Hi Marco, There are two reasons why TF1 are Tnamed objects. 1- I/O. It is convenient if one wants to archive via func->Write or ListofFunctions->Write(). A key is automatically generated. 2- It is the best way to access predefined simple functions ("gaus", etc). one does not need to get a pointer to these basic functions before fitting. a TF1::Fit (TF1 *func) could also be added. Coming back to your example, the syntax should be: func(1) = new TF1("func","sin([0]*x)+[1]"); MyHist.Fit("func"); Forget the time to get the pointer from the name. Names are in a hash table. The access is totally negligible compared to the fit. Rene Brun Marco van Leeuwen wrote: > > Hi all, > > Does anyone know why there is no TH1F::Fit(TF1& func) method. Now you have > to name your formula/funtion and use that name at fitting time. This is > inconvenient when you do a lot of fits and you want to keeptrack of the > different fits. I was thinking of having a TObjArray with fitfunctions. > But now I don't know how to fit them: > > e.g. > TObjArray funcs(10); > func(1) = new TF1("sin([0])+[1]"); > MyHist.Fit( ???? ); > > I foresee two possible solutions: > 1) using a naming scheme for the functions in the array and keeping track > of those. > 2) using something like: > MyHist.Fit(func(1).GetName()); > > However, it seems superfluous to have an extra name (this also implies a > look-up method which is used during run-time), why can't I use the > object directly? > > Regards, > > Marco van Leeuwen
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:38 MET