Jpp
JPrintTree.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 
6 #include "TError.h"
7 #include "TROOT.h"
8 #include "TFile.h"
9 
10 #include "evt/Head.hh"
11 #include "evt/Evt.hh"
12 
13 #include "JDAQ/JDAQEvent.hh"
14 #include "JDAQ/JDAQTimeslice.hh"
15 #include "JDAQ/JDAQSummaryslice.hh"
16 
19 
20 #include "JROOT/JTreeParameters.hh"
21 #include "JROOT/JTreeReader.hh"
22 #include "JSupport/JSupport.hh"
23 
24 #include "JLang/JSinglePointer.hh"
25 #include "JLang/JBool.hh"
26 #include "JLang/JType.hh"
27 #include "JLang/JTypeList.hh"
28 #include "JLang/JNullType.hh"
29 
30 #include "Jeep/JParser.hh"
31 #include "Jeep/JMessage.hh"
32 
33 
34 namespace {
35 
36  using namespace JPP;
37 
38 
39  /**
40  * Auxiliary class to build list of valid TreeReader pointers.
41  */
42  class JTreeList :
43  public std::vector< JSinglePointer<JAbstractTreeReader> >
44  {
45  public:
46  /**
47  * Constructor.
48  *
49  * \param typelist type list
50  */
51  template<class T>
52  JTreeList(JType<T> typelist)
53  {
54  for_each(*this, typelist);
55  }
56 
57 
58  /**
59  * Addition of class.
60  *
61  * \param type type
62  */
63  template<class T>
64  void operator()(JType<T> type)
65  {
67  }
68 
69  private:
70  /**
71  * Addition of TTree compatible class.
72  */
73  template<class T>
74  void add(JType<T>, JBool<true>)
75  {
76  this->push_back(new JTreeReader<T>());
77  }
78 
79 
80  /**
81  * No addition of TTree incompatible class.
82  */
83  template<class T>
84  void add(JType<T>, JBool<false>)
85  {}
86  };
87 }
88 
89 
90 /**
91  * \file
92  *
93  * Auxiliary program to print ROOT TTree information.
94  * \author mdejong
95  */
96 int main(int argc, char **argv)
97 {
98  using namespace std;
99 
100  vector<string> inputFile;
101  int debug;
102 
103  try {
104 
105  JParser<> zap("Auxiliary program to print ROOT TTree information.");
106 
107  zap['f'] = make_field(inputFile);
108  zap['d'] = make_field(debug) = 1;
109 
110  zap(argc, argv);
111  }
112  catch(const exception &error) {
113  FATAL(error.what() << endl);
114  }
115 
116  cout.tie(&cerr);
117 
119 
120  JTreeList inspector(typelist);
121 
122  for (vector<string>::const_iterator file = inputFile.begin(); file != inputFile.end(); ++file) {
123 
124  cout << *file << endl;
125 
126  for (JTreeList::iterator i = inspector.begin(); i != inspector.end(); ++i) {
127 
128  gErrorIgnoreLevel = kFatal;
129 
130  if ((*i)->load(TFile::Open(file->c_str()))) {
131  cout << setw(24) << left << (**i)->GetName() << ' '
132  << setw(32) << left << (*i)->getDictionary()->GetName() << ' '
133  << setw(10) << right << (**i)->GetEntries() << ' '
134  << setw( 6) << right << ((**i)->GetTotBytes() >> 20) << " [MB]" << endl;
135  }
136  }
137  }
138 }
TimeSlice.hh
JLANG::JType
Auxiliary class for a type holder.
Definition: JType.hh:19
JBool.hh
JMessage.hh
JTreeReader.hh
JROOT::JTreeReader
Auxiliary class for template TTree reading.
Definition: JTreeReader.hh:54
JSinglePointer.hh
JTreeParameters.hh
std::vector
Definition: JSTDTypes.hh:12
JPARSER::JParser
Utility class to parse command line options.
Definition: JParser.hh:1493
JDAQTimeslice.hh
JROOT::JTreeParametersAvailable
Test availability of TTree parameters for given class.
Definition: JTreeParameters.hh:174
JDAQSummaryslice.hh
JSupport.hh
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
debug
int debug
debug level
Definition: JSirene.cc:59
JLANG::for_each
JObject_t & for_each(JObject_t &object, JType< JTypeList< JHead_t, JTail_t > > typelist)
For each data type method.
Definition: JTypeList.hh:572
JLANG::JBool
Auxiliary template class for type bool.
Definition: JBool.hh:20
JParser.hh
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
PhysicsEvent.hh
std
Definition: jaanetDictionary.h:36
JTypeList.hh
JNullType.hh
JDAQEvent.hh
FATAL
#define FATAL(A)
Definition: JMessage.hh:67
JType.hh
main
int main(int argc, char **argv)
Definition: JPrintTree.cc:96