Re: put class elements in a tree

From: Philippe Canal <pcanal_at_fnal.gov>
Date: Mon, 25 Jan 2010 13:51:49 -0600


Hi,

C-style array of objects are not support as a top level type in a branch. To store such an array you need to wrap it into another class (class MyClass { Particle myPartcle[N_PART]; }; ) or use a C++ collection (either a TClonesArray or an std::vector) instead of the C-style array.

Cheers,
Philippe.

On 1/25/10 5:34 AM, Massimiliano Chiorboli wrote:
> Hi All,
> I have a problem in storing an array of classes into a tree using tree->Branch() method.
> I declare and appropriately fill an array of Classes (created by me) of kind e.g. "Particle"
>
> Particle myPartcle[N_PART];
>
> Is it possible and, if so, what is the correct syntax for creating a branch containing the myParticle array?
> I tried with:
>
> tree->Branch("particle", myParticle, 32000, 99);
>
> but this stores into the tree only the first element of the array.
> Thanks.
>
Received on Mon Jan 25 2010 - 20:52:28 CET

This archive was generated by hypermail 2.2.0 : Tue Jan 26 2010 - 11:50:01 CET