LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
altns::ExampleAction Class Reference

#include "ExampleAction.h"

Inheritance diagram for altns::ExampleAction:
g4b::UserAction

Public Member Functions

 ExampleAction ()
 
virtual ~ExampleAction ()
 
void Config (fhicl::ParameterSet const &pset)
 Override Config() to extract any necessary parameters. More...
 
void PrintConfig (std::string const &opt)
 Override PrintConfig() to print out current configuration. More...
 
void BeginOfEventAction (const G4Event *)
 
void EndOfEventAction (const G4Event *)
 
void PreTrackingAction (const G4Track *)
 G4UserTrackingAction interfaces. More...
 
void PostTrackingAction (const G4Track *)
 
void SteppingAction (const G4Step *)
 G4UserSteppingAction interface. More...
 
bool ProvidesStacking ()
 
G4ClassificationOfNewTrack StackClassifyNewTrack (const G4Track *)
 G4UserStackingAction interfaces. More...
 
void StackNewStage ()
 
void StackPrepareNewEvent ()
 
virtual void BeginOfRunAction (const G4Run *)
 G4UserRunAction interfaces. More...
 
virtual void EndOfRunAction (const G4Run *)
 
std::string const & GetName () const
 
void SetName (std::string const &name)
 

Private Attributes

double fSomeValue
 some user config value More...
 
int fVerbose
 verbosity More...
 
int fStepMsgMaxPerEvt
 shut up about steps More...
 
int fTrack2ndMsgMaxPerEvt
 shut up about 2ndary tracks More...
 
int fStepMsg
 

steps have we printed this evt?

More...
 
int fTrack2ndMsg
 

of 2ndary track printed this evt?

More...
 

Detailed Description

Definition at line 25 of file ExampleAction.h.

Constructor & Destructor Documentation

altns::ExampleAction::ExampleAction ( )

Create the object

Definition at line 44 of file ExampleAction.cxx.

45  : fSomeValue(0)
46  , fVerbose(0)
47  , fStepMsgMaxPerEvt(42)
49  {
51  }
int fVerbose
verbosity
Definition: ExampleAction.h:54
int fStepMsgMaxPerEvt
shut up about steps
Definition: ExampleAction.h:55
int fTrack2ndMsgMaxPerEvt
shut up about 2ndary tracks
Definition: ExampleAction.h:56
double fSomeValue
some user config value
Definition: ExampleAction.h:53
altns::ExampleAction::~ExampleAction ( )
virtual

Delete anything that we created with "new'.

Definition at line 55 of file ExampleAction.cxx.

56  {
58  }

Member Function Documentation

void altns::ExampleAction::BeginOfEventAction ( const G4Event *  event)
virtual

UserActions method that we'll override, to obtain access to Geant4's particle tracks and trajectories.

This method is invoked before converting the primary particles to G4Track objects. A typical use of this method would be to initialize and/or book histograms for a particular event.

Reimplemented from g4b::UserAction.

Definition at line 85 of file ExampleAction.cxx.

References fStepMsg, and fTrack2ndMsg.

86  {
90 
91  mf::LogInfo("ExampleAction")
92  << "ExampleAction::BeginOfEventAction EventID="
93  << event->GetEventID();
94 
95  fStepMsg = 0;
96  fTrack2ndMsg = 0;
97 
98  }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
int fTrack2ndMsg
of 2ndary track printed this evt?
Definition: ExampleAction.h:59
int fStepMsg
steps have we printed this evt?
Definition: ExampleAction.h:58
virtual void g4b::UserAction::BeginOfRunAction ( const G4Run *  )
inlinevirtualinherited

G4UserRunAction interfaces.

The following a list of methods that correspond to the available user action classes in Geant 4.0.1 and higher.

Reimplemented in larg4::VisualizationAction.

Definition at line 74 of file UserAction.h.

74 {};
void altns::ExampleAction::Config ( fhicl::ParameterSet const &  )
virtual

Override Config() to extract any necessary parameters.

Configure the object

Reimplemented from g4b::UserAction.

Definition at line 61 of file ExampleAction.cxx.

References fSomeValue, fStepMsgMaxPerEvt, fTrack2ndMsgMaxPerEvt, fVerbose, and fhicl::ParameterSet::get().

62  {
64 
65  fSomeValue = pset.get< double >("SomeValue",0)*CLHEP::GeV;
66  fVerbose = pset.get< int >("Verbose",0);
67  fStepMsgMaxPerEvt = pset.get< int >("StepMsgMaxPerEvt",42);
68  fTrack2ndMsgMaxPerEvt = pset.get< int >("Track2ndMsgMaxPerEvt",2);
69 
70  }
int fVerbose
verbosity
Definition: ExampleAction.h:54
int fStepMsgMaxPerEvt
shut up about steps
Definition: ExampleAction.h:55
int fTrack2ndMsgMaxPerEvt
shut up about 2ndary tracks
Definition: ExampleAction.h:56
double fSomeValue
some user config value
Definition: ExampleAction.h:53
void altns::ExampleAction::EndOfEventAction ( const G4Event *  event)
virtual

