CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

virtual int binIndex (T z) const
 returns an index in the valid range for the bin closest to Z More...
 
virtual int binIndex (int i) const
 returns an index in the valid range More...
 
virtual T binPosition (int ind) const
 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

Definition at line 18 of file GeneralBinFinderInZforGeometricSearchDet.h.

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

Definition at line 20 of file GeneralBinFinderInZforGeometricSearchDet.h.

22  :
23  theNbins( last-first -1) // -1!
24  {
25  theBins.reserve(theNbins);
26  theBorders.reserve(theNbins);
27  for (auto i=first; i<last-1; i++) {
28  theBins.push_back((**i).position().z());
29  theBorders.push_back(((**i).position().z() +
30  (**(i+1)).position().z()) / 2.);
31  }
32  assert(theNbins==int(theBorders.size()));
33 
34  theZOffset = theBorders.front();
35  theZStep = (theBorders.back() - theBorders.front()) / (theNbins-1);
36  theInvZStep = 1./theZStep;
37  }
int i
Definition: DBlmapReader.cc:9
assert(m_qm.get())

Member Function Documentation

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

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

Implements BaseBinFinder< T >.

Definition at line 40 of file GeneralBinFinderInZforGeometricSearchDet.h.

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

40  {
41  int bin = int((z-theZOffset)*theInvZStep)+1;
42  if (bin<=0) return 0;
43  if (bin>=theNbins) return theNbins;
44 
45  // check left border
46  if ( z < theBorders[bin-1]) {
47  // z is to the left of the left border, the correct bin is left
48  for (auto i=bin-1; i>0; i--) {
49  if ( z > theBorders[i-1]) 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]) return i;
59  }
60  return theNbins;
61  }
62  // if we arrive here it means that the bin is ok
63  return bin;
64  }
int i
Definition: DBlmapReader.cc:9
template<class T>
virtual int GeneralBinFinderInZforGeometricSearchDet< T >::binIndex ( int  i) const
inlinevirtual

returns an index in the valid range

Implements BaseBinFinder< T >.

Definition at line 67 of file GeneralBinFinderInZforGeometricSearchDet.h.

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

the middle of the bin.

Implements BaseBinFinder< T >.

Definition at line 72 of file GeneralBinFinderInZforGeometricSearchDet.h.

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

Member Data Documentation

template<class T>
std::vector<T> GeneralBinFinderInZforGeometricSearchDet< T >::theBins
private
template<class T>
std::vector<float> GeneralBinFinderInZforGeometricSearchDet< T >::theBorders
private
template<class T>
T GeneralBinFinderInZforGeometricSearchDet< T >::theInvZStep =0
private
template<class T>
int GeneralBinFinderInZforGeometricSearchDet< T >::theNbins =0
private
template<class T>
T GeneralBinFinderInZforGeometricSearchDet< T >::theZOffset =0
private
template<class T>
T GeneralBinFinderInZforGeometricSearchDet< T >::theZStep =0
private