LDMX Software
simcore::KaonPhysics Class Reference

Allows the configuration of properties of kaons produced in the simulation, in particular setting their lifetime and branching ratios. More...

#include <KaonPhysics.h>

Public Member Functions

 KaonPhysics (const G4String &name, const framework::config::Parameters &parameters)
 
void setDecayProperties (G4ParticleDefinition *kaon, const std::vector< double > &branching_ratios, double lifetime_factor) const
 Set the lifetime and branching ratios for one of the kaon species.
 
void ConstructParticle () override
 Construct/Update particles.
 
void dumpDecayDetails (const G4ParticleDefinition *kaon) const
 
void ConstructProcess () override
 Construct processes.
 

Private Types

enum  ChargedKaonDecayChannel {
  mu_nu = 0 , pi_pi0 = 1 , pi_pi_pi = 2 , pi0_e_nu = 3 ,
  pi0_mu_nu = 4 , pi_pi0_pi0 = 5
}
 Represents the 6 possible decay channels for charged kaons in Geant4 (See G4KaonMinus.cc and G4KaonPlus.cc in the Geant4 sources) in the order they appear in the decay table. More...
 
enum  KaonZeroLongDecayChannel {
  pim_e_nu = 0 , pip_e_nu = 1 , pi0_pi0_pi0 = 2 , pim_mu_nu = 3 ,
  pip_mu_nu = 4 , pi0_pip_pim = 5
}
 Corresponding entries for the K^0_L. More...
 
enum  KaonZeroShortDecayChannel { pip_pim = 0 , pi0_pi0 = 1 }
 

Private Attributes

double kplus_lifetime_factor_ {1}
 
double kminus_lifetime_factor_ {1}
 
double k0l_lifetime_factor_ {1}
 
double k0s_lifetime_factor_ {1}
 
std::vector< double > kplus_branching_ratios_
 
std::vector< double > kminus_branching_ratios_
 
std::vector< double > k0l_branching_ratios_
 
std::vector< double > k0s_branching_ratios_
 
framework::logging::logger the_log_
 

Detailed Description

Allows the configuration of properties of kaons produced in the simulation, in particular setting their lifetime and branching ratios.

Definition at line 32 of file KaonPhysics.h.

Member Enumeration Documentation

◆ ChargedKaonDecayChannel

Represents the 6 possible decay channels for charged kaons in Geant4 (See G4KaonMinus.cc and G4KaonPlus.cc in the Geant4 sources) in the order they appear in the decay table.

The processes are K^+ -> \mu^+ + \nu_\mu K^+ -> \pi^+ + \pi^0 K^+ -> \pi^+ + \pi^- + \pi^+ K^+ -> \pi^0 + e^+ + \nu_e K^+ -> \pi^0 + \mu^+ + \nu_\mu K^+ -> \pi^+ + \pi^0 + \pi^0

And vice versa for K^-. The indices here correspond to the position of the branching ratio for that process in the corresponding parameter as well as the position in the decay table.

Note
: The order in the the decay table is sorted by the branching ratios of the default physics settings since G4DecayTable::insert sorts its entries by branching ratio!

Definition at line 59 of file KaonPhysics.h.

59 {
60 mu_nu = 0,
61 pi_pi0 = 1,
62 pi_pi_pi = 2,
63 pi0_e_nu = 3,
64 pi0_mu_nu = 4,
65 pi_pi0_pi0 = 5,
66 };

◆ KaonZeroLongDecayChannel

Corresponding entries for the K^0_L.

Note that K^0_L and K^0_S decays are not symmetric like the charged ones so they need to be handled manually.

The processes are

K^0_L -> \pi^- + e^+ + \nu_e K^0_L -> \pi^+ + e^- + \nu_e K^0_L -> \pi^0 + \pi^0 + \pi^0 K^0_L -> \pi^- + \mu^+ + \nu_\mu K^0_L -> \pi^+ + \mu^- + \nu_\mu K^0_L -> \pi^0 + \pi^+ + \pi^-

and

K^0_S -> \pi^+ + \pi^- K^0_S -> \pi^0 + \pi^0

Note
: The order in the the decay table is sorted by the branching ratios of the default physics settings since G4DecayTable::insert sorts its entries by branching ratio!

Definition at line 91 of file KaonPhysics.h.

91 {
92 pim_e_nu = 0,
93 pip_e_nu = 1,
94 pi0_pi0_pi0 = 2,
95 pim_mu_nu = 3,
96 pip_mu_nu = 4,
97 pi0_pip_pim = 5,
98 };

◆ KaonZeroShortDecayChannel

enum simcore::KaonPhysics::KaonZeroShortDecayChannel
private

Definition at line 99 of file KaonPhysics.h.

99 {
100 pip_pim = 0,
101 pi0_pi0 = 1,
102 };

Constructor & Destructor Documentation

◆ KaonPhysics()

