Looping in Directiry over .fits files

Hi there,

I was wonderning how I could manage to iterate over a chain of .fits files. Using TChain is not working, as .fits is obviously not .root. I read about the TDirIter class developed in the ATLAS experiment. Is there something similiar?
Somehting like: indicate the directory, indicate the specific file names (in my case .fits files), sort them and then loop over files for analysis using an iterator (somehting like a Next option?!)

Hope you have an idea.



Hi Cornelia,

See for example [url=https://root-forum.cern.ch/t/get-and-process-all-files-from-a-directory/12565/1 post[/url] or [url=https://root-forum.cern.ch/t/open-files-in-a-directory-with-a-for-loop/12471/1 one[/url]

Cheers, Bertrand.

Dear Bertrand,

thanks for the quick reply. I already had a look on this post, but hosently speaking I do not consider it an “easy” way to loop over data. Is there nothing more simple?!

I have to add something. Working with signal and dark frames as fits., I would need two sperated lists with the sorted files respectively so that I can aubstract tha dark from the correct signal frame

Dear Cornelia,

Sorry, but I’m scared there is nothing much simpler than those few lines of code, as far as I know… Maybe someone on the forum will have another suggestion.

Cheers, Bertrand.