Adding two TH2F histograms

Hi I’m currently trying to add (subtract) two TH2F histograms.
I’ve plotted positive charge against momentum in os, and negative charge against momentum in ss. I wish to plot the different of positive to negative charges against momentum. I tried the following:

h1->Add(os,ss,1,-1);
h1->Draw(“e”);

But what I get out is nonsense (covers the whole plot with entries). I have been working with TH1F only, so I wasn’t sure if the Add command was the right one. Can someone lend me a hand please? Thank you

Could you send the shortest possible RUNNING script reproducing/explaining your problem?
Do you have the same binning in your histograms?
Note that you can simply do

os.Add(ss,-1); This will substract ss from os. You can save the original os before the operation if necessary.

Rene

This is very vague,


os = new TH2F("os","TLpt:OS",120,0,120,120,0,120);    
ss = new TH2F("ss","TLpt:SS",120,0,120,120,0,120);
oss = new TH2F("oss","TLpt:OS-SS",120,0,120,120,0,120);
 

data->Draw("pt*dQ:TLpt>>os","njet==1&&Ht>=0&&Met>20&&SLT==1&&run<237795&&dQ<0");
 data->Draw("pt*dQ:TLpt>>ss","njet==1&&Ht>=0&&Met>20&&SLT==1&&run<237795&&dQ>0");
oss->Add(os,ss,1,-1);
oss->Draw();

They have the same number of bins, and the variables are filled from ntuples. Thank you for helping

Kim