Jpp  18.2.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JSplitEvt.cc
Go to the documentation of this file.
1 #include <uuid/uuid.h>
2 #include <iostream>
3 #include <iomanip>
4 
8 
9 #include "Jeep/JPrint.hh"
10 #include "Jeep/JParser.hh"
11 #include "Jeep/JMessage.hh"
12 
13 #include "JSupport/JMeta.hh"
14 #include "JSupport/JLimit.hh"
15 #include "JSupport/JSupport.hh"
19 
20 
21 /**
22  * \file
23  * Application for splitting an offline file in two parts,\n
24  * one containing all even-numbered events, another containing all odd-numbered events
25  *
26  * \author bjung
27  */
28 
29 int main(int argc, char **argv)
30 {
31  using namespace std;
32  using namespace JPP;
33  using namespace KM3NETDAQ;
34 
36 
37 
38  JMultipleFileScanner<Evt> inputFile;
40  JFileRecorder<typelist> > outputFiles;
41 
42  int debug;
43 
44  try {
45 
46  JParser<> zap;
47 
48  zap['f'] = make_field(inputFile);
49  zap['o'] = make_field(outputFiles) = make_pair(JFileRecorder<typelist>("part1.root"),
50  JFileRecorder<typelist>("part2.root"));
51  zap['d'] = make_field(debug) = 1;
52 
53  zap(argc, argv);
54  }
55  catch(const exception& error) {
56  FATAL(error.what() << endl);
57  }
58 
59 
60  outputFiles.first.open();
61  outputFiles.second.open();
62 
63  outputFiles.first.put(JMeta(argc, argv));
64  outputFiles.second.put(JMeta(argc, argv));
65 
66  while (inputFile.hasNext()) {
67 
68  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
69 
70  const Evt* event = inputFile.next();
71 
72  if (inputFile.getCounter() & 1) { // Separate even and odd events
73  outputFiles.first.put(*event);
74  } else {
75  outputFiles.second.put(*event);
76  }
77  }
78 
79  JHead header = getHeader(inputFile);
80  header.UUID.clear();
81  header.createUUID();
82 
83  if (is_gseagen(header) || is_corsika(header)) {
84  header.genvol.numberOfEvents /= 2;
85  }
86 
87  Head head;
88  copy(header, head);
89 
90  outputFiles.first.put(head);
91  outputFiles.second.put(head);
92 
94 
95  io >> outputFiles.first;
96  io >> outputFiles.second;
97 
98  outputFiles.first.close();
99  outputFiles.second.close();
100 
101  return 0;
102 }
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.
bool is_gseagen(const JHead &header)
Check for generator.
Definition: JHeadToolkit.hh:61
#define STATUS(A)
Definition: JMessage.hh:63
Recording of objects on file according a format that follows from the file name extension.
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
Type list.
Definition: JTypeList.hh:22
I/O formatting auxiliaries.
bool is_corsika(const JHead &header)
Check for generator.
Monte Carlo run header.
Definition: JHead.hh:1234
#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.
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:162
Auxiliaries for defining the range of iterations of objects.
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