Logo ROOT  
Reference Guide
TMCManager Class Reference

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...
 
TVirtualMCGetCurrentEngine () const
 Get the current engine pointer. More...
 
TVirtualMCGetEngine (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 TMCManagerInstance ()
 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

TVirtualMCApplicationfApplication
 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...
 
TVirtualMCfCurrentEngine
 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...
 
TVirtualMCStackfUserStack
 Pointer to user stack. More...
 

Static Private Attributes

static TMCThreadLocal TMCManagerfgInstance = nullptr
 Singleton instance. More...
 

Friends

class TVirtualMCApplication
 

#include <TMCManager.h>

Constructor & Destructor Documentation

◆ TMCManager()

TMCManager::TMCManager ( )

Default constructor.

Default and standard constructor.

Definition at line 46 of file TMCManager.cxx.

◆ ~TMCManager()

TMCManager::~TMCManager ( )
virtual

Destructor.

Definition at line 61 of file TMCManager.cxx.

Member Function Documentation

◆ Apply()

template<typename F >
void TMCManager::Apply ( F  engineLambda)
inline

Apply something to all engines.

Definition at line 120 of file TMCManager.h.

◆ ConnectEnginePointer() [1/2]

void TMCManager::ConnectEnginePointer ( TVirtualMC *&  mc)

Connect a pointer which is updated whenever the engine is changed.

Definition at line 212 of file TMCManager.cxx.

◆ ConnectEnginePointer() [2/2]

void TMCManager::ConnectEnginePointer ( TVirtualMC **  mc)

Connect a pointer which is updated whenever the engine is changed.

Definition at line 199 of file TMCManager.cxx.

◆ ForwardTrack() [1/2]

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.

◆ ForwardTrack() [2/2]

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.

◆ GetCurrentEngine()

TVirtualMC * TMCManager::GetCurrentEngine ( ) const

Get the current engine pointer.

Definition at line 189 of file TMCManager.cxx.

◆ GetEngine()

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.

◆ GetEngineId()

Int_t TMCManager::GetEngineId ( const char *  name) const

Get engine ID by its name.

Definition at line 173 of file TMCManager.cxx.

◆ GetEngines()

void TMCManager::GetEngines ( std::vector< TVirtualMC * > &  engines) const

Get registered engine pointers.

Definition at line 146 of file TMCManager.cxx.

◆ GetNextEngine()

Bool_t TMCManager::GetNextEngine ( )
private

Find the next engine.

Choose next engines to be run in the loop.

Definition at line 462 of file TMCManager.cxx.

◆ Init() [1/2]

void TMCManager::Init ( )

Initialize engines.

Definition at line 364 of file TMCManager.cxx.

◆ Init() [2/2]

template<typename F >
void TMCManager::Init ( F  initFunction)
inline

Further specific initialization.

Definition at line 134 of file TMCManager.h.

◆ Instance()

TMCManager * TMCManager::Instance ( )
static

Static access method.

Definition at line 74 of file TMCManager.cxx.

◆ NEngines()

Int_t TMCManager::NEngines ( ) const

Return the number of registered engines.

Definition at line 136 of file TMCManager.cxx.

◆ PrepareNewEvent()

void TMCManager::PrepareNewEvent ( )
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.

◆ Register() [1/2]

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.

◆ Register() [2/2]

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.

◆ RestoreGeometryState() [1/2]

Bool_t TMCManager::RestoreGeometryState ( )

Try to restore geometry for the track currently set.

Definition at line 354 of file TMCManager.cxx.

◆ RestoreGeometryState() [2/2]

Bool_t TMCManager::RestoreGeometryState ( Int_t  trackId,
Bool_t  checkTrackIdRange = kTRUE 
)

Try to restore geometry for a given track.

Definition at line 332 of file TMCManager.cxx.

◆ Run()

void TMCManager::Run ( Int_t  nEvents)

Run the event loop.

Definition at line 408 of file TMCManager.cxx.

◆ SetUserStack()

void TMCManager::SetUserStack ( TVirtualMCStack stack)

Set user stack.

Definition at line 222 of file TMCManager.cxx.

◆ TerminateRun()

void TMCManager::TerminateRun ( )
private

Terminate a run in all engines.

Terminate the run for all engines.

Definition at line 495 of file TMCManager.cxx.

◆ TransferTrack() [1/2]

void TMCManager::TransferTrack ( Int_t  engineTargetId)

Transfer track from current engine to engine with engineTargetId.

Definition at line 280 of file TMCManager.cxx.

◆ TransferTrack() [2/2]

void TMCManager::TransferTrack ( TVirtualMC mc)

Transfer track from current engine to target engine mc.

Definition at line 295 of file TMCManager.cxx.

◆ UpdateEnginePointers()

void TMCManager::UpdateEnginePointers ( TVirtualMC mc)
private

Update all engine pointers connected to the TMCManager.

Definition at line 480 of file TMCManager.cxx.

Friends And Related Function Documentation

◆ TVirtualMCApplication

friend class TVirtualMCApplication
friend

Definition at line 38 of file TMCManager.h.

Member Data Documentation

◆ fApplication

TVirtualMCApplication* TMCManager::fApplication
private

Pointer to user application.

Definition at line 170 of file TMCManager.h.

◆ fBranchArrayContainer

TGeoMCBranchArrayContainer TMCManager::fBranchArrayContainer
private

Pointer to cache with geometry states.

Definition at line 191 of file TMCManager.h.

◆ fConnectedEnginePointers

std::vector<TVirtualMC **> TMCManager::fConnectedEnginePointers
private

Connected engine pointers which will be updated everytime the current engine changes.

Definition at line 187 of file TMCManager.h.

◆ fCurrentEngine

TVirtualMC* TMCManager::fCurrentEngine
private

Pointer to current engine.

Definition at line 172 of file TMCManager.h.

◆ fEngines

std::vector<TVirtualMC *> TMCManager::fEngines
private

Collecting pointers to all instanciated TVirtualMCs.

Definition at line 174 of file TMCManager.h.

◆ fgInstance

TMCThreadLocal TMCManager * TMCManager::fgInstance = nullptr
staticprivate

Singleton instance.

Definition at line 164 of file TMCManager.h.

◆ fIsInitialized

Bool_t TMCManager::fIsInitialized
private

Flag if engines are initilaized.

Definition at line 193 of file TMCManager.h.

◆ fIsInitializedUser

Bool_t TMCManager::fIsInitializedUser
private

Flag if specific initialization for engines was done.

Definition at line 195 of file TMCManager.h.

◆ fParticles

std::vector<TParticle *> TMCManager::fParticles
private

All tracks (persistent)

Definition at line 178 of file TMCManager.h.

◆ fParticlesStatus

std::vector<std::unique_ptr<TMCParticleStatus> > TMCManager::fParticlesStatus
private

All particles' status (persistent)

Definition at line 180 of file TMCManager.h.

◆ fStacks

std::vector<std::unique_ptr<TMCManagerStack> > TMCManager::fStacks
private

Stacks connected to engines.

Definition at line 176 of file TMCManager.h.

◆ fTotalNPrimaries

Int_t TMCManager::fTotalNPrimaries
private

Total number of primaries ever pushed.

Definition at line 182 of file TMCManager.h.

◆ fTotalNTracks

Int_t TMCManager::fTotalNTracks
private

Total number of tracks ever pushed.

Definition at line 184 of file TMCManager.h.

◆ fUserStack

TVirtualMCStack* TMCManager::fUserStack
private

Pointer to user stack.

Definition at line 189 of file TMCManager.h.

Libraries for TMCManager:
[legend]

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