CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/CalibMuon/DTCalibration/python/PlottingTools/drawHistoAllChambers.py

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