Hi Antonio,
Thanks for pointing the typo in the comments.
Instead of using globals to communicate between your application
and your fitting functions, you can use the SetObjectFit/GetObjectFit
functions.
For example in your Double_t func(Double_t*x, Double_t *par) function,
you can access some object via
TObject *myObject = gMinuit->GetObjectFit()
The same if you want to implement your own fitting model in the FCN
function.
You can find an example in TH1::Fit and the default fitting function
H1FitChisquare
Rene Brun
On Wed, 20 Jun 2001, Antonio Kanaan wrote:
>
> Hi All,
>
> I have been using minuit to fit multiple Gaussians. My code is
> becoming more elegant now and I don't want to keep using global
> variables so I dug in TMinuit.cxx and found this at the beggining:
>
> //*-* - The functions SetObjFit(TObject *obj) and GetObjFit() can be *
> //*-* used inside the FCN function to set/get a referenced object *
> //*-* instead of using global variables. *
>
> I have no clue as what to do to actually make use of this. I found
> the definition (?) of this function in G__Minuit.cxx but that only
> made me more confuse. I guess first of all the my object containing
> the data to be fit needs to be transformed to a TObject and then I can
> use SetObjectFit (note there is no SetObjFit - I am saying this not to
> be picky just to point out a little inconsistency between the comment
> and the code) within FCN to have access to my object. However, how do
> I get this object inside FCN? I must confess there is a couple
> arguments in the FCN function whose meaning I never quite understood:
>
> void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
> {
> // computes Chi^2
> // &npar = number os parameters
> // *gin = ???????? , not used here
> // &f = returns the chisq^2 value in this variable
> // *par = the array of parameters
> // iflag = ???????? , not used here
>
> so far I have survived without messing with them... But neither one
> is of type TObject, therefore I gather they are not what I am after.
>
> If anyone has some example code showing the use of SetObjectFit
> (hopefully showing the creation of the TObject as well) I would
> appreciate it.
>
> thanks, have you all a nice day,
>
> Antonio
>
>
> Antônio Kanaan
> Departamento de Física - Universidade Federal de Santa Catarina
> CP 476 -- CEP 88040-900 -- Florianópolis -- SC -- Brasil
> http://www.astro.ufsc.br/~kanaan e-mail: kanaan@astro.ufsc.br
> Phone: 55,48,3319069 FAX : 55,48,3319946
>
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:49 MET