1 #include "../interface/CascadeMinimizer.h"
2 #include "../interface/ProfiledLikelihoodRatioTestStatExt.h"
3 #include "../interface/ProfileLikelihood.h"
4 #include "../interface/CloseCoutSentry.h"
5 #include "../interface/utils.h"
7 #include <Math/MinimizerOptions.h>
8 #include <RooCategory.h>
9 #include <RooNumIntConfig.h>
24 strategy_(initialStrategy),
34 if (cascade && !outcome && !
fallbacks_.empty()) {
35 std::string nominalType(ROOT::Math::MinimizerOptions::DefaultMinimizerType());
36 std::string nominalAlgo(ROOT::Math::MinimizerOptions::DefaultMinimizerAlgo());
37 float nominalTol(ROOT::Math::MinimizerOptions::DefaultTolerance());
39 if (verbose > 0)
std::cerr <<
"Failed minimization with " << nominalType <<
"," << nominalAlgo <<
" and tolerance " << nominalTol << std::endl;
40 for (std::vector<Algo>::const_iterator it =
fallbacks_.begin(), ed =
fallbacks_.end(); it != ed; ++it) {
43 if (nominalType != ROOT::Math::MinimizerOptions::DefaultMinimizerType() ||
44 nominalAlgo != ROOT::Math::MinimizerOptions::DefaultMinimizerAlgo() ||
45 nominalTol != ROOT::Math::MinimizerOptions::DefaultTolerance() ||
46 myStrategy != nominalStrat) {
47 if (verbose > 0)
std::cerr <<
"Will fallback to minimization using " << it->algo <<
", strategy " << myStrategy <<
" and tolerance " << it->tolerance << std::endl;
63 std::string myType(ROOT::Math::MinimizerOptions::DefaultMinimizerType());
64 std::string myAlgo(ROOT::Math::MinimizerOptions::DefaultMinimizerAlgo());
76 outcome = (status == 0);
94 return improve(verbose, cascade);
101 (
"cminPoiOnlyFit",
"Do first a fit floating only the parameter of interest")
102 (
"cminPreScan",
"Do a scan before first minimization")
103 (
"cminSingleNuisFit",
"Do first a minimization of each nuisance parameter individually")
104 (
"cminFallbackAlgo",
boost::program_options::value<std::vector<std::string> >(),
"Fallback algorithms if the default minimizer fails (can use multiple ones). Syntax is algo[,subalgo][,strategy][:tolerance]")
105 (
"cminSetZeroPoint", boost::program_options::value<bool>(&
setZeroPoint_)->default_value(
setZeroPoint_),
"Change the reference point of the NLL to be zero during minimization")
106 (
"cminOldRobustMinimize", boost::program_options::value<bool>(&
oldFallback_)->default_value(
oldFallback_),
"Use the old 'robustMinimize' logic in addition to the cascade")
126 if (vm.count(
"cminFallbackAlgo")) {
127 vector<string> falls(vm[
"cminFallbackAlgo"].as<vector<string> >());
128 for (vector<string>::const_iterator it = falls.begin(), ed = falls.end(); it != ed; ++it) {
129 std::string
algo = *it;
133 if (idx != string::npos && idx < algo.length()) {
134 tolerance = atof(algo.substr(idx+1).c_str());
135 algo = algo.substr(0,idx);
137 idx = algo.find(
",");
138 if (idx != string::npos && idx < algo.length()) {
140 if (
'0' <= algo[idx+1] && algo[idx+1] <=
'9' ) {
141 strategy = atoi(algo.substr(idx+1).c_str());
142 algo = algo.substr(0,idx);
145 idx = algo.find(
",",idx+1);
146 if (idx != string::npos && idx < algo.length()) {
147 strategy = atoi(algo.substr(idx+1).c_str());
148 algo = algo.substr(0,idx);
154 ", strategy " <<
fallbacks_.back().strategy <<
155 ", tolerance " <<
fallbacks_.back().tolerance << std::endl;
184 double rMin = r.getMin(), rMax = r.getMax(), rStep = (rMax-rMin)/(points-1);
185 int iMin = -1;
double minnll = 0;
186 for (
int i = 0;
i < points; ++
i) {
187 double x = rMin + (
i+0.5)*rStep;
189 double y = nll.getVal();
190 if (iMin == -1 || y < minnll) { minnll =
y; iMin =
i; }
192 r.setVal( rMin + (iMin+0.5)*rStep );
static bool poiOnlyFit_
do first a fit of only the POI
bool improveOnce(int verbose)
static bool preScan_
do a pre-scan
bool robustMinimize(RooAbsReal &nll, RooMinimizerOpt &minimizer, int verbosity=0)
bool minimize(int verbose=0, bool cascade=true)
static float default_tolerance()
static void applyOptions(const boost::program_options::variables_map &vm)
static int default_strategy()
bool improve(int verbose=0, bool cascade=true)
CascadeMinimizer(RooAbsReal &nll, Mode mode, RooRealVar *poi=0, int initialStrategy=0)
compact information about an algorithm
static bool singleNuisFit_
do first a minimization of each nuisance individually
static bool oldFallback_
don't do old fallback using robustMinimize
static bool setZeroPoint_
do first a fit of only the POI
static boost::program_options::options_description options_
options configured from command line
RooMinimizerOpt minimizer_
static void initOptions()
Setup Minimizer configuration on creation, reset the previous one on destruction. ...
static std::vector< Algo > fallbacks_
list of algorithms to run if the default one fails
void trivialMinimize(const RooAbsReal &nll, RooRealVar &r, int points=100) const