VMC Version 2.2
Loading...
Searching...
No Matches
TMCRootManager Class Reference

The Root IO manager for VMC examples for both sequential and multi-threaded applications. More...

#include <TMCRootManager.h>

Public Types

enum  FileMode { kRead , kWrite }
 Root file mode. More...
enum  StorageMode { kTTree , kRNTuple }

Public Member Functions

 TMCRootManager (const char *projectName, FileMode fileMode=kWrite, Int_t threadRank=-1)
 TMCRootManager (const char *projectName, StorageMode storageMode, FileMode fileMode=kWrite, Int_t threadRank=-1)
 TMCRootManager (std::shared_ptr< RNTParaWriter > sharedWriter)
virtual ~TMCRootManager ()
template<typename T>
void Register (const char *name, T *&obj)
void Register (const char *name, const char *className, void *objAddress)
void Register (const char *name, const char *className, const void *objAddress)
void Fill ()
void WriteAll ()
void Close ()
void WriteAndClose ()
void ReadEvent (Int_t i)
void CreateRNTuple (bool parallelMode=false, bool workerMode=false)
std::shared_ptr< RNTParaWriterGetParallelRNTupleWriter ()

Static Public Member Functions

static TMCRootManagerInstance ()
static void SetDebug (Bool_t debug)
static Bool_t GetDebug ()

Private Member Functions

 TMCRootManager (const TMCRootManager &rhs)
TMCRootManageroperator= (const TMCRootManager &rhs)
void OpenFile (const char *projectName, FileMode fileMode, Int_t threadRank)

Private Attributes

Int_t fId
TFile * fFile {nullptr}
TTree * fTree {nullptr}
std::string fStorageName {}
std::vector< std::pair< std::string, void * > > fNameAddress
std::unique_ptr< REntryfEntry
std::unique_ptr< RNTupleModelfModel
std::unique_ptr< RNTupleWriterfWriter
std::shared_ptr< RNTParaWriterfParaWriter
std::shared_ptr< RNTupleFillContextfFillContext
StorageMode fStorageMode {kTTree}
Bool_t fIsClosed {false}

Static Private Attributes

static Int_t fgCounter = 0
static Bool_t fgDebug = false
static TMCThreadLocal TMCRootManagerfgInstance = 0

Detailed Description

The Root IO manager for VMC examples for both sequential and multi-threaded applications.

It facilitates use of ROOT IO in VMC examples and also handles necessary locking in multi-threaded applications.

Definition at line 52 of file TMCRootManager.h.

Member Enumeration Documentation

◆ FileMode

Root file mode.

Enumerator
kRead 
kWrite 

Definition at line 55 of file TMCRootManager.h.

◆ StorageMode

Enumerator
kTTree 
kRNTuple 

Definition at line 59 of file TMCRootManager.h.

Constructor & Destructor Documentation

◆ TMCRootManager() [1/4]

TMCRootManager::TMCRootManager ( const char * projectName,
TMCRootManager::FileMode fileMode = kWrite,
Int_t threadRank = -1 )

◆ TMCRootManager() [2/4]

TMCRootManager::TMCRootManager ( const char * projectName,
TMCRootManager::StorageMode storageMode,
TMCRootManager::FileMode fileMode = kWrite,
Int_t threadRank = -1 )

Standard constructor

Parameters
projectNameThe project name (passed as the Root tree name)
fileModeOption for opening Root file (read or write mode)
threadRank>0 when MT mode, -1 when sequential mode

Definition at line 78 of file TMCRootManager.cxx.

◆ TMCRootManager() [3/4]

TMCRootManager::TMCRootManager ( std::shared_ptr< RNTParaWriter > sharedWriter)

Definition at line 119 of file TMCRootManager.cxx.

◆ ~TMCRootManager()

TMCRootManager::~TMCRootManager ( )
virtual

Destructor

Definition at line 139 of file TMCRootManager.cxx.

◆ TMCRootManager() [4/4]

TMCRootManager::TMCRootManager ( const TMCRootManager & rhs)
private

Member Function Documentation

◆ Instance()

TMCRootManager * TMCRootManager::Instance ( )
static
Returns
The singleton instance.

Definition at line 60 of file TMCRootManager.cxx.

◆ SetDebug()

void TMCRootManager::SetDebug ( Bool_t debug)
inlinestatic

Definition at line 136 of file TMCRootManager.h.

◆ GetDebug()

Bool_t TMCRootManager::GetDebug ( )
inlinestatic

Definition at line 141 of file TMCRootManager.h.

◆ Register() [1/3]

template<typename T>
void TMCRootManager::Register ( const char * name,
T *& obj )

Definition at line 147 of file TMCRootManager.h.

Referenced by Register().

◆ Register() [2/3]

void TMCRootManager::Register ( const char * name,
const char * className,
void * objAddress )

Create a branch and associates it with the given address.

Parameters
nameThe branch name
classNameThe class name of the object
objAddressThe object address

Definition at line 216 of file TMCRootManager.cxx.

◆ Register() [3/3]

void TMCRootManager::Register ( const char * name,
const char * className,
const void * objAddress )

Create a branch and associates it with the given address.

Parameters
nameThe branch name
classNameThe class name of the object
objAddressThe object address

Definition at line 231 of file TMCRootManager.cxx.

◆ Fill()

void TMCRootManager::Fill ( )

Fill the Root tree.

Fill the RNTuple.

Definition at line 269 of file TMCRootManager.cxx.

◆ WriteAll()

void TMCRootManager::WriteAll ( )

Write the Root tree in the file.

Write the RNTuple in the file.

Definition at line 300 of file TMCRootManager.cxx.

Referenced by WriteAndClose().

◆ Close()

void TMCRootManager::Close ( )

Close the Root file.

Definition at line 322 of file TMCRootManager.cxx.

Referenced by WriteAndClose().

◆ WriteAndClose()

void TMCRootManager::WriteAndClose ( )

Write the Root tree in the file and close the file

Definition at line 342 of file TMCRootManager.cxx.

◆ ReadEvent()

void TMCRootManager::ReadEvent ( Int_t i)

Read the event data for i -th event for all connected branches.

Parameters
iThe event to be read

Definition at line 351 of file TMCRootManager.cxx.

◆ CreateRNTuple()

void TMCRootManager::CreateRNTuple ( bool parallelMode = false,
bool workerMode = false )

Definition at line 243 of file TMCRootManager.cxx.

◆ GetParallelRNTupleWriter()

std::shared_ptr< RNTParaWriter > TMCRootManager::GetParallelRNTupleWriter ( )
inline

Definition at line 92 of file TMCRootManager.h.

◆ operator=()

TMCRootManager & TMCRootManager::operator= ( const TMCRootManager & rhs)
private

◆ OpenFile()

void TMCRootManager::OpenFile ( const char * projectName,
FileMode fileMode,
Int_t threadRank )
private

Definition at line 167 of file TMCRootManager.cxx.

Referenced by TMCRootManager().

Member Data Documentation

◆ fgCounter

Int_t TMCRootManager::fgCounter = 0
staticprivate

Definition at line 101 of file TMCRootManager.h.

Referenced by TMCRootManager(), TMCRootManager(), and ~TMCRootManager().

◆ fgDebug

Bool_t TMCRootManager::fgDebug = false
staticprivate

Definition at line 103 of file TMCRootManager.h.

Referenced by GetDebug(), OpenFile(), SetDebug(), TMCRootManager(), and ~TMCRootManager().

◆ fgInstance

TMCThreadLocal TMCRootManager * TMCRootManager::fgInstance = 0
staticprivate

Definition at line 106 of file TMCRootManager.h.

Referenced by Instance(), TMCRootManager(), and TMCRootManager().

◆ fId

Int_t TMCRootManager::fId
private

Definition at line 115 of file TMCRootManager.h.

Referenced by TMCRootManager(), and TMCRootManager().

◆ fFile

TFile* TMCRootManager::fFile {nullptr}
private

◆ fTree

TTree* TMCRootManager::fTree {nullptr}
private

Definition at line 117 of file TMCRootManager.h.

Referenced by Fill(), OpenFile(), ReadEvent(), Register(), and Register().

◆ fStorageName

std::string TMCRootManager::fStorageName {}
private

Definition at line 120 of file TMCRootManager.h.

Referenced by CreateRNTuple(), and OpenFile().

◆ fNameAddress

std::vector<std::pair<std::string, void *> > TMCRootManager::fNameAddress
private

Definition at line 121 of file TMCRootManager.h.

Referenced by CreateRNTuple(), and Register().

◆ fEntry

std::unique_ptr<REntry> TMCRootManager::fEntry
private

Definition at line 122 of file TMCRootManager.h.

Referenced by CreateRNTuple(), Fill(), and WriteAll().

◆ fModel

std::unique_ptr<RNTupleModel> TMCRootManager::fModel
private

Definition at line 123 of file TMCRootManager.h.

Referenced by CreateRNTuple(), OpenFile(), Register(), and WriteAll().

◆ fWriter

std::unique_ptr<RNTupleWriter> TMCRootManager::fWriter
private

Definition at line 124 of file TMCRootManager.h.

Referenced by CreateRNTuple(), Fill(), and WriteAll().

◆ fParaWriter

std::shared_ptr<RNTParaWriter> TMCRootManager::fParaWriter
private

◆ fFillContext

std::shared_ptr<RNTupleFillContext> TMCRootManager::fFillContext
private

Definition at line 126 of file TMCRootManager.h.

Referenced by CreateRNTuple(), Fill(), and WriteAll().

◆ fStorageMode

StorageMode TMCRootManager::fStorageMode {kTTree}
private

◆ fIsClosed

Bool_t TMCRootManager::fIsClosed {false}
private

Definition at line 131 of file TMCRootManager.h.

Referenced by Close(), and ~TMCRootManager().


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