CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Attributes
GenericBinFinderInZ< T, G > Class Template Reference

#include <GenericBinFinderInZ.h>

Inheritance diagram for GenericBinFinderInZ< T, G >:
BaseBinFinder< T >

Public Types

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

Public Member Functions

int binIndex (T z) const override
 returns an index in the valid range for the bin closest to Z More...
 
int binIndex (int i) const override
 returns an index in the valid range More...
 
T binPosition (int ind) const override
 the middle of the bin. More...
 
 GenericBinFinderInZ ()
 
 GenericBinFinderInZ (ConstItr first, ConstItr last)
 
- Public Member Functions inherited from BaseBinFinder< T >
 BaseBinFinder ()
 
virtual ~BaseBinFinder ()
 

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 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
template<class T, class G>
GenericBinFinderInZ< T, G >::GenericBinFinderInZ ( ConstItr  first,
ConstItr  last 
)
inline

Definition at line 21 of file GenericBinFinderInZ.h.

21  :
23  {
24  theBins.reserve(theNbins);
25  theBorders.reserve(theNbins-1);
26  for (ConstItr i=first; i<last-1; i++) {
27  theBins.push_back((**i).position().z());
28  theBorders.push_back(((**i).position().z() +
29  (**(i+1)).position().z()) / 2.);
30  }
31  theBins.push_back((**(last-1)).position().z());
32 
33  theZOffset = theBorders.front();
34  theZStep = (theBorders.back() - theBorders.front()) / (theNbins-2);
35  }
std::vector< T > theBins
std::vector< const G * >::const_iterator ConstItr
static int position[264][3]
Definition: ReadPGInfo.cc:509
std::vector< float > theBorders

Member Function Documentation

template<class T, class G>
int GenericBinFinderInZ< T, G >::binIndex ( T  z) const
inlineoverridevirtual

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

Implements BaseBinFinder< T >.

Definition at line 38 of file GenericBinFinderInZ.h.

Referenced by GenericBinFinderInZ< float, GeomDet >::binIndex(), GenericBinFinderInZ< float, GeomDet >::binPosition(), MuDetRod::compatibleDets(), MTDDetTray::compatibleDets(), and Phase2OTBarrelRod::computeCrossings().

38  {
39  int bin = binIndex( int((z-theZOffset)/theZStep)+1);
40 
41  // check left border
42  if (bin > 0) {
43  if ( z < theBorders[bin-1]) {
44  // z is to the left of the left border, the correct bin is left
45  for (int i=bin-1; ; i--) {
46  if (i <= 0) return 0;
47  if ( z > theBorders[i-1]) return i;
48  }
49  }
50  }
51  else return 0;
52 
53  // check right border
54  if (bin < theNbins-1) {
55  if ( z > theBorders[bin]) {
56  // z is to the right of the right border, the correct bin is right
57  for (int i=bin+1; ; i++) {
58  if (i >= theNbins-1) return theNbins-1;
59  if ( z < theBorders[i]) return i;
60  }
61  }
62  }
63  else return theNbins-1;
64 
65  // if we arrive here it means that the bin is ok
66  return bin;
67  }
int binIndex(T z) const override
returns an index in the valid range for the bin closest to Z
bin
set the eta bin as selection string.
std::vector< float > theBorders
template<class T, class G>
int GenericBinFinderInZ< T, G >::binIndex ( int  i) const
inlineoverridevirtual

returns an index in the valid range

Implements BaseBinFinder< T >.

Definition at line 70 of file GenericBinFinderInZ.h.

70  {
71  return std::min( std::max( i, 0), theNbins-1);
72  }
T min(T a, T b)
Definition: MathUtil.h:58
template<class T, class G>
T GenericBinFinderInZ< T, G >::binPosition ( int  ind) const
inlineoverridevirtual

the middle of the bin.

Implements BaseBinFinder< T >.

Definition at line 75 of file GenericBinFinderInZ.h.

Referenced by Phase2OTBarrelRod::computeCrossings().

75  {
76  return theBins[binIndex(ind)];
77  }
int binIndex(T z) const override
returns an index in the valid range for the bin closest to Z
std::vector< T > theBins
template<class T, class G>
static double GenericBinFinderInZ< T, G >::pi ( )
inlinestatic

Definition at line 79 of file GenericBinFinderInZ.h.

Referenced by GenericBinFinderInZ< float, GeomDet >::twoPi().

79 { return 3.141592653589793238;}
template<class T, class G>
static double GenericBinFinderInZ< T, G >::twoPi ( )
inlinestatic

Definition at line 80 of file GenericBinFinderInZ.h.

80 { return 2.*pi();}

Member Data Documentation

template<class T, class G>
std::vector<T> GenericBinFinderInZ< T, G >::theBins
private
template<class T, class G>
std::vector<float> GenericBinFinderInZ< T, G >::theBorders
private
template<class T, class G>
int GenericBinFinderInZ< T, G >::theNbins
private
template<class T, class G>
T GenericBinFinderInZ< T, G >::theZOffset
private
template<class T, class G>
T GenericBinFinderInZ< T, G >::theZStep
private