Subtracting two histograms

Hi there

I have two histograms being filled out in two different FOR loops:




Remember they are in different FOR loops, which take different root files as input and hence they have different entries in them.

now to plot the residue (difference) I do the following, outside both the FOR loops:

h_hit_residue->Fill(h_hit_hitsperchannel1 - h_hit_hitsperchannel2);

When i do this, I see an empty canvas for residue (Image attached)

The entries for the two histograms are 21748 and 21326.

Could you guys please help with this?

Let me know if you need any more info.


TH1F *h_hit_residue = new TH1F(*h_hit_hitsperchannel1); // TH1F or TH1D, same as h_hit_hitsperchannel1
h_hit_residue->SetNameTitle("h_hit_residue", "Hits per channel residue;Channel Number;Difference in Number of Hits");
if (!(h_hit_residue->GetSumw2N() > 0)) h_hit_residue->Sumw2(kTRUE); // ensure proper error propagation
h_hit_residue->Add(h_hit_hitsperchannel2, -1.0);

Thank you so much. That worked like a charm

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