#include <GenericBinFinderInZ.h>
Public Types | |
typedef std::vector< const G * > ::const_iterator | ConstItr |
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. | |
GenericBinFinderInZ () | |
GenericBinFinderInZ (ConstItr first, ConstItr last) | |
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 |
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.
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.
: theNbins(0), theZStep(0), theZOffset(0) {}
GenericBinFinderInZ< T, G >::GenericBinFinderInZ | ( | ConstItr | first, |
ConstItr | last | ||
) | [inline] |
Definition at line 21 of file GenericBinFinderInZ.h.
: theNbins( last-first) { theBins.reserve(theNbins); for (ConstItr 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); }
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.
Referenced by GenericBinFinderInZ< float, GeomDet >::binIndex(), GenericBinFinderInZ< float, GeomDet >::binPosition(), and MuDetRod::compatibleDets().
{ 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; }
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.
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.
static double GenericBinFinderInZ< T, G >::pi | ( | ) | [inline, static] |
Definition at line 77 of file GenericBinFinderInZ.h.
Referenced by GenericBinFinderInZ< float, GeomDet >::twoPi().
{ return 3.141592653589793238;}
static double GenericBinFinderInZ< T, G >::twoPi | ( | ) | [inline, static] |
Definition at line 78 of file GenericBinFinderInZ.h.
{ return 2.*pi();}
std::vector<T> GenericBinFinderInZ< T, G >::theBins [private] |
Definition at line 86 of file GenericBinFinderInZ.h.
Referenced by GenericBinFinderInZ< float, GeomDet >::binPosition(), and GenericBinFinderInZ< float, GeomDet >::GenericBinFinderInZ().
std::vector<float> GenericBinFinderInZ< T, G >::theBorders [private] |
Definition at line 85 of file GenericBinFinderInZ.h.
Referenced by GenericBinFinderInZ< float, GeomDet >::binIndex(), and GenericBinFinderInZ< float, GeomDet >::GenericBinFinderInZ().
int GenericBinFinderInZ< T, G >::theNbins [private] |
Definition at line 82 of file GenericBinFinderInZ.h.
Referenced by GenericBinFinderInZ< float, GeomDet >::binIndex(), and GenericBinFinderInZ< float, GeomDet >::GenericBinFinderInZ().
T GenericBinFinderInZ< T, G >::theZOffset [private] |
Definition at line 84 of file GenericBinFinderInZ.h.
Referenced by GenericBinFinderInZ< float, GeomDet >::binIndex(), and GenericBinFinderInZ< float, GeomDet >::GenericBinFinderInZ().
T GenericBinFinderInZ< T, G >::theZStep [private] |
Definition at line 83 of file GenericBinFinderInZ.h.
Referenced by GenericBinFinderInZ< float, GeomDet >::binIndex(), and GenericBinFinderInZ< float, GeomDet >::GenericBinFinderInZ().