Hi, A TF1 can only use free standing function (it would not know which object to call a member function on). Before 3.05/06 you needed to declare a free standing function with the exact signature described in the TF1 documentation. With 3.05/06 you can access any free standing function or static data member functions, using a syntax like: TF1 *fitFcn = new TF1("fitFcn","func_fit::func_val(x,y,[0])",-600.,-1.,fclass.get_nparam()); with func_val being 'static double func_fit::func_val(double arg1, double arg2, double param)' Cheers, Philippe -----Original Message----- From: owner-roottalk@pcroot.cern.ch [mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Dr. John Krane Sent: Tuesday, July 22, 2003 9:06 AM To: roottalk@pcroot.cern.ch Subject: [ROOT] fitting with a member function Hi, I'm trying to use weighted histograms to fit a distribution. Because I want to be able to change the histos that I'm using as components, I made a little class that holds an array of TH1F. A member function provides the weighted sum of these histograms, with the weights being the fit parameters and the interface being as required by TF1. So I tried to make a TF1 for use with the ->Fit method, like this: cerr<< "Assign the histos that contribute to fit"<<endl; func_fit fclass; fclass.add_param(d1or); //first histo fclass.add_param(d1crl); //second histo...etc. TF1 *fitFcn = new TF1("fitFcn",fclass.func_val,-600.,-1.,fclass.get_nparam()); Well the compiler within ROOT doesn't like that, so I tried making a pointer-to-member-function and giving that to root, but I didn't get anywhere. Does anybody know how to provide a member-function to TF1? I think my class solution is quite clean for what I'd like to do, but I need to get around this barrier... - John
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:13 MET