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

Tool to gauge impact of individual parameters on process yields #268

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CombineTools/interface/CombineHarvester.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ class CombineHarvester {
*/
/**@{*/
double GetRate();
std::map<std::string, double> RateEvolution(RooFitResult const& fit);
double GetObservedRate();
double GetUncertainty();

Expand Down
30 changes: 30 additions & 0 deletions CombineTools/src/CombineHarvester_Evaluate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,36 @@ void CombineHarvester::UpdateParameters(RooFitResult const* fit) {
UpdateParameters(*fit);
}

std::map<std::string, double> CombineHarvester::RateEvolution(RooFitResult const& fit) {
auto lookup = GenerateProcSystMap();
std::map<std::string, double> rates;
auto backup = GetParameters();
rates["prefit"] = GetRateInternal(lookup);
for (int i = 0; i < fit.floatParsFinal().getSize(); ++i) {
RooRealVar const* var =
dynamic_cast<RooRealVar const*>(fit.floatParsFinal().at(i));
// check for failed cast here
auto it = params_.find(std::string(var->GetName()));
if (it != params_.end()) {
it->second->set_val(var->getVal());
it->second->set_err_d(var->getErrorLo());
it->second->set_err_u(var->getErrorHi());
} else {
if (verbosity_ >= 1) {
LOGLINE(log(),
"Parameter " + std::string(var->GetName()) + " is not defined");
}
continue;
}
double rate = GetRateInternal(lookup);
// std::cout << "\t" << it->first << "\t" << rate << std::endl;
rates[it->first] = rate;
// reset parameters to prefit conditions
this->UpdateParameters(backup);
}
return rates;
}

std::vector<ch::Parameter> CombineHarvester::GetParameters() const {
std::vector<ch::Parameter> params;
for (auto const& it : params_) {
Expand Down
4 changes: 4 additions & 0 deletions CombineTools/src/CombineHarvester_Python.cc
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ BOOST_PYTHON_MODULE(libCombineHarvesterCombineTools)
py::to_python_converter<std::map<std::string, CombineHarvester>,
convert_cpp_map_to_py_dict<std::string, CombineHarvester>>();

py::to_python_converter<std::map<std::string, double>,
convert_cpp_map_to_py_dict<std::string, double>>();

py::to_python_converter<TH1F,
convert_cpp_root_to_py_root<TH1F>>();

Expand Down Expand Up @@ -338,6 +341,7 @@ BOOST_PYTHON_MODULE(libCombineHarvesterCombineTools)
// Modification
.def("GetParameter", Overload1_GetParameter,
py::return_value_policy<py::reference_existing_object>())
.def("RateEvolution", &CombineHarvester::RateEvolution)
.def("UpdateParameters", Overload1_UpdateParameters)
.def("RenameParameter", &CombineHarvester::RenameParameter)
.def("RenameSystematic", &CombineHarvester::RenameSystematic)
Expand Down