Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JPMTRouter.hh
Go to the documentation of this file.
1#ifndef __JDETECTOR__JPMTROUTER__
2#define __JDETECTOR__JPMTROUTER__
3
4#include "JLang/JObjectID.hh"
9#include "JTools/JRouter.hh"
10#include "JLang/JReference.hh"
11
12
13/**
14 * \file
15 * Direct access to PMT in detector data structure.
16 * \author mdejong
17 */
18namespace JDETECTOR {}
19namespace JPP { using namespace JDETECTOR; }
20
21namespace JDETECTOR {
22
23 using JLANG::JObjectID;
25
26
27 /**
28 * Router for direct addressing of PMT data in detector data structure.
29 *
30 * This router can be used to directly map the PMT identifier to
31 * the logical address of the PMT (JPMTAddress) in the detector data structure.
32 *
33 * Note that the required memory is determined by the range covered by the PMT identifiers.
34 */
35 class JPMTRouter :
36 public JReference<const JDetector>
37 {
38
40
41 public:
42
43 typedef JDetector::const_iterator const_iterator;
44
45
46 /**
47 * Constructor.
48 *
49 * \param detector detector
50 */
51 JPMTRouter(const JDetector& detector) :
52 JReference_t(detector),
54 {
55 for (const_iterator module = detector.begin(); module != detector.end(); ++module) {
56 for (JModule::const_iterator pmt = module->begin(); pmt != module->end(); ++pmt) {
57 router.put(pmt->getID(), JPMTAddress(JModuleAddress(std::distance(detector.begin(), module)), std::distance(module->begin(), pmt)));
58 }
59 }
60 }
61
62
63 /**
64 * Get PMT router.
65 *
66 * \return PMT router
67 */
68 const JPMTRouter& getPMTRouter() const
69 {
70 return static_cast<const JPMTRouter&>(*this);
71 }
72
73
74 /**
75 * Get address of PMT.
76 *
77 * \param id PMT identifier
78 * \return address
79 */
80 const JPMTAddress& getAddress(const JObjectID& id) const
81 {
82 return router.get(id.getID());
83 }
84
85
86 /**
87 * Get PMT.
88 *
89 * \param address PMT address
90 * \return PMT
91 */
92 const JPMT& getPMT(const JPMTAddress& address) const
93 {
94 return getReference().getPMT(address);
95 }
96
97
98 /**
99 * Get PMT.
100 *
101 * \param id PMT identifier
102 * \return PMT
103 */
104 const JPMT& getPMT(const JObjectID& id) const
105 {
106 return getReference().getPMT(this->getAddress(id));
107 }
108
109
110 /**
111 * Has PMT.
112 *
113 * \param id PMT identifier
114 * \return true if PMT present; else false
115 */
116 bool hasPMT(const JObjectID& id) const
117 {
118 return router.has(id.getID());
119 }
120
121
122 /**
123 * Get identifier of PMT.
124 *
125 * \param address PMT address
126 * \return address
127 */
129 {
130 return JPMTIdentifier(getModule(address), address.second);
131 }
132
133
134 /**
135 * Get identifier of PMT.
136 *
137 * \param id PMT identifier
138 * \return address
139 */
141 {
142 return getIdentifier(this->getAddress(id));
143 }
144
145
146 /**
147 * Get module.
148 *
149 * \param address module address
150 * \return module
151 */
152 const JModule& getModule(const JModuleAddress& address) const
153 {
154 return getReference().getModule(address);
155 }
156
157
158 /**
159 * Get parent module.
160 *
161 * \param id PMT identifier
162 * \return module
163 */
164 const JModule& getParentModule(const JObjectID& id) const
165 {
166 return getModule(this->getAddress(id));
167 }
168
169
170 /**
171 * Get parent module identifier.
172 *
173 * \param id PMT identifier
174 * \return module identifier
175 */
176 int getParentModuleID(const JObjectID& id) const
177 {
178 return getParentModule(id).getID();
179 }
180
181
182 /**
183 * Get PMT channel.
184 *
185 * \param address PMT address
186 * \return PMT channel
187 */
189 {
190 return JPMTChannel(getModule(address).getLocation(), address.second);
191 }
192
193
194 /**
195 * Get PMT channel.
196 *
197 * \param id PMT identifier
198 * \return PMT channel
199 */
200 inline JPMTChannel getPMTChannel(const JObjectID& id) const
201 {
202 return getPMTChannel(getAddress(id));
203 }
204
205
206 /**
207 * Get UTM position of given PMT identifier.
208 *
209 * \param id PMT identifier
210 * \return UTM position
211 */
213 {
214 return JUTMPosition(getPMT(id).getPosition() + getReference().getPosition());
215 }
216
217 private:
219 };
220}
221
222#endif
Data structure for detector geometry and calibration.
Data structure to uniquely identify PMT readout channel.
Detector data structure.
Definition JDetector.hh:96
Address of module in detector data structure.
Data structure for a composite optical module.
Definition JModule.hh:75
Address of PMT in detector data structure.
int second
index of PMT in module data structure.
Auxiliary class to uniquely identify PMT readout channel.
Router for direct addressing of PMT data in detector data structure.
Definition JPMTRouter.hh:37
JDetector::const_iterator const_iterator
Definition JPMTRouter.hh:43
JPMTChannel getPMTChannel(const JObjectID &id) const
Get PMT channel.
JUTMPosition getUTMPosition(const JObjectID &id) const
Get UTM position of given PMT identifier.
const JPMT & getPMT(const JObjectID &id) const
Get PMT.
JPMTChannel getPMTChannel(const JPMTAddress &address) const
Get PMT channel.
bool hasPMT(const JObjectID &id) const
Has PMT.
const JPMTRouter & getPMTRouter() const
Get PMT router.
Definition JPMTRouter.hh:68
JTOOLS::JRouter< JPMTAddress > router
JReference< const JDetector > JReference_t
Definition JPMTRouter.hh:39
JPMTIdentifier getIdentifier(const JObjectID &id) const
Get identifier of PMT.
int getParentModuleID(const JObjectID &id) const
Get parent module identifier.
JPMTRouter(const JDetector &detector)
Constructor.
Definition JPMTRouter.hh:51
const JPMT & getPMT(const JPMTAddress &address) const
Get PMT.
Definition JPMTRouter.hh:92
const JModule & getModule(const JModuleAddress &address) const
Get module.
JPMTIdentifier getIdentifier(const JPMTAddress &address) const
Get identifier of PMT.
const JModule & getParentModule(const JObjectID &id) const
Get parent module.
const JPMTAddress & getAddress(const JObjectID &id) const
Get address of PMT.
Definition JPMTRouter.hh:80
Data structure for PMT geometry, calibration and status.
Definition JPMT.hh:49
Auxiliary class for object identification.
Definition JObjectID.hh:25
The template JReference class can be used to reference an object.
Definition JReference.hh:21
Direct addressing of elements with unique identifiers.
Definition JRouter.hh:27
Data structure for UTM position.
file Auxiliary data structures and methods for detector calibration.
Definition JAnchor.hh:12
const JModule & getModule(const JType< JDetector_t > type, const int id, const JLocation &location=JLocation())
Get module according given detector type.
JPosition3D getPosition(const JModule &first, const JModule &second)
Get position to go from first to second module.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).