Jpp 21.0.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JModuleRouter.hh
Go to the documentation of this file.
1#ifndef __JDETECTOR__JMODULEROUTER__
2#define __JDETECTOR__JMODULEROUTER__
3
8#include "JTools/JRouter.hh"
9#include "JLang/JReference.hh"
10
11
12/**
13 * \file
14 * Direct access to module in detector data structure.
15 * \author mdejong
16 */
17namespace JDETECTOR {}
18namespace JPP { using namespace JDETECTOR; }
19
20namespace JDETECTOR {
21
22
24
25
26 /**
27 * Router for direct addressing of module data in detector data structure.
28 *
29 * This router can be used to directly map the module identifier to
30 * the logical address of the module (JModuleAddress) in the detector data structure.
31 *
32 * Note that the required memory is determined by the range covered by the module identifiers.
33 */
35 public JReference<const JDetector>
36 {
37
39
40 public:
41
42 typedef JDetector::const_iterator const_iterator;
43
44
45 /**
46 * Constructor.
47 *
48 * \param detector detector
49 */
50 JModuleRouter(const JDetector& detector) :
51 JReference_t(detector),
53 {
54 for (const_iterator module = detector.begin(); module != detector.end(); ++module) {
55 router.put(module->getID(), JModuleAddress(std::distance(detector.begin(), module)));
56 }
57 }
58
59
60 /**
61 * Get module router.
62 *
63 * \return module router
64 */
66 {
67 return static_cast<const JModuleRouter&>(*this);
68 }
69
70
71 /**
72 * Get address of module.
73 *
74 * \param id module identifier
75 * \return address
76 */
78 {
79 return router.get(id.getID());
80 }
81
82
83 /**
84 * Get module parameters.
85 *
86 * \param id module identifier
87 * \return module parameters
88 */
89 const JModule& getModule(const JModuleIdentifier& id) const
90 {
91 return getReference().getModule(this->getAddress(id));
92 }
93
94
95 /**
96 * Has module.
97 *
98 * \param id module identifier
99 * \return true if module present; else false
100 */
101 bool hasModule(const JModuleIdentifier& id) const
102 {
103 return router.has(id.getID());
104 }
105
106
107 /**
108 * Get index of module.
109 *
110 * \param id module identifier
111 * \return index
112 */
113 const int getIndex(const JModuleIdentifier& id) const
114 {
115 return getAddress(id).first;
116 }
117
118
119 /**
120 * Has PMT.
121 *
122 * \param id PMT identifier
123 * \return true if PMT present; else false
124 */
125 bool hasPMT(const JPMTIdentifier& id) const
126 {
127 return hasModule(id.getID()) && id.getPMTAddress() >= 0 && id.getPMTAddress() < (int) getModule(id.getID()).size();
128 }
129
130
131 /**
132 * Get PMT parameters.
133 *
134 * \param id PMT identifier
135 * \return PMT parameters
136 */
137 const JPMT& getPMT(const JPMTIdentifier& id) const
138 {
139 return getModule(id.getID()).getPMT(id.getPMTAddress());
140 }
141
142
143 /**
144 * Get UTM position of given module identifier.
145 *
146 * \param id module identifier
147 * \return UTM position
148 */
153
154 private:
156 };
157}
158
159#endif
Data structure for detector geometry and calibration.
Detector data structure.
Definition JDetector.hh:96
Address of module in detector data structure.
int first
index of module in detector data structure
Router for direct addressing of module data in detector data structure.
JDetector::const_iterator const_iterator
JReference< const JDetector > JReference_t
JModuleRouter(const JDetector &detector)
Constructor.
bool hasModule(const JModuleIdentifier &id) const
Has module.
const JPMT & getPMT(const JPMTIdentifier &id) const
Get PMT parameters.
const JModule & getModule(const JModuleIdentifier &id) const
Get module parameters.
const int getIndex(const JModuleIdentifier &id) const
Get index of module.
bool hasPMT(const JPMTIdentifier &id) const
Has PMT.
const JModuleAddress & getAddress(const JModuleIdentifier &id) const
Get address of module.
JTOOLS::JRouter< JModuleAddress > router
const JModuleRouter & getModuleRouter() const
Get module router.
JUTMPosition getUTMPosition(const JModuleIdentifier &id) const
Get UTM position of given module identifier.
Data structure for a composite optical module.
Definition JModule.hh:76
const JPMT & getPMT(const int index) const
Get PMT.
Definition JModule.hh:173
Data structure for PMT geometry, calibration and status.
Definition JPMT.hh:49
Auxiliary base class for object identification.
Definition JObjectID.hh:38
The template JReference class can be used to reference an object.
Definition JReference.hh:21
const JClass_t & getReference() const
Get reference to object.
Definition JReference.hh:38
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
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).