Utilities
BinningTools
interface
PeriodicBinFinderInPhi.h
Go to the documentation of this file.
1
#ifndef PeriodicBinFinderInPhi_H
2
#define PeriodicBinFinderInPhi_H
3
4
#include "
Utilities/BinningTools/interface/BaseBinFinder.h
"
5
6
#include <algorithm>
7
#include <cmath>
8
13
template
<
class
T>
14
class
PeriodicBinFinderInPhi
final :
public
BaseBinFinder
<T> {
15
public
:
16
PeriodicBinFinderInPhi
() {}
17
18
PeriodicBinFinderInPhi
(
T
firstPhi,
int
nbins
)
19
:
theNbins
(
nbins
),
20
thePhiStep
(
twoPiC
/
T
(
nbins
)),
21
theInvPhiStep
(
T
(1) /
thePhiStep
),
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;
49
T
thePhiStep
= 0;
50
T
theInvPhiStep
= 0;
51
T
thePhiOffset
= 0;
52
};
53
#endif
mps_fire.i
i
Definition:
mps_fire.py:428
PeriodicBinFinderInPhi::twoPi
static constexpr T twoPi()
Definition:
PeriodicBinFinderInPhi.h:42
min
T min(T a, T b)
Definition:
MathUtil.h:58
PeriodicBinFinderInPhi::thePhiStep
T thePhiStep
Definition:
PeriodicBinFinderInPhi.h:49
PeriodicBinFinderInPhi::twoPiC
static constexpr T twoPiC
Definition:
PeriodicBinFinderInPhi.h:46
PeriodicBinFinderInPhi::pi
static constexpr T pi()
Definition:
PeriodicBinFinderInPhi.h:41
PeriodicBinFinderInPhi::binPosition
T binPosition(int ind) const override
the middle of the bin in radians
Definition:
PeriodicBinFinderInPhi.h:39
createJobs.tmp
tmp
align.sh
Definition:
createJobs.py:716
PeriodicBinFinderInPhi::theNbins
int theNbins
Definition:
PeriodicBinFinderInPhi.h:48
PeriodicBinFinderInPhi::PeriodicBinFinderInPhi
PeriodicBinFinderInPhi()
Definition:
PeriodicBinFinderInPhi.h:16
PeriodicBinFinderInPhi::theInvPhiStep
T theInvPhiStep
Definition:
PeriodicBinFinderInPhi.h:50
LaserClient_cfi.nbins
nbins
Definition:
LaserClient_cfi.py:51
PeriodicBinFinderInPhi::PeriodicBinFinderInPhi
PeriodicBinFinderInPhi(T firstPhi, int nbins)
Definition:
PeriodicBinFinderInPhi.h:18
BaseBinFinder.h
DDAxes::phi
PeriodicBinFinderInPhi
Definition:
MagBLayer.h:22
T
long double T
Definition:
Basic3DVectorLD.h:48
BaseBinFinder
Definition:
BaseBinFinder.h:11
PeriodicBinFinderInPhi::binIndex
int binIndex(T phi) const override
returns an index in the valid range for the bin that contains phi
Definition:
PeriodicBinFinderInPhi.h:25
PeriodicBinFinderInPhi::thePhiOffset
T thePhiOffset
Definition:
PeriodicBinFinderInPhi.h:51
PeriodicBinFinderInPhi::binIndex
int binIndex(int i) const override
returns an index in the valid range, modulo Nbins
Definition:
PeriodicBinFinderInPhi.h:33
PeriodicBinFinderInPhi::piC
static constexpr T piC
Definition:
PeriodicBinFinderInPhi.h:45
Generated for CMSSW Reference Manual by
1.8.16