List of (TClonesArray *) in an object added to a TTree

From: Olivier Dormond (Olivier.Dormond@iphe.unil.ch)
Date: Wed Mar 31 1999 - 16:42:28 MEST


Rene Brun wrote:
> 
> Olivier,
> I suggest you build a TList of TClonesArray to be more general.
> You can then loop on the TList to create a branch for each
> TClonesArray.
> There is an example in the ATLFast package.
> 
> Rene Brun

Hi Rooters,

I've try to solve my problems with your indication but without success.
So this time I'll try to be as much clear as I can. Here is what I'm
trying to do:

Program's layout:
- run object containing pointers to the current event, to a TTree and
  some more informations.
- FZReader object used to fill the current event with data from a
  zebra file.
- event object containing all the reconstructed data which is mainly
  the clusters informations. This is implemented, now, by a TList of
  TClonesArray * containing cluster objects.
- cluster objects storing clusters information.

Program's execution sequence:
- A run object is created which create a TTree and an event object.
- The tree is created by issuing a

  fTree->Branch("event", "LVxEvent", &fEvent, 32000, 1);

  in a method of the run object and than a similar method is called
  on the event object which does the following things:

  void LVxEvent::MakeBranch( Text_t *name, Int_t bufsize, Int_t
splitlevel )
  {
    TIter nextR(&fgRClusters), nextPhi(&fgPhiClusters);
    TClonesArray *clusters;
    int i=0;
    Text_t *RName[] = {"R0","R1","R2","R3","R4","R5","R6"};
    Text_t *PhiName[] =
{"Phi0","Phi1","Phi2","Phi3","Phi4","Phi5","Phi6"};

    while( clusters = (TClonesArray *)nextR() )
      gRun->GetTree()->Branch(RName[i++], &clusters, bufsize,
splitlevel);
    i=0;
    while( clusters = (TClonesArray *)nextPhi() )
      gRun->GetTree()->Branch(PhiName[i++], &clusters, bufsize,
splitlevel);
  }

  N.B. I also tried clusters instead of &clusters.

- A loop is done on the fz file in which the next event is read. The
  cluster maker is than run and a short display of the resulting data
  is printed out. Next the tree is filled (by fTree->Fill();) and at
  last the event is cleared.

The program segfault next to the call to the Fill() method. dbx says:

Segmentation fault in ptrgl.$PTRGL
[/afs/cern.ch/na49/library.4/ROOT/pro/rs_aix41/root/lib/libRoot.a] at
0xd12e3868 ($t1)
0xd12e3868 ($PTRGL)    800b0000        lwz   r0,0x0(r11)
(dbx) where
ptrgl.$PTRGL() at 0xd12e3868
Fill__13TBranchClonesFv() at 0xd160ad8c
Fill__5TTreeFv() at 0xd1401064
FillTree()(0x204edbd8), line 106 in "LVxRun.cxx"
unnamed block $b2, line 124 in "LVxMain.cxx"
main(argc = 3, argv = 0x2ff21f48), line 124 in "LVxMain.cxx"

I don't see what's wrong in my code. The TTree::Branch(..) method
documentation says:

 "clonesaddress is the address of a pointer to a TClonesArray."

That the case of &clusters but as it's the same for all the branch
and it becomes invalid on exit of LVxEvent::MakeBranch(..) I've thought
this might be the cause of my trouble.

All ideas/comments are welcome!

Cheers,


		Odie
-- 
+----------------------------------------------------------------------+
| Olivier Dormond                 EMail : Olivier.Dormond@iphe.unil.ch |
| IPHE - BSP - UNIL               WWW   : iphedec2.unil.ch/~odie       |
| CH-1015 Dorigny                 Phone : (++41 21) 692 3739           |
| Switzerland                     Fax   : (++41 21) 692 3605           |
+----------------------------------------------------------------------+



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:31 MET