pyhf icon indicating copy to clipboard operation
pyhf copied to clipboard

repeated modifiers

Open andrewfowlie opened this issue 1 year ago • 2 comments

Summary

Consider this model. It applies two normfactors, one called mu and one called mu2, so the signal channel is scaled signal *= mu * mu2.

{
    "channels": [
        { "name": "singlechannel",
          "samples": [
            { "name": "signal",
              "data": [5.0, 10.0],
              "modifiers": [ { "name": "mu", "type": "normfactor", "data": null}, { "name": "mu2", "type": "normfactor", "data": null} ]
            }
          ]
        }
    ],
    "observations": [
        { "name": "singlechannel", "data": [50.0, 60.0] }
    ],
    "measurements": [
        { "name": "Measurement", "config": {"poi": "mu", "parameters": [{ "name":"mu", "fixed": false}]} }
    ],
    "version": "1.0.0"
}

Now consider correlating them by giving them the same name,

{
    "channels": [
        { "name": "singlechannel",
          "samples": [
            { "name": "signal",
              "data": [5.0, 10.0],
              "modifiers": [ { "name": "mu", "type": "normfactor", "data": null}, { "name": "mu", "type": "normfactor", "data": null} ]
            }
          ]
        }
    ],
    "observations": [
        { "name": "singlechannel", "data": [50.0, 60.0] }
    ],
    "measurements": [
        { "name": "Measurement", "config": {"poi": "mu", "parameters": [{ "name":"mu", "fixed": false}]} }
    ],
    "version": "1.0.0"
}

In this case, we just get signal *= mu, I expected signal *= mu * mu . I guess that inside some dictionary somewhere, the second mu just overwrites the first one.

OS / Environment

PRETTY_NAME="Ubuntu 23.10"
NAME="Ubuntu"
VERSION_ID="23.10"
VERSION="23.10 (Mantic Minotaur)"
VERSION_CODENAME=mantic
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=mantic
LOGO=ubuntu-logo

Steps to Reproduce

{
    "channels": [
        { "name": "singlechannel",
          "samples": [
            { "name": "signal",
              "data": [5.0, 10.0],
              "modifiers": [ { "name": "mu", "type": "normfactor", "data": null}, { "name": "mu", "type": "normfactor", "data": null} ]
            }
          ]
        }
    ],
    "observations": [
        { "name": "singlechannel", "data": [50.0, 60.0] }
    ],
    "measurements": [
        { "name": "Measurement", "config": {"poi": "mu", "parameters": [{ "name":"mu", "fixed": false}]} }
    ],
    "version": "1.0.0"
}

File Upload (optional)

No response

Expected Results

In this case, we just get signal *= mu, I expected signal *= mu * mu , or alternatively warning/exception that the model was not correctly specified & and that the second mu would be ignored.

Actual Results

The mu gets applied just once.

pyhf Version

pyhf, version 0.7.6

Code of Conduct

  • [X] I agree to follow the Code of Conduct

andrewfowlie avatar Nov 14 '24 08:11 andrewfowlie

Not a bug I don't think. This is expected behavior since I believe even ROOT's HistFactory does the same thing (one would need to confirm what the expected behavior should be there). The reason it only treats it as a single µ is because modifiers are identifier by the {TYPE}/{NAME} so in this case, we have normfactor/mu for both so only one gets used, and the other is ignored/overwritten.

However, pyhf should catch this as part of the validation checks its doing and complain about it, presumably.

kratsg avatar Nov 14 '24 12:11 kratsg

Thanks for your prompt response! Yes, I thought something like that might be going on.

However,` pyhf should catch this as part of the validation checks its doing and complain about it, presumably.

If ignoring the second one is the intended interpretation, then yes, that would be great.

This is a smaller reproducible example of behaviour I stumbled across and it had me stumped for a while. I was debugging a different issue, and for simplicity I gave my modifiers all the same name and tried to independently check the result.

andrewfowlie avatar Nov 14 '24 13:11 andrewfowlie