Jpp 19.3.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JDETECTOR::JModuleAddressMap Class Reference

Lookup table for PMT addresses in optical module. More...

#include <JModuleAddressMap.hh>

Inheritance diagram for JDETECTOR::JModuleAddressMap:
std::vector< JPMTAddressTranslator >

Public Member Functions

 JModuleAddressMap ()
 Default constructor.
 
bool has (const int index) const
 Test whether index is available.
 
bool hasTDC (const int tdc) const
 Test whether TDC is available.
 
bool hasPMT (const JPMTPhysicalAddress &address) const
 Test whether PMT is available.
 
void configure ()
 Configure internal router.
 
void swap (const int i1, const int i2)
 Swap readout addresses corresponding to indices.
 
void swapTDC (const int tdc1, const int tdc2)
 Swap physical addresses corresponding to TDCs.
 
void swapPMT (const JPMTPhysicalAddress &pmt1, const JPMTPhysicalAddress &pmt2)
 Swap readout addresses corresponding to PMTs.
 
void rotateR (const char ring)
 Swap readout addresses by right rotation of physical addresses of PMTs in a given ring.
 
void rotateL (const char ring)
 Swap readout addresses by left rotation of physical addresses of PMTs in a given ring.
 
int getIndex (const int tdc) const
 Get PMT logical index for given TDC channel.
 
const JPMTAddressTranslatorgetAddressTranslator (const int tdc) const
 Get PMT address translator.
 
const JPMTPhysicalAddressgetPMTPhysicalAddress (const int tdc) const
 Get PMT physical address.
 
const JPMTAddressTranslatorgetAddressTranslator (const JPMTPhysicalAddress &address) const
 Get PMT address translator.
 
const JPMTReadoutAddressgetPMTReadoutAddress (const JPMTPhysicalAddress &address) const
 Get PMT readout address.
 

Protected Attributes

std::vector< int > router
 

Detailed Description

Lookup table for PMT addresses in optical module.

Definition at line 86 of file JModuleAddressMap.hh.

Constructor & Destructor Documentation

◆ JModuleAddressMap()

JDETECTOR::JModuleAddressMap::JModuleAddressMap ( )
inline

Default constructor.

The list of valid PMT address translations should be build according to the detector type. The internal router is used to convert a readout channel (TDC) to a PMT readout address.

Definition at line 96 of file JModuleAddressMap.hh.

Member Function Documentation

◆ has()

bool JDETECTOR::JModuleAddressMap::has ( const int index) const
inline

Test whether index is available.

Parameters
indexindex
Returns
true if index is available; else false

Definition at line 107 of file JModuleAddressMap.hh.

108 {
109 return (index >= 0 && index < (int) this->size());
110 }

◆ hasTDC()

bool JDETECTOR::JModuleAddressMap::hasTDC ( const int tdc) const
inline

Test whether TDC is available.

Parameters
tdcTDC
Returns
true if TDC is available; else false

Definition at line 119 of file JModuleAddressMap.hh.

120 {
121 return (tdc >= 0 && tdc < (int) router.size() && router[tdc] != -1);
122 }

◆ hasPMT()

bool JDETECTOR::JModuleAddressMap::hasPMT ( const JPMTPhysicalAddress & address) const
inline

Test whether PMT is available.

Parameters
addressPMT address
Returns
true if PMT is available; else false

Definition at line 131 of file JModuleAddressMap.hh.

132 {
133 using namespace std;
134
135 const_iterator p = lower_bound(this->begin(), this->end(), address, less<JPMTPhysicalAddress>());
136
137 return (p != this->end() && *p == address);
138 }

◆ configure()

void JDETECTOR::JModuleAddressMap::configure ( )
inline

Configure internal router.

Definition at line 144 of file JModuleAddressMap.hh.

145 {
146 using namespace std;
147
148 sort(this->begin(), this->end(), less<JPMTPhysicalAddress>());
149
150 for (const_iterator i = this->begin(); i != this->end(); ++i) {
151
152 if (i->tdc >= (int) router.size()) {
153 router.resize(i->tdc + 1, -1);
154 }
155
156 router[i->tdc] = std::distance(const_iterator(this->begin()),i);
157 }
158 }

◆ swap()

void JDETECTOR::JModuleAddressMap::swap ( const int i1,
const int i2 )
inline

Swap readout addresses corresponding to indices.

Parameters
i1first index
i2second index

Definition at line 167 of file JModuleAddressMap.hh.

168 {
169 std::swap(router[at(i1).tdc],
170 router[at(i2).tdc]);
171
172 std::swap(static_cast<JPMTReadoutAddress&>(at(i1)),
173 static_cast<JPMTReadoutAddress&>(at(i2)));
174 }

◆ swapTDC()

void JDETECTOR::JModuleAddressMap::swapTDC ( const int tdc1,
const int tdc2 )
inline

Swap physical addresses corresponding to TDCs.

Parameters
tdc1first TDC
tdc2second TDC

Definition at line 183 of file JModuleAddressMap.hh.

184 {
185 std::swap(static_cast<JPMTReadoutAddress&>(at(router[tdc1])),
186 static_cast<JPMTReadoutAddress&>(at(router[tdc2])));
187
188 std::swap(router[tdc1],
189 router[tdc2]);
190 }

