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