ATLAS Offline Software
Loading...
Searching...
No Matches
effCurvesVersionsEta.cxx
Go to the documentation of this file.
1
15
17
19
21ATLAS_NO_CHECK_FILE_THREAD_SAFETY; // single-threaded plotting application
22
23#include "TCanvas.h"
24#include "TEnv.h"
25#include "TGraphAsymmErrors.h"
26#include "THStack.h"
27#include "TLegend.h"
28#include "TPad.h"
29
30#include <iostream>
31
33
34void effCurvesVersionsEta(TString config_file_name = "") {
35 if (config_file_name != "") {
36 g_config_file_name = config_file_name;
37 }
38 TEnv env(g_config_file_name);
39
40 g_input_file_path = env.GetValue("input_file_path_TTI", "default");
41 g_output_plot_path = env.GetValue("output_plot_path", "default");
42 g_dataset_name = env.GetValue("dataset_name", "default");
43 g_dataset_description = env.GetValue("dataset_description", "My Sample");
44 g_print_png = env.GetValue("print_png", false);
45 g_do_zoom = env.GetValue("do_zoom", false);
46 g_use_log_scale = env.GetValue("use_log_scale", false);
47 g_work_status = env.GetValue("work_status", "default");
48 g_time_acc_tool = env.GetValue(
49 "time_acc_tool",
50 "HGTD_TrkTimePerformanceStudies.ExpertTrackTimeFromClusters/");
51 g_track_selection_tool = env.GetValue(
52 "track_selection_tool",
53 "HGTD_TrkTimePerformanceStudies.AllTracksSelection/");
54
55 TFile* file = TFile::Open(g_input_file_path, "READ");
56 if (file == nullptr || file->IsZombie()) {
57 std::cout << "could not open input file " << g_input_file_path << std::endl;
58 return;
59 }
60
62
63 efficiencyAndMistagLinePrimeFractionGT50(file, "|#eta|");
64 efficiencyStackPlotAllCases(file, "|#eta|");
65
66 file->Close();
67}
68
69void efficiencyAndMistagLinePrimeFractionGT50(TFile* file, TString xlabel) {
70
71 auto eff = (TEfficiency *)file->Get(g_track_selection_tool + g_time_acc_tool + "m_eff_vs_eta");
72 if (eff == nullptr) {
73 std::cout << "s_m_eff_vs_eta histogram not found" << std::endl;
74 return;
75 }
76 TGraphAsymmErrors *graph_total = eff->CreateGraph();
77 graph_total->SetMarkerStyle(21);
78 graph_total->SetMarkerSize(1.);
79 Color_t marker_color = kBlack;
80 graph_total->SetMarkerColor(marker_color);
81 graph_total->SetLineColor(marker_color);
82 graph_total->SetLineWidth(4);
83
84 auto eff2 = (TEfficiency *)file->Get(g_track_selection_tool + g_time_acc_tool + "m_eff_gt50pcprimes_vs_eta");
85 if (eff2 == nullptr) {
86 std::cout << "histogram m_eff_gt50pcprimes_vs_eta not found" << std::endl;
87 return;
88 }
89 TGraphAsymmErrors *graph2 = eff2->CreateGraph();
90 graph2->SetMarkerStyle(21);
91 graph2->SetMarkerSize(1.);
92 Color_t marker_color2 = kBlue;
93 graph2->SetMarkerColor(marker_color2);
94 graph2->SetLineColor(marker_color2);
95 graph2->SetLineWidth(4);
96
97 auto eff3 = (TEfficiency *)file->Get(g_track_selection_tool + g_time_acc_tool + "m_eff_gt50pcprimes_vs_eta_mistag");
98 if (eff3 == nullptr) {
99 std::cout << "s_m_eff_gt50pcprimes_vs__mistag histogram not found"
100 << std::endl;
101 return;
102 }
103 TGraphAsymmErrors *graph3 = eff3->CreateGraph();
104 graph3->SetMarkerStyle(21);
105 graph3->SetMarkerSize(1.);
106 Color_t marker_color3 = kRed;
107 graph3->SetMarkerColor(marker_color3);
108 graph3->SetLineColor(marker_color3);
109 graph3->SetLineWidth(4);
110
111 TCanvas *canvas = new TCanvas();
112
113 auto hist =
114 new TH1F("axishist", Form(";%s; Time Association Rate", xlabel.Data()),
115 10, 2.4, 4.0);
116 hist->SetAxisRange(0.001, 1.4, "Y");
117 if (g_config_file_name == "muon10_mu0.cfg" or
118 g_config_file_name == "pion0p1to5p0_mu0.cfg") {
119 hist->SetAxisRange(0.001, 1.75, "Y");
120 }
121 hist->Draw();
122
123 Color_t text_color = kBlack;
124 atlas::ATLAS_LABEL(0.19, 0.89, text_color);
125 atlas::myText(0.31, 0.89, text_color, g_work_status.Data());
126
127 graph2->Draw("same P");
128 graph3->Draw("same P");
129
130 float label_text_size = 0.05;
131
132 atlas::myText(0.19, 0.84, text_color, g_dataset_description.Data(), label_text_size);
133
134 atlas::myText(0.19, 0.77, text_color, "Timing scenario \"Initial\"",
135 label_text_size);
136
137 auto legend = new TLegend(0.62, 0.7, 0.9, 0.92);
138 legend->SetFillStyle(0);
139 legend->SetTextFont(42);
140 legend->SetBorderSize(0);
141 legend->SetTextSize(0.04);
142 legend->AddEntry(graph2, "#splitline{Correctly}{reconstructed}", "lp");
143 legend->AddEntry(graph3, "Misassignment", "lp");
144
145 legend->Draw("same");
146
147 gPad->RedrawAxis();
148
149 TString plot_name =
150 Form("%s/efficiencyAndMistagLinePrimeFractionGT50Vseta_%s.pdf",
151 g_output_plot_path.Data(), g_dataset_name.Data());
152 canvas->Print(plot_name);
153 plot_name.ReplaceAll(".pdf", ".png");
154 if (g_print_png)
155 canvas->Print(plot_name);
156
157 plot_name.ReplaceAll(".png", ".C");
158 canvas->Print(plot_name);
159}
160
161void efficiencyStackPlotAllCases(TFile* file, TString xlabel) {
162
163 auto eff = (TEfficiency *)file->Get(g_track_selection_tool + g_time_acc_tool + "m_eff_vs_eta");
164 if (eff == nullptr) {
165 std::cout << "s_m_eff_vs_eta histogram not found" << std::endl;
166 return;
167 }
168 TGraphAsymmErrors *graph_total = eff->CreateGraph();
169 graph_total->SetMarkerStyle(21);
170 graph_total->SetMarkerSize(0);
171 Color_t marker_color = kBlack;
172 graph_total->SetMarkerColor(marker_color);
173 graph_total->SetLineColor(marker_color);
174 graph_total->SetLineWidth(2);
175
176 std::vector<TEfficiency *> effs;
177 std::vector<TH1F *> hists;
178
179 for (size_t i = 0; i < primes_fractions.size(); i++) {
180 TString plotname = Form("m_eff_vs_eta_primesfrac%s",
181 primes_fractions.at(i).Data());
182 auto eff = (TEfficiency *)file->Get(g_track_selection_tool + g_time_acc_tool + plotname);
183 if (eff == nullptr) {
184 std::cout << "efficiencyStackPlotAllCases ERROR\n";
185 std::cout << "could not find " << plotname << '\n';
186 return;
187 }
188 eff->SetFillColor(colors.at(i));
189 effs.push_back(eff);
190 }
191
192 THStack *stack_hist =
193 new THStack("stack_hist", ";|#eta|; Time Association Rate");
194
195 for (size_t i = 0; i < effs.size(); i++) {
196 auto graph = effs.at(i)->CreateGraph();
197 TH1F *hist =
198 turnGraphIntoHist(graph, graph->GetName() + TString::Format("h%zu", i),
199 "", 32, 2.4, 4.0, effs.at(i)->GetFillColor());
200 hist->SetFillColor(colors.at(i));
201 hists.push_back(hist);
202 stack_hist->Add(hist);
203 }
204
205 TCanvas *canvas = new TCanvas();
206 canvas->SetTicks(1, 1);
207
208 auto hist =
209 new TH1F("axishist", Form(";%s; Time Association Rate", xlabel.Data()),
210 10, 2.4, 4.0);
211 hist->SetAxisRange(0.001, 1.6, "Y");
212 if (g_config_file_name == "muon10_mu0.cfg" or
213 g_config_file_name == "pion0p1to5p0_mu0.cfg") {
214 hist->SetAxisRange(0.001, 1.75, "Y");
215 }
216 hist->Draw();
217
218 stack_hist->Draw("same");
219 graph_total->Draw("same p");
220
221 Color_t text_color = kBlack;
222 atlas::ATLAS_LABEL(0.19, 0.89, text_color);
223 atlas::myText(0.31, 0.89, text_color, g_work_status.Data());
224
225 float label_text_size = 0.05;
226
227 atlas::myText(0.19, 0.84, text_color, g_dataset_description.Data(), label_text_size);
228
229 atlas::myText(0.19, 0.77, text_color, "Timing scenario \"Initial\"",
230 label_text_size);
231
232 auto legend = new TLegend(0.65, 0.62, 0.85, 0.94);
233
234 legend->SetTextFont(42);
235 legend->SetFillStyle(0);
236 legend->SetBorderSize(0);
237 legend->SetTextSize(0.035);
238
239 legend->AddEntry(graph_total, "Total", "lp");
240 for (size_t i = 0; i < labels.size(); i++) {
241 legend->AddEntry(hists.at(i), labels.at(i), "f");
242 }
243
244 legend->Draw("same");
245
246 gPad->RedrawAxis();
247
248 TString plot_name = Form("%s/efficiencyStackPlotAllCases_eta_%s.pdf",
249 g_output_plot_path.Data(),
250 g_dataset_name.Data());
251 canvas->Print(plot_name);
252 plot_name.ReplaceAll(".pdf", ".png");
253 if (g_print_png)
254 canvas->Print(plot_name);
255
256 plot_name.ReplaceAll(".png", ".C");
257 canvas->Print(plot_name);
258}
259
261
262TH1F* turnGraphIntoHist(TGraph *graph, TString name, TString label, int bins,
263 double xmin, double xmax, int color) {
264 TH1F *hist = new TH1F(name, label, bins, xmin, xmax);
265 for (int point = 0; point < graph->GetN(); point++) {
266 double x, y;
267 graph->GetPoint(point, x, y);
268 int bin_n = hist->FindFixBin(x);
269 hist->SetBinContent(bin_n, y);
270 }
271 hist->SetFillColor(color);
272 hist->SetLineWidth(0);
273 hist->SetMarkerSize(0);
274 hist->SetMarkerColor(color);
275 return hist;
276}
277
278int main(int argc, char* argv[]) {
279 if (argc != 2) {
280 std::cout << "Syntax: " << argv[0] << " <config file>" << std::endl;
281 return 1;
282 }
283 effCurvesVersionsEta(argv[1]);
284 return 0;
285}
286
static const std::vector< std::string > bins
#define y
#define x
Define macros for attributes used to control the static checker.
#define ATLAS_NO_CHECK_FILE_THREAD_SAFETY
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration.
int main()
Definition hello.cxx:18
std::string label(const std::string &format, int i)
Definition label.h:19
double xmax
Definition listroot.cxx:61
double xmin
Definition listroot.cxx:60
TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
TFile * file