Ejemplo n.º 1
0
//// runCode // 0=merged, 1=1stRun, 2=2ndRun
void draw_1D_RFB_rap(char* dirName = "8rap9pt2gev", int runCode=0, bool isPrompt = true)
{
	//gROOT->Macro("./JpsiStyleForFinalResult.C");
	gROOT->Macro("./tdrstyle_kyo.C");
	gStyle->SetTitleSize(0.046, "XYZ");
  gStyle->SetEndErrorSize(0);
// Margins:
/*
//  gStyle->SetPadTopMargin(0.05);
  gStyle->SetPadBottomMargin(0.132); //KYO
  gStyle->SetPadLeftMargin(0.132); //KYO
  //gStyle->SetPadRightMargin(0.04);
*/	
	gStyle->SetOptTitle(0);
  gStyle->SetPadTopMargin(0.075);
  gStyle->SetPadBottomMargin(0.13); //KYO
  gStyle->SetPadLeftMargin(0.13); //KYO
  gStyle->SetPadRightMargin(0.075);
	gStyle->SetTitleXOffset(1.15);
	gStyle->SetTitleYOffset(1.22);
	
	writeExtraText = true;
	extraText  = "Preliminary";
	lumi_502TeV  = "34.6 nb^{-1}";
	int iPeriod = 0; 
	int iPos=0;

	double pxshift = 0.06;

	// set info.
	const Double_t br = 0.0593 ;
	const Double_t brErr = 0.0006;
	Double_t lumi_nb;
	Double_t lumi_nb_err;
	Double_t lumi_mub;
	Double_t lumi_mub_err;
	string runstring;
	string lumistring;
	string cmsstring = "CMS preliminary";
	string beamstring = "pPb #sqrt{s_{NN}} = 5.02 TeV";
	if (runCode ==0) { runstring = "All"; lumi_nb =34.622; lumi_nb_err=1.2; }
	else if (runCode == 1) { runstring = "Pbp"; lumi_nb =20.7; lumi_nb_err=0.7; }//1stRun
	else if (runCode == 2) { runstring = "pPb"; lumi_nb = 14.0; lumi_nb_err=0.5; }//2ndRun
	else { cout << " *** Error!!! choose runCode 0, 1, or 2 " << endl; return ; }
	lumistring = Form("L_{int} = %.1f nb^{  -1}", lumi_nb);
	lumi_mub = lumi_nb * 1000; // (nb)^{-1} -> {#mub}^{-1}
	lumi_mub_err = lumi_nb_err * 1000; // (nb)^{-1} -> {#mub}^{-1}

	/////////////////////////////////////////////////////////////////////////
	/// systematic uncertainties by hand KYO
	const int nRap = 8;
	const int nPt = 9;
	const int nRapTmp = nRap + 1;
	const int nPtTmp = nPt + 1;
	const int nRapRFB=3;
	Double_t pxtmp_lowpt[nRapRFB]; // x point to fill tmp
	Double_t pxtmp_highpt[nRapRFB]; // x point to fill tmp
	Double_t pytmp_lowpt[nRapRFB]; // y point to fill tmp
	Double_t pytmp_highpt[nRapRFB]; // y point to fill tmp
	Double_t eytmp[nRapRFB]; // y point error to fill tmp
	Double_t ex[nRapRFB] = {0.0, 0.0, 0.0}; //x stat error
	Double_t exsys[nRapRFB] = {0.03, 0.03, 0.03}; //sys x error
	Double_t eysys_lowpt[nRapRFB]; //absolute y sys error
	Double_t eysys_highpt[nRapRFB]; //absolute y sys error
	Double_t eysysrelPR_lowpt[nRapRFB] = { //relative y sys error
		0.04694, //0-0.9
		0.04245, //0.9-1.5
		0.04795}; //1.5-1.93; 
	Double_t eysysrelNP_lowpt[nRapRFB] = {
		0.07412,
		0.06288,
		0.10487};
	Double_t eysysrelPR_highpt[nRapRFB] = { //relative y sys error
		0.03705,
		0.03360,
		0.06486};
	Double_t eysysrelNP_highpt[nRapRFB] = { //relative y sys error
		0.04483,
		0.05592,
		0.09280};
	Double_t eysysrel_lowpt[nRapRFB];
	Double_t eysysrel_highpt[nRapRFB];
	for (int iy=0; iy<nRapRFB; iy++){
		if (isPrompt) { 
			eysysrel_lowpt[iy] = eysysrelPR_lowpt[iy];
			eysysrel_highpt[iy] = eysysrelPR_highpt[iy];
		}
		else { 
			eysysrel_lowpt[iy] = eysysrelNP_lowpt[iy];
			eysysrel_highpt[iy] = eysysrelNP_highpt[iy];
		}
	}
			
	//y_CM array (from forward to backward)
	//Double_t rapArrNumFB[] = {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.
//	const Int_t nRap = sizeof(rapArrNumBF)/sizeof(Double_t)-1;
//	cout << "nRap = " << nRap << endl;
	Double_t rapBinW[nRap];
	for (Int_t iy=0; iy<nRap; iy++) {
		//rapBinW[iy] = rapArrNumFB[iy]-rapArrNumFB[iy+1]; 
		rapBinW[iy] = rapArrNumBF[iy+1]-rapArrNumBF[iy]; 
		cout << iy <<"th rapBinW = " << rapBinW[iy] <<endl;
	}
	//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
	string rapArr[nRap];
	for (Int_t iy=0; iy<nRap; iy++) {
		formRapArr(rapArrNumBF[iy], rapArrNumBF[iy+1], &rapArr[iy]);
		cout << iy <<"th rapArr = " << rapArr[iy] << endl;
	}
	string 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 file
	TFile * f2D = new TFile(Form("../fittingResult/total2Dhist_%s.root",dirName));
	cout << "dirName = " << dirName << endl;
	cout << "runCode = " << runCode << ", runstring = " << runstring.c_str() << endl;

	// --- read-in 2D hist for corrected yield
	TH2D* h2D_corrY_Pbp;
	TH2D* h2D_corrY_pPb;
	if (isPrompt) h2D_corrY_Pbp = (TH2D*)f2D->Get("h2D_corrY_PR_Pbp");
	else h2D_corrY_Pbp = (TH2D*)f2D->Get("h2D_corrY_NP_Pbp");
	if (isPrompt) h2D_corrY_pPb = (TH2D*)f2D->Get("h2D_corrY_PR_pPb");
	else h2D_corrY_pPb = (TH2D*)f2D->Get("h2D_corrY_NP_pPb");
	cout << "h2D_corrY_Pbp = " << h2D_corrY_Pbp << endl;
	cout << "h2D_corrY_pPb = " << h2D_corrY_pPb << endl;
	const int nbinsX = h2D_corrY_Pbp->GetNbinsX();
	const int nbinsY = h2D_corrY_Pbp->GetNbinsY();
	cout << "nbinsX = " << nbinsX << endl;
	cout << "nbinsY = " << nbinsY << endl;
	if (nbinsX != nRap) { cout << " *** Error!!! nbinsX != nRap"; return; };
	if (nbinsY != nPt) { cout << " *** Error!!! nbinsY != nPt"; return; };

	// ---  projection to 1D hist
	TH1D* h1D_corrY_Pbp_tmp[nPt]; // in y_lab(1st)
	TH1D* h1D_corrY_Pbp[nPt]; 
	TH1D* h1D_corrY_pPb_tmp[nPt]; // in y_lab(2nd)
	TH1D* h1D_corrY_pPb[nPt]; //in y_CM

	// iy=0 refers to forwards !!! (ordering here && in CM)
	int tmpbin;
	double tmpval=0;
	double tmperr=0;
	for (Int_t ipt = 0; ipt < nPt; ipt++) {
		h1D_corrY_Pbp_tmp[ipt] = h2D_corrY_Pbp->ProjectionX(Form("h1D_corrY_Pbp_tmp_%d",ipt),ipt+1,ipt+1);
		h1D_corrY_pPb_tmp[ipt] = h2D_corrY_pPb->ProjectionX(Form("h1D_corrY_pPb_tmp_%d",ipt),ipt+1,ipt+1);
		h1D_corrY_Pbp[ipt] = new TH1D(Form("h1D_corrY_Pbp_%d",ipt),Form("h1D_corrY_Pbp_%d",ipt),nRap,rapArrNumBF);
		h1D_corrY_pPb[ipt] = new TH1D(Form("h1D_corrY_pPb_%d",ipt),Form("h1D_corrY_pPb_%d",ipt),nRap,rapArrNumBF);
		h1D_corrY_Pbp[ipt]->Sumw2();
		h1D_corrY_pPb[ipt]->Sumw2();
		
		for (Int_t iy=0; iy<nRap; iy++){
			//1st run
			tmpval = h1D_corrY_Pbp_tmp[ipt]->GetBinContent(iy+1);
			tmperr = h1D_corrY_Pbp_tmp[ipt]->GetBinError(iy+1);
			h1D_corrY_Pbp[ipt]->SetBinContent(nRap-iy,tmpval);
			h1D_corrY_Pbp[ipt]->SetBinError(nRap-iy,tmperr);
			//2nd run
			tmpval = h1D_corrY_pPb_tmp[ipt]->GetBinContent(iy+1);
			tmperr = h1D_corrY_pPb_tmp[ipt]->GetBinError(iy+1);
			h1D_corrY_pPb[ipt]->SetBinContent(iy+1,tmpval);
			h1D_corrY_pPb[ipt]->SetBinError(iy+1,tmperr);
		}
	}
	
	//////////////////////////////////////////////////////////////////////////////////////
	// 1) merge Pbp+pPb corrected yield
	
	TH1D* h1D_corrY_tot[nPt]; 
	
	for (Int_t ipt = 0; ipt < nPt; ipt++) {
		// --- merging
		if (runCode ==0) {	
			h1D_corrY_tot[ipt] = (TH1D*)h1D_corrY_Pbp[ipt]->Clone(Form("h1D_corrY_tot_%d",ipt));
			h1D_corrY_tot[ipt]->Add(h1D_corrY_pPb[ipt]);	
		}
		else if (runCode ==1) {
			h1D_corrY_tot[ipt] = (TH1D*)h1D_corrY_Pbp[ipt]->Clone(Form("h1D_corrY_tot_%d",ipt));
		}
		else if (runCode ==2) {
			h1D_corrY_tot[ipt] = (TH1D*)h1D_corrY_pPb[ipt]->Clone(Form("h1D_corrY_tot_%d",ipt));
		}
		cout <<" "<<endl;
		cout <<ipt<<"th pt !!!"<<endl;
		for (int iy=0; iy <nRap; iy ++ ){ 
			cout << iy <<"th rap" << endl;
			cout << "h1D_corrY_tot = " << h1D_corrY_tot[ipt]->GetBinContent(iy+1)<<endl; 
		}		
	}
	//////////////////////////////////////////////////////////////////
	/////////// calculate RFB
	
	const int lowpt_init=4;
	const int highpt_init=7;	

	// *** pt bin merging
	cout << "*** low pT bin starts from : " << ptArr[lowpt_init].c_str() << endl;
	for (Int_t ipt = lowpt_init+1; ipt < highpt_init; ipt++) {
		h1D_corrY_tot[lowpt_init]->Add(h1D_corrY_tot[ipt]);
		cout << " *** and to low pT, merging : " << ptArr[ipt].c_str() << endl; 
	}
	cout << "*** high pT bin starts from : " << ptArr[highpt_init].c_str() << endl;
	for (Int_t ipt = highpt_init+1; ipt < nPt; ipt++) {
		h1D_corrY_tot[highpt_init]->Add(h1D_corrY_tot[ipt]);
		cout << " *** and to high pT, merging : " << ptArr[ipt].c_str() << endl; 
	}
		
	// |yCM| for drawing (actual binning)
	Double_t rapArrRFBNum[nRapRFB+1] = {0., 0.9, 1.5, 1.93};// for rap dist.
	//const Int_t nRapRFB = sizeof(rapArrRFBNum)/sizeof(Double_t)-1;
	//cout << "nRapRFB = " << nRapRFB << endl;

	TH1D* h1D_RFB[nPt]; //byHand	
	int rap_init = 2;

	// actual RFB calculation
	double tmpFWval[nRapRFB], tmpBWval[nRapRFB]; 
	double tmpFWerr[nRapRFB], tmpBWerr[nRapRFB];
	double actval[nRapRFB], acterr[nRapRFB];
	for (Int_t ipt = 0; ipt < nPt; ipt++) {
		if (ipt != lowpt_init && ipt != highpt_init) continue;
		cout << ipt <<"th pt -- actual RFB *** " << endl;
		h1D_RFB[ipt] = new TH1D(Form("h1D_RFB_%d",ipt),Form("h1D_RFB_%d",ipt),nRapRFB,rapArrRFBNum);
		h1D_RFB[ipt]->Sumw2();
		for (int iy=0; iy <nRapRFB; iy ++ ){ 
			cout << iy<< "th RFB calcul" <<endl;
			tmpFWval[iy] = h1D_corrY_tot[ipt]->GetBinContent(nRap-iy); 
			tmpFWerr[iy] = h1D_corrY_tot[ipt]->GetBinError(nRap-iy); 
			tmpBWval[iy] = h1D_corrY_tot[ipt]->GetBinContent(rap_init+iy+1); 
			tmpBWerr[iy] = h1D_corrY_tot[ipt]->GetBinError(rap_init+iy+1); 
			DivideValue(tmpFWval[iy],tmpFWerr[iy],tmpBWval[iy],tmpBWerr[iy],&actval[iy],&acterr[iy]);
			h1D_RFB[ipt]->SetBinContent(nRapRFB-iy,actval[iy]);	
			h1D_RFB[ipt]->SetBinError(nRapRFB-iy,acterr[iy]);	
		}
	}	
	
	//////////////////////////////////////////////////////////////////
	TLegend *legUR = new TLegend(0.52, 0.75, 0.86, 0.92); //upper left
	TLegend *legUL = new TLegend(0.16, 0.75, 0.45, 0.94, NULL, "brNDC");
	//TLegend *legBL = new TLegend(0.17,0.17,0.42,0.38,NULL,"brNDC");
	TLegend *legBL = new TLegend(0.16,0.17,0.42,0.38,NULL,"brNDC");
//	TLegend *legBR = new TLegend(0.54, 0.17, 0.87, 0.39); //upper left
	TLegend *legBR = new TLegend(0.51, 0.17, 0.85, 0.37); //upper left
	SetLegendStyle(legUR);
	SetLegendStyle(legUL);
	SetLegendStyle(legBL);
	SetLegendStyle(legBR);
	legBR->SetTextSize(0.037);
	 	
	//globtex box for beam, rapidity, pT info
	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);

	// --- Draw histograms
		
	// ---- prompt
	TCanvas* c1 = new TCanvas("c1","c1",200,10,600,600);
	c1->cd();
	
	// --- scaling for drawing norm.
//	h1D_RFB[lowpt_init]->Scale(scalePR_lowpt);
//	h1D_RFB[highpt_init]->Scale(scalePR_highpt);
	string ptArr_lowpt;
	string ptArr_highpt;
	formPtArr(ptArrNum[lowpt_init], ptArrNum[highpt_init], &ptArr_lowpt);
	formPtArr(ptArrNum[highpt_init], ptArrNum[nPt], &ptArr_highpt);
	
	//////////////////////////////////////////////
	/// convert to TGraphErrors	
	
	//lowpt
	TGraphAsymmErrors* gRFB_lowpt = new TGraphAsymmErrors(h1D_RFB[lowpt_init]); 
	gRFB_lowpt->SetName("gRFB_lowpt");
	for (int iy=0; iy <nRapRFB; iy ++ ){ 
		gRFB_lowpt->	SetPointEXlow(iy, ex[iy]);
		gRFB_lowpt->	SetPointEXhigh(iy, ex[iy]);
		gRFB_lowpt->GetPoint(iy, pxtmp_lowpt[iy], pytmp_lowpt[iy]);
		eytmp[iy] = gRFB_lowpt-> GetErrorY(iy);
	}	
	
	//sys_lowpt
	TGraphAsymmErrors* gRFB_sys_lowpt = new TGraphAsymmErrors(h1D_RFB[lowpt_init]); 
	gRFB_sys_lowpt->SetName("gRFB_sys_lowpt");
	for (int iy=0; iy <nRapRFB; iy ++ ){ 
		//abs err calcul.
		eysys_lowpt[iy]=eysysrel_lowpt[iy]*pytmp_lowpt[iy];
		gRFB_sys_lowpt->SetPointError(iy, exsys[iy], exsys[iy], eysys_lowpt[iy], eysys_lowpt[iy]);
		cout << "pytmp_lowpt["<<iy<<"] = " << pytmp_lowpt[iy]<<endl;
		cout << "eytmp_lowpt["<<iy<<"] = " << eytmp[iy]<<endl;
		cout << "eysys_lowpt["<<iy<<"] = " << eysys_lowpt[iy]<<endl;
	}	

	//highpt
	TGraphAsymmErrors* gRFB_highpt = new TGraphAsymmErrors(h1D_RFB[highpt_init]); 
	gRFB_highpt->SetName("gRFB_highpt");
	for (int iy=0; iy <nRapRFB; iy ++ ){ 
		gRFB_highpt->	SetPointEXlow(iy, ex[iy]);
		gRFB_highpt->	SetPointEXhigh(iy, ex[iy]);
		gRFB_highpt->GetPoint(iy, pxtmp_highpt[iy], pytmp_highpt[iy]);
		gRFB_highpt->SetPoint(iy, pxtmp_highpt[iy]+pxshift, pytmp_highpt[iy]);
		eytmp[iy] = gRFB_highpt-> GetErrorY(iy);
	}	
	
	//sys_highpt
	TGraphAsymmErrors* gRFB_sys_highpt = new TGraphAsymmErrors(h1D_RFB[highpt_init]); 
	gRFB_sys_highpt->SetName("gRFB_sys_highpt");
	for (int iy=0; iy <nRapRFB; iy ++ ){ 
		//abs err calcul.
		eysys_highpt[iy]=eysysrel_highpt[iy]*pytmp_highpt[iy];
		gRFB_sys_highpt->GetPoint(iy, pxtmp_highpt[iy], pytmp_highpt[iy]);
		gRFB_sys_highpt->SetPoint(iy, pxtmp_highpt[iy]+pxshift, pytmp_highpt[iy]);
		gRFB_sys_highpt->SetPointError(iy, exsys[iy], exsys[iy], eysys_highpt[iy], eysys_highpt[iy]);
		cout << "pytmp_highpt["<<iy<<"] = " << pytmp_highpt[iy]<<endl;
		cout << "eytmp_highpt["<<iy<<"] = " << eytmp[iy]<<endl;
		cout << "eysys_highpt["<<iy<<"] = " << eysys_highpt[iy]<<endl;
	}	
	
	gRFB_sys_lowpt->GetXaxis()->SetTitle("|y_{CM}|");	
	gRFB_sys_lowpt->GetXaxis()->CenterTitle();	
	gRFB_sys_lowpt->GetYaxis()->SetTitle("R_{FB}");	
