|
ATLAS Offline Software
|
Go to the documentation of this file.
9 #ifndef TRKDETDESCRUTILS_BINNINGDATA_H
10 #define TRKDETDESCRUTILS_BINNINGDATA_H
13 #include "GaudiKernel/GaudiException.h"
60 std::vector<std::pair<int, float>>
hbounds;
78 std::vector<float> bBoundaries = std::vector<float>())
85 ,
step(bStep != 0. ? bStep : 1.)
103 const std::vector<std::pair<int, float>>& bBoundaries)
135 return (position.perp());
137 return (position.perp() * position.phi());
139 return (position.eta());
159 return (std::pair<double, double>(lposition[0], lposition[0] *
cos(fabs(
refphi - lposition[1]))));
165 return (std::pair<double, double>(position.perp(), position.perp() *
cos(fabs(position.phi() -
refphi))));
180 std::pair<double, double> valH =
valueH(position);
181 float valmin =
hbounds.front().first == 0 ? valH.first : valH.second;
182 float valmax =
hbounds.back().first == 0 ? valH.first : valH.second;
195 std::pair<double, double> valH =
valueH(lp);
196 float valmin =
hbounds.front().first == 0 ? valH.first : valH.second;
197 float valmax =
hbounds.back().first == 0 ? valH.first : valH.second;
239 float nextval =
value(probe);
260 int bin = (nextval -
val) > 0. ? bin0 + 1 : bin0 - 1;
275 nextval =
valueH(probe).second;
280 nextval =
valueH(probe).second;
291 float dist = std::fabs(
dd) > 1.e-06 ? (bval -
val) /
dd : 1.e06;
292 return std::pair<size_t, float>(
bin, dist);
330 return (bData.
bins - 1);
349 return bData.
bins - 1;
352 float bDist =
value - (bData.
min + (leadbin + 1) * bData.
step);
353 int addon =
int(bDist / bData.
subStep) ? 0 : 1;
355 return leadbin * 2 + addon;
375 std::vector<float>::const_iterator vIter = bData.
boundaries.begin();
378 if ((*vIter) >
value)
389 value += 2 * acos(-1.);
392 value -= 2 * acos(-1.);
405 while (nabove - nbelow > 1) {
406 middle = (nabove + nbelow) / 2;
422 if ((bData.
hbounds.back().first == 0 ?
val.first :
val.second) >= bData.
max)
425 if (bData.
hbounds.size() < 10) {
426 std::vector<std::pair<int, float>>::const_iterator vBeg = bData.
hbounds.begin();
427 std::vector<std::pair<int, float>>::const_iterator vIter = vBeg + 1;
428 for (; vIter != bData.
hbounds.end(); ++vIter)
429 if ((*vIter).second > ((*vIter).first == 0 ?
val.first :
val.second))
431 return (vIter != bData.
hbounds.end() ? vIter - vBeg - 1 : bData.
bins - 1);
441 while (nabove - nbelow > 1) {
442 middle = (nabove + nbelow) / 2;
443 float valm = bData.
hbounds[middle].first == 0 ?
val.first :
val.second;
444 if (valm == bData.
hbounds[middle].second) {
448 if (valm < bData.
hbounds[middle].second)
454 if (nbelow > bData.
bins - 1)
455 return bData.
bins - 1;
BinningType type
holding all the data for binning calculatuion
size_t searchGlobal(const Amg::Vector3D &position) const
generic search from a 3D position
BinningData(BinningData &&)=default
bool inside(const Amg::Vector2D &lp) const
Check if bin is inside from Vector2D.
Eigen::Matrix< double, 2, 1 > Vector2D
std::pair< float, float > valueH(const Amg::Vector3D &position) const
take float values for binH
float gaugePhi(float phi) const
gauge phi
BinningData & operator=(BinningData &&)=default
static size_t searchInVectorWithMixedBoundary(std::pair< float, float > val, const BinningData &bData)
Search in mixed vector - linear in O-10 bins, otherwise binary.
size_t next(const Amg::Vector3D &position, const Amg::Vector3D &dir) const
the next bin : gives -1 if the next one is outside
static size_t binarySearchWithBoundary(float value, const BinningData &bData)
A binary search with underflow/overflow - faster than vector search for O(50) objects.
bool inside(const Amg::Vector3D &position) const
Check if bin is inside from Vector3D.
LayerOrder orderDirection(const Amg::Vector3D &position, const Amg::Vector3D &dir) const
layer order is needed for value H binning
BinningValue
how to take the global / local position
size_t entry(const Amg::Vector3D &position) const
the entry bin
static size_t searchInVectorWithBoundary(float value, const BinningData &bData)
Linear search in vector - superior in O(10) searches: arbitraty 2.
size_t searchH(std::pair< double, double > value) const
generic search - forwards to correct function pointer
size_t(* m_functionPtr)(float, const BinningData &)
the pointer to the function to be used
std::pair< float, float > valueH(const Amg::Vector2D &lposition) const
take float values for binH
BinningData(BinningOption bOption, float bRefPhi, const std::vector< std::pair< int, float >> &bBoundaries)
Constructor for binH type : non-equidistant binning assumed.
std::vector< float > boundaries
static size_t searchBiequidistantWithBoundary(float value, const BinningData &bData)
Biequidistant search : biequidist 1.
std::vector< std::pair< int, float > > hbounds
static size_t searchEaquidstantWithBoundary(float value, const BinningData &bData)
Equidistant search : equidist 0.
Ensure that the ATLAS eigen extensions are properly loaded.
size_t search(float value) const
generic search - forwards to correct function pointer
BinningData(const BinningData &)=default
BinningData & operator=(const BinningData &)=default
BinningData(BinningType bType, BinningOption bOption, BinningValue bValue, size_t bBins, float bMin, float bMax, float bStep, float bSubStep=0, std::vector< float > bBoundaries=std::vector< float >())
Constructor with arguments.
Eigen::Matrix< double, 3, 1 > Vector3D
size_t searchLocal(const Amg::Vector2D &lposition) const
generic search from a 2D position — corresponds to local coordinate schema
size_t(* m_mixPtr)(std::pair< float, float >, const BinningData &)
float value(const Amg::Vector3D &position) const
take the right float value
float value(const Amg::Vector2D &lposition) const
take the right float value - assumes the correct local position expression
float binPosition(size_t bin, float pos) const
bin->BinningValue navigation : pos=+-1.
std::pair< size_t, float > distanceToNext(const Amg::Vector3D &position, const Amg::Vector3D &dir) const
distance to the next bin : gives -1 if the next one is outside
BinningOption
enum BinValue