3 def drawHisto(histo,title,ymin,ymax,option="HISTOP",draw=True):
6 histo.SetMarkerStyle(20)
7 histo.SetMarkerSize(0.9)
8 histo.GetYaxis().SetRangeUser(ymin,ymax)
9 histo.GetYaxis().SetTitle(title)
10 histo.GetXaxis().SetLabelSize(0.04)
11 histo.GetXaxis().SetTickLength(0.)
12 histo.LabelsOption(
"d",
"X")
17 canvas = ROOT.TCanvas(
"c_" + histo.GetName())
19 canvas.SetFillColor(fillColor)
20 if draw: histo.Draw(option)
25 for idx_st
in range(1,5):
27 if idx_st == 4: nSectors = 14
28 for idx_wh
in range(-1,3):
29 xline = (idx_st - 1)*60 + (idx_wh + 2)*nSectors
30 if xline >= histo.GetNbinsX():
continue 32 linesWh[(idx_st,idx_wh)] = ROOT.TLine(xline,ymin,xline,ymax)
33 linesWh[(idx_st,idx_wh)].SetLineStyle(2)
34 if draw: linesWh[(idx_st,idx_wh)].Draw(
"SAME")
36 for idx
in range(1,4):
38 if xline >= histo.GetNbinsX():
continue 40 linesSt[idx] = ROOT.TLine(xline,ymin,xline,ymax)
41 linesSt[idx].SetLineStyle(2)
42 linesSt[idx].SetLineWidth(2)
43 if draw: linesSt[idx].Draw(
"SAME")
45 for idx
in range(1,5):
46 xlabel = (idx - 1)*60 + 20
47 ylabel = ymin + 0.75*(ymax -ymin)
48 if xlabel >= histo.GetNbinsX():
continue 51 labels[idx] = ROOT.TPaveLabel(xlabel,ylabel,(xlabel+20),(ylabel + 0.10*(ymax -ymin)),strSt)
52 labels[idx].SetTextSize(0.5)
53 labels[idx].SetFillColor(fillColor)
54 if draw: labels[idx].Draw(
"SAME")
57 objects.append(linesWh)
58 objects.append(linesSt)
59 objects.append(labels)
61 return (canvas,histo,objects)
62
def drawHisto(histo, title, ymin, ymax, option="HISTOP", draw=True)