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 10 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 102 of file SimpleJetCorrectionUncertainty.cc.

References i, and gen::n.

Referenced by uncertaintyBin().

103 {
104  int i;
105  int n = v.size()-1;
106  if (n<=0) return -1;
107  if (x<v[0] || x>=v[n])
108  return -1;
109  for(i=0;i<n;i++)
110  {
111  if (x>=v[i] && x<v[i+1])
112  return i;
113  }
114  return 0;
115 }
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 79 of file SimpleJetCorrectionUncertainty.cc.

References a, b, and alignCSCRings::r.

Referenced by uncertaintyBin().

80 {
81  // Linear interpolation through the points (x[i],y[i]). First find the line that
82  // is defined by the points and then calculate the y(z).
83  float r = 0;
84  if (fX[0] == fX[1])
85  {
86  if (fY[0] == fY[1])
87  r = fY[0];
88  else {
89  edm::LogError("SimpleJetCorrectionUncertainty")<<" interpolation error";
90  return -999.0;
91  }
92  }
93  else
94  {
95  float a = (fY[1]-fY[0])/(fX[1]-fX[0]);
96  float b = (fY[0]*fX[1]-fY[1]*fX[0])/(fX[1]-fX[0]);
97  r = a*fZ+b;
98  }
99  return r;
100 }
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(), mParameters, query::result, and uncertaintyBin().

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

29 {
30  float result = 1.;
31  int bin = mParameters->binIndex(fX);
32  if (bin<0) {
33  edm::LogError("SimpleJetCorrectionUncertainty")<<" bin variables out of range";
34  result = -999.0;
35  } else
36  result = uncertaintyBin((unsigned)bin,fY,fDirection);
37  return result;
38 }
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 40 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().

41 {
42  if (fBin >= mParameters->size()) {
43  edm::LogError("SimpleJetCorrectionUncertainty")<<" wrong bin: "<<fBin<<": only "<<mParameters->size()<<" are available";
44  return -999.0;
45  }
46  const std::vector<float>& p = mParameters->record(fBin).parameters();
47  if ((p.size() % 3) != 0)
48  throw cms::Exception ("SimpleJetCorrectionUncertainty")<<"wrong # of parameters: multiple of 3 expected, "<<p.size()<< " got";
49  std::vector<float> yGrid,value;
50  unsigned int N = p.size()/3;
51  float result = -1.0;
52  for(unsigned i=0;i<N;i++)
53  {
54  unsigned ind = 3*i;
55  yGrid.push_back(p[ind]);
56  if (fDirection)// true = UP
57  value.push_back(p[ind+1]);
58  else // false = DOWN
59  value.push_back(p[ind+2]);
60  }
61  if (fY <= yGrid[0])
62  result = value[0];
63  else if (fY >= yGrid[N-1])
64  result = value[N-1];
65  else
66  {
67  int bin = findBin(yGrid,fY);
68  float vx[2],vy[2];
69  for(int i=0;i<2;i++)
70  {
71  vx[i] = yGrid[bin+i];
72  vy[i] = value[bin+i];
73  }
74  result = linearInterpolation(fY,vx,vy);
75  }
76  return result;
77 }
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