GGS(GenericGEANT4Simulation)Software  2.6.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 35 of file GGSUserActionsManager.cpp.

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

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 87 of file GGSUserActionsManager.cpp.

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

Adds a stepping action.

Parameters
steppingActionThe stepping action to be added to the manager.

Definition at line 96 of file GGSUserActionsManager.cpp.

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

Adds a tracking action.

Parameters
trackingActionThe tracking action to be added to the manager.

Definition at line 103 of file GGSUserActionsManager.cpp.

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

Adds a event action.

Parameters
eventActionThe event action to be added to the manager.

Definition at line 112 of file GGSUserActionsManager.cpp.

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

Adds a run action.

Parameters
runActionThe run action to be added to the manager.

Definition at line 119 of file GGSUserActionsManager.cpp.

119  {
120  if (runAction)
121  _runActions.push_back(runAction);
122 }
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 166 of file GGSUserActionsManager.cpp.

166  {
167 
168  // Call routine for general actions
169  for (unsigned int i = 0; i < _userActions.size(); i++)
170  _userActions[i]->BeginOfEventAction(event);
171 
172  // Call routine for event actions
173  for (unsigned int i = 0; i < _eventActions.size(); i++)
174  _eventActions[i]->BeginOfEventAction(event);
175 }
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 197 of file GGSUserActionsManager.cpp.

197  {
198 
199  // Call routine for general actions
200  for (unsigned int i = 0; i < _userActions.size(); i++)
201  _userActions[i]->BeginOfRunAction(run);
202 
203  // Call routine for run actions
204  for (unsigned int i = 0; i < _runActions.size(); i++)
205  _runActions[i]->BeginOfRunAction(run);
206 }
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 223 of file GGSUserActionsManager.cpp.

223  {
224 
225  int classif, actionClassif;
226  classif = -100;
227 
228  for (unsigned int i = 0; i < _userActions.size(); i++) {
229  actionClassif = _userActions[i]->ClassifyNewTrack(aTrack);
230  if (actionClassif != -100) {
231  if (actionClassif != classif && classif != -100) {
232  return G4UserStackingAction::ClassifyNewTrack(aTrack);
233  }
234  else
235  classif = actionClassif;
236  }
237  }
238  if (classif == -100)
239  return G4UserStackingAction::ClassifyNewTrack(aTrack);
240  else
241  return (G4ClassificationOfNewTrack) classif;
242 }
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 179 of file GGSUserActionsManager.cpp.

179  {
180 
181  if (!GGSRunManager::GetRunManager()->IsCurrentEventKilled()) {
182 
183  // Call routine for general actions
184  for (unsigned int i = 0; i < _userActions.size(); i++)
185  _userActions[i]->EndOfEventAction(event);
186 
187  // Call routine for event actions
188  for (unsigned int i = 0; i < _eventActions.size(); i++)
189  _eventActions[i]->EndOfEventAction(event);
190 
191  GGSRootFileService::GetInstance()._FillDefaultEventsTrees();
192  }
193 }
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 210 of file GGSUserActionsManager.cpp.

210  {
211 
212  // Call routine for general actions
213  for (unsigned int i = 0; i < _userActions.size(); i++)
214  _userActions[i]->EndOfRunAction(run);
215 
216  // Call routine for run actions
217  for (unsigned int i = 0; i < _runActions.size(); i++)
218  _runActions[i]->EndOfRunAction(run);
219 }
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 246 of file GGSUserActionsManager.cpp.

246  {
247  for (unsigned int i = 0; i < _userActions.size(); i++) {
248  _userActions[i]->NewStage();
249  }
250 }
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 152 of file GGSUserActionsManager.cpp.

152  {
153 
154  // Call routine for general actions
155  for (unsigned int i = 0; i < _userActions.size(); i++)
156  _userActions[i]->PostUserTrackingAction(track);
157 
158  // Call routine for tracking actions
159  for (unsigned int i = 0; i < _trackingActions.size(); i++)
160  _trackingActions[i]->PostUserTrackingAction(track);
161 
162 }
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 254 of file GGSUserActionsManager.cpp.

254  {
255 
256  for (unsigned int i = 0; i < _userActions.size(); i++) {
257  _userActions[i]->PrepareNewEvent();
258  }
259 }
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 139 of file GGSUserActionsManager.cpp.

139  {
140 
141  // Call routine for general actions
142  for (unsigned int i = 0; i < _userActions.size(); i++)
143  _userActions[i]->PreUserTrackingAction(track);
144 
145  // Call routine for tracking actions
146  for (unsigned int i = 0; i < _trackingActions.size(); i++)
147  _trackingActions[i]->PreUserTrackingAction(track);
148 }
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 126 of file GGSUserActionsManager.cpp.

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

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