8 Modify histogram so that it is rescaled in a "bilog" manner. 9 Negative values are -log10(-z). An offset in log10 is returned 12 nx,ny = hist.GetNbinsX(), hist.GetNbinsY()
13 zmax =
max(
abs(hist.GetMinimum()),
abs(hist.GetMaximum()))
16 zmin = sum([
abs(hist.GetBinContent(99,iy))
for iy
in range(ny)]) / ny
17 lmin =
int(log10(zmin))
19 lmax = 1+
int(log10(zmax))
21 for ix
in range(hist.GetNbinsX()):
22 for iy
in range(hist.GetNbinsY()):
23 val = hist.GetBinContent(ix, iy)
25 hist.SetBinContent(ix, iy, 0.0)
31 lval = log10(
abs(val))
37 hist.SetBinContent(ix, iy, lval)
43 hist.SetMaximum(lhmax)
44 hist.SetMinimum(-lhmax)
48 from array
import array
49 stops =
array(
'd',[ 0.00, 0.45, 0.50, 0.55, 1.00 ])
50 reds =
array(
'd',[ 0.00, 0.00, 1.00, 1.00, 0.51 ])
51 greens =
array(
'd',[ 0.00, 0.81, 1.00, 0.20, 0.00 ])
52 blues =
array(
'd',[ 0.51, 1.00, 1.00, 0.00, 0.00 ])
55 ROOT.gStyle.SetNumberContours(100)
58 if not which
or which ==
"custom":
59 ROOT.TColor.CreateGradientColorTable(len(stops), stops, reds, greens, blues, 100)
61 ROOT.gStyle.SetPalette(which)
64 fp = ROOT.TFile.Open(
"build/util/test_impactresponse.root")
68 outname =
"test_impactresponse.pdf" 71 c.SetRightMargin(0.15)
72 c.Print(outname+
"[",
"pdf")
76 limits = dict(fr = [0.5e-12, 0.3e-12, 0.8e-12],
77 dr = [9.0e-12, 9.0e-12, 20.0e-12])
78 lmins = dict(fr = [-17, -17, -17],
83 wline.SetLineColorAlpha(1, 0.5)
87 hline.SetLineColorAlpha(2, 0.5)
90 for wpitch
in range(0,36,3):
91 wline.DrawLine(0, wpitch, 100, wpitch)
92 wline.DrawLine(0, -wpitch, 100, -wpitch)
94 hline.DrawLine(0, wpitch-1.5, 100, wpitch-1.5)
95 hline.DrawLine(0, -wpitch+1.5, 100, -wpitch+1.5)
98 for name
in [
"fr",
"dr"]:
99 hist = fp.Get(
"h%s_%c" % (name, letter))
105 lim = limits[name][iplane]
106 hist.GetZaxis().SetRangeUser(-lim, lim)
107 c.Print(outname,
"pdf")
110 lminin = lmins[name][iplane]
112 print name,iplane,lminin,lminout
113 title = hist.GetTitle()
114 title +=
" [sign(z)(log10(abs(z)) %d)]" % lminout
118 c.Print(outname,
"pdf")
120 c.Print(outname+
"]",
"pdf")
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
def set_palette(which="custom")
def bilogify(hist, lmin=None)
static int max(int a, int b)
auto array(Array const &a)
Returns a manipulator which will print the specified array.