Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
MinuitWrapper.cxx
Go to the documentation of this file.
1// @(#)root/tmva $Id$
2// Author: Peter Speckmayer
3
4/**********************************************************************************
5 * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6 * Package: TMVA *
7 * Class : MinuitWrapper *
8 * *
9 * *
10 * Description: *
11 * Implementation *
12 * *
13 * Authors (alphabetical): *
14 * Peter Speckmayer <peter.speckmayer@cern.ch> - CERN, Switzerland *
15 * *
16 * Copyright (c) 2005: *
17 * CERN, Switzerland *
18 * MPI-K Heidelberg, Germany *
19 * *
20 * Redistribution and use in source and binary forms, with or without *
21 * modification, are permitted according to the terms listed in LICENSE *
22 * (see tmva/doc/LICENSE) *
23 **********************************************************************************/
24
25/*! \class TMVA::MinuitWrapper
26\ingroup TMVA
27Wrapper around MINUIT
28*/
29#include "TMVA/MinuitWrapper.h"
30
31#include "TMVA/IFitterTarget.h"
32
33
34////////////////////////////////////////////////////////////////////////////////
35/// constructor
36
38: TMinuit( maxpar ),
39 fFitterTarget( target ),
40 fNumPar( maxpar )
41{
42 for ( Int_t i=0; i< maxpar; i++ ) {
43 fParameters.push_back(0.0);
44 }
45}
46
47////////////////////////////////////////////////////////////////////////////////
48/// std::vector<Double_t> parameters( npar );
49
51{
52 for (Int_t ipar=0; ipar<fNumPar; ipar++) fParameters[ipar] = par[ipar];
53
54 f = fFitterTarget.EstimatorFunction( fParameters );
55 return 0;
56}
57
58////////////////////////////////////////////////////////////////////////////////
59/// Execute a fitter command;
60/// command : command string
61/// args : list of nargs command arguments
62
63Int_t TMVA::MinuitWrapper::ExecuteCommand(const char *command, Double_t *args, Int_t nargs)
64{
65 Int_t ierr = 0;
66 mnexcm(command,args,nargs,ierr);
67 return ierr;
68}
69
70////////////////////////////////////////////////////////////////////////////////
71/// reset the fitter environment
72
74{
75 // reset the internal Minuit random generator to its initial state
76 Double_t val = 3;
77 Int_t inseed = 12345;
78 mnrn15(val,inseed);
79}
80
81////////////////////////////////////////////////////////////////////////////////
82/// return global fit parameters
83/// - amin : chisquare
84/// - edm : estimated distance to minimum
85/// - errdef
86/// - nvpar : number of variable parameters
87/// - nparx : total number of parameters
88
90{
91 Int_t ierr = 0;
92 mnstat(amin,edm,errdef,nvpar,nparx,ierr);
93 return ierr;
94}
95
96////////////////////////////////////////////////////////////////////////////////
97/// return current errors for a parameter
98/// - ipar : parameter number
99/// - eplus : upper error
100/// - eminus : lower error
101/// - eparab : parabolic error
102/// - globcc : global correlation coefficient
103
105{
106 Int_t ierr = 0;
107 mnerrs(ipar, eplus,eminus,eparab,globcc);
108 return ierr;
109}
110
111////////////////////////////////////////////////////////////////////////////////
112/// set initial values for a parameter
113/// - ipar : parameter number
114/// - parname : parameter name
115/// - value : initial parameter value
116/// - verr : initial error for this parameter
117/// - vlow : lower value for the parameter
118/// - vhigh : upper value for the parameter
119
120Int_t TMVA::MinuitWrapper::SetParameter(Int_t ipar,const char *parname,Double_t value,Double_t verr,Double_t vlow, Double_t vhigh)
121{
122 // if (fCovar) {delete [] fCovar; fCovar = 0;}
123 Int_t ierr = 0;
124 mnparm(ipar,parname,value,verr,vlow,vhigh,ierr);
125 return ierr;
126}
127
128////////////////////////////////////////////////////////////////////////////////
129/// produces a clone of this MinuitWrapper
130
131TObject *TMVA::MinuitWrapper::Clone(char const* newname) const
132{
133 MinuitWrapper *named = (MinuitWrapper*)TNamed::Clone(newname);
135 return 0;
136}
#define f(i)
Definition RSha256.hxx:104
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
const char Option_t
Option string (const char).
Definition RtypesCore.h:80
Interface for a fitter 'target'.
Int_t ExecuteCommand(const char *command, Double_t *args, Int_t nargs)
Execute a fitter command; command : command string args : list of nargs command arguments.
IFitterTarget & fFitterTarget
fitter Target
Int_t SetParameter(Int_t ipar, const char *parname, Double_t value, Double_t verr, Double_t vlow, Double_t vhigh)
set initial values for a parameter
MinuitWrapper(IFitterTarget &target, Int_t maxpar)
constructor
void Clear(Option_t *=nullptr) override
reset the fitter environment
Int_t fNumPar
number of parameters
Int_t Eval(Int_t, Double_t *, Double_t &, Double_t *, Int_t) override
std::vector<Double_t> parameters( npar );
TObject * Clone(char const *) const override
produces a clone of this MinuitWrapper
std::vector< Double_t > fParameters
vector holding the current parameters
Int_t GetStats(Double_t &amin, Double_t &edm, Double_t &errdef, Int_t &nvpar, Int_t &nparx)
return global fit parameters
Int_t GetErrors(Int_t ipar, Double_t &eplus, Double_t &eminus, Double_t &eparab, Double_t &globcc)
return current errors for a parameter
TMinuit(const TMinuit &m)
virtual void mnrn15(Double_t &val, Int_t &inseed)
This is a super-portable random number generator.
Definition TMinuit.cxx:6613
virtual void mnerrs(Int_t number, Double_t &eplus, Double_t &eminus, Double_t &eparab, Double_t &gcc)
Utility routine to get MINOS errors.
Definition TMinuit.cxx:2577
virtual void mnexcm(const char *comand, Double_t *plist, Int_t llist, Int_t &ierflg)
Interprets a command and takes appropriate action.
Definition TMinuit.cxx:2663
virtual void mnstat(Double_t &fmin, Double_t &fedm, Double_t &errdef, Int_t &npari, Int_t &nparx, Int_t &istat)
Returns concerning the current status of the minimization.
Definition TMinuit.cxx:7632
virtual void mnparm(Int_t k, TString cnamj, Double_t uk, Double_t wk, Double_t a, Double_t b, Int_t &ierflg)
Implements one parameter definition.
Definition TMinuit.cxx:5664
TObject * Clone(const char *newname="") const override
Make a clone of an object using the Streamer facility.
Definition TNamed.cxx:73
TObject()
TObject constructor.
Definition TObject.h:259