Jpp  18.0.0-rc.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JSummaryFileRouter.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <iomanip>
4 #include <limits>
5 #include <map>
6 
7 #include "JDAQ/JDAQEventIO.hh"
9 
12 #include "JSupport/JSupport.hh"
13 
14 #include "JTools/JQuantile.hh"
15 
16 #include "Jeep/JParser.hh"
17 #include "Jeep/JMessage.hh"
18 
19 
20 /**
21  * \file
22  *
23  * Program to test JSUPPORT::JSummaryFileRouter.
24  * \author mdejong
25  */
26 int main(int argc, char **argv)
27 {
28  using namespace std;
29  using namespace JPP;
30  using namespace KM3NETDAQ;
31 
33  JLimit_t& numberOfEvents = inputFile.getLimit();
34  double rate_Hz;
35  int debug;
36 
37  try {
38 
39  JParser<> zap("Program to test router of summary data.");
40 
41  zap['f'] = make_field(inputFile);
42  zap['n'] = make_field(numberOfEvents) = JLimit::max();
43  zap['B'] = make_field(rate_Hz) = 0.0;
44  zap['d'] = make_field(debug) = 2;
45 
46  zap(argc, argv);
47  }
48  catch(const exception& error) {
49  FATAL(error.what() << endl);
50  }
51 
52  JSummaryFileRouter router(inputFile.getFilename(), rate_Hz);
53 
55 
56  while (inputFile.hasNext()) {
57 
58  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
59 
60  JDAQEvent* event = inputFile.next();
61 
62  router.update(*event);
63 
64  for (JDAQEvent::const_iterator<JDAQSnapshotHit> hit = event->begin<JDAQSnapshotHit>(); hit != event->end<JDAQSnapshotHit>(); ++hit) {
65 
66  const JDAQPMTIdentifier id(hit->getModuleID(), hit->getPMT());
67 
68  const double R = router.getRate(id);
69 
70  zmap[id].put(R);
71  }
72  }
73 
74  for (map<JDAQPMTIdentifier, JQuantile>::const_iterator i = zmap.begin(); i != zmap.end(); ++i) {
75  cout << setw(10) << i->first.getModuleID() << '.'
76  << FILL(2,'0') << i->first.getPMTAddress() << FILL() << ' '
77  << FIXED(9,2) << i->second.getMean();
78  if (i->second.getCount() > 2) {
79  cout << " +/- "
80  << FIXED(9,2) << i->second.getSTDev();
81  }
82  cout << endl;
83  }
84 }
Utility class to parse command line options.
Definition: JParser.hh:1514
DAQ key hit.
Definition: JDAQKeyHit.hh:19
int main(int argc, char *argv[])
Definition: Main.cc:15
ROOT TTree parameter settings of various packages.
#define STATUS(A)
Definition: JMessage.hh:63
Template const_iterator.
Definition: JDAQEvent.hh:68
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
Scanning of objects from a single file according a format that follows from the extension of each fil...
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
File router for fast addressing of summary data.
General purpose messaging.
Auxiliary data structure for sequence of same character.
Definition: JManip.hh:328
#define FATAL(A)
Definition: JMessage.hh:67
then JCookie sh JDataQuality D $DETECTOR_ID R
Definition: JDataQuality.sh:41
Utility class to parse command line options.
Object reading from a list of files.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:84
int debug
debug level
JTriggerCounter_t next()
Increment trigger counter.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62