CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
SimpleJetCorrectionUncertainty Class Reference

#include <SimpleJetCorrectionUncertainty.h>

Public Member Functions

const JetCorrectorParametersparameters () const
 
 SimpleJetCorrectionUncertainty ()
 
 SimpleJetCorrectionUncertainty (const JetCorrectorParameters &fParameters)
 
 SimpleJetCorrectionUncertainty (const std::string &fDataFile)
 
float uncertainty (const std::vector< float > &fX, float fY, bool fDirection) const
 
 ~SimpleJetCorrectionUncertainty ()
 

Private Member Functions

int findBin (const std::vector< float > &v, float x) const
 
float linearInterpolation (float fZ, const float fX[2], const float fY[2]) const
 
SimpleJetCorrectionUncertaintyoperator= (const SimpleJetCorrectionUncertainty &)=delete
 
 SimpleJetCorrectionUncertainty (const SimpleJetCorrectionUncertainty &)=delete
 
float uncertaintyBin (unsigned fBin, float fY, bool fDirection) const
 

Private Attributes

JetCorrectorParametersmParameters
 

Detailed Description

Definition at line 10 of file SimpleJetCorrectionUncertainty.h.

Constructor & Destructor Documentation

◆ SimpleJetCorrectionUncertainty() [1/4]

SimpleJetCorrectionUncertainty::SimpleJetCorrectionUncertainty ( )

Definition at line 8 of file SimpleJetCorrectionUncertainty.cc.

References mParameters.

◆ SimpleJetCorrectionUncertainty() [2/4]

SimpleJetCorrectionUncertainty::SimpleJetCorrectionUncertainty ( const std::string &  fDataFile)

Definition at line 10 of file SimpleJetCorrectionUncertainty.cc.

10  {
11  mParameters = new JetCorrectorParameters(fDataFile);
12 }

References mParameters.

◆ SimpleJetCorrectionUncertainty() [3/4]

SimpleJetCorrectionUncertainty::SimpleJetCorrectionUncertainty ( const JetCorrectorParameters fParameters)

Definition at line 14 of file SimpleJetCorrectionUncertainty.cc.

14  {
15  mParameters = new JetCorrectorParameters(fParameters);
16 }

References mParameters.

◆ ~SimpleJetCorrectionUncertainty()

SimpleJetCorrectionUncertainty::~SimpleJetCorrectionUncertainty ( )

Definition at line 18 of file SimpleJetCorrectionUncertainty.cc.

18 { delete mParameters; }

References mParameters.

◆ SimpleJetCorrectionUncertainty() [4/4]

SimpleJetCorrectionUncertainty::SimpleJetCorrectionUncertainty ( const SimpleJetCorrectionUncertainty )
privatedelete

Member Function Documentation

◆ findBin()

int SimpleJetCorrectionUncertainty::findBin ( const std::vector< float > &  v,
float  x 
) const
private

Definition at line 87 of file SimpleJetCorrectionUncertainty.cc.

87  {
88  int i;
89  int n = v.size() - 1;
90  if (n <= 0)
91  return -1;
92  if (x < v[0] || x >= v[n])
93  return -1;
94  for (i = 0; i < n; i++) {
95  if (x >= v[i] && x < v[i + 1])
96  return i;
97  }
98  return 0;
99 }

References mps_fire::i, dqmiodumpmetadata::n, findQualityFiles::v, and x.

Referenced by uncertaintyBin().

◆ linearInterpolation()

float SimpleJetCorrectionUncertainty::linearInterpolation ( float  fZ,
const float  fX[2],
const float  fY[2] 
) const
private

Definition at line 68 of file SimpleJetCorrectionUncertainty.cc.

68  {
69  // Linear interpolation through the points (x[i],y[i]). First find the line that
70  // is defined by the points and then calculate the y(z).
71  float r = 0;
72  if (fX[0] == fX[1]) {
73  if (fY[0] == fY[1])
74  r = fY[0];
75  else {
76  edm::LogError("SimpleJetCorrectionUncertainty") << " interpolation error";
77  return -999.0;
78  }
79  } else {
80  float a = (fY[1] - fY[0]) / (fX[1] - fX[0]);
81  float b = (fY[0] * fX[1] - fY[1] * fX[0]) / (fX[1] - fX[0]);
82  r = a * fZ + b;
83  }
84  return r;
85 }

References a, b, and alignCSCRings::r.

Referenced by uncertaintyBin().

◆ operator=()

SimpleJetCorrectionUncertainty& SimpleJetCorrectionUncertainty::operator= ( const SimpleJetCorrectionUncertainty )
privatedelete

◆ parameters()

const JetCorrectorParameters& SimpleJetCorrectionUncertainty::parameters ( void  ) const
inline

Definition at line 16 of file SimpleJetCorrectionUncertainty.h.

16 { return *mParameters; }

References mParameters.

Referenced by JetCorrectionUncertainty::getUncertainty().

