CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

SimpleJetCorrectionUncertainty Class Reference

#include <SimpleJetCorrectionUncertainty.h>

List of all members.

Public Member Functions

const JetCorrectorParametersparameters () 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
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 ( )

Definition at line 8 of file SimpleJetCorrectionUncertainty.cc.

References mParameters.

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]

Member Function Documentation

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

Definition at line 96 of file SimpleJetCorrectionUncertainty.cc.

References i, and n.

Referenced by uncertaintyBin().

{
  int i;
  int n = v.size()-1;
  if (n<=0) return -1;
  if (x<v[0] || x>=v[n])
    return -1;
  for(i=0;i<n;i++)
   {
     if (x>=v[i] && x<v[i+1])
       return i;
   }
  return 0; 
}
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 csvReporter::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, MultiGaussianStateTransform::N, L1TEmulatorMonitor_cff::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;
}

Member Data Documentation