Re: Pointers of branch objects inside a TObjArray

From: Axel Naumann <axel_at_fnal.gov>
Date: Mon, 28 Feb 2005 10:58:19 -0600


Hi Francois-Xavier,
to answer your question: you are probably doing soemthing wrong. Could you send us some code on how you're trying to set the branchs' addresses with your TObjArray? And note the different level of "pointing" (indirection) in a TObjArray (see its doc), which means you'll have to initialize each entry first:
DCCTower *fTow[70]; //All towers
`for(k)` {
  void* pa = &fTow[k];
  fTree->SetBranchAddress(branchname[k].Data(), pa); }

corresponds to

TObjArray* oa=new TObjArray(70);
oa->SetLast(69);
`for(k)` {
  // just initialize to 0, root will create the object for you   oa->At(k) = 0;
  // use the TObjArray::operator returning a TObject*&   void* pa = &(*oa)[k];
  fTree->SetBranchAddress(branchname[k].Data(), pa); }

Axel.

GENTIT Francois-Xavier DAPNIA wrote:
> -->
>
> Hello rooters,
>
> Suppose I have a TTree with N branches containing the same type of
> objects. If I store the pointers to these objects into an array, like:
>
> * DCCTower *fTow[70]; //All towers
>
> and if I give the address of these pointers to TTree::SetBranchAddress()
> by:
>
> * void *pa;
> * pa = &fTow[k];
> * fTree->SetBranchAddress(branchname[k].Data(), pa);
>
> everything goes fine. If now the pointers to the towers are NOT in an
> array, but are in a TObjArray, and if I give to SetBranchAddress the
> address of those pointers in a TObjArray, ROOT crashes at the call to
> TBranch::GetEntry(). I only succeeded in making the pointers reintegrate
> the TObjArray by first getting them into the array fTow, and then
> inserting them into the TObjArray by the method TObjArray::AddAt(). Is
> it a feature or do I do something wrong?
>
> Thanks a lot in advance.
>
> F.X.Gentit
>
> DAPNIA/SPP CEA Saclay
>
> http://gentit.home.cern.ch/gentit/
>
>
>
>
> ------------------------------------------------------------------------
>
Received on Mon Feb 28 2005 - 18:07:36 MET

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:05 MET