Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JModuleL0.hh
Go to the documentation of this file.
1#ifndef __JRECONSTRUCTION__JMODULEL0__
2#define __JRECONSTRUCTION__JMODULEL0__
3
4#include <vector>
5#include <set>
6
9
10#include "JDetector/JModule.hh"
11#include "JPhysics/JK40Rates.hh"
12#include "JTrigger/JHitR0.hh"
13#include "JTrigger/JHitL0.hh"
15#include "JFit/JFitToolkit.hh"
16#include "JFit/JTimeRange.hh"
18
19
20/**
21 * \author mdejong
22 */
23
24namespace JRECONSTRUCTION {}
25namespace JPP { using namespace JRECONSTRUCTION; }
26
27namespace JRECONSTRUCTION {
28
33 using JDETECTOR::JPMT;
34 using JTRIGGER::JHitR0;
37 using JFIT::JTimeRange;
38
39
40 /**
41 * Auxiliary class for handling module response.
42 */
43 struct JModuleL0 :
44 std::vector<JHitR0>
45 {
46 /**
47 * Default constructor.
48 */
50 {}
51
52
53 /**
54 * Constructor.
55 *
56 * \param module module
57 * \param frame frame
58 * \param data data
59 */
62 const std::vector<JHitR0>& data) :
63 std::vector<JHitR0>(data),
65 frame (frame)
66 {}
67
68
69 /**
70 * Smart pointer.
71 *
72 * \return module
73 */
74 const JModule* operator->() const
75 {
76 return &module;
77 }
78
79
80 /**
81 * Get status of PMT.
82 *
83 * \param pmt PMT
84 * \return true is valid; else false
85 */
86 bool getStatus(const int pmt) const
87 {
88 using namespace JPP;
89
90 return (getDAQStatus(frame, module, pmt) &&
91 getPMTStatus(frame, module, pmt) &&
92 frame[pmt].is_valid() &&
94 }
95
96
97 /**
98 * Get probability of response in optical module due to random background.
99 *
100 * \param R_Hz multiples rates [Hz]
101 * \param T_ns time window [ns]
102 * \return probability
103 */
104 inline double getProbability(const JRateL1_t& R_Hz,
105 const JTimeRange& T_ns) const
106 {
107 using namespace std;
108 using namespace JPP;
109
111
112 for (const_iterator hit = this->begin(); hit != this->end(); ++hit) {
113 if (T_ns(hit->getT())) {
114 top.insert(hit->getPMT());
115 }
116 }
117
118 size_t N = 0; // number of active PMTs
119 size_t M = 0; // multiplicity
120 double R = 0.0; // total rate
121
122 for (size_t i = 0; i != module.size(); ++i) {
123 if (getStatus(i)) {
124 N += 1;
125 M += top.count(i);
126 R += frame.getRate(i);
127 }
128 }
129
130 if (N != 0)
131 return JFIT::getProbability(N, M, JK40Rates(R/N, R_Hz), (T_ns.getUpperLimit() - T_ns.getLowerLimit()));
132 else
133 return (M == 0 ? 1.0 : 0.0);
134 }
135
138 };
139}
140
141#endif
Auxiliary methods to evaluate Poisson probabilities and chi2.
Basic data structure for L0 hit.
Basic data structure for L0 hit.
Data structure for optical module.
Data structure for a composite optical module.
Definition JModule.hh:75
const JPMT & getPMT(const int index) const
Get PMT.
Definition JModule.hh:172
Data structure for PMT geometry, calibration and status.
Definition JPMT.hh:49
Data structure for position in three dimensions.
T getLowerLimit() const
Get lower limit.
Definition JRange.hh:202
T getUpperLimit() const
Get upper limit.
Definition JRange.hh:213
Reduced data structure for L0 hit.
Definition JHitR0.hh:27
Data storage class for rate measurements of all PMTs in one module.
double getRate(const int tdc, const double factor=1.0) const
Get count rate.
double getProbability(const size_t N, const size_t M, const JK40Rates &R_Hz, const double T_ns)
Get probability due to random background.
double JRateL0_t
Type definition of singles rate [Hz].
Definition JK40Rates.hh:21
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Model fits to data.
bool is_valid(const json &js)
Check validity of JSon data.
bool getDAQStatus(const JDAQFrameStatus &frame, const JStatus &status)
Test status of DAQ.
bool getPMTStatus(const JStatus &status)
Test status of PMT.
static const int PMT_DISABLE
KM3NeT Data Definitions v3.5.1-1-gd514d72 https://git.km3net.de/common/km3net-dataformat.
Definition pmt_status.hh:12
bool has(const int bit) const
Test PMT status.
Definition JStatus.hh:120
Auxiliary class for K40 rates.
Definition JK40Rates.hh:41
Auxiliary class for handling module response.
Definition JModuleL0.hh:45
double getProbability(const JRateL1_t &R_Hz, const JTimeRange &T_ns) const
Get probability of response in optical module due to random background.
Definition JModuleL0.hh:104
JModuleL0()
Default constructor.
Definition JModuleL0.hh:49
bool getStatus(const int pmt) const
Get status of PMT.
Definition JModuleL0.hh:86
JModuleL0(const JModule &module, const JDAQSummaryFrame &frame, const std::vector< JHitR0 > &data)
Constructor.
Definition JModuleL0.hh:60
JDAQSummaryFrame frame
Definition JModuleL0.hh:137
const JModule * operator->() const
Smart pointer.
Definition JModuleL0.hh:74