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"
44BDSSDEnergyDeposition::BDSSDEnergyDeposition(
const G4String& name,
46 G4bool killedParticleMassAddedToElossIn):
48 storeExtras(storeExtrasIn),
49 killedParticleMassAddedToEloss(killedParticleMassAddedToElossIn),
55 collectionName.insert(colName);
58BDSSDEnergyDeposition::~BDSSDEnergyDeposition()
63void BDSSDEnergyDeposition::Initialize(G4HCofThisEvent* HCE)
67 {HCIDe = G4SDManager::GetSDMpointer()->GetCollectionID(hits);}
68 HCE->AddHitsCollection(HCIDe,hits);
71 G4cout << __METHOD_NAME__ <<
"Hits Collection ID: " << HCIDe << G4endl;
79 G4double energy = aStep->GetTotalEnergyDeposit();
85 G4Track* track = aStep->GetTrack();
86 G4int parentID = track->GetParentID();
87 G4int ptype = track->GetDefinition()->GetPDGEncoding();
90 G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
91 G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
93 G4double preStepKineticEnergy = preStepPoint->GetKineticEnergy();
97 G4double randDist = G4UniformRand();
100 const G4ThreeVector& posbefore = preStepPoint->GetPosition();
101 const G4ThreeVector& posafter = postStepPoint->GetPosition();
102 G4ThreeVector eDepPos = posbefore + randDist*(posafter - posbefore);
106 const G4ThreeVector& posbeforelocal = stepLocal.
PreStepPoint();
107 const G4ThreeVector& posafterlocal = stepLocal.PostStepPoint();
108 G4ThreeVector eDepPosLocal = posbeforelocal + randDist*(posafterlocal - posbeforelocal);
109 G4double stepLength = (posafterlocal - posbeforelocal).mag();
112 G4double X = eDepPos.x();
113 G4double Y = eDepPos.y();
114 G4double Z = eDepPos.z();
116 G4double x = eDepPosLocal.x();
117 G4double y = eDepPosLocal.y();
118 G4double z = eDepPosLocal.z();
124 G4double preGlobalTime = preStepPoint->GetGlobalTime();
125 G4double postGlobalTime = postStepPoint->GetGlobalTime();
126 G4double globalTime = preGlobalTime + randDist * (postGlobalTime - preGlobalTime);
131 G4int beamlineIndex = -1;
134 G4double sBefore = -1000;
135 G4double sAfter = -1000;
138 G4double sCentre = info->
GetSPos();
139 sAfter = sCentre + posafterlocal.z();
140 sBefore = sCentre + posbeforelocal.z();
141 beamlineIndex = info->GetBeamlineIndex();
145 {UpdateParams(theInfo);}
149 G4ThreeVector unitDirection = (posafter - posbefore).unit();
153 {UpdateParams(theInfo);}
157 G4ThreeVector shiftedPos = posbefore + 0.1*CLHEP::mm*unitDirection;
161 {UpdateParams(theInfo);}
165 G4cerr <<
"No volume info for ";
166 auto vol = stepLocal.VolumeForTransform();
168 {G4cerr << vol->GetName() << G4endl;}
170 {G4cerr <<
"Unknown" << G4endl;}
180 G4double sHit = sBefore + randDist*(sAfter - sBefore);
182 G4double weight = track->GetWeight();
183 G4int trackID = track->GetTrackID();
186 G4int postStepProcessType = -1;
187 G4int postStepProcessSubType = -1;
190 const G4StepPoint* postPoint = aStep->GetPostStepPoint();
191 const G4VProcess* postProcess = postPoint->GetProcessDefinedStep();
194 postStepProcessType = postProcess->GetProcessType();
195 postStepProcessSubType = postProcess->GetProcessSubType();
204 preStepKineticEnergy,
215 postStepProcessSubType);
224 G4TouchableHistory* )
226 G4int parentID = track->GetParentID();
227 G4int ptype = track->GetDefinition()->GetPDGEncoding();
232 G4double globalTime = track->GetGlobalTime();
233 G4double weight = track->GetWeight();
234 G4int trackID = track->GetTrackID();
235 G4double preStepKineticEnergy = track->GetKineticEnergy();
241 G4double stepLength = 0;
242 const G4ThreeVector& posGlobal = track->GetPosition();
243 G4double X = posGlobal.x();
244 G4double Y = posGlobal.y();
245 G4double Z = posGlobal.z();
248 const G4ThreeVector& momGlobalUnit = track->GetMomentumDirection();
252 G4double x = posLocal.x();
253 G4double y = posLocal.y();
254 G4double z = posLocal.z();
259 G4int beamlineIndex = -1;
262 G4double sBefore = -1000;
263 G4double sAfter = -1000;
266 G4double sCentre = info->
GetSPos();
267 sAfter = sCentre + posLocal.z();
268 sBefore = sCentre + posLocal.z();
269 beamlineIndex = info->GetBeamlineIndex();
273 {UpdateParams(theInfo);}
277 G4ThreeVector shiftedPos = posGlobal + 0.1*CLHEP::mm * momGlobalUnit;
281 {UpdateParams(theInfo);}
285 G4cerr <<
"No volume info for ";
288 {G4cerr << vol->GetName() << G4endl;}
290 {G4cerr <<
"Unknown" << G4endl;}
298 G4double sHit = sBefore;
302 G4int postStepProcessType = -1;
303 G4int postStepProcessSubType = -1;
306 const G4Step* aStep = track->GetStep();
309 const G4StepPoint* postPoint = aStep->GetPostStepPoint();
310 const G4VProcess* postProcess = postPoint->GetProcessDefinedStep();
313 postStepProcessType = postProcess->GetProcessType();
314 postStepProcessSubType = postProcess->GetProcessSubType();
324 preStepKineticEnergy,
335 postStepProcessSubType);
346 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.