19#include "BDSGlobalConstants.hh"
21#include "BDSHitSampler.hh"
22#include "BDSParticleCoordsFull.hh"
23#include "BDSPhysicalConstants.hh"
24#include "BDSSamplerRegistry.hh"
25#include "BDSSDSampler.hh"
26#include "BDSUtilities.hh"
29#include "G4AffineTransform.hh"
30#include "G4DynamicParticle.hh"
31#include "G4ParticleDefinition.hh"
32#include "G4SDManager.hh"
34#include "G4StepPoint.hh"
35#include "G4ThreeVector.hh"
36#include "G4TouchableHistory.hh"
38#include "G4VPhysicalVolume.hh"
39#include "G4VTouchable.hh"
45 SamplerCollection(nullptr),
46 itsCollectionName(name),
51 collectionName.insert(name);
54BDSSDSampler::~BDSSDSampler()
74 G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
75 if(postStepPoint->GetStepStatus() != fGeomBoundary)
78 G4cout << __METHOD_NAME__ <<
"not storing as not on geometry boundary" << G4endl;
83 G4Track* track = aStep->GetTrack();
84 const G4DynamicParticle* dp = track->GetDynamicParticle();
85 G4int TrackID = track->GetTrackID();
86 G4int ParentID = track->GetParentID();
87 G4double T = track->GetGlobalTime();
88 G4double energy = track->GetTotalEnergy();
89 G4double charge = dp->GetCharge();
90 G4int turnstaken =
globals->TurnsTaken();
91 const G4ThreeVector& pos = track->GetPosition();
92 const G4ThreeVector& mom = track->GetMomentumDirection();
93 G4double weight = track->GetWeight();
94 G4int nElectrons = dp->GetTotalOccupancy();
95 G4double mass = dp->GetMass();
96 G4double rigidity = 0;
98 {rigidity =
BDS::Rigidity(track->GetMomentum().mag(), charge);}
99 G4double p = dp->GetTotalMomentum();
106 G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
107 G4int samplerID = preStepPoint->GetTouchable()->GetVolume()->GetCopyNo();
110 G4ThreeVector localPosition;
111 G4ThreeVector localDirection;
115 if (globalToLocal == G4Transform3D::Identity)
118 G4cout << __METHOD_NAME__ <<
"Getting transform dynamically from geometry." << G4endl;
123 G4AffineTransform tf = preStepPoint->GetTouchableHandle()->GetHistory()->GetTopTransform();
124 localPosition = tf.TransformPoint(pos);
125 localDirection = tf.TransformAxis(mom);
131 localPosition = globalToLocal * (HepGeom::Point3D<G4double>)pos;
134 localPosition.setZ(0.0);
136 localDirection = globalToLocal * (HepGeom::Vector3D<G4double>)mom;
142 G4int PDGtype = track->GetDefinition()->GetPDGEncoding();
143 G4String pName = track->GetDefinition()->GetParticleName();
176 return dynamic_cast<G4VHit*
>(lastHit);
static BDSGlobalConstants * Instance()
Access method.
The information recorded from a particle impacting a sampler.
A set of particle coordinates including energy and weight.
BDSGlobalConstants * globals
Cached pointer to global constants as accessed many times.
virtual void Initialize(G4HCofThisEvent *HCE)
virtual G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *readOutTH)
BDSSDSampler(const G4String &name)
Construct a sampler with name and type (plane/cylinder).
virtual G4VHit * last() const
Provide access to last hit.
BDSHitsCollectionSampler * SamplerCollection
The hits collection for this sensitive detector class that's owned by each instance.
BDSSamplerRegistry * registry
Cached pointer to registry as accessed many times.
G4String itsCollectionName
The name of the hits collection that's created and registered.
Information about a registered sampler.
G4int BeamlineIndex() const
Accessor.
G4double SPosition() const
Accessor.
static BDSSamplerRegistry * Instance()
Accessor for registry.
const BDSSamplerPlacementRecord & GetInfo(G4int index) const
Accessor.
G4Transform3D GetTransformInverse(G4int index) const
Accessor.
Virtual class to define interface for ordered multi-sensitive detector.
G4double Rigidity(G4double momentumMagnitude, G4double charge)
Calculate the rigidity for a total momentum and charge.
G4bool IsFinite(G4double value, G4double tolerance=std::numeric_limits< double >::epsilon())