Re: Finding corrupted root files

From: Rene BRUN <brun_at_mail.cern.ch>
Date: Fri, 14 Jan 2005 08:26:44 +0100 (MET)


My answer was in the last paragraph of my mail p3->Add("./TMBTREEROOTFILES/recoT*.root",-1);

see: http://root.cern.ch/root/htmldoc/TChain.html#TChain:Add

Rene Brun

On Fri, 14 Jan
2005, Avdhesh
Chandra wrote:

>
> Hi,
> I have a different type of problem now.
> >From some dir., I am chaining using *
> like
> --------------
> TChain *p3 = new TChain("TMBTree","chain q");
> p3->Add("./TMBTREEROOTFILES/recoT*.root");
> TTree* mytreec = (TTree*)p3;
> --------------
>
> What I can do so it reject bad files for chaining?
> and it will be better if can tell me which files it is rejecting.
>
> Thanks,
> Avdhesh
>
> >>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 Fri Jan 14 2005 - 08:27:01 MET

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