Jpp
JAAnetPreprocessor.cc
Go to the documentation of this file.
1 #include "evt/Head.hh"
2 #include "evt/Evt.hh"
3 
8 #include "JSupport/JSupport.hh"
9 
10 #include "Jeep/JParser.hh"
11 #include "Jeep/JMessage.hh"
12 
13 #include "JSupport/JMeta.hh"
14 
15 
16 /**
17  * \file
18  * Auxiliary program to preprocess an aanet file.\n
19  * Currently it provide support for the suppression of empty events from a file, but implementation of other options is encouraged.
20  * \author mlincetto
21  */
22 
23 int main(int argc, char **argv)
24 {
25  using namespace std;
26  using namespace JPP;
27 
28  JMultipleFileScanner<JAAnetTypes_t> inputFile;
29  JFileRecorder <JAAnetTypes_t> outputFile;
30  JLimit_t& numberOfEvents = inputFile.getLimit();
31  int debug;
32  bool filterEmptyMCH;
33  double timeOffset_ms;
34 
35  try {
36 
37  JParser<> zap("Auxiliary program to preprocess aanet files.");
38 
39  zap['f'] = make_field(inputFile);
40  zap['o'] = make_field(outputFile);
41  zap['n'] = make_field(numberOfEvents) = JLimit::max();
42  zap['d'] = make_field(debug) = 1;
43  zap['H'] = make_field(filterEmptyMCH, "Filter events without hits.");
44  zap['T'] = make_field(timeOffset_ms, "Add time offset [ms] to events.") = 0;
45 
46  zap(argc, argv);
47  }
48  catch(const exception& error) {
49  FATAL(error.what() << endl);
50  }
51 
52  outputFile.open();
53 
54  // put header
55  Head header = inputFile.getHeader();
56 
57  JMultipleFileScanner<Evt> in = inputFile;
58 
59  outputFile.put(header);
60 
61  while (in.hasNext()) {
62 
63  Evt* cur = in.next();
64 
65  if (filterEmptyMCH and cur->mc_hits.empty()) { continue; }
66 
67  if (timeOffset_ms != 0) { add_time_offset (*cur, 1.0e6 * timeOffset_ms); }
68 
69  outputFile.put(*cur);
70 
71  } // while
72 
73  outputFile.close();
74 }
JMeta.hh
JFileRecorder.hh
JMessage.hh
JSUPPORT::JLimit_t
JLimit JLimit_t
Type definition of limit.
Definition: JLimit.hh:215
JPARSER::JParser
Utility class to parse command line options.
Definition: JParser.hh:1493
JSupport.hh
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
debug
int debug
debug level
Definition: JSirene.cc:59
JSUPPORT::JLimit::getLimit
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
JAAnetToolkit.hh
JMultipleFileScanner.hh
JParser.hh
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
std
Definition: jaanetDictionary.h:36
JMonteCarloFileSupportkit.hh
JAANET::add_time_offset
void add_time_offset(Evt &evt, const double tOff)
Add time offset to mc event; according to current definition, the absolute time of the event is defin...
Definition: JAAnetToolkit.hh:653
FATAL
#define FATAL(A)
Definition: JMessage.hh:67
outputFile
string outputFile
Definition: JDAQTimesliceSelector.cc:37
main
int main(int argc, char **argv)
Definition: JAAnetPreprocessor.cc:23