Jpp  master_rocky-37-gf0c5bc59d
the software that should make you happy
Functions
JGizmo/JEvt.cc File Reference

Auxiliary program for time sorting of Monte-Carlo events. More...

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include "km3net-dataformat/offline/Head.hh"
#include "km3net-dataformat/offline/MultiHead.hh"
#include "km3net-dataformat/offline/Evt.hh"
#include "JSupport/JMeta.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JFileRecorder.hh"
#include "JSupport/JSingleFileScanner.hh"
#include "JSupport/JMonteCarloFileSupportkit.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program for time sorting of Monte-Carlo events.

Author
mdejong

Definition in file JGizmo/JEvt.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 52 of file JGizmo/JEvt.cc.

53 {
54  using namespace std;
55  using namespace JPP;
56 
57  typedef typename JTYPELIST<Head, MultiHead, Evt, JMeta>::typelist typelist;
58 
59  string inputFile;
60  JLimit_t numberOfEvents;
62  int debug;
63 
64  try {
65 
66  JParser<> zap("Auxiliary program for time sorting of Monte-Carlo events.");
67 
68  zap['f'] = make_field(inputFile);
69  zap['n'] = make_field(numberOfEvents) = JLimit::max();
70  zap['o'] = make_field(outputFile);
71  zap['d'] = make_field(debug) = 1;
72 
73  zap(argc, argv);
74  }
75  catch(const exception& error) {
76  FATAL(error.what() << endl);
77  }
78 
79 
80  STATUS("Processing " << inputFile << "." << flush);
81 
82  vector<Evt> buffer;
83 
84  for (JSingleFileScanner<Evt> in(inputFile, numberOfEvents); in.hasNext(); ) {
85  buffer.push_back(*in.next());
86  }
87 
88  STATUS("." << flush);
89 
90  sort(buffer.begin(), buffer.end(), compare);
91 
92  STATUS("OK" << endl);
93 
94  outputFile.open();
95 
96  outputFile.put(JMeta(argc, argv));
97 
98  for (vector<Evt>::const_iterator i = buffer.begin(); i != buffer.end(); ++i) {
99  outputFile.put(*i);
100  }
101 
103 
104  io >> outputFile;
105 
106  outputFile.close();
107 }
string outputFile
#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
Utility class to parse command line options.
Definition: JParser.hh:1698
Object writing to file.
Object reading from a list of files.
virtual bool hasNext() override
Check availability of next element.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JSTDTypes.hh:14
Type list.
Definition: JTypeList.hh:23
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:45
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:72