Dear experts,
I am trying to use a RooExtendPdf to fitTo a dataset. After the fit is done, I draw the dataset and the pdf in the same frame, but it seems the pdf did not normalize to the number of events in that dataset correctly. angular_reco_cosl_bin3_Index_1.pdf (26.9 KB)
The fit results seems reasonable. So can you tell me what cause this problem?
The following are some segments of my code:
RooRealVar Q2("Q2","q^{2}",1.0,22.);
RooRealVar fh("fh", "F_{H}", Ifh, 0., 3. );
RooRealVar afb("afb", "A_{FB}", Iafb, -1.5, 1.5);
RooRealVar nsig("nsig","nsig",1E6,1E1,1E9);
TFile *KDEfile = new TFile( "./KDE/KDEeff.root","READ" );
RooWorkspace* ws_eff = (RooWorkspace*)KDEfile->Get( Form("ws_eff_bin%i",iBin) );
RooRealVar* ctL = (RooRealVar*)ws_eff->var("ctL");
RooGenericPdf* KDEeff = (RooGenericPdf*)ws_eff->pdf( Form("KDEtotaleff_bin%i",iBin) );
RooArgSet f_ang_argset(*ctL);
f_ang_argset.add(RooArgSet(fh,afb));
TString f_ang_format;
f_ang_format = "( 0.75*(1-fh)*(1-ctL*ctL) + 0.5*fh + afb*ctL )";
RooGenericPdf* f_ang = new RooGenericPdf("f_ang","angular pdf", f_ang_format,f_ang_argset);
RooGenericPdf* f_sig = new RooGenericPdf("f_sig","signal pdf","@0*@1",RooArgList(*KDEeff,*f_ang));
RooExtendPdf f("f","", *f_sig, nsig);
RooDataSet *data = new RooDataSet("data","data",RooArgSet(*ctL,Q2));
double q2=0;
double cosTheta=0;
int n_ch=0;
ch->SetBranchAddress("Q2",&q2);
ch->SetBranchAddress("CosThetaL",&cosTheta);
n_ch=ch->GetEntries();
double q2Low[13] = {1.00, 2.00, 4.30, 8.68, 10.09, 12.86, 14.18, 16.00, 18.00, 1.00, 1.00, 10.09, 14.18};
double q2High[13] = {2.00, 4.30, 8.68, 10.09, 12.86, 14.18, 16.00, 18.00, 22.00, 6.00, 8.68, 12.86, 22};
for(int evt=0; evt<n_ch; evt++){
ch->GetEntry(evt);
if( (q2<q2Low[iBin])||(q2>q2High[iBin]) )continue;
ctL->setVal(cosTheta);
Q2.setVal(q2);
data->add(RooArgSet(*ctL,Q2));
}
double ne = data->sumEntries();
cout<<"number of processing entries: "<<ne<<endl;
RooFitResult *f_fitresult = f.fitTo(*data,Extended(kTRUE),Save(kTRUE),Minimizer("Minuit"),Warnings(-1), PrintEvalErrors(-1));
TCanvas* c = new TCanvas("c");
RooPlot* framecosl = ctL->frame();
data->plotOn(framecosl,Binning(100));
f.plotOn(framecosl);
framecosl->SetTitle("");
framecosl->SetMinimum(0);
framecosl->SetTitleOffset(1.1,"Y");
framecosl->SetMaximum(framecosl->GetMaximum() * 1.25);
framecosl->Draw();
c->Print("./plots/cosl.pdf");
the “KDEeff” above is a RooGenericPdf whose function form is “[0]*[1]/[2]/[3]”. the [0],[1],[2],[3] indicates four RooKeysPdfs.
Thank you