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 analyze impact of individual nuisances on process shapes #269

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, TH1F> ShapeEvolution(RooFitResult const& fit);
double GetObservedRate();
double GetUncertainty();

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

std::map<std::string, TH1F> CombineHarvester::ShapeEvolution(RooFitResult const& fit) {
auto lookup = GenerateProcSystMap();
std::map<std::string, TH1F> shapes;
auto backup = GetParameters();
shapes["prefit"] = GetShapeInternal(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;
}
auto shape = GetShapeInternal(lookup);
// std::cout << "\t" << it->first << "\t" << rate << std::endl;
shapes[it->first] = shape;
// reset parameters to prefit conditions
this->UpdateParameters(backup);
}

// also safe postfit shape
this->UpdateParameters(fit);
shapes["total"] = GetShapeInternal(lookup);
this->UpdateParameters(backup);
return shapes;
}

void CombineHarvester::UpdateParameters(RooFitResult const* fit) {
UpdateParameters(*fit);
}
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, TH1F>,
convert_cpp_map_to_py_dict<std::string, TH1F>>();

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("ShapeEvolution", &CombineHarvester::ShapeEvolution)
.def("UpdateParameters", Overload1_UpdateParameters)
.def("RenameParameter", &CombineHarvester::RenameParameter)
.def("RenameSystematic", &CombineHarvester::RenameSystematic)
Expand Down