Crisps
October 15, 2025, 3:14am
1
Dear experts
I want to set the compatibility for a ROOT file, and I’m suggested to do it by TFile::SetBit(TFile::k630forwardCompatibility), but when I try to change it, I found I couldn’t:
root [0] TFile* f = TFile::Open("SimDetectorResponse/parameters/RECBE_response/response_RECBE002ch24_20241121.root", "Update")
(TFile *) 0x43b6870
root [1] f->TestBit(TFile::k630forwardCompatibility)
(bool) false
root [2] f->SetBit(TFile::k630forwardCompatibility)
root [3] f->TestBit(TFile::k630forwardCompatibility)
(bool) true
root [4] f->Write()
(int) 0
root [5] f->TestBit(TFile::k630forwardCompatibility)
(bool) true
root [6] f->Close()
root [7] delete f;
root [8] TFile* f = TFile::Open("SimDetectorResponse/parameters/RECBE_response/response_RECBE002ch24_20241121.root", "Update")
(TFile *) 0x43b6870
root [9] f->TestBit(TFile::k630forwardCompatibility)
(bool) false
How can I change it?
ferhue
October 15, 2025, 11:52am
3
I think this was fixed some time ago, see the versions that include the fix here:
opened 08:15PM - 07 Aug 24 UTC
closed 01:06PM - 01 Feb 25 UTC
bug
### Check duplicate issues.
- [X] Checked for duplicates
### Description
When… setting `TFile.v630forwardCompatibility` to true in `/etc/root/system.rootrc`, there is still confusing behavior and new files can be written without compability. In particular, *new* files are not opened in compatibility mode (largely limiting the usefulness of the configuration flag).
### Reproducer
```
gEnv->GetValue("TFile.v630forwardCompatibility", 0)
TFile file1 = TFile("file1.root","CREATE")
file1.TestBit(TFile::k630forwardCompatibility)
file1.Close()
TFile file2 = TFile("file1.root","READ")
file2.TestBit(TFile::k630forwardCompatibility)
file2.Close()
TFile* file3 = TFile::Open("file3.root","CREATE")
file3->TestBit(TFile::k630forwardCompatibility)
file3->Close()
TFile* file4 = TFile::Open("file3.root","READ")
file4->TestBit(TFile::k630forwardCompatibility)
file4->Close()
```
produces
```
$ root -l
root [0] gEnv->GetValue("TFile.v630forwardCompatibility", 0)
(int) 1
root [1]
root [1] TFile file1 = TFile("file1.root","CREATE")
(TFile &) Name: file1.root Title:
root [2] file1.TestBit(TFile::k630forwardCompatibility)
(bool) false
root [3] file1.Close()
root [4]
root [4] TFile file2 = TFile("file1.root","READ")
(TFile &) Name: file1.root Title:
root [5] file2.TestBit(TFile::k630forwardCompatibility)
(bool) true
root [6] file2.Close()
root [7]
root [7] TFile* file3 = TFile::Open("file3.root","CREATE")
(TFile *) 0x5650bd7edba0
root [8] file3->TestBit(TFile::k630forwardCompatibility)
(bool) false
root [9] file3->Close()
root [10]
root [10] TFile* file4 = TFile::Open("file3.root","READ")
(TFile *) 0x5650bd584570
root [11] file4->TestBit(TFile::k630forwardCompatibility)
(bool) true
root [12] file4->Close()
```
### ROOT version
```
------------------------------------------------------------------
| Welcome to ROOT 6.30/02 https://root.cern |
| (c) 1995-2023, The ROOT Team; conception: R. Brun, F. Rademakers |
| Built for linuxx8664gcc on Aug 02 2024, 15:34:40 |
| From heads/master@tags/v6-30-02 |
| With g++ (Debian 12.2.0-14) 12.2.0 |
| Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q' |
------------------------------------------------------------------
```
### Installation method
Spack
### Operating system
Linux, debian
### Additional context
Ref. #15006 .
pcanal
October 15, 2025, 3:48pm
4
The meaning of the flag is to change the way object are stored in the file. It can not change the way object are already stored.
So you need to set the flag when creating the file before writing any objects in it.
In addition this bit is not a persistent property of the file. i.e. you need to set it whenever you want to update it (alternative you can use .rootrc setting to do so automatically for all files).
Crisps
October 18, 2025, 12:14pm
5
This means I need to SetBit right after I create the TFile?