Jpp  19.1.0
the software that should make you happy
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

◆ main()

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 }
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
#define STATUS(A)
Definition: JMessage.hh:63
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2142
Monte Carlo run header.
Definition: JHead.hh:1236
void createUUID()
Create UUID if not already set.
Definition: JHead.hh:1301
JAANET::genvol genvol
Definition: JHead.hh:1600
JUUID UUID
Definition: JHead.hh:1584
Utility class to parse command line options.
Definition: JParser.hh:1698
Object writing to file.
virtual bool hasNext() override
Check availability of next element.
counter_type getCounter() const
Get counter.
virtual const pointer_type & next() override
Get next element.
bool is_corsika(const JHead &header)
Check for generator.
bool is_gseagen(const JHead &header)
Check for generator.
Definition: JHeadToolkit.hh:61
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:162
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
KM3NeT DAQ data structures and auxiliaries.
Definition: DataQueue.cc:39
Definition: JSTDTypes.hh:14
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:21
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
Definition: Head.hh:65
double numberOfEvents
Number of events.
Definition: JHead.hh:721
Type list.
Definition: JTypeList.hh:23
void clear()
Clear UUID.
Definition: JUUID.hh:100
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:72