Writing a tree in one cycle

Dear all;

I greatly appreciate your help. I would like to fill a tree (CxAODTuple_Nominal) in a single cycle, to avoid the multiple tree naming scheme that root uses when dealing with large files, since this is producing segmentation faults later on when utilising them in TMVA.

I have been told there is an option in root to prevent this from happening, by increasing some default memory? I am using root 6.14/04.

Regards;

Hello @rgamboa,

@pcanal is the I/O expert, so he might have some additional comments, but to me it looks like you might have called Write multiple times?

If writing multiple times is not easy to avoid, overwriting the object might also be a solution. See here:
https://root.cern.ch/doc/master/classTDirectoryFile.html#a14a82403d521393f5f18bd3d7a095fd0

1 Like

I guess your own source code is buggy, if it cannot properly use ROOT trees.
Otherwise, TMVA developers should be made aware of any problems related to their source code.

1 Like

Hi StephanH;

Thanks for your reply and for tagging @pcanal. I believe this has to do more with the way root deals with large files, by saving trees in mid production (as backups) to prevent information loss in the case of power interruption or so. Also, this behaviour only happens for large files, and only pose a problem in further use in trainings when a lack of consecutive cycles are observed, i.e. trees with structure Tree;1, Tree;2 … Tree;n-1, Tree;n behave, while structures like the one in the image does not.

I don’t understand the reason for this, but it has been pointed out to me that there is a way to tell root to save the tree in a single cycle. I suspect there might be a loss of metadata if not doing so.

Rodrigo.

This should be never the case. For all intent and purposes the lower cycles (when coming from ROOT’s backup mechanism) should be ignored when reading (i.e. they ‘just’ point to a subset of the data).

So the real question is ‘why’ a differing pattern of cycles matters in your case.

Cheers,
Philippe

PS. You can disable the autosave mechanism by calling

tree->SetAutoSave(0);
1 Like

Hi Philippe;

Thank you, this clarifies things, I have the suspicion the file is corrupted.

Regards;
Rodrigo.

Try:

{
  TFile *f = TFile::Open("ttbar.root");
  TTree *t;
  f->GetObject("CxAODTuple_Nominal;2", t);
  if (t) t->Print();
  delete t;
  f->GetObject("CxAODTuple_Nominal;3", t);
  if (t) t->Print();
  delete t;
  f->GetObject("CxAODTuple_Nominal", t); // the "very last" ("final") cycle
  if (t) t->Print();
  // delete t;
  delete f; // automatically deletes "t", too
}
1 Like

Thank you for the suggestions @Wile_E_Coyote and @Pepe_Le_Pew.