Checking a TFile is present in castor before opening


I want to check that a root file in castor is present before I try to read it in so that I don’t try to read in a file that doesn’t exist.

How do I do this?

Thanks, Claire

Hi Claire,

You can useTString path = "file_location"; TFile *mfile = 0; if (!gSystem->AccessPathName(path+"myfile.root",kFileExists)) { // file exists mfile = TFile::Open(path+"myfile.root"); } else { // it does not, you may print a warning }Cheers, Ilka

Thanks Ilka,

This is now working. Is there a similar command to put a limit on the time it takes to read in a file?


Hi Claire,

You could use TTimer class to create a timer according your needs (see

Cheers, Ilka