Skip to content
This repository was archived by the owner on May 6, 2024. It is now read-only.

Commit 6818809

Browse files
EinarElentomeichlersmith
authored andcommitted
Add helper function to write out details
1 parent 4b6c819 commit 6818809

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

include/SimCore/KaonPhysics.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include <G4ParticleDefinition.hh>
1010
#include <G4VDecayChannel.hh>
1111
#include <G4VPhysicsConstructor.hh>
12+
#include <iomanip>
13+
#include <iostream>
1214
#include <numeric>
1315
#include <vector>
1416

@@ -127,6 +129,8 @@ class KaonPhysics : public G4VPhysicsConstructor {
127129

128130
void ConstructParticle() override;
129131

132+
void DumpDecayDetails(const G4ParticleDefinition* kaon) const;
133+
130134
/**
131135
* Construct processes
132136
*

src/SimCore/KaonPhysics.cxx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,26 @@ void KaonPhysics::ConstructParticle() {
7979
setDecayProperties(kaonShort, k0s_branching_ratios, k0s_lifetime_factor);
8080
}
8181

82+
void KaonPhysics::DumpDecayDetails(const G4ParticleDefinition* kaon) const {
83+
std::cout << "Decay table details for " << kaon->GetParticleName()
84+
<< std::endl
85+
<< std::scientific << std::setprecision(15);
86+
std::cout << "PDG Lifetime " << kaon->GetPDGLifeTime() << std::endl;
87+
const auto table{kaon->GetDecayTable()};
88+
const int entries{table->entries()};
89+
for (auto i{0}; i < entries; ++i) {
90+
const auto channel{(*table)[i]};
91+
std::cout << "Channel " << i << " Kinematics type "
92+
<< channel->GetKinematicsName() << " with BR " << channel->GetBR()
93+
<< std::endl;
94+
std::cout << kaon->GetParticleName() << " -> ";
95+
const auto daughters{channel->GetNumberOfDaughters()};
96+
for (auto j{0}; j < daughters - 1; ++j) {
97+
std::cout << channel->GetDaughter(j)->GetParticleName() << " + ";
98+
}
99+
// Special formatting for last one :)
100+
std::cout << channel->GetDaughter(daughters - 1)->GetParticleName()
101+
<< std::endl;
102+
}
103+
}
82104
} // namespace simcore

0 commit comments

Comments
 (0)