25#include "TGraphAsymmErrors.h"
34void effCurvesVersionsEta(TString config_file_name =
"") {
35 if (config_file_name !=
"") {
36 g_config_file_name = config_file_name;
38 TEnv
env(g_config_file_name);
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(
50 "HGTD_TrkTimePerformanceStudies.ExpertTrackTimeFromClusters/");
51 g_track_selection_tool =
env.GetValue(
52 "track_selection_tool",
53 "HGTD_TrkTimePerformanceStudies.AllTracksSelection/");
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;
63 efficiencyAndMistagLinePrimeFractionGT50(
file,
"|#eta|");
64 efficiencyStackPlotAllCases(
file,
"|#eta|");
69void efficiencyAndMistagLinePrimeFractionGT50(TFile*
file, TString xlabel) {
71 auto eff = (TEfficiency *)
file->Get(g_track_selection_tool + g_time_acc_tool +
"m_eff_vs_eta");
73 std::cout <<
"s_m_eff_vs_eta histogram not found" << std::endl;
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);
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;
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);
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"
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);
111 TCanvas *
canvas =
new TCanvas();
114 new TH1F(
"axishist", Form(
";%s; Time Association Rate", xlabel.Data()),
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");
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());
127 graph2->Draw(
"same P");
128 graph3->Draw(
"same P");
130 float label_text_size = 0.05;
132 atlas::myText(0.19, 0.84, text_color, g_dataset_description.Data(), label_text_size);
134 atlas::myText(0.19, 0.77, text_color,
"Timing scenario \"Initial\"",
137 auto legend =
new TLegend(0.62, 0.7, 0.9, 0.92);
141 legend->SetTextSize(0.04);
142 legend->AddEntry(graph2,
"#splitline{Correctly}{reconstructed}",
"lp");
143 legend->AddEntry(graph3,
"Misassignment",
"lp");
150 Form(
"%s/efficiencyAndMistagLinePrimeFractionGT50Vseta_%s.pdf",
151 g_output_plot_path.Data(), g_dataset_name.Data());
153 plot_name.ReplaceAll(
".pdf",
".png");
157 plot_name.ReplaceAll(
".png",
".C");
161void efficiencyStackPlotAllCases(TFile*
file, TString xlabel) {
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;
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);
176 std::vector<TEfficiency *> effs;
177 std::vector<TH1F *>
hists;
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';
192 THStack *stack_hist =
193 new THStack(
"stack_hist",
";|#eta|; Time Association Rate");
195 for (
size_t i = 0;
i < effs.size();
i++) {
196 auto graph = effs.at(i)->CreateGraph();
198 turnGraphIntoHist(graph, graph->GetName() + TString::Format(
"h%zu", i),
199 "", 32, 2.4, 4.0, effs.at(i)->GetFillColor());
201 hists.push_back(hist);
202 stack_hist->Add(hist);
205 TCanvas *
canvas =
new TCanvas();
209 new TH1F(
"axishist", Form(
";%s; Time Association Rate", xlabel.Data()),
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");
218 stack_hist->Draw(
"same");
219 graph_total->Draw(
"same p");
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());
225 float label_text_size = 0.05;
227 atlas::myText(0.19, 0.84, text_color, g_dataset_description.Data(), label_text_size);
229 atlas::myText(0.19, 0.77, text_color,
"Timing scenario \"Initial\"",
232 auto legend =
new TLegend(0.65, 0.62, 0.85, 0.94);
237 legend->SetTextSize(0.035);
239 legend->AddEntry(graph_total,
"Total",
"lp");
240 for (
size_t i = 0;
i <
labels.size();
i++) {
248 TString plot_name = Form(
"%s/efficiencyStackPlotAllCases_eta_%s.pdf",
249 g_output_plot_path.Data(),
250 g_dataset_name.Data());
252 plot_name.ReplaceAll(
".pdf",
".png");
256 plot_name.ReplaceAll(
".png",
".C");
262TH1F* turnGraphIntoHist(TGraph *graph, TString name, TString
label,
int bins,
265 for (
int point = 0; point < graph->GetN(); point++) {
267 graph->GetPoint(point,
x,
y);
268 int bin_n =
hist->FindFixBin(
x);
269 hist->SetBinContent(bin_n,
y);
272 hist->SetLineWidth(0);
273 hist->SetMarkerSize(0);
278int main(
int argc,
char* argv[]) {
280 std::cout <<
"Syntax: " <<
argv[0] <<
" <config file>" << std::endl;
283 effCurvesVersionsEta(argv[1]);
static const std::vector< std::string > bins
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.
std::string label(const std::string &format, int i)
TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)