Jpp 20.0.0-27-g39925593c-D
the software that should make you happy
Loading...
Searching...
No Matches
JSupport/JSummaryRouter.hh
Go to the documentation of this file.
1#ifndef __JSUPPORT__JSUMMARYROUTER__
2#define __JSUPPORT__JSUMMARYROUTER__
3
8
9#include "JTools/JRouter.hh"
10#include "JLang/JException.hh"
11
12
13/**
14 * \author mdejong
15 */
16
17namespace JSUPPORT {}
18namespace JPP { using namespace JSUPPORT; }
19
20namespace JSUPPORT {
21
26
27
28 /**
29 * Router for fast addressing of summary data in KM3NETDAQ::JDAQSummaryslice data structure
30 * as a function of the optical module identifier and PMT address.
31 *
32 * The member method update() should be used to update the internal router for a given event.
33 * The member method getRate(const JDAQPMTIdentifier&) const can subsequently be used to obtain
34 * the measured singles rate for a given PMT.
35 */
37 public JDAQSummaryslice
38 {
39 public:
40 /**
41 * Default constructor.
42 */
44 router (-1)
45 {}
46
47
48 /**
49 * Update router.
50 *
51 * \param ps pointer to new summary slice
52 */
53 void update(const JDAQSummaryslice* ps)
54 {
55 if (ps != NULL) {
56
57 // reset internal router
58
59 for (JDAQSummaryslice::const_iterator i = this->begin(); i != this->end(); ++i) {
60 router.put(i->getModuleID(), router.getDefaultAddress());
61 }
62
63 static_cast<JDAQSummaryslice&>(*this) = *ps;
64
65 // set internal router
66
67 for (JDAQSummaryslice::const_iterator i = this->begin(); i != this->end(); ++i) {
68 router.put(i->getModuleID(), distance(this->cbegin(), i));
69 }
70 }
71 }
72
73
74 /**
75 * Get address of module.
76 *
77 * \param module module
78 * \return address
79 */
80 const int getAddress(const JDAQModuleIdentifier& module) const
81 {
82 return router.get(module.getModuleID());
83 }
84
85
86 /**
87 * Has summary frame.
88 *
89 * \param module module
90 * \return true if module present; else false
91 */
93 {
94 return router.has(module.getModuleID());
95 }
96
97
98 /**
99 * Get summary frame.
100 *
101 * \param module module
102 * \return summary frame
103 */
105 {
106 if (router.has(module.getModuleID()))
107 return (*this)[getAddress(module)];
108 else
109 THROW(JValueOutOfRange, "Module identifier " << module);
110 }
111
112
113 /**
114 * Get summary frame.
115 *
116 * \param module module
117 * \param rate_Hz default rate [Hz]
118 * \return summary frame
119 */
121 {
122 if (router.has(module.getModuleID())) {
123
124 return (*this)[getAddress(module)];
125
126 } else {
127
130
131 for (int i = 0; i != NUMBER_OF_PMTS; ++i) {
133 }
134
135 return frame;
136 }
137 }
138
139
140 /**
141 * Get rate.
142 *
143 * \param id PMT identifier
144 * \return rate [Hz]
145 */
146 double getRate(const JDAQPMTIdentifier& id) const
147 {
148 if (this->hasSummaryFrame(id.getModuleIdentifier()))
149 return this->getSummaryFrame(id.getModuleIdentifier()).getRate(id.getPMTAddress());
150 else
151 THROW(JValueOutOfRange, "Module identifier " << id.getModuleIdentifier());
152 }
153
154
155 /**
156 * Get rate.
157 *
158 * \param id PMT identifier
159 * \param rate_Hz default rate [Hz]
160 * \return rate [Hz]
161 */
162 double getRate(const JDAQPMTIdentifier& id, const double rate_Hz) const
163 {
164 double R = 0.0;
165
166 if (this->hasSummaryFrame(id.getModuleIdentifier())) {
167 R = this->getSummaryFrame(id.getModuleIdentifier()).getRate(id.getPMTAddress());
168 }
169
170 if (R < rate_Hz) {
171 R = rate_Hz;
172 }
173
174 return R;
175 }
176
177 private:
180 };
181}
182
183#endif
KM3NeT DAQ constants, bit handling, etc.
Exceptions.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Exception for accessing a value in a collection that is outside of its range.
Template definition of a multi-dimensional oscillation probability interpolation table.
Router for fast addressing of summary data in KM3NETDAQ::JDAQSummaryslice data structure as a functio...
double getRate(const JDAQPMTIdentifier &id, const double rate_Hz) const
Get rate.
bool hasSummaryFrame(const JDAQModuleIdentifier &module) const
Has summary frame.
double getRate(const JDAQPMTIdentifier &id) const
Get rate.
JSummaryRouter()
Default constructor.
const JDAQSummaryFrame & getSummaryFrame(const JDAQModuleIdentifier &module, const double rate_Hz) const
Get summary frame.
const int getAddress(const JDAQModuleIdentifier &module) const
Get address of module.
const JDAQSummaryFrame & getSummaryFrame(const JDAQModuleIdentifier &module) const
Get summary frame.
void update(const JDAQSummaryslice *ps)
Update router.
Direct addressing of elements with unique identifiers.
Definition JRouter.hh:27
static const JDAQFrameStatus & getInstance()
Get reference to unique instance of this class object.
void setDAQFrameStatus(const JDAQFrameStatus &status)
Set DAQ frame status.
void setModuleIdentifier(const JDAQModuleIdentifier &module)
Set Module identifier.
Data storage class for rate measurements of all PMTs in one module.
void setRate(const int tdc, const double rate_Hz)
Set count rate.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Support classes and methods for experiment specific I/O.
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition JDAQ.hh:26