From cbd6e7f5a5dc49fd490e124a9e7face84e66d782 Mon Sep 17 00:00:00 2001 From: Philip Daniel Keicher Date: Tue, 19 Mar 2019 12:15:25 +0100 Subject: [PATCH 1/2] added option to set label size in plot --- CombineTools/scripts/plotImpacts.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CombineTools/scripts/plotImpacts.py b/CombineTools/scripts/plotImpacts.py index 9479ea43205..4e25c0dea5c 100755 --- a/CombineTools/scripts/plotImpacts.py +++ b/CombineTools/scripts/plotImpacts.py @@ -23,6 +23,7 @@ parser.add_argument('--color-groups', default=None, help='Comma separated list of GROUP=COLOR') parser.add_argument("--pullDef", default=None, help="Choose the definition of the pull, see HiggsAnalysis/CombinedLimit/python/calculate_pulls.py for options") parser.add_argument('--POI', default=None, help='Specify a POI to draw') +parser.add_argument("--set-label-size", dest = "labelsize",default = 0.022, help = "Set size of labels on the left hand side (default = 0.022", type = float) args = parser.parse_args() if args.transparent: @@ -219,7 +220,7 @@ def GetRounded(nom, e_hi, e_lo): else: plot.Set(h_pulls.GetXaxis(), TitleSize=0.04, LabelSize=0.03, Title='(#hat{#theta}-#theta_{0})/#Delta#theta') - plot.Set(h_pulls.GetYaxis(), LabelSize=0.021, TickLength=0.0) + plot.Set(h_pulls.GetYaxis(), LabelSize=args.labelsize, TickLength=0.0) h_pulls.GetYaxis().LabelsOption('v') h_pulls.Draw() @@ -324,4 +325,4 @@ def GetRounded(nom, e_hi, e_lo): extra = '(' if page == n - 1: extra = ')' - canv.Print('.pdf%s' % extra) + canv.Print('.pdf%s' % extra) \ No newline at end of file From 94dbb80490aa36c8e4446d155fd69232f2550ec3 Mon Sep 17 00:00:00 2001 From: Philip Daniel Keicher Date: Tue, 18 Jan 2022 15:30:21 +0100 Subject: [PATCH 2/2] implemented tool to calculate influence of individual parameters on process yields --- CombineTools/interface/CombineHarvester.h | 1 + CombineTools/src/CombineHarvester_Evaluate.cc | 30 +++++++++++++++++++ CombineTools/src/CombineHarvester_Python.cc | 4 +++ 3 files changed, 35 insertions(+) diff --git a/CombineTools/interface/CombineHarvester.h b/CombineTools/interface/CombineHarvester.h index 1f6403bc687..a4f87c7784f 100644 --- a/CombineTools/interface/CombineHarvester.h +++ b/CombineTools/interface/CombineHarvester.h @@ -337,6 +337,7 @@ class CombineHarvester { */ /**@{*/ double GetRate(); + std::map RateEvolution(RooFitResult const& fit); double GetObservedRate(); double GetUncertainty(); diff --git a/CombineTools/src/CombineHarvester_Evaluate.cc b/CombineTools/src/CombineHarvester_Evaluate.cc index 6a6dea751a4..dee308f46cd 100644 --- a/CombineTools/src/CombineHarvester_Evaluate.cc +++ b/CombineTools/src/CombineHarvester_Evaluate.cc @@ -580,6 +580,36 @@ void CombineHarvester::UpdateParameters(RooFitResult const* fit) { UpdateParameters(*fit); } +std::map CombineHarvester::RateEvolution(RooFitResult const& fit) { + auto lookup = GenerateProcSystMap(); + std::map rates; + auto backup = GetParameters(); + rates["prefit"] = GetRateInternal(lookup); + for (int i = 0; i < fit.floatParsFinal().getSize(); ++i) { + RooRealVar const* var = + dynamic_cast(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 CombineHarvester::GetParameters() const { std::vector params; for (auto const& it : params_) { diff --git a/CombineTools/src/CombineHarvester_Python.cc b/CombineTools/src/CombineHarvester_Python.cc index 93002b02a8d..aa1787f4dc9 100644 --- a/CombineTools/src/CombineHarvester_Python.cc +++ b/CombineTools/src/CombineHarvester_Python.cc @@ -232,6 +232,9 @@ BOOST_PYTHON_MODULE(libCombineHarvesterCombineTools) py::to_python_converter, convert_cpp_map_to_py_dict>(); + py::to_python_converter, + convert_cpp_map_to_py_dict>(); + py::to_python_converter>(); @@ -338,6 +341,7 @@ BOOST_PYTHON_MODULE(libCombineHarvesterCombineTools) // Modification .def("GetParameter", Overload1_GetParameter, py::return_value_policy()) + .def("RateEvolution", &CombineHarvester::RateEvolution) .def("UpdateParameters", Overload1_UpdateParameters) .def("RenameParameter", &CombineHarvester::RenameParameter) .def("RenameSystematic", &CombineHarvester::RenameSystematic)