00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef __CINT__
00015 #include "RooGlobalFunc.h"
00016 #endif
00017 #include "RooRealVar.h"
00018 #include "RooDataSet.h"
00019 #include "RooGaussian.h"
00020 #include "TCanvas.h"
00021 #include "RooPlot.h"
00022 using namespace RooFit ;
00023
00024
00025
00026 class TestBasic101 : public RooFitTestUnit
00027 {
00028 public:
00029 TestBasic101(TFile* refFile, Bool_t writeRef, Int_t verbose) : RooFitTestUnit("Fitting,plotting & event generation of basic p.d.f",refFile,writeRef,verbose) {} ;
00030 Bool_t testCode() {
00031
00032
00033
00034
00035
00036 RooRealVar x("x","x",-10,10) ;
00037 RooRealVar mean("mean","mean of gaussian",1,-10,10) ;
00038 RooRealVar sigma("sigma","width of gaussian",1,0.1,10) ;
00039
00040
00041 RooGaussian gauss("gauss","gaussian PDF",x,mean,sigma) ;
00042
00043
00044 RooPlot* xframe = x.frame(Title("Gaussian p.d.f.")) ;
00045
00046
00047
00048
00049
00050
00051 gauss.plotOn(xframe) ;
00052
00053
00054 sigma.setVal(3) ;
00055
00056
00057 gauss.plotOn(xframe,LineColor(kRed),Name("another")) ;
00058
00059
00060
00061
00062
00063
00064 RooDataSet* data = gauss.generate(x,10000) ;
00065
00066
00067
00068 RooPlot* xframe2 = x.frame(Title("Gaussian p.d.f. with data")) ;
00069 data->plotOn(xframe2) ;
00070 gauss.plotOn(xframe2) ;
00071
00072
00073
00074
00075
00076
00077 gauss.fitTo(*data) ;
00078
00079
00080
00081 regPlot(xframe ,"rf101_plot1") ;
00082 regPlot(xframe2,"rf101_plot2") ;
00083
00084 delete data ;
00085
00086 return kTRUE ;
00087 }
00088 } ;
00089
00090