Singleton manager class for handling and steering a run with multiple TVirtualMC engines sharing events.
It provides interfaces to transfer tracks between engines and exposes the correct stacks to each running engine. A registered user stack is kept up-to-date automatically seeing a consistent history. Track objects (aka TParticle) are still owned by the user who must forward these to the manager after creation. Everything else is done automatically.
Definition at line 36 of file TMCManager.h.
Public Member Functions | |
TMCManager () | |
Default constructor. More... | |
virtual | ~TMCManager () |
Destructor. More... | |
template<typename F > | |
void | Apply (F engineLambda) |
Apply something to all engines. More... | |
void | ConnectEnginePointer (TVirtualMC *&mc) |
Connect a pointer which is updated whenever the engine is changed. More... | |
void | ConnectEnginePointer (TVirtualMC **mc) |
Connect a pointer which is updated whenever the engine is changed. More... | |
void | ForwardTrack (Int_t toBeDone, Int_t trackId, Int_t parentId, TParticle *particle) |
User interface to forward particle to specifiic engine. More... | |
void | ForwardTrack (Int_t toBeDone, Int_t trackId, Int_t parentId, TParticle *particle, Int_t engineId) |
User interface to forward particle to specifiic engine. More... | |
TVirtualMC * | GetCurrentEngine () const |
Get the current engine pointer. More... | |
TVirtualMC * | GetEngine (Int_t id) const |
Get an engine pointer by ID. More... | |
Int_t | GetEngineId (const char *name) const |
Get engine ID by its name. More... | |
void | GetEngines (std::vector< TVirtualMC * > &engines) const |
Get registered engine pointers. More... | |
void | Init () |
Initialize engines. More... | |
template<typename F > | |
void | Init (F initFunction) |
Further specific initialization. More... | |
Int_t | NEngines () const |
Return the number of registered engines. More... | |
void | Register (TVirtualMC *engine) |
A TVirtualMC will register itself via this method during construction if a TMCManager was instanciated before. More... | |
void | Register (TVirtualMCApplication *application) |
The user application will register itself via this method when the manager was requested. More... | |
Bool_t | RestoreGeometryState () |
Try to restore geometry for the track currently set. More... | |
Bool_t | RestoreGeometryState (Int_t trackId, Bool_t checkTrackIdRange=kTRUE) |
Try to restore geometry for a given track. More... | |
void | Run (Int_t nEvents) |
Run the event loop. More... | |
void | SetUserStack (TVirtualMCStack *stack) |
Set user stack. More... | |
void | TransferTrack (Int_t engineTargetId) |
Transfer track from current engine to engine with engineTargetId. More... | |
void | TransferTrack (TVirtualMC *mc) |
Transfer track from current engine to target engine mc. More... | |
Static Public Member Functions | |
static TMCManager * | Instance () |
Static access method. More... | |
Private Member Functions | |
Bool_t | GetNextEngine () |
Find the next engine. More... | |
void | PrepareNewEvent () |
Do necessary steps before an event is triggered. More... | |
void | TerminateRun () |
Terminate a run in all engines. More... | |
void | UpdateEnginePointers (TVirtualMC *mc) |
Update all engine pointers connected to the TMCManager. More... | |
Private Attributes | |
TVirtualMCApplication * | fApplication |
Pointer to user application. More... | |
TGeoMCBranchArrayContainer | fBranchArrayContainer |
Pointer to cache with geometry states. More... | |
std::vector< TVirtualMC ** > | fConnectedEnginePointers |
Connected engine pointers which will be updated everytime the current engine changes. More... | |
TVirtualMC * | fCurrentEngine |
Pointer to current engine. More... | |
std::vector< TVirtualMC * > | fEngines |
Collecting pointers to all instanciated TVirtualMCs. More... | |
Bool_t | fIsInitialized |
Flag if engines are initilaized. More... | |
Bool_t | fIsInitializedUser |
Flag if specific initialization for engines was done. More... | |
std::vector< TParticle * > | fParticles |
All tracks (persistent) More... | |
std::vector< std::unique_ptr< TMCParticleStatus > > | fParticlesStatus |
All particles' status (persistent) More... | |
std::vector< std::unique_ptr< TMCManagerStack > > | fStacks |
Stacks connected to engines. More... | |
Int_t | fTotalNPrimaries |
Total number of primaries ever pushed. More... | |
Int_t | fTotalNTracks |
Total number of tracks ever pushed. More... | |
TVirtualMCStack * | fUserStack |
Pointer to user stack. More... | |
Static Private Attributes | |
static TMCThreadLocal TMCManager * | fgInstance = nullptr |
Singleton instance. More... | |
Friends | |
class | TVirtualMCApplication |
#include <TMCManager.h>
TMCManager::TMCManager | ( | ) |
Default constructor.
Default and standard constructor.
Definition at line 46 of file TMCManager.cxx.
|
virtual |
Destructor.
Definition at line 61 of file TMCManager.cxx.
Apply something to all engines.
Definition at line 120 of file TMCManager.h.
void TMCManager::ConnectEnginePointer | ( | TVirtualMC *& | mc | ) |
Connect a pointer which is updated whenever the engine is changed.
Definition at line 212 of file TMCManager.cxx.
void TMCManager::ConnectEnginePointer | ( | TVirtualMC ** | mc | ) |
Connect a pointer which is updated whenever the engine is changed.
Definition at line 199 of file TMCManager.cxx.
void TMCManager::ForwardTrack | ( | Int_t | toBeDone, |
Int_t | trackId, | ||
Int_t | parentId, | ||
TParticle * | particle | ||
) |
User interface to forward particle to specifiic engine.
It is assumed that the TParticle is owned by the user. It will not be modified by the TMCManager. Assume current engine Id
Definition at line 270 of file TMCManager.cxx.
void TMCManager::ForwardTrack | ( | Int_t | toBeDone, |
Int_t | trackId, | ||
Int_t | parentId, | ||
TParticle * | particle, | ||
Int_t | engineId | ||
) |
User interface to forward particle to specifiic engine.
It is assumed that the TParticle is owned by the user. It will not be modified by the TMCManager.
Definition at line 234 of file TMCManager.cxx.
TVirtualMC * TMCManager::GetCurrentEngine | ( | ) | const |
Get the current engine pointer.
Definition at line 189 of file TMCManager.cxx.
TVirtualMC * TMCManager::GetEngine | ( | Int_t | id | ) | const |
Get an engine pointer by ID.
Return the number of registered engines.
Definition at line 160 of file TMCManager.cxx.
Int_t TMCManager::GetEngineId | ( | const char * | name | ) | const |
Get engine ID by its name.
Definition at line 173 of file TMCManager.cxx.
void TMCManager::GetEngines | ( | std::vector< TVirtualMC * > & | engines | ) | const |
Get registered engine pointers.
Definition at line 146 of file TMCManager.cxx.
|
private |
Find the next engine.
Choose next engines to be run in the loop.
Definition at line 462 of file TMCManager.cxx.
void TMCManager::Init | ( | ) |
Initialize engines.
Definition at line 364 of file TMCManager.cxx.
Further specific initialization.
Definition at line 134 of file TMCManager.h.
|
static |
Static access method.
Definition at line 74 of file TMCManager.cxx.
Int_t TMCManager::NEngines | ( | ) | const |
Return the number of registered engines.
Definition at line 136 of file TMCManager.cxx.
|
private |
Do necessary steps before an event is triggered.
Choose next engines to be run in the loop.
Definition at line 440 of file TMCManager.cxx.
void TMCManager::Register | ( | TVirtualMC * | mc | ) |
A TVirtualMC will register itself via this method during construction if a TMCManager was instanciated before.
The TMCManager will assign an ID to the engines.
Definition at line 86 of file TMCManager.cxx.
void TMCManager::Register | ( | TVirtualMCApplication * | application | ) |
The user application will register itself via this method when the manager was requested.
Definition at line 111 of file TMCManager.cxx.
Bool_t TMCManager::RestoreGeometryState | ( | ) |
Try to restore geometry for the track currently set.
Definition at line 354 of file TMCManager.cxx.
Try to restore geometry for a given track.
Definition at line 332 of file TMCManager.cxx.
Run the event loop.
Definition at line 408 of file TMCManager.cxx.
void TMCManager::SetUserStack | ( | TVirtualMCStack * | stack | ) |
Set user stack.
Definition at line 222 of file TMCManager.cxx.
|
private |
Terminate a run in all engines.
Terminate the run for all engines.
Definition at line 495 of file TMCManager.cxx.
Transfer track from current engine to engine with engineTargetId.
Definition at line 280 of file TMCManager.cxx.
void TMCManager::TransferTrack | ( | TVirtualMC * | mc | ) |
Transfer track from current engine to target engine mc.
Definition at line 295 of file TMCManager.cxx.
|
private |
Update all engine pointers connected to the TMCManager.
Definition at line 480 of file TMCManager.cxx.
|
friend |
Definition at line 38 of file TMCManager.h.
|
private |
Pointer to user application.
Definition at line 170 of file TMCManager.h.
|
private |
Pointer to cache with geometry states.
Definition at line 191 of file TMCManager.h.
|
private |
Connected engine pointers which will be updated everytime the current engine changes.
Definition at line 187 of file TMCManager.h.
|
private |
Pointer to current engine.
Definition at line 172 of file TMCManager.h.
|
private |
Collecting pointers to all instanciated TVirtualMCs.
Definition at line 174 of file TMCManager.h.
|
staticprivate |
Singleton instance.
Definition at line 164 of file TMCManager.h.
|
private |
Flag if engines are initilaized.
Definition at line 193 of file TMCManager.h.
|
private |
Flag if specific initialization for engines was done.
Definition at line 195 of file TMCManager.h.
|
private |
All tracks (persistent)
Definition at line 178 of file TMCManager.h.
|
private |
All particles' status (persistent)
Definition at line 180 of file TMCManager.h.
|
private |
Stacks connected to engines.
Definition at line 176 of file TMCManager.h.
|
private |
Total number of primaries ever pushed.
Definition at line 182 of file TMCManager.h.
|
private |
Total number of tracks ever pushed.
Definition at line 184 of file TMCManager.h.
|
private |
Pointer to user stack.
Definition at line 189 of file TMCManager.h.