Belle II Software development
SectorsOnSensor< sectorID > Class Template Reference

This class associates to an ordered pairs of normalized local coordinates a compact sector id. More...

#include <SectorsOnSensor.h>

Public Member Functions

 SectorsOnSensor ()
 Default constructor needed for the vector traits.
 
 SectorsOnSensor (const std::vector< double > &normalizedUsup, const std::vector< double > &normalizedVsup, const std::vector< std::vector< FullSecID > > &fullSecIDs)
 Useful constructor.
 
 ~SectorsOnSensor ()
 Destructor of the object.
 
FullSecID operator() (double normalizedU, double normalizedV) const
 Returns the Full Sector ID of the sector on this sensor that contains the point at normalized coordinates U, V.
 
void get (std::vector< double > *normalizedUsup, std::vector< double > *normalizedVsup, std::vector< std::vector< unsigned int > > *secID) const
 copy the vector members on the vector pointed from the arguments.
 
bool areCoordinatesValid (double normalizedU, double normalizedV) const
 check if using operator() would be safe (true if it is safe):
 
sectorID & operator[] (int index)
 minimal vector semantics to access the compactSecIDs vector using the sector
 
const sectorID & operator[] (int index) const
 minimal vector semantics to access the compactSecIDs vector
 
size_t size () const
 minimal vector semantics to get the size of the compactSecIDs vector
 
void resize (size_t n)
 minimal vector semantics to resize the compactSecIDs vector
 
bool updateSubLayerID (FullSecID sector, int sublayer)
 update the sublayer id for the sector with the given FullSecID, the sublayer id is ignored when searching for the sector
 
const std::vector< sectorID > & getCompactSecIDs () const
 JKL: for testing - get all compactSecIDs:
 

Private Types

typedef unsigned char index_t
 Typedef for the internal numbering of rows and columns of the sectors.
 

Private Attributes

std::map< double, index_tm_normalizedUsup
 Upper limits of the sectors in normalized U coordinates.
 
std::map< double, index_tm_normalizedVsup
 Upper limits of the sectors in normalized V coordinates.
 
std::vector< std::vector< FullSecID > > m_fullSecIDs
 The 2D array of the full sec ID is stored in this member.
 
std::vector< sectorID > m_compactSecIDs
 The 1D array of the compact ID is stored in this member.
 

Detailed Description

template<class sectorID>
class Belle2::SectorsOnSensor< sectorID >

This class associates to an ordered pairs of normalized local coordinates a compact sector id.

Definition at line 26 of file SectorsOnSensor.h.

Member Typedef Documentation

◆ index_t

template<class sectorID>
typedef unsigned char index_t
private

Typedef for the internal numbering of rows and columns of the sectors.

Definition at line 29 of file SectorsOnSensor.h.

Constructor & Destructor Documentation

◆ SectorsOnSensor() [1/2]

template<class sectorID>
SectorsOnSensor ( )
inline

Default constructor needed for the vector traits.

Definition at line 48 of file SectorsOnSensor.h.

48{}

◆ SectorsOnSensor() [2/2]

template<class sectorID>
SectorsOnSensor ( const std::vector< double > & normalizedUsup,
const std::vector< double > & normalizedVsup,
const std::vector< std::vector< FullSecID > > & fullSecIDs )
inline

Useful constructor.

Definition at line 51 of file SectorsOnSensor.h.

55 {
56 index_t index = 0;
57
58 for (auto Vsup : normalizedVsup)
59 m_normalizedVsup.insert({Vsup, index++});
60 m_normalizedVsup.insert({FLT_MAX, index++});
61
62 index = 0;
63 for (auto Usup : normalizedUsup)
64 m_normalizedUsup.insert({Usup, index++});
65 m_normalizedUsup.insert({FLT_MAX, index++});
66
67 m_fullSecIDs = fullSecIDs;
68
69 }

◆ ~SectorsOnSensor()

template<class sectorID>
~SectorsOnSensor ( )
inline

Destructor of the object.

Definition at line 72 of file SectorsOnSensor.h.

72{};

Member Function Documentation

◆ areCoordinatesValid()

template<class sectorID>
bool areCoordinatesValid ( double normalizedU,
double normalizedV ) const
inline

check if using operator() would be safe (true if it is safe):

Definition at line 130 of file SectorsOnSensor.h.

131 {
132 // check u and v
133 if ((normalizedU < 0.) or (normalizedU > 1.)) return false;
134 if ((normalizedV < 0.) or (normalizedV > 1.)) return false;
135 // check internal map for problems:
136 if (m_normalizedUsup.upper_bound(normalizedU) == m_normalizedUsup.end())
137 return false;
138
139 if (m_normalizedVsup.upper_bound(normalizedV) == m_normalizedVsup.end())
140 return false;
141
142 return true;
143 }

◆ get()

template<class sectorID>
void get ( std::vector< double > * normalizedUsup,
std::vector< double > * normalizedVsup,
std::vector< std::vector< unsigned int > > * secID ) const
inline

copy the vector members on the vector pointed from the arguments.

