Jpp  18.5.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JMultiHead.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 #include <cmath>
6 
7 #include "TROOT.h"
8 #include "TFile.h"
9 
13 
17 #include "JSupport/JSupport.hh"
18 #include "JSupport/JMeta.hh"
19 
20 #include "Jeep/JParser.hh"
21 #include "Jeep/JMessage.hh"
22 
23 
24 /**
25  * \file
26  *
27  * Example program to add MultiHead.
28  * \author mdejong
29  */
30 int main(int argc, char **argv)
31 {
32  using namespace std;
33  using namespace JPP;
34 
35  JMultipleFileScanner<Evt> inputFile;
37  JLimit_t& numberOfEvents = inputFile.getLimit();
38  int debug;
39 
40  try {
41 
42  JParser<> zap("Example program to add MultiHead.");
43 
44  zap['f'] = make_field(inputFile);
45  zap['n'] = make_field(numberOfEvents) = JLimit::max();
46  zap['o'] = make_field(outputFile);
47  zap['d'] = make_field(debug) = 2;
48 
49  zap(argc, argv);
50  }
51  catch(const exception& error) {
52  FATAL(error.what() << endl);
53  }
54 
55 
56  outputFile.open();
57 
58  outputFile.put(JMeta(argc, argv));
59 
60  Head header;
61 
62  try {
63 
64  header = getHeader(inputFile);
65 
66  MultiHead buffer;
67 
68  buffer.push_back(header);
69 
70  outputFile.put(header);
71  outputFile.put(buffer);
72 
73  } catch(const exception& error) {
74  FATAL("Missing header." << endl);
75  }
76 
77  while (inputFile.hasNext()) {
78 
79  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
80 
81  const Evt* evt = inputFile.next();
82 
83  outputFile.put(*evt);
84  }
85  STATUS(endl);
86 
87  outputFile.close();
88 }
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:70
Object writing to file.
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.
#define STATUS(A)
Definition: JMessage.hh:63
Recording of objects on file according a format that follows from the file name extension.
string outputFile
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
ROOT I/O of application specific meta data.
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.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:84
int debug
debug level
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:20
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62