Jpp  18.6.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JDAQEvaluator.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 #include <vector>
6 #include <algorithm>
7 #include <iterator>
8 
12 
13 #include "JDAQ/JDAQEventIO.hh"
14 #include "JDAQ/JDAQTimesliceIO.hh"
16 #include "JDAQ/JDAQEvaluator.hh"
18 
19 #include "JSupport/JTreeScanner.hh"
20 #include "JSupport/JSupport.hh"
21 
22 #include "Jeep/JParser.hh"
23 #include "Jeep/JMessage.hh"
24 
25 
26 /**
27  * \file
28  *
29  * Program to print DAQ value used for sorting entries in ROOT TTree.
30  * \author mdejong
31  */
32 int main(int argc, char **argv)
33 {
34  using namespace std;
35  using namespace JPP;
36  using namespace KM3NETDAQ;
37 
38  std::string inputFile;
39  JLimit numberOfEvents;
40  bool option;
41  int debug;
42 
43  try {
44 
45  JParser<> zap("Program to print DAQ value used for sorting entries in ROOT TTree.");
46 
47  zap['f'] = make_field(inputFile);
48  zap['n'] = make_field(numberOfEvents) = JLimit();
49  zap['O'] = make_field(option);
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 
60 
61  JTreeScanner<JDAQEvent, JDAQEvaluator> in(inputFile, numberOfEvents);
62 
63  double v0 = numeric_limits<double>::lowest();
64  JDAQEventHeader h0;
65 
66  while (in.hasNext()) {
67 
68  const JDAQEvent* tev = in.next();
69 
70  DEBUG(*tev);
71 
72  const double v1 = getDAQValue(*tev);
73 
74  cout << "event "
75  << setw(8) << in.getCounter() << ' '
76  << setw(6) << tev->getFrameIndex() << ' '
77  << setw(6) << tev->getCounter() << ' '
78  << FIXED(20,10) << v1 << ' ';
79 
80  if (v0 != numeric_limits<double>::lowest()) {
81  cout << SCIENTIFIC(20,10) << (v1 - v0) << ' ';
82  }
83 
84  cout << endl;
85 
86  if (option) {
87 
88  if (v0 != numeric_limits<double>::lowest()) {
89  ASSERT(tev->getDetectorID() == h0.getDetectorID());
90  ASSERT(tev->getRunNumber() == h0.getRunNumber());
91  ASSERT((tev->getFrameIndex() > h0.getFrameIndex()) ||
92  (tev->getFrameIndex() == h0.getFrameIndex() && tev->getCounter() > h0.getCounter()));
93  }
94  }
95 
96  v0 = v1;
97  h0 = tev->getDAQEventHeader();
98  }
99 }
Utility class to parse command line options.
Definition: JParser.hh:1711
static const JDAQEvaluator getDAQValue
Function object for evaluation of DAQ objects.
int main(int argc, char *argv[])
Definition: Main.cc:15
ROOT TTree parameter settings of various packages.
int getDetectorID() const
Get detector identifier.
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
int getRunNumber() const
Get run number.
Template definition for direct access of elements in ROOT TChain.
int getFrameIndex() const
Get frame index.
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
#define ASSERT(A,...)
Assert macro.
Definition: JMessage.hh:90
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2158
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
then fatal The output file must have the wildcard in the e g root fi eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:48
Utility class to parse command line options.
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:486
const JDAQEventHeader & getDAQEventHeader() const
Get DAQ event header.
JTriggerCounter_t getCounter() const
Get trigger counter.
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62