-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRooErfPdf.cxx
82 lines (61 loc) · 2.47 KB
/
RooErfPdf.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
/*****************************************************************************
* Project: RooFit *
* *
* This code was autogenerated by RooClassFactory *
*****************************************************************************/
// Your description goes here...
#include "Riostream.h"
#include "RooErfPdf.h"
#include "RooAbsReal.h"
#include "RooAbsCategory.h"
#include <math.h>
#include "TMath.h"
ClassImp(RooErfPdf)
RooErfPdf::RooErfPdf(const char *name, const char *title,
RooAbsReal& _x,
RooAbsReal& _turnOn,
RooAbsReal& _width) :
RooAbsPdf(name,title),
x("x","x",this,_x),
turnOn("turnOn","turnOn",this,_turnOn),
width("width","width",this,_width)
{
}
RooErfPdf::RooErfPdf(const RooErfPdf& other, const char* name) :
RooAbsPdf(other,name),
x("x",this,other.x),
turnOn("turnOn",this,other.turnOn),
width("width",this,other.width)
{
}
Double_t RooErfPdf::evaluate() const
{
// ENTER EXPRESSION IN TERMS OF VARIABLE ARGUMENTS HERE
return (TMath::Erf((x-turnOn)/width)+1.)/2. ;
}
Int_t RooErfPdf::getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char* /*rangeName*/) const
{
// LIST HERE OVER WHICH VARIABLES ANALYTICAL INTEGRATION IS SUPPORTED,
// ASSIGN A NUMERIC CODE FOR EACH SUPPORTED (SET OF) PARAMETERS
// THE EXAMPLE BELOW ASSIGNS CODE 1 TO INTEGRATION OVER VARIABLE X
// YOU CAN ALSO IMPLEMENT MORE THAN ONE ANALYTICAL INTEGRAL BY REPEATING THE matchArgs
// EXPRESSION MULTIPLE TIMES
if (matchArgs(allVars,analVars,x)) return 1 ;
return 0 ;
}
Double_t RooErfPdf::analyticalIntegral(Int_t code, const char* rangeName) const
{
// RETURN ANALYTICAL INTEGRAL DEFINED BY RETURN CODE ASSIGNED BY getAnalyticalIntegral
// THE MEMBER FUNCTION x.min(rangeName) AND x.max(rangeName) WILL RETURN THE INTEGRATION
// BOUNDARIES FOR EACH OBSERVABLE x
if (code==1) {
return indefIntegral(x.max(rangeName))-indefIntegral(x.min(rangeName));
}
return 0 ;
}
double RooErfPdf::indefIntegral(double val) const {
static double const rootpi = TMath::Sqrt(TMath::Pi());
return 0.5*(val-turnOn)*TMath::Erf((val-turnOn)/width) +
0.5*width/rootpi*TMath::Exp(-(val-turnOn)*(val-turnOn)/width/width) +
0.5*val ;
}