20#include "BDSGlobalConstants.hh"
21#include "BDSMultiSensitiveDetectorOrdered.hh"
22#include "BDSRunManager.hh"
23#include "BDSSDEnergyDeposition.hh"
24#include "BDSSDEnergyDepositionGlobal.hh"
25#include "BDSStackingAction.hh"
30#include "G4ThreeVector.hh"
32#include "G4TrackStatus.hh"
33#include "G4ParticleDefinition.hh"
34#include "G4ParticleTypes.hh"
35#include "G4VSensitiveDetector.hh"
36#include "G4Version.hh"
38#if G4VERSION_NUMBER > 1029
39#include "G4MultiSensitiveDetector.hh"
42G4double BDSStackingAction::energyKilled = 0;
51 minimumEK = globals->MinimumKineticEnergy();
52 particlesToExcludeFromCuts = globals->ParticlesToExcludeFromCutsAsSet();
55BDSStackingAction::~BDSStackingAction()
60 G4ClassificationOfNewTrack classification = fUrgent;
63 G4cout<<
"StackingAction: ClassifyNewtrack "<<aTrack->GetTrackID()<<
64 " "<<aTrack->GetDefinition()->GetParticleName()<<G4endl;
65 G4StackManager* SM = G4EventManager::GetEventManager()->GetStackManager();
66 G4cout<<
"N total, waiting, urgent, postponed tracks: "
67 << std::setw(6) << SM->GetNTotalTrack() <<
" : "
68 << std::setw(6) << SM->GetNWaitingTrack() <<
" : "
69 << std::setw(6) << SM->GetNUrgentTrack() <<
" : "
70 << std::setw(6) << SM->GetNPostponedTrack()
73 G4int pdgCode = aTrack->GetParticleDefinition()->GetPDGEncoding();
74 if ( (aTrack->GetKineticEnergy() < minimumEK) && (particlesToExcludeFromCuts.count(pdgCode) == 0) )
75 {classification = fKill;}
79 {classification = fKill;}
84 G4int pdgNr = std::abs(pdgCode);
85 if( pdgNr == 12 || pdgNr == 14 || pdgNr == 16)
86 {classification = fKill;}
91 {classification = fKill;}
97 if (classification == fKill)
99 G4VPhysicalVolume* pv = aTrack->GetVolume();
102 G4VSensitiveDetector* sd = pv->GetLogicalVolume()->GetSensitiveDetector();
106 {ecSD->ProcessHitsTrack(aTrack,
nullptr);}
107#if G4VERSION_NUMBER > 1029
108 else if (
auto mSD =
dynamic_cast<G4MultiSensitiveDetector*
>(sd))
110 for (G4int i=0; i < (G4int)mSD->GetSize(); ++i)
113 {ecSD2->ProcessHitsTrack(aTrack,
nullptr);}
115 {egSD->ProcessHitsTrack(aTrack,
nullptr);}
118 for (G4int j=0; j < (G4int)mSDO->GetSize(); ++j)
121 {ecSD3->ProcessHitsTrack(aTrack,
nullptr);}
132 for (G4int i=0; i < (G4int)mSDO->GetSize(); ++i)
135 {ecSD2->ProcessHitsTrack(aTrack,
nullptr);}
140 {energyKilled += aTrack->GetTotalEnergy();}
143 {energyKilled += aTrack->GetTotalEnergy();}
146 {energyKilled += aTrack->GetTotalEnergy();}
149 return classification;
156 G4cout<<
"StackingAction: New stage"<<G4endl;
A class that holds global options and constants.
Modified G4MultiSensitiveDetector that retains order and passes hits in sequence.
Generates BDSHitsEnergyDepositionGlobal from step information.
Generates BDSHitsEnergyDepositions from step information - uses curvilinear coords.
G4long maxTracksPerEvent
Maximum number of tracks before start killing.
virtual void PrepareNewEvent()
We don't do anything here.
BDSStackingAction()=delete
Force use of supplied constructor.
G4bool killNeutrinos
Local copy of whether to kill neutrinos for tracking efficiency.
virtual G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track *aTrack)
G4bool stopSecondaries
Whether particles with parentID > 0 will be killed.
virtual void NewStage()
We don't do anything here.