Error in TTree::Fill how to get rid of pop-up and/or error?

Hi everyone,

I have this error that keeps cropping up, basically I’m filling trees and I get the following:

Error in : Failed filling branch:GammaSinglesTree.SBGOVector, nbytes = -1

And other almost identical ones.

Since my data set is huge I get pages and pages of these. However the tree my code produces seems perfectly fine and all the data is in it.

Is there a simple explanation for this? Is there a way to get rid of the error messages?

My code is relatively short though quite complicated and poorly commented, basically a bastardisation of a whole pile of things but I’ve attached it anyways.
I’ve been having major memory problems with trying to process large files (>100 M), if anyone spots an obvious memory leak please tell me!

Thanks for any help or advice in advance! [-o<
DragonSelector.h (7.1 KB)
DragonSelector.C (26.5 KB)

You must create the output file before creating the output Tree and make sure that the current directory is set where you want to create the Tree.
Recent versions of ROOT print a warning message if this is not the case.

Rene

Thanks so much I can get rid of the error messages now but I haven’t solved my memory problem.
I think it’s because I don’t understand how to “set the current directory”.

What I did was I pushed the Tree definitions later in the code and added the bolded line

gDirectory->Delete(“h*”);
TList *l = gROOT->GetListOfBrowsables();
if (TFolder *f = dynamic_cast
(l->Remove(l->FindObject(“DragonRoot”))))
f->Delete();
fHistFolder = new TFolder(“DragonRoot”, “Offline”);
l->Add(fHistFolder, “E1024”);
fHistFolder->SaveAs(“blah.root”);

This gets rid of the error messages however the file “blah.root” doesn’t contain the tree-data, it merely takes a snapshot of an empty folder.
I think those unbolded lines of code basically create a list that resides in memory and that list contains the folder with all the data. The entire thing resides in memory and then is written out at the end. This was probably adequate for the guy who wrote the code initially but it’s too much memory usage for my purpose.
How do I write the tree as I go rather than right at the end?
The examples in the reference manual all have a write command right at the end. I’ve added AutoSave() at points in my code but it doesn’t seem to require less memory when running. What am I doing wrong? I’m pretty new to manipulating trees.
Any help would be much appreciated!

Could you send the shortest possible RUNNING script reproducing your problem?

Rene