CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

virtual int binIndex (T z) const
 returns an index in the valid range for the bin closest to Z More...
 
virtual int binIndex (int i) const
 returns an index in the valid range More...
 
virtual T binPosition (int ind) const
 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  for (ConstItr i=first; i<last-1; i++) {
26  theBins.push_back((**i).position().z());
27  theBorders.push_back(((**i).position().z() +
28  (**(i+1)).position().z()) / 2.);
29  }
30 
31  theZOffset = theBorders.front();
32  theZStep = (theBorders.back() - theBorders.front()) / (theNbins-2);
33  }
int i
Definition: DBlmapReader.cc:9
std::vector< T > theBins
bool first
Definition: L1TdeRCT.cc:79
std::vector< const G * >::const_iterator ConstItr
std::vector< float > theBorders

Member Function Documentation

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

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().

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

returns an index in the valid range

Implements BaseBinFinder< T >.

Definition at line 68 of file GenericBinFinderInZ.h.

68  {
69  return std::min( std::max( i, 0), theNbins-1);
70  }
int i
Definition: DBlmapReader.cc:9
const T & max(const T &a, const T &b)
template<class T, class G>
virtual T GenericBinFinderInZ< T, G >::binPosition ( int  ind) const
inlinevirtual

the middle of the bin.

Implements BaseBinFinder< T >.

Definition at line 73 of file GenericBinFinderInZ.h.

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

Definition at line 77 of file GenericBinFinderInZ.h.

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

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

Definition at line 78 of file GenericBinFinderInZ.h.

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