Hi Fred, Your function is ill-defined between 0 and 30. If you activate the print statement in your function, you will get: 20.000000 nan 60.000000 4.943486 100.000000 10.928848 You should protect the function against returning infinite or NaN values. If you change the lower limit of the function from 0 to 20, you will get a correct behaviour. Rene Brun On Fri, 4 Oct 2002, Fred Sarazin wrote: > Dear rooters, > > I'd like to create a function with 7 GIVEN parameters. I don't want to > make a fit, I'd just like to DRAW this function > (and eventually use it to multiply a 1D-histogram). > The actual calculation seems to work, but effit->Draw() doesn't work and > effit->Eval() returns an integer. Is it not the > right way to proceed ? > > thanks, > > Fred > > ----------------------------- > > Double_t func(Double_t *x, Double_t *par) > { > > Double_t E1=100;//100 keV > Double_t E2=1000;//1000 keV = 1 MeV > Double_t XX,YY; > Double_t lowE, highE; > Double_t Dum,Eff; > > XX = TMath::Log(x[0]/E1); > YY = TMath::Log(x[0]/E2); > > lowE = par[0]+par[1]*XX+par[2]*XX*XX; > highE = par[3]+par[4]*YY+par[5]*YY*YY; > > Dum = TMath::Power(lowE,(-par[6]))+TMath::Power(highE,(-par[6])); > Eff = TMath::Exp(TMath::Power(Dum,(-1./par[6]))); > > // printf("%f %f \n",x[0],Eff); > > return Eff; > } > > EffCurve() > { > Double_t A = 2.4356484; > Double_t B = 1.6351060; > Double_t C = 0.0000000; > Double_t D = 2.2948568; > Double_t E = -0.71539408; > Double_t F = -0.032038290; > Double_t G = 5.2433171; > > TF1 *effit = new TF1("func",func,0,4000,7); > effit->SetParameter(0,A); > effit->SetParameter(1,B); > effit->SetParameter(2,C); > effit->SetParameter(3,D); > effit->SetParameter(4,E); > effit->SetParameter(5,F); > effit->SetParameter(6,G); > > TCanvas *c = new TCanvas(); > > effit->Eval(2000.); > effit->Draw(); > } > >
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:12 MET