is there a way to invert the ratio calculated by TRatioPlot?
I have a TH1 with my data events and a THStack with all backgrounds and would like to see Data/Background in the ratio window, not Background/Data.
I haven’t seen such an option, that is why I am asking, but from a quick look at the code this seems to be impossible to me.
Also, I couldn’t find an option to invert in TGraph or TGraphErrors, so it seems to me as if I had to hack in a graph inversion myself by going through the array of the graph entries. Is there really no easier way?
from array import array
def invert_graph(graph):
yvalues = array('d', [0 if y==0 else 1/y for y in graph.GetY()])
errors = array('d', [0 if y==0 else e/(y**2) for y, e in zip(graph.GetY(), graph.GetEY())])
return ROOT.TGraphErrors(len(errors), graph.GetX(), yvalues, graph.GetEX(), errors)
and draw it to the lower pad. Then make the original ratio graph invisible: