Add a branch holding a TClonesArray

HI all,
I want to add a branch to tree holding a TClonesArray
codes:
[color=green]TTree *t=new TTree(“t”,“Particle”);
TClonesArray *array = new TClonesArray(“TParticle”,3);
TParticle *mother= new (array->At(0)) TParticle();
TParticle *daughter1= new (array->At(1)) TParticle();
TParticle *daughter2= new (array->At(2)) TParticle();[/color]
[color=red] t->Branch(array,8000,99);[/color]

[color=red]Error in TTree::Branch: Cannot call this constructor for a TClonesArray[/color]
who can tell me the correct way adding a branch to hold a TCloensArray?
Any guidance will be appreciated.

Hi,

As mentioned in the User’s guide you always need to give a name to the branch … t->Branch("mybranch",&array,8000,99);

Cheers,
Philippe.

Dear Philippe,
Thank you very much. :slight_smile: