CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PeriodicBinFinderInPhi.h
Go to the documentation of this file.
1 #ifndef PeriodicBinFinderInPhi_H
2 #define PeriodicBinFinderInPhi_H
3 
5 
6 #include <algorithm>
7 #include <cmath>
8 
13 template <class T>
14 class PeriodicBinFinderInPhi final : public BaseBinFinder<T> {
15 public:
17 
19  : theNbins(nbins),
20  thePhiStep(twoPiC / T(nbins)),
22  thePhiOffset(firstPhi - T(0.5) * thePhiStep) {}
23 
25  int binIndex(T phi) const override {
26  T tmp = std::fmod((phi - thePhiOffset), twoPiC) * theInvPhiStep;
27  if (tmp < 0)
28  tmp += theNbins;
29  return std::min(int(tmp), theNbins - 1);
30  }
31 
33  int binIndex(int i) const override {
34  int ind = i % theNbins;
35  return ind < 0 ? ind + theNbins : ind;
36  }
37 
39  T binPosition(int ind) const override { return thePhiOffset + thePhiStep * (T(ind) + T(0.5)); }
40 
41  static constexpr T pi() { return piC; }
42  static constexpr T twoPi() { return twoPiC; }
43 
44 private:
45  static constexpr T piC = 3.141592653589793238;
46  static constexpr T twoPiC = 2 * piC;
47 
48  int theNbins = 0;
52 };
53 #endif
int binIndex(T phi) const override
returns an index in the valid range for the bin that contains phi
PeriodicBinFinderInPhi(T firstPhi, int nbins)
int binIndex(int i) const override
returns an index in the valid range, modulo Nbins
static constexpr T twoPi()
tmp
align.sh
Definition: createJobs.py:716
long double T
T binPosition(int ind) const override
the middle of the bin in radians