Example #1
0
void analyzer_stack() {

//int main(){

    const int nfiles  = 8;
    const int nhistos = 46;
    const int ndiscr = 5;
    TString leg_names[nfiles] = {/*"powheg, m(H) = 130 GeV","amc@NLO, m(H) = 125 GeV",*/"powheg, m(H) = 125 GeV" ,"QCD, H_{T}=100-200 GeV","QCD, H_{T}=200-300 GeV","QCD, H_{T}=300-500 GeV","QCD, H_{T}=500-700 GeV","QCD, H_{T}=700-1000 GeV","QCD, H_{T}=1500-2000 GeV","QCD, H_{T}=2000-Inf GeV"};
    TString file_names[nfiles] = {/*"Spring15_powheg_M130","Spring15_amcatnlo_M125",*/"Spring15_powheg_M125","Spring15_QCD_HT100to200","Spring15_QCD_HT200to300","Spring15_QCD_HT300to500","Spring15_QCD_HT500to700","Spring15_QCD_HT700to1000","Spring15_QCD_HT1500to2000","Spring15_QCD_HT2000toInf"};
    for (int i=0; i<nfiles; i++) {
//	file_names[i].Prepend("SingleBtag_");
        file_names[i].Prepend("../data40pb/tree");
        file_names[i].Append(".root");
    }
    TString trigger = "DoubleBtag_";
//TString trigger = "SingleBtag_";
//TString dir_name= "plots_powheg_130/";
    TString dir_name= "plots_powheg_125/";
//TString dir_name = "plots_amc/";


    Double_t xsec[nfiles] = {  /* 1.96, 2.16,*/2.16, 2.75E07,  6.52E03,  3.67E05, 2.94E04, 2.54E01,  1.74E06, 121.5 };


    TLegend *leg = new TLegend(0.35,0.58,0.75,0.88);
    leg->SetBorderSize(0);
    leg->SetTextSize(0.04);

    TString hist_names[nhistos]= {"hJet1_pt","hJet2_pt","hJet3_pt","hJet4_pt","hJet1_eta","hJet2_eta","hJet3_eta","hJet4_eta","hJet1_phi","hJet2_phi","hJet3_phi","hJet4_phi","hMqq", "hEtaQQ", "hPhiBB", "hEtaSoftJets", "hPtSoftJets","hMassSoftJets","hHTsoft","hSoft_n2","hSoft_n5","hSoft_n10","hMbb","hqgl","hbtag","hqgl2","hbtag2","hPtSoftJets2","hPtSoftJets3","hcosOqqbb","hEtaQB1", "hEtaQB2", "hPhiQB1", "hPhiQB2","hx1","hx2","hVB1_mass","hVB2_mass","hEtot","hPxtot","hPytot","hPztot","hJet5_pt","hPtqqbb","hEtaqqbb","hPhiqqbb"};
    std::string hist_names_sort[nhistos];
    for (int i=0; i<nhistos; i++) {
        hist_names_sort[i] = hist_names[i];
    }
    Float_t discriminators[nhistos];
    TString stacks_names[nhistos];
    for (int i=0; i<nhistos; i++) {
        stacks_names[i] = hist_names[i];
        stacks_names[i].Prepend("s");
    }
    TString output_names[nhistos];
    for (int i=0; i<nhistos; i++) {
        output_names[i] = hist_names[i];
        output_names[i].Prepend(dir_name);
        output_names[i].Prepend(trigger);
        output_names[i].Append(".png");
    }
    const char *xaxis_names[100] = {"1^{st} Jet p_{T} (GeV)","2^{nd} Jet p_{T} (GeV)","3^{rd} Jet p_{T} (GeV)","4^{th} Jet p_{T} (GeV)","1^{st} Jet #eta", "2^{nd} Jet #eta", "3^{rd} Jet #eta", "4^{th} Jet #eta", "1^{st} Jet #phi", "2^{nd} Jet #phi", "3^{rd} Jet #phi", "4^{th} Jet #phi","m_{qq} (GeV)","|#Delta#eta_{qq}|","|#Delta#phi_{bb}|","#eta^{soft}","1^{st} Soft jet p_{T} (GeV)","m^{soft} (GeV)","H_{T}^{soft} (GeV)","N^{soft}","m_{bb} (GeV)", "QGL of the first quark jet candidate","CSV of 1^{st} b-jet","QGL of the second quark jet candidate","CSV of 2^{nd} b-jet","2^{nd} Soft jet p_{T} (GeV)","3^{rd} Soft jet p_{T} (GeV)","H_{T}^{soft 3 jets} (GeV)","cos#theta_{qqbb}","#Delta#eta_{qb}^{forward}","#Delta#eta_{qb}^{backward}","|#Delta#phi_{qb}^{forward}|","|#Delta#phi_{qb}^{backward}|","x_{1}","x_{2}","M_{W'_{1}} (GeV)","M_{W'_{2}} (GeV)","E^{tot} (GeV)","p_{x}^{tot} (GeV)","p_{y}^{tot} (GeV)","p_{z}^{tot} (GeV)", "5^{th} Jet p_{T} (GeV)"};

    TH1F *signal_histos[100];
    TH1F *discr_histos[100];//Mqq,delta eta, delta phi, qgl, btag //12,13,14,21,22
    int discr_index[100] = {12,13,14,21,22};//not used now
    int files=0;
    THStack *stacks[100];
    for (int i=0; i<nhistos; ++i) {
        stacks[i] = new THStack(stacks_names[i],"");
    }
    Double_t totalBG=0.;
    ofstream out_efficiency;
    ofstream out_discrimination;
    out_efficiency.open(trigger+dir_name+"efficiency.txt");
    do {

        TFile *file_initial = new TFile(file_names[files]);
        file_initial->ls();

        TString temp_number;
        temp_number.Form("%d",files);
        TH1F *histos[100];
        for (int hist=0; hist<nhistos; ++hist) {
            histos[hist] = (TH1F*)file_initial->Get(hist_names[hist]);
            histos[hist]->Sumw2(kFALSE);
//		histos[hist]->Scale(40.);
            if (files==0) signal_histos[hist] = (TH1F*)file_initial->Get(hist_names[hist]);
//		signal_histos[hist]->Scale(40.);
            //	histos[hist]->SetLineColor(1+files);
            //	histos[hist]->SetFillColor(1+files);
            if (files==1) {
                histos[hist]->SetFillColor(kBlue-10);
                histos[hist]->SetLineColor(kBlue-10);
            }
            if (files==2) {
                histos[hist]->SetFillColor(kBlue);
                histos[hist]->SetLineColor(kBlue);
            }
            if (files==3) {
                histos[hist]->SetFillColor(kOrange);
                histos[hist]->SetLineColor(kOrange);
            }
            if (files==4) {
                histos[hist]->SetFillColor(kRed);
                histos[hist]->SetLineColor(kRed);
            }
            if (files==5) {
                histos[hist]->SetFillColor(kAzure+10);
                histos[hist]->SetLineColor(kAzure+10);
            }
            if (files==6) {
                histos[hist]->SetFillColor(kGreen+2);
                histos[hist]->SetLineColor(kGreen+2);
            }
            if (files==7) {
                histos[hist]->SetFillColor(kPink+9);
                histos[hist]->SetLineColor(kPink+9);
            }
            if (files==0) {
                histos[hist]->SetFillStyle(3324);
                histos[hist]->SetFillColor(1);
                histos[hist]->SetLineColor(1);
                signal_histos[hist]->SetFillStyle(3324);
                signal_histos[hist]->SetLineColor(1);
                signal_histos[hist]->SetFillColor(1);
            }
            if (files>=0)stacks[hist]->Add(histos[hist]);
            if (hist==0) leg->AddEntry(histos[hist],leg_names[files],"F");
            if (files==1) {
                discr_histos[hist] = (TH1F*)file_initial->Get(hist_names[hist]);
            }
            if ((files>1)) {
                discr_histos[hist]->Add(histos[hist]);
            }
        }
        if (files!=0) totalBG+=histos[4]->Integral();
        if (files==0) out_efficiency<<"Sample & \t\t\t yield(per $fb^{-1}$)& \t efficiency"<<endl;
        if (files==0) out_efficiency<<leg_names[files]<<"&\t \t \t"<<histos[5]->Integral()*1000. <<"&\t"<< histos[5]->Integral()/xsec[files] <<endl;
        else out_efficiency<<leg_names[files]<<"&\t  "<<histos[4]->Integral()*1000. <<"&\t"<< histos[4]->Integral()/xsec[files] <<endl;
        if (files==nfiles-1) out_efficiency<<"Total BG"<<"&\t \t \t  "<<totalBG*1000.<< endl;
        files++;
    } while (files<nfiles);
    out_efficiency.close();

    for (int d=0; d<nhistos; d++) {
        discriminators[d] = Discr(discr_histos[d],signal_histos[d]);
    }

    bubblesort(discriminators, hist_names_sort,nhistos);

    out_discrimination.open(trigger+dir_name+"discrimination.txt");
    for (int d=0; d<nhistos; d++) {
        if (d==0) out_discrimination<<"Variable &\t d"<<endl;
        out_discrimination<<"$"<<hist_names_sort[d]<<"$"<<" & \t "<< std::setprecision(2)<< discriminators[d]<<endl;
    }
    out_discrimination.close();
    TLatex* tex = new TLatex(0.90,0.92,"13 TeV, PU = 20, bx = 25 ns, 1 pb^{-1}");
    tex->SetNDC();
    tex->SetTextAlign(35);
    tex->SetTextFont(42);
    tex->SetTextSize(0.04);
    tex->SetLineWidth(2);
    TLatex *tex1 = new TLatex(0.13,0.83,"CMS");
    tex1->SetNDC();
    tex1->SetTextAlign(20);
    tex1->SetTextFont(61);
    tex1->SetTextSize(0.06);
    tex1->SetLineWidth(2);
    TLatex* tex2 = new TLatex(0.22,0.77,"Work in progress");
    tex2->SetNDC();
    tex2->SetTextAlign(20);
    tex2->SetTextFont(52);
    tex2->SetTextSize(0.04);
    tex2->SetLineWidth(2);
    TLatex* tex_file = new TLatex(0.35,0.92,"Spring15, DoubleBtag");
    //	TLatex* tex_file = new TLatex(0.35,0.92,"Spring15, SingleBtag");
    tex_file->SetNDC();
    tex_file->SetTextAlign(35);
    tex_file->SetTextFont(42);
    tex_file->SetTextSize(0.04);
    tex_file->SetLineWidth(2);
    for (int i=0; i<nhistos; i++) {
        TString temp_str;
        temp_str.Form("%2.2f",Discr(discr_histos[i],signal_histos[i]));
        TString disc_value = temp_str.Prepend(", d = ");
        TLatex *disc_value_text = new TLatex(0.86,0.853,disc_value);
        disc_value_text->SetNDC();
        disc_value_text->SetTextAlign(35);
        disc_value_text->SetTextFont(42);
        disc_value_text->SetTextSize(0.04);
        disc_value_text->SetLineWidth(2);

        TCanvas *c1 = new TCanvas();
        c1->SetBottomMargin(.12);
        c1->cd();
        c1->SetLogy();
        Double_t xmin = signal_histos[i]->GetBinCenter(0);
        Double_t xmax = signal_histos[i]->GetBinCenter(signal_histos[i]->GetNbinsX());
        TH1F *frame = new TH1F("frame","",1,xmin,xmax);
        frame->SetMinimum(1e-4);
        frame->SetMaximum(1e10);
        frame->GetYaxis()->SetTitleOffset(0.9);
        frame->GetXaxis()->SetTitleOffset(0.91);
        frame->SetStats(0);
        frame->SetTitleFont(42,"x");
        frame->SetTitleFont(42,"y");
        frame->SetTitleSize(0.05, "XYZ");
        frame->SetXTitle(signal_histos[i]->GetXaxis()->GetTitle());

        if ((i<4))frame->SetYTitle("Events  /  20 GeV");
        else if (i==37)frame->SetYTitle("Events  /  20 GeV");
        else if (i==41)frame->SetYTitle("Events  /  20 GeV");
        else if ((i>=4) && (i<8)) frame->SetYTitle("Events  /  0.5");
        else if (i==15) frame->SetYTitle("Events  /  0.5");
        else if ((i>=8) && (i<12)) frame->SetYTitle("Events  /  0.2");
        else if (i==40) frame->SetYTitle("Events / 100 GeV");
        else if ((i==10)||(i==12)||(i==16)||(i==17)||(i==18) || (i==20) || (i==25) || (i==26) || (i==27) || (i==35) || (i==36) ||(i==38) || (i==39)) frame->SetYTitle("Events / 10 GeV");
        else if ((i==13)||(i==14)) frame->SetYTitle("Events / 0.1");
        else if ((i==21)||(i==22)) frame->SetYTitle("Events / 0.05");
        else if ((i==23)||(i==24)) frame->SetYTitle("Events / 0.01");
        else if (i==28) frame->SetYTitle("Events / 0.02");
        else if ((i==29) || (i==30) || (i==31) || (i==32) )frame->SetYTitle("Events / 0.1");
        else if ((i==33) || (i==33))frame->SetYTitle("Events / 0.01");
        else frame->SetYTitle("Events");
        frame->Draw();
        tex->Draw();
        tex1->Draw();
        tex2->Draw();
        tex_file->Draw();
        stacks[i]->Draw("nostacksame");
        leg->Draw("same");
        signal_histos[i]->Draw("same");
        disc_value_text->Draw();
        c1->Print(output_names[i]);
        c1->Delete();
    }

}
void bcal_hist_eff_summary(void)
{
// read in histograms plotting BCAL efficiencies and print history to file.
//

gROOT->Reset();
//TTree *Bfield = (TTree *) gROOT->FindObject("Bfield");
gStyle->SetPalette(1,0);
gStyle->SetOptStat(kFALSE);
// gStyle->SetOptStat(11111111);
gStyle->SetPadRightMargin(0.15);
gStyle->SetPadLeftMargin(0.15);
gStyle->SetPadBottomMargin(0.15);
//

   char string[256];
   Int_t j,jj;
   Int_t ndx;
   // Int_t npts=7;   // run 1506
   // Int_t npts=42;   // run 2400
   // Int_t npts=423;    // run 2439
   // Int_t npts=205;    // run 2439
   Int_t npts=18;    // run 2179

   // define history histogram

   Double_t xmin=0;
   Double_t xmax=npts;
   //Double_t ymin=0.5;
   // Double_t ymax=1.1;
   Double_t ymin=0.;
   Double_t ymax=1.2;
  TH1F *hsummary_layer1 = new TH1F("hsummary_layer1","Summary layer 1",npts,xmin,xmax);
  TH1F *hsummary_layer2 = new TH1F("hsummary_layer2","Summary layer 2",npts,xmin,xmax);
  TH1F *hsummary_layer3 = new TH1F("hsummary_layer3","Summary layer 3",npts,xmin,xmax);
  TH1F *hsummary_layer4 = new TH1F("hsummary_layer4","Summary layer 4",npts,xmin,xmax);

  TH1F *hsummary2_layer1 = new TH1F("hsummary2_layer1","Summary layer 1",npts,xmin,xmax);
  TH1F *hsummary2_layer2 = new TH1F("hsummary2_layer2","Summary layer 2",npts,xmin,xmax);
  TH1F *hsummary2_layer3 = new TH1F("hsummary2_layer3","Summary layer 3",npts,xmin,xmax);
  TH1F *hsummary2_layer4 = new TH1F("hsummary2_layer4","Summary layer 4",npts,xmin,xmax);

   // read histograms from file

   for (ndx=0; ndx < npts; ndx++) {

   sprintf(string,"hd_rawdata_002179_%03d_.root",ndx);


   // if (ndx == 1) continue;  // run 1506
   /*if (ndx == 2) continue;
   if (ndx == 6) continue;
   if (ndx == 12) continue;;
   if (ndx == 39) continue;*/ 

   /*if (ndx == 10) continue;     // file #3 is empty
   if (ndx == 92) continue;     // file #3 is empty
   if (ndx == 95) continue;     // file #3 is empty
   if (ndx == 141) continue;     // file #3 is empty
   if (ndx == 176) continue;     // file #3 is empty
   if (ndx == 225) continue;     // file #3 is empty
   if (ndx == 226) continue;     // file #3 is empty
   if (ndx == 227) continue;     // file #3 is empty
   if (ndx >= 230 && ndx<=254 ) continue;     // file #3 is empty
   if (ndx == 257) continue;     // file #3 is empty
   if (ndx == 258) continue;     // file #3 is empty
   if (ndx == 260) continue;     // file #3 is empty
   if (ndx == 262) continue;     // file #3 is empty
   if (ndx == 264) continue;     // file #3 is empty
   if (ndx == 278) continue;     // file #3 is empty
   if (ndx == 281) continue;     // file #3 is empty
   if (ndx == 284) continue;     // file #3 is empty
   if (ndx == 285) continue;     // file #3 is empty
   if (ndx == 286) continue;     // file #3 is empty
   if (ndx == 287) continue;     // file #3 is empty
   if (ndx == 289) continue;     // file #3 is empty
   if (ndx == 290) continue;     // file #3 is empty
   if (ndx == 291) continue;     // file #3 is empty
   if (ndx == 293) continue;     // file #3 is empty
   if (ndx == 294) continue;     // file #3 is empty
   if (ndx == 295) continue;     // file #3 is empty
   if (ndx == 298) continue;     // file #3 is empty
   if (ndx == 299) continue;     // file #3 is empty
   if (ndx == 304) continue;     // file #3 is empty
   if (ndx == 306) continue;     // file #3 is empty*/

   TFile *in=NULL;
   in = new TFile(string,"read");
   if (!in) {
     printf ("Histogram input filename=%s does not open\n",string);
     continue;
   }
   else {
     printf ("Histogram input filename=%s OK\n",string);
   }

   // cd into bcal_eff directory
   TDirectory *dir = (TDirectory*)gDirectory->FindObjectAny("bcal_eff");
   if(dir) dir->cd();

   TH1F *h1eff_eff= NULL;
   h1eff_eff = (TH1F*)gDirectory->FindObjectAny("h1eff_eff");
   TH1F *h1eff_cellideff = (TH1F*)gDirectory->FindObjectAny("h1eff_cellideff");
   TH1F *h1eff2_eff2 = (TH1F*)gDirectory->FindObjectAny("h1eff2_eff2");
   TH1F *h1eff2_cellideff2 = (TH1F*)gDirectory->FindObjectAny("h1eff2_cellideff2");

   if ( (h1eff_eff == NULL) ||  (h1eff_eff->GetEntries() <=0)) continue;

   // retrieving information from the histogram

   Int_t ndim = h1eff_eff->GetNbinsX();
   Double_t xlo = h1eff_eff->GetBinLowEdge(1);
   Double_t width = h1eff_eff->GetBinWidth(1);
   Double_t xhi = xlo + width*ndim;
   printf ("\nbcal_hist_eff_summary: ndx=%d, ndim=%d, xlo=%f, width=%f, xhi=%d\n\n",ndx,ndim,xlo,width,xhi);

      for(j=0;j<ndim;j++) {
      Double_t xbin = xlo + j*width;
      Double_t content = h1eff_eff->GetBinContent(j+1);
      Double_t error = h1eff_eff->GetBinError(j+1);
      printf ("j=%d, xbin=%f, content=%f\n",j,xbin,content);

     // fill summary histogram

          if (j == 1) {
	hsummary_layer1->SetBinContent(ndx+1,content);
                    hsummary_layer1->SetBinError(ndx+1,error);
	}
         if (j == 2) {
	hsummary_layer2->SetBinContent(ndx+1,content);
                    hsummary_layer2->SetBinError(ndx+1,error);
	}
         if (j == 3) {
	hsummary_layer3->SetBinContent(ndx+1,content);
                    hsummary_layer3->SetBinError(ndx+1,error);
	}
         if (j == 4) {
	hsummary_layer4->SetBinContent(ndx+1,content);
                    hsummary_layer4->SetBinError(ndx+1,error);
	}
    
   }



   // retrieving information from the histogram

   ndim = h1eff2_eff2->GetNbinsX();
   xlo = h1eff2_eff2->GetBinLowEdge(1);
   width = h1eff2_eff2->GetBinWidth(1);
   xhi = xlo + width*ndim;
   printf ("\nbcal_hist_eff2_summary: ndx=%d, ndim=%d, xlo=%f, width=%f, xhi=%f\n\n",ndx,ndim,xlo,width,xhi);

      for(j=0;j<ndim;j++) {
      Double_t xbin = xlo + j*width;
      Double_t content = h1eff2_eff2->GetBinContent(j+1);
      Double_t error = h1eff2_eff2->GetBinError(j+1);
      printf ("j=%d, xbin=%f, content=%f\n",j,xbin,content);

     // fill summary histogram

          if (j == 1) {
	hsummary2_layer1->SetBinContent(ndx+1,content);
                    hsummary2_layer1->SetBinError(ndx+1,error);
	}
         if (j == 2) {
	hsummary2_layer2->SetBinContent(ndx+1,content);
                    hsummary2_layer2->SetBinError(ndx+1,error);
	}
         if (j == 3) {
	hsummary2_layer3->SetBinContent(ndx+1,content);
                    hsummary2_layer3->SetBinError(ndx+1,error);
	}
         if (j == 4) {
	hsummary2_layer4->SetBinContent(ndx+1,content);
                    hsummary2_layer4->SetBinError(ndx+1,error);
	}
    
   }

      in->Close();
   
   }   // end loop over histogram files

   //
   TCanvas *c1 = new TCanvas("c1","c1 bcal_hist_eff_summary ",200,10,700,700);
   c1->SetBorderMode(0);
   c1->SetFillColor(0);

   c1->SetGridx();
   c1->SetGridy();
   c1->SetBorderMode(0);
   c1->SetFillColor(0);

  TLegend *leg = new TLegend(0.6,0.8,0.85,0.95);
  leg->AddEntry(hsummary_layer1,"Layer 1","p");
  leg->AddEntry(hsummary_layer2,"Layer 2","p");
  leg->AddEntry(hsummary_layer3,"Layer 3","p");
  leg->AddEntry(hsummary_layer4,"Layer 4","p");

   hsummary_layer1->SetTitle("");
   //hsummary_layer1->GetXaxis()->SetRangeUser(xmin,xmax);
   hsummary_layer1->GetYaxis()->SetRangeUser(ymin,ymax);
   hsummary_layer1->GetXaxis()->SetTitleSize(0.05);
   hsummary_layer1->GetYaxis()->SetTitleSize(0.05);
   hsummary_layer1->GetXaxis()->SetTitle("File Number");
   hsummary_layer1->GetYaxis()->SetTitle("Efficiency Clusters");
   hsummary_layer1->SetLineColor(2);
   hsummary_layer1->SetMarkerColor(2);
   hsummary_layer1->SetMarkerStyle(20);
   hsummary_layer1->Draw("p");

   hsummary_layer2->SetLineColor(4);
   hsummary_layer2->SetMarkerColor(4);
   hsummary_layer2->SetMarkerStyle(20);
   hsummary_layer2->Draw("samep");

   hsummary_layer3->SetLineColor(1);
   hsummary_layer3->SetMarkerColor(1);
   hsummary_layer3->SetMarkerStyle(20);
   hsummary_layer3->Draw("samep");

   hsummary_layer4->SetLineColor(3);
   hsummary_layer4->SetMarkerColor(3);
   hsummary_layer4->SetMarkerStyle(20);
   hsummary_layer4->Draw("samep");

   sprintf(string,"hd_rawdata_002179");
   printf ("Histogram input filename=%s\n",string);
   TLatex *t1 = new TLatex(0.15,0.92,string);
   t1->SetNDC();
   t1->SetTextSize(0.03);
   t1->Draw();

  leg->Draw();

   //
   TCanvas *c2 = new TCanvas("c2","c2 bcal_hist_eff_summary ",200,10,700,700);
   c2->SetBorderMode(0);
   c2->SetFillColor(0);

   c2->SetGridx();
   c2->SetGridy();
   c2->SetBorderMode(0);
   c2->SetFillColor(0);

   leg = new TLegend(0.6,0.80,0.85,0.95);
  leg->AddEntry(hsummary2_layer1,"Layer 1","p");
  leg->AddEntry(hsummary2_layer2,"Layer 2","p");
  leg->AddEntry(hsummary2_layer3,"Layer 3","p");
  leg->AddEntry(hsummary2_layer4,"Layer 4","p");

   hsummary2_layer1->SetTitle("");
   //hsummary2_layer1->GetXaxis()->SetRangeUser(xmin,xmax);
   hsummary2_layer1->GetYaxis()->SetRangeUser(ymin,ymax);
   hsummary2_layer1->GetXaxis()->SetTitleSize(0.05);
   hsummary2_layer1->GetYaxis()->SetTitleSize(0.05);
   hsummary2_layer1->GetXaxis()->SetTitle("File Number");
   hsummary2_layer1->GetYaxis()->SetTitle("Efficiency Enhanced Hits");
   hsummary2_layer1->SetLineColor(2);
   hsummary2_layer1->SetMarkerColor(2);
   hsummary2_layer1->SetMarkerStyle(20);
   hsummary2_layer1->Draw("p");

   hsummary2_layer2->SetLineColor(4);
   hsummary2_layer2->SetMarkerColor(4);
   hsummary2_layer2->SetMarkerStyle(20);
   hsummary2_layer2->Draw("samep");

   hsummary2_layer3->SetLineColor(1);
   hsummary2_layer3->SetMarkerColor(1);
   hsummary2_layer3->SetMarkerStyle(20);
   hsummary2_layer3->Draw("samep");

   hsummary2_layer4->SetLineColor(3);
   hsummary2_layer4->SetMarkerColor(3);
   hsummary2_layer4->SetMarkerStyle(20);
   hsummary2_layer4->Draw("samep");

   sprintf(string,"hd_rawdata_002179");
   printf ("Histogram input filename=%s\n",string);
   t1 = new TLatex(0.15,0.92,string);
   t1->SetNDC();
   t1->SetTextSize(0.03);
   t1->Draw();

  leg->Draw();



   sprintf(string,"bcal_hist_eff_summary_002179.pdf(");
   c1->SaveAs(string);

   sprintf(string,"bcal_hist_eff_summary_002179.pdf)");
   c2->SaveAs(string);

}
void compare_ATLAS_pp_fitBoth(Int_t nfit=6, Int_t FitStart=50, Int_t FitEnd=450) {

//=========Macro generated from canvas: cATLAS_pp/
//=========  (Wed Jul 22 23:01:26 2015) by ROOT version5.32/00
    TCanvas *cATLAS_pp = new TCanvas("cATLAS_pp", "",0,0,1200,1000);
    TH1::SetDefaultSumw2();
    gStyle->SetOptFit(1);
    gStyle->SetOptStat(0);
    cATLAS_pp->Range(-3.725291e-06,-5.878322,500,3.279288);
    cATLAS_pp->SetFillColor(0);
    cATLAS_pp->SetBorderMode(0);
    cATLAS_pp->SetBorderSize(2);
    cATLAS_pp->SetLogy();
    cATLAS_pp->SetFrameBorderMode(0);
    cATLAS_pp->SetFrameBorderMode(0);
    TF1 *fitppATLAS = new TF1("fitppATLAS","[0]*pow(x+[2],[1])"); //create function
    fitppATLAS->SetParameters(1e10,-5,0);
    fitppATLAS->SetLineColor(kRed);
    TF1 *fitppCMS = new TF1("fitppCMS","[0]*pow(x+[2],[1])"); //create function
    fitppCMS->SetParameters(1e10,-5,0);
    fitppCMS->SetLineColor(kBlue);

    TGraphAsymmErrors *grae = new TGraphAsymmErrors(12);
    grae->SetName("/HepData/8719/d2x1y1");
    grae->SetTitle(" ");
    grae->SetFillColor(1);
    grae->SetMarkerStyle(33);
    grae->SetPoint(0,35,180);
    grae->SetPointError(0,4,4,29.95905,29.95905);
    grae->SetPoint(1,44.5,55.7);
    grae->SetPointError(1,5.5,5.5,7.828377,7.828377);
    grae->SetPoint(2,56.5,16.9);
    grae->SetPointError(2,6.5,6.5,2.625436,2.625436);
    grae->SetPoint(3,71,4.85);
    grae->SetPointError(3,8,8,0.6276957,0.6276957);
    grae->SetPoint(4,89.5,1.42);
    grae->SetPointError(4,10.5,10.5,0.1878054,0.1878054);
    grae->SetPoint(5,112.5,0.364);
    grae->SetPointError(5,12.5,12.5,0.04772427,0.04772427);
    grae->SetPoint(6,141.5,0.0882);
    grae->SetPointError(6,16.5,16.5,0.01103805,0.01103805);
    grae->SetPoint(7,178.5,0.0197);
    grae->SetPointError(7,20.5,20.5,0.002292152,0.002292152);
    grae->SetPoint(8,225,0.00406);
    grae->SetPointError(8,26,26,0.0004822521,0.0004822521);
    grae->SetPoint(9,283.5,0.000735);
    grae->SetPointError(9,32.5,32.5,8.981748e-05,8.981748e-05);
    grae->SetPoint(10,357,0.000114);
    grae->SetPointError(10,41,41,1.442494e-05,1.442494e-05);
    grae->SetPoint(11,449.5,1.41e-05);
    grae->SetPointError(11,51.5,51.5,1.98855e-06,1.98855e-06);

    TH1F *hATLASpp = new TH1F("hATLASpp"," ",100,50,450);
    hATLASpp->SetMinimum(1.090031e-05);
    hATLASpp->SetMaximum(230.955);
    hATLASpp->SetDirectory(0);
    hATLASpp->SetStats(0);

    Int_t ci;   // for color index setting
    ci = TColor::GetColor("#000099");
    hATLASpp->SetLineColor(ci);
    hATLASpp->GetXaxis()->SetTitle("ak R=0.4 Jet p_{T} (GeV/c)");
    hATLASpp->GetXaxis()->SetLabelFont(42);
    hATLASpp->GetXaxis()->SetLabelSize(0.035);
    hATLASpp->GetXaxis()->SetTitleSize(0.035);
    hATLASpp->GetXaxis()->SetTitleFont(42);
    hATLASpp->GetYaxis()->SetTitle("#frac{d^{2}#sigma}{dp_{T} d#eta} nb");
    hATLASpp->GetYaxis()->SetLabelFont(42);
    hATLASpp->GetYaxis()->SetLabelSize(0.035);
    hATLASpp->GetYaxis()->SetTitleSize(0.035);
    hATLASpp->GetYaxis()->SetTitleFont(42);
    hATLASpp->GetZaxis()->SetLabelFont(42);
    hATLASpp->GetZaxis()->SetLabelSize(0.035);
    hATLASpp->GetZaxis()->SetTitleSize(0.035);
    hATLASpp->GetZaxis()->SetTitleFont(42);
    grae->SetHistogram(hATLASpp);
    hATLASpp->Draw();
    grae->Draw("ap,same");

    for(int i=0; i<nfit; ++i) {
        grae->Fit("fitppATLAS","I","",FitStart,FitEnd); //fit function
    }

    Double_t xAxis2086[101] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520, 530, 540, 550, 560, 570, 580, 590, 600, 610, 620, 630, 640, 650, 660, 670, 680, 690, 700, 710, 720, 730, 740, 750, 760, 770, 780, 790, 800, 810, 820, 830, 840, 850, 860, 870, 880, 890, 900, 910, 920, 930, 940, 950, 960, 970, 980, 990, 1000};

    TH1F *uPP_R4_SVD = new TH1F("uPP_R4_SVD","Unfold Matrix refpt jtpt from trigger addition R4 20_eta_20 ",100, xAxis2086);
    uPP_R4_SVD->SetBinContent(1,15.44572);
    uPP_R4_SVD->SetBinContent(2,81.73347);
    uPP_R4_SVD->SetBinContent(3,85.49986);
    uPP_R4_SVD->SetBinContent(4,90.07588);
    uPP_R4_SVD->SetBinContent(5,47.67952);
    uPP_R4_SVD->SetBinContent(6,18.31659);
    uPP_R4_SVD->SetBinContent(7,7.348095);
    uPP_R4_SVD->SetBinContent(8,3.295203);
    uPP_R4_SVD->SetBinContent(9,1.60486);
    uPP_R4_SVD->SetBinContent(10,0.8393627);
    uPP_R4_SVD->SetBinContent(11,0.4622419);
    uPP_R4_SVD->SetBinContent(12,0.265131);
    uPP_R4_SVD->SetBinContent(13,0.1587068);
    uPP_R4_SVD->SetBinContent(14,0.09774788);
    uPP_R4_SVD->SetBinContent(15,0.06153403);
    uPP_R4_SVD->SetBinContent(16,0.03981187);
    uPP_R4_SVD->SetBinContent(17,0.02620752);
    uPP_R4_SVD->SetBinContent(18,0.01766706);
    uPP_R4_SVD->SetBinContent(19,0.01206758);
    uPP_R4_SVD->SetBinContent(20,0.008403017);
    uPP_R4_SVD->SetBinContent(21,0.005956108);
    uPP_R4_SVD->SetBinContent(22,0.004267026);
    uPP_R4_SVD->SetBinContent(23,0.003102345);
    uPP_R4_SVD->SetBinContent(24,0.002273482);
    uPP_R4_SVD->SetBinContent(25,0.001699103);
    uPP_R4_SVD->SetBinContent(26,0.001281323);
    uPP_R4_SVD->SetBinContent(27,0.000971557);
    uPP_R4_SVD->SetBinContent(28,0.0007444665);
    uPP_R4_SVD->SetBinContent(29,0.0005746992);
    uPP_R4_SVD->SetBinContent(30,0.0004462709);
    uPP_R4_SVD->SetBinContent(31,0.0003483805);
    uPP_R4_SVD->SetBinContent(32,0.0002725941);
    uPP_R4_SVD->SetBinContent(33,0.0002141152);
    uPP_R4_SVD->SetBinContent(34,0.0001705039);
    uPP_R4_SVD->SetBinContent(35,0.0001352845);
    uPP_R4_SVD->SetBinContent(36,0.0001073623);
    uPP_R4_SVD->SetBinContent(37,8.559958e-05);
    uPP_R4_SVD->SetBinContent(38,6.847693e-05);
    uPP_R4_SVD->SetBinContent(39,5.506579e-05);
    uPP_R4_SVD->SetBinContent(40,4.404838e-05);
    uPP_R4_SVD->SetBinContent(41,3.566817e-05);
    uPP_R4_SVD->SetBinContent(42,2.88001e-05);
    uPP_R4_SVD->SetBinContent(43,2.33088e-05);
    uPP_R4_SVD->SetBinContent(44,1.897322e-05);
    uPP_R4_SVD->SetBinContent(45,1.546483e-05);
    uPP_R4_SVD->SetBinContent(46,1.251424e-05);
    uPP_R4_SVD->SetBinContent(47,1.020799e-05);
    uPP_R4_SVD->SetBinContent(48,8.267746e-06);
    uPP_R4_SVD->SetBinContent(49,6.760333e-06);
    uPP_R4_SVD->SetBinContent(50,5.504337e-06);
    uPP_R4_SVD->SetBinContent(51,4.514429e-06);
    uPP_R4_SVD->SetBinContent(52,3.665816e-06);
    uPP_R4_SVD->SetBinContent(53,3.010496e-06);
    uPP_R4_SVD->SetBinContent(54,2.463812e-06);
    uPP_R4_SVD->SetBinContent(55,2.01082e-06);
    uPP_R4_SVD->SetBinContent(56,1.624154e-06);
    uPP_R4_SVD->SetBinContent(57,1.334625e-06);
    uPP_R4_SVD->SetBinContent(58,1.088798e-06);
    uPP_R4_SVD->SetBinContent(59,8.896167e-07);
    uPP_R4_SVD->SetBinContent(60,7.305952e-07);
    uPP_R4_SVD->SetBinContent(61,5.930196e-07);
    uPP_R4_SVD->SetBinContent(62,4.863888e-07);
    uPP_R4_SVD->SetBinContent(63,3.941485e-07);
    uPP_R4_SVD->SetBinContent(64,3.221651e-07);
    uPP_R4_SVD->SetBinContent(65,2.636797e-07);
    uPP_R4_SVD->SetBinContent(66,2.146457e-07);
    uPP_R4_SVD->SetBinContent(67,1.742243e-07);
    uPP_R4_SVD->SetBinContent(68,1.409108e-07);
    uPP_R4_SVD->SetBinContent(69,1.142703e-07);
    uPP_R4_SVD->SetBinContent(70,9.293402e-08);
    uPP_R4_SVD->SetBinContent(71,7.511816e-08);
    uPP_R4_SVD->SetBinContent(72,6.013509e-08);
    uPP_R4_SVD->SetBinContent(73,4.927971e-08);
    uPP_R4_SVD->SetBinContent(74,3.992714e-08);
    uPP_R4_SVD->SetBinContent(75,3.176246e-08);
    uPP_R4_SVD->SetBinContent(76,2.560933e-08);
    uPP_R4_SVD->SetBinContent(77,2.039975e-08);
    uPP_R4_SVD->SetBinContent(78,1.627726e-08);
    uPP_R4_SVD->SetBinContent(79,1.272043e-08);
    uPP_R4_SVD->SetBinContent(80,1.022684e-08);
    uPP_R4_SVD->SetBinContent(81,8.172451e-09);
    uPP_R4_SVD->SetBinContent(82,6.570082e-09);
    uPP_R4_SVD->SetBinContent(83,5.205766e-09);
    uPP_R4_SVD->SetBinContent(84,4.075393e-09);
    uPP_R4_SVD->SetBinContent(85,3.265506e-09);
    uPP_R4_SVD->SetBinContent(86,2.62088e-09);
    uPP_R4_SVD->SetBinContent(87,2.003114e-09);
    uPP_R4_SVD->SetBinContent(88,1.535628e-09);
    uPP_R4_SVD->SetBinContent(89,1.063791e-09);
    uPP_R4_SVD->SetBinContent(90,9.092138e-10);
    uPP_R4_SVD->SetBinContent(91,6.803265e-10);
    uPP_R4_SVD->SetBinContent(92,4.778346e-10);
    uPP_R4_SVD->SetBinContent(93,3.988072e-10);
    uPP_R4_SVD->SetBinContent(94,2.474126e-10);
    uPP_R4_SVD->SetBinContent(95,2.140924e-10);
    uPP_R4_SVD->SetBinContent(96,1.623732e-10);
    uPP_R4_SVD->SetBinContent(97,1.45067e-10);
    uPP_R4_SVD->SetBinContent(98,9.186947e-11);
    uPP_R4_SVD->SetBinContent(99,6.040857e-11);
    uPP_R4_SVD->SetBinContent(100,6.157141e-11);
    uPP_R4_SVD->SetBinError(1,0.1237595);
    uPP_R4_SVD->SetBinError(2,0.6234048);
    uPP_R4_SVD->SetBinError(3,0.586929);
    uPP_R4_SVD->SetBinError(4,0.5173901);
    uPP_R4_SVD->SetBinError(5,0.2055361);
    uPP_R4_SVD->SetBinError(6,0.04990473);
    uPP_R4_SVD->SetBinError(7,0.01308245);
    uPP_R4_SVD->SetBinError(8,0.006804987);
    uPP_R4_SVD->SetBinError(9,0.003260532);
    uPP_R4_SVD->SetBinError(10,0.001534405);
    uPP_R4_SVD->SetBinError(11,0.001026545);
    uPP_R4_SVD->SetBinError(12,0.000705749);
    uPP_R4_SVD->SetBinError(13,0.0004784051);
    uPP_R4_SVD->SetBinError(14,0.0003483983);
    uPP_R4_SVD->SetBinError(15,0.0002598719);
    uPP_R4_SVD->SetBinError(16,0.0001903908);
    uPP_R4_SVD->SetBinError(17,0.0001387089);
    uPP_R4_SVD->SetBinError(18,0.0001040173);
    uPP_R4_SVD->SetBinError(19,7.981541e-05);
    uPP_R4_SVD->SetBinError(20,6.24475e-05);
    uPP_R4_SVD->SetBinError(21,4.937991e-05);
    uPP_R4_SVD->SetBinError(22,3.947987e-05);
    uPP_R4_SVD->SetBinError(23,3.254473e-05);
    uPP_R4_SVD->SetBinError(24,2.764293e-05);
    uPP_R4_SVD->SetBinError(25,2.429597e-05);
    uPP_R4_SVD->SetBinError(26,2.159774e-05);
    uPP_R4_SVD->SetBinError(27,1.917051e-05);
    uPP_R4_SVD->SetBinError(28,1.6997e-05);
    uPP_R4_SVD->SetBinError(29,1.498669e-05);
    uPP_R4_SVD->SetBinError(30,1.312744e-05);
    uPP_R4_SVD->SetBinError(31,1.142902e-05);
    uPP_R4_SVD->SetBinError(32,9.871913e-06);
    uPP_R4_SVD->SetBinError(33,8.480939e-06);
    uPP_R4_SVD->SetBinError(34,7.324674e-06);
    uPP_R4_SVD->SetBinError(35,6.255272e-06);
    uPP_R4_SVD->SetBinError(36,5.306614e-06);
    uPP_R4_SVD->SetBinError(37,4.495288e-06);
    uPP_R4_SVD->SetBinError(38,3.800242e-06);
    uPP_R4_SVD->SetBinError(39,3.214166e-06);
    uPP_R4_SVD->SetBinError(40,2.692884e-06);
    uPP_R4_SVD->SetBinError(41,2.275421e-06);
    uPP_R4_SVD->SetBinError(42,1.910914e-06);
    uPP_R4_SVD->SetBinError(43,1.60384e-06);
    uPP_R4_SVD->SetBinError(44,1.350324e-06);
    uPP_R4_SVD->SetBinError(45,1.135728e-06);
    uPP_R4_SVD->SetBinError(46,9.463317e-07);
    uPP_R4_SVD->SetBinError(47,7.933288e-07);
    uPP_R4_SVD->SetBinError(48,6.591956e-07);
    uPP_R4_SVD->SetBinError(49,5.520988e-07);
    uPP_R4_SVD->SetBinError(50,4.597711e-07);
    uPP_R4_SVD->SetBinError(51,3.851643e-07);
    uPP_R4_SVD->SetBinError(52,3.190695e-07);
    uPP_R4_SVD->SetBinError(53,2.670117e-07);
    uPP_R4_SVD->SetBinError(54,2.22444e-07);
    uPP_R4_SVD->SetBinError(55,1.84622e-07);
    uPP_R4_SVD->SetBinError(56,1.515098e-07);
    uPP_R4_SVD->SetBinError(57,1.263889e-07);
    uPP_R4_SVD->SetBinError(58,1.045901e-07);
    uPP_R4_SVD->SetBinError(59,8.662012e-08);
    uPP_R4_SVD->SetBinError(60,7.20551e-08);
    uPP_R4_SVD->SetBinError(61,5.920339e-08);
    uPP_R4_SVD->SetBinError(62,4.912298e-08);
    uPP_R4_SVD->SetBinError(63,4.024705e-08);
    uPP_R4_SVD->SetBinError(64,3.324212e-08);
    uPP_R4_SVD->SetBinError(65,2.747888e-08);
    uPP_R4_SVD->SetBinError(66,2.258106e-08);
    uPP_R4_SVD->SetBinError(67,1.849393e-08);
    uPP_R4_SVD->SetBinError(68,1.50859e-08);
    uPP_R4_SVD->SetBinError(69,1.233344e-08);
    uPP_R4_SVD->SetBinError(70,1.010825e-08);
    uPP_R4_SVD->SetBinError(71,8.230567e-09);
    uPP_R4_SVD->SetBinError(72,6.634947e-09);
    uPP_R4_SVD->SetBinError(73,5.473309e-09);
    uPP_R4_SVD->SetBinError(74,4.462479e-09);
    uPP_R4_SVD->SetBinError(75,3.571148e-09);
    uPP_R4_SVD->SetBinError(76,2.895626e-09);
    uPP_R4_SVD->SetBinError(77,2.318939e-09);
    uPP_R4_SVD->SetBinError(78,1.859689e-09);
    uPP_R4_SVD->SetBinError(79,1.460273e-09);
    uPP_R4_SVD->SetBinError(80,1.179314e-09);
    uPP_R4_SVD->SetBinError(81,9.46416e-10);
    uPP_R4_SVD->SetBinError(82,7.638915e-10);
    uPP_R4_SVD->SetBinError(83,6.075323e-10);
    uPP_R4_SVD->SetBinError(84,4.772801e-10);
    uPP_R4_SVD->SetBinError(85,3.836821e-10);
    uPP_R4_SVD->SetBinError(86,3.088773e-10);
    uPP_R4_SVD->SetBinError(87,2.367363e-10);
    uPP_R4_SVD->SetBinError(88,1.819577e-10);
    uPP_R4_SVD->SetBinError(89,1.263493e-10);
    uPP_R4_SVD->SetBinError(90,1.082238e-10);
    uPP_R4_SVD->SetBinError(91,8.113796e-11);
    uPP_R4_SVD->SetBinError(92,5.70881e-11);
    uPP_R4_SVD->SetBinError(93,4.772047e-11);
    uPP_R4_SVD->SetBinError(94,2.964495e-11);
    uPP_R4_SVD->SetBinError(95,2.568217e-11);
    uPP_R4_SVD->SetBinError(96,1.949672e-11);
    uPP_R4_SVD->SetBinError(97,1.743206e-11);
    uPP_R4_SVD->SetBinError(98,1.104588e-11);
    uPP_R4_SVD->SetBinError(99,7.265969e-12);
    uPP_R4_SVD->SetBinError(100,7.407249e-12);
    uPP_R4_SVD->SetEntries(100);
    uPP_R4_SVD->SetStats(0);

    ci = TColor::GetColor("#000099");
    uPP_R4_SVD->SetLineColor(ci);

//    ci = TColor::GetColor("#0000ff");
//    uPP_R4_SVD->SetMarkerColor(ci);
//    uPP_R4_SVD->SetMarkerStyle(24);
//    uPP_R4_SVD->GetXaxis()->CenterTitle(true);
//    uPP_R4_SVD->GetXaxis()->SetLabelFont(42);
//    uPP_R4_SVD->GetXaxis()->SetLabelSize(0.035);
//    uPP_R4_SVD->GetXaxis()->SetTitleSize(0.035);
//    uPP_R4_SVD->GetXaxis()->SetTitleFont(42);
//    uPP_R4_SVD->GetYaxis()->CenterTitle(true);
//    uPP_R4_SVD->GetYaxis()->SetLabelFont(42);
//    uPP_R4_SVD->GetYaxis()->SetLabelSize(0.035);
//    uPP_R4_SVD->GetYaxis()->SetTitleSize(0.035);
//    uPP_R4_SVD->GetYaxis()->SetTitleFont(42);
//    uPP_R4_SVD->GetZaxis()->SetLabelFont(42);
//    uPP_R4_SVD->GetZaxis()->SetLabelSize(0.035);
//    uPP_R4_SVD->GetZaxis()->SetTitleSize(0.035);
//    uPP_R4_SVD->GetZaxis()->SetTitleFont(42);
//    uPP_R4_SVD->Draw("same E1");
//    TBox *box = new TBox(60,7.108492,70,7.587699);
//    box->SetFillColor(2);
//    box->SetFillStyle(0);
//    box->SetLineColor(2);
//    box->Draw();
//    box = new TBox(70,3.186674,80,3.403731);
//    box->SetFillColor(2);
//    box->SetFillStyle(0);
//    box->SetLineColor(2);
//    box->Draw();
//    box = new TBox(80,1.551541,90,1.658179);
//    box->SetFillColor(2);
//    box->SetFillStyle(0);
//    box->SetLineColor(2);
//    box->Draw();
//    box = new TBox(90,0.8111346,100,0.8675909);
//    box->SetFillColor(2);
//    box->SetFillStyle(0);
//    box->SetLineColor(2);
//    box->Draw();
//    box = new TBox(100,0.4464541,110,0.4780297);
//    box->SetFillColor(2);
//    box->SetFillStyle(0);
//    box->SetLineColor(2);
//    box->Draw();
//    box = new TBox(110,0.2045159,130,0.2193219);
//    box->SetFillColor(2);
//    box->SetFillStyle(0);
//    box->SetLineColor(2);
//    box->Draw();
//    box = new TBox(130,0.07677678,150,0.08250514);
//    box->SetFillColor(2);
//    box->SetFillStyle(0);
//    box->SetLineColor(2);
//    box->Draw();
//    box = new TBox(150,0.03180206,170,0.03421734);
//    box->SetFillColor(2);
//    box->SetFillStyle(0);
//    box->SetLineColor(2);
//    box->Draw();
//    box = new TBox(170,0.01431415,190,0.01542048);
//    box->SetFillColor(2);
//    box->SetFillStyle(0);
//    box->SetLineColor(2);
//    box->Draw();
//    box = new TBox(190,0.006909775,210,0.007449351);
//    box->SetFillColor(2);
//    box->SetFillStyle(0);
//    box->SetLineColor(2);
//    box->Draw();
//    box = new TBox(210,0.003092187,240,0.003336382);
//    box->SetFillColor(2);
//    box->SetFillStyle(0);
//    box->SetLineColor(2);
//    box->Draw();
//    box = new TBox(240,0.001266417,270,0.001368238);
//    box->SetFillColor(2);
//    box->SetFillStyle(0);
//    box->SetLineColor(2);
//    box->Draw();
//    box = new TBox(270,0.00056544,300,0.0006115177);
//    box->SetFillColor(2);
//    box->SetFillStyle(0);
//    box->SetLineColor(2);
//    box->Draw();

    TLegend *leg = new TLegend(0.4,0.65,0.6,0.85,NULL,"BRNDC");
    leg->SetBorderSize(0);
    leg->SetTextSize(0.04);
    leg->SetLineColor(1);
    leg->SetLineStyle(1);
    leg->SetLineWidth(1);
    leg->SetFillColor(10);
    leg->SetFillStyle(1001);
    TLegendEntry *entry=leg->AddEntry("NULL","","h");
    entry->SetLineColor(1);
    entry->SetLineStyle(1);
    entry->SetLineWidth(1);
    entry->SetMarkerColor(1);
    entry->SetMarkerStyle(21);
    entry->SetMarkerSize(1);
    entry->SetTextFont(62);
    entry=leg->AddEntry("/HepData/8719/d2x1y1","ATLAS pp","p");
    entry->SetLineColor(1);
    entry->SetLineStyle(1);
    entry->SetLineWidth(1);
    entry->SetMarkerColor(1);
    entry->SetMarkerStyle(33);
    entry->SetMarkerSize(1);
    entry=leg->AddEntry("uPP_R4_SVD","CMS pp","p");
    entry->SetLineColor(1);
    entry->SetLineStyle(1);
    entry->SetLineWidth(1);

    ci = TColor::GetColor("#0000ff");
    entry->SetMarkerColor(ci);
    entry->SetMarkerStyle(24);
    entry->SetMarkerSize(1);
    leg->Draw();

    TPaveText *pt = new TPaveText(0.4845652,0.94,0.5154348,0.995,"blNDC");
    pt->SetName("title");
    pt->SetBorderSize(0);
    pt->SetFillColor(0);
    pt->SetFillStyle(0);
    pt->SetTextFont(42);
    TText *text = pt->AddText(" ");
    pt->Draw();
    cATLAS_pp->Modified();
    cATLAS_pp->cd();
    cATLAS_pp->SetSelected(cATLAS_pp);

    for(int ic=0; ic<nfit; ic++) {
        uPP_R4_SVD->Fit("fitppCMS","IL","",60,FitEnd); //fit function
//      uPP_R4_SVD->Fit("fitppCMS","IL","",50,300); //fit function
    }

    hATLASpp->Draw();
    grae->Draw("ap,same");
    uPP_R4_SVD->Draw("same E1");
    leg->Draw();
    cATLAS_pp->SaveAs("Plots/CMSfit_ATLASfit_spectra_pp.pdf");


    TCanvas *cCMS_pp = new TCanvas("cCMS_pp", "",0,0,1200,1000);
    cCMS_pp->Range(-3.725291e-06,-5.878322,500,3.279288);
    cCMS_pp->SetFillColor(0);
    cCMS_pp->SetBorderMode(0);
    cCMS_pp->SetBorderSize(2);
    cCMS_pp->SetLogy();
    cCMS_pp->SetLogx();
    cCMS_pp->SetFrameBorderMode(0);
    cCMS_pp->SetFrameBorderMode(0);
    uPP_R4_SVD->GetXaxis()->SetTitle("ak R=0.4 Jet p_{T} (GeV/c)");
    uPP_R4_SVD->GetXaxis()->SetLabelFont(42);
    uPP_R4_SVD->GetXaxis()->SetLabelSize(0.035);
    uPP_R4_SVD->GetXaxis()->SetTitleSize(0.035);
    uPP_R4_SVD->GetXaxis()->SetTitleFont(42);
    uPP_R4_SVD->GetXaxis()->SetRangeUser(50,450);
    uPP_R4_SVD->GetYaxis()->SetTitle("#frac{d^{2}#sigma}{dp_{T} d#eta} nb");
    uPP_R4_SVD->GetYaxis()->SetLabelFont(42);
    uPP_R4_SVD->GetYaxis()->SetLabelSize(0.035);
    uPP_R4_SVD->GetYaxis()->SetTitleSize(0.035);
    uPP_R4_SVD->GetYaxis()->SetTitleFont(42);
    uPP_R4_SVD->GetZaxis()->SetLabelFont(42);
    uPP_R4_SVD->GetZaxis()->SetLabelSize(0.035);
    uPP_R4_SVD->GetZaxis()->SetTitleSize(0.035);
    uPP_R4_SVD->GetZaxis()->SetTitleFont(42);

    uPP_R4_SVD->Draw();

    TLegend *leg = new TLegend(0.4,0.65,0.6,0.85,NULL,"BRNDC");
    leg->SetBorderSize(0);
    leg->SetTextSize(0.04);
    leg->SetLineColor(1);
    leg->SetLineStyle(1);
    leg->SetLineWidth(1);
    leg->SetFillColor(10);
    leg->SetFillStyle(1001);
    TLegendEntry *entry=leg->AddEntry("NULL","","h");
    entry->SetLineColor(1);
    entry->SetLineStyle(1);
    entry->SetLineWidth(1);
    entry->SetMarkerColor(1);
    entry->SetMarkerStyle(33);
    entry->SetMarkerSize(1);
    entry=leg->AddEntry("uPP_R4_SVD","CMS pp","p");
    entry->SetLineColor(1);
    entry->SetLineStyle(1);
    entry->SetLineWidth(1);

    ci = TColor::GetColor("#0000ff");
    entry->SetMarkerColor(ci);
    entry->SetMarkerStyle(24);
    entry->SetMarkerSize(1);
    leg->Draw();

    TPaveText *pt = new TPaveText(0.4845652,0.94,0.5154348,0.995,"blNDC");
    pt->SetName("title");
    pt->SetBorderSize(0);
    pt->SetFillColor(0);
    pt->SetFillStyle(0);
    pt->SetTextFont(42);
    TText *text = pt->AddText(" ");
    pt->Draw();
    cCMS_pp->Modified();
    cCMS_pp->cd();
    cCMS_pp->SetSelected(cCMS_pp);
    cCMS_pp->SaveAs("Plots/CMSfit_spectra_pp.pdf");

    TCanvas *cATLAS_lin_pp = new TCanvas("cATLAS_lin_pp", "",0,0,1200,1000);
    cATLAS_lin_pp->Range(-3.725291e-06,-5.878322,500,3.279288);
    cATLAS_lin_pp->SetFillColor(0);
    cATLAS_lin_pp->SetBorderMode(0);
    cATLAS_lin_pp->SetBorderSize(2);
    cATLAS_lin_pp->SetFrameBorderMode(0);
    cATLAS_lin_pp->SetFrameBorderMode(0);
    cATLAS_lin_pp->SetLogy();
    cATLAS_lin_pp->SetLogx();
    hATLASpp->Draw();
    grae->Draw("ap,same");
    TLegend *leg = new TLegend(0.4,0.65,0.6,0.85,NULL,"BRNDC");
    leg->SetBorderSize(0);
    leg->SetTextSize(0.04);
    leg->SetLineColor(1);
    leg->SetLineStyle(1);
    leg->SetLineWidth(1);
    leg->SetFillColor(10);
    leg->SetFillStyle(1001);
    TLegendEntry *entry=leg->AddEntry("NULL","","h");
    entry->SetLineColor(1);
    entry->SetLineStyle(1);
    entry->SetLineWidth(1);
    entry->SetMarkerColor(1);
    entry->SetMarkerStyle(21);
    entry->SetMarkerSize(1);
    entry->SetTextFont(62);
    entry=leg->AddEntry("/HepData/8719/d2x1y1","ATLAS pp","p");
    entry->SetLineColor(1);
    entry->SetLineStyle(1);
    entry->SetLineWidth(1);
    entry->SetMarkerColor(1);
    entry->SetMarkerStyle(33);
    entry->SetMarkerSize(1);
    entry=leg->AddEntry("uPP_R4_SVD","CMS pp","p");
    entry->SetLineColor(1);
    entry->SetLineStyle(1);
    entry->SetLineWidth(1);

    ci = TColor::GetColor("#0000ff");
    entry->SetMarkerColor(ci);
    entry->SetMarkerStyle(24);
    entry->SetMarkerSize(1);
    leg->Draw();

    TPaveText *pt = new TPaveText(0.4845652,0.94,0.5154348,0.995,"blNDC");
    pt->SetName("title");
    pt->SetBorderSize(0);
    pt->SetFillColor(0);
    pt->SetFillStyle(0);
    pt->SetTextFont(42);
    TText *text = pt->AddText(" ");
    pt->Draw();
    cATLAS_lin_pp->Modified();
    cATLAS_lin_pp->cd();
    cATLAS_lin_pp->SetSelected(cATLAS_lin_pp);

    for(int ic=0; ic<nfit; ic++) {
        uPP_R4_SVD->Fit("fitppCMS","IL","",60,FitEnd); //fit function
//      uPP_R4_SVD->Fit("fitppCMS","IL","",50,300); //fit function
    }

    hATLASpp->Draw();
    grae->Draw("ap,same");
    uPP_R4_SVD->Draw("same E1");
    leg->Draw();
    cATLAS_lin_pp->SaveAs("Plots/CMSfit_ATLASfit_spectra_loglog_pp.pdf");

    fitppCMS->SetBit(TF1::kNotDraw);
    fitppCMS->SetLineColor(0);
    uPP_R4_SVD->SetBit(TF1::kNotDraw);

    TH1F *hFitRatioATLAS = (TH1F*)functionHist(fitppCMS,uPP_R4_SVD,"hFitRatioATLAS"); //clone fitRatioATLAS from fitppCMS
//   hFitRatioATLAS->SetLineColor(0);
    TH1F *hRatioATLAS = (TH1F*)uPP_R4_SVD->Clone("hRatioATLAS"); //clone histogram hRatio from h

    TH1F *hfunctionATLAS = (TH1F*)functionHist(fitppATLAS,uPP_R4_SVD,"hfunctionATLAS");
    hFitRatioATLAS->Divide(hfunctionATLAS);
    hFitRatioATLAS->SetMarkerColor(kRed);
    hFitRatioATLAS->SetMarkerStyle(21);
    hFitRatioATLAS->SetMarkerSize(1.2);
    hFitRatioATLAS->SetLineColor(0);
//   hfunctionATLAS->Draw();
//   hATLASpp->Draw();
    hRatioATLAS->Divide(hfunctionATLAS);
    TCanvas *cRatio_pp = new TCanvas("cRatio_pp", "",0,0,1200,1000);
    gStyle->SetOptFit(1);
    gStyle->SetOptStat(0);
    gStyle->SetOptTitle(0);
    cRatio_pp->Range(-50.00001,-6.302699,538.2353,2.631555);
    cRatio_pp->SetFillColor(0);
    cRatio_pp->SetBorderMode(0);
    cRatio_pp->SetBorderSize(0);
    cRatio_pp->SetTickx(1);
    cRatio_pp->SetTicky(1);
    cRatio_pp->SetLeftMargin(0.17);
    cRatio_pp->SetRightMargin(0.15);
    cRatio_pp->SetTopMargin(0.03);
    cRatio_pp->SetBottomMargin(0.15);
    cRatio_pp->SetFrameLineColor(0);
    cRatio_pp->SetFrameBorderMode(0);
    cRatio_pp->SetFrameLineColor(0);
    cRatio_pp->SetFrameBorderMode(0);
    TH1F *hRatioBlank = new TH1F("hRatioBlank"," ",100,50,300);
    hRatioBlank->SetMinimum(0);
    hRatioBlank->SetMaximum(1.2);
    hRatioBlank->SetDirectory(0);
    hRatioBlank->SetStats(0);
    hRatioBlank->SetFillColor(1);
    hRatioBlank->SetFillStyle(0);
    hRatioBlank->SetLineStyle(0);
    hRatioBlank->SetMarkerStyle(20);
    hRatioBlank->SetMarkerSize(1.2);
    hRatioBlank->GetXaxis()->SetTitle("ak R=0.4 Jet p_{T} (GeV/c)");
    hRatioBlank->GetXaxis()->SetLabelFont(42);
    hRatioBlank->GetXaxis()->SetLabelOffset(0.01);
    hRatioBlank->GetXaxis()->SetLabelSize(0.045);
    hRatioBlank->GetXaxis()->SetTitleSize(0.055);
    hRatioBlank->GetXaxis()->SetTitleFont(42);
    hRatioBlank->GetYaxis()->SetTitle("CMS/ATLAS #frac{d^{2}#sigma}{dp_{T} d#eta} nb");
    hRatioBlank->GetYaxis()->SetLabelFont(42);
    hRatioBlank->GetYaxis()->SetLabelOffset(0.01);
    hRatioBlank->GetYaxis()->SetLabelSize(0.045);
    hRatioBlank->GetYaxis()->SetTitleSize(0.055);
    hRatioBlank->GetYaxis()->SetTitleOffset(1.5);
    hRatioBlank->GetYaxis()->SetTitleFont(42);
    hRatioBlank->GetZaxis()->SetLabelFont(42);
    hRatioBlank->GetZaxis()->SetLabelSize(0.045);
    hRatioBlank->GetZaxis()->SetTitleSize(0.035);
    hRatioBlank->GetZaxis()->SetTitleFont(42);
    hRatioBlank->Draw();
//   hRatioATLAS->Scale(5.3/4);
//   hFitRatioATLAS->Scale(5.3/4);
    hFitRatioATLAS->Draw("ap,same");
    hRatioATLAS->Draw("ap,same");

    cRatio_pp->SaveAs("Plots/CMSfit_ATLASfit_ratio_pp.pdf");



}
void studyTemplate(const TString conf="sample.conf") {

  const Int_t nSamples=3;

  vector<TString> sampleNames;
  vector<TString> sampleTitles;
  vector<Int_t> sampleColors;

  confParse(conf, sampleNames, sampleTitles, sampleColors);

  TH1D *hSample[nSamples];

  char hname[100];

  for(UInt_t iSamp=0; iSamp<nSamples; iSamp++) {

    sprintf(hname, "hSample_%s", sampleTitles[iSamp].Data()); hSample[iSamp]= new TH1D(hname, "", 4, 0, 4);

  }

  UInt_t eventNum;
  UInt_t bTag1, bTag2;
  UInt_t tauDecayCat1, tauDecayCat2;
  LorentzVector *genB1=0, *genB2=0, *recoB1=0, *recoB2=0;
  LorentzVector *genTau1=0, *genTau2=0, *genDecayTau1=0, *genDecayTau2=0, *recoTau1=0, *recoTau2=0;

  TFile *infile;
  TTree *intree;

  for (UInt_t iSamp=0; iSamp<nSamples; iSamp++) { // sample loop

    TString infilename = sampleNames[iSamp];
    cout << "Processing  " << infilename << " ..." << endl;
    infile = new TFile(infilename); assert(infile);
    intree = (TTree*) infile->Get("Events"); assert(intree);
 
    intree->SetBranchAddress("eventNum",       &eventNum);
    intree->SetBranchAddress("bTag1",          &bTag1);
    intree->SetBranchAddress("bTag2",          &bTag2);
    intree->SetBranchAddress("genB1",          &genB1);
    intree->SetBranchAddress("genB2",          &genB2);
    intree->SetBranchAddress("recoB1",         &recoB1);
    intree->SetBranchAddress("recoB2",         &recoB2);
    intree->SetBranchAddress("tauDecayCat1",   &tauDecayCat1);
    intree->SetBranchAddress("tauDecayCat2",   &tauDecayCat2);
    intree->SetBranchAddress("genTau1",        &genTau1);
    intree->SetBranchAddress("genTau2",        &genTau2);
    intree->SetBranchAddress("genDecayTau1",   &genDecayTau1);
    intree->SetBranchAddress("genDecayTau2",   &genDecayTau2);
    intree->SetBranchAddress("recoTau1",       &recoTau1);
    intree->SetBranchAddress("recoTau2",       &recoTau2);

    for(UInt_t iEntry=0; iEntry<intree->GetEntries(); iEntry++) { // entry loop
      intree->GetEntry(iEntry);

      hSample[iSamp]->Fill(tauDecayCat1);

    } // end entry loop
    delete infile;
    infile=0, intree=0;

  } // end sample loop

  char pname[100];
  char xlabel[100];
  char ylabel[100];
  
  TCanvas *c = new TCanvas("c", "c", 800, 600);
  TLegend *leg = new TLegend(0.6, 0.7, 0.9, 0.9);
  leg->SetShadowColor(0);
  leg->SetFillColor(0);

  for (UInt_t iSamp=0; iSamp<nSamples; iSamp++) {

    sprintf(xlabel, "Tau Decay Cat");
    sprintf(ylabel, "Events");
    sprintf(pname, "taudecay_%s", sampleTitles[iSamp].Data());
    hSample[iSamp]->SetLineColor(sampleColors[iSamp]);
    leg->AddEntry(hSample[iSamp], sampleTitles[iSamp],"l");

    if (iSamp==0) {
      hSample[iSamp]->GetXaxis()->SetTitle(xlabel);
      hSample[iSamp]->GetYaxis()->SetTitle(ylabel);
      hSample[iSamp]->Draw();
    }
    else {
      if (hSample[iSamp]->GetMaximum() > hSample[0]->GetMaximum()) hSample[0]->GetYaxis()->SetRangeUser(0,hSample[iSamp]->GetMaximum()*1.2);
      hSample[iSamp]->Draw("same");
    }
  }
  leg->Draw();
}
void plotTreeNorms(TTree *tree_, std::string selectString, bool do7TeV){

	// Create a map for plotting the pullsummaries:
	std::map < const char*, std::pair <double,double> > pullSummaryMap;
	int nPulls=0;

	TObjArray *l_branches = tree_->GetListOfBranches();
	int nBranches = l_branches->GetEntries();

	gStyle->SetPadTopMargin(0.01);

	TCanvas *c = new TCanvas("c","",960,800);

	std::string treename = tree_->GetName();
	c->SaveAs(Form("%s_normresiduals.pdf[",treename.c_str()));
	// File to store plots in 
	TFile *fOut = new TFile(Form("%s_normresiduals.root",treename.c_str()),"RECREATE");

        TH1F *bHd = new TH1F("bHd","",50,-1.0,1.0);
        TH1F *bHfd = new TH1F("bHfd","",50,-1.0,1.0);

	for (int iobj=0;iobj<nBranches;iobj++){

		TBranch *br =(TBranch*) l_branches->At(iobj);

		// Draw the normal histogram
		const char* name = br->GetName();

                // select only the normalizations
                string namestr(name);
                if(namestr.find("n_exp")==string::npos) continue;

                bool fitPull=true;
                bool fitPullf=true;

		double p_mean =0;

		int nToysInTree = tree_->GetEntries();
		// Find out if paramter is fitted value or constraint term.
                bool isFitted = true;
			
                p_mean = prenorms_[name].first;	// toy initial parameters from the datacards
                std::cout << "******* "<< name << " *******"<<std::endl;
                std::cout << p_mean << std::endl;
                std::cout << "******************************" <<std::endl;

                TH1F* bH = (TH1F*)bHd->Clone(Form("%s",name));
                TH1F* bHf = (TH1F*)bHfd->Clone(Form("%s_fail",name));
                
                const char* drawInput = Form("(%s-%f)/%f",name,p_mean,p_mean);
                tree_->Draw(Form("%s>>%s",drawInput,name),"");
                tree_->Draw(Form("%s>>%s_fail",drawInput,name),selectString.c_str(),"same");
                fitPull  = true;
                fitPullf = true;
                  
		bHf->SetLineColor(2);
		bH->GetXaxis()->SetTitle(bH->GetTitle());
		bH->GetYaxis()->SetTitle(Form("no toys (%d total)",nToysInTree));
		bH->GetYaxis()->SetTitleOffset(1.05);
		bH->GetXaxis()->SetTitleOffset(0.9);
		bH->GetYaxis()->SetTitleSize(0.05);
		bH->GetXaxis()->SetTitleSize(0.05);
		bH->GetXaxis()->SetTitle(Form("%s",name));
                
		
		bH->SetTitle("");	

		if ( bH->Integral() <=0 )  fitPull = false;
		if (fitPull) {bH->Fit("gaus"); bH->GetFunction("gaus")->SetLineColor(4);}
		
		if ( bHf->Integral() <=0 )  fitPullf = false;
		if (fitPullf) {bHf->Fit("gaus"); bHf->GetFunction("gaus")->SetLineColor(2);}

		c->Clear();
		
 		TPad pad1("t1","",0.01,0.01,0.66,0.95);
 		TPad pad2("t2","",0.70,0.20,0.98,0.80);

		pad1.SetNumber(1); pad2.SetNumber(2);

                if ( isFitted ) {pad2.Draw();}

		pad1.Draw();
		pad1.SetGrid(true);


		TLatex *titletext = new TLatex();titletext->SetNDC();

		
		c->cd(1); bH->Draw(); bHf->Draw("same");
		TLegend *legend = new TLegend(0.6,0.8,0.9,0.89);
		legend->SetFillColor(0);
		legend->AddEntry(bH,"All Toys","L");
		legend->AddEntry(bHf,selectString.c_str(),"L");
		legend->Draw();

		if (fitPull){
			c->cd(2);
			double gap;
			TLatex *tlatex = new TLatex(); tlatex->SetNDC(); 
			if (fitPullf) {tlatex->SetTextSize(0.09); gap=0.12;}
			else  {tlatex->SetTextSize(0.11);gap=0.14;}

			tlatex->SetTextColor(4);
			tlatex->DrawLatex(0.11,0.80,Form("Mean    : %.3f #pm %.3f",bH->GetFunction("gaus")->GetParameter(1),bH->GetFunction("gaus")->GetParError(1)));
			tlatex->DrawLatex(0.11,0.80-gap,Form("Sigma   : %.3f #pm %.3f",bH->GetFunction("gaus")->GetParameter(2),bH->GetFunction("gaus")->GetParError(2)));

			if (fitPullf){ 
				tlatex->SetTextColor(2);
				tlatex->DrawLatex(0.11,0.60,Form("Mean    : %.3f #pm %.3f",bHf->GetFunction("gaus")->GetParameter(1),bHf->GetFunction("gaus")->GetParError(1)));
				tlatex->DrawLatex(0.11,0.60-gap,Form("Sigma   : %.3f #pm %.3f",bHf->GetFunction("gaus")->GetParameter(2),bHf->GetFunction("gaus")->GetParError(2)));
			}

			tlatex->SetTextSize(0.10);
			tlatex->SetTextColor(1);
				
                        tlatex->DrawLatex(0.11,0.33,Form("Pre-fit: %.3f",p_mean));
			
			pullSummaryMap[name]=std::make_pair<double,double>(bH->GetFunction("gaus")->GetParameter(1),bH->GetFunction("gaus")->GetParameter(2));
			nPulls++;

		}

		// double titleSize = isFitted ? 0.1 : 0.028;
		//titletext->SetTextSize(titleSize);titletext->SetTextAlign(21); titletext->DrawLatex(0.55,0.92,name);
		c->SaveAs(Form("%s_normresiduals_%s.pdf",treename.c_str(),(do7TeV ? "7TeV": "8TeV")));
                c->SaveAs(Form("mlfit/%s_residual_%s_%s.pdf",name,treename.c_str(),(do7TeV ? "7TeV": "8TeV")));
		fOut->WriteObject(c,Form("%s_%s",treename.c_str(),name));
	}
	
	if (nPulls>0){
	  
	    std::cout << "Generating Pull Summaries" <<std::endl; 
	    int nRemainingPulls = nPulls;
	    TCanvas *hc = new TCanvas("hc","",3000,2000); hc->SetGrid(0);
	    std::map < const char*, std::pair <double,double> >::iterator pull_it = pullSummaryMap.begin();
	    std::map < const char*, std::pair <double,double> >::iterator pull_end = pullSummaryMap.end();

	    int pullPlots = 1;
	    while (nRemainingPulls > 0){

		int nThisPulls = min(maxPullsPerPlot,nRemainingPulls);

		TH1F pullSummaryHist("pullSummary","",nThisPulls,0,nThisPulls);
		for (int pi=1;pull_it!=pull_end && pi<=nThisPulls ;pull_it++,pi++){
			pullSummaryHist.GetXaxis()->SetBinLabel(pi,(*pull_it).first);
			pullSummaryHist.SetBinContent(pi,((*pull_it).second).first);
			pullSummaryHist.SetBinError(pi,((*pull_it).second).second);
			nRemainingPulls--;
		}		

		pullSummaryHist.SetMarkerStyle(21);pullSummaryHist.SetMarkerSize(1.5);pullSummaryHist.SetMarkerColor(2);pullSummaryHist.SetLabelSize(pullLabelSize);
		pullSummaryHist.GetYaxis()->SetRangeUser(-1,1);pullSummaryHist.GetYaxis()->SetTitle("residual summary (relative)");pullSummaryHist.Draw("E1");
		hc->SaveAs(Form("%s_normresiduals_%s.pdf",treename.c_str(),(do7TeV ? "7TeV": "8TeV")));
                hc->SaveAs(Form("mlfit/residual_summary_%d_%s_%s.pdf",pullPlots,treename.c_str(),(do7TeV ? "7TeV": "8TeV")));
		fOut->WriteObject(hc,Form("comb_pulls_%s_%d",treename.c_str(),pullPlots));
	//	hc->SaveAs(Form("comb_pulls_%s_%d.pdf",treename.c_str(),pullPlots));
		pullPlots++;
	   }

	    delete hc;
	}

	c->SaveAs(Form("%s_normresiduals_%s.pdf]",treename.c_str(),(do7TeV ? "7TeV": "8TeV")));
	fOut->Close();
	delete c;
	return;


}
Example #6
0
void SimplePlots(TString Cut="2btag", TString Channel="mujets"){
  gROOT->SetStyle("Plain");
  gStyle->SetOptStat(kFALSE);

  const int nh = 3;
  //TString namefile = "TopResults/hSF-EffCSVFull_Tree_LepJets_GenCone_v8-0-0_Spring16-80X_5913pb-1_ttbar_PowhegPythia";
  TString namefile = "TopResults/hSF-NuiPar-v0_Tree_LepJets_KFCSVOrder01NoSkim_v8-0-1_Spring16-80X_15920pb-1_ttbar_LepJetsPowhegPythiaTranche3FullPhSp";

  TFile *hFile=NULL;
  hFile = TFile::Open(namefile + ".root");

  if(!hFile){
    std::cerr << "ERROR: Could not open " <<  namefile  << " files!!!"  << std::endl;
    std::exit(0);
  }

  TH1F *histo[nh];
  // TEfficiency *histo[nh];
  TString histoname[nh] = {"hTJetPosition","hWJetPosition","hOJetPosition"};

  cout << "Loading: " << Cut + "/" + Channel + "/" + histoname[0] + "_" + Channel + "_" + Cut << endl;

  histo[0] = (TH1F*)hFile->Get(Cut + "/" + Channel + "/" + histoname[0] + "_" + Channel + "_" + Cut );
  histo[1] = (TH1F*)hFile->Get(Cut + "/" + Channel + "/" + histoname[1] + "_" + Channel + "_" + Cut );
  histo[2] = (TH1F*)hFile->Get(Cut + "/" + Channel + "/" + histoname[2] + "_" + Channel + "_" + Cut );
  //histo[0] = (TEfficiency*)hFile->Get(Cut + "/" + Channel + "/" + histoname[0] + "_" + Channel + "_" + Cut ) ->Clone(histoname[0] + Channel + Cut);

  TCanvas *histocanvas;
  histocanvas = new TCanvas("plots", "Plots");

  histocanvas->SetGrid();
  histocanvas->cd();

  for (int ih=0; ih<3; ih++){
    float Nhisto = histo[ih]->Integral();
    if(Nhisto!=0.0) histo[ih]->Scale(1.0/Nhisto);
  }
  histo[0]->SetTitle("CSV Jet Positions");
  histo[0]->SetMarkerStyle(20);
  histo[0]->SetMarkerColor(4);
  histo[0]->SetLineColor(4);
  histo[0]->Draw();

  histo[1]->SetMarkerStyle(21);
  histo[1]->SetMarkerColor(2);
  histo[1]->SetLineColor(2);
  histo[1]->Draw("SAME");

  histo[2]->SetMarkerStyle(22);
  histo[2]->SetMarkerColor(kGreen-2);
  histo[2]->SetLineColor(kGreen-2);
  histo[2]->Draw("SAME");

  TLegend *leg;
  leg = new TLegend(0.70, 0.64,
		     0.93, 0.87);
  leg->AddEntry(histo[0],"Jets From Top",   "LP");
  leg->AddEntry(histo[1],"Jets From W",     "LP");
  leg->AddEntry(histo[2],"Additional Jets", "LP");
  leg->Draw("SAME");

  histocanvas->SaveAs(TString(histo[0]->GetName()) + ".pdf");

}
Example #7
0
void DrawBoosted(TString VAR, float XMIN, float XMAX, int REBIN, TString XTITLE)
{
  gROOT->ForceStyle();
  const int N = 7;
  float XSEC[N] = {1.74e+6,3.67e+5,2.94e+4,6.524e+03,1.064e+03,121.5,2.542e+01};

  TString SAMPLE[N] = {
    "QCD_HT200to300",
    "QCD_HT300to500",
    "QCD_HT500to700", 
    "QCD_HT700to1000",
    "QCD_HT1000to1500",
    "QCD_HT1500to2000",
    "QCD_HT2000toInf" 
  };
 
  TFile *inf[N];
  TH1F  *h0[N],*h1[N];
  TH1F  *hQCD0,*hQCD1; 

  TCanvas *can = new TCanvas("Boosted","Boosted",900,600);
  can->cd(1);
  can->SetBottomMargin(0.3);
  //can->SetRightMargin(0.15);
  for(int k=0;k<N;k++) {
    inf[k] = TFile::Open("Histo_"+SAMPLE[k]+".root");
    h0[k]  = (TH1F*)inf[k]->Get("hadtopBoost/h_"+VAR+"_Cut_ctl");
    h0[k]->Sumw2();
    h0[k]->Rebin(REBIN);
    h1[k]  = (TH1F*)inf[k]->Get("hadtopBoost/h_"+VAR+"_Cut_sig");
    h1[k]->Sumw2();
    h1[k]->Rebin(REBIN);
    h0[k]->Scale(XSEC[k]/((TH1F*)inf[k]->Get("hadtopBoost/TriggerPass"))->GetBinContent(1));
    h1[k]->Scale(XSEC[k]/((TH1F*)inf[k]->Get("hadtopBoost/TriggerPass"))->GetBinContent(1)); 
    cout<<SAMPLE[k]<<": "<<h0[k]->GetEntries()<<" "<<h0[k]->Integral()<<endl;
    if (k == 0) {
      hQCD0 = (TH1F*)h0[k]->Clone();
      hQCD1 = (TH1F*)h1[k]->Clone();
    }
    if (k > 0) {
      hQCD0->Add(h0[k]);
      hQCD1->Add(h1[k]);
    }
  } 
  hQCD0->Scale(1/hQCD0->Integral());
  hQCD1->Scale(1/hQCD1->Integral());
  double max1 = TMath::Max(hQCD0->GetBinContent(hQCD0->GetMaximumBin()),hQCD1->GetBinContent(hQCD1->GetMaximumBin()));
  hQCD0->SetMaximum(1.2*max1);
  hQCD0->SetMinimum(1e-4);
  hQCD0->GetXaxis()->SetLabelSize(0.0);
  hQCD0->GetXaxis()->SetRangeUser(XMIN,XMAX); 
  hQCD0->Draw("HIST");
  hQCD1->Draw("sameE");

  TLegend *leg = new TLegend(0.6,0.7,0.9,0.9);
  leg->SetHeader("QCD Closure");
  leg->SetBorderSize(0);
  leg->SetTextFont(42);
  leg->SetTextSize(0.05);
  leg->AddEntry(hQCD1,"Signal sample","P");
  leg->AddEntry(hQCD0,"Control sample","F");
  leg->Draw();

  TH1F *hRatio = (TH1F*)hQCD1->Clone("Ratio");
  hRatio->Divide(hQCD0);

  hRatio->SetLineColor(kBlack);
  hRatio->SetMarkerColor(kBlack);

  TPad* pad = new TPad("pad", "pad", 0., 0., 1., 1.);
  pad->SetTopMargin(0.7);
  //pad->SetRightMargin(0.15);
  pad->SetFillColor(0);
  pad->SetFillStyle(0);
  pad->Draw();
  pad->cd(0);
  gPad->SetGridy();
  hRatio->GetXaxis()->SetTitle(XTITLE);
  hRatio->GetXaxis()->SetRangeUser(XMIN,XMAX); 
  hRatio->GetYaxis()->SetNdivisions(505);
  hRatio->GetYaxis()->SetRangeUser(0,2);
  hRatio->GetYaxis()->SetLabelSize(0.04);
  hRatio->Draw();
  hRatio->Draw("same");
}
Example #8
0
void plotvn(){
    gStyle->SetOptStat(kFALSE);
    int icent = 0;
    int n = 3;
    int color[6] = {1,2,4,7,8,5};
    int style[12] = {20,21,24,25,26,27,29,30,31,32,33,34};
    TGraphErrors *gr[nsub][3][2];
    TGraphErrors *grraw[nsub][3][2];
    TString CNTEP, dire;
    for(int isub=0;isub<nsub;isub++){
    for(int idire=0;idire<3;idire++){
    for(int iCNTEP=0;iCNTEP<1;iCNTEP++){
        if(iCNTEP==0) CNTEP = "NoUseCNTEP";
        if(iCNTEP==1) CNTEP = "UseCNTEP";
        if(idire==0) dire = "";
        if(idire==1) dire = "_east";
        if(idire==2) dire = "_west";
        TString str = choosesub(isub);
        if(str=="ABORT") continue;
        gr[isub][idire][iCNTEP] = new TGraphErrors(Form("Result/%s/v%d_00_%d%s_%s.dat",CNTEP.Data(),n,icent,dire.Data(),str.Data()),"%lg %lg %lg");
        grraw[isub][idire][iCNTEP] = new TGraphErrors(Form("Result/%s/v%draw_00_%d%s_%s.dat",CNTEP.Data(),n,icent,dire.Data(),str.Data()),"%lg %lg %lg");
        SetStyle(*gr[isub][idire][iCNTEP], 1.2, color[idire+3*iCNTEP],style[isub]);
        SetStyle(*grraw[isub][idire][iCNTEP], 1.2, color[idire+3*iCNTEP],style[isub]);
    }
    }
    }
TH1F* h = new TH1F("h","",50,0,5);
h->GetXaxis()->SetRangeUser(0,3.2);
/*
TCanvas *c1 = new TCanvas("c1","c1",800,450);
iCNTEP = 0;
idire = 0;
c1->Divide(2);
c1->cd(1);
h->SetMinimum(0);
h->SetMaximum(0.3);
h->GetXaxis()->SetRangeUser(0,3.2);
//SetTitle(h,"","p_{T}","v_{2}^{raw}");
SetTitle(h,"","p_{T}","v_{2}");
h->DrawCopy();
TLegend *leg = new TLegend(0.2,0.7,0.5,0.9);
leg->SetFillColor(0);
leg->SetBorderSize(0);
for(int ilay = 0;ilay<4;ilay++){
leg->AddEntry(gr[ilay+8][idire][iCNTEP],Form("FVTX layer %d",ilay));
gr[ilay+8][idire][iCNTEP]->Draw("Psame");
}
gr[6][0][1]->Draw("Psame");
leg->AddEntry(gr[6][idire][iCNTEP],Form("FVTX -3.0<#eta<-1.0"));
leg->Draw("Psame");

c1->cd(2);
h->SetMinimum(0.8);
h->SetMaximum(1.2);
SetTitle(h,"","p_{T}","v_{2} ratio");
h->DrawCopy();
for(int ilay = 0;ilay<4;ilay++){
TGraphErrors *grr = (TGraphErrors*)DivideTwoGraphs(gr[ilay+8][idire][iCNTEP],gr[6][idire][iCNTEP]);
SetStyle(*grr,1.2,color[idire+3*iCNTEP],style[ilay+8]);
grr->Draw("Psame");
}
*/
TCanvas *c2 = new TCanvas("c2","c2",450,450);
iCNTEP = 0;
idire = 0;
//c2->Divide(2);
c2->cd(1);
if(n==1){
h->SetMinimum(-0.05);
h->SetMaximum(0.);
}
else if(n==2){
isub=5;
h->SetMinimum(0);
h->SetMaximum(0.3);
}
else if(n==3){
isub=6;
h->SetMinimum(-0.05);
h->SetMaximum(0.2);
}
//SetTitle(h,"","p_{T}","v_{2}^{raw}");
SetTitle(*h,"p_{T} (GeV/c)",Form("v_{%d}",n),"");
c2->SetLeftMargin(0.12);
h->GetXaxis()->CenterTitle();
h->GetYaxis()->CenterTitle();
h->GetYaxis()->SetTitleSize(0.06);
h->DrawCopy();
TLatex t;
t.SetNDC();
t.DrawLatex(0.6,0.82,"d+Au 62GeV");
TLegend *leg = new TLegend(0.2,0.7,0.5,0.88);
leg->SetFillColor(0);
leg->SetBorderSize(0);
leg->SetTextSize(0.04);
SetStyle(*gr[4][idire][iCNTEP], 1.2, 2,style[6]);
SetStyle(*gr[isub][idire][iCNTEP], 1.2, 4,style[6]);
gr[4][idire][iCNTEP]->Draw("Psame");
gr[isub][idire][iCNTEP]->Draw("Psame");
leg->AddEntry(gr[4][idire][iCNTEP],Form("BBCs"),"P");
leg->AddEntry(gr[isub][idire][iCNTEP],Form("FVTXs 1+2+3L -3.0<#eta<-1.0"),"P");
leg->Draw("Psame");
/*
c2->cd(2);
if(n==2){
h->SetMinimum(0.8);
h->SetMaximum(1.2);
}
if(n==3){
h->SetMinimum(0);
h->SetMaximum(2);
}
SetTitle(h,"","p_{T}","v_{2} ratio BBCs/FVTXs");
h->DrawCopy();
TGraphErrors *grr = (TGraphErrors*)DivideTwoGraphs(gr[4][idire][iCNTEP],gr[5][idire][iCNTEP]);
//SetStyle(*grr,1.2,color[idire+3*iCNTEP],style[2]);
grr->Draw("Psame");
*/
c2->Print(Form("v%d.png",n));
/*
TCanvas *c3 = new TCanvas("c3","c3",800,450);
idire = 0;
isub=5;
c3->Divide(2);
c3->cd(1);
h->SetMinimum(0);
h->SetMaximum(0.3);
//SetTitle(h,"","p_{T}","v_{2}^{raw}");
SetTitle(h,"","p_{T}","v_{2}");
h->DrawCopy();
TLegend *leg = new TLegend(0.2,0.7,0.5,0.9);
leg->SetFillColor(0);
leg->SetBorderSize(0);
gr[isub][idire][1]->Draw("Psame");
gr[isub][idire][0]->Draw("Psame");
leg->AddEntry(gr[isub][idire][1],Form("FVTXs -3.0<#eta<-1.0"));
leg->AddEntry(gr[isub][idire][1],Form("Using Psi EP"),"P");
leg->AddEntry(gr[isub][idire][0],Form("Using phi EP"),"P");
leg->Draw("Psame");

c3->cd(2);
h->SetMinimum(0.8);
h->SetMaximum(1.2);
SetTitle(h,"","p_{T}","v_{2} ratio FVTXs using phi EP/using Psi EP");
h->DrawCopy();
TGraphErrors *grr = (TGraphErrors*)DivideTwoGraphs(gr[isub][idire][0],gr[isub][idire][1]);
SetStyle(*grr,1.2,color[idire+3*0],style[isub]);
grr->Draw("Psame");
*/
TCanvas *c4 = new TCanvas("c4","c4",800,450);
isub=5;
iCNTEP = 0;
c4->Divide(2);
c4->cd(1);
if(n==1){
h->SetMinimum(-0.05);
h->SetMaximum(0.);
}
else if(n==2){
h->SetMinimum(0);
h->SetMaximum(0.3);
}
else if(n==3){
h->SetMinimum(-0.05);
h->SetMaximum(0.1);
}
SetTitle(h,"","p_{T}","v_{2}");
h->DrawCopy();
TLegend *leg = new TLegend(0.2,0.7,0.5,0.88);
leg->SetFillColor(0);
leg->SetBorderSize(0);
leg->SetTextSize(0.04);
gr[isub][0][iCNTEP]->Draw("Psame");
gr[isub][1][iCNTEP]->Draw("Psame");
gr[isub][2][iCNTEP]->Draw("Psame");
leg->AddEntry(gr[isub][0][iCNTEP],Form("FVTXs -3.0<#eta<-1.0"),"P");
leg->AddEntry(gr[isub][0][iCNTEP],Form("inclusive"),"P");
leg->AddEntry(gr[isub][1][iCNTEP],Form("East"),"P");
leg->AddEntry(gr[isub][2][iCNTEP],Form("West"),"P");
leg->Draw("Psame");

c4->cd(2);
h->SetMinimum(0.8);
h->SetMaximum(1.2);
SetTitle(h,"","p_{T}","v_{2} ratio FVTXs");
h->DrawCopy();
TGraphErrors *grr = (TGraphErrors*)DivideTwoGraphs(gr[isub][1][iCNTEP],gr[isub][0][iCNTEP]);
//SetStyle(*grr,1.2,color[1+3*iCNTEP],style[isub]);
grr->Draw("Psame");
TGraphErrors *grr = (TGraphErrors*)DivideTwoGraphs(gr[isub][2][iCNTEP],gr[isub][0][iCNTEP]);
//SetStyle(*grr,1.2,color[2+3*iCNTEP],style[isub]);
grr->Draw("Psame");
c4->Print(Form("v%dEWFVTX.png",n));

TCanvas *c5 = new TCanvas("c5","c5",800,450);
isub=4;
iCNTEP = 0;
c5->Divide(2);
c5->cd(1);
//SetTitle(h,"","p_{T}","v_{2}^{raw}");
if(n==1){
h->SetMinimum(-0.05);
h->SetMaximum(0.);
}
else if(n==2){
h->SetMinimum(0);
h->SetMaximum(0.3);
}
else if(n==3){
h->SetMinimum(-0.05);
h->SetMaximum(0.1);
}
SetTitle(h,"","p_{T}","v_{2}");
h->DrawCopy();
TLegend *leg = new TLegend(0.2,0.7,0.5,0.9);
leg->SetTextSize(0.05);
leg->SetFillColor(0);
leg->SetBorderSize(0);
gr[isub][0][iCNTEP]->Draw("Psame");
gr[isub][1][iCNTEP]->Draw("Psame");
gr[isub][2][iCNTEP]->Draw("Psame");
leg->AddEntry(gr[isub][0][iCNTEP],Form("Using BBC event plane"),"");
leg->AddEntry(gr[isub][0][iCNTEP],Form("inclusive"),"P");
leg->AddEntry(gr[isub][1][iCNTEP],Form("East"),"P");
leg->AddEntry(gr[isub][2][iCNTEP],Form("West"),"P");
leg->Draw("Psame");

c5->cd(2);
h->SetMinimum(0);
h->SetMaximum(2.);
SetTitle(h,"","p_{T}","v_{2} ratio");
h->DrawCopy();
TGraphErrors *grr = (TGraphErrors*)DivideTwoGraphs(gr[isub][1][iCNTEP],gr[isub][0][iCNTEP]);
//SetStyle(*grr,1.2,color[1+3*iCNTEP],style[isub]);
grr->Draw("Psame");
TGraphErrors *grr = (TGraphErrors*)DivideTwoGraphs(gr[isub][2][iCNTEP],gr[isub][0][iCNTEP]);
//SetStyle(*grr,1.2,color[2+3*iCNTEP],style[isub]);
grr->Draw("Psame");
c5->Print(Form("v%dEWBBC.png",n));

TCanvas *c6 = new TCanvas("c6","c6",800,450);
iCNTEP = 0;
c6->Divide(2);
c6->cd(1);
if(n==1){
h->SetMinimum(-0.05);
h->SetMaximum(0.);
}
else if(n==2){
h->SetMinimum(0);
h->SetMaximum(0.3);
}
else if(n==3){
h->SetMinimum(-0.05);
h->SetMaximum(0.1);
}
//SetTitle(h,"","p_{T}","v_{2}^{raw}");
SetTitle(h,"","p_{T}","v_{2}");
h->DrawCopy();
TLegend *leg = new TLegend(0.5,0.75,0.8,0.85);
leg->SetFillColor(0);
leg->SetBorderSize(0);
gr[0][0][iCNTEP]->Draw("Psame");
gr[1][0][iCNTEP]->Draw("Psame");
gr[2][0][iCNTEP]->Draw("Psame");
gr[3][0][iCNTEP]->Draw("Psame");
SetStyle(*gr[0][0][iCNTEP],1.2,color[0],style[0]);
SetStyle(*gr[0][1][iCNTEP],1.2,color[1],style[1]);
SetStyle(*gr[0][2][iCNTEP],1.2,color[2],style[2]);
SetStyle(*gr[0][3][iCNTEP],1.2,color[3],style[3]);
leg->AddEntry(gr[0][0][iCNTEP],Form("FVTX 1LS"),"P");
leg->AddEntry(gr[1][0][iCNTEP],Form("FVTX 2LS"),"P");
leg->AddEntry(gr[2][0][iCNTEP],Form("FVTX 3LS"),"P");
leg->AddEntry(gr[3][0][iCNTEP],Form("FVTX 4LS"),"P");
leg->Draw("same");

c6->cd(2);
if(n==2){
h->SetMinimum(0);
h->SetMaximum(2);
}
SetTitle(h,"","p_{T}","v_{2} ratio");
h->DrawCopy();
TGraphErrors *grr = (TGraphErrors*)DivideTwoGraphs(gr[0][0][iCNTEP],gr[5][0][iCNTEP]);
//SetStyle(*grr,1.2,color[idire+3*iCNTEP],style[0]);
grr->Draw("Psame");
TGraphErrors *grr = (TGraphErrors*)DivideTwoGraphs(gr[1][0][iCNTEP],gr[5][0][iCNTEP]);
//SetStyle(*grr,1.2,color[idire+3*iCNTEP],style[1]);
grr->Draw("Psame");
TGraphErrors *grr = (TGraphErrors*)DivideTwoGraphs(gr[2][0][iCNTEP],gr[5][0][iCNTEP]);
//SetStyle(*grr,1.2,color[idire+3*iCNTEP],style[2]);
grr->Draw("Psame");
TGraphErrors *grr = (TGraphErrors*)DivideTwoGraphs(gr[3][0][iCNTEP],gr[5][0][iCNTEP]);
//SetStyle(*grr,1.2,color[idire+3*iCNTEP],style[3]);
grr->Draw("Psame");
c6->Print(Form("v%dLayers.png",n));
}
void PlotPtTresh2() {
	//  gROOT->ProcessLine(".L ./tdrstyle.C");
	//  setTDRStyle();
	Int_t r=1; 
	

	TFile *f1 = new TFile("histo_file_QCDPU50GEM2019.root");
	
	char  histo[40], histo1[40], histo2[40], histoDC[40];
	
	TH1F *hInitialBarrel = (TH1F*)f1->Get("hInitialBarrel"); 
	TH1F *hInitialEndcap = (TH1F*)f1->Get("hInitialEndcap"); 	
	
	TH1F *hPtBarrel = (TH1F*)f1->Get("hMuonPtFinal_Barrel"); 
	TH1F *hPtHE = (TH1F*)f1->Get("hMuonPtFinal_HE"); 
	TH1F *hPtFull = (TH1F*)f1->Get("hMuonPtFinal_Full"); 
	TH1F *hInitial = (TH1F*)f1->Get("entries_after_vertex"); 
	TH1F *hWP2012Pt = (TH1F*)f1->Get("hMuonPtWP2012"); 
	TH1F *h_HTot = (TH1F*)f1->Get("H_tot"); 
	TH1F *initial_entries = (TH1F*)f1->Get("initial_entries"); 
	
	cout<<"Htot"<<h_HTot->Integral()<<"  initial entries  "<<initial_entries->Integral()<<endl;
	
	int  Ninitial=hInitial->Integral();    
	cout<<" initial  "<<Ninitial<<endl;
	cout<<" initial  barrel "<<hInitialBarrel->Integral()<<endl;
	cout<<" initial endcap"<<hInitialEndcap->Integral()<<endl;
	
	cout<<" after muon barrel  "<<hPtBarrel->Integral()<<endl;
	cout<<" after muon HE  "<<hPtHE->Integral()<<endl;
	
	float MuonEff2012[1] =0;
	MuonEff2012[0]= hWP2012Pt->Integral()/hInitial->Integral();
	float Err_MuonEff2012[1];
	Err_MuonEff2012[0]=(TMath::Sqrt(Err_MuonEff2012[0]*(1-Err_MuonEff2012[0])))/Ninitial;
	//cout<<"Muon Eff WP 2012 "<<hWP2012Pt->Integral()/hInitial->Integral()<<endl;
	
	/////////////////////////compute selection eff as a function of muon pt threshold/////////////////////////////
	int EvAfterPtCut_HE[100]; float EffSel[100], xgr[100], ex[100],ey[100], EffSelFull[100], eyfull[100], Eff_Barrel[100], Eff_Endcap[100], err_Eff_barrel[100],err_Eff_endcap[100];
	int EvAfterPtCut_Barrel[100]; 
	int EvAfterPtCut[100];
	int EvAfterPtCut_BB[100];	
	int EvAfterPtCut_EE[100];	
	
	//  std::cout<<" Muon Pt in |eta|<2.4 "<<hMuonTot->Integral(0,200)<<endl;
	
	for(int i=0;i<40;i++){
		EvAfterPtCut_Barrel[i]=hPtBarrel->Integral(10,100);
		EvAfterPtCut_HE[i]=hPtHE->Integral(i+1,100);
		
		EvAfterPtCut[i]=hPtFull->Integral(i+1,100); 
		EvAfterPtCut_BB[i] =hPtBarrel->Integral(i+1,100);
		EvAfterPtCut_EE[i] =hPtHE->Integral(i+1,100);
		
		EffSelFull[i] = EvAfterPtCut[i] / (hInitialBarrel->Integral() + hInitialEndcap->Integral() );		
		Eff_Barrel[i]= EvAfterPtCut_BB[i]/hInitialBarrel->Integral();  
		Eff_Endcap[i]=EvAfterPtCut_EE[i]/hInitialEndcap->Integral();  
		
		std::cout<<i*2<<" nev after pt cut barrel "<<EvAfterPtCut_BB[i]<<"  nev after pt cut endcap  "<<EvAfterPtCut_HE[i]<<"  eff sel  "<<endl;
		
		xgr[i]=i*2;
		ex[i]=0; 
		EffSel[i]=(EvAfterPtCut_Barrel[i]+EvAfterPtCut_HE[i])/(hInitial->Integral());
		
		ey[i]=TMath::Sqrt((EffSel[i]*(1-EffSel[i])))/hInitial->Integral();
		eyfull[i]=TMath::Sqrt((EffSelFull[i]*(1-EffSelFull[i])))/hInitial->Integral();
		//  std::cout<<i*2<<" nev after pt cut barrel || endcap "<<EvAfterPtCut_Barrel[i]+EvAfterPtCut_HE[i]<<" eff sel  "<<EffSel[i]<<" errore "<<ey[i]<<endl;
	}
	
	double xgr12[1]; xgr12[0]=13.0; 
	double ex12[1]; ex12[0]=0.; 
	TGraphErrors* gr = new TGraphErrors(26,xgr,EffSel,ex,ey);
	TGraphErrors* gr_full = new TGraphErrors(26,xgr,EffSelFull,ex,eyfull);
	TGraph* gr12 = new TGraph(1);
	gr12->SetPoint(0,20,MuonEff2012[0]);
	
	TGraphErrors* gr_BB = new TGraphErrors(26,xgr,Eff_Barrel,ex,ey);	
	TGraphErrors* gr_EE = new TGraphErrors(26,xgr,Eff_Endcap,ex,ey);	
	
	///////////////////////////////////////////************************************////////////////////////////////////////////
	TCanvas *Canv5 = new TCanvas("Canv5","Palle",800,700);
	gr->SetMarkerStyle(24);  
	gr12->SetMarkerStyle(23); 
	gr->SetMarkerColor(kRed);  
	gr12->SetMarkerColor(kBlue);  
	gr->SetTitle(" Selection Efficiency as a function of muon pt threshold ");
	gr->GetYaxis()->SetTitle("Selection Efficiency");
	gr->GetYaxis()->SetTitleOffset(1.4);
	gr->GetXaxis()->SetTitle("P_{T}^{#mu Endcap} Cut (GeV/c)");
	
	gr->SetMarkerSize(1.2);  
	gr12->SetMarkerSize(1.4); 
	
	gr->Draw("ACP");
	gr12->Draw("CP");
	gr->SetMinimum(0.5);
	TLegend* legend = new TLegend( 0.15, 0.5, 0.75, 0.7);
	legend->SetTextSize(0.025);
	legend->SetFillColor(0);
	legend->AddEntry(gr, "PU=50 wGEM (P_{T}^{#mu, barrel}>20, |#eta|<2.1)","p");
	legend->AddEntry(gr12, "PU=50 wGEM 2012 WP  (P_{T}^{#mu Full Accept}>24,|#eta|<2.1)","p");
	Canv5->cd();
	legend->Draw("same");
	Canv5->SaveAs("WHPtTresh.pdf");
	
	///////////////////////////////////////////************************************////////////////////////////////////////////
	
	TCanvas *Canv6 = new TCanvas("Canv6","StraPalle",800,700);
	gr_full->SetMarkerStyle(24);  
	gr_full->SetMarkerColor(kBlue);
	
	gr_BB->SetMarkerStyle(24);  
	gr_EE->SetMarkerStyle(24);  
	
	gr_BB->SetMarkerColor(kGreen);  
	gr_EE->SetMarkerColor(kMagenta);  
	
	gr_full->SetTitle(" Selection Efficiency as a function of muon pt threshold ");
	gr_full->GetYaxis()->SetTitle("Selection Efficiency");
	gr_full->GetYaxis()->SetTitleOffset(1.4);
	gr_full->GetXaxis()->SetTitle("P_{T}^{#mu Endcap} Cut (GeV/c)");
	gr_BB->Draw("ACP");
	gr_full->Draw("CP");
//	gr_BB->Draw("CP");
	gr_EE->Draw("CP");
	//gr12->Draw("CP");
	//gr_full->SetMinimum(0.1);
	gr_BB->SetMinimum(0.);
	gr_BB->SetMaximum(0.001);
	gPad->SetGrid();
	gPad->Update();
	
	TLegend* legend = new TLegend( 0.65, 0.7, 0.85, 0.9);
	legend->SetTextSize(0.025);
	legend->SetFillColor(0);
	legend->AddEntry(gr_full, "full acceptance","p");
	legend->AddEntry(gr_BB, "|#eta|<1.6","p");
	legend->AddEntry(gr_EE, "1.6<|#eta|<2.1","p");
	Canv6->cd();
	legend->Draw("same");
	Canv6->SaveAs("QCD_threshold_fullAcc.pdf");
	
	
}
void METJetsb3()
{
//=========Macro generated from canvas: b3/METJetsb3/b3/METJetsb3
//=========  (Tue Nov 24 14:23:54 2015) by ROOT version6.02/05
   TCanvas *b3/METJetsb3 = new TCanvas("b3/METJetsb3", "b3/METJetsb3",20,42,700,700);
   b3/METJetsb3->Range(-1.875,-5.87466,16.875,-0.2969325);
   b3/METJetsb3->SetFillColor(0);
   b3/METJetsb3->SetBorderMode(0);
   b3/METJetsb3->SetBorderSize(2);
   b3/METJetsb3->SetLogy();
   b3/METJetsb3->SetFrameBorderMode(0);
   b3/METJetsb3->SetFrameBorderMode(0);
   
   THStack *b3/METJetsb3 = new THStack();
   b3/METJetsb3->SetName("b3/METJetsb3");
   b3/METJetsb3->SetTitle("b3/METJetsb3");
   
   TH1F *b3/METJetsb3_stack_2 = new TH1F("b3/METJetsb3_stack_2","b3/METJetsb3",15,0,15);
   b3/METJetsb3_stack_2->SetMinimum(4.820734e-06);
   b3/METJetsb3_stack_2->SetMaximum(0.1397317);
   b3/METJetsb3_stack_2->SetDirectory(0);
   b3/METJetsb3_stack_2->SetStats(0);

   Int_t ci;      // for color index setting
   TColor *color; // for color definition with alpha
   ci = TColor::GetColor("#000099");
   b3/METJetsb3_stack_2->SetLineColor(ci);
   b3/METJetsb3_stack_2->GetXaxis()->SetTitle("b3/METJetsb3");
   b3/METJetsb3_stack_2->GetXaxis()->SetLabelFont(42);
   b3/METJetsb3_stack_2->GetXaxis()->SetLabelSize(0.035);
   b3/METJetsb3_stack_2->GetXaxis()->SetTitleSize(0.035);
   b3/METJetsb3_stack_2->GetXaxis()->SetTitleFont(42);
   b3/METJetsb3_stack_2->GetYaxis()->SetTitle("Events/pb");
   b3/METJetsb3_stack_2->GetYaxis()->SetLabelFont(42);
   b3/METJetsb3_stack_2->GetYaxis()->SetLabelSize(0.035);
   b3/METJetsb3_stack_2->GetYaxis()->SetTitleSize(0.035);
   b3/METJetsb3_stack_2->GetYaxis()->SetTitleFont(42);
   b3/METJetsb3_stack_2->GetZaxis()->SetLabelFont(42);
   b3/METJetsb3_stack_2->GetZaxis()->SetLabelSize(0.035);
   b3/METJetsb3_stack_2->GetZaxis()->SetTitleSize(0.035);
   b3/METJetsb3_stack_2->GetZaxis()->SetTitleFont(42);
   b3/METJetsb3->SetHistogram(b3/METJetsb3_stack_2);
   
   
   TH1D *METJetsb36 = new TH1D("METJetsb36"," Number of jets in MET hemisphere",15,0,15);
   METJetsb36->SetBinContent(4,0.01580636);
   METJetsb36->SetBinContent(5,0.01716774);
   METJetsb36->SetBinContent(6,0.03857011);
   METJetsb36->SetBinContent(7,0.02397464);
   METJetsb36->SetBinContent(8,0.05573785);
   METJetsb36->SetBinContent(9,0.0198905);
   METJetsb36->SetBinContent(10,0.01852912);
   METJetsb36->SetBinContent(11,0.01648705);
   METJetsb36->SetBinContent(12,0.0068069);
   METJetsb36->SetBinContent(13,0.00272276);
   METJetsb36->SetBinContent(14,0.00136138);
   METJetsb36->SetBinError(4,0.008619667);
   METJetsb36->SetBinError(5,0.008673255);
   METJetsb36->SetBinError(6,0.01472659);
   METJetsb36->SetBinError(7,0.008936371);
   METJetsb36->SetBinError(8,0.01709087);
   METJetsb36->SetBinError(9,0.008779448);
   METJetsb36->SetBinError(10,0.008726513);
   METJetsb36->SetBinError(11,0.008646503);
   METJetsb36->SetBinError(12,0.002152531);
   METJetsb36->SetBinError(13,0.00136138);
   METJetsb36->SetBinError(14,0.000962641);
   METJetsb36->SetEntries(173);

   ci = TColor::GetColor("#00cc00");
   METJetsb36->SetFillColor(ci);

   ci = TColor::GetColor("#00cc00");
   METJetsb36->SetLineColor(ci);

   ci = TColor::GetColor("#00cc00");
   METJetsb36->SetMarkerColor(ci);
   METJetsb36->SetMarkerStyle(22);
   METJetsb36->GetXaxis()->SetTitle("METJetsb3");
   METJetsb36->GetXaxis()->SetLabelFont(42);
   METJetsb36->GetXaxis()->SetLabelSize(0.035);
   METJetsb36->GetXaxis()->SetTitleSize(0.035);
   METJetsb36->GetXaxis()->SetTitleFont(42);
   METJetsb36->GetYaxis()->SetTitle("Events/pb");
   METJetsb36->GetYaxis()->SetLabelFont(42);
   METJetsb36->GetYaxis()->SetLabelSize(0.035);
   METJetsb36->GetYaxis()->SetTitleSize(0.035);
   METJetsb36->GetYaxis()->SetTitleFont(42);
   METJetsb36->GetZaxis()->SetLabelFont(42);
   METJetsb36->GetZaxis()->SetLabelSize(0.035);
   METJetsb36->GetZaxis()->SetTitleSize(0.035);
   METJetsb36->GetZaxis()->SetTitleFont(42);
   b3/METJetsb3->Add(METJetsb3,"");
   
   TH1D *METJetsb37 = new TH1D("METJetsb37"," Number of jets in MET hemisphere",15,0,15);
   METJetsb37->SetBinContent(2,0.002338485);
   METJetsb37->SetBinContent(3,0.01213548);
   METJetsb37->SetBinContent(4,0.03911485);
   METJetsb37->SetBinContent(5,0.05935342);
   METJetsb37->SetBinContent(6,0.07976154);
   METJetsb37->SetBinContent(7,0.07921214);
   METJetsb37->SetBinContent(8,0.07074378);
   METJetsb37->SetBinContent(9,0.05650522);
   METJetsb37->SetBinContent(10,0.03861221);
   METJetsb37->SetBinContent(11,0.02423331);
   METJetsb37->SetBinContent(12,0.01568092);
   METJetsb37->SetBinContent(13,0.007865999);
   METJetsb37->SetBinContent(14,0.004044566);
   METJetsb37->SetBinContent(15,0.002485602);
   METJetsb37->SetBinContent(16,0.001332737);
   METJetsb37->SetBinError(2,0.0004741848);
   METJetsb37->SetBinError(3,0.001070286);
   METJetsb37->SetBinError(4,0.001860397);
   METJetsb37->SetBinError(5,0.002122127);
   METJetsb37->SetBinError(6,0.00260765);
   METJetsb37->SetBinError(7,0.002484655);
   METJetsb37->SetBinError(8,0.00213964);
   METJetsb37->SetBinError(9,0.002290398);
   METJetsb37->SetBinError(10,0.001484044);
   METJetsb37->SetBinError(11,0.001122589);
   METJetsb37->SetBinError(12,0.0009340995);
   METJetsb37->SetBinError(13,0.0005900923);
   METJetsb37->SetBinError(14,0.000436201);
   METJetsb37->SetBinError(15,0.0003518751);
   METJetsb37->SetBinError(16,0.0001839227);
   METJetsb37->SetEntries(19755);

   ci = TColor::GetColor("#00ffff");
   METJetsb37->SetFillColor(ci);

   ci = TColor::GetColor("#00ffff");
   METJetsb37->SetLineColor(ci);

   ci = TColor::GetColor("#00ffff");
   METJetsb37->SetMarkerColor(ci);
   METJetsb37->SetMarkerStyle(20);
   METJetsb37->GetXaxis()->SetTitle("METJetsb3");
   METJetsb37->GetXaxis()->SetLabelFont(42);
   METJetsb37->GetXaxis()->SetLabelSize(0.035);
   METJetsb37->GetXaxis()->SetTitleSize(0.035);
   METJetsb37->GetXaxis()->SetTitleFont(42);
   METJetsb37->GetYaxis()->SetTitle("Events/pb");
   METJetsb37->GetYaxis()->SetLabelFont(42);
   METJetsb37->GetYaxis()->SetLabelSize(0.035);
   METJetsb37->GetYaxis()->SetTitleSize(0.035);
   METJetsb37->GetYaxis()->SetTitleFont(42);
   METJetsb37->GetZaxis()->SetLabelFont(42);
   METJetsb37->GetZaxis()->SetLabelSize(0.035);
   METJetsb37->GetZaxis()->SetTitleSize(0.035);
   METJetsb37->GetZaxis()->SetTitleFont(42);
   b3/METJetsb3->Add(METJetsb3,"");
   
   TH1D *METJetsb38 = new TH1D("METJetsb38"," Number of jets in MET hemisphere",15,0,15);
   METJetsb38->SetBinContent(2,0.0009177575);
   METJetsb38->SetBinContent(3,0.00576745);
   METJetsb38->SetBinContent(4,0.01292017);
   METJetsb38->SetBinContent(5,0.01880496);
   METJetsb38->SetBinContent(6,0.02087393);
   METJetsb38->SetBinContent(7,0.02034564);
   METJetsb38->SetBinContent(8,0.015766);
   METJetsb38->SetBinContent(9,0.01107381);
   METJetsb38->SetBinContent(10,0.008173232);
   METJetsb38->SetBinContent(11,0.005028661);
   METJetsb38->SetBinContent(12,0.002473002);
   METJetsb38->SetBinContent(13,0.001381076);
   METJetsb38->SetBinContent(14,0.0007763309);
   METJetsb38->SetBinContent(15,0.0003814013);
   METJetsb38->SetBinContent(16,0.0002253684);
   METJetsb38->SetBinError(2,0.000129842);
   METJetsb38->SetBinError(3,0.0003288236);
   METJetsb38->SetBinError(4,0.000503543);
   METJetsb38->SetBinError(5,0.0005596204);
   METJetsb38->SetBinError(6,0.0005627736);
   METJetsb38->SetBinError(7,0.000546037);
   METJetsb38->SetBinError(8,0.0004419707);
   METJetsb38->SetBinError(9,0.0003442228);
   METJetsb38->SetBinError(10,0.0003222388);
   METJetsb38->SetBinError(11,0.0002385337);
   METJetsb38->SetBinError(12,0.0001445456);
   METJetsb38->SetBinError(13,0.0001153007);
   METJetsb38->SetBinError(14,9.079403e-05);
   METJetsb38->SetBinError(15,5.475103e-05);
   METJetsb38->SetBinError(16,2.085404e-05);
   METJetsb38->SetEntries(37083);

   ci = TColor::GetColor("#ffcc00");
   METJetsb38->SetFillColor(ci);

   ci = TColor::GetColor("#ffcc00");
   METJetsb38->SetLineColor(ci);

   ci = TColor::GetColor("#ffcc00");
   METJetsb38->SetMarkerColor(ci);
   METJetsb38->SetMarkerStyle(21);
   METJetsb38->GetXaxis()->SetTitle("METJetsb3");
   METJetsb38->GetXaxis()->SetLabelFont(42);
   METJetsb38->GetXaxis()->SetLabelSize(0.035);
   METJetsb38->GetXaxis()->SetTitleSize(0.035);
   METJetsb38->GetXaxis()->SetTitleFont(42);
   METJetsb38->GetYaxis()->SetTitle("Events/pb");
   METJetsb38->GetYaxis()->SetLabelFont(42);
   METJetsb38->GetYaxis()->SetLabelSize(0.035);
   METJetsb38->GetYaxis()->SetTitleSize(0.035);
   METJetsb38->GetYaxis()->SetTitleFont(42);
   METJetsb38->GetZaxis()->SetLabelFont(42);
   METJetsb38->GetZaxis()->SetLabelSize(0.035);
   METJetsb38->GetZaxis()->SetTitleSize(0.035);
   METJetsb38->GetZaxis()->SetTitleFont(42);
   b3/METJetsb3->Add(METJetsb3,"");
   
   TH1D *METJetsb39 = new TH1D("METJetsb39"," Number of jets in MET hemisphere",15,0,15);
   METJetsb39->SetBinContent(2,1.542458e-05);
   METJetsb39->SetBinContent(3,0.0002467932);
   METJetsb39->SetBinContent(4,0.0007866534);
   METJetsb39->SetBinContent(5,0.001635005);
   METJetsb39->SetBinContent(6,0.002868971);
   METJetsb39->SetBinContent(7,0.003717323);
   METJetsb39->SetBinContent(8,0.003485954);
   METJetsb39->SetBinContent(9,0.003007792);
   METJetsb39->SetBinContent(10,0.00289982);
   METJetsb39->SetBinContent(11,0.002051469);
   METJetsb39->SetBinContent(12,0.001496184);
   METJetsb39->SetBinContent(13,0.0008329271);
   METJetsb39->SetBinContent(14,0.0007095305);
   METJetsb39->SetBinContent(15,0.0002930669);
   METJetsb39->SetBinContent(16,0.0003701898);
   METJetsb39->SetBinError(2,1.542458e-05);
   METJetsb39->SetBinError(3,6.16983e-05);
   METJetsb39->SetBinError(4,0.0001101535);
   METJetsb39->SetBinError(5,0.0001588057);
   METJetsb39->SetBinError(6,0.0002103632);
   METJetsb39->SetBinError(7,0.0002394538);
   METJetsb39->SetBinError(8,0.0002318822);
   METJetsb39->SetBinError(9,0.0002153925);
   METJetsb39->SetBinError(10,0.0002114911);
   METJetsb39->SetBinError(11,0.0001778849);
   METJetsb39->SetBinError(12,0.0001519145);
   METJetsb39->SetBinError(13,0.000113347);
   METJetsb39->SetBinError(14,0.0001046146);
   METJetsb39->SetBinError(15,6.723417e-05);
   METJetsb39->SetBinError(16,7.556468e-05);
   METJetsb39->SetEntries(1583);

   ci = TColor::GetColor("#ff0000");
   METJetsb39->SetFillColor(ci);

   ci = TColor::GetColor("#ff0000");
   METJetsb39->SetLineColor(ci);

   ci = TColor::GetColor("#ff0000");
   METJetsb39->SetMarkerColor(ci);
   METJetsb39->SetMarkerStyle(20);
   METJetsb39->GetXaxis()->SetTitle("METJetsb3");
   METJetsb39->GetXaxis()->SetLabelFont(42);
   METJetsb39->GetXaxis()->SetLabelSize(0.035);
   METJetsb39->GetXaxis()->SetTitleSize(0.035);
   METJetsb39->GetXaxis()->SetTitleFont(42);
   METJetsb39->GetYaxis()->SetTitle("Events/pb");
   METJetsb39->GetYaxis()->SetLabelFont(42);
   METJetsb39->GetYaxis()->SetLabelSize(0.035);
   METJetsb39->GetYaxis()->SetTitleSize(0.035);
   METJetsb39->GetYaxis()->SetTitleFont(42);
   METJetsb39->GetZaxis()->SetLabelFont(42);
   METJetsb39->GetZaxis()->SetLabelSize(0.035);
   METJetsb39->GetZaxis()->SetTitleSize(0.035);
   METJetsb39->GetZaxis()->SetTitleFont(42);
   b3/METJetsb3->Add(METJetsb3,"");
   
   TH1D *METJetsb310 = new TH1D("METJetsb310"," Number of jets in MET hemisphere",15,0,15);
   METJetsb310->SetBinContent(5,1.677165e-05);
   METJetsb310->SetBinContent(6,8.385824e-05);
   METJetsb310->SetBinContent(7,0.0002348031);
   METJetsb310->SetBinContent(8,0.0001341732);
   METJetsb310->SetBinContent(9,0.0002683464);
   METJetsb310->SetBinContent(10,0.0004025195);
   METJetsb310->SetBinContent(11,0.0003018897);
   METJetsb310->SetBinContent(12,0.0002012598);
   METJetsb310->SetBinContent(13,0.0002683464);
   METJetsb310->SetBinContent(14,0.0001174015);
   METJetsb310->SetBinContent(15,8.385824e-05);
   METJetsb310->SetBinContent(16,0.0001006299);
   METJetsb310->SetBinError(5,1.677165e-05);
   METJetsb310->SetBinError(6,3.750254e-05);
   METJetsb310->SetBinError(7,6.275376e-05);
   METJetsb310->SetBinError(8,4.743738e-05);
   METJetsb310->SetBinError(9,6.708659e-05);
   METJetsb310->SetBinError(10,8.216396e-05);
   METJetsb310->SetBinError(11,7.115607e-05);
   METJetsb310->SetBinError(12,5.809869e-05);
   METJetsb310->SetBinError(13,6.708659e-05);
   METJetsb310->SetBinError(14,4.437361e-05);
   METJetsb310->SetBinError(15,3.750254e-05);
   METJetsb310->SetBinError(16,4.108198e-05);
   METJetsb310->SetEntries(132);

   ci = TColor::GetColor("#0000ff");
   METJetsb310->SetFillColor(ci);

   ci = TColor::GetColor("#0000ff");
   METJetsb310->SetLineColor(ci);

   ci = TColor::GetColor("#0000ff");
   METJetsb310->SetMarkerColor(ci);
   METJetsb310->SetMarkerStyle(21);
   METJetsb310->GetXaxis()->SetTitle("METJetsb3");
   METJetsb310->GetXaxis()->SetLabelFont(42);
   METJetsb310->GetXaxis()->SetLabelSize(0.035);
   METJetsb310->GetXaxis()->SetTitleSize(0.035);
   METJetsb310->GetXaxis()->SetTitleFont(42);
   METJetsb310->GetYaxis()->SetTitle("Events/pb");
   METJetsb310->GetYaxis()->SetLabelFont(42);
   METJetsb310->GetYaxis()->SetLabelSize(0.035);
   METJetsb310->GetYaxis()->SetTitleSize(0.035);
   METJetsb310->GetYaxis()->SetTitleFont(42);
   METJetsb310->GetZaxis()->SetLabelFont(42);
   METJetsb310->GetZaxis()->SetLabelSize(0.035);
   METJetsb310->GetZaxis()->SetTitleSize(0.035);
   METJetsb310->GetZaxis()->SetTitleFont(42);
   b3/METJetsb3->Add(METJetsb3,"");
   b3/METJetsb3->Draw("nostack");
   
   TPaveText *pt = new TPaveText(0.3218966,0.94,0.6781034,0.995,"blNDC");
   pt->SetName("title");
   pt->SetBorderSize(0);
   pt->SetFillColor(0);
   pt->SetFillStyle(0);
   pt->SetTextFont(42);
   TText *AText = pt->AddText("b3/METJetsb3");
   pt->Draw();
   
   TLegend *leg = new TLegend(0.54023,0.639881,0.938218,0.924107,NULL,"brNDC");
   leg->SetBorderSize(1);
   leg->SetTextSize(0.034965);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(1001);
   TLegendEntry *entry=leg->AddEntry("METJetsb3","b3/METJetsb3_QCD_b3/","lp");

   ci = TColor::GetColor("#00cc00");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);

   ci = TColor::GetColor("#00cc00");
   entry->SetMarkerColor(ci);
   entry->SetMarkerStyle(22);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("METJetsb3","b3/METJetsb3_WJetsToLNu_b3/","lp");

   ci = TColor::GetColor("#00ffff");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);

   ci = TColor::GetColor("#00ffff");
   entry->SetMarkerColor(ci);
   entry->SetMarkerStyle(20);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("METJetsb3","b3/METJetsb3_ZJetsToNuNu_b3/","lp");

   ci = TColor::GetColor("#ffcc00");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);

   ci = TColor::GetColor("#ffcc00");
   entry->SetMarkerColor(ci);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("METJetsb3","b3/METJetsb3_signal_b3/","lp");

   ci = TColor::GetColor("#ff0000");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);

   ci = TColor::GetColor("#ff0000");
   entry->SetMarkerColor(ci);
   entry->SetMarkerStyle(20);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("METJetsb3","b3/METJetsb3_ttbar_b3/","lp");

   ci = TColor::GetColor("#0000ff");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);

   ci = TColor::GetColor("#0000ff");
   entry->SetMarkerColor(ci);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   leg->Draw();
   b3/METJetsb3->Modified();
   b3/METJetsb3->cd();
   b3/METJetsb3->SetSelected(b3/METJetsb3);
}
Example #11
0
//***############## main fitting Fxn ################ *****//
void FitPlotAndSave( char *Ifile ){
 
/** Plot Options***/	
//gROOT->Reset();
// gROOT->Clear();
gROOT->SetStyle("Plain") ;
gROOT->SetBatch(kFALSE);
gStyle->SetOptTitle(1);
gStyle->SetOptStat(0);
gStyle->SetOptFit(1);
gStyle->SetStatX(.89);
gStyle->SetStatY(.89) ;
gStyle->SetStatBorderSize(0);
//gStyle->SetOptStat(1111111)
gStyle->SetCanvasColor(kWhite);   // background is no longer mouse-dropping white
gStyle->SetPalette(1);        // blue to red false color palette. Use 9 for b/w
gStyle->SetCanvasBorderMode(0);     // turn off canvas borders
gStyle->SetPadBorderMode(0);
gStyle->SetPaintTextFormat("5.2f");  // What precision to put numbers if plotted with "TEXT"

// For publishing:
gStyle->SetLineWidth(2);
gStyle->SetTextSize(1.1);
gStyle->SetLabelSize(0.06,"xy");
gStyle->SetTitleSize(0.08,"xy");
gStyle->SetTitleOffset(1.2,"x");
gStyle->SetTitleOffset(1.0,"y");
gStyle->SetPadTopMargin(0.1);
gStyle->SetPadRightMargin(0.1);
gStyle->SetPadBottomMargin(0.16);
gStyle->SetPadLeftMargin(0.12);
TGaxis::SetMaxDigits(1); // Set Axis to be of the form 0.11 10^N


       TFile *ifile  = new TFile(Ifile);
        
	TF1 *fitFcn  = new TF1("fitFcn", mygaus, FitLowRange, FitHighRange, 3 );
	fitFcn->SetNpx(500);
	fitFcn->SetLineWidth(4);
	fitFcn->SetLineStyle(5);
	fitFcn->SetLineColor(kBlue);
        cout <<" Calling Fitting Fxntion" << endl;
	TH1F*h_Seed_TimeEBEB = (TH1F*)ifile->Get("EBEB/seed time");
	if(h_Seed_TimeEBEB == 0){ std::cout  <<"!! Histogram Does not exist!!" << std::endl; throw 1;}
        
	h_Seed_TimeEBEB->SetTitle("Seed Time[ns]");   
        h_Seed_TimeEBEB->SetMarkerStyle(20);
        h_Seed_TimeEBEB->SetMarkerSize(0.8);
        h_Seed_TimeEBEB->SetStats(1);
        h_Seed_TimeEBEB->SetTitleSize(0.08, "x");   
        h_Seed_TimeEBEB->SetTitleOffset(1.0, "x");    
        h_Seed_TimeEBEB->SetTitleSize(0.06, "y"); 
        h_Seed_TimeEBEB->SetTitleOffset(0.95, "y");    
        h_Seed_TimeEBEB->SetYTitle("Number of Seeds/0.05ns"); 
        h_Seed_TimeEBEB->SetXTitle("t_{seed}[ns]"); 
        h_Seed_TimeEBEB->GetXaxis()->SetRangeUser(FitLowRange, FitHighRange);   

       /** Set parms as parms of Fit Fxn **/
	fitFcn->SetParameters(500, h_Seed_TimeEBEB->GetMean(), h_Seed_TimeEBEB->GetRMS() );
	fitFcn->SetParNames("CONST", "#mu(ns)", "#sigma(ns)");
	h_Seed_TimeEBEB->Fit("fitFcn", "LL"); /**Fit with improved LL**/
	std::cout << "Printing Fit Parameters for EBEB ......   " << std::endl;
        printf("Integral of function in EBEB = %g\n", fitFcn->Integral( FitLowRange, FitHighRange));

        //*** retrive fit results***//
        int npar = fitFcn->GetNpar();
        TVirtualFitter *fit = TVirtualFitter::GetFitter();
        fit->PrintResults(2,0.);
        TMatrixD *CovMatrix = new TMatrixD ( npar, npar, fit->GetCovarianceMatrix() );
	CovMatrix->Print();
        TCanvas *c1 = new TCanvas("c1","EB-EB",200,10,800,900);
     	c1->SetGridx();
     	c1->SetGridy();
	c1->GetFrame()->SetFillColor(21);
	c1->GetFrame()->SetBorderMode(-1);
	c1->GetFrame()->SetBorderSize(5);
        /* c1->Divide(2,1);  */
	c1->cd();
	h_Seed_TimeEBEB->Draw();
	fitFcn->Draw("sames");
        c1->SetLogy(0);
	//  draw the legend
    	TLegend *leg = new TLegend(0.15,0.72,0.3,0.85);
       	leg->SetTextFont(72);
        leg->SetTextSize(0.04);
        leg->AddEntry(h_Seed_TimeEBEB,"EB","lpe");
        leg->AddEntry(fitFcn,"GAUS","l");
        leg->Draw();
	c1->SaveAs("Seed_Time_DoubleElectron_Run2012A-EB-EB.png");
}       
Example #12
0
void forData(string channel, string catcut, bool removeMinor=true){

  // Suppress all the INFO message

  RooMsgService::instance().setGlobalKillBelow(RooFit::WARNING);

  // Input files and sum all backgrounds

  TChain* treeData  = new TChain("tree");
  TChain* treeZjets = new TChain("tree");

  if( channel == "ele" ){

    treeData->Add(Form("%s/data/SingleElectron-Run2015D-05Oct2015-v1_toyMCnew.root",  channel.data()));
    treeData->Add(Form("%s/data/SingleElectron-Run2015D-PromptReco-V4_toyMCnew.root", channel.data()));

  }

  else if( channel == "mu" ){

    treeData->Add(Form("%s/data/SingleMuon-Run2015D-05Oct2015-v1_toyMCnew.root",  channel.data()));
    treeData->Add(Form("%s/data/SingleMuon-Run2015D-PromptReco-V4_toyMCnew.root", channel.data()));

  }

  else return;

  treeZjets->Add(Form("%s/Zjets/DYJetsToLL_M-50_HT-100to200_13TeV_toyMCnew.root", channel.data()));
  treeZjets->Add(Form("%s/Zjets/DYJetsToLL_M-50_HT-200to400_13TeV_toyMCnew.root", channel.data()));
  treeZjets->Add(Form("%s/Zjets/DYJetsToLL_M-50_HT-400to600_13TeV_toyMCnew.root", channel.data()));
  treeZjets->Add(Form("%s/Zjets/DYJetsToLL_M-50_HT-600toInf_13TeV_toyMCnew.root", channel.data()));

  // To remove minor background contribution in data set (weight is -1)

  if( removeMinor ){

    treeData->Add(Form("%s/VV/WW_TuneCUETP8M1_13TeV_toyMCnew.root", channel.data()));
    treeData->Add(Form("%s/VV/WZ_TuneCUETP8M1_13TeV_toyMCnew.root", channel.data()));
    treeData->Add(Form("%s/VV/ZZ_TuneCUETP8M1_13TeV_toyMCnew.root", channel.data()));
    treeData->Add(Form("%s/TT/TT_TuneCUETP8M1_13TeV_toyMCnew.root", channel.data()));

  }

  // Define all the variables from the trees

  RooRealVar cat ("cat", "", 0, 2);
  RooRealVar mJet("prmass", "M_{jet}",  30.,  300., "GeV");
  RooRealVar mZH ("mllbb",   "M_{ZH}", 900., 3000., "GeV");
  RooRealVar evWeight("evweight", "", -1.e3, 1.e3);

  // Set the range in jet mass

  mJet.setRange("allRange", 30., 300.);
  mJet.setRange("lowSB",    30.,  65.);
  mJet.setRange("highSB",  135., 300.);
  mJet.setRange("signal",  105., 135.);

  RooBinning binsmJet(54, 30, 300);

  RooArgSet variables(cat, mJet, mZH, evWeight);

  TCut catCut = Form("cat==%s", catcut.c_str());
  TCut sbCut  = "prmass>30 && !(prmass>65 && prmass<135) && prmass<300";
  TCut sigCut = "prmass>105 && prmass<135";

  // Create a dataset from a tree -> to process an unbinned likelihood fitting

  RooDataSet dataSetData   ("dataSetData",    "dataSetData",    variables, Cut(catCut),           WeightVar(evWeight), Import(*treeData));
  RooDataSet dataSetDataSB ("dataSetDataSB",  "dataSetDataSB",  variables, Cut(catCut && sbCut),  WeightVar(evWeight), Import(*treeData));
  RooDataSet dataSetZjets  ("dataSetZjets",   "dataSetZjets",   variables, Cut(catCut),           WeightVar(evWeight), Import(*treeZjets));
  RooDataSet dataSetZjetsSB("dataSetZjetsSB", "dataSetZjetsSB", variables, Cut(catCut && sbCut),  WeightVar(evWeight), Import(*treeZjets));  
  RooDataSet dataSetZjetsSG("dataSetZjetsSG", "dataSetZjetsSG", variables, Cut(catCut && sigCut), WeightVar(evWeight), Import(*treeZjets));
  
  // Total events number

  float totalMcEv   = dataSetZjetsSB.sumEntries() + dataSetZjetsSG.sumEntries();
  float totalDataEv = dataSetData.sumEntries();

  RooRealVar nMcEvents("nMcEvents", "nMcEvents", 0., 99999.);
  RooRealVar nDataEvents("nDataEvents", "nDataEvents", 0., 99999.);

  nMcEvents.setVal(totalMcEv);
  nMcEvents.setConstant(true);

  nDataEvents.setVal(totalDataEv);
  nDataEvents.setConstant(true);

  // Signal region jet mass

  RooRealVar constant("constant", "constant", -0.02,  -1.,   0.);
  RooRealVar offset  ("offset",   "offset",     30., -50., 200.);
  RooRealVar width   ("width",    "width",     100.,   0., 200.);

  if( catcut == "1" ) offset.setConstant(true);
  
  RooErfExpPdf model_mJet("model_mJet", "model_mJet", mJet, constant, offset, width);
  RooExtendPdf ext_model_mJet("ext_model_mJet", "ext_model_mJet", model_mJet, nMcEvents);

  RooFitResult* mJet_result = ext_model_mJet.fitTo(dataSetZjets, SumW2Error(true), Extended(true), Range("allRange"), Strategy(2), Minimizer("Minuit2"), Save(1));

  // Side band jet mass

  RooRealVar constantSB("constantSB", "constantSB", constant.getVal(),  -1.,   0.);
  RooRealVar offsetSB  ("offsetSB",   "offsetSB",   offset.getVal(),   -50., 200.);
  RooRealVar widthSB   ("widthSB",    "widthSB",    width.getVal(),      0., 200.);

  offsetSB.setConstant(true);

  RooErfExpPdf model_mJetSB("model_mJetSB", "model_mJetSB", mJet, constantSB, offsetSB, widthSB);
  RooExtendPdf ext_model_mJetSB("ext_model_mJetSB", "ext_model_mJetSB", model_mJetSB, nMcEvents);

  RooFitResult* mJetSB_result = ext_model_mJetSB.fitTo(dataSetZjetsSB, SumW2Error(true), Extended(true), Range("lowSB,highSB"), Strategy(2), Minimizer("Minuit2"), Save(1));

  RooAbsReal* nSIGFit = ext_model_mJetSB.createIntegral(RooArgSet(mJet), NormSet(mJet), Range("signal"));

  float normFactor = nSIGFit->getVal() * totalMcEv;
  
  // Plot the results on a frame

  RooPlot* mJetFrame = mJet.frame();

  dataSetZjetsSB.  plotOn(mJetFrame, Binning(binsmJet));  
  ext_model_mJetSB.plotOn(mJetFrame, Range("allRange"), VisualizeError(*mJetSB_result), FillColor(kYellow));
  dataSetZjetsSB.  plotOn(mJetFrame, Binning(binsmJet));  
  ext_model_mJetSB.plotOn(mJetFrame, Range("allRange"));
  mJetFrame->SetTitle("M_{jet} distribution in Z+jets MC");

  // Alpha ratio part

  mZH.setRange("fullRange", 900., 3000.);

  RooBinning binsmZH(21, 900, 3000);

  RooRealVar a("a", "a",  0., -1.,    1.);
  RooRealVar b("b", "b", 1000,  0., 4000.);
  
  RooGenericPdf model_ZHSB("model_ZHSB", "model_ZHSB", "TMath::Exp(@1*@0+@2/@0)", RooArgSet(mZH,a,b));
  RooGenericPdf model_ZHSG("model_ZHSG", "model_ZHSG", "TMath::Exp(@1*@0+@2/@0)", RooArgSet(mZH,a,b));
  RooGenericPdf model_ZH  ("model_ZH",   "model_ZH",   "TMath::Exp(@1*@0+@2/@0)", RooArgSet(mZH,a,b));

  RooExtendPdf ext_model_ZHSB("ext_model_ZHSB", "ext_model_ZHSB", model_ZHSB, nMcEvents);
  RooExtendPdf ext_model_ZHSG("ext_model_ZHSG", "ext_model_ZHSG", model_ZHSG, nMcEvents);
  RooExtendPdf ext_model_ZH  ("ext_model_ZH",   "ext_model_ZH",   model_ZH,   nDataEvents);

  // Fit ZH mass in side band  

  RooFitResult* mZHSB_result = ext_model_ZHSB.fitTo(dataSetZjetsSB, SumW2Error(true), Extended(true), Range("fullRange"), Strategy(2), Minimizer("Minuit2"), Save(1));

  float p0 = a.getVal();
  float p1 = b.getVal();

  // Fit ZH mass in signal region

  RooFitResult* mZHSG_result = ext_model_ZHSG.fitTo(dataSetZjetsSG, SumW2Error(true), Extended(true), Range("fullRange"), Strategy(2), Minimizer("Minuit2"), Save(1));

  float p2 = a.getVal();
  float p3 = b.getVal();

  // Fit ZH mass in side band region (data)

  RooFitResult* mZH_result = ext_model_ZH.fitTo(dataSetDataSB, SumW2Error(true), Extended(true), Range("fullRange"), Strategy(2), Minimizer("Minuit2"), Save(1));

  // Draw the model of alpha ratio
  // Multiply the model of background in data side band with the model of alpha ratio to the a model of background in data signal region

  RooGenericPdf model_alpha("model_alpha", "model_alpha", Form("TMath::Exp(%f*@0+%f/@0)/TMath::Exp(%f*@0+%f/@0)", p2,p3,p0,p1), RooArgSet(mZH));
  RooProdPdf    model_sigData("model_sigData", "ext_model_ZH*model_alpha", RooArgList(ext_model_ZH,model_alpha));

  // Plot the results to a frame 

  RooPlot* mZHFrameMC = mZH.frame();

  dataSetZjetsSB.plotOn(mZHFrameMC, Binning(binsmZH));
  ext_model_ZHSB.plotOn(mZHFrameMC, VisualizeError(*mZHSB_result), FillColor(kYellow));
  dataSetZjetsSB.plotOn(mZHFrameMC, Binning(binsmZH));
  ext_model_ZHSB.plotOn(mZHFrameMC, LineStyle(7), LineColor(kBlue));

  dataSetZjetsSG.plotOn(mZHFrameMC, Binning(binsmZH));
  ext_model_ZHSG.plotOn(mZHFrameMC, VisualizeError(*mZHSG_result), FillColor(kYellow));
  dataSetZjetsSG.plotOn(mZHFrameMC, Binning(binsmZH));
  ext_model_ZHSG.plotOn(mZHFrameMC, LineStyle(7), LineColor(kRed));

  TLegend* leg = new TLegend(0.65,0.77,0.85,0.85);

  leg->AddEntry(mZHFrameMC->findObject(mZHFrameMC->nameOf(3)), "side band",     "l");
  leg->AddEntry(mZHFrameMC->findObject(mZHFrameMC->nameOf(7)), "signal region", "l");
  leg->Draw();

  mZHFrameMC->addObject(leg);
  mZHFrameMC->SetTitle("M_{ZH} distribution in MC");

  RooPlot* mZHFrame = mZH.frame();

  dataSetDataSB.plotOn(mZHFrame, Binning(binsmZH));
  ext_model_ZH .plotOn(mZHFrame, VisualizeError(*mZH_result), FillColor(kYellow));
  dataSetDataSB.plotOn(mZHFrame, Binning(binsmZH));
  ext_model_ZH .plotOn(mZHFrame, LineStyle(7), LineColor(kBlue));
  model_sigData.plotOn(mZHFrame, Normalization(normFactor, RooAbsReal::NumEvent), LineStyle(7), LineColor(kRed));

  TLegend* leg1 = new TLegend(0.65,0.77,0.85,0.85);

  leg1->AddEntry(mZHFrame->findObject(mZHFrame->nameOf(3)), "side band",     "l");
  leg1->AddEntry(mZHFrame->findObject(mZHFrame->nameOf(4)), "signal region", "l");
  leg1->Draw();
  
  mZHFrame->addObject(leg1);
  mZHFrame->SetTitle("M_{ZH} distribution in Data");

  TCanvas* c = new TCanvas("c","",0,0,1000,800);

  c->cd();
  mZHFrameMC->Draw();
  c->Print(Form("rooFit_forData_%s_cat%s.pdf(", channel.data(), catcut.data()));

  c->cd();
  mZHFrame->Draw();
  c->Print(Form("rooFit_forData_%s_cat%s.pdf", channel.data(), catcut.data()));

  c->cd();
  mJetFrame->Draw();
  c->Print(Form("rooFit_forData_%s_cat%s.pdf)", channel.data(), catcut.data()));

}
//
// Principal code segment
//
void pi0_HadCorrelations_Projections(const int iMultOption = 4,
				     const bool peakRegionFile = true,
				     const bool sideBandFile = false,
				     const bool usePbPbData = false,
				     const bool usepPbData = false,
				     const bool useSimReco = false,
				     const bool useGenEvts = true,
				     const bool useV1V2Fit = true,
                                     const bool useV2FitOnly = false) {
  // 
  //             Control Parameter Instructions
  // iMultOption = 0, 1, 2, 3, 4 controls the track multiplicity selection [120-150, 150-195, 185-220, 220-260, 120-260]
  // peakRegionFile = true means that the input file inputTrue.root will be used
  //                  it is assumed that inputTrue.root is soft-linked to a peak-region output ROOT file from the EDM
  //                  this could be either a PbPb, or a pPb, or a pPb simulation ROOT file from the EDM
  //
  // sideBandFile = true is the same logic for a side-band output ROOT file from the EDM analyzer
  //                the inputSide.root is to be soft-lined to a side-band output ROOT file from the EDM
  //
  // only one of peakRegionFile or sideBandFile can be true
  //
  // usePbPbData, usepPbData, useSimReco, or useGenEvts indicate which type of data or MC is being processed
  //
  // for the pPb data and the Sim data choices, there are 8 pT bins
  // for the PbPb data there are 6 pT bins
  //
 
  //
  //          Output results
  // The macro produces two sets of plots: two-dimensional correlation and Fourier-fitted one-dimension
  // The macro produces an output text file, either PeakRegion_ijkMultlmn.txt or SideBand_ijkMultlmn.txt
  //                  the ijk and lmn are the track multiplicity limits determined by the iOption choice
  //

  if(sideBandFile && useGenEvts) {
    cerr << "\n\n Error in input parameters: cannot have a side-band file for generator events" << endl << endl;
    return;
  }

  int nPtBins = 8;
  const float _PbPb_ptMin[6] = {0.7, 1.0, 1.5, 2.0, 2.5, 3.0};
  const float _PbPb_ptMax[6] = {1.0, 1.5, 2.0, 2.5, 3.0, 5.0};

  const float _pPb_ptMin[8] = {0.7, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0};
  const float _pPb_ptMax[8] = {1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 5.0};

  float _ptMin[8] = {0.7, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0};
  float _ptMax[8] = {1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 5.0};

  bool goodDataSource = false;
  char *dataText = new char[200];
  if(usePbPbData) {
    if(usepPbData || useSimReco || useGenEvts) {
      cerr << "\n Cannot only specify one data source as true" << endl;
      return;
    }
    nPtBins = 6;
    for(int kPt=0; kPt<nPtBins; kPt++) {
      _ptMin[kPt] = _PbPb_ptMin[kPt];
      _ptMax[kPt] = _PbPb_ptMax[kPt];
    }
    goodDataSource = true;
    cout << "\n Using PbPbData source with " << nPtBins << " pT bins" << endl;
    sprintf(dataText, "CMS PbPb #sqrt{s_{NN}}=2.76 TeV");
  }
  if(usepPbData) {
    if(usePbPbData || useSimReco || useGenEvts) {
      cerr << "\n Cannot only specify one data source as true" << endl;
      return;
    }
    nPtBins = 8;
    for(int kPt=0; kPt<nPtBins; kPt++) {
      _ptMin[kPt] = _pPb_ptMin[kPt];
      _ptMax[kPt] = _pPb_ptMax[kPt];
    }
    goodDataSource = true;
    cout << "\n Using pPbData source with " << nPtBins << " pT bins" << endl;
    sprintf(dataText, "CMS pPb #sqrt{s_{NN}}=5.0 TeV");
  }
  if(useSimReco) {
    if(usePbPbData || usepPbData || useGenEvts) {
      cerr << "\n Cannot only specify one data source as true" << endl;
      return;
    }
    nPtBins = 8;
    for(int kPt=0; kPt<nPtBins; kPt++) {
      _ptMin[kPt] = _pPb_ptMin[kPt];
      _ptMax[kPt] = _pPb_ptMax[kPt];
    }
    goodDataSource = true;
    cout << "\n Using SimData source with " << nPtBins << " pT bins" << endl;
    sprintf(dataText, "EPOS RECO pPb #sqrt{s_{NN}}=5.01 TeV");
  }

  if(useGenEvts) {
    if(usePbPbData || usepPbData || useSimReco) {
      cerr << "\n Cannot only specify one data source as true" << endl;
      return;
    }
    if(!peakRegionFile) {
      cerr << "\n The peakRegionFile must be set to true when useGenEvts is true" << endl;
      return;
    }
    nPtBins = 8;
    for(int kPt=0; kPt<nPtBins; kPt++) {
      _ptMin[kPt] = _pPb_ptMin[kPt];
      _ptMax[kPt] = _pPb_ptMax[kPt];
    }
    goodDataSource = true;
    cout << "\n Using GenEvts source with " << nPtBins << " pT bins" << endl;
    sprintf(dataText, "EPOS GEN pPb #sqrt{s_{NN}}=5.01 TeV");
  }

  if(!goodDataSource) {
    cerr << "\n The data source was not specified" << endl;
    return;
  }  

  if(peakRegionFile && sideBandFile) {
    cerr << "\n Cannot have the peakRegionFile and the sideBandFile both set to true"<< endl;
    return;
  }
  
  if(!peakRegionFile && !sideBandFile) {
    cerr << "\n Cannot have the peakRegionFile and the sideBandFile both set to false"<< endl;
    return;
  }
  
  TCanvas *c1 = new TCanvas("c1","",900,900);
  Canvas();
  c1->SetFillColor(0);
  c1->SetBorderMode(0);
  c1->SetBorderSize(2);
  c1->SetTickx(1);
  c1->SetTicky(1);
  c1->SetFrameFillStyle(0);
  c1->SetFrameBorderMode(0);
  c1->SetTopMargin(0.05);
  c1->SetBottomMargin(0.1);
  c1->SetLeftMargin(0.1742581);
  c1->SetRightMargin(0.05);
  c1->SetTheta(50.61189);
  c1->SetPhi(40.90062);

  if(nPtBins == 8)
    c1->Divide(3,3);

  if(nPtBins == 6)
    c1->Divide(3,2);

  TCanvas *c2 = new TCanvas("c2", "c2",900,900);
  gStyle->SetOptFit(0);
  gStyle->SetOptStat(0);
  gStyle->SetOptTitle(0);
  c2->Range(0,0,1,1);
  c2->SetFillColor(0);
  c2->SetBorderMode(0);
  c2->SetBorderSize(2);
  //c1->SetLogy();
  c2->SetTickx(1);
  c2->SetTicky(1);
  c2->SetLeftMargin(0.16);
  c2->SetRightMargin(0.16);
  c2->SetTopMargin(0.05);
  c2->SetBottomMargin(0.13);
  c2->SetFrameFillStyle(0);
  c2->SetFrameBorderMode(0);

  if(nPtBins == 8)
    c2->Divide(3,3);

  if(nPtBins == 6)
    c2->Divide(3,2);
    
  TH1::SetDefaultSumw2();
 
  char *inputFileName = new char[200];
  if(peakRegionFile) {
    sprintf(inputFileName, "inputTrue.root");
  }
  if(sideBandFile) {
    sprintf(inputFileName, "inputSide.root");
  }
  TFile *_fpPbData = new TFile(inputFileName, "r");
  if(!_fpPbData) {
    cerr << "\n Cannot find input file " << inputFileName << endl;
    return;
  }
  else {
    cout << "\n Found input file " << inputFileName << endl;
  }

  TH1F * _hEvent_pPb;
  double _nEvents_pPb;
  TH2D *_hSignal_pPb[8];
  TH2D *_hBackground_pPb[8];
    
  char *multText = new char[10];
  char *eventText = new char[100];
  char *signalText = new char[100];
  char *bkgText = new char[100];

  int lowMultiplicity = 120;
  int highMultiplicity = 150;
  char *multiplicityText = new char[200];
  bool goodMultOption = false;
  if(iMultOption == 0) {
    sprintf(multText, "EcalFlowNtpMult100");
    goodMultOption = true;
    sprintf(multiplicityText, "120 #leq N_{track}^{offline} < 150");
  }
  if(iMultOption == 1) {
    sprintf(multText, "EcalFlowNtpMult130");
    lowMultiplicity = 150;
    highMultiplicity = 185;
    goodMultOption = true;
    sprintf(multiplicityText, "150 #leq N_{track}^{offline} < 185");
  }
  if(iMultOption == 2) {
    sprintf(multText, "EcalFlowNtpMult160");
    lowMultiplicity = 185;
    highMultiplicity = 220;
    goodMultOption = true;
    sprintf(multiplicityText, "185 #leq N_{track}^{offline} < 220");
  }
  if(iMultOption == 3) {
    sprintf(multText, "EcalFlowNtpMult190");
    lowMultiplicity = 220;
    highMultiplicity = 260;
    goodMultOption = true;
    sprintf(multiplicityText, "220 #leq N_{track}^{offline} < 260");
  }
  if(iMultOption == 4) {
    sprintf(multText, "EcalFlowNtp");
    lowMultiplicity = 120;
    highMultiplicity = 260;
    goodMultOption = true;
    sprintf(multiplicityText, "120 #leq N_{track}^{offline} < 260");
  }

  if(goodMultOption) {
    if(!useGenEvts) {
      sprintf(eventText, "%s/ChargedParticles/tHPTracks_", multText);
      sprintf(signalText, "%s/pi0HadCorrFunc/hSignalPtBin", multText);
      sprintf(bkgText, "%s/pi0HadCorrFunc/hBackgroundPtBin", multText);
    }
    else {
      sprintf(eventText, "%s/ChargedParticles/tHPTracks_", multText);
      sprintf(signalText, "%s/pi0HadCorrFunc/hGenSignalPtBin", multText);
      sprintf(bkgText, "%s/pi0HadCorrFunc/hGenBackgroundPtBin", multText);
    }
  }
  else {
    cerr << "\n Multiplicity option " << iMultOption << " is not valid" << endl;
    return;
  } // safety check
   
  ofstream myfile;
  char *myFileName = new char[200];
  if(peakRegionFile) {
    sprintf(myFileName, "PeakRegion_%dMult%d.txt", lowMultiplicity, highMultiplicity);
  }
  if(sideBandFile) {
    sprintf(myFileName, "SideBand_%dMult%d.txt", lowMultiplicity, highMultiplicity);
  }
  cout << "\n Opening output text file " << myFileName << endl;
  myfile.open (myFileName);

  cout << "\n eventText = " << eventText;
  cout << "\n signalText= " << signalText;
  cout << "\n signalText = " << bkgText;
  cout << endl;

  char *_SignalHistoName1 = new char[200];
  char *_BkgHistoName1 = new char[200];

  //
  // Why are these numbers hard=coded here?
  //    
  float _SignalFraction[8] = {0.09, 0.23, 0.44, 0.59, 0.66, 0.71, 0.73, 0.74};
    
  _hEvent_pPb = (TH1F*)_fpPbData->Get(eventText);
  if(!_hEvent_pPb) {
    cerr << "\n Unable to find hEvent_pPb with name " << eventText << endl;
    return;
  }
  _nEvents_pPb = _hEvent_pPb->Integral();
    
  cout << "\n Number of events _nEvents_pPb = " << _nEvents_pPb << "; setting up 8 histogram names" << endl;
  for(int iCount=0; iCount<8; ++iCount)
    {
      sprintf(_SignalHistoName1, "%s%d", signalText, iCount);
      sprintf(_BkgHistoName1, "%s%d", bkgText, iCount);

      cout << " iCount = " << iCount << '\t' << "Signal name = " << _SignalHistoName1<<endl;
      cout << " iCount = " << iCount << '\t' << "Background name = " << _BkgHistoName1<<endl;
        
      _hSignal_pPb[iCount] = (TH2D*)_fpPbData->Get(_SignalHistoName1);
      if(!_hSignal_pPb[iCount]) {
	cerr << "\n Unable to find _hSignal_pPb[iCount]" << endl;
	return;
      }

      _hBackground_pPb[iCount] = (TH2D*)_fpPbData->Get(_BkgHistoName1);
      if(!_hBackground_pPb[iCount]) {
	cerr << "\n Unable to find _hBackground_pPb[iCount]" << endl;
	return;
      }
        
    } // loop over 8 histogram bins
    
  double  _etabinwidth = _hSignal_pPb[0]->GetXaxis()->GetBinWidth(1);
  double  _phibinwidth = _hSignal_pPb[0]->GetYaxis()->GetBinWidth(1);
    
  for(long iCount=0; iCount<nPtBins; ++iCount)
    {
      _hSignal_pPb[iCount]->Divide(_hBackground_pPb[iCount]);
      int _x0 = _hBackground_pPb[iCount]->GetXaxis()->FindBin(0.0);
      int _y0 = _hBackground_pPb[iCount]->GetYaxis()->FindBin(0.0);
      double _B0 = _hBackground_pPb[iCount]->GetBinContent(_x0,_y0);
      _hSignal_pPb[iCount]->Scale(_B0/(_nEvents_pPb));
      _hSignal_pPb[iCount]->Scale(1.0/_etabinwidth/_phibinwidth);
        
      c1->cd(iCount+1);
    
      _hSignal_pPb[iCount]->GetXaxis()->SetRange(5,29);
        
      _hSignal_pPb[iCount]->GetXaxis()->SetTitle("#Delta#eta");
      _hSignal_pPb[iCount]->GetXaxis()->SetRange(5,29);
      _hSignal_pPb[iCount]->GetXaxis()->CenterTitle(true);
      _hSignal_pPb[iCount]->GetXaxis()->SetLabelFont(42);
      _hSignal_pPb[iCount]->GetXaxis()->SetLabelSize(0.035);
      _hSignal_pPb[iCount]->GetXaxis()->SetTitleSize(0.05);
      _hSignal_pPb[iCount]->GetXaxis()->SetTitleOffset(1.38);
      _hSignal_pPb[iCount]->GetXaxis()->SetTitleFont(42);
      _hSignal_pPb[iCount]->GetYaxis()->SetTitle("#Delta#phi");
      _hSignal_pPb[iCount]->GetYaxis()->CenterTitle(true);
      _hSignal_pPb[iCount]->GetYaxis()->SetLabelFont(42);
      _hSignal_pPb[iCount]->GetYaxis()->SetLabelSize(0.035);
      _hSignal_pPb[iCount]->GetYaxis()->SetTitleSize(0.05);
      _hSignal_pPb[iCount]->GetYaxis()->SetTitleOffset(1.59);
      _hSignal_pPb[iCount]->GetYaxis()->SetTitleFont(42);
      _hSignal_pPb[iCount]->GetZaxis()->SetTitle("#frac{1}{N_{trig}} #frac{d^{2}N^{pair}}{d#Delta#etad#Delta#phi}");
      _hSignal_pPb[iCount]->GetZaxis()->SetLabelFont(42);
      _hSignal_pPb[iCount]->GetZaxis()->SetLabelSize(0.035);
      _hSignal_pPb[iCount]->GetZaxis()->SetTitleSize(0.035);
      _hSignal_pPb[iCount]->GetZaxis()->SetTitleOffset(2.33);
      _hSignal_pPb[iCount]->GetZaxis()->SetTitleFont(42);
      _hSignal_pPb[iCount]->GetZaxis()->SetNdivisions(505);
      _hSignal_pPb[iCount]->Draw("SURF1");
        
      TLatex * tex = new TLatex(-0.8847018,0.9364877,Form("%5.1f < p_{T} < %5.1f (GeV/c)",_ptMin[iCount],_ptMax[iCount]));
      tex->SetTextSize(0.06);
      tex->Draw();

    } // loop over 8 histogram bins
    
  cout <<"\n Now drawing the projections..." << endl;
  float etaMin = 2.0;
  float etaMax = 3.6;
    
  TString _Name = "projClone";
  TString _Name2 = "_pi0HadProj";
  TString _Name4 = "FourierDecompose";
  TString _Name1, _Name3, _Name5;
    
  TH2D *_projCorrFunc[9];
  TH1D * _pi0HadCorrProj[9];
  TF1 *_FourierDecompose[9];
  const int n = 9;
  double _Parameter0[n];
  double _Par0Error[n];
  double _Parameter2[n];
  double _Par2Error[n];
  double _Ratio[n];
  double _Error[n];
    
  for(long iCount=0; iCount<nPtBins; ++iCount) {
    _Name1 = _Name + iCount;
    _Name3 = _Name2 + iCount;
    _Name5 = _Name4 + iCount;
        
    _projCorrFunc[iCount] = (TH2D*) _hSignal_pPb[iCount]->Clone(_Name1);
    Int_t etabin10m=_projCorrFunc[iCount]->GetXaxis()->FindBin(etaMin+0.01);
    Int_t etabin10p=_projCorrFunc[iCount]->GetXaxis()->FindBin(etaMax-0.01);
    
    _pi0HadCorrProj[iCount] = (TH1D *) _projCorrFunc[iCount]->ProjectionY(_Name3,etabin10m,etabin10p,"e");
    _pi0HadCorrProj[iCount]->GetXaxis()->SetRange(8,24);
            
    c2->cd(iCount+1);
   
    _pi0HadCorrProj[iCount]->SetMarkerColor(4);
    _pi0HadCorrProj[iCount]->SetMarkerStyle(20);
    _pi0HadCorrProj[iCount]->SetMarkerSize(1.0);
    _pi0HadCorrProj[iCount]->GetXaxis()->SetTitle("#Delta#phi");
    _pi0HadCorrProj[iCount]->GetXaxis()->SetLabelFont(42);
    _pi0HadCorrProj[iCount]->GetXaxis()->SetTitleSize(0.06);
    _pi0HadCorrProj[iCount]->GetXaxis()->SetTitleOffset(0.67);
    _pi0HadCorrProj[iCount]->GetXaxis()->SetTitleFont(42);
    _pi0HadCorrProj[iCount]->GetYaxis()->SetTitle("Associated yield");
    _pi0HadCorrProj[iCount]->GetYaxis()->SetLabelFont(42);
    _pi0HadCorrProj[iCount]->GetYaxis()->SetTitleSize(0.06);
    _pi0HadCorrProj[iCount]->GetYaxis()->SetTitleOffset(0.77);
    _pi0HadCorrProj[iCount]->GetYaxis()->SetTitleFont(42);

    _pi0HadCorrProj[iCount]->GetZaxis()->SetLabelFont(42);
    _pi0HadCorrProj[iCount]->GetZaxis()->SetLabelSize(0.035);
    _pi0HadCorrProj[iCount]->GetZaxis()->SetTitleSize(0.035);
    _pi0HadCorrProj[iCount]->GetZaxis()->SetTitleFont(42);

    float maximumHistogramValue = _pi0HadCorrProj[iCount]->GetMaximum();
    float minimumHistogramValue = _pi0HadCorrProj[iCount]->GetMinimum();
    _pi0HadCorrProj[iCount]->SetMaximum(maximumHistogramValue + 0.60*(maximumHistogramValue - minimumHistogramValue));

    _pi0HadCorrProj[iCount]->Draw("E1");
    (c2->cd(iCount+1))->SetGrid();

    if(useV1V2Fit) {
      _FourierDecompose[iCount] = new TF1(_Name5, v1v2Fit, -1.4, 4.88, 3);
      _FourierDecompose[iCount]->SetParNames("Norm","v1", "v2");
    }

    if(useV2FitOnly) {
      _FourierDecompose[iCount] = new TF1(_Name5, v2Fit, -1.4, 4.88, 2);
      _FourierDecompose[iCount]->SetParNames("Norm","v2");
    }
    
    if(!useV2FitOnly && !useV1V2Fit) {
    _FourierDecompose[iCount] = new TF1(_Name5, Function, -1.4, 4.88, 4);
    _FourierDecompose[iCount]->SetParNames("Par0","Par1","Par2","Par3");
    }

    _pi0HadCorrProj[iCount]->Fit(_Name5, "", "", -1.4, 4.84);
        
    double v1 = 0;
    double v1Error = 0;

    double v3 = 0;
    double v3Error = 0;

    if(useV1V2Fit) {
     v1 = ((_FourierDecompose[iCount]->GetParameter(1))/0.232);
     v1Error = ((_FourierDecompose[iCount]->GetParError(1))/0.232);

     _Ratio[iCount] = (_FourierDecompose[iCount]->GetParameter(2))/0.232;
     _Error[iCount] = (_FourierDecompose[iCount]->GetParError(2))/0.232;

   } // using a v1 + v2 fit function

    if(useV2FitOnly) {
      _Ratio[iCount] = (_FourierDecompose[iCount]->GetParameter(1))/0.232;
      _Error[iCount] = (_FourierDecompose[iCount]->GetParError(1))/0.232;
    } // using a pure v2 fit function
    
    if(!useV2FitOnly && !useV1V2Fit) {
      _Parameter0[iCount] = _FourierDecompose[iCount]->GetParameter(0);
      _Par0Error[iCount] = _FourierDecompose[iCount]->GetParError(0);
      _Parameter2[iCount] = _FourierDecompose[iCount]->GetParameter(2);
      _Par2Error[iCount] = _FourierDecompose[iCount]->GetParError(2);

      v3 = ((_FourierDecompose[iCount]->GetParameter(3))/0.232)/_Parameter0[iCount];
      v3Error = ((_FourierDecompose[iCount]->GetParError(3))/0.232)/_Parameter0[iCount];
    
      _Ratio[iCount] = _Parameter2[iCount]/_Parameter0[iCount];
        
      _Ratio[iCount] /= 0.232;  // v2 of the EPOS generator charged particles, 0.3 - 3.0 GeV/c, according to Z. Chen (May 4, 2014, K0-short analysis)
      
      _Error[iCount] = _Ratio[iCount]*(sqrt((_Par2Error[iCount]/_Parameter2[iCount])*(_Par2Error[iCount]/_Parameter2[iCount]) + 
					  (_Par0Error[iCount]/_Parameter0[iCount])*(_Par0Error[iCount]/_Parameter0[iCount]) + 
					  (0.0001364/0.08609)*(0.0001364/0.08609)));
    } // using Monika's fitting function

    TLegend *legend = new TLegend(0.15, 0.65, 0.88, 0.85);
    char *legendHeader = new char[200];
    sprintf(legendHeader, "%s, %s", dataText, multiplicityText); 
    legend->SetHeader(legendHeader);
    legend->SetTextSize(0.04);
    legend->SetTextColor(kBlue);
    char *ptRangeText = new char[200];

    if(sideBandFile) {
      sprintf(ptRangeText, "Bkg: %4.1f < p_{T} < %4.1f (GeV/c)", _ptMin[iCount], _ptMax[iCount]);
    }
    if(peakRegionFile) {
      sprintf(ptRangeText, "Peak for: %4.1f < p_{T} < %4.1f (GeV/c)", _ptMin[iCount], _ptMax[iCount]);
    }
 
    char *fitResults = new char[200];

    if(useV1V2Fit) {
      sprintf(fitResults, "v_{2} = %4.3f #pm %4.3f, v_{1} = %4.3f #pm %4.3f",_Ratio[iCount], _Error[iCount], v1, v1Error); 
    }

    if(useV2FitOnly) {
      sprintf(fitResults, "v_{2} = %4.3f #pm %4.3f (pure v_{2} fit)",_Ratio[iCount], _Error[iCount]); 
    }

    if(!useV2FitOnly && !useV1V2Fit) {
      sprintf(fitResults, "v_{2} = %4.3f #pm %4.3f, v_{3} = %4.3f #pm %4.3f",_Ratio[iCount], _Error[iCount], v3, v3Error); 
    }

    legend->AddEntry(_Name5, fitResults, "l");
    legend->AddEntry((TObject*)0, ptRangeText, "");
    legend->Draw();

  }  // loop over pT bins

  cout << "\n Now writing to the output text file " << myFileName << endl;
  cout << "------------------------****-------------------" << endl;
  for(long iCount=0; iCount<8; ++iCount)
    {

      cout << "Final v2(pi0) ["<< iCount << "] = " << _Ratio[iCount] << '\t' << _Error[iCount] << '\t' << _Error[iCount]/_SignalFraction[iCount] << endl;
      myfile << _Ratio[iCount] << '\t' << _Error[iCount] << endl;
    }
  cout <<"------------------------****-------------------" << endl;

  myfile.close();

}
void jet2ptb3()
{
//=========Macro generated from canvas: b3/jet2ptb3/b3/jet2ptb3
//=========  (Tue Nov 24 14:23:59 2015) by ROOT version6.02/05
   TCanvas *b3/jet2ptb3 = new TCanvas("b3/jet2ptb3", "b3/jet2ptb3",160,182,700,700);
   b3/jet2ptb3->Range(-91.25001,-6.900868,1121.25,0.06037564);
   b3/jet2ptb3->SetFillColor(0);
   b3/jet2ptb3->SetBorderMode(0);
   b3/jet2ptb3->SetBorderSize(2);
   b3/jet2ptb3->SetLogy();
   b3/jet2ptb3->SetFrameBorderMode(0);
   b3/jet2ptb3->SetFrameBorderMode(0);
   
   THStack *b3/jet2ptb3 = new THStack();
   b3/jet2ptb3->SetName("b3/jet2ptb3");
   b3/jet2ptb3->SetTitle("b3/jet2ptb3");
   
   TH1F *b3/jet2ptb3_stack_9 = new TH1F("b3/jet2ptb3_stack_9","b3/jet2ptb3",40,30,1000);
   b3/jet2ptb3_stack_9->SetMinimum(6.241037e-07);
   b3/jet2ptb3_stack_9->SetMaximum(0.2313403);
   b3/jet2ptb3_stack_9->SetDirectory(0);
   b3/jet2ptb3_stack_9->SetStats(0);

   Int_t ci;      // for color index setting
   TColor *color; // for color definition with alpha
   ci = TColor::GetColor("#000099");
   b3/jet2ptb3_stack_9->SetLineColor(ci);
   b3/jet2ptb3_stack_9->GetXaxis()->SetTitle("b3/jet2ptb3");
   b3/jet2ptb3_stack_9->GetXaxis()->SetLabelFont(42);
   b3/jet2ptb3_stack_9->GetXaxis()->SetLabelSize(0.035);
   b3/jet2ptb3_stack_9->GetXaxis()->SetTitleSize(0.035);
   b3/jet2ptb3_stack_9->GetXaxis()->SetTitleFont(42);
   b3/jet2ptb3_stack_9->GetYaxis()->SetTitle("Events/pb");
   b3/jet2ptb3_stack_9->GetYaxis()->SetLabelFont(42);
   b3/jet2ptb3_stack_9->GetYaxis()->SetLabelSize(0.035);
   b3/jet2ptb3_stack_9->GetYaxis()->SetTitleSize(0.035);
   b3/jet2ptb3_stack_9->GetYaxis()->SetTitleFont(42);
   b3/jet2ptb3_stack_9->GetZaxis()->SetLabelFont(42);
   b3/jet2ptb3_stack_9->GetZaxis()->SetLabelSize(0.035);
   b3/jet2ptb3_stack_9->GetZaxis()->SetTitleSize(0.035);
   b3/jet2ptb3_stack_9->GetZaxis()->SetTitleFont(42);
   b3/jet2ptb3->SetHistogram(b3/jet2ptb3_stack_9);
   
   
   TH1D *jet2ptb341 = new TH1D("jet2ptb341","p_{T}^{2nd jet}",40,30,1000);
   jet2ptb341->SetBinContent(2,0.00831877);
   jet2ptb341->SetBinContent(3,0.02495631);
   jet2ptb341->SetBinContent(4,0.025637);
   jet2ptb341->SetBinContent(5,0.0193603);
   jet2ptb341->SetBinContent(6,0.01512567);
   jet2ptb341->SetBinContent(7,0.01867961);
   jet2ptb341->SetBinContent(8,0.00340345);
   jet2ptb341->SetBinContent(9,0.01648705);
   jet2ptb341->SetBinContent(10,0.01021035);
   jet2ptb341->SetBinContent(11,0.00884897);
   jet2ptb341->SetBinContent(12,0.01021035);
   jet2ptb341->SetBinContent(13,0.00748759);
   jet2ptb341->SetBinContent(14,0.00544552);
   jet2ptb341->SetBinContent(15,0.00884897);
   jet2ptb341->SetBinContent(16,0.00612621);
   jet2ptb341->SetBinContent(17,0.00612621);
   jet2ptb341->SetBinContent(18,0.00272276);
   jet2ptb341->SetBinContent(19,0.00136138);
   jet2ptb341->SetBinContent(20,0.00272276);
   jet2ptb341->SetBinContent(21,0.00340345);
   jet2ptb341->SetBinContent(22,0.00204207);
   jet2ptb341->SetBinContent(23,0.00136138);
   jet2ptb341->SetBinContent(24,0.00204207);
   jet2ptb341->SetBinContent(25,0.00068069);
   jet2ptb341->SetBinContent(26,0.00068069);
   jet2ptb341->SetBinContent(27,0.00136138);
   jet2ptb341->SetBinContent(33,0.00068069);
   jet2ptb341->SetBinContent(34,0.00068069);
   jet2ptb341->SetBinContent(36,0.00068069);
   jet2ptb341->SetBinContent(41,0.00136138);
   jet2ptb341->SetBinError(2,0.00831877);
   jet2ptb341->SetBinError(3,0.01440853);
   jet2ptb341->SetBinError(4,0.0144246);
   jet2ptb341->SetBinError(5,0.01184302);
   jet2ptb341->SetBinError(6,0.008592749);
   jet2ptb341->SetBinError(7,0.01182345);
   jet2ptb341->SetBinError(8,0.001522069);
   jet2ptb341->SetBinError(9,0.008646503);
   jet2ptb341->SetBinError(10,0.002636301);
   jet2ptb341->SetBinError(11,0.002454263);
   jet2ptb341->SetBinError(12,0.002636301);
   jet2ptb341->SetBinError(13,0.002257593);
   jet2ptb341->SetBinError(14,0.001925282);
   jet2ptb341->SetBinError(15,0.002454263);
   jet2ptb341->SetBinError(16,0.00204207);
   jet2ptb341->SetBinError(17,0.00204207);
   jet2ptb341->SetBinError(18,0.00136138);
   jet2ptb341->SetBinError(19,0.000962641);
   jet2ptb341->SetBinError(20,0.00136138);
   jet2ptb341->SetBinError(21,0.001522069);
   jet2ptb341->SetBinError(22,0.00117899);
   jet2ptb341->SetBinError(23,0.000962641);
   jet2ptb341->SetBinError(24,0.00117899);
   jet2ptb341->SetBinError(25,0.00068069);
   jet2ptb341->SetBinError(26,0.00068069);
   jet2ptb341->SetBinError(27,0.000962641);
   jet2ptb341->SetBinError(33,0.00068069);
   jet2ptb341->SetBinError(34,0.00068069);
   jet2ptb341->SetBinError(36,0.00068069);
   jet2ptb341->SetBinError(41,0.000962641);
   jet2ptb341->SetEntries(173);

   ci = TColor::GetColor("#00cc00");
   jet2ptb341->SetFillColor(ci);

   ci = TColor::GetColor("#00cc00");
   jet2ptb341->SetLineColor(ci);

   ci = TColor::GetColor("#00cc00");
   jet2ptb341->SetMarkerColor(ci);
   jet2ptb341->SetMarkerStyle(22);
   jet2ptb341->GetXaxis()->SetTitle("jet2ptb3");
   jet2ptb341->GetXaxis()->SetLabelFont(42);
   jet2ptb341->GetXaxis()->SetLabelSize(0.035);
   jet2ptb341->GetXaxis()->SetTitleSize(0.035);
   jet2ptb341->GetXaxis()->SetTitleFont(42);
   jet2ptb341->GetYaxis()->SetTitle("Events/pb");
   jet2ptb341->GetYaxis()->SetLabelFont(42);
   jet2ptb341->GetYaxis()->SetLabelSize(0.035);
   jet2ptb341->GetYaxis()->SetTitleSize(0.035);
   jet2ptb341->GetYaxis()->SetTitleFont(42);
   jet2ptb341->GetZaxis()->SetLabelFont(42);
   jet2ptb341->GetZaxis()->SetLabelSize(0.035);
   jet2ptb341->GetZaxis()->SetTitleSize(0.035);
   jet2ptb341->GetZaxis()->SetTitleFont(42);
   b3/jet2ptb3->Add(jet2ptb3,"");
   
   TH1D *jet2ptb342 = new TH1D("jet2ptb342","p_{T}^{2nd jet}",40,30,1000);
   jet2ptb342->SetBinContent(1,0.07486187);
   jet2ptb342->SetBinContent(2,0.1186285);
   jet2ptb342->SetBinContent(3,0.09820675);
   jet2ptb342->SetBinContent(4,0.06501379);
   jet2ptb342->SetBinContent(5,0.04100031);
   jet2ptb342->SetBinContent(6,0.02808765);
   jet2ptb342->SetBinContent(7,0.01842664);
   jet2ptb342->SetBinContent(8,0.01210031);
   jet2ptb342->SetBinContent(9,0.00923428);
   jet2ptb342->SetBinContent(10,0.006208909);
   jet2ptb342->SetBinContent(11,0.004516214);
   jet2ptb342->SetBinContent(12,0.003135629);
   jet2ptb342->SetBinContent(13,0.003092221);
   jet2ptb342->SetBinContent(14,0.002159794);
   jet2ptb342->SetBinContent(15,0.00156004);
   jet2ptb342->SetBinContent(16,0.001183959);
   jet2ptb342->SetBinContent(17,0.001086456);
   jet2ptb342->SetBinContent(18,0.0009471669);
   jet2ptb342->SetBinContent(19,0.0006407306);
   jet2ptb342->SetBinContent(20,0.000557157);
   jet2ptb342->SetBinContent(21,0.0004875124);
   jet2ptb342->SetBinContent(22,0.0003621521);
   jet2ptb342->SetBinContent(23,0.0004875124);
   jet2ptb342->SetBinContent(24,0.0002785785);
   jet2ptb342->SetBinContent(25,0.000181076);
   jet2ptb342->SetBinContent(26,0.0001392893);
   jet2ptb342->SetBinContent(27,0.000181076);
   jet2ptb342->SetBinContent(28,1.392893e-05);
   jet2ptb342->SetBinContent(29,8.357355e-05);
   jet2ptb342->SetBinContent(30,8.357355e-05);
   jet2ptb342->SetBinContent(31,8.357355e-05);
   jet2ptb342->SetBinContent(32,4.178678e-05);
   jet2ptb342->SetBinContent(33,5.57157e-05);
   jet2ptb342->SetBinContent(34,1.392893e-05);
   jet2ptb342->SetBinContent(35,4.178678e-05);
   jet2ptb342->SetBinContent(37,2.785785e-05);
   jet2ptb342->SetBinContent(38,5.57157e-05);
   jet2ptb342->SetBinContent(39,4.178678e-05);
   jet2ptb342->SetBinContent(40,2.785785e-05);
   jet2ptb342->SetBinContent(41,8.357355e-05);
   jet2ptb342->SetBinError(1,0.00312213);
   jet2ptb342->SetBinError(2,0.003520459);
   jet2ptb342->SetBinError(3,0.002788437);
   jet2ptb342->SetBinError(4,0.001890853);
   jet2ptb342->SetBinError(5,0.001113989);
   jet2ptb342->SetBinError(6,0.001204478);
   jet2ptb342->SetBinError(7,0.0005398228);
   jet2ptb342->SetBinError(8,0.0004129643);
   jet2ptb342->SetBinError(9,0.0003597722);
   jet2ptb342->SetBinError(10,0.0002943446);
   jet2ptb342->SetBinError(11,0.000250906);
   jet2ptb342->SetBinError(12,0.0002090451);
   jet2ptb342->SetBinError(13,0.0002075363);
   jet2ptb342->SetBinError(14,0.0001734807);
   jet2ptb342->SetBinError(15,0.0001474099);
   jet2ptb342->SetBinError(16,0.0001284183);
   jet2ptb342->SetBinError(17,0.0001230169);
   jet2ptb342->SetBinError(18,0.0001148609);
   jet2ptb342->SetBinError(19,9.447057e-05);
   jet2ptb342->SetBinError(20,8.809426e-05);
   jet2ptb342->SetBinError(21,8.240463e-05);
   jet2ptb342->SetBinError(22,7.102386e-05);
   jet2ptb342->SetBinError(23,8.240463e-05);
   jet2ptb342->SetBinError(24,6.229205e-05);
   jet2ptb342->SetBinError(25,5.022145e-05);
   jet2ptb342->SetBinError(26,4.404713e-05);
   jet2ptb342->SetBinError(27,5.022145e-05);
   jet2ptb342->SetBinError(28,1.392893e-05);
   jet2ptb342->SetBinError(29,3.411876e-05);
   jet2ptb342->SetBinError(30,3.411876e-05);
   jet2ptb342->SetBinError(31,3.411876e-05);
   jet2ptb342->SetBinError(32,2.412561e-05);
   jet2ptb342->SetBinError(33,2.785785e-05);
   jet2ptb342->SetBinError(34,1.392893e-05);
   jet2ptb342->SetBinError(35,2.412561e-05);
   jet2ptb342->SetBinError(37,1.969847e-05);
   jet2ptb342->SetBinError(38,2.785785e-05);
   jet2ptb342->SetBinError(39,2.412561e-05);
   jet2ptb342->SetBinError(40,1.969847e-05);
   jet2ptb342->SetBinError(41,3.411876e-05);
   jet2ptb342->SetEntries(19755);

   ci = TColor::GetColor("#00ffff");
   jet2ptb342->SetFillColor(ci);

   ci = TColor::GetColor("#00ffff");
   jet2ptb342->SetLineColor(ci);

   ci = TColor::GetColor("#00ffff");
   jet2ptb342->SetMarkerColor(ci);
   jet2ptb342->SetMarkerStyle(20);
   jet2ptb342->GetXaxis()->SetTitle("jet2ptb3");
   jet2ptb342->GetXaxis()->SetLabelFont(42);
   jet2ptb342->GetXaxis()->SetLabelSize(0.035);
   jet2ptb342->GetXaxis()->SetTitleSize(0.035);
   jet2ptb342->GetXaxis()->SetTitleFont(42);
   jet2ptb342->GetYaxis()->SetTitle("Events/pb");
   jet2ptb342->GetYaxis()->SetLabelFont(42);
   jet2ptb342->GetYaxis()->SetLabelSize(0.035);
   jet2ptb342->GetYaxis()->SetTitleSize(0.035);
   jet2ptb342->GetYaxis()->SetTitleFont(42);
   jet2ptb342->GetZaxis()->SetLabelFont(42);
   jet2ptb342->GetZaxis()->SetLabelSize(0.035);
   jet2ptb342->GetZaxis()->SetTitleSize(0.035);
   jet2ptb342->GetZaxis()->SetTitleFont(42);
   b3/jet2ptb3->Add(jet2ptb3,"");
   
   TH1D *jet2ptb343 = new TH1D("jet2ptb343","p_{T}^{2nd jet}",40,30,1000);
   jet2ptb343->SetBinContent(1,0.0195546);
   jet2ptb343->SetBinContent(2,0.03026164);
   jet2ptb343->SetBinContent(3,0.02452556);
   jet2ptb343->SetBinContent(4,0.01675718);
   jet2ptb343->SetBinContent(5,0.01008021);
   jet2ptb343->SetBinContent(6,0.006921597);
   jet2ptb343->SetBinContent(7,0.004480691);
   jet2ptb343->SetBinContent(8,0.003208372);
   jet2ptb343->SetBinContent(9,0.002113963);
   jet2ptb343->SetBinContent(10,0.001629851);
   jet2ptb343->SetBinContent(11,0.001125754);
   jet2ptb343->SetBinContent(12,0.0009584771);
   jet2ptb343->SetBinContent(13,0.0006565393);
   jet2ptb343->SetBinContent(14,0.0005032298);
   jet2ptb343->SetBinContent(15,0.0004037541);
   jet2ptb343->SetBinContent(16,0.0003241736);
   jet2ptb343->SetBinContent(17,0.0002445931);
   jet2ptb343->SetBinContent(18,0.0001872483);
   jet2ptb343->SetBinContent(19,0.0001884186);
   jet2ptb343->SetBinContent(20,0.0001439471);
   jet2ptb343->SetBinContent(21,9.713505e-05);
   jet2ptb343->SetBinContent(22,9.011324e-05);
   jet2ptb343->SetBinContent(23,6.55369e-05);
   jet2ptb343->SetBinContent(24,6.55369e-05);
   jet2ptb343->SetBinContent(25,5.149328e-05);
   jet2ptb343->SetBinContent(26,3.979026e-05);
   jet2ptb343->SetBinContent(27,3.276845e-05);
   jet2ptb343->SetBinContent(28,3.393875e-05);
   jet2ptb343->SetBinContent(29,1.287332e-05);
   jet2ptb343->SetBinContent(30,2.457634e-05);
   jet2ptb343->SetBinContent(31,2.223573e-05);
   jet2ptb343->SetBinContent(32,1.287332e-05);
   jet2ptb343->SetBinContent(33,8.192112e-06);
   jet2ptb343->SetBinContent(34,1.404362e-05);
   jet2ptb343->SetBinContent(35,1.170302e-05);
   jet2ptb343->SetBinContent(36,2.340604e-06);
   jet2ptb343->SetBinContent(37,7.021811e-06);
   jet2ptb343->SetBinContent(38,5.851509e-06);
   jet2ptb343->SetBinContent(39,8.192112e-06);
   jet2ptb343->SetBinContent(40,4.681207e-06);
   jet2ptb343->SetBinContent(41,2.808724e-05);
   jet2ptb343->SetBinError(1,0.0006989454);
   jet2ptb343->SetBinError(2,0.0008037971);
   jet2ptb343->SetBinError(3,0.0006427974);
   jet2ptb343->SetBinError(4,0.0004326389);
   jet2ptb343->SetBinError(5,0.000216814);
   jet2ptb343->SetBinError(6,0.000143422);
   jet2ptb343->SetBinError(7,9.166301e-05);
   jet2ptb343->SetBinError(8,7.081659e-05);
   jet2ptb343->SetBinError(9,5.28481e-05);
   jet2ptb343->SetBinError(10,4.411704e-05);
   jet2ptb343->SetBinError(11,3.6404e-05);
   jet2ptb343->SetBinError(12,3.34919e-05);
   jet2ptb343->SetBinError(13,2.771911e-05);
   jet2ptb343->SetBinError(14,2.426789e-05);
   jet2ptb343->SetBinError(15,2.173739e-05);
   jet2ptb343->SetBinError(16,1.94777e-05);
   jet2ptb343->SetBinError(17,1.691886e-05);
   jet2ptb343->SetBinError(18,1.480328e-05);
   jet2ptb343->SetBinError(19,1.484946e-05);
   jet2ptb343->SetBinError(20,1.297927e-05);
   jet2ptb343->SetBinError(21,1.066196e-05);
   jet2ptb343->SetBinError(22,1.026936e-05);
   jet2ptb343->SetBinError(23,8.757736e-06);
   jet2ptb343->SetBinError(24,8.757736e-06);
   jet2ptb343->SetBinError(25,7.762904e-06);
   jet2ptb343->SetBinError(26,6.823973e-06);
   jet2ptb343->SetBinError(27,6.192655e-06);
   jet2ptb343->SetBinError(28,6.302268e-06);
   jet2ptb343->SetBinError(29,3.881452e-06);
   jet2ptb343->SetBinError(30,5.362996e-06);
   jet2ptb343->SetBinError(31,5.101227e-06);
   jet2ptb343->SetBinError(32,3.881452e-06);
   jet2ptb343->SetBinError(33,3.096327e-06);
   jet2ptb343->SetBinError(34,4.054044e-06);
   jet2ptb343->SetBinError(35,3.700819e-06);
   jet2ptb343->SetBinError(36,1.655057e-06);
   jet2ptb343->SetBinError(37,2.866642e-06);
   jet2ptb343->SetBinError(38,2.616874e-06);
   jet2ptb343->SetBinError(39,3.096327e-06);
   jet2ptb343->SetBinError(40,2.340604e-06);
   jet2ptb343->SetBinError(41,5.733284e-06);
   jet2ptb343->SetEntries(37083);

   ci = TColor::GetColor("#ffcc00");
   jet2ptb343->SetFillColor(ci);

   ci = TColor::GetColor("#ffcc00");
   jet2ptb343->SetLineColor(ci);

   ci = TColor::GetColor("#ffcc00");
   jet2ptb343->SetMarkerColor(ci);
   jet2ptb343->SetMarkerStyle(21);
   jet2ptb343->GetXaxis()->SetTitle("jet2ptb3");
   jet2ptb343->GetXaxis()->SetLabelFont(42);
   jet2ptb343->GetXaxis()->SetLabelSize(0.035);
   jet2ptb343->GetXaxis()->SetTitleSize(0.035);
   jet2ptb343->GetXaxis()->SetTitleFont(42);
   jet2ptb343->GetYaxis()->SetTitle("Events/pb");
   jet2ptb343->GetYaxis()->SetLabelFont(42);
   jet2ptb343->GetYaxis()->SetLabelSize(0.035);
   jet2ptb343->GetYaxis()->SetTitleSize(0.035);
   jet2ptb343->GetYaxis()->SetTitleFont(42);
   jet2ptb343->GetZaxis()->SetLabelFont(42);
   jet2ptb343->GetZaxis()->SetLabelSize(0.035);
   jet2ptb343->GetZaxis()->SetTitleSize(0.035);
   jet2ptb343->GetZaxis()->SetTitleFont(42);
   b3/jet2ptb3->Add(jet2ptb3,"");
   
   TH1D *jet2ptb344 = new TH1D("jet2ptb344","p_{T}^{2nd jet}",40,30,1000);
   jet2ptb344->SetBinContent(1,0.002976943);
   jet2ptb344->SetBinContent(2,0.005105535);
   jet2ptb344->SetBinContent(3,0.005151808);
   jet2ptb344->SetBinContent(4,0.003393407);
   jet2ptb344->SetBinContent(5,0.002375385);
   jet2ptb344->SetBinContent(6,0.0018201);
   jet2ptb344->SetBinContent(7,0.001187692);
   jet2ptb344->SetBinContent(8,0.0006478322);
   jet2ptb344->SetBinContent(9,0.0005707093);
   jet2ptb344->SetBinContent(10,0.0004164636);
   jet2ptb344->SetBinContent(11,0.0001850949);
   jet2ptb344->SetBinContent(12,0.0001696703);
   jet2ptb344->SetBinContent(13,9.254746e-05);
   jet2ptb344->SetBinContent(14,7.712288e-05);
   jet2ptb344->SetBinContent(15,4.627373e-05);
   jet2ptb344->SetBinContent(16,6.16983e-05);
   jet2ptb344->SetBinContent(18,1.542458e-05);
   jet2ptb344->SetBinContent(19,6.16983e-05);
   jet2ptb344->SetBinContent(21,1.542458e-05);
   jet2ptb344->SetBinContent(22,1.542458e-05);
   jet2ptb344->SetBinContent(24,1.542458e-05);
   jet2ptb344->SetBinContent(25,1.542458e-05);
   jet2ptb344->SetBinError(1,0.0002142851);
   jet2ptb344->SetBinError(2,0.0002806256);
   jet2ptb344->SetBinError(3,0.0002818944);
   jet2ptb344->SetBinError(4,0.0002287834);
   jet2ptb344->SetBinError(5,0.000191414);
   jet2ptb344->SetBinError(6,0.0001675538);
   jet2ptb344->SetBinError(7,0.0001353501);
   jet2ptb344->SetBinError(8,9.996268e-05);
   jet2ptb344->SetBinError(9,9.382403e-05);
   jet2ptb344->SetBinError(10,8.014845e-05);
   jet2ptb344->SetBinError(11,5.34323e-05);
   jet2ptb344->SetBinError(12,5.115753e-05);
   jet2ptb344->SetBinError(13,3.778234e-05);
   jet2ptb344->SetBinError(14,3.44904e-05);
   jet2ptb344->SetBinError(15,2.671615e-05);
   jet2ptb344->SetBinError(16,3.084915e-05);
   jet2ptb344->SetBinError(18,1.542458e-05);
   jet2ptb344->SetBinError(19,3.084915e-05);
   jet2ptb344->SetBinError(21,1.542458e-05);
   jet2ptb344->SetBinError(22,1.542458e-05);
   jet2ptb344->SetBinError(24,1.542458e-05);
   jet2ptb344->SetBinError(25,1.542458e-05);
   jet2ptb344->SetEntries(1583);

   ci = TColor::GetColor("#ff0000");
   jet2ptb344->SetFillColor(ci);

   ci = TColor::GetColor("#ff0000");
   jet2ptb344->SetLineColor(ci);

   ci = TColor::GetColor("#ff0000");
   jet2ptb344->SetMarkerColor(ci);
   jet2ptb344->SetMarkerStyle(20);
   jet2ptb344->GetXaxis()->SetTitle("jet2ptb3");
   jet2ptb344->GetXaxis()->SetLabelFont(42);
   jet2ptb344->GetXaxis()->SetLabelSize(0.035);
   jet2ptb344->GetXaxis()->SetTitleSize(0.035);
   jet2ptb344->GetXaxis()->SetTitleFont(42);
   jet2ptb344->GetYaxis()->SetTitle("Events/pb");
   jet2ptb344->GetYaxis()->SetLabelFont(42);
   jet2ptb344->GetYaxis()->SetLabelSize(0.035);
   jet2ptb344->GetYaxis()->SetTitleSize(0.035);
   jet2ptb344->GetYaxis()->SetTitleFont(42);
   jet2ptb344->GetZaxis()->SetLabelFont(42);
   jet2ptb344->GetZaxis()->SetLabelSize(0.035);
   jet2ptb344->GetZaxis()->SetTitleSize(0.035);
   jet2ptb344->GetZaxis()->SetTitleFont(42);
   b3/jet2ptb3->Add(jet2ptb3,"");
   
   TH1D *jet2ptb345 = new TH1D("jet2ptb345","p_{T}^{2nd jet}",40,30,1000);
   jet2ptb345->SetBinContent(1,6.708659e-05);
   jet2ptb345->SetBinContent(2,0.0003186613);
   jet2ptb345->SetBinContent(3,0.0003186613);
   jet2ptb345->SetBinContent(4,0.000335433);
   jet2ptb345->SetBinContent(5,0.0004192912);
   jet2ptb345->SetBinContent(6,0.0001341732);
   jet2ptb345->SetBinContent(7,0.0001509448);
   jet2ptb345->SetBinContent(8,0.0002348031);
   jet2ptb345->SetBinContent(9,5.031494e-05);
   jet2ptb345->SetBinContent(10,3.35433e-05);
   jet2ptb345->SetBinContent(11,1.677165e-05);
   jet2ptb345->SetBinContent(12,1.677165e-05);
   jet2ptb345->SetBinContent(13,3.35433e-05);
   jet2ptb345->SetBinContent(15,3.35433e-05);
   jet2ptb345->SetBinContent(17,1.677165e-05);
   jet2ptb345->SetBinContent(18,1.677165e-05);
   jet2ptb345->SetBinContent(21,1.677165e-05);
   jet2ptb345->SetBinError(1,3.35433e-05);
   jet2ptb345->SetBinError(2,7.310592e-05);
   jet2ptb345->SetBinError(3,7.310592e-05);
   jet2ptb345->SetBinError(4,7.500509e-05);
   jet2ptb345->SetBinError(5,8.385824e-05);
   jet2ptb345->SetBinError(6,4.743738e-05);
   jet2ptb345->SetBinError(7,5.031494e-05);
   jet2ptb345->SetBinError(8,6.275376e-05);
   jet2ptb345->SetBinError(9,2.904935e-05);
   jet2ptb345->SetBinError(10,2.371869e-05);
   jet2ptb345->SetBinError(11,1.677165e-05);
   jet2ptb345->SetBinError(12,1.677165e-05);
   jet2ptb345->SetBinError(13,2.371869e-05);
   jet2ptb345->SetBinError(15,2.371869e-05);
   jet2ptb345->SetBinError(17,1.677165e-05);
   jet2ptb345->SetBinError(18,1.677165e-05);
   jet2ptb345->SetBinError(21,1.677165e-05);
   jet2ptb345->SetEntries(132);

   ci = TColor::GetColor("#0000ff");
   jet2ptb345->SetFillColor(ci);

   ci = TColor::GetColor("#0000ff");
   jet2ptb345->SetLineColor(ci);

   ci = TColor::GetColor("#0000ff");
   jet2ptb345->SetMarkerColor(ci);
   jet2ptb345->SetMarkerStyle(21);
   jet2ptb345->GetXaxis()->SetTitle("jet2ptb3");
   jet2ptb345->GetXaxis()->SetLabelFont(42);
   jet2ptb345->GetXaxis()->SetLabelSize(0.035);
   jet2ptb345->GetXaxis()->SetTitleSize(0.035);
   jet2ptb345->GetXaxis()->SetTitleFont(42);
   jet2ptb345->GetYaxis()->SetTitle("Events/pb");
   jet2ptb345->GetYaxis()->SetLabelFont(42);
   jet2ptb345->GetYaxis()->SetLabelSize(0.035);
   jet2ptb345->GetYaxis()->SetTitleSize(0.035);
   jet2ptb345->GetYaxis()->SetTitleFont(42);
   jet2ptb345->GetZaxis()->SetLabelFont(42);
   jet2ptb345->GetZaxis()->SetLabelSize(0.035);
   jet2ptb345->GetZaxis()->SetTitleSize(0.035);
   jet2ptb345->GetZaxis()->SetTitleFont(42);
   b3/jet2ptb3->Add(jet2ptb3,"");
   b3/jet2ptb3->Draw("nostack");
   
   TPaveText *pt = new TPaveText(0.3578161,0.9342857,0.6421839,0.995,"blNDC");
   pt->SetName("title");
   pt->SetBorderSize(0);
   pt->SetFillColor(0);
   pt->SetFillStyle(0);
   pt->SetTextFont(42);
   TText *AText = pt->AddText("b3/jet2ptb3");
   pt->Draw();
   
   TLegend *leg = new TLegend(0.54023,0.639881,0.938218,0.924107,NULL,"brNDC");
   leg->SetBorderSize(1);
   leg->SetTextSize(0.034965);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(1001);
   TLegendEntry *entry=leg->AddEntry("jet2ptb3","b3/jet2ptb3_QCD_b3/","lp");

   ci = TColor::GetColor("#00cc00");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);

   ci = TColor::GetColor("#00cc00");
   entry->SetMarkerColor(ci);
   entry->SetMarkerStyle(22);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("jet2ptb3","b3/jet2ptb3_WJetsToLNu_b3/","lp");

   ci = TColor::GetColor("#00ffff");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);

   ci = TColor::GetColor("#00ffff");
   entry->SetMarkerColor(ci);
   entry->SetMarkerStyle(20);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("jet2ptb3","b3/jet2ptb3_ZJetsToNuNu_b3/","lp");

   ci = TColor::GetColor("#ffcc00");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);

   ci = TColor::GetColor("#ffcc00");
   entry->SetMarkerColor(ci);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("jet2ptb3","b3/jet2ptb3_signal_b3/","lp");

   ci = TColor::GetColor("#ff0000");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);

   ci = TColor::GetColor("#ff0000");
   entry->SetMarkerColor(ci);
   entry->SetMarkerStyle(20);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("jet2ptb3","b3/jet2ptb3_ttbar_b3/","lp");

   ci = TColor::GetColor("#0000ff");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);

   ci = TColor::GetColor("#0000ff");
   entry->SetMarkerColor(ci);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   leg->Draw();
   b3/jet2ptb3->Modified();
   b3/jet2ptb3->cd();
   b3/jet2ptb3->SetSelected(b3/jet2ptb3);
}
void drawLateralScan( const std::string& outputdir, const std::string& name, std::vector<LateralScanStruct> lss, const std::string& axisName, const std::string& fullVarName_mc ) {


  ResoStruct rs_ref_mc;
  ResoStruct rs_ref_data;

  for( unsigned i=0; i<lss.size(); ++i ) {

    if( lss[i].offset==0. ) {

      std::string histoName_data("data_ref");
      TH1D* h1_data = new TH1D( histoName_data.c_str(), "", 200, 0., 5000. );
      lss[i].tree_data->Project( histoName_data.c_str(), "cef3_corr[0]+cef3_corr[1]+cef3_corr[2]+cef3_corr[3]", "isSingleEle_scintFront" );
  
      std::string histoName_mc("mc_ref");
      TH1D* h1_mc = new TH1D( histoName_mc.c_str(), "", 100, 0., 500. );
      lss[i].tree_mc->Project( histoName_mc.c_str(), fullVarName_mc.c_str() );

      rs_ref_mc   = getRespResoFromHisto( h1_mc );
      rs_ref_data = getRespResoFromHisto( h1_data );

      delete h1_data;
      delete h1_mc;

      break;

    }

  }



  TGraphErrors* gr_RespVsDiag_data = new TGraphErrors(0);
  TGraphErrors* gr_ResoVsDiag_data = new TGraphErrors(0);
  TGraphErrors* gr_RespVsDiag_mc   = new TGraphErrors(0);
  TGraphErrors* gr_ResoVsDiag_mc   = new TGraphErrors(0);

  for( unsigned i=0; i<lss.size(); ++i ) {

    std::string histoName_data(Form("data_%.0f", lss[i].offset));
    TH1D* h1_data = new TH1D( histoName_data.c_str(), "", 200, 0., 5000. );
    lss[i].tree_data->Project( histoName_data.c_str(), "cef3_corr[0]+cef3_corr[1]+cef3_corr[2]+cef3_corr[3]", "isSingleEle_scintFront" );

    std::string histoName_mc(Form("mc_%.0f", lss[i].offset));
    TH1D* h1_mc = new TH1D( histoName_mc.c_str(), "", 100, 0., 500. );
    lss[i].tree_mc->Project( histoName_mc.c_str(), fullVarName_mc.c_str() );


    ResoStruct rs_mc = getRespResoFromHisto( h1_mc );
    ResoStruct rs_data = getRespResoFromHisto( h1_data );

    gr_RespVsDiag_data->SetPoint( i, lss[i].offset, rs_data.resp/rs_ref_data.resp );
    gr_ResoVsDiag_data->SetPoint( i, lss[i].offset, rs_data.reso/rs_ref_data.reso );
    gr_RespVsDiag_mc  ->SetPoint( i, lss[i].offset, rs_mc.resp/rs_ref_mc.resp );
    gr_ResoVsDiag_mc  ->SetPoint( i, lss[i].offset, rs_mc.reso/rs_ref_mc.reso );
    
    gr_RespVsDiag_data->SetPointError( i, 0., getRatioError( rs_data.resp, rs_ref_data.resp, rs_data.resp_error, rs_ref_data.resp_error) );
    gr_ResoVsDiag_data->SetPointError( i, 0., getRatioError( rs_data.reso, rs_ref_data.reso, rs_data.reso_error, rs_ref_data.reso_error) );
    gr_RespVsDiag_mc  ->SetPointError( i, 0., getRatioError( rs_mc  .resp, rs_ref_mc  .resp, rs_mc  .resp_error, rs_ref_mc  .resp_error) );
    gr_ResoVsDiag_mc  ->SetPointError( i, 0., getRatioError( rs_mc  .reso, rs_ref_mc  .reso, rs_mc  .reso_error, rs_ref_mc  .reso_error) );

    delete h1_data;
    delete h1_mc;
    
  }


  TCanvas* c1 = new TCanvas("c2", "", 600, 600);
  c1->cd();

  float xMax = (axisName=="Diagonal") ? 20. : 13.;
  float xMin = (axisName=="Diagonal") ? -1. : -xMax;
  TH2D* h2_axes = new TH2D("axes", "", 10, xMin, xMax, 10, 0., 1.1);
  h2_axes->SetXTitle( Form("%s Distance From Center [mm]", axisName.c_str()));
  h2_axes->SetYTitle( "Response Ratio" );

  h2_axes->Draw();

  TLine* line_one = new TLine( xMin, 1., xMax, 1. );
  line_one->Draw("same");

  gr_RespVsDiag_data->SetMarkerSize(1.6);
  gr_RespVsDiag_mc->SetMarkerSize(1.6);

  gr_RespVsDiag_data->SetMarkerStyle(20);
  gr_RespVsDiag_mc->SetMarkerStyle(24);

  gr_RespVsDiag_data->SetMarkerColor(46);
  gr_RespVsDiag_mc->SetMarkerColor(kBlack);

  gr_RespVsDiag_data->Draw("p same");
  gr_RespVsDiag_mc->Draw("p same");

  TLegend* legend = new TLegend( 0.22, 0.21, 0.45, 0.39 );
  legend->SetFillStyle(1);
  legend->SetFillColor(0);
  legend->SetTextSize(0.038);
  legend->AddEntry( gr_RespVsDiag_data, "Data", "P" );
  legend->AddEntry( gr_RespVsDiag_mc, "Geant4", "P" );
  legend->Draw("same");

  TPaveText* labelTop = DrawTools::getLabelTop();
  labelTop->Draw("same");

  gPad->RedrawAxis();

  c1->SaveAs( Form("%s/resp_vs_%s.eps", outputdir.c_str(), name.c_str()) );
  c1->SaveAs( Form("%s/resp_vs_%s.png", outputdir.c_str(), name.c_str()) );
  c1->SaveAs( Form("%s/resp_vs_%s.pdf", outputdir.c_str(), name.c_str()) );

  delete c1;
  delete h2_axes;
  delete legend;
  delete gr_RespVsDiag_data;
  delete gr_RespVsDiag_mc;
  delete gr_ResoVsDiag_data;
  delete gr_ResoVsDiag_mc;

}
Example #16
0
File: plotgvsr.C Project: XuQiao/HI
void plotgvsr(){

int xbin=0;	//xbin<1
int xpt=0;
int xtheta=0;	//xtheta<5

TFile *f = TFile::Open("mergedV_Sum.root");
TFile *fProd = TFile::Open("mergedV_Prod.root");
TVectorD *vecDr = f->Get(Form("D_%d/r",xbin));
TVectorD *vecDg2 = f->Get(Form("D_%d/D_%d/D_%d/G2",xbin,xpt,xtheta));
TVectorD *vecDsigma2 = f->Get(Form("D_%d/D_%d/sigma2",xbin,xpt));
TVectorD *vecDV = f->Get(Form("D_%d/D_%d/V",xbin,xpt));
TVectorD *vecDavgmult = f->Get(Form("D_%d/avgmult",xbin));

TVectorD *vecDr_ = fProd->Get(Form("D_%d/r",xbin));
TVectorD *vecDg2_ = fProd->Get(Form("D_%d/D_%d/D_%d/G2",xbin,xpt,xtheta));
TVectorD *vecDsigma2_ = fProd->Get(Form("D_%d/D_%d/sigma2",xbin,xpt));
TVectorD *vecDV_ = fProd->Get(Form("D_%d/D_%d/V",xbin,xpt));
TVectorD *vecDVmean_ = fProd->Get(Form("D_%d/Vmean",xbin));
TVectorD *vecDavgmult_ = fProd->Get(Form("D_%d/avgmult",xbin));

double *r = vecDr->GetMatrixArray();
double *g2 = vecDg2->GetMatrixArray();
double *sigma2 = vecDsigma2->GetMatrixArray();
double *V = vecDV->GetMatrixArray();
double *avgmult = vecDavgmult->GetMatrixArray();

double *r_ = vecDr_->GetMatrixArray();
double *g2_ = vecDg2_->GetMatrixArray();
double *sigma2_ = vecDsigma2_->GetMatrixArray();
double *V_ = vecDV_->GetMatrixArray();
double *Vmean_ = vecDVmean_->GetMatrixArray();
double *avgmult_ = vecDavgmult_->GetMatrixArray();

TCanvas *c1 = new TCanvas;
c1->SetLogy();
TGraph *gr=new TGraph(nstepr,r,g2);
TGraph *grProd=new TGraph(nstepr,r_,g2_);
gr->GetXaxis()->SetTitle("r");
gr->GetYaxis()->SetTitle("|G^{#theta}(ir)|");
gr->GetXaxis()->SetRangeUser(0.1,0.4);
gr->GetYaxis()->SetRangeUser(1e-8,2);
gr->SetTitle("");
gr->SetMarkerSize(1);
gr->SetMarkerColor(1);
grProd->SetMarkerColor(4);
gr->SetMarkerStyle(20);
grProd->SetMarkerStyle(29);
gr->Draw("AP");
grProd->Draw("Psame");
TLatex *t= new TLatex();
t->SetNDC();
if(xtheta==0)
t->DrawLatex(0.2,0.8,Form("%d < mult <%d, theta = %d", trkbin[xbin+1],trkbin[xbin],xtheta));
else
t->DrawLatex(0.2,0.8,Form("%d < mult <%d, theta = #frac{%d}{%d}#pi", trkbin[xbin+1],trkbin[xbin],xtheta,ntheta*nn));

cout<<sigma2[xtheta]<<"\t"<<V[xtheta]<<"\t"<<avgmult[xbin]<<endl;
TLegend *leg = new TLegend(0.6,0.45,0.8,0.65);
leg->SetBorderSize(0);
leg->SetFillColor(0);
leg->SetTextSize(0.04);
leg->AddEntry(gr,"LYZ Sum Analysis result","P");
leg->AddEntry(grProd,"LYZ Prod Analysis result","P");
//leg->AddEntry(gcl,"theoretical prediction","L");
leg->Draw("same");
c1->Print("gvsr.png");

f->Close();

}
void plotEfficiency_barrelEta() {
  TString fbrem = "(Trk_P_Vtx - Trk_P_Out)/Trk_P_Vtx";

  TCut PtCut="Pt>10";
  TCut EtaCut ="abs(Eta)<2.5";
  TCut Signal ="MatchedGen && MatchedGenFromWZ";
  TCut Bkg ="(!MatchedGen || (MatchedGen && !MatchedGenFromWZ ))";
  TCut barr = "abs(Eta)<1.479";
  TCut endc = "abs(Eta)>1.550&&abs(Eta)<2.5";
  TCut qcd ="(processID==11 || processID==12 || processID==13 || processID==28 || processID==53 || processID==68)";
  
  TFile *_file2 = TFile::Open("Data/Gumbo/New/Gumbo_All.root"); 
  TTree* g = _file2->Get("ElTree");
  TFile *_file1 = TFile::Open("Data/WZ_3l/New/WZCSA07-WZ.root");    
  TTree* s = _file1->Get("ElTree");

  TH1D* h1  = new TH1D("h1", "",50,0,1.5);
  TH1D* h2  = new TH1D("h2", "",50,0,1.5);
  TH1D* sig = new TH1D("sig","",50,0,1.5);
  h1->Sumw2();
  h2->Sumw2();

  TH1D* b1  = new TH1D("b1", "",50,0,1.5);
  TH1D* b2  = new TH1D("b2", "",50,0,1.5);
  TH1D* bkg = new TH1D("bkg","",50,0,1.5);
  b1->Sumw2();
  b2->Sumw2();
  
  TCut sig_preselection = PtCut && Signal && barr;
  TCut bkg_preselection = PtCut && Bkg && qcd && barr;

  // Barrel- Loose Id
  TCut eb_deta = "DeltaEtaVtx <  0.009"; 
  TCut eb_dphi = "DeltaPhiVtx < 0.05";  
  TCut eb_sEE = "sqrt(CovEtaEta)<0.012";
  TCut eb_trkIso = "(IsoKFTrackDR030 - IsoKFTrackDR005)/Pt<0.1";
  TCut eb_EseedPout = "ESeed/Trk_P_Out>0.9";
  // additional cut for Tight criteria
  TCut eb_EmHadIso = "(IsoEmCaloRecHitDR030 + IsoHadCaloRecHitDR030 - ESC)/ESC<0.18";   

  TCut eb_id = eb_deta && eb_dphi && eb_sEE && eb_trkIso && eb_EseedPout; // && eb_EmHadIso; 


  s->Draw("Eta>>h1", sig_preselection);
  s->Draw("Eta>>h2", sig_preselection && eb_id);

  g->Draw("Eta>>b1", "weight"*(bkg_preselection));
  g->Draw("Eta>>b2", "weight"*(bkg_preselection && eb_id));


  sig->Divide(h2, h1, 1, 1, "B");
  bkg->Divide(b2, b1, 1, 1, "B");

  sig->SetMarkerColor(2);
  sig->SetMarkerStyle(21);
  sig->SetMarkerSize(1);

  bkg->SetMarkerColor(4);
  bkg->SetMarkerStyle(22);
  bkg->SetMarkerSize(1);
  
  gStyle->SetOptStat(0);
  TH2F* f = new TH2F("f","",1000,0,1.5,1000,0,1);
  f->Draw();
  f->GetXaxis()->SetTitle("|#eta|");
  f->GetYaxis()->SetTitle("Efficiency");
  sig->Draw("SAMEE");
  bkg->Draw("SAMEE");

  TLegend* leg = new TLegend(0.5,0.5,0.8,0.8);
  leg->AddEntry(sig, "Signal electron");
  leg->AddEntry(bkg, "mis-identified jet (Gumbo)");
  leg->SetLineColor(0);
  leg->SetBorderSize(0);
  leg->Draw();
}
//void PaintOverflow(THStack *h);
void SamMacroModBinWidth(){
  float value = 2.5;
  TCanvas *c1 = new TCanvas("c1", "c1",800,500);
  TPad* spectrumPad=0;
  TPad* ratioPad=0;
  //c1->Divide(1,2);
  //gStyle->SetOptStat(111111);
  gStyle->SetOptFit(kFALSE);
  gStyle->SetOptStat(kFALSE);
  gStyle->SetStatX(0.457589);
  gStyle->SetStatY(0.312937);
  gStyle->SetStatW(0.29241/2+0.0185);
  gStyle->SetStatH(0.169580+0.05);
  gStyle->SetStatFontSize(0.0402098);
  gStyle->SetStatFont(0.02);
  gStyle->SetFitFormat("5.2g");
  gStyle->SetStatBorderSize(0);
  gStyle->SetStatFontSize(0.040209);
  gStyle->SetStatFontSize(0.035209);
  c1->Range(1.592761,-5.173913,3.533814,6.006211);
  c1->SetFillColor(0);
  c1->SetBorderMode(0);
  c1->SetBorderSize(2);
  c1->SetLogx(1);
  c1->SetLogy(1);
  c1->SetTickx(1);
  c1->SetTicky(1);
  c1->SetLeftMargin(0.13);
  c1->SetRightMargin(0.07);
  c1->SetFrameBorderMode(0);
  c1->SetFrameBorderMode(0);
  c1->SetTopMargin(0.085);
  c1->SetBottomMargin(0.11);
  
  // Build the histo with constant log bin width
  const int NMBINS = 100;
  const double MMIN = 60., MMAX = 3000.;
  double logMbins[NMBINS+1];
  float binNormNr=0.;
  for (int ibin = 0; ibin <= NMBINS; ibin++) {
    logMbins[ibin] = exp(log(MMIN) + (log(MMAX)-log(MMIN))*ibin/NMBINS);
    cout << logMbins[ibin] << endl;
  }
  TH1* hTTbarDiboson   = new TH1F("hTTbarDiboson","",NMBINS, logMbins);
  TH1* hDijetWjets     = new TH1F("hDijetWjets","",NMBINS, logMbins);
  TH1* ttbarHist       = new TH1F("ttbarHist","",NMBINS, logMbins);
  TH1* dibosonsBkgHist = new TH1F("dibosonsBkgHist","",NMBINS, logMbins);
  //========================================================== 
  //                                                              
  //               Get the histograms                                  
  //==========================================================
  //TFile *file1 = new TFile("h_ZprimeRecomass_DYBinWidth.root","READ");
  //TH1* zeeHist = (TH1*) file1->Get("ZprimeRecomassBinWidth");

  TFile *file1 = new TFile("DY-MuMu-MC-OS-allbins-MC-2673pb.root","READ");
  TH1* zeeHist = (TH1*) file1->Get("hMassDYAll6");

  TFile *file2 = new TFile("h_ZprimeRecomass_Tlike.root","READ");
  TH1* ttbarHist = (TH1*) file2->Get("ZprimeRecomassBinWidth");
  TFile *file3 = new TFile("h_ZprimeRecomass_DiBoson.root","READ");
  TH1* dibosonsBkgHist = (TH1*) file3->Get("ZprimeRecomassBinWidth");

  TFile *file4 = new TFile("h_ZprimeRecomass_data.root","READ");
  TH1* dataHistTempbar = (TH1*) file4->Get("ZprimeRecomassBinWidth");

  TFile *file5 = new TFile("FR-DiJets-Data-OS-BinWidth-2673pb.root","READ");
  TH1* jetBkgHist   = (TH1*) file5->Get("DataSub");

  TFile *file6 = new TFile("FR-Wjets-25nsMC-OS-BinWidth-2673pb.root","READ");
  TH1* WjetsBkgHist = (TH1*) file6->Get("WjetsHisto");
  std::cout<<"nbQCD(dijets,Data)  = "<<jetBkgHist->Integral()<<endl;
  std::cout<<"nb.Wjets(MC)  = "<<WjetsBkgHist->Integral()<<endl;

  hTTbarDiboson->Add(ttbarHist,dibosonsBkgHist,1,1);
  hDijetWjets->Add(jetBkgHist,WjetsBkgHist,1,1);

  
  zeeHist->Rebin(value);
  hTTbarDiboson->Rebin(value);
  dibosonsBkgHist->Rebin(value);
  dataHistTempbar->Rebin(value);
  hDijetWjets->Rebin(value);
  WjetsBkgHist->Rebin(value);

  
  float binWidthNorm=1;
  int zeeColour    =  TColor::GetColor("#99ccff");
  int jetBkgColour = TColor::GetColor("#ffff66"); 
  int ttbarColour  = TColor::GetColor("#ff6666");
  int bosonColour  = TColor::GetColorDark(3);
  int WjetsColour  = TColor::GetColorDark(5);
  int font = 42;
  //float xAxisMin = 60; //72
  //float xAxisMax = 1000.0;
  //float yAxisMin = 1e-4;
  //float yAxisMax = 1e3; 
  
  TGraphAsymmErrors* dataHist = makeDataGraph(dataHistTempbar,binWidthNorm,0);
  normHistToBinWidth(zeeHist,binWidthNorm);
  normHistToBinWidth(hTTbarDiboson,binWidthNorm);
  //normHistToBinWidth(dibosonsBkgHist,binWidthNorm);
  normHistToBinWidth(hDijetWjets,binWidthNorm);
  //normHistToBinWidth(WjetsBkgHist,binWidthNorm);
  
  //gStyle->SetOptStat(111111);
  //PaintOverflow(zeeHist);
  //PaintOverflow(ttbarHist);
  //PaintOverflow(dibosonsBkgHist);
  //PaintOverflow(dataHistTempbar);
  //PaintOverflow(jetBkgHist);
  //PaintOverflow(WjetsBkgHist);   
  

  THStack *axisHist = new THStack("axisHist","");
  zeeHist->SetFillColor(zeeColour);
  zeeHist->SetLineWidth(2);
  zeeHist->SetLineColor(1);
  zeeHist->SetTitle("");
  
  hTTbarDiboson->SetFillColor(ttbarColour);
  hTTbarDiboson->SetLineWidth(2); 
  hTTbarDiboson->SetLineColor(1);
  
  //dibosonsBkgHist->SetFillColor(bosonColour);
  //dibosonsBkgHist->SetLineWidth(2); 
  //dibosonsBkgHist->SetLineColor(1);
  
  //WjetsBkgHist->SetFillColor(WjetsColour);
  //WjetsBkgHist->SetFillColor(jetBkgColour);
  //WjetsBkgHist->SetLineWidth(2);
  //WjetsBkgHist->SetLineColor(1);

  hDijetWjets->SetFillColor(jetBkgColour);
  hDijetWjets->SetLineWidth(2);
  hDijetWjets->SetLineColor(1);


  


  axisHist->Add(hDijetWjets,"histo");
  //axisHist->Add(WjetsBkgHist,"histo");
  axisHist->Add(hTTbarDiboson);
  //axisHist->Add(dibosonsBkgHist);
  axisHist->Add(zeeHist);
  axisHist->Draw("histo");

  
  //axisHist->GetYaxis()->SetTitle("Events / 20 GeV");
  axisHist->GetXaxis()->SetTitle("M(#mu^{+}#mu^{-}) [GeV]");
  axisHist->GetYaxis()->SetTitle("Events/GeV");
  //axisHist->GetXaxis()->SetTitleOffset(1.1);
  //axisHist->GetYaxis()->SetTitleOffset(1.1);
  axisHist->GetXaxis()->SetTitleSize(0.047);
  axisHist->GetYaxis()->SetTitleSize(0.047);
  axisHist->GetXaxis()->SetLabelSize(0.050);
  axisHist->GetYaxis()->SetLabelSize(0.050);
  axisHist->GetXaxis()->SetMoreLogLabels();
  axisHist->GetXaxis()->SetNoExponent();
  axisHist->GetXaxis()->SetRangeUser(70.0,2999.0);
  
  //axisHist->SetMinimum(0.01);
  //axisHist->SetMaximum(20000.0);
  axisHist->SetMinimum(0.0001);
  axisHist->SetMaximum(2000.0);
  
  dataHist->SetMarkerStyle(20);
  dataHist->SetMarkerSize(0.9);
  dataHist->GetXaxis()->SetRange(5,83);
  dataHist->GetXaxis()->SetTitleSize(0.047);
  dataHist->GetXaxis()->SetTitleOffset(0.9);
  dataHist->GetYaxis()->SetTitleSize(0.047);
  dataHist->GetYaxis()->SetTitleOffset(1.2);
  dataHist->Draw("PZ");
  
  //==========================================================
  TLegend *leg = new TLegend(0.56741,0.62671,0.820536,0.87664,NULL,"brNDC"); //for lumi in plot
  leg->AddEntry(dataHist,"Data","PE");
  leg->AddEntry(zeeHist,"#gamma^{*}/Z#rightarrow#mu^{+}#mu^{-}","F");
  leg->AddEntry(hTTbarDiboson,"t#bar{t}, tW, WW, WZ, ZZ, #tau^{+}#tau^{-}","F");
  //leg->AddEntry(dibosonsBkgHist,"di-boson, #gamma^{*}/Z#rightarrow#tau^{+}#tau^{-}","F");
  //leg->AddEntry(WjetsBkgHist,"W+jets (FR)","F");
  leg->AddEntry(hDijetWjets,"Jets (data)","F");
  leg->SetBorderSize(0);
  leg->SetLineColor(1);
  leg->SetLineStyle(1);
  leg->SetLineWidth(1);
  leg->SetFillColor(19);
  leg->SetFillStyle(0);
  leg->SetTextFont(font);
  leg->SetTextSize(0.04);
  leg->Draw();
  //==========================================================
  TPaveText* tText1 = new TPaveText(0.75, 0.92, 0.87, 0.98, "brNDC");
  tText1->SetBorderSize(0);
  tText1->SetFillColor(0);
  tText1->SetFillStyle(0);
  TText *t1 = tText1->AddText("2.8 fb^{-1} (13 TeV)");
  tText1->SetTextSize(0.04);
  tText1->Draw(); 
  //==========================================================
  TPaveText* tText2 = new TPaveText(0.85, 0.86, 0.88, 0.87, "brNDC");
  tText2->SetBorderSize(0);
  tText2->SetFillColor(0);
  tText2->SetFillStyle(0);
  TText *t1 = tText2->AddText("CMS");
  tText2->SetTextSize(0.04);
  tText2->Draw(); 
  //==========================================================
  TPaveText* tText3 = new TPaveText(0.80, 0.81, 0.85, 0.83, "brNDC");
  tText3->SetBorderSize(0);
  tText3->SetFillColor(0);
  tText3->SetFillStyle(0);
  TText *t1 = tText3->AddText("#it{Preliminary}");
  tText3->SetTextSize(0.04);
  tText3->Draw(); 
  //---------------------------------------------------------------------
  //---------------------------------------------------------------------
  
  //=================================================================================== 
  c1->Print("Stack-DY-Spring15MCs-Data2015-mass-spectrum-MuMu-OS-2800pb_logx.png","png");
  c1->Print("Stack-DY-Spring15MCs-Data2015-mass-spectrum-MuMu-OS-2673pb_logx.pdf","pdf");
  //=========================================================================
  //=========================================================================
  //=========================================================================
  //=========================================================================
  //=========================================================================
  //=========================================================================
  TCanvas *c2 = new TCanvas("c2", "c2",800,500);
  TPad* spectrumPad=0;
  TPad* ratioPad=0;
  // Build the histo with constant log bin width
  const int NMBINS = 100;
  const double MMIN = 60., MMAX = 3000.;
  double logMbins[NMBINS+1];
  float binNormNr=0.;
  for (int ibin = 0; ibin <= NMBINS; ibin++) {
    logMbins[ibin] = exp(log(MMIN) + (log(MMAX)-log(MMIN))*ibin/NMBINS);
    cout << logMbins[ibin] << endl;
  }
  TH1* hTTbarDiboson   = new TH1F("hTTbarDiboson","",NMBINS, logMbins);
  TH1* hDijetWjets     = new TH1F("hDijetWjets","",NMBINS, logMbins);
  TH1* ttbarHist       = new TH1F("ttbarHist","",NMBINS, logMbins);
  TH1* dibosonsBkgHist = new TH1F("dibosonsBkgHist","",NMBINS, logMbins);
  TH1F* hDivideHisto2 = new TH1F("hDivideHisto2","",150,0.0,3000.0);
  //TH1F* hMass1    = new TH1F("hMass1","",150,0.0,3000.0);
  //TH1F* hMass2    = new TH1F("hMass2","",150,0.0,3000.0);
  //TH1F* hMass3    = new TH1F("hMass3","",150,0.0,3000.0);
  //TH1F* hMass5    = new TH1F("hMass5","",150,0.0,3000.0);
  //TH1F* hMass6    = new TH1F("hMass6","",150,0.0,3000.0);
  //TH1F* AllEKWbkg = new TH1F("AllEKWbkg","",150,0.0,3000.0);
  gStyle->SetOptFit(1111);
  gStyle->SetOptStat(0);
  gStyle->SetStatX(0.457589);
  gStyle->SetStatY(0.312937);
  gStyle->SetStatW(0.29241/2+0.0185);
  gStyle->SetStatH(0.169580+0.05);
  gStyle->SetStatFontSize(0.0402098);
  gStyle->SetStatFont(0.03);
  gStyle->SetFitFormat("5.2g");
  gStyle->SetStatBorderSize(0);
  gStyle->SetStatFontSize(0.040209);
  gStyle->SetStatFontSize(0.035209);
  c2->Range(1.592761,-5.173913,3.533814,6.006211);
  c2->SetFillColor(0);
  c2->SetBorderMode(0);
  c2->SetBorderSize(2);
  c2->SetLogx(1);
  c2->SetLogy(1);
  c2->SetTickx(1);
  c2->SetTicky(1);
  c2->SetLeftMargin(0.13);
  c2->SetRightMargin(0.07);
  c2->SetFrameBorderMode(0);
  c2->SetFrameBorderMode(0);
  c2->SetTopMargin(0.085);
  c2->SetBottomMargin(0.11);
   //========================================================== 
  //                                                              
  //               Get the histograms                                  
  //==========================================================
  //TFile *file1 = new TFile("h_ZprimeRecomass_DYBinWidth.root","READ");
  //TH1* zeeHist = (TH1*) file1->Get("ZprimeRecomassBinWidth");

  TFile *file1 = new TFile("DY-MuMu-MC-OS-allbins-MC-2673pb.root","READ");
  TH1* zeeHist = (TH1*) file1->Get("hMassDYAll6");

  TFile *file2 = new TFile("h_ZprimeRecomass_Tlike.root","READ");
  TH1* ttbarHist = (TH1*) file2->Get("ZprimeRecomassBinWidth");

  TFile *file3 = new TFile("h_ZprimeRecomass_DiBoson.root","READ");
  TH1* dibosonsBkgHist = (TH1*) file3->Get("ZprimeRecomassBinWidth");

  TFile *file4 = new TFile("h_ZprimeRecomass_data.root","READ");
  TH1* dataHistTempbar = (TH1*) file4->Get("ZprimeRecomassBinWidth");

  TFile *file5 = new TFile("FR-DiJets-Data-OS-BinWidth-2673pb.root","READ");
  TH1* jetBkgHist   = (TH1*) file5->Get("DataSub");

  TFile *file6 = new TFile("FR-Wjets-25nsMC-OS-BinWidth-2673pb.root","READ");
  TH1* WjetsBkgHist = (TH1*) file6->Get("WjetsHisto");
  std::cout<<"nbQCD(dijets,Data)  = "<<jetBkgHist->Integral()<<endl;
  std::cout<<"nb.Wjets(MC)  = "<<WjetsBkgHist->Integral()<<endl;

  hTTbarDiboson->Add(ttbarHist,dibosonsBkgHist,1,1);
  hDijetWjets->Add(jetBkgHist,WjetsBkgHist,1,1);

  
  //zeeHist->Rebin(value);
  //hTTbarDiboson->Rebin(value);
  //dibosonsBkgHist->Rebin(value);
  //dataHistTempbar->Rebin(value);
  //hDijetWjets->Rebin(value);
  //WjetsBkgHist->Rebin(value);

  float binWidthNorm2=-1;
  int zeeColour    =  TColor::GetColor("#99ccff");
  int jetBkgColour = TColor::GetColor("#ffff66"); 
  int ttbarColour  = TColor::GetColor("#ff6666");
  int bosonColour  = TColor::GetColorDark(3);
  int WjetsColour  = TColor::GetColorDark(5);
  int font = 42;
  float xAxisMin = 60; //72
  float xAxisMax = 1000.0;
  float yAxisMin = 1e-4;
  float yAxisMax = 1e4; 

  dataHistTempbar = makeIntHist(dataHistTempbar);
  zeeHist         = makeIntHist(zeeHist);
  hTTbarDiboson   = makeIntHist(hTTbarDiboson);
  hDijetWjets     = makeIntHist(hDijetWjets);
  TGraphAsymmErrors* dataHist = makeDataGraph(dataHistTempbar,binWidthNorm2,0);
  
  

  THStack *axisHist2 = new THStack("axisHist2","");
  zeeHist->SetFillColor(zeeColour);
  zeeHist->SetLineWidth(2);
  zeeHist->SetLineColor(1);
  zeeHist->SetTitle("");
    
  hTTbarDiboson->SetFillColor(ttbarColour);
  hTTbarDiboson->SetLineWidth(2); 
  hTTbarDiboson->SetLineColor(1);
    
  //dibosonsBkgHist->SetFillColor(bosonColour);
  //dibosonsBkgHist->SetLineWidth(2); 
  //dibosonsBkgHist->SetLineColor(1);
   
  hDijetWjets->SetFillColor(jetBkgColour);
  hDijetWjets->SetLineWidth(2);
  hDijetWjets->SetLineColor(1);

  //WjetsBkgHist->SetFillColor(WjetsColour);
  //WjetsBkgHist->SetLineWidth(2);
  //WjetsBkgHist->SetLineColor(1);
  
  
  axisHist2->Add(hDijetWjets,"histo");
  //axisHist2->Add(WjetsBkgHist,"histo");
  //axisHist2->Add(dibosonsBkgHist,"histo");
  axisHist2->Add(hTTbarDiboson,"histo");
  axisHist2->Add(zeeHist,"histo");
  axisHist2->Draw();
  axisHist2->GetXaxis()->SetTitle("M(#mu^{+}#mu^{-}) [GeV]");
  axisHist2->GetYaxis()->SetTitle("Events #geq M(#mu^{+}#mu^{-}) [GeV]");
  axisHist2->GetXaxis()->SetTitleOffset(1.1);
  axisHist2->GetYaxis()->SetTitleOffset(1.1);
  axisHist2->GetXaxis()->SetTitleSize(0.047);
  axisHist2->GetYaxis()->SetTitleSize(0.047);
  axisHist2->GetXaxis()->SetLabelSize(0.040);
  axisHist2->GetYaxis()->SetLabelSize(0.040);
  axisHist2->GetXaxis()->SetMoreLogLabels();
  axisHist2->GetXaxis()->SetNoExponent();
  axisHist2->GetXaxis()->SetRangeUser(70.0,4000.0);
  axisHist2->SetMinimum(0.01);
  axisHist2->SetMaximum(60000.0);
  
  dataHist->SetMarkerStyle(20);
  dataHist->SetMarkerSize(0.9);
  dataHist->Draw("PZsames");
  //==========================================================
  TLegend *leg = new TLegend(0.56741,0.62671,0.820536,0.87664,NULL,"brNDC"); //for lumi in plot
  leg->AddEntry(dataHist,"Data","PE");
  leg->AddEntry(zeeHist,"#gamma^{*}/Z#rightarrow#mu^{+}#mu^{-}","F");
  leg->AddEntry(hTTbarDiboson,"t#bar{t}, tW, WW, WZ, ZZ, #tau^{+}#tau^{-}","F");
  leg->AddEntry(hDijetWjets,"Jets (data)","F");
  leg->SetBorderSize(0);
  leg->SetLineColor(1);
  leg->SetLineStyle(1);
  leg->SetLineWidth(1);
  leg->SetFillColor(19);
  leg->SetFillStyle(0);
  leg->SetTextFont(font);
  leg->SetTextSize(0.04);
  leg->Draw();

  
  //==========================================================
  TPaveText* tText1 = new TPaveText(0.75, 0.92, 0.87, 0.98, "brNDC");
  tText1->SetBorderSize(0);
  tText1->SetFillColor(0);
  tText1->SetFillStyle(0);
  TText *t1 = tText1->AddText("2.8 fb^{-1} (13 TeV)");
  tText1->SetTextSize(0.04);
  tText1->Draw(); 
  //==========================================================
  TPaveText* tText2 = new TPaveText(0.85, 0.86, 0.88, 0.87, "brNDC");
  tText2->SetBorderSize(0);
  tText2->SetFillColor(0);
  tText2->SetFillStyle(0);
  TText *t1 = tText2->AddText("CMS");
  tText2->SetTextSize(0.04);
  tText2->Draw(); 
  //==========================================================
  TPaveText* tText3 = new TPaveText(0.80, 0.81, 0.85, 0.83, "brNDC");
  tText3->SetBorderSize(0);
  tText3->SetFillColor(0);
  tText3->SetFillStyle(0);
  TText *t1 = tText3->AddText("#it{Preliminary}");
  tText3->SetTextSize(0.04);
  tText3->Draw(); 
  //===================================================================================
 
  //=================================================================================== 
  c2->Print("Stack-DY-Spring15MCs-Data2015-cumulative-spectrum-MuMu-OS-2800pb-logx.png","png");
  //c2->Print("Stack-DY-Spring15MCs-Data2015-cumulative-spectrum-MuMu-OS-2673pb-logx.pdf","pdf");

}
Example #19
0
void ComparedNdcutNewInternal(int variationoption=6,const int nBins=4){
  
  gROOT->SetStyle("Plain");	
  gStyle->SetOptStat(0);
  gStyle->SetOptStat(0000);
  gStyle->SetPalette(0);
  gStyle->SetCanvasColor(0);
  gStyle->SetFrameFillColor(0);
  gStyle->SetOptTitle(0);

  double ptBins[nBins+1];
  
  if(variationoption==1){ ptBins[0]=1.32e-02; ptBins[1]=0.2; ptBins[2]=0.4; ptBins[3]=0.6; ptBins[4]=0.8; ptBins[5]=1.;}
  if(variationoption==2){ ptBins[0]=3.41; ptBins[1]=6.; ptBins[2]=10.; ptBins[3]=20.; ptBins[4]=30.; ptBins[5]=50.;}
  if(variationoption==3){ ptBins[0]=0.9995; ptBins[1]=0.9997; ptBins[2]=0.9998; ptBins[3]=0.9999; ptBins[4]=0.99995; ptBins[5]=1.0;}
  if(variationoption==4){ ptBins[0]=0.7; ptBins[1]=2.; ptBins[2]=4.; ptBins[3]=6.; ptBins[4]=10.; ptBins[5]=20.;}
  if(variationoption==5){ ptBins[0]=10.; ptBins[1]=15.; ptBins[2]=20.; ptBins[3]=25.; ptBins[4]=30.; ptBins[5]=60.;}
  if(variationoption==6){ ptBins[0]=-1.93; ptBins[1]=-1; ptBins[2]=0; ptBins[3]=1.0; ptBins[4]=1.93;}

  TH1D *hPtAll_Data = new TH1D("hPtAll_Data","",nBins,ptBins);  
  TH1D *hPtAll_MC = new TH1D("hPtAll_MC","",nBins,ptBins);  


  //if(variationoption==1 || variationoption==2 || variationoption==3 || variationoption==4 ){
  if(0){
  
    double binsize1=ptBins[1]-ptBins[0];
    double binsize2=ptBins[2]-ptBins[1];
    double binsize3=ptBins[3]-ptBins[2];
    double binsize4=ptBins[4]-ptBins[3];
    double binsize5=ptBins[5]-ptBins[4];
    double binsize6=ptBins[6]-ptBins[5];
    double binsize7=ptBins[7]-ptBins[6];
    double binsize8=ptBins[8]-ptBins[7];
  

    TFile*file0_Data=new TFile(Form("ResultsBplus/CutId%d/SigmaBplusCutId%d_Step0_isData1.root",variationoption,variationoption));
    TFile*file1_Data=new TFile(Form("ResultsBplus/CutId%d/SigmaBplusCutId%d_Step1_isData1.root",variationoption,variationoption));
    TFile*file2_Data=new TFile(Form("ResultsBplus/CutId%d/SigmaBplusCutId%d_Step2_isData1.root",variationoption,variationoption));
    TFile*file3_Data=new TFile(Form("ResultsBplus/CutId%d/SigmaBplusCutId%d_Step3_isData1.root",variationoption,variationoption));
    TFile*file4_Data=new TFile(Form("ResultsBplus/CutId%d/SigmaBplusCutId%d_Step4_isData1.root",variationoption,variationoption));
    TFile*file5_Data=new TFile(Form("ResultsBplus/CutId%d/SigmaBplusCutId%d_Step5_isData1.root",variationoption,variationoption));
    TFile*file6_Data=new TFile(Form("ResultsBplus/CutId%d/SigmaBplusCutId%d_Step6_isData1.root",variationoption,variationoption));
    TFile*file7_Data=new TFile(Form("ResultsBplus/CutId%d/SigmaBplusCutId%d_Step7_isData1.root",variationoption,variationoption));

    TFile*file0_MC=new TFile(Form("ResultsBplus/CutId%d/SigmaBplusCutId%d_Step0_isData0.root",variationoption,variationoption));
    TFile*file1_MC=new TFile(Form("ResultsBplus/CutId%d/SigmaBplusCutId%d_Step1_isData0.root",variationoption,variationoption));
    TFile*file2_MC=new TFile(Form("ResultsBplus/CutId%d/SigmaBplusCutId%d_Step2_isData0.root",variationoption,variationoption));
    TFile*file3_MC=new TFile(Form("ResultsBplus/CutId%d/SigmaBplusCutId%d_Step3_isData0.root",variationoption,variationoption));
    TFile*file4_MC=new TFile(Form("ResultsBplus/CutId%d/SigmaBplusCutId%d_Step4_isData0.root",variationoption,variationoption));
    TFile*file5_MC=new TFile(Form("ResultsBplus/CutId%d/SigmaBplusCutId%d_Step5_isData0.root",variationoption,variationoption));
    TFile*file6_MC=new TFile(Form("ResultsBplus/CutId%d/SigmaBplusCutId%d_Step6_isData0.root",variationoption,variationoption));
    TFile*file7_MC=new TFile(Form("ResultsBplus/CutId%d/SigmaBplusCutId%d_Step7_isData0.root",variationoption,variationoption));

    TH1F*hPtYieldBis_Data1=(TH1F*)file0_Data->Get("hPt");
    TH1F*hPtYieldBis_Data2=(TH1F*)file1_Data->Get("hPt");
    TH1F*hPtYieldBis_Data3=(TH1F*)file2_Data->Get("hPt");
    TH1F*hPtYieldBis_Data4=(TH1F*)file3_Data->Get("hPt");
    TH1F*hPtYieldBis_Data5=(TH1F*)file4_Data->Get("hPt");
    TH1F*hPtYieldBis_Data6=(TH1F*)file5_Data->Get("hPt");
    TH1F*hPtYieldBis_Data7=(TH1F*)file6_Data->Get("hPt");
    TH1F*hPtYieldBis_Data8=(TH1F*)file7_Data->Get("hPt");
   
    TH1F*hPtYieldBis_MC1=(TH1F*)file0_MC->Get("hPt");
    TH1F*hPtYieldBis_MC2=(TH1F*)file1_MC->Get("hPt");
    TH1F*hPtYieldBis_MC3=(TH1F*)file2_MC->Get("hPt");
    TH1F*hPtYieldBis_MC4=(TH1F*)file3_MC->Get("hPt");
    TH1F*hPtYieldBis_MC5=(TH1F*)file4_MC->Get("hPt");
    TH1F*hPtYieldBis_MC6=(TH1F*)file5_MC->Get("hPt");
    TH1F*hPtYieldBis_MC7=(TH1F*)file6_MC->Get("hPt");
    TH1F*hPtYieldBis_MC8=(TH1F*)file7_MC->Get("hPt");


    hPtYieldBis_Data1->SetName("hPtYieldBis_Data1");
    hPtYieldBis_Data2->SetName("hPtYieldBis_Data2");
    hPtYieldBis_Data3->SetName("hPtYieldBis_Data3");
    hPtYieldBis_Data4->SetName("hPtYieldBis_Data4");
    hPtYieldBis_Data5->SetName("hPtYieldBis_Data5");
    hPtYieldBis_Data6->SetName("hPtYieldBis_Data6");
    hPtYieldBis_Data7->SetName("hPtYieldBis_Data7");
    hPtYieldBis_Data8->SetName("hPtYieldBis_Data8");

    hPtYieldBis_MC1->SetName("hPtYieldBis_MC1");
    hPtYieldBis_MC2->SetName("hPtYieldBis_MC2");
    hPtYieldBis_MC3->SetName("hPtYieldBis_MC3");
    hPtYieldBis_MC4->SetName("hPtYieldBis_MC4");
    hPtYieldBis_MC5->SetName("hPtYieldBis_MC5");
    hPtYieldBis_MC6->SetName("hPtYieldBis_MC6");
    hPtYieldBis_MC7->SetName("hPtYieldBis_MC7");
    hPtYieldBis_MC8->SetName("hPtYieldBis_MC8");
    
    hPtAll_Data->SetBinContent(1,hPtYieldBis_Data1->GetBinContent(1)/binsize1);
    hPtAll_Data->SetBinContent(2,hPtYieldBis_Data2->GetBinContent(1)/binsize2);
    hPtAll_Data->SetBinContent(3,hPtYieldBis_Data3->GetBinContent(1)/binsize3);
    hPtAll_Data->SetBinContent(4,hPtYieldBis_Data4->GetBinContent(1)/binsize4);
    hPtAll_Data->SetBinContent(5,hPtYieldBis_Data5->GetBinContent(1)/binsize5);
    hPtAll_Data->SetBinContent(6,hPtYieldBis_Data6->GetBinContent(1)/binsize6);
    hPtAll_Data->SetBinContent(7,hPtYieldBis_Data7->GetBinContent(1)/binsize7);
    hPtAll_Data->SetBinContent(8,hPtYieldBis_Data8->GetBinContent(1)/binsize8);

    hPtAll_Data->SetBinError(1,hPtYieldBis_Data1->GetBinError(1)/binsize1);
    hPtAll_Data->SetBinError(2,hPtYieldBis_Data2->GetBinError(1)/binsize2);
    hPtAll_Data->SetBinError(3,hPtYieldBis_Data3->GetBinError(1)/binsize3);
    hPtAll_Data->SetBinError(4,hPtYieldBis_Data4->GetBinError(1)/binsize4);
    hPtAll_Data->SetBinError(5,hPtYieldBis_Data5->GetBinError(1)/binsize5);
    hPtAll_Data->SetBinError(6,hPtYieldBis_Data6->GetBinError(1)/binsize6);
    hPtAll_Data->SetBinError(7,hPtYieldBis_Data7->GetBinError(1)/binsize7);
    hPtAll_Data->SetBinError(8,hPtYieldBis_Data8->GetBinError(1)/binsize8);
   
    hPtAll_MC->SetBinContent(1,hPtYieldBis_MC1->GetBinContent(1)/binsize1);
    hPtAll_MC->SetBinContent(2,hPtYieldBis_MC2->GetBinContent(1)/binsize2);
    hPtAll_MC->SetBinContent(3,hPtYieldBis_MC3->GetBinContent(1)/binsize3);
    hPtAll_MC->SetBinContent(4,hPtYieldBis_MC4->GetBinContent(1)/binsize4);
    hPtAll_MC->SetBinContent(5,hPtYieldBis_MC5->GetBinContent(1)/binsize5);
    hPtAll_MC->SetBinContent(6,hPtYieldBis_MC6->GetBinContent(1)/binsize6);
    hPtAll_MC->SetBinContent(7,hPtYieldBis_MC7->GetBinContent(1)/binsize7);
    hPtAll_MC->SetBinContent(8,hPtYieldBis_MC8->GetBinContent(1)/binsize8);

    hPtAll_MC->SetBinError(1,hPtYieldBis_MC1->GetBinError(1)/binsize1);
    hPtAll_MC->SetBinError(2,hPtYieldBis_MC2->GetBinError(1)/binsize2);
    hPtAll_MC->SetBinError(3,hPtYieldBis_MC3->GetBinError(1)/binsize3);
    hPtAll_MC->SetBinError(4,hPtYieldBis_MC4->GetBinError(1)/binsize4);
    hPtAll_MC->SetBinError(5,hPtYieldBis_MC5->GetBinError(1)/binsize5);
    hPtAll_MC->SetBinError(6,hPtYieldBis_MC6->GetBinError(1)/binsize6);
    hPtAll_MC->SetBinError(7,hPtYieldBis_MC7->GetBinError(1)/binsize7);
    hPtAll_MC->SetBinError(8,hPtYieldBis_MC8->GetBinError(1)/binsize8);
      
  }

  if(variationoption==1 || variationoption==2 || variationoption==3 || variationoption==4 || variationoption==5){
  
    double binsize1=ptBins[1]-ptBins[0];
    double binsize2=ptBins[2]-ptBins[1];
    double binsize3=ptBins[3]-ptBins[2];
    double binsize4=ptBins[4]-ptBins[3];
    double binsize5=ptBins[5]-ptBins[4];
  

    TFile*file0_Data=new TFile(Form("ResultsBplus/CutId%d/SigmaBplusCutId%d_Step0_isData1.root",variationoption,variationoption));
    TFile*file1_Data=new TFile(Form("ResultsBplus/CutId%d/SigmaBplusCutId%d_Step1_isData1.root",variationoption,variationoption));
    TFile*file2_Data=new TFile(Form("ResultsBplus/CutId%d/SigmaBplusCutId%d_Step2_isData1.root",variationoption,variationoption));
    TFile*file3_Data=new TFile(Form("ResultsBplus/CutId%d/SigmaBplusCutId%d_Step3_isData1.root",variationoption,variationoption));
    TFile*file4_Data=new TFile(Form("ResultsBplus/CutId%d/SigmaBplusCutId%d_Step4_isData1.root",variationoption,variationoption));

    TFile*file0_MC=new TFile(Form("ResultsBplus/CutId%d/SigmaBplusCutId%d_Step0_isData0.root",variationoption,variationoption));
    TFile*file1_MC=new TFile(Form("ResultsBplus/CutId%d/SigmaBplusCutId%d_Step1_isData0.root",variationoption,variationoption));
    TFile*file2_MC=new TFile(Form("ResultsBplus/CutId%d/SigmaBplusCutId%d_Step2_isData0.root",variationoption,variationoption));
    TFile*file3_MC=new TFile(Form("ResultsBplus/CutId%d/SigmaBplusCutId%d_Step3_isData0.root",variationoption,variationoption));
    TFile*file4_MC=new TFile(Form("ResultsBplus/CutId%d/SigmaBplusCutId%d_Step4_isData0.root",variationoption,variationoption));

    TH1F*hPtYieldBis_Data1=(TH1F*)file0_Data->Get("hPt");
    TH1F*hPtYieldBis_Data2=(TH1F*)file1_Data->Get("hPt");
    TH1F*hPtYieldBis_Data3=(TH1F*)file2_Data->Get("hPt");
    TH1F*hPtYieldBis_Data4=(TH1F*)file3_Data->Get("hPt");
    TH1F*hPtYieldBis_Data5=(TH1F*)file4_Data->Get("hPt");
   
    TH1F*hPtYieldBis_MC1=(TH1F*)file0_MC->Get("hPt");
    TH1F*hPtYieldBis_MC2=(TH1F*)file1_MC->Get("hPt");
    TH1F*hPtYieldBis_MC3=(TH1F*)file2_MC->Get("hPt");
    TH1F*hPtYieldBis_MC4=(TH1F*)file3_MC->Get("hPt");
    TH1F*hPtYieldBis_MC5=(TH1F*)file4_MC->Get("hPt");


    hPtYieldBis_Data1->SetName("hPtYieldBis_Data1");
    hPtYieldBis_Data2->SetName("hPtYieldBis_Data2");
    hPtYieldBis_Data3->SetName("hPtYieldBis_Data3");
    hPtYieldBis_Data4->SetName("hPtYieldBis_Data4");
    hPtYieldBis_Data5->SetName("hPtYieldBis_Data5");

    hPtYieldBis_MC1->SetName("hPtYieldBis_MC1");
    hPtYieldBis_MC2->SetName("hPtYieldBis_MC2");
    hPtYieldBis_MC3->SetName("hPtYieldBis_MC3");
    hPtYieldBis_MC4->SetName("hPtYieldBis_MC4");
    hPtYieldBis_MC5->SetName("hPtYieldBis_MC5");
    
    hPtAll_Data->SetBinContent(1,hPtYieldBis_Data1->GetBinContent(1)/binsize1);
    hPtAll_Data->SetBinContent(2,hPtYieldBis_Data2->GetBinContent(1)/binsize2);
    hPtAll_Data->SetBinContent(3,hPtYieldBis_Data3->GetBinContent(1)/binsize3);
    hPtAll_Data->SetBinContent(4,hPtYieldBis_Data4->GetBinContent(1)/binsize4);
    hPtAll_Data->SetBinContent(5,hPtYieldBis_Data5->GetBinContent(1)/binsize5);

    hPtAll_Data->SetBinError(1,hPtYieldBis_Data1->GetBinError(1)/binsize1);
    hPtAll_Data->SetBinError(2,hPtYieldBis_Data2->GetBinError(1)/binsize2);
    hPtAll_Data->SetBinError(3,hPtYieldBis_Data3->GetBinError(1)/binsize3);
    hPtAll_Data->SetBinError(4,hPtYieldBis_Data4->GetBinError(1)/binsize4);
    hPtAll_Data->SetBinError(5,hPtYieldBis_Data5->GetBinError(1)/binsize5);
   
    hPtAll_MC->SetBinContent(1,hPtYieldBis_MC1->GetBinContent(1)/binsize1);
    hPtAll_MC->SetBinContent(2,hPtYieldBis_MC2->GetBinContent(1)/binsize2);
    hPtAll_MC->SetBinContent(3,hPtYieldBis_MC3->GetBinContent(1)/binsize3);
    hPtAll_MC->SetBinContent(4,hPtYieldBis_MC4->GetBinContent(1)/binsize4);
    hPtAll_MC->SetBinContent(5,hPtYieldBis_MC5->GetBinContent(1)/binsize5);

    hPtAll_MC->SetBinError(1,hPtYieldBis_MC1->GetBinError(1)/binsize1);
    hPtAll_MC->SetBinError(2,hPtYieldBis_MC2->GetBinError(1)/binsize2);
    hPtAll_MC->SetBinError(3,hPtYieldBis_MC3->GetBinError(1)/binsize3);
    hPtAll_MC->SetBinError(4,hPtYieldBis_MC4->GetBinError(1)/binsize4);
    hPtAll_MC->SetBinError(5,hPtYieldBis_MC5->GetBinError(1)/binsize5);
      
  }
  
  if(variationoption==6){
  
    double binsize1=ptBins[1]-ptBins[0];
    double binsize2=ptBins[2]-ptBins[1];
    double binsize3=ptBins[3]-ptBins[2];
    double binsize4=ptBins[4]-ptBins[3];
  

    TFile*file0_Data=new TFile(Form("ResultsBplus/CutId%d/SigmaBplusCutId%d_Step0_isData1.root",variationoption,variationoption));
    TFile*file1_Data=new TFile(Form("ResultsBplus/CutId%d/SigmaBplusCutId%d_Step1_isData1.root",variationoption,variationoption));
    TFile*file2_Data=new TFile(Form("ResultsBplus/CutId%d/SigmaBplusCutId%d_Step2_isData1.root",variationoption,variationoption));
    TFile*file3_Data=new TFile(Form("ResultsBplus/CutId%d/SigmaBplusCutId%d_Step3_isData1.root",variationoption,variationoption));

    TFile*file0_MC=new TFile(Form("ResultsBplus/CutId%d/SigmaBplusCutId%d_Step0_isData0.root",variationoption,variationoption));
    TFile*file1_MC=new TFile(Form("ResultsBplus/CutId%d/SigmaBplusCutId%d_Step1_isData0.root",variationoption,variationoption));
    TFile*file2_MC=new TFile(Form("ResultsBplus/CutId%d/SigmaBplusCutId%d_Step2_isData0.root",variationoption,variationoption));
    TFile*file3_MC=new TFile(Form("ResultsBplus/CutId%d/SigmaBplusCutId%d_Step3_isData0.root",variationoption,variationoption));

    TH1F*hPtYieldBis_Data1=(TH1F*)file0_Data->Get("hPt");
    TH1F*hPtYieldBis_Data2=(TH1F*)file1_Data->Get("hPt");
    TH1F*hPtYieldBis_Data3=(TH1F*)file2_Data->Get("hPt");
    TH1F*hPtYieldBis_Data4=(TH1F*)file3_Data->Get("hPt");
   
    TH1F*hPtYieldBis_MC1=(TH1F*)file0_MC->Get("hPt");
    TH1F*hPtYieldBis_MC2=(TH1F*)file1_MC->Get("hPt");
    TH1F*hPtYieldBis_MC3=(TH1F*)file2_MC->Get("hPt");
    TH1F*hPtYieldBis_MC4=(TH1F*)file3_MC->Get("hPt");


    hPtYieldBis_Data1->SetName("hPtYieldBis_Data1");
    hPtYieldBis_Data2->SetName("hPtYieldBis_Data2");
    hPtYieldBis_Data3->SetName("hPtYieldBis_Data3");
    hPtYieldBis_Data4->SetName("hPtYieldBis_Data4");

    hPtYieldBis_MC1->SetName("hPtYieldBis_MC1");
    hPtYieldBis_MC2->SetName("hPtYieldBis_MC2");
    hPtYieldBis_MC3->SetName("hPtYieldBis_MC3");
    hPtYieldBis_MC4->SetName("hPtYieldBis_MC4");
    
    hPtAll_Data->SetBinContent(1,hPtYieldBis_Data1->GetBinContent(1)/binsize1);
    hPtAll_Data->SetBinContent(2,hPtYieldBis_Data2->GetBinContent(1)/binsize2);
    hPtAll_Data->SetBinContent(3,hPtYieldBis_Data3->GetBinContent(1)/binsize3);
    hPtAll_Data->SetBinContent(4,hPtYieldBis_Data4->GetBinContent(1)/binsize4);

    hPtAll_Data->SetBinError(1,hPtYieldBis_Data1->GetBinError(1)/binsize1);
    hPtAll_Data->SetBinError(2,hPtYieldBis_Data2->GetBinError(1)/binsize2);
    hPtAll_Data->SetBinError(3,hPtYieldBis_Data3->GetBinError(1)/binsize3);
    hPtAll_Data->SetBinError(4,hPtYieldBis_Data4->GetBinError(1)/binsize4);
   
    hPtAll_MC->SetBinContent(1,hPtYieldBis_MC1->GetBinContent(1)/binsize1);
    hPtAll_MC->SetBinContent(2,hPtYieldBis_MC2->GetBinContent(1)/binsize2);
    hPtAll_MC->SetBinContent(3,hPtYieldBis_MC3->GetBinContent(1)/binsize3);
    hPtAll_MC->SetBinContent(4,hPtYieldBis_MC4->GetBinContent(1)/binsize4);

    hPtAll_MC->SetBinError(1,hPtYieldBis_MC1->GetBinError(1)/binsize1);
    hPtAll_MC->SetBinError(2,hPtYieldBis_MC2->GetBinError(1)/binsize2);
    hPtAll_MC->SetBinError(3,hPtYieldBis_MC3->GetBinError(1)/binsize3);
    hPtAll_MC->SetBinError(4,hPtYieldBis_MC4->GetBinError(1)/binsize4);
      
  }


    
    
  hPtAll_Data->SetMinimum(0.01);
  hPtAll_MC->SetMinimum(0.01);
  
  double normMC=0.;
  double normData=0.;
  
  for (int i=1;i<nBins;i++){
  normMC=normMC+hPtAll_MC->GetBinContent(i);
  normData=normData+hPtAll_Data->GetBinContent(i);
  }
  hPtAll_MC->Scale(1/normMC); 
  hPtAll_Data->Scale(1/normData); 
  
  
  
  TH1D *hPtAll_DataOverMC = (TH1D*)hPtAll_Data->Clone();
  hPtAll_DataOverMC->SetName("hPtAll_DataOverMC");
  hPtAll_DataOverMC->Divide(hPtAll_MC);  
  
  TCanvas *canvasVscut=new TCanvas("canvasVscut","canvasVscut",1200,500);
  canvasVscut->Divide(2,1);
  canvasVscut->cd(1);
  

  if(variationoption==1) {
    hPtAll_Data->GetXaxis()->SetTitle("chi2cl");
    hPtAll_Data->GetYaxis()->SetTitle("dN^{yield}/d(chi2cl)");
    hPtAll_DataOverMC->GetXaxis()->SetTitle("chi2cl");
    hPtAll_DataOverMC->GetYaxis()->SetTitle("dN^{yield}/d(chi2cl) Data/MC");   
    hPtAll_Data->SetMinimum(0);
    hPtAll_Data->SetMaximum(0.5);
 
  }
   
  if(variationoption==2) {
    hPtAll_Data->GetXaxis()->SetTitle("d0/d0err");
    hPtAll_Data->GetYaxis()->SetTitle("dN^{yield}/d(d0/d0err)");
    hPtAll_DataOverMC->GetXaxis()->SetTitle("d0/d0err");
    hPtAll_DataOverMC->GetYaxis()->SetTitle("dN^{yield}/d(d0/d0err) Data/MC");
  }
  
  if(variationoption==3) {
    hPtAll_Data->GetXaxis()->SetTitle("cos(Theta)");
    hPtAll_Data->GetYaxis()->SetTitle("dN^{yield}/d(cos(Theta))");
    hPtAll_DataOverMC->GetXaxis()->SetTitle("chi2cl");
    hPtAll_DataOverMC->GetYaxis()->SetTitle("dN^{yield}/d(cos(Theta)) Data/MC");
  }
  
  if(variationoption==4) {
    hPtAll_Data->GetXaxis()->SetTitle("p^{track}_{t}");
    hPtAll_Data->GetYaxis()->SetTitle("dN^{yield}/d(p^{track}_{t})");
    hPtAll_DataOverMC->GetXaxis()->SetTitle("p^{track}_{t}");
    hPtAll_DataOverMC->GetYaxis()->SetTitle("dN^{yield}/d(p^{track}_{t}) Data/MC");
    
    hPtAll_Data->GetXaxis()->SetRangeUser(0.,20.);
    hPtAll_DataOverMC->GetXaxis()->SetRangeUser(0.,20.);
    hPtAll_Data->SetMaximum(0.5);

  }
   
  if(variationoption==5) {
    hPtAll_Data->GetXaxis()->SetTitle("p_{t}");
    hPtAll_Data->GetYaxis()->SetTitle("dN^{yield}/dp_{t}");
    hPtAll_DataOverMC->GetXaxis()->SetTitle("p_{t}");
    hPtAll_DataOverMC->GetYaxis()->SetTitle("dN^{yield}/dp_{t} Data/MC");
    canvasVscut_1->SetLogy();
  }
  
  if(variationoption==6) {
    hPtAll_Data->GetXaxis()->SetTitle("y_{LAB}");
    hPtAll_Data->GetYaxis()->SetTitle("dN^{yield}/dy_{LAB}");
    hPtAll_DataOverMC->GetXaxis()->SetTitle("y_{LAB}");
    hPtAll_DataOverMC->GetYaxis()->SetTitle("dN^{yield}/dy_{LAB} Data/MC");
    hPtAll_Data->SetMinimum(0);
    hPtAll_Data->SetMaximum(1);
  }

  hPtAll_Data->GetXaxis()->SetTitleOffset(1.);
  hPtAll_Data->GetYaxis()->SetTitleOffset(1.2);
  hPtAll_Data->GetXaxis()->SetTitleSize(0.04);
  hPtAll_Data->GetYaxis()->SetTitleSize(0.04);
  hPtAll_Data->GetXaxis()->SetTitleFont(42);
  hPtAll_Data->GetYaxis()->SetTitleFont(42);
  hPtAll_Data->GetXaxis()->SetLabelFont(42);
  hPtAll_Data->GetYaxis()->SetLabelFont(42);
  hPtAll_Data->GetXaxis()->SetLabelSize(0.035);
  hPtAll_Data->GetYaxis()->SetLabelSize(0.035);  
  
  
  hPtAll_Data->SetLineColor(1);
  hPtAll_Data->SetLineWidth(3);
  hPtAll_Data->Draw();
  hPtAll_MC->SetLineColor(2);
  hPtAll_MC->SetLineWidth(3);
  hPtAll_MC->Draw("same");
  
  TLegend *leg = new TLegend(0.4597315,0.6173362,0.8590604,0.7463002,NULL,"brNDC");
  leg->AddEntry(hPtAll_Data,"Data","pl");
  leg->AddEntry(hPtAll_MC,"MC","pl");
  leg->SetBorderSize(0);
  leg->SetFillStyle(0);
  leg->Draw();
  
  canvasVscut->cd(2);
  
  hPtAll_DataOverMC->GetXaxis()->SetTitleOffset(1.);
  hPtAll_DataOverMC->GetYaxis()->SetTitleOffset(1.2);
  hPtAll_DataOverMC->GetXaxis()->SetTitleSize(0.04);
  hPtAll_DataOverMC->GetYaxis()->SetTitleSize(0.04);
  hPtAll_DataOverMC->GetXaxis()->SetTitleFont(42);
  hPtAll_DataOverMC->GetYaxis()->SetTitleFont(42);
  hPtAll_DataOverMC->GetXaxis()->SetLabelFont(42);
  hPtAll_DataOverMC->GetYaxis()->SetLabelFont(42);
  hPtAll_DataOverMC->GetXaxis()->SetLabelSize(0.035);
  hPtAll_DataOverMC->GetYaxis()->SetLabelSize(0.035); 
  hPtAll_DataOverMC->SetLineColor(1);
  hPtAll_DataOverMC->SetLineWidth(3);
  hPtAll_DataOverMC->SetMinimum(0);
  hPtAll_DataOverMC->SetMaximum(2.);
  
  hPtAll_DataOverMC->Draw();

  
  canvasVscut->SaveAs(Form("Plots/canvasMCDataVscutId%d.pdf",variationoption));
  
  
}
void effAndSmallSF_DATA_MC_Cracks_pT2()
{
//=========Macro generated from canvas: Canvas/Canvas
//=========  (Mon Feb  8 16:36:58 2016) by ROOT version6.02/05
   TCanvas *Canvas = new TCanvas("Canvas", "Canvas",0,0,725,725);
   gStyle->SetOptFit(1);
   gStyle->SetOptStat(0);
   gStyle->SetOptTitle(0);
   Canvas->SetHighLightColor(2);
   Canvas->Range(0,0,1,1);
   Canvas->SetFillColor(0);
   Canvas->SetBorderMode(0);
   Canvas->SetBorderSize(2);
   Canvas->SetTickx(1);
   Canvas->SetTicky(1);
   Canvas->SetLeftMargin(0.15);
   Canvas->SetRightMargin(0.05);
   Canvas->SetTopMargin(0.07);
   Canvas->SetBottomMargin(0.17);
   Canvas->SetFrameFillStyle(0);
   Canvas->SetFrameBorderMode(0);
  
// ------------>Primitives in pad: pad1
   TPad *pad1 = new TPad("pad1", "pad1",0.01,0.3,0.99,0.99);
   pad1->Draw();
   pad1->cd();
   pad1->Range(-15.32432,-0.03620689,94.13513,1.17069);
   pad1->SetFillColor(0);
   pad1->SetBorderMode(0);
   pad1->SetBorderSize(2);
   pad1->SetGridx();
   pad1->SetGridy();
   pad1->SetTickx(1);
   pad1->SetTicky(1);
   pad1->SetLeftMargin(0.14);
   pad1->SetRightMargin(0.12);
   pad1->SetBottomMargin(0.03);
   pad1->SetFrameFillStyle(0);
   pad1->SetFrameBorderMode(0);
   pad1->SetFrameFillStyle(0);
   pad1->SetFrameBorderMode(0);
   
   Double_t Graph0_fx3001[3] = {
   13.5,
   25,
   55};
   Double_t Graph0_fy3001[3] = {
   0.9799,
   0.9781,
   0.978};
   Double_t Graph0_felx3001[3] = {
   6.5,
   5,
   25};
   Double_t Graph0_fely3001[3] = {
   0.002,
   0.0011,
   0.0004};
   Double_t Graph0_fehx3001[3] = {
   6.5,
   5,
   25};
   Double_t Graph0_fehy3001[3] = {
   0.002,
   0.0011,
   0.0004};
   TGraphAsymmErrors *grae = new TGraphAsymmErrors(3,Graph0_fx3001,Graph0_fy3001,Graph0_felx3001,Graph0_fehx3001,Graph0_fely3001,Graph0_fehy3001);
   grae->SetName("Graph0");
   grae->SetTitle("TGraphAsymmErrors for MC efficiencies");

   Int_t ci;      // for color index setting
   TColor *color; // for color definition with alpha
   ci = TColor::GetColor("#99ccff");
   grae->SetFillColor(ci);

   ci = TColor::GetColor("#3399ff");
   grae->SetLineColor(ci);

   ci = TColor::GetColor("#3399ff");
   grae->SetMarkerColor(ci);
   grae->SetMarkerStyle(22);
   grae->SetMarkerSize(0.7);
   
   TH1F *Graph_TH1F3001 = new TH1F("Graph_TH1F3001","TH1F histogram",100,0,81);
   Graph_TH1F3001->SetMinimum(0);
   Graph_TH1F3001->SetMaximum(1.05);
   Graph_TH1F3001->SetFillStyle(0);
   Graph_TH1F3001->SetLineStyle(0);
   Graph_TH1F3001->SetMarkerStyle(20);
   Graph_TH1F3001->GetXaxis()->SetLabelFont(42);
   Graph_TH1F3001->GetXaxis()->SetLabelOffset(0.007);
   Graph_TH1F3001->GetXaxis()->SetLabelSize(0);
   Graph_TH1F3001->GetXaxis()->SetTitleSize(0.06);
   Graph_TH1F3001->GetXaxis()->SetTitleFont(42);
   Graph_TH1F3001->GetYaxis()->SetTitle("SIP efficiency");
   Graph_TH1F3001->GetYaxis()->SetLabelFont(42);
   Graph_TH1F3001->GetYaxis()->SetLabelOffset(0.007);
   Graph_TH1F3001->GetYaxis()->SetLabelSize(0.05);
   Graph_TH1F3001->GetYaxis()->SetTitleSize(0.06);
   Graph_TH1F3001->GetYaxis()->SetTitleOffset(0.85);
   Graph_TH1F3001->GetYaxis()->SetTitleFont(42);
   Graph_TH1F3001->GetZaxis()->SetLabelFont(42);
   Graph_TH1F3001->GetZaxis()->SetLabelOffset(0.007);
   Graph_TH1F3001->GetZaxis()->SetLabelSize(0.05);
   Graph_TH1F3001->GetZaxis()->SetTitleSize(0.06);
   Graph_TH1F3001->GetZaxis()->SetTitleFont(42);
   grae->SetHistogram(Graph_TH1F3001);
   
   grae->Draw("a2");
   
   Double_t Graph0_fx3002[3] = {
   13.5,
   25,
   55};
   Double_t Graph0_fy3002[3] = {
   0.9799,
   0.9781,
   0.978};
   Double_t Graph0_felx3002[3] = {
   6.5,
   5,
   25};
   Double_t Graph0_fely3002[3] = {
   0.002,
   0.0011,
   0.0004};
   Double_t Graph0_fehx3002[3] = {
   6.5,
   5,
   25};
   Double_t Graph0_fehy3002[3] = {
   0.002,
   0.0011,
   0.0004};
   grae = new TGraphAsymmErrors(3,Graph0_fx3002,Graph0_fy3002,Graph0_felx3002,Graph0_fehx3002,Graph0_fely3002,Graph0_fehy3002);
   grae->SetName("Graph0");
   grae->SetTitle("TGraphAsymmErrors for MC efficiencies");

   ci = TColor::GetColor("#99ccff");
   grae->SetFillColor(ci);

   ci = TColor::GetColor("#3399ff");
   grae->SetLineColor(ci);

   ci = TColor::GetColor("#3399ff");
   grae->SetMarkerColor(ci);
   grae->SetMarkerStyle(22);
   grae->SetMarkerSize(0.7);
   
   TH1F *Graph_Graph_TH1F30013002 = new TH1F("Graph_Graph_TH1F30013002","TH1F histogram",100,0,81);
   Graph_Graph_TH1F30013002->SetMinimum(0);
   Graph_Graph_TH1F30013002->SetMaximum(1.05);
   Graph_Graph_TH1F30013002->SetFillStyle(0);
   Graph_Graph_TH1F30013002->SetLineStyle(0);
   Graph_Graph_TH1F30013002->SetMarkerStyle(20);
   Graph_Graph_TH1F30013002->GetXaxis()->SetLabelFont(42);
   Graph_Graph_TH1F30013002->GetXaxis()->SetLabelOffset(0.007);
   Graph_Graph_TH1F30013002->GetXaxis()->SetLabelSize(0);
   Graph_Graph_TH1F30013002->GetXaxis()->SetTitleSize(0.06);
   Graph_Graph_TH1F30013002->GetXaxis()->SetTitleFont(42);
   Graph_Graph_TH1F30013002->GetYaxis()->SetTitle("SIP efficiency");
   Graph_Graph_TH1F30013002->GetYaxis()->SetLabelFont(42);
   Graph_Graph_TH1F30013002->GetYaxis()->SetLabelOffset(0.007);
   Graph_Graph_TH1F30013002->GetYaxis()->SetLabelSize(0.05);
   Graph_Graph_TH1F30013002->GetYaxis()->SetTitleSize(0.06);
   Graph_Graph_TH1F30013002->GetYaxis()->SetTitleOffset(0.85);
   Graph_Graph_TH1F30013002->GetYaxis()->SetTitleFont(42);
   Graph_Graph_TH1F30013002->GetZaxis()->SetLabelFont(42);
   Graph_Graph_TH1F30013002->GetZaxis()->SetLabelOffset(0.007);
   Graph_Graph_TH1F30013002->GetZaxis()->SetLabelSize(0.05);
   Graph_Graph_TH1F30013002->GetZaxis()->SetTitleSize(0.06);
   Graph_Graph_TH1F30013002->GetZaxis()->SetTitleFont(42);
   grae->SetHistogram(Graph_Graph_TH1F30013002);
   
   grae->Draw("p");
   
   Double_t Graph1_fx3003[3] = {
   13.5,
   25,
   55};
   Double_t Graph1_fy3003[3] = {
   0.974,
   0.959,
   0.965};
   Double_t Graph1_felx3003[3] = {
   6.5,
   5,
   25};
   Double_t Graph1_fely3003[3] = {
   0.0035,
   0.0013,
   0.0007};
   Double_t Graph1_fehx3003[3] = {
   6.5,
   5,
   25};
   Double_t Graph1_fehy3003[3] = {
   0.0035,
   0.0013,
   0.0007};
   grae = new TGraphAsymmErrors(3,Graph1_fx3003,Graph1_fy3003,Graph1_felx3003,Graph1_fehx3003,Graph1_fely3003,Graph1_fehy3003);
   grae->SetName("Graph1");
   grae->SetTitle("TGraphAsymmErrors for Data efficiencies");
   grae->SetFillColor(1);
   grae->SetMarkerStyle(9);
   grae->SetMarkerSize(0.7);
   
   TH1F *Graph_Graph3003 = new TH1F("Graph_Graph3003","TGraphAsymmErrors for Data efficiencies",100,0,87.3);
   Graph_Graph3003->SetMinimum(0.95572);
   Graph_Graph3003->SetMaximum(0.97948);
   Graph_Graph3003->SetDirectory(0);
   Graph_Graph3003->SetStats(0);
   Graph_Graph3003->SetFillStyle(0);
   Graph_Graph3003->SetLineStyle(0);
   Graph_Graph3003->SetMarkerStyle(20);
   Graph_Graph3003->GetXaxis()->SetLabelFont(42);
   Graph_Graph3003->GetXaxis()->SetLabelOffset(0.007);
   Graph_Graph3003->GetXaxis()->SetLabelSize(0.05);
   Graph_Graph3003->GetXaxis()->SetTitleSize(0.06);
   Graph_Graph3003->GetXaxis()->SetTitleFont(42);
   Graph_Graph3003->GetYaxis()->SetLabelFont(42);
   Graph_Graph3003->GetYaxis()->SetLabelOffset(0.007);
   Graph_Graph3003->GetYaxis()->SetLabelSize(0.05);
   Graph_Graph3003->GetYaxis()->SetTitleSize(0.06);
   Graph_Graph3003->GetYaxis()->SetTitleOffset(0.85);
   Graph_Graph3003->GetYaxis()->SetTitleFont(42);
   Graph_Graph3003->GetZaxis()->SetLabelFont(42);
   Graph_Graph3003->GetZaxis()->SetLabelOffset(0.007);
   Graph_Graph3003->GetZaxis()->SetLabelSize(0.05);
   Graph_Graph3003->GetZaxis()->SetTitleSize(0.06);
   Graph_Graph3003->GetZaxis()->SetTitleFont(42);
   grae->SetHistogram(Graph_Graph3003);
   
   grae->Draw("p");
   
   TLegend *leg = new TLegend(0.63,0.2,0.87,0.33,NULL,"brNDC");
   leg->SetBorderSize(0);
   leg->SetTextFont(62);
   leg->SetTextSize(0.03);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(1001);
   TLegendEntry *entry=leg->AddEntry("Graph1","Data","p");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(9);
   entry->SetMarkerSize(0.7);
   entry->SetTextFont(62);
   entry=leg->AddEntry("Graph0","Simulation","fp");

   ci = TColor::GetColor("#99ccff");
   entry->SetFillColor(ci);
   entry->SetFillStyle(1001);

   ci = TColor::GetColor("#3399ff");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);

   ci = TColor::GetColor("#3399ff");
   entry->SetMarkerColor(ci);
   entry->SetMarkerStyle(22);
   entry->SetMarkerSize(0.7);
   entry->SetTextFont(62);
   leg->Draw();
   
   TPaveText *pt = new TPaveText(0.14,0.94,0.89,0.99,"brNDC");
   pt->SetBorderSize(0);
   pt->SetFillStyle(0);
   pt->SetTextAlign(12);
   pt->SetTextSize(0.03);
   TText *AText = pt->AddText(0.01,0.3,"CMS Preliminary");
   AText = pt->AddText(0.7,0.3,"#sqrt{s} = 13 TeV, L = 2.26 fb^{-1}");
   pt->Draw();
      tex = new TLatex(0.67,0.4,"Z #rightarrow e^{+} e^{-}");
tex->SetNDC();
   tex->SetTextSize(0.03);
   tex->SetLineWidth(2);
   tex->Draw();
      tex = new TLatex(0.63,0.35," Crack probes");
tex->SetNDC();
   tex->SetTextSize(0.03);
   tex->SetLineWidth(2);
   tex->Draw();
   pad1->Modified();
   Canvas->cd();
  
// ------------>Primitives in pad: pad2
   TPad *pad2 = new TPad("pad2", "pad2",0.01,0.01,0.99,0.3);
   pad2->Draw();
   pad2->cd();
   pad2->Range(-15.32432,0.4915493,94.13513,1.125352);
   pad2->SetFillColor(0);
   pad2->SetBorderMode(0);
   pad2->SetBorderSize(2);
   pad2->SetGridx();
   pad2->SetGridy();
   pad2->SetTickx(1);
   pad2->SetTicky(1);
   pad2->SetLeftMargin(0.14);
   pad2->SetRightMargin(0.12);
   pad2->SetTopMargin(0.04);
   pad2->SetBottomMargin(0.25);
   pad2->SetFrameFillStyle(0);
   pad2->SetFrameBorderMode(0);
   pad2->SetFrameFillStyle(0);
   pad2->SetFrameBorderMode(0);
   
   Double_t Graph0_fx3004[3] = {
   13.5,
   25,
   55};
   Double_t Graph0_fy3004[3] = {
   0.994,
   0.9805,
   0.9866};
   Double_t Graph0_felx3004[3] = {
   6.5,
   5,
   25};
   Double_t Graph0_fely3004[3] = {
   0.0041,
   0.0133,
   0.0009};
   Double_t Graph0_fehx3004[3] = {
   6.5,
   5,
   25};
   Double_t Graph0_fehy3004[3] = {
   0.0041,
   0.0133,
   0.0009};
   grae = new TGraphAsymmErrors(3,Graph0_fx3004,Graph0_fy3004,Graph0_felx3004,Graph0_fehx3004,Graph0_fely3004,Graph0_fehy3004);
   grae->SetName("Graph0");
   grae->SetTitle("TGraphAsymmErrors for scale factors");

   ci = TColor::GetColor("#99ccff");
   grae->SetFillColor(ci);

   ci = TColor::GetColor("#3399ff");
   grae->SetLineColor(ci);

   ci = TColor::GetColor("#3399ff");
   grae->SetMarkerColor(ci);
   grae->SetMarkerSize(0.7);
   
   TH1F *Graph_Small TH1F3004 = new TH1F("Graph_Small TH1F3004","Small TH1F histogram",100,0,81);
   Graph_Small TH1F3004->SetMinimum(0.65);
   Graph_Small TH1F3004->SetMaximum(1.1);
   Graph_Small TH1F3004->SetFillStyle(0);
   Graph_Small TH1F3004->SetLineStyle(0);
   Graph_Small TH1F3004->SetMarkerStyle(20);
   Graph_Small TH1F3004->GetXaxis()->SetTitle("p_{T} [GeV]");
   Graph_Small TH1F3004->GetXaxis()->SetLabelFont(42);
   Graph_Small TH1F3004->GetXaxis()->SetLabelOffset(0.007);
   Graph_Small TH1F3004->GetXaxis()->SetLabelSize(0.08);
   Graph_Small TH1F3004->GetXaxis()->SetTitleSize(0.08);
   Graph_Small TH1F3004->GetXaxis()->SetTitleFont(42);
   Graph_Small TH1F3004->GetYaxis()->SetLabelFont(42);
   Graph_Small TH1F3004->GetYaxis()->SetLabelOffset(0.007);
   Graph_Small TH1F3004->GetYaxis()->SetLabelSize(0.08);
   Graph_Small TH1F3004->GetYaxis()->SetTitleSize(0.08);
   Graph_Small TH1F3004->GetYaxis()->SetTitleOffset(0.75);
   Graph_Small TH1F3004->GetYaxis()->SetTitleFont(42);
   Graph_Small TH1F3004->GetZaxis()->SetLabelFont(42);
   Graph_Small TH1F3004->GetZaxis()->SetLabelOffset(0.007);
   Graph_Small TH1F3004->GetZaxis()->SetLabelSize(0.05);
   Graph_Small TH1F3004->GetZaxis()->SetTitleSize(0.06);
   Graph_Small TH1F3004->GetZaxis()->SetTitleFont(42);
   grae->SetHistogram(Graph_Small TH1F3004);
   
   grae->Draw("a2");
   
   Double_t Graph0_fx3005[3] = {
   13.5,
   25,
   55};
   Double_t Graph0_fy3005[3] = {
   0.994,
   0.9805,
   0.9866};
   Double_t Graph0_felx3005[3] = {
   6.5,
   5,
   25};
   Double_t Graph0_fely3005[3] = {
   0.0041,
   0.0133,
   0.0009};
   Double_t Graph0_fehx3005[3] = {
   6.5,
   5,
   25};
   Double_t Graph0_fehy3005[3] = {
   0.0041,
   0.0133,
   0.0009};
   grae = new TGraphAsymmErrors(3,Graph0_fx3005,Graph0_fy3005,Graph0_felx3005,Graph0_fehx3005,Graph0_fely3005,Graph0_fehy3005);
   grae->SetName("Graph0");
   grae->SetTitle("TGraphAsymmErrors for scale factors");

   ci = TColor::GetColor("#99ccff");
   grae->SetFillColor(ci);

   ci = TColor::GetColor("#3399ff");
   grae->SetLineColor(ci);

   ci = TColor::GetColor("#3399ff");
   grae->SetMarkerColor(ci);
   grae->SetMarkerSize(0.7);
   
   TH1F *Graph_Graph_Small TH1F30043005 = new TH1F("Graph_Graph_Small TH1F30043005","Small TH1F histogram",100,0,81);
   Graph_Graph_Small TH1F30043005->SetMinimum(0.65);
   Graph_Graph_Small TH1F30043005->SetMaximum(1.1);
   Graph_Graph_Small TH1F30043005->SetFillStyle(0);
   Graph_Graph_Small TH1F30043005->SetLineStyle(0);
   Graph_Graph_Small TH1F30043005->SetMarkerStyle(20);
   Graph_Graph_Small TH1F30043005->GetXaxis()->SetTitle("p_{T} [GeV]");
   Graph_Graph_Small TH1F30043005->GetXaxis()->SetLabelFont(42);
   Graph_Graph_Small TH1F30043005->GetXaxis()->SetLabelOffset(0.007);
   Graph_Graph_Small TH1F30043005->GetXaxis()->SetLabelSize(0.08);
   Graph_Graph_Small TH1F30043005->GetXaxis()->SetTitleSize(0.08);
   Graph_Graph_Small TH1F30043005->GetXaxis()->SetTitleFont(42);
   Graph_Graph_Small TH1F30043005->GetYaxis()->SetLabelFont(42);
   Graph_Graph_Small TH1F30043005->GetYaxis()->SetLabelOffset(0.007);
   Graph_Graph_Small TH1F30043005->GetYaxis()->SetLabelSize(0.08);
   Graph_Graph_Small TH1F30043005->GetYaxis()->SetTitleSize(0.08);
   Graph_Graph_Small TH1F30043005->GetYaxis()->SetTitleOffset(0.75);
   Graph_Graph_Small TH1F30043005->GetYaxis()->SetTitleFont(42);
   Graph_Graph_Small TH1F30043005->GetZaxis()->SetLabelFont(42);
   Graph_Graph_Small TH1F30043005->GetZaxis()->SetLabelOffset(0.007);
   Graph_Graph_Small TH1F30043005->GetZaxis()->SetLabelSize(0.05);
   Graph_Graph_Small TH1F30043005->GetZaxis()->SetTitleSize(0.06);
   Graph_Graph_Small TH1F30043005->GetZaxis()->SetTitleFont(42);
   grae->SetHistogram(Graph_Graph_Small TH1F30043005);
   
   grae->Draw("p");
   pad2->Modified();
   Canvas->cd();
   Canvas->Modified();
   Canvas->cd();
   Canvas->SetSelected(Canvas);
}
void EnergyDependentCorrections() {

  gStyle->SetOptStat(0);
  gStyle->SetTitleSize(0.08,"t");
  gStyle->SetPadLeftMargin(0.15);
  //gStyle->SetPadRightMargin(0.15);
  gStyle->SetPadBottomMargin(0.15);
  gStyle->SetTitleYSize(0.05);
  gStyle->SetTitleYOffset(1.4);
  gStyle->SetTitleXSize(0.05);
  gStyle->SetTitleXOffset(1.2);
  gStyle->SetTitleSize(0.04,"Z");
  gStyle->SetTitleOffset(1.6,"Z");
  gStyle->SetLabelSize(0.04,"xyz");
  gStyle->SetLegendBorderSize(0);
  gStyle->SetFillStyle(0);

  // read in the corrections and plot their deltaA/A for each bin
  // This can be done for both theory and MC

  //Int_t octmin = year==2011?0:60;
  //Int_t octmax = year==2011?59:121;

  std::vector <Double_t> energy;
  std::vector <Double_t> UnCorr2011;
  std::vector <Double_t> TheoryCorr2011;
  std::vector <Double_t> AllCorr2011;

  std::vector <Double_t> UnCorr2012;
  std::vector <Double_t> TheoryCorr2012;
  std::vector <Double_t> AllCorr2012;

  Double_t en, val, err;
  
  std::ifstream infile(TString::Format("%s/Asymmetries/UnCorr_OctetAsymmetries_AnaChC_Octets_%i-%i_BinByBin.txt",getenv("ANALYSIS_RESULTS"),0,59));
  
  while (infile >> en >> val >> err ) {
    energy.push_back(en);
    UnCorr2011.push_back(val);
  }

  infile.close();

  infile.open(TString::Format("%s/Asymmetries/DeltaTheoryOnly_OctetAsymmetries_AnaChC_Octets_%i-%i_BinByBin.txt",getenv("ANALYSIS_RESULTS"),0,59));
  
  while (infile >> en >> val >> err) {
    TheoryCorr2011.push_back(val);
  }

  infile.close();

  infile.open(TString::Format("%s/Asymmetries/AllCorr_OctetAsymmetries_AnaChC_Octets_%i-%i_BinByBin.txt",getenv("ANALYSIS_RESULTS"),0,59));
  
  while (infile >> en >> val >> err) {
    AllCorr2011.push_back(val);
  }

  infile.close();
    
  infile.open(TString::Format("%s/Asymmetries/UnCorr_OctetAsymmetries_AnaChC_Octets_%i-%i_BinByBin.txt",getenv("ANALYSIS_RESULTS"),60,121));
  
  while (infile >> en >> val >> err ) {
    energy.push_back(en);
    UnCorr2012.push_back(val);
  }

  infile.close();

  infile.open(TString::Format("%s/Asymmetries/DeltaTheoryOnly_OctetAsymmetries_AnaChC_Octets_%i-%i_BinByBin.txt",getenv("ANALYSIS_RESULTS"),60,121));
  
  while (infile >> en >> val >> err) {
    TheoryCorr2012.push_back(val);
  }

  infile.close();

  infile.open(TString::Format("%s/Asymmetries/AllCorr_OctetAsymmetries_AnaChC_Octets_%i-%i_BinByBin.txt",getenv("ANALYSIS_RESULTS"),60,121));
  
  while (infile >> en >> val >> err) {
    AllCorr2012.push_back(val);
  }

  infile.close();


  
  
  
  

  std::vector <Double_t> en_Th;
  std::vector <Double_t> corr_Th;
  std::vector <Double_t> en_MC2011;
  std::vector <Double_t> corr_MC2011;
  std::vector <Double_t> en_MC2012;
  std::vector <Double_t> corr_MC2012;
  
  
  for (int i=2;i<80;++i) {

    if (UnCorr2011[i]!=0.) en_Th.push_back(energy[i]), corr_Th.push_back(100.*(TheoryCorr2011[i]/UnCorr2011[i]-1.));
    if (TheoryCorr2011[i]!=0.) en_MC2011.push_back(energy[i]), corr_MC2011.push_back(100.*(AllCorr2011[i]/TheoryCorr2011[i]-1.));
    if (TheoryCorr2012[i]!=0.) en_MC2012.push_back(energy[i]), corr_MC2012.push_back(100.*(AllCorr2012[i]/TheoryCorr2012[i]-1.));
  }

  

  TCanvas *c2 = new TCanvas("c2","c2",1200,800);
  c2->Divide(2,1);

  c2->cd(1);

  TGraph *gTheory = new TGraph(en_Th.size(),&en_Th[0],&corr_Th[0]);
  gTheory->SetTitle("Theory Corrections vs. Energy");
  gTheory->SetMarkerStyle(kFullCircle);
  gTheory->SetMinimum(-5.);
  gTheory->SetMaximum(0.);
  gTheory->SetLineWidth(3);
  gTheory->SetLineColor(kBlack);
  gTheory->GetYaxis()->SetTitle("#DeltaA/A (%)");
  gTheory->GetYaxis()->CenterTitle();
  gTheory->GetXaxis()->SetTitle("Energy (keV)");
  gTheory->GetXaxis()->CenterTitle();
  gTheory->Draw("AL");
  
  c2->cd(2);

  TMultiGraph *mg = new TMultiGraph();
  mg->SetTitle("MC Corrections vs. Energy");
  
  TGraph *gMC2011 = new TGraph(en_MC2011.size(),&en_MC2011[0],&corr_MC2011[0]);
  gMC2011->SetMarkerStyle(kFullCircle);
  //gMC2011->SetMinimum(-10.);
  //gMC2011->SetMaximum(6.);
  gMC2011->SetLineWidth(3);
  gMC2011->SetLineColor(kBlue);
  gMC2011->GetYaxis()->SetTitle("#DeltaA/A (%)");
  gMC2011->GetYaxis()->CenterTitle();
  gMC2011->GetXaxis()->SetTitle("Energy (keV)");
  gMC2011->GetXaxis()->CenterTitle();
  //gMC2011->Draw("AC");

  TGraph *gMC2012 = new TGraph(en_MC2012.size(),&en_MC2012[0],&corr_MC2012[0]);
  gMC2012->SetMarkerStyle(kFullCircle);
  //gMC2012->SetMinimum(-10.);
  //gMC2012->SetMaximum(6.);
  gMC2012->SetLineWidth(3);
  gMC2012->SetLineColor(kGreen);
  //gMC2012->GetYaxis()->SetTitle("#DeltaA/A (%)");
  //gMC2012->GetYaxis()->CenterTitle();
  //gMC2012->GetXaxis()->SetTitle("Energy (keV)");
  //gMC2012->GetXaxis()->CenterTitle();
  //gMC2012->Draw("AC");
  
  mg->Add(gMC2011);
  mg->Add(gMC2012);
  mg->SetMinimum(-8.);
  mg->SetMaximum(6.);
  
  mg->Draw("AC");
  mg->GetYaxis()->SetTitle("#DeltaA/A (%)");
  mg->GetYaxis()->CenterTitle();
  mg->GetXaxis()->SetTitle("Energy (keV)");
  mg->GetXaxis()->CenterTitle();
  gPad->Modified();

  TLegend *leg = new TLegend(0.55,0.75,0.85,0.85);
  leg->AddEntry(gMC2011,"2011-2012","l");
  leg->AddEntry(gMC2012,"2012-2013","l");
  leg->SetTextSize(0.05);
  leg->Draw("SAME");
}
Example #22
0
void bkgnd_iso_velo()
{
//=========Macro generated from canvas: backgroundiso_max2_set1_velnb/backgroundiso_max2_set1_velnb
//=========  (Wed Mar 29 17:53:22 2017) by ROOT version6.04/02
   TCanvas *backgroundiso_max2_set1_velnb = new TCanvas("backgroundiso_max2_set1_velnb", "backgroundiso_max2_set1_velnb",84,51,400,300);
   gStyle->SetOptStat(0);
   gStyle->SetOptTitle(0);
   backgroundiso_max2_set1_velnb->Range(-0.8534979,-0.121519,0.9572016,0.6379747);
   backgroundiso_max2_set1_velnb->SetFillColor(0);
   backgroundiso_max2_set1_velnb->SetBorderMode(0);
   backgroundiso_max2_set1_velnb->SetBorderSize(2);
   backgroundiso_max2_set1_velnb->SetTickx(1);
   backgroundiso_max2_set1_velnb->SetTicky(1);
   backgroundiso_max2_set1_velnb->SetLeftMargin(0.14);
   backgroundiso_max2_set1_velnb->SetRightMargin(0.05);
   backgroundiso_max2_set1_velnb->SetTopMargin(0.05);
   backgroundiso_max2_set1_velnb->SetBottomMargin(0.16);
   backgroundiso_max2_set1_velnb->SetFrameLineWidth(2);
   backgroundiso_max2_set1_velnb->SetFrameBorderMode(0);
   backgroundiso_max2_set1_velnb->SetFrameLineWidth(2);
   backgroundiso_max2_set1_velnb->SetFrameBorderMode(0);
   
   TH1F *dataset_data_2012__iso_max2_set1_velnb__57 = new TH1F("dataset_data_2012__iso_max2_set1_velnb__57","  ",15,-1,1);
   dataset_data_2012__iso_max2_set1_velnb__57->SetBinContent(1,6.112469e-05);
   dataset_data_2012__iso_max2_set1_velnb__57->SetBinContent(2,6.112469e-05);
   dataset_data_2012__iso_max2_set1_velnb__57->SetBinContent(3,6.112469e-05);
   dataset_data_2012__iso_max2_set1_velnb__57->SetBinContent(4,6.112469e-05);
   dataset_data_2012__iso_max2_set1_velnb__57->SetBinContent(5,0.0004278729);
   dataset_data_2012__iso_max2_set1_velnb__57->SetBinContent(6,0.001344743);
   dataset_data_2012__iso_max2_set1_velnb__57->SetBinContent(7,0.003178484);
   dataset_data_2012__iso_max2_set1_velnb__57->SetBinContent(8,0.03893643);
   dataset_data_2012__iso_max2_set1_velnb__57->SetBinContent(9,0.2641809);
   dataset_data_2012__iso_max2_set1_velnb__57->SetBinContent(10,0.4991443);
   dataset_data_2012__iso_max2_set1_velnb__57->SetBinContent(11,0.1844132);
   dataset_data_2012__iso_max2_set1_velnb__57->SetBinContent(12,0.00806846);
   dataset_data_2012__iso_max2_set1_velnb__57->SetBinContent(13,6.112469e-05);
   dataset_data_2012__iso_max2_set1_velnb__57->SetBinError(1,6.112469e-05);
   dataset_data_2012__iso_max2_set1_velnb__57->SetBinError(2,6.112469e-05);
   dataset_data_2012__iso_max2_set1_velnb__57->SetBinError(3,6.112469e-05);
   dataset_data_2012__iso_max2_set1_velnb__57->SetBinError(4,6.112469e-05);
   dataset_data_2012__iso_max2_set1_velnb__57->SetBinError(5,0.0001617207);
   dataset_data_2012__iso_max2_set1_velnb__57->SetBinError(6,0.0002867002);
   dataset_data_2012__iso_max2_set1_velnb__57->SetBinError(7,0.0004407764);
   dataset_data_2012__iso_max2_set1_velnb__57->SetBinError(8,0.001542718);
   dataset_data_2012__iso_max2_set1_velnb__57->SetBinError(9,0.004018455);
   dataset_data_2012__iso_max2_set1_velnb__57->SetBinError(10,0.005523589);
   dataset_data_2012__iso_max2_set1_velnb__57->SetBinError(11,0.00335741);
   dataset_data_2012__iso_max2_set1_velnb__57->SetBinError(12,0.0007022693);
   dataset_data_2012__iso_max2_set1_velnb__57->SetBinError(13,6.112469e-05);
   dataset_data_2012__iso_max2_set1_velnb__57->SetMinimum(0);
   dataset_data_2012__iso_max2_set1_velnb__57->SetMaximum(0.6);
   dataset_data_2012__iso_max2_set1_velnb__57->SetEntries(16360);
   dataset_data_2012__iso_max2_set1_velnb__57->SetStats(0);

   Int_t ci;      // for color index setting
   TColor *color; // for color definition with alpha
   ci = TColor::GetColor("#006600");
   dataset_data_2012__iso_max2_set1_velnb__57->SetLineColor(ci);
   dataset_data_2012__iso_max2_set1_velnb__57->SetLineWidth(2);

   ci = TColor::GetColor("#006600");
   dataset_data_2012__iso_max2_set1_velnb__57->SetMarkerColor(ci);
   dataset_data_2012__iso_max2_set1_velnb__57->SetMarkerStyle(20);
   dataset_data_2012__iso_max2_set1_velnb__57->GetXaxis()->SetTitle("VELO track isolation");
   dataset_data_2012__iso_max2_set1_velnb__57->GetXaxis()->SetRange(4,14);
   dataset_data_2012__iso_max2_set1_velnb__57->GetXaxis()->SetNdivisions(505);
   dataset_data_2012__iso_max2_set1_velnb__57->GetXaxis()->SetLabelFont(132);
   dataset_data_2012__iso_max2_set1_velnb__57->GetXaxis()->SetLabelOffset(0.01);
   dataset_data_2012__iso_max2_set1_velnb__57->GetXaxis()->SetLabelSize(0.06);
   dataset_data_2012__iso_max2_set1_velnb__57->GetXaxis()->SetTitleSize(0.072);
   dataset_data_2012__iso_max2_set1_velnb__57->GetXaxis()->SetTitleOffset(0.95);
   dataset_data_2012__iso_max2_set1_velnb__57->GetXaxis()->SetTitleFont(132);
   dataset_data_2012__iso_max2_set1_velnb__57->GetYaxis()->SetTitle("Arbitrary units");
   dataset_data_2012__iso_max2_set1_velnb__57->GetYaxis()->SetLabelFont(132);
   dataset_data_2012__iso_max2_set1_velnb__57->GetYaxis()->SetLabelOffset(0.01);
   dataset_data_2012__iso_max2_set1_velnb__57->GetYaxis()->SetLabelSize(0.06);
   dataset_data_2012__iso_max2_set1_velnb__57->GetYaxis()->SetTitleSize(0.072);
   dataset_data_2012__iso_max2_set1_velnb__57->GetYaxis()->SetTitleOffset(0.95);
   dataset_data_2012__iso_max2_set1_velnb__57->GetYaxis()->SetTitleFont(132);
   dataset_data_2012__iso_max2_set1_velnb__57->GetZaxis()->SetLabelFont(132);
   dataset_data_2012__iso_max2_set1_velnb__57->GetZaxis()->SetLabelSize(0.06);
   dataset_data_2012__iso_max2_set1_velnb__57->GetZaxis()->SetTitleSize(0.072);
   dataset_data_2012__iso_max2_set1_velnb__57->GetZaxis()->SetTitleOffset(1.2);
   dataset_data_2012__iso_max2_set1_velnb__57->GetZaxis()->SetTitleFont(132);
   dataset_data_2012__iso_max2_set1_velnb__57->Draw("E1");
   
   TH1F *dataset_data_2011__iso_max2_set1_velnb__58 = new TH1F("dataset_data_2011__iso_max2_set1_velnb__58","Histogram of dataset_data_2011__iso_max2_set1_velnb",15,-1,1);
   dataset_data_2011__iso_max2_set1_velnb__58->SetBinContent(2,0.0001461347);
   dataset_data_2011__iso_max2_set1_velnb__58->SetBinContent(4,0.0001461347);
   dataset_data_2011__iso_max2_set1_velnb__58->SetBinContent(6,0.000584539);
   dataset_data_2011__iso_max2_set1_velnb__58->SetBinContent(7,0.003214964);
   dataset_data_2011__iso_max2_set1_velnb__58->SetBinContent(8,0.04647085);
   dataset_data_2011__iso_max2_set1_velnb__58->SetBinContent(9,0.2561742);
   dataset_data_2011__iso_max2_set1_velnb__58->SetBinContent(10,0.5027035);
   dataset_data_2011__iso_max2_set1_velnb__58->SetBinContent(11,0.1825223);
   dataset_data_2011__iso_max2_set1_velnb__58->SetBinContent(12,0.008037411);
   dataset_data_2011__iso_max2_set1_velnb__58->SetBinError(2,0.0001461347);
   dataset_data_2011__iso_max2_set1_velnb__58->SetBinError(4,0.0001461347);
   dataset_data_2011__iso_max2_set1_velnb__58->SetBinError(6,0.0002922695);
   dataset_data_2011__iso_max2_set1_velnb__58->SetBinError(7,0.0006854327);
   dataset_data_2011__iso_max2_set1_velnb__58->SetBinError(8,0.002605956);
   dataset_data_2011__iso_max2_set1_velnb__58->SetBinError(9,0.006118492);
   dataset_data_2011__iso_max2_set1_velnb__58->SetBinError(10,0.008571023);
   dataset_data_2011__iso_max2_set1_velnb__58->SetBinError(11,0.005164576);
   dataset_data_2011__iso_max2_set1_velnb__58->SetBinError(12,0.001083764);
   dataset_data_2011__iso_max2_set1_velnb__58->SetEntries(6843);
   dataset_data_2011__iso_max2_set1_velnb__58->SetStats(0);

   ci = TColor::GetColor("#33cc00");
   dataset_data_2011__iso_max2_set1_velnb__58->SetLineColor(ci);
   dataset_data_2011__iso_max2_set1_velnb__58->SetLineWidth(2);

   ci = TColor::GetColor("#33cc00");
   dataset_data_2011__iso_max2_set1_velnb__58->SetMarkerColor(ci);
   dataset_data_2011__iso_max2_set1_velnb__58->SetMarkerStyle(20);
   dataset_data_2011__iso_max2_set1_velnb__58->GetXaxis()->SetTitle("iso_max2_set1_velnb");
   dataset_data_2011__iso_max2_set1_velnb__58->GetXaxis()->SetRange(4,14);
   dataset_data_2011__iso_max2_set1_velnb__58->GetXaxis()->SetNdivisions(505);
   dataset_data_2011__iso_max2_set1_velnb__58->GetXaxis()->SetLabelFont(132);
   dataset_data_2011__iso_max2_set1_velnb__58->GetXaxis()->SetLabelOffset(0.01);
   dataset_data_2011__iso_max2_set1_velnb__58->GetXaxis()->SetLabelSize(0.06);
   dataset_data_2011__iso_max2_set1_velnb__58->GetXaxis()->SetTitleSize(0.072);
   dataset_data_2011__iso_max2_set1_velnb__58->GetXaxis()->SetTitleOffset(0.95);
   dataset_data_2011__iso_max2_set1_velnb__58->GetXaxis()->SetTitleFont(132);
   dataset_data_2011__iso_max2_set1_velnb__58->GetYaxis()->SetTitle("Events / ( 0.133333 )");
   dataset_data_2011__iso_max2_set1_velnb__58->GetYaxis()->SetLabelFont(132);
   dataset_data_2011__iso_max2_set1_velnb__58->GetYaxis()->SetLabelOffset(0.01);
   dataset_data_2011__iso_max2_set1_velnb__58->GetYaxis()->SetLabelSize(0.06);
   dataset_data_2011__iso_max2_set1_velnb__58->GetYaxis()->SetTitleSize(0.072);
   dataset_data_2011__iso_max2_set1_velnb__58->GetYaxis()->SetTitleOffset(0.95);
   dataset_data_2011__iso_max2_set1_velnb__58->GetYaxis()->SetTitleFont(132);
   dataset_data_2011__iso_max2_set1_velnb__58->GetZaxis()->SetLabelFont(132);
   dataset_data_2011__iso_max2_set1_velnb__58->GetZaxis()->SetLabelSize(0.06);
   dataset_data_2011__iso_max2_set1_velnb__58->GetZaxis()->SetTitleSize(0.072);
   dataset_data_2011__iso_max2_set1_velnb__58->GetZaxis()->SetTitleOffset(1.2);
   dataset_data_2011__iso_max2_set1_velnb__58->GetZaxis()->SetTitleFont(132);
   dataset_data_2011__iso_max2_set1_velnb__58->Draw("E1SAME");
   
   TH1F *dataset_data_2015__iso_max2_set1_velnb__59 = new TH1F("dataset_data_2015__iso_max2_set1_velnb__59","Histogram of dataset_data_2015__iso_max2_set1_velnb",15,-1,1);
   dataset_data_2015__iso_max2_set1_velnb__59->SetBinContent(2,0.0002716653);
   dataset_data_2015__iso_max2_set1_velnb__59->SetBinContent(5,0.0005433306);
   dataset_data_2015__iso_max2_set1_velnb__59->SetBinContent(7,0.001629992);
   dataset_data_2015__iso_max2_set1_velnb__59->SetBinContent(8,0.04373812);
   dataset_data_2015__iso_max2_set1_velnb__59->SetBinContent(9,0.2893235);
   dataset_data_2015__iso_max2_set1_velnb__59->SetBinContent(10,0.5104591);
   dataset_data_2015__iso_max2_set1_velnb__59->SetBinContent(11,0.1507742);
   dataset_data_2015__iso_max2_set1_velnb__59->SetBinContent(12,0.003259984);
   dataset_data_2015__iso_max2_set1_velnb__59->SetBinError(2,0.0002716653);
   dataset_data_2015__iso_max2_set1_velnb__59->SetBinError(5,0.0003841928);
   dataset_data_2015__iso_max2_set1_velnb__59->SetBinError(7,0.0006654414);
   dataset_data_2015__iso_max2_set1_velnb__59->SetBinError(8,0.003447046);
   dataset_data_2015__iso_max2_set1_velnb__59->SetBinError(9,0.008865617);
   dataset_data_2015__iso_max2_set1_velnb__59->SetBinError(10,0.01177599);
   dataset_data_2015__iso_max2_set1_velnb__59->SetBinError(11,0.00640001);
   dataset_data_2015__iso_max2_set1_velnb__59->SetBinError(12,0.0009410762);
   dataset_data_2015__iso_max2_set1_velnb__59->SetEntries(3681);
   dataset_data_2015__iso_max2_set1_velnb__59->SetStats(0);

   ci = TColor::GetColor("#ff9900");
   dataset_data_2015__iso_max2_set1_velnb__59->SetLineColor(ci);
   dataset_data_2015__iso_max2_set1_velnb__59->SetLineWidth(2);

   ci = TColor::GetColor("#ff9900");
   dataset_data_2015__iso_max2_set1_velnb__59->SetMarkerColor(ci);
   dataset_data_2015__iso_max2_set1_velnb__59->SetMarkerStyle(20);
   dataset_data_2015__iso_max2_set1_velnb__59->GetXaxis()->SetTitle("iso_max2_set1_velnb");
   dataset_data_2015__iso_max2_set1_velnb__59->GetXaxis()->SetRange(4,14);
   dataset_data_2015__iso_max2_set1_velnb__59->GetXaxis()->SetNdivisions(505);
   dataset_data_2015__iso_max2_set1_velnb__59->GetXaxis()->SetLabelFont(132);
   dataset_data_2015__iso_max2_set1_velnb__59->GetXaxis()->SetLabelOffset(0.01);
   dataset_data_2015__iso_max2_set1_velnb__59->GetXaxis()->SetLabelSize(0.06);
   dataset_data_2015__iso_max2_set1_velnb__59->GetXaxis()->SetTitleSize(0.072);
   dataset_data_2015__iso_max2_set1_velnb__59->GetXaxis()->SetTitleOffset(0.95);
   dataset_data_2015__iso_max2_set1_velnb__59->GetXaxis()->SetTitleFont(132);
   dataset_data_2015__iso_max2_set1_velnb__59->GetYaxis()->SetTitle("Events / ( 0.133333 )");
   dataset_data_2015__iso_max2_set1_velnb__59->GetYaxis()->SetLabelFont(132);
   dataset_data_2015__iso_max2_set1_velnb__59->GetYaxis()->SetLabelOffset(0.01);
   dataset_data_2015__iso_max2_set1_velnb__59->GetYaxis()->SetLabelSize(0.06);
   dataset_data_2015__iso_max2_set1_velnb__59->GetYaxis()->SetTitleSize(0.072);
   dataset_data_2015__iso_max2_set1_velnb__59->GetYaxis()->SetTitleOffset(0.95);
   dataset_data_2015__iso_max2_set1_velnb__59->GetYaxis()->SetTitleFont(132);
   dataset_data_2015__iso_max2_set1_velnb__59->GetZaxis()->SetLabelFont(132);
   dataset_data_2015__iso_max2_set1_velnb__59->GetZaxis()->SetLabelSize(0.06);
   dataset_data_2015__iso_max2_set1_velnb__59->GetZaxis()->SetTitleSize(0.072);
   dataset_data_2015__iso_max2_set1_velnb__59->GetZaxis()->SetTitleOffset(1.2);
   dataset_data_2015__iso_max2_set1_velnb__59->GetZaxis()->SetTitleFont(132);
   dataset_data_2015__iso_max2_set1_velnb__59->Draw("E1SAME");
   
   TH1F *dataset_data_2016__iso_max2_set1_velnb__60 = new TH1F("dataset_data_2016__iso_max2_set1_velnb__60","Histogram of dataset_data_2016__iso_max2_set1_velnb",15,-1,1);
   dataset_data_2016__iso_max2_set1_velnb__60->SetBinContent(1,6.164468e-05);
   dataset_data_2016__iso_max2_set1_velnb__60->SetBinContent(2,6.164468e-05);
   dataset_data_2016__iso_max2_set1_velnb__60->SetBinContent(3,0.0002465787);
   dataset_data_2016__iso_max2_set1_velnb__60->SetBinContent(4,0.0003082234);
   dataset_data_2016__iso_max2_set1_velnb__60->SetBinContent(5,0.0003698681);
   dataset_data_2016__iso_max2_set1_velnb__60->SetBinContent(6,0.0001232894);
   dataset_data_2016__iso_max2_set1_velnb__60->SetBinContent(7,0.0028973);
   dataset_data_2016__iso_max2_set1_velnb__60->SetBinContent(8,0.03519911);
   dataset_data_2016__iso_max2_set1_velnb__60->SetBinContent(9,0.2823943);
   dataset_data_2016__iso_max2_set1_velnb__60->SetBinContent(10,0.525336);
   dataset_data_2016__iso_max2_set1_velnb__60->SetBinContent(11,0.1491801);
   dataset_data_2016__iso_max2_set1_velnb__60->SetBinContent(12,0.00382197);
   dataset_data_2016__iso_max2_set1_velnb__60->SetBinError(1,6.164468e-05);
   dataset_data_2016__iso_max2_set1_velnb__60->SetBinError(2,6.164468e-05);
   dataset_data_2016__iso_max2_set1_velnb__60->SetBinError(3,0.0001232894);
   dataset_data_2016__iso_max2_set1_velnb__60->SetBinError(4,0.0001378417);
   dataset_data_2016__iso_max2_set1_velnb__60->SetBinError(5,0.000150998);
   dataset_data_2016__iso_max2_set1_velnb__60->SetBinError(6,8.717874e-05);
   dataset_data_2016__iso_max2_set1_velnb__60->SetBinError(7,0.0004226146);
   dataset_data_2016__iso_max2_set1_velnb__60->SetBinError(8,0.001473037);
   dataset_data_2016__iso_max2_set1_velnb__60->SetBinError(9,0.004172302);
   dataset_data_2016__iso_max2_set1_velnb__60->SetBinError(10,0.005690709);
   dataset_data_2016__iso_max2_set1_velnb__60->SetBinError(11,0.003032517);
   dataset_data_2016__iso_max2_set1_velnb__60->SetBinError(12,0.0004853907);
   dataset_data_2016__iso_max2_set1_velnb__60->SetEntries(16222);
   dataset_data_2016__iso_max2_set1_velnb__60->SetStats(0);

   ci = TColor::GetColor("#ff3333");
   dataset_data_2016__iso_max2_set1_velnb__60->SetLineColor(ci);
   dataset_data_2016__iso_max2_set1_velnb__60->SetLineWidth(2);

   ci = TColor::GetColor("#ff3333");
   dataset_data_2016__iso_max2_set1_velnb__60->SetMarkerColor(ci);
   dataset_data_2016__iso_max2_set1_velnb__60->SetMarkerStyle(20);
   dataset_data_2016__iso_max2_set1_velnb__60->GetXaxis()->SetTitle("iso_max2_set1_velnb");
   dataset_data_2016__iso_max2_set1_velnb__60->GetXaxis()->SetRange(4,14);
   dataset_data_2016__iso_max2_set1_velnb__60->GetXaxis()->SetNdivisions(505);
   dataset_data_2016__iso_max2_set1_velnb__60->GetXaxis()->SetLabelFont(132);
   dataset_data_2016__iso_max2_set1_velnb__60->GetXaxis()->SetLabelOffset(0.01);
   dataset_data_2016__iso_max2_set1_velnb__60->GetXaxis()->SetLabelSize(0.06);
   dataset_data_2016__iso_max2_set1_velnb__60->GetXaxis()->SetTitleSize(0.072);
   dataset_data_2016__iso_max2_set1_velnb__60->GetXaxis()->SetTitleOffset(0.95);
   dataset_data_2016__iso_max2_set1_velnb__60->GetXaxis()->SetTitleFont(132);
   dataset_data_2016__iso_max2_set1_velnb__60->GetYaxis()->SetTitle("Events / ( 0.133333 )");
   dataset_data_2016__iso_max2_set1_velnb__60->GetYaxis()->SetLabelFont(132);
   dataset_data_2016__iso_max2_set1_velnb__60->GetYaxis()->SetLabelOffset(0.01);
   dataset_data_2016__iso_max2_set1_velnb__60->GetYaxis()->SetLabelSize(0.06);
   dataset_data_2016__iso_max2_set1_velnb__60->GetYaxis()->SetTitleSize(0.072);
   dataset_data_2016__iso_max2_set1_velnb__60->GetYaxis()->SetTitleOffset(0.95);
   dataset_data_2016__iso_max2_set1_velnb__60->GetYaxis()->SetTitleFont(132);
   dataset_data_2016__iso_max2_set1_velnb__60->GetZaxis()->SetLabelFont(132);
   dataset_data_2016__iso_max2_set1_velnb__60->GetZaxis()->SetLabelSize(0.06);
   dataset_data_2016__iso_max2_set1_velnb__60->GetZaxis()->SetTitleSize(0.072);
   dataset_data_2016__iso_max2_set1_velnb__60->GetZaxis()->SetTitleOffset(1.2);
   dataset_data_2016__iso_max2_set1_velnb__60->GetZaxis()->SetTitleFont(132);
   dataset_data_2016__iso_max2_set1_velnb__60->Draw("E1SAME");
   
   TLegend *leg = new TLegend(-10965.71,0.6052649,430.0176,0.8060148,NULL,"brNDC");
   leg->SetBorderSize(0);
   leg->SetTextFont(132);
   leg->SetTextSize(0.055);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(2);
   leg->SetFillColor(0);
   leg->SetFillStyle(0);
   TLegendEntry *entry=leg->AddEntry("dataset_data_2011__iso_max2_set8_lt","2011 data","L");

   ci = TColor::GetColor("#33cc00");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(2);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(132);
   entry=leg->AddEntry("dataset_data_2012__iso_max2_set8_lt","2012 data","L");

   ci = TColor::GetColor("#006600");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(2);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(132);
   entry=leg->AddEntry("dataset_data_2015__iso_max2_set8_lt","2015 data","L");

   ci = TColor::GetColor("#ff9900");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(2);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(132);
   entry=leg->AddEntry("dataset_data_2016__iso_max2_set8_lt","2016 data","L");

   ci = TColor::GetColor("#ff3333");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(2);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(132);
   leg->Draw();
   backgroundiso_max2_set1_velnb->Modified();
   backgroundiso_max2_set1_velnb->cd();
   backgroundiso_max2_set1_velnb->SetSelected(backgroundiso_max2_set1_velnb);
}
void plotTree(TTree *tree_, std::string whichfit, std::string selectString){

	// Create a map for plotting the pullsummaries:
	std::map < const char*, std::pair <double,double> > pullSummaryMap;
	int nPulls=0;

	TObjArray *l_branches = tree_->GetListOfBranches();
	int nBranches = l_branches->GetEntries();

	gStyle->SetPadTopMargin(0.01);

	TCanvas *c = new TCanvas("c","",960,800);

	std::string treename = tree_->GetName();
	c->SaveAs(Form("%s.pdf[",treename.c_str()));
	// File to store plots in 
	TFile *fOut = new TFile(Form("%s.root",treename.c_str()),"RECREATE");

	for (int iobj=0;iobj<nBranches;iobj++){

		TBranch *br =(TBranch*) l_branches->At(iobj);

		// Draw the normal histogram
		const char* name = br->GetName();

                // names with - are not allowed
                string namestr(name);
                if(namestr.find("-")!=string::npos) {
                  std::cout << "Variable " << name << " contains a bad character: -. Skipping. " << std::endl;
                  continue;
                }
		bool fitPull=false;
		bool fitPullf=false;

		bool plotLH=false;

		TGraph *gr=NULL;
		double p_mean =0;
		double p_err  =0;

		int nToysInTree = tree_->GetEntries();
		// Find out if paramter is fitted value or constraint term
		bool isFitted = findNuisancePre(name);
		if (doPull && isFitted){
			
			p_mean = bfvals_[name].first;	// toy constrainits thrown about best fit to data
			if(namestr.find("n_exp")==string::npos) p_err  = prevals_[name].second; // uncertainties taken from card
			std::cout << "******* "<< name << " *******"<<std::endl;
			std::cout << p_mean <<  " " << p_err << std::endl;
			std::cout << "******************************" <<std::endl;

			const char* drawInput;
                        // if the parameter is a normalization, the error is not available. Do the residual instead of the pull
                        if(namestr.find("n_exp")!=string::npos) drawInput = Form("(%s-%f)/%f",name,p_mean,p_mean);
                        else drawInput = Form("(%s-%f)/%f",name,p_mean,p_err);
			tree_->Draw(Form("%s>>%s",drawInput,name),"");
			tree_->Draw(Form("%s>>%s_fail",drawInput,name),selectString.c_str(),"same");
			fitPull  = true;
			fitPullf = true;
			if (doLH) {
			  gr = graphLH(name,p_err,whichfit);
			  if (gr) plotLH=true;
			}
			
		}

		else{
			tree_->Draw(Form("%s>>%s",name,name),"");
			tree_->Draw(Form("%s>>%s_fail",name,name),selectString.c_str(),"same");
		}
		

		TH1F* bH  = (TH1F*) gROOT->FindObject(Form("%s",name))->Clone();
		TH1F* bHf = (TH1F*) gROOT->FindObject(Form("%s_fail",name))->Clone();
		bHf->SetLineColor(2);
		bH->GetXaxis()->SetTitle(bH->GetTitle());
		bH->GetYaxis()->SetTitle(Form("no toys (%d total)",nToysInTree));
		bH->GetYaxis()->SetTitleOffset(1.05);
		bH->GetXaxis()->SetTitleOffset(0.9);
		bH->GetYaxis()->SetTitleSize(0.05);
		bH->GetXaxis()->SetTitleSize(0.05);
		if (isFitted) {bH->GetXaxis()->SetTitle(Form("(%s-#theta_{B})/#sigma_{#theta}",name));}
		else {bH->GetXaxis()->SetTitle(Form("%s",name));}
		
		bH->SetTitle("");	

		if ( bH->Integral() <=0 )  fitPull = false;
		if (fitPull) {bH->Fit("gaus"); bH->GetFunction("gaus")->SetLineColor(4);}
		
		if ( bHf->Integral() <=0 )  fitPullf = false;
		if (fitPullf) {bHf->Fit("gaus"); bHf->GetFunction("gaus")->SetLineColor(2);}

		c->Clear();
		//TPad pad1("t1","",0.01,0.02,0.59,0.98);
		// Pad 1 sizes depend on the parameter type ...
		double pad1_x1,pad1_x2,pad1_y1,pad1_y2;
		if ( !isFitted ) {
			 pad1_x1 = 0.01; 
			 pad1_x2 = 0.98; 
			 pad1_y1 = 0.045; 
			 pad1_y2 = 0.98; 
		} else {
			 pad1_x1 = 0.01; 
			 pad1_x2 = 0.59; 
			 pad1_y1 = 0.56; 
			 pad1_y2 = 0.98; 
		}
		
		TPad pad1("t1","",pad1_x1,pad1_y1,pad1_x2,pad1_y2);
		TPad pad1a("t1a","",0.01,0.045,0.59,0.522);
		TPad pad2("t2","",0.59,0.04,0.98,0.62);
		TPad pad3("t3","",0.55,0.64,0.96,0.95);

		pad1.SetNumber(1); pad2.SetNumber(2); pad3.SetNumber(3); pad1a.SetNumber(4);

		if ( isFitted ) {pad1a.Draw();pad2.Draw();pad3.Draw();}

		pad1.Draw();
		pad2.SetGrid(true);


		TLatex *titletext = new TLatex();titletext->SetNDC();

		if ( isFitted ){
			c->cd(4); 
			tree_->Draw(Form("%s:%s_In>>%s_%s_2d",name,name,name,tree_->GetName()),""); 
			//TH2D *h2d_corr = (TH2D*)gROOT->FindObject(Form("%s_2d",name));
			//h2d_corr->SetMarkerColor(4);
			//h2d_corr->SetTitle("");
			//h2d_corr->GetXaxis()->SetTitle(Form("%s_In",name));
			//h2d_corr->GetYaxis()->SetTitle(Form("%s",name));
			titletext->SetTextAlign(11);
			titletext->SetTextSize(0.05);
			titletext->DrawLatex(0.05,0.02,Form("%s_In",name));
			titletext->SetTextAngle(90);
			titletext->DrawLatex(0.04,0.06,Form("%s",name));
			titletext->SetTextAngle(0);
		}

		
		c->cd(1); bH->Draw(); bHf->Draw("same");
		TLegend *legend = new TLegend(0.6,0.8,0.9,0.89);
		legend->SetFillColor(0);
		legend->AddEntry(bH,"All Toys","L");
		legend->AddEntry(bHf,selectString.c_str(),"L");
		legend->Draw();

		if (doPull && plotLH) {
			c->cd(2); gr->Draw("ALP");
		}

		if (fitPull){
			c->cd(3);
			double gap;
			TLatex *tlatex = new TLatex(); tlatex->SetNDC(); 
			if (fitPullf) {tlatex->SetTextSize(0.09); gap=0.12;}
			else  {tlatex->SetTextSize(0.11);gap=0.14;}

			tlatex->SetTextColor(4);
			tlatex->DrawLatex(0.11,0.80,Form("Mean    : %.3f #pm %.3f",bH->GetFunction("gaus")->GetParameter(1),bH->GetFunction("gaus")->GetParError(1)));
			tlatex->DrawLatex(0.11,0.80-gap,Form("Sigma   : %.3f #pm %.3f",bH->GetFunction("gaus")->GetParameter(2),bH->GetFunction("gaus")->GetParError(2)));

			if (fitPullf){ 
				tlatex->SetTextColor(2);
				tlatex->DrawLatex(0.11,0.60,Form("Mean    : %.3f #pm %.3f",bHf->GetFunction("gaus")->GetParameter(1),bHf->GetFunction("gaus")->GetParError(1)));
				tlatex->DrawLatex(0.11,0.60-gap,Form("Sigma   : %.3f #pm %.3f",bHf->GetFunction("gaus")->GetParameter(2),bHf->GetFunction("gaus")->GetParError(2)));
			}

			tlatex->SetTextSize(0.10);
			tlatex->SetTextColor(1);
				
                        if(namestr.find("n_exp")!=string::npos) tlatex->DrawLatex(0.11,0.33,Form("Pre-fit: %.3f",prevals_[name].first));
			else tlatex->DrawLatex(0.11,0.33,Form("Pre-fit #pm #sigma_{#theta}: %.3f #pm %.3f",prevals_[name].first, p_err));
			tlatex->DrawLatex(0.11,0.18,Form("Best-fit (#theta_{B})  : %.3f ",p_mean));
			tlatex->DrawLatex(0.11,0.03,Form("Best-fit (#theta_{S+B}): %.3f ",bfvals_sb_[name].first));
			
			pullSummaryMap[name]=std::make_pair<double,double>(bH->GetFunction("gaus")->GetParameter(1),bH->GetFunction("gaus")->GetParameter(2));
			nPulls++;

		}

		double titleSize = isFitted ? 0.1 : 0.028;
		titletext->SetTextSize(titleSize);titletext->SetTextAlign(21); titletext->DrawLatex(0.55,0.92,name);
		c->SaveAs(Form("%s.pdf",treename.c_str()));
		fOut->WriteObject(c,Form("%s_%s",treename.c_str(),name));
		//c->SaveAs(Form("%s_%s.pdf",treename.c_str(),name));
	}
	
	if (doPull && nPulls>0){
	  
	    std::cout << "Generating Pull Summaries" <<std::endl; 
	    int nRemainingPulls = nPulls;
	    TCanvas *hc = new TCanvas("hc","",3000,2000); hc->SetGrid(0);
	    std::map < const char*, std::pair <double,double> >::iterator pull_it = pullSummaryMap.begin();
	    std::map < const char*, std::pair <double,double> >::iterator pull_end = pullSummaryMap.end();

	    int pullPlots = 1;
	    while (nRemainingPulls > 0){

		int nThisPulls = min(maxPullsPerPlot,nRemainingPulls);

		TH1F pullSummaryHist("pullSummary","",nThisPulls,0,nThisPulls);
		for (int pi=1;pull_it!=pull_end && pi<=nThisPulls ;pull_it++,pi++){
			pullSummaryHist.GetXaxis()->SetBinLabel(pi,(*pull_it).first);
			pullSummaryHist.SetBinContent(pi,((*pull_it).second).first);
			pullSummaryHist.SetBinError(pi,((*pull_it).second).second);
			nRemainingPulls--;
		}		

		pullSummaryHist.SetMarkerStyle(21);pullSummaryHist.SetMarkerSize(1.5);pullSummaryHist.SetMarkerColor(2);pullSummaryHist.SetLabelSize(pullLabelSize);
		pullSummaryHist.GetYaxis()->SetRangeUser(-3,3);pullSummaryHist.GetYaxis()->SetTitle("pull summary (n#sigma)");pullSummaryHist.Draw("E1");
		hc->SaveAs(Form("%s.pdf",treename.c_str()));
		fOut->WriteObject(hc,Form("comb_pulls_%s_%d",treename.c_str(),pullPlots));
	//	hc->SaveAs(Form("comb_pulls_%s_%d.pdf",treename.c_str(),pullPlots));
		pullPlots++;
	   }

	    delete hc;
	}

	c->SaveAs(Form("%s.pdf]",treename.c_str()));
	fOut->Close();
	delete c;
	return;


}
Example #24
0
void fractionFit()
{
   char name[1000];
  sprintf(name,"/Users/zach/Research/pythia/npeTemplate/outputs/currentB.root");
  TFile *fB = new TFile(name,"READ");
  sprintf(name,"/Users/zach/Research/pythia/npeTemplate/outputs/currentC.root");
  TFile *fC = new TFile(name,"READ");
   sprintf(name,"/Users/zach/Research/rootFiles/run12NPEhPhi/currentData.root");
  TFile *fD = new TFile(name,"READ");
  if (fB->IsOpen()==kFALSE || fC->IsOpen()==kFALSE)
    { std::cout << "!!!!!! Either B,C, or Data File not found !!!!!!" << std::endl
		<< "Looking for currentB.root, currentC.root, and currentData.root" << std::endl;
      exit(1); }
  
  // Set constants and projection bins
  const Int_t numPtBins = 10;
  Float_t lowpt[14] ={2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,7.0,7.5,8.5,10.,14.0};
  Float_t highpt[14]={3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,7.0,7.5,8.5,10.,14.,200.};
  Float_t hptCut=0.5;

  // Make Canvases
  TCanvas* deltaPhi  = new TCanvas("deltaPhi","Pythia Delta Phi",150,0,1150,1000);
  TCanvas* fitResult0 = new TCanvas("fitResult0","RB Extraction HT0",150,0,1150,1000);
  //  TCanvas* fitResult2 = new TCanvas("fitResult2","RB Extraction HT2",150,0,1150,1000);
  deltaPhi->Divide(2,2);
  fitResult0->Divide(4,3);
  //fitResult2->Divide(4,3);

  // Make histos
  TH1D* projB[numPtBins];
  TH1D* projC[numPtBins];
  TH1D* projData0[numPtBins];
  TH1D* projData2[numPtBins];
  
  // Get and Draw histos
  TPaveText* lbl[numPtBins];
  char textLabel[100];
  Int_t plotbin;

  for(Int_t ptbin=0; ptbin<numPtBins; ptbin++)
    {
      if(ptbin!=0 && ptbin!=2 && ptbin!=4 && ptbin!=6)
	continue;
      if(ptbin==0)plotbin=0;
      if(ptbin==2)plotbin=1;
      if(ptbin==4)plotbin=2;
      if(ptbin==6)plotbin=3;
      // Init necessary plotting tools
      lbl[ptbin] = new TPaveText(.2,.76,.5,.82,Form("NB NDC%i",ptbin));
      sprintf(textLabel,"%.1f < P_{T,e} < %.1f",lowpt[ptbin],highpt[ptbin]);
      lbl[ptbin]->AddText(textLabel);
      lbl[ptbin]->SetFillColor(kWhite);

      projB[ptbin] = (TH1D*)fB->Get(Form("projDelPhi_%i",ptbin));
      projC[ptbin] = (TH1D*)fC->Get(Form("projDelPhi_%i",ptbin));
      projData0[ptbin]= (TH1D*)fD->Get(Form("NPEhDelPhi_0_%i",ptbin));
      projData2[ptbin]= (TH1D*)fD->Get(Form("NPEhDelPhi_2_%i",ptbin));
      Int_t RB = 8;
      projB[ptbin]->Rebin(RB);
      projC[ptbin]->Rebin(RB);
      
      // Draw Templates on own plots
      deltaPhi->cd(plotbin+1);
      projData0[ptbin]->SetLineColor(kBlue);
      projData2[ptbin]->SetLineColor(kGreen+3);
      projB[ptbin]->SetLineColor(kRed);
      projC[ptbin]->SetLineColor(kBlack);
      //      projC[ptbin]->GetYaxis()->SetRangeUser(0.,0.5);
      projC[ptbin]    -> Draw();
      projB[ptbin]    -> Draw("same");
      projData0[ptbin]-> Draw("same");
      projData2[ptbin]-> Draw("same");
      lbl[ptbin]      -> Draw("same");

      TLegend* leg = new TLegend(0.5,0.73,0.85,0.85);
      leg->AddEntry(projB[ptbin],"b#bar{b}->NPE","lpe");
      leg->AddEntry(projC[ptbin],"c#bar{c}->NPE","lpe");
      leg->AddEntry(projData0[ptbin],"HT0","lpe");
      leg->AddEntry(projData2[ptbin],"HT2","lpe");
      leg->Draw();

      // Do the actual fit
      TObjArray *mc = new TObjArray(2);   // MC histograms are put in this array
      mc->Add(projC[ptbin]);
      mc->Add(projB[ptbin]);

      fitResult0->cd(ptbin+1);
      TFractionFitter* fit = new TFractionFitter(projData0[ptbin], mc,"V"); // initialise
      fit->Constrain(1,0.0,1.0);               // constrain fraction 1 to be between 0 and 1
      fit->SetRangeX(46,56);                    // use only the first 15 bins in the fit
      Int_t status = fit->Fit();               // perform the fit
      std::cout << "fit status: " << status << std::endl;
      if (status == 0) {                       // check on fit status
	TH1F* result = (TH1F*) fit->GetPlot();
	projData0[ptbin]->Draw("Ep");
	result->Draw("same");
	}

      
      /* fitResult2->cd(ptbin+1);
      TFractionFitter* fit2 = new TFractionFitter(projData2[ptbin], mc); // initialise
      fit2->Constrain(0,0.0,1.0);              // constrain fraction 0
      fit2->Constrain(1,0.0,1.0);              // constrain fraction 1 to be between 0 and 1
      fit2->SetRangeX(23,29);                  // use only the first 15 bins in the fit
      Int_t status2 = fit2->Fit();             // perform the fit
      std::cout << "fit status: " << status2 << std::endl;
      if (status2 == 0) {                       // check on fit status
	TH1F* result2 = (TH1F*) fit2->GetPlot();
	projData2[ptbin]->Draw("Ep");
	result2->Draw("same");
	}*/
    }
}
Example #25
0
void glbToId_eta()
{
  ofstream txtfile;
  char txtfname[100];
  char histfname[100];
  sprintf(txtfname,"eta_plus.txt");
  sprintf(histfname,"eta_plus.png");
  //sprintf(txtfname,"eta_minus.txt");
  //sprintf(histfname,"eta_minus.png");
  txtfile.open(txtfname);
  txtfile << fixed << setprecision(4);
  TCanvas *myCan=new TCanvas("myCan","myCan",800,600);
  gStyle->SetLineWidth(2.);
  gStyle->SetLabelSize(0.04,"xy");
  gStyle->SetTitleSize(0.05,"xy");
  gStyle->SetTitleOffset(1.1,"x");
  gStyle->SetTitleOffset(1.2,"y");
  gStyle->SetPadTopMargin(0.1);
  gStyle->SetPadRightMargin(0.1);
  gStyle->SetPadBottomMargin(0.16);
  gStyle->SetPadLeftMargin(0.12);

  myCan->SetGrid();
  TLegend* Lgd = new TLegend(.8, .25,.9,.35);
  TFile *f_MCndof2= new TFile("TnP_GlbToID_MCetaplus_WptNumValidMuon_eta.root","read");
  TFile *f_MCndof4= new TFile("TnP_GlbToID_MCetaplus_ndof4_WptNumValidMuon_eta.root","read");
  
  //TFile *f_MCndof2= new TFile("TnP_GlbToID_MCetaminus_WptNumValidMuon_eta.root","read");
  //TFile *f_MCndof4= new TFile("TnP_GlbToID_MCetaminus_ndof4_WptNumValidMuon_eta.root","read");
  RooDataSet *datasetMC = (RooDataSet*)f_MCndof2->Get("tpTree/WptNumValidMuon_eta/fit_eff");
  cout<<"ntry: "<<datasetMC->numEntries()<<endl;
  double XMC[Nbin],XMCerrL[Nbin],XMCerrH[Nbin],YMC[Nbin],YMCerrLo[Nbin],YMCerrHi[Nbin],ErrMC[Nbin];
  for(int i(0); i<datasetMC->numEntries();i++)
  {
    const RooArgSet &pointMC=*datasetMC->get(i);
    RooRealVar &etaMC=pointMC["eta"],&effMC = pointMC["efficiency"];
    XMC[i]=etaMC.getVal();
    XMCerrL[i]=-etaMC.getAsymErrorLo();
    XMCerrH[i]=etaMC.getAsymErrorHi();
    YMC[i]=effMC.getVal();
    YMCerrLo[i]=-effMC.getAsymErrorLo();
    YMCerrHi[i]=effMC.getAsymErrorHi();
    ErrMC[i]=TMath::Max(YMCerrLo[i],YMCerrHi[i]);
  }

  grMC=new TGraphAsymmErrors(Nbin,XMC,YMC,XMCerrL,XMCerrH,YMCerrLo,YMCerrHi);
  grMC->SetLineColor(kRed);
  grMC->SetMarkerColor(kRed);
  grMC->SetMinimum(0.5);
  grMC->SetMaximum(1.1);
  grMC->GetXaxis()->SetNdivisions(505);
  grMC->GetXaxis()->SetTitle("Muon #eta");
  grMC->GetYaxis()->SetTitle("ID+ISO Efficiency");
  grMC->Draw("AP");

  RooDataSet *datasetRD = (RooDataSet*)f_MCndof4->Get("tpTree/WptNumValidMuon_eta/fit_eff");
  double XRD[Nbin],XRDerrL[Nbin],XRDerrH[Nbin],YRD[Nbin],YRDerrLo[Nbin],YRDerrHi[Nbin],ErrRD[Nbin];
  for(int i(0); i<datasetRD->numEntries();i++)
  {
    const RooArgSet &pointRD=*datasetRD->get(i);
    RooRealVar &etaRD=pointRD["eta"],&effRD = pointRD["efficiency"];
    XRD[i]=etaRD.getVal();
    XRDerrL[i]=-etaRD.getAsymErrorLo();
    XRDerrH[i]=etaRD.getAsymErrorHi();
    YRD[i]=effRD.getVal();
    YRDerrLo[i]=-effRD.getAsymErrorLo();
    YRDerrHi[i]=effRD.getAsymErrorHi();
    ErrRD[i]=TMath::Max(YRDerrLo[i],YRDerrHi[i]);
  }
  txtfile << "Bins \t MC ndof>2\t\t\t MC ndof>4 \t\t\t Scale Factor ndof4/ndof2 "  << endl;
  for(int i(0); i<datasetRD->numEntries();i++)
  {
    txtfile << i << "\t" << YMC[i] << "+/-" << ErrMC[i] << "\t\t" << YRD[i] << "+/-" << ErrRD[i] << "\t\t" << YRD[i]/YMC[i] << "+/-" << YRD[i]*sqrt(ErrMC[i]*ErrMC[i]/(YMC[i]*YMC[i])+ErrRD[i]*ErrRD[i]/(YRD[i]*YRD[i]))/YMC[i] << endl;
  }

  grRD=new TGraphAsymmErrors(Nbin,XRD,YRD,XRDerrL,XRDerrH,YRDerrLo,YRDerrHi);
  grRD->SetLineColor(kBlack);
  grRD->SetMarkerColor(kBlack);
  Lgd->AddEntry(grMC,"MC ndof>2","pl");
  Lgd->AddEntry(grRD,"MC ndof>4","pl");
  Lgd->SetFillStyle(0);
  Lgd->Draw();
  grRD->Draw("PSAME");
  
  myCan->SaveAs(histfname);
  txtfile.close();
}
Example #26
0
void control(TString var,TString bin, TCut cuts, TCut cutsA, TString cutpoint,bool log,Double_t ymax){
setstyle();
 TH1::SetDefaultSumw2(true);
TCanvas *c2 = new TCanvas("canvas"+var+cutpoint,"canname"+var+cutpoint,700,800);

  TPad *mainPad = new TPad("","",0.01,0.25,0.99,0.99);
   mainPad->SetNumber(1);
   mainPad->Draw();
    TPad *ratioPad = new TPad("","",0.01,0.01,0.99,0.25);
   ratioPad->SetNumber(2);
   ratioPad->Draw();
 c2->cd(1);

 TCut lo = cuts && mu_pt_lo;
 TCut hi = cuts && mu_pt_hi;

 // TH1D *Ctrl_lo = GetHist("AS",kBlack,var,lo,bin,astQCD,cutpoint);
 // TH1D *Sig_lo = GetHist("S",kRed,var,lo,bin,stQCD,cutpoint);
  TH1D *Ctrl_hi = GetHist("AS",kBlack,var,cuts,bin,astQCD,cutpoint);
  TH1D *Sig_hi = GetHist("S",kRed,var,cuts,bin,stQCD,cutpoint);
  //  Ctrl_lo->Scale(1.94);
  //  Sig_lo->Scale(1.94);
  TH1D *Ctrl = Ctrl_hi->Clone();
  TH1D *Sig = Sig_hi->Clone();
  //  Ctrl->Add(Ctrl_hi);
  // Sig->Add(Sig_hi);

  Sig->Scale(intlumi);
  // TH1D *Ctrl = GetHist("AS",kBlack,var,cuts,bin,astQCD,cutpoint);
  if(Ctrl->Integral()!=0){
  Ctrl->Scale(Sig->Integral()/Ctrl->Integral());
  }
  
  if(log){ c2->cd(1)->SetLogy();}
  
 TLegend *leg = new TLegend(0.564,0.719,0.775,0.875);
 leg->SetTextSize(0.054);
  leg->SetFillColor(0);
  leg->SetLineColor(0);
  //  leg->AddEntry(Ctrl,"Anti-Selected","LF");
  leg->AddEntry(Sig,"Selected","LF");
    leg->AddEntry(Ctrl,"Anti-Selected","LF");

  Ctrl->Draw("EHIST9");
  Sig->Draw("E9same");

  Sig->SetMarkerStyle(20); Sig->SetMarkerColor(kRed);
  leg->Draw("same");
  Ctrl->SetTitle();
  Ctrl->GetXaxis()->SetTitle(var);
  if(log){
  Ctrl->GetYaxis()->SetRangeUser(0.001,ymax);
  }
  else{
    ymax=(Ctrl->GetMaximum()*1.6);
     Ctrl->GetYaxis()->SetRangeUser(0.,ymax);
  }
   TH1D *RatioBottom = (TH1D*)Ctrl->Clone("Ratiob");
   TH1D *RatioTop = (TH1D*)Sig->Clone("Ratiot");

  RatioTop->GetYaxis()->SetTitle("Selected / Anti-Selected");
 RatioTop->GetXaxis()->SetTitle();
 RatioTop->SetTitle();
      RatioTop->Divide(RatioBottom);

      c2->cd(2);
  gPad->SetGridx(); gPad->SetGridy();
   RatioTop->SetTitleSize(0.1, "XYZ");
    RatioTop->SetTitleOffset(0.55, "X");
    RatioTop->SetTitleOffset(0.3, "Y");
    RatioTop->SetLabelSize(0.06,"XY");
    RatioTop->GetYaxis()->SetRangeUser(-2.,5.0);
    RatioTop->SetLineColor(kBlack);
    RatioTop->Draw();
  TBox *unity = new TBox(RatioTop->GetXaxis()->GetBinLowEdge(RatioTop->GetXaxis()->GetFirst()), 0.79,RatioTop->GetXaxis()->GetBinLowEdge(RatioTop->GetXaxis()->GetLast()), 1.21);
			   unity->SetLineWidth(2);
unity->SetLineColor(2);
    unity->SetFillColor(2);
			   unity->SetFillStyle(3002);
			   unity->Draw();
  c2->Update();
  c2->SaveAs(plots+"SAS_Muon_10to25"+var+"_"+cutpoint+".png");
  // c2->Close();
}
Example #27
0
void compare()
{
	msglvl[DBG] = SILENT;
	msglvl[INF] = VISUAL;
	msglvl[WRN] = VISUAL;
	msglvl[ERR] = VISUAL;
	msglvl[FAT] = VISUAL;

	TDirectory* oldDir = gDirectory;

	style();

	TFile* f2ds = NULL;
	TFile* f2d  = NULL;
	TH2D* h2ds  = NULL;
	TH2D* h2d   = NULL;
	TH1D* h1s   = NULL;
	TH1D* h1    = NULL;
	TH1D* h1dy  = NULL;

	Int_t g4bin = 50;
	TString model = "ZP";

	int imassmin = 330;
	int imassmax = 4930;
	int dimass   = 100;
	for(int imass=imassmin ; imass<=imassmax ; imass+=dimass)
	{
		TString mass = (TString)_s(imass);
		_INFO("enter "+(string)mass);

		TString modeltmp = (model=="ZP") ? "P" : "KK";

		oldDir->cd();
		f2ds = new TFile("~yiftahsi/KK_analysis_t301/2dtemplates_FEB1/templates2d_Xmass"+mass+".root","READ");
		h2ds = (TH2D*)f2ds->Get("h2"+model+"/Z"+modeltmp+"_mXp"+mass)->Clone();

		f2d  = new TFile("~yiftahsi/KK_analysis_t301/2dtemplates_FEB2/templates2d_Xmass"+mass+".root","READ");
		h2d = (TH2D*)f2d->Get("h2"+model+"/Z"+modeltmp+"_mXp"+mass)->Clone();
                oldDir->cd();

		//------------------------------------------------------------
		const Int_t nbins = h2d->GetNbinsX();
		Double_t bins[nbins+1];
		TAxis* xaxis = (TAxis*)h2d->GetXaxis();
		for(int i=0 ; i<nbins ; i++) bins[i] = xaxis->GetBinLowEdge(i+1);
		bins[nbins] = xaxis->GetBinUpEdge(nbins);
		//------------------------------------------------------------
		
		Double_t g4 = h2d->GetYaxis()->GetBinLowEdge(g4bin);
		TString g = (TString)_s(sqrt(sqrt(g4)),2);
	
		TString modelname = (model=="ZP") ? "Z'" : "KK";
	
		h1s  = new TH1D(mass+"_subtracted","g="+g+", m_{"+modelname+"} = "+mass+" GeV;m_{ee} TeV;Events",nbins,bins);
		h1   = new TH1D(mass+"_inamplitude","g="+g+", m_{"+modelname+"} = "+mass+" GeV;m_{ee} TeV;Events",nbins,bins);
		h1dy = new TH1D(mass+"_dy","g="+g+", m_{"+modelname+"} = "+mass+" GeV;m_{ee} TeV;Events",nbins,bins);
		for(Int_t bin=0 ; bin<=nbins+1 ; bin++)
		{
			h1s->SetBinContent(bin, h2ds->GetBinContent(bin,g4bin));
			h1->SetBinContent(bin, h2d->GetBinContent(bin,g4bin));
			h1dy->SetBinContent(bin, h2d->GetBinContent(bin,1));
		}

		TLegend* leg = new TLegend(0.55,0.72,0.85,0.85,NULL,"brNDC");
		leg->SetFillStyle(4000); //will be transparent
		leg->SetFillColor(0);
		leg->SetTextFont(42);
		
		TCanvas* c = new TCanvas("c"+mass,"c"+mass,600,400);
		c->Draw();
		c->cd();
		c->SetTicks(1,1);
		c->SetLogy();
		c->SetLogx();
		c->SetGridy();	
		c->cd();

		double ymin = getYmin(h1s);
		ymin = (getYmin(h1dy)<ymin) ? getYmin(h1dy): ymin;
		h1dy->SetMinimum( ymin*0.1);
		TLine* l = new TLine(0.12805,h1dy->GetMinimum(),0.12805,h1dy->GetMaximum());
		l->SetLineColor(kGreen+2);
		
		h1dy->SetLineColor(kBlue);
		h1dy->SetLineStyle(1);
		h1dy->SetLineWidth(2);
		leg->AddEntry(h1dy,"DY, in-amplitude k_{F}","l");
		h1dy->DrawCopy();

		h1s->SetLineColor(kBlack);
		h1s->SetLineStyle(1);
		h1s->SetLineWidth(2);
		leg->AddEntry(h1s,modelname+", subtracted k_{F}","l");
		h1s->DrawCopy("SAMES");

		h1->SetLineColor(kRed);
		h1->SetLineStyle(3);
		h1->SetLineWidth(2);
		leg->AddEntry(h1,modelname+", in-amplitude k_{F}","l");
		h1->DrawCopy("SAMES");
		l->Draw("SAMES");
		leg->Draw("SAMES");
	
		_INFO("done "+(string)mass);

		c->RedrawAxis();
		c->Update();
		g.ReplaceAll(".","");
		if(imass==imassmin)      c->SaveAs("kfactors_g"+model+g+".pdf(");
		else if(imass==imassmax) c->SaveAs("kfactors_g"+model+g+".pdf)");
		else                     c->SaveAs("kfactors_g"+model+g+".pdf");
	}
}
Example #28
0
void process() {

/////////////////////////
// F I L E S
/////////////////////////

    TFile* f_El = new TFile("FourTopnoRho_EventSelection_El_preApp.root");
    TFile* f1 = new TFile("SystematicShapes_El_preApp.root");
// TFile* f2 = new TFile("SystematicShapes_El_preApp_tttt.root");


////////////////////////////////////////////////
// P R O C E S S   N O M I N A L   S H A P E S
////////////////////////////////////////////////

    TFile* fnom = new TFile("NominalShapes_El.root","RECREATE");


//////////////////////
/// I N C L U S I V E
//////////////////////

    TH1F * hData_El = (TH1F*)f_El->Get("MultiSamplePlot_MVA/MVA_Data");
    TH1F * hSig_El = (TH1F*)f_El->Get("MultiSamplePlot_MVA/MVA_NP_overlay_TTTT");

    double sig_scale = 0.87*1.3; //correcting for (very slightly incorrect int.lumi of sig histo and correcting to NLO xsection (doesn't make any real difference))


    hSig_El->Scale(sig_scale);

    //signal injection test
    TH1F * hdata_100fbtttt = new TH1F();
    TH1F * hdata_150fbtttt = new TH1F();
    TH1F * hdata_200fbtttt = new TH1F();

    hdata_100fbtttt = (TH1F*)hData_El->Clone();
    hdata_150fbtttt = (TH1F*)hData_El->Clone();
    hdata_200fbtttt = (TH1F*)hData_El->Clone();

    hdata_100fbtttt->Add(hSig_El, 100/1.3);
    hdata_150fbtttt->Add(hSig_El, 150/1.3);
    hdata_200fbtttt->Add(hSig_El, 200/1.3);

    hdata_100fbtttt->SetMarkerColor(kBlue);
    hdata_150fbtttt->SetMarkerColor(kGreen);
    hdata_200fbtttt->SetMarkerColor(kRed);
    hSig_El->SetLineColor(kOrange);
    hSig_El->SetLineWidth(2);
    hData_El->SetLineWidth(2);
    hData_El->SetTitle("");
    hData_El->SetMinimum(0.001);
    hData_El->SetMaximum(100000);

    TCanvas * cx = new TCanvas();
    hData_El->Draw("HIST");
    hSig_El->Draw("HISTSAME");
    hdata_100fbtttt->Draw("same");
    hdata_150fbtttt->Draw("same");
    hdata_200fbtttt->Draw("same");
    cx->SetLogy();
    cx->Update();

    TLegend* leg = new TLegend(0.6, 0.73, .97, .95);
    leg->SetFillColor(0);
    leg->AddEntry(hData_El, "Data", "l");
    leg->AddEntry(hdata_100fbtttt, "Data with signal injection (#sigma = 100 fb)", "p");
    leg->AddEntry(hdata_150fbtttt, "Data with signal injection (#sigma = 150 fb)", "p");
    leg->AddEntry(hdata_200fbtttt, "Data with signal injection (#sigma = 200 fb)", "p");
    leg->AddEntry(hSig_El, "Signal", "l");
    leg->Draw();

    cx->SaveAs("SignalInjection_El.pdf");


    TH1F * hTTll_El = (TH1F*)f_El->Get("MultiSamplePlot_MVA/MVA_TTJets_ll");
    TH1F * hTTcc_El = (TH1F*)f_El->Get("MultiSamplePlot_MVA/MVA_TTJets_cc");
    TH1F * hTTbb_El = (TH1F*)f_El->Get("MultiSamplePlot_MVA/MVA_TTJets_bb");
    TH1F * hTT_El = (TH1F*)hTTbb_El->Clone();
    hTT_El->Reset();
    hTT_El->Add(hTTll_El);
    hTT_El->Add(hTTcc_El);
    hTT_El->Add(hTTbb_El);

    double nExTT_El  = hTT_El->Integral(0,16);


    hTT_El->Write("tt");
    hSig_El->Write("tttt");
    hData_El->Write("data");
    hdata_100fbtttt->Write("data_w100fbtttt");
    hdata_150fbtttt->Write("data_w150fbtttt");
    hdata_200fbtttt->Write("data_w200fbtttt");

    //  cout << hTTll_El->Integral(0,16) <<endl;
    //cout << hTTcc_El->Integral(0,16) <<endl;
    //cout << hTTbb_El->Integral(0,16) <<endl;
    //  cout << nExTT_El<<endl;

    //EW histo
    TH1F * hW4_El = (TH1F*)f_El->Get("MultiSamplePlot_MVA/MVA_W_4Jets");
    TH1F * hZ4_El = (TH1F*)f_El->Get("MultiSamplePlot_MVA/MVA_Z_4Jets");
    TH1F * hZ4_lm_El = (TH1F*)f_El->Get("MultiSamplePlot_MVA/MVA_Z_4Jets_lm");
    TH1F * hSingleTop_t_T_El = (TH1F*)f_El->Get("MultiSamplePlot_MVA/MVA_SingleTop_t_T");
    TH1F * hSingleTop_t_TBar_El = (TH1F*)f_El->Get("MultiSamplePlot_MVA/MVA_SingleTop_t_TBar");
    TH1F * hSingleTop_s_T_El = (TH1F*)f_El->Get("MultiSamplePlot_MVA/MVA_SingleTop_s_T");
    TH1F * hSingleTop_s_TBar_El = (TH1F*)f_El->Get("MultiSamplePlot_MVA/MVA_SingleTop_s_TBar");
    TH1F * hSingleTop_tW_T_El = (TH1F*)f_El->Get("MultiSamplePlot_MVA/MVA_SingleTop_tW_T");
    TH1F * hSingleTop_tW_TBar_El = (TH1F*)f_El->Get("MultiSamplePlot_MVA/MVA_SingleTop_tW_TBar");
    TH1F * hWW_El = (TH1F*)f_El->Get("MultiSamplePlot_MVA/MVA_WW");
    TH1F * hWZ_El = (TH1F*)f_El->Get("MultiSamplePlot_MVA/MVA_WZ");
    TH1F * hZZ_El = (TH1F*)f_El->Get("MultiSamplePlot_MVA/MVA_ZZ");

    TH1F * hEW_El = (TH1F*)hW4_El->Clone();
    hEW_El->Reset();

    hEW_El->Add(hW4_El);
    hEW_El->Add(hZ4_El);
    hEW_El->Add(hZ4_lm_El);
    hEW_El->Add(hSingleTop_t_T_El);
    hEW_El->Add(hSingleTop_t_TBar_El);
    hEW_El->Add(hSingleTop_s_T_El);
    hEW_El->Add(hSingleTop_s_TBar_El);
    hEW_El->Add(hSingleTop_tW_T_El);
    hEW_El->Add(hSingleTop_tW_TBar_El);
    hEW_El->Add(hWW_El);
    hEW_El->Add(hWZ_El);
    hEW_El->Add(hZZ_El);

    hEW_El->Write("EW");

    //tt other histo
    TH1F * httW_El = (TH1F*)f_El->Get("MultiSamplePlot_MVA/MVA_ttW");
    TH1F * httZ_El = (TH1F*)f_El->Get("MultiSamplePlot_MVA/MVA_ttZ");
    TH1F * httH_El = (TH1F*)f_El->Get("MultiSamplePlot_MVA/MVA_ttH");
    TH1F * hTTOther_El = (TH1F*)f_El->Get("MultiSamplePlot_MVA/MVA_TTJets_Other");

    hTTOther_El->Add(httW_El);
    hTTOther_El->Add(httZ_El);
    hTTOther_El->Add(httH_El);

    hTTOther_El->Write("ttOther");



    fnom->Close();
    cout<<"processing sytematic shapes..."<<endl;

///////////////////////////////////////////////////////
//// P R O C E S S   S Y S T E M A T I C   H I S T O S
///////////////////////////////////////////////////////

    TFile* f2 = new TFile("SystematicShapes_norm_El.root", "RECREATE");

///////////////////////
/// I N C L U S I V E
///////////////////////

    TH1F *h_Scale_Down = (TH1F*)f1->Get("Scale_Down");
    TH1F *h_Scale_Up = (TH1F*)f1->Get("Scale_Up");
    double int_scaledown = h_Scale_Down->Integral(0,16);
    double int_scaleup = h_Scale_Up->Integral(0,16);

    double s = nExTT_El/h_Scale_Up->Integral(0,16);
    h_Scale_Up->Scale(s);
    s = nExTT_El/h_Scale_Down->Integral(0,16);
    h_Scale_Down->Scale(s);
    h_Scale_Up->Write("Scale_Up");
    h_Scale_Down->Write("Scale_Down");

    cout<<"processing sytematic shapes..scale done."<<endl;


    /*
    TH1F *h_Scale_Down_1stHalf = (TH1F*)f1->Get("MVA_Scale_Down_1stHalf");
    TH1F *h_Scale_Up_1stHalf = (TH1F*)f1->Get("MVA_Scale_Up_1stHalf");
    double int_scaledown_1stHalf = h_Scale_Down_1stHalf->Integral(0,16);
    double int_scaleup_1stHalf = h_Scale_Up_1stHalf->Integral(0,16);

    s = nExTT_El/h_Scale_Up_1stHalf->Integral(0,16);
    h_Scale_Up_1stHalf->Scale(s);
    s = nExTT_El/h_Scale_Down_1stHalf->Integral(0,16);
    h_Scale_Down_1stHalf->Scale(s);
    h_Scale_Up_1stHalf->Write("Scale_Up_1stHalf");
    h_Scale_Down_1stHalf->Write("Scale_Down_1stHalf");


    TH1F *h_Scale_Down_2ndHalf = (TH1F*)f1->Get("MVA_Scale_Down_2ndHalf");
    TH1F *h_Scale_Up_2ndHalf = (TH1F*)f1->Get("MVA_Scale_Up_2ndHalf");
    double int_scaledown_2ndHalf = h_Scale_Down_2ndHalf->Integral(0,16);
    double int_scaleup_2ndHalf = h_Scale_Up_2ndHalf->Integral(0,16);

    s = nExTT_El/h_Scale_Up_2ndHalf->Integral(0,16);
    h_Scale_Up_2ndHalf->Scale(s);
    s = nExTT_El/h_Scale_Down_2ndHalf->Integral(0,16);
    h_Scale_Down_2ndHalf->Scale(s);
    h_Scale_Up_2ndHalf->Write("Scale_Up_2ndHalf");
    h_Scale_Down_2ndHalf->Write("Scale_Down_2ndHalf");


     cout<<"scale done....."<<endl;
    */



    cout<<"scale done....."<<endl;

    TH1F *h_Matching_Down = (TH1F*)f1->Get("Matching_Down");
    TH1F *h_Matching_Up = (TH1F*)f1->Get("Matching_Up");
    double int_matchingdown = h_Matching_Down->Integral(0,16);
    double int_matchingup = h_Matching_Up->Integral(0,16);


    s = nExTT_El/h_Matching_Up->Integral(0,16);
    h_Matching_Up->Scale(s);
    s = nExTT_El/h_Matching_Down->Integral(0,16);
    h_Matching_Down->Scale(s);
    h_Matching_Up->Write("Matching_Up");
    h_Matching_Down->Write("Matching_Down");

    cout<<"matching done....."<<endl;

    TH1F *h_JES_Down = (TH1F*)f1->Get("JES_Down");
    TH1F *h_JES_Up = (TH1F*)f1->Get("JES_Up");
    double int_jesdown = h_JES_Down->Integral(0,16);
    double int_jesup = h_JES_Up->Integral(0,16);

    s = nExTT_El/h_JES_Up->Integral(0,16);
    h_JES_Up->Scale(s);
    s = nExTT_El/h_JES_Down->Integral(0,16);
    h_JES_Down->Scale(s);
    h_JES_Up->Write("JES_Up");
    h_JES_Down->Write("JES_Down");

    cout<<"JES done....."<<endl;


    TH1F *h_ttbb_Down = (TH1F*)f1->Get("ttbb_Down");
    TH1F *h_ttbb_Up = (TH1F*)f1->Get("ttbb_Up");
    double int_ttbbdown = h_ttbb_Down->Integral(0,16);
    double int_ttbbup = h_ttbb_Up->Integral(0,16);
    s = nExTT_El/h_ttbb_Up->Integral(0,16);
    h_ttbb_Up->Scale(s);
    s = nExTT_El/h_ttbb_Down->Integral(0,16);
    h_ttbb_Down->Scale(s);
    h_ttbb_Up->Write("ttbb_Up");
    h_ttbb_Down->Write("ttbb_Down");

    cout<<"ttbb done....."<<endl;

    TH1F *h_bTag_Down = (TH1F*)f1->Get("bTag_Down");
    TH1F *h_bTag_Up = (TH1F*)f1->Get("bTag_Up");
    double int_btagdown = h_bTag_Down->Integral(0,16);
    double int_btagup = h_bTag_Up->Integral(0,16);

    s = nExTT_El/h_bTag_Up->Integral(0,16);
    h_bTag_Up->Scale(s);
    s = nExTT_El/h_bTag_Down->Integral(0,16);
    h_bTag_Down->Scale(s);
    h_bTag_Up->Write("bTag_Up");
    h_bTag_Down->Write("bTag_Down");

    cout<<"btag done....."<<endl;


    TH1F *h_misTag_Down = (TH1F*)f1->Get("misTag_Down");
    TH1F *h_misTag_Up = (TH1F*)f1->Get("misTag_Up");
    double int_mistagdown = h_misTag_Down->Integral(0,16);
    double int_mistagup = h_misTag_Up->Integral(0,16);

    s = nExTT_El/h_misTag_Up->Integral(0,16);
    h_misTag_Up->Scale(s);
    s = nExTT_El/h_misTag_Down->Integral(0,16);
    h_misTag_Down->Scale(s);
    h_misTag_Up->Write("misTag_Up");
    h_misTag_Down->Write("misTag_Down");

    cout<<"mistag done....."<<endl;

    TH1F *h_leptonSF_Down = (TH1F*)f1->Get("leptonSF_Down");
    TH1F *h_leptonSF_Up = (TH1F*)f1->Get("leptonSF_Up");

    double int_leptonsfdown = h_leptonSF_Down->Integral(0,16);
    double int_leptonsfup = h_leptonSF_Up->Integral(0,16);

    s = nExTT_El/h_leptonSF_Up->Integral(0,16);
    h_leptonSF_Up->Scale(s);
    s = nExTT_El/h_leptonSF_Down->Integral(0,16);
    h_leptonSF_Down->Scale(s);
    h_leptonSF_Up->Write("leptonSF_Up");
    h_leptonSF_Down->Write("leptonSF_Down");


    cout<<"lepton sf done....."<<endl;

    TH1F *h_PU_Down = (TH1F*)f1->Get("PU_Down");
    TH1F *h_PU_Up = (TH1F*)f1->Get("PU_Up");
    double int_pudown = h_PU_Down->Integral(0,16);
    double int_puup = h_PU_Up->Integral(0,16);

    s = nExTT_El/h_PU_Up->Integral(0,16);
    h_PU_Up->Scale(s);
    s = nExTT_El/h_PU_Down->Integral(0,16);
    h_PU_Down->Scale(s);
    h_PU_Up->Write("PU_Up");
    h_PU_Down->Write("PU_Down");


    cout<<"PU  done....."<<endl;

    TH1F *h_JER_Down = (TH1F*)f1->Get("JER_Down");
    TH1F *h_JER_Up = (TH1F*)f1->Get("JER_Up");
    double int_jerdown = h_JER_Down->Integral(0,16);
    double int_jerup = h_JER_Up->Integral(0,16);
    s = nExTT_El/h_JER_Up->Integral(0,16);
    h_JER_Up->Scale(s);
    s = nExTT_El/h_JER_Down->Integral(0,16);
    h_JER_Down->Scale(s);
    h_JER_Up->Write("JER_Up");
    h_JER_Down->Write("JER_Down");



    cout <<"closing files..."<<endl;

    f2->Close();
    f1->Close();

    cout <<"end job..."<<endl;



    double k_factor_1 = 2*1.022727*1.034*1.022525;
    double k_factor_2 = (k_factor_1/2.)*0.9644;
    double k_factor_3 =  1.;
    // double k_factor = 2.0;


    cout<<"Comparing effects of shape systematics..test. "<<endl;
//if (h_Scale_Up)cout<<"Comparing effects of shape systematics... "<<h_Scale_Up->Integral(0,16)<<endl;
    cout <<"Scale ="<<nExTT_El<<" "<< int_scaleup <<" "<<  int_scaledown <<" ==>    "<<100*((k_factor_3*int_scaledown) - nExTT_El )/nExTT_El<<"     "<<100*((k_factor_3*int_scaleup) - nExTT_El )/nExTT_El   <<  endl;
    cout <<"Matching =  "<<nExTT_El << " "<< int_matchingup <<" "<< int_matchingdown <<" ==>    "<<100*((k_factor_3*int_matchingdown) - nExTT_El )/nExTT_El<<"     "<<100*((k_factor_3*int_matchingup) - nExTT_El )/nExTT_El     <<endl;
    cout <<"JES =  "<<nExTT_El<< " "<<k_factor_1*int_jesup <<" "<<k_factor_1*int_jesdown<<" ==>      "<<100*((k_factor_1*int_jesdown) - nExTT_El )/nExTT_El<<"     "<<100*((k_factor_1*int_jesup) - nExTT_El )/nExTT_El     <<endl;
    cout <<"JER =  "<<nExTT_El<< "   "<< k_factor_2*int_jerup <<"   "<< k_factor_2*int_jerdown <<" ==>      "<<100*((k_factor_2*int_jerdown) - nExTT_El )/nExTT_El<<"     "<<100*((k_factor_2*int_jerup) - nExTT_El )/nExTT_El     <<endl;
    cout <<"ttbb =  "<<  nExTT_El         << "   "<<k_factor_1*int_ttbbup <<"   "<< k_factor_1*int_ttbbdown<<" ==>      "<<100*((k_factor_1*int_ttbbdown) - nExTT_El )/nExTT_El<<"      "<<100*((k_factor_1*int_ttbbup) - nExTT_El )/nExTT_El     <<endl;
    cout <<"PU =  "<<nExTT_El << " "<<k_factor_2*int_puup <<"   "<<k_factor_2*int_pudown<<" ==>  "<<100*((k_factor_2*int_pudown) - nExTT_El )/nExTT_El<<"      "<<100*((k_factor_2*int_puup) - nExTT_El )/nExTT_El     <<endl;
    cout <<"lep sf = "<<nExTT_El << "   "<< k_factor_1*int_leptonsfup <<"   "<<k_factor_1*int_leptonsfdown<<" ==>      "<<100*((k_factor_1*int_leptonsfdown) - nExTT_El )/nExTT_El<<"     "<<100*((k_factor_1*int_leptonsfup) - nExTT_El )/nExTT_El     <<endl;
    cout <<"btag =  "<<nExTT_El << "   "<< k_factor_1*int_btagup <<"   "<< k_factor_1*int_btagdown <<" ==>      "<<100*((k_factor_1*int_btagdown) - nExTT_El )/nExTT_El<<"     "<<100*((k_factor_1*int_btagup) - nExTT_El )/nExTT_El     <<endl;
    cout <<"mistag =  "<<  nExTT_El<< "   "<< k_factor_1*int_mistagup <<"   "<< k_factor_1*int_mistagdown <<" ==>      "<<100*((k_factor_1*int_mistagdown) - nExTT_El )/nExTT_El<<"     "<<100*((k_factor_1*int_mistagup) - nExTT_El )/nExTT_El     <<endl;






}
Example #29
0
void fitLMdataDD1()
{
//=========Macro generated from canvas: c1/data fits
//=========  (Thu Jun 30 23:01:40 2016) by ROOT version6.06/02
   TCanvas *c1 = new TCanvas("c1", "data fits",0,0,1200,800);
   gStyle->SetOptStat(0);
   gStyle->SetOptTitle(0);
   c1->Range(0,0,1,1);
   c1->SetFillColor(0);
   c1->SetBorderMode(0);
   c1->SetBorderSize(2);
   c1->SetTickx(1);
   c1->SetTicky(1);
   c1->SetLeftMargin(0.14);
   c1->SetRightMargin(0.05);
   c1->SetTopMargin(0.05);
   c1->SetBottomMargin(0.16);
   c1->SetFrameLineWidth(2);
   c1->SetFrameBorderMode(0);
  
// ------------>Primitives in pad: pad2
   TPad *pad2 = new TPad("pad2", "pad2",0,0,1,0.3);
   pad2->Draw();
   pad2->cd();
   pad2->Range(1075.63,-26.4,1149.704,8.8);
   pad2->SetFillColor(0);
   pad2->SetBorderMode(0);
   pad2->SetBorderSize(2);
   pad2->SetTickx(1);
   pad2->SetTicky(1);
   pad2->SetLeftMargin(0.14);
   pad2->SetRightMargin(0.05);
   pad2->SetTopMargin(0);
   pad2->SetBottomMargin(0.5);
   pad2->SetFrameLineWidth(2);
   pad2->SetFrameBorderMode(0);
   pad2->SetFrameLineWidth(2);
   pad2->SetFrameBorderMode(0);
   
   TH1D *frame_4616180__1 = new TH1D("frame_4616180__1","",100,1086,1146);
   frame_4616180__1->SetBinContent(1,3.231238);
   frame_4616180__1->SetMinimum(-8.8);
   frame_4616180__1->SetMaximum(8.8);
   frame_4616180__1->SetEntries(1);
   frame_4616180__1->SetDirectory(0);
   frame_4616180__1->SetStats(0);
   frame_4616180__1->SetLineWidth(2);
   frame_4616180__1->SetMarkerStyle(20);
   frame_4616180__1->GetXaxis()->SetTitle("#Lambda mass (MeV)");
   frame_4616180__1->GetXaxis()->SetNdivisions(505);
   frame_4616180__1->GetXaxis()->SetLabelFont(132);
   frame_4616180__1->GetXaxis()->SetLabelOffset(0.01);
   frame_4616180__1->GetXaxis()->SetLabelSize(0.15);
   frame_4616180__1->GetXaxis()->SetTitleSize(0.2);
   frame_4616180__1->GetXaxis()->SetTitleOffset(1.1);
   frame_4616180__1->GetXaxis()->SetTitleFont(132);
   frame_4616180__1->GetYaxis()->SetTitle("Pull");
   frame_4616180__1->GetYaxis()->CenterTitle(true);
   frame_4616180__1->GetYaxis()->SetNdivisions(505);
   frame_4616180__1->GetYaxis()->SetLabelFont(132);
   frame_4616180__1->GetYaxis()->SetLabelOffset(0.01);
   frame_4616180__1->GetYaxis()->SetLabelSize(0.15);
   frame_4616180__1->GetYaxis()->SetTitleSize(0.15);
   frame_4616180__1->GetYaxis()->SetTitleOffset(0.45);
   frame_4616180__1->GetYaxis()->SetTitleFont(132);
   frame_4616180__1->GetZaxis()->SetLabelFont(132);
   frame_4616180__1->GetZaxis()->SetLabelSize(0.06);
   frame_4616180__1->GetZaxis()->SetTitleSize(0.072);
   frame_4616180__1->GetZaxis()->SetTitleOffset(1.2);
   frame_4616180__1->GetZaxis()->SetTitleFont(132);
   frame_4616180__1->Draw("FUNC");
   
   Double_t pull_Hist_curvetot_fx3001[100] = {
   1086.3,
   1086.9,
   1087.5,
   1088.1,
   1088.7,
   1089.3,
   1089.9,
   1090.5,
   1091.1,
   1091.7,
   1092.3,
   1092.9,
   1093.5,
   1094.1,
   1094.7,
   1095.3,
   1095.9,
   1096.5,
   1097.1,
   1097.7,
   1098.3,
   1098.9,
   1099.5,
   1100.1,
   1100.7,
   1101.3,
   1101.9,
   1102.5,
   1103.1,
   1103.7,
   1104.3,
   1104.9,
   1105.5,
   1106.1,
   1106.7,
   1107.3,
   1107.9,
   1108.5,
   1109.1,
   1109.7,
   1110.3,
   1110.9,
   1111.5,
   1112.1,
   1112.7,
   1113.3,
   1113.9,
   1114.5,
   1115.1,
   1115.7,
   1116.3,
   1116.9,
   1117.5,
   1118.1,
   1118.7,
   1119.3,
   1119.9,
   1120.5,
   1121.1,
   1121.7,
   1122.3,
   1122.9,
   1123.5,
   1124.1,
   1124.7,
   1125.3,
   1125.9,
   1126.5,
   1127.1,
   1127.7,
   1128.3,
   1128.9,
   1129.5,
   1130.1,
   1130.7,
   1131.3,
   1131.9,
   1132.5,
   1133.1,
   1133.7,
   1134.3,
   1134.9,
   1135.5,
   1136.1,
   1136.7,
   1137.3,
   1137.9,
   1138.5,
   1139.1,
   1139.7,
   1140.3,
   1140.9,
   1141.5,
   1142.1,
   1142.7,
   1143.3,
   1143.9,
   1144.5,
   1145.1,
   1145.7};
   Double_t pull_Hist_curvetot_fy3001[100] = {
   1.567716,
   -0.01802354,
   1.048819,
   -1.337434,
   0.7673198,
   -1.19002,
   1.657461,
   0.3555638,
   -0.4222204,
   0.08805511,
   -1.111787,
   -0.4985715,
   -1.001333,
   -0.4301789,
   -0.8996244,
   -1.03039,
   -0.4813203,
   -1.690616,
   0.136304,
   0.7381026,
   -1.663937,
   0.3265525,
   -0.8449469,
   -1.283283,
   -0.2146925,
   1.001906,
   1.2668,
   -0.8713828,
   -0.2588558,
   0.4168138,
   -1.05013,
   -0.2365293,
   0.9717923,
   0.177655,
   -0.6809003,
   -2.050549,
   -1.317319,
   -1.744711,
   0.7530113,
   -0.5324956,
   -3.192609,
   -0.702433,
   -0.4992051,
   1.446781,
   0.4511227,
   0.1234012,
   -0.1842181,
   -0.6838522,
   0.6279079,
   1.226488,
   0.8796543,
   -1.375341,
   -1.52658,
   -1.501556,
   0.7034038,
   0.2379835,
   0.5620199,
   1.110507,
   1.312001,
   0.4867169,
   -0.9343264,
   -0.1303707,
   1.184677,
   1.786442,
   0.971916,
   -0.2368873,
   0.8377656,
   1.528783,
   0.1657852,
   -0.1623629,
   -0.03456284,
   1.033279,
   0.910172,
   -0.2947283,
   1.647159,
   -1.386851,
   0.3986765,
   0.2064252,
   0.8516845,
   -0.7986838,
   0.1469755,
   0.3027171,
   -0.07111516,
   -1.561177,
   0.07538211,
   0.05947311,
   -0.1374486,
   0.5432766,
   0.691862,
   -0.3671123,
   0.3407757,
   1.545623,
   -0.5970584,
   -2.22819,
   -1.973752,
   0.6254225,
   1.778508,
   -1.274099,
   -0.07162717,
   -5.109475};
   Double_t pull_Hist_curvetot_felx3001[100] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t pull_Hist_curvetot_fely3001[100] = {
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1};
   Double_t pull_Hist_curvetot_fehx3001[100] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t pull_Hist_curvetot_fehy3001[100] = {
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1};
   TGraphAsymmErrors *grae = new TGraphAsymmErrors(100,pull_Hist_curvetot_fx3001,pull_Hist_curvetot_fy3001,pull_Hist_curvetot_felx3001,pull_Hist_curvetot_fehx3001,pull_Hist_curvetot_fely3001,pull_Hist_curvetot_fehy3001);
   grae->SetName("pull_Hist_curvetot");
   grae->SetTitle("Pull of Histogram of data_plot__R_M and Projection of totalPdf");
   grae->SetFillColor(1);
   grae->SetLineWidth(2);
   grae->SetMarkerStyle(8);
   
   TH1F *Graph_pull_Hist_curvetot3001 = new TH1F("Graph_pull_Hist_curvetot3001","Pull of Histogram of data_plot__R_M and Projection of totalPdf",100,1080.36,1151.64);
   Graph_pull_Hist_curvetot3001->SetMinimum(-6.999066);
   Graph_pull_Hist_curvetot3001->SetMaximum(3.676033);
   Graph_pull_Hist_curvetot3001->SetDirectory(0);
   Graph_pull_Hist_curvetot3001->SetStats(0);
   Graph_pull_Hist_curvetot3001->SetLineWidth(2);
   Graph_pull_Hist_curvetot3001->SetMarkerStyle(20);
   Graph_pull_Hist_curvetot3001->GetXaxis()->SetNdivisions(505);
   Graph_pull_Hist_curvetot3001->GetXaxis()->SetLabelFont(132);
   Graph_pull_Hist_curvetot3001->GetXaxis()->SetLabelOffset(0.01);
   Graph_pull_Hist_curvetot3001->GetXaxis()->SetLabelSize(0.06);
   Graph_pull_Hist_curvetot3001->GetXaxis()->SetTitleSize(0.072);
   Graph_pull_Hist_curvetot3001->GetXaxis()->SetTitleOffset(0.95);
   Graph_pull_Hist_curvetot3001->GetXaxis()->SetTitleFont(132);
   Graph_pull_Hist_curvetot3001->GetYaxis()->SetLabelFont(132);
   Graph_pull_Hist_curvetot3001->GetYaxis()->SetLabelOffset(0.01);
   Graph_pull_Hist_curvetot3001->GetYaxis()->SetLabelSize(0.06);
   Graph_pull_Hist_curvetot3001->GetYaxis()->SetTitleSize(0.072);
   Graph_pull_Hist_curvetot3001->GetYaxis()->SetTitleOffset(0.95);
   Graph_pull_Hist_curvetot3001->GetYaxis()->SetTitleFont(132);
   Graph_pull_Hist_curvetot3001->GetZaxis()->SetLabelFont(132);
   Graph_pull_Hist_curvetot3001->GetZaxis()->SetLabelSize(0.06);
   Graph_pull_Hist_curvetot3001->GetZaxis()->SetTitleSize(0.072);
   Graph_pull_Hist_curvetot3001->GetZaxis()->SetTitleOffset(1.2);
   Graph_pull_Hist_curvetot3001->GetZaxis()->SetTitleFont(132);
   grae->SetHistogram(Graph_pull_Hist_curvetot3001);
   
   grae->Draw("p");
   
   TH1D *frame_4616180__2 = new TH1D("frame_4616180__2","",100,1086,1146);
   frame_4616180__2->SetBinContent(1,3.231238);
   frame_4616180__2->SetMinimum(-8.8);
   frame_4616180__2->SetMaximum(8.8);
   frame_4616180__2->SetEntries(1);
   frame_4616180__2->SetDirectory(0);
   frame_4616180__2->SetStats(0);
   frame_4616180__2->SetLineWidth(2);
   frame_4616180__2->SetMarkerStyle(20);
   frame_4616180__2->GetXaxis()->SetTitle("#Lambda mass (MeV)");
   frame_4616180__2->GetXaxis()->SetNdivisions(505);
   frame_4616180__2->GetXaxis()->SetLabelFont(132);
   frame_4616180__2->GetXaxis()->SetLabelOffset(0.01);
   frame_4616180__2->GetXaxis()->SetLabelSize(0.15);
   frame_4616180__2->GetXaxis()->SetTitleSize(0.2);
   frame_4616180__2->GetXaxis()->SetTitleOffset(1.1);
   frame_4616180__2->GetXaxis()->SetTitleFont(132);
   frame_4616180__2->GetYaxis()->SetTitle("Pull");
   frame_4616180__2->GetYaxis()->CenterTitle(true);
   frame_4616180__2->GetYaxis()->SetNdivisions(505);
   frame_4616180__2->GetYaxis()->SetLabelFont(132);
   frame_4616180__2->GetYaxis()->SetLabelOffset(0.01);
   frame_4616180__2->GetYaxis()->SetLabelSize(0.15);
   frame_4616180__2->GetYaxis()->SetTitleSize(0.15);
   frame_4616180__2->GetYaxis()->SetTitleOffset(0.45);
   frame_4616180__2->GetYaxis()->SetTitleFont(132);
   frame_4616180__2->GetZaxis()->SetLabelFont(132);
   frame_4616180__2->GetZaxis()->SetLabelSize(0.06);
   frame_4616180__2->GetZaxis()->SetTitleSize(0.072);
   frame_4616180__2->GetZaxis()->SetTitleOffset(1.2);
   frame_4616180__2->GetZaxis()->SetTitleFont(132);
   frame_4616180__2->Draw("AXISSAME");
   pad2->Modified();
   c1->cd();
  
// ------------>Primitives in pad: pad1
   TPad *pad1 = new TPad("pad1", "pad1",0,0.3,1,1);
   pad1->Draw();
   pad1->cd();
   pad1->Range(1075.63,0,1149.704,4.122406);
   pad1->SetFillColor(0);
   pad1->SetBorderMode(0);
   pad1->SetBorderSize(2);
   pad1->SetLogy();
   pad1->SetTickx(1);
   pad1->SetTicky(1);
   pad1->SetLeftMargin(0.14);
   pad1->SetRightMargin(0.05);
   pad1->SetTopMargin(0.06);
   pad1->SetBottomMargin(0);
   pad1->SetFrameLineWidth(2);
   pad1->SetFrameBorderMode(0);
   pad1->SetFrameLineWidth(2);
   pad1->SetFrameBorderMode(0);
   
   TH1D *frame_4324fb0__3 = new TH1D("frame_4324fb0__3","A RooPlot of \"#Lambda mass\"",100,1086,1146);
   frame_4324fb0__3->SetBinContent(1,1260.154);
   frame_4324fb0__3->SetMinimum(1);
   frame_4324fb0__3->SetMaximum(7500);
   frame_4324fb0__3->SetEntries(1);
   frame_4324fb0__3->SetDirectory(0);
   frame_4324fb0__3->SetStats(0);
   frame_4324fb0__3->SetLineWidth(2);
   frame_4324fb0__3->SetMarkerStyle(20);
   frame_4324fb0__3->GetXaxis()->SetTitle("#Lambda mass (MeV)");
   frame_4324fb0__3->GetXaxis()->SetNdivisions(505);
   frame_4324fb0__3->GetXaxis()->SetLabelFont(132);
   frame_4324fb0__3->GetXaxis()->SetLabelOffset(0.01);
   frame_4324fb0__3->GetXaxis()->SetLabelSize(0.06);
   frame_4324fb0__3->GetXaxis()->SetTitleSize(0.072);
   frame_4324fb0__3->GetXaxis()->SetTitleOffset(0.95);
   frame_4324fb0__3->GetXaxis()->SetTitleFont(132);
   frame_4324fb0__3->GetYaxis()->SetTitle("Events/(5 MeV)");
   frame_4324fb0__3->GetYaxis()->SetLabelFont(132);
   frame_4324fb0__3->GetYaxis()->SetLabelOffset(0.01);
   frame_4324fb0__3->GetYaxis()->SetLabelSize(0.06);
   frame_4324fb0__3->GetYaxis()->SetTitleSize(0.072);
   frame_4324fb0__3->GetYaxis()->SetTitleOffset(0.95);
   frame_4324fb0__3->GetYaxis()->SetTitleFont(132);
   frame_4324fb0__3->GetZaxis()->SetLabelFont(132);
   frame_4324fb0__3->GetZaxis()->SetLabelSize(0.06);
   frame_4324fb0__3->GetZaxis()->SetTitleSize(0.072);
   frame_4324fb0__3->GetZaxis()->SetTitleOffset(1.2);
   frame_4324fb0__3->GetZaxis()->SetTitleFont(132);
   frame_4324fb0__3->Draw("FUNC");
   
   Double_t Hist_fx3002[100] = {
   1086.3,
   1086.9,
   1087.5,
   1088.1,
   1088.7,
   1089.3,
   1089.9,
   1090.5,
   1091.1,
   1091.7,
   1092.3,
   1092.9,
   1093.5,
   1094.1,
   1094.7,
   1095.3,
   1095.9,
   1096.5,
   1097.1,
   1097.7,
   1098.3,
   1098.9,
   1099.5,
   1100.1,
   1100.7,
   1101.3,
   1101.9,
   1102.5,
   1103.1,
   1103.7,
   1104.3,
   1104.9,
   1105.5,
   1106.1,
   1106.7,
   1107.3,
   1107.9,
   1108.5,
   1109.1,
   1109.7,
   1110.3,
   1110.9,
   1111.5,
   1112.1,
   1112.7,
   1113.3,
   1113.9,
   1114.5,
   1115.1,
   1115.7,
   1116.3,
   1116.9,
   1117.5,
   1118.1,
   1118.7,
   1119.3,
   1119.9,
   1120.5,
   1121.1,
   1121.7,
   1122.3,
   1122.9,
   1123.5,
   1124.1,
   1124.7,
   1125.3,
   1125.9,
   1126.5,
   1127.1,
   1127.7,
   1128.3,
   1128.9,
   1129.5,
   1130.1,
   1130.7,
   1131.3,
   1131.9,
   1132.5,
   1133.1,
   1133.7,
   1134.3,
   1134.9,
   1135.5,
   1136.1,
   1136.7,
   1137.3,
   1137.9,
   1138.5,
   1139.1,
   1139.7,
   1140.3,
   1140.9,
   1141.5,
   1142.1,
   1142.7,
   1143.3,
   1143.9,
   1144.5,
   1145.1,
   1145.7};
   Double_t Hist_fy3002[100] = {
   12,
   7,
   11,
   5,
   11,
   6,
   16,
   11,
   9,
   11,
   8,
   10,
   9,
   11,
   10,
   10,
   12,
   9,
   15,
   18,
   10,
   17,
   13,
   12,
   16,
   22,
   24,
   15,
   18,
   22,
   17,
   22,
   31,
   30,
   30,
   29,
   40,
   47,
   79,
   84,
   81,
   128,
   168,
   257,
   335,
   467,
   641,
   828,
   1045,
   1166,
   1142,
   951,
   765,
   571,
   449,
   311,
   231,
   184,
   150,
   115,
   82,
   74,
   73,
   68,
   53,
   39,
   42,
   44,
   33,
   30,
   30,
   36,
   35,
   28,
   40,
   23,
   32,
   31,
   35,
   26,
   31,
   32,
   30,
   23,
   31,
   31,
   30,
   34,
   35,
   29,
   33,
   41,
   28,
   21,
   22,
   35,
   43,
   25,
   31,
   13};
   Double_t Hist_felx3002[100] = {
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3};
   Double_t Hist_fely3002[100] = {
   3.464102,
   2.645751,
   3.316625,
   2.236068,
   3.316625,
   2.44949,
   4,
   3.316625,
   3,
   3.316625,
   2.828427,
   3.162278,
   3,
   3.316625,
   3.162278,
   3.162278,
   3.464102,
   3,
   3.872983,
   4.242641,
   3.162278,
   4.123106,
   3.605551,
   3.464102,
   4,
   4.690416,
   4.898979,
   3.872983,
   4.242641,
   4.690416,
   4.123106,
   4.690416,
   5.567764,
   5.477226,
   5.477226,
   5.385165,
   6.324555,
   6.855655,
   8.888194,
   9.165151,
   9,
   11.31371,
   12.96148,
   16.03122,
   18.30301,
   21.61018,
   25.31798,
   28.77499,
   32.32646,
   34.14674,
   33.79349,
   30.83829,
   27.65863,
   23.89561,
   21.18962,
   17.63519,
   15.19868,
   13.56466,
   12.24745,
   10.72381,
   9.055385,
   8.602325,
   8.544004,
   8.246211,
   7.28011,
   6.244998,
   6.480741,
   6.63325,
   5.744563,
   5.477226,
   5.477226,
   6,
   5.91608,
   5.291503,
   6.324555,
   4.795832,
   5.656854,
   5.567764,
   5.91608,
   5.09902,
   5.567764,
   5.656854,
   5.477226,
   4.795832,
   5.567764,
   5.567764,
   5.477226,
   5.830952,
   5.91608,
   5.385165,
   5.744563,
   6.403124,
   5.291503,
   4.582576,
   4.690416,
   5.91608,
   6.557439,
   5,
   5.567764,
   3.605551};
   Double_t Hist_fehx3002[100] = {
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3,
   0.3};
   Double_t Hist_fehy3002[100] = {
   3.464102,
   2.645751,
   3.316625,
   2.236068,
   3.316625,
   2.44949,
   4,
   3.316625,
   3,
   3.316625,
   2.828427,
   3.162278,
   3,
   3.316625,
   3.162278,
   3.162278,
   3.464102,
   3,
   3.872983,
   4.242641,
   3.162278,
   4.123106,
   3.605551,
   3.464102,
   4,
   4.690416,
   4.898979,
   3.872983,
   4.242641,
   4.690416,
   4.123106,
   4.690416,
   5.567764,
   5.477226,
   5.477226,
   5.385165,
   6.324555,
   6.855655,
   8.888194,
   9.165151,
   9,
   11.31371,
   12.96148,
   16.03122,
   18.30301,
   21.61018,
   25.31798,
   28.77499,
   32.32646,
   34.14674,
   33.79349,
   30.83829,
   27.65863,
   23.89561,
   21.18962,
   17.63519,
   15.19868,
   13.56466,
   12.24745,
   10.72381,
   9.055385,
   8.602325,
   8.544004,
   8.246211,
   7.28011,
   6.244998,
   6.480741,
   6.63325,
   5.744563,
   5.477226,
   5.477226,
   6,
   5.91608,
   5.291503,
   6.324555,
   4.795832,
   5.656854,
   5.567764,
   5.91608,
   5.09902,
   5.567764,
   5.656854,
   5.477226,
   4.795832,
   5.567764,
   5.567764,
   5.477226,
   5.830952,
   5.91608,
   5.385165,
   5.744563,
   6.403124,
   5.291503,
   4.582576,
   4.690416,
   5.91608,
   6.557439,
   5,
   5.567764,
   3.605551};
   grae = new TGraphAsymmErrors(100,Hist_fx3002,Hist_fy3002,Hist_felx3002,Hist_fehx3002,Hist_fely3002,Hist_fehy3002);
   grae->SetName("Hist");
   grae->SetTitle("Histogram of data_plot__R_M");
   grae->SetFillColor(1);
   grae->SetLineWidth(2);
   grae->SetMarkerStyle(8);
   
   TH1F *Graph_Hist3002 = new TH1F("Graph_Hist3002","Histogram of data_plot__R_M",100,1080,1152);
   Graph_Hist3002->SetMinimum(2.487539);
   Graph_Hist3002->SetMaximum(1319.885);
   Graph_Hist3002->SetDirectory(0);
   Graph_Hist3002->SetStats(0);
   Graph_Hist3002->SetLineWidth(2);
   Graph_Hist3002->SetMarkerStyle(20);
   Graph_Hist3002->GetXaxis()->SetNdivisions(505);
   Graph_Hist3002->GetXaxis()->SetLabelFont(132);
   Graph_Hist3002->GetXaxis()->SetLabelOffset(0.01);
   Graph_Hist3002->GetXaxis()->SetLabelSize(0.06);
   Graph_Hist3002->GetXaxis()->SetTitleSize(0.072);
   Graph_Hist3002->GetXaxis()->SetTitleOffset(0.95);
   Graph_Hist3002->GetXaxis()->SetTitleFont(132);
   Graph_Hist3002->GetYaxis()->SetLabelFont(132);
   Graph_Hist3002->GetYaxis()->SetLabelOffset(0.01);
   Graph_Hist3002->GetYaxis()->SetLabelSize(0.06);
   Graph_Hist3002->GetYaxis()->SetTitleSize(0.072);
   Graph_Hist3002->GetYaxis()->SetTitleOffset(0.95);
   Graph_Hist3002->GetYaxis()->SetTitleFont(132);
   Graph_Hist3002->GetZaxis()->SetLabelFont(132);
   Graph_Hist3002->GetZaxis()->SetLabelSize(0.06);
   Graph_Hist3002->GetZaxis()->SetTitleSize(0.072);
   Graph_Hist3002->GetZaxis()->SetTitleOffset(1.2);
   Graph_Hist3002->GetZaxis()->SetTitleFont(132);
   grae->SetHistogram(Graph_Hist3002);
   
   grae->Draw("p");
   
   Double_t curvetot_fx1[139] = {
   1086,
   1086.6,
   1087.2,
   1087.8,
   1088.4,
   1089,
   1089.6,
   1090.2,
   1090.8,
   1091.4,
   1092,
   1092.6,
   1093.2,
   1093.8,
   1094.4,
   1095,
   1095.6,
   1096.2,
   1096.8,
   1097.4,
   1098,
   1098.6,
   1099.2,
   1099.8,
   1100.4,
   1101,
   1101.6,
   1102.2,
   1102.8,
   1103.4,
   1104,
   1104.6,
   1105.2,
   1105.8,
   1106.4,
   1107,
   1107.6,
   1108.2,
   1108.8,
   1109.4,
   1110,
   1110.6,
   1110.9,
   1111.2,
   1111.5,
   1111.8,
   1112.1,
   1112.25,
   1112.4,
   1112.55,
   1112.7,
   1112.85,
   1113,
   1113.15,
   1113.3,
   1113.45,
   1113.6,
   1113.9,
   1114.2,
   1114.5,
   1114.65,
   1114.8,
   1114.95,
   1115.1,
   1115.25,
   1115.4,
   1115.55,
   1115.7,
   1115.85,
   1116,
   1116.15,
   1116.3,
   1116.45,
   1116.6,
   1116.75,
   1116.9,
   1117.05,
   1117.2,
   1117.5,
   1117.8,
   1118.1,
   1118.25,
   1118.4,
   1118.55,
   1118.7,
   1118.85,
   1119,
   1119.15,
   1119.3,
   1119.45,
   1119.6,
   1119.9,
   1120.2,
   1120.5,
   1120.8,
   1121.1,
   1121.4,
   1122,
   1122.6,
   1123.2,
   1123.8,
   1124.4,
   1125,
   1125.6,
   1126.2,
   1126.8,
   1127.4,
   1128,
   1128.6,
   1129.2,
   1129.8,
   1130.4,
   1131,
   1131.6,
   1132.2,
   1132.8,
   1133.4,
   1134,
   1134.6,
   1135.2,
   1135.8,
   1136.4,
   1137,
   1137.6,
   1138.2,
   1138.8,
   1139.4,
   1140,
   1140.6,
   1141.2,
   1141.8,
   1142.4,
   1143,
   1143.6,
   1144.2,
   1144.8,
   1145.4,
   1146,
   1146};
   Double_t curvetot_fy1[139] = {
   6.328904,
   6.809639,
   7.285733,
   7.757187,
   8.224001,
   8.686175,
   9.143709,
   9.596602,
   10.04485,
   10.48847,
   10.92744,
   11.36177,
   11.79147,
   12.21653,
   12.63696,
   13.05277,
   13.46399,
   13.87069,
   14.273,
   14.67119,
   15.0658,
   15.45786,
   15.84932,
   16.24368,
   16.64716,
   17.07038,
   17.53091,
   18.05704,
   18.69267,
   19.5038,
   20.58614,
   22.07345,
   24.14539,
   27.03319,
   31.0207,
   36.43819,
   43.6469,
   53.01601,
   64.90626,
   79.70792,
   98.05289,
   121.4141,
   135.9471,
   153.2937,
   174.4704,
   200.786,
   233.8063,
   253.3648,
   275.2424,
   299.6417,
   326.7431,
   356.6932,
   389.5923,
   425.4823,
   464.3333,
   506.0327,
   550.3752,
   645.664,
   746.513,
   847.6778,
   896.3993,
   942.7281,
   985.7829,
   1024.702,
   1058.673,
   1086.963,
   1108.945,
   1124.119,
   1132.139,
   1132.819,
   1126.145,
   1112.273,
   1091.526,
   1064.377,
   1031.433,
   993.4132,
   951.1172,
   905.4008,
   807.2231,
   705.7161,
   606.8806,
   559.9721,
   515.3401,
   473.3072,
   434.0951,
   397.8313,
   364.5585,
   334.2463,
   306.8031,
   282.0892,
   259.929,
   222.458,
   192.6838,
   168.9364,
   149.7481,
   133.9313,
   120.5882,
   98.97284,
   81.94853,
   68.29445,
   57.46178,
   49.07547,
   42.77322,
   38.1855,
   34.95581,
   32.76258,
   31.33269,
   30.44591,
   29.93271,
   29.66794,
   29.56276,
   29.55635,
   29.60855,
   29.69366,
   29.79583,
   29.90552,
   30.01721,
   30.12779,
   30.23556,
   30.33959,
   30.43944,
   30.53485,
   30.62573,
   30.71201,
   30.79367,
   30.87069,
   30.94308,
   31.01084,
   31.07395,
   31.13242,
   31.18625,
   31.23544,
   31.28,
   31.31991,
   31.35518,
   31.38581,
   31.4118,
   31.43315,
   31.43315};
   TGraph *graph = new TGraph(139,curvetot_fx1,curvetot_fy1);
   graph->SetName("curvetot");
   graph->SetTitle("Projection of totalPdf");
   graph->SetFillColor(1);

   Int_t ci;      // for color index setting
   TColor *color; // for color definition with alpha
   ci = TColor::GetColor("#0000ff");
   graph->SetLineColor(ci);
   graph->SetLineWidth(3);
   graph->SetMarkerStyle(20);
   
   TH1F *Graph_curvetot1 = new TH1F("Graph_curvetot1","Projection of totalPdf",139,1080,1152);
   Graph_curvetot1->SetMinimum(5.696013);
   Graph_curvetot1->SetMaximum(1245.468);
   Graph_curvetot1->SetDirectory(0);
   Graph_curvetot1->SetStats(0);
   Graph_curvetot1->SetLineWidth(2);
   Graph_curvetot1->SetMarkerStyle(20);
   Graph_curvetot1->GetXaxis()->SetNdivisions(505);
   Graph_curvetot1->GetXaxis()->SetLabelFont(132);
   Graph_curvetot1->GetXaxis()->SetLabelOffset(0.01);
   Graph_curvetot1->GetXaxis()->SetLabelSize(0.06);
   Graph_curvetot1->GetXaxis()->SetTitleSize(0.072);
   Graph_curvetot1->GetXaxis()->SetTitleOffset(0.95);
   Graph_curvetot1->GetXaxis()->SetTitleFont(132);
   Graph_curvetot1->GetYaxis()->SetLabelFont(132);
   Graph_curvetot1->GetYaxis()->SetLabelOffset(0.01);
   Graph_curvetot1->GetYaxis()->SetLabelSize(0.06);
   Graph_curvetot1->GetYaxis()->SetTitleSize(0.072);
   Graph_curvetot1->GetYaxis()->SetTitleOffset(0.95);
   Graph_curvetot1->GetYaxis()->SetTitleFont(132);
   Graph_curvetot1->GetZaxis()->SetLabelFont(132);
   Graph_curvetot1->GetZaxis()->SetLabelSize(0.06);
   Graph_curvetot1->GetZaxis()->SetTitleSize(0.072);
   Graph_curvetot1->GetZaxis()->SetTitleOffset(1.2);
   Graph_curvetot1->GetZaxis()->SetTitleFont(132);
   graph->SetHistogram(Graph_curvetot1);
   
   graph->Draw("l");
   
   Double_t bkg_fx2[102] = {
   1086,
   1086.6,
   1087.2,
   1087.8,
   1088.4,
   1089,
   1089.6,
   1090.2,
   1090.8,
   1091.4,
   1092,
   1092.6,
   1093.2,
   1093.8,
   1094.4,
   1095,
   1095.6,
   1096.2,
   1096.8,
   1097.4,
   1098,
   1098.6,
   1099.2,
   1099.8,
   1100.4,
   1101,
   1101.6,
   1102.2,
   1102.8,
   1103.4,
   1104,
   1104.6,
   1105.2,
   1105.8,
   1106.4,
   1107,
   1107.6,
   1108.2,
   1108.8,
   1109.4,
   1110,
   1110.6,
   1111.2,
   1111.8,
   1112.4,
   1113,
   1113.6,
   1114.2,
   1114.8,
   1115.4,
   1116,
   1116.6,
   1117.2,
   1117.8,
   1118.4,
   1119,
   1119.6,
   1120.2,
   1120.8,
   1121.4,
   1122,
   1122.6,
   1123.2,
   1123.8,
   1124.4,
   1125,
   1125.6,
   1126.2,
   1126.8,
   1127.4,
   1128,
   1128.6,
   1129.2,
   1129.8,
   1130.4,
   1131,
   1131.6,
   1132.2,
   1132.8,
   1133.4,
   1134,
   1134.6,
   1135.2,
   1135.8,
   1136.4,
   1137,
   1137.6,
   1138.2,
   1138.8,
   1139.4,
   1140,
   1140.6,
   1141.2,
   1141.8,
   1142.4,
   1143,
   1143.6,
   1144.2,
   1144.8,
   1145.4,
   1146,
   1146};
   Double_t bkg_fy2[102] = {
   6.328904,
   6.809639,
   7.285733,
   7.757187,
   8.224001,
   8.686175,
   9.143709,
   9.596602,
   10.04485,
   10.48847,
   10.92744,
   11.36177,
   11.79146,
   12.21652,
   12.63693,
   13.0527,
   13.46383,
   13.87032,
   14.27217,
   14.66938,
   15.06195,
   15.44988,
   15.83317,
   16.21182,
   16.58583,
   16.9552,
   17.31993,
   17.68001,
   18.03546,
   18.38627,
   18.73244,
   19.07397,
   19.41085,
   19.7431,
   20.07071,
   20.39367,
   20.712,
   21.02568,
   21.33473,
   21.63913,
   21.9389,
   22.23402,
   22.52451,
   22.81035,
   23.09156,
   23.36812,
   23.64004,
   23.90733,
   24.16997,
   24.42797,
   24.68134,
   24.93006,
   25.17414,
   25.41358,
   25.64838,
   25.87855,
   26.10407,
   26.32495,
   26.54119,
   26.75279,
   26.95975,
   27.16207,
   27.35975,
   27.55279,
   27.74119,
   27.92495,
   28.10406,
   28.27854,
   28.44838,
   28.61358,
   28.77414,
   28.93005,
   29.08133,
   29.22797,
   29.36996,
   29.50732,
   29.64004,
   29.76811,
   29.89155,
   30.01034,
   30.1245,
   30.23401,
   30.33889,
   30.43912,
   30.53472,
   30.62567,
   30.71198,
   30.79366,
   30.87069,
   30.94308,
   31.01084,
   31.07395,
   31.13242,
   31.18625,
   31.23544,
   31.28,
   31.31991,
   31.35518,
   31.38581,
   31.4118,
   31.43315,
   31.43315};
   graph = new TGraph(102,bkg_fx2,bkg_fy2);
   graph->SetName("bkg");
   graph->SetTitle("Projection of totalPdf");
   graph->SetFillColor(1);
   graph->SetLineColor(2);
   graph->SetLineStyle(2);
   graph->SetLineWidth(3);
   graph->SetMarkerStyle(20);
   
   TH1F *Graph_bkg2 = new TH1F("Graph_bkg2","Projection of totalPdf",102,1080,1152);
   Graph_bkg2->SetMinimum(3.818479);
   Graph_bkg2->SetMaximum(33.94357);
   Graph_bkg2->SetDirectory(0);
   Graph_bkg2->SetStats(0);
   Graph_bkg2->SetLineWidth(2);
   Graph_bkg2->SetMarkerStyle(20);
   Graph_bkg2->GetXaxis()->SetNdivisions(505);
   Graph_bkg2->GetXaxis()->SetLabelFont(132);
   Graph_bkg2->GetXaxis()->SetLabelOffset(0.01);
   Graph_bkg2->GetXaxis()->SetLabelSize(0.06);
   Graph_bkg2->GetXaxis()->SetTitleSize(0.072);
   Graph_bkg2->GetXaxis()->SetTitleOffset(0.95);
   Graph_bkg2->GetXaxis()->SetTitleFont(132);
   Graph_bkg2->GetYaxis()->SetLabelFont(132);
   Graph_bkg2->GetYaxis()->SetLabelOffset(0.01);
   Graph_bkg2->GetYaxis()->SetLabelSize(0.06);
   Graph_bkg2->GetYaxis()->SetTitleSize(0.072);
   Graph_bkg2->GetYaxis()->SetTitleOffset(0.95);
   Graph_bkg2->GetYaxis()->SetTitleFont(132);
   Graph_bkg2->GetZaxis()->SetLabelFont(132);
   Graph_bkg2->GetZaxis()->SetLabelSize(0.06);
   Graph_bkg2->GetZaxis()->SetTitleSize(0.072);
   Graph_bkg2->GetZaxis()->SetTitleOffset(1.2);
   Graph_bkg2->GetZaxis()->SetTitleFont(132);
   graph->SetHistogram(Graph_bkg2);
   
   graph->Draw("l");
   
   Double_t sigLM_fx3[139] = {
   1086,
   1086.6,
   1087.2,
   1087.8,
   1088.4,
   1089,
   1089.6,
   1090.2,
   1090.8,
   1091.4,
   1092,
   1092.6,
   1093.2,
   1093.8,
   1094.4,
   1095,
   1095.6,
   1096.2,
   1096.8,
   1097.4,
   1098,
   1098.6,
   1099.2,
   1099.8,
   1100.4,
   1101,
   1101.6,
   1102.2,
   1102.8,
   1103.4,
   1104,
   1104.6,
   1105.2,
   1105.8,
   1106.4,
   1107,
   1107.6,
   1108.2,
   1108.8,
   1109.4,
   1110,
   1110.6,
   1110.9,
   1111.2,
   1111.5,
   1111.8,
   1112.1,
   1112.25,
   1112.4,
   1112.55,
   1112.7,
   1112.85,
   1113,
   1113.15,
   1113.3,
   1113.45,
   1113.6,
   1113.9,
   1114.2,
   1114.5,
   1114.65,
   1114.8,
   1114.95,
   1115.1,
   1115.25,
   1115.4,
   1115.55,
   1115.7,
   1115.85,
   1116,
   1116.15,
   1116.3,
   1116.45,
   1116.6,
   1116.75,
   1116.9,
   1117.05,
   1117.2,
   1117.5,
   1117.8,
   1118.1,
   1118.25,
   1118.4,
   1118.55,
   1118.7,
   1118.85,
   1119,
   1119.15,
   1119.3,
   1119.45,
   1119.6,
   1119.9,
   1120.2,
   1120.5,
   1120.8,
   1121.1,
   1121.4,
   1122,
   1122.6,
   1123.2,
   1123.8,
   1124.4,
   1125,
   1125.6,
   1126.2,
   1126.8,
   1127.4,
   1128,
   1128.6,
   1129.2,
   1129.8,
   1130.4,
   1131,
   1131.6,
   1132.2,
   1132.8,
   1133.4,
   1134,
   1134.6,
   1135.2,
   1135.8,
   1136.4,
   1137,
   1137.6,
   1138.2,
   1138.8,
   1139.4,
   1140,
   1140.6,
   1141.2,
   1141.8,
   1142.4,
   1143,
   1143.6,
   1144.2,
   1144.8,
   1145.4,
   1146,
   1146};
   Double_t sigLM_fy3[139] = {
   9.707338e-12,
   3.306592e-11,
   1.098715e-10,
   3.561345e-10,
   1.126074e-09,
   3.473315e-09,
   1.045071e-08,
   3.067406e-08,
   8.782559e-08,
   2.452986e-07,
   6.683337e-07,
   1.776298e-06,
   4.605348e-06,
   1.164751e-05,
   2.873613e-05,
   6.915881e-05,
   0.0001623645,
   0.0003718421,
   0.0008307119,
   0.001810366,
   0.003848635,
   0.007981255,
   0.01614581,
   0.03186198,
   0.0613352,
   0.1151784,
   0.2109874,
   0.3770216,
   0.6572038,
   1.117527,
   1.853704,
   2.999486,
   4.734538,
   7.290089,
   10.94999,
   16.04452,
   22.9349,
   31.99033,
   43.57153,
   58.06879,
   76.11399,
   99.18006,
   113.5673,
   130.7692,
   151.8024,
   177.9756,
   210.8548,
   230.3431,
   252.1508,
   276.4806,
   303.5127,
   333.3937,
   366.2242,
   402.0458,
   440.8286,
   482.4602,
   526.7351,
   621.8898,
   722.6056,
   823.6386,
   872.2946,
   918.5582,
   961.5479,
   1000.402,
   1034.309,
   1062.535,
   1084.453,
   1099.564,
   1107.521,
   1108.138,
   1101.401,
   1087.467,
   1066.658,
   1039.447,
   1006.442,
   968.3605,
   926.0036,
   880.2266,
   781.9287,
   680.3025,
   581.349,
   534.3819,
   489.6917,
   447.6009,
   408.3311,
   372.0098,
   338.68,
   308.3109,
   280.8112,
   256.0411,
   233.825,
   196.243,
   166.3589,
   142.5027,
   123.2069,
   107.2838,
   93.83545,
   72.01309,
   54.78646,
   40.93471,
   29.90899,
   21.33429,
   14.84827,
   10.08144,
   6.67727,
   4.314204,
   2.71911,
   1.671772,
   1.002655,
   0.5866114,
   0.3347908,
   0.1863892,
   0.101226,
   0.05362751,
   0.02771452,
   0.01397177,
   0.006870993,
   0.003296188,
   0.001542512,
   0.0007041567,
   0.0003135698,
   0.0001362145,
   5.77214e-05,
   2.386022e-05,
   9.621356e-06,
   3.78462e-06,
   1.45222e-06,
   5.435843e-07,
   1.98484e-07,
   7.069819e-08,
   2.456492e-08,
   8.326194e-09,
   2.752973e-09,
   8.879359e-10,
   2.793736e-10,
   8.574592e-11,
   2.567235e-11,
   7.497942e-12,
   7.497942e-12};
   graph = new TGraph(139,sigLM_fx3,sigLM_fy3);
   graph->SetName("sigLM");
   graph->SetTitle("Projection of totalPdf");
   graph->SetFillColor(1);
   graph->SetLineColor(3);
   graph->SetLineStyle(2);
   graph->SetLineWidth(3);
   graph->SetMarkerStyle(20);
   
   TH1F *Graph_sigLM3 = new TH1F("Graph_sigLM3","Projection of totalPdf",139,1080,1152);
   Graph_sigLM3->SetMinimum(6.748148e-12);
   Graph_sigLM3->SetMaximum(1218.952);
   Graph_sigLM3->SetDirectory(0);
   Graph_sigLM3->SetStats(0);
   Graph_sigLM3->SetLineWidth(2);
   Graph_sigLM3->SetMarkerStyle(20);
   Graph_sigLM3->GetXaxis()->SetNdivisions(505);
   Graph_sigLM3->GetXaxis()->SetLabelFont(132);
   Graph_sigLM3->GetXaxis()->SetLabelOffset(0.01);
   Graph_sigLM3->GetXaxis()->SetLabelSize(0.06);
   Graph_sigLM3->GetXaxis()->SetTitleSize(0.072);
   Graph_sigLM3->GetXaxis()->SetTitleOffset(0.95);
   Graph_sigLM3->GetXaxis()->SetTitleFont(132);
   Graph_sigLM3->GetYaxis()->SetLabelFont(132);
   Graph_sigLM3->GetYaxis()->SetLabelOffset(0.01);
   Graph_sigLM3->GetYaxis()->SetLabelSize(0.06);
   Graph_sigLM3->GetYaxis()->SetTitleSize(0.072);
   Graph_sigLM3->GetYaxis()->SetTitleOffset(0.95);
   Graph_sigLM3->GetYaxis()->SetTitleFont(132);
   Graph_sigLM3->GetZaxis()->SetLabelFont(132);
   Graph_sigLM3->GetZaxis()->SetLabelSize(0.06);
   Graph_sigLM3->GetZaxis()->SetTitleSize(0.072);
   Graph_sigLM3->GetZaxis()->SetTitleOffset(1.2);
   Graph_sigLM3->GetZaxis()->SetTitleFont(132);
   graph->SetHistogram(Graph_sigLM3);
   
   graph->Draw("l");
   
   TLegend *leg = new TLegend(0.75,0.5,1,0.9,NULL,"brNDC");
   leg->SetBorderSize(0);
   leg->SetTextFont(132);
   leg->SetTextSize(0.06);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(2);
   leg->SetFillColor(0);
   leg->SetFillStyle(1001);
   TLegendEntry *entry=leg->AddEntry("curvetot","Total PDF","l");

   ci = TColor::GetColor("#0000ff");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(3);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(132);
   entry=leg->AddEntry("bkg","Background","l");
   entry->SetLineColor(2);
   entry->SetLineStyle(2);
   entry->SetLineWidth(3);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(132);
   entry=leg->AddEntry("sigLM","#Lambda M (dbl Gaus)","l");
   entry->SetLineColor(3);
   entry->SetLineStyle(2);
   entry->SetLineWidth(3);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(132);
   leg->Draw();
   
   TH1D *frame_4324fb0__4 = new TH1D("frame_4324fb0__4","A RooPlot of \"#Lambda mass\"",100,1086,1146);
   frame_4324fb0__4->SetBinContent(1,1260.154);
   frame_4324fb0__4->SetMinimum(1);
   frame_4324fb0__4->SetMaximum(7500);
   frame_4324fb0__4->SetEntries(1);
   frame_4324fb0__4->SetDirectory(0);
   frame_4324fb0__4->SetStats(0);
   frame_4324fb0__4->SetLineWidth(2);
   frame_4324fb0__4->SetMarkerStyle(20);
   frame_4324fb0__4->GetXaxis()->SetTitle("#Lambda mass (MeV)");
   frame_4324fb0__4->GetXaxis()->SetNdivisions(505);
   frame_4324fb0__4->GetXaxis()->SetLabelFont(132);
   frame_4324fb0__4->GetXaxis()->SetLabelOffset(0.01);
   frame_4324fb0__4->GetXaxis()->SetLabelSize(0.06);
   frame_4324fb0__4->GetXaxis()->SetTitleSize(0.072);
   frame_4324fb0__4->GetXaxis()->SetTitleOffset(0.95);
   frame_4324fb0__4->GetXaxis()->SetTitleFont(132);
   frame_4324fb0__4->GetYaxis()->SetTitle("Events/(5 MeV)");
   frame_4324fb0__4->GetYaxis()->SetLabelFont(132);
   frame_4324fb0__4->GetYaxis()->SetLabelOffset(0.01);
   frame_4324fb0__4->GetYaxis()->SetLabelSize(0.06);
   frame_4324fb0__4->GetYaxis()->SetTitleSize(0.072);
   frame_4324fb0__4->GetYaxis()->SetTitleOffset(0.95);
   frame_4324fb0__4->GetYaxis()->SetTitleFont(132);
   frame_4324fb0__4->GetZaxis()->SetLabelFont(132);
   frame_4324fb0__4->GetZaxis()->SetLabelSize(0.06);
   frame_4324fb0__4->GetZaxis()->SetTitleSize(0.072);
   frame_4324fb0__4->GetZaxis()->SetTitleOffset(1.2);
   frame_4324fb0__4->GetZaxis()->SetTitleFont(132);
   frame_4324fb0__4->Draw("AXISSAME");
   pad1->Modified();
   c1->cd();
   c1->Modified();
   c1->cd();
   c1->SetSelected(c1);
}
Example #30
0
int main (int argc, char **argv) 
{
  gROOT->SetStyle ("Plain") ;

  int N_MG = 50000 ;
  float XS_MG = 207.03 * 0.22 * 0.22  ; /* fb */
  map<string, TH1F *> hmap_MG = 
    readSample ("/Users/govoni/data/TP/compareEWK/WW/madgraph.lhe", "MG", N_MG) ;

  float XS_MGBB = 232.37 * 0.22 * 0.22 ; /* fb */
//  int N_MGBB = 10000 ;
//  map<string, TH1F *> hmap_MGBB = 
//    readSample ("/Users/govoni/data/TP/compareEWK/WW/madgraph_bb.lhe", "MGBB", N_MGBB) ;
  int N_MGBB = 400000 ; // max = 490.000 
  map<string, TH1F *> hmap_MGBB = 
    readSample ("/Users/govoni/data/TP/Madgraph_bbar_WW_SS_QED4_QCD0_DECAY/total.lhe", "MGBB", N_MGBB) ;

  int N_PH = 79904 ;
  float XS_PH = 8.262 ; /* fb */
  map<string, TH1F *> hmap_PH = 
    readSample ("/Users/govoni/data/TP/compareEWK/WW/phantom.lhe", "PH", N_PH) ;

  TFile outfile ("testWW.root", "recreate") ;
  savemap (hmap_MG,  outfile,  XS_MG * 1./N_MG) ;  /*result in fb */
  savemap (hmap_MGBB,  outfile,  XS_MGBB * 1./N_MGBB) ;  /*result in fb */
  savemap (hmap_PH,  outfile,  XS_PH * 1./N_PH) ;  /*result in fb */
  
  gStyle->SetStatStyle (0) ; 
  gStyle->SetTitleStyle (0) ; 
  gStyle->SetCanvasBorderSize (0) ; 
  gStyle->SetFrameBorderSize (0) ; 
  gStyle->SetLegendBorderSize (0) ; 
  gStyle->SetStatBorderSize (0) ; 
  gStyle->SetTitleBorderSize (0) ; 
  gStyle->SetTitleYOffset (2) ;

  TCanvas c1 ;
  c1.SetLeftMargin (0.17) ; 
  c1.SetTopMargin (0.1) ; 
  
  map<string, TH1F *>::iterator iMap_PH = hmap_PH.begin () ;
  map<string, TH1F *>::iterator iMap_MG = hmap_MG.begin () ;

  // plotting
  for (map<string, TH1F *>::iterator iMap_MGBB = hmap_MGBB.begin () ;
       iMap_MGBB != hmap_MGBB.end () ;
       ++iMap_MGBB)
    {
      iMap_MGBB->second->SetStats (0) ;
      iMap_MG->second->SetStats (0) ;
      iMap_PH->second->SetStats (0) ;
      
      iMap_MGBB->second->SetTitle ("") ;
      iMap_MG->second->SetTitle ("") ;
      iMap_PH->second->SetTitle ("") ;
      
      iMap_MGBB->second->SetLineWidth (2) ;
      iMap_MG->second->SetLineWidth (2) ;
      iMap_PH->second->SetLineWidth (2) ;
      
      iMap_MGBB->second->SetLineColor (2) ;
      iMap_MG->second->SetLineColor (30) ;
      iMap_PH->second->SetLineColor (9) ;
      
      iMap_MG->second->SetFillColor (30) ;

      TLegend leg (0.3, 0.9, 0.8, 1) ;
      leg.SetNColumns (3) ;
      leg.SetLineStyle (0) ;
      leg.SetFillStyle (0) ;
      leg.AddEntry (iMap_MGBB->second, "madgraph NEW", "fl") ;
      leg.AddEntry (iMap_MG->second, "madgraph", "fl") ;
      leg.AddEntry (iMap_PH->second, "phantom", "fl") ;
      
      iMap_MGBB->second->GetXaxis ()->SetTitle (iMap_MGBB->first.c_str ()) ;        
      iMap_MG->second->GetXaxis ()->SetTitle (iMap_MG->first.c_str ()) ;        
      iMap_PH->second->GetXaxis ()->SetTitle (iMap_PH->first.c_str ()) ;        
      iMap_PH->second->Draw () ;           
      iMap_MG->second->Draw ("same") ;           
      iMap_MGBB->second->Draw ("same") ;           
      iMap_MG->second->DrawCopy ("histsame") ;   
      iMap_MGBB->second->DrawCopy ("histsame") ;   
      iMap_PH->second->SetFillStyle (3001) ;
      iMap_PH->second->SetFillColor (9) ;
      iMap_PH->second->DrawCopy ("E2same") ;           
      iMap_PH->second->SetFillStyle (0) ;
      iMap_PH->second->SetFillColor (0) ;
      iMap_PH->second->Draw ("same") ;           
      leg.Draw () ;
      c1.Print (("WW_" + iMap_MGBB->first + ".png").c_str (), "png") ;
      iMap_PH->second->DrawNormalized ("E2") ;           
      iMap_MG->second->DrawNormalized ("histsame") ;   
      iMap_MGBB->second->DrawNormalized ("histsame") ;   
      iMap_PH->second->DrawNormalized ("E2same") ;           
      leg.Draw () ;
      c1.Print (("WW_" + iMap_MG->first + "_norm.png").c_str (), "png") ;

      ++iMap_PH ;
      ++iMap_MG ;
    }   
  
  return 0 ;
}