20#include "BDSHitSamplerLink.hh"
21#include "BDSLinkRegistry.hh"
22#include "BDSParticleCoordsFull.hh"
23#include "BDSPhysicsUtilities.hh"
24#include "BDSSDSamplerLink.hh"
26#include "G4DynamicParticle.hh"
27#include "G4ParticleDefinition.hh"
28#include "G4SDManager.hh"
30#include "G4StepPoint.hh"
31#include "G4ThreeVector.hh"
32#include "G4TouchableHistory.hh"
36#include "CLHEP/Geometry/Point3D.h"
37#include "CLHEP/Geometry/Vector3D.h"
43 samplerLinkCollection(nullptr),
44 itsCollectionName(name),
48 protonsAndIonsOnly(true)
50 collectionName.insert(name);
53BDSSDSamplerLink::~BDSSDSamplerLink()
70 G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
71 if (postStepPoint->GetStepStatus() != fGeomBoundary)
74 G4Track* track = aStep->GetTrack();
75 const G4DynamicParticle* dp = track->GetDynamicParticle();
76 G4double charge = dp->GetCharge();
77 auto pd = dp->GetParticleDefinition();
82 if (!pd->GetPDGStable())
84 G4double ek = track->GetKineticEnergy();
88 G4int PDGtype = pd->GetPDGEncoding();
95 G4int trackID = track->GetTrackID();
96 G4int parentID = track->GetParentID();
97 G4double T = track->GetGlobalTime();
98 G4double energy = track->GetTotalEnergy();
100 const G4ThreeVector& pos = track->GetPosition();
101 const G4ThreeVector& mom = track->GetMomentumDirection();
102 G4double weight = track->GetWeight();
103 G4int nElectrons = dp->GetTotalOccupancy();
104 G4double mass = dp->GetMass();
105 G4double momentum = dp->GetTotalMomentum();
107 G4int z = pd->GetAtomicNumber();
108 G4int a = pd->GetAtomicMass();
111 G4int samplerID = track->GetVolume()->GetCopyNo();
115 G4ThreeVector localPosition;
116 G4ThreeVector localDirection;
119 G4Transform3D globalToLocal = G4Transform3D::Identity;
120 G4ThreeVector globalToLocalOffset = G4ThreeVector();
121 G4bool noRotation =
true;
124 noRotation =
registry->NoRotation(samplerID);
125 globalToLocal =
registry->TransformInverse(samplerID);
126 globalToLocalOffset = globalToLocal.getTranslation();
130 localPosition = pos + globalToLocalOffset;
131 localDirection = mom;
133 else if (globalToLocal != G4Transform3D::Identity)
137 localPosition = globalToLocal * (HepGeom::Point3D<G4double>)pos;
140 localPosition.setZ(0.0);
142 localDirection = globalToLocal * (HepGeom::Vector3D<G4double>)mom;
175 return dynamic_cast<G4VHit*
>(lastHit);
The information recorded from a particle impacting a link sampler.
A set of particle coordinates including energy and weight.
BDSSDSamplerLink(const G4String &name)
Construct a sampler with name and type (plane/cylinder).
G4String itsCollectionName
The name of the hits collection that's created and registered.
G4double minimumEK
Minimum kinetic energy to generate a hit for.
BDSLinkRegistry * registry
Cached pointer to registry as accessed many times.
virtual void Initialize(G4HCofThisEvent *HCE)
virtual G4VHit * last() const
Provide access to last hit.
virtual G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *readOutTH)
BDSHitsCollectionSamplerLink * samplerLinkCollection
The hits collection for this sensitive detector class that's owned by each instance.
G4bool protonsAndIonsOnly
Whether to return protons and ions only.
Virtual class to define interface for ordered multi-sensitive detector.
G4bool IsIon(const G4ParticleDefinition *particle)
Whether a particle is an ion. A proton is counted NOT as an ion.