VMC Version 2.0
Loading...
Searching...
No Matches
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 <Rtypes.h>
20
21class TParticle;
22class TFile;
23class TTree;
24
30
32public:
34 enum FileMode {
35 kRead, // Read mode
36 kWrite // Write mode
37 };
38
39public:
40 // static access method
41 static TMCRootManager *Instance();
42
43 // static method for activating debug mode
44 static void SetDebug(Bool_t debug);
45 static Bool_t GetDebug();
46
47 TMCRootManager(const char *projectName, FileMode fileMode = kWrite, Int_t threadRank = -1);
48 virtual ~TMCRootManager();
49
50 // methods
51 void Register(const char *name, const char *className, void *objAddress);
52 void Register(const char *name, const char *className, const void *objAddress);
53 void Fill();
54 void WriteAll();
55 void Close();
56 void WriteAndClose();
57 void ReadEvent(Int_t i);
58
59private:
60 // not implemented
63
64 // global static data members
65 static Int_t fgCounter; // The counter of instances
66 // static data members
67 static Bool_t fgDebug; // Option to activate debug printings
68
69#if !defined(__CINT__)
70 static TMCThreadLocal TMCRootManager *fgInstance; // singleton instance
71#else
72 static TMCRootManager *fgInstance; // singleton instance
73#endif
74
75 // Methods
76 void OpenFile(const char *projectName, FileMode fileMode, Int_t threadRank);
77
78 // data members
79 Int_t fId; // This manager ID
80 TFile *fFile; // Root output file
81 TTree *fTree; // Root output tree
82 Bool_t fIsClosed; // Info whether its file was closed
83};
84
85// inline functions
86
87inline void TMCRootManager::SetDebug(Bool_t debug)
88{
89 fgDebug = debug;
90}
91
93{
94 return fgDebug;
95}
96
97#endif // ROOT_TMCRootManager
The Root IO manager for VMC examples for both sequential and multi-threaded applications.
void OpenFile(const char *projectName, FileMode fileMode, Int_t threadRank)
TMCRootManager(const TMCRootManager &rhs)
void ReadEvent(Int_t i)
static TMCThreadLocal TMCRootManager * fgInstance
FileMode
Root file mode.
TMCRootManager & operator=(const TMCRootManager &rhs)
static Bool_t fgDebug
void Register(const char *name, const char *className, void *objAddress)
virtual ~TMCRootManager()
static Int_t fgCounter
static TMCRootManager * Instance()
static void SetDebug(Bool_t debug)
static Bool_t GetDebug()