19#include "BDSAcceleratorModel.hh"
20#include "BDSAuxiliaryNavigator.hh"
21#include "BDSBeamline.hh"
22#include "BDSSDCollimator.hh"
24#include "BDSHitEnergyDeposition.hh"
25#include "BDSPhysicalVolumeInfo.hh"
26#include "BDSPhysicalVolumeInfoRegistry.hh"
28#include "BDSTrajectoryPoint.hh"
31#include "G4SDManager.hh"
33#include "G4StepPoint.hh"
34#include "G4ThreeVector.hh"
36#include "G4VPhysicalVolume.hh"
37#include "G4VProcess.hh"
44 collimatorCollection(nullptr),
45 itsCollectionName(name),
49 collectionName.insert(name);
52BDSSDCollimator::~BDSSDCollimator()
68 G4cout << __METHOD_NAME__ <<
"Hits Collection ID: " <<
itsHCID << G4endl;
74 std::vector<G4VHit*> hits;
80 const std::vector<G4VHit*>& hits)
82 G4VHit* lastHit =
nullptr;
86 lastHit = hits.back();
96 G4StepPoint* preStepPoint = step->GetPreStepPoint();
97 G4ThreeVector preStepPosLocal = stepLocal.
PreStepPoint();
98 G4ThreeVector momGlobal = preStepPoint->GetMomentumDirection();
101 G4double totalEnergy = preStepPoint->GetTotalEnergy();
109 G4int beamlineIndex = -1;
110 G4int collimatorIndex = -1;
118 auto beamlineMap =
mapping.find(mwBeamline);
119 if (beamlineMap !=
mapping.end())
121 const auto& indexMap = beamlineMap->second;
122 collimatorIndex = indexMap.at(beamlineIndex);
126 std::map<G4int, G4int> indexMap;
128 for (G4int i = 0; i < (G4int)collimatorIndices.size(); i++)
129 {indexMap[collimatorIndices[i]] = i;}
130 mapping[mwBeamline] = indexMap;
131 collimatorIndex = indexMap.at(beamlineIndex);
150 if (hitsVector->empty())
155 return static_cast<G4VHit*
>(lastHit);
BDSBeamline * CorrespondingMassWorldBeamline(BDSBeamline *bl) const
Extra G4Navigator to get coordinate transforms.
G4ThreeVector ConvertAxisToLocal(const G4ThreeVector &globalAxis, const G4bool useCurvilinear=true) const
BDSStep ConvertToLocal(G4Step const *const step, G4bool useCurvilinear=true) const
A vector of BDSBeamlineElement instances - a beamline.
std::vector< G4int > GetIndicesOfCollimators() const
Return indices in order of ecol, rcol, jcol and crystalcol elements.
Snapshot of information for particle passing through a collimator.
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.
BDSBeamline * GetBeamline() const
Accessor.
G4int GetBeamlineIndex() const
Accessor.
BDSSDCollimator(G4String name)
Include unique name for each instance.
BDSHitsCollectionCollimator * collimatorCollection
The hits collection for this sensitive detector class that's owned by each instance.
virtual void Initialize(G4HCofThisEvent *HCE) override
virtual G4VHit * last() const override
Return the last collimator hit.
virtual G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *rOHist) override
BDSAuxiliaryNavigator * auxNavigator
An auxiliary navigator object for coordinate transforms.
virtual G4bool ProcessHitsOrdered(G4Step *step, G4TouchableHistory *rOHist, const std::vector< G4VHit * > &hits) override
G4String itsCollectionName
The name of the hits collection that's created and registered.
std::map< BDSBeamline *, std::map< G4int, G4int > > mapping
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 IsScatteringPoint() const