simcore::KaonPhysics::KaonPhysics ( const G4String & name,
const framework::config::Parameters & parameters )

Definition at line 4 of file KaonPhysics.cxx.

6 : G4VPhysicsConstructor(name) {
7 kplus_branching_ratios_ =
8 parameters.get<std::vector<double>>("kplus_branching_ratios");
9 kminus_branching_ratios_ =
10 parameters.get<std::vector<double>>("kminus_branching_ratios");
11 k0l_branching_ratios_ =
12 parameters.get<std::vector<double>>("k0l_branching_ratios");
13 k0s_branching_ratios_ =
14 parameters.get<std::vector<double>>("k0s_branching_ratios");
15 kplus_lifetime_factor_ = parameters.get<double>("kplus_lifetime_factor");
16 kminus_lifetime_factor_ = parameters.get<double>("kminus_lifetime_factor");
17 k0l_lifetime_factor_ = parameters.get<double>("k0l_lifetime_factor");
18 k0s_lifetime_factor_ = parameters.get<double>("k0s_lifetime_factor");
19}
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:78

Member Function Documentation

◆ ConstructParticle()

void simcore::KaonPhysics::ConstructParticle ( )
override

Construct/Update particles.

Update the particle definitions for charged kaons

  1. Scale their lifetime by the corresponding lifetime factor
  2. Set their branching ratios to those in the corresponding branching raito parameter

Definition at line 69 of file KaonPhysics.cxx.

69 {
70 auto kaon_plus{G4KaonPlus::Definition()};
71 auto kaon_minus{G4KaonMinus::Definition()};
72 auto kaon_long{G4KaonZeroLong::Definition()};
73 auto kaon_short{G4KaonZeroShort::Definition()};
74
75 if (!kaon_plus || !kaon_minus || !kaon_long || !kaon_short) {
76 EXCEPTION_RAISE("KaonPhysics",
77 "Unable to get the charged kaon particle definitions, "
78 "something is very wrong with the configuration.");
79 }
80 setDecayProperties(kaon_plus, kplus_branching_ratios_,
81 kplus_lifetime_factor_);
82 setDecayProperties(kaon_minus, kminus_branching_ratios_,
83 kminus_lifetime_factor_);
84 setDecayProperties(kaon_long, k0l_branching_ratios_, k0l_lifetime_factor_);
85 setDecayProperties(kaon_short, k0s_branching_ratios_, k0s_lifetime_factor_);
86}
void setDecayProperties(G4ParticleDefinition *kaon, const std::vector< double > &branching_ratios, double lifetime_factor) const
Set the lifetime and branching ratios for one of the kaon species.

◆ ConstructProcess()

void simcore::KaonPhysics::ConstructProcess ( )
inlineoverride

Construct processes.

We don't do anything here since we are just attaching/updating the kaon particle definitions.

Definition at line 151 of file KaonPhysics.h.

151{};

◆ dumpDecayDetails()

void simcore::KaonPhysics::dumpDecayDetails ( const G4ParticleDefinition * kaon) const

Definition at line 88 of file KaonPhysics.cxx.

88 {
89 ldmx_log(trace) << "Decay table details for " << kaon->GetParticleName()
90 << std::scientific << std::setprecision(15)
91 << " (PDG Lifetime " << kaon->GetPDGLifeTime() << ")"
92 << std::endl;
93 auto* table{kaon->GetDecayTable()};
94 if (not table) {
95 ldmx_log(error) << "No Kaon decay table.";
96 return;
97 }
98 const int entries{table->entries()};
99 for (auto i{0}; i < entries; ++i) {
100 const auto channel{(*table)[i]};
101 const auto daughters{channel->GetNumberOfDaughters()};
102 std::string products{};
103 // N-1 to avoid extra " + "
104 for (auto j{0}; j < daughters; ++j) {
105 auto* d{channel->GetDaughter(j)};
106 if (d) {
107 products += d->GetParticleName();
108 } else {
109 products += "NULL";
110 }
111 if (j < daughters - 1) {
112 // only add '+' when there are more to come
113 products += " + ";
114 }
115 }
116 ldmx_log(trace) << "Channel " << i << " (" << kaon->GetParticleName()
117 << " -> " << products << ") Kinematics type "
118 << channel->GetKinematicsName() << " with BR "
119 << channel->GetBR() << std::endl;
120 }
121}

◆ setDecayProperties()

void simcore::KaonPhysics::setDecayProperties ( G4ParticleDefinition * kaon,
const std::vector< double > & branching_ratios,
double lifetime_factor ) const

Set the lifetime and branching ratios for one of the kaon species.

Definition at line 20 of file KaonPhysics.cxx.

