Subtracting Histograms: A Quick Guide

  • Thread starter Thread starter lavster
  • Start date Start date
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
4 replies · 13K views
lavster
Messages
213
Reaction score
0
can anyone tell me how to subtract histograms?

ive got to histograms already defined (pointers) called h1 and h2. and i want to make a third histogram object that is one subtract the other.

so far I've got TH1F h3 = (*h2)-(*h1);
and then after defining a new canvas I've got

h3.Draw();

but its not doing anything :(

thanks!
 
Physics news on Phys.org
lol i forgot that bit - root/C++ :)
 
I think you can do it by making a copy or clone of the first, A, and then using A->Add(B, -1), where B is your second histogram.

Likewise for normalization stuff in your other question, just use something like A->Divide(A->GetEntries), if that normalization function doesn't work.