Jpp  15.0.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Attributes | List of all members
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. More...
 
bool has (const int index) const
 Test whether index is available. More...
 
bool hasTDC (const int tdc) const
 Test whether TDC is available. More...
 
bool hasPMT (const JPMTPhysicalAddress &address) const
 Test whether PMT is available. More...
 
void configure ()
 Configure internal router. More...
 
void swap (const int i1, const int i2)
 Swap readout addresses corresponding to indices. More...
 
void swapTDC (const int tdc1, const int tdc2)
 Swap physical addresses corresponding to TDCs. More...
 
int getIndex (const int tdc) const
 Get PMT logical index for given TDC channel. More...
 
const JPMTAddressTranslatorgetAddressTranslator (const int tdc) const
 Get PMT address translator. More...
 
const JPMTPhysicalAddressgetPMTPhysicalAddress (const int tdc) const
 Get PMT physical address. More...
 
const JPMTAddressTranslatorgetAddressTranslator (const JPMTPhysicalAddress &address) const
 Get PMT address translator. More...
 
const JPMTReadoutAddressgetPMTReadoutAddress (const JPMTPhysicalAddress &address) const
 Get PMT readout address. More...
 

Protected Attributes

std::vector< int > router
 

Detailed Description

Lookup table for PMT addresses in optical module.

Definition at line 82 of file JModuleAddressMap.hh.

Constructor & Destructor Documentation

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 92 of file JModuleAddressMap.hh.

Member Function Documentation

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 103 of file JModuleAddressMap.hh.

104  {
105  return (index >= 0 && index < (int) this->size());
106  }
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 115 of file JModuleAddressMap.hh.

116  {
117  return (tdc >= 0 && tdc < (int) router.size() && router[tdc] != -1);
118  }
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 127 of file JModuleAddressMap.hh.

128  {
129  using namespace std;
130 
131  const_iterator p = lower_bound(this->begin(), this->end(), address, less<JPMTPhysicalAddress>());
132 
133  return (p != this->end() && *p == address);
134  }
void JDETECTOR::JModuleAddressMap::configure ( )
inline

Configure internal router.

Definition at line 140 of file JModuleAddressMap.hh.

141  {
142  using namespace std;
143 
144  sort(this->begin(), this->end(), less<JPMTPhysicalAddress>());
145 
146  for (const_iterator i = this->begin(); i != this->end(); ++i) {
147 
148  if (i->tdc >= (int) router.size()) {
149  router.resize(i->tdc + 1, -1);
150  }
151 
152  router[i->tdc] = std::distance(const_iterator(this->begin()),i);
153  }
154  }
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
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 163 of file JModuleAddressMap.hh.

164  {
165  std::swap(router[at(i1).tdc],
166  router[at(i2).tdc]);
167 
168  std::swap(static_cast<JPMTReadoutAddress&>(at(i1)),
169  static_cast<JPMTReadoutAddress&>(at(i2)));
170  }
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 179 of file JModuleAddressMap.hh.

180  {
181  std::swap(static_cast<JPMTReadoutAddress&>(at(router[tdc1])),
182  static_cast<JPMTReadoutAddress&>(at(router[tdc2])));
183 
184  std::swap(router[tdc1],
185  router[tdc2]);
186 
187  }
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 196 of file JModuleAddressMap.hh.

197  {
198  return router.at(tdc);
199  }
const JPMTAddressTranslator& JDETECTOR::JModuleAddressMap::getAddressTranslator ( const int  tdc) const
inline

Get PMT address translator.

Parameters
tdcTDC
Returns
PMT address translator

Definition at line 208 of file JModuleAddressMap.hh.

209  {
210  return at(getIndex(tdc));
211  }
int getIndex(const int tdc) const
Get PMT logical index for given TDC channel.
const JPMTPhysicalAddress& JDETECTOR::JModuleAddressMap::getPMTPhysicalAddress ( const int  tdc) const
inline

Get PMT physical address.

Parameters
tdcTDC
Returns
PMT physical address

Definition at line 220 of file JModuleAddressMap.hh.

221  {
222  return getAddressTranslator(tdc);
223  }
const JPMTAddressTranslator & getAddressTranslator(const int tdc) const
Get PMT address translator.
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 232 of file JModuleAddressMap.hh.

233  {
234  using namespace std;
235 
236  const_iterator p = lower_bound(this->begin(), this->end(), address, less<JPMTPhysicalAddress>());
237 
238  if (p != this->end() && *p == address)
239  return *p;
240  else
241  THROW(JIndexOutOfRange, "Invalid PMT address " << address);
242  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
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 251 of file JModuleAddressMap.hh.

252  {
253  return getAddressTranslator(address);
254  }
const JPMTAddressTranslator & getAddressTranslator(const int tdc) const
Get PMT address translator.

Member Data Documentation

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

Definition at line 258 of file JModuleAddressMap.hh.


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