CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
MagBinFinders::GeneralBinFinderInR< T > Class Template Reference

#include <MagBinFinders.h>

Inheritance diagram for MagBinFinders::GeneralBinFinderInR< T >:
BaseBinFinder< T >

Public Member Functions

int binIndex (int i) const override
 Returns an index in the valid range. More...
 
int binIndex (T R) const override
 
T binPosition (int ind) const override
 The middle of the bin. More...
 
 GeneralBinFinderInR ()
 
 GeneralBinFinderInR (std::vector< T > &borders)
 
- Public Member Functions inherited from BaseBinFinder< T >
 BaseBinFinder ()
 
virtual ~BaseBinFinder ()
 

Private Attributes

std::vector< TtheBins
 
std::vector< TtheBorders
 
int theNbins
 

Detailed Description

template<class T>
class MagBinFinders::GeneralBinFinderInR< T >

A R binfinder for a non-periodic group of detectors.

Author
N. Amapane - INFN Torino

Definition at line 8 of file MagBinFinders.h.

Constructor & Destructor Documentation

◆ GeneralBinFinderInR() [1/2]

template<class T>
MagBinFinders::GeneralBinFinderInR< T >::GeneralBinFinderInR ( )
inline

Definition at line 30 of file MagBinFinders.h.

30 : theNbins(0) {}

◆ GeneralBinFinderInR() [2/2]

template<class T>
MagBinFinders::GeneralBinFinderInR< T >::GeneralBinFinderInR ( std::vector< T > &  borders)
inline

Definition at line 32 of file MagBinFinders.h.

32  : theNbins(borders.size()), theBorders(borders) {
33  // FIXME: compute bin positions.
34  // for (vector<T>::const_iterator i=theBorders.begin();
35  // i<theBorders.end(); ++i) {
36  // theBorders.push_back(((*i) + (*(i+1))) / 2.);
37 
38  // cout << "GeneralBinFinderInR_ " << theNbins << " " << theBorders.size() << " " << (int) this << endl;
39  }

Member Function Documentation

◆ binIndex() [1/2]

template<class T>
int MagBinFinders::GeneralBinFinderInR< T >::binIndex ( int  i) const
inlineoverridevirtual

Returns an index in the valid range.

Implements BaseBinFinder< T >.

Definition at line 73 of file MagBinFinders.h.

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

◆ binIndex() [2/2]

template<class T>
int MagBinFinders::GeneralBinFinderInR< T >::binIndex ( T  R) const
inlineoverridevirtual

Returns an index in the valid range for the bin that contains AND is closest to R

Implements BaseBinFinder< T >.

Definition at line 62 of file MagBinFinders.h.

62  {
63  int i;
64  for (i = 0; i < theNbins; ++i) {
65  if (R < theBorders[i]) { // FIXME: one can be skipped?
66  break;
67  }
68  }
69  return binIndex(i - 1);
70  }

Referenced by MagBinFinders::GeneralBinFinderInR< double >::binIndex(), MagBinFinders::GeneralBinFinderInR< double >::binPosition(), and MagGeometry::findVolume().

◆ binPosition()

template<class T>
T MagBinFinders::GeneralBinFinderInR< T >::binPosition ( int  ind) const
inlineoverridevirtual

The middle of the bin.

Implements BaseBinFinder< T >.

Definition at line 76 of file MagBinFinders.h.

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

Member Data Documentation

◆ theBins

template<class T>
std::vector<T> MagBinFinders::GeneralBinFinderInR< T >::theBins
private

◆ theBorders

template<class T>
std::vector<T> MagBinFinders::GeneralBinFinderInR< T >::theBorders
private

◆ theNbins

template<class T>
int MagBinFinders::GeneralBinFinderInR< T >::theNbins
private
MagBinFinders::GeneralBinFinderInR::theBorders
std::vector< T > theBorders
Definition: MagBinFinders.h:80
mps_fire.i
i
Definition: mps_fire.py:428
min
T min(T a, T b)
Definition: MathUtil.h:58
MagBinFinders::GeneralBinFinderInR::binIndex
int binIndex(T R) const override
Definition: MagBinFinders.h:62
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
MagBinFinders::GeneralBinFinderInR::theBins
std::vector< T > theBins
Definition: MagBinFinders.h:81
MagBinFinders::GeneralBinFinderInR::theNbins
int theNbins
Definition: MagBinFinders.h:79
dttmaxenums::R
Definition: DTTMax.h:29