◆ uncertainty()

float SimpleJetCorrectionUncertainty::uncertainty ( const std::vector< float > &  fX,
float  fY,
bool  fDirection 
) const

Definition at line 20 of file SimpleJetCorrectionUncertainty.cc.

20  {
21  float result = 1.;
22  int bin = mParameters->binIndex(fX);
23  if (bin < 0) {
24  edm::LogError("SimpleJetCorrectionUncertainty") << " bin variables out of range";
25  result = -999.0;
26  } else
27  result = uncertaintyBin((unsigned)bin, fY, fDirection);
28  return result;
29 }

References newFWLiteAna::bin, JetCorrectorParameters::binIndex(), mParameters, mps_fire::result, and uncertaintyBin().

Referenced by average.Average::average(), and JetCorrectionUncertainty::getUncertainty().

◆ uncertaintyBin()

float SimpleJetCorrectionUncertainty::uncertaintyBin ( unsigned  fBin,
float  fY,
bool  fDirection 
) const
private

Definition at line 31 of file SimpleJetCorrectionUncertainty.cc.

31  {
32  if (fBin >= mParameters->size()) {
33  edm::LogError("SimpleJetCorrectionUncertainty")
34  << " wrong bin: " << fBin << ": only " << mParameters->size() << " are available";
35  return -999.0;
36  }
37  const std::vector<float>& p = mParameters->record(fBin).parameters();
38  if ((p.size() % 3) != 0)
39  throw cms::Exception("SimpleJetCorrectionUncertainty")
40  << "wrong # of parameters: multiple of 3 expected, " << p.size() << " got";
41  std::vector<float> yGrid, value;
42  unsigned int N = p.size() / 3;
43  float result = -1.0;
44  for (unsigned i = 0; i < N; i++) {
45  unsigned ind = 3 * i;
46  yGrid.push_back(p[ind]);
47  if (fDirection) // true = UP
48  value.push_back(p[ind + 1]);
49  else // false = DOWN
50  value.push_back(p[ind + 2]);
51  }
52  if (fY <= yGrid[0])
53  result = value[0];
54  else if (fY >= yGrid[N - 1])
55  result = value[N - 1];
56  else {
57  int bin = findBin(yGrid, fY);
58  float vx[2], vy[2];
59  for (int i = 0; i < 2; i++) {
60  vx[i] = yGrid[bin + i];
61  vy[i] = value[bin + i];
62  }
63  result = linearInterpolation(fY, vx, vy);
64  }
65  return result;
66 }

References newFWLiteAna::bin, Exception, findBin(), mps_fire::i, linearInterpolation(), mParameters, N, AlCaHLTBitMon_ParallelJobs::p, JetCorrectorParameters::Record::parameters(), JetCorrectorParameters::record(), mps_fire::result, JetCorrectorParameters::size(), and relativeConstraints::value.

Referenced by uncertainty().

Member Data Documentation

◆ mParameters

JetCorrectorParameters* SimpleJetCorrectionUncertainty::mParameters
private
SimpleJetCorrectionUncertainty::uncertaintyBin
float uncertaintyBin(unsigned fBin, float fY, bool fDirection) const
Definition: SimpleJetCorrectionUncertainty.cc:31
mps_fire.i
i
Definition: mps_fire.py:428
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
DDAxes::x
findQualityFiles.v
v
Definition: findQualityFiles.py:179
SimpleJetCorrectionUncertainty::linearInterpolation
float linearInterpolation(float fZ, const float fX[2], const float fY[2]) const
Definition: SimpleJetCorrectionUncertainty.cc:68
N
#define N
Definition: blowfish.cc:9
b
double b
Definition: hdecay.h:118
a
double a
Definition: hdecay.h:119
JetCorrectorParameters::record
const Record & record(unsigned fBin) const
Definition: JetCorrectorParameters.h:121
value
Definition: value.py:1
JetCorrectorParameters::Record::parameters
std::vector< float > parameters() const
Definition: JetCorrectorParameters.h:79
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
alignCSCRings.r
r
Definition: alignCSCRings.py:93
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
SimpleJetCorrectionUncertainty::mParameters
JetCorrectorParameters * mParameters
Definition: SimpleJetCorrectionUncertainty.h:25
relativeConstraints.value
value
Definition: relativeConstraints.py:53
JetCorrectorParameters::size
unsigned size() const
Definition: JetCorrectorParameters.h:123
Exception
Definition: hltDiff.cc:245
JetCorrectorParameters
Definition: JetCorrectorParameters.h:25
JetCorrectorParameters::binIndex
int binIndex(const std::vector< float > &fX) const
Definition: JetCorrectorParameters.cc:178
mps_fire.result
result
Definition: mps_fire.py:311
SimpleJetCorrectionUncertainty::findBin
int findBin(const std::vector< float > &v, float x) const
Definition: SimpleJetCorrectionUncertainty.cc:87