Jpp 20.0.0-195-g190c9e876
the software that should make you happy
Loading...
Searching...
No Matches
JDAQPrint.cc
Go to the documentation of this file.
1#include <string>
2#include <iostream>
3#include <iomanip>
4
5#include "JDAQ/JDAQEventIO.hh"
9
13
14#include "JSupport/JSupport.hh"
18
19#include "Jeep/JParser.hh"
20#include "Jeep/JMessage.hh"
21
22/**
23 * \file
24 *
25 * Example program to print DAQ events with associated information.
26 *
27 * \author mdejong
28 */
29int main(int argc, char **argv)
30{
31 using namespace std;
32 using namespace JPP;
33 using namespace KM3NETDAQ;
34
35 JSingleFileScanner<> inputFile;
36 JLimit_t& numberOfEvents = inputFile.getLimit();
37 string detectorFile;
38 int debug;
39
40 try {
41
42 JParser<> zap("Example program to print DAQ events with associated information.");
43
44 zap['f'] = make_field(inputFile);
45 zap['a'] = make_field(detectorFile) = "";
46 zap['n'] = make_field(numberOfEvents) = JLimit::max();
47 zap['d'] = make_field(debug) = 1;
48
49 zap(argc, argv);
50 }
51 catch(const exception& error) {
52 FATAL(error.what() << endl);
53 }
54
55
57
58 if (detectorFile != "") {
59
60 try {
61 load(detectorFile, detector);
62 }
63 catch(const JException& error) {
64 FATAL(error);
65 }
66 }
67
68 const JModuleRouter router(detector);
69
70
71 JSummaryFileRouter summary(inputFile);
72
73 for (JTreeScanner<JDAQEvent, JDAQEvaluator> in(inputFile, inputFile.getLimit()); in.hasNext(); ) {
74
75 const JDAQEvent* tev = in.next();
76
77 summary.update(*tev);
78
79 cout << "TTree counter " << in.getCounter() << endl;
80 cout << "Detector identifier " << tev->getDetectorID() << endl;
81 cout << "Run number " << tev->getRunNumber() << endl;
82 cout << "Frame index " << tev->getFrameIndex() << endl;
83 cout << "UTC " << tev->getTimesliceStart() << endl;
84 cout << "Trigger counter " << tev->getCounter() << endl;
85 cout << "Trigger mask (hex) " << hex << tev->getTriggerMask() << dec << endl;
86 cout << "Overlays " << tev->getOverlays() << endl;
87 cout << "Triggered hits " << tev->size<JDAQTriggeredHit>() << endl;
88 cout << "Snapshot hits " << tev->size<JDAQSnapshotHit> () << endl;
89 cout << endl;
90
91 cout << " module PMT TDC ToT trigger rate [kHz] status location serial x y z dx dy dz t0 status t1" << endl;
92 {
94
95 for (JDAQEvent::const_iterator<JHit_t> hit = tev->begin<JHit_t>(); hit != tev->end<JHit_t>(); ++hit) {
96
97 cout << setw(8) << hit->getModuleID() << ' '
98 << setw(2) << (int) hit->getPMT() << ' '
99 << setw(10) << (int) hit->getT() << ' '
100 << setw(3) << (int) hit->getToT() << ' '
101 << setw(10) << hex << hit->getTriggerMask() << dec;
102
103 if (summary.hasSummaryFrame(hit->getModuleID()))
104 cout << ' ' << FIXED(9,2) << summary.getRate(JDAQPMTIdentifier(hit->getModuleID(), hit->getPMT())) * 1.0e-3 << setw(6) << ' '
105 << summary.getSummaryFrame(hit->getModuleID()).testHighRateVeto(hit->getPMT())
106 << summary.getSummaryFrame(hit->getModuleID()).testFIFOStatus (hit->getPMT());
107 else
108 cout << ' ' << setw(9) << " ? " << ' '
109 << " ";
110
111 if (router.hasModule(hit->getModuleID())) {
112
113 const JModule& module = router.getModule(hit->getModuleID());
114 const JPMT& PMT = module.getPMT(hit->getPMT());
115
116 cout << setw(2) << ' ';
117 cout << ' ' << getLabel(module.getLocation());
118 cout << ' ' << PMT;
119 cout << setw(6) << ' ';
120 cout << ' ' << FIXED(10,1) << getTime(hit->getT(), PMT.getCalibration());
121 }
122
123 cout << endl;
124 }
125 }
126 cout << endl;
127
128 if (debug >= debug_t) {
129
130 typedef JDAQSnapshotHit JHit_t;
131
132 for (JDAQEvent::const_iterator<JHit_t> hit = tev->begin<JHit_t>(); hit != tev->end<JHit_t>(); ++hit) {
133
134 cout << setw(8) << hit->getModuleID() << ' '
135 << setw(2) << (int) hit->getPMT() << ' '
136 << setw(10) << (int) hit->getT() << ' '
137 << setw(3) << (int) hit->getToT() << ' '
138 << setw(10) << '_';
139
140 if (summary.hasSummaryFrame(hit->getModuleID()))
141 cout << ' ' << FIXED(9,2) << summary.getRate(JDAQPMTIdentifier(hit->getModuleID(), hit->getPMT())) * 1.0e-3 << setw(6) << ' '
142 << summary.getSummaryFrame(hit->getModuleID()).testHighRateVeto(hit->getPMT())
143 << summary.getSummaryFrame(hit->getModuleID()).testFIFOStatus (hit->getPMT());
144 else
145 cout << ' ' << setw(9) << " ? " << ' '
146 << " ";
147
148 if (router.hasModule(hit->getModuleID())) {
149
150 const JModule& module = router.getModule(hit->getModuleID());
151 const JPMT& PMT = module.getPMT(hit->getPMT());
152
153 cout << setw(2) << ' ' ;
154 cout << ' ' << getLabel(module.getLocation());
155 cout << ' ' << PMT;
156 cout << setw(6) << ' ';
157 cout << ' ' << FIXED(10,1) << getTime(hit->getT(), PMT.getCalibration());
158 }
159
160 cout << endl;
161 }
162 }
163 cout << endl;
164 }
165}
int main(int argc, char **argv)
Definition JDAQPrint.cc:29
JDAQPMTIdentifier PMT
Command line options.
Data structure for detector geometry and calibration.
General purpose messaging.
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:74
Direct access to module in detector data structure.
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...
ROOT TTree parameter settings of various packages.
Detector data structure.
Definition JDetector.hh:96
const JLocation & getLocation() const
Get location.
Definition JLocation.hh:70
Router for direct addressing of module data in detector data structure.
bool hasModule(const JObjectID &id) const
Has module.
const JModule & getModule(const JObjectID &id) const
Get module parameters.
Data structure for a composite optical module.
Definition JModule.hh:76
Data structure for PMT geometry, calibration and status.
Definition JPMT.hh:49
General exception.
Definition JException.hh:24
Utility class to parse command line options.
Definition JParser.hh:1698
File router for fast addressing of summary data.
void update(const JDAQHeader &header)
Update router.
bool hasSummaryFrame(const JDAQModuleIdentifier &module) const
Has summary frame.
double getRate(const JDAQPMTIdentifier &id) const
Get rate.
const JDAQSummaryFrame & getSummaryFrame(const JDAQModuleIdentifier &module) const
Get summary frame.
Template definition for direct access of elements in ROOT TChain.
int getDetectorID() const
Get detector identifier.
int getRunNumber() const
Get run number.
JDAQUTCExtended getTimesliceStart() const
Get start of timeslice.
int getFrameIndex() const
Get frame index.
unsigned int getOverlays() const
Get number of overlays.
Template const_iterator.
Definition JDAQEvent.hh:68
static JTriggerMask_t getTriggerMask(const JDAQTriggeredHit &hit)
Get trigger mask of given hit.
Definition JDAQEvent.hh:226
const_iterator< T > end() const
Get end of data.
unsigned int size() const
Get number of hits.
const_iterator< T > begin() const
Get begin of data.
bool testFIFOStatus() const
Test FIFO status.
bool testHighRateVeto() const
Test high-rate veto status.
JTriggerCounter_t getCounter() const
Get trigger counter.
JTriggerCounter_t next()
Increment trigger counter.
std::string getLabel(const JLocation &location)
Get module label for monitoring and other applications.
Definition JLocation.hh:247
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
@ debug_t
debug
Definition JMessage.hh:29
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
const char * getTime()
Get current local time conform ISO-8601 standard.
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
Auxiliary data structure for floating point format specification.
Definition JManip.hh:448
Detector file.
Definition JHead.hh:227
Auxiliary class to set-up Hit.
Definition JSirene.hh:60
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