Parameters
normalizedUsup
normalizedVsup
secID

Definition at line 106 of file SectorsOnSensor.h.

109 {
110 // let us copy the sorted map Usup
111 for (auto uIndexPair : m_normalizedUsup)
112 if (uIndexPair.first != FLT_MAX)
113 normalizedUsup->push_back(uIndexPair.first);
114
115 // let us copy the sorted map Vsup
116 for (auto vIndexPair : m_normalizedVsup)
117 if (vIndexPair.first != FLT_MAX)
118 normalizedVsup->push_back(vIndexPair.first);
119
120 // and finally we copy the array of full sec ids
121 for (auto col : m_fullSecIDs) {
122 std::vector< unsigned int > tmp_col;
123 for (auto id : col)
124 tmp_col.push_back(id);
125 secID->push_back(tmp_col);
126 }
127 }

◆ getCompactSecIDs()

template<class sectorID>
const std::vector< sectorID > & getCompactSecIDs ( ) const
inline

JKL: for testing - get all compactSecIDs:

Definition at line 178 of file SectorsOnSensor.h.

178{ return m_compactSecIDs; }

◆ operator()()

template<class sectorID>
FullSecID operator() ( double normalizedU,
double normalizedV ) const
inline

Returns the Full Sector ID of the sector on this sensor that contains the point at normalized coordinates U, V.

Definition at line 76 of file SectorsOnSensor.h.

77 {
78
79 if (normalizedU < 0. or normalizedU > 1.)
80 return FullSecID(0);
81 if (normalizedV < 0. or normalizedV > 1.)
82 return FullSecID(0);
83
84 auto uKeyVal = m_normalizedUsup.upper_bound(normalizedU);
85 if (uKeyVal == m_normalizedUsup.end())
86 return FullSecID(0);
87
88 auto vKeyVal = m_normalizedVsup.upper_bound(normalizedV);
89 if (vKeyVal == m_normalizedVsup.end())
90 return FullSecID(0);
91
92
93 auto uIndex = uKeyVal->second;
94 auto vIndex = vKeyVal->second;
95
96 return m_fullSecIDs[ uIndex ][ vIndex ];
97 }

◆ operator[]() [1/2]

template<class sectorID>
sectorID & operator[] ( int index)
inline

minimal vector semantics to access the compactSecIDs vector using the sector

Parameters
indexfrom the fullSecId

Definition at line 148 of file SectorsOnSensor.h.

148{ return m_compactSecIDs[index] ;};

◆ operator[]() [2/2]

template<class sectorID>
const sectorID & operator[] ( int index) const
inline

minimal vector semantics to access the compactSecIDs vector

Definition at line 151 of file SectorsOnSensor.h.

151{ return m_compactSecIDs[index] ;};

◆ resize()

template<class sectorID>
void resize ( size_t n)
inline

minimal vector semantics to resize the compactSecIDs vector

Definition at line 157 of file SectorsOnSensor.h.

157{ m_compactSecIDs.resize(n); };

◆ size()

template<class sectorID>
size_t size ( ) const
inline

minimal vector semantics to get the size of the compactSecIDs vector

Definition at line 154 of file SectorsOnSensor.h.

154{ return m_compactSecIDs.size(); };

◆ updateSubLayerID()

template<class sectorID>
bool updateSubLayerID ( FullSecID sector,
int sublayer )
inline

update the sublayer id for the sector with the given FullSecID, the sublayer id is ignored when searching for the sector

Parameters
sectorFullSecID of the sector to be updated
sublayer: the new value for the sublayer ID, the new SubLayerID will be 0 if sublayer==0, and will be 1 else

WARNING: the comparison will ignore the sublayer id

Definition at line 163 of file SectorsOnSensor.h.

164 {
165 for (auto& v : m_fullSecIDs) {
166 for (FullSecID& thisSecID : v) {
168 if (sector.equalIgnoreSubLayerID(thisSecID)) {
169 thisSecID = FullSecID(thisSecID.getVxdID(), (bool)sublayer, thisSecID.getSecID());
170 return true;
171 }
172 }
173 }
174 return false;
175 }

Member Data Documentation

◆ m_compactSecIDs

template<class sectorID>
std::vector< sectorID > m_compactSecIDs
private

The 1D array of the compact ID is stored in this member.

It is indexed by the sector component on the FullSecID

Definition at line 43 of file SectorsOnSensor.h.

◆ m_fullSecIDs

template<class sectorID>
std::vector< std::vector < FullSecID > > m_fullSecIDs
private

The 2D array of the full sec ID is stored in this member.

It is indexed by discretized normalized U V pairs

Definition at line 39 of file SectorsOnSensor.h.

◆ m_normalizedUsup

template<class sectorID>
std::map<double, index_t> m_normalizedUsup
private

Upper limits of the sectors in normalized U coordinates.

Definition at line 32 of file SectorsOnSensor.h.

◆ m_normalizedVsup

template<class sectorID>
std::map<double, index_t> m_normalizedVsup
private

Upper limits of the sectors in normalized V coordinates.

Definition at line 35 of file SectorsOnSensor.h.


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