CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
GeneralBinFinderInZforGeometricSearchDet< T > Class Template Referencefinal

#include <GeneralBinFinderInZforGeometricSearchDet.h>

Inheritance diagram for GeneralBinFinderInZforGeometricSearchDet< T >:
BaseBinFinder< T >

Public Member Functions

int binIndex (T z) const override
 returns an index in the valid range for the bin closest to Z More...
 
int binIndex (int i) const override
 returns an index in the valid range More...
 
T binPosition (int ind) const override
 the middle of the bin. More...
 
 GeneralBinFinderInZforGeometricSearchDet ()
 
 GeneralBinFinderInZforGeometricSearchDet (std::vector< const GeometricSearchDet *>::const_iterator first, std::vector< const GeometricSearchDet *>::const_iterator last)
 
- Public Member Functions inherited from BaseBinFinder< T >
 BaseBinFinder ()
 
virtual ~BaseBinFinder ()
 

Private Attributes

std::vector< TtheBins
 
std::vector< float > theBorders
 
T theInvZStep = 0
 
int theNbins = 0
 
T theZOffset = 0
 
T theZStep = 0
 

Detailed Description

template<class T>
class GeneralBinFinderInZforGeometricSearchDet< T >

Definition at line 15 of file GeneralBinFinderInZforGeometricSearchDet.h.

Constructor & Destructor Documentation

◆ GeneralBinFinderInZforGeometricSearchDet() [1/2]

Definition at line 17 of file GeneralBinFinderInZforGeometricSearchDet.h.

17 {}

◆ GeneralBinFinderInZforGeometricSearchDet() [2/2]

template<class T>
GeneralBinFinderInZforGeometricSearchDet< T >::GeneralBinFinderInZforGeometricSearchDet ( std::vector< const GeometricSearchDet *>::const_iterator  first,
std::vector< const GeometricSearchDet *>::const_iterator  last 
)
inline

Definition at line 19 of file GeneralBinFinderInZforGeometricSearchDet.h.

Member Function Documentation

◆ binIndex() [1/2]

template<class T>
int GeneralBinFinderInZforGeometricSearchDet< T >::binIndex ( T  z) const
inlineoverridevirtual

returns an index in the valid range for the bin closest to Z

Implements BaseBinFinder< T >.

Definition at line 37 of file GeneralBinFinderInZforGeometricSearchDet.h.

Referenced by GeneralBinFinderInZforGeometricSearchDet< float >::binPosition(), and TIBLayer::computeIndexes().

37  {
38  int bin = int((z - theZOffset) * theInvZStep) + 1;
39  if (bin <= 0)
40  return 0;
41  if (bin >= theNbins)
42  return theNbins;
43 
44  // check left border
45  if (z < theBorders[bin - 1]) {
46  // z is to the left of the left border, the correct bin is left
47  for (auto i = bin - 1; i > 0; i--) {
48  if (z > theBorders[i - 1])
49  return i;
50  }
51  return 0;
52  }
53 
54  // check right border
55  if (z > theBorders[bin]) {
56  // z is to the right of the right border, the correct bin is right
57  for (int i = bin + 1; i < theNbins; i++) {
58  if (z < theBorders[i])
59  return i;
60  }
61  return theNbins;
62  }
63  // if we arrive here it means that the bin is ok
64  return bin;
65  }

◆ binIndex() [2/2]

template<class T>
int GeneralBinFinderInZforGeometricSearchDet< T >::binIndex ( int  i) const
inlineoverridevirtual

◆ binPosition()

template<class T>
T GeneralBinFinderInZforGeometricSearchDet< T >::binPosition ( int  ind) const
inlineoverridevirtual

the middle of the bin.

Implements BaseBinFinder< T >.

Definition at line 71 of file GeneralBinFinderInZforGeometricSearchDet.h.

71 { return theBins[binIndex(ind)]; }
int binIndex(T z) const override
returns an index in the valid range for the bin closest to Z

Member Data Documentation

◆ theBins

template<class T>
std::vector<T> GeneralBinFinderInZforGeometricSearchDet< T >::theBins
private

◆ theBorders

template<class T>
std::vector<float> GeneralBinFinderInZforGeometricSearchDet< T >::theBorders
private

◆ theInvZStep

template<class T>
T GeneralBinFinderInZforGeometricSearchDet< T >::theInvZStep = 0
private

◆ theNbins

template<class T>
int GeneralBinFinderInZforGeometricSearchDet< T >::theNbins = 0
private

◆ theZOffset

template<class T>
T GeneralBinFinderInZforGeometricSearchDet< T >::theZOffset = 0
private

◆ theZStep

template<class T>
T GeneralBinFinderInZforGeometricSearchDet< T >::theZStep = 0
private