19#include "BDSOutputROOTEventSamplerC.hh"
20#include "BDSOutputROOTParticleData.hh"
27#include "BDSHitSamplerCylinder.hh"
28#include "BDSParticleCoordsCylindrical.hh"
29#include "BDSPhysicalConstants.hh"
30#include "BDSPrimaryVertexInformationV.hh"
33#include "CLHEP/Units/SystemOfUnits.h"
41BDSOutputROOTEventSamplerC::BDSOutputROOTEventSamplerC():
42 samplerName(
"samplercylinder")
47BDSOutputROOTEventSamplerC::BDSOutputROOTEventSamplerC(
const std::string& samplerNameIn):
48 samplerName(samplerNameIn)
53BDSOutputROOTEventSamplerC::~BDSOutputROOTEventSamplerC()
60 G4bool storeElectrons,
62 G4bool storeKineticEnergy)
66 totalEnergy.push_back(
static_cast<float>(hit->totalEnergy / CLHEP::GeV));
67 z.push_back(
static_cast<float>(hit->coords.z / CLHEP::m));
68 phi.push_back(
static_cast<float>(hit->coords.phi / CLHEP::radian));
69 rp.push_back(
static_cast<float>(hit->coords.rp));
70 zp.push_back(
static_cast<float>(hit->coords.zp));
71 phip.push_back(
static_cast<float>(hit->coords.phip));
72 p.push_back(
static_cast<float>(hit->momentum / CLHEP::GeV));
73 T.push_back(
static_cast<float>(hit->coords.T / CLHEP::ns));
75 weight.push_back(
static_cast<float>(hit->weight));
76 partID.push_back(hit->pdgID);
77 parentID.push_back(hit->parentID);
78 trackID.push_back(hit->trackID);
79 modelID = hit->beamlineIndex;
80 turnNumber.push_back(hit->turnsTaken);
82 S =
static_cast<float> (hit->S / CLHEP::m);
85 {
mass.push_back(
static_cast<float>(hit->mass / CLHEP::GeV));}
88 {
charge.push_back(
static_cast<int>(hit->
charge / (G4double)CLHEP::eplus));}
90 if (storeKineticEnergy)
91 {
kineticEnergy.push_back(
static_cast<float>((hit->totalEnergy - hit->mass) / CLHEP::GeV));}
94 {
rigidity.push_back(
static_cast<float>(hit->rigidity/(CLHEP::tesla*CLHEP::m)));}
107 totalEnergy = other->totalEnergy;
116 weight = other->weight;
117 partID = other->partID;
118 parentID = other->parentID;
119 trackID = other->trackID;
120 modelID = other->modelID;
121 turnNumber = other->turnNumber;
135void BDSOutputROOTEventSamplerC::SetBranchAddress(TTree*)
170 std::vector<float> result((
unsigned long)n);
173 for (
int i = 0; i < n; ++i)
174 {result[i] =
static_cast<float>(particleTable->
KineticEnergy(partID[i], totalEnergy[i]));}
180 std::vector<float> result((
unsigned long)n);
183 for (
int i = 0; i < n; ++i)
184 {result[i] =
static_cast<float>(particleTable->Mass(partID[i]));}
190 std::vector<float> result((
unsigned long)n);
193 for (
int i = 0; i < n; ++i)
194 {result[i] =
static_cast<float>(particleTable->
Rigidity(partID[i], totalEnergy[i]));}
201 std::vector<bool> result((
unsigned long)n);
204 for (
int i = 0; i < n; ++i)
206 result[i] = particleTable->
IsIon(partID[i]);
215 std::vector<int> result((
unsigned long)n);
218 for (
int i = 0; i < n; ++i)
219 {result[i] =
static_cast<int>(particleTable->IonA(partID[i]));}
225 std::vector<int> result((
unsigned long)n);
228 for (
int i = 0; i < n; ++i)
229 {result[i] =
static_cast<int>(particleTable->IonZ(partID[i]));}
The information recorded from a particle impacting a sampler.
G4int nElectrons
Can only get this at inspection time so include here.
G4double charge
Double as g4 uses charge as a double.
Information stored per cylindrical sampler per event.
std::vector< int > getIonA()
Function to calculate on the fly the parameters.
std::vector< int > ionZ
These are not filled by default.
std::vector< bool > isIon
These are not filled by default.
std::vector< float > rigidity
These are not filled by default.
std::vector< bool > getIsIon()
Function to calculate on the fly the parameters.
std::vector< float > mass
These are not filled by default.
std::vector< float > getMass()
Function to calculate on the fly the parameters.
std::vector< float > getRigidity()
Function to calculate on the fly the parameters.
std::vector< int > getIonZ()
Function to calculate on the fly the parameters.
std::vector< float > kineticEnergy
These are not filled by default.
std::vector< int > charge
These are not filled by default.
std::vector< float > getKineticEnergy()
Function to calculate on the fly the parameters.
std::vector< int > ionA
These are not filled by default.
virtual void Flush()
Clean Sampler.
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.