TrackingTools
DetLayers
interface
GeneralBinFinderInZforGeometricSearchDet.h
Go to the documentation of this file.
1
#ifndef GeneralBinFinderInZ_H
2
#define GeneralBinFinderInZ_H
3
8
#include "
Utilities/BinningTools/interface/BaseBinFinder.h
"
9
#include "
TrackingTools/DetLayers/interface/GeometricSearchDet.h
"
10
#include <cmath>
11
12
#include <cassert>
13
14
template
<
class
T>
15
class
GeneralBinFinderInZforGeometricSearchDet
final :
public
BaseBinFinder
<T> {
16
public
:
17
GeneralBinFinderInZforGeometricSearchDet
() {}
18
19
GeneralBinFinderInZforGeometricSearchDet
(std::vector<const GeometricSearchDet*>::const_iterator
first
,
20
std::vector<const GeometricSearchDet*>::const_iterator
last
)
21
:
theNbins
(
last
-
first
- 1)
// -1!
22
{
23
theBins
.reserve(
theNbins
);
24
theBorders
.reserve(
theNbins
);
25
for
(
auto
i
=
first
;
i
<
last
- 1;
i
++) {
26
theBins
.push_back((**i).position().z());
27
theBorders
.push_back(((**i).position().z() + (**(
i
+ 1)).position().z()) / 2.);
28
}
29
assert
(
theNbins
==
int
(
theBorders
.size()));
30
31
theZOffset
=
theBorders
.front();
32
theZStep
= (
theBorders
.back() -
theBorders
.front()) / (
theNbins
- 1);
33
theInvZStep
= 1. /
theZStep
;
34
}
35
37
int
binIndex
(
T
z
)
const override
{
38
int
bin
=
int
((
z
-
theZOffset
) *
theInvZStep
) + 1;
39
if
(
bin
<= 0)
40
return
0;
41
if
(
bin
>=
theNbins
)
42
return
theNbins
;
43
44
// check left border
45
if
(
z
<
theBorders
[
bin
- 1]) {
46
// z is to the left of the left border, the correct bin is left
47
for
(
auto
i
=
bin
- 1;
i
> 0;
i
--) {
48
if
(
z
>
theBorders
[
i
- 1])
49
return
i
;
50
}
51
return
0;
52
}
53
54
// check right border
55
if
(
z
>
theBorders
[
bin
]) {
56
// z is to the right of the right border, the correct bin is right
57
for
(
int
i
=
bin
+ 1;
i
<
theNbins
;
i
++) {
58
if
(
z
<
theBorders
[
i
])
59
return
i
;
60
}
61
return
theNbins
;
62
}
63
// if we arrive here it means that the bin is ok
64
return
bin
;
65
}
66
68
int
binIndex
(
int
i
)
const override
{
return
std::min
(
std::max
(
i
, 0),
theNbins
); }
69
71
T
binPosition
(
int
ind)
const override
{
return
theBins
[
binIndex
(ind)]; }
72
73
private
:
74
int
theNbins
= 0;
// -1
75
T
theZStep
= 0;
76
T
theInvZStep
= 0;
77
T
theZOffset
= 0;
78
std::vector<float>
theBorders
;
79
std::vector<T>
theBins
;
80
};
81
#endif
mps_fire.i
i
Definition:
mps_fire.py:428
GeneralBinFinderInZforGeometricSearchDet::theZStep
T theZStep
Definition:
GeneralBinFinderInZforGeometricSearchDet.h:75
GeneralBinFinderInZforGeometricSearchDet
Definition:
GeneralBinFinderInZforGeometricSearchDet.h:15
min
T min(T a, T b)
Definition:
MathUtil.h:58
GeometricSearchDet.h
cms::cuda::assert
assert(be >=bs)
GeneralBinFinderInZforGeometricSearchDet::binPosition
T binPosition(int ind) const override
the middle of the bin.
Definition:
GeneralBinFinderInZforGeometricSearchDet.h:71
dqmdumpme.last
last
Definition:
dqmdumpme.py:56
DDAxes::z
GeneralBinFinderInZforGeometricSearchDet::theInvZStep
T theInvZStep
Definition:
GeneralBinFinderInZforGeometricSearchDet.h:76
first
auto first
Definition:
CAHitNtupletGeneratorKernelsImpl.h:125
GeneralBinFinderInZforGeometricSearchDet::theBins
std::vector< T > theBins
Definition:
GeneralBinFinderInZforGeometricSearchDet.h:79
SiStripPI::max
Definition:
SiStripPayloadInspectorHelper.h:169
createfilelist.int
int
Definition:
createfilelist.py:10
GeneralBinFinderInZforGeometricSearchDet::GeneralBinFinderInZforGeometricSearchDet
GeneralBinFinderInZforGeometricSearchDet()
Definition:
GeneralBinFinderInZforGeometricSearchDet.h:17
GeneralBinFinderInZforGeometricSearchDet::binIndex
int binIndex(T z) const override
returns an index in the valid range for the bin closest to Z
Definition:
GeneralBinFinderInZforGeometricSearchDet.h:37
BaseBinFinder.h
newFWLiteAna.bin
bin
Definition:
newFWLiteAna.py:161
T
long double T
Definition:
Basic3DVectorLD.h:48
GeneralBinFinderInZforGeometricSearchDet::theBorders
std::vector< float > theBorders
Definition:
GeneralBinFinderInZforGeometricSearchDet.h:78
BaseBinFinder
Definition:
BaseBinFinder.h:11
GeneralBinFinderInZforGeometricSearchDet::theZOffset
T theZOffset
Definition:
GeneralBinFinderInZforGeometricSearchDet.h:77
GeneralBinFinderInZforGeometricSearchDet::GeneralBinFinderInZforGeometricSearchDet
GeneralBinFinderInZforGeometricSearchDet(std::vector< const GeometricSearchDet * >::const_iterator first, std::vector< const GeometricSearchDet * >::const_iterator last)
Definition:
GeneralBinFinderInZforGeometricSearchDet.h:19
GeneralBinFinderInZforGeometricSearchDet::binIndex
int binIndex(int i) const override
returns an index in the valid range
Definition:
GeneralBinFinderInZforGeometricSearchDet.h:68
GeneralBinFinderInZforGeometricSearchDet::theNbins
int theNbins
Definition:
GeneralBinFinderInZforGeometricSearchDet.h:74
Generated for CMSSW Reference Manual by
1.8.16