VMC Version 2.0
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
TMCManager Class Reference

Singleton manager class for handling and steering a run with multiple TVirtualMC engines sharing events. More...

#include <TMCManager.h>

Public Member Functions

 TMCManager ()
 Default constructor.
 
virtual ~TMCManager ()
 Destructor.
 
void Register (TVirtualMC *engine)
 A TVirtualMC will register itself via this method during construction if a TMCManager was instanciated before.
 
void Register (TVirtualMCApplication *application)
 The user application will register itself via this method when the manager was requested.
 
Int_t NEngines () const
 Return the number of registered engines.
 
void GetEngines (std::vector< TVirtualMC * > &engines) const
 Get registered engine pointers.
 
TVirtualMCGetEngine (Int_t id) const
 Get an engine pointer by ID.
 
Int_t GetEngineId (const char *name) const
 Get engine ID by its name.
 
TVirtualMCGetCurrentEngine () const
 Get the current engine pointer.
 
void ConnectEnginePointer (TVirtualMC **mc)
 Connect a pointer which is updated whenever the engine is changed.
 
void ConnectEnginePointer (TVirtualMC *&mc)
 Connect a pointer which is updated whenever the engine is changed.
 
void SetUserStack (TVirtualMCStack *stack)
 Set user stack.
 
void ForwardTrack (Int_t toBeDone, Int_t trackId, Int_t parentId, TParticle *particle, Int_t engineId)
 User interface to forward particle to specifiic engine.
 
void ForwardTrack (Int_t toBeDone, Int_t trackId, Int_t parentId, TParticle *particle)
 User interface to forward particle to specifiic engine.
 
void TransferTrack (Int_t engineTargetId)
 Transfer track from current engine to engine with engineTargetId.
 
void TransferTrack (TVirtualMC *mc)
 Transfer track from current engine to target engine mc.
 
Bool_t RestoreGeometryState (Int_t trackId, Bool_t checkTrackIdRange=kTRUE)
 Try to restore geometry for a given track.
 
Bool_t RestoreGeometryState ()
 Try to restore geometry for the track currently set.
 
template<typename F >
void Apply (F engineLambda)
 Apply something to all engines.
 
void Init ()
 Initialize engines.
 
template<typename F >
void Init (F initFunction)
 Further specific initialization.
 
void Run (Int_t nEvents)
 Run the event loop.
 

Static Public Member Functions

static TMCManagerInstance ()
 Static access method.
 

Private Member Functions

void PrepareNewEvent ()
 Do necessary steps before an event is triggered.
 
Bool_t GetNextEngine ()
 Find the next engine.
 
void UpdateEnginePointers (TVirtualMC *mc)
 Update all engine pointers connected to the TMCManager.
 
void TerminateRun ()
 Terminate a run in all engines.
 

Private Attributes

TVirtualMCApplicationfApplication
 Pointer to user application.
 
TVirtualMCfCurrentEngine
 Pointer to current engine.
 
std::vector< TVirtualMC * > fEngines
 Collecting pointers to all instanciated TVirtualMCs.
 
std::vector< std::unique_ptr< TMCManagerStack > > fStacks
 Stacks connected to engines.
 
std::vector< TParticle * > fParticles
 All tracks (persistent)
 
std::vector< std::unique_ptr< TMCParticleStatus > > fParticlesStatus
 All particles' status (persistent)
 
Int_t fTotalNPrimaries
 Total number of primaries ever pushed.
 
Int_t fTotalNTracks
 Total number of tracks ever pushed.
 
std::vector< TVirtualMC ** > fConnectedEnginePointers
 Connected engine pointers which will be updated everytime the current engine changes.
 
TVirtualMCStackfUserStack
 Pointer to user stack.
 
TGeoMCBranchArrayContainer fBranchArrayContainer
 Pointer to cache with geometry states.
 
Bool_t fIsInitialized
 Flag if engines are initilaized.
 
Bool_t fIsInitializedUser
 Flag if specific initialization for engines was done.
 
