19#include "BDSOutputROOTEventCollimator.hh"
20#include "BDSOutputROOTParticleData.hh"
23#include "BDSHitCollimator.hh"
24#include "BDSHitEnergyDeposition.hh"
25#include "BDSUtilities.hh"
28#include "G4TwoVector.hh"
30#include "CLHEP/Units/SystemOfUnits.h"
45 primaryInteracted(false),
46 primaryStopped(false),
48 totalEnergyDeposited(0)
51BDSOutputROOTEventCollimator::~BDSOutputROOTEventCollimator()
56 primaryInteracted =
false;
57 primaryStopped =
false;
60 energyDeposited.clear();
73 impactParameterX.clear();
74 impactParameterY.clear();
89 const std::pair<G4double, G4double>& differences,
98 xIn.push_back((
float) (pos.x() / CLHEP::m));
99 yIn.push_back((
float) (pos.y() / CLHEP::m));
100 zIn.push_back((
float) (pos.z() / CLHEP::m));
101 xpIn.push_back((
float) (mom.x() / CLHEP::rad));
102 ypIn.push_back((
float) (mom.y() / CLHEP::rad));
103 zpIn.push_back((
float) (mom.z() / CLHEP::rad));
106 G4double impactX = std::abs(xIn.back() - info.offsetX);
107 G4double impactY = std::abs(yIn.back() - info.offsetY);
108 G4double impactZ = zIn.back();
111 G4double zFromStart = -0.5 * info.length - impactZ;
114 G4double fraction = zFromStart / info.length;
115 G4double xAperAtZ = info.xSizeIn + differences.first * fraction;
116 G4double yAperAtZ = info.ySizeIn + differences.second * fraction;
119 impactX = impactX - xAperAtZ;
120 impactY = impactY - yAperAtZ;
124 G4TwoVector impactPos(impactX, impactY);
125 impactPos.rotate(info.tilt);
126 impactX = impactPos.x();
127 impactY = impactPos.y();
129 impactParameterX.push_back((
float) impactX);
130 impactParameterY.push_back((
float) impactY);
136 G4double eDep = eHit->GetEnergy() / CLHEP::GeV;
137 G4double eW = eHit->GetEnergyWeighted() / CLHEP::GeV;
138 G4double w = eHit->GetWeight();
142 primaryInteracted = primaryInteracted || eHit->
GetParentID() == 0;
147 energyDeposited.push_back((
float)eDep);
149 weight.push_back((
float)w);
159 if (parentID.back() == 0)
167void BDSOutputROOTEventCollimator::FillExtras(G4bool fillIonInfo,
173 if (!(fillIonInfo || fillLinks))
176 for (
int i = 0; i < n; ++i)
178 auto& pid = partID[i];
179 if (particleTable->
IsIon(pid))
181 auto& ionInfo = particleTable->GetIonInfo(pid);
184 isIon.push_back(
true);
185 ionA.push_back(ionInfo.a);
186 ionZ.push_back(ionInfo.z);
190 charge.push_back(ionInfo.charge);
191 mass.push_back((
float)ionInfo.mass);
192 rigidity.push_back((
float)ionInfo.rigidity(
energy[i], ionInfo.charge));
198 auto& pInfo = particleTable->GetParticleInfo(pid);
201 isIon.push_back(
false);
207 charge.push_back(pInfo.charge);
208 mass.push_back((
float)pInfo.mass);
209 rigidity.push_back((
float)pInfo.rigidity(
energy[i], pInfo.charge));
222 primaryInteracted = other->primaryInteracted;
223 primaryStopped = other->primaryStopped;
226 energyDeposited = other->energyDeposited;
236 weight = other->weight;
237 partID = other->partID;
238 parentID = other->parentID;
242 impactParameterX = other->impactParameterX;
243 impactParameterY = other->impactParameterY;
245 isIon = other->isIon;
Snapshot of information for particle passing through a collimator.
G4double totalEnergy
Total energy of particle.
G4ThreeVector preStepMomentum
Local pre step point momentum.
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())