IsZombie

In a program I’m trying to open files in a loop, and maybe some times the files don’t exist, but I woulld liike the loop to go on, so I have writen this portection:

rootfile = new TFile(dummy);
if(rootfile->IsZombie())
{printf ("There is no .root file ");
}

But still if the file don’t exists I get:

Error in TFile::TFile file run2808.root does not exist

And my progran crash!

How can I solve this?

Thank you very much

Berta

Hi,

You are most likely still missing some protection in your code. Once the file is a zombie it object is not really usable.

You might have to do

rootfile = new TFile(dummy); if(rootfile->IsZombie()) { printf ("There is no .root file "); delete rootfile; rootfile = 0; } .... if (rootfile) { ... use rootfile ... } else { ... do something without the rootfile ... }

Cheers,
Philippe.