Re: [ROOT] TClonesArray in trees

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Jul 21 2000 - 09:26:47 MEST


Stefano,
I cannot do much with this bit of information. You should send the piece
of code reading your Tree. Did you look at the example in
$ROOTSYS/test/MainEvent, Event ? We give an example with a TClonesArray.
 I also notice that you do not create your TClonesArray correctly.
You must specify the type of class that it should contain as argument.

Please reply to me, not to the list.

Rene Brun

Stefano Argiro' wrote:
> 
> 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