34 gStyle->SetOptStat(0);
35 gStyle->SetOptTitle(0);
40 bool print_plots =
true;
50 const char* inDir =
"/phenix/plhf/dcm07e/sPHENIX/bjetsims/ana";
57 double lumiDesired = 200;
58 TString scol(
"p + p #sqrt{s_{_{NN}}} = 200 GeV");
59 TString slumi(Form(
"#int L dt = %.0f pb^{-1} |z| < 10 cm", lumiDesired));
65 double evntDesired = 24e9;
66 lumiDesired = evntDesired * 962 / 42e9;
67 scol =
"0-10% Au + Au #sqrt{s_{_{NN}}}=200 GeV";
68 slumi = Form(
"%.0fB events |z| < 10 cm", evntDesired / 1.e9);
72 double lumiPerFile = 99405 / (4.641e-06 * 1e12);
81 double bJetEff = 0.60;
85 double bJetPur = 0.40;
91 const int NETACUT = 3;
92 double etacut[] = {1.3, 1.0, 0.7};
93 double etaColor[] = {kBlue, kRed, kBlack};
96 double ptcut[] = {10, 20, 40};
97 double ptColor[] = {kBlue, kRed, kBlack};
107 Int_t truthjet_parton_flavor[100];
108 Int_t truthjet_hadron_flavor[100];
109 Float_t truthjet_pt[100];
110 Float_t truthjet_eta[100];
111 Float_t truthjet_phi[100];
115 TH1D* hjet_pT =
new TH1D(
"hjet_pT",
";p_{T}^{jet} [GeV/c]", 20, 0, 100);
116 TH1D* hjet_eta =
new TH1D(
"hjet_eta",
";#eta^{jet}", 40, -2., 2.);
117 TH1D* hjet_phi =
new TH1D(
"hjet_phi",
";#phi^{jet}", 40, -4, 4);
119 TH1D* hdijet_pT1 =
new TH1D(
"hdijet_pT1",
";p_{T,1}^{jet} [GeV/c]", 20, 0, 100);
120 TH1D* hdijet_pT2 =
new TH1D(
"hdijet_pT2",
";p_{T,2}^{jet} [GeV/c]", 20, 0, 100);
121 TH1D* hdijet_xj =
new TH1D(
"hdijet_xj",
";x_{j} = p_{T,2} / p_{T,1}; event fraction", 10, 0, 1);
122 TH1D* hdijet_dphi =
new TH1D(
"hdijet_dphi",
";|#Delta#phi_{12}|; event fraction", 10, 0, TMath::Pi());
124 TH1D* hdijet_sing_pT1 =
new TH1D(
"hdijet_sing_pT1",
125 ";p_{T,1} [GeV/c];Fraction of Dijet / Single Accepted",
127 TH1D* hdijet_sing_eta2 =
new TH1D(
"hdijet_sing_eta2",
128 ";#eta_{2};Fraction of Dijet / Single Accepted",
130 TH1D* hdijet_eff_pT1[3];
131 TH1D* hdijet_eff_eta2[3];
132 for (
int i = 0;
i < NETACUT;
i++)
134 hdijet_eff_pT1[
i] =
new TH1D(Form(
"hdijet_eff_pT1_%i",
i),
135 ";p_{T,1} [GeV/c];Fraction of Dijet / Single Accepted",
137 hdijet_eff_pT1[
i]->SetLineColor(etaColor[
i]);
138 hdijet_eff_pT1[
i]->SetLineWidth(2);
140 for (
int i = 0;
i < PTCUT;
i++)
142 hdijet_eff_eta2[
i] =
new TH1D(Form(
"hdijet_eff_eta2_%i",
i),
143 ";#eta;Fraction of Dijet / Single Accepted",
145 hdijet_eff_eta2[
i]->SetLineColor(etaColor[
i]);
146 hdijet_eff_eta2[
i]->SetLineWidth(2);
155 hdijet_dphi->Sumw2();
162 TRandom3 *rand =
new TRandom3();
187 cout <<
"--> Reading data from dir: " << inDir << endl;
190 int nfiles = (int)(lumiDesired / lumiPerFile);
191 cout <<
" desired luminosity : " << lumiDesired << endl;
192 cout <<
" luminosity per file: " << lumiPerFile << endl;
193 cout <<
" N files needed : " << nfiles << endl;
197 int nfound = (gSystem->GetFromPipe(Form(
"ls %s/*.root | wc -l", inDir))).Atoi();
198 cout <<
" N files found : " << nfound << endl;
202 cout <<
"WARNING!! There are not enough files for the desired luminosity." << endl;
203 cout <<
" Will scale the statistical uncertainties accordingly." << endl;
208 ttree =
new TChain(
"ttree");
211 TString fileList = gSystem->GetFromPipe(Form(
"ls %s/*.root", inDir));
213 int spos = fileList.First(
"\n");
214 while (spos > 0 && nread < nfiles)
216 TString
tfile = fileList(0, spos);
219 ttree->Add(tfile.Data());
223 fileList = fileList(spos + 1, fileList.Length());
224 spos = fileList.First(
"\n");
228 cout <<
" successfully read in " << nread <<
" files" << endl;
229 lumiRead = lumiPerFile * nread;
232 ttree->SetBranchAddress(
"event", &event);
233 ttree->SetBranchAddress(
"truthjet_n", &truthjet_n);
234 ttree->SetBranchAddress(
"truthjet_parton_flavor", truthjet_parton_flavor);
235 ttree->SetBranchAddress(
"truthjet_hadron_flavor", truthjet_hadron_flavor);
236 ttree->SetBranchAddress(
"truthjet_pt", truthjet_pt);
237 ttree->SetBranchAddress(
"truthjet_eta", truthjet_eta);
238 ttree->SetBranchAddress(
"truthjet_phi", truthjet_phi);
240 Long64_t nentries = ttree->GetEntries();
247 cout <<
"--> Running over " << nentries << endl;
250 for (Long64_t ientry = 0; ientry < nentries; ientry++)
252 ttree->GetEntry(ientry);
254 if (ientry % 100000 == 0) cout <<
"----> Processing event " << ientry << endl;
257 for (
int i = 0;
i < truthjet_n;
i++)
258 acc[
i] = (rand->Uniform() < bJetEff);
262 for (
int i = 0;
i < truthjet_n;
i++)
264 if (TMath::Abs(truthjet_parton_flavor[
i]) != 5)
268 hjet_pT->Fill(truthjet_pt[i]);
269 hjet_eta->Fill(truthjet_eta[i]);
270 hjet_phi->Fill(truthjet_phi[i]);
272 for (
int j = i + 1;
j < truthjet_n;
j++)
274 if (TMath::Abs(truthjet_parton_flavor[
j]) != 5)
285 if (truthjet_pt[i] > truthjet_pt[j])
296 pT1 = truthjet_pt[i1];
297 phi1 = truthjet_phi[i1];
298 eta1 = truthjet_eta[i1];
301 pT2 = truthjet_pt[i2];
302 phi2 = truthjet_phi[i2];
303 eta2 = truthjet_eta[i2];
310 cout <<
" ientry: " << ientry << endl
311 <<
" i1:" << i1 <<
" pT1:" << pT1 <<
" eta1:" << eta1 <<
" acc1:" << acc1 << endl
312 <<
" i2:" << i2 <<
" pT2:" << pT2 <<
" eta2:" << eta2 <<
" acc2:" << acc2 << endl;
320 if ( pT1 < pT1min || TMath::Abs(eta1) > etamax || !acc1 || rand->Uniform() > RAA)
324 double dphi = TMath::Abs(TMath::ATan2(TMath::Sin(phi1 - phi2), TMath::Cos(phi1 - phi2)));
325 if (dphi > TMath::Pi())
326 cout <<
" " << truthjet_phi[
i] <<
" " << truthjet_phi[
j] <<
" " << dphi << endl;
329 hdijet_sing_pT1->Fill(pT1);
332 if ( pT2 < pT2min || TMath::Abs(eta2) > etamax || !acc2 )
335 hdijet_sing_eta2->Fill(eta2);
339 for (
int k = 0;
k < NETACUT;
k++)
341 if ( TMath::Abs(eta2) < etacut[
k])
342 hdijet_eff_pT1[
k]->Fill(pT1);
344 for (
int k = 0;
k < PTCUT;
k++)
347 hdijet_eff_eta2[
k]->Fill(eta2);
350 hdijet_dphi->Fill(dphi);
352 if ( dphi < 2.*TMath::Pi() / 3)
358 hdijet_pT1->Fill(pT1);
359 hdijet_pT2->Fill(pT2);
360 hdijet_xj->Fill(pT2 / pT1);
368 cout <<
" N b dijets: " << hdijet_dphi->Integral() << endl;
369 cout <<
" N b dijets w / dphi cut: " << hdijet_xj->Integral() << endl;
372 for (
int i = 0;
i < NETACUT;
i++)
374 hdijet_eff_pT1[
i]->Divide(hdijet_sing_pT1);
375 cout <<
" i: " << hdijet_eff_pT1[
i]->GetMaximum() << endl;
377 for (
int i = 0;
i < PTCUT;
i++)
379 hdijet_eff_eta2[
i]->Divide(hdijet_sing_eta2);
383 hdijet_dphi->Scale(1. / hdijet_dphi->Integral());
384 hdijet_xj->Scale(1. / hdijet_xj->Integral());
387 if ( lumiRead < lumiDesired )
390 cout <<
"-- Scaling statistical uncertainties by:" << endl;
391 cout <<
" sqrt(" << lumiRead <<
"/" << lumiDesired <<
") = "
392 << TMath::Sqrt(lumiRead / lumiDesired) << endl;
393 for (
int ix = 1; ix <= hdijet_xj->GetNbinsX(); ix++)
395 double be = hdijet_xj->GetBinError(ix);
396 be = be * TMath::Sqrt(lumiRead / lumiDesired);
397 hdijet_xj->SetBinError(ix, be);
402 hdijet_xj_fix = (TH1D*) hdijet_xj->Clone(
"hdijet_xj_fix");
403 hdijet_xj_fix->SetLineColor(kRed);
404 hdijet_xj_fix->SetMarkerColor(kRed);
405 for (
int ix = 1; ix <= hdijet_xj->GetNbinsX(); ix++)
407 double bc = hdijet_xj->GetBinContent(ix);
408 double be = hdijet_xj->GetBinError(ix);
412 be = be / TMath::Sqrt(bJetPur * bJetPur);
413 hdijet_xj_fix->SetBinError(ix, be);
422 cout <<
"--> Calculating <x_j>" << endl;
427 for (
int i = 1;
i <= hdijet_xj->GetNbinsX();
i++)
429 double c = hdijet_xj->GetBinContent(
i);
432 sum += c * hdijet_xj->GetBinCenter(
i);
434 err += TMath::Power(c * hdijet_xj->GetBinError(
i), 2);
437 double mean = sum / w;
438 err = TMath::Sqrt(err) / w;
440 cout <<
" <x_j>=" << mean <<
" +/- " << err << endl;
446 cout <<
"-- > Plotting" << endl;
448 hdijet_xj->SetMarkerStyle(kFullCircle);
449 hdijet_xj->SetMarkerColor(kBlack);
450 hdijet_xj->SetLineColor(kBlack);
462 hdijet_xj_fix->SetMarkerStyle(kFullCircle);
463 hdijet_xj_fix->SetMarkerColor(kBlack);
464 hdijet_xj_fix->SetLineColor(kBlack);
466 hdijet_dphi->SetMarkerStyle(kFullCircle);
467 hdijet_dphi->SetMarkerColor(kBlack);
468 hdijet_dphi->SetLineColor(kBlack);
469 hdijet_dphi->GetYaxis()->SetTitleFont(63);
470 hdijet_dphi->GetYaxis()->SetTitleSize(24);
471 hdijet_dphi->GetYaxis()->SetTitleOffset(1.4);
472 hdijet_dphi->GetYaxis()->SetLabelFont(63);
473 hdijet_dphi->GetYaxis()->SetLabelSize(20);
474 hdijet_dphi->GetXaxis()->SetTitleFont(63);
475 hdijet_dphi->GetXaxis()->SetTitleSize(24);
476 hdijet_dphi->GetXaxis()->SetTitleOffset(1.0);
477 hdijet_dphi->GetXaxis()->SetLabelFont(63);
478 hdijet_dphi->GetXaxis()->SetLabelSize(20);
480 hdijet_pT1->SetLineColor(kBlue);
481 hdijet_pT2->SetLineColor(kRed);
483 TH1D* heff_axis_pt =
new TH1D(
"heff_axis_pt",
484 "; p_{T, 1} [GeV / c]; Fraction of Dijet / Single Accepted",
486 heff_axis_pt->SetMinimum(0);
487 heff_axis_pt->SetMaximum(1.);
488 heff_axis_pt->GetYaxis()->SetTitleFont(63);
489 heff_axis_pt->GetYaxis()->SetTitleSize(24);
490 heff_axis_pt->GetYaxis()->SetTitleOffset(1.4);
491 heff_axis_pt->GetYaxis()->SetLabelFont(63);
492 heff_axis_pt->GetYaxis()->SetLabelSize(20);
493 heff_axis_pt->GetXaxis()->SetTitleFont(63);
494 heff_axis_pt->GetXaxis()->SetTitleSize(24);
495 heff_axis_pt->GetXaxis()->SetTitleOffset(1.0);
496 heff_axis_pt->GetXaxis()->SetLabelFont(63);
497 heff_axis_pt->GetXaxis()->SetLabelSize(20);
499 TH1D* heff_axis_eta =
new TH1D(
"heff_axis_eta",
500 "; #eta_{2}; Fraction of Dijet / Single Accepted",
502 heff_axis_eta->SetMinimum(0);
503 heff_axis_eta->SetMaximum(1.);
504 heff_axis_eta->GetYaxis()->SetTitleFont(63);
505 heff_axis_eta->GetYaxis()->SetTitleSize(24);
506 heff_axis_eta->GetYaxis()->SetTitleOffset(1.4);
507 heff_axis_eta->GetYaxis()->SetLabelFont(63);
508 heff_axis_eta->GetYaxis()->SetLabelSize(20);
509 heff_axis_eta->GetXaxis()->SetTitleFont(63);
510 heff_axis_eta->GetXaxis()->SetTitleSize(24);
511 heff_axis_eta->GetXaxis()->SetTitleOffset(1.0);
512 heff_axis_eta->GetXaxis()->SetLabelFont(63);
513 heff_axis_eta->GetXaxis()->SetLabelSize(20);
515 for (
int i = 0;
i < NETACUT;
i++)
519 TLegend *leg_jetpt =
new TLegend(0.6, 0.5, 0.95, 0.95);
520 leg_jetpt->SetFillStyle(0);
521 leg_jetpt->SetBorderSize(0);
522 leg_jetpt->SetTextFont(63);
523 leg_jetpt->SetTextSize(12);
524 leg_jetpt->AddEntry(hjet_pT,
"Inclusive b - jet",
"L");
525 leg_jetpt->AddEntry(hdijet_pT1,
"leading b - jet",
"L");
526 leg_jetpt->AddEntry(hdijet_pT2,
"subleading b - jet",
"L");
532 ltxt.SetTextFont(63);
533 ltxt.SetTextSize(20);
540 TCanvas *cjet =
new TCanvas(
"cjet",
"b - jet", 1200, 400);
541 cjet->SetMargin(0, 0, 0, 0);
544 cjet->GetPad(1)->SetMargin(0.12, 0.02, 0.12, 0.02);
545 cjet->GetPad(2)->SetMargin(0.12, 0.02, 0.12, 0.02);
546 cjet->GetPad(3)->SetMargin(0.12, 0.02, 0.12, 0.02);
550 hjet_pT->GetYaxis()->SetRangeUser(0.5, 1.5 * hjet_pT->GetMaximum());
551 hjet_pT->GetXaxis()->SetRangeUser(0, 50);
559 hjet_eta->Draw(
"HIST");
562 hjet_phi->Draw(
"HIST");
566 TCanvas *ceff =
new TCanvas(
"ceff",
"eff", 1200, 600);
568 ceff->GetPad(1)->SetMargin(0.12, 0.02, 0.12, 0.02);
569 ceff->GetPad(1)->SetTicks(1, 1);
570 ceff->GetPad(2)->SetMargin(0.12, 0.02, 0.12, 0.02);
571 ceff->GetPad(2)->SetTicks(1, 1);
575 heff_axis_pt->Draw();
577 for (
int i = 0; i < NETACUT; i++)
578 hdijet_eff_pT1[i]->
Draw(
"L same");
582 heff_axis_eta->Draw();
584 for (
int i = 0; i < NETACUT; i++)
585 hdijet_eff_eta2[i]->
Draw(
"L same");
588 TCanvas *cdijet2 =
new TCanvas(
"cdijet2",
"dijet", 1200, 600);
589 cdijet2->SetMargin(0, 0, 0, 0);
590 cdijet2->Divide(2, 1);
592 cdijet2->GetPad(1)->SetMargin(0.12, 0.02, 0.12, 0.02);
593 cdijet2->GetPad(2)->SetMargin(0.12, 0.02, 0.12, 0.02);
598 ltxt.DrawLatex(0.2, 0.92,
"Di b-jets (Pythia8)");
599 ltxt.DrawLatex(0.2, 0.86,
"p + p #sqrt{s_{_{NN}}}=200 GeV");
600 ltxt.DrawLatex(0.2, 0.80,
"anti - k_ {T}, R = 0.4");
601 ltxt.DrawLatex(0.2, 0.74, Form(
"p_{T, 1} > % .0f GeV", pT1min));
602 ltxt.DrawLatex(0.2, 0.68, Form(
"p_{T, 2} > % .0f GeV", pT2min));
603 ltxt.DrawLatex(0.2, 0.62, Form(
" | #Delta#phi_{12}| > 2#pi/3"));
614 TCanvas *cdijet =
new TCanvas(
"cdijet",
"dijet", 600, 600);
618 hdijet_xj_fix->GetYaxis()->SetRangeUser(0, 0.3);
619 hdijet_xj_fix->Draw();
623 TLegend *legsphenix =
new TLegend(0.15, 0.5, 0.5, 0.9);
624 legsphenix->SetFillStyle(0);
625 legsphenix->SetBorderSize(0);
626 legsphenix->AddEntry(
"",
"#it{#bf{sPHENIX}} Simulation",
"");
627 legsphenix->AddEntry(
"",
"Di b-jets (Pythia8, CTEQ6L)",
"");
638 legsphenix->AddEntry(
"", scol.Data(),
"");
639 legsphenix->AddEntry(
"", slumi.Data(),
"");
640 legsphenix->AddEntry(
"",
"anti-k_{T}, R = 0.4",
"");
641 legsphenix->AddEntry(
"", Form(
" |#eta| < %.1f", etamax),
"");
642 legsphenix->AddEntry(
"", Form(
" |#Delta#phi_{12}| > 2#pi/3"),
"");
643 legsphenix->AddEntry(
"", Form(
"p_{T, 1} > % .0f GeV", pT1min),
"");
644 legsphenix->AddEntry(
"", Form(
"p_{T, 2} > % .0f GeV", pT2min),
"");
645 legsphenix->AddEntry(
"", Form(
"%.0f%% b-jet Eff, %.0f%% b-jet Pur.", bJetEff * 100., bJetPur * 100.),
"");
646 legsphenix->Draw(
"same");
675 cdijet->Print(
"dibjet_imbalance_pp.pdf");
676 cdijet->Print(
"dibjet_imbalance_pp.C");
677 cdijet->Print(
"dibjet_imbalance_pp.root");
679 TFile *
fout =
new TFile(
"dibjet_imbalance_histos_pp.root",
"RECREATE");
682 hdijet_xj_fix->Write();
689 cdijet->Print(
"dibjet_imbalance_AuAu0-10.pdf");
690 cdijet->Print(
"dibjet_imbalance_AuAu0-10.C");
691 cdijet->Print(
"dibjet_imbalance_AuAu0-10.root");
693 TFile *
fout =
new TFile(
"dibjet_imbalance_histos_AuAu0-10.root",
"RECREATE");
696 hdijet_xj_fix->Write();