Jpp
 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  push_back(JDAQSummaryFrame(module->getID()));
106 
107  this->rbegin()->setDAQFrameStatus(clbSimulator.getDAQFrameStatus(module->getID()));
108 
109  for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
110 
111  const JPMTIdentifier id(module->getID(), pmt);
112 
113  double rate_Hz = k40Simulator.getSinglesRate(id);
114 
115  rate_Hz *= pmtSimulator.getPMTSignalProcessor(id).getSurvivalProbability(NPE);
116 
117  if (rate_Hz > HIGH_RATE_VETO_HZ) {
118  this->rbegin()->setHighRateVeto(pmt, true);
119  }
120 
121  // correct rate for UDP packet loss
122 
123  const int n1 = clbSimulator.getUDPNumberOfReceivedPackets(module->getID());
124  const int n2 = clbSimulator.getUDPMaximalSequenceNumber (module->getID());
125 
126  if (n1 < n2 + 1) {
127  rate_Hz *= (double) n1 / (double) (n2 + 1);
128  }
129 
130  this->rbegin()->setRate(pmt, rate_Hz);
131  }
132  }
133  }
134  catch(const std::exception& error) {};
135  }
136 
137 
138  /**
139  * Correct measured singles rates for the probability that a hit survives the simulation of the PMT.
140  *
141  * \param simulator PMT simulator
142  */
143  void correct(const JPMTDefaultSimulatorInterface& simulator)
144  {
145  using namespace JPP;
146  using namespace KM3NETDAQ;
147 
148  for (iterator frame = this->begin(); frame != this->end(); ++frame) {
149 
150  for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
151 
152  const JPMTIdentifier id(frame->getModuleID(), pmt);
153 
154  const double P = simulator.getPMTSignalProcessor(id).getSurvivalProbability(NPE);
155 
156  if (P > 0.0)
157  (*frame)[pmt].div(P);
158  else
159  (*frame)[pmt].setValue(0.0);
160  }
161  }
162  }
163 
164  static const int NPE = 1; //!< Number of photo-electrons corresponding to singles rate.
165  };
166 }
167 
168 #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:80
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.
esac $JPP_DIR examples JDetector JTransitTime o $OUTPUT_FILE n N $NPE T $TTS_NS d $DEBUG for HISTOGRAM in tts tt2 pmt
Definition: JTransitTime.sh:36
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:130
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:60