19 xTitleOffset = {
"TH1" : 0.9,
24 yTitleOffset = {
"TH1" : 1.6,
29 zTitleOffset = {
"TH1" : 0.,
38 (
"1:3",
"1:32"), (
"7",
"1:32"), (
"9",
"1:32"), (
"19:20",
"1:32"), (
"30",
"1:32"), (
"32",
"1:32"),(
"36:38",
"1:32"),
40 (
"4:12",
"23:24"), (
"4:12",
"27:28"), (
"27:35",
"23:24"), (
"27:35",
"27:28"),
42 (
"4",
"3:4"), (
"4",
"7:8"), (
"4",
"11:12"), (
"4",
"15:16"), (
"4",
"19:20"), (
"4",
"31:32"),
43 (
"35",
"3:4"), (
"35",
"7:8"), (
"35",
"11:12"), (
"35",
"15:16"), (
"35",
"19:20"), (
"35",
"31:32"),
45 (
"10",
"1:2"), (
"10",
"5:6"), (
"10",
"9:10"), (
"10",
"13:14"), (
"10",
"17:18"), (
"10",
"21:22"), (
"10",
"29:30"),
46 (
"14",
"1:2"), (
"14",
"5:6"), (
"14",
"9:10"), (
"14",
"13:14"), (
"14",
"17:18"), (
"14",
"21:30"),
47 (
"17",
"1:2"), (
"17",
"13:14"), (
"17",
"17:18"), (
"17",
"21:22"), (
"17",
"25:26"), (
"17",
"29:30"),
49 (
"29",
"1:2"), (
"29",
"5:6"), (
"29",
"9:10"), (
"29",
"13:14"), (
"29",
"17:18"), (
"29",
"21:22"), (
"29",
"29:30"),
50 (
"25",
"1:2"), (
"25",
"5:6"), (
"25",
"9:10"), (
"25",
"13:14"), (
"25",
"17:18"), (
"25",
"21:30"),
51 (
"22",
"13:14"), (
"22",
"17:18"), (
"22",
"21:22"), (
"22",
"25:26"), (
"22",
"29:30"),
55 (
"1:3",
"1:32"), (
"7",
"1:32"), (
"9",
"1:32"), (
"19:20",
"1:32"), (
"30",
"1:32"), (
"32",
"1:32"),(
"36:38",
"1:32"),
57 (
"4:12",
"23:24"), (
"4:12",
"27:28"), (
"27:35",
"23:24"), (
"27:35",
"27:28"),
59 (
"4",
"3:4"), (
"4",
"7:8"), (
"4",
"11:12"), (
"4",
"15:16"), (
"4",
"19:20"), (
"4",
"31:32"),
60 (
"35",
"3:4"), (
"35",
"7:8"), (
"35",
"11:12"), (
"35",
"15:16"), (
"35",
"19:20"), (
"35",
"31:32"),
62 (
"10",
"1:2"), (
"10",
"5:6"), (
"10",
"9:10"), (
"10",
"13:14"), (
"10",
"17:18"), (
"10",
"21:22"), (
"10",
"29:30"),
63 (
"14",
"1:2"), (
"14",
"5:6"), (
"14",
"9:10"), (
"14",
"13:14"), (
"14",
"17:18"), (
"14",
"21:30"),
64 (
"17",
"1:2"), (
"17",
"13:14"), (
"17",
"17:18"), (
"17",
"21:22"), (
"17",
"25:26"), (
"17",
"29:30"),
66 (
"29",
"1:2"), (
"29",
"5:6"), (
"29",
"9:10"), (
"29",
"13:14"), (
"29",
"17:18"), (
"29",
"21:22"), (
"29",
"29:30"),
67 (
"25",
"1:2"), (
"25",
"5:6"), (
"25",
"9:10"), (
"25",
"13:14"), (
"25",
"17:18"), (
"25",
"21:30"),
68 (
"22",
"13:14"), (
"22",
"17:18"), (
"22",
"21:22"), (
"22",
"25:26"), (
"22",
"29:30"),
72 (
"1:4",
"1:32"), (
"7",
"1:32"), (
"19:20",
"1:32"), (
"32",
"1:32"),(
"35:38",
"1:32"),
74 (
"5:11",
"23:24"), (
"5:11",
"27:28"), (
"28:34",
"23:24"), (
"28:34",
"27:28"),
76 (
"9:10",
"1:2"), (
"9:10",
"5:6"), (
"9:10",
"9:10"), (
"9:10",
"13:14"), (
"9:10",
"17:18"), (
"9:10",
"21:22"), (
"9:10",
"29:30"),
77 (
"29:30",
"1:2"), (
"29:30",
"5:6"), (
"29:30",
"9:10"), (
"29:30",
"13:14"), (
"29:30",
"17:18"), (
"29:30",
"21:22"), (
"29:30",
"29:30"),
79 (
"9",
"25:26"), (
"30",
"25:26"),
81 (
"14",
"1:2"), (
"14",
"5:6"), (
"14",
"9:10"), (
"14",
"13:14"), (
"14",
"17:18"), (
"14",
"21:30"),
82 (
"17",
"1:2"), (
"17",
"13:14"), (
"17",
"17:18"), (
"17",
"21:22"), (
"17",
"25:26"), (
"17",
"29:30"),
84 (
"25",
"1:2"), (
"25",
"5:6"), (
"25",
"9:10"), (
"25",
"13:14"), (
"25",
"17:18"), (
"25",
"21:30"),
85 (
"22",
"13:14"), (
"22",
"17:18"), (
"22",
"21:22"), (
"22",
"25:26"), (
"22",
"29:30"),
89 (
"1:4",
"1:32"), (
"7",
"1:32"), (
"19:20",
"1:32"), (
"32",
"1:32"),(
"35:38",
"1:32"),
91 (
"5:11",
"23:24"), (
"5:11",
"27:28"), (
"28:34",
"23:24"), (
"28:34",
"27:28"),
93 (
"9:10",
"1:2"), (
"9:10",
"5:6"), (
"9:10",
"9:10"), (
"9:10",
"13:14"), (
"9:10",
"17:18"), (
"9:10",
"21:22"), (
"9:10",
"29:30"),
94 (
"29:30",
"1:2"), (
"29:30",
"5:6"), (
"29:30",
"9:10"), (
"29:30",
"13:14"), (
"29:30",
"17:18"), (
"29:30",
"21:22"), (
"29:30",
"29:30"),
96 (
"9",
"25:26"), (
"30",
"25:26"),
98 (
"14",
"1:2"), (
"14",
"5:6"), (
"14",
"9:10"), (
"14",
"13:14"), (
"14",
"17:18"), (
"14",
"21:30"),
99 (
"17",
"1:2"), (
"17",
"13:14"), (
"17",
"17:18"), (
"17",
"21:22"), (
"17",
"25:26"), (
"17",
"29:30"),
101 (
"25",
"1:2"), (
"25",
"5:6"), (
"25",
"9:10"), (
"25",
"13:14"), (
"25",
"17:18"), (
"25",
"21:30"),
102 (
"22",
"13:14"), (
"22",
"17:18"), (
"22",
"21:22"), (
"22",
"25:26"), (
"22",
"29:30"),
106 (
"1:4",
"1:22"), (
"19:20",
"1:22"), (
"35:38",
"1:22"),
107 (
"1:4",
"29:32"), (
"19:20",
"29:32"), (
"35:38",
"29:32"),
109 (
"9",
"1:32"), (
"14",
"1:32"), (
"25",
"1:32"), (
"30",
"1:32"),
111 (
"1",
"23:28"), (
"3",
"23:28"), (
"19",
"23:28"), (
"36",
"23:28"), (
"38",
"23:28"),
113 (
"5",
"23:24"), (
"10",
"23:24"), (
"15",
"23:24"), (
"24",
"23:24"), (
"29",
"23:24"), (
"34",
"23:24"),
114 (
"5",
"27:28"), (
"10",
"27:28"), (
"15",
"27:28"), (
"24",
"27:28"), (
"29",
"27:28"), (
"34",
"27:28"),
116 (
"4",
"25:26"), (
"20",
"25:26"), (
"35",
"25:26"),
120 (
"1:4",
"1:22"), (
"19:20",
"1:22"), (
"35:38",
"1:22"),
121 (
"1:4",
"29:32"), (
"19:20",
"29:32"), (
"35:38",
"29:32"),
123 (
"9",
"1:32"), (
"14",
"1:32"), (
"25",
"1:32"), (
"30",
"1:32"),
125 (
"1",
"23:28"), (
"3",
"23:28"), (
"19",
"23:28"), (
"36",
"23:28"), (
"38",
"23:28"),
127 (
"5",
"23:24"), (
"10",
"23:24"), (
"15",
"23:24"), (
"24",
"23:24"), (
"29",
"23:24"), (
"34",
"23:24"),
128 (
"5",
"27:28"), (
"10",
"27:28"), (
"15",
"27:28"), (
"24",
"27:28"), (
"29",
"27:28"), (
"34",
"27:28"),
130 (
"4",
"25:26"), (
"20",
"25:26"), (
"35",
"25:26"),
140 (
"1",
"23:28"), (
"3",
"23:28"), (
"5",
"23:28"), (
"34",
"23:28"), (
"36",
"23:28"), (
"38",
"23:28"),
142 (
"9:11",
"23:28"), (
"28:30",
"23:28"),
152 (
"1",
"23:28"), (
"3",
"23:28"), (
"5",
"23:28"), (
"34",
"23:28"), (
"36",
"23:28"), (
"38",
"23:28"),
154 (
"9:11",
"23:28"), (
"28:30",
"23:28"),
161 if isinstance(hist, ROOT.TH1D)
or isinstance(hist, ROOT.TH1I)
or isinstance(hist, ROOT.TProfile)
or isinstance(hist, ROOT.TH1F):
163 elif isinstance(hist, ROOT.TH2D)
or isinstance(hist, ROOT.TH2I)
or isinstance(hist, ROOT.TH2F)
or isinstance(hist, ROOT.TProfile2D):
165 elif isinstance(hist, ROOT.TGraph)
or isinstance(hist, ROOT.TGraphErrors):
167 elif isinstance(hist, ROOT.TEfficiency):
168 instance =
"TEfficiency"
177 if instance ==
"TEfficiency":
178 hist.GetPaintedGraph().GetXaxis().SetTitleOffset(xTitleOffset[instance])
179 hist.GetPaintedGraph().GetYaxis().SetTitleOffset(yTitleOffset[instance])
181 hist.GetXaxis().SetTitleOffset(xTitleOffset[instance])
182 hist.GetYaxis().SetTitleOffset(yTitleOffset[instance])
183 if instance ==
"TH2":
184 hist.GetZaxis().SetTitleOffset(zTitleOffset[instance])
191 dashlines_x = [-18., -16., -14., -12., -10., -9., -7., -5., -4., -2., 2., 4., 5., 7., 9., 10., 12., 14., 16., 18.]
192 solidlines_x = [-17., -15., -13., -11., -8., -6., -3., -1., 1., 3., 6., 8., 11., 13., 15., 17.]
194 for i_x
in dashlines_x:
195 dash_line = ROOT.TLine(i_x, y_min, i_x, y_max)
196 dash_line.SetLineStyle(2)
197 dash_line.SetLineWidth(1)
198 dash_line.SetLineColor(ROOT.kBlack)
200 hist2d.GetListOfFunctions().Add(dash_line)
202 for i_x
in solidlines_x:
203 solid_line = ROOT.TLine(i_x, y_min, i_x, y_max)
204 solid_line.SetLineStyle(1)
205 solid_line.SetLineWidth(1)
206 solid_line.SetLineColor(ROOT.kBlack)
208 hist2d.GetListOfFunctions().Add(solid_line)
214 for i_sec
in range(1, 16+1):
215 solid_line = ROOT.TLine(xmin, i_sec*2, xmax, i_sec*2)
216 solid_line.SetLineStyle(1)
217 solid_line.SetLineWidth(1)
218 solid_line.SetLineColor(ROOT.kBlack)
219 hist2d.GetListOfFunctions().Add(solid_line)
221 dash_line = ROOT.TLine(xmin, i_sec*2-1, xmax, i_sec*2-1)
222 dash_line .SetLineStyle(2)
223 dash_line .SetLineWidth(1)
224 dash_line .SetLineColor(ROOT.kBlack)
225 hist2d.GetListOfFunctions().Add(dash_line)
229 if not (layer
in list_boxes_layers):
230 print(
"HistDecorate::set_blankBox::ERROR - unknown layer index %d"%layer)
233 list_boxes = list_boxes_layers[layer]
234 for box_str
in list_boxes:
235 box_pos =
findBoxPos(hist_2d, box_str[0], box_str[1])
237 tbox =ROOT.TBox(box_pos[0], box_pos[1], box_pos[2], box_pos[3])
238 tbox.SetFillColor(ROOT.kGray)
240 hist_2d.GetListOfFunctions().Add(tbox)
244 bins_X = [
int(i)
for i
in binx_str.split(
":")]
245 bins_Y = [
int(i)
for i
in biny_str.split(
":")]
250 return (Xpos[0], Ypos[0], Xpos[1], Ypos[1])
264 pos_1 = h2.GetXaxis().GetBinLowEdge(low_bin)
265 pos_2 = h2.GetXaxis().GetBinUpEdge(up_bin)
267 pos_1 = h2.GetYaxis().GetBinLowEdge(low_bin)
268 pos_2 = h2.GetYaxis().GetBinUpEdge(up_bin)
270 print(
"HistDecorate::findAxisPos::ERROR - the axis index can only be 1 or 2")
272 return (pos_1, pos_2)
276 x_axis = hist2d.GetXaxis()
277 y_axis = hist2d.GetYaxis()
318 for i_bin, i_label
in XBins_Labeled.items():
319 x_axis.SetBinLabel(i_bin, i_label)
321 for i_bin, i_label
in YBins_Labeled.items():
322 y_axis.SetBinLabel(i_bin*2-1, i_label)
324 hist2d.GetXaxis().SetTitleOffset(0.9)
325 hist2d.GetYaxis().SetTitleOffset(1.0)
326 hist2d.GetZaxis().SetTitleOffset(1.2)
329 if __name__ ==
'__main__':
330 print (
"HistDecorate: Hello, World !")