|
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 |
| TString | fMapFileDir |
| Int_t | fUpdateInterval |
| Int_t | fCompressionAlgorithm |
| Int_t | fCompressionLevel |
| Int_t | fRNTupleCompressionAlgorithm |
| Int_t | fRNTupleCompressionLevel |
| 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 |
| UInt_t | fHistoFillPrescale = 1 |
| UInt_t | fHistoFillCount = 0 |
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 859 of file QwRootFile.h.
| QwRootFile::QwRootFile | ( | const TString & | run_label | ) |
Constructor with run label.
Constructor with relative filename
Definition at line 28 of file QwRootFile.cc.
References QwLog::endl(), fCompressionAlgorithm, fCompressionLevel, fEnableMapFile, fMakePermanent, fMapFile, fMapFileDir, 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 156 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 1176 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 1093 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 1121 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 1657 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 1378 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 1616 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 1404 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 217 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 1262 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 1252 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 927 of file QwRootFile.h.
References fHistoFillCount, fHistoFillPrescale, 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 993 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 1463 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 1489 of file QwRootFile.h.
References fTreeByAddr, and HasTreeByAddr().
Here is the call graph for this function:
|
inline |
Fill all registered trees.
Definition at line 999 of file QwRootFile.h.
References fTreeByName.
|
inline |
Get the tree with name.
Definition at line 987 of file QwRootFile.h.
References fTreeByName, and HasTreeByName().
Referenced by GrandCorrelator::ConstructTreeBranches(), QwCorrelator::ConstructTreeBranches(), and QwCorrelatorNew::ConstructTreeBranches().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 522 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 519 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 1338 of file QwRootFile.h.
References fDirsByName.
|
inlineprivate |
Is a directory registered for this type.
Definition at line 1344 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 1305 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 1292 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 1298 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 1266 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 1256 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 1086 of file QwRootFile.h.
References fRootFile.
|
inline |
Definition at line 1184 of file QwRootFile.h.
References fRootFile.
|
inline |
Create a new tree with name and description.
Definition at line 953 of file QwRootFile.h.
References cd(), fTreeByName, HasTreeByName(), and IsTreeDisabled().
Referenced by GrandCorrelator::ConstructTreeBranches(), QwCorrelator::ConstructTreeBranches(), and QwCorrelatorNew::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 1045 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 1030 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 338 of file QwRootFile.cc.
References DisableHisto(), DisableTree(), QwLog::endl(), fAutoFlush, fAutoSave, fBasketSize, fCircularBufferSize, fCompressionAlgorithm, fCompressionLevel, fEnableMapFile, fHistoFillPrescale, fMapFileDir, fNumHelEventsToSave, fNumHelEventsToSkip, fNumMpsEventsToSave, fNumMpsEventsToSkip, fRNTupleCompressionAlgorithm, fRNTupleCompressionLevel, fRootFileDir, fRootFileStem, fUpdateInterval, fUseTemporaryFile, QwOptions::GetValue(), QwOptions::GetValueVector(), kMaxMapFileSize, QwError, 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 874 of file QwRootFile.h.
References fDefaultRootFileDir.
|
inlinestatic |
Set default ROOT file stem.
Definition at line 878 of file QwRootFile.h.
References fDefaultRootFileStem.
|
inline |
Definition at line 1066 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 1191 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 1057 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 1705 of file QwRootFile.h.
References fRootFile.
Referenced by main().
Here is the caller graph for this function:
|
private |
Definition at line 1240 of file QwRootFile.h.
Referenced by ConstructTreeBranches(), and ProcessOptions().
|
private |
Definition at line 1241 of file QwRootFile.h.
Referenced by ConstructTreeBranches(), and ProcessOptions().
|
private |
Definition at line 1239 of file QwRootFile.h.
Referenced by ConstructTreeBranches(), and ProcessOptions().
|
private |
Definition at line 1358 of file QwRootFile.h.
Referenced by ConstructTreeBranches(), and ProcessOptions().
|
private |
Definition at line 1235 of file QwRootFile.h.
Referenced by ProcessOptions(), and QwRootFile().
|
private |
Definition at line 1236 of file QwRootFile.h.
Referenced by ProcessOptions(), and QwRootFile().
|
private |
Definition at line 1359 of file QwRootFile.h.
|
staticprivate |
Default ROOT files dir.
Definition at line 1211 of file QwRootFile.h.
Referenced by DefineOptions(), and SetDefaultRootFileDir().
|
staticprivate |
Default ROOT file stem.
Definition at line 1216 of file QwRootFile.h.
Referenced by DefineOptions(), and SetDefaultRootFileStem().
|
private |
Directories.
Definition at line 1334 of file QwRootFile.h.
Referenced by ConstructHistograms(), ConstructObjects(), HasDirByName(), and PrintDirs().
|
private |
Definition at line 1335 of file QwRootFile.h.
Referenced by ConstructHistograms(), ConstructObjects(), and HasDirByType().
|
private |
Definition at line 1249 of file QwRootFile.h.
Referenced by DisableHisto(), and IsHistoDisabled().
|
private |
List of excluded trees.
Definition at line 1248 of file QwRootFile.h.
Referenced by DisableTree(), and IsTreeDisabled().
|
private |
Definition at line 1230 of file QwRootFile.h.
Referenced by ProcessOptions(), and QwRootFile().
|
private |
Definition at line 1365 of file QwRootFile.h.
Referenced by FillHistograms().
|
private |
Live-output fill prescale: fill histograms (and, via the per-tree prescale, the trees) only on every Nth processed event. Default 1 fills on every event. Used to raise throughput in live mapfile mode.
Definition at line 1364 of file QwRootFile.h.
Referenced by FillHistograms(), and ProcessOptions().
|
private |
Definition at line 1221 of file QwRootFile.h.
Referenced by Close(), QwRootFile(), and ~QwRootFile().
|
private |
Map file.
Definition at line 1229 of file QwRootFile.h.
Referenced by cd(), Close(), ConstructHistograms(), ConstructObjects(), IsMapFile(), ls(), Print(), QwRootFile(), Update(), and ~QwRootFile().
|
private |
Directory that holds the memory-mapped file (default "/dev/shm" on Linux; override with –mapfile-dir on platforms without /dev/shm, e.g. macOS).
Definition at line 1233 of file QwRootFile.h.
Referenced by ProcessOptions(), and QwRootFile().
|
private |
Definition at line 1357 of file QwRootFile.h.
Referenced by ConstructTreeBranches(), and ProcessOptions().
|
private |
Definition at line 1356 of file QwRootFile.h.
Referenced by ConstructTreeBranches(), and ProcessOptions().
|
private |
Definition at line 1355 of file QwRootFile.h.
Referenced by ConstructTreeBranches(), and ProcessOptions().
|
private |
Prescaling of events written to tree.
Definition at line 1354 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 1220 of file QwRootFile.h.
Referenced by QwRootFile(), and ~QwRootFile().
|
private |
Definition at line 1237 of file QwRootFile.h.
Referenced by ProcessOptions().
|
private |
Definition at line 1238 of file QwRootFile.h.
Referenced by ProcessOptions().
|
private |
ROOT file.
Definition at line 1206 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 1209 of file QwRootFile.h.
Referenced by ProcessOptions(), and QwRootFile().
|
private |
ROOT file stem.
Definition at line 1214 of file QwRootFile.h.
Referenced by ProcessOptions(), and QwRootFile().
|
private |
Definition at line 1277 of file QwRootFile.h.
Referenced by ConstructTreeBranches(), FillTreeBranches(), FillTreeBranches(), and HasTreeByAddr().
|
private |
Tree names, addresses, and types.
Definition at line 1276 of file QwRootFile.h.
Referenced by Close(), ConstructIndices(), ConstructTreeBranches(), FillTree(), FillTrees(), GetTree(), HasAnyFilled(), HasTreeByName(), NewTree(), PrintTrees(), Update(), and ~QwRootFile().
|
private |
Definition at line 1278 of file QwRootFile.h.
Referenced by ConstructTreeBranches(), and HasTreeByType().
|
private |
Definition at line 1234 of file QwRootFile.h.
Referenced by FillHistograms(), ProcessOptions(), and QwRootFile().
|
private |
Definition at line 1222 of file QwRootFile.h.
Referenced by ProcessOptions(), QwRootFile(), and ~QwRootFile().
|
staticprivate |
Definition at line 1369 of file QwRootFile.h.
Referenced by ProcessOptions(), and QwRootFile().
|
staticprivate |
Maximum tree size.
Definition at line 1368 of file QwRootFile.h.
Referenced by ConstructTreeBranches().