Error in <TTree::Fill>: Failed filling branch

Hi rooters,
I have the following problem filling a TTree :unamused: ,
does someone

I have a program (fusgamma_OneRing.cxx)
which reads one Tree of data, makes an analysis
and puts the output in 5 different Tree .

TFile *outtree = new TFile(outfile,ā€œRECREATEā€);
TTree *outT = new TTree(ā€œh1_gamā€,ā€œreduced_dataā€);

TFile *outtree1 = new TFile(outfile1,ā€œRECREATEā€);
TTree *outT1 = new TTree(ā€œh1_gam1ā€,ā€œreduced_dataā€);

.
.
.
outT->Branch(ā€œmulfuā€,&mulfu,ā€œmulfu/Iā€);
outT->Branch(ā€œmulfiā€,&mulfi,ā€œmulfi/Iā€);
outT->Branch(ā€œbaffuā€,baffu,ā€œbaffu[mulfu]/Iā€);
outT->Branch(ā€œbaffiā€,baffi,ā€œbaffi[mulfi]/Iā€);
outT->Branch(ā€œenfusā€,enfus,ā€œenfus[mulfu]/Dā€);
outT->Branch(ā€œenfisā€,enfis,ā€œenfis[mulfi]/Dā€);
outT->Branch(ā€œlibfusā€,&libfus,ā€œlibfus/Iā€);
outT->Branch(ā€œlibfisā€,&libfis,ā€œlibfis/Iā€);

outT1->Branch(ā€œmulfu1ā€,&mulfu1,ā€œmulfu1/Iā€);
outT1->Branch(ā€œmulfiā€,&mulfi,ā€œmulfi/Iā€);
outT1->Branch(ā€œbaffu1ā€,baffu1,ā€œbaffu1[mulfu1]/Iā€);
outT1->Branch(ā€œbaffiā€,baffi,ā€œbaffi[mulfi]/Iā€);
outT1->Branch(ā€œenfus1ā€,enfus1,ā€œenfus1[mulfu1]/Dā€);
outT1->Branch(ā€œenfisā€,enfis,ā€œenfis[mulfi]/Dā€);
outT1->Branch(ā€œlibfus1ā€,&libfus1,ā€œlibfus1/Iā€);
outT1->Branch(ā€œlibfisā€,&libfis,ā€œlibfis/Iā€);

.
.
.
outT->Fill();
outT1->Fill();
.
.
.

I compiled the makefile and the program seemed to work.
But for one of the two systems which I want to analyze
I got this error

Error in TTree::Fill: Failed filling branch:h1_gam3.libfus3, nbytes=-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(ā€¦)
Error in TTree::Fill: Failed filling branch:h1_gam3.libfis, nbytes=-1
Error in TTree::Fill: Failed filling branch:h1_gam4.mulfu4, nbytes=-1
This error is symptomatic of a Tree created as a memory-resident Tree
Instead of doing:

Then, I added a line outT->SetAutoSave(600000000);
for each Tree
(trying to increase the AutoSave)

TFile *outtree = new TFile(outfile,ā€œRECREATEā€);
TTree *outT = new TTree(ā€œh1_gamā€,ā€œreduced_dataā€);
outT->SetAutoSave(600000000);

but now when I run my program I get again the same error

Any other suggestions ?

Thanks in advance,
R.

It looks like you changed the directory between the opening of the file and the creation of the Tree.
Could you post the shortest possible running script reproducing your problem?

Rene

Many thanks for your suggestions.

I have found the cause of my problem working around the different directories.

Cheers,
Rosetta