Jpp  18.0.1-rc.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JDK.cc File Reference

Example program to filter out-of-time hits in Evt data. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <cmath>
#include "km3net-dataformat/offline/Head.hh"
#include "km3net-dataformat/offline/MultiHead.hh"
#include "km3net-dataformat/offline/Evt.hh"
#include "km3net-dataformat/online/JDAQClock.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JFileRecorder.hh"
#include "JSupport/JMonteCarloFileSupportkit.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JMeta.hh"
#include "JAAnet/JAAnetToolkit.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

Example program to filter out-of-time hits in Evt data.

Author
mdejong

Definition in file JDK.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 30 of file JDK.cc.

31 {
32  using namespace std;
33  using namespace JPP;
34  using namespace KM3NETDAQ;
35 
36  JMultipleFileScanner<Evt> inputFile;
38  JLimit_t& numberOfEvents = inputFile.getLimit();
39  double T_ns;
40  int debug;
41 
42  try {
43 
44  JParser<> zap("Example program to filter out-of-time hits in Evt data.");
45 
46  zap['f'] = make_field(inputFile);
47  zap['o'] = make_field(outputFile);
48  zap['n'] = make_field(numberOfEvents) = JLimit::max();
49  zap['T'] = make_field(T_ns) = getFrameTime();
50  zap['d'] = make_field(debug) = 2;
51 
52  zap(argc, argv);
53  }
54  catch(const exception& error) {
55  FATAL(error.what() << endl);
56  }
57 
58  outputFile.open();
59 
60  if (!outputFile.is_open()) {
61  FATAL("Error opening file " << outputFile << endl);
62  }
63 
64  outputFile.put(JMeta(argc, argv));
65  outputFile.put(getHeader(inputFile));
66 
67  while (inputFile.hasNext()) {
68 
69  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
70 
71  Evt* evt = inputFile.next();
72 
73  double t0 = numeric_limits<double>::max();
74 
75  for (vector<Hit>::iterator hit = evt->mc_hits.begin(); hit != evt->mc_hits.end(); ++hit) {
76  if (getTime(*hit) < t0) {
77  t0 = getTime(*hit);
78  }
79  }
80 
81  vector<Hit>::iterator __end = evt->mc_hits.end();
82 
83  for (vector<Hit>::iterator hit = evt->mc_hits.begin(); hit != __end; ) {
84  if (getTime(*hit) <= t0 + T_ns)
85  ++hit;
86  else
87  iter_swap(hit, --__end);
88  }
89 
90  evt->mc_hits.erase(__end, evt->mc_hits.end());
91 
92  outputFile.put(*evt);
93  }
94  STATUS(endl);
95 
97 
98  io >> outputFile;
99 
100  outputFile.close();
101 }
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:70
Object writing to file.
Utility class to parse command line options.
Definition: JParser.hh:1514
#define STATUS(A)
Definition: JMessage.hh:63
double getTime(const Hit &hit)
Get true time of hit.
string outputFile
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
double getFrameTime()
Get frame time duration.
Definition: JDAQClock.hh:162
#define FATAL(A)
Definition: JMessage.hh:67
General purpose class for object reading from a list of file names.
std::vector< Hit > mc_hits
MC: list of MC truth hits.
Definition: Evt.hh:48
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:84
int debug
debug level
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:20
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62