Jpp 19.3.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JPrintHeader.cc File Reference

Auxiliary program to print contents of summed Monte Carlo run headers. More...

#include <string>
#include <iostream>
#include <iomanip>
#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"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program to print contents of summed Monte Carlo run headers.

Author
mdejong

Definition in file JPrintHeader.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 38 of file JPrintHeader.cc.

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}
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
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.