CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
AsymPow.cc
Go to the documentation of this file.
1 #include "../interface/AsymPow.h"
2 
3 #include <cmath>
4 #include <cassert>
5 #include <cstdio>
6 
7 AsymPow::AsymPow(const char *name, const char *title, RooAbsReal &kappaLow, RooAbsReal &kappaHigh, RooAbsReal &theta) :
8  RooAbsReal(name,title),
9  kappaLow_("kappaLow","Base for theta < 0", this, kappaLow),
10  kappaHigh_("kappaHigh","Base for theta > 0", this, kappaHigh),
11  theta_("theta", "Exponent (unit gaussian)", this, theta)
12  { }
13 
15 
16 TObject *AsymPow::clone(const char *newname) const
17 {
18  // never understood if RooFit actually cares of const-correctness or not.
19  return new AsymPow(newname, this->GetTitle(),
20  const_cast<RooAbsReal &>(kappaLow_.arg()),
21  const_cast<RooAbsReal &>(kappaHigh_.arg()),
22  const_cast<RooAbsReal &>(theta_.arg()));
23 }
24 
25 Double_t AsymPow::evaluate() const {
26  Double_t x = theta_;
27  return exp(logKappaForX(x) * x);
28 }
29 
30 Double_t AsymPow::logKappaForX(Double_t x) const {
31 #if 0
32  // old version with discontinuous derivatives
33  return (x >= 0 ? log(kappaHigh_) : - log(kappaLow_));
34 #else
35  if (fabs(x) >= 0.5) return (x >= 0 ? log(kappaHigh_) : - log(kappaLow_));
36  // interpolate between log(kappaHigh) and -log(kappaLow)
37  // logKappa(x) = avg + halfdiff * h(2x)
38  // where h(x) is the 3th order polynomial
39  // h(x) = (3 x^5 - 10 x^3 + 15 x)/8;
40  // chosen so that h(x) satisfies the following:
41  // h (+/-1) = +/-1
42  // h'(+/-1) = 0
43  // h"(+/-1) = 0
44  double logKhi = log(kappaHigh_);
45  double logKlo = -log(kappaLow_);
46  double avg = 0.5*(logKhi + logKlo), halfdiff = 0.5*(logKhi - logKlo);
47  double twox = x+x, twox2 = twox*twox;
48  double alpha = 0.125 * twox * (twox2 * (3*twox2 - 10.) + 15.);
49  double ret = avg + alpha*halfdiff;
50  //assert(alpha >= -1 && alpha <= 1 && "Something is wrong in the interpolation");
51  return ret;
52 #endif
53 }
54 
55 ClassImp(AsymPow)
float alpha
Definition: AMPTWrapper.h:95
Double_t evaluate() const
Definition: AsymPow.cc:25
Geom::Theta< T > theta() const
TObject * clone(const char *newname) const
Definition: AsymPow.cc:16
RooRealProxy theta_
Definition: AsymPow.h:36
AsymPow()
Definition: AsymPow.h:25
Double_t logKappaForX(Double_t x) const
Definition: AsymPow.cc:30
~AsymPow()
Definition: AsymPow.cc:14
RooRealProxy kappaHigh_
Definition: AsymPow.h:35
RooRealProxy kappaLow_
Definition: AsymPow.h:35
Definition: DDAxes.h:10