void NuclearModification(
  TString  particle,
  const int      nbins,
  Double_t xbins[],
  Double_t xhbins[],
  Double_t exl[],
  Double_t exl2[],
  Double_t exl0[],
  Double_t yPercSigmapPbSystTotHigh[],
  Double_t yPercSigmapPbSystTotLow[],
  Double_t commonErrorP,
  Double_t commonErrorN,
  Double_t FFsysterror,
  Double_t tagandprobcorrection[],
  TCanvas *canvasSigma,
  TCanvas *canvasRpA,
  int PadNum
){
  gROOT->SetStyle("Plain");
  gStyle->SetOptTitle(0);
  gStyle->SetOptStat(0);
  
  TFile*filePPReference=new TFile(Form("../../../fonll/output%s.root",particle.Data()));  
  //###TFile*filePPReference=new TFile(Form("../../fonll/output%s.root",particle.Data()));  
  TGraphAsymmErrors*gaeBplusReference=(TGraphAsymmErrors*)filePPReference->Get(Form("gaeSigmaDecay%s",particle.Data()));
  gaeBplusReference->SetName(Form("gae%sReference",particle.Data()));
  
  TFile*filepPb=new TFile(Form("../Results%s/Sigma%s.root",particle.Data(),particle.Data()));
  TH1F*hSigmapPbStat=(TH1F*)filepPb->Get("hPtSigma");  
  TH1F*hPt=(TH1F*)filepPb->Get("hPt");
  TH1F*hEff=(TH1F*)filepPb->Get("hEff");
  
  double scalingfactor=1e-6;
  double yvalue,xvalue,yerrorhigh,yerrorlow;
  
  for (int i=0;i<nbins;i++){
    hSigmapPbStat->SetBinContent(i+1,scalingfactor*hSigmapPbStat->GetBinContent(i+1));
    hSigmapPbStat->SetBinError(i+1,scalingfactor*hSigmapPbStat->GetBinError(i+1));
    
    yvalue=-1.;
    xvalue=-1.;
    yerrorhigh=-1.;
    yerrorlow=-1.;
    
    gaeBplusReference->GetPoint(i,xvalue,yvalue);
    yerrorhigh=gaeBplusReference->GetEYhigh()[i];
    yerrorlow=gaeBplusReference->GetEYlow()[i];
  
    gaeBplusReference->SetPoint(i,xvalue,yvalue*scalingfactor);
    gaeBplusReference->SetPointEYhigh(i,yerrorhigh*scalingfactor);
    gaeBplusReference->SetPointEYlow(i,yerrorlow*scalingfactor);

  } 
  
  
  for (int i=0;i<nbins;i++){
    hSigmapPbStat->SetBinContent(i+1,(1./tagandprobcorrection[i])*hSigmapPbStat->GetBinContent(i+1));
    hSigmapPbStat->SetBinError(i+1,(1./tagandprobcorrection[i])*hSigmapPbStat->GetBinError(i+1));
  
  } 
  Double_t yRefPP[nbins];                        //value y reference
  Double_t xRefPP[nbins];                        //value x reference
  Double_t yPPsystFONLLhigh[nbins];              //y err syst FONLL high
  Double_t yPPsystFONLLlow[nbins];               //y err syst FONLL low
  Double_t yPercPPsystFONLLhigh[nbins];          //y percentuale err syst FONLL high
  Double_t yPercPPsystFONLLlow[nbins];           //y percentuale err syst FONLL low
    
  Double_t ySigmapPb[nbins];                     //value y pPb 
  Double_t xSigmapPb[nbins];                     //value x pPb
  Double_t ySigmapPbStat[nbins];                 //y err stat pPb
  Double_t yPercSigmapPbStat[nbins];             //y err stat pPb
  
  Double_t yFONLL[nbins];                        //1
  Double_t yRpA[nbins];                          //value y RpA 
  Double_t yRpAStat[nbins];                      //y err stat RpA 
  Double_t yRpAsystFONLLhigh[nbins];             //y err syst FONLL RpA high
  Double_t yRpAsystFONLLlow[nbins];              //y err syst FONLL RpA lzow
  Double_t yPercRpAsystFONLLhigh[nbins];         //y percentuale err syst FONLL RpA high
  Double_t yPercRpAsystFONLLlow[nbins];          //y percentuale err syst FONLL RpA low
    
  Double_t ySigmapPbSystTotHigh[nbins];              //y percentuale err syst pPb TOT
  Double_t ySigmapPbSystTotLow[nbins];              //y percentuale err syst pPb TOT

  Double_t yPercRpPbSystTotHigh[nbins];          //y percentuale err syst RpPb TOT
  Double_t yPercRpPbSystTotLow[nbins];          //y percentuale err syst RpPb TOT
  
  Double_t yRpPbSystTotHigh[nbins];              //y percentuale err syst RpPb TOT
  Double_t yRpPbSystTotLow[nbins];              //y percentuale err syst RpPb TOT

  
  double x,y;
  for (Int_t i=0;i<nbins;i++) {
    gaeBplusReference->GetPoint(i,xRefPP[i],yRefPP[i]);
    yPPsystFONLLhigh[i]=gaeBplusReference->GetEYhigh()[i];
    yPPsystFONLLlow[i]=gaeBplusReference->GetEYlow()[i];
    yPercPPsystFONLLhigh[i]=yPPsystFONLLhigh[i]/yRefPP[i];
    yPercPPsystFONLLlow[i]=yPPsystFONLLlow[i]/yRefPP[i];
    yPercPPsystFONLLhigh[i]=TMath::Sqrt(yPercPPsystFONLLhigh[i]*yPercPPsystFONLLhigh[i]+FFsysterror*FFsysterror);
    yPercPPsystFONLLlow[i]=TMath::Sqrt(yPercPPsystFONLLlow[i]*yPercPPsystFONLLlow[i]+FFsysterror*FFsysterror);
    
  }
  
  for(Int_t i=0;i<nbins;i++) {
    ySigmapPb[i]=hSigmapPbStat->GetBinContent(i+1);
    ySigmapPbStat[i]=hSigmapPbStat->GetBinError(i+1);
    yPercSigmapPbStat[i]=ySigmapPbStat[i]/ySigmapPb[i];
    ySigmapPbSystTotHigh[i]=yPercSigmapPbSystTotHigh[i]*ySigmapPb[i];
    ySigmapPbSystTotLow[i]=yPercSigmapPbSystTotLow[i]*ySigmapPb[i];
  }
  
  for(Int_t i=0;i<nbins;i++) {
    yRpA[i]=ySigmapPb[i]/yRefPP[i];
    yRpAStat[i]=ySigmapPbStat[i]/yRefPP[i];
    yFONLL[i]=yRpA[i];
    yPercRpAsystFONLLhigh[i]=(yPercPPsystFONLLlow[i]/(1-yPercPPsystFONLLlow[i]));
    yPercRpAsystFONLLlow[i]=(yPercPPsystFONLLhigh[i]/(1+yPercPPsystFONLLhigh[i]));
    yRpAsystFONLLhigh[i]=yPercRpAsystFONLLhigh[i]*yRpA[i];
    yRpAsystFONLLlow[i]=yPercRpAsystFONLLlow[i]*yRpA[i];

    yRpPbSystTotHigh[i]=yPercSigmapPbSystTotHigh[i]*yRpA[i];
    yRpPbSystTotLow[i]=yPercSigmapPbSystTotLow[i]*yRpA[i];   

	std::cout << i << " , " << xbins[i] << " , " << ySigmapPb[i] << " , sta: " << ySigmapPbStat[i] << " , syslow: " << ySigmapPbSystTotLow[i] << " ,syshigh: " << ySigmapPbSystTotHigh[i] << std::endl;
	std::cout << "FONLL: " << yRefPP[i] << " - " << yPPsystFONLLlow[i] << " + " << yPPsystFONLLhigh[i] << std::endl;
	std::cout << i << " ####### " << xbins[i] << " , " << yRpA[i] << " , sta: " << yRpAStat[i] << " , syslow: " << yRpPbSystTotLow[i] << " ,syshigh: " << yRpPbSystTotHigh[i] << " ,FONLLlow: " << yRpAsystFONLLlow[i] << " , FONLLhigh: " << yRpAsystFONLLhigh[i] << std::endl;

  TGraphAsymmErrors *gRpAstat = new TGraphAsymmErrors(nbins,xbins,yRpA,exl0,exl0,yRpAStat,yRpAStat);
  TGraphAsymmErrors *gRpAsyst = new TGraphAsymmErrors(nbins,xbins,yRpA,exl,exl,yRpPbSystTotLow,yRpPbSystTotHigh);
  TGraphAsymmErrors *gRpAsystFONLL = new TGraphAsymmErrors(nbins,xbins,yFONLL,exl,exl,yRpAsystFONLLlow,yRpAsystFONLLhigh);
 

  }
  
  TGraphAsymmErrors *gSigmasyst = new TGraphAsymmErrors(nbins,xbins,ySigmapPb,exl2,exl2,ySigmapPbSystTotLow,ySigmapPbSystTotHigh);
  //###TGraphAsymmErrors *gSigmasyst = new TGraphAsymmErrors(nbins,xbins,ySigmapPb,exl,exl,ySigmapPbSystTotLow,ySigmapPbSystTotHigh);


  gSigmasyst->SetTitle("Sigma syst uncertainty from pPb");
  gSigmasyst->SetMarkerColor(1);
  gSigmasyst->SetLineColor(1);
  gSigmasyst->SetLineWidth(1);   
  gSigmasyst->SetMarkerStyle(21);
  gSigmasyst->SetMarkerColor(1);
  gSigmasyst->SetFillColor(kYellow-7);//5
  gSigmasyst->SetFillStyle(1001);
  TGraphAsymmErrors*gSigmasyst2=(TGraphAsymmErrors*)gSigmasyst->Clone();
  gSigmasyst2->SetMarkerColor(1);
  gSigmasyst2->SetMarkerStyle(25);
  gSigmasyst2->SetFillColor(0);
  gSigmasyst2->SetFillStyle(0);
  gSigmasyst2->SetLineColor(1);//5
  gSigmasyst2->SetLineStyle(1);
  gSigmasyst2->SetLineWidth(1);
 

  //###TGraphAsymmErrors *gSigmastat = new TGraphAsymmErrors(nbins,xbins,ySigmapPb,exl,exl,ySigmapPbStat,ySigmapPbStat);
  TGraphAsymmErrors *gSigmastat = new TGraphAsymmErrors(nbins,xbins,ySigmapPb,exl0,exl0,ySigmapPbStat,ySigmapPbStat);


  gSigmastat->SetTitle("Sigma stat uncertainty from pPb");
  gSigmastat->SetMarkerColor(1);
  gSigmastat->SetLineColor(1);
  gSigmastat->SetLineWidth(2);//###   
  gSigmastat->SetMarkerStyle(21);
  gSigmastat->SetMarkerColor(1);
  
  gSigmastat->SetFillColor(0);
  gSigmastat->SetFillStyle(0);
  gSigmastat->SetFillStyle(0);

  Double_t padcorrection;
  if (particle=="Bplus") padcorrection=Bp_padratio/Bp_padratio;
  else if (particle=="Bzero") padcorrection=Bp_padratio/B0_padratio;
  else if (particle=="Bs") padcorrection=Bp_padratio/Bs_padratio;
  std::cout << "padcorrection: " << padcorrection << std::endl;
  canvasSigma->cd(PadNum);
  //canvasSigma->Range(-1.989924,-0.2917772,25.49622,2.212202);
  canvasSigma->SetFillColor(0);
  canvasSigma->SetBorderMode(0);
  canvasSigma->SetBorderSize(2);
  //canvasSigma->SetLeftMargin(0.1451613);
  //canvasSigma->SetRightMargin(0.05443548);
  //canvasSigma->SetTopMargin(0.005);//0.08474576
  //canvasSigma->SetBottomMargin(0.1165254);
  canvasSigma->SetFrameBorderMode(0);
  canvasSigma->SetFrameBorderMode(0);
  canvasSigma->SetLogy();
  
  //###TH2F* hempty=new TH2F("hempty","", 10, 0.1, 65., 10., 0.1, 1e3);    
  TH2F* hempty=new TH2F("hempty","", 10, 0.1, 65., 10., 0.3, 1e3);    
  hempty->GetXaxis()->SetTitle("p_{T} (GeV/c)");
  //if(particle=="Bplus") hempty->GetYaxis()->SetTitle("d#sigma / dp_{T} (B^{+}) (pb GeV^{-1}c)");
  //if(particle=="Bzero") hempty->GetYaxis()->SetTitle("d#sigma / dp_{T} (B^{0}) (pb GeV^{-1}c)");
  //if(particle=="Bs") hempty->GetYaxis()->SetTitle("d#sigma / dp_{T} (B_{s}) (pb GeV^{-1}c)");
  hempty->GetXaxis()->CenterTitle();
  hempty->GetYaxis()->CenterTitle();
  //###hempty->GetYaxis()->SetTitle("d#sigma / dp_{T}( #mub GeV^{-1}c)");
  hempty->GetYaxis()->SetTitle("d#sigma / dp_{T}(#mub/(GeV/c))");
  //###hempty->GetXaxis()->SetTitleOffset(1.0);//###1.0
  if (particle=="Bplus") hempty->GetXaxis()->SetTitleOffset(0.90);//###1.0
  else if (particle=="Bzero") hempty->GetXaxis()->SetTitleOffset(0.90);//###0.80
  else if (particle=="Bs") hempty->GetXaxis()->SetTitleOffset(0.90);//###0.85

  hempty->GetYaxis()->SetTitleOffset(1.0);//###1.3
  hempty->GetXaxis()->SetTitleSize(0.070*padcorrection);//###0.055
  hempty->GetYaxis()->SetTitleSize(0.070*padcorrection);//###0.055
  hempty->GetXaxis()->SetTitleFont(42);
  hempty->GetYaxis()->SetTitleFont(42);
  hempty->GetXaxis()->SetLabelFont(42);
  hempty->GetYaxis()->SetLabelFont(42);
  hempty->GetXaxis()->SetLabelSize(0.060*padcorrection);//###0.055
  hempty->GetYaxis()->SetLabelSize(0.060*padcorrection);//###0.055
  if (particle=="Bplus") hempty->GetXaxis()->SetLabelOffset(0.005);//###0.005
  else if (particle=="Bzero") hempty->GetXaxis()->SetLabelOffset(0.005);//###0.0001
  else if (particle=="Bs") hempty->GetXaxis()->SetLabelOffset(0.005);//###0.0005
  //###hempty->GetXaxis()->SetLabelOffset(0.005);//###0.005
  hempty->SetMaximum(2);
  hempty->SetMinimum(0.);
  hempty->Draw();
  
  gaeBplusReference->SetMarkerColor(1);
  gaeBplusReference->SetMarkerStyle(25);  
  gaeBplusReference->SetFillColor(kYellow-7);//5
  gaeBplusReference->SetFillStyle(1001);
  gaeBplusReference->SetLineColor(kAzure-3);
  gaeBplusReference->SetLineWidth(1);
  
  
  gSigmastat->SetMarkerColor(1);
  gSigmastat->SetLineColor(1);
  gSigmastat->SetLineWidth(2);   
  gSigmastat->SetMarkerStyle(21);
  gSigmastat->SetMarkerColor(1);

  // Histogram style
  TH1D* hBplusReference = new TH1D("hBplusReference","",nbins,xhbins);
  TH1D* hBplusReferenceEYhigh = new TH1D("hBplusReferenceEYhigh","",nbins,xhbins);
  TH1D* hBplusReferenceEYlow = new TH1D("hBplusReferenceEYlow","",nbins,xhbins);



  for (int i=0;i<nbins;i++){
	double xgae,ygae;
	gaeBplusReference->GetPoint(i,xgae,ygae);
	hBplusReference->SetBinContent(i+1,ygae);
	hBplusReferenceEYhigh->SetBinContent(i+1,ygae+gaeBplusReference->GetEYhigh()[i]);
	hBplusReferenceEYlow->SetBinContent(i+1,ygae-gaeBplusReference->GetEYlow()[i]);
	std::cout << "### FONLL (" << i << ") : " << ygae << " + " << gaeBplusReference->GetEYhigh()[i] << " - " << gaeBplusReference->GetEYlow()[i] << std::endl;
}

  //hBplusReference->SetMarkerColor(1);
  //hBplusReference->SetMarkerStyle(25);  
  //hBplusReference->SetFillColor(kYellow-7);//5
  //hBplusReference->SetFillStyle(1001);
  hBplusReference->SetLineColor(kAzure-3);
  hBplusReference->SetLineWidth(2);
  hBplusReferenceEYhigh->SetLineColor(kAzure-3);
  hBplusReferenceEYhigh->SetLineWidth(2);
  hBplusReferenceEYhigh->SetLineStyle(2);
  hBplusReferenceEYlow->SetLineColor(kAzure-3);
  hBplusReferenceEYlow->SetLineWidth(2);
  hBplusReferenceEYlow->SetLineStyle(2);


/*
  hBplusReference->Draw("][,same");

  hBplusReferenceEYhigh->Draw("][,same");
  hBplusReferenceEYlow->Draw("][,same");
*/


/*
  gaeBplusReference->Draw("2psame");//2same
  TGraphAsymmErrors*gaeBplusReference2=(TGraphAsymmErrors*)gaeBplusReference->Clone();
  gaeBplusReference2->SetMarkerColor(1);
  gaeBplusReference2->SetMarkerStyle(25);  
  gaeBplusReference2->SetFillColor(0);
  gaeBplusReference2->SetFillStyle(0);
  gaeBplusReference2->SetLineColor(kAzure-3);
  gaeBplusReference2->SetLineWidth(1);
  gaeBplusReference2->Draw("2psame");//2same
*/
 
  //coord.  for legend for sigma in the B+ pannel 
  //###TLegend *legendSigma=new TLegend(0.468298,0.7045614,0.7678185,0.8757895,"");
  //###TLegend *legendSigma=new TLegend(0.55,0.63,0.85,0.80,"");
  TLegend *legendSigma=new TLegend(0.38,0.67,0.68,0.84,"");


  legendSigma->SetBorderSize(0);
  legendSigma->SetLineColor(0);
  legendSigma->SetFillColor(0);
  legendSigma->SetFillStyle(1001);
  legendSigma->SetTextFont(42);
  legendSigma->SetTextSize(0.060);//###0.045
/* 
  TBox *c = new TBox(3,1-commonErrorN,7,1+commonErrorP);
  c->SetLineColor(5);
  c->SetFillColor(5);
  c->Draw();

  TBox *c2 = c->Clone();
  c2->SetLineColor(1);
  c2->SetFillStyle(0);
  c2->Draw();
*/  
  //TLegendEntry *ent_SigmapPb=legendSigma->AddEntry(gSigmastat,"pPb","pf");
  TLegendEntry *ent_SigmapPb=legendSigma->AddEntry(gSigmasyst,"pPb","pf");


/*
  ent_SigmapPb->SetTextFont(42);
  ent_SigmapPb->SetLineColor(1);
  ent_SigmapPb->SetMarkerColor(1);
  ent_SigmapPb->SetFillColor(0);
  ent_SigmapPb->SetFillStyle(0);
*/
  ent_SigmapPb->SetTextFont(42);
  ent_SigmapPb->SetMarkerColor(1);
  ent_SigmapPb->SetMarkerStyle(25);  
  //ent_SigmapPb->SetFillColor(kYellow-7);//5
  //ent_SigmapPb->SetFillStyle(1001);
  ent_SigmapPb->SetLineColor(1);
  ent_SigmapPb->SetLineWidth(0);
  ent_SigmapPb->SetLineStyle(0);
 

/*
  TLegendEntry *ent_Sigmapp=legendSigma->AddEntry(gaeBplusReference,"FONLL pp ref.","pf");
  ent_Sigmapp->SetTextFont(42);
  ent_Sigmapp->SetLineColor(kAzure-3);//5
  ent_Sigmapp->SetLineStyle(1);
  ent_Sigmapp->SetMarkerColor(1);
  ent_Sigmapp->SetMarkerStyle(21);
*/
  TLegendEntry *ent_Sigmapp=legendSigma->AddEntry(hBplusReference,"Scaled FONLL pp ref.","l");
  ent_Sigmapp->SetTextFont(42);
  ent_Sigmapp->SetLineColor(kAzure-3);//5
  ent_Sigmapp->SetLineStyle(1);
  ent_Sigmapp->SetMarkerColor(1);
  ent_Sigmapp->SetMarkerStyle(21);

  TLegendEntry *ent_Sigmapperr=legendSigma->AddEntry(hBplusReferenceEYhigh,"FONLL pp ref. uncert.","l");
  ent_Sigmapperr->SetTextFont(42);
  ent_Sigmapperr->SetLineColor(kAzure-3);//5
  ent_Sigmapperr->SetLineStyle(2);
  ent_Sigmapperr->SetMarkerColor(1);
  ent_Sigmapperr->SetMarkerStyle(21);


  //###gSigmasyst->SetFillColor(0);
  //###gSigmasyst->SetFillStyle(0);

for (int i=0;i<nbins;i++){
        double xgae,ygae;
        gSigmastat->GetPoint(i,xgae,ygae);
        std::cout << "### cross section (" << i << ") : " << ygae << " stat: " << gSigmastat->GetEYhigh()[i] << " syst: " << gSigmasyst->GetEYhigh()[i] << std::endl;
}

  gSigmasyst->Draw("2esame");//###2psame
  gSigmasyst2->Draw("2esame");

  hBplusReference->Draw("][,same");

  hBplusReferenceEYhigh->Draw("][,same");
  hBplusReferenceEYlow->Draw("][,same");

  gSigmastat->SetFillColor(0);
  gSigmastat->Draw("epsame");
/*  
  TBox *d = new TBox(0.1,1-commonErrorN,4,1+commonErrorP);
  d->SetLineColor(1);
  d->SetFillColor(0);
  d->Draw();
*/  
  //if(PadNum==0 || PadNum==1){
  if(PadNum==3 || PadNum==1 || PadNum==2){


    legendSigma->Draw("same");
    
    //TLatex * tlatex1=new TLatex(0.21,0.88801268,"CMS");
    TLatex * tlatex1=new TLatex(0.19,0.86,"CMS");
    tlatex1->SetNDC();
    tlatex1->SetTextColor(1);
    tlatex1->SetTextFont(62);//42
    tlatex1->SetTextSize(0.07);//0.045
    tlatex1->Draw();
/*
    TLatex * tlatex12=new TLatex(0.35,0.86,"Preliminary");
    tlatex12->SetNDC();
    tlatex12->SetTextColor(1);
    tlatex12->SetTextFont(52);//42
    tlatex12->SetTextSize(0.05);//0.045
    tlatex12->Draw();
*/   
    //TLatex * tlatexlumi=new TLatex(0.471371,0.88801268,"L = 34.8 nb^{-1} (pPb 5.02 TeV)");
    //TLatex * tlatexlumi=new TLatex(0.471371,0.88801268,"34.6 nb^{-1} (pPb 5.02 TeV)");
    TLatex * tlatexlumi;
//###TLatex * tlatexlumi=new TLatex(0.390,0.950,"34.6 nb^{-1} (pPb 5.02 TeV)");
   if (PadNum==1) tlatexlumi = new TLatex(0.41,0.94,"34.6 nb^{-1} (pPb 5.02 TeV)");
   else tlatexlumi = new TLatex(0.39,0.94,"34.6 nb^{-1} (pPb 5.02 TeV)");
    tlatexlumi->SetNDC();
    tlatexlumi->SetTextColor(1);
    tlatexlumi->SetTextFont(42);
    tlatexlumi->SetTextSize(0.06);//0.045
    tlatexlumi->Draw();
  }

   //if(PadNum==2){
    if(PadNum==3 || PadNum==1 || PadNum==2) {
    //TLatex * tlatex4=new TLatex(0.60,0.73,"|y_{lab}| < 2.4");
    TLatex * tlatex4=new TLatex(0.65,0.50,"|y_{lab}| < 2.4");


    tlatex4->SetNDC();
    tlatex4->SetTextColor(1);
    tlatex4->SetTextFont(42);//42
    tlatex4->SetTextSize(0.07);//0.045
    tlatex4->Draw();
	 }

	double GloUnc;
	double xtl5=0.54;

   if(PadNum==1) {GloUnc=Bp_commonErrorP*100;xtl5=0.54;}//###0.57
   if(PadNum==2) {GloUnc=B0_commonErrorP*100;xtl5=0.47;}
   if(PadNum==3) {GloUnc=Bs_commonErrorP*100;xtl5=0.42;}

	xtl5=0.54;


//TLegend *legendSigma=new TLegend(0.55,0.63,0.85,0.80,"");
   TLatex * tlatex5=new TLatex(xtl5,0.60,Form("Global uncert. %2.1f%%",GloUnc));
    tlatex5->SetNDC();
    tlatex5->SetTextColor(1);
    tlatex5->SetTextFont(42);//42
    tlatex5->SetTextSize(0.05*padcorrection);//0.045
    tlatex5->Draw();

  //###double xpos=0.8528226;
  //###double ypos=0.6849894;
  double xpos=0.90;//0.86
  double ypos=0.85;//0.86
  
  TString mypar;
  if(particle=="Bplus") mypar="B^{+}";
  if(particle=="Bzero") mypar="B^{0}";
  if(particle=="Bs") mypar="B_{s}^{0}";  

  double xlgap=0.04;
/*
  if(particle=="Bplus") xpos=(0.365816-xlgap)/0.365816;
  if(particle=="Bzero") xpos=1-xlgap/(0.673101-0.365816);
  if(particle=="Bs") xpos=0.94-xlgap/(1-0.673101);;  
*/
  TLatex * tlatex3=new TLatex(xpos,ypos,mypar.Data());
  tlatex3->SetNDC();
  tlatex3->SetTextColor(1);
  tlatex3->SetTextFont(42);
  tlatex3->SetTextSize(0.07*padcorrection);
  tlatex3->Draw();

  TGraphAsymmErrors *gRpAstat = new TGraphAsymmErrors(nbins,xbins,yRpA,exl0,exl0,yRpAStat,yRpAStat);
  gRpAstat->SetTitle("RpA stat uncertainty from pPb");
  gRpAstat->SetMarkerStyle(21);
  gRpAstat->SetMarkerColor(1);
  gRpAstat->SetLineColor(1);
  gRpAstat->SetLineWidth(2);  
  gRpAstat->SetFillColor(0);


  TGraphAsymmErrors *gRpAsyst = new TGraphAsymmErrors(nbins,xbins,yRpA,exl,exl,yRpPbSystTotLow,yRpPbSystTotHigh);
  gRpAsyst->SetTitle("RpA syst uncertainty from pPb");
  gRpAsyst->SetName("gRpAsyst");
/*
  gRpAsyst->SetFillColor(0);
  gRpAsyst->SetMarkerSize(0);
  gRpAsyst->SetLineColor(1);
  gRpAsyst->SetLineWidth(2);
  gRpAsyst->SetFillStyle(0);
*/
  gRpAsyst->SetFillColor(kYellow-7);//###0
  //gRpAsyst->SetMarkerSize(0);
  gRpAsyst->SetLineColor(1);
  gRpAsyst->SetLineWidth(2);
  gRpAsyst->SetFillStyle(1001);
  gRpAsyst->SetMarkerStyle(21);
  gRpAsyst->SetMarkerColor(1);
  TGraphAsymmErrors*gRpAsyst2=(TGraphAsymmErrors*)gRpAsyst->Clone();
  gRpAsyst2->SetMarkerColor(1);
  gRpAsyst2->SetMarkerStyle(25);
  gRpAsyst2->SetFillColor(0);
  gRpAsyst2->SetFillStyle(0);
  gRpAsyst2->SetLineColor(1);//5
  gRpAsyst2->SetLineStyle(1);
  gRpAsyst2->SetLineWidth(2);
  
  TGraphAsymmErrors *gRpAsystFONLL = new TGraphAsymmErrors(nbins,xbins,yFONLL,exl,exl,yRpAsystFONLLlow,yRpAsystFONLLhigh);
  gRpAsystFONLL->SetTitle("RpA syst uncertainty from FONLL reference");
/*
  gRpAsystFONLL->SetFillColor(kYellow-7);//5
  gRpAsystFONLL->SetLineColor(kAzure-3);//5
  gRpAsystFONLL->SetMarkerColor(4);//kAzure-3);

  TGraphAsymmErrors *gRpAsystFONLL2 = (TGraphAsymmErrors*)gRpAsystFONLL->Clone();
  gRpAsystFONLL2->SetFillStyle(0);
  gRpAsystFONLL2->SetLineColor(kAzure-3);//5
  gRpAsystFONLL2->SetMarkerColor(4);//kAzure-3);
*/
  gRpAsystFONLL->SetFillColor(0);//5,kYellow-7
  gRpAsystFONLL->SetLineColor(kAzure-3);//5
  gRpAsystFONLL->SetMarkerColor(4);//kAzure-3);
  gRpAsystFONLL->SetLineStyle(1);
  gRpAsystFONLL->SetLineWidth(2);

  TGraphAsymmErrors*gRpAsystFONLL2=(TGraphAsymmErrors*)gRpAsystFONLL->Clone();
  gRpAsystFONLL2->SetMarkerColor(1);
  gRpAsystFONLL2->SetMarkerStyle(25);
  gRpAsystFONLL2->SetFillColor(0);
  gRpAsystFONLL2->SetFillStyle(0);
  gRpAsystFONLL2->SetLineColor(kAzure-3);//5
  gRpAsystFONLL2->SetLineStyle(1);
  gRpAsystFONLL2->SetLineWidth(2);

  canvasRpA->cd(PadNum);
  //canvasRpA->Range(-1.989924,-0.2917772,25.49622,2.212202);
  canvasRpA->SetFillColor(0);
  canvasRpA->SetBorderMode(0);
  canvasRpA->SetBorderSize(2);
/*
  canvasRpA->SetLeftMargin(0.1451613);
  canvasRpA->SetRightMargin(0.05443548);
  canvasRpA->SetTopMargin(0.08474576);
  canvasRpA->SetBottomMargin(0.1165254);
*/
  canvasRpA->SetFrameBorderMode(0);
  canvasRpA->SetFrameBorderMode(0);
  
  hempty=new TH2F("hempty","",10,0.1, 62. ,30.,0.,3.0);  
  hempty->GetXaxis()->CenterTitle();
  hempty->GetYaxis()->CenterTitle();
  hempty->GetXaxis()->SetTitle("p_{T} (GeV/c)");
  hempty->GetYaxis()->SetTitle("R^{FONLL}_{pA}");
  //###hempty->GetXaxis()->SetTitleOffset(1.0);//###1.3
  hempty->GetYaxis()->SetTitleOffset(1.0);//###1.1
  hempty->GetXaxis()->SetTitleSize(0.070*padcorrection);//###0.055
  hempty->GetYaxis()->SetTitleSize(0.070*padcorrection);//###0.055
  hempty->GetXaxis()->SetTitleFont(42);
  hempty->GetYaxis()->SetTitleFont(42);
  hempty->GetXaxis()->SetLabelFont(42);
  hempty->GetYaxis()->SetLabelFont(42);
  hempty->GetXaxis()->SetLabelSize(0.060*padcorrection);//###0.055
  hempty->GetYaxis()->SetLabelSize(0.060*padcorrection);//###0.055  
  if (particle=="Bplus") hempty->GetXaxis()->SetTitleOffset(0.90);//###1.0
  else if (particle=="Bzero") hempty->GetXaxis()->SetTitleOffset(0.90);//###0.80
  else if (particle=="Bs") hempty->GetXaxis()->SetTitleOffset(0.90);//###0.85
  if (particle=="Bplus") hempty->GetXaxis()->SetLabelOffset(0.005);//###0.005
  else if (particle=="Bzero") hempty->GetXaxis()->SetLabelOffset(0.005);//###0.0001
  else if (particle=="Bs") hempty->GetXaxis()->SetLabelOffset(0.005);//###0.0005
  //###hempty->SetMaximum(2);
  hempty->SetMaximum(3.0);
  hempty->SetMinimum(0.);

  hempty->Draw();
  
  TLine *l = new TLine(0,1, 65.,1);
  l->SetLineStyle(2);

  //TLine *line = new TLine(8.740882,1.017445,61,1.008586);
  //###TLine *line = new TLine(4.740882,1.017445,61,1.008586);
  TLine *line = new TLine(4.740882,1.00,61,1.00);


  line->SetLineColor(kRed);//###
  line->SetLineStyle(2);  
  line->SetLineWidth(2);
/*  
  gRpAsystFONLL->Draw("2same");
  gRpAsystFONLL2->Draw("2same");
  line->Draw();
  gRpAsyst->Draw("2esame");
  gRpAstat->Draw("psame");
*/
  gRpAstat->SetMarkerStyle(21);
  gRpAstat->SetLineColor(1);
  gRpAstat->SetMarkerColor(1);

for (int i=0;i<nbins;i++){
         double xgae,ygae;
         gRpAstat->GetPoint(i,xgae,ygae);
         std::cout << "####### RpA (" << i << ") : " << ygae << " stat: " << gRpAstat->GetEYhigh()[i] << " syst: " << gRpAsyst->GetEYhigh()[i] << std::endl;
	 std::cout << "########### FONLL (" << i << ") : " << " + " << gRpAsystFONLL->GetEYhigh()[i] << " - " << gRpAsystFONLL->GetEYlow()[i] << std::    endl;
}

  gRpAsystFONLL->Draw("2same");
  gRpAsystFONLL2->Draw("2same");
  //###line->Draw();

  gRpAsyst->Draw("2esame");
  gRpAsyst2->Draw("2esame");
  gRpAstat->Draw("psame");  
  line->Draw();

 
  TBox *a = new TBox(0.1,1-commonErrorN,4,1+commonErrorP);
  a->SetLineColor(1);
  a->SetFillColor(0);
  a->Draw();
  std::cout << "%%%%%%% RpA commonError " << " - " << commonErrorN << " + " << commonErrorP << std::endl;
  TBox *b = new TBox(0.1,1-commonErrorN,4,1+commonErrorP);
  b->SetLineColor(1);
  b->SetFillColor(kGray);
  b->Draw();
  TBox *b2 = (TBox*)b->Clone();
  b2->SetLineColor(1);
  b2->SetFillStyle(0);
  b2->Draw();

  TLegend *legendRpA=new TLegend(0.22,0.60,0.51,0.83,"");

  legendRpA->SetBorderSize(0);
  legendRpA->SetLineColor(0);
  legendRpA->SetFillColor(0);
  legendRpA->SetFillStyle(1001);
  legendRpA->SetTextFont(42);
  legendRpA->SetTextSize(0.060);//###0.045

  TLegendEntry *ent_RpAstat=legendRpA->AddEntry(gRpAstat,"R^{FONLL}_{pA}","p");
  //###TLegendEntry *ent_RpAstat=legendRpA->AddEntry(gRpAstat,"pPb data","pf");

/*
  ent_RpAstat->SetTextFont(42);
  ent_RpAstat->SetLineColor(2);
  ent_RpAstat->SetMarkerColor(2);
*/
  ent_RpAstat->SetTextFont(42);
  ent_RpAstat->SetMarkerColor(1);
  ent_RpAstat->SetMarkerStyle(25);
  //ent_RpAstat->SetFillColor(kYellow-7);//5
  //ent_RpAstat->SetFillStyle(1001);
  ent_RpAstat->SetLineColor(1);
  ent_RpAstat->SetLineWidth(2);
  ent_RpAstat->SetLineStyle(0);

  TLegendEntry *ent_RpAsyst=legendRpA->AddEntry(gRpAsyst,"Syst. pPb data","f");
  ent_RpAsyst->SetTextFont(42);
  ent_RpAsyst->SetMarkerColor(1);
  ent_RpAsyst->SetMarkerStyle(25);
  //ent_RpAsyst->SetFillColor(kYellow-7);//5
  //ent_RpAsyst->SetFillStyle(1001);
  ent_RpAsyst->SetLineColor(1);
  ent_RpAsyst->SetLineWidth(2);
  ent_RpAsyst->SetLineStyle(0);
  
  TLegendEntry *ent_RpAsystFONLL=legendRpA->AddEntry(gRpAsystFONLL,"Syst. FONLL pp ref.","f");
/*
  ent_RpAsystFONLL->SetTextFont(42);
  ent_RpAsystFONLL->SetLineColor(kAzure-3);//5
  ent_RpAsystFONLL->SetLineStyle(1);
  ent_RpAsystFONLL->SetLineWidth(1);
  ent_RpAsystFONLL->SetMarkerColor(kYellow-7);//5
*/

  ent_RpAsystFONLL->SetTextFont(42);
  ent_RpAsystFONLL->SetLineColor(2);//###5
  ent_RpAsystFONLL->SetLineStyle(1);
  ent_RpAsystFONLL->SetMarkerColor(kYellow-7);//5

   TLegendEntry *ent_RpAsystData=legendRpA->AddEntry(b,"Syst. int. lumi + B","f");
/*
  ent_RpAsystData->SetTextFont(42);
  ent_RpAsystData->SetLineColor(1);
  ent_RpAsystData->SetMarkerColor(2);
*/
  ent_RpAsystData->SetTextFont(42);
  ent_RpAsystData->SetLineColor(2);
  ent_RpAsystData->SetMarkerColor(2);
 
  //if(PadNum==1||PadNum==3){
    if(PadNum==3 || PadNum==1 || PadNum==2) {

    legendRpA->Draw();

    //TLatex * tlatex4=new TLatex(0.21,0.88801268,"CMS");
    TLatex * tlatex4=new TLatex(0.19,0.85,"CMS");

    tlatex4->SetNDC();
    tlatex4->SetTextColor(1);
    tlatex4->SetTextFont(62);//42
    tlatex4->SetTextSize(0.07);//0.045
    tlatex4->Draw();
/* 
    TLatex * tlatex42=new TLatex(0.35,0.86,"Preliminary");
    tlatex42->SetNDC();
    tlatex42->SetTextColor(1);
    tlatex42->SetTextFont(52);//42
    tlatex42->SetTextSize(0.05);//0.045
    tlatex42->Draw();
*/ 
    //TLatex * tlatex2=new TLatex(0.471371,0.88801268,"L = 34.8 nb^{-1} (pPb 5.02 TeV)");
    //TLatex * tlatex2=new TLatex(0.471371,0.88801268,"34.6 nb^{-1} (pPb 5.02 TeV)");
    //###TLatex * tlatex2=new TLatex(0.390,0.950,"34.6 nb^{-1} (pPb 5.02 TeV)");
    TLatex * tlatex2;

   if (PadNum==1) tlatex2 = new TLatex(0.41,0.94,"34.6 nb^{-1} (pPb 5.02 TeV)");
   else tlatex2 = new TLatex(0.39,0.94,"34.6 nb^{-1} (pPb 5.02 TeV)");

    tlatex2->SetNDC();
    tlatex2->SetTextColor(1);
    tlatex2->SetTextFont(42);
    tlatex2->SetTextSize(0.06);//0.045
   tlatex2->Draw();
  }
    //if(PadNum==2){
    if(PadNum==3 || PadNum==1 || PadNum==2) {

    TLatex * tlatex4=new TLatex(0.65,0.23,"|y_{lab}| < 2.4");
    tlatex4->SetNDC();
    tlatex4->SetTextColor(1);
    tlatex4->SetTextFont(42);//42
    tlatex4->SetTextSize(0.07);//0.045
    tlatex4->Draw();
	 }

  
  tlatex3->Draw();
  
  
  
  TFile *fout=new TFile(Form("../Results%s/fileRpA%s.root",particle.Data(),particle.Data()),"recreate");  
  fout->cd();
  gSigmasyst->SetName("gSigmasyst");
  gSigmasyst->Write();
  gaeBplusReference->Write();
  hSigmapPbStat->Write();
}
예제 #2
0
void raaExpOpen_pt(const char* inputDir = "../macro_raa/outRoot", // the place where the input root files, with the histograms are
                   bool bSavePlots      = true,
                   bool bDrawCh         = true,
                   double xMax          = 30 // x-axis range limit (ALICE D has x-range maximum value at 36, CMS has it at 30)
                  )
{
  // set the style
  gSystem->mkdir(Form("./figs/png"), kTRUE);
  gSystem->mkdir(Form("./figs/pdf"), kTRUE);
  setTDRStyle();
  
  // read CMS graphs
  TFile *pgRaaCms_pt   = new TFile(Form("%s/makeRaa_pt.root",inputDir));
  // ##################### HIGH PT ############################
  TGraphErrors *pgCms     = (TGraphErrors *)pgRaaCms_pt->Get("gNonPrJpsi");
  TGraphErrors *pgCmsP    = (TGraphErrors *)pgRaaCms_pt->Get("gNonPrJpsiP");
  TGraphErrors *pgCmsSyst = (TGraphErrors *)pgRaaCms_pt->Get("gNonPrJpsiSyst");
  pgCmsSyst->SetFillColorAlpha(kOrange-9,0.5);
  pgCms->SetName("gNonPrJpsi");

  TBox *lumi = (TBox*)pgRaaCms_pt->Get("lumi");
  lumi->SetFillColor(kOrange-9);
  lumi->SetFillStyle(1001);
  lumi->SetX1(xMax-0.75); lumi->SetX2(xMax);
  TBox *lumi_lowpt = (TBox*)lumi->Clone("lumi_lowpt");
  lumi_lowpt->SetFillColor(kViolet-9);
  lumi_lowpt->SetFillStyle(1001);
  lumi_lowpt->SetX1(xMax-1.5); lumi_lowpt->SetX2(xMax-0.75);

  // ##################### LOW PT ############################
  TGraphErrors *pgCms_lowpt     = (TGraphErrors *)pgRaaCms_pt->Get("gNonPrJpsi_pt365y1624");
  TGraphErrors *pgCmsP_lowpt    = (TGraphErrors *)pgRaaCms_pt->Get("gNonPrJpsiP_pt365y1624");
  TGraphErrors *pgCmsSyst_lowpt = (TGraphErrors *)pgRaaCms_pt->Get("gNonPrJpsiSyst_pt365y1624");
  pgCmsSyst_lowpt->SetFillColorAlpha(kViolet-9,0.5);
  pgCms_lowpt->SetName("gNonPrJpsi_pt365y1624");

  //-------------------------------------------------------------------- 
  // *********** CMS Charged particle RAA
  TGraphAsymmErrors *p8165_d5x1y1 = new TGraphAsymmErrors(p8165_d5x1y1_numpoints, p8165_d5x1y1_xval, p8165_d5x1y1_yval, p8165_d5x1y1_xerrminus, p8165_d5x1y1_xerrplus, p8165_d5x1y1_ystatminus, p8165_d5x1y1_ystatplus);
  TGraphAsymmErrors *p8165_d5x1y1_syst = new TGraphAsymmErrors(p8165_d5x1y1_numpoints, p8165_d5x1y1_xval, p8165_d5x1y1_yval, p8165_d5x1y1_xerrminus, p8165_d5x1y1_xerrplus, p8165_d5x1y1_yerrminus, p8165_d5x1y1_yerrplus);
  p8165_d5x1y1->SetName("cms_ch_raa");
  // X-axis errors will be discarded
  for (int i=0; i<p8165_d5x1y1_numpoints; i++) {
    p8165_d5x1y1->SetPointEXlow(i,0);
    p8165_d5x1y1->SetPointEXhigh(i,0);
    p8165_d5x1y1_syst->SetPointEXlow(i,0.5);
    p8165_d5x1y1_syst->SetPointEXhigh(i,0.5);
  }
   
  // *********** ALICE D RAA vs. pT
  TGraphAsymmErrors *p9059_d15x1y1 = new TGraphAsymmErrors(p9059_d15x1y1_numpoints, p9059_d15x1y1_xval, p9059_d15x1y1_yval, p9059_d15x1y1_xerrminus, p9059_d15x1y1_xerrplus, p9059_d15x1y1_yerrminus, p9059_d15x1y1_yerrplus);
  TGraphAsymmErrors *p9059_d15x1y1_syst = new TGraphAsymmErrors(p9059_d15x1y1_numpoints, p9059_d15x1y1_xval, p9059_d15x1y1_yval, p9059_d15x1y1_xerrminus, p9059_d15x1y1_xerrplus, p9059_d15x1y1_yerrminus, p9059_d15x1y1_yerrplus);
  p9059_d15x1y1->SetName("alice_d_raa");
  // X-axis errors will be discarded
  for (int i=0; i<p9059_d15x1y1_numpoints; i++) {
    p9059_d15x1y1->SetPointEXlow(i,0);
    p9059_d15x1y1->SetPointEXhigh(i,0);
    p9059_d15x1y1_syst->SetPointEXlow(i,0.5);
    p9059_d15x1y1_syst->SetPointEXhigh(i,0.5);
    if (xMax<=30 && (i+1)==p9059_d15x1y1_numpoints) {
      double x,y;
      p9059_d15x1y1->GetPoint(i,x,y);
      p9059_d15x1y1->SetPoint(i,x+5,y);
      p9059_d15x1y1_syst->GetPoint(i,x,y);
      p9059_d15x1y1_syst->SetPoint(i,x+5,y);
    }
  }

  // Style for graphs
  p9059_d15x1y1->SetMarkerStyle(kOpenSquare);
  p9059_d15x1y1->SetMarkerSize(1.3);
  p9059_d15x1y1->SetMarkerColor(kBlack);
  p9059_d15x1y1->SetLineColor(kBlack);
  p9059_d15x1y1_syst->SetFillColorAlpha(kGray+1,0.5);

  p8165_d5x1y1->SetMarkerStyle(20);
  p8165_d5x1y1->SetMarkerSize(1.3);
  p8165_d5x1y1->SetMarkerColor(kTeal+3);
  p8165_d5x1y1->SetLineColor(kTeal+4);
  p8165_d5x1y1_syst->SetFillColorAlpha(kTeal-1,0.5);



  //---------------------------------------------------------
  TLine *line = new TLine(0.,1,xMax,1);
  line->SetLineStyle(1);
  line->SetLineWidth(1);

  TCanvas *pc = new TCanvas("pc","pc");

  TF1 *f4 = new TF1("f4","1",0,xMax);
  f4->SetLineWidth(1);
  f4->GetXaxis()->SetTitle("p_{T} (GeV/c)");
  f4->GetYaxis()->SetTitle("R_{AA}");
  f4->GetXaxis()->SetRangeUser(0.0,xMax);
  f4->GetYaxis()->SetRangeUser(0.0,1.5);
  f4->GetXaxis()->CenterTitle(kTRUE);
 
  f4->Draw();
  lumi->Draw();
  lumi_lowpt->Draw();
  pc->Update();

  pgCmsSyst->Draw("2"); // for drawing x-axis

  p9059_d15x1y1_syst->Draw("2");
  if (bDrawCh) p8165_d5x1y1_syst->Draw("2");
  p9059_d15x1y1->Draw("pz");
  if (bDrawCh) p8165_d5x1y1->Draw("pz");

  pgCmsSyst->Draw("2");
  pgCmsP->Draw("P");
  pgCms->Draw("P");
  pgCmsSyst_lowpt->Draw("2");
  pgCmsP_lowpt->Draw("P");
  pgCms_lowpt->Draw("P");

  // additional info
  CMS_lumi(pc,12003000,0);

  TLegend *leg_cent = new TLegend(0.28,0.77,0.86,0.89,NULL,"brNDC"); // at top center
  leg_cent->SetMargin(0.12);
  leg_cent->SetBorderSize(0);
  leg_cent->SetTextFont(132);
  leg_cent->SetTextSize(0.03);
  leg_cent->SetLineColor(1);
  leg_cent->SetLineStyle(1);
  leg_cent->SetLineWidth(1);
  leg_cent->SetFillColor(19);
  leg_cent->SetFillStyle(0);

  TLegendEntry *entry_cent;
  entry_cent=leg_cent->AddEntry("raab","Open beauty: Nonprompt J/#psi","");
  entry_cent->SetTextFont(132);
  entry_cent->SetTextSize(ltxSetTextSize3);
  entry_cent=leg_cent->AddEntry("gNonPrJpsi_pt365y1624", "1.6 < |y| < 2.4","p");
  entry_cent->SetTextFont(42);
  entry_cent->SetTextSize(entrySize);
  entry_cent=leg_cent->AddEntry("gNonPrJpsi", "|y| < 2.4","p");
  entry_cent->SetTextFont(42);
  entry_cent->SetTextSize(entrySize);

  TLegend *leg_ch = new TLegend(0.28,0.685,0.86,0.765,NULL,"brNDC");
  leg_ch->SetMargin(0.12);
  leg_ch->SetBorderSize(0);
  leg_ch->SetTextFont(132);
  leg_ch->SetTextSize(0.03);
  leg_ch->SetLineColor(1);
  leg_ch->SetLineStyle(1);
  leg_ch->SetLineWidth(1);
  leg_ch->SetFillColor(19);
  leg_ch->SetFillStyle(0);

  if (bDrawCh) {
    TLegendEntry *entry_ch;
    entry_ch=leg_ch->AddEntry("cms_ch","Charged hadron","");
    entry_ch->SetTextSize(ltxSetTextSize3);
    entry_ch->SetTextFont(132);
    entry_ch=leg_ch->AddEntry("cms_ch_raa","|#eta| < 1, Cent. 0-5%","p");
    entry_ch->SetTextSize(entrySize);
    entry_ch->SetTextFont(42);
  }
  
  TLegend *leg_alice;
  if (bDrawCh) {
    leg_alice = new TLegend(0.28,0.60,0.86,0.68,NULL,"brNDC");
  } else {
    leg_alice = new TLegend(0.28,0.685,0.86,0.765,NULL,"brNDC");
  }
  leg_alice->SetMargin(0.12);
  leg_alice->SetBorderSize(0);
  leg_alice->SetTextFont(132);
  leg_alice->SetTextSize(0.03);
  leg_alice->SetLineColor(1);
  leg_alice->SetLineStyle(1);
  leg_alice->SetLineWidth(1);
  leg_alice->SetFillColor(kWhite);
  leg_alice->SetFillStyle(1000);

  TLegendEntry *entry_alice;
  entry_alice=leg_alice->AddEntry("alice_d","Open charm: Prompt D (ALICE)","");
  entry_alice->SetTextSize(ltxSetTextSize3);
  entry_alice->SetTextFont(132);
  entry_alice=leg_alice->AddEntry("alice_d_raa","|y| < 0.5, Cent. 0-10%","p");
  entry_alice->SetTextSize(entrySize);
  entry_alice->SetTextFont(42);

  TLatex *lat = new TLatex();
  lat->SetNDC();
  lat->SetTextFont(42);
  lat->SetTextSize(ltxSetTextSize2);
  if (bDrawCh) lat->DrawLatex(0.63,0.53,"Cent. 0-100%");
  else lat->DrawLatex(0.63,0.58,"Cent. 0-100%");

  line->Draw();
  leg_cent->Draw();
  if (bDrawCh) leg_ch->Draw();
  leg_alice->Draw();
  gPad->RedrawAxis();

  if(bSavePlots)
  {
    pc->SaveAs(Form("figs/pdf/raaExpOpen_pt_RaaCh%d.pdf",bDrawCh));
    pc->SaveAs(Form("figs/png/raaExpOpen_pt_RaaCh%d.png",bDrawCh));
  }
}
예제 #3
0
void categories_sig() {

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

  gStyle->SetCanvasColor(0);
  gStyle->SetFrameBorderMode(0);
  
  gStyle->SetPalette(1);

  TText *text = new TText();
  text->SetNDC();
  text->SetTextSize(0.05);

  TFile *file = TFile::Open("histograms_CMS-HGG_categories_sig.root");
  file->cd();

  TCanvas *c_bdtout = new TCanvas("c_bdtout","BDT output");

  bdtout_all_tot = (TH1*)bdtout_cat0_tot->Clone();
  bdtout_all_tot->Add(bdtout_cat1_tot);
  bdtout_all_tot->Add(bdtout_cat2_tot);
  bdtout_all_tot->Add(bdtout_cat3_tot);

  cout << bdtout_all_tot->Integral() << endl;
  cout << bdtout_all_tot->Integral(49,100)+bdtout_all_tot->GetBinContent(48)/2. << endl;
  cout << bdtout_all_tot->GetBinLowEdge(49) << endl;
  cout << bdtout_all_tot->GetBinLowEdge(48) << endl;
  cout << (bdtout_all_tot->Integral(49,100)+bdtout_all_tot->GetBinContent(48)/2.)/bdtout_all_tot->Integral() << endl;

  bdtout_passCiC_all_tot = (TH1*)bdtout_passCiC_cat0_tot->Clone();
  bdtout_passCiC_all_tot->Add(bdtout_passCiC_cat1_tot);
  bdtout_passCiC_all_tot->Add(bdtout_passCiC_cat2_tot);
  bdtout_passCiC_all_tot->Add(bdtout_passCiC_cat3_tot);

  bdtout_failpresel_cat0_tot->Rebin(2);
  bdtout_failpresel_cat1_tot->Rebin(2);
  bdtout_failpresel_cat2_tot->Rebin(2);
  bdtout_failpresel_cat3_tot->Rebin(2);

  bdtout_failpresel_all_tot = (TH1*)bdtout_failpresel_cat0_tot->Clone();
  bdtout_failpresel_all_tot->Add(bdtout_failpresel_cat1_tot);
  bdtout_failpresel_all_tot->Add(bdtout_failpresel_cat2_tot);
  bdtout_failpresel_all_tot->Add(bdtout_failpresel_cat3_tot);

  float nFail_m100180_bdtout005 = bdtout_all_tot->Integral(1,52) + bdtout_all_tot->GetBinContent(53)/2.;
  float nFail_m100180 = bdtout_all_tot->Integral(1,100);
  float frac_bdtout005 = nFail_m100180_bdtout005/nFail_m100180;
  float frac_bdtout005_err = frac_err(nFail_m100180_bdtout005,nFail_m100180);
  cout << bdtout_all_tot->Integral(1,52) << " " <<  bdtout_all_tot->GetBinContent(53)/2. << " " << bdtout_all_tot->Integral(1,100) << " " << bdtout_all_tot->GetBinLowEdge(53) << " " << frac_bdtout005 << " ± " << frac_bdtout005_err << endl;

  bdtout_all_tot->SetLineColor(1);
  bdtout_cat0_tot->SetLineColor(2);
  bdtout_cat1_tot->SetLineColor(3);
  bdtout_cat2_tot->SetLineColor(4);
  bdtout_cat3_tot->SetLineColor(6);

  bdtout_all_tot->SetLineWidth(2);
  bdtout_cat0_tot->SetLineWidth(2);
  bdtout_cat1_tot->SetLineWidth(2);
  bdtout_cat2_tot->SetLineWidth(2);
  bdtout_cat3_tot->SetLineWidth(2);

  bdtout_cat0_tot->SetMarkerColor(2);
  bdtout_cat1_tot->SetMarkerColor(3);
  bdtout_cat2_tot->SetMarkerColor(4);
  bdtout_cat3_tot->SetMarkerColor(6);

  bdtout_all_tot->SetMarkerStyle(20);
  bdtout_cat0_tot->SetMarkerStyle(20);
  bdtout_cat1_tot->SetMarkerStyle(20);
  bdtout_cat2_tot->SetMarkerStyle(20);
  bdtout_cat3_tot->SetMarkerStyle(20);

  bdtout_all_tot->SetMarkerSize(0.7);
  bdtout_cat0_tot->SetMarkerSize(0.7);
  bdtout_cat1_tot->SetMarkerSize(0.7);
  bdtout_cat2_tot->SetMarkerSize(0.7);
  bdtout_cat3_tot->SetMarkerSize(0.7);

  bdtout_passCiC_all_tot->SetLineColor(1);
  bdtout_passCiC_cat0_tot->SetLineColor(2);
  bdtout_passCiC_cat1_tot->SetLineColor(3);
  bdtout_passCiC_cat2_tot->SetLineColor(4);
  bdtout_passCiC_cat3_tot->SetLineColor(6);

  bdtout_passCiC_lowPt_cat0_tot->SetLineColor(2);
  bdtout_passCiC_lowPt_cat1_tot->SetLineColor(3);
  bdtout_passCiC_lowPt_cat2_tot->SetLineColor(4);
  bdtout_passCiC_lowPt_cat3_tot->SetLineColor(6);

  bdtout_passCiC_highPt_cat0_tot->SetLineColor(2);
  bdtout_passCiC_highPt_cat1_tot->SetLineColor(3);
  bdtout_passCiC_highPt_cat2_tot->SetLineColor(4);
  bdtout_passCiC_highPt_cat3_tot->SetLineColor(6);

  bdtout_failpresel_all_tot->SetLineColor(1);
  bdtout_failpresel_cat0_tot->SetLineColor(2);
  bdtout_failpresel_cat1_tot->SetLineColor(3);
  bdtout_failpresel_cat2_tot->SetLineColor(4);
  bdtout_failpresel_cat3_tot->SetLineColor(6);


  bdtout_all_tot->GetXaxis()->SetTitle("di-photon MVA output");

  float boundaries[4] = {-0.05,0.49,0.79,.91};
  float max = bdtout_all_tot->GetMaximum();

  TBox* box = new TBox(-1.,0.,boundaries[0],max*1.05);
  box->SetFillColor(38);
  box->SetFillStyle(3002);

  bdtout_all_tot->Draw("hist");
  box->Draw("hist,same");
  bdtout_all_tot->Draw("hist,same");
  bdtout_cat0_tot->Draw("hist,same");
  bdtout_cat1_tot->Draw("hist,same");
  bdtout_cat2_tot->Draw("hist,same");
  bdtout_cat3_tot->Draw("hist,same");

  TLegend *leg;
  leg = new TLegend(.14,.6,.46,.87);
  leg->SetBorderSize(0);
  leg->SetFillColor(10);
  leg->SetTextSize(.035);
  leg->AddEntry(bdtout_all_tot,"All");
  leg->AddEntry(bdtout_cat0_tot,"both EB, both R9>0.94");
  leg->AddEntry(bdtout_cat1_tot,"both EB, !both R9>0.94");
  leg->AddEntry(bdtout_cat2_tot,"!both EB, both R9>0.94");
  leg->AddEntry(bdtout_cat3_tot,"!both EB, !both R9>0.94");
  leg->Draw("hist");

  TLine* line[4];
  for (int i=0; i<4; i++) {
    line[i] = new TLine(boundaries[i],0.,boundaries[i],max*1.05);
    line[i]->SetLineColor(4);
    line[i]->SetLineWidth(2);
    line[i]->SetLineStyle(9);
    line[i]->Draw("hist");
  }

  gPad->RedrawAxis();

  c_bdtout->SaveAs("categories_sig.png");


  TCanvas *c_bdtout_passCiC = new TCanvas("c_bdtout_passCiC","BDT output, pass CiC");

  bdtout_passCiC_cat0_tot_clone = (TH1*)bdtout_passCiC_cat0_tot->Clone();
  bdtout_passCiC_cat1_tot_clone = (TH1*)bdtout_passCiC_cat1_tot->Clone();
  bdtout_passCiC_cat2_tot_clone = (TH1*)bdtout_passCiC_cat2_tot->Clone();
  bdtout_passCiC_cat3_tot_clone = (TH1*)bdtout_passCiC_cat3_tot->Clone();

  bdtout_passCiC_all_tot->SetLineWidth(2);
  bdtout_passCiC_cat0_tot_clone->SetLineWidth(2);
  bdtout_passCiC_cat1_tot_clone->SetLineWidth(2);
  bdtout_passCiC_cat2_tot_clone->SetLineWidth(2);
  bdtout_passCiC_cat3_tot_clone->SetLineWidth(2);

  bdtout_passCiC_all_tot->GetXaxis()->SetTitle("di-photon MVA output");

  max = bdtout_passCiC_all_tot->GetMaximum();
  TBox* box_passCiC = new TBox(-1.,0.,boundaries[0],max*1.05);
  box_passCiC->SetFillColor(38);
  box_passCiC->SetFillStyle(3002);

  bdtout_passCiC_all_tot->Draw("hist");
  box_passCiC->Draw("hist,same");
  bdtout_passCiC_all_tot->Draw("hist,same");
  bdtout_passCiC_cat0_tot_clone->Draw("hist,same");
  bdtout_passCiC_cat1_tot_clone->Draw("hist,same");
  bdtout_passCiC_cat2_tot_clone->Draw("hist,same");
  bdtout_passCiC_cat3_tot_clone->Draw("hist,same");

  leg->Draw("hist");

  TLine* line_passCiC[4];
  for (int i=0; i<4; i++) {
    line_passCiC[i] = new TLine(boundaries[i],0.,boundaries[i],max*1.05);
    line_passCiC[i]->SetLineColor(4);
    line_passCiC[i]->SetLineWidth(2);
    line_passCiC[i]->SetLineStyle(9);
    line_passCiC[i]->Draw("hist");
  }

  gPad->RedrawAxis();

  c_bdtout_passCiC->SaveAs("categories_passCiC_sig.png");

  /*
  TCanvas *c_bdtout_failpresel = new TCanvas("c_bdtout_failpresel","BDT output, pass CiC, fail presel");

  bdtout_failpresel_cat0_tot_clone = (TH1*)bdtout_failpresel_cat0_tot->Clone();
  bdtout_failpresel_cat1_tot_clone = (TH1*)bdtout_failpresel_cat1_tot->Clone();
  bdtout_failpresel_cat2_tot_clone = (TH1*)bdtout_failpresel_cat2_tot->Clone();
  bdtout_failpresel_cat3_tot_clone = (TH1*)bdtout_failpresel_cat3_tot->Clone();

  bdtout_failpresel_all_tot->SetLineWidth(2);
  bdtout_failpresel_cat0_tot_clone->SetLineWidth(2);
  bdtout_failpresel_cat1_tot_clone->SetLineWidth(2);
  bdtout_failpresel_cat2_tot_clone->SetLineWidth(2);
  bdtout_failpresel_cat3_tot_clone->SetLineWidth(2);

  bdtout_failpresel_all_tot->GetXaxis()->SetTitle("di-photon MVA output");

  max = bdtout_failpresel_all_tot->GetMaximum();
  TBox* box_failpresel = new TBox(-1.,0.,boundaries[0],max*1.05);
  box_failpresel->SetFillColor(38);
  box_failpresel->SetFillStyle(3002);

  bdtout_failpresel_all_tot->Draw("hist");
  box_failpresel->Draw("hist,same");
  bdtout_failpresel_all_tot->Draw("hist,same");
  bdtout_failpresel_cat0_tot_clone->Draw("hist,same");
  bdtout_failpresel_cat1_tot_clone->Draw("hist,same");
  bdtout_failpresel_cat2_tot_clone->Draw("hist,same");
  bdtout_failpresel_cat3_tot_clone->Draw("hist,same");

  leg->Draw("hist");

  TLine* line_failpresel[4];
  for (int i=0; i<4; i++) {
    line_failpresel[i] = new TLine(boundaries[i],0.,boundaries[i],max*1.05);
    line_failpresel[i]->SetLineColor(4);
    line_failpresel[i]->SetLineWidth(2);
    line_failpresel[i]->SetLineStyle(9);
    line_failpresel[i]->Draw("hist");
  }

  gPad->RedrawAxis();

  c_bdtout_failpresel->SaveAs("categories_failpresel_sig.png");
  */

  TCanvas *c_bdtout_compareCiC = new TCanvas("c_bdtout_compareCiC","BDT output: pass CiC supertight",1000,650);
  c_bdtout_compareCiC->Divide(2,2);

  bdtout_passCiC_cat0_tot->SetFillColor(2);
  bdtout_passCiC_cat1_tot->SetFillColor(3);
  bdtout_passCiC_cat2_tot->SetFillColor(4);
  bdtout_passCiC_cat3_tot->SetFillColor(6);

  bdtout_passCiC_cat0_tot->SetFillStyle(3002);
  bdtout_passCiC_cat1_tot->SetFillStyle(3002);
  bdtout_passCiC_cat2_tot->SetFillStyle(3002);
  bdtout_passCiC_cat3_tot->SetFillStyle(3002);

  bdtout_cat0_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_cat1_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_cat2_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_cat3_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_cat0_tot->GetXaxis()->SetTitleSize(0.05);
  bdtout_cat1_tot->GetXaxis()->SetTitleSize(0.05);
  bdtout_cat2_tot->GetXaxis()->SetTitleSize(0.05);
  bdtout_cat3_tot->GetXaxis()->SetTitleSize(0.05);

  c_bdtout_compareCiC->cd(1);

  box_passCiC_cat0 = (TBox*)box->Clone();
  box_passCiC_cat0->SetY2(bdtout_cat0_tot->GetMaximum()*1.05);

  bdtout_cat0_tot->Draw("hist");
  box_passCiC_cat0->Draw("hist,same");
  bdtout_cat0_tot->Draw("hist,same");
  bdtout_passCiC_cat0_tot->Draw("hist,same");

  TLine* line_passCiC_cat0[4];
  for (int i=0; i<4; i++) {
    line_passCiC_cat0[i] = (TLine*)line[i]->Clone();
    line_passCiC_cat0[i]->SetY2(bdtout_cat0_tot->GetMaximum()*1.05);
    line_passCiC_cat0[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"both EB, both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC->cd(2);

  box_passCiC_cat1 = (TBox*)box->Clone();
  box_passCiC_cat1->SetY2(bdtout_cat1_tot->GetMaximum()*1.05);

  bdtout_cat1_tot->Draw("hist");
  box_passCiC_cat1->Draw("hist,same");
  bdtout_cat1_tot->Draw("hist,same");
  bdtout_passCiC_cat1_tot->Draw("hist,same");

  TLine* line_passCiC_cat1[4];
  for (int i=0; i<4; i++) {
    line_passCiC_cat1[i] = (TLine*)line[i]->Clone();
    line_passCiC_cat1[i]->SetY2(bdtout_cat1_tot->GetMaximum()*1.05);
    line_passCiC_cat1[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"both EB, !both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC->cd(3);

  box_passCiC_cat2 = (TBox*)box->Clone();
  box_passCiC_cat2->SetY2(bdtout_cat2_tot->GetMaximum()*1.05);

  bdtout_cat2_tot->Draw("hist");
  box_passCiC_cat2->Draw("hist,same");
  bdtout_cat2_tot->Draw("hist,same");
  bdtout_passCiC_cat2_tot->Draw("hist,same");

  TLine* line_passCiC_cat2[4];
  for (int i=0; i<4; i++) {
    line_passCiC_cat2[i] = (TLine*)line[i]->Clone();
    line_passCiC_cat2[i]->SetY2(bdtout_cat2_tot->GetMaximum()*1.05);
    line_passCiC_cat2[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"!both EB, both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC->cd(4);

  box_passCiC_cat3 = (TBox*)box->Clone();
  box_passCiC_cat3->SetY2(bdtout_cat3_tot->GetMaximum()*1.05);

  bdtout_cat3_tot->Draw("hist");
  box_passCiC_cat3->Draw("hist,same");
  bdtout_cat3_tot->Draw("hist,same");
  bdtout_passCiC_cat3_tot->Draw("hist,same");

  TLine* line_passCiC_cat3[4];
  for (int i=0; i<4; i++) {
    line_passCiC_cat3[i] = (TLine*)line[i]->Clone();
    line_passCiC_cat3[i]->SetY2(bdtout_cat3_tot->GetMaximum()*1.05);
    line_passCiC_cat3[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"!both EB, !both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC->SaveAs("categories_compareCiC_sig.png");



  TCanvas *c_bdtout_lowPt = new TCanvas("c_bdtout_lowPt","BDT output: di-photon pT<40 GeV");

  bdtout_lowPt_all_tot = (TH1*)bdtout_lowPt_cat0_tot->Clone();
  bdtout_lowPt_all_tot->Add(bdtout_lowPt_cat1_tot);
  bdtout_lowPt_all_tot->Add(bdtout_lowPt_cat2_tot);
  bdtout_lowPt_all_tot->Add(bdtout_lowPt_cat3_tot);

  bdtout_lowPt_all_tot->SetLineColor(1);
  bdtout_lowPt_cat0_tot->SetLineColor(2);
  bdtout_lowPt_cat1_tot->SetLineColor(3);
  bdtout_lowPt_cat2_tot->SetLineColor(4);
  bdtout_lowPt_cat3_tot->SetLineColor(6);

  bdtout_lowPt_all_tot->SetLineWidth(2);
  bdtout_lowPt_cat0_tot->SetLineWidth(2);
  bdtout_lowPt_cat1_tot->SetLineWidth(2);
  bdtout_lowPt_cat2_tot->SetLineWidth(2);
  bdtout_lowPt_cat3_tot->SetLineWidth(2);

  bdtout_lowPt_all_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_lowPt_all_tot->GetYaxis()->SetTitle("Events/0.02");
  bdtout_lowPt_all_tot->GetXaxis()->SetTitleSize(0.05);
  bdtout_lowPt_all_tot->GetXaxis()->SetLabelSize(0.05);
  bdtout_lowPt_all_tot->GetYaxis()->SetTitleSize(0.05);
  bdtout_lowPt_all_tot->GetYaxis()->SetLabelSize(0.05);

  max = bdtout_lowPt_all_tot->GetMaximum();
  TBox* box_lowPt = new TBox(-1.,0.,boundaries[0],max*1.05);
  box_lowPt->SetFillColor(38);
  box_lowPt->SetFillStyle(3002);

  bdtout_lowPt_all_tot->Draw("hist");
  box_lowPt->Draw("hist,same");
  bdtout_lowPt_all_tot->Draw("hist,same");
  bdtout_lowPt_cat0_tot->Draw("hist,same");
  bdtout_lowPt_cat1_tot->Draw("hist,same");
  bdtout_lowPt_cat2_tot->Draw("hist,same");
  bdtout_lowPt_cat3_tot->Draw("hist,same");

  TLegend *leg_lowPt = (TLegend*)leg->Clone();
  leg_lowPt->Clear();
  leg_lowPt->AddEntry(bdtout_all_tot,"All (p_{T}(#gamma#gamma) < 40 GeV)");
  leg_lowPt->AddEntry(bdtout_cat0_tot,"both EB, both R9>0.94");
  leg_lowPt->AddEntry(bdtout_cat1_tot,"both EB, !both R9>0.94");
  leg_lowPt->AddEntry(bdtout_cat2_tot,"!both EB, both R9>0.94");
  leg_lowPt->AddEntry(bdtout_cat3_tot,"!both EB, !both R9>0.94");
  leg_lowPt->Draw("hist");

  TLine* line_lowPt[4];
  for (int i=0; i<4; i++) {
    line_lowPt[i] = new TLine(boundaries[i],0.,boundaries[i],max*1.05);
    line_lowPt[i]->SetLineColor(4);
    line_lowPt[i]->SetLineWidth(2);
    line_lowPt[i]->SetLineStyle(9);
    line_lowPt[i]->Draw("hist");
  }

  gPad->RedrawAxis();

  c_bdtout_lowPt->SaveAs("categories_lowPt_sig.png");


  TCanvas *c_bdtout_compareCiC_lowPt = new TCanvas("c_bdtout_compareCiC_lowPt","BDT output: di-photon pT<40 GeV, pass CiC supertight",1000,650);
  c_bdtout_compareCiC_lowPt->Divide(2,2);

  bdtout_passCiC_lowPt_cat0_tot->SetFillColor(2);
  bdtout_passCiC_lowPt_cat1_tot->SetFillColor(3);
  bdtout_passCiC_lowPt_cat2_tot->SetFillColor(4);
  bdtout_passCiC_lowPt_cat3_tot->SetFillColor(6);

  bdtout_passCiC_lowPt_cat0_tot->SetFillStyle(3002);
  bdtout_passCiC_lowPt_cat1_tot->SetFillStyle(3002);
  bdtout_passCiC_lowPt_cat2_tot->SetFillStyle(3002);
  bdtout_passCiC_lowPt_cat3_tot->SetFillStyle(3002);

  bdtout_lowPt_cat0_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_lowPt_cat1_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_lowPt_cat2_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_lowPt_cat3_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_lowPt_cat0_tot->GetXaxis()->SetTitleSize(0.05);
  bdtout_lowPt_cat1_tot->GetXaxis()->SetTitleSize(0.05);
  bdtout_lowPt_cat2_tot->GetXaxis()->SetTitleSize(0.05);
  bdtout_lowPt_cat3_tot->GetXaxis()->SetTitleSize(0.05);

  c_bdtout_compareCiC_lowPt->cd(1);

  box_passCiC_lowPt_cat0 = (TBox*)box->Clone();
  box_passCiC_lowPt_cat0->SetY2(bdtout_lowPt_cat0_tot->GetMaximum()*1.05);

  bdtout_lowPt_cat0_tot->Draw("hist");
  box_passCiC_lowPt_cat0->Draw("hist,same");
  bdtout_lowPt_cat0_tot->Draw("hist,same");
  bdtout_passCiC_lowPt_cat0_tot->Draw("hist,same");

  TLine* line_passCiC_lowPt_cat0[4];
  for (int i=0; i<4; i++) {
    line_passCiC_lowPt_cat0[i] = (TLine*)line[i]->Clone();
    line_passCiC_lowPt_cat0[i]->SetY2(bdtout_lowPt_cat0_tot->GetMaximum()*1.05);
    line_passCiC_lowPt_cat0[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"both EB, both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC_lowPt->cd(2);

  box_passCiC_lowPt_cat1 = (TBox*)box->Clone();
  box_passCiC_lowPt_cat1->SetY2(bdtout_lowPt_cat1_tot->GetMaximum()*1.05);

  bdtout_lowPt_cat1_tot->Draw("hist");
  box_passCiC_lowPt_cat1->Draw("hist,same");
  bdtout_lowPt_cat1_tot->Draw("hist,same");
  bdtout_passCiC_lowPt_cat1_tot->Draw("hist,same");

  TLine* line_passCiC_lowPt_cat1[4];
  for (int i=0; i<4; i++) {
    line_passCiC_lowPt_cat1[i] = (TLine*)line[i]->Clone();
    line_passCiC_lowPt_cat1[i]->SetY2(bdtout_lowPt_cat1_tot->GetMaximum()*1.05);
    line_passCiC_lowPt_cat1[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"both EB, !both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC_lowPt->cd(3);

  box_passCiC_lowPt_cat2 = (TBox*)box->Clone();
  box_passCiC_lowPt_cat2->SetY2(bdtout_lowPt_cat2_tot->GetMaximum()*1.05);

  bdtout_lowPt_cat2_tot->Draw("hist");
  box_passCiC_lowPt_cat2->Draw("hist,same");
  bdtout_lowPt_cat2_tot->Draw("hist,same");
  bdtout_passCiC_lowPt_cat2_tot->Draw("hist,same");

  TLine* line_passCiC_lowPt_cat2[4];
  for (int i=0; i<4; i++) {
    line_passCiC_lowPt_cat2[i] = (TLine*)line[i]->Clone();
    line_passCiC_lowPt_cat2[i]->SetY2(bdtout_lowPt_cat2_tot->GetMaximum()*1.05);
    line_passCiC_lowPt_cat2[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"!both EB, both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC_lowPt->cd(4);

  box_passCiC_lowPt_cat3 = (TBox*)box->Clone();
  box_passCiC_lowPt_cat3->SetY2(bdtout_lowPt_cat3_tot->GetMaximum()*1.05);

  bdtout_lowPt_cat3_tot->Draw("hist");
  box_passCiC_lowPt_cat3->Draw("hist,same");
  bdtout_lowPt_cat3_tot->Draw("hist,same");
  bdtout_passCiC_lowPt_cat3_tot->Draw("hist,same");

  TLine* line_passCiC_lowPt_cat3[4];
  for (int i=0; i<4; i++) {
    line_passCiC_lowPt_cat3[i] = (TLine*)line[i]->Clone();
    line_passCiC_lowPt_cat3[i]->SetY2(bdtout_lowPt_cat3_tot->GetMaximum()*1.05);
    line_passCiC_lowPt_cat3[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"!both EB, !both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC_lowPt->SaveAs("categories_compareCiC_lowPt_sig.png");


  TCanvas *c_bdtout_highPt = new TCanvas("c_bdtout_highPt","BDT output: di-photon pT>40 GeV");

  bdtout_highPt_all_tot = (TH1*)bdtout_highPt_cat0_tot->Clone();
  bdtout_highPt_all_tot->Add(bdtout_highPt_cat1_tot);
  bdtout_highPt_all_tot->Add(bdtout_highPt_cat2_tot);
  bdtout_highPt_all_tot->Add(bdtout_highPt_cat3_tot);

  bdtout_highPt_all_tot->SetLineColor(1);
  bdtout_highPt_cat0_tot->SetLineColor(2);
  bdtout_highPt_cat1_tot->SetLineColor(3);
  bdtout_highPt_cat2_tot->SetLineColor(4);
  bdtout_highPt_cat3_tot->SetLineColor(6);

  bdtout_highPt_all_tot->SetLineWidth(2);
  bdtout_highPt_cat0_tot->SetLineWidth(2);
  bdtout_highPt_cat1_tot->SetLineWidth(2);
  bdtout_highPt_cat2_tot->SetLineWidth(2);
  bdtout_highPt_cat3_tot->SetLineWidth(2);

  bdtout_highPt_all_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_highPt_all_tot->GetYaxis()->SetTitle("Events/0.02");
  bdtout_highPt_all_tot->GetXaxis()->SetTitleSize(0.05);
  bdtout_highPt_all_tot->GetXaxis()->SetLabelSize(0.05);
  bdtout_highPt_all_tot->GetYaxis()->SetTitleSize(0.05);
  bdtout_highPt_all_tot->GetYaxis()->SetLabelSize(0.05);

  max = 1.2*bdtout_highPt_all_tot->GetMaximum();
  bdtout_highPt_all_tot->SetMaximum(max);

  TBox* box_highPt = new TBox(-1.,0.,boundaries[0],max);
  box_highPt->SetFillColor(38);
  box_highPt->SetFillStyle(3002);

  bdtout_highPt_all_tot->Draw("hist");
  box_highPt->Draw("hist,same");
  bdtout_highPt_all_tot->Draw("hist,same");
  bdtout_highPt_cat0_tot->Draw("hist,same");
  bdtout_highPt_cat1_tot->Draw("hist,same");
  bdtout_highPt_cat2_tot->Draw("hist,same");
  bdtout_highPt_cat3_tot->Draw("hist,same");

  TLegend *leg_highPt = (TLegend*)leg->Clone();
  leg_highPt->Clear();
  leg_highPt->AddEntry(bdtout_all_tot,"All (p_{T}(#gamma#gamma) > 40 GeV)");
  leg_highPt->AddEntry(bdtout_cat0_tot,"both EB, both R9>0.94");
  leg_highPt->AddEntry(bdtout_cat1_tot,"both EB, !both R9>0.94");
  leg_highPt->AddEntry(bdtout_cat2_tot,"!both EB, both R9>0.94");
  leg_highPt->AddEntry(bdtout_cat3_tot,"!both EB, !both R9>0.94");
  leg_highPt->Draw("hist");

  TLine* line_highPt[4];
  for (int i=0; i<4; i++) {
    line_highPt[i] = new TLine(boundaries[i],0.,boundaries[i],max);
    line_highPt[i]->SetLineColor(4);
    line_highPt[i]->SetLineWidth(2);
    line_highPt[i]->SetLineStyle(9);
    line_highPt[i]->Draw("hist");
  }

  gPad->RedrawAxis();

  c_bdtout_highPt->SaveAs("categories_highPt_sig.png");



  TCanvas *c_bdtout_compareCiC_highPt = new TCanvas("c_bdtout_compareCiC_highPt","BDT output: di-photon pT>40 GeV, pass CiC supertight",1000,650);
  c_bdtout_compareCiC_highPt->Divide(2,2);

  bdtout_passCiC_highPt_cat0_tot->SetFillColor(2);
  bdtout_passCiC_highPt_cat1_tot->SetFillColor(3);
  bdtout_passCiC_highPt_cat2_tot->SetFillColor(4);
  bdtout_passCiC_highPt_cat3_tot->SetFillColor(6);

  bdtout_passCiC_highPt_cat0_tot->SetFillStyle(3002);
  bdtout_passCiC_highPt_cat1_tot->SetFillStyle(3002);
  bdtout_passCiC_highPt_cat2_tot->SetFillStyle(3002);
  bdtout_passCiC_highPt_cat3_tot->SetFillStyle(3002);

  bdtout_highPt_cat0_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_highPt_cat1_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_highPt_cat2_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_highPt_cat3_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_highPt_cat0_tot->GetXaxis()->SetTitleSize(0.05);
  bdtout_highPt_cat1_tot->GetXaxis()->SetTitleSize(0.05);
  bdtout_highPt_cat2_tot->GetXaxis()->SetTitleSize(0.05);
  bdtout_highPt_cat3_tot->GetXaxis()->SetTitleSize(0.05);

  c_bdtout_compareCiC_highPt->cd(1);

  box_passCiC_highPt_cat0 = (TBox*)box->Clone();
  box_passCiC_highPt_cat0->SetY2(bdtout_highPt_cat0_tot->GetMaximum()*1.05);

  bdtout_highPt_cat0_tot->Draw("hist");
  box_passCiC_highPt_cat0->Draw("hist,same");
  bdtout_highPt_cat0_tot->Draw("hist,same");
  bdtout_passCiC_highPt_cat0_tot->Draw("hist,same");

  TLine* line_passCiC_highPt_cat0[4];
  for (int i=0; i<4; i++) {
    line_passCiC_highPt_cat0[i] = (TLine*)line[i]->Clone();
    line_passCiC_highPt_cat0[i]->SetY2(bdtout_highPt_cat0_tot->GetMaximum()*1.05);
    line_passCiC_highPt_cat0[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"both EB, both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC_highPt->cd(2);

  box_passCiC_highPt_cat1 = (TBox*)box->Clone();
  box_passCiC_highPt_cat1->SetY2(bdtout_highPt_cat1_tot->GetMaximum()*1.05);

  bdtout_highPt_cat1_tot->Draw("hist");
  box_passCiC_highPt_cat1->Draw("hist,same");
  bdtout_highPt_cat1_tot->Draw("hist,same");
  bdtout_passCiC_highPt_cat1_tot->Draw("hist,same");

  TLine* line_passCiC_highPt_cat1[4];
  for (int i=0; i<4; i++) {
    line_passCiC_highPt_cat1[i] = (TLine*)line[i]->Clone();
    line_passCiC_highPt_cat1[i]->SetY2(bdtout_highPt_cat1_tot->GetMaximum()*1.05);
    line_passCiC_highPt_cat1[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"both EB, !both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC_highPt->cd(3);

  box_passCiC_highPt_cat2 = (TBox*)box->Clone();
  box_passCiC_highPt_cat2->SetY2(bdtout_highPt_cat2_tot->GetMaximum()*1.05);

  bdtout_highPt_cat2_tot->Draw("hist");
  box_passCiC_highPt_cat2->Draw("hist,same");
  bdtout_highPt_cat2_tot->Draw("hist,same");
  bdtout_passCiC_highPt_cat2_tot->Draw("hist,same");

  TLine* line_passCiC_highPt_cat2[4];
  for (int i=0; i<4; i++) {
    line_passCiC_highPt_cat2[i] = (TLine*)line[i]->Clone();
    line_passCiC_highPt_cat2[i]->SetY2(bdtout_highPt_cat2_tot->GetMaximum()*1.05);
    line_passCiC_highPt_cat2[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"!both EB, both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC_highPt->cd(4);

  box_passCiC_highPt_cat3 = (TBox*)box->Clone();
  box_passCiC_highPt_cat3->SetY2(bdtout_highPt_cat3_tot->GetMaximum()*1.05);

  bdtout_highPt_cat3_tot->Draw("hist");
  box_passCiC_highPt_cat3->Draw("hist,same");
  bdtout_highPt_cat3_tot->Draw("hist,same");
  bdtout_passCiC_highPt_cat3_tot->Draw("hist,same");

  TLine* line_passCiC_highPt_cat3[4];
  for (int i=0; i<4; i++) {
    line_passCiC_highPt_cat3[i] = (TLine*)line[i]->Clone();
    line_passCiC_highPt_cat3[i]->SetY2(bdtout_highPt_cat3_tot->GetMaximum()*1.05);
    line_passCiC_highPt_cat3[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"!both EB, !both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC_highPt->SaveAs("categories_compareCiC_highPt_sig.png");


  TCanvas *c_ptVsBdtout = new TCanvas("c_ptVsBdtout","pT(#gamma#gamma) vs MVA output",1000,650);
  c_ptVsBdtout->Divide(2,2);

  pt_vs_bdtout_cat0_all = (TH2*)pt_vs_bdtout_cat0_ggh_m125_8TeV->Clone();
  pt_vs_bdtout_cat1_all = (TH2*)pt_vs_bdtout_cat1_ggh_m125_8TeV->Clone();
  pt_vs_bdtout_cat2_all = (TH2*)pt_vs_bdtout_cat2_ggh_m125_8TeV->Clone();
  pt_vs_bdtout_cat3_all = (TH2*)pt_vs_bdtout_cat3_ggh_m125_8TeV->Clone();
  pt_vs_bdtout_cat4_all = (TH2*)pt_vs_bdtout_cat4_ggh_m125_8TeV->Clone();

  pt_vs_bdtout_cat0_all->Add(pt_vs_bdtout_cat0_vbf_m125_8TeV);
  pt_vs_bdtout_cat1_all->Add(pt_vs_bdtout_cat1_vbf_m125_8TeV);
  pt_vs_bdtout_cat2_all->Add(pt_vs_bdtout_cat2_vbf_m125_8TeV);
  pt_vs_bdtout_cat3_all->Add(pt_vs_bdtout_cat3_vbf_m125_8TeV);
  pt_vs_bdtout_cat4_all->Add(pt_vs_bdtout_cat4_vbf_m125_8TeV);

  pt_vs_bdtout_cat0_all->Add(pt_vs_bdtout_cat0_wzh_m125_8TeV);
  pt_vs_bdtout_cat1_all->Add(pt_vs_bdtout_cat1_wzh_m125_8TeV);
  pt_vs_bdtout_cat2_all->Add(pt_vs_bdtout_cat2_wzh_m125_8TeV);
  pt_vs_bdtout_cat3_all->Add(pt_vs_bdtout_cat3_wzh_m125_8TeV);
  pt_vs_bdtout_cat4_all->Add(pt_vs_bdtout_cat4_wzh_m125_8TeV);

  pt_vs_bdtout_cat0_all->Add(pt_vs_bdtout_cat0_tth_m125_8TeV);
  pt_vs_bdtout_cat1_all->Add(pt_vs_bdtout_cat1_tth_m125_8TeV);
  pt_vs_bdtout_cat2_all->Add(pt_vs_bdtout_cat2_tth_m125_8TeV);
  pt_vs_bdtout_cat3_all->Add(pt_vs_bdtout_cat3_tth_m125_8TeV);
  pt_vs_bdtout_cat4_all->Add(pt_vs_bdtout_cat4_tth_m125_8TeV);

  pt_vs_bdtout_cat0_all->GetXaxis()->SetTitle("di-photon MVA output");
  pt_vs_bdtout_cat1_all->GetXaxis()->SetTitle("di-photon MVA output");
  pt_vs_bdtout_cat2_all->GetXaxis()->SetTitle("di-photon MVA output");
  pt_vs_bdtout_cat3_all->GetXaxis()->SetTitle("di-photon MVA output");
  pt_vs_bdtout_cat0_all->GetXaxis()->SetTitleSize(0.05);
  pt_vs_bdtout_cat1_all->GetXaxis()->SetTitleSize(0.05);
  pt_vs_bdtout_cat2_all->GetXaxis()->SetTitleSize(0.05);
  pt_vs_bdtout_cat3_all->GetXaxis()->SetTitleSize(0.05);
  pt_vs_bdtout_cat0_all->GetYaxis()->SetTitle("di-photon p_{T} (GeV)");
  pt_vs_bdtout_cat1_all->GetYaxis()->SetTitle("di-photon p_{T} (GeV)");
  pt_vs_bdtout_cat2_all->GetYaxis()->SetTitle("di-photon p_{T} (GeV)");
  pt_vs_bdtout_cat3_all->GetYaxis()->SetTitle("di-photon p_{T} (GeV)");
  pt_vs_bdtout_cat0_all->GetYaxis()->SetTitleSize(0.05);
  pt_vs_bdtout_cat1_all->GetYaxis()->SetTitleSize(0.05);
  pt_vs_bdtout_cat2_all->GetYaxis()->SetTitleSize(0.05);
  pt_vs_bdtout_cat3_all->GetYaxis()->SetTitleSize(0.05);

  c_ptVsBdtout->cd(1);
  pt_vs_bdtout_cat0_all->Draw("colz");
  box_ptVsBdtout = (TBox*)box->Clone();
  box_ptVsBdtout->SetY2(200.);
  box_ptVsBdtout->Draw("hist");
  pt_vs_bdtout_cat0_all->Draw("colz,same");
  TLine* line_ptVsBdtout[4];
  for (int i=0; i<4; i++) {
    line_ptVsBdtout[i] = (TLine*)line[i]->Clone();
    line_ptVsBdtout[i]->SetY2(200.);
    line_ptVsBdtout[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"both EB, both R9>0.94");
  gPad->RedrawAxis();
  c_ptVsBdtout->cd(2);
  pt_vs_bdtout_cat1_all->Draw("colz");
  box_ptVsBdtout->Draw("hist");
  pt_vs_bdtout_cat1_all->Draw("colz,same");
  for (int i=0; i<4; i++) line_ptVsBdtout[i]->Draw("hist");
  text->DrawText(0.15,0.75,"both EB, !both R9>0.94");
  gPad->RedrawAxis();
  c_ptVsBdtout->cd(3);
  pt_vs_bdtout_cat2_all->Draw("colz");
  box_ptVsBdtout->Draw("hist");
  pt_vs_bdtout_cat2_all->Draw("colz,same");
  for (int i=0; i<4; i++) line_ptVsBdtout[i]->Draw("hist");
  text->DrawText(0.15,0.75,"!both EB, both R9>0.94");
  gPad->RedrawAxis();
  c_ptVsBdtout->cd(4);
  pt_vs_bdtout_cat3_all->Draw("colz");
  box_ptVsBdtout->Draw("hist");
  pt_vs_bdtout_cat3_all->Draw("colz,same");
  for (int i=0; i<4; i++) line_ptVsBdtout[i]->Draw("hist");
  text->DrawText(0.15,0.75,"!both EB, !both R9>0.94");
  gPad->RedrawAxis();

  c_ptVsBdtout->SaveAs("ptVsBdtout_sig.png");


  TCanvas *c_2D = new TCanvas("c_2D","min(R9) vs max(eta), sublead eta vs lead eta",1250,500);
  c_2D->Divide(4,2);

  minR9_vs_maxEta_cat2_all = (TH2*)minR9_vs_maxEta_cat2_ggh_m125_8TeV->Clone();
  minR9_vs_maxEta_cat3_all = (TH2*)minR9_vs_maxEta_cat3_ggh_m125_8TeV->Clone();
  minR9_vs_maxEta_cat4_all = (TH2*)minR9_vs_maxEta_cat4_ggh_m125_8TeV->Clone();
  minR9_vs_maxEta_cat5_all = (TH2*)minR9_vs_maxEta_cat5_ggh_m125_8TeV->Clone();
  minR9_vs_maxEta_cat6_all = (TH2*)minR9_vs_maxEta_cat6_ggh_m125_8TeV->Clone();

  minR9_vs_maxEta_cat2_all->Add(minR9_vs_maxEta_cat2_vbf_m125_8TeV);
  minR9_vs_maxEta_cat3_all->Add(minR9_vs_maxEta_cat3_vbf_m125_8TeV);
  minR9_vs_maxEta_cat4_all->Add(minR9_vs_maxEta_cat4_vbf_m125_8TeV);
  minR9_vs_maxEta_cat5_all->Add(minR9_vs_maxEta_cat5_vbf_m125_8TeV);
  minR9_vs_maxEta_cat6_all->Add(minR9_vs_maxEta_cat6_vbf_m125_8TeV);

  minR9_vs_maxEta_cat2_all->Add(minR9_vs_maxEta_cat2_wzh_m125_8TeV);
  minR9_vs_maxEta_cat3_all->Add(minR9_vs_maxEta_cat3_wzh_m125_8TeV);
  minR9_vs_maxEta_cat4_all->Add(minR9_vs_maxEta_cat4_wzh_m125_8TeV);
  minR9_vs_maxEta_cat5_all->Add(minR9_vs_maxEta_cat5_wzh_m125_8TeV);
  minR9_vs_maxEta_cat6_all->Add(minR9_vs_maxEta_cat6_wzh_m125_8TeV);

  minR9_vs_maxEta_cat2_all->Add(minR9_vs_maxEta_cat2_tth_m125_8TeV);
  minR9_vs_maxEta_cat3_all->Add(minR9_vs_maxEta_cat3_tth_m125_8TeV);
  minR9_vs_maxEta_cat4_all->Add(minR9_vs_maxEta_cat4_tth_m125_8TeV);
  minR9_vs_maxEta_cat5_all->Add(minR9_vs_maxEta_cat5_tth_m125_8TeV);
  minR9_vs_maxEta_cat6_all->Add(minR9_vs_maxEta_cat6_tth_m125_8TeV);

  eta2_vs_eta1_cat2_all = (TH2*)eta2_vs_eta1_cat2_ggh_m125_8TeV->Clone();
  eta2_vs_eta1_cat3_all = (TH2*)eta2_vs_eta1_cat3_ggh_m125_8TeV->Clone();
  eta2_vs_eta1_cat4_all = (TH2*)eta2_vs_eta1_cat4_ggh_m125_8TeV->Clone();
  eta2_vs_eta1_cat5_all = (TH2*)eta2_vs_eta1_cat5_ggh_m125_8TeV->Clone();
  eta2_vs_eta1_cat6_all = (TH2*)eta2_vs_eta1_cat6_ggh_m125_8TeV->Clone();

  eta2_vs_eta1_cat2_all->Add(eta2_vs_eta1_cat2_vbf_m125_8TeV);
  eta2_vs_eta1_cat3_all->Add(eta2_vs_eta1_cat3_vbf_m125_8TeV);
  eta2_vs_eta1_cat4_all->Add(eta2_vs_eta1_cat4_vbf_m125_8TeV);
  eta2_vs_eta1_cat5_all->Add(eta2_vs_eta1_cat5_vbf_m125_8TeV);
  eta2_vs_eta1_cat6_all->Add(eta2_vs_eta1_cat6_vbf_m125_8TeV);

  eta2_vs_eta1_cat2_all->Add(eta2_vs_eta1_cat2_wzh_m125_8TeV);
  eta2_vs_eta1_cat3_all->Add(eta2_vs_eta1_cat3_wzh_m125_8TeV);
  eta2_vs_eta1_cat4_all->Add(eta2_vs_eta1_cat4_wzh_m125_8TeV);
  eta2_vs_eta1_cat5_all->Add(eta2_vs_eta1_cat5_wzh_m125_8TeV);
  eta2_vs_eta1_cat6_all->Add(eta2_vs_eta1_cat6_wzh_m125_8TeV);

  eta2_vs_eta1_cat2_all->Add(eta2_vs_eta1_cat2_tth_m125_8TeV);
  eta2_vs_eta1_cat3_all->Add(eta2_vs_eta1_cat3_tth_m125_8TeV);
  eta2_vs_eta1_cat4_all->Add(eta2_vs_eta1_cat4_tth_m125_8TeV);
  eta2_vs_eta1_cat5_all->Add(eta2_vs_eta1_cat5_tth_m125_8TeV);
  eta2_vs_eta1_cat6_all->Add(eta2_vs_eta1_cat6_tth_m125_8TeV);

  minR9_vs_maxEta_cat2_all->GetXaxis()->SetTitle("max(#eta)");
  minR9_vs_maxEta_cat3_all->GetXaxis()->SetTitle("max(#eta)");
  minR9_vs_maxEta_cat4_all->GetXaxis()->SetTitle("max(#eta)");
  minR9_vs_maxEta_cat5_all->GetXaxis()->SetTitle("max(#eta)");
  minR9_vs_maxEta_cat6_all->GetXaxis()->SetTitle("max(#eta)");
  minR9_vs_maxEta_cat2_all->GetYaxis()->SetTitle("min(R9)");
  minR9_vs_maxEta_cat3_all->GetYaxis()->SetTitle("min(R9)");
  minR9_vs_maxEta_cat4_all->GetYaxis()->SetTitle("min(R9)");
  minR9_vs_maxEta_cat5_all->GetYaxis()->SetTitle("min(R9)");
  minR9_vs_maxEta_cat6_all->GetYaxis()->SetTitle("min(R9)");

  minR9_vs_maxEta_cat2_all->GetXaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat3_all->GetXaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat4_all->GetXaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat5_all->GetXaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat6_all->GetXaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat2_all->GetYaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat3_all->GetYaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat4_all->GetYaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat5_all->GetYaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat6_all->GetYaxis()->SetTitleSize(0.05);

  line_minr9 = new TLine(0.,0.94,2.5,0.94);
  line_maxeta = new TLine(1.479,0.5,1.479,1.);
  //line_minr9->SetLineColor(4);
  line_minr9->SetLineWidth(2);
  line_minr9->SetLineStyle(9);
  //line_maxeta->SetLineColor(4);
  line_maxeta->SetLineWidth(2);
  line_maxeta->SetLineStyle(9);

  c_2D->cd(1);
  minR9_vs_maxEta_cat2_all->Draw("colz");
  line_minr9->Draw("hist");
  line_maxeta->Draw("hist");
  c_2D->cd(2);
  minR9_vs_maxEta_cat3_all->Draw("colz");
  line_minr9->Draw("hist");
  line_maxeta->Draw("hist");
  c_2D->cd(3);
  minR9_vs_maxEta_cat4_all->Draw("colz");
  line_minr9->Draw("hist");
  line_maxeta->Draw("hist");
  c_2D->cd(4);
  minR9_vs_maxEta_cat5_all->Draw("colz");
  line_minr9->Draw("hist");
  line_maxeta->Draw("hist");
  //c_2D->cd(5);
  //minR9_vs_maxEta_cat6_all->Draw("colz");
  //line_minr9->Draw("hist");
  //line_maxeta->Draw("hist");

  eta2_vs_eta1_cat2_all->GetYaxis()->SetTitle("sublead #eta");
  eta2_vs_eta1_cat3_all->GetYaxis()->SetTitle("sublead #eta");
  eta2_vs_eta1_cat4_all->GetYaxis()->SetTitle("sublead #eta");
  eta2_vs_eta1_cat5_all->GetYaxis()->SetTitle("sublead #eta");
  eta2_vs_eta1_cat6_all->GetYaxis()->SetTitle("sublead #eta");
  eta2_vs_eta1_cat2_all->GetXaxis()->SetTitle("lead #eta");
  eta2_vs_eta1_cat3_all->GetXaxis()->SetTitle("lead #eta");
  eta2_vs_eta1_cat4_all->GetXaxis()->SetTitle("lead #eta");
  eta2_vs_eta1_cat5_all->GetXaxis()->SetTitle("lead #eta");
  eta2_vs_eta1_cat6_all->GetXaxis()->SetTitle("lead #eta");

  eta2_vs_eta1_cat2_all->GetXaxis()->SetTitleSize(0.05);
  eta2_vs_eta1_cat3_all->GetXaxis()->SetTitleSize(0.05);
  eta2_vs_eta1_cat4_all->GetXaxis()->SetTitleSize(0.05);
  eta2_vs_eta1_cat5_all->GetXaxis()->SetTitleSize(0.05);
  eta2_vs_eta1_cat6_all->GetXaxis()->SetTitleSize(0.05);
  eta2_vs_eta1_cat2_all->GetYaxis()->SetTitleSize(0.05);
  eta2_vs_eta1_cat3_all->GetYaxis()->SetTitleSize(0.05);
  eta2_vs_eta1_cat4_all->GetYaxis()->SetTitleSize(0.05);
  eta2_vs_eta1_cat5_all->GetYaxis()->SetTitleSize(0.05);
  eta2_vs_eta1_cat6_all->GetYaxis()->SetTitleSize(0.05);

  c_2D->cd(5);
  eta2_vs_eta1_cat2_all->Draw("colz");
  c_2D->cd(6);
  eta2_vs_eta1_cat3_all->Draw("colz");
  c_2D->cd(7);
  eta2_vs_eta1_cat4_all->Draw("colz");
  c_2D->cd(8);
  eta2_vs_eta1_cat5_all->Draw("colz");
  //c_2D->cd(10);
  //eta2_vs_eta1_cat6_all->Draw("colz");

  c_2D->SaveAs("categories_2D_sig.png");

  /*
  TCanvas *c_2D_v2 = new TCanvas("c_2D_v2","min(R9) vs max(eta), |lead eta| vs |deltaEeta|",1500,500);
  c_2D_v2->Divide(5,2);

  minR9_vs_maxEta_cat2_tot->GetXaxis()->SetTitle("max(#eta)");
  minR9_vs_maxEta_cat3_tot->GetXaxis()->SetTitle("max(#eta)");
  minR9_vs_maxEta_cat4_tot->GetXaxis()->SetTitle("max(#eta)");
  minR9_vs_maxEta_cat5_tot->GetXaxis()->SetTitle("max(#eta)");
  minR9_vs_maxEta_cat6_tot->GetXaxis()->SetTitle("max(#eta)");
  minR9_vs_maxEta_cat2_tot->GetYaxis()->SetTitle("min(R9)");
  minR9_vs_maxEta_cat3_tot->GetYaxis()->SetTitle("min(R9)");
  minR9_vs_maxEta_cat4_tot->GetYaxis()->SetTitle("min(R9)");
  minR9_vs_maxEta_cat5_tot->GetYaxis()->SetTitle("min(R9)");
  minR9_vs_maxEta_cat6_tot->GetYaxis()->SetTitle("min(R9)");

  minR9_vs_maxEta_cat2_tot->GetXaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat3_tot->GetXaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat4_tot->GetXaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat5_tot->GetXaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat6_tot->GetXaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat2_tot->GetYaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat3_tot->GetYaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat4_tot->GetYaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat5_tot->GetYaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat6_tot->GetYaxis()->SetTitleSize(0.05);

  c_2D_v2->cd(1);
  minR9_vs_maxEta_cat2_tot->Draw("colz");
  line_minr9->Draw("hist");
  line_maxeta->Draw("hist");
  c_2D_v2->cd(2);
  minR9_vs_maxEta_cat3_tot->Draw("colz");
  line_minr9->Draw("hist");
  line_maxeta->Draw("hist");
  c_2D_v2->cd(3);
  minR9_vs_maxEta_cat4_tot->Draw("colz");
  line_minr9->Draw("hist");
  line_maxeta->Draw("hist");
  c_2D_v2->cd(4);
  minR9_vs_maxEta_cat5_tot->Draw("colz");
  line_minr9->Draw("hist");
  line_maxeta->Draw("hist");
  c_2D_v2->cd(5);
  minR9_vs_maxEta_cat6_tot->Draw("colz");
  line_minr9->Draw("hist");
  line_maxeta->Draw("hist");

  eta1_vs_deltaEta_cat2_tot->GetYaxis()->SetTitle("|lead #eta|");
  eta1_vs_deltaEta_cat3_tot->GetYaxis()->SetTitle("|lead #eta|");
  eta1_vs_deltaEta_cat4_tot->GetYaxis()->SetTitle("|lead #eta|");
  eta1_vs_deltaEta_cat5_tot->GetYaxis()->SetTitle("|lead #eta|");
  eta1_vs_deltaEta_cat6_tot->GetYaxis()->SetTitle("|lead #eta|");
  eta1_vs_deltaEta_cat2_tot->GetXaxis()->SetTitle("|#Delta#eta|");
  eta1_vs_deltaEta_cat3_tot->GetXaxis()->SetTitle("|#Delta#eta|");
  eta1_vs_deltaEta_cat4_tot->GetXaxis()->SetTitle("|#Delta#eta|");
  eta1_vs_deltaEta_cat5_tot->GetXaxis()->SetTitle("|#Delta#eta|");
  eta1_vs_deltaEta_cat6_tot->GetXaxis()->SetTitle("|#Delta#eta|");

  eta1_vs_deltaEta_cat2_tot->GetXaxis()->SetTitleSize(0.05);
  eta1_vs_deltaEta_cat3_tot->GetXaxis()->SetTitleSize(0.05);
  eta1_vs_deltaEta_cat4_tot->GetXaxis()->SetTitleSize(0.05);
  eta1_vs_deltaEta_cat5_tot->GetXaxis()->SetTitleSize(0.05);
  eta1_vs_deltaEta_cat6_tot->GetXaxis()->SetTitleSize(0.05);
  eta1_vs_deltaEta_cat2_tot->GetYaxis()->SetTitleSize(0.05);
  eta1_vs_deltaEta_cat3_tot->GetYaxis()->SetTitleSize(0.05);
  eta1_vs_deltaEta_cat4_tot->GetYaxis()->SetTitleSize(0.05);
  eta1_vs_deltaEta_cat5_tot->GetYaxis()->SetTitleSize(0.05);
  eta1_vs_deltaEta_cat6_tot->GetYaxis()->SetTitleSize(0.05);

  c_2D_v2->cd(6);
  eta1_vs_deltaEta_cat2_tot->Draw("colz");
  c_2D_v2->cd(7);
  eta1_vs_deltaEta_cat3_tot->Draw("colz");
  c_2D_v2->cd(8);
  eta1_vs_deltaEta_cat4_tot->Draw("colz");
  c_2D_v2->cd(9);
  eta1_vs_deltaEta_cat5_tot->Draw("colz");
  c_2D_v2->cd(10);
  eta1_vs_deltaEta_cat6_tot->Draw("colz");

  c_2D_v2->SaveAs("categories_2D_v2_sig.png");
  */
}
예제 #4
0
void NuclearModificationY(){

  gROOT->SetStyle("Plain");
  gStyle->SetOptTitle(0);
  gStyle->SetOptStat(0);
/*
  gStyle->SetPadRightMargin(0.010);//###0.020
  gStyle->SetPadLeftMargin(0.165);
  gStyle->SetPadTopMargin(0.075);
  gStyle->SetPadBottomMargin(0.145);
*/

    
  TFile*filePPReference=new TFile(Form("../../../fonll/output%sY.root",particle.Data()));  
  //TFile*filePPReference=new TFile(Form("../../fonll/output%sY.root",particle.Data()));  
  TGraphAsymmErrors*gaeBplusReference=(TGraphAsymmErrors*)filePPReference->Get(Form("gaeSigmaDecay%s",particle.Data()));
  gaeBplusReference->SetName(Form("gae%sReference",particle.Data()));
  
  TFile*filepPb=new TFile(Form("../Results%s_y/Sigma%s.root",particle.Data(),particle.Data()));
  TH1F*hSigmapPbStat=(TH1F*)filepPb->Get("hPtSigma");  
  
  double scalingfactor=1e-6;
  double yvalue,xvalue,yerrorhigh,yerrorlow;
  
  for (int i=0;i<nbins;i++){
    hSigmapPbStat->SetBinContent(i+1,scalingfactor*hSigmapPbStat->GetBinContent(i+1));
    hSigmapPbStat->SetBinError(i+1,scalingfactor*hSigmapPbStat->GetBinError(i+1));
    
    yvalue=-1.;
    xvalue=-1.;
    yerrorhigh=-1.;
    yerrorlow=-1.;
    
    gaeBplusReference->GetPoint(i,xvalue,yvalue);
    yerrorhigh=gaeBplusReference->GetEYhigh()[i];
    yerrorlow=gaeBplusReference->GetEYlow()[i];
  
    gaeBplusReference->SetPoint(i,xvalue,yvalue*scalingfactor);
    gaeBplusReference->SetPointEYhigh(i,yerrorhigh*scalingfactor);
    gaeBplusReference->SetPointEYlow(i,yerrorlow*scalingfactor);

  } 

  
  
  for (int i=0;i<nbins;i++){
    hSigmapPbStat->SetBinContent(i+1,(1./tagandprobcorrection[i])*(hSigmapPbStat->GetBinContent(i+1)));
    hSigmapPbStat->SetBinError(i+1,(1./tagandprobcorrection[i])*(hSigmapPbStat->GetBinError(i+1)));
  } 

  
  Double_t yRefPP[nbins];                        //value y reference
  Double_t xRefPP[nbins];                        //value x reference
  Double_t yPPsystFONLLhigh[nbins];              //y err syst FONLL high
  Double_t yPPsystFONLLlow[nbins];               //y err syst FONLL low
  Double_t yPercPPsystFONLLhigh[nbins];          //y percentuale err syst FONLL high
  Double_t yPercPPsystFONLLlow[nbins];           //y percentuale err syst FONLL low
    
  Double_t ySigmapPb[nbins];                     //value y pPb 
  Double_t xSigmapPb[nbins];                     //value x pPb
  Double_t ySigmapPbStat[nbins];                 //y err stat pPb
  Double_t yPercSigmapPbStat[nbins];             //y err stat pPb
  
  Double_t yFONLL[nbins];                        //1
  Double_t yRpA[nbins];                          //value y RpA 
  Double_t yRpAStat[nbins];                      //y err stat RpA 
  Double_t yRpAsystFONLLhigh[nbins];             //y err syst FONLL RpA high
  Double_t yRpAsystFONLLlow[nbins];              //y err syst FONLL RpA lzow
  Double_t yPercRpAsystFONLLhigh[nbins];         //y percentuale err syst FONLL RpA high
  Double_t yPercRpAsystFONLLlow[nbins];          //y percentuale err syst FONLL RpA low
    
  Double_t ySigmapPbSystTotHigh[nbins];              //y percentuale err syst pPb TOT
  Double_t ySigmapPbSystTotLow[nbins];              //y percentuale err syst pPb TOT

  Double_t yPercRpPbSystTotHigh[nbins];          //y percentuale err syst RpPb TOT
  Double_t yPercRpPbSystTotLow[nbins];          //y percentuale err syst RpPb TOT
  
  Double_t yRpPbSystTotHigh[nbins];              //y percentuale err syst RpPb TOT
  Double_t yRpPbSystTotLow[nbins];              //y percentuale err syst RpPb TOT

  Double_t yRFB[nbinsRFB];
  Double_t yRFBStat[nbinsRFB];
  Double_t yRFBSystTotHigh[nbinsRFB];
  Double_t yRFBSystTotLow[nbinsRFB];

  double x,y;

  for (Int_t i=0;i<nbins;i++) {
    gaeBplusReference->GetPoint(i,xRefPP[i],yRefPP[i]);
    yPPsystFONLLhigh[i]=gaeBplusReference->GetEYhigh()[i];
    yPPsystFONLLlow[i]=gaeBplusReference->GetEYlow()[i];
    yPercPPsystFONLLhigh[i]=yPPsystFONLLhigh[i]/yRefPP[i];
    yPercPPsystFONLLlow[i]=yPPsystFONLLlow[i]/yRefPP[i];
  }
  
  for(Int_t i=0;i<nbins;i++) {
    ySigmapPb[i]=hSigmapPbStat->GetBinContent(i+1);
    ySigmapPbStat[i]=hSigmapPbStat->GetBinError(i+1);
    yPercSigmapPbStat[i]=ySigmapPbStat[i]/ySigmapPb[i];
    ySigmapPbSystTotHigh[i]=yPercSigmapPbSystTotHigh[i]*ySigmapPb[i];
    ySigmapPbSystTotLow[i]=yPercSigmapPbSystTotLow[i]*ySigmapPb[i];
  }
  
  for(Int_t i=0;i<nbins;i++) {
    yRpA[i]=ySigmapPb[i]/yRefPP[i];
    yRpAStat[i]=ySigmapPbStat[i]/yRefPP[i];
    yFONLL[i]=yRpA[i];
    yPercRpAsystFONLLhigh[i]=(yPercPPsystFONLLlow[i]/(1-yPercPPsystFONLLlow[i]));
    yPercRpAsystFONLLlow[i]=(yPercPPsystFONLLhigh[i]/(1+yPercPPsystFONLLhigh[i]));
    yRpAsystFONLLhigh[i]=yPercRpAsystFONLLhigh[i]*yRpA[i];
    yRpAsystFONLLlow[i]=yPercRpAsystFONLLlow[i]*yRpA[i];
    yRpPbSystTotHigh[i]=yPercSigmapPbSystTotHigh[i]*yRpA[i];
    yRpPbSystTotLow[i]=yPercSigmapPbSystTotLow[i]*yRpA[i];

        std::cout << i << " , " << xbins[i] << " , " << ySigmapPb[i] << " , sta: " << ySigmapPbStat[i] << " , syslow: " << ySigmapPbSystTotLow[i] << " ,syshigh: " << ySigmapPbSystTotHigh[i] << std::endl;
std::cout << "FONLL: " << yRefPP[i] << " - " << yPPsystFONLLlow[i] << " + " << yPPsystFONLLhigh[i] << std::endl;
        std::cout << i << " ####### " << xbins[i] << " , " << yRpA[i] << " , sta: " << yRpAStat[i] << " , syslow: " << yRpPbSystTotLow[i] << " ,syshigh: " << yRpPbSystTotHigh[i] << " ,FONLLlow: " << yRpAsystFONLLlow[i] << " , FONLLhigh: " << yRpAsystFONLLhigh[i] << std::endl;
  }

  //RFB stuff
  //central value
  yRFB[0] =  ySigmapPb[3]/ySigmapPb[2];
  yRFB[1] =  ySigmapPb[4]/ySigmapPb[1];
  //Stat.
  yRFBStat[0] =  yRFB[0]*sqrt(pow(ySigmapPbStat[2]/ySigmapPb[2],2)+pow(ySigmapPbStat[3]/ySigmapPb[3],2));
  yRFBStat[1] =  yRFB[1]*sqrt(pow(ySigmapPbStat[4]/ySigmapPb[4],2)+pow(ySigmapPbStat[1]/ySigmapPb[1],2));
  //Syst.

  yRFBSystTotHigh[0] = yRFB[0]*yRFBSystTotHighRel[0];
  yRFBSystTotLow[0] = yRFB[0]*yRFBSystTotLowRel[0];
  yRFBSystTotHigh[1] = yRFB[1]*yRFBSystTotHighRel[1];
  yRFBSystTotLow[1] = yRFB[1]*yRFBSystTotLowRel[1];
    
  TGraphAsymmErrors *gSigmasyst = new TGraphAsymmErrors(nbins,xbins,ySigmapPb,exl2,exl2,ySigmapPbSystTotLow,ySigmapPbSystTotHigh);
  //###TGraphAsymmErrors *gSigmasyst = new TGraphAsymmErrors(nbins,xbins,ySigmapPb,exl,exl,ySigmapPbSystTotLow,ySigmapPbSystTotHigh);

  gSigmasyst->SetTitle("Sigma syst uncertainty from pPb");
  gSigmasyst->SetMarkerColor(1);
  gSigmasyst->SetLineColor(1);
  gSigmasyst->SetLineWidth(3);   
  gSigmasyst->SetMarkerStyle(21);
  gSigmasyst->SetMarkerColor(1);
  gSigmasyst->SetFillColor(kYellow-7);//5
  gSigmasyst->SetFillStyle(1001);

  TGraphAsymmErrors*gSigmasyst2=(TGraphAsymmErrors*)gSigmasyst->Clone();
  gSigmasyst2->SetMarkerColor(1);
  gSigmasyst2->SetMarkerStyle(25);  
  gSigmasyst2->SetFillColor(0);
  gSigmasyst2->SetFillStyle(0);
  gSigmasyst2->SetLineColor(1);//5
  gSigmasyst2->SetLineStyle(1);
  gSigmasyst2->SetLineWidth(3);


  //###TGraphAsymmErrors *gSigmastat = new TGraphAsymmErrors(nbins,xbins,ySigmapPb,exl,exl,ySigmapPbStat,ySigmapPbStat);
  TGraphAsymmErrors *gSigmastat = new TGraphAsymmErrors(nbins,xbins,ySigmapPb,exl0,exl0,ySigmapPbStat,ySigmapPbStat);


  gSigmastat->SetTitle("Sigma stat uncertainty from pPb");
  gSigmastat->SetMarkerColor(1);
  gSigmastat->SetLineColor(1);
  gSigmastat->SetLineWidth(3);   
  gSigmastat->SetMarkerStyle(21);
  gSigmastat->SetMarkerColor(1);
  
  gSigmastat->SetFillColor(0);
  gSigmastat->SetFillStyle(0);


  //###TCanvas *canvasSigma=new TCanvas("canvasSigma","canvasSigma",600,500);   
  TCanvas *canvasSigma=new TCanvas("canvasSigma","canvasSigma",500,500);   
  canvasSigma->cd();
  canvasSigma->Range(-1.989924,-0.2917772,25.49622,2.212202);
  canvasSigma->SetFillColor(0);
  canvasSigma->SetBorderMode(0);
  canvasSigma->SetBorderSize(2);
  canvasSigma->SetLeftMargin(0.200);
  canvasSigma->SetRightMargin(0.025);
  canvasSigma->SetTopMargin(0.080);
  canvasSigma->SetBottomMargin(0.150);
  canvasSigma->SetFrameBorderMode(0);
  
  TH2F* hempty=new TH2F("hempty","",10,-3.5,2.5,10,0,650.);  
  hempty->GetXaxis()->SetTitle("y_{CM}");
  hempty->GetXaxis()->CenterTitle();
  hempty->GetYaxis()->CenterTitle();
  //###hempty->GetYaxis()->SetTitle("d#sigma / dy_{CM}(#mub GeV^{-1}c)");
  hempty->GetYaxis()->SetTitle("d#sigma / dy_{CM}(#mub)");
  hempty->GetXaxis()->SetTitleOffset(0.90);
  hempty->GetYaxis()->SetTitleOffset(1.34);
  hempty->GetXaxis()->SetTitleSize(0.070);//###0.045
  hempty->GetYaxis()->SetTitleSize(0.070);//###0.045
  hempty->GetXaxis()->SetTitleFont(42);
  hempty->GetYaxis()->SetTitleFont(42);
  hempty->GetXaxis()->SetLabelFont(42);
  hempty->GetYaxis()->SetLabelFont(42);
  hempty->GetXaxis()->SetLabelSize(0.060);//###0.037
  hempty->GetYaxis()->SetLabelSize(0.060);//###0.037  
  hempty->SetMaximum(2);
  hempty->SetMinimum(0.);
  hempty->Draw();
    
  // Histogram style
  TH1D* hBplusReference = new TH1D("hBplusReference","",nbins,xhbins);
  TH1D* hBplusReferenceEYhigh = new TH1D("hBplusReferenceEYhigh","",nbins,xhbins);
  TH1D* hBplusReferenceEYlow = new TH1D("hBplusReferenceEYlow","",nbins,xhbins);

  for (int i=0;i<nbins;i++){
        double xgae,ygae;
        gaeBplusReference->GetPoint(i,xgae,ygae);
        hBplusReference->SetBinContent(i+1,ygae);
        hBplusReferenceEYhigh->SetBinContent(i+1,ygae+gaeBplusReference->GetEYhigh()[i]);
        hBplusReferenceEYlow->SetBinContent(i+1,ygae-gaeBplusReference->GetEYlow()[i]);
}

  //hBplusReference->SetMarkerColor(1);
  //hBplusReference->SetMarkerStyle(25);  
  //hBplusReference->SetFillColor(kYellow-7);//5
  //hBplusReference->SetFillStyle(1001);
  hBplusReference->SetLineColor(kAzure-3);
  hBplusReference->SetLineWidth(3);
  hBplusReferenceEYhigh->SetLineColor(kAzure-3);
  hBplusReferenceEYhigh->SetLineWidth(3);
  hBplusReferenceEYhigh->SetLineStyle(2);
  hBplusReferenceEYlow->SetLineColor(kAzure-3);
  hBplusReferenceEYlow->SetLineWidth(3);
  hBplusReferenceEYlow->SetLineStyle(2);

for (int i=0;i<nbins;i++){
        double xgae,ygae;
        gaeBplusReference->GetPoint(i,xgae,ygae);
        hBplusReference->SetBinContent(i+1,ygae);
        hBplusReferenceEYhigh->SetBinContent(i+1,ygae+gaeBplusReference->GetEYhigh()[i]);
        hBplusReferenceEYlow->SetBinContent(i+1,ygae-gaeBplusReference->GetEYlow()[i]);
        std::cout << "### FONLL (" << i << ") : " << ygae << " + " << gaeBplusReference->GetEYhigh()[i] << " - " << gaeBplusReference->GetEYlow()[i] << std::endl;
}

  for (int i=0;i<nbins;i++){
        double xgae,ygae;
        gSigmastat->GetPoint(i,xgae,ygae);
        std::cout << "### cross section (" << i << ") : " << ygae << " stat: " << gSigmastat->GetEYhigh()[i] << " syst: " << gSigmasyst->GetEYhigh()[i]     << std::endl;
  }
/*
  hBplusReference->Draw("][,same");

  hBplusReferenceEYhigh->Draw("][,same");
  hBplusReferenceEYlow->Draw("][,same");
*/
/*  
  gaeBplusReference->SetMarkerColor(1);
  gaeBplusReference->SetMarkerStyle(25);  
  gaeBplusReference->SetFillColor(kYellow-7);//5
  gaeBplusReference->SetFillStyle(1001);
  gaeBplusReference->SetLineColor(kAzure-3);//5
  gaeBplusReference->SetLineStyle(1);
  gaeBplusReference->SetLineWidth(0);
  gaeBplusReference->Draw("2psame");

  TGraphAsymmErrors*gaeBplusReference2=(TGraphAsymmErrors*)gaeBplusReference->Clone(); 
  gaeBplusReference2->SetMarkerColor(1);
  gaeBplusReference2->SetMarkerStyle(25);  
  gaeBplusReference2->SetFillColor(0);
  gaeBplusReference2->SetFillStyle(0);
  gaeBplusReference2->SetLineColor(kAzure-3);//5
  gaeBplusReference2->SetLineStyle(1);
  gaeBplusReference2->SetLineWidth(1);
  gaeBplusReference2->Draw("2psame");
*/
  //gSigmasyst->SetFillColor(0);
  //gSigmasyst->SetFillStyle(0);
  gSigmasyst->Draw("2esame");//2same
  gSigmasyst2->Draw("2esame");

  hBplusReference->Draw("][,same");

  hBplusReferenceEYhigh->Draw("][,same");
  hBplusReferenceEYlow->Draw("][,same");

  gSigmastat->SetMarkerColor(1);
  gSigmastat->SetLineColor(1);
  gSigmastat->SetLineWidth(3);   
  gSigmastat->SetMarkerStyle(21);
  gSigmastat->SetMarkerColor(1);
  gSigmastat->SetFillColor(0);
  gSigmastat->Draw("epsame");

  //###TLegend *legendSigma=new TLegend(0.233871,0.6701903,0.5322581,0.7526427,"");
  //TLegend *legendSigma=new TLegend(0.40,0.60,0.70,0.78,"");
  TLegend *legendSigma=new TLegend(0.23,0.56,0.57,0.77,"");

  legendSigma->SetBorderSize(0);
  legendSigma->SetLineColor(0);
  legendSigma->SetFillColor(0);
  legendSigma->SetFillStyle(1001);
  legendSigma->SetTextFont(42);
  legendSigma->SetTextSize(0.055);//###0.045
/*
  TBox *c = new TBox(0.1,1-commonErrorN,4,1+commonErrorP);
  c->SetLineColor(5);
  c->SetFillColor(5);
  c->Draw();
*/  
  gSigmastat->SetMarkerSize(1);

  TLegendEntry *ent_SigmapPb=legendSigma->AddEntry(gSigmastat,"pPb data","p");
  ent_SigmapPb->SetTextFont(42);
  ent_SigmapPb->SetMarkerColor(1);
  ent_SigmapPb->SetMarkerStyle(25);
  ent_SigmapPb->SetLineColor(1);
  ent_SigmapPb->SetLineWidth(2);
  ent_SigmapPb->SetLineStyle(0);

  TLegendEntry *ent_SigmapPbsyst=legendSigma->AddEntry(gSigmasyst,"Syst. pPb data","f");
  ent_SigmapPbsyst->SetTextFont(42);
  ent_SigmapPbsyst->SetMarkerColor(1);
  ent_SigmapPbsyst->SetMarkerStyle(25);
  ent_SigmapPbsyst->SetLineColor(1);
  ent_SigmapPbsyst->SetLineWidth(2);
  ent_SigmapPbsyst->SetLineStyle(0);
/*
///
  TLegendEntry *ent_SigmapPb=legendSigma->AddEntry(gSigmasyst,"pPb","pf");
  ent_SigmapPb->SetTextFont(42);
  ent_SigmapPb->SetLineColor(1);
  ent_SigmapPb->SetMarkerColor(1);
  ent_SigmapPb->SetMarkerStyle(25);
  //ent_SigmapPb->SetFillColor(kYellow-7);//5
  //ent_SigmapPb->SetFillStyle(1001);
  ent_SigmapPb->SetLineColor(1);
  ent_SigmapPb->SetLineWidth(0);
  ent_SigmapPb->SetLineStyle(0);
////
*/
/*
  TLegendEntry *ent_Sigmapp=legendSigma->AddEntry(gaeBplusReference,"FONLL pp ref.","fp");
  ent_Sigmapp->SetTextFont(42);
  ent_Sigmapp->SetLineColor(kAzure-3);//5
  ent_Sigmapp->SetLineStyle(1);
  ent_Sigmapp->SetMarkerColor(1);
  ent_Sigmapp->SetMarkerStyle(25);
*/

  TLegendEntry *ent_Sigmapp=legendSigma->AddEntry(hBplusReference,"Scaled FONLL pp ref.","l");
  ent_Sigmapp->SetTextFont(42);
  ent_Sigmapp->SetLineColor(kAzure-3);//5
  ent_Sigmapp->SetLineStyle(1);
  ent_Sigmapp->SetMarkerColor(1);
  ent_Sigmapp->SetMarkerStyle(21);

  TLegendEntry *ent_Sigmapperr=legendSigma->AddEntry(hBplusReferenceEYhigh,"FONLL pp ref. uncert.","l");
  ent_Sigmapperr->SetTextFont(42);
  ent_Sigmapperr->SetLineColor(kAzure-3);//5
  ent_Sigmapperr->SetLineStyle(2);
  ent_Sigmapperr->SetMarkerColor(1);
  ent_Sigmapperr->SetMarkerStyle(21);

  legendSigma->Draw("psame");
/*
  TBox *d = new TBox(0.1,1-commonErrorN,4,1+commonErrorP);
  d->SetLineColor(1);
  d->SetFillColor(0);
  d->Draw();
*/
  //###TLatex * tlatex1=new TLatex(0.23,0.84,"CMS");
  TLatex * tlatex1=new TLatex(0.24,0.85,"CMS");

  tlatex1->SetNDC();
  tlatex1->SetTextColor(1);
  tlatex1->SetTextFont(62);//###42
  tlatex1->SetTextSize(0.07);//###0.045
  tlatex1->Draw();
/*
  TLatex * tlatex12=new TLatex(0.24,0.80,"Preliminary");
  tlatex12->SetNDC();
  tlatex12->SetTextColor(1);
  tlatex12->SetTextFont(52);//###42
  tlatex12->SetTextSize(0.05);//###0.045
  tlatex12->Draw();
*/  

  TString mypar="B^{+}";
  
  //###TLatex * tlatexlumi=new TLatex(0.671371,0.7801268,"L = 34.8 nb^{-1}");
  TLatex * tlatexlumi=new TLatex(0.40,0.94,"34.6 nb^{-1} (pPb 5.02 TeV)");
  tlatexlumi->SetNDC();
  tlatexlumi->SetTextColor(1);
  tlatexlumi->SetTextFont(42);
  tlatexlumi->SetTextSize(0.06);//###0.045
  tlatexlumi->Draw();

  //###double xpos=0.8528226;
  //###double ypos=0.6849894;
  double xpos=0.85;
  double ypos=0.75;
  
  TLatex * tlatex3=new TLatex(xpos,ypos,mypar.Data());
   tlatex3->SetNDC();
  tlatex3->SetTextColor(1);
  tlatex3->SetTextFont(42);
  tlatex3->SetTextSize(0.07);//###0.06
  tlatex3->Draw();
  
  //###TLatex * tlatex4=new TLatex(0.51,0.84,"10 < p_{T}^{B} < 60 GeV/c");
  TLatex * tlatex4=new TLatex(0.51,0.84,"10 < p_{T} < 60 GeV/c");
  tlatex4->SetNDC();
  tlatex4->SetTextColor(1);
  tlatex4->SetTextFont(42);
  tlatex4->SetTextSize(0.06);
  tlatex4->Draw();
 
  TLatex * tlatex5=new TLatex(0.62,0.20,Form("Global uncert. %2.1f%%",commonErrorP*100));
  tlatex5->SetNDC();
  tlatex5->SetTextColor(1);
  tlatex5->SetTextFont(42);
  tlatex5->SetTextSize(0.04);
  tlatex5->Draw();


  canvasSigma->SaveAs(Form("../Results%s_y/canvasSigma%s.pdf",particle.Data(),particle.Data()));  
  canvasSigma->SaveAs(Form("../Results%s_y/canvasSigma%s.png",particle.Data(),particle.Data()));  

  canvasSigma->SaveAs(Form("../Results%s_y/canvasSigma%s.eps",particle.Data(),particle.Data()));  
  
  TGraphAsymmErrors *gRpAstat = new TGraphAsymmErrors(nbins,xbins,yRpA,exl,exl,yRpAStat,yRpAStat);
  gRpAstat->SetTitle("RpA stat uncertainty from pPb");
  gRpAstat->SetMarkerStyle(21);
  gRpAstat->SetMarkerColor(1);
  gRpAstat->SetLineColor(1);
  gRpAstat->SetLineWidth(3);  
  gRpAstat->SetFillColor(0);
  
  TGraphAsymmErrors *gRpAsyst = new TGraphAsymmErrors(nbins,xbins,yRpA,exl,exl,yRpPbSystTotLow,yRpPbSystTotHigh);
  gRpAsyst->SetTitle("RpA syst uncertainty from pPb");
  gRpAsyst->SetFillColor(kYellow-7);//###0
  //gRpAsyst->SetMarkerSize(0);
  gRpAsyst->SetLineColor(1);
  gRpAsyst->SetLineWidth(3);
  gRpAsyst->SetFillStyle(1001);
  gRpAsyst->SetMarkerStyle(21);
  gRpAsyst->SetMarkerColor(1);
  TGraphAsymmErrors*gRpAsyst2=(TGraphAsymmErrors*)gRpAsyst->Clone();
  gRpAsyst2->SetMarkerColor(1);
  gRpAsyst2->SetMarkerStyle(25);  
  gRpAsyst2->SetFillColor(0);
  gRpAsyst2->SetFillStyle(0);
  gRpAsyst2->SetLineColor(1);//5
  gRpAsyst2->SetLineStyle(1);
  gRpAsyst2->SetLineWidth(3);


   
  TGraphAsymmErrors *gRpAsystFONLL = new TGraphAsymmErrors(nbins,xbins,yFONLL,exl,exl,yRpAsystFONLLlow,yRpAsystFONLLhigh);
  gRpAsystFONLL->SetTitle("RpA syst uncertainty from FONLL reference");
  gRpAsystFONLL->SetFillColor(0);//5,kYellow-7
  gRpAsystFONLL->SetLineColor(kAzure-3);//5
  gRpAsystFONLL->SetMarkerColor(4);//kAzure-3);
  gRpAsystFONLL->SetLineStyle(2);//###1
  gRpAsystFONLL->SetLineWidth(3);


  TGraphAsymmErrors*gRpAsystFONLL2=(TGraphAsymmErrors*)gRpAsystFONLL->Clone(); 
  gRpAsystFONLL2->SetMarkerColor(1);
  gRpAsystFONLL2->SetMarkerStyle(25);  
  gRpAsystFONLL2->SetFillColor(0);
  gRpAsystFONLL2->SetFillStyle(0);
  gRpAsystFONLL2->SetLineColor(kAzure-3);//5
  gRpAsystFONLL2->SetLineStyle(2);//###1
  gRpAsystFONLL2->SetLineStyle(3);
  gRpAsystFONLL2->SetLineWidth(3);

//###
  TBox *gRpAsystFONLL_box0 = new TBox(xbins[0]-exl[0],yFONLL[0]-yRpAsystFONLLlow[0],xbins[0]+exl[0],yFONLL[0]+yRpAsystFONLLhigh[0]);
  gRpAsystFONLL_box0->SetLineColor(kAzure-3);
  gRpAsystFONLL_box0->SetLineWidth(3);
  gRpAsystFONLL_box0->SetLineStyle(2);
  gRpAsystFONLL_box0->SetFillColor(0);
  gRpAsystFONLL_box0->SetFillStyle(0);

  TBox *gRpAsystFONLL_box1 = new TBox(xbins[1]-exl[1],yFONLL[1]-yRpAsystFONLLlow[1],xbins[1]+exl[1],yFONLL[1]+yRpAsystFONLLhigh[1]);
  gRpAsystFONLL_box1->SetLineColor(kAzure-3);
  gRpAsystFONLL_box1->SetLineWidth(3);
  gRpAsystFONLL_box1->SetLineStyle(2);
  gRpAsystFONLL_box1->SetFillColor(0);
  gRpAsystFONLL_box1->SetFillStyle(0);

  TBox *gRpAsystFONLL_box2 = new TBox(xbins[2]-exl[2],yFONLL[2]-yRpAsystFONLLlow[2],xbins[2]+exl[2],yFONLL[2]+yRpAsystFONLLhigh[2]);
  gRpAsystFONLL_box2->SetLineColor(kAzure-3);
  gRpAsystFONLL_box2->SetLineWidth(3);
  gRpAsystFONLL_box2->SetLineStyle(2);
  gRpAsystFONLL_box2->SetFillColor(0);
  gRpAsystFONLL_box2->SetFillStyle(0);

  TBox *gRpAsystFONLL_box3 = new TBox(xbins[3]-exl[3],yFONLL[3]-yRpAsystFONLLlow[3],xbins[3]+exl[3],yFONLL[3]+yRpAsystFONLLhigh[3]);
  gRpAsystFONLL_box3->SetLineColor(kAzure-3);
  gRpAsystFONLL_box3->SetLineWidth(3);
  gRpAsystFONLL_box3->SetLineStyle(2);
  gRpAsystFONLL_box3->SetFillColor(0);
  gRpAsystFONLL_box3->SetFillStyle(0);

  TBox *gRpAsystFONLL_box4 = new TBox(xbins[4]-exl[4],yFONLL[4]-yRpAsystFONLLlow[4],xbins[4]+exl[4],yFONLL[4]+yRpAsystFONLLhigh[4]);
  gRpAsystFONLL_box4->SetLineColor(kAzure-3);
  gRpAsystFONLL_box4->SetLineWidth(3);
  gRpAsystFONLL_box4->SetLineStyle(2);
  gRpAsystFONLL_box4->SetFillColor(0);
  gRpAsystFONLL_box4->SetFillStyle(0);

  // Histogram style
  TH1D* hRpAsystFONLL = new TH1D("hRpAsystFONLL","",nbins,xhbins);
  TH1D* hRpAsystFONLLEYhigh = new TH1D("hRpAsystFONLLEYhigh","",nbins,xhbins);
  TH1D* hRpAsystFONLLEYlow = new TH1D("hRpAsystFONLLEYlow","",nbins,xhbins);
  
  for (int i=0;i<nbins;i++){
    hRpAsystFONLL->SetBinContent(i+1,yFONLL[i]);
    hRpAsystFONLLEYhigh->SetBinContent(i+1,yFONLL[i]+yRpAsystFONLLhigh[i]);
    hRpAsystFONLLEYlow->SetBinContent(i+1,yFONLL[i]-yRpAsystFONLLlow[i]);
    }
 
    hRpAsystFONLLEYhigh->SetLineColor(kAzure-3);
    hRpAsystFONLLEYhigh->SetLineWidth(3);
    hRpAsystFONLLEYhigh->SetLineStyle(2);
    hRpAsystFONLLEYhigh->SetFillColor(0);
    hRpAsystFONLLEYhigh->SetFillStyle(0);

    hRpAsystFONLLEYlow->SetLineColor(kAzure-3);
    hRpAsystFONLLEYlow->SetLineWidth(3);
    hRpAsystFONLLEYlow->SetLineStyle(2);
    hRpAsystFONLLEYlow->SetFillColor(0);
    hRpAsystFONLLEYlow->SetFillStyle(0);
    hRpAsystFONLLEYlow->Draw("][,same");


  //###TCanvas *canvasRpA=new TCanvas("canvasRpA","canvasRpA",600,500);   
  TCanvas *canvasRpA=new TCanvas("canvasRpA","canvasRpA",500,500);   
  
  canvasRpA->Range(-1.989924,-0.2917772,25.49622,2.212202);
  canvasRpA->SetFillColor(0);
  canvasRpA->SetBorderMode(0);
  canvasRpA->SetBorderSize(2);
  canvasRpA->SetLeftMargin(0.200);
  canvasRpA->SetRightMargin(0.025);
  canvasRpA->SetTopMargin(0.080);
  canvasRpA->SetBottomMargin(0.150);
  canvasRpA->SetFrameBorderMode(0);
  canvasRpA->SetFrameBorderMode(0);
  
  //###TLegend *legendRpA=new TLegend(0.23,0.58,0.57,0.77,"");
  TLegend *legendRpA=new TLegend(0.23,0.56,0.57,0.77,"");

  legendRpA->SetBorderSize(0);
  legendRpA->SetLineColor(0);
  legendRpA->SetFillColor(0);
  legendRpA->SetFillStyle(1001);
  legendRpA->SetTextFont(42);
  legendRpA->SetTextSize(0.055);//###0.04

  hempty=new TH2F("hempty","",4,-3.5,2.7,40.,0.,4.0);  
  hempty->GetXaxis()->SetTitle("y_{CM}");
  /*
  if(particle=="Bplus") hempty->GetYaxis()->SetTitle("R^{FONLL}_{pA}  (B^{+})");
  if(particle=="Bzero") hempty->GetYaxis()->SetTitle("R^{FONLL}_{pA}  (B^{0})");
  if(particle=="Bs") hempty->GetYaxis()->SetTitle("R^{FONLL}_{pA}  (B_{s})");
  */
  hempty->GetYaxis()->SetTitle("R^{FONLL}_{pA}");

  hempty->GetXaxis()->CenterTitle();
  hempty->GetYaxis()->CenterTitle();
  hempty->GetXaxis()->SetTitleOffset(0.90);
  hempty->GetYaxis()->SetTitleOffset(1.34);
  hempty->GetXaxis()->SetTitleSize(0.070);//###0.045
  hempty->GetYaxis()->SetTitleSize(0.070);//###0.045
  hempty->GetXaxis()->SetTitleFont(42);
  hempty->GetYaxis()->SetTitleFont(42);
  hempty->GetXaxis()->SetLabelFont(42);
  hempty->GetYaxis()->SetLabelFont(42);
  hempty->GetXaxis()->SetLabelSize(0.060);//###0.040
  hempty->GetYaxis()->SetLabelSize(0.060);//###0.040  
  hempty->SetMaximum(4.0);
  hempty->SetMinimum(0.);
  hempty->Draw();
  
  TLine *l = new TLine(0,1,70,1);
  l->SetLineStyle(2);
  
  legendRpA->Draw();
  gRpAstat->SetMarkerStyle(21);
  gRpAstat->SetLineColor(1);
  gRpAstat->SetMarkerColor(1);

for (int i=0;i<nbins;i++){
         double xgae,ygae;
         gRpAstat->GetPoint(i,xgae,ygae);
         std::cout << "####### RpA (" << i << ") : " << ygae << " stat: " << gRpAstat->GetEYhigh()[i] << " syst: " << gRpAsyst->GetEYhigh()[i] << std::endl;
         std::cout << "########### FONLL (" << i << ") : " << " + " << gRpAsystFONLL->GetEYhigh()[i] << " - " << gRpAsystFONLL->GetEYlow()[i] << std::    endl;
}

  //###gRpAsystFONLL->Draw("e2same");//###2same
  //###gRpAsystFONLL2->Draw("2esame");//###2same
/*
  gRpAsystFONLL_box0->Draw("same");
  gRpAsystFONLL_box1->Draw("same");
  gRpAsystFONLL_box2->Draw("same");
  gRpAsystFONLL_box3->Draw("same");
  gRpAsystFONLL_box4->Draw("same");
*/
  hRpAsystFONLLEYlow->Draw("][,same");
  hRpAsystFONLLEYhigh->Draw("][,same");
 
  gRpAsyst->Draw("2esame");
  gRpAsyst2->Draw("2esame");
  gRpAstat->Draw("psame");
  
  std::cout << "%%%%%%% RpA commonError " << " - " << commonErrorN << " + " << commonErrorP << std::endl;
  TBox *b = new TBox(-3.49,1-commonErrorN,-3.1,1+commonErrorP);
  b->SetLineColor(1);
  b->SetLineWidth(1);
  b->SetLineStyle(1);
  b->SetFillColor(kGray);
  b->Draw();
  
  TBox *b2=(TBox*)b->Clone();
  b2->SetFillStyle(0);
  b2->SetLineStyle(1);
  b2->SetLineWidth(1);
  b2->Draw();

  TGraphAsymmErrors*gRpAstat2=(TGraphAsymmErrors*)gRpAstat->Clone();
  gRpAstat2->SetTitle("RpA stat uncertainty from pPb");
  gRpAstat2->SetMarkerStyle(21);
  gRpAstat2->SetMarkerColor(1);
  gRpAstat2->SetLineColor(1);
  gRpAstat2->SetLineWidth(3);  
  gRpAstat2->SetFillColor(0);
  gRpAstat2->SetMarkerSize(1.5);
  
  TLegendEntry *ent_RpAstat=legendRpA->AddEntry(gRpAstat2,"R^{FONLL}_{pA}","p");
  ent_RpAstat->SetTextFont(42);
  ent_RpAstat->SetMarkerColor(1);
  ent_RpAstat->SetMarkerStyle(25);
  ent_RpAstat->SetMarkerSize(30);//###3
  //ent_RpAstat->SetFillColor(kYellow-7);//5
  //ent_RpAstat->SetFillStyle(1001);
  ent_RpAstat->SetLineColor(1);
  ent_RpAstat->SetLineWidth(3);
  ent_RpAstat->SetLineStyle(0);
 
   //TLegendEntry *ent_RpAsyst=legendRpA->AddEntry(gRpAsyst,"R^{FONLL}_{pA}","pf");
  TLegendEntry *ent_RpAsyst=legendRpA->AddEntry(gRpAsyst,"Syst. pPb data","f");
  ent_RpAsyst->SetTextFont(42);
  ent_RpAsyst->SetMarkerColor(1);
  ent_RpAsyst->SetMarkerStyle(25);
  //ent_RpAsyst->SetFillColor(kYellow-7);//5
  //ent_RpAsyst->SetFillStyle(1001);
  ent_RpAsyst->SetLineColor(1);
  ent_RpAsyst->SetLineWidth(3);
  ent_RpAsyst->SetLineStyle(0);
 
  TLegendEntry *ent_RpAsystFONLL=legendRpA->AddEntry(gRpAsystFONLL,"Syst. FONLL pp ref.","f");
  ent_RpAsystFONLL->SetTextFont(42);
  ent_RpAsystFONLL->SetLineColor(kAzure-3);//###5
  ent_RpAsystFONLL->SetLineStyle(1);//###0
  ent_RpAsystFONLL->SetLineWidth(3);
  ent_RpAsystFONLL->SetMarkerColor(kYellow-7);//5

   //###TLegendEntry *ent_RpAsystData=legendRpA->AddEntry(b,"Syst. int. lumi + BR","f");
  TLegendEntry *ent_RpAsystData=legendRpA->AddEntry(b,"Syst. int. lumi + B","f");
  ent_RpAsystData->SetTextFont(42);
  ent_RpAsystData->SetLineColor(2);
  ent_RpAsystData->SetMarkerColor(2);
  
  tlatex1->Draw();
  //###tlatex12->Draw();


  tlatexlumi->Draw();
  tlatex3->Draw();
  tlatex4->Draw();


  canvasRpA->SaveAs(Form("../Results%s_y/canvasRpA%s.pdf",particle.Data(),particle.Data()));  
  canvasRpA->SaveAs(Form("../Results%s_y/canvasRpA%s.png",particle.Data(),particle.Data()));  

  canvasRpA->SaveAs(Form("../Results%s_y/canvasRpA%s.eps",particle.Data(),particle.Data()));  
  canvasRpA->SaveAs(Form("../Results%s_y/canvasRpA%s.ps",particle.Data(),particle.Data()));  


/*
  TCanvas *canvasRFB=new TCanvas("canvasRFB","canvasRFB",500,500);   
  canvasRFB->cd();
  canvasRFB->Range(-1.989924,-0.2917772,25.49622,2.212202);
  canvasRFB->SetFillColor(0);
  canvasRFB->SetBorderMode(0);
  canvasRFB->SetBorderSize(2);
  canvasRFB->SetLeftMargin(0.1451613);
  canvasRFB->SetRightMargin(0.05443548);
  canvasRFB->SetTopMargin(0.08474576);
  canvasRFB->SetBottomMargin(0.1165254);
  canvasRFB->SetFrameBorderMode(0);
  canvasRFB->SetFrameBorderMode(0);
 
  TLegend *legendRFB=new TLegend(0.2560484,0.6490486,0.5483871,0.7716702,"");
  legendRFB->SetBorderSize(0);
  legendRFB->SetLineColor(0);
  legendRFB->SetFillColor(0);
  legendRFB->SetFillStyle(1001);
  legendRFB->SetTextFont(42);
  legendRFB->SetTextSize(0.045);

  TH2F* hempty=new TH2F("hempty","",4,-0.1,2.,10.,0.,2.5);  
  hempty->GetXaxis()->SetTitle("|y_{CM}|");
  hempty->GetYaxis()->SetTitle("R_{FB}");
  hempty->GetXaxis()->SetTitleOffset(1.1);
  hempty->GetYaxis()->SetTitleOffset(1.3);
  hempty->GetXaxis()->SetTitleSize(0.045);
  hempty->GetYaxis()->SetTitleSize(0.045);
  hempty->GetXaxis()->SetTitleFont(42);
  hempty->GetYaxis()->SetTitleFont(42);
  hempty->GetXaxis()->SetLabelFont(42);
  hempty->GetYaxis()->SetLabelFont(42);
  hempty->GetXaxis()->SetLabelSize(0.04);
  hempty->GetYaxis()->SetLabelSize(0.04);  
  hempty->GetXaxis()->CenterTitle();
  hempty->GetYaxis()->CenterTitle();
  hempty->SetMaximum(3);
  hempty->SetMinimum(0.);
  hempty->Draw();
  legendRFB->Draw();

  TGraphAsymmErrors *gRFBsyst = new TGraphAsymmErrors(nbinsRFB,xbinsRFB,yRFB,exlRFB,exlRFB,yRFBSystTotLow,yRFBSystTotHigh);
  gRFBsyst->SetTitle("gRFBsyst");
   gRFBsyst->SetName("gRFBsyst");
  gRFBsyst->SetMarkerColor(4);
  gRFBsyst->SetLineColor(4);
  gRFBsyst->SetLineWidth(2);   
  gRFBsyst->SetMarkerStyle(0);
  gRFBsyst->SetMarkerColor(1);


  


  TGraphAsymmErrors *gRFBstat = new TGraphAsymmErrors(nbinsRFB,xbinsRFB,yRFB,exlRFB,exlRFB,yRFBStat, yRFBStat);
  gRFBstat->SetTitle("gRFBstat");
  gRFBstat->SetName("gRFBstat");
  gRFBstat->SetMarkerColor(1);
  gRFBstat->SetLineColor(1);
  gRFBstat->SetLineWidth(2);   
  gRFBstat->SetMarkerStyle(21);
  gRFBstat->SetMarkerColor(1);
  gRFBstat->SetFillColor(0);
  gRFBstat->SetFillStyle(0);

  gRFBsyst->SetFillColor(0);
  gRFBsyst->SetFillStyle(0);
  
  gRFBsyst->Draw("2same");
  gRFBstat->Draw("psame");



  TLegendEntry *ent_RFB=legendRFB->AddEntry(gRFBstat,"R_{FB} stat.","pl");
  ent_RFB->SetTextFont(42);
  ent_RFB->SetLineColor(2);
  ent_RFB->SetMarkerColor(2);

  TLegendEntry *ent_RFB=legendRFB->AddEntry(gRFBsyst,"R_{FB} syst.","l");
  ent_RFB->SetTextFont(42);
  ent_RFB->SetLineColor(4);
  // ent_RFB->SetMarkerColor(2);

  TLatex * tlatex1=new TLatex(0.1612903,0.8625793,"CMS                 pPb #sqrt{s_{NN}}= 5.02 TeV");
  tlatex1->SetNDC();
  tlatex1->SetTextColor(1);
  tlatex1->SetTextFont(42);
  tlatex1->SetTextSize(0.045);
  tlatex1->Draw();

    
  TLatex * tlatexlumi=new TLatex(0.671371,0.7801268,"L = 34.8 nb^{-1}");
  tlatexlumi->SetNDC();
  tlatexlumi->SetTextColor(1);
  tlatexlumi->SetTextFont(42);
  tlatexlumi->SetTextSize(0.045);
  tlatexlumi->Draw();

  
  //double xpos1=0.6528226;
  // double ypos1=0.6849894;
  TLatex * tlatex3=new TLatex(xpos,ypos,mypar.Data());
   tlatex3->SetNDC();
  tlatex3->SetTextColor(1);
  tlatex3->SetTextFont(42);
  tlatex3->SetTextSize(0.06);
  tlatex3->Draw();
  canvasRFB->SaveAs(Form("../Results%s_y/CanvasRDFB.pdf",particle.Data(),particle.Data()));

  */


//  l->Draw();  
//  canvasRpA->SaveAs(Form("../Results%sY/canvasRpA%s.pdf",particle.Data(),particle.Data()));  
//  canvasRpA->SaveAs(Form("../Results%s_y/canvasRpA%s.pdf",particle.Data(),particle.Data()));  
  
//  TFile *fout=new TFile(Form("../Results%sY/fileRpA%s.root",particle.Data(),particle.Data()),"recreate");  
  TFile *fout=new TFile(Form("../Results%s_y/fileRpA%s.root",particle.Data(),particle.Data()),"recreate");  
  fout->cd();
  gSigmasyst->SetName("gSigmasyst");
  gSigmasyst->Write();
  gaeBplusReference->Write();
  hSigmapPbStat->Write();






}