LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
g4b::UserActionManager Class Reference

#include "UserActionManager.h"

Inheritance diagram for g4b::UserActionManager:

Public Member Functions

virtual ~UserActionManager ()
 
void Close ()
 
G4int GetSize () const
 
UserActionGetAction (G4int i) const
 
UserActionGetAction (std::string const &name) const
 
G4int GetIndex (std::string const &name) const
 
void PrintActionList (std::string const &opt) const
 
virtual void BeginOfRunAction (const G4Run *)
 
virtual void EndOfRunAction (const G4Run *)
 
virtual void BeginOfEventAction (const G4Event *)
 
virtual void EndOfEventAction (const G4Event *)
 
virtual void PreUserTrackingAction (const G4Track *)
 
virtual void PostUserTrackingAction (const G4Track *)
 
virtual void UserSteppingAction (const G4Step *)
 
virtual G4ClassificationOfNewTrack ClassifyNewTrack (const G4Track *)
 
virtual void NewStage ()
 
virtual void PrepareNewEvent ()
 
virtual bool DoesAnyActionProvideStacking ()
 
G4EventManager * GetEventManager () const
 
G4TrackingManager * GetTrackingManager () const
 
G4SteppingManager * GetSteppingManager () const
 

Static Public Member Functions

static UserActionManagerInstance ()
 
static void AddAndAdoptAction (UserAction *a)
 

Protected Member Functions

 UserActionManager ()
 

Private Types

typedef std::vector< UserAction * > fuserActions_t
 
typedef fuserActions_t::const_iterator fuserActions_ptr_t
 

Static Private Attributes

static fuserActions_t fuserActions
 

Detailed Description

Definition at line 60 of file UserActionManager.h.

Member Typedef Documentation

typedef std::vector<UserAction*> g4b::UserActionManager::fuserActions_t
private

Definition at line 111 of file UserActionManager.h.

Constructor & Destructor Documentation

g4b::UserActionManager::~UserActionManager ( )
virtual

Definition at line 43 of file UserActionManager.cxx.

References Close().

44  {
45  // This destructor is probably never going to be called. If it
46  // is, make sure all the UserAction classes we manage are deleted
47  // properly.
48  Close();
49  }
g4b::UserActionManager::UserActionManager ( )
protected

Definition at line 30 of file UserActionManager.cxx.

31  {
32  }

Member Function Documentation

void g4b::UserActionManager::BeginOfEventAction ( const G4Event *  a_event)
virtual

Definition at line 122 of file UserActionManager.cxx.

References fuserActions.

Referenced by AddAndAdoptAction().

123  {
124  for ( fuserActions_ptr_t i = fuserActions.begin(); i != fuserActions.end(); i++ ){
125  (*i)->BeginOfEventAction(a_event);
126  }
127  }
fuserActions_t::const_iterator fuserActions_ptr_t
static fuserActions_t fuserActions
void g4b::UserActionManager::BeginOfRunAction ( const G4Run *  a_run)
virtual

Definition at line 106 of file UserActionManager.cxx.

References fuserActions.

Referenced by AddAndAdoptAction().

107  {
108  for ( fuserActions_ptr_t i = fuserActions.begin(); i != fuserActions.end(); i++ ){
109  (*i)->BeginOfRunAction(a_run);
110  }
111  }
fuserActions_t::const_iterator fuserActions_ptr_t
static fuserActions_t fuserActions
G4ClassificationOfNewTrack g4b::UserActionManager::ClassifyNewTrack ( const G4Track *  a_track)
virtual

Definition at line 163 of file UserActionManager.cxx.

References fuserActions.

Referenced by AddAndAdoptAction().

164  {
165  std::map<G4ClassificationOfNewTrack,int> stackChoices;
166  for ( fuserActions_ptr_t i = fuserActions.begin(); i != fuserActions.end(); i++ ){
167  if ( (*i)->ProvidesStacking() ) {
168  G4ClassificationOfNewTrack choice = (*i)->StackClassifyNewTrack(a_track);
169  stackChoices[choice]++;
170  }
171  }
172  // based on all results pick an action
173  // fUrgent, // put into the urgent stack
174  // fWaiting, // put into the waiting stack
175  // fPostpone, // postpone to the next event
176  // fKill // kill without stacking
177 
178  //G4ClassificationOfNewTrack choice = fUrgent; // safe choice
179  // prioritize: anyone shoots it, it's dead;
180  // then postpone; then waiting; finally just process it
181  const G4ClassificationOfNewTrack priority[] =
182  { fKill, fPostpone, fWaiting, fUrgent };
183  const size_t nprio = sizeof(priority)/sizeof(G4ClassificationOfNewTrack);
184  for (unsigned int j=0; j<nprio; ++j) {
185  G4ClassificationOfNewTrack saction = priority[j];
186  if ( stackChoices[saction] > 0 ) return saction;
187  }
188  // shouldn't get here (already covered) ... but a fall back
189  return fUrgent;
190  }
fuserActions_t::const_iterator fuserActions_ptr_t
static fuserActions_t fuserActions
void g4b::UserActionManager::Close ( )

