Jpp  18.3.0-209-g56ce19a
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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"
9 #include "JAAnet/JHeadToolkit.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 
24 namespace {
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  */
38 int 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  int debug;
48 
49  try {
50 
51  JParser<> zap("Auxiliary program to print contents of summed Monte Carlo run headers.");
52 
53  zap['f'] = make_field(inputFile);
54  zap['k'] = make_field(key,
55  "optional key corresponds to a data member or any of the values "\
56  << offset_t << ", "
57  << origin_t << ", "
58  << cylinder_t << ".") = "";
59  zap['H'] = make_field(print_as_head);
60  zap['J'] = make_field(print_as_json);
61  zap['d'] = make_field(debug) = 1;
62 
63  zap(argc, argv);
64  }
65  catch(const exception &error) {
66  FATAL(error.what() << endl);
67  }
68 
69  const JHead header = getHeader(inputFile);
70 
71  if (key == "") {
72 
73  Head buffer;
74 
75  copy(header, buffer);
76 
77  typedef JTYPELIST<Head, JHead>::typelist typelist;
78  typedef JObjectOutput<typelist>* output_type;
79 
80  output_type out = (print_as_json ?
81  (output_type) new JSonObjectOutput <typelist>(cout) :
82  (output_type) new JStreamObjectOutput<typelist>(cout));
83 
84  if (print_as_head)
85  out->put(buffer);
86  else
87  out->put(header);
88 
89  delete out;
90 
91  } else {
92 
93  if (key == offset_t)
94  cout << getOffset(header) << endl;
95  else if (key == origin_t)
96  cout << getOrigin(header) << endl;
97  else if (key == cylinder_t)
98  cout << getCylinder(header) << endl;
99  else
101  }
102 }
103 
Utility class to parse command line options.
Definition: JParser.hh:1711
int main(int argc, char *argv[])
Definition: Main.cc:15
ROOT TTree parameter settings of various packages.
Vec getOffset(const JHead &header)
Get offset.
JCylinder3D getCylinder(const JHead &header)
Get cylinder corresponding to the positions of generated tracks (i.e.
Print objects in ASCII format using ROOT dictionary.
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
Type list.
Definition: JTypeList.hh:22
Monte Carlo run header.
Definition: JHead.hh:1234
T & getInstance(const T &object)
Get static instance from temporary object.
Definition: JObject.hh:75
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2158
Template implementation of stream output for single data type.
print
Definition: JConvertDusj.sh:44
General purpose messaging.
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
Definition: Head.hh:65
#define FATAL(A)
Definition: JMessage.hh:67
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Vec getOrigin(const JHead &header)
Get origin.
General purpose class for object reading from a list of file names.
Utility class to parse command line options.
Template implementation of stream output for single data type.
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:162
Template interface of object output for single data type.
virtual bool put(const T &object)=0
Object output.
int debug
debug level