22 {
23 auto table{kaon->GetDecayTable()};
24 if (!table) {
25 EXCEPTION_RAISE("KaonPhysics", "Unable to get the decay table from " +
26 kaon->GetParticleName());
27 }
28 ldmx_log(trace) << "Decay details (" << kaon->GetParticleName()
29 << ") before setting branching ratios and lifetimes";
30 dumpDecayDetails(kaon);
31 kaon->SetPDGLifeTime(kaon->GetPDGLifeTime() * lifetime_factor);
32 if (kaon == G4KaonZeroLong::Definition()) {
33 (*table)[KaonZeroLongDecayChannel::pi0_pi0_pi0]->SetBR(
34 branching_ratios[KaonZeroLongDecayChannel::pi0_pi0_pi0]);
35 (*table)[KaonZeroLongDecayChannel::pi0_pip_pim]->SetBR(
36 branching_ratios[KaonZeroLongDecayChannel::pi0_pip_pim]);
37 (*table)[KaonZeroLongDecayChannel::pip_e_nu]->SetBR(
38 branching_ratios[KaonZeroLongDecayChannel::pip_e_nu]);
39 (*table)[KaonZeroLongDecayChannel::pim_e_nu]->SetBR(
40 branching_ratios[KaonZeroLongDecayChannel::pim_e_nu]);
41 (*table)[KaonZeroLongDecayChannel::pim_mu_nu]->SetBR(
42 branching_ratios[KaonZeroLongDecayChannel::pim_mu_nu]);
43 (*table)[KaonZeroLongDecayChannel::pip_mu_nu]->SetBR(
44 branching_ratios[KaonZeroLongDecayChannel::pip_mu_nu]);
45 } else if (kaon == G4KaonZeroShort::Definition()) {
46 (*table)[KaonZeroShortDecayChannel::pip_pim]->SetBR(
47 branching_ratios[KaonZeroShortDecayChannel::pip_pim]);
48 (*table)[KaonZeroShortDecayChannel::pi0_pi0]->SetBR(
49 branching_ratios[KaonZeroShortDecayChannel::pi0_pi0]);
50 } else {
51 (*table)[ChargedKaonDecayChannel::mu_nu]->SetBR(
52 branching_ratios[ChargedKaonDecayChannel::mu_nu]);
53 (*table)[ChargedKaonDecayChannel::pi_pi0]->SetBR(
54 branching_ratios[ChargedKaonDecayChannel::pi_pi0]);
55 (*table)[ChargedKaonDecayChannel::pi_pi_pi]->SetBR(
56 branching_ratios[ChargedKaonDecayChannel::pi_pi_pi]);
57 (*table)[ChargedKaonDecayChannel::pi_pi0_pi0]->SetBR(
58 branching_ratios[ChargedKaonDecayChannel::pi_pi0_pi0]);
59 (*table)[ChargedKaonDecayChannel::pi0_e_nu]->SetBR(
60 branching_ratios[ChargedKaonDecayChannel::pi0_e_nu]);
61 (*table)[ChargedKaonDecayChannel::pi0_mu_nu]->SetBR(
62 branching_ratios[ChargedKaonDecayChannel::pi0_mu_nu]);
63 }
64 ldmx_log(trace) << "Decay details (" << kaon->GetParticleName()
65 << ") after setting branching ratios and lifetimes"
66 << std::endl;
67 dumpDecayDetails(kaon);
68}

Member Data Documentation

◆ k0l_branching_ratios_

std::vector<double> simcore::KaonPhysics::k0l_branching_ratios_
private

Definition at line 115 of file KaonPhysics.h.

◆ k0l_lifetime_factor_

double simcore::KaonPhysics::k0l_lifetime_factor_ {1}
private

Definition at line 108 of file KaonPhysics.h.

108{1};

◆ k0s_branching_ratios_

std::vector<double> simcore::KaonPhysics::k0s_branching_ratios_
private

Definition at line 116 of file KaonPhysics.h.

◆ k0s_lifetime_factor_

double simcore::KaonPhysics::k0s_lifetime_factor_ {1}
private

Definition at line 109 of file KaonPhysics.h.

109{1};

◆ kminus_branching_ratios_

std::vector<double> simcore::KaonPhysics::kminus_branching_ratios_
private

Definition at line 114 of file KaonPhysics.h.

◆ kminus_lifetime_factor_

double simcore::KaonPhysics::kminus_lifetime_factor_ {1}
private

Definition at line 107 of file KaonPhysics.h.

107{1};

◆ kplus_branching_ratios_

std::vector<double> simcore::KaonPhysics::kplus_branching_ratios_
private

Definition at line 113 of file KaonPhysics.h.

◆ kplus_lifetime_factor_

double simcore::KaonPhysics::kplus_lifetime_factor_ {1}
private

Definition at line 106 of file KaonPhysics.h.

106{1};

◆ the_log_

framework::logging::logger simcore::KaonPhysics::the_log_
mutableprivate
Initial value:
{
framework::logging::makeLogger("KaonPhysics")}

Definition at line 154 of file KaonPhysics.h.

154 {
155 framework::logging::makeLogger("KaonPhysics")};

The documentation for this class was generated from the following files: