(simple) fill TClonesArray

I want to read TH1I’s from a TFile and copy them into a TClonesArray, but i can’t figure out how to do it.

TClonesArray arr(“TH1I”,N);
arr[0] = (TH1I*) HistFromFile->Clone();
arr[1] = HistFromFile;

doesn’t do it. I could just fill each bin individually, but that’s obviously a horrible hack.

thanks for helping my noob self. couldn’t find an example for this anywhere, though it’s surely a common task.

Hi,

The content of the TClonesArray need to be initialized, use: TClonesArray arr("TH1I",N); new (arr[0]) TH1I(HistFromFile);

Cheers,
Philippe.

thanks!