|
JAPAn
Just Another Parity Analyzer
|
A wrapper class for a ROOT file or memory mapped file. More...
#include <QwRootFile.h>
Collaboration diagram for QwRootFile: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 | |
| void | ClearInMemoryObjects (TDirectory *dir) |
| 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 833 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, QwVerbose, and WriteObject().
Here is the call graph for this function:
|
virtual |
Destructor.
Destructor
Definition at line 135 of file QwRootFile.cc.
References QwLog::endl(), fMakePermanent, fMapFile, fPermanentName, fRootFile, fTreeByName, fUseTemporaryFile, HasAnyFilled(), QwMessage, and QwWarning.
Here is the call graph for this function:
|
private |
Private default constructor.
|
inline |
Definition at line 1136 of file QwRootFile.h.
References fMapFile, and fRootFile.
Referenced by ConstructTreeBranches(), and NewTree().
Here is the caller graph for this function:
|
inlineprivate |
Recursively clear in-memory objects from a directory tree. This removes objects from the TDirectory's in-memory list without deleting their on-disk representation (keys). Used to prevent RNTupleWriter::Close() from creating duplicate histogram cycles when it internally calls TFile::Write().
Definition at line 1055 of file QwRootFile.h.
References ClearInMemoryObjects().
Referenced by ClearInMemoryObjects(), and Close().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Definition at line 1083 of file QwRootFile.h.
References ClearInMemoryObjects(), fMakePermanent, fMapFile, fRootFile, fTreeByName, and HasAnyFilled().
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| 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 1595 of file QwRootFile.h.
References QwLog::endl(), fDirsByName, fDirsByType, fMapFile, fRootFile, IsHistoDisabled(), and QwMessage.
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:
|
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 1327 of file QwRootFile.h.
References fTreeByName, and IsTreeDisabled().
Here is the call graph for this function:| 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 1561 of file QwRootFile.h.
References QwLog::endl(), fDirsByName, fDirsByType, fMapFile, fRootFile, and QwMessage.
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| 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 1353 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().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Define the configuration options.
Defines configuration options using QwOptions functionality.
| options | Options object |
Definition at line 196 of file QwRootFile.cc.
References QwOptions::AddOptions(), fDefaultRootFileDir, and fDefaultRootFileStem.
Referenced by QwOptions::DefineOptions().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlineprivate |
Add regexp to list of disabled histogram directories.
Definition at line 1217 of file QwRootFile.h.
References fDisabledHistos.
Referenced by ProcessOptions().
Here is the caller graph for this function:
|
inlineprivate |
Add regexp to list of disabled trees names.
Definition at line 1207 of file QwRootFile.h.
References fDisabledTrees.
Referenced by ProcessOptions().
Here is the caller graph for this function:
|
inline |
Fill histograms of the subsystem array.
Definition at line 901 of file QwRootFile.h.
References fUpdateInterval, HasDirByType(), and Update().
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Fill the tree with name.
Definition at line 955 of file QwRootFile.h.
References fTreeByName, and HasTreeByName().
Referenced by QwExtractor::FillTreeBranches(), VQwDataHandler::FillTreeBranches(), and main().
Here is the call graph for this function:
Here is the caller graph for this function:| 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 1412 of file QwRootFile.h.
References fTreeByAddr, HasTreeByName(), and HasTreeByType().
Referenced by QwExtractor::FillTreeBranches(), VQwDataHandler::FillTreeBranches(), and main().
Here is the call graph for this function:
Here is the caller graph for this function:| 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 1438 of file QwRootFile.h.
References fTreeByAddr, and HasTreeByAddr().
Here is the call graph for this function:
|
inline |
Fill all registered trees.
Definition at line 961 of file QwRootFile.h.
References fTreeByName.
|
inline |
Get the tree with name.
Definition at line 949 of file QwRootFile.h.
References fTreeByName, and HasTreeByName().
Referenced by QwCorrelator::ConstructTreeBranches().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 370 of file QwRootFile.cc.
References fTreeByName, and HasAnyFilled().
Here is the call graph for this function:
|
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 367 of file QwRootFile.cc.
References fRootFile, and HasAnyFilled().
Referenced by Close(), HasAnyFilled(), HasAnyFilled(), and ~QwRootFile().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlineprivate |
Is a tree registered for this name.
Definition at line 1293 of file QwRootFile.h.
References fDirsByName.
|
inlineprivate |
Is a directory registered for this type.
Definition at line 1299 of file QwRootFile.h.
References fDirsByType.
Referenced by FillHistograms().
Here is the caller graph for this function:
|
inlineprivate |
Is a tree registered for this object.
Definition at line 1260 of file QwRootFile.h.
References fTreeByAddr.
Referenced by FillTreeBranches().
Here is the caller graph for this function:
|
inlineprivate |
Is a tree registered for this name.
Definition at line 1247 of file QwRootFile.h.
References fTreeByName.
Referenced by FillTree(), FillTreeBranches(), GetTree(), and NewTree().
Here is the caller graph for this function:
|
inlineprivate |
Is a tree registered for this type.
Definition at line 1253 of file QwRootFile.h.
References fTreeByType.
Referenced by FillTreeBranches().
Here is the caller graph for this function:
|
inlineprivate |
Does this histogram directory match a disabled histogram directory?
Definition at line 1221 of file QwRootFile.h.
References fDisabledHistos.
Referenced by ConstructHistograms().
Here is the caller graph for this function:
|
inline |
|
inline |
|
inlineprivate |
Does this tree name match a disabled tree name?
Definition at line 1211 of file QwRootFile.h.
References fDisabledTrees.
Referenced by ConstructIndices(), ConstructTreeBranches(), and NewTree().
Here is the caller graph for this function:
|
inline |
|
inline |
Definition at line 1048 of file QwRootFile.h.
References fRootFile.
|
inline |
Definition at line 1144 of file QwRootFile.h.
References fRootFile.
|
inline |
Create a new tree with name and description.
Definition at line 918 of file QwRootFile.h.
References cd(), fTreeByName, HasTreeByName(), and IsTreeDisabled().
Referenced by QwCorrelator::ConstructTreeBranches().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
|
inline |
Print registered histogram directories.
Definition at line 1007 of file QwRootFile.h.
References QwLog::endl(), fDirsByName, and QwMessage.
Here is the call graph for this function:
|
inline |
Print registered trees.
Definition at line 992 of file QwRootFile.h.
References QwLog::endl(), fTreeByName, and QwMessage.
Here is the call graph for this function:| void QwRootFile::ProcessOptions | ( | QwOptions & | options | ) |
Process the configuration options.
Parse the configuration options and store in class fields
| options | Options object |
Definition at line 294 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().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlinestatic |
Set default ROOT files dir.
Definition at line 848 of file QwRootFile.h.
References fDefaultRootFileDir.
|
inlinestatic |
Set default ROOT file stem.
Definition at line 852 of file QwRootFile.h.
References fDefaultRootFileStem.
|
inline |
Definition at line 1028 of file QwRootFile.h.
References QwLog::endl(), fMapFile, fTreeByName, and QwMessage.
Referenced by FillHistograms().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Definition at line 1151 of file QwRootFile.h.
References fRootFile.
Referenced by main().
Here is the caller graph for this function:
|
inline |
Write any object to the ROOT file (only valid for TFile)
Definition at line 1019 of file QwRootFile.h.
References fRootFile.
Referenced by QwRootFile().
Here is the caller graph for this function:| Int_t QwRootFile::WriteParamFileList | ( | const TString & | name, |
| T & | object ) |
Definition at line 1629 of file QwRootFile.h.
References fRootFile.
Referenced by main().
Here is the caller graph for this function:
|
private |
Definition at line 1195 of file QwRootFile.h.
Referenced by ConstructTreeBranches(), and ProcessOptions().
|
private |
Definition at line 1196 of file QwRootFile.h.
Referenced by ConstructTreeBranches(), and ProcessOptions().
|
private |
Definition at line 1194 of file QwRootFile.h.
Referenced by ConstructTreeBranches(), and ProcessOptions().
|
private |
Definition at line 1313 of file QwRootFile.h.
Referenced by ConstructTreeBranches(), and ProcessOptions().
|
private |
Definition at line 1192 of file QwRootFile.h.
Referenced by ProcessOptions(), and QwRootFile().
|
private |
Definition at line 1193 of file QwRootFile.h.
Referenced by ProcessOptions(), and QwRootFile().
|
private |
Definition at line 1314 of file QwRootFile.h.
|
staticprivate |
Default ROOT files dir.
Definition at line 1171 of file QwRootFile.h.
Referenced by DefineOptions(), and SetDefaultRootFileDir().
|
staticprivate |
Default ROOT file stem.
Definition at line 1176 of file QwRootFile.h.
Referenced by DefineOptions(), and SetDefaultRootFileStem().
|
private |
Directories.
Definition at line 1289 of file QwRootFile.h.
Referenced by ConstructHistograms(), ConstructObjects(), HasDirByName(), and PrintDirs().
|
private |
Definition at line 1290 of file QwRootFile.h.
Referenced by ConstructHistograms(), ConstructObjects(), and HasDirByType().
|
private |
Definition at line 1204 of file QwRootFile.h.
Referenced by DisableHisto(), and IsHistoDisabled().
|
private |
List of excluded trees.
Definition at line 1203 of file QwRootFile.h.
Referenced by DisableTree(), and IsTreeDisabled().
|
private |
Definition at line 1190 of file QwRootFile.h.
Referenced by ProcessOptions(), and QwRootFile().
|
private |
Definition at line 1181 of file QwRootFile.h.
Referenced by Close(), QwRootFile(), and ~QwRootFile().
|
private |
Map file.
Definition at line 1189 of file QwRootFile.h.
Referenced by cd(), Close(), ConstructHistograms(), ConstructObjects(), IsMapFile(), ls(), Print(), QwRootFile(), Update(), and ~QwRootFile().
|
private |
Definition at line 1312 of file QwRootFile.h.
Referenced by ConstructTreeBranches(), and ProcessOptions().
|
private |
Definition at line 1311 of file QwRootFile.h.
Referenced by ConstructTreeBranches(), and ProcessOptions().
|
private |
Definition at line 1310 of file QwRootFile.h.
Referenced by ConstructTreeBranches(), and ProcessOptions().
|
private |
Prescaling of events written to tree.
Definition at line 1309 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 1180 of file QwRootFile.h.
Referenced by QwRootFile(), and ~QwRootFile().
|
private |
ROOT file.
Definition at line 1166 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 1169 of file QwRootFile.h.
Referenced by ProcessOptions(), and QwRootFile().
|
private |
ROOT file stem.
Definition at line 1174 of file QwRootFile.h.
Referenced by ProcessOptions(), and QwRootFile().
|
private |
Definition at line 1232 of file QwRootFile.h.
Referenced by ConstructTreeBranches(), FillTreeBranches(), FillTreeBranches(), and HasTreeByAddr().
|
private |
Tree names, addresses, and types.
Definition at line 1231 of file QwRootFile.h.
Referenced by Close(), ConstructIndices(), ConstructTreeBranches(), FillTree(), FillTrees(), GetTree(), HasAnyFilled(), HasTreeByName(), NewTree(), PrintTrees(), Update(), and ~QwRootFile().
|
private |
Definition at line 1233 of file QwRootFile.h.
Referenced by ConstructTreeBranches(), and HasTreeByType().
|
private |
Definition at line 1191 of file QwRootFile.h.
Referenced by FillHistograms(), ProcessOptions(), and QwRootFile().
|
private |
Definition at line 1182 of file QwRootFile.h.
Referenced by ProcessOptions(), QwRootFile(), and ~QwRootFile().
|
staticprivate |
Definition at line 1318 of file QwRootFile.h.
Referenced by QwRootFile().
|
staticprivate |
Maximum tree size.
Definition at line 1317 of file QwRootFile.h.
Referenced by ConstructTreeBranches().