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 (int i) const override
 returns an index in the valid range More...
 
int binIndex (T z) const override
 returns an index in the valid range for the bin closest to Z 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

◆ ConstItr

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

◆ GenericBinFinderInZ() [1/2]

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

Definition at line 19 of file GenericBinFinderInZ.h.

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

◆ GenericBinFinderInZ() [2/2]

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  }

Member Function Documentation

◆ binIndex() [1/2]

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.

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

◆ binIndex() [2/2]

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.

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  }

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

◆ binPosition()

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.

74 { return theBins[binIndex(ind)]; }

Referenced by Phase2OTBarrelRod::computeCrossings().

◆ pi()

template<class T, class G>
static double GenericBinFinderInZ< T, G >::pi ( )
inlinestatic

Definition at line 76 of file GenericBinFinderInZ.h.

76 { return 3.141592653589793238; }

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

◆ twoPi()

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

◆ theBins

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

◆ theBorders

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

◆ theNbins

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

◆ theZOffset

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

◆ theZStep

template<class T, class G>
T GenericBinFinderInZ< T, G >::theZStep
private
mps_fire.i
i
Definition: mps_fire.py:355
GenericBinFinderInZ::theNbins
int theNbins
Definition: GenericBinFinderInZ.h:80
min
T min(T a, T b)
Definition: MathUtil.h:58
dqmdumpme.first
first
Definition: dqmdumpme.py:55
dqmdumpme.last
last
Definition: dqmdumpme.py:56
GenericBinFinderInZ::ConstItr
std::vector< const G * >::const_iterator ConstItr
Definition: GenericBinFinderInZ.h:18
DDAxes::z
GenericBinFinderInZ::theBorders
std::vector< float > theBorders
Definition: GenericBinFinderInZ.h:83
GenericBinFinderInZ::binIndex
int binIndex(T z) const override
returns an index in the valid range for the bin closest to Z
Definition: GenericBinFinderInZ.h:35
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
GenericBinFinderInZ::pi
static double pi()
Definition: GenericBinFinderInZ.h:76
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
GenericBinFinderInZ::theZStep
T theZStep
Definition: GenericBinFinderInZ.h:81
GenericBinFinderInZ::theZOffset
T theZOffset
Definition: GenericBinFinderInZ.h:82
GenericBinFinderInZ::theBins
std::vector< T > theBins
Definition: GenericBinFinderInZ.h:84