Jpp  18.1.0
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 "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 22 of file JPrintTree.cc.

23 {
24  using namespace std;
25 
26  vector<string> inputFile;
27  int debug;
28 
29  try {
30 
31  JParser<> zap("Auxiliary program to print ROOT TTree information.");
32 
33  zap['f'] = make_field(inputFile);
34  zap['d'] = make_field(debug) = 1;
35 
36  zap(argc, argv);
37  }
38  catch(const exception &error) {
39  FATAL(error.what() << endl);
40  }
41 
42  gErrorIgnoreLevel = kFatal;
43 
44  int number_of_errors = 0;
45 
46  for (vector<string>::const_iterator file_name = inputFile.begin(); file_name != inputFile.end(); ++file_name) {
47 
48  TFile* file = TFile::Open(file_name->c_str());
49 
50  cout << *file_name << flush;
51 
52  if (file != NULL) {
53 
54  cout << endl;
55 
56  TIter iter(file->GetListOfKeys(), kIterBackward);
57 
58  for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
59 
60  TKey* p = dynamic_cast<TKey*>(file->GetListOfKeys()->Before(key));
61 
62  if (p == NULL || strcmp(key->GetName(), p->GetName()) != 0) { // select last key
63 
64  TTree* tree = dynamic_cast<TTree*>(key->ReadObj());
65 
66  if (tree != NULL) {
67 
68  TBranch* branch = dynamic_cast<TBranch*>(tree->GetListOfBranches()->At(0)); // KM3NeT policy
69 
70  if (branch != NULL) {
71  cout << setw(24) << left << key->GetName() << ' '
72  << setw(32) << left << branch->GetClassName() << ' '
73  << setw(10) << right << tree->GetEntries() << ' '
74  << setw( 6) << right << (tree->GetTotBytes() >> 20) << " [MB]" << endl;
75  }
76  }
77  }
78  }
79 
80  } else {
81 
82  ++number_of_errors;
83 
84  cout << " not opened." << endl;
85  }
86  }
87 
88  return (number_of_errors == 0 ? 0 : 1);
89 }
Utility class to parse command line options.
Definition: JParser.hh:1514
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 make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level