Dear ROOT-Experts,
(root version 5.14/00e)
is it possible to detect a root file (in a TChain), which was “probably not closed”?
The background to this question is:
In my analysis code, I am adding a large number of files to a chain using a wildcard.
One of this input files got somehow corrupted. Because of that corrupted file, a warning is printed when the contents of the chain are accessed.
But than the root file is (only partially) recovered and my program continues.
The root session below illustrates what happens:
root [0] TChain * chain = new TChain("ntp1011");
root [1] chain->Add("Tau11-tau-run4-*.root")
(Int_t)1
root [2] chain->GetEntries()
Warning in <TFile::Init>: file Tau11-tau-run4-90.root probably not closed, trying to recover
Info in <TFile::Recover>: Tau11-tau-run4-90.root, recovered key TDirectory:PreMicroCuts at address 442
Info in <TFile::Recover>: Tau11-tau-run4-90.root, recovered key TDirectory:PreSelHistos at address 565
Info in <TFile::Recover>: Tau11-tau-run4-90.root, recovered key TDirectory:DecayModes at address 688
Info in <TFile::Recover>: Tau11-tau-run4-90.root, recovered key TDirectory:PostMicroCuts at address 807
Info in <TFile::Recover>: Tau11-tau-run4-90.root, recovered key TDirectory:TopCheckerHistos at address 932
Info in <TFile::Recover>: Tau11-tau-run4-90.root, recovered key TDirectory:Pi0Histograms at address 1063
Info in <TFile::Recover>: Tau11-tau-run4-90.root, recovered key TDirectory:conversionshistos at address 1190
Info in <TFile::Recover>: Tau11-tau-run4-90.root, recovered key TDirectory:NanoHistos at address 1323
Info in <TFile::Recover>: Tau11-tau-run4-90.root, recovered key TTree:ntp1011 at address 215743522
Warning in <TFile::Init>: successfully recovered 9 keys
(const Long64_t)66487364
My problem is, that despite the recovery, the output of my program is useless because of lost contents in the corrupted input file.
Currently, I have to search my log files for the warning given above to detect if there were corrupted input files.
What I would like to do instead is something like that:
[code]{
TChain * chain = new TChain(“ntp1011”);
chain->Add(“Tau11-tau-run4-*.root”)
if( chain->ContainsFileWhichWasNotClosed() ){
exit the program
}
else{
go on
}
}[/code]
Thank you in advance for any hint how to do that.
Best regards,
Aleks