CMS 3D CMS Logo

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