Jpp  15.0.0-rc.2
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 (JObjectID) to
31  * the logical address of the PMT (JPMTAddress) in the detector data structure.
32  */
33  class JPMTRouter :
34  public JReference<const JDetector>
35  {
36 
38 
39  public:
40 
41  typedef JDetector::const_iterator const_iterator;
42 
43 
44  /**
45  * Constructor.
46  *
47  * \param detector detector
48  */
50  JReference_t(detector),
52  {
53  for (const_iterator module = detector.begin(); module != detector.end(); ++module) {
54  for (JModule::const_iterator pmt = module->begin(); pmt != module->end(); ++pmt) {
55  router.put(pmt->getID(), JPMTAddress(JModuleAddress(std::distance(detector.begin(), module)), std::distance(module->begin(), pmt)));
56  }
57  }
58  }
59 
60 
61  /**
62  * Get PMT router.
63  *
64  * \return PMT router
65  */
66  const JPMTRouter& getPMTRouter() const
67  {
68  return static_cast<const JPMTRouter&>(*this);
69  }
70 
71 
72  /**
73  * Get address of PMT.
74  *
75  * \param id PMT identifier
76  * \return address
77  */
78  const JPMTAddress& getAddress(const JObjectID& id) const
79  {
80  return router.get(id.getID());
81  }
82 
83 
84  /**
85  * Get PMT.
86  *
87  * \param address PMT address
88  * \return PMT
89  */
90  const JPMT& getPMT(const JPMTAddress& address) const
91  {
92  return getReference().getPMT(address);
93  }
94 
95 
96  /**
97  * Get PMT.
98  *
99  * \param id PMT identifier
100  * \return PMT
101  */
102  const JPMT& getPMT(const JObjectID& id) const
103  {
104  return getReference().getPMT(this->getAddress(id));
105  }
106 
107 
108  /**
109  * Has PMT.
110  *
111  * \param id PMT identifier
112  * \return true if PMT present; else false
113  */
114  bool hasPMT(const JObjectID& id) const
115  {
116  return router.has(id.getID());
117  }
118 
119 
120  /**
121  * Get identifier of PMT.
122  *
123  * \param address PMT address
124  * \return address
125  */
127  {
128  return JPMTIdentifier(getModule(address), address.second);
129  }
130 
131 
132  /**
133  * Get identifier of PMT.
134  *
135  * \param id PMT identifier
136  * \return address
137  */
139  {
140  return getIdentifier(this->getAddress(id));
141  }
142 
143 
144  /**
145  * Get module.
146  *
147  * \param address module address
148  * \return module
149  */
150  const JModule& getModule(const JModuleAddress& address) const
151  {
152  return getReference().getModule(address);
153  }
154 
155 
156  /**
157  * Get parent module.
158  *
159  * \param id PMT identifier
160  * \return module
161  */
162  const JModule& getParentModule(const JObjectID& id) const
163  {
164  return getModule(this->getAddress(id));
165  }
166 
167 
168  /**
169  * Get parent module identifier.
170  *
171  * \param id PMT identifier
172  * \return module identifier
173  */
174  int getParentModuleID(const JObjectID& id) const
175  {
176  return getParentModule(id).getID();
177  }
178 
179 
180  /**
181  * Get PMT channel.
182  *
183  * \param address PMT address
184  * \return PMT channel
185  */
186  JPMTChannel getPMTChannel(const JPMTAddress& address) const
187  {
188  return JPMTChannel(getModule(address).getLocation(), address.second);
189  }
190 
191 
192  /**
193  * Get PMT channel.
194  *
195  * \param id PMT identifier
196  * \return PMT channel
197  */
198  inline JPMTChannel getPMTChannel(const JObjectID& id) const
199  {
200  return getPMTChannel(getAddress(id));
201  }
202 
203 
204  /**
205  * Get UTM position of given PMT identifier.
206  *
207  * \param id PMT identifier
208  * \return UTM position
209  */
211  {
213  }
214 
215  private:
217  };
218 }
219 
220 #endif
Router for direct addressing of PMT data in detector data structure.
Definition: JPMTRouter.hh:33
JTOOLS::JRouter< JPMTAddress > router
Definition: JPMTRouter.hh:216
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:186
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:126
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:114
const JPMT & getPMT(const JPMTAddress &address) const
Get PMT.
Definition: JPMTRouter.hh:90
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:150
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:162
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:66
Address of module in detector data structure.
const JPMT & getPMT(const JObjectID &id) const
Get PMT.
Definition: JPMTRouter.hh:102
JReference< const JDetector > JReference_t
Definition: JPMTRouter.hh:37
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:49
JUTMPosition getUTMPosition(const JObjectID &id) const
Get UTM position of given PMT identifier.
Definition: JPMTRouter.hh:210
int getParentModuleID(const JObjectID &id) const
Get parent module identifier.
Definition: JPMTRouter.hh:174
JPMTIdentifier getIdentifier(const JObjectID &id) const
Get identifier of PMT.
Definition: JPMTRouter.hh:138
JPMTChannel getPMTChannel(const JObjectID &id) const
Get PMT channel.
Definition: JPMTRouter.hh:198
const JPMTAddress & getAddress(const JObjectID &id) const
Get address of PMT.
Definition: JPMTRouter.hh:78
JDetector::const_iterator const_iterator
Definition: JPMTRouter.hh:41