CMS 3D CMS Logo

GenericBinFinderInZ< T, G > Class Template Reference

A Z bin finder for a non-periodic group of detectors. More...

#include <Utilities/BinningTools/interface/GenericBinFinderInZ.h>

Inheritance diagram for GenericBinFinderInZ< T, G >:

BaseBinFinder< T >

List of all members.

Public Types

typedef std::vector< const G * >
::const_iterator 
ConstItr

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.
 GenericBinFinderInZ (ConstItr first, ConstItr last)
 GenericBinFinderInZ ()

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 G>
class GenericBinFinderInZ< T, G >

A Z bin finder for a non-periodic group of detectors.

The template argument G should be something with a surface() method, such as a GeomDet or a GeometricSearchDet

Definition at line 16 of file GenericBinFinderInZ.h.


Member Typedef Documentation

template<class T, class G>
typedef std::vector<const G*>::const_iterator GenericBinFinderInZ< T, G >::ConstItr

Definition at line 18 of file GenericBinFinderInZ.h.


Constructor & Destructor Documentation

template<class T, class G>
GenericBinFinderInZ< T, G >::GenericBinFinderInZ (  )  [inline]

Definition at line 19 of file GenericBinFinderInZ.h.

00019 : theNbins(0), theZStep(0), theZOffset(0) {}

template<class T, class G>
GenericBinFinderInZ< T, G >::GenericBinFinderInZ ( ConstItr  first,
ConstItr  last 
) [inline]

Definition at line 21 of file GenericBinFinderInZ.h.

References i, GenericBinFinderInZ< T, G >::theBins, GenericBinFinderInZ< T, G >::theBorders, GenericBinFinderInZ< T, G >::theNbins, GenericBinFinderInZ< T, G >::theZOffset, and GenericBinFinderInZ< T, G >::theZStep.

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


Member Function Documentation

template<class T, class G>
virtual int GenericBinFinderInZ< T, G >::binIndex ( int  i  )  const [inline, virtual]

returns an index in the valid range

Implements BaseBinFinder< T >.

Definition at line 68 of file GenericBinFinderInZ.h.

References max, min, and GenericBinFinderInZ< T, G >::theNbins.

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

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

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

Implements BaseBinFinder< T >.

Definition at line 36 of file GenericBinFinderInZ.h.

References i, GenericBinFinderInZ< T, G >::theBorders, GenericBinFinderInZ< T, G >::theNbins, GenericBinFinderInZ< T, G >::theZOffset, and GenericBinFinderInZ< T, G >::theZStep.

Referenced by GenericBinFinderInZ< T, G >::binPosition(), and MuDetRod::compatibleDets().

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

template<class T, class G>
virtual T GenericBinFinderInZ< T, G >::binPosition ( int  ind  )  const [inline, virtual]

the middle of the bin.

Implements BaseBinFinder< T >.

Definition at line 73 of file GenericBinFinderInZ.h.

References GenericBinFinderInZ< T, G >::binIndex(), and GenericBinFinderInZ< T, G >::theBins.

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

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

Definition at line 77 of file GenericBinFinderInZ.h.

Referenced by GenericBinFinderInZ< T, G >::twoPi().

00077 { return 3.141592653589793238;}

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

Definition at line 78 of file GenericBinFinderInZ.h.

References GenericBinFinderInZ< T, G >::pi().

00078 { return 2.*pi();}


Member Data Documentation

template<class T, class G>
std::vector<T> GenericBinFinderInZ< T, G >::theBins [private]

Definition at line 86 of file GenericBinFinderInZ.h.

Referenced by GenericBinFinderInZ< T, G >::binPosition(), and GenericBinFinderInZ< T, G >::GenericBinFinderInZ().

template<class T, class G>
std::vector<float> GenericBinFinderInZ< T, G >::theBorders [private]

Definition at line 85 of file GenericBinFinderInZ.h.

Referenced by GenericBinFinderInZ< T, G >::binIndex(), and GenericBinFinderInZ< T, G >::GenericBinFinderInZ().

template<class T, class G>
int GenericBinFinderInZ< T, G >::theNbins [private]

Definition at line 82 of file GenericBinFinderInZ.h.

Referenced by GenericBinFinderInZ< T, G >::binIndex(), and GenericBinFinderInZ< T, G >::GenericBinFinderInZ().

template<class T, class G>
T GenericBinFinderInZ< T, G >::theZOffset [private]

Definition at line 84 of file GenericBinFinderInZ.h.

Referenced by GenericBinFinderInZ< T, G >::binIndex(), and GenericBinFinderInZ< T, G >::GenericBinFinderInZ().

template<class T, class G>
T GenericBinFinderInZ< T, G >::theZStep [private]

Definition at line 83 of file GenericBinFinderInZ.h.

Referenced by GenericBinFinderInZ< T, G >::binIndex(), and GenericBinFinderInZ< T, G >::GenericBinFinderInZ().


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