CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PeriodicBinFinderInPhi.h
Go to the documentation of this file.
1 #ifndef PeriodicBinFinderInPhi_H
2 #define PeriodicBinFinderInPhi_H
3 
5 
6 #include <cmath>
7 
12 template <class T>
13 class PeriodicBinFinderInPhi : public BaseBinFinder<T> {
14 public:
15 
17 
18  PeriodicBinFinderInPhi( T firstPhi, int nbins) :
19  theNbins( nbins), thePhiStep( twoPi() / nbins),
20  thePhiOffset( firstPhi - thePhiStep/2.) {}
21 
23  virtual int binIndex( T phi) const {
24  T tmp = fmod((phi - thePhiOffset), twoPi()) / thePhiStep;
25  if ( tmp < 0) tmp += theNbins;
26  return std::min( int(tmp), theNbins-1);
27  }
28 
30  virtual int binIndex( int i) const {
31  int ind = i % theNbins;
32  return ind < 0 ? ind+theNbins : ind;
33  }
34 
36  virtual T binPosition( int ind) const {
37  return thePhiOffset + thePhiStep * ( ind + 0.5);
38  }
39 
40  static T pi() { return 3.141592653589793238;}
41  static T twoPi() { return 2.*pi();}
42 
43 private:
44 
45  int theNbins;
48 
49 };
50 #endif
int i
Definition: DBlmapReader.cc:9
PeriodicBinFinderInPhi(T firstPhi, int nbins)
virtual int binIndex(T phi) const
returns an index in the valid range for the bin that contains phi
virtual T binPosition(int ind) const
the middle of the bin in radians
virtual int binIndex(int i) const
returns an index in the valid range, modulo Nbins
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
long double T
Definition: DDAxes.h:10