CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  virtual int binIndex( T R) const {
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  virtual int binIndex( int i) const {
58  return std::min( std::max( i, 0), theNbins-1);
59  }
60 
62  virtual T binPosition( int ind) const {
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 i
Definition: DBlmapReader.cc:9
std::vector< T > theBins
GeneralBinFinderInR(std::vector< Det * >::const_iterator first, std::vector< Det * >::const_iterator last)
Construct from the list of Det*.
virtual int binIndex(T R) const
std::vector< double > RBins() const
The centers of the Dets.
T min(T a, T b)
Definition: MathUtil.h:58
std::vector< T > theBorders
std::vector< double > RBorders() const
virtual T binPosition(int ind) const
The middle of the bin.
virtual int binIndex(int i) const
Returns an index in the valid range.
long double T
GeneralBinFinderInR(const RBorderFinder &bf)
Construct from an already initialized RBorderFinder.
RBorderFinder::Det Det