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
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)
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.
[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.
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
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