Jpp 20.0.0-27-g39925593c-D
the software that should make you happy
Loading...
Searching...
No Matches
JSummaryslice.hh
Go to the documentation of this file.
1#ifndef __JSUMMARYSLICE__JSUMMARYSLICE__
2#define __JSUMMARYSLICE__JSUMMARYSLICE__
3
4#include <exception>
5
10
18#include "JDAQ/JHighRateVeto.hh"
20
21
22/**
23 * \file
24 *
25 * Auxiliaries for creation of summary data.
26 * \author mdejong
27 */
28namespace KM3NETDAQ {
29
34
35
36 /**
37 * Auxiliary class to create summary data.
38 */
40 public JDAQSummaryslice
41 {
42 /**
43 * Default constructor.
44 */
47
48
49 /**
50 * Constructor.
51 *
52 * This constructor blends multiple KM3NETDAQ::JDAQSummaryslice's from an incomplete detector to
53 * a single KM3NETDAQ::JDAQSummaryslice for a complete detector.
54 *
55 * \param chronometer DAQ chronometer
56 * \param input summary data
57 * \param detector detector
58 */
61 const JDetector& detector) :
63 {
64 for (JDetector::const_iterator module = detector.begin(); module != detector.end() && input.hasNext(); ) {
65
66 const JDAQSummaryslice* summary = input.next();
67
68 for (const_iterator i = summary->begin(); i != summary->end() && module != detector.end(); ++i, ++module) {
69
70 push_back(*i);
71
72 rbegin()->setModuleIdentifier(module->getID());
73 }
74 }
75 }
76
77
78 /**
79 * Constructor.
80 *
81 * This constructor directly creates a KM3NETDAQ::JDAQSummaryslice for a given detector simulation
82 * without the need to create first a KM3NETDAQ::JDAQTimeslice.
83 *
84 * The high-rate veto of a given PMT is set to true when:
85 * - status of the PMT is not JPMTStatus::ON every time during the time slice; or
86 * - specified rate -corrected for the hit survival probability- exceeds KM3NETDAQ::HIGH_RATE_VETO_HZ.
87 *
88 * \param chronometer chronometer
89 * \param simbad detector simulator
90 */
94 {
95 using namespace JPP;
96 using namespace KM3NETDAQ;
97
99
100 try {
101
102 const JK40DefaultSimulatorInterface& k40Simulator = dynamic_cast<const JK40DefaultSimulatorInterface&>(simbad.getK40Simulator());
103 const JPMTDefaultSimulatorInterface& pmtSimulator = dynamic_cast<const JPMTDefaultSimulatorInterface&>(simbad.getPMTSimulator());
104 const JCLBDefaultSimulatorInterface& clbSimulator = dynamic_cast<const JCLBDefaultSimulatorInterface&>(simbad.getCLBSimulator());
105
106 for (JDetector::const_iterator module = simbad->begin(); module != simbad->end(); ++module) {
107
108 if (!module->empty() && clbSimulator.hasCLB(module->getID())) {
109
110 push_back(JDAQSummaryFrame(module->getID()));
111
112 this->rbegin()->setDAQFrameStatus(clbSimulator.getDAQFrameStatus(module->getID()));
113
114 for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
115
116 const JPMTIdentifier id(module->getID(), pmt);
117
118 double rate_Hz = k40Simulator.getSinglesRate(id);
119
120 // uncorrect rate for PMT survival probability
121
122 rate_Hz *= pmtSimulator.getPMTSignalProcessor(id).getSurvivalProbability(NPE, false);
123
124 // uncorrect rate for UDP packet loss
125
126 const int n1 = clbSimulator.getUDPNumberOfReceivedPackets(module->getID());
127 const int n2 = clbSimulator.getUDPMaximalSequenceNumber (module->getID());
128
129 if (n1 < n2 + 1) {
130 rate_Hz *= (double) n1 / (double) getBayesianMedian(n2 , n1, 0);
131 }
132
133 this->rbegin()->setRate(pmt, rate_Hz);
134
135 if (clbSimulator.setHighRateVeto() && rate_Hz > HIGH_RATE_VETO_HZ) {
136 this->rbegin()->setHighRateVeto(pmt, true);
137 }
138 }
139 }
140 }
141 }
142 catch(const std::exception& error) {};
143 }
144
145
146 /**
147 * Correct measured singles rates for the probability that a hit survives the simulation of the PMT.
148 *
149 * \param simulator PMT simulator
150 */
152 {
153 using namespace JPP;
154 using namespace KM3NETDAQ;
155
156 for (iterator frame = this->begin(); frame != this->end(); ++frame) {
157
158 for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
159
160 const JPMTIdentifier id(frame->getModuleID(), pmt);
161
162 const double P = simulator.getPMTSignalProcessor(id).getSurvivalProbability(NPE, false);
163
164 if (P > 0.0)
165 (*frame)[pmt].div(P);
166 else
167 (*frame)[pmt].setValue(0.0);
168 }
169 }
170 }
171
172 static const int NPE = 1; //!< Number of photo-electrons corresponding to singles rate.
173 };
174}
175
176#endif
KM3NeT DAQ constants, bit handling, etc.
Data structure for detector geometry and calibration.
Auxiliary methods for mathematics.
JDAQFrameStatus getDAQFrameStatus(const JModuleIdentifier &id) const
Get DAQ frame status of given module.
virtual int getUDPMaximalSequenceNumber(const JModuleIdentifier &id) const
Get maximal sequence number of UDP packet.
virtual int getUDPNumberOfReceivedPackets(const JModuleIdentifier &id) const
Get number of received UDP packets.
virtual bool setHighRateVeto() const
Set high-rate veto based on number of hits.
virtual bool hasCLB(const JModuleIdentifier &id) const
Check if CLB exist.
Detector data structure.
Definition JDetector.hh:96
virtual double getSinglesRate(const JPMTIdentifier &pmt) const =0
Get singles rate as a function of PMT.
virtual const JPMTSignalProcessorInterface & getPMTSignalProcessor(const JPMTIdentifier &pmt) const
Get PMT signal processor.
Interface of object iteration for a single data type.
Template definition of a multi-dimensional oscillation probability interpolation table.
void setDAQChronometer(const JDAQChronometer &chronometer)
Set DAQ chronometer.
Data storage class for rate measurements of all PMTs in one module.
size_t getBayesianMedian(const size_t m, const size_t k)
Get estimate of maximum number.
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
static double HIGH_RATE_VETO_HZ
High-rate veto [kHz].
Detector file.
Definition JHead.hh:227
Auxiliary class to create summary data.
JSummaryslice(const JDAQChronometer &chronometer, JObjectIterator< JDAQSummaryslice > &input, const JDetector &detector)
Constructor.
void correct(const JPMTDefaultSimulatorInterface &simulator)
Correct measured singles rates for the probability that a hit survives the simulation of the PMT.
JSummaryslice()
Default constructor.
JSummaryslice(const JDAQChronometer &chronometer, const JDetectorSimulator &simbad)
Constructor.
static const int NPE
Number of photo-electrons corresponding to singles rate.