Fitting a histogramm using another one - Problems with TF1

Hi, rooters,
I use a histogramm depending on my parameters to fit my data. In principle, something like Double_t GetHistValue(Double_t *x, Double_t *par)
{
makeMyHisto(par);
return myHisto->GetBinContent(x[0]);
}
works to make a TF1-function TF1 *fun=new TF1(“fun”, GetHistValue,…) , but as above code would recalculate the histogramm everytime the function is evaluated, it’s unusable for fitting. As I didn’t want to use to much global or static variables, I wrote a class MyFit containing all my Histogramms, with a function

Double_t MyFit::GetHistoBin(Double_t *x, Double_t *parameter)

which looks for changes, and returns the HistoBin x[0];

and a function

TF1 *MyFit::GetFunction(void)
{
TF1 *fitfun=new TF1(“fitfun”,GetHistoBin,0.,(double)SPEKLEN/2.,PAR_NUM);
return fitfun;
}

which should return the fitfunction.
But if I try to compile my code, I get the error message:

g++ -c -Wall -O3 -I./ -I/home/perkeo/root/include/ fitfun.cpp
fitfun.cpp: In member function Double_t MyFit::GetHistoBin(Double_t*, Double_t*)': fitfun.cpp:226: warning: passingdouble’ for argument 1 of virtual Stat_t TH1F::GetBinContent(int) const' fitfun.cpp: In member functionTF1* MyFit::GetFunction()’:
fitfun.cpp:264: error: no matching function for call to `TF1::TF1(const
char[7], , double,double, int)’
/home/perkeo/root/include/TF1.h:86: error: candidates are: TF1::TF1(const TF1&)
/home/perkeo/root/include/TF1.h:85: error: TF1::TF1(const
char*, Double_t ()(Double_t, Double_t*), double = 0, double = 1, int = 0)
/home/perkeo/root/include/TF1.h:84: error: TF1::TF1(const
char*, void*, double, double, int)
/home/perkeo/root/include/TF1.h:83: error: TF1::TF1(const
char*, double, double, int)
/home/perkeo/root/include/TF1.h:82: error: TF1::TF1(const
char*, const char*, double = 0, double = 1)
/home/perkeo/root/include/TF1.h:81: error: TF1::TF1()
make: *** [fitfun.o] Fehler 1

So I’m completely in the dark: why doesn’t he recognize the type? I attached the whole file and would be grateful, if someone could help.

I use Suse8.2, root4.00/08
pspekfit.cpp (3.98 KB)
fitfun.h (1.74 KB)
fitfun.cpp (8.55 KB)

see :http://root.cern.ch/root/htmldoc/TF1.html

and look at:
WHY TF1 CANNOT ACCEPT A CLASS MEMBER FUNCTION ?

Rene

Thanks, I didn’t see this. I solved my problem using static variables, and now it works fine!