Jpp test-rotations-old
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
23 using JLANG::JObjectID;
26
27
28 /**
29 * Router for direct addressing of module data in detector data structure.
30 *
31 * This router can be used to directly map the module identifier to
32 * the logical address of the module (JModuleAddress) in the detector data structure.
33 *
34 * Note that the required memory is determined by the range covered by the module identifiers.
35 */
37 public JReference<const JDetector>
38 {
39
41
42 public:
43
44 typedef JDetector::const_iterator const_iterator;
45
46
47 /**
48 * Constructor.
49 *
50 * \param detector detector
51 */
52 JModuleRouter(const JDetector& detector) :
53 JReference_t(detector),
55 {
56 for (const_iterator module = detector.begin(); module != detector.end(); ++module) {
57 router.put(module->getID(), JModuleAddress(std::distance(detector.begin(), module)));
58 }
59 }
60
61
62 /**
63 * Get module router.
64 *
65 * \return module router
66 */
68 {
69 return static_cast<const JModuleRouter&>(*this);
70 }
71
72
73 /**
74 * Get address of module.
75 *
76 * \param id module identifier
77 * \return address
78 */
79 const JModuleAddress& getAddress(const JObjectID& id) const
80 {
81 return router.get(id.getID());
82 }
83
84
85 /**
86 * Get module parameters.
87 *
88 * \param id module identifier
89 * \return module parameters
90 */
91 const JModule& getModule(const JObjectID& id) const
92 {
93 return getReference().getModule(this->getAddress(id));
94 }
95
96
97 /**
98 * Has module.
99 *
100 * \param id module identifier
101 * \return true if module present; else false
102 */
103 bool hasModule(const JObjectID& id) const
104 {
105 return router.has(id.getID());
106 }
107
108
109 /**
110 * Get index of module.
111 *
112 * \param id module identifier
113 * \return index
114 */
115 const int getIndex(const JObjectID& id) const
116 {
117 return getAddress(id).first;
118 }
119
120
121 /**
122 * Has PMT.
123 *
124 * \param id PMT identifier
125 * \return true if PMT present; else false
126 */
127 bool hasPMT(const JPMTIdentifier& id) const
128 {
129 return hasModule(id.getID()) && id.getPMTAddress() >= 0 && id.getPMTAddress() < (int) getModule(id.getID()).size();
130 }
131
132
133 /**
134 * Get PMT parameters.
135 *
136 * \param id PMT identifier
137 * \return PMT parameters
138 */
139 const JPMT& getPMT(const JPMTIdentifier& id) const
140 {
141 return getModule(id.getID()).getPMT(id.getPMTAddress());
142 }
143
144
145 /**
146 * Get UTM position of given module identifier.
147 *
148 * \param id module identifier
149 * \return UTM position
150 */
152 {
154 }
155
156 private:
158 };
159}
160
161#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.
const JPMT & getPMT(const JPMTIdentifier &id) const
Get PMT parameters.
bool hasPMT(const JPMTIdentifier &id) const
Has PMT.
bool hasModule(const JObjectID &id) const
Has module.
const int getIndex(const JObjectID &id) const
Get index of module.
JTOOLS::JRouter< JModuleAddress > router
const JModuleAddress & getAddress(const JObjectID &id) const
Get address of module.
const JModuleRouter & getModuleRouter() const
Get module router.
const JModule & getModule(const JObjectID &id) const
Get module parameters.
JUTMPosition getUTMPosition(const JObjectID &id) const
Get UTM position of given module identifier.
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
Auxiliary class for object identification.
Definition JObjectID.hh:25
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.
const JObjectID & getUndefinedObjectID()
Get undefined object identifier.
Definition JObjectID.hh:149
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).