Jpp  17.2.1-pre0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JPrintDAQHeader.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 
6 #include "JDAQ/JDAQHeaderIO.hh"
8 #include "JDAQ/JDAQEventIO.hh"
12 #include "JSupport/JSupport.hh"
13 #include "JROOT/JRootFileReader.hh"
14 
15 #include "Jeep/JPrint.hh"
16 #include "Jeep/JParser.hh"
17 #include "Jeep/JMessage.hh"
18 
19 /**
20  * \file
21  *
22  * Auxiliary program to print DAQ header data.
23  * \author mdejong
24  */
25 int main(int argc, char **argv)
26 {
27  using namespace std;
28  using namespace JPP;
29  using namespace KM3NETDAQ;
30 
32  counter_type numberOfEvents;
33  int debug;
34 
35  try {
36 
37  JParser<> zap("Auxiliary program to print DAQ header data.");
38 
39  zap['f'] = make_field(inputFile, "input file.");
40  zap['n'] = make_field(numberOfEvents) = 1;
41  zap['d'] = make_field(debug, "debug flag.") = 1;
42 
43  zap(argc, argv);
44  }
45  catch(const exception &error) {
46  FATAL(error.what() << endl);
47  }
48 
49 
50  JDAQHeader header;
51  int numberOfErrors = 0;
52  counter_type counter = 0;
53 
54  for (JObjectMultiplexer<JDAQTypes_t, JDAQHeader> in(inputFile); in.hasNext() && counter != numberOfEvents; ++counter) {
55 
56  const JDAQHeader* p = in.next();
57 
58  if (counter == 0)
59  header = *p;
60  else if (header.getDetectorID() != p->getDetectorID() ||
61  header.getRunNumber () != p->getRunNumber ())
62  ++numberOfErrors;
63  }
64 
65  for (JMultipleFileScanner_t::const_iterator i = inputFile.begin(); i != inputFile.end(); ++i) {
66 
67  for (JRootFileReader<JDAQHeader> in(i->c_str()); in.hasNext() && counter != numberOfEvents; ++counter) {
68 
69  const JDAQHeader* p = in.next();
70 
71  if (counter == 0)
72  header = *p;
73  else if (header.getDetectorID() != p->getDetectorID() ||
74  header.getRunNumber () != p->getRunNumber ())
75  ++numberOfErrors;
76  }
77  }
78 
79  if (numberOfErrors != 0) {
80  FATAL("Number of errors/counts " << numberOfErrors << "/" << counter << endl);
81  }
82 
83  if (counter != 0)
84  cout << header << endl;
85  else
86  FATAL("No header.");
87 
88  return 0;
89 }
Utility class to parse command line options.
Definition: JParser.hh:1517
int main(int argc, char *argv[])
Definition: Main.cc:15
ROOT TTree parameter settings of various packages.
int getDetectorID() const
Get detector identifier.
Long64_t counter_type
Type definition for counter.
Auxiliary class for multiplexing object iterators.
int getRunNumber() const
Get run number.
I/O formatting auxiliaries.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1993
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.
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] 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:46
ROOT file reader.
int debug
debug level