CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch2/src/HiggsAnalysis/CombinedLimit/src/AsymPow.cc

Go to the documentation of this file.
00001 #include "../interface/AsymPow.h"
00002 
00003 #include <cmath>
00004 #include <cassert>
00005 #include <cstdio>
00006 
00007 AsymPow::AsymPow(const char *name, const char *title, RooAbsReal &kappaLow, RooAbsReal &kappaHigh, RooAbsReal &theta) :
00008         RooAbsReal(name,title),
00009         kappaLow_("kappaLow","Base for theta < 0", this, kappaLow), 
00010         kappaHigh_("kappaHigh","Base for theta > 0", this, kappaHigh),
00011         theta_("theta", "Exponent (unit gaussian)", this, theta) 
00012         { }
00013 
00014 AsymPow::~AsymPow() {}
00015 
00016 TObject *AsymPow::clone(const char *newname) const 
00017 {
00018     // never understood if RooFit actually cares of const-correctness or not.
00019     return new AsymPow(newname, this->GetTitle(), 
00020                 const_cast<RooAbsReal &>(kappaLow_.arg()), 
00021                 const_cast<RooAbsReal &>(kappaHigh_.arg()),
00022                 const_cast<RooAbsReal &>(theta_.arg()));
00023 }
00024 
00025 Double_t AsymPow::evaluate() const {
00026     Double_t x = theta_;
00027     return exp(logKappaForX(x) * x);
00028 }
00029 
00030 Double_t AsymPow::logKappaForX(Double_t x) const {
00031 #if 0
00032     // old version with discontinuous derivatives
00033     return (x >= 0 ? log(kappaHigh_) : - log(kappaLow_));
00034 #else
00035     if (fabs(x) >= 0.5) return (x >= 0 ? log(kappaHigh_) : - log(kappaLow_));
00036     // interpolate between log(kappaHigh) and -log(kappaLow) 
00037     //    logKappa(x) = avg + halfdiff * h(2x)
00038     // where h(x) is the 3th order polynomial
00039     //    h(x) = (3 x^5 - 10 x^3 + 15 x)/8;
00040     // chosen so that h(x) satisfies the following:
00041     //      h (+/-1) = +/-1 
00042     //      h'(+/-1) = 0
00043     //      h"(+/-1) = 0
00044     double logKhi =  log(kappaHigh_);
00045     double logKlo = -log(kappaLow_);
00046     double avg = 0.5*(logKhi + logKlo), halfdiff = 0.5*(logKhi - logKlo);
00047     double twox = x+x, twox2 = twox*twox;
00048     double alpha = 0.125 * twox * (twox2 * (3*twox2 - 10.) + 15.);
00049     double ret = avg + alpha*halfdiff;
00050     //assert(alpha >= -1 && alpha <= 1 && "Something is wrong in the interpolation");
00051     return ret;
00052 #endif
00053 } 
00054 
00055 ClassImp(AsymPow)