Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
garana::TreeManager Class Reference

#include <TreeManager.h>

Public Member Functions

 TreeManager ()
 
 TreeManager (const string &infilename)
 
HeaderTreeGetHeaderTree () const
 
GenTreeGetGenTree () const
 
G4TreeGetG4Tree () const
 
DetTreeGetDetTree () const
 
RecoTreeGetRecoTree () const
 
DisplayTreeGetDisplayTree () const
 
void GetEntry (const UInt_t &ientry)
 
UInt_t const & NEntries () const
 
void SetActiveGenTree (bool active=true)
 
void SetActiveG4Tree (bool active=true)
 
void SetActiveDetTree (bool active=true)
 
void SetActiveRecTree (bool active=true)
 
void SetActiveDisTree (bool active=true)
 
bool IsActiveGenTree () const
 
bool IsActiveG4Tree () const
 
bool IsActiveDetTree () const
 
bool IsActiveRecTree () const
 
bool IsActiveDisTree () const
 

Public Attributes

const string genName = "genTree"
 
const string g4Name = "g4Tree"
 
const string detName = "detTree"
 
const string recoName = "recoTree"
 
const string displayName = "displayTree"
 

Private Member Functions

void Init ()
 
bool CheckEntries ()
 

Private Attributes

string fInFileName = ""
 
TFile * fInFile = nullptr
 
string fTreeType = ""
 
UInt_t fNEntries = 0
 
bool fOnGen = true
 
bool fOnG4 = true
 
bool fOnDet = false
 
bool fOnRec = true
 
bool fOnDis = false
 
HeaderTreefHeaderTree = nullptr
 
StructuredGenTreefStructGenTree = nullptr
 
StructuredG4TreefStructG4Tree = nullptr
 
StructuredDetTreefStructDetTree = nullptr
 
StructuredRecoTreefStructRecoTree = nullptr
 
StructuredDisplayTreefStructDisplayTree = nullptr
 
FlatGenTreefFlatGenTree = nullptr
 
FlatG4TreefFlatG4Tree = nullptr
 
FlatDetTreefFlatDetTree = nullptr
 
FlatRecoTreefFlatRecoTree = nullptr
 
FlatDisplayTreefFlatDisplayTree = nullptr
 

Detailed Description

Definition at line 38 of file TreeManager.h.

Constructor & Destructor Documentation

garana::TreeManager::TreeManager ( )
inline

Definition at line 42 of file TreeManager.h.

42 {}
TreeManager::TreeManager ( const string infilename)

Definition at line 14 of file TreeManager.cxx.

14  : //, bool onGen=1, bool onG4=1, bool onDet=0, bool onReco=1, bool onDis=0) :
15  fInFileName(infilename),
16  fOnGen(true),
17  fOnG4(true),
18  fOnDet(false),
19  fOnRec(true),
20  fOnDis(false)
21  {
22 
23  //fInFileName = infilename;
24  Init();
25  CheckEntries();
26 
27 }

Member Function Documentation

bool TreeManager::CheckEntries ( )
private

Definition at line 257 of file TreeManager.cxx.

