Skip to content

Commit 2a6b6a3

Browse files
committed
ITS: TrackExtensionStudy Efficiencies
Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch>
1 parent 4453e6b commit 2a6b6a3

File tree

4 files changed

+520
-17
lines changed

4 files changed

+520
-17
lines changed

Detectors/ITSMFT/ITS/postprocessing/studies/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,6 @@ o2_target_root_dictionary(ITSPostprocessing
3030
HEADERS include/ITSStudies/ITSStudiesConfigParam.h
3131
include/ITSStudies/TrackCuts.h
3232
include/ITSStudies/TrackMethods.h
33-
LINKDEF src/ITSStudiesLinkDef.h)
33+
LINKDEF src/ITSStudiesLinkDef.h)
34+
35+
add_subdirectory(macros)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
# All rights not expressly granted are reserved.
4+
#
5+
# This software is distributed under the terms of the GNU General Public
6+
# License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
#
8+
# In applying this license CERN does not waive the privileges and immunities
9+
# granted to it by virtue of its status as an Intergovernmental Organization
10+
# or submit itself to any jurisdiction.
11+
12+
o2_add_test_root_macro(
13+
PostTrackExtension.C
14+
PUBLIC_LINK_LIBRARIES ROOT::Hist ROOT::RIO ROOT::Core ROOT::Gpad
15+
LABELS its-study
16+
COMPILE_ONLY)
Lines changed: 348 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,348 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
#if !defined(__CLING__) || defined(__ROOTCLING__)
13+
#include "TStyle.h"
14+
#include "TFile.h"
15+
#include "TError.h"
16+
#include "TColor.h"
17+
#include "TCanvas.h"
18+
#include "TH1F.h"
19+
#include "TEfficiency.h"
20+
#include "TLegend.h"
21+
#include "TTree.h"
22+
23+
#include <memory>
24+
#include <array>
25+
#include <format>
26+
#endif
27+
28+
static constexpr std::array<uint8_t, 9> bitPatternsBefore{15, 30, 31, 60, 62, 63, 120, 124, 126};
29+
static constexpr std::array<uint8_t, 16> bitPatternsAfter{31, 47, 61, 62, 63, 79, 94, 95, 111, 121, 122, 123, 124, 125, 126, 127};
30+
static constexpr std::array<int, 16> patternColors = {
31+
kRed, // Red
32+
kBlue, // Blue
33+
kGreen, // Green
34+
kMagenta, // Magenta
35+
kCyan, // Cyan
36+
kOrange, // Orange
37+
kViolet, // Violet
38+
kYellow, // Yellow
39+
kPink, // Pink
40+
kAzure, // Azure
41+
kSpring, // Spring Green
42+
kTeal, // Teal
43+
kBlack, // Black
44+
kGray, // Gray
45+
kOrange + 7, // Light Orange
46+
kBlue - 9 // Light Blue
47+
};
48+
49+
// Marker styles
50+
static constexpr std::array<int, 16> patternMarkers = {
51+
20, // Full circle
52+
21, // Full square
53+
22, // Full triangle up
54+
23, // Full triangle down
55+
24, // Open circle
56+
25, // Open square
57+
26, // Open triangle up
58+
27, // Open cross
59+
28, // Star
60+
29, // Plus sign
61+
30, // Open diamond
62+
31, // Full diamond
63+
32, // Cross
64+
33, // Circle with cross
65+
34, // X sign
66+
35 // Double open cross
67+
};
68+
69+
enum Labels : unsigned int {
70+
eAll = 0,
71+
eGood,
72+
eFake,
73+
eFakeBefore,
74+
eFakeAfter,
75+
eFakeMix,
76+
eTopGood,
77+
eBotGood,
78+
eMixGood,
79+
eTopFake,
80+
eBotFake,
81+
eMixFake,
82+
eN,
83+
};
84+
static const std::array<const char* const, eN> names{
85+
"ALL #frac{ext trks}{all trks}",
86+
"GOOD #frac{good ext trks}{all ext trks}",
87+
"FAKE #frac{fake trks}{all ext trks}",
88+
"FAKE BF #frac{fake bf trks}{fake ext trks}",
89+
"FAKE AF #frac{fake af trks}{fake ext trks}",
90+
"FAKE MIX #frac{fake mix trks}{fake ext trks}",
91+
// Good Top/Bot/Mix
92+
"TOP #frac{good top ext trks}{good ext trks}",
93+
"BOT #frac{good bot ext trks}{good ext trks}",
94+
"MIX #frac{good mix ext trks}{good ext trks}",
95+
// Fake Top/Bot/Mix
96+
"TOP #frac{fake top ext trks}{fake ext trks}",
97+
"BOT #frac{fake bot ext trks}{fake ext trks}",
98+
"MIX #frac{fake mix ext trks}{fake ext trks}",
99+
};
100+
static const std::array<EColor, eN> colors{kBlack, kGreen, kRed, kCyan, kYellow, kAzure,
101+
// Good Top/Bot/Mix
102+
kBlue, kOrange, kPink,
103+
// Fake Top/Bot/Mix
104+
kBlue, kOrange, kPink};
105+
static const std::array<int, eN> markers{20, 21, 22, 23, 27, 28,
106+
// Good Top/Bot/Mix
107+
29, 33, 39,
108+
// Fake Top/Bot/Mix
109+
29, 33, 39};
110+
static const char* const texPtX = "#it{p}_{T} (GeV/#it{c})";
111+
static const char* const texEff = "Efficiency";
112+
113+
void setStyle();
114+
TEfficiency* makeEff(TFile*, const char* num, const char* den);
115+
116+
template <class T>
117+
void style(T* t, Labels lab, TLegend* leg = nullptr)
118+
{
119+
t->SetMarkerStyle(markers[lab]);
120+
t->SetMarkerColor(colors[lab]);
121+
t->SetLineColor(colors[lab]);
122+
if (leg) {
123+
leg->AddEntry(t, names[lab]);
124+
}
125+
}
126+
127+
template <class T>
128+
void stylePattern(T* t, int i, TLegend* leg = nullptr, const char* name = nullptr)
129+
{
130+
t->SetMarkerStyle(patternMarkers[i]);
131+
t->SetMarkerColor(patternColors[i]);
132+
t->SetLineColor(patternColors[i]);
133+
if (leg) {
134+
leg->AddEntry(t, name);
135+
}
136+
}
137+
138+
void PostTrackExtension(const char* fileName = "TrackExtensionStudy.root")
139+
{
140+
setStyle();
141+
142+
std::unique_ptr<TFile> fIn{TFile::Open(fileName, "READ")};
143+
if (!fIn || fIn->IsZombie()) {
144+
Error("", "Cannot open file %s", fileName);
145+
return;
146+
}
147+
148+
{ // Purity & Fake-Rate
149+
auto c = new TCanvas("cPFR", "", 800, 600);
150+
auto h = c->DrawFrame(0.05, 0.0, 10., 1.05);
151+
h->GetXaxis()->SetTitle(texPtX);
152+
h->GetYaxis()->SetTitle(texEff);
153+
auto leg = new TLegend(0.35, 0.35, 0.7, 0.7);
154+
auto eff = fIn->Get<TEfficiency>("eExtension");
155+
style(eff, eAll, leg);
156+
eff->Draw("same");
157+
auto effPurity = fIn->Get<TEfficiency>("eExtensionPurity");
158+
style(effPurity, eGood, leg);
159+
effPurity->Draw("same");
160+
auto effFake = fIn->Get<TEfficiency>("eExtensionFake");
161+
style(effFake, eFake, leg);
162+
effFake->Draw("same");
163+
leg->Draw();
164+
gPad->SetLogx();
165+
gPad->SetGrid();
166+
c->SaveAs("trkExt_purity_fake.pdf");
167+
}
168+
169+
{ // FAKE-Rate composition
170+
auto c = new TCanvas("cFR", "", 800, 600);
171+
auto h = c->DrawFrame(0.05, 0.0, 10., 1.05);
172+
h->GetXaxis()->SetTitle(texPtX);
173+
h->GetYaxis()->SetTitle(texEff);
174+
auto leg = new TLegend(0.35, 0.35, 0.7, 0.7);
175+
auto effFake = fIn->Get<TEfficiency>("eExtensionFake");
176+
style(effFake, eFake, leg);
177+
effFake->Draw("same");
178+
auto effFakeBf = fIn->Get<TEfficiency>("eExtensionFakeBefore");
179+
style(effFakeBf, eFakeBefore, leg);
180+
effFakeBf->Draw("same");
181+
auto effFakeAf = fIn->Get<TEfficiency>("eExtensionFakeAfter");
182+
style(effFakeAf, eFakeAfter, leg);
183+
effFakeAf->Draw("same");
184+
auto effFakeMi = fIn->Get<TEfficiency>("eExtensionFakeMix");
185+
style(effFakeMi, eFakeMix, leg);
186+
effFakeMi->Draw("same");
187+
leg->Draw();
188+
gPad->SetLogx();
189+
gPad->SetGrid();
190+
c->SaveAs("trkExt_fake.pdf");
191+
}
192+
193+
{ // GOOD Top/Bot/Mix Purity composition
194+
auto c = new TCanvas("cGC", "", 800, 600);
195+
auto h = c->DrawFrame(0.05, 0.0, 10., 1.05);
196+
h->GetXaxis()->SetTitle(texPtX);
197+
h->GetYaxis()->SetTitle(texEff);
198+
auto leg = new TLegend(0.35, 0.35, 0.7, 0.7);
199+
auto effTop = makeEff(fIn.get(), "eExtensionTopPurity", "eExtensionPurity");
200+
style(effTop, eTopGood, leg);
201+
effTop->Draw("same");
202+
auto effBot = makeEff(fIn.get(), "eExtensionBotPurity", "eExtensionPurity");
203+
style(effBot, eBotGood, leg);
204+
effBot->Draw("same");
205+
auto effMix = makeEff(fIn.get(), "eExtensionMixPurity", "eExtensionPurity");
206+
style(effMix, eMixGood, leg);
207+
effMix->Draw("same");
208+
leg->Draw();
209+
gPad->SetLogx();
210+
gPad->SetGrid();
211+
c->SaveAs("trkExt_good_comp.pdf");
212+
}
213+
214+
{ // FAKE Top/Bot/Mix composition
215+
auto c = new TCanvas("cFC", "", 800, 600);
216+
auto h = c->DrawFrame(0.05, 0.0, 10., 1.05);
217+
h->GetXaxis()->SetTitle(texPtX);
218+
h->GetYaxis()->SetTitle(texEff);
219+
auto leg = new TLegend(0.35, 0.35, 0.7, 0.7);
220+
auto effTop = fIn->Get<TEfficiency>("eExtensionTopFake");
221+
style(effTop, eTopFake, leg);
222+
effTop->Draw("same");
223+
auto effBot = fIn->Get<TEfficiency>("eExtensionBotFake");
224+
style(effBot, eBotFake, leg);
225+
effBot->Draw("same");
226+
auto effMix = fIn->Get<TEfficiency>("eExtensionMixFake");
227+
style(effMix, eMixFake, leg);
228+
effMix->Draw("same");
229+
leg->Draw();
230+
gPad->SetLogx();
231+
gPad->SetGrid();
232+
c->SaveAs("trkExt_fake_comp.pdf");
233+
}
234+
235+
{ // Good Patterns
236+
auto c = new TCanvas("cPatGood", "", 3 * 800, 3 * 600);
237+
c->Divide(3, 3);
238+
for (int i{0}; i < (int)bitPatternsBefore.size(); ++i) {
239+
auto p = c->cd(i + 1);
240+
auto h = p->DrawFrame(0.05, 0.0, 10., 1.05);
241+
h->GetXaxis()->SetTitle(texPtX);
242+
h->GetYaxis()->SetTitle(texEff);
243+
auto leg = new TLegend(0.35, 0.35, 0.7, 0.7);
244+
leg->SetNColumns(4);
245+
leg->SetHeader(std::format("BEFORE={:07b} GOOD Pattern AFTER/BEFORE", bitPatternsBefore[i]).c_str());
246+
for (int j{0}; j < (int)bitPatternsAfter.size(); ++j) {
247+
auto eff = fIn->Get<TEfficiency>(std::format("eExtensionPatternGood_{:07b}_{:07b}", bitPatternsBefore[i], bitPatternsAfter[j]).c_str());
248+
stylePattern(eff, j, leg, std::format("{:07b}", bitPatternsAfter[j]).c_str());
249+
eff->Draw("same");
250+
}
251+
leg->Draw();
252+
p->SetLogx();
253+
p->SetGrid();
254+
}
255+
c->SaveAs("trkExt_good_pattern_comp.pdf");
256+
}
257+
258+
{ // Fake Patterns
259+
auto c = new TCanvas("cPatFake", "", 3 * 800, 3 * 600);
260+
c->Divide(3, 3);
261+
for (int i{0}; i < (int)bitPatternsBefore.size(); ++i) {
262+
auto p = c->cd(i + 1);
263+
auto h = p->DrawFrame(0.05, 0.0, 10., 1.05);
264+
h->GetXaxis()->SetTitle(texPtX);
265+
h->GetYaxis()->SetTitle(texEff);
266+
auto leg = new TLegend(0.35, 0.35, 0.7, 0.7);
267+
leg->SetNColumns(4);
268+
leg->SetHeader(std::format("BEFORE={:07b} FAKE Pattern AFTER/BEFORE", bitPatternsBefore[i]).c_str());
269+
for (int j{0}; j < (int)bitPatternsAfter.size(); ++j) {
270+
auto eff = fIn->Get<TEfficiency>(std::format("eExtensionPatternFake_{:07b}_{:07b}", bitPatternsBefore[i], bitPatternsAfter[j]).c_str());
271+
stylePattern(eff, j, leg, std::format("{:07b}", bitPatternsAfter[j]).c_str());
272+
eff->Draw("same");
273+
}
274+
leg->Draw();
275+
p->SetLogx();
276+
p->SetGrid();
277+
}
278+
c->SaveAs("trkExt_fake_pattern_comp.pdf");
279+
}
280+
281+
{ // Kinematic variables
282+
auto t = fIn->Get<TTree>("tree");
283+
auto c = new TCanvas("cKG", "", 800, 600);
284+
c->Divide(3, 2);
285+
auto p = c->cd(1);
286+
p->SetGrid();
287+
auto h = p->DrawFrame(-.5, 0., .5, 30.);
288+
h->GetXaxis()->SetTitle("#it{p}_{T,TRK}-#it{p}_{T,MC}");
289+
h->GetYaxis()->SetTitle("n. counts");
290+
t->Draw("trk.getPt()-mcTrk.getPt()>>hPtNo(100,-.5,.5)", "isGood&&!isExtended", "HIST;SAME");
291+
auto htemp = (TH1F*)p->GetPrimitive("hPtNo");
292+
htemp->Scale(1.0 / htemp->Integral("width"));
293+
htemp->SetLineColor(kRed);
294+
t->Draw("trk.getPt()-mcTrk.getPt()>>hPtYes(100,-.5,.5)", "isGood&&isExtended", "HIST;SAME");
295+
htemp = (TH1F*)p->GetPrimitive("hPtYes");
296+
htemp->Scale(1.0 / htemp->Integral("width"));
297+
htemp->SetLineColor(kBlue);
298+
p->Modified();
299+
p->Update();
300+
c->SaveAs("trkExt_kinematics.pdf");
301+
}
302+
}
303+
304+
void setStyle()
305+
{
306+
gStyle->Reset("Plain");
307+
gStyle->SetOptTitle(0);
308+
gStyle->SetOptStat(0);
309+
gStyle->SetPalette(kRainbow);
310+
gStyle->SetCanvasColor(10);
311+
gStyle->SetCanvasBorderMode(0);
312+
gStyle->SetFrameLineWidth(1);
313+
gStyle->SetFrameFillColor(kWhite);
314+
gStyle->SetPadColor(10);
315+
gStyle->SetPadTickX(1);
316+
gStyle->SetPadTickY(1);
317+
gStyle->SetPadBottomMargin(0.15);
318+
gStyle->SetPadLeftMargin(0.15);
319+
gStyle->SetHistLineWidth(1);
320+
gStyle->SetHistLineColor(kRed);
321+
gStyle->SetFuncWidth(2);
322+
gStyle->SetFuncColor(kGreen);
323+
gStyle->SetLineWidth(2);
324+
gStyle->SetLabelSize(0.045, "xyz");
325+
gStyle->SetLabelOffset(0.01, "y");
326+
gStyle->SetLabelOffset(0.01, "x");
327+
gStyle->SetLabelColor(kBlack, "xyz");
328+
gStyle->SetTitleSize(0.05, "xyz");
329+
gStyle->SetTitleOffset(1.25, "y");
330+
gStyle->SetTitleOffset(1.2, "x");
331+
gStyle->SetTitleFillColor(kWhite);
332+
gStyle->SetTextSizePixels(26);
333+
gStyle->SetTextFont(42);
334+
gStyle->SetTickLength(0.04, "X");
335+
gStyle->SetTickLength(0.04, "Y");
336+
gStyle->SetLegendBorderSize(0);
337+
gStyle->SetLegendFillColor(kWhite);
338+
gStyle->SetFillColor(kWhite);
339+
gStyle->SetLegendFont(42);
340+
}
341+
342+
TEfficiency* makeEff(TFile* fIn, const char* num, const char* den)
343+
{
344+
auto h1 = fIn->Get<TEfficiency>(num)->GetPassedHistogram();
345+
auto h2 = fIn->Get<TEfficiency>(den)->GetPassedHistogram();
346+
auto e = new TEfficiency(*h1, *h2);
347+
return e;
348+
}

0 commit comments

Comments
 (0)