[ROOT] function compiling

From: Pietro Govoni (Pietro.Govoni@cern.ch)
Date: Mon Aug 12 2002 - 12:30:41 MEST


Dear rooters,
I am creating some TF1 functions with a very simple macro; I cannot get
why one of them does not compile when I run the macro, while if I try to
create and plot it with on line commands I don't get any problem:

this is the error message:
--------------------------

>root functions.C
  *******************************************
  *                                         *
  *        W E L C O M E  to  R O O T       *
  *                                         *
  *   Version   3.03/07      18 July 2002   *
  *                                         *
  *  You are welcome to visit our Web site  *
  *          http://root.cern.ch            *
  *                                         *
  *******************************************

Compiled for linux with thread support.

CINT/ROOT C/C++ Interpreter version 5.15.50, July 7 2002
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] 
Processing functions.C...
Function:sigma_hyp cannot be compiled



this is the code:
-----------------

Double_t theta(Double_t *x, Double_t *par)
  {
    if (x[0] > par[0]) return 1;
    else return 0;
  }

void functions()
{

  Double_t min = -10.;  // minimum of the formulas range
  Double_t max = +10.;  // maximum of the formulas range
  Double_t thres = 0.;  // coordinate of the formula half value point

  // the theta (step) function

  TF1 *step = new TF1("step",theta,min,max,1);
  step->SetParameter(0,thres);
  step->SetParNames("Threshold");

 // the sigma function with the hyperbolic tangent

  TF1 *sigma_hyp = new TF1("sigma_hyp","tanh(x-[0])",min,max,1);
  sigma_hyp->SetParameter(0,thres);
  sigma_hyp->SetParNames("Threshold");


  // the sigma function with the exponential

  TF1 *sigma_exp = new TF1("sigma_exp","1/(exp(-1*x-1+[0])+1)",min,max);
  sigma_exp->SetParameter(0,thres);
  sigma_exp->SetParNames("Threshold");

  // graphics
  
  TCanvas *c1= new TCanvas("c1","functions",10,10,400,400);
  c1->Divide(2,2);
  c1->cd(1);
  step->Draw(); 
  c1->cd(2);
  sigma_hyp->Draw(); 
  c1->cd(3);
  sigma_exp->Draw(); 
}


Do anybody have an explanation for this behaviour?
Thanks in advance, regards

pietro



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