RE: [ROOT] using user-defined function

From: Philippe Canal (pcanal@fnal.gov)
Date: Thu Feb 20 2003 - 18:28:31 MET


Hi Vladimir,

We are currently working on an upgrade of TTree::Draw where you will be able
to provide a function that will be executed in a context such that 'x'
contains the value from the TTree.  In this function you will be able to use
arbitrary C++.

In other word you will be able to do:

	double drawfunc() {
		return func(x);
      }
	....
     TNtuple *nt = new TNtuple("nt","nt","x:y");
     nt->Fill(10,10); ... etc;

     nt->Draw("drawfunc()");

In the meantime, you have to use the files created by TTree::MakeSelector
(or MakeClass).

Cheers,
Philippe.


-----Original Message-----
From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Vladimir Morozov
Sent: Tuesday, February 18, 2003 10:48 PM
To: roottalk@pcroot.cern.ch
Subject: [ROOT] using user-defined function


Dear All:
Is it possible to define a function in ROOT, say, via
    .L func.C++
where

   float func(float in){
      return smth;
   }

and then use it in drawing ntuples, etc, for instance:

   TNtuple *nt = new TNtuple("nt","nt","x:y");
   nt->Fill(10,10); ... etc;

   nt->Draw("func(x)")

???

I tried this particular way, but it doesn't seem to work.
Is there another way to do it??

Thanks a lot,
Vladimir



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:09 MET