CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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:
16 
17  PeriodicBinFinderInZ(std::vector<const GeomDet*>::const_iterator first,
18  std::vector<const GeomDet*>::const_iterator last)
19  : theNbins(last - first) {
20  float zFirst = (**first).surface().position().z();
21  theZStep = ((**(last - 1)).surface().position().z() - zFirst) / (theNbins - 1);
22  theZOffset = zFirst - 0.5 * theZStep;
23  }
24 
26  int binIndex(T z) const override { return binIndex(int((z - theZOffset) / theZStep)); }
27 
29  int binIndex(int i) const override { return std::min(std::max(i, 0), theNbins - 1); }
30 
32  T binPosition(int ind) const override { return theZOffset + theZStep * (ind + 0.5); }
33 
34 private:
35  int theNbins;
38 };
39 #endif
int binIndex(T z) const override
returns an index in the valid range for the bin that contains Z
T binPosition(int ind) const override
the middle of the bin
tuple last
Definition: dqmdumpme.py:56
PeriodicBinFinderInZ(std::vector< const GeomDet * >::const_iterator first, std::vector< const GeomDet * >::const_iterator last)
long double T
int binIndex(int i) const override
returns an index in the valid range