Public Member Functions | Private Attributes | List of all members
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 ()
 
- Public Member Functions inherited from g4b::UserAction
 UserAction ()
 
 UserAction (fhicl::ParameterSet const &pset)
 
virtual ~UserAction ()
 
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  {
50  /// Create the object
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  {
57  /// Delete anything that we created with "new'.
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.

86  {
87  /// This method is invoked before converting the primary particles
88  /// to G4Track objects. A typical use of this method would be to
89  /// initialize and/or book histograms for a particular event.
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
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.

62  {
63  /// Configure the object
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
static const double GeV
Definition: Units.h:29
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  {
103  /// This method is invoked at the very end of event processing.
104  /// It is typically used for a simple analysis of the processed event.
105 
106  mf::LogInfo("ExampleAction")
107  << "ExampleAction::EndOfEventAction EventID="
108  << event->GetEventID();
109  }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
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.

128  {
129  /// This method is invoked after all stepping of this track
130  /// has occurred
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  }
std::string string
Definition: nybbler.cc:12
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
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.

113  {
114  /// This method is invoked before any stepping of this track
115  /// has occurred
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
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.

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.

45 { return true; }
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.

172  {
173  /// This method is invoked by G4StackManager whenever a new G4Track
174  /// object is "pushed" onto a stack by G4EventManager. ClassifyNewTrack()
175  /// returns an enumerator, G4ClassificationOfNewTrack, whose value
176  /// indicates to which stack, if any, the track will be sent.
177  /// G4ClassificationOfNewTrack has four possible values:
178  /// fUrgent - track is placed in the urgent stack
179  /// fWaiting - track is placed in the waiting stack,
180  /// and will not be simulated until the urgent stack is empty
181  /// fPostpone - track is postponed to the next event
182  /// fKill - the track is deleted immediately and not stored in any stack.
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  }
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
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.

204  {
205  /// This method is invoked when the urgent stack is empty and the
206  /// waiting stack contains at least one G4Track object. Here the user
207  /// may kill or re-assign to different stacks all the tracks in the
208  /// waiting stack by calling the stackManager->ReClassify() method
209  /// which, in turn, calls the ClassifyNewTrack() method. If no user
210  /// action is taken, all tracks in the waiting stack are transferred
211  /// to the urgent stack. The user may also decide to abort the current
212  /// event even though some tracks may remain in the waiting stack by
213  /// calling stackManager->clear(). This method is valid and safe only
214  /// if it is called from the G4UserStackingAction class.
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.

222  {
223  /// This method is invoked at the beginning of each event. At this
224  /// point no primary particles have been converted to tracks, so the
225  /// urgent and waiting stacks are empty. However, there may be tracks
226  /// in the postponed-to-next-event stack; for each of these the
227  /// ClassifyNewTrack() method is called and the track is assigned
228  /// to the appropriate stack.
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.

150  {
151  /// This method is invoked at each end of stepping
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  }
std::string string
Definition: nybbler.cc:12
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.

int altns::ExampleAction::fStepMsg
private

steps have we printed this evt?

Definition at line 58 of file ExampleAction.h.

int altns::ExampleAction::fStepMsgMaxPerEvt
private

shut up about steps

Definition at line 55 of file ExampleAction.h.

int altns::ExampleAction::fTrack2ndMsg
private

of 2ndary track printed this evt?

Definition at line 59 of file ExampleAction.h.

int altns::ExampleAction::fTrack2ndMsgMaxPerEvt
private

shut up about 2ndary tracks

Definition at line 56 of file ExampleAction.h.

int altns::ExampleAction::fVerbose
private

verbosity

Definition at line 54 of file ExampleAction.h.


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