[ROOT] Defining a (fit) function as a method of a class

From: Cristobal Cuenca Almenar (Cristobal.Cuenca@cern.ch)
Date: Thu Nov 06 2003 - 20:28:19 MET


Hi!

I have defined a class (Reconst1_0.C) in which a method (FitTB) fits a set of points to a funtion defined in the another method (pulseshape) of the same class. Unfortunatelly it doesn't work. These are the two methods:


//
Double_t Reconst1_0::pulseshape(Double_t *x, Double_t *par)
//
{
  Double_t newvar=(x[0]-par[1])/par[2];
  Double_t fitval=par[4]+par[0]*(newvar*par[3])*exp(-par[3]*newvar);
  return fitval;
}

//
void Reconst1_0::FitTB(Float_t *samples, Int_t NSMP, Double_t *fitpar, Int_t gain, Int_t iped)
//
{  
   TF1 *f_pulse = new TF1("f_pulse",pulseshape,0.,200.,5);
  f_pulse->SetParameters(fitpar[0],fitpar[1],fitpar[2],fitpar[3],fitpar[4]);
  
  TH1F *h_pulse = new  TH1F("pulse histogram","pulse histogram",9,0.,9.);
  for (Int_t isample=0;isample<9;isample++)
    {
      h_pulse->SetBinContent(isample+1,samples[isample]);
    }
  h_pulse->Fit("f_pulse");
  
  f_pulse->GetParameters(&fitpar[0]);
  cout<<"fitpar "<<fitpar[0]<<fitpar[1]<<fitpar[2]<<fitpar[3]<<fitpar[4]<<endl;
}


this is the error message

/afs/cern.ch/user/c/ccuenca/analysis/roddemo/Reconst1_0.C: In method `void Reconst1_0::FitTB (Float_t*, int, Double_t *, int, int)':
/afs/cern.ch/user/c/ccuenca/analysis/roddemo/Reconst1_0.C:114: no matching function for call to`TF1::TF1 (const char[8], {unknown type}, double, double, int)'
/afs/cern.ch/sw/root/v3.05.05/rh73_gcc296/root/include/TF1.h:79: candidates are: TF1::TF1 ()
/afs/cern.ch/sw/root/v3.05.05/rh73_gcc296/root/include/TF1.h:80:                 TF1::TF1 (const char*, const char *, double = 0, double = 1)
/afs/cern.ch/sw/root/v3.05.05/rh73_gcc296/root/include/TF1.h:81:                 TF1::TF1 (const char*, double, double, int)
/afs/cern.ch/sw/root/v3.05.05/rh73_gcc296/root/include/TF1.h:82:                 TF1::TF1 (const char*, void *, double, double, int)
/afs/cern.ch/sw/root/v3.05.05/rh73_gcc296/root/include/TF1.h:83:                 TF1::TF1 (const char*, Double_t (*) (Double_t *, Double_t *), double = 0, double = 1, int = 0)
/afs/cern.ch/sw/root/v3.05.05/rh73_gcc296/root/include/TF1.h:84:                 TF1::TF1 (const TF1 &)


how could I sort it out?  
                



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:16 MET