Can't f->get specific histos

hi All,

I am trying to read some histos from a file and then write these to another file. It should be a straightforward and common task ; I tried 2 different approaches but ended up with the same result. I am attaching the rootfile and the codes I tried. Why can’t I iterate over this f->get thing ? Doesn’t make any sense :slight_smile:

I would appreciate some insight from experienced users.

y.
calibPulseShapes_212135.root (903 KB)
test2.C (969 Bytes)
test1.C (1.04 KB)

Hi,

First of all, you should replace: for(i=0;i==55;i++){
By: for(i=0;i<55;i++){
And also use TString::Format() to format parameters… For example: hHFR->Write(TString::Format("Chan_%d",i));
And try again :wink:

Cheers, Bertrand.

hi Bertrand,

Thank you for your reply, it works. But I would prefer to make the other method work (eta[i],phi[i],depth[i]) ?

Well, as I said, use TString::Format():

TH1F *hHFR = (TH1F*)f->Get(TString::Format("calibPulseShapes/HF_eta%d_phi%d_depth%d_chanNo=32767",eta[i],phi[i],depth[i]));
Cheers, Bertrand.

Excellent! Thank you very much.

Cheers.

No problem! :slight_smile:
Cheers, Bertrand.