Logo ROOT  
Reference Guide
MnParameterScan.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 
11 #include "Minuit2/FCNBase.h"
12 
13 namespace ROOT {
14 
15 namespace Minuit2 {
16 
18  : fFCN(fcn), fParameters(par), fAmin(fcn(par.Params()))
19 {
20 }
21 
22 MnParameterScan::MnParameterScan(const FCNBase &fcn, const MnUserParameters &par, double fval)
23  : fFCN(fcn), fParameters(par), fAmin(fval)
24 {
25 }
26 
27 std::vector<std::pair<double, double>> MnParameterScan::
28 operator()(unsigned int par, unsigned int maxsteps, double low, double high)
29 {
30  // do the scan for parameter par between low and high values
31 
32  // if(maxsteps > 101) maxsteps = 101;
33  std::vector<std::pair<double, double>> result;
34  result.reserve(maxsteps + 1);
35  std::vector<double> params = fParameters.Params();
36  result.push_back(std::pair<double, double>(params[par], fAmin));
37 
38  if (low > high)
39  return result;
40  if (maxsteps < 2)
41  return result;
42 
43  if (low == 0. && high == 0.) {
44  low = params[par] - 2. * fParameters.Error(par);
45  high = params[par] + 2. * fParameters.Error(par);
46  }
47 
48  if (low == 0. && high == 0. && fParameters.Parameter(par).HasLimits()) {
50  low = fParameters.Parameter(par).LowerLimit();
52  high = fParameters.Parameter(par).UpperLimit();
53  }
54 
55  if (fParameters.Parameter(par).HasLimits()) {
57  low = std::max(low, fParameters.Parameter(par).LowerLimit());
59  high = std::min(high, fParameters.Parameter(par).UpperLimit());
60  }
61 
62  double x0 = low;
63  double stp = (high - low) / double(maxsteps - 1);
64  for (unsigned int i = 0; i < maxsteps; i++) {
65  params[par] = x0 + double(i) * stp;
66  double fval = fFCN(params);
67  if (fval < fAmin) {
68  fParameters.SetValue(par, params[par]);
69  fAmin = fval;
70  }
71  result.push_back(std::pair<double, double>(params[par], fval));
72  }
73 
74  return result;
75 }
76 
77 } // namespace Minuit2
78 
79 } // namespace ROOT
ROOT::Minuit2::MinuitParameter::UpperLimit
double UpperLimit() const
Definition: MinuitParameter.h:158
ROOT::Minuit2::MnParameterScan::MnParameterScan
MnParameterScan(const FCNBase &, const MnUserParameters &)
Definition: MnParameterScan.cxx:17
ROOT::Minuit2::FCNBase
Interface (abstract class) defining the function to be minimized, which has to be implemented by the ...
Definition: FCNBase.h:45
ROOT::Minuit2::MnParameterScan::fAmin
double fAmin
Definition: MnParameterScan.h:48
ROOT::Minuit2::MinuitParameter::HasUpperLimit
bool HasUpperLimit() const
Definition: MinuitParameter.h:156
ROOT::Minuit2::MnParameterScan::fParameters
MnUserParameters fParameters
Definition: MnParameterScan.h:47
ROOT::Minuit2::MnUserParameters::SetValue
void SetValue(unsigned int, double)
Definition: MnUserParameters.cxx:86
ROOT::Minuit2::MnUserParameters
API class for the user interaction with the parameters; serves as input to the minimizer as well as o...
Definition: MnUserParameters.h:36
ROOT::Minuit2::MnUserParameters::Error
double Error(unsigned int) const
Definition: MnUserParameters.cxx:128
double
double
Definition: Converters.cxx:921
MnParameterScan.h
ROOT::Minuit2::MinuitParameter::HasLimits
bool HasLimits() const
Definition: MinuitParameter.h:154
ROOT::Minuit2::MnUserParameters::Params
std::vector< double > Params() const
access to parameters and errors in column-wise representation
Definition: MnUserParameters.cxx:29
ROOT::Minuit2::MnParameterScan::fFCN
const FCNBase & fFCN
Definition: MnParameterScan.h:46
ROOT::Minuit2::MnUserParameters::Parameter
const MinuitParameter & Parameter(unsigned int) const
access to single Parameter
Definition: MnUserParameters.cxx:41
FCNBase.h
ROOT::Minuit2::MnParameterScan::operator()
std::vector< std::pair< double, double > > operator()(unsigned int par, unsigned int maxsteps=41, double low=0., double high=0.)
Definition: MnParameterScan.cxx:28
ROOT::Minuit2::MinuitParameter::LowerLimit
double LowerLimit() const
Definition: MinuitParameter.h:157
ROOT
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: EExecutionPolicy.hxx:4
ROOT::Minuit2::MinuitParameter::HasLowerLimit
bool HasLowerLimit() const
Definition: MinuitParameter.h:155