19#include "BDSAuxiliaryNavigator.hh"
20#include "BDSHitEnergyDeposition.hh"
21#include "BDSSDEnergyDeposition.hh"
23#include "BDSGlobalConstants.hh"
24#include "BDSPhysicalVolumeInfo.hh"
25#include "BDSPhysicalVolumeInfoRegistry.hh"
27#include "BDSUtilities.hh"
30#include "G4AffineTransform.hh"
32#include "G4EventManager.hh"
33#include "G4LogicalVolume.hh"
34#include "G4ParticleDefinition.hh"
35#include "G4SDManager.hh"
37#include "G4ThreeVector.hh"
39#include "G4VPhysicalVolume.hh"
40#include "G4VTouchable.hh"
41#include "Randomize.hh"
43BDSSDEnergyDeposition::BDSSDEnergyDeposition(
const G4String& name,
45 G4bool killedParticleMassAddedToElossIn):
47 storeExtras(storeExtrasIn),
48 killedParticleMassAddedToEloss(killedParticleMassAddedToElossIn),
54 collectionName.insert(colName);
57BDSSDEnergyDeposition::~BDSSDEnergyDeposition()
62void BDSSDEnergyDeposition::Initialize(G4HCofThisEvent* HCE)
66 {HCIDe = G4SDManager::GetSDMpointer()->GetCollectionID(hits);}
67 HCE->AddHitsCollection(HCIDe,hits);
70 G4cout << __METHOD_NAME__ <<
"Hits Collection ID: " << HCIDe << G4endl;
78 G4double energy = aStep->GetTotalEnergyDeposit();
84 G4Track* track = aStep->GetTrack();
85 G4int parentID = track->GetParentID();
86 G4int ptype = track->GetDefinition()->GetPDGEncoding();
89 G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
90 G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
92 G4double preStepKineticEnergy = preStepPoint->GetKineticEnergy();
96 G4double randDist = G4UniformRand();
99 const G4ThreeVector& posbefore = preStepPoint->GetPosition();
100 const G4ThreeVector& posafter = postStepPoint->GetPosition();
101 G4ThreeVector eDepPos = posbefore + randDist*(posafter - posbefore);
105 const G4ThreeVector& posbeforelocal = stepLocal.
PreStepPoint();
106 const G4ThreeVector& posafterlocal = stepLocal.PostStepPoint();
107 G4ThreeVector eDepPosLocal = posbeforelocal + randDist*(posafterlocal - posbeforelocal);
108 G4double stepLength = (posafterlocal - posbeforelocal).mag();
111 G4double X = eDepPos.x();
112 G4double Y = eDepPos.y();
113 G4double Z = eDepPos.z();
115 G4double x = eDepPosLocal.x();
116 G4double y = eDepPosLocal.y();
117 G4double z = eDepPosLocal.z();
123 G4double preGlobalTime = preStepPoint->GetGlobalTime();
124 G4double postGlobalTime = postStepPoint->GetGlobalTime();
125 G4double globalTime = preGlobalTime + randDist * (postGlobalTime - preGlobalTime);
130 G4int beamlineIndex = -1;
133 G4double sBefore = -1000;
134 G4double sAfter = -1000;
137 G4double sCentre = info->
GetSPos();
138 sAfter = sCentre + posafterlocal.z();
139 sBefore = sCentre + posbeforelocal.z();
140 beamlineIndex = info->GetBeamlineIndex();
144 {UpdateParams(theInfo);}
148 G4ThreeVector unitDirection = (posafter - posbefore).unit();
152 {UpdateParams(theInfo);}
156 G4ThreeVector shiftedPos = posbefore + 0.1*CLHEP::mm*unitDirection;
160 {UpdateParams(theInfo);}
164 G4cerr <<
"No volume info for ";
165 auto vol = stepLocal.VolumeForTransform();
167 {G4cerr << vol->GetName() << G4endl;}
169 {G4cerr <<
"Unknown" << G4endl;}
179 G4double sHit = sBefore + randDist*(sAfter - sBefore);
181 G4double weight = track->GetWeight();
182 G4int trackID = track->GetTrackID();
185 G4int postStepProcessType = -1;
186 G4int postStepProcessSubType = -1;
189 const G4StepPoint* postPoint = aStep->GetPostStepPoint();
190 const G4VProcess* postProcess = postPoint->GetProcessDefinedStep();
193 postStepProcessType = postProcess->GetProcessType();
194 postStepProcessSubType = postProcess->GetProcessSubType();
203 preStepKineticEnergy,
214 postStepProcessSubType);
223 G4TouchableHistory* )
225 G4int parentID = track->GetParentID();
226 G4int ptype = track->GetDefinition()->GetPDGEncoding();
231 G4double globalTime = track->GetGlobalTime();
232 G4double weight = track->GetWeight();
233 G4int trackID = track->GetTrackID();
234 G4double preStepKineticEnergy = track->GetKineticEnergy();
240 G4double stepLength = 0;
241 const G4ThreeVector& posGlobal = track->GetPosition();
242 G4double X = posGlobal.x();
243 G4double Y = posGlobal.y();
244 G4double Z = posGlobal.z();
247 const G4ThreeVector& momGlobalUnit = track->GetMomentumDirection();
251 G4double x = posLocal.x();
252 G4double y = posLocal.y();
253 G4double z = posLocal.z();
258 G4int beamlineIndex = -1;
261 G4double sBefore = -1000;
262 G4double sAfter = -1000;
265 G4double sCentre = info->
GetSPos();
266 sAfter = sCentre + posLocal.z();
267 sBefore = sCentre + posLocal.z();
268 beamlineIndex = info->GetBeamlineIndex();
272 {UpdateParams(theInfo);}
276 G4ThreeVector shiftedPos = posGlobal + 0.1*CLHEP::mm * momGlobalUnit;
280 {UpdateParams(theInfo);}
284 G4cerr <<
"No volume info for ";
287 {G4cerr << vol->GetName() << G4endl;}
289 {G4cerr <<
"Unknown" << G4endl;}
297 G4double sHit = sBefore;
301 G4int postStepProcessType = -1;
302 G4int postStepProcessSubType = -1;
305 const G4Step* aStep = track->GetStep();
308 const G4StepPoint* postPoint = aStep->GetPostStepPoint();
309 const G4VProcess* postProcess = postPoint->GetProcessDefinedStep();
312 postStepProcessType = postProcess->GetProcessType();
313 postStepProcessSubType = postProcess->GetProcessSubType();
323 preStepKineticEnergy,
334 postStepProcessSubType);
345 return dynamic_cast<G4VHit*
>(lastHit);
Extra G4Navigator to get coordinate transforms.
BDSStep ConvertToLocal(G4Step const *const step, G4bool useCurvilinear=true) const
static BDSGlobalConstants * Instance()
Access method.
Information recorded for a single piece of energy deposition.
BDSPhysicalVolumeInfo * GetInfo(G4VPhysicalVolume *logicalVolume, G4bool isTunnel=false)
static BDSPhysicalVolumeInfoRegistry * Instance()
Singleton accessor.
A class holding any information pertaining to a particular physical volume in a BDSIM geant4 model.
G4double GetSPos() const
Get the s position coordinate of the logical volume.
G4bool killedParticleMassAddedToEloss
In the case of a G4Track being deposited.
G4String colName
Collection name.
G4bool storeExtras
Whether to store extra information.
virtual G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *th)
BDSAuxiliaryNavigator * auxNavigator
Navigator for checking points in read out geometry.
virtual G4VHit * last() const
Provide access to last hit.
virtual G4bool ProcessHitsTrack(const G4Track *track, G4TouchableHistory *th)
Virtual class to define interface for ordered multi-sensitive detector.
A simple class to represent the positions of a step.
G4VPhysicalVolume * VolumeForTransform() const
Accessor.
G4ThreeVector PreStepPoint() const
Accessor.
G4bool IsFinite(G4double value, G4double tolerance=std::numeric_limits< double >::epsilon())
const char * GetName(int)
Name of element.