Writing an array of objects to a single TTree Branch


ROOT Version: 6.04/02
Platform, compiler: Debian, g+±4.9


Dear ROOT experts,

is there a way to write an array of objects (of length N) to a single Branch of a TTree without creating N different sub-branches?

In other words, I would like to obtain something like this:
myTree->Branch(“myBranch”, thePointer, “myBranch[32]/D”); //this creates a new branch containing an array of 32 Double_t
Where rather than an array of Double_t I would like to have an array of a certain object.

Thank you in advance.

Hi,
What about using TObjArray/TClonesArray?

In general, I think, you will need to “encapsulate” your “myBranch[32]” into some another class (and then create the tree branch for an object of this class).

TClonesArray and/or TObjArray are fine but I think they both require the object inherits from TObject.

For a “general purpose” solution you might try to play with std::array and/or std::vector.

Maybe @pcanal has some better ideas.

@Wile_E_Coyote is correct.

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