Jpp  18.2.1-ARCA-DF-PATCH
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 
12 #include "JSupport/JSupport.hh"
13 
14 #include "JROOT/JRootPrinter.hh"
16 
18 
19 #include "Jeep/JParser.hh"
20 #include "Jeep/JMessage.hh"
21 
22 
23 /**
24  * \file
25  * Auxiliary program to print sum of Monte Carlo run headers.
26  *
27  * \author mdejong
28  */
29 int main(int argc, char **argv)
30 {
31  using namespace std;
32  using namespace JPP;
33 
35  string key;
36  bool print_as_head;
37  bool print_as_json;
38  int debug;
39 
40  try {
41 
42  JParser<> zap("Auxiliary program to print sum of Monte Carlo run headers.");
43 
44  zap['f'] = make_field(inputFile);
45  zap['k'] = make_field(key) = "";
46  zap['H'] = make_field(print_as_head);
47  zap['J'] = make_field(print_as_json);
48  zap['d'] = make_field(debug) = 1;
49 
50  zap(argc, argv);
51  }
52  catch(const exception &error) {
53  FATAL(error.what() << endl);
54  }
55 
56  const JHead header = getHeader(inputFile);
57 
58  if (key == "") {
59 
60  Head buffer;
61 
62  copy(header, buffer);
63 
64  typedef JTYPELIST<Head, JHead>::typelist typelist;
65  typedef JObjectOutput<typelist>* output_type;
66 
67  output_type out = (print_as_json ?
68  (output_type) new JSonObjectOutput <typelist>(cout) :
69  (output_type) new JStreamObjectOutput<typelist>(cout));
70 
71  if (print_as_head)
72  out->put(buffer);
73  else
74  out->put(header);
75 
76  delete out;
77 
78  } else {
79 
81  }
82 }
83 
Utility class to parse command line options.
Definition: JParser.hh:1514
int main(int argc, char *argv[])
Definition: Main.cc:15
ROOT TTree parameter settings of various packages.
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:1989
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...
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