Jpp 20.0.0-27-g39925593c-D
the software that should make you happy
Loading...
Searching...
No Matches
Functions
JCompareSummaryslice.cc File Reference

Auxiliary program to compare summary data. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "TH2D.h"
#include "JDAQ/JDAQSummarysliceIO.hh"
#include "JSupport/JSummaryFileRouter.hh"
#include "JSupport/JSingleFileScanner.hh"
#include "JSupport/JSupportToolkit.hh"
#include "JSupport/JSupport.hh"
#include "JDetector/JPMTIdentifier.hh"
#include "JTools/JRange.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program to compare summary data.

Author
mdejong

Definition in file JCompareSummaryslice.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 98 of file JCompareSummaryslice.cc.

99{
100 using namespace std;
101 using namespace JPP;
102 using namespace KM3NETDAQ;
103
104 pair<string, string> inputFile;
105 string outputFile;
106 JLimit_t numberOfEvents;
108 int debug;
109
110 try {
111
112 JParser<> zap("Auxiliary program to compare summary data.");
113
114 zap['f'] = make_field(inputFile, "pair of input files");
115 zap['o'] = make_field(outputFile, "output file") = "summary.root";
116 zap['n'] = make_field(numberOfEvents) = JLimit::max();
117 zap['R'] = make_field(rate_kHz, "accepted range [kHz]") = JRange<double>(-0.1, +0.1);
118 zap['d'] = make_field(debug, "debug") = 0;
119
120 zap(argc, argv);
121 }
122 catch(const exception &error) {
123 FATAL(error.what() << endl);
124 }
125
126 JSummaryFileRouter router(inputFile.second);
127
128 TFile out(outputFile.c_str(), "recreate");
129
130 TH1D h0("h0", NULL, 200, -2.0, +2.0);
132 TH2D h2("h2", NULL, 2, -0.5, +1.5, 2, -0.5, +1.5);
133 TH2D h3("h3", NULL, 2, -0.5, +1.5, 2, -0.5, +1.5);
134 TH2D h4("h4", NULL, 100, 0.0, 100.0, 100, 0.0, 100.0);
135 TH2D h5("h5", NULL, 100, 0.0, 100.0, 100, 0.0, 100.0);
136 TH2D h6("h6", NULL, 2, -0.5, +1.5, 2, -0.5, +1.5);
137
138 TH2D ha("ha", NULL, JDAQRate::getN(), JDAQRate::getData(factor), 200, -10.0, +10.0);
139 TH2D hb("hb", NULL, JDAQRate::getN(), JDAQRate::getData(factor), 513, -256.5, +256.5);
140
141 size_t counts = 0;
142 size_t misses = 0;
143
144 struct {
147 } module;
148
149 struct {
153 } PMT;
154
155
156 for (JSingleFileScanner<JDAQSummaryslice> in(inputFile.first, numberOfEvents); in.hasNext(); ) {
157
158 STATUS("event: " << setw(10) << in.getCounter() << '\r'); DEBUG(endl);
159
160 const JDAQSummaryslice* const p = in.next();
161
162 router.update(*p);
163
164 counts += 1;
165
166 DEBUG("frame index: " << setw(6) << p->getFrameIndex() << ' ' << p->getTimesliceStart() << " / " << setw(6) << router.getFrameIndex() << ' ' << router.getTimesliceStart() << endl);
167
168 if (p->getFrameIndex() == router.getFrameIndex()) {
169
170 for (JDAQSummaryslice::const_iterator i = p->begin(); i != p->end(); ++i) {
171
172 const JDAQSummaryFrame& f1 = *i;
173
174 module.counts[f1.getModuleID()] += 1;
175
176 if (router.hasSummaryFrame(f1.getModuleID())) {
177
178 const JDAQSummaryFrame& f2 = router.getSummaryFrame(f1.getModuleID());
179
180 for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
181
182 const JPMTIdentifier id(f1.getModuleID(), pmt);
183
184 if (debug >= debug_t || !rate_kHz(f2.getRate(pmt, factor) - f1.getRate(pmt, factor))) {
185 cout << "PMT " << id << ' ' << printer(*i,pmt) << " -> " << printer(f2,pmt) << endl;
186 }
187
188 PMT.counts[id] += 1;
189
190 if ((f2.testHighRateVeto(pmt) != f1.testHighRateVeto(pmt)) ||
191 (f2.testFIFOStatus (pmt) != f1.testFIFOStatus (pmt))) {
192 PMT.misses[id] += 1;
193 }
194
195 if (!rate_kHz(f2.getRate(pmt, factor) - f1.getRate(pmt, factor))) {
196 PMT.errors[id] += 1;
197 }
198
199 ha.Fill(f1.getRate(pmt, factor), f1.getRate(pmt, factor) - f2.getRate(pmt, factor));
200 hb.Fill(f1.getRate(pmt, factor), (int) f1.getValue(pmt) - (int) f2.getValue(pmt));
201 h0.Fill(f1.getRate (pmt, factor) - f2.getRate (pmt, factor));
202 h1.Fill(f1.getRate (pmt, factor), f2.getRate (pmt, factor));
203 h2.Fill(f1.testHighRateVeto(pmt), f2.testHighRateVeto(pmt));
204 h3.Fill(f1.testFIFOStatus (pmt), f2.testFIFOStatus (pmt));
205 }
206
209 h6.Fill(f1.hasUDPTrailer(), f2.hasUDPTrailer());
210
211 } else {
212
213 module.misses[f1.getModuleID()] += 1;
214 }
215 }
216 } else {
217
218 misses += 1;
219 }
220 }
221 STATUS(endl);
222
223 cout << "Number of slice misses "<< setw(6) << misses << '/' << setw(6) << counts << endl;
224
225 for (const auto& i : module.misses) {
226 cout << "Number of module misses " << setw(8) << i.first << ' ' << setw(6) << i.second << '/' << setw(6) << module.counts[i.first] << endl;
227 }
228
229 for (const auto& i : PMT.misses) {
230 cout << "Number of PMT misses " << i.first << ' ' << setw(6) << i.second << '/' << setw(6) << PMT.counts[i.first] << endl;
231 }
232
233 for (const auto& i : PMT.errors) {
234 cout << "Number of PMT errors " << i.first << ' ' << setw(6) << i.second << '/' << setw(6) << PMT.counts[i.first] << endl;
235 }
236
237 out.Write();
238 out.Close();
239}
JDAQPMTIdentifier PMT
Command line options.
string outputFile
#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
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Template definition of a multi-dimensional oscillation probability interpolation table.
File router for fast addressing of summary data.
JDAQUTCExtended getTimesliceStart() const
Get start of timeslice.
int getFrameIndex() const
Get frame index.
bool testFIFOStatus() const
Test FIFO status.
int getUDPNumberOfReceivedPackets() const
Get number of received UDP packets.
bool hasUDPTrailer() const
Get UDP trailer status.
bool testHighRateVeto() const
Test high-rate veto status.
int getUDPMaximalSequenceNumber() const
Get maximal sequence number of UDP packet.
int getModuleID() const
Get module identifier.
static int getN()
Get number of bins.
static const double * getData(const double factor=1.0)
Get abscissa values.
Data storage class for rate measurements of all PMTs in one module.
double getRate(const int tdc, const double factor=1.0) const
Get count rate.
JRate_t getValue(const int tdc) const
Get value.
@ debug_t
debug
Definition JMessage.hh:29
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition JDAQ.hh:26
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