Datao,
Are you using the CVS version? Fitting with a function derived from TF1
will work with any version
of ROOT, but the drawing of the function will only work with the CVS
version.
Rene Brun
Datao Gong wrote:
> Rene,
> Yes. It works. I defined a class myFit inherited from TF1.
> class MyFit : public TF1
> {
> ...
> ClassDef(MyFit,1)
> };
>
> ClassImp(MyFit);
>
> In the fitting routine:
> TH1F* th1;
> MyFit* fitfunc = new MyFit("myfit",minX,maxX);
> ...
> th1->Fit(fitfunc,option);
> ...
>
> Then i write the fitted histogram to a root file.
>
> th1->Write();
> ...
>
> The problem is when i use function pointer and TF1, the fitted curve
> appears when i draw the histogram in the root file. When i use MyFit,
> the fitted curve does not show when i re-draw the histogram in the root
> file. The fitted parameter box does show the fitted parameters. Do i
> need to do something to save the curve?
>
> Thanks,
>
> Datao
>
>
> On Mon, 2 Apr 2007, Rene Brun wrote:
>
>> Only static functions are accepted by the fitting functions.
>> In the CVS version an extension of TH1::Fit accepts fits with member
>> functions of classes
>> deriving from TF1 and redefining the function TF1::EvalPar. See an
>> example of use
>> in the attachment.
>>
>> Rene Brun
>>
>> Datao Gong wrote:
>>> hi,Rooters,
>>> I have a question about using TF1. I have to define a user-defined
>>> function to fit histogram. If i define this function as a class member
>>> function, it has to be a static member function. This requirement
>>> bring me some troubles to pass member data to configure this function.
>>> If i do not want to define the member data to be static type,
>>> is there any easy way to pass by this problem?
>>>
>>> Thanks a lot,
>>>
>>> Datao
>>>
>>
>>
Received on Wed Apr 04 2007 - 08:39:36 CEST
This archive was generated by hypermail 2.2.0 : Wed Apr 04 2007 - 11:50:02 CEST