CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PeriodicBinFinderInZ.h
Go to the documentation of this file.
1 #ifndef DetLayers_PeriodicBinFinderInZ_H
2 #define DetLayers_PeriodicBinFinderInZ_H
3 
6 #include <cmath>
7 
12 template <class T>
14 public:
15 
17 
18  PeriodicBinFinderInZ(std::vector<const GeomDet*>::const_iterator first,
19  std::vector<const GeomDet*>::const_iterator last) :
20  theNbins( last-first)
21  {
22  float zFirst = (**first).surface().position().z();
23  theZStep = ((**(last-1)).surface().position().z() - zFirst) / (theNbins-1);
24  theZOffset = zFirst - 0.5*theZStep;
25  }
26 
28  virtual int binIndex( T z) const {
29  return binIndex( int((z-theZOffset)/theZStep));
30  }
31 
33  virtual int binIndex( int i) const {
34  return std::min( std::max( i, 0), theNbins-1);
35  }
36 
38  virtual T binPosition( int ind) const {
39  return theZOffset + theZStep * ( ind + 0.5);
40  }
41 
42 private:
43 
44  int theNbins;
47 
48 };
49 #endif
virtual int binIndex(int i) const
returns an index in the valid range
int i
Definition: DBlmapReader.cc:9
virtual T binPosition(int ind) const
the middle of the bin
float float float z
virtual int binIndex(T z) const
returns an index in the valid range for the bin that contains Z
T min(T a, T b)
Definition: MathUtil.h:58
PeriodicBinFinderInZ(std::vector< const GeomDet * >::const_iterator first, std::vector< const GeomDet * >::const_iterator last)
long double T