//// 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.
void plot_eff(void){ double Eff_Zee_XML[] = {39.7214,38.8696,93.6765,51.5404,13.719}; double Eff_Zee_XML_err[] = {0.252063,0.251102,0.125374,0.257442,0.177229}; double Eff_Zuu_XML[] = {40.1903,39.4074,94.1036,51.6524,13.849}; double Eff_Zuu_XML_err[] = {0.232544,0.23177,0.111726,0.237024,0.163832}; double Eff_Zee_EML[] = {45.5494,43.2493,88.7815,64.0103,20.0086}; double Eff_Zee_EML_err[] = {0.460514,0.458115,0.291829,0.443827,0.369938}; double Eff_Zuu_EML[] = {46.0007,43.3616,89.3255,64.1872,19.5724}; double Eff_Zuu_EML_err[] = {0.427924,0.425499,0.265126,0.411655,0.340655}; double Eff_Zee_FML[] = {37.0989,36.8988,95.8792,45.9292,10.8888}; double Eff_Zee_FML_err[] = {0.299645,0.29931,0.123296,0.309117,0.19322}; double Eff_Zuu_FML[] = {37.6384,37.6708,96.2022,46.1471,11.3352}; double Eff_Zuu_FML_err[] = {0.275672,0.275719,0.108763,0.283659,0.180389}; double Eff_Zee_XLH[] = {30.8201,35.0276,94.0576,12.4058,4.30321}; double Eff_Zee_XLH_err[] = {0.161678,0.167037,0.0827788,0.115423,0.0710539}; double Eff_Zuu_XLH[] = {31.1368,35.2342,94.1469,12.3076,4.33464}; double Eff_Zuu_XLH_err[] = {0.148723,0.153428,0.0753954,0.105516,0.0654037}; double Eff_Zee_ELH[] = {32.3647,35.6655,89.6553,26.6593,8.96672}; double Eff_Zee_ELH_err[] = {0.293989,0.300992,0.191362,0.277847,0.179525}; double Eff_Zuu_ELH[] = {32.3288,35.3524,89.9079,26.6647,8.94981}; double Eff_Zuu_ELH_err[] = {0.271104,0.277093,0.174594,0.256309,0.165458}; double Eff_Zee_FLH[] = {30.1245,34.7404,96.0402,5.98684,2.20306}; double Eff_Zee_FLH_err[] = {0.193464,0.200778,0.0822321,0.100039,0.0618946}; double Eff_Zuu_FLH[] = {30.6086,35.1818,96.0252,5.94575,2.28958}; double Eff_Zuu_FLH_err[] = {0.177817,0.18425,0.0753784,0.0912414,0.0577095}; //------------------------------------------------------------// TCanvas*cnvs_ZX=new TCanvas; TH1F *hFrame_ZX=cnvs_ZX->DrawFrame(0,0,5,100); TH1F*geData_ZeeX= new TH1F("geData_ZeeX","geData_ZeeX",5,0,5); hFrame_ZX->SetXTitle("Cuts"); hFrame_ZX->SetYTitle("Efficiency [%]"); cnvs_ZX->SetGridy(); int color[5]={kBlue,kRed,kGreen,kMagenta,kYellow}; TLegend*leg_ZX=new TLegend(0.17,0.6,0.55,0.94); leg_ZX->SetFillColor(0); leg_ZX->SetShadowColor(0); leg_ZX->SetBorderSize(0); leg_ZX->SetHeader("2012 Ldt ~ 20fb^{-1}"); for(int bin = 0; bin < 5; bin++) { geData_ZeeX->SetBinContent(bin+1,Eff_Zee_XML[bin]); geData_ZeeX->SetBinError(bin+1,Eff_Zee_XML_err[bin]); SetGraphStyle(geData_ZeeX,22,kRed ,1,1,0); } const char *names[] = { "caloIso", "trackIso", "d0s", "relaxedID #rightarrow ID", "all"}; for(int i = 1; i <= 5; i++) geData_ZeeX->GetXaxis()->SetBinLabel(i, names[i-1]); // geData_ZeeX->Draw("PE same"); geData_ZeeX->Draw("HIST"); //leg_ZX->Draw(); //ATLASLabel(0.2, 0.2, true, kBlack); //TLatex l; //l.SetNDC(); //l.SetTextFont(42); //l.DrawLatex(0.7, 0.2, "Z + X"); }
void draw_1D_eff_Zvtx1_Zvtx0_pp(TString szBinning="8rap9pt", bool isPrompt=false, bool isLog=false, bool isNoErr=true) { gROOT->Macro("../Style.C"); double ratiomin = 0.9; double ratiomax = 1.1; TString szPrompt; if (isPrompt) szPrompt = "PR"; else szPrompt = "NP"; ////rap array in yCM (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 rapArrNumFB[] = {2.4, 1.93, 1.5, 0.9, 0., -0.9, -1.5, -1.93, -2.4};// for pt dist. //Double_t rapArrNumBF[] = {-2.87, -2.4, -1.93, -1.5, -0.9, 0., 0.9, 1.5, 1.93};// for rap dist. //Double_t rapArrNumBF[] = {-2.4, -1.93, -1.5, -0.9, 0., 0.9, 1.5, 1.93, 2.4};// for rap dist. const Int_t nRap = sizeof(rapArrNumFB)/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]; } ////pt array Double_t ptArrNum[] = {2.0, 3.0, 4.0, 5.0, 6.5, 7.5, 8.5, 10., 14., 30.}; //8rap9pt //Double_t ptArrNum[] = {5.0, 6.5, 10., 30.}; //8rap3pt const Int_t nPt = sizeof(ptArrNum)/sizeof(Double_t)-1; cout << "nPt = " << nPt << endl; Double_t ptBinW[nPt]; for (Int_t ipt=0; ipt<nPt; ipt++) { ptBinW[ipt] = ptArrNum[ipt+1]-ptArrNum[ipt]; } //// array TString 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 file TFile * f2D_pp01 = new TFile(Form("../FittingResult/totalHist_pp_%s_newcut_nominal_Zvtx1_SF1_noPtWeight.root",szBinning.Data())); TFile * f2D_pp02 = new TFile(Form("../FittingResult/totalHist_pp_%s_newcut_nominal_Zvtx0_SF1_noPtWeight.root",szBinning.Data())); // --- read-in 2D hist for data reco dist TH2D* h2D_pp01 = (TH2D*)f2D_pp01->Get(Form("h2D_Eff_%s_pp",szPrompt.Data())); TH2D* h2D_pp02 = (TH2D*)f2D_pp02->Get(Form("h2D_Eff_%s_pp",szPrompt.Data())); cout << "h2D_pp01 = " << h2D_pp01 << endl; cout << "h2D_pp02 = " << h2D_pp02 << endl; const int nbinsX = h2D_pp01->GetNbinsX(); const int nbinsY = h2D_pp01->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_pp01[nbinsX]; TH1D* h1D_pp02[nbinsX]; //// iy=0 refers to forwards !!! (ordering here) for (Int_t iy = 0; iy < nbinsX; iy++) { h1D_pp01[iy] = h2D_pp01->ProjectionY(Form("h1D_pp01_%d",iy),nbinsX-iy,nbinsX-iy); h1D_pp02[iy] = h2D_pp02->ProjectionY(Form("h1D_pp02_%d",iy),nbinsX-iy,nbinsX-iy); } ////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// //// --- set values as zero for unused bins //// 8rap9pt pp for (Int_t iy = 0; iy < nbinsX; iy++) { if (iy>=1 && iy<=6) { h1D_pp01[iy]->SetBinContent(1,-532); h1D_pp01[iy]->SetBinError(1,0); h1D_pp02[iy]->SetBinContent(1,+532); h1D_pp02[iy]->SetBinError(1,0); h1D_pp01[iy]->SetBinContent(2,-532); h1D_pp01[iy]->SetBinError(2,0); h1D_pp02[iy]->SetBinContent(2,+532); h1D_pp02[iy]->SetBinError(2,0); } if (iy>=2 && iy<=5) { h1D_pp01[iy]->SetBinContent(3,-532); h1D_pp01[iy]->SetBinError(3,0); h1D_pp02[iy]->SetBinContent(3,+532); h1D_pp02[iy]->SetBinError(3,0); } //if (iy>=2 && iy<=4) {}//pp if (iy>=2 && iy<=5) { h1D_pp01[iy]->SetBinContent(4,-532); h1D_pp01[iy]->SetBinError(4,0); h1D_pp02[iy]->SetBinContent(4,+532); h1D_pp02[iy]->SetBinError(4,0); } } /* ////// after zero-bin setting, normalize! for (Int_t iy = 0; iy < nbinsX; iy++) { h1D_pp01[iy]->Scale(1./h1D_pp01[iy]->Integral()); h1D_pp01[iy]->Scale(1,"width"); h1D_pp02[iy]->Scale(1./h1D_pp02[iy]->Integral()); h1D_pp02[iy]->Scale(1,"width"); } */ //// calculate ratio TH1D* hRatio_pp[nRap]; for (Int_t iy = 0; iy < nbinsX; iy++) { hRatio_pp[iy]=(TH1D*)h1D_pp01[iy]->Clone(Form("hRatio_pp_%d",iy)); hRatio_pp[iy]->Divide(h1D_pp02[iy]); if (isNoErr) { for (int ipt=0; ipt<nbinsY; ipt++) { hRatio_pp[iy]->SetBinError(ipt+1,0.); cout << iy <<"th rap, "<<ipt<<"th pT, ratio = "<<hRatio_pp[iy]->GetBinContent(ipt+1)<<endl; } } } ////////////////////////////////////////////////////////////////// //// Draw plots ////////////////////////////////////////////////////////////////// TGraphAsymmErrors* g_pp01[nbinsX]; TGraphAsymmErrors* g_pp02[nbinsX]; TLegend *legBR = new TLegend(0.55, 0.28, 0.86, 0.40); SetLegendStyle(legBR); //latex box for beam, rapidity, pT info TLatex* latex = new TLatex(); latex->SetNDC(); latex->SetTextAlign(12); latex->SetTextSize(0.04); TCanvas* c01 = new TCanvas("c01","c01",200,10,1600,800); c01->Divide(4,2); for (Int_t iy = 0; iy < nbinsX; iy++) { g_pp01[iy]=new TGraphAsymmErrors(h1D_pp01[iy]); g_pp01[iy]->SetName(Form("g_pp01_%d",iy)); g_pp02[iy]=new TGraphAsymmErrors(h1D_pp02[iy]); g_pp02[iy]->SetName(Form("g_pp02_%d",iy)); c01->cd(iy+1); if (isLog) gPad->SetLogy(1); else gPad->SetLogy(0); SetGraphStyle(g_pp01[iy],3,0); SetGraphStyle(g_pp02[iy],4,10); g_pp01[iy]->GetXaxis()->SetTitle("p_{T} (GeV/c)"); g_pp01[iy]->GetXaxis()->CenterTitle(); g_pp01[iy]->GetXaxis()->SetLimits(0.0,30.0); g_pp01[iy]->GetYaxis()->SetTitle("Efficiency"); g_pp01[iy]->GetYaxis()->SetRangeUser(0,1.0); g_pp01[iy]->Draw("AP"); g_pp02[iy]->Draw("P"); if (iy==0) { legBR -> AddEntry(g_pp01[iy],"z vtx weight","lp"); legBR -> AddEntry(g_pp02[iy],"no weight","lp"); legBR->Draw(); if (isPrompt) latex->DrawLatex(0.19,0.23,"pp Prompt J/#psi"); else latex->DrawLatex(0.19, 0.23,"pp Nonprompt J/#psi"); } latex->DrawLatex(0.55,0.23,Form("%s",rapArr[iy].Data())); } c01->Modified(); c01->Update(); c01->SaveAs(Form("dir_1D_%s/eff_isPrompt%d_isLog%d_Zvtx1_Zvtx0_pp.pdf",szBinning.Data(),(int)isPrompt,(int)isLog)); ////////////////////////////////////////////////////////////////// //// hRatio, and convert to gRatio (TGraphAsymErrors) ////////////////////////////////////////////////////////////////// TCanvas* c02 = new TCanvas("c02","c02",200,10,1600,800); c02->Divide(4,2); TGraphAsymmErrors* gRatio_pp[nbinsX]; for (Int_t iy = 0; iy < nbinsX; iy++) { gRatio_pp[iy]=new TGraphAsymmErrors(hRatio_pp[iy]); gRatio_pp[iy]->SetName(Form("gRatio_pp_%d",iy)); SetGraphStyle(gRatio_pp[iy],1,0); /* for (Int_t ipt=0; ipt<nbinsY; ipt++ ){ gRatio_pp[iy]->GetPoint(ipt, pxtmp[iy][ipt], pytmp[iy][ipt]); gRatio_pp[iy]->SetPoint(ipt, px[iy][ipt], pytmp[iy][ipt]); gRatio_pp[iy]->SetPointEXlow(ipt, ex[ipt]); gRatio_pp[iy]->SetPointEXhigh(ipt, ex[ipt]); }*/ c02->cd(iy+1); gRatio_pp[iy]->GetXaxis()->SetLimits(0.0,30.0); gRatio_pp[iy]->GetXaxis()->CenterTitle(); gRatio_pp[iy]->SetMinimum(ratiomin); gRatio_pp[iy]->SetMaximum(ratiomax); gRatio_pp[iy]->GetYaxis()->CenterTitle(); gRatio_pp[iy]->GetXaxis()->SetTitle("p_{T} (GeV/c)"); gRatio_pp[iy]->GetYaxis()->SetTitle("[Weight] / [No weight]"); gRatio_pp[iy]->Draw("AP"); if (iy==0){ if (isPrompt) latex->DrawLatex(0.19,0.23,"pp Prompt J/#psi"); else latex->DrawLatex(0.19, 0.23,"pp Nonprompt J/#psi"); } latex->DrawLatex(0.55,0.23,Form("%s",rapArr[iy].Data())); dashedLine(0.,1.,30.,1.,1,1); } c02->SaveAs(Form("dir_1D_%s/effRatio_isPrompt%d_isLog%d_Zvtx1_Zvtx0_pp.pdf",szBinning.Data(),(int)isPrompt,(int)isLog)); return; } // end of main func.
void fitRatio_kyo01(bool isPrompt=true, bool isPbp=true, char* dirName="8rap9pt2gev"){ gRandom->SetSeed(time(0)); gROOT->Macro("./JpsiStyle.C"); //latex box for beam, rapidity, pT info TLatex* latex = new TLatex(); latex->SetNDC(); latex->SetTextAlign(12); latex->SetTextSize(0.04); string 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; } // TFile* fin = new TFile(Form("../pPbJPsiAnalysis/2015/004_closure/DataMcReco_8rap9pt/DataMcRecoPt_isPropmt%d.root",(int)isPrompt));//in KNU TFile* fin = new TFile(Form("../004_closure/DataMcReco_%s/DataMcRecoPt_isPropmt%d.root",dirName,(int)isPrompt));//in KNU //KYO string runstring; string runstringOverlay; if(isPbp) {runstring="Pbp"; runstringOverlay="pPb";} else {runstring="pPb"; runstringOverlay="Pbp"; } TGraphAsymmErrors* gRatio[nRap]; TGraphAsymmErrors* gRatioOverlay[nRap]; for(int iy=0;iy<nRap;iy++){ gRatio[iy]=(TGraphAsymmErrors*)fin->Get(Form("gRatio_%s_%d",runstring.c_str(),iy)); gRatioOverlay[iy]=(TGraphAsymmErrors*)fin->Get(Form("gRatio_%s_%d",runstringOverlay.c_str(),iy)); gRatio[iy]->SetName(Form("gRatio_%d",iy)); gRatioOverlay[iy]->SetName(Form("gRatioOverlay_%d",iy)); } //TFile* fout= new TFile(Form("ToyGaussian_isPrompt%d_%s.root",(int)isPrompt,runstring.c_str()),"recreate"); //TFile* fout= new TFile(Form("ToyGaussian_isPrompt%d_%s_kyo01.root",(int)isPrompt,runstring.c_str()),"recreate");//KYO TFile* fout= new TFile(Form("fitRatio_isPrompt%d_%s_kyo01.root",(int)isPrompt,runstring.c_str()),"recreate");//KYO //////////////////////////////////////////////////////////// // Output gaussian parameter histograms TH1D* hWeight[nRap]; // TH1D* hWeightSigma[nRap]; for(int iy=0;iy<nRap;iy++){ // if (iy!=0) continue ; //KYO hWeight[iy]=new TH1D(Form("hWeight_%s_%d",runstring.c_str(),iy), Form("hWeight_%s_%d",runstring.c_str(),iy), nPtFine, ptFineArrNum); // hWeightSigma[iy]=new TH1D(Form("hWeightSigma_%s_%d",runstring.c_str(),iy), Form("hWeightSigma_%s_%d",runstring.c_str(),iy), nPtFine, ptFineArrNum); } #if 0 int rapiditybin[nRap],nfpt[nRap]; double mean[nRap][nPtFine],sigma[nRap][nPtFine]; TTree* toyGaus[nRap]; for(int iy=0;iy<nRap;iy++){ toyGaus[iy]=new TTree(Form("toyGaus%d",iy),Form("rapidity bin %dth",iy)); toyGaus[iy]->Branch("rapiditybin", &rapiditybin[iy]); toyGaus[iy]->Branch("nfpt", &nfpt[iy]); toyGaus[iy]->Branch("mean", mean[iy],"mean[nfpt]/D"); toyGaus[iy]->Branch("sigma", sigma[iy],"sigma[nfpt]/D"); } #endif //////////////////////////////////////////////////////////// // Fitting // TF1* fhevi= new TF1("fhevi","[0]/(exp((-x+[1])/[2] +1)+[3])+[4]",0,30); // fhevi->SetParameters(-4.795, 1.653, 0.923, 3.018, 2.369); // TF1* fexp= new TF1("fexp","[0]/(1+exp([1]*x))+[2]/x",0.0,30.0);//Prompt TF1* func[nRap]; // TCanvas* c1 = new TCanvas("c1", "", 1200,1500); // c1 -> Divide(3,3); TCanvas* c1 = new TCanvas("c1", "", 1600,800); //KYO c1 -> Divide(4,2); // KYO for(int iy=0;iy<nRap;iy++){ c1->cd(iy+1); if(iy==0 || iy==nRap-1){ func[iy] = new TF1(Form("func_%d",iy), fitHevi,0.0,30.0,5); func[iy]->SetParameters(-4.795, 1.653, 0.923, 3.018, 2.369); if(isPrompt==1 && isPbp==0 && iy==0) { // func[iy]->SetParameters(-51.7167, -0.694876, 0.491544,4.55470,12.1672); #if 1 func[iy]->FixParameter(0,-5.17167e+01 ); func[iy]->FixParameter(1,-6.94876e-01 ); //func[iy]->FixParameter(2,4.91544e-01 ); func[iy]->FixParameter(2,9.91544e-01 ); //func[iy]->FixParameter(3,4.55470e+00 ); //func[iy]->FixParameter(3,3.55470e+00 ); //func[iy]->FixParameter(4,1.11672e+01 ); #endif } else if(isPrompt==1 && isPbp==1 && iy==0) { //func[iy]->FixParameter(0,-5.17167e+01 ); func[iy]->FixParameter(1,2.06705e+00 ); func[iy]->FixParameter(2,3.72512e-01 ); func[iy]->FixParameter(3,3.11521e+00 ); //func[iy]->FixParameter(4,1.11672e+01 ); } else if (isPrompt==0 && isPbp==1 && iy==7) { func[iy]->FixParameter(0, -3.40711e+02); func[iy]->FixParameter(1, 3.20176e+00); func[iy]->FixParameter(2, 1.09760e+00); } } //else if(isPrompt==1 && isPbp==0 && iy==4){ // func[iy] = new TF1(Form("func_%d",iy), fitHevi,0.0,30.0,5); // func[iy]->SetParameters(-3.40747e+02,3.32373e+00,6.51294e-01,2.98861e+00,1.14947e+02); //} else{ func[iy] = new TF1(Form("func_%d",iy), fitHevi,0.0,30.0,5); //func[iy]->SetParameters(-3.40711e+02,-2.02319e+00,1.42753e+00,2.98897e+00,1.14958e+02); //yeonju 0509 func[iy]->SetParameters(-3.40711e+02,-5.20176e+00,1.79760e+00,2.98896e+00,1.14958e+02); //yeonju 0509 //func[iy]->SetParameters(-3.40747e+02,3.32373e+00,6.51294e-01,2.98861e+00,1.14947e+02); //yeonju //yeonju if (isPrompt==0 && iy==2) { func[iy]->FixParameter(0, -3.40711e+02); func[iy]->FixParameter(1, -5.20176e+00); func[iy]->FixParameter(2, 1.79760e+00); func[iy]->FixParameter(3, 2.98896); } else if (isPrompt==0 && iy==6) { func[iy]->FixParameter(0, -3.40711e+02); func[iy]->FixParameter(1, 3.20176e+00); func[iy]->FixParameter(2, 1.79760e+00); } //KYO if (isPrompt && iy==6) { func[iy]->FixParameter(0,-3.40743e+02); func[iy]->FixParameter(1,-2.56691e+01); func[iy]->FixParameter(2,5.14736e+00); } else if (isPrompt && (iy==2 || iy==1)) { func[iy]->FixParameter(0,-3.40743e+02); func[iy]->FixParameter(1,-1.37032e-01); func[iy]->FixParameter(2,1.19902); } /* func[iy] = new TF1(Form("func_%d",iy), fitExp,0.0,30.0,3); if(isPrompt==0 && isPbp==1 && (iy==2 || iy==3 || iy==4 || iy==5) ) func[iy]->SetParameters(-1.01556e+01,1.51712e-01,2.80282e+01); if(isPrompt==0 && isPbp==0 && (iy==2 || iy==3 || iy==4) ) func[iy]->SetParameters(-1.01556e+01,1.51712e-01,2.80282e+01); if(isPrompt==1 && isPbp==0 && (iy==3) ) func[iy]->SetParameters(-1.01556e+01,1.51712e-01,2.80282e+01); if(isPrompt==1 && isPbp==1 && (iy==3) ) func[iy]->SetParameters(-1.01556e+01,1.51712e-01,2.80282e+01); */ } //KYO for TGraphAsymmErrors only if (!isPrompt && iy==0){ func[iy]->SetParameters(-1.04829e+01,-5.38813e+00,2.10443e+00,1.74460e+00,6.89848e+02); func[iy]->FixParameter(0,-1.04829e+01); func[iy]->FixParameter(1,-5.38813e+00); func[iy]->FixParameter(2,2.10443e+00); } SetGraphStyle(gRatio[iy],2,0); SetGraphStyle(gRatioOverlay[iy],4,10); func[iy]->SetLineColor(kRed); gRatio[iy]->Fit(Form("func_%d",iy)); gRatio[iy]->Draw("AP"); gRatioOverlay[iy]->Draw("P"); //func[iy]->Draw("same"); if (iy==0){ if (isPrompt) latex->DrawLatex(0.23,0.23,"Prompt J/#psi Pbp"); else latex->DrawLatex(0.23, 0.23,"Non-prompt J/#psi Pbp"); } latex->DrawLatex(0.56,0.80,Form("%s",rapArr[iy].c_str())); dashedLine(0.,1.,25.,1.,1,1); /* for(int ifpt=0;ifpt<nPtFine;ifpt++){ int hBin = gRatio[iy]->FindBin(ptFineArrNum[ifpt+1]-0.1); double mean = func[iy]->Eval(ptFineArrNum[ifpt+1]); double sigma = gRatio[iy]->GetBinError(hBin) / mean; hWeight[iy]->SetBinContent(ifpt+1, mean); hWeight[iy]->SetBinError(ifpt+1, sigma); //cout <<"x : "<<ptFineArrNum[ifpt+1]-0.01<< ", gRatio bin : " <<hBin << ", Ratio error value : " << gRatio[iy]->GetBinError(hBin) << endl; //cout << iy+1 << "th rapidity, "<< ifpt<<"th fine ptbin, mean = "<< mean <<", sigma = "<<sigma<<endl; } */ } c1 -> Update(); for(int iy=0;iy<nRap;iy++){ cout << " **** " <<iy<< "th rap, values at min pT = " <<func[iy]->Eval(minPt[iy])<<endl; } fout->cd(); for(int iy=0;iy<nRap;iy++){ //hWeight[iy]->Write(); gRatio[iy]->Write(); func[iy]->Write(); } c1->Write(); fout->Close(); }//end of main func.
//// runCode // 0=merged, 1=1stRun, 2=2ndRun void draw_1D_RFB_ETHF_tworange(char* dirName = "6rap3pt", int runCode=0, bool isPrompt=false) { gROOT->Macro("./tdrstyle_kyo.C"); gStyle->SetTitleSize(0.046, "XYZ"); gStyle->SetEndErrorSize(0); 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.5; double pxshift = 1.; // 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"; //1stRun lumi_nb =20.7; lumi_nb_err=0.7; } else if (runCode == 2) { runstring = "pPb"; //2ndRun lumi_nb = 14.0; lumi_nb_err=0.5; } 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} ///////////////////////////////////////////////////////////////////////// // bin center & systematic uncertainties by hand //inh=0 : pT 5-6.5, rap 1.5-1.93 //inh=1 : pT 6.5-30, rap 1.5-1.93 //inh=2 : pT 6.5-30, rap 0.9-1.5 //inh=3 : pT 6.5-30, rap 0.0-0.9 const int nRap = 6; const int nRapTmp = nRap+1; const int nPt = 3; const int nPtTmp = nPt+1; const int nEt = 3; const int nEtTmp = nEt+1; const int nHist = 4; const int nHistTmp = nHist+1; Double_t pxtmp[nHist][nEt]; //x point to fill temp Double_t pytmp[nHist][nEt]; //y point to fill temp Double_t eytmp[nHist][nEt]; //y stat error to fill temp Double_t px[nEt] = {9.4, 24.3, 37.2}; // x point Double_t ex[nEt] = {0.,0.,0.}; // x stat error Double_t exsys[nEt] = {0.5, 0.5, 0.5};; //x sys error Double_t eysys[nHist][nEt]; //absolute y sys error Double_t eysysrel[nHist][nEt]; //relative y sys error Double_t eysysrelPR[nHist][nEt] = { {0.05299,0.06155,0.06715}, //1.5-1.93 low {0.05088,0.05442,0.05913}, //1.5-1.93 {0.03741,0.04958,0.04227}, //0.9-1.5 {0.04425,0.04528,0.05314} //0.0-0.9 }; Double_t eysysrelNP[nHist][nEt] = { {0.04971,0.06138,0.06459}, // 1.5-1.93 low {0.05188,0.05442,0.05999}, //0.5-1.93 {0.03694,0.04952,0.04221}, //0.9-1.5 {0.04242,0.04349,0.05162} //0.0-0.9 }; for (int inh = 0; inh < nHist; inh++ ) { for (int iet = 0; iet < nEt; iet++ ) { if (isPrompt) eysysrel[inh][iet] = eysysrelPR[inh][iet]; else eysysrel[inh][iet] = eysysrelNP[inh][iet]; } } //rap array in yCM (from forward to backward) Double_t rapArrNumFB[nRapTmp] = {1.93, 1.5, 0.9, 0., -0.9, -1.5, -1.93};// for pt dist. //Double_t rapArrNumBF[nRapTmp] = {-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; } //pt array Double_t ptArrNum[nPtTmp] = {5.0, 6.5, 10., 30.}; //6rap3pt 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; } //ethf array Double_t etArrNum[nEtTmp] = {0.0, 20.0, 30.0, 120.0}; // array string string 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; } 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; } string etArr[nEt]; for (Int_t i=0; i<nEt; i++) { formEtArr(etArrNum[i], etArrNum[i+1], &etArr[i]); cout << "etArr["<<i<<"] = "<< etArr[i].c_str() << 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[nEt]; TH2D* h2D_corrY_pPb[nEt]; for (int iet=0; iet<nEt; iet++) { if (isPrompt) { h2D_corrY_Pbp[iet] = (TH2D*)f2D->Get(Form("h2D_corrY_PR_Pbp_%d",iet)); h2D_corrY_pPb[iet] = (TH2D*)f2D->Get(Form("h2D_corrY_PR_pPb_%d",iet)); } else { h2D_corrY_Pbp[iet] = (TH2D*)f2D->Get(Form("h2D_corrY_NP_Pbp_%d",iet)); h2D_corrY_pPb[iet] = (TH2D*)f2D->Get(Form("h2D_corrY_NP_pPb_%d",iet)); } cout << iet << "th h2D_corrY_Pbp = " << h2D_corrY_Pbp[iet] << endl; cout << iet << "th h2D_corrY_pPb = " << h2D_corrY_pPb[iet] << endl; } const int nbinsX = h2D_corrY_Pbp[0]->GetNbinsX(); const int nbinsY = h2D_corrY_Pbp[0]->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[nEt][nbinsX]; TH1D* h1D_corrY_pPb[nEt][nbinsX]; // iy=0 refers to forwards !!! (ordering here) for (Int_t iet=0; iet<nEt; iet++) { for (Int_t iy = 0; iy < nbinsX; iy++) { h1D_corrY_Pbp[iet][iy] = h2D_corrY_Pbp[iet]->ProjectionY(Form("h1D_corrY_Pbp_%d_%d",iet,iy),iy+1,iy+1); h1D_corrY_Pbp[iet][iy]->SetName(Form("h1D_corrY_Pbp_%d_%d",iet,iy)); //for 2nd run h1D_corrY_pPb[iet][iy] = h2D_corrY_pPb[iet]->ProjectionY(Form("h1D_corrY_pPb_%d_%d",iet,iy),nbinsX-iy,nbinsX-iy); h1D_corrY_pPb[iet][iy]->SetName(Form("h1D_corrY_pPb_%d_%d",iet,iy)); } } ////////////////////////////////////////////////////////////////////////////////////// // 1) merge Pbp+pPb corrected yield TH1D* h1D_corrY_tot[nEt][nbinsX]; for (Int_t iet=0; iet<nEt; iet++) { for (Int_t iy = 0; iy < nbinsX; iy++) { if (runCode ==0) { h1D_corrY_tot[iet][iy] = (TH1D*)h1D_corrY_Pbp[iet][iy]->Clone(Form("h1D_corrY_tot_%d_%d",iet,iy)); h1D_corrY_tot[iet][iy]->Add(h1D_corrY_pPb[iet][iy]); } else if (runCode ==1) { h1D_corrY_tot[iet][iy] = (TH1D*)h1D_corrY_Pbp[iet][iy]->Clone(Form("h1D_corrY_tot_%d_%d",iet,iy)); } else if (runCode ==2) { h1D_corrY_tot[iet][iy] = (TH1D*)h1D_corrY_pPb[iet][iy]->Clone(Form("h1D_corrY_tot_%d_%d",iet,iy)); } } } ////////////////////////////////////////////////////////////////// /////////// calculate RFB const int nRapRFB = 3; TH1D* h1D_RFB_tmp[nEt][nbinsX]; // corrYield with merged pT TH1D* h1D_RFB[nEt][nRapRFB]; // actual RFB vs pt // bin settingg string 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[] = {5.0, 6.5, 30.}; const Int_t nPtRFB = sizeof(ptArrRFBNum)/sizeof(Double_t)-1; cout << "nPtRFB = " << nPtRFB << endl; // merging pT bins (KYO - byHand) double tmpPRval01, tmpPRerr01, tmpPRval02, tmpPRerr02; double actPRval01, actPRerr01, actPRval02, actPRerr02; for (int iet=0; iet<nEt; iet++) { for (int iy=0; iy<nRapRFB*2; iy++) { h1D_RFB_tmp[iet][iy]= new TH1D(Form("h1D_RFB_tmp_%d_%d",iet,iy),Form("h1D_RFB_tmp_%d_%d",iet,iy),nPtRFB,ptArrRFBNum); h1D_RFB_tmp[iet][iy]->Sumw2(); actPRval01=0; actPRval02=0; actPRerr01=0; actPRerr02=0; // 1) pT 5-6.5 GeV tmpPRval01=0; tmpPRval02=0; tmpPRerr01=0; tmpPRerr02=0; if (iy==0 || iy==nRapRFB*2-1) { actPRval01=h1D_corrY_tot[iet][iy]->GetBinContent(1); actPRerr01=h1D_corrY_tot[iet][iy]->GetBinError(1); h1D_RFB_tmp[iet][iy]->SetBinContent(1,actPRval01); h1D_RFB_tmp[iet][iy]->SetBinError(1,actPRerr01); } else { h1D_RFB_tmp[iet][iy]->SetBinContent(1,0.); h1D_RFB_tmp[iet][iy]->SetBinError(1,0.); } // 2) pT 6.5-30. GeV tmpPRval01=0; tmpPRval02=0; tmpPRerr01=0; tmpPRerr02=0; tmpPRval01=h1D_corrY_tot[iet][iy]->GetBinContent(2); tmpPRerr01=h1D_corrY_tot[iet][iy]->GetBinError(2); tmpPRval02=h1D_corrY_tot[iet][iy]->GetBinContent(3); tmpPRerr02=h1D_corrY_tot[iet][iy]->GetBinError(3); actPRval02=tmpPRval01+tmpPRval02; actPRerr02=TMath::Sqrt( TMath::Power(tmpPRerr01,2) + TMath::Power(tmpPRerr02,2) ); h1D_RFB_tmp[iet][iy]->SetBinContent(2,actPRval02); h1D_RFB_tmp[iet][iy]->SetBinError(2,actPRerr02); } } // actual RFB calculation vs pT!! for (int iet=0; iet<nEt; iet++) { for (int iy=0; iy<nRapRFB; iy++) { h1D_RFB[iet][iy] = (TH1D*)h1D_RFB_tmp[iet][iy]->Clone(Form("h1D_RFB_%d_%d",iet,iy)); h1D_RFB[iet][iy]->Divide(h1D_RFB_tmp[iet][2*nRapRFB-iy-1]); cout << iet<<"th, "<<iy<<"th h1D_RFB = "<<h1D_RFB[iet][iy]<<endl; } } /////////////////////////////////////////////// //////// --- RFB vs ETHF : 4 histograms //inh=0 : pT 5-6.5, rap 1.5-1.93 //inh=1 : pT 6.5-30, rap 1.5-1.93 //inh=2 : pT 6.5-30, rap 0.9-1.5 //inh=3 : pT 6.5-30, rap 0.0-0.9 double tmpRFBval01, tmpRFBerr01, tmpRFBval02, tmpRFBerr02, tmpRFBval03, tmpRFBerr03; TH1D* h1D_RFB_ETHF[nHist]; for (int inh=0; inh< nHist; inh++) { h1D_RFB_ETHF[inh]= new TH1D(Form("h1D_RFB_ETHF_%d",inh),Form("h1D_RFB_ETHF_%d",inh),nEt,etArrNum); h1D_RFB_ETHF[inh]->Sumw2(); tmpRFBval01=0; tmpRFBerr01=0; tmpRFBval02=0; tmpRFBerr02=0; tmpRFBval03=0; tmpRFBerr03=0; for (int iet=0; iet<nEt; iet++) { if (inh==0) { tmpRFBval01=h1D_RFB[iet][0]->GetBinContent(1); tmpRFBerr01=h1D_RFB[iet][0]->GetBinError(1); h1D_RFB_ETHF[inh]->SetBinContent(iet+1,tmpRFBval01); h1D_RFB_ETHF[inh]->SetBinError(iet+1,tmpRFBerr01); } else { tmpRFBval01=h1D_RFB[iet][inh-1]->GetBinContent(2); tmpRFBerr01=h1D_RFB[iet][inh-1]->GetBinError(2); h1D_RFB_ETHF[inh]->SetBinContent(iet+1,tmpRFBval01); h1D_RFB_ETHF[inh]->SetBinError(iet+1,tmpRFBerr01); } } } ////////////////////////////////////////////////////////////////// /////////// samey ////////////////////////////////////////////////////////////////// TCanvas* c1 = new TCanvas("c1","c1",600,600); c1->cd(); // TLegend *legBL = new TLegend(0.16, 0.16, 0.43, 0.41); //bottom left TLegend *legBL = new TLegend(0.16, 0.16, 0.40, 0.36); //bottom left TLegend *legBL2 = new TLegend(0.16, 0.16, 0.40, 0.40); //bottom left // TLegend *legUR = new TLegend(0.36, 0.77, 0.89, 0.95); //upper left TLegend *legUR = new TLegend(0.34, 0.71, 0.89, 0.88); //upper left SetLegendStyle(legBL); SetLegendStyle(legBL2); //legBL->SetTextSize(0.032); legBL->SetTextSize(0.037); legBL2->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); // convert to TGraphAsymErrors //RFB TGraphAsymmErrors*gRFB[nHist]; for (int inh=0; inh< nHist; inh++) { gRFB[inh] = new TGraphAsymmErrors(h1D_RFB_ETHF[inh]); gRFB[inh]->SetName(Form("gRFB_%d",inh)); for (int iet=0; iet<nEt; iet++) { gRFB[inh]->GetPoint(iet, pxtmp[inh][iet], pytmp[inh][iet]); eytmp[inh][iet] = gRFB[inh] -> GetErrorY(iet); // gRFB[inh]->SetPoint(iet, px[iet], pytmp[inh][iet]); gRFB[inh]->SetPoint(iet, px[iet]+pxshift*inh, pytmp[inh][iet]); gRFB[inh]->SetPointEXlow(iet, ex[inh]); gRFB[inh]->SetPointEXhigh(iet, ex[inh]); } } //sys TGraphAsymmErrors* gRFB_sys[nHist]; for (int inh=0; inh< nHist; inh++) { gRFB_sys[inh] = new TGraphAsymmErrors(h1D_RFB_ETHF[inh]); gRFB_sys[inh]->SetName(Form("gRFB_sys_%d",inh)); for (int iet=0; iet<nEt; iet++) { gRFB_sys[inh]->GetPoint(iet, pxtmp[inh][iet], pytmp[inh][iet]); //abs err calcul. eysys[inh][iet] = eysysrel[inh][iet]*pytmp[inh][iet]; //gRFB_sys[inh]->SetPoint(iet, px[iet], pytmp[inh][iet]); gRFB_sys[inh]->SetPoint(iet, px[iet]+pxshift*inh, pytmp[inh][iet]); gRFB_sys[inh]->SetPointError(iet, exsys[iet], exsys[iet], eysys[inh][iet], eysys[inh][iet]); cout << "" << endl; cout << "pytmp["<<inh<<"]["<<iet<<"] = " << pytmp[inh][iet]<<endl; cout << "eytmp["<<inh<<"]["<<iet<<"] = " << eytmp[inh][iet]<<endl; cout << "eysys["<<inh<<"]["<<iet<<"] = " << eysys[inh][iet]<<endl; } } gRFB_sys[0]->GetXaxis()->SetTitle("E_{T}^{HF |#eta|>4} [GeV]"); gRFB_sys[0]->GetXaxis()->CenterTitle(); gRFB_sys[0]->GetYaxis()->SetTitle("R_{FB}"); gRFB_sys[0]->GetXaxis()->SetLimits(0.,50.0); gRFB_sys[0]->SetMinimum(0.5); gRFB_sys[0]->SetMaximum(1.15); gRFB_sys[0]->SetFillColor(kViolet-9); gRFB_sys[0]->Draw("A2"); gRFB_sys[1]->SetFillColor(kTeal-9); gRFB_sys[1]->Draw("2"); gRFB_sys[2]->SetFillColor(kRed-9); // gRFB_sys[2]->Draw("2"); gRFB_sys[3]->SetFillColor(kAzure-9); // gRFB_sys[3]->Draw("2"); SetGraphStyle(gRFB[0], 8, 2); //1.5-1.93 low SetGraphStyle(gRFB[1], 0, 5); //1.5-1.93 SetGraphStyle(gRFB[2], 1, 3); //0.9-1.5 SetGraphStyle(gRFB[3], 2, 0); //0-0.9 gRFB[0]->SetMarkerSize(1.6); gRFB[0]->Draw("P"); gRFB[1]->SetMarkerSize(2.1); gRFB[1]->Draw("P"); dashedLine(0.,1.,50.,1.,1,1); legBL -> SetHeader ("1.5 < |y_{CM}| < 1.93"); legBL -> AddEntry(gRFB[0],"5 < p_{T} < 6.5 GeV/c","lp"); legBL -> AddEntry(gRFB[1],"6.5 < p_{T} < 30 GeV/c","lp"); // legBL -> AddEntry(gRFB[0],"1.5 < |y_{CM}| < 1.93, 5 < p_{T} < 6.5 GeV/c","lp"); // legBL -> AddEntry(gRFB[1],"1.5 < |y_{CM}| < 1.93, 6.5 < p_{T} < 30 GeV/c","lp"); // legBL -> AddEntry(gRFB[2],"0.9 < |y_{CM}| < 1.5, 6.5 < p_{T} < 30 GeV/c","lp"); // legBL -> AddEntry(gRFB[3],"0.0 < |y_{CM}| < 0.9, 6.5 < p_{T} < 30 GeV/c","lp"); legBL->Draw(); 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_ETHF_samey_isPrompt%d_%s.pdf",dirName,(int)isPrompt,runstring.c_str())); c1->SaveAs(Form("RFB_%s/RFB_ETHF_samey_isPrompt%d_%s.png",dirName,(int)isPrompt,runstring.c_str())); legBL->Clear(); ////////////////////////////////////////////////////////////////// /////////// samept ////////////////////////////////////////////////////////////////// TCanvas* c2 = new TCanvas("c2","c2",600,600); c2->cd(); for (int inh=1; inh< nHist; inh++) { for (int iet=0; iet<nEt; iet++) { gRFB[inh]->GetPoint(iet, pxtmp[inh][iet], pytmp[inh][iet]); eytmp[inh][iet] = gRFB[inh] -> GetErrorY(iet); gRFB[inh]->SetPoint(iet, px[iet]+pxshift*(nHist-1-inh), pytmp[inh][iet]); //sys gRFB_sys[inh]->GetPoint(iet, pxtmp[inh][iet], pytmp[inh][iet]); gRFB_sys[inh]->SetPoint(iet, px[iet]+pxshift*(nHist-1-inh), pytmp[inh][iet]); } } gRFB_sys[0]->GetXaxis()->SetTitle("E_{T}^{HF |#eta|>4} [GeV]"); gRFB_sys[0]->GetXaxis()->CenterTitle(); gRFB_sys[0]->GetYaxis()->SetTitle("R_{FB}"); gRFB_sys[0]->GetXaxis()->SetLimits(0.,50.0); gRFB_sys[0]->SetMinimum(0.5); gRFB_sys[0]->SetMaximum(1.15); gRFB_sys[0]->SetFillColor(kViolet-9); gRFB_sys[0]->Draw("A2"); gRFB_sys[1]->SetFillColor(kTeal-9); gRFB_sys[1]->Draw("2"); gRFB_sys[2]->SetFillColor(kRed-9); // gRFB_sys[2]->Draw("2"); gRFB_sys[3]->SetFillColor(kAzure-9); // gRFB_sys[3]->Draw("2"); SetGraphStyle(gRFB[0], 8, 2); //1.5-1.93 low SetGraphStyle(gRFB[1], 0, 5); //1.5-1.93 SetGraphStyle(gRFB[2], 1, 3); //0.9-1.5 SetGraphStyle(gRFB[3], 2, 0); //0-0.9 gRFB[0]->SetMarkerSize(1.6); gRFB[0]->Draw("P"); gRFB[1]->SetMarkerSize(2.1); gRFB[1]->Draw("P"); // just for drawing gRFB_sys[0]->SetFillColor(kWhite); gRFB_sys[0]->Draw("A2"); gRFB_sys[1]->Draw("2"); gRFB_sys[2]->Draw("2"); gRFB_sys[3]->Draw("2"); gRFB[1]->Draw("P"); gRFB[2]->Draw("P"); gRFB[3]->Draw("P"); dashedLine(0.,1.,50.,1.,1,1); legBL2 -> SetHeader ("6.5 < p_{T} < 30 GeV/c"); legBL2 -> AddEntry(gRFB[3],"0.0 < |y_{CM}| < 0.9","lp"); legBL2 -> AddEntry(gRFB[2],"0.9 < |y_{CM}| < 1.5","lp"); legBL2 -> AddEntry(gRFB[1],"1.5 < |y_{CM}| < 1.93","lp"); legBL2 ->Draw(); 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( c2, iPeriod, iPos ); c2->Update(); c2->SaveAs(Form("RFB_%s/RFB_ETHF_samept_isPrompt%d_%s.pdf",dirName,(int)isPrompt,runstring.c_str())); c2->SaveAs(Form("RFB_%s/RFB_ETHF_samept_isPrompt%d_%s.png",dirName,(int)isPrompt,runstring.c_str())); #if 0 /////////////////////////////////////////////////////////////////// // save as a root file TFile *outFile = new TFile(Form("RFB_%s/RFB_ETHF_FWonly_isPrompt%d.root",dirName,(int)isPrompt),"RECREATE"); outFile->cd(); for (int inh=0; inh< nHist; inh++) { gRFB_sys[inh]->Write(); gRFB[inh]->Write(); } outFile->Close(); #endif return; } // end of main func.