Esempio n. 1
0
void AnalysisSparse(Bool_t save_output = kFALSE)
{
  gStyle->SetGridColor(kGray);
  //  TString tmpstr(fname);
  //  if (tmpstr.Contains("data")) {
  //    Printf("!!! Real Data !!!");
  //    mc = kFALSE;
  //  }
  TString gtitle = Form("Monte Carlo, %s", graph_name.Data());
  grapht = graph_name.Data();
  Double_t grx[999], gry[999], gry2[999], gry3[999], gry4[999],
    gry_eff[999], gry_fix[999], grxE[999];
  Double_t gry22[999], gry22E[999], grx22E[999];
  Double_t gry_true[999], gry_true_eff[999], gry_true_effE[999];
  TH1::AddDirectory(kFALSE);
  TFile::SetCacheFileDir(gSystem->HomeDirectory());
  TFile *f = TFile::Open(fname.Data(), "CACHEREAD");
  if (!f) return;
  TList *l; f->GetObject(lname.Data(), l);
  if (!l) return;
  Int_t bf[999], bl[999];
  Int_t nn = FindExactRange(((THnSparse *)(l->FindObject(s1name.Data())))->
                            Projection(1), del_step, bf, bl);
  //  Int_t nn = FindRange5(bf, bl);
  Bool_t binhaluska = kFALSE;
  if (binAnders) {
    nn = 8;
    bf[0] = 6;bf[1] =  9;bf[2] = 11;bf[3] = 16;bf[4] = 21;bf[5] = 26;
    bl[0] = 8;bl[1] = 10;bl[2] = 15;bl[3] = 20;bl[4] = 25;bl[5] = 30;

    bf[6] = 31;bf[7] = 41;
    bl[6] = 40;bl[7] = 50;
  }
  Printf("number of intervals = %d =>", nn);

  Int_t count = 0;
  Double_t ptmean = 0, value = 0;
  Int_t fitStatus = -1;
  gStyle->SetOptStat(0);
  TCanvas *c = new TCanvas("c", "Signal & Background");
  c->Divide(5, 5); c->Modified(); c->Draw();
  TCanvas *c2 = (TCanvas *)c->DrawClone("c2");
  c2->SetTitle("Phi mesons (raw)"); c2->Modified(); c2->Draw();
  TCanvas *c3, *c4;
  if (mc) {
    c3 = (TCanvas *)c->DrawClone("c3");
    c3->SetTitle("Phi mesons (gen)"); c3->Modified(); c3->Draw();
    c4 = (TCanvas *)c->DrawClone("c4");
    c4->SetTitle("Phi mesons (true)"); c4->Modified(); c4->Draw();
  }

  for (Int_t i = 0; i < nn; i++) {
    c->cd(count + 1)->SetGrid();
    h1 = (TH1D *)PullHisto(l, s1name.Data(), bf[i], bl[i], ptmean);
    h1->SetLineColor(kRed);
    h1->GetXaxis()->SetTitle("inv. mass, GeV/c^2");
    h1->Draw("hist");

    h3_p = (TH1D *)PullHisto(l, s3name_p.Data(), bf[i], bl[i], ptmean);
    h3_m = (TH1D *)PullHisto(l, s3name_m.Data(), bf[i], bl[i], ptmean);
    // !!!!!!!!!!!!!!!!!!!!!!!!
    if (count==0) h3_p = h1;
    // !!!!!!!!!!!!!!!!!!!!!!!!
    else {
      h3_p->Add(h3_m);
      //      h3_p->Add((TH1D *)PullHisto(l, smix.Data(), bf[i], bl[i], ptmean));
      //      h3_p->Add((TH1D *)PullHisto(l, smixpp.Data(), bf[i], bl[i], ptmean));
      //      h3_p->Add((TH1D *)PullHisto(l, smixmm.Data(), bf[i], bl[i], ptmean));
      Norm(h1, h3_p, norm[0], norm[1]);
    }
    h3_p->SetLineColor(kBlue);
    h3_p->Draw("hist, same");

    if (mc) {
      c3->cd(count + 1)->SetGrid();
      Printf("%s", s1namegen.Data());
      hg = (TH1D *)PullHisto(l, s1namegen.Data(), bf[i], bl[i], ptmean);
      hg->SetLineColor(kMagenta);
      hg->GetXaxis()->SetTitle("inv. mass, GeV/c^2");
      hg->Draw("hist");
      c4->cd(count + 1)->SetGrid();
      ht = (TH1D *)PullHisto(l, s1nametrue.Data(), bf[i], bl[i], ptmean);
      ht->SetLineColor(kMagenta-5);
      ht->GetXaxis()->SetTitle("inv. mass, GeV/c^2");
      ht->Draw("hist");
    }
    c2->cd(count + 1)->SetGrid();
    TH1 *hh = (TH1 *)h1->Clone("hh");
    hh->SetLineColor(kRed+1);
    hh->Add(h3_p, -1);
    /// !!!!!!!!!!!!!!!!!!!!!!
    //////////    if ((ilist == 3) && (count < 2)) hh->Reset();
    // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    hh->Draw("hist");

    // !!!!!!!!!!!!!!!!!!
    ff->SetParameters(0.1, 1.02, 0.004, -25000., 0., 0., 0.);
    ff->SetLineColor(hh->GetLineColor());
    ff->SetLineWidth(1);
    //    ff->SetLineStyle(kDashed);
    // where fit
    Double_t fmin = 1.02-2*0.004;
    Double_t fmax = 1.02+2*0.004;
    //    Double_t fmin = 0.995;
    //    Double_t fmax = 1.185;
    // !!!!!!!!!!!!!!!!!!
    Bool_t hisfun = kFALSE; // kFALSE = integral from function
    Double_t   hisfun_k = 1.0/hh->GetBinWidth(10);
    // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    if (binhaluska)
      if (i > 9) hisfun_k = 0.5/hh->GetBinWidth(10);
    Printf("======= %f", hisfun_k);
    // !!!!!!!!!!!!!!!!!!
    // wehere integral (his or fun)
    Double_t fmini = 1.02-2*0.004;
    Double_t fmaxi = 1.02+2*0.004;
    hh->Fit(ff, "Q", "", fmin, fmax);
    hh->Fit(ff, "Q", "", fmin, fmax);
    fitStatus = hh->Fit(ff, "Q", "", fmin, fmax);
    TF1 *pp3 = new TF1("pp3", "[0]+x*[1]+x*x*[2]+x*x*x*[3]", fmin, fmax);
    pp3->SetParameters(ff->GetParameter(3), ff->GetParameter(4),
                       ff->GetParameter(5), ff->GetParameter(6));
    pp3->SetLineWidth(1);
    pp3->SetLineColor(h3_p->GetLineColor());
    pp3->Draw("same");
    // ff->SetRange(fmin, fmax);
    // ff->DrawCopy("same");

    value              = hh->Integral(hh->FindBin(fmini), hh->FindBin(fmaxi));
    if (!hisfun) value = ff->Integral(fmini, fmaxi)*hisfun_k -
                   pp3->Integral(fmini, fmaxi)*hisfun_k;
    if (value < 0) value = 0;

    if ((fitStatus != 0) || (ff->GetParameter(2) > 0.1)) {
      printf(" SKIP Data");
      value = 0;
    }
    grx[count] = ptmean;
    if (binhaluska) {
      if (count < 10) grxE[count] = 0.25; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      else            grxE[count] = 0.50; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    }
    else
      //      grxE[count] = (1.30-1.10)/2.0; // !!!!!!!!!!!!!!!!!!!!!!!!!!
      grxE[count] = 0.05;
    gry[count] = value;

    Double_t tmp1 = h1->Integral(h1->FindBin(fmini), h1->FindBin(fmaxi));
    Double_t tmp2 = h3_p->Integral(h3_p->FindBin(fmini), h3_p->FindBin(fmaxi));
    Double_t tmp_sg = tmp1 - tmp2;
    Double_t tmp_bg = tmp2;

    // if ((tmp_sg <= -tmp_bg) || (tmp_bg < 33.0)) {
    //   gry3[count] = 0.0;
    //   gry4[count] = 0.0;
    // }
    // else {
    gry3[count] = tmp_sg/tmp_bg;
    gry4[count] = tmp_sg/TMath::Sqrt(tmp_sg + tmp_bg);
    // }

    //    Printf("%4.2f, %10f, %10f, %10f", ptmean, tmp1, tmp2, gry3[count]);


    if (mc) {
      c3->cd(count + 1);
      // !!!!!!!!!!!!!!!!
      ff->SetParameters(1, 1.02, 0.004, 0., 0., 0., 0.);
      hg->Fit(ff, "Q", "", fmin, fmax);
      hg->Fit(ff, "Q", "", fmin, fmax);
      fitStatus = hg->Fit(ff, "Q", "", fmin, fmax);
      /*      TF1 *pp3 = new TF1("pp3", "[0]+x*[1]+x*x*[2]+x*x*x*[3]", fmin, fmax);
              pp3->SetParameters(ff->GetParameter(3), ff->GetParameter(4),
              ff->GetParameter(5), ff->GetParameter(6));
              pp3->SetLineWidth(1);
              pp3->SetLineColor(h3_p->GetLineColor());
              pp3->Draw("same");
      */

      value              = hg->Integral(hg->FindBin(fmini), hg->FindBin(fmaxi));
      if (!hisfun) value = ff->Integral(fmini, fmaxi)*hisfun_k;
      //!!!!!!!!!!!!!!!!!!!pp3->Integral(fmini, fmaxi)*hisfun_k;
      if (value <= 0) value = -1;

      if ((fitStatus != 0) || (ff->GetParameter(2) > 0.1)) {
        printf(" SKIP MC");
        value = -1;
      }
      gry2[count]    = value;
      Double_t superfactor = CalculateFactor(l, 0.1);
      if (useCF) {
        gry22E[i] = TMath::Sqrt(gry2[i])*superfactor;
        //        gry22E[i] = 0.0001;
        gry22[i]  = gry2[i]*superfactor;
        grx22E[i] = 0.05;
      }
      gry_eff[count] = gry[count]/gry2[count];

      c4->cd(count + 1);
      // !!!!!!!!!!!!!!!!
      ff->SetParameters(1, 1.02, 0.004, 0., 0., 0., 0.);
      ht->Fit(ff, "Q", "", fmin, fmax);
      ht->Fit(ff, "Q", "", fmin, fmax);
      fitStatus = ht->Fit(ff, "Q", "", fmin, fmax);
      /*      TF1 *pp3 = new TF1("pp3", "[0]+x*[1]+x*x*[2]+x*x*x*[3]", fmin, fmax);
              pp3->SetParameters(ff->GetParameter(3), ff->GetParameter(4),
              ff->GetParameter(5), ff->GetParameter(6));
              pp3->SetLineWidth(1);
              pp3->SetLineColor(h3_p->GetLineColor());
              pp3->Draw("same");
      */

      value              = ht->Integral(ht->FindBin(fmini), ht->FindBin(fmaxi));
      if (!hisfun) value = ff->Integral(fmini, fmaxi)*hisfun_k;
      //!!!!!!!!!!!!!!!!!!!pp3->Integral(fmini, fmaxi)*hisfun_k;
      if (value <= 0) value = -1;

      if ((fitStatus != 0) || (ff->GetParameter(2) > 0.1)) {
        printf(" SKIP true");
        value = -1;
      }
      gry_true[count]     = value;
      gry_true_eff[count] = gry_true[count]/gry2[count];
      // Propagation of uncertainty (A/B)
      Double_t AAA  = gry_true[count];
      Double_t AAAE = TMath::Sqrt(AAA);
      Double_t BBB  = gry2[count];
      Double_t BBBE = TMath::Sqrt(BBB);
      Double_t EEE  = TMath::Sqrt((AAAE/AAA)*(AAAE/AAA)+(BBBE/BBB)*(BBBE/BBB));
      EEE = EEE*gry_true_eff[count];
      gry_true_effE[count] = EEE;
    }

    Printf("=> %6.4f", ptmean);
    count++;
  }

  new TCanvas();
  TGraph *gr = new TGraph(count, grx, gry);
  gr->SetMarkerStyle(8);
  gr->SetMarkerColor(hh->GetLineColor());
  gr->GetXaxis()->SetTitle("p_{t}, GeV/c");
  gr->SetTitle(Form("raw phi, %s", gtitle.Data()));
  gr->Draw("AP");

  cc3 = new TCanvas();
  TGraph *gr3 = new TGraph(count, grx, gry3);
  gr3->SetMarkerStyle(22);
  gr3->SetMarkerColor(kBlue+1);
  gr3->GetXaxis()->SetTitle("p_{t}, GeV/c");
  gr3->SetTitle(Form("SIG / BKG, %s", gtitle.Data()));
  gr3->SetMinimum(0);
  gr3->Draw("AP");

  cc4 = new TCanvas();
  TGraph *gr4 = new TGraph(count, grx, gry4);
  gr4->SetMarkerStyle(23);
  gr4->SetMarkerColor(kBlue-1);
  gr4->GetXaxis()->SetTitle("p_{t}, GeV/c");
  gr4->SetTitle(Form("Significance, %s", gtitle.Data()));
  gr4->SetMinimum(0);
  gr4->Draw("AP");

  ccc = new TCanvas("ccc","ccc",0,0,900,300);
  ccc->Divide(2, 1, 0.001, 0.001);
  ccc->cd(1); gr3->Draw("AP");
  ccc->cd(2); gr4->Draw("AP");

  TString blabla = "mc";
  if (!mc) blabla = "data";
  // gr3->SaveAs(Form("SB_%s_%s.C", blabla.Data(), grapht.Data()));
  // gr4->SaveAs(Form("Sig_%s_%s.C", blabla.Data(), grapht.Data()));
  // ccc->SaveAs(Form("%s_%s_2.eps", blabla.Data(), grapht.Data()));
  // c->SaveAs(Form("%s_%s_0.eps", blabla.Data(), grapht.Data()));
  // c2->SaveAs(Form("%s_%s_1.eps", blabla.Data(), grapht.Data()));

  //  cc3->SaveAs(Form("%s_%s_2.eps", blabla.Data(), grapht.Data()));
  //  gr3->SaveAs(Form("sig_bck_%s_%s.C", blabla.Data(), grapht.Data()));

  if (mc) {
    new TCanvas();
    TGraph *gr2 = new TGraph(count, grx, gry2);
    gr2->SetMarkerStyle(8);
    gr2->SetMarkerColor(hg->GetLineColor());
    gr2->GetXaxis()->SetTitle("p_{t}, GeV/c");
    gr2->SetTitle(Form("gen phi, %s", gtitle.Data()));
    gr2->Draw("AP");

    new TCanvas();
    TGraphErrors *gr22 = new TGraphErrors(count, grx, gry22, grx22E, gry22E);
    gr22->SetMarkerStyle(8);
    gr22->SetMarkerColor(kCyan);
    gr22->GetXaxis()->SetTitle("p_{t}, GeV/c");
    gr22->SetTitle(Form("gen phi, %s", gtitle.Data()));
    gr22->Draw("AP");


    c = new TCanvas();
    c->SetGrid();
    TGraph *gr_e = new TGraph(count, grx, gry_eff);
    gr_e->SetMarkerStyle(22);
    gr_e->SetMarkerColor(kBlack);
    gr_e->GetXaxis()->SetTitle("p_{t}, GeV/c");
    gr_e->SetTitle(Form("efficiency (raw), %s", grapht.Data()));
    gr_e->Draw("AP");
    Printf("Save as '\033[1meffi_raw_%s\033[0m' file", grapht.Data());
    for (Int_t i = 0; i < gr_e->GetN(); i++)
      Printf("%f %f", gr_e->GetX()[i], gr_e->GetY()[i]);

    cvb = new TCanvas();
    cvb->cd();
    TGraph *gr_true = new TGraph(count, grx, gry_true);
    gr_true->SetMarkerStyle(8);
    gr_true->SetMarkerColor(ht->GetLineColor());
    gr_true->GetXaxis()->SetTitle("p_{t}, GeV/c");
    gr_true->SetTitle(Form("true phi, %s", gtitle.Data()));
    gr_true->Draw("AP");
    c = new TCanvas();
    c->cd();
    c->SetGrid();
    TGraphErrors *gr_true_eff = new TGraphErrors(count, grx, gry_true_eff,
                                                 grxE, gry_true_effE);
    gr_true_eff->SetMarkerStyle(20);
    //    gr_true_eff->SetMarkerSize(0.75);
    gr_true_eff->SetMarkerColor(kBlack);
    gr_true_eff->GetXaxis()->SetTitle("p_{t}, GeV/c");
    gr_true_eff->SetTitle(Form("efficiency (true), %s", grapht.Data()));
    gr_true_eff->Draw("AEP");
    m_gr->Add(gr_true_eff);
    Printf("Save as '\033[1meffi_true_%s\033[0m' file", grapht.Data());
    TString tout;
    Double_t oux, ouy, ouxe, ouye;
    for (Int_t i = 0; i < gr_true_eff->GetN(); i++) {
      oux = gr_true_eff->GetX()[i];
      ouy = gr_true_eff->GetY()[i];
      ouy = MinusCheck(ouy);
      ouxe = gr_true_eff->GetErrorX(i);
      ouye = gr_true_eff->GetErrorY(i);
      ouye = NanCheck(ouye);
      Printf("%f %f %f %f", gr_true_eff->GetX()[i], gr_true_eff->GetY()[i],
             gr_true_eff->GetErrorX(i), gr_true_eff->GetErrorY(i));
      if (!save_output) continue;
      gSystem->mkdir(dir_prefix.Data());
      tout = Form("%f %f %f %f", oux, ouy, ouxe, ouye);
      if (i == 0)
        tout = Form("Printf(\"%s\"); > %s/effi_%s", tout.Data(),
                    dir_prefix.Data(), grapht.Data());
      else
        tout = Form("Printf(\"%s\"); >> %s/effi_%s", tout.Data(),
                    dir_prefix.Data(), grapht.Data());
      //      Printf(":::::: %s", tout.Data());
      gROOT->ProcessLine(tout.Data());
    }
    // ------------------
    c = new TCanvas("cfinal", "mc_effi", 1200, 450);
    c->Divide(2, 1, 0.001, 0.001); c->Modified(); c->Draw();
    c->cd(1);
    gr_true->SetMinimum(0);
    gr_true->SetTitle(Form("phi (true & raw), %s", gtitle.Data()));
    gr_true->SetMarkerColor(kGreen+1);
    gr_true->Draw("AP");
    gr->SetMarkerColor(kRed+1);
    gr->Draw("P");
    c->cd(2)->SetGrid();
    gr_true_eff->SetMinimum(0);
    gr_true_eff->SetTitle(Form("efficiency, %s", grapht.Data()));
    gr_true_eff->SetMarkerColor(kGreen+1);
    gr_true_eff->Draw("AP");
    gr_e->SetMarkerColor(kRed+1);
    gr_e->Draw("P");
    //    c->SaveAs(Form("%s_%s.eps", blabla.Data(), grapht.Data()));
    return;
  }

  //  TGraph *geff = new TGraph(Form("effi_raw_%s", grapht.Data()));
  //  TGraph *geff = new TGraph(Form("effi_true_%s", grapht.Data()));
  //  TGraph *geff = new TGraph("effi_true_Phi2010_qualityonly");
  TGraph *geff = new TGraph("effi_true_PhiNsigma_qualityonly");
  if (geff->IsZombie()) return;
  geff->SetMarkerStyle(22);
  geff->SetMarkerColor(kBlack);
  geff->GetXaxis()->SetTitle("p_{t}, GeV/c");
  geff->SetTitle(Form("efficiency, %s", grapht.Data()));
  c = new TCanvas();
  c->SetGrid();
  geff->Draw("AP");
  Double_t tpcsigma = 9999.9;
  if (ilist == 1) tpcsigma = 1.0;
  if (ilist == 2) tpcsigma = 1.5;
  if (ilist == 3) tpcsigma = 2.0;
  if (ilist == 4) tpcsigma = 2.5;
  if (ilist == 5) tpcsigma = 3.0;
  Double_t sss = TMath::Erf(tpcsigma/TMath::Sqrt(2.0));
  if (noSigma) sss = 1.0;
  Printf("sigma = %10f", sss);

  // for (Int_t i = 0; i < count; i++)
  //   geff->GetY()[i] = (sss*sss)/(geff->GetY()[i]);
  // geff->SetMaximum(1.0);
  // geff->Draw("AP");

  for (Int_t i = 0; i < count; i++) {
    Double_t deno = geff->Eval(grx[i])*sss*sss;
    if (deno < 0.00001) deno = 1;
    gry_fix[i] = gry[i]/deno;
  }
  new TCanvas;
  TGraph *gr_fix = new TGraph(count, grx, gry_fix);
  gr_fix->SetMarkerStyle(21);
  gr_fix->SetMarkerColor(hh->GetLineColor());
  gr_fix->GetXaxis()->SetTitle("p_{t}, GeV/c");
  gr_fix->SetTitle(Form("corrected phi * #sigma^{2}, %s", gtitle.Data()));
  if (noSigma)
    gr_fix->SetTitle(Form("corrected phi (no #sigma), %s", gtitle.Data()));
  gr_fix->Draw("AP");

  //---------------------
  c = new TCanvas("cfinald", "data_correct", 1200, 450);
  c->Divide(2, 1, 0.001, 0.001); c->Modified(); c->Draw();
  c->cd(1);
  gr->SetMinimum(0);
  gr->SetMarkerColor(kBlack);
  gr->Draw("AP");
  c->cd(2);
  gr_fix->SetMinimum(0);
  gr_fix->SetMarkerColor(kGreen+3);
  gr_fix->Draw("AP");
  TString bla9 = Form("qualityonly_PID2_%s", grapht.Data());
  if (noSigma) bla9 = Form("%s_noSig.C", bla9.Data());
  else         bla9 = Form("%s.C", bla9.Data());
  //  gr_fix->SaveAs(bla9.Data());
  //  TPad *cp = new TPad("cpf", "", 0.45,0.45,0.99,0.92);
  TPad *cp = new TPad("cpf", "", 0.60,0.55,0.99,0.93);
  cp->SetLogy(); cp->Draw(); cp->cd();
  TGraph *cloneg = ((TGraph *)gr_fix->Clone());
  cloneg->SetTitle(); cloneg->SetMarkerSize(0.8);
  cloneg->Draw("AP");
  //  c->SaveAs(Form("%s_%s.eps", blabla.Data(), grapht.Data()));
  f->Close();
}
Esempio n. 2
0
checkFieldMap()
{

  // Choose field map
  TString fieldName = "field_v12b";
  TString psFile = "check." + fieldName + ".ps";
  Double_t fzref1 =   0.;        // Origin plane
  Double_t fzref2 = 170.;        // RICH entrance
  Double_t fzref3 = 180.;        // RICH PM
  // ---> Regions of interest for the field
  Double_t fxmin =  -200.;    // along x axis
  Double_t fxmax =   200.;
  Double_t fymin =  -200.;    // along y axis
  Double_t fymax =   200.;
  Double_t fzmin =  -300.;    // along z axis
  Double_t fzmax =   300.;
  // ---> Target location
  Double_t targX = 0.;
  Double_t targY = 0.;
  Double_t targZ = 0.;

    // -------  Get magnetic field  -----------------------------------------
  CbmFieldMap* field = NULL;
  if ( fieldName == "field_v12b" ) 
    field = new CbmFieldMapSym3(fieldName.Data());
  else if ( fieldName == "field_v12a" )
    field = new CbmFieldMapSym2(fieldName.Data());
  else {
    cout << "=====> ERROR: Field map " << fieldName << " unknown!" << endl;
    exit;
  }
  field->Init();
  field->Print();
  Int_t type = field->GetType();
  if ( type >=1 && type <= 3) 
    const char* mapFile = field->GetFileName();
  // ----------------------------------------------------------------------



  // -------  Create graphs and histograms  -------------------------------
  Int_t fnx = TMath::Nint( (fxmax-fxmin) * 3. );
  Int_t fny = TMath::Nint( (fymax-fymin) * 3. );
  Int_t fnz = TMath::Nint( (fzmax-fzmin) * 3. );
  Int_t fmx = TMath::Nint( (fxmax-fxmin) * 3. / 10. );
  Int_t fmy = TMath::Nint( (fymax-fymin) * 3. / 10. );
  TGraph hBy1(fnz+1);
  TGraph hBy2(fnz+1);
  TGraph hBt1(fnz+1);
  TGraph hBt2(fnz+1);
  TH2F hB1("hB1", "B at z_{target}", 
	   fmx, fxmin, fxmax, fmy, fymin, fymax);
  TH2F hB2("hB1", "B at RICH entrance", 
	   fmx, fxmin, fxmax, fmy, fymin, fymax);
  TH2F hB3("hB2", "B at RICH PM",       
	   fmx, fxmin, fxmax, fmy, fymin, fymax);
  // ----------------------------------------------------------------------



  // -------  Get field and fill graphs and histograms  -------------------
  cout << endl;
  cout << "=====>  Filling histograms..." << endl;
  Double_t x, y, z;  Double_t bx, by, bz, bt, b;
  Double_t fdx = (fxmax-fxmin) / Double_t(fnx);
  Double_t fdy = (fymax-fymin) / Double_t(fny);
  Double_t fdz = (fzmax-fzmin) / Double_t(fnz);


  // ---> Loop over z axis (x=y=0)
  cout << "                           ... z axis 1" << endl;
  x = y = 0.;
  for (Int_t iz=0; iz<=fnz; iz++) {
    z = fzmin + Double_t(iz) * fdz;
    bx = field->GetBx(x,y,z) / 10.;
    by = field->GetBy(x,y,z) / 10.;
    bz = field->GetBz(x,y,z) / 10.;
    bt = TMath::Sqrt(bx*bx + bz*bz);
    hBy1.SetPoint(iz, z, by);
    hBt1.SetPoint(iz, z, bt);
  }

  // ---> Loop over z axis (x=y=20)
  cout << "                           ... z axis 2" << endl;
  x = y = 20.;
  for (Int_t iz=0; iz<=fnz; iz++) {
    z = fzmin + Double_t(iz) * fdz;
    bx = field->GetBx(x,y,z) / 10.;
    by = field->GetBy(x,y,z) / 10.;
    bz = field->GetBz(x,y,z) / 10.;
    bt = TMath::Sqrt(bx*bx + bz*bz);
    hBy2.SetPoint(iz, z, by);
    hBt2.SetPoint(iz, z, bt);
  }

  // ---> Double loop over z (target) plane
  cout << "                           ... target plane" << endl;
  fdx = (fxmax-fxmin) / Double_t(fmx);
  fdy = (fymax-fymin) / Double_t(fmy);
  z = fzref1;
  for (Int_t ix=0; ix<fmx; ix++) {
    x = fxmin + (Double_t(ix)+0.5) * fdx;
    for (Int_t iy=0; iy<fmy; iy++) {
      y = fymin + (Double_t(iy)+0.5) * fdy;
      bx = field->GetBx(x,y,z) / 10.;
      by = field->GetBy(x,y,z) / 10.;
      bz = field->GetBz(x,y,z) / 10.;
      b = TMath::Sqrt(bx*bx + by*by + bz*bz);
      hB1.SetBinContent(ix, iy, b);
    }
  }

  // ---> Double loop over z (RICH entrance) plane
  cout << "                           ... RICH entrance plane" << endl;
  fdx = (fxmax-fxmin) / Double_t(fmx);
  fdy = (fymax-fymin) / Double_t(fmy);
  z = fzref2;
  for (Int_t ix=0; ix<fmx; ix++) {
    x = fxmin + (Double_t(ix)+0.5) * fdx;
    for (Int_t iy=0; iy<fmy; iy++) {
      y = fymin + (Double_t(iy)+0.5) * fdy;
      bx = field->GetBx(x,y,z) / 10.;
      by = field->GetBy(x,y,z) / 10.;
      bz = field->GetBz(x,y,z) / 10.;
      b = TMath::Sqrt(bx*bx + by*by + bz*bz);
      hB2.SetBinContent(ix, iy, b);
    }
  }

  // ---> Double loop over z (RICH PM) plane
  cout << "                           ... RICH PM plane" << endl;
  fdx = (fxmax-fxmin) / Double_t(fmx);
  fdy = (fymax-fymin) / Double_t(fmy);
  z = fzref3;
  for (Int_t ix=0; ix<fmx; ix++) {
    x = fxmin + (Double_t(ix)+0.5) * fdx;
    for (Int_t iy=0; iy<fmy; iy++) {
      y = fymin + (Double_t(iy)+0.5) * fdy;
      bx = field->GetBx(x,y,z) / 10.;
      by = field->GetBy(x,y,z) / 10.;
      bz = field->GetBz(x,y,z) / 10.;
      b = TMath::Sqrt(bx*bx + by*by + bz*bz);
      hB3.SetBinContent(ix, iy, b);
    }
  }
  // ----------------------------------------------------------------------



  // --------   Calculate field integral along z axis   -------------------
  Double_t zint1 = -400.;
  Double_t zint2 =  400.;
  Int_t nz = Int_t(zint2-zint1);
  Double_t bint = 0;
  z = zint1 - 1.;
  for (Int_t iz=0; iz<=nz; iz++) {
    z += 1;
    by = field->GetBy(targX, targY, z) / 10.;
    bint += by * 0.01;
  }
  // ----------------------------------------------------------------------



  // -------  Draw graphs and histogram   ---------------------------------
  cout << endl << "=====>  Drawing..." << endl;
  gROOT->SetStyle("Plain");
  gStyle->SetOptStat(0000);
  gStyle->SetPalette(1,0);
  gStyle->SetTitleW(0.5);
  gStyle->SetTitleAlign(13);
  gStyle->SetTitleBorderSize(0.);
  gStyle->SetTitleOffset(2.,"y");
  gStyle->SetOptDate(2);
  gStyle->GetAttDate()->SetTextSize(0.02);

  TPostScript* ps = new TPostScript(psFile, -111);
  ps->Range(20,30);

  TCanvas* c1 = new TCanvas("c1", "canvas", 768, 1152);
  TPad* master = new TPad("master","", 0.10, 0.05, 0.95, 0.95);
  master->Draw();
  master->cd();

  TPad* padinf = new TPad("padinf", "", 0.12, 0.80, 0.88, 0.90);
  TPad* pad1   = new TPad("pad1",   "", 0.05, 0.60, 0.48, 0.78);
  TPad* pad2   = new TPad("pad2",   "", 0.52, 0.60, 0.95, 0.78);
  TPad* pad3   = new TPad("pad3",   "", 0.05, 0.41, 0.48, 0.59);
  TPad* pad4   = new TPad("pad4",   "", 0.52, 0.41, 0.95, 0.59);
  TPad* pad5   = new TPad("pad5",   "", 0.30, 0.22, 0.70, 0.40);
  TPad* pad6   = new TPad("pad6",   "", 0.10, 0.02, 0.47, 0.20);
  TPad* pad7   = new TPad("pad7",   "", 0.53, 0.02, 0.90, 0.20);

  padinf->Draw();
  pad1->Draw();
  pad2->Draw();
  pad3->Draw();
  pad4->Draw();
  pad5->Draw();
  pad6->Draw();
  pad7->Draw();

  Double_t max, min;

  pad1->cd();
  gPad->SetFillColor(10);
  gPad->SetLeftMargin(0.15);
  hBy1.SetLineColor(4);
  hBy1.SetLineWidth(2);
  hBy1.SetTitle("x = y = 0");
  hBy1.GetXaxis()->SetTitle("z [cm]");
  hBy1.GetYaxis()->SetTitle("B_{y} [T]");
  hBy1.Draw("AC");
  max = hBy1.GetHistogram()->GetMaximum();
  min = hBy1.GetHistogram()->GetMinimum();
  TLine l1(targZ, min, targZ, max);
  l1.Draw();

  pad2->cd();
  gPad->SetFillColor(10);
  gPad->SetLeftMargin(0.15);
  hBy2.SetLineColor(4);
  hBy2.SetLineWidth(2);
  hBy2.SetTitle("x = y = 20 cm");
  hBy2.GetXaxis()->SetTitle("z [cm]");
  hBy2.GetYaxis()->SetTitle("B_{y} [T]");
  hBy2.Draw("AC");
  max = hBy2.GetHistogram()->GetMaximum();
  min = hBy2.GetHistogram()->GetMinimum();
  TLine l2(targZ, min, targZ, max);
  l2.Draw();

  pad3->cd();
  gPad->SetFillColor(10);
  gPad->SetLeftMargin(0.15);
  hBt1.SetLineColor(2);
  hBt1.SetLineWidth(2);
  hBt1.SetTitle("x = y = 0");
  hBt1.GetXaxis()->SetTitle("z [cm]");
  hBt1.GetYaxis()->SetTitle("B_{xz} [T]");
  hBt1.Draw("AC");
  max = hBt1.GetHistogram()->GetMaximum();
  min = hBt1.GetHistogram()->GetMinimum();
  TLine l3(targZ, min, targZ, max);
  l3.Draw();

  pad4->cd();
  gPad->SetFillColor(10);
  gPad->SetLeftMargin(0.15);
  hBt2.SetLineColor(2);
  hBt2.SetLineWidth(2);
  hBt2.SetTitle("x = y = 20 cm");
  hBt2.GetXaxis()->SetTitle("z [cm]");
  hBt2.GetYaxis()->SetTitle("B_{xz} [T]");
  hBt2.Draw("AC");
  max = hBt2.GetHistogram()->GetMaximum();
  min = hBt2.GetHistogram()->GetMinimum();
  TLine l4(targZ, min, targZ, max);
  l4.Draw();

  pad5->cd();
  gPad->SetLeftMargin(0.15);
  gPad->SetFillColor(10);
  hB1.UseCurrentStyle();
  hB1.GetXaxis()->SetTitle("x [cm]");
  hB1.GetYaxis()->SetTitle("y [cm]");
  char t[100];
  sprintf(t,"B [T] at z= 0",fzref1);
  hB1.SetTitle(t);
  hB1.Draw("COLZ");

  pad6->cd();
  gPad->SetFillColor(10);
  gPad->SetLeftMargin(0.15);
  hB2.UseCurrentStyle();
  hB2.GetXaxis()->SetTitle("x [cm]");
  hB2.GetYaxis()->SetTitle("y [cm]");
  char t[100];
  sprintf(t,"B [T] at RICH entrance (z=%8.2f cm)",fzref2);
  hB2->SetTitle(t);
  hB2.Draw("COLZ");

  pad7->cd();
  gPad->SetFillColor(10);
  gPad->SetLeftMargin(0.15);
  hB3.UseCurrentStyle();
  hB3.GetXaxis()->SetTitle("x [cm]");
  hB3.GetYaxis()->SetTitle("y [cm]");
  sprintf(t,"B [T] at RICH PM plane (z=%8.2f cm)",fzref3);
  hB3.SetTitle(t);
  hB3.Draw("COLZ");


  TString fieldType = "";
  if      ( type == 0 ) fieldType = "Constant field";
  else if ( type == 1 ) fieldType = "Field map";
  else if ( type == 2 ) fieldType = "Field Map Sym2";
  else if ( type == 3 ) fieldType = "Field Map Sym3";


  char t1[300];
  padinf->cd();
  TPaveText info(0.1,0.1,0.9,0.9);
  info.SetFillColor(10);
  info.SetBorderSize(0);
  info.SetTextAlign(2);
  sprintf(t1,"Field name: %s, type: %s",field->GetName(),fieldType.Data());
  info.AddText(0.05, 0.9, t1);
  Double_t bx = field->GetBx(0.,0.,0.) / 10.;
  Double_t by = field->GetBy(0.,0.,0.) / 10.;
  Double_t bz = field->GetBz(0.,0.,0.) / 10.;
  sprintf(t1,"Field at origin is (%7.4f, %7.4f, %7.4f) T",bx,by,bz);
  cout << t1 << endl;
  info.AddText(0.05, 0.7, t1);
  if ( type >= 1 && type <=3 ) {
    sprintf(t1, "Map file: %s",mapFile);
    cout << t1 << endl;
    info.AddText(0.05, 0.5, t1);
    Double_t xp = field->GetPositionX();
    Double_t yp = field->GetPositionY();
    Double_t zp = field->GetPositionZ();
    sprintf(t1,"Centre position (%.2f, %.2f, %.2f) cm",xp,yp,zp);
    info->AddText(0.05, 0.3, t1);
    Double_t scale = field->GetScale();
    sprintf(t1,"Scaling factor %.2f, Field integral along z = %.4f Tm",
	    scale,bint);
    info->AddText(0.05, 0.1, t1);
  }
  info.Draw();

  master->cd();
  sprintf(t1,"Field check for %s", field->GetName());
  TPaveLabel label(0.20, 0.92, 0.88, 0.97, t1);
  label->Draw();
  
  /*
  c1->cd();
  const char* wrkdir = getenv("VMCWORKDIR");
  TString logo = TString(wrkdir) + "/input/cbmlogo.gif";
  TImage* cbm = TImage::Open(logo);
  TPad* padimg = new TPad("padimg", "", 0.05, 0.80, 0.20, 0.95);
  padimg->Draw();
  padimg->cd();
  cbm->Draw();
  */
  


  ps->Close();
  
}
Esempio n. 3
0
// infilename - root file with relevant histograms
// system - PP,APAP,PP
// status - Pass,Fail
// rWrite - 0-no,1-png,2-eps
// rPerformance - 0-no,1-yes (ALICE logo etc.)
// bin: 0 - all, 1- 0:5, 2- 5:10, etc
void drawDCA(const char* infilename, const char* system, const char* status, Int_t rWrite, Int_t rPerformance, int isMC, Int_t bin, Int_t ptrange)
{

    myOptions(0);

    gROOT->ForceStyle();
    gStyle->SetPalette(1.0);

    TDatime now;
    int iDate = now.GetDate();
    int iYear=iDate/10000;
    int iMonth=(iDate%10000)/100;
    int iDay=iDate%100;
    char* cMonth[12]={"Jan","Feb","Mar","Apr","May","Jun",
                      "Jul","Aug","Sep","Oct","Nov","Dec"};
    char cStamp1[25],cStamp2[25];
    sprintf(cStamp1,"%i %s %i",iDay, cMonth[iMonth-1], iYear);
    sprintf(cStamp2,"%i/%.2d/%i",iDay, iMonth, iYear);

    TFile *f = new TFile(infilename, "read");

    // DCA xy
    TH2D* DCAxy =(TH2D*)f->Get(Form("DCARPtcut%s1%stpcM%d","Pass", system,0));


    if (!bin) {
        int minMultBin = 0;
        int maxMultBin = 6; // 8
    }
    else {
        int minMultBin = bin-1;
        int maxMultBin = bin; // 8
    }

    // int minMultBin = 0;
    // int maxMultBin = 0; // 8

    double EvMultall = 0;

    for(int i = minMultBin; i<maxMultBin; i++) {

        TH2D* DCAxyN = (TH2D*)f->Get(Form("DCARPtcut%s1%stpcM%d",status, system,i));
        DCAxy->Add(DCAxyN);

        cout<<i<<" "<<DCAxyN->GetEntries()<<endl;

        //delete hEvMult;
    }


    if (!isMC) {
        TCanvas *c2 = new TCanvas("DCA xy prim", "DCA xy prim");
        c2->SetGridx();
        c2->SetGridy();
        c2->SetFillColor(10);
        c2->SetRightMargin(1.9);
        c2->SetLogz();

        DCAxy->GetXaxis()->SetTitle("DCA_{XY} (cm)");
        DCAxy->GetXaxis()->SetRangeUser(-5.0,5.0);
        DCAxy->GetYaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})");
        // DCAxy->GetZaxis()->SetLabelSize(0.05);
        DCAxy->Draw("colz");
        postprocess(c2,Form("DCAxy%s",status),rWrite,rPerformance,system);

        // TCanvas *c4 = new TCanvas("DCA xy Projection X", "DCA xy Projection X");
        // c4->SetGridx();
        // c4->SetGridy();
        // c4->SetFillColor(10);
        // c4->SetRightMargin(1.9);
        // c4->SetLogy();

        gStyle->SetOptTitle(1);
        TCanvas *myCan = new TCanvas("myCan",cStamp1,600,400);
        myCan->Draw();
        myCan->cd();

        TPad *myPad = new TPad("myPad", "The pad",0,0,1,1);
        myPadSetUp(myPad,0.15,0.04,0.04,0.15);
        myPad->Draw();
        myPad->SetLogy();

        myPad->cd();

        if (ptrange == 0) {
            TH1D* pripp = (TH1D*)DCAxy->ProjectionX("zxc1",1,100);
            pripp->SetTitle("0.5 < #it{p}_{T} < 3 GeV/#it{c}");
        }
        else if (ptrange == 1) {
            TH1D* pripp = (TH1D*)DCAxy->ProjectionX("zxc1",15,33);
            pripp->SetTitle("0.5 < #it{p}_{T} < 1 GeV/#it{c}");
        }
        else if (ptrange == 2) {
            TH1D* pripp = (TH1D*)DCAxy->ProjectionX("zxc1",33,100);
            pripp->SetTitle("1 < #it{p}_{T} < 3 GeV/#it{c}");
        }

        pripp->SetYTitle("Number of Entries (normalized)");
        pripp->GetXaxis()->SetTitleSize(0.068);
        pripp->GetYaxis()->SetTitleSize(0.068);
        pripp->GetXaxis()->SetLabelSize(0.058);
        pripp->GetYaxis()->SetLabelSize(0.058);

        // pripp->SetLabelSize(0.05);
        // DCAxy->ProjectionX("asd",50,100)->SetYTitle("Number of Entries");
        // DCAxy->ProjectionX("asd",50,100)->SetTitle("1.0 < p_{T} < 2.0 GeV");
        // DCAxy->ProjectionX("asd",0,200)->SetTitle("");
        // DCAxy->ProjectionX("asd",50,100)->GetXaxis()->SetNdivisions(8);
        // DCAxy->ProjectionX("asd",50,100)->GetYaxis()->SetNdivisions(8);
        // DCAxy->ProjectionX("asd",50,100)->GetXaxis()->SetTitleSize(0.05);
        // DCAxy->ProjectionX("asd",50,100)->GetYaxis()->SetTitleSize(0.05);
        // DCAxy->ProjectionX("asd",50,100)->GetXaxis()->SetLabelSize(0.05);
        // DCAxy->ProjectionX("asd",50,100)->GetYaxis()->SetLabelSize(0.05);

        pripp->Draw("");

        //if (!isMC) {
        pripp->Scale(1./pripp->Integral());
        TFile* fout = new TFile("dca.root","update");
        pripp->SetName(Form("dcaxyMC%d",isMC));
        pripp->Write();
        //}

        postprocess(myCan,Form("DCAxy%sProX",status),rWrite,rPerformance,system);

    }
    else if (isMC) {

        TH2D* primp =(TH2D*)f->Get(Form("DCARPtcut%s1%stpcM%dprim","Pass", system,0));
        TH2D* weakp =(TH2D*)f->Get(Form("DCARPtcut%s1%stpcM%dweak","Pass", system,0));
        TH2D* matp =(TH2D*)f->Get(Form("DCARPtcut%s1%stpcM%dmat","Pass", system,0));

        // prim 2D
        TCanvas *c3prim = new TCanvas("DCA xy primary", "DCA xy primary");
        c3prim->SetGridx();
        c3prim->SetGridy();
        c3prim->SetFillColor(10);
        c3prim->SetRightMargin(1.9);
        c3prim->SetLogz();

        primp->GetXaxis()->SetTitle("DCA_{XY} (cm)");
        primp->GetXaxis()->SetRangeUser(-5.0,5.0);
        primp->GetYaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})");
        primp->GetZaxis()->SetLabelSize(0.03);
        primp->Draw("colz");
        postprocess(c3prim,Form("DCAxy%s",status),rWrite,rPerformance,system);

        // weak 2D
        TCanvas *c3 = new TCanvas("DCA xy weak", "DCA xy weak");
        c3->SetGridx();
        c3->SetGridy();
        c3->SetFillColor(10);
        c3->SetRightMargin(1.9);
        c3->SetLogz();

        weakp->GetXaxis()->SetTitle("DCA_{XY} (cm)");
        weakp->GetXaxis()->SetRangeUser(-5.0,5.0);
        weakp->GetYaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})");
        weakp->GetZaxis()->SetLabelSize(0.03);
        weakp->Draw("colz");
        postprocess(c3,Form("DCAxy%s",status),rWrite,rPerformance,system);

        // mat 2D
        TCanvas *c4 = new TCanvas("DCA xy mat", "DCA xy mat");
        c4->SetGridx();
        c4->SetGridy();
        c4->SetFillColor(10);
        c4->SetRightMargin(1.9);
        c4->SetLogz();

        matp->GetXaxis()->SetTitle("DCA_{XY} (cm)");
        matp->GetXaxis()->SetRangeUser(-5.0,5.0);
        matp->GetYaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})");
        matp->GetZaxis()->SetLabelSize(0.03);
        matp->Draw("colz");
        postprocess(c4,Form("DCAxy%s",status),rWrite,rPerformance,system);


        // prim proj
        gStyle->SetOptTitle(1);

        TCanvas *myCan3prim = new TCanvas("myCan3prim",cStamp1);
        myCan3prim->Draw();
        myCan3prim->cd();

        TPad *myPad3prim = new TPad("myPad3prim", "The pad3prim",0,0,1,1);
        myPadSetUp(myPad3prim,0.15,0.04,0.04,0.15);
        myPad3prim->Draw();
        myPad3prim->SetLogy();

        myPad3prim->cd();

        TH1D* primpp = (TH1D*)primp->ProjectionX("zxc22",0,100);
        primpp->Draw("");

        cout << primpp->FindBin(-0.1) << endl;
        cout << primpp->FindBin(0.1) << endl;

        cout << "primary in cut- " << primpp->Integral(191,211) << endl;
        cout << "primary all- " << primpp->Integral(1,400) << endl;

        postprocess(myCan3prim,Form("DCAxy%sProX",status),rWrite,rPerformance,system);


        // weak proj
        TCanvas *myCan3 = new TCanvas("myCan3",cStamp1);
        myCan3->Draw();
        myCan3->cd();

        TPad *myPad3 = new TPad("myPad3", "The pad3",0,0,1,1);
        myPadSetUp(myPad3,0.15,0.04,0.04,0.15);
        myPad3->Draw();
        myPad3->SetLogy();

        myPad3->cd();

        TH1D* weakpp = (TH1D*)weakp->ProjectionX("zxc2",0,100);
        weakpp->Draw("");

        cout << "weak in cut- " << weakpp->Integral(191,211) << endl;
        cout << "weak all- " << weakpp->Integral(1,400) << endl;

        postprocess(myCan3,Form("DCAxy%sProX",status),rWrite,rPerformance,system);

        // mat proj
        gStyle->SetOptTitle(1);
        TCanvas *myCan4 = new TCanvas("myCan4",cStamp1);
        myCan4->Draw();
        myCan4->cd();

        TPad *myPad4 = new TPad("myPad4", "The pad4",0,0,1,1);
        myPadSetUp(myPad4,0.15,0.04,0.04,0.15);
        myPad4->Draw();
        myPad4->SetLogy();

        myPad4->cd();

        TH1D* matpp = (TH1D*)matp->ProjectionX("zxc3",0,100);
        matpp->Draw("");

        cout << "material in cut- " << matpp->Integral(191,211) << endl;
        cout << "material all- " << matpp->Integral(1,400) << endl;

        postprocess(myCan4,Form("DCAxy%sProX",status),rWrite,rPerformance,system);

        cout  << "in cut: " << endl;
        cout << "prim - " << primpp->Integral(191,211) / (primpp->Integral(191,211)+weakpp->Integral(191,211)+matpp->Integral(191,211)) << endl;
        cout << "weak - " << weakpp->Integral(191,211) / (primpp->Integral(191,211)+weakpp->Integral(191,211)+matpp->Integral(191,211)) << endl;
        cout << "mat - " << matpp->Integral(191,211) / (primpp->Integral(191,211)+weakpp->Integral(191,211)+matpp->Integral(191,211)) << endl;

        cout << endl << "in cut / all " << endl;
        cout << "prim - " << primpp->Integral(191,211) / primpp->Integral(1,400) << endl;
        cout << "weak - " << weakpp->Integral(191,211) / weakpp->Integral(1,400) << endl;
        cout << "mat - " << matpp->Integral(191,211) / matpp->Integral(1,400) << endl;


        // _____sum____

        TH2D* psum = new TH2D("psum","",400, -2.0, 2.0, 100,0.0,2.0);
        psum->GetXaxis()->SetTitle("DCA_{xy} (cm)");
        psum->GetYaxis()->SetTitle("Number of Entries (normalized)");
        psum->GetXaxis()->SetLimits(-2,2);


        for (int i = 0; i < primp->GetNbinsX(); i++) {
            for (int j = 0; j < primp->GetNbinsY(); j++) {
                psum->SetBinContent(i,j,primp->GetBinContent(i,j)+weakp->GetBinContent(i,j)+matp->GetBinContent(i,j));
            }
        }

        gStyle->SetOptStat(0);

        TCanvas *cansum = new TCanvas("cansum",cStamp1,600,400);
        cansum->Draw();
        cansum->cd();

        TPad *padsum = new TPad("padsum", "The pad4",0,0,1,1);
        myPadSetUp(padsum,0.15,0.04,0.04,0.15);
        padsum->Draw();
        padsum->SetLogy();

        padsum->cd();

        // TCanvas* cansum = new TCanvas("cansum","cansum");
        // cansum->SetLogy();
        //psum->Draw("colz");
        TH1D* asd0 = (TH1D*)psum->ProjectionX("zxc",0,100);

        // asd0->Scale(1./asd0->Integral());
        // TFile* fout = new TFile("dca.root","update");
        // asd0->SetName(Form("dcaxyMC%d",isMC));
        // asd0->Write();

        asd0->GetXaxis()->SetTitle("DCA_{xy} (cm)");
        asd0->GetYaxis()->SetTitle("Number of Entries (normalized)");
        //asd0->SetMaximum(5000);
        //asd0->SetMinimum(0.00008);
        asd0->GetXaxis()->SetNdivisions(8);
        asd0->GetYaxis()->SetNdivisions(8);
        //asd0->GetYaxis()->SetTitleOffset(1.4);
        asd0->GetXaxis()->SetTitleSize(0.068);
        asd0->GetYaxis()->SetTitleSize(0.068);
        asd0->GetXaxis()->SetLabelSize(0.058);
        asd0->GetYaxis()->SetLabelSize(0.058);
        asd0->SetFillColor(kBlack);

        Double_t norm = asd0->Integral();
        //asd0->Scale(1./norm);
        //asd0->SetMinimum(0.00007);

        asd0->SetMarkerSize(1.3);
        asd0->SetMarkerColor(kBlack);
        asd0->SetMarkerStyle(20);
        asd0->Draw("pc");

        primpp->SetFillColor(kGreen+2);
        //primpp->Scale(1./norm);
        primpp->SetMarkerSize(1.3);
        primpp->SetMarkerColor(kGreen+2);
        primpp->SetMarkerStyle(20);
        primpp->Draw("psame");

        matpp->SetFillColor(kRed);
        //matpp->Scale(1./norm);
        matpp->SetMarkerSize(1.3);
        matpp->SetMarkerColor(kRed);
        matpp->SetMarkerStyle(20);
        matpp->Draw("psame");

        weakpp->SetFillColor(kBlue);
        //weakpp->Scale(1./norm);
        weakpp->SetMarkerSize(1.3);
        weakpp->SetMarkerColor(kBlue);
        weakpp->SetMarkerStyle(20);
        weakpp->Draw("psame");



        // _____endofsum____


        TLegend *myLegend = new TLegend(0.6,0.6,0.89,0.89);
        myLegend->SetFillColor(10);
        myLegend->SetBorderSize(0);

        myLegend->AddEntry(asd0,"all","f");
        myLegend->AddEntry(primpp,"primary","f");
        myLegend->AddEntry(weakpp,"weak decay","f");
        myLegend->AddEntry(matpp,"material","f");
        //myLegend->Draw("same");


        // logo

        TLatex *sys = new TLatex(0.16,0.91,"AMPT Pb-Pb #sqrt{s_{NN}} = 2.76 TeV");
        sys->SetNDC();
        sys->SetTextFont(42);
        sys->SetTextSize(0.05);
        sys->SetTextColor(kRed+2);
        sys->Draw();

        TDatime now;
        int iDate = now.GetDate();
        int iYear=iDate/10000;
        int iMonth=(iDate%10000)/100;
        int iDay=iDate%100;
        char* cMonth[12]={"Jan","Feb","Mar","Apr","May","Jun",
                          "Jul","Aug","Sep","Oct","Nov","Dec"};
        char cStamp1[25],cStamp2[25];
        sprintf(cStamp1,"%i %s %i",iDay, cMonth[iMonth-1], iYear);
        sprintf(cStamp2,"%i/%.2d/%i",iDay, iMonth, iYear);


        TText *date = new TText(0.27,0.5,cStamp2);
        date->SetNDC();
        date->SetTextFont(42);
        date->SetTextSize(0.04);
        date->Draw();

        //           //Acquire canvas proportions
