Logo ROOT   6.08/07
Reference Guide
Quad4FMain.cxx
Go to the documentation of this file.
1 // @(#)root/minuit2:$Id$
2 // Authors: M. Winkler, F. James, L. Moneta, A. Zsenei 2003-2005
3 
4 /**********************************************************************
5  * *
6  * Copyright (c) 2005 LCG ROOT Math team, CERN/PH-SFT *
7  * *
8  **********************************************************************/
9 
10 #include "Quad4F.h"
12 #include "Minuit2/MnMigrad.h"
13 #include "Minuit2/MnHesse.h"
15 #include "Minuit2/MnPrint.h"
16 // #include "TimingUtilities/PentiumTimer.h"
17 
18 // StackAllocator gStackAllocator;
19 
20 using namespace ROOT::Minuit2;
21 
22 int main() {
23 
24  Quad4F fcn;
25 
26 // PentiumTimer stopwatch;
27 // stopwatch.start();
28 
29 // long long int start = stopwatch.lap().ticks();
30 // long long int stop = stopwatch.lap().ticks();
31 // std::cout<<"stop-start: "<<stop - start<<std::endl;
32 // start = stopwatch.lap().ticks();
33  {
34  //test constructor
35  MnUserParameters upar;
36  upar.Add("x", 1., 0.1);
37  upar.Add("y", 1., 0.1);
38  upar.Add("z", 1., 0.1);
39  upar.Add("w", 1., 0.1);
40 
41  MnMigrad migrad(fcn, upar);
42  FunctionMinimum min = migrad();
43  std::cout<<"minimum: "<<min<<std::endl;
44  }
45  {
46  // use analytical derivatives
47  Quad4FGrad gfcn;
48 
49  MnUserParameters upar;
50  upar.Add("x", 1., 0.1);
51  upar.Add("y", 1., 0.1);
52  upar.Add("z", 1., 0.1);
53  upar.Add("w", 1., 0.1);
54 
55  MnMigrad migrad(gfcn, upar);
56  FunctionMinimum min = migrad();
57  std::cout<<"minimum with grad calculation : "<<min<<std::endl;
58 
59  // try to run hesse
60  MnHesse hesse;
61  hesse( gfcn, min);
62  std::cout<<"minimum after hesse: "<<min<<std::endl;
63  }
64 
65 // stop = stopwatch.lap().ticks();
66 // std::cout<<"stop-start: "<<stop - start<<std::endl;
67 /*
68 
69  {
70  //test constructor
71  std::vector<double> par(4);
72  std::vector<double> err(4);
73  for(int i = 0; i < 4; i++) {
74  par[i] = 1.;
75  err[i] = 0.1;
76  }
77  MnMigrad migrad(fcn, par, err);
78  FunctionMinimum min = migrad();
79  std::cout<<"minimum: "<<min<<std::endl;
80  }
81 
82  {
83  //test edm Value
84  std::vector<double> par(4);
85  std::vector<double> err(4);
86  for(int i = 0; i < 4; i++) {
87  par[i] = 1.;
88  err[i] = 0.1;
89  }
90  MnMigrad migrad(fcn, par, err);
91  double edm = 1.e-1;
92  FunctionMinimum min = migrad(20, edm);
93  std::cout<<"minimum: "<<min<<std::endl;
94  }
95 
96  {
97  //test # of iterations
98  std::vector<double> par(4);
99  std::vector<double> err(4);
100  for(int i = 0; i < 4; i++) {
101  par[i] = 1.;
102  err[i] = 0.1;
103  }
104  MnMigrad migrad(fcn, par, err);
105  int niter = 2;
106  FunctionMinimum min = migrad(niter, 1.e-5);
107  std::cout<<"minimum: "<<min<<std::endl;
108  }
109 */
110 
111  return 0;
112 }
API class for minimization using Variable Metric technology ("MIGRAD"); allows for user interaction: ...
Definition: MnMigrad.h:31
int main()
Definition: Quad4FMain.cxx:22
bool Add(const std::string &, double, double)
Add free Parameter Name, Value, Error.
class holding the full result of the minimization; both internal and external (MnUserParameterState) ...
API class for calculating the numerical covariance matrix (== 2x Inverse Hessian == 2x Inverse 2nd de...
Definition: MnHesse.h:40
API class for the user interaction with the parameters; serves as input to the minimizer as well as o...