Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JDATABASE::JProductRouter Struct Reference

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

#include <JProductRouter.hh>

Inheritance diagram for JDATABASE::JProductRouter:
std::map< JUPI_t, JLocation_t >

Public Member Functions

 JProductRouter (const JDetectorIntegration_t &detector, const JPBSSequences &pbs)
 Constructor.
 
JLocation_t getLocation (const JUPI_t &upi) const
 Get location of product with given UPI.
 

Private Member Functions

bool insert (const JDetectorIntegration_t &detector, const JProductIntegration_t &product, const JPBSSequence &pbs)
 Insert product.
 

Detailed Description

Auxiliary class to map UPI to location in detector.

Definition at line 25 of file JProductRouter.hh.

Constructor & Destructor Documentation

◆ JProductRouter()

JDATABASE::JProductRouter::JProductRouter ( const JDetectorIntegration_t & detector,
const JPBSSequences & pbs )
inline

Constructor.

Parameters
detectordetector integration
pbsPBS sequences

Definition at line 34 of file JProductRouter.hh.

35 {
36 for (JDetectorIntegration_t::const_iterator product = detector.begin(); product != detector.end(); ++product) {
37 if (product->is_set()) {
38 for (JPBSSequences::const_iterator i = pbs.begin(); i != pbs.end(); ++i) {
39 if (insert(detector, *product, *i)) {
40 break;
41 }
42 }
43 }
44 }
45 }
bool insert(const JDetectorIntegration_t &detector, const JProductIntegration_t &product, const JPBSSequence &pbs)
Insert product.

Member Function Documentation

◆ getLocation()

JLocation_t JDATABASE::JProductRouter::getLocation ( const JUPI_t & upi) const
inline

Get location of product with given UPI.

Parameters
upiUPI
Returns
location

Definition at line 54 of file JProductRouter.hh.

55 {
56 const_iterator p = this->find(upi);
57
58 if (p != this->end())
59 return p->second;
60 else
61 return JLocation_t();
62 }

◆ insert()

bool JDATABASE::JProductRouter::insert ( const JDetectorIntegration_t & detector,
const JProductIntegration_t & product,
const JPBSSequence & pbs )
inlineprivate

Insert product.

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

Definition at line 73 of file JProductRouter.hh.

76 {
77 using namespace std;
78
79 if (!pbs.empty()) {
80
81 JPBSSequence::const_iterator i = pbs.begin();
82
83 if (product.content.getPBS() == i->getPBS()) {
84
85 JLocation_t location;
86
87 for (JUPI_t upi = product.content.getUPI(); ++i != pbs.end(); ) {
88
89 const JDetectorIntegration_t::range_type range = detector.find(upi);
90
91 if (distance(range.first, range.second) == 1) {
92
93 const JProductIntegration_t& ps = detector[range.first->second];
94
95 if (is_optical_module(ps.container.getPBS()) ||
96 is_base_module (ps.container.getPBS())) { location.position = ps.position; }
97 else if (is_string (ps.container.getPBS())) { location.floor = ps.position; }
98 else if (is_detector (ps.container.getPBS())) { location.string = ps.position; }
99
100 upi = ps.container.getUPI();
101
102 } else {
103
104 break;
105 }
106 }
107
108 if (i == pbs.end()) {
109
110 std::map<JUPI_t, JLocation_t>::insert(make_pair(product.content.getUPI(), location));
111
112 return true;
113 }
114 }
115 }
116
117 return false;
118 }
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
bool is_base_module(const JPBS_t &pbs)
Test if given PBS corresponds to a base module.
Definition JPBS_t.hh:291
bool is_string(const JPBS_t &pbs)
Test if given PBS corresponds to a string.
Definition JPBS_t.hh:267
bool is_detector(const JPBS_t &pbs)
Test if given PBS corresponds to a detector.
Definition JPBS_t.hh:255
bool is_optical_module(const JPBS_t &pbs)
Test if given PBS corresponds to a optical module.
Definition JPBS_t.hh:279
std::pair< map_type::const_iterator, map_type::const_iterator > range_type

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