19#include "BDSAcceleratorModel.hh"
21#include "BDSEventAction.hh"
22#include "BDSGlobalConstants.hh"
23#include "BDSIntegratorMag.hh"
24#include "BDSTrackingAction.hh"
25#include "BDSTrajectory.hh"
26#include "BDSTrajectoryPrimary.hh"
27#include "BDSUtilities.hh"
30#include "G4TrackingManager.hh"
32#include "G4VPhysicalVolume.hh"
39 G4bool storeTrajectoryIn,
42 G4int verboseSteppingEventStartIn,
43 G4int verboseSteppingEventStopIn,
44 G4bool verboseSteppingPrimaryOnlyIn,
45 G4int verboseSteppingLevelIn):
46 interactive(!batchMode),
47 storeTrajectory(storeTrajectoryIn),
48 storeTrajectoryOptions(storeTrajectoryOptionsIn),
49 eventAction(eventActionIn),
50 verboseSteppingEventStart(verboseSteppingEventStartIn),
51 verboseSteppingEventStop(verboseSteppingEventStopIn),
52 verboseSteppingPrimaryOnly(verboseSteppingPrimaryOnlyIn),
53 verboseSteppingLevel(verboseSteppingLevelIn)
59 G4int eventIndex =
eventAction->CurrentEventIndex();
60 G4bool verboseSteppingThisEvent =
BDS::VerboseThisEvent(eventIndex, verboseSteppingEventStart, verboseSteppingEventStop);
61 G4bool primaryParticle = track->GetParentID() == 0;
64 if (primaryParticle && verboseSteppingThisEvent)
65 {fpTrackingManager->GetSteppingManager()->SetVerboseLevel(verboseSteppingLevel);}
66 else if (!primaryParticle && verboseSteppingThisEvent && !verboseSteppingPrimaryOnly)
67 {fpTrackingManager->GetSteppingManager()->SetVerboseLevel(verboseSteppingLevel);}
77 fpTrackingManager->SetStoreTrajectory(1);
78 fpTrackingManager->SetTrajectory(traj);
81 {fpTrackingManager->SetStoreTrajectory(0);}
88 G4bool storePoints = storeTrajectory ||
interactive;
94 fpTrackingManager->SetStoreTrajectory(1);
95 fpTrackingManager->SetTrajectory(traj);
102 fpTrackingManager->GetSteppingManager()->SetVerboseLevel(0);
105 G4int trackID = track->GetTrackID();
108 auto status = track->GetTrackStatus();
112 case G4TrackStatus::fAlive:
113 {name =
"fAlive";
break;}
114 case G4TrackStatus::fStopButAlive:
115 {name =
"fStopButAlive";
break;}
116 case G4TrackStatus::fKillTrackAndSecondaries:
117 {name =
"fKillTrackAndSecondaries";
break;}
118 case G4TrackStatus::fStopAndKill:
119 {name =
"fStopAndKill";
break;}
121 {name =
"other";
break;}
123 G4cout <<
"track ID " << trackID <<
" status " << name << G4endl;
126 if (track->GetParentID() == 0)
128 G4LogicalVolume* lv = track->GetVolume()->GetLogicalVolume();
129 std::set<G4LogicalVolume*>* collimators = BDSAcceleratorModel::Instance()->
VolumeSet(
"collimators");
130 if (collimators->find(lv) != collimators->end())
std::set< G4LogicalVolume * > * VolumeSet(const G4String &name)
Returns pointer to a set of logical volumes. If no set by that name exits, create it.
Process information at the event level.
void IncrementNTracks()
Interface for tracking action to increment the number of tracks in each event.
void SetPrimaryAbsorbedInCollimator(G4bool stoppedIn)
Flag that the primary was absorbed in a collimator - can be done externally to this class.
void RegisterPrimaryTrajectory(const BDSTrajectoryPrimary *trajectoryIn)
Append this trajectory to vector of primaries we keep to avoid sifting at the end of event.
static G4bool currentTrackIsPrimary
virtual void PreUserTrackingAction(const G4Track *track)
Used to decide whether or not to store trajectories.
virtual void PostUserTrackingAction(const G4Track *track)
Detect whether track is a primary and if so whether it ended in a collimator.
BDSTrackingAction()=delete
No default constructor required.
BDSEventAction * eventAction
Cache of trajectory options.
const BDS::TrajectoryOptions storeTrajectoryOptions
Cache of flag from global constants to control storing all trajectories.
Trajectory information for only the primary.
Trajectory information from track including last scatter etc.
G4bool VerboseThisEvent(G4int eventIndex, G4int eventStart, G4int eventStop)
Logic of whether this event should be verbose or not. Code here so it's not duplicated.