Adding histograms

Hi,

I was wondering if i can get help to solve a simple problem in root. I have four different histograms in four different folders. I want to add them up. Can someone please help me how to do it?

Thanks in advance!

Hi,

the method you are looking for is TH1::Add. In code:

histo1.Add(histo2);
histo1.Add(histo3);
histo1.Add(histo4);

Cheers,
D

Thanks for reply. I have another problem. My histograms are in different folders e.g, histo 1 is in one folder and histo 2 is in another folder. I am wondering how can i set the path for those histograms?

cheers

You should “cd” in each folder, "Get’ the histogram you need in that folder and do the Add once you have got all them.

… Or simply input the full path into the Get or GetObject methods of TFile.

Cheers,
D