SLIC  6.1.1
Simulation for the Linear Collider (SLIC) - Geant4 simulation application
SteppingAction.cc
Go to the documentation of this file.
1 #include "SteppingAction.hh"
2 
3 // SLIC
5 #include "TrackUtil.hh"
6 
7 // LCDD
8 #include "lcdd/core/UserRegionInformation.hh"
9 
10 // Geant4
11 #include "G4SteppingManager.hh"
12 #include "G4UserSteppingAction.hh"
13 #include "G4Track.hh"
14 
15 namespace slic {
16 
18  Module("SteppingAction", false, true) {
19 }
20 
22 }
23 
24 void SteppingAction::UserSteppingAction(const G4Step* step) {
25 
26  /* Check for back scattering. */
27  if (isBackScattering(step) && step->GetStepLength() != 0.) {
28 
29  // Get track information.
30  UserTrackInformation* trackInfo = (UserTrackInformation*) fpSteppingManager->GetTrack()->GetUserInformation();
31 
32  // Need to start making track information if doesn't exist because these tracks or daughters could leave tracker hits.
33  if (trackInfo == NULL)
34  // Add new track information but don't save. The tracker hit processor can turn saving on.
35  trackInfo = TrackUtil::setupUserTrackInformation(fpSteppingManager->GetTrack(), false);
36 
37  TrackSummary* trackSummary = trackInfo->getTrackSummary();
38 
39  //G4cout << "setting backscattering flag" << G4endl;
40  trackSummary->update(fpSteppingManager->GetTrack());
41  trackSummary->setBackScattering();
42 
43  // Suspend backscattering tracks to postpone them to the end of shower development.
44  fpSteppingManager->GetTrack()->SetTrackStatus(fSuspend);
45 
46  //G4cout << "suspended backscattering track " << fpSteppingManager->GetTrack()->GetTrackID() << G4endl;
47  }
48 
49  /* Check if the track should be killed. */
50  checkKillTrack(step);
51 
53 }
54 
55 void SteppingAction::checkKillTrack(const G4Step* aStep) {
56  /* Check if the region of the pre-point has tracking killing enabled. */
57  UserRegionInformation* regionInfo = UserRegionInformation::getRegionInformation(aStep->GetPreStepPoint());
58  if (regionInfo->getKillTracks()) {
59  /* Kill the track if region track kill flag is set to true. */
60  log() << LOG::always << "Killing track: " << aStep->GetTrack()->GetTrackID() << LOG::done;
61  aStep->GetTrack()->SetTrackStatus(fStopAndKill);
62  }
63 }
64 
65 bool SteppingAction::isBackScattering(const G4Step* step) {
66 
67  /* Get pre-point info. */
68  const G4StepPoint* prePoint = step->GetPreStepPoint();
69  const G4StepPoint* postPoint = step->GetPostStepPoint();
70  const UserRegionInformation* prePointRegionInfo = (UserRegionInformation*) prePoint->GetTouchableHandle()->GetVolume()->GetLogicalVolume()->GetRegion()->GetUserInformation();
71  G4bool prePointInsideTrackerRegion = prePointRegionInfo->getStoreSecondaries();
72 
73  /* Get post-point info. */
74  G4bool postPointInsideTrackerRegion = false;
75  if (postPoint->GetTouchableHandle()->GetVolume() != NULL) {
76  const UserRegionInformation* postPointRegionInfo = (UserRegionInformation*) postPoint->GetTouchableHandle()->GetVolume()->GetLogicalVolume()->GetRegion()->GetUserInformation();
77  postPointInsideTrackerRegion = postPointRegionInfo->getStoreSecondaries();
78  }
79 
80  /* Track is backscattering if it steps from a non-tracking region back into a tracking region. */
81  return ((!prePointInsideTrackerRegion) && postPointInsideTrackerRegion);
82 }
83 
84 } // namespace slic
Base class for slic code modules that provides common functionality, such as logging to an output str...
Definition: Module.hh:25
LogStream & log()
Definition: Module.hh:99
void stepping(const G4Step *aStep)
void UserSteppingAction(const G4Step *step)
bool isBackScattering(const G4Step *step)
void checkKillTrack(const G4Step *step)
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
static UserTrackInformation * setupUserTrackInformation(const G4Track *track, G4bool save)
Definition: TrackUtil.hh:42
The implementation of the G4VUserTrackInformation class for storing track information within the even...
TrackSummary * getTrackSummary() const
@ always
Definition: LogStream.hh:33
@ done
Definition: LogStream.hh:26