//                 Double_t AliLogo_LowX = 0.27;
//                 Double_t AliLogo_LowY = 0.6;
//                 Double_t AliLogo_Height = 0.22;
//                 //ALICE logo is a png file that is 821x798 pixels->should be wider than a square
//                 Double_t AliLogo_Width  = (821./798.) * AliLogo_Height * gPad->GetWh() / gPad->GetWw();

//                 TPad *myPadLogo = new TPad("myPadLogo", "Pad for ALICE Logo",AliLogo_LowX,AliLogo_LowY,AliLogo_LowX+AliLogo_Width,AliLogo_LowY+AliLogo_Height);
//                 //    myPadLogo->SetFillColor(2); // color to first figure out where is the pad then comment !
//                 myPadSetUp(myPadLogo,0,0,0,0);
//                 myPadLogo->SetFixedAspectRatio(1);
//                 myPadLogo->Draw();
//                 myPadLogo->cd();

// //                TASImage *myAliceLogo = new TASImage("alice_preliminary.eps");
//                 TASImage *myAliceLogo = new TASImage("alice_performance.eps");
// //		TASImage *myAliceLogo = new TASImage("alice_logo_transparent.png");
//                 myAliceLogo->Draw();

        DrawALICELogo(0,0.27,0.55,0.7,0.8);

//logo

        // postprocess(cansum,Form("DCAxyMC%s",status),rWrite,rPerformance,system);
        cansum->SaveAs("DCAxyMC.png");
        cansum->SaveAs("DCAxyMC.eps");
    }

