#ifndef __CINT__ #include "RooGlobalFunc.h" #endif #include #include #include #include #include #include #include //#include #include "RooFit.h"// #include "RooRealVar.h" #include "RooAbsPdf.h" #include "RooAddPdf.h" #include "RooDataSet.h" #include "RooDataHist.h" #include "RooGaussian.h" #include "RooGlobalFunc.h" #include "RooBifurGauss.h" #include "RooLandau.h" #include "RooChebychev.h" #include "RooFitResult.h" #include "RooNLLVar.h" #include "RooMinuit.h" #include "RooPlot.h" #include "RooArgList.h" #include "RooHist.h" //#include "RooDstarBG.h" // for the threshold function #include "TLine.h" #include "TFile.h" #include "TCanvas.h" #include "TTree.h" #include "TH1.h" #include "TH1F.h" #include "TRandom.h" #include "TString.h" #include "TApplication.h" #include "TROOT.h" #include "TPad.h" //#include "RooFitModels.h" #include "RooDstD0BG.h" // will be used for fitting deltam of combinatoric background using namespace RooFit ; using namespace std ; int combinatoric_mdz() { //--------------------BLock1-------------------------------// // declare the required variables for fitting // RooRealVar M_dz("M_dz","M_{D^{0}}(GeV/c^{2})",1.81,1.92); // for Mdz variable RooRealVar deltam("deltam","#Delta M(GeV/c^{2})",0.14,0.15); // fro deltam variable RooDataSet* ds1 = (RooDataSet*)RooDataSet::read("signal_new.txt",RooArgSet(M_dz, deltam),"Q"); ds1->Print("V"); RooPlot* frame = M_dz.frame(Title("M_{D^{0}}"));// making a frame linking to variable mdz ds1->plotOn(frame);// plotting all the data on the frame //----------------------BLOCK 4------------------------// ********( !!!! very important part) //--------here start constructing the models to be used for fitting -----------// //-------------------Chebychev polynomial----------------------// RooRealVar a1("a1","a1",1,0,10); RooRealVar a2("a2","a2",0.5,-1,1); RooChebychev dg_mdz1("dg_mdz1","dg_mdz1",M_dz,RooArgList(a1,a2)); unsigned long nentries = (long)ds1->numEntries(); RooRealVar nsig("nsig","nsig",nentries*1,0,nentries*1.2); RooAddPdf dg_mdz("dz_mdz","dg_mdz",RooArgList(dg_mdz1),RooArgList(nsig)); // this is done to float the yield dg_mdz.fitTo(*ds1,Extended(kTRUE),Minos(1));//,Extended(kTRUE));//,Extended(),Minos(1)); dg_mdz.plotOn(frame,Name("Total pdf"),LineColor(kBlue)); dg_mdz.paramOn(frame); double chi2_ndf = frame->chiSquare();// cout<<"chi square = "<SetFillColor(10); box->SetBorderSize(1); box->SetTextAlign(12); box->SetTextSize(0.04F); box->SetFillStyle(1001); box->SetFillColor(10); TText *text = 0; Char_t buf[30]; sprintf( buf, "#chi^{2}/ndf = %f", chi2_ndf ); text = box->AddText( buf ); frame->addObject(box) ; /////////////pull distribution//////////////// //*********** pull ******************************* RooPlot* z1frame = M_dz.frame(Title("Pull Distribution")); RooHist* hpull1 = frame->pullHist(); z1frame->addPlotable(hpull1,"P");// p is drawing option. TCanvas* c1 = new TCanvas("c1","c1",550,400) ; c1->Divide(1,2) ; // column, row double xmin = 1.81; double xmax = 1.92; TLine *line = new TLine(xmin,0.0,xmax,0.0); TLine *line1 = new TLine(xmin,3.0,xmax,3.0); TLine *line2 = new TLine(xmin,-3.0,xmax,-3.0); c1->cd(2)->SetPad(0.005,0.005,0.995,0.2525); line->SetLineColor(kRed); line->SetLineWidth(2); //gPad->SetLeftMargin(0.15); //z1frame->GetYaxis()->SetTitleOffset(1.45); z1frame->GetYaxis()->SetTitle("Pull(#sigma)"); z1frame->GetXaxis()->CenterTitle(); z1frame->Draw(); line1->SetLineColor(kRed); line1->SetLineWidth(3); line1->SetLineStyle(2); line2->SetLineColor(kRed); line2->SetLineWidth(3); line2->SetLineStyle(2); line->Draw("SAME"); //z1frame->GetYaxis()->SetRangeUser(-3.5, 3.5); line1->Draw("SAME"); line2->Draw("SAME"); c1->cd(1)->SetPad(0.005,0.2525,0.995,0.995); //gPad->SetLeftMargin(0.15); //frame->GetYaxis()->SetTitleOffset(1.45); frame->GetXaxis()->CenterTitle(); // Add the components pdf's after calculating the chi square and pull. dg_mdz.plotOn(frame);//,Name("Asymmetric Gauss1"),Components(gauss1),LineStyle(kDashed),LineColor(kRed)); frame->Draw(); TLegend *leg = new TLegend(0.5,0.5,0.6,0.6); leg->AddEntry("dg_mdz1","Chebychev polynomial","L"); leg->Draw(); c1->Draw(); cout<<"the total no. of events are "<