void my_clonesarray() { gSystem->Load("./libParticleArray.so"); TFile file("my_clonesarray.root", "RECREATE"); TTree tree("tree", "Test tree"); TClonesArray *ca = new TClonesArray("TParticle"); ParticleArray *pa = new ParticleArray("TParticle"); tree.Branch("clonesarray_split", &ca); tree.Branch("particlearray_split", &pa); for (Int_t i=0; i<100; i++) { //create TParticle objects for (Int_t j=0; j<10; j++) { TParticle *particle = new((*ca)[j]) TParticle(); particle->SetMomentum(gRandom->Gaus(100, 10), gRandom->Gaus(200, 10), gRandom->Gaus(300, 10), gRandom->Gaus(400,10)); new((*pa)[j]) TParticle(*particle); } tree.Fill(); ca->Clear(); } file.Write(); tree.Print(); }