This method is invoked at the very end of event processing. It is typically used for a simple analysis of the processed event.

Reimplemented from g4b::UserAction.

Definition at line 101 of file ExampleAction.cxx.

102  {
105 
106  mf::LogInfo("ExampleAction")
107  << "ExampleAction::EndOfEventAction EventID="
108  << event->GetEventID();
109  }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
virtual void g4b::UserAction::EndOfRunAction ( const G4Run *  )
inlinevirtualinherited

Reimplemented in larg4::VisualizationAction.

Definition at line 75 of file UserAction.h.

75 {};
std::string const& g4b::UserAction::GetName ( ) const
inlineinherited

Definition at line 98 of file UserAction.h.

References g4b::UserAction::myName.

Referenced by g4b::UserActionManager::PrintActionList().

98 { return myName; }
std::string myName
self-knowledge
Definition: UserAction.h:101
void altns::ExampleAction::PostTrackingAction ( const G4Track *  track)
virtual

This method is invoked after all stepping of this track has occurred

Reimplemented from g4b::UserAction.

Definition at line 127 of file ExampleAction.cxx.

References fTrack2ndMsg, and fTrack2ndMsgMaxPerEvt.

128  {
131 
132  G4int parent_id = track->GetParentID();
133  std::string extra_msg = "";
134  if ( parent_id > 0 ) {
135  ++fTrack2ndMsg;
136  if ( fTrack2ndMsg > fTrack2ndMsgMaxPerEvt ) return;
138  extra_msg = "...last such message this event";
139  }
140  }
141 
142  mf::LogInfo("ExampleAction")
143  << "ExampleAction::PostTrackingAction TrackID="
144  << track->GetTrackID()
145  << " " << extra_msg;
146  }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
int fTrack2ndMsgMaxPerEvt
shut up about 2ndary tracks
Definition: ExampleAction.h:56
int fTrack2ndMsg
of 2ndary track printed this evt?
Definition: ExampleAction.h:59
Float_t track
Definition: plot.C:35
void altns::ExampleAction::PreTrackingAction ( const G4Track *  )
virtual

G4UserTrackingAction interfaces.

This method is invoked before any stepping of this track has occurred

Reimplemented from g4b::UserAction.

Definition at line 112 of file ExampleAction.cxx.

References fTrack2ndMsg, and fTrack2ndMsgMaxPerEvt.

113  {
116 
117  G4int parent_id = track->GetParentID();
118  if ( parent_id > 0 && fTrack2ndMsg > fTrack2ndMsgMaxPerEvt ) return;
119 
120  mf::LogInfo("ExampleAction")
121  << "ExampleAction::PreTrackingAction TrackID="
122  << track->GetTrackID()
123  << " is a " << track->GetParticleDefinition()->GetParticleName();
124  }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
int fTrack2ndMsgMaxPerEvt
shut up about 2ndary tracks
Definition: ExampleAction.h:56
int fTrack2ndMsg
of 2ndary track printed this evt?
Definition: ExampleAction.h:59
Float_t track
Definition: plot.C:35
void altns::ExampleAction::PrintConfig ( std::string const &  )
virtual

Override PrintConfig() to print out current configuration.

Reimplemented from g4b::UserAction.

Definition at line 73 of file ExampleAction.cxx.

References fSomeValue, fStepMsgMaxPerEvt, fTrack2ndMsgMaxPerEvt, and fVerbose.

74  {
75  mf::LogInfo("ExampleAction")
76  << "ExampleAction::PrintConfig \n"
77  << " SomeValue " << fSomeValue << "\n"
78  << " Verbose " << fVerbose << "\n"
79  << " StepMsgMaxPerEvt " << fStepMsgMaxPerEvt << "\n"
80  << " Track2ndMsgMaxPerEvt " << fTrack2ndMsgMaxPerEvt << "\n";
81 
82  }
int fVerbose
verbosity
Definition: ExampleAction.h:54
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
int fStepMsgMaxPerEvt
shut up about steps
Definition: ExampleAction.h:55
int fTrack2ndMsgMaxPerEvt
shut up about 2ndary tracks
Definition: ExampleAction.h:56
double fSomeValue
some user config value
Definition: ExampleAction.h:53
bool altns::ExampleAction::ProvidesStacking ( )
inlinevirtual

Does this UserAction do stacking? Override to return "true" if the following interfaces are implemented

Reimplemented from g4b::UserAction.

Definition at line 45 of file ExampleAction.h.

References StackClassifyNewTrack(), StackNewStage(), and StackPrepareNewEvent().

45 { return true; }
void g4b::UserAction::SetName ( std::string const &  name)
inlineinherited

Definition at line 99 of file UserAction.h.

References g4b::UserAction::myName.

Referenced by g4b::UserActionFactory::GetUserAction().

99 { myName = name; }
std::string myName
self-knowledge
Definition: UserAction.h:101
G4ClassificationOfNewTrack altns::ExampleAction::StackClassifyNewTrack ( const G4Track *  track)
virtual

G4UserStackingAction interfaces.

This method is invoked by G4StackManager whenever a new G4Track object is "pushed" onto a stack by G4EventManager. ClassifyNewTrack() returns an enumerator, G4ClassificationOfNewTrack, whose value indicates to which stack, if any, the track will be sent. G4ClassificationOfNewTrack has four possible values: fUrgent - track is placed in the urgent stack fWaiting - track is placed in the waiting stack, and will not be simulated until the urgent stack is empty fPostpone - track is postponed to the next event fKill - the track is deleted immediately and not stored in any stack.

Reimplemented from g4b::UserAction.

Definition at line 171 of file ExampleAction.cxx.

Referenced by ProvidesStacking().

172  {
183 
184  G4int parent_id = track->GetParentID();
185  std::string tsrc = "primary";
186  if ( parent_id < 0 ) tsrc = "postponed (from previous event)";
187  if ( parent_id > 0 ) tsrc = "secondary";
188 
189  mf::LogInfo("ExampleAction")
190  << "ExampleAction::StackClassifyNewTrack TrackID="
191  << track->GetTrackID()
192  << " ParentID=" << parent_id << " "
193  << track->GetDefinition()->GetParticleName()
194  << " (" << tsrc << " particle)";
195 
196  // One *must* return a classification
197  // Since we're not doing anything useful in NewStage/PrepareNewEvent
198  // the only things we should return are fUrgent or fKill
199  return fUrgent;
200  }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
Float_t track
Definition: plot.C:35
void altns::ExampleAction::StackNewStage ( )
virtual

This method is invoked when the urgent stack is empty and the waiting stack contains at least one G4Track object. Here the user may kill or re-assign to different stacks all the tracks in the waiting stack by calling the stackManager->ReClassify() method which, in turn, calls the ClassifyNewTrack() method. If no user action is taken, all tracks in the waiting stack are transferred to the urgent stack. The user may also decide to abort the current event even though some tracks may remain in the waiting stack by calling stackManager->clear(). This method is valid and safe only if it is called from the G4UserStackingAction class.

Reimplemented from g4b::UserAction.

Definition at line 203 of file ExampleAction.cxx.

Referenced by ProvidesStacking().

204  {
215 
216  mf::LogInfo("ExampleAction")
217  << "ExampleAction::StackNewStage";
218  }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
void altns::ExampleAction::StackPrepareNewEvent ( )
virtual

This method is invoked at the beginning of each event. At this point no primary particles have been converted to tracks, so the urgent and waiting stacks are empty. However, there may be tracks in the postponed-to-next-event stack; for each of these the ClassifyNewTrack() method is called and the track is assigned to the appropriate stack.

Reimplemented from g4b::UserAction.

Definition at line 221 of file ExampleAction.cxx.

Referenced by ProvidesStacking().

222  {
229 
230  mf::LogInfo("ExampleAction")
231  << "ExampleAction::StackPrepareNewEvent";
232  }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
void altns::ExampleAction::SteppingAction ( const G4Step *  )
virtual

G4UserSteppingAction interface.

This method is invoked at each end of stepping

Reimplemented from g4b::UserAction.

Definition at line 149 of file ExampleAction.cxx.

References fStepMsg, and fStepMsgMaxPerEvt.

150  {
152 
153  ++fStepMsg;
154  if ( ++fStepMsg > fStepMsgMaxPerEvt ) return;
155 
156  std::string extra_msg = "";
157  if ( fStepMsg == fStepMsgMaxPerEvt ) {
158  extra_msg = "...last such message this event";
159  }
160 
161  mf::LogInfo("ExampleAction")
162  << "ExampleAction::SteppingAction TrackID="
163  << step->GetTrack()->GetTrackID()
164  << " " << extra_msg;
165 
166 
167  }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
int fStepMsgMaxPerEvt
shut up about steps
Definition: ExampleAction.h:55
int fStepMsg
steps have we printed this evt?
Definition: ExampleAction.h:58

Member Data Documentation

double altns::ExampleAction::fSomeValue
private

some user config value

Definition at line 53 of file ExampleAction.h.

Referenced by Config(), and PrintConfig().

int altns::ExampleAction::fStepMsg
private

steps have we printed this evt?

Definition at line 58 of file ExampleAction.h.

Referenced by BeginOfEventAction(), and SteppingAction().

int altns::ExampleAction::fStepMsgMaxPerEvt
private

shut up about steps

Definition at line 55 of file ExampleAction.h.

Referenced by Config(), PrintConfig(), and SteppingAction().

int altns::ExampleAction::fTrack2ndMsg
private

of 2ndary track printed this evt?

Definition at line 59 of file ExampleAction.h.

Referenced by BeginOfEventAction(), PostTrackingAction(), and PreTrackingAction().

int altns::ExampleAction::fTrack2ndMsgMaxPerEvt
private

shut up about 2ndary tracks

Definition at line 56 of file ExampleAction.h.

Referenced by Config(), PostTrackingAction(), PreTrackingAction(), and PrintConfig().

int altns::ExampleAction::fVerbose
private

verbosity

Definition at line 54 of file ExampleAction.h.

Referenced by Config(), and PrintConfig().


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