RE: [ROOT] aceess to array elements from TObject

From: Elena Vataga (vataga@fnal.gov)
Date: Thu Apr 18 2002 - 16:32:10 MEST


Thank you!

So, when I need to see distributions of second element, I am making:
Draw("MUO.T0[][0]","MUO.nt0>0")
and instead of making plot, it "forget" all tree:

root [2] csx->Draw("MUO.T0[][0]","MUO.nt0>0")
 *** Break *** segmentation violation
Root >
root [3] csx->Print()
Error: Symbol csx is not defined in current scope
FILE:/tmp/fileXYV5Oe_cint LINE:1
Error: Failed to evaluate csx->Print()Possible
candidates are...
filename       line:size busy function type and name
*** Interpreter error recovered ***
root [4]

root [5] .ls
TFile**		JPSI.root	Simple ROOT Ntuple
 TFile*		JPSI.root	Simple ROOT Ntuple
  OBJ: TTree	csx	cmx-csx analysis : 0
  KEY: TList	StreamerInfo;1	Doubly linked list
  KEY: TTree	csx;723	cmx-csx analysis

root [6] csx->Print("Mu*")
Error: Symbol csx is not defined in current scope
FILE:/tmp/file6njLq0_cint LINE:1
Error: Failed to evaluate csx->Print("Mu*")Possible candidates are...
filename       line:size busy function type and name
*** Interpreter error recovered ***

What is all it about?

Elena


On Thu, 18 Apr 2002, Philippe Canal wrote:

> > 1. TBrowser not able to manipulate this arrays any more
> >   ( with older version it was fine)
>
> I will investigate the problem.  You should still be able to use the
> TBrowser when you do NOT load the MakeClass generate file
>
> > tree->Draw("MUO.T0[0]") -> draws all T0 for the first muon, but if I need
> > to compare first and second elements in array?
>
> What you have is a 1 dimension array stored into another 1 dimension array
> (the TClonesArray).  So you can use:
>
> 	tree->Draw("MUO.T0[0][0]-MUO.T0[0][1]");
>
> Cheers,
> Philippe.
>
>
> -----Original Message-----
> From: Elena Vataga [mailto:vataga@fnal.gov]
> Sent: Thursday, April 18, 2002 8:09 AM
> To: Philippe Canal
> Cc: roottalk@pcroot.cern.ch
> Subject: RE: [ROOT] aceess to array elements from TObject
>
>
>
>
> 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
> >
> >
>
>



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