ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonValidation
MuonVertexValidation
util
PlotAnnotations.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
Utils.h
"
6
#include "
PlotAnnotations.h
"
7
8
9
using namespace
MuonVertexValidationMacroUtils
;
10
11
namespace
MuonVertexValidationMacroPlotAnnotations
{
12
13
TLegend*
makeLegend
(
double
lower_x,
double
lower_y,
double
upper_x,
double
upper_y,
double
textsize){
14
// Takes NDC coordinates and the textsize as a faction of the pad dimensions to construct a TLegend object and return its pointer
15
TLegend* legend =
new
TLegend(lower_x,lower_y,upper_x,upper_y);
16
legend->SetBorderSize(0);
17
legend->SetTextFont(42);
18
legend->SetTextSize(textsize);
19
return
legend;
20
}
21
22
23
void
drawATLASlabel
(
const
char
* text,
double
x
,
double
y
,
double
textsize){
24
// Draw the ATLAS label with some optional text. The textsize is a fraction of the pad dimensions.
25
TLatex l;
26
l.SetTextFont(42);
// 42 for Helvetica and 72 for Helvetica italics
27
l.SetTextColor(1);
28
l.SetTextSize(textsize);
29
l.DrawLatexNDC(
x
,
y
, TString::Format(
"#it{#bf{ATLAS}} %s"
,text));
30
31
return
;
32
}
33
34
35
void
drawDetectorRegionLabel
(
const
char
*name,
const
char
* customlabel,
double
x
,
double
y
,
double
textsize){
36
// Returns an annotation for the detector region based on the name of the histogram:
37
// if the histogram name ends with "b" it is assumed to be in the barrel region
38
// if the histogram name ends with "e" it is assumed to be in the endcaps region
39
// if customlabel is provided, it is used instead of the default label.
40
// if non of the above applies, the function returns without drawing anything.
41
// The textsize is a fraction of the pad dimensions.
42
43
const
char
DecReg = name[std::strlen(name)-1];
44
TString DecReg_label{};
45
if
(*customlabel != 0){
46
DecReg_label = TString(customlabel);
47
}
48
else
if
(DecReg == *
"b"
){
49
DecReg_label = TString::Format(
"Barrel: |#kern[0.2]{#eta}| < %.2f"
,
fidVol_barrel_etaCut
);
50
}
51
else
if
(DecReg == *
"e"
){
52
DecReg_label = TString::Format(
"Endcaps: %.2f < |#kern[0.1]{#eta}| < %.2f"
,
fidVol_endcaps_etaCut_low
,
fidVol_endcaps_etaCut_up
);
53
}
54
else
return
;
55
56
TLatex t;
57
t.SetTextFont(42);
58
t.SetTextSize(textsize);
59
t.DrawLatexNDC(
x
,
y
, DecReg_label);
60
61
return
;
62
}
63
64
65
void
drawDetectorBoundaryLine
(
double
x
,
double
y_max,
int
line_style,
const
char
* text){
66
// Draw a vertical line at the detector boundary location x between 0 and y_max in absolute coordinates.
67
TLine* l =
new
TLine(
x
, y_max,
x
, 0);
// assures that dashed lines don't start with a gap
68
Int_t ashGrey = TColor::GetColor(
"#717581"
);
69
l->SetLineColor(ashGrey);
70
l->SetLineStyle(line_style);
71
l->Draw();
72
73
TText* t =
new
TText(
x
, y_max, text);
74
t->SetTextFont(42);
75
t->SetTextSize(0.03);
76
t->SetTextAlign(31);
// text is bottom right aligned to the position of the text
77
t->SetTextAngle(90);
78
t->Draw();
79
80
return
;
81
}
82
83
84
void
drawDetectorBoundaryLines
(
const
char
* bin_var,
double
y_max){
85
// Draw annotated vertical lines at the detector boundary locations for plots binned in Lxy or z.
86
// Valid inputs for bin_var are "Lxy" or "z".
87
// y_max defines the upper end of the line in absolute coordinates.
88
double
hcalEnd{0}, mdt1S{0}, mdt1L{0}, mdt2S{0}, mdt2L{0};
89
if
((std::string)bin_var ==
"Lxy"
) {hcalEnd = 3.9; mdt1S = 4.383; mdt1L = 4.718; mdt2S = 7.888; mdt2L = 6.861;}
90
else
if
((std::string)bin_var ==
"z"
) {hcalEnd = 6.05; mdt1S = 7.023; mdt1L = 7.409; mdt2S = 13.265; mdt2L = 13.660;}
91
else
printf(
"Invalid binning variable. Please use 'Lxy' or 'z'.\nReturning without drawing detector boundary lines.\n"
);
92
93
drawDetectorBoundaryLine
(hcalEnd, y_max, 9,
"HCal end"
);
94
drawDetectorBoundaryLine
(mdt1S, y_max, 7,
"MDT1S"
);
95
drawDetectorBoundaryLine
(mdt1L, y_max, 2,
"MDT1L"
);
96
drawDetectorBoundaryLine
(mdt2S, y_max, 7,
"MDT2S"
);
97
drawDetectorBoundaryLine
(mdt2L, y_max, 2,
"MDT2L"
);
98
99
return
;
100
}
101
102
103
double
getMaxy
(
const
TGraphAsymmErrors* graph,
double
current_max){
104
// returns the maximum of the current_max and the maximum y value+error of the passed graph.
105
double
max
= current_max;
106
double
max_graph;
107
for
(
int
i=0; i<graph->GetN(); ++i){
108
max_graph = graph->GetPointY(i) + graph->GetErrorYhigh(i);
109
max
= max_graph >
max
? max_graph :
max
;
110
}
111
112
return
max
;
113
}
114
115
}
// namespace MuonVertexValidationMacroPlotAnnotations
Utils.h
PlotAnnotations.h
y
#define y
x
#define x
max
#define max(a, b)
Definition
cfImp.cxx:41
MuonVertexValidationMacroPlotAnnotations
Definition
PlotAnnotations.cxx:11
MuonVertexValidationMacroPlotAnnotations::getMaxy
double getMaxy(const TGraphAsymmErrors *graph, double current_max)
Definition
PlotAnnotations.cxx:103
MuonVertexValidationMacroPlotAnnotations::drawATLASlabel
void drawATLASlabel(const char *text, double x, double y, double textsize)
Definition
PlotAnnotations.cxx:23
MuonVertexValidationMacroPlotAnnotations::makeLegend
TLegend * makeLegend(double lower_x, double lower_y, double upper_x, double upper_y, double textsize)
Definition
PlotAnnotations.cxx:13
MuonVertexValidationMacroPlotAnnotations::drawDetectorRegionLabel
void drawDetectorRegionLabel(const char *name, const char *customlabel, double x, double y, double textsize)
Definition
PlotAnnotations.cxx:35
MuonVertexValidationMacroPlotAnnotations::drawDetectorBoundaryLine
void drawDetectorBoundaryLine(double x, double y_max, int line_style, const char *text)
Definition
PlotAnnotations.cxx:65
MuonVertexValidationMacroPlotAnnotations::drawDetectorBoundaryLines
void drawDetectorBoundaryLines(const char *bin_var, double y_max)
Definition
PlotAnnotations.cxx:84
MuonVertexValidationMacroUtils
Definition
MuonSpectrometer/MuonValidation/MuonVertexValidation/util/Utils.cxx:9
MuonVertexValidationMacroUtils::fidVol_barrel_etaCut
constexpr double fidVol_barrel_etaCut
Definition
MuonSpectrometer/MuonValidation/MuonVertexValidation/util/Utils.h:18
MuonVertexValidationMacroUtils::fidVol_endcaps_etaCut_low
constexpr double fidVol_endcaps_etaCut_low
Definition
MuonSpectrometer/MuonValidation/MuonVertexValidation/util/Utils.h:22
MuonVertexValidationMacroUtils::fidVol_endcaps_etaCut_up
constexpr double fidVol_endcaps_etaCut_up
Definition
MuonSpectrometer/MuonValidation/MuonVertexValidation/util/Utils.h:23
Generated on
for ATLAS Offline Software by
1.17.0