Jpp  18.4.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JSplitEvt.cc File Reference

Application for splitting an offline file in two parts,
one containing all even-numbered events, another containing all odd-numbered events. More...

#include <uuid/uuid.h>
#include <iostream>
#include <iomanip>
#include "km3net-dataformat/offline/MultiHead.hh"
#include "km3net-dataformat/offline/Head.hh"
#include "km3net-dataformat/offline/Evt.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
#include "JSupport/JMeta.hh"
#include "JSupport/JLimit.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JFileRecorder.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JMonteCarloFileSupportkit.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Application for splitting an offline file in two parts,
one containing all even-numbered events, another containing all odd-numbered events.

Author
bjung

Definition in file JSplitEvt.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 29 of file JSplitEvt.cc.

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
bool is_gseagen(const JHead &header)
Check for generator.
Definition: JHeadToolkit.hh:61
#define STATUS(A)
Definition: JMessage.hh:63
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
Type list.
Definition: JTypeList.hh:22
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
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
General purpose class for object reading from a list of file names.
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:162
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