Re: Finding corrupted root files

From: Rene Brun <>
Date: Mon, 03 Jan 2005 10:20:18 +0100

You can detect if a file is corrupted or correctly open with:  -case A

   TFile *f = new TFile("myfile.root");
   if (f->IsZombie()) {

      cout << "Error opening file" << endl;    }

 -case B

  TFile *f = TFile::Open("myfile.root");    if (!f) {

      cout << "Error opening file" << endl;    }  

 -case C

   TFile *f = new TFile("myfile.root");
   if (f->TestBit(TFile::kRecovered)) {

      cout << "file has been recovered" << endl;    }    

When building a TChain, you can force TChain::Add to check if the file is valid by specifying the second argument negative. In case of failure the bad file is not added to the list of files.

Rene Brun

Avdhesh Chandra wrote:
> Hi,
> I am having more then 2000 root files, after chaining them I read file
> content using macro. It goes smoothly for some events but its coming out
> without any error mesg.
> >root -l input_files*.root
> is not showing any error mesg like any file is not closed etc.
> It seems to me that root is able to read the file, but when it tries to
> open the file its not able to read the file content, as file is corrupt.
> Is there is any way which can tell me which file is corrupt?
> Thanks,
> Avdhesh
Received on Mon Jan 03 2005 - 10:19:06 MET

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:04 MET