CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Private Attributes

GeneralBinFinderInZforGeometricSearchDet< T > Class Template Reference

#include <GeneralBinFinderInZforGeometricSearchDet.h>

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

List of all members.

Public Member Functions

virtual int binIndex (T z) const
 returns an index in the valid range for the bin closest to Z
virtual int binIndex (int i) const
 returns an index in the valid range
virtual T binPosition (int ind) const
 the middle of the bin.
 GeneralBinFinderInZforGeometricSearchDet ()
 GeneralBinFinderInZforGeometricSearchDet (std::vector< const GeometricSearchDet * >::const_iterator first, std::vector< const GeometricSearchDet * >::const_iterator last)

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

Definition at line 16 of file GeneralBinFinderInZforGeometricSearchDet.h.

: theNbins(0), theZStep(0), theZOffset(0) {}
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.

                                                                               :
    theNbins( last-first)
  {
    theBins.reserve(theNbins);
    for (std::vector<const GeometricSearchDet*>::const_iterator i=first; i<last-1; i++) {
      theBins.push_back((**i).position().z());
      theBorders.push_back(((**i).position().z() + 
                            (**(i+1)).position().z()) / 2.);
    }

    theZOffset = theBorders.front(); 
    theZStep = (theBorders.back() - theBorders.front()) / (theNbins-2);
  }

Member Function Documentation

template<class T>
virtual int GeneralBinFinderInZforGeometricSearchDet< T >::binIndex ( T  z) const [inline, virtual]

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(), GeneralBinFinderInZforGeometricSearchDet< float >::binPosition(), and TIBLayer::computeCrossings().

                                   {
    int bin = binIndex( int((z-theZOffset)/theZStep)+1);
    
    // check left border
    if (bin > 0) {
      if ( z < theBorders[bin-1]) {
        // z is to the left of the left border, the correct bin is left
        for (int i=bin-1; ; i--) {
          if (i <= 0) return 0;  
          if ( z > theBorders[i-1]) return i;
        }
      }
    } 
    else return 0;
    
    // check right border
    if (bin < theNbins-1) {
      if ( z > theBorders[bin]) {
        // z is to the right of the right border, the correct bin is right
        for (int i=bin+1; ; i++) {
          if (i >= theNbins-1) return theNbins-1;  
          if ( z < theBorders[i]) return i;
        }
      }
    }
    else return theNbins-1;
    
    // if we arrive here it means that the bin is ok 
    return bin;
  }
template<class T>
virtual int GeneralBinFinderInZforGeometricSearchDet< T >::binIndex ( int  i) const [inline, virtual]

returns an index in the valid range

Implements BaseBinFinder< T >.

Definition at line 67 of file GeneralBinFinderInZforGeometricSearchDet.h.

                                     {
    return std::min( std::max( i, 0), theNbins-1);
  }
template<class T>
virtual T GeneralBinFinderInZforGeometricSearchDet< T >::binPosition ( int  ind) const [inline, virtual]

the middle of the bin.

Implements BaseBinFinder< T >.

Definition at line 72 of file GeneralBinFinderInZforGeometricSearchDet.h.

                                        {
    return theBins[binIndex(ind)];
  }
template<class T>
static double GeneralBinFinderInZforGeometricSearchDet< T >::pi ( ) [inline, static]

Definition at line 76 of file GeneralBinFinderInZforGeometricSearchDet.h.

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

{ return 3.141592653589793238;}
template<class T>
static double GeneralBinFinderInZforGeometricSearchDet< T >::twoPi ( ) [inline, static]

Definition at line 77 of file GeneralBinFinderInZforGeometricSearchDet.h.

{ return 2.*pi();}

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]