Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JLocationRouter.hh
Go to the documentation of this file.
1#ifndef __JDETECTOR__JLOCATIONROUTER__
2#define __JDETECTOR__JLOCATIONROUTER__
3
7#include "JTools/JHashMap.hh"
8#include "JLang/JReference.hh"
9
10
11/**
12 * \file
13 * Direct access to location in detector data structure.
14 * \author mdejong
15 */
16namespace JDETECTOR {}
17namespace JPP { using namespace JDETECTOR; }
18
19namespace JDETECTOR {
20
21
23
24
25 /**
26 * Router for direct addressing of location data in detector data structure.
27 */
29 public JReference<const JDetector>
30 {
31
33
34 public:
35
36 typedef JDetector::const_iterator const_iterator;
37
38
39 /**
40 * Constructor.
41 *
42 * \param detector detector
43 */
44 JLocationRouter(const JDetector& detector) :
45 JReference_t(detector)
46 {
47 for (const_iterator module = detector.begin(); module != detector.end(); ++module) {
48 router[module->getString()][module->getFloor()] = JModuleAddress(std::distance(detector.begin(), module));
49 }
50 }
51
52
53 /**
54 * Get location router.
55 *
56 * \return location router
57 */
59 {
60 return static_cast<const JLocationRouter&>(*this);
61 }
62
63
64 /**
65 * Get address of location.
66 *
67 * \param location location
68 * \return address
69 */
70 const JModuleAddress& getAddress(const JLocation& location) const
71 {
72 return router[location.getString()][location.getFloor()];
73 }
74
75
76 /**
77 * Get module parameters.
78 *
79 * \param location location
80 * \return module parameters
81 */
82 const JModule& getModule(const JLocation& location) const
83 {
84 return getReference().getModule(this->getAddress(location));
85 }
86
87
88 /**
89 * Has module.
90 *
91 * \param location location
92 * \return true if location present; else false
93 */
94 bool hasLocation(const JLocation& location) const
95 {
96 return router.has(location.getString()) && router[location.getString()].has(location.getFloor());
97 }
98
99
100 /**
101 * Get index of location.
102 *
103 * \param location location
104 * \return index
105 */
106 const int getIndex(const JLocation& location) const
107 {
108 return getAddress(location).first;
109 }
110
111 private:
113 };
114}
115
116#endif
Data structure for detector geometry and calibration.
General purpose class for hash map of unique elements.
Logical location of module.
Detector data structure.
Definition JDetector.hh:96
Router for direct addressing of location data in detector data structure.
bool hasLocation(const JLocation &location) const
Has module.
JTOOLS::JHashMap< int, JTOOLS::JHashMap< int, JModuleAddress > > router
JReference< const JDetector > JReference_t
const JModuleAddress & getAddress(const JLocation &location) const
Get address of location.
JDetector::const_iterator const_iterator
const JModule & getModule(const JLocation &location) const
Get module parameters.
const JLocationRouter & getLocationRouter() const
Get location router.
const int getIndex(const JLocation &location) const
Get index of location.
JLocationRouter(const JDetector &detector)
Constructor.
Logical location of module.
Definition JLocation.hh:40
int getFloor() const
Get floor number.
Definition JLocation.hh:146
int getString() const
Get string number.
Definition JLocation.hh:135
Address of module in detector data structure.
int first
index of module in detector data structure
Data structure for a composite optical module.
Definition JModule.hh:75
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
file Auxiliary data structures and methods for detector calibration.
Definition JAnchor.hh:12
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
General purpose class for hash map of unique keys.
Definition JHashMap.hh:75