#include <SimpleJetCorrectionUncertainty.h>
Public Member Functions | |
const JetCorrectorParameters & | parameters () const |
SimpleJetCorrectionUncertainty () | |
SimpleJetCorrectionUncertainty (const std::string &fDataFile) | |
SimpleJetCorrectionUncertainty (const JetCorrectorParameters &fParameters) | |
float | uncertainty (std::vector< float > fX, float fY, bool fDirection) const |
~SimpleJetCorrectionUncertainty () | |
Private Member Functions | |
int | findBin (std::vector< float > v, float x) const |
float | linearInterpolation (float fZ, const float fX[2], const float fY[2]) const |
SimpleJetCorrectionUncertainty & | operator= (const SimpleJetCorrectionUncertainty &) |
SimpleJetCorrectionUncertainty (const SimpleJetCorrectionUncertainty &) | |
float | uncertaintyBin (unsigned fBin, float fY, bool fDirection) const |
Private Attributes | |
JetCorrectorParameters * | mParameters |
Definition at line 8 of file SimpleJetCorrectionUncertainty.h.
SimpleJetCorrectionUncertainty::SimpleJetCorrectionUncertainty | ( | ) |
Definition at line 8 of file SimpleJetCorrectionUncertainty.cc.
References mParameters.
{ mParameters = new JetCorrectorParameters(); }
SimpleJetCorrectionUncertainty::SimpleJetCorrectionUncertainty | ( | const std::string & | fDataFile | ) |
Definition at line 13 of file SimpleJetCorrectionUncertainty.cc.
References mParameters.
{ mParameters = new JetCorrectorParameters(fDataFile); }
SimpleJetCorrectionUncertainty::SimpleJetCorrectionUncertainty | ( | const JetCorrectorParameters & | fParameters | ) |
Definition at line 18 of file SimpleJetCorrectionUncertainty.cc.
References mParameters.
{ mParameters = new JetCorrectorParameters(fParameters); }
SimpleJetCorrectionUncertainty::~SimpleJetCorrectionUncertainty | ( | ) |
Definition at line 23 of file SimpleJetCorrectionUncertainty.cc.
References mParameters.
{ delete mParameters; }
SimpleJetCorrectionUncertainty::SimpleJetCorrectionUncertainty | ( | const SimpleJetCorrectionUncertainty & | ) | [private] |
int SimpleJetCorrectionUncertainty::findBin | ( | std::vector< float > | v, |
float | x | ||
) | const [private] |
float SimpleJetCorrectionUncertainty::linearInterpolation | ( | float | fZ, |
const float | fX[2], | ||
const float | fY[2] | ||
) | const [private] |
Definition at line 75 of file SimpleJetCorrectionUncertainty.cc.
References a, b, Exception, and alignCSCRings::r.
Referenced by uncertaintyBin().
{ // Linear interpolation through the points (x[i],y[i]). First find the line that // is defined by the points and then calculate the y(z). float r = 0; if (fX[0] == fX[1]) { if (fY[0] == fY[1]) r = fY[0]; else throw cms::Exception("SimpleJetCorrectionUncertainty")<<" interpolation error"; } else { float a = (fY[1]-fY[0])/(fX[1]-fX[0]); float b = (fY[0]*fX[1]-fY[1]*fX[0])/(fX[1]-fX[0]); r = a*fZ+b; } return r; }
SimpleJetCorrectionUncertainty& SimpleJetCorrectionUncertainty::operator= | ( | const SimpleJetCorrectionUncertainty & | ) | [private] |
const JetCorrectorParameters& SimpleJetCorrectionUncertainty::parameters | ( | void | ) | const [inline] |
Definition at line 15 of file SimpleJetCorrectionUncertainty.h.
References mParameters.
Referenced by JetCorrectionUncertainty::getUncertainty().
{return *mParameters;}
float SimpleJetCorrectionUncertainty::uncertainty | ( | std::vector< float > | fX, |
float | fY, | ||
bool | fDirection | ||
) | const |
Definition at line 28 of file SimpleJetCorrectionUncertainty.cc.
References newFWLiteAna::bin, JetCorrectorParameters::binIndex(), Exception, mParameters, query::result, and uncertaintyBin().
Referenced by JetCorrectionUncertainty::getUncertainty().
{ float result = 1.; int bin = mParameters->binIndex(fX); if (bin<0) throw cms::Exception("SimpleJetCorrectionUncertainty")<<" bin variables out of range"; result = uncertaintyBin((unsigned)bin,fY,fDirection); return result; }
float SimpleJetCorrectionUncertainty::uncertaintyBin | ( | unsigned | fBin, |
float | fY, | ||
bool | fDirection | ||
) | const [private] |
Definition at line 38 of file SimpleJetCorrectionUncertainty.cc.
References newFWLiteAna::bin, Exception, findBin(), i, linearInterpolation(), mParameters, N, AlCaHLTBitMon_ParallelJobs::p, JetCorrectorParameters::record(), query::result, JetCorrectorParameters::size(), and relativeConstraints::value.
Referenced by uncertainty().
{ if (fBin >= mParameters->size()) throw cms::Exception("SimpleJetCorrectionUncertainty")<<" wrong bin: "<<fBin<<": only "<<mParameters->size()<<" are available"; const std::vector<float>& p = mParameters->record(fBin).parameters(); if ((p.size() % 3) != 0) throw cms::Exception ("SimpleJetCorrectionUncertainty")<<"wrong # of parameters: multiple of 3 expected, "<<p.size()<< " got"; std::vector<float> yGrid,value; unsigned int N = p.size()/3; float result = -1.0; for(unsigned i=0;i<N;i++) { unsigned ind = 3*i; yGrid.push_back(p[ind]); if (fDirection)// true = UP value.push_back(p[ind+1]); else // false = DOWN value.push_back(p[ind+2]); } if (fY <= yGrid[0]) result = value[0]; else if (fY >= yGrid[N-1]) result = value[N-1]; else { int bin = findBin(yGrid,fY); float vx[2],vy[2]; for(int i=0;i<2;i++) { vx[i] = yGrid[bin+i]; vy[i] = value[bin+i]; } result = linearInterpolation(fY,vx,vy); } return result; }
Definition at line 24 of file SimpleJetCorrectionUncertainty.h.
Referenced by parameters(), SimpleJetCorrectionUncertainty(), uncertainty(), uncertaintyBin(), and ~SimpleJetCorrectionUncertainty().