Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JPrintHeader.cc
Go to the documentation of this file.
1#include <string>
2#include <iostream>
3#include <iomanip>
4
6
7#include "JAAnet/JHead.hh"
8#include "JAAnet/JAAnetDictionary.hh"
10
13#include "JSupport/JSupport.hh"
14
15#include "JROOT/JRootPrinter.hh"
17
19
20#include "Jeep/JParser.hh"
21#include "Jeep/JMessage.hh"
22
23
24namespace {
25
26 const char* const offset_t = "offset";
27 const char* const origin_t = "origin";
28 const char* const cylinder_t = "cylinder";
29}
30
31
32/**
33 * \file
34 * Auxiliary program to print contents of summed Monte Carlo run headers.
35 *
36 * \author mdejong
37 */
38int main(int argc, char **argv)
39{
40 using namespace std;
41 using namespace JPP;
42
44 string key;
45 bool print_as_head;
46 bool print_as_json;
47 bool common;
48 int debug;
49
50 try {
51
52 JParser<> zap("Auxiliary program to print contents of summed Monte Carlo run headers.");
53
54 zap['f'] = make_field(inputFile);
55 zap['k'] = make_field(key,
56 "optional key corresponds to a data member or any of the values "\
57 << offset_t << ", "
58 << origin_t << ", "
59 << cylinder_t << ".") = "";
60 zap['H'] = make_field(print_as_head);
61 zap['J'] = make_field(print_as_json);
62 zap['c'] = make_field(common);
63 zap['d'] = make_field(debug) = 1;
64
65 zap(argc, argv);
66 }
67 catch(const exception &error) {
68 FATAL(error.what() << endl);
69 }
70
71 try {
72
73 const JHead header = (common ? getCommonHeader(inputFile) : getHeader(inputFile));
74
75 if (key == "") {
76
77 Head buffer;
78
79 copy(header, buffer);
80
81 typedef JTYPELIST<Head, JHead>::typelist typelist;
82 typedef JObjectOutput<typelist>* output_type;
83
84 output_type out = (print_as_json ?
85 (output_type) new JSonObjectOutput <typelist>(cout) :
86 (output_type) new JStreamObjectOutput<typelist>(cout));
87
88 if (print_as_head)
89 out->put(buffer);
90 else
91 out->put(header);
92
93 delete out;
94
95 } else {
96
97 if (key == offset_t)
98 cout << getOffset(header) << endl;
99 else if (key == origin_t)
100 cout << getOrigin(header) << endl;
101 else if (key == cylinder_t)
102 cout << getCylinder(header) << endl;
103 else
104 JRootPrinter::print(cout, header, key, JAAnetDictionary::getInstance());
105 }
106 }
107 catch (const exception& error) {
108 FATAL(error.what() << endl);
109 }
110}
111
General purpose messaging.
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
int main(int argc, char **argv)
Print objects in ASCII format using ROOT dictionary.
ROOT TTree parameter settings of various packages.
Monte Carlo run header.
Definition JHead.hh:1236
Template interface of object output for single data type.
virtual bool put(const T &object)=0
Object output.
Template implementation of stream output for single data type.
Utility class to parse command line options.
Definition JParser.hh:1698
General purpose class for object reading from a list of file names.
Vec getOrigin(const JHead &header)
Get origin.
JCylinder3D getCylinder(const JHead &header)
Get cylinder corresponding to the positions of generated tracks (i.e.
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition JHead.cc:163
Vec getOffset(const JHead &header)
Get offset.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Head getCommonHeader(const JMultipleFileScanner_t &file_list)
Get common Monte Carlo header.
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
Definition Head.hh:65
Type list.
Definition JTypeList.hh:23
static void print(JRootWriter &writer, const JRootWritableClass &cls)
Write class contents to output.