This repository has been archived by the owner on Mar 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathRooGausDExp.cxx
95 lines (80 loc) · 2.66 KB
/
RooGausDExp.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*****************************************************************************
* Project: RooFit *
* *
* This code was autogenerated by RooClassFactory *
*****************************************************************************/
#include "RooGausDExp.h"
#include <Riostream.h>
#include <TMath.h>
ClassImp(RooGausDExp)
RooGausDExp::RooGausDExp(const char *name, const char *title,
RooAbsReal& _x,
RooAbsReal& _mu,
RooAbsReal& _sig,
RooAbsReal& _tau0,
RooAbsReal& _tau1)
: RooAbsPdf(name,title)
, x("x","x",this,_x)
, mu("mu","mu",this,_mu)
, sig("sig","sig",this,_sig)
, tau0("tau0","tau",this,_tau0)
, tau1("tau1","tau",this,_tau1) {
}
RooGausDExp::RooGausDExp(const RooGausDExp& other, const char* name)
: RooAbsPdf(other,name)
, x("x",this,other.x)
, mu("mu",this,other.mu)
, sig("sig",this,other.sig)
, tau0("tau0",this,other.tau0)
, tau1("tau1",this,other.tau1) {
}
Double_t RooGausDExp::evaluate() const {
double u = (x - mu) / sig;
if (u < tau0)
return TMath::Exp(-tau0 * (u - 0.5 * tau0));
else if (u <= tau1)
return TMath::Exp(-u * u * 0.5);
else
return TMath::Exp(-tau1 * (u - 0.5 * tau1));
}
#ifdef _AN_INT_
Int_t RooGausDExp::getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char*) const {
if (matchArgs(allVars,analVars,x)) return 1 ;
return 0 ;
}
Double_t RooGausDExp::analyticalIntegral(Int_t code, const char* r) const
{
double umin = (x.min(r) - mu) / sig;
double umax = (x.max(r) - mu) / sig;
R__ASSERT(code==1);
double integral = 0.;
if (umin < tau0) {
integral -= IntExp(umin, tau0);
if (umax <= tau0)
integral += IntExp(umax, tau0);
else {
integral += IntExp(tau0, tau0) - IntGaus(tau0);
if (umax <= tau1)
integral += IntGaus(umax);
else
integral += IntGaus(tau1) - IntExp(tau1, tau1) + IntExp(umax, tau1);
}
} else if (umin < tau1) {
integral -= IntGaus(umin);
if (umax < tau1)
integral += IntGaus(umax);
else
integral += IntGaus(tau1) - IntExp(tau1, tau1) + IntExp(umax, tau1);
} else {
integral = IntExp(umax, tau1) - IntExp(umin, tau1);
}
return sig * integral;
}
#endif
double RooGausDExp::IntExp(double x,double tau) const {
return -1. * TMath::Exp(tau * (0.5 * tau - x)) / tau;
}
double RooGausDExp::IntGaus(double x) const {
static const double rootPiBy2 = TMath::Sqrt(TMath::PiOver2());
return rootPiBy2 * (TMath::Erf(x / TMath::Sqrt2()));
}