RE: [ROOT] TTree::Draw with objects

From: Philippe Canal (pcanal@popgtw.fnal.gov)
Date: Thu Aug 03 2000 - 16:56:02 MEST


Hi,

Currently the draw function is limited to one level of method calls.  
This means that in you case as you mentioned you can to 

   T->Draw("vec2.GetT()") 

but can not do:

  T->Draw("vec2.GetV().Mod()")

> It seems to me that if I want to use TTree::Draw I need to write a lot of
> "get" functions that return directly what I want
> Am I wrong?

  You are correct.  But this is consistent with typical oriented object 
programming.  If you choose to not split you classes, you also select to
keep your internal data member private and thus you probably do want to
force the access via the accessor functions.  If you want/need to give
access to the data member without going through accessor functions you 
can also elect to split you objects in the tree.
[Alternatively it will possible (but probably not desirable) to upgrade
the code to allow access to variable in the case of non-split branches]

Philippe



> -----Original Message-----
> From: owner-roottalk@pcroot.cern.ch
> [mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Angela Biselli
> Sent: Wednesday, August 02, 2000 1:55 PM
> To: roottalk@pcroot.cern.ch
> Subject: [ROOT] TTree::Draw with objects
> 
> 
> Dear Rooters,
> I created a class V4 that contain another clas V3 
> 
> class V4 : public TObject {
> ...
>   double GetT() {return tt}
>   V3 GetV() {return vv}
>  private:
>   V3 vv;  
>   Double_t tt;
>   ClassDef(V4,1)
> };
> 
> Then a created a tree with a single branch 
> tree->Branch("vec2","V4",&vec2,bsize,0);
> If I try to use T->Draw I can plot member functions that return directly a
> Double_t 
> T->Draw("vec2.GetT()") 
> 
> but if I try to plot the modulus of the 3 vector(V3::Mod())
> T->Draw("vec2.GetV().Mod()")
> the histogram has the right number of entries but the values are always
> zero
> 
> Also if I have a public member "var" and I try to do
> T->Draw("vec2.var")
> I get
> Error in <TLeafObject::GetMethodCall>: Unknown method:var
> 
> *ERROR 26 : 
>  Unknown name : "vec2.var"
> 
> 
> It seems to me that if I want to use TTree::Draw I need to write a lot of
> "get" functions that return directly what I want
> Am I wrong?
> 
> Angela
> 
> -- 
> Angela Biselli             homepage : http://ignatz.phys.rpi.edu/~biselli
> Graduate Student           e-mail:biselli@angel.phys.rpi.edu
> Office TEL.518-276-2050 
> 
> 
> 
> 



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:30 MET