#include <Utilities/BinningTools/interface/GenericBinFinderInZ.h>
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 |
T | theZOffset |
T | theZStep |
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.
typedef std::vector<const G*>::const_iterator GenericBinFinderInZ< T, G >::ConstItr |
Definition at line 18 of file GenericBinFinderInZ.h.
GenericBinFinderInZ< T, G >::GenericBinFinderInZ | ( | ) | [inline] |
Definition at line 19 of file GenericBinFinderInZ.h.
00019 : theNbins(0), theZStep(0), theZOffset(0) {}
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 }
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.
virtual int GenericBinFinderInZ< T, G >::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 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 }
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.
static double GenericBinFinderInZ< T, G >::pi | ( | ) | [inline, static] |
Definition at line 77 of file GenericBinFinderInZ.h.
Referenced by GenericBinFinderInZ< T, G >::twoPi().
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();}
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().
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().
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().
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().
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().