Jpp  18.2.1-ARCA-DF-PATCH
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JPrintChain.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 
12 
13 #include "JDAQ/JDAQEventIO.hh"
14 #include "JDAQ/JDAQTimesliceIO.hh"
16 
18 
21 
22 #include "JROOT/JTreeParameters.hh"
23 #include "JROOT/JChainReader.hh"
24 #include "JSupport/JSupport.hh"
25 
26 #include "JLang/JBool.hh"
27 #include "JLang/JType.hh"
28 
29 #include "Jeep/JParser.hh"
30 #include "Jeep/JMessage.hh"
31 
32 
33 namespace {
34 
35  using namespace JPP;
36 
37 
38  /**
39  * Auxiliary class to build list of valid TreeReader pointers.
40  */
41  class JChainList :
42  public std::vector<TChain*>
43  {
44  public:
45  /**
46  * Constructor.
47  *
48  * \param typelist type list
49  */
50  template<class T>
51  JChainList(JType<T> typelist)
52  {
53  for_each(*this, typelist);
54  }
55 
56 
57  /**
58  * Addition of class.
59  *
60  * \param type type
61  */
62  template<class T>
63  void operator()(JType<T> type)
64  {
66  }
67 
68  private:
69  /**
70  * Addition of TChain compatible class.
71  */
72  template<class T>
73  void add(JType<T>, JBool<true>)
74  {
75  this->push_back(new JChainReader<T>(getTreeParameters(JType<T>())));
76  }
77 
78 
79  /**
80  * No addition of TChain incompatible class.
81  */
82  template<class T>
83  void add(JType<T>, JBool<false>)
84  {}
85  };
86 }
87 
88 
89 /**
90  * \file
91  *
92  * Auxiliary program to print ROOT TChain information.
93  * \author mdejong
94  */
95 int main(int argc, char **argv)
96 {
97  using namespace std;
98  using namespace JPP;
99 
101 
102  vector<string> inputFile;
103  int debug;
104 
105  try {
106 
107  JParser<> zap("Auxiliary program to print ROOT TChain information.");
108 
109  zap['f'] = make_field(inputFile);
110  zap['d'] = make_field(debug) = 1;
111 
112  zap(argc, argv);
113  }
114  catch(const exception &error) {
115  FATAL(error.what() << endl);
116  }
117 
118 
119  JType<typelist> type;
120 
121  JChainList inspector(type);
122 
123  for (JChainList::iterator i = inspector.begin(); i != inspector.end(); ++i) {
124  for (vector<string>::const_iterator file = inputFile.begin(); file != inputFile.end(); ++file) {
125  (*i)->Add(file->c_str());
126  }
127  }
128 
129  DEBUG("Number of files " << inputFile.size() << endl);
130 
131  gErrorIgnoreLevel = kFatal;
132 
133  for (JChainList::iterator i = inspector.begin(); i != inspector.end(); ++i) {
134  cout << setw(24) << left << (*i)->GetName() << ' '
135  << setw(10) << right << (*i)->GetEntries() << endl;
136  }
137 }
Utility class to parse command line options.
Definition: JParser.hh:1514
int main(int argc, char *argv[])
Definition: Main.cc:15
ROOT TTree parameter settings of various packages.
then usage $script[< detector identifier >< run range >]< QA/QCfile > nExample script to produce data quality plots nWhen a detector identifier and run range are data are downloaded from the database nand subsequently stored in the given QA QC file
Definition: JDataQuality.sh:19
Test availability of TTree parameters for given class.
Auxiliary class for a type holder.
Definition: JType.hh:19
Auxiliary class for template TChain reading.
Definition: JChainReader.hh:24
Type list.
Definition: JTypeList.hh:22
Auxiliary template class for type bool.
Definition: JBool.hh:20
TChain reading for template data type.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
General purpose messaging.
JObject_t & for_each(JObject_t &object, JType< JTypeList< JHead_t, JTail_t > > typelist)
For each data type method.
Definition: JTypeList.hh:415
#define FATAL(A)
Definition: JMessage.hh:67
JROOT::JTreeParameters getTreeParameters(JLANG::JType< JRECONSTRUCTION::JEvt >)
Get TTree parameters for given data type.
Utility class to parse command line options.
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62