257  {
258 
259  vector<UInt_t> ns;
260  if(fOnGen) {
261  if(fStructGenTree) ns.push_back(fStructGenTree->NEntries());
262  else if(fFlatGenTree) ns.push_back(fFlatGenTree->NEntries());
263  }
264  if(fOnG4) {
265  if(fStructG4Tree) ns.push_back(fStructG4Tree->NEntries());
266  else if(fFlatG4Tree) ns.push_back(fFlatG4Tree->NEntries());
267  }
268  if(fOnDet) {
269  if(fStructDetTree) ns.push_back(fStructDetTree->NEntries());
270  else if(fFlatDetTree) ns.push_back(fFlatDetTree->NEntries());
271  }
272  if(fOnRec) {
273  if(fStructRecoTree) ns.push_back(fStructRecoTree->NEntries());
274  else if(fFlatRecoTree) ns.push_back(fFlatRecoTree->NEntries());
275  }
276 
277  try {
278  for(size_t i=1; i<ns.size(); i++){
279  if(ns[0]!=ns[i])
280  throw ns[0];
281  }
282  }
283  catch(Int_t n){
284  cerr << "number of entries differs between trees!" << endl;
285  return false;
286  }
287 
288  fNEntries = ns[0];
289  return true;
290 }
StructuredRecoTree * fStructRecoTree
Definition: TreeManager.h:95
FlatGenTree * fFlatGenTree
Definition: TreeManager.h:98
StructuredGenTree * fStructGenTree
Definition: TreeManager.h:92
StructuredDetTree * fStructDetTree
Definition: TreeManager.h:94
std::void_t< T > n
FlatG4Tree * fFlatG4Tree
Definition: TreeManager.h:99
FlatRecoTree * fFlatRecoTree
Definition: TreeManager.h:101
FlatDetTree * fFlatDetTree
Definition: TreeManager.h:100
StructuredG4Tree * fStructG4Tree
Definition: TreeManager.h:93
QAsciiDict< Entry > ns
size_t NEntries() const
Definition: TreeReader.cxx:35
QTextStream & endl(QTextStream &s)
DetTree * TreeManager::GetDetTree ( ) const

Definition at line 174 of file TreeManager.cxx.

174  {
175 
176  try{
178  throw fStructDetTree;
179  if(!fStructDetTree){
180  return fFlatDetTree;
181  }
182  else{
183  return fStructDetTree;
184  }
185  }
186  catch(StructuredDetTree* e){
187  std::cerr << "TreeManager::DetTree: no structured detTree or flat detTree found!" << std::endl;
188  }
189 
190  return nullptr;
191 
192 }//GetGenTree()
StructuredDetTree * fStructDetTree
Definition: TreeManager.h:94
const double e
FlatDetTree * fFlatDetTree
Definition: TreeManager.h:100
QTextStream & endl(QTextStream &s)
DisplayTree * TreeManager::GetDisplayTree ( ) const

Definition at line 214 of file TreeManager.cxx.

214  {
215 
216  try{
218  throw fStructDisplayTree;
219  if(!fStructDisplayTree){
220  return fFlatDisplayTree;
221  }
222  else{
223  return fStructDisplayTree;
224  }
225  }
226  catch(StructuredDisplayTree* e){
227  cerr << "TreeManager::DisplayTree: no structured displayTree or flat displayTree found!" << endl;
228  }
229 
230  return nullptr;
231 
232 }//GetGenTree()
FlatDisplayTree * fFlatDisplayTree
Definition: TreeManager.h:102
StructuredDisplayTree * fStructDisplayTree
Definition: TreeManager.h:96
const double e
QTextStream & endl(QTextStream &s)
void TreeManager::GetEntry ( const UInt_t &  ientry)

Definition at line 235 of file TreeManager.cxx.

235  {
236 
237  if(fOnGen) {
239  else if(fFlatGenTree) fFlatGenTree->GetEntry(ientry);
240  }
241  if(fOnG4) {
242  if(fStructG4Tree) fStructG4Tree->GetEntry(ientry);
243  else if(fFlatG4Tree) fFlatG4Tree->GetEntry(ientry);
244  }
245  if(fOnDet) {
247  else if(fFlatDetTree) fFlatDetTree->GetEntry(ientry);
248  }
249  if(fOnRec) {
251  else if(fFlatRecoTree) fFlatRecoTree->GetEntry(ientry);
252  }
253 
254  // probably don't want to include display tree
255 }
StructuredRecoTree * fStructRecoTree
Definition: TreeManager.h:95
FlatGenTree * fFlatGenTree
Definition: TreeManager.h:98
StructuredGenTree * fStructGenTree
Definition: TreeManager.h:92
StructuredDetTree * fStructDetTree
Definition: TreeManager.h:94
void GetEntry(const UInt_t &ientry) override
Definition: FlatGenTree.cxx:39
FlatG4Tree * fFlatG4Tree
Definition: TreeManager.h:99
FlatRecoTree * fFlatRecoTree
Definition: TreeManager.h:101
FlatDetTree * fFlatDetTree
Definition: TreeManager.h:100
StructuredG4Tree * fStructG4Tree
Definition: TreeManager.h:93
void GetEntry(const UInt_t &ientry) override
Definition: FlatG4Tree.cxx:38
virtual void GetEntry(const UInt_t &ientry)
Definition: TreeReader.cxx:39
G4Tree * TreeManager::GetG4Tree ( ) const

