How to determine version a root file was created with?

I don’t know to what extent the format of root files change between versions of root, but this might explain why I am occasionally having problems reading files - particularly when it is a file I created a while ago! Is there a quick way to determine which version of root was used to create a file and therefore use the right version of root to read it?

Cheers

Ben

see TFile::GetVersion

Rene

Indeed! Sorry!

Is there a way to do this from the shell without invoking root? (I think you get “R__unzip: error in header” if I use an old version of root to open a newer version file.)

Ben

You need to write a small program
-opening the file
-reading the first 8 bytes of the file

The bytes 1->4 contain the chars "root"
The bytes 5->8 are an integer with the ROOT version number
used to write this file.
For more info see the documentation of class TFile.

Rene

Hi ROOTers,

My understanding was TFile::GetVersion() returns a value which is greater than 1000000 when the file is larger than 2 GBs. For example :

  • 52000 : for 5.20.00 I guess.
  • 1052000 : the same for files >2GBs.

I am surprised today to cross files which return 2052000… what does it mean ? Is there a complete description somewhere ?

Thanks.

Hi David,

This may happen when you open a big file (> 2GB) in update mode and save the header again.
I have protected this case such that the version number will only be in this case 1000000+ROOT version number.
Thanks for reporting this case.

Rene

Ok. Fine.