Bool_t fGeometryConstructed
 

Static Private Attributes

static TMCThreadLocal TMCManagerfgInstance = nullptr
 Singleton instance.
 

Friends

class TVirtualMCApplication
 

Detailed Description

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 43 of file TMCManager.h.

Constructor & Destructor Documentation

◆ TMCManager()

TMCManager::TMCManager ( )

Default constructor.

Default and standard constructor.

Definition at line 53 of file TMCManager.cxx.

◆ ~TMCManager()

TMCManager::~TMCManager ( )
virtual

Destructor.

Definition at line 68 of file TMCManager.cxx.

Member Function Documentation

◆ Instance()

TMCManager * TMCManager::Instance ( )
static

Static access method.

Definition at line 81 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 93 of file TMCManager.cxx.

Referenced by TVirtualMCApplication::Register(), and TVirtualMCApplication::RequestMCManager().

◆ 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 131 of file TMCManager.cxx.

◆ NEngines()

Int_t TMCManager::NEngines ( ) const

Return the number of registered engines.

Definition at line 146 of file TMCManager.cxx.

◆ GetEngines()

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

Get registered engine pointers.

Definition at line 156 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 170 of file TMCManager.cxx.

◆ GetEngineId()

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

Get engine ID by its name.

Definition at line 183 of file TMCManager.cxx.

◆ GetCurrentEngine()

TVirtualMC * TMCManager::GetCurrentEngine ( ) const

Get the current engine pointer.

Definition at line 199 of file TMCManager.cxx.

◆ ConnectEnginePointer() [1/2]

void TMCManager::ConnectEnginePointer ( TVirtualMC **  mc)

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

Definition at line 209 of file TMCManager.cxx.

Referenced by ConnectEnginePointer(), and TVirtualMCApplication::RequestMCManager().

◆ ConnectEnginePointer() [2/2]

void TMCManager::ConnectEnginePointer ( TVirtualMC *&  mc)

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

Definition at line 222 of file TMCManager.cxx.

◆ SetUserStack()

void TMCManager::SetUserStack ( TVirtualMCStack stack)

Set user stack.

Definition at line 232 of file TMCManager.cxx.

