When you want to pass the pointer to an object that is in a ROOT
collection, use the GetObjectRef function of the collection.
See an example in TTree::Branch(TCollection *list,
http://root.cern.ch/root/htmldoc/src/TTree.cxx.html#TTree:Branch
Rene Brun
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 - 17:57:22 MET
This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:05 MET