Definition at line 154 of file TreeManager.cxx.

154  {
155 
156  try{
157  if(!fStructG4Tree && !fFlatG4Tree)
158  throw fStructG4Tree;
159  if(!fStructG4Tree){
160  return fFlatG4Tree;
161  }
162  else{
163  return fStructG4Tree;
164  }
165  }
166  catch(StructuredGenTree* e){
167  std::cerr << "TreeManager::G4Tree: no structured g4Tree or flat g4Tree found!" << std::endl;
168  }
169 
170  return nullptr;
171 
172 }//GetGenTree()
const double e
FlatG4Tree * fFlatG4Tree
Definition: TreeManager.h:99
StructuredG4Tree * fStructG4Tree
Definition: TreeManager.h:93
QTextStream & endl(QTextStream &s)
GenTree * TreeManager::GetGenTree ( ) const

Definition at line 134 of file TreeManager.cxx.

134  {
135 
136  try{
138  throw fStructGenTree;
139  if(!fStructGenTree){
140  return fFlatGenTree;
141  }
142  else{
143  return fStructGenTree;
144  }
145  }
146  catch(StructuredGenTree* e){
147  std::cerr << "TreeManager::GenTree: no structured genTree or flat genTree found!" << std::endl;
148  }
149 
150  return nullptr;
151 
152 }//GetGenTree()
FlatGenTree * fFlatGenTree
Definition: TreeManager.h:98
StructuredGenTree * fStructGenTree
Definition: TreeManager.h:92
const double e
QTextStream & endl(QTextStream &s)
HeaderTree * TreeManager::GetHeaderTree ( ) const

Definition at line 128 of file TreeManager.cxx.

128  {
129 
130  return fHeaderTree;
131 
132 }
HeaderTree * fHeaderTree
Definition: TreeManager.h:90
RecoTree * TreeManager::GetRecoTree ( ) const

Definition at line 194 of file TreeManager.cxx.

194  {
195 
196  try{
198  throw fStructRecoTree;
199  if(!fStructRecoTree){
200  return fFlatRecoTree;
201  }
202  else{
203  return fStructRecoTree;
204  }
205  }
206  catch(StructuredRecoTree* e){
207  cerr << "TreeManager::RecoTree: no structured recoTree or flat recoTree found!" << endl;
208  }
209 
210  return nullptr;
211 
212 }//GetGenTree()
StructuredRecoTree * fStructRecoTree
Definition: TreeManager.h:95
const double e
FlatRecoTree * fFlatRecoTree
Definition: TreeManager.h:101
QTextStream & endl(QTextStream &s)
void TreeManager::Init ( void  )
private

genTree

g4Tree ///

recoTree ///

Definition at line 29 of file TreeManager.cxx.

