Hi,
Your class FcnClass should inherit from TObject (and have a ClassDef and a dictionary).
Cheers,
Philippe.
-----Original Message-----
From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Christian Hansen
Sent: Sunday, July 11, 2004 2:58 PM
To: Rene Brun
Cc: Christian Hansen; roottalk@pcroot.cern.ch
Subject: [ROOT] Re: [ROOTDEV] how to run TMINUIT from a stand alone c++
class?
On Fri, 9 Jul 2004, Rene Brun wrote:
Hi Rene,
I've found an email from you on the ROOT TALK DIGEST's
search engine suggesting a solution to my 'fcn' problem;
http://root.cern.ch/root/roottalk/roottalk97/0102.html
Here you suggest to declare 'fcn', externt and give an object
of that class, where 'fcn' is a member, to TMinuit.
This is how I understood it and this is how I have done it in
my latest version of my MinuitTest;
I've made a new class FcnClass(.C/.h) with only one public
member function, 'fcn', and in the header file of MinuitTest
I've made the externed declaration of this function;
extern void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag);
And in the source code of MinuitTest the line
minuit->SetFCN(fcn);
now does work!!! But then when I try to set an object
of the FcnClass to minuit
FcnClass* anObjectOfFcnClass;
minuit->SetObjectFit(anObjectOfFcnClass);
the compiler complains:
MinuitTest.C:20: no matching function for call to
`TVirtualFitter::SetObjectFit(FcnClass*&)'
/home/hansen/ROOT/include/TVirtualFitter.h:87: candidates are:
virtual void TVirtualFitter::SetObjectFit(TObject*)
Could you tell me how I've missunderstood this email
of yours and how I should change in my test code
(attached) so that it goes through compilation?
Thanks
/Christian
> Hi Christian,
>
> see example in $ROOTSYS/test/minexam.cxx
>
> Rene Brun
>
> On Fri, 9 Jul 2004, Christian
> Hansen wrote:
>
> >
> > Dear Rooters,
> >
> > I'm trying to call TMinuit from a c++ class in a similar way
> > that I've used TMinuit in a program called directly from
> > ROOT, but now I do not know how to define the 'fcn'
> > function in order for TMinuit to recognice it with the
> > SetFCN(fcn)
> > I've tried many different ways (attached is a small example)
> > but my code does not want to compile. Could anyone help me how
> > to change this so that the attached code goes through the compilation?
> >
> > Thanks!!!
> >
>
>
--
/ Christian Hansen
===============================================
Box 535 Office: +46-(0)18-471 32 57
S-751 21 Uppsala Office: 82104
Sweden
-----------------------------------------------
Mobile : +46-(0)708-887617
Home Page : http://welcome.to/Christian_Hansen
http://www.cern.ch/Christian.Hansen
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:08 MET