-
Notifications
You must be signed in to change notification settings - Fork 0
106 see if kaon properties can be configured at runtime patch #110
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,16 +18,22 @@ KaonPhysics::KaonPhysics(const G4String& name, | |
parameters.getParameter<double>("kminus_lifetime_factor"); | ||
k0l_lifetime_factor = parameters.getParameter<double>("k0l_lifetime_factor"); | ||
k0s_lifetime_factor = parameters.getParameter<double>("k0s_lifetime_factor"); | ||
verbosity = parameters.getParameter<int>("verbosity"); | ||
} | ||
void KaonPhysics::setDecayProperties( | ||
G4ParticleDefinition* kaon, const std::vector<double>& branching_ratios, | ||
double lifetime_factor) const { | ||
kaon->SetPDGLifeTime(kaon->GetPDGLifeTime() * lifetime_factor); | ||
auto table{kaon->GetDecayTable()}; | ||
if (!table) { | ||
EXCEPTION_RAISE("KaonPhysics", "Unable to get the decay table from " + | ||
kaon->GetParticleName()); | ||
} | ||
if (verbosity > 1) { | ||
std::cout << "Decay details after setting branching ratios and lifetimes" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here and other places, would it be possible to use the logger instead of standard printouts? I see a use case where we use these modifications routinely and would only want to see details at debug or info level. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, although I'm not familiar with how to do that with things in LDMX-sw that aren't processors There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Basically I also wrote another macro https://ldmx-software.github.io/Logging.html#more-detail-logging-outside-processors There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Me neither :) hence the hesitation. To be clear I think a combination of the local verbosity and the log level is the best way to do it in that case, so this suggestion is just about where the message is directed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, was straight-forward to do although the enableLogging macro didn't play nicely by default with the namespace I was in so had to do mutable framework::logging::logger theLog_{
framework::logging::makeLogger("KaonPhysics")}; directly. Not the end of the world I guess You run into something like /Users/einarelen/ldmx/ldmx-sw/Framework/include/Framework/Logger.h:137:11: error: 'logging' does not name a type; did you mean 'long'?
137 | mutable logging::logger theLog_{logging::makeLogger(name)};
| ^~~~~~~
/Users/einarelen/ldmx/ldmx-sw/Framework/include/Framework/Logger.h:137:11: note: in definition of macro 'enableLogging'
137 | mutable logging::logger theLog_{logging::makeLogger(name)};
| ^~~~~~~ |
||
<< std::endl; | ||
DumpDecayDetails(kaon); | ||
} | ||
kaon->SetPDGLifeTime(kaon->GetPDGLifeTime() * lifetime_factor); | ||
if (kaon == G4KaonZeroLong::Definition()) { | ||
(*table)[KaonZeroLongDecayChannel::pi0_pi0_pi0]->SetBR( | ||
branching_ratios[KaonZeroLongDecayChannel::pi0_pi0_pi0]); | ||
|
@@ -60,6 +66,11 @@ void KaonPhysics::setDecayProperties( | |
(*table)[ChargedKaonDecayChannel::pi0_mu_nu]->SetBR( | ||
branching_ratios[ChargedKaonDecayChannel::pi0_mu_nu]); | ||
} | ||
if (verbosity > 0) { | ||
std::cout << "Decay details after setting branching ratios and lifetimes" | ||
<< std::endl; | ||
DumpDecayDetails(kaon); | ||
} | ||
} | ||
void KaonPhysics::ConstructParticle() { | ||
auto kaonPlus{G4KaonPlus::Definition()}; | ||
|
@@ -79,4 +90,27 @@ void KaonPhysics::ConstructParticle() { | |
setDecayProperties(kaonShort, k0s_branching_ratios, k0s_lifetime_factor); | ||
} | ||
|
||
void KaonPhysics::DumpDecayDetails(const G4ParticleDefinition* kaon) const { | ||
std::cout << "Decay table details for " << kaon->GetParticleName() | ||
<< std::endl | ||
<< std::scientific << std::setprecision(15); | ||
std::cout << "PDG Lifetime " << kaon->GetPDGLifeTime() << std::endl; | ||
const auto table{kaon->GetDecayTable()}; | ||
const int entries{table->entries()}; | ||
for (auto i{0}; i < entries; ++i) { | ||
const auto channel{(*table)[i]}; | ||
std::cout << "Channel " << i << " Kinematics type " | ||
<< channel->GetKinematicsName() << " with BR " << channel->GetBR() | ||
<< std::endl; | ||
std::cout << kaon->GetParticleName() << " -> "; | ||
const auto daughters{channel->GetNumberOfDaughters()}; | ||
for (auto j{0}; j < daughters - 1; ++j) { | ||
std::cout << channel->GetDaughter(j)->GetParticleName() << " + "; | ||
} | ||
// Special formatting for last one :) | ||
std::cout << channel->GetDaughter(daughters - 1)->GetParticleName() | ||
<< std::endl; | ||
} | ||
} | ||
|
||
} // namespace simcore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps this should be "must be" rather than "is", if I understood the bug correctly? If I'm right, I think the stronger language will be more helpful for the future developer reading the comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and same on L52