Reading trees from files (TFile)

Hi,

I’ve got trouble working with reading trees from files.

  1. When I use TChain to read about 200 files and process this, my job gets killed on lxplus (unreasonable memory used), so I’m guessing after the information is read, the files aren’t closed. For this, my macro used the code provided in the documentation:

TObjArray *fileElements=chain->GetListOfFiles(); TIter next(fileElements); TChainElement *chEl=0; while (( chEl=(TChainElement*)next() )) { TFile f(chEl->GetTitle()); ... do something with f ... }

  1. When I want to proceed the trees one by one (so also files, one by one), I get segmentation violations.

About problem 2, I had the following question: I read the trees from files; after getting all the tree data, can my file be closed? And similar, do TFiles get automatically closed or not if they go out of scope?

Thanks!

Footnote:
About the last question whether files get automatically closed or not: is it possible that CINT has trouble processing scopes?
I tried to do in CINT:

{ TFile *file=TFile::Open("file.root"); } root [1] TFile file("file.root") Error: file already declared as different type. ~TFile() called
But about this last problem I do not care much since I want to run my code compiled, this was just a testing case.
When this was o

[quote]About the last question whether files get automatically closed or not: is it possible that CINT has trouble processing scopes?
[/quote]Yes, it does have problem with scopes.

Philippe.

[quote]For this, my macro used the code provided in the documentation:[/quote]If the code provided is interpreter, it is plausible that the TFile are only deleted at the end of the loop. Does it also cause problem when you compile that code? If it does, then the trouble is somewhere else (i.e. in the code you did not provide).

[quote]after getting all the tree data, can my file be closed? [/quote]That really depends what you mean by TTree data. When a file is closed (and deleted) the TTree object is deleted and is no longer accessible.

Cheers,
Philippe.

Thanks