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 , kRNTupleParallel }

Public Member Functions

 TMCRootManager (const char *projectName, FileMode fileMode=kWrite, Int_t threadRank=-1)
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 CreateRNTuple ()
void Fill ()
void WriteAll ()
void Close ()
void WriteAndClose ()
void ReadEvent (Int_t i)
TString GetFileModifier () const
TMCVNtupleWriterGetNtupleWriter ()

Static Public Member Functions

static TMCRootManagerInstance ()
static void SetDebug (Bool_t debug)
static Bool_t GetDebug ()
static void SetStorageMode (StorageMode mode)
static StorageMode GetStorageMode ()
static TString GetFileModifier (StorageMode mode)

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 {0}
TFile * fFile {nullptr}
TMCVNtupleWriterfNtupleWriter {nullptr}
Bool_t fIsClosed {false}

Static Private Attributes

static Int_t fgCounter = 0
static Bool_t fgDebug = false
static StorageMode fgStorageMode = kTTree
static TMCThreadLocal TMCRootManagerfgInstance = nullptr

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 33 of file TMCRootManager.h.

Member Enumeration Documentation

◆ FileMode

Root file mode.

Enumerator
kRead 
kWrite 

Definition at line 36 of file TMCRootManager.h.

◆ StorageMode

Enumerator
kTTree 
kRNTuple 
kRNTupleParallel 

Definition at line 40 of file TMCRootManager.h.

Constructor & Destructor Documentation

◆ TMCRootManager() [1/2]

TMCRootManager::TMCRootManager ( const char * projectName,
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 103 of file TMCRootManager.cxx.

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

◆ ~TMCRootManager()

TMCRootManager::~TMCRootManager ( )
virtual

Destructor

Definition at line 143 of file TMCRootManager.cxx.

◆ TMCRootManager() [2/2]

TMCRootManager::TMCRootManager ( const TMCRootManager & rhs)
private

Member Function Documentation

◆ Instance()

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

Definition at line 62 of file TMCRootManager.cxx.

◆ SetDebug()

void TMCRootManager::SetDebug ( Bool_t debug)
inlinestatic

Definition at line 105 of file TMCRootManager.h.

◆ GetDebug()

Bool_t TMCRootManager::GetDebug ( )
inlinestatic

Definition at line 110 of file TMCRootManager.h.

◆ SetStorageMode()

void TMCRootManager::SetStorageMode ( StorageMode mode)
static
Returns
Set storage mode only if available

Definition at line 70 of file TMCRootManager.cxx.

◆ GetStorageMode()

TMCRootManager::StorageMode TMCRootManager::GetStorageMode ( )
inlinestatic

Definition at line 115 of file TMCRootManager.h.

◆ GetFileModifier() [1/2]

TString TMCRootManager::GetFileModifier ( StorageMode mode)
static

Definition at line 86 of file TMCRootManager.cxx.

◆ Register() [1/3]

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

Definition at line 121 of file TMCRootManager.h.

Referenced by Register(), Register(), and 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 230 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 246 of file TMCRootManager.cxx.

◆ CreateRNTuple()

void TMCRootManager::CreateRNTuple ( )

RNTuple must be create after registering all the user data to RNTupleModel For kTTree storage mode this function is empty.

Definition at line 257 of file TMCRootManager.cxx.

◆ Fill()

void TMCRootManager::Fill ( )

Definition at line 266 of file TMCRootManager.cxx.

◆ WriteAll()

void TMCRootManager::WriteAll ( )

Definition at line 272 of file TMCRootManager.cxx.

Referenced by WriteAndClose().

◆ Close()

void TMCRootManager::Close ( )

Close the Root file.

Definition at line 278 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 299 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(entry) to be read

Definition at line 308 of file TMCRootManager.cxx.

◆ GetFileModifier() [2/2]

TString TMCRootManager::GetFileModifier ( ) const

◆ GetNtupleWriter()

TMCVNtupleWriter * TMCRootManager::GetNtupleWriter ( )
inline

Definition at line 74 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 174 of file TMCRootManager.cxx.

Referenced by TMCRootManager().

Member Data Documentation

◆ fgCounter

Int_t TMCRootManager::fgCounter = 0
staticprivate

Definition at line 82 of file TMCRootManager.h.

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

◆ fgDebug

Bool_t TMCRootManager::fgDebug = false
staticprivate

Definition at line 84 of file TMCRootManager.h.

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

◆ fgStorageMode

TMCRootManager::StorageMode TMCRootManager::fgStorageMode = kTTree
staticprivate

Definition at line 85 of file TMCRootManager.h.

Referenced by Close(), GetStorageMode(), OpenFile(), Register(), Register(), and SetStorageMode().

◆ fgInstance

TMCThreadLocal TMCRootManager * TMCRootManager::fgInstance = nullptr
staticprivate

Definition at line 88 of file TMCRootManager.h.

Referenced by Instance(), and TMCRootManager().

◆ fId

Int_t TMCRootManager::fId {0}
private

Definition at line 97 of file TMCRootManager.h.

Referenced by Close(), and TMCRootManager().

◆ fFile

TFile* TMCRootManager::fFile {nullptr}
private

Definition at line 98 of file TMCRootManager.h.

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

◆ fNtupleWriter

TMCVNtupleWriter* TMCRootManager::fNtupleWriter {nullptr}
private

◆ fIsClosed

Bool_t TMCRootManager::fIsClosed {false}
private

Definition at line 100 of file TMCRootManager.h.

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


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