CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 std::string &fDataFile)
 
 SimpleJetCorrectionUncertainty (const JetCorrectorParameters &fParameters)
 
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 &)
 
 SimpleJetCorrectionUncertainty (const SimpleJetCorrectionUncertainty &)
 
float uncertaintyBin (unsigned fBin, float fY, bool fDirection) const
 

Private Attributes

JetCorrectorParametersmParameters
 

Detailed Description

Definition at line 8 of file SimpleJetCorrectionUncertainty.h.

Constructor & Destructor Documentation

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

Definition at line 13 of file SimpleJetCorrectionUncertainty.cc.

References mParameters.

SimpleJetCorrectionUncertainty::SimpleJetCorrectionUncertainty ( const JetCorrectorParameters fParameters)

Definition at line 18 of file SimpleJetCorrectionUncertainty.cc.

References mParameters.

SimpleJetCorrectionUncertainty::~SimpleJetCorrectionUncertainty ( )

Definition at line 23 of file SimpleJetCorrectionUncertainty.cc.

References mParameters.

24 {
25  delete mParameters;
26 }
SimpleJetCorrectionUncertainty::SimpleJetCorrectionUncertainty ( const SimpleJetCorrectionUncertainty )
private

Member Function Documentation

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

Definition at line 96 of file SimpleJetCorrectionUncertainty.cc.

References i, and n.

Referenced by uncertaintyBin().

97 {
98  int i;
99  int n = v.size()-1;
100  if (n<=0) return -1;
101  if (x<v[0] || x>=v[n])
102  return -1;
103  for(i=0;i<n;i++)
104  {
105  if (x>=v[i] && x<v[i+1])
106  return i;
107  }
108  return 0;
109 }
int i
Definition: DBlmapReader.cc:9
Definition: DDAxes.h:10
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, edm::hlt::Exception, and alignCSCRings::r.

Referenced by uncertaintyBin().

76 {
77  // Linear interpolation through the points (x[i],y[i]). First find the line that
78  // is defined by the points and then calculate the y(z).
79  float r = 0;
80  if (fX[0] == fX[1])
81  {
82  if (fY[0] == fY[1])
83  r = fY[0];
84  else
85  throw cms::Exception("SimpleJetCorrectionUncertainty")<<" interpolation error";
86  }
87  else
88  {
89  float a = (fY[1]-fY[0])/(fX[1]-fX[0]);
90  float b = (fY[0]*fX[1]-fY[1]*fX[0])/(fX[1]-fX[0]);
91  r = a*fZ+b;
92  }
93  return r;
94 }
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
SimpleJetCorrectionUncertainty& SimpleJetCorrectionUncertainty::operator= ( const SimpleJetCorrectionUncertainty )
private
const JetCorrectorParameters& SimpleJetCorrectionUncertainty::parameters ( void  ) const
inline
float SimpleJetCorrectionUncertainty::uncertainty ( const std::vector< float > &  fX,
float  fY,
bool  fDirection 
) const

Definition at line 28 of file SimpleJetCorrectionUncertainty.cc.

References newFWLiteAna::bin, JetCorrectorParameters::binIndex(), edm::hlt::Exception, mParameters, query::result, and uncertaintyBin().

Referenced by JetCorrectionUncertainty::getUncertainty().

29 {
30  float result = 1.;
31  int bin = mParameters->binIndex(fX);
32  if (bin<0)
33  throw cms::Exception("SimpleJetCorrectionUncertainty")<<" bin variables out of range";
34  result = uncertaintyBin((unsigned)bin,fY,fDirection);
35  return result;
36 }
float uncertaintyBin(unsigned fBin, float fY, bool fDirection) const
int binIndex(const std::vector< float > &fX) const
tuple result
Definition: query.py:137
float SimpleJetCorrectionUncertainty::uncertaintyBin ( unsigned  fBin,
float  fY,
bool  fDirection 
) const
private

Definition at line 38 of file SimpleJetCorrectionUncertainty.cc.

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

Referenced by uncertainty().

39 {
40  if (fBin >= mParameters->size())
41  throw cms::Exception("SimpleJetCorrectionUncertainty")<<" wrong bin: "<<fBin<<": only "<<mParameters->size()<<" are available";
42  const std::vector<float>& p = mParameters->record(fBin).parameters();
43  if ((p.size() % 3) != 0)
44  throw cms::Exception ("SimpleJetCorrectionUncertainty")<<"wrong # of parameters: multiple of 3 expected, "<<p.size()<< " got";
45  std::vector<float> yGrid,value;
46  unsigned int N = p.size()/3;
47  float result = -1.0;
48  for(unsigned i=0;i<N;i++)
49  {
50  unsigned ind = 3*i;
51  yGrid.push_back(p[ind]);
52  if (fDirection)// true = UP
53  value.push_back(p[ind+1]);
54  else // false = DOWN
55  value.push_back(p[ind+2]);
56  }
57  if (fY <= yGrid[0])
58  result = value[0];
59  else if (fY >= yGrid[N-1])
60  result = value[N-1];
61  else
62  {
63  int bin = findBin(yGrid,fY);
64  float vx[2],vy[2];
65  for(int i=0;i<2;i++)
66  {
67  vx[i] = yGrid[bin+i];
68  vy[i] = value[bin+i];
69  }
70  result = linearInterpolation(fY,vx,vy);
71  }
72  return result;
73 }
int i
Definition: DBlmapReader.cc:9
std::vector< float > parameters() const
const Record & record(unsigned fBin) const
float linearInterpolation(float fZ, const float fX[2], const float fY[2]) const
int findBin(const std::vector< float > &v, float x) const
tuple result
Definition: query.py:137
#define N
Definition: blowfish.cc:9

Member Data Documentation

JetCorrectorParameters* SimpleJetCorrectionUncertainty::mParameters
private