Subtraction two histograms with differents entries in Pyroot

Hello everyone
In advance thank you very much for the help.

I’m just learning about pyroot and now I have a difficulty because I have to subtract two histograms with pyroot but the number of entries is different in each one, but I can’t find on the internet examples of how to do it in pyroot when there are different inputs.

Thank you again.

Carlos

The answer to this depends on what you mean by different number of entries. Strictly speaking, a different number of entries in a histogram (number of times you called Fill on the histogram) doesn’t prevent you from subtracting one from another. However, a different binning (number of bins, or lower/upper edges of bins) will stop you, and there are workarounds like re-binning, to reach a common number, in some cases.

So giving some more info will let someone help you with your specific case:

print(histo1.GetXaxis().GetNbins(), histo2.GetXaxis().GetNbins())
print(histo1.GetXaxis().GetBinLowEdge(1), histo2.GetXaxis().GetBinLowEdge(1))
print(histo1.GetXaxis().GetBinUpEdge(histo1.GetXaxis().GetNbins()), histo2.GetXaxis().GetBinUpEdge(histo2.GetXaxis().GetNbins()))

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.