Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
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
29int main(int argc, char **argv)
30{
31 using namespace std;
32 using namespace JPP;
33 using namespace KM3NETDAQ;
34
36
37
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}
Recording of objects on file according a format that follows from the file name extension.
Auxiliaries for defining the range of iterations of objects.
General purpose messaging.
#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:72
ROOT I/O of application specific meta data.
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
I/O formatting auxiliaries.
int main(int argc, char **argv)
Definition JSplitEvt.cc:29
ROOT TTree parameter settings of various packages.
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
Utility class to parse command line options.
Definition JParser.hh:1698
Object writing to file.
General purpose class for object reading from a list of file names.
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.
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition JHead.cc:163
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
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