Hi, The TF1 class actually has 6 different constructor. In particular it has those 4 constructors. TF1 TF1(const char* name, const char* formula, Double_t xmin = 0, Double_t xmax = 1) TF1 TF1(const char* name, Double_t xmin, Double_t xmax, Int_t npar) TF1 TF1(const char* name, void* fcn, Double_t xmin, Double_t xmax, Int_t npar) TF1 TF1(const char* name, Double_t (*)(Double_t*, Double_t*) fcn, Double_t xmin = 0, Double_t xmax = 1, Int_t npar = 0) If you ran your script in interpreted mode, your first statement uses the 3rd constructor. While your 2nd statement uses the 1st constructor. Those 2 constructor have very different meaning (in your case, you do mean to use the 3rd constructor). The 1st constructor is only used to build up formula on top of the built-in functions and can never call a function defined by the user using C++. 'gauss' is one of the built-in functions. For more details please read carefully the User's Guide and/or the class description for TFormula and TF1: http://root.cern.ch/root/html/TFormula.html#TFormula:description http://root.cern.ch/root/html/TF1.html#TF1:description Cheers, Philippe. -----Original Message----- From: owner-roottalk@pcroot.cern.ch [mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of kmakonyi@nist.gov Sent: Wednesday, July 24, 2002 8:06 PM To: roottalk@pcroot.cern.ch Subject: [ROOT] TF1 peoblem (?) Dear ROOTrs, According to the documentation the TF1 has constructor like this: TF1 TF1(const char* name, const char* formula, Double_t xmin = 0, Double_t xmax = 1) I made a little program: ----------------------------------------------------------------- Double_t Voigt(Double_t* x, Double_t* par){ Double_t arg = 0; if(par[2]) arg = (x[0] - par[1]) / par[2]; Double_t Gaus = TMath::Exp( -0.5 * arg * arg ); Double_t Lorentz = 1 / ( 1 + arg * arg ); return par[0] * ( par[3] * Gaus + ( 1- par[3] ) * Lorentz ); } main(){ TF1* f1 = new TF1("f1", Voigt, 100, 200, 4); TF1* f2 = new TF1("f2", "Voigt", 100, 200, 4); } --------------------------------------------------------- Run it with CINT I get an error: "Function:f2 cannot be compiled" Why cannot be compiled the "f2", and why can be the "f1"? In the header the dclaration said, that the "formula" have to be "const char*". In the "f2" the formula is "const char*", but the in the "f1" it is not! (?) In the tutorial the "multifit" can use the "gaus" function like this, but is doesn't work with my funcion. I would have to use the "TF1" that the "formula" comes from an TString. ROOT 3.03/03, CINT5.15.35, win2k Thanks, Karoly
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:01 MET