Jpp  test_elongated_shower_pde
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JDK.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 #include <cmath>
6 
10 
14 #include "JSupport/JSupport.hh"
15 #include "JSupport/JMeta.hh"
16 
17 #include "JAAnet/JAAnetToolkit.hh"
18 
19 #include "Jeep/JParser.hh"
20 #include "Jeep/JMessage.hh"
21 
22 
23 /**
24  * \file
25  *
26  * Example program to filter out-of-time hits in Evt data.
27  * \author mdejong
28  */
29 int main(int argc, char **argv)
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
int main(int argc, char *argv[])
Definition: Main.cc:15
ROOT TTree parameter settings of various packages.
#define STATUS(A)
Definition: JMessage.hh:63
Recording of objects on file according a format that follows from the file name extension.
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
ROOT I/O of application specific meta data.
Definition of hit and track types and auxiliary methods for handling Monte Carlo data.
int debug
debug level
Definition: JSirene.cc:68
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Scanning of objects from multiple files according a format that follows from the extension of each fi...
General purpose class for object reading from a list of file names.
Utility class to parse command line options.
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