Hi John,
It could be that you use the wrong path to the Root documentation.
The class TF1 is described at:
http://root.cern.ch/root/htmldoc/TF1.html
The paragraph that I quoted is at the end of the introduction after
the example.
Rene Brun
"Dr. John Krane" wrote:
>
> Thanks Rene,
>
> I have been looking at http://root.cern.ch/root/html/TH1.htm and didn't
> see this very clear discussion. Sorry: I always feel silly when I miss
> a well-documented fact. I will try the full-blown TVirtualFitter method
> that I was hoping to avoid.
>
> (What should I have typed into the "search the root reference guide"
> window to find the TF1 doc you mentioned? Your excerpt is actually not
> in the TH1.htm page that I have been using as a reference, nor in the
> "fitting with a user-defined function" etc. pages in the ref guide. I
> also didn't see it in the User's Guide 3.02c. A new source of
> documentation is always welcome...what is the origin of that excerpt?)
>
> - John
>
> Rene Brun wrote:
> > Hi John,
> >
> > The TF1 doc has this remark:
> >
> > //
> > // WHY TF1 CANNOT ACCEPT A CLASS MEMBER FUNCTION ?
> > // ===============================================
> > // This is a frequently asked question.
> > // C++ is a strongly typed language. There is no way for TF1 (without
> > // recompiling this class) to know about all possible user defined data types.
> > // This also apply to the case of a static class function.
> >
> >
> > In the C-style function referenced by TF1 and called from TH1::Fit,
> > you can call your class member function.
> > You can either use a global to access an object of your class
> > or use TVirtualFitter::SetUserFunc to register the address of a TObject*
> > to the fitter. In the C-style function, you can retrieve this pointer
> > with something like:
> > TObject *myobject = TVirtualfitter::GetFitter()->GetUserFunc();
> >
> > Rene Brun
> >
> >
> > "Dr. John Krane" wrote:
> >
> >>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