CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
GeneralBinFinderInZforGeometricSearchDet< T > Class Template Reference

#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 ()
 

Static Public Member Functions

static double pi ()
 
static double twoPi ()
 

Private Attributes

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

Detailed Description

template<class T>
class GeneralBinFinderInZforGeometricSearchDet< T >

Definition at line 13 of file GeneralBinFinderInZforGeometricSearchDet.h.

Constructor & Destructor Documentation

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

Definition at line 18 of file GeneralBinFinderInZforGeometricSearchDet.h.

20  :
22  {
23  theBins.reserve(theNbins);
24  for (std::vector<const GeometricSearchDet*>::const_iterator i=first; i<last-1; i++) {
25  theBins.push_back((**i).position().z());
26  theBorders.push_back(((**i).position().z() +
27  (**(i+1)).position().z()) / 2.);
28  }
29 
30  theZOffset = theBorders.front();
31  theZStep = (theBorders.back() - theBorders.front()) / (theNbins-2);
32  }
int i
Definition: DBlmapReader.cc:9
bool first
Definition: L1TdeRCT.cc:79

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 35 of file GeneralBinFinderInZforGeometricSearchDet.h.

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

35  {
36  int bin = binIndex( int((z-theZOffset)/theZStep)+1);
37 
38  // check left border
39  if (bin > 0) {
40  if ( z < theBorders[bin-1]) {
41  // z is to the left of the left border, the correct bin is left
42  for (int i=bin-1; ; i--) {
43  if (i <= 0) return 0;
44  if ( z > theBorders[i-1]) return i;
45  }
46  }
47  }
48  else return 0;
49 
50  // check right border
51  if (bin < theNbins-1) {
52  if ( z > theBorders[bin]) {
53  // z is to the right of the right border, the correct bin is right
54  for (int i=bin+1; ; i++) {
55  if (i >= theNbins-1) return theNbins-1;
56  if ( z < theBorders[i]) return i;
57  }
58  }
59  }
60  else return theNbins-1;
61 
62  // if we arrive here it means that the bin is ok
63  return bin;
64  }
int i
Definition: DBlmapReader.cc:9
float float float z
virtual int binIndex(T z) const
returns an index in the valid range for the bin closest to Z
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.

67  {
68  return std::min( std::max( i, 0), theNbins-1);
69  }
int i
Definition: DBlmapReader.cc:9
const T & max(const T &a, const T &b)
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
template<class T>
static double GeneralBinFinderInZforGeometricSearchDet< T >::pi ( )
inlinestatic

Definition at line 76 of file GeneralBinFinderInZforGeometricSearchDet.h.

Referenced by GeneralBinFinderInZforGeometricSearchDet< float >::twoPi().

76 { return 3.141592653589793238;}
template<class T>
static double GeneralBinFinderInZforGeometricSearchDet< T >::twoPi ( )
inlinestatic

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>
int GeneralBinFinderInZforGeometricSearchDet< T >::theNbins
private
template<class T>
T GeneralBinFinderInZforGeometricSearchDet< T >::theZOffset
private
template<class T>
T GeneralBinFinderInZforGeometricSearchDet< T >::theZStep
private