TH1F combine spectra

Hello

I have a question about a piece of code. I have various 1D histograms and want to combine. Now I have been able to do this successfully but I want to know why I cannot include the code in the same script.

e.g.

#include <runsPR254.h>
#include <TROOT.h>
#include <TH1F.h>

TH1F *hCombo, *hExCurrent;

void hEx_add()
{
	for(int i=0 ; i<109 ; i++)
	{
		gROOT->ProcessLine(Form(".x Ex/Ex-runs%d.C",runs[i]));
		hExCurrent = (TH1F*)gROOT->FindObjectAny("Ex");
		if(i==0) hCombo = (TH1F*)hExCurrent->Clone("hExCombo");
		else if(i>0) hCombo->Add(hExCurrent);
	}
	hCombo->Draw();
}

Now if this code is executed in the same script as the one that actually generates the 1D histograms, it simply copies the first histogram every loop iteration. I have to run this script separately. Does anyone know why? Or is this a bug. I think it might be.

(ROOT v5-34-00-patches, Ubuntu 18.04)

Can you show this “same script” ?
We need to have the full picture to understand your problem.