Thanks Rene,
I tried , but I get a segmentation violation on
Particle * p = (Particle *) ArrayofParticle->At(1);
actually, also ArrayofParticle->GetSize() breaks.
It is strange, because, as I
said, I can access other branches (but no TClonesArray) with no problem.
Is it a symptom you have already seen, by chance? What can my mistake be
?
Cheers
Stefano
On Thu, 20 Jul 2000, Rene Brun wrote:
> Hi Stefano,
> If you change:
>
> tree->SetBranchAddress("ArrayofParticles", ArrayofParticles);
> to
> tree->SetBranchAddress("ArrayofParticles", &ArrayofParticles);
>
> your program will work OK.
>
> Rene Brun
>
> Stefano Argiro' wrote:
> >
> > Hi Rooters,
> >
> > I am very confused about the following:
> > suppose you store many objects of the kind 'Particle' in a
> > TClonesArray of particles called "ArrayofParticles"
> > You now want to store the array in a TTree. Then ,
> > TTree::Branch("ArrayofParticles",clonesarrayname,...) splits in many
> > sub-branches, each containing, at the end, basic data types of the kind
> > 'Particle.fPX, etc... '.
> >
> > If I want to read back directly Particle.fPX from its associated branch,
> > no problem.
> >
> > The question is: can you read back ArrayofParticles and have access to
> > every 'Particle ' in the TClonesArray ??
> >
> > I tried with something like:
> >
> > TClonesArray *ArrayofParticles = new TClonesArray();
> > tree->SetBranchAddress("ArrayofParticles", ArrayofParticles);
> > tree->GetEvent(0);
> > Particle * p = (Particle *) ArrayofParticles->At(1);
> > cout<< p->GetPX();
> >
> > ROOT tells me something like
> > Error: non class,struct,union object p used with . or ->
> > FILE:/tmp/fileg62HaS_cint LINE:1
> >
> > Thank you very much
> >
> > Stefano
>
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:30 MET