Пример #1
0
//______________________________________________________________________________
void ArgusHistoDisplay::SetLimits(TGraph *g)
{
   const Int_t n = g->GetN();
   if (n<=1) {
      return;
   }
   int i;
   double xmin, xmax, ymin, ymax;
   double *x;
   double *y;
   x = g->GetX();
   y = g->GetY();
   xmin = xmax = x[0];
   ymin = ymax = y[0];
   for (i=1;i<n;i++) {
      if (xmin>x[i])
         xmin = x[i];
      if (xmax<x[i])
         xmax = x[i];
      if (ymin>y[i])
         ymin = y[i];
      if (ymax<y[i])
         ymax = y[i];
   }
   if (xmin<xmax && ymin<ymax) {
      g->SetMinimum(ymin-(ymax-ymin)/10.);
      g->SetMaximum(ymax+(ymax-ymin)/10.);
      TAxis *axis = g->GetXaxis();
      if(axis) {
         axis->SetLimits(xmin, xmax);
      }
   }
}
Пример #2
0
void Draw_ALICEMid_JPsi_RaaVsNpart(TLegend *lgd)
{
  //ALICE MID rapidity
  int nbinsALICEMid=3;
  Double_t NPartALICEMid[3]={357,193,46};
  Double_t ErrNPartALICEMid[3]={0};
  Double_t RaaALICEMid[3] = {0.82,0.65,0.73}; 
  Double_t SystErrALICEMid[3] = {0.15,0.10,0.16};
  
  TGraphErrors *grRaaALICEMid = new TGraphErrors(nbinsALICEMid, NPartALICEMid, RaaALICEMid, ErrNPartALICEMid, SystErrALICEMid);  
  grRaaALICEMid->SetMarkerStyle(20);
  grRaaALICEMid->SetMarkerColor(2);
  //grRaaALICEMid->SetLineColor(2);
  grRaaALICEMid->GetYaxis()->SetRangeUser(0,1.5);
  
  TAxis *Xaxis = grRaaALICEMid->GetXaxis();
  Xaxis->SetLimits(0.,430.0);
  grRaaALICEMid->GetXaxis()->SetTitle("N_{Part}");
  grRaaALICEMid->GetYaxis()->SetTitle("R_{AA}");
  
  grRaaALICEMid->Draw("Psame");
  
  //TLatex *tb= new TLatex;
  //tb->SetNDC(); 
  //tb->SetTextAlign(12);
  //tb->SetTextColor(1);
  //tb->SetTextSize(0.040);
  //tb->DrawLatex(0.55,0.90,"PbPb #sqrt{s_{NN}} = 2.76 TeV");
  //tb->DrawLatex(0.22,0.16,"J/#psi #rightarrow #mu^{+} #mu^{-}, p_{T}^{J/#psi} > 0.0 GeV/c");  
  //tb->DrawLatex(0.55,0.85,"p_{T}^{J/#psi} > 0.0 GeV/c");  
  
  TLine *lh3 = new TLine(0.0,1.0,420,1.0);
  lh3->SetLineColor(1);
  lh3->SetLineStyle(1);
  lh3->SetLineWidth(1.5);
  lh3->Draw("same");
    
  TBox *RaaJPsiALICEMidSys[12];
  for(int j=0;j<3;j++){
    RaaJPsiALICEMidSys[j] = new TBox(NPartALICEMid[j]-3,  RaaALICEMid[j]-SystErrALICEMid[j], NPartALICEMid[j]+3, RaaALICEMid[j]+SystErrALICEMid[j]);
  }
  
  for(int j=0;j<3;j++){
    RaaJPsiALICEMidSys[j]->SetFillStyle(0000);
    RaaJPsiALICEMidSys[j]->SetLineColor(2);
    RaaJPsiALICEMidSys[j]->Draw("same"); 
  }
  
  TBox *ALICEMidGlobalSysJPsi;
  ALICEMidGlobalSysJPsi = new TBox(385-5, 1 - 0.26, 385+5, 1 + 0.26);
  
  ALICEMidGlobalSysJPsi->SetFillStyle(3001);
  ALICEMidGlobalSysJPsi->SetLineColor(2);
  ALICEMidGlobalSysJPsi->SetFillColor(2);
  ALICEMidGlobalSysJPsi->Draw("same"); 

  lgd->AddEntry(grRaaALICEMid,"ALICE Data p_{T}^{J/#psi} > 0.0 GeV/c, |y^{J/#psi}| #leq 1.0","P");
  
}
Пример #3
0
void Draw_CMS_JPsi_RaaVsRap(TLegend *lgd)
{
  //=============== CMS Raa Vs Rap Data ===============================================================//
  //AvpT 10.92,9.65,8.92
  int nbinsRapCMS=3;
  Double_t RapCMSD[3]={0.6,1.4,2.0};
  Double_t ErrRapCMS[3]={0.6,0.2,0.4};
  Double_t RaaRapCMS[3] = {0.31,0.33,0.36}; 
  Double_t RaaRapStatErrCMS[3] = {0.02,0.03,0.03};
  Double_t RaaRapSystErrCMS[3] = {0.03,0.04,0.04};

  TGraphErrors *grRaaRapCMS = new TGraphErrors(nbinsRapCMS, RapCMSD, RaaRapCMS, ErrRapCMS, RaaRapStatErrCMS);  
  grRaaRapCMS->SetMarkerStyle(20);
  grRaaRapCMS->SetMarkerColor(2);
  grRaaRapCMS->GetYaxis()->SetRangeUser(0,1.5);
  grRaaRapCMS->GetXaxis()->SetTitle("|y|");
  grRaaRapCMS->GetYaxis()->SetTitle("R_{AA}");
  
  TAxis *XaxisgrRaaRapCMS = grRaaRapCMS->GetXaxis();
  XaxisgrRaaRapCMS->SetLimits(0.0,2.4);
  
  grRaaRapCMS->Draw("AP"); 

  TLine *lh_grRaaRapCMS = new TLine(0.0,1.0,2.4,1.0);
  lh_grRaaRapCMS->SetLineColor(1);
  lh_grRaaRapCMS->SetLineStyle(1);
  lh_grRaaRapCMS->SetLineWidth(1.5);
  lh_grRaaRapCMS->Draw("same");

  TLatex *tb= new TLatex;
  tb->SetNDC(); 
  tb->SetTextAlign(12);
  tb->SetTextColor(1);
  tb->SetTextSize(0.040);
  tb->DrawLatex(0.20,0.20,"Pb+Pb #sqrt{s_{NN}} = 2.76 TeV");
  tb->DrawLatex(0.20,0.15,"J/#psi #rightarrow #mu^{+} #mu^{-}, p_{T}^{J/#psi} > 6.5 GeV/c");  
  
  TBox *RaaRapJPsiCMSSys[4];
  for(int j=0;j<3;j++){
    RaaRapJPsiCMSSys[j] = new TBox(RapCMSD[j]-0.05,  RaaRapCMS[j]-RaaRapSystErrCMS[j], RapCMSD[j]+0.05,  RaaRapCMS[j]+RaaRapSystErrCMS[j]);
  }
  
  for(int j=0;j<3;j++){
    RaaRapJPsiCMSSys[j]->SetFillStyle(0000);
    RaaRapJPsiCMSSys[j]->SetLineColor(2);
    RaaRapJPsiCMSSys[j]->Draw("same"); 
  }
  
  TBox *CMSGlobalSysJPsiRap;
  CMSGlobalSysJPsiRap = new TBox(0.2-0.05, 1 - 0.05, 0.2+0.05, 1 + 0.05);
  CMSGlobalSysJPsiRap->SetFillStyle(3001);
  CMSGlobalSysJPsiRap->SetLineColor(2);
  CMSGlobalSysJPsiRap->SetFillColor(2);
  CMSGlobalSysJPsiRap->Draw("same"); 


  lgd->AddEntry(grRaaRapCMS,"CMS Data", "P");
}
Пример #4
0
//______________________________________________________________________________
void ROMETGraphErrors::SetLimits()
{
    Double_t rwxmin,rwxmax, rwymin, rwymax, dx, dy;
    ComputeRange(rwxmin, rwymin, rwxmax, rwymax);

    if (rwxmin == rwxmax) rwxmax += 1.;
    if (rwymin == rwymax) rwymax += 1.;
    dx = 0.1 * (rwxmax - rwxmin);
    dy = 0.1 * (rwymax - rwymin);
    fMinimum = rwymin - dy;
    fMaximum = rwymax + dy;
    TAxis *axis = GetXaxis();

    if(axis) {
        axis->SetLimits(rwxmin - dx, rwxmax + dx);
    }
}
Пример #5
0
void Draw_CMS_JPsi_RaaVspT(TLegend *legend_ratio)
{
  
  int nbinsPtCMS=4;
  Double_t PtCMSD[4]={7.31,8.97,11.32,16.52};
  Double_t ErrPtCMS[4]={0};
  Double_t RaaPtCMS[4] = {0.35,0.34,0.34,0.29}; 
  Double_t RaaPtStatErrCMS[4] = {0.09,0.03,0.03,0.04};
  Double_t RaaPtSystErrCMS[4] = {0.04,0.04,0.03,0.03};
  
  TGraphErrors *grRaaPtCMS = new TGraphErrors(nbinsPtCMS, PtCMSD, RaaPtCMS, ErrPtCMS, RaaPtStatErrCMS);  
  grRaaPtCMS->SetMarkerStyle(21);
  grRaaPtCMS->SetMarkerColor(kRed+1);
  grRaaPtCMS->SetMarkerSize(1.3);
  //grRaaPtCMS->SetFillColor(kRed);
  grRaaPtCMS->SetLineColor(1);
  grRaaPtCMS->GetYaxis()->SetRangeUser(0,1.5);
  grRaaPtCMS->GetXaxis()->SetTitle("p_{T}(GeV/c)");
  grRaaPtCMS->GetYaxis()->SetTitle("R_{AA}");
  
  TLine *lh5 = new TLine(0.0,1.0,20.0,1.0);
  lh5->SetLineColor(1);
  lh5->SetLineStyle(1);
  lh5->SetLineWidth(1.5);
  
  TLatex *tb= new TLatex;
  tb->SetNDC(); 
  tb->SetTextAlign(12);
  tb->SetTextColor(1);
  tb->SetTextSize(0.040);
  
  TBox *RaaPtJPsiCMSSys[4];
  for(int j=0;j<4;j++){
    RaaPtJPsiCMSSys[j] = new TBox(PtCMSD[j]-0.4,  RaaPtCMS[j]-RaaPtSystErrCMS[j], PtCMSD[j]+0.4,  RaaPtCMS[j]+RaaPtSystErrCMS[j]);
  }
  
  for(int j=0;j<4;j++){
    RaaPtJPsiCMSSys[j]->SetFillStyle(1001);
    RaaPtJPsiCMSSys[j]->SetFillColor(kPink+1);
    RaaPtJPsiCMSSys[j]->SetLineColor(1);
  }
  
  TBox *CMSGlobalSysJPsiPt;
  //CMSGlobalSysJPsiPt = new TBox(27.0-1.0, 1 - 0.075, 27.0+1.0, 1 + 0.075);
  CMSGlobalSysJPsiPt = new TBox(19.165,0.923,19.948,1.067);
  CMSGlobalSysJPsiPt->SetFillStyle(3001);
  CMSGlobalSysJPsiPt->SetLineColor(2);
  CMSGlobalSysJPsiPt->SetFillColor(2);
  
  TAxis *XaxisgrRaaPtCMS = grRaaPtCMS->GetXaxis();
  XaxisgrRaaPtCMS->SetLimits(0.0,20.0);
  grRaaPtCMS->Draw("AP");
  for(int j=0;j<4;j++) RaaPtJPsiCMSSys[j]->Draw("same"); 
  grRaaPtCMS->Draw("Psame");
  CMSGlobalSysJPsiPt->Draw("same"); 
  tb->SetTextSize(0.030);
  //tb->DrawLatex(0.20,0.20,"PbPb #sqrt{s_{NN}} = 2.76 TeV");
  tb->DrawLatex(0.71476,0.91289,"J/#psi #rightarrow #mu^{+} #mu^{-}");  
  lh5->Draw("same");
  //legend_ratio->AddEntry(grRaaPtCMS,"PbPb #sqrt{s_{NN}} = 2.76 TeV and Au-Au #sqrt{s_{NN}} = 0.2 TeV", "");
  legend_ratio->AddEntry(grRaaPtCMS,"Pb+Pb #sqrt{s_{NN}} = 2.76 TeV", "");
  legend_ratio->AddEntry(grRaaPtCMS,"Prompt J/#psi CMS: |y| < 2.4", "P");

  //legend_ratio->AddEntry(grRaaPtCMS,"PbPb #sqrt{s_{NN}} = 2.76 TeV and Au-Au #sqrt{s_{NN}} = 0.2 TeV", "");
  //legend_ratio->AddEntry(grRaaPtCMS,"CMS: J/#psi #rightarrow #mu^{+} #mu^{-}, |y| < 2.4 & p_{T}^{J/#psi} > 6.5 GeV/c", "P");
  //legend_ratio->AddEntry(grRaaPtCMS,"CMS: J/#psi #rightarrow #mu^{+} #mu^{-}, |y| < 2.4 & p_{T}^{J/#psi} > 6.5 GeV/c", "P");
}
Пример #6
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// drawFigure7
//
//    parameter = "dg0"
//    parameter = "lam0"
//    parameter = "dk0"
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void drawFigure7(TString parameter = "dk0")
{
  gInterpreter->ExecuteMacro("WZPaperStyle.C");

  gSystem->mkdir("pdf", kTRUE);
  gSystem->mkdir("png", kTRUE);


  // Individual settings
  //----------------------------------------------------------------------------
  if (parameter.Contains("dg0"))
    {
      xtitle = "#Delta#kappa^{Z}";
      ytitle = "#lambda";
      xmin   = -0.5;
      xmax   =  0.5;
      ymin   = -0.039;
      ymax   =  0.053;
    }
  else if (parameter.Contains("lam0"))
    {
      xtitle = "#Delta#kappa^{Z}";
      ytitle = "#Deltag^{Z}_{1}";
      xmin   = -0.53;
      xmax   =  0.53;
      ymin   = -0.05;
      ymax   =  0.09;
    }
  else if (parameter.Contains("dk0"))
    {
      xtitle = "#Deltag^{Z}_{1}";
      ytitle = "#lambda";
      xmin   = -0.059;
      xmax   =  0.059;
      ymin   = -0.037;
      ymax   =  0.052;
    }


  // Read the input file
  //----------------------------------------------------------------------------
  TFile* file = new TFile("rootfiles/contours_" + parameter + "_2Dpol2.root", "read");

  TGraph* cont_exp_68 = (TGraph*)file->Get("cont_exp_68");
  TGraph* cont_exp_95 = (TGraph*)file->Get("cont_exp_95");
  TGraph* cont_exp_99 = (TGraph*)file->Get("cont_exp_99");
  TGraph* cont_obs_95 = (TGraph*)file->Get("cont_obs_95");
  TGraph* bestFit     = (TGraph*)file->Get("bestFit");

  bestFit->SetMarkerSize(1.5);
  bestFit->SetMarkerStyle(34);

  TGraph* g_large = new TGraph(2);

  g_large->SetPoint(0, -1.0, 1.0);
  g_large->SetPoint(1,  1.0, 1.0);


  // Draw
  //----------------------------------------------------------------------------
  TCanvas* canvas = new TCanvas("canvas", "canvas");

  TMultiGraph* mg = new TMultiGraph();

  mg->Add(cont_exp_68);
  mg->Add(cont_exp_95);
  mg->Add(cont_exp_99);
  mg->Add(cont_obs_95);
  mg->Add(bestFit, "p");
  mg->Add(g_large);

  mg->Draw("ac");

  mg->SetMinimum(ymin);
  mg->SetMaximum(ymax);


  // Axis labels
  //----------------------------------------------------------------------------
  TAxis* xaxis = mg->GetXaxis();
  TAxis* yaxis = mg->GetYaxis();
  
  xaxis->SetLabelFont  (    42);
  xaxis->SetLabelOffset(  0.01);
  xaxis->SetLabelSize  (  0.05);
  xaxis->SetNdivisions (   505);
  xaxis->SetTitle      (xtitle);
  xaxis->SetTitleFont  (    42);
  xaxis->SetTitleOffset(   1.2);
  xaxis->SetTitleSize  (  0.05);

  xaxis->SetLimits(xmin, xmax);

  yaxis->SetLabelFont  (    42);
  yaxis->SetLabelOffset(  0.01);
  yaxis->SetLabelSize  (  0.05);
  yaxis->SetNdivisions (   505);
  yaxis->SetTitle      (ytitle);
  yaxis->SetTitleFont  (    42);
  yaxis->SetTitleOffset(   1.6);
  yaxis->SetTitleSize  (  0.05);

  canvas->Modified();


  // Legend
  //----------------------------------------------------------------------------
  Double_t x0 = 0.580;
  Double_t y0 = 0.755;

  DrawTLegend(x0 - 0.36, y0 + 2.*(_yoffset+0.001), (TH1F*)cont_exp_68, " Expected 68% CL", "l");
  DrawTLegend(x0 - 0.36, y0 + 1.*(_yoffset+0.001), (TH1F*)cont_exp_95, " Expected 95% CL", "l");
  DrawTLegend(x0,        y0 + 2.*(_yoffset+0.001), (TH1F*)cont_exp_99, " Expected 99% CL", "l");
  DrawTLegend(x0,        y0 + 1.*(_yoffset+0.001), (TH1F*)cont_obs_95, " Observed 95% CL", "l");
  DrawTLegend(x0,        y0,                       (TH1F*)bestFit,     " Best fit",          "p");


  // Finish it
  //----------------------------------------------------------------------------
  DrawTLatex(_cmsTextFont,   0.190, 0.94, 0.055, 11, "CMS");
  //  DrawTLatex(_extraTextFont, 0.315, 0.94, 0.030, 11, "Preliminary");
  DrawTLatex(_lumiTextFont,  0.940, 0.94, 0.040, 31, "19.6 fb^{-1} (8 TeV)");

  canvas->SaveAs("pdf/lZ_dkg_2dlimit_" + parameter + "_2Dpol2_deltaNLL.pdf");
  canvas->SaveAs("png/lZ_dkg_2dlimit_" + parameter + "_2Dpol2_deltaNLL.png");
}
Пример #7
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");   
  */

}
Пример #8
0
void genPngClsExpBarrel100(){
  //Being calculated the number of rolls from luigi's file
  string line;
  ifstream rollslist;
  ifstream luigi;
  luigi.open("data/luigi.txt");
  if(!luigi){
    cout<<"WARNING luigi.txt do not exist"<<endl;
  }
  cout<<"Reading Luigis file"<<endl;
  int l=0;
  while(!luigi.eof()){
    getline(luigi,line);
    l++;
  }
  const int runsAmmount = l-1;
  
  //Being defined the variables and constants
  const int P=200;
  ifstream runsData;
  TGraphErrors * hvcls;
  const int runsHavingInAccount = runsAmmount -3;
  float ex[runsAmmount]; 
  float HV[runsAmmount];
  float EFF[runsAmmount];
  float ERR[runsAmmount];
  float EXP[runsAmmount];
  float CLS[runsAmmount];
  float hv[runsHavingInAccount];
  float cls[runsHavingInAccount];
  float exc[runsHavingInAccount];
  float ecls[runsHavingInAccount];
  ifstream rolls;
  string rollName;
  double ca,cb;
  double chi2,wp,clswp;
  double knee,clsknee;
  ifstream fitData;
  TCanvas *c1 = new TCanvas("C1","CLS VS HV",200,10,800,600);  
  TF1 *f1;
  float wpCh[1];
  float clsWpCh[1];
  float hvc[2];
  float CLSc[2];
  float xmax=9.9;
  float xmin = 8.5;
  float x[P];
  float y[P];
  double wpDef;
  double clsWpDef;
  ifstream wpChannel;
  
  rolls.open("data/Barrel.txt");
  rolls>>rollName;      
  while (!rolls.eof()){
    //Being charged the working point per channel associated with the current roll
    /*    wpChannel.open(("results/"+rollName+"/wpChannel.txt").c_str());
    wpChannel>>wpDef;
    cout<<"wpDef= "<<wpDef<<endl;
    wpChannel.close();
    */
    //Being charged the run data for the current roll
    runsData.open(("results/"+rollName+"/runsData.txt").c_str());
    for (int n=0;n<runsAmmount;n++){
      runsData>>HV[n]>>EFF[n]>>ERR[n]>>EXP[n]>>CLS[n];
      //The first three runs (lower high voltage) are not plotted
      if (n>2){
	hv[n-3]=HV[n];
	cls[n-3]=CLS[n];
      }
    }
    runsData.close();

    ///////////////////////////////// The error in this cases is defined in this way,  this is something that must be improved    
    for(int n=0;n<runsAmmount;n++){
      if (n>2){
	exc[n-3]=0.0001;
	ecls[n-3] = 0.0001;
      }
    }
    
    //////////////////////////////////////////////////////
    //Being charged the fit data obtained for the current roll
    hvcls = new TGraphErrors(runsHavingInAccount, hv, cls, exc, ecls);
    cout<<rollName;
    fitData.open(("results/"+rollName+"/fitDataCLS.txt").c_str());
    fitData>>ca>>cb>>chi2>>wp>>clswp>>wpDef>>clsWpDef;
    cout<<ca<<" "<<cb<<" "<<wp<<" "<<clswp<<endl;
    fitData.close();
    f1 = new TF1("f1",expFunc,8.5,9.9,2); //3 es el numero de parametros del fit//
    f1->SetParameter(0, ca);
    f1->SetParameter(1, cb);//
    
    //Being made the plot of Working Point and Knee  
    knee = wp - 0.100;
    clsknee=expFuncAMano(knee,ca,cb);
    hvc[0]=wp - 0.100;
    hvc[1]=wp;
    CLSc[0]=clsknee;
    CLSc[1]=clswp;
    TGraph *gr2 = new TGraph(2,hvc,CLSc);
    
    //Being made the plot of Working Point per Channel
    wpCh[0]=wpDef;
    clsWpCh[0]=clsWpDef;
    TGraph *gr4 = new TGraph(1,wpCh,clsWpCh);
    
    //Being made the plot of the sigmoid
    for (int k=0; k<P; k++){
      x[k]=xmin+k*(xmax-xmin)/(P-1);
      y[k]=expFuncAMano(x[k],ca,cb);
      x[k]=x[k];
    }
    TGraph *gr3 = new TGraph(200,x,y);
   
    
    //Being set plot parameters 
    hvcls->SetLineColor(kRed);
    hvcls->SetMarkerStyle(20);
    hvcls->SetMarkerSize(2.0);
    hvcls->SetMinimum(-0.01);
    hvcls->SetMaximum(6);
    TAxis *axis = hvcls->GetXaxis();
    axis->SetLimits(8.5,9.9); 
    hvcls->SetTitle(("CLS vs HV_Eff " + rollName).c_str());
    hvcls->GetXaxis()->SetTitle("HV_Eff(kV)");
    hvcls->GetYaxis()->SetTitle("CLS");
    hvcls->Draw("AP");   
    gr3->SetLineColor(kBlue);
    gr3->Draw("C");// superimpose the second graph by leaving out the axis option "A"
    gr2->SetMarkerStyle(28);
    gr2->SetMarkerSize(3);
    gr2->SetLineColor(kBlue);
    gr2->Draw("P");
    gr4->SetMarkerStyle(24);
    gr4->SetMarkerSize(5);
    gr4->SetLineColor(kRed);
    gr4->Draw("P");
    
    //Being stored the plot as png file
    gSystem->mkdir(("results/"+rollName).c_str());
    c1->SaveAs(("results/"+rollName+"/CLSvsHV.png").c_str());
    c1->Clear();     
    //}
    rolls>>rollName;
  }
  exit(0);
}
Пример #9
0
void SinglePionEfficiencyNewVSpT::Loop()
{
//   In a ROOT session, you can do:
//      Root > .L SinglePionEfficiencyNewVSpT.C
//      Root > SinglePionEfficiencyNewVSpT t
//      Root > t.GetEntry(12); // Fill t data members with entry number 12
//      Root > t.Show();       // Show values of entry 12
//      Root > t.Show(16);     // Read and show values of entry 16
//      Root > t.Loop();       // Loop on all entries
//

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

    Long64_t nentries = fChain->GetEntriesFast();

    Long64_t nbytes = 0, nb = 0;


    // number of pt bins and intervals
    const Int_t nptbins = 17;
    const Int_t nptcuts = nptbins+1;
    //   const Double_t pt[nptcuts]={0.0, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.5, 3.0, 4.0, 5.0, 10.0, 15.0, 20.0, 25.0, 30.0, 40., 50.0};
    const Double_t pt[nptcuts]= {1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.5, 3.0, 4.0, 5.0, 10.0, 15.0, 20.0, 25.0, 30.0, 40., 50.0, 60.0};
    //                              0    1    2    3    4    5    6    7    8    9
    // energy ecal+hcal in different matrices
    TProfile* hprEH11x5  = new  TProfile("hprEH11x5","prEH11x5",nptbins, pt, -10., 10.);
    TProfile* hprEH11x3  = new  TProfile("hprEH11x3","prEH11x3",nptbins, pt, -10., 10.);
    TProfile* hprEH7x5   = new  TProfile("hprEH7x5","prEH7x5",nptbins, pt, -10., 10.);
    TProfile* hprEH7x3   = new  TProfile("hprEH7x3","prEH7x3",nptbins, pt, -10., 10.);
    // energy in hcal matrix
    TProfile* hprH5  = new  TProfile("hprH5","prH5",nptbins, pt, -10., 10.);
    TProfile* hprH3  = new  TProfile("hprH3","prH3",nptbins, pt, -10., 10.);

    //
    TH1F * hH5_1_2GeV    = new TH1F( "hH5_1_2GeV", "H5_1_2GeV", 40, -2., 2.);
    TH1F * hH3_1_2GeV    = new TH1F( "hH3_1_2GeV", "H3_1_2GeV", 40, -2., 2.);
    TH1F * hH5_3_4GeV    = new TH1F( "hH5_3_4GeV", "H5_3_4GeV", 40, -2., 2.);
    TH1F * hH3_3_4GeV    = new TH1F( "hH3_3_4GeV", "H3_3_4GeV", 40, -2., 2.);
    TH1F * hH5_5_10GeV   = new TH1F( "hH5_5_10GeV", "H5_5_10GeV", 40, -2., 2.);
    TH1F * hH3_5_10GeV   = new TH1F( "hH3_5_10GeV", "H3_5_10GeV", 40, -2., 2.);

    //
    TH1F * hE11_1_2GeV   = new TH1F( "hE11_1_2GeV", "E11_1_2GeV", 100, -2., 2.);
    TH1F * hE11_3_4GeV   = new TH1F( "hE11_3_4GeV", "E11_3_4GeV", 100, -2., 2.);
    TH1F * hE11_5_10GeV  = new TH1F( "hE11_5_10GeV", "E11_5_10GeV", 100, -2., 2.);

    //
    TH1F * hE11H5_1_2GeV   = new TH1F( "hE11H5_1_2GeV", "E11H5_1_2GeV", 40, -2., 2.);
    TH1F * hE11H5_3_4GeV   = new TH1F( "hE11H5_3_4GeV", "E11H5_3_4GeV", 40, -2., 2.);
    TH1F * hE11H5_5_10GeV  = new TH1F( "hE11H5_5_10GeV", "E11H5_5_10GeV", 40, -2., 2.);

    //   TH1F * hEH11x5 = new TH1F( "hEH11x5", "EH11x5", 200, -2., 2.);
    //   TH2F * hresp2 = new TH2F( "hresp2", "resp2", 200, -2., 2.,200, -2., 2.);

    // prepare for graph
    Float_t ptgr[nptbins], eptgr[nptbins];
    for(Int_t i = 0; i < nptbins; i++) {
        ptgr[i]  = 0.5*(pt[i]+pt[i+1]);
        eptgr[i] = 0.5*(pt[i+1]-pt[i]);
        cout <<" i = " << i <<" pT = " << ptgr[i] <<" err pT = " << eptgr[i] << endl;
    }

    // number of eta bins and intervals
    const Int_t netabins = 12;
    const Int_t netacuts = netabins+1;
    Float_t eta[netacuts]= {0.01, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2, 2.4};
    cout <<"  Eta bins " << endl;
    // prepare eta points for graph
    Float_t etagr[netabins], eetagr[netabins];
    for(Int_t i = 0; i < netabins; i++) {
        etagr[i]  = 0.5*(eta[i]+eta[i+1]);
        eetagr[i] = 0.5*(eta[i+1]-eta[i]);
        cout <<" i = " << i <<" Eta = " << etagr[i] <<" err Eta = " << eetagr[i] << endl;
    }

    // ===> for pi- and pi+
    // N total and N reco tracks
    // efficiency and error as a function of pT
    Int_t ntrk[nptbins]     = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
    Int_t ntrkreco[nptbins] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
    Int_t ntrkrecor[nptbins] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
    Float_t trkeff[nptbins], etrkeff[nptbins];
    Double_t responceVSpt[nptbins]  = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
    Double_t responceVSptF[nptbins];
    Double_t eresponceVSpt[nptbins] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

    // N total and N reco tracks
    // efficiency and error as a function of eta
    Int_t ntrketa[netabins]     = {0,0,0,0,0,0,0,0,0,0,0,0};
    Int_t ntrketareco[netabins] = {0,0,0,0,0,0,0,0,0,0,0,0};
    Int_t ntrketarecor[netabins] = {0,0,0,0,0,0,0,0,0,0,0,0};
    Float_t trketaeff[netabins], etrketaeff[netabins];
    Double_t responceVSeta[nptbins]  = {0,0,0,0,0,0,0,0,0,0,0,0};
    Double_t responceVSetaF[nptbins];
    Double_t eresponceVSeta[nptbins] = {0,0,0,0,0,0,0,0,0,0,0,0};

    //
    Int_t Ntot = 0;
    for (Long64_t jentry=0; jentry<nentries; jentry++) {
        Long64_t ientry = LoadTree(jentry);
        if (ientry < 0) break;
        nb = fChain->GetEntry(jentry);
        nbytes += nb;
        Ntot = Ntot + 1;
        // if (Cut(ientry) < 0) continue;
        // evaluate as a function of pT
        for(Int_t i = 0; i < nptbins; i++) {
            // ==> pi+
            if(ptSim1 >= pt[i] && ptSim1 < pt[i+1]) {
                ntrk[i] = ntrk[i]+1;
                // number of reco tracks
                if(drTrk1 < 0.01 && purityTrk1 == 1) {
                    ntrkreco[i] = ntrkreco[i]+1;
                    Double_t theta = 2.*atan(exp(-etaSim1));
                    Double_t eSim1 = ptSim1/sin(theta);
                    if(e1ECAL11x11 > -1000. && e1HCAL5x5 > -1000. && fabs(etaSim1) < 1.0) {
                        //	    if(e1ECAL11x11 > -1000. && e1HCAL5x5 > -1000. && fabs(etaSim1) < 1000) {
                        ntrkrecor[i] = ntrkrecor[i]+1;

                        Double_t e_ecal11 = e1ECAL11x11/eSim1;
                        Double_t e_ecal7  = e1ECAL7x7/eSim1;
                        Double_t e_hcal5  = e1HCAL5x5/eSim1;
                        Double_t e_hcal3  = e1HCAL3x3/eSim1;

                        Double_t e_ecalhcal11x5 = e_ecal11 + e_hcal5;
                        Double_t e_ecalhcal11x3 = e_ecal11 + e_hcal3;
                        Double_t e_ecalhcal7x5  = e_ecal7 + e_hcal5;
                        Double_t e_ecalhcal7x3  = e_ecal7 + e_hcal3;

                        responceVSpt[i] = responceVSpt[i] + e_ecalhcal11x5;

                        hprEH11x5->Fill(ptSim1,e_ecalhcal11x5,1.);
                        hprEH11x3->Fill(ptSim1,e_ecalhcal11x3,1.);
                        hprEH7x5->Fill(ptSim1,e_ecalhcal7x5,1.);
                        hprEH7x3->Fill(ptSim1,e_ecalhcal7x3,1.);

                        hprH5->Fill(ptSim1,e_hcal5,1.);
                        hprH3->Fill(ptSim1,e_hcal3,1.);

                        //	      if(i == nptbins-1) {
                        if(i < 5) {
                            hH5_1_2GeV->Fill(e_hcal5,1.);
                            hH3_1_2GeV->Fill(e_hcal3,1.);
                            hE11_1_2GeV->Fill(e_ecal11,1.);
                            hE11H5_1_2GeV->Fill(e_ecalhcal11x5,1.);
                        }
                        if(i == 7) {
                            hH5_3_4GeV->Fill(e_hcal5,1.);
                            hH3_3_4GeV->Fill(e_hcal3,1.);
                            hE11_3_4GeV->Fill(e_ecal11,1.);
                            hE11H5_3_4GeV->Fill(e_ecalhcal11x5,1.);
                        }
                        if(i == 9) {
                            hH5_5_10GeV->Fill(e_hcal5,1.);
                            hH3_5_10GeV->Fill(e_hcal3,1.);
                            hE11_5_10GeV->Fill(e_ecal11,1.);
                            hE11H5_5_10GeV->Fill(e_ecalhcal11x5,1.);
                        }
                    }
                }
            }
            // ==> pi-
            if(ptSim2 >= pt[i] && ptSim2 < pt[i+1]) {
                ntrk[i] = ntrk[i]+1;
                // number of reco tracks
                if(drTrk2 < 0.01 && purityTrk2 == 1) {
                    ntrkreco[i] = ntrkreco[i]+1;
                    Double_t theta = 2.*atan(exp(-etaSim2));
                    Double_t eSim2 = ptSim2/sin(theta);
                    if(e2ECAL11x11 > -1000. && e2HCAL5x5 > -1000. && fabs(etaSim2) < 1.0) {
                        //	    if(e2ECAL11x11 > -1000. && e2HCAL5x5 > -1000. && fabs(etaSim2) < 1000.) {
                        ntrkrecor[i] = ntrkrecor[i]+1;

                        Double_t e_ecal11 = e2ECAL11x11/eSim2;
                        Double_t e_ecal7  = e2ECAL7x7/eSim2;
                        Double_t e_hcal5  = e2HCAL5x5/eSim2;
                        Double_t e_hcal3  = e2HCAL3x3/eSim2;

                        Double_t e_ecalhcal11x5 = e_ecal11 + e_hcal5;
                        Double_t e_ecalhcal11x3 = e_ecal11 + e_hcal3;
                        Double_t e_ecalhcal7x5  = e_ecal7 + e_hcal5;
                        Double_t e_ecalhcal7x3  = e_ecal7 + e_hcal3;

                        responceVSpt[i] = responceVSpt[i] + e_ecalhcal11x5;

                        hprEH11x5->Fill(ptSim2,e_ecalhcal11x5,1.);
                        hprEH11x3->Fill(ptSim2,e_ecalhcal11x3,1.);
                        hprEH7x5->Fill(ptSim2,e_ecalhcal7x5,1.);
                        hprEH7x3->Fill(ptSim2,e_ecalhcal7x3,1.);

                        hprH5->Fill(ptSim2,e_hcal5,1.);
                        hprH3->Fill(ptSim2,e_hcal3,1.);

                        //	      if(i == nptbins-1) {
                        if(i < 5) {
                            hH5_1_2GeV->Fill(e_hcal5,1.);
                            hH3_1_2GeV->Fill(e_hcal3,1.);
                            hE11_1_2GeV->Fill(e_ecal11,1.);
                            hE11H5_1_2GeV->Fill(e_ecalhcal11x5,1.);
                        }
                        if(i == 7) {
                            hH5_3_4GeV->Fill(e_hcal5,1.);
                            hH3_3_4GeV->Fill(e_hcal3,1.);
                            hE11_3_4GeV->Fill(e_ecal11,1.);
                            hE11H5_3_4GeV->Fill(e_ecalhcal11x5,1.);
                        }
                        if(i == 9) {
                            hH5_5_10GeV->Fill(e_hcal5,1.);
                            hH3_5_10GeV->Fill(e_hcal3,1.);
                            hE11_5_10GeV->Fill(e_ecal11,1.);
                            hE11H5_5_10GeV->Fill(e_ecalhcal11x5,1.);
                        }
                    }
                }
            }
        }
        // Nick
        // evaluate efficiency as a function on eta
        for(Int_t i = 0; i < netabins; i++) {
            // ==> pi+
            if(fabs(etaSim1) >= eta[i] && fabs(etaSim1) < eta[i+1]) {
                // number of sim tracks in pt interval
                ntrketa[i] = ntrketa[i]+1;
                // number of reco tracks
                if(drTrk1 < 0.04 && purityTrk1 >= 0.7) {
                    Double_t theta = 2.*atan(exp(-etaSim1));
                    Double_t eSim1 = ptSim1/sin(theta);
                    ntrketareco[i] = ntrketareco[i]+1;
                    if(e1ECAL11x11 > -1000. && e1HCAL5x5 > -1000.) {
                        ntrketarecor[i] = ntrketarecor[i]+1;
                        responceVSeta[i] = responceVSeta[i] + (e1ECAL7x7 + e1HCAL3x3)/eSim1;
                    }
                }
            }
            // ==> pi-
            if(fabs(etaSim2) >= eta[i] && fabs(etaSim2) < eta[i+1]) {
                // number of sim tracks in pt interval
                ntrketa[i] = ntrketa[i]+1;
                // number of reco tracks
                if(drTrk2 < 0.04 && purityTrk2 >= 0.7) {
                    ntrketareco[i] = ntrketareco[i]+1;
                    Double_t theta = 2.*atan(exp(-etaSim2));
                    Double_t eSim2 = ptSim2/sin(theta);
                    if(e2ECAL11x11 > -1000. && e2HCAL5x5 > -1000.) {
                        ntrketarecor[i] = ntrketarecor[i]+1;
                        responceVSeta[i] = responceVSeta[i] + (e2ECAL7x7 + e2HCAL3x3)/eSim2;
                    }
                }
            }
        }
    }

    // calculate efficiency and full graph
    for(Int_t i = 0; i < nptbins; i++) {
        if(ntrk[i] > 0) {
            trkeff[i] = 1.*ntrkreco[i]/ntrk[i];
            etrkeff[i] = sqrt( trkeff[i]*(1.-trkeff[i])/ntrk[i] );
            //       responceVSptF[i] = responceVSpt[i]/ntrkrecor[i];
            cout <<" i = " << i
                 <<" pt interval = " << pt[i] <<" - " << pt[i+1]
                 <<" ntrkreco[i] = " << ntrkreco[i]
                 <<" ntrkrecor[i] = " << ntrkrecor[i]
                 <<" ntrk[i] = " << ntrk[i]
                 <<" eff = " << trkeff[i] << endl;
            //       	    <<" responce = " << responceVSptF[i] << endl;
        }
    }
    // calculate efficiency vs Eta and full graph
    cout <<" Efficiency vs Eta " << endl;
    for(Int_t i = 0; i < netabins; i++) {
        if(ntrketa[i] > 0) {
            trketaeff[i] = 1.*ntrketareco[i]/ntrketa[i];
            etrketaeff[i] = sqrt( trketaeff[i]*(1.-trketaeff[i])/ntrketa[i] );
            responceVSetaF[i] = responceVSeta[i]/ntrketarecor[i];
            cout <<" i = " << i
                 <<" eta interval = " << eta[i] <<" - " << eta[i+1]
                 <<" ntrketareco[i] = " << ntrketareco[i]
                 <<" ntrketa[i] = " << ntrketa[i]
                 <<" eff = " << trketaeff[i]
                 <<" responce = " << responceVSetaF[i] << endl;
        }
    }

    // create graph
    //  vs pT
    setTDRStyle(1,0);
    TCanvas* c1 = new TCanvas("X","Y",1);
    TGraph *grpt  = new TGraphErrors(nptbins,ptgr,trkeff,eptgr,etrkeff);
    TAxis* xaxis = grpt->GetXaxis();
    grpt->GetXaxis()->SetTitle("p_{T}, GeV");
    grpt->GetYaxis()->SetTitle("track finding efficiency");
    xaxis->SetLimits(0.8,50.);
    grpt->SetMarkerStyle(21);
    grpt->SetMaximum(0.9);
    grpt->SetMinimum(0.6);
    grpt->Draw("AP");
    TLatex *t = new TLatex();
    t->SetTextSize(0.042);
    //   TLegend *leg = new TLegend(0.5,0.2,0.7,0.35,NULL,"brNDC");
    //   leg->SetFillColor(10);
    //   leg->AddEntry(grpt,"#pi ^{+} and #pi ^{-}","P");
    //   leg->Draw();
    t->DrawLatex(1.,0.85,"CMSSW169, single #pi ^{+} and #pi ^{-}. |#eta ^{#pi}|< 2.5");
    c1->SaveAs("trkeff_vs_pt.gif");
    c1->SaveAs("trkeff_vs_pt.eps");

    setTDRStyle(0,0);
    //  vs Eta
    TCanvas* c2 = new TCanvas("X","Y",1);
    TGraph *greta = new TGraphErrors(netabins,etagr,trketaeff,eetagr,etrketaeff);
    TAxis* xaxis = greta->GetXaxis();
    greta->GetXaxis()->SetTitle("#eta");
    greta->GetYaxis()->SetTitle("track finding efficiency");
    xaxis->SetLimits(0.0,2.4);
    greta->SetMarkerStyle(21);
    greta->SetMaximum(1.0);
    greta->SetMinimum(0.50);
    greta->Draw("AP");
    TLatex *t = new TLatex();
    t->SetTextSize(0.042);
    //   TLegend *leg = new TLegend(0.5,0.2,0.7,0.35,NULL,"brNDC");
    //   leg->SetFillColor(10);
    //   leg->AddEntry(greta,"#pi ^{+} and #pi ^{-}","P");
    //   leg->Draw();
    t->DrawLatex(0.3,0.87,"CMSSW217, single #pi ^{+} and #pi ^{-}");
    t->DrawLatex(0.8,0.85,"1 < p^{#pi^{#pm}} < 50 GeV");
    c2->SaveAs("trkeff_vs_eta.gif");
    c2->SaveAs("trkeff_vs_eta.eps");

    cout <<" Ntot = " << Ntot << endl;

    /*
    setTDRStyle(1,0);
    //
    TCanvas* c3 = new TCanvas("X","Y",1);
    TAxis* xaxis = hEH->GetXaxis();
    hEH->GetXaxis()->SetTitle("p_{T} of #pi ^{+} and #pi ^{-}, GeV");
    hEH->GetYaxis()->SetTitle("(ECAL11x11+HCAL5x5)/E^{true}");
    //   xaxis->SetLimits(1.2,50.);
    hEH->SetMarkerStyle(21);
    hEH->SetMaximum(0.9);
    hEH->SetMinimum(0.2);
    hEH->Draw();
    c3->SaveAs("EmatrixtWithZSP11x11.5x5.gif");

    setTDRStyle(1,0);
    //
    TCanvas* c4 = new TCanvas("X","Y",1);
    TAxis* xaxis = hEmatrix->GetXaxis();
    hHmatrix->GetXaxis()->SetTitle("p_{T} of #pi ^{+} and #pi ^{-}, GeV");
    hHmatrix->GetYaxis()->SetTitle("HCAL3x3/E^{true}");
    //   xaxis->SetLimits(1.2,50.);
    hHmatrix->SetMarkerStyle(21);
    hHmatrix->SetMaximum(0.9);
    hHmatrix->SetMinimum(-0.2);
    hHmatrix->Draw();
    c4->SaveAs("HmatrixWithNoZSP3x3.gif");

    setTDRStyle(0,0);
    TCanvas* c5 = new TCanvas("X","Y",1);
    hresp2->Draw("hist");

    setTDRStyle(0,0);
    TCanvas* c6 = new TCanvas("X","Y",1);
    hhcal->Draw("hist");
    */

    TFile efile("sr_barrel.root","recreate");

    hprEH11x5->Write();
    hprEH11x3->Write();
    hprEH7x5->Write();
    hprEH7x3->Write();
    hprH5->Write();
    hprH3->Write();
    hH5_1_2GeV->Write();
    hH3_1_2GeV->Write();
    hH5_3_4GeV->Write();
    hH3_3_4GeV->Write();
    hH5_5_10GeV->Write();
    hH3_5_10GeV->Write();
    hE11_1_2GeV->Write();
    hE11_3_4GeV->Write();
    hE11_5_10GeV->Write();
    hE11H5_1_2GeV->Write();
    hE11H5_3_4GeV->Write();
    hE11H5_5_10GeV->Write();

    efile.Close();
}
Пример #10
0
void SinglePionEfficiency::Loop()
{
//   In a ROOT session, you can do:
//      Root > .L SinglePionEfficiency.C
//      Root > SinglePionEfficiency t
//      Root > t.GetEntry(12); // Fill t data members with entry number 12
//      Root > t.Show();       // Show values of entry 12
//      Root > t.Show(16);     // Read and show values of entry 16
//      Root > t.Loop();       // Loop on all entries
//

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

   Long64_t nentries = fChain->GetEntriesFast();
 
   Long64_t nbytes = 0, nb = 0;

   // number of pt bins and intervals
   const Int_t nptbins = 12;
   const Int_t nptcuts = nptbins+1;
   //                       0    1   2    3    4     5     6     7     8     9    10   11    
   Double_t pt[nptcuts]={0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 10.0, 15.0, 20.0, 25.0, 30.0, 40., 50.0};
   // number of eta bins and intervals
   const Int_t netabins = 12;
   const Int_t netacuts = netabins+1;
   //                         0    1    2    3    4    5    6    7    8    9    10   11
   Double_t eta[netacuts]={0.0, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2, 2.4};
   cout <<"  Eta bins " << endl;

   // prepare eta points for graph
   Float_t etagr[netabins], eetagr[netabins];
   for(Int_t i = 0; i < netabins; i++) {
     etagr[i]  = 0.5*(eta[i]+eta[i+1]);
     eetagr[i] = 0.5*(eta[i+1]-eta[i]);
     cout <<" i = " << i <<" Eta = " << etagr[i] <<" err Eta = " << eetagr[i] << endl;
   } 
   // prepare for graph
   Float_t ptgr[nptbins], eptgr[nptbins];
   for(Int_t i = 0; i < nptbins; i++) {
     ptgr[i]  = 0.5*(pt[i]+pt[i+1]);
     eptgr[i] = 0.5*(pt[i+1]-pt[i]);
     cout <<" i = " << i <<" pT = " << ptgr[i] <<" err pT = " << eptgr[i] << endl;
   } 


   TH2D* hResp = new TH2D("hResp","Resp",nptbins, pt, netabins, eta);
   // histos for energy losses
   TH1F* hEnTrkNotInter[netabins];
   const char* namesEnTrkNotInter[netabins] = {"hEnTrkNotInter1",
					       "hEnTrkNotInter2",
					       "hEnTrkNotInter3",
					       "hEnTrkNotInter4",
					       "hEnTrkNotInter5",
					       "hEnTrkNotInter6",
					       "hEnTrkNotInter7",
					       "hEnTrkNotInter8",
					       "hEnTrkNotInter9",
					       "hEnTrkNotInter10",
					       "hEnTrkNotInter11",
					       "hEnTrkNotInter12"};

   const char* titleEnTrkNotInter[netabins] = {"EnTrkNotInter1",
					       "EnTrkNotInter2",
					       "EnTrkNotInter3",
					       "EnTrkNotInter4",
					       "EnTrkNotInter5",
					       "EnTrkNotInter6",
					       "EnTrkNotInter7",
					       "EnTrkNotInter8",
					       "EnTrkNotInter9",
					       "EnTrkNotInter10",
					       "EnTrkNotInter11",
					       "EnTrkNotInter12"};

   TH1F* hEnTrkInter[netabins];
   const char* namesEnTrkInter[netabins] = {"hEnTrkInter1",
					    "hEnTrkInter2",
					    "hEnTrkInter3",
					    "hEnTrkInter4",
					    "hEnTrkInter5",
					    "hEnTrkInter6",
					    "hEnTrkInter7",
					    "hEnTrkInter8",
					    "hEnTrkInter9",
					    "hEnTrkInter10",
					    "hEnTrkInter11",
					    "hEnTrkInter12"};

   const char* titleEnTrkInter[netabins] = {"EnTrkInter1",
					    "EnTrkInter2",
					    "EnTrkInter3",
					    "EnTrkInter4",
					    "EnTrkInter5",
					    "EnTrkInter6",
					    "EnTrkInter7",
					    "EnTrkInter8",
					    "EnTrkInter9",
					    "EnTrkInter10",
					    "EnTrkInter11",
					    "EnTrkInter12"};

   for(Int_t ih=0; ih < netabins; ih++) { 
     hEnTrkNotInter[ih] = new TH1F(namesEnTrkNotInter[ih], titleEnTrkNotInter[ih], 40, -1., 3.);
     hEnTrkInter[ih] = new TH1F(namesEnTrkInter[ih], titleEnTrkInter[ih], 40, -1., 3.);
   }
   //
 
   // ===> for pi- and pi+
   // N total and N reco tracks
   // find how to write output in file
   //~/scratch0/CMSSW_TEST/cmssw134gammajet/src/JetMETCorrections/GammaJet/src/GammaJetAnalysis.cc

   // total number of analized MC tracks
   Int_t ntrk[netabins][nptbins] =   {  
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,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},
   };
   // number of found tracks
   Int_t ntrkreco[netabins][nptbins] = {
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,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},
   };
   // number of lost tracks
   Int_t ntrklost[netabins][nptbins] = {
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,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},
   };
   // number of tracks with impact point on calo
   Int_t ntrkrecor[netabins][nptbins] = {
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,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},
   };

   // trk efficiency and error
   Float_t trkeff[netabins][nptbins], etrkeff[netabins][nptbins];
   // response in 11x11 crystals + 5x5 HCAL around IP in ECAL
   Double_t response[netabins][nptbins] = {
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,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},
   };

   // response for found tracks in cone 0.5 around MC track direction at vertex
   Double_t responseFoundTrk[netabins][nptbins] = {
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,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},
   };

   // response for lost tracks in cone 0.5 around MC track direction at vertex
   Double_t responseLostTrk[netabins][nptbins] = {
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,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},
   };

   // average response in 11x11 crystals + 5x5 HCAL around IP in ECAL
   Double_t responseF[netabins][nptbins];
   // average response for found tracks in cone 0.5 around MC track direction at vertex
   Double_t responseFoundTrkF[netabins][nptbins];
   // average response for lost tracks in cone 0.5 around MC track direction at vertex
   Double_t responseLostTrkF[netabins][nptbins];
   // ratio of responses of lost and found tracks
   Double_t leak[netabins][nptbins];

   Double_t drTrkcut = 0.01;
   Double_t purityTrkcut = 0.75;
   // 
   for (Long64_t jentry=0; jentry<nentries;jentry++) {
      Long64_t ientry = LoadTree(jentry);
      if (ientry < 0) break;
      nb = fChain->GetEntry(jentry);   nbytes += nb;
      // if (Cut(ientry) < 0) continue;
      // counting events for efficiency calculation
      for(Int_t ieta = 0; ieta < netabins; ieta++) {
	for(Int_t ipt = 0; ipt < nptbins; ipt++) {
	  // ==> pi+
	  if(fabs(etaSim1) >= eta[ieta] && fabs(etaSim1) < eta[ieta+1]) {
	    // checking leakage
	    if(ptSim1 > 10. && ptSim1 < 10000.)
	      {
		if(drTrk2 < 0.01 && purityTrk2 == 1) 
		  {
		    hEnTrkNotInter[ieta]->Fill(etCalo1/ptSim1);
		  } else {
		    hEnTrkInter[ieta]->Fill(etCalo1/ptSim1);
		  }
	      }
	    // end of checking leakage
	    if(ptSim1 >= pt[ipt] && ptSim1 < pt[ipt+1]) {
	      ntrk[ieta][ipt] = ntrk[ieta][ipt]+1;
	      // number of reco tracks
	      if(drTrk1 < drTrkcut && purityTrk1 >= purityTrkcut) { 
		ntrkreco[ieta][ipt] = ntrkreco[ieta][ipt]+1;
		// response for found tracks
		responseFoundTrk[ieta][ipt] = responseFoundTrk[ieta][ipt] + etCalo1/ptSim1;  
		//
		Double_t theta = 2.*atan(exp(-etaSim1));
		Double_t eSim1 = ptSim1/sin(theta);
		if(e1ECAL11x11 > -1000. && e1HCAL5x5 > -1000. && fabs(etaSim1) < 1000.) { 
		  ntrkrecor[ieta][ipt] = ntrkrecor[ieta][ipt]+1;
		  Double_t e_ecal11 = e1ECAL11x11/eSim1;
		  Double_t e_hcal5  = e1HCAL5x5/eSim1;
		  Double_t e_ecalhcal11x5 = e_ecal11 + e_hcal5;
		  response[ieta][ipt] = response[ieta][ipt] + e_ecalhcal11x5;
		}
	      } else {
		// response for lost tracks
		ntrklost[ieta][ipt] = ntrklost[ieta][ipt]+1;
		responseLostTrk[ieta][ipt] = responseLostTrk[ieta][ipt] + etCalo1/ptSim1;  
		//
	      }
	    }
	  }
	  // ==> pi-
	  if(fabs(etaSim2) >= eta[ieta] && fabs(etaSim2) < eta[ieta+1]) {
	    // checking leakage
	    if(ptSim2 > 10. && ptSim2 < 1000.)
	      {
		if(drTrk2 < 0.01 && purityTrk2 == 1) 
		  {
		    hEnTrkNotInter[ieta]->Fill(etCalo2/ptSim2);
		  } else {
		    hEnTrkInter[ieta]->Fill(etCalo2/ptSim2);
		  }
	      }
	    // end of checking leakage
	    if(ptSim2 >= pt[ipt] && ptSim2 < pt[ipt+1]) {
	      ntrk[ieta][ipt] = ntrk[ieta][ipt]+1;
	      // number of reco tracks
	      if(drTrk2 < drTrkcut && purityTrk2 >= purityTrkcut) { 
		ntrkreco[ieta][ipt] = ntrkreco[ieta][ipt]+1;
		// response for found tracks
		responseFoundTrk[ieta][ipt] = responseFoundTrk[ieta][ipt] + etCalo2/ptSim2;  
		//
		Double_t theta = 2.*atan(exp(-etaSim2));
		Double_t eSim2 = ptSim2/sin(theta);
		if(e2ECAL11x11 > -1000. && e2HCAL5x5 > -1000. && fabs(etaSim2) < 1000.) { 
		  ntrkrecor[ieta][ipt] = ntrkrecor[ieta][ipt]+1;
		  Double_t e_ecal11 = e2ECAL11x11/eSim2;
		  Double_t e_hcal5  = e2HCAL5x5/eSim2;
		  Double_t e_ecalhcal11x5 = e_ecal11 + e_hcal5;
		  response[ieta][ipt] = response[ieta][ipt] + e_ecalhcal11x5;
		}
	      } else {
		// response for lost tracks
		ntrklost[ieta][ipt] = ntrklost[ieta][ipt]+1;
		responseLostTrk[ieta][ipt] = responseLostTrk[ieta][ipt] + etCalo2/ptSim2;  
		//
	      }
	    }
	  }
	}
      }
   }

   // calculate efficiencfy, full graph and write output stream
   ofstream myoutput_eff("CMSSW_167_TrackNonEff.txt");
   ofstream myoutput_eff1("CMSSW_167_TrackNonEff_one.txt");
   ofstream myoutput_leak("CMSSW_167_TrackLeakage.txt");
   ofstream myoutput_leak1("CMSSW_167_TrackLeakage_one.txt");
   ofstream myoutput_resp("CMSSW_167_response.txt");

   // calculate map of leackage
   for(Int_t ieta = 0; ieta < netabins; ieta++) {
     for(Int_t ipt = 0; ipt < nptbins; ipt++) {
       
	 // found tracks
       if(ntrkreco[ieta][ipt] != 0) {
	 
	 responseFoundTrkF[ieta][ipt] = responseFoundTrk[ieta][ipt]/ntrkreco[ieta][ipt]; 
	 
       } else {
	 
	 responseFoundTrkF[ieta][ipt] = responseFoundTrkF[ieta][ipt-1];
       }
       // lost tracks
       if(ntrklost[ieta][ipt] != 0) {
	 
	 responseLostTrkF[ieta][ipt] = responseLostTrk[ieta][ipt]/ntrklost[ieta][ipt]; 
	 
       } else {
	 
	 responseLostTrkF[ieta][ipt] = responseLostTrkF[ieta][ipt-1];

       }
     }
   } 

   for(Int_t ieta = 0; ieta <= netabins; ieta++) {
     for(Int_t ipt = 0; ipt <= nptbins; ipt++) {

       if(ieta < netabins && ipt < nptbins) {

	 leak[ieta][ipt] = responseLostTrkF[ieta][ipt]/responseFoundTrkF[ieta][ipt];
	 
	 cout <<" ieta = " << ieta
	      <<" eta = " << eta[ieta]
	      <<" ipt = " << ipt
	      <<" pt = " << pt[ipt]
	      <<" ntrkreco = " << ntrkreco[ieta][ipt] 
	      <<" ntrklost = " << ntrklost[ieta][ipt] 
	      <<" responseFoundTrk = " << responseFoundTrkF[ieta][ipt] 
	      <<" responseLostTrk = " << responseLostTrkF[ieta][ipt]
	      <<" leak = " << leak[ieta][ipt] <<  endl;

	 myoutput_leak << ieta << " " 
		       << ipt  << " " 
		       << eta[ieta] << " " 
		       << pt[ipt] << " "
		       << leak[ieta][ipt] << endl;
	 myoutput_leak1 << ieta << " " 
			<< ipt  << " " 
			<< eta[ieta] << " " 
			<< pt[ipt] << " "
			<< " 1. " << endl;
       }
       if(ipt == nptbins && ieta < netabins) {
	 
	 myoutput_leak << ieta << " " 
		       << ipt  << " " 
		       << eta[ieta] << " " 
		       << pt[ipt] << " "
		       << leak[ieta][ipt-1] << endl;
	 myoutput_leak1 << ieta << " " 
			<< ipt  << " " 
			<< eta[ieta] << " " 
			<< pt[ipt] << " "
			<< " 1. " << endl;
       }
       if(ipt < nptbins && ieta == netabins) {

	 myoutput_leak << ieta << " " 
		       << ipt  << " " 
		       << eta[ieta] << " " 
		       << pt[ipt] << " "
		       << leak[ieta-1][ipt] << endl;
	 myoutput_leak1 << ieta << " " 
			<< ipt  << " " 
			<< eta[ieta] << " " 
			<< pt[ipt] << " "
			<< " 1. " << endl;

       }
       if(ipt == nptbins && ieta == netabins) {

	 myoutput_leak << ieta << " " 
		       << ipt  << " " 
		       << eta[ieta] << " " 
		       << pt[ipt] << " "
		       << leak[ieta-1][ipt-1] << endl;
	 myoutput_leak1 << ieta << " " 
			<< ipt  << " " 
			<< eta[ieta] << " " 
			<< pt[ipt] << " "
			<< " 1. " << endl;

       }
     }
   }

   // calculate map of response and tracker efficiency

   cout <<" " << endl;
   cout <<" " << endl;
   cout <<" " << endl;

   for(Int_t ieta = 0; ieta <= netabins; ieta++) {
     for(Int_t ipt = 0; ipt <= nptbins; ipt++) {

       if(ieta < netabins && ipt < nptbins) {

	 if(ntrk[ieta][ipt] != 0 && ntrkrecor[ieta][ipt] != 0) {
	   trkeff[ieta][ipt] = 1.*ntrkreco[ieta][ipt]/ntrk[ieta][ipt];
	   etrkeff[ieta][ipt] = sqrt( trkeff[ieta][ipt]*(1.-trkeff[ieta][ipt])/ntrk[ieta][ipt] );
	   responseF[ieta][ipt] = response[ieta][ipt]/ntrkrecor[ieta][ipt];
	   
	   cout <<" ieta = " << ieta
		<<" eta = " << eta[ieta]
		<<" ipt = " << ipt
		<<" pt = " << pt[ipt]
		<<" ntrkreco = " << ntrkreco[ieta][ipt] 
		<<" ntrkrecor = " << ntrkrecor[ieta][ipt] 
		<<" ntrk = " << ntrk[ieta][ipt]
		<<" eff = " << trkeff[ieta][ipt] 
		<<" +/- " << etrkeff[ieta][ipt] 
		<<" response = " << responseF[ieta][ipt] << endl;
	   hResp->Fill(pt[ipt],eta[ieta],responseF[ieta][ipt]);
	   
	   myoutput_eff << ieta << " " 
			<< ipt  << " " 
			<< eta[ieta] << " " 
			<< pt[ipt] << " "
			<< trkeff[ieta][ipt] << endl;
	   
	   myoutput_resp << ieta << " " 
			 << ipt  << " " 
			 << eta[ieta] << " " 
			 << pt[ipt] << " "
			 << responseF[ieta][ipt] << endl;
	   
	   myoutput_eff1 << ieta << " " 
			 << ipt  << " " 
			 << eta[ieta] << " " 
			 << pt[ipt] << " "
			 << " 1." << endl;
	 } else {

	   trkeff[ieta][ipt] = trkeff[ieta][ipt-1];
	   responseF[ieta][ipt] = responseF[ieta][ipt-1];
	   hResp->Fill(pt[ipt],eta[ieta],responseF[ieta][ipt]);
	   myoutput_eff << ieta << " " 
			<< ipt  << " " 
			<< eta[ieta] << " " 
			<< pt[ipt] << " "
			<< trkeff[ieta][ipt] << endl;
	   
	   myoutput_resp << ieta << " " 
			 << ipt  << " " 
			 << eta[ieta] << " " 
			 << pt[ipt] << " "
			 << responseF[ieta][ipt] << endl;
	   
	   myoutput_eff1 << ieta << " " 
			 << ipt  << " " 
			 << eta[ieta] << " " 
			 << pt[ipt] << " "
			 << " 1." << endl;
	 }
       }

       if(ipt == nptbins && ieta < netabins) {
	 myoutput_eff << ieta << " " 
		      << ipt  << " " 
		      << eta[ieta] << " " 
		      << pt[ipt] << " "
		      << trkeff[ieta][ipt-1] << endl;
	 
	 myoutput_resp << ieta << " " 
		       << ipt  << " " 
		       << eta[ieta] << " " 
		       << pt[ipt] << " "
		       << responseF[ieta][ipt-1] << endl;
	 
	 myoutput_eff1 << ieta << " " 
		       << ipt  << " " 
		       << eta[ieta] << " " 
		       << pt[ipt] << " "
		       << " 1." << endl;
       }
       if(ipt < nptbins && ieta == netabins) {
	 myoutput_eff << ieta << " " 
		      << ipt  << " " 
		      << eta[ieta] << " " 
		      << pt[ipt] << " "
		      << trkeff[ieta-1][ipt] << endl;
	 
	 myoutput_resp << ieta << " " 
		       << ipt  << " " 
		       << eta[ieta] << " " 
		       << pt[ipt] << " "
		       << responseF[ieta-1][ipt] << endl;
	 
	 myoutput_eff1 << ieta << " " 
		       << ipt  << " " 
		       << eta[ieta] << " " 
		       << pt[ipt] << " "
		       << " 1." << endl;
       }
       if(ipt == nptbins && ieta == netabins) {
	 myoutput_eff << ieta << " " 
		      << ipt  << " " 
		      << eta[ieta] << " " 
		      << pt[ipt] << " "
		      << trkeff[ieta-1][ipt-1] << endl;
	 
	 myoutput_resp << ieta << " " 
		       << ipt  << " " 
		       << eta[ieta] << " " 
		       << pt[ipt] << " "
		       << responseF[ieta-1][ipt-1] << endl;
	 
	 myoutput_eff1 << ieta << " " 
		       << ipt  << " " 
		       << eta[ieta] << " " 
		       << pt[ipt] << " "
		       << " 1." << endl;
       }
     }
   }
   
   //
   // plot leakage graph
   Float_t leakage[netabins], eleakage[netabins];
   Float_t MeanNotInter[netabins], MeanErrorNotInter[netabins];
   Float_t MeanInter[netabins], MeanErrorInter[netabins];

   for(Int_t ih=0; ih < netabins; ih++) { 
     //     hEnTrkNotInter[ih]->Write();
     //     hEnTrkInter[ih]->Write();

     MeanNotInter[ih]      = hEnTrkNotInter[ih]->GetMean();
     MeanErrorNotInter[ih] = hEnTrkNotInter[ih]->GetMeanError();
     MeanInter[ih]         = hEnTrkInter[ih]->GetMean();
     MeanErrorInter[ih]    = hEnTrkInter[ih]->GetMeanError();
     leakage[ih] = MeanInter[ih]/MeanNotInter[ih];
     eleakage[ih] = leakage[ih] *
       sqrt( (MeanErrorNotInter[ih]/MeanNotInter[ih])*(MeanErrorNotInter[ih]/MeanNotInter[ih]) +
             (MeanErrorInter[ih]/MeanInter[ih])*(MeanErrorInter[ih]/MeanInter[ih]));

     cout <<" ieta = " << ih <<" MeanNotInter = " << MeanNotInter[ih] <<" +/- " << MeanErrorNotInter[ih]
	  <<" MeanInter = " << MeanInter[ih] <<" +/- " << MeanErrorInter[ih]  
	  <<" leakage = " << leakage[ih] <<" +/- " << eleakage[ih] << endl; 
   }

   TGraph *gleak = new TGraphErrors(netabins,etagr,leakage, eetagr,eleakage);
   TGraph *eMeanNotInter = new TGraphErrors(netabins,etagr,MeanNotInter, eetagr,MeanErrorNotInter);
   TGraph *eMeanInter = new TGraphErrors(netabins,etagr,MeanInter, eetagr,MeanErrorInter);
   //  vs Eta
   setTDRStyle(0,0);
   TCanvas* c3 = new TCanvas("X","Y",1);
   c3->Divide(1,2);
   c3->cd(1);
   TAxis* xaxis = eMeanNotInter->GetXaxis();
   eMeanNotInter->GetXaxis()->SetTitle("#eta");
   eMeanNotInter->GetYaxis()->SetTitle("calo E_{T}^{raw reco} in cone 0.5/p_{T}^{MC}");
   xaxis->SetLimits(0.0,2.4);
   eMeanNotInter->SetMarkerStyle(21);
   //   eMeanNotInter->SetMaximum(0.95);
   //   eMeanNotInter->SetMinimum(0.55);
   eMeanNotInter->SetMaximum(1.);
   eMeanNotInter->SetMinimum(0.);
   eMeanNotInter->Draw("AP");
   eMeanInter->SetMarkerStyle(24);
   eMeanInter->Draw("P");
   TLatex *t = new TLatex();
   t->SetTextSize(0.08);
   t->DrawLatex(0.2,0.9,"CMSSW_1_6_9");
   TLegend *leg = new TLegend(0.2,0.2,0.8,0.4,NULL,"brNDC");
   leg->SetFillColor(10);
   leg->AddEntry(eMeanNotInter,"recontructed tracks 2 < p_{T}^{#pi^{#pm}} < 10 GeV","P");
   leg->AddEntry(eMeanInter,"not reconstructed tracks 2 < p_{T}^{#pi^{#pm}} < 10 GeV","P");
   leg->Draw();

   c3->cd(2);
   TAxis* xaxis = gleak->GetXaxis();
   gleak->GetXaxis()->SetTitle("#eta");
   gleak->GetYaxis()->SetTitle("ratio = <E_{T for lost tracks}^{raw reco} / E_{T for found tracks}^{raw reco}>");
   xaxis->SetLimits(0.0,2.4);
   gleak->SetMarkerStyle(21);
   gleak->SetMaximum(1.0);
   //  leak->SetMinimum(0.7);
   gleak->SetMinimum(0.5);
   gleak->Draw("AP");
   TLatex *t = new TLatex();
   t->SetTextSize(0.08);
   //   t->DrawLatex(0.1,0.75,"<E_{T for lost tracks}^{raw reco} / E_{T for found tracks}^{raw reco}> for p_{T}^{#pi^{#pm}} >2 GeV");
   c3->SaveAs("eMean_vs_eta_pt2-10.gif");
   c3->SaveAs("eMean_vs_eta_pt2-10.eps");

   //  original distribtions
   setTDRStyle(0,0);
   gStyle->SetOptFit(0);
   TCanvas* c4 = new TCanvas("X","Y",1);
   hEnTrkNotInter[0]->GetYaxis()->SetTitle("");
   hEnTrkNotInter[0]->GetXaxis()->SetTitle("calo E_{T}^{raw reco} in cone 0.5/p_{T}^{MC}");
   Double_t scale = 1./hEnTrkNotInter[0]->Integral();
   hEnTrkNotInter[0]->Scale(scale);
   hEnTrkNotInter[0]->SetLineWidth(4);
   hEnTrkNotInter[0]->SetMaximum(0.14);
   //   hEnTrkNotInter[0]->SetMinimum(0.55);
   // Fitting
   Int_t binMax = hEnTrkNotInter[0]->GetMaximumBin();
   TAxis* xaxis = hEnTrkNotInter[0]->GetXaxis();
   Double_t binCenter = xaxis->GetBinCenter(binMax);
   Double_t rms = hEnTrkNotInter[0]->GetRMS();
   Double_t rFitMin = binCenter - 1.5 * rms; 
   Double_t rFitMax = binCenter + 1.5 * rms;
   hEnTrkNotInter[0]->Fit("gaus","","",rFitMin,rFitMax);
   TF1 *fit = hEnTrkNotInter[0]->GetFunction("gaus"); 
   fit->SetLineWidth(4);
   fit->SetLineStyle(2);
   fit->Draw("same");
   scale = 1./hEnTrkInter[0]->Integral();
   hEnTrkInter[0]->Scale(scale);
   hEnTrkInter[0]->SetLineWidth(2);
  // Fitting
   Int_t binMax = hEnTrkInter[0]->GetMaximumBin();
   TAxis* xaxis = hEnTrkInter[0]->GetXaxis();
   Double_t binCenter = xaxis->GetBinCenter(binMax);
   Double_t rms = hEnTrkNotInter[0]->GetRMS();
   Double_t rFitMin = binCenter - 1.5 * rms; 
   Double_t rFitMax = binCenter + 1.5 * rms;
   hEnTrkInter[0]->Fit("gaus","","same",rFitMin,rFitMax);
   TF1 *fit = hEnTrkInter[0]->GetFunction("gaus"); 
   fit->SetLineWidth(2);
   fit->SetLineStyle(2);
   fit->Draw("same");
   TLatex *t = new TLatex();
   t->SetTextSize(0.08);
   t->DrawLatex(0.2,0.9,"CMSSW_1_6_9");
   TLegend *leg = new TLegend(0.15,0.7,0.9,0.9,NULL,"brNDC");
   leg->SetFillColor(10);
   leg->AddEntry(hEnTrkNotInter[0],"recontructed tracks 2< p_{T}^{#pi^{#pm}} < 10 GeV, 0<#eta<0.2","L");
   leg->AddEntry(hEnTrkInter[0],"not reconstructed tracks 2< p_{T}^{#pi^{#pm}} < 10 GeV, 0<#eta<0.2","L");
   leg->Draw();

   c4->SaveAs("eMean_at_eta0.gif");
   c4->SaveAs("eMean_at_eta0.eps");

   //  original distribtions
   setTDRStyle(0,0);
   gStyle->SetOptFit(0);
   TCanvas* c5 = new TCanvas("X","Y",1);
   hEnTrkNotInter[9]->GetYaxis()->SetTitle("");
   hEnTrkNotInter[9]->GetXaxis()->SetTitle("calo E_{T}^{raw reco} in cone 0.5/p_{T}^{MC}");
   Double_t scale = 1./hEnTrkNotInter[9]->Integral();
   hEnTrkNotInter[9]->Scale(scale);
   hEnTrkNotInter[9]->SetLineWidth(4);
   hEnTrkNotInter[9]->SetMaximum(0.17);
   //   hEnTrkNotInter[9]->SetMinimum(0.55);
   // Fitting
   Int_t binMax = hEnTrkNotInter[9]->GetMaximumBin();
   TAxis* xaxis = hEnTrkNotInter[9]->GetXaxis();
   Double_t binCenter = xaxis->GetBinCenter(binMax);
   Double_t rms = hEnTrkNotInter[9]->GetRMS();
   Double_t rFitMin = binCenter - 1.5 * rms; 
   Double_t rFitMax = binCenter + 1.5 * rms;
   hEnTrkNotInter[9]->Fit("gaus","","",rFitMin,rFitMax);
   TF1 *fit = hEnTrkNotInter[9]->GetFunction("gaus"); 
   fit->SetLineWidth(4);
   fit->SetLineStyle(2);
   fit->Draw("same");
   scale = 1./hEnTrkInter[9]->Integral();
   hEnTrkInter[9]->Scale(scale);
   hEnTrkInter[9]->SetLineWidth(2);
  // Fitting
   Int_t binMax = hEnTrkInter[9]->GetMaximumBin();
   TAxis* xaxis = hEnTrkInter[9]->GetXaxis();
   Double_t binCenter = xaxis->GetBinCenter(binMax);
   Double_t rms = hEnTrkNotInter[9]->GetRMS();
   Double_t rFitMin = binCenter - 1.2 * rms; 
   Double_t rFitMax = binCenter + 1.5 * rms;
   hEnTrkInter[9]->Fit("gaus","","same",rFitMin,rFitMax);
   TF1 *fit = hEnTrkInter[9]->GetFunction("gaus"); 
   fit->SetLineWidth(2);
   fit->SetLineStyle(2);
   fit->Draw("same");
   TLatex *t = new TLatex();
   t->SetTextSize(0.08);
   t->DrawLatex(0.2,0.9,"CMSSW_1_6_9");
   TLegend *leg = new TLegend(0.15,0.7,0.9,0.9,NULL,"brNDC");
   leg->SetFillColor(10);
   leg->AddEntry(hEnTrkNotInter[9],"recontructed tracks p_{T}^{#pi^{#pm}} > 2 GeV, 1.8<#eta<2.0","L");
   leg->AddEntry(hEnTrkInter[9],"not reconstructed tracks p_{T}^{#pi^{#pm}} > 2 GeV, 1.8<#eta<2.0","L");
   leg->Draw();

   c5->SaveAs("eMean_at_eta1.9.gif");
   c5->SaveAs("eMean_at_eta1.9.eps");

   TFile efile("response.root","recreate");
   hResp->Write();
   efile.Close();
}
Пример #11
0
void finalSpectra(
		 const char* inCentral=
		 "links/P01hi.central.2000.hist/finish_cut88778999_iter3.hist.root",
		 const char* inMinbias=
		 "links/P01hi.minbias.2000.hist/finish_cut97778999_iter3.hist.root",
		 const char* inPeripheral=
		 "links/P01hi.minbias.2000.hist/finish_cut57778999_iter3.hist.root",
		 const char* psDir="psFinal"
		 )
{
  gSystem->Clear();

  TFile* rCentral=new TFile(inCentral);
  TFile* rMinbias=new TFile(inMinbias);
  TFile* rPeripheral=new TFile(inPeripheral);
  
  int DOKLUDGE=1;

 
  //
  // get the graphs
  //
  char name[200],title[200],txt[500];
  char* sign=0; // "Minus"
  int bin=0;

  setName(name,"gSpecCorrected",bin,sign);

  TGraphAsymmErrors* gCentralX=(TGraphAsymmErrors*)rCentral->Get(name);
  TGraphAsymmErrors* gMinbiasX=(TGraphAsymmErrors*)rMinbias->Get(name);
  TGraphAsymmErrors* gPeripheralX=(TGraphAsymmErrors*)rPeripheral->Get(name);
  
  //
  // kludges
  //
  if(DOKLUDGE){
    cout << ">>>>WARNING DOING KLUDGE" << endl;
    cout << ">>>>WARNING DOING KLUDGE" << endl;
    cout << ">>>>WARNING DOING KLUDGE" << endl;

    kludgeBackground(gCentralX,0.08);
    kludgeBackground(gMinbiasX,0.08);
    kludgeBackground(gPeripheralX,0.05);

    kludgeSystematics(gCentralX);
    kludgeSystematics(gMinbiasX);
    kludgeSystematics(gPeripheralX);

  }

  
  // low pt stuff
  TGraphAsymmErrors* gCentralLowPt=makeHMinus(2);
  TGraphAsymmErrors* gMinbiasLowPt=makeHMinus(0);
  TGraphAsymmErrors* gPeripheralLowPt=makeHMinus(1);

  // ua1
  float sigmaUA1_200=42;
  float ua1Scale200 = 2.*3.14159/sigmaUA1_200;

  float sigmaUA1_130=40.5;
  float ua1Scale130= 2.*3.14159/sigmaUA1_130;

  TGraphErrors* gUA1Data200=ua1Data200();
  scale(gUA1Data200,ua1Scale200);

  TF1* fUA1Fit130 = ua1Fit130(ua1Scale130);


  // remove some error bars

  gCentralLowPt=removeXErrors(gCentralLowPt);
  gMinbiasLowPt=removeXErrors(gMinbiasLowPt);
  gPeripheralLowPt=removeXErrors(gPeripheralLowPt);


  //  gStyles
  gStyle->SetOptStat(0); gStyle->SetOptTitle(0);
  gStyle->SetPadTickX(1); 
  gStyle->SetPadTickY(1);
  
  // follow manuel in the fonts
  int font = 42;
  gStyle->SetTextFont(font); gStyle->SetTitleFont(font);
  gStyle->SetLabelFont(font,"x"); gStyle->SetLabelFont(font,"y");
  
  // TLatex
  TLatex* ltx=new TLatex;

  TCanvas* c1=new TCanvas("c1","c1",400,500);

  // draw the spectra
  double xMin=0,xMax=6;
  double yMin=1e-7,yMax=10000;
  double textSize=0.03;
  double titleSize=0.04;
  double markerSize=1;
  double labelSize=0.03;
  double yTitleOffset=1.2;
  double xTitleOffset=0.8;
  double tickSize=9990;
  
  TAxis* axis;

  c1->cd(); gPad->SetLogy(); 

  int centralMarker=29;
  int minbiasMarker=8;
  int peripheralMarker=22;
  int hMinusMarker=21;
  int ua1Marker=4;


  // central
  //
  gCentral=removeXErrors(gCentralX);

  gCentral->SetMinimum(yMin); gCentral->SetMaximum(yMax);
  gCentral->SetMarkerStyle(centralMarker); 
  gCentral->SetMarkerSize(markerSize+.2);
  gCentral->Draw("ap");


  strcpy(txt,"1/p_{T} d^{2}N^{(h^{-}+h^{+})/2}/dp_{T}d#eta #cbar_{|#eta|<0.5}(GeV/c)^{-2}");

  // yaxis
  axis=gCentral->GetYaxis();
  axis->SetTitle(txt);
  axis->SetTitleSize(titleSize);
  axis->SetTitleOffset(yTitleOffset);
  axis->SetLabelSize(labelSize);

  // xaxis
  axis=gCentral->GetXaxis();
  axis->SetTitle("p_{T} (GeV/c)");
  axis->SetTitleSize(titleSize);
  axis->SetTitleOffset(xTitleOffset);
  axis->SetLabelOffset(0.003);
  axis->SetLabelSize(labelSize);
  axis->SetLimits(xMin,xMax);

  
  // low pt central
  gCentralLowPt->SetMarkerStyle(centralMarker);
  gCentralLowPt->SetMarkerSize(markerSize);
  gCentralLowPt->Draw("p");


  // draw bin widths
  // drawAxisBins(gCentralX,tickSize,yMax);
  //  TLine* line=new TLine;
  // line->DrawLineNDC((2/6)*(1./.8)+.1,.8,2/6*(1./.8)+.1 ,.9);


  // minbias
  //
  // remove x errors
  gMinbias=removeXErrors(gMinbiasX);

  gMinbias->SetMarkerStyle(minbiasMarker); 
  gMinbias->SetMarkerSize(markerSize);
  gMinbias->Draw("p");

  gMinbiasLowPt->SetMarkerStyle(minbiasMarker);
  gMinbiasLowPt->SetMarkerSize(markerSize);
  gMinbiasLowPt->Draw("p");

  // peripheral
  //
  // remove x errors
  gPeripheral=removeXErrors(gPeripheralX);

  gPeripheral->SetMarkerStyle(peripheralMarker); 
  gPeripheral->SetMarkerSize(markerSize);
  gPeripheral->Draw("p");

  gPeripheralLowPt->SetMarkerStyle(peripheralMarker);
  gPeripheralLowPt->SetMarkerSize(markerSize);
  gPeripheralLowPt->Draw("p");
  
  // ua1
  //
  

  gUA1Data200->SetMarkerStyle(ua1Marker);
  gUA1Data200->SetMarkerSize(markerSize);

  //fUA1Fit130->SetLineColor();

  gUA1Data200->Draw("p");
  fUA1Fit130->SetRange(.1,6);
  fUA1Fit130->Draw("same");


  //
  // legend
  //
  TLegend* l=new TLegend(0.5,0.7,0.8,0.8);
  l->SetTextSize(textSize);
  l->SetBorderSize(0); l->SetFillColor(4000); // transparent
  l->AddEntry(gCentral,"central 0-5%","p");
  l->AddEntry(gPeripheral,"periperhal 60-80%","p");
  l->AddEntry(gMinbias,"minimum bias","p");  
  l->AddEntry(gUA1Data200,"ua1 200 GeV data","p");
  l->AddEntry(fUA1Fit130,"ua1 130 GeV fit","l");
  l->Draw();

  Print(c1,psDir,"spectra");

}