Example #1
0
TH1F * DrawOverflow(TH1F *h)
{
      // This function paint the histogram h with an extra bin for overflows
   UInt_t nx    = h->GetNbinsX()+1;
   Double_t *xbins= new Double_t[nx+1];
   for (UInt_t i=0;i<nx;i++)
     xbins[i]=h->GetBinLowEdge(i+1);
   xbins[nx]=xbins[nx-1]+h->GetBinWidth(nx);
   char *tempName= new char[strlen(h->GetName())+10];
   sprintf(tempName,"%swtOverFlow",h->GetName());
   // Book a temporary histogram having ab extra bin for overflows
   TH1F *htmp = new TH1F(tempName, h->GetTitle(), nx, xbins);
   // Reset the axis labels
   htmp->SetXTitle(h->GetXaxis()->GetTitle());
   htmp->SetYTitle(h->GetYaxis()->GetTitle());
   // Fill the new hitogram including the extra bin for overflows
   for (UInt_t i=1; i<=nx; i++)
     htmp->Fill(htmp->GetBinCenter(i), h->GetBinContent(i));
   // Fill the underflows
   htmp->Fill(h->GetBinLowEdge(1)-1, h->GetBinContent(0));
   // Restore the number of entries
   htmp->SetEntries(h->GetEntries());
   // FillStyle and color
   htmp->SetFillStyle(h->GetFillStyle());
   htmp->SetFillColor(h->GetFillColor());
   return htmp;
}
Example #2
0
TH1* AddOverflow(TH1* h) {

  ++overflowCounter;

  TString  name = h->GetName();
  Int_t    nx   = h->GetNbinsX()+1;
  Double_t bw   = h->GetBinWidth(nx);
  Double_t x1   = h->GetBinLowEdge(1);
  Double_t x2   = h->GetBinLowEdge(nx) + bw;
  
  // Book a new histogram having an extra bin for overflows
  TH1F* htmp = new TH1F(Form(name + "_overflow_%d", overflowCounter), "", nx, x1, x2);

  // Fill the new histogram including the extra bin for overflows
  for (Int_t i=1; i<=nx; i++) {
    htmp->Fill(htmp->GetBinCenter(i), h->GetBinContent(i));
    htmp->SetBinError(i, h->GetBinError(i));
  }

  // Fill the underflow
  htmp->Fill(x1-1, h->GetBinContent(0));

  // Restore the number of entries
  htmp->SetEntries(h->GetEntries());

  // Cosmetics
  htmp->SetLineColor(h->GetLineColor());
  htmp->SetLineWidth(h->GetLineWidth());
  htmp->GetXaxis()->SetTitleOffset(1.5);

  return htmp;
}
void PaintOverflow(TH1 *h)
{
  // This function paint the histogram h with an extra bin for overflows
  
  char* name  = h->GetName();
  char* title = h->GetTitle();
  Int_t nx    = h->GetNbinsX()+1;
  Double_t x1 = h->GetBinLowEdge(1);
  Double_t bw = h->GetBinWidth(nx);
  Double_t x2 = h->GetBinLowEdge(nx)+bw;
  
  // Book a temporary histogram having ab extra bin for overflows
  TH1F *htmp = new TH1F(name, title, nx, x1, x2);
  
  // Fill the new hitogram including the extra bin for overflows
  for (Int_t i=1; i<=nx; i++) {
    htmp->Fill(htmp->GetBinCenter(i), h->GetBinContent(i));
  }
  
  // Fill the underflows
  htmp->Fill(x1-1, h->GetBinContent(0));
  
  // Restore the number of entries
  htmp->SetEntries(h->GetEntries());
  
  // Draw the temporary histogram
  htmp->Draw();
  /*
  TText *t = new TText(x2-bw/2,h->GetBinContent(nx),"Overflow");
  t->SetTextAngle(90);
  t->SetTextAlign(12);
  t->SetTextSize(0.03);;
  t->Draw();
  */
}
Example #4
0
TH1F* fixrange(TH1F* old, int numB) {

  float x1, x2;
  string name = old->GetName();

  if (name.find("Ht")!=string::npos) {
    x1 = 30.;
    x2 = 500.;
    if (numB==2) x2 = 400.;
  } else if (name.find("jet_pt")!=string::npos) {
    x1 = 30.;
    x2 = 300.;
    if (numB==2) {
      if (name.find("first")!=string::npos) x2 = 200.;
      if (name.find("second")!=string::npos) x2 = 120.;
    }
  } else if (name.find("pt_Z")!=string::npos) {
    x1 = 0.;
    x2 = 300.;
    if (numB==2) x2 = 230.;
  } else {
    x1 = old->GetXaxis()->GetBinCenter(1);
    x2 = old->GetXaxis()->GetBinCenter(old->GetNbinsX());
  }

  int nx = old->GetXaxis()->FindBin(x2)-old->GetXaxis()->FindBin(x1)+1;

  x1 = old->GetXaxis()->GetBinLowEdge(old->GetXaxis()->FindBin(x1));
  x2 = old->GetXaxis()->GetBinUpEdge(old->GetXaxis()->FindBin(x2));

  TH1F* tmp = new TH1F("tmp",old->GetTitle(),nx,x1,x2);
  tmp->Sumw2();

  tmp->GetXaxis()->SetTitle(old->GetXaxis()->GetTitle());
  tmp->GetYaxis()->SetTitle(old->GetYaxis()->GetTitle());

  for (int i=0;i<=old->GetNbinsX()+1;i++) {
    int ii = tmp->GetXaxis()->FindBin(old->GetXaxis()->GetBinCenter(i));
    float c1 = tmp->GetBinContent(ii);
    float e1 = tmp->GetBinError(ii);
    float c2 = old->GetBinContent(i);
    float e2 = old->GetBinError(i);

    tmp->SetBinContent(ii,c1+c2);
    tmp->SetBinError(ii,TMath::Sqrt(e1*e1+e2*e2));
  }

  tmp->SetEntries(old->GetEntries());

  old->Delete();
  tmp->SetName(name.c_str());

  return tmp;
}
Example #5
0
void unfoldPt(int mode=0)
{

   // Matched Tracklets
   TFile *inf = new TFile("match-10TeV-12.root");
   TNtuple *nt = (TNtuple*)inf->FindObjectAny("nt");

   // Test sample
   TFile *infTest = new TFile("./TrackletTree-Run123596.root");
   TNtuple *ntTest = (TNtuple*)infTest->FindObjectAny("TrackletTree12");
   
   TFile *pdfFile;
   if (mode==0) pdfFile = new TFile("pdf.root","recreate");
           else pdfFile = new TFile("pdf.root");

   double nPtBin=15;
   double minPt=log(0.05);
   double maxPt=log(10);
   double nDphiBin=600;
   double maxDphi=0.4;
   
   char* mycut = Form("abs(eta)<2&&log(pt)>%f&&log(pt)<%f",minPt,maxPt);
   char* mycut1=Form("abs(eta)<2&&log(pt)>%f&&log(pt)<%f&&abs(eta-eta1)<0.01&&abs(deta)<0.01",minPt,maxPt);

   TH2F *h;
   TH1F *hdphi = new TH1F("hdphi","",nDphiBin,0,maxDphi);
   TH1F *hdphi2;
   TH1F *hpt;
   TH1F *hptH = new TH1F("hptH","",nPtBin,minPt,maxPt);
   
   TH1F *hptUnfold = new TH1F("hptUnfold","",nPtBin,minPt,maxPt);
   TH1F *hptMC = new TH1F("hptMC","",nPtBin,minPt,maxPt);
   TH1F *hptTemp = new TH1F("hptTemp","",nPtBin,minPt,maxPt);

   // Delta phi as a function of matched genparticle transverse momentum
   TCanvas *c = new TCanvas("c","",600,600);
   
   if (mode == 0) {
      h = new TH2F("h","",nPtBin,minPt,maxPt,nDphiBin,0,maxDphi);
      hdphi2 = new TH1F("hdphiMC","",nDphiBin,0,maxDphi);
      hpt = new TH1F("hpt","",nPtBin,minPt,maxPt);      
      h->SetXTitle("ln(P_{T}) GeV/c");
      h->SetYTitle("|#Delta#phi|");
      nt->Draw("abs(dphi):log(pt)>>h",mycut1,"col");
      // used to generate pdf
      nt->Draw("abs(dphi)>>hdphiMC",mycut,"");
      nt->Draw("log(pt)>>hpt",mycut,"");
      h->Write();      
      hpt->Write();      
      hdphi2->Write();      
   } else {
      h = (TH2F*) pdfFile->FindObjectAny("h");
      hdphi2 = (TH1F*) pdfFile->FindObjectAny("hdphiMC");
      hpt = (TH1F*) pdfFile->FindObjectAny("hpt");
   }
   // Delta phi fit
   TCanvas *c2 = new TCanvas("c2","",600,600);
   c2->SetLogy();
   c2->SetLogx();

 
   // dphi for unfolding and MC truth:  
   ntTest->Draw("abs(dphi)>>hdphi","abs(eta1)<2&&abs(deta)<0.1","",200000);
   ntTest->Draw("log(pt)>>hptH",mycut,"",200000);
   
   histFunction2D *myfun = new histFunction2D(h);
   
   TF1 *test = new TF1("histFun",myfun,&histFunction2D::evaluate,0,maxDphi,nPtBin+1);
   TF1 *test2 = new TF1("histFunMC",myfun,&histFunction2D::evaluate,0,maxDphi,nPtBin+1);

   for (int i=0;i<nPtBin+1;i++)
   {  
      test->SetParameter(i,1);   
   }


   hdphi2->SetXTitle("|#Delta#phi|");
   hdphi2->SetYTitle("Arbitrary Normalization");
   hdphi2->Fit("histFunMC","M");

   hdphi->SetXTitle("|#Delta#phi|");
   hdphi->SetYTitle("Arbitrary Normalization");
   hdphi->Fit("histFun","M");
   hdphi->SetStats(0);
   hdphi->Draw();

   
   for (int i=0;i<nPtBin+1;i++) {
      TF1 *testPlot = new TF1(Form("histFun%d",i),myfun,&histFunction2D::evaluate,0,maxDphi,nPtBin+1);

      testPlot->SetParameter(i,test->GetParameter(i));
      testPlot->SetLineColor(i+2);
      testPlot->Draw("same");
   }
   
   int total=0,totalMC=0;


   for (int i=0;i<nPtBin;i++){
      if (test->GetParameter(i)==0) continue;
      hptUnfold->SetBinContent(i+1,fabs(test->GetParameter(i)));
      hptUnfold->SetBinError(i+1,test->GetParError(i));

      hptMC->SetBinContent(i+1,fabs(test2->GetParameter(i)));
      hptMC->SetBinError(i+1,test2->GetParError(i));

      total+=fabs(test->GetParameter(i));
      totalMC+=fabs(test2->GetParameter(i));
   }

   hptUnfold->SetEntries(total);
   hptMC->SetEntries(totalMC);
   
   TCanvas *c3 = new TCanvas("c3","",600,600);
   hpt->Sumw2();
   hptH->Sumw2();
   //hptMC->Sumw2();
   
   double normMC=0;
   double norm=0;
   double normTruth=0;
   

   hptUnfold->SetMarkerColor(2);
   hptUnfold->SetMarkerStyle(4);
//   hptUnfold->Scale(1./hptUnfold->GetEntries());
   TH1F *hptCorrected = (TH1F*)hptUnfold->Clone();
   hptCorrected->SetName("hptCorrected");
   hptMC->Divide(hpt);
   hptCorrected->Divide(hptMC);
   
   for (int i=0;i<nPtBin;i++){
      if (hptMC->GetBinContent(i)<=0.001)hptCorrected->SetBinContent(i,0);
   }
   hptCorrected->Scale(1./(hptCorrected->GetSum()));
   hptCorrected->SetMarkerStyle(20);

   hpt->Scale(1./hpt->GetEntries());
   if (hptH->GetEntries())hptH->Scale(1./hptH->GetEntries());

   hptTemp->SetXTitle("ln(P_{T}) GeV/c");
   hptTemp->SetYTitle("Arbitrary Normalization");
   hptTemp->Draw();
   

   hptH->SetXTitle("ln(P_{T}) GeV/c");
   hptH->SetYTitle("Arbitrary Normalization");
   hptH->Draw("hist");
   hptH->SetLineColor(4);
   
   hpt->Draw("hist same ");
   
   hptCorrected->Draw("same");
   
   TH1F *hptUnfoldRatio = (TH1F*)hptUnfold->Clone();
   hptUnfoldRatio->SetName("hptUnfoldRatio");
   hptUnfoldRatio->Scale(1./hptUnfoldRatio->GetSum());
   //hptUnfoldRatio->Divide(hptH);

   TH1F *hptCorrectedRatio = (TH1F*)hptCorrected->Clone();
   hptCorrectedRatio->SetName("hptCorrectedRatio");
   hptCorrectedRatio->SetMarkerColor(2);
   //hptCorrectedRatio->Divide(hptH);

   TCanvas *c4 = new TCanvas("c4","",600,600);
   TLine *l = new TLine(-2.5,1,2.5,1);
   hptUnfoldRatio->Draw();
   hptMC->Draw("same");
   hptCorrectedRatio->Draw("same");
   l->Draw("same");
}
Example #6
0
void Merged()
{
   TH1F *hTracklet = new TH1F("hTracklet","",12,-3,3);

   hTracklet->SetBinContent(2,6.251);
   hTracklet->SetBinContent(11,6.251);
   hTracklet->SetBinContent(3,6.314);
   hTracklet->SetBinContent(10,6.314);
   hTracklet->SetBinContent(4,6.222);
   hTracklet->SetBinContent(9,6.222);
   hTracklet->SetBinContent(5,5.976);
   hTracklet->SetBinContent(8,5.976);
   hTracklet->SetBinContent(6,5.75);
   hTracklet->SetBinContent(7,5.75);
   hTracklet->SetAxisRange(0,8,"Y");
   hTracklet->SetXTitle("#eta");
   hTracklet->SetYTitle("dN/d#eta");

   TH1F *hCluster = new TH1F("hCluster","",12,-3,3);

   hCluster->SetBinContent(3,6.53);
   hCluster->SetBinContent(4,6.25);
   hCluster->SetBinContent(5,6.09);
   hCluster->SetBinContent(6,5.73);
   hCluster->SetBinContent(7,5.73);
   hCluster->SetBinContent(8,6.11);
   hCluster->SetBinContent(9,6.29);
   hCluster->SetBinContent(10,6.55);
   hCluster->SetMarkerStyle(4);

   TH1F *h = new TH1F("h","",40,-10,10);
   h->SetBinContent(0,0.07195663);
   h->SetBinContent(1,0.1089206);
   h->SetBinContent(2,0.2419911);
   h->SetBinContent(3,0.4864465);
   h->SetBinContent(4,0.8314441);
   h->SetBinContent(5,1.224248);
   h->SetBinContent(6,1.54066);
   h->SetBinContent(7,1.773287);
   h->SetBinContent(8,2.302119);
   h->SetBinContent(9,2.786102);
   h->SetBinContent(10,3.409561);
   h->SetBinContent(11,3.827994);
   h->SetBinContent(12,4.253327);
   h->SetBinContent(13,4.371119);
   h->SetBinContent(14,4.529325);
   h->SetBinContent(15,4.641202);
   h->SetBinContent(16,4.679152);
   h->SetBinContent(17,4.618039);
   h->SetBinContent(18,4.389847);
   h->SetBinContent(19,4.233613);
   h->SetBinContent(20,4.05175);
   h->SetBinContent(21,4.100049);
   h->SetBinContent(22,4.364712);
   h->SetBinContent(23,4.435683);
   h->SetBinContent(24,4.593889);
   h->SetBinContent(25,4.614588);
   h->SetBinContent(26,4.524396);
   h->SetBinContent(27,4.514539);
   h->SetBinContent(28,4.350912);
   h->SetBinContent(29,4.185806);
   h->SetBinContent(30,3.950222);
   h->SetBinContent(31,3.432725);
   h->SetBinContent(32,2.915722);
   h->SetBinContent(33,2.364712);
   h->SetBinContent(34,1.825037);
   h->SetBinContent(35,1.494332);
   h->SetBinContent(36,1.25382);
   h->SetBinContent(37,0.8669295);
   h->SetBinContent(38,0.501725);
   h->SetBinContent(39,0.2138985);
   h->SetBinContent(40,0.1059635);
   h->SetBinContent(41,0.07343519);
   h->SetBinError(0,0.005955173);
   h->SetBinError(1,0.007326796);
   h->SetBinError(2,0.01092091);
   h->SetBinError(3,0.01548376);
   h->SetBinError(4,0.02024303);
   h->SetBinError(5,0.0245637);
   h->SetBinError(6,0.02755576);
   h->SetBinError(7,0.029563);
   h->SetBinError(8,0.03368394);
   h->SetBinError(9,0.03705591);
   h->SetBinError(10,0.04099286);
   h->SetBinError(11,0.04343548);
   h->SetBinError(12,0.04578501);
   h->SetBinError(13,0.04641467);
   h->SetBinError(14,0.04724716);
   h->SetBinError(15,0.04782712);
   h->SetBinError(16,0.04802226);
   h->SetBinError(17,0.04770762);
   h->SetBinError(18,0.046514);
   h->SetBinError(19,0.04567878);
   h->SetBinError(20,0.04468691);
   h->SetBinError(21,0.04495247);
   h->SetBinError(22,0.04638064);
   h->SetBinError(23,0.0467562);
   h->SetBinError(24,0.04758271);
   h->SetBinError(25,0.0476898);
   h->SetBinError(26,0.04722145);
   h->SetBinError(27,0.04716998);
   h->SetBinError(28,0.04630726);
   h->SetBinError(29,0.04542014);
   h->SetBinError(30,0.04412348);
   h->SetBinError(31,0.04113188);
   h->SetBinError(32,0.0379081);
   h->SetBinError(33,0.03413879);
   h->SetBinError(34,0.02999127);
   h->SetBinError(35,0.02713829);
   h->SetBinError(36,0.02485859);
   h->SetBinError(37,0.02067049);
   h->SetBinError(38,0.01572504);
   h->SetBinError(39,0.01026746);
   h->SetBinError(40,0.007226653);
   h->SetBinError(41,0.006016045);
   h->SetEntries(237505);
   h->SetFillColor(1);
   h->SetFillStyle(0);
   h->SetLineStyle(0);
   h->SetMarkerStyle(21);
   h->SetMarkerColor(4);
   h->SetMarkerSize(1.25);
   h->GetXaxis()->SetTitle("#eta");
   h->GetXaxis()->SetLabelFont(42);
   h->GetXaxis()->SetLabelOffset(0.01);
   h->GetXaxis()->SetLabelSize(0.045);
   h->GetXaxis()->SetTitleSize(0.055);
   h->GetXaxis()->SetTitleFont(42);
   h->GetYaxis()->SetTitle("dN/d#eta");
   h->GetYaxis()->SetLabelFont(42);
   h->GetYaxis()->SetLabelOffset(0.01);
   h->GetYaxis()->SetLabelSize(0.045);
   h->GetYaxis()->SetTitleSize(0.055);
   h->GetYaxis()->SetTitleOffset(1.3);
   h->GetYaxis()->SetTitleFont(42);
   h->GetZaxis()->SetLabelFont(42);
   h->GetZaxis()->SetLabelSize(0.045);
   h->GetZaxis()->SetTitleFont(42);


   TH1F *hATLAS = new TH1F("hATLAS","",40,-10,10);
   hATLAS->SetBinContent(0,0.08524267);
   hATLAS->SetBinContent(1,0.1512688);
   hATLAS->SetBinContent(2,0.3321015);
   hATLAS->SetBinContent(3,0.6415373);
   hATLAS->SetBinContent(4,0.9425967);
   hATLAS->SetBinContent(5,1.193397);
   hATLAS->SetBinContent(6,1.452082);
   hATLAS->SetBinContent(7,1.836413);
   hATLAS->SetBinContent(8,2.275437);
   hATLAS->SetBinContent(9,2.840108);
   hATLAS->SetBinContent(10,3.400838);
   hATLAS->SetBinContent(11,4.043853);
   hATLAS->SetBinContent(12,4.521803);
   hATLAS->SetBinContent(13,5.043114);
   hATLAS->SetBinContent(14,5.39591);
   hATLAS->SetBinContent(15,5.757083);
   hATLAS->SetBinContent(16,6.010347);
   hATLAS->SetBinContent(17,6.007884);
   hATLAS->SetBinContent(18,5.883715);
   hATLAS->SetBinContent(19,5.838877);
   hATLAS->SetBinContent(20,5.451097);
   hATLAS->SetBinContent(21,5.490022);
   hATLAS->SetBinContent(22,5.663464);
   hATLAS->SetBinContent(23,5.971914);
   hATLAS->SetBinContent(24,6.058635);
   hATLAS->SetBinContent(25,5.969944);
   hATLAS->SetBinContent(26,5.797487);
   hATLAS->SetBinContent(27,5.353043);
   hATLAS->SetBinContent(28,4.894802);
   hATLAS->SetBinContent(29,4.5085);
   hATLAS->SetBinContent(30,4.00542);
   hATLAS->SetBinContent(31,3.448633);
   hATLAS->SetBinContent(32,2.883469);
   hATLAS->SetBinContent(33,2.337029);
   hATLAS->SetBinContent(34,1.805863);
   hATLAS->SetBinContent(35,1.42104);
   hATLAS->SetBinContent(36,1.205223);
   hATLAS->SetBinContent(37,0.9795516);
   hATLAS->SetBinContent(38,0.6228135);
   hATLAS->SetBinContent(39,0.3261887);
   hATLAS->SetBinContent(40,0.1547179);
   hATLAS->SetBinContent(41,0.09608278);
   hATLAS->SetBinError(0,0.00648088);
   hATLAS->SetBinError(1,0.008633366);
   hATLAS->SetBinError(2,0.01279207);
   hATLAS->SetBinError(3,0.01777937);
   hATLAS->SetBinError(4,0.02155105);
   hATLAS->SetBinError(5,0.02424923);
   hATLAS->SetBinError(6,0.0267486);
   hATLAS->SetBinError(7,0.03008089);
   hATLAS->SetBinError(8,0.03348404);
   hATLAS->SetBinError(9,0.03740873);
   hATLAS->SetBinError(10,0.04093534);
   hATLAS->SetBinError(11,0.04463784);
   hATLAS->SetBinError(12,0.0472021);
   hATLAS->SetBinError(13,0.04984882);
   hATLAS->SetBinError(14,0.05156296);
   hATLAS->SetBinError(15,0.05326068);
   hATLAS->SetBinError(16,0.05441959);
   hATLAS->SetBinError(17,0.05440843);
   hATLAS->SetBinError(18,0.05384325);
   hATLAS->SetBinError(19,0.0536377);
   hATLAS->SetBinError(20,0.05182597);
   hATLAS->SetBinError(21,0.05201068);
   hATLAS->SetBinError(22,0.05282586);
   hATLAS->SetBinError(23,0.05424532);
   hATLAS->SetBinError(24,0.05463776);
   hATLAS->SetBinError(25,0.05423637);
   hATLAS->SetBinError(26,0.05344725);
   hATLAS->SetBinError(27,0.05135773);
   hATLAS->SetBinError(28,0.04911035);
   hATLAS->SetBinError(29,0.04713261);
   hATLAS->SetBinError(30,0.04442521);
   hATLAS->SetBinError(31,0.04122199);
   hATLAS->SetBinError(32,0.03769321);
   hATLAS->SetBinError(33,0.03393419);
   hATLAS->SetBinError(34,0.02982963);
   hATLAS->SetBinError(35,0.02646114);
   hATLAS->SetBinError(36,0.02436908);
   hATLAS->SetBinError(37,0.02196945);
   hATLAS->SetBinError(38,0.017518);
   hATLAS->SetBinError(39,0.01267768);
   hATLAS->SetBinError(40,0.008731237);
   hATLAS->SetBinError(41,0.006880631);
   hATLAS->SetEntries(280271);
   hATLAS->SetFillColor(1);
   hATLAS->SetFillStyle(0);
   hATLAS->SetLineStyle(0);
   hATLAS->SetMarkerStyle(22);
   hATLAS->SetMarkerColor(4);
   hATLAS->SetMarkerSize(1.25);
   hATLAS->GetXaxis()->SetTitle("#eta");
   hATLAS->GetXaxis()->SetLabelFont(42);
   hATLAS->GetXaxis()->SetLabelOffset(0.01);
   hATLAS->GetXaxis()->SetLabelSize(0.045);
   hATLAS->GetXaxis()->SetTitleSize(0.055);
   hATLAS->GetXaxis()->SetTitleFont(42);
   hATLAS->GetYaxis()->SetTitle("dN/d#eta");
   hATLAS->GetYaxis()->SetLabelFont(42);
   hATLAS->GetYaxis()->SetLabelOffset(0.01);
   hATLAS->GetYaxis()->SetLabelSize(0.045);
   hATLAS->GetYaxis()->SetTitleSize(0.055);
   hATLAS->GetYaxis()->SetTitleOffset(1.3);
   hATLAS->GetYaxis()->SetTitleFont(42);
   hATLAS->GetZaxis()->SetLabelFont(42);
   hATLAS->GetZaxis()->SetLabelSize(0.045);
   hATLAS->GetZaxis()->SetTitleFont(42);
   
   TCanvas *MyCanvas = new TCanvas("MyCanvas", "Final result",1,360,550,600);

   hTracklet->Draw("p");
   hCluster->Draw("p same");
   hATLAS->Draw("same");
   h->Draw("same");
   Float_t ywidth = 0.25;
   //TLegend *leg2 = new TLegend(0.38,0.27,0.81,0.27+ywidth2,"","brNDC");
   TLegend *leg2 = new TLegend(0.39,0.21,0.82,0.21+ywidth,NULL,"brNDC");

   leg2->SetMargin(0.5);
   leg2->SetBorderSize(0);
   leg2->SetTextFont(62);
   leg2->SetLineColor(1);
   leg2->SetLineStyle(1);
   leg2->SetLineWidth(1);
   leg2->SetFillColor(0);
   //leg->SetFillStyle(1001);
   leg2->SetFillStyle(0);
   leg2->SetTextSize(0.033);
   leg2->SetHeader("     7.0 TeV");
   leg2->AddEntry(hTracklet,"CMS Preliminary Tracklet","p");
   leg2->AddEntry(hCluster,"CMS Preliminary Cluster","p");
   leg2->AddEntry(hATLAS,"ATLAS Tune","p");
   leg2->AddEntry(h,"D6T Tune","p");


   leg2->Draw();
}