#include #include #include #include "km3net-dataformat/offline/Head.hh" #include "JAAnet/JHead.hh" #include "JAAnet/JAAnetDictionary.hh" #include "JAAnet/JHeadToolkit.hh" #include "JSupport/JMultipleFileScanner.hh" #include "JSupport/JMonteCarloFileSupportkit.hh" #include "JSupport/JSupport.hh" #include "JROOT/JRootPrinter.hh" #include "JROOT/JSonObjectOutput.hh" #include "JLang/JStreamObjectOutput.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" namespace { const char* const offset_t = "offset"; const char* const origin_t = "origin"; const char* const cylinder_t = "cylinder"; } /** * \file * Auxiliary program to print contents of summed Monte Carlo run headers. * * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; JMultipleFileScanner inputFile; string key; bool print_as_head; bool print_as_json; bool common; int debug; try { JParser<> zap("Auxiliary program to print contents of summed Monte Carlo run headers."); zap['f'] = make_field(inputFile); zap['k'] = make_field(key, "optional key corresponds to a data member or any of the values "\ << offset_t << ", " << origin_t << ", " << cylinder_t << ".") = ""; zap['H'] = make_field(print_as_head); zap['J'] = make_field(print_as_json); zap['c'] = make_field(common); zap['d'] = make_field(debug) = 1; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } try { const JHead header = (common ? getCommonHeader(inputFile) : getHeader(inputFile)); if (key == "") { Head buffer; copy(header, buffer); typedef JTYPELIST::typelist typelist; typedef JObjectOutput* output_type; output_type out = (print_as_json ? (output_type) new JSonObjectOutput (cout) : (output_type) new JStreamObjectOutput(cout)); if (print_as_head) out->put(buffer); else out->put(header); delete out; } else { if (key == offset_t) cout << getOffset(header) << endl; else if (key == origin_t) cout << getOrigin(header) << endl; else if (key == cylinder_t) cout << getCylinder(header) << endl; else JRootPrinter::print(cout, header, key, JAAnetDictionary::getInstance()); } } catch (const exception& error) { FATAL(error.what() << endl); } }