Jpp  16.0.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JPMTRouter.hh
Go to the documentation of this file.
1 #ifndef __JDETECTOR__JPMTROUTER__
2 #define __JDETECTOR__JPMTROUTER__
3 
4 #include "JLang/JObjectID.hh"
7 #include "JDetector/JDetector.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  */
18 namespace JDETECTOR {}
19 namespace JPP { using namespace JDETECTOR; }
20 
21 namespace JDETECTOR {
22 
23  using JLANG::JObjectID;
24  using JLANG::JReference;
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  */
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  */
188  JPMTChannel getPMTChannel(const JPMTAddress& address) const
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  {
215  }
216 
217  private:
219  };
220 }
221 
222 #endif
Router for direct addressing of PMT data in detector data structure.
Definition: JPMTRouter.hh:35
JTOOLS::JRouter< JPMTAddress > router
Definition: JPMTRouter.hh:218
Auxiliary class to uniquely identify PMT readout channel.
Definition: JPMTChannel.hh:30
Data structure to uniquely identify PMT readout channel.
Data structure for a composite optical module.
Definition: JModule.hh:68
Direct addressing of elements with unique identifiers.
Definition: JRouter.hh:27
JPMTChannel getPMTChannel(const JPMTAddress &address) const
Get PMT channel.
Definition: JPMTRouter.hh:188
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
JPMTIdentifier getIdentifier(const JPMTAddress &address) const
Get identifier of PMT.
Definition: JPMTRouter.hh:128
Detector data structure.
Definition: JDetector.hh:89
int second
index of PMT in module data structure.
Definition: JPMTAddress.hh:100
bool hasPMT(const JObjectID &id) const
Has PMT.
Definition: JPMTRouter.hh:116
const JPMT & getPMT(const JPMTAddress &address) const
Get PMT.
Definition: JPMTRouter.hh:92
Data structure for detector geometry and calibration.
Data structure for UTM position.
Definition: JUTMPosition.hh:36
const JModule & getModule(const JModuleAddress &address) const
Get module.
Definition: JPMTRouter.hh:152
The template JReference class can be used to reference an object.
Definition: JReference.hh:21
const JModule & getParentModule(const JObjectID &id) const
Get parent module.
Definition: JPMTRouter.hh:164
int getID() const
Get identifier.
Definition: JObjectID.hh:50
Data structure for PMT geometry, calibration and status.
Definition: JPMT.hh:43
JPosition3D getPosition(const Vec &pos)
Get position.
const JPMTRouter & getPMTRouter() const
Get PMT router.
Definition: JPMTRouter.hh:68
Address of module in detector data structure.
const JPMT & getPMT(const JObjectID &id) const
Get PMT.
Definition: JPMTRouter.hh:104
JReference< const JDetector > JReference_t
Definition: JPMTRouter.hh:39
const JClass_t & getReference() const
Get reference to object.
Definition: JReference.hh:38
Address of PMT in detector data structure.
Definition: JPMTAddress.hh:32
Auxiliary class for object identification.
Definition: JObjectID.hh:22
do set_variable DETECTOR_TXT $WORKDIR detector
JPMTRouter(const JDetector &detector)
Constructor.
Definition: JPMTRouter.hh:51
JUTMPosition getUTMPosition(const JObjectID &id) const
Get UTM position of given PMT identifier.
Definition: JPMTRouter.hh:212
int getParentModuleID(const JObjectID &id) const
Get parent module identifier.
Definition: JPMTRouter.hh:176
JPMTIdentifier getIdentifier(const JObjectID &id) const
Get identifier of PMT.
Definition: JPMTRouter.hh:140
JPMTChannel getPMTChannel(const JObjectID &id) const
Get PMT channel.
Definition: JPMTRouter.hh:200
const JPMTAddress & getAddress(const JObjectID &id) const
Get address of PMT.
Definition: JPMTRouter.hh:80
JDetector::const_iterator const_iterator
Definition: JPMTRouter.hh:43