GGS(GenericGEANT4Simulation)Software  2.7.0
 All Data Structures Namespaces Files Functions Variables Typedefs Macros
Public Member Functions | Static Public Member Functions
GGSUserActionsManager Class Reference

The GGS ser actions manager. More...

#include <GGSUserActionsManager.h>

Inheritance diagram for GGSUserActionsManager:
Inheritance graph
[legend]
Collaboration diagram for GGSUserActionsManager:
Collaboration graph
[legend]

Public Member Functions

 ~GGSUserActionsManager ()
 Destructor. More...
 
void AddAction (GGSUserAction *userAction)
 Adds a general user action. More...
 
void AddAction (G4UserSteppingAction *steppingAction)
 Adds a stepping action. More...
 
void AddAction (G4UserTrackingAction *trackingAction)
 Adds a tracking action. More...
 
void AddAction (G4UserEventAction *eventAction)
 Adds a event action. More...
 
void AddAction (G4UserRunAction *runAction)
 Adds a run action. More...
 
void AddAction (G4UserStackingAction *stackingAction)
 Adds a stacking action. More...
 
void UserSteppingAction (const G4Step *step)
 Override of UserSteppingAction method. More...
 
void PreUserTrackingAction (const G4Track *track)
 Override of PreUserTrackingAction method. More...
 
void PostUserTrackingAction (const G4Track *track)
 Override of PostUserTrackingAction method. More...
 
void BeginOfEventAction (const G4Event *event)
 Override of BeginOfEventAction method. More...
 
void EndOfEventAction (const G4Event *event)
 Override of EndOfEventAction method. More...
 
void BeginOfRunAction (const G4Run *run)
 Override of BeginOfRunAction method. More...
 
void EndOfRunAction (const G4Run *run)
 Override of EndOfRunAction method. More...
 
G4ClassificationOfNewTrack ClassifyNewTrack (const G4Track *aTrack)
 Override of ClassifyNewTrack method. More...
 
void NewStage ()
 Override of NewStage method. More...
 
void PrepareNewEvent ()
 Override of PrepareNewEvent method. More...
 
- Public Member Functions inherited from GGSUserAction
 GGSUserAction ()
 Constructor. More...
 
virtual ~GGSUserAction ()
 Destructor.
 
G4ClassificationOfNewTrack ClassifyNewTrack (const G4Track *)
 Override of the ClassifyNewTrack method. More...
 

Static Public Member Functions

static GGSUserActionsManagerGetInstance ()
 Get the singleton instance. More...
 

Detailed Description

The GGS ser actions manager.

