Continue filling an already existing histogram

Dear co-rooters,

What I would like to do the following task :

Open a root file, do some calculations, fill a histogram. Then open a second root file, do some calculations, and continue filling the same histogram as before WITHOUT erasing the previous data.

If I do

TFile *f = new TFile(TString::Format("Signals_%d_%d.root",run, segment)); <calculations> histo->Fill(x); TFile *f1 = new TFile(TString::Format("Signals_%d_%d.root",run+10, segment)); <calculations> histo->Fill(x);

won’t work.

Any idea on how to achieve that?

Thanks in advance!

What you posted is not precise enough.
Is “histo” in memory only ?
Is “histo” present in one file only ? in both file ?

histo is a histogram that I create in my code.
It’s not present in any of the root files that I open.

So there is no reason why you could not continue to fill it.
Can you send a small macro reproducing the problem ?

It seems that there was something else happeing. It works!

Cheers!