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