Exemplo n.º 1
0
void comp_RpPb_pt_Bmeson(bool isPrompt = false)
{
	gROOT->Macro("./tdrstyle_kyo.C");
	int isPA = 10;
	int iPos=33;
  
  //// BR and lumi info.
  const Double_t br = 0.0593 ;
  const Double_t brErr = 0.0006;
	const Double_t pp_lumi_pb =27.972; // 28.0/pb
	const Double_t pp_lumi_pb_err = 0.643; // 2.3 %
	const Double_t pPb_lumi_nb = 34.622; // 34.6/nb
	const Double_t pPb_lumi_nb_err = 1.211; // 3.5 %
  const Double_t pp_lumi_mub = pp_lumi_pb *1000*1000;
  const Double_t pPb_lumi_mub_err = pp_lumi_pb_err *1000*1000;
 
  double A_pb =208;
  
  //// read our result
	TFile *inFile_pp;
  if (isPrompt) inFile_pp = new TFile("plot_cross/pp_cross_pt_integ_middle_isPrompt1_isLog0_isScale0_maxrap386.root");
  else inFile_pp= new TFile("plot_cross/pp_cross_pt_integ_middle_isPrompt0_isLog0_isScale0_maxrap386.root");
	TGraphAsymmErrors* g_cross_fwrap_pp = (TGraphAsymmErrors*)inFile_pp->Get("g_cross_fwrap"); 
	TGraphAsymmErrors* g_cross_sys_fwrap_pp = (TGraphAsymmErrors*)inFile_pp->Get("g_cross_sys_fwrap"); 

	//// read our result
	TFile *inFile_pA;
  if (isPrompt) inFile_pA = new TFile("plot_cross/pA_cross_pt_integ_middle_isPrompt1_isLog0_isScale0_maxrap386.root");
  else inFile_pA= new TFile("plot_cross/pA_cross_pt_integ_middle_isPrompt0_isLog0_isScale0_maxrap386.root");
	TGraphAsymmErrors* g_cross_fwrap_pA = (TGraphAsymmErrors*)inFile_pA->Get("g_cross_fwrap"); 
	TGraphAsymmErrors* g_cross_sys_fwrap_pA = (TGraphAsymmErrors*)inFile_pA->Get("g_cross_sys_fwrap"); 

  const int nPt = 5;
  double dummy1;
  double pxtmp[nPt];
  double pytmp_pp[nPt]; double pytmp_pA[nPt]; double rppb[nPt];
  double eytmp_pp[nPt]; double eytmp_pA[nPt]; double ey_rppb[nPt];
  double eysystmp_pp[nPt]; double eysystmp_pA[nPt]; double eysys_rppb[nPt];
  for (int ipt=0; ipt<nPt; ipt++) {
    g_cross_fwrap_pp->GetPoint(ipt+4, pxtmp[ipt], pytmp_pp[ipt]); 
    g_cross_fwrap_pA->GetPoint(ipt+4, pxtmp[ipt], pytmp_pA[ipt]); 
    eytmp_pp[ipt] = g_cross_fwrap_pp->GetErrorY(ipt+4); 
    eytmp_pA[ipt] = g_cross_fwrap_pA->GetErrorY(ipt+4);
    eysystmp_pp[ipt] = g_cross_sys_fwrap_pp->GetErrorY(ipt+4); 
    eysystmp_pA[ipt] = g_cross_sys_fwrap_pA->GetErrorY(ipt+4);
  }
  cout << "::: for excel ::: " << endl;
  for (int ipt=0; ipt<nPt; ipt++) {
    DivideValue(pytmp_pA[ipt],eytmp_pA[ipt],pytmp_pp[ipt],eytmp_pp[ipt],&rppb[ipt],&ey_rppb[ipt]);  //actual values
    DivideValue(pytmp_pA[ipt],eysystmp_pA[ipt],pytmp_pp[ipt],eysystmp_pp[ipt],&dummy1,&eysys_rppb[ipt]); //syst. 
    rppb[ipt]/=A_pb; 
    ey_rppb[ipt]/=A_pb; 
    eysys_rppb[ipt]/=A_pb; 
    //cout << " "<<endl;
    //cout << "rppb["<<ipt<<"] ="  << rppb[ipt] << endl;
    //cout << "stat.["<<ipt<<"] ="  << ey_rppb[ipt] << endl;
    //cout << "syst.["<<ipt<<"] ="  << eysys_rppb[ipt] << endl;
    cout << rppb[ipt] <<"\t"<<ey_rppb[ipt] << "\t "<<eysys_rppb[ipt]<<endl;
  }
	Double_t exsys[nPt] = {0.4,0.4,0.4,0.4,0.4};
	Double_t exlow[nPt];
	Double_t exhigh[nPt];
	Double_t ptArrNum[nPt+1] = {6.5, 7.5, 8.5, 10., 14., 30.};
	
  //// ex calculation
  for (Int_t ipt=0; ipt<nPt; ipt++) {
    exlow[ipt] = pxtmp[ipt]-ptArrNum[ipt];
    exhigh[ipt] = ptArrNum[ipt+1]-pxtmp[ipt];
  }
	
  ///////////////////////////////////////////////////
	///////////////////// Bmeson ////////////////////////
	///////////////////////////////////////////////////
  TCanvas *c1 = new TCanvas("c1","c1",600,600);
	
  const int nPtBmeson = 5;
  double px_Bmeson[nPtBmeson] = {12.5, 17.5, 22.5, 27.5, 45};
  double rppb_Bmeson[nPtBmeson] = {1.11, 1.19, 0.91, 0.86, 1.14};
  double ex_Bmeson[nPtBmeson] = {0,0,0,0,0};
  double exsys_Bmeson[nPtBmeson] = {2.5, 2.5, 2.5, 2.5, 15.};
  double ey_Bmeson[nPtBmeson] = {0.08, 0.10, 0.12, 0.18, 0.19};
  double eysys_Bmeson[nPtBmeson] = {0.17, 0.17, 0.13, 0.12, 0.17};
  double eysysFONLLlow_Bmeson[nPtBmeson] = {0.29,0.28,0.19,0.16,0.18};
  double eysysFONLLhigh_Bmeson[nPtBmeson] = {0.33,0.31,0.21,0.18,0.21};
  TGraphAsymmErrors* g_RpPb_Bmeson_sys = new TGraphAsymmErrors(nPtBmeson, px_Bmeson, rppb_Bmeson, exsys_Bmeson, exsys_Bmeson, eysys_Bmeson, eysys_Bmeson);	
  TGraphAsymmErrors* g_RpPb_Bmeson_sysFONLL = new TGraphAsymmErrors(nPtBmeson, px_Bmeson, rppb_Bmeson, exsys_Bmeson, exsys_Bmeson, eysysFONLLlow_Bmeson, eysysFONLLhigh_Bmeson);	
  TGraphAsymmErrors* g_RpPb_Bmeson = new TGraphAsymmErrors(nPtBmeson, px_Bmeson, rppb_Bmeson, ex_Bmeson, ex_Bmeson, ey_Bmeson, ey_Bmeson);	
  
  g_RpPb_Bmeson_sysFONLL->GetXaxis()->SetTitle("p_{T} (GeV/c)");
  g_RpPb_Bmeson_sysFONLL->GetXaxis()->CenterTitle();
  g_RpPb_Bmeson_sysFONLL->GetYaxis()->SetTitle("R_{pPb}");
  g_RpPb_Bmeson_sysFONLL->GetYaxis()->CenterTitle();
  g_RpPb_Bmeson_sysFONLL->GetXaxis()->SetLimits(0.,62.0);
  g_RpPb_Bmeson_sysFONLL->SetMinimum(0.0);
  g_RpPb_Bmeson_sysFONLL->SetMaximum(2.0);
  g_RpPb_Bmeson_sysFONLL->SetLineColor(kGray);
  g_RpPb_Bmeson_sysFONLL->SetFillColor(kWhite);
  g_RpPb_Bmeson_sysFONLL->SetFillStyle(4000);
  g_RpPb_Bmeson_sysFONLL->SetLineWidth(3);
  g_RpPb_Bmeson_sysFONLL->SetLineStyle(7);
  
  g_RpPb_Bmeson_sys->SetFillColor(kGray);
  //g_RpPb_Bmeson_sys->SetFillStyle(3001);
  
  SetGraphStyleFinal(g_RpPb_Bmeson, 9, 13);
  g_RpPb_Bmeson->SetMarkerSize(1.2);
   
  //////////////////////////////////////////////////////////////
  
  TLatex* globtex = new TLatex();
	globtex->SetNDC();
	globtex->SetTextAlign(12); //1:left, 2:vertical center
  //globtex->SetTextAlign(32); //3:right 2:vertical center
  globtex->SetTextFont(42);
	globtex->SetTextSize(0.04);
  
  TBox * globbox_br = new TBox(2, 0.969, 4, 1.031); //for B+ branching ratio
  globbox_br->SetFillColorAlpha(kWhite,0.5);
  globbox_br->SetLineColor(kBlack);

  //// our results
  TGraphAsymmErrors* g_RpPb_sys = new TGraphAsymmErrors(nPt, pxtmp, rppb, exlow, exhigh, eysys_rppb, eysys_rppb);	
  TGraphAsymmErrors* g_RpPb = new TGraphAsymmErrors(nPt, pxtmp, rppb, exsys, exsys, ey_rppb, ey_rppb);	
  
  g_RpPb_sys->SetFillColorAlpha(kRed-10,0.5);
  g_RpPb_sys->SetLineColor(kPink-6);

  SetGraphStyleFinal(g_RpPb, 1, 0);
  g_RpPb->SetMarkerSize(1.2);
  
  ////// actual draw
  g_RpPb_Bmeson_sysFONLL->Draw("A5");
  g_RpPb_Bmeson_sys->Draw("2");
  g_RpPb_sys->Draw("5");
  solidLine(0.,1.,62.,1.,1,1);
  g_RpPb->Draw("p");
  g_RpPb_Bmeson->Draw("p");
  
	
  //TLegend *legBL = new TLegend(0.50,0.18,0.90,0.25);
  TLegend *legBL = new TLegend(0.18,0.18,0.77,0.32);
	SetLegendStyle(legBL);
	//legBL->SetTextSize(0.037);
	legBL->SetTextSize(0.043);
  legBL->SetTextFont(42);
	legBL -> AddEntry(g_RpPb,"Nonprompt J/#psi: |y_{CM}| < 1.93","lp");
	legBL -> AddEntry(g_RpPb_Bmeson,"B^{+}: -2.86 < y_{CM} < 1.93","lp");
	legBL -> Draw();
  
  globtex->SetTextSize(0.055); 
  globtex->SetTextFont(42);
  globtex->DrawLatex(0.212, 0.852, "Open beauty");
  //if (isPrompt) globtex->DrawLatex(0.212, 0.852, "Prompt J/#psi");
  //else globtex->DrawLatex(0.212, 0.852, "Nonprompt J/#psi");
  
  CMS_lumi( c1, isPA, iPos );
  c1->Update();

	c1->SaveAs(Form("plot_otherExp/comp_RpPb_pt_Bmeson_isPrompt%d.pdf",(int)isPrompt));
	c1->SaveAs(Form("plot_otherExp/comp_RpPb_pt_Bmeson_isPrompt%d.png",(int)isPrompt));
  
  return;

}
Exemplo n.º 2
0
void comp_RpPb_pt_ATLAS(bool isPrompt = true)
{
	gROOT->Macro("./tdrstyle_kyo.C");
	int isPA = 10;
	int iPos=33;
  
  //// BR and lumi info.
  const Double_t br = 0.0593 ;
  const Double_t brErr = 0.0006;
	const Double_t pp_lumi_pb =27.972; // 28.0/pb
	const Double_t pp_lumi_pb_err = 0.643; // 2.3 %
	const Double_t pPb_lumi_nb = 34.622; // 34.6/nb
	const Double_t pPb_lumi_nb_err = 1.211; // 3.5 %
  const Double_t pp_lumi_mub = pp_lumi_pb *1000*1000;
  const Double_t pPb_lumi_mub_err = pp_lumi_pb_err *1000*1000;
 
  double A_pb =208;
  
  //// read our result
	TFile *inFile_pp;
  if (isPrompt) inFile_pp = new TFile("plot_cross/pp_cross_pt_integ_middle_isPrompt1_isLog0_isScale0_maxrap300.root");
  else inFile_pp= new TFile("plot_cross/pp_cross_pt_integ_middle_isPrompt0_isLog0_isScale0_maxrap300.root");
	TGraphAsymmErrors* g_cross_fwrap_pp = (TGraphAsymmErrors*)inFile_pp->Get("g_cross_fwrap"); 
	TGraphAsymmErrors* g_cross_sys_fwrap_pp = (TGraphAsymmErrors*)inFile_pp->Get("g_cross_sys_fwrap"); 

	//// read our result
	TFile *inFile_pA;
  if (isPrompt) inFile_pA = new TFile("plot_cross/pA_cross_pt_integ_middle_isPrompt1_isLog0_isScale0_maxrap300.root");
  else inFile_pA= new TFile("plot_cross/pA_cross_pt_integ_middle_isPrompt0_isLog0_isScale0_maxrap300.root");
	TGraphAsymmErrors* g_cross_fwrap_pA = (TGraphAsymmErrors*)inFile_pA->Get("g_cross_fwrap"); 
	TGraphAsymmErrors* g_cross_sys_fwrap_pA = (TGraphAsymmErrors*)inFile_pA->Get("g_cross_sys_fwrap"); 

  const int nPt = 5;
  double dummy1;
  double pxtmp[nPt];
  double pytmp_pp[nPt]; double pytmp_pA[nPt]; double rppb[nPt];
  double eytmp_pp[nPt]; double eytmp_pA[nPt]; double ey_rppb[nPt];
  double eysystmp_pp[nPt]; double eysystmp_pA[nPt]; double eysys_rppb[nPt];
  for (int ipt=0; ipt<nPt; ipt++) {
    g_cross_fwrap_pp->GetPoint(ipt+4, pxtmp[ipt], pytmp_pp[ipt]); 
    g_cross_fwrap_pA->GetPoint(ipt+4, pxtmp[ipt], pytmp_pA[ipt]); 
    eytmp_pp[ipt] = g_cross_fwrap_pp->GetErrorY(ipt+4); 
    eytmp_pA[ipt] = g_cross_fwrap_pA->GetErrorY(ipt+4);
    eysystmp_pp[ipt] = g_cross_sys_fwrap_pp->GetErrorY(ipt+4); 
    eysystmp_pA[ipt] = g_cross_sys_fwrap_pA->GetErrorY(ipt+4);
  }
  for (int ipt=0; ipt<nPt; ipt++) {
    DivideValue(pytmp_pA[ipt],eytmp_pA[ipt],pytmp_pp[ipt],eytmp_pp[ipt],&rppb[ipt],&ey_rppb[ipt]);  //actual values
    DivideValue(pytmp_pA[ipt],eysystmp_pA[ipt],pytmp_pp[ipt],eysystmp_pp[ipt],&dummy1,&eysys_rppb[ipt]); //syst. 
    rppb[ipt]/=A_pb; 
    ey_rppb[ipt]/=A_pb; 
    eysys_rppb[ipt]/=A_pb; 
    cout << " "<<endl;
    cout << "rppb["<<ipt<<"] ="  << rppb[ipt] << endl;
    cout << "stat.["<<ipt<<"] ="  << ey_rppb[ipt] << endl;
    cout << "syst.["<<ipt<<"] ="  << eysys_rppb[ipt] << endl;
  }
	Double_t exsys[nPt] = {0.4,0.4,0.4,0.4,0.4};
	Double_t exlow[nPt];
	Double_t exhigh[nPt];
	Double_t ptArrNum[nPt+1] = {6.5, 7.5, 8.5, 10., 14., 30.};
	
  //// ex calculation
  for (Int_t ipt=0; ipt<nPt; ipt++) {
    exlow[ipt] = pxtmp[ipt]-ptArrNum[ipt];
    exhigh[ipt] = ptArrNum[ipt+1]-pxtmp[ipt];
  }
	
  ///////////////////////////////////////////////////
	///////////////////// ATLAS ////////////////////////
	///////////////////////////////////////////////////
	TFile *inFileATLAS;
  if (isPrompt) inFileATLAS = new TFile("ATLAS_Jpsi_RpPb/RpPb_PromptJpsi_dpT.root");
  else inFileATLAS= new TFile("ATLAS_Jpsi_RpPb/RpPb_NonPromptJpsi_dpT.root");
  cout << "inFileATLAS = " << inFileATLAS << endl;
	TGraphAsymmErrors* g_RpPb_ATLAS_sys;
	TGraphAsymmErrors* g_RpPb_ATLAS;
  if (isPrompt) { 
     g_RpPb_ATLAS_sys = (TGraphAsymmErrors*)inFileATLAS->Get("RpPb_p_syst"); 
     g_RpPb_ATLAS = (TGraphAsymmErrors*)inFileATLAS->Get("RpPb_p"); 
  }else {
     g_RpPb_ATLAS_sys = (TGraphAsymmErrors*)inFileATLAS->Get("RpPb_np_syst"); 
     g_RpPb_ATLAS = (TGraphAsymmErrors*)inFileATLAS->Get("RpPb_np"); 
  }
  cout << "g_RpPb_ATLAS_sys = " << g_RpPb_ATLAS_sys << endl;
  cout << "g_RpPb_ATLAS = " << g_RpPb_ATLAS << endl;
  
  
  //////////////////////////////////////////////////////////////
  
  TLatex* globtex = new TLatex();
	globtex->SetNDC();
	globtex->SetTextAlign(12); //1:left, 2:vertical center
  //globtex->SetTextAlign(32); //3:right 2:vertical center
  globtex->SetTextFont(42);
	globtex->SetTextSize(0.04);
  
  TCanvas *c1 = new TCanvas("c1","c1",600,600);
  
  g_RpPb_ATLAS_sys->GetXaxis()->SetTitle("p_{T} (GeV/c)");
  g_RpPb_ATLAS_sys->GetXaxis()->CenterTitle();
  g_RpPb_ATLAS_sys->GetYaxis()->SetTitle("R_{pPb}");
  g_RpPb_ATLAS_sys->GetYaxis()->CenterTitle();
  g_RpPb_ATLAS_sys->GetXaxis()->SetTitleOffset(1.15);
  g_RpPb_ATLAS_sys->GetXaxis()->SetLimits(0.,32.);
  g_RpPb_ATLAS_sys->SetMinimum(0.0);
  g_RpPb_ATLAS_sys->SetMaximum(2.0);
  g_RpPb_ATLAS_sys->SetLineColor(kGray);
  g_RpPb_ATLAS_sys->SetFillColor(kWhite);
  g_RpPb_ATLAS_sys->SetFillStyle(4000);
  g_RpPb_ATLAS_sys->SetLineWidth(3);
  g_RpPb_ATLAS_sys->SetLineStyle(7);
  
  g_RpPb_ATLAS_sys->SetFillColor(kGray);
  
  SetGraphStyleFinal(g_RpPb_ATLAS, 9, 10);
  g_RpPb_ATLAS->SetMarkerSize(1.7);
  
  //TGraphAsymmErrors* g_RpPb_sys = new TGraphAsymmErrors(nPt, pxtmp, rppb, exsys, exsys, eysys_rppb, eysys_rppb);	
  TGraphAsymmErrors* g_RpPb_sys = new TGraphAsymmErrors(nPt, pxtmp, rppb, exlow, exhigh, eysys_rppb, eysys_rppb);	
  TGraphAsymmErrors* g_RpPb = new TGraphAsymmErrors(nPt, pxtmp, rppb, exsys, exsys, ey_rppb, ey_rppb);	
  g_RpPb_sys->GetXaxis()->SetTitle("p_{T} (GeV/c)");
  g_RpPb_sys->GetXaxis()->CenterTitle();
  g_RpPb_sys->GetYaxis()->SetTitle("R_{pPb}");
  g_RpPb_sys->GetYaxis()->CenterTitle();
  g_RpPb_sys->GetXaxis()->SetLimits(0.,30.0);
  g_RpPb_sys->SetMinimum(0.0);
  g_RpPb_sys->SetMaximum(2.0);
  g_RpPb_sys->SetFillColorAlpha(kRed-10,0.5);
  g_RpPb_sys->SetLineColor(kPink-6);

  SetGraphStyleFinal(g_RpPb, 1, 0);
  //g_RpPb->SetMarkerSize(2.1);
  g_RpPb->SetMarkerSize(1.7);
  
  ////// actual draw
  g_RpPb_ATLAS_sys->Draw("A5");
  g_RpPb_sys->Draw("5");
  solidLine(0.,1.,32.,1.,1,1);
  g_RpPb_ATLAS->Draw("p");
  g_RpPb->Draw("p");
  
	
  //TLegend *legBL = new TLegend(0.19,0.18,0.54,0.25);
  TLegend *legBL = new TLegend(0.18,0.18,0.77,0.32);
	SetLegendStyle(legBL);
	legBL->SetTextSize(0.043);
  legBL->SetTextFont(42);
	legBL -> AddEntry(g_RpPb,"-1.5 < y_{CM} < 1.5","lp");
	legBL -> AddEntry(g_RpPb_ATLAS,"ATLAS: -1.5 < y_{CM} < 1.5","lp");
	legBL -> Draw();
  
  globtex->SetTextSize(0.055); 
  globtex->SetTextFont(42);
  if (isPrompt) globtex->DrawLatex(0.21, 0.84, "Prompt J/#psi");
  else globtex->DrawLatex(0.21, 0.84, "Nonprompt J/#psi");
  
  CMS_lumi( c1, isPA, iPos );
  c1->Update();

	c1->SaveAs(Form("plot_otherExp/comp_RpPb_pt_ATLAS_isPrompt%d.pdf",(int)isPrompt));
	c1->SaveAs(Form("plot_otherExp/comp_RpPb_pt_ATLAS_isPrompt%d.png",(int)isPrompt));
  
  return;

}
Exemplo n.º 3
0
void draw_RFB_pt_mergedBin(bool sysByHand=false, bool noPtWeight=false, bool isPrompt=false)
{
  gROOT->Macro("./tdrstyle_kyo.C");
  //cmsTextFont   = 42;  // for b.hong
  //extraTextFont = 42;  // for b.hong
  int isPA = 1;  // 0:pp, 1:pPb
	//int iPos=0; //outside topleft
	int iPos=33; //right corner

  //// BR and lumi info.
  const Double_t br = 0.0593 ;
  const Double_t brErr = 0.0006;
  const Double_t pPb_lumi_nb = 34.622; // 34.6/nb
  const Double_t pPb_lumi_nb_err = 1.211; // 3.5 %
  const Double_t pPb_lumi_mub = pPb_lumi_nb * 1000; // (nb)^{-1} -> {#mub}^{-1}
  const Double_t pPb_lumi_mub_err = pPb_lumi_nb_err * 1000; // (nb)^{-1} -> {#mub}^{-1}
  
  /////////////////////////////////////////////////////////////////////////
  // bin center & systematic uncertainties by hand
  // for 1.5 - 1.93 
  const int nRap = 8; 
  const int nPt = 9;
  const int nRapTmp = nRap + 1;
  const int nPtTmp = nPt + 1;
  const int nRapRFB = 3;  
  const int nPtRFB = 3;
  
  Double_t pxtmp[nRapRFB][nPtRFB]; //x point to fill remporarily
  Double_t pytmp[nRapRFB][nPtRFB]; //y point to fill remporarily
  Double_t eytmp[nRapRFB][nPtRFB]; //y point error to fill remporarily
  /// 2015 PAS
  Double_t px[nRapRFB][nPtRFB] = { // x point (mean pT)
    {5.75945, 7.90077, 13.2826}, //1.5-1.93
    {-531, 7.98106, 13.2588}, //0.9-1.5
    {-531, 8.2616, 13.5598} //0.0-0.9
  };
  Double_t ex[nPtRFB] = {0.,0.,0.}; // x stat error (0)
  Double_t exlow[nRapRFB][nPtRFB];
  Double_t exhigh[nRapRFB][nPtRFB];
  //Double_t exsys[nPtRFB] = {0.25,0.25,0.25}; // x sys err (box width)
  Double_t exsys[nPtRFB] = {0.3,0.3,0.3}; // x sys err (box width)
  Double_t eysys[nRapRFB][nPtRFB]; //absolute y sys error
  //Double_t eysysrel[nRapRFB][nPtRFB]; //relative y sys error
  /*
  Double_t eysysrelPR[nRapRFB][nPtRFB] = {
    {0.04529, 0.04795, 0.06486}, //1.5-1.03
    {0.00, 0.04245, 0.03360}, //0.9-1.5
    {0.00, 0.04694, 0.03705} //0.0-0.9
  };
  Double_t eysysrelNP[nRapRFB][nPtRFB] = {
    {0.06133, 0.10487,  0.09280},
    {0.00, 0.06288, 0.05592},
    {0.00, 0.07412, 0.04483}
  };
  for (int iy=0; iy<nRapRFB; iy++){
    for (int ipt=0; ipt<nPtRFB; ipt++){
      if(isPrompt) eysysrel[iy][ipt] = eysysrelPR[iy][ipt];
      else eysysrel[iy][ipt] = eysysrelNP[iy][ipt];
    }
  }
*/
  //// 1) y_CM array (from forward to backward)
  Double_t rapArrNumFB[nRapTmp] = {1.93, 1.5, 0.9, 0., -0.9, -1.5, -1.93, -2.4, -2.87};// for pt dist.
  //Double_t rapArrNumBF[nRapTmp] = {-2.87, -2.4, -1.93, -1.5, -0.9, 0., 0.9, 1.5, 1.93};// for rap dist.
  Double_t rapBinW[nRap];
  for (Int_t iy=0; iy<nRap; iy++) {
    rapBinW[iy] = rapArrNumFB[iy]-rapArrNumFB[iy+1];
    //cout << iy <<"th rapBinW = " << rapBinW[iy] <<endl;
  }
  //// 2) pt array
  Double_t ptArrNum[nPtTmp] = {2.0, 3.0, 4.0, 5.0, 6.5, 7.5, 8.5, 10., 14., 30.};
  Double_t ptBinW[nPt];
  for (Int_t ipt=0; ipt<nPt; ipt++) {
    ptBinW[ipt] = ptArrNum[ipt+1]-ptArrNum[ipt]; 
    //cout << ipt <<"th ptBinW = " << ptBinW[ipt] <<endl;
  }
  //// array string
  TString rapArr[nRap];
  for (Int_t iy=0; iy<nRap; iy++) {
    formRapArr(rapArrNumFB[iy+1], rapArrNumFB[iy], &rapArr[iy]);
    cout << iy <<"th rapArr = " << rapArr[iy] << endl;
  }
  TString ptArr[nPt];
  for (Int_t ipt=0; ipt<nPt; ipt++) {
    formPtArr(ptArrNum[ipt], ptArrNum[ipt+1], &ptArr[ipt]);
    cout << ipt <<"th ptArr = " << ptArr[ipt] << endl;
  }

  //////////////////////////////////////////////////////////////  
  //// read-in sys. file 
  TFile * fSys;
  if (isPA==0) fSys = new TFile("../TotalSys/TotSys_8rap9pt_pp_etOpt0.root");
  else fSys = new TFile("../TotalSys/TotSys_8rap9pt_pA_etOpt0.root");
  TH2D* h2D_SysErr;
  if (isPrompt) h2D_SysErr = (TH2D*)fSys->Get("hTotalPR");
  else h2D_SysErr = (TH2D*)fSys->Get("hTotalNP");
//  cout << " *** h2D_SysErr = " <<  h2D_SysErr << endl;  

  /////////////////////////////////////////////////////////////////////////
  //// read-in file
  TFile * f2D;
  if (noPtWeight) f2D = new TFile("../FittingResult/totalHist_pA_8rap9pt_newcut_nominal_Zvtx1_SF1_etOpt0_noPtWeight.root");
  else f2D = new TFile("../FittingResult/totalHist_pA_8rap9pt_newcut_nominal_Zvtx1_SF1_etOpt0.root");
  //// read-in 2D hist
  TH2D* h2D_CorrY;
  if (isPrompt) h2D_CorrY = (TH2D*)f2D->Get("h2D_CorrY_PR_pA");
  else h2D_CorrY = (TH2D*)f2D->Get("h2D_CorrY_NP_pA");
  h2D_CorrY->SetName("h2D_CorrY");  
  const int nbinsX = h2D_CorrY->GetNbinsX();
  const int nbinsY = h2D_CorrY->GetNbinsY();
  if (nbinsX != nRap) { cout << " *** Error!!! nbinsX != nRap"; return; };
  if (nbinsY != nPt) { cout << " *** Error!!! nbinsY != nPt"; return; };
  
  //// projection to 1D hist : iy=0 refers to forwards !!! (ordering here)
  TH1D* h1D_CorrY[nRap]; 
  TH1D* h1D_SysErr[nRap];
  for (Int_t iy = 0; iy < nRap; iy++) {
    h1D_CorrY[iy] = h2D_CorrY->ProjectionY(Form("h1D_CorrY_%d",iy),iy+1,iy+1);
    h1D_SysErr[iy] = h2D_SysErr->ProjectionY(Form("h1D_SysErr_%d",iy),iy+1,iy+1);
  }
  
  //////////////////////////////////////////////////////////////////
  //// calculate RFB

  TH1D* h1D_RFB_tmp[nRap]; // CorrYield with merged pT    
  TH1D* h1D_RFB[nRapRFB]; // actual RFB   
  TH1D* h1D_RFBSys_tmp[nRap]; // Sys with merged pT   
  TH1D* h1D_RFBSys[nRapRFB]; // Sys F/B   
  
  //// RFB bin setting
  TString rapAbsArr[nRap];
  for (Int_t iy=0; iy<nRapRFB; iy++) {
    formAbsRapArr(rapArrNumFB[iy+1], rapArrNumFB[iy], &rapAbsArr[iy]);
    cout << iy <<"th rapAbsArr = " << rapAbsArr[iy] << endl;
  }
  Double_t ptArrRFBNum[nPtRFB+1] = {5.0, 6.5, 10., 30.};
  
  //// ex calculation
  for (Int_t iy=0; iy<nRapRFB; iy++) {
    for (Int_t ipt=0; ipt<nPtRFB; ipt++) {
      exlow[iy][ipt] = px[iy][ipt]-ptArrRFBNum[ipt]; 
      exhigh[iy][ipt] = ptArrRFBNum[ipt+1]-px[iy][ipt]; 
      //cout << iy<<"th y, "<<ipt<<"th pt"<<endl;
      //cout << "exlow = "<< exlow[iy][ipt] << endl;
      //cout << "exhigh = " <<exhigh[iy][ipt] << endl;
    }
  }
  
  //// take proper error propagataion for sys (merge pT bins (KYO - byHand))
  double tmpsys01, tmpsys02, tmpsys03;
  double actsys01, actsys02, actsys03;
  for (int iy=0; iy<nRapRFB*2; iy++){
    h1D_RFBSys_tmp[iy]= new TH1D(Form("h1D_RFBSys_tmp_%d",iy),Form("h1D_RFBSys_tmp_%d",iy),nPtRFB,ptArrRFBNum);
    h1D_RFBSys_tmp[iy]->Sumw2();
    actsys01=0; actsys02=0; actsys03=0;
    //// 1) pT 5-6.5 GeV
    tmpsys01=0; tmpsys02=0;tmpsys03=0;
    if (iy==0 || iy==nRapRFB*2-1){
      //// from relative error to absolute error
      //actsys01=h1D_SysErr[iy]->GetBinContent(4);
      actsys01=h1D_SysErr[iy]->GetBinContent(4)*h1D_CorrY[iy]->GetBinContent(4);  
      h1D_RFBSys_tmp[iy]->SetBinContent(1,actsys01);
    } else {
      h1D_RFBSys_tmp[iy]->SetBinContent(1,0.);
    }
    //// 2) pT 6.5-10. GeV
    tmpsys01=0; tmpsys02=0;tmpsys03=0;
    //// from relative error to absolute error
    tmpsys01=h1D_SysErr[iy]->GetBinContent(5)*h1D_CorrY[iy]->GetBinContent(5);  
    tmpsys02=h1D_SysErr[iy]->GetBinContent(6)*h1D_CorrY[iy]->GetBinContent(6);  
    tmpsys03=h1D_SysErr[iy]->GetBinContent(7)*h1D_CorrY[iy]->GetBinContent(7);  
    //actsys02=TMath::Sqrt( TMath::Power(tmpsys01,2) + TMath::Power(tmpsys02,2) +TMath::Power(tmpsys03,2) );
    actsys02= TMath::Abs(tmpsys01) + TMath::Abs(tmpsys02) +TMath::Abs(tmpsys03) ;
    h1D_RFBSys_tmp[iy]->SetBinContent(2,actsys02);
    //// 3) pT 10.-30. GeV
    tmpsys01=0; tmpsys02=0;tmpsys03=0;
    //// from relative error to absolute error
    tmpsys01=h1D_SysErr[iy]->GetBinContent(8)*h1D_CorrY[iy]->GetBinContent(8);  
    tmpsys02=h1D_SysErr[iy]->GetBinContent(9)*h1D_CorrY[iy]->GetBinContent(9);  
    //actsys03=TMath::Sqrt( TMath::Power(tmpsys01,2) + TMath::Power(tmpsys02,2) );
    actsys03= TMath::Abs(tmpsys01) + TMath::Abs(tmpsys02) ;
    h1D_RFBSys_tmp[iy]->SetBinContent(3,actsys03);
  }
  //TCanvas *ctmp = new TCanvas("ctmp","",1200,800); ctmp->Divide(3,2);
  //for (int iy=0; iy<nRapRFB*2; iy++){
  //  ctmp->cd(iy+1);
  //  h1D_RFBSys_tmp[iy]->Draw("");
  //}
  
  //// merge pT bins (KYO - byHand)
  double tmpPRval01, tmpPRerr01, tmpPRval02, tmpPRerr02, tmpPRval03, tmpPRerr03;
  double actPRval01, actPRerr01, actPRval02, actPRerr02, actPRval03, actPRerr03;
  for (int iy=0; iy<nRapRFB*2; iy++){
    h1D_RFB_tmp[iy]= new TH1D(Form("h1D_RFB_tmp_%d",iy),Form("h1D_RFB_tmp_%d",iy),nPtRFB,ptArrRFBNum);
    h1D_RFB_tmp[iy]->Sumw2();
    actPRval01=0; actPRval02=0; actPRval03=0; actPRerr01=0; actPRerr02=0; actPRerr03=0;
    //// 1) pT 5-6.5 GeV
    tmpPRval01=0; tmpPRval02=0;tmpPRval03=0; tmpPRerr01=0; tmpPRerr02=0;tmpPRerr03=0;
    if (iy==0 || iy==nRapRFB*2-1){
      actPRval01=h1D_CorrY[iy]->GetBinContent(4); 
      actPRerr01=h1D_CorrY[iy]->GetBinError(4); 
      h1D_RFB_tmp[iy]->SetBinContent(1,actPRval01);
      h1D_RFB_tmp[iy]->SetBinError(1,actPRerr01);
    } else {
      h1D_RFB_tmp[iy]->SetBinContent(1,0.);
      h1D_RFB_tmp[iy]->SetBinError(1,0.);
    }
    //// 2) pT 6.5-10. GeV
    tmpPRval01=0; tmpPRval02=0;tmpPRval03=0; tmpPRerr01=0; tmpPRerr02=0;tmpPRerr03=0;
    tmpPRval01=h1D_CorrY[iy]->GetBinContent(5); 
    tmpPRerr01=h1D_CorrY[iy]->GetBinError(5); 
    tmpPRval02=h1D_CorrY[iy]->GetBinContent(6); 
    tmpPRerr02=h1D_CorrY[iy]->GetBinError(6); 
    tmpPRval03=h1D_CorrY[iy]->GetBinContent(7); 
    tmpPRerr03=h1D_CorrY[iy]->GetBinError(7); 
    actPRval02=tmpPRval01+tmpPRval02+tmpPRval03;
    actPRerr02=TMath::Sqrt( TMath::Power(tmpPRerr01,2) + TMath::Power(tmpPRerr02,2) +TMath::Power(tmpPRerr03,2) );
    h1D_RFB_tmp[iy]->SetBinContent(2,actPRval02);
    h1D_RFB_tmp[iy]->SetBinError(2,actPRerr02);
    //// 3) pT 10.-30. GeV
    tmpPRval01=0; tmpPRval02=0;tmpPRval03=0; tmpPRerr01=0; tmpPRerr02=0;tmpPRerr03=0;
    tmpPRval01=h1D_CorrY[iy]->GetBinContent(8); 
    tmpPRerr01=h1D_CorrY[iy]->GetBinError(8); 
    tmpPRval02=h1D_CorrY[iy]->GetBinContent(9); 
    tmpPRerr02=h1D_CorrY[iy]->GetBinError(9); 
    actPRval03=tmpPRval01+tmpPRval02;
    actPRerr03=TMath::Sqrt( TMath::Power(tmpPRerr01,2) + TMath::Power(tmpPRerr02,2) );
    h1D_RFB_tmp[iy]->SetBinContent(3,actPRval03);
    h1D_RFB_tmp[iy]->SetBinError(3,actPRerr03);
    //for (int ipt=0; ipt<nPtRFB; ipt++){
    //  cout << iy<<"th rap, pT merged PR CorrYield = " << h1D_RFB_tmp[iy]->GetBinContent(ipt+1) <<endl;
    //}
  }
  //////////////////////////////////////////////////////////////////
  //// actual RFB calculation 
  for (int iy=0; iy<nRapRFB; iy++){
    h1D_RFB[iy] = (TH1D*)h1D_RFB_tmp[iy]->Clone(Form("h1D_RFB_%d",iy));
    h1D_RFB[iy]->Divide(h1D_RFB_tmp[2*nRapRFB-iy-1]); 
  }
  //// sys F/B calculation
  Double_t dummy;
  for (int iy=0; iy<nRapRFB; iy++){
    for (int ipt=0; ipt<nPtRFB; ipt++){
      //eysysrel[iy][ipt] = TMath::Sqrt(h1D_RFBSys_tmp[iy]->GetBinContent(ipt+1)*h1D_RFBSys_tmp[iy]->GetBinContent(ipt+1)+ h1D_RFBSys_tmp[2*nRapRFB-iy-1]->GetBinContent(ipt+1)*h1D_RFBSys_tmp[2*nRapRFB-iy-1]->GetBinContent(ipt+1)); 
      DivideValue(h1D_RFB_tmp[iy]->GetBinContent(ipt+1),h1D_RFBSys_tmp[iy]->GetBinContent(ipt+1),h1D_RFB_tmp[2*nRapRFB-iy-1]->GetBinContent(ipt+1),h1D_RFBSys_tmp[2*nRapRFB-iy-1]->GetBinContent(ipt+1),&dummy,&eysys[iy][ipt]);
      //cout << "FW bin = " << h1D_RFBSys_tmp[iy]->GetBinContent(ipt+1) << endl;
      //cout << "BW bin = " << h1D_RFBSys_tmp[2*nRapRFB-iy-1]->GetBinContent(ipt+1) << endl;
      //cout << "dummy = " << dummy << endl;
      //cout << "eysys["<<iy<<"]["<<ipt<<"] = " << eysys[iy][ipt] << endl;
    }
  }
  //////////////////////////////////////////////////////////////////

  TLegend *legBR = new TLegend(0.50, 0.18, 0.70, 0.39);
  SetLegendStyle(legBR);
  legBR->SetTextSize(0.05);
    
  TLatex* globtex = new TLatex();
  globtex->SetNDC();
  globtex->SetTextAlign(12); //1:left, 2:vertical center
  //globtex->SetTextAlign(32); //3:right 2:vertical center
  globtex->SetTextFont(42);
  globtex->SetTextSize(0.04);

  //TCanvas* c1 = new TCanvas("c1","c1",600,600);
  //c1->cd();
  
  //////////////////////////////////////////////////////////////////
  //// convert to TGraphAsymErrors
  const int fw_init = 0;
  
  //// 1) sys graph
  TGraphAsymmErrors*gRFB_sys[nRapRFB]; 
  for (int iy=0; iy<nRapRFB; iy++){
    gRFB_sys[iy] = new TGraphAsymmErrors(h1D_RFB[iy]);
    gRFB_sys[iy] -> SetName(Form("gRFB_sys_%d",iy));
    for (int ipt=0; ipt<nPtRFB; ipt++){
      gRFB_sys[iy]->GetPoint(ipt, pxtmp[iy][ipt], pytmp[iy][ipt]);
      gRFB_sys[iy]->SetPoint(ipt, px[iy][ipt], pytmp[iy][ipt]);
      //// absolute err calculation
      //eysys[iy][ipt]=eysysrel[iy][ipt]*pytmp[iy][ipt];
      //gRFB_sys[iy]->SetPointError(ipt, exsys[ipt], exsys[ipt], eysys[iy][ipt], eysys[iy][ipt]);
      gRFB_sys[iy]->SetPointError(ipt, exlow[iy][ipt], exhigh[iy][ipt], eysys[iy][ipt], eysys[iy][ipt]);
    }
    gRFB_sys[iy]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
    gRFB_sys[iy]->GetXaxis()->CenterTitle();
    gRFB_sys[iy]->GetYaxis()->SetTitle("R_{FB}");
    gRFB_sys[iy]->GetYaxis()->CenterTitle();
    gRFB_sys[iy]->GetXaxis()->SetLimits(0.,32.0);
    gRFB_sys[iy]->SetMinimum(0.0);
    gRFB_sys[iy]->SetMaximum(1.8);
  }
  
  gRFB_sys[0]->SetFillColorAlpha(kGreen-10,0.5);
  gRFB_sys[1]->SetFillColorAlpha(kRed-10,0.5);
  gRFB_sys[2]->SetFillColorAlpha(kBlue-10,0.5);
  gRFB_sys[0]->SetLineColor(kGreen+3);
  gRFB_sys[1]->SetLineColor(kPink-6);
  gRFB_sys[2]->SetLineColor(kBlue-3);

  //// 2) RFB graph
  TGraphAsymmErrors*gRFB[nRapRFB]; 
  for (int iy=0; iy<nRapRFB; iy++){
    gRFB[iy] = new TGraphAsymmErrors(h1D_RFB[iy]);
    gRFB[iy] -> SetName(Form("gRFB_%d",iy));
    cout << "::: for excel ::: iy= " << iy << endl;
    for (int ipt=0; ipt<nPtRFB; ipt++){
      gRFB[iy]->GetPoint(ipt, pxtmp[iy][ipt], pytmp[iy][ipt]);
      eytmp[iy][ipt] = gRFB[iy]-> GetErrorY(ipt);
      gRFB[iy]->SetPoint(ipt, px[iy][ipt], pytmp[iy][ipt]);
      gRFB[iy]->SetPointEXlow(ipt, ex[iy]);
      gRFB[iy]->SetPointEXhigh(ipt, ex[iy]);
      cout << pytmp[iy][ipt] <<"\t"<<eytmp[iy][ipt] << "\t "<<eysys[iy][ipt]<<endl;
    }
  }
  SetGraphStyleFinal(gRFB[0], 0, 5); //1.5-1.93
  SetGraphStyleFinal(gRFB[1], 1, 3); //0.9-1.5
  SetGraphStyleFinal(gRFB[2], 2, 0); //0-0.9
  gRFB[0]->SetMarkerSize(2.6);
  gRFB[1]->SetMarkerSize(1.4);
  gRFB[2]->SetMarkerSize(1.4);

  ///////////////// CANVAS 1  
  TCanvas* c1 = new TCanvas("c1","c1",600,600);
  c1->cd(); 
  gRFB_sys[0]->Draw("A5");
  solidLine(0.,1.,32.,1.,1,1);
  gRFB[0]->Draw("P");
  
  TLegendEntry *le1=legBR->AddEntry("le1",Form("  %s", rapAbsArr[2].Data()),"lpf");
  le1->SetFillColorAlpha(kBlue-10,0.5);
  le1->SetFillStyle(1001);
  le1->SetLineColor(kBlue-3);
  le1->SetMarkerStyle(kFullCircle);
  le1->SetMarkerColor(kBlue-3);
  le1->SetMarkerSize(2.1);
  TLegendEntry *le2=legBR->AddEntry("le2",Form("  %s", rapAbsArr[1].Data()),"lpf");
  le2->SetFillColorAlpha(kRed-10,0.5);
  le2->SetFillStyle(1001);
  le2->SetLineColor(kPink-6);
  le2->SetMarkerStyle(kFullSquare);
  le2->SetMarkerColor(kPink-6);
  le2->SetMarkerSize(2.1);
  TLegendEntry *le3=legBR->AddEntry("le3",Form("  %s", rapAbsArr[0].Data()),"lpf");
  le3->SetFillColorAlpha(kGreen-10,0.5);
  le3->SetFillStyle(1001);
  le3->SetLineColor(kGreen+3);
  le3->SetMarkerStyle(kFullDiamond);
  le3->SetMarkerColor(kGreen+3);
  le3->SetMarkerSize(3.3);

  //legBR->Draw();

  globtex->SetTextAlign(32); //3:right 2:vertical center
  globtex->SetTextFont(42);
  globtex->SetTextSize(0.05);
  globtex->DrawLatex(0.9, 0.23, rapAbsArr[0].Data());
  
  globtex->SetTextAlign(12); //1:left, 2:vertical center
  globtex->SetTextSize(0.055);
  globtex->SetTextFont(42);
  if (isPrompt) globtex->DrawLatex(0.21, 0.84, "Prompt J/#psi");
  else globtex->DrawLatex(0.21, 0.84, "Nonprompt J/#psi");

  CMS_lumi( c1, isPA, iPos );
  c1->Update();
  
  if (noPtWeight) { 
    c1->SaveAs(Form("plot_RFB/RFB_pt_mergedBin_isPrompt%d_noPtWeight_rap1.pdf",(int)isPrompt));
    c1->SaveAs(Form("plot_RFB/RFB_pt_mergedBin_isPrompt%d_noPtWeight_rap1.png",(int)isPrompt));
  } else {
    c1->SaveAs(Form("plot_RFB/RFB_pt_mergedBin_isPrompt%d_rap1.pdf",(int)isPrompt));
    c1->SaveAs(Form("plot_RFB/RFB_pt_mergedBin_isPrompt%d_rap1.png",(int)isPrompt));
  }

  ///////////////// CANVAS 2  
  
  TCanvas* c2 = new TCanvas("c2","c2",600,600);
  c2->cd();
  gRFB_sys[1]->Draw("A5");
  solidLine(0.,1.,32.,1.,1,1);
  gRFB[1]->Draw("P");
  //legBR->Draw();
  
  globtex->SetTextAlign(32); //3:right 2:vertical center
  globtex->SetTextFont(42);
  globtex->SetTextSize(0.05);
  globtex->DrawLatex(0.9, 0.23, rapAbsArr[1].Data());
  
  globtex->SetTextAlign(12); //1:left, 2:vertical center
  globtex->SetTextSize(0.055);
  globtex->SetTextFont(42);
  if (isPrompt) globtex->DrawLatex(0.21, 0.84, "Prompt J/#psi");
  else globtex->DrawLatex(0.21, 0.84, "Nonprompt J/#psi");
  
  CMS_lumi( c2, isPA, iPos );
  c2->Update();
 
  if (noPtWeight) { 
    c2->SaveAs(Form("plot_RFB/RFB_pt_mergedBin_isPrompt%d_noPtWeight_rap2.pdf",(int)isPrompt));
    c2->SaveAs(Form("plot_RFB/RFB_pt_mergedBin_isPrompt%d_noPtWeight_rap2.png",(int)isPrompt));
  } else {
    c2->SaveAs(Form("plot_RFB/RFB_pt_mergedBin_isPrompt%d_rap2.pdf",(int)isPrompt));
    c2->SaveAs(Form("plot_RFB/RFB_pt_mergedBin_isPrompt%d_rap2.png",(int)isPrompt));
  }

  
  ///////////////// CANVAS 3  
  
  TCanvas* c3 = new TCanvas("c3","c3",600,600);
  c3->cd();
  gRFB_sys[2]->Draw("A5");
  solidLine(0.,1.,32.,1.,1,1);
  gRFB[2]->Draw("P");
  ///legBR->Draw();
  
  globtex->SetTextAlign(32); //3:right 2:vertical center
  globtex->SetTextFont(42);
  globtex->SetTextSize(0.05);
  globtex->DrawLatex(0.9, 0.23, rapAbsArr[2].Data());

  globtex->SetTextAlign(12); //1:left, 2:vertical center
  globtex->SetTextSize(0.055);
  globtex->SetTextFont(42);
  if (isPrompt) globtex->DrawLatex(0.21, 0.84, "Prompt J/#psi");
  else globtex->DrawLatex(0.21, 0.84, "Nonprompt J/#psi");

  CMS_lumi( c3, isPA, iPos );
  c3->Update();

  if (noPtWeight) { 
    c3->SaveAs(Form("plot_RFB/RFB_pt_mergedBin_isPrompt%d_noPtWeight_rap3.pdf",(int)isPrompt));
    c3->SaveAs(Form("plot_RFB/RFB_pt_mergedBin_isPrompt%d_noPtWeight_rap3.png",(int)isPrompt));
  } else {
    c3->SaveAs(Form("plot_RFB/RFB_pt_mergedBin_isPrompt%d_rap3.pdf",(int)isPrompt));
    c3->SaveAs(Form("plot_RFB/RFB_pt_mergedBin_isPrompt%d_rap3.png",(int)isPrompt));
  }
  
  ///////////////////////////////////////////////////////////////////
  //// save as a root file
  TFile *outFile;
  if (noPtWeight) outFile = new TFile(Form("plot_RFB/RFB_pt_mergedBin_isPrompt%d_noPtWeight.root",(int)isPrompt),"RECREATE");
  else outFile = new TFile(Form("plot_RFB/RFB_pt_mergedBin_isPrompt%d.root",(int)isPrompt),"RECREATE");
  outFile->cd();
  for (int iy=0; iy<nRapRFB; iy++){
    gRFB_sys[iy]->Write();  
    gRFB[iy]->Write();  
  }
  outFile->Close();
  
  return;

} // end of main func.
Exemplo n.º 4
0
void comp_RpPb_rap_Overlay(bool isPoint=true, bool isSmoothened=false)
{
	gROOT->Macro("./tdrstyle_kyo.C");
	int isPA = 10;  // 0:pp, 1:pPb, 10 : pp & pPb together for RpPb plot
	int iPos=33;

  bool isPrompt=true;
	
  const Double_t pp_lumi_relerr = 0.023; // 2.3 %
  const Double_t pPb_lumi_relerr = 0.035; // 3.5 %
  const Double_t glb_err = TMath::Sqrt(pp_lumi_relerr*pp_lumi_relerr+pPb_lumi_relerr*pPb_lumi_relerr);
  //cout << "glb_err = " << glb_err << endl;
  
  ///////////////////////////////////////////////////
  const int nRap = 8; 
  const int nRapTmp = nRap + 1;
	const int nRapRpPb = 7;
	const int nRapRpPbTheory = 6; //Ramona..
	//const int nPtRpPb = 49;
	const int nPtRpPb = 2;
  Double_t theory_px[nPtRpPb][nRapRpPbTheory]; 
	Double_t theory_py[nPtRpPb][nRapRpPbTheory];
	//Double_t theory_exlow_tmp[nPtRpPb][nRapRpPbTheory];
	//Double_t theory_exhigh_tmp[nPtRpPb][nRapRpPbTheory];
  Double_t theory_exlow[nPtRpPb][nRapRpPbTheory];
  Double_t theory_exhigh[nPtRpPb][nRapRpPbTheory];
	Double_t theory_eylow_tmp[nPtRpPb][nRapRpPbTheory];
	Double_t theory_eyhigh_tmp[nPtRpPb][nRapRpPbTheory];
  Double_t theory_eylow[nPtRpPb][nRapRpPbTheory];
	Double_t theory_eyhigh[nPtRpPb][nRapRpPbTheory];
  
  //// 1) y_CM array (from forward to backward)
  Double_t rapArrNumFB[nRapTmp] = {1.93, 1.5, 0.9, 0., -0.9, -1.5, -1.93, -2.4, -2.87};// for pt dist.
  //Double_t rapArrNumBF[nRapTmp] = {-2.87, -2.4, -1.93, -1.5, -0.9, 0., 0.9, 1.5, 1.93};// for rap dist.
  //// array string
  TString rapArr[nRap];
  for (Int_t iy=0; iy<nRap; iy++) {
    formRapArr(rapArrNumFB[iy+1], rapArrNumFB[iy], &rapArr[iy]);
    cout << iy <<"th rapArr = " << rapArr[iy] << endl;
  }
  
	///////////////////////////////////////////////////
  //////// experimental points	
  TFile *inFile = new TFile("../DrawFinalPlot/plot_RpPb/RpPb_rap_isPrompt1.root");
  
  TGraphAsymmErrors* g_RpPb_sys[nRapRpPb];
  TGraphAsymmErrors* g_RpPb_sys_line[nRapRpPb];
  TGraphAsymmErrors* g_RpPb[nRapRpPb];
  g_RpPb_sys[0] = (TGraphAsymmErrors*)inFile->Get("g_RpPb_sys_lowpt");
  g_RpPb_sys_line[0] = (TGraphAsymmErrors*)inFile->Get("g_RpPb_sys_lowpt_line");
  g_RpPb[0] = (TGraphAsymmErrors*)inFile->Get("g_RpPb_lowpt");
  g_RpPb_sys[1] = (TGraphAsymmErrors*)inFile->Get("g_RpPb_sys_highpt");
  g_RpPb_sys_line[1] = (TGraphAsymmErrors*)inFile->Get("g_RpPb_sys_highpt_line");
  g_RpPb[1] = (TGraphAsymmErrors*)inFile->Get("g_RpPb_highpt");
  g_RpPb_sys[0]->SetName("g_RpPb_sys_lowpt");
  g_RpPb_sys_line[0]->SetName("g_RpPb_sys_lowpt_line");
  g_RpPb_sys[1]->SetName("g_RpPb_sys_highpt");
  g_RpPb_sys_line[1]->SetName("g_RpPb_sys_highpt_line");
  //g_RpPb_sys[0]->SetFillColorAlpha(kRed-10,0.5);
  //g_RpPb_sys_line[0]->SetFillColorAlpha(kRed-10,0.);
  //g_RpPb_sys_line[0]->SetLineColor(kPink-6);
  //g_RpPb_sys[1]->SetFillColorAlpha(kGreen-10,0.5);
  //g_RpPb_sys_line[1]->SetFillColorAlpha(kGreen-10,0.);
  //g_RpPb_sys_line[1]->SetLineColor(kGreen+3);
  g_RpPb_sys_line[0]->SetFillColorAlpha(kRed-10,0.);
  g_RpPb_sys_line[1]->SetFillColorAlpha(kRed-10,0.);
  for (int ipt = 0 ; ipt < nPtRpPb; ipt ++ ) {
    if (isPoint) {
      g_RpPb_sys[ipt]->SetFillColorAlpha(kRed-10,0.5);
      g_RpPb_sys[ipt]->SetLineColor(kPink-6);
    } else {
      g_RpPb_sys[ipt]->SetFillColor(kWhite);
      g_RpPb_sys[ipt]->SetLineColor(kWhite);
    }
    g_RpPb[ipt]->SetMarkerColor(kPink-6);
    g_RpPb[ipt]->SetLineColor(kPink-6);
    g_RpPb[ipt]->SetMarkerStyle(kFullCircle);
    g_RpPb[ipt]->SetMarkerSize(1.4);
  }
  
  ///////////////////////////////////////////////////
  //////// theory curves	
//  const int nTheory = 4;
  const int nTheory = 3;
  TFile *inFileTh[nTheory];
  inFileTh[0]= new TFile("./plot_theory/comp_RpPb_rap_isSmoothened0_Vogt.root","READ");
  inFileTh[1]= new TFile("./plot_theory/comp_RpPb_rap_isSmoothened0_Lansberg_EPS09NLO.root","READ");
  inFileTh[2]= new TFile("./plot_theory/comp_RpPb_rap_isSmoothened0_Lansberg_nCTEQ15.root","READ");
  
  TGraphAsymmErrors* g_RpPb_theory[nTheory][nPtRpPb];
  TGraphAsymmErrors* g_RpPb_theory_line[nTheory][nPtRpPb];
  for (int ith = 0 ; ith < nTheory; ith ++ ) {
    for (int ipt = 0 ; ipt < nPtRpPb; ipt ++ ) {
      g_RpPb_theory[ith][ipt] = (TGraphAsymmErrors*)inFileTh[ith]->Get(Form("g_RpPb_theory_%d",ipt));
      g_RpPb_theory[ith][ipt]->SetName(Form("g_RpPb_theory_%d_%d",ith,ipt));
      g_RpPb_theory_line[ith][ipt] = (TGraphAsymmErrors*)inFileTh[ith]->Get(Form("g_RpPb_theory_%d",ipt));
      g_RpPb_theory_line[ith][ipt]->SetName(Form("g_RpPb_theory_line_%d_%d",ith,ipt));
    } 
  } 

  //// color
  for (int ipt = 0 ; ipt < nPtRpPb; ipt ++ ) {
    g_RpPb_theory[0][ipt]->SetFillColorAlpha(kAzure+1,0.5);
    g_RpPb_theory[0][ipt]->SetLineColor(kAzure+1);
    g_RpPb_theory[0][ipt]->SetFillStyle(1001);
    g_RpPb_theory_line[0][ipt]->SetFillColorAlpha(kAzure+5,0.0);
    g_RpPb_theory_line[0][ipt]->SetLineColor(kAzure+5);
    g_RpPb_theory_line[0][ipt]->SetFillStyle(1001);
    g_RpPb_theory[1][ipt]->SetFillColor(kOrange+2);
    g_RpPb_theory[1][ipt]->SetLineColor(kOrange+2);
    g_RpPb_theory[1][ipt]->SetFillStyle(3345);
    //g_RpPb_theory[1][ipt]->SetFillStyle(3004);
    g_RpPb_theory_line[1][ipt]->SetFillColorAlpha(kOrange+2,0.);
    g_RpPb_theory_line[1][ipt]->SetLineColor(kOrange+2);
    g_RpPb_theory_line[1][ipt]->SetFillStyle(1001);
    g_RpPb_theory[2][ipt]->SetFillColor(kGreen+2);
    g_RpPb_theory[2][ipt]->SetLineColor(kGreen+2);
    g_RpPb_theory[2][ipt]->SetFillStyle(3454);
    //g_RpPb_theory[2][ipt]->SetFillStyle(3005);
    g_RpPb_theory_line[2][ipt]->SetFillColorAlpha(kGreen+2,0.);
    g_RpPb_theory_line[2][ipt]->SetLineColor(kGreen+2);
    g_RpPb_theory_line[2][ipt]->SetFillStyle(1001);
  } 
	///////////////////////////////////////////////////
	//// Draw
  ///////////////////////////////////////////////////
	
	//TLegend *legBL1 = new TLegend(0.195, 0.168, 0.38, 0.333);
	TLegend *legBL1 = new TLegend(0.195, 0.168, 0.38, 0.388);
	SetLegendStyle(legBL1);
	//legBL1->SetTextSize(0.05);
	legBL1->SetTextSize(0.037);
  
  TLatex* globtex = new TLatex();
	globtex->SetNDC();
	globtex->SetTextAlign(12); //1:left, 2:vertical center
  //globtex->SetTextAlign(32); //3:right 2:vertical center
  globtex->SetTextFont(42);
	globtex->SetTextSize(0.075);
 
  //// global uncertainty from lumi
	TBox * globbox_pp = new TBox(-3.0, 1-pp_lumi_relerr, -2.8, 1+pp_lumi_relerr);
	globbox_pp->SetFillColorAlpha(kGray+2,0.5);
	globbox_pp->SetLineColor(kBlack);
	TBox * globbox_pa = new TBox(-2.8, 1-pPb_lumi_relerr, -2.6, 1+pPb_lumi_relerr);
	globbox_pa->SetFillColorAlpha(kWhite,0.5);
	globbox_pa->SetLineColor(kBlack);
	TBox * globbox_all = new TBox(-2.7, 1-glb_err, -2.5, 1+glb_err);
	globbox_all->SetFillColorAlpha(kGray+2,0.5);
	globbox_all->SetLineColor(kBlack);

  TCanvas* c1 = new TCanvas("c1","c1",600,600);
  c1->cd();
  
  g_RpPb_sys[0]->Draw("A5"); 
  for (int ith = 0 ; ith < nTheory; ith ++ ) {
    if (ith==0){
      g_RpPb_theory[ith][0]->Draw("5");
      g_RpPb_theory_line[ith][0]->Draw("5");
    }
  }
//  if (isPoint) { g_RpPb_sys[0]->Draw("5"); }
  globbox_all->Draw("lf");
  solidLine(-2.7,1.,2.1,1.,1,1);
  for (int ith = 0 ; ith < nTheory; ith ++ ) {
    if (ith!=0){
      g_RpPb_theory[ith][0]->Draw("5");
    }
    g_RpPb_theory_line[ith][0]->Draw("5");
  }
  if (isPoint) {
    g_RpPb_sys_line[0]->Draw("5");
    g_RpPb[0]->Draw("p");
  }

  globtex->SetTextAlign(12);
	globtex->SetTextSize(0.045);
	globtex->SetTextFont(42);
  globtex->DrawLatex(0.21, 0.84, "6.5 < p_{T} < 10 GeV/c");
  
  TLegendEntry *ent_data=legBL1->AddEntry("ent_data"," Data","pf");
	ent_data->SetFillColorAlpha(kRed-10,0.5);
	ent_data->SetLineColor(kPink-6);
	ent_data->SetMarkerColor(kPink-6);
  ent_data->SetMarkerStyle(kFullCircle);
  ent_data->SetLineWidth(1);
//  ent_data->SetMarkerSize(1.9);
  ent_data->SetFillStyle(1001);
  TLegendEntry *ent1_thr=legBL1->AddEntry("ent1_thr"," EPS09 NLO (Vogt)","f");
	ent1_thr->SetFillColorAlpha(kAzure+1,0.5);
	ent1_thr->SetLineColor(kAzure+5);
  ent1_thr->SetFillStyle(1001);
  TLegendEntry *ent2_thr=legBL1->AddEntry("ent2_thr"," EPS09 NLO (Lansberg-Shao)","f");
	ent2_thr->SetFillColor(kOrange+2);
	ent2_thr->SetLineColor(kOrange+2);
  ent2_thr->SetFillStyle(3345);
  TLegendEntry *ent3_thr=legBL1->AddEntry("ent3_thr"," nCTEQ15 NLO (Lansberg-Shao)","f");
	ent3_thr->SetFillColor(kGreen+2);
	ent3_thr->SetLineColor(kGreen+2);
  ent3_thr->SetFillStyle(3454);
//  TLegendEntry *ent5_thr=legBL1->AddEntry("ent5_thr","(Lansberg-Shao)","f");
//	ent5_thr->SetFillColor(kWhite);
//	ent5_thr->SetLineColor(kWhite);
//  ent5_thr->SetFillStyle(1001);
	legBL1->Draw();

  globtex->SetTextAlign(32); //3:right 2:vertical center	
  globtex->SetTextSize(0.048);
	globtex->SetTextFont(42);
	if (isPrompt) globtex->DrawLatex(0.92, 0.77, "Prompt J/#psi");
	else globtex->DrawLatex(0.92, 0.77, "Non-prompt J/#psi");
	
  CMS_lumi( c1, isPA, iPos );
    
  c1->SaveAs(Form("plot_theory/comp_RpPb_rap_pt1_isSmoothened%d_Overlay.pdf",(int)isSmoothened));
  c1->SaveAs(Form("plot_theory/comp_RpPb_rap_pt1_isSmoothened%d_Overlay.png",(int)isSmoothened));
 
 
  TCanvas* c2 = new TCanvas("c2","c2",600,600);
  c2->cd();
  
  g_RpPb_sys[1]->Draw("A5"); 
  for (int ith = 0 ; ith < nTheory; ith ++ ) {
    if (ith==0){
      g_RpPb_theory[ith][1]->Draw("5");
      g_RpPb_theory_line[ith][1]->Draw("5");
    }
  }
//  if (isPoint) { g_RpPb_sys[1]->Draw("5"); }
  globbox_all->Draw("lf");
  solidLine(-2.7,1.,2.1,1.,1,1);
  for (int ith = 0 ; ith < nTheory; ith ++ ) {
    if (ith!=0){
      g_RpPb_theory[ith][1]->Draw("5");
    }
    g_RpPb_theory_line[ith][1]->Draw("5");
  }
  if (isPoint) {
    g_RpPb_sys_line[1]->Draw("5");
    g_RpPb[1]->Draw("p");
  }
  
  globtex->SetTextAlign(12);
	globtex->SetTextSize(0.045);
	globtex->SetTextFont(42);
  globtex->DrawLatex(0.21, 0.84, "10 < p_{T} < 30 GeV/c");
  
  legBL1->Draw();
  
  globtex->SetTextAlign(32); //3:right 2:vertical center	
  globtex->SetTextSize(0.048);
	globtex->SetTextFont(42);
	if (isPrompt) globtex->DrawLatex(0.92, 0.77, "Prompt J/#psi");
	else globtex->DrawLatex(0.92, 0.77, "Non-prompt J/#psi");
	
  CMS_lumi( c2, isPA, iPos );
    
  c2->SaveAs(Form("plot_theory/comp_RpPb_rap_pt2_isSmoothened%d_Overlay.pdf",(int)isSmoothened));
  c2->SaveAs(Form("plot_theory/comp_RpPb_rap_pt2_isSmoothened%d_Overlay.png",(int)isSmoothened));
 
 
 
  
  ///////////////////////////////////////////////////////////////////
  // save as a root file
//  TFile* outFile = new TFile(Form("plot_theory/comp_RpPb_rap_isSmoothened%d_Overlay.root",(int)isSmoothened),"RECREATE");
//  outFile->cd();
//  for (int ipt = 0 ; ipt < nPtRpPb; ipt ++ ) {
//    g_RpPb_theory[ipt]->Write();
//  } 

  return;
}