#include #include #include #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" /** * \file * Application for splitting an offline file in two parts,\n * one containing all even-numbered events, another containing all odd-numbered events * * \author bjung */ int main(int argc, char **argv) { using namespace std; using namespace JPP; using namespace KM3NETDAQ; typedef JTYPELIST::typelist typelist; JMultipleFileScanner inputFile; pair, JFileRecorder > outputFiles; int debug; try { JParser<> zap; zap['f'] = make_field(inputFile); zap['o'] = make_field(outputFiles) = make_pair(JFileRecorder("part1.root"), JFileRecorder("part2.root")); zap['d'] = make_field(debug) = 1; zap(argc, argv); } catch(const exception& error) { FATAL(error.what() << endl); } outputFiles.first.open(); outputFiles.second.open(); outputFiles.first.put(JMeta(argc, argv)); outputFiles.second.put(JMeta(argc, argv)); while (inputFile.hasNext()) { STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl); const Evt* event = inputFile.next(); if (inputFile.getCounter() & 1) { // Separate even and odd events outputFiles.first.put(*event); } else { outputFiles.second.put(*event); } } JHead header = getHeader(inputFile); header.UUID.clear(); header.createUUID(); if (is_gseagen(header) || is_corsika(header)) { header.genvol.numberOfEvents /= 2; } Head head; copy(header, head); outputFiles.first.put(head); outputFiles.second.put(head); JMultipleFileScanner::typelist> io(inputFile); io >> outputFiles.first; io >> outputFiles.second; outputFiles.first.close(); outputFiles.second.close(); return 0; }