Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:33:22

0001 /*******************************************************************
0002  * Project: CMS detector at the CERN
0003  *
0004  * Package: Presently in the user code
0005  *
0006  *
0007  * Authors:
0008  *
0009  *   Kalanand Mishra, Fermilab - kalanand@fnal.gov
0010  *
0011  * Description:
0012  *   A standalone macro to perform single bin simultaneos fit of 
0013  *   dilepton mass under Z peak. 
0014  *   Works with  unbinned data. 
0015  *
0016  * Implementation details:
0017  *  Uses RooFit classes.
0018  *
0019  * History:
0020  *   
0021  *
0022  ********************************************************************/
0023 
0024 //// Following are the 3 irreducible free parameters of the fit:
0025 ////        Z cross section and single electron efficiency: eff_B, eff_E.
0026 ////  Additionally, the following 4 nuisance parameters are floating:
0027 ////        nBkgTF_BB,  nBkgTF_Endcap, bkgGamma_TF_BB, bkgGamma_TF_Endcap.
0028 ///  Later added more nuisance parameters: resolution in TT, TF_BB, TF_Endcap.
0029 
0030 // ROOT
0031 #include <TROOT.h>
0032 #include <TChain.h>
0033 #include <TFile.h>
0034 #include <TCanvas.h>
0035 #include <TH1F.h>
0036 #include <TH2F.h>
0037 #include <TTree.h>
0038 #include <TGraph.h>
0039 #include "tdrstyle.C"
0040 
0041 using namespace RooFit;
0042 
0043 void makeSignalPdf();
0044 void makeBkgPdf();
0045 
0046 // The signal & background Pdf 
0047 RooRealVar *rooMass_;
0048 RooAbsPdf* signalShapePdfTT_;
0049 RooAbsPdf* signalShapePdfTF_BB_;
0050 RooAbsPdf* signalShapePdfTF_End_;
0051 RooAbsPdf *bkgShapePdfTF_BB_;
0052 RooAbsPdf *bkgShapePdfTF_End_;
0053 
0054 
0055 
0056 TFile* Zeelineshape_file;
0057 TCanvas *c;
0058 
0059 // Acceptance for Gen-->SC 
0060 const float A_BB= 0.2257;
0061 const float A_BE= 0.1612;
0062 const float A_EE= 0.0476;
0063 
0064 // Specify the electron selection: "WP95" or "WP80"
0065 const char* selection = "WP80";
0066 
0067 
0068 // Integrated luminosity
0069 const double intLumi = 2.88;
0070 
0071 
0072 // In case we want to fix the nuisance parameters ...
0073 const bool FIX_NUIS_PARS=false;
0074 
0075 
0076 
0077 
0078 void ThreeCategorySimZFitter()
0079 {
0080   // The fit variable - lepton invariant mass
0081   rooMass_ = new RooRealVar("mass","m_{ee}",60.0, 120.0, "GeV/c^{2}");
0082   rooMass_->setBins(120.0);
0083   RooRealVar Mass = *rooMass_;
0084 
0085   // Make the category variable that defines the two fits,
0086   // namely whether the probe passes or fails the eff criteria.
0087   RooCategory sample("sample","") ;
0088   sample.defineType("BB_pass", 1) ;
0089   sample.defineType("BB_fail", 2) ; 
0090   sample.defineType("End_fail", 3) ; 
0091 
0092 
0093   gROOT->cd();
0094   char inFile[50];
0095   sprintf(inFile, "ZeeEvents_%s.root", selection);
0096   TFile fin(inFile, "read");
0097   TTree* treeTT = (TTree*) fin.Get("tree");
0098   sprintf(inFile, "ZeeEvents_%s_TF.root", selection);
0099   TFile fin2(inFile, "read");
0100   TTree* treeTF = (TTree*) fin2.Get("tree");
0101   TTree* treeTF_BB = treeTF->CopyTree("tag_gsfEle_isEB>0 && abs(probe_eta)<1.5");
0102   TTree* treeTF_End = treeTF->CopyTree("!(tag_gsfEle_isEB>0 && abs(probe_eta)<1.5)");
0103 
0104 
0105   ///////// convert Histograms into RooDataHists
0106   RooDataSet* data_TT = new RooDataSet("data_TT","data_TT", treeTT, Mass);
0107   RooDataSet* data_TF_BB = new RooDataSet("data_TF_BB","data_TF_BB",treeTF_BB, Mass);
0108   RooDataSet* data_TF_End = new RooDataSet("data_TF_End","data_TF_End", treeTF_End, Mass);
0109 
0110   RooDataSet* data = new RooDataSet( "data","data",
0111                        RooArgList(Mass),Index(sample),
0112                        Import("BB_pass",*data_TT),
0113                        Import("BB_fail",*data_TF_BB),
0114                        Import("End_fail",*data_TF_End) ); 
0115 
0116   data->get()->Print();
0117   cout << "Made dataset" << endl;
0118 
0119 
0120 
0121 
0122   // ********** Construct signal & bkg shape PDF ********** //
0123   makeSignalPdf();
0124   cout << "Made signal pdf" << endl;
0125   makeBkgPdf();
0126   cout << "Made bkg pdf" << endl;
0127 
0128   // Now supply integrated luminosity in inverse picobarn
0129   RooRealVar lumi("lumi","lumi", intLumi);
0130 
0131 
0132   // Now define Z production cross section variable (in pb) 
0133   RooRealVar xsec("xsec","xsec", 912.187, 200.0, 2000.0);
0134 
0135 
0136   // Define efficiency variables  
0137   RooRealVar eff_B("eff_B","eff_B", 0.93, 0.0, 1.0);
0138   RooRealVar eff_E("eff_E","eff_E", 0.91, 0.0, 1.0);
0139  
0140 
0141 
0142   // Now define acceptance variables --> we get these numbers from MC:0.434527   
0143   RooRealVar acc_BB("acc_BB","acc_BB", A_BB);
0144   RooRealVar acc_EB("acc_EB","acc_EB", A_BE);
0145   RooRealVar acc_EE("acc_EE","acc_EE", A_EE);
0146   RooRealVar acc("acc","acc", A_BB+A_BE+A_EE);
0147 
0148 
0149 
0150   // Define background yield variables: they are not related to each other  
0151   float numBkgHighPurity=11.8;
0152   if(!strcmp(selection,"WP80")) numBkgHighPurity=3.0; 
0153   RooRealVar nBkgTT("nBkgTT","nBkgTT", numBkgHighPurity);
0154   RooRealVar nBkgTF_BB("nBkgTF_BB","nBkgTF_BB", 58.0,     0.0, 500.);
0155   RooRealVar nBkgTF_End("nBkgTF_End","nBkgTF_End", 110.2, 0.0, 500.);
0156    if(FIX_NUIS_PARS) nBkgTF_BB.setConstant(true);
0157    if(FIX_NUIS_PARS) nBkgTF_End.setConstant(true);
0158 
0159   ////////////////////////////////////////////////////////////////////////////
0160   ////////////////////////////////////////////////////////////////////////////
0161  //  Define signal yield variables.  
0162   // They are linked together by the total cross section:  e.g. 
0163   //          Nbb = sigma*L*Abb*effB
0164 
0165   const char* formula = 0;
0166   RooArgList* args;
0167   formula="lumi*xsec*(acc_BB*eff_B*eff_B + acc_EB*eff_B*eff_E + acc_EE*eff_E*eff_E)+nBkgTT";
0168   args = new RooArgList(lumi,xsec,acc_BB,acc_EB,acc_EE,eff_B,eff_E,nBkgTT);
0169   RooFormulaVar nSigTT("nSigTT", formula, *args);
0170   delete args;
0171 
0172   formula="lumi*xsec*acc_BB*eff_B*(1.0-eff_B)";
0173   args = new RooArgList(lumi,xsec,acc_BB,eff_B);
0174   RooFormulaVar nSigTF_BB("nSigTF_BB",formula, *args);
0175   delete args;
0176 
0177   formula="lumi*xsec*(0.5*acc_EB*(eff_B*(1.0-eff_E)+eff_E*(1.0-eff_B)) + acc_EE*eff_E*(1.0-eff_E))";
0178   args = new RooArgList(lumi,xsec,acc_EB,eff_B,eff_E,acc_EE);
0179 
0180   RooFormulaVar nSigTF_End("nSigTF_EB",formula, *args);
0181   delete args;
0182 
0183   /////////////////////////////////////////////////////////////////////////
0184   /////////////////////////////////////////////////////////////////////////
0185 
0186    RooArgList componentsTF_BB(*signalShapePdfTF_BB_,*bkgShapePdfTF_BB_);
0187    RooArgList componentsTF_End(*signalShapePdfTF_End_,*bkgShapePdfTF_End_);
0188 
0189    RooArgList yieldsTF_BB(nSigTF_BB, nBkgTF_BB );     
0190    RooArgList yieldsTF_End(nSigTF_End, nBkgTF_End);   
0191 
0192    RooExtendPdf pdfTT("pdfTT","extended sum pdf", *signalShapePdfTT_, nSigTT);
0193    RooAddPdf pdfTF_BB("pdfTF_BB","extended sum pdf",componentsTF_BB, yieldsTF_BB);
0194    RooAddPdf pdfTF_End("pdfTF_End","extended sum pdf",componentsTF_End, yieldsTF_End);
0195 
0196 
0197    // The total simultaneous fit ...
0198    RooSimultaneous totalPdf("totalPdf","totalPdf", sample);
0199    totalPdf.addPdf(pdfTT,"BB_pass");
0200    totalPdf.Print();
0201    totalPdf.addPdf(pdfTF_BB,"BB_fail");
0202    totalPdf.addPdf(pdfTF_End,"End_fail");
0203    totalPdf.Print();
0204 
0205 
0206   // ********* Do the Actual Fit ********** //  
0207    RooFitResult *fitResult = totalPdf.fitTo(*data, Save(true), 
0208    RooFit::Extended(true), 
0209    RooFit::Minos(true), 
0210    PrintEvalErrors(-1),
0211    Warnings(false) 
0212       );
0213   fitResult->Print("v");
0214   // Mass.setRange("fullRange", 60., 120.);
0215 
0216   // ********** Make and save Canvas for the plots ********** //
0217   gROOT->ProcessLine(".L ~/tdrstyle.C");
0218   setTDRStyle();
0219   tdrStyle->SetErrorX(0.5);
0220   tdrStyle->SetPadLeftMargin(0.19);
0221   tdrStyle->SetPadRightMargin(0.10);
0222   tdrStyle->SetPadBottomMargin(0.15);
0223   tdrStyle->SetLegendBorderSize(0);
0224   tdrStyle->SetTitleYOffset(1.5);
0225   RooAbsData::ErrorType errorType = RooAbsData::SumW2;
0226 
0227 
0228   TString cname = Form("Zmass_TT_%dnb", (int)(1000*intLumi) );
0229   c = new TCanvas(cname,cname,500,500);
0230   RooPlot* frame1 = Mass.frame(60., 120., 60);
0231   data_TT->plotOn(frame1,RooFit::DataError(errorType));
0232   pdfTT.plotOn(frame1,ProjWData(*data_TT));
0233   frame1->SetMinimum(0);
0234   frame1->Draw("e0");
0235   TPaveText *plotlabel = new TPaveText(0.23,0.87,0.43,0.92,"NDC");
0236    plotlabel->SetTextColor(kBlack);
0237    plotlabel->SetFillColor(kWhite);
0238    plotlabel->SetBorderSize(0);
0239    plotlabel->SetTextAlign(12);
0240    plotlabel->SetTextSize(0.03);
0241    plotlabel->AddText("CMS Preliminary 2010");
0242   TPaveText *plotlabel2 = new TPaveText(0.23,0.82,0.43,0.87,"NDC");
0243    plotlabel2->SetTextColor(kBlack);
0244    plotlabel2->SetFillColor(kWhite);
0245    plotlabel2->SetBorderSize(0);
0246    plotlabel2->SetTextAlign(12);
0247    plotlabel2->SetTextSize(0.03);
0248    plotlabel2->AddText("#sqrt{s} = 7 TeV");
0249   TPaveText *plotlabel3 = new TPaveText(0.23,0.75,0.43,0.80,"NDC");
0250    plotlabel3->SetTextColor(kBlack);
0251    plotlabel3->SetFillColor(kWhite);
0252    plotlabel3->SetBorderSize(0);
0253    plotlabel3->SetTextAlign(12);
0254    plotlabel3->SetTextSize(0.03);
0255   char temp[100];
0256   sprintf(temp, "%.1f", intLumi);
0257   plotlabel3->AddText((string("#int#font[12]{L}dt = ") + 
0258   temp + string(" pb^{ -1}")).c_str());
0259   TPaveText *plotlabel4 = new TPaveText(0.6,0.87,0.8,0.92,"NDC");
0260    plotlabel4->SetTextColor(kBlack);
0261    plotlabel4->SetFillColor(kWhite);
0262    plotlabel4->SetBorderSize(0);
0263    plotlabel4->SetTextAlign(12);
0264    plotlabel4->SetTextSize(0.03);
0265    double nsig = nSigTT.getVal();
0266    double nsigerr = nSigTT.getPropagatedError(*fitResult) ;
0267    sprintf(temp, "Signal = %.1f #pm %.1f", nsig, nsigerr);
0268    plotlabel4->AddText(temp);
0269    TPaveText *plotlabel5 = new TPaveText(0.6,0.82,0.8,0.87,"NDC");
0270    plotlabel5->SetTextColor(kBlack);
0271    plotlabel5->SetFillColor(kWhite);
0272    plotlabel5->SetBorderSize(0);
0273    plotlabel5->SetTextAlign(12);
0274    plotlabel5->SetTextSize(0.03);
0275    sprintf(temp, "#epsilon_{EB} = %.3f #pm %.3f", eff_B.getVal(), eff_B.getError() );
0276    plotlabel5->AddText(temp);
0277   TPaveText *plotlabel6 = new TPaveText(0.6,0.77,0.8,0.82,"NDC");
0278    plotlabel6->SetTextColor(kBlack);
0279    plotlabel6->SetFillColor(kWhite);
0280    plotlabel6->SetBorderSize(0);
0281    plotlabel6->SetTextAlign(12);
0282    plotlabel6->SetTextSize(0.03);
0283    sprintf(temp, "#epsilon_{EE} = %.3f #pm %.3f", eff_E.getVal(), eff_E.getError() );
0284    plotlabel6->AddText(temp);
0285   TPaveText *plotlabel7 = new TPaveText(0.6,0.72,0.8,0.77,"NDC");
0286    plotlabel7->SetTextColor(kBlack);
0287    plotlabel7->SetFillColor(kWhite);
0288    plotlabel7->SetBorderSize(0);
0289    plotlabel7->SetTextAlign(12);
0290    plotlabel7->SetTextSize(0.03);
0291    sprintf(temp, "#sigma = %.1f #pm %.1f pb", xsec.getVal(), xsec.getError());
0292    plotlabel7->AddText(temp);
0293   plotlabel->Draw();
0294   plotlabel2->Draw();
0295   plotlabel3->Draw();
0296   plotlabel4->Draw();
0297   plotlabel5->Draw();
0298   plotlabel6->Draw();
0299   plotlabel7->Draw();
0300 //   c->SaveAs( cname + TString(".eps"));
0301 //   c->SaveAs( cname + TString(".gif"));
0302 //   c->SaveAs( cname + TString(".root"));
0303 //   c->SaveAs( cname + TString(".png"));
0304 //   c->SaveAs( cname + TString(".C"));
0305 
0306 
0307   cname = Form("Zmass_TF_BB%dnb", (int)(1000*intLumi) );
0308   c = new TCanvas(cname,cname,500,500);
0309   RooPlot* frame2 = Mass.frame(60., 120., 12);
0310   data_TF_BB->plotOn(frame2,RooFit::DataError(errorType));
0311   pdfTF_BB.plotOn(frame2,ProjWData(*data_TF_BB),
0312   Components(*signalShapePdfTF_BB_),DrawOption("LF"),FillStyle(1001),FillColor(kOrange),VLines());
0313   pdfTF_BB.plotOn(frame2,ProjWData(*data_TF_BB));
0314   pdfTF_BB.plotOn(frame2,ProjWData(*data_TF_BB),
0315   Components(*bkgShapePdfTF_BB_),LineColor(kRed));
0316   data_TF_BB->plotOn(frame2,RooFit::DataError(errorType));
0317   frame2->SetMinimum(0);
0318   frame2->Draw("e0");
0319   frame2->GetYaxis()->SetNdivisions(505);
0320   plotlabel = new TPaveText(0.23,0.87,0.43,0.92,"NDC");
0321    plotlabel->SetTextColor(kBlack);
0322    plotlabel->SetFillColor(kWhite);
0323    plotlabel->SetBorderSize(0);
0324    plotlabel->SetTextAlign(12);
0325    plotlabel->SetTextSize(0.03);
0326    plotlabel->AddText("CMS Preliminary 2010");
0327   plotlabel2 = new TPaveText(0.23,0.82,0.43,0.87,"NDC");
0328    plotlabel2->SetTextColor(kBlack);
0329    plotlabel2->SetFillColor(kWhite);
0330    plotlabel2->SetBorderSize(0);
0331    plotlabel2->SetTextAlign(12);
0332    plotlabel2->SetTextSize(0.03);
0333    plotlabel2->AddText("#sqrt{s} = 7 TeV");
0334   plotlabel3 = new TPaveText(0.23,0.75,0.43,0.80,"NDC");
0335    plotlabel3->SetTextColor(kBlack);
0336    plotlabel3->SetFillColor(kWhite);
0337    plotlabel3->SetBorderSize(0);
0338    plotlabel3->SetTextAlign(12);
0339    plotlabel3->SetTextSize(0.03);
0340   char temp2[100];
0341   sprintf(temp2, "%.1f", intLumi);
0342   plotlabel3->AddText((string("#int#font[12]{L}dt = ") + 
0343   temp2 + string(" pb^{ -1}")).c_str());
0344   plotlabel4 = new TPaveText(0.6,0.87,0.8,0.92,"NDC");
0345    plotlabel4->SetTextColor(kBlack);
0346    plotlabel4->SetFillColor(kWhite);
0347    plotlabel4->SetBorderSize(0);
0348    plotlabel4->SetTextAlign(12);
0349    plotlabel4->SetTextSize(0.03);
0350    nsig = nSigTF_BB.getVal();
0351    nsigerr = nSigTF_BB.getPropagatedError(*fitResult) ;
0352    sprintf(temp2, "Signal = %.2f #pm %.2f", nsig, nsigerr);
0353    plotlabel4->AddText(temp2);
0354   plotlabel5 = new TPaveText(0.6,0.82,0.8,0.87,"NDC");
0355    plotlabel5->SetTextColor(kBlack);
0356    plotlabel5->SetFillColor(kWhite);
0357    plotlabel5->SetBorderSize(0);
0358    plotlabel5->SetTextAlign(12);
0359    plotlabel5->SetTextSize(0.03);
0360    sprintf(temp2, "Bkg = %.2f #pm %.2f", nBkgTF_BB.getVal(), nBkgTF_BB.getError());
0361    plotlabel5->AddText(temp2);
0362   plotlabel6 = new TPaveText(0.6,0.77,0.8,0.82,"NDC");
0363    plotlabel6->SetTextColor(kBlack);
0364    plotlabel6->SetFillColor(kWhite);
0365    plotlabel6->SetBorderSize(0);
0366    plotlabel6->SetTextAlign(12);
0367    plotlabel6->SetTextSize(0.03);
0368    sprintf(temp2, "#epsilon_{EB} = %.3f #pm %.3f", eff_B.getVal(), eff_B.getError() );
0369    plotlabel6->AddText(temp2);
0370    plotlabel7 = new TPaveText(0.6,0.72,0.8,0.77,"NDC");
0371    plotlabel7->SetTextColor(kBlack);
0372    plotlabel7->SetFillColor(kWhite);
0373    plotlabel7->SetBorderSize(0);
0374    plotlabel7->SetTextAlign(12);
0375    plotlabel7->SetTextSize(0.03);
0376    sprintf(temp2, "#epsilon_{EE} = %.3f #pm %.3f", eff_E.getVal(), eff_E.getError() );
0377    plotlabel7->AddText(temp2);
0378 
0379   plotlabel->Draw();
0380   plotlabel2->Draw();
0381   plotlabel3->Draw();
0382   plotlabel4->Draw();
0383   plotlabel5->Draw();
0384   plotlabel6->Draw();
0385   plotlabel7->Draw();
0386 
0387 //   c->SaveAs( cname + TString(".eps"));
0388 //   c->SaveAs( cname + TString(".gif"));
0389 //   c->SaveAs( cname + TString(".root"));
0390 //   c->SaveAs( cname + TString(".png"));
0391 //   c->SaveAs( cname + TString(".C"));
0392 
0393 
0394 // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
0395 
0396   cname = Form("Zmass_TF_EndCaps%dnb", (int)(1000*intLumi) );
0397   c = new TCanvas(cname,cname,500,500);
0398   RooPlot* frame3 = Mass.frame(60., 120., 12);
0399   data_TF_End->plotOn(frame3,RooFit::DataError(errorType));
0400   pdfTF_End.plotOn(frame3,ProjWData(*data_TF_End),
0401   Components(*signalShapePdfTF_End_),DrawOption("LF"),FillStyle(1001),FillColor(kOrange),VLines());
0402   pdfTF_End.plotOn(frame3,ProjWData(*data_TF_End),
0403   Components(*bkgShapePdfTF_End_),LineColor(kRed));
0404   pdfTF_End.plotOn(frame3,ProjWData(*data_TF_End));
0405   data_TF_End->plotOn(frame3,RooFit::DataError(errorType));
0406   frame3->SetMinimum(0);
0407   frame3->Draw("e0");
0408   frame3->GetYaxis()->SetNdivisions(505);
0409   plotlabel = new TPaveText(0.23,0.87,0.43,0.92,"NDC");
0410    plotlabel->SetTextColor(kBlack);
0411    plotlabel->SetFillColor(kWhite);
0412    plotlabel->SetBorderSize(0);
0413    plotlabel->SetTextAlign(12);
0414    plotlabel->SetTextSize(0.03);
0415    plotlabel->AddText("CMS Preliminary 2010");
0416   plotlabel2 = new TPaveText(0.23,0.82,0.43,0.87,"NDC");
0417    plotlabel2->SetTextColor(kBlack);
0418    plotlabel2->SetFillColor(kWhite);
0419    plotlabel2->SetBorderSize(0);
0420    plotlabel2->SetTextAlign(12);
0421    plotlabel2->SetTextSize(0.03);
0422    plotlabel2->AddText("#sqrt{s} = 7 TeV");
0423   plotlabel3 = new TPaveText(0.23,0.75,0.43,0.80,"NDC");
0424    plotlabel3->SetTextColor(kBlack);
0425    plotlabel3->SetFillColor(kWhite);
0426    plotlabel3->SetBorderSize(0);
0427    plotlabel3->SetTextAlign(12);
0428    plotlabel3->SetTextSize(0.03);
0429   char temp3[100];
0430   sprintf(temp3, "%.1f", intLumi);
0431   plotlabel3->AddText((string("#int#font[12]{L}dt = ") + 
0432   temp3 + string(" pb^{ -1}")).c_str());
0433   plotlabel4 = new TPaveText(0.6,0.87,0.8,0.92,"NDC");
0434    plotlabel4->SetTextColor(kBlack);
0435    plotlabel4->SetFillColor(kWhite);
0436    plotlabel4->SetBorderSize(0);
0437    plotlabel4->SetTextAlign(12);
0438    plotlabel4->SetTextSize(0.03);
0439    nsig = nSigTF_End.getVal();
0440    nsigerr = nSigTF_End.getPropagatedError(*fitResult) ;
0441    sprintf(temp3, "Signal = %.2f #pm %.2f", nsig, nsigerr);
0442    plotlabel4->AddText(temp3);
0443   plotlabel5 = new TPaveText(0.6,0.82,0.8,0.87,"NDC");
0444    plotlabel5->SetTextColor(kBlack);
0445    plotlabel5->SetFillColor(kWhite);
0446    plotlabel5->SetBorderSize(0);
0447    plotlabel5->SetTextAlign(12);
0448    plotlabel5->SetTextSize(0.03);
0449    sprintf(temp3, "Bkg = %.2f #pm %.2f", nBkgTF_End.getVal(), nBkgTF_End.getError());
0450    plotlabel5->AddText(temp3);
0451   plotlabel6 = new TPaveText(0.6,0.77,0.8,0.82,"NDC");
0452    plotlabel6->SetTextColor(kBlack);
0453    plotlabel6->SetFillColor(kWhite);
0454    plotlabel6->SetBorderSize(0);
0455    plotlabel6->SetTextAlign(12);
0456    plotlabel6->SetTextSize(0.03);
0457    sprintf(temp3, "#epsilon_{EB} = %.3f #pm %.3f", eff_B.getVal(), eff_B.getError() );
0458    plotlabel6->AddText(temp3);
0459   plotlabel7 = new TPaveText(0.6,0.72,0.8,0.77,"NDC");
0460    plotlabel7->SetTextColor(kBlack);
0461    plotlabel7->SetFillColor(kWhite);
0462    plotlabel7->SetBorderSize(0);
0463    plotlabel7->SetTextAlign(12);
0464    plotlabel7->SetTextSize(0.03);
0465    sprintf(temp3, "#epsilon_{EE} = %.3f #pm %.3f", eff_E.getVal(), eff_E.getError() );
0466    plotlabel7->AddText(temp3);
0467 
0468   plotlabel->Draw();
0469   plotlabel2->Draw();
0470   plotlabel3->Draw();
0471   plotlabel4->Draw();
0472   plotlabel5->Draw();
0473   plotlabel6->Draw();
0474   plotlabel7->Draw();
0475 
0476 //   c->SaveAs( cname + TString(".eps"));
0477 //   c->SaveAs( cname + TString(".gif"));
0478 //   c->SaveAs( cname + TString(".root"));
0479 //   c->SaveAs( cname + TString(".png"));
0480 //   c->SaveAs( cname + TString(".C"));
0481 
0482 
0483 
0484 
0485   //    if(data) delete data;
0486   //    if(c) delete c;
0487 }
0488 
0489 
0490 
0491 
0492 
0493 // // ***** Function to return the signal Pdf *** //
0494  void makeSignalPdf() {
0495 
0496  // Tag+Tag selection pdf
0497   Zeelineshape_file =  new TFile("../Zlineshapes.root", "READ");
0498 
0499   // Tag+Tag selection pdf
0500   TH1* histbbpass = (TH1D*) Zeelineshape_file->Get("pass_BB");
0501   TH1* histebpass = (TH1D*) Zeelineshape_file->Get("pass_BE");
0502   TH1* histeepass = (TH1D*) Zeelineshape_file->Get("pass_EE");
0503 
0504   TH1D* th1_TT = (TH1D*) histbbpass->Clone("th1_TT");
0505   th1_TT->Add(histebpass);
0506   th1_TT->Add(histeepass);
0507 
0508   RooRealVar* zero  = new RooRealVar("zero","", 0.0);
0509   RooDataHist* rdh_TT = new RooDataHist("rdh_TT","", *rooMass_, th1_TT);
0510   RooAbsPdf* signalModelTT_ = new RooHistPdf("signalModelTT", "", *rooMass_, *rdh_TT);
0511   RooRealVar* resoTT_  = new RooRealVar("resoTT","resoTT",1.88, 0.0, 5.);
0512   if(FIX_NUIS_PARS) resoTT_->setConstant(true);
0513   RooGaussModel* resModelTT_ = new RooGaussModel("resModelTT","gaussian resolution model", 
0514                 *rooMass_, *zero, *resoTT_);
0515   signalShapePdfTT_  = new RooFFTConvPdf("sigModel","final signal shape", 
0516                        *rooMass_, *signalModelTT_, *resModelTT_);
0517 
0518 
0519  // Tag+Fail selection pdf
0520   TH1* histbb = (TH1D*) Zeelineshape_file->Get("fail_BB");
0521   TH1* histeb = (TH1D*) Zeelineshape_file->Get("fail_BE");
0522   TH1* histee = (TH1D*) Zeelineshape_file->Get("fail_EE");
0523 
0524   TH1D* th1_TF = (TH1D*) histeb->Clone("th1_TF");
0525   th1_TF->Add(histee);
0526 
0527   RooDataHist* rdh_TF_BB_ = new RooDataHist("rdh_TF_BB","", *rooMass_, histbb);
0528   RooAbsPdf* signalModelTF_BB_ = new RooHistPdf("signalModelTF_BB", 
0529   "",*rooMass_,*rdh_TF_BB_);
0530   RooRealVar* resoTF_BB_  = new RooRealVar("resoTF_BB","resoTF_BB", 2.76762, 0.0, 10.);
0531   if(FIX_NUIS_PARS) resoTF_BB_->setConstant(true);
0532 
0533   RooGaussModel* resModelTF_BB_ = new RooGaussModel("resModelTF_BB",
0534   "gaussian resolution model", *rooMass_, *zero, *resoTF_BB_);
0535   signalShapePdfTF_BB_  = new RooFFTConvPdf("signalShapePdfTF_BB","final signal shape", 
0536                        *rooMass_, *signalModelTF_BB_, *resModelTF_BB_);
0537 
0538 //////////////////////////
0539   RooDataHist* rdh_TF_End_ = new RooDataHist("rdh_TF_End","", *rooMass_, th1_TF);
0540   RooAbsPdf* signalModelTF_End_ = new RooHistPdf("signalModelTF_End", "",
0541   *rooMass_, *rdh_TF_End_);
0542   RooRealVar* resoTF_End_  = new RooRealVar("resoTF_End","resoTF_End", 2.76563, 0.0, 10.);
0543   if(FIX_NUIS_PARS) resoTF_End_->setConstant(true);
0544   RooGaussModel* resModelTF_End_ = new RooGaussModel("resModelTF_End",
0545   "gaussian resolution model", *rooMass_, *zero, *resoTF_End_);
0546   signalShapePdfTF_End_  = new RooFFTConvPdf("signalShapePdfTF_End","final signal shape", 
0547                        *rooMass_, *signalModelTF_End_, *resModelTF_End_);
0548 }
0549 
0550 
0551 
0552 
0553 // ***** Function to return the background Pdf **** //
0554 void makeBkgPdf()
0555 {  
0556   // Background PDF variables
0557    RooRealVar* bkgGammaFailTF_BB_ = new RooRealVar("bkgGammaFailTF_BB",
0558    "",-0.028394, -10., 10.);
0559    if(FIX_NUIS_PARS) bkgGammaFailTF_BB_->setConstant(true);
0560    bkgShapePdfTF_BB_ = new RooExponential("bkgShapePdfTF_BB",
0561    "",*rooMass_, *bkgGammaFailTF_BB_);
0562    RooRealVar* bkgGammaFailTF_End_ = new RooRealVar("bkgGammaFailTF_End",
0563    "",-0.017778, -10., 10.);
0564    if(FIX_NUIS_PARS) bkgGammaFailTF_End_->setConstant(true);
0565    bkgShapePdfTF_End_ = new RooExponential("bkgShapePdfTF_End",
0566    "",*rooMass_, *bkgGammaFailTF_End_);
0567 }
0568 
0569 
0570 
0571 
0572