Jpp test-rotations-old
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"
19
20
21/**
22 * \file
23 *
24 * Auxiliaries for creation of summary data.
25 * \author mdejong
26 */
27namespace KM3NETDAQ {
28
33
34
35 /**
36 * Auxiliary class to create summary data.
37 */
39 public JDAQSummaryslice
40 {
41 /**
42 * Default constructor.
43 */
46
47
48 /**
49 * Constructor.
50 *
51 * This constructor blends multiple KM3NETDAQ::JDAQSummaryslice's from an incomplete detector to
52 * a single KM3NETDAQ::JDAQSummaryslice for a complete detector.
53 *
54 * \param chronometer DAQ chronometer
55 * \param input summary data
56 * \param detector detector
57 */
58 JSummaryslice(const JDAQChronometer& chronometer,
60 const JDetector& detector) :
61 JDAQSummaryslice(chronometer)
62 {
63 for (JDetector::const_iterator module = detector.begin(); module != detector.end() && input.hasNext(); ) {
64
65 const JDAQSummaryslice* summary = input.next();
66
67 for (const_iterator i = summary->begin(); i != summary->end() && module != detector.end(); ++i, ++module) {
68
69 push_back(*i);
70
71 rbegin()->setModuleIdentifier(module->getID());
72 }
73 }
74 }
75
76
77 /**
78 * Constructor.
79 *
80 * This constructor directly creates a KM3NETDAQ::JDAQSummaryslice for a given detector simulation
81 * without the need to create first a KM3NETDAQ::JDAQTimeslice.
82 *
83 * The high-rate veto of a given PMT is set to true when:
84 * - status of the PMT is not JPMTStatus::ON every time during the time slice; or
85 * - specified rate -corrected for the hit survival probability- exceeds KM3NETDAQ::HIGH_RATE_VETO_HZ.
86 *
87 * \param chronometer chronometer
88 * \param simbad detector simulator
89 */
90 JSummaryslice(const JDAQChronometer& chronometer,
91 const JDetectorSimulator& simbad) :
93 {
94 using namespace JPP;
95 using namespace KM3NETDAQ;
96
97 setDAQChronometer(chronometer);
98
99 try {
100
101 const JK40DefaultSimulatorInterface& k40Simulator = dynamic_cast<const JK40DefaultSimulatorInterface&>(simbad.getK40Simulator());
102 const JPMTDefaultSimulatorInterface& pmtSimulator = dynamic_cast<const JPMTDefaultSimulatorInterface&>(simbad.getPMTSimulator());
103 const JCLBDefaultSimulatorInterface& clbSimulator = dynamic_cast<const JCLBDefaultSimulatorInterface&>(simbad.getCLBSimulator());
104
105 for (JDetector::const_iterator module = simbad->begin(); module != simbad->end(); ++module) {
106
107 if (!module->empty()) {
108
109 push_back(JDAQSummaryFrame(module->getID()));
110
111 this->rbegin()->setDAQFrameStatus(clbSimulator.getDAQFrameStatus(module->getID()));
112
113 for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
114
115 const JPMTIdentifier id(module->getID(), pmt);
116
117 double rate_Hz = k40Simulator.getSinglesRate(id);
118
119 rate_Hz *= pmtSimulator.getPMTSignalProcessor(id).getSurvivalProbability(NPE);
120
121 if (rate_Hz > HIGH_RATE_VETO_HZ) {
122 this->rbegin()->setHighRateVeto(pmt, true);
123 }
124
125 // correct rate for UDP packet loss
126
127 const int n1 = clbSimulator.getUDPNumberOfReceivedPackets(module->getID());
128 const int n2 = clbSimulator.getUDPMaximalSequenceNumber (module->getID());
129
130 if (n1 < n2 + 1) {
131 rate_Hz *= (double) n1 / (double) (n2 + 1);
132 }
133
134 this->rbegin()->setRate(pmt, rate_Hz);
135 }
136 }
137 }
138 }
139 catch(const std::exception& error) {};
140 }
141
142
143 /**
144 * Correct measured singles rates for the probability that a hit survives the simulation of the PMT.
145 *
146 * \param simulator PMT simulator
147 */
149 {
150 using namespace JPP;
151 using namespace KM3NETDAQ;
152
153 for (iterator frame = this->begin(); frame != this->end(); ++frame) {
154
155 for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
156
157 const JPMTIdentifier id(frame->getModuleID(), pmt);
158
159 if (simulator.hasPMTSignalProcessor(id)) {
160
161 const double P = simulator.getPMTSignalProcessor(id).getSurvivalProbability(NPE);
162
163 if (P > 0.0)
164 (*frame)[pmt].div(P);
165 else
166 (*frame)[pmt].setValue(0.0);
167 }
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.
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.
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.