Dear Lorenzo
Thank you! That is a great example. (I almost had it right, I only had to change my ROOT::Math::Functor call following your example, and then my class worked as desired.)
yours, Steve
On May 17, 2011, at 10:21 AM, Lorenzo Moneta wrote:
> Hi Steve,
>
> If you want to use a member function of a class for defining your objective function (i.e. the chi2 function), you can do it by using the ROOT::Math::Minimizer and ROOT::Math::Functor class.
> If you want to use the interpreter you need to call a special constructor of the ROOT::Math::Functor class.
> I attach below a modified version of the tutorial, NumericalMinimization.C, which works for a class member function
>
> Best Regards
>
> Lorenzo
>
> <NumericalMinimization.C>
>
> On May 16, 2011, at 9:09 PM, Stephen Pate wrote:
>
>> Dear Rooters >> >> I want to create a class, with the following characteristics: >> >> (1) reads in private data at the time the class object is instantiated >> (2) has a member function that will calculate a chi-squared comparing that data to a model >> (3) has another member function that will perform a fit using the member chi-squared function, calling on minuit/migrad to do so >> >> I would like to use the interpreter, not compiled code, at least in the beginning while I am developing my process. >> >> (1) and (2) are standard things to do, but in trying to do (3) I run into the problem that the address of the member chi-squared function cannot be passed to the "SetFCN" or "SetFunction" call because it "is not defined in current scope". I can call from one member function to another, no problem, but I can't pass the address of the member chi-squared function to the fitter interface. >> >> All of the code works as long as I don't try to wrap it all into a class; it is only when placed inside a class that the call to "SetFCN" or "SetFunction" does not work. >> >> There are many fitting interfaces in ROOT. I have tried to do this using TVirtualFitter; I also tried a combination of ROOT::Math::Minimizer, ROOT::Math::Factory, and ROOT::Math::Functor; both methods were successful until placed inside a class. It occurs to me that I have simply not tried the right interface yet, or that I need to do something additional to be able to get the address of the member function. I hope someone can help me to do this. >> >> I am using ROOT 5.28/00c on a MacBook Pro 10.6.7, i.e. everything is up-to-date. >> >> thanks, >> Steve Pate >>
()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
Stephen Pate Department of Physics office: 575-646-2135 New Mexico State University dept: 575-646-3831 pate_at_nmsu.edu Las Cruces NM 88003 fax: 575-646-1934 skype: sfpate skype: 575-680-1261Received on Tue May 17 2011 - 13:02:38 CEST
This archive was generated by hypermail 2.2.0 : Tue May 17 2011 - 17:50:01 CEST