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 73bcde4b908d9ffc4c9fc69aab557995d718eab2 Mon Sep 17 00:00:00 2001 From: Philip Daniel Keicher Date: Tue, 18 Jan 2022 16:05:09 +0100 Subject: [PATCH 2/2] implemented tool to analyze effect of individual nuisances on shape of processes --- CombineTools/interface/CombineHarvester.h | 1 + CombineTools/src/CombineHarvester_Evaluate.cc | 35 +++++++++++++++++++ CombineTools/src/CombineHarvester_Python.cc | 4 +++ 3 files changed, 40 insertions(+) diff --git a/CombineTools/interface/CombineHarvester.h b/CombineTools/interface/CombineHarvester.h index 1f6403bc687..b601ba187ea 100644 --- a/CombineTools/interface/CombineHarvester.h +++ b/CombineTools/interface/CombineHarvester.h @@ -337,6 +337,7 @@ class CombineHarvester { */ /**@{*/ double GetRate(); + std::map ShapeEvolution(RooFitResult const& fit); double GetObservedRate(); double GetUncertainty(); diff --git a/CombineTools/src/CombineHarvester_Evaluate.cc b/CombineTools/src/CombineHarvester_Evaluate.cc index 6a6dea751a4..0471bc7831a 100644 --- a/CombineTools/src/CombineHarvester_Evaluate.cc +++ b/CombineTools/src/CombineHarvester_Evaluate.cc @@ -576,6 +576,41 @@ void CombineHarvester::UpdateParameters(RooFitResult const& fit) { } } +std::map CombineHarvester::ShapeEvolution(RooFitResult const& fit) { + auto lookup = GenerateProcSystMap(); + std::map shapes; + auto backup = GetParameters(); + shapes["prefit"] = GetShapeInternal(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; + } + 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); } diff --git a/CombineTools/src/CombineHarvester_Python.cc b/CombineTools/src/CombineHarvester_Python.cc index 93002b02a8d..34c63e50919 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("ShapeEvolution", &CombineHarvester::ShapeEvolution) .def("UpdateParameters", Overload1_UpdateParameters) .def("RenameParameter", &CombineHarvester::RenameParameter) .def("RenameSystematic", &CombineHarvester::RenameSystematic)