I am interested in finding the significance of the difference between entries in bins between two plots
“X / uncertainty on X”
where X is the difference on the number of entries. In ROOT, I think that I should make something like this
(BinContent_a - BinContent_b) / sqrt((BinError_aBinError_a + BinError_bBinError_b))
and then use SetBinContent on the comparison histogram to overwrite its contents with the significance, instead of the ratio.
I am looking for a way to implement this in my own code which makes a ratio of 2-D histograms. Here is the code in PyROOT:
import ROOT
ROOT.gROOT.SetBatch()
#open root file
rootfile1 = ROOT.TFile.Open(“HIST.07511504._000001.pool.root.1”)
#get histo 1
etaphi_284285 = rootfile1.Get(“run_284285/MuonPhysics/Muons/CBMuons/Muons_CBMuons_eta_phi”)
#open second root file
rootfile2 = ROOT.TFile.Open(“HIST.07363316._000001.pool.root.1”)
#get histo 2
etaphi_283429 = rootfile2.Get(“run_283429/MuonPhysics/Muons/CBMuons/Muons_CBMuons_eta_phi”)
#n bins merge into one bin in both the x and the y directions
rebin_eta = 4
rebin_phi = 4
#begin loop over both histograms
for histogram in [etaphi_284285,
etaphi_283429,
]:
print “histogram=”, histogram
#rebin
histogram.Rebin2D(rebin_eta, rebin_phi)
print “histogram.Integral=”, histogram.Integral()
#normalize to get ratio of the events in bin/total events in each histogram
histogram.Scale(1 / histogram.Integral())
#divide the histograms
ratio = etaphi_284285.Clone()
ratio.Reset()
ratio.SetName(“ratio_284285_283429”)
ratio.Divide(etaphi_284285, etaphi_283429)
(then I create a root file containing this histogram).