JetMETCorrections
InterpolationTables
interface
LinearMapper1d.h
Go to the documentation of this file.
1
#ifndef NPSTAT_LINEARMAPPER1D_HH_
2
#define NPSTAT_LINEARMAPPER1D_HH_
3
14
#include "
JetMETCorrections/InterpolationTables/interface/NpstatException.h
"
15
16
namespace
npstat
{
18
class
LinearMapper1d
{
19
public
:
21
inline
LinearMapper1d
() :
a_
(1.0),
b_
(0.0) {}
22
28
inline
LinearMapper1d
(
const
double
x0,
const
double
y0,
const
double
x1
,
const
double
y1
) {
29
const
double
dx
=
x1
- x0;
30
if
(!
dx
)
31
throw
npstat::NpstatInvalidArgument
(
32
"In npstat::LinearMapper1d constructor: "
33
"invalid arguments (x0 == x1)"
);
34
a_
= (
y1
- y0) /
dx
;
35
b_
= ((y0 +
y1
) -
a_
* (x0 +
x1
)) / 2.0;
36
}
37
39
inline
LinearMapper1d
(
const
double
ca,
const
double
cb) :
a_
(ca),
b_
(cb) {}
40
42
inline
double
operator()
(
const
double
& x)
const
{
return
a_
* x +
b_
; }
43
45
inline
double
a
()
const
{
return
a_
; }
46
48
inline
double
b
()
const
{
return
b_
; }
49
51
inline
LinearMapper1d
inverse
()
const
{
52
if
(!
a_
)
53
throw
npstat::NpstatInvalidArgument
(
54
"In npstat::LinearMapper1d::inverse: "
55
"mapping is not invertible"
);
56
return
LinearMapper1d
(1.0 /
a_
, -
b_
/
a_
);
57
}
58
60
inline
LinearMapper1d
operator*
(
const
LinearMapper1d
&
r
)
const
{
return
LinearMapper1d
(
a_
*
r
.a_,
a_
*
r
.b_ +
b_
); }
61
62
private
:
63
double
a_
;
64
double
b_
;
65
};
66
}
// namespace npstat
67
68
#endif // NPSTAT_LINEARMAPPER1D_HH_
npstat::LinearMapper1d
Definition:
LinearMapper1d.h:18
npstat::LinearMapper1d::operator()
double operator()(const double &x) const
Definition:
LinearMapper1d.h:42
npstat::LinearMapper1d::LinearMapper1d
LinearMapper1d(const double ca, const double cb)
Definition:
LinearMapper1d.h:39
npstat
Definition:
AbsArrayProjector.h:14
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition:
testProducerWithPsetDescEmpty_cfi.py:33
testProducerWithPsetDescEmpty_cfi.y1
y1
Definition:
testProducerWithPsetDescEmpty_cfi.py:29
npstat::NpstatInvalidArgument
Definition:
NpstatException.h:38
npstat::LinearMapper1d::inverse
LinearMapper1d inverse() const
Definition:
LinearMapper1d.h:51
npstat::LinearMapper1d::b_
double b_
Definition:
LinearMapper1d.h:64
npstat::LinearMapper1d::b
double b() const
Definition:
LinearMapper1d.h:48
npstat::LinearMapper1d::a_
double a_
Definition:
LinearMapper1d.h:63
alignCSCRings.r
r
Definition:
alignCSCRings.py:93
npstat::LinearMapper1d::a
double a() const
Definition:
LinearMapper1d.h:45
npstat::LinearMapper1d::LinearMapper1d
LinearMapper1d()
Definition:
LinearMapper1d.h:21
npstat::LinearMapper1d::operator*
LinearMapper1d operator*(const LinearMapper1d &r) const
Definition:
LinearMapper1d.h:60
NpstatException.h
Exceptions for the npstat namespace.
npstat::LinearMapper1d::LinearMapper1d
LinearMapper1d(const double x0, const double y0, const double x1, const double y1)
Definition:
LinearMapper1d.h:28
PVValHelper::dx
Definition:
PVValidationHelpers.h:49
Generated for CMSSW Reference Manual by
1.8.16