Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
JDATABASE::JProductRouter Class Reference

Auxiliary class to map UPI to location in detector. More...

#include <JProductRouter.hh>

Public Member Functions

 JProductRouter (const JDetectorIntegration_t &detector)
 Constructor. More...
 
JLocation_t getLocation (const JUPI &upi) const
 Get location of product with given UPI. More...
 
JUPI getUPI (const JLocation_t &location) const
 Get UPI of product with given location. More...
 

Private Member Functions

bool insert (const JDetectorIntegration_t &detector, const JProductIntegration_t &product, const std::vector< JPBS > &pbs)
 Insert product. More...
 

Private Attributes

std::map< JUPI, JLocation_tmap
 
std::map< JLocation_t, JUPIinverse_map
 

Detailed Description

Auxiliary class to map UPI to location in detector.

Definition at line 107 of file JProductRouter.hh.

Constructor & Destructor Documentation

JDATABASE::JProductRouter::JProductRouter ( const JDetectorIntegration_t detector)
inline

Constructor.

Parameters
detectordetector integration

Definition at line 117 of file JProductRouter.hh.

118  {
119  using namespace std;
120  using namespace JPP;
121 
122  for (JDetectorIntegration_t::const_iterator i = detector.begin(); i != detector.end(); ++i) {
123 
124  if (i->has()) {
125 
126  if (insert(detector, *i, vector<JPBS>{ PBS::DOM, PBS::DETECTION_UNIT, PBS::DETECTOR })) { continue; }
127  if (insert(detector, *i, vector<JPBS>{ PBS::BASE, PBS::DETECTION_UNIT, PBS::DETECTOR })) { continue; }
128  if (insert(detector, *i, vector<JPBS>{ PBS::BASE_CONTAINER, PBS::DETECTION_UNIT, PBS::DETECTOR })) { continue; }
129 
130  if (insert(detector, *i, vector<JPBS>{ PBS::CLB, PBS::DOM, PBS::DETECTION_UNIT, PBS::DETECTOR })) { continue; }
131  if (insert(detector, *i, vector<JPBS>{ PBS::CLB, PBS::BASE, PBS::DETECTION_UNIT, PBS::DETECTOR })) { continue; }
132  if (insert(detector, *i, vector<JPBS>{ PBS::CLB, PBS::BASE_CONTAINER, PBS::DETECTION_UNIT, PBS::DETECTOR })) { continue; }
133  }
134  }
135  }
static const JPBS DETECTOR(0)
Fixed PBS.
const_iterator end() const
end of integration data
static const JPBS BASE_CONTAINER(3, 2, 2)
static const JPBS DETECTION_UNIT(3)
data_type::const_iterator const_iterator
static const JPBS DOM(3, 4)
static const JPBS BASE(3, 2)
bool insert(const JDetectorIntegration_t &detector, const JProductIntegration_t &product, const std::vector< JPBS > &pbs)
Insert product.
static const JPBS CLB(3, 4, 3, 2)
const_iterator begin() const
begin of integration data

Member Function Documentation

JLocation_t JDATABASE::JProductRouter::getLocation ( const JUPI upi) const
inline

Get location of product with given UPI.

Note that only for products inside a string, a valid location is returned, otherwise, the default location is returned.

Parameters
upiUPI
Returns
location

Definition at line 147 of file JProductRouter.hh.

148  {
150 
151  if (p != map.end())
152  return p->second;
153  else
154  return JLocation_t();
155  }
Auxiliary data structure for location of product in detector.
JUPI JDATABASE::JProductRouter::getUPI ( const JLocation_t location) const
inline

Get UPI of product with given location.

Note that only for products inside a string, a valid location is returned, otherwise, the default location is returned.

Parameters
locationlocation
Returns
UPI

Definition at line 167 of file JProductRouter.hh.

168  {
170 
171  if (p != inverse_map.end())
172  return p->second;
173  else
174  return JUPI();
175  }
std::map< JLocation_t, JUPI > inverse_map
Universal product identifier (UPI).
Definition: JUPI.hh:30
bool JDATABASE::JProductRouter::insert ( const JDetectorIntegration_t detector,
const JProductIntegration_t product,
const std::vector< JPBS > &  pbs 
)
inlineprivate

Insert product.

Note that given PBS hierarchy should contain at least three levels and normally terminate with detection unit and detector.

Parameters
detectordetector integration
productproduct
pbsPBS hierarchy
Returns
true if inserted; else false

Definition at line 190 of file JProductRouter.hh.

193  {
194  if (pbs.size() >= 3) {
195 
196  const JProductTrace trace(detector, product.content.getUPI(), pbs);
197 
198  if (trace.size() == pbs.size()) {
199 
200  const JUPI upi = product.content.getUPI();
201  const JLocation_t loc = JLocation_t(trace[2].position, trace[1].position, trace[0].position);
202 
203  map.insert (make_pair(upi, loc));
204  inverse_map.insert(make_pair(loc, upi));
205 
206  return true;
207  }
208  }
209 
210  return false;
211  }
Auxiliary class to trace product.
Auxiliary data structure for location of product in detector.
std::map< JLocation_t, JUPI > inverse_map
Universal product identifier (UPI).
Definition: JUPI.hh:30
const JUPI & getUPI() const
Get UPI.
Definition: JUPI.hh:68
char * loc(char *orig)

Member Data Documentation

std::map<JUPI, JLocation_t> JDATABASE::JProductRouter::map
private

Definition at line 213 of file JProductRouter.hh.

std::map<JLocation_t, JUPI> JDATABASE::JProductRouter::inverse_map
private

Definition at line 214 of file JProductRouter.hh.


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