I am trying to save to TFile two TTree objects, that get filled by a selection of events taken by another TFile, that changes during the execution.
When I declare and create the TTree I do:
TFile * outputFile = new ...
TTree * TreeS = new ...
but then there is a loop that eventually opens different other TFiles for reading the events and filling the tree. From time to time I try
TreeS->Write();
in order to avoid filling up the RAM.
I get the error
Error in <TFile::WriteTObject>: Directory /nfs/cuore1/data/CUORE/ContinuousData/run301530/QRaw_RDCF_301530_C_C2_p041.root is not writable
as if ROOT was trying to write the tree in the file it was supposed to read from. I tried also to put
BranchS->SetFile(pOutputFile);
before the TreeS->Write() command, but nothing changed.
Can someone help me out?
Many, many (and even more!) thanks in advance.
Guido
ROOT Version: Not Provided Platform: Not Provided Compiler: Not Provided
Thanks! That actually solves the problem of the tree being written to the wrong file but I guess somehow ROOT does not flush the RAM after that because I get very soon to 9 GB of memory usage, which is my limit, and the process gets killed. I tried to debug with
but I can’t get to understand anything useful.
In other words, is there any way to force the flushing of the RAM space allocated for the TTree and/or setting a limit for it?
The output I get from the commands above is
0.29171 % completed.
******************************************************************************
*Tree :TreeS : Signal Tree *
*Entries : 3022 : Total = 121055535 bytes File Size = 47691584 *
* : : Tree compression factor = 2.50 *
******************************************************************************
*Br 0 :V : V[10000]/F *
*Entries : 3022 : Total Size= 121073113 bytes File Size = 47681716 *
*Baskets : 1879 : Basket Size= 3200000 bytes Compression= 2.50 *
*............................................................................*
******************************************************************************
*Tree :TreeB : Background Tree *
*Entries : 993 : Total = 39812995 bytes File Size = 15977746 *
* : : Tree compression factor = 2.49 *
******************************************************************************
*Br 0 :V : V[10000]/F *
*Entries : 993 : Total Size= 39817445 bytes File Size = 15977370 *
*Baskets : 993 : Basket Size= 32000 bytes Compression= 2.49 *
*............................................................................*
* * * * * * * * * * * *
gDirectory->ls( -d ) LIST OBJECTS ON DISK
TFile** /nfs/cuore1/scratch/gfantini/neuralnet/TMVA/input/InputTMVA.root
TFile* /nfs/cuore1/scratch/gfantini/neuralnet/TMVA/input/InputTMVA.root
KEY: TTree TreeS;3 Signal Tree
KEY: TTree TreeS;2 Signal Tree
KEY: TTree TreeB;2 Background Tree
KEY: TTree TreeB;1 Background Tree
gDirectory->ls( -m ) LIST OBJECTS ON RAM
TFile** /nfs/cuore1/scratch/gfantini/neuralnet/TMVA/input/InputTMVA.root
TFile* /nfs/cuore1/scratch/gfantini/neuralnet/TMVA/input/InputTMVA.root
OBJ: TTree TreeS Signal Tree : 0 at: 0x2ae26e0
OBJ: TTree TreeB Background Tree : 0 at: 0x2ae2a10
^C
Thanks a lot for the suggestions!
In the end I realized that the memory issue was coming from a bug I introduced that had nothing to do with ROOT (I just forgot to free a double *).
But the other part outputFile->cd() was really helpful. Thanks a lot for that.