Jpp  18.6.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JPrintTree.cc File Reference

Auxiliary program to print ROOT TTree information. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "TError.h"
#include "TROOT.h"
#include "TFile.h"
#include "TKey.h"
#include "TTree.h"
#include "JSystem/JGlob.hh"
#include "JLang/JEquals.hh"
#include "JLang/JVectorize.hh"
#include "Jeep/JeepToolkit.hh"
#include "Jeep/JProperties.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program to print ROOT TTree information.

Author
mdejong

Definition in file JPrintTree.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 146 of file JPrintTree.cc.

147 {
148  using namespace std;
149  using namespace JPP;
150 
151  vector<string> inputFile;
152  tree_info ta; // selection
153  tree_info tb; // actual
154  string key; // format
155  int debug;
156 
157  JProperties format;
158 
159  format.insert(gmake_property(tb.name));
160  format.insert(gmake_property(tb.type));
161  format.insert(gmake_property(tb.number_of_entries));
162  format.insert(gmake_property(tb.number_of_bytes));
163 
164  try {
165 
166  JProperties properties;
167 
168  properties.insert(gmake_property(ta.name));
169  properties.insert(gmake_property(ta.type));
170 
171  JParser<> zap("Auxiliary program to print ROOT TTree information.");
172 
173  zap['f'] = make_field(inputFile);
174  zap['@'] = make_field(properties) = JPARSER::initialised();
175  zap['k'] = make_field(key) = "", get_keys(format);
176  zap['d'] = make_field(debug) = 1;
177 
178  zap(argc, argv);
179  }
180  catch(const exception &error) {
181  FATAL(error.what() << endl);
182  }
183 
184  gErrorIgnoreLevel = kFatal;
185 
186  inputFile = getFilenames(inputFile);
187 
188  int number_of_errors = 0;
189 
190  for (vector<string>::const_iterator file_name = inputFile.begin(); file_name != inputFile.end(); ++file_name) {
191 
192  TFile* file = TFile::Open(file_name->c_str());
193 
194  if (file == NULL) {
195 
196  ++number_of_errors;
197 
198  cerr << *file_name << " not opened." << endl;
199 
200  continue;
201  }
202 
203  if (key == "") {
204  cout << *file_name << endl;
205  }
206 
207  TIter iter(file->GetListOfKeys(), kIterBackward);
208 
209  for (TKey* _key; (_key = (TKey*) iter.Next()) != NULL; ) {
210 
211  TKey* p = dynamic_cast<TKey*>(file->GetListOfKeys()->Before(_key));
212 
213  if (p == NULL || strcmp(_key->GetName(), p->GetName()) != 0) { // select last key
214 
215  tb = tree_info(dynamic_cast<TTree*>(_key->ReadObj()));
216 
217  if (tb.is_valid() && ta == tb) {
218 
219  if (key == "")
220  cout << tb << endl;
221  else
222  format.write(cout, key) << ' ';
223  }
224  }
225  }
226 
227  file->Close();
228 
229  delete file;
230  }
231 
232  return (number_of_errors == 0 ? 0 : 1);
233 }
Utility class to parse command line options.
Definition: JParser.hh:1711
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
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
static JGlob getFilenames
Function object to get list of files for given pattern.
Definition: JGlob.hh:123
Utility class to parse parameter values.
Definition: JProperties.hh:497
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:84
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2158
#define FATAL(A)
Definition: JMessage.hh:67
const array_type< JKey_t > & get_keys(const std::map< JKey_t, JValue_t, JComparator_t, JAllocator_t > &data)
Method to create array of keys of map.
Definition: JVectorize.hh:139
int debug
debug level