Normalize and subtract two 2D histograms

Hello all,

I have two histograms that I created from macros and then saved as 1.root and 2.root. 1.root has ~10 times as many events in it, so I want to normalize 2.root to have the same number of events, then subtract the bins in 1.root from 2.root to produce another histogram, “1-2”.root. Can anyone tell me how I can do this?

Thank you for your time,

Normalize your histograms to the number of entries (or whatever you want) with:

TFile *f1 = new TFile("1.root"); TH1 *h1 = (TH1*)f1-->Get("myhistogramname"); double nentries = h1->GetEntries(); h1->Scale(1/nentries);


EDIT: Thanks, I got it to work.