CMS 3D CMS Logo

GeneralBinFinderInR.h
Go to the documentation of this file.
1 #ifndef TrackingTools_DetLayers_GeneralBinFinderInR_H
2 #define TrackingTools_DetLayers_GeneralBinFinderInR_H
3 
12 
13 #include <cmath>
14 #include <vector>
15 
16 template <class T>
18 public:
19  typedef RBorderFinder::Det Det; //FIXME!!!
20 
22 
25  theBorders = bf.RBorders();
26  theBins = bf.RBins();
27  theNbins = theBins.size();
28  }
29 
31  GeneralBinFinderInR(std::vector<Det*>::const_iterator first, std::vector<Det*>::const_iterator last)
32  : theNbins(last - first) {
33  std::vector<const Det*> dets(first, last);
34  RBorderFinder bf(dets);
35  theBorders = bf.RBorders();
36  theBins = bf.RBins();
37  theNbins = theBins.size();
38  }
39 
42  int binIndex(T R) const override {
43  int i;
44  for (i = 0; i < theNbins; i++) {
45  if (R < theBorders[i]) {
46  break;
47  }
48  }
49  return binIndex(i - 1);
50  }
51 
53  int binIndex(int i) const override { return std::min(std::max(i, 0), theNbins - 1); }
54 
56  T binPosition(int ind) const override { return theBins[binIndex(ind)]; }
57 
58 private:
59  int theNbins;
60  std::vector<T> theBorders;
61  std::vector<T> theBins;
62 };
63 #endif
int binIndex(T R) const override
std::vector< T > theBins
std::vector< double > RBorders() const
Definition: RBorderFinder.h:39
std::vector< T > theBorders
GeneralBinFinderInR(std::vector< Det *>::const_iterator first, std::vector< Det *>::const_iterator last)
Construct from the list of Det*.
int binIndex(int i) const override
Returns an index in the valid range.
T binPosition(int ind) const override
The middle of the bin.
std::vector< double > RBins() const
The centers of the Dets.
Definition: RBorderFinder.h:42
long double T
GeneralBinFinderInR(const RBorderFinder &bf)
Construct from an already initialized RBorderFinder.
RBorderFinder::Det Det