-
Notifications
You must be signed in to change notification settings - Fork 0
/
ErrFFitDescription.C
105 lines (80 loc) · 3.22 KB
/
ErrFFitDescription.C
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
96
97
98
99
100
101
102
103
104
//////////////////////////////////////////////////////////////////////////
//
// 'BASIC FUNCTIONALITY' RooFit tutorial macro #104
//
// The class factory for functions and p.d.f.s
//
//
// NOTE: This demo uses code that is generated by the macro,
// therefore it cannot be compiled in one step by ACliC.
// To run this macro compiled with ACliC do
//
// root>.x rf104_classfactory.C // run interpreted to generate code
// root>.L MyPdfV3.cxx+ // Compile and load created classs
// root>.x rf104_classfactory.C+ // run compiled code
//
//
// 07/2008 - Wouter Verkerke
//
/////////////////////////////////////////////////////////////////////////
#ifndef __CINT__
#include "RooGlobalFunc.h"
#endif
#include "RooRealVar.h"
#include "RooDataSet.h"
#include "RooGaussian.h"
#include "TCanvas.h"
#include "TAxis.h"
#include "RooPlot.h"
#include "RooClassFactory.h"
#include "TROOT.h"
#ifndef __CINT__
#include "MyPdfV1.h"
#endif
using namespace RooFit ;
void ErrFFitDescription()
{
// W r i t e c l a s s s k e l e t o n c o d e
// --------------------------------------------------
// Write skeleton p.d.f class with variable x,a,b
// To use this class,
// - Edit the file MyPdfV1.cxx and implement the evaluate() method in terms of x,a and b
// - Compile and link class with '.x MyPdfV1.cxx+'
//
//RooClassFactory::makePdf("MyPdfV1","x,m,c,p") ;
// W i t h a d d e d i n i t i a l v a l u e e x p r e s s i o n
// ---------------------------------------------------------------------
// Write skeleton p.d.f class with variable x,a,b and given formula expression
// To use this class,
// - Compile and link class with '.x MyPdfV2.cxx+'
//
//RooClassFactory::makePdf("MyPdfV2","x,A,B","","A*fabs(x)+pow(x-B,2)") ;
// W i t h a d d e d a n a l y t i c a l i n t e g r a l e x p r e s s i o n
// ---------------------------------------------------------------------------------
// Write skeleton p.d.f class with variable x,a,b, given formula expression _and_
// given expression for analytical integral over x
// To use this class,
// - Compile and link class with '.x MyPdfV3.cxx+'
//
//RooClassFactory::makePdf("MyPdfV1","x,m,c,p","","m*fabs(x)+pow(x-c,2)",kTRUE,kFALSE,
// "x:(m/2)*(pow(x.max(rangeName),2)+pow(x.min(rangeName),2))+(1./3)*(pow(x.max(rangeName)-c,3)-pow(x.min(rangeName)-c,3))") ;
// U s e i n s t a n c e o f c r e a t e d c l a s s
// ---------------------------------------------------------
// Compile MyPdfV3 class (only when running in CINT)
#ifdef __CINT__
gROOT->ProcessLineSync(".x MyPdfV1.cxx+") ;
#endif
// Creat instance of MyPdfV3 class
RooRealVar a("a","a",1.) ;
RooRealVar b("b","b",1.) ;
RooRealVar y("y","y",0.,5.);
MyPdfV1 pdf("pdf","pdf",y,a,b) ;
// Generate toy data from pdf and plot data and p.d.f on frame
RooPlot* frame1 = y.frame(Title("Compiled class MyPdfV3")) ;
RooDataSet* data = pdf.generate(y,1000) ;
pdf.fitTo(*data) ;
data->plotOn(frame1) ;
pdf.plotOn(frame1) ;
TCanvas* c = new TCanvas("rf104_classfactory","rf104_classfactory",800,400) ;
gPad->SetLeftMargin(0.15) ; frame1->GetYaxis()->SetTitleOffset(1.4) ; frame1->Draw() ;
}