Definition at line 53 of file UserActionManager.cxx.

References fuserActions.

Referenced by g4b::G4Helper::~G4Helper(), and ~UserActionManager().

54  {
55  // Since we adopted the pointers for the user-action classes we're
56  // managing, delete all of them.
57  for ( fuserActions_t::iterator i = fuserActions.begin(); i != fuserActions.end(); i++ ){
58  delete *i;
59  }
60 
61  fuserActions.clear();
62  }
intermediate_table::iterator iterator
static fuserActions_t fuserActions
bool g4b::UserActionManager::DoesAnyActionProvideStacking ( )
virtual

Definition at line 213 of file UserActionManager.cxx.

References fuserActions.

Referenced by AddAndAdoptAction(), g4b::G4Helper::SetUserAction(), and g4b::G4Helper::~G4Helper().

214  {
215  // do any managed UserActions do stacking?
216  bool doany = false;
217  for ( fuserActions_ptr_t i = fuserActions.begin(); i != fuserActions.end(); i++ ){
218  doany |= (*i)->ProvidesStacking(); // any == take the "or"
219  }
220  return doany;
221  }
fuserActions_t::const_iterator fuserActions_ptr_t
static fuserActions_t fuserActions
void g4b::UserActionManager::EndOfEventAction ( const G4Event *  a_event)
virtual

Definition at line 130 of file UserActionManager.cxx.

References fuserActions.

Referenced by AddAndAdoptAction().

131  {
132  for ( fuserActions_ptr_t i = fuserActions.begin(); i != fuserActions.end(); i++ ) {
133  (*i)->EndOfEventAction(a_event);
134  }
135  }
fuserActions_t::const_iterator fuserActions_ptr_t
static fuserActions_t fuserActions
void g4b::UserActionManager::EndOfRunAction ( const G4Run *  a_run)
virtual

Definition at line 114 of file UserActionManager.cxx.

References fuserActions.

Referenced by AddAndAdoptAction().

115  {
116  for ( fuserActions_ptr_t i = fuserActions.begin(); i != fuserActions.end(); i++ ){
117  (*i)->EndOfRunAction(a_run);
118  }
119  }
fuserActions_t::const_iterator fuserActions_ptr_t
static fuserActions_t fuserActions
UserAction* g4b::UserActionManager::GetAction ( G4int  i) const
inline

Definition at line 76 of file UserActionManager.h.

References fuserActions, GetIndex(), and PrintActionList().

Referenced by PrintActionList().

76 { return fuserActions[i]; }
static fuserActions_t fuserActions
UserAction * g4b::UserActionManager::GetAction ( std::string const &  name) const

Definition at line 76 of file UserActionManager.cxx.

References fuserActions, and GetIndex().

77  {
78  G4int indx = GetIndex(name);
79  if ( indx < 0 ) return 0; // not found
80  return fuserActions[indx];
81  }
G4int GetIndex(std::string const &name) const
static fuserActions_t fuserActions
G4EventManager* g4b::UserActionManager::GetEventManager ( ) const
inline

Definition at line 106 of file UserActionManager.h.

106 { return fpEventManager; }
G4int g4b::UserActionManager::GetIndex ( std::string const &  name) const

Definition at line 65 of file UserActionManager.cxx.

References fuserActions.

Referenced by GetAction().

66  {
67  int indx=0;
68  for ( fuserActions_ptr_t i = fuserActions.begin(); i != fuserActions.end(); i++, indx++ ){
69  if ( (*i)->GetName() == name ) return indx;
70  }
71  // not found
72  return -1;
73  }
fuserActions_t::const_iterator fuserActions_ptr_t
static fuserActions_t fuserActions
G4int g4b::UserActionManager::GetSize ( ) const
inline

