EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
eASTTrackingAction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file eASTTrackingAction.cc
1 // ********************************************************************
2 //
3 // eASTTrackingAction.cc
4 // Header file of eAST Tracking Action class
5 //
6 // History
7 // May 8th, 2021 : first implementation
8 //
9 // ********************************************************************
10 
11 #include "eASTTrackingAction.hh"
13 #include "globals.hh"
14 #include "G4Track.hh"
15 #include "G4TrackingManager.hh"
16 #include "G4GenericMessenger.hh"
17 #include "G4Gamma.hh"
18 #include "G4Electron.hh"
19 #include "G4Positron.hh"
20 
22 {
23  messenger = new G4GenericMessenger(this,"/eAST/trajectory/","eAST trajectory commands");
24  auto& mkeCmd = messenger->DeclarePropertyWithUnit("minimumKE","MeV",
25  lowELimit,"minimum kinetic energy for recording as a trajectory");
26  mkeCmd.SetStates(G4State_Idle);
27 }
28 
30 {
31  delete messenger;
32 }
33 
35 {
36  auto trackingActions = eASTUserActionDispatcher::Instance()->GetTrackingActions();
37  if((trackingActions!=nullptr) && !(trackingActions->empty()))
38  {
39  for(auto ua : *trackingActions)
40  { ua.second->PreUserTrackingAction(trk); }
41  }
42 
43  defaultStoreTraj = fpTrackingManager->GetStoreTrajectory();
44 
45  if(trk->GetParentID() > 0) // secondary track
46  {
47  auto partDef = trk->GetDefinition();
48  if( partDef == G4Gamma::Definition() || partDef == G4Electron::Definition()
49  || partDef == G4Positron::Definition() ) // for e+/- and gamma
50  {
51  if(trk->GetKineticEnergy() < lowELimit)
52  { fpTrackingManager->SetStoreTrajectory(0); }
53  }
54  }
55 }
56 
58 {
59  auto trackingActions = eASTUserActionDispatcher::Instance()->GetTrackingActions();
60  if((trackingActions!=nullptr) && !(trackingActions->empty()))
61  {
62  for(auto ua : *trackingActions)
63  { ua.second->PostUserTrackingAction(trk); }
64  }
65 
66  // restore trajectory option
67  fpTrackingManager->SetStoreTrajectory(defaultStoreTraj);
68 }
69