19#include "BDSAuxiliaryNavigator.hh"
21#include "BDSGlobalConstants.hh"
22#include "BDSPhysicalVolumeInfo.hh"
23#include "BDSPhysicalVolumeInfoRegistry.hh"
24#include "BDSSDApertureImpacts.hh"
28#include "G4AffineTransform.hh"
30#include "G4EventManager.hh"
31#include "G4LogicalVolume.hh"
32#include "G4ParticleDefinition.hh"
33#include "G4SDManager.hh"
35#include "G4StepStatus.hh"
36#include "G4ThreeVector.hh"
38#include "G4VPhysicalVolume.hh"
39#include "G4VTouchable.hh"
41BDSSDApertureImpacts::BDSSDApertureImpacts(
const G4String& name):
42 G4VSensitiveDetector(
"aperture_impacts/"+name),
48 collectionName.insert(colName);
51BDSSDApertureImpacts::~BDSSDApertureImpacts()
56void BDSSDApertureImpacts::Initialize(G4HCofThisEvent* HCE)
60 {
HCIDe = G4SDManager::GetSDMpointer()->GetCollectionID(
hits);}
64 G4cout << __METHOD_NAME__ <<
"Hits Collection ID: " <<
HCIDe << G4endl;
72 G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
73 G4StepStatus preStepStatus = preStepPoint->GetStepStatus();
74 if (preStepStatus != G4StepStatus::fGeomBoundary)
80 G4ThreeVector globalPos = preStepPoint->GetPosition();
81 G4ThreeVector globalMom = preStepPoint->GetMomentum();
86 G4VSolid* preStepSolid = preStepPoint->GetPhysicalVolume()->GetLogicalVolume()->GetSolid();
88 G4ThreeVector surfaceNormal = preStepSolid->SurfaceNormal(posLocal);
94 G4ThreeVector radius(posLocal.x(), posLocal.y(), 0);
95 if (radius.dot(surfaceNormal) < 0)
96 {surfaceNormal *= -1;}
100 G4double dotProduct = surfaceNormal.dot(localPosMom.
PreStepPoint());
101 G4bool leavingBeamPipe = dotProduct >= 0;
102 if (!leavingBeamPipe)
106 G4ThreeVector momLocalUnit = momLocal.unit();
107 G4double x = posLocal.x();
108 G4double y = posLocal.y();
110 G4int beamlineIndex = -1;
121 S = info->
GetSPos() + posLocal.z();
122 beamlineIndex = info->GetBeamlineIndex();
126 {UpdateParams(theInfo);}
129 G4ThreeVector unitDir = globalMom.unit();
130 G4ThreeVector newPos = globalPos + 1e-3*unitDir;
134 {UpdateParams(theInfo);}
138 G4Track* track = aStep->GetTrack();
139 G4int nElectrons = track->GetDynamicParticle()->GetTotalOccupancy();
141 preStepPoint->GetKineticEnergy(),
147 preStepPoint->GetWeight(),
148 preStepPoint->GetGlobalTime(),
149 track->GetDefinition()->GetPDGEncoding(),
151 track->GetParentID(),
Extra G4Navigator to get coordinate transforms.
BDSStep ConvertToLocal(G4Step const *const step, G4bool useCurvilinear=true) const
static BDSGlobalConstants * Instance()
Access method.
Snapshot of information for particle passing through a collimator.
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.
virtual G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *th)
BDSAuxiliaryNavigator * auxNavigator
Navigator for checking points in read out geometry.
G4int HCIDe
Hits collection ID of the event.
BDSHitsCollectionApertureImpacts * hits
Hits.
G4String colName
Collection name.
A simple class to represent the positions of a step.
G4ThreeVector PostStepPoint() const
Accessor.
G4VPhysicalVolume * VolumeForTransform() const
Accessor.
G4ThreeVector PreStepPoint() const
Accessor.
const char * GetName(int)
Name of element.