Error in <TFile::WriteBuffer>: error writing all requested bytes to file

Hello all,
I am having problem with the writing of my file.
I am using a Selector that runs on a chain of datafile. The chain element is called in the Notify() function, then this tree is read and in Process() there is the loop on the File and some operations.
A new tree and output file are defined in the Begin() function with all the branches.
I want to copy a part of the branches of the input file and with the other ones, I want to do some operations and fill new branches.
I tested the program for a small amount of data and looks is working fine, no compilation error so far and all the branches are filled correctly.
I fill the tree for each entry of the loop and write the output file in the Terminate() function of the selector.
When the loop on the first file of the Chain ended I receive the following error:

Error in TFile::WriteBuffer: error writing all requested bytes to file /eos/user/c/cgrieco/HGTDTestbeam/Merged/March2019/Batch1605/Batch1605_analyzed_chain.root, wrote 1439840 of 14122550
Error in TBranchElement::TBranch::WriteBasketImpl: basket’s WriteBuffer failed.

Error in TBranchElement::TBranch::Fill: Failed to write out basket.

Error in TBranchElement::Fill: Failed filling branch:myxTr, nbytes=-1
Error in TTree::Fill: Failed filling branch:mytree.myxTr, nbytes=-1, entry=28851
This error is symptomatic of a Tree created as a memory-resident Tree
Instead of doing:
TTree *T = new TTree(…)
TFile *f = new TFile(…)
you should do:
TFile *f = new TFile(…)
TTree *T = new TTree(…)

This is repeated for all the branches that I want to copy from the input tree to the output one. Not for the “new” one, I am filling with analyzed info from the loop.
I understood that this can be a space related problem but have no idea how can be solved. I tried to write my file each 5000 events but then I am getting this error anyway.

I am running in lxplus and have no idea if this is something related to it because I don’t have the possibility to run locally at the moment.

Hope that someone can help me!
Thank you all,

Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided

In which order did you create the output TFile compared to the output TTree. Most likely the output TTree is not attached to the output file (but instead to one of the input).

I create the output Tfile in the Begin() function and then the output TTree. Then in the Notify() function call the TChain and load the Tree on which I loop.

Hi Chiara,

On the sounds of it, it should have worked.

Is the output filename “Batch1605_analyzed_chain.root” ?

Is the disk you are writing to either full or reaching its user quota?


Hi Philippe,
yes “Batch1605_analyzed_chain.root” is the output file name.
I am fine with space, I’m writing the output on my cernbox space trought eos and there are still 800Gb free there.
Also, this happens at the end of the first data file I’m analyzing, while I would need to loop on about ten data files. Also, does not happen for the branches I am filling with “new” informations, but only with the one I’m copying the entries from the input file to the output one.
In the beginning I was basically cloning the branches I wanted to preserve that I would need for the next step of my analysis but this was going in conflict in the case of the chain, because when the second file was opened the cloned branches from the input files were attached as a second tree in my output and not together with the one from the same file, so was not useful.

If you have any suggestion in which this copy of branches could be done that maybe could avoid my problem, they are welcome.


Can you show me the difference in code between the 2?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.