◆ ForwardTrack() [1/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 244 of file TMCManager.cxx.

Referenced by ForwardTrack().

◆ ForwardTrack() [2/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 280 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 290 of file TMCManager.cxx.

Referenced by TransferTrack().

◆ TransferTrack() [2/2]

void TMCManager::TransferTrack ( TVirtualMC mc)

Transfer track from current engine to target engine mc.

Definition at line 305 of file TMCManager.cxx.

◆ RestoreGeometryState() [1/2]

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

Try to restore geometry for a given track.

Definition at line 342 of file TMCManager.cxx.

◆ RestoreGeometryState() [2/2]

Bool_t TMCManager::RestoreGeometryState ( )

Try to restore geometry for the track currently set.

Definition at line 364 of file TMCManager.cxx.

Referenced by RestoreGeometryState().

◆ Apply()

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

Apply something to all engines.

Definition at line 127 of file TMCManager.h.

◆ Init() [1/2]

void TMCManager::Init ( )

Initialize engines.

Definition at line 374 of file TMCManager.cxx.

Referenced by Init().

◆ Init() [2/2]

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

Further specific initialization.

Definition at line 141 of file TMCManager.h.

◆ Run()

void TMCManager::Run ( Int_t  nEvents)

Run the event loop.

Definition at line 418 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 450 of file TMCManager.cxx.

Referenced by Run().

◆ GetNextEngine()

Bool_t TMCManager::GetNextEngine ( )
private

Find the next engine.

Choose next engines to be run in the loop.

Definition at line 472 of file TMCManager.cxx.

Referenced by Run().

◆ UpdateEnginePointers()

void TMCManager::UpdateEnginePointers ( TVirtualMC mc)
private

Update all engine pointers connected to the TMCManager.

Definition at line 490 of file TMCManager.cxx.

Referenced by Apply(), GetNextEngine(), Init(), and Register().

◆ TerminateRun()

void TMCManager::TerminateRun ( )
private

Terminate a run in all engines.

Terminate the run for all engines.

Definition at line 505 of file TMCManager.cxx.

Referenced by Run().

Friends And Related Function Documentation

◆ TVirtualMCApplication

friend class TVirtualMCApplication
friend

Definition at line 45 of file TMCManager.h.

Member Data Documentation

◆ fgInstance

TMCThreadLocal TMCManager * TMCManager::fgInstance = nullptr
staticprivate

Singleton instance.

Definition at line 171 of file TMCManager.h.

Referenced by Instance(), TMCManager(), and ~TMCManager().

◆ fApplication

TVirtualMCApplication* TMCManager::fApplication
private

Pointer to user application.

Definition at line 177 of file TMCManager.h.

Referenced by PrepareNewEvent(), Register(), and Run().

◆ fCurrentEngine

TVirtualMC* TMCManager::fCurrentEngine
private

Pointer to current engine.

Definition at line 179 of file TMCManager.h.

Referenced by ConnectEnginePointer(), ForwardTrack(), GetCurrentEngine(), RestoreGeometryState(), Run(), TransferTrack(), and UpdateEnginePointers().

◆ fEngines

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

Collecting pointers to all instanciated TVirtualMCs.

Definition at line 181 of file TMCManager.h.

Referenced by Apply(), ForwardTrack(), GetEngine(), GetEngineId(), GetEngines(), GetNextEngine(), Init(), NEngines(), Register(), TerminateRun(), TransferTrack(), and ~TMCManager().

◆ fStacks

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

Stacks connected to engines.

Definition at line 183 of file TMCManager.h.

Referenced by ForwardTrack(), GetNextEngine(), Init(), PrepareNewEvent(), Register(), RestoreGeometryState(), and TransferTrack().

◆ fParticles

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

All tracks (persistent)

Definition at line 185 of file TMCManager.h.

Referenced by ForwardTrack(), Init(), PrepareNewEvent(), RestoreGeometryState(), and TransferTrack().

◆ fParticlesStatus

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

All particles' status (persistent)

Definition at line 187 of file TMCManager.h.

Referenced by ForwardTrack(), Init(), PrepareNewEvent(), RestoreGeometryState(), and TransferTrack().

◆ fTotalNPrimaries

Int_t TMCManager::fTotalNPrimaries
private

Total number of primaries ever pushed.

Definition at line 189 of file TMCManager.h.

Referenced by ForwardTrack(), and Init().

◆ fTotalNTracks

Int_t TMCManager::fTotalNTracks
private

Total number of tracks ever pushed.

Definition at line 191 of file TMCManager.h.

Referenced by ForwardTrack(), and Init().

◆ fConnectedEnginePointers

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

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

Definition at line 194 of file TMCManager.h.

Referenced by ConnectEnginePointer(), and UpdateEnginePointers().

◆ fUserStack

TVirtualMCStack* TMCManager::fUserStack
private

Pointer to user stack.

Definition at line 196 of file TMCManager.h.

Referenced by Init(), and SetUserStack().

◆ fBranchArrayContainer

TGeoMCBranchArrayContainer TMCManager::fBranchArrayContainer
private

Pointer to cache with geometry states.

Definition at line 198 of file TMCManager.h.

Referenced by Init(), PrepareNewEvent(), RestoreGeometryState(), and TransferTrack().

◆ fIsInitialized

Bool_t TMCManager::fIsInitialized
private

Flag if engines are initilaized.

Definition at line 200 of file TMCManager.h.

Referenced by Init(), and Run().

◆ fIsInitializedUser

Bool_t TMCManager::fIsInitializedUser
private

Flag if specific initialization for engines was done.

Definition at line 202 of file TMCManager.h.

Referenced by Init(), and Run().

◆ fGeometryConstructed

Bool_t TMCManager::fGeometryConstructed
private

Definition at line 203 of file TMCManager.h.

Referenced by Register().


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