def getSmallestBinMarker(hist, color=ROOT.kBlack): bx, by, bz = (ROOT.Long(), ROOT.Long(), ROOT.Long()) hist.GetBinXYZ(hist.GetMinimumBin(), bx, by, bz) cm = PyROOTUtils.CrossMarker( hist.GetXaxis().GetBinCenter(bx), hist.GetYaxis().GetBinCenter(by), markerColor=color, ) return cm
def getInterpolatedMinimumMarker(hist, color=ROOT.kBlack): """ This takes the neighboring two bins and plots a parabola through the three points defined by the three bins (parabolas are uniquely defined by three points). No fitting has to be done. The minimum of that parabola is used as the interpolated minimum. For the bin heights y1, y2 and y3 at the bin positions 0, \Delta x and 2\Delta x, the parabola minimum x0 is at: -x0 = [4(y2-y1) - (y3-y1)]\Delta x / [2(y3-y1) - 4(y2-y1)] This ignores (off-)diagonal neighboring cells which would go beyond what can be uniquely defined for a parabola. """ bx, by, bz = (ROOT.Long(), ROOT.Long(), ROOT.Long()) hist.GetBinXYZ(hist.GetMinimumBin(), bx, by, bz) # interpolate position horizontally y1 = hist.GetBinContent(hist.GetMinimumBin() - 1) y2 = hist.GetBinContent(hist.GetMinimumBin()) y3 = hist.GetBinContent(hist.GetMinimumBin() + 1) deltax = (hist.GetXaxis().GetBinCenter(bx + 1) - hist.GetXaxis().GetBinCenter(bx - 1)) / 2.0 x0 = hist.GetXaxis().GetBinCenter(bx - 1) + ( (4.0 * (y2 - y1) - (y3 - y1)) * (-deltax)) / (2.0 * (y3 - y1) - 4.0 * (y2 - y1)) # interpolate position vertically bU = hist.GetMinimumBin() + (hist.GetXaxis().GetNbins() + 2) # bin up bD = hist.GetMinimumBin() - (hist.GetXaxis().GetNbins() + 2) # bin down y1 = hist.GetBinContent(bU) y2 = hist.GetBinContent(hist.GetMinimumBin()) y3 = hist.GetBinContent(bD) deltay = (hist.GetYaxis().GetBinCenter(by + 1) - hist.GetYaxis().GetBinCenter(by - 1)) / 2.0 y0 = hist.GetYaxis().GetBinCenter(by - 1) + ( (4.0 * (y2 - y1) - (y3 - y1)) * (-deltay)) / (2.0 * (y3 - y1) - 4.0 * (y2 - y1)) cm = PyROOTUtils.CrossMarker( x0, y0, markerColor=color, ) return cm
def drawH(filename, histname): f = ROOT.TFile.Open(filename, "READ") h = f.Get(histname) h.SetStats(False) h.SetContour(100) #h.Scale( 2 ) h.SetMinimum(-1e-6) h.SetMaximum(6) #h.GetZaxis().SetTitle( "-2 ln #Lambda" ) h.Draw("COLZ,SAME") container.append(h) bFOrig = f.Get(histname + "_bestFit") bF = PyROOTUtils.CrossMarker(bFOrig.GetX(), bFOrig.GetY()) bF.Draw() container.append(bF) openFiles.append(f) return (h, bF)