I have some code which fills a nice TProfile graph, from which I can see the mean of all the entries in each bin as the bin content, with the RMS of those entries as the vertical error bar of that bin content. I would like to see a graph of the ratio RMS/mean for each bin, but searching on RootTalk yielded only partial answers.
In the end I tried two strategies but they seem to give different results. In one case, I did:
mean = h.ProjectionX()
rms = h.ProjectionX('','C=E')
where h is the original TProfile. This seems to work and gives a reasonable graph.
Separately, I did a more convoluted:
convert_type = numpy.double rmsovermean = [h.GetBinError(i)/h.GetBinContent(i) for i in range(h.GetNbinsX()) if h.GetBinContent(i) !=0] myX = [X[i] for i in range(h.GetNbinsX()) if h.GetBinContent(i) != 0] rmsovermean = numpy.asarray(rmsovermean,dtype=numpy.double) myX = numpy.asarray(myX,dtype=numpy.double) gr_rmsovermean = ROOT.TGraph(len(rmsovermean),myX,rmsovermean)
where X is an array of the X coordinates used when filling the TProfile.
While the two give comparable results, they are not equal entry-by-entry. I know one of them is a TGraph and one is a TH1D, but there must be some other misunderstanding on my part between the two processes. Can someone perhaps explain the difference?