Re: [ROOT] Questions on TMinuit::SetFCN

From: Edmond Offermann (edmondoffermann@yahoo.com)
Date: Fri Aug 29 2003 - 00:46:08 MEST


Hi Yiqun,

You should use it in your objective function fcn:

For instance:

void FitChisquare(Int_t &nrPar,Double_t *grad,Double_t
&chiSquare,
                         Double_t *par,Int_t flag)
{
// Minimization function using a Chisquare method

const MyClass *fit = (MyClass *)
gMinuit->GetObjectFit();
const Int_t nrPoints = fit->GetN();
const Int_t nrVar    = fit->GetNrVar();
const Double_t *x   = (fit->GetX()).GetArray();
const Double_t *y   = (fit->GetY()).GetArray();
const Double_t *ey  = (fit->GetEY()).GetArray();
.
.
.

with 

class MyClass : public TObject
{
protected:
  Int_t    fNrPoints;    //#total data point
  TArrayD  fX;
  TArrayD  fY;
  TArrayD  fEY;
.
.
};

Eddy

--- Yiqun Wang <yqwang@rcf.rhic.bnl.gov> wrote:
> Edmont:
> 
> Thanks for your reply! However, my problem is not
> with TMinuit. I should
> explained more clearly. The problem is the function
> "fcn(Int_t &npar,
> Double_t *gin, Double_t &f, Double_t *par, Int_t
> iflag)". How can it get
> the  data points? It has no knowledge of any
> objects. In "Ifit.C", global
> variables were used. My question is, is there any
> other way?
> 
> Yiqun Wang
> 
> > Hi Yiqun,
> >
> > Have a look at TMinuit::SetObjectFit and
> > TMinuit::GetObjectFit with which you can set and
> > retrieve apointer to a class that inherits from
> > TObject. In this class you could define data
> > points and other fit information.
> >
> > Eddy
> >
> > --- Yiqun Wang <yqwang@rcf.rhic.bnl.gov> wrote:
> >> Hi, ROOTers:
> >>
> >> I have a question on using TMinuit. I read the
> >> tutorial "Ifit.C", but it
> >> did not answer my question. I am using ROOT
> 3.10.00
> >> self-compiled on
> >> Mandrake 9.1.
> >>
> >> In "Ifit.C", the data points "Float_t
> >> z[5],x[5],y[5],errorz[5];" are
> >> global variables. This is understandable, since
> >> "void fcn(Int_t &npar,
> >> Double_t *gin, Double_t &f, Double_t *par, Int_t
> >> iflag)" has not idea what
> >> data points to use beforehand. However, this is
> >> ugly, not particularly
> >> safe.
> >>
> >> Now suppose I want to make a custom fitter for my
> >> own class. Data points
> >> will come from the members of the class (actually
> I
> >> will reload the data
> >> members every event, use the fitter, and write
> fit
> >> result to a tree). Can
> >> I call "TMinuit::SetFCN(...)" on a memeber
> function
> >> "void fcn(Int_t &npar,
> >> Double_t *gin, Double_t &f, Double_t *par, Int_t
> >> iflag)" (so it knows the
> >> member data, without the need to make the data
> >> global)? Is this possible?
> >> Or there is a better solution?
> >>
> >> Thanks in advance!
> >>
> >> Yiqun Wang
> >>
> >>
> 
> 
> 



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