JAPAn
Just Another Parity Analyzer
|
A wrapper class for a ROOT file or memory mapped file. More...
#include <QwRootFile.h>
Public Member Functions | |
QwRootFile (const TString &run_label) | |
Constructor with run label. | |
virtual | ~QwRootFile () |
Destructor. | |
void | ProcessOptions (QwOptions &options) |
Process the configuration options. | |
Bool_t | IsRootFile () const |
Is the ROOT file active? | |
Bool_t | IsMapFile () const |
Is the map file active? | |
void | ConstructIndices (const std::string &from, const std::string &to, bool reverse=true) |
Construct indices from one tree to another tree. | |
template<class T> | |
void | ConstructTreeBranches (const std::string &name, const std::string &desc, T &object, const std::string &prefix="") |
Construct the tree branches of a generic object. | |
template<class T> | |
void | FillTreeBranches (const std::string &name, const T &object) |
Fill the tree branches of a generic object by tree name. | |
template<class T> | |
void | FillTreeBranches (const T &object) |
Fill the tree branches of a generic object by type only. | |
template<class T> | |
Int_t | WriteParamFileList (const TString &name, T &object) |
template<class T> | |
void | ConstructObjects (const std::string &name, T &object) |
Construct the histograms of a generic object. | |
template<class T> | |
void | ConstructHistograms (const std::string &name, T &object) |
Construct the histograms of a generic object. | |
template<class T> | |
void | FillHistograms (T &object) |
Fill histograms of the subsystem array. | |
void | NewTree (const std::string &name, const std::string &desc) |
Create a new tree with name and description. | |
TTree * | GetTree (const std::string &name) |
Get the tree with name. | |
Int_t | FillTree (const std::string &name) |
Fill the tree with name. | |
Int_t | FillTrees () |
Fill all registered trees. | |
void | PrintTrees () const |
Print registered trees. | |
void | PrintDirs () const |
Print registered histogram directories. | |
template<class T> | |
Int_t | WriteObject (const T *obj, const char *name, Option_t *option="", Int_t bufsize=0) |
Write any object to the ROOT file (only valid for TFile) | |
void | Update () |
void | Print () |
void | ls () |
void | Map () |
void | Close () |
Bool_t | cd (const char *path=0) |
TDirectory * | mkdir (const char *name, const char *title="") |
Int_t | Write (const char *name=0, Int_t option=0, Int_t bufsize=0) |
Static Public Member Functions | |
static void | DefineOptions (QwOptions &options) |
Define the configuration options. | |
static void | SetDefaultRootFileDir (const std::string &dir) |
Set default ROOT files dir. | |
static void | SetDefaultRootFileStem (const std::string &stem) |
Set default ROOT file stem. | |
Private Member Functions | |
QwRootFile () | |
Private default constructor. | |
Bool_t | HasAnyFilled (void) |
Search for non-empty trees or histograms in the file. | |
Bool_t | HasAnyFilled (TDirectory *d) |
void | DisableTree (const TString ®exp) |
Add regexp to list of disabled trees names. | |
bool | IsTreeDisabled (const std::string &name) |
Does this tree name match a disabled tree name? | |
void | DisableHisto (const TString ®exp) |
Add regexp to list of disabled histogram directories. | |
bool | IsHistoDisabled (const std::string &name) |
Does this histogram directory match a disabled histogram directory? | |
bool | HasTreeByName (const std::string &name) |
Is a tree registered for this name. | |
template<class T> | |
bool | HasTreeByType (const T &object) |
Is a tree registered for this type. | |
template<class T> | |
bool | HasTreeByAddr (const T &object) |
Is a tree registered for this object. | |
bool | HasDirByName (const std::string &name) |
Is a tree registered for this name. | |
template<class T> | |
bool | HasDirByType (const T &object) |
Is a directory registered for this type. | |
Private Attributes | |
TFile * | fRootFile |
ROOT file. | |
TString | fRootFileDir |
ROOT files dir. | |
TString | fRootFileStem |
ROOT file stem. | |
TString | fPermanentName |
Bool_t | fMakePermanent |
Bool_t | fUseTemporaryFile |
TMapFile * | fMapFile |
Map file. | |
Bool_t | fEnableMapFile |
Int_t | fUpdateInterval |
Int_t | fCompressionAlgorithm |
Int_t | fCompressionLevel |
Int_t | fBasketSize |
Int_t | fAutoFlush |
Int_t | fAutoSave |
std::vector< TPRegexp > | fDisabledTrees |
List of excluded trees. | |
std::vector< TPRegexp > | fDisabledHistos |
std::map< const std::string, std::vector< QwRootTree * > > | fTreeByName |
Tree names, addresses, and types. | |
std::map< const void *, std::vector< QwRootTree * > > | fTreeByAddr |
std::map< const std::type_index, std::vector< QwRootTree * > > | fTreeByType |
std::map< const std::string, TDirectory * > | fDirsByName |
Directories. | |
std::map< const std::string, std::vector< std::string > > | fDirsByType |
UInt_t | fNumMpsEventsToSkip |
Prescaling of events written to tree. | |
UInt_t | fNumMpsEventsToSave |
UInt_t | fNumHelEventsToSkip |
UInt_t | fNumHelEventsToSave |
UInt_t | fCircularBufferSize |
UInt_t | fCurrentEvent |
Static Private Attributes | |
static std::string | fDefaultRootFileDir = "." |
Default ROOT files dir. | |
static std::string | fDefaultRootFileStem = "Qweak_" |
Default ROOT file stem. | |
static const Long64_t | kMaxTreeSize = 100000000000LL |
Maximum tree size. | |
static const Int_t | kMaxMapFileSize = 0x3fffffff |
A wrapper class for a ROOT file or memory mapped file.
This class functions as a wrapper around a ROOT TFile or a TMapFile. The common inheritance of both is only TObject, so there is a lot that we have to wrap (rather than inherit). Theoretically you could have both a TFile and a TMapFile represented by an object of this class at the same time, but that is untested.
The functionality of writing to the file is done by templated functions. The objects that are passed to these functions have to provide the following functions:
The class keeps track of the registered tree names, and the types of objects that have branches constructed in those trees (via QwRootTree). In most cases it should be possible to just call FillTreeBranches with only the object, although in rare cases this could be ambiguous.
The proper way to register a tree is by either calling ConstructTreeBranches of NewTree first. Then FillTreeBranches will fill the vector, and FillTree will actually fill the tree. FillTree should be called only once.
Definition at line 827 of file QwRootFile.h.
QwRootFile::QwRootFile | ( | const TString & | run_label | ) |
Constructor with run label.
Constructor with relative filename
Definition at line 25 of file QwRootFile.cc.
References QwLog::endl(), fCompressionAlgorithm, fCompressionLevel, fEnableMapFile, fMakePermanent, fMapFile, fPermanentName, fRootFile, fRootFileDir, fRootFileStem, fUpdateInterval, fUseTemporaryFile, QwRunCondition::Get(), QwRunCondition::GetName(), gQwOptions, kMaxMapFileSize, ProcessOptions(), QwError, QwMessage, and WriteObject().
|
virtual |
Destructor.
Destructor
Definition at line 108 of file QwRootFile.cc.
References QwLog::endl(), fMakePermanent, fMapFile, fPermanentName, fRootFile, fTreeByName, fUseTemporaryFile, HasAnyFilled(), QwMessage, and QwWarning.
|
private |
Private default constructor.
|
inline |
Definition at line 1086 of file QwRootFile.h.
References fMapFile, and fRootFile.
Referenced by ConstructTreeBranches(), and NewTree().
|
inline |
Definition at line 1043 of file QwRootFile.h.
References fMakePermanent, fMapFile, fRootFile, fTreeByName, and HasAnyFilled().
Referenced by main().
void QwRootFile::ConstructHistograms | ( | const std::string & | name, |
T & | object ) |
Construct the histograms of a generic object.
Construct the histogram of a generic object
name | Name for histogram directory |
object | Subsystem array |
Definition at line 1545 of file QwRootFile.h.
References QwLog::endl(), fDirsByName, fDirsByType, fMapFile, fRootFile, IsHistoDisabled(), and QwMessage.
Referenced by main().
|
inline |
Construct indices from one tree to another tree.
Construct the indices from one tree to another tree, and optionally in reverse as well.
from | Name of tree where index will be created |
to | Name of tree to which index will point |
reverse | Flag to create indices in both direction |
Definition at line 1277 of file QwRootFile.h.
References fTreeByName, and IsTreeDisabled().
void QwRootFile::ConstructObjects | ( | const std::string & | name, |
T & | object ) |
Construct the histograms of a generic object.
Construct the objects directory of a generic object
name | Name for objects directory |
object | Subsystem array |
Definition at line 1511 of file QwRootFile.h.
References QwLog::endl(), fDirsByName, fDirsByType, fMapFile, fRootFile, and QwMessage.
Referenced by main().
void QwRootFile::ConstructTreeBranches | ( | const std::string & | name, |
const std::string & | desc, | ||
T & | object, | ||
const std::string & | prefix = "" ) |
Construct the tree branches of a generic object.
Construct the tree branches of a generic object
name | Name for tree |
desc | Description for tree |
object | Subsystem array |
prefix | Prefix for the tree |
Definition at line 1303 of file QwRootFile.h.
References cd(), fAutoFlush, fAutoSave, fBasketSize, fCircularBufferSize, fNumHelEventsToSave, fNumHelEventsToSkip, fNumMpsEventsToSave, fNumMpsEventsToSkip, fTreeByAddr, fTreeByName, fTreeByType, IsTreeDisabled(), kMaxTreeSize, QwRootTree::SetAutoFlush(), QwRootTree::SetAutoSave(), QwRootTree::SetBasketSize(), QwRootTree::SetCircular(), QwRootTree::SetMaxTreeSize(), and QwRootTree::SetPrescaling().
Referenced by QwExtractor::ConstructTreeBranches(), VQwDataHandler::ConstructTreeBranches(), and main().
|
static |
Define the configuration options.
Defines configuration options using QwOptions functionality.
options | Options object |
Definition at line 165 of file QwRootFile.cc.
References QwOptions::AddOptions(), fDefaultRootFileDir, and fDefaultRootFileStem.
Referenced by QwOptions::DefineOptions().
|
inlineprivate |
Add regexp to list of disabled histogram directories.
Definition at line 1167 of file QwRootFile.h.
References fDisabledHistos.
Referenced by ProcessOptions().
|
inlineprivate |
Add regexp to list of disabled trees names.
Definition at line 1157 of file QwRootFile.h.
References fDisabledTrees.
Referenced by ProcessOptions().
|
inline |
Fill histograms of the subsystem array.
Definition at line 895 of file QwRootFile.h.
References fUpdateInterval, HasDirByType(), and Update().
Referenced by main().
|
inline |
Fill the tree with name.
Definition at line 949 of file QwRootFile.h.
References fTreeByName, and HasTreeByName().
Referenced by QwExtractor::FillTreeBranches(), VQwDataHandler::FillTreeBranches(), and main().
void QwRootFile::FillTreeBranches | ( | const std::string & | name, |
const T & | object ) |
Fill the tree branches of a generic object by tree name.
Fill the tree branches of a generic object by name
name | Name for tree |
object | Subsystem array |
Definition at line 1362 of file QwRootFile.h.
References fTreeByAddr, HasTreeByName(), and HasTreeByType().
Referenced by QwExtractor::FillTreeBranches(), VQwDataHandler::FillTreeBranches(), and main().
void QwRootFile::FillTreeBranches | ( | const T & | object | ) |
Fill the tree branches of a generic object by type only.
Fill the tree branches of a generic object by type only
object | Subsystem array |
Definition at line 1388 of file QwRootFile.h.
References fTreeByAddr, and HasTreeByAddr().
|
inline |
Fill all registered trees.
Definition at line 955 of file QwRootFile.h.
References fTreeByName.
|
inline |
Get the tree with name.
Definition at line 943 of file QwRootFile.h.
References fTreeByName, and HasTreeByName().
Referenced by QwCorrelator::ConstructTreeBranches().
|
private |
Definition at line 339 of file QwRootFile.cc.
References fTreeByName, and HasAnyFilled().
|
private |
Search for non-empty trees or histograms in the file.
Determine whether the rootfile object has any non-empty trees or histograms.
Definition at line 336 of file QwRootFile.cc.
References fRootFile, and HasAnyFilled().
Referenced by Close(), HasAnyFilled(), HasAnyFilled(), and ~QwRootFile().
|
inlineprivate |
Is a tree registered for this name.
Definition at line 1243 of file QwRootFile.h.
References fDirsByName.
|
inlineprivate |
Is a directory registered for this type.
Definition at line 1249 of file QwRootFile.h.
References fDirsByType.
Referenced by FillHistograms().
|
inlineprivate |
Is a tree registered for this object.
Definition at line 1210 of file QwRootFile.h.
References fTreeByAddr.
Referenced by FillTreeBranches().
|
inlineprivate |
Is a tree registered for this name.
Definition at line 1197 of file QwRootFile.h.
References fTreeByName.
Referenced by FillTree(), FillTreeBranches(), GetTree(), and NewTree().
|
inlineprivate |
Is a tree registered for this type.
Definition at line 1203 of file QwRootFile.h.
References fTreeByType.
Referenced by FillTreeBranches().
|
inlineprivate |
Does this histogram directory match a disabled histogram directory?
Definition at line 1171 of file QwRootFile.h.
References fDisabledHistos.
Referenced by ConstructHistograms().
|
inline |
|
inline |
|
inlineprivate |
Does this tree name match a disabled tree name?
Definition at line 1161 of file QwRootFile.h.
References fDisabledTrees.
Referenced by ConstructIndices(), ConstructTreeBranches(), and NewTree().
|
inline |
|
inline |
Definition at line 1042 of file QwRootFile.h.
References fRootFile.
|
inline |
Definition at line 1094 of file QwRootFile.h.
References fRootFile.
|
inline |
Create a new tree with name and description.
Definition at line 912 of file QwRootFile.h.
References cd(), fTreeByName, HasTreeByName(), and IsTreeDisabled().
Referenced by QwCorrelator::ConstructTreeBranches().
|
inline |
|
inline |
Print registered histogram directories.
Definition at line 1001 of file QwRootFile.h.
References QwLog::endl(), fDirsByName, and QwMessage.
|
inline |
Print registered trees.
Definition at line 986 of file QwRootFile.h.
References QwLog::endl(), fTreeByName, and QwMessage.
void QwRootFile::ProcessOptions | ( | QwOptions & | options | ) |
Process the configuration options.
Parse the configuration options and store in class fields
options | Options object |
Definition at line 263 of file QwRootFile.cc.
References DisableHisto(), DisableTree(), QwLog::endl(), fAutoFlush, fAutoSave, fBasketSize, fCircularBufferSize, fCompressionAlgorithm, fCompressionLevel, fEnableMapFile, fNumHelEventsToSave, fNumHelEventsToSkip, fNumMpsEventsToSave, fNumMpsEventsToSkip, fRootFileDir, fRootFileStem, fUpdateInterval, fUseTemporaryFile, QwOptions::GetValue(), QwOptions::GetValueVector(), QwMessage, and QwWarning.
Referenced by QwRootFile().
|
inlinestatic |
Set default ROOT files dir.
Definition at line 842 of file QwRootFile.h.
References fDefaultRootFileDir.
|
inlinestatic |
Set default ROOT file stem.
Definition at line 846 of file QwRootFile.h.
References fDefaultRootFileStem.
|
inline |
Definition at line 1022 of file QwRootFile.h.
References QwLog::endl(), fMapFile, fTreeByName, and QwMessage.
Referenced by FillHistograms().
|
inline |
Definition at line 1101 of file QwRootFile.h.
References fRootFile.
Referenced by main().
|
inline |
Write any object to the ROOT file (only valid for TFile)
Definition at line 1013 of file QwRootFile.h.
References fRootFile.
Referenced by QwRootFile().
Int_t QwRootFile::WriteParamFileList | ( | const TString & | name, |
T & | object ) |
Definition at line 1579 of file QwRootFile.h.
References fRootFile.
Referenced by main().
|
private |
Definition at line 1145 of file QwRootFile.h.
Referenced by ConstructTreeBranches(), and ProcessOptions().
|
private |
Definition at line 1146 of file QwRootFile.h.
Referenced by ConstructTreeBranches(), and ProcessOptions().
|
private |
Definition at line 1144 of file QwRootFile.h.
Referenced by ConstructTreeBranches(), and ProcessOptions().
|
private |
Definition at line 1263 of file QwRootFile.h.
Referenced by ConstructTreeBranches(), and ProcessOptions().
|
private |
Definition at line 1142 of file QwRootFile.h.
Referenced by ProcessOptions(), and QwRootFile().
|
private |
Definition at line 1143 of file QwRootFile.h.
Referenced by ProcessOptions(), and QwRootFile().
|
private |
Definition at line 1264 of file QwRootFile.h.
|
staticprivate |
Default ROOT files dir.
Definition at line 1121 of file QwRootFile.h.
Referenced by DefineOptions(), and SetDefaultRootFileDir().
|
staticprivate |
Default ROOT file stem.
Definition at line 1126 of file QwRootFile.h.
Referenced by DefineOptions(), and SetDefaultRootFileStem().
|
private |
Directories.
Definition at line 1239 of file QwRootFile.h.
Referenced by ConstructHistograms(), ConstructObjects(), HasDirByName(), and PrintDirs().
|
private |
Definition at line 1240 of file QwRootFile.h.
Referenced by ConstructHistograms(), ConstructObjects(), and HasDirByType().
|
private |
Definition at line 1154 of file QwRootFile.h.
Referenced by DisableHisto(), and IsHistoDisabled().
|
private |
List of excluded trees.
Definition at line 1153 of file QwRootFile.h.
Referenced by DisableTree(), and IsTreeDisabled().
|
private |
Definition at line 1140 of file QwRootFile.h.
Referenced by ProcessOptions(), and QwRootFile().
|
private |
Definition at line 1131 of file QwRootFile.h.
Referenced by Close(), QwRootFile(), and ~QwRootFile().
|
private |
Map file.
Definition at line 1139 of file QwRootFile.h.
Referenced by cd(), Close(), ConstructHistograms(), ConstructObjects(), IsMapFile(), ls(), Print(), QwRootFile(), Update(), and ~QwRootFile().
|
private |
Definition at line 1262 of file QwRootFile.h.
Referenced by ConstructTreeBranches(), and ProcessOptions().
|
private |
Definition at line 1261 of file QwRootFile.h.
Referenced by ConstructTreeBranches(), and ProcessOptions().
|
private |
Definition at line 1260 of file QwRootFile.h.
Referenced by ConstructTreeBranches(), and ProcessOptions().
|
private |
Prescaling of events written to tree.
Definition at line 1259 of file QwRootFile.h.
Referenced by ConstructTreeBranches(), and ProcessOptions().
|
private |
While the file is open, give it a temporary filename. Perhaps change to a permanent name when closing the file.
Definition at line 1130 of file QwRootFile.h.
Referenced by QwRootFile(), and ~QwRootFile().
|
private |
ROOT file.
Definition at line 1116 of file QwRootFile.h.
Referenced by cd(), Close(), ConstructHistograms(), ConstructObjects(), HasAnyFilled(), IsRootFile(), ls(), Map(), mkdir(), Print(), QwRootFile(), Write(), WriteObject(), WriteParamFileList(), and ~QwRootFile().
|
private |
ROOT files dir.
Definition at line 1119 of file QwRootFile.h.
Referenced by ProcessOptions(), and QwRootFile().
|
private |
ROOT file stem.
Definition at line 1124 of file QwRootFile.h.
Referenced by ProcessOptions(), and QwRootFile().
|
private |
Definition at line 1182 of file QwRootFile.h.
Referenced by ConstructTreeBranches(), FillTreeBranches(), FillTreeBranches(), and HasTreeByAddr().
|
private |
Tree names, addresses, and types.
Definition at line 1181 of file QwRootFile.h.
Referenced by Close(), ConstructIndices(), ConstructTreeBranches(), FillTree(), FillTrees(), GetTree(), HasAnyFilled(), HasTreeByName(), NewTree(), PrintTrees(), Update(), and ~QwRootFile().
|
private |
Definition at line 1183 of file QwRootFile.h.
Referenced by ConstructTreeBranches(), and HasTreeByType().
|
private |
Definition at line 1141 of file QwRootFile.h.
Referenced by FillHistograms(), ProcessOptions(), and QwRootFile().
|
private |
Definition at line 1132 of file QwRootFile.h.
Referenced by ProcessOptions(), QwRootFile(), and ~QwRootFile().
|
staticprivate |
Definition at line 1268 of file QwRootFile.h.
Referenced by QwRootFile().
|
staticprivate |
Maximum tree size.
Definition at line 1267 of file QwRootFile.h.
Referenced by ConstructTreeBranches().