Utilities
BinningTools
interface
GenericBinFinderInZ.h
Go to the documentation of this file.
1
#ifndef BinningTools_GenericBinFinderInZ_H
2
#define BinningTools_GenericBinFinderInZ_H
3
11
#include "
Utilities/BinningTools/interface/BaseBinFinder.h
"
12
#include <cmath>
13
#include <vector>
14
15
template
<
class
T,
class
G>
16
class
GenericBinFinderInZ
:
public
BaseBinFinder
<T> {
17
public
:
18
typedef
typename
std::vector<const G*>::const_iterator
ConstItr
;
19
GenericBinFinderInZ
() :
theNbins
(0),
theZStep
(0),
theZOffset
(0) {}
20
21
GenericBinFinderInZ
(
ConstItr
first
,
ConstItr
last
) :
theNbins
(
last
-
first
) {
22
theBins
.reserve(
theNbins
);
23
theBorders
.reserve(
theNbins
- 1);
24
for
(
ConstItr
i
=
first
;
i
<
last
- 1;
i
++) {
25
theBins
.push_back((**i).position().z());
26
theBorders
.push_back(((**i).position().z() + (**(
i
+ 1)).position().z()) / 2.);
27
}
28
theBins
.push_back((**(
last
- 1)).
position
().
z
());
29
30
theZOffset
=
theBorders
.front();
31
theZStep
= (
theBorders
.back() -
theBorders
.front()) / (
theNbins
- 2);
32
}
33
35
int
binIndex
(
T
z
)
const override
{
36
int
bin
=
binIndex
(
int
((
z
-
theZOffset
) /
theZStep
) + 1);
37
38
// check left border
39
if
(
bin
> 0) {
40
if
(
z
<
theBorders
[
bin
- 1]) {
41
// z is to the left of the left border, the correct bin is left
42
for
(
int
i
=
bin
- 1;;
i
--) {
43
if
(
i
<= 0)
44
return
0;
45
if
(
z
>
theBorders
[
i
- 1])
46
return
i
;
47
}
48
}
49
}
else
50
return
0;
51
52
// check right border
53
if
(
bin
<
theNbins
- 1) {
54
if
(
z
>
theBorders
[
bin
]) {
55
// z is to the right of the right border, the correct bin is right
56
for
(
int
i
=
bin
+ 1;;
i
++) {
57
if
(
i
>=
theNbins
- 1)
58
return
theNbins
- 1;
59
if
(
z
<
theBorders
[
i
])
60
return
i
;
61
}
62
}
63
}
else
64
return
theNbins
- 1;
65
66
// if we arrive here it means that the bin is ok
67
return
bin
;
68
}
69
71
int
binIndex
(
int
i
)
const override
{
return
std::min
(
std::max
(
i
, 0),
theNbins
- 1); }
72
74
T
binPosition
(
int
ind)
const override
{
return
theBins
[
binIndex
(ind)]; }
75
76
static
double
pi
() {
return
3.141592653589793238; }
77
static
double
twoPi
() {
return
2. *
pi
(); }
78
79
private
:
80
int
theNbins
;
81
T
theZStep
;
82
T
theZOffset
;
83
std::vector<float>
theBorders
;
84
std::vector<T>
theBins
;
85
};
86
#endif
mps_fire.i
i
Definition:
mps_fire.py:355
GenericBinFinderInZ::GenericBinFinderInZ
GenericBinFinderInZ(ConstItr first, ConstItr last)
Definition:
GenericBinFinderInZ.h:21
GenericBinFinderInZ::theNbins
int theNbins
Definition:
GenericBinFinderInZ.h:80
min
T min(T a, T b)
Definition:
MathUtil.h:58
dqmdumpme.first
first
Definition:
dqmdumpme.py:55
GenericBinFinderInZ::binIndex
int binIndex(int i) const override
returns an index in the valid range
Definition:
GenericBinFinderInZ.h:71
GenericBinFinderInZ::binPosition
T binPosition(int ind) const override
the middle of the bin.
Definition:
GenericBinFinderInZ.h:74
dqmdumpme.last
last
Definition:
dqmdumpme.py:56
GenericBinFinderInZ::twoPi
static double twoPi()
Definition:
GenericBinFinderInZ.h:77
GenericBinFinderInZ::ConstItr
std::vector< const G * >::const_iterator ConstItr
Definition:
GenericBinFinderInZ.h:18
DDAxes::z
GenericBinFinderInZ::theBorders
std::vector< float > theBorders
Definition:
GenericBinFinderInZ.h:83
GenericBinFinderInZ::binIndex
int binIndex(T z) const override
returns an index in the valid range for the bin closest to Z
Definition:
GenericBinFinderInZ.h:35
GenericBinFinderInZ::GenericBinFinderInZ
GenericBinFinderInZ()
Definition:
GenericBinFinderInZ.h:19
SiStripPI::max
Definition:
SiStripPayloadInspectorHelper.h:169
GenericBinFinderInZ::pi
static double pi()
Definition:
GenericBinFinderInZ.h:76
position
static int position[264][3]
Definition:
ReadPGInfo.cc:289
BaseBinFinder.h
newFWLiteAna.bin
bin
Definition:
newFWLiteAna.py:161
GenericBinFinderInZ
Definition:
GenericBinFinderInZ.h:16
T
long double T
Definition:
Basic3DVectorLD.h:48
BaseBinFinder
Definition:
BaseBinFinder.h:11
GenericBinFinderInZ::theZStep
T theZStep
Definition:
GenericBinFinderInZ.h:81
GenericBinFinderInZ::theZOffset
T theZOffset
Definition:
GenericBinFinderInZ.h:82
GenericBinFinderInZ::theBins
std::vector< T > theBins
Definition:
GenericBinFinderInZ.h:84
Generated for CMSSW Reference Manual by
1.8.16