Adding and substracting histograms from same root file but different trees


ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Hello,
I have one root file and there is five different trees. I want to subtract all four trees from the one tree. That is after defining all five trees was not a problem but when I did something like following it is showing me error.

hist6 = hist1-hist2-hist3-hist4-hist5;…(1)
error: invalid operands to binary expression (‘long’ and ‘TH1D *’)
Basically I want to subtract hist2 hist3 hist4 hist5 from hist1. Defining them is not a problem, I think. But I think writing equation 1 is creating a problem. Can you please sort out the problem and send me a macro of it ?

Thanks and Regards
Souvik

Hi Souvik,

Try this:

hist6 = (TH1F*) hist1->Clone("hist6");
hist6->Add(hist2, -1);
hist6->Add(hist3, -1);
...

Makes sense?

Cheers, Axel.

Thanks for the reply. Now it is showing this error.
error: assigning to ‘TH1F *’ from incompatible type ‘TObject *’
hist6 = hist1->Clone(“hist6”);

I have edited my previous post accordingly!

Axel

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