1 #include "TreeManager.hxx" 2 #include <TDirectory.h> 9 TreeManager::TreeManager(){
17 for (UInt_t i=0;i<
_trees.size();i++)
24 TreeManager::~TreeManager() {
35 if (index!=-1)
return GetTree(index);
55 return _trees[index]->GetName();
62 if (index<0 || index>(Int_t)
_trees.size()-1)
return false;
63 return (
_trees[index]!=NULL);
79 _file =
new TFile(file.c_str(),
"READ");
83 TTree *t = (TTree*)(
_file->Get(tree_name.c_str()));
84 Int_t tree_index = std::atoi(t->GetTitle());
100 if (index!=-1)
ReadTree(file,index);
107 for (UInt_t i=0;i<
_trees.size();i++)
114 _file =
new TFile(file.c_str(),
"READ");
116 TList *keys =
_file->GetListOfKeys();
117 for (
int i=0;i<keys->GetEntries();i++){
118 std::string tree_name = keys->At(i)->GetName();
119 TTree *t = (TTree*)(
_file->Get(tree_name.c_str()));
120 Int_t tree_index = std::atoi(t->GetTitle());
121 if(
_trees[tree_index])
continue;
std::vector< Int_t > _trees_indices
Vector of indices for the non NULL TTree in previous vector.
Int_t GetCurrentTree() const
Retuns the current tree index.
std::string GetTreeName(Int_t index)
Retuns the tree name provided the index.
std::string GetCurrentTreeName()
Retuns the current tree name.
void ReadFile(const std::string &file)
Read all trees from a file.
void SetCurrentTree(Int_t index)
Sets the current tree provided the index.
Int_t GetTreeIndex(const std::string &tree_name)
Retuns the tree index provided the name.
bool HasTree(Int_t index)
Check the existence of a tree provided the index.
std::vector< TTree *> _trees
Vector of trees.
void ReadTree(const std::string &file, Int_t index)
Read a tree from a file provided the index.
TFile * _file
Root input or output file.
std::vector< TTree *> _trees_nonull
Vector of non NULL trees.
TTree * GetTree()
Returns the a tree set as current.
Int_t _current_tree
The current tree.