TFile::ReadKeys

I am trying to open a root file that I have on disk, and what I get is the following:

root [0] TFile *f=new TFile(“TrackingData2004.root”)
Error in TFile::ReadKeys: reading illegal key, exiting after 0 keys
Info in TFile::Recover: TrackingData2004.root, recovered key TTree:tracking_data_tree_2004 at address 2972985
Info in TFile::Recover: TrackingData2004.root, recovered key TTree:tracking_data_tree_2004 at address 3129599
Info in TFile::Recover: TrackingData2004.root, recovered key TTree:tracking_data_tree_2004 at address 3286213

Why do I have this error, and what can I do to solve it?..

Thank you very much…
Berta

Hi Berta,

Either the file has not been closed properly (I.e. missing file->Write() and/or file->Close() and/or crash in the writing program) or the file has been corrupted on disk.

It is possible but not guaranteed that the following might fix the file:
(i.e. before doing so make a backup of the file):

TFile *f=new TFile("TrackingData2004.root","UPDATE") ; f->Write(); f->Close();

Cheers,
Philippe.