Jpp  19.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JSummaryslice.hh
Go to the documentation of this file.
1 #ifndef __JSUMMARYSLICE__JSUMMARYSLICE__
2 #define __JSUMMARYSLICE__JSUMMARYSLICE__
3 
4 #include <exception>
5 
10 
11 #include "JLang/JObjectIterator.hh"
12 #include "JDetector/JDetector.hh"
18 #include "JDAQ/JHighRateVeto.hh"
19 
20 
21 /**
22  * \file
23  *
24  * Auxiliaries for creation of summary data.
25  * \author mdejong
26  */
27 namespace KM3NETDAQ {
28 
33 
34 
35  /**
36  * Auxiliary class to create summary data.
37  */
38  struct JSummaryslice :
39  public JDAQSummaryslice
40  {
41  /**
42  * Default constructor.
43  */
45  {}
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  */
148  void correct(const JPMTDefaultSimulatorInterface& simulator)
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  const double P = simulator.getPMTSignalProcessor(id).getSurvivalProbability(NPE);
160 
161  if (P > 0.0)
162  (*frame)[pmt].div(P);
163  else
164  (*frame)[pmt].setValue(0.0);
165  }
166  }
167  }
168 
169  static const int NPE = 1; //!< Number of photo-electrons corresponding to singles rate.
170  };
171 }
172 
173 #endif
JSummaryslice()
Default constructor.
virtual int getUDPNumberOfReceivedPackets(const JModuleIdentifier &id) const
Get number of received UDP packets.
JSummaryslice(const JDAQChronometer &chronometer, const JDetectorSimulator &simbad)
Constructor.
Detector data structure.
Definition: JDetector.hh:89
Interface of object iteration for a single data type.
const JPMTSimulator & getPMTSimulator() const
Get PMT simulator.
Data structure for detector geometry and calibration.
JSummaryslice(const JDAQChronometer &chronometer, JObjectIterator< JDAQSummaryslice > &input, const JDetector &detector)
Constructor.
virtual double getSurvivalProbability(const int NPE) const
Probability that a hit survives the simulation of the PMT.
virtual const pointer_type & next()=0
Get next element.
Detector file.
Definition: JHead.hh:226
virtual const JPMTSignalProcessorInterface & getPMTSignalProcessor(const JPMTIdentifier &pmt) const
Get PMT signal processor.
Data storage class for rate measurements of all PMTs in one module.
virtual double getSinglesRate(const JPMTIdentifier &pmt) const =0
Get singles rate as a function of PMT.
static const int NPE
Number of photo-electrons corresponding to singles rate.
Auxiliary class to create summary data.
virtual bool hasNext()=0
Check availability of next element.
const JCLBSimulator & getCLBSimulator() const
Get CLB simulator.
void setDAQChronometer(const JDAQChronometer &chronometer)
Set DAQ chronometer.
virtual int getUDPMaximalSequenceNumber(const JModuleIdentifier &id) const
Get maximal sequence number of UDP packet.
JDAQFrameStatus getDAQFrameStatus(const JModuleIdentifier &id) const
Get DAQ frame status of given module.
static double HIGH_RATE_VETO_HZ
High-rate veto [kHz].
KM3NeT DAQ constants, bit handling, etc.
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition: JDAQ.hh:26
void correct(const JPMTDefaultSimulatorInterface &simulator)
Correct measured singles rates for the probability that a hit survives the simulation of the PMT...
const JK40Simulator & getK40Simulator() const
Get K40 simulator.
then $DIR JPlotNPE PDG P
Definition: JPlotNPE-PDG.sh:62