[ROOT] TRef

From: Davide Grandi (Davide.Grandi@cern.ch)
Date: Fri Nov 22 2002 - 14:43:44 MET


Hi rooters,
	I have a problem with TRef and TRefArrays. 
I'm using root version 3.03.09 
on a Linux machine, Intel 2.0 Ghz double processor

I'm reading events written with in a tree with branches that
are TClonesArray and include TRef, TRefArrays, with
TRef pointing from one branch as for example fParticle

TClonesArray* fParticle           offset=  0 type=64           

to another as for example fTrack

TClonesArray* fTrack       	  offset=  0 type=64                     

so that in class Paricle there is

StreamerInfo for class: Particle, version=1
  BASE          TObject         offset=  0 type=66 Basic ROOT object   
  int           Particle        offset=  0 type= 3         
  TRef          fTrack          offset=  0 type=61 pointer to track; 
....
..
.
..
.

StreamerInfo for class: Track, version=1
  BASE          TObject         offset=  0 type=66 Basic ROOT object   
  int           Status          offset=  0 type= 3                     
  int           Pattern         offset=  0 type= 3                     
  int           Address         offset=  0 type= 3       
...
..
..

suppose that in my selection code I want to use the reference TRef fTrack
to the object (class) Track, can I get it without loading the respective
branch b_Track? I mean in this example(1) of the code



example(1):
-----------------------------------------------------------------------

 b_Particle->GetEntry(entry);
    
    if(Particle->GetSize()>0){ 
     pobj=Particle->At(0);
     Particle* p_ok=dynamic_cast<Particle*>(pobj);
     
     if(p_ok){
         cout << p_ok->fTrack.GetObject() << endl;
       }
     }

----------------------------------------------------------------------
I got (nil) pointers while in this example(2) of code

example(2)

---------------------------------------------------------------------
    b_Particle->GetEntry(entry);
        
    if(Particle->GetSize()>0){
       pobj=Particle->At(0);
       Particle* p_ok=dynamic_cast<Particle*>(pobj);

       if(p_ok){
         b_Track->GetEntry(entry);
         cout << p_ok->fTrack.GetObject() << endl;
       }
     }
---------------------------------------------------------------------
I got the pointers..

is it possible to do it (get the pointers) without loading the branch
b_Track (or better loading the branch only when is needed to access the
data, in the relative if cycle)?
I hope this is not a stupid question.... 

Thanks

Davide

**********************************************************************
$      Davide  Grandi					             % 
$      INFN Milano		e-mail	Davide.Grandi@mib.infn.it    %   
$      P.zza delle Scienze 3    phone	+39 02 6448 2306             % 
$      20126 MILANO		fax	+39 02 6448 2367	     %
$      ITALY		                                 	     %  
$       						 	     % 
$      at CERN			e-mail	Davide.Grandi@cern.ch	     % 
$      CH-1211 Geneve CH        phone	+41 22 767 9403		     % 
$                               Bldg.   506 room R018                %
$               or              phone   +41 22 767 7560              %  
$                               Bldg.   576 room R002                %
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:20 MET