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

SimpleJetCorrectionUncertaintyoperator= (const SimpleJetCorrectionUncertainty &)=delete
 
const JetCorrectorParametersparameters () const
 
 SimpleJetCorrectionUncertainty ()
 
 SimpleJetCorrectionUncertainty (const std::string &fDataFile)
 
 SimpleJetCorrectionUncertainty (const JetCorrectorParameters &fParameters)
 
 SimpleJetCorrectionUncertainty (const SimpleJetCorrectionUncertainty &)=delete
 
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
 
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 ( )

◆ SimpleJetCorrectionUncertainty() [2/4]

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

Definition at line 10 of file SimpleJetCorrectionUncertainty.cc.

References mParameters.

◆ SimpleJetCorrectionUncertainty() [3/4]

SimpleJetCorrectionUncertainty::SimpleJetCorrectionUncertainty ( const JetCorrectorParameters fParameters)

Definition at line 14 of file SimpleJetCorrectionUncertainty.cc.

References mParameters.

◆ SimpleJetCorrectionUncertainty() [4/4]

SimpleJetCorrectionUncertainty::SimpleJetCorrectionUncertainty ( const SimpleJetCorrectionUncertainty )
delete

◆ ~SimpleJetCorrectionUncertainty()

SimpleJetCorrectionUncertainty::~SimpleJetCorrectionUncertainty ( )

Definition at line 18 of file SimpleJetCorrectionUncertainty.cc.

References mParameters.

18 { delete mParameters; }

Member Function Documentation

◆ findBin()

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

Definition at line 87 of file SimpleJetCorrectionUncertainty.cc.

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

Referenced by uncertaintyBin().

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 }

◆ linearInterpolation()

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

Definition at line 68 of file SimpleJetCorrectionUncertainty.cc.

References a, b, and alignCSCRings::r.

Referenced by uncertaintyBin().

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 }
Log< level::Error, false > LogError
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121

◆ operator=()

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

◆ parameters()

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

Definition at line 18 of file SimpleJetCorrectionUncertainty.h.

References mParameters.

Referenced by JetCorrectionUncertainty::getUncertainty().

18 { return *mParameters; }

◆ uncertainty()

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

Definition at line 20 of file SimpleJetCorrectionUncertainty.cc.

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

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

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 }
float uncertaintyBin(unsigned fBin, float fY, bool fDirection) const
int binIndex(const std::vector< float > &fX) const
Log< level::Error, false > LogError

◆ uncertaintyBin()

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

Definition at line 31 of file SimpleJetCorrectionUncertainty.cc.

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

Referenced by uncertainty().

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  }
64  }
65  return result;
66 }
std::vector< float > parameters() const
Log< level::Error, false > LogError
int findBin(const std::vector< float > &v, float x) const
Definition: value.py:1
#define N
Definition: blowfish.cc:9
const Record & record(unsigned fBin) const
float linearInterpolation(float fZ, const float fX[2], const float fY[2]) const

Member Data Documentation

◆ mParameters

JetCorrectorParameters* SimpleJetCorrectionUncertainty::mParameters
private