scikit-hep / cabinetry

design and steer profile likelihood fits
https://cabinetry.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
26 stars 21 forks source link

Would like to scan for staterror #410

Open Tomoya-Iizawa opened 1 year ago

Tomoya-Iizawa commented 1 year ago

I would like to see the likelihood scan distribution for staterror by cabinetry.fit.scan function, but it does not work. Does it work only for NormFactors defined in the yml file, or is there any way to check staterror?

I checked it works for the NormFactors defined in the yml file. Also it seems that staterror parameters are added to modifier, as seeing the log INFO - pyhf.pdf - adding modifier staterror_HighMassOSs2thh_1bjets (3 new nuisance parameters) but it fails with error as ValueError: parameter staterror_HighMassOSs2thh_1bjets not found in model

Could you give me some advice for this?

Tomoya

alexander-held commented 1 year ago

Hi Tomoya, the likelihood scan also works for other parameters but this specific case is a bit more tricky to set up. The modifiers staterror (as well as shapesys and shapefactor in pyhf) independently act on every bin in the channels to which they are attached. This means that in your example

INFO - pyhf.pdf - adding modifier staterror_HighMassOSs2thh_1bjets (3 new nuisance parameters)

this channel HighMassOSs2thh_1bjets has three bins and there are actually going to be three independent parameters being created. These parameters will have the respective bin attached to the end of the name, resulting in parameters called staterror_HighMassOSs2thh_1bjets[0], staterror_HighMassOSs2thh_1bjets[1], staterror_HighMassOSs2thh_1bjets[2]. This naming scheme is a convention adopted in pyhf and you can access all names of parameters for reference via model.config.par_names (for a given model) or also from the .labels property in the object returned by cabinetry.fit.fit. The names are also shown in the printed values after running this function (assuming you set a corresponding log level, for example via cabinetry.set_logging()). By using these names you can perform the scan via cabinetry.fit.scan in the same way as with other parameters.

This is all perhaps not very intuitive so I am thinking what we could do to improve this, any suggestions are welcome here. One thing that should be fairly easy to add is a function that checks for this specific case where the bin information via [i] is missing and informs the user that it is required for these specific parameters.

Tomoya-Iizawa commented 1 year ago

Thank you for your advice, I tried staterror_HighMassOSs2thh_1bjets[i] and it works.

alexander-held commented 1 year ago

Glad to hear it is working! I'll leave this issue open for now as a reminder to catch this particular issue with a more helpful error message in cabinetry.