JetMETCorrections
InterpolationTables
src
convertAxis.cc
Go to the documentation of this file.
1
#include "
JetMETCorrections/InterpolationTables/interface/NpstatException.h
"
2
3
#include "
JetMETCorrections/InterpolationTables/interface/convertAxis.h
"
4
5
namespace
npstat
{
6
HistoAxis
convertToHistoAxis
(
const
UniformAxis
& gridAxis) {
7
const
unsigned
nBins
= gridAxis.
nCoords
();
8
const
double
xmin
= gridAxis.
min
();
9
const
double
xmax
= gridAxis.
max
();
10
const
double
hbw = 0.5 * (
xmax
-
xmin
) / (
nBins
- 1
U
);
11
HistoAxis
ax(
nBins
,
xmin
- hbw,
xmax
+ hbw, gridAxis.
label
().c_str());
12
return
ax;
13
}
14
15
UniformAxis
convertToGridAxis
(
const
HistoAxis
& histoAxis) {
16
const
unsigned
nBins
= histoAxis.
nBins
();
17
const
double
xmin
= histoAxis.
binCenter
(0);
18
const
double
xmax
= histoAxis.
binCenter
(
nBins
- 1);
19
UniformAxis
ax(
nBins
,
xmin
,
xmax
, histoAxis.
label
().c_str());
20
return
ax;
21
}
22
23
NUHistoAxis
convertToHistoAxis
(
const
GridAxis
& gridAxis,
double
xMin
) {
24
const
unsigned
nCoords = gridAxis.
nCoords
();
25
std::vector<double> binEdges;
26
binEdges.reserve(nCoords + 1
U
);
27
binEdges.push_back(
xMin
);
28
for
(
unsigned
i
= 0;
i
< nCoords; ++
i
) {
29
const
double
x = gridAxis.
coordinate
(
i
);
30
if
(x <=
xMin
)
31
throw
npstat::NpstatInvalidArgument
(
32
"In npstat::convertToHistoAxis: "
33
"conversion is impossible"
);
34
const
double
halfbin = x -
xMin
;
35
xMin
= x + halfbin;
36
binEdges.push_back(
xMin
);
37
}
38
NUHistoAxis
ax(binEdges, gridAxis.
label
().c_str());
39
return
ax;
40
}
41
42
GridAxis
convertToGridAxis
(
const
NUHistoAxis
& histoAxis) {
43
const
unsigned
nBins
= histoAxis.
nBins
();
44
std::vector<double> coords;
45
coords.reserve(
nBins
);
46
for
(
unsigned
i
= 0;
i
<
nBins
; ++
i
)
47
coords.push_back(histoAxis.
binCenter
(
i
));
48
GridAxis
ax(coords, histoAxis.
label
().c_str());
49
return
ax;
50
}
51
}
// namespace npstat
npstat::UniformAxis::max
double max() const
Definition:
UniformAxis.h:35
npstat::HistoAxis::nBins
unsigned nBins() const
Definition:
HistoAxis.h:45
mps_fire.i
i
Definition:
mps_fire.py:355
npstat::UniformAxis
Definition:
UniformAxis.h:27
convertAxis.h
Functions for converting between grid and histogram axes.
npstat::convertToGridAxis
UniformAxis convertToGridAxis(const HistoAxis &histoAxis)
Definition:
convertAxis.cc:15
npstat::NUHistoAxis::nBins
unsigned nBins() const
Definition:
NUHistoAxis.h:43
npstat::UniformAxis::label
const std::string & label() const
Definition:
UniformAxis.h:36
npstat::convertToHistoAxis
HistoAxis convertToHistoAxis(const UniformAxis &gridAxis)
Definition:
convertAxis.cc:6
photonAnalyzer_cfi.xMin
xMin
Definition:
photonAnalyzer_cfi.py:82
npstat
Definition:
AbsArrayProjector.h:14
seedmultiplicitymonitor_newtracking_cfi.nBins
nBins
Definition:
seedmultiplicitymonitor_newtracking_cfi.py:8
npstat::NpstatInvalidArgument
Definition:
NpstatException.h:38
npstat::UniformAxis::nCoords
unsigned nCoords() const
Definition:
UniformAxis.h:33
mitigatedMETSequence_cff.U
U
Definition:
mitigatedMETSequence_cff.py:36
npstat::HistoAxis::label
const std::string & label() const
Definition:
HistoAxis.h:47
npstat::NUHistoAxis::label
const std::string & label() const
Definition:
NUHistoAxis.h:45
npstat::HistoAxis
Definition:
HistoAxis.h:31
npstat::GridAxis::coordinate
double coordinate(const unsigned i) const
Definition:
GridAxis.h:82
TrackerOfflineValidation_Dqm_cff.xmax
xmax
Definition:
TrackerOfflineValidation_Dqm_cff.py:11
npstat::NUHistoAxis::binCenter
double binCenter(const int binNum) const
Definition:
NUHistoAxis.h:56
npstat::HistoAxis::binCenter
double binCenter(const int binNum) const
Definition:
HistoAxis.h:52
npstat::NUHistoAxis
Definition:
NUHistoAxis.h:28
npstat::UniformAxis::min
double min() const
Definition:
UniformAxis.h:34
TrackerOfflineValidation_Dqm_cff.xmin
xmin
Definition:
TrackerOfflineValidation_Dqm_cff.py:10
NpstatException.h
Exceptions for the npstat namespace.
npstat::GridAxis::nCoords
unsigned nCoords() const
Definition:
GridAxis.h:81
npstat::GridAxis::label
const std::string & label() const
Definition:
GridAxis.h:44
npstat::GridAxis
Definition:
GridAxis.h:30
Generated for CMSSW Reference Manual by
1.8.16