HistFactory Issue with MakeSingleChannelModel

Dear Experts,

I have been trying to use the RooStats::HistFactory::HistoToWorkspaceFactoryFast::MakeSingleChannelModel()
to create a model from my histograms. However, I have been getting the following error

*** Break *** segmentation violation
[/usr/lib/system/libsystem_platform.dylib] _sigtramp (no debug info)
[<unknown binary>] (no debug info)
[/usr/local/lib/libHistFactory.so] RooStats::HistFactory::HistoToWorkspaceFactoryFast::MakeSingleChannelWorkspace(RooStats::HistFactory::Measurement&, RooStats::HistFactory::Channel&) /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:633
[/usr/local/lib/libHistFactory.so] RooStats::HistFactory::HistoToWorkspaceFactoryFast::MakeSingleChannelModel(RooStats::HistFactory::Measurement&, RooStats::HistFactory::Channel&) /Users/Deshan/ROOT/root-6.14.02/roofit/histfactory/src/HistoToWorkspaceFactoryFast.cxx:256
[<unknown binary>] (no debug info)
[/usr/local/lib/libPyROOT.so] FastCall(long, void*, void*, void*) /Users/Deshan/ROOT/root-6.14.02/bindings/pyroot/src/Cppyy.cxx:407
[/usr/local/lib/libPyROOT.so] Cppyy::CallR(long, void*, void*) /Users/Deshan/ROOT/root-6.14.02/bindings/pyroot/src/Cppyy.cxx:0
[/usr/local/lib/libPyROOT.so] PyROOT::TCppObjectExecutor::Execute(long, void*, PyROOT::TCallContext*) /Users/Deshan/ROOT/root-6.14.02/bindings/pyroot/src/Executors.cxx:73
[/usr/local/lib/libPyROOT.so] PyROOT::TMethodHolder::CallFast(void*, long, PyROOT::TCallContext*) /Users/Deshan/ROOT/root-6.14.02/bindings/pyroot/src/TMethodHolder.cxx:110
[/usr/local/lib/libPyROOT.so] PyROOT::TMethodHolder::CallSafe(void*, long, PyROOT::TCallContext*) /Users/Deshan/ROOT/root-6.14.02/bindings/pyroot/src/TMethodHolder.cxx:122
[/usr/local/lib/libPyROOT.so] PyROOT::TMethodHolder::Execute(void*, long, PyROOT::TCallContext*) /Users/Deshan/ROOT/root-6.14.02/bindings/pyroot/src/TMethodHolder.cxx:0
[/usr/local/lib/libPyROOT.so] PyROOT::TMethodHolder::Call(PyROOT::ObjectProxy*&, _object*, _object*, PyROOT::TCallContext*) /Users/Deshan/ROOT/root-6.14.02/bindings/pyroot/src/TMethodHolder.cxx:585
[/usr/local/lib/libPyROOT.so] PyROOT::(anonymous namespace)::mp_call(PyROOT::MethodProxy*, _object*, _object*) /Users/Deshan/ROOT/root-6.14.02/bindings/pyroot/src/MethodProxy.cxx:598
[/Users/Deshan/anaconda2/lib/libpython2.7.dylib] PyObject_Call (no debug info)
[/Users/Deshan/anaconda2/lib/libpython2.7.dylib] PyEval_EvalFrameEx (no debug info)
[/Users/Deshan/anaconda2/lib/libpython2.7.dylib] PyEval_EvalCodeEx (no debug info)
[/Users/Deshan/anaconda2/lib/libpython2.7.dylib] PyEval_EvalCode (no debug info)
[/Users/Deshan/anaconda2/lib/libpython2.7.dylib] PyRun_FileExFlags (no debug info)
[/Users/Deshan/anaconda2/lib/libpython2.7.dylib] PyRun_SimpleFileExFlags (no debug info)
[/Users/Deshan/anaconda2/lib/libpython2.7.dylib] Py_Main (no debug info)
[/usr/lib/system/libdyld.dylib] start (no debug info)
Traceback (most recent call last):
  File "limittest.py", line 52, in <module>
    w = hist2workspace.MakeSingleChannelModel(meas,chan)
SystemError: RooWorkspace* RooStats::HistFactory::HistoToWorkspaceFactoryFast::MakeSingleChannelModel(RooStats::HistFactory::Measurement& measurement, RooStats::HistFactory::Channel& channel) =>
    problem in C++; program state has been reset

I tried a bit of debugging my self to narrow down the issue. looking at:

[/usr/local/lib/libHistFactory.so] RooStats::HistFactory::HistoToWorkspaceFactoryFast::MakeSingleChannelModel(RooStats::HistFactory::Measurement&, RooStats::HistFactory::Channel&) /Users/Deshan/ROOT/root-6.14.02/roofit/histfactory/src/HistoToWorkspaceFactoryFast.cxx:256

which is at, RooWorkspace* HistoToWorkspaceFactoryFast::MakeSingleChannelWorkspace()
Diving deeper, it looks like it is failing at

channel.GetSamples().at(0).GetHisto()

It looks like there is some issue with the GetHist() from the GetSamples() function. I am unsure why it is failing at this point.

MakeCombinedModel()
It doesn’t seem to have a problem with my inputs and it makes the model correctly and neither does

MakeModelAndMeasurementFast()

I can’t seem to figure out what I am doing wrong. Maybe I am misunderstanding something on how it should be set up? I have included an example code that reproduces the problem, along with my inputs.

Regards,
Deshan

makeModel.py (1.8 KB)
inputSig_pureCI_LL.root (144.3 KB)
sysHist_ee.root (47.8 KB)

Hello Deshan,

This happens because the channel is behaving differently than you expect. It holds names of files and histograms, but it does not actually retrieve them. They are only retrieved when you call chan.CollectHistograms().

You triggered the collection using

meas.CollectHistograms()

but that’s only for the channels inside the measurement. Therefore, MakeCombinedModel works, but the channel being passed to MakeSingleChannelModel is not initialised, yet, because they are all passed by copy.

An easy fix is:

chan.CollectHistograms()
w = hist2workspace.MakeSingleChannelModel(meas,chan)

I will, however, add a function that automatically starts the collection of histograms.

Hey Stephan,

Thant’s quite interesting! Thanks a lot for your suggestion, it works!

Regards,
Deshan