ATLAS Offline Software
Functions | Variables
HistDecorate Namespace Reference

Functions

def classifyInstance (hist)
 
def setTitleOffset (hist, instance="")
 
def set_verticalGrid (hist2d)
 
def set_horizonGrid (hist2d)
 
def set_blankBox (hist_2d, layer)
 
def findBoxPos (h2, binx_str, biny_str)
 
def findAxisPos (h2, bins, axis=1)
 
def setAxisLabel_EtaPhi (hist2d)
 

Variables

dictionary Dic_etaStation_dbZ
 
dictionary xTitleOffset
 
dictionary yTitleOffset
 
dictionary zTitleOffset
 
dictionary list_boxes_layers
 

Function Documentation

◆ classifyInstance()

def HistDecorate.classifyInstance (   hist)

Definition at line 160 of file HistDecorate.py.

160 def classifyInstance(hist):
161  if isinstance(hist, ROOT.TH1D) or isinstance(hist, ROOT.TH1I) or isinstance(hist, ROOT.TProfile) or isinstance(hist, ROOT.TH1F):
162  instance = "TH1"
163  elif isinstance(hist, ROOT.TH2D) or isinstance(hist, ROOT.TH2I) or isinstance(hist, ROOT.TH2F) or isinstance(hist, ROOT.TProfile2D):
164  instance = "TH2"
165  elif isinstance(hist, ROOT.TGraph) or isinstance(hist, ROOT.TGraphErrors):
166  instance = "TGraph"
167  elif isinstance(hist, ROOT.TEfficiency):
168  instance = "TEfficiency"
169 
170  return instance
171 
172 # -----------------------------------------------------------------------

◆ findAxisPos()

def HistDecorate.findAxisPos (   h2,
  bins,
  axis = 1 
)

Definition at line 253 of file HistDecorate.py.

253 def findAxisPos(h2, bins, axis = 1):
254  low_bin = 0
255  up_bin = 0
256  if len(bins) == 2:
257  low_bin = bins[0]
258  up_bin = bins[1]
259  else:
260  low_bin = bins[0]
261  up_bin = bins[0]
262 
263  if axis == 1:
264  pos_1 = h2.GetXaxis().GetBinLowEdge(low_bin)
265  pos_2 = h2.GetXaxis().GetBinUpEdge(up_bin)
266  elif axis == 2:
267  pos_1 = h2.GetYaxis().GetBinLowEdge(low_bin)
268  pos_2 = h2.GetYaxis().GetBinUpEdge(up_bin)
269  else:
270  print("HistDecorate::findAxisPos::ERROR - the axis index can only be 1 or 2")
271 
272  return (pos_1, pos_2)
273 

◆ findBoxPos()

def HistDecorate.findBoxPos (   h2,
  binx_str,
  biny_str 
)

Definition at line 243 of file HistDecorate.py.

243 def findBoxPos(h2, binx_str, biny_str):
244  bins_X = [int(i) for i in binx_str.split(":")]
245  bins_Y = [int(i) for i in biny_str.split(":")]
246 
247  Xpos = findAxisPos(h2, bins_X, axis = 1)
248  Ypos = findAxisPos(h2, bins_Y, axis = 2)
249 
250  return (Xpos[0], Ypos[0], Xpos[1], Ypos[1])
251 
252 # -----------------------------------------------------------------------

◆ set_blankBox()

def HistDecorate.set_blankBox (   hist_2d,
  layer 
)

Definition at line 228 of file HistDecorate.py.

228 def set_blankBox(hist_2d, layer):
229  if not (layer in list_boxes_layers):
230  print("HistDecorate::set_blankBox::ERROR - unknown layer index %d"%layer)
231  return
232 
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])
236 
237  tbox =ROOT.TBox(box_pos[0], box_pos[1], box_pos[2], box_pos[3])
238  tbox.SetFillColor(ROOT.kGray)
239 
240  hist_2d.GetListOfFunctions().Add(tbox)
241 
242 # -----------------------------------------------------------------------

◆ set_horizonGrid()

def HistDecorate.set_horizonGrid (   hist2d)

Definition at line 211 of file HistDecorate.py.

211 def set_horizonGrid(hist2d):
212  xmin = -19.
213  xmax = 19.
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)
220 
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)
226 
227 # -----------------------------------------------------------------------

◆ set_verticalGrid()

def HistDecorate.set_verticalGrid (   hist2d)

Definition at line 188 of file HistDecorate.py.

188 def set_verticalGrid(hist2d):
189  y_min = 0.
190  y_max = 32.
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.]
193 
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)
199 
200  hist2d.GetListOfFunctions().Add(dash_line)
201 
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)
207 
208  hist2d.GetListOfFunctions().Add(solid_line)
209 
210 # -----------------------------------------------------------------------

◆ setAxisLabel_EtaPhi()

def HistDecorate.setAxisLabel_EtaPhi (   hist2d)

Definition at line 275 of file HistDecorate.py.

275 def setAxisLabel_EtaPhi(hist2d):
276  x_axis = hist2d.GetXaxis()
277  y_axis = hist2d.GetYaxis()
278 
279  XBins_Labeled = { # bin : eta station
280  1 : '-8',
281  3 : '-7',
282  5 : '-6',
283  7 : '-5',
284  10: '-4',
285  12: '-3',
286  15: '-2',
287  17: '-1',
288  19: '0',
289  21: '1',
290  24: '2',
291  26: '3',
292  29: '4',
293  32: '5',
294  34: '6',
295  36: '7',
296  38: '8'
297  }
298 
299  YBins_Labeled = { # bin : Sector name
300  1:"L1",
301  2:"S2",
302  3:"L3",
303  4:"S4",
304  5:"L5",
305  6:"S6",
306  7:"L7",
307  8:"S8",
308  9:"L9",
309  10:"S10",
310  11:"L11",
311  12:"FG12",
312  13:"L13",
313  14:"FG14",
314  15:"L15",
315  16:"S16"
316  }
317 
318  for i_bin, i_label in XBins_Labeled.items():
319  x_axis.SetBinLabel(i_bin, i_label)
320 
321  for i_bin, i_label in YBins_Labeled.items():
322  y_axis.SetBinLabel(i_bin*2-1, i_label)
323 
324  hist2d.GetXaxis().SetTitleOffset(0.9)
325  hist2d.GetYaxis().SetTitleOffset(1.0)
326  hist2d.GetZaxis().SetTitleOffset(1.2)
327 

◆ setTitleOffset()

def HistDecorate.setTitleOffset (   hist,
  instance = "" 
)

Definition at line 173 of file HistDecorate.py.

173 def setTitleOffset(hist, instance=""):
174  if instance == "":
175  instance = classifyInstance(hist)
176 
177  if instance == "TEfficiency":
178  hist.GetPaintedGraph().GetXaxis().SetTitleOffset(xTitleOffset[instance])
179  hist.GetPaintedGraph().GetYaxis().SetTitleOffset(yTitleOffset[instance])
180  else:
181  hist.GetXaxis().SetTitleOffset(xTitleOffset[instance])
182  hist.GetYaxis().SetTitleOffset(yTitleOffset[instance])
183  if instance == "TH2":
184  hist.GetZaxis().SetTitleOffset(zTitleOffset[instance])
185 
186 
187 # -----------------------------------------------------------------------

Variable Documentation

◆ Dic_etaStation_dbZ

dictionary HistDecorate.Dic_etaStation_dbZ
Initial value:
1 = {
2  1:[1,2],
3  2:[1,2,3],
4  3:[1,2],
5  4:[1,2,3],
6  5:[1,2],
7  6:[1,2],
8  7:[1,2],
9  8:[1,2]
10 }

Definition at line 7 of file HistDecorate.py.

◆ list_boxes_layers

dictionary HistDecorate.list_boxes_layers

Definition at line 36 of file HistDecorate.py.

◆ xTitleOffset

dictionary HistDecorate.xTitleOffset
Initial value:
1 = {"TH1" : 0.9,
2  "TH2" : 0.9,
3  "TGraph" : 1.0,
4  "TEfficiency" : 1.0
5 }

Definition at line 19 of file HistDecorate.py.

◆ yTitleOffset

dictionary HistDecorate.yTitleOffset
Initial value:
1 = {"TH1" : 1.6,
2  "TH2" : 1.0,
3  "TGraph" : 1.6,
4  "TEfficiency" : 1.6
5 }

Definition at line 24 of file HistDecorate.py.

◆ zTitleOffset

dictionary HistDecorate.zTitleOffset
Initial value:
1 = {"TH1" : 0.,
2  "TH2" : 1.2,
3  "TGraph" : 0.,
4  "TEfficiency" : 0.
5 }

Definition at line 29 of file HistDecorate.py.

HistDecorate.set_verticalGrid
def set_verticalGrid(hist2d)
Definition: HistDecorate.py:188
HistDecorate.classifyInstance
def classifyInstance(hist)
Definition: HistDecorate.py:160
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
HistDecorate.findBoxPos
def findBoxPos(h2, binx_str, biny_str)
Definition: HistDecorate.py:243
HistDecorate.set_horizonGrid
def set_horizonGrid(hist2d)
Definition: HistDecorate.py:211
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
HistDecorate.set_blankBox
def set_blankBox(hist_2d, layer)
Definition: HistDecorate.py:228
HistDecorate.findAxisPos
def findAxisPos(h2, bins, axis=1)
Definition: HistDecorate.py:253
HistDecorate.setTitleOffset
def setTitleOffset(hist, instance="")
Definition: HistDecorate.py:173
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70
HistDecorate.setAxisLabel_EtaPhi
def setAxisLabel_EtaPhi(hist2d)
Definition: HistDecorate.py:275