Example #1
0
void plotMultiplicity(char target[6], char list[20], char ene[6], char part[4],
		      char dir[12]="histo", char g4ver[20]="G4.9.1.p01") {

  setStyle();
  gStyle->SetOptTitle(0);
  
  char name[1024], sym[10];
  if      (part=="pim") sprintf(sym, "#pi^{-}");
  else if (part=="pip") sprintf(sym, "#pi^{+}");
  else                  sprintf(sym, "p");

  std::vector<std::string> typeOld = typesOld();
  int energy = atoi(ene);
  
  char ofile[100];
  sprintf (ofile, "%s/histo_%s%s_%s_%sGeV.root", dir, target, list, part, ene);
  std::cout << "Input file " << ofile << "\n";
  TFile *fout = TFile::Open(ofile);
  fout->cd();

  char name[160], title[160], ctype[20], ytitle[20], cname[160];
  TH1I *hiMulti[20];
  for (unsigned int ii=0; ii<=(typeOld.size()); ii++) {
    if      (ii == 0) sprintf (ctype, "All Particles");
    else              sprintf (ctype, "%s", typeOld[ii-1].c_str());
    sprintf (name, "Multi%s%s%sGeV(%s)", target, list, ene, ctype);
    hiMulti[ii] = (TH1I*)fout->FindObjectAny(name);
    //    std::cout << ii << " (" << ctype << ") " << name << " " << hiMulti[ii] << "\n";
  }

  TCanvas *c[20];
  std::vector<std::string> types = types();
  for (unsigned int ii=0; ii<types.size(); ii++) {
    if      (ii == 0) sprintf (ctype, "All Particles");
    else              sprintf (ctype, "%s", types[ii-1].c_str());
    sprintf (cname, "Multiplicity (%s)", ctype);
    hiMulti[ii]->GetXaxis()->SetTitle(cname);
    hiMulti[ii]->SetMarkerStyle(mstyle[ii]);
    hiMulti[ii]->SetMarkerSize(msiz[ii]);
    hiMulti[ii]->SetMarkerColor(mcolor[ii]);
    hiMulti[ii]->SetLineColor(lcolor[ii]);
    hiMulti[ii]->SetLineStyle(lstyle[ii]);
    hiMulti[ii]->SetLineWidth(lwidth[ii]); 

    sprintf(cname, "c_%s%s_%s_%sGeV_Multiplicity(%s)", target, list, part, 
	    ene, ctype);
    c[ii] = new TCanvas(cname, cname, 800, 500);
    hiMulti[ii]->Draw();

    TLegend *leg = new TLegend(0.35, 0.80, 0.8, 0.87);
    char hdr[160];
    sprintf(hdr, "%s+%s at %s GeV (%s-%s)", sym, target, ene, g4ver, list);
    leg->SetHeader(hdr);  leg->SetFillColor(10); leg->SetMargin(0.45);
    leg->SetTextSize(.036); leg->Draw("same");
  }
}
Example #2
0
void overlay_plots(const string& fFile0, const string& fFile1, const double fYmax, const string& fPlot, const string& fLegendEnt1, const string& fLegendEnt2, const string& fName) {
  
   TProfile *p[2];
 
   TFile file0(fFile0.c_str());
   TDirectoryFile *subDir = (TDirectoryFile*)file0.Get("offsetAnalysis");
   p[0] = (TProfile*)subDir->Get(fPlot.c_str());

   TFile file1(fFile1.c_str());
   subDir = (TDirectoryFile*)file1.Get("offsetAnalysis");
   p[1] = (TProfile*)subDir->Get(fPlot.c_str()); 

   p[0]->SetTitleOffset(1.5,"Y");
   p[0]->GetXaxis()->SetTitleSize(0.04);
   p[0]->GetYaxis()->SetTitleSize(0.04);
   
   double ymax = ((p[0]->GetMaximum())>(p[1]->GetMaximum())) ? p[0]->GetMaximum() : p[1]->GetMaximum();
   
   p[0]->GetYaxis()->SetRangeUser(0.,fYmax);
   
   TCanvas *c = new TCanvas("c","",800,800);
   c->cd();
  
   p[0]->SetLineWidth(3);
   p[0]->SetLineColor(kRed);
   p[0]->SetFillColor(kRed);
   p[0]->Draw("hist");
   p[1]->SetLineWidth(3);
   p[1]->SetLineColor(kBlack);
   p[1]->SetMarkerStyle(20);
   p[1]->SetMarkerColor(kBlack);
   p[1]->Draw("sames");
   
   TLegend *legend = new TLegend(.57,.77,.9,.87);
   legend->SetBorderSize(1);
   legend->SetFillColor(0);
//    legend->SetFillStyle(0);
   legend->SetMargin(0.12);
   legend->AddEntry(p[0],fLegendEnt1.c_str(),"l");
   legend->AddEntry(p[1],fLegendEnt2.c_str(),"l");
   legend->Draw();
   
   TLatex l;
   l.SetTextAlign(12);
   l.SetTextSize(0.04);
   l.SetTextFont(62);
   l.SetNDC();
   l.DrawLatex(0.15,0.85,"CMS 2009 Preliminary");
   
   string fileName = fName;
   c->SetGridy();
   c->SaveAs(fileName.c_str());
   
   delete legend;
   delete c;
}
Example #3
0
 TLegend* BuildLegend(TCanvas* canvas, Double_t x1, Double_t y1, Double_t x2, Double_t y2, TString& Header) {
   TLegend* leg = (TLegend*)canvas->BuildLegend(x1, y1, x2, y2, Header);
   if (leg) {
     leg->SetTextFont(_DefaultFont);
     leg->SetFillColor(kWhite);
     leg->SetTextSize(0.06);
     leg->SetMargin(0.15);
     leg->SetBorderSize(0.0);
   }
   return leg;
 }
Example #4
0
TLegend *createLegend(const string &text)
{
    TLegend *legend = new TLegend( .2, .7, .3, .8);
    if (!text.empty())
        legend->SetHeader(text.c_str());

    legend->SetMargin(0.12);
    legend->SetTextSize(0.06);
    legend->SetFillColor(10);
    legend->SetBorderSize(0);

    return legend;
}
Example #5
0
//___________________________________________________________________
Int_t studyBinZero(TString pathData, TString fileNameData, TString listName = "",
                   Double_t etaLow = -0.9, Double_t etaUp = 0.9,
                   Double_t lowerCentrality = -2, Double_t upperCentrality = -2)
{
  PrintSettingsAxisRangeForMultiplicityAxisForMB();
  
  TString pathNameData = Form("%s/%s", pathData.Data(), fileNameData.Data());
  
  if (listName == "") {
    listName = pathNameData;
    listName.Replace(0, listName.Last('/') + 1, "");
    listName.ReplaceAll(".root", "");
  }
  
  TObjArray* histList = 0x0;
  
  TFile* f = TFile::Open(pathNameData.Data());
  if (!f)  {
    std::cout << std::endl;
    std::cout << "Failed to open file \"" << pathNameData.Data() << "\"!" << std::endl;
    return -1;
  }
  
  histList = (TObjArray*)(f->Get(listName.Data()));
  if (!histList) {
    std::cout << std::endl;
    std::cout << "Failed to load list \"" << listName.Data() << "\"!" << std::endl;
    return -1;
  }
  
  // Extract the data histograms
  TH1* hNumEventsTriggerSel = dynamic_cast<TH1*>(histList->FindObject("fhEventsTriggerSel"));
  TH1* hNumEventsTriggerSelVtxCut = dynamic_cast<TH1*>(histList->FindObject("fhEventsTriggerSelVtxCut"));
  TH1* hNumEventsTriggerSelVtxCutZ= dynamic_cast<TH1*>(histList->FindObject("fhEventsProcessedNoPileUpRejection"));
  TH1* hNumEventsTriggerSelVtxCutZPileUpRej= dynamic_cast<TH1*>(histList->FindObject("fhEventsProcessed"));
  
  THnSparse* hDataTriggerSel = dynamic_cast<THnSparse*>(histList->FindObject("fChargedGenPrimariesTriggerSel"));
  THnSparse* hDataTriggerSelVtxCut = dynamic_cast<THnSparse*>(histList->FindObject("fChargedGenPrimariesTriggerSelVtxCut"));
  THnSparse* hDataTriggerSelVtxCutZ = dynamic_cast<THnSparse*>(histList->FindObject("fChargedGenPrimariesTriggerSelVtxCutZ"));
  THnSparse* hDataTriggerSelVtxCutZPileUpRej = dynamic_cast<THnSparse*>(histList->FindObject("fChargedGenPrimariesTriggerSelVtxCutZPileUpRej"));
  
  setSparseErrors(hDataTriggerSel);
  setSparseErrors(hDataTriggerSelVtxCut);
  setSparseErrors(hDataTriggerSelVtxCutZ);
  setSparseErrors(hDataTriggerSelVtxCutZPileUpRej);
  
  
  
  // Set multiplicity range, if desired. Note that mult and pT axes are the same for all histos
  Int_t lowerCentralityBinLimit = -1;
  Int_t upperCentralityBinLimit = -2;
  Bool_t restrictCentralityAxis = kFALSE;
  Double_t actualLowerCentrality = -1.;
  Double_t actualUpperCentrality = -1.;
  
  if (lowerCentrality >= -1 && upperCentrality >= -1) {
    // Add subtract a very small number to avoid problems with values right on the border between to bins
    lowerCentralityBinLimit = hNumEventsTriggerSel->GetXaxis()->FindFixBin(lowerCentrality + 0.001);
    upperCentralityBinLimit = hNumEventsTriggerSel->GetXaxis()->FindFixBin(upperCentrality - 0.001);
    
    // Check if the values look reasonable
    if (lowerCentralityBinLimit <= upperCentralityBinLimit && lowerCentralityBinLimit >= 1
        && upperCentralityBinLimit <= hNumEventsTriggerSel->GetXaxis()->GetNbins()) {
      actualLowerCentrality = hNumEventsTriggerSel->GetXaxis()->GetBinLowEdge(lowerCentralityBinLimit);
      actualUpperCentrality = hNumEventsTriggerSel->GetXaxis()->GetBinUpEdge(upperCentralityBinLimit);

      restrictCentralityAxis = kTRUE;
    }
    else {
      std::cout << std::endl;
      std::cout << "Requested centrality range out of limits or upper and lower limit are switched!" << std::endl;
      return -1;
    }
  }
  
  if (!restrictCentralityAxis)
    GetAxisRangeForMultiplicityAxisForMB(hNumEventsTriggerSel->GetXaxis(), lowerCentralityBinLimit, upperCentralityBinLimit);
  
  hNumEventsTriggerSel->GetXaxis()->SetRange(lowerCentralityBinLimit, upperCentralityBinLimit);
  
  actualLowerCentrality = hNumEventsTriggerSel->GetXaxis()->GetBinLowEdge(hNumEventsTriggerSel->GetXaxis()->GetFirst());
  actualUpperCentrality = hNumEventsTriggerSel->GetXaxis()->GetBinUpEdge(hNumEventsTriggerSel->GetXaxis()->GetLast());
  
  std::cout << "centrality: ";
  if (restrictCentralityAxis) {
    std::cout << actualLowerCentrality << " - " << actualUpperCentrality << std::endl;
    std::cout << "WARNING: Does it really make sense to restrict the centrality? Usually, centrality estimators imply centrality >= 0!"
              << std::endl;
  }
  else
    std::cout << "MB (" << actualLowerCentrality << " - " << actualUpperCentrality << ")" << std::endl;
    
  if (restrictCentralityAxis) {
    hDataTriggerSel->GetAxis(iMult)->SetRange(lowerCentralityBinLimit, upperCentralityBinLimit);
    hDataTriggerSelVtxCut->GetAxis(iMult)->SetRange(lowerCentralityBinLimit, upperCentralityBinLimit);
    hDataTriggerSelVtxCutZ->GetAxis(iMult)->SetRange(lowerCentralityBinLimit, upperCentralityBinLimit);
    hDataTriggerSelVtxCutZPileUpRej->GetAxis(iMult)->SetRange(lowerCentralityBinLimit, upperCentralityBinLimit);
  }
  
  
  // Restrict eta range
  const Int_t lowerEtaBinLimit = hDataTriggerSel->GetAxis(iEta)->FindFixBin(etaLow + 0.0001);
  const Int_t upperEtaBinLimit = hDataTriggerSel->GetAxis(iEta)->FindFixBin(etaUp  - 0.0001);
  
  const Double_t actualLowerEta = hDataTriggerSel->GetAxis(iEta)->GetBinLowEdge(lowerEtaBinLimit);
  const Double_t actualUpperEta = hDataTriggerSel->GetAxis(iEta)->GetBinUpEdge(upperEtaBinLimit);
  
  std::cout << "Eta: ";
  std::cout << actualLowerEta << " - " << actualUpperEta << std::endl;
  
  
  
  Bool_t symmetricInEta = TMath::Abs(TMath::Abs(actualLowerEta) - TMath::Abs(actualUpperEta)) < 1e-6;
  TString etaRange = symmetricInEta ? Form("|#it{#eta}| < %.1f", TMath::Abs(actualLowerEta)) 
                                    : Form("%.1f < #it{#eta} < %.1f", actualLowerEta, actualUpperEta); 
  
  hDataTriggerSel->GetAxis(iEta)->SetRange(lowerEtaBinLimit, upperEtaBinLimit);
  hDataTriggerSelVtxCut->GetAxis(iEta)->SetRange(lowerEtaBinLimit, upperEtaBinLimit);
  hDataTriggerSelVtxCutZ->GetAxis(iEta)->SetRange(lowerEtaBinLimit, upperEtaBinLimit);
  hDataTriggerSelVtxCutZPileUpRej->GetAxis(iEta)->SetRange(lowerEtaBinLimit, upperEtaBinLimit);
  
  // Obtain number of events for each class
  // Note: Under- and overflow automatically taken into account for unrestricted axis by using -1 and -2 for limits
  const Double_t numEvtsTriggerSel = hNumEventsTriggerSel->Integral(lowerCentralityBinLimit, upperCentralityBinLimit);
  const Double_t numEvtsTriggerSelVtxCut = hNumEventsTriggerSelVtxCut->Integral(lowerCentralityBinLimit, upperCentralityBinLimit);
  const Double_t numEvtsTriggerSelVtxCutZ = hNumEventsTriggerSelVtxCutZ->Integral(lowerCentralityBinLimit, upperCentralityBinLimit);
  const Double_t numEvtsTriggerSelVtxCutZPileUpRej = hNumEventsTriggerSelVtxCutZPileUpRej->Integral(lowerCentralityBinLimit,
                                                                                                    upperCentralityBinLimit);
  
  // Project pT spectra
  TH1D* hSpectraTriggerSel = (TH1D*)hDataTriggerSel->Projection(iPt, "e");
  TH1D* hSpectraTriggerSelVtxCut = (TH1D*)hDataTriggerSelVtxCut->Projection(iPt, "e");
  TH1D* hSpectraTriggerSelVtxCutZ = (TH1D*)hDataTriggerSelVtxCutZ->Projection(iPt, "e");
  TH1D* hSpectraTriggerSelVtxCutZPileUpRej = (TH1D*)hDataTriggerSelVtxCutZPileUpRej->Projection(iPt, "e");
  
  // Normalise histos to 1/Nevt dN/dPt
  normaliseHist(hSpectraTriggerSel, numEvtsTriggerSel);
  normaliseHist(hSpectraTriggerSelVtxCut, numEvtsTriggerSelVtxCut);
  normaliseHist(hSpectraTriggerSelVtxCutZ, numEvtsTriggerSelVtxCutZ);
  normaliseHist(hSpectraTriggerSelVtxCutZPileUpRej, numEvtsTriggerSelVtxCutZPileUpRej);
  
  setupHist(hSpectraTriggerSel, kBlack, "Trigger selection");
  setupHist(hSpectraTriggerSelVtxCut, kRed, "& vertex cut");
  setupHist(hSpectraTriggerSelVtxCutZ, kBlue, "& vertex #it{z} cut");
  setupHist(hSpectraTriggerSelVtxCutZPileUpRej, kGreen, "& pile-up rejection");
  
  TCanvas* canvSpectra = new TCanvas("canvSpectra", "Spectra", 760, 420);
  canvSpectra->SetLogx();
  canvSpectra->SetLogy();
  canvSpectra->SetGrid(0, 0);
  SetCanvasMargins(canvSpectra);
  
  TLegend* leg = new TLegend(0.14, 0.26, 0.62, 0.55);
  leg->SetHeader(Form("MC pp #sqrt{s}=7 TeV, inclusive, %s", etaRange.Data()));
  leg->AddEntry(hSpectraTriggerSel, "", "l");
  leg->AddEntry(hSpectraTriggerSelVtxCut, "", "l");
  leg->AddEntry(hSpectraTriggerSelVtxCutZ, "", "l");
  if (drawPileUp)
    leg->AddEntry(hSpectraTriggerSelVtxCutZPileUpRej, "", "l");
  SetupLegend(leg);
  leg->SetMargin(0.15);
  
  hSpectraTriggerSel->Draw();
  hSpectraTriggerSelVtxCut->Draw("same");
  hSpectraTriggerSelVtxCutZ->Draw("same");
  if (drawPileUp)
    hSpectraTriggerSelVtxCutZPileUpRej->Draw("same");
  
  leg->Draw("same");
  
  // Ratios (take binomial errors, since real sub-samples)
  
  TH1D* hRatioVtxCut = new TH1D(*hSpectraTriggerSelVtxCut);
  hRatioVtxCut->SetName("hRatioVtxCut");
  setupHist(hRatioVtxCut, kBlack, "MB & vtx / MB");
  hRatioVtxCut->GetYaxis()->SetTitle("1/#it{N}_{evt} d#it{N}/d#it{p}_{T}^{gen} ratio");
  hRatioVtxCut->Divide(hRatioVtxCut, hSpectraTriggerSel, 1., 1., "B");
  hRatioVtxCut->GetYaxis()->SetRangeUser(1.08, 1.14);
  
  // Mean ratio of spectra and of Nevt
  TF1* funcRatioVtxCut = new TF1("funcRatioVtxCut", "pol0",
                                 0.15, hRatioVtxCut->GetXaxis()->GetBinUpEdge(hSpectraTriggerSelVtxCut->FindLastBinAbove(0)));
  funcRatioVtxCut->SetLineWidth(2);
  funcRatioVtxCut->SetLineColor(kRed);
  hRatioVtxCut->Fit(funcRatioVtxCut, "N");
  const Double_t meanRatioVtxCut = funcRatioVtxCut->GetParameter(0);
  const Double_t ratioNevtVtxCut = numEvtsTriggerSelVtxCut > 0 ? numEvtsTriggerSel / numEvtsTriggerSelVtxCut : -1.;
  const Double_t doubleRatioMinusOne = meanRatioVtxCut > 0 ? (ratioNevtVtxCut / meanRatioVtxCut - 1.) : -999.;
  
  
  
  TH1D* hRatioVtxCutZ = new TH1D(*hSpectraTriggerSelVtxCutZ);
  hRatioVtxCutZ->SetName("hRatioVtxCutZ");
  setupHist(hRatioVtxCutZ, kBlack, "MB & vtx & #it{z} vtx / MB & vtx");
  hRatioVtxCutZ->GetYaxis()->SetTitle("1/#it{N}_{evt} d#it{N}/d#it{p}_{T}^{gen} ratio");
  hRatioVtxCutZ->Divide(hRatioVtxCutZ, hSpectraTriggerSelVtxCut, 1., 1., "B");
  hRatioVtxCutZ->GetYaxis()->SetRangeUser(0.95, 1.05);
  
  // Mean ratio of spectra and of Nevt
  TF1* funcRatioVtxCutZ = new TF1("funcRatioVtxCutZ", "pol0",
                                  0.15, hRatioVtxCutZ->GetXaxis()->GetBinUpEdge(hSpectraTriggerSelVtxCutZ->FindLastBinAbove(0)));
  hRatioVtxCutZ->Fit(funcRatioVtxCutZ, "N");
  funcRatioVtxCutZ->SetLineWidth(2);
  funcRatioVtxCutZ->SetLineColor(kRed);
  const Double_t meanRatioVtxCutZ = funcRatioVtxCutZ->GetParameter(0);
  const Double_t ratioNevtVtxCutZ = numEvtsTriggerSelVtxCutZ > 0 ? numEvtsTriggerSelVtxCut / numEvtsTriggerSelVtxCutZ : -1.;
  
  TH1D* hRatioPileUp = new TH1D(*hSpectraTriggerSelVtxCutZPileUpRej);
  hRatioPileUp->SetName("hRatioPileUp");
  setupHist(hRatioPileUp, kBlack, "MB & vtx & #it{z} vtx & pile-up / MB & vtx & #it{z} vtx");
  hRatioPileUp->GetYaxis()->SetTitle("1/#it{N}_{evt} d#it{N}/d#it{p}_{T}^{gen} ratio");
  hRatioPileUp->Divide(hRatioPileUp, hSpectraTriggerSelVtxCutZ, 1., 1., "B");
  
  /*
  TF1* funcRatioPileUp = new TF1("funcRatioPileUp", "pol0",
                                 0.15, hRatioPileUp->GetXaxis()->GetBinUpEdge(hSpectraTriggerSelVtxCutZPileUpRej->FindLastBinAbove(0)));
  hRatioPileUp->Fit(funcRatioPileUp, "N");*/
  
  ClearTitleFromHistoInCanvas(canvSpectra);
  
  TCanvas* canvRatioVtx = new TCanvas("canvRatioVtx", "Ratio vertex", 760, 420);
  canvRatioVtx->SetLogx();
  canvRatioVtx->SetGrid(0, 1);
  SetCanvasMargins(canvRatioVtx);
  
  hRatioVtxCut->Draw();
  funcRatioVtxCut->Draw("same");
  
  TLegend* leg2 = new TLegend(0.22, 0.7, drawPileUp ? 0.87 : 0.72, 0.9);
  leg2->SetHeader(Form("MC pp #sqrt{s}=7 TeV, inclusive, %s", etaRange.Data()));
  leg2->AddEntry(hRatioVtxCut, "", "l");
  SetupLegend(leg2);
  leg2->SetMargin(0.1);
  
  leg2->Draw("same");
  
  ClearTitleFromHistoInCanvas(canvRatioVtx);
  
  TCanvas* canvRatioOther = new TCanvas("canvRatioOther", "Ratio others", 760, 420);
  canvRatioOther->SetLogx();
  canvRatioOther->SetGrid(0, 1);
  SetCanvasMargins(canvRatioOther);
  
  hRatioVtxCutZ->Draw();
  if (drawPileUp)
    hRatioPileUp->Draw("same");

  TLegend* leg3 = new TLegend(0.22, drawPileUp ? 0.63 : 0.7, drawPileUp ? 0.87 : 0.72, 0.9);
  leg3->SetHeader(Form("MC pp #sqrt{s}=7 TeV, inclusive, %s", etaRange.Data()));
  leg3->AddEntry(hRatioVtxCutZ, "", "l");
  if (drawPileUp)
    leg3->AddEntry(hRatioPileUp, "", "l");
  SetupLegend(leg3);
  leg3->SetMargin(0.1);
  
  leg3->Draw("same");
  
  ClearTitleFromHistoInCanvas(canvRatioOther);

  
  printf("meanRatioVtxCut %f <-> ratioNevtVtxCut %f => meanRatioVtxCutZ/ratioNevtVtxCutZ - 1 = %f\nmeanRatioVtxCutZ %f <-> ratioNevtVtxCutZ %f\n",
         meanRatioVtxCut, ratioNevtVtxCut, doubleRatioMinusOne, meanRatioVtxCutZ, ratioNevtVtxCutZ);
  
  
  TNamed* settings = new TNamed(
      Form("Settings: Data file \"%s\", lowerEta %.2f, uppEta %.2f, lowerCentrality %.3f, upperCentrality %.3f, doubleRatioMinusOne %.4f\n",
           pathNameData.Data(), etaLow, etaUp, lowerCentrality, upperCentrality, doubleRatioMinusOne), "");
  
  // Save results to file
  TString saveFileName = pathNameData;
  saveFileName = Form("%s_binZeroStudy.root", saveFileName.ReplaceAll(".root", "").Data());
  TFile *saveFile = TFile::Open(saveFileName.Data(), "RECREATE");
  saveFile->cd();
  hSpectraTriggerSel->Write();
  hSpectraTriggerSelVtxCut->Write();
  hSpectraTriggerSelVtxCutZ->Write();
  hSpectraTriggerSelVtxCutZPileUpRej->Write();
  
  hRatioVtxCut->Write();
  hRatioVtxCutZ->Write();
  hRatioPileUp->Write();
  
  funcRatioVtxCut->Write();
  funcRatioVtxCutZ->Write();
  
  canvSpectra->Write();
  canvRatioVtx->Write();
  canvRatioOther->Write();
  
  settings->Write();
  
  saveFile->Close();
  
  TString temp = saveFileName;
  canvRatioVtx->SaveAs(Form("%s", temp.ReplaceAll(".root", "_ratioVtx.pdf").Data()));
  temp = saveFileName;
  canvRatioOther->SaveAs(Form("%s", temp.ReplaceAll(".root", "_ratioOther.pdf").Data()));
  
  PrintSettingsAxisRangeForMultiplicityAxisForMB();
  
  return 0;
}
Example #6
0
void Plotting()
{
  TH1::AddDirectory(kFALSE);
  gStyle->SetCanvasDefH(600);
  gStyle->SetCanvasDefW(600);
  
  gROOT->SetStyle("Plain");
  gStyle->SetPalette(1);
  gStyle->SetFrameBorderMode(0);
  gStyle->SetFrameFillColor(0);
  gStyle->SetCanvasColor(0);
  gStyle->SetTitleFillColor(0);
  gStyle->SetStatColor(0);
  gStyle->SetPadBorderSize(0);
  gStyle->SetCanvasBorderSize(0);
  gStyle->SetOptTitle(0); // at least most of the time
  gStyle->SetOptStat("nemr"); // most of the time, sometimes "nemriou" might be useful to display name, 
  //number of entries, mean, rms, integral, overflow and underflow
  gStyle->SetOptFit(0); // set to 1 only if you want to display fit results
  
  //=================================== Histo for all cut variables ==========================================
  using namespace RooFit;
  using namespace RooStats;
 
  void setWSRange(RooWorkspace *ws);
  void defineMassBkg(RooWorkspace *ws);
  void defineMassSig(RooWorkspace *ws);    

  double RError(double,double,double,double);
  double WeightRatioError(double,double,double,double);
  
  bool is3D =1;
  bool significance = 0;
  bool isHI=0; 
  bool Prompt = 0;
  bool nonPrompt = 1;

  bool savePlot=0;
  bool Binning =0;
  bool ctauFit = 1;
  

  float ptmin=3.0; float ptmax=30.0; float ymin=1.6; float ymax=2.4; bool absRapidity=true; 
  double threshold=0.8; double efficiency=0.9; int centmin=0; int centmax=200;

  ymin=1.6; ymax=2.4; ptmin=3.0; ptmax=30.0; 
  //ymin=1.6; ymax=2.4; ptmin=3.0; ptmax=6.5; 
  //ymin=1.6; ymax=2.4; ptmin=6.5; ptmax=12.0; 
  //ymin=1.6; ymax=2.4; ptmin=12.0; ptmax=30.0; 
  
  //ymin=0.0; ymax=1.6; ptmin=6.5; ptmax=30.0;  
  //ymin=0.0; ymax=1.6; ptmin=6.5; ptmax=9.0;  
  //ymin=0.0; ymax=1.6; ptmin=9.0; ptmax=12.0;  
  //ymin=0.0; ymax=1.6; ptmin=12.0; ptmax=15.0;  
  //ymin=0.0; ymax=1.6; ptmin=15.0; ptmax=20.0;  
  //ymin=0.0; ymax=1.6; ptmin=20.0; ptmax=30.0;  
  
  int range1 = 0; int fbin = 0;
  int range2 = 0; int lbin = 0;
  float xVal = 0.0;

  if(significance){
    range1 = -10;
    range2 = 50;
    fbin = -10; lbin = 50;
    xVal = 11.0;
  }else{
    range1 = -1;
    range2 = 3;
    fbin = -5; lbin = 10;
    xVal = 0.5;
  }

  float lCut=-10.0;
  TLegend *leg = new TLegend(0.38,0.5,0.87,0.75);
  if (isHI)
    leg->SetHeader("PYTHIA: PbPb #sqrt{s_{NN}} = 5.02 TeV");
  else
    leg->SetHeader("PYTHIA: pp #sqrt{s} = 5.02 TeV");
  leg->SetFillStyle(0);
  leg->SetFillColor(0);
  leg->SetBorderSize(0);
  leg->SetMargin(0.15);
  leg->SetTextSize(0.032);
  leg->SetTextColor(2);

  TCut defaultCut = NULL;
  //  TCut defaultCut = "Reco_QQ_sign==0&&Gen_QQ_4mom.M()>3.09&&Gen_QQ_4mom.M()<3.10&&Reco_QQ_4mom.M()>2.9&&Reco_QQ_4mom.M()<3.2&&Reco_QQ_ctauTrue>-10";
  defaultCut = "Reco_QQ_sign==0&&Reco_QQ_4mom.M()>2.9&&Reco_QQ_4mom.M()<3.2&&Reco_QQ_ctau>-500&&Reco_QQ_ctauTrue>-10";
  if(significance)
    defaultCut = "Reco_QQ_sign==0&&Reco_QQ_4mom.M()>2.85&&Reco_QQ_4mom.M()<3.25&&Reco_QQ_ctau>-500&&Reco_QQ_ctauErr>-500&&Reco_QQ_ctauTrue>-10";
  if(is3D){
    defaultCut = "Reco_QQ_sign==0&&Reco_QQ_4mom.M()>2.85&&Reco_QQ_4mom.M()<3.25&&Reco_QQ_ctau3D>-500&&Reco_QQ_ctauTrue3D>-10";
    if(significance)
      defaultCut = "Reco_QQ_sign==0&&Reco_QQ_4mom.M()>2.85&&Reco_QQ_4mom.M()<3.25&&Reco_QQ_ctau3D>-500&&Reco_QQ_ctauErr3D>-500&&Reco_QQ_ctauTrue3D>-10";
  }
  
  TCut ptCut = Form("Reco_QQ_4mom.Pt()>%3.1f&&Reco_QQ_4mom.Pt()<%3.1f",ptmin,ptmax);
  TCut rapCut;
  if (absRapidity)
    rapCut = Form("abs(Reco_QQ_4mom.Rapidity())>%3.1f&&abs(Reco_QQ_4mom.Rapidity())<%3.1f",ymin,ymax);
  else
    rapCut = Form("Reco_QQ_4mom.Rapidity()>%3.1f&&Reco_QQ_4mom.Rapidity()<%3.1f",ymin,ymax);
  TCut centCut;
  if (isHI)
    centCut = Form("Centrality>=%d&&Centrality<%d",centmin,centmax);
  
  // new Acceptance
  TCut IsPlAccept = "(abs(Reco_QQ_mupl_4mom->Eta()) < 2.4 && ( (abs(Reco_QQ_mupl_4mom->Eta()) < 1.2 && Reco_QQ_mupl_4mom->Pt() >= 3.5 ) || (1.2 <= abs(Reco_QQ_mupl_4mom->Eta()) && abs(Reco_QQ_mupl_4mom->Eta()) < 2.1 && Reco_QQ_mupl_4mom->Pt() >= 5.77-1.89*abs(Reco_QQ_mupl_4mom->Eta() )) || (2.1 <= abs(Reco_QQ_mupl_4mom->Eta()) && Reco_QQ_mupl_4mom->Pt() >= 1.8 )))";
  TCut IsMiAccept = "(abs(Reco_QQ_mumi_4mom->Eta()) < 2.4 && ( (abs(Reco_QQ_mumi_4mom->Eta()) < 1.2 && Reco_QQ_mumi_4mom->Pt() >= 3.5 ) || (1.2 <= abs(Reco_QQ_mumi_4mom->Eta()) && abs(Reco_QQ_mumi_4mom->Eta()) < 2.1 && Reco_QQ_mumi_4mom->Pt() >= 5.77-1.89*abs(Reco_QQ_mumi_4mom->Eta() )) || (2.1 <= abs(Reco_QQ_mumi_4mom->Eta()) && Reco_QQ_mumi_4mom->Pt() >= 1.8 )))";

  TCut MuPlID = "((Reco_QQ_mupl_isGoodMuon==1) && Reco_QQ_mupl_nTrkWMea> 5 &&  Reco_QQ_mupl_nPixWMea > 0 && TMath::Abs(Reco_QQ_mupl_dxy) < 0.3 && TMath::Abs(Reco_QQ_mupl_dz) < 20 && Reco_QQ_VtxProb > 0.01 )";
  TCut MuMiID = "((Reco_QQ_mumi_isGoodMuon==1) && Reco_QQ_mumi_nTrkWMea> 5 &&  Reco_QQ_mumi_nPixWMea > 0 && TMath::Abs(Reco_QQ_mumi_dxy) < 0.3 && TMath::Abs(Reco_QQ_mumi_dz) < 20 && Reco_QQ_VtxProb > 0.01 )";
  
  
  unsigned int trigBit;
  if (isHI)
    trigBit=1; // DoubleMu0_HighQ
  else
    trigBit=1; // DoubleMu0_HighQ
  TCut trigCut = Form("(HLTriggers&%u)==%u&&(Reco_QQ_trig&%u)==%u",trigBit,trigBit,trigBit,trigBit);

  TString fname;
  TString fnamepng;
  TString outfname;
  TString plotDir;
  
  if(!is3D){plotDir = "Plots/2015";}
  if(!is3D && significance){plotDir = "Plots/2015/significance";}
  if(is3D){plotDir = "Plots/2015/3D";}
  if(is3D && Binning){plotDir = "Plots/2015/3D/Binning";}
  if(is3D && ctauFit){plotDir = "Plots/2015/3D/ctauFit";}
  if(is3D && significance){plotDir = "Plots/2015/3D/significance";}
  
  if (isHI) {
    if(Prompt){
      fname = Form("/Jpsi_PbPb_XcheckEff_%3.1f_Rap_%3.1f-%3.1f_Pt_%3.1f-%3.1f_Cent_%d-%d.pdf",efficiency,ymin,ymax,ptmin,ptmax,int(centmin/2.0),int(centmax/2.0));
      fnamepng = Form("/Jpsi_PbPb_XcheckEff_%3.1f_Rap_%3.1f-%3.1f_Pt_%3.1f-%3.1f_Cent_%d-%d.png",efficiency,ymin,ymax,ptmin,ptmax,int(centmin/2.0),int(centmax/2.0));
      outfname = Form("/Jpsi_PbPb_XcheckEff_%3.1f_Rap_%3.1f-%3.1f_Pt_%3.1f-%3.1f_Cent_%d-%d.root",efficiency,ymin,ymax,ptmin,ptmax,int(centmin/2.0),int(centmax/2.0));
    }
    if(nonPrompt){
      fname = Form("/Jpsi_PbPb_XcheckEff_NP_%3.1f_Rap_%3.1f-%3.1f_Pt_%3.1f-%3.1f_Cent_%d-%d.pdf",efficiency,ymin,ymax,ptmin,ptmax,int(centmin/2.0),int(centmax/2.0));
      fnamepng = Form("/Jpsi_PbPb_XcheckEff_NP_%3.1f_Rap_%3.1f-%3.1f_Pt_%3.1f-%3.1f_Cent_%d-%d.png",efficiency,ymin,ymax,ptmin,ptmax,int(centmin/2.0),int(centmax/2.0));
      outfname = Form("/Jpsi_PbPb_XcheckEff_NP_%3.1f_Rap_%3.1f-%3.1f_Pt_%3.1f-%3.1f_Cent_%d-%d.root",efficiency,ymin,ymax,ptmin,ptmax,int(centmin/2.0),int(centmax/2.0));
    }
      
  } 
  else {
    if(Prompt){
      fname = Form("/Jpsi_pp_XcheckEff_%3.1f_Rap_%3.1f-%3.1f_Pt_%3.1f-%3.1f.pdf",efficiency,ymin,ymax,ptmin,ptmax);
      fnamepng = Form("/Jpsi_pp_XcheckEff_%3.1f_Rap_%3.1f-%3.1f_Pt_%3.1f-%3.1f.png",efficiency,ymin,ymax,ptmin,ptmax);
      outfname = Form("/Jpsi_pp_XcheckEff_%3.1f_Rap_%3.1f-%3.1f_Pt_%3.1f-%3.1f.root",efficiency,ymin,ymax,ptmin,ptmax);
    }
    if(nonPrompt){
      fname = Form("/Jpsi_pp_XcheckEff_NP_%3.1f_Rap_%3.1f-%3.1f_Pt_%3.1f-%3.1f.pdf",efficiency,ymin,ymax,ptmin,ptmax);
      fnamepng = Form("/Jpsi_pp_XcheckEff_NP_%3.1f_Rap_%3.1f-%3.1f_Pt_%3.1f-%3.1f.png",efficiency,ymin,ymax,ptmin,ptmax);
      outfname = Form("/Jpsi_pp_XcheckEff_NP_%3.1f_Rap_%3.1f-%3.1f_Pt_%3.1f-%3.1f.root",efficiency,ymin,ymax,ptmin,ptmax);
    }
  }
  std::cout << fname << std::endl;

  std::cout << "default: " << defaultCut.GetTitle() << std::endl;
  std::cout << "pt cut: " << ptCut.GetTitle() << std::endl;
  std::cout << "rapidity cut: " << rapCut.GetTitle() << std::endl;
  std::cout << "centrality cut: " << centCut.GetTitle() << std::endl;
  std::cout << "trigger bit: " << trigCut.GetTitle() << std::endl;

  TLatex *lpt;
  if (ptmin==0.0)
    lpt = new TLatex(0.38,0.845,Form("p_{T} < %3.1f GeV/c",ptmax));
  else{
    lpt = new TLatex(0.38,0.845,Form("%3.1f < p_{T} < %3.1f GeV/c",ptmin,ptmax));
    lpt->SetTextSize(0.033);
  }
  TLatex *lrap;
  if (absRapidity){
    if (ymin==0.0){
      lrap = new TLatex(0.38,0.77,Form("|y| < %3.1f",ymax));
      lrap->SetTextSize(0.033);
    }
    else{
      lrap = new TLatex(0.38,0.77,Form("%3.1f < |y| < %3.1f",ymin,ymax));
      lrap->SetTextSize(0.033);
    }
  }
  else {
    if (ymin==0.0)
      lrap = new TLatex(0.38,0.77,Form("y < %3.1f",ymax));
    else
      lrap = new TLatex(0.38,0.77,Form("%3.1f < y < %3.1f",ymin,ymax));
  }

  lpt->SetNDC(kTRUE);
  lrap->SetNDC(kTRUE);
  
  TLatex *lcent = NULL;
  if (isHI) {
    lcent = new TLatex(0.38,0.69,Form("Cent. %d-%d%%",int(centmin/2.0),int(centmax/2.0)));
    lcent->SetTextSize(0.033);
    lcent->SetNDC(kTRUE);
  }
  
  TChain *iTree = NULL;
  iTree = new TChain("hionia/myTree");
  if (isHI) {
    if(Prompt)
      {
	iTree->Add("/home/abdulla/CMS/quarkoniaData/Charm2015/rootfiles/MC/PbPb/Jpsi/OniaTree_Pythia8_JpsiMM_ptJpsi_00_03_Hydjet_MB_HINPbPbWinter16DR-75X_mcRun2_HeavyIon_v13-v1.root");
	iTree->Add("/home/abdulla/CMS/quarkoniaData/Charm2015/rootfiles/MC/PbPb/Jpsi/OniaTree_Pythia8_JpsiMM_ptJpsi_03_06_Hydjet_MB_HINPbPbWinter16DR-75X_mcRun2_HeavyIon_v13-v1.root");
	iTree->Add("/home/abdulla/CMS/quarkoniaData/Charm2015/rootfiles/MC/PbPb/Jpsi/OniaTree_Pythia8_JpsiMM_ptJpsi_06_09_Hydjet_MB_HINPbPbWinter16DR-75X_mcRun2_HeavyIon_v13-v1.root");
	iTree->Add("/home/abdulla/CMS/quarkoniaData/Charm2015/rootfiles/MC/PbPb/Jpsi/OniaTree_Pythia8_JpsiMM_ptJpsi_09_12_Hydjet_MB_HINPbPbWinter16DR-75X_mcRun2_HeavyIon_v13-v1.root");
	iTree->Add("/home/abdulla/CMS/quarkoniaData/Charm2015/rootfiles/MC/PbPb/Jpsi/OniaTree_Pythia8_JpsiMM_ptJpsi_12_15_Hydjet_MB_HINPbPbWinter16DR-75X_mcRun2_HeavyIon_v13-v1.root");
	iTree->Add("/home/abdulla/CMS/quarkoniaData/Charm2015/rootfiles/MC/PbPb/Jpsi/OniaTree_Pythia8_JpsiMM_ptJpsi_15_30_Hydjet_MB_HINPbPbWinter16DR-75X_mcRun2_HeavyIon_v13-v1.root");
	iTree->Add("/home/abdulla/CMS/quarkoniaData/Charm2015/rootfiles/MC/PbPb/Jpsi/OniaTree_Pythia8_JpsiMM_ptJpsi_30_Inf_Hydjet_MB_HINPbPbWinter16DR-75X_mcRun2_HeavyIon_v13-v1.root");
      }
    if(nonPrompt)
      {
	iTree->Add("/home/abdulla/CMS/quarkoniaData/Charm2015/rootfiles/MC/PbPb/BJpsi/OniaTree_Pythia8_BJpsiMM_ptJpsi_00_03_Hydjet_MB_HINPbPbWinter16DR-75X_mcRun2_HeavyIon_v13-v1.root");
	iTree->Add("/home/abdulla/CMS/quarkoniaData/Charm2015/rootfiles/MC/PbPb/BJpsi/OniaTree_Pythia8_BJpsiMM_ptJpsi_03_06_Hydjet_MB_HINPbPbWinter16DR-75X_mcRun2_HeavyIon_v13-v1.root");
	iTree->Add("/home/abdulla/CMS/quarkoniaData/Charm2015/rootfiles/MC/PbPb/BJpsi/OniaTree_Pythia8_BJpsiMM_ptJpsi_06_09_Hydjet_MB_HINPbPbWinter16DR-75X_mcRun2_HeavyIon_v13-v1.root");
	iTree->Add("/home/abdulla/CMS/quarkoniaData/Charm2015/rootfiles/MC/PbPb/BJpsi/OniaTree_Pythia8_BJpsiMM_ptJpsi_09_12_Hydjet_MB_HINPbPbWinter16DR-75X_mcRun2_HeavyIon_v13-v1.root");
	iTree->Add("/home/abdulla/CMS/quarkoniaData/Charm2015/rootfiles/MC/PbPb/BJpsi/OniaTree_Pythia8_BJpsiMM_ptJpsi_12_15_Hydjet_MB_HINPbPbWinter16DR-75X_mcRun2_HeavyIon_v13-v1.root");
	iTree->Add("/home/abdulla/CMS/quarkoniaData/Charm2015/rootfiles/MC/PbPb/BJpsi/OniaTree_Pythia8_BJpsiMM_ptJpsi_15_30_Hydjet_MB_HINPbPbWinter16DR-75X_mcRun2_HeavyIon_v13-v1.root");
	//iTree->Add("/home/abdulla/CMS/quarkoniaData/Charm2015/rootfiles/MC/PbPb/BJpsi/OniaTree_Pythia8_BJpsiMM_ptJpsi_30_Inf_Hydjet_MB_HINPbPbWinter16DR-75X_mcRun2_HeavyIon_v13-v1.root");
      }
  }
  else{
    if(Prompt)
      iTree->Add("/home/abdulla/CMS/quarkoniaData/Charm2015/rootfiles/MC/pp/OniaTree_JpsiMM_5p02TeV_TuneCUETP8M1_HINppWinter16DR-75X_mcRun2_asymptotic_ppAt5TeV_v3-v1.root");
    if(nonPrompt)
      iTree->Add("/home/abdulla/CMS/quarkoniaData/Charm2015/rootfiles/MC/pp/OniaTree_BJpsiMM_5p02TeV_TuneCUETP8M1_HINppWinter16DR-75X_mcRun2_asymptotic_ppAt5TeV_v3-v1.root");
  }
  
  Float_t         muPlPt;
  Float_t         muMiPt;
  Float_t         muPlEta;
  Float_t         muMiEta;
  Float_t         QQctau3D;
  Float_t         QQctau3DErr;
  
  double invariantMass;
  double JpsiPt;
  double JpsiRap;
  double vProb;

  float muPlDxy;
  float muPlDz;
  int muPlNhits;
  int muPlNPxlLayers;
  int muPlNTrkLayers;
  float muPlInnerChi;
  float muPlGlobalChi;
  int muPlNMuonhits;
  bool muPlGoodMu;
  bool muPlTrkArb;
  bool muPlTMOneStaTight;
  bool muPlHighPurity;

  float muMiDxy;
  float muMiDz;
  int muMiNhits;
  int muMiNPxlLayers;
  int muMiNTrkLayers;
  float muMiInnerChi;
  float muMiGlobalChi;
  int muMiNMuonhits;
  bool muMiGoodMu;
  bool muMiTrkArb;
  bool muMiTMOneStaTight;
  bool muMiHighPurity;
  
  
  int nx = 14, ny = 15000;
  //double xBins[22] = {0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,30.0}; //19
  double xBins[15] = {3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,15.0,18.0,22.0,30.0}; //19
  
  //double xBins[4] = {3.0,6.5,12.0,30.0}; //19
  //double xBins[6] = {6.5,9.0,12.0,15.0,20.0,30.0}; //19
  
  //double xBins[13] = {6.5,7.0,8.0,9.0,10.0,11.0,12.0,13.0,15.0,18.0,21.0,24.0,30.0}; //13
  //double xBins[8] = {6.0,9.0,12.0,15.0,18.0,21.0,24.0,30.0}; //19
  //TH2D *hPR2D = new TH2D("hPR2D","hPR2D",nx,xBins,ny,-5.0,10.0);
  
  //TH1F *hPR = new TH1F("hPR","hPR;Inv_mass",100,-2.5,3.2);
  TH1F *hPR = new TH1F("hPR","hPR;p_{T}",nx,xBins);
  //TH1F *hPR = new TH1F("hPR","hPR;l_{J/#psi} (mm);counts",1500,-5,10);
  hPR->Sumw2();
  hPR->SetLineColor(1);
  //TH1F *hPRfunc = new TH1F("hPRfunc","hPRfunc;Inv_mass",100,-2.8,3.2);
  TH1F *hPRfunc = new TH1F("hPRfunc","hPRfunc;p_{T}",nx,xBins);
  //TH1F *hPRfunc = new TH1F("hPRfunc","hPRfunc;l_{J/#psi} (mm);counts",1500,-5,10);
  hPRfunc->Sumw2();
  hPRfunc->SetLineColor(2);
  //TH1F* hPRCut = (TH1F*) hPR->Clone("hPRCut");
  
  TFile *Fitfile = new TFile("Plots/2015/3D/ctauFit/Jpsi_pp_eff_0.9_Rap_1.6-2.4_Pt_3.0-30.0.root");
  TGraph *FitGr = (TGraph*)Fitfile->Get("Graph");
  TF1 *func1 = (TF1*)FitGr->GetFunction("FitFn");
  
  new TCanvas;
  TAxis *XaxctauFW = FitGr->GetXaxis();
  XaxctauFW->SetLimits(0.0,30.0);
  TAxis *YaxctauFW = FitGr->GetYaxis();
  YaxctauFW->SetLimits(0.0,0.1);
  FitGr->GetXaxis()->SetRangeUser(0.0,30.0);
  FitGr->GetYaxis()->SetRangeUser(0.0,0.1);
  //FitGr->Draw("AP");
  //FitGr->Draw();
  func1->Draw();

  initOniaTree(iTree);
  Long64_t nentries = iTree->GetEntries();
  nentries = 500000;          
  cout<<"Total Entries in data  Tree  "<<"  "<<nentries<< "====="<<endl;
  Long64_t nbytes = 0, nb = 0;
 
  for (Long64_t jentry=0; jentry<nentries;jentry++) {
    nb = iTree->GetEntry(jentry);   
    
    for (int iQQ=0; iQQ<Reco_QQ_size; iQQ++) {
      TLorentzVector *qq4mom = (TLorentzVector*) Reco_QQ_4mom->At(iQQ);
      TLorentzVector *qq4mupl = (TLorentzVector*) Reco_QQ_mupl_4mom->At(iQQ);
      TLorentzVector *qq4mumi = (TLorentzVector*) Reco_QQ_mumi_4mom->At(iQQ);
      
      invariantMass = qq4mom->M();
      JpsiPt = qq4mom->Pt();
      JpsiRap = qq4mom->Rapidity();

      muPlPt = qq4mupl->Pt();
      muMiPt = qq4mumi->Pt();
      muPlEta = qq4mupl->Eta();
      muMiEta = qq4mumi->Eta();

      QQctau3D = Reco_QQ_ctau3D[iQQ];
      //QQctauTrue3D = Reco_QQ_ctauTrue3D[iQQ];
      
      vProb = Reco_QQ_VtxProb[iQQ];
      muPlDxy=Reco_QQ_mupl_dxy[iQQ];
      muPlDz=Reco_QQ_mupl_dz[iQQ];
      muPlNPxlLayers=Reco_QQ_mupl_nPixWMea[iQQ];
      muPlNTrkLayers=Reco_QQ_mupl_nTrkWMea[iQQ];
      muPlTMOneStaTight=Reco_QQ_mupl_TMOneStaTight[iQQ];
      muPlGoodMu = Reco_QQ_mupl_isGoodMuon[iQQ];
      muPlHighPurity = Reco_QQ_mupl_highPurity[iQQ];

      muMiDxy=Reco_QQ_mumi_dxy[iQQ];
      muMiDz=Reco_QQ_mumi_dz[iQQ];
      muMiNPxlLayers=Reco_QQ_mumi_nPixWMea[iQQ];
      muMiNTrkLayers=Reco_QQ_mumi_nTrkWMea[iQQ];
      muMiTMOneStaTight=Reco_QQ_mumi_TMOneStaTight[iQQ];
      muMiGoodMu = Reco_QQ_mumi_isGoodMuon[iQQ];
      muMiHighPurity = Reco_QQ_mumi_highPurity[iQQ];
      
      bool defaultpass =0, ptpass =0, rappass =0, PosPass=0, NegPass=0, AllCut=0 ,PosIn=0, NegIn=0,TriggerPass=0;
      
      //if(Reco_QQ_sign[iQQ]==0 && invariantMass>2.85 && invariantMass<3.25 && Reco_QQ_ctau3D[iQQ]>-500 && Reco_QQ_ctauTrue3D[iQQ]>-10) {defaultpass =1;}
      if(Reco_QQ_sign[iQQ]==0 && invariantMass>2.85 && invariantMass<3.25 ) {defaultpass =1;}
      if(!defaultpass) continue;
      
      if(JpsiPt>ptmin && JpsiPt<ptmax)  {ptpass =1;}
      if( fabs(JpsiRap)>ymin && fabs(JpsiRap) <ymax )   {rappass =1;}

      if(!ptpass) continue;
      if(!rappass) continue; 
      //centCut = Form("Centrality>=%d&&Centrality<%d",centmin,centmax);
      
      if( (HLTriggers&(ULong64_t)pow(2,0))==pow(2,0) && (Reco_QQ_trig[iQQ]&(ULong64_t)pow(2,0))==pow(2,0) )
	{TriggerPass =1;}
      
      if (fabs(muPlEta) < 2.4 && ( (fabs(muPlEta) < 1.2 && muPlPt >= 3.5 ) || (1.2 <= fabs(muPlEta) && fabs(muPlEta) < 2.1 && muPlPt >= 5.77-1.89*fabs(muPlEta )) || (2.1 <= fabs(muPlEta) && muPlPt >= 1.8 )) )  {PosIn =1;}
	
      if(fabs(muMiEta) < 2.4 && ( (fabs(muMiEta) < 1.2 && muMiPt >= 3.5 ) || (1.2 <= fabs(muMiEta) && fabs(muMiEta) < 2.1 && muMiPt >= 5.77-1.89*fabs(muMiEta )) || (2.1 <= fabs(muMiEta) && muMiPt >= 1.8 )) )  {NegIn =1;}

      if( (muPlGoodMu==1) && muPlNTrkLayers> 5 &&  muPlNPxlLayers > 0 && TMath::Abs(muPlDxy) < 0.3 && TMath::Abs(muPlDz) < 20 && vProb > 0.01){PosPass=1;}

      if( (muMiGoodMu==1) && muMiNTrkLayers> 5 &&  muMiNPxlLayers > 0 && TMath::Abs(muMiDxy) < 0.3 && TMath::Abs(muMiDz) < 20 ){NegPass=1;}

      //if((Reco_QQ_mupl_isGoodMuon==1) && Reco_QQ_mupl_nTrkWMea> 5 &&  Reco_QQ_mupl_nPixWMea > 0 && TMath::fabs(Reco_QQ_mupl_dxy) < 0.3 && TMath::fabs(Reco_QQ_mupl_dz) < 20 && Reco_QQ_VtxProb > 0.01 )  {PosPass =1;}
      //if((Reco_QQ_mumi_isGoodMuon==1) && Reco_QQ_mumi_nTrkWMea> 5 &&  Reco_QQ_mumi_nPixWMea > 0 && TMath::fabs(Reco_QQ_mumi_dxy) < 0.3 && TMath::fabs(Reco_QQ_mumi_dz) < 20 && Reco_QQ_VtxProb > 0.01 )  {NegPass =1;}
      
      if(TriggerPass &&PosIn && NegIn && PosPass && NegPass) {AllCut = 1;}
      if(!AllCut) continue;
      
      //hPR->Fill(QQctau3D);
      hPR->Fill(JpsiPt);
      
      //for pp fwdrap:         cut.dMuon.ctauCut = "( ctau < (0.0128 + (0.288/pt)) )";
      //for pbpb fwdrap:     cut.dMuon.ctauCut = "( ctau < (0.0147 + (0.279/pt)) )";
      //for pp midrap:         cut.dMuon.ctauCut = "( ctau < (0.0097 + (0.249/pt)) )";
      //for pbpb midrap:     cut.dMuon.ctauCut = "( ctau < (0.0134 + (0.216/pt)) )";
      if( QQctau3D < (0.0128 + (0.288/JpsiPt) ) ) {hPRfunc->Fill(JpsiPt);}
      
    }
  }
  
  //TH1F* ratio = (TH1F*)hPR->Clone();      
  //ratio->Divide(hPRfunc);

  TH1F* ratio = (TH1F*)hPRfunc->Clone();      
  ratio->Divide(hPR);
  
  ratio->SetStats(0);
  //gStyle->SetFitFormat("1.3f");
  
  TCanvas *rt = new TCanvas();
  gPad->SetTickx();
  gPad->SetTicky();
  gPad->SetGridy();
  ratio->SetMarkerColor(kGreen+3);
  ratio->SetLineColor(0);
  ratio->SetMarkerStyle(29);
  ratio->SetMarkerSize(1.3);
  
  XaxctauFW = ratio->GetXaxis();
  XaxctauFW->SetLimits(0.0,30.0);
  YaxctauFW = ratio->GetYaxis();
  YaxctauFW->SetLimits(0.5,1.5);
  ratio->GetXaxis()->SetRangeUser(0.0,30.0);
  ratio->GetYaxis()->SetRangeUser(0.5,1.5);
  ratio->Draw();
 
  //*/
  
  
  lpt->Draw();
  lrap->Draw();
  leg->Draw();
  
  if (isHI)
    lcent->Draw();

  if (savePlot) {
    rt->SaveAs(plotDir+fname);
    rt->SaveAs(plotDir+fnamepng);
  }

  return;

  /*
  //TH1D *ctauMid_pT = new TH1D("ctauMid_pT","ctauMid_pT",90,0,30);
  //TH1D *ctauFW_pT = new TH1D("ctauFW_pT","ctauFW_pT",90,0,30);
  
  //double ctauFrw[5] = {0.04,0.03,0.02,0.02,0.01};
  double ctauFrw[4] = {0.07,0.04,0.03};
  double ctauMd[6] = {0.04,0.03,0.02,0.02,0.01};
  
  double Fbins[4] = {3,6.5,12.0,30.0};
  double Mbins[6] = {6.5,9.0,12.0,15.0,20.0,30.0};
  double x1bins[4] = {0.0};
  double x2bins[6] = {0.0};
  
  for(int i=0; i<3; i++){
    x1bins[i] = (Fbins[i] + Fbins[i+1])/2.0;
    cout<<x1bins[i]<<endl;
    //ctauFW_pT->SetBinContent(x1bins[i], ctauFrw[i-1]);
  } 

  for(int i=0; i<5; i++){
    x2bins[i] = (Mbins[i] + Mbins[i+1])/2.0;
    //ctauMid_pT->SetBinContent(x2bins[i], ctauMd[i]);
  } 
  
  new TCanvas;
  gPad->SetTickx();
  gPad->SetTicky();
  gPad->SetGridy();

  TGraph *ctauFW_pT = new TGraph(3,x1bins,ctauFrw);
  
  TF1 *FitFn = new TF1("FitFn",Pol2,0.0,30.0,3);
  FitFn->SetParNames("C","a","b");
  FitFn->SetLineWidth(2.0);
  FitFn->SetLineColor(2);
  ctauFW_pT->Fit("FitFn","", "",3.0,30.0);

  ctauFW_pT->SetLineColor(2);    
  ctauFW_pT->SetLineWidth(3); 
  ctauFW_pT->SetMarkerSize(1.5);
  ctauFW_pT->GetYaxis()->SetTitle("c#tau");
  ctauFW_pT->GetXaxis()->SetTitle("p_{T} bin");

  TAxis *XaxctauFW = ctauFW_pT->GetXaxis();
  XaxctauFW->SetLimits(0.0,30.0);
  TAxis *YaxctauFW = ctauFW_pT->GetYaxis();
  YaxctauFW->SetLimits(0.0,0.1);
  ctauFW_pT->GetXaxis()->SetRangeUser(0.0,30.0);
  ctauFW_pT->GetYaxis()->SetRangeUser(0.0,0.1);
  ctauFW_pT->Draw("AP*");

  new TCanvas;
  gPad->SetTickx();
  gPad->SetTicky();
  gPad->SetGridy();
  
  TF1 *FitFn2 = new TF1("FitFn2",Exp,0.0,30.0,2);
  TGraph *ctauMid_pT = new TGraph(5,x2bins,ctauMd);
  ctauMid_pT->SetLineColor(2);    
  ctauMid_pT->SetLineWidth(3); 
  ctauMid_pT->SetMarkerSize(1.5);
  ctauMid_pT->GetYaxis()->SetTitle("c#tau");
  ctauMid_pT->GetXaxis()->SetTitle("p_{T} bin");
  
  ctauMid_pT->Fit("FitFn2","", "",3.0,30.0);
  FitFn2->SetParNames("C1","n");

  TAxis *XaxctauMid = ctauMid_pT->GetXaxis();
  XaxctauMid->SetLimits(0.0,30.0);
  TAxis *YaxctauMid = ctauMid_pT->GetYaxis();
  YaxctauMid->SetLimits(0.0,0.1);
  ctauMid_pT->GetXaxis()->SetRangeUser(0.0,30.0);
  ctauMid_pT->GetYaxis()->SetRangeUser(0.0,0.1);
  ctauMid_pT->Draw("AP*");
  
  TLatex *t = new TLatex();
  t->SetNDC(); t->SetTextAlign(12);t->SetTextColor(1);
  t->SetTextSize(0.03);
  
  //t->DrawLatex(0.135,0.21," 10  pp               6.5-30   0.0-1.6");
  //lh->Draw("same");
  
  TF1 *myfunc1=ctauFW_pT->GetFunction("FitFn");
  TF1 *myfunc2=ctauMid_pT->GetFunction("FitFn2");
  
  TH1F *funHist = new TH1F("funHist","funHist",30,0.0,30.0);
  TH1F *funHist2 = new TH1F("funHist2","funHist2",30,0.0,30.0);
  
  funHist->Eval(myfunc1);
  funHist2->Eval(myfunc2);
  //funHist = myfunc->GetHistogram();
  //root > TH1F h("h","",100,0,10);
  //root > h.Eval(f1);

  cout<<"funHist:Entries "<<funHist->GetEntries()<<endl;
  for(int i=1;i<=funHist->GetNbinsX();++i)
    {
      cout<<"bin:pT "<<i<<"ctau: "<<funHist->GetBinContent(i)<<endl<<endl;
    }

  for(int i=1;i<=funHist2->GetNbinsX();++i)
    {
      cout<<"bin:pT "<<i<<"ctau: "<<funHist2->GetBinContent(i)<<endl<<endl;
    }

  new TCanvas;
  gPad->SetTickx();
  gPad->SetTicky();
  gPad->SetGridy();
  TAxis *XaxHistMid = funHist->GetXaxis();
  XaxHistMid->SetLimits(0.0,30.0);
  TAxis *YaxHistMid = funHist->GetYaxis();
  YaxHistMid->SetLimits(0.0,0.1);
  funHist->GetXaxis()->SetRangeUser(0.0,30.0);
  funHist->GetYaxis()->SetRangeUser(0.0,0.1);
  funHist->Draw();
  funHist2->SetLineColor(2);
  funHist2->Draw("same");
  //gPad->SaveAs("Plots/ctauMid.png");   
  //gPad->SaveAs("plots/ctauMid.pdf");   
  */

}
Example #7
0
void plotFR_QCD(){

  gROOT->Reset();
  gROOT->SetStyle("Plain");
  gStyle->SetStatFormat("6.4f");
  gStyle->SetFitFormat("6.4f");
  int BoxValue = 11111111; //4680;  
  gStyle->SetOptFit(11);
  gStyle->SetOptDate(0);
  gStyle->SetOptTitle(0);
  //gStyle->SetOptStat(BoxValue);
  gStyle->SetOptStat(0);
  gStyle->SetPadBorderMode(0);
  gStyle->SetCanvasColor(0); //(10);
  gStyle->SetPadLeftMargin(0.15);
  gStyle->SetPadBottomMargin(0.15);
  gStyle->SetPalette(0);
  TPaveLabel pl;
  TLatex lt;
  lt.SetTextFont(70);
  lt.SetTextAlign(12);
  lt.SetTextSize(0.07);
  lt.SetTextColor(1);

  TPaveText* tText1 = new TPaveText(0.70, 0.90, 0.90, 0.95, "brNDC");
  tText1->SetBorderSize(0);
  tText1->SetFillColor(0);
  tText1->SetFillStyle(0);
  TText *t1 = tText1->AddText("(13 TeV)");
  tText1->SetTextSize(0.035);
  //tText1->Draw(); 
  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  TPaveText* tText2 = new TPaveText(0.2, 0.90, 0.4, 0.95, "brNDC");
  tText2->SetBorderSize(0);
  tText2->SetFillColor(0);
  tText2->SetFillStyle(0);
  TText *t2 = tText2->AddText("CMS Spring15 Simulation");
  tText2->SetTextSize(0.035);
  //tText2->Draw(); 


  TLegend *leg = new TLegend(0.17, 0.77, 0.4, 0.85);
  leg->SetBorderSize(0.0);
  leg->SetMargin(0.3);
  leg->SetFillColor(0);
  leg->SetFillStyle(10);
  leg->SetLineColor(0);
  Float_t tsize2 = 0.03;
  leg->SetTextSize(tsize2); 

  
  TFile *_file0 = TFile::Open("ZprimetoMuMu-MC-CMSSW745_FR_QCD_25ns.root");
  

  TH1F *num; _file0->GetObject("h1_Num_Pt_w",num);
  TH1F *den; _file0->GetObject("h1_Den_Pt_w",den);

  TH1F *numMB; _file0->GetObject("h1_Num_Pt_Barrel_w",numMB);
  TH1F *denMB; _file0->GetObject("h1_Den_Pt_Barrel_w",denMB);

  TH1F *numME; _file0->GetObject("h1_Num_Pt_EndCap_w",numME);
  TH1F *denME; _file0->GetObject("h1_Den_Pt_EndCap_w",denME);

  
  double Nbins = num->GetNbinsX();
  cout << "Nbins=" << Nbins << endl;

  int nRebin=10;

  num->Rebin(nRebin);
  den->Rebin(nRebin);

  numMB->Rebin(nRebin);
  denMB->Rebin(nRebin);

  numME->Rebin(nRebin);
  denME->Rebin(nRebin);


  // 
  TH1F *fake=new TH1F("fake","fake",Nbins/nRebin,0.,2000.);
  TH1F *fakeMB=new TH1F("fakeMB","fakeMB",Nbins/nRebin,0.,2000.);
  TH1F *fakeME=new TH1F("fakeME","fakeME",Nbins/nRebin,0.,2000.);
   
  cout << "Bins=" << Nbins/nRebin << endl;

  int* arraysize = new int[1];
  arraysize[0]=Nbins/nRebin;
  Float_t xMB[arraysize[0]],yMB[arraysize[0]],exlMB[arraysize[0]],exhMB[arraysize[0]],eylMB[arraysize[0]],eyhMB[arraysize[0]];


  for (unsigned int i=1; i<=Nbins/nRebin;i++){
    // All Muon
    if (denMB->GetBinContent(i)>0.) {
      fakeMB->SetBinContent(i,double(numMB->GetBinContent(i)/denMB->GetBinContent(i)));

      xMB[i-1]=fakeMB->GetBinCenter(i);
      yMB[i-1]=fakeMB->GetBinContent(i);
      exlMB[i-1]=0.;
      exhMB[i-1]=0.;
      //eyhMB[i-1]=+0.5 + sqrt(fakeMB->GetBinContent(i)+0.25);
      //eylMB[i-1]=-0.5 + sqrt(fakeMB->GetBinContent(i)+0.25); 
      
      if (double(numMB->GetBinContent(i)/denMB->GetBinContent(i))<1.){
	fakeMB->SetBinError(i, sqrt( double(numMB->GetBinContent(i)/denMB->GetBinContent(i))*(1-double(numMB->GetBinContent(i)/denMB->GetBinContent(i)))/double(denMB->GetBinContent(i)) ) );}
      else fakeMB->SetBinError(i, sqrt( double(numMB->GetBinContent(i)/pow(denMB->GetBinContent(i),2)+1./pow(denMB->GetBinContent(i),3))));
      eyhMB[i-1]=fakeMB->GetBinError(i)/2.;
      eylMB[i-1]=fakeMB->GetBinError(i)/2.;      
    }
    else {
      fakeMB->SetBinContent(i,0.);
      fakeMB->SetBinError(i,0.);
      xMB[i-1] = 0.;
      eylMB[i-1] = 0.;
      eyhMB[i-1] = 0.;
      exlMB[i-1]=0.;
      exhMB[i-1]=0.;
    }

  }
 
  //TGraphAsymmErrors *grMB = new TGraphAsymmErrors(Nbins/nRebin,xMB,yMB,exlMB,exhMB,eylMB,eyhMB);
  TGraphAsymmErrors *grMB = new TGraphAsymmErrors();
  grMB->BayesDivide(numMB,denMB);

  //TGraphAsymmErrors *grMB = new TGraphAsymmErrors(numMB,denMB);
  grMB->SetMarkerColor(2);
  grMB->SetMarkerStyle(20);
  grMB->SetMarkerSize(0.95);

  //TF1* fn1 = new TF1("fn1","pol1",10,100);
  //fn1->SetLineColor(1);
  //grMB->Fit("fn1","R,smaes");

  //TF1* fn2 = new TF1("fn2",FittingFunc1,100,2000.0,3);
  //fn2->SetLineColor(1);
  //grMB->Fit("fn2","R");


  // ME
  Float_t xME[arraysize[0]],yME[arraysize[0]],exlME[arraysize[0]],exhME[arraysize[0]],eylME[arraysize[0]],eyhME[arraysize[0]];

  for (unsigned int i=1; i<=Nbins/nRebin;i++){
    // All Muon                                                                                                                                                                            
    if (denME->GetBinContent(i)>0.) {
      fakeME->SetBinContent(i,double(numME->GetBinContent(i)/denME->GetBinContent(i)));

      xME[i-1]=fakeME->GetBinCenter(i);
      yME[i-1]=fakeME->GetBinContent(i);
      exlME[i-1]=0.;
      exhME[i-1]=0.;
      //eyhME[i-1]=+0.5 + sqrt(fakeME->GetBinContent(i)+0.25);                                                                                                                               
      //eylME[i-1]=-0.5 + sqrt(fakeME->GetBinContent(i)+0.25);                                                                                

      if (double(numME->GetBinContent(i)/denME->GetBinContent(i))<1.){
        fakeME->SetBinError(i, sqrt( double(numME->GetBinContent(i)/denME->GetBinContent(i))*(1-double(numME->GetBinContent(i)/denME->GetBinContent(i)))/double(denME->GetBinContent(i)) ) );
      }
      else fakeME->SetBinError(i, sqrt( double(numME->GetBinContent(i)/pow(denME->GetBinContent(i),2)+1./pow(denME->GetBinContent(i),3))));
      eyhME[i-1]=fakeME->GetBinError(i)/2.;
      eylME[i-1]=fakeME->GetBinError(i)/2.;
    }
    else {
      fakeME->SetBinContent(i,0.);
      fakeME->SetBinError(i,0.);
      xME[i-1] = 0.;
      eylME[i-1] = 0.;
      eyhME[i-1] = 0.;
      exlME[i-1]=0.;
      exhME[i-1]=0.;
    }

  }


  //TGraphAsymmErrors *grME = new TGraphAsymmErrors(Nbins/nRebin,xME,yME,exlME,exhME,eylME,eyhME);  
  TGraphAsymmErrors *grME = new TGraphAsymmErrors();
  grME->BayesDivide(numME,denME);

  grME->SetMarkerColor(4);
  grME->SetMarkerStyle(20);
  grME->SetMarkerSize(0.95);
  

  
  TH2F *hframe=NULL,*hframe2=NULL; 
  hframe= new TH2F("hframe","hframe",500,50.,2000.,500,0.0001,2.0);
  hframe->GetYaxis()->SetTitle("Fake rate");
  hframe->GetXaxis()->SetTitle("p_{T} (GeV)");
  hframe->GetXaxis()->SetTitleOffset(1.7);
  hframe->GetYaxis()->SetTitleOffset(1.7);

  TCanvas *c1 = new TCanvas("c1","c1",800,600);

  c1->SetLogy(1);
  c1->SetLogx(1);
  //c1->SetGrid();
  
  gPad->SetTopMargin(0.12);
  gPad->SetLeftMargin(0.15);
  gPad->SetFillColor(0);
  gPad->SetTickx();
  gPad->SetTicky();
  // gPad->SetGridy();
  //gPad->SetGridx();
    
  c1->SetLogy(1);
  c1->SetLogx(1);
  // c1->SetGrid();
  
  grMB->SetLineColor(1);
  grMB->GetXaxis()->SetTitleOffset(1.7);
  grMB->GetYaxis()->SetTitleOffset(1.7);
  grMB->GetXaxis()->SetLabelSize(0.03);
  grMB->GetYaxis()->SetLabelSize(0.03);
  grMB->GetXaxis()->SetTitle("p_{T} (GeV)");
  grMB->GetYaxis()->SetTitle("Fake rate");
  grMB->GetXaxis()->SetTitleOffset(1.5);
  grMB->GetYaxis()->SetTitleOffset(2.0);
  grMB->GetXaxis()->SetTitleSize(0.05);
  grMB->GetXaxis()->SetLabelSize(0.03);
  grMB->GetYaxis()->SetLabelSize(0.03);
  leg->AddEntry(grMB,"barrel","p");

  grME->SetLineColor(1);
  grME->GetXaxis()->SetTitleOffset(1.7);
  grME->GetYaxis()->SetTitleOffset(1.7);
  grME->GetXaxis()->SetLabelSize(0.03);
  grME->GetYaxis()->SetLabelSize(0.03);
  grME->GetXaxis()->SetTitle("p_{T} (GeV)");
  grME->GetYaxis()->SetTitle("Fake rate");
  grME->GetXaxis()->SetTitleOffset(1.5);
  grME->GetYaxis()->SetTitleOffset(2.0);
  grME->GetXaxis()->SetTitleSize(0.05);
  grME->GetXaxis()->SetLabelSize(0.03);
  grME->GetYaxis()->SetLabelSize(0.03);
  leg->AddEntry(grME,"endcap","p");

  hframe->Draw();
  grMB->Draw("Psame");
  grME->Draw("Psame");
  tText1->Draw("same");
  tText2->Draw("same");
  leg->Draw("same");
  
  c1->SaveAs("FR_QCD.png");
  c1->SaveAs("FR_QCD.pdf");
  c1->SaveAs("FR_QCD.eps");
  //c1->SaveAs("FR_QCD.root");

  TFile *fileX = new TFile("FR_QCD.root", "RECREATE");
  fileX->cd();
  numMB->Write();
  denMB->Write();
  numME->Write();
  denME->Write();
  //grMB->Write();
  //grME->Write();
  fileX->Write();
  fileX->Close();


}   
Example #8
0
//int main(int argc, char** argv)
int cmp_ps_polars()
{
        ifstream infile("cmp_ps_polars.dat");
        char line[1000];
        infile.getline(line,1000);
        int n=0;
        double enes[21];
        double eenes[21];
        double n_p[21];
        double ne_p[21];
        double n_pol[21];
        double ne_pol[21];

        double n_rela[21];
        double ne_rela[21];
         while (!infile.eof()){
	    infile.getline(line,1000);
	    if (line[0]=='\0') continue;
	    istringstream iss;
	    iss.clear();
	    iss.str(line);
	    //iss.seekg(30,ios::beg);
	    iss>>enes[n]>>n_p[n]>>ne_p[n]>>n_pol[n]>>ne_pol[n];
	  //n_pol[n] = n_pol[n];
	  //ne_pol[n] = ne_pol[n];
	    eenes[n] = 0;

	    // relative difference
	    n_rela[n]  = n_pol[n]/n_p[n];
	    ne_rela[n] = n_pol[n]/n_p[n]*sqrt(pow(ne_pol[n]/n_pol[n],2)+pow(ne_p[n]/n_p[n],2));
	    
	    cout<<enes[n]<<"\t"<<(n_rela[n]-1)*100<<endl;
	    
	    n++;
        }

        TGraphErrors* g_p = new TGraphErrors(n,enes,n_p,eenes,ne_p);
        TGraphErrors* g_pol = new TGraphErrors(n,enes,n_pol,eenes,ne_pol);
        g_p->SetMarkerStyle(20);
        g_p->SetMarkerColor(2);
        g_p->SetFillColor(0);
        g_p->SetTitle("");
        g_p->SetLineWidth(2);
        g_p->GetXaxis()->SetNdivisions(505);
        g_p->GetYaxis()->SetNdivisions(505);
        g_p->GetXaxis()->SetTitle("#sqrt{s} (GeV)");
        g_p->GetYaxis()->SetTitle("events");
        g_p->GetXaxis()->SetLabelSize(0.06);
        g_p->GetXaxis()->SetTitleSize(0.06);
        g_p->GetYaxis()->SetLabelSize(0.06);
        g_p->GetYaxis()->SetTitleSize(0.07);
        g_p->GetXaxis()->SetLabelOffset(1.5);
        g_p->GetYaxis()->SetTitleOffset(0.75);
        g_pol->SetMarkerStyle(21);
        g_pol->SetMarkerColor(3);
        g_pol->SetFillColor(0);
        g_pol->SetLineWidth(2);
        
        TLegend *legendf = new TLegend(0.42,0.65,0.95,0.85);
        legendf->SetBorderSize(0); 
        legendf->SetMargin(0.25); 
        legendf->SetFillStyle(0); 
        legendf->AddEntry(g_p,"N from p spectrum");
        legendf->AddEntry(g_pol,"N from polar angle spectrum");

        TCanvas *c1 = new TCanvas();
        TPad *pad1 = new TPad("pad1","pad1",0.05,0.3,1.0,0.98);
        TPad *pad2 = new TPad("pad2","pad2",0.05,0.02,1.0,0.3);
        //c1->SetMargin(0.15,0.1,0.15,0.1);
        pad1->SetTopMargin(0.05);
        pad1->SetBottomMargin(0.02);
        pad2->SetTopMargin(0.05);
        pad2->SetBottomMargin(0.3);
        pad1->Draw();
        pad2->Draw();
        pad1->cd();
 
        g_p->Draw("AP");
        g_pol->Draw("P");
        legendf->Draw();

        pad2->cd();
        pad2->SetGridy();
        // relative comparison
      //TCanvas *c2 = new TCanvas();
      //c2->SetMargin(0.15,0.1,0.15,0.1);
        TGraphErrors* g_rela = new TGraphErrors(n,enes,n_rela,eenes,ne_rela);
        g_rela->SetMarkerStyle(20);
        g_rela->SetMarkerColor(2);
        g_rela->SetFillColor(0);
        g_rela->SetTitle("");
        g_rela->SetLineWidth(2);
        g_rela->GetXaxis()->SetNdivisions(505);
        g_rela->GetYaxis()->SetNdivisions(502);
        g_rela->GetXaxis()->SetTitle("#sqrt{s} (GeV)");
        g_rela->GetYaxis()->SetTitle("N_{pol}/N_{p}");
        g_rela->GetXaxis()->SetLabelSize(0.15);
        g_rela->GetXaxis()->SetTitleSize(0.15);
        g_rela->GetYaxis()->SetLabelSize(0.15);
        g_rela->GetYaxis()->SetTitleSize(0.15);
        g_rela->GetYaxis()->SetTitleOffset(0.3);
        g_rela->GetYaxis()->SetRangeUser(0.5,1.5);
 
        g_rela->Draw("AP");

        c1->cd();
        c1->Print("cmp_ps_pols.pdf");
        return 0;
}
void produceRatePlots(TString ext)
{
  gem_dir = "files/"; 
  gem_label = "gem98";

  TString the_ttl = "         L1 Single Muon Trigger                             CMS Simulation;L1 candidate muon p_{T}^{cut} [GeV/c];rate [kHz]";
  TString plots = "plots/rate/";

  //gStyle->SetStatW(0.13);
  //gStyle->SetStatH(0.08);
  gStyle->SetStatW(0.07);
  gStyle->SetStatH(0.06);
  gStyle->SetOptStat(0);

  gStyle->SetTitleStyle(0);
  gStyle->SetTitleAlign(13);// coord in top left
  gStyle->SetTitleX(0.);
  gStyle->SetTitleY(1.);
  gStyle->SetTitleW(1);
  gStyle->SetTitleH(0.058);
  gStyle->SetTitleBorderSize(0);

  gStyle->SetPadLeftMargin(0.126);
  gStyle->SetPadRightMargin(0.04);
  gStyle->SetPadTopMargin(0.06);
  gStyle->SetPadBottomMargin(0.13);

  gStyle->SetMarkerStyle(1);

  // ********** PAT2 **********

  getPTHistos("minbias_pt06_pat2");
  hh = (TH1D*)result_def_3s1b->Clone("gem_new");
  for (int b = hh->FindBin(6.01); b <= hh->GetNbinsX(); ++b) hh->SetBinContent(b, 0);
  hh_all = (TH1D*)result_def_eta_all_3s1b->Clone("gem_new_eta_all");
  for (int b = hh_all->FindBin(6.01); b <= hh_all->GetNbinsX(); ++b) hh_all->SetBinContent(b, 0);
  hh_no1a = (TH1D*)result_def_eta_no1a_3s1b->Clone("gem_new_eta_no1a");
  for (int b = hh_no1a->FindBin(6.01); b <= hh_no1a->GetNbinsX(); ++b) hh_no1a->SetBinContent(b, 0);
  hh_2s1b = (TH1D*)result_def_2s1b->Clone("gem_new_2s1b");
  for (int b = hh_2s1b->FindBin(6.01); b <= hh_2s1b->GetNbinsX(); ++b) hh_2s1b->SetBinContent(b, 0);

  h06 = (TH1D*)result_gem->Clone("gem_new_06");
  for (int b = h06->FindBin(6.01); b < h06->FindBin(10.01); ++b) {hh->SetBinContent(b, h06->GetBinContent(b)); hh->SetBinError(b, h06->GetBinError(b));}
  h06_all = (TH1D*)result_gem_eta_all->Clone("gem_new_eta_all_06");
  for (int b = h06_all->FindBin(6.01); b < h06_all->FindBin(10.01); ++b) {hh_all->SetBinContent(b, h06_all->GetBinContent(b)); hh_all->SetBinError(b, h06_all->GetBinError(b));}
  h06_no1a = (TH1D*)result_gem_eta_no1a->Clone("gem_new_eta_no1a_06");
  for (int b = h06_no1a->FindBin(6.01); b < h06_no1a->FindBin(10.01); ++b) {hh_no1a->SetBinContent(b, h06_no1a->GetBinContent(b)); hh_no1a->SetBinError(b, h06_no1a->GetBinError(b));}
  h06_2s1b = (TH1D*)result_gem_2s1b->Clone("gem_new_2s1b_06");
  for (int b = h06_2s1b->FindBin(6.01); b < h06_2s1b->FindBin(10.01); ++b) {hh_2s1b->SetBinContent(b, h06_2s1b->GetBinContent(b)); hh_2s1b->SetBinError(b, h06_2s1b->GetBinError(b));}

  getPTHistos("minbias_pt10_pat2");
  h10 = (TH1D*)result_gem->Clone("gem10");
  for (int b = h10->FindBin(10.01); b < h10->FindBin(15.01); ++b) {hh->SetBinContent(b, h10->GetBinContent(b)); hh->SetBinError(b, h10->GetBinError(b));}
  h10_all = (TH1D*)result_gem_eta_all->Clone("gem_new_eta_all_10");
  for (int b = h10_all->FindBin(10.01); b < h10_all->FindBin(15.01); ++b) {hh_all->SetBinContent(b, h10_all->GetBinContent(b)); hh_all->SetBinError(b, h10_all->GetBinError(b));}
  h10_no1a = (TH1D*)result_gem_eta_no1a->Clone("gem_new_eta_no1a_10");
  for (int b = h10_no1a->FindBin(10.01); b < h10_no1a->FindBin(15.01); ++b) {hh_no1a->SetBinContent(b, h10_no1a->GetBinContent(b)); hh_no1a->SetBinError(b, h10_no1a->GetBinError(b));}
  h10_2s1b = (TH1D*)result_gem_2s1b->Clone("gem_new_2s1b_10");
  for (int b = h10_2s1b->FindBin(10.01); b < h10_2s1b->FindBin(15.01); ++b) {hh_2s1b->SetBinContent(b, h10_2s1b->GetBinContent(b)); hh_2s1b->SetBinError(b, h10_2s1b->GetBinError(b));}

  getPTHistos("minbias_pt15_pat2");
  h15 = (TH1D*)result_gem->Clone("gem15");
  for (int b = h15->FindBin(15.01); b < h15->FindBin(20.01); ++b) {hh->SetBinContent(b, h15->GetBinContent(b)); hh->SetBinError(b, h15->GetBinError(b));}
  h15_all = (TH1D*)result_gem_eta_all->Clone("gem_new_eta_all_15");
  for (int b = h15_all->FindBin(15.01); b < h15_all->FindBin(20.01); ++b) {hh_all->SetBinContent(b, h15_all->GetBinContent(b)); hh_all->SetBinError(b, h15_all->GetBinError(b));}
  h15_no1a = (TH1D*)result_gem_eta_no1a->Clone("gem_new_eta_no1a_15");
  for (int b = h15_no1a->FindBin(15.01); b < h15_no1a->FindBin(20.01); ++b) {hh_no1a->SetBinContent(b, h15_no1a->GetBinContent(b)); hh_no1a->SetBinError(b, h15_no1a->GetBinError(b));}
  h15_2s1b = (TH1D*)result_gem_2s1b->Clone("gem_new_2s1b_15");
  for (int b = h15_2s1b->FindBin(15.01); b < h15_2s1b->FindBin(20.01); ++b) {hh_2s1b->SetBinContent(b, h15_2s1b->GetBinContent(b)); hh_2s1b->SetBinError(b, h15_2s1b->GetBinError(b));}

  getPTHistos("minbias_pt20_pat2");
  h20 = (TH1D*)result_gem->Clone("gem20");
  for (int b = h20->FindBin(20.01); b < h20->FindBin(30.01); ++b) {hh->SetBinContent(b, h20->GetBinContent(b)); hh->SetBinError(b, h20->GetBinError(b));}
  h20_all = (TH1D*)result_gem_eta_all->Clone("gem_new_eta_all_20");
  for (int b = h20_all->FindBin(20.01); b < h20_all->FindBin(30.01); ++b) {hh_all->SetBinContent(b, h20_all->GetBinContent(b)); hh_all->SetBinError(b, h20_all->GetBinError(b));}
  h20_no1a = (TH1D*)result_gem_eta_no1a->Clone("gem_new_eta_no1a_20");
  for (int b = h20_no1a->FindBin(20.01); b < h20_no1a->FindBin(30.01); ++b) {hh_no1a->SetBinContent(b, h20_no1a->GetBinContent(b)); hh_no1a->SetBinError(b, h20_no1a->GetBinError(b));}
  h20_2s1b = (TH1D*)result_gem_2s1b->Clone("gem_new_2s1b_20");
  for (int b = h20_2s1b->FindBin(20.01); b < h20_2s1b->FindBin(30.01); ++b) {hh_2s1b->SetBinContent(b, h20_2s1b->GetBinContent(b)); hh_2s1b->SetBinError(b, h20_2s1b->GetBinError(b));}

  getPTHistos("minbias_pt30_pat2");
  h30 = (TH1D*)result_gem->Clone("gem30");
  for (int b = h30->FindBin(30.01); b <= h30->FindBin(40.01); ++b) {hh->SetBinContent(b, h30->GetBinContent(b)); hh->SetBinError(b, h30->GetBinError(b));}
  h30_all = (TH1D*)result_gem_eta_all->Clone("gem_new_eta_all_30");
  for (int b = h30_all->FindBin(30.01); b < h30_all->FindBin(40.01); ++b) {hh_all->SetBinContent(b, h30_all->GetBinContent(b)); hh_all->SetBinError(b, h30_all->GetBinError(b));}
  h30_no1a = (TH1D*)result_gem_eta_no1a->Clone("gem_new_eta_no1a_30");
  for (int b = h30_no1a->FindBin(30.01); b < h30_no1a->FindBin(40.01); ++b) {hh_no1a->SetBinContent(b, h30_no1a->GetBinContent(b)); hh_no1a->SetBinError(b, h30_no1a->GetBinError(b));}
  h30_2s1b = (TH1D*)result_gem_2s1b->Clone("gem_new_2s1b_30");
  for (int b = h30_2s1b->FindBin(30.01); b < h30_2s1b->FindBin(40.01); ++b) {hh_2s1b->SetBinContent(b, h30_2s1b->GetBinContent(b)); hh_2s1b->SetBinError(b, h30_2s1b->GetBinError(b));}

  getPTHistos("minbias_pt40_pat2");
  h40 = (TH1D*)result_gem->Clone("gem30");
  for (int b = h40->FindBin(40.01); b <= h40->GetNbinsX(); ++b) {hh->SetBinContent(b, h40->GetBinContent(b)); hh->SetBinError(b, h40->GetBinError(b));}
  h40_all = (TH1D*)result_gem_eta_all->Clone("gem_new_eta_all_40");
  for (int b = h40_all->FindBin(40.01); b < h40_all->GetNbinsX(); ++b) {hh_all->SetBinContent(b, h40_all->GetBinContent(b)); hh_all->SetBinError(b, h40_all->GetBinError(b));}
  h40_no1a = (TH1D*)result_gem_eta_no1a->Clone("gem_new_eta_no1a_40");
  for (int b = h40_no1a->FindBin(40.01); b < h40_no1a->GetNbinsX(); ++b) {hh_no1a->SetBinContent(b, h40_no1a->GetBinContent(b)); hh_no1a->SetBinError(b, h40_no1a->GetBinError(b));}
  h40_2s1b = (TH1D*)result_gem_2s1b->Clone("gem_new_2s1b_40");
  for (int b = h40_2s1b->FindBin(40.01); b < h40_2s1b->GetNbinsX(); ++b) {hh_2s1b->SetBinContent(b, h40_2s1b->GetBinContent(b)); hh_2s1b->SetBinError(b, h40_2s1b->GetBinError(b));}

  for (int b = 1; b <= hh->GetNbinsX(); ++b) if (hh->GetBinContent(b)==0) hh->SetBinError(b, 0.);
  for (int b = 1; b <= hh_all->GetNbinsX(); ++b) if (hh_all->GetBinContent(b)==0) hh_all->SetBinError(b, 0.);
  for (int b = 1; b <= hh_no1a->GetNbinsX(); ++b) if (hh_no1a->GetBinContent(b)==0) hh_no1a->SetBinError(b, 0.);
  for (int b = 1; b <= hh_2s1b->GetNbinsX(); ++b) if (hh_2s1b->GetBinContent(b)==0) hh_2s1b->SetBinError(b, 0.);

  hh = setPTHisto(hh, the_ttl, kGreen+3, 1, 1);
  hh_all = setPTHisto(hh_all, the_ttl, kGreen+3, 1, 1);
  hh_no1a = setPTHisto(hh_no1a, the_ttl, kGreen+3, 1, 1);
  hh_2s1b = setPTHisto(hh_2s1b, the_ttl, kGreen+3, 1, 1);

  result_gmtsing = setPTHisto(result_gmtsing, the_ttl, kAzure+1, 1, 1);

  result_def = setPTHisto(result_def, the_ttl, kAzure+9, 1, 1);
  result_def_2s = setPTHisto(result_def_2s, the_ttl, kAzure+9, 1, 1);
  result_def_3s1b = setPTHisto(result_def_3s1b, the_ttl, kAzure+9, 1, 1);
  result_def_2s1b = setPTHisto(result_def_2s1b, the_ttl, kAzure+9, 1, 1);
  result_def_eta_all = setPTHisto(result_def_eta_all, the_ttl, kAzure+9, 1, 1);
  result_def_eta_all_3s1b = setPTHisto(result_def_eta_all_3s1b, the_ttl, kAzure+9, 1, 1);
  result_def_eta_no1a = setPTHisto(result_def_eta_no1a, the_ttl, kAzure+9, 1, 1);
  result_def_eta_no1a_3s1b = setPTHisto(result_def_eta_no1a_3s1b, the_ttl, kAzure+9, 1, 1);

  result_def_2s__pat2 = (TH1D*) result_def_2s->Clone("result_def_2s__pat2");
  result_def_3s__pat2 = (TH1D*) result_def->Clone("result_def_2s__pat2");
  result_def_2s1b__pat2 = (TH1D*) result_def_2s1b->Clone("result_def_2s1b__pat2");
  result_def_3s1b__pat2 = (TH1D*) result_def_3s1b->Clone("result_def_3s1b__pat2");
  result_gmtsing__pat2 = (TH1D*) result_gmtsing->Clone("result_gmtsing__pat2");;

  result_gem_2s1b__pat2 = (TH1D*) hh_2s1b->Clone("result_gem_2s1b__pat2");
  result_gem_3s1b__pat2 = (TH1D*) hh->Clone("result_gem_2s1b__pat2");

  // ********** PAT8 **********

  getPTHistos("minbias_pt06_pat8");
  hh = (TH1D*)result_def_3s1b->Clone("gem_new");
  for (int b = hh->FindBin(6.01); b <= hh->GetNbinsX(); ++b) hh->SetBinContent(b, 0);
  hh_all = (TH1D*)result_def_eta_all_3s1b->Clone("gem_new_eta_all");
  for (int b = hh_all->FindBin(6.01); b <= hh_all->GetNbinsX(); ++b) hh_all->SetBinContent(b, 0);
  hh_no1a = (TH1D*)result_def_eta_no1a_3s1b->Clone("gem_new_eta_no1a");
  for (int b = hh_no1a->FindBin(6.01); b <= hh_no1a->GetNbinsX(); ++b) hh_no1a->SetBinContent(b, 0);
  hh_2s1b = (TH1D*)result_def_2s1b->Clone("gem_new_2s1b");
  for (int b = hh_2s1b->FindBin(6.01); b <= hh_2s1b->GetNbinsX(); ++b) hh_2s1b->SetBinContent(b, 0);

  h06 = (TH1D*)result_gem->Clone("gem_new_06");
  for (int b = h06->FindBin(6.01); b < h06->FindBin(10.01); ++b) {hh->SetBinContent(b, h06->GetBinContent(b)); hh->SetBinError(b, h06->GetBinError(b));}
  h06_all = (TH1D*)result_gem_eta_all->Clone("gem_new_eta_all_06");
  for (int b = h06_all->FindBin(6.01); b < h06_all->FindBin(10.01); ++b) {hh_all->SetBinContent(b, h06_all->GetBinContent(b)); hh_all->SetBinError(b, h06_all->GetBinError(b));}
  h06_no1a = (TH1D*)result_gem_eta_no1a->Clone("gem_new_eta_no1a_06");
  for (int b = h06_no1a->FindBin(6.01); b < h06_no1a->FindBin(10.01); ++b) {hh_no1a->SetBinContent(b, h06_no1a->GetBinContent(b)); hh_no1a->SetBinError(b, h06_no1a->GetBinError(b));}
  h06_2s1b = (TH1D*)result_gem_2s1b->Clone("gem_new_2s1b_06");
  for (int b = h06_2s1b->FindBin(6.01); b < h06_2s1b->FindBin(10.01); ++b) {hh_2s1b->SetBinContent(b, h06_2s1b->GetBinContent(b)); hh_2s1b->SetBinError(b, h06_2s1b->GetBinError(b));}

  getPTHistos("minbias_pt10_pat8");
  h10 = (TH1D*)result_gem->Clone("gem10");
  for (int b = h10->FindBin(10.01); b < h10->FindBin(15.01); ++b) {hh->SetBinContent(b, h10->GetBinContent(b)); hh->SetBinError(b, h10->GetBinError(b));}
  h10_all = (TH1D*)result_gem_eta_all->Clone("gem_new_eta_all_10");
  for (int b = h10_all->FindBin(10.01); b < h10_all->FindBin(15.01); ++b) {hh_all->SetBinContent(b, h10_all->GetBinContent(b)); hh_all->SetBinError(b, h10_all->GetBinError(b));}
  h10_no1a = (TH1D*)result_gem_eta_no1a->Clone("gem_new_eta_no1a_10");
  for (int b = h10_no1a->FindBin(10.01); b < h10_no1a->FindBin(15.01); ++b) {hh_no1a->SetBinContent(b, h10_no1a->GetBinContent(b)); hh_no1a->SetBinError(b, h10_no1a->GetBinError(b));}
  h10_2s1b = (TH1D*)result_gem_2s1b->Clone("gem_new_2s1b_10");
  for (int b = h10_2s1b->FindBin(10.01); b < h10_2s1b->FindBin(15.01); ++b) {hh_2s1b->SetBinContent(b, h10_2s1b->GetBinContent(b)); hh_2s1b->SetBinError(b, h10_2s1b->GetBinError(b));}

  getPTHistos("minbias_pt15_pat8");
  h15 = (TH1D*)result_gem->Clone("gem15");
  for (int b = h15->FindBin(15.01); b < h15->FindBin(20.01); ++b) {hh->SetBinContent(b, h15->GetBinContent(b)); hh->SetBinError(b, h15->GetBinError(b));}
  h15_all = (TH1D*)result_gem_eta_all->Clone("gem_new_eta_all_15");
  for (int b = h15_all->FindBin(15.01); b < h15_all->FindBin(20.01); ++b) {hh_all->SetBinContent(b, h15_all->GetBinContent(b)); hh_all->SetBinError(b, h15_all->GetBinError(b));}
  h15_no1a = (TH1D*)result_gem_eta_no1a->Clone("gem_new_eta_no1a_15");
  for (int b = h15_no1a->FindBin(15.01); b < h15_no1a->FindBin(20.01); ++b) {hh_no1a->SetBinContent(b, h15_no1a->GetBinContent(b)); hh_no1a->SetBinError(b, h15_no1a->GetBinError(b));}
  h15_2s1b = (TH1D*)result_gem_2s1b->Clone("gem_new_2s1b_15");
  for (int b = h15_2s1b->FindBin(15.01); b < h15_2s1b->FindBin(20.01); ++b) {hh_2s1b->SetBinContent(b, h15_2s1b->GetBinContent(b)); hh_2s1b->SetBinError(b, h15_2s1b->GetBinError(b));}

  getPTHistos("minbias_pt20_pat8");
  h20 = (TH1D*)result_gem->Clone("gem20");
  for (int b = h20->FindBin(20.01); b < h20->FindBin(30.01); ++b) {hh->SetBinContent(b, h20->GetBinContent(b)); hh->SetBinError(b, h20->GetBinError(b));}
  h20_all = (TH1D*)result_gem_eta_all->Clone("gem_new_eta_all_20");
  for (int b = h20_all->FindBin(20.01); b < h20_all->FindBin(30.01); ++b) {hh_all->SetBinContent(b, h20_all->GetBinContent(b)); hh_all->SetBinError(b, h20_all->GetBinError(b));}
  h20_no1a = (TH1D*)result_gem_eta_no1a->Clone("gem_new_eta_no1a_20");
  for (int b = h20_no1a->FindBin(20.01); b < h20_no1a->FindBin(30.01); ++b) {hh_no1a->SetBinContent(b, h20_no1a->GetBinContent(b)); hh_no1a->SetBinError(b, h20_no1a->GetBinError(b));}
  h20_2s1b = (TH1D*)result_gem_2s1b->Clone("gem_new_2s1b_20");
  for (int b = h20_2s1b->FindBin(20.01); b < h20_2s1b->FindBin(30.01); ++b) {hh_2s1b->SetBinContent(b, h20_2s1b->GetBinContent(b)); hh_2s1b->SetBinError(b, h20_2s1b->GetBinError(b));}

  getPTHistos("minbias_pt30_pat8");
  h30 = (TH1D*)result_gem->Clone("gem30");
  for (int b = h30->FindBin(30.01); b <= h30->FindBin(40.01); ++b) {hh->SetBinContent(b, h30->GetBinContent(b)); hh->SetBinError(b, h30->GetBinError(b));}
  h30_all = (TH1D*)result_gem_eta_all->Clone("gem_new_eta_all_30");
  for (int b = h30_all->FindBin(30.01); b < h30_all->FindBin(40.01); ++b) {hh_all->SetBinContent(b, h30_all->GetBinContent(b)); hh_all->SetBinError(b, h30_all->GetBinError(b));}
  h30_no1a = (TH1D*)result_gem_eta_no1a->Clone("gem_new_eta_no1a_30");
  for (int b = h30_no1a->FindBin(30.01); b < h30_no1a->FindBin(40.01); ++b) {hh_no1a->SetBinContent(b, h30_no1a->GetBinContent(b)); hh_no1a->SetBinError(b, h30_no1a->GetBinError(b));}
  h30_2s1b = (TH1D*)result_gem_2s1b->Clone("gem_new_2s1b_30");
  for (int b = h30_2s1b->FindBin(30.01); b < h30_2s1b->FindBin(40.01); ++b) {hh_2s1b->SetBinContent(b, h30_2s1b->GetBinContent(b)); hh_2s1b->SetBinError(b, h30_2s1b->GetBinError(b));}

  getPTHistos("minbias_pt40_pat8");
  h40 = (TH1D*)result_gem->Clone("gem30");
  for (int b = h40->FindBin(40.01); b <= h40->GetNbinsX(); ++b) {hh->SetBinContent(b, h40->GetBinContent(b)); hh->SetBinError(b, h40->GetBinError(b));}
  h40_all = (TH1D*)result_gem_eta_all->Clone("gem_new_eta_all_40");
  for (int b = h40_all->FindBin(40.01); b < h40_all->GetNbinsX(); ++b) {hh_all->SetBinContent(b, h40_all->GetBinContent(b)); hh_all->SetBinError(b, h40_all->GetBinError(b));}
  h40_no1a = (TH1D*)result_gem_eta_no1a->Clone("gem_new_eta_no1a_40");
  for (int b = h40_no1a->FindBin(40.01); b < h40_no1a->GetNbinsX(); ++b) {hh_no1a->SetBinContent(b, h40_no1a->GetBinContent(b)); hh_no1a->SetBinError(b, h40_no1a->GetBinError(b));}
  h40_2s1b = (TH1D*)result_gem_2s1b->Clone("gem_new_2s1b_40");
  for (int b = h40_2s1b->FindBin(40.01); b < h40_2s1b->GetNbinsX(); ++b) {hh_2s1b->SetBinContent(b, h40_2s1b->GetBinContent(b)); hh_2s1b->SetBinError(b, h40_2s1b->GetBinError(b));}

  for (int b = 1; b <= hh->GetNbinsX(); ++b) if (hh->GetBinContent(b)==0) hh->SetBinError(b, 0.);
  for (int b = 1; b <= hh_all->GetNbinsX(); ++b) if (hh_all->GetBinContent(b)==0) hh_all->SetBinError(b, 0.);
  for (int b = 1; b <= hh_no1a->GetNbinsX(); ++b) if (hh_no1a->GetBinContent(b)==0) hh_no1a->SetBinError(b, 0.);
  for (int b = 1; b <= hh_2s1b->GetNbinsX(); ++b) if (hh_2s1b->GetBinContent(b)==0) hh_2s1b->SetBinError(b, 0.);

  hh = setPTHisto(hh, the_ttl, kGreen+3, 1, 1);
  hh_all = setPTHisto(hh_all, the_ttl, kGreen+3, 1, 1);
  hh_no1a = setPTHisto(hh_no1a, the_ttl, kGreen+3, 1, 1);
  hh_2s1b = setPTHisto(hh_2s1b, the_ttl, kGreen+3, 1, 1);

  result_gmtsing = setPTHisto(result_gmtsing, the_ttl, kAzure+1, 1, 1);

  result_def = setPTHisto(result_def, the_ttl, kAzure+9, 1, 1);
  result_def_2s = setPTHisto(result_def_2s, the_ttl, kAzure+9, 1, 1);
  result_def_3s1b = setPTHisto(result_def_3s1b, the_ttl, kAzure+9, 1, 1);
  result_def_2s1b = setPTHisto(result_def_2s1b, the_ttl, kAzure+9, 1, 1);
  result_def_eta_all = setPTHisto(result_def_eta_all, the_ttl, kAzure+9, 1, 1);
  result_def_eta_all_3s1b = setPTHisto(result_def_eta_all_3s1b, the_ttl, kAzure+9, 1, 1);
  result_def_eta_no1a = setPTHisto(result_def_eta_no1a, the_ttl, kAzure+9, 1, 1);
  result_def_eta_no1a_3s1b = setPTHisto(result_def_eta_no1a_3s1b, the_ttl, kAzure+9, 1, 1);

  result_def_2s__pat8 = (TH1D*) result_def_2s->Clone("result_def_2s__pat8");
  result_def_3s__pat8 = (TH1D*) result_def->Clone("result_def_2s__pat8");
  result_def_2s1b__pat8 = (TH1D*) result_def_2s1b->Clone("result_def_2s1b__pat8");
  result_def_3s1b__pat8 = (TH1D*) result_def_3s1b->Clone("result_def_3s1b__pat8");
  result_gmtsing__pat8 = (TH1D*) result_gmtsing->Clone("result_gmtsing__pat8");;

  result_gem_2s1b__pat8 = (TH1D*) hh_2s1b->Clone("result_gem_2s1b__pat8");
  result_gem_3s1b__pat8 = (TH1D*) hh->Clone("result_gem_2s1b__pat8");

  ////////////////////////
  // PLOTS FOR APPROVAL //
  ////////////////////////
  {
    Color_t col0 = kRed;
    Color_t col1 = kViolet+1;
    Color_t col2 = kAzure+2;
    Color_t col3 = kGreen-2;

    result_gmtsing__pat2->SetFillColor(col0);
    result_gmtsing__pat8->SetFillColor(col0);

    result_def_2s__pat2->SetFillColor(col1);
    result_def_2s1b__pat2->SetFillColor(col2);
    result_gem_2s1b__pat2->SetFillColor(col3);

    result_def_3s__pat2->SetFillColor(col1);
    result_def_3s1b__pat2->SetFillColor(col2);
    result_gem_3s1b__pat2->SetFillColor(col3);

    result_def_2s__pat8->SetFillColor(col1);
    result_def_2s1b__pat8->SetFillColor(col2);
    result_gem_2s1b__pat8->SetFillColor(col3);

    result_def_3s__pat8->SetFillColor(col1);
    result_def_3s1b__pat8->SetFillColor(col2);
    result_gem_3s1b__pat8->SetFillColor(col3);

    // GMT; CSCTF 2 stubs; CSCTF 2 stubs + ME1/b; CSCTF 2 stubs + ME1/b + GEM -- LOOSE -- Absolute + ratio
    TCanvas* c = new TCanvas("c","c",800,800);
    c->Clear();
    TPad *pad1 = new TPad("pad1","top pad",0.0,0.25,1.0,1.0);
    pad1->Draw();
    TPad *pad2 = new TPad("pad2","bottom pad",0,0.,1.0,.30);
    pad2->Draw();

    pad1->cd();
    pad1->SetLogx(1);
    pad1->SetLogy(1);
    pad1->SetGridx(1);
    pad1->SetGridy(1);
    pad1->SetFrameBorderMode(0);
    pad1->SetFillColor(kWhite);

    result_gmtsing__pat2->Draw("e3");
    result_def_2s__pat2->Draw("same e3");
    result_def_2s1b__pat2->Draw("same e3");
    result_gem_2s1b__pat2->Draw("same e3");
    result_gmtsing__pat2->Draw("same e3");
    result_gmtsing__pat2->GetYaxis()->SetRangeUser(0.1, 10000.);
    result_gmtsing__pat2->GetXaxis()->SetTitle("");
 
    TLegend *leg0 = new TLegend(0.365,0.88,.93,0.93,NULL,"brNDC");
    leg0->SetBorderSize(0);
    leg0->SetMargin(0.235);
    leg0->SetFillStyle(0);
    leg0->SetTextSize(0.04);
    leg0->SetFillStyle(1001);
    leg0->SetFillColor(kWhite);
    leg0->AddEntry(result_gmtsing__pat2,"Standard Configuration (GMT 2012)","f");
    leg0->Draw();
 
    TLegend *leg = new TLegend(0.45,0.68,.93,0.86,"L1 Selections (#geq 2 stations):","brNDC");
    leg->SetMargin(0.25);
    leg->SetBorderSize(0);
    leg->SetFillStyle(1001);
    leg->SetFillColor(kWhite);
    leg->SetTextSize(0.04);
    leg->SetFillStyle(1001);
    leg->SetFillColor(kWhite);
    //    leg->AddEntry((TObject*)0,          "L1 Selections (#geq 2 stations):","");
    leg->AddEntry(result_def_2s__pat2,  "CSC, loose","f");
    leg->AddEntry(result_def_2s1b__pat2,"CSC, tight","f");
    leg->AddEntry(result_gem_2s1b__pat2,"GEM+CSC Integrated Trigger","f");
    leg->Draw();

    leg->Draw();
 
    //    drawL1Label(0.17,0.35);
    drawLumiLabel(0.17,.3);
    drawEtaLabel("1.64","2.14",0.17,.37);
    
    pad2->cd();
    pad2->SetLogx(1);
    pad2->SetLogy(1);
    pad2->SetGridx(1);
    pad2->SetGridy(1);
    pad2->SetFillColor(kWhite);
    pad2->SetFrameBorderMode(0);
    pad2->SetLeftMargin(0.126);
    pad2->SetRightMargin(0.04);
    pad2->SetTopMargin(0.06);
    pad2->SetBottomMargin(0.4);
    
    hh_ratio = setHistoRatio(result_gem_2s1b__pat2, result_def_2s1b__pat2, "", 0.01,1.1,col2);

    hh_ratio->GetXaxis()->SetTitle("L1 muon candidate p_{T}^{cut} [GeV/c]");
    hh_ratio->Draw("P");

    hh_ratio_gmt = setHistoRatio(result_gem_2s1b__pat2, result_gmtsing__pat2, "", 0.01,1.1,col0);
    hh_ratio_gmt->Draw("P same");

    leg = new TLegend(0.15,0.45,.45,0.7,NULL,"brNDC");
    leg->SetMargin(0.1);
    leg->SetBorderSize(0);
    leg->SetTextSize(0.1);
    leg->SetFillStyle(1001);
    leg->SetFillColor(kWhite);
    leg->AddEntry(hh_ratio_gmt, "GEM+CSC/GMT","p");
    leg->AddEntry(hh_ratio,     "GEM+CSC/CSC tight","p");
    leg->Draw("same");

    c->SaveAs(plots + "rates_vs_pt__PU100__def_2s_2s1b_2s1bgem__loose" + ext);
  }
  {
    // GMT; CSCTF 2 stubs; CSCTF 2 stubs + ME1/b; CSCTF 2 stubs + ME1/b + GEM -- TIGHT + GEM -- Absolute
    pad1->cd();
    pad1->SetLogx(1);
    pad1->SetLogy(1);
    pad1->SetGridx(1);
    pad1->SetGridy(1);
    pad1->SetFrameBorderMode(0);
    pad1->SetFillColor(kWhite);

    result_gmtsing__pat8->Draw("e3");
    result_def_2s__pat8->Draw("same e3");
    result_def_2s1b__pat8->Draw("same e3");
    result_gem_2s1b__pat8->Draw("same e3");
    result_gmtsing__pat8->Draw("same e3");
    result_gmtsing__pat8->GetYaxis()->SetRangeUser(0.1, 10000.);
    result_gmtsing__pat8->GetXaxis()->SetTitle("");
 
    TLegend *leg0 = new TLegend(0.15,0.88,.9,0.93,NULL,"brNDC");
    leg0->SetBorderSize(0);
    leg0->SetFillStyle(0);
    leg0->SetTextSize(0.04);
    leg0->SetFillStyle(1001);
    leg0->SetFillColor(kWhite);
    leg0->AddEntry(result_gmtsing__pat8,"Single muon trigger in 2012 configuration [GMT]","f");
    leg0->Draw();
 
    TLegend *leg = new TLegend(0.45,0.68,.93,0.86,"L1 Selections (#geq 2 stations):","brNDC");
    leg->SetMargin(0.25);
    leg->SetBorderSize(0);
    leg->SetFillStyle(0);
    leg->SetTextSize(0.04);
    leg->SetFillStyle(1001);
    leg->SetFillColor(kWhite);
    leg->AddEntry(result_def_2s__pat8,  "CSC, loose","f");
    leg->AddEntry(result_def_2s1b__pat8,"CSC, tight","f");
    leg->AddEntry(result_gem_2s1b__pat8,"GEM+CSC Integrated Trigger","f");
    leg->Draw();

    // drawL1Label(0.17,0.35);
    drawLumiLabel(0.17,.3);
    drawEtaLabel("1.64","2.14",0.17,.37);

    pad2->cd();
    pad2->SetLogx(1);
    pad2->SetLogy(1);
    pad2->SetGridx(1);
    pad2->SetGridy(1);
    pad2->SetFillColor(kWhite);
    pad2->SetFrameBorderMode(0);
    pad2->SetLeftMargin(0.126);
    pad2->SetRightMargin(0.04);
    pad2->SetTopMargin(0.06);
    pad2->SetBottomMargin(0.4);
    
    hh_ratio = setHistoRatio(result_gem_2s1b__pat8, result_def_2s1b__pat8, "", 0.01,1.1,col2);
    hh_ratio->GetXaxis()->SetTitle("p_{T}^{cut} [GeV/c]");
    hh_ratio->Draw("P");
    hh_ratio_gmt = setHistoRatio(result_gem_2s1b__pat8, result_gmtsing__pat8, "", 0.01,1.1,col0);
    hh_ratio_gmt->Draw("P same");

    leg = new TLegend(0.15,0.45,.5,0.7,NULL,"brNDC");
    leg->SetMargin(0.1);
    leg->SetBorderSize(0);
    leg->SetFillStyle(0);
    leg->SetTextSize(0.1);
    leg->SetFillStyle(1001);
    leg->SetFillColor(kWhite);
    leg->AddEntry(hh_ratio_gmt, "GEM+CSC/GMT","p");
    leg->AddEntry(hh_ratio,     "GEM+CSC/CSC tight","p");
    leg->Draw("same");

    c->SaveAs(plots + "rates_vs_pt__PU100__def_2s_2s1b_2s1bgem__tight" + ext);
  }
  {
    // GMT; CSCTF 3 stubs; CSCTF 3 stubs + ME1/b; CSCTF 3 stubs + ME1/b + GEM -- LOOSE -- Absolute
    pad1->cd();
    pad1->SetLogx(1);
    pad1->SetLogy(1);
    pad1->SetGridx(1);
    pad1->SetGridy(1);
    pad1->SetFrameBorderMode(0);
    pad1->SetFillColor(kWhite);

    result_gmtsing__pat2->Draw("e3");
    result_def_3s__pat2->Draw("same e3");
    result_def_3s1b__pat2->Draw("same e3");
    result_gem_3s1b__pat2->Draw("same e3");
    result_gmtsing__pat2->Draw("same e3");
    result_gmtsing__pat2->GetYaxis()->SetRangeUser(0.01, 10000.);
    result_gmtsing__pat2->GetXaxis()->SetTitle("");
 
    TLegend *leg0 = new TLegend(0.15,0.88,.9,0.93,NULL,"brNDC");
    leg0->SetBorderSize(0);
    leg0->SetFillStyle(0);
    leg0->SetTextSize(0.04);
    leg0->SetFillStyle(1001);
    leg0->SetFillColor(kWhite);
    leg0->AddEntry(result_gmtsing__pat2,"Single muon trigger in 2012 configuration [GMT]","f");
    leg0->Draw();
 
    TLegend *leg = new TLegend(0.45,0.68,.93,0.86,"L1 Selections (#geq 3 stations):","brNDC");
    leg->SetMargin(0.25);
    leg->SetBorderSize(0);
    leg->SetFillStyle(0);
    leg->SetTextSize(0.04);
    leg->SetFillStyle(1001);
    leg->SetFillColor(kWhite);
    leg->AddEntry(result_def_3s__pat2,  "CSC, loose","f");
    leg->AddEntry(result_def_3s1b__pat2,"CSC, tight","f");
    leg->AddEntry(result_gem_3s1b__pat2,"GEM+CSC Integrated Trigger","f");
    leg->Draw();

    // drawL1Label(0.17,0.35);
    drawLumiLabel(0.17,.3);
    drawEtaLabel("1.64","2.14",0.17,.37);

    pad2->cd();
    pad2->SetLogx(1);
    pad2->SetLogy(1);
    pad2->SetGridx(1);
    pad2->SetGridy(1);
    pad2->SetFillColor(kWhite);
    pad2->SetFrameBorderMode(0);
    pad2->SetLeftMargin(0.126);
    pad2->SetRightMargin(0.04);
    pad2->SetTopMargin(0.06);
    pad2->SetBottomMargin(0.4);
    
    hh_ratio = setHistoRatio(result_gem_3s1b__pat2, result_def_3s1b__pat2, "", 0.01,1.1,col2);
    hh_ratio->GetXaxis()->SetTitle("p_{T}^{cut} [GeV/c]");
    hh_ratio->Draw("P");
    hh_ratio_gmt = setHistoRatio(result_gem_3s1b__pat2, result_gmtsing__pat2, "", 0.01,1.1,col0);
    hh_ratio_gmt->Draw("P same");

    leg = new TLegend(0.15,0.45,.5,0.7,NULL,"brNDC");
    leg->SetMargin(0.1);
    leg->SetBorderSize(0);
    leg->SetFillStyle(0);
    leg->SetTextSize(0.1);
    leg->SetFillStyle(1001);
    leg->SetFillColor(kWhite);
    leg->AddEntry(hh_ratio_gmt, "GEM+CSC/GMT","p");
    leg->AddEntry(hh_ratio,     "GEM+CSC/CSC tight","p");
    leg->Draw("same");

    c->SaveAs(plots + "rates_vs_pt__PU100__def_3s_3s1b_3s1bgem__loose" + ext);
  }
  {
    // GMT; CSCTF 3 stubs; CSCTF 3 stubs + ME1/b; CSCTF 3 stubs + ME1/b + GEM -- TIGHT + GEM -- Absolute
    pad1->cd();
    pad1->SetLogx(1);
    pad1->SetLogy(1);
    pad1->SetGridx(1);
    pad1->SetGridy(1);
    pad1->SetFrameBorderMode(0);
    pad1->SetFillColor(kWhite);

    result_gmtsing__pat8->Draw("e3");
    result_def_3s__pat8->Draw("same e3");
    result_def_3s1b__pat8->Draw("same e3");
    result_gem_3s1b__pat8->Draw("same e3");
    result_gmtsing__pat8->Draw("same e3");
    result_gmtsing__pat8->GetYaxis()->SetRangeUser(0.01, 10000.);
    result_gmtsing__pat8->GetXaxis()->SetTitle("");

    TLegend *leg0 = new TLegend(0.15,0.88,.9,0.93,NULL,"brNDC");
    leg0->SetBorderSize(0);
    leg0->SetFillStyle(0);
    leg0->SetTextSize(0.04);
    leg0->SetFillStyle(1001);
    leg0->SetFillColor(kWhite);
    leg0->AddEntry(result_gmtsing__pat8,"Single muon trigger in 2012 configuration [GMT]","f");
    leg0->Draw();
 
    TLegend *leg = new TLegend(0.45,0.68,.93,0.86,"L1 Selections (#geq 3 stations):","brNDC");
    leg->SetMargin(0.25);
    leg->SetBorderSize(0);
    leg->SetFillStyle(0);
    leg->SetTextSize(0.04);
    leg->SetFillStyle(1001);
    leg->SetFillColor(kWhite);
    leg->AddEntry(result_def_3s__pat8,  "CSC, loose","f");
    leg->AddEntry(result_def_3s1b__pat8,"CSC, tight","f");
    leg->AddEntry(result_gem_3s1b__pat8,"GEM+CSC Integrated Trigger","f");
    leg->Draw();

    // drawL1Label(0.17,0.35);
    drawLumiLabel(0.17,.3);
    drawEtaLabel("1.64","2.14",0.17,.37);

    pad2->cd();
    pad2->SetLogx(1);
    pad2->SetLogy(1);
    pad2->SetGridx(1);
    pad2->SetGridy(1);
    pad2->SetFillColor(kWhite);
    pad2->SetFrameBorderMode(0);
    pad2->SetLeftMargin(0.126);
    pad2->SetRightMargin(0.04);
    pad2->SetTopMargin(0.06);
    pad2->SetBottomMargin(0.4);
    
    hh_ratio = setHistoRatio(result_gem_3s1b__pat8, result_def_3s1b__pat8, "", 0.01,1.1,col2);
    hh_ratio->GetXaxis()->SetTitle("p_{T}^{cut} [GeV/c]");
    hh_ratio->Draw("P");
    hh_ratio_gmt = setHistoRatio(result_gem_3s1b__pat8, result_gmtsing__pat8, "", 0.01,1.1,col0);
    hh_ratio_gmt->Draw("P same");

    leg = new TLegend(0.15,0.45,.5,0.7,NULL,"brNDC");
    leg->SetMargin(0.1);
    leg->SetBorderSize(0);
    leg->SetFillStyle(0);
    leg->SetTextSize(0.1);
    leg->SetFillStyle(1001);
    leg->SetFillColor(kWhite);
    leg->AddEntry(hh_ratio_gmt, "GEM+CSC/GMT","p");
    leg->AddEntry(hh_ratio,     "GEM+CSC/CSC tight","p");
    leg->Draw("same");

    c->SaveAs(plots + "rates_vs_pt__PU100__def_3s_3s1b_3s1bgem__tight" + ext);
  }

  // EXTRA PLOTS
  {
    result_def_2s__pat8->SetFillColor(kViolet+2);
    result_def_2s1b__pat8->SetFillColor(kAzure+2);
    result_gem_2s1b__pat8->SetFillColor(kGreen-1);

    // GMT; CSCTF 2 stubs; CSCTF 2 stubs + ME1/b; CSCTF 2 stubs + ME1/b + GEM -- LOOSE & TIGHT + GEM-- Absolute + ratio
    TCanvas* c = new TCanvas("c","c",1000,800);
    c->Clear();
    TPad *pad1 = new TPad("pad1","top pad",0.0,0.0,1.0,1.0);
    pad1->Draw();

    pad1->cd();
    pad1->SetLogx(1);
    pad1->SetLogy(1);
    pad1->SetGridx(1);
    pad1->SetGridy(1);
    pad1->SetFrameBorderMode(0);
    pad1->SetFillColor(kWhite);

    result_gmtsing__pat2->Draw("e3");
    result_def_2s__pat2->Draw("same e3");
    result_def_2s1b__pat2->Draw("same e3");
    result_gem_2s1b__pat2->Draw("same e3");
    result_def_2s__pat8->Draw("same e3");
    result_def_2s1b__pat8->Draw("same e3");
    result_gem_2s1b__pat8->Draw("same e3");
    result_gmtsing__pat2->Draw("same e3");
    result_gmtsing__pat2->GetYaxis()->SetRangeUser(0.1, 10000.);
    result_gmtsing__pat2->GetXaxis()->SetTitle("p_{T}^{cut} [GeV/c]");
 
    TLegend *leg = new TLegend(0.5,0.65,.92,0.92,NULL,"brNDC");
    leg->SetBorderSize(0);
    leg->SetFillStyle(0);
    leg->SetTextSize(0.03);
    leg->AddEntry((TObject*)0, "Global Muon Trigger [GMT]:","");
    leg->AddEntry(result_gmtsing__pat2, "default muon selection","f");
    leg->AddEntry((TObject*)0,          "CSCTF tracks with:","");
    leg->AddEntry(result_def_2s__pat2,  "#geq 2 stubs","f");
    leg->AddEntry(result_def_2s1b__pat2,"#geq 2 with ME1/b stub","f");
    leg->AddEntry(result_gem_2s1b__pat2,"#geq 2 with ME1/b stub and GEM pad","f");
    leg->AddEntry(result_def_2s__pat8,  "#geq 2 stubs","f");
    leg->AddEntry(result_def_2s1b__pat8,"#geq 2 with ME1/b stub","f");
    leg->AddEntry(result_gem_2s1b__pat8,"#geq 2 with ME1/b stub and GEM pad","f");
    leg->SetFillStyle(1001);
    leg->SetFillColor(kWhite);
    leg->Draw();
 
    drawLumiLabel(0.17,.3);
    drawEtaLabel("1.64","2.14");

    c->SaveAs(plots + "rates_vs_pt__PU100__def_2s_2s1b_2s1bgem" + ext);
  }

  {
    result_def_3s__pat8->SetFillColor(kViolet+2);
    result_def_3s1b__pat8->SetFillColor(kAzure+2);
    result_gem_3s1b__pat8->SetFillColor(kGreen-1);

    // GMT; CSCTF 3 stubs; CSCTF 3 stubs + ME1/b; CSCTF 3 stubs + ME1/b + GEM -- LOOSE & TIGHT + GEM-- Absolute + ratio
    TCanvas* c = new TCanvas("c","c",1000,800);
    c->Clear();
    TPad *pad1 = new TPad("pad1","top pad",0.0,0.0,1.0,1.0);
    pad1->Draw();

    pad1->cd();
    pad1->SetLogx(1);
    pad1->SetLogy(1);
    pad1->SetGridx(1);
    pad1->SetGridy(1);
    pad1->SetFrameBorderMode(0);
    pad1->SetFillColor(kWhite);

    result_gmtsing__pat2->Draw("e3");
    result_def_3s__pat2->Draw("same e3");
    result_def_3s1b__pat2->Draw("same e3");
    result_gem_3s1b__pat2->Draw("same e3");
    result_def_3s__pat8->Draw("same e3");
    result_def_3s1b__pat8->Draw("same e3");
    result_gem_3s1b__pat8->Draw("same e3");
    result_gmtsing__pat2->Draw("same e3");
    result_gmtsing__pat2->GetYaxis()->SetRangeUser(0.01, 10000.);
    result_gmtsing__pat2->GetXaxis()->SetTitle("p_{T}^{cut} [GeV/c]");
 
    TLegend *leg = new TLegend(0.5,0.65,.92,0.92,NULL,"brNDC");
    leg->SetBorderSize(0);
    leg->SetFillStyle(0);
    leg->SetTextSize(0.03);
    leg->AddEntry((TObject*)0, "Global Muon Trigger [GMT]:","");
    leg->AddEntry(result_gmtsing__pat2, "default muon selection","f");
    leg->AddEntry((TObject*)0,          "CSCTF tracks with:","");
    leg->AddEntry(result_def_3s__pat2,  "#geq 3 stubs","f");
    leg->AddEntry(result_def_3s1b__pat2,"#geq 3 with ME1/b stub","f");
    leg->AddEntry(result_gem_3s1b__pat2,"#geq 3 with ME1/b stub and GEM pad","f");
    leg->AddEntry(result_def_3s__pat8,  "#geq 3 stubs","f");
    leg->AddEntry(result_def_3s1b__pat8,"#geq 3 with ME1/b stub","f");
    leg->AddEntry(result_gem_3s1b__pat8,"#geq 3 with ME1/b stub and GEM pad","f");
    leg->SetFillStyle(1001);
    leg->SetFillColor(kWhite);
    leg->Draw();
 
    drawLumiLabel(0.17,.3);
    drawEtaLabel("1.64","2.14");

    c->SaveAs(plots + "rates_vs_pt__PU100__def_3s_3s1b_3s1bgem" + ext);
  }
}
void dNdEta_ThreeMethods_FullTrackingRebinned_DividedByMidRapidValue() {
//=========Macro generated from canvas: MyCanvas/MyCanvas
//=========  (Thu Dec 10 11:52:00 2009) by ROOT version5.22/00d

   gROOT->Reset();
   gROOT->ProcessLine(".x rootlogon.C");

   gStyle->SetTitleYOffset(1.4);


   TCanvas *MyCanvas = new TCanvas("MyCanvas", "Final result",1,360,550,600); 
   TH1 *corr_result_all = new TH1D("corr_result_all","",14,-3.5,3.5);
   corr_result_all->GetXaxis()->SetRange(2,13);

   // ========================= Cluster Counting =======================

   corr_result_all->SetBinContent(4,4.043821);  // -2.0 to -1.5
   corr_result_all->SetBinContent(5,3.821537);  // -1.5 to -1.0 
   corr_result_all->SetBinContent(6,3.611029); // -1.0 to -0.5
   corr_result_all->SetBinContent(7,3.501129); // -0.5 to 0.0
   corr_result_all->SetBinContent(8,3.51732);      
   corr_result_all->SetBinContent(9,3.632249);      
   corr_result_all->SetBinContent(10,3.747706);    
   corr_result_all->SetBinContent(11,4.01596);  

   corr_result_all->SetBinError(4,0.177928124);
   corr_result_all->SetBinError(5,0.168147628);
   corr_result_all->SetBinError(6,0.158885276);
   corr_result_all->SetBinError(7,0.154049676);
   corr_result_all->SetBinError(8,0.15476208);
   corr_result_all->SetBinError(9,0.159818956);
   corr_result_all->SetBinError(10,0.164899064);
   corr_result_all->SetBinError(11,0.17670224);

   /*
   corr_result_all->SetBinContent(4,3.954);  // -2.0 to -1.5    
   corr_result_all->SetBinContent(5,3.770);  // -1.5 to -1.0
   corr_result_all->SetBinContent(6,3.607); // -1.0 to -0.5
   corr_result_all->SetBinContent(7,3.548); // -0.5 to 0.0

   corr_result_all->SetBinContent(8,3.567); 
   corr_result_all->SetBinContent(9,3.681); 
   corr_result_all->SetBinContent(10,3.791); 
   corr_result_all->SetBinContent(11,4.025); 

   corr_result_all->SetBinError(4,0.1779);
   corr_result_all->SetBinError(5,0.1697);
   corr_result_all->SetBinError(6,0.1623);
   corr_result_all->SetBinError(7,0.1597);
   corr_result_all->SetBinError(8,0.1605);
   corr_result_all->SetBinError(9,0.1657);
   corr_result_all->SetBinError(10,0.1706);
   corr_result_all->SetBinError(11,0.1811);
   */

   corr_result_all->SetMarkerStyle(20);  
   //corr_result_all->SetMarkerSize(1.5); // use rootlogon size 
   corr_result_all->SetMarkerColor(kRed);
   corr_result_all->SetLineColor(2);

   corr_result_all->GetYaxis()->SetTitle("dN_{ch}/d#eta/dN_{ch,mid}/d#eta");
   corr_result_all->GetXaxis()->SetTitle("#eta"); 
   corr_result_all->GetXaxis()->CenterTitle();
   corr_result_all->GetYaxis()->CenterTitle();
   corr_result_all->GetXaxis()->SetNdivisions(405);
   //corr_result_all->GetYaxis()->SetNdivisions(1005);
   corr_result_all->GetYaxis()->SetNdivisions(506);

   Float_t midrapid = 0.5*(corr_result_all->GetBinContent(7)+corr_result_all->GetBinContent(8));
   cout<<"mid rapid value = "<<midrapid<<endl;

   corr_result_all->Scale(1/midrapid);

   corr_result_all->SetMinimum(0.95);
   corr_result_all->SetMaximum(1.3);

   corr_result_all->Draw("pz");

   // ======= YJ Tracklet three layer combination averaged (updated with dead modules..) ======
   //                        1     2   3     4   5     6  7    8  9   10 11   12
   Double_t xAxis5[13] = {-3, -2.5, -2, -1.5, -1, -0.5, 0, 0.5, 1, 1.5, 2, 2.5, 3}; 
   
   TH1 *hMeasuredFinal = new TH1D("hMeasuredFinal","",12, xAxis5);

   hMeasuredFinal->SetBinContent(3,3.7459);
   hMeasuredFinal->SetBinContent(4,3.65462);
   hMeasuredFinal->SetBinContent(5,3.55475);
   hMeasuredFinal->SetBinContent(6,3.45008);

   hMeasuredFinal->SetBinContent(7,3.44329);
   hMeasuredFinal->SetBinContent(8,3.5244);
   hMeasuredFinal->SetBinContent(9,3.59575);
   hMeasuredFinal->SetBinContent(10,3.6612);

   hMeasuredFinal->SetBinError(3,0.142344);
   hMeasuredFinal->SetBinError(4,0.138876);
   hMeasuredFinal->SetBinError(5,0.13508);
   hMeasuredFinal->SetBinError(6,0.131103);
   hMeasuredFinal->SetBinError(7,0.130845);
   hMeasuredFinal->SetBinError(8,0.133927);
   hMeasuredFinal->SetBinError(9,0.136638);
   hMeasuredFinal->SetBinError(10,0.139126);

   hMeasuredFinal->SetMarkerColor(kBlue);   
   hMeasuredFinal->SetLineColor(4);
   hMeasuredFinal->SetMarkerStyle(21); 
   //hMeasuredFinal->SetMarkerSize(1.5); // use rootlogon size 

   midrapid = 0.5*(hMeasuredFinal->GetBinContent(6)+hMeasuredFinal->GetBinContent(7));
   cout<<"mid rapid value = "<<midrapid<<endl;

   hMeasuredFinal->Scale(1/midrapid);
   hMeasuredFinal->Draw("pzsame");

   /// ==================================================== Ferenc's dN/dEta   (rebinned)
   Double_t xAxis6[13] = {-3, -2.5, -2, -1.5, -1, -0.5, 0, 0.5, 1, 1.5, 2, 2.5, 3}; 
   TH1 *hMeasuredFinal2 = new TH1D("hMeasuredFinal2","",12, xAxis6);

   // Hight Stat
   hMeasuredFinal2->SetBinContent(2,3.65413);
   hMeasuredFinal2->SetBinContent(3,3.68883);
   hMeasuredFinal2->SetBinContent(4,3.73805);
   hMeasuredFinal2->SetBinContent(5,3.62817);
   hMeasuredFinal2->SetBinContent(6,3.52704);

   hMeasuredFinal2->SetBinContent(7,3.47443);
   hMeasuredFinal2->SetBinContent(8,3.63319);
   hMeasuredFinal2->SetBinContent(9,3.7577);
   hMeasuredFinal2->SetBinContent(10,3.67975);
   hMeasuredFinal2->SetBinContent(11,3.65413);

   // Systematic error of 3.1%  --> to 2.4%
   hMeasuredFinal2->SetBinError(2,0.08769912);
   hMeasuredFinal2->SetBinError(3,0.08853192);
   hMeasuredFinal2->SetBinError(4,0.0897132);
   hMeasuredFinal2->SetBinError(5,0.08707608);
   hMeasuredFinal2->SetBinError(6,0.08464896);
   hMeasuredFinal2->SetBinError(7,0.08338632);
   hMeasuredFinal2->SetBinError(8,0.08719656);
   hMeasuredFinal2->SetBinError(9,0.0901848);
   hMeasuredFinal2->SetBinError(10,0.088314);
   hMeasuredFinal2->SetBinError(11,0.08769912);

   /*
   // Systematic error of 3.1%  --> to 2.3%
   hMeasuredFinal2->SetBinError(2,0.084045);
   hMeasuredFinal2->SetBinError(3,0.0848431);
   hMeasuredFinal2->SetBinError(4,0.0859752);
   hMeasuredFinal2->SetBinError(5,0.0834479);
   hMeasuredFinal2->SetBinError(6,0.0811219);
   hMeasuredFinal2->SetBinError(7,0.0799119);
   hMeasuredFinal2->SetBinError(8,0.0835634);
   hMeasuredFinal2->SetBinError(9,0.0864271);
   hMeasuredFinal2->SetBinError(10,0.0846342);
   hMeasuredFinal2->SetBinError(11,0.084045);
   */

   hMeasuredFinal2->SetMarkerColor(kBlack);
   hMeasuredFinal2->SetLineColor(1);
   hMeasuredFinal2->SetMarkerStyle(22);
   //hMeasuredFinal2->SetMarkerSize(1.5); use root logon size

   midrapid = 0.5*(hMeasuredFinal2->GetBinContent(6)+hMeasuredFinal2->GetBinContent(7));
   cout<<"mid rapid value = "<<midrapid<<endl;


   hMeasuredFinal2->Scale(1/midrapid);
   hMeasuredFinal2->Draw("pzsame");
   
   // ================== 2.36 TeV
   // ========================= Cluster Counting ======================= 
   TH1 *corr_result_all236 = new TH1D("corr_result_all236","",14,-3.5,3.5);
   corr_result_all236->GetXaxis()->SetRange(2,13);

   corr_result_all236->SetBinContent(4,5.203552);
   corr_result_all236->SetBinContent(5,4.913457);
   corr_result_all236->SetBinContent(6,4.710017);
   corr_result_all236->SetBinContent(7,4.44485);
   corr_result_all236->SetBinContent(8,4.448675);
   corr_result_all236->SetBinContent(9,4.659581);
   corr_result_all236->SetBinContent(10,4.856712);
   corr_result_all236->SetBinContent(11,5.065867);

   corr_result_all236->SetBinError(4,0.23416);
   corr_result_all236->SetBinError(5,0.221106);
   corr_result_all236->SetBinError(6,0.211951);
   corr_result_all236->SetBinError(7,0.200018);
   corr_result_all236->SetBinError(8,0.20019);
   corr_result_all236->SetBinError(9,0.209681);
   corr_result_all236->SetBinError(10,0.218552);
   corr_result_all236->SetBinError(11,0.227964);

   corr_result_all236->SetMarkerColor(kRed);
   corr_result_all236->SetLineColor(2);
   corr_result_all236->SetMarkerStyle(24);

   midrapid = 0.5*(corr_result_all236->GetBinContent(7)+corr_result_all236->GetBinContent(8));
   cout<<"mid rapid value = "<<midrapid<<endl;

   corr_result_all236->Scale(1./midrapid);
   corr_result_all236->Draw("pzsame");



   /// ==================================================== Yenjie 2.36 TeV
   //                        1     2   3     4   5     6  7    8  9   10 11   12
   TH1 *hTracklet236 = new TH1D("hTracklet236","",12, xAxis5);

   hTracklet236->SetBinContent(3,4.73663);
   hTracklet236->SetBinContent(4,4.69978);
   hTracklet236->SetBinContent(5,4.61061);
   hTracklet236->SetBinContent(6,4.40814);

   hTracklet236->SetBinContent(7,4.38437);
   hTracklet236->SetBinContent(8,4.51905);
   hTracklet236->SetBinContent(9,4.6502);
   hTracklet236->SetBinContent(10,4.80977);
   
   // 4.8 % Systematic Error 
   hTracklet236->SetBinError(3,0.179992);
   hTracklet236->SetBinError(4,0.178592);
   hTracklet236->SetBinError(5,0.175203);
   hTracklet236->SetBinError(6,0.167509);
   hTracklet236->SetBinError(7,0.166606);
   hTracklet236->SetBinError(8,0.171724);
   hTracklet236->SetBinError(9,0.176707);
   hTracklet236->SetBinError(10,0.182771);

   hTracklet236->SetMarkerColor(4);   
   hTracklet236->SetLineColor(4);
   hTracklet236->SetMarkerStyle(kOpenSquare); 
   //hTracklet236->SetMarkerSize(1.5); // use rootlogon size

   midrapid = 0.5*(hTracklet236->GetBinContent(6)+hTracklet236->GetBinContent(7));
   cout<<"mid rapid value = "<<midrapid<<endl;

   hTracklet236->Scale(1./midrapid);
   hTracklet236->Draw("pzsame");

   /// ==================================================== Ferenc's dN/dEta   (rebinned) 
   Double_t xAxis7[13] = {-3, -2.5, -2, -1.5, -1, -0.5, 0, 0.5, 1, 1.5, 2, 2.5, 3};
   TH1 *hMeasuredFinal2236 = new TH1D("hMeasuredFinal2","",12, xAxis7);

   hMeasuredFinal2236->SetBinContent(2,4.9689);
   hMeasuredFinal2236->SetBinContent(3,4.93581);
   hMeasuredFinal2236->SetBinContent(4,4.67197);
   hMeasuredFinal2236->SetBinContent(5,4.70044);
   hMeasuredFinal2236->SetBinContent(6,4.52142);

   hMeasuredFinal2236->SetBinContent(7,4.55674);
   hMeasuredFinal2236->SetBinContent(8,4.61255);
   hMeasuredFinal2236->SetBinContent(9,4.67611);
   hMeasuredFinal2236->SetBinContent(10,4.87402);
   hMeasuredFinal2236->SetBinContent(11,4.96891);


   // Systematic error of 3.1% --> 2.3%
   hMeasuredFinal2236->SetBinError(2,0.114285);
   hMeasuredFinal2236->SetBinError(3,0.113524);
   hMeasuredFinal2236->SetBinError(4,0.107455);
   hMeasuredFinal2236->SetBinError(5,0.10811);
   hMeasuredFinal2236->SetBinError(6,0.103993);
   hMeasuredFinal2236->SetBinError(7,0.104805);
   hMeasuredFinal2236->SetBinError(8,0.106089);
   hMeasuredFinal2236->SetBinError(9,0.107551);
   hMeasuredFinal2236->SetBinError(10,0.112102);
   hMeasuredFinal2236->SetBinError(11,0.114285);


   hMeasuredFinal2236->SetMarkerColor(kBlack);
   hMeasuredFinal2236->SetLineColor(1);
   hMeasuredFinal2236->SetMarkerStyle(26);
   //hMeasuredFinal2->SetMarkerSize(1.5); use root logon size                                                              

   midrapid = 0.5*(hMeasuredFinal2236->GetBinContent(6)+hMeasuredFinal2236->GetBinContent(7));
   cout<<"mid rapid value = "<<midrapid<<endl;

   hMeasuredFinal2236->Scale(1./midrapid);

   //hMeasuredFinal2236->Scale(1/4.53908);
   hMeasuredFinal2236->Draw("pzsame");
   


   /// ====================================================  UA5 Data

   TH1F* hEta_UA5_NSD = new TH1F("hEta_UA5_NSD",";#eta;dN/d#eta",50,-3,3);

   // positive eta
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(0.125),3.48);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(0.375),3.38);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(0.625),3.52);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(0.875),3.68);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(1.125),3.71);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(1.375),3.86);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(1.625),3.76);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(1.875),3.66);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(2.125),3.72);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(2.375),3.69);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(2.625),3.56);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(2.875),3.41);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(3.125),3.15);

   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(0.125),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(0.375),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(0.625),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(0.875),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(1.125),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(1.375),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(1.625),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(1.875),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(2.125),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(2.375),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(2.625),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(2.875),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(3.125),0.07);


   //negative eta
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(-0.125),3.48);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(-0.375),3.38);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(-0.625),3.52);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(-0.875),3.68);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(-1.125),3.71);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(-1.375),3.86);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(-1.625),3.76);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(-1.875),3.66);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(-2.125),3.72);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(-2.375),3.69);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(-2.625),3.56);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(-2.875),3.41);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(-3.125),3.15);

   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(-0.125),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(-0.375),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(-0.625),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(-0.875),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(-1.125),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(-1.375),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(-1.625),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(-1.875),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(-2.125),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(-2.375),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(-2.625),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(-2.875),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(-3.125),0.07);

   hEta_UA5_NSD->SetMarkerStyle(25);
   hEta_UA5_NSD->SetMarkerSize(1.0);
   //hEta_UA5_NSD->Draw("psame");

   //TLegend *leg = new TLegend(0.20,0.27,0.53,0.47,NULL,"brNDC");
   //TLegend *leg = new TLegend(0.20,0.35,0.53,0.47,NULL,"brNDC"); 
   Float_t ywidth = 0.045*4;

   //TLegend *leg = new TLegend(0.27,0.26,0.70,0.26+ywidth,NULL,"brNDC");
   //TLegend *leg = new TLegend(0.39,0.21,0.82,0.21+ywidth,NULL,"brNDC");
   TLegend *leg = new TLegend(0.45,0.753,0.892,0.93,NULL,"brNDC");


   //leg->SetNColumns(2);
   leg->SetBorderSize(0);
   leg->SetMargin(0.5);
   leg->SetTextFont(62);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(0);
   leg->SetTextSize(0.03); 
   leg->SetHeader("      2.36 TeV");
   leg->AddEntry(corr_result_all236,"Hit counting","P");
   leg->AddEntry(hTracklet236,"Tracklet","P");
   leg->AddEntry(hMeasuredFinal2236,"Global tracking","P");


   //cout<<"Number of column "<<leg->GetNColumns()<<endl;
   /*
   leg->AddEntry(corr_result_all236,"","P");
   leg->AddEntry(hTracklet236,"","P"); 
   leg->AddEntry(hMeasuredFinal2236,"","P");
   */

   //TLegend *leg2 = new TLegend(0.20,0.22,0.53,0.35,NULL,"brNDC");
   //TLegend *leg2 = new TLegend(0.50,0.26,0.93,0.47,NULL,"brNDC");
   //TLegend *leg2 = new TLegend(0.39,0.26,0.82,0.26+ywidth,NULL,"brNDC");
   //TLegend *leg2 = new TLegend(0.27,0.21,0.70,0.21+ywidth,NULL,"brNDC"); 
   TLegend *leg2 = new TLegend(0.35,0.75,0.782,0.932,NULL,"brNDC"); 
   leg2->SetMargin(0.37);
   leg2->SetBorderSize(0);
   leg2->SetTextFont(62);
   leg2->SetLineColor(1);
   leg2->SetLineStyle(1);
   leg2->SetLineWidth(1);
   leg2->SetFillColor(0);
   //leg2->SetFillStyle(1001);
   leg2->SetFillStyle(0); 
   leg2->SetTextSize(0.03);
   leg2->SetHeader("   0.9 TeV");
   leg2->AddEntry(corr_result_all,"","P");
   leg2->AddEntry(hMeasuredFinal,"","P"); 
   leg2->AddEntry(hMeasuredFinal2,"","P");

   leg->Draw();
   leg2->Draw();

   printFinalCanvases(MyCanvas,"dNdeta_ThreeMethods_Divided",0,2);
}
//_________________________________________________________________________________
void multipleSplinesWithHistogramsVb(int iEventLook = 163, int nEvents = 1000, int nPoints = 9, double seed = 231) 
{
	double lowerBound = 10; //bounds for random vector function
	double upperBound = 20;
	double lowerErrorBound = 1;
	double upperErrorBound = 2;

	//Load the data
	vector< vector<double> > xEvents, yEvents, yErrorEvents; //each of these is a vector of vectors (of randomized data points)
	for(int i = 0; i < nEvents; i++) 
	{
		vector <double> xData, yData, yErrorData; //temporary vectors that are only used to get random values from FillRand function
		FillRandVectors(nPoints, xData, yData, yErrorData, seed*(i+1), lowerBound, upperBound, lowerErrorBound, upperErrorBound); //populates random vectors for y values and y error vector
		xEvents.push_back(xData);
		yEvents.push_back(yData);
		yErrorEvents.push_back(yErrorData);
	}

	//Intialization of the variables
	const int npar = nPoints;
	const int orderSpline = 4;
	const int nbreak = npar+2-orderSpline;
	double stepSpline = 0.01;
	double xminBSplineWorkspace = 0;
	double xmaxBSplineWorkspace = 9;
	double startCSplineWorkspace = 15.;
	double stepCSplineWorkspace = 1.5;

	acc_GLOB = gsl_interp_accel_alloc ();
	spline_GLOB = gsl_spline_alloc (gsl_interp_cspline, nPoints);	
	bw_GLOB = gsl_bspline_alloc(orderSpline, nbreak);
	
	//B- and C-splines
	clock_t tbstart, tbstop, tcstart, tcstop;
	vector <double> timeb, timec;

	vector< vector<double> > xBSplineValues, yBSplineValues;
	vector< vector<double> > xCSplineValues, yCSplineValues; 

//Setup for the C-spline_________________________________________________________________________
	TMinuit *myMinuit = new TMinuit(npar);  //initialize TMinuit with a maximum of npar 
	myMinuit->SetFCN(fcn);
	myMinuit->SetPrintLevel(-1);//No output: -1, output:1

	double arglist[10];
	int ierflg = 0;
	arglist[0] = 1;
	myMinuit->mnexcm("SET ERR", arglist, 1, ierflg);

	//Initialize Minuit
	vector<double> vstart, vstep;
	for(int i=0; i<npar; i++) 	//set starting values and step sizes for parameters
	{
		vstart.push_back(startCSplineWorkspace);
		vstep.push_back(stepCSplineWorkspace);
	}

	for (int i = 0; i < npar; i++) {
		stringstream ss;
		ss<<"a"<<i;
		myMinuit->mnparm(i, ss.str().c_str(), vstart.at(i), vstep.at(i), 0, 0, ierflg);
	}

//Setup for the B-spline_________________________________________________________________________

	//Looping begins for the calculations of the B and C-splines for each event
	for(int i = 0; i < (int)xEvents.size(); i++)
	{
		//Populate the global variables
		xData_GLOB = xEvents.at(i);
		yData_GLOB = yEvents.at(i);
		yErrorData_GLOB = yErrorEvents.at(i);

		tbstart = clock();
		vector< vector<double> > bSplineValues = bSpline(nPoints, npar, xEvents.at(i), yEvents.at(i), yErrorEvents.at(i), stepSpline, xminBSplineWorkspace, xmaxBSplineWorkspace);
		tbstop = clock();
		timeb.push_back(((float)tbstop-(float)tbstart)/ (CLOCKS_PER_SEC/1000.) );		

		std::cout<<timeb.back()<<std::endl;

		xBSplineValues.push_back(bSplineValues.at(0));
		yBSplineValues.push_back(bSplineValues.at(1));

		tcstart = clock();
		vector< vector<double> > cSplineValues = cSpline(nPoints, npar, xEvents.at(i), stepSpline, myMinuit);
		tcstop = clock();
		timec.push_back(((float)tcstop-(float)tcstart)/ (CLOCKS_PER_SEC/1000.) );		

		xCSplineValues.push_back(cSplineValues.at(0));
		yCSplineValues.push_back(cSplineValues.at(1));
	}

	//Histograms______________________________________________________________________________________

	//Time
	int nbins = 100;
	double xlow = 0;
	double xup = 1.;

	TH1D *hTimeB = new TH1D("Time","Timing; time [ms]; Number of Events", nbins, xlow, xup); 
	hTimeB->SetStats(0);
	hTimeB->SetMarkerStyle(10);
	TH1D *hTimeC = new TH1D("TimeC","Timing; time [ms]; Number of Events", nbins, xlow, xup); 
	hTimeC->SetLineColor(kRed);
	hTimeC->SetMarkerStyle(10);
	hTimeC->SetStats(0);

	for(int i=0; i<(int)timec.size(); i++) 
	{
		hTimeB->Fill(timeb.at(i));
		hTimeC->Fill(timec.at(i));	
	}

	//Interpolation
	vector <double> interpB, interpC;
	for(int i = 0; i < (int)yEvents.size(); i++)
	{
		for(int j = 0; j < (int)yEvents[i].size(); j++)
		{
			int indexForB = binarySearch(xBSplineValues[i], xEvents[i][j]);
			int indexForC = binarySearch(xCSplineValues[i], xEvents[i][j]);

			interpB.push_back( (yEvents[i][j]-yBSplineValues[i][indexForB])/yErrorEvents[i][j] );
			interpC.push_back( (yEvents[i][j]-yCSplineValues[i][indexForC])/yErrorEvents[i][j] );
		}
	}	

	//Test graphs for splines
	TGraph *GCspline = new TGraph(xCSplineValues[iEventLook].size(), &xCSplineValues[iEventLook][0], &yCSplineValues[iEventLook][0]);
	GCspline->SetLineColor(kRed);
	TGraph *GBspline = new TGraph(xBSplineValues[iEventLook].size(), &xBSplineValues[iEventLook][0], &yBSplineValues[iEventLook][0]);
	TGraph *Gdata = new TGraph(xEvents[0].size(), &xEvents[iEventLook][0], &yEvents[iEventLook][0]);
		Gdata->SetMarkerStyle(20);

	int nbinsI = 101;
	double xlowI = -0.1;
	double xupI = 0.1;
	TH1D *hInterpB = new TH1D("Interp B","Interpolation; Distance between spline and data normalized by error; Number of Events", nbinsI, xlowI, xupI); 
	for(int i=0; i<(int)interpB.size(); i++) hInterpB->Fill(interpB.at(i));
	hInterpB->SetStats(0);

	TH1D *hInterpC = new TH1D("Interp C","Interpolation; Distance between spline and data normalized by error; Number of Events", nbinsI, xlowI, xupI); 
	for (int i=0; i<(int)interpC.size(); i++) hInterpC->Fill(interpC.at(i));
	hInterpC->SetLineColor(kGreen);
	hInterpC->SetStats(0);	

	//Draws______________________________________________________________________________________

	//Interpolation 
	TLegend *legInterp = new TLegend(0.9,0.70,0.75,0.85);
	legInterp->SetLineColor(kWhite); 
	legInterp->SetFillColor(kWhite);
	legInterp->SetMargin(0.3); 
	legInterp->AddEntry(hInterpB,"b-spline","l");
	legInterp->AddEntry(hInterpC,"c-spline","l");
	legInterp->SetTextSize(0.05);

	TCanvas *c1 = new TCanvas("c1", "Interpolation distance");
	c1->cd();
	hInterpB->Draw("");
	hInterpC->Draw("same");
	legInterp->Draw();

	//Time
	TLegend *legTime = new TLegend(0.9,0.70,0.75,0.85);
	legTime->SetLineColor(kWhite); 
	legTime->SetFillColor(kWhite);
	legTime->SetMargin(0.3); 
	legTime->AddEntry(hTimeB,"b-spline","l");
	legTime->AddEntry(hTimeC,"c-spline","l");
	legTime->SetTextSize(0.05);

	TCanvas *c2 = new TCanvas("c2", "Computation time");
	c2->cd();
	hTimeB->Draw();
//	hTimeC->Draw("same");
	legTime-> Draw();

	TCanvas *c3 = new TCanvas("c3", "Test splines");
	c3->cd();
	Gdata->Draw("ap");
	GCspline->Draw("samel");
	GBspline->Draw("samel");

	//Free the memory used
	gsl_spline_free (spline_GLOB); 
 	gsl_interp_accel_free (acc_GLOB);
	gsl_bspline_free(bw_GLOB);
}
Example #12
0
void plotTotalKE(char target[6], char list[20], char part[4], 
		 char dir[12]="histo", char g4ver[20]="G4.9.1.p01",
		 bool flag=true) {

  setStyle();
  gStyle->SetOptTitle(0);

  char name[1024];
  char sym[10];
  if      (part=="pim") sprintf(sym, "#pi^{-}");
  else if (part=="pip") sprintf(sym, "#pi^{+}");
  else                  sprintf(sym, "p");

  std::map<string, double> means_300=getMean(target,list,part,"300.0","TotalKE",dir);
  std::map<string, double> means_200=getMean(target,list,part,"200.0","TotalKE",dir);
  std::map<string, double> means_150=getMean(target,list,part,"150.0","TotalKE",dir);
  std::map<string, double> means_100=getMean(target,list,part,"100.0","TotalKE",dir);
  std::map<string, double> means_50 =getMean(target,list,part,"50.0", "TotalKE",dir);
  std::map<string, double> means_30 =getMean(target,list,part,"30.0", "TotalKE",dir);
  std::map<string, double> means_20 =getMean(target,list,part,"20.0", "TotalKE",dir);
  std::map<string, double> means_15 =getMean(target,list,part,"15.0", "TotalKE",dir);
  std::map<string, double> means_9  =getMean(target,list,part,"9.0",  "TotalKE",dir);
  std::map<string, double> means_7  =getMean(target,list,part,"7.0",  "TotalKE",dir);
  std::map<string, double> means_5  =getMean(target,list,part,"5.0",  "TotalKE",dir);
  std::map<string, double> means_3  =getMean(target,list,part,"3.0",  "TotalKE",dir);
  std::map<string, double> means_2  =getMean(target,list,part,"2.0",  "TotalKE",dir);
  std::map<string, double> means_1  =getMean(target,list,part,"1.0",  "TotalKE",dir);
  if (flag) {
    std::map<string, double> means_10 =getMean(target,list,part,"10.0", "TotalKE",dir);
    std::map<string, double> means_8  =getMean(target,list,part,"8.0",  "TotalKE",dir);
    std::map<string, double> means_6  =getMean(target,list,part,"6.0",  "TotalKE",dir);
    std::map<string, double> means_4  =getMean(target,list,part,"4.0",  "TotalKE",dir);
  }

  char ctype[20];
  std::vector<std::string> types   = types();
  std::vector<std::string> typeOld = typesOld();
  //  std::cout << "Number of types " << types.size() << "\n";

  TGraph *gr[20];
  TLegend *leg = new TLegend(0.55, 0.45, 0.9, 0.80);
  char hdr[160];
  sprintf(hdr, "%s+%s (%s-%s)", sym, target, g4ver, list);
  leg->SetHeader(hdr);
  leg->SetFillColor(10);
  leg->SetMargin(0.45);
  leg->SetTextSize(.02);
  sprintf(name, "c_%s_%s_totalKE_%s", part,target,list);
  TCanvas *cc = new TCanvas(name, name, 700, 700);

  for (unsigned int ii=0; ii<=(types.size()); ii++) {
    if      (ii == 0) sprintf (ctype, "All Particles");
    else              sprintf (ctype, "%s", typeOld[ii-1].c_str());

    string a(ctype);
    //    std::cout<<a<<" "<< means_300[a]<<std::endl;
    double vx[18], vy[18];
    int np=0;
    vx[np] = 300.0;  vy[np] = means_300[a]; np++;
    vx[np] = 200.0;  vy[np] = means_200[a]; np++;
    vx[np] = 150.0;  vy[np] = means_150[a]; np++;
    vx[np] = 100.0;  vy[np] = means_100[a]; np++;
    vx[np] = 50.0;   vy[np] = means_50[a];  np++;
    vx[np] = 30.0;   vy[np] = means_30[a];  np++;
    vx[np] = 20.0;   vy[np] = means_20[a];  np++;
    vx[np] = 15.0;   vy[np] = means_15[a];  np++;
    if (flag) { vx[np] = 10.0;   vy[np] = means_10[a];  np++;}
    vx[np] = 9.0;    vy[np] = means_9[a];   np++;
    if (flag) { vx[np] = 8.0;    vy[np] = means_8[a];   np++;}
    vx[np] = 7.0;    vy[np] = means_7[a];   np++;
    if (flag) { vx[np] = 6.0;    vy[np] = means_6[a];   np++;}
    vx[np] = 5.0;    vy[np] = means_5[a];   np++;
    if (flag && part != "pro") { vx[np] = 4.0;    vy[np] = means_4[a];   np++;}
    vx[np] = 3.0;    vy[np] = means_3[a];   np++;
    vx[np] = 2.0;    vy[np] = means_2[a];   np++;
    vx[np] = 1.0;    vy[np] = means_1[a];   np++;

    for (int i=0; i<np; i++) vy[i] = vy[i]/vx[i];

    gPad->SetLogx(1);
    gPad->SetGridx(1);
    gPad->SetGridy(1);
    gr[ii] = new TGraph(np, vx,vy);
    sprintf(name, "KE carried by secondaries in %s-%s (%s)", sym, target, list);
    gr[ii]->SetTitle(name);
    gr[ii]->GetXaxis()->SetTitle("Beam Momentum (GeV)");
    gr[ii]->GetYaxis()->SetTitle("Mean Total KE/Beam Momentum");

    gr[ii]->SetMarkerStyle(mstyle[ii]);
    gr[ii]->SetMarkerSize(msiz[ii]);
    gr[ii]->SetMarkerColor(mcolor[ii]);
    gr[ii]->SetLineColor(lcolor[ii]);
    gr[ii]->SetLineStyle(lstyle[ii]);
    gr[ii]->SetLineWidth(lwidth[ii]); 

    gr[ii]->GetYaxis()->SetRangeUser(-0.02, 1.0);
    if (ii!= 0) sprintf (ctype, "%s", types[ii-1].c_str());
    if (ii!= 1) leg->AddEntry(gr[ii], ctype, "lP");
    if (ii==0)      gr[ii]->Draw("APl");
    else if (ii>1)  gr[ii]->Draw("Pl");
  }
  leg->Draw("same");
}
Example #13
0
void plotKE(char target[6], char list[20], char ene[6], char part[4],
	    int typ=0, char dir[12]="histo", char g4ver[20]="G4.9.1.p01") {

  setStyle();
  gStyle->SetOptTitle(0);
  gStyle->SetOptLogy(1);

  char name[1024];
  char sym[10];
  if      (part=="pim") sprintf(sym, "#pi^{-}");
  else if (part=="pip") sprintf(sym, "#pi^{+}");
  else                  sprintf(sym, "p");

  std::vector<std::string> typeOld = typesOld();
  int energy = atoi(ene);
  int bins=energy/4;
  float ener = energy;
  std::cout << "Energy " << ener << "\n";
  
  char ofile[100];
  sprintf (ofile, "%s/histo_%s%s_%s_%sGeV.root", dir, target, list, part, ene);
  std::cout << "Input file " << ofile << "\n";
  TFile *fout = TFile::Open(ofile);
  fout->cd();

  char name[160], title[160], ctype[20], ytitle[20], cname[160], pre[10];
  TH1F *hiKE[20];
  if (typ == 0) sprintf (pre, "KE2");
  else          sprintf (pre, "TotalKE");
  for (unsigned int ii=0; ii<=(typeOld.size()); ii++) {
    if      (ii == 0) sprintf (ctype, "All Particles");
    else              sprintf (ctype, "%s", typeOld[ii-1].c_str());
    sprintf (name, "%s%s%s%sGeV(%s)", pre, target, list, ene, ctype);
    hiKE[ii] = (TH1F*)fout->FindObjectAny(name);
    //    std::cout << ii << " (" << ctype << ") " << name << " " << hiKE[ii] <<"\n";
  }

  TCanvas *c[25];
  std::vector<std::string> types = types();
  for (unsigned int ii=0; ii<types.size(); ii++) {
    if      (ii == 0) sprintf (ctype, "All Particles");
    else              sprintf (ctype, "%s", types[ii-1].c_str());
    if (typ == 0) sprintf (cname, "Kinetic Energy of %s (GeV)", ctype);
    else          sprintf (cname, "Total Kinetic Energy of %s (GeV)", ctype);
    hiKE[ii]->GetXaxis()->SetTitle(cname);
    hiKE[ii]->SetMarkerStyle(mstyle[ii]);
    hiKE[ii]->SetMarkerSize(msiz[ii]);
    hiKE[ii]->SetMarkerColor(mcolor[ii]);
    hiKE[ii]->SetLineColor(lcolor[ii]);
    hiKE[ii]->SetLineStyle(lstyle[ii]);
    hiKE[ii]->SetLineWidth(lwidth[ii]); 
    if (bins > 0) hiKE[ii]->Rebin(bins);
    hiKE[ii]->GetXaxis()->SetRangeUser(0.0, ener);

    sprintf(cname, "c_%s%s_%s_%sGeV_%s(%s)", target,list,part,ene,pre,ctype);
    c[ii] = new TCanvas(cname, cname, 800, 500);
    hiKE[ii]->Draw();

    TLegend *leg = new TLegend(0.35, 0.80, 0.8, 0.87);
    char hdr[160];
    sprintf(hdr, "%s+%s at %s GeV (%s-%s)", sym, target, ene, g4ver, list);
    leg->SetHeader(hdr);  leg->SetFillColor(10); leg->SetMargin(0.45);
    leg->SetTextSize(.036); leg->Draw("same");
  }

  TLegend *leg1 = new TLegend(0.50, 0.75, 0.90, 0.90);
  if (typ == 0) sprintf (cname, "Kinetic Energy (GeV)");
  else          sprintf (cname, "Total Kinetic Energy (GeV)");
  hiKE[6]->GetXaxis()->SetTitle(cname);
  char hdr[160];
  sprintf(hdr, "%s+%s at %s GeV (%s-%s)", sym, target, ene, g4ver, list);
  leg1->SetHeader(hdr);  leg1->SetFillColor(10); leg1->SetMargin(0.45);
  sprintf(cname, "c_%s%s_%s_%sGeV_%s(Pion)", target,list,part,ene,pre);
  leg1->SetTextSize(.030); 
  c[19] = new TCanvas(cname, cname, 800, 500);
  hiKE[6]->Draw(); sprintf (ctype, "%s", types[5].c_str()); leg1->AddEntry(hiKE[6], ctype, "l");
  hiKE[5]->Draw("same"); sprintf (ctype, "%s", types[4].c_str()); leg1->AddEntry(hiKE[5], ctype, "l");
  hiKE[4]->Draw("same"); sprintf (ctype, "%s", types[3].c_str()); leg1->AddEntry(hiKE[4], ctype, "l"); leg->Draw("same");

  TLegend *leg2 = new TLegend(0.50, 0.75, 0.90, 0.90);
  if (typ == 0) sprintf (cname, "Kinetic Energy (GeV)");
  else          sprintf (cname, "Total Kinetic Energy (GeV)");
  hiKE[7]->GetXaxis()->SetTitle(cname);
  sprintf(hdr, "%s+%s at %s GeV (%s-%s)", sym, target, ene, g4ver, list);
  leg2->SetHeader(hdr);  leg2->SetFillColor(10); leg2->SetMargin(0.45);
  sprintf(cname, "c_%s%s_%s_%sGeV_%s(Kaon)", target,list,part,ene,pre);
  leg2->SetTextSize(.030); 
  c[20] = new TCanvas(cname, cname, 800, 500);
  hiKE[7]->Draw(); sprintf (ctype, "%s", types[6].c_str()); leg2->AddEntry(hiKE[7], ctype, "l");
  hiKE[8]->Draw("same"); sprintf (ctype, "%s", types[7].c_str()); leg2->AddEntry(hiKE[8], ctype, "l");
  hiKE[9]->Draw("same"); sprintf (ctype, "%s", types[8].c_str()); leg2->AddEntry(hiKE[9], ctype, "l"); leg2->Draw("same");

  TLegend *leg3 = new TLegend(0.50, 0.75, 0.90, 0.90);
  if (typ == 0) sprintf (cname, "Kinetic Energy (GeV)");
  else          sprintf (cname, "Total Kinetic Energy (GeV)");
  hiKE[12]->GetXaxis()->SetTitle(cname);
  sprintf(hdr, "%s+%s at %s GeV (%s-%s)", sym, target, ene, g4ver, list);
  leg3->SetHeader(hdr);  leg3->SetFillColor(10); leg3->SetMargin(0.45);
  sprintf(cname, "c_%s%s_%s_%sGeV_%s(Nucleon)", target,list,part,ene,pre);
  leg3->SetTextSize(.030); 
  c[21] = new TCanvas(cname, cname, 800, 500);
  hiKE[12]->Draw(); sprintf (ctype, "%s", types[11].c_str()); leg3->AddEntry(hiKE[12], ctype, "l");
  hiKE[11]->Draw("same"); sprintf (ctype, "%s", types[10].c_str()); leg3->AddEntry(hiKE[11], ctype, "l"); leg3->Draw("same");
}
void spike_summarize(TString dirOut="./HPU2012/Rebin/rebin3/", int factor=3, TString graph_style="A*") {
  
  loadPresentationStyle();
  /*
    gStyle->SetCanvasBorderMode(0);
    gStyle->SetCanvasColor(kWhite);
    gStyle->SetCanvasDefH(600); //Height of canvas                                                     
    gStyle->SetCanvasDefW(600); //Width of canvas                                                                   
    gStyle->SetCanvasDefX(0);   //POsition on screen                                                                 
    gStyle->SetCanvasDefY(0);

    gStyle->SetTitleFont(42);
    gStyle->SetTitleColor(1);
    gStyle->SetTitleTextColor(1);
  */
  //gStyle->SetTitleFillColor(10);
  /*
    gStyle->SetTitleFontSize(0.05);
    gStyle->SetTitleColor(1, "XYZ");
    gStyle->SetTitleFont(42, "XYZ");
  */
  gStyle->SetTitleSize(0.05, "XYZ");
  gStyle->SetTitleYOffset(1.2);
  /*
    gStyle->SetLabelColor(1, "XYZ");
    gStyle->SetLabelFont(42, "XYZ");
    gStyle->SetLabelOffset(0.007, "XYZ");
    gStyle->SetLabelSize(0.05, "XYZ");

    gStyle->SetAxisColor(1, "XYZ");
    gStyle->SetStripDecimals(kTRUE);
    gStyle->SetTickLength(0.03, "XYZ");
    gStyle->SetNdivisions(510, "XYZ");
    gStyle->SetPadTickX(1);  // To get tick marks on the opposite side of the frame                                                  
    gStyle->SetPadTickY(1);
  */
  //const int nSrc = 3; // 2011A, 2011B, highPU
  const int nSrc=5; // data 2011B, newkill 2011B, data highPU, emul highPU, 2012 online HPU
  const int nStrict = 2;
  const int nEG = 8;
  const int nVtx = 40;
  const int nVTX[nSrc]={40,40,40,40,60};
  const int nEG_g=4; // nEG for graph : EG12,15,20,30

  //TString src_name[nSrc]={"2011A","2011B","highPU"};
  TString src_name[nSrc]={"data_2011B","newsetting_2011B", "data_highPU", "d2012_HPU"};
  TString strict_name[nStrict] = {"large","strict"};

  TString trigname[nEG]={"2","5","8","10","12","15","20","30"};
  int trigthresh[nEG]={2,5,8,10,12,15,20,30};

  TH1F * h_evts_trigBy_any[nEG][nSrc];
  TH1F * h_evts_trigBy_spikes[nEG][nStrict][nSrc];

  cout << "objects declared and counters initialized" << endl;

  TString name_histo;

  for( int iSrc=0 ; iSrc<nSrc ; iSrc++ ) {
    for( int iEG=0 ; iEG<nEG ; iEG++ ) {
      name_histo = "h_evts_trigBy_any_EG"+trigname[iEG]+"_"+src_name[iSrc];
      h_evts_trigBy_any[iEG][iSrc] = new TH1F(name_histo,name_histo,nVTX[iSrc],0,nVTX[iSrc]);

      for( int iStrict=0 ; iStrict<nStrict ; iStrict++ ) {
	name_histo = "h_evts_trigBy_spikes_EG"+trigname[iEG]+"_"+strict_name[iStrict]+"_"+src_name[iSrc];
	h_evts_trigBy_spikes[iEG][iStrict][iSrc] = new TH1F(name_histo,name_histo,nVTX[iSrc],0,nVTX[iSrc]);
      }
    }
  }

  TString file[nSrc];

  // FILES : HLTEG12
  file[0]="/home/llr/cms/ndaci/SKWork/macro/skEfficiency/tagAndProbe/Spike2011A/Commi_2011B_HLTEG12_fromfilter/spike_plots_half_0_1.root";

  file[1]="/home/llr/cms/ndaci/SKWork/macro/skEfficiency/tagAndProbe/Spike2011A/CommiEmulReco_Run2011B/GetContamNewkill/spike_plots_half_0_1.root";

  file[2]="/home/llr/cms/ndaci/SKWork/macro/skEfficiency/tagAndProbe/Spike2011A/Commi_2011B_highPU_HLTEG_repro/spike_plots_half_0_1.root" ;

  file[3]="/home/llr/cms/ndaci/SKWork/macro/skEfficiency/Spikes/HighPuContamination/try2/spike_plots.root" ;

  file[4]="/home/llr/cms/ndaci/SKWork/macro/skEfficiency/Spikes2012/HPU/spike_plots_half_0_1.root" ;

  TFile * f;

  cout << "going to open files" << endl;

  for(int iSrc=0 ; iSrc<nSrc ; iSrc++) {

    if(iSrc==3) continue;

    f = TFile::Open(file[iSrc]);
    cout << "file #" << iSrc << " opened" << endl;
    for( int iEG=0 ; iEG<nEG ; iEG++ ) {
      name_histo = "h_evts_trigBy_any_EG"+trigname[iEG];
      h_evts_trigBy_any[iEG][iSrc] -> Add( (TH1F*)gDirectory->Get(name_histo) );
  
      if(iSrc==4) h_evts_trigBy_any[iEG][iSrc] -> Rebin(2);

      cout << " got histogram " + name_histo << endl;

      for( int iStrict=0 ; iStrict<nStrict ; iStrict++ ) {
        name_histo = "h_evts_trigBy_spikes_EG"+trigname[iEG]+"_"+strict_name[iStrict];
        h_evts_trigBy_spikes[iEG][iStrict][iSrc] -> Add( (TH1F*)gDirectory->Get(name_histo) );

	if(iSrc==4) h_evts_trigBy_spikes[iEG][iStrict][iSrc] -> Rebin(2);

	cout << "got histogram "+ name_histo <<endl;
      }
    }
    f->Close();
  } 
  
  // highPU emul is special case
  f = TFile::Open(file[3]);
  cout << "file #" << 3 << " opened" << endl;
  for( int iEG=0 ; iEG<nEG ; iEG++ ) {
    name_histo = "h_evts_trigBy_any_EG"+trigname[iEG]+"_M";
    h_evts_trigBy_any[iEG][3] -> Add( (TH1F*)gDirectory->Get(name_histo) );
    //
    name_histo = "h_evts_trigBy_spikes_EG"+trigname[iEG]+"_M";
    h_evts_trigBy_spikes[iEG][0][3] -> Add( (TH1F*)gDirectory->Get(name_histo) );
    h_evts_trigBy_spikes[iEG][1][3] -> Add( (TH1F*)gDirectory->Get(name_histo) );
  }

  const int nFr=2; // low/up frontier of iBin
  const int nBins_src[nSrc][nEG_g]={ {21,15,19,16} , {16,15,13,10} , {28,25,24,21} , {28,25,24,21} , {15,15,15,15}};

  int idxBinsFr[nSrc][nEG_g][nFr]={ { {2,22},{1,15},{2,20},{3,18} },
				    { {3,18},{1,15},{4,16},{5,14} }, 
				    { {12,39},{14,38},{14,37},{14,34} }, 
				    { {12,39},{14,38},{14,37},{14,34} },
				    { {30,60},{30,60},{30,60},{30,60} } };

  int fact[nSrc]={1,1,1,1,factor};

  vector< float > n_evts_trigBy_any[nEG][nSrc]; // double tableau de vecteurs de floats
  vector< float > n_evts_trigBy_spikes[nEG][nStrict][nSrc]; // triple 
  vector< float > n_contam[nEG][nStrict][nSrc]; 
  vector< float > err_contam[nEG][nStrict][nSrc];

  // --> chaque element du tableau est un vecteur contenant les valeurs des bins des histos

  for(int iEG=0 ; iEG<nEG_g ; iEG++) {
    for(int iSrc=0 ; iSrc<nSrc ; iSrc++) {

      const int nBins = nBins_src[iSrc][iEG] ;
	       
      for(int iBin=0 ; iBin<nBins ; iBin++) {
	n_evts_trigBy_any[iEG][iSrc].push_back( 
					       (float)( h_evts_trigBy_any[iEG+4][iSrc] -> GetBinContent(idxBinsFr[iSrc][iEG][0]/fact[iSrc]+iBin+1) ) );
	for(int iStrict=0 ; iStrict<nStrict ; iStrict++ ) {
	  n_evts_trigBy_spikes[iEG][iStrict][iSrc].push_back( 
							     (float)( h_evts_trigBy_spikes[iEG+4][iStrict][iSrc] 
								      -> GetBinContent(idxBinsFr[iSrc][iEG][0]/fact[iSrc]+iBin+1) ) );

	  if( n_evts_trigBy_any[iEG][iSrc][iBin] !=0 ) {
	    n_contam[iEG][iStrict][iSrc].push_back(
						   n_evts_trigBy_spikes[iEG][iStrict][iSrc][iBin]/n_evts_trigBy_any[iEG][iSrc][iBin]);
	    err_contam[iEG][iStrict][iSrc].push_back( 
						     errPoissCount( n_evts_trigBy_spikes[iEG][iStrict][iSrc][iBin], n_evts_trigBy_any[iEG][iSrc][iBin]) );
	  }

	  else {
	    n_contam[iEG][iStrict][iSrc].push_back(-0.01);
	    err_contam[iEG][iStrict][iSrc].push_back(0);
	  }
	} // loop over iStrict
      } // loop over iBin
    } // loop over iSrc
  } // loop over iEG

  for(int iEG=0 ; iEG<nEG_g ; iEG++) {
    for(int iSrc=0 ; iSrc<nSrc ; iSrc++) {
      int nBins = n_evts_trigBy_any[iEG][iSrc].size();
      cout << "EG" << trigname[iEG+4] << " src=" << src_name[iSrc] << endl;
      for(int iBin=0 ; iBin<nBins ; iBin++)
	cout << n_evts_trigBy_any[iEG][iSrc][iBin] << "   " ;
      cout << endl;
      
      for(int iStrict=0 ; iStrict<nStrict ; iStrict++ ) {
	cout << "strict="<< strict_name[iStrict]<< endl;

	int nBins_s = n_evts_trigBy_spikes[iEG][iStrict][iSrc].size();
	for(int iBin=0 ; iBin<nBins_s ; iBin++)
	  cout << n_evts_trigBy_spikes[iEG][iStrict][iSrc][iBin] << "   ";
	cout << endl;

	nBins_s = n_contam[iEG][iStrict][iSrc].size();
	for(int iBin=0 ; iBin<nBins_s ; iBin++)
	  cout << n_contam[iEG][iStrict][iSrc][iBin] << "   ";
	cout << endl;
      }
      cout << endl;
    }
    cout << endl;
  }

  //int mark_style[nSrc] = {22,20,21}; // kFullTriangleUp, kFullCircle, kFullSquare
  //int mark_col[nSrc] = {4,2,1}; // bleu, rouge, noir

  int mark_style[nSrc] = {22,22,21,21,20};
  //int mark_col[nSrc] = {4,2,4,2};
  int mark_col[nSrc] = {kRed,kGreen+2,kRed,kGreen+2,kBlue};

  TGraph * g_evt_contam[nEG][nStrict][nSrc];
  TGraphErrors * g_evt_contam_err[nEG][nStrict][nSrc];
				    
  for(int iSrc=0 ; iSrc<nSrc ; iSrc++) {
    for(int iStrict=0 ; iStrict<nStrict ; iStrict++) {
      for(int iEG=0 ; iEG<nEG_g ; iEG++) {

	const int nPts = nBins_src[iSrc][iEG];
	float x_vtx[nPts];
	float err_vtx[nPts];
	for(int iVtx=0 ; iVtx<nPts ; iVtx++) {
	  x_vtx[iVtx] = (float)( idxBinsFr[iSrc][iEG][0] + iVtx*fact[iSrc] ) ;
	  cout << x_vtx[iVtx] << " | " ;
	  err_vtx[iVtx] = 0.49*fact[iSrc];
	}
	cout << endl;

	const int nDots = n_contam[iEG][iStrict][iSrc].size();
	if( nDots != nPts ) {
	  cout << "ERROR : nDots != nPts ! exit..." << endl;
	  return;
	}

	float contam_vtx[nPts];
	float err_contam_vtx[nPts];

	for(int iVtx=0 ; iVtx<nPts ; iVtx++) {
	  contam_vtx[iVtx] = n_contam[iEG][iStrict][iSrc][iVtx];
	  cout << n_contam[iEG][iStrict][iSrc][iVtx] << " |||" ;
	  cout << contam_vtx[iVtx] << " || ";
	  err_contam_vtx[iVtx] = err_contam[iEG][iStrict][iSrc][iVtx];
	}
	cout << endl;

        g_evt_contam[iEG][iStrict][iSrc] = new TGraph( nPts, x_vtx, contam_vtx );
	g_evt_contam_err[iEG][iStrict][iSrc] = new TGraphErrors( nPts, x_vtx, contam_vtx, err_vtx, err_contam_vtx );

        g_evt_contam[iEG][iStrict][iSrc]->SetName(
						  "Event_"+strict_name[iStrict]+"_contamination_EG"+trigname[iEG+4]+"_"+src_name[iSrc] );
        g_evt_contam[iEG][iStrict][iSrc]->SetTitle(
						   "Event "+strict_name[iStrict]+" contamination (EG"+trigname[iEG+4]+") "+src_name[iSrc] );
	g_evt_contam[iEG][iStrict][iSrc]->SetMarkerStyle(mark_style[iSrc]);
	g_evt_contam[iEG][iStrict][iSrc]->SetMarkerColor(mark_col[iSrc]);
	g_evt_contam[iEG][iStrict][iSrc]->SetFillColor(kWhite);
	cout << "N POINTS = " << g_evt_contam[iEG][iStrict][iSrc]->GetN() << endl;

        g_evt_contam_err[iEG][iStrict][iSrc]->SetName(
						      "Event_"+strict_name[iStrict]+"_contamination_error_EG"+trigname[iEG+4]+"_"+src_name[iSrc] );
        g_evt_contam_err[iEG][iStrict][iSrc]->SetTitle(
						       "Event "+strict_name[iStrict]+" contamination (EG"+trigname[iEG+4]+") "+src_name[iSrc] );
        g_evt_contam_err[iEG][iStrict][iSrc]->SetMarkerStyle(mark_style[iSrc]);
        g_evt_contam_err[iEG][iStrict][iSrc]->SetMarkerColor(mark_col[iSrc]);
        g_evt_contam_err[iEG][iStrict][iSrc]->SetFillColor(kWhite);



      }
    }
  }
  cout << endl << endl;

  for(int iSrc=0 ; iSrc<nSrc ; iSrc++)
    for(int iStrict=0 ; iStrict<nStrict ; iStrict++)
      for(int iEG=0 ; iEG<nEG_g ; iEG++)
	cout << "N POINTS = " << g_evt_contam[iEG][iStrict][iSrc]->GetN() << endl;
  //for(int iVtx=0 ; iVtx<nPts ; iVtx++)
  //cout << n_contam[iEG][iStrict][iSrc][iVtx] << " || " <<
	    
  //////////////////////////////////////////////////////////
  // PLOTTING //////////////////////////////////////////////
  //////////////////////////////////////////////////////////

  TCanvas * c_evt_contam[nEG_g][nStrict];
  TCanvas * c_evt_contam_err[nEG_g][nStrict];

  float g_max[nEG_g] = {0.3,0.4,0.6,0.35};

  //for(int iEG=0 ; iEG<nEG_g ; iEG++) {
  /*
    for(int iEG=0 ; iEG<2 ; iEG++) {
    for(int iStrict=0 ; iStrict<nStrict ; iStrict++) {
      
    c_evt_contam[iEG][iStrict] = new TCanvas("c_evt_contam_EG"+trigname[iEG+4]+"_"+strict_name[iStrict],
    "Spike contamination "+strict_name[iStrict]+" (EG"+trigname[iEG+4]+")",
    0,0,800,600);
      
    c_evt_contam[iEG][iStrict]->SetFillColor(kWhite);
    c_evt_contam[iEG][iStrict]->GetFrame()->SetFillColor(kWhite);

    g_evt_contam[iEG][iStrict][0]->SetMinimum(0);
    g_evt_contam[iEG][iStrict][0]->SetMaximum(g_max[iEG]);      
    g_evt_contam[iEG][iStrict][0]->GetXaxis()->Set(40,0,40);
    g_evt_contam[iEG][iStrict][0]->GetXaxis()->SetTitle("Number of vertices");
    g_evt_contam[iEG][iStrict][0]->GetYaxis()->SetTitle("Fraction of EG events trig. by spikes");

    g_evt_contam[iEG][iStrict][0]->SetTitle( "Spike contamination (EG"+trigname[iEG+4]+")" );

    g_evt_contam[iEG][iStrict][0]->Draw("AP");
    g_evt_contam[iEG][iStrict][1]->Draw("P");
    g_evt_contam[iEG][iStrict][2]->Draw("P");
    g_evt_contam[iEG][iStrict][3]->Draw("P");

    TLegend * leg = new TLegend(0.5,0.70,0.885,0.90,"CMS Preliminary 2011 pp #sqrt{s}=7 TeV","brNDC"); 
    //(x1,y1),(x2,y2)->bottom left , top right
    leg->SetLineColor(1);
    leg->SetTextColor(1);
    leg->SetTextFont(42);
    leg->SetTextSize(0.03);
    leg->SetMargin(0.2);
    leg->SetShadowColor(kWhite);
    leg->SetFillColor(kWhite);
    //
    leg->AddEntry(g_evt_contam[iEG][iStrict][0],"Run 2011B Data","P");
    leg->AddEntry(g_evt_contam[iEG][iStrict][1],"Run 2011B Emul new setting (data)","P");
    leg->AddEntry(g_evt_contam[iEG][iStrict][2],"High PU runs Data","P");
    leg->AddEntry(g_evt_contam[iEG][iStrict][3],"High PU runs Emul new setting (data)","P");
    leg->Draw();

    c_evt_contam[iEG][iStrict]->Print(dirOut+"evt_contam_EG"+trigname[iEG+4]+"_"+strict_name[iStrict]+".C");
    c_evt_contam[iEG][iStrict]->Print(dirOut+"evt_contam_EG"+trigname[iEG+4]+"_"+strict_name[iStrict]+".gif");
    c_evt_contam[iEG][iStrict]->Print(dirOut+"evt_contam_EG"+trigname[iEG+4]+"_"+strict_name[iStrict]+".png");
    c_evt_contam[iEG][iStrict]->Print(dirOut+"evt_contam_EG"+trigname[iEG+4]+"_"+strict_name[iStrict]+".eps");
    c_evt_contam[iEG][iStrict]->Print(dirOut+"evt_contam_EG"+trigname[iEG+4]+"_"+strict_name[iStrict]+".ps");
    c_evt_contam[iEG][iStrict]->Print(dirOut+"evt_contam_EG"+trigname[iEG+4]+"_"+strict_name[iStrict]+".pdf");
    }
    }
  */
  cout << "<--- FINE UNTIL HERE --->" << endl;

  //for(int iEG=0 ; iEG<nEG_g ; iEG++) {
  for(int iEG=1 ; iEG<3 ; iEG++) {
    for(int iStrict=0 ; iStrict<nStrict ; iStrict++) {

      c_evt_contam_err[iEG][iStrict] = new TCanvas("c_evt_contam_err_EG"+trigname[iEG+4]+"_"+strict_name[iStrict],
						   "Spike contamination "+strict_name[iStrict]+" (EG"+trigname[iEG+4]+")",
						   0,0,800,600);

      c_evt_contam_err[iEG][iStrict]->SetFillColor(kWhite);
      c_evt_contam_err[iEG][iStrict]->GetFrame()->SetFillColor(kWhite);

      g_evt_contam_err[iEG][iStrict][0]->SetMinimum(0);
      g_evt_contam_err[iEG][iStrict][0]->SetMaximum(g_max[iEG]);
      g_evt_contam_err[iEG][iStrict][0]->GetXaxis()->Set(60,0,60);

      g_evt_contam_err[iEG][iStrict][0]->SetTitle( "Spike contamination (EG"+trigname[iEG+4]+")" );
      g_evt_contam_err[iEG][iStrict][0]->GetXaxis()->SetTitle("Number of vertices");
      g_evt_contam_err[iEG][iStrict][0]->GetYaxis()->SetTitle("Fraction of EG events trig. by spikes");

      g_evt_contam_err[iEG][iStrict][0]->Draw("AP");
      g_evt_contam_err[iEG][iStrict][1]->Draw("P");
      g_evt_contam_err[iEG][iStrict][2]->Draw("P");
      g_evt_contam_err[iEG][iStrict][3]->Draw("P");
      g_evt_contam_err[iEG][iStrict][4]->Draw("P");

      //TLegend * leg = new TLegend(0.17,0.695,0.58,0.90,"CMS Preliminary 2012 pp  #sqrt{s}=7+8 TeV","brNDC");
      TLegend * leg = new TLegend(0.17,0.675,0.58,0.88,"CMS Preliminary 2012 pp  #sqrt{s}=7+8 TeV","brNDC");
      //(x1,y1),(x2,y2)->bottom left , top right
      leg->SetMargin(0.15);
      leg->SetLineColor(1);
      leg->SetTextColor(1);
      leg->SetTextFont(42);
      leg->SetTextSize(0.03);
      leg->SetShadowColor(kWhite);
      leg->SetFillColor(kWhite);
      //
      leg->AddEntry(g_evt_contam[iEG][iStrict][0],"Run 2011B Data","P");
      leg->AddEntry(g_evt_contam[iEG][iStrict][1],"Run 2011B Emul new setting (data)","P");
      leg->AddEntry(g_evt_contam[iEG][iStrict][2],"High PU runs Data","P");
      leg->AddEntry(g_evt_contam[iEG][iStrict][3],"High PU runs Emul new setting (data)","P");
      leg->AddEntry(g_evt_contam[iEG][iStrict][4],"High PU runs 2012 (data)","P");
      leg->Draw();

      /*
	TLegend * leg2 = new TLegend(0.4,0.78,0.885,0.88,"","brNDC"); //(x1,y1),(x2,y2):bottom left,top right
	leg2->SetLineColor(1);
	leg2->SetTextColor(1);
	leg2->SetTextFont(42);
	leg2->SetTextSize(0.03);
	leg2->SetShadowColor(kWhite);
	leg2->SetFillColor(kWhite);
      
	leg2->AddEntry("NULL","Contamination = #frac{N(events triggered by a spike)}{N(events triggered by any object)}","h");
      
	leg2->Draw();
      */

      c_evt_contam_err[iEG][iStrict]->Print(dirOut+"evt_contam_err_EG"+trigname[iEG+4]+"_"+strict_name[iStrict]+".C");
      c_evt_contam_err[iEG][iStrict]->Print(dirOut+"evt_contam_err_EG"+trigname[iEG+4]+"_"+strict_name[iStrict]+".gif");
      c_evt_contam_err[iEG][iStrict]->Print(dirOut+"evt_contam_err_EG"+trigname[iEG+4]+"_"+strict_name[iStrict]+".png");
      c_evt_contam_err[iEG][iStrict]->Print(dirOut+"evt_contam_err_EG"+trigname[iEG+4]+"_"+strict_name[iStrict]+".eps");
      c_evt_contam_err[iEG][iStrict]->Print(dirOut+"evt_contam_err_EG"+trigname[iEG+4]+"_"+strict_name[iStrict]+".ps");
      c_evt_contam_err[iEG][iStrict]->Print(dirOut+"evt_contam_err_EG"+trigname[iEG+4]+"_"+strict_name[iStrict]+".pdf");

    }
  }

}
void metDistribution(const Int_t signalRegion_flag = 1) {

  // if signalRegion_flag == 1 (default), will do met distribution in the monojet signal region, else it will do the control region

  gROOT->SetStyle("Plain");  // to have white legend (on my pc it's already white, but in tier2 it appears grey)
  gStyle->SetFillColor(10);

  string plotDirectoryPath = "/cmshome/ciprianim/CMSSW721/pdfsFromAnalysis/plots/monojet/met_distribution/";
  //string plotDirectoryPath = "./";
  string plotFileExtension = ".pdf";
  string suffix = "_mumu";

  TH1D* hmet = NULL;
  vector<TH1D*> hMCmetNoLep;

  vector<string> sampleName;
  vector<string> MC_TexLabel;
  setSampleName(signalRegion_flag, sampleName, MC_TexLabel);

  Int_t nFiles = (Int_t)sampleName.size();

  vector<Int_t> histColor;
   setHistColor(histColor, nFiles);

   string filenameBase;
   string canvasName;
   if (signalRegion_flag == 1) {
     filenameBase = "monojet_SR_spring15_25ns_";
     canvasName = "metDistribution_monojetSR";
   } else {
     filenameBase = "zmumujets_CS_spring15_25ns_";
     canvasName = "metDistribution_zjetsCS" + suffix;
   }
 
  string filenameExtension = ".root";

  vector<string> MCfileName;
  for (Int_t i = 0; i < nFiles; i++){
    MCfileName.push_back(filenameBase + sampleName[i] + filenameExtension);
  }

  for(Int_t i = 0; i < nFiles; i++) {

    cout<<"fileName : "<<MCfileName[i]<<endl;

    TFile* f = TFile::Open(MCfileName[i].c_str(),"READ");
    if (!f || !f->IsOpen()) {
      cout<<"*******************************"<<endl;
      cout<<"Error opening file \""<<MCfileName[i]<<"\".\nApplication will be terminated."<<endl;
      cout<<"*******************************"<<endl;
      exit(EXIT_FAILURE);
    }

    //cout << "check 1 " << endl;    

    hmet = (TH1D*)f->Get("HYieldsMetBin");
    if (!hmet) {
      cout << "Error: histogram not found in file ' " << MCfileName[i] << "'. End of programme." << endl;
      exit(EXIT_FAILURE);
    }
    hMCmetNoLep.push_back( (TH1D*)hmet->Clone() );

  } 

  THStack* hstack_metNoLep = new THStack("hstack_metNoLep","");

  for (Int_t j = 0; j < nFiles; j++) {

    for (Int_t i = 1; i <= hMCmetNoLep[j]->GetNbinsX(); i++) {

      hMCmetNoLep[j]->SetBinError(i,sqrt(hMCmetNoLep[j]->GetBinContent(i)));

    }

    hMCmetNoLep[j]->SetFillColor(histColor[j]);
    hstack_metNoLep->Add(hMCmetNoLep[j]);

  }

  // now here we go with the canvas
  // TH1D * ratioplot = NULL; // will use it for the ratio plots

  // TPad *subpad_1 = NULL;  // will use it to access specific subpad in canvas
  // TPad *subpad_2 = NULL; 
  TCanvas *c = new TCanvas(canvasName.c_str(),"met distribution");
  c->SetLogy();

  TLegend *leg = new TLegend(0.6,0.55,0.89,0.89);
  
  // subpad_1 = new TPad("pad_1","",0.0,0.28,1.0,1.0);
  // //subpad_1->SetBottomMargin(0);
  // subpad_2 = new TPad("pad_2","",0.0,0.0,1.0,0.32);
  // subpad_2->SetGridy();
  // //subpad_2->SetTopMargin(0);
  // subpad_2->SetBottomMargin(0.3);
  // subpad_1->Draw();
  // subpad_2->Draw();

  //subpad_1->cd();
  hstack_metNoLep->Draw("HIST");
  //hstack_metNoLep->SetMinimum(0.3);
  //hstack_metNoLep->SetMaximum(4000.0);
  TH1D* stackCopy = (TH1D*)(((TH1D*)hstack_metNoLep->GetStack()->Last())->DrawCopy("E2 SAME"));
  stackCopy->SetFillColor(kBlack);
  stackCopy->SetFillStyle(3017);
  hstack_metNoLep->GetXaxis()->SetTitle("#slash{E}_{T} [GeV]");
  hstack_metNoLep->GetXaxis()->SetTitleSize(0.06);
  hstack_metNoLep->GetXaxis()->SetTitleOffset(0.6);
  hstack_metNoLep->GetYaxis()->SetTitle("events");
  hstack_metNoLep->GetYaxis()->SetTitleSize(0.06);
  hstack_metNoLep->GetYaxis()->SetTitleOffset(0.8);
  hstack_metNoLep->GetYaxis()->CenterTitle();
  for (Int_t j = (nFiles-1); j >= 0; j--) {
    leg->AddEntry(hMCmetNoLep[j],Form("%s",MC_TexLabel[j].c_str()),"lf");
  }
  gStyle->SetStatStyle(0);
  leg->Draw(); 
  leg->SetMargin(0.3); 
  leg->SetBorderSize(0);

  // subpad_2->cd();
  // ratioplot = new TH1D(*hratio);
  // ratioplot->Divide(hBRratioOverAxe);
  // ratioplot->SetStats(0);
  // ratioplot->GetXaxis()->SetLabelSize(0.10);
  // ratioplot->GetXaxis()->SetTitle("#slash{E}_{T} [GeV]");
  // ratioplot->GetXaxis()->SetTitleSize(0.15);
  // ratioplot->GetXaxis()->SetTitleOffset(0.8);
  // ratioplot->GetYaxis()->SetLabelSize(0.10);
  // ratioplot->GetYaxis()->SetTitle("ratio");
  // ratioplot->GetYaxis()->SetTitleSize(0.15);
  // ratioplot->GetYaxis()->SetTitleOffset(0.3);
  // ratioplot->GetYaxis()->CenterTitle();
  // ratioplot->GetYaxis()->SetRangeUser(0.5,1.5);
  // ratioplot->GetYaxis()->SetNdivisions(011);
  // ratioplot->DrawCopy("HE");
  // ratioplot->SetMarkerStyle(8);  //medium dot
  c->SaveAs( (plotDirectoryPath + c->GetName() + plotFileExtension).c_str() );

}
Example #16
0
void makePlots()
{
 // **********************************************
 // *            Input parameters                *
 // **********************************************
 
static int numbetas = 179;

// Double_t beta_vals[101]={0.004,0.006,0.01,0.012,0.014,0.016,0.026,0.028,0.03,0.032,0.034,0.036,0.038,0.04,0.042,0.046,0.048,0.052,0.054,0.056,0.058,0.062,0.064,0.066,0.068,0.07,0.072,0.074,0.076,0.08,0.082,0.084,0.088,0.09,0.092,0.094,0.096,0.098,0.1,0.12,0.13,0.14,0.15,0.18,0.19,0.2,0.21,0.26,0.27,0.28,0.29,0.3,0.31,0.32,0.33,0.34,0.35,0.36,0.37,0.4,0.41,0.43,0.44,0.45,0.46,0.47,0.48,0.49,0.51,0.53,0.55,0.59,0.61,0.62,0.65,0.67,0.68,0.69,0.7,0.72,0.74,0.81,0.87,0.88,0.906,0.908,0.924,0.926,0.93,0.932,0.942,0.95,0.962,0.966,0.97,0.976,0.986,0.992,0.994,0.996,0.9995};
// Double_t m_expected_combo[101]={300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,355.6,380.8,429.4,460.7,470.8,482.8,504.4,512.4,527.1,534.8,541.8,549.2,562.8,569.4,575.9,582.4,589.2,595.8,601.4,605.0,613.0,616.6,620.0,627.3,631.0,634.4,637.4,641.0,643.5,646.7,671.3,680.9,690.6,699.8,719.1,725.0,730.3,735.8,759.8,764.0,767.8,771.8,775.8,779.6,783.2,787.0,790.7,793.9,797.5,801.7,821.1,827.4,840.4,845.2,850.0,853.3,857.1,861.1,863.8,871.7,879.4,886.6,904.3,913.9,918.8,932.2,941.7,946.5,950.3,954.2,961.0,968.2,995.5,1012.0,1014.6,1021.2,1021.7,1025.6,1026.2,1027.2,1027.7,1030.2,1032.1,1035.3,1036.3,1037.2,1038.8,1041.5,1042.9,1043.6,1043.8,1044.7};
// Double_t m_observed_combo[101]={300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,358.1,367.1,386.0,395.3,462.9,471.3,480.1,490.3,507.6,515.2,522.7,530.2,537.9,545.4,551.1,554.0,559.6,562.3,564.9,570.0,572.5,574.9,577.3,579.6,582.1,584.5,609.0,623.8,638.2,651.1,672.4,678.4,684.4,690.1,713.8,717.6,721.4,724.9,728.4,731.7,735.0,738.0,741.0,743.9,746.7,749.5,758.1,760.8,766.2,768.8,771.4,774.1,776.7,779.4,781.9,786.8,791.9,796.8,820.1,834.7,842.2,856.6,863.7,867.2,870.7,874.6,882.1,888.9,985.2,1023.0,1026.9,1037.2,1038.0,1044.3,1045.1,1046.6,1047.4,1051.2,1054.3,1058.8,1060.3,1061.8,1064.0,1067.7,1069.9,1070.7,1071.4,1072.7};
// Double_t m_1sigma_combo[202]={300.0,300.0,300.0,300.0,300.0,300.0,450.4,467.4,484.3,500.9,512.2,523.1,533.3,544.0,553.4,573.6,583.2,601.1,607.1,612.1,617.6,628.8,633.8,638.1,642.6,647.7,651.6,655.2,658.9,666.1,669.6,672.8,678.4,681.9,684.5,687.6,690.2,693.2,696.0,717.1,726.0,734.3,741.9,763.4,769.4,775.1,781.1,814.9,824.4,834.4,844.7,851.4,855.5,859.7,863.4,866.9,870.8,874.9,879.2,890.0,893.8,902.3,908.1,913.6,918.7,923.7,928.5,933.7,943.7,952.5,959.4,973.5,980.9,984.6,995.6,1002.2,1004.6,1007.2,1009.7,1014.7,1019.9,1037.2,1052.5,1054.5,1061.0,1061.7,1065.6,1066.2,1067.1,1067.8,1070.2,1072.2,1075.3,1076.3,1077.5,1078.8,1081.7,1083.0,1083.8,1084.2,1085.1,1004.4,1003.7,1003.0,1002.7,1001.1,997.7,995.1,993.7,992.6,987.3,984.3,980.3,979.4,977.9,976.9,970.5,969.9,959.6,955.8,930.8,898.8,888.2,879.6,873.5,869.0,864.2,855.9,843.5,840.2,830.5,813.9,803.8,796.9,790.5,787.7,785.1,782.2,779.2,776.3,773.3,767.1,764.4,754.9,751.1,748.0,744.7,740.6,736.9,733.6,729.8,726.1,722.2,718.7,714.5,691.4,685.6,679.3,672.9,650.5,641.1,629.6,617.7,587.7,582.6,577.8,574.2,569.3,564.8,560.3,551.5,546.0,541.1,532.0,526.8,521.7,516.8,511.2,506.0,500.2,492.3,476.0,468.5,461.2,452.3,381.9,361.8,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};
// Double_t m_2sigma_combo[202]={300.0,300.0,300.0,300.0,300.0,300.0,517.7,531.8,545.8,560.1,572.7,586.2,598.0,607.1,614.6,629.6,636.2,649.1,654.1,659.2,664.5,673.8,677.9,681.6,685.9,690.1,693.8,698.3,701.4,707.1,710.1,712.9,718.1,721.0,723.3,726.1,728.2,730.7,733.2,754.7,764.5,773.5,781.8,810.4,825.4,841.9,852.4,877.8,882.2,886.7,891.0,895.6,900.0,906.5,912.5,918.5,924.8,930.6,936.5,952.2,956.3,963.8,967.8,971.5,974.9,979.1,982.5,986.3,994.3,1001.4,1006.8,1017.6,1023.1,1025.6,1033.1,1038.3,1040.8,1043.5,1045.8,1050.7,1055.5,1072.4,1087.9,1090.2,1096.8,1097.6,1101.7,1102.0,1103.0,1103.7,1106.1,1108.0,1111.1,1111.9,1113.2,1114.3,1117.0,1118.3,1118.9,1119.3,1120.3,952.9,951.6,950.8,950.2,947.6,943.8,941.2,939.8,937.9,933.5,929.9,926.1,925.0,923.5,923.0,915.9,915.8,904.1,898.9,863.8,833.2,825.7,817.7,813.5,810.1,805.6,798.4,789.5,786.6,781.0,769.5,763.6,758.4,752.0,749.0,746.1,742.5,738.6,735.7,732.3,725.9,722.9,713.2,709.9,706.8,704.1,700.6,697.2,693.8,690.1,686.2,681.9,678.2,673.9,649.1,642.2,635.0,627.4,602.4,589.0,573.2,558.0,523.5,519.8,515.8,512.5,508.6,505.2,500.7,490.0,484.5,478.3,468.1,462.8,456.3,449.4,410.5,388.7,374.6,360.7,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};
// Double_t m_expected_lljj[101]={300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,307.8,317.1,327.2,338.2,392.9,414.2,433.7,452.5,495.2,510.6,526.6,542.5,600.9,612.7,623.9,635.6,646.3,655.4,664.2,672.5,679.8,687.8,695.1,704.0,737.1,748.5,761.0,766.6,772.1,777.7,783.1,788.2,794.1,805.4,818.2,831.1,860.0,879.0,886.5,908.2,918.9,924.3,929.4,934.5,944.9,954.2,985.0,1006.8,1009.6,1016.7,1017.1,1021.4,1021.9,1023.2,1023.6,1026.0,1028.1,1031.2,1032.0,1033.1,1035.0,1037.5,1038.7,1039.3,1039.5,1040.3};
// Double_t m_observed_lljj[101]={300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,351.2,354.2,357.2,360.1,387.8,400.8,421.4,441.2,480.1,491.5,502.7,514.7,617.2,650.8,660.7,670.8,679.8,689.0,698.1,703.6,708.0,712.4,716.6,720.8,732.6,736.4,743.7,747.2,750.9,755.2,759.4,763.4,767.4,775.4,783.0,790.4,812.5,831.2,841.6,859.0,867.0,871.0,875.2,879.3,886.5,893.7,1016.5,1033.9,1036.8,1043.9,1044.4,1048.7,1049.2,1050.3,1050.8,1053.3,1055.4,1058.4,1059.4,1060.4,1061.9,1064.4,1065.9,1066.4,1066.9,1067.7};
// Double_t m_expected_lvjj[101]={300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,356.8,381.7,422.7,458.7,468.8,479.3,501.2,509.2,524.6,532.8,540.1,547.0,561.1,568.3,574.6,580.8,588.5,594.4,600.6,605.1,612.2,616.4,619.8,627.4,630.4,633.7,637.1,640.3,643.3,646.2,670.8,680.1,689.7,698.7,717.6,723.0,728.5,733.2,753.6,756.5,759.8,762.9,765.4,768.2,770.6,772.9,775.0,777.0,778.7,780.5,784.5,785.9,787.7,788.6,788.9,789.4,790.1,790.1,790.2,790.2,790.1,788.9,785.9,783.4,781.8,777.0,772.9,770.6,768.2,765.4,759.8,753.6,723.0,680.1,670.8,637.1,633.7,605.1,600.6,588.5,580.8,547.0,517.3,458.7,381.7,300.0,300.0,300.0,300.0,300.0,300.0,300.0};
// Double_t m_observed_lvjj[101]={300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,351.0,359.5,368.3,386.0,394.9,460.3,467.8,475.3,483.8,500.7,508.5,516.1,523.7,531.4,539.2,546.8,551.8,557.8,560.8,563.6,569.1,571.7,574.3,576.9,579.3,581.8,584.3,608.8,622.5,635.5,647.3,667.1,672.4,677.2,681.7,701.1,704.6,707.8,710.9,713.8,716.5,719.0,721.3,723.5,725.5,727.4,729.1,733.5,734.6,736.6,737.4,738.1,738.6,739.0,739.3,739.5,739.5,739.0,738.1,734.6,732.1,730.7,725.5,721.3,719.0,716.5,713.8,707.8,701.1,672.4,622.5,608.8,576.9,574.3,551.8,546.8,531.4,523.7,483.8,451.4,351.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0};

Double_t beta_vals[179]={0.004,0.006,0.008,0.01,0.012,0.014,0.016,0.018,0.02,0.022,0.024,0.026,0.028,0.03,0.032,0.034,0.036,0.038,0.04,0.042,0.044,0.046,0.048,0.05,0.052,0.054,0.056,0.058,0.06,0.062,0.064,0.066,0.068,0.07,0.072,0.074,0.076,0.078,0.08,0.082,0.084,0.086,0.088,0.09,0.092,0.094,0.096,0.098,0.1,0.11,0.12,0.13,0.14,0.15,0.16,0.17,0.18,0.19,0.2,0.21,0.22,0.23,0.24,0.25,0.26,0.27,0.28,0.29,0.3,0.31,0.32,0.33,0.34,0.35,0.36,0.37,0.38,0.39,0.4,0.41,0.42,0.43,0.44,0.45,0.46,0.47,0.48,0.49,0.5,0.51,0.52,0.53,0.54,0.55,0.56,0.57,0.58,0.59,0.6,0.61,0.62,0.63,0.64,0.65,0.66,0.67,0.68,0.69,0.7,0.71,0.72,0.73,0.74,0.75,0.76,0.77,0.78,0.79,0.8,0.81,0.82,0.83,0.84,0.85,0.86,0.87,0.88,0.89,0.9,0.902,0.904,0.906,0.908,0.91,0.912,0.914,0.916,0.918,0.92,0.922,0.924,0.926,0.928,0.93,0.932,0.934,0.936,0.938,0.94,0.942,0.944,0.946,0.948,0.95,0.952,0.954,0.956,0.958,0.96,0.962,0.964,0.966,0.968,0.97,0.972,0.974,0.976,0.978,0.98,0.982,0.984,0.986,0.988,0.99,0.992,0.994,0.996,0.998,0.9995};
Double_t m_expected_combo[179]={300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,354.2,379.9,425.8,460.0,470.8,482.2,495.3,504.5,512.0,520.3,527.3,534.3,542.2,549.5,556.2,563.1,569.9,575.9,582.8,590.4,596.5,601.9,605.5,609.6,613.6,617.3,620.9,624.8,628.5,632.1,635.0,638.6,642.3,645.1,648.1,660.6,672.3,682.1,691.8,700.7,707.3,714.1,720.1,725.9,731.4,736.6,741.8,746.6,751.3,756.0,760.6,764.7,768.7,772.8,776.8,780.6,784.0,787.9,791.1,794.8,798.3,803.3,810.1,816.2,823.3,828.6,835.9,841.1,846.8,851.6,854.9,858.7,862.1,865.5,869.3,873.0,877.0,881.0,884.5,888.2,892.0,896.2,901.2,906.2,910.8,915.6,919.8,924.3,929.4,933.4,937.9,942.5,947.0,950.8,954.5,957.9,961.6,964.6,968.3,971.9,975.7,979.5,983.4,986.6,990.5,994.0,998.5,1001.1,1003.7,1005.9,1008.6,1010.8,1013.3,1016.1,1018.4,1019.0,1019.5,1020.2,1020.4,1020.9,1021.7,1022.1,1022.5,1023.0,1023.4,1023.9,1024.5,1024.9,1025.4,1025.8,1026.2,1026.7,1027.6,1027.9,1028.5,1028.7,1029.3,1029.7,1030.2,1030.7,1031.5,1031.8,1032.3,1032.7,1033.4,1033.8,1034.3,1035.0,1035.2,1035.9,1036.3,1036.8,1037.2,1037.8,1038.3,1038.8,1039.4,1039.7,1040.3,1040.9,1041.2,1041.7,1042.7,1042.9,1043.3};
Double_t m_observed_combo[179]={300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,356.7,366.1,375.6,385.2,394.6,453.1,462.7,471.2,480.2,490.5,500.2,507.9,515.5,523.1,530.7,538.4,546.0,551.3,554.3,557.2,560.0,562.7,565.4,568.1,570.7,573.2,575.7,578.1,580.5,583.0,585.5,596.9,611.1,626.4,641.0,652.8,660.2,667.6,674.2,680.2,686.3,692.1,697.7,702.7,707.2,711.5,715.6,719.5,723.3,726.8,730.2,733.6,736.8,739.8,742.9,745.8,748.6,751.4,754.4,757.3,760.1,762.8,765.5,768.2,770.8,773.5,776.1,778.7,781.2,783.7,786.2,788.6,791.2,793.6,796.1,798.5,803.2,810.5,818.6,825.7,833.0,840.9,847.6,852.2,855.7,859.3,862.8,866.2,869.7,873.5,877.3,880.9,884.2,887.5,890.9,894.7,898.6,907.8,918.8,932.8,949.0,983.3,1002.4,1006.3,1010.2,1014.2,1018.1,1022.1,1025.9,1029.7,1033.6,1034.4,1035.2,1036.0,1036.8,1037.5,1038.3,1039.1,1039.9,1040.6,1041.4,1042.2,1042.9,1043.7,1044.4,1045.2,1045.9,1046.7,1047.4,1048.2,1049.0,1049.7,1050.4,1051.2,1051.9,1052.7,1053.4,1054.2,1054.9,1055.6,1056.4,1057.1,1057.8,1058.6,1059.3,1060.0,1060.8,1061.5,1062.2,1063.0,1063.7,1064.4,1065.1,1065.9,1066.6,1067.3,1068.0,1068.7,1069.4,1070.2,1070.7};
Double_t m_1sigma_combo[358]={300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,374.4,451.2,467.6,484.0,501.0,512.1,523.3,534.0,544.4,553.6,563.9,574.4,583.5,593.4,601.4,607.5,613.2,618.5,623.9,629.8,634.7,639.4,643.8,648.6,652.5,656.3,659.9,663.7,667.2,670.8,673.8,676.6,679.8,682.7,685.5,688.5,691.6,694.2,697.0,708.1,717.9,726.6,734.9,742.7,749.8,757.2,763.9,769.9,776.0,781.7,787.4,792.2,797.5,805.6,816.2,825.7,837.6,846.6,852.3,856.8,860.7,864.6,868.1,872.1,876.3,880.6,883.9,887.6,891.3,895.2,899.6,905.0,910.5,915.4,920.0,925.6,930.3,935.0,940.2,945.0,949.6,953.4,956.8,960.2,963.4,967.2,970.6,974.1,977.4,981.1,984.4,988.1,991.9,995.2,999.7,1001.8,1004.6,1006.7,1009.6,1011.9,1014.3,1016.7,1019.4,1021.8,1024.3,1026.8,1029.4,1031.6,1034.1,1036.5,1039.1,1041.2,1043.8,1046.4,1049.1,1051.1,1053.5,1056.0,1058.4,1058.8,1059.5,1060.2,1060.3,1061.0,1061.6,1061.8,1062.5,1063.1,1063.3,1064.0,1064.4,1064.8,1065.5,1065.9,1066.4,1066.7,1067.7,1067.8,1068.4,1068.7,1069.3,1069.8,1070.2,1070.8,1071.6,1072.0,1072.3,1072.7,1073.6,1073.9,1074.3,1074.9,1075.3,1075.9,1076.3,1077.0,1077.3,1077.8,1078.2,1078.9,1079.4,1080.0,1080.5,1081.0,1081.4,1081.8,1082.7,1083.0,1083.4,1003.0,1002.4,1002.4,1001.4,1001.1,1000.4,1000.2,999.3,998.7,997.8,997.8,996.8,995.8,994.8,993.9,993.4,992.4,991.9,991.0,990.0,989.5,988.7,988.2,987.2,986.3,985.8,985.1,983.9,983.4,982.7,981.9,981.5,980.4,979.5,978.8,978.1,977.2,976.9,976.0,974.9,974.3,973.5,972.6,972.3,971.5,970.3,969.8,968.9,968.2,967.6,966.5,963.0,959.6,955.6,951.7,947.6,944.0,939.8,935.8,931.7,927.6,923.3,918.7,914.6,909.8,905.6,900.2,894.7,889.5,884.8,880.7,875.6,870.4,866.1,861.7,856.9,852.9,849.1,845.0,841.0,837.2,832.6,827.8,823.9,819.5,815.3,809.9,805.7,801.5,797.6,794.8,791.9,789.1,786.0,783.3,780.1,777.3,773.9,771.1,767.8,765.0,761.9,759.1,755.8,752.2,749.2,745.1,741.8,738.1,734.4,730.7,727.3,723.5,719.7,716.0,711.4,707.2,702.9,698.3,692.7,687.0,680.9,674.5,667.5,659.5,651.8,641.9,630.9,618.8,606.1,588.5,583.9,579.1,574.7,570.1,566.0,560.9,556.5,551.7,547.1,541.4,537.3,531.6,527.1,521.3,516.2,511.4,505.5,500.2,492.2,483.9,475.9,468.5,460.6,452.0,407.1,378.6,360.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};
Double_t m_2sigma_combo[358]={300.0,300.0,300.0,300.0,300.0,300.0,300.0,377.0,458.6,479.9,502.7,517.3,531.9,546.4,560.0,573.6,587.0,599.5,607.2,615.3,622.8,630.7,637.2,643.9,649.9,655.0,660.2,665.7,670.0,674.8,679.0,682.9,687.0,691.3,694.9,699.1,702.0,705.3,708.2,710.8,713.8,716.3,719.3,721.6,724.2,726.6,729.0,731.4,733.6,745.3,755.5,765.0,773.8,782.3,790.1,797.5,810.5,826.8,843.9,853.0,858.7,863.9,868.9,874.0,879.0,883.5,887.7,892.2,896.9,901.9,908.5,914.8,920.3,926.3,932.1,937.9,943.8,949.0,953.4,957.5,960.9,964.7,968.2,972.3,975.6,979.4,983.2,986.9,990.4,994.4,997.8,1001.4,1004.2,1006.8,1009.5,1012.2,1014.9,1017.8,1020.2,1022.9,1025.3,1027.9,1030.3,1033.0,1035.8,1037.9,1040.6,1042.8,1045.6,1047.9,1050.3,1052.7,1055.2,1057.3,1059.8,1062.1,1064.6,1066.9,1069.3,1071.7,1074.2,1076.6,1079.1,1081.9,1084.2,1086.6,1089.5,1091.8,1094.2,1094.8,1095.2,1095.8,1096.2,1096.8,1097.2,1097.9,1098.6,1098.9,1099.3,1100.0,1100.3,1101.0,1101.3,1102.0,1102.7,1102.7,1103.3,1103.6,1104.1,1104.7,1105.1,1105.8,1106.2,1106.8,1107.2,1107.9,1108.2,1108.6,1109.3,1109.7,1109.9,1110.5,1111.1,1111.5,1111.9,1112.6,1112.9,1113.5,1113.8,1114.5,1114.9,1115.5,1115.9,1116.3,1116.8,1117.2,1117.8,1118.2,1118.5,952.5,951.5,950.8,950.2,949.5,948.3,947.6,946.9,946.3,946.1,944.5,943.8,943.5,942.5,941.8,941.1,940.0,939.3,938.6,937.6,936.8,936.2,935.4,935.0,933.7,933.1,932.4,931.3,930.6,930.0,928.9,928.6,927.5,926.7,926.2,925.1,924.3,923.7,922.9,921.6,921.0,920.2,919.5,918.6,918.2,917.1,916.3,915.6,914.4,913.9,912.8,908.8,904.3,899.8,893.8,887.7,882.4,876.6,869.9,864.4,859.6,854.0,848.6,845.2,841.7,837.7,834.2,829.6,826.0,822.6,818.6,814.7,810.7,807.0,802.4,798.8,795.9,793.5,790.5,787.4,784.6,782.2,778.8,775.9,773.1,770.5,767.3,764.5,762.2,758.8,756.3,753.4,750.5,747.4,743.8,740.1,737.0,733.4,730.1,727.0,723.9,720.8,718.0,715.0,711.5,708.4,705.2,702.0,699.0,695.2,691.4,687.6,683.7,679.5,675.6,671.0,666.1,660.9,655.7,650.7,643.5,637.0,629.3,620.3,612.0,602.9,590.5,574.6,558.6,541.1,523.4,519.7,516.1,512.5,508.7,505.0,500.8,495.5,490.0,483.8,477.7,473.1,467.3,462.8,456.2,450.2,409.5,389.5,371.5,359.2,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};
Double_t m_expected_lljj[179]={300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,305.1,314.1,324.0,336.1,368.3,392.7,414.3,433.9,452.7,467.7,481.6,495.6,511.3,527.5,543.5,557.3,569.4,580.3,591.7,602.7,614.8,626.6,638.1,649.1,657.8,666.5,674.5,682.2,689.8,697.9,708.0,718.4,729.4,740.1,750.3,756.3,762.3,767.8,773.7,779.1,784.4,789.6,794.9,800.3,806.8,814.0,820.3,827.0,833.1,839.8,846.3,853.4,862.8,871.1,881.2,888.3,896.2,903.8,909.4,915.1,920.7,926.0,931.2,936.7,941.5,946.7,951.6,956.5,961.1,965.3,969.7,974.2,978.8,983.2,987.3,991.7,996.0,999.8,1003.0,1005.5,1008.5,1011.2,1014.1,1016.8,1017.3,1017.9,1018.4,1019.0,1019.5,1020.1,1020.7,1021.2,1021.7,1022.2,1022.8,1023.4,1023.8,1024.5,1024.9,1025.4,1025.8,1026.4,1026.9,1027.4,1027.9,1028.5,1028.9,1029.5,1030.1,1030.7,1030.9,1031.5,1032.1,1032.6,1033.3,1033.5,1034.2,1034.7,1035.2,1035.7,1036.3,1036.7,1037.2,1037.7,1038.3,1038.6,1039.3,1040.0,1040.2,1040.6,1041.1,1041.8,1042.0,1042.7};
Double_t m_observed_lljj[179]={300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,351.5,354.6,357.5,372.0,385.7,398.6,418.8,439.1,456.2,468.1,479.5,491.1,502.4,514.6,526.5,538.2,549.6,584.3,621.1,652.3,662.5,672.4,681.6,691.0,700.0,704.6,709.1,713.5,717.7,721.9,725.9,729.8,733.7,737.4,741.1,744.8,748.3,752.3,756.5,760.7,764.8,768.8,772.8,776.7,780.6,784.4,788.0,791.7,795.4,799.0,806.7,816.2,825.6,835.6,845.6,852.3,856.6,860.8,864.8,868.8,872.9,877.0,881.0,884.5,888.1,891.7,895.5,899.2,1002.5,1005.6,1008.7,1011.9,1015.0,1018.1,1021.1,1024.1,1027.0,1029.9,1032.8,1035.6,1038.5,1041.3,1044.0,1044.5,1045.1,1045.6,1046.2,1046.7,1047.2,1047.8,1048.3,1048.9,1049.4,1049.9,1050.5,1051.0,1051.5,1052.0,1052.5,1053.1,1053.6,1054.1,1054.6,1055.2,1055.7,1056.2,1056.7,1057.2,1057.7,1058.2,1058.8,1059.3,1059.8,1060.3,1060.8,1061.3,1061.8,1062.3,1062.8,1063.3,1063.8,1064.3,1064.8,1065.3,1065.8,1066.3,1066.8,1067.3,1067.8,1068.3,1068.8,1069.3,1069.7};
Double_t m_expected_lvjj[179]={300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,355.0,380.0,417.7,458.1,468.6,479.1,491.3,501.2,510.0,517.7,525.3,533.0,540.1,548.1,555.8,562.4,569.3,575.5,582.0,589.3,595.9,601.4,605.2,609.1,613.0,616.8,620.5,624.5,627.9,631.1,634.7,637.8,641.0,644.3,647.1,659.5,671.4,681.2,690.4,699.1,706.2,712.3,718.3,723.8,729.2,734.0,738.2,742.5,746.8,750.4,753.9,757.7,760.8,763.3,766.3,768.9,771.1,773.8,775.9,777.9,779.8,781.5,782.8,784.0,785.2,786.4,787.6,788.3,789.3,789.7,790.6,790.6,791.1,791.4,791.2,791.4,791.1,790.6,790.6,789.7,789.3,788.3,787.6,786.4,785.2,784.0,782.8,781.5,779.8,777.9,775.9,773.8,771.1,768.9,766.3,763.3,760.8,757.7,753.9,750.4,746.8,742.5,738.2,734.0,729.2,723.8,718.3,712.3,706.2,699.1,690.4,681.2,671.4,659.5,647.1,644.3,641.0,637.8,634.7,631.1,627.9,624.5,620.5,616.8,613.0,609.1,605.2,601.4,595.9,589.3,582.0,575.5,569.3,562.4,555.8,548.1,540.1,533.0,525.3,517.7,510.0,501.2,491.3,479.1,468.6,458.1,417.7,380.0,355.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0};
Double_t m_observed_lvjj[179]={300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,358.4,367.2,376.1,385.1,394.1,451.0,460.1,467.7,475.5,483.9,492.7,501.0,508.9,516.6,524.4,532.3,540.2,548.0,552.3,555.4,558.4,561.4,564.2,567.0,569.8,572.4,575.0,577.5,580.0,582.6,585.1,596.7,610.2,624.1,637.2,649.2,656.1,662.4,668.5,673.7,678.5,683.2,687.6,691.7,695.6,699.3,702.9,706.3,709.6,712.6,715.5,718.2,720.7,723.1,725.2,727.2,729.1,730.8,732.4,733.9,735.2,736.4,737.4,738.3,739.1,739.8,740.3,740.8,741.1,741.3,741.3,741.3,741.1,740.8,740.3,739.8,739.1,738.3,737.4,736.4,735.2,733.9,732.4,730.8,729.1,727.2,725.2,723.1,720.7,718.2,715.5,712.6,709.6,706.3,702.9,699.3,695.6,691.7,687.6,683.2,678.5,673.7,668.5,662.4,656.1,649.2,637.2,624.1,610.2,596.7,585.1,582.6,580.0,577.5,575.0,572.4,569.8,567.0,564.2,561.4,558.4,555.4,552.3,548.0,540.2,532.3,524.4,516.6,508.9,501.0,492.7,483.9,475.5,467.7,460.1,451.0,394.1,385.1,376.1,367.2,358.4,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0};


// INFORMATION PASTING OVER

Double_t beta_valsdub[numbetas*2];
int ind = numbetas;
for (unsigned int ii = 0; ii < numbetas*2; ++ii){
	if (ii < numbetas) beta_valsdub[ii] = beta_vals[ii];
	else {
		ind = ind -1;
		beta_valsdub[ii] = beta_vals[ind];
	}
}

for (unsigned int ii = 0; ii < numbetas; ++ii){
	if (beta_vals[ii] == 0.5) {
	std::cout<<"## ---------------- B = 1/2 Limits ----------------------"<<std::endl;
	std::cout<<"##   lvjj Expected : "<<m_expected_lvjj[ii]<<std::endl;
	std::cout<<"##   lvjj Observed : "<<m_observed_lvjj[ii]<<std::endl;
	std::cout<<"##  combo Expected : "<<m_expected_combo[ii]<<std::endl;
	std::cout<<"##  combo Observed : "<<m_observed_combo[ii]<<std::endl;
	std::cout<<"##   "<<std::endl;
	}
	if (beta_vals[ii] > 0.999) {
	std::cout<<"## ----------------   B = 1 Limits ----------------------"<<std::endl;
	std::cout<<"##   lljj Expected : "<<m_expected_lljj[ii]<<std::endl;
	std::cout<<"##   lljj Observed : "<<m_observed_lljj[ii]<<std::endl;
	std::cout<<"##  combo Expected : "<<m_expected_combo[ii]<<std::endl;
	std::cout<<"## combo Observed : "<<m_observed_combo[ii]<<std::endl;
	std::cout<<"##   "<<std::endl;

	}	

}

 // filename for the final plot (NB: changing the name extension changes the file format)
 string fileName0 = "LQ2Combination.eps";
 string fileName1 = "LQ2Combination.pdf";
 string fileName2 = "LQ2Combination.png";


 // axes labels for the final plot
 string title = ";M_{LQ} (GeV);#beta";

 // integrated luminosity
 string sqrts = "#sqrt{s} = 8 TeV";

 // region excluded by Tevatron limits (1 fb-1)
 Double_t x_excl_D0[11] = {214.39,235.13,254.08,268.12,275.92,283.95,289.08,293.09,295.99,297.10,298.89};
 Double_t y_excl_D0[11] = {0,0.10,0.20,0.30,0.40,0.50,0.60,0.70,0.80,0.90,1};

 // region excluded by ATLAS limits (35 pb-1)
 Double_t x_excl_ATLAS[13] = {200,221.91,243.07,254.12,265.17,287.83,304.68,318.54,331.46,342.88,353.75,363.11,375.47};
 Double_t y_excl_ATLAS[13] = {0.095,0.10,0.126,0.151,0.20,0.30,0.40,0.50,0.60,0.70,0.80,0.90,1.0};
 
 // region excluded by Tevatron limits (5.4 fb-1)
 Double_t x_excl_D0_new[11] = {243.13,275.12,308.18,320.02,325.95,327.96,325.95,320.02,308.18,275.12,243.13};
 Double_t y_excl_D0_new[11] = {0.05,0.10,0.20,0.30,0.40,0.50,0.60,0.70,0.80,0.90,0.95};

//Double_t AtlasComboMass[13] = {250,253.997194950912,278.541374474053,305.539971949509,341.374474053296,352.173913043478,362.973352033661,371.318373071529,385.063113604488,395.371669004208,413.534361851332,421.879382889201,250};
//Double_t AtlasComboBeta[13] ={.1,0.12280701754386,0.14619883040936,0.19493177387914,0.34892787524366,0.39766081871345,0.51851851851852,0.60038986354776,0.74269005847953,0.79727095516569,0.93567251461988,0.99805068226121,1.0};

// Double_t AtlasComboMass[34] = {250.88,284.14,00.0,332.10,354.57,357.86,361.14,380.60,401.43,417.33,437.61,459.81,463.92,477.07,493.79,511.05,521.19,541.75,553.81,565.86,581.49,596.29,613.55,629.45,641.50,647.53,653.56,662.61,667.27,674.67,679.87,683.16,250,250};
// Double_t AtlasComboBeta[34] ={0.04541595925297,0.04626485568761,0.04668930390492,0.04711375212224,0.04711375212224,0.04753820033956,0.04881154499151,0.05772495755518,0.06748726655348,0.07555178268251,0.08446519524618,0.09507640067912,0.09847198641766,0.1213921901528,0.14983022071307,0.17996604414261,0.19821731748727,0.26146010186757,0.29966044142615,0.36332767402377,0.4393039049236,0.51273344651952,0.58828522920204,0.65195246179966,0.69694397283531,0.74363327674024,0.78989813242784,0.87054329371817,0.90789473684211,0.94482173174873,0.97453310696095,1.00042444821732,1.00169779286927,0.04499151103565};

// Double_t CMSComboBeta[165]={     0.034,0.036,0.038,0.04,0.042,0.044,0.046,0.048,0.05,0.052,0.054,0.056,0.058,0.06,0.062,0.064,0.066,0.068,0.07,0.072,0.074,0.076,0.078,0.08,0.082,0.084,0.086,0.088,0.09,0.092,0.094,0.096,0.098,0.1,0.11,0.12,0.13,0.14,0.15,0.16,0.17,0.18,0.19,0.2,0.21,0.22,0.23,0.24,0.25,0.26,0.27,0.28,0.29,0.3,0.31,0.32,0.33,0.34,0.35,0.36,0.37,0.38,0.39,0.4,0.41,0.42,0.43,0.44,0.45,0.46,0.47,0.48,0.49,0.5,0.51,0.52,0.53,0.54,0.56,0.57,0.58,0.59,0.6,0.61,0.62,0.63,0.64,0.65,0.66,0.67,0.68,0.69,0.7,0.71,0.72,0.73,0.74,0.75,0.76,0.77,0.78,0.79,0.8,0.81,0.82,0.83,0.84,0.85,0.86,0.87,0.88,0.89,0.9,0.902,0.904,0.906,0.908,0.91,0.912,0.914,0.916,0.918,0.92,0.922,0.924,0.926,0.928,0.93,0.932,0.934,0.936,0.938,0.94,0.942,0.944,0.946,0.948,0.95,0.952,0.954,0.956,0.958,0.96,0.962,0.964,0.966,0.968,0.97,0.972,0.974,0.976,0.978,0.98,0.982,0.984,0.986,0.988,0.99,0.992,0.994,0.996,0.998,0.9995,1.0,0.034};
// Double_t CMSComboMass[165]={    300.,345.9,356.6,363.4,369.9,376.1,382.1,387.8,393.3,398.7,404.2,409.7,414.9,419.3,424.1,429.0,433.8,438.5,443.0,447.2,451.8,457.2,462.4,467.4,471.9,476.6,481.2,485.6,490.0,494.3,498.5,500.7,502.5,504.3,512.4,520.0,527.0,533.3,539.1,545.0,550.1,561.5,573.1,583.2,592.5,600.2,602.4,604.7,607.0,609.1,611.1,613.1,615.0,617.0,618.7,620.5,622.5,624.0,625.7,627.6,628.9,630.8,632.5,634.0,635.6,637.2,638.8,640.3,641.9,643.5,645.2,646.8,648.1,649.8,653.8,657.2,661.5,665.8,673.7,678.0,682.3,686.5,691.2,695.5,699.9,704.8,710.2,714.8,719.6,725.0,730.0,734.8,740.9,746.8,750.5,754.0,757.9,760.9,764.6,767.6,771.4,774.0,777.9,781.0,784.2,787.1,791.0,794.1,797.3,800.8,804.0,807.6,811.2,811.8,812.2,813.3,814.0,814.4,815.0,815.5,816.2,817.2,817.5,818.4,819.3,819.7,820.5,821.0,821.4,822.8,823.2,823.5,824.5,825.4,825.7,826.3,827.3,828.0,828.5,829.2,829.9,830.8,831.0,831.8,832.8,832.7,834.2,834.0,834.7,835.8,836.1,837.0,838.0,838.4,838.6,839.3,840.5,841.2,841.6,841.6,842.1,843.5,844.0,300,300};

Double_t mass_CMSATLAS[195]={300.0000,319.8520,331.7728,339.8246,351.0135,359.7973,370.1496,379.8745,389.8086,399.8472,409.4675,420.0290,429.8584,439.4788,449.3082,460.0788,469.4900,478.3784,486.8485,494.2728,498.7693,501.8018,508.4942,515.2912,522.0882,527.5257,532.4405,536.7278,541.8517,545.7207,549.0669,551.5766,557.4324,564.9614,573.7452,580.5421,586.1889,592.5676,597.2732,600.0965,602.0833,603.2336,605.7432,608.1483,610.8671,613.0631,615.0499,617.0367,618.7098,621.1149,623.7291,625.9250,627.4936,630.2124,633.2449,635.5454,638.2642,640.7738,642.9698,645.8977,647.6754,649.4530,650.0804,653.4266,656.4591,658.1322,660.8510,665.2429,669.6348,673.9221,677.7912,682.0785,685.5293,689.3983,694.5222,699.1232,704.2471,709.3710,713.7629,719.3050,723.5923,728.2979,730.9122,733.5264,736.8726,741.8919,746.8066,750.7802,755.5904,759.5640,761.1326,764.5833,768.8707,772.1123,773.3671,777.8636,782.9875,786.4382,788.9479,793.4443,798.4636,801.7053,806.2017,810.2799,814.7764,817.1815,823.3510,827.6384,832.6577,836.2130,838.1998,840.9186,841.9643,842.2780,682.8105,678.5232,676.2227,673.7130,670.4714,668.3800,665.6612,663.9881,662.0013,660.7465,658.9688,657.5048,655.9363,653.9495,651.5444,650.1850,647.3616,645.7931,644.0154,642.3423,640.4601,637.8459,635.1271,631.7809,627.0753,624.7748,621.4286,618.1869,613.8996,609.6123,605.6387,602.5016,598.9463,595.3909,591.4173,588.1757,585.2477,582.0061,578.7645,575.0000,571.7584,568.6213,564.7523,561.9289,558.4781,554.8182,552.2040,547.0801,540.8060,534.7410,530.2445,526.0618,521.7745,519.0557,513.0952,506.4028,499.2921,486.7439,476.8098,467.9215,462.6931,459.6606,450.1448,440.5245,429.8584,420.1335,410.4086,397.8604,389.4949,381.5476,373.9141,365.8623,357.3922,352.5820,342.2297,331.9820,323.3028,314.3098,306.6763,300.0000,300.0000};
Double_t beta_CMSATLAS[195]={0.0333,0.0337,0.0345,0.0350,0.0357,0.0376,0.0411,0.0445,0.0478,0.0516,0.0550,0.0593,0.0636,0.0681,0.0724,0.0767,0.0804,0.0841,0.0881,0.0914,0.0934,0.0963,0.1043,0.1135,0.1225,0.1303,0.1382,0.1453,0.1541,0.1613,0.1678,0.1710,0.1756,0.1824,0.1903,0.1966,0.2027,0.2098,0.2154,0.2197,0.2271,0.2328,0.2440,0.2547,0.2679,0.2781,0.2896,0.2992,0.3090,0.3218,0.3360,0.3485,0.3591,0.3764,0.3936,0.4092,0.4252,0.4411,0.4563,0.4722,0.4854,0.4974,0.5005,0.5085,0.5167,0.5215,0.5281,0.5378,0.5489,0.5597,0.5697,0.5786,0.5876,0.5956,0.6076,0.6185,0.6279,0.6383,0.6478,0.6586,0.6668,0.6757,0.6811,0.6874,0.6929,0.7014,0.7093,0.7205,0.7330,0.7441,0.7503,0.7589,0.7727,0.7815,0.7886,0.7994,0.8154,0.8281,0.8350,0.8470,0.8626,0.8724,0.8855,0.8974,0.9094,0.9200,0.9356,0.9498,0.9632,0.9746,0.9823,0.9897,0.9961,1.0000,1.0003,0.9738,0.9595,0.9436,0.9283,0.9173,0.9068,0.8929,0.8755,0.8619,0.8464,0.8311,0.8159,0.7988,0.7801,0.7675,0.7489,0.7355,0.7228,0.7097,0.6968,0.6872,0.6754,0.6631,0.6467,0.6363,0.6235,0.6108,0.5942,0.5763,0.5569,0.5435,0.5275,0.5130,0.4934,0.4765,0.4631,0.4461,0.4307,0.4133,0.3976,0.3811,0.3642,0.3488,0.3314,0.3103,0.2975,0.2815,0.2631,0.2431,0.2288,0.2160,0.2030,0.1960,0.1847,0.1741,0.1611,0.1402,0.1231,0.1083,0.0984,0.0960,0.0914,0.0866,0.0820,0.0772,0.0732,0.0666,0.0630,0.0582,0.0548,0.0515,0.0484,0.0473,0.0470,0.0471,0.0465,0.0467,0.0467,0.0461,0.0333};


Double_t mass_CMS[116]={300.0000,319.8520,331.7728,339.8246,351.0135,359.7973,370.1496,379.8745,389.8086,399.8472,409.4675,420.0290,429.8584,439.4788,449.3082,460.0788,469.4900,478.3784,486.8485,494.2728,498.7693,501.8018,508.4942,515.2912,522.0882,527.5257,532.4405,536.7278,541.8517,545.7207,549.0669,551.5766,557.4324,564.9614,573.7452,580.5421,586.1889,592.5676,597.2732,600.0965,602.0833,603.2336,605.7432,608.1483,610.8671,613.0631,615.0499,617.0367,618.7098,621.1149,623.7291,625.9250,627.4936,630.2124,633.2449,635.5454,638.2642,640.7738,642.9698,645.8977,647.6754,649.4530,650.0804,653.4266,656.4591,658.1322,660.8510,665.2429,669.6348,673.9221,677.7912,682.0785,685.5293,689.3983,694.5222,699.1232,704.2471,709.3710,713.7629,719.3050,723.5923,728.2979,730.9122,733.5264,736.8726,741.8919,746.8066,750.7802,755.5904,759.5640,761.1326,764.5833,768.8707,772.1123,773.3671,777.8636,782.9875,786.4382,788.9479,793.4443,798.4636,801.7053,806.2017,810.2799,814.7764,817.1815,823.3510,827.6384,832.6577,836.2130,838.1998,840.9186,841.9643,842.2780,300.0000,300.0000};
Double_t beta_CMS[116]={0.0333,0.0337,0.0345,0.0350,0.0357,0.0376,0.0411,0.0445,0.0478,0.0516,0.0550,0.0593,0.0636,0.0681,0.0724,0.0767,0.0804,0.0841,0.0881,0.0914,0.0934,0.0963,0.1043,0.1135,0.1225,0.1303,0.1382,0.1453,0.1541,0.1613,0.1678,0.1710,0.1756,0.1824,0.1903,0.1966,0.2027,0.2098,0.2154,0.2197,0.2271,0.2328,0.2440,0.2547,0.2679,0.2781,0.2896,0.2992,0.3090,0.3218,0.3360,0.3485,0.3591,0.3764,0.3936,0.4092,0.4252,0.4411,0.4563,0.4722,0.4854,0.4974,0.5005,0.5085,0.5167,0.5215,0.5281,0.5378,0.5489,0.5597,0.5697,0.5786,0.5876,0.5956,0.6076,0.6185,0.6279,0.6383,0.6478,0.6586,0.6668,0.6757,0.6811,0.6874,0.6929,0.7014,0.7093,0.7205,0.7330,0.7441,0.7503,0.7589,0.7727,0.7815,0.7886,0.7994,0.8154,0.8281,0.8350,0.8470,0.8626,0.8724,0.8855,0.8974,0.9094,0.9200,0.9356,0.9498,0.9632,0.9746,0.9823,0.9897,0.9961,1.0000,1.0000,0.0333};

Double_t mass_ATLAS[82]={300.0000,306.6763,314.3098,323.3028,331.9820,342.2297,352.5820,357.3922,365.8623,373.9141,381.5476,389.4949,397.8604,410.4086,420.1335,429.8584,440.5245,450.1448,459.6606,462.6931,467.9215,476.8098,486.7439,499.2921,506.4028,513.0952,519.0557,521.7745,526.0618,530.2445,534.7410,540.8060,547.0801,552.2040,554.8182,558.4781,561.9289,564.7523,568.6213,571.7584,575.0000,578.7645,582.0061,585.2477,588.1757,591.4173,595.3909,598.9463,602.5016,605.6387,609.6123,613.8996,618.1869,621.4286,624.7748,627.0753,631.7809,635.1271,637.8459,640.4601,642.3423,644.0154,645.7931,647.3616,650.1850,651.5444,653.9495,655.9363,657.5048,658.9688,660.7465,662.0013,663.9881,665.6612,668.3800,670.4714,673.7130,676.2227,678.5232,682.8105,300.0,300.0};
Double_t beta_ATLAS[82]={0.0461,0.0467,0.0467,0.0465,0.0471,0.0470,0.0473,0.0484,0.0515,0.0548,0.0582,0.0630,0.0666,0.0732,0.0772,0.0820,0.0866,0.0914,0.0960,0.0984,0.1083,0.1231,0.1402,0.1611,0.1741,0.1847,0.1960,0.2030,0.2160,0.2288,0.2431,0.2631,0.2815,0.2975,0.3103,0.3314,0.3488,0.3642,0.3811,0.3976,0.4133,0.4307,0.4461,0.4631,0.4765,0.4934,0.5130,0.5275,0.5435,0.5569,0.5763,0.5942,0.6108,0.6235,0.6363,0.6467,0.6631,0.6754,0.6872,0.6968,0.7097,0.7228,0.7355,0.7489,0.7675,0.7801,0.7988,0.8159,0.8311,0.8464,0.8619,0.8755,0.8929,0.9068,0.9173,0.9283,0.9436,0.9595,0.9738,1.0000,1.0,0.0461};






 // turn on/off batch mode
 gROOT->SetBatch(kTRUE);
 // set ROOT style
//  myStyle();
 setTDRStyle();
//  gStyle->SetPadLeftMargin(0.14);
 gROOT->ForceStyle();

 TH2F *bg = new TH2F("bg",title.c_str(), 20, 300., 1350., 100, 0., 1.);
 bg->SetStats(kFALSE);
 bg->SetTitleOffset(1.,"X");
 bg->SetTitleOffset(1.05,"Y");
//  bg->GetXaxis()->SetNdivisions(505);

 TCanvas *c = new TCanvas("c","",800,800);
 c->cd();

 bg->Draw();

 TGraph *gr_excl_D0 = new TGraph(11,x_excl_D0,y_excl_D0);
 gr_excl_D0->SetLineWidth(3);
 gr_excl_D0->SetLineColor(49);
 gr_excl_D0->SetLineStyle(6);
 //gr_excl_D0->Draw("C");

 TPolyLine*gr_excl_ATLAS = new TPolyLine(82,mass_ATLAS,beta_ATLAS,"");
 //gr_excl_ATLAS->SetLineWidth(3);
 gr_excl_ATLAS->SetLineColor(8);
 gr_excl_ATLAS->SetFillColor(8);
 gr_excl_ATLAS->SetFillStyle(3345);


 TPolyLine*gr_excl_CMS = new TPolyLine(116,mass_CMS,beta_CMS,"");
 //gr_excl_CMS->SetLineWidth(3);
 gr_excl_CMS->SetLineColor(14);
 gr_excl_CMS->SetFillColor(14);
 gr_excl_CMS->SetFillStyle(3344);

 TPolyLine*gr_excl_CMSborder = new TPolyLine(195,mass_CMSATLAS,beta_CMSATLAS,"");
 //gr_excl_CMS->SetLineWidth(3);
 gr_excl_CMSborder->SetLineColor(14);
 gr_excl_CMSborder->SetFillColor(14);
 gr_excl_CMSborder->SetFillStyle(3344);

 TGraph *gr_excl_D0_new = new TGraph(11,x_excl_D0_new,y_excl_D0_new);
 gr_excl_D0_new->SetLineWidth(3);
 gr_excl_D0_new->SetLineColor(30);
 gr_excl_D0_new->SetLineStyle(7);
 //gr_excl_D0_new->Draw("C");


// ------------------------------------ LLJJ CURVES  -------------------------------------//
 TPolyLine *beta_vs_m_lljj_observed = new TPolyLine(numbetas, m_observed_lljj, beta_vals);
 TPolyLine *beta_vs_m_lljj_expected = new TPolyLine(numbetas, m_expected_lljj, beta_vals);
 //TPolyLine *beta_vs_m_lljj_observed_shade = new TPolyLine(numbetas*2, m_2sigma_lljj, beta_valsdub);
 
 beta_vs_m_lljj_observed->SetLineWidth(2);
 beta_vs_m_lljj_observed->SetLineColor(kBlue);
 beta_vs_m_lljj_observed->SetLineStyle(1);

 beta_vs_m_lljj_expected->SetLineWidth(2);
 beta_vs_m_lljj_expected->SetLineColor(kBlue);
 beta_vs_m_lljj_expected->SetLineStyle(2);
 
 
 //beta_vs_m_lljj_observed_shade->SetLineWidth(3);
 //beta_vs_m_lljj_observed_shade->SetLineColor(kGreen+2);
 //beta_vs_m_lljj_observed_shade->SetLineStyle(4);
 //beta_vs_m_lljj_observed_shade->SetFillStyle(3425);
 //beta_vs_m_lljj_observed_shade->SetFillColor(kGreen+2);
 //beta_vs_m_lljj_observed_shade->Draw("f");




// ------------------------------------ LVJJ CURVES  -------------------------------------//

 TPolyLine *beta_vs_m_lvjj_observed = new TPolyLine(numbetas, m_observed_lvjj, beta_vals);
 TPolyLine *beta_vs_m_lvjj_expected = new TPolyLine(numbetas, m_expected_lvjj, beta_vals);
 //TPolyLine *beta_vs_m_lvjj_observed_shade = new TPolyLine(numbetas*2, m_2sigma_lvjj, beta_valsdub);
 
 beta_vs_m_lvjj_observed->SetLineWidth(2);
 beta_vs_m_lvjj_observed->SetLineColor(kRed);
 beta_vs_m_lvjj_observed->SetLineStyle(1);
 
 beta_vs_m_lvjj_expected->SetLineWidth(2);
 beta_vs_m_lvjj_expected->SetLineColor(kRed);
 beta_vs_m_lvjj_expected->SetLineStyle(2);
 
 //beta_vs_m_lvjj_observed_shade->SetFillStyle(3452);
 //beta_vs_m_lvjj_observed_shade->SetFillColor(kRed);
 //beta_vs_m_lvjj_observed_shade->Draw("f");




// ------------------------------------ COMBO CURVES  -------------------------------------//

 TPolyLine *beta_vs_m_comb_observed = new TPolyLine(numbetas, m_observed_combo, beta_vals);
 TPolyLine *beta_vs_m_comb_expected = new TPolyLine(numbetas, m_expected_combo, beta_vals);
 TGraph *beta_vs_m_comb_expected_shade2 = new TGraph(numbetas*2, m_2sigma_combo, beta_valsdub);
 TGraph *beta_vs_m_comb_expected_shade1 = new TGraph(numbetas*2, m_1sigma_combo, beta_valsdub);

 
 beta_vs_m_comb_observed->SetLineWidth(4);
 beta_vs_m_comb_observed->SetLineColor(kBlack);
 beta_vs_m_comb_expected->SetLineStyle(1);

 //beta_vs_m_comb_expected_shade->SetLineWidth(1);
 beta_vs_m_comb_expected_shade1->SetFillStyle(1001);
 beta_vs_m_comb_expected_shade1->SetFillColor(kGreen);
 beta_vs_m_comb_expected_shade2->SetFillStyle(1001);
 beta_vs_m_comb_expected_shade2->SetFillColor(kYellow);

 
 beta_vs_m_comb_expected->SetLineWidth(4);
 beta_vs_m_comb_expected->SetLineColor(kBlack);
 beta_vs_m_comb_expected->SetLineStyle(2);

// ------------------------------------ DRAW  -------------------------------------//

 beta_vs_m_comb_expected_shade2->Draw("f");

 beta_vs_m_comb_expected_shade1->Draw("f");

 gr_excl_ATLAS->Draw("L");
 gr_excl_ATLAS->Draw("F");

 gr_excl_CMSborder->Draw("L");
 gr_excl_CMSborder->Draw("F");

 beta_vs_m_lljj_expected->Draw("C");
 beta_vs_m_lvjj_expected->Draw("C");
 beta_vs_m_comb_expected->Draw("C");
 beta_vs_m_lljj_observed->Draw("C");
 beta_vs_m_lvjj_observed->Draw("C");
 beta_vs_m_comb_observed->Draw("C");




 gPad->RedrawAxis();

 TLegend *legend = new TLegend(.64,.15,.93,.44);
 legend->SetBorderSize(1);
 legend->SetFillColor(0);
 //legend->SetFillStyle(0);
 legend->SetTextFont(42);
 legend->SetMargin(0.15);
 legend->SetHeader("95% CL limits");
 legend->AddEntry(beta_vs_m_comb_observed,"CMS #mu#mujj + #mu#nujj (Obs.)","l");
  legend->AddEntry(beta_vs_m_comb_expected,"CMS #mu#mujj + #mu#nujj (Exp.)","l");

 legend->AddEntry(beta_vs_m_lvjj_observed,"CMS #mu#nujj (Obs.)","l");
  legend->AddEntry(beta_vs_m_lvjj_expected,"CMS #mu#nujj (Exp.)","l");

 legend->AddEntry(beta_vs_m_lljj_observed,"CMS #mu#mujj (Obs.)","l");
  legend->AddEntry(beta_vs_m_lljj_expected,"CMS #mu#mujj (Exp.)","l");

 legend->AddEntry(gr_excl_ATLAS,"ATLAS, 7 TeV, 1.03 fb^{-1}","f");
 legend->AddEntry(gr_excl_CMSborder,"CMS, 7 TeV, 5.0 fb^{-1}","f");

 //legend->AddEntry(gr_excl_D0,"D#oslash (Obs.), 1 fb^{-1}","l");

 legend->Draw();

 TLatex l1;
 l1.SetTextAlign(12);
 l1.SetTextFont(42);
 l1.SetNDC();
 l1.SetTextSize(0.04);
 
 // l1.DrawLatex(0.7,0.41,"CMS 2012");
 // l1.DrawLatex(0.7,0.36,sqrts.c_str());

 // l1.DrawLatex(0.7,0.47,"CMS Preliminary");
 // l1.DrawLatex(0.7,0.41,"Preliminary");
 // l1.DrawLatex(0.7,0.36,sqrts.c_str());
 l1.DrawLatex(0.14,0.93,"CMS Preliminary          #sqrt{s} = 8 TeV         19.6 fb^{-1}");

 TLatex l2;
 l2.SetTextAlign(12);
 l2.SetTextFont(42);
 l2.SetNDC();
 l2.SetTextSize(0.04);
 l2.SetTextColor(kBlue);
 l2.SetTextAngle(30);
 l2.DrawLatex(0.25,0.29,"#mu#mujj");
 l2.SetTextColor(kRed);
 l2.SetTextAngle(-20);
 l2.DrawLatex(0.25,0.84,"#mu#nujj");
 l2.SetTextColor(kBlack);
 l2.SetTextAngle(63);
 l2.DrawLatex(0.56,0.43,"#mu#mujj + #mu#nujj");

 // c->SetGridx();
 // c->SetGridy();
 c->SetLogy(0);
 c->SaveAs(fileName0.c_str());
 c->SaveAs(fileName1.c_str());
 c->SaveAs(fileName2.c_str());


 delete legend;
 delete beta_vs_m_lljj_observed;
 delete beta_vs_m_lvjj_observed;
 delete beta_vs_m_comb_observed;
 delete gr_excl_D0;
 delete gr_excl_ATLAS;
 delete gr_excl_D0_new;
 delete bg;
 delete c;
}
Example #17
0
int CompareP()
{
  char wkdir[1000]={"/Volumes/IR1_CPRA_X6/output"};
  TFile *outfile = new TFile("/Volumes/IR1_CPRA_X6/output/pcom.root","recreate");
  char file[21][100];
  double ene[21];
  sprintf(file[0], "001_2.0000"); ene[0] = 2.0000;
  sprintf(file[1], "002_2.0500"); ene[1] = 2.0500;
  sprintf(file[2], "003_2.1000"); ene[2] = 2.1000;
  sprintf(file[3], "004_2.1500"); ene[3] = 2.1500;
  sprintf(file[4], "005_2.1750"); ene[4] = 2.1750;
  sprintf(file[5], "006_2.2000"); ene[5] = 2.2000;
  sprintf(file[6], "007_2.2324"); ene[6] = 2.2324;
  sprintf(file[7], "008_2.3094"); ene[7] = 2.3094;
  sprintf(file[8], "009_2.3864"); ene[8] = 2.3864;
  sprintf(file[9], "010_2.3960"); ene[9] = 2.3960;
  sprintf(file[10],"011_2.5000"); ene[10]= 2.5000;
  sprintf(file[11],"012_2.6444"); ene[11]= 2.6444;
  sprintf(file[12],"013_2.6464"); ene[12]= 2.6464;
  sprintf(file[13],"014_2.7000"); ene[13]= 2.7000;
  sprintf(file[14],"015_2.8000"); ene[14]= 2.8000;
  sprintf(file[15],"016_2.9000"); ene[15]= 2.9000;
  sprintf(file[16],"017_2.9500"); ene[16]= 2.9500;
  sprintf(file[17],"018_2.9810"); ene[17]= 2.9810;
  sprintf(file[18],"019_3.0000"); ene[18]= 3.0000;
  sprintf(file[19],"020_3.0200"); ene[19]= 3.0200;
  sprintf(file[20],"021_3.0800"); ene[20]= 3.0800;
  double mka = 0.493677;
  double mmu = 0.1057;

  double enee[21]={0};
  double pka[21],pkae[21],pka3e[21],pka5e[21];
  double pmu[21],pmue[21],pmu3e[21],pmu5e[21];

  gStyle->SetOptStat(0);
  for (int enei=0; enei<21; enei++){
    char filename[100];
    sprintf(filename,"%s/mcBB_%s.root",wkdir,file[enei]);
    TFile *filei1 = new TFile(filename);
    TH1D *hpee   = (TH1D*)filei1->Get("hpNocut");
    TH2D *h2pee  = (TH2D*)filei1->Get("h2pNocut");
    TH1D *hpeec  = (TH1D*)filei1->Get("hpcutTOF");
    TH2D *h2peec = (TH2D*)filei1->Get("h2pcutTOF");

    sprintf(filename,"%s/mcdimu_%s.root",wkdir,file[enei]);
    TFile *filei2 = new TFile(filename);
    TH1D *hpmu   = (TH1D*)filei2->Get("hpNocut");
    TH2D *h2pmu  = (TH2D*)filei2->Get("h2pNocut");
    TH1D *hpmuc  = (TH1D*)filei2->Get("hpcutTOF");
    TH2D *h2pmuc = (TH2D*)filei2->Get("h2pcutTOF");

    sprintf(filename,"%s/mchad_%s.root",wkdir,file[enei]);
    TFile *filei3 = new TFile(filename);
    TH1D *hpha   = (TH1D*)filei3->Get("hpNocut");
    TH2D *h2pha  = (TH2D*)filei3->Get("h2pNocut");
    TH1D *hphac  = (TH1D*)filei3->Get("hpcutTOF");
    TH2D *h2phac = (TH2D*)filei3->Get("h2pcutTOF");

    sprintf(filename,"%s/KKsel_%03d_myxs.root",wkdir,enei+1);
    TFile *filei4 = new TFile(filename);
    TH1D *hpka   = (TH1D*)filei4->Get("hpNocut");
    TH2D *h2pka  = (TH2D*)filei4->Get("h2pNocut");
    TH1D *hpkac  = (TH1D*)filei4->Get("hpcutTOF");
    TH2D *h2pkac = (TH2D*)filei4->Get("h2pcutTOF");

    TCanvas *c1 = new TCanvas();
    TLegend *legend = new TLegend(0.15, 0.6,0.4,0.85);
    if (hpka!=0) {hpka->SetFillColor(0);hpka->SetLineColor(1);hpka->SetMarkerColor(1);hpka->Draw(); legend->AddEntry(hpka,"p_{K}");} else continue;
    if (hpee!=0) {hpee->SetFillColor(0);hpee->SetLineColor(2);hpee->SetMarkerColor(2);hpee->Draw("same");legend->AddEntry(hpee,"p_{e}");}
    if (hpmu!=0) {hpmu->SetFillColor(0);hpmu->SetLineColor(3);hpmu->SetMarkerColor(3);hpmu->Draw("same");legend->AddEntry(hpmu,"p_{#mu}");}
    if (hpha!=0) {hpha->SetFillColor(0);hpha->SetLineColor(4);hpha->SetMarkerColor(4);hpha->Draw("same");legend->AddEntry(hpha,"p_{had}");}
    legend->Draw();
    
    TCanvas *c3 = new TCanvas();
    TLegend *lgd3 = new TLegend(0.15, 0.6,0.4,0.85);
    if (hpkac!=0) {hpkac->SetFillColor(0);hpkac->SetLineColor(1);hpkac->SetMarkerColor(1);hpkac->Draw(); lgd3->AddEntry(hpkac,"p_{K}");} else continue;
    if (hpeec!=0) {hpeec->SetFillColor(0);hpeec->SetLineColor(2);hpeec->SetMarkerColor(2);hpeec->Draw("same");lgd3->AddEntry(hpeec,"p_{e}");}
    if (hpmuc!=0) {hpmuc->SetFillColor(0);hpmuc->SetLineColor(3);hpmuc->SetMarkerColor(3);hpmuc->Draw("same");lgd3->AddEntry(hpmuc,"p_{#mu}");}
    if (hphac!=0) {hphac->SetFillColor(0);hphac->SetLineColor(4);hphac->SetMarkerColor(4);hphac->Draw("same");lgd3->AddEntry(hphac,"p_{had}");}
    lgd3->Draw();
    
    TCanvas *c2 = new TCanvas();
    TLegend *lgd2 = new TLegend(0.15, 0.6,0.4,0.85);
    if(h2pka!=0){h2pka->SetFillColor(0);h2pka->SetLineColor(1);h2pka->SetMarkerColor(1);h2pka->Draw();lgd2->AddEntry(h2pka,"p_{K}");} else continue;
    if(h2pee!=0){h2pee->SetFillColor(0);h2pee->SetLineColor(2);h2pee->SetMarkerColor(2);h2pee->Draw("same");lgd2->AddEntry(h2pee,"p_{e}");}
    if(h2pmu!=0){h2pmu->SetFillColor(0);h2pmu->SetLineColor(3);h2pmu->SetMarkerColor(3);h2pmu->Draw("same");lgd2->AddEntry(h2pmu,"p_{#mu}");}
    if(h2pha!=0){h2pha->SetFillColor(0);h2pha->SetLineColor(4);h2pha->SetMarkerColor(4);h2pha->Draw("same");lgd2->AddEntry(h2pha,"p_{had}");}
    lgd2->Draw();
    
    TCanvas *c4 = new TCanvas();
    TLegend *lgd4 = new TLegend(0.15, 0.6,0.4,0.85);
    if (h2pkac!=0) {h2pkac->SetFillColor(0);h2pkac->SetLineColor(1);h2pkac->SetMarkerColor(1);h2pkac->Draw(); lgd4->AddEntry(h2pkac,"p_{K}");} else continue;
    if (h2peec!=0) {h2peec->SetFillColor(0);h2peec->SetLineColor(2);h2peec->SetMarkerColor(2);h2peec->Draw("same");lgd4->AddEntry(h2peec,"p_{e}");}
    if (h2pmuc!=0) {h2pmuc->SetFillColor(0);h2pmuc->SetLineColor(3);h2pmuc->SetMarkerColor(3);h2pmuc->Draw("same");lgd4->AddEntry(h2pmuc,"p_{#mu}");}
    if (h2phac!=0) {h2phac->SetFillColor(0);h2phac->SetLineColor(4);h2phac->SetMarkerColor(4);h2phac->Draw("same");lgd4->AddEntry(h2phac,"p_{had}");}
    lgd4->Draw();
    
    sprintf(filename,"%s_1p",file[enei]);
    outfile->WriteTObject(c1,filename);
    sprintf(filename,"%s_2p",file[enei]);
    outfile->WriteTObject(c2,filename);
    sprintf(filename,"%s_1p_cut",file[enei]);
    outfile->WriteTObject(c3,filename);
    sprintf(filename,"%s_2p_cut",file[enei]);
    outfile->WriteTObject(c4,filename);

    double p_ka = sqrt(pow(ene[enei]/2,2)-mka*mka);
    double p_mu = sqrt(pow(ene[enei]/2,2)-mmu*mmu);
    //std::cout<<p_ka<<' '<<p_mu<<std::endl;
    hpka->Fit("gaus","R","",p_ka-0.1,p_ka+0.1);
    hpmu->Fit("gaus","R","",p_mu-0.1,p_mu+0.1);
    pka[enei] = hpka->GetFunction("gaus")->GetParameter(1);
    pkae[enei]= hpka->GetFunction("gaus")->GetParameter(2);
    pka3e[enei]= 3*pkae[enei]/2.6*3;
    pka5e[enei]= 5*pkae[enei]/2.6*3;
    pmu[enei] = hpmu->GetFunction("gaus")->GetParameter(1);
    pmue[enei]= hpmu->GetFunction("gaus")->GetParameter(2);
    pmu3e[enei]= 3*pmue[enei]/2.6*3;
    pmu5e[enei]= 5*pmue[enei]/2.6*3;
    std::cout<<p_ka<<' ' << pka[enei]<<" "<< pkae[enei]<<std::endl;
    std::cout<<p_mu<<' ' << pmu[enei]<<" "<< pmue[enei]<<std::endl;
    
    delete filei1;
    delete filei2;
    delete filei3;
    delete filei4;
    delete c1;
    delete c2;
    delete c3;
    delete c4;
    delete legend;
    delete lgd2;
    delete lgd3;
    delete lgd4;
  }

  new TCanvas();
  TGraphErrors *graph1 = new TGraphErrors(21,ene,pka,enee,pkae);
  graph1->SetFillColor(0);
  graph1->SetMarkerStyle(24);
  TGraphErrors *graph1_1 = new TGraphErrors(21,ene,pka,enee,pkae);
  graph1_1->SetFillColor(3);
  TGraphErrors *graph1_3 = new TGraphErrors(21,ene,pka,enee,pka3e);
  graph1_3->SetFillColor(4);
  TGraphErrors *graph1_5 = new TGraphErrors(21,ene,pka,enee,pka5e);
  graph1_5->SetFillColor(2);
  //graph1->Draw("A3LP");

  TGraphErrors *graph2 = new TGraphErrors(21,ene,pmu,enee,pmue);
  graph2->SetFillColor(0);
  graph2->SetMarkerStyle(25);
  TGraphErrors *graph2_1 = new TGraphErrors(21,ene,pmu,enee,pmue);
  graph2_1->SetFillColor(3);
  TGraphErrors *graph2_3 = new TGraphErrors(21,ene,pmu,enee,pmu3e);
  graph2_3->SetFillColor(4);
  TGraphErrors *graph2_5 = new TGraphErrors(21,ene,pmu,enee,pmu5e);
  graph2_5->SetFillColor(2);
  //graph2->Draw("L3P");
  
  TMultiGraph *mg = new TMultiGraph();
  mg->SetTitle("p of 2 prong process");
  mg->Add(graph1_5);
  mg->Add(graph2_5);
  mg->Add(graph1_3);
  mg->Add(graph2_3);
  mg->Add(graph1_1);
  mg->Add(graph2_1);
  mg->Draw("ALP3");
  mg->GetXaxis()->SetTitle("#sqrt{s} (GeV)");
  mg->GetYaxis()->SetTitle("p (GeV/c)");
  graph1->Draw("PL");
  graph2->Draw("PL");

  TLegend *legend = new TLegend(0.15,0.65,0.45,0.85);
  legend->AddEntry(graph1,"p_{K}");
  legend->AddEntry(graph2,"p_{#mu}");
  legend->AddEntry(graph1_1,"1 #sigma");
  legend->AddEntry(graph1_3,"3 #sigma");
  legend->AddEntry(graph1_5,"5 #sigma");
  legend->SetMargin(0.6);
  legend->Draw();

}
void makePlots()
{
 // **********************************************
 // *            Input parameters                *
 // **********************************************
 // switch to include/exclude sytematics uncertainties 
 bool systematics = true;

 // array of signal efficiencies
 Double_t S_eff[5] = {0.36, 0.43, 0.54, 0.59, 0.66};
//  Double_t S_eff[1] = {0.66}; // for testing of individual mass points  <----------------------------------------------
 // array of relative uncertainties on the signal efficiencies
 Double_t Sigma_S_eff[5] = {0.18, 0.15, 0.12, 0.12, 0.10};
 
 // array of N_background for 100 pb^-1
 Double_t N_bkg_100[5] = {10.35, 6.37, 2.83, 1.27, 1.27};
//  Double_t N_bkg_100[1] = {1.27}; // for testing of individual mass points   <----------------------------------------------
 // array of relative uncertainties on N_background (0.1 = 10%)
 Double_t Sigma_N_bkg[5] = {0.19, 0.23, 0.33, 0.33, 0.33};
//  Double_t Sigma_N_bkg[1] = {0.46}; // for testing of individual mass points   <----------------------------------------------
 
 // arrays of leptoquark masses
 string mass[5] = {"m250", "m300", "m400", "m500", "m600"};
 Double_t m[5] = {250, 300, 400, 500, 600};
 
 // relative uncertainty on the integrated luminosity (0.1 = 10% uncertainty)
 Double_t Sigma_L = 0.1;
 
 // array of theoretical cross-sections for different leptoquark mass
 Double_t xsTh[5] = {9.64045, 3.6081, 0.691125, 0.176217, 0.0538333};
 
 // arrays of beta^2 ranges that contain 95% CL exclusion of different leptoquark mass hypotheses
 Double_t rangeMin[5] = {0.018, 0.03, 0.09, 0.3,  0.9};
 Double_t rangeMax[5] = { 0.03, 0.08,  0.2, 0.55, 1.5};
 Double_t rangeMin_sys[5] = {0.02, 0.04,  0.1, 0.35, 1.0};
 Double_t rangeMax_sys[5] = {0.05, 0.09, 0.25, 0.6 , 1.6};
//  Double_t rangeMin[1] = {0.8}; // for testing of individual mass points   <----------------------------------------------
//  Double_t rangeMax[1] = {1.4}; // for testing of individual mass points   <----------------------------------------------
//  Double_t rangeMin_sys[1] = {0.9}; // for testing of individual mass points   <----------------------------------------------
//  Double_t rangeMax_sys[1] = {1.5}; // for testing of individual mass points   <----------------------------------------------
 
 // number of points used for interpolation
 Int_t NPts = 5;
  
 // filename for the final plot (NB: changing the name extension changes the file format)
 string fileName = "beta2_vs_m_excl.eps";
  
 // axes labels for the final plot 
 string title = ";m (GeV/c^{2});#beta^{2}";

 TH2F *bg = new TH2F("bg",title.c_str(), 100, 200., 650., 100, 0., 1.);
 bg->SetStats(kFALSE);
 bg->SetTitleOffset(1.,"X");
 bg->SetTitleOffset(1.5,"Y");

 TF1 *fit1 = new TF1("fit1","[0]*exp([1]*x)",200,600);
 fit1->SetLineWidth(2);
 fit1->SetLineStyle(7);
 fit1->SetLineColor(kBlue);

 TF1 *fit2 = new TF1("fit2","[0]*exp([1]*x)",200,600);
 fit2->SetLineWidth(2);
 fit2->SetLineColor(kRed);
 
 // region excluded by Tevatron limits
 Double_t x_shaded[14] = {200,205,210,215,220,225,230,235,240,245,250,255,256,200};
 Double_t y_shaded[14] = {0.0267547,0.0380903,0.0531225,0.0736446,0.10221,0.142373,0.194058,0.265091,0.385415,0.520114,0.721552,0.945015,1,1};

 // **********************************************
 // *  Don't change anything below this point!   *
 // **********************************************
 
  // turn on/off batch mode
 gROOT->SetBatch(kTRUE);
 // set ROOT style
 style();
 
 TCanvas *c = new TCanvas("c","",800,800);
 c->cd();

 bg->Draw();
 
 TGraph *grexcl = new TGraph(14,x_shaded,y_shaded);
 grexcl->SetFillColor(kGray+1);
 grexcl->Draw("f");

 Int_t size = sizeof(S_eff)/sizeof(*S_eff);

 // array of minimum beta^2 values for 95% CL exclusion
//  Double_t beta2[size];
 Double_t beta2[5] = {0.0246067, 0.0460278, 0.146584, 0.429775, 1.24257};
//  Double_t beta2_sys[size]; // with systematics included
 Double_t beta2_sys[5] = {0.031345, 0.0550194, 0.16532, 0.467803, 1.33682}; // with systematics included
 
//  for(Int_t i = 0; i < size; i++){
//   
//   beta2[i] = beta2_for_exclusion(NPts, xsTh[i], rangeMin[i], rangeMax[i], 0, S_eff[i], 0, N_bkg_100[i], 0, mass[i]);
//   if(systematics) beta2_sys[i] = beta2_for_exclusion(NPts, xsTh[i], rangeMin_sys[i], rangeMax_sys[i], Sigma_L, S_eff[i], Sigma_S_eff[i], N_bkg_100[i], Sigma_N_bkg[i], mass[i]);
//  }

 TGraph *beta2_vs_m = new TGraph(size, m, beta2);
 beta2_vs_m->SetLineWidth(2);
 beta2_vs_m->SetLineStyle(7);
 beta2_vs_m->SetLineColor(kBlue);
 beta2_vs_m->SetMarkerSize(.9);
 beta2_vs_m->SetMarkerStyle(22);
 beta2_vs_m->SetMarkerColor(kBlue); 
 beta2_vs_m->Fit("fit1");
 fit1->SetRange(200,600);

 TGraph *beta2_vs_m_sys = new TGraph(size, m, beta2_sys);
 beta2_vs_m_sys->SetLineWidth(2);
 beta2_vs_m_sys->SetLineColor(kRed);
 beta2_vs_m_sys->SetMarkerSize(.9);
 beta2_vs_m_sys->SetMarkerStyle(21);
 beta2_vs_m_sys->SetMarkerColor(kRed); 
 if(systematics) beta2_vs_m_sys->Fit("fit2");
 if(systematics) fit2->SetRange(200,600);
  
 const Int_t n = 21;
 Double_t x[n], ymin[n], ymin_sys[n], ymax[n];
 for(Int_t i=0;i<n;i++) {
   x[i] = 200+20*i;
   ymin[i] = fit1->Eval(x[i]);
   if(systematics) ymin_sys[i] = fit2->Eval(x[i]); else ymin_sys[i] = fit1->Eval(x[i]);
   ymax[i] = 1;
 }
 TGraph *grshade = new TGraph(2*n);
 TGraph *grshade_sys = new TGraph(2*n);
 for(Int_t i=0;i<n;i++) {
    grshade->SetPoint(i,x[i],ymax[i]);
    grshade->SetPoint(n+i,x[n-i-1],ymin[n-i-1]);
    grshade_sys->SetPoint(i,x[i],ymax[i]);
    grshade_sys->SetPoint(n+i,x[n-i-1],ymin_sys[n-i-1]);
 }
 grshade->SetFillStyle(3005);
 grshade->SetFillColor(kBlue);
 grshade->Draw("f");
 grshade_sys->SetFillStyle(3004);
 grshade_sys->SetFillColor(kRed);
 grshade_sys->Draw("f");
 
 gPad->RedrawAxis();
 
 beta2_vs_m->Draw("P");
 fit1->Draw("same");
 if(systematics) beta2_vs_m_sys->Draw("P");
 if(systematics) fit2->Draw("same");
 
 TLegend *legend = new TLegend(.25,.68,.7,.85);
 legend->SetBorderSize(1);
 legend->SetFillColor(0);
 //legend->SetFillStyle(0);
 legend->SetMargin(0.2);
 legend->SetHeader("LQ #rightarrow eq");
 legend->AddEntry(beta2_vs_m_sys,"95% C.L. (with sys. unc.)","lp");
 legend->AddEntry(beta2_vs_m,"95% C.L. (no sys. unc.)","lp");
 if(systematics) legend->Draw();

 TLatex l1;
 l1.SetTextAlign(12);
 l1.SetTextSize(0.04);
 l1.SetTextFont(62);
 l1.SetNDC();
 l1.DrawLatex(0.6,0.24,"CMS Preliminary");

 TLatex l2;
 l2.SetTextAlign(12);
 l2.SetTextSize(0.04);
 l2.SetTextFont(62);
 l2.SetNDC();
 l2.DrawLatex(0.6,0.15,"#intLdt=100 pb^{-1}");

 c->SetGridx();
 c->SetGridy();
 c->SaveAs(fileName.c_str());

//  string name, extension;
//  size_t pos = fileName.find(".");
// 
//  name = fileName.substr(0,pos);
//  extension = fileName.substr(pos);
// 
//  c->SetLogy();
//  c->SaveAs((name + "_log" + extension).c_str());
 
 delete fit1;
 delete fit2;
 delete grexcl;
 delete grshade;
 delete grshade_sys;
 delete legend;
 delete beta2_vs_m;
 delete beta2_vs_m_sys;
 delete bg;
 delete c;
}
Example #19
0
void alicePlots(){
    
    TFile* alice = new TFile("~/Downloads/HEPData-ins1288320-v1-root.root");
    alice->cd("Table 16");
    TGraph* aliceData = Graph1D_y1;
    TH1F* hist = Hist1D_y1;
    TH1F* stat = Hist1D_y1_e1;
    TH1F* syst = Hist1D_y1_e2;
    TGraphAsymmErrors* graph2 = (TGraphAsymmErrors*)aliceData->Clone("graph2");

    Int_t numPts = aliceData->GetN();
    Double_t x, y;
    for(int i = 0; i<numPts; i++){
        aliceData->GetPoint(i, x, y);
        aliceData->SetPoint(i, x, (y - 0.89581));
        graph2->SetPoint(i, x, (y- 0.89581));
        hist->SetBinContent(i+1, hist->GetBinContent(i+1) - 0.89581);
        hist->SetBinError(i+1, stat->GetBinContent(i+1));
        graph2->SetPointEXhigh(i, 0.1);
        graph2->SetPointEXlow(i, 0.1);
    }

    graph2->SetLineColor(kBlue-10);
    graph2->SetLineWidth(2);
    graph2->SetMarkerColor(kBlue-10);
    graph2->SetFillColor(kBlue-10);
    hist->SetLineColor(kBlue-2);
    hist->SetLineWidth(2);

    aliceData->SetTitle("");
    aliceData->GetYaxis()->SetTitle("Mass - Vacuum Mass (GeV/c^{2})");
    aliceData->GetYaxis()->SetTitleSize(0.06);
    aliceData->GetYaxis()->SetLabelSize(0.04);
    aliceData->GetYaxis()->SetTitleOffset(1.65);
    aliceData->GetYaxis()->SetTitleFont(42);
    aliceData->GetYaxis()->SetLabelFont(42);
    aliceData->GetXaxis()->SetTitle("p_{T} (GeV/c)");
    aliceData->GetXaxis()->SetTitleSize(0.06);
    aliceData->GetXaxis()->SetLabelSize(0.05);
    aliceData->GetXaxis()->SetTitleFont(42);
    aliceData->GetXaxis()->SetLabelFont(42);
    aliceData->SetMarkerStyle(29);
    aliceData->SetMarkerSize(2.5);
    aliceData->SetMarkerColor(kBlue-2);
    aliceData->SetLineColor(kBlue-2);

    aliceData->GetYaxis()->SetRangeUser(-0.02, 0.015);
    aliceData->GetXaxis()->SetRangeUser(0, 5);

    TFile* phsd = new TFile("~/utaustin/resonancefits/finalplotting/20170721_KKbarAdded2_fixedwidth42_recon_pf100_scaled_error05.root");
    TH1D* mass = phsd->Get("kstar0mass");
    mass->SetName("mass");
    mass->SetMarkerStyle(26);
    mass->SetMarkerSize(2.5);
    mass->SetMarkerColor(2);
    mass->SetLineColor(2);

    TF1* line = new TF1("line", "[0]", 0.0, 5.0);
    line->SetParameter(0, 0.0);
    line->SetLineColor(1);
    line->SetLineStyle(7);
    line->SetLineWidth(3);

    for(int j = 0; j<mass->GetNbinsX(); j++){
        mass->SetBinContent(j+1, (mass->GetBinContent(j+1) - 0.892));
    }


    TFile* phsd2 = new TFile("~/utaustin/resonancefits/finalplotting/20170616_KKbarAdded2_fixedwidth_recon_pf100_scaled_error05.root");
    TH1D* mass2 = phsd2->Get("kstar0mass");
    mass2->SetName("mass2");
    mass2->SetMarkerStyle(22);
    mass2->SetMarkerSize(2.5);
    mass2->SetMarkerColor(2);
    mass2->SetLineColor(2);
    for(int j = 0; j<mass2->GetNbinsX(); j++){
        mass2->SetBinContent(j+1, (mass2->GetBinContent(j+1) - 0.892));
    }



    TExec *exec1 = new TExec("exec1", "gStyle->SetErrorX(0.1)");
    TExec *exec2 = new TExec("exec2", "gStyle->SetErrorX(0.5)");
    
    TCanvas *c = new TCanvas ("c", "c", 50, 50, 650, 600);
    c->cd()->SetMargin(0.1997, 0.0369, 0.1396, 0.0681);
    aliceData->Draw("APX");
    //exec1->Draw();
    graph2->Draw("SAME P2");
    //exec2->Draw();
    hist->Draw("SAME E1");
    line->Draw("SAME");
    mass2->Draw("SAME P E1");
    mass->Draw("SAME P E1");
    aliceData->Draw("SAME PX");
    

    TLegend* legend = new TLegend(0.5836, 0.1815, 0.9489, 0.3438);
    legend->SetMargin(0.2);
    legend->SetTextSizePixels(20);
    legend->AddEntry(aliceData, "ALICE data, 0-20%", "p");
    legend->AddEntry(mass2, "Fit IV to PHSD: w in-med", "p");
    legend->AddEntry(mass, "Fit IV to PHSD: w/o in-med", "p");
    legend->Draw("SAME"); 
  
    TPaveText* text = new TPaveText(0.2554, 0.7243, 0.6006, 0.9162, "NDC");
    text->AddText("(K*^{0} + #bar{K}*^{0})");
    text->AddText("Pb-Pb #sqrt{s_{NN}} = 2.76 TeV");
    text->GetLine(0)->SetTextSizePixels(36);
    text->GetLine(1)->SetTextSizePixels(24);
    text->SetTextFont(42);
    text->SetBorderSize(0);
    text->SetFillStyle(0);
    text->Draw();
}
Example #20
0
void makePlots (string configFilePath){

  if (( nHistList % inputRootFile.size() == 0 )) 
    {
      for (int i=0; i<numHistos; i++) 
        {
	 
          TCanvas *c = new TCanvas(theHistNameStrings.at(i).c_str(), "", 81,58,500,602);
 
          TH1* h_mc;        // histograms for MC
          TH1* h_mc_clone;  // histograms for MC 
          TH1* h_data;      // histogram to store data points 
	  TH1* h_data_clone;
          TLegend *legend = new TLegend(0.2, 0.85-.035*inputLegend.size(), 0.5, 0.90,NULL,"brNDC");
          int whichHisto = 0;
	  
          for (int j=1;j<inputRootFile.size();j++)
	    {
	      
	      whichHisto=j*numHistos; 
	      
	      int a = 0;
	      bool foundHisto = false;
              
	      if (theHistNameStrings.at(i) == theHistNameStrings.at(i+whichHisto)) 
		{
		  foundHisto=true; 
		  a=i;
		}
	      
	      else 
		{
		  for (a = 0; a < numHistos; a++)
		    {
		      if (theHistNameStrings.at(i) == theHistNameStrings.at(a+whichHisto))
			{
			  foundHisto = true;
			  break;
			}
		    }
		}
	      //-----------------------------------------------------------
              
	      string hist2name = listHistos->At(a+whichHisto)->GetName();
	      if (foundHisto == true)
		{
                  h_data = (TH1*)listHistos->At(i);
                  h_data->SetMarkerStyle(inputMarkerStyle.at(0));
                  h_data = SetStyleh(h_data);
                  h_data->Sumw2();
                  int thelineStyle = inputSetLineStyle.at(j);
                  int thelineWidth = inputSetLineWidth.at(j);
                  int setcolor = inputColor.at(j);
                  int marker   = inputMarkerStyle.at(j);
                  h_data->SetMarkerColor(inputColor.at(0));
                  h_data->SetLineColor(inputColor.at(0));
                  if (j == 1) 
                    { 
		       if ( h_data->IsA()->InheritsFrom( "TH2" ) ) {
			 //n.b. that ProfileX will do nothing if the
			 //name you choose is alreayd taken!  so each
			 //profileX needs a unique name
			 TString profileName = TString::Format("%s_data_pfx",h_data->GetName());
			 TProfile *dataProf = ((TH2*)h_data)->ProfileX(profileName.Data());
			 dataProf->SetMinimum(h_data->GetMinimum()); //min/max values were stored in the original hist
			 dataProf->SetMaximum(h_data->GetMaximum());
			 dataProf->Draw("");
			 
			 //profileX cretaes a clone, so no need to
			 //clone again here.  Need to set the hist
			 //name so root doesn't complain
			 TString cloneName = TString::Format("%s_data_pfx_clone",h_data->GetName());
			 TString cloneName2 = TString::Format("%s_data_pfx_clone_px",h_data->GetName());
			 h_data_clone = ((TH2*)h_data)->ProfileX(cloneName.Data())->ProjectionX(cloneName2.Data());
		       }
		       else { //1d case
                         Float_t ymaxc = gPad->GetUymax();
                         //h_data->SetMaximum(ymaxc+0.15*ymaxc);
			 h_data->Draw("ep1");
			 h_data_clone = (TH1*)h_data->Clone();
		       }
                       //h_data->SetLineColor(1);
                       h_data->SetLineStyle(thelineStyle);
                       h_data->SetLineWidth(thelineWidth);
                       float rms_data = h_data->GetRMS();
                       float mean_data = h_data->GetMean();
                       std::stringstream legend_data;
                       legend_data.str("");
                       legend_data << inputLegend.at(0).c_str() << ": mean=" << setprecision(3)
                                   <<mean_data <<", rms=" << setprecision(3) <<rms_data<< endl;
                       legend->AddEntry(h_data,legend_data.str().c_str(), "lep");

                    }
		  h_mc = (TH1*)listHistos->At(a+whichHisto);
                  h_mc = SetStyleh(h_mc);
		  h_mc->SetName(hist2name.c_str());
                  //cout<<"NAME "<<h_mc->GetName()<<endl;
		  // Style
                  
		  string processlegend = (inputLegend.at(j)).c_str();
 
		  h_mc->SetLineStyle(thelineStyle);
		  h_mc->SetLineWidth(thelineWidth);
		  h_mc->SetLineColor(setcolor);
                  h_mc->SetMarkerStyle(marker);
                  h_mc->SetMarkerColor(setcolor);                 
 
                  string processlegend = (inputLegend.at(j)).c_str(); 

		  if ( h_mc->IsA()->InheritsFrom( "TH2" ) ) {
		    TString profileName = TString::Format("%s_mc_pfx", h_mc->GetName());
		    ((TH2*)h_mc)->ProfileX(profileName.Data())->Draw("SAME");
		    //profileX cretaes a clone, so no need to
		    //clone again here.  Need to set the hist
		    //name so root doesn't complain
		    TString cloneName = TString::Format("%s_mc_pfx_clone",h_mc->GetName());
		    TString cloneName2 = TString::Format("%s_mc_pfx_clone_px",h_mc->GetName());
		    h_mc_clone = ((TH2*)h_mc)->ProfileX(cloneName.Data())->ProjectionX(cloneName2.Data());
		  } else { //1d case
                    Float_t ymaxc = gPad->GetUymax();
                    h_mc->SetMaximum(ymaxc+0.15*ymaxc);
		    h_mc->Draw("epsame");
		    h_mc_clone = (TH1*)h_mc->Clone();
		  }
                  h_mc_clone->SetMarkerStyle(marker);
                  h_mc_clone->SetMarkerColor(setcolor);
                  float rms_mc = h_mc->GetRMS();
                  float mean_mc = h_mc->GetMean();
		  std::stringstream legend_mc;
                  legend_mc.str("");
                  legend_mc << processlegend.c_str() << " - "<< "mean: " << setprecision(3)
                              <<mean_mc <<" , rms: " << setprecision(3) <<rms_mc<< endl;
                  legend->AddEntry(h_mc, legend_mc.str().c_str(), "lep"); 
		}// close if (foundHisto)
 
	      legend->SetTextFont(42);
              legend->SetTextSize(.04);
              legend->SetMargin(0.15);
              legend->SetLineColor(1);
              legend->SetLineStyle(1);
              legend->SetLineWidth(1);
              legend->SetFillColor(0);
              legend->SetFillStyle(0);
              legend->SetBorderSize(0);
              legend->SetFillColor(kWhite);
              legend->Draw();
 
	      c->cd();
 	      
              if (j == 1)
                {
	           float startxbin = h_data_clone->GetXaxis()->GetBinWidth(h_data_clone->GetXaxis()->GetFirst()) * 
		      (h_data_clone->GetXaxis()->GetFirst() - 1);
	           float lastxbin  = h_data_clone->GetXaxis()->GetBinCenter(h_data_clone->GetXaxis()->GetNbins());
	      
	            double x1 = 0;
	            double x2 = lastxbin + h_data_clone->GetXaxis()->GetBinWidth(h_data_clone->GetXaxis()->GetNbins())/2.;
	      
	            if (h_data_clone->GetXaxis()->GetBinCenter(0) <= 0)
		        x1 = h_data_clone->GetXaxis()->GetBinCenter(0) + h_data_clone->GetXaxis()->GetBinWidth(0)/2. + startxbin;
	            else 
		        x1 = h_data_clone->GetXaxis()->GetBinCenter(0) - h_data_clone->GetXaxis()->GetBinWidth(0)/2. - startxbin;
	        } 
	  
	    } // close for loop inputRootFile
	  
	  TFile *hfile = (TFile*)gROOT->FindObject(HistosOutputRootFile.c_str());
	  if (hfile) {hfile->Close();}
	  hfile = new TFile(HistosOutputRootFile.c_str(),"UPDATE");

          for (int o = 0; o < inputHistoName.size(); o++)
             {
                if ( c->GetName() == inputHistoName.at(o) )
                  {
                     string save = configFilePath+"/"+inputHistoName.at(o)+".pdf";  
                     c->SaveAs(save.c_str());
                     c->Write();    
                     break;
                  }
             }

	  hfile->Close();
          c->Close();
	  
	}  // close foor loop numHistos     
      
    } // close if numHistos % inputRootFile.size() == 0
} // close  makePlots function
void makePlots()
{
 // **********************************************
 // *            Input parameters                *
 // **********************************************
 // switch to include/exclude sytematics uncertainties 
 bool plot10TeV = true;
 bool plot7TeV = false;

 // array of N_signal for 100 pb^-1
 Double_t N_sig_100[5] = {359.39, 163.37, 40.41, 11.56, 4.04};
 Double_t N_sig_STRL_100[5] = {123.12, 53.105, 11.716, 3.179, 0.888};  // numbers rescaled using Stirling plot
 
 // array of N_background for 100 pb^-1
 Double_t N_bkg_100[5] = {10.35, 6.37, 2.83, 1.27, 1.27};
 Double_t N_bkg_STRL_100[5] = {4.068, 1.937, 0.48, 0.2001, 0.2001}; // numbers rescaled using Stirling plot
 
 // arrays of leptoquark masses
 string mass[5] = {"m250", "m300", "m400", "m500", "m600"};
 Double_t m[5] = {250, 300, 400, 500, 600};
 
 // arrays of beta^2 ranges that contain 5 sigma significance for different leptoquark masses
 Double_t rangeMin[5] = {0.03,  0.05,  0.15,  0.4, 1.4};
 Double_t rangeMax[5] = {0.07, 0.125,  0.38, 1.05, 2.9};
 Double_t rangeMin_7TeV[5] = {0.08,  0.1,  0.45,  1.3, 4.0};
 Double_t rangeMax_7TeV[5] = {0.15, 0.3,  0.7, 2.3, 8.0};
 Double_t rangeMin_sys[5] = {0.04, 0.07,  0.2, 0.5, 1.6};
 Double_t rangeMax_sys[5] = {0.08, 0.16, 0.48, 1.3, 3.6};
 
 // number of points used for interpolation
 Int_t NPts = 10;
  
 // filename for the final plot (NB: changing the name extension changes the file format)
 string fileName = "beta_vs_m.eps";
 if (plot10TeV && !plot7TeV) fileName = "10TeV_beta_vs_m.eps";
 else if (!plot10TeV && plot7TeV) fileName = "7TeV_beta_vs_m.eps";
 
 // axes labels for the final plot 
 string title = ";m (GeV/c^{2});#beta";

 TH2F *bg = new TH2F("bg",title.c_str(), 100, 200., 550., 100, 0., 1.);
 bg->SetStats(kFALSE);
 bg->SetTitleOffset(1.,"X");
 bg->SetTitleOffset(1.5,"Y");
 
 TF1 *fit1 = new TF1("fit1","[0]+[1]*x+[2]*pow(x,2)",200,600);
 TF1 *fit2 = new TF1("fit2","[0]+[1]*x+[2]*pow(x,2)",200,600);

 // regions excluded by Tevatron limits
 Double_t x_shaded[14] = {200,205,210,215,220,225,230,235,240,245,250,255,256,200};
 Double_t y_shaded[14] = {sqrt(0.0267547),sqrt(0.0380903),sqrt(0.0531225),sqrt(0.0736446),sqrt(0.10221),sqrt(0.142373),sqrt(0.194058),sqrt(0.265091),sqrt(0.385415),sqrt(0.520114),sqrt(0.721552),sqrt(0.945015),sqrt(1),sqrt(1)};  // 250 pb-1
 Double_t NEW_x_shaded[14] = {216,220,225,231,235,254,268,276,284,289,293,296,297,299};
 Double_t NEW_y_shaded[14] = {0.02,0.04,0.06,0.08,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1};  // 1 fb-1

 // **********************************************
 // *  Don't change anything below this point!   *
 // **********************************************
 
  // turn on/off batch mode
 gROOT->SetBatch(kTRUE);
 // set ROOT style
 style();
 
 TCanvas *c = new TCanvas("c","",800,800);
 c->cd();

 bg->Draw();
 
 TGraph *grshade = new TGraph(14,x_shaded,y_shaded);
 grshade->SetFillColor(kGray+1);
 grshade->Draw("f");
 TGraph *NEWexcl = new TGraph(14,NEW_x_shaded,NEW_y_shaded);
 NEWexcl->SetLineStyle(6);
 NEWexcl->SetLineWidth(3);
 NEWexcl->Draw("C");
 
 gPad->RedrawAxis();

 Int_t size = sizeof(N_sig_100)/sizeof(*N_sig_100);

 // array of minimum beta^2 values for 5 sigma significance
 Double_t beta2[size];
 Double_t beta2_STRL[size];
 
 for(Int_t i = 0; i < size; i++){
  
  beta2[i] = sqrt(beta2_for_5sigma(NPts, rangeMin[i], rangeMax[i], N_sig_100[i], N_bkg_100[i], 0, mass[i]));
  beta2_STRL[i] = sqrt(beta2_for_5sigma(NPts, rangeMin_7TeV[i], rangeMax_7TeV[i], N_sig_STRL_100[i], N_bkg_STRL_100[i], 0, mass[i]));
 }

 Double_t beta2_log[size];
 Double_t beta2_STRL_log[size];
 
 for(Int_t i=0; i<size; i++){
   beta2_log[i] = log(beta2[i]);
   beta2_STRL_log[i] = log(beta2_STRL[i]);
 }

 TGraph *beta2_vs_m = new TGraph(size, m, beta2);
 TGraph *beta2_vs_m_fit = new TGraph(size, m, beta2_log);
 beta2_vs_m->SetLineWidth(2);
 beta2_vs_m->SetLineStyle(7);
 beta2_vs_m->SetLineColor(kBlue);
 beta2_vs_m->SetMarkerSize(.9);
 beta2_vs_m->SetMarkerStyle(22);
 beta2_vs_m->SetMarkerColor(kBlue);
 if (plot10TeV) beta2_vs_m->Draw("P"); 
 beta2_vs_m_fit->Fit("fit1");
 TF1 *final1 = new TF1("final1","exp(fit1)",200,600);
 final1->SetLineWidth(2);
 final1->SetLineStyle(7);
 final1->SetLineColor(kBlue);
 final1->SetRange(200,600);
 if (plot10TeV) final1->Draw("same");

 TGraph *beta2_STRL_vs_m = new TGraph(size, m, beta2_STRL);
 TGraph *beta2_STRL_vs_m_fit = new TGraph(size, m, beta2_STRL_log);
 beta2_STRL_vs_m->SetLineWidth(2);
 beta2_STRL_vs_m->SetLineStyle(7);
 beta2_STRL_vs_m->SetLineColor(kRed);
 beta2_STRL_vs_m->SetMarkerSize(.9);
 beta2_STRL_vs_m->SetMarkerStyle(22);
 beta2_STRL_vs_m->SetMarkerColor(kRed);
 if (plot7TeV) beta2_STRL_vs_m->Draw("P"); 
 beta2_STRL_vs_m_fit->Fit("fit2");
 TF1 *final2 = new TF1("final2","exp(fit2)",200,600);
 final2->SetLineWidth(2);
 final2->SetLineStyle(7);
 final2->SetLineColor(kRed);
 final2->SetRange(200,600);
 if (plot7TeV) final2->Draw("same");
 
 TLegend *legend = new TLegend(.14,.65,.54,.85);
 legend->SetBorderSize(1);
 legend->SetFillColor(0);
 legend->SetMargin(0.2);
 legend->SetHeader("LQ #rightarrow eq");
 legend->AddEntry(grshade,"Tevatron exclusion (250 pb^{-1})","f");
 legend->AddEntry(NEWexcl,"Tevatron exclusion (1 fb^{-1})","l");
 if (plot10TeV) legend->AddEntry(beta2_vs_m,"5#sigma_{S_{cP}} (no sys. unc.)","lp");
 if (plot7TeV) legend->AddEntry(beta2_STRL_vs_m,"5#sigma_{S_{cP}} (no sys. unc.)","lp");
 legend->Draw();

 TLatex l1;
 l1.SetTextAlign(12);
 l1.SetTextSize(0.04);
 l1.SetTextFont(62);
 l1.SetNDC();
 l1.DrawLatex(0.6,0.34,"CMS Preliminary");

 TLatex l2;
 l2.SetTextAlign(12);
 l2.SetTextSize(0.04);
 l2.SetTextFont(62);
 l2.SetNDC();
 l2.DrawLatex(0.6,0.25,"#intLdt=100 pb^{-1}");

 if (plot7TeV){
 TLatex l3;
 l3.SetTextAlign(12);
 l3.SetTextSize(0.035);
 l3.SetTextFont(62);
 l3.SetNDC();
 l3.DrawLatex(0.4,0.16,"EXO-08-010 scaled to #sqrt{s} = 7 TeV");
 }

 c->SetGridx();
 c->SetGridy();
 c->SaveAs(fileName.c_str());

 delete final1;
 delete final2;
 delete fit1;
 delete fit2;
 delete grshade;
 delete legend;
 delete beta2_vs_m;
 delete beta2_vs_m_fit;
 delete bg;
 delete c;
}
void zlljets_ZpT_recoGenAna(const string fmumuName = "zmumujets_resoResp_noSkim_light.root", const string feeName = "zeejets_resoResp_noSkim_light.root", const char* suffix = "") {

  TH1::SetDefaultSumw2();   

  string plotDirectoryPath = "/cmshome/ciprianim/CMSSW721/pdfsFromAnalysis/plots/ZtoLLSamples/ZpTAnalysis/";
  //string plotDirectoryPath = "./tmpPlots/";  used when working in my pc
  string plotFileExtension = ".pdf";

  // index 0 of array is for muons, index 1 is for electrons, thus recoZpt[0] refers to Z->mumu ((maybe it will be better to change it)

  vector<string> fileName;
  fileName.push_back(fmumuName);
  fileName.push_back(feeName);

  vector<string> sample;
  sample.push_back("Z(#mu#mu)+jets");
  sample.push_back("Z(ee)+jets");

  vector<TH1D*> hZpTreco;
  vector<TH1D*> hZpTgen;
  vector<TH1D*> hZpTrecoGenRatio;
  vector<TH1D*> hZpTrecoGenRatio_pdf;

  Int_t nFiles = (Int_t)fileName.size();
  Int_t histColor[] = {kBlue,kOrange,kRed,kGreen};

  Double_t zptStart = 400.0;
  Double_t zptEnd = 800.0;
  TH1D *HZtoLLPt_RecoGenRatio_pdf_inRange[2];

  for(Int_t i = 0; i < 2; i++) {
	
    HZtoLLPt_RecoGenRatio_pdf_inRange[i] = new TH1D(Form("HZtoLLPt_RecoGenRatio_pdf_%d_Zpt%2.0lfTo%2.0lf",i+1,zptStart,zptEnd),"",100,0.5,1.5);

  }

  for(Int_t i = 0; i < nFiles; i++) {

    cout<<"fileName : "<<fileName[i]<<endl;

    TFile* f = TFile::Open(fileName[i].c_str(),"READ");
    
    if (!f || !f->IsOpen()) {

      cout<<"*******************************"<<endl;
      cout<<"Error opening file \""<<fileName[i]<<"\".\nApplication will be terminated."<<endl;
      cout<<"*******************************"<<endl;
      exit(EXIT_FAILURE);

    }

    hZpTreco.push_back((TH1D*)f->Get("HZtoLLRecoPt"));
    hZpTgen.push_back((TH1D*)f->Get("HZtoLLGenPt"));
    hZpTrecoGenRatio.push_back((TH1D*)f->Get("HZtoLLPt_RecoGenRatio"));
    hZpTrecoGenRatio_pdf.push_back((TH1D*)f->Get("HZtoLLPt_RecoGenRatio_pdf"));

    if ( !(hZpTreco[i] && hZpTgen[i] && hZpTrecoGenRatio[i] && hZpTrecoGenRatio_pdf[i] ) ) {

      cout << "Error: could not get histograms from file " << fileName[i] << endl;
      exit(EXIT_FAILURE);

    }
	 
  }

  Int_t startingBin = hZpTrecoGenRatio[0]->FindBin(zptStart) ;  // will consider ratio pdf for Zpt > 600 GeV  (they should be equal for Z->ee and Z->nunu)
  Int_t endingBin = hZpTrecoGenRatio[0]->FindBin(zptEnd) ;     // will consider ratio pdf for Zpt < 1000 GeV  (they should be equal for Z->ee and Z->nunu)
  cout << "ZpT bins from "<<startingBin<<" to "<<endingBin<< endl;

  for (Int_t j = 0; j < 2; j++) {

    for (Int_t i = startingBin; i < endingBin; i++) {

      HZtoLLPt_RecoGenRatio_pdf_inRange[j]->Fill(hZpTrecoGenRatio[j]->GetBinContent(i));

    }

    HZtoLLPt_RecoGenRatio_pdf_inRange[j]->Scale(1./HZtoLLPt_RecoGenRatio_pdf_inRange[j]->Integral(0,1 + HZtoLLPt_RecoGenRatio_pdf_inRange[j]->GetNbinsX()));

  }   // note that this distribution will be almost empty because it's the distribution of the mean of various ZpT points.

  //cout << " ****************  check ************** " << endl;

  for (Int_t j = 0; j < nFiles; j++) {

    hZpTreco[j]->SetStats(kFALSE);   // to avoid drawing statistic box
    hZpTreco[j]->SetLineColor(histColor[j]);
    // no need to use TH1::Scale() between reco and gen of Z->mumu or Z->ee, because histogram are filled for the same set of events, so integral
    // should be the same in principle
    //hZpTreco[j]->SetFillColorAlpha(histColor[j], 0.80);
    hZpTgen[j]->SetStats(kFALSE);   // to avoid drawing statistic box
    hZpTgen[j]->SetLineColor(histColor[j+2]);
    hZpTrecoGenRatio[j]->SetStats(kFALSE);
    //hZpTrecoGenRatio[j]->SetLineColor(histColor[j]);
    hZpTrecoGenRatio_pdf[j]->SetStats(kFALSE);
    hZpTrecoGenRatio_pdf[j]->SetLineColor(histColor[j+2]);
    HZtoLLPt_RecoGenRatio_pdf_inRange[j]->SetStats(kFALSE);
    HZtoLLPt_RecoGenRatio_pdf_inRange[j]->SetLineColor(histColor[j*2]);
    
  }

  TPad *subpad1 = NULL;  // will use it to access specific subpad in canvas
  TPad *subpad2 = NULL; 

  TCanvas *cZtomumuPtRecoGen = new TCanvas("cZtomumuPtRecoGen","",700,700);
  TLegend *legZtomumuPtRecoGen = new TLegend(0.70,0.7,0.89,0.89); 
  subpad1 = new TPad("pad1","",0.0,0.36,1.0,1.0);
  subpad1->SetLogy();
  subpad1->SetBottomMargin(0);
  subpad2 = new TPad("pad2","",0.0,0.0,1.0,0.36);
  subpad2->SetGrid();
  subpad2->SetTopMargin(0);
  subpad2->SetBottomMargin(0.2);
  subpad1->Draw();
  subpad2->Draw();
  //cout <<"Drawing histograms and ratio"<<endl;
  subpad1->cd();
  // hZpTreco[0]->GetXaxis()->SetTitle("Z_{pT}[GeV]");
  // hZpTreco[0]->GetXaxis()->SetTitleSize(0.04);
  //hZpTreco[0]->GetXaxis()->SetLabelSize(0.04);
  hZpTreco[0]->GetYaxis()->SetTitle("# events");
  hZpTreco[0]->GetYaxis()->SetTitleSize(0.04);
  hZpTreco[0]->GetYaxis()->SetLabelSize(0.04);
  hZpTreco[0]->GetYaxis()->CenterTitle();
  //hZpTreco[0]->GetYaxis()->SetLabelSize(0.04);
  hZpTreco[0]->Draw("HE");
  hZpTgen[0]->Draw("HE SAME");
  legZtomumuPtRecoGen->AddEntry(hZpTreco[0],"Z(#mu#mu) reco","l");
  legZtomumuPtRecoGen->AddEntry(hZpTgen[0],"Z(#mu#mu) gen","l");
  gStyle->SetStatStyle(0);
  legZtomumuPtRecoGen->Draw(); 
  legZtomumuPtRecoGen->SetMargin(0.3); 
  legZtomumuPtRecoGen->SetBorderSize(0);
  subpad2->cd();
  hZpTrecoGenRatio[0]->GetXaxis()->SetLabelSize(0.08);
  hZpTrecoGenRatio[0]->GetXaxis()->SetTitle("Z_{pT}[GeV]");
  hZpTrecoGenRatio[0]->GetXaxis()->SetTitleSize(0.07);
  hZpTrecoGenRatio[0]->GetXaxis()->SetTitleOffset(1.2);
  hZpTrecoGenRatio[0]->GetYaxis()->SetLabelSize(0.07);
  hZpTrecoGenRatio[0]->GetYaxis()->SetTitle("reco/gen ZpT");
  hZpTrecoGenRatio[0]->GetYaxis()->SetTitleSize(0.07);
  hZpTrecoGenRatio[0]->GetYaxis()->SetTitleOffset(0.5);
  hZpTrecoGenRatio[0]->GetYaxis()->CenterTitle();
  hZpTrecoGenRatio[0]->Draw("E");
  hZpTrecoGenRatio[0]->SetMarkerStyle(7);  //medium dot
  cZtomumuPtRecoGen->SaveAs( (plotDirectoryPath + cZtomumuPtRecoGen->GetName() + suffix + plotFileExtension).c_str() );

  TPad *subpad1_bis = NULL;
  TPad *subpad2_bis = NULL;

  TCanvas *cZtoeePtRecoGen = new TCanvas("cZtoeePtRecoGen","",700,700);
  TLegend *legZtoeePtRecoGen = new TLegend(0.70,0.7,0.89,0.89); 
  subpad1_bis = new TPad("pad1","",0.0,0.36,1.0,1.0);
  subpad1_bis->SetLogy();
  subpad1_bis->SetBottomMargin(0);
  subpad2_bis = new TPad("pad2","",0.0,0.0,1.0,0.36);
  subpad2_bis->SetGrid();
  subpad2_bis->SetTopMargin(0);
  subpad2_bis->SetBottomMargin(0.2);
  subpad1_bis->Draw();
  subpad2_bis->Draw();
  //cout <<"Drawing histograms and ratio"<<endl;
  subpad1_bis->cd();
  // hZpTreco[1]->GetXaxis()->SetTitle("Z_{pT}[GeV]");
  // hZpTreco[1]->GetXaxis()->SetTitleSize(0.04);
  //hZpTreco[1]->GetXaxis()->SetLabelSize(0.04);
  hZpTreco[1]->GetYaxis()->SetTitle("# events");
  hZpTreco[1]->GetYaxis()->SetTitleSize(0.04);
  hZpTreco[1]->GetYaxis()->SetLabelSize(0.04);
  hZpTreco[1]->GetYaxis()->CenterTitle();
  //hZpTreco[1]->GetYaxis()->SetLabelSize(0.04);
  hZpTreco[1]->Draw("HE");
  hZpTgen[1]->Draw("HE SAME");
  legZtoeePtRecoGen->AddEntry(hZpTreco[0],"Z(ee) reco","l");
  legZtoeePtRecoGen->AddEntry(hZpTgen[0],"Z(ee) gen","l");
  gStyle->SetStatStyle(0);
  legZtoeePtRecoGen->Draw(); 
  legZtoeePtRecoGen->SetMargin(0.3); 
  legZtoeePtRecoGen->SetBorderSize(0);
  subpad2_bis->cd();
  hZpTrecoGenRatio[1]->GetXaxis()->SetLabelSize(0.08);
  hZpTrecoGenRatio[1]->GetXaxis()->SetTitle("Z_{pT}[GeV]");
  hZpTrecoGenRatio[1]->GetXaxis()->SetTitleSize(0.07);
  hZpTrecoGenRatio[1]->GetXaxis()->SetTitleOffset(1.2);
  hZpTrecoGenRatio[1]->GetYaxis()->SetLabelSize(0.07);
  hZpTrecoGenRatio[1]->GetYaxis()->SetTitle("reco/gen ZpT");
  hZpTrecoGenRatio[1]->GetYaxis()->SetTitleOffset(0.5);
  hZpTrecoGenRatio[1]->GetYaxis()->SetTitleSize(0.07);
  hZpTrecoGenRatio[1]->GetYaxis()->CenterTitle();
  hZpTrecoGenRatio[1]->Draw("E");
  hZpTrecoGenRatio[1]->SetMarkerStyle(7);  //medium dot
  cZtoeePtRecoGen->SaveAs( (plotDirectoryPath + cZtoeePtRecoGen->GetName() + suffix + plotFileExtension).c_str() );

  // TCanvas *cZtoeePtRecoGen = new TCanvas("cZtoeePtRecoGen","",700,700);
  // TLegend *legZtoeePtRecoGen = new TLegend(0.70,0.7,0.89,0.89);
  // cZtoeePtRecoGen->Divide(1,2,0,0);
  // cZtoeePtRecoGen->cd(1);
  // subpad1 = (TPad*)cZtoeePtRecoGen->GetPad(1);
  // subpad1->SetPad(0.0,0.36,0.98,0.99);
  // subpad1->SetLogy();
  // //cout <<"Drawing histograms and ratio"<<endl;
  // // hZpTreco[1]->GetXaxis()->SetTitle("Z_{pT}[GeV]");
  // // hZpTreco[1]->GetXaxis()->SetTitleSize(0.04);
  // hZpTreco[1]->GetYaxis()->SetTitle("# events");
  // hZpTreco[1]->GetYaxis()->SetTitleSize(0.045);
  // hZpTreco[1]->GetYaxis()->CenterTitle();
  // //hZpTreco[1]->GetYaxis()->SetLabelSize(0.1);
  // hZpTreco[1]->Draw("HE");
  // hZpTgen[1]->Draw("HE SAME");
  // legZtoeePtRecoGen->AddEntry(hZpTreco[1],"Z(ee) reco","l");
  // legZtoeePtRecoGen->AddEntry(hZpTgen[1],"Z(ee) gen","l");
  // gStyle->SetStatStyle(0);
  // legZtoeePtRecoGen->Draw(); 
  // legZtoeePtRecoGen->SetMargin(0.3); 
  // legZtoeePtRecoGen->SetBorderSize(0);
  // cZtoeePtRecoGen->cd(2);
  // subpad2 = (TPad*)cZtoeePtRecoGen->GetPad(2);
  // subpad2->SetPad(0.0,0.0,0.98,0.36);
  // subpad2->SetGrid();
  // hZpTrecoGenRatio[1]->GetXaxis()->SetLabelSize(0.08);
  // hZpTrecoGenRatio[1]->GetXaxis()->SetTitle("Z_{pT}[GeV]");
  // hZpTrecoGenRatio[1]->GetXaxis()->SetTitleSize(0.06);
  // hZpTrecoGenRatio[1]->GetXaxis()->SetTitleOffset(1.2);
  // hZpTrecoGenRatio[1]->GetYaxis()->SetLabelSize(0.08);
  // hZpTrecoGenRatio[1]->Draw("E");
  // hZpTrecoGenRatio[1]->SetMarkerStyle(7);  //medium dot
  // cZtoeePtRecoGen->SaveAs( (plotDirectoryPath + cZtoeePtRecoGen->GetName() + suffix + plotFileExtension).c_str() );

  // now I normalize histograms to same area (here is 1) to compare Z->mumu and Z->ee which have different numbers of events

  for (Int_t j = 0; j < nFiles; j++) {

    hZpTreco[j]->Scale(1./hZpTreco[j]->Integral(0,1 + hZpTreco[j]->GetNbinsX()));  // normalize to unity, use integral including underflow & overflow bin
    hZpTgen[j]->Scale(1./hZpTgen[j]->Integral(0,1 + hZpTgen[j]->GetNbinsX()));
    hZpTrecoGenRatio_pdf[j]->Scale(1./hZpTrecoGenRatio_pdf[j]->Integral(0,1 + hZpTrecoGenRatio_pdf[j]->GetNbinsX()));

  }

  TCanvas *cZtollPtRecoGen = new TCanvas("cZtollPtRecoGen","");
  TLegend *legZtollPtRecoGen = new TLegend(0.70,0.7,0.89,0.89); 
  cZtollPtRecoGen->SetLogy();
  //cout <<"Drawing histograms and ratio"<<endl;
  hZpTreco[0]->GetXaxis()->SetTitle("Z_{pT}[GeV]");
  hZpTreco[0]->GetXaxis()->SetTitleSize(0.04);
  hZpTreco[0]->GetYaxis()->SetTitle("# events");
  hZpTreco[0]->GetYaxis()->SetTitleSize(0.045);
  hZpTreco[0]->GetYaxis()->CenterTitle();
  hZpTreco[0]->Draw("HE");
  hZpTgen[0]->Draw("HE SAME");
  hZpTreco[1]->Draw("HE SAME");
  hZpTgen[1]->Draw("HE SAME");
  legZtollPtRecoGen->AddEntry(hZpTreco[0],"Z(#mu#mu) reco","l");
  legZtollPtRecoGen->AddEntry(hZpTgen[0],"Z(#mu#mu) gen","l");
  legZtollPtRecoGen->AddEntry(hZpTreco[1],"Z(ee) reco","l");
  legZtollPtRecoGen->AddEntry(hZpTgen[1],"Z(ee) gen","l");
  gStyle->SetStatStyle(0);
  legZtollPtRecoGen->Draw(); 
  legZtollPtRecoGen->SetMargin(0.3); 
  legZtollPtRecoGen->SetBorderSize(0);
  cZtollPtRecoGen->SaveAs( (plotDirectoryPath + cZtollPtRecoGen->GetName() + suffix + plotFileExtension).c_str() );

  Int_t bins;
  Double_t firstEdge;
  Double_t lastEdge;
  TH1D *hZpTMuEleRecoRatio;
  TCanvas *cZpTMuEleRecoRatio;

  if( hZpTreco[0]->GetNbinsX() == hZpTreco[1]->GetNbinsX() ) {

    bins = hZpTreco[0]->GetNbinsX();
    firstEdge = hZpTreco[0]->GetXaxis()->GetBinLowEdge(1);
    lastEdge = hZpTreco[0]->GetXaxis()->GetBinUpEdge(bins);
    hZpTMuEleRecoRatio = new TH1D("hZpTMuEleRecoRatio","",bins,firstEdge,lastEdge);
    

    // cout << "hZpTreco[0]->GetNbinsX() : "<< hZpTreco[0]->GetNbinsX() << endl;
    // cout << "hZpTreco[1]->GetNbinsX() : "<< hZpTreco[1]->GetNbinsX() << endl;
    // cout << "hZpTMuEleGenRatio->GetNbinsX() : "<< hZpTMuEleGenRatio->GetNbinsX() << endl;

    if (!hZpTMuEleRecoRatio->Divide(hZpTreco[0],hZpTreco[1])) cout << " Error in hZpTMuEleRecoRatio->Divide(hZpTreco[0],hZpTreco[1])" << endl;
    hZpTMuEleRecoRatio->SetStats(kFALSE);
   
    cZpTMuEleRecoRatio = new TCanvas("cZpTMuEleRecoRatio","");
    hZpTMuEleRecoRatio->GetXaxis()->SetTitle("Z_{pT}[GeV]");
    hZpTMuEleRecoRatio->GetXaxis()->SetTitleSize(0.04);
    hZpTMuEleRecoRatio->GetYaxis()->SetTitle("reco pT_{Z(#mu#mu)} / pT_{Z(ee)} ");
    hZpTMuEleRecoRatio->GetYaxis()->SetTitleSize(0.045);
    hZpTMuEleRecoRatio->GetYaxis()->SetRangeUser(0.5,1.5);
    hZpTMuEleRecoRatio->GetYaxis()->CenterTitle();
    hZpTMuEleRecoRatio->Draw("E");
    gStyle->SetStatStyle(0);
    cZpTMuEleRecoRatio->SaveAs( (plotDirectoryPath + cZpTMuEleRecoRatio->GetName() + suffix + plotFileExtension).c_str() );
    
  }

  TH1D *hZpTMuEleGenRatio;
  TCanvas *cZpTMuEleGenRatio;

  if (hZpTgen[0]->GetNbinsX() == hZpTgen[1]->GetNbinsX()) {

    bins = hZpTgen[0]->GetNbinsX();
    firstEdge = hZpTgen[0]->GetXaxis()->GetBinLowEdge(1);
    lastEdge = hZpTgen[0]->GetXaxis()->GetBinUpEdge(bins);
    hZpTMuEleGenRatio = new TH1D("hZpTMuEleGenRatio","",bins,firstEdge,lastEdge);

    if (!hZpTMuEleGenRatio->Divide(hZpTgen[0],hZpTgen[1])) cout << " Error in hZpTMuEleGenRatio->Divide(hZpTgen[0],hZpTgen[1])" << endl;
    hZpTMuEleGenRatio->SetStats(kFALSE);

    cZpTMuEleGenRatio = new TCanvas("cZpTMuEleGenRatio","");
    hZpTMuEleGenRatio->GetXaxis()->SetTitle("Z_{pT}[GeV]");
    hZpTMuEleGenRatio->GetXaxis()->SetTitleSize(0.04);
    hZpTMuEleGenRatio->GetYaxis()->SetTitle("gen pT_{Z(#mu#mu)} / pT_{Z(ee)} ");
    hZpTMuEleGenRatio->GetYaxis()->SetTitleSize(0.045);
    hZpTMuEleGenRatio->GetYaxis()->SetRangeUser(0.5,1.5);
    hZpTMuEleGenRatio->GetYaxis()->CenterTitle();
    hZpTMuEleGenRatio->Draw("E");
    gStyle->SetStatStyle(0);
    cZpTMuEleGenRatio->SaveAs( (plotDirectoryPath + cZpTMuEleGenRatio->GetName() + suffix + plotFileExtension).c_str() );
 
  }


  TCanvas *cZpTRecoGenRatio_pdf = new TCanvas("cZpTRecoGenRatio_pdf","");
  TLegend *legZpTRecoGenRatio_pdf = new TLegend(0.78,0.78,0.89,0.89);
  hZpTrecoGenRatio_pdf[0]->GetXaxis()->SetTitle("reco Z_{pT}/gen Z_{pT}");
  hZpTrecoGenRatio_pdf[0]->GetXaxis()->SetTitleSize(0.04);
  hZpTrecoGenRatio_pdf[0]->GetXaxis()->SetRangeUser(0.7,1.3);
  hZpTrecoGenRatio_pdf[0]->GetYaxis()->SetTitle("a.u. ");
  hZpTrecoGenRatio_pdf[0]->GetYaxis()->SetTitleSize(0.045);
  hZpTrecoGenRatio_pdf[0]->GetYaxis()->SetRangeUser(0.0,0.4);
  hZpTrecoGenRatio_pdf[0]->GetYaxis()->CenterTitle();
  hZpTrecoGenRatio_pdf[0]->Draw("HE");
  hZpTrecoGenRatio_pdf[1]->Draw("HE SAME");
  legZpTRecoGenRatio_pdf->AddEntry(hZpTrecoGenRatio_pdf[0],"Z(#mu#mu)","l");
  legZpTRecoGenRatio_pdf->AddEntry(hZpTrecoGenRatio_pdf[1],"Z(ee)","l");
  gStyle->SetStatStyle(0);
  legZpTRecoGenRatio_pdf->Draw(); 
  legZpTRecoGenRatio_pdf->SetMargin(0.3); 
  legZpTRecoGenRatio_pdf->SetBorderSize(0);
  cZpTRecoGenRatio_pdf->SaveAs( (plotDirectoryPath + cZpTRecoGenRatio_pdf->GetName() + suffix + plotFileExtension).c_str() );

  TCanvas *cZpTRecoGenRatio_pdf_inRange = new TCanvas(Form("ZpTRecoGenRatio_pdf_Zpt%2.0lfTo%2.0lf",zptStart,zptEnd),"");
  TLegend *legZpTRecoGenRatio_pdf_inRange = new TLegend(0.78,0.78,0.89,0.89);
  TPaveLabel *title = new TPaveLabel(0.1,0.94,0.9,0.98,Form("Zpt recoGen ratio: %2.0lf < ZpT < %2.0lf",zptStart,zptEnd));
  title->Draw();
  HZtoLLPt_RecoGenRatio_pdf_inRange[0]->GetXaxis()->SetTitle("reco Z_{pT}/gen Z_{pT}");
  HZtoLLPt_RecoGenRatio_pdf_inRange[0]->GetXaxis()->SetTitleSize(0.04);
  HZtoLLPt_RecoGenRatio_pdf_inRange[0]->GetXaxis()->SetRangeUser(0.7,1.3);
  HZtoLLPt_RecoGenRatio_pdf_inRange[0]->GetYaxis()->SetTitle("a.u. ");
  HZtoLLPt_RecoGenRatio_pdf_inRange[0]->GetYaxis()->SetTitleSize(0.045);
  HZtoLLPt_RecoGenRatio_pdf_inRange[0]->GetYaxis()->SetRangeUser(0.0,0.4);
  HZtoLLPt_RecoGenRatio_pdf_inRange[0]->GetYaxis()->CenterTitle();
  HZtoLLPt_RecoGenRatio_pdf_inRange[0]->Draw("HE");
  HZtoLLPt_RecoGenRatio_pdf_inRange[1]->Draw("HE SAME");
  legZpTRecoGenRatio_pdf_inRange->AddEntry(HZtoLLPt_RecoGenRatio_pdf_inRange[0],"Z(#mu#mu)","l");
  legZpTRecoGenRatio_pdf_inRange->AddEntry(HZtoLLPt_RecoGenRatio_pdf_inRange[1],"Z(ee)","l");
  gStyle->SetStatStyle(0);
  legZpTRecoGenRatio_pdf_inRange->Draw(); 
  legZpTRecoGenRatio_pdf_inRange->SetMargin(0.3); 
  legZpTRecoGenRatio_pdf_inRange->SetBorderSize(0);
  cZpTRecoGenRatio_pdf_inRange->SaveAs( (plotDirectoryPath + cZpTRecoGenRatio_pdf_inRange->GetName() + suffix + plotFileExtension).c_str() );

}
void makePlots()
{
 // **********************************************
 // *            Input parameters                *
 // **********************************************

 // turn on/off batch mode
 gROOT->SetBatch(kTRUE);
 
 // turn on/off debugging mode
 Bool_t debug = kFALSE;

 // array of LQ masses for calculation of upXS
 Double_t mData[10] = {200, 250, 280, 300, 320, 340, 370, 400, 450, 500};
 // arrays of upper limits on the cross section
 Double_t xsUp_observed[10] = {1.0918, 0.56543, 0.536133, 0.420898, 0.411621, 0.394043, 0.287354, 0.27124, 0.180835, 0.168945};
 Double_t xsUp_expected[10] = {1.3625, 0.728578, 0.560355, 0.478632, 0.411471, 0.36518, 0.318113, 0.284102, 0.248004, 0.226132};
 // Zero systematics case
//  Double_t xsUp_observed[10] = {0.975586, 0.526367, 0.510254, 0.404297, 0.39917, 0.383789, 0.280762, 0.265625, 0.178125, 0.166406};
//  Double_t xsUp_expected[10] = {1.24111, 0.685307, 0.537118, 0.462398, 0.400498, 0.356725, 0.31154, 0.278739, 0.243565, 0.222276};
 // Doubled systematics case
//  Double_t xsUp_observed[10] = {1.21094, 0.615234, 0.577881, 0.450195, 0.438965, 0.419434, 0.304199, 0.286865, 0.189697, 0.1771};
//  Double_t xsUp_expected[10] = {1.50694, 0.792841, 0.602788, 0.512162, 0.437966, 0.387823, 0.336865, 0.300479, 0.261752, 0.238493};

 // arrays of LQ masses for theoretical cross section
 Double_t mTh[10] = {100, 150, 200, 250, 300, 350, 400, 450, 500, 550};
 // arrays of theoretical cross-sections for different leptoquark masses
 Double_t xsTh[10] = {386, 53.3, 11.9, 3.47, 1.21, 0.477, 0.205, 0.0949, 0.0463, 0.0236};
 // arays of upper and lower bounds with PDF and scale uncertainties included
 Double_t xsTh_upper[10] = {445.5, 61.4, 13.7, 4.1, 1.43, 0.572, 0.249, 0.1167, 0.0581, 0.0300}; // upper bounds with PDF and scale uncertainties included
 Double_t xsTh_lower[10] = {330.3, 45.2, 10.0, 2.9, 0.98, 0.379, 0.160, 0.0719, 0.0340, 0.0169}; // lower bounds with PDF and scale uncertainties included

 // filename for the final plot (NB: changing the name extension changes the file format)
 string fileName = "beta_vs_m_excl_enujj.eps";
 // Zero systematics case
//  string fileName = "beta_vs_m_excl_enujj_zeroSyst.eps";
 // Doubled systematics case
//  string fileName = "beta_vs_m_excl_enujj_doubledSyst.eps";

 // axes labels for the final plot
 string title = ";M_{LQ} [GeV];#beta";

 // integrated luminosity
 string sqrts = "#sqrt{s} = 7 TeV";

 // number of points used for beta vs m line
 Int_t nPts = 50;
 // range of LQ masses in which beta vs m line is derived
 Double_t mass_range[2] = {200, 360};

 // region excluded by Tevatron limits (1 fb-1)
 Double_t x_excl[13] = {200,214.39,235.13,254.08,268.12,275.92,283.95,289.08,293.09,295.99,297.10,298.89,200};
 Double_t y_excl[13] = {0,0,0.10,0.20,0.30,0.40,0.50,0.60,0.70,0.80,0.90,1,1};

 // set ROOT style
//  myStyle();
 setTDRStyle();
//  gStyle->SetPadLeftMargin(0.14);
//  gStyle->SetPadRightMargin(0.6);
 gROOT->ForceStyle();

 TH2F *bg = new TH2F("bg",title.c_str(), 20, 200., 360., 100, 0., 1.);
 bg->SetStats(kFALSE);
 bg->SetTitleOffset(1.,"X");
 bg->SetTitleOffset(1.,"Y");
//  bg->GetXaxis()->SetNdivisions(505);

 TCanvas *c = new TCanvas("c","",800,800);
 c->cd();

 Int_t size_th = sizeof(xsTh)/sizeof(*xsTh);

 Double_t xsTh_log[size_th];
 Double_t xsTh_upper_log[size_th];
 Double_t xsTh_lower_log[size_th];

 for(Int_t i=0; i<size_th; i++) {
   xsTh_log[i] = log(xsTh[i]);
   xsTh_upper_log[i] = log(xsTh_upper[i]);
   xsTh_lower_log[i] = log(xsTh_lower[i]);
 }

 TGraph *xsTh_vs_m_log = new TGraph(size_th, mTh, xsTh_log);
 TGraph *xsTh_upper_vs_m_log = new TGraph(size_th, mTh, xsTh_upper_log);
 TGraph *xsTh_lower_vs_m_log = new TGraph(size_th, mTh, xsTh_lower_log);

 TSpline3 gs_xsTh_vs_m("gs_xsTh_vs_m", xsTh_vs_m_log);
 TSpline3 gs_xsTh_upper_vs_m("gs_xsTh_vs_m", xsTh_upper_vs_m_log);
 TSpline3 gs_xsTh_lower_vs_m("gs_xsTh_vs_m", xsTh_lower_vs_m_log);

 Int_t size_Data = sizeof(xsUp_expected)/sizeof(*xsUp_expected);

 Double_t xsUp_expected_log[size_Data];
 Double_t xsUp_observed_log[size_Data];

 for(Int_t i=0; i<size_Data; i++) {
   xsUp_expected_log[i] = log(xsUp_expected[i]);
   xsUp_observed_log[i] = log(xsUp_observed[i]);
 }

 TGraph *xsUp_expected_vs_m_log = new TGraph(size_Data, mData, xsUp_expected_log);
 TGraph *xsUp_observed_vs_m_log = new TGraph(size_Data, mData, xsUp_observed_log);

 TSpline3 gs_xsUp_expected_vs_m("gs_xsTh_vs_m", xsUp_expected_vs_m_log);
 TSpline3 gs_xsUp_observed_vs_m("gs_xsTh_vs_m", xsUp_observed_vs_m_log);

 /*******************************************
 ****         Debugging section          ****
 *******************************************/
 if(debug) {
   Double_t mTh_int[20];
   Double_t xsTh_int[20];
   Double_t xsTh_upper_int[20];
   Double_t xsTh_lower_int[20];

   Double_t step_th = (mTh[size_th-1]-mTh[0])/19;

   for(Int_t i=0; i<20; i++) {
     mTh_int[i] = mTh[0]+step_th*i;
     xsTh_int[i] = exp(gs_xsTh_vs_m.Eval(mTh_int[i]));
     xsTh_upper_int[i] = exp(gs_xsTh_upper_vs_m.Eval(mTh_int[i]));
     xsTh_lower_int[i] = exp(gs_xsTh_lower_vs_m.Eval(mTh_int[i]));
   }

   TGraph *xsTh_vs_m = new TGraph(size_th, mTh, xsTh);
   xsTh_vs_m->SetLineWidth(2);
   xsTh_vs_m->SetLineColor(kRed);
   xsTh_vs_m->Draw("ACP");

   TGraph *xsTh_vs_m_int = new TGraph(20, mTh_int, xsTh_int);
   xsTh_vs_m_int->SetMarkerSize(1.);
   xsTh_vs_m_int->SetMarkerStyle(24);
   xsTh_vs_m_int->SetMarkerColor(kBlue);
   xsTh_vs_m_int->Draw("P");

   c->SetGridx();
   c->SetGridy();
   c->SetLogy();
   c->SaveAs("xsTh_vs_m.png");

   TGraph *xsTh_upper_vs_m = new TGraph(size_th, mTh, xsTh_upper);
   xsTh_upper_vs_m->SetLineWidth(2);
   xsTh_upper_vs_m->SetLineColor(kRed);
   xsTh_upper_vs_m->Draw("ACP");

   TGraph *xsTh_upper_vs_m_int = new TGraph(20, mTh_int, xsTh_upper_int);
   xsTh_upper_vs_m_int->SetMarkerSize(1.);
   xsTh_upper_vs_m_int->SetMarkerStyle(24);
   xsTh_upper_vs_m_int->SetMarkerColor(kBlue);
   xsTh_upper_vs_m_int->Draw("P");

   c->SetGridx();
   c->SetGridy();
   c->SetLogy();
   c->SaveAs("xsTh_upper_vs_m.png");

   TGraph *xsTh_lower_vs_m = new TGraph(size_th, mTh, xsTh_lower);
   xsTh_lower_vs_m->SetLineWidth(2);
   xsTh_lower_vs_m->SetLineColor(kRed);
   xsTh_lower_vs_m->Draw("ACP");

   TGraph *xsTh_lower_vs_m_int = new TGraph(20, mTh_int, xsTh_lower_int);
   xsTh_lower_vs_m_int->SetMarkerSize(1.);
   xsTh_lower_vs_m_int->SetMarkerStyle(24);
   xsTh_lower_vs_m_int->SetMarkerColor(kBlue);
   xsTh_lower_vs_m_int->Draw("P");

   c->SetGridx();
   c->SetGridy();
   c->SetLogy();
   c->SaveAs("xsTh_lower_vs_m.png");

   Double_t mData_int[20];
   Double_t xsUp_expected_int[20];
   Double_t xsUp_observed_int[20];

   Double_t step_Data = (mData[size_Data-1]-mData[0])/19;

   for(Int_t i=0; i<20; i++) {
     mData_int[i] = mData[0]+step_Data*i;
     xsUp_expected_int[i] = exp(gs_xsUp_expected_vs_m.Eval(mData_int[i]));
     xsUp_observed_int[i] = exp(gs_xsUp_observed_vs_m.Eval(mData_int[i]));
   }

   TGraph *xsUp_expected_vs_m = new TGraph(size_Data, mData, xsUp_expected);
   xsUp_expected_vs_m->SetLineWidth(2);
   xsUp_expected_vs_m->SetLineColor(kRed);
   xsUp_expected_vs_m->Draw("ACP");

   TGraph *xsUp_expected_vs_m_int = new TGraph(20, mData_int, xsUp_expected_int);
   xsUp_expected_vs_m_int->SetMarkerSize(1.);
   xsUp_expected_vs_m_int->SetMarkerStyle(24);
   xsUp_expected_vs_m_int->SetMarkerColor(kBlue);
   xsUp_expected_vs_m_int->Draw("P");

   c->SetGridx();
   c->SetGridy();
   c->SetLogy();
   c->SaveAs("xsUp_expected_vs_m.png");

   TGraph *xsUp_observed_vs_m = new TGraph(size_Data, mData, xsUp_observed);
   xsUp_observed_vs_m->SetLineWidth(2);
   xsUp_observed_vs_m->SetLineColor(kRed);
   xsUp_observed_vs_m->Draw("ACP");

   TGraph *xsUp_observed_vs_m_int = new TGraph(20, mData_int, xsUp_observed_int);
   xsUp_observed_vs_m_int->SetMarkerSize(1.);
   xsUp_observed_vs_m_int->SetMarkerStyle(24);
   xsUp_observed_vs_m_int->SetMarkerColor(kBlue);
   xsUp_observed_vs_m_int->Draw("P");

   c->SetGridx();
   c->SetGridy();
   c->SetLogy();
   c->SaveAs("xsUp_observed_vs_m.png");

   delete xsTh_vs_m;
   delete xsTh_vs_m_int;
   delete xsTh_upper_vs_m;
   delete xsTh_upper_vs_m_int;
   delete xsTh_lower_vs_m;
   delete xsTh_lower_vs_m_int;
   delete xsUp_expected_vs_m_int;
   delete xsUp_observed_vs_m_int;
 }
 /*******************************************
 ****       End of debugging section     ****
 *******************************************/

 bg->Draw();

 TGraph *gr_excl = new TGraph(13,x_excl,y_excl);
 gr_excl->SetLineColor(0);
 gr_excl->SetFillColor(kGray);
//  gr_excl->Draw("f");

 Double_t m_expected[2*nPts], beta_expected[2*nPts], m_observed[2*nPts], beta_observed[2*nPts], m_observed_upper[2*nPts], beta_observed_upper[2*nPts], m_observed_lower[2*nPts], beta_observed_lower[2*nPts];

 fill_arrays(mass_range[0], mass_range[1], nPts, gs_xsUp_expected_vs_m, gs_xsTh_vs_m, m_expected, beta_expected);
 fill_arrays(mass_range[0], mass_range[1], nPts, gs_xsUp_observed_vs_m, gs_xsTh_vs_m, m_observed, beta_observed);
 fill_arrays(mass_range[0], mass_range[1], nPts, gs_xsUp_observed_vs_m, gs_xsTh_upper_vs_m, m_observed_lower, beta_observed_lower);
 fill_arrays(mass_range[0], mass_range[1], nPts, gs_xsUp_observed_vs_m, gs_xsTh_lower_vs_m, m_observed_upper, beta_observed_upper);

 cout<<endl<<Form("Double_t m_enujj_observed[%i] = {", 2*nPts);
 for(Int_t i = 0; i<2*nPts; i++) {
   cout<<m_observed[i];
   if(i<(2*nPts-1)) cout<<", ";
 }
 cout<<"};"<<endl;
 cout<<Form("Double_t beta_enujj_observed[%i] = {", 2*nPts);
 for(Int_t i = 0; i<2*nPts; i++) {
   cout<<beta_observed[i];
   if(i<(2*nPts-1)) cout<<", ";
 }
 cout<<"};"<<endl;
 cout<<Form("Double_t m_enujj_expected[%i] = {", 2*nPts);
 for(Int_t i = 0; i<2*nPts; i++) {
   cout<<m_expected[i];
   if(i<(2*nPts-1)) cout<<", ";
 }
 cout<<"};"<<endl;
 cout<<Form("Double_t beta_enujj_expected[%i] = {", 2*nPts);
 for(Int_t i = 0; i<2*nPts; i++) {
   cout<<beta_expected[i];
   if(i<(2*nPts-1)) cout<<", ";
 }
 cout<<"};"<<endl<<endl;

 TGraph *beta_observed_vs_m_band = new TGraph(4*nPts);
 for(Int_t i=0;i<(2*nPts);i++) {
   beta_observed_vs_m_band->SetPoint(i,m_observed_lower[i],beta_observed_lower[i]);
   beta_observed_vs_m_band->SetPoint(2*nPts+i,m_observed_upper[2*nPts-i-1],beta_observed_upper[2*nPts-i-1]);
 }
 beta_observed_vs_m_band->SetLineColor(0);
 beta_observed_vs_m_band->SetFillColor(kYellow);
 beta_observed_vs_m_band->Draw("f");

 TGraph *beta_expected_vs_m = new TGraph(2*nPts, m_expected, beta_expected);
 beta_expected_vs_m->SetLineWidth(3);
 beta_expected_vs_m->SetLineStyle(2);
 beta_expected_vs_m->SetLineColor(kBlue);
 beta_expected_vs_m->Draw();

 TGraph *beta_observed_vs_m = new TGraph(2*nPts, m_observed, beta_observed);
 beta_observed_vs_m->SetLineWidth(3);
 beta_observed_vs_m->SetLineColor(kBlack);
 beta_observed_vs_m->SetFillColor(kYellow);
 beta_observed_vs_m->Draw();

 gPad->RedrawAxis();

 TLegend *legend = new TLegend(.17,.6,.43,.75);
 legend->SetBorderSize(1);
 legend->SetFillColor(0);
 //legend->SetFillStyle(0);
 legend->SetTextFont(132);
 legend->SetMargin(0.15);
 legend->SetHeader("LQ#bar{LQ} #rightarrow e#nujj");
//  legend->AddEntry(gr_excl,"D#oslash exclusion (1 fb^{-1})","f");
 legend->AddEntry(beta_expected_vs_m,"Expected limit","l");
 legend->AddEntry(beta_observed_vs_m,"Observed limit  ","lf");
 legend->Draw();

 TLatex l1;
 l1.SetTextAlign(12);
 l1.SetTextFont(132);
 l1.SetNDC();
 l1.SetTextSize(0.05);
 l1.DrawLatex(0.18,0.50,"CMS");
 l1.SetTextSize(0.05);
 l1.DrawLatex(0.18,0.43,sqrts.c_str());
 l1.SetTextSize(0.05);
 l1.DrawLatex(0.18,0.31,"#intLdt = 36 pb^{-1}");

 c->SetGridx();
 c->SetGridy();
 c->SetLogy(0);
 c->SaveAs(fileName.c_str());

 delete legend;
 delete beta_observed_vs_m;
 delete beta_expected_vs_m;
 delete beta_observed_vs_m_band;
 delete gr_excl;
 delete xsTh_vs_m_log;
 delete xsTh_upper_vs_m_log;
 delete xsTh_lower_vs_m_log;
 delete xsUp_expected_vs_m_log;
 delete xsUp_observed_vs_m_log;
 delete bg;
 delete c;
}
void distribution(const string folderNameWithRootFiles = "", const Int_t signalRegion0_controlRegion1 = 0, const Int_t mumu0_ee1 = 0, const Int_t data0_noData1 = 0, const string var = "met", const Int_t yAxisLog_flag = 0, const Int_t MCpoissonUncertainty_flag = 0, const Double_t xAxisMin = 0, const Double_t xAxisMax = -1, const Double_t yAxisMin = 0, const Double_t yAxisMax = -1, const Int_t binDensity_flag = 0, const Int_t MCnormalizedToData_flag = 0) {

  // if signalRegion0_controlRegion1 == 0 (default), will do met distribution in the monojet signal region, else it will do the control region

  // mumu0_ee1 is for lepton flavour in CS (not used in SR)

  // data0_noData1 is to use or not a data file to compared with MC

  // yAxisLog_flag is to choose whether or not to use log scale in Y axis (default is 0, that is, normal scale)
  // xAxisMin and xAxisMax are the ranges for x Axis. Default values are used if xAxisMin > xAxisMax (otherwise user values are used)

  TH1::SetDefaultSumw2();            //all the following histograms will automatically call TH1::Sumw2() 

  gROOT->SetStyle("Plain");  // to have white legend (on my pc it's already white, but in tier2 it appears grey)
  gStyle->SetFillColor(10);

  string filenameExtension = ".root";
  // string fileDirectoryPath = "spring15_25ns_rootfiles/";
  string fileDirectoryPath = "/cmshome/ciprianim/CMSSW721/output/" + folderNameWithRootFiles + "/";

  string plotDirectoryPath = fileDirectoryPath;
  // string plotDirectoryPath = "/cmshome/ciprianim/CMSSW721/pdfsFromAnalysis/plots/monojet/met_distribution/";
  //string plotDirectoryPath = "./distributions/";
  string plotFileExtension = ".pdf";
  string suffix;

  if (mumu0_ee1 == 0) suffix = "_mumu";
  else if (mumu0_ee1 == 1) suffix = "_ee";
  else {
    cout << "Error: mumu0_ee1 must be 0 or 1. End of programme." << endl;
    exit(EXIT_FAILURE);
  }

  TH1D* hvar = NULL;   // to get histogram from file
  string hvarName;          // name of histogram to take from file
  string xAxisName;        // name of X axis when plotting distribution. It is a tex string (with ROOT standard), e.g. "#slash{E}_{T} [GeV]" for MET

  // ===== TO BE MODIFIED =====

  // hvarName = "HmetNoLepDistribution";
  // xAxisName = "#slash{E}_{T} [GeV]";

  setDistribution(signalRegion0_controlRegion1, mumu0_ee1, var, hvarName, xAxisName);
    
  // =====================

  vector<TH1D*> hMC;
  TH1D* hdata = NULL;

  vector<string> sampleName;
  vector<string> MC_TexLabel;
  if (data0_noData1 == 1) setSampleName(signalRegion0_controlRegion1, sampleName, MC_TexLabel, mumu0_ee1);
  else setSampleName2lepSkim(signalRegion0_controlRegion1, sampleName, MC_TexLabel, mumu0_ee1);

  string data_TexLabel = "data";

  Int_t nFiles = (Int_t) sampleName.size();

  vector<Int_t> histColor;
   setHistColor(histColor, nFiles);

   string filenameBase;
   string canvasName;

   if (signalRegion0_controlRegion1 == 0) {

     filenameBase = "monojet_SR_spring15_25ns_";
     canvasName = var + "_monojetSR_";

   } else {

     canvasName = var + "_zjetsCS" + suffix;

     if (mumu0_ee1 == 0) filenameBase = "zmumujets_CS_spring15_25ns_";
     else if (mumu0_ee1 == 1) filenameBase = "zeejets_CS_spring15_25ns_";

   }
 

  vector<string> MCfileName;
  for (Int_t i = 0; i < nFiles; i++) {
    MCfileName.push_back(fileDirectoryPath + filenameBase + sampleName[i] + filenameExtension);
  }

  for(Int_t i = 0; i < nFiles; i++) {

    cout<<"fileName : "<<MCfileName[i]<<endl;

    TFile* f = TFile::Open(MCfileName[i].c_str(),"READ");
    if (!f || !f->IsOpen()) {
      cout<<"*******************************"<<endl;
      cout<<"Error opening file \""<<MCfileName[i]<<"\".\nApplication will be terminated."<<endl;
      cout<<"*******************************"<<endl;
      exit(EXIT_FAILURE);
    }

    //cout << "check 1 " << endl;    

    hvar = (TH1D*)f->Get(hvarName.c_str());
    if (!hvar) {
      cout << "Error: histogram not found in file ' " << MCfileName[i] << "'. End of programme." << endl;
      exit(EXIT_FAILURE);
    }
    hMC.push_back( (TH1D*)hvar->Clone() );

  } 

  // ==== FILE NAME WILL HAVE TO BE MODIFIED, NOW IT IS JUST A TEST =====

  string datafileName = fileDirectoryPath;

  if (data0_noData1 == 0) {

    if (signalRegion0_controlRegion1 == 0) {

      datafileName += "monojet_SR_spring15_25ns_DATA.root";

    } else {

      if (mumu0_ee1 == 0) datafileName += "zmumujets_CS_spring15_25ns_DATA.root";
      else if (mumu0_ee1 == 1) datafileName += "zeejets_CS_spring15_25ns_DATA.root";

    }

  }

  // ==== opening data file ======

  if (data0_noData1 == 0) {

    cout<<"fileName : "<<datafileName<<endl;

    TFile* f = TFile::Open(datafileName.c_str(),"READ");
    if (!f || !f->IsOpen()) {
      cout<<"*******************************"<<endl;
      cout<<"Error opening file \""<<datafileName<<"\".\nApplication will be terminated."<<endl;
      cout<<"*******************************"<<endl;
      exit(EXIT_FAILURE);
    }

    hvar = (TH1D*)f->Get(hvarName.c_str());

    if (!hvar) {
      cout << "Error: histogram not found in file ' " << datafileName << "'. End of programme." << endl;
      exit(EXIT_FAILURE);
    }
    hdata = (TH1D*)hvar->Clone();

  }

  // ===============================

  THStack* hMCstack = new THStack("hMCstack","");
  Double_t stackNorm = 0.0;

  for (Int_t j = 0; j < nFiles; j++) {

    for (Int_t i = 1; i <= hMC[j]->GetNbinsX(); i++) {

      if (MCpoissonUncertainty_flag == 1) {

	hMC[j]->SetBinError(i,sqrt(hMC[j]->GetBinContent(i)));
	
      }

    }

    hMC[j]->SetFillColor(histColor[j]);
    stackNorm += hMC[j]->Integral();

  }

  // loop again on MC histograms to scale them and then fill the thstack

  for (Int_t j = 0; j < nFiles; j++) {

    if (data0_noData1 == 0 && MCnormalizedToData_flag != 0) {

      Double_t dataNorm = hdata->Integral();

      if (binDensity_flag != 0) hMC[j]->Scale(dataNorm/stackNorm,"width");
      else hMC[j]->Scale(dataNorm/stackNorm);

    } else if (binDensity_flag != 0) hMC[j]->Scale(1.0,"width");  // option width divides by bin width and manages the correct error setting

    hMCstack->Add(hMC[j]);

  }

  if (data0_noData1 == 0) {

    cout << "Events in data: " << hdata->Integral() << endl;
    cout << "Events in MC   : " << ((TH1D*) hMCstack->GetStack()->Last())->Integral() << endl;

  }
  
  if (data0_noData1 == 0 && binDensity_flag != 0) hdata->Scale(1.0,"width");
  //if (data0_noData1 == 0 && MCnormalizedToData_flag != 0)

  // now here we go with the canvas

  TH1D * ratioplot = NULL; // will use it for the ratio plots

  TPad *subpad_1 = NULL;  // will use it to access specific subpad in canvas
  TPad *subpad_2 = NULL; 

  TCanvas *c;
  if (data0_noData1 == 0) c = new TCanvas(canvasName.c_str(), (var + " distribution").c_str(), 700, 700);
  else c = new TCanvas(canvasName.c_str(), (var + " distribution").c_str());
  TLegend *leg = new TLegend(0.7,0.6,0.99,0.94);  

  // if there are data, split canvas to draw the dta/MC ratio plot

  if (data0_noData1 == 0) {

    subpad_1 = new TPad("pad_1","",0.0,0.28,1.0,1.0);
    if (yAxisLog_flag) subpad_1->SetLogy();
    //subpad_1->SetBottomMargin(0);
    subpad_2 = new TPad("pad_2","",0.0,0.0,1.0,0.32);
    subpad_2->SetGridy();
    //subpad_2->SetTopMargin(0);
    subpad_2->SetBottomMargin(0.3);
    subpad_1->Draw();
    subpad_2->Draw();

    subpad_1->cd();

  } else if (yAxisLog_flag) c->SetLogy();

  
  hMCstack->Draw("HIST");
  //if (yAxisMin > 0) hMCstack->SetMinimum(yAxisMin);

  if (yAxisMin < yAxisMax) {
    if (data0_noData1 == 0) subpad_1->Update();  // to be done after Draw() to access pad parameters such as default axis range
    else c->Update();  
    hMCstack->GetYaxis()->SetRangeUser(yAxisMin,yAxisMax);
  }

  // if (data0_noData1 == 0) {

  //   if (yAxisMin > 0) hMCstack->GetYaxis()->SetRangeUser(yAxisMin, subpad_1->GetY2());
  //   else hMCstack->GetYaxis()->SetRangeUser(yAxisMin, c->GetY2());

  // }

  //hMCstack->SetMaximum(4000.0);
  TH1D* stackCopy = (TH1D*)(((TH1D*)hMCstack->GetStack()->Last())->DrawCopy("E2 SAME"));
  stackCopy->SetFillColor(kBlack);
  stackCopy->SetFillStyle(3144);

  if (data0_noData1 == 1) {    //  when using data ( == 0) the x axis will not have labels (they will only be below in the ratio plot
    hMCstack->GetXaxis()->SetTitle(xAxisName.c_str());
    hMCstack->GetXaxis()->SetTitleSize(0.06);
    hMCstack->GetXaxis()->SetTitleOffset(0.6);
  }

  if (xAxisMin < xAxisMax) {
    if (data0_noData1 == 0) subpad_1->Update();  // to be done after Draw() to access pad parameters such as default axis range
    else c->Update();  
    hMCstack->GetXaxis()->SetRangeUser(xAxisMin,xAxisMax);
  }

  if (binDensity_flag == 0) hMCstack->GetYaxis()->SetTitle("events");
  else hMCstack->GetYaxis()->SetTitle("events / GeV");
  hMCstack->GetYaxis()->SetTitleSize(0.06);
  hMCstack->GetYaxis()->SetTitleOffset(0.8);
  hMCstack->GetYaxis()->CenterTitle();
  for (Int_t j = (nFiles-1); j >= 0; j--) {
    leg->AddEntry(hMC[j],Form("%s",MC_TexLabel[j].c_str()),"lf");
  }

  if (data0_noData1 == 0) {    
    hdata->SetMarkerStyle(8); // large dot
    hdata->Draw("EX0 SAME"); //X0 doesn't draw x error
    leg->AddEntry(hdata,Form("%s",data_TexLabel.c_str()),"p");
  }

  gStyle->SetStatStyle(0);
  leg->Draw(); 
  leg->SetMargin(0.3); 
  leg->SetBorderSize(0);

  if (data0_noData1 == 0) { // if using data, draw the ratio plot

    subpad_2->cd();
    ratioplot = new TH1D(*hdata);
    ratioplot->Divide(stackCopy);
    ratioplot->SetStats(0);
    ratioplot->SetTitle("");
    ratioplot->GetXaxis()->SetLabelSize(0.10);
    ratioplot->GetXaxis()->SetTitle(xAxisName.c_str());
    ratioplot->GetXaxis()->SetTitleSize(0.14);
    ratioplot->GetXaxis()->SetTitleOffset(0.8);
    ratioplot->GetYaxis()->SetLabelSize(0.10);
    ratioplot->GetYaxis()->SetTitle("data / MC");
    ratioplot->GetYaxis()->SetTitleSize(0.15);
    ratioplot->GetYaxis()->SetTitleOffset(0.3);
    ratioplot->GetYaxis()->CenterTitle();
    ratioplot->GetYaxis()->SetRangeUser(0.5,1.5);
    ratioplot->GetYaxis()->SetNdivisions(011);
    if (xAxisMin < xAxisMax) {
      //subpad_2->Update();  // to be done after Draw() to access pad parameters such as default axis range  
      ratioplot->GetXaxis()->SetRangeUser(xAxisMin,xAxisMax);
    }
    ratioplot->SetMarkerStyle(8);  //medium dot
    ratioplot->DrawCopy("E");  

  }

  c->SaveAs( (plotDirectoryPath + c->GetName() + plotFileExtension).c_str() );

}
Example #25
0
void fastEfficiencyNadir(unsigned int iEG, int iECAL1, int iColl1, int iECAL2, int iColl2,
			 TString dirIn="/home/llr/cms/ndaci/SKWork/macro/skEfficiency/tagAndProbe/EfficiencyStudy/SingEle-May10ReReco/UPDATE2/Tag80Probe95/", 
			 TString lumi="200 pb", int nCPU=4, 
			 int color1=kBlack, int style1=kFullCircle, int color2=kRed, int style2=kOpenSquare,
			 TString probe="WP80", TString tag="WP80", TString fileIn="tree_effi_TagProbe.root")
{
  // STYLE //
  gROOT->Reset();
  loadPresentationStyle();  
  gROOT->ForceStyle();

  // EG THRESHOLDS //
  const int nEG = 71;
  double thres[nEG];
  for(int i=0 ; i<nEG ; i++) thres[i]=i;

  TString names[nEG];
  ostringstream ossi;
  for(int i=0;i<(int)nEG;i++) {
    ossi.str("");
    ossi << thres[i] ;
    names[i] = ossi.str();
  }

  // NAMES //
  const int nECAL=2;
  const int nColl=2;

  TString name_leg_ecal[nECAL] = {"Barrel","Endcaps"};
  TString name_leg_coll[nColl] = {"Online","Emulation"};  

  TString name_ecal[nECAL] = {"_EB","_EE"};
  TString name_coll[nColl] = {"_N","_M"};

  TString dirResults = dirIn + "/turnons/EG"+names[iEG]+"/" ;
  TString name_image = 
    dirResults + "eff_EG"+names[iEG]+"_tag"+tag+"_probe"+probe+name_ecal[iECAL1]+name_coll[iColl1]+"_vs"+name_ecal[iECAL2]+name_coll[iColl2] ;

  // Output log //
  ofstream fichier(name_image+".txt", ios::out);


  // BINNING //
  const int nbins[nEG] = {29,29,29,29,21,21,21,22,22,21,22,21,22,18,19,18,18,18,18,20,20,20,20,19,20,20,20,20,21,21,
			  21,21,21,21,21,21,21,21,21,21, //EG30
			  22,22,22,22,22,22,22,22,22,22, //EG40
			  29,29,29,29,29,29,29,29,29,29, //EG50
			  29,29,29,29,29,29,29,29,29,29};//EG60

  Double_t bins_0[29] = {1,1.5,1.8,2,2.2,2.4,2.6,2.8, 3, 3.5, 4,4.2,4.5,4.7,5,5.5,6,6.5,7,7.5,8,8.5,9,10,12,15,20,50,150};// EG0
  Double_t bins_1[29] = {1,1.5,1.8,2,2.2,2.4,2.6,2.8, 3, 3.5, 4,4.2,4.5,4.7,5,5.5,6,6.5,7,7.5,8,8.5,9,10,12,15,20,50,150};// EG1
  Double_t bins_2[29] = {1,1.5,1.8,2,2.2,2.4,2.6,2.8, 3, 3.5, 4,4.2,4.5,4.7,5,5.5,6,6.5,7,7.5,8,8.5,9,10,12,15,20,50,150};// EG2 
  Double_t bins_3[29] = {1,1.5,1.8,2,2.2,2.4,2.6,2.8, 3, 3.5, 4,4.2,4.5,4.7,5,5.5,6,6.5,7,7.5,8,8.5,9,10,12,15,20,50,150};// EG3

  Double_t bins_4[21] = {1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 15, 17, 19, 21, 27, 32, 41, 50, 60, 70, 150}; // EG4
  Double_t bins_5[21] = {2, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20, 22, 24, 31, 40, 50, 60, 70, 150}; // EG5
  Double_t bins_6[21] = {3, 4, 5, 6, 7, 8, 9, 11, 13, 15, 17, 19, 21, 23, 27, 32, 41, 50, 60, 70, 150}; // EG6

  Double_t bins_7[22] = {2, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20, 22, 24, 26, 31, 40, 50, 60, 70, 150}; // EG7
  Double_t bins_8[22] = {3, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 21, 23, 25, 27, 32, 41, 50, 60, 70, 150}; // EG8
  Double_t bins_9[21] = {4, 6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 31, 40, 50, 60, 70, 150}; // EG9

  Double_t bins_10[22] = {5, 7, 8, 9, 10, 11, 12, 13, 15, 17, 19, 21, 23, 25, 27, 29, 32, 41, 50, 60, 70, 150}; // EG10
  Double_t bins_11[21] = {6, 8, 9, 10, 11, 12, 13, 14, 16, 18, 20, 22, 24, 26, 28, 31, 40, 50, 60, 70, 150}; // EG11
  Double_t bins_12[22] = {5, 7, 9, 10, 11, 12, 13, 14, 15, 17, 19, 21, 23, 25, 27, 29, 32, 41, 50, 60, 70, 150}; // EG12

  Double_t bins_13[18] = {5, 7, 9, 11, 12, 13, 14, 15, 17, 19, 22, 25, 29, 37, 50, 60, 70, 150}; // EG13
  Double_t bins_14[19] = {6, 8, 10, 12, 13, 14, 15, 16, 18, 20, 22, 25, 30, 35, 40, 50, 60, 70, 150}; // EG14
  Double_t bins_15[18] = {5, 7, 9, 11, 13, 14, 15, 16, 17, 19, 22, 25, 29, 37, 50, 60, 70, 150}; // EG15

  Double_t bins_16[18] = {8, 10, 12, 14, 16, 17, 18, 19, 20, 22, 25, 30, 35, 40, 50, 60, 70, 150}; // EG16
  Double_t bins_17[18] = {9, 11, 13, 15, 16, 17, 18, 19, 21, 23, 25, 30, 35, 40, 50, 60, 70, 150}; // EG17
  Double_t bins_18[18] = {8, 10, 12, 14, 16, 17, 18, 19, 20, 22, 25, 30, 35, 40, 50, 60, 70, 150}; // EG18

  Double_t bins_19[20] = {9, 11, 13, 15, 17, 18, 19, 20, 21, 23, 25, 27, 30, 35, 40, 45, 50, 60, 70, 150}; // EG19
  Double_t bins_20[20] = {8, 10, 12, 14, 16, 18, 19, 20, 21, 22, 24, 26, 30, 35, 40, 45, 50, 60, 70, 100}; // EG20
  Double_t bins_21[20] = {9, 11, 13, 15, 17, 19, 20, 21, 22, 23, 25, 27, 30, 35, 40, 45, 50, 60, 70, 150}; // EG21

  Double_t bins_22[20] = {10, 12, 14, 16, 18, 20, 21, 22, 23, 24, 26, 28, 30, 35, 40, 45, 50, 60, 70, 150}; // EG22
  Double_t bins_23[19] = {11, 13, 15, 17, 19, 21, 22, 23, 24, 25, 27, 30, 35, 40, 45, 50, 60, 70, 150}; // EG23
  Double_t bins_24[20] = {10, 12, 14, 16, 18, 20, 22, 23, 24, 25, 26, 28, 30, 35, 40, 45, 50, 60, 70, 150}; // EG24

  Double_t bins_25[20] = {11, 13, 15, 17, 19, 21, 23, 24, 25, 26, 27, 29, 30, 35, 40, 45, 50, 60, 70, 150}; // EG25
  Double_t bins_26[20] = {10, 12, 14, 16, 18, 20, 22, 24, 25, 26, 27, 28, 30, 35, 40, 45, 50, 60, 70, 150}; // EG26
  Double_t bins_27[20] = {11, 13, 15, 17, 19, 21, 23, 25, 26, 27, 28, 29, 33, 35, 40, 45, 50, 60, 70, 150}; // EG27

  Double_t bins_28[21] = {10, 12, 14, 16, 18, 20, 22, 24, 26, 27, 28, 29, 30, 32, 35, 40, 45, 50, 60, 70, 150}; // EG28
  Double_t bins_29[21] = {11, 13, 15, 17, 19, 21, 23, 25, 27, 28, 29, 30, 31, 33, 35, 40, 45, 50, 60, 70, 150}; // EG29
  Double_t bins_30[21] = {10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 29, 30, 31, 32, 35, 40, 45, 50, 60, 70, 150}; // EG30

  Double_t bins_40[22] = {10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 38, 39, 40, 42, 45, 50, 60, 70, 150}; // EG40
  Double_t bins_50[29] = {10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 48, 50, 55, 60, 70, 90, 110, 130, 150, 170, 190}; // EG50
  Double_t bins_60[29] = {10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 48, 50, 55, 60, 70, 90, 110, 130, 150, 170, 190}; // EG60

  vector< Double_t* > bins;
  bins.push_back( bins_0 ); bins.push_back( bins_1 ); bins.push_back( bins_2 ); bins.push_back( bins_3 ); bins.push_back( bins_4 ); 
  bins.push_back( bins_5 ); bins.push_back( bins_6 ); bins.push_back( bins_7 ); bins.push_back( bins_8 ); bins.push_back( bins_9 ); 
  bins.push_back( bins_10 ); bins.push_back( bins_11 ); bins.push_back( bins_12 ); bins.push_back( bins_13 ); bins.push_back( bins_14 ); 
  bins.push_back( bins_15 ); bins.push_back( bins_16 ); bins.push_back( bins_17 ); bins.push_back( bins_18 ); bins.push_back( bins_19 ); 
  bins.push_back( bins_20 ); bins.push_back( bins_21 ); bins.push_back( bins_22 ); bins.push_back( bins_23 ); bins.push_back( bins_24 ); 
  bins.push_back( bins_25 ); bins.push_back( bins_26 ); bins.push_back( bins_27 ); bins.push_back( bins_28 ); bins.push_back( bins_29 ); 

  for(int iV=0 ; iV<10 ; iV++) bins.push_back( bins_30 );
  for(int iV=0 ; iV<10 ; iV++) bins.push_back( bins_40 );
  for(int iV=0 ; iV<10 ; iV++) bins.push_back( bins_50 );
  for(int iV=0 ; iV<10 ; iV++) bins.push_back( bins_60 );

  RooBinning binning = RooBinning(nbins[iEG]-1, bins[iEG], "binning");


  // INPUT DATA //
  TFile* f1 = TFile::Open(dirIn+"/"+fileIn);

  TTree* treenew;
  TTree* treenew_2;

  treenew = (TTree*) gDirectory->Get( "treenew"+name_ecal[iECAL1]+name_coll[iColl1] ) ;
  treenew_2 = (TTree*) gDirectory->Get( "treenew"+name_ecal[iECAL2]+name_coll[iColl2] ) ;

  TString name_scet[2], name_scdr[2], name_l1bin[2];
  name_scet[0] = "sc_et"+name_ecal[iECAL1]+name_coll[iColl1];
  name_scet[1] = "sc_et"+name_ecal[iECAL2]+name_coll[iColl2];
  name_scdr[0] = "sc_dr"+name_ecal[iECAL1]+name_coll[iColl1];
  name_scdr[1] = "sc_dr"+name_ecal[iECAL2]+name_coll[iColl2];
  
  name_l1bin[0] = "l1_"+names[iEG]+name_ecal[iECAL1]+name_coll[iColl1];
  name_l1bin[1] = "l1_"+names[iEG]+name_ecal[iECAL2]+name_coll[iColl2];

  RooRealVar et_plot(name_scet[0],name_scet[0],0,150) ;
  RooRealVar dr(name_scdr[0],name_scdr[0],0.5,1.5) ; 
  RooRealVar et_plot2(name_scet[1],name_scet[1],0,150) ;
  RooRealVar dr2(name_scdr[1],name_scdr[1],0.5,1.5) ;

  // Acceptance state cut (1 or 0)
  RooCategory cut(name_l1bin[0],name_l1bin[0]) ;
  cut.defineType("accept",1) ;
  cut.defineType("reject",0) ;
  RooCategory cut2(name_l1bin[1],name_l1bin[1]) ;
  cut2.defineType("accept",1) ;
  cut2.defineType("reject",0) ;
  
  // PARAMETRES ROOFIT CRYSTAL BALL
  RooRealVar norm("norm","N",1,0.6,1);
  RooRealVar alpha("alpha","#alpha",0.671034,0.01,8);
  RooRealVar n("n","n",4.07846,1.1,35);
  RooRealVar mean("mean","mean",20.8,0,100);
  //mean.setVal(thres[iEG]);
  RooRealVar sigma("sigma","#sigma",0.972825,0.01,5);
  //RooRealVar pedestal("pedestal","pedestal",0.01,0,0.4);

  RooRealVar norm2("norm2","N",0.999069,0.6,1);
  RooRealVar alpha2("alpha2","#alpha",0.492303,0.01,8);
  RooRealVar n2("n2","n",11.6694,1.1,35);
  RooRealVar mean2("mean2","mean",21.4582,0,100);
  //mean2.setVal(thres[iEG]);
  RooRealVar sigma2("sigma2","#sigma",1.19,0.01,5);
  //RooRealVar pedestal2("pedestal2","pedestal",0.01,0,0.4);

  FuncCB cb("cb","Crystal Ball Integree",et_plot,mean,sigma,alpha,n,norm) ;
  FuncCB cb2("cb2","Crystal Ball Integree",et_plot2,mean2,sigma2,alpha2,n2,norm2) ;
  
  // EFFICIENCY //
  RooEfficiency eff("eff","efficiency",cb,cut,"accept");
  RooEfficiency eff2("eff2","efficiency",cb2,cut2,"accept");

  // DATASETS //
  RooDataSet dataSet("data","data",RooArgSet(et_plot, cut,dr),Import(*treenew)); 
  RooDataSet dataSet2("data2","data2",RooArgSet(et_plot2, cut2,dr2),Import(*treenew_2));

  dataSet.Print();
  dataSet2.Print();
  
  // PLOT //
  RooPlot* frame = et_plot.frame(Bins(18000),Title("Fitted efficiency")) ;
  RooPlot* frame2 = et_plot2.frame(Bins(18000),Title("Fitted efficiency")) ;

  dataSet.plotOn(frame, Binning(binning), Efficiency(cut), MarkerColor(color1), LineColor(color1), MarkerStyle(style1) );
  dataSet2.plotOn(frame2, Binning(binning), Efficiency(cut2), MarkerColor(color2), LineColor(color2), MarkerStyle(style2) );


  /////////////////////// FITTING /////////////////////////////

  double fit_cuts_min = thres[iEG]-1.5 ;
  double fit_cuts_max = 150;

  et_plot.setRange("interesting",fit_cuts_min,fit_cuts_max);
  et_plot2.setRange("interesting",fit_cuts_min,fit_cuts_max);

  RooFitResult* roofitres1 = new RooFitResult("roofitres1","roofitres1");
  RooFitResult* roofitres2 = new RooFitResult("roofitres2","roofitres2");

  fichier << "Fit characteristics :"   << endl ;
  fichier << "EG "     << names[iEG] << endl ;
  fichier << "Fit Range , EB Coll : [" << fit_cuts_min << "," << fit_cuts_max << "]" << endl ;
  fichier << "Fit Range , EE Coll : [" << fit_cuts_min << "," << fit_cuts_max << "]" << endl ;
  fichier << "----------------------"  << endl ;

  // Fit #1 //
  roofitres1 = eff.fitTo(dataSet,ConditionalObservables(et_plot),Range("interesting"),Minos(kTRUE),Warnings(kFALSE),NumCPU(nCPU),Save(kTRUE));
  
  cb.plotOn(frame,LineColor(color1),LineWidth(2));

  double res_norm1  = norm.getVal();
  double err_norm1  = norm.getErrorLo();
  double res_mean1  = mean.getVal();
  double err_mean1  = mean.getError();
  double res_sigma1 = sigma.getVal();
  double err_sigma1 = sigma.getError();
  double res_n1     = n.getVal();
  double err_n1     = n.getError();
  double res_alpha1 = alpha.getVal();
  double err_alpha1 = alpha.getError();

  fichier << "<----------------- EB ----------------->" << endl
	  << "double res_mean="  << res_mean1  << "; "
	  << "double res_sigma=" << res_sigma1 << "; "
          << "double res_alpha=" << res_alpha1 << "; "
          << "double res_n="     << res_n1     << "; "
          << "double res_norm="  << res_norm1  << "; "
	  << endl
	  << "double err_mean="  << err_mean1  << "; "
	  << "double err_sigma=" << err_sigma1 << "; "
          << "double err_alpha=" << err_alpha1 << "; "
          << "double err_n="     << err_n1     << "; "
          << "double err_norm="  << err_norm1  << "; "
	  << endl;

  // Fit #2 //
  roofitres2 = eff2.fitTo(dataSet2,ConditionalObservables(et_plot2),Range("interesting"),Minos(kTRUE),Warnings(kFALSE),NumCPU(nCPU),Save(kTRUE));
 
  cb2.plotOn(frame2,LineColor(color2),LineWidth(2));

  double res_norm2  = norm2.getVal();
  double err_norm2  = norm2.getErrorLo();
  double res_mean2  = mean2.getVal();
  double err_mean2  = mean2.getError();
  double res_sigma2 = sigma2.getVal();
  double err_sigma2 = sigma2.getError();
  double res_n2     = n2.getVal();
  double err_n2     = n2.getError();
  double res_alpha2 = alpha2.getVal();
  double err_alpha2 = alpha2.getError();

  fichier << "<----------------- EE ----------------->" << endl
	  << "double res_mean="  << res_mean2  << "; "
	  << "double res_sigma=" << res_sigma2 << "; "
	  << "double res_alpha=" << res_alpha2 << "; "
	  << "double res_n="     << res_n2     << "; "
	  << "double res_norm="  << res_norm2  << "; "
	  << endl
	  << "double err_mean="  << err_mean2  << "; "
	  << "double err_sigma=" << err_sigma2 << "; "
	  << "double err_alpha=" << err_alpha2 << "; "
	  << "double err_n="     << err_n2     << "; "
	  << "double err_norm="  << err_norm2  << "; "
	  << endl;
    

  ////////////////////////////  DRAWING PLOTS AND LEGENDS /////////////////////////////////
  TCanvas* ca = new TCanvas("ca","Trigger Efficiency") ;

  ca->SetGridx();
  ca->SetGridy();
  ca->cd();
  
  gPad->SetLogx();
  gPad->SetObjectStat(1);

  frame->GetYaxis()->SetRangeUser(0,1.05);
  frame->GetXaxis()->SetRangeUser(1,100.);
  frame->GetYaxis()->SetTitle("Efficiency");
  frame->GetXaxis()->SetTitle("E_{T} [GeV]");
  frame->Draw() ;

  frame2->GetYaxis()->SetRangeUser(0,1.05);
  frame2->GetXaxis()->SetRangeUser(1,100.);
  frame2->GetYaxis()->SetTitle("Efficiency");
  frame2->GetXaxis()->SetTitle("E_{T} [GeV]");
  frame2->Draw("same") ;

  TH1F *SCeta1 = new TH1F("SCeta1","SCeta1",50,-2.5,2.5);
  TH1F *SCeta2 = new TH1F("SCeta2","SCeta2",50,-2.5,2.5);

  SCeta1->SetLineColor(color1) ;
  SCeta1->SetMarkerColor(color1);
  SCeta1->SetMarkerStyle(style1);

  SCeta2->SetLineColor(color2) ;
  SCeta2->SetMarkerColor(color2);
  SCeta2->SetMarkerStyle(style2);

  TLegend *leg = new TLegend(0.246,0.435,0.461,0.560,NULL,"brNDC"); // mid : x=353.5
  leg->SetLineColor(1);
  leg->SetTextColor(1);
  leg->SetTextFont(42);
  leg->SetTextSize(0.03);
  leg->SetShadowColor(kWhite);
  leg->SetFillColor(kWhite);
  leg->SetMargin(0.25);
  TLegendEntry *entry=leg->AddEntry("NULL","L1_SingleEG"+names[iEG],"h");
//   leg->AddEntry(SCeta1,name_leg_ecal[iECAL1]+" "+name_leg_coll[iColl1],"p");
//   leg->AddEntry(SCeta2,name_leg_ecal[iECAL2]+" "+name_leg_coll[iColl2],"p");
  leg->AddEntry(SCeta1,name_leg_ecal[iECAL1],"p");
  leg->AddEntry(SCeta2,name_leg_ecal[iECAL2],"p");
  leg->Draw();

  leg = new TLegend(0.16,0.725,0.58,0.905,NULL,"brNDC");
  leg->SetBorderSize(0);
  leg->SetTextFont(62);
  leg->SetTextSize(0.03);
  leg->SetLineColor(0);
  leg->SetLineStyle(1);
  leg->SetLineWidth(1);
  leg->SetFillColor(0);
  leg->SetFillStyle(0);
  leg->AddEntry("NULL","CMS Preliminary 2012 pp  #sqrt{s}=8 TeV","h");
  leg->AddEntry("NULL","#int L dt = "+lumi+"^{-1}","h");
  leg->AddEntry("NULL","Threshold : "+names[iEG]+" GeV","h");
  leg->Draw();

  TPaveText *pt2 = new TPaveText(0.220,0.605,0.487,0.685,"brNDC"); // mid : x=353.5                                          
  pt2->SetLineColor(1);
  pt2->SetTextColor(1);
  pt2->SetTextFont(42);
  pt2->SetTextSize(0.03);
  pt2->SetFillColor(kWhite);
  pt2->SetShadowColor(kWhite);
  pt2->AddText("L1 E/Gamma Trigger");
  pt2->AddText("Electrons from Z");
  pt2->Draw();
  
  //TString name_image="eff_EG20_2012_12fb";

  ca->Print(name_image+".cxx","cxx");
  ca->Print(name_image+".png","png");
  ca->Print(name_image+".gif","gif");
  ca->Print(name_image+".pdf","pdf");
  ca->Print(name_image+".ps","ps");
  ca->Print(name_image+".eps","eps");

  /////////////////////////////
  // SAVE THE ROO FIT RESULT //
  /////////////////////////////

  RooWorkspace *w = new RooWorkspace("workspace","workspace") ;

  w->import(dataSet);
  w->import(dataSet2);
  
  w->import(*roofitres1,"roofitres1");
  w->import(*roofitres2,"roofitres2");

  cout << "CREATES WORKSPACE : " << endl;
  w->Print();
  
  w->writeToFile(name_image+"_fitres.root") ;
  //gDirectory->Add(w) ;

  //f1->Close();
}
void ComparisonOldAndNewPi0PbPb(TString suffix = "pdf"){
   gROOT->Reset();   
   gROOT->SetStyle("Plain");
   
   
   StyleSettingsThesis();  
   SetPlotStyle();

   Color_t  colorCombPbPb0005          = kRed+1;
   Color_t  colorCombPbPb0010          = kRed+1;
   Color_t  colorCombPbPb0510          = 807;
   Color_t  colorCombPbPb1020          = 800;
   Color_t  colorCombPbPb2040          = kGreen+2;
   Color_t  colorCombPbPb4060          = kCyan+2;
   Color_t  colorCombPbPb6080          = kBlue+1;

   Color_t  colorCombMCPbPb0005           = kRed+3;
   Color_t  colorCombMCPbPb0010           = kRed+3;
   Color_t  colorCombMCPbPb0510           = 807+2;
   Color_t  colorCombMCPbPb1020           = 800+2;
   Color_t  colorCombMCPbPb2040           = kGreen+4;
   Color_t  colorCombMCPbPb4060           = kCyan+4;
   Color_t  colorCombMCPbPb6080           = kBlue+3;

   Style_t  markerStylePbPb0005  = 20 ;
   Style_t  markerStylePbPb0010  = 20 ;
   Style_t  markerStylePbPb0510  = 21 ;
   Style_t  markerStylePbPb1020  = 29 ;
   Style_t  markerStylePbPb2040  = 33 ;
   Style_t  markerStylePbPb4060  = 20 ;
   Style_t  markerStylePbPb6080  = 21 ;

   Style_t  markerStylePbPb0005MC   = 24 ;
   Style_t  markerStylePbPb0010MC   = 24 ;
   Style_t  markerStylePbPb0510MC   = 25 ;
   Style_t  markerStylePbPb1020MC   = 30 ;
   Style_t  markerStylePbPb2040MC   = 27 ;
   Style_t  markerStylePbPb4060MC   = 24 ;
   Style_t  markerStylePbPb6080MC   = 25 ;
   
   Size_t   markerSizePbPb0005   = 2.;
   Size_t   markerSizePbPb0010   = 2.;
   Size_t   markerSizePbPb0510   = 2.;
   Size_t   markerSizePbPb1020   = 2.5;
   Size_t   markerSizePbPb2040   = 2.5;
   Size_t   markerSizePbPb4060   = 2.;
   Size_t   markerSizePbPb6080   = 2.;
    
   TString collisionSystemPbPb0005 = "0-5% Pb-Pb #sqrt{#it{s}_{_{NN}}} = 2.76 TeV";      
   TString collisionSystemPbPb0510 = "5-10% Pb-Pb #sqrt{#it{s}_{_{NN}}} = 2.76 TeV";     
   TString collisionSystemPbPb1020 = "10-20% Pb-Pb #sqrt{#it{s}_{_{NN}}} = 2.76 TeV";    
   TString collisionSystemPbPb0010 = "0-10% Pb-Pb #sqrt{#it{s}_{_{NN}}} = 2.76 TeV";     
   TString collisionSystemPbPb2040 = "20-40% Pb-Pb #sqrt{#it{s}_{_{NN}}} = 2.76 TeV";    
   TString collisionSystemPbPb4060 = "40-60% Pb-Pb #sqrt{#it{s}_{_{NN}}} = 2.76 TeV";    
   TString collisionSystemPbPb6080 = "60-80% Pb-Pb #sqrt{#it{s}_{_{NN}}} = 2.76 TeV";    
   TString collisionSystemPbPb0020 = "0-20% Pb-Pb #sqrt{#it{s}_{_{NN}}} = 2.76 TeV";     
   TString collisionSystemPbPb0080 = "0-80% Pb-Pb #sqrt{#it{s}_{_{NN}}} = 2.76 TeV";     
   TString collisionSystemPbPb0040 = "0-40% Pb-Pb #sqrt{#it{s}_{_{NN}}} = 2.76 TeV";     
   TString collisionSystemPbPb4080 = "40-80% Pb-Pb #sqrt{#it{s}_{_{NN}}} = 2.76 TeV";     
    
   
   //**************************************************************************************************************************
   //**************************************** Read files before weighting *****************************************************
   //**************************************************************************************************************************
   TFile*   filePCMPbPb0thIteration =              new TFile("/home/fredi/Photon/Results/PbPbTests/data_PCMResults_PbPb_2.76TeV_0thIterationRerun.root");
   cout << "0-5%" << endl;
   TDirectory* directory0thIterationPi0PbPb0005 =  (TDirectory*)filePCMPbPb0thIteration->Get("Pi0_PbPb_2.76TeV_0-5%");   
   TH1D* histo0thIterationTrueEffiPt0005 =        (TH1D*)directory0thIterationPi0PbPb0005->Get("Pi0_Efficiency");
   TH1D* histo0thIterationTrueEffiPtFit0005 =     (TH1D*)directory0thIterationPi0PbPb0005->Get("Pi0_EfficiencyFitted");

   cout << "0-10%" << endl;
   TDirectory* directory0thIterationPi0PbPb0010 =           (TDirectory*)filePCMPbPb0thIteration->Get("Pi0_PbPb_2.76TeV_0-10%"); 
   TH1D* histo0thIterationTrueEffiPt0010 =        (TH1D*)directory0thIterationPi0PbPb0010->Get("Pi0_Efficiency");
   TH1D* histo0thIterationTrueEffiPtFit0010 =     (TH1D*)directory0thIterationPi0PbPb0010->Get("Pi0_EfficiencyFitted");
   
   cout << "5-10%" << endl;
   TDirectory* directory0thIterationPi0PbPb0510 =           (TDirectory*)filePCMPbPb0thIteration->Get("Pi0_PbPb_2.76TeV_5-10%"); 
   TH1D* histo0thIterationTrueEffiPt0510 =        (TH1D*)directory0thIterationPi0PbPb0510->Get("Pi0_Efficiency");
   TH1D* histo0thIterationTrueEffiPtFit0510 =     (TH1D*)directory0thIterationPi0PbPb0510->Get("Pi0_EfficiencyFitted");
   
   cout << "10-20%" << endl;
   TDirectory* directory0thIterationPi0PbPb1020 =           (TDirectory*)filePCMPbPb0thIteration->Get("Pi0_PbPb_2.76TeV_10-20%"); 
   TH1D* histo0thIterationTrueEffiPt1020 =        (TH1D*)directory0thIterationPi0PbPb1020->Get("Pi0_Efficiency");
   TH1D* histo0thIterationTrueEffiPtFit1020 =     (TH1D*)directory0thIterationPi0PbPb1020->Get("Pi0_EfficiencyFitted");
   
   cout << "20-40%" << endl;
   TDirectory* directory0thIterationPi0PbPb2040 =           (TDirectory*)filePCMPbPb0thIteration->Get("Pi0_PbPb_2.76TeV_20-40%"); 
   TH1D* histo0thIterationTrueEffiPt2040 =        (TH1D*)directory0thIterationPi0PbPb2040->Get("Pi0_Efficiency");
   TH1D* histo0thIterationTrueEffiPtFit2040 =     (TH1D*)directory0thIterationPi0PbPb2040->Get("Pi0_EfficiencyFitted");
   
   cout << "40-60%" << endl;
   TDirectory* directory0thIterationPi0PbPb4060 =           (TDirectory*)filePCMPbPb0thIteration->Get("Pi0_PbPb_2.76TeV_40-60%"); 
   TH1D* histo0thIterationTrueEffiPt4060 =        (TH1D*)directory0thIterationPi0PbPb4060->Get("Pi0_Efficiency");
   TH1D* histo0thIterationTrueEffiPtFit4060 =     (TH1D*)directory0thIterationPi0PbPb4060->Get("Pi0_EfficiencyFitted");
   
   cout << "60-80%" << endl;
   TDirectory* directory0thIterationPi0PbPb6080 =           (TDirectory*)filePCMPbPb0thIteration->Get("Pi0_PbPb_2.76TeV_60-80%");
   TH1D* histo0thIterationTrueEffiPt6080 =        (TH1D*)directory0thIterationPi0PbPb6080->Get("Pi0_Efficiency");
   TH1D* histo0thIterationTrueEffiPtFit6080 =     (TH1D*)directory0thIterationPi0PbPb6080->Get("Pi0_EfficiencyFitted");

   TFile*   filePCMPbPb0thIterationNewMC =              new TFile("/home/fredi/Photon/Results/PbPbNewMCTest/0thIteration/data_PCMResults_PbPb_2.76TeV_TPCMultNewMCWeighted0thIteration.root");
   cout << "0-5%" << endl;
   TDirectory* directory0thIterationNewMCPi0PbPb0005 =  (TDirectory*)filePCMPbPb0thIterationNewMC->Get("Pi0_PbPb_2.76TeV_0-5%");   
   TH1D* histo0thIterationNewMCTrueEffiPt0005 =        (TH1D*)directory0thIterationNewMCPi0PbPb0005->Get("Pi0_Efficiency");

   cout << "0-10%" << endl;
   TDirectory* directory0thIterationNewMCPi0PbPb0010 =           (TDirectory*)filePCMPbPb0thIterationNewMC->Get("Pi0_PbPb_2.76TeV_0-10%"); 
   TH1D* histo0thIterationNewMCTrueEffiPt0010 =        (TH1D*)directory0thIterationNewMCPi0PbPb0010->Get("Pi0_Efficiency");
   
   cout << "5-10%" << endl;
   TDirectory* directory0thIterationNewMCPi0PbPb0510 =           (TDirectory*)filePCMPbPb0thIterationNewMC->Get("Pi0_PbPb_2.76TeV_5-10%"); 
   TH1D* histo0thIterationNewMCTrueEffiPt0510 =        (TH1D*)directory0thIterationNewMCPi0PbPb0510->Get("Pi0_Efficiency");
   
   cout << "10-20%" << endl;
   TDirectory* directory0thIterationNewMCPi0PbPb1020 =           (TDirectory*)filePCMPbPb0thIterationNewMC->Get("Pi0_PbPb_2.76TeV_10-20%"); 
   TH1D* histo0thIterationNewMCTrueEffiPt1020 =        (TH1D*)directory0thIterationNewMCPi0PbPb1020->Get("Pi0_Efficiency");
   
   cout << "20-40%" << endl;
   TDirectory* directory0thIterationNewMCPi0PbPb2040 =           (TDirectory*)filePCMPbPb0thIterationNewMC->Get("Pi0_PbPb_2.76TeV_20-40%"); 
   TH1D* histo0thIterationNewMCTrueEffiPt2040 =        (TH1D*)directory0thIterationNewMCPi0PbPb2040->Get("Pi0_Efficiency");
   
   cout << "40-60%" << endl;
   TDirectory* directory0thIterationNewMCPi0PbPb4060 =           (TDirectory*)filePCMPbPb0thIterationNewMC->Get("Pi0_PbPb_2.76TeV_40-60%"); 
   TH1D* histo0thIterationNewMCTrueEffiPt4060 =        (TH1D*)directory0thIterationNewMCPi0PbPb4060->Get("Pi0_Efficiency");
   
   cout << "60-80%" << endl;
   TDirectory* directory0thIterationNewMCPi0PbPb6080 =           (TDirectory*)filePCMPbPb0thIterationNewMC->Get("Pi0_PbPb_2.76TeV_60-80%");
   TH1D* histo0thIterationNewMCTrueEffiPt6080 =        (TH1D*)directory0thIterationNewMCPi0PbPb6080->Get("Pi0_Efficiency");
  

   
   //**************************************************************************************************************************
   //**************************************** Read files after weighting *****************************************************
   //**************************************************************************************************************************
   
   TFile*   filePCMPbPb2ndIteration =              new TFile("/home/fredi/Photon/Results/PbPbNewMCTest/data_PCMResults_PbPb_2.76TeV_TPCMultNewMCWeighted2ndIteration.root");
   cout << "0-5%" << endl;
   TDirectory* directory2ndIterationPi0PbPb0005 =  (TDirectory*)filePCMPbPb2ndIteration->Get("Pi0_PbPb_2.76TeV_0-5%");   
   TH1D* histo2ndIterationTrueEffiPt0005 =        (TH1D*)directory2ndIterationPi0PbPb0005->Get("Pi0_Efficiency");
   TH1D* histoPi02ndIterationWeights0005 = (TH1D*)directory2ndIterationPi0PbPb0005->Get("Pi0_HIJING_Weights");
   
   cout << "0-10%" << endl;
   TDirectory* directory2ndIterationPi0PbPb0010 =           (TDirectory*)filePCMPbPb2ndIteration->Get("Pi0_PbPb_2.76TeV_0-10%"); 
   TH1D* histo2ndIterationTrueEffiPt0010 =        (TH1D*)directory2ndIterationPi0PbPb0010->Get("Pi0_Efficiency");
   TH1D* histoPi02ndIterationWeights0010 = (TH1D*)directory2ndIterationPi0PbPb0010->Get("Pi0_HIJING_Weights");
   
   cout << "5-10%" << endl;
   TDirectory* directory2ndIterationPi0PbPb0510 =           (TDirectory*)filePCMPbPb2ndIteration->Get("Pi0_PbPb_2.76TeV_5-10%"); 
   TH1D* histo2ndIterationTrueEffiPt0510 =        (TH1D*)directory2ndIterationPi0PbPb0510->Get("Pi0_Efficiency");
   TH1D* histoPi02ndIterationWeights0510 = (TH1D*)directory2ndIterationPi0PbPb0510->Get("Pi0_HIJING_Weights");
   cout << "10-20%" << endl;
   TDirectory* directory2ndIterationPi0PbPb1020 =           (TDirectory*)filePCMPbPb2ndIteration->Get("Pi0_PbPb_2.76TeV_10-20%"); 
   TH1D* histo2ndIterationTrueEffiPt1020 =        (TH1D*)directory2ndIterationPi0PbPb1020->Get("Pi0_Efficiency");
   TH1D* histoPi02ndIterationWeights1020 = (TH1D*)directory2ndIterationPi0PbPb1020->Get("Pi0_HIJING_Weights");
   cout << "20-40%" << endl;
   TDirectory* directory2ndIterationPi0PbPb2040 =           (TDirectory*)filePCMPbPb2ndIteration->Get("Pi0_PbPb_2.76TeV_20-40%"); 
   TH1D* histo2ndIterationTrueEffiPt2040 =        (TH1D*)directory2ndIterationPi0PbPb2040->Get("Pi0_Efficiency");
   TH1D* histoPi02ndIterationWeights2040 = (TH1D*)directory2ndIterationPi0PbPb2040->Get("Pi0_HIJING_Weights");
   cout << "40-60%" << endl;
   TDirectory* directory2ndIterationPi0PbPb4060 =           (TDirectory*)filePCMPbPb2ndIteration->Get("Pi0_PbPb_2.76TeV_40-60%"); 
   TH1D* histo2ndIterationTrueEffiPt4060 =        (TH1D*)directory2ndIterationPi0PbPb4060->Get("Pi0_Efficiency");
   TH1D* histoPi02ndIterationWeights4060 = (TH1D*)directory2ndIterationPi0PbPb4060->Get("Pi0_HIJING_Weights");
   cout << "60-80%" << endl;
   TDirectory* directory2ndIterationPi0PbPb6080 =           (TDirectory*)filePCMPbPb2ndIteration->Get("Pi0_PbPb_2.76TeV_60-80%");
   TH1D* histo2ndIterationTrueEffiPt6080 =        (TH1D*)directory2ndIterationPi0PbPb6080->Get("Pi0_Efficiency");
   TH1D* histoPi02ndIterationWeights6080 = (TH1D*)directory2ndIterationPi0PbPb6080->Get("Pi0_HIJING_Weights");
   
   TFile*   filePCMPbPb2ndIterationAddSig0005 =              new TFile("601000104209297002322000000_01522045009000/PbPb_2.76TeV/Pi0_MC_GammaConvV1CorrectionHistosAddSig_601000104209297002322000000_01522045009000.root");
   TH1D* histoPi02ndIterationWeightsAddSig0005 = (TH1D*)filePCMPbPb2ndIterationAddSig0005->Get("MC_Meson_genPt_Weights");
   TFile*   filePCMPbPb2ndIterationAddSig0510 =              new TFile("612000104209297002322000000_01522045009000/PbPb_2.76TeV/Pi0_MC_GammaConvV1CorrectionHistosAddSig_612000104209297002322000000_01522045009000.root");
   TH1D* histoPi02ndIterationWeightsAddSig0510 = (TH1D*)filePCMPbPb2ndIterationAddSig0510->Get("MC_Meson_genPt_Weights");
   TFile*   filePCMPbPb2ndIterationAddSig1020 =              new TFile("512000104209297002322000000_01522045009000/PbPb_2.76TeV/Pi0_MC_GammaConvV1CorrectionHistosAddSig_512000104209297002322000000_01522045009000.root");
   TH1D* histoPi02ndIterationWeightsAddSig1020 = (TH1D*)filePCMPbPb2ndIterationAddSig1020->Get("MC_Meson_genPt_Weights");
   TFile*   filePCMPbPb2ndIterationAddSig2040 =              new TFile("524000104209297002322000000_01522045009000/PbPb_2.76TeV/Pi0_MC_GammaConvV1CorrectionHistosAddSig_524000104209297002322000000_01522045009000.root");
   TH1D* histoPi02ndIterationWeightsAddSig2040 = (TH1D*)filePCMPbPb2ndIterationAddSig2040->Get("MC_Meson_genPt_Weights");
   TFile*   filePCMPbPb2ndIterationAddSig4060 =              new TFile("546000104209297002322000000_01522065009000/PbPb_2.76TeV/Pi0_MC_GammaConvV1CorrectionHistosAddSig_546000104209297002322000000_01522065009000.root");
   TH1D* histoPi02ndIterationWeightsAddSig4060 = (TH1D*)filePCMPbPb2ndIterationAddSig4060->Get("MC_Meson_genPt_Weights");
   TFile*   filePCMPbPb2ndIterationAddSig6080 =              new TFile("568000104209297002322000000_01522065009000/PbPb_2.76TeV/Pi0_MC_GammaConvV1CorrectionHistosAddSig_568000104209297002322000000_01522065009000.root");
   TH1D* histoPi02ndIterationWeightsAddSig6080 = (TH1D*)filePCMPbPb2ndIterationAddSig6080->Get("MC_Meson_genPt_Weights");
   
      
   TCanvas* canvasFraction2 = new TCanvas("canvasFraction2","",1550,1200);  // gives the page size
   canvasFraction2->SetTickx();
   canvasFraction2->SetTicky();
   canvasFraction2->SetGridx(0);
   canvasFraction2->SetGridy(0);
   canvasFraction2->SetLogy(0);
   canvasFraction2->SetLeftMargin(0.13);
   canvasFraction2->SetRightMargin(0.02);
   canvasFraction2->SetTopMargin(0.02);
   canvasFraction2->SetFillColor(0);
   canvasFraction2->cd();
   
   TH1D* histoRatioEffi2ndIteDiv0thIte0005= (TH1D*)histo2ndIterationTrueEffiPt0005->Clone("histoRatioEffi2ndIteDiv0thIte0005");
   histoRatioEffi2ndIteDiv0thIte0005->Divide(histo2ndIterationTrueEffiPt0005, histo0thIterationNewMCTrueEffiPt0005, 1. ,1., "");
   TH1D* histoRatioEffi2ndIteDiv0thIte0510= (TH1D*)histo2ndIterationTrueEffiPt0510->Clone("histoRatioEffi2ndIteDiv0thIte0510");
   histoRatioEffi2ndIteDiv0thIte0510->Divide(histo2ndIterationTrueEffiPt0510, histo0thIterationNewMCTrueEffiPt0510, 1. ,1., "");
   TH1D* histoRatioEffi2ndIteDiv0thIte1020= (TH1D*)histo2ndIterationTrueEffiPt1020->Clone("histoRatioEffi2ndIteDiv0thIte1020");
   histoRatioEffi2ndIteDiv0thIte1020->Divide(histo2ndIterationTrueEffiPt1020, histo0thIterationNewMCTrueEffiPt1020, 1. ,1., "");
   TH1D* histoRatioEffi2ndIteDiv0thIte2040= (TH1D*)histo2ndIterationTrueEffiPt2040->Clone("histoRatioEffi2ndIteDiv0thIte2040");
   histoRatioEffi2ndIteDiv0thIte2040->Divide(histo2ndIterationTrueEffiPt2040, histo0thIterationNewMCTrueEffiPt2040, 1. ,1., "");
   TH1D* histoRatioEffi2ndIteDiv0thIte4060= (TH1D*)histo2ndIterationTrueEffiPt4060->Clone("histoRatioEffi2ndIteDiv0thIte4060");
   histoRatioEffi2ndIteDiv0thIte4060->Divide(histo2ndIterationTrueEffiPt4060, histo0thIterationNewMCTrueEffiPt4060, 1. ,1., "");
   TH1D* histoRatioEffi2ndIteDiv0thIte6080= (TH1D*)histo2ndIterationTrueEffiPt6080->Clone("histoRatioEffi2ndIteDiv0thIte6080");
   histoRatioEffi2ndIteDiv0thIte6080->Divide(histo2ndIterationTrueEffiPt6080, histo0thIterationNewMCTrueEffiPt6080, 1. ,1., "");
 
   
   canvasFraction2->cd();
   if (histoRatioEffi2ndIteDiv0thIte6080) DrawGammaSetMarker(histoRatioEffi2ndIteDiv0thIte6080, markerStylePbPb6080MC,markerSizePbPb6080, colorCombPbPb6080 , colorCombPbPb6080 );
   if (histoRatioEffi2ndIteDiv0thIte0005) DrawGammaSetMarker(histoRatioEffi2ndIteDiv0thIte0005, markerStylePbPb0005MC,markerSizePbPb0005, colorCombPbPb0005 , colorCombPbPb0005 );
   if (histoRatioEffi2ndIteDiv0thIte0510) DrawGammaSetMarker(histoRatioEffi2ndIteDiv0thIte0510, markerStylePbPb0510MC,markerSizePbPb0510, colorCombPbPb0510 , colorCombPbPb0510 );
   if (histoRatioEffi2ndIteDiv0thIte1020) DrawGammaSetMarker(histoRatioEffi2ndIteDiv0thIte1020, markerStylePbPb1020MC,markerSizePbPb1020, colorCombPbPb1020 , colorCombPbPb1020 );
   if (histoRatioEffi2ndIteDiv0thIte2040) DrawGammaSetMarker(histoRatioEffi2ndIteDiv0thIte2040, markerStylePbPb2040MC,markerSizePbPb2040, colorCombPbPb2040 , colorCombPbPb2040 );
   if (histoRatioEffi2ndIteDiv0thIte4060) DrawGammaSetMarker(histoRatioEffi2ndIteDiv0thIte4060, markerStylePbPb4060MC,markerSizePbPb4060, colorCombPbPb4060 , colorCombPbPb4060 );
   DrawAutoGammaMesonHistos( histoRatioEffi2ndIteDiv0thIte6080,
               "", "p_{T} (GeV/c)", "Effi 2nd Iteration of weighting/ no weighting, New MC",
               kFALSE, 1.5, 0, kTRUE,
               kTRUE, 0.5, 1.5,
               kTRUE, 0., 7.9);
   if (histoRatioEffi2ndIteDiv0thIte0005)histoRatioEffi2ndIteDiv0thIte0005->Draw("same,e,p");
//    if (histoRatioEffi2ndIteDiv0thIte0510)histoRatioEffi2ndIteDiv0thIte0510->Draw("same,e,p");  
   if (histoRatioEffi2ndIteDiv0thIte1020)histoRatioEffi2ndIteDiv0thIte1020->Draw("same,e,p");  
//    if (histoRatioEffi2ndIteDiv0thIte2040)histoRatioEffi2ndIteDiv0thIte2040->Draw("same,e,p");  
//    if (histoRatioEffi2ndIteDiv0thIte4060)histoRatioEffi2ndIteDiv0thIte4060->Draw("same,e,p");  
   
   TLegend* legendCompEffiDifferentWeighting = new TLegend(0.16,0.11,0.4,0.3);
   legendCompEffiDifferentWeighting->SetFillColor(0);
   legendCompEffiDifferentWeighting->SetLineColor(0);
   legendCompEffiDifferentWeighting->SetTextSize(0.025);
//    legendCompEffiDifferentWeighting->SetNColumns(3);
   legendCompEffiDifferentWeighting->SetMargin(0.2);
   if (histoRatioEffi2ndIteDiv0thIte0005)legendCompEffiDifferentWeighting->AddEntry(histoRatioEffi2ndIteDiv0thIte0005,Form("%s",collisionSystemPbPb0005.Data()),"p");
//    if (histoRatioEffi2ndIteDiv0thIte0510)legendCompEffiDifferentWeighting->AddEntry(histoRatioEffi2ndIteDiv0thIte0510,Form("%s",collisionSystemPbPb0510.Data()),"p");
   if (histoRatioEffi2ndIteDiv0thIte1020)legendCompEffiDifferentWeighting->AddEntry(histoRatioEffi2ndIteDiv0thIte1020,Form("%s",collisionSystemPbPb1020.Data()),"p");
//    if (histoRatioEffi2ndIteDiv0thIte2040)legendCompEffiDifferentWeighting->AddEntry(histoRatioEffi2ndIteDiv0thIte2040,Form("%s",collisionSystemPbPb2040.Data()),"p");
//    if (histoRatioEffi2ndIteDiv0thIte4060)legendCompEffiDifferentWeighting->AddEntry(histoRatioEffi2ndIteDiv0thIte4060,Form("%s",collisionSystemPbPb4060.Data()),"p");
   if (histoRatioEffi2ndIteDiv0thIte6080)legendCompEffiDifferentWeighting->AddEntry(histoRatioEffi2ndIteDiv0thIte6080,Form("%s",collisionSystemPbPb6080.Data()),"p");
   legendCompEffiDifferentWeighting->Draw();
   
   DrawGammaLines(0., 30.,1., 1.,0.1);
   canvasFraction2->Update();
   canvasFraction2->SaveAs(Form("RatioEffiFinalWeightsDivNoWeights.%s",suffix.Data()));

   TH1D* histoRatioEffiNewMCDivOldMC0005= (TH1D*)histo0thIterationNewMCTrueEffiPt0005->Clone("histoRatioEffiNewMCDivOldMC0005");
   histoRatioEffiNewMCDivOldMC0005->Divide(histo0thIterationNewMCTrueEffiPt0005, histo0thIterationTrueEffiPt0005, 1. ,1., "");
   TH1D* histoRatioEffiNewMCDivOldMC0510= (TH1D*)histo0thIterationNewMCTrueEffiPt0510->Clone("histoRatioEffiNewMCDivOldMC0510");
   histoRatioEffiNewMCDivOldMC0510->Divide(histo0thIterationNewMCTrueEffiPt0510, histo0thIterationTrueEffiPt0510, 1. ,1., "");
   TH1D* histoRatioEffiNewMCDivOldMC1020= (TH1D*)histo0thIterationNewMCTrueEffiPt1020->Clone("histoRatioEffiNewMCDivOldMC1020");
   histoRatioEffiNewMCDivOldMC1020->Divide(histo0thIterationNewMCTrueEffiPt1020, histo0thIterationTrueEffiPt1020, 1. ,1., "");
   TH1D* histoRatioEffiNewMCDivOldMC2040= (TH1D*)histo0thIterationNewMCTrueEffiPt2040->Clone("histoRatioEffiNewMCDivOldMC2040");
   histoRatioEffiNewMCDivOldMC2040->Divide(histo0thIterationNewMCTrueEffiPt2040, histo0thIterationTrueEffiPt2040, 1. ,1., "");
   TH1D* histoRatioEffiNewMCDivOldMC4060= (TH1D*)histo0thIterationNewMCTrueEffiPt4060->Clone("histoRatioEffiNewMCDivOldMC4060");
   histoRatioEffiNewMCDivOldMC4060->Divide(histo0thIterationNewMCTrueEffiPt4060, histo0thIterationTrueEffiPt4060, 1. ,1., "");
   TH1D* histoRatioEffiNewMCDivOldMC6080= (TH1D*)histo0thIterationNewMCTrueEffiPt6080->Clone("histoRatioEffiNewMCDivOldMC6080");
   histoRatioEffiNewMCDivOldMC6080->Divide(histo0thIterationNewMCTrueEffiPt6080, histo0thIterationTrueEffiPt6080, 1. ,1., "");
 
   
   canvasFraction2->cd();
   if (histoRatioEffiNewMCDivOldMC6080) DrawGammaSetMarker(histoRatioEffiNewMCDivOldMC6080, markerStylePbPb6080MC,markerSizePbPb6080, colorCombPbPb6080 , colorCombPbPb6080 );
   if (histoRatioEffiNewMCDivOldMC0005) DrawGammaSetMarker(histoRatioEffiNewMCDivOldMC0005, markerStylePbPb0005MC,markerSizePbPb0005, colorCombPbPb0005 , colorCombPbPb0005 );
   if (histoRatioEffiNewMCDivOldMC0510) DrawGammaSetMarker(histoRatioEffiNewMCDivOldMC0510, markerStylePbPb0510MC,markerSizePbPb0510, colorCombPbPb0510 , colorCombPbPb0510 );
   if (histoRatioEffiNewMCDivOldMC1020) DrawGammaSetMarker(histoRatioEffiNewMCDivOldMC1020, markerStylePbPb1020MC,markerSizePbPb1020, colorCombPbPb1020 , colorCombPbPb1020 );
   if (histoRatioEffiNewMCDivOldMC2040) DrawGammaSetMarker(histoRatioEffiNewMCDivOldMC2040, markerStylePbPb2040MC,markerSizePbPb2040, colorCombPbPb2040 , colorCombPbPb2040 );
   if (histoRatioEffiNewMCDivOldMC4060) DrawGammaSetMarker(histoRatioEffiNewMCDivOldMC4060, markerStylePbPb4060MC,markerSizePbPb4060, colorCombPbPb4060 , colorCombPbPb4060 );
   DrawAutoGammaMesonHistos( histoRatioEffiNewMCDivOldMC6080,
               "", "p_{T} (GeV/c)", "Effi New MC/ Old MC, wo weighting",
               kFALSE, 1.5, 0, kTRUE,
               kTRUE, 0.5, 1.5,
               kTRUE, 0., 7.9);
   if (histoRatioEffiNewMCDivOldMC0005)histoRatioEffiNewMCDivOldMC0005->Draw("same,e,p");
//    if (histoRatioEffiNewMCDivOldMC0510)histoRatioEffiNewMCDivOldMC0510->Draw("same,e,p");  
   if (histoRatioEffiNewMCDivOldMC1020)histoRatioEffiNewMCDivOldMC1020->Draw("same,e,p");  
//    if (histoRatioEffiNewMCDivOldMC2040)histoRatioEffiNewMCDivOldMC2040->Draw("same,e,p");  
//    if (histoRatioEffiNewMCDivOldMC4060)histoRatioEffiNewMCDivOldMC4060->Draw("same,e,p");  
   
   TLegend* legendCompEffiDifferentMC = new TLegend(0.16,0.11,0.4,0.3);
   legendCompEffiDifferentMC->SetFillColor(0);
   legendCompEffiDifferentMC->SetLineColor(0);
   legendCompEffiDifferentMC->SetTextSize(0.025);
//    legendCompEffiDifferentMC->SetNColumns(3);
   legendCompEffiDifferentMC->SetMargin(0.2);
   if (histoRatioEffiNewMCDivOldMC0005)legendCompEffiDifferentMC->AddEntry(histoRatioEffiNewMCDivOldMC0005,Form("%s",collisionSystemPbPb0005.Data()),"p");
//    if (histoRatioEffiNewMCDivOldMC0510)legendCompEffiDifferentMC->AddEntry(histoRatioEffiNewMCDivOldMC0510,Form("%s",collisionSystemPbPb0510.Data()),"p");
   if (histoRatioEffiNewMCDivOldMC1020)legendCompEffiDifferentMC->AddEntry(histoRatioEffiNewMCDivOldMC1020,Form("%s",collisionSystemPbPb1020.Data()),"p");
//    if (histoRatioEffiNewMCDivOldMC2040)legendCompEffiDifferentMC->AddEntry(histoRatioEffiNewMCDivOldMC2040,Form("%s",collisionSystemPbPb2040.Data()),"p");
//    if (histoRatioEffiNewMCDivOldMC4060)legendCompEffiDifferentMC->AddEntry(histoRatioEffiNewMCDivOldMC4060,Form("%s",collisionSystemPbPb4060.Data()),"p");
   if (histoRatioEffiNewMCDivOldMC6080)legendCompEffiDifferentMC->AddEntry(histoRatioEffiNewMCDivOldMC6080,Form("%s",collisionSystemPbPb6080.Data()),"p");
   legendCompEffiDifferentMC->Draw();
   
   DrawGammaLines(0., 30.,1., 1.,0.1);
   canvasFraction2->Update();
   canvasFraction2->SaveAs(Form("RatioEffiNewDivOldMC.%s",suffix.Data()));

   
//    TH1D* histoRatioNewDivOld0005= (TH1D*)histo2ndIterationTrueEffiPt0005->Clone("histoRatioNewDivOld0005");
//    histoRatioNewDivOld0005->Divide(histo2ndIterationTrueEffiPt0005, histo0thIterationTrueEffiPtFit0005, 1. ,1., "B");
//    TH1D* histoRatioNewDivOld0510= (TH1D*)histo2ndIterationTrueEffiPt0510->Clone("histoRatioNewDivOld0510");
//    histoRatioNewDivOld0510->Divide(histo2ndIterationTrueEffiPt0510, histo0thIterationTrueEffiPtFit0510, 1. ,1., "B");
//    TH1D* histoRatioNewDivOld1020= (TH1D*)histo2ndIterationTrueEffiPt1020->Clone("histoRatioNewDivOld1020");
//    histoRatioNewDivOld1020->Divide(histo2ndIterationTrueEffiPt1020, histo0thIterationTrueEffiPtFit1020, 1. ,1., "B");
//    TH1D* histoRatioNewDivOld2040= (TH1D*)histo2ndIterationTrueEffiPt2040->Clone("histoRatioNewDivOld2040");
//    histoRatioNewDivOld2040->Divide(histo2ndIterationTrueEffiPt2040, histo0thIterationTrueEffiPtFit2040, 1. ,1., "B");
//    TH1D* histoRatioNewDivOld4060= (TH1D*)histo2ndIterationTrueEffiPt4060->Clone("histoRatioNewDivOld4060");
//    histoRatioNewDivOld4060->Divide(histo2ndIterationTrueEffiPt4060, histo0thIterationTrueEffiPtFit4060, 1. ,1., "B");
//    TH1D* histoRatioNewDivOld6080= (TH1D*)histo2ndIterationTrueEffiPt6080->Clone("histoRatioNewDivOld6080");
//    histoRatioNewDivOld6080->Divide(histo2ndIterationTrueEffiPt6080, histo0thIterationTrueEffiPtFit6080, 1. ,1., "B");
//    
//    
//    canvasFraction2->cd();
//    if (histoRatioNewDivOld6080) DrawGammaSetMarker(histoRatioNewDivOld6080, markerStylePbPb6080MC,markerSizePbPb6080, colorCombPbPb6080 , colorCombPbPb6080 );
//    if (histoRatioNewDivOld0005) DrawGammaSetMarker(histoRatioNewDivOld0005, markerStylePbPb0005MC,markerSizePbPb0005, colorCombPbPb0005 , colorCombPbPb0005 );
//    if (histoRatioNewDivOld0510) DrawGammaSetMarker(histoRatioNewDivOld0510, markerStylePbPb0510MC,markerSizePbPb0510, colorCombPbPb0510 , colorCombPbPb0510 );
//    if (histoRatioNewDivOld1020) DrawGammaSetMarker(histoRatioNewDivOld1020, markerStylePbPb1020MC,markerSizePbPb1020, colorCombPbPb1020 , colorCombPbPb1020 );
//    if (histoRatioNewDivOld2040) DrawGammaSetMarker(histoRatioNewDivOld2040, markerStylePbPb2040MC,markerSizePbPb2040, colorCombPbPb2040 , colorCombPbPb2040 );
//    if (histoRatioNewDivOld4060) DrawGammaSetMarker(histoRatioNewDivOld4060, markerStylePbPb4060MC,markerSizePbPb4060, colorCombPbPb4060 , colorCombPbPb4060 );
//    DrawAutoGammaMesonHistos( histoRatioNewDivOld6080,
//                "", "p_{T} (GeV/c)", "Effi final/ fitted no weighting",
//                kFALSE, 1.5, 0, kTRUE,
//                kTRUE, 0.5, 1.5,
//                kTRUE, 0., 7.9);
//    if (histoRatioNewDivOld0005)histoRatioNewDivOld0005->Draw("same,e,p");
//    if (histoRatioNewDivOld0510)histoRatioNewDivOld0510->Draw("same,e,p");  
//    if (histoRatioNewDivOld1020)histoRatioNewDivOld1020->Draw("same,e,p");  
//    if (histoRatioNewDivOld2040)histoRatioNewDivOld2040->Draw("same,e,p");  
//    if (histoRatioNewDivOld4060)histoRatioNewDivOld4060->Draw("same,e,p");  
//    
//    TLegend* legendCompEffiFinalDivOld = new TLegend(0.16,0.11,0.4,0.3);
//    legendCompEffiFinalDivOld->SetFillColor(0);
//    legendCompEffiFinalDivOld->SetLineColor(0);
//    legendCompEffiFinalDivOld->SetTextSize(0.025);
// //    legendCompEffiFinalDivOld->SetNColumns(3);
//    legendCompEffiFinalDivOld->SetMargin(0.2);
//    if (histoRatioNewDivOld0005)legendCompEffiFinalDivOld->AddEntry(histoRatioNewDivOld0005,Form("%s",collisionSystemPbPb0005.Data()),"p");
//    if (histoRatioNewDivOld0510)legendCompEffiFinalDivOld->AddEntry(histoRatioNewDivOld0510,Form("%s",collisionSystemPbPb0510.Data()),"p");
//    if (histoRatioNewDivOld1020)legendCompEffiFinalDivOld->AddEntry(histoRatioNewDivOld1020,Form("%s",collisionSystemPbPb1020.Data()),"p");
//    if (histoRatioNewDivOld2040)legendCompEffiFinalDivOld->AddEntry(histoRatioNewDivOld2040,Form("%s",collisionSystemPbPb2040.Data()),"p");
//    if (histoRatioNewDivOld4060)legendCompEffiFinalDivOld->AddEntry(histoRatioNewDivOld4060,Form("%s",collisionSystemPbPb4060.Data()),"p");
//    if (histoRatioNewDivOld6080)legendCompEffiFinalDivOld->AddEntry(histoRatioNewDivOld6080,Form("%s",collisionSystemPbPb6080.Data()),"p");
//    legendCompEffiFinalDivOld->Draw();
//    
//    DrawGammaLines(0., 30.,1., 1.,0.1);
//    canvasFraction2->Update();
//    canvasFraction2->SaveAs(Form("RatioEffiFinalDivNoWeightsFitted.%s",suffix.Data()));
   
   canvasFraction2->cd();
   if (histoPi02ndIterationWeights6080) DrawGammaSetMarker(histoPi02ndIterationWeights6080, markerStylePbPb6080MC,markerSizePbPb6080, colorCombPbPb6080 , colorCombPbPb6080 );
   if (histoPi02ndIterationWeights0005) DrawGammaSetMarker(histoPi02ndIterationWeights0005, markerStylePbPb0005MC,markerSizePbPb0005, colorCombPbPb0005 , colorCombPbPb0005 );
   if (histoPi02ndIterationWeights0510) DrawGammaSetMarker(histoPi02ndIterationWeights0510, markerStylePbPb0510MC,markerSizePbPb0510, colorCombPbPb0510 , colorCombPbPb0510 );
   if (histoPi02ndIterationWeights1020) DrawGammaSetMarker(histoPi02ndIterationWeights1020, markerStylePbPb1020MC,markerSizePbPb1020, colorCombPbPb1020 , colorCombPbPb1020 );
   if (histoPi02ndIterationWeights2040) DrawGammaSetMarker(histoPi02ndIterationWeights2040, markerStylePbPb2040MC,markerSizePbPb2040, colorCombPbPb2040 , colorCombPbPb2040 );
   if (histoPi02ndIterationWeights4060) DrawGammaSetMarker(histoPi02ndIterationWeights4060, markerStylePbPb4060MC,markerSizePbPb4060, colorCombPbPb4060 , colorCombPbPb4060 );
   DrawAutoGammaMesonHistos( histoPi02ndIterationWeights6080,
               "", "p_{T} (GeV/c)", "Weights",
               kFALSE, 1.5, 0, kTRUE,
               kTRUE, 0., 3.,
               kTRUE, 0., 7.9);
   if (histoPi02ndIterationWeights0005)histoPi02ndIterationWeights0005->Draw("same,e,p");
   if (histoPi02ndIterationWeights0510)histoPi02ndIterationWeights0510->Draw("same,e,p");  
   if (histoPi02ndIterationWeights1020)histoPi02ndIterationWeights1020->Draw("same,e,p");  
   if (histoPi02ndIterationWeights2040)histoPi02ndIterationWeights2040->Draw("same,e,p");  
   if (histoPi02ndIterationWeights4060)histoPi02ndIterationWeights4060->Draw("same,e,p");  
   
   TLegend* legendWeights = new TLegend(0.56,0.71,0.95,0.95);
   legendWeights->SetFillColor(0);
   legendWeights->SetLineColor(0);
   legendWeights->SetTextSize(0.025);
//    legendWeights->SetNColumns(3);
   legendWeights->SetMargin(0.2);
   if (histoPi02ndIterationWeights0005)legendWeights->AddEntry(histoPi02ndIterationWeights0005,Form("%s",collisionSystemPbPb0005.Data()),"p");
   if (histoPi02ndIterationWeights0510)legendWeights->AddEntry(histoPi02ndIterationWeights0510,Form("%s",collisionSystemPbPb0510.Data()),"p");
   if (histoPi02ndIterationWeights1020)legendWeights->AddEntry(histoPi02ndIterationWeights1020,Form("%s",collisionSystemPbPb1020.Data()),"p");
   if (histoPi02ndIterationWeights2040)legendWeights->AddEntry(histoPi02ndIterationWeights2040,Form("%s",collisionSystemPbPb2040.Data()),"p");
   if (histoPi02ndIterationWeights4060)legendWeights->AddEntry(histoPi02ndIterationWeights4060,Form("%s",collisionSystemPbPb4060.Data()),"p");
   if (histoPi02ndIterationWeights6080)legendWeights->AddEntry(histoPi02ndIterationWeights6080,Form("%s",collisionSystemPbPb6080.Data()),"p");
   legendWeights->Draw();
   
   DrawGammaLines(0., 30.,1., 1.,0.1);
   canvasFraction2->Update();
   canvasFraction2->SaveAs(Form("Weights2ndIteration.%s",suffix.Data()));
   
   canvasFraction2->cd();
   canvasFraction2->SetLogy();
   if (histoPi02ndIterationWeightsAddSig6080) DrawGammaSetMarker(histoPi02ndIterationWeightsAddSig6080, markerStylePbPb6080MC,markerSizePbPb6080, colorCombPbPb6080 , colorCombPbPb6080 );
   if (histoPi02ndIterationWeightsAddSig0005) DrawGammaSetMarker(histoPi02ndIterationWeightsAddSig0005, markerStylePbPb0005MC,markerSizePbPb0005, colorCombPbPb0005 , colorCombPbPb0005 );
   if (histoPi02ndIterationWeightsAddSig0510) DrawGammaSetMarker(histoPi02ndIterationWeightsAddSig0510, markerStylePbPb0510MC,markerSizePbPb0510, colorCombPbPb0510 , colorCombPbPb0510 );
   if (histoPi02ndIterationWeightsAddSig1020) DrawGammaSetMarker(histoPi02ndIterationWeightsAddSig1020, markerStylePbPb1020MC,markerSizePbPb1020, colorCombPbPb1020 , colorCombPbPb1020 );
   if (histoPi02ndIterationWeightsAddSig2040) DrawGammaSetMarker(histoPi02ndIterationWeightsAddSig2040, markerStylePbPb2040MC,markerSizePbPb2040, colorCombPbPb2040 , colorCombPbPb2040 );
   if (histoPi02ndIterationWeightsAddSig4060) DrawGammaSetMarker(histoPi02ndIterationWeightsAddSig4060, markerStylePbPb4060MC,markerSizePbPb4060, colorCombPbPb4060 , colorCombPbPb4060 );
   DrawAutoGammaMesonHistos( histoPi02ndIterationWeightsAddSig6080,
               "", "p_{T} (GeV/c)", "Weights Added Signals",
               kFALSE, 1.5, 0, kTRUE,
               kTRUE, 1e-3, 1e5,
               kTRUE, 0., 7.9);
   if (histoPi02ndIterationWeightsAddSig0005)histoPi02ndIterationWeightsAddSig0005->Draw("same,e,p");
   if (histoPi02ndIterationWeightsAddSig0510)histoPi02ndIterationWeightsAddSig0510->Draw("same,e,p");  
   if (histoPi02ndIterationWeightsAddSig1020)histoPi02ndIterationWeightsAddSig1020->Draw("same,e,p");  
   if (histoPi02ndIterationWeightsAddSig2040)histoPi02ndIterationWeightsAddSig2040->Draw("same,e,p");  
   if (histoPi02ndIterationWeightsAddSig4060)histoPi02ndIterationWeightsAddSig4060->Draw("same,e,p");  
   
   TLegend* legendWeightsAddSig = new TLegend(0.56,0.71,0.95,0.95);
   legendWeightsAddSig->SetFillColor(0);
   legendWeightsAddSig->SetLineColor(0);
   legendWeightsAddSig->SetTextSize(0.025);
//    legendWeights->SetNColumns(3);
   legendWeightsAddSig->SetMargin(0.2);
   if (histoPi02ndIterationWeightsAddSig0005)legendWeightsAddSig->AddEntry(histoPi02ndIterationWeightsAddSig0005,Form("%s",collisionSystemPbPb0005.Data()),"p");
   if (histoPi02ndIterationWeightsAddSig0510)legendWeightsAddSig->AddEntry(histoPi02ndIterationWeightsAddSig0510,Form("%s",collisionSystemPbPb0510.Data()),"p");
   if (histoPi02ndIterationWeightsAddSig1020)legendWeightsAddSig->AddEntry(histoPi02ndIterationWeightsAddSig1020,Form("%s",collisionSystemPbPb1020.Data()),"p");
   if (histoPi02ndIterationWeightsAddSig2040)legendWeightsAddSig->AddEntry(histoPi02ndIterationWeightsAddSig2040,Form("%s",collisionSystemPbPb2040.Data()),"p");
   if (histoPi02ndIterationWeightsAddSig4060)legendWeightsAddSig->AddEntry(histoPi02ndIterationWeightsAddSig4060,Form("%s",collisionSystemPbPb4060.Data()),"p");
   if (histoPi02ndIterationWeightsAddSig6080)legendWeightsAddSig->AddEntry(histoPi02ndIterationWeightsAddSig6080,Form("%s",collisionSystemPbPb6080.Data()),"p");
   legendWeightsAddSig->Draw();
   
   DrawGammaLines(0., 30.,1., 1.,0.1);
   canvasFraction2->Update();
   canvasFraction2->SaveAs(Form("Weights2ndIterationAddSig.%s",suffix.Data()));
   
   
//    TH1D* histoRatio5thDiv2ndIte0005= (TH1D*)histo2ndIterationTrueEffiPt0005->Clone("histoRatio5thDiv2ndIte0005");
//    histoRatio5thDiv2ndIte0005->Divide(histo5thIterationTrueEffiPt0005, histo2ndIterationTrueEffiPtFit0005, 1. ,1., "B");
//    TH1D* histoRatio5thDiv2ndIte0510= (TH1D*)histo2ndIterationTrueEffiPt0510->Clone("histoRatio5thDiv2ndIte0510");
//    histoRatio5thDiv2ndIte0510->Divide(histo5thIterationTrueEffiPt0510, histo2ndIterationTrueEffiPtFit0510, 1. ,1., "B");
//    TH1D* histoRatio5thDiv2ndIte1020= (TH1D*)histo2ndIterationTrueEffiPt1020->Clone("histoRatio5thDiv2ndIte1020");
//    histoRatio5thDiv2ndIte1020->Divide(histo5thIterationTrueEffiPt1020, histo2ndIterationTrueEffiPtFit1020, 1. ,1., "B");
//    TH1D* histoRatio5thDiv2ndIte2040= (TH1D*)histo2ndIterationTrueEffiPt2040->Clone("histoRatio5thDiv2ndIte2040");
//    histoRatio5thDiv2ndIte2040->Divide(histo5thIterationTrueEffiPt2040, histo2ndIterationTrueEffiPtFit2040, 1. ,1., "B");
//    TH1D* histoRatio5thDiv2ndIte4060= (TH1D*)histo2ndIterationTrueEffiPt4060->Clone("histoRatio5thDiv2ndIte4060");
//    histoRatio5thDiv2ndIte4060->Divide(histo5thIterationTrueEffiPt4060, histo2ndIterationTrueEffiPtFit4060, 1. ,1., "B");
//    TH1D* histoRatio5thDiv2ndIte6080= (TH1D*)histo2ndIterationTrueEffiPt6080->Clone("histoRatio5thDiv2ndIte6080");
//    histoRatio5thDiv2ndIte6080->Divide(histo5thIterationTrueEffiPt6080, histo2ndIterationTrueEffiPtFit6080, 1. ,1., "B");
//    
//    
//    canvasFraction2->cd();
//    if (histoRatio5thDiv2ndIte6080) DrawGammaSetMarker(histoRatio5thDiv2ndIte6080, markerStylePbPb6080MC,markerSizePbPb6080, colorCombPbPb6080 , colorCombPbPb6080 );
//    if (histoRatio5thDiv2ndIte0005) DrawGammaSetMarker(histoRatio5thDiv2ndIte0005, markerStylePbPb0005MC,markerSizePbPb0005, colorCombPbPb0005 , colorCombPbPb0005 );
//    if (histoRatio5thDiv2ndIte0510) DrawGammaSetMarker(histoRatio5thDiv2ndIte0510, markerStylePbPb0510MC,markerSizePbPb0510, colorCombPbPb0510 , colorCombPbPb0510 );
//    if (histoRatio5thDiv2ndIte1020) DrawGammaSetMarker(histoRatio5thDiv2ndIte1020, markerStylePbPb1020MC,markerSizePbPb1020, colorCombPbPb1020 , colorCombPbPb1020 );
//    if (histoRatio5thDiv2ndIte2040) DrawGammaSetMarker(histoRatio5thDiv2ndIte2040, markerStylePbPb2040MC,markerSizePbPb2040, colorCombPbPb2040 , colorCombPbPb2040 );
//    if (histoRatio5thDiv2ndIte4060) DrawGammaSetMarker(histoRatio5thDiv2ndIte4060, markerStylePbPb4060MC,markerSizePbPb4060, colorCombPbPb4060 , colorCombPbPb4060 );
//    DrawAutoGammaMesonHistos( histoRatio5thDiv2ndIte6080,
//                "", "p_{T} (GeV/c)", "possible additional systematic error",
//                kFALSE, 1.5, 0, kTRUE,
//                kTRUE, 0.5, 1.5,
//                kTRUE, 0., 7.9);
//    if (histoRatio5thDiv2ndIte0005)histoRatio5thDiv2ndIte0005->Draw("same,e,p");
//    if (histoRatio5thDiv2ndIte0510)histoRatio5thDiv2ndIte0510->Draw("same,e,p");  
//    if (histoRatio5thDiv2ndIte1020)histoRatio5thDiv2ndIte1020->Draw("same,e,p");  
//    if (histoRatio5thDiv2ndIte2040)histoRatio5thDiv2ndIte2040->Draw("same,e,p");  
//    if (histoRatio5thDiv2ndIte4060)histoRatio5thDiv2ndIte4060->Draw("same,e,p");  
//    
//    TLegend* legendPossAddSyst = new TLegend(0.16,0.11,0.4,0.3);
//    legendPossAddSyst->SetFillColor(0);
//    legendPossAddSyst->SetLineColor(0);
//    legendPossAddSyst->SetTextSize(0.025);
// //    legendPossAddSyst->SetNColumns(3);
//    legendPossAddSyst->SetMargin(0.2);
//    if (histoRatio5thDiv2ndIte0005)legendPossAddSyst->AddEntry(histoRatio5thDiv2ndIte0005,Form("%s",collisionSystemPbPb0005.Data()),"p");
//    if (histoRatio5thDiv2ndIte0510)legendPossAddSyst->AddEntry(histoRatio5thDiv2ndIte0510,Form("%s",collisionSystemPbPb0510.Data()),"p");
//    if (histoRatio5thDiv2ndIte1020)legendPossAddSyst->AddEntry(histoRatio5thDiv2ndIte1020,Form("%s",collisionSystemPbPb1020.Data()),"p");
//    if (histoRatio5thDiv2ndIte2040)legendPossAddSyst->AddEntry(histoRatio5thDiv2ndIte2040,Form("%s",collisionSystemPbPb2040.Data()),"p");
//    if (histoRatio5thDiv2ndIte4060)legendPossAddSyst->AddEntry(histoRatio5thDiv2ndIte4060,Form("%s",collisionSystemPbPb4060.Data()),"p");
//    if (histoRatio5thDiv2ndIte6080)legendPossAddSyst->AddEntry(histoRatio5thDiv2ndIte6080,Form("%s",collisionSystemPbPb6080.Data()),"p");
//    legendPossAddSyst->Draw();
//    
//    DrawGammaLines(0., 30.,1., 1.,0.1);
//    canvasFraction2->Update();
//    canvasFraction2->SaveAs(Form("RatioOf5thDiv2ndIteration.%s",suffix.Data()));
   
  
//    Double_t fMesonPlotRange[2] = {0., 0.2};
//    
//    
//   TCanvas *c1 = new TCanvas("PCM","InvMass",0,0,600*1.2,600);
//   c1->SetRightMargin(0.03);
//   c1->SetTopMargin(0.05);
//   c1->SetLeftMargin(0.12);
//   c1->SetBottomMargin(0.13);
//   c1->cd();
//   
//   DrawGammaHisto( histoPi00thIterationInvMassBin9_0005,
//              "2.0 GeV/c < p_{T} < 2.2 GeV/c",
//              "M_{#gamma#gamma} (GeV/c^{2})","dN_{#gamma#gamma}/dM_{#gamma#gamma}",
//              fMesonPlotRange[0],fMesonPlotRange[1],0);
//   histoPi02ndIterationInvMassBin9_0005->SetLineColor(kRed+2);
//   histoPi02ndIterationInvMassBin9_0005->Draw("hist,e,same");
//   
//   TLatex *labelMassPi00005 = new TLatex(0.15,0.88,collisionSystemPbPb0005.Data());
//    SetStyleTLatex( labelMassPi00005, 0.035,4);
//    labelMassPi00005->Draw();
//    TLegend* legendInvMass = new TLegend(0.15,0.76,0.35,0.84);
//    legendInvMass->SetFillColor(0);
//    legendInvMass->SetLineColor(0);
//    legendInvMass->SetTextSize(0.025);
// //    legendInvMass->SetNColumns(3);
//    legendInvMass->SetMargin(0.2);
//    legendInvMass->AddEntry((TObject*)0, "2.0 GeV/c < p_{T} < 2.2 GeV/c","");
//    legendInvMass->AddEntry(histoPi00thIterationInvMassBin9_0005,"no weighting","l");
//    legendInvMass->AddEntry(histoPi02ndIterationInvMassBin9_0005,"2nd iteration reweighted","l");
//    legendInvMass->Draw();
//   
// 
//   c1->SaveAs(Form("InvMass_2000MeV-2200MeV_0005.%s",suffix.Data()));
//   
//    c1->cd();
//    DrawGammaHisto( histoPi00thIterationInvMassBin9_0510,
//              "2.0 GeV/c < p_{T} < 2.2 GeV/c",
//              "M_{#gamma#gamma} (GeV/c^{2})","dN_{#gamma#gamma}/dM_{#gamma#gamma}",
//              fMesonPlotRange[0],fMesonPlotRange[1],0);
//    histoPi02ndIterationInvMassBin9_0510->SetLineColor(kRed+2);
//    histoPi02ndIterationInvMassBin9_0510->Draw("hist,e,same");
//   
//    TLatex *labelMassPi00510 = new TLatex(0.15,0.88,collisionSystemPbPb0510.Data());
//    SetStyleTLatex( labelMassPi00510, 0.035,4);
//    labelMassPi00510->Draw();
//    legendInvMass->Draw();
//    c1->SaveAs(Form("InvMass_2000MeV-2200MeV_0510.%s",suffix.Data()));
//   
//    c1->cd();
//    DrawGammaHisto( histoPi00thIterationInvMassBin9_1020,
//              "2.0 GeV/c < p_{T} < 2.2 GeV/c",
//              "M_{#gamma#gamma} (GeV/c^{2})","dN_{#gamma#gamma}/dM_{#gamma#gamma}",
//              fMesonPlotRange[0],fMesonPlotRange[1],0);
//    histoPi02ndIterationInvMassBin9_1020->SetLineColor(kRed+2);
//    histoPi02ndIterationInvMassBin9_1020->Draw("hist,e,same");
//   
//    TLatex *labelMassPi01020 = new TLatex(0.15,0.88,collisionSystemPbPb1020.Data());
//    SetStyleTLatex( labelMassPi01020, 0.035,4);
//    labelMassPi01020->Draw();
//    legendInvMass->Draw();
//    c1->SaveAs(Form("InvMass_2000MeV-2200MeV_1020.%s",suffix.Data()));
// 
//       c1->cd();
//    DrawGammaHisto( histoPi00thIterationInvMassBin9_2040,
//              "2.0 GeV/c < p_{T} < 2.2 GeV/c",
//              "M_{#gamma#gamma} (GeV/c^{2})","dN_{#gamma#gamma}/dM_{#gamma#gamma}",
//              fMesonPlotRange[0],fMesonPlotRange[1],0);
//    histoPi02ndIterationInvMassBin9_2040->SetLineColor(kRed+2);
//    histoPi02ndIterationInvMassBin9_2040->Draw("hist,e,same");
//    TLatex *labelMassPi02040 = new TLatex(0.15,0.88,collisionSystemPbPb2040.Data());
//    SetStyleTLatex( labelMassPi02040, 0.035,4);
//    labelMassPi02040->Draw();
//    legendInvMass->Draw();
//    c1->SaveAs(Form("InvMass_2000MeV-2200MeV_2040.%s",suffix.Data()));
// 
//    
//    c1->cd();
//    DrawGammaHisto( histoPi00thIterationInvMassBin9_4060,
//              "2.0 GeV/c < p_{T} < 2.2 GeV/c",
//              "M_{#gamma#gamma} (GeV/c^{2})","dN_{#gamma#gamma}/dM_{#gamma#gamma}",
//              fMesonPlotRange[0],fMesonPlotRange[1],0);
//    histoPi02ndIterationInvMassBin9_4060->SetLineColor(kRed+2);
//    histoPi02ndIterationInvMassBin9_4060->Draw("hist,e,same");
// 
//    TLatex *labelMassPi04060 = new TLatex(0.15,0.88,collisionSystemPbPb4060.Data());
//    SetStyleTLatex( labelMassPi04060, 0.035,4);
//    labelMassPi04060->Draw();
//    legendInvMass->Draw();
//    c1->SaveAs(Form("InvMass_2000MeV-2200MeV_4060.%s",suffix.Data()));
// 
//       c1->cd();
//    DrawGammaHisto( histoPi00thIterationInvMassBin9_6080,
//              "2.0 GeV/c < p_{T} < 2.2 GeV/c",
//              "M_{#gamma#gamma} (GeV/c^{2})","dN_{#gamma#gamma}/dM_{#gamma#gamma}",
//              fMesonPlotRange[0],fMesonPlotRange[1],0);
//    histoPi02ndIterationInvMassBin9_6080->SetLineColor(kRed+2);
//    histoPi02ndIterationInvMassBin9_6080->Draw("hist,e,same");
//   
//    TLatex *labelMassPi06080 = new TLatex(0.15,0.88,collisionSystemPbPb6080.Data());
//    SetStyleTLatex( labelMassPi06080, 0.035,4);
//    labelMassPi06080->Draw();
//    legendInvMass->Draw();
//    c1->SaveAs(Form("InvMass_2000MeV-2200MeV_6080.%s",suffix.Data()));
// 
//    c1->cd();
//    DrawGammaHisto( histoPi00thIterationInvMassBin10_0005,
//              "2.0 GeV/c < p_{T} < 2.2 GeV/c",
//              "M_{#gamma#gamma} (GeV/c^{2})","dN_{#gamma#gamma}/dM_{#gamma#gamma}",
//              fMesonPlotRange[0],fMesonPlotRange[1],0);
//    histoPi02ndIterationInvMassBin10_0005->SetLineColor(kRed+2);
//    histoPi02ndIterationInvMassBin10_0005->Draw("hist,e,same");
//   
//    labelMassPi00005->Draw();
//    TLegend* legendInvMass2 = new TLegend(0.15,0.76,0.35,0.84);
//    legendInvMass2->SetFillColor(0);
//    legendInvMass2->SetLineColor(0);
//    legendInvMass2->SetTextSize(0.025);
// //    legendInvMass->SetNColumns(3);
//    legendInvMass2->SetMargin(0.2);
//    legendInvMass2->AddEntry((TObject*)0, "2.2 GeV/c < p_{T} < 2.4 GeV/c","");
//    legendInvMass2->AddEntry(histoPi00thIterationInvMassBin10_0005,"no weighting","l");
//    legendInvMass2->AddEntry(histoPi02ndIterationInvMassBin10_0005,"2nd iteration reweighted","l");
//    legendInvMass2->Draw();
// 
//    c1->SaveAs(Form("InvMass_2200MeV-2400MeV_0005.%s",suffix.Data()));
// 
//    c1->cd();
//    DrawGammaHisto( histoPi00thIterationInvMassBin10_0510,
//              "2.0 GeV/c < p_{T} < 2.2 GeV/c",
//              "M_{#gamma#gamma} (GeV/c^{2})","dN_{#gamma#gamma}/dM_{#gamma#gamma}",
//              fMesonPlotRange[0],fMesonPlotRange[1],0);
//    histoPi02ndIterationInvMassBin10_0510->SetLineColor(kRed+2);
//    histoPi02ndIterationInvMassBin10_0510->Draw("hist,e,same");
//   
//    labelMassPi00510->Draw();
//    legendInvMass2->Draw();
// 
//    c1->SaveAs(Form("InvMass_2200MeV-2400MeV_0510.%s",suffix.Data()));
// 
//    c1->cd();
//    DrawGammaHisto( histoPi00thIterationInvMassBin10_1020,
//              "2.0 GeV/c < p_{T} < 2.2 GeV/c",
//              "M_{#gamma#gamma} (GeV/c^{2})","dN_{#gamma#gamma}/dM_{#gamma#gamma}",
//              fMesonPlotRange[0],fMesonPlotRange[1],0);
//    histoPi02ndIterationInvMassBin10_1020->SetLineColor(kRed+2);
//    histoPi02ndIterationInvMassBin10_1020->Draw("hist,e,same");
//   
//    labelMassPi01020->Draw();
//    legendInvMass2->Draw();
// 
//    c1->SaveAs(Form("InvMass_2200MeV-2400MeV_1020.%s",suffix.Data()));
// 
//    c1->cd();
//    DrawGammaHisto( histoPi00thIterationInvMassBin10_2040,
//              "2.0 GeV/c < p_{T} < 2.2 GeV/c",
//              "M_{#gamma#gamma} (GeV/c^{2})","dN_{#gamma#gamma}/dM_{#gamma#gamma}",
//              fMesonPlotRange[0],fMesonPlotRange[1],0);
//    histoPi02ndIterationInvMassBin10_2040->SetLineColor(kRed+2);
//    histoPi02ndIterationInvMassBin10_2040->Draw("hist,e,same");
//   
//    labelMassPi02040->Draw();
//    legendInvMass2->Draw();
// 
//    c1->SaveAs(Form("InvMass_2200MeV-2400MeV_2040.%s",suffix.Data()));
// 
//    c1->cd();
//    DrawGammaHisto( histoPi00thIterationInvMassBin10_4060,
//              "2.0 GeV/c < p_{T} < 2.2 GeV/c",
//              "M_{#gamma#gamma} (GeV/c^{2})","dN_{#gamma#gamma}/dM_{#gamma#gamma}",
//              fMesonPlotRange[0],fMesonPlotRange[1],0);
//    histoPi02ndIterationInvMassBin10_4060->SetLineColor(kRed+2);
//    histoPi02ndIterationInvMassBin10_4060->Draw("hist,e,same");
//   
//    labelMassPi04060->Draw();
//    legendInvMass2->Draw();
// 
//    c1->SaveAs(Form("InvMass_2200MeV-2400MeV_4060.%s",suffix.Data()));
// 
//    c1->cd();
//    DrawGammaHisto( histoPi00thIterationInvMassBin10_6080,
//              "2.0 GeV/c < p_{T} < 2.2 GeV/c",
//              "M_{#gamma#gamma} (GeV/c^{2})","dN_{#gamma#gamma}/dM_{#gamma#gamma}",
//              fMesonPlotRange[0],fMesonPlotRange[1],0);
//    histoPi02ndIterationInvMassBin10_6080->SetLineColor(kRed+2);
//    histoPi02ndIterationInvMassBin10_6080->Draw("hist,e,same");
//   
//    labelMassPi06080->Draw();
//    legendInvMass2->Draw();
// 
//    c1->SaveAs(Form("InvMass_2200MeV-2400MeV_6080.%s",suffix.Data()));
   
}
Example #27
0
void plot_efficiencies( TFile* file, Int_t type = 2, TDirectory* BinDir)
{
   // input:   - Input file (result from TMVA),
   //          - type = 1 --> plot efficiency(B) versus eff(S)
   //                 = 2 --> plot rejection (B) versus efficiency (S)

   Bool_t __PLOT_LOGO__  = kTRUE;
   Bool_t __SAVE_IMAGE__ = kTRUE;

   // the coordinates
   Float_t x1 = 0;
   Float_t x2 = 1;
   Float_t y1 = 0;
   Float_t y2 = 0.8;

   // reverse order if "rejection"
   if (type == 2) {
      Float_t z = y1;
      y1 = 1 - y2;
      y2 = 1 - z;    
      //      cout << "--- type==2: plot background rejection versus signal efficiency" << endl;
   }
   else {
      //  cout << "--- type==1: plot background efficiency versus signal efficiency" << endl;
   }
   // create canvas
   TCanvas* c = new TCanvas( "c", "the canvas", 200, 0, 650, 500 );

   // global style settings
   c->SetGrid();
   c->SetTicks();

   // legend
   Float_t x0L = 0.107,     y0H = 0.899;
   Float_t dxL = 0.457-x0L, dyH = 0.22;
   if (type == 2) {
      x0L = 0.15;
      y0H = 1 - y0H + dyH + 0.07;
   }
   TLegend *legend = new TLegend( x0L, y0H-dyH, x0L+dxL, y0H );
   legend->SetTextSize( 0.05 );
   legend->SetHeader( "MVA Method:" );
   legend->SetMargin( 0.4 );

   TString xtit = "Signal efficiency";
   TString ytit = "Background efficiency";  
   if (type == 2) ytit = "Background rejection";
   TString ftit = ytit + " versus " + xtit;

   if (TString(BinDir->GetName()).Contains("multicut")){
      ftit += "  Bin: ";
      ftit += (BinDir->GetTitle());
   }

   // draw empty frame
   if(gROOT->FindObject("frame")!=0) gROOT->FindObject("frame")->Delete();
   TH2F* frame = new TH2F( "frame", ftit, 500, x1, x2, 500, y1, y2 );
   frame->GetXaxis()->SetTitle( xtit );
   frame->GetYaxis()->SetTitle( ytit );
   TMVAGlob::SetFrameStyle( frame, 1.0 );

   frame->Draw();  

   Int_t color = 1;
   Int_t nmva  = 0;
   TKey *key, *hkey;

   TString hNameRef = "effBvsS";
   if (type == 2) hNameRef = "rejBvsS";

   TList hists;
   TList methods;
   UInt_t nm = TMVAGlob::GetListOfMethods( methods );
   //   TIter next(file->GetListOfKeys());
   TIter next(&methods);

   // loop over all methods
   while (key = (TKey*)next()) {
      TDirectory * mDir = (TDirectory*)key->ReadObj();
      TList titles;
      UInt_t ninst = TMVAGlob::GetListOfTitles(mDir,titles);
      TIter nextTitle(&titles);
      TKey *titkey;
      TDirectory *titDir;
      while ((titkey = TMVAGlob::NextKey(nextTitle,"TDirectory"))) {
         titDir = (TDirectory *)titkey->ReadObj();
         TString methodTitle;
         TMVAGlob::GetMethodTitle(methodTitle,titDir);
         TIter nextKey( titDir->GetListOfKeys() );
         while ((hkey = TMVAGlob::NextKey(nextKey,"TH1"))) {
            TH1 *h = (TH1*)hkey->ReadObj();    
            TString hname = h->GetName();
            if (hname.Contains( hNameRef ) && hname.BeginsWith( "MVA_" )) {
               h->SetLineWidth(3);
               h->SetLineColor(color);
               color++; if (color == 5 || color == 10 || color == 11) color++; 
               h->Draw("csame");
               hists.Add(h);
               nmva++;
            }
         }
      }
   }

   while (hists.GetSize()) {
      TListIter hIt(&hists);
      TH1* hist(0);
      Double_t largestInt=-1;
      TH1* histWithLargestInt(0);
      while ((hist = (TH1*)hIt())!=0) {
         Double_t integral = hist->Integral(1,hist->FindBin(0.9999));
         if (integral>largestInt) {
            largestInt = integral;
            histWithLargestInt = hist;
         }
      }
      if (histWithLargestInt == 0) {
         cout << "ERROR - unknown hist \"histWithLargestInt\" --> serious problem in ROOT file" << endl;
         break;
      }
      legend->AddEntry(histWithLargestInt,TString(histWithLargestInt->GetTitle()).ReplaceAll("MVA_",""),"l");
      hists.Remove(histWithLargestInt);
   }   
   
   // rescale legend box size
   // current box size has been tuned for 3 MVAs + 1 title
   if (type == 1) {
      dyH *= (1.0 + Float_t(nmva - 3.0)/4.0);
      legend->SetY1( y0H - dyH );
   }
   else {
      dyH *= (Float_t(nmva - 3.0)/4.0);
      legend->SetY2( y0H + dyH);
   }

   // redraw axes
   frame->Draw("sameaxis");  
   legend->Draw("same");

   // ============================================================

   if (__PLOT_LOGO__) TMVAGlob::plot_logo();

   // ============================================================

   c->Update();

   TString fname = "plots/" + hNameRef;
   if (TString(BinDir->GetName()).Contains("multicut")){
      TString fprepend(BinDir->GetName());
      fprepend.ReplaceAll("multicutMVA_","");
      fname = "plots/" + fprepend + "_" + hNameRef;
   }
   if (__SAVE_IMAGE__) TMVAGlob::imgconv( c, fname );

   return;
}
Example #28
0
//_________________________________________________________________________________
void integratedSplinesV4a(double seed = 231)
{
    //Load the data
    int nEvents = 1000; //number of times the data will be randomized
    int nPoints = 9;

    vector< vector<double> > xEvents, yEvents, yErrorEvents; //each of these is a vector of vectors (of randomized data points)
    for(int i = 0; i < nEvents; i++)
    {
        vector <double> xData, yData, yErrorData; //temporary vectors that are only used to get random values from FillRand function
        FillRandVectors(nPoints, xData, yData, yErrorData, seed*(i+1)); //populates random vectors for y values and y error vector
        xEvents.push_back(xData);
        yEvents.push_back(yData);
        yErrorEvents.push_back(yErrorData);
        //Populate the global variables
        xData_GLOB = xData;
        yData_GLOB = yData;
        yErrorData_GLOB = yErrorData;
    }

    //Intialization of the variables
    const int npar = nPoints;
    const int orderSpline = 4;
    const int nbreak = npar+2-orderSpline;
    double stepSpline = 0.01;
    double xminBSplineWorkspace = 0;
    double xmaxBSplineWorkspace = 9;
    double startCSplineWorkspace = 15.;
    double stepCSplineWorkspace = 1.5;

    acc_GLOB = gsl_interp_accel_alloc ();
    spline_GLOB = gsl_spline_alloc (gsl_interp_cspline, nPoints);
    gsl_bspline_workspace *bw = gsl_bspline_alloc(orderSpline, nbreak);

    //Setting up TMinuit for C-spline minimization
    TMinuit *myMinuit = new TMinuit(npar);  //initialize TMinuit with a maximum of npar (5)
    myMinuit->SetFCN(fcn);
    myMinuit->SetPrintLevel(-1);//No output: -1, output:1

    double arglist[10];
    int ierflg = 0;
    arglist[0] = 1;
    myMinuit->mnexcm("SET ERR", arglist, 1, ierflg);

    vector<double> vstart, vstep;
    for(int i=0; i < npar; i++) 	//set starting values and step sizes for parameters
    {
        vstart.push_back(startCSplineWorkspace);
        vstep.push_back(stepCSplineWorkspace);
    }

    for (int i = 0; i < npar; i++)
    {
        stringstream ss;
        ss<<"a"<<i;
        myMinuit->mnparm(i, ss.str().c_str(), vstart.at(i), vstep.at(i), 0, 0, ierflg);
    }

    //Perform the Minuit fit
    arglist[0] = 500;
    arglist[1] = 1.;

    //B and C spline loops__________________________________________________________________________
    clock_t tbstart, tbstop, tcstart, tcstop;
    vector <double> timeb, timec;

    vector< vector<double> > xBSplineValues, yBSplineValues;
    vector< vector<double> > xCSplineValues, yCSplineValues;
    for(int i = 0; i < (int)xEvents.size(); i++)
    {
        tbstart = clock();
        vector< vector<double> > bSplineValues = bSpline(nPoints, npar, xEvents.at(i), yEvents.at(i), yErrorEvents.at(i), stepSpline, xminBSplineWorkspace, xmaxBSplineWorkspace, bw);
        tbstop = clock();
        timeb.push_back(((float)tbstop-(float)tbstart)/ (CLOCKS_PER_SEC/1000.) );

        xBSplineValues.push_back(bSplineValues.at(0));
        yBSplineValues.push_back(bSplineValues.at(1));

        tcstart = clock();
        vector< vector<double> > cSplineValues = cSpline(nPoints, npar, xEvents.at(i), stepSpline, myMinuit, arglist, ierflg);
        tcstop = clock();
        timec.push_back(((float)tcstop-(float)tcstart)/ (CLOCKS_PER_SEC/1000.) );

        xCSplineValues.push_back(cSplineValues.at(0));
        yCSplineValues.push_back(cSplineValues.at(1));
    }

    //Histograms______________________________________________________________________________________

    //Time
    int nbins = 100;
    double xlow = 0;
    double xup = 5.;

    TH1D *hTimeB = new TH1D("Time","; time [ms]; number of runs", nbins, xlow, xup);
    hTimeB->SetStats(0);
    TH1D *hTimeC = new TH1D("TimeC","; time [ms]; number of runs", nbins, xlow, xup);
    hTimeC->SetLineColor(kRed);
    hTimeC->SetStats(0);

    for(int i=0; i<(int)timec.size(); i++)
    {
        hTimeB->Fill(timeb.at(i));
        hTimeC->Fill(timec.at(i));
    }

    //Interpolation distance -> Should FIND THE RIGHT J FOR SPLINE
    vector <double> interpB, interpC;
    for(int i = 0; i < (int)yEvents.size(); i++)
    {
        for(int j = 0; j < (int)yEvents[i].size(); j++)
        {
            double key = xEvents[i][j];
            int indexForB = binarySearch(xBSplineValues[i], key);
            int indexForC = binarySearch(xCSplineValues[i], key);
//			std::cout << "B: " << indexForB << " C: " << indexForC << endl;
            if(indexForB != -1)
                interpB.push_back( (yEvents[i][j]-yBSplineValues[i][indexForB])/yErrorEvents[i][indexForB] );
            if(indexForC != -1)
                interpC.push_back( (yEvents[i][j]-yCSplineValues[i][indexForC])/yErrorEvents[i][indexForC] );
        }
    }

    int nbinsI = 40;
    int xlowI = -4;
    int xupI = 4;
    TH1D *hInterpB = new TH1D("Interp B","; xAxis; yAxis", nbinsI, xlowI, xupI);
    for(int i=0; i<(int)interpB.size(); i++) hInterpB->Fill(interpB.at(i));
    hInterpB->SetStats(0);

    TH1D *hInterpC = new TH1D("Interp C","; xAxis; yAxis", nbinsI, xlowI, xupI);
    for (int i=0; i<(int)interpC.size(); i++) hInterpC->Fill(interpC.at(i));
    hInterpC->SetLineColor(kRed);
    hInterpC->SetStats(0);

    //Draws______________________________________________________________________________________

    //Interpolation distance
    TLegend *legInterp = new TLegend(0.75,0.70,0.4,0.85);
    legInterp->SetLineColor(kWhite);
    legInterp->SetFillColor(kWhite);
    legInterp->SetMargin(0.3);
    legInterp->AddEntry(hInterpB,"b-spline","l");
    legInterp->AddEntry(hInterpC,"c-spline","l");

    TCanvas *c1 = new TCanvas("c1", "Interpolation distance");
    c1->cd();
    hInterpB->Draw("");
    hInterpC->Draw("same");
    legInterp->Draw();

    //Time
    TLegend *legTime = new TLegend(0.75,0.70,0.4,0.85);
    legTime->SetLineColor(kWhite);
    legTime->SetFillColor(kWhite);
    legTime->SetMargin(0.3);
    legTime->AddEntry(hTimeB,"b-spline","l");
    legTime->AddEntry(hTimeC,"c-spline","l");

    TCanvas *c2 = new TCanvas("c2", "Computation time");
    c2->cd();
    hTimeB->Draw("");
    hTimeC->Draw("same");
    legTime-> Draw();

    //Free the memory for the spline
    gsl_spline_free (spline_GLOB); //frees the memory used by the spline
    gsl_interp_accel_free (acc_GLOB);
    gsl_bspline_free(bw);
}
void TagProbeMuonPlots(){
  gROOT->Reset();
  gROOT->SetStyle("Plain");
  gStyle->SetStatFormat("5.3f");
  gStyle->SetFitFormat("5.3f");
  int BoxValue = 11111111; //4680;  
  gStyle->SetOptFit(11);
  gStyle->SetOptDate(0);
  gStyle->SetOptTitle(0);
  gStyle->SetOptStat(BoxValue);
  gStyle->SetPadBorderMode(0);
  gStyle->SetCanvasColor(0); //(10);
  gStyle->SetPadLeftMargin(0.15);
  gStyle->SetPadBottomMargin(0.15);
  gStyle->SetPalette(0);
  TPaveLabel pl;
  TLatex lt;
  lt.SetTextFont(70);
  lt.SetTextAlign(12);
  lt.SetTextSize(0.07);
  lt.SetTextColor(1);
  //-----------------------------------
  float Eff1    = 0.992541;
  float Eff2    = 0.997441;
  float Eff3    = 0.998276;
  float Eff4    = 0.993334;
  float Eff5    = 0.994771;
  float Eff6    = 0.975608;
  float Eff7    = 0.984109;
  float Eff8    = 0.964307;
  float Eff9    = 0.99461;
  float Eff10   = 0.992715;
  float Eff11   = 0.997227;
  float Eff12   = 0.997424;
  float Eff13   = 0.99038;

  float error1     = 0.000632637;
  float error2     = 0.000245095;
  float error3     = 0.000196413;
  float error4     = 0.000414215;
  float error5     = 0.000248457;
  float error6     = 0.00135095;
  float error7     = 0.000522484;
  float error8     = 0.00163942;
  float error9     = 0.000251847;
  float error10    = 0.00043307;
  float error11    = 0.000251077;
  float error12    = 0.000247884;
  float error13    = 0.000725104;

  /*
    [0.0,0.9]   = 98.97
    [0.9,1.2]   = 99.30
    [1.2,2.1]   = 99.76
    [2.1,2.4]   = 99.15
    error[0.0,0.9]    = 0.02
    error[0.9,1.2]    = 0.03
    error[1.2,2.1]    = 0.01
    error[2.1,2.4]    = 0.05
  */
 /*
   [0.0,0.9]   = 98.90 (+/-) 0.01
   [0.9,1.2]   = 99.30 (+/-) 0.02
   [1.2,2.1]   = 99.80 (+/-) 0.0
   [2.1,2.4]   = 0.991507
   error[0.0,0.9]    = 0.01
   error[0.9,1.2]    = 0.02
   error[1.2,2.1]    = 0.0
   error[2.1,2.4]    = 0.000296783
 */



  //==============================================
  //  Data
  //==============================================
 float EffD1    = 0.974227;
 float EffD2    = 0.990483;
 float EffD3    = 0.995014;
 float EffD4    = 0.983568;
 float EffD5    = 0.99011;
 float EffD6    = 0.970588;
 float EffD7    = 0.981162;
 float EffD8    = 0.952618;
 float EffD9    = 0.987393;
 float EffD10   = 0.979916;
 float EffD11   = 0.994776;
 float EffD12   = 0.992913;
 float EffD13   = 0.981324;

 float errorD1     = 0.00665461;
 float errorD2     = 0.0026395;
 float errorD3     = 0.00188444;
 float errorD4     = 0.00358574;
 float errorD5     = 0.00190335;
 float errorD6     = 0.00815736;
 float errorD7     = 0.00313972;
 float errorD8     = 0.0108701;
 float errorD9     = 0.00216201;
 float errorD10    = 0.00409956;
 float errorD11    = 0.00197444;
 float errorD12    = 0.0023622;
 float errorD13    = 0.00563094;
 /*
   [0.0,0.9]   = 98.42 (+/-) 0.14
   [0.9,1.2]   = 98.18 (+/-) 0.27
   [1.2,2.1]   = 99.33 (+/-) 0.11
   [2.1,2.4]   = 0.977797
   error[0.0,0.9]    = 0.14
   error[0.9,1.2]    = 0.27
   error[1.2,2.1]    = 0.11
   error[2.1,2.4]    = 0.00435441
 */
 
  //================================================================== 
  //==================================================================  
  //================================================================== 
  //==================================================================  
  //================================================================== 
  //==================================================================  
  //================================================================== 
  TCanvas *c1 = new TCanvas("c1","Eff. pt",500,500);
  char textpro1[100],textNDF1[100],textRatio1[100];           
  c1->cd(1);
  gPad->SetTopMargin(0.12);
  gPad->SetLeftMargin(0.15);
  gPad->SetFillColor(0);
  gPad->SetTickx();
  gPad->SetTicky();
  gPad->SetGridy();
  gPad->SetGridx();
  TH1F* MassProbeTTandProbeTF1    = new TH1F("MassProbeTTandProbeTF1","",10,0.0,100.0);
  TH1F* MassProbeTTandProbeTF2    = new TH1F("MassProbeTTandProbeTF2","",10,0.0,100.0);
  TH1F* MassProbeTTandProbe720TF1 = new TH1F("MassProbeTTandProbe720TF1","",10,0.0,100.0);
  TH1F* MassProbeTTandProbe720TF2 = new TH1F("MassProbeTTandProbe720TF2","",10,0.0,100.0);
  TGraphAsymmErrors *MassEffForTagProbe539  = new TGraphAsymmErrors;
  TGraphAsymmErrors *MassEffForTagProbe720  = new TGraphAsymmErrors;
  TMultiGraph *mg1 = new TMultiGraph;
  //========================================================== 
  //                      Mass 539                         
  //==========================================================
  TFile *f1 = new TFile("Analyse_TagandProbe_MC_DY_60_Mass_120_HighPtMuon_ID_pt45.root","READ");
  //---------------------------------------------------
  MassProbeTTandProbeTF1->Add(PtProbeTT);
  MassProbeTTandProbeTF2->Add(PtProbeTP);
  cout<<"====================== T&P1 =============================="<<endl;
  int nbEleTopMass1                             = MassProbeTTandProbeTF1->Integral();
  int nbEleBottomMass1                          = MassProbeTTandProbeTF2->Integral();
  float EffChargedHadMass1                      = (float)nbEleTopMass1/nbEleBottomMass1;
  cout<<"nbEleTopMass1                          = "<<nbEleTopMass1<<endl;
  cout<<"nbEleBottomMass1                       = "<<nbEleBottomMass1<<endl;
  cout<<"EffChargedHadMass1(electron)           = "<<EffChargedHadMass1<<endl;
  float StatErrorMass1                          = sqrt(nbEleBottomMass1 - nbEleTopMass1)/nbEleBottomMass1;
  cout<<"StatErrorMass1(electron)               = "<<StatErrorMass1<<endl;
  //---------------------------------------------------
  MassEffForTagProbe539->BayesDivide(MassProbeTTandProbeTF1,MassProbeTTandProbeTF2);
  MassEffForTagProbe539->SetLineStyle(0);
  MassEffForTagProbe539->SetLineColor(1);
  MassEffForTagProbe539->SetLineWidth(2);
  MassEffForTagProbe539->SetMarkerColor(1); 
  MassEffForTagProbe539->SetMarkerStyle(20);
  MassEffForTagProbe539->SetMarkerSize(0.875);
  //-----------------------------------------------------------------
  //========================================================== 
  //                      Mass 720                                                  
  //==========================================================
  TFile *f100 = new TFile("Analyse_TagandProbe_Data_DY_60_Mass_120_HighPtMuon_ID_pt45.root","READ");
  //---------------------------------------------------
  MassProbeTTandProbe720TF1->Add(PtProbeTT);
  MassProbeTTandProbe720TF2->Add(PtProbeTP);
  cout<<"====================== T&P1 =============================="<<endl;
  int nbEleTopMass2                             = MassProbeTTandProbe720TF1->Integral();
  int nbEleBottomMass2                          = MassProbeTTandProbe720TF2->Integral();
  float EffChargedHadMass2                      = (float)nbEleTopMass2/nbEleBottomMass2;
  cout<<"nbEleTopMass2                          = "<<nbEleTopMass2<<endl;
  cout<<"nbEleBottomMass2                       = "<<nbEleBottomMass2<<endl;
  cout<<"EffChargedHadMass2(electron)           = "<<EffChargedHadMass2<<endl;
  float StatErrorMass2                          = sqrt(nbEleBottomMass2 - nbEleTopMass2)/nbEleBottomMass2;
  cout<<"StatErrorMass2(electron)               = "<<StatErrorMass2<<endl;
  //---------------------------------------------------
  MassEffForTagProbe720->BayesDivide(MassProbeTTandProbe720TF1,MassProbeTTandProbe720TF2);
  MassEffForTagProbe720->SetLineStyle(0);
  MassEffForTagProbe720->SetLineColor(2);
  MassEffForTagProbe720->SetLineWidth(2);
  MassEffForTagProbe720->SetMarkerColor(2); 
  MassEffForTagProbe720->SetMarkerStyle(24);
  MassEffForTagProbe720->SetMarkerSize(0.875);
  //----------------------------------------------------------------- 
  mg1->Add(MassEffForTagProbe539);
  mg1->Add(MassEffForTagProbe720);
  mg1->Draw("AP");
  mg1->SetTitle("title;muon pt [GeV/c]; Eff.(High pt muons ID)");
  mg1->GetXaxis()->SetTitleOffset(1.7);
  mg1->GetYaxis()->SetTitleOffset(1.7);
  mg1->GetXaxis()->SetLabelSize(0.03);
  mg1->GetYaxis()->SetLabelSize(0.03);
  mg1->GetYaxis()->SetRangeUser(0.7,1.05);
  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
  TPaveText* tText1 = new TPaveText(0.70, 0.90, 0.90, 0.95, "brNDC");
  tText1->SetBorderSize(0);
  tText1->SetFillColor(0);
  tText1->SetFillStyle(0);
  TText *t1 = tText1->AddText("46.152 pb^{-1} (13 TeV)");
  tText1->SetTextSize(0.035);
  tText1->Draw(); 
  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  TPaveText* tText2 = new TPaveText(0.2, 0.90, 0.4, 0.95, "brNDC");
  tText2->SetBorderSize(0);
  tText2->SetFillColor(0);
  tText2->SetFillStyle(0);
  TText *t1 = tText2->AddText("CMS Spring15 Simulation");
  tText2->SetTextSize(0.035);
  tText2->Draw(); 
  //==========================================================
  TPaveText* tText1 = new TPaveText(0.50, 0.25, 0.80, 0.45, "brNDC");
  tText1->SetBorderSize(0);
  tText1->SetTextColor(1);
  tText1->SetFillStyle(0);
  Float_t tsize = 0.035;
  tText1->SetTextSize(tsize); 
  TText *t1 = tText1->AddText("Pt > 20 GeV/c"); 
  TText *t2 = tText1->AddText("|#eta|<2.4"); 
  tText1->Draw();
  //========================================================== 
  TLegend *leg = new TLegend(0.20, 0.20, 0.40, 0.35);
  leg->AddEntry(MassEffForTagProbe539,"MC","p");
  leg->AddEntry(MassEffForTagProbe720,"Data (PromptReco)","p");
  leg->SetBorderSize(0.0);
  leg->SetMargin(0.3);
  leg->SetFillColor(0);
  leg->SetFillStyle(10);
  leg->SetLineColor(0);
  Float_t tsize2 = 0.035;
  leg->SetTextSize(tsize2); 
  leg->Draw();
  //======================================================================= 
  c1->Print("Eff_TagProbe_ID_MC_13TeV_PtProbe_cmssw720.png","png");
  c1->Print("Eff_TagProbe_ID_MC_13TeV_PtProbe_cmssw720.pdf","pdf");
  //c1->Print("PlotsDir4/Eff_DeltaPhi_HEEP_ID_MC_CMSSW701_Eta_EBEE.eps","eps");
  //=======================================================================
  
  //==================================================================   
  //================================================================== 
  //==================================================================  
  //================================================================== 
  TCanvas *c4 = new TCanvas("c4","Eff. PVs",500,500);
  char textpro1[100],textNDF1[100],textRatio1[100];           
  c4->cd(1);
  gPad->SetTopMargin(0.12);
  gPad->SetLeftMargin(0.15);
  gPad->SetFillColor(0);
  gPad->SetTickx();
  gPad->SetTicky();
  gPad->SetGridy();
  gPad->SetGridx();
  TH1F* NbPVProbeTTandProbeTF1            = new TH1F("NbPVProbeTTandProbeTF1","",15,0.0,50.0);
  TH1F* NbPVProbeTTandProbeTF2            = new TH1F("NbPVProbeTTandProbeTF2","",15,0.0,50.0);
  TGraphAsymmErrors *TagProbePhi539       = new TGraphAsymmErrors;
  TH1F* NbPVProbeTTandProbe720TF1         = new TH1F("NbPVProbeTTandProbe720TF1","",15,0.0,50.0);
  TH1F* NbPVProbeTTandProbe720TF2         = new TH1F("NbPVProbeTTandProbe720TF2","",15,0.0,50.0);
  TGraphAsymmErrors *TagProbePhi720       = new TGraphAsymmErrors;
  TMultiGraph *mg4 = new TMultiGraph;
  //========================================================== 
  //                     Phi                                                  
  //==========================================================
  TFile *f5 = new TFile("Analyse_TagandProbe_MC_DY_60_Mass_120_HighPtMuon_ID_pt45.root","READ");
  //---------------------------------------------------
  NbPVProbeTTandProbeTF1->Add(PVProbeTT);
  NbPVProbeTTandProbeTF2->Add(PVProbeTP);
  cout<<"====================== dBeta =============================="<<endl;
  int nbEleTopPV1                             = NbPVProbeTTandProbeTF1->Integral();
  int nbEleBottomPV1                          = NbPVProbeTTandProbeTF2->Integral();
  float EffChargedHadPV1                      = (float)nbEleTopPV1/nbEleBottomPV1;
  cout<<"nbEleTopPV1                          = "<<nbEleTopPV1<<endl;
  cout<<"nbEleBottomPV1                       = "<<nbEleBottomPV1<<endl;
  cout<<"EffChargedHadPV1(electron)           = "<<EffChargedHadPV1<<endl;
  float StatErrorPV1                          = sqrt(nbEleBottomPV1 - nbEleTopPV1)/nbEleBottomPV1;
  cout<<"StatErrorPV1(electron)               = "<<StatErrorPV1<<endl;
  //---------------------------------------------------
  TagProbePhi539->BayesDivide(NbPVProbeTTandProbeTF1,NbPVProbeTTandProbeTF2);
  TagProbePhi539->SetLineStyle(0);
  TagProbePhi539->SetLineColor(1);
  TagProbePhi539->SetLineWidth(2);
  TagProbePhi539->SetMarkerColor(1); 
  TagProbePhi539->SetMarkerStyle(20);
  TagProbePhi539->SetMarkerSize(0.875);
  //========================================================== 
  //                     Phi                                                  
  //==========================================================
  TFile *f50 = new TFile("Analyse_TagandProbe_Data_DY_60_Mass_120_HighPtMuon_ID_pt45.root","READ");
  //---------------------------------------------------
  NbPVProbeTTandProbe720TF1->Add(PVProbeTT);
  NbPVProbeTTandProbe720TF2->Add(PVProbeTP);
  cout<<"====================== dBeta =============================="<<endl;
  int nbEleTopPV2                             = NbPVProbeTTandProbe720TF1->Integral();
  int nbEleBottomPV2                          = NbPVProbeTTandProbe720TF2->Integral();
  float EffChargedHadPV2                      = (float)nbEleTopPV2/nbEleBottomPV2;
  cout<<"nbEleTopPV2                          = "<<nbEleTopPV2<<endl;
  cout<<"nbEleBottomPV2                       = "<<nbEleBottomPV2<<endl;
  cout<<"EffChargedHadPV2(electron)           = "<<EffChargedHadPV2<<endl;
  float StatErrorPV2                          = sqrt(nbEleBottomPV2 - nbEleTopPV2)/nbEleBottomPV2;
  cout<<"StatErrorPV2(electron)               = "<<StatErrorPV2<<endl;
  //---------------------------------------------------
  TagProbePhi720->BayesDivide(NbPVProbeTTandProbe720TF1,NbPVProbeTTandProbe720TF2);
  TagProbePhi720->SetLineStyle(0);
  TagProbePhi720->SetLineColor(2);
  TagProbePhi720->SetLineWidth(2);
  TagProbePhi720->SetMarkerColor(2); 
  TagProbePhi720->SetMarkerStyle(24);
  TagProbePhi720->SetMarkerSize(0.875);
  //============================================================================
  mg4->Add(TagProbePhi539);
  mg4->Add(TagProbePhi720);
  mg4->Draw("AP");
  mg4->SetTitle("title;Number of vertices; Eff.(High pt muons ID)");
  mg4->GetXaxis()->SetTitleOffset(1.7);
  mg4->GetYaxis()->SetTitleOffset(1.7);
  mg4->GetXaxis()->SetLabelSize(0.03);
  mg4->GetYaxis()->SetLabelSize(0.03);
  mg4->GetXaxis()->SetRangeUser(0.0,37.0);
  mg4->GetYaxis()->SetRangeUser(0.7,1.05);
  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
  TPaveText* tText1 = new TPaveText(0.70, 0.90, 0.90, 0.95, "brNDC");
  tText1->SetBorderSize(0);
  tText1->SetFillColor(0);
  tText1->SetFillStyle(0);
  TText *t1 = tText1->AddText("46.152 pb^{-1} (13 TeV)");
  tText1->SetTextSize(0.035);
  tText1->Draw(); 
  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  TPaveText* tText2 = new TPaveText(0.2, 0.90, 0.4, 0.95, "brNDC");
  tText2->SetBorderSize(0);
  tText2->SetFillColor(0);
  tText2->SetFillStyle(0);
  TText *t1 = tText2->AddText("CMS Spring15 Simulation");
  tText2->SetTextSize(0.035);
  tText2->Draw(); 
  //========================================================== 
  TPaveText* tText1 = new TPaveText(0.50, 0.25, 0.80, 0.45, "brNDC");
  tText1->SetBorderSize(0);
  tText1->SetTextColor(1);
  tText1->SetFillStyle(0);
  Float_t tsize = 0.035;
  tText1->SetTextSize(tsize); 
  TText *t1 = tText1->AddText("Pt > 20 GeV/c"); 
  TText *t2 = tText1->AddText("|#eta|<2.4"); 
  tText1->Draw();
  //========================================================== 
  TLegend *leg = new TLegend(0.20, 0.20, 0.40, 0.35);
  leg->AddEntry(TagProbePhi539,"MC","p");
  leg->AddEntry(TagProbePhi720,"Data (PromptReco)","p");
  leg->SetBorderSize(0.0);
  leg->SetMargin(0.3);
  leg->SetFillColor(0);
  leg->SetFillStyle(10);
  leg->SetLineColor(0);
  Float_t tsize2 = 0.035;
  leg->SetTextSize(tsize2); 
  leg->Draw();
  //======================================================================= 
  c4->Print("Eff_TagProbe_ID_MC_13TeV_vtxProbe_cmssw720.png","png");
  c4->Print("Eff_TagProbe_ID_MC_13TeV_vtxProbe_cmssw720.pdf","pdf");
  //c4->Print("PlotsDir4/Eff_DeltaPhi_HEEP_ID_MC_CMSSW701_Phi_EBEE.eps","eps");
  //=======================================================================

  //================================================================== 
  //==================================================================  
  //================================================================== 
  //==================================================================
  //TCanvas *c5 = new TCanvas("c5","A Simple Graph with error bars",200,10,700,500);
  TCanvas *c5 = new TCanvas("c5","Eff. Eta",500,500);
  c5->SetFillColor(0);
  c5->SetGrid();
  c5->GetFrame()->SetFillColor(21);
  c5->GetFrame()->SetBorderSize(12);
  gPad->SetTopMargin(0.12);
  gPad->SetLeftMargin(0.15);
  gPad->SetFillColor(0);
  gPad->SetTickx();
  gPad->SetTicky();
  gPad->SetGridy();
  gPad->SetGridx();
  const Int_t n = 13;
  Float_t x[n]  = {-2.25,-1.85,-1.4,-1.05,-0.6,-0.25,0.0,0.25,0.6,1.05,1.4,1.85,2.25};
  Float_t y[n]  = {Eff1,
		   Eff2,
		   Eff3,
		   Eff4,
		   Eff5,
		   Eff6,
		   Eff7,
		   Eff8,
		   Eff9,
		   Eff10,
		   Eff11,
		   Eff12,
		   Eff13};
  Float_t ex[n] = {0.15,0.25,0.2,0.15,0.3,0.05,0.2,0.05,0.3,0.15,0.2,0.25,0.15};
  Float_t ey[n] = {error1,error2,error3,error4,error5,error6,error7,error8,error9,error10,error11,error12,error13};
  TGraphErrors *gr = new TGraphErrors(n,x,y,ex,ey);
  gr->SetMarkerColor(1);
  gr->SetMarkerStyle(20);
  gr->SetMarkerSize(0.9);
  gr->Draw("AP");
  gr->GetYaxis()->SetNdivisions(10,kTRUE);
  gr->GetYaxis()->SetDecimals();
  //gr->GetYaxis()->SetRangeUser(0.0,0.4);
  //gr->GetXaxis()->SetNdivisions(510,kFALSE);
  gr->GetXaxis()->SetRangeUser(-2.4,2.4);
  gr->GetYaxis()->SetRangeUser(0.70,1.05);
  gr->SetTitle("title;muon #eta; Eff.(High pt muons ID)");
  gr->GetXaxis()->SetTitleOffset(1.7);
  gr->GetYaxis()->SetTitleOffset(1.7);
  gr->GetXaxis()->SetLabelSize(0.03);
  gr->GetYaxis()->SetLabelSize(0.03);
  gr->GetXaxis()->SetRangeUser(-2.1,2.1);
  Float_t x2[n]  = {-2.25,-1.85,-1.4,-1.05,-0.6,-0.25,0.0,0.25,0.6,1.05,1.4,1.85,2.25};
  Float_t y2[n]  = {EffD1,
		   EffD2,
		   EffD3,
		   EffD4,
		   EffD5,
		   EffD6,
		   EffD7,
		   EffD8,
		   EffD9,
		   EffD10,
		   EffD11,
		   EffD12,
		   EffD13};
  Float_t ex2[n] = {0.15,0.25,0.2,0.15,0.3,0.05,0.2,0.05,0.3,0.15,0.2,0.25,0.15};
  Float_t ey2[n] = {errorD1,errorD2,errorD3,errorD4,errorD5,errorD6,errorD7,errorD8,errorD9,errorD10,errorD11,errorD12,errorD13};
  TGraphErrors *gr2 = new TGraphErrors(n,x2,y2,ex2,ey2);
  gr2->SetMarkerColor(2);
  gr2->SetLineColor(2);
  gr2->SetMarkerStyle(24);
  gr2->SetMarkerSize(0.9);
  gr2->GetXaxis()->SetRangeUser(-2.1,2.1);
  gr2->Draw("p,sames");
  //-----------------------------------------------------------------
  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
  double LikelihoodCut1    = 1.2 ;
  TLine *line1 = new TLine( LikelihoodCut1 , 0.7,  LikelihoodCut1 , 1.05);
  line1->SetLineColor(2);
  line1->SetLineWidth(3);
  line1->SetLineStyle(2);
  line1->Draw();
  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
  double LikelihoodCut2    = -1.2 ;
  TLine *line2 = new TLine( LikelihoodCut2 , 0.7,  LikelihoodCut2 , 1.05);
  line2->SetLineColor(2);
  line2->SetLineWidth(3);
  line2->SetLineStyle(2);
  line2->Draw();
  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
   TPaveText* tText1 = new TPaveText(0.70, 0.90, 0.90, 0.95, "brNDC");
  tText1->SetBorderSize(0);
  tText1->SetFillColor(0);
  tText1->SetFillStyle(0);
  TText *t1 = tText1->AddText("46.152 pb^{-1} (13 TeV)");
  tText1->SetTextSize(0.035);
  tText1->Draw(); 
  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  TPaveText* tText2 = new TPaveText(0.2, 0.90, 0.4, 0.95, "brNDC");
  tText2->SetBorderSize(0);
  tText2->SetFillColor(0);
  tText2->SetFillStyle(0);
  TText *t1 = tText2->AddText("CMS Spring15 Simulation");
  tText2->SetTextSize(0.035);
  tText2->Draw(); 
  //========================================================== 
  TPaveText* tText1 = new TPaveText(0.50, 0.25, 0.80, 0.45, "brNDC");
  tText1->SetBorderSize(0);
  tText1->SetTextColor(1);
  tText1->SetFillStyle(0);
  Float_t tsize = 0.035;
  tText1->SetTextSize(tsize); 
  TText *t1 = tText1->AddText("Pt > 20 GeV/c"); 
  TText *t2 = tText1->AddText("|#eta|<2.4"); 
  tText1->Draw();
  //==========================================================
  TLegend *leg = new TLegend(0.20, 0.20, 0.40, 0.35);
  leg->AddEntry(gr,"MC","p");
  leg->AddEntry(gr2,"Data (PromptReco)","p");
  leg->SetBorderSize(0.0);
  leg->SetMargin(0.3);
  leg->SetFillColor(0);
  leg->SetFillStyle(10);
  leg->SetLineColor(0);
  Float_t tsize2 = 0.03;
  leg->SetTextSize(tsize2); 
  leg->Draw();  
  //======================================================================= 
  c5->Print("Eff_TagProbe_ID_MC_13TeV_EtaProbe_cmssw720.png","png");
  c5->Print("Eff_TagProbe_ID_MC_13TeV_EtaProbe_cmssw720.pdf","pdf");
  c5->Update();
  //================================================================== 
  

}
Example #30
0
//_________________________________________________________________________________
void integratedSplinesV2a(double seed = 231) 
{
	//Load the data
	int nPoints = 9;
	vector <double> xData, yData, yErrorData; 
	FillRandVectors(nPoints, xData, yData, yErrorData, seed); //create random vectors for y values and y error vector

	//Intialization of the variables
	const int npar = nPoints;
	const int orderSpline = 4;
	const int nbreak = npar+2-orderSpline;
	double stepSpline = 0.01;
	double xminBSplineWorkspace = 0;
	double xmaxBSplineWorkspace = 9;

	acc_GLOB = gsl_interp_accel_alloc ();
	spline_GLOB = gsl_spline_alloc (gsl_interp_cspline, nPoints);	
	bw_GLOB = gsl_bspline_alloc(orderSpline, nbreak);
	
	//B-spline
	clock_t tbstart = clock();
	TGraph *bGraph = bSpline(nPoints, npar, xData, yData, yErrorData, stepSpline, xminBSplineWorkspace, xmaxBSplineWorkspace);
	bGraph->SetTitle("");
	bGraph->GetXaxis()->SetTitle("X-axis Arbitrary Units");
	bGraph->GetYaxis()->SetTitle("Y-axis Arbirary Units");
	clock_t tbstop = clock();


	//C-spline
	clock_t tcstart = clock();
	TGraph *cGraph = cSpline(nPoints, npar, xData, yData, yErrorData, stepSpline);
	clock_t tcstop = clock();
	cGraph->SetLineColor(kRed);


	//Control points
	TGraphErrors *pGraph = new TGraphErrors(nPoints, &xData[0], &yData[0], 0 ,&yErrorData[0]);
	pGraph-> SetMarkerStyle(20);
	pGraph->SetMarkerColor(kBlue);

	//Free the memory for the spline
	gsl_spline_free (spline_GLOB); //frees the memory used by the spline
 	gsl_interp_accel_free (acc_GLOB);
	gsl_bspline_free(bw_GLOB);

	// time histogram
	int nbins = 100;
	double xlow = 0;
	double xup = 0.001;

	TH1D *hello2 = new TH1D("TimeB","TimeB; time; number of runs", nbins, xlow, xup); 
	double timeb = ((float)tbstop-(float)tbstart)/ CLOCKS_PER_SEC;
	hello2->Fill(timeb);

	TH1D *hello3 = new TH1D("TimeC","TimeC; time; number of runs", nbins, xlow, xup); 
	hello3->SetLineColor(kRed);
	double timec = ((float)tcstop-(float)tcstart)/ CLOCKS_PER_SEC;
	hello3->Fill(timec);

	//Legends
	TLegend *leg = new TLegend(0.15,0.70,0.4,0.85);
	leg->SetLineColor(kWhite); 
	leg->SetFillColor(kWhite);
	leg->SetMargin(0.3); 
	leg->AddEntry(pGraph,"Simulated data","lp");
	leg->AddEntry(bGraph,"b-spline","l");
	leg->AddEntry(cGraph,"c-spline","l");


	//Draw to canvas
	TCanvas *can1 = new TCanvas("c2", "Timing");
	can1->cd();
	hello2->Draw("");
	hello3->Draw("same");

	TCanvas *c1 = new TCanvas("c1", "Spline Comparison");
 	c1->cd();
	bGraph->Draw("al");
	cGraph->Draw("same l");
	pGraph->Draw("same pz");
	leg->Draw();
}