Re: using class methods in treeViewer/Draw()

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Tue, 21 Aug 2007 14:46:36 +0200


Christian,

Of course you must load the shared lib with the code that you want to execute.
TH1 code is automatically loaded by ROOT autoloader because the class is known to the system.
In your case you can run the following session:

{

   gSystem->Load("libEvent");
   TFile f("Event.root");
   TTree *T = (TTree*)f.Get("T");
   //display the Pt of all tracks
   T->Draw("fTracks.GetPt()");
   //display Pt of last track
   T->Draw("fLastTrack.GetPt()");
}

Rene Brun

Christian Hoeppner wrote:
> Hi,
>
> yes that works with the fH member of Event. But in the fTracks
> TClonesArray it doesnt work. There I cant plot e.g. Track::GetPt() which
> calculates a return value out of member variables. This is exactly what
> I want though. Is this possible?
> Or to ask in another way, why does it work with a TH1D and not with a
> TObject derived Track class?
>
> Cheers, Christian
>
> On Tue, 2007-08-21 at 10:13 +0200, Rene Brun wrote:
>
>> Hi Christian,
>>
>> As an example run $ROOTSYS/test/Event with
>> Event 500 1 99 1
>> then run the following session
>> root [0] TFile f("Event.root")
>> root [1] T.Draw("fH.GetMean():fH.GetRMS()")
>> You can also call a member function from TBrowser
>> -click on "ROOT Files" ->Event.root -> T -> event -> fH
>>
>> Rene Brun
>>
>> hoeppner_at_e18.physik.tu-muenchen.de wrote:
>>
>>> Sorry that Ididnt completely get it, but in Rene's answer, what exactly is
>>> "obj" supposed to be. I tries the Branch name, the Class name, ...
>>>
>>> Cheers, Christian
>>>
>>>
>>>
>>>
>>>> With TTree::Draw you can do
>>>> T.Draw("obj.Function(params,..)" (see doc)
>>>>
>>>> same with TBrowser.
>>>> A future version of TTreeViewer will also provide this functionality.
>>>>
>>>> Rene Brun
>>>>
>>>> Christian Hoeppner wrote:
>>>>
>>>>
>>>>> Hi everybody,
>>>>>
>>>>> I have a question: Is it possible to directly plot or cut on a return
>>>>> value of a method instead of a member variable. E.g.: I have a class
>>>>> event : public TObject, that I write to my tree, that has a method with
>>>>> the prototype
>>>>>
>>>>> double getMinResid();
>>>>>
>>>>> I want to plot some histogram out of the tree viewer or with Draw() and
>>>>> want to cut on this for example. Is this possible and if yes how. Of
>>>>> course if it is not possible I could just save the output of the method
>>>>> in the event as well.
>>>>>
>>>>> Thanks a bunch, Christian
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
Received on Tue Aug 21 2007 - 14:46:42 CEST

This archive was generated by hypermail 2.2.0 : Wed Aug 22 2007 - 17:50:02 CEST