20#include "BDSOutputROOTParticleData.hh"
25#include "G4IonTable.hh"
26#include "G4NuclideTable.hh"
27#include "G4ParticleDefinition.hh"
28#include "G4ParticleTable.hh"
36BDSOutputROOTParticleData::BDSOutputROOTParticleData()
47 auto result = particles.find(pdgID);
48 if (result != particles.end())
49 {
return result->second;}
51 {
return ParticleInfo();}
56 auto result = ions.find(pdgID);
57 if (result != ions.end())
58 {
return result->second;}
63int BDSOutputROOTParticleData::Charge(
const int& pdgID)
const
67 auto result = ions.find(pdgID);
68 if (result != ions.end())
69 {
return result->second.charge;}
75 auto result = particles.find(pdgID);
76 if (result != particles.end())
77 {
return result->second.charge;}
83double BDSOutputROOTParticleData::Mass(
const int& pdgID)
const
87 auto result = ions.find(pdgID);
88 if (result != ions.end())
89 {
return result->second.mass;}
95 auto result = particles.find(pdgID);
96 if (result != particles.end())
97 {
return result->second.mass;}
104 const double& totalEnergy)
const
108 auto result = ions.find(pdgID);
109 if (result != ions.end())
110 {
return result->second.rigidity(totalEnergy);}
116 auto result = particles.find(pdgID);
117 if (result != particles.end())
118 {
return result->second.rigidity(totalEnergy);}
125 const double& totalEnergy)
const
129 auto result = ions.find(pdgID);
130 if (result != ions.end())
131 {
return totalEnergy - result->second.mass;}
137 auto result = particles.find(pdgID);
138 if (result != particles.end())
139 {
return totalEnergy - result->second.mass;}
145std::string BDSOutputROOTParticleData::Name(
const int& pdgID)
const
149 auto result = ions.find(pdgID);
150 if (result != ions.end())
151 {
return result->second.name;}
157 auto result = particles.find(pdgID);
158 if (result != particles.end())
159 {
return result->second.name;}
165int BDSOutputROOTParticleData::IonA(
const int& pdgID)
const
169 auto result = ions.find(pdgID);
170 if (result != ions.end())
171 {
return result->second.a;}
175 else if (pdgID == 2212)
181int BDSOutputROOTParticleData::IonZ(
const int& pdgID)
const
185 auto result = ions.find(pdgID);
186 if (result != ions.end())
187 {
return result->second.z;}
191 else if (pdgID == 2212)
200 G4ParticleTable* pt = G4ParticleTable::GetParticleTable();
203 auto it = pt->GetIterator();
207 const G4ParticleDefinition* particle = it->value();
208 const G4String& particleName = particle->GetParticleName();
210 int pdgID =
static_cast<int>(particle->GetPDGEncoding());
213 (
int)particle->GetPDGCharge(),
214 (double)particle->GetPDGMass()/CLHEP::GeV};
215 particles[pdgID] = info;
225 G4IonTable* ionTable = pt->GetIonTable();
226 G4NuclideTable* table = G4NuclideTable::GetInstance();
227 unsigned int number = (
unsigned int)table->GetSizeOfIsotopeList();
228 for (
unsigned int i = 0; i < number; i++)
230 G4IsotopeProperty* iso = table->GetIsotopeByIndex(i);
231 int atmass = iso->GetAtomicMass();
232 int atnum = iso->GetAtomicNumber();
233 double eng = iso->GetEnergy();
235 G4ParticleDefinition* def = ionTable->GetIon(atnum, atmass, eng);
239 (int)def->GetPDGCharge(),
240 (double)def->GetPDGMass()/CLHEP::GeV,
241 (int)def->GetAtomicMass(),
242 (int)def->GetAtomicNumber()};
243 ions[def->GetPDGEncoding()] = ionDef;
Geant4 particle data for particles used in simulation.
bool IsIon(const int &pdgID) const
This doesn't count a proton (even with electrons) as an ion.
void Fill(G4bool fillIons)
Fill maps of particle information from Geant4.
double KineticEnergy(const int &pdgID, const double &totalEnergy) const
Calculate kinetic energy of particle given PDG ID and total energy in GeV.
virtual void Flush()
Clear maps.
double Rigidity(const int &pdgID, const double &totalEnergy) const
Calculate rigidity of particle given PDG ID and total energy in GeV.
Simple particle information to be stored per ion specifically.
Simple particle information to be stored per particle.