Skip to content

hist2workspace regression (or change) #2570

@kratsg

Description

@kratsg

Summary

When one uses a simple workspace/model like so

{
  "channels": [
    {
      "name": "singlechannel",
      "samples": [
        {
          "name": "signal",
          "data": [12.0, 11.0],
          "modifiers": [
            {
              "name": "mu",
              "type": "normfactor",
              "data": null
            }
          ]
        },
        {
          "name": "background",
          "data": [50.0, 52.0],
          "modifiers": [
            {
              "name": "uncorr_bkguncrt",
              "type": "shapesys",
              "data": [3.0, 7.0]
            }
          ]
        }
      ]
    }
  ],
  "measurements": [
    {
      "config": {
        "parameters": [],
        "poi": "mu"
      },
      "name": "measurement"
    }
  ],
  "observations": [
    {
      "data": [51.0, 48.0],
      "name": "singlechannel"
    }
  ],
  "version": "1.0.0"
}

and converts to XML via pyhf xml2json, the output for the singlechannel channel is

<!DOCTYPE Channel SYSTEM '../HistFactorySchema.dtd'>

<Channel Name="singlechannel" InputFile="/Users/kratsg/pyhs3/tests/test_hifa/foo/data/data.root">
  <Data HistoName="histsinglechannel_data" InputFile="/Users/kratsg/pyhs3/tests/test_hifa/foo/data/data.root">
    </Data>
  <Sample Name="signal" HistoName="histsinglechannel_signal" InputFile="/Users/kratsg/pyhs3/tests/test_hifa/foo/data/data.root" NormalizeByTheory="False">
    <NormFactor Name="mu" Val="1" Low="0" High="10">
     </NormFactor>
    </Sample>
  <Sample Name="background" HistoName="histsinglechannel_background" InputFile="/Users/kratsg/pyhs3/tests/test_hifa/foo/data/data.root" NormalizeByTheory="False">
    <ShapeSys Name="uncorr_bkguncrt" ConstraintType="Poisson" HistoName="histsinglechannel_background_uncorr_bkguncrt">
      </ShapeSys>
    </Sample>
  </Channel>

however, ROOT complains in hist2workspace about some of the above having "declared content" even though it's meant to be empty (weird XML validation going on in ROOT) to the point that one needs to modify the above to

<!DOCTYPE Channel SYSTEM '../HistFactorySchema.dtd'>

<Channel Name="singlechannel" InputFile="/Users/kratsg/pyhs3/tests/test_hifa/foo/data/data.root">
  <Data HistoName="histsinglechannel_data" InputFile="/Users/kratsg/pyhs3/tests/test_hifa/foo/data/data.root"></Data>
  <Sample Name="signal" HistoName="histsinglechannel_signal" InputFile="/Users/kratsg/pyhs3/tests/test_hifa/foo/data/data.root" NormalizeByTheory="False">
    <NormFactor Name="mu" Val="1" Low="0" High="10"></NormFactor>
    </Sample>
  <Sample Name="background" HistoName="histsinglechannel_background" InputFile="/Users/kratsg/pyhs3/tests/test_hifa/foo/data/data.root" NormalizeByTheory="False">
    <ShapeSys Name="uncorr_bkguncrt" ConstraintType="Poisson" HistoName="histsinglechannel_background_uncorr_bkguncrt"></ShapeSys>
    </Sample>
  </Channel>

where the newlines are just removed -- which is rather odd, as XML is not sensitive to newlines typically... I wonder if ROOT has a particular regression here or somehow became even more strict.

OS / Environment

$ system_profiler -detailLevel mini SPSoftwareDataType | head -n 6 | pbcopy
Software:

    System Software Overview:

      System Version: macOS 14.6.1 (23G93)
      Kernel Version: Darwin 23.6.0

$ root --version
ROOT Version: 6.32.06
Built for macosxarm64 on Sep 21 2024, 18:21:53
From tags/6-32-06@6-32-06

Steps to Reproduce

.

File Upload (optional)

No response

Expected Results

.

Actual Results

.

pyhf Version

.

Code of Conduct

  • I agree to follow the Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds-triageNeeds a maintainer to categorize and assign

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions