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  : theNbins(last - first) {
22  theBins.reserve(theNbins);
23  theBorders.reserve(theNbins - 1);
24  for (ConstItr i = first; i < last - 1; i++) {
25  theBins.push_back((**i).position().z());
26  theBorders.push_back(((**i).position().z() + (**(i + 1)).position().z()) / 2.);
27  }
28  theBins.push_back((**(last - 1)).position().z());
29 
30  theZOffset = theBorders.front();
31  theZStep = (theBorders.back() - theBorders.front()) / (theNbins - 2);
32  }
std::vector< T > theBins
std::vector< const G * >::const_iterator ConstItr
static int position[264][3]
Definition: ReadPGInfo.cc:289
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 35 of file GenericBinFinderInZ.h.

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

35  {
36  int bin = binIndex(int((z - theZOffset) / theZStep) + 1);
37 
38  // check left border
39  if (bin > 0) {
40  if (z < theBorders[bin - 1]) {
41  // z is to the left of the left border, the correct bin is left
42  for (int i = bin - 1;; i--) {
43  if (i <= 0)
44  return 0;
45  if (z > theBorders[i - 1])
46  return i;
47  }
48  }
49  } else
50  return 0;
51 
52  // check right border
53  if (bin < theNbins - 1) {
54  if (z > theBorders[bin]) {
55  // z is to the right of the right border, the correct bin is right
56  for (int i = bin + 1;; i++) {
57  if (i >= theNbins - 1)
58  return theNbins - 1;
59  if (z < theBorders[i])
60  return i;
61  }
62  }
63  } else
64  return theNbins - 1;
65 
66  // if we arrive here it means that the bin is ok
67  return bin;
68  }
int binIndex(T z) const override
returns an index in the valid range for the bin closest to Z
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 71 of file GenericBinFinderInZ.h.

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 74 of file GenericBinFinderInZ.h.

Referenced by Phase2OTBarrelRod::computeCrossings().

74 { return theBins[binIndex(ind)]; }
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 76 of file GenericBinFinderInZ.h.

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

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

Definition at line 77 of file GenericBinFinderInZ.h.

77 { 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