#include #include #include #include "TROOT.h" #include "TFile.h" #include "TNamed.h" #include "TKey.h" #include "TRegexp.h" #include "JLang/JLangToolkit.hh" #include "JLang/JObjectMultiplexer.hh" #include "Jeep/JeepToolkit.hh" #include "JSon/JSon.hh" #include "JSupport/JMultipleFileScanner.hh" #include "JSupport/JMeta.hh" #include "JSupport/JSupport.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" namespace { /** * Print options. */ static const char* plain_t = "plain"; //!< plain text static const char* json_t = "JSON"; //!< JSON format } /** * \file * Auxiliary program to print Jpp meta data. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; string inputFile; JLimit_t numberOfEvents; string application; string option; vector key; int debug; try { JParser<> zap("Auxiliary program to print Jpp meta data."); zap['f'] = make_field(inputFile); zap['n'] = make_field(numberOfEvents) = JLimit::max(); zap['A'] = make_field(application) = ""; zap['O'] = make_field(option) = plain_t, json_t; zap['k'] = make_field(key, "possible values: " << GITrelease_t << ", " << SVNrelease_t << ", " << ROOTrelease_t << ", " << namespace_t << ", " << command_t << ", " << system_t) = JPARSER::initialised(); zap['d'] = make_field(debug) = 1; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } if (application != "") { TFile* in = TFile::Open(inputFile.c_str(), "exists"); if (in != NULL && in->IsOpen()) { const TRegexp regexp(application.c_str()); TIter iter(in->GetListOfKeys()); for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) { const TString tag(key->GetName()); if (tag.Contains(regexp)) { TNamed* named = dynamic_cast(key->ReadObj()); if (named != NULL) { cout << named->GetName() << "[" << key->GetCycle() << "] " << named->GetTitle() << endl; } } } in->Close(); } else { ERROR("Error opening file: " << inputFile << endl); } } else { JMultipleFileScanner in(inputFile, numberOfEvents); JObjectMultiplexer abc(in); json js; while (abc.hasNext()) { JMeta* meta = abc.next(); if (option == plain_t) { if (key.empty()) { cout << (*meta) << endl; } else { for (const auto& i : key) { cout << ' ' << (*meta)[i]; } cout << endl; } } else if (option == json_t) { js += json(*meta); } } if (option == json_t) { cout << setw(4) << js << endl; } } }