Jpp 20.0.0-72-g597b30bc9
the software that should make you happy
Loading...
Searching...
No Matches
JDAQSummaryslice.cc
Go to the documentation of this file.
1
2#include <string>
3#include <iostream>
4#include <iomanip>
5#include <limits>
6
7#include "TROOT.h"
8#include "TFile.h"
9#include "TH1D.h"
10#include "TH2D.h"
11#include "TProfile.h"
12
16
18#include "JSupport/JSupport.hh"
19
20#include "Jeep/JParser.hh"
21#include "Jeep/JMessage.hh"
22
23
24/**
25 * \file
26 *
27 * Example program to histogram KM3NETDAQ::JDAQSummaryslice.
28 * \author mdejong
29 */
30int main(int argc, char **argv)
31{
32 using namespace std;
33 using namespace JPP;
34 using namespace KM3NETDAQ;
35
37 JLimit_t& numberOfEvents = inputFile.getLimit();
38 string outputFile;
39 bool correct;
40 int debug;
41
42 try {
43
44 JParser<> zap("Example program to histogram summary data.");
45
46 zap['f'] = make_field(inputFile);
47 zap['o'] = make_field(outputFile) = "summaryslice.root";
48 zap['n'] = make_field(numberOfEvents) = JLimit::max();
49 zap['c'] = make_field(correct);
50 zap['d'] = make_field(debug) = 2;
51
52 zap(argc, argv);
53 }
54 catch(const exception& error) {
55 FATAL(error.what() << endl);
56 }
57
58
59 const double factor = 1.0e-3; // [kHz]
60
61
62 TFile out(outputFile.c_str(), "recreate");
63
64 TH1D h0("h0", NULL, JDAQRate::getN(), JDAQRate::getData(factor));
65 TH1D hb("hb", NULL, JDAQRate::getN(), JDAQRate::getData(factor));
66
67 TProfile h1("h1", NULL, 32,-0.5, 31.5);
68 TProfile h2("h2", NULL, 32,-0.5, 31.5);
69
70 TH2D hu("hu", NULL, 201, -0.5, +200.5, 201, -0.5, +200.5);
71
72 TH2D hv("hv", NULL, 51, -0.5, +50.5, 200, 0.0, 50.0);
73 TH2D hw("hw", NULL, 51, -0.5, +50.5, 200, 0.0, 50.0);
74
75 TH2D hx("hx", NULL, NUMBER_OF_PMTS, -0.5, NUMBER_OF_PMTS - 0.5, 200, 0.0, 50.0);
76 TH2D hy("hy", NULL, NUMBER_OF_PMTS, -0.5, NUMBER_OF_PMTS - 0.5, 200, 0.0, 50.0);
77
78 size_t udp[] = { 0, 0, 0, 0 };
79
80 while (inputFile.hasNext()) {
81
82 STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
83
84 JDAQSummaryslice* summaryslice = inputFile.next();
85
86 DEBUG("Summary: "
87 << setw(8) << inputFile.getCounter() << ' '
88 << setw(8) << summaryslice->getRunNumber() << ' '
89 << setw(8) << summaryslice->getFrameIndex() << ' '
90 << setw(6) << summaryslice->size() << endl);
91
92 const JDetectorAddressMap& demo = getDetectorAddressMap(summaryslice->getDetectorID());
93
94 for (JDAQSummaryslice::const_iterator frame = summaryslice->begin(); frame != summaryslice->end(); ++frame) {
95
96 const JModuleAddressMap& memo = demo.get(frame->getModuleID());
97
98 int N[2] = { 0 };
99 double R[2] = { 0.0 };
100
101 int lower[2] = { 0 };
102 int upper[2] = { 0 };
103
104 for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
105
106 const int index = (!frame->testHighRateVeto(pmt) && !frame->testFIFOStatus(pmt) ? 0 : 1);
107
108 N[index] += 1;
109 R[index] += correct ? getRate(*frame, pmt, factor) : frame->getRate(pmt, factor);
110
111 if (memo.getAddressTranslator(pmt).ring <= 'D')
112 lower[index] += 1;
113 else
114 upper[index] += 1;
115
116 h0.Fill(correct ? getRate(*frame, pmt, factor) : frame->getRate(pmt, factor), frame->getWeight(pmt, factor));
117
118 if (!frame->testHighRateVeto(pmt) && !frame->testFIFOStatus(pmt)) {
119 hb.Fill(correct ? getRate(*frame, pmt, factor) : frame->getRate(pmt, factor), frame->getWeight(pmt, factor));
120 }
121
122 h1.Fill((Double_t) pmt, (frame->testHighRateVeto(pmt) ? 1.0 : 0.0));
123 h2.Fill((Double_t) pmt, (frame->testFIFOStatus (pmt) ? 1.0 : 0.0));
124 }
125
126 hu.Fill((double) frame->getUDPMaximalSequenceNumber(),
127 (double) frame->getUDPNumberOfReceivedPackets());
128
129 if (N[0] != 0) { hv.Fill((double) frame->getUDPMaximalSequenceNumber(), R[0] / N[0]); }
130 if (N[1] != 0) { hw.Fill((double) frame->getUDPMaximalSequenceNumber(), R[1] / N[1]); }
131
132 if (N[0] != 0) {
133
134 hx.Fill((double) N[1], R[0] / N[0]);
135
136 if (lower[0] != 0 && upper[0] != 0) {
137 hy.Fill((double) N[1], R[0] / N[0]);
138 }
139 }
140
141 const bool status = (frame->getUDPNumberOfReceivedPackets() == frame->getUDPMaximalSequenceNumber() + 1 &&
142 frame->hasUDPTrailer());
143
144 udp[0] += 1;
145 udp[1] += (status ? 1 : 0);
146 udp[2] += max(frame->getUDPMaximalSequenceNumber() + 1,
147 frame->getUDPNumberOfReceivedPackets());
148 udp[3] += frame->getUDPNumberOfReceivedPackets();
149
150 h1.Fill((Double_t) 31, (frame->testWhiteRabbitStatus() ? 1.0 : 0.0));
151 h2.Fill((Double_t) 31, (status ? 1.0 : 0.0));
152 }
153 }
154 STATUS(endl);
155
156 if (debug >= notice_t) {
157
158 for (int i = 0; i != sizeof(udp)/sizeof(udp[0]); ++i) {
159 cout << "UDP[" << i << "] = " << setw(12) << udp[i] << endl;
160 }
161
162 cout << "Estimated packet loss probability " << SCIENTIFIC(12,3) << (double) (udp[2] - udp[3]) / (double) (udp[2]) << endl;
163 cout << "Estimated packet loss probability (worst-case-scenario) " << SCIENTIFIC(12,3) << (double) (udp[0] - udp[1]) / (double) (udp[3]) << endl;
164 }
165
166 out.Write();
167 out.Close();
168}
int main(int argc, char **argv)
string outputFile
Detector support kit.
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
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
ROOT TTree parameter settings of various packages.
Lookup table for PMT addresses in detector.
const JModuleAddressMap & get(const int id) const
Get module address map.
Lookup table for PMT addresses in optical module.
const JPMTAddressTranslator & getAddressTranslator(const int tdc) const
Get PMT address translator.
Utility class to parse command line options.
Definition JParser.hh:1698
General purpose class for object reading from a list of file names.
virtual bool hasNext() override
Check availability of next element.
counter_type getCounter() const
Get counter.
virtual const pointer_type & next() override
Get next element.
int getDetectorID() const
Get detector identifier.
int getRunNumber() const
Get run number.
int getFrameIndex() const
Get frame index.
static int getN()
Get number of bins.
static const double * getData(const double factor=1.0)
Get abscissa values.
JDetectorAddressMap & getDetectorAddressMap()
Get detector address map.
@ notice_t
notice
Definition JMessage.hh:32
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
double getRate(const JDAQSummaryFrame &frame, const int pmt, const double factor=1.0)
Get corrected rate of PMT.
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
Auxiliary data structure for floating point format specification.
Definition JManip.hh:488