Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement option in FitterAlgoBase to toggle between nll backends #1028

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/FitterAlgoBase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ std::string FitterAlgoBase::autoBoundsPOIs_ = "";
std::string FitterAlgoBase::autoMaxPOIs_ = "";
double FitterAlgoBase::nllValue_ = std::numeric_limits<double>::quiet_NaN();
double FitterAlgoBase::nll0Value_ = std::numeric_limits<double>::quiet_NaN();
extern std::string nllBackend_ = "combine";
FitterAlgoBase::ProfilingMode FitterAlgoBase::profileMode_ = ProfileAll;

FitterAlgoBase::FitterAlgoBase(const char *title) :
Expand All @@ -85,6 +86,8 @@ FitterAlgoBase::FitterAlgoBase(const char *title) :
("autoBoundsPOIs", boost::program_options::value<std::string>(&autoBoundsPOIs_)->default_value(autoBoundsPOIs_), "Adjust bounds for these POIs if they end up close to the boundary. Can be a list of POIs, or \"*\" to get all")
("autoMaxPOIs", boost::program_options::value<std::string>(&autoMaxPOIs_)->default_value(autoMaxPOIs_), "Adjust maxima for these POIs if they end up close to the boundary. Can be a list of POIs, or \"*\" to get all")
("forceRecreateNLL", "Always recreate NLL when running on multiple toys rather than re-using nll with new dataset")
("nllbackend", boost::program_options::value<std::string>(&nllBackend_)->default_value(nllBackend_), "DEBUG OPTION, DO NOT USE! Set backend to create NLL. Choices: combine (default behavior), cpu, legacy, codegen")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a minor nitpick, but maybe it should be called nllBackend to be consistent with the other options in camelCase?


;
}

Expand All @@ -101,6 +104,13 @@ void FitterAlgoBase::applyOptionsBase(const boost::program_options::variables_ma
else if (profileMode == "none") profileMode_ = NoProfiling;
else throw std::invalid_argument("option 'profilingMode' can only take as values 'all', 'none', 'poi' and 'unconstrained' (at least for now)\n");

// translate input nllbackend_ parameter into a RooFit option
std::string nllbackend = vm["nllbackend"].as<std::string>();
std::set<std::string> allowed_nll_options{"combine", "legacy", "cpu", "codegen"};
if (allowed_nll_options.find(nllbackend) != allowed_nll_options.end()) {
Combine::nllBackend_ = nllbackend;
} else throw std::invalid_argument("option 'nllbackend' can only take as values 'combine', 'legacy', 'cpu' and 'codegen' (at least for now)\n");

if (!vm.count("setRobustFitAlgo") || vm["setRobustFitAlgo"].defaulted()) {
minimizerAlgoForMinos_ = Form("%s,%s",ROOT::Math::MinimizerOptions::DefaultMinimizerType().c_str(), ROOT::Math::MinimizerOptions::DefaultMinimizerAlgo().c_str());
}
Expand Down
Loading