Jpp  18.6.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
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

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  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 }
Utility class to parse command line options.
Definition: JParser.hh:1711
Vec getOffset(const JHead &header)
Get offset.
JCylinder3D getCylinder(const JHead &header)
Get cylinder corresponding to the positions of generated tracks (i.e.
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
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
Vec getOrigin(const JHead &header)
Get origin.
General purpose class for object reading from a list of file names.
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