18#include "BDSOutputROOTEventCollimator.hh"
19#include "BDSOutputROOTParticleData.hh"
22#include "BDSHitCollimator.hh"
23#include "BDSHitEnergyDeposition.hh"
24#include "BDSUtilities.hh"
27#include "G4TwoVector.hh"
29#include "CLHEP/Units/SystemOfUnits.h"
44 primaryInteracted(false),
45 primaryStopped(false),
47 totalEnergyDeposited(0)
50BDSOutputROOTEventCollimator::~BDSOutputROOTEventCollimator()
55 primaryInteracted =
false;
56 primaryStopped =
false;
59 energyDeposited.clear();
72 impactParameterX.clear();
73 impactParameterY.clear();
88 const std::pair<G4double, G4double>& differences,
97 xIn.push_back((
float) (pos.x() / CLHEP::m));
98 yIn.push_back((
float) (pos.y() / CLHEP::m));
99 zIn.push_back((
float) (pos.z() / CLHEP::m));
100 xpIn.push_back((
float) (mom.x() / CLHEP::rad));
101 ypIn.push_back((
float) (mom.y() / CLHEP::rad));
102 zpIn.push_back((
float) (mom.z() / CLHEP::rad));
105 G4double impactX = std::abs(xIn.back() - info.offsetX);
106 G4double impactY = std::abs(yIn.back() - info.offsetY);
107 G4double impactZ = zIn.back();
110 G4double zFromStart = -0.5 * info.length - impactZ;
113 G4double fraction = zFromStart / info.length;
114 G4double xAperAtZ = info.xSizeIn + differences.first * fraction;
115 G4double yAperAtZ = info.ySizeIn + differences.second * fraction;
118 impactX = impactX - xAperAtZ;
119 impactY = impactY - yAperAtZ;
123 G4TwoVector impactPos(impactX, impactY);
124 impactPos.rotate(info.tilt);
125 impactX = impactPos.x();
126 impactY = impactPos.y();
128 impactParameterX.push_back((
float) impactX);
129 impactParameterY.push_back((
float) impactY);
136 primaryInteracted = primaryInteracted || eHit->
GetParentID() == 0;
147 energyDeposited.push_back((
float)(eHit->GetEnergy() / CLHEP::GeV));
149 weight.push_back((
float)eHit->GetWeight());
156 energyDeposited.push_back(0);
157 T.push_back((
float)(hit->
globalTime / CLHEP::ns));
158 weight.push_back((
float)hit->
weight);
159 partID.push_back(hit->
partID);
163 G4int tn = turn.back();
169 if (parentID.back() == 0)
176void BDSOutputROOTEventCollimator::FillExtras(G4bool fillIonInfo,
182 if (!(fillIonInfo || fillLinks))
185 for (
int i = 0; i < n; ++i)
187 auto& pid = partID[i];
188 if (particleTable->
IsIon(pid))
190 auto& ionInfo = particleTable->GetIonInfo(pid);
193 isIon.push_back(
true);
194 ionA.push_back(ionInfo.a);
195 ionZ.push_back(ionInfo.z);
199 charge.push_back(ionInfo.charge);
200 mass.push_back((
float)ionInfo.mass);
201 rigidity.push_back((
float)ionInfo.rigidity(
energy[i], ionInfo.charge));
207 auto& pInfo = particleTable->GetParticleInfo(pid);
210 isIon.push_back(
false);
216 charge.push_back(pInfo.charge);
217 mass.push_back((
float)pInfo.mass);
218 rigidity.push_back((
float)pInfo.rigidity(
energy[i], pInfo.charge));
231 primaryInteracted = other->primaryInteracted;
232 primaryStopped = other->primaryStopped;
235 energyDeposited = other->energyDeposited;
245 weight = other->weight;
246 partID = other->partID;
247 parentID = other->parentID;
251 impactParameterX = other->impactParameterX;
252 impactParameterY = other->impactParameterY;
254 isIon = other->isIon;
Snapshot of information for particle passing through a collimator.
G4double totalEnergy
Total energy of particle.
G4int parentID
Track ID of the parent of the particle.
G4ThreeVector preStepMomentum
Local pre step point momentum.
G4int turnsTaken
Turn number of the hit.
G4double globalTime
Pre step point global time.
G4double weight
Statistical weight of the track.
G4int partID
PDG ID of the particle.
BDSHitEnergyDeposition * energyDepositionHit
G4ThreeVector preStepPosition
Local pre step point (z from centre of object).
Information recorded for a single piece of energy deposition.
G4int GetTurnsTaken() const
Accessor for extra piece of information.
G4int GetPartID() const
Accessor for extra piece of information.
G4int GetParentID() const
Accessor for extra piece of information.
G4double GetGlobalTime() const
Accessor for extra piece of information.
Data stored for each collimator in the model.
Data stored for each collimator per event.
std::vector< float > energy
Total energy of particle for each hit.
std::set< int > turnSet
Different length set of turn number.
std::vector< int > charge
These are not filled by default.
std::vector< float > mass
These are not filled by default.
virtual void Flush()
Flush this instance.
std::vector< float > kineticEnergy
These are not filled by default.
std::vector< bool > firstPrimaryHitThisTurn
BDSOutputROOTEventCollimator()
Default constructor for ROOT.
double totalEnergyDeposited
Sum of energy deposits including weights.
std::vector< float > rigidity
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.
G4bool IsFinite(G4double value, G4double tolerance=std::numeric_limits< double >::epsilon())