22 #define BRANCH_VECTOR_MAX_SIZE 13000
41 QwRootTree(
const std::string& name,
const std::string& desc,
const std::string& prefix =
"")
58 QwRootTree(
const std::string& name,
const std::string& desc,
T&
object,
const std::string& prefix =
"")
94 std::string name =
"previous_entry_in_" + to->
fName;
104 TString prefix = Form(
"%s",
fPrefix.c_str());
105 object.ConstructBranchAndVector(
fTree, prefix,
fVector);
108 fType =
typeid(object).name();
112 QwError <<
"The branch vector is too large: " <<
fVector.size() <<
" leaves! "
125 if (
typeid(
object).name() ==
fType) {
127 object.FillTreeVector(
fVector);
129 QwError <<
"Attempting to fill tree vector for type " <<
fType <<
" with "
130 <<
"object of type " <<
typeid(object).name() <<
QwLog::endl;
147 Int_t retval =
fTree->Fill();
228 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,26,00)
242 if (
fTree)
fTree->SetBasketSize(
"*",basketsize);
307 void ConstructIndices(
const std::string& from,
const std::string& to,
bool reverse =
true);
311 void ConstructTreeBranches(
const std::string& name,
const std::string& desc,
T&
object,
const std::string& prefix =
"");
331 static Int_t update_count = 0;
336 object.FillHistograms();
341 void NewTree(
const std::string& name,
const std::string& desc) {
368 std::map< const std::string, std::vector<QwRootTree*> >::iterator iter;
370 retval += iter->second.front()->Fill();
379 std::map< const std::string, std::vector<QwRootTree*> >::const_iterator iter;
381 QwMessage << iter->first <<
": " << iter->second.size()
384 std::vector<QwRootTree*>::const_iterator tree;
385 for (tree = iter->second.begin(); tree != iter->second.end(); tree++) {
394 std::map< const std::string, TDirectory* >::const_iterator iter;
403 Int_t
WriteObject(
const T* obj,
const char* name, Option_t* option =
"", Int_t bufsize = 0) {
422 Bool_t
cd(
const char* path = 0) {
423 Bool_t status = kTRUE;
430 TDirectory*
mkdir(
const char* name,
const char* title =
"") {
437 Int_t
Write(
const char* name = 0, Int_t option = 0, Int_t bufsize = 0) {
510 std::map< const std::string, std::vector<QwRootTree*> >
fTreeByName;
512 std::map< const type_info* , std::vector<QwRootTree*> >
fTreeByType;
523 const type_info* type = &
typeid(object);
530 const void* addr =
static_cast<const void*
>(&object);
537 std::map< const std::string, std::vector<std::string> >
fDirsByType;
547 std::string type =
typeid(object).name();
601 const std::string& name,
602 const std::string& desc,
604 const std::string& prefix)
619 tree =
new QwRootTree(name, desc,
object, prefix);
622 if (name ==
"Mps_Tree")
624 else if (name ==
"Hel_Tree")
627 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,26,00)
644 const void* addr =
static_cast<const void*
>(&object);
645 const type_info* type = &
typeid(object);
659 const std::string& name,
668 const void* addr =
static_cast<const void*
>(&object);
671 for (
size_t tree = 0; tree <
fTreeByAddr[addr].size(); tree++) {
672 if (
fTreeByAddr[addr].at(tree)->GetName() == name) {
673 fTreeByAddr[addr].at(tree)->FillTreeBranches(
object);
691 const void* addr =
static_cast<const void*
>(&object);
694 for (
size_t tree = 0; tree <
fTreeByAddr[addr].size(); tree++) {
695 fTreeByAddr[addr].at(tree)->FillTreeBranches(
object);
713 std::string type =
typeid(object).name();
721 QwMessage <<
"QwRootFile::ConstructHistograms::detectors address "
723 <<
" and its name " << name
726 std::string type =
typeid(object).name();
730 object.ConstructHistograms();
740 TList *param_list = (TList*)
fRootFile->FindObjectAny(name);
741 if (not param_list) {
742 retval =
fRootFile->WriteObject(
object.GetParamFileNameList(name), name);
749 #endif // __QWROOTFILE__
#define QwMessage
Predefined log drain for regular messages.
void ConstructIndexTo(QwRootTree *to)
Construct index from this tree to another tree.
UInt_t fNumMpsEventsToSave
QwRootTree(const std::string &name, const std::string &desc, const std::string &prefix="")
Constructor with name, and description.
TTree * fTree
Tree pointer.
const std::string & GetName() const
Get the name of the tree.
UInt_t fCurrentEvent
Tree prescaling parameters.
void Print() const
Print the tree name and description.
A wrapper class for a ROOT tree.
Int_t WriteParamFileList(const TString &name, T &object)
void SetMaxTreeSize(Long64_t maxsize=1900000000)
Set maximum tree size.
UInt_t fNumHelEventsToSkip
void ConstructHistograms(const std::string &name, T &object)
Construct the histograms of a generic object.
TTree * GetTree(const std::string &name)
Get the tree with name.
Int_t Fill()
Fill the tree.
void SetAutoSave(Long64_t autosave=300000000)
Set autosave size.
void SetAutoFlush(Long64_t autoflush=30000000)
Set autoflush size.
bool HasTreeByName(const std::string &name)
Is a tree registered for this name.
void ConstructIndices(const std::string &from, const std::string &to, bool reverse=true)
Construct indices from one tree to another tree.
TMapFile * fMapFile
Map file.
void DisableHisto(const TString ®exp)
Add regexp to list of disabled histogram directories.
std::map< const void *, std::vector< QwRootTree * > > fTreeByAddr
Int_t FillTrees()
Fill all registered trees.
UInt_t fNumMpsEventsToSkip
Prescaling of events written to tree.
bool HasTreeByAddr(const T &object)
Is a tree registered for this object.
Bool_t IsRootFile() const
Is the ROOT file active?
QwRootFile()
Private default constructor.
std::vector< Double_t > fVector
Vector of leaves.
UInt_t fNumHelEventsToSave
Int_t FillTree(const std::string &name)
Fill the tree with name.
std::vector< TPRegexp > fDisabledHistos
void SetBasketSize(Int_t basketsize=16000)
Set basket size.
TTree * GetTree() const
Get the tree pointer for low level operations.
void SetPrescaling(UInt_t num_to_save, UInt_t num_to_skip)
Set tree prescaling parameters.
TString fRootFileStem
ROOT file stem.
virtual ~QwRootFile()
Destructor.
Bool_t cd(const char *path=0)
bool IsTreeDisabled(const std::string &name)
Does this tree name match a disabled tree name?
const std::string fName
Name, description.
UInt_t fCircularBufferSize
A wrapper class for a ROOT file or memory mapped file.
const std::string & GetDesc() const
Get the description of the tree.
Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
static std::string fDefaultRootFileStem
Default ROOT file stem.
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 ConstructBranchAndVector(T &object)
Construct the branches and vector for generic objects.
QwRootTree(const QwRootTree *tree, const std::string &prefix="")
Constructor with existing tree.
QwRootTree(const QwRootTree *tree, T &object, const std::string &prefix="")
Constructor with existing tree, and object.
std::vector< TPRegexp > fDisabledTrees
List of excluded trees.
void ConstructTreeBranches(const std::string &name, const std::string &desc, T &object, const std::string &prefix="")
Construct the tree branches of a generic object.
virtual ~QwRootTree()
Destructor.
#define BRANCH_VECTOR_MAX_SIZE
std::map< const std::string, TDirectory * > fDirsByName
Directories.
TFile * fRootFile
ROOT file.
void NewTree(const std::string &name, const std::string &desc)
Create a new tree with name and description.
Bool_t HasAnyFilled(void)
Search for non-empty trees or histograms in the file.
QwRootTree(const std::string &name, const std::string &desc, T &object, const std::string &prefix="")
Constructor with name, description, and object.
static const double T
Magnetic field: base unit is T.
void ConstructNewTree()
Construct the tree.
static void SetDefaultRootFileStem(const std::string &stem)
Set default ROOT file stem.
const std::string & GetPrefix() const
Get the description of the tree.
std::string GetType() const
Get the object type.
std::map< const std::string, std::vector< QwRootTree * > > fTreeByName
Tree names, addresses, and types.
const std::string fPrefix
static const Long64_t kMaxTreeSize
Maximum tree size.
std::string fType
Object type.
TDirectory * mkdir(const char *name, const char *title="")
Bool_t IsMapFile() const
Is the map file active?
static std::ostream & endl(std::ostream &)
End of the line.
static const Int_t kMaxMapFileSize
void ProcessOptions(QwOptions &options)
Process the configuration options.
void FillTreeBranches(const std::string &name, const T &object)
Fill the tree branches of a generic object by tree name.
void FillHistograms(T &object)
Fill histograms of the subsystem array.
An options class which parses command line, config file and environment.
void DisableTree(const TString ®exp)
Add regexp to list of disabled trees names.
bool HasDirByName(const std::string &name)
Is a tree registered for this name.
bool HasDirByType(const T &object)
Is a directory registered for this type.
void SetCircular(Long64_t buff=100000)
bool HasTreeByType(const T &object)
Is a tree registered for this type.
std::map< const std::string, std::vector< std::string > > fDirsByType
bool IsHistoDisabled(const std::string &name)
Does this histogram directory match a disabled histogram directory?
void PrintTrees() const
Print registered trees.
Long64_t fMaxTreeSize
Maximum tree size, autoflush and autosave.
void FillTreeBranches(const T &object)
Fill the branches for generic objects.
std::map< const type_info *, std::vector< QwRootTree * > > fTreeByType
void PrintDirs() const
Print registered histogram directories.
static void DefineOptions(QwOptions &options)
Define the configuration options.
#define QwError
Predefined log drain for errors.