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

change ValidateDatacards report for 1-bin shapes #332

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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/scripts/ValidateDatacards.py
Original file line number Diff line number Diff line change
Expand Up @@ -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\'")


27 changes: 15 additions & 12 deletions CombineTools/src/ValidationTools.cc
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ void CheckSizeOfShapeEffect(CombineHarvester& cb){
}
if(up_diff<diff_lim && down_diff<diff_lim){
PrintSystematic(sys);
std::cout<<"Uncertainty probably has no genuine shape effect. Summed relative difference per bin between normalised nominal and up shape: "<<up_diff<<" between normalised nominal and down shape: "<<down_diff<<std::endl;
std::cout<<"Uncertainty probably has no genuine shape effect. Summed relative difference per bin between normalised nominal and up shape: "<<up_diff<<" between normalised nominal and down shape: "<<down_diff<<" . If you are using 1-bin shapes you can ignore this warning, but you can consider using lnN instead of a shape uncertainty"<<std::endl;
}
}
});
Expand All @@ -244,19 +244,22 @@ void CheckSizeOfShapeEffect(CombineHarvester& cb, json& jsobj){
if(sys->type()=="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_diff<diff_lim && down_diff<diff_lim) jsobj["smallShapeEff"][sys->name()][sys->bin()][sys->process()]={{"diff_u",up_diff},{"diff_d",down_diff}};
}
if(up_diff<diff_lim && down_diff<diff_lim) jsobj["smallShapeEff"][sys->name()][sys->bin()][sys->process()]={{"diff_u",up_diff},{"diff_d",down_diff}};
}
});
}
Expand Down