Symbol fitf not defined in current scope (newbie alert)

Hello,
I am trying to fit some data with a user-defined function as described in Chapter 5 of the User’s Guide. (I realize that a user-defined function is not required for the code I have attached, but am trying to start with this simple attempt.) The problem is that my attached (otherwise working) code does not recognize my user-defined fit function at all. I am wondering if there is a library missing in ABCClass.C , for example? Any thoughts would be greatly appreciated.
Regards,
Penny

p.s. (newbie alert :open_mouth: )
ABCClass.C (934 Bytes)
readrootfile.C (2.79 KB)

Hi,

The classic interface TF1 does not support non-static member functions. To use non-static member function you would to use the ROOT::Math::Functor (see for example root.cern.ch/root/html/tutorials … ion.C.html)

Cheers,
Philippe.

Hi Philippe,

Thanks for the reply. To clarify, do you mean that the line:

TF1 *func = new("fit",fitf,-1,2,2);

is not ever valid for user-defined fit-functions called fitf()?

Or, are you saying that the above line is OK if I include
the Math::Functor.h library as in the link to the tutorial
that you sent? I attempted (attached) to include the libraries
shown in the tutorial but did not make any progress.

Regards,
Penny
ABCClass.C (1.06 KB)

[quote]is not ever valid for user-defined fit-functions called fitf()? [/quote]When using a TF1, the function can be user-defined but must be either a free standing function or a static member function.

[quote]Or, are you saying that the above line is OK if I include the Math::Functor.h library [/quote]You need to not only include this header file but also use the Functor calls instead of TF1.

Cheers,
Philippe.

Hi Philippe,
Thanks! I pulled the fit function out of the class and now everything works. :smiley:
Regards,
Penny

Hi,

You can create a TF1 from a class member function, just you need to pass in addition to the member function pointer also the pointer to the class.
See root.cern.ch/root/htmldoc/TF1.html#F5

Lorenzo

Thank you Lorenzo. That is what I would like to do after some more time studying. In the meantime I will have to run with the above ‘work-around’.
Best regards,
Penny