8 #include <unordered_map>
20 #include "TApplication.h"
21 #include "TGraphErrors.h"
22 #include "/sphenix/user/gregtom3/SBU/research/macros/macros/sPHENIXStyle/sPhenixStyle.C"
24 TTree *
load_tree(
const char *
const file_name,
const char *
const tree_name);
26 {
"/sphenix/user/gregtom3/data/Summer2018/fasttrack-efficiency-10GeV/fasttrack.root"};
32 gROOT->SetBatch(
true);
38 TH1F *h_true_count {
new TH1F(
"h_true_count",
"Psuedorapidity count", 100, -5, 5)};
39 h_true_count->SetXTitle(
"#eta");
40 h_true_count->SetYTitle(
"Count");
41 h_true_count->SetLineColor(kBlue);
42 TH1F *h_reco_count {
new TH1F(
"h_reco_count",
"Psuedorapidity count", 100, -5, 5)};
43 h_reco_count->SetXTitle(
"#eta");
44 h_reco_count->SetYTitle(
"Count");
45 h_reco_count->SetLineColor(kRed);
47 tracks->SetBranchAddress(
"gpx", &gpx);
48 tracks->SetBranchAddress(
"gpy", &gpy);
49 tracks->SetBranchAddress(
"gpz", &gpz);
50 tracks->SetBranchAddress(
"px", &px);
51 tracks->SetBranchAddress(
"py", &py);
52 tracks->SetBranchAddress(
"pz", &pz);
57 const double mom {std::sqrt(px * px + py * py + pz * pz)};
58 const double eta {0.5 *std::log((mom + pz) / (mom - pz))};
59 const double gmom {std::sqrt(gpx * gpx + gpy * gpy + gpz * gpz)};
60 const double geta {0.5 *std::log((gmom + gpz) / (gmom - gpz))};
62 h_true_count->Fill(
geta);
66 h_reco_count->Fill(
geta);
70 const Long64_t
nbins {h_true_count->GetSize() - 2};
71 Double_t *
x {
new Double_t[
nbins]};
72 Double_t *
y {
new Double_t[
nbins]};
73 Double_t *ey {
new Double_t[
nbins]};
75 for (Long64_t
i {0};
i <
nbins; ++
i) {
76 if (h_true_count->GetBinContent(
i + 1) != 0) {
77 const Double_t
n {h_reco_count->GetBinContent(
i + 1)};
78 const Double_t
N {h_true_count->GetBinContent(
i + 1)};
80 x[top] = {h_true_count->GetBinCenter(
i + 1)};
82 ey[top++] = {sqrt(
n / (
N *
N) + (
n *
n) / (N * N * N))};
85 TGraphErrors *
gr {
new TGraphErrors(top,
x,
y,
nullptr, ey)};
86 gr->SetMarkerColor(kBlue);
87 gr->SetMarkerStyle(21);
88 gr->SetMarkerSize(0.5);
89 gr->GetXaxis()->SetTitle(
"#eta");
90 gr->GetYaxis()->SetTitle(
"Efficiency");
92 TCanvas *
count {
new TCanvas(
"count",
"FastTrack Event Count",
93 gStyle->GetCanvasDefW(), gStyle->GetCanvasDefH())};
94 h_true_count->GetYaxis()->SetRangeUser(0, 2000);
96 h_reco_count->Draw(
"SAME");
97 TLegend *
l1 {
new TLegend(0.825, .9, .95, 0.8,
"Track")};
98 l1->SetTextSize(0.03);
99 l1->AddEntry(h_true_count,
"True",
"l");
100 l1->AddEntry(h_reco_count,
"Reco",
"l");
104 TCanvas *efficiency {
new TCanvas(
"efficiency",
"FastTrack Efficiency",
105 gStyle->GetCanvasDefW(), gStyle->GetCanvasDefH())};
106 gr->GetYaxis()->SetRangeUser(-0.05, 1);
108 TLegend *
l2 {
new TLegend(0.825, 0.9, 0.95, 0.8,
"Track")};
109 l2->SetTextSize(0.03);
110 l2->AddEntry(
gr,
"Efficiency",
"l");
114 TImage *
const img {TImage::Create()};
116 std::stringstream
name;
119 img->WriteImage(
strdup(name.str().c_str()));
122 img->FromPad(efficiency);
123 name <<
"FastTrack_Efficiency-" <<
"margin=" << MOMENTUM_MARGIN <<
125 img->WriteImage(
strdup(name.str().c_str()));
126 gApplication->Terminate(0);
129 TTree *
load_tree(
const char *
const file_name,
const char *
const tree_name)
131 return (TTree *) (
new TFile(file_name,
"READ"))->
Get(tree_name);
134 int main(
int argc,
char *argv[])
136 TApplication
app {
"FastTrack Efficiency Plots", &argc, argv};
138 std::stringstream
tmp {argv[1]};