//	gRFB_sys_lowpt->GetXaxis()->SetLimits(0.,1.93);	
	gRFB_sys_lowpt->GetXaxis()->SetLimits(0.,2.2);	
	//gRFB_sys_lowpt->SetMinimum(0.0);	
	//gRFB_sys_lowpt->SetMaximum(1.4);	
	gRFB_sys_lowpt->SetMinimum(0.5);
	gRFB_sys_lowpt->SetMaximum(1.15);
	gRFB_sys_lowpt->SetFillColor(kRed-9);	
	//gRFB_sys_lowpt->SetFillStyle(3001);
	gRFB_sys_lowpt->Draw("A2");
	
	gRFB_sys_highpt->SetFillColor(kTeal-9);
	//gRFB_sys_highpt->SetFillStyle(3001);
	gRFB_sys_highpt->Draw("2");
	
	SetGraphStyle(gRFB_lowpt, 1, 3);
	gRFB_lowpt->SetMarkerSize(1.2);
	gRFB_lowpt->Draw("P");	
	
	SetGraphStyle(gRFB_highpt, 0, 5);
	gRFB_highpt->SetMarkerSize(1.9);
	gRFB_highpt->Draw("P");	
	
//	dashedLine(0.,1.,1.93,1.,1,1);
	dashedLine(0.,1.,2.2,1.,1,1);
	//if (isPrompt) legBR -> SetHeader("Prompt J/#psi");
	//else legBR -> SetHeader("Non-prompt J/#psi");
	legBR -> AddEntry(gRFB_lowpt,Form("%s",ptArr_lowpt.c_str()));
	legBR -> AddEntry(gRFB_highpt,Form("%s",ptArr_highpt.c_str()));
	legBR->Draw();
