// RooArgusBg is a RooAbsPdf implementation describing the ARGUS background shape
// END_HTML
#include "RooFit.h"
#include "Riostream.h"
#include "Riostream.h"
#include <math.h>
#include "RooArgusBG.h"
#include "RooRealVar.h"
#include "RooRealConstant.h"
#include "RooMath.h"
#include "TMath.h"
using namespace std;
ClassImp(RooArgusBG)
RooArgusBG::RooArgusBG(const char *name, const char *title,
RooAbsReal& _m, RooAbsReal& _m0, RooAbsReal& _c) :
RooAbsPdf(name, title),
m("m","Mass",this,_m),
m0("m0","Resonance mass",this,_m0),
c("c","Slope parameter",this,_c),
p("p","Power",this,(RooRealVar&)RooRealConstant::value(0.5))
{
}
RooArgusBG::RooArgusBG(const char *name, const char *title,
RooAbsReal& _m, RooAbsReal& _m0, RooAbsReal& _c, RooAbsReal& _p) :
RooAbsPdf(name, title),
m("m","Mass",this,_m),
m0("m0","Resonance mass",this,_m0),
c("c","Slope parameter",this,_c),
p("p","Power",this,_p)
{
}
RooArgusBG::RooArgusBG(const RooArgusBG& other, const char* name) :
RooAbsPdf(other,name),
m("m",this,other.m),
m0("m0",this,other.m0),
c("c",this,other.c),
p("p",this,other.p)
{
}
Double_t RooArgusBG::evaluate() const {
Double_t t= m/m0;
if(t >= 1) return 0;
Double_t u= 1 - t*t;
return m*TMath::Power(u,p)*exp(c*u) ;
}
Int_t RooArgusBG::getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char* ) const
{
if (p.arg().isConstant()) {
if (matchArgs(allVars,analVars,m) && p == 0.5) return 1;
}
return 0;
}
Double_t RooArgusBG::analyticalIntegral(Int_t code, const char* rangeName) const
{
(void)code;
assert(code==1);
static const Double_t pi = atan2(0.0,-1.0);
Double_t min = (m.min(rangeName) < m0) ? m.min(rangeName) : m0;
Double_t max = (m.max(rangeName) < m0) ? m.max(rangeName) : m0;
Double_t f1 = (1.-TMath::Power(min/m0,2));
Double_t f2 = (1.-TMath::Power(max/m0,2));
Double_t aLow, aHigh ;
aLow = -0.5*m0*m0*(exp(c*f1)*sqrt(f1)/c + 0.5/TMath::Power(-c,1.5)*sqrt(pi)*RooMath::erf(sqrt(-c*f1)));
aHigh = -0.5*m0*m0*(exp(c*f2)*sqrt(f2)/c + 0.5/TMath::Power(-c,1.5)*sqrt(pi)*RooMath::erf(sqrt(-c*f2)));
Double_t area = aHigh - aLow;
return area;
}