Logo ROOT  
Reference Guide
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 * Web : http://tmva.sourceforge.net *
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 * (http://tmva.sourceforge.net/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
34
35////////////////////////////////////////////////////////////////////////////////
36/// constructor
37
39: TMinuit( maxpar ),
40 fFitterTarget( target ),
41 fNumPar( maxpar )
42{
43 for ( Int_t i=0; i< maxpar; i++ ) {
44 fParameters.push_back(0.0);
45 }
46}
47
48////////////////////////////////////////////////////////////////////////////////
49/// std::vector<Double_t> parameters( npar );
50
52{
53 for (Int_t ipar=0; ipar<fNumPar; ipar++) fParameters[ipar] = par[ipar];
54
55 f = fFitterTarget.EstimatorFunction( fParameters );
56 return 0;
57}
58
59////////////////////////////////////////////////////////////////////////////////
60/// Execute a fitter command;
61/// command : command string
62/// args : list of nargs command arguments
63
64Int_t TMVA::MinuitWrapper::ExecuteCommand(const char *command, Double_t *args, Int_t nargs)
65{
66 Int_t ierr = 0;
67 mnexcm(command,args,nargs,ierr);
68 return ierr;
69}
70
71////////////////////////////////////////////////////////////////////////////////
72/// reset the fitter environment
73
75{
76 // reset the internal Minuit random generator to its initial state
77 Double_t val = 3;
78 Int_t inseed = 12345;
79 mnrn15(val,inseed);
80}
81
82////////////////////////////////////////////////////////////////////////////////
83/// return global fit parameters
84/// - amin : chisquare
85/// - edm : estimated distance to minimum
86/// - errdef
87/// - nvpar : number of variable parameters
88/// - nparx : total number of parameters
89
91{
92 Int_t ierr = 0;
93 mnstat(amin,edm,errdef,nvpar,nparx,ierr);
94 return ierr;
95}
96
97////////////////////////////////////////////////////////////////////////////////
98/// return current errors for a parameter
99/// - ipar : parameter number
100/// - eplus : upper error
101/// - eminus : lower error
102/// - eparab : parabolic error
103/// - globcc : global correlation coefficient
104
106{
107 Int_t ierr = 0;
108 mnerrs(ipar, eplus,eminus,eparab,globcc);
109 return ierr;
110}
111
112////////////////////////////////////////////////////////////////////////////////
113/// set initial values for a parameter
114/// - ipar : parameter number
115/// - parname : parameter name
116/// - value : initial parameter value
117/// - verr : initial error for this parameter
118/// - vlow : lower value for the parameter
119/// - vhigh : upper value for the parameter
120
121Int_t TMVA::MinuitWrapper::SetParameter(Int_t ipar,const char *parname,Double_t value,Double_t verr,Double_t vlow, Double_t vhigh)
122{
123 // if (fCovar) {delete [] fCovar; fCovar = 0;}
124 Int_t ierr = 0;
125 mnparm(ipar,parname,value,verr,vlow,vhigh,ierr);
126 return ierr;
127}
128
129////////////////////////////////////////////////////////////////////////////////
130/// produces a clone of this MinuitWrapper
131
132TObject *TMVA::MinuitWrapper::Clone(char const* newname) const
133{
134 MinuitWrapper *named = (MinuitWrapper*)TNamed::Clone(newname);
135 named->fFitterTarget = fFitterTarget;
136 return 0;
137}
#define f(i)
Definition: RSha256.hxx:104
int Int_t
Definition: RtypesCore.h:41
double Double_t
Definition: RtypesCore.h:55
const char Option_t
Definition: RtypesCore.h:62
#define ClassImp(name)
Definition: Rtypes.h:365
Interface for a fitter 'target'.
Definition: IFitterTarget.h:44
Wrapper around MINUIT.
Definition: MinuitWrapper.h:45
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
Definition: MinuitWrapper.h:64
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 *=0)
reset the fitter environment
Int_t Eval(Int_t, Double_t *, Double_t &, Double_t *, Int_t)
std::vector<Double_t> parameters( npar );
std::vector< Double_t > fParameters
Definition: MinuitWrapper.h:65
TObject * Clone(char const *) const
produces a clone of this MinuitWrapper
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
Implementation in C++ of the Minuit package written by Fred James.
Definition: TMinuit.h:27
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
Definition: TNamed.cxx:74
Mother of all ROOT objects.
Definition: TObject.h:37
static constexpr double eplus