SLIC  6.1.1
Simulation for the Linear Collider (SLIC) - Geant4 simulation application
TrackingAction.cc
Go to the documentation of this file.
1 #include "TrackingAction.hh"
2 
3 // LCDD
4 #include "lcdd/detectors/CurrentTrackState.hh"
5 
6 // SLIC
7 #include "TrackUtil.hh"
9 
10 // Geant4
11 #include "G4TransportationManager.hh"
12 
13 namespace slic {
14 
15 void TrackingAction::PreUserTrackingAction(const G4Track* track) {
16 
17  G4int trackID = track->GetTrackID();
18  G4int parentID = track->GetParentID();
19 
20  G4bool isTruePrimary = (track->GetParentID() == 0);
21  UserRegionInformation* regionInfo = TrackUtil::getRegionInformation(track);
22  G4bool insideTrackerRegion = regionInfo->getStoreSecondaries();
24  bool hasTrackInfo = (trackInfo != NULL);
25  bool aboveEnergyThreshold = (track->GetKineticEnergy() > regionInfo->getThreshold());
26 
27  // This happens when backscattering track are un-suspended.
28  if (hasTrackInfo) {
29  // Track is backscattering?
30  if (trackInfo->getTrackSummary()->getBackScattering()) {
31  // Update current track ID for calorimeter SDs and return.
32  CurrentTrackState::setCurrentTrackID(trackID);
33  return;
34  }
35  return;
36  }
37 
38  // Primary OR in tracker region and above energy threshold?
39  if (isTruePrimary || (insideTrackerRegion && aboveEnergyThreshold)) {
40 
41  // Update track ID for calorimeter SDs.
42  CurrentTrackState::setCurrentTrackID(trackID);
43 
44  // Turn on trajectory storage.
45  fpTrackingManager->SetStoreTrajectory(true);
46 
47  // Has track information?
48  if (!hasTrackInfo) {
49  // Create the track information and save it.
51  }
52 
53  } else {
54  // Inside tracker region and below energy threshold?
55  if (insideTrackerRegion && !aboveEnergyThreshold) {
56  // Has track information?
57  if (!hasTrackInfo) {
58  // Create track information but do not save it.
60  }
61  } else {
62  // Track is outside tracking region so turn off trajectory storage.
63  // These are generally tracks from calorimeter showers.
64  fpTrackingManager->SetStoreTrajectory(false);
65  }
66  }
67 
69 }
70 
71 void TrackingAction::PostUserTrackingAction(const G4Track* track) {
72 
73  // Get the track information and summary.
75  TrackSummary* trackSummary = NULL;
76  if (trackInfo != NULL)
77  trackSummary = trackInfo->getTrackSummary();
78 
79  // Track has secondaries?
80  if (fpTrackingManager->GimmeSecondaries()->size() > 0 && trackInfo == NULL) {
81  // Tracks with secondaries always get track information but they are not saved by default.
82  trackSummary = TrackUtil::setupUserTrackInformation(track, false)->getTrackSummary();
83  }
84 
85  // Track summary exists?
86  if (trackSummary != NULL) {
87  // Update the track summary.
88  trackSummary->update(track);
89  }
90 
92 }
93 
94 } // namespace slic
void preTracking(const G4Track *aTrack)
void postTracking(const G4Track *aTrack)
Container for all information from G4Track that may be persisted to MCParticle output collection.
Definition: TrackSummary.hh:33
void update(const G4Track *track)
Definition: TrackSummary.cc:44
G4bool getBackScattering() const
static UserTrackInformation * getUserTrackInformation(const G4Track *track)
Definition: TrackUtil.hh:66
static UserRegionInformation * getRegionInformation(const G4Track *track)
Definition: TrackUtil.hh:29
static UserTrackInformation * setupUserTrackInformation(const G4Track *track, G4bool save)
Definition: TrackUtil.hh:42
void PostUserTrackingAction(const G4Track *)
void PreUserTrackingAction(const G4Track *)
The implementation of the G4VUserTrackInformation class for storing track information within the even...
TrackSummary * getTrackSummary() const