19#include "BDSGlobalConstants.hh"
21#include "BDSHitSamplerSphere.hh"
22#include "BDSParticleCoordsSpherical.hh"
23#include "BDSPhysicalConstants.hh"
24#include "BDSSamplerRegistry.hh"
25#include "BDSSDSamplerSphere.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 samplerHitsCollection(nullptr),
46 itsCollectionName(name),
51 collectionName.insert(name);
54BDSSDSamplerSphere::~BDSSDSamplerSphere()
74 G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
75 if(postStepPoint->GetStepStatus() != fGeomBoundary)
78 G4Track* track = aStep->GetTrack();
79 const G4DynamicParticle* dp = track->GetDynamicParticle();
80 G4int trackID = track->GetTrackID();
81 G4int parentID = track->GetParentID();
82 G4double T = track->GetGlobalTime();
83 G4double energy = track->GetTotalEnergy();
84 G4double charge = dp->GetCharge();
85 G4int turnsTaken =
globals->TurnsTaken();
86 const G4ThreeVector& pos = track->GetPosition();
87 const G4ThreeVector& mom = track->GetMomentumDirection();
88 G4double weight = track->GetWeight();
89 G4int nElectrons = dp->GetTotalOccupancy();
90 G4double mass = dp->GetMass();
91 G4double rigidity = 0;
93 {rigidity =
BDS::Rigidity(track->GetMomentum().mag(), charge);}
94 G4double p = dp->GetTotalMomentum();
101 G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
102 G4int samplerID = preStepPoint->GetTouchable()->GetVolume()->GetCopyNo();
105 G4ThreeVector localPosition;
106 G4ThreeVector localDirection;
110 if (globalToLocal == G4Transform3D::Identity)
115 G4AffineTransform tf = preStepPoint->GetTouchableHandle()->GetHistory()->GetTopTransform();
116 localPosition = tf.TransformPoint(pos);
117 localDirection = tf.TransformAxis(mom);
123 localPosition = globalToLocal * (HepGeom::Point3D<G4double>)pos;
125 localDirection = globalToLocal * (HepGeom::Vector3D<G4double>)mom;
131 G4int PDGtype = track->GetDefinition()->GetPDGEncoding();
132 G4String pName = track->GetDefinition()->GetParticleName();
135 G4double r = localPosition.mag();
136 G4ThreeVector unitR = localPosition.unit();
137 G4ThreeVector lds = localDirection - unitR;
139 G4double rp = localDirection.dot(unitR);
140 G4double thetap = localDirection.theta(unitR);
141 G4double phip = localDirection.deltaPhi(unitR);
144 rp, thetap, phip, T);
169 return dynamic_cast<G4VHit*
>(lastHit);
static BDSGlobalConstants * Instance()
Access method.
The information recorded from a particle impacting a sampler.
A set of spherical particle coordinates.
virtual void Initialize(G4HCofThisEvent *HCE)
BDSGlobalConstants * globals
Cached pointer to global constants as accessed many times.
BDSSDSamplerSphere(const G4String &name)
Construct a sampler with name and type (plane/cylinder).
BDSHitsCollectionSamplerSphere * samplerHitsCollection
The hits collection for this sensitive detector class that's owned by each instance.
virtual G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *readOutTH)
G4String itsCollectionName
The name of the hits collection that's created and registered.
virtual G4VHit * last() const
Provide access to last hit.
BDSSamplerRegistry * registry
Cached pointer to registry as accessed many times.
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())