Dear,
I am trying to analyses a bunch of rootuple file with our analyses software. Some of this file seems to be corrupted but, I did not find a way to detect it. Each time my analyses encounter such a file, it crashes. I could simply removed them from the hard drive, but data are coming each 30 min and I would like an automatic procedure to detect those file.
Here is the procedure I am using to add the file to be analysed to a TChain object :
[code][…]
TChain* chain = new TChain();
TFile *File;
char PATH[1054];
DIR *dp;
struct dirent *dirp;
//1- Load a list of File
if(Param.InputFile.size() > 1 )
for(int i=0; i<Param.InputFile.size(); i++)
{
//CHECK THE FILE ISN'T CORRUPTED
File = TFile::Open (Param.InputFile[i]);
if (File == 0x0)
{
printf("\033[43;31m!!!! ERROR !!!!\033[0m\n Bad File %s Access\n\n",Param.InputFile[i]);
continue;
}
if (File->IsZombie())
{
printf("\033[43;31m!!!! ERROR !!!!\033[0m\n File %s is zombie\n\n",Param.InputFile[i]);
File->Close();
continue;
}
File->Close();
if(chain->Add(Param.InputFile[i]) <= 0)
{
printf("\033[43;31m!!!! ERROR !!!!\033[0m\n Can not add file %s to chain.\n",Param.InputFile[i]);
continue;
}
printf(" Add file [%i] \033[22;34m%s\033[0m to chain.\n",i+1,Param.InputFile[i]);
}
}
chain->TChain::Process(Param.Script,Param.OPTIONS);
return 1;
}
[/code]
In the above code, Param is a class describing the input parameters of my analyses software. InputFile is a array of char which list all file I whish to analyse, Script is the analyses script and OPTIONS are the option required in my script.
For some file, I get the following error :
R__unzip: error -3 in inflate (zlib)
TrRecon::SetParFromDataCards-I-TrackThrSeed= 4 4
R__unzip: error in header
TrPdfDB::Load-W no TrPdfDB in file.
InitDB Init done 0
R__unzip: error in header
AMSEventR::ReadHeader-I-Version/OS 526/12 root://ccxroot:XXXX//hpss/in2p3.fr/XXXXXXXXXXXXXXXXXXXXXXX/1309758010.00000001.root
AMSEventR::ReadHeader-I-NewRun 1309758010
AMSEventR::UpdateSetup-E-UnabletofindSetupEntryfor 1309758010
Error in <TBranchElement::GetBasket>: File: root://ccxroot:XXXX//hpss/in2p3.fr/XXXXXXXXXXXXXXXXXXXXXXX/1309758010.00000001.root at byte:4126432, branch:ev.fHeader, entry:466, badread=1, nerrors=1, basketnumber=1
Error in <TBranchElement::GetBasket>: File: root://ccxroot:XXXX//hpss/XXXXXXXXXXXXXXXXXXXXXXX/1309758010.00000001.root at byte:0, branch:ev.fHeader, entry:467, badread=1, nerrors=2, basketnumber=1
.....
Error in <TBranchElement::GetBasket>: File: root://ccxroot:XXXX//hpss/in2p3.fr/XXXXXXXXXXXXXXXXXXXXXXX/1309758010.00000001.root at byte:0, branch:ev.fHeader, entry:475, badread=1, nerrors=10, basketnumber=1
Whish lead to a memory leaks and crashes of the analyses when the memory exceed the allowed memory.
I tryed several way to detect such corrupted file but did not manage and I am now asking the help of other people which encouter the same problem.
Note that this file can be opened with root
root oot://ccxroot:XXXX//hpss/XXXXXXXXXXXXXXXXXXXXXXX/1309758010.00000001.root
Their is no message informing me that the file is corrupted or has been recovered while it was opened by root.
I can read the Tree with the TBrowser and plot some histogram. But, I can not run my analyses on this file. So, I wonder the problem is coming from 1 single evenment but I really do not want to loop over all event to check the validity of the file. How can I solve this.