//	latex->SetTextSize(0.05);
//	latex->DrawLatex(0.54, 0.35, cmsstring.c_str());	
//	latex->SetTextSize(0.04);
//	latex->DrawLatex(0.56, 0.27, beamstring.c_str());
//	latex->SetTextSize(0.04);
//	latex->DrawLatex(0.56, 0.20, lumistring.c_str());
	globtex->SetTextSize(0.045);
	globtex->SetTextFont(62);
	if (isPrompt) globtex->DrawLatex(0.88, 0.86, "Prompt J/#psi");
	else globtex->DrawLatex(0.88, 0.86, "Non-prompt J/#psi");
	CMS_lumi( c1, iPeriod, iPos );
	c1->Update();
	c1->SaveAs(Form("RFB_%s/RFB_rap_isPrompt%d_%s.pdf",dirName,(int)isPrompt,runstring.c_str()));
	c1->SaveAs(Form("RFB_%s/RFB_rap_isPrompt%d_%s.png",dirName,(int)isPrompt,runstring.c_str()));
	
	///////////////////////////////////////////////////////////////////
	// save as a root file
	TFile *outFile = new TFile(Form("RFB_%s/RFB_rap_isPrompt%d.root",dirName,(int)isPrompt),"RECREATE");
	outFile->cd();
	gRFB_sys_lowpt->Write();	
	gRFB_lowpt->Write();	
	gRFB_sys_highpt->Write();	
	gRFB_highpt->Write();	
	outFile->Close();
	
	
	return;

} // end of main func.
Ejemplo n.º 2
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.
Ejemplo n.º 3
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;

}
Ejemplo n.º 4
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;

}