//__________________________________________________


}
Esempio n. 4
0
TF1* fit(Double_t ptmin, Double_t ptmax)
{
  TCanvas* c = new TCanvas(Form("c_%.0f_%.0f",ptmin,ptmax),"",600,600);
  TFile* infile = new TFile(Form("%s_%s_%.0f_%.0f.root",infname.Data(),collisionsystem.Data(),ptmin,ptmax));
  TH1D* h = (TH1D*)infile->Get("h");                    h->SetName(Form("h_%.0f_%.0f",ptmin,ptmax));
  TH1D* hMCSignal = (TH1D*)infile->Get("hMCSignal");    hMCSignal->SetName(Form("hMCSignal_%.0f_%.0f",ptmin,ptmax));
  TH1D* hMCSwapped = (TH1D*)infile->Get("hMCSwapped");  hMCSwapped->SetName(Form("hMCSwapped_%.0f_%.0f",ptmin,ptmax));
  TF1* f = new TF1(Form("f_%.0f_%.0f",ptmin,ptmax),"[0]*([7]*([9]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2])+(1-[9])*Gaus(x,[1],[10])/(sqrt(2*3.14159)*[10]))+(1-[7])*Gaus(x,[1],[8])/(sqrt(2*3.14159)*[8]))+[3]*exp([4]*x)", 1.7, 2.0);

  f->SetParLimits(10,0.001,0.05);
  f->SetParLimits(2,0.01,0.1);
  f->SetParLimits(8,0.02,0.2);
  f->SetParLimits(7,0,1);
  f->SetParLimits(9,0,1);
  
  f->SetParameter(0,setparam0);
  f->SetParameter(1,setparam1);
  f->SetParameter(2,setparam2);
  f->SetParameter(10,setparam10);
  f->SetParameter(9,setparam9);

  f->FixParameter(8,setparam8);
  f->FixParameter(7,1);
  f->FixParameter(1,fixparam1);
  f->FixParameter(3,0);
  f->FixParameter(4,0);
  h->GetEntries();
  
  hMCSignal->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"q","",minhisto,maxhisto);
  hMCSignal->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"q","",minhisto,maxhisto);
  f->ReleaseParameter(1);
  hMCSignal->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto);
  hMCSignal->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto);
  hMCSignal->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L m","",minhisto,maxhisto);
  
  f->FixParameter(1,f->GetParameter(1));
  f->FixParameter(2,f->GetParameter(2));
  f->FixParameter(10,f->GetParameter(10));
  f->FixParameter(9,f->GetParameter(9));
  f->FixParameter(7,0);
  f->ReleaseParameter(8);
  f->SetParameter(8,setparam8);
  
  hMCSwapped->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto);
  hMCSwapped->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto);
  hMCSwapped->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto);
  hMCSwapped->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L m","",minhisto,maxhisto);
  
  f->SetParLimits(0,0,1.e+6);
  f->FixParameter(7,hMCSignal->Integral(0,1000)/(hMCSwapped->Integral(0,1000)+hMCSignal->Integral(0,1000)));
  f->FixParameter(8,f->GetParameter(8));
  f->ReleaseParameter(3);
  f->ReleaseParameter(4);
  f->SetParLimits(3,0,1.e+10);
  f->SetParameter(3,1.e+3);

  f->SetLineColor(kRed);
  
  h->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"q","",minhisto,maxhisto);
  h->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"q","",minhisto,maxhisto);
  f->ReleaseParameter(1);
  f->SetParLimits(1,1.85,1.90);
  //f->ReleaseParameter(2);                                     // you need to release these two parameters if you want to perform studies on the sigma shape
  //f->ReleaseParameter(10);                                   // you need to release these two parameters if you want to perform studies on the sigma shape
  h->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto);
  h->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto);
  h->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto);
  h->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L m","",minhisto,maxhisto);
  
  TF1* background = new TF1(Form("background_%.0f_%.0f",ptmin,ptmax),"[0]*exp([1]*x)");
  background->SetParameter(0,f->GetParameter(3));
  background->SetParameter(1,f->GetParameter(4));
  background->SetLineColor(4);
  background->SetRange(minhisto,maxhisto);
  background->SetLineStyle(2);
  
  TF1* mass = new TF1(Form("fmass_%.0f_%.0f",ptmin,ptmax),"[0]*([3]*([4]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2])+(1-[4])*Gaus(x,[1],[5])/(sqrt(2*3.14159)*[5])))");
  mass->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(2),f->GetParameter(7),f->GetParameter(9),f->GetParameter(10));
  mass->SetParError(0,f->GetParError(0));
  mass->SetParError(1,f->GetParError(1));
  mass->SetParError(2,f->GetParError(2));
  mass->SetParError(3,f->GetParError(7));
  mass->SetParError(4,f->GetParError(9));
  mass->SetParError(5,f->GetParError(10));
  mass->SetFillColor(kOrange-3);
  mass->SetFillStyle(3002);
  mass->SetLineColor(kOrange-3);
  mass->SetLineWidth(3);
  mass->SetLineStyle(2);
  
  TF1* massSwap = new TF1(Form("fmassSwap_%.0f_%.0f",ptmin,ptmax),"[0]*(1-[2])*Gaus(x,[1],[3])/(sqrt(2*3.14159)*[3])");
  massSwap->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(7),f->GetParameter(8));
  massSwap->SetParError(0,f->GetParError(0));
  massSwap->SetParError(1,f->GetParError(1));
  massSwap->SetParError(2,f->GetParError(7));
  massSwap->SetParError(3,f->GetParError(8));
  massSwap->SetFillColor(kGreen+4);
  massSwap->SetFillStyle(3005);
  massSwap->SetLineColor(kGreen+4);
  massSwap->SetLineWidth(3);
  massSwap->SetLineStyle(1);
  
  h->SetXTitle("m_{#piK} (GeV/c^{2})");
  h->SetYTitle("Entries / (5 MeV/c^{2})");
  h->GetXaxis()->CenterTitle();
  h->GetYaxis()->CenterTitle();
  h->SetAxisRange(0,h->GetMaximum()*1.4*1.2,"Y");
  h->GetXaxis()->SetTitleOffset(1.3);
  h->GetYaxis()->SetTitleOffset(1.8);
  h->GetXaxis()->SetLabelOffset(0.007);
  h->GetYaxis()->SetLabelOffset(0.007);
  h->GetXaxis()->SetTitleSize(0.045);
  h->GetYaxis()->SetTitleSize(0.045);
  h->GetXaxis()->SetTitleFont(42);
  h->GetYaxis()->SetTitleFont(42);
  h->GetXaxis()->SetLabelFont(42);
  h->GetYaxis()->SetLabelFont(42);
  h->GetXaxis()->SetLabelSize(0.04);
  h->GetYaxis()->SetLabelSize(0.04);
  h->SetMarkerSize(0.8);
  h->SetMarkerStyle(20);
  h->SetStats(0);
  h->Draw("e");

  background->Draw("same");   
  mass->SetRange(minhisto,maxhisto);	
  mass->Draw("same");
  massSwap->SetRange(minhisto,maxhisto);
  massSwap->Draw("same");
  f->Draw("same");
  
  Double_t yield = mass->Integral(minhisto,maxhisto)/binwidthmass;
  Double_t yieldErr = mass->Integral(minhisto,maxhisto)/binwidthmass*mass->GetParError(0)/mass->GetParameter(0);
  
  std::cout<<"YIELD="<<yield<<std::endl;

  TLegend* leg = new TLegend(0.65,0.58,0.82,0.88,NULL,"brNDC");
  leg->SetBorderSize(0);
  leg->SetTextSize(0.04);
  leg->SetTextFont(42);
  leg->SetFillStyle(0);
  leg->AddEntry(h,"Data","pl");
  leg->AddEntry(f,"Fit","l");
  leg->AddEntry(mass,"D^{0}+#bar{D^{#lower[0.2]{0}}} Signal","f");
  leg->AddEntry(massSwap,"K-#pi swapped","f");
  leg->AddEntry(background,"Combinatorial","l");
  leg->Draw("same");

  TLatex* texCms = new TLatex(0.18,0.93, "#scale[1.25]{CMS} Preliminary");
  texCms->SetNDC();
  texCms->SetTextAlign(12);
  texCms->SetTextSize(0.04);
  texCms->SetTextFont(42);
  texCms->Draw();

  TLatex* texCol = new TLatex(0.96,0.93, Form("%s #sqrt{s_{NN}} = 5.02 TeV",collisionsystem.Data()));
  texCol->SetNDC();
  texCol->SetTextAlign(32);
  texCol->SetTextSize(0.04);
  texCol->SetTextFont(42);
  texCol->Draw();

  TLatex* texPt = new TLatex(0.22,0.78,Form("%.1f < p_{T} < %.1f GeV/c",ptmin,ptmax));
  texPt->SetNDC();
  texPt->SetTextFont(42);
  texPt->SetTextSize(0.04);
  texPt->SetLineWidth(2);
  texPt->Draw();

  TLatex* texY = new TLatex(0.22,0.83,"|y| < 1.0");
  texY->SetNDC();
  texY->SetTextFont(42);
  texY->SetTextSize(0.04);
  texY->SetLineWidth(2);
  texY->Draw();

  TLatex* texYield = new TLatex(0.22,0.73,Form("N_{D} = %.0f #pm %.0f",yield,yieldErr));
  texYield->SetNDC();
  texYield->SetTextFont(42);
  texYield->SetTextSize(0.04);
  texYield->SetLineWidth(2);
  texYield->Draw();

  c->SaveAs(Form("plotFits/DMass_expo_%s_%.0f_%.0f.pdf",collisionsystem.Data(),ptmin,ptmax));
  
  TCanvas* cPull = new TCanvas(Form("cPull_%.0f_%.0f",ptmin,ptmax),"",600,700);
  TH1D* hPull = (TH1D*)h->Clone("hPull");
  for(int i=0;i<h->GetNbinsX();i++)
    {
      Double_t nfit = f->Integral(h->GetBinLowEdge(i+1),h->GetBinLowEdge(i+1)+h->GetBinWidth(i+1))/h->GetBinWidth(i+1);
      if(h->GetBinError(i+1)==0)
        {
          hPull->SetBinContent(i+1,0.);
        }
      else hPull->SetBinContent(i+1,(h->GetBinContent(i+1)-nfit)/h->GetBinError(i+1));
      hPull->SetBinError(i+1,0);
    }
  hPull->SetMinimum(-4.);
  hPull->SetMaximum(4.);
  hPull->SetYTitle("Pull");
  hPull->GetXaxis()->SetTitleOffset(1.);
  hPull->GetYaxis()->SetTitleOffset(0.65);
  hPull->GetXaxis()->SetLabelOffset(0.007);
  hPull->GetYaxis()->SetLabelOffset(0.007);
  hPull->GetXaxis()->SetTitleSize(0.12);
  hPull->GetYaxis()->SetTitleSize(0.12);
  hPull->GetXaxis()->SetLabelSize(0.1);
  hPull->GetYaxis()->SetLabelSize(0.1);
  hPull->GetYaxis()->SetNdivisions(504);
  TLine* lPull = new TLine(1.7, 0, 2., 0);
  lPull->SetLineWidth(1);
  lPull->SetLineStyle(7);
  lPull->SetLineColor(1);
  TPad* pFit = new TPad("pFit","",0,0.3,1,1);
  pFit->SetBottomMargin(0);
  pFit->Draw();
  pFit->cd();
  h->Draw("e");
  background->Draw("same");
  mass->Draw("same");
  massSwap->Draw("same");
  f->Draw("same");
  leg->Draw("same");
  texCms->Draw();
  texCol->Draw();
  texPt->Draw();
  texY->Draw();
  texYield->Draw();
  cPull->cd();
  TPad* pPull = new TPad("pPull","",0,0,1,0.3);
  pPull->SetTopMargin(0);
  pPull->SetBottomMargin(0.3);
  pPull->Draw();
  pPull->cd();
  hPull->Draw("p");
  lPull->Draw();
  cPull->cd();
  cPull->SaveAs(Form("plotFits/DMass_expo_%s_%.0f_%.0f_Pull.pdf",collisionsystem.Data(),ptmin,ptmax));

  return mass;
}
Esempio n. 5
0
void eta1(double pt1min, double pt2min, double METmin){


  TLegend* leg = new TLegend(0.13,0.6,0.87,0.87);
  leg->SetNColumns(3);
  leg->SetBorderSize(0);
  leg->SetFillStyle(0);
  gStyle->SetPadTickY(1);
  gStyle->SetPadTickX(1);

  TFile *data =  TFile::Open("./25ns_2246inv_v3/DoubleEG.root","READ");
  TFile *sig1 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP600.root","READ");
  TFile *sig2 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP800.root","READ");
  TFile *sig3 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1000.root","READ");
  TFile *sig4 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1200.root","READ");
  TFile *sig5 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1400.root","READ");
  TFile *sig6 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1700.root","READ");
  TFile *sig7 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP2500.root","READ");


  TFile *bkg1 =  TFile::Open("./25ns_2246inv_v3/DiPhoton.root","READ"); 
  TFile *bkg2 =  TFile::Open("./25ns_2246inv_v3/DYJetsToLL.root","READ");
  TFile *bkg3 =  TFile::Open("./25ns_2246inv_v3/GJets.root","READ");  
  TFile *bkg4 =  TFile::Open("./25ns_2246inv_v3/GluGluHToGG.root","READ");
  TFile *bkg5 =  TFile::Open("./25ns_2246inv_v3/QCD.root","READ");
  TFile *bkg6 =  TFile::Open("./25ns_2246inv_v3/VH.root","READ");
  TFile *bkg7 =  TFile::Open("./25ns_2246inv_v3/ttHJetToGG.root","READ");
  TFile *bkg8 =  TFile::Open("./25ns_2246inv_v3/VBFHToGG.root","READ");
  TFile *bkg9 =  TFile::Open("./25ns_2246inv_v3/TGJets.root","READ");
  TFile *bkg10 =  TFile::Open("./25ns_2246inv_v3/TTGJets.root","READ");
  TFile *bkg11 =  TFile::Open("./25ns_2246inv_v3/WGToLNuG.root","READ");
  TFile *bkg12 =  TFile::Open("./25ns_2246inv_v3/ZGTo2LG.root","READ");
 
  TTree *tree_data = (TTree*) data->Get("DiPhotonTree");

  TTree *tree_sig1 = (TTree*) sig1->Get("DiPhotonTree"); 
  TTree *tree_sig2 = (TTree*) sig2->Get("DiPhotonTree"); 
  TTree *tree_sig3 = (TTree*) sig3->Get("DiPhotonTree"); 
  TTree *tree_sig4 = (TTree*) sig4->Get("DiPhotonTree"); 
  TTree *tree_sig5 = (TTree*) sig5->Get("DiPhotonTree"); 
  TTree *tree_sig6 = (TTree*) sig6->Get("DiPhotonTree");
  TTree *tree_sig7 = (TTree*) sig7->Get("DiPhotonTree");  


  TTree *tree_bkg1 = (TTree*) bkg1->Get("DiPhotonTree");
  TTree *tree_bkg2 = (TTree*) bkg2->Get("DiPhotonTree");
  TTree *tree_bkg3 = (TTree*) bkg3->Get("DiPhotonTree");
  TTree *tree_bkg4 = (TTree*) bkg4->Get("DiPhotonTree");
  TTree *tree_bkg5 = (TTree*) bkg5->Get("DiPhotonTree");
  TTree *tree_bkg6 = (TTree*) bkg6->Get("DiPhotonTree");
  TTree *tree_bkg7 = (TTree*) bkg7->Get("DiPhotonTree");
  TTree *tree_bkg8 = (TTree*) bkg8->Get("DiPhotonTree");
  TTree *tree_bkg9 = (TTree*) bkg9->Get("DiPhotonTree");
  TTree *tree_bkg10 = (TTree*) bkg10->Get("DiPhotonTree");
  TTree *tree_bkg11 = (TTree*) bkg11->Get("DiPhotonTree");
  TTree *tree_bkg12 = (TTree*) bkg12->Get("DiPhotonTree");

  TCanvas *c1 = new TCanvas("c1","",500,600);
  TPad *mainPad = new TPad("mainPad","",0,0.3,1,1); 
  TPad *smallPad = new TPad("smallPad","",0,0.05,1,0.3);
  mainPad->SetBottomMargin(0.015);
 
  
  smallPad->SetTopMargin(0.05); 
smallPad->SetBottomMargin(0.25); 

  c1->cd();
  
  mainPad->Draw();
  mainPad->cd(); 
 
  
  
  
  
  
  
  // gPad->SetLogy();  
  
  TCut mggmax = "mgg<180";
  TCut mggmin = "mgg>100";
  TCut mggblind = "((mgg<115)||(mgg>135))";

  TCut pt1Cut = Form("pt1/mgg>%lf",pt1min);
  TCut pt2Cut = Form("pt2/mgg>%lf",pt2min);
  TCut METCut = Form("t1pfmet>%lf",METmin);
  TCut eveto1 = "eleveto1 == 1";
  TCut eveto2 = "eleveto2 == 1";
  TCut eveto = eveto1 && eveto2;
  TCut genmatch = "((genmatch1==1 && genmatch2==0)||(genmatch1==0 && genmatch2==1)||(genmatch1==0 && genmatch2==0))";  
  TCut metF = "((metF_GV==1) && (metF_HBHENoise==1) && (metF_HBHENoiseIso==1) && (metF_CSC==1) && (metF_eeBadSC==1))";  
  
  tree_data->Draw("(eta1)>>hdata(15,-3,3)",(mggmax && mggmin && metF&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *hdata =(TH1F*)gPad->GetPrimitive("hdata");
  
  
  tree_sig1->Draw("(eta1)>>h1(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *h1 =(TH1F*)gPad->GetPrimitive("h1");
  tree_sig2->Draw("(eta1)>>h2(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *h2 =(TH1F*)gPad->GetPrimitive("h2");
  tree_sig3->Draw("(eta1)>>h3(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *h3 =(TH1F*)gPad->GetPrimitive("h3");
  tree_sig4->Draw("(eta1)>>h4(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *h4 =(TH1F*)gPad->GetPrimitive("h4");
  tree_sig5->Draw("(eta1)>>h5(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *h5 =(TH1F*)gPad->GetPrimitive("h5");
  tree_sig6->Draw("(eta1)>>h6(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *h6 =(TH1F*)gPad->GetPrimitive("h6");
  tree_sig7->Draw("(eta1)>>h7(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *h7 =(TH1F*)gPad->GetPrimitive("h7");
  
  
  tree_bkg1->Draw("(eta1)>>hbkg1(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *hbkg1 =(TH1F*)gPad->GetPrimitive("hbkg1");
  tree_bkg2->Draw("(eta1)>>hbkg2(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto));  
  TH1F *hbkg2 =(TH1F*)gPad->GetPrimitive("hbkg2");
  tree_bkg3->Draw("(eta1)>>hbkg3(15,-3,3)","weight"*(mggmin && mggmax && genmatch&& METCut &&pt1Cut && pt2Cut&& eveto));  
  TH1F *hbkg3 =(TH1F*)gPad->GetPrimitive("hbkg3");
  tree_bkg4->Draw("(eta1)>>hbkg4(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); //weight also on BR = 0.002 if using the 50ns samples
  TH1F *hbkg4 =(TH1F*)gPad->GetPrimitive("hbkg4");
  tree_bkg5->Draw("(eta1)>>hbkg5(15,-3,3)","weight"*(mggmin && mggmax && genmatch&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *hbkg5 =(TH1F*)gPad->GetPrimitive("hbkg5");
  tree_bkg6->Draw("(eta1)>>hbkg6(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *hbkg6 =(TH1F*)gPad->GetPrimitive("hbkg6");
  tree_bkg7->Draw("(eta1)>>hbkg7(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *hbkg7 =(TH1F*)gPad->GetPrimitive("hbkg7");
  tree_bkg8->Draw("(eta1)>>hbkg8(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *hbkg8 =(TH1F*)gPad->GetPrimitive("hbkg8");
  tree_bkg9->Draw("(eta1)>>hbkg9(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *hbkg9 =(TH1F*)gPad->GetPrimitive("hbkg9");
  tree_bkg10->Draw("(eta1)>>hbkg10(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *hbkg10 =(TH1F*)gPad->GetPrimitive("hbkg10");
  tree_bkg11->Draw("(eta1)>>hbkg11(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *hbkg11 =(TH1F*)gPad->GetPrimitive("hbkg11");
  tree_bkg12->Draw("(eta1)>>hbkg12(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *hbkg12 =(TH1F*)gPad->GetPrimitive("hbkg12");
  
  hdata->SetMarkerColor(kBlack);
  hdata->SetMarkerStyle(15);
  hdata->SetLineColor(kBlack);
  
  h1->SetLineColor(kRed+3);
  h2->SetLineColor(kRed+1);
  h3->SetLineColor(kRed);
  h4->SetLineColor(kPink+2);
  h5->SetLineColor(kPink+4);
  h6->SetLineColor(kPink+7);
  h7->SetLineColor(kMagenta+2);
 
  h1->SetLineWidth(2);
  h2->SetLineWidth(2);  
  h3->SetLineWidth(2);
  h4->SetLineWidth(2);
  h5->SetLineWidth(2);
 h6->SetLineWidth(2);
 h7->SetLineWidth(2);
  




  THStack *hs= new THStack("hs","");
  hbkg7->SetFillColor(kGreen+2);
  hbkg6->SetFillColor(kGreen);
  hbkg8->SetFillColor(kYellow);
  hbkg4->SetFillColor(kOrange);
  hbkg9->SetFillColor(kOrange+7);
  hbkg10->SetFillColor(kOrange+4);
  hbkg11->SetFillColor(kCyan);
  hbkg12->SetFillColor(kCyan+1);
  hbkg5->SetFillColor(kBlue+2);
  hbkg2->SetFillColor(kBlue);
  hbkg3->SetFillColor(kMagenta-2);
  hbkg1->SetFillColor(kViolet);

  hbkg1->SetLineColor(kBlack);
  hbkg2->SetLineColor(kBlack);
  hbkg3->SetLineColor(kBlack);
  hbkg4->SetLineColor(kBlack);
  hbkg5->SetLineColor(kBlack);
  hbkg6->SetLineColor(kBlack);
  hbkg7->SetLineColor(kBlack);
  hbkg8->SetLineColor(kBlack);
  hbkg9->SetLineColor(kBlack);
  hbkg10->SetLineColor(kBlack);
  hbkg11->SetLineColor(kBlack);
  hbkg12->SetLineColor(kBlack);

  hs->Add(hbkg7);
  hs->Add(hbkg6);
  hs->Add(hbkg8);
  hs->Add(hbkg4);
  hs->Add(hbkg9);
  hs->Add(hbkg10);
  hs->Add(hbkg11);
  hs->Add(hbkg12);
  hs->Add(hbkg2);
  hs->Add(hbkg5);
  hs->Add(hbkg3);
  hs->Add(hbkg1);






  
  TH1F *hsum = (TH1F*)hbkg1->Clone("hsum");
  hsum->Add(hbkg2);
  hsum->Add(hbkg3);
  hsum->Add(hbkg4);
  hsum->Add(hbkg5);
  hsum->Add(hbkg6);
  hsum->Add(hbkg7);
  hsum->Add(hbkg8);
  hsum->Add(hbkg9);
  hsum->Add(hbkg10);
  hsum->Add(hbkg11);
  hsum->Add(hbkg12);

  // hs->SetMaximum(1000000);
 hs->SetMaximum(5000);
  // hs->SetMinimum(0.1);
  hs->SetTitle("");
  hs->Draw("HIST"); 

  hsum->SetMarkerStyle(1);
  hsum->SetFillColor(kGray+3);
  hsum->SetFillStyle(3002);
  hsum->Draw("same e2");
  h2->Draw("same hist");
  h3->Draw("same hist"); 
  h4->Draw("same hist");
  h1->Draw("same hist");
  h5->Draw("same hist"); 
 h6->Draw("same hist"); 
 h7->Draw("same hist"); 

  hdata->Draw("same E1");
  
  hs->GetXaxis()->SetLabelOffset(999);
  hs->GetYaxis()->SetTitle("Events/0.4");  
  hs->GetYaxis()->SetTitleOffset(1.4);  
  gPad->Modified();
  
  leg->AddEntry(hdata,"Data","lep");
     
  
  
  leg->AddEntry(hbkg1,"#gamma #gamma","f");
leg->AddEntry(h1,"m_{Z'} = 600 GeV","l");                                                                               

  leg->AddEntry(hbkg2,"Drell Yann","f");
 
  leg->AddEntry(hbkg3,"#gamma + Jets","f");
leg->AddEntry(h2,"m_{Z'} = 800 GeV","l");                                                                               

  leg->AddEntry(hbkg5,"QCD","f");
  
  leg->AddEntry(hbkg4,"ggH","f");
 leg->AddEntry(h3,"m_{Z'} = 1000 GeV","l");                                                                    
 
  leg->AddEntry(hbkg6,"VH","f");
 
  leg->AddEntry(hbkg7,"ttH","f");

 leg->AddEntry(h4,"m_{Z'} = 1200 GeV","l");                                                                    
  leg->AddEntry(hbkg8,"VBF H","f");
  leg->AddEntry(hbkg9,"t + #gamma + Jets","f");
leg->AddEntry(h5,"m_{Z'} = 1400 GeV","l");                                                            
leg->AddEntry(hbkg10,"tt + #gamma +Jets","f");
  leg->AddEntry(hbkg11,"#gamma+W","f");
leg->AddEntry(h6,"m_{Z'} = 1700 GeV","l");     
  leg->AddEntry(hbkg12,"#gamma+Z","f");
  leg->AddEntry(hsum,"Bkg uncertainty","f");

 leg->AddEntry(h7,"m_{Z'} = 2500 GeV","l");                            
 leg->Draw("same");
  
  c1->cd(); 
  smallPad->Draw(); 
  smallPad->cd();

  TGraphErrors *gr = new TGraphErrors(0);
  double integralData=hdata->Integral();
  double integralBKG=hsum->Integral();
  double error, ratio;
  for(int w=1; w<15; w++){
    if((hdata->GetBinContent(w)!=0) && (hsum->GetBinContent(w)!=0)){
      
      gr->SetPoint(w, hdata->GetBinCenter(w),(hdata->GetBinContent(w))/(hsum->GetBinContent(w)));
      ratio= (hdata->GetBinContent(w))/(hsum->GetBinContent(w));
      error= (hdata->GetBinContent(w)*sqrt(hsum->GetBinContent(w))/(hsum->GetBinContent(w)*hsum->GetBinContent(w)) + sqrt(hdata->GetBinContent(w))/hsum->GetBinContent(w));
      std::cout<<"VALUE: "<<ratio<<" ERROR: "<<error<<std::endl;
      gr->SetPointError(w, hdata->GetBinWidth(w)/2,error);
    }else{
      gr->SetPoint(w, hdata->GetBinCenter(w),10);
    } 
  }

  
  
  gStyle->SetPadTickY(1);
  gStyle->SetPadTickX(1);
  gr->GetHistogram()->SetMaximum(2);
  gr->GetHistogram()->SetMinimum(0.1);
  
  gStyle->SetTextSize(14);
  gROOT->ForceStyle();
  
  gr->GetXaxis()->SetLabelFont(43);
  gr->GetXaxis()->SetLabelSize(15);
  gr->GetYaxis()->SetLabelFont(43);
  gr->GetYaxis()->SetLabelSize(15);
  
  gr->GetXaxis()->SetLimits(-3,3);
  
  
  gPad->SetGrid();
  gStyle->SetStripDecimals(kTRUE);
  gr->SetMarkerStyle(20);
  gr->SetMarkerSize(0.7);
  
  
  gr->Draw("AZP");
  gr->GetXaxis()->SetTitle("#eta_{1}");
  gr->GetXaxis()->SetTitleSize(0.1);
  gr->GetYaxis()->SetTitleSize(0.1);
  gr->GetYaxis()->SetNdivisions(505);
 
  gr->GetXaxis()->SetTitleOffset(1);
  gr->GetYaxis()->SetTitle("Data/MC"); 
  gr->GetYaxis()->SetTitleOffset(0.4);
  gr->SetTitle(""); 
  smallPad->Update();
  TF1* line = new TF1("line","1",-3,3);
  line->SetLineColor(kRed);
  line->SetLineWidth(2);
  line->Draw("L same");
  gr->Draw("ZP SAME");
  

  if(pt1min==0 && pt2min == 0 && METmin == 0){
    c1->SaveAs("./25ns_2246inv_v3/plots/kinematics/eta1.png");
    c1->SaveAs("./25ns_2246inv_v3/plots/kinematics/eta1.pdf");
  }
  if(pt1min==0.65 && pt2min == 0.25){
    c1->SaveAs(Form("./25ns_2246inv_v3/plots/kinematics/eta1_optcuts_MET%.0lf.png",METmin));
    c1->SaveAs(Form("./25ns_2246inv_v3/plots/kinematics/eta1_optcuts_MET%.0lf.pdf",METmin));
  }
  


}
int CompareAllHistos(TString input1 = "../../QCD_ref.root", TString input2 = "../../QCD_filter.root", TString outdir="../plots/QCD/", TString leg1="no cut", TString leg2="jet filter", TString name="RelValQCD", bool MakeTotal=false) {
	
	gROOT->Reset();             
  //SetAtlasStyle();
  setTDRStyle();
  gStyle->SetPalette(1);
  gStyle->SetErrorX(0.5);
  gROOT->ProcessLine(".!mkdir -p "+outdir);
  gROOT->ProcessLine(".!mkdir -p "+outdir+"/pdf");
  gROOT->ProcessLine(".!mkdir -p "+outdir+"/png");

  
  TString Names[2] = { input1, input2};
  
//  TString outdir = "../plots/QCD/";
  const uint nFiles = 2;
  TFile * f[nFiles];  	

  
  std::stringstream indexes;
  for(uint iFile = 0; iFile < nFiles; iFile++)
  {
	indexes.str("");
  	indexes << Names[iFile];
  	
	std::string input_file=indexes.str();
	f[iFile] = TFile::Open(input_file.c_str());
	if(!f[iFile]) {
		std::cerr << "Error: file " << input_file << " could not be opened." << std::endl; 
    return 1;
	}
	else std::cout << "File " << input_file << " succesfully opened!" << std::endl;
  
  }
 // const uint nProfile12=8;
  const uint nProfile=4;
 // const uint nWP=3;
 // const uint n123=3;
  const uint n12=5;
  
  TString dirNames[1] = { "tauDifferenceAnalyzer"}; //"mmet_zh","mmmt_zh","mmme_zh","eett_zh","eemt_zh","eeet_zh","eeem_zh"};
 // TString profileNames_12[nProfile12] = {"pt_DM","eta_DM","vx_DM","phi_DM","pt_DMall","eta_DMall","vx_DMall","phi_DMall"};
  TString prefix_12 = "h_eff_id_";
  TString suffix_12[n12] = {"_DM","_DMall","_loose","_medium","_tight"};
  
  TString profileX[nProfile] = {"pt","eta","vx","phi"};
  const uint nTotal=nProfile*n12;
  //~ TString profile123_prefix="h_eff_id_";
  //~ TString profile123_WP[nWP]={"_loose","_medium","_tight"};
  //~ TString profile123_suffix[n123]={"","_2","_3"};
  //~ 
  TProfile* profileHist1[nTotal][nFiles];
// TProfile* profileHist2[nTotal][nFiles];
  
  //TProfile* profileHist[n123][nProfile*nWP][nFiles];
  //~ TProfile* profileHistB[nProfile*nWP][nFiles];
  //~ TProfile* profileHistC[nProfile*nWP][nFiles];
  //~ 
  
  
 // std::stringstream name;
 for(uint iFile = 0; iFile < nFiles; iFile++)
  {
	for(uint iSuff=0; iSuff < n12; iSuff++)
	{		
		for(uint iProf12=0; iProf12< nProfile; iProf12++)
		{
			profileHist1[iProf12+iSuff*nProfile][iFile]=(TProfile*)f[iFile]->Get(TString(dirNames[0]+"/"+prefix_12+profileX[iProf12]+suffix_12[iSuff]));
		//	profileHist2[iProf12+iSuff*nProfile][iFile]=(TProfile*)f[iFile]->Get(TString(dirNames[0]+"/"+prefix_12+profileX[iProf12]+suffix_12[iSuff]));
		}
	}
  }
  
  //~ for(uint iFile = 0; iFile < nFiles; iFile++)
  //~ {
	//~ for(uint iWP=0; iWP<nWP; iWP++)
		//~ {
			//~ for(uint iProf123=0; iProf123< nProfile; iProf123++)
			//~ {
				//~ for(uint i123=0; i123 < n123; i123++)
				//~ {
					//~ std::cout << dirNames[0]+"/"+profile123_prefix+profileX[iProf123]+profile123_WP[iWP]+profile123_suffix[i123] << std::endl;
					//~ profileHist[i123][iWP*nProfile+iProf123][iFile]=(TProfile*)f[iFile]->Get(TString(dirNames[0]+"/"+profile123_prefix+profileX[iProf123]+profile123_WP[iWP]+profile123_suffix[i123]));
				//~ }
			//~ }
		//~ }
  //~ }
  
  
  
  
  TCanvas *c1 = new TCanvas("c1","",5,30,1024,1024);
  c1->SetGrid(0,0);
  c1->SetFillStyle(4000);
  c1->SetFillColor(10);
  c1->SetTicky();
  c1->SetObjectStat(0);
  
  TPad* histPad = new TPad("histPad","histPad",0.01,0.25,0.99,0.99);
  histPad->SetBottomMargin(0.02);
  histPad->Draw();
  
  TPad* diffPad = new TPad("diffPad","diffPad",0.01,0.01,0.99,0.25);
  diffPad->SetBottomMargin(0.3);
  diffPad->SetTopMargin(0.0);
  diffPad->Draw();
  
  // plotting
  
	TString XTitle[4] = {"True P_{T} [GeV]","True #eta", "nVx","True #phi"};
   // c1->SetLogy();
	std::cout << "hej hola " << std::endl;
	for(uint iProf12=0; iProf12< nTotal; iProf12++)
	{
		 int title_id=iProf12%4;
		
		 if(title_id!=2){
			 profileHist1[iProf12][0]->Rebin(5);
			 profileHist1[iProf12][1]->Rebin(5);
		 }
	
		 TH1D* baseHist = (TH1D*)profileHist1[iProf12][0]->Clone();
		 TH1D* overHist = (TH1D*)profileHist1[iProf12][1]->Clone();
		 
		 if(MakeTotal && iProf12>7){ 
			 double binLow = baseHist->GetXaxis()->GetBinLowEdge(baseHist->GetXaxis()->GetFirst());
			 double binUp = baseHist->GetXaxis()->GetBinUpEdge(baseHist->GetXaxis()->GetLast());
			 int nBins = baseHist->GetXaxis()->GetNbins();
			 
			 TH1D* newBaseHist = new TH1D(TString(baseHist->GetName())+"TOT",baseHist->GetTitle(),nBins,binLow,binUp);
			 TH1D* newDMHist = new TH1D("newDMHist","",nBins,binLow,binUp);
			 TH1D* newOverHist = new TH1D(TString(overHist->GetName())+"TOTover",baseHist->GetTitle(),nBins,binLow,binUp);
			 TH1D* newDMHist2 = new TH1D("newDMHist2","",nBins,binLow,binUp);
			 
			 
			 for(int iBin=0; iBin <= baseHist->GetNbinsX(); iBin++)
			 {
				newBaseHist->SetBinContent(iBin,baseHist->GetBinContent(iBin));
				newBaseHist->SetBinError(iBin,baseHist->GetBinError(iBin));
				newDMHist->SetBinContent(iBin,profileHist1[title_id][0]->GetBinContent(iBin));
				newDMHist->SetBinError(iBin,profileHist1[title_id][0]->GetBinError(iBin));
				newOverHist->SetBinContent(iBin,overHist->GetBinContent(iBin));
				newOverHist->SetBinError(iBin,overHist->GetBinError(iBin));
				newDMHist2->SetBinContent(iBin,profileHist1[title_id][1]->GetBinContent(iBin));
				newDMHist2->SetBinError(iBin,profileHist1[title_id][1]->GetBinError(iBin));	
				
			 }
			 newBaseHist->Multiply(newDMHist);
			 newOverHist->Multiply(newDMHist2);
			 baseHist=newBaseHist;
			 overHist=newOverHist;
			 delete newDMHist;
			 delete newDMHist2;
		 }
	
		 if(title_id==0) baseHist->GetXaxis()->SetRangeUser(0,100);
		 baseHist->GetXaxis()->SetLabelOffset(0.1);		
		 baseHist->GetXaxis()->SetTitle(XTitle[title_id]);
		 baseHist->GetYaxis()->SetTitle("Fake rate");
		 baseHist->SetMarkerStyle(20);
		 baseHist->SetMarkerSize(2);
		 baseHist->SetLineWidth(2);
		 
		 overHist->SetMarkerColor(kRed);
		 overHist->SetMarkerStyle(25);
		 overHist->SetMarkerSize(2);
		 overHist->SetLineWidth(2);
		 overHist->SetLineStyle(2);
		 overHist->SetLineColor(kRed);
		
		 int binmax = baseHist->GetMaximumBin();
	     double max = 1.2*(baseHist->GetBinContent(binmax)+baseHist->GetBinError(binmax));
	     int binmax2 = overHist->GetMaximumBin();
	     double max2 = 1.2*(overHist->GetBinContent(binmax2)+overHist->GetBinError(binmax2));
	     max = max2 > max ? max2 : max;
	 
	     baseHist->SetMaximum(10.0);
	     baseHist->SetMinimum(1e-3);
	     
		 
		 histPad->cd();	
			 histPad->SetLogy();
		 baseHist->Draw();
		 overHist->Draw("same");	
		 
		TLegend* leg = new TLegend(0.8,0.80,0.9,0.9,NULL,"brNDC");
		leg->SetFillColor(0);
		leg->SetTextSize(0.035);
		leg->SetBorderSize(0);
		
		leg->AddEntry(baseHist, leg1, "lp");
		leg->AddEntry(overHist, leg2, "lp");
		
		leg->Draw();
		 //~ 
		 
    TString lumist="";
	TPaveText *ll = new TPaveText(0.15, 0.95, 0.95, 0.99, "NDC");
	ll->SetTextSize(0.03);
	ll->SetTextFont(62);
	ll->SetFillColor(0);
	ll->SetBorderSize(0);
	ll->SetMargin(0.01);
	ll->SetTextAlign(12); // align left
	TString text = name;
	ll->AddText(0.01,0.7,text);
	text = "#sqrt{s} = 13 TeV";
	text = text + lumist;
	//  ll->SetTextAlign(32); // align right
	ll->AddText(0.7, 0.5, text);
	ll->Draw("same");
	  
	
	c1->Update();
	
	TH1D* h_diff=(TH1D*)baseHist->Clone();
	h_diff->Divide(overHist);
	diffPad->cd();
	diffPad->SetGridy();
	diffPad->SetGridx();
	
	h_diff->GetYaxis()->SetLabelSize(0.1);
    h_diff->GetYaxis()->SetTitleOffset(0.55);
    h_diff->GetYaxis()->SetTitleSize(0.12);
    h_diff->GetYaxis()->SetTitle("Ratio");
    h_diff->GetXaxis()->SetLabelSize(0.12);
    h_diff->GetXaxis()->SetLabelOffset(0.01);
    h_diff->GetXaxis()->SetTitleSize(0.15);
	h_diff->GetYaxis()->SetNdivisions(509);
	h_diff->SetMinimum(0.9);
	h_diff->SetMaximum(1.1);
	
	h_diff->Draw("hist");
	c1->Print(outdir+"/pdf/"+profileHist1[iProf12][0]->GetName()+".pdf");
	c1->Print(outdir+"/png/"+profileHist1[iProf12][0]->GetName()+".png");
	
	
	}
  
  
	return 0;
}
Esempio n. 7
0
void compareDataMC( vector<TChain*> chmc , vector<char*> labels , TChain* chdata , char* var , 
		    TCut sel , TCut weight , int nbins ,  float xmin , float xmax ,  
		    char* xtitle , bool overlayData , bool residual , bool drawLegend , bool log , char* flavor ){

  TPad* fullpad = new TPad();
  TPad* plotpad = new TPad();
  TPad* respad  = new TPad();

  if( residual ){
    fullpad = new TPad("fullpad","fullpad",0,0,1,1);
    fullpad->Draw();
    fullpad->cd();

    plotpad = new TPad("plotpad","plotpad",0,0,1,0.8);
    plotpad->Draw();
    plotpad->cd();
    if( log ) plotpad->SetLogy();
  }
  else{
    if( log ) gPad->SetLogy();
  }

  TString tvar(var);
  tvar.ReplaceAll("()","");
  tvar.ReplaceAll(".","");
  const char* myvar = tvar;

  cout << "Plotting var " << myvar << " flavor " << flavor << endl;

  //int colors[]={6,2,7,4,5,8,9,15,12};
  int colors[]={kBlue-6,kRed+2,7,5,5,8,9,15,12};

  assert( chmc.size() == labels.size() );
  const unsigned int nmc = chmc.size();

  THStack* mcstack = new THStack("mcstack","mcstack");
  TH1F*    mctothist = new TH1F();
  TH1F*    mchist[nmc];
  TH1F*    datahist = new TH1F(Form("%s_datahist_%s",myvar,flavor),Form("%s_datahist_%s",myvar,flavor),nbins,xmin,xmax);

  float trigeff = 1.0;
  //if     ( TString(flavor).Contains("ee")  ) trigeff = 1.00;
  //else if( TString(flavor).Contains("mm")  ) trigeff = 0.90;
  //else if( TString(flavor).Contains("em")  ) trigeff = 0.95;
  //else if( TString(flavor).Contains("all") ) trigeff = 0.95;
  if     ( TString(flavor).Contains("ee")  ) sel+="leptype==0";
  else if( TString(flavor).Contains("mm")  ) sel+="leptype==1";
  else if( TString(flavor).Contains("em")  ) sel+="leptype==2";
  //else if( TString(flavor).Contains("all") ) 

  TCut trigweight(Form("%.2f",trigeff));

  for( unsigned int imc = 0 ; imc < nmc ; imc++ ){
  //for( int imc = nmc-1 ; imc > -1 ; imc-- ){

    mchist[imc] = new TH1F(Form("%s_mc_%i_%s",myvar,imc,flavor),Form("%s_mc_%i_%s",myvar,imc,flavor),nbins,xmin,xmax);
    mchist[imc]->Sumw2();

    chmc.at(imc)->Draw(Form("TMath::Min(%s,%f)>>%s_mc_%i_%s",var,xmax-0.01,myvar,imc,flavor),sel*weight*trigweight);

    if( TString( labels.at(imc) ).Contains("LM") || TString( labels.at(imc) ).Contains("T2tt") ){
      mchist[imc]->SetFillColor( 0 );
      mchist[imc]->SetLineStyle(2);
    }else{
      mchist[imc]->SetFillColor( colors[imc] );
    }

    // if( strcmp(labels[imc],"ttfake")  == 0 || strcmp(labels[imc],"wjets")  == 0 ){
    //   cout << "Scaling " << labels[imc] << " by 3.8" << endl;
    //   mchist[imc]->Scale(3.8);
    // }

    mcstack->Add( mchist[imc] );

    if( imc == 0 ) mctothist = (TH1F*) mchist[imc]->Clone();
    else           mctothist->Add(mchist[imc]);

    cout << "MC yield " << labels[imc] << " " << Form("%.2f",mchist[imc]->Integral()) << endl;
  }

  chdata->Draw(Form("TMath::Min(%s,%f)>>%s_datahist_%s",var,xmax-0.01,myvar,flavor),sel);

  if( overlayData ){

    float max = datahist->GetMaximum() + datahist->GetBinError(datahist->GetMaximumBin());
    if( mctothist->GetMaximum() > max ) max = mctothist->GetMaximum();
    if( log ) datahist->SetMaximum( 15 * max );
    else      datahist->SetMaximum( 1.4 * max );

    datahist->GetXaxis()->SetTitle(xtitle);
    datahist->Draw("E1");
    mcstack->Draw("samehist");
    datahist->Draw("sameE1");
    datahist->Draw("sameaxis");
    
    if(!log) datahist->GetYaxis()->SetRangeUser(0.,1.4*max);
    
    cout << "data yield " << datahist->Integral() << endl;

  }
  else{
    mctothist->GetXaxis()->SetTitle(xtitle);
    mctothist->Draw();
    mcstack->Draw("same");
    mctothist->Draw("sameaxis");
  }

  if( drawLegend ){
    TLegend* myleg = getLegend( chmc , labels , overlayData );
    myleg->Draw();
  }

  TLatex *text = new TLatex();
  text->SetNDC();
  text->SetTextSize(0.05);
  text->DrawLatex(0.2,0.88,"CMS Preliminary");
  //text->DrawLatex(0.2,0.83,"0.98 fb^{-1} at #sqrt{s} = 7 TeV");
  text->DrawLatex(0.2,0.83,"#sqrt{s} = 7 TeV, #scale[0.6]{#int}Ldt = 4.3 fb^{-1}");

  if     ( TString(flavor).Contains("ee")  ) text->DrawLatex(0.2,0.78,"Events with ee");
  else if( TString(flavor).Contains("mm")  ) text->DrawLatex(0.2,0.78,"Events with #mu#mu");
  else if( TString(flavor).Contains("em")  ) text->DrawLatex(0.2,0.78,"Events with e#mu");
  else if( TString(flavor).Contains("all") ) text->DrawLatex(0.2,0.78,"Events with ee/#mu#mu/e#mu");

  if( residual ){
    fullpad->cd();

    respad = new TPad("respad","respad",0,0.8,1,1);
    respad->Draw();
    respad->cd();

    gPad->SetGridy();

    TH1F* ratio = (TH1F*) datahist->Clone(Form("%s_ratio",datahist->GetName()));
    ratio->Divide(mctothist);

    ratio->GetYaxis()->SetTitleOffset(0.3);
    ratio->GetYaxis()->SetTitleSize(0.2);
    ratio->GetYaxis()->SetNdivisions(5);
    ratio->GetYaxis()->SetLabelSize(0.2);
    //ratio->GetYaxis()->SetRangeUser(0.5,1.5);
    ratio->GetYaxis()->SetRangeUser(0.,2.);
    ratio->GetYaxis()->SetTitle("data/MC  ");
    ratio->GetXaxis()->SetLabelSize(0);
    ratio->GetXaxis()->SetTitleSize(0);
    ratio->SetMarkerSize(0.7);
    ratio->Draw();

    TLine line;
    line.SetLineWidth(1);
    line.DrawLine(datahist->GetXaxis()->GetXmin(),1,datahist->GetXaxis()->GetXmax(),1);

  }






}
////////////////////////////////////////////////////////////////////////////////////////
// Draw and save the canvas
// This bit shouldn't need to be updated except the region and channel labels
// As of Jan 10,2013 - the known issues are:
// ++ Error bands don't show correctly
// ++ Data histogram needs to be converted to TGraphAsymmErrors and 
//    plotted w/ poisson errors
// ++ Ratio plot needs to divide the Data TGraphAsymmErrors and
//    TGraphAsymmErrors for the total SM (by turning off the errors since they are
//    shown explicitly)
////////////////////////////////////////////////////////////////////////////////////////
void PlotUnifier(
                  TH1F* histos[9],                   // Array of pointers to histograms
                  TGraphAsymmErrors* smErrorBand,    // Error band for the top pad
                  TGraphAsymmErrors* ratioErrorBand  // Error band for the bottom pad
                )
{
  ////////////////////////////////////////////////////////////////////////////////////////
  // Set Histogram Properties, build the stack and make the ratio plot
  histos[0]->SetMarkerStyle(20)     ; histos[0]->SetMarkerSize(1.2); 
  histos[1]->SetFillColor(kOrange-2); histos[4]->SetLineWidth (2);
  histos[2]->SetFillColor(kAzure-9 ); histos[1]->SetLineWidth (2);
  histos[3]->SetFillColor(kSpring+1); histos[2]->SetLineWidth (2);
  histos[4]->SetFillColor(kAzure+4 ); histos[3]->SetLineWidth (2);
  histos[5]->SetFillColor(kGray    ); histos[5]->SetLineWidth (2);
  histos[6]->SetFillColor(kYellow-9); histos[6]->SetLineWidth (2);
  histos[7]->SetLineColor(kMagenta ); histos[7]->SetLineWidth (3); histos[7]->SetLineStyle(2);
  histos[8]->SetLineColor(kGreen+1 ); histos[8]->SetLineWidth (3); histos[8]->SetLineStyle(2);
  
  ////////////////////////////////////////////////////////////////////////////////////////
  // Here comes the stack 
  THStack* sm = new THStack("sm","sm");
  sm->Add(histos[6]);
  sm->Add(histos[5]);
  sm->Add(histos[4]);
  sm->Add(histos[3]);
  sm->Add(histos[2]);
  sm->Add(histos[1]);

  ////////////////////////////////////////////////////////////////////////////////////////
  // Define the legend and fill in the stack order
  TLegend* legendA        = new TLegend(0.49,0.65,0.74,0.85);
  TLegend* legendB        = new TLegend(0.62,0.65,0.87,0.85);
  legendA->SetTextFont(42);    
  legendB->SetTextFont(42);    
  legendA->SetTextSize(0.03);
  legendB->SetTextSize(0.03);
  legendA->SetBorderSize(0);
  legendB->SetBorderSize(0);
  legendA->SetFillColor(0);
  legendB->SetFillColor(0);
  legendA->AddEntry(histos[0],"Data"               ,"p");
  legendA->AddEntry(histos[1],"Z+jets"             ,"f");
  legendA->AddEntry(histos[2],"WW"                 ,"f");
  legendA->AddEntry(histos[3],"t#bar{t}+Wt"        ,"f");
  legendA->AddEntry(histos[4],"ZV"                 ,"f");
  legendB->AddEntry(histos[5],"Non-prompt leptons" ,"f");
  legendB->AddEntry(histos[6],"Higgs"              ,"f");
  TH1F* histoError = new TH1F("histoError"         ,"histoError",1,0,1);
  histoError->SetFillStyle(3004);
  histoError->SetFillColor(kBlack);
  legendB->AddEntry(histoError,"Bkg. Uncert."      ,"f");
  legendB->AddEntry(histos[7],"Signal 1"           ,"l");
  legendB->AddEntry(histos[8],"Signal 2"           ,"l");

  ////////////////////////////////////////////////////////////////////////////////////////
  // Ratio plot 
  TH1F* ratio      = (TH1F*) histos[0]->Clone(); ratio->Reset(); 
  TH1F* stackHisto = (TH1F*) sm->GetStack()->Last();
  ratio->Divide(histos[0],stackHisto);
  ratio->SetMarkerSize(1.2);
  ratio->SetMarkerStyle(20);
  ratio->SetLineColor(kBlack);
  ratio->SetLineWidth(2);

  ratio->GetXaxis()->SetTitle("Observable");
  ratio->GetYaxis()->SetTitle("Data/SM");
  ratio->GetXaxis()->SetLabelSize(0.13);
  ratio->GetXaxis()->SetLabelOffset(0.02);
  ratio->GetXaxis()->SetTitleSize(0.14);
  ratio->GetXaxis()->SetTitleOffset(1.2);

  ratio->GetYaxis()->SetRangeUser(0,2);
  ratio->GetYaxis()->SetLabelSize(0.13);
  ratio->GetYaxis()->SetLabelOffset(0.0125);
  ratio->GetYaxis()->SetTitleSize(0.14);
  ratio->GetYaxis()->SetTitleOffset(0.5);
  ratio->GetYaxis()->SetNdivisions(5);

  ////////////////////////////////////////////////////////////////////////////////////////
  // Error bands
  smErrorBand->SetMarkerSize(0); 
  smErrorBand->SetFillStyle(3004);
  smErrorBand->SetFillColor(kBlack);
  ratioErrorBand->SetMarkerSize(0); 
  ratioErrorBand->SetFillStyle(3004);
  ratioErrorBand->SetFillColor(kBlack);
 
  ////////////////////////////////////////////////////////////////////////////////////////
  // Draw and save the canvas
  TCanvas* canvas = new TCanvas("canvas","canvas",500,500);
  TPad*    topPad = new TPad("pTop","pTop",0,0.2,1,1);
  TPad*    botPad = new TPad("pBot","pBot",0,0.0,1,0.3);
  topPad->Draw();
  botPad->Draw();

  ////////////////////////////////////////////////////////////////////////////////////////
  // Data is special since I use it to draw the axis labels etc.
  histos[0]->GetXaxis()->SetTitle("Observable"); 
  histos[0]->GetYaxis()->SetTitle("Events / Bin"); 
  histos[0]->GetXaxis()->SetLabelOffset(1.2); 
  histos[0]->GetXaxis()->SetLabelSize(0.03);
  histos[0]->GetYaxis()->SetRangeUser(1.e-2,1.e5);
  histos[0]->GetYaxis()->SetTitleSize(0.055);
  histos[0]->GetYaxis()->SetTitleOffset(1.28);
  histos[0]->GetYaxis()->SetLabelSize(0.05);
  histos[0]->GetYaxis()->SetLabelOffset(0.01);

  ////////////////////////////////////////////////////////////////////////////////////////
  // Top Pad
  topPad      ->cd();
  topPad      ->SetBottomMargin(0.15);
  histos[0]   ->Draw("p && e && x0");
  sm          ->Draw("same && hists");
  smErrorBand ->Draw("same && E2");
  histos[0]   ->Draw("same && p && e && x0");
  histos[7]   ->Draw("same && hist");
  histos[8]   ->Draw("same && hist");
  legendA     ->Draw();
  legendB     ->Draw();
  gPad        ->RedrawAxis();
  gPad        ->SetLogy(1);

  ////////////////////////////////////////////////////////////////////////////////////////
  // Decoration
  char annoyingLabel1[100] = "#bf{#it{ATLAS}}, #sqrt{s} = 8 TeV, 20.3 fb^{-1}";
  char annoyingLabel2[100] = "SF/DF channel"; 
  char annoyingLabel3[100] = "- Top CR for SR-#scale[0.9]{m_{T2}} and SR-WWb/c";
  myText(0.53,0.880,kBlack,annoyingLabel1);
  myText(0.17,0.965,kBlack,annoyingLabel2);
  myText(0.37,0.965,kBlack,annoyingLabel3);

  ////////////////////////////////////////////////////////////////////////////////////////
  // Bottom Pad
  botPad ->cd();
  botPad ->SetBottomMargin(0.4);
  
  ////////////////////////////////////////////////////////////////////////////////////////
  // 1 Line
  TLine* line = new TLine(histos[0]->GetXaxis()->GetXmin(),1,histos[0]->GetXaxis()->GetXmax(),1);
  line   ->SetLineColor(kRed);
  line   ->SetLineStyle(7);

  ////////////////////////////////////////////////////////////////////////////////////////
  // Draw
  ratio          ->Draw("p && e && x0");
  ratioErrorBand ->Draw("same && E2");
  line           ->Draw("same");
  ratio          ->Draw("same && p && e && x0");
  gPad           ->SetGridy(1);

  ////////////////////////////////////////////////////////////////////////////////////////
  // Save
  canvas ->SaveAs("Test_v3.eps");

} 
Esempio n. 9
0
// Make main selection plots
// n-1, control type plots and plots after all cuts
void makePlot(const TString & histoName, TFile * outputFile, TString anaType,
    const TString & xTitle,  const double & xMin, const double & xMax,
    const double & yMin = 0., const double & yMax = 0., bool logY=false,
    const float lumi = 0, const bool plotData=false, bool drawRatioPlot=false )
{
  std::cout << "----> Making plots for : " << histoName.Data() << std::endl;
  std::cout << "Plotting data ? " << plotData << std::endl;
  TH1::SetDefaultSumw2();
  gStyle->SetOptStat(0);
  gStyle->SetOptTitle(0);

  // Keep track of integrals of background & data
  double totalBkgMCIntegral = 0;
  //  double totalDataIntegral = 0;

  //
  // DATA
  //

  TH1F * histoData=0;

  if (plotData) {

    TFile * inputFile= new TFile ("CombinedFiles/Data_combined_"+anaType+".root", "READ");
    histoData = (TH1F*)inputFile->Get(histoName);
    //    totalDataIntegral = histoData->Integral();

    histoData->SetStats(0);
    histoData->SetMarkerStyle(21);
    histoData->SetMarkerSize(1);
  }

  //
  // SIGNAL MC
  //


  // Not good at the moment - just taking one or two examples to plot and hard coded the names of the files here
  TFile * signalInputFile1= new TFile (signal1+anaType+".root", "READ");
  TH1F * histoSignal1 = (TH1F*)signalInputFile1->Get(histoName);
  histoSignal1->SetStats(0);
  histoSignal1->Scale(lumi);

  TFile * signalInputFile2= new TFile (signal2+anaType+".root", "READ");
  TH1F * histoSignal2 = (TH1F*)signalInputFile2->Get(histoName);
  histoSignal2->SetStats(0);
  histoSignal2->Scale(lumi);

  int minIntegral=0;
  int maxIntegral=histoSignal1->GetNbinsX();

//  if ( histoName=="nMinus1_isolationLeptonH_removedLifetimeCuts" || histoName=="nMinus1_relIsolationLeptonH_removedLifetimeCuts" ) {
//    //    std::cout << find90Cut( histoSignal1 ) << std::endl;
//    //    std::cout << find90Cut( histoSignal2 ) << std::endl;
//
//    minIntegral=histoSignal1->FindBin( find90Cut(histoSignal1) );
//
//    // Check integral below specific cut
//    if ( histoName=="nMinus1_relIsolationLeptonH_removedLifetimeCuts" ) {
//      std::cout << "Signal 1" << std::endl;
//      std::cout << "Efficiency with rel iso cut at 0.1 : " << histoSignal1->Integral( 1, histoSignal1->FindBin(0.1) ) / histoSignal1->Integral() << std::endl;
//      std::cout << "Efficiency with rel iso cut at 0.05 : " << histoSignal1->Integral( 1, histoSignal1->FindBin(0.05) ) / histoSignal1->Integral() << std::endl;
//      std::cout << "Signal 2" << std::endl;
//      std::cout << "Efficiency with rel iso cut at 0.1 : " << histoSignal2->Integral( 1, histoSignal2->FindBin(0.1) ) / histoSignal2->Integral() << std::endl;
//      std::cout << "Efficiency with rel iso cut at 0.05 : " << histoSignal2->Integral( 1, histoSignal2->FindBin(0.05) ) / histoSignal2->Integral() << std::endl;
//    }
//  }

  TFile * signalInputFile3= new TFile (signal3+anaType+".root", "READ");
  TH1F * histoSignal3 = (TH1F*)signalInputFile3->Get(histoName);
  histoSignal3->SetStats(0);
  histoSignal3->Scale(lumi);

  //
  // BACKGROUND MC
  //

  THStack stack("Background MC","");
  setPlotTitle(stack, lumi);

  // Add all different background MC to this stack
  TLegend *legend= new TLegend(0.5,0.6,0.85,0.85);

  totalBkgMCIntegral = addBackgroundHistos(anaType, histoName, stack, legend, lumi, minIntegral, maxIntegral);


//  if ( histoName=="nMinus1_isolationLeptonH_removedLifetimeCuts" || histoName=="nMinus1_relIsolationLeptonH_removedLifetimeCuts" ) {
//    std::cout << "Integral of background between " << minIntegral << " and " << maxIntegral << " : " << totalBkgMCIntegral << std::endl;
//  }

  // Output histograms to file
  outputFile->cd();

  // Setup canvas
  TCanvas canvas(histoName);
  canvas.cd();
  // Draw one or two pads
  TPad * up = new TPad("u","u",0.01,0.25,0.99,0.99);
  up->SetNumber(1);
  up->Draw();
  TPad * dp = new TPad("d","d",0.01,0.01,0.99,0.25);

  if ( drawRatioPlot ) {
    dp->SetNumber(2);
    dp->UseCurrentStyle();
    dp->Draw();
  }
  else {
    up->SetPad(0.01,0.01,0.99,0.99);
    up->Draw();
  }

  if ( logY ) up->SetLogy();
  canvas.Draw();
  canvas.cd(1);
  up->cd();
  canvas.SetFillColor(kWhite);
  canvas.SetBorderMode(0);


  // Draw background MC
  // There may be zero entries, which will mess up drawing options
  // Not a good fix at the moment
  bool axesExist=false;
  if (totalBkgMCIntegral>0) {
    axesExist=true;

    stack.Draw("HISTE");

    stack.GetXaxis()->SetRangeUser(xMin, xMax);
    stack.SetMaximum(yMax);
    stack.SetMinimum(yMin);
    stack.GetXaxis()->SetTitle(xTitle);
    stack.GetYaxis()->SetTitle("Entries");
  }

  std::cout << "Drawing signal histos" << std::endl;
  // Draw signal MC
  histoSignal1->SetLineStyle(2);
  histoSignal1->SetLineColor(kMagenta+2);
  histoSignal1->SetLineWidth(2);
  if(axesExist) histoSignal1->Draw("same,HIST");
  else histoSignal1->Draw("HIST");

  histoSignal2->SetLineStyle(2);
  histoSignal2->SetLineColor(kGreen+2);
  histoSignal2->SetLineWidth(2);
  if(axesExist) histoSignal2->Draw("same,HIST");
  else histoSignal2->Draw("HIST");

  //  histoSignal3->SetLineStyle(2);
  //  histoSignal3->SetLineColor(4);
  //  histoSignal3->SetLineWidth(2);
  //  histoSignal3->Draw("same,HIST");

  // Draw data
  if ( plotData ) {
    if (axesExist) histoData->Draw("same,P,E,X0");
    else histoData->Draw("P,E,X0");
  }

  // Draw legend
  legend->SetBorderSize(0);
  legend->SetFillStyle(0);
  if ( plotData ) legend->AddEntry(histoData,"data","p");
  legend->AddEntry(histoSignal1,"m_{H}=1000 GeV/c^{2} m_{X}=350 GeV/c^{2}","l");
  legend->AddEntry(histoSignal2,"m_{H}=400 GeV/c^{2} m_{X}=50 GeV/c^{2}","l");
  //  legend->AddEntry(histoSignal3,"m_{squark}=350 GeV/c^{2} m_{#Chi}=148 GeV/c^{2}","l");

  legend->Draw();

  canvas.Update();

  // Draw mc/data ratio
  if ( drawRatioPlot ) {
    dp->cd();
    TH1F ratioHist( drawMCDataRatio( ((TH1*)stack.GetStack()->Last()), histoData ) );

    // Check content of ratioHist
    ratioHist.GetXaxis()->SetRangeUser(xMin, xMax);
    ratioHist.SetMarkerStyle(20);
    ratioHist.GetYaxis()->SetNdivisions(5,0,0);
    ratioHist.GetYaxis()->SetTickLength(0.01);
    dp->SetGridy();
    ratioHist.Draw("P");
    canvas.Update();
    canvas.Write();
  }
  else canvas.Write();

  // Draw systematic errors for reco PV plot
  // FIXME For some reason, old canvas can't handle this!
  if ( histoName=="nRecoPV" ) {
    TGraphAsymmErrors gr( makePUPlot( stack, anaType, lumi ) );

    // Move back to output file (as other files have been opened and closed in makePUPlot
    outputFile->cd();

    gr.SetFillColor(1);
    gr.SetFillStyle(3001);
    gr.Draw("2P0");
    canvas.Update();

    // Test
    TCanvas can("puSystematic");
    can.cd();
//    can.SetLogy();
    can.Draw();
    gr.SetTitle("TGraphAsymmErrors Example");

    stack.Draw("HISTE");
    gr.Draw("2P0");
    histoData->Draw("P,E,X0SAME");
    legend->Draw();

    can.Update();
    can.Write();
  }
}
Esempio n. 10
0
void DrawQCDClosure(TString VAR,int NBINS,float XMIN,float XMAX,TString XTITLE)
{
  gROOT->ForceStyle();
  
  const int N = 11;
  float XSEC[N] = {471100.,117276.,7823.,648.2,186.9,32.293,9.4183,0.84265,0.114943,0.00682981,0.000165445};

  TString SAMPLE[N] = {
    "QCD_Pt_120to170",
    "QCD_Pt_170to300",
    "QCD_Pt_300to470",
    "QCD_Pt_470to600",
    "QCD_Pt_600to800",
    "QCD_Pt_800to1000",
    "QCD_Pt_1000to1400",
    "QCD_Pt_1400to1800",
    "QCD_Pt_1800to2400",
    "QCD_Pt_2400to3200",
    "QCD_Pt_3200toInf" 
  }; 

  TFile *inf[N];
  TTree *tr0[N],*tr1[N],*tr2[N];
  TH1F  *h0[N],*h1[N],*h2[N];

  TCanvas *can = new TCanvas("can_QCDClosure_"+VAR,"can_QCDClosure_"+VAR,900,600);
  can->cd(1);
  can->SetBottomMargin(0.3);
  can->SetRightMargin(0.15);

  for(int i=0;i<N;i++) {
    inf[i] = TFile::Open("flatTree_"+SAMPLE[i]+".root");
    tr0[i] = (TTree*)inf[i]->Get("hadtopNoBtag/events");
    tr1[i] = (TTree*)inf[i]->Get("hadtopOneBtag/events");
    tr2[i] = (TTree*)inf[i]->Get("hadtop/events");
    TH1F *hpu = (TH1F*)inf[i]->Get("hadtop/pileup");
    h0[i]  = new TH1F("h0_"+SAMPLE[i],"h0_"+SAMPLE[i],NBINS,XMIN,XMAX);
    h1[i]  = new TH1F("h1_"+SAMPLE[i],"h1_"+SAMPLE[i],NBINS,XMIN,XMAX);
    h2[i]  = new TH1F("h2_"+SAMPLE[i],"h2_"+SAMPLE[i],NBINS,XMIN,XMAX);
    h0[i]->Sumw2();
    h1[i]->Sumw2();
    h2[i]->Sumw2();
    tr0[i]->Draw(VAR+">>"+"h0_"+SAMPLE[i],"triggerBit[0] && prob>0.05 && nBJets==0 && dRbbTop>2");
    tr1[i]->Draw(VAR+">>"+"h1_"+SAMPLE[i],"triggerBit[0] && prob>0.05 && nBJets==1 && dRbbTop>2");
    tr2[i]->Draw(VAR+">>"+"h2_"+SAMPLE[i],"triggerBit[0] && prob>0.05 && nBJets>1 && dRbbTop>2");
    h0[i]->Scale(XSEC[i]/hpu->GetEntries());
    h1[i]->Scale(XSEC[i]/hpu->GetEntries());
    h2[i]->Scale(XSEC[i]/hpu->GetEntries()); 
    cout<<SAMPLE[i]<<" "<<hpu->GetEntries()<<" "<<h0[i]->GetEntries()<<" "<<h1[i]->GetEntries()<<" "<<h2[i]->GetEntries()<<endl;
  }

  TH1F *hQCD0 = (TH1F*)h0[0]->Clone("hQCD0");
  TH1F *hQCD1 = (TH1F*)h1[0]->Clone("hQCD1");
  TH1F *hQCD2 = (TH1F*)h2[0]->Clone("hQCD2");

  for(int i=1;i<N;i++) {
    hQCD0->Add(h0[1]);
    hQCD1->Add(h1[1]);
    hQCD2->Add(h2[1]);
  }  
   
  hQCD0->SetFillColor(kGray);
  hQCD1->SetLineColor(kBlack);
  hQCD1->SetMarkerColor(kBlack);
  hQCD1->SetMarkerStyle(21);
  hQCD2->SetLineColor(kRed);
  hQCD2->SetMarkerColor(kRed);
  hQCD2->SetMarkerStyle(20);

  hQCD0->Scale(1./hQCD0->Integral());
  hQCD1->Scale(1./hQCD1->Integral());
  hQCD2->Scale(1./hQCD2->Integral());

  hQCD0->GetXaxis()->SetLabelSize(0.0);
  double max = 1.1*TMath::Max(hQCD0->GetBinContent(hQCD0->GetMaximumBin()),hQCD2->GetBinContent(hQCD2->GetMaximumBin()));
  hQCD0->SetMinimum(1e-5);
  hQCD0->SetMaximum(max);
  hQCD0->Draw("hist");
  hQCD1->Draw("sameE");
  hQCD2->Draw("sameE");
  gPad->RedrawAxis();

  TLegend *leg = new TLegend(0.86,0.65,0.99,0.9);
  leg->SetFillColor(0);
  leg->SetTextFont(42);
  leg->SetTextSize(0.03);
  leg->AddEntry(hQCD0,"Zero btag","F");
  leg->AddEntry(hQCD1,"One btag","LP");
  leg->AddEntry(hQCD2,"Two btag","LP");
  leg->Draw();

  TH1F *hRatio0 = (TH1F*)hQCD2->Clone("Ratio0");
  hRatio0->Divide(hQCD0);
  TH1F *hRatio1 = (TH1F*)hQCD2->Clone("Ratio1");
  hRatio1->Divide(hQCD1);

  hRatio0->SetLineColor(kBlack);
  hRatio0->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();
  hRatio0->GetXaxis()->SetTitle(XTITLE);
  hRatio0->GetYaxis()->SetNdivisions(505);
  hRatio0->GetYaxis()->SetRangeUser(0,2);
  hRatio0->GetYaxis()->SetLabelSize(0.04);
  hRatio0->Draw();
  hRatio1->Draw("same");
}
Esempio n. 11
0
void ptBestFit(float BIN_SIZE=5.0,bool BLIND=false,TString MASS,TString NAME)
{
  gROOT->ProcessLine(".x ../../common/styleCMSTDR.C");
  gSystem->Load("libHiggsAnalysisCombinedLimit.so");
  gROOT->ForceStyle();
  gStyle->SetOptStat(0);
  gStyle->SetOptTitle(0);
  gROOT->SetBatch(1);
  gStyle->SetPadRightMargin(0.04);
  gStyle->SetPadLeftMargin(0.16);
  gStyle->SetPadTopMargin(0.06);
  gStyle->SetPadBottomMargin(0.10);
  gStyle->SetTitleFont(42,"XY");
  gStyle->SetTitleSize(0.0475,"XY");
  gStyle->SetTitleOffset(0.9,"X");
  gStyle->SetTitleOffset(1.5,"Y");
  gStyle->SetLabelSize(0.0375,"XY");

  RooMsgService::instance().setSilentMode(kTRUE);
  for(int i=0;i<2;i++) {
    RooMsgService::instance().setStreamStatus(i,kFALSE);
  }
  float XMIN = 80;
  float XMAX = 200; 

  TFile *f1 = TFile::Open("datacards/datacard_m"+MASS+"_"+NAME+".root");
  TFile *f2 = TFile::Open("combine/mlfit.vbfHbb_"+NAME+"_mH"+MASS+".root");
  TFile *f3 = TFile::Open("root/sig_shapes_workspace_B80-200.root");
  TFile *f4 = TFile::Open("root/data_shapes_workspace_"+NAME+".root");

  RooWorkspace *w = (RooWorkspace*)f1->Get("w");
  //w->Print();
  RooAbsPdf *bkg_model = (RooAbsPdf*)w->pdf("model_s");
  RooFitResult *res_s  = (RooFitResult*)f2->Get("fit_s"); 
  RooFitResult *res_b  = (RooFitResult*)f2->Get("fit_b");
  RooRealVar *rFit     = dynamic_cast<RooRealVar *>(res_s->floatParsFinal()).find("r");
  RooDataSet *data     = (RooDataSet*)w->data("data_obs");
  
  int nparS=0,nparB=0;
  cout << res_s->floatParsFinal().getSize() << endl;
  cout << res_b->floatParsFinal().getSize() << endl;
  nparS = res_s->floatParsFinal().getSize();
  nparB = res_b->floatParsFinal().getSize();  
  float chi2sumS = 0.;
  float chi2sumB = 0.;
  int nparsum = 0;
//  if (BLIND) {
//    res_b->Print();
//  }
//  else {
//    res_s->Print();
//  }
  
  w->allVars().assignValueOnly(res_s->floatParsFinal());
//  w->Print();
//  w->allVars()->Print();

  RooWorkspace *wSig = (RooWorkspace*)f3->Get("w"); 
  RooWorkspace *wDat = (RooWorkspace*)f4->Get("w"); 

  const RooSimultaneous *sim = dynamic_cast<const RooSimultaneous *> (bkg_model);
  const RooAbsCategoryLValue &cat = (RooAbsCategoryLValue &) sim->indexCat();
  TList *datasets = data->split(cat,true);
  TIter next(datasets);
  //int count = 0; 
  for(RooAbsData *ds = (RooAbsData*)next();ds != 0; ds = (RooAbsData*)next()) {
	 //if (count > 0) return 0;
	 //count++;
    RooAbsPdf *pdfi = sim->getPdf(ds->GetName());
    RooArgSet *obs = (RooArgSet*)pdfi->getObservables(ds);
    RooRealVar *x = dynamic_cast<RooRealVar *>(obs->first());

    RooRealVar *yield_vbf = (RooRealVar*)wSig->var("yield_signalVBF_mass"+MASS+"_"+TString(ds->GetName()));
    RooRealVar *yield_gf  = (RooRealVar*)wSig->var("yield_signalGF_mass"+MASS+"_"+TString(ds->GetName()));
    TString ds_name(ds->GetName());
    //----- get the QCD normalization -----------
    RooRealVar *qcd_norm_final = dynamic_cast<RooRealVar *>(res_s->floatParsFinal()).find("CMS_vbfbb_qcd_norm_"+ds_name);
    RooRealVar *qcd_yield      = (RooRealVar*)wDat->var("yield_data_"+ds_name);

    float Nqcd  = exp(log(1.5)*qcd_norm_final->getVal())*qcd_yield->getVal();
    float eNqcd = log(1.5)*qcd_norm_final->getError()*Nqcd;
    cout<<"QCD normalization = "<<Nqcd<<" +/- "<<eNqcd<<endl;
    
    TH1 *hCoarse = (TH1*)ds->createHistogram("coarseHisto_"+ds_name,*x);
    float norm = hCoarse->Integral();
  
	 int rebin = BIN_SIZE/hCoarse->GetBinWidth(1);
    hCoarse->Rebin(rebin);

    float MIN_VAL = TMath::Max(0.9*hCoarse->GetBinContent(hCoarse->GetMinimumBin()),1.0);
    float MAX_VAL = 1.3*hCoarse->GetBinContent(hCoarse->GetMaximumBin());
    RooDataHist ds_coarse("ds_coarse_"+ds_name,"ds_coarse_"+ds_name,*x,hCoarse);

    TH1F *hBlind = (TH1F*)hCoarse->Clone("blindHisto_"+ds_name);
    for(int i=0;i<hBlind->GetNbinsX();i++) {
      double x0 = hBlind->GetBinCenter(i+1);
      if (x0 > 100 && x0 < 150) {
        hBlind->SetBinContent(i+1,0);
        hBlind->SetBinError(i+1,0);
      }
    }
    
    RooDataHist ds_blind("ds_blind_"+ds_name,"ds_blind_"+ds_name,*x,hBlind); 
    
    RooHist *hresid,*hresid0;
    RooPlot *frame1 = x->frame();
    RooPlot *frame2 = x->frame();
    
    if (BLIND) {
		//cout << "Blind case: " << ds_coarse.GetName() << endl;
      ds_coarse.plotOn(frame1,LineColor(0),MarkerColor(0));
      pdfi->plotOn(frame1,Components("shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name),VisualizeError(*res_s,1,kTRUE),FillColor(0),MoveToBack());
      pdfi->plotOn(frame1,Components("shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name),LineWidth(2),LineStyle(3));
      ds_blind.plotOn(frame1);
      hresid = frame1->residHist();
      frame2->addPlotable(hresid,"pE1");
    }
    else {    
		//cout << "Non-blind case: " << ds_coarse.GetName() << endl;
		ds_coarse.plotOn(frame1);
      pdfi->plotOn(frame1);
		//cout << pdfi->getParameters(ds_coarse)->selectByAttrib("Constant",kFALSE)->getSize() << endl;
      cout<<"chi2/ndof (bkg+sig) = "<<frame1->chiSquare()<<endl;
		cout << ds_coarse.numEntries() << endl;
		chi2sumS += frame1->chiSquare()*ds_coarse.numEntries();
		nparsum += ds_coarse.numEntries();
		//hresid0 = frame1->residHist();
      //pdfi->plotOn(frame1,VisualizeError(*res_s,1,kTRUE),FillColor(0),MoveToBack());
      pdfi->plotOn(frame1,Components("shapeBkg_qcd_"+ds_name),LineWidth(2),LineStyle(5),LineColor(kGreen+2));
      pdfi->plotOn(frame1,Components("shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name),LineWidth(2),LineStyle(2),LineColor(kBlack)); 
      cout<<"chi2/ndof (bkg) = "<<frame1->chiSquare()<<endl;
		chi2sumB += frame1->chiSquare()*ds_coarse.numEntries();
		pdfi->plotOn(frame1,Components("shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name),LineWidth(2),LineStyle(2),LineColor(kBlack),VisualizeError(*res_s,1,kTRUE),FillColor(0),MoveToBack()); 
      hresid = frame1->residHist();
      frame2->addPlotable(hresid,"pE1");
    
      float yield_sig = rFit->getValV()*(yield_vbf->getValV()+yield_gf->getValV());
      RooAbsPdf *signal_pdf = (RooAbsPdf*)w->pdf("shapeSig_qqH_"+ds_name);
      signal_pdf->plotOn(frame2,LineWidth(2),LineColor(kRed),Normalization(yield_sig,RooAbsReal::NumEvent),MoveToBack());
    }
//	 hresid0->Print();
//	 hresid->Print();
//	 double x2,y2;
//	 for (int i=0; i<3; ++i) {
//		 hresid0->GetPoint(i,x2,y2);
//		 cout << "BKG+SIG\t" << x2 << "\t" << y2 << endl;
//		 hresid->GetPoint(i,x2,y2);
//		 cout << "BKG\t" << x2 << "\t" << y2 << endl;
//		 ds_coarse.get(i);
//		 cout << ds_coarse.weightError(RooAbsData::SumW2) << endl;
//		 cout << endl;
//	 }

    TCanvas* canFit = new TCanvas("Higgs_fit_"+ds_name,"Higgs_fit_"+ds_name,900,750);
    canFit->cd(1)->SetBottomMargin(0.4);
    frame1->SetMinimum(MIN_VAL);
    frame1->SetMaximum(MAX_VAL);
    frame1->GetYaxis()->SetNdivisions(510);
    frame1->GetXaxis()->SetTitleSize(0);
    frame1->GetXaxis()->SetLabelSize(0);
    frame1->GetYaxis()->SetTitle(TString::Format("Events / %1.1f GeV",BIN_SIZE));
    frame1->Draw();
    gPad->Update();
    
    TList *list = (TList*)gPad->GetListOfPrimitives();
    //list->Print();
    TH1F *hUncH  = new TH1F("hUncH"+ds_name,"hUncH"+ds_name,(XMAX-XMIN)/BIN_SIZE,XMIN,XMAX);
    TH1F *hUncL  = new TH1F("hUncL"+ds_name,"hUncL"+ds_name,(XMAX-XMIN)/BIN_SIZE,XMIN,XMAX);
    TH1F *hUnc2H = new TH1F("hUnc2H"+ds_name,"hUnc2H"+ds_name,(XMAX-XMIN)/BIN_SIZE,XMIN,XMAX);
    TH1F *hUnc2L = new TH1F("hUnc2L"+ds_name,"hUnc2L"+ds_name,(XMAX-XMIN)/BIN_SIZE,XMIN,XMAX); 
    TH1F *hUncC  = new TH1F("hUncC"+ds_name,"hUncC"+ds_name,(XMAX-XMIN)/BIN_SIZE,XMIN,XMAX); 
    
    RooCurve *errorBand,*gFit,*gQCDFit,*gBkgFit;
    
	//list->Print();
    if (BLIND) {
      errorBand = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]_errorband_Comp[shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name+"]");
      gFit = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]"+"_Comp[shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name+"]");
    }
    else {
      //errorBand = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]_errorband");
      errorBand = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]_errorband_Comp[shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name+"]");
      gFit = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]");
    } 
    gQCDFit = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]"+"_Comp[shapeBkg_qcd_"+ds_name+"]");  
    gBkgFit = (RooCurve*)list->FindObject("pdf_bin"+ds_name+"_Norm[mbbReg_"+ds_name+"]"+"_Comp[shapeBkg_qcd_"+ds_name+",shapeBkg_top_"+ds_name+",shapeBkg_zjets_"+ds_name+"]");
    for(int i=0;i<hUncH->GetNbinsX();i++) {
      double x0 = hUncH->GetBinCenter(i+1);
      double e1 = fabs(errorBand->Eval(x0)-gBkgFit->Eval(x0));
      //double e1 = fabs(errorBand->Eval(x0)-gFit->Eval(x0));
      double e2 = eNqcd/hUncH->GetNbinsX();
      hUncH->SetBinContent(i+1,sqrt(pow(e2,2)+pow(e1,2)));
      hUnc2H->SetBinContent(i+1,2*sqrt(pow(e2,2)+pow(e1,2)));
      hUncL->SetBinContent(i+1,-sqrt(pow(e2,2)+pow(e1,2)));
      hUnc2L->SetBinContent(i+1,-2*sqrt(pow(e2,2)+pow(e1,2)));
		hUncC->SetBinContent(i+1,0.);
    }
   
    TPad* pad = new TPad("pad", "pad", 0., 0., 1., 1.);
    pad->SetTopMargin(0.63);
    pad->SetFillColor(0);
    pad->SetFillStyle(0);
    pad->Draw();
    pad->cd(0);
    hUnc2H->GetXaxis()->SetTitle("m_{bb} (GeV)");
    hUnc2H->GetYaxis()->SetTitle("Data - Bkg");
    //hUnc2H->GetYaxis()->SetTitle("Data - Fit");
    double YMAX = 1.1*frame2->GetMaximum();
    double YMIN = -1.1*frame2->GetMaximum();
    hUnc2H->GetYaxis()->SetRangeUser(YMIN,YMAX);
    hUnc2H->GetYaxis()->SetNdivisions(507);
//    hUnc2H->GetXaxis()->SetTitleOffset(0.9);
//    hUnc2H->GetYaxis()->SetTitleOffset(1.0);
    hUnc2H->GetYaxis()->SetTickLength(0.0);
//    hUnc2H->GetYaxis()->SetTitleSize(0.05);
//    hUnc2H->GetYaxis()->SetLabelSize(0.04);
    hUnc2H->GetYaxis()->CenterTitle(kTRUE);
    hUnc2H->SetFillColor(kGreen);
    hUnc2L->SetFillColor(kGreen);
    hUncH->SetFillColor(kYellow);
    hUncL->SetFillColor(kYellow);
	 hUncC->SetLineColor(kBlack);
	 hUncC->SetLineStyle(7);
    hUnc2H->Draw("HIST");
    hUnc2L->Draw("same HIST");
    hUncH->Draw("same HIST");
    hUncL->Draw("same HIST");
	 hUncC->Draw("same HIST");
	 frame2->GetYaxis()->SetTickLength(0.03/0.4);
    frame2->Draw("same");

    TList *list1 = (TList*)gPad->GetListOfPrimitives();
    //list1->Print();
    RooCurve *gSigFit = (RooCurve*)list1->FindObject("shapeSig_qqH_"+ds_name+"_Norm[mbbReg_"+ds_name+"]");

    TLegend *leg = new TLegend(0.70,0.61,0.94,1.-gStyle->GetPadTopMargin()-0.01);
	 leg->SetTextFont(42);
	 leg->SetFillStyle(-1);
	 //leg->SetHeader(ds_name+" (m_{H}="+MASS+")");
    leg->SetHeader(TString::Format("Category %d",atoi(ds_name(3,1).Data())+1));
    leg->AddEntry(hBlind,"Data","P");
    if (!BLIND) {
      leg->AddEntry(gSigFit,"Fitted signal","L");
    }
	 TLine *gEmpty = new TLine(0.0,0.0,0.0,0.0);
	 gEmpty->SetLineWidth(0);
	 TLegendEntry *l1 = leg->AddEntry(gEmpty,"(m_{H} = "+MASS+" GeV)","");
	 l1->SetTextSize(0.038*0.97*0.85);
    leg->AddEntry(gFit,"Bkg. + signal","L");
    leg->AddEntry(gBkgFit,"Bkg.","L");
    leg->AddEntry(gQCDFit,"QCD","L");
    leg->AddEntry(hUnc2H,"2#sigma bkg. unc.","F");
    leg->AddEntry(hUncH,"1#sigma bkg. unc.","F");
    leg->SetFillColor(0);
    leg->SetBorderSize(0);
    leg->SetTextFont(42);
    leg->SetTextSize(0.038*0.98);
    leg->Draw(); 
	 leg->SetY1(leg->GetY2()-leg->GetNRows()*0.045*0.96);
     
    TPaveText *paveCMS = new TPaveText(gStyle->GetPadLeftMargin()+0.02,0.7,gStyle->GetPadLeftMargin()+0.15,1.-gStyle->GetPadTopMargin()-0.01,"NDC");
	 paveCMS->SetTextFont(62);
	 paveCMS->SetTextSize(gStyle->GetPadTopMargin()*3./4.);
	 paveCMS->SetBorderSize(0);
	 paveCMS->SetFillStyle(-1);
	 paveCMS->SetTextAlign(12);
	 paveCMS->AddText("CMS");
	 paveCMS->Draw();
	 gPad->Update();
	 paveCMS->SetY1NDC(paveCMS->GetY2NDC()-paveCMS->GetListOfLines()->GetSize()*gStyle->GetPadTopMargin());

	 TPaveText *paveLumi = new TPaveText(0.5,1.-gStyle->GetPadTopMargin(),0.98,1.00,"NDC");
	 paveLumi->SetTextFont(42);
	 paveLumi->SetTextSize(gStyle->GetPadTopMargin()*3./4.);
	 paveLumi->SetBorderSize(0);
	 paveLumi->SetFillStyle(-1);
	 paveLumi->SetTextAlign(32);
	 paveLumi->AddText(TString::Format("%.1f fb^{-1} (8TeV)",(atoi(ds_name(3,1).Data())<4 ? 19.8 : 18.3)).Data());//+ 18.2 ;
	 paveLumi->Draw();

	 TString path=".";
	 //TString path="BiasV10_limit_BRN5p4_dX0p1_B80-200_CAT0-6/output/";
	 system(TString::Format("[ ! -d %s/plot ] && mkdir %s/plot",path.Data(),path.Data()).Data());
	 system(TString::Format("[ ! -d %s/plot/fits ] && mkdir %s/plot/fits",path.Data(),path.Data()).Data());
	 canFit->SaveAs(TString::Format("%s/plot/fits/Fit_mH%s_%s.pdf",path.Data(),MASS.Data(),ds_name.Data()).Data());
	 canFit->SaveAs(TString::Format("%s/plot/fits/Fit_mH%s_%s.png",path.Data(),MASS.Data(),ds_name.Data()).Data());
	 canFit->SaveAs(TString::Format("%s/plot/fits/Fit_mH%s_%s.eps",path.Data(),MASS.Data(),ds_name.Data()).Data());
	 TText *l = (TText*)paveCMS->AddText("Preliminary");
	 l->SetTextFont(52);
	 paveCMS->Draw();
	 gPad->Update();
	 paveCMS->SetY1NDC(paveCMS->GetY2NDC()-paveCMS->GetListOfLines()->GetSize()*gStyle->GetPadTopMargin());
	 canFit->SaveAs(TString::Format("%s/plot/fits/Fit_mH%s_%s_prelim.pdf",path.Data(),MASS.Data(),ds_name.Data()).Data());
	 canFit->SaveAs(TString::Format("%s/plot/fits/Fit_mH%s_%s_prelim.png",path.Data(),MASS.Data(),ds_name.Data()).Data());
	 canFit->SaveAs(TString::Format("%s/plot/fits/Fit_mH%s_%s_prelim.eps",path.Data(),MASS.Data(),ds_name.Data()).Data());

    delete ds;
  }

  cout << "chi2sumS: " << chi2sumS << endl;
  cout << "chi2sumB: " << chi2sumB << endl;
  cout << "nparS: " << nparS << endl;
  cout << "nparB: " << nparB << endl;
  cout << "nbinsum: " << nparsum << endl;
  cout << "chi2sumS/(nbinsum - nparS): " << chi2sumS / (float)(nparsum - nparS) << endl;
  cout << "chi2sumB/(nbinsum - nparB): " << chi2sumB / (float)(nparsum - nparB) << endl;
  delete datasets; 
}
Esempio n. 12
0
void plotComparison( TH1F* h_dt , TH1F* h_mc , TH1F *h_extra, char* label, bool dolog, bool drawbkg) {

  TPad* fullpad = new TPad();
  TPad* plotpad = new TPad();
  TPad* respad  = new TPad();
  fullpad = new TPad("fullpad","fullpad",0,0,1,1);
  fullpad->Draw();
  fullpad->cd();
  plotpad = new TPad("plotpad","plotpad",0,0,1,0.8);
  plotpad->Draw();
  plotpad->cd();
  if (dolog) plotpad->SetLogy();

  h_dt->GetYaxis()->SetTitle("Entries");
  h_dt->GetXaxis()->SetTitle(Form("%s", label));
  h_dt->GetYaxis()->SetTitleSize(0.05);
  h_dt->GetXaxis()->SetTitleSize(0.05);
  h_dt->GetYaxis()->SetTitleOffset(1.5);
  h_dt->GetXaxis()->SetTitleOffset(1.3);
  if (!dolog) h_dt->GetYaxis()->SetRangeUser(0., 1.4*h_dt->GetMaximum());
  h_dt->SetLineColor(kBlack);
  h_dt->SetMarkerColor(kBlack);
  h_mc->SetLineColor(kBlue);
  h_mc->SetMarkerColor(kBlue);
  h_extra->SetLineColor(kRed);
  h_extra->SetLineWidth(2);
  h_mc->SetLineWidth(2);
  h_dt->Draw();
  h_mc->Draw("HISTSAME");
  if (drawbkg) h_extra->Draw("HISTSAME");
  h_dt->Draw("ESAME");

  TLegend *legComp = new TLegend( 0.653, 0.663, 0.944, 0.870);
  legComp->AddEntry(h_dt, "Data", "lp");
  legComp->AddEntry(h_mc, "MC", "l");
  if (drawbkg) legComp->AddEntry(h_extra, "MC Bkg", "l");
  legComp->SetFillColor(0);
  legComp->SetBorderSize(0);
  legComp->Draw();
  
  TLatex *text = new TLatex();
  text->SetNDC();
  text->SetTextSize(0.04);
  //  float xtex = 0.65;
  //  text->DrawLatex(xtex,0.88,"1 lepton + jets Sample");
  
  fullpad->cd();
  
  respad = new TPad("respad","respad",0,0.8,1,1);
  respad->Draw();
  respad->cd();
  
  //gPad->SetGridy();
  
  TH1F* ratio = (TH1F*) h_dt->Clone("ratio");
  ratio->Divide(h_mc);

  ratio->GetYaxis()->SetTitleOffset(0.3);
  ratio->GetYaxis()->SetTitleSize(0.2);
  ratio->GetYaxis()->SetNdivisions(5);
  ratio->GetYaxis()->SetLabelSize(0.2);
  if (dolog) ratio->GetYaxis()->SetRangeUser(0.5,1.5);
  else ratio->GetYaxis()->SetRangeUser(0.7,1.3);
  ratio->GetYaxis()->SetTitle("Ratio    ");
  ratio->GetXaxis()->SetLabelSize(0);
  ratio->GetXaxis()->SetTitleSize(0);
  ratio->SetMarkerSize(1);
  ratio->SetLineWidth(2);
  ratio->SetLineColor(kBlue);
  ratio->SetMarkerColor(kBlue);
  ratio->SetFillColor(kBlue);
  ratio->SetFillStyle(3002);
  ratio->Draw("E2");
  
  TLine line;
  line.SetLineWidth(2);
  line.DrawLine(h_dt->GetXaxis()->GetXmin(),1,h_dt->GetXaxis()->GetXmax(),1);

}
Esempio n. 13
0
void Dist()
{
  TH1::AddDirectory(kFALSE);
  gStyle->SetOptStat(0);
  gStyle->SetOptTitle(0);
  gStyle->SetFrameLineWidth(1);
  
  TCanvas *c1 = new TCanvas("c1","multipads",700,500);
  gPad->SetLeftMargin(0.15);
  
  TLegend* leg = new TLegend(0.35, 0.12, 0.7, 0.22);
  leg-> SetNColumns(2);
  leg->SetHeader("After Sub.:");

  TFile f("../../data/Sample/Distance/P12e_1.5MeV/H5m/Near.root");
  TH1F* Near = (TH1F*)f.Get("h1dDistAccSum");
  Near->GetYaxis()->SetRangeUser(-3000,12000);
  Near->SetLineColor(4);
  Near->GetYaxis()->SetTitleOffset(1.5);
  //Near->Rebin(5);
  Near->DrawCopy();
  leg->AddEntry( Near, "Near site", "lep" );

  TFile f("../../data/Sample/Distance/P12e_1.5MeV/H5m/EH3.root");
  TH1F* Far = (TH1F*)f.Get("h1dDistAccSum");
  Far->SetLineColor(2);
  Far->GetYaxis()->SetTitleOffset(1.5);
  //Far->Rebin(5);
  Far->DrawCopy("same");
  leg->AddEntry( Far, "Far site", "lep" );

  leg->SetFillColor(0);
  leg->Draw();
  TLine line;
  line.SetLineStyle(2);
  line.DrawLine(0,0,5000,0);

  //h1dDistAccSum->Fit("pol0","","",2000,5000);
  {
    TFile f("../../data/Sample/Distance/P12e_1.5MeV/H5m/Near.root");

    TLegend* leg = new TLegend(0.51, 0.22, 0.80, 0.53);

    TPad* pad = new TPad("name","Title",0.3,0.3,0.935,0.935);
    pad->SetTopMargin(0.05);
    pad->SetBottomMargin(0.2);
    pad->SetLeftMargin(0.2);
    pad->SetRightMargin(0.05);
    pad->Draw();
    pad->cd();
    
    h1dDistVtxSum->SetLineColor(4);
    h1dDistVtxSum->GetYaxis()->SetTitleOffset(1.6);
    h1dDistVtxSum->GetYaxis()->SetLabelSize(0.06);
    h1dDistVtxSum->GetYaxis()->SetTitleSize(0.06);
    h1dDistVtxSum->GetYaxis()->SetNdivisions(405);
    
    h1dDistVtxSum->GetXaxis()->SetNdivisions(405);
    h1dDistVtxSum->GetXaxis()->SetLabelSize(0.06);
    h1dDistVtxSum->GetXaxis()->SetTitleSize(0.06);

    h1dDistVtxSum->DrawCopy();
    h1dDistBkgSum->SetLineColor(1);
    h1dDistBkgSum->DrawCopy("same");
    
    TLine line;
    line.SetLineStyle(2);
    line.DrawLine(2000,0,2000,22250);

    leg->SetHeader("Near site:");
    leg->AddEntry( h1dDistVtxSum, "Before Sub.", "lep" );
    leg->AddEntry( h1dDistBkgSum, "Accidental", "lep" );
    leg->SetFillColor(0);
    leg->Draw();
      
    /*
      label->AddText("Subtraction");
      label->AddText("Validation");
      label->SetFillColor(0);
      label->SetShadowColor(0);
      label->SetBorderSize(1);
      label->Draw();
    */
  }
}
Esempio n. 14
0
void quarks () {
   TCanvas *c1 = new TCanvas("c1", "c1",10,10,630,760);
   c1->SetFillColor(kBlack);
   Int_t quarkColor  = 50;
   Int_t leptonColor = 16;
   Int_t forceColor  = 38;
   Int_t titleColor  = kYellow;
   Int_t border = 8;

   TLatex *texf = new TLatex(0.90,0.455,"Force Carriers");
   texf->SetTextColor(forceColor);
   texf->SetTextAlign(22); texf->SetTextSize(0.07);
   texf->SetTextAngle(90);
   texf->Draw();

   TLatex *texl = new TLatex(0.11,0.288,"Leptons");
   texl->SetTextColor(leptonColor);
   texl->SetTextAlign(22); texl->SetTextSize(0.07);
   texl->SetTextAngle(90);
   texl->Draw();

   TLatex *texq = new TLatex(0.11,0.624,"Quarks");
   texq->SetTextColor(quarkColor);
   texq->SetTextAlign(22); texq->SetTextSize(0.07);
   texq->SetTextAngle(90);
   texq->Draw();

   TLatex tex(0.5,0.5,"u");
   tex.SetTextColor(titleColor); tex.SetTextFont(32);
   tex.SetTextAlign(22);
   tex.SetTextSize(0.14);
   tex.DrawLatex(0.5,0.93,"Elementary");
   tex.SetTextSize(0.12);
   tex.DrawLatex(0.5,0.84,"Particles");
   tex.SetTextSize(0.05);
   tex.DrawLatex(0.5,0.067,"Three Generations of Matter");

   tex.SetTextColor(kBlack); tex.SetTextSize(0.8);

// ------------>Create main pad and its subdivisions
   TPad *pad = new TPad("pad", "pad",0.15,0.11,0.85,0.79);
   pad->Draw();
   pad->cd();
   pad->Divide(4,4,0.0003,0.0003);

   pad->cd(1); gPad->SetFillColor(quarkColor);
   gPad->SetBorderSize(border);
   tex.DrawLatex(.5,.5,"u");

   pad->cd(2); gPad->SetFillColor(quarkColor);
   gPad->SetBorderSize(border);
   tex.DrawLatex(.5,.5,"c");

   pad->cd(3); gPad->SetFillColor(quarkColor);
   gPad->SetBorderSize(border);
   tex.DrawLatex(.5,.5,"t");

   pad->cd(4); gPad->SetFillColor(forceColor);
   gPad->SetBorderSize(border);
   tex.DrawLatex(.5,.55,"#gamma");

   pad->cd(5); gPad->SetFillColor(quarkColor);
   gPad->SetBorderSize(border);
   tex.DrawLatex(.5,.5,"d");

   pad->cd(6); gPad->SetFillColor(quarkColor);
   gPad->SetBorderSize(border);
   tex.DrawLatex(.5,.5,"s");

   pad->cd(7); gPad->SetFillColor(quarkColor);
   gPad->SetBorderSize(border);
   tex.DrawLatex(.5,.5,"b");

   pad->cd(8); gPad->SetFillColor(forceColor);
   gPad->SetBorderSize(border);
   tex.DrawLatex(.5,.55,"g");

   pad->cd(9); gPad->SetFillColor(leptonColor);
   gPad->SetBorderSize(border);
   tex.DrawLatex(.5,.5,"#nu_{e}");

   pad->cd(10); gPad->SetFillColor(leptonColor);
   gPad->SetBorderSize(border);
   tex.DrawLatex(.5,.5,"#nu_{#mu}");

   pad->cd(11); gPad->SetFillColor(leptonColor);
   gPad->SetBorderSize(border);
   tex.DrawLatex(.5,.5,"#nu_{#tau}");

   pad->cd(12); gPad->SetFillColor(forceColor);
   gPad->SetBorderSize(border);
   tex.DrawLatex(.5,.5,"Z");

   pad->cd(13); gPad->SetFillColor(leptonColor);
   gPad->SetBorderSize(border);
   tex.DrawLatex(.5,.5,"e");

   pad->cd(14); gPad->SetFillColor(leptonColor);
   gPad->SetBorderSize(border);
   tex.DrawLatex(.5,.56,"#mu");

   pad->cd(15); gPad->SetFillColor(leptonColor);
   gPad->SetBorderSize(border);
   tex.DrawLatex(.5,.5,"#tau");

   pad->cd(16); gPad->SetFillColor(forceColor);
   gPad->SetBorderSize(border);
   tex.DrawLatex(.5,.5,"W");

   c1->cd();
}
void makePlot(TH1* histogram_data, bool doKeepBlinded,
	      TH1* histogram_ttH, 
	      TH1* histogram_ttZ,
	      TH1* histogram_ttW,
	      TH1* histogram_EWK,
	      TH1* histogram_Rares,
	      TH1* histogram_fakes,
	      TH1* histogramSum_mc,
	      TH1* histogramErr_mc,		
	      const std::string& xAxisTitle, 
	      const std::string& yAxisTitle, double yMin, double yMax,
	      bool showLegend,
	      const std::string& label,
	      const std::string& outputFileName,
	      bool useLogScale)
{
  TH1* histogram_data_density = 0;
  if ( histogram_data ) {
    histogram_data_density = divideHistogramByBinWidth(histogram_data);      
  }
  histogram_data_density->SetMarkerColor(1);
  histogram_data_density->SetMarkerStyle(20);
  histogram_data_density->SetMarkerSize(2);
  histogram_data_density->SetLineColor(1);
  histogram_data_density->SetLineWidth(1);
  histogram_data_density->SetLineStyle(1);

  TH1* histogram_ttH_density = 0;
  if ( histogram_ttH ) {
    if ( histogram_data ) checkCompatibleBinning(histogram_ttH, histogram_data);
    histogram_ttH_density = divideHistogramByBinWidth(histogram_ttH);
  }
  histogram_ttH_density->SetFillColor(628);
  histogram_ttH_density->SetLineColor(1);
  histogram_ttH_density->SetLineWidth(1);

  TH1* histogram_ttZ_density = 0;
  if ( histogram_ttZ ) {
    if ( histogram_data ) checkCompatibleBinning(histogram_ttZ, histogram_data);
    histogram_ttZ_density = divideHistogramByBinWidth(histogram_ttZ);
  }
  histogram_ttZ_density->SetFillColor(822);
  histogram_ttZ_density->SetLineColor(1);
  histogram_ttZ_density->SetLineWidth(1);

  TH1* histogram_ttW_density = 0;
  if ( histogram_ttW ) {
    if ( histogram_data ) checkCompatibleBinning(histogram_ttW, histogram_data);
    histogram_ttW_density = divideHistogramByBinWidth(histogram_ttW);
  }
  histogram_ttW_density->SetFillColor(823);
  histogram_ttW_density->SetLineColor(1);
  histogram_ttW_density->SetLineWidth(1);

  TH1* histogram_EWK_density = 0;
  if ( histogram_EWK ) {
    if ( histogram_data ) checkCompatibleBinning(histogram_EWK, histogram_data);
    histogram_EWK_density = divideHistogramByBinWidth(histogram_EWK);
  }
  histogram_EWK_density->SetFillColor(610);
  histogram_EWK_density->SetLineColor(1);
  histogram_EWK_density->SetLineWidth(1);

  TH1* histogram_Rares_density = 0;
  if ( histogram_Rares ) {
    if ( histogram_data ) checkCompatibleBinning(histogram_Rares, histogram_data);
    histogram_Rares_density = divideHistogramByBinWidth(histogram_Rares);
  }
  histogram_Rares_density->SetFillColor(851);
  histogram_Rares_density->SetLineColor(1);
  histogram_Rares_density->SetLineWidth(1);

  TH1* histogram_fakes_density = 0;
  if ( histogram_fakes ) {
    if ( histogram_data ) checkCompatibleBinning(histogram_fakes, histogram_data);
    histogram_fakes_density = divideHistogramByBinWidth(histogram_fakes);
  }
  histogram_fakes_density->SetFillColor(1);
  histogram_fakes_density->SetFillStyle(3005);
  histogram_fakes_density->SetLineColor(1);
  histogram_fakes_density->SetLineWidth(1);
  
  TH1* histogramSum_mc_density = 0;
  if ( histogramSum_mc ) {
    if ( histogram_data ) checkCompatibleBinning(histogramSum_mc, histogram_data);
    histogramSum_mc_density = divideHistogramByBinWidth(histogramSum_mc);
  }
  std::cout << "histogramSum_mc_density = " << histogramSum_mc_density << std::endl;
  dumpHistogram(histogramSum_mc_density);

  TH1* histogramErr_mc_density = 0;
  if ( histogramErr_mc ) {
    if ( histogram_data ) checkCompatibleBinning(histogramErr_mc, histogram_data);
    histogramErr_mc_density = divideHistogramByBinWidth(histogramErr_mc);
  }
  setStyle_uncertainty(histogramErr_mc_density);

  TCanvas* canvas = new TCanvas("canvas", "canvas", 950, 1100);
  canvas->SetFillColor(10);
  canvas->SetBorderSize(2);
  canvas->Draw();

  TPad* topPad = new TPad("topPad", "topPad", 0.00, 0.34, 1.00, 0.995);
  topPad->SetFillColor(10);
  topPad->SetTopMargin(0.065);
  topPad->SetLeftMargin(0.20);
  topPad->SetBottomMargin(0.00);
  topPad->SetRightMargin(0.04);
  topPad->SetLogy(useLogScale);
  
  TPad* bottomPad = new TPad("bottomPad", "bottomPad", 0.00, 0.01, 1.00, 0.335);
  bottomPad->SetFillColor(10);
  bottomPad->SetTopMargin(0.085);
  bottomPad->SetLeftMargin(0.20);
  bottomPad->SetBottomMargin(0.35);
  bottomPad->SetRightMargin(0.04);
  bottomPad->SetLogy(false);

  canvas->cd();
  topPad->Draw();
  topPad->cd();

  THStack* histogramStack_mc = new THStack();
  histogramStack_mc->Add(histogram_fakes_density);
  histogramStack_mc->Add(histogram_Rares_density);
  histogramStack_mc->Add(histogram_EWK_density);
  histogramStack_mc->Add(histogram_ttW_density);
  histogramStack_mc->Add(histogram_ttZ_density);
  histogramStack_mc->Add(histogram_ttH_density);

  TH1* histogram_ref = histogram_data_density;
  histogram_ref->SetTitle("");
  histogram_ref->SetStats(false);
  histogram_ref->SetMaximum(yMax);
  histogram_ref->SetMinimum(yMin);

  TAxis* xAxis_top = histogram_ref->GetXaxis();
  assert(xAxis_top);
  if ( xAxisTitle != "" ) xAxis_top->SetTitle(xAxisTitle.data());
  xAxis_top->SetTitleOffset(1.20);
  xAxis_top->SetLabelColor(10);
  xAxis_top->SetTitleColor(10);

  TAxis* yAxis_top = histogram_ref->GetYaxis();
  assert(yAxis_top);
  if ( yAxisTitle != "" ) yAxis_top->SetTitle(yAxisTitle.data());
  yAxis_top->SetTitleOffset(1.20);
  yAxis_top->SetTitleSize(0.080);
  yAxis_top->SetLabelSize(0.065);
  yAxis_top->SetTickLength(0.04);  

  histogram_ref->Draw("axis");

  // CV: calling THStack::Draw() causes segmentation violation ?!
  //histogramStack_mc->Draw("histsame");

  // CV: draw histograms without using THStack instead;
  //     note that order in which histograms need to be drawn needs to be reversed 
  //     compared to order in which histograms were added to THStack !!
  histogram_ttH_density->Add(histogram_ttZ_density);
  histogram_ttH_density->Add(histogram_ttW_density);
  histogram_ttH_density->Add(histogram_EWK_density);
  histogram_ttH_density->Add(histogram_Rares_density);
  histogram_ttH_density->Add(histogram_fakes_density);
  histogram_ttH_density->Draw("histsame");
  std::cout << "histogram_ttH_density = " << histogram_ttH_density << ":" << std::endl;
  dumpHistogram(histogram_ttH_density);

  histogram_ttZ_density->Add(histogram_ttW_density);
  histogram_ttZ_density->Add(histogram_EWK_density);
  histogram_ttZ_density->Add(histogram_Rares_density);
  histogram_ttZ_density->Add(histogram_fakes_density);
  histogram_ttZ_density->Draw("histsame");

  histogram_ttW_density->Add(histogram_EWK_density);
  histogram_ttW_density->Add(histogram_Rares_density);
  histogram_ttW_density->Add(histogram_fakes_density);
  histogram_ttW_density->Draw("histsame");

  histogram_EWK_density->Add(histogram_Rares_density);
  histogram_EWK_density->Add(histogram_fakes_density);
  histogram_EWK_density->Draw("histsame");

  histogram_Rares_density->Add(histogram_fakes_density);
  histogram_Rares_density->Draw("histsame");

  TH1* histogram_fakes_density_cloned = (TH1*)histogram_fakes_density->Clone();
  histogram_fakes_density_cloned->SetFillColor(10);
  histogram_fakes_density_cloned->SetFillStyle(1001);
  histogram_fakes_density_cloned->Draw("histsame");
  histogram_fakes_density->Draw("histsame");

  if ( histogramErr_mc_density ) {    
    histogramErr_mc_density->Draw("e2same");
  }
  
  if ( !doKeepBlinded ) {
    histogram_data_density->Draw("e1psame");
  }

  histogram_ref->Draw("axissame");

  double legend_y0 = 0.6950;
  if ( showLegend ) {
    TLegend* legend1 = new TLegend(0.2600, legend_y0, 0.5350, 0.9250, NULL, "brNDC");
    legend1->SetFillStyle(0);
    legend1->SetBorderSize(0);
    legend1->SetFillColor(10);
    legend1->SetTextSize(0.050);    
    TH1* histogram_data_forLegend = (TH1*)histogram_data_density->Clone();
    histogram_data_forLegend->SetMarkerSize(2);
    legend1->AddEntry(histogram_data_forLegend, "Observed", "p");
    legend1->AddEntry(histogram_ttH_density, "t#bar{t}H", "f");
    legend1->AddEntry(histogram_ttZ_density, "t#bar{t}Z", "f");
    legend1->AddEntry(histogram_ttW_density, "t#bar{t}W", "f");
    legend1->Draw();
    TLegend* legend2 = new TLegend(0.6600, legend_y0, 0.9350, 0.9250, NULL, "brNDC");
    legend2->SetFillStyle(0);
    legend2->SetBorderSize(0);
    legend2->SetFillColor(10);
        legend2->SetTextSize(0.050); 
    legend2->AddEntry(histogram_EWK_density, "Electroweak", "f");
    legend2->AddEntry(histogram_Rares_density, "Rares", "f");
    legend2->AddEntry(histogram_fakes_density, "Fakes", "f");    
    if ( histogramErr_mc ) legend2->AddEntry(histogramErr_mc_density, "Uncertainty", "f");
    legend2->Draw();
  }

  //addLabel_CMS_luminosity(0.2100, 0.9700, 0.6350);
  addLabel_CMS_preliminary(0.2100, 0.9700, 0.6350);

  TPaveText* label_category = 0;
  if ( showLegend ) label_category = new TPaveText(0.6600, legend_y0 - 0.0550, 0.9350, legend_y0, "NDC");
  else label_category = new TPaveText(0.2350, 0.8500, 0.5150, 0.9100, "NDC");
  label_category->SetTextAlign(13);
  label_category->AddText(label.data());
  label_category->SetTextSize(0.055);
  label_category->SetTextColor(1);
  label_category->SetFillStyle(0);
  label_category->SetBorderSize(0);
  label_category->Draw();

  canvas->cd();
  bottomPad->Draw();
  bottomPad->cd();
 
  TH1* histogramRatio = (TH1*)histogram_data_density->Clone("histogramRatio");
  if ( !histogramRatio->GetSumw2N() ) histogramRatio->Sumw2();
  histogramRatio->SetTitle("");
  histogramRatio->SetStats(false);
  histogramRatio->SetMinimum(-0.99);
  histogramRatio->SetMaximum(+0.99);
  histogramRatio->SetMarkerColor(histogram_data_density->GetMarkerColor());
  histogramRatio->SetMarkerStyle(histogram_data_density->GetMarkerStyle());
  histogramRatio->SetMarkerSize(histogram_data_density->GetMarkerSize());
  histogramRatio->SetLineColor(histogram_data_density->GetLineColor());

  TH1* histogramRatioUncertainty = (TH1*)histogram_data_density->Clone("histogramRatioUncertainty");
  if ( !histogramRatioUncertainty->GetSumw2N() ) histogramRatioUncertainty->Sumw2();
  histogramRatioUncertainty->SetMarkerColor(10);
  histogramRatioUncertainty->SetMarkerSize(0);
  setStyle_uncertainty(histogramRatioUncertainty);

  int numBins_bottom = histogramRatio->GetNbinsX();
  for ( int iBin = 1; iBin <= numBins_bottom; ++iBin ) {
    double binContent_data = histogram_data_density->GetBinContent(iBin);
    double binError_data = histogram_data_density->GetBinError(iBin);
    double binContent_mc = 0;
    double binError_mc = 0;
    if ( histogramSum_mc && histogramErr_mc ) {
      binContent_mc = histogramSum_mc_density->GetBinContent(iBin);
      binError_mc = histogramErr_mc_density->GetBinError(iBin);
    } else {
      TList* histograms = histogramStack_mc->GetHists();
      TIter nextHistogram(histograms);
      double binError2_mc = 0.;
      while ( TH1* histogram_density = dynamic_cast<TH1*>(nextHistogram()) ) {
        binContent_mc += histogram_density->GetBinContent(iBin);
        binError2_mc += square(histogram_density->GetBinError(iBin));
      }
      binError_mc = TMath::Sqrt(binError2_mc);
    }
    if ( binContent_mc > 0. ) {
      histogramRatio->SetBinContent(iBin, binContent_data/binContent_mc - 1.0);
      histogramRatio->SetBinError(iBin, binError_data/binContent_mc);

      histogramRatioUncertainty->SetBinContent(iBin, 0.);
      histogramRatioUncertainty->SetBinError(iBin, binError_mc/binContent_mc);
    }
  }
  std::cout << "histogramRatio = " << histogramRatio << std::endl;
  dumpHistogram(histogramRatio);
  std::cout << "histogramRatioUncertainty = " << histogramRatioUncertainty << std::endl;
  dumpHistogram(histogramRatioUncertainty);

  TAxis* xAxis_bottom = histogramRatio->GetXaxis();
  assert(xAxis_bottom);
  xAxis_bottom->SetTitle(xAxis_top->GetTitle());
  xAxis_bottom->SetLabelColor(1);
  xAxis_bottom->SetTitleColor(1);
  xAxis_bottom->SetTitleOffset(1.05);
  xAxis_bottom->SetTitleSize(0.16);
  xAxis_bottom->SetTitleFont(xAxis_top->GetTitleFont());
  xAxis_bottom->SetLabelOffset(0.02);
  xAxis_bottom->SetLabelSize(0.12);
  xAxis_bottom->SetTickLength(0.065);
  xAxis_bottom->SetNdivisions(505);

  TAxis* yAxis_bottom = histogramRatio->GetYaxis();
  assert(yAxis_bottom);
  yAxis_bottom->SetTitle("#frac{Data - Expectation}{Expectation}");
  yAxis_bottom->SetLabelColor(1);
  yAxis_bottom->SetTitleColor(1);
  yAxis_bottom->SetTitleOffset(0.95);
  yAxis_bottom->SetTitleFont(yAxis_top->GetTitleFont());
  yAxis_bottom->SetNdivisions(505);
  yAxis_bottom->CenterTitle();
  yAxis_bottom->SetTitleSize(0.095);
  yAxis_bottom->SetLabelSize(0.110);
  yAxis_bottom->SetTickLength(0.04);  

  histogramRatio->Draw("axis");

  TF1* line = new TF1("line","0", xAxis_bottom->GetXmin(), xAxis_bottom->GetXmax());
  line->SetLineStyle(3);
  line->SetLineWidth(1.5);
  line->SetLineColor(kBlack);
  line->Draw("same");

  histogramRatioUncertainty->Draw("e2same"); 

  if ( !doKeepBlinded ) {
    histogramRatio->Draw("epsame");
  }

  histogramRatio->Draw("axissame");

  canvas->Update();

  size_t idx = outputFileName.find_last_of('.');
  std::string outputFileName_plot = std::string(outputFileName, 0, idx);
  if ( useLogScale ) outputFileName_plot.append("_log");
  else outputFileName_plot.append("_linear");
  canvas->Print(std::string(outputFileName_plot).append(".pdf").data());
  canvas->Print(std::string(outputFileName_plot).append(".root").data());

  //delete label_cms;
  delete topPad;
  delete label_category;
  delete histogramRatio;
  delete histogramRatioUncertainty;
  delete line;
  delete bottomPad;    
  delete canvas;
}
Esempio n. 16
0
void DrawQCDClosure(TString VAR,TString XTITLE)
{
  gROOT->ForceStyle();
  TString FileName[7] = {"QCD_HT200to300","QCD_HT300to500","QCD_HT500to700","QCD_HT700to1000","QCD_HT1000to1500","QCD_HT1500to2000","QCD_HT2000toInf"};
  float XSEC[7]       = {1.74e+6,3.67e+5,2.94e+4,6.524e+03,1.064e+03,121.5,2.542e+01};
  TFile *inf[7];
  TH1F  *h[7],*h1[7];

  TCanvas *can = new TCanvas("can_QCDClosure_"+VAR,"can_QCDClosure_"+VAR,900,600);
  can->cd(1);
  can->SetBottomMargin(0.3);
  can->SetRightMargin(0.15);

  for(int i=0;i<7;i++) {
    inf[i] = TFile::Open("Histo_"+FileName[i]+".root");
    TH1F *hTriggerPass = (TH1F*)inf[i]->Get("hadtopL/TriggerPass");
    h[i]   = (TH1F*)inf[i]->Get("hadtopL/h_"+VAR);
    h1[i]   = (TH1F*)inf[i]->Get("hadtop/h_"+VAR);
    h[i]->Sumw2();
    h1[i]->Sumw2();
    h[i]->Rebin(5);
    h1[i]->Rebin(5);
    h[i]->Scale(XSEC[i]/hTriggerPass->GetBinContent(1));
    h1[i]->Scale(XSEC[i]/hTriggerPass->GetBinContent(1));
    cout<<hTriggerPass->GetBinContent(1)<<endl;
  }

  TH1F *hQCD  = (TH1F*)h[0]->Clone("hQCD");
  TH1F *hQCD1 = (TH1F*)h1[0]->Clone("hQCD1");
  for(int i=0;i<7;i++) {
    hQCD->Add(h[i]);
    hQCD1->Add(h1[i]);
  } 
  hQCD->SetFillColor(kGray);

  hQCD->Scale(1./hQCD->Integral());
  hQCD1->Scale(1./hQCD1->Integral());
  hQCD->GetXaxis()->SetLabelSize(0.0);
  double max = 1.1*TMath::Max(hQCD->GetBinContent(hQCD->GetMaximumBin()),hQCD1->GetBinContent(hQCD1->GetMaximumBin()));
  hQCD->SetMinimum(1e-5);
  hQCD->SetMaximum(max);
  hQCD->Draw("hist");
  hQCD1->Draw("sameE");
  gPad->RedrawAxis();

  TLegend *leg = new TLegend(0.86,0.65,0.99,0.9);
  leg->SetFillColor(0);
  leg->SetTextFont(42);
  leg->SetTextSize(0.03);
  leg->AddEntry(hQCD,"Control","F");
  leg->AddEntry(hQCD1,"Signal","LP");
  leg->Draw();

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

  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->GetYaxis()->SetNdivisions(505);
  hRatio->GetYaxis()->SetRangeUser(0,2);
  hRatio->GetYaxis()->SetLabelSize(0.04);
  hRatio->Draw();
}
Esempio n. 17
0
void invmasscomb::Loop()
{
//   In a ROOT session, you can do:
//      Root > .L invmasscomb.C
//      Root > invmasscomb t
//      Root > t.GetEntry(12); // Fill t data members with entry number 12
//      Root > t.Show();       // Show values of entry 12
//      Root > t.Show(16);     // Read and show values of entry 16
//      Root > t.Loop();       // Loop on all entries
//

//     This is the loop skeleton where:
//    jentry is the global entry number in the chain
//    ientry is the entry number in the current Tree
//  Note that the argument to GetEntry must be:
//    jentry for TChain::GetEntry
//    ientry for TTree::GetEntry and TBranch::GetEntry
//
//       To read only selected branches, Insert statements like:
// METHOD1:
//    fChain->SetBranchStatus("*",0);  // disable all branches
//    fChain->SetBranchStatus("branchname",1);  // activate branchname
// METHOD2: replace line
//    fChain->GetEntry(jentry);       //read all branches
//by  b_branchname->GetEntry(ientry); //read only this branch
    if (fChain == 0) return;

    double maxE(10.);

    TH1D massPi0("massPi0","masspi0",100,0.,1.);
    TH1D massPi0_2("massPi0_2","masspi0_2",150,0.,.4);
    TH1D massPi0full("massPi0full","masspi0full",200,0.4,2.5);
    TH1D masseta("masseta","masseta",50,0.25,.75);
    TH1D massetafull("massetafull","massetafull",100,0.4,2.5);
    TH1D masseta3pi0("masseta3pi0","masseta",30,0.15,1.2);
    TH1D masseta3pi0full("masseta3pi0full","masseta",100,0.,3.);
    TH1D masspi01("masspi01","",50,0.,.4);
    TH1D masspi02("masspi02","",50,0.,.4);
    TH2D mp01mp02("mp01mp02","",50,0.,.4,50,0.,.4);
    TH1D distance("distance","distance",100,0.,50.);
    TH1D energypi0("energypi0","",50,0.,maxE*1.1);
    TH1D x("x","x",50,130.,140.);
    TH1D y("y","y",50,-20.,30.);
    TH1D z("z","z",50,50.,200.);
    TH2D yz("yz","yz",30,-30.,30.,30,0.,250.);
    TH2D yzeta("yzeta","yz",30,-30.,30.,30,0.,250.);
    TH2D yz3pi0("yz3pi0","yz",30,-30.,30.,30,0.,250.);
    TH1D phi("phi","phi",50,-.15,.15);
    TH1D eta("eta","eta",50,0.,1.4);

    TH2D massPi0vsE("massPi0vsE","masspi0 vs E",150,0.,.4,15,0.,maxE*1.1);
    TH2D massPi0vsE1("massPi0vsE1","masspi0 vs E",150,0.,.4,15,0.,maxE*1.);
    TH2D massPi0vsE2("massPi0vsE2","masspi0 vs E",150,0.,.4,15,0.,maxE*1.);
    TH2D massPi0vsECE("massPi0vsECE","masspi0 vs E",150,0.,.4,15,0.,maxE*1.1);
    TH2D massPi0vsEDF("massPi0vsEDF","masspi0 vs E",150,0.,.4,15,0.,maxE*1.1);
    TH2D massPi0vsE_2("massPi0vsE_2","masspi0 vs E",50,0.,1.,50,0.,maxE*1.1);
    TH2D massPi0vsdistance("massPi0vsdistance","masspi0 vs D",150,0.,.4,10,0.,70.);
    TH2D massPi0vsy("massPi0vsy","masspi0 vs y",150,0.,.4,20,-15.,25.);
    TH2D massPi0vsz("massPi0vsz","masspi0 vs z",150,0.,.4,20,80.,180.);

    TH2D xyA("xyA","xy A",100,-40.,40.,100,-40.,40.);
    TH2D xyB("xyB","xy B",100,-40.,40.,100,-40.,40.);

    TH1D Y1vsE("Y1vsE","yield1 vs E",15,0.,maxE*1.1);
    TH1D Y1vsEbis("Y1vsEbis","yield1 vs E",15,0.,maxE*1.1);
    TH1D Y1vsECE("Y1vsECE","yield1 vs E",15,0.,maxE*1.1);
    TH1D Y1vsEDF("Y1vsEDF","yield1 vs E",15,0.,maxE*1.1);
    TH1D Y2vsE("Y2vsE","yield2 vs E",15,0.,maxE*1.1);
    TH1D Y1vsE1("Y1vsE1","yield1 vs E1",15,0.,maxE*1.);
    TH1D Y1vsE2("Y1vsE2","yield1 vs E2",15,0.,maxE*1.);

    TH1D Y1vsdist("Y1vsdist","yield1 vs dist",10,0.,70.);
    TH1D Y2vsdist("Y2vsdist","yield2 vs dist",10,0.,70.);
    TH1D s1_1p("s1_1p","S1 ADC",100,0.,2000);
    TH1D s2_1p("s2_1p","S2 ADC",100,0.,2000);
    TH1D s1_2p("s1_2p","S1 ADC",100,0.,2000);
    TH1D s2_2p("s2_2p","S2 ADC",100,0.,2000);
    TH2D masss1("masss1","mass vs S1 ADC",150,0.,.4,100,0.,2000);
    TH2D masss2("masss2","mass vs S2 ADC",150,0.,.4,100,0.,2000);
    TH2D s1s2_1p("s1s2_1p","S1 vs S2 ADC",100,0.,2000,100,0.,2000);
    TH2D s1s2_2p("s1s2_2p","S1 vs S2 ADC",100,0.,2000,100,0.,2000);

    TH1D massPi0Pi0("massPi0Pi0","masspi0pi0",33,0.5,2.5);
    TH1D massPi0Pi0full("massPi0Pi0full","masspi0pi0",50,0.,3.);
    TH1D n_Pi0("n_Pi0","npi0",8,2.,10.0);

    Long64_t nentries = fChain->GetEntriesFast();

    cout << nentries << endl;

    Long64_t nbytes = 0, nb = 0;
    for (Long64_t jentry=0; jentry<nentries; jentry++) {
        Long64_t ientry = LoadTree(jentry);
        if (ientry < 0) break;
        nb = fChain->GetEntry(jentry);
        nbytes += nb;
        // if (Cut(ientry) < 0) continue;

        int nPi0(0);
        double mpi01, mpi02;
        double px_pi0[100],py_pi0[100],pz_pi0[100],E_pi0[100];
        int index1_pi0[100], index2_pi0[100];

        if(nClu!=2) continue;
        //     if(nClu<2) continue;

        double  distance_pivot_target(270.3);

        //SELECT CHARGE EXCHANGE OR DIFFRACTION
        if (scint1>140. && scint2>220.) distance_pivot_target = 376.8;
        else if(scint2<110.) distance_pivot_target = 376.8;
        else if(scint1<140. && scint2>400.) distance_pivot_target = 376.8;
        else if(scint1<140. && scint2>100. && scint2<220.) distance_pivot_target = 270.3;
        else continue;

        for (int ii=0; ii<nClu; ii++) {
            for (int jj=0; jj<nClu; jj++) {
                if(jj>49) continue;
                if(ii>=jj) continue;

                if(amplClu[ii]<.025*maxE) continue;
                if(amplClu[jj]<.025*maxE) continue;
                // 	 if(amplClu[ii]+amplClu[jj]<0.35*maxE) continue;
                if(nCryClu[ii]<7) continue;
                if(nCryClu[jj]<7) continue;

                double dist =
                    sqrt(pow((xClu[ii]-xClu[jj]),2) + pow((yClu[ii]-yClu[jj]),2) + pow((zClu[ii]-zClu[jj]),2));

                double x_pivot = 135.4;
                double y_pivot = 4.;
                double z_pivot = 135.;
                double distance_pivot = sqrt(pow(x_pivot,2)+pow(y_pivot,2)+pow(z_pivot,2));
                double x_versor = x_pivot / distance_pivot;
                double y_versor = y_pivot / distance_pivot;
                double z_versor = z_pivot / distance_pivot;


                double newx0 = xClu[ii] + x_versor * distance_pivot_target;
                double newy0 = yClu[ii] + y_versor * distance_pivot_target;
                double newz0 = zClu[ii] + z_versor * distance_pivot_target;

                double newx1 = xClu[jj] + x_versor * distance_pivot_target;
                double newy1 = yClu[jj] + y_versor * distance_pivot_target;
                double newz1 = zClu[jj] + z_versor * distance_pivot_target;

                double cost = newx0 * newx1 + newy0 * newy1 + newz0 * newz1;
                cost = cost / (sqrt(pow(newx0,2)+pow(newy0,2)+pow(newz0,2)) * sqrt(pow(newx1,2)+pow(newy1,2)+pow(newz1,2)));

                double masspi0;
                masspi0 = sqrt(2*amplClu[ii]*amplClu[jj]*(1-cost));

                double lenght0 = sqrt(pow(newx0,2)+pow(newy0,2)+pow(newz0,2));
                double px0 = newx0 * amplClu[ii] / lenght0;
                double py0 = newy0 * amplClu[ii] / lenght0;
                double pz0 = newz0 * amplClu[ii] / lenght0;
                double lenght1 = sqrt(pow(newx1,2)+pow(newy1,2)+pow(newz1,2));
                double px1 = newx1 * amplClu[jj] / lenght1;
                double py1 = newy1 * amplClu[jj] / lenght1;
                double pz1 = newz1 * amplClu[jj] / lenght1;

                double pxpi0 = px0+px1;
                double pypi0 = py0+py1;
                double pzpi0 = pz0+pz1;

                double ppi0 = sqrt(pow(pxpi0,2)+pow(pypi0,2)+pow(pzpi0,2));
                double enepi0 = amplClu[ii] + amplClu[jj];

                double xpi0 = pxpi0 / ppi0 * (distance_pivot_target + distance_pivot);
                double ypi0 = pypi0 / ppi0 * (distance_pivot_target + distance_pivot);
                double zpi0 = pzpi0 / ppi0 * (distance_pivot_target + distance_pivot);
// 	 double xpi0 = pxpi0 / ppi0;
// 	 double ypi0 = pypi0 / ppi0;
// 	 double zpi0 = pzpi0 / ppi0;

// 	 cout << "X = " << xpi0 << ", " <<newx0 << ", " << newx1 << "    Y = " << ypi0 << ", " << newy0 << ", " << newy1 << "    Z = " << zpi0 << ", " << newz0 << ", " << newz1 << endl;

// 	 cout << lenght0 << "   "  << lenght1 << "   "  << sqrt(pow(xpi0,2)+pow(ypi0,2)+pow(zpi0,2)) << endl;


// 	 if(!abs((lenght0 + lenght1)/2 - sqrt(pow(xpi0,2)+pow(ypi0,2)+pow(zpi0,2)))>5) continue;
//  	 if(!(x_wcA[0]>-20.&&x_wcA[0]<20.)) continue;
// 	 if(!(y_wcA[0]>-20.&&y_wcA[0]<20.)) continue;
// 	 if(!(x_wcB[0]>-20.&&x_wcB[0]<20.)) continue;
//  	 if(!(y_wcB[0]>-20.&&y_wcB[0]<20.)) continue;

                massPi0.Fill(masspi0);
                massPi0_2.Fill(masspi0);
                massPi0full.Fill(masspi0);
                if(amplClu[ii]+amplClu[jj]>0.55*maxE) {
                    masseta.Fill(masspi0);
                    massetafull.Fill(masspi0);
                }
                massPi0vsE.Fill(masspi0,amplClu[ii]+amplClu[jj]);
                massPi0vsE1.Fill(masspi0,amplClu[ii]);
                massPi0vsE2.Fill(masspi0,amplClu[jj]);
                if(distance_pivot_target == 273.8)
                    massPi0vsECE.Fill(masspi0,amplClu[ii]+amplClu[jj]);
                else
                    massPi0vsEDF.Fill(masspi0,amplClu[ii]+amplClu[jj]);
                massPi0vsE_2.Fill(masspi0,amplClu[ii]+amplClu[jj]);
                massPi0vsdistance.Fill(masspi0,dist);

                masss1.Fill(masspi0,scint1);
                masss2.Fill(masspi0,scint2);

                if(masspi0>0.104&&masspi0<0.176) {
                    if(masspi0>0.120&&masspi0<0.145) {
                        distance.Fill(dist);
                        energypi0.Fill(amplClu[ii]+amplClu[jj]);
                        x.Fill(xClu[ii]);
                        y.Fill(yClu[ii]);
                        z.Fill(zClu[ii]);
                        yz.Fill(yClu[ii],zClu[ii]);
                        x.Fill(xClu[jj]);
                        y.Fill(yClu[jj]);
                        z.Fill(zClu[jj]);
                        yz.Fill(yClu[jj],zClu[jj]);
                        phi.Fill(phiClu[ii]);
                        phi.Fill(phiClu[jj]);
                        eta.Fill(etaClu[ii]);
                        eta.Fill(etaClu[jj]);
                        xyA.Fill(x_wcA[0],y_wcA[0]);
                        xyB.Fill(x_wcB[0],y_wcB[0]);
                        s1_1p.Fill(scint1);
                        s2_1p.Fill(scint2);
                        s1s2_1p.Fill(scint1,scint2);
                        px_pi0[nPi0] = pxpi0;
                        py_pi0[nPi0] = pypi0;
                        pz_pi0[nPi0] = pzpi0;
                        index1_pi0[nPi0] = ii;
                        index2_pi0[nPi0] = jj;
                        E_pi0[nPi0] = amplClu[ii]+amplClu[jj];
                        nPi0++;
                        if(nPi0==1) mpi01 = masspi0;
                        if(nPi0==2) mpi02 = masspi0;
                    }
                    if(masspi0>0.150&&masspi0<0.170) {
                        s1_2p.Fill(scint1);
                        s2_2p.Fill(scint2);
                        s1s2_2p.Fill(scint1,scint2);
                    }
                }
                if(masspi0>0.500&&masspi0<0.560&&amplClu[ii]+amplClu[jj]>0.55*maxE) {
                    yzeta.Fill(yClu[ii],zClu[ii]);
                    yzeta.Fill(yClu[jj],zClu[jj]);
                }
            }
        }
        if(nPi0==2) {
            masspi01.Fill(mpi01);
            masspi02.Fill(mpi02);
            mp01mp02.Fill(mpi01,mpi02);
        }
        n_Pi0.Fill(nPi0);
        //     if(nPi0==2){
        for(int yy=0; yy<nPi0; yy++) {
            for (int kk=0; kk<nPi0; kk++) {
                if(kk>99) continue;
                if(yy>=kk) continue;
                if(index1_pi0[yy] == index1_pi0[kk]) continue;
                if(index1_pi0[yy] == index2_pi0[kk]) continue;
                if(index2_pi0[yy] == index1_pi0[kk]) continue;
                double px_pp = px_pi0[yy] + px_pi0[kk];
                double py_pp = py_pi0[yy] + py_pi0[kk];
                double pz_pp = pz_pi0[yy] + pz_pi0[kk];
                double p_pp = sqrt(pow(px_pp,2)+pow(py_pp,2)+pow(pz_pp,2));
                double E_pp = E_pi0[yy] + E_pi0[kk];
                double masspi0pi0 = sqrt(E_pp*E_pp - p_pp*p_pp);

                if(E_pi0[yy]<.05*maxE) continue;
                if(E_pi0[kk]<.05*maxE) continue;

                if(E_pp>.75*maxE) {
                    massPi0Pi0.Fill(masspi0pi0);
                    massPi0Pi0full.Fill(masspi0pi0);
                }
// 	   double m1 = sqrt(pow(E_pi0[yy],2)-pow(px_pi0[yy],2)-pow(py_pi0[yy],2)-pow(pz_pi0[yy],2));
// 	   double m2 = sqrt(pow(E_pi0[kk],2)-pow(px_pi0[kk],2)-pow(py_pi0[kk],2)-pow(pz_pi0[kk],2));
// 	   cout << m1 << "  " << m2 << "   "  << sqrt(pow(px_pi0[yy],2)+pow(py_pi0[yy],2)+pow(pz_pi0[yy],2)) << "   "  << E_pi0[yy] << "   "  << sqrt(pow(px_pi0[kk],2)+pow(py_pi0[kk],2)+pow(pz_pi0[kk],2)) << "   "  << E_pi0[kk] << "   "  << p_pp << "   " <<  E_pp << "   "  << p_pp << endl;
            }
        }
        //       if(nPi0==3){
        for(int yy=0; yy<nPi0; yy++) {
            for (int kk=0; kk<nPi0; kk++) {
                for (int ii=0; ii<nPi0; ii++) {
                    if(kk>99) continue;
                    if(yy>=kk) continue;
                    if(kk>=ii) continue;
                    if(index1_pi0[yy] == index1_pi0[kk]) continue;
                    if(index1_pi0[yy] == index2_pi0[kk]) continue;
                    if(index2_pi0[yy] == index1_pi0[kk]) continue;
                    if(index1_pi0[yy] == index1_pi0[ii]) continue;
                    if(index1_pi0[yy] == index2_pi0[ii]) continue;
                    if(index2_pi0[yy] == index1_pi0[ii]) continue;
                    if(index1_pi0[ii] == index1_pi0[kk]) continue;
                    if(index1_pi0[ii] == index2_pi0[kk]) continue;
                    if(index2_pi0[ii] == index1_pi0[kk]) continue;
                    double px_pp = px_pi0[ii] +px_pi0[yy] + px_pi0[kk];
                    double py_pp = py_pi0[ii] +py_pi0[yy] + py_pi0[kk];
                    double pz_pp = pz_pi0[ii] +pz_pi0[yy] + pz_pi0[kk];
                    double p_pp = sqrt(pow(px_pp,2)+pow(py_pp,2)+pow(pz_pp,2));
                    double E_pp = E_pi0[ii] + E_pi0[yy] + E_pi0[kk];
                    double masspi0pi0pi0 = sqrt(E_pp*E_pp - p_pp*p_pp);

                    if(E_pi0[yy]<.08*maxE) continue;
                    if(E_pi0[kk]<.08*maxE) continue;
                    if(E_pi0[ii]<.08*maxE) continue;

                    if(E_pp>.55*maxE) {
                        masseta3pi0.Fill(masspi0pi0pi0);
                        masseta3pi0full.Fill(masspi0pi0pi0);
                        if(masspi0pi0pi0<.65) {
                            yz3pi0.Fill(yClu[index1_pi0[kk]],zClu[index1_pi0[kk]]);
                            yz3pi0.Fill(yClu[index2_pi0[kk]],zClu[index2_pi0[kk]]);
                            yz3pi0.Fill(yClu[index1_pi0[yy]],zClu[index1_pi0[yy]]);
                            yz3pi0.Fill(yClu[index2_pi0[yy]],zClu[index2_pi0[yy]]);
                            yz3pi0.Fill(yClu[index1_pi0[ii]],zClu[index1_pi0[ii]]);
                            yz3pi0.Fill(yClu[index2_pi0[ii]],zClu[index2_pi0[ii]]);
                        }
                    }
                    cout << masspi0pi0pi0 << "  " <<  E_pi0[yy] << "   " << E_pi0[kk] << "   "  << E_pi0[ii] <<  endl;
                }
            }
        }
    }

    TCanvas *c0 = new TCanvas("c1"," ",200,10,500,500);
    c0->Clear();

    massPi0.SetXTitle("m(#pi^{0}) [GeV]");
    massPi0.SetStats(0);
    massPi0.SetTitle("");
    massPi0.Draw();

    c0->SaveAs("masspi0.eps");

    TF1 *gaussian_p;
    gaussian_p = new TF1("gaupoly2",gaup2,0.03,2.8, 9) ;
    gaussian_p->SetLineColor(kBlue);
    gaussian_p->SetParNames ("Mean1","Sigma1","Norm1","p0","p1","p2","Mean2","Sigma2","Norm2");
    gaussian_p->SetParameter(0, .132);
    gaussian_p->SetParLimits(0, 0.12,0.145);
    gaussian_p->SetParLimits(1, 0.003,0.015);
    gaussian_p->SetParameter(2, 10.);
    gaussian_p->SetParLimits(2, 0.,1000.);
    gaussian_p->SetParameter(3, 1.);
    gaussian_p->SetParameter(4, 0.);
    gaussian_p->SetParameter(5, 0.);
    gaussian_p->SetParameter(6, .132);
    gaussian_p->SetParLimits(6, 0.12,0.145);
    gaussian_p->SetParameter(7, .020);
    gaussian_p->SetParLimits(7, 0.015,0.1);
    gaussian_p->SetParameter(8, 10.);
    gaussian_p->SetParLimits(8, 0.,1000.);

    massPi0_2.SetStats(0);
    massPi0_2.SetXTitle("m(#gamma#gamma) [GeV/c^{2}]");
    massPi0_2.SetYTitle("events/2.7MeV/c^{2}");
    massPi0_2.SetTitleOffset(1.8,"Y");
    massPi0_2.SetTitle("");
    //   massPi0_2.SetMarkerSize(1.);
    massPi0_2.Fit ("gaupoly2","L","",.03,.4) ;
    //   massPi0_2.SetAxisRange(.0,.35);
    //   massPi0_2.Draw("pe");

    double mpi0= gaussian_p->GetParameter(0);
    double errmpi0= gaussian_p->GetParError(0);

    double smpi0= gaussian_p->GetParameter(1);
    double errsmpi0= gaussian_p->GetParError(1);

    double events= gaussian_p->GetParameter(2)/massPi0_2.GetBinWidth(1);
    double errevents = gaussian_p->GetParError(2)/massPi0_2.GetBinWidth(1);

    char line[100];

    TText tl;
    tl.SetTextSize(.03);
    sprintf(line, "mass1 = (%7.1f +/- %5.1f) MeV", mpi0*1000, errmpi0*1000);
    tl.DrawTextNDC(.5, 0.85, line);
    sprintf(line, "sigma1 = (%7.1f +/- %5.1f) MeV", smpi0*1000, errsmpi0*1000);
    tl.DrawTextNDC(.5, 0.79, line);
    sprintf(line, "N(ev1) = %7.1f +/- %5.1f", events, errevents);
    tl.DrawTextNDC(.5, 0.73, line);

    c0->SaveAs("masspi0_comb.eps");

    massPi0_2.SetMarkerSize(1.);
    massPi0_2.SetAxisRange(.03,.4);
    massPi0_2.Draw("pe");

    TF1 *gaussian3_p;
    gaussian3_p = new TF1("gaupoly3_p",gaup2,0.03,2.8, 9) ;

    gaussian3_p->SetParNames ("Mean1","Sigma1","Norm1","p0","p1","p2","Mean2","Sigma2","Norm2");
    gaussian3_p->SetParameter(0, .131);
    gaussian3_p->SetParameter(1, 1.);
    gaussian3_p->SetParameter(2, 0.);
    gaussian3_p->SetParameter(3, gaussian_p->GetParameter(3));
    gaussian3_p->SetParameter(4, gaussian_p->GetParameter(4));
    gaussian3_p->SetParameter(5, gaussian_p->GetParameter(5));
    gaussian3_p->SetParameter(6, 0.);
    gaussian3_p->SetParameter(7, 0.);
    gaussian3_p->SetParameter(8, 0.);

//    gaussian3_p->SetLineStyle(3);
//    gaussian3_p->SetFillStyle(34);
//    gaussian3_p->SetFillColor(kRed);

    gaussian3_p->SetLineStyle(3);
    gaussian3_p->Draw("same");

    TPad *npad = new TPad("npad", "", 0.45, 0.45, 0.89, 0.89);
    npad->Draw();
    npad->cd();
    masseta.SetYTitle("events/10MeV/c^{2}");
    masseta.SetTitleSize(0.06,"X");
    masseta.SetTitleSize(0.06,"Y");
    masseta.SetTitleOffset(.8,"X");
    masseta.SetTitleOffset(1.,"Y");

    gaussian_p->SetParameter(0, .55);
    gaussian_p->SetParameter(1, .03);
    gaussian_p->SetParLimits(0, 0.5,0.6);
    gaussian_p->SetParLimits(1, 0.005,0.04);
    gaussian_p->SetParameter(6, .65);
    gaussian_p->SetParLimits(6, 0.55,0.7);
    gaussian_p->SetParameter(7, .03);
    gaussian_p->SetParLimits(7, 0.05,0.03);
    gaussian_p->FixParameter(8, 0.);

    masseta.SetXTitle("m(#gamma#gamma) [GeV/c^{2}]");
    //   masseta.SetTitleSize(.4);
    masseta.SetStats(0);
    masseta.SetMarkerSize(.8);
    masseta.SetTitle("");
    masseta.SetAxisRange(.38,.72);
    masseta.Fit ("gaupoly2","L","",.38,.72) ;
    masseta.Draw("pe");
//    gaussian_p->SetLineColor(kBlue);
//    gaussian_p->Draw("same");

    c0->SaveAs("masspi0_times.eps");


    gaussian_p->SetParameter(0, .131);
    gaussian_p->SetParameter(1, .008);
    gaussian_p->SetParameter(2, 10.);
    gaussian_p->SetParLimits(2, 0.,1000.);
    gaussian_p->SetParameter(3, 1.);
    gaussian_p->SetParameter(4, 0.);
    gaussian_p->SetParameter(5, 0.);
    gaussian_p->SetParameter(6, .159);
    gaussian_p->SetParameter(7, .008);
    gaussian_p->SetParameter(8, 10.);
    gaussian_p->SetParLimits(8, 0.,1000.);
    gaussian_p->SetParLimits(0, 0.12,0.145);
    gaussian_p->SetParLimits(6, 0.145,0.6);
    gaussian_p->FixParameter(6, .135);
    gaussian_p->FixParameter(7, .022);

    massPi0_2.SetXTitle("m(#pi^{0}) [GeV]");
    massPi0_2.SetStats(0);
    massPi0_2.SetTitle("");
    massPi0_2.Fit ("gaupoly2","L","",.05,.4) ;

    cout << massPi0_2.Integral() << endl;

    mpi0= gaussian_p->GetParameter(0);
    errmpi0= gaussian_p->GetParError(0);

    smpi0= gaussian_p->GetParameter(1);
    errsmpi0= gaussian_p->GetParError(1);

    double mpi1= gaussian_p->GetParameter(6);
    double errmpi1= gaussian_p->GetParError(6);

    double smpi1= gaussian_p->GetParameter(7);
    double errsmpi1= gaussian_p->GetParError(7);

    events= gaussian_p->GetParameter(2)/massPi0_2.GetBinWidth(1);
    errevents = gaussian_p->GetParError(2)/massPi0_2.GetBinWidth(1);

    double events1= gaussian_p->GetParameter(8)/massPi0_2.GetBinWidth(1);
    double errevents1 = gaussian_p->GetParError(8)/massPi0_2.GetBinWidth(1);


    tl.SetTextSize(.03);
    sprintf(line, "mass1 = (%7.1f +/- %5.1f) MeV", mpi0*1000, errmpi0*1000);
    tl.DrawTextNDC(.5, 0.85, line);
    sprintf(line, "sigma1 = (%7.1f +/- %5.1f) MeV", smpi0*1000, errsmpi0*1000);
    tl.DrawTextNDC(.5, 0.79, line);
    sprintf(line, "N(ev1) = %7.1f +/- %5.1f", events, errevents);
    tl.DrawTextNDC(.5, 0.73, line);
    sprintf(line, "mass2 = (%7.1f +/- %5.1f) MeV", mpi1*1000, errmpi1*1000);
    tl.DrawTextNDC(.5, 0.67, line);
    sprintf(line, "sigma2 = (%7.1f +/- %5.1f) MeV", smpi1*1000, errsmpi1*1000);
    tl.DrawTextNDC(.5, 0.61, line);
    sprintf(line, "N(ev2) = %7.1f +/- %5.1f", events1, errevents1);
    tl.DrawTextNDC(.5, 0.55, line);

    c0->SaveAs("masspi0_2.eps");


    for (int h=2; h<16; h++) {
        TH1D tmpmass("tmpmass","mass",150,0.,.4);
        for (int j=1; j<150; j++) {
            tmpmass.SetBinContent(j,massPi0vsE.GetBinContent(j,h));
        }
        gaussian_p->SetParameter(0, .132);
        gaussian_p->SetParameter(1, .008);
        gaussian_p->SetParameter(2, 10.);
        gaussian_p->SetParLimits(2, 0.,1000.);
        gaussian_p->SetParameter(3, 1.);
        gaussian_p->SetParameter(4, 0.);
        gaussian_p->SetParameter(5, 0.);
        gaussian_p->SetParLimits(3, 0.,1000.);
        gaussian_p->SetParLimits(4, -100.,100.);
        gaussian_p->SetParLimits(5, -100.,100.);
        gaussian_p->SetParameter(6, .132);
        gaussian_p->SetParameter(7, .020);
        gaussian_p->SetParameter(8, 10.);
        gaussian_p->SetParLimits(8, 0.,1000.);
        gaussian_p->SetParLimits(0, 0.125,0.14);
        gaussian_p->SetParLimits(1, 0.003,0.01);
        gaussian_p->SetParLimits(6, 0.125,0.14);
        gaussian_p->SetParLimits(7, 0.01,0.1);

        tmpmass.Fit ("gaupoly2","LQ","",.05,.4) ;
        events= gaussian_p->GetParameter(2)/massPi0_2.GetBinWidth(1);
        errevents = gaussian_p->GetParError(2)/massPi0_2.GetBinWidth(1);
        events1= gaussian_p->GetParameter(8)/massPi0_2.GetBinWidth(1);
        errevents1 = gaussian_p->GetParError(8)/massPi0_2.GetBinWidth(1);
        if(tmpmass.Integral(45,55)>2.) {
            Y1vsE.SetBinContent(h,events);
            Y1vsE.SetBinError(h,errevents);
            Y1vsEbis.SetBinContent(h,events);
        } else {
            Y1vsE.SetBinContent(h,0);
            Y1vsE.SetBinError(h,0);
            Y1vsEbis.SetBinError(h,0);
        }

        Y2vsE.SetBinContent(h,events1);
        Y2vsE.SetBinError(h,errevents1);

        char tempchar[100];
        sprintf(tempchar,"%d%s",h,"masspi0_2.eps");
        c0->SaveAs(tempchar);
    }

    for (int h=2; h<16; h++) {
        TH1D tmpmass("tmpmass","mass",150,0.,.4);
        for (int j=1; j<150; j++) {
            tmpmass.SetBinContent(j,massPi0vsE1.GetBinContent(j,h));
        }
        gaussian_p->SetParameter(0, .132);
        gaussian_p->SetParameter(1, .008);
        gaussian_p->SetParameter(2, 10.);
        gaussian_p->SetParLimits(2, 0.,1000.);
        gaussian_p->SetParameter(3, 1.);
        gaussian_p->SetParameter(4, 0.);
        gaussian_p->SetParameter(5, 0.);
        gaussian_p->SetParLimits(3, 0.,1000.);
        gaussian_p->SetParLimits(4, -100.,100.);
        gaussian_p->SetParLimits(5, -100.,100.);
        gaussian_p->SetParameter(6, .132);
        gaussian_p->SetParameter(7, .020);
        gaussian_p->SetParameter(8, 10.);
        gaussian_p->SetParLimits(8, 0.,1000.);
        gaussian_p->SetParLimits(0, 0.125,0.14);
        gaussian_p->SetParLimits(1, 0.003,0.01);
        gaussian_p->SetParLimits(6, 0.125,0.14);
        gaussian_p->SetParLimits(7, 0.01,0.1);

        tmpmass.Fit ("gaupoly2","LQ","",.05,.4) ;
        events= gaussian_p->GetParameter(2)/massPi0_2.GetBinWidth(1);
        errevents = gaussian_p->GetParError(2)/massPi0_2.GetBinWidth(1);
        events1= gaussian_p->GetParameter(8)/massPi0_2.GetBinWidth(1);
        errevents1 = gaussian_p->GetParError(8)/massPi0_2.GetBinWidth(1);
        if(tmpmass.Integral(45,55)>2.) {
            Y1vsE1.SetBinContent(h,events);
            Y1vsE1.SetBinError(h,errevents);
        } else {
            Y1vsE1.SetBinContent(h,0);
            Y1vsE1.SetBinError(h,0);
        }
    }

    for (int h=2; h<16; h++) {
        TH1D tmpmass("tmpmass","mass",150,0.,.4);
        for (int j=1; j<150; j++) {
            tmpmass.SetBinContent(j,massPi0vsE2.GetBinContent(j,h));
        }
        gaussian_p->SetParameter(0, .132);
        gaussian_p->SetParameter(1, .008);
        gaussian_p->SetParameter(2, 10.);
        gaussian_p->SetParLimits(2, 0.,1000.);
        gaussian_p->SetParameter(3, 1.);
        gaussian_p->SetParameter(4, 0.);
        gaussian_p->SetParameter(5, 0.);
        gaussian_p->SetParLimits(3, 0.,1000.);
        gaussian_p->SetParLimits(4, -100.,100.);
        gaussian_p->SetParLimits(5, -100.,100.);
        gaussian_p->SetParameter(6, .132);
        gaussian_p->SetParameter(7, .020);
        gaussian_p->SetParameter(8, 10.);
        gaussian_p->SetParLimits(8, 0.,1000.);
        gaussian_p->SetParLimits(0, 0.125,0.14);
        gaussian_p->SetParLimits(1, 0.003,0.01);
        gaussian_p->SetParLimits(6, 0.125,0.14);
        gaussian_p->SetParLimits(7, 0.01,0.1);

        tmpmass.Fit ("gaupoly2","LQ","",.05,.4) ;
        events= gaussian_p->GetParameter(2)/massPi0_2.GetBinWidth(1);
        errevents = gaussian_p->GetParError(2)/massPi0_2.GetBinWidth(1);
        events1= gaussian_p->GetParameter(8)/massPi0_2.GetBinWidth(1);
        errevents1 = gaussian_p->GetParError(8)/massPi0_2.GetBinWidth(1);
        if(tmpmass.Integral(45,55)>2.) {
            Y1vsE2.SetBinContent(h,events);
            Y1vsE2.SetBinError(h,errevents);
        } else {
            Y1vsE2.SetBinContent(h,0);
            Y1vsE2.SetBinError(h,0);
        }
    }

    for (int h=2; h<16; h++) {
        TH1D tmpmass("tmpmass","mass",150,0.,.4);
        for (int j=1; j<150; j++) {
            tmpmass.SetBinContent(j,massPi0vsECE.GetBinContent(j,h));
        }
        gaussian_p->SetParameter(0, .132);
        gaussian_p->SetParameter(1, .008);
        gaussian_p->SetParameter(2, 10.);
        gaussian_p->SetParLimits(2, 0.,1000.);
        gaussian_p->SetParameter(3, 1.);
        gaussian_p->SetParameter(4, 0.);
        gaussian_p->SetParameter(5, 0.);
        gaussian_p->SetParLimits(3, 0.,1000.);
        gaussian_p->SetParLimits(4, -100.,100.);
        gaussian_p->SetParLimits(5, -100.,100.);
        gaussian_p->SetParameter(6, .132);
        gaussian_p->SetParameter(7, .020);
        gaussian_p->SetParameter(8, 10.);
        gaussian_p->SetParLimits(8, 0.,1000.);
        gaussian_p->SetParLimits(0, 0.125,0.14);
        gaussian_p->SetParLimits(1, 0.003,0.01);
        gaussian_p->SetParLimits(6, 0.125,0.14);
        gaussian_p->SetParLimits(7, 0.01,0.1);

        tmpmass.Fit ("gaupoly2","LQ","",.05,.4) ;
        events= gaussian_p->GetParameter(2)/massPi0_2.GetBinWidth(1);
        errevents = gaussian_p->GetParError(2)/massPi0_2.GetBinWidth(1);
        if(tmpmass.Integral(45,55)>2.) {
            Y1vsECE.SetBinContent(h,events);
            Y1vsECE.SetBinError(h,errevents);
        } else {
            Y1vsECE.SetBinContent(h,0);
            Y1vsECE.SetBinError(h,0);
        }
//      char tempchar[100];
//      sprintf(tempchar,"%d%s",h,"masspi0_2_CE.eps");
//      c0->SaveAs(tempchar);
    }

    for (int h=2; h<16; h++) {
        TH1D tmpmass("tmpmass","mass",150,0.,.4);
        for (int j=1; j<150; j++) {
            tmpmass.SetBinContent(j,massPi0vsEDF.GetBinContent(j,h));
        }
        gaussian_p->SetParameter(0, .132);
        gaussian_p->SetParameter(1, .008);
        gaussian_p->SetParameter(2, 10.);
        gaussian_p->SetParLimits(2, 0.,1000.);
        gaussian_p->SetParameter(3, 1.);
        gaussian_p->SetParameter(4, 0.);
        gaussian_p->SetParameter(5, 0.);
        gaussian_p->SetParLimits(3, 0.,1000.);
        gaussian_p->SetParLimits(4, -100.,100.);
        gaussian_p->SetParLimits(5, -100.,100.);
        gaussian_p->SetParameter(6, .132);
        gaussian_p->SetParameter(7, .020);
        gaussian_p->SetParameter(8, 10.);
        gaussian_p->SetParLimits(8, 0.,1000.);
        gaussian_p->SetParLimits(0, 0.125,0.14);
        gaussian_p->SetParLimits(1, 0.003,0.01);
        gaussian_p->SetParLimits(6, 0.125,0.14);
        gaussian_p->SetParLimits(7, 0.01,0.1);

        tmpmass.Fit ("gaupoly2","LQ","",.05,.4) ;
        events= gaussian_p->GetParameter(2)/massPi0_2.GetBinWidth(1);
        errevents = gaussian_p->GetParError(2)/massPi0_2.GetBinWidth(1);
        if(tmpmass.Integral(45,55)>2.) {
            Y1vsEDF.SetBinContent(h,events);
            Y1vsEDF.SetBinError(h,errevents);
        } else {
            Y1vsEDF.SetBinContent(h,0);
            Y1vsEDF.SetBinError(h,0);
        }

//      char tempchar[100];
//      sprintf(tempchar,"%d%s",h,"masspi0_2_CE.eps");
//      c0->SaveAs(tempchar);
    }

    for (int h=1; h<11; h++) {
        TH1D tmpmass("tmpmass","mass",150,0.,.4);
        for (int j=1; j<150; j++) {
            tmpmass.SetBinContent(j,massPi0vsdistance.GetBinContent(j,h));
        }

        gaussian_p->SetParameter(0, .132);
        gaussian_p->SetParameter(1, .008);
        gaussian_p->SetParameter(2, 10.);
        gaussian_p->SetParLimits(2, 0.,1000.);
        gaussian_p->SetParameter(3, 1.);
        gaussian_p->SetParameter(4, 0.);
        gaussian_p->SetParameter(5, 0.);
        gaussian_p->SetParLimits(3, 0.,1000.);
        gaussian_p->SetParLimits(4, -100.,100.);
        gaussian_p->SetParLimits(5, -100.,100.);
        gaussian_p->SetParameter(6, .132);
        gaussian_p->SetParameter(7, .020);
        gaussian_p->SetParameter(8, 10.);
        gaussian_p->SetParLimits(8, 0.,1000.);
        gaussian_p->SetParLimits(0, 0.125,0.14);
        gaussian_p->SetParLimits(1, 0.003,0.01);
        gaussian_p->SetParLimits(6, 0.125,0.14);
        gaussian_p->SetParLimits(7, 0.01,0.1);
        tmpmass.Fit ("gaupoly2","LQ","",.05,.4) ;
        events= gaussian_p->GetParameter(2)/massPi0_2.GetBinWidth(1);
        errevents = gaussian_p->GetParError(2)/massPi0_2.GetBinWidth(1);
        events1= gaussian_p->GetParameter(8)/massPi0_2.GetBinWidth(1);
        errevents1 = gaussian_p->GetParError(8)/massPi0_2.GetBinWidth(1);
        Y1vsdist.SetBinContent(h,events);
        Y1vsdist.SetBinError(h,errevents);
        Y2vsdist.SetBinContent(h,events1);
        Y2vsdist.SetBinError(h,errevents1);

        cout << "1 gauss " << events << "+/-" << errevents << endl;
        cout << "2 gauss " << events1 << "+/-" << errevents1 << endl;
    }

//    gaussian_p->FixParameter(0, .1305);
//    gaussian_p->FixParameter(6, .1595);

//    for (int h=2;h<12;h++){
//      TH1D tmpmass("tmpmass","mass",150,0.,.4);
//      for (int j=1;j<150;j++){
//        tmpmass.SetBinContent(j,massPi0vsE.GetBinContent(j,h));
//      }
//      gaussian_p->FixParameter(1, .008);
//      gaussian_p->FixParameter(7, .009);
//      gaussian_p->SetParameter(2, 10.);
//      gaussian_p->SetParameter(3, 1.);
//      gaussian_p->SetParameter(4, 0.);
//      gaussian_p->SetParameter(5, 0.);
//      gaussian_p->SetParameter(8, 10.);
//      //     gaussian_p->FixParameter(8, .0);
//      tmpmass.Fit ("gaupoly2","L","",.05,.4) ;
//      events= gaussian_p->GetParameter(2)/massPi0_2.GetBinWidth(1);
//      errevents = gaussian_p->GetParError(2)/massPi0_2.GetBinWidth(1);
//      events1= gaussian_p->GetParameter(8)/massPi0_2.GetBinWidth(1);
//      errevents1 = gaussian_p->GetParError(8)/massPi0_2.GetBinWidth(1);
//      Y1vsE.SetBinContent(h,events);
//      Y1vsE.SetBinError(h,errevents);
//      Y2vsE.SetBinContent(h,events1);
//      Y2vsE.SetBinError(h,errevents1);

//      cout << "1 gauss " << events << "+/-" << errevents << endl;
//      cout << "2 gauss " << events1 << "+/-" << errevents1 << endl;
//      char tempchar[100];
//      sprintf(tempchar,"%d%s",h,"masspi0_2.eps");
//      c0->SaveAs(tempchar);
//    }

//    for (int h=1;h<11;h++){
//      TH1D tmpmass("tmpmass","mass",150,0.,.4);
//      for (int j=1;j<150;j++){
//        tmpmass.SetBinContent(j,massPi0vsdistance.GetBinContent(j,h));
//      }
//      gaussian_p->FixParameter(1, .008);
//      gaussian_p->FixParameter(7, .009);
//      gaussian_p->SetParameter(2, 10.);
//      gaussian_p->SetParameter(3, 1.);
//      gaussian_p->SetParameter(4, 0.);
//      gaussian_p->SetParameter(5, 0.);
//      //     gaussian_p->SetParameter(8, 10.);
//      tmpmass.Fit ("gaupoly2","L","",.05,.4) ;
//      events= gaussian_p->GetParameter(2)/massPi0_2.GetBinWidth(1);
//      errevents = gaussian_p->GetParError(2)/massPi0_2.GetBinWidth(1);
//      events1= gaussian_p->GetParameter(8)/massPi0_2.GetBinWidth(1);
//      errevents1 = gaussian_p->GetParError(8)/massPi0_2.GetBinWidth(1);
//      Y1vsdist.SetBinContent(h,events);
//      Y1vsdist.SetBinError(h,errevents);
//      Y2vsdist.SetBinContent(h,events1);
//      Y2vsdist.SetBinError(h,errevents1);

//      cout << "1 gauss " << events << "+/-" << errevents << endl;
//      cout << "2 gauss " << events1 << "+/-" << errevents1 << endl;
//    }

    gaussian_p->SetParameter(0, .55);
    gaussian_p->SetParameter(1, .03);
    gaussian_p->SetParLimits(0, 0.5,0.6);
    gaussian_p->SetParLimits(1, 0.005,0.04);
    gaussian_p->SetParameter(6, .65);
    gaussian_p->SetParLimits(6, 0.55,0.7);
    gaussian_p->SetParameter(7, .03);
    gaussian_p->SetParLimits(7, 0.05,0.03);
    gaussian_p->FixParameter(8, 0.);

    masseta.SetXTitle("m(#eta) [GeV]");
    masseta.SetStats(0);
    masseta.SetMarkerSize(1.);
    masseta.SetTitle("");
    masseta.Fit ("gaupoly2","L","",.3,.68) ;
    masseta.Draw("pe");
    cout << masseta.Integral() << endl;

    mpi0= gaussian_p->GetParameter(0);
    errmpi0= gaussian_p->GetParError(0);

    smpi0= gaussian_p->GetParameter(1);
    errsmpi0= gaussian_p->GetParError(1);

    events= gaussian_p->GetParameter(2)/masseta.GetBinWidth(1);
    errevents = gaussian_p->GetParError(2)/masseta.GetBinWidth(1);


    tl.SetTextSize(.03);
    sprintf(line, "mass = (%7.1f +/- %5.1f) MeV", mpi0*1000, errmpi0*1000);
    tl.DrawTextNDC(.13, 0.85, line);
    sprintf(line, "sigma = (%7.1f +/- %5.1f) MeV", smpi0*1000, errsmpi0*1000);
    tl.DrawTextNDC(.13, 0.79, line);
    sprintf(line, "N(ev) = %7.1f +/- %5.1f", events, errevents);
    tl.DrawTextNDC(.13, 0.73, line);

    c0->SaveAs("masseta.eps");

    gaussian_p->SetParLimits(8, 0.,1000.);

    masseta.Fit ("gaupoly2","L","",.3,.75) ;
    masseta.Draw("pe");
    cout << masseta.Integral() << endl;

    mpi0= gaussian_p->GetParameter(0);
    errmpi0= gaussian_p->GetParError(0);

    smpi0= gaussian_p->GetParameter(1);
    errsmpi0= gaussian_p->GetParError(1);

    events= gaussian_p->GetParameter(2)/masseta.GetBinWidth(1);
    errevents = gaussian_p->GetParError(2)/masseta.GetBinWidth(1);


    tl.SetTextSize(.03);
    sprintf(line, "mass = (%7.1f +/- %5.1f) MeV", mpi0*1000, errmpi0*1000);
    tl.DrawTextNDC(.13, 0.85, line);
    sprintf(line, "sigma = (%7.1f +/- %5.1f) MeV", smpi0*1000, errsmpi0*1000);
    tl.DrawTextNDC(.13, 0.79, line);
    sprintf(line, "N(ev) = %7.1f +/- %5.1f", events, errevents);
    tl.DrawTextNDC(.13, 0.73, line);

    c0->SaveAs("masseta2.eps");

    gaussian_p->SetParLimits(1, 0.005,0.08);
    gaussian_p->SetParLimits(6, 0.4,0.9);
    gaussian_p->SetParameter(6, 0.7);
    gaussian_p->SetParLimits(7, .1,3.0);
    gaussian_p->SetParameter(7, 1.);
    gaussian_p->SetParLimits(8, 0.,1000.);
    gaussian_p->FixParameter(3, 0.);
    gaussian_p->FixParameter(4, 0.);
    gaussian_p->FixParameter(5, 0.);


    masseta3pi0.SetXTitle("m(#eta) [GeV]");
    masseta3pi0.SetStats(0);
    masseta3pi0.SetMarkerSize(1.);
    masseta3pi0.SetTitle("");
    masseta3pi0.Fit ("gaupoly2","L","",.35,1.2) ;
    masseta3pi0.Draw("pe");

    mpi0= gaussian_p->GetParameter(0);
    errmpi0= gaussian_p->GetParError(0);

    smpi0= gaussian_p->GetParameter(1);
    errsmpi0= gaussian_p->GetParError(1);

    events= gaussian_p->GetParameter(2)/masseta3pi0.GetBinWidth(1);
    errevents = gaussian_p->GetParError(2)/masseta3pi0.GetBinWidth(1);

    TF1 *gaussian2_p;
    gaussian2_p = new TF1("gaupoly2_@",gaup2,0.03,2.8, 9) ;

    gaussian2_p->SetParNames ("Mean1","Sigma1","Norm1","p0","p1","p2","Mean2","Sigma2","Norm2");
    gaussian2_p->SetParameter(0, .131);
    gaussian2_p->SetParameter(1, 1.);
    gaussian2_p->SetParameter(2, 0.);
    gaussian2_p->SetParameter(3, 0.);
    gaussian2_p->SetParameter(4, 0.);
    gaussian2_p->SetParameter(5, 0.);
    gaussian2_p->SetParameter(6, gaussian_p->GetParameter(6));
    gaussian2_p->SetParameter(7, gaussian_p->GetParameter(7));
    gaussian2_p->SetParameter(8, gaussian_p->GetParameter(8));

    gaussian2_p->SetLineStyle(3);
    gaussian2_p->Draw("same");

    tl.SetTextSize(.03);
    sprintf(line, "mass = (%7.1f +/- %5.1f) MeV", mpi0*1000, errmpi0*1000);
    tl.DrawTextNDC(.53, 0.85, line);
    sprintf(line, "sigma = (%7.1f +/- %5.1f) MeV", smpi0*1000, errsmpi0*1000);
    tl.DrawTextNDC(.53, 0.79, line);
    sprintf(line, "N(ev) = %7.1f +/- %5.1f", events, errevents);
    tl.DrawTextNDC(.53, 0.73, line);

    c0->SaveAs("masseta3pi0.eps");

    masspi01.SetXTitle("m(#pi^{0}) [GeV]");
    masspi01.SetStats(0);
    masspi01.SetTitle("");
    masspi01.Fit ("gaupoly2","L","",.03,.4) ;
    c0->SaveAs("mpi01.eps");
    masspi02.SetXTitle("m(#pi^{0}) [GeV]");
    masspi02.SetStats(0);
    masspi02.SetTitle("");
    masspi02.Fit ("gaupoly2","L","",.03,.4) ;
    c0->SaveAs("mpi02.eps");

    mp01mp02.SetXTitle("m(#pi^{0})_{1} [GeV]");
    mp01mp02.SetYTitle("m(#pi^{0})_{2} [GeV]");
    mp01mp02.SetStats(0);
    mp01mp02.SetTitle("");
    mp01mp02.Draw("colz") ;
    c0->SaveAs("mpi01mpi02.eps");

    distance.SetXTitle("#Delta(clusters) [cm]");
    distance.SetStats(0);
    distance.SetTitle("");
    distance.Draw();

    c0->SaveAs("distance.eps");

    energypi0.SetXTitle("E(#pi^{0}) [GeV]");
    energypi0.SetStats(0);
    energypi0.SetTitle("");
    energypi0.Draw();

    c0->SaveAs("energypi0.eps");
    x.Draw();
    c0->SaveAs("x.eps");
    y.Draw();
    c0->SaveAs("y.eps");
    z.Draw();
    c0->SaveAs("z.eps");

    yz.Draw("colz");
    c0->SaveAs("yz.eps");
    yzeta.Draw("colz");
    c0->SaveAs("yzeta.eps");
    yz3pi0.Draw("colz");
    c0->SaveAs("yz3pi0.eps");
    phi.Draw();
    c0->SaveAs("phi.eps");
    eta.Draw();
    c0->SaveAs("eta.eps");
    xyA.Draw("box");
    c0->SaveAs("xyA.eps");
    xyB.Draw("box");
    c0->SaveAs("xyB.eps");
    massPi0vsE.SetStats(0);
    massPi0vsE.SetXTitle("m(#pi^{0}) [GeV]");
    massPi0vsE.SetYTitle("E(#pi^{0}) [GeV]");
    massPi0vsE.Draw("colz");
    c0->SaveAs("massvsE.eps");
    massPi0vsE_2.SetStats(0);
    massPi0vsE_2.SetXTitle("m(#pi^{0}) [GeV]");
    massPi0vsE_2.SetYTitle("E(#pi^{0}) [GeV]");
    massPi0vsE_2.Draw("colz");
    c0->SaveAs("massvsE_2.eps");
    massPi0vsdistance.SetStats(0);
    massPi0vsdistance.SetXTitle("m(#pi^{0}) [GeV]");
    massPi0vsdistance.SetYTitle("distance [cm]");
    massPi0vsdistance.Draw("colz");
    c0->SaveAs("massvsdist.eps");
    Y1vsE.SetMaximum(Y1vsE.GetMaximum()*1.3);
    Y1vsE.SetMinimum(0.);
    Y1vsE.SetMarkerSize(1.);
    Y1vsE.SetStats(0);
    Y1vsE.SetTitle("");
    Y1vsE.SetXTitle("E(#pi^{0}) [GeV]");
    Y1vsE.Draw("pe");
    c0->SaveAs("Y1vsE.eps");
    Y1vsECE.SetMaximum(Y1vsECE.GetMaximum()*1.3);
    Y1vsECE.SetMinimum(0.);
    Y1vsECE.SetMarkerSize(1.);
    Y1vsECE.SetStats(0);
    Y1vsECE.SetTitle("");
    Y1vsECE.SetXTitle("E(#pi^{0}) [GeV]");
    Y1vsECE.Draw("pe");
    c0->SaveAs("Y1vsECE.eps");
    Y1vsEDF.SetMaximum(Y1vsEDF.GetMaximum()*1.3);
    Y1vsEDF.SetMinimum(0.);
    Y1vsEDF.SetMarkerSize(1.);
    Y1vsEDF.SetStats(0);
    Y1vsEDF.SetTitle("");
    Y1vsEDF.SetXTitle("E(#pi^{0}) [GeV]");
    Y1vsEDF.Draw("pe");
    c0->SaveAs("Y1vsEDF.eps");
    Y1vsE.Draw("pe");
    Y1vsECE.SetFillColor(38);
    Y1vsEbis.SetFillColor(38);
    Y1vsEbis.Draw("same");
    Y1vsEDF.SetFillColor(kYellow);
    Y1vsEDF.Draw("same");
    Y1vsE.Draw("pesame");
    TLegendEntry *legge;
    TLegend *leg;
    leg = new TLegend(0.16,0.63,0.4,0.89);
    leg->SetFillStyle(0);
    leg->SetBorderSize(0.);
    leg->SetTextSize(0.06);
    leg->SetFillColor(0);
    legge = leg->AddEntry(&Y1vsECE, "charge ex.", "f");
    legge = leg->AddEntry(&Y1vsEDF, "diffr.", "f");
    legge = leg->AddEntry(&Y1vsE, "all", "p");
    leg->Draw();
    Y1vsE1.SetMaximum(Y1vsE1.GetMaximum()*1.3);
    Y1vsE1.SetMinimum(0.);
    Y1vsE1.SetMarkerSize(1.);
    Y1vsE1.SetStats(0);
    Y1vsE1.SetTitle("");
    Y1vsE1.SetXTitle("E1(#gamma) [GeV]");
    Y1vsE1.Draw("pe");
    c0->SaveAs("Y1vsE1.eps");
    Y1vsE2.SetMaximum(Y1vsE2.GetMaximum()*1.3);
    Y1vsE2.SetMinimum(0.);
    Y1vsE2.SetMarkerSize(1.);
    Y1vsE2.SetStats(0);
    Y1vsE2.SetTitle("");
    Y1vsE2.SetXTitle("E2(#gamma) [GeV]");
    Y1vsE2.Draw("pe");
    c0->SaveAs("Y1vsE2.eps");

    c0->SaveAs("Y1vsEcomb.eps");
    Y2vsE.SetMaximum(Y2vsE.GetMaximum()*1.3);
    Y2vsE.SetMinimum(0.);
    Y2vsE.SetStats(0);
    Y2vsE.SetTitle("");
    Y2vsE.SetMarkerSize(1.);
    Y2vsE.SetXTitle("E(#pi^{0}) [GeV]");
    Y2vsE.Draw("pe");
    c0->SaveAs("Y2vsE.eps");
    Y1vsdist.SetMaximum(Y1vsdist.GetMaximum()*1.3);
    Y1vsdist.SetMinimum(0.);
    Y1vsdist.SetStats(0);
    Y1vsdist.SetTitle("");
    Y1vsdist.SetMarkerSize(1.);
    Y1vsdist.SetXTitle("distance [cm]");
    Y1vsdist.Draw("pe");
    c0->SaveAs("Y1vsdist.eps");
    Y2vsdist.SetMaximum(Y2vsdist.GetMaximum()*1.3);
    Y2vsdist.SetMinimum(0.);
    Y2vsdist.SetStats(0);
    Y2vsdist.SetTitle("");
    Y2vsdist.SetMarkerSize(1.);
    Y2vsdist.SetXTitle("distance [cm]");
    Y2vsdist.Draw("pe");
    c0->SaveAs("Y2vsdist.eps");

    s1_1p.SetXTitle("ADC counts");
    s1_1p.Draw();
    c0->SaveAs("s1_1p.eps");

    s2_1p.SetXTitle("ADC counts");
    s2_1p.Draw();
    c0->SaveAs("s2_1p.eps");

    s1_2p.SetXTitle("ADC counts");
    s1_2p.Draw();
    c0->SaveAs("s1_2p.eps");

    s2_2p.SetXTitle("ADC counts");
    s2_2p.Draw();
    c0->SaveAs("s2_2p.eps");

    masss1.SetXTitle("m(#pi^{0})_{1} [GeV]");
    masss1.SetYTitle("S1 ADC counts");
    masss1.SetStats(0);
    masss1.SetTitle("");
    masss1.Draw("colz") ;
    c0->SaveAs("massvsS1.eps");

    masss2.SetXTitle("m(#pi^{0})_{1} [GeV]");
    masss2.SetYTitle("S2 ADC counts");
    masss2.SetStats(0);
    masss2.SetTitle("");
    masss2.Draw("colz") ;
    c0->SaveAs("massvsS2.eps");

    s1s2_1p.SetXTitle("S1 ADC counts 1' peak");
    s1s2_1p.SetYTitle("S2 ADC counts 1' peak");
//    s1s2_1p.SetStats(0);
    s1s2_1p.SetTitle("");
    s1s2_1p.Draw("colz") ;
    c0->SaveAs("s1s2_1p.eps");

    s1s2_2p.SetXTitle("S1 ADC counts 2' peak");
    s1s2_2p.SetYTitle("S2 ADC counts 2' peak");
//    s1s2_2p.SetStats(0);
    s1s2_2p.SetTitle("");
    s1s2_2p.Draw("colz") ;
    c0->SaveAs("s1s2_2p.eps");


    gaussian_p->SetParameter(0, 1.27);
    gaussian_p->SetParameter(1, .1);
    gaussian_p->SetParameter(2, 1.);
    gaussian_p->SetParameter(3, 1.);
    gaussian_p->SetParameter(4, 0.);
    gaussian_p->SetParameter(5, 0.);
    gaussian_p->SetParLimits(3, -1000.,1000.);
    gaussian_p->SetParLimits(4, -1000.,1000.);
    gaussian_p->SetParLimits(5, -1000.,1000.);
    gaussian_p->SetParLimits(0, 1.2,1.4);
    gaussian_p->SetParLimits(1, 0.03,0.2);
//    gaussian_p->FixParameter(0, 1.27);
//    gaussian_p->FixParameter(1, .1);
    gaussian_p->FixParameter(6, 1.);
    gaussian_p->FixParameter(7, 1.);
    gaussian_p->FixParameter(8, 0.);

    massPi0Pi0.SetXTitle("m(#pi^{0}#pi^{0}) [GeV]");
    massPi0Pi0.SetStats(0);
    massPi0Pi0.SetTitle("");
    massPi0Pi0.SetMarkerSize(1.);
    massPi0Pi0.Fit ("gaupoly2","L","",.75,2.2) ;
    massPi0Pi0.Draw("pe");

    mpi0= gaussian_p->GetParameter(0);
    errmpi0= gaussian_p->GetParError(0);

    smpi0= gaussian_p->GetParameter(1);
    errsmpi0= gaussian_p->GetParError(1);

    events= gaussian_p->GetParameter(2)/massPi0Pi0.GetBinWidth(1);
    errevents = gaussian_p->GetParError(2)/massPi0Pi0.GetBinWidth(1);


    tl.SetTextSize(.03);
    sprintf(line, "mass = (%7.1f +/- %5.1f) MeV", mpi0*1000, errmpi0*1000);
    tl.DrawTextNDC(.5, 0.85, line);
    sprintf(line, "sigma = (%7.1f +/- %5.1f) MeV", smpi0*1000, errsmpi0*1000);
    tl.DrawTextNDC(.5, 0.79, line);
    sprintf(line, "N(ev) = %7.1f +/- %5.1f", events, errevents);
    tl.DrawTextNDC(.5, 0.73, line);

    c0->SaveAs("masspi0pi0.eps");
//    massPi0Pi0.SetXTitle("m(#pi^{0}#pi^{0}) [GeV]");
//    //   massPi0Pi0.SetStats(0);
//    massPi0Pi0.SetTitle("");
//    massPi0Pi0.Draw();

//    c0->SaveAs("masspi0pi0.eps");

    n_Pi0.SetXTitle("N(#pi^{0})");
    n_Pi0.SetTitle("");
    n_Pi0.Draw();

    c0->SaveAs("nPi0.eps");

    massPi0full.SetXTitle("m(#gamma #gamma) [GeV]");
    massPi0full.SetStats(0);
    massPi0full.SetTitle("");
    massPi0full.Draw("") ;
    c0->SaveAs("massPi0full.eps");

    massPi0Pi0full.SetXTitle("m(#pi^{0} #pi^{0}) [GeV]");
    massPi0Pi0full.SetStats(0);
    massPi0Pi0full.SetTitle("");
    massPi0Pi0full.Draw("") ;
    c0->SaveAs("massPi0Pi0full.eps");

    massetafull.SetXTitle("m(#gamma #gamma) [GeV]");
    massetafull.SetStats(0);
    massetafull.SetTitle("");
    massetafull.Draw("") ;
    c0->SaveAs("massetafull.eps");

    masseta3pi0full.SetXTitle("m(#eta #rightarrow #pi^{0} #pi^{0} #pi^{0}) [GeV]");
    masseta3pi0full.SetStats(0);
    masseta3pi0full.SetTitle("");
    masseta3pi0full.Draw("") ;
    c0->SaveAs("masseta3pi0full.eps");
}
Esempio n. 18
0
void test3()
{
//=========Macro generated from canvas: default_Canvas/defaultCanvas
//=========  (Fri May  6 10:50:13 2016) by ROOT version6.04/10
   TCanvas *default_Canvas = new TCanvas("default_Canvas", "defaultCanvas",0,0,700,500);
   gStyle->SetOptStat(0);
   gStyle->SetOptTitle(0);
   default_Canvas->SetHighLightColor(2);
   default_Canvas->Range(0,0,1,1);
   default_Canvas->SetFillColor(0);
   default_Canvas->SetBorderMode(0);
   default_Canvas->SetBorderSize(2);
   default_Canvas->SetTickx(1);
   default_Canvas->SetTicky(1);
   default_Canvas->SetLeftMargin(0.14);
   default_Canvas->SetRightMargin(0.05);
   default_Canvas->SetTopMargin(0.05);
   default_Canvas->SetBottomMargin(0.16);
   default_Canvas->SetFrameLineWidth(2);
   default_Canvas->SetFrameBorderMode(0);
  
// ------------>Primitives in pad: upperPad
   TPad *upperPad = new TPad("upperPad", "upperPad",0.005,0.05,0.995,0.995);
   upperPad->Draw();
   upperPad->cd();
   upperPad->Range(1.567901,0.02811051,4.654321,0.1367104);
   upperPad->SetFillColor(0);
   upperPad->SetFillStyle(4000);
   upperPad->SetBorderMode(0);
   upperPad->SetBorderSize(2);
   upperPad->SetTickx(1);
   upperPad->SetTicky(1);
   upperPad->SetLeftMargin(0.14);
   upperPad->SetRightMargin(0.05);
   upperPad->SetTopMargin(0.05);
   upperPad->SetBottomMargin(0.14);
   upperPad->SetFrameLineWidth(2);
   upperPad->SetFrameBorderMode(0);
   upperPad->SetFrameLineWidth(2);
   upperPad->SetFrameBorderMode(0);
   
   TH1F *test3_red_0_0_norm__1 = new TH1F("test3_red_0_0_norm__1","ETA",10,2,4.5);
   test3_red_0_0_norm__1->SetBinContent(1,0.1040398);
   test3_red_0_0_norm__1->SetBinContent(2,0.1186439);
   test3_red_0_0_norm__1->SetBinContent(3,0.1256071);
   test3_red_0_0_norm__1->SetBinContent(4,0.1229555);
   test3_red_0_0_norm__1->SetBinContent(5,0.118442);
   test3_red_0_0_norm__1->SetBinContent(6,0.1127067);
   test3_red_0_0_norm__1->SetBinContent(7,0.09951538);
   test3_red_0_0_norm__1->SetBinContent(8,0.08332527);
   test3_red_0_0_norm__1->SetBinContent(9,0.06651872);
   test3_red_0_0_norm__1->SetBinContent(10,0.0482457);
   test3_red_0_0_norm__1->SetBinError(1,0.001708584);
   test3_red_0_0_norm__1->SetBinError(2,0.001736969);
   test3_red_0_0_norm__1->SetBinError(3,0.001484444);
   test3_red_0_0_norm__1->SetBinError(4,0.001426268);
   test3_red_0_0_norm__1->SetBinError(5,0.001336676);
   test3_red_0_0_norm__1->SetBinError(6,0.00122978);
   test3_red_0_0_norm__1->SetBinError(7,0.00125216);
   test3_red_0_0_norm__1->SetBinError(8,0.00113555);
   test3_red_0_0_norm__1->SetBinError(9,0.0009819959);
   test3_red_0_0_norm__1->SetBinError(10,0.0009418311);
   test3_red_0_0_norm__1->SetEntries(58129);
   test3_red_0_0_norm__1->SetStats(0);

   Int_t ci;      // for color index setting
   TColor *color; // for color definition with alpha
   ci = TColor::GetColor("#ff0000");
   test3_red_0_0_norm__1->SetFillColor(ci);
   test3_red_0_0_norm__1->SetFillStyle(0);

   ci = TColor::GetColor("#ff0000");
   test3_red_0_0_norm__1->SetLineColor(ci);
   test3_red_0_0_norm__1->SetLineWidth(2);

   ci = TColor::GetColor("#ff0000");
   test3_red_0_0_norm__1->SetMarkerColor(ci);
   test3_red_0_0_norm__1->SetMarkerStyle(20);
   test3_red_0_0_norm__1->GetXaxis()->SetTitle("#eta");
   test3_red_0_0_norm__1->GetXaxis()->SetNdivisions(1005);
   test3_red_0_0_norm__1->GetXaxis()->SetLabelFont(132);
   test3_red_0_0_norm__1->GetXaxis()->SetLabelOffset(0.02);
   test3_red_0_0_norm__1->GetXaxis()->SetLabelSize(0.05);
   test3_red_0_0_norm__1->GetXaxis()->SetTitleSize(0.06);
   test3_red_0_0_norm__1->GetXaxis()->SetTitleFont(132);
   test3_red_0_0_norm__1->GetYaxis()->SetNdivisions(505);
   test3_red_0_0_norm__1->GetYaxis()->SetLabelFont(132);
   test3_red_0_0_norm__1->GetYaxis()->SetLabelSize(0.05);
   test3_red_0_0_norm__1->GetYaxis()->SetTitleSize(0.06);
   test3_red_0_0_norm__1->GetYaxis()->SetTitleFont(132);
   test3_red_0_0_norm__1->GetZaxis()->SetLabelFont(132);
   test3_red_0_0_norm__1->GetZaxis()->SetLabelSize(0.05);
   test3_red_0_0_norm__1->GetZaxis()->SetTitleSize(0.06);
   test3_red_0_0_norm__1->GetZaxis()->SetTitleFont(132);
   test3_red_0_0_norm__1->Draw("");
   Double_t xAxis1[11] = {2, 2.25, 2.5, 2.75, 3, 3.25, 3.5, 3.75, 4, 4.25, 4.5}; 
   
   TH1F *test3_green_0_1_norm__2 = new TH1F("test3_green_0_1_norm__2","ETA",10, xAxis1);
   test3_green_0_1_norm__2->SetBinContent(1,0.1214835);
   test3_green_0_1_norm__2->SetBinContent(2,0.1235428);
   test3_green_0_1_norm__2->SetBinContent(3,0.1252758);
   test3_green_0_1_norm__2->SetBinContent(4,0.1207572);
   test3_green_0_1_norm__2->SetBinContent(5,0.1150848);
   test3_green_0_1_norm__2->SetBinContent(6,0.1056844);
   test3_green_0_1_norm__2->SetBinContent(7,0.09450962);
   test3_green_0_1_norm__2->SetBinContent(8,0.07910584);
   test3_green_0_1_norm__2->SetBinContent(9,0.06467657);
   test3_green_0_1_norm__2->SetBinContent(10,0.04987957);
   test3_green_0_1_norm__2->SetEntries(10);
   test3_green_0_1_norm__2->SetStats(0);

   ci = TColor::GetColor("#00ff00");
   test3_green_0_1_norm__2->SetFillColor(ci);
   test3_green_0_1_norm__2->SetFillStyle(0);

   ci = TColor::GetColor("#00ff00");
   test3_green_0_1_norm__2->SetLineColor(ci);
   test3_green_0_1_norm__2->SetLineWidth(2);

   ci = TColor::GetColor("#00ff00");
   test3_green_0_1_norm__2->SetMarkerColor(ci);
   test3_green_0_1_norm__2->SetMarkerStyle(20);
   test3_green_0_1_norm__2->GetXaxis()->SetTitle("#eta");
   test3_green_0_1_norm__2->GetXaxis()->SetNdivisions(1005);
   test3_green_0_1_norm__2->GetXaxis()->SetLabelFont(132);
   test3_green_0_1_norm__2->GetXaxis()->SetLabelOffset(0.02);
   test3_green_0_1_norm__2->GetXaxis()->SetLabelSize(0.05);
   test3_green_0_1_norm__2->GetXaxis()->SetTitleSize(0.06);
   test3_green_0_1_norm__2->GetXaxis()->SetTitleFont(132);
   test3_green_0_1_norm__2->GetYaxis()->SetNdivisions(505);
   test3_green_0_1_norm__2->GetYaxis()->SetLabelFont(132);
   test3_green_0_1_norm__2->GetYaxis()->SetLabelSize(0.05);
   test3_green_0_1_norm__2->GetYaxis()->SetTitleSize(0.06);
   test3_green_0_1_norm__2->GetYaxis()->SetTitleFont(132);
   test3_green_0_1_norm__2->GetZaxis()->SetLabelFont(132);
   test3_green_0_1_norm__2->GetZaxis()->SetLabelSize(0.05);
   test3_green_0_1_norm__2->GetZaxis()->SetTitleSize(0.06);
   test3_green_0_1_norm__2->GetZaxis()->SetTitleFont(132);
   test3_green_0_1_norm__2->Draw("same");
   
   TLegend *leg = new TLegend(0.2,0.7,0.4,0.85,NULL,"brNDC");
   leg->SetBorderSize(0);
   leg->SetTextFont(132);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(2);
   leg->SetFillColor(10);
   leg->SetFillStyle(0);
   TLegendEntry *entry=leg->AddEntry("MuonTrackingMC2015RW_Sim09/ETA_tot","T&P","lep");

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

   ci = TColor::GetColor("#ff0000");
   entry->SetMarkerColor(ci);
   entry->SetMarkerStyle(20);
   entry->SetMarkerSize(1);
   entry->SetTextFont(132);
   entry=leg->AddEntry("MuonUbsTrackingMC2015/ETA_tot","Truth","lep");

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

   ci = TColor::GetColor("#00ff00");
   entry->SetMarkerColor(ci);
   entry->SetMarkerStyle(20);
   entry->SetMarkerSize(1);
   entry->SetTextFont(132);
   leg->Draw();
   
   TH1F *test3_red_0_0_norm_copy__3 = new TH1F("test3_red_0_0_norm_copy__3","ETA",10,2,4.5);
   test3_red_0_0_norm_copy__3->SetBinContent(1,0.1040398);
   test3_red_0_0_norm_copy__3->SetBinContent(2,0.1186439);
   test3_red_0_0_norm_copy__3->SetBinContent(3,0.1256071);
   test3_red_0_0_norm_copy__3->SetBinContent(4,0.1229555);
   test3_red_0_0_norm_copy__3->SetBinContent(5,0.118442);
   test3_red_0_0_norm_copy__3->SetBinContent(6,0.1127067);
   test3_red_0_0_norm_copy__3->SetBinContent(7,0.09951538);
   test3_red_0_0_norm_copy__3->SetBinContent(8,0.08332527);
   test3_red_0_0_norm_copy__3->SetBinContent(9,0.06651872);
   test3_red_0_0_norm_copy__3->SetBinContent(10,0.0482457);
   test3_red_0_0_norm_copy__3->SetBinError(1,0.001708584);
   test3_red_0_0_norm_copy__3->SetBinError(2,0.001736969);
   test3_red_0_0_norm_copy__3->SetBinError(3,0.001484444);
   test3_red_0_0_norm_copy__3->SetBinError(4,0.001426268);
   test3_red_0_0_norm_copy__3->SetBinError(5,0.001336676);
   test3_red_0_0_norm_copy__3->SetBinError(6,0.00122978);
   test3_red_0_0_norm_copy__3->SetBinError(7,0.00125216);
   test3_red_0_0_norm_copy__3->SetBinError(8,0.00113555);
   test3_red_0_0_norm_copy__3->SetBinError(9,0.0009819959);
   test3_red_0_0_norm_copy__3->SetBinError(10,0.0009418311);
   test3_red_0_0_norm_copy__3->SetEntries(58129);
   test3_red_0_0_norm_copy__3->SetDirectory(0);
   test3_red_0_0_norm_copy__3->SetStats(0);

   ci = TColor::GetColor("#ff0000");
   test3_red_0_0_norm_copy__3->SetFillColor(ci);
   test3_red_0_0_norm_copy__3->SetFillStyle(0);

   ci = TColor::GetColor("#ff0000");
   test3_red_0_0_norm_copy__3->SetLineColor(ci);
   test3_red_0_0_norm_copy__3->SetLineWidth(2);

   ci = TColor::GetColor("#ff0000");
   test3_red_0_0_norm_copy__3->SetMarkerColor(ci);
   test3_red_0_0_norm_copy__3->SetMarkerStyle(20);
   test3_red_0_0_norm_copy__3->GetXaxis()->SetTitle("#eta");
   test3_red_0_0_norm_copy__3->GetXaxis()->SetNdivisions(1005);
   test3_red_0_0_norm_copy__3->GetXaxis()->SetLabelFont(132);
   test3_red_0_0_norm_copy__3->GetXaxis()->SetLabelOffset(0.02);
   test3_red_0_0_norm_copy__3->GetXaxis()->SetLabelSize(0.05);
   test3_red_0_0_norm_copy__3->GetXaxis()->SetTitleSize(0.06);
   test3_red_0_0_norm_copy__3->GetXaxis()->SetTitleFont(132);
   test3_red_0_0_norm_copy__3->GetYaxis()->SetNdivisions(505);
   test3_red_0_0_norm_copy__3->GetYaxis()->SetLabelFont(132);
   test3_red_0_0_norm_copy__3->GetYaxis()->SetLabelSize(0.05);
   test3_red_0_0_norm_copy__3->GetYaxis()->SetTitleSize(0.06);
   test3_red_0_0_norm_copy__3->GetYaxis()->SetTitleFont(132);
   test3_red_0_0_norm_copy__3->GetZaxis()->SetLabelFont(132);
   test3_red_0_0_norm_copy__3->GetZaxis()->SetLabelSize(0.05);
   test3_red_0_0_norm_copy__3->GetZaxis()->SetTitleSize(0.06);
   test3_red_0_0_norm_copy__3->GetZaxis()->SetTitleFont(132);
   test3_red_0_0_norm_copy__3->Draw("sameaxis");
   upperPad->Modified();
   default_Canvas->cd();
   default_Canvas->Modified();
   default_Canvas->cd();
   default_Canvas->SetSelected(default_Canvas);
}
Esempio n. 19
0
void zj_dphi_8TeV_log()
{
//=========Macro generated from canvas: default_Canvas/defaultCanvas
//=========  (Thu Apr 28 10:19:34 2016) by ROOT version6.04/10
   TCanvas *default_Canvas = new TCanvas("default_Canvas", "defaultCanvas",0,0,800,800);
   gStyle->SetOptStat(0);
   gStyle->SetOptTitle(0);
   default_Canvas->SetHighLightColor(2);
   default_Canvas->Range(0,0,1,1);
   default_Canvas->SetFillColor(0);
   default_Canvas->SetBorderMode(0);
   default_Canvas->SetBorderSize(2);
   default_Canvas->SetTickx(1);
   default_Canvas->SetTicky(1);
   default_Canvas->SetLeftMargin(0.14);
   default_Canvas->SetRightMargin(0.05);
   default_Canvas->SetTopMargin(0.05);
   default_Canvas->SetBottomMargin(0.16);
   default_Canvas->SetFrameLineWidth(2);
   default_Canvas->SetFrameBorderMode(0);
  
// ------------>Primitives in pad: bottomPad
   TPad *bottomPad = new TPad("bottomPad", "bottomPad",0.005,0.05,0.995,0.995);
   bottomPad->Draw();
   bottomPad->cd();
   bottomPad->Range(0,0,1,1);
   bottomPad->SetFillColor(0);
   bottomPad->SetFillStyle(4000);
   bottomPad->SetBorderMode(0);
   bottomPad->SetBorderSize(2);
   bottomPad->SetTickx(1);
   bottomPad->SetTicky(1);
   bottomPad->SetLeftMargin(0.14);
   bottomPad->SetRightMargin(0.05);
   bottomPad->SetTopMargin(0.05);
   bottomPad->SetBottomMargin(0.16);
   bottomPad->SetFrameLineWidth(2);
   bottomPad->SetFrameBorderMode(0);
   bottomPad->Modified();
   default_Canvas->cd();
  
// ------------>Primitives in pad: upperPad
   TPad *upperPad = new TPad("upperPad", "upperPad",0.005,0.05,0.995,0.995);
   upperPad->Draw();
   upperPad->cd();
   upperPad->Range(-0.5429913,-2.062865,3.335518,1.327192);
   upperPad->SetFillColor(0);
   upperPad->SetFillStyle(4000);
   upperPad->SetBorderMode(0);
   upperPad->SetBorderSize(2);
   upperPad->SetLogy();
   upperPad->SetTickx(1);
   upperPad->SetTicky(1);
   upperPad->SetLeftMargin(0.14);
   upperPad->SetRightMargin(0.05);
   upperPad->SetTopMargin(0.05);
   upperPad->SetBottomMargin(0.33);
   upperPad->SetFrameLineWidth(2);
   upperPad->SetFrameBorderMode(0);
   upperPad->SetFrameLineWidth(2);
   upperPad->SetFrameBorderMode(0);
   
   TH1F *z_dphi_toterr__37 = new TH1F("z_dphi_toterr__37","z_dphi",6,0,3.141593);
   z_dphi_toterr__37->SetBinContent(1,0.261202);
   z_dphi_toterr__37->SetBinContent(2,0.3162337);
   z_dphi_toterr__37->SetBinContent(3,0.3852335);
   z_dphi_toterr__37->SetBinContent(4,0.7150939);
   z_dphi_toterr__37->SetBinContent(5,1.796506);
   z_dphi_toterr__37->SetBinContent(6,7.258657);
   z_dphi_toterr__37->SetBinContent(7,3.800624);
   z_dphi_toterr__37->SetBinError(1,0.03375302);
   z_dphi_toterr__37->SetBinError(2,0.03634611);
   z_dphi_toterr__37->SetBinError(3,0.0427511);
   z_dphi_toterr__37->SetBinError(4,0.05747346);
   z_dphi_toterr__37->SetBinError(5,0.1278198);
   z_dphi_toterr__37->SetBinError(6,0.3295685);
   z_dphi_toterr__37->SetBinError(7,0.1725617);
   z_dphi_toterr__37->SetEntries(14);
   z_dphi_toterr__37->SetStats(0);

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

   ci = TColor::GetColor("#ffff00");
   z_dphi_toterr__37->SetLineColor(ci);
   z_dphi_toterr__37->SetLineWidth(2);

   ci = TColor::GetColor("#ffff00");
   z_dphi_toterr__37->SetMarkerColor(ci);
   z_dphi_toterr__37->SetMarkerStyle(0);
   z_dphi_toterr__37->GetXaxis()->SetNdivisions(4);
   z_dphi_toterr__37->GetXaxis()->SetLabelFont(132);
   z_dphi_toterr__37->GetXaxis()->SetLabelOffset(999);
   z_dphi_toterr__37->GetXaxis()->SetLabelSize(0);
   z_dphi_toterr__37->GetXaxis()->SetTitleSize(0.06);
   z_dphi_toterr__37->GetXaxis()->SetTitleFont(132);
   z_dphi_toterr__37->GetYaxis()->SetTitle("d#sigma(#it{Zj})/d|#Delta#it{#phi} [pb/rad]");
   z_dphi_toterr__37->GetYaxis()->SetLabelFont(132);
   z_dphi_toterr__37->GetYaxis()->SetLabelSize(0.05);
   z_dphi_toterr__37->GetYaxis()->SetTitleSize(0.06);
   z_dphi_toterr__37->GetYaxis()->SetTitleOffset(1.3);
   z_dphi_toterr__37->GetYaxis()->SetTitleFont(132);
   z_dphi_toterr__37->GetZaxis()->SetLabelFont(132);
   z_dphi_toterr__37->GetZaxis()->SetLabelSize(0.05);
   z_dphi_toterr__37->GetZaxis()->SetTitleSize(0.06);
   z_dphi_toterr__37->GetZaxis()->SetTitleFont(132);
   z_dphi_toterr__37->Draw("e2");
   
   TH1F *z_dphi_staterr__38 = new TH1F("z_dphi_staterr__38","z_dphi",6,0,3.141593);
   z_dphi_staterr__38->SetBinContent(1,0.261202);
   z_dphi_staterr__38->SetBinContent(2,0.3162337);
   z_dphi_staterr__38->SetBinContent(3,0.3852335);
   z_dphi_staterr__38->SetBinContent(4,0.7150939);
   z_dphi_staterr__38->SetBinContent(5,1.796506);
   z_dphi_staterr__38->SetBinContent(6,7.258657);
   z_dphi_staterr__38->SetBinContent(7,3.800624);
   z_dphi_staterr__38->SetBinError(1,0.01764622);
   z_dphi_staterr__38->SetBinError(2,0.01951211);
   z_dphi_staterr__38->SetBinError(3,0.02108379);
   z_dphi_staterr__38->SetBinError(4,0.03021233);
   z_dphi_staterr__38->SetBinError(5,0.04899558);
   z_dphi_staterr__38->SetBinError(6,0.1002775);
   z_dphi_staterr__38->SetBinError(7,0.05250516);
   z_dphi_staterr__38->SetEntries(14);
   z_dphi_staterr__38->SetStats(0);

   ci = TColor::GetColor("#ff9933");
   z_dphi_staterr__38->SetFillColor(ci);

   ci = TColor::GetColor("#ff9933");
   z_dphi_staterr__38->SetLineColor(ci);
   z_dphi_staterr__38->SetLineWidth(2);

   ci = TColor::GetColor("#ff9933");
   z_dphi_staterr__38->SetMarkerColor(ci);
   z_dphi_staterr__38->SetMarkerStyle(0);
   z_dphi_staterr__38->GetXaxis()->SetNdivisions(4);
   z_dphi_staterr__38->GetXaxis()->SetLabelFont(132);
   z_dphi_staterr__38->GetXaxis()->SetLabelOffset(999);
   z_dphi_staterr__38->GetXaxis()->SetLabelSize(0);
   z_dphi_staterr__38->GetXaxis()->SetTitleSize(0.06);
   z_dphi_staterr__38->GetXaxis()->SetTitleFont(132);
   z_dphi_staterr__38->GetYaxis()->SetTitle("d#sigma(#it{Zj})/d|#Delta#it{#phi} [pb/rad]");
   z_dphi_staterr__38->GetYaxis()->SetLabelFont(132);
   z_dphi_staterr__38->GetYaxis()->SetLabelSize(0.05);
   z_dphi_staterr__38->GetYaxis()->SetTitleSize(0.06);
   z_dphi_staterr__38->GetYaxis()->SetTitleFont(132);
   z_dphi_staterr__38->GetZaxis()->SetLabelFont(132);
   z_dphi_staterr__38->GetZaxis()->SetLabelSize(0.05);
   z_dphi_staterr__38->GetZaxis()->SetTitleSize(0.06);
   z_dphi_staterr__38->GetZaxis()->SetTitleFont(132);
   z_dphi_staterr__38->Draw("e2same");
   
   Double_t dphi_toterrs_fx3043[6] = {
   0.3403392,
   0.863938,
   1.387537,
   1.911136,
   2.434734,
   2.958333};
   Double_t dphi_toterrs_fy3043[6] = {
   0.1926519,
   0.2207154,
   0.3546338,
   0.6864677,
   2.01515,
   7.779723};
   Double_t dphi_toterrs_felx3043[6] = {
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t dphi_toterrs_fely3043[6] = {
   0.03415733,
   0.03577312,
   0.05682396,
   0.09598937,
   0.1897309,
   0.5023379};
   Double_t dphi_toterrs_fehx3043[6] = {
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t dphi_toterrs_fehy3043[6] = {
   0.04673612,
   0.05211068,
   0.07287587,
   0.1207667,
   0.143423,
   0.3949306};
   TGraphAsymmErrors *grae = new TGraphAsymmErrors(6,dphi_toterrs_fx3043,dphi_toterrs_fy3043,dphi_toterrs_felx3043,dphi_toterrs_fehx3043,dphi_toterrs_fely3043,dphi_toterrs_fehy3043);
   grae->SetName("dphi_toterrs");
   grae->SetTitle("");
   grae->SetFillColor(1);
   grae->SetLineWidth(2);
   grae->SetMarkerStyle(24);
   
   TH1F *Graph_dphi_toterrs3043 = new TH1F("Graph_dphi_toterrs3043","",100,0.07853982,3.220132);
   Graph_dphi_toterrs3043->SetMinimum(0.1426451);
   Graph_dphi_toterrs3043->SetMaximum(8.976269);
   Graph_dphi_toterrs3043->SetDirectory(0);
   Graph_dphi_toterrs3043->SetStats(0);
   Graph_dphi_toterrs3043->SetLineWidth(2);
   Graph_dphi_toterrs3043->SetMarkerStyle(0);
   Graph_dphi_toterrs3043->GetXaxis()->SetNdivisions(4);
   Graph_dphi_toterrs3043->GetXaxis()->SetLabelFont(132);
   Graph_dphi_toterrs3043->GetXaxis()->SetLabelOffset(999);
   Graph_dphi_toterrs3043->GetXaxis()->SetLabelSize(0);
   Graph_dphi_toterrs3043->GetXaxis()->SetTitleSize(0.06);
   Graph_dphi_toterrs3043->GetXaxis()->SetTitleFont(132);
   Graph_dphi_toterrs3043->GetYaxis()->SetTitle("d#sigma(#it{Zj})/d|#Delta#it{#phi} [pb/rad]");
   Graph_dphi_toterrs3043->GetYaxis()->SetLabelFont(132);
   Graph_dphi_toterrs3043->GetYaxis()->SetLabelSize(0.05);
   Graph_dphi_toterrs3043->GetYaxis()->SetTitleSize(0.06);
   Graph_dphi_toterrs3043->GetYaxis()->SetTitleFont(132);
   Graph_dphi_toterrs3043->GetZaxis()->SetLabelFont(132);
   Graph_dphi_toterrs3043->GetZaxis()->SetLabelSize(0.05);
   Graph_dphi_toterrs3043->GetZaxis()->SetTitleSize(0.06);
   Graph_dphi_toterrs3043->GetZaxis()->SetTitleFont(132);
   grae->SetHistogram(Graph_dphi_toterrs3043);
   
   grae->Draw("p1p");
   
   Double_t _fx3044[6] = {
   0.3403392,
   0.863938,
   1.387537,
   1.911136,
   2.434734,
   2.958333};
   Double_t _fy3044[6] = {
   0.1926519,
   0.2207154,
   0.3546338,
   0.6864677,
   2.01515,
   7.779723};
   Double_t _felx3044[6] = {
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t _fely3044[6] = {
   0.02873042,
   0.03223617,
   0.04948444,
   0.07740101,
   0.1117696,
   0.3251484};
   Double_t _fehx3044[6] = {
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t _fehy3044[6] = {
   0.03948655,
   0.04420709,
   0.06698785,
   0.1028379,
   0.1104173,
   0.2636435};
   grae = new TGraphAsymmErrors(6,_fx3044,_fy3044,_felx3044,_fehx3044,_fely3044,_fehy3044);
   grae->SetName("");
   grae->SetTitle("");
   grae->SetFillColor(1);
   grae->SetLineWidth(2);
   grae->SetMarkerStyle(24);
   
   TH1F *Graph_Graph3044 = new TH1F("Graph_Graph3044","",100,0.07853982,3.220132);
   Graph_Graph3044->SetMinimum(0.1475293);
   Graph_Graph3044->SetMaximum(8.831311);
   Graph_Graph3044->SetDirectory(0);
   Graph_Graph3044->SetStats(0);
   Graph_Graph3044->SetLineWidth(2);
   Graph_Graph3044->SetMarkerStyle(0);
   Graph_Graph3044->GetXaxis()->SetNdivisions(4);
   Graph_Graph3044->GetXaxis()->SetLabelFont(132);
   Graph_Graph3044->GetXaxis()->SetLabelOffset(999);
   Graph_Graph3044->GetXaxis()->SetLabelSize(0);
   Graph_Graph3044->GetXaxis()->SetTitleSize(0.06);
   Graph_Graph3044->GetXaxis()->SetTitleFont(132);
   Graph_Graph3044->GetYaxis()->SetTitle("d#sigma(#it{Zj})/d|#Delta#it{#phi} [pb/rad]");
   Graph_Graph3044->GetYaxis()->SetLabelFont(132);
   Graph_Graph3044->GetYaxis()->SetLabelSize(0.05);
   Graph_Graph3044->GetYaxis()->SetTitleSize(0.06);
   Graph_Graph3044->GetYaxis()->SetTitleFont(132);
   Graph_Graph3044->GetZaxis()->SetLabelFont(132);
   Graph_Graph3044->GetZaxis()->SetLabelSize(0.05);
   Graph_Graph3044->GetZaxis()->SetTitleSize(0.06);
   Graph_Graph3044->GetZaxis()->SetTitleFont(132);
   grae->SetHistogram(Graph_Graph3044);
   
   grae->Draw("p1p");
   
   Double_t dphi_toterrs_fx3045[6] = {
   0.1832596,
   0.7068583,
   1.230457,
   1.754056,
   2.277655,
   2.801253};
   Double_t dphi_toterrs_fy3045[6] = {
   0.3071206,
   0.3788296,
   0.5235754,
   0.9026085,
   2.09773,
   8.042891};
   Double_t dphi_toterrs_felx3045[6] = {
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t dphi_toterrs_fely3045[6] = {
   0.03223837,
   0.05049376,
   0.0513308,
   0.07859791,
   0.1671821,
   0.6048482};
   Double_t dphi_toterrs_fehx3045[6] = {
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t dphi_toterrs_fehy3045[6] = {
   0.05069997,
   0.04670219,
   0.05741781,
   0.0972528,
   0.2140117,
   0.6377428};
   grae = new TGraphAsymmErrors(6,dphi_toterrs_fx3045,dphi_toterrs_fy3045,dphi_toterrs_felx3045,dphi_toterrs_fehx3045,dphi_toterrs_fely3045,dphi_toterrs_fehy3045);
   grae->SetName("dphi_toterrs");
   grae->SetTitle("");
   grae->SetFillColor(1);
   grae->SetLineWidth(2);
   grae->SetMarkerStyle(20);
   
   TH1F *Graph_dphi_toterrs3045 = new TH1F("Graph_dphi_toterrs3045","",100,0,3.063053);
   Graph_dphi_toterrs3045->SetMinimum(0.247394);
   Graph_dphi_toterrs3045->SetMaximum(9.521209);
   Graph_dphi_toterrs3045->SetDirectory(0);
   Graph_dphi_toterrs3045->SetStats(0);
   Graph_dphi_toterrs3045->SetLineWidth(2);
   Graph_dphi_toterrs3045->SetMarkerStyle(0);
   Graph_dphi_toterrs3045->GetXaxis()->SetNdivisions(4);
   Graph_dphi_toterrs3045->GetXaxis()->SetLabelFont(132);
   Graph_dphi_toterrs3045->GetXaxis()->SetLabelOffset(999);
   Graph_dphi_toterrs3045->GetXaxis()->SetLabelSize(0);
   Graph_dphi_toterrs3045->GetXaxis()->SetTitleSize(0.06);
   Graph_dphi_toterrs3045->GetXaxis()->SetTitleFont(132);
   Graph_dphi_toterrs3045->GetYaxis()->SetTitle("d#sigma(#it{Zj})/d|#Delta#it{#phi} [pb/rad]");
   Graph_dphi_toterrs3045->GetYaxis()->SetLabelFont(132);
   Graph_dphi_toterrs3045->GetYaxis()->SetLabelSize(0.05);
   Graph_dphi_toterrs3045->GetYaxis()->SetTitleSize(0.06);
   Graph_dphi_toterrs3045->GetYaxis()->SetTitleFont(132);
   Graph_dphi_toterrs3045->GetZaxis()->SetLabelFont(132);
   Graph_dphi_toterrs3045->GetZaxis()->SetLabelSize(0.05);
   Graph_dphi_toterrs3045->GetZaxis()->SetTitleSize(0.06);
   Graph_dphi_toterrs3045->GetZaxis()->SetTitleFont(132);
   grae->SetHistogram(Graph_dphi_toterrs3045);
   
   grae->Draw("p1p");
   
   Double_t _fx3046[6] = {
   0.1832596,
   0.7068583,
   1.230457,
   1.754056,
   2.277655,
   2.801253};
   Double_t _fy3046[6] = {
   0.3071206,
   0.3788296,
   0.5235754,
   0.9026085,
   2.09773,
   8.042891};
   Double_t _felx3046[6] = {
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t _fely3046[6] = {
   0.02710968,
   0.03295216,
   0.04124188,
   0.06402796,
   0.1338949,
   0.4694553};
   Double_t _fehx3046[6] = {
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t _fehy3046[6] = {
   0.03469016,
   0.04020747,
   0.048986,
   0.07362466,
   0.1488417,
   0.5027875};
   grae = new TGraphAsymmErrors(6,_fx3046,_fy3046,_felx3046,_fehx3046,_fely3046,_fehy3046);
   grae->SetName("");
   grae->SetTitle("");
   grae->SetFillColor(1);
   grae->SetLineWidth(2);
   grae->SetMarkerStyle(20);
   
   TH1F *Graph_Graph3046 = new TH1F("Graph_Graph3046","",100,0,3.063053);
   Graph_Graph3046->SetMinimum(0.2520099);
   Graph_Graph3046->SetMaximum(9.372245);
   Graph_Graph3046->SetDirectory(0);
   Graph_Graph3046->SetStats(0);
   Graph_Graph3046->SetLineWidth(2);
   Graph_Graph3046->SetMarkerStyle(0);
   Graph_Graph3046->GetXaxis()->SetNdivisions(4);
   Graph_Graph3046->GetXaxis()->SetLabelFont(132);
   Graph_Graph3046->GetXaxis()->SetLabelOffset(999);
   Graph_Graph3046->GetXaxis()->SetLabelSize(0);
   Graph_Graph3046->GetXaxis()->SetTitleSize(0.06);
   Graph_Graph3046->GetXaxis()->SetTitleFont(132);
   Graph_Graph3046->GetYaxis()->SetTitle("d#sigma(#it{Zj})/d|#Delta#it{#phi} [pb/rad]");
   Graph_Graph3046->GetYaxis()->SetLabelFont(132);
   Graph_Graph3046->GetYaxis()->SetLabelSize(0.05);
   Graph_Graph3046->GetYaxis()->SetTitleSize(0.06);
   Graph_Graph3046->GetYaxis()->SetTitleFont(132);
   Graph_Graph3046->GetZaxis()->SetLabelFont(132);
   Graph_Graph3046->GetZaxis()->SetLabelSize(0.05);
   Graph_Graph3046->GetZaxis()->SetTitleSize(0.06);
   Graph_Graph3046->GetZaxis()->SetTitleFont(132);
   grae->SetHistogram(Graph_Graph3046);
   
   grae->Draw("p1p");
   
   TLegend *leg = new TLegend(0.2,0.57,0.5,0.82,NULL,"brNDC");
   leg->SetBorderSize(0);
   leg->SetTextFont(132);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(2);
   leg->SetFillColor(10);
   leg->SetFillStyle(0);
   TLegendEntry *entry=leg->AddEntry("data_stat","Data_{stat}","f");

   ci = TColor::GetColor("#ff9933");
   entry->SetFillColor(ci);
   entry->SetFillStyle(1001);
   entry->SetLineStyle(1);
   entry->SetLineWidth(2);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(132);
   entry=leg->AddEntry("data_tot","Data_{tot}","f");

   ci = TColor::GetColor("#ffff00");
   entry->SetFillColor(ci);
   entry->SetFillStyle(1001);
   entry->SetLineStyle(1);
   entry->SetLineWidth(2);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(132);
   entry=leg->AddEntry("powheg_temp","POWHEG","p");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(20);
   entry->SetMarkerSize(1);
   entry->SetTextFont(132);
   entry=leg->AddEntry("amcatnlo_temp","aMC@NLO","p");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(24);
   entry->SetMarkerSize(1);
   entry->SetTextFont(132);
   leg->Draw();
   
   TPaveText *pt = new TPaveText(0.2,0.8,0.55,0.95,"brNDC");
   pt->SetBorderSize(0);
   pt->SetFillStyle(0);
   pt->SetLineWidth(2);
   pt->SetTextFont(132);
   TText *AText = pt->AddText("LHCb, #sqrt{s} = 8 TeV");
   pt->Draw();
   
   TH1F *z_dphi_toterr_copy__39 = new TH1F("z_dphi_toterr_copy__39","z_dphi",6,0,3.141593);
   z_dphi_toterr_copy__39->SetBinContent(1,0.261202);
   z_dphi_toterr_copy__39->SetBinContent(2,0.3162337);
   z_dphi_toterr_copy__39->SetBinContent(3,0.3852335);
   z_dphi_toterr_copy__39->SetBinContent(4,0.7150939);
   z_dphi_toterr_copy__39->SetBinContent(5,1.796506);
   z_dphi_toterr_copy__39->SetBinContent(6,7.258657);
   z_dphi_toterr_copy__39->SetBinContent(7,3.800624);
   z_dphi_toterr_copy__39->SetBinError(1,0.03375302);
   z_dphi_toterr_copy__39->SetBinError(2,0.03634611);
   z_dphi_toterr_copy__39->SetBinError(3,0.0427511);
   z_dphi_toterr_copy__39->SetBinError(4,0.05747346);
   z_dphi_toterr_copy__39->SetBinError(5,0.1278198);
   z_dphi_toterr_copy__39->SetBinError(6,0.3295685);
   z_dphi_toterr_copy__39->SetBinError(7,0.1725617);
   z_dphi_toterr_copy__39->SetEntries(14);
   z_dphi_toterr_copy__39->SetDirectory(0);
   z_dphi_toterr_copy__39->SetStats(0);

   ci = TColor::GetColor("#ffff00");
   z_dphi_toterr_copy__39->SetFillColor(ci);

   ci = TColor::GetColor("#ffff00");
   z_dphi_toterr_copy__39->SetLineColor(ci);
   z_dphi_toterr_copy__39->SetLineWidth(2);

   ci = TColor::GetColor("#ffff00");
   z_dphi_toterr_copy__39->SetMarkerColor(ci);
   z_dphi_toterr_copy__39->SetMarkerStyle(0);
   z_dphi_toterr_copy__39->GetXaxis()->SetNdivisions(4);
   z_dphi_toterr_copy__39->GetXaxis()->SetLabelFont(132);
   z_dphi_toterr_copy__39->GetXaxis()->SetLabelOffset(999);
   z_dphi_toterr_copy__39->GetXaxis()->SetLabelSize(0);
   z_dphi_toterr_copy__39->GetXaxis()->SetTitleSize(0.06);
   z_dphi_toterr_copy__39->GetXaxis()->SetTitleFont(132);
   z_dphi_toterr_copy__39->GetYaxis()->SetTitle("d#sigma(#it{Zj})/d|#Delta#it{#phi} [pb/rad]");
   z_dphi_toterr_copy__39->GetYaxis()->SetLabelFont(132);
   z_dphi_toterr_copy__39->GetYaxis()->SetLabelSize(0.05);
   z_dphi_toterr_copy__39->GetYaxis()->SetTitleSize(0.06);
   z_dphi_toterr_copy__39->GetYaxis()->SetTitleOffset(1.3);
   z_dphi_toterr_copy__39->GetYaxis()->SetTitleFont(132);
   z_dphi_toterr_copy__39->GetZaxis()->SetLabelFont(132);
   z_dphi_toterr_copy__39->GetZaxis()->SetLabelSize(0.05);
   z_dphi_toterr_copy__39->GetZaxis()->SetTitleSize(0.06);
   z_dphi_toterr_copy__39->GetZaxis()->SetTitleFont(132);
   z_dphi_toterr_copy__39->Draw("sameaxis");
   upperPad->Modified();
   default_Canvas->cd();
  
// ------------>Primitives in pad: lowerPad
   TPad *lowerPad = new TPad("lowerPad", "lowerPad",0.005,0.05,0.995,0.995);
   lowerPad->Draw();
   lowerPad->cd();
   lowerPad->Range(-0.5429913,-0.4371795,3.335518,5.614103);
   lowerPad->SetFillColor(0);
   lowerPad->SetFillStyle(4000);
   lowerPad->SetBorderMode(0);
   lowerPad->SetBorderSize(2);
   lowerPad->SetTickx(1);
   lowerPad->SetTicky(1);
   lowerPad->SetLeftMargin(0.14);
   lowerPad->SetRightMargin(0.05);
   lowerPad->SetTopMargin(0.665);
   lowerPad->SetBottomMargin(0.14);
   lowerPad->SetFrameLineWidth(2);
   lowerPad->SetFrameBorderMode(0);
   lowerPad->SetFrameLineWidth(2);
   lowerPad->SetFrameBorderMode(0);
   
   TH1F *zj_dphi_8TeV_log_400_1001_0ratiocomp0__40 = new TH1F("zj_dphi_8TeV_log_400_1001_0ratiocomp0__40","z_dphi",6,0,3.141593);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->SetBinContent(1,1);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->SetBinContent(2,1);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->SetBinContent(3,1);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->SetBinContent(4,1);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->SetBinContent(5,1);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->SetBinContent(6,1);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->SetBinContent(7,3.800624);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->SetBinError(1,0.1292219);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->SetBinError(2,0.1149343);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->SetBinError(3,0.1109745);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->SetBinError(4,0.08037191);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->SetBinError(5,0.07114914);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->SetBinError(6,0.04540351);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->SetBinError(7,0.1725617);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->SetMinimum(0.41);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->SetMaximum(1.59);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->SetEntries(20);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->SetStats(0);

   ci = TColor::GetColor("#ffff00");
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->SetFillColor(ci);

   ci = TColor::GetColor("#ffff00");
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->SetLineColor(ci);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->SetLineWidth(2);

   ci = TColor::GetColor("#ffff00");
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->SetMarkerColor(ci);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->SetMarkerStyle(0);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->GetXaxis()->SetTitle("|#Delta#it{#phi}| [rad]");
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->GetXaxis()->SetNdivisions(4);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->GetXaxis()->SetLabelFont(132);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->GetXaxis()->SetLabelOffset(0.02);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->GetXaxis()->SetLabelSize(0.05);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->GetXaxis()->SetTitleSize(0.06);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->GetXaxis()->SetTitleFont(132);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->GetYaxis()->SetTitle("Ratio");
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->GetYaxis()->CenterTitle(true);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->GetYaxis()->SetNdivisions(505);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->GetYaxis()->SetLabelFont(132);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->GetYaxis()->SetLabelSize(0.05);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->GetYaxis()->SetTitleSize(0.06);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->GetYaxis()->SetTickLength(0.12325);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->GetYaxis()->SetTitleOffset(1.3);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->GetYaxis()->SetTitleFont(132);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->GetZaxis()->SetLabelFont(132);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->GetZaxis()->SetLabelSize(0.05);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->GetZaxis()->SetTitleSize(0.06);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->GetZaxis()->SetTitleFont(132);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0__40->Draw("e2");
   
   TH1F *zj_dphi_8TeV_log_400_1001_0ratiocomp1__41 = new TH1F("zj_dphi_8TeV_log_400_1001_0ratiocomp1__41","z_dphi",6,0,3.141593);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->SetBinContent(1,1);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->SetBinContent(2,1);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->SetBinContent(3,1);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->SetBinContent(4,1);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->SetBinContent(5,1);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->SetBinContent(6,1);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->SetBinContent(7,3.800624);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->SetBinError(1,0.06755777);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->SetBinError(2,0.06170157);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->SetBinError(3,0.0547299);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->SetBinError(4,0.04224946);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->SetBinError(5,0.02727271);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->SetBinError(6,0.01381488);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->SetBinError(7,0.05250516);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->SetMinimum(0.41);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->SetMaximum(1.59);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->SetEntries(20);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->SetStats(0);

   ci = TColor::GetColor("#ff9933");
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->SetFillColor(ci);

   ci = TColor::GetColor("#ff9933");
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->SetLineColor(ci);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->SetLineWidth(2);

   ci = TColor::GetColor("#ff9933");
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->SetMarkerColor(ci);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->SetMarkerStyle(0);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->GetXaxis()->SetTitle("|#Delta#it{#phi}| [rad]");
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->GetXaxis()->SetNdivisions(4);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->GetXaxis()->SetLabelFont(132);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->GetXaxis()->SetLabelOffset(0.02);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->GetXaxis()->SetLabelSize(0.05);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->GetXaxis()->SetTitleSize(0.06);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->GetXaxis()->SetTitleFont(132);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->GetYaxis()->SetTitle("Ratio");
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->GetYaxis()->CenterTitle(true);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->GetYaxis()->SetNdivisions(505);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->GetYaxis()->SetLabelFont(132);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->GetYaxis()->SetLabelSize(0.05);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->GetYaxis()->SetTitleSize(0.06);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->GetYaxis()->SetTickLength(0.12325);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->GetYaxis()->SetTitleFont(132);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->GetZaxis()->SetLabelFont(132);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->GetZaxis()->SetLabelSize(0.05);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->GetZaxis()->SetTitleSize(0.06);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->GetZaxis()->SetTitleFont(132);
   zj_dphi_8TeV_log_400_1001_0ratiocomp1__41->Draw("e2same");
   
   Double_t zj_dphi_8TeV_log_400_1001_0ratiocomp2_fx3047[6] = {
   0.3403392,
   0.863938,
   1.387537,
   1.911136,
   2.434734,
   2.958333};
   Double_t zj_dphi_8TeV_log_400_1001_0ratiocomp2_fy3047[6] = {
   0.7375589,
   0.6979502,
   0.9205685,
   0.9599686,
   1.121705,
   1.071786};
   Double_t zj_dphi_8TeV_log_400_1001_0ratiocomp2_felx3047[6] = {
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t zj_dphi_8TeV_log_400_1001_0ratiocomp2_fely3047[6] = {
   0.1307698,
   0.1131224,
   0.1475052,
   0.1342332,
   0.1056111,
   0.06920535};
   Double_t zj_dphi_8TeV_log_400_1001_0ratiocomp2_fehx3047[6] = {
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t zj_dphi_8TeV_log_400_1001_0ratiocomp2_fehy3047[6] = {
   0.1789271,
   0.1647854,
   0.1891732,
   0.1688822,
   0.07983441,
   0.05440822};
   grae = new TGraphAsymmErrors(6,zj_dphi_8TeV_log_400_1001_0ratiocomp2_fx3047,zj_dphi_8TeV_log_400_1001_0ratiocomp2_fy3047,zj_dphi_8TeV_log_400_1001_0ratiocomp2_felx3047,zj_dphi_8TeV_log_400_1001_0ratiocomp2_fehx3047,zj_dphi_8TeV_log_400_1001_0ratiocomp2_fely3047,zj_dphi_8TeV_log_400_1001_0ratiocomp2_fehy3047);
   grae->SetName("zj_dphi_8TeV_log_400_1001_0ratiocomp2");
   grae->SetTitle("");
   grae->SetFillColor(1);
   grae->SetLineWidth(2);
   grae->SetMarkerStyle(24);
   
   TH1F *Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp23047 = new TH1F("Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp23047","",100,0.07853982,3.220132);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp23047->SetMinimum(0.41);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp23047->SetMaximum(1.59);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp23047->SetDirectory(0);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp23047->SetStats(0);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp23047->SetLineWidth(2);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp23047->SetMarkerStyle(0);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp23047->GetXaxis()->SetTitle("|#Delta#it{#phi}| [rad]");
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp23047->GetXaxis()->SetNdivisions(4);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp23047->GetXaxis()->SetLabelFont(132);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp23047->GetXaxis()->SetLabelOffset(0.02);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp23047->GetXaxis()->SetLabelSize(0.05);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp23047->GetXaxis()->SetTitleSize(0.06);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp23047->GetXaxis()->SetTitleFont(132);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp23047->GetYaxis()->SetTitle("Ratio");
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp23047->GetYaxis()->CenterTitle(true);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp23047->GetYaxis()->SetNdivisions(505);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp23047->GetYaxis()->SetLabelFont(132);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp23047->GetYaxis()->SetLabelSize(0.05);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp23047->GetYaxis()->SetTitleSize(0.06);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp23047->GetYaxis()->SetTitleFont(132);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp23047->GetZaxis()->SetLabelFont(132);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp23047->GetZaxis()->SetLabelSize(0.05);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp23047->GetZaxis()->SetTitleSize(0.06);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp23047->GetZaxis()->SetTitleFont(132);
   grae->SetHistogram(Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp23047);
   
   grae->Draw("p1");
   
   Double_t zj_dphi_8TeV_log_400_1001_0ratiocomp3_fx3048[6] = {
   0.3403392,
   0.863938,
   1.387537,
   1.911136,
   2.434734,
   2.958333};
   Double_t zj_dphi_8TeV_log_400_1001_0ratiocomp3_fy3048[6] = {
   0.7375589,
   0.6979502,
   0.9205685,
   0.9599686,
   1.121705,
   1.071786};
   Double_t zj_dphi_8TeV_log_400_1001_0ratiocomp3_felx3048[6] = {
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t zj_dphi_8TeV_log_400_1001_0ratiocomp3_fely3048[6] = {
   0.1099931,
   0.1019378,
   0.1284531,
   0.1082389,
   0.06221498,
   0.04479457};
   Double_t zj_dphi_8TeV_log_400_1001_0ratiocomp3_fehx3048[6] = {
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t zj_dphi_8TeV_log_400_1001_0ratiocomp3_fehy3048[6] = {
   0.1511724,
   0.1397925,
   0.1738889,
   0.1438103,
   0.06146226,
   0.03632125};
   grae = new TGraphAsymmErrors(6,zj_dphi_8TeV_log_400_1001_0ratiocomp3_fx3048,zj_dphi_8TeV_log_400_1001_0ratiocomp3_fy3048,zj_dphi_8TeV_log_400_1001_0ratiocomp3_felx3048,zj_dphi_8TeV_log_400_1001_0ratiocomp3_fehx3048,zj_dphi_8TeV_log_400_1001_0ratiocomp3_fely3048,zj_dphi_8TeV_log_400_1001_0ratiocomp3_fehy3048);
   grae->SetName("zj_dphi_8TeV_log_400_1001_0ratiocomp3");
   grae->SetTitle("");
   grae->SetFillColor(1);
   grae->SetLineWidth(2);
   grae->SetMarkerStyle(24);
   
   TH1F *Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp33048 = new TH1F("Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp33048","",100,0.07853982,3.220132);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp33048->SetMinimum(0.41);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp33048->SetMaximum(1.59);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp33048->SetDirectory(0);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp33048->SetStats(0);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp33048->SetLineWidth(2);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp33048->SetMarkerStyle(0);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp33048->GetXaxis()->SetTitle("|#Delta#it{#phi}| [rad]");
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp33048->GetXaxis()->SetNdivisions(4);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp33048->GetXaxis()->SetLabelFont(132);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp33048->GetXaxis()->SetLabelOffset(0.02);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp33048->GetXaxis()->SetLabelSize(0.05);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp33048->GetXaxis()->SetTitleSize(0.06);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp33048->GetXaxis()->SetTitleFont(132);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp33048->GetYaxis()->SetTitle("Ratio");
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp33048->GetYaxis()->CenterTitle(true);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp33048->GetYaxis()->SetNdivisions(505);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp33048->GetYaxis()->SetLabelFont(132);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp33048->GetYaxis()->SetLabelSize(0.05);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp33048->GetYaxis()->SetTitleSize(0.06);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp33048->GetYaxis()->SetTitleFont(132);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp33048->GetZaxis()->SetLabelFont(132);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp33048->GetZaxis()->SetLabelSize(0.05);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp33048->GetZaxis()->SetTitleSize(0.06);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp33048->GetZaxis()->SetTitleFont(132);
   grae->SetHistogram(Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp33048);
   
   grae->Draw("p1");
   
   Double_t zj_dphi_8TeV_log_400_1001_0ratiocomp4_fx3049[6] = {
   0.1832596,
   0.7068583,
   1.230457,
   1.754056,
   2.277655,
   2.801253};
   Double_t zj_dphi_8TeV_log_400_1001_0ratiocomp4_fy3049[6] = {
   1.175797,
   1.197942,
   1.359112,
   1.262224,
   1.167673,
   1.108041};
   Double_t zj_dphi_8TeV_log_400_1001_0ratiocomp4_felx3049[6] = {
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t zj_dphi_8TeV_log_400_1001_0ratiocomp4_fely3049[6] = {
   0.1234231,
   0.1596723,
   0.1332459,
   0.1099127,
   0.09305962,
   0.08332785};
   Double_t zj_dphi_8TeV_log_400_1001_0ratiocomp4_fehx3049[6] = {
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t zj_dphi_8TeV_log_400_1001_0ratiocomp4_fehy3049[6] = {
   0.1941025,
   0.1476825,
   0.1490468,
   0.136,
   0.1191266,
   0.08785962};
   grae = new TGraphAsymmErrors(6,zj_dphi_8TeV_log_400_1001_0ratiocomp4_fx3049,zj_dphi_8TeV_log_400_1001_0ratiocomp4_fy3049,zj_dphi_8TeV_log_400_1001_0ratiocomp4_felx3049,zj_dphi_8TeV_log_400_1001_0ratiocomp4_fehx3049,zj_dphi_8TeV_log_400_1001_0ratiocomp4_fely3049,zj_dphi_8TeV_log_400_1001_0ratiocomp4_fehy3049);
   grae->SetName("zj_dphi_8TeV_log_400_1001_0ratiocomp4");
   grae->SetTitle("");
   grae->SetFillColor(1);
   grae->SetLineWidth(2);
   grae->SetMarkerStyle(20);
   
   TH1F *Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp43049 = new TH1F("Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp43049","",100,0,3.063053);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp43049->SetMinimum(0.41);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp43049->SetMaximum(1.59);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp43049->SetDirectory(0);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp43049->SetStats(0);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp43049->SetLineWidth(2);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp43049->SetMarkerStyle(0);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp43049->GetXaxis()->SetTitle("|#Delta#it{#phi}| [rad]");
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp43049->GetXaxis()->SetNdivisions(4);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp43049->GetXaxis()->SetLabelFont(132);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp43049->GetXaxis()->SetLabelOffset(0.02);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp43049->GetXaxis()->SetLabelSize(0.05);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp43049->GetXaxis()->SetTitleSize(0.06);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp43049->GetXaxis()->SetTitleFont(132);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp43049->GetYaxis()->SetTitle("Ratio");
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp43049->GetYaxis()->CenterTitle(true);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp43049->GetYaxis()->SetNdivisions(505);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp43049->GetYaxis()->SetLabelFont(132);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp43049->GetYaxis()->SetLabelSize(0.05);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp43049->GetYaxis()->SetTitleSize(0.06);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp43049->GetYaxis()->SetTitleFont(132);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp43049->GetZaxis()->SetLabelFont(132);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp43049->GetZaxis()->SetLabelSize(0.05);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp43049->GetZaxis()->SetTitleSize(0.06);
   Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp43049->GetZaxis()->SetTitleFont(132);
   grae->SetHistogram(Graph_zj_dphi_8TeV_log_400_1001_0ratiocomp43049);
   
   grae->Draw("p1");
   
   TH1F *zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42 = new TH1F("zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42","z_dphi",6,0,3.141593);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->SetBinContent(1,1);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->SetBinContent(2,1);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->SetBinContent(3,1);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->SetBinContent(4,1);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->SetBinContent(5,1);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->SetBinContent(6,1);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->SetBinContent(7,3.800624);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->SetBinError(1,0.1292219);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->SetBinError(2,0.1149343);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->SetBinError(3,0.1109745);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->SetBinError(4,0.08037191);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->SetBinError(5,0.07114914);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->SetBinError(6,0.04540351);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->SetBinError(7,0.1725617);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->SetMinimum(0.41);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->SetMaximum(1.59);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->SetEntries(20);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->SetDirectory(0);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->SetStats(0);

   ci = TColor::GetColor("#ffff00");
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->SetFillColor(ci);

   ci = TColor::GetColor("#ffff00");
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->SetLineColor(ci);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->SetLineWidth(2);

   ci = TColor::GetColor("#ffff00");
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->SetMarkerColor(ci);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->SetMarkerStyle(0);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->GetXaxis()->SetTitle("|#Delta#it{#phi}| [rad]");
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->GetXaxis()->SetNdivisions(4);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->GetXaxis()->SetLabelFont(132);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->GetXaxis()->SetLabelOffset(0.02);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->GetXaxis()->SetLabelSize(0.05);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->GetXaxis()->SetTitleSize(0.06);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->GetXaxis()->SetTitleFont(132);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->GetYaxis()->SetTitle("Ratio");
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->GetYaxis()->CenterTitle(true);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->GetYaxis()->SetNdivisions(505);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->GetYaxis()->SetLabelFont(132);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->GetYaxis()->SetLabelSize(0.05);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->GetYaxis()->SetTitleSize(0.06);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->GetYaxis()->SetTickLength(0.12325);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->GetYaxis()->SetTitleOffset(1.3);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->GetYaxis()->SetTitleFont(132);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->GetZaxis()->SetLabelFont(132);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->GetZaxis()->SetLabelSize(0.05);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->GetZaxis()->SetTitleSize(0.06);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->GetZaxis()->SetTitleFont(132);
   zj_dphi_8TeV_log_400_1001_0ratiocomp0_copy__42->Draw("sameaxis");
   lowerPad->Modified();
   default_Canvas->cd();
   default_Canvas->Modified();
   default_Canvas->cd();
   default_Canvas->SetSelected(default_Canvas);
}