◆ swapPMT()

void JDETECTOR::JModuleAddressMap::swapPMT ( const JPMTPhysicalAddress & pmt1,
const JPMTPhysicalAddress & pmt2 )
inline

Swap readout addresses corresponding to PMTs.

Parameters
pmt1first PMT
pmt2second PMT

Definition at line 199 of file JModuleAddressMap.hh.

200 {
202 }
void swapTDC(const int tdc1, const int tdc2)
Swap physical addresses corresponding to TDCs.
const JPMTReadoutAddress & getPMTReadoutAddress(const JPMTPhysicalAddress &address) const
Get PMT readout address.

◆ rotateR()

void JDETECTOR::JModuleAddressMap::rotateR ( const char ring)
inline

Swap readout addresses by right rotation of physical addresses of PMTs in a given ring.

Parameters
ringring

Definition at line 210 of file JModuleAddressMap.hh.

211 {
212 if (ring != 'A') {
213 swapPMT(JPMTPhysicalAddress(ring,5), JPMTPhysicalAddress(ring,6));
214 swapPMT(JPMTPhysicalAddress(ring,4), JPMTPhysicalAddress(ring,5));
215 swapPMT(JPMTPhysicalAddress(ring,3), JPMTPhysicalAddress(ring,4));
216 swapPMT(JPMTPhysicalAddress(ring,2), JPMTPhysicalAddress(ring,3));
217 swapPMT(JPMTPhysicalAddress(ring,1), JPMTPhysicalAddress(ring,2));
218 }
219 }
void swapPMT(const JPMTPhysicalAddress &pmt1, const JPMTPhysicalAddress &pmt2)
Swap readout addresses corresponding to PMTs.

◆ rotateL()

void JDETECTOR::JModuleAddressMap::rotateL ( const char ring)
inline

Swap readout addresses by left rotation of physical addresses of PMTs in a given ring.

Parameters
ringring

Definition at line 227 of file JModuleAddressMap.hh.

228 {
229 if (ring != 'A') {
230 swapPMT(JPMTPhysicalAddress(ring,1), JPMTPhysicalAddress(ring,2));
231 swapPMT(JPMTPhysicalAddress(ring,2), JPMTPhysicalAddress(ring,3));
232 swapPMT(JPMTPhysicalAddress(ring,3), JPMTPhysicalAddress(ring,4));
233 swapPMT(JPMTPhysicalAddress(ring,4), JPMTPhysicalAddress(ring,5));
234 swapPMT(JPMTPhysicalAddress(ring,5), JPMTPhysicalAddress(ring,6));
235 }
236 }

◆ getIndex()

int JDETECTOR::JModuleAddressMap::getIndex ( const int tdc) const
inline

Get PMT logical index for given TDC channel.

Parameters
tdcTDC
Returns
PMT logical index

Definition at line 245 of file JModuleAddressMap.hh.

246 {
247 return router.at(tdc);
248 }

◆ getAddressTranslator() [1/2]

const JPMTAddressTranslator & JDETECTOR::JModuleAddressMap::getAddressTranslator ( const int tdc) const
inline

Get PMT address translator.

Parameters
tdcTDC
Returns
PMT address translator

Definition at line 257 of file JModuleAddressMap.hh.

258 {
259 return at(getIndex(tdc));
260 }
int getIndex(const int tdc) const
Get PMT logical index for given TDC channel.

◆ getPMTPhysicalAddress()

const JPMTPhysicalAddress & JDETECTOR::JModuleAddressMap::getPMTPhysicalAddress ( const int tdc) const
inline

Get PMT physical address.

Parameters
tdcTDC
Returns
PMT physical address

Definition at line 269 of file JModuleAddressMap.hh.

270 {
271 return getAddressTranslator(tdc);
272 }
const JPMTAddressTranslator & getAddressTranslator(const int tdc) const
Get PMT address translator.

◆ getAddressTranslator() [2/2]

const JPMTAddressTranslator & JDETECTOR::JModuleAddressMap::getAddressTranslator ( const JPMTPhysicalAddress & address) const
inline

Get PMT address translator.

Parameters
addressPMT physical address
Returns
PMT address translator

Definition at line 281 of file JModuleAddressMap.hh.

282 {
283 using namespace std;
284
285 const_iterator p = lower_bound(this->begin(), this->end(), address, less<JPMTPhysicalAddress>());
286
287 if (p != this->end() && *p == address)
288 return *p;
289 else
290 THROW(JIndexOutOfRange, "Invalid PMT address " << address);
291 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.

◆ getPMTReadoutAddress()

const JPMTReadoutAddress & JDETECTOR::JModuleAddressMap::getPMTReadoutAddress ( const JPMTPhysicalAddress & address) const
inline

Get PMT readout address.

Parameters
addressPMT physical address
Returns
PMT readout address

Definition at line 300 of file JModuleAddressMap.hh.

301 {
302 return getAddressTranslator(address);
303 }

Member Data Documentation

◆ router

std::vector<int> JDETECTOR::JModuleAddressMap::router
protected

Definition at line 307 of file JModuleAddressMap.hh.


The documentation for this class was generated from the following file: