[ROOT] Using a user defined function from the command line

From: Stilianos Kesisoglou (kesisogl@fnal.gov)
Date: Mon Jun 09 2003 - 03:14:13 MEST


Hi,

    Is it possible to use a user defined function from the command line on ROOT
when drawing a histogram?

    For example I have the function:

#include <cmath>

float angl(float y, float phi)
{
    const float pi = 3.141592654;

    float angle;
        
    if (y==0.0) {
        angle = pi;
    } else if (y>0.0) {
        angle = phi;
    } else {
        angle = phi-2*pi;
    }
    
    return angle;

}

and I load it to ROOT:

root[] .L angl.C

    I can use it from the command line if I want to:

root[] angl(0.5,0.58)

with no problem, but what about when I plot a histogram?

root[] myTree->Draw("angl(y,phi)")

(where "y" and "phi" are variables of the tree "myTree")

    I try to do it and ROOT complains. I would like to do it exactly as
if that function was let's say "atan2"

    Any suggestions?

    Thanks!

Stelios.



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