6 import Validation.RecoTrack.plotting.plotting
as plotting
10 h.SetDirectory(tdirectory)
13 h.SetMarkerStyle(markerStyle)
14 h.SetMarkerColor(color)
20 _defaultStyles = [(
lambda c, m: (
lambda h:
applyStyle(h, c, m)))(color, ms)
for color, ms
in itertools.izip(plotting._plotStylesColor, plotting._plotStylesMarker)]
24 def draw(name, histos, styles=_defaultStyles, legendLabels=[], **kwargs):
31 if not "ratioFactor" in args:
32 args[
"ratioFactor"] = _ratioFactor
33 ratio = args.get(
"ratio",
False)
36 height = int(height*ratioFactor)
43 if len(legendLabels) > 0:
44 if len(legendLabels) != len(histos):
45 raise Exception(
"Got %d histos but %d legend labels" % (len(histos), len(legendLabels)))
59 legend = ROOT.TLegend(lx1, ly1, lx2, ly2)
60 legend.SetLineColor(1)
61 legend.SetLineWidth(1)
62 legend.SetLineStyle(1)
63 legend.SetFillColor(0)
64 legend.SetMargin(0.07)
65 legend.SetBorderSize(0)
67 for h, l
in zip(histos, legendLabels):
68 legend.AddEntry(h, l,
"L")
80 def drawSingle(pad, histos, styles=_defaultStyles,
82 xtitle=
None, ytitle=
None,
84 legendDx=0, legendDy=0, legendDw=0, legendDh=0,
85 xmin=
None, ymin=0, xmax=
None, ymax=
None, xlog=
False, ylog=
False,
86 xgrid=
True, ygrid=
True,
87 ratio=
False, ratioYmin=0.5, ratioYmax=1.5, ratioYTitle=plotting._ratioYTitle, ratioFactor=1.25):
91 ratioBounds = (bounds[0], ratioYmin, bounds[2], ratioYmax)
92 frame =
plotting.FrameRatio(pad, bounds, ratioBounds, ratioFactor, ratioYTitle=ratioYTitle, nrows=nrows)
97 if xtitle
is not None:
98 frame.setXTitle(xtitle)
99 if ytitle
is not None:
100 frame.setYTitle(ytitle)
104 frame.setGridx(xgrid)
105 frame.setGridy(ygrid)
109 for i, h
in enumerate(histos):
110 st = styles[i%len(styles)]
112 h.Draw(drawOpt+
" same")
125 def drawMany(name, histoDicts, styles=_defaultStyles, opts={}, ncolumns=4):
126 if len(histoDicts) == 0:
129 histoNames = histoDicts[0].
keys()
131 ratioFactor = _ratioFactor
132 for opt
in opts.values():
135 if "ratioFactor" in opt:
136 ratioFactor =
max(ratioFactor, opt[
"ratioFactor"])
138 nhistos = len(histoNames)
139 nrows = int((nhistos+ncolumns-1)/ncolumns)
144 height = int(_ratioFactor*height)
147 canvas.Divide(ncolumns, nrows)
149 histos = collections.defaultdict(list)
152 for n, h
in d.items():
155 for i, histoName
in enumerate(histoNames):
159 args.update(opts.get(histoName, {}))
161 if not "ratioFactor" in args:
162 args[
"ratioFactor"] = _ratioFactor
165 frame =
drawSingle(pad, histos[histoName], styles, nrows, **args)
168 frame._pad.RedrawAxis()
170 canvas.SaveAs(name+
".png")
171 canvas.SaveAs(name+
".pdf")
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)