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 "RooPolyVar.h"
00021 #include "RooProdPdf.h"
00022 #include "RooPlot.h"
00023 #include "TRandom.h"
00024 #include "TCanvas.h"
00025 #include "TH1.h"
00026 using namespace RooFit ;
00027
00028
00029 class TestBasic303 : public RooFitTestUnit
00030 {
00031 public:
00032
00033 RooDataSet* makeFakeDataXY()
00034 {
00035 RooRealVar x("x","x",-10,10) ;
00036 RooRealVar y("y","y",-10,10) ;
00037 RooArgSet coord(x,y) ;
00038
00039 RooDataSet* d = new RooDataSet("d","d",RooArgSet(x,y)) ;
00040
00041 for (int i=0 ; i<10000 ; i++) {
00042 Double_t tmpy = gRandom->Gaus(0,10) ;
00043 Double_t tmpx = gRandom->Gaus(0.5*tmpy,1) ;
00044 if (fabs(tmpy)<10 && fabs(tmpx)<10) {
00045 x = tmpx ;
00046 y = tmpy ;
00047 d->add(coord) ;
00048 }
00049
00050 }
00051
00052 return d ;
00053 }
00054
00055
00056
00057 TestBasic303(TFile* refFile, Bool_t writeRef, Int_t verbose) : RooFitTestUnit("Conditional use of F(x|y)",refFile,writeRef,verbose) {} ;
00058 Bool_t testCode() {
00059
00060
00061
00062
00063
00064 RooRealVar x("x","x",-10,10) ;
00065 RooRealVar y("y","y",-10,10) ;
00066
00067
00068 RooRealVar a0("a0","a0",-0.5,-5,5) ;
00069 RooRealVar a1("a1","a1",-0.5,-1,1) ;
00070 RooPolyVar fy("fy","fy",y,RooArgSet(a0,a1)) ;
00071
00072
00073 RooRealVar sigma("sigma","width of gaussian",0.5,0.1,2.0) ;
00074 RooGaussian model("model","Gaussian with shifting mean",x,fy,sigma) ;
00075
00076
00077
00078 RooDataSet* expDataXY = makeFakeDataXY() ;
00079
00080
00081
00082
00083
00084
00085
00086 RooDataSet* expDataY= (RooDataSet*) expDataXY->reduce(y) ;
00087
00088
00089 RooDataSet *data = model.generate(x,ProtoData(*expDataY)) ;
00090
00091
00092
00093
00094
00095
00096 model.fitTo(*expDataXY,ConditionalObservables(y)) ;
00097
00098
00099
00100
00101
00102
00103
00104 RooPlot* xframe = x.frame() ;
00105 expDataXY->plotOn(xframe) ;
00106 model.plotOn(xframe,ProjWData(*expDataY)) ;
00107
00108
00109
00110 RooAbsData* binnedDataY = expDataY->binnedClone() ;
00111 model.plotOn(xframe,ProjWData(*binnedDataY),LineColor(kCyan),LineStyle(kDotted),Name("Alt1")) ;
00112
00113
00114
00115 ((RooRealVar*)expDataY->get()->find("y"))->setBins(5) ;
00116 RooAbsData* binnedDataY2 = expDataY->binnedClone() ;
00117 model.plotOn(xframe,ProjWData(*binnedDataY2),LineColor(kRed),Name("Alt2")) ;
00118
00119
00120 regPlot(xframe,"rf303_plot1") ;
00121
00122 delete binnedDataY ;
00123 delete binnedDataY2 ;
00124 delete expDataXY ;
00125 delete expDataY ;
00126 delete data ;
00127
00128 return kTRUE ;
00129 }
00130 } ;
00131
00132
00133
00134