RE: [ROOT] aceess to array elements from TObject

From: Reinhardt Chamonal (chamonal@ph.ed.ac.uk)
Date: Thu Apr 18 2002 - 19:14:33 MEST


Hi,
Here is an example:

 tree->Draw("MUO.T0[0]:MU0,TO[2]");

It plots MUO.T0[0] vs MU0,TO[2] 
(or the otherway round ;)



On Thu, 18 Apr 2002, Elena Vataga wrote:

> 
> 
> Hello!
> 
> Thanks a lot for your reply!
> 
> I took CVS version and MakeClass produced correct code:
> 
>    Int_t           MUO_nt0[kMaxMUO];   //[MUO_]
>    Int_t           MUO_nt1[kMaxMUO];   //[MUO_]
>    Int_t          *MUO_mT0[kMaxMUO];   //[MUO_nt0]
>    Int_t          *MUO_mT1[kMaxMUO];   //[MUO_nt1]
>    Int_t          *MUO_C0[kMaxMUO];   //[MUO_nt0]
>    Int_t          *MUO_C1[kMaxMUO];   //[MUO_nt1]
>    Float_t        *MUO_T0[kMaxMUO];   //[MUO_nt0]
>    Float_t        *MUO_T1[kMaxMUO];   //[MUO_nt1]
> 
> But:
> 
> 1. TBrowser not able to manipulate this arrays any more
>   ( with older version it was fine)
> 
> 2. I still do not understand how to access array elements in tree->Draw:
> 
> *Br   76 :MUO.T0    : T0[MUO_]                                               *
> *Entries :     6971 : Total  Size=      49626 bytes  File Size  =      18920 *
> *Baskets :        1 : Basket Size=      64000 bytes  Compression=   2.62     *
> *............................................................................*
> 
> tree->Draw("MUO.T0[0]") -> draws all T0 for the first muon, but if I need
> to compare first and second elements in array?
> 
> 
> 	Will be grateful for your reply,
> 				regards,
> 					Elena
> 
> 
> On Wed, 17 Apr 2002, Philippe Canal wrote:
> 
> > Hi,
> >
> > ( In our usual pre-planning :) ), this has been fixed 5 days ago
> > and the fix is available in the head of the CVS repository.
> >
> > The problem was that MakeClass was not creating the correct code
> > in the case of a TClonesArray containing object of a class that has
> > variable size array.  As you pointed out it should have had a '*' in
> > the date member definition.  However this is not sufficient since the
> > reading part also needed to be fixed.
> >
> > Cheers,
> > Philippe.
> >
> > -----Original Message-----
> > From: owner-roottalk@pcroot.cern.ch
> > [mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Elena Vataga
> > Sent: Wednesday, April 17, 2002 7:23 AM
> > To: Rene Brun
> > Cc: roottalk@pcroot.cern.ch
> > Subject: [ROOT] aceess to array elements from TObject
> >
> >
> >
> >
> > 	Hello rooters!
> >
> >
> > I used the following arrays in my TObject:
> >
> > class TCMXmuon: public TObject {
> >
> > protected:
> > //---------------------------------------------------------------
> > //  data members
> > //---------------------------------------------------------------
> >   TLorentzVector  lvec;
> >
> >   Int_t           DetCode;     // (1)CMU (2)CMP (3)CMU+CMP (4)CMX (5)BMU
> > ....
> >
> >   Int_t           nt0;          // number of  inner times
> >
> >   Int_t*          mT0;          //[nt0]  Mean Time in inner layer
> >   Int_t*          C0;           //[nt0]  Counter in inner layer
> >   Float_t*        T0;           //[nt0]   Time in inner layer
> >
> > ...
> >   Int_t           nt1;          // number of  outer times
> >   Float_t*        T1;           //[nt1]   Time in outer layer
> >
> >
> > My question is: how can I access first, second etc member of
> > my array variables (T0[0], T0[1] etc) inside root - they look like flat
> > numbers and not array?
> >
> > *............................................................................*
> > *Br   70 :MUO.nt0   : nt0[MUO_]                                              *
> > *Entries :     4971 : Total  Size=      47305 bytes  File Size  =      12009 *
> > *Baskets :        1 : Basket Size=      64000 bytes  Compression=   3.94     *
> > *............................................................................*
> > *Br   71 :MUO.nt1   : nt1[MUO_]                                              *
> > *Entries :     4971 : Total  Size=      47305 bytes  File Size  =      11753 *
> > *Baskets :        1 : Basket Size=      64000 bytes  Compression=   4.02     *
> > *............................................................................*
> > *Br   72 :MUO.mT0   : mT0[MUO_]                                              *
> > *Entries :     4971 : Total  Size=      49127 bytes  File Size  =      13721 *
> > *Baskets :        1 : Basket Size=      64000 bytes  Compression=   3.58     *
> > *............................................................................*
> > *Br   73 :MUO.mT1   : mT1[MUO_]                                              *
> > *Entries :     4971 : Total  Size=      48567 bytes  File Size  =      13918 *
> > *Baskets :        1 : Basket Size=      64000 bytes  Compression=   3.49     *
> > *............................................................................*
> > *Br   74 :MUO.C0    : C0[MUO_]                                               *
> > *Entries :     4971 : Total  Size=      49126 bytes  File Size  =      18567 *
> > *Baskets :        1 : Basket Size=      64000 bytes  Compression=   2.65     *
> > *............................................................................*
> >
> >
> >
> > I tried to MakeClass from my tree and I am getting in the header:
> >    Int_t           MUO_nt0[kMaxMUO];   //[MUO_]
> >    Int_t           MUO_nt1[kMaxMUO];   //[MUO_]
> >    Int_t           MUO_mT0[kMaxMUO];   //[MUO_]
> >    Int_t           MUO_mT1[kMaxMUO];   //[MUO_]
> >    Int_t           MUO_C0[kMaxMUO];   //[MUO_]
> >    Int_t           MUO_C1[kMaxMUO];   //[MUO_]
> >    Float_t         MUO_T0[kMaxMUO];   //[MUO_]
> >    Float_t         MUO_T1[kMaxMUO];   //[MUO_]
> >
> > so it is not an array?
> >
> >
> > 	Will be most grateful for any advice,
> > 					regards,
> > 						Elena
> >
> >
> 

-- 
------------------------------------------------------------
 Reinhardt CHAMONAL            The University of Edinburgh  
                               Dept. of Physics & Astronomy 
 email: chamonal@ph.ed.ac.uk   King's Buildings, JCMB, 5301 
                               Mayfield Road                
 phone: +44-131-650 5307       Edinburgh, EH9 3JZ           
 
 web: http://www.ph.ed.ac.uk/~chamonal/
      http://www.reuh.fr.st
------------------------------------------------------------



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