1#include "TRestGeant4ParticleSourceDecay0.h"
7TRestGeant4ParticleSourceDecay0::TRestGeant4ParticleSourceDecay0()
9 fDecay0Model =
new bxdecay0::decay0_generator();
13 RESTMetadata <<
"---------------------------------------" <<
RESTendl;
14 if (!fParticleName.empty() && fParticleName !=
"NO_SUCH_PARA")
15 RESTMetadata <<
"Particle Source Name: " << fParticleName <<
RESTendl;
16 RESTMetadata <<
"Parent Nuclide: " << fParentName <<
RESTendl;
17 RESTMetadata <<
"Decay Mode: " << fDecayType <<
RESTendl;
18 RESTMetadata <<
"Daughter Level: " << fDaughterLevel <<
RESTendl;
19 RESTMetadata <<
"Seed: " << fSeed <<
RESTendl;
33 fSeed = (uintptr_t)
this;
35 generator =
new std::default_random_engine(fSeed);
36 prng =
new bxdecay0::std_random(*generator);
38 fDecay0Model->set_decay_category(bxdecay0::decay0_generator::DECAY_CATEGORY_DBD);
40 if (fParentName !=
"Xe136") {
41 ferr <<
"Only Xe136 double beta decay is supported by restDecay0" << endl;
44 if (fDaughterLevel < 0 || fDaughterLevel > 3) {
45 ferr <<
"Supported Ba136 excitation level: 0, 1, 2, 3" << endl;
49 fDecay0Model->set_decay_isotope(fParentName);
51 fDecay0Model->set_decay_dbd_level(fDaughterLevel);
53 if (fDecayType ==
"2vbb") {
54 if (fDaughterLevel == 0 || fDaughterLevel == 3) {
55 fDecay0Model->set_decay_dbd_mode(bxdecay0::DBDMODE_2NUBB_0_2N);
56 }
else if (fDaughterLevel == 1 || fDaughterLevel == 2) {
57 fDecay0Model->set_decay_dbd_mode(bxdecay0::DBDMODE_2NUBB_2_2N);
59 }
else if (fDecayType ==
"0vbb") {
60 if (fDaughterLevel == 0 || fDaughterLevel == 3) {
61 fDecay0Model->set_decay_dbd_mode(bxdecay0::DBDMODE_0NUBB_MN_0_2N);
62 }
else if (fDaughterLevel == 1 || fDaughterLevel == 2) {
63 fDecay0Model->set_decay_dbd_mode(bxdecay0::DBDMODE_0NUBB_RHC_LAMBDA_2_2N);
67 fDecay0Model->initialize(*prng);
72void TRestGeant4ParticleSourceDecay0::Update() {
75 bxdecay0::event gendecay;
76 fDecay0Model->shoot(*prng, gendecay);
78 auto ps = gendecay.get_particles();
84 double momx = p.get_px();
85 double momy = p.get_py();
86 double momz = p.get_pz();
87 double momentum2 = p.get_p() * p.get_p();
88 int pID = p.get_code();
101 energy = TMath::Sqrt(momentum2);
102 particle.SetParticleName(
"gamma");
103 particle.SetParticleCharge(0);
104 particle.SetExcitationLevel(0);
105 }
else if (pID == 2) {
107 energy = TMath::Sqrt(momentum2);
108 particle.SetParticleName(
"positron");
109 particle.SetParticleCharge(1);
110 particle.SetExcitationLevel(0);
111 }
else if (pID == 3) {
113 energy = TMath::Sqrt(momentum2 + mass * mass) - mass;
114 particle.SetParticleName(
"e-");
115 particle.SetParticleCharge(-1);
116 particle.SetExcitationLevel(0);
117 }
else if (pID == 13) {
119 energy = TMath::Sqrt(momentum2);
120 particle.SetParticleName(
"neutron");
121 particle.SetParticleCharge(0);
122 particle.SetExcitationLevel(0);
123 }
else if (pID == 14) {
125 energy = TMath::Sqrt(momentum2);
126 particle.SetParticleName(
"proton");
127 particle.SetParticleCharge(1);
128 particle.SetExcitationLevel(0);
129 }
else if (pID == 47) {
131 energy = TMath::Sqrt(momentum2);
132 particle.SetParticleName(
"alpha");
133 particle.SetParticleCharge(2);
134 particle.SetExcitationLevel(0);
137 TVector3 momDirection(momx, momy, momz);
138 momDirection = momDirection.Unit();
140 particle.SetEnergy(1000. * energy);
141 particle.SetDirection(momDirection);
145 AddParticle(particle);
void InitFromConfigFile() override
To make settings from rml file. This method must be implemented in the derived class.
void PrintMetadata() override
Implemented it in the derived metadata class to print out specific metadata information.
A class used to store particle properties.
Int_t StringToInteger(std::string in)
Gets an integer from a string.