LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
artg4tk::ExampleGeneralActionService Class Reference

#include "ExampleGeneralAction_service.hh"

Inheritance diagram for artg4tk::ExampleGeneralActionService:
artg4tk::TrackingActionBase artg4tk::RunActionBase artg4tk::SteppingActionBase artg4tk::ActionBase artg4tk::ActionBase artg4tk::ActionBase

Public Member Functions

 ExampleGeneralActionService (fhicl::ParameterSet const &)
 
void preUserTrackingAction (const G4Track *currTrack) override
 
void userSteppingAction (const G4Step *theStep) override
 
void beginOfRunAction (const G4Run *currentRun) override
 
virtual void postUserTrackingAction (const G4Track *)
 
std::string const & myName () const
 
virtual void initialize ()
 
virtual void endOfRunAction (const G4Run *)
 
std::string const & myName () const
 
std::string const & myName () const
 

Detailed Description

Definition at line 41 of file ExampleGeneralAction_service.hh.

Constructor & Destructor Documentation

artg4tk::ExampleGeneralActionService::ExampleGeneralActionService ( fhicl::ParameterSet const &  p)
explicit

Definition at line 23 of file ExampleGeneralAction.cc.

24  : artg4tk::TrackingActionBase(p.get<string>("name", "exampleGeneral"))
25  , artg4tk::RunActionBase(p.get<string>("name", "exampleGeneral"))
26  , artg4tk::SteppingActionBase(p.get<string>("name", "exampleGeneral"))
27 {}

Member Function Documentation

void artg4tk::ExampleGeneralActionService::beginOfRunAction ( const G4Run *  currentRun)
overridevirtual

Reimplemented from artg4tk::RunActionBase.

Definition at line 49 of file ExampleGeneralAction.cc.

50 {
51  G4cout << "### Run " << currRun->GetRunID() << " start." << G4endl;
52 
53  artg4tk::ArtG4RunManager::GetRunManager()->SetRandomNumberStore(true);
54 }
virtual void artg4tk::RunActionBase::endOfRunAction ( const G4Run *  )
inlinevirtualinherited

Definition at line 61 of file RunActionBase.hh.

62  {}
virtual void artg4tk::ActionBase::initialize ( )
inlinevirtualinherited

Reimplemented in artg4tk::myParticleGunActionService, and artg4tk::HepevtInputActionService.

Definition at line 36 of file ActionBase.hh.

37  {}
std::string const& artg4tk::ActionBase::myName ( ) const
inlineinherited

Definition at line 25 of file ActionBase.hh.

References artg4tk::ActionBase::myName_.

26  {
27  return myName_;
28  }
std::string myName_
Definition: ActionBase.hh:41
std::string const& artg4tk::ActionBase::myName ( ) const
inlineinherited

Definition at line 25 of file ActionBase.hh.

References artg4tk::ActionBase::myName_.

26  {
27  return myName_;
28  }
std::string myName_
Definition: ActionBase.hh:41
std::string const& artg4tk::ActionBase::myName ( ) const
inlineinherited

Definition at line 25 of file ActionBase.hh.

References artg4tk::ActionBase::myName_.

26  {
27  return myName_;
28  }
std::string myName_
Definition: ActionBase.hh:41
virtual void artg4tk::TrackingActionBase::postUserTrackingAction ( const G4Track *  )
inlinevirtualinherited

Reimplemented in larg4::ParticleListActionService.

Definition at line 54 of file TrackingActionBase.hh.

55  {}
void artg4tk::ExampleGeneralActionService::preUserTrackingAction ( const G4Track *  currTrack)
overridevirtual

Reimplemented from artg4tk::TrackingActionBase.

Definition at line 32 of file ExampleGeneralAction.cc.

33 {
34  // Get the tracking manager so we can tell it whether or not to store
35  // the trajectory.
36  G4TrackingManager* trackingMan = G4EventManager::GetEventManager()->GetTrackingManager();
37 
38  // Create trajectory only for primaries
39  if (currTrack->GetParentID() == 0) {
40  trackingMan->SetStoreTrajectory(true);
41  }
42  else {
43  trackingMan->SetStoreTrajectory(false);
44  }
45 }
void artg4tk::ExampleGeneralActionService::userSteppingAction ( const G4Step *  theStep)
overridevirtual

Reimplemented from artg4tk::SteppingActionBase.

Definition at line 59 of file ExampleGeneralAction.cc.

60 {
61  // This method suspends any tracks of live, primary non-muons that enter
62  // the calorimeter.
63 
64  // Get the track in question.
65  G4Track* theTrack = currStep->GetTrack();
66 
67  // check if the track is dead - if so, we don't need to suspend, so just
68  // return.
69  if (theTrack->GetTrackStatus() != fAlive) {
70  return;
71  }
72 
73  // check if it is a non-primary particle - if so, we don't need to suspend.
74  if (theTrack->GetParentID() != 0) {
75  return;
76  }
77 
78  // check if it's a muon - if so, we don't need to suspend it.
79  G4ParticleDefinition* particleType = theTrack->GetDefinition();
80  if ((particleType == G4MuonPlus::MuonPlusDefinition()) ||
81  (particleType == G4MuonMinus::MuonMinusDefinition())) {
82  return;
83  }
84 
85  // First, check whether the step started inside the calorimeter. If so,
86  // we don't need to suspend it.
87  G4StepPoint* thePrePoint = currStep->GetPreStepPoint();
88  G4VPhysicalVolume* thePrePV = thePrePoint->GetPhysicalVolume();
89  G4String thePrePVname = thePrePV->GetName();
90  if (thePrePVname(0, 4) == "calo") {
91  return;
92  }
93 
94  // Check whether the step ended outside the calorimeter. If so, we don't
95  // need to suspend it.
96  G4StepPoint* thePostPoint = currStep->GetPostStepPoint();
97  G4VPhysicalVolume* thePostPV = thePostPoint->GetPhysicalVolume();
98  G4String thePostPVname = thePostPV->GetName();
99  if (thePostPVname(0, 4) != "calo") {
100  return;
101  }
102 
103  // Any step that has survived all those checks:
104  // * is alive
105  // * is a primary
106  // * is a non-muon
107  // * started outside the calorimeter
108  // * ended inside the calorimeter
109 
110  // Now suspend the track
111  theTrack->SetTrackStatus(fSuspend);
112 }

The documentation for this class was generated from the following files: