SysError in <TFile::Flush>: error flushing file test.r

In the context of a GEANT4 simulation, I’m storing the data in a ROOT file.
I’m running quite long simulation (around 40 hours) on LSF-batch mode at CERN. From time to time, not systematically and always after a consequent number of events, I got this error message at the end of an event:

SysError in : error flushing file test.root (No such file or directory)
The G4 run does not stop and at the end of the following event, I got this other message:
Error in : Failed filling branch:tree.particule, nbytes=-1
Error in : Failed filling branch:tree.left, nbytes=-1

The code to open the file, define the TTree and the method to fill it is in the in attachment. The G4 call to the fill method at the end of the event is in

What am I doing wrong?

Thanks for the help
classes.tar (20 KB)


There are two possible causes to this error
-1 (I suspect it). You have created a memory resident Tree instead of disk resident. This happens when you do
TTree *T = new TTree(…
TFile *f = new TFile(…
instead of
TFile *f = new TFile(…
TTree *T = new TTree(…

-2 you have a network or AFs problem or disk quota exceeded