ATLAS Offline Software
Loading...
Searching...
No Matches
timeResSplitCases.cxx
Go to the documentation of this file.
1
14
16
17#include "timeResSplitCases.h"
18
20ATLAS_NO_CHECK_FILE_THREAD_SAFETY; // single-threaded plotting application
21
22#include "TCanvas.h"
23#include "TEnv.h"
24#include "THStack.h"
25#include "TLegend.h"
26#include "TPad.h"
27
28#include <iostream>
29
30void timeResSplitCases(TString config_file_name = "") {
31 if (config_file_name != "") {
32 g_config_file_name = config_file_name;
33 }
34
35 TEnv env(g_config_file_name);
36
37 g_input_file_path = env.GetValue("input_file_path_TTI", "default");
38 g_output_plot_path = env.GetValue("output_plot_path", "default");
39 dataset_name = env.GetValue("dataset_name", "default");
40 g_dataset_description = env.GetValue("dataset_description", "My Sample");
41 print_png = env.GetValue("print_png", false);
42 do_zoom = env.GetValue("do_zoom", false);
43 g_use_log_scale = env.GetValue("use_log_scale", false);
44 work_status = env.GetValue("work_status", "default");
45 g_time_acc_tool = env.GetValue(
46 "time_acc_tool",
47 "HGTD_TrkTimePerformanceStudies.ExpertTrackTimeFromClusters/");
48 g_track_selection_tool = env.GetValue(
49 "track_selection_tool",
50 "HGTD_TrkTimePerformanceStudies.AllTracksSelection/");
51
52 TFile* file = TFile::Open(g_input_file_path, "READ");
53 if (file == nullptr || file->IsZombie()) {
54 std::cout << "could not open input file " << g_input_file_path << std::endl;
55 return;
56 }
57
59
60 plot(file);
61
62}
63
64void plot(TFile* file) {
65
66 std::vector<Color_t> colors = {
67 kTeal + 4, kTeal + 2, kTeal, kTeal - 9, kMagenta, kRed, kRed, kRed, kRed};
68
69 std::vector<TH1F *> hists;
70 std::cout << g_track_selection_tool + g_time_acc_tool << std::endl;
71
72 for (const TString& primes_fraction : primes_fractions) {
73 TString plotname = "m_hist_timeres_outlier_cases" + primes_fraction;
74 auto hist = (TH1F*)file->Get(g_track_selection_tool + g_time_acc_tool +
75 plotname);
76 if (hist == nullptr) {
77 std::cout << "could not find " << plotname << std::endl;
78 return;
79 }
80 hists.push_back(hist);
81 }
82
83 auto overall_hist =
84 new TH1F("overall_hist", ";t_{reco} - t_{truth} [ns]; number of tracks",
85 200, -.4, 0.4);
86 for (const auto &h : hists) {
87 overall_hist->Add(h);
88 }
89
90 THStack *stack_hist =
91 new THStack("stack_hist", ";t_{reco} - t_{truth} [ns]; Number of Tracks");
92
93 for (size_t i = 0; i < hists.size(); i++) {
94 hists.at(i)->SetFillColor(colors.at(i));
95 hists.at(i)->SetLineWidth(0.);
96 stack_hist->Add(hists.at(i));
97 }
98
99 stack_hist->SetMaximum(stack_hist->GetMaximum() * 1.7);
100
101 if (do_zoom) {
102 stack_hist->SetMaximum(100);
103 }
104
105 TCanvas *c = new TCanvas();
106 c->SetTicks(1, 1);
107 if (g_use_log_scale) {
108 c->SetLogy();
109 }
110
111 auto hist = new TH1F(
112 "axishist", ";t_{reco} - t_{truth} [ns]; Number of Tracks", 10, -0.4, 0.4);
113
114 if (g_use_log_scale) {
115 hist->SetAxisRange(1, 1.e8, "Y");
116 } else {
117 hist->SetAxisRange(0, 0.08, "Y");
118 }
119
120 hist->Draw();
121
122 stack_hist->Draw("hist same");
123
124 overall_hist->SetMarkerColor(kBlack);
125 overall_hist->SetLineWidth(0);
126 overall_hist->SetMarkerStyle(20);
127 overall_hist->SetMarkerSize(0);
128
129 c->Update();
130
131 gPad->RedrawAxis();
132
133
134 Color_t text_color = kBlack;
135 atlas::ATLAS_LABEL(0.19, 0.88, text_color);
136 atlas::myText(0.31, 0.88, text_color, work_status);
137
138 float label_text_size = 0.05;
139
140 atlas::myText(0.19, 0.83, text_color, g_dataset_description.Data(), label_text_size);
141 atlas::myText(0.19, 0.77, text_color, "Timing scenario \"Initial\"",
142 label_text_size);
143
144
145 auto legend = new TLegend(0.62, 0.65, 0.9, 0.92);
146
147 legend->SetTextFont(42);
148 legend->SetBorderSize(0);
149 legend->SetTextSize(0.035);
150
151 for (size_t i = 0; i < labels.size(); i++) {
152 legend->AddEntry(hists.at(i), labels.at(i), "f");
153 }
154
155 legend->Draw("same");
156
157 TString plot_name =
158 Form("%s/%s_%s.pdf", g_output_plot_path.Data(),
159 dataset_name.ReplaceAll(" ", "").ReplaceAll(",", "_").Data(),
160 descr.Data());
161 if (g_use_log_scale) {
162 plot_name.ReplaceAll(".pdf", "LogScale.pdf");
163 }
164 c->Print(plot_name);
165 if (print_png)
166 c->Print(plot_name.ReplaceAll(".pdf", ".png"));
167
168 plot_name.ReplaceAll(".png", ".C");
169 c->Print(plot_name);
170
171}
172
173int main(int argc, char* argv[]) {
174 if (argc != 2) {
175 std::cout << "Syntax: " << argv[0] << " <config file>" << std::endl;
176 return 1;
177 }
178 timeResSplitCases(argv[1]);
179 return 0;
180}
181
Define macros for attributes used to control the static checker.
#define ATLAS_NO_CHECK_FILE_THREAD_SAFETY
Header file for AthHistogramAlgorithm.
int main()
Definition hello.cxx:18
list descr
print "%s.properties()" % self.__name__
TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
TFile * file
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration.