Jpp  18.0.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JDetectorAddressMap.hh
Go to the documentation of this file.
1 #ifndef __JDETECTOR__JPMTLOGICALADDRESSTABLE__
2 #define __JDETECTOR__JPMTLOGICALADDRESSTABLE__
3 
4 #include <vector>
5 
6 #include "JTools/JRouter.hh"
8 #include "JDetector/JLocation.hh"
10 
11 
12 /**
13  * \author mdejong
14  */
15 
16 namespace JDETECTOR {}
17 namespace JPP { using namespace JDETECTOR; }
18 
19 namespace JDETECTOR {
20 
21 
22  /**
23  * Lookup table for PMT addresses in detector.
24  */
26  {
27  protected:
28  /**
29  * Default constructor.
30  */
32  buffer(),
33  router(-1)
34  {}
35 
36  public:
37  /**
38  * Virtual destructor.
39  */
41  {}
42 
43 
44  /**
45  * Get default module address map.
46  *
47  * \return module address map
48  */
49  virtual const JModuleAddressMap& getDefaultModuleAddressMap() const = 0;
50 
51 
52  /**
53  * Get module identifier.
54  *
55  * \param location module location
56  * \return module identifier
57  */
58  virtual int getModuleID(const JLocation& location) const
59  {
60  return location.getString() * 100 + location.getFloor();
61  }
62 
63 
64  /**
65  * Get module address map.
66  *
67  * \param id module identifier
68  */
69  const JModuleAddressMap& get(const int id) const
70  {
71  if (router.has(id))
72  return buffer[router.get(id)];
73  else
75  }
76 
77 
78  /**
79  * Get module address map.
80  *
81  * \param id module identifier
82  * \return module address map
83  */
84  JModuleAddressMap& get(const int id)
85  {
86  if (!router.has(id)) {
87 
89 
90  router.put(id, buffer.size() - 1);
91  }
92 
93  return buffer[router.get(id)];
94  }
95 
96 
97  /**
98  * Get PMT address translator.
99  *
100  * \param id PMY identifier
101  * \return PMT address translator
102  */
103  const JPMTAddressTranslator& get(const JPMTIdentifier& id) const
104  {
105  return get(id.getModuleID()).getAddressTranslator(id.getTDC());
106  }
107 
108  protected:
111  };
112 }
113 
114 #endif
int getFloor() const
Get floor number.
Definition: JLocation.hh:145
virtual int getModuleID(const JLocation &location) const
Get module identifier.
Lookup table for PMT addresses in detector.
virtual const JModuleAddressMap & getDefaultModuleAddressMap() const =0
Get default module address map.
Lookup table for PMT addresses in optical module.
Logical location of module.
Definition: JLocation.hh:37
std::vector< JModuleAddressMap > buffer
Data structure to translate PMT physical to readout address.
Logical location of module.
int getString() const
Get string number.
Definition: JLocation.hh:134
virtual ~JDetectorAddressMap()
Virtual destructor.
JDetectorAddressMap()
Default constructor.