This class is intended as an actions container. User can fill it with desired actions and the manager will provide the necessary interface to GEANT4 kernel calls. The main aim of this software layer is to give the user the possibility to define and use the set of actions which is most suitable for the specific simulation. The manager can contain general actions inheriting from GGSUserAction (which can do something at each simulation level) as well as actions inheriting from regular GEANT4 user actions (like G4UserEventAction, which acts only at the beginning and at the end of an event. The actions are NOT guaranteed to be executed in the same order they are added to the manager. The manager in current implementation owns the actions; this means that when the manager is destroyed it will delete all the actions it contains.

Definition at line 32 of file GGSUserActionsManager.h.

Constructor & Destructor Documentation

GGSUserActionsManager::~GGSUserActionsManager ( )

Destructor.

It destroys also the actions previously added to the manager.

Definition at line 33 of file GGSUserActionsManager.cpp.

33  {
34 
35  // Delete general actions
36  for (unsigned int i = 0; i < _userActions.size(); i++)
37  if (_userActions[i]) {
38  delete _userActions[i];
39  }
40  // Delete stepping actions
41  for (unsigned int i = 0; i < _steppingActions.size(); i++)
42  if (_steppingActions[i]) {
43  delete _steppingActions[i];
44  }
45  // Delete tracking actions
46  for (unsigned int i = 0; i < _trackingActions.size(); i++)
47  if (_trackingActions[i]) {
48  delete _trackingActions[i];
49  }
50  // Delete event actions
51  for (unsigned int i = 0; i < _eventActions.size(); i++)
52  if (_eventActions[i]) {
53  delete _eventActions[i];
54  }
55  // Delete run actions
56  for (unsigned int i = 0; i < _runActions.size(); i++)
57  if (_runActions[i]) {
58  delete _runActions[i];
59  }
60 
61  // Warning: this destructor will be called by ~G4Manager, which runs after
62  // ~GGSRunManager. So at this stage the child GGSRunManager is no
63  // more available and thus the mother G4Manager must be referenced.
64  // TODO: handle the destruction of the actions manager inside ~GGSRunManager, when
65  // the GGSRunManager interface has been properly extended to handle the
66  // actions manager.
67  G4RunManager *runManager = G4RunManager::GetRunManager();
68  if (runManager->GetUserSteppingAction() == this)
69  runManager->SetUserAction((G4UserSteppingAction *)0);
70  if (runManager->GetUserTrackingAction() == this)
71  runManager->SetUserAction((G4UserTrackingAction *)0);
72  if (runManager->GetUserEventAction() == this)
73  runManager->SetUserAction((G4UserEventAction *)0);
74  if (runManager->GetUserRunAction() == this)
75  runManager->SetUserAction((G4UserRunAction *)0);
76  if (runManager->GetUserStackingAction() == this)
77  runManager->SetUserAction((G4UserStackingAction *)0);
78 
79  // delete messenger
80  delete _messenger;
81 }

Member Function Documentation

void GGSUserActionsManager::AddAction ( GGSUserAction userAction)

Adds a general user action.

Parameters
userActionThe general user action to be added to the manager.

Definition at line 85 of file GGSUserActionsManager.cpp.

85  {
86  if (userAction) {
87  _userActions.push_back(userAction);
88  _userActions.back()->SetTrackingManagerPointer(fpTrackingManager);
89  }
90 }
void GGSUserActionsManager::AddAction ( G4UserSteppingAction *  steppingAction)

Adds a stepping action.

Parameters
steppingActionThe stepping action to be added to the manager.

Definition at line 94 of file GGSUserActionsManager.cpp.

94  {
95  if (steppingAction)
96  _steppingActions.push_back(steppingAction);
97 }
void GGSUserActionsManager::AddAction ( G4UserTrackingAction *  trackingAction)

Adds a tracking action.

Parameters
trackingActionThe tracking action to be added to the manager.

Definition at line 101 of file GGSUserActionsManager.cpp.

101  {
102  if (trackingAction) {
103  _trackingActions.push_back(trackingAction);
104  _trackingActions.back()->SetTrackingManagerPointer(fpTrackingManager);
105  }
106 }
void GGSUserActionsManager::AddAction ( G4UserEventAction *  eventAction)

Adds a event action.

Parameters
eventActionThe event action to be added to the manager.

Definition at line 110 of file GGSUserActionsManager.cpp.

110  {
111  if (eventAction)
112  _eventActions.push_back(eventAction);
113 }
void GGSUserActionsManager::AddAction ( G4UserRunAction *  runAction)

Adds a run action.

Parameters
runActionThe run action to be added to the manager.

Definition at line 117 of file GGSUserActionsManager.cpp.

117  {
118  if (runAction)
119  _runActions.push_back(runAction);
120 }
void GGSUserActionsManager::AddAction ( G4UserStackingAction *  stackingAction)

Adds a stacking action.

Parameters
stackingActionThe stacking action to be added to the manager.
void GGSUserActionsManager::BeginOfEventAction ( const G4Event *  event)

Override of BeginOfEventAction method.

This routine calls BeginOfEventAction for every general and event actions in the manager.

Parameters
eventThe current event.

Definition at line 163 of file GGSUserActionsManager.cpp.

163  {
164 
165  // Call routine for general actions
166  for (unsigned int i = 0; i < _userActions.size(); i++)
167  _userActions[i]->BeginOfEventAction(event);
168 
169  // Call routine for event actions
170  for (unsigned int i = 0; i < _eventActions.size(); i++)
171  _eventActions[i]->BeginOfEventAction(event);
172 }
void BeginOfEventAction(const G4Event *event)
Override of BeginOfEventAction method.
void GGSUserActionsManager::BeginOfRunAction ( const G4Run *  run)

Override of BeginOfRunAction method.

This routine calls BeginOfRunAction for every general and run actions in the manager.

Parameters
runThe current run.

Definition at line 194 of file GGSUserActionsManager.cpp.

194  {
195 
196  // Call routine for general actions
197  for (unsigned int i = 0; i < _userActions.size(); i++)
198  _userActions[i]->BeginOfRunAction(run);
199 
200  // Call routine for run actions
201  for (unsigned int i = 0; i < _runActions.size(); i++)
202  _runActions[i]->BeginOfRunAction(run);
203 }
void BeginOfRunAction(const G4Run *run)
Override of BeginOfRunAction method.
G4ClassificationOfNewTrack GGSUserActionsManager::ClassifyNewTrack ( const G4Track *  aTrack)

Override of ClassifyNewTrack method.

This routine calls ClassifyNewTrack for every general actions in the manager. If no general actions are present, or if none of them reimplements ClassifyNewTrack properly, it returns the return value of G4UserStackingAction::ClassifyNewTrack. If more actions are present and the classifications are not in agreement, the default classification given by G4UserStackingAction::ClassifyNewTrack will be returned;

Parameters
aTrackThe new track.

Definition at line 220 of file GGSUserActionsManager.cpp.

220  {
221 
222  int classif, actionClassif;
223  classif = -100;
224 
225  for (unsigned int i = 0; i < _userActions.size(); i++) {
226  actionClassif = _userActions[i]->ClassifyNewTrack(aTrack);
227  if (actionClassif != -100) {
228  if (actionClassif != classif && classif != -100) {
229  return G4UserStackingAction::ClassifyNewTrack(aTrack);
230  } else
231  classif = actionClassif;
232  }
233  }
234  if (classif == -100)
235  return G4UserStackingAction::ClassifyNewTrack(aTrack);
236  else
237  return (G4ClassificationOfNewTrack)classif;
238 }
void GGSUserActionsManager::EndOfEventAction ( const G4Event *  event)

Override of EndOfEventAction method.

This routine calls EndOfEventAction for every general and event actions in the manager.

Parameters
eventThe current event.

Definition at line 176 of file GGSUserActionsManager.cpp.

176  {
177 
178  if (!GGSRunManager::GetRunManager()->IsCurrentEventKilled()) {
179 
180  // Call routine for general actions
181  for (unsigned int i = 0; i < _userActions.size(); i++)
182  _userActions[i]->EndOfEventAction(event);
183 
184  // Call routine for event actions
185  for (unsigned int i = 0; i < _eventActions.size(); i++)
186  _eventActions[i]->EndOfEventAction(event);
187 
188  GGSRootFileService::GetInstance()._FillDefaultEventsTrees();
189  }
190 }
static GGSRunManager * GetRunManager()
Static getter function the run manager.
static GGSRootFileService & GetInstance()
Get reference to GGSRootFileService unique instance.
void EndOfEventAction(const G4Event *event)
Override of EndOfEventAction method.
void GGSUserActionsManager::EndOfRunAction ( const G4Run *  run)

Override of EndOfRunAction method.

This routine calls EndOfRunAction for every general and run actions in the manager.

Parameters
runThe current run.

Definition at line 207 of file GGSUserActionsManager.cpp.

207  {
208 
209  // Call routine for general actions
210  for (unsigned int i = 0; i < _userActions.size(); i++)
211  _userActions[i]->EndOfRunAction(run);
212 
213  // Call routine for run actions
214  for (unsigned int i = 0; i < _runActions.size(); i++)
215  _runActions[i]->EndOfRunAction(run);
216 }
void EndOfRunAction(const G4Run *run)
Override of EndOfRunAction method.
GGSUserActionsManager * GGSUserActionsManager::GetInstance ( )
static

Get the singleton instance.

This method instantiate the singleton when it is first called. Every access to the manager must be done using the returned pointer.

Returns
A pointer to the singleton instance of GGSUserActionsManager.

Definition at line 20 of file GGSUserActionsManager.cpp.

20  {
21  if (!_instance)
22  _instance = new GGSUserActionsManager();
23 
24  return _instance;
25 }
The GGS ser actions manager.
void GGSUserActionsManager::NewStage ( )

Override of NewStage method.

This routine calls NewStage for every general and stacking actions in the manager.

Definition at line 242 of file GGSUserActionsManager.cpp.

242  {
243  for (unsigned int i = 0; i < _userActions.size(); i++) {
244  _userActions[i]->NewStage();
245  }
246 }
void GGSUserActionsManager::PostUserTrackingAction ( const G4Track *  track)

Override of PostUserTrackingAction method.

This routine calls PostUserTrackingAction for every general and tracking actions in the manager.

Parameters
trackThe current track.

Definition at line 150 of file GGSUserActionsManager.cpp.

150  {
151 
152  // Call routine for general actions
153  for (unsigned int i = 0; i < _userActions.size(); i++)
154  _userActions[i]->PostUserTrackingAction(track);
155 
156  // Call routine for tracking actions
157  for (unsigned int i = 0; i < _trackingActions.size(); i++)
158  _trackingActions[i]->PostUserTrackingAction(track);
159 }
void PostUserTrackingAction(const G4Track *track)
Override of PostUserTrackingAction method.
void GGSUserActionsManager::PrepareNewEvent ( )

Override of PrepareNewEvent method.

This routine calls PrepareNewEvent for every general and stacking actions in the manager.

Definition at line 250 of file GGSUserActionsManager.cpp.

250  {
251 
252  for (unsigned int i = 0; i < _userActions.size(); i++) {
253  _userActions[i]->PrepareNewEvent();
254  }
255 }
void GGSUserActionsManager::PreUserTrackingAction ( const G4Track *  track)

Override of PreUserTrackingAction method.

This routine calls PreUserTrackingAction for every general and tracking actions in the manager.

Parameters
trackThe current track.

Definition at line 137 of file GGSUserActionsManager.cpp.

137  {
138 
139  // Call routine for general actions
140  for (unsigned int i = 0; i < _userActions.size(); i++)
141  _userActions[i]->PreUserTrackingAction(track);
142 
143  // Call routine for tracking actions
144  for (unsigned int i = 0; i < _trackingActions.size(); i++)
145  _trackingActions[i]->PreUserTrackingAction(track);
146 }
void PreUserTrackingAction(const G4Track *track)
Override of PreUserTrackingAction method.
void GGSUserActionsManager::UserSteppingAction ( const G4Step *  step)

Override of UserSteppingAction method.

This routine calls UserSteppingAction for every general and stepping actions in the manager.

Parameters
stepThe current step.

Definition at line 124 of file GGSUserActionsManager.cpp.

124  {
125 
126  // Call routine for general actions
127  for (unsigned int i = 0; i < _userActions.size(); i++)
128  _userActions[i]->UserSteppingAction(step);
129 
130  // Call routine for stepping actions
131  for (unsigned int i = 0; i < _steppingActions.size(); i++)
132  _steppingActions[i]->UserSteppingAction(step);
133 }
void UserSteppingAction(const G4Step *step)
Override of UserSteppingAction method.

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