Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
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 */
26int 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());
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, rate_Hz);
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}
General purpose messaging.
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define STATUS(A)
Definition JMessage.hh:63
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Scanning of objects from a single file according a format that follows from the extension of each fil...
int main(int argc, char **argv)
ROOT TTree parameter settings of various packages.
Utility class to parse command line options.
Definition JParser.hh:1698
Object reading from a list of files.
virtual bool hasNext() override
Check availability of next element.
counter_type getCounter() const
Get counter.
virtual const pointer_type & next() override
Get next element.
File router for fast addressing of summary data.
void update(const JDAQHeader &header)
Update router.
double getRate(const JDAQPMTIdentifier &id, const double rate_Hz) const
Get rate.
Template const_iterator.
Definition JDAQEvent.hh:68
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
Auxiliary data structure for sequence of same character.
Definition JManip.hh:330
Auxiliary data structure for floating point format specification.
Definition JManip.hh:448
Auxiliary class for defining the range of iterations of objects.
Definition JLimit.hh:45
static counter_type max()
Get maximum counter value.
Definition JLimit.hh:128