This error is symptomatic of a Tree created as a memory-resident Tree

_ROOT Version:6.20/02
_Platform:CentOS-7-x86_64
_Compiler:gcc 9.2 (I’m not sure but I install root from epel)

When I run a macro, I get the following error

Error in <TBranch::TBranch::WriteBasketImpl>: basket's WriteBuffer failed.

Error in <TBranch::TBranch::Fill>: Failed to write out basket.

Error in <TTree::Fill>: Failed filling branch:Gaussian.Gaussian, nbytes=-1, entry=1
 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(...)

However , I has write

TTree *Gau=new TTree("Gaussian","Gaussian");
TFile* GS=new TFile("GS.ROOT","RECREATE"); 

So what can I do to solve this error

The problem is likely the order in which the tree and the file are created. Please try swapping your code lines such that you create the TFile first and only then then TTree.

Thanks , It has been solved

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