18#include "BDSOutputROOTEventSamplerS.hh"
19#include "BDSOutputROOTParticleData.hh"
26#include "BDSHitSamplerSphere.hh"
27#include "BDSParticleCoordsSpherical.hh"
28#include "BDSPhysicalConstants.hh"
29#include "BDSPrimaryVertexInformationV.hh"
32#include "CLHEP/Units/SystemOfUnits.h"
40BDSOutputROOTEventSamplerS::BDSOutputROOTEventSamplerS():
41 samplerName(
"samplersphere")
46BDSOutputROOTEventSamplerS::BDSOutputROOTEventSamplerS(
const std::string& samplerNameIn):
47 samplerName(samplerNameIn)
52BDSOutputROOTEventSamplerS::~BDSOutputROOTEventSamplerS()
59 G4bool storeElectrons,
61 G4bool storeKineticEnergy)
65 totalEnergy.push_back(
static_cast<float>(hit->totalEnergy / CLHEP::GeV));
66 theta.push_back(
static_cast<float>(hit->coords.theta / CLHEP::radian));
67 phi.push_back(
static_cast<float>(hit->coords.phi / CLHEP::radian));
68 rp.push_back(
static_cast<float>(hit->coords.rp));
69 thetap.push_back(
static_cast<float>(hit->coords.thetap));
70 phip.push_back(
static_cast<float>(hit->coords.phip));
71 p.push_back(
static_cast<float>(hit->momentum / CLHEP::GeV));
72 T.push_back(
static_cast<float>(hit->coords.T / CLHEP::ns));
74 weight.push_back(
static_cast<float>(hit->weight));
75 partID.push_back(hit->pdgID);
76 parentID.push_back(hit->parentID);
77 trackID.push_back(hit->trackID);
78 modelID = hit->beamlineIndex;
79 turnNumber.push_back(hit->turnsTaken);
81 S =
static_cast<float>(hit->S / CLHEP::m);
84 {
mass.push_back(
static_cast<float>(hit->mass / CLHEP::GeV));}
87 {
charge.push_back(
static_cast<int>(hit->
charge / (G4double)CLHEP::eplus));}
89 if (storeKineticEnergy)
90 {
kineticEnergy.push_back(
static_cast<float>((hit->totalEnergy - hit->mass) / CLHEP::GeV));}
93 {
rigidity.push_back(
static_cast<float>(hit->rigidity/(CLHEP::tesla*CLHEP::m)));}
106 totalEnergy = other->totalEnergy;
107 theta = other->theta;
110 thetap = other->thetap;
115 weight = other->weight;
116 partID = other->partID;
117 parentID = other->parentID;
118 trackID = other->trackID;
119 modelID = other->modelID;
120 turnNumber = other->turnNumber;
134void BDSOutputROOTEventSamplerS::SetBranchAddress(TTree*)
169 std::vector<float> result((
unsigned long)n);
172 for (
int i = 0; i < n; ++i)
173 {result[i] =
static_cast<float>(particleTable->
KineticEnergy(partID[i], totalEnergy[i]));}
179 std::vector<float> result((
unsigned long)n);
182 for (
int i = 0; i < n; ++i)
183 {result[i] =
static_cast<float>(particleTable->Mass(partID[i]));}
189 std::vector<float> result((
unsigned long)n);
192 for (
int i = 0; i < n; ++i)
193 {result[i] =
static_cast<float>(particleTable->
Rigidity(partID[i], totalEnergy[i]));}
200 std::vector<bool> result((
unsigned long)n);
203 for (
int i = 0; i < n; ++i)
205 result[i] = particleTable->
IsIon(partID[i]);
214 std::vector<int> result((
unsigned long)n);
217 for (
int i = 0; i < n; ++i)
218 {result[i] =
static_cast<int>(particleTable->IonA(partID[i]));}
224 std::vector<int> result((
unsigned long)n);
227 for (
int i = 0; i < n; ++i)
228 {result[i] =
static_cast<int>(particleTable->IonZ(partID[i]));}
The information recorded from a particle impacting a sampler.
G4double charge
Double as g4 uses charge as a double.
G4int nElectrons
Can only get this at inspection time so include here.
Information stored per spherical sampler per event.
std::vector< int > getIonZ()
Function to calculate on the fly the parameters.
std::vector< bool > isIon
These are not filled by default.
std::vector< int > ionA
These are not filled by default.
std::vector< int > getIonA()
Function to calculate on the fly the parameters.
std::vector< int > charge
These are not filled by default.
std::vector< int > ionZ
These are not filled by default.
std::vector< float > rigidity
These are not filled by default.
virtual void Flush()
Clean Sampler.
std::vector< float > getKineticEnergy()
Function to calculate on the fly the parameters.
std::vector< float > kineticEnergy
These are not filled by default.
std::vector< bool > getIsIon()
Function to calculate on the fly the parameters.
std::vector< float > getMass()
Function to calculate on the fly the parameters.
std::vector< float > mass
These are not filled by default.
std::vector< float > getRigidity()
Function to calculate on the fly the parameters.
std::vector< int > nElectrons
These are not filled by default.
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.
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.