From 1ef8cbe2b3de5e217d0bd27f1178d8683b60c93f Mon Sep 17 00:00:00 2001 From: giacomoortona Date: Fri, 20 Sep 2024 15:09:48 +0200 Subject: [PATCH 1/3] Update ValidationTools.cc to remove 1-bin-shapes warnings --- CombineTools/src/ValidationTools.cc | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/CombineTools/src/ValidationTools.cc b/CombineTools/src/ValidationTools.cc index 16f94ce87e0..e1b857cfb36 100644 --- a/CombineTools/src/ValidationTools.cc +++ b/CombineTools/src/ValidationTools.cc @@ -228,7 +228,7 @@ void CheckSizeOfShapeEffect(CombineHarvester& cb){ } if(up_difftype()=="shape"){ hist_u = sys->shape_u(); hist_d = sys->shape_d(); - hist_nom=cb.cp().bin({sys->bin()}).process({sys->process()}).GetShape(); - hist_nom.Scale(1./hist_nom.Integral()); - double up_diff=0; - double down_diff=0; - for(int i=1;i<=hist_u->GetNbinsX();i++){ - if(fabs(hist_u->GetBinContent(i))+fabs(hist_nom.GetBinContent(i))>0){ - up_diff+=2*double(fabs(hist_u->GetBinContent(i)-hist_nom.GetBinContent(i)))/(fabs(hist_u->GetBinContent(i))+fabs(hist_nom.GetBinContent(i))); - } - if(fabs(hist_d->GetBinContent(i))+fabs(hist_nom.GetBinContent(i))>0){ - down_diff+=2*double(fabs(hist_d->GetBinContent(i)-hist_nom.GetBinContent(i)))/(fabs(hist_d->GetBinContent(i))+fabs(hist_nom.GetBinContent(i))); + if (hist_u->GetNbinsX() = 1) jsobj["smallShapeEff1bin"][sys->name()][sys->bin()][sys->process()]={{"diff_u",up_diff},{"diff_d",down_diff}}; + else{ + hist_nom=cb.cp().bin({sys->bin()}).process({sys->process()}).GetShape(); + hist_nom.Scale(1./hist_nom.Integral()); + double up_diff=0; + double down_diff=0; + for(int i=1;i<=hist_u->GetNbinsX();i++){ + if(fabs(hist_u->GetBinContent(i))+fabs(hist_nom.GetBinContent(i))>0){ + up_diff+=2*double(fabs(hist_u->GetBinContent(i)-hist_nom.GetBinContent(i)))/(fabs(hist_u->GetBinContent(i))+fabs(hist_nom.GetBinContent(i))); + } + if(fabs(hist_d->GetBinContent(i))+fabs(hist_nom.GetBinContent(i))>0){ + down_diff+=2*double(fabs(hist_d->GetBinContent(i)-hist_nom.GetBinContent(i)))/(fabs(hist_d->GetBinContent(i))+fabs(hist_nom.GetBinContent(i))); + } } + if(up_diffname()][sys->bin()][sys->process()]={{"diff_u",up_diff},{"diff_d",down_diff}}; } - if(up_diffname()][sys->bin()][sys->process()]={{"diff_u",up_diff},{"diff_d",down_diff}}; } }); } From 10292deb7bca1c84daf90e20049018295d84e987 Mon Sep 17 00:00:00 2001 From: giacomoortona Date: Fri, 20 Sep 2024 15:14:27 +0200 Subject: [PATCH 2/3] report 1-bin shape uncertainties as info instead of warning --- CombineTools/scripts/ValidateDatacards.py | 1 + 1 file changed, 1 insertion(+) diff --git a/CombineTools/scripts/ValidateDatacards.py b/CombineTools/scripts/ValidateDatacards.py index 2b983bc1f0b..14701556be3 100755 --- a/CombineTools/scripts/ValidateDatacards.py +++ b/CombineTools/scripts/ValidateDatacards.py @@ -130,5 +130,6 @@ def print_bin(js_dict, dict_key, err_type_msg): print_process(data,"emptyProcessShape","\'Empty process\'") print_bin(data,"emptyBkgBin","\'Bins of the template empty in background\'") print_process_info(data,"smallSignalProc","\'Small signal process\'") + print_process_info(data,"smallShapeEff1bin","\'Shape uncertainties with 1 bin only. You can consider replacing them with lnN\'") From 22d1c38eae91027e38266ea8a197fd18d415e928 Mon Sep 17 00:00:00 2001 From: giacomoortona Date: Tue, 24 Sep 2024 10:42:55 +0200 Subject: [PATCH 3/3] fix typo in ValidationTools.cc --- CombineTools/src/ValidationTools.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CombineTools/src/ValidationTools.cc b/CombineTools/src/ValidationTools.cc index e1b857cfb36..66793077e99 100644 --- a/CombineTools/src/ValidationTools.cc +++ b/CombineTools/src/ValidationTools.cc @@ -244,7 +244,7 @@ void CheckSizeOfShapeEffect(CombineHarvester& cb, json& jsobj){ if(sys->type()=="shape"){ hist_u = sys->shape_u(); hist_d = sys->shape_d(); - if (hist_u->GetNbinsX() = 1) jsobj["smallShapeEff1bin"][sys->name()][sys->bin()][sys->process()]={{"diff_u",up_diff},{"diff_d",down_diff}}; + if (hist_u->GetNbinsX() == 1) jsobj["smallShapeEff1bin"][sys->name()][sys->bin()][sys->process()]={{"diff_u",up_diff},{"diff_d",down_diff}}; else{ hist_nom=cb.cp().bin({sys->bin()}).process({sys->process()}).GetShape(); hist_nom.Scale(1./hist_nom.Integral());