Jpp test-rotations-old-533-g2bdbdb559
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 */
59 JSummaryslice(const JDAQChronometer& chronometer,
61 const JDetector& detector) :
62 JDAQSummaryslice(chronometer)
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 */
91 JSummaryslice(const JDAQChronometer& chronometer,
92 const JDetectorSimulator& simbad) :
94 {
95 using namespace JPP;
96 using namespace KM3NETDAQ;
97
98 setDAQChronometer(chronometer);
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()) {
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 rate_Hz *= pmtSimulator.getPMTSignalProcessor(id).getSurvivalProbability(NPE);
121
122 if (rate_Hz > HIGH_RATE_VETO_HZ) {
123 this->rbegin()->setHighRateVeto(pmt, true);
124 }
125
126 // correct rate for UDP packet loss
127
128 const int n1 = clbSimulator.getUDPNumberOfReceivedPackets(module->getID());
129 const int n2 = clbSimulator.getUDPMaximalSequenceNumber (module->getID());
130
131 if (n1 < n2 + 1) {
132 rate_Hz *= (double) n1 / (double) getBayesianMedian(n2 , n1, 0);
133 }
134
135 this->rbegin()->setRate(pmt, rate_Hz);
136 }
137 }
138 }
139 }
140 catch(const std::exception& error) {};
141 }
142
143
144 /**
145 * Correct measured singles rates for the probability that a hit survives the simulation of the PMT.
146 *
147 * \param simulator PMT simulator
148 */
150 {
151 using namespace JPP;
152 using namespace KM3NETDAQ;
153
154 for (iterator frame = this->begin(); frame != this->end(); ++frame) {
155
156 for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
157
158 const JPMTIdentifier id(frame->getModuleID(), pmt);
159
160 if (simulator.hasPMTSignalProcessor(id)) {
161
162 const double P = simulator.getPMTSignalProcessor(id).getSurvivalProbability(NPE);
163
164 if (P > 0.0)
165 (*frame)[pmt].div(P);
166 else
167 (*frame)[pmt].setValue(0.0);
168 }
169 }
170 }
171 }
172
173 static const int NPE = 1; //!< Number of photo-electrons corresponding to singles rate.
174 };
175}
176
177#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.
const JCLBSimulator & getCLBSimulator() const
Get CLB simulator.
const JK40Simulator & getK40Simulator() const
Get K40 simulator.
const JPMTSimulator & getPMTSimulator() const
Get PMT simulator.
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 bool hasPMTSignalProcessor(const JPMTIdentifier &pmt) const
Has PMT signal processor.
virtual const JPMTSignalProcessorInterface & getPMTSignalProcessor(const JPMTIdentifier &pmt) const
Get PMT signal processor.
virtual double getSurvivalProbability(const int NPE) const
Probability that a hit survives the simulation of the PMT.
Interface of object iteration for a single data type.
virtual bool hasNext()=0
Check availability of next element.
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.