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);
32 gROOT->SetBatch(
true);
38 Long64_t ntrack {ntp_track->GetEntries()};
40 TH1F *h_true_count {
new TH1F(
"h_true_count",
"Psuedorapidity count", 100, -5, 5)};
41 h_true_count->SetXTitle(
"#eta");
42 h_true_count->SetYTitle(
"Count");
43 h_true_count->SetLineColor(kBlue);
46 for (Long64_t
i {0};
i < ngtrack; ++
i) {
50 h_true_count->Fill(geta);
52 TH1F *h_reco_count {
new TH1F(
"h_reco_count",
"Psuedorapidity count", 100, -5, 5)};
53 h_reco_count->SetXTitle(
"#eta");
54 h_reco_count->SetYTitle(
"Count");
55 h_reco_count->SetLineColor(kRed);
57 ntp_track->SetBranchAddress(
"geta", &geta);
58 ntp_track->SetBranchAddress(
"gpx", &gpx);
59 ntp_track->SetBranchAddress(
"gpy", &gpy);
60 ntp_track->SetBranchAddress(
"gpz", &gpz);
61 ntp_track->SetBranchAddress(
"px", &px);
62 ntp_track->SetBranchAddress(
"py", &py);
63 ntp_track->SetBranchAddress(
"pz", &pz);
64 for (Long64_t
i {0};
i < ntrack; ++
i) {
65 if (ntp_track->LoadTree(
i) < 0)
68 ntp_track->GetEntry(
i);
72 h_reco_count->Fill(geta);
75 const Long64_t
nbins {h_true_count->GetSize() - 2};
76 Double_t *
x {
new Double_t[
nbins]};
77 Double_t *
y {
new Double_t[
nbins]};
78 Double_t *ey {
new Double_t[
nbins]};
80 for (Long64_t
i {0};
i <
nbins; ++
i) {
81 if (h_true_count->GetBinContent(
i + 1) != 0) {
82 const Double_t
n {h_reco_count->GetBinContent(
i + 1)};
83 const Double_t
N {h_true_count->GetBinContent(
i + 1)};
85 x[top] = {h_true_count->GetBinCenter(
i + 1)};
87 ey[top++] = {sqrt(
n / (
N *
N) + (
n *
n) / (N * N * N))};
90 TGraphErrors *
gr {
new TGraphErrors(top,
x,
y,
nullptr, ey)};
91 gr->SetMarkerColor(kBlue);
92 gr->SetMarkerStyle(21);
93 gr->SetMarkerSize(0.5);
94 gr->GetXaxis()->SetTitle(
"#eta");
95 gr->GetYaxis()->SetTitle(
"Efficiency");
97 TCanvas *
count {
new TCanvas(
"count",
"SVTX Event Count",
98 gStyle->GetCanvasDefW(), gStyle->GetCanvasDefH())};
99 h_true_count->GetYaxis()->SetRangeUser(0, 2000);
100 h_true_count->Draw();
101 h_reco_count->Draw(
"SAME");
102 TLegend *
l1 {
new TLegend(0.825, .90, .95, 0.80,
"Track")};
103 l1->SetTextSize(0.03);
104 l1->AddEntry(h_true_count,
"True",
"l");
105 l1->AddEntry(h_reco_count,
"Reco",
"l");
109 TCanvas *efficiency {
new TCanvas(
"efficiency",
"SVTX Efficiency",
110 gStyle->GetCanvasDefW(), gStyle->GetCanvasDefH())};
111 gr->GetYaxis()->SetRangeUser(-0.05, 1);
113 TLegend *
l2 {
new TLegend(0.825, 0.90, 0.95, 0.8,
"Track")};
114 l2->SetTextSize(0.03);
115 l2->AddEntry(
gr,
"Efficiency",
"l");
119 TImage *
const img {TImage::Create()};
121 std::stringstream
name;
123 img->WriteImage(
strdup(name.str().c_str()));
126 img->FromPad(efficiency);
127 name <<
"SVTX_Efficiency-" <<
"margin=" << MOMENTUM_MARGIN <<
".png";
128 img->WriteImage(
strdup(name.str().c_str()));
129 gApplication->Terminate(0);
132 TTree *
load_tree(
const char *
const file_name,
const char *
const tree_name)
134 return (TTree *) (
new TFile(file_name,
"READ"))->
Get(tree_name);
137 int main(
int argc,
char *argv[])
139 TApplication
app {
"SVTX Efficiency Plots", &argc, argv};
141 std::stringstream
tmp {argv[1]};