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 
13 #include "RBorderFinder.h"
14 
15 #include <cmath>
16 #include <vector>
17 
18 template <class T>
20 public:
21 
22  typedef RBorderFinder::Det Det; //FIXME!!!
23 
25 
28  theBorders=bf.RBorders();
29  theBins=bf.RBins();
30  theNbins=theBins.size();
31  }
32 
34  GeneralBinFinderInR(std::vector<Det*>::const_iterator first,
35  std::vector<Det*>::const_iterator last)
36  : theNbins( last-first)
37  {
38  std::vector<Det*> dets(first,last);
39  RBorderFinder bf(dets);
40  theBorders=bf.RBorders();
41  theBins=bf.RBins();
42  theNbins=theBins.size();
43  }
44 
45 
48  virtual int binIndex( T R) const {
49  int i;
50  for (i = 0; i<theNbins; i++) {
51  if (R < theBorders[i]){
52  break;
53  }
54  }
55  return binIndex(i-1);
56  }
57 
59  virtual int binIndex( int i) const {
60  return std::min( std::max( i, 0), theNbins-1);
61  }
62 
64  virtual T binPosition( int ind) const {
65  return theBins[binIndex(ind)];
66  }
67 
68 
69 private:
70  int theNbins;
71  std::vector<T> theBorders;
72  std::vector<T> theBins;
73 
74 };
75 #endif
76 
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*.
#define min(a, b)
Definition: mlp_lapack.h:161
virtual int binIndex(T R) const
const T & max(const T &a, const T &b)
std::vector< double > RBins() const
The centers of the Dets.
std::vector< T > theBorders
bool first
Definition: L1TdeRCT.cc:79
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.
GeneralBinFinderInR(const RBorderFinder &bf)
Construct from an already initialized RBorderFinder.
RBorderFinder::Det Det