Jpp  16.0.0-rc.1
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/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 29 of file JDK.cc.

30 {
31  using namespace std;
32  using namespace JPP;
33  using namespace KM3NETDAQ;
34 
35  JMultipleFileScanner<Evt> inputFile;
37  JLimit_t& numberOfEvents = inputFile.getLimit();
38  double T_ns;
39  int debug;
40 
41  try {
42 
43  JParser<> zap("Example program to filter out-of-time hits in Evt data.");
44 
45  zap['f'] = make_field(inputFile);
46  zap['o'] = make_field(outputFile);
47  zap['n'] = make_field(numberOfEvents) = JLimit::max();
48  zap['T'] = make_field(T_ns) = getFrameTime();
49  zap['d'] = make_field(debug) = 2;
50 
51  zap(argc, argv);
52  }
53  catch(const exception& error) {
54  FATAL(error.what() << endl);
55  }
56 
57  outputFile.open();
58 
59  if (!outputFile.is_open()) {
60  FATAL("Error opening file " << outputFile << endl);
61  }
62 
63  outputFile.put(JMeta(argc, argv));
64  outputFile.put(getHeader(inputFile));
65 
66  while (inputFile.hasNext()) {
67 
68  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
69 
70  Evt* evt = inputFile.next();
71 
72  double t0 = numeric_limits<double>::max();
73 
74  for (vector<Hit>::iterator hit = evt->mc_hits.begin(); hit != evt->mc_hits.end(); ++hit) {
75  if (getTime(*hit) < t0) {
76  t0 = getTime(*hit);
77  }
78  }
79 
80  vector<Hit>::iterator __end = evt->mc_hits.end();
81 
82  for (vector<Hit>::iterator hit = evt->mc_hits.begin(); hit != __end; ) {
83  if (getTime(*hit) <= t0 + T_ns)
84  ++hit;
85  else
86  iter_swap(hit, --__end);
87  }
88 
89  evt->mc_hits.erase(__end, evt->mc_hits.end());
90 
91  outputFile.put(*evt);
92  }
93  STATUS(endl);
94 
95  outputFile.close();
96 }
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:1500
#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:1961
double getFrameTime()
Get frame time duration.
Definition: JDAQClock.hh:162
int debug
debug level
Definition: JSirene.cc:63
#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:45
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:19