29  {
30 
31  //open file for reading
32  try {
33  fInFile = new TFile(fInFileName.c_str(),"READ");
34  if(!fInFile)
35  throw fInFileName;
36  }
37  catch(std::string& fname){
38  std::cerr << "TreeManager::Init: unable to find the file, "
39  << fInFileName << '\n';
40  }
41 
42  // headerTree
43  TTree* header = (TTree*)fInFile->FindObjectAny("headerTree");
44  try {
45  if(!header)
46  throw header;
47  }
48  catch(TTree* t){
49  std::cerr << "TreeManager::Init: "
50  << "No HeaderTree found in input file, " << fInFile
51  << '\n';
52  }
53 
54  cout << "found header Tree" << endl;
55 
56  fHeaderTree = new HeaderTree(header);
58 
59  /// genTree
60  TTree* gen = nullptr;
61  try{
62  gen = (TTree*)fInFile->FindObjectAny(genName.c_str());
63  if(!gen)
64  throw gen;
65  }
66  catch(TTree* t){
67  std::cerr << "TreeManager::Init: "
68  << "No GenTree found in input file, " << fInFile
69  << '\n';
70  }
71 
72  if(fTreeType == "structured"){ //structured tree
74  }
75  else { //flat tree
76  fFlatGenTree = new FlatGenTree(gen);
77  }
78 
79  cout << "found genTree" << endl;
80 
81  /// g4Tree ///
82  TTree* g4 = nullptr;
83  try{
84  g4 = (TTree*)fInFile->FindObjectAny(g4Name.c_str());
85  if(!g4)
86  throw g4;
87  }
88  catch(TTree* t){
89  std::cerr << "TreeManager::Init: "
90  << "No G4Tree found in input file, " << fInFile
91  << '\n';
92  }
93 
94  if(fTreeType == "structured"){ //structured tree
96  }
97  else { //flat tree
98  fFlatG4Tree = new FlatG4Tree(g4);
99  }
100  cout << "found g4Tree" << endl;
101 
102  /// recoTree ///
103  TTree* reco = nullptr;
104  try{
105  reco = (TTree*)fInFile->FindObjectAny(recoName.c_str());
106  if(!reco)
107  throw reco;
108  }
109  catch(TTree* t){
110  std::cerr << "TreeManager::Init: "
111  << "No RecoTree found in input file, " << fInFile
112  << '\n';
113  }
114 
115  if(fTreeType == "structured"){ //structured tree
117  }
118  else { //flat tree
119  fFlatRecoTree = new FlatRecoTree(reco);
120  }
121 
122  cout << "found recoTree" << endl;
123 
124  cout << "at end of Init()" << endl;
125 
126 }// Init()
StructuredRecoTree * fStructRecoTree
Definition: TreeManager.h:95
FlatGenTree * fFlatGenTree
Definition: TreeManager.h:98
std::string string
Definition: nybbler.cc:12
StructuredGenTree * fStructGenTree
Definition: TreeManager.h:92
const std::string *const TreeType() const
Definition: HeaderTree.cxx:32
gen
Definition: demo.py:24
FlatG4Tree * fFlatG4Tree
Definition: TreeManager.h:99
FlatRecoTree * fFlatRecoTree
Definition: TreeManager.h:101
StructuredG4Tree * fStructG4Tree
Definition: TreeManager.h:93
const string recoName
Definition: TreeManager.h:71
const string genName
Definition: TreeManager.h:68
HeaderTree * fHeaderTree
Definition: TreeManager.h:90
const string g4Name
Definition: TreeManager.h:69
QTextStream & endl(QTextStream &s)
g4
Definition: tracks.py:87
bool garana::TreeManager::IsActiveDetTree ( ) const
inline

Definition at line 63 of file TreeManager.h.

63 {return fOnDet; }
bool garana::TreeManager::IsActiveDisTree ( ) const
inline

Definition at line 65 of file TreeManager.h.

65 {return fOnDis; }
bool garana::TreeManager::IsActiveG4Tree ( ) const
inline

Definition at line 62 of file TreeManager.h.

62 {return fOnG4 ; }
bool garana::TreeManager::IsActiveGenTree ( ) const
inline

Definition at line 61 of file TreeManager.h.

61 {return fOnGen; }
bool garana::TreeManager::IsActiveRecTree ( ) const
inline

Definition at line 64 of file TreeManager.h.

