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

Commit 11bfe4f

Browse files
EinarElentomeichlersmith
authored andcommitted
Add verbosity setting
1 parent 6818809 commit 11bfe4f

3 files changed

Lines changed: 23 additions & 0 deletions

File tree

include/SimCore/KaonPhysics.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ class KaonPhysics : public G4VPhysicsConstructor {
104104
std::vector<double> k0l_branching_ratios;
105105
std::vector<double> k0s_branching_ratios;
106106

107+
// If > 0, dump details about what was changed
108+
// If > 1, dump details about the initial branching ratios
109+
int verbosity;
107110
public:
108111
KaonPhysics(const G4String& name,
109112
const framework::config::Parameters& parameters);

python/kaon_physics.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ class KaonPhysics():
4343
Multiplicative factor to scale the lifetime of kaons by. Default is to
4444
scale by 1 (no scaling)
4545
46+
verbosity : int
47+
48+
If > 0: Dump details about the decay after the update
49+
If > 1: Also dump details about the decay before the update to show the
50+
difference
51+
4652
"""
4753
def __init__(self):
4854
self.kplus_branching_ratios = [
@@ -78,6 +84,8 @@ def __init__(self):
7884
self.k0l_lifetime_factor = 1.
7985
self.k0s_lifetime_factor = 1.
8086

87+
self.verbosity=0
88+
8189

8290
def upKaons():
8391
"""Returns a configuration of the kaon physics corresponding
@@ -109,6 +117,7 @@ def upKaons():
109117
]
110118
kaon_physics.kplus_lifetime_factor = 1/50.
111119
kaon_physics.kminus_lifetime_factor = 1/50.
120+
kaon_physics.verbosity = 2
112121
return kaon_physics
113122

114123
def __setattr__(self, key, value):

src/SimCore/KaonPhysics.cxx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ KaonPhysics::KaonPhysics(const G4String& name,
1818
parameters.getParameter<double>("kminus_lifetime_factor");
1919
k0l_lifetime_factor = parameters.getParameter<double>("k0l_lifetime_factor");
2020
k0s_lifetime_factor = parameters.getParameter<double>("k0s_lifetime_factor");
21+
verbosity = parameters.getParameter<int>("verbosity");
2122
}
2223
void KaonPhysics::setDecayProperties(
2324
G4ParticleDefinition* kaon, const std::vector<double>& branching_ratios,
@@ -28,6 +29,11 @@ void KaonPhysics::setDecayProperties(
2829
EXCEPTION_RAISE("KaonPhysics", "Unable to get the decay table from " +
2930
kaon->GetParticleName());
3031
}
32+
if (verbosity > 1) {
33+
std::cout << "Decay details after setting branching ratios and lifetimes"
34+
<< std::endl;
35+
DumpDecayDetails(kaon);
36+
}
3137
if (kaon == G4KaonZeroLong::Definition()) {
3238
(*table)[KaonZeroLongDecayChannel::pi0_pi0_pi0]->SetBR(
3339
branching_ratios[KaonZeroLongDecayChannel::pi0_pi0_pi0]);
@@ -60,6 +66,11 @@ void KaonPhysics::setDecayProperties(
6066
(*table)[ChargedKaonDecayChannel::pi0_mu_nu]->SetBR(
6167
branching_ratios[ChargedKaonDecayChannel::pi0_mu_nu]);
6268
}
69+
if (verbosity > 0) {
70+
std::cout << "Decay details after setting branching ratios and lifetimes"
71+
<< std::endl;
72+
DumpDecayDetails(kaon);
73+
}
6374
}
6475
void KaonPhysics::ConstructParticle() {
6576
auto kaonPlus{G4KaonPlus::Definition()};

0 commit comments

Comments
 (0)