CMS 3D CMS Logo

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.

00004                                                               :
00005     histo.SetStats(0)
00006     histo.SetLineWidth(3)
00007     histo.SetMarkerStyle(20)
00008     histo.SetMarkerSize(0.9)
00009     histo.GetYaxis().SetRangeUser(ymin,ymax)
00010     histo.GetYaxis().SetTitle(title)
00011     histo.GetXaxis().SetLabelSize(0.04)
00012     histo.GetXaxis().SetTickLength(0.)
00013     histo.LabelsOption("d","X")
00014  
00015     fillColor = 0
00016     canvas = None 
00017     if draw:
00018         canvas = ROOT.TCanvas("c_" + histo.GetName())
00019         canvas.SetGridy()
00020         canvas.SetFillColor(fillColor)
00021     if draw: histo.Draw(option)
00022 
00023     linesWh = {}
00024     linesSt = {}
00025     labels = {}
00026     for idx_st in range(1,5):
00027         nSectors = 12
00028         if idx_st == 4: nSectors = 14
00029         for idx_wh in range(-1,3):
00030             xline = (idx_st - 1)*60 + (idx_wh + 2)*nSectors
00031             if xline >= histo.GetNbinsX(): continue 
00032 
00033             linesWh[(idx_st,idx_wh)] = ROOT.TLine(xline,ymin,xline,ymax)
00034             linesWh[(idx_st,idx_wh)].SetLineStyle(2)
00035             if draw: linesWh[(idx_st,idx_wh)].Draw("SAME")
00036 
00037     for idx in range(1,4):
00038         xline = idx*60
00039         if xline >= histo.GetNbinsX(): continue
00040 
00041         linesSt[idx] = ROOT.TLine(xline,ymin,xline,ymax)
00042         linesSt[idx].SetLineStyle(2)
00043         linesSt[idx].SetLineWidth(2)
00044         if draw: linesSt[idx].Draw("SAME")
00045 
00046     for idx in range(1,5):
00047         xlabel = (idx - 1)*60 + 20
00048         ylabel = ymin + 0.75*(ymax -ymin)
00049         if xlabel >= histo.GetNbinsX(): continue
00050 
00051         strSt = "MB%d" % idx
00052         labels[idx] = ROOT.TPaveLabel(xlabel,ylabel,(xlabel+20),(ylabel + 0.10*(ymax -ymin)),strSt)
00053         labels[idx].SetTextSize(0.5)
00054         labels[idx].SetFillColor(fillColor)
00055         if draw: labels[idx].Draw("SAME")
00056 
00057     objects = []
00058     objects.append(linesWh)
00059     objects.append(linesSt)
00060     objects.append(labels)
00061 
00062     return (canvas,histo,objects)