Definition at line 75 of file UserActionManager.h.

References fuserActions.

Referenced by PrintActionList().

75 { return fuserActions.size(); }
static fuserActions_t fuserActions
G4SteppingManager* g4b::UserActionManager::GetSteppingManager ( ) const
inline

Definition at line 108 of file UserActionManager.h.

108 { return fpSteppingManager; }
G4TrackingManager* g4b::UserActionManager::GetTrackingManager ( ) const
inline

Definition at line 107 of file UserActionManager.h.

107 { return fpTrackingManager; }
UserActionManager * g4b::UserActionManager::Instance ( )
static

Definition at line 36 of file UserActionManager.cxx.

References instance.

Referenced by larg4::LArG4::beginJob(), g4b::G4Helper::SetUserAction(), and g4b::G4Helper::~G4Helper().

37  {
39  return &instance;
40  }
const std::string instance
void g4b::UserActionManager::NewStage ( )
virtual

Definition at line 193 of file UserActionManager.cxx.

References fuserActions.

Referenced by AddAndAdoptAction().

194  {
195  for ( fuserActions_ptr_t i = fuserActions.begin(); i != fuserActions.end(); i++ ){
196  if ( (*i)->ProvidesStacking() ) {
197  (*i)->StackNewStage();
198  }
199  }
200  }
fuserActions_t::const_iterator fuserActions_ptr_t
static fuserActions_t fuserActions
void g4b::UserActionManager::PostUserTrackingAction ( const G4Track *  a_track)
virtual

Definition at line 146 of file UserActionManager.cxx.

References fuserActions.

Referenced by AddAndAdoptAction().

147  {
148  for ( fuserActions_ptr_t i = fuserActions.begin(); i != fuserActions.end(); i++ ){
149  (*i)->PostTrackingAction(a_track);
150  }
151  }
fuserActions_t::const_iterator fuserActions_ptr_t
static fuserActions_t fuserActions
void g4b::UserActionManager::PrepareNewEvent ( )
virtual

Definition at line 203 of file UserActionManager.cxx.

References fuserActions.

Referenced by AddAndAdoptAction().

204  {
205  for ( fuserActions_ptr_t i = fuserActions.begin(); i != fuserActions.end(); i++ ){
206  if ( (*i)->ProvidesStacking() ) {
207  (*i)->StackPrepareNewEvent();
208  }
209  }
210  }
fuserActions_t::const_iterator fuserActions_ptr_t
static fuserActions_t fuserActions
void g4b::UserActionManager::PreUserTrackingAction ( const G4Track *  a_track)
virtual

Definition at line 138 of file UserActionManager.cxx.

References fuserActions.

Referenced by AddAndAdoptAction().

139  {
140  for ( fuserActions_ptr_t i = fuserActions.begin(); i != fuserActions.end(); i++ ){
141  (*i)->PreTrackingAction(a_track);
142  }
143  }
fuserActions_t::const_iterator fuserActions_ptr_t
static fuserActions_t fuserActions
void g4b::UserActionManager::PrintActionList ( std::string const &  opt) const

Definition at line 84 of file UserActionManager.cxx.

References GetAction(), g4b::UserAction::GetName(), GetSize(), g4b::UserAction::PrintConfig(), and g4b::UserAction::ProvidesStacking().

Referenced by GetAction().

85  {
86  bool pcfg = ( opt.find("config") != std::string::npos );
87  std::cout << "UserActionManager::PrintActionList " << GetSize()
88  << " entries" << std::endl;
89  for ( G4int indx=0; indx < GetSize(); ++indx ) {
90  UserAction* action = GetAction(indx);
91  std::cout << " [" << indx << "] " << action->GetName()
92  << ( action->ProvidesStacking() ? " [stacking]":"" )
93  << std::endl;
94  if ( pcfg ) action->PrintConfig(opt);
95  }
96  }
UserAction * GetAction(G4int i) const
void g4b::UserActionManager::UserSteppingAction ( const G4Step *  a_step)
virtual

Definition at line 154 of file UserActionManager.cxx.

References fuserActions.

Referenced by AddAndAdoptAction().

155  {
156  for ( fuserActions_ptr_t i = fuserActions.begin(); i != fuserActions.end(); i++ ){
157  (*i)->SteppingAction(a_step);
158  }
159  }
fuserActions_t::const_iterator fuserActions_ptr_t
static fuserActions_t fuserActions

Member Data Documentation


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