VMC
Version 2.2
Toggle main menu visibility
Loading...
Searching...
No Matches
source
include
TMCRootManager.h
Go to the documentation of this file.
1
#ifndef ROOT_TMCRootManager
2
#define ROOT_TMCRootManager
3
4
//------------------------------------------------
5
// The Geant4 Virtual Monte Carlo package
6
// Copyright (C) 2013 - 2018 Ivana Hrivnacova
7
// All rights reserved.
8
//
9
// For the licensing terms see geant4_vmc/LICENSE.
10
// Contact: root-vmc@cern.ch
11
//-------------------------------------------------
12
17
18
#include "
TMCtls.h
"
19
#include "
TMCRNTupleWriter.h
"
20
#include "
TMCRNTupleParallelWriter.h
"
21
#include "
TMCTTreeWriter.h
"
22
23
#include <Rtypes.h>
24
25
class
TFile;
26
32
33
class
TMCRootManager
{
34
public
:
36
enum
FileMode
{
37
kRead
,
// Read mode
38
kWrite
// Write mode
39
};
40
enum
StorageMode
{
41
kTTree
,
// TTree storage
42
kRNTuple
,
// RNTuple storage
43
kRNTupleParallel
// RNTuple storage with parallel write
44
};
45
46
public
:
47
// static access method
48
static
TMCRootManager
*
Instance
();
49
50
// static method for activating debug mode
51
static
void
SetDebug
(Bool_t debug);
52
static
Bool_t
GetDebug
();
53
static
void
SetStorageMode
(
StorageMode
mode);
54
static
StorageMode
GetStorageMode
();
55
static
TString
GetFileModifier
(
StorageMode
mode);
56
57
TMCRootManager
(
const
char
*projectName,
FileMode
fileMode =
kWrite
, Int_t threadRank = -1);
58
virtual
~TMCRootManager
();
59
60
// methods
61
template
<
typename
T>
62
void
Register
(
const
char
*name, T *&obj);
63
void
Register
(
const
char
*name,
const
char
*className,
void
*objAddress);
64
void
Register
(
const
char
*name,
const
char
*className,
const
void
*objAddress);
65
void
CreateRNTuple
();
66
void
Fill
();
67
void
WriteAll
();
68
void
Close
();
69
void
WriteAndClose
();
70
void
ReadEvent
(Int_t i);
71
72
// get methods
73
TString
GetFileModifier
()
const
;
74
TMCVNtupleWriter
*
GetNtupleWriter
() {
return
fNtupleWriter
; }
75
76
private
:
77
// not implemented
78
TMCRootManager
(
const
TMCRootManager
&rhs);
79
TMCRootManager
&
operator=
(
const
TMCRootManager
&rhs);
80
81
// global static data members
82
static
Int_t
fgCounter
;
// The counter of instances
83
// static data members
84
static
Bool_t
fgDebug
;
// Option to activate debug printings
85
static
StorageMode
fgStorageMode
;
86
87
#if !defined(__CINT__)
88
static
TMCThreadLocal
TMCRootManager
*
fgInstance
;
// singleton thread local instance
89
#else
90
static
TMCRootManager
*
fgInstance
;
// singleton instance
91
#endif
92
93
// Methods
94
void
OpenFile
(
const
char
*projectName,
FileMode
fileMode, Int_t threadRank);
95
96
// data members
97
Int_t
fId
{0};
// This manager ID
98
TFile *
fFile
{
nullptr
};
// Root output file
99
TMCVNtupleWriter
*
fNtupleWriter
{
nullptr
};
// ntuple manager
100
Bool_t
fIsClosed
{
false
};
// Info whether its file was closed
101
};
102
103
// inline functions
104
105
inline
void
TMCRootManager::SetDebug
(Bool_t debug)
106
{
107
fgDebug
= debug;
108
}
109
110
inline
Bool_t
TMCRootManager::GetDebug
()
111
{
112
return
fgDebug
;
113
}
114
115
inline
TMCRootManager::StorageMode
TMCRootManager::GetStorageMode
()
116
{
117
return
fgStorageMode
;
118
}
119
120
template
<
typename
T>
121
void
TMCRootManager::Register
(
const
char
*brname, T *&obj)
122
{
123
if
(
fgStorageMode
==
kTTree
) {
124
dynamic_cast<
TMCTTreeWriter
*
>
(
fNtupleWriter
)->
Register<T>
(brname, obj);
125
}
126
if
(
fgStorageMode
==
kRNTuple
) {
127
dynamic_cast<
TMCRNTupleWriter
*
>
(
fNtupleWriter
)->
Register<T>
(brname, obj);
128
}
129
if
(
fgStorageMode
==
kRNTupleParallel
) {
130
dynamic_cast<
TMCRNTupleParallelWriter
*
>
(
fNtupleWriter
)->
Register<T>
(brname, obj);
131
}
132
}
133
134
#endif
// ROOT_TMCRootManager
TMCRNTupleParallelWriter.h
Definition of the TMCRNTupleParallelWriter class.
TMCRNTupleWriter.h
Definition of the TMCRNTupleWriter class.
TMCTTreeWriter.h
Definition of the TMCTTreeWriter class.
TMCtls.h
TMCRNTupleParallelWriter
Definition
TMCRNTupleParallelWriter.h:41
TMCRNTupleWriter
Definition
TMCRNTupleWriter.h:39
TMCRootManager
The Root IO manager for VMC examples for both sequential and multi-threaded applications.
Definition
TMCRootManager.h:33
TMCRootManager::fId
Int_t fId
Definition
TMCRootManager.h:97
TMCRootManager::fNtupleWriter
TMCVNtupleWriter * fNtupleWriter
Definition
TMCRootManager.h:99
TMCRootManager::fFile
TFile * fFile
Definition
TMCRootManager.h:98
TMCRootManager::WriteAll
void WriteAll()
Definition
TMCRootManager.cxx:272
TMCRootManager::OpenFile
void OpenFile(const char *projectName, FileMode fileMode, Int_t threadRank)
Definition
TMCRootManager.cxx:174
TMCRootManager::TMCRootManager
TMCRootManager(const TMCRootManager &rhs)
TMCRootManager::ReadEvent
void ReadEvent(Int_t i)
Definition
TMCRootManager.cxx:308
TMCRootManager::Fill
void Fill()
Definition
TMCRootManager.cxx:266
TMCRootManager::fgInstance
static TMCThreadLocal TMCRootManager * fgInstance
Definition
TMCRootManager.h:88
TMCRootManager::Close
void Close()
Definition
TMCRootManager.cxx:278
TMCRootManager::FileMode
FileMode
Root file mode.
Definition
TMCRootManager.h:36
TMCRootManager::kWrite
@ kWrite
Definition
TMCRootManager.h:38
TMCRootManager::kRead
@ kRead
Definition
TMCRootManager.h:37
TMCRootManager::fgStorageMode
static StorageMode fgStorageMode
Definition
TMCRootManager.h:85
TMCRootManager::operator=
TMCRootManager & operator=(const TMCRootManager &rhs)
TMCRootManager::fgDebug
static Bool_t fgDebug
Definition
TMCRootManager.h:84
TMCRootManager::CreateRNTuple
void CreateRNTuple()
Definition
TMCRootManager.cxx:257
TMCRootManager::GetFileModifier
TString GetFileModifier() const
TMCRootManager::fIsClosed
Bool_t fIsClosed
Definition
TMCRootManager.h:100
TMCRootManager::WriteAndClose
void WriteAndClose()
Definition
TMCRootManager.cxx:299
TMCRootManager::~TMCRootManager
virtual ~TMCRootManager()
Definition
TMCRootManager.cxx:143
TMCRootManager::fgCounter
static Int_t fgCounter
Definition
TMCRootManager.h:82
TMCRootManager::Instance
static TMCRootManager * Instance()
Definition
TMCRootManager.cxx:62
TMCRootManager::SetDebug
static void SetDebug(Bool_t debug)
Definition
TMCRootManager.h:105
TMCRootManager::TMCRootManager
TMCRootManager(const char *projectName, FileMode fileMode=kWrite, Int_t threadRank=-1)
Definition
TMCRootManager.cxx:103
TMCRootManager::GetStorageMode
static StorageMode GetStorageMode()
Definition
TMCRootManager.h:115
TMCRootManager::GetNtupleWriter
TMCVNtupleWriter * GetNtupleWriter()
Definition
TMCRootManager.h:74
TMCRootManager::StorageMode
StorageMode
Definition
TMCRootManager.h:40
TMCRootManager::kRNTuple
@ kRNTuple
Definition
TMCRootManager.h:42
TMCRootManager::kTTree
@ kTTree
Definition
TMCRootManager.h:41
TMCRootManager::kRNTupleParallel
@ kRNTupleParallel
Definition
TMCRootManager.h:43
TMCRootManager::GetDebug
static Bool_t GetDebug()
Definition
TMCRootManager.h:110
TMCRootManager::SetStorageMode
static void SetStorageMode(StorageMode mode)
Definition
TMCRootManager.cxx:70
TMCRootManager::Register
void Register(const char *name, T *&obj)
Definition
TMCRootManager.h:121
TMCTTreeWriter
Definition
TMCTTreeWriter.h:26
TMCVNtupleWriter
Definition
TMCVNtupleWriter.h:23
Generated on
for VMC by
1.17.0