#include #include #include #include "TError.h" #include "TROOT.h" #include "TFile.h" #include "TKey.h" #include "TTree.h" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Auxiliary program to print ROOT TTree information. * \author mdejong */ int main(int argc, char **argv) { using namespace std; vector inputFile; int debug; try { JParser<> zap("Auxiliary program to print ROOT TTree information."); zap['f'] = make_field(inputFile); zap['d'] = make_field(debug) = 1; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } cout.tie(&cerr); gErrorIgnoreLevel = kFatal; int number_of_errors = 0; for (vector::const_iterator file_name = inputFile.begin(); file_name != inputFile.end(); ++file_name) { TFile* file = TFile::Open(file_name->c_str()); cout << *file_name << flush; if (file != NULL) { cout << endl; TIter iter(file->GetListOfKeys(), kIterBackward); for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) { TKey* p = dynamic_cast(file->GetListOfKeys()->Before(key)); if (p == NULL || strcmp(key->GetName(), p->GetName()) != 0) { // select last key TTree* tree = dynamic_cast(key->ReadObj()); if (tree != NULL) { TBranch* branch = dynamic_cast(tree->GetListOfBranches()->At(0)); // KM3NeT policy if (branch != NULL) { cout << setw(24) << left << key->GetName() << ' ' << setw(32) << left << branch->GetClassName() << ' ' << setw(10) << right << tree->GetEntries() << ' ' << setw( 6) << right << (tree->GetTotBytes() >> 20) << " [MB]" << endl; } } } } } else { ++number_of_errors; cout << " not opened." << endl; } } return (number_of_errors == 0 ? 0 : 1); }