test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
drawHistoAllChambers Namespace Reference

Functions

def drawHisto
 

Function Documentation

def drawHistoAllChambers.drawHisto (   histo,
  title,
  ymin,
  ymax,
  option = "HISTOP",
  draw = True 
)

Definition at line 3 of file drawHistoAllChambers.py.

Referenced by plotTTrigFromHistos.compareDiff(), plotResiduals.plot(), plotResidualsCosmics.plot(), plotTTrigFromHistos.plot(), plotVDriftFromHistos.plot(), and plotResidualsPerLayer.plotResLayer().

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