CMS 3D CMS Logo

GeneralBinFinderInZforGeometricSearchDet< T > Class Template Reference

#include <TrackingTools/DetLayers/interface/GeneralBinFinderInZforGeometricSearchDet.h>

Inheritance diagram for GeneralBinFinderInZforGeometricSearchDet< T >:

BaseBinFinder< T >

List of all members.

Public Member Functions

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

Static Public Member Functions

static double pi ()
static double twoPi ()

Private Attributes

std::vector< T > theBins
std::vector< float > theBorders
int theNbins
theZOffset
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 (  )  [inline]

Definition at line 16 of file GeneralBinFinderInZforGeometricSearchDet.h.

00016 : 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.

00020                                                                                :
00021     theNbins( last-first)
00022   {
00023     theBins.reserve(theNbins);
00024     for (std::vector<const GeometricSearchDet*>::const_iterator i=first; i<last-1; i++) {
00025       theBins.push_back((**i).position().z());
00026       theBorders.push_back(((**i).position().z() + 
00027                             (**(i+1)).position().z()) / 2.);
00028     }
00029 
00030     theZOffset = theBorders.front(); 
00031     theZStep = (theBorders.back() - theBorders.front()) / (theNbins-2);
00032   }


Member Function Documentation

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.

00067                                      {
00068     return std::min( std::max( i, 0), theNbins-1);
00069   }

template<class T>
virtual int GeneralBinFinderInZforGeometricSearchDet< T >::binIndex ( 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().

00035                                    {
00036     int bin = binIndex( int((z-theZOffset)/theZStep)+1);
00037     
00038     // check left border
00039     if (bin > 0) {
00040       if ( z < theBorders[bin-1]) {
00041         // z is to the left of the left border, the correct bin is left
00042         for (int i=bin-1; ; i--) {
00043           if (i <= 0) return 0;  
00044           if ( z > theBorders[i-1]) return i;
00045         }
00046       }
00047     } 
00048     else return 0;
00049     
00050     // check right border
00051     if (bin < theNbins-1) {
00052       if ( z > theBorders[bin]) {
00053         // z is to the right of the right border, the correct bin is right
00054         for (int i=bin+1; ; i++) {
00055           if (i >= theNbins-1) return theNbins-1;  
00056           if ( z < theBorders[i]) return i;
00057         }
00058       }
00059     }
00060     else return theNbins-1;
00061     
00062     // if we arrive here it means that the bin is ok 
00063     return bin;
00064   }

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.

00072                                         {
00073     return theBins[binIndex(ind)];
00074   }

template<class T>
static double GeneralBinFinderInZforGeometricSearchDet< T >::pi (  )  [inline, static]

Definition at line 76 of file GeneralBinFinderInZforGeometricSearchDet.h.

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

00076 { return 3.141592653589793238;}

template<class T>
static double GeneralBinFinderInZforGeometricSearchDet< T >::twoPi (  )  [inline, static]

Definition at line 77 of file GeneralBinFinderInZforGeometricSearchDet.h.

00077 { return 2.*pi();}


Member Data Documentation

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

Definition at line 85 of file GeneralBinFinderInZforGeometricSearchDet.h.

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

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

Definition at line 84 of file GeneralBinFinderInZforGeometricSearchDet.h.

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

template<class T>
int GeneralBinFinderInZforGeometricSearchDet< T >::theNbins [private]

Definition at line 81 of file GeneralBinFinderInZforGeometricSearchDet.h.

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

template<class T>
T GeneralBinFinderInZforGeometricSearchDet< T >::theZOffset [private]

Definition at line 83 of file GeneralBinFinderInZforGeometricSearchDet.h.

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

template<class T>
T GeneralBinFinderInZforGeometricSearchDet< T >::theZStep [private]

Definition at line 82 of file GeneralBinFinderInZforGeometricSearchDet.h.

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


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:21:11 2009 for CMSSW by  doxygen 1.5.4