-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[RF] Inconsistent behavior when editing constraint terms in HistFactory models #9070
Description
- Checked for duplicates
Describe the bug
The HistFactory xml specification allows for editing constraint terms of nuisance parameters in the measurement with constructions like:
<ConstraintTerm Type="Uniform" RelativeUncertainty="1">NP_norm</ConstraintTerm>Constraint terms can be removed from OverallSys modifiers, but the same method does not seem to work for HistoSys modifiers (and the setting seems to be silently ignored).
Constraint term "removal" can be achieved by changing the constraint term to be uniform, but RooStats::HistFactory::Measurement::AddNoSyst also provides an alternative method. The xml created from that seems to be incompatible with hist2workspace, as the xml uses NoSyst and hist2workspace seems to (at least parse) NoConstraint instead, but crashes for NoSyst.
Expected behavior
I expect constraint term editing to work for both OverallSys and HistoSys modifiers. Both approaches of changing the constraint term to be uniform and removing it completely should work with hist2workspace.
To Reproduce
Download the required input files from https://cernbox.cern.ch/index.php/s/AO4ruN3G7LNtcRo. They contain a minimal HistFactory workspace specification (xml + ROOT file with histograms) and a simple script to fit the workspace.
Baseline for comparisons
To establish the baseline behavior, run hist2workspace on the provided HistFactory workspace (xml + ROOT) and perform a fit:
cd input
hist2workspace minimal_example.xml
cd ..
root -l -q fit.cxxThe relevant best-fit parameter values are:
NO. NAME VALUE
1 alpha_NP_norm -4.66233e-01
2 alpha_NP_shape -1.70517e-01
3 mu 1.04248e+00OverallSys with uniform constraint [working as expected]
To see the behavior of the OverallSys modifier when removing the associated constraint term, edit the xml and add the ConstraintTerm configuration. The measurement should then look like this:
<Measurement Name="minimal_example" Lumi="1" LumiRelErr="0.1" ExportOnly="True">
<POI>mu</POI>
<ParamSetting Const="True">Lumi</ParamSetting>
<ConstraintTerm Type="Uniform" RelativeUncertainty="1">NP_norm</ConstraintTerm>
</Measurement>Repeat the workspace conversion and fitting:
cd input
hist2workspace minimal_example.xml
cd ..
root -l -q fit.cxxand the result is now
NO. NAME VALUE
1 alpha_NP_norm -6.61703e-01
2 alpha_NP_shape -2.12313e-01
3 mu 1.10747e+00where the pull for alpha_NP_norm has increased, which makes sense given the removal of its constraint term.
HistoSys with uniform constraint [not working as expected]
To see the behavior of the HistoSys modifier when removing the associated constraint term, edit the xml and add the ConstraintTerm configuration for NP_shape. The measurement should then look like this:
<Measurement Name="minimal_example" Lumi="1" LumiRelErr="0.1" ExportOnly="True">
<POI>mu</POI>
<ParamSetting Const="True">Lumi</ParamSetting>
<ConstraintTerm Type="Uniform" RelativeUncertainty="1">NP_shape</ConstraintTerm>
</Measurement>Repeat the workspace conversion and fitting:
cd input
hist2workspace minimal_example.xml
cd ..
root -l -q fit.cxxand the result is again
NO. NAME VALUE
1 alpha_NP_norm -4.66233e-01
2 alpha_NP_shape -1.70517e-01
3 mu 1.04248e+00which is exactly the same as the initial result when
<ConstraintTerm Type="Uniform" RelativeUncertainty="1">NP_shape</ConstraintTerm>was not used. The setting seems to have been ignored.
Using NoSyst [crashing, unexpected behavior in workaround]
In addition to Uniform, NoSyst is also available:
root/roofit/histfactory/src/Measurement.cxx
Lines 401 to 406 in c2c918c
| // NoSyst | |
| for( ConstrItr = fNoSyst.begin(); ConstrItr != fNoSyst.end(); ++ConstrItr ) { | |
| xml << "<ConstraintTerm Type=\"NoSyst\" RelativeUncertainty=\"" | |
| << ConstrItr->second << "\">" << ConstrItr->first | |
| << "</ConstraintTerm>" << std::endl; | |
| } |
When using the following measurement (Uniform replaced by NoSyst):
<Measurement Name="minimal_example" Lumi="1" LumiRelErr="0.1" ExportOnly="True">
<POI>mu</POI>
<ParamSetting Const="True">Lumi</ParamSetting>
<ConstraintTerm Type="NoSyst" RelativeUncertainty="1">NP_norm</ConstraintTerm>
</Measurement>hist2workspace crashes:
[#2] ERROR:HistFactory -- Error: Encountered unknown type for ConstraintTerm: NoSyst
HistFactory - Exception
hist2workspace - Caught Exception: HistFactory - ExceptionIn ConfigParser.cxx, NoConstraint appears:
root/roofit/histfactory/src/ConfigParser.cxx
Lines 509 to 514 in c2c918c
| if (type=="NoConstraint") { | |
| for (vector<string>::const_iterator it=syst.begin(); it!=syst.end(); ++it) { | |
| // Fix Here...? | |
| measurement.GetNoSyst()[(*it).c_str()] = 1.0; // MB : dummy value | |
| } | |
| } |
When using that via
<ConstraintTerm Type="NoConstraint" RelativeUncertainty="1">NP_norm</ConstraintTerm>hist2workspace runs but the parameter for NP_norm disappears from the fit results.
Setup
ROOT 6.24/06 in a container built with Debian 10
Additional context
none