64 {return fOnRec; }
UInt_t const& garana::TreeManager::NEntries ( ) const
inline

Definition at line 53 of file TreeManager.h.

53 {return fNEntries;}
void garana::TreeManager::SetActiveDetTree ( bool  active = true)
inline

Definition at line 57 of file TreeManager.h.

57 {fOnDet = active; }
void garana::TreeManager::SetActiveDisTree ( bool  active = true)
inline

Definition at line 59 of file TreeManager.h.

59 {fOnDis = active; }
void garana::TreeManager::SetActiveG4Tree ( bool  active = true)
inline

Definition at line 56 of file TreeManager.h.

56 {fOnG4 = active; }
void garana::TreeManager::SetActiveGenTree ( bool  active = true)
inline

Definition at line 55 of file TreeManager.h.

55 {fOnGen = active; }
void garana::TreeManager::SetActiveRecTree ( bool  active = true)
inline

Definition at line 58 of file TreeManager.h.

58 {fOnRec = active; }

Member Data Documentation

const string garana::TreeManager::detName = "detTree"

Definition at line 70 of file TreeManager.h.

const string garana::TreeManager::displayName = "displayTree"

Definition at line 72 of file TreeManager.h.

FlatDetTree* garana::TreeManager::fFlatDetTree = nullptr
private

Definition at line 100 of file TreeManager.h.

FlatDisplayTree* garana::TreeManager::fFlatDisplayTree = nullptr
private

Definition at line 102 of file TreeManager.h.

FlatG4Tree* garana::TreeManager::fFlatG4Tree = nullptr
private

Definition at line 99 of file TreeManager.h.

FlatGenTree* garana::TreeManager::fFlatGenTree = nullptr
private

Definition at line 98 of file TreeManager.h.

FlatRecoTree* garana::TreeManager::fFlatRecoTree = nullptr
private

Definition at line 101 of file TreeManager.h.

HeaderTree* garana::TreeManager::fHeaderTree = nullptr
private

Definition at line 90 of file TreeManager.h.

TFile* garana::TreeManager::fInFile = nullptr
private

Definition at line 80 of file TreeManager.h.

string garana::TreeManager::fInFileName = ""
private

Definition at line 79 of file TreeManager.h.

UInt_t garana::TreeManager::fNEntries = 0
private

Definition at line 82 of file TreeManager.h.

bool garana::TreeManager::fOnDet = false
private

Definition at line 86 of file TreeManager.h.

bool garana::TreeManager::fOnDis = false
private

Definition at line 88 of file TreeManager.h.

bool garana::TreeManager::fOnG4 = true
private

Definition at line 85 of file TreeManager.h.

bool garana::TreeManager::fOnGen = true
private

Definition at line 84 of file TreeManager.h.

bool garana::TreeManager::fOnRec = true
private

Definition at line 87 of file TreeManager.h.

StructuredDetTree* garana::TreeManager::fStructDetTree = nullptr
private

Definition at line 94 of file TreeManager.h.

StructuredDisplayTree* garana::TreeManager::fStructDisplayTree = nullptr
private

Definition at line 96 of file TreeManager.h.

StructuredG4Tree* garana::TreeManager::fStructG4Tree = nullptr
private

Definition at line 93 of file TreeManager.h.

StructuredGenTree* garana::TreeManager::fStructGenTree = nullptr
private

Definition at line 92 of file TreeManager.h.

StructuredRecoTree* garana::TreeManager::fStructRecoTree = nullptr
private

Definition at line 95 of file TreeManager.h.

string garana::TreeManager::fTreeType = ""
private

Definition at line 81 of file TreeManager.h.

const string garana::TreeManager::g4Name = "g4Tree"

Definition at line 69 of file TreeManager.h.

const string garana::TreeManager::genName = "genTree"

Definition at line 68 of file TreeManager.h.

const string garana::TreeManager::recoName = "recoTree"

Definition at line 71 of file TreeManager.h.


The documentation for this class was generated from the following files: