NewR
September 2, 2019, 3:00pm
1
Hi,
I am trying to open recursively root files; I try this code:
TFile *file[5];
TTree *T1[5];
f[1]->Open("/home/daqmgr/neutroni/DataAnalysis/dst/run328.root");
T1[0]=(TTree*) f[1]->Get("T");
but I obtain an error.
The point, to be clear, is that I need to initialize a TFile array to get the TTree contained in the files in a TTree array.
Thanks, NewR
couet
September 2, 2019, 3:27pm
2
NewR:
but I obtain an error.
Can tell us which error you get ?
NewR
September 2, 2019, 4:05pm
3
Thx,
I obtain:
f[1]->Open("/home/daqmgr/neutroni/DataAnalysis/dst/run328.root");
input_line_29:2:3: error: use of undeclared identifier ‘f’
(f[1]->Open("/home/daqmgr/neutroni/DataAnalysis/dst/run328.root"))
^
Error in : Error evaluating expression (f[1]->Open("/home/daqmgr/neutroni/DataAnalysis/dst/run328.root")).
Execution of your code was aborted.
but using f[1].Open I get the same error!
linev
September 2, 2019, 7:01pm
4
Hi,
You should do something like:
f[1] = TFile::Open("/home/daqmgr/neutroni/DataAnalysis/dst/run328.root");
Regards,
Sergey
1 Like
NewR
September 3, 2019, 1:29pm
5
It doesn’t work. I fixed by opening and closing the same temporary root file recursively as:
TFile *f;
Char_t filenm[80];
for (Int_t i=0; i<5; i++) {
nrun = 330 + i;
sprintf(filenm,"…/dst/run%3i.root",nrun);
f = new TFile(filenm);
T1[i]=(TTree*) f->Get(“T”);
f->Close();
delete f;
}
Many thanks, NewR
b_h
September 4, 2019, 7:00pm
6
Is your error due to the act that you called your array TFile *file[5] and not f[] as in your following code?
1 Like
NewR
September 5, 2019, 8:59am
7
Yes, you are right!!! Very stupid error!!
Thank you very much!