19#include "BDSOutputROOTParticleData.hh"
24#include "G4IonTable.hh"
25#include "G4NuclideTable.hh"
26#include "G4ParticleDefinition.hh"
27#include "G4ParticleTable.hh"
35BDSOutputROOTParticleData::BDSOutputROOTParticleData()
46 auto result = particles.find(pdgID);
47 if (result != particles.end())
48 {
return result->second;}
50 {
return ParticleInfo();}
55 auto result = ions.find(pdgID);
56 if (result != ions.end())
57 {
return result->second;}
62int BDSOutputROOTParticleData::Charge(
const int& pdgID)
const
66 auto result = ions.find(pdgID);
67 if (result != ions.end())
68 {
return result->second.charge;}
74 auto result = particles.find(pdgID);
75 if (result != particles.end())
76 {
return result->second.charge;}
82double BDSOutputROOTParticleData::Mass(
const int& pdgID)
const
86 auto result = ions.find(pdgID);
87 if (result != ions.end())
88 {
return result->second.mass;}
94 auto result = particles.find(pdgID);
95 if (result != particles.end())
96 {
return result->second.mass;}
103 const double& totalEnergy)
const
107 auto result = ions.find(pdgID);
108 if (result != ions.end())
109 {
return result->second.rigidity(totalEnergy);}
115 auto result = particles.find(pdgID);
116 if (result != particles.end())
117 {
return result->second.rigidity(totalEnergy);}
124 const double& totalEnergy)
const
128 auto result = ions.find(pdgID);
129 if (result != ions.end())
130 {
return totalEnergy - result->second.mass;}
136 auto result = particles.find(pdgID);
137 if (result != particles.end())
138 {
return totalEnergy - result->second.mass;}
144std::string BDSOutputROOTParticleData::Name(
const int& pdgID)
const
148 auto result = ions.find(pdgID);
149 if (result != ions.end())
150 {
return result->second.name;}
156 auto result = particles.find(pdgID);
157 if (result != particles.end())
158 {
return result->second.name;}
164int BDSOutputROOTParticleData::IonA(
const int& pdgID)
const
168 auto result = ions.find(pdgID);
169 if (result != ions.end())
170 {
return result->second.a;}
174 else if (pdgID == 2212)
180int BDSOutputROOTParticleData::IonZ(
const int& pdgID)
const
184 auto result = ions.find(pdgID);
185 if (result != ions.end())
186 {
return result->second.z;}
190 else if (pdgID == 2212)
199 G4ParticleTable* pt = G4ParticleTable::GetParticleTable();
202 auto it = pt->GetIterator();
206 const G4ParticleDefinition* particle = it->value();
207 const G4String& particleName = particle->GetParticleName();
209 int pdgID =
static_cast<int>(particle->GetPDGEncoding());
212 (
int)particle->GetPDGCharge(),
213 (double)particle->GetPDGMass()/CLHEP::GeV};
214 particles[pdgID] = info;
224 G4IonTable* ionTable = pt->GetIonTable();
225 G4NuclideTable* table = G4NuclideTable::GetInstance();
226 unsigned int number = (
unsigned int)table->GetSizeOfIsotopeList();
227 for (
unsigned int i = 0; i < number; i++)
229 G4IsotopeProperty* iso = table->GetIsotopeByIndex(i);
230 int atmass = iso->GetAtomicMass();
231 int atnum = iso->GetAtomicNumber();
232 double eng = iso->GetEnergy();
234 G4ParticleDefinition* def = ionTable->GetIon(atnum, atmass, eng);
238 (int)def->GetPDGCharge(),
239 (double)def->GetPDGMass()/CLHEP::GeV,
240 (int)def->GetAtomicMass(),
241 (int)def->GetAtomicNumber()};
242 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.