Hello,
I am trying to make a workspace for data, signal and bkg using 2D histograms in with HistFactory
My python code crashes however and I suspect the problem is a simple one to solve as I get errors like this one:
[#0] ERROR:ObjectHandling – RooWorkSpace::import(chanGLR2d) ERROR importing object named mtt_costhetastar_r_chanGLR2d_epsilon: another instance with same name already in the workspace and no conflict resolution protocol specified
Given that I am new to HistFactory and RootStats I am confident, my mistake is probably an obvious one. I would definitely appreciate some help to speed things up and get the result going.
Below I ass ) 1 the python code 2) the log file of the output and the crash.
Best,
Francesco
=====================python CODE==============================
#!/usr/bin/env python
A pyROOT script demonstrating
an example of writing a HistFactory
model using python
This example was written to match
the example.xml analysis in
$ROOTSYS/tutorials/histfactory/
Written by George Lewis
For the analysis: we nee dto generate the model
generate the associated data set
then pass the dataset and the model to the calculator so generate the model and save it in a workspace
upload the workspace to teh clculator and clauclate significance
def main():
try:
import ROOT
except:
print "It seems that pyROOT isn't properly configured"
return
"""
Create a HistFactory measurement from python
"""
InputFile = “./data/example.root”
InputDataFile = "./data/GLR-R-3_ggqq-GAZX-tt-bbllvv_2-4_5x10M.a.L100.2D.root"
InputSigFile = "./data/GRLMinusSM_ggqq-GAZ-tt-bbllvv_2-4_5x10M.a.L100.2D.root"
InputBkgFile = "./data/SM_ggqq-GAZ-tt-bbllvv_2-4_5x10M.a.L100.2D.root"
# Create the measurement
meas2d = ROOT.RooStats.HistFactory.Measurement("meas", "meas")
meas2d.SetOutputFilePrefix("./results/example_2dPy")
#o.k.
meas2d.SetPOI("SigXsecOverSM2d")
#o.k.
meas2d.AddConstantParam("Lumi")
set luminosity to 1 : assume everything is normalized to lumi
meas2d.SetLumi(1.0)
10%uncertainty is even too much, but to startwith…
meas2d.SetLumiRelErr(0.10)
to be understood
meas2d.SetExportOnly(False)
# Create two channels
chan2d = ROOT.RooStats.HistFactory.Channel("chanGLR2d")
this one needs the data histogram
chan2d.SetData("mtt_costhetastar_r", InputDataFile)
chan2d.SetStatErrorConfig(0.001, "Poisson")
# Now, create some samples
# Create the signal samples
signal2d = ROOT.RooStats.HistFactory.Sample("mtt_costhetastar_r", "mtt_costhetastar_r", InputSigFile)
signal2d.AddNormFactor("SigXsecOverSM2d", 1, 0, 4)
chan2d.AddSample(signal2d)
Background 2d
background2d = ROOT.RooStats.HistFactory.Sample("mtt_costhetastar_r","mtt_costhetastar_r", InputBkgFile)
background2d.ActivateStatError(“background1_statUncert”, InputBKgFile)
chan2d.AddSample(background2d)
# Add it to the measurement:
meas2d.AddChannel(chan2d)
# Collect the histograms from their files,
# print some output,
meas2d.CollectHistograms()
meas2d.PrintTree();
One can print XML code to an
output directory:
meas2d.PrintXML("xml2dFromPy", meas2d.GetOutputFilePrefix());
# Now, do the measurement i.e. change iny a Worksspace
ROOT.RooStats.HistFactory.MakeModelAndMeasurementFast(meas2d);
pass
if name == “main”:
main()
================LOG FILE======================================
macbookspano2016:HistDIrectory francescospano$ python runSigZPrimeV2.py
RooFit v3.60 – Developed by Wouter Verkerke and David Kirkby
Copyright © 2000-2013 NIKHEF, University of California & Stanford University
All rights reserved, please read roofit.sourceforge.net/license.txt
Getting histogram. InputFile ./data/GLR-R-3_ggqq-GAZX-tt-bbllvv_2-4_5x10M.a.L100.2D.root HistoPath HistoName mtt_costhetastar_r
Opened input file: ./data/GLR-R-3_ggqq-GAZX-tt-bbllvv_2-4_5x10M.a.L100.2D.root: 0x7fd6853ee730
Collecting Nominal Histogram
Getting histogram. InputFile ./data/GRLMinusSM_ggqq-GAZ-tt-bbllvv_2-4_5x10M.a.L100.2D.root HistoPath HistoName mtt_costhetastar_r
Opened input file: ./data/GRLMinusSM_ggqq-GAZ-tt-bbllvv_2-4_5x10M.a.L100.2D.root: 0x7fd6854b0b40
Collecting Nominal Histogram
Getting histogram. InputFile ./data/SM_ggqq-GAZ-tt-bbllvv_2-4_5x10M.a.L100.2D.root HistoPath HistoName mtt_costhetastar_r
Opened input file: ./data/SM_ggqq-GAZ-tt-bbllvv_2-4_5x10M.a.L100.2D.root: 0x7fd682f75bf0
Measurement Name: meas OutputFilePrefix: ./results/example_2dPy POI: SigXsecOverSM2d Lumi: 1 LumiRelErr: 0.1 BinLow: 0 BinHigh: 1 ExportOnly: 0
Constant Params: Lumi
Channels:
Channel Name: chanGLR2d InputFile:
Data:
InputFile: ./data/GLR-R-3_ggqq-GAZX-tt-bbllvv_2-4_5x10M.a.L100.2D.root HistoName: mtt_costhetastar_r HistoPath: HistoAddress: 0x7fd685792020
statErrorConfig:
RelErrorThreshold: 0.001 ConstraintType: Poisson
Samples:
Name: mtt_costhetastar_r Channel: chanGLR2d NormalizeByTheory: True StatErrorActivate: False
InputFile: ./data/GRLMinusSM_ggqq-GAZ-tt-bbllvv_2-4_5x10M.a.L100.2D.root HistName: mtt_costhetastar_r HistoPath: HistoAddress: 0x7fd682f8ddf0
Name: mtt_costhetastar_r Channel: chanGLR2d NormalizeByTheory: True StatErrorActivate: False
InputFile: ./data/SM_ggqq-GAZ-tt-bbllvv_2-4_5x10M.a.L100.2D.root HistName: mtt_costhetastar_r HistoPath: HistoAddress: 0x7fd68572d150
End of Channel chanGLR2d
End Measurement: meas
Printing XML Files for measurement: meas
Printing XML Files for channel: chanGLR2d
Finished printing XML files
Finished printing XML files
Making Model and Measurements (Fast) for measurement: meas
using lumi = 1 and lumiError = 0.1 including bins between 0 and 1
fixing the following parameters:
Lumi
Checking if output directory : ./results - exists
Creating the output file: ./results/example_2dPy_meas.root
Creating the table file: ./results/example_2dPy_results.table
Creating the HistoToWorkspaceFactoryFast factory
Setting preprocess functions
Starting to process channel: chanGLR2d
Starting to process chanGLR2d channel with 2 observables
lumi str = [1,0,10]
lumi Error str = nominalLumi[1,0,2],0.1
[#1] INFO:ObjectHandling – RooWorkspace::import(chanGLR2d) importing RooConstVar::mtt_costhetastar_r_chanGLR2d_epsilon
making normFactor: SigXsecOverSM2d
mtt_costhetastar_r_chanGLR2d has no variation histograms
processing hist mtt_costhetastar_r
[#1] INFO:DataHandling – RooDataHist::adjustBinning(mtt_costhetastar_r_chanGLR2dnominalDHist): fit range of variable obs_x_chanGLR2d expanded to nearest bin boundaries: [2.025,3.975] --> [2.025,3.975]
[#1] INFO:DataHandling – RooDataHist::adjustBinning(mtt_costhetastar_r_chanGLR2dnominalDHist): fit range of variable obs_y_chanGLR2d expanded to nearest bin boundaries: [-1,1] --> [-1,1]
[#1] INFO:ObjectHandling – RooWorkspace::import(chanGLR2d) importing dataset mtt_costhetastar_r_chanGLR2dnominalDHist
[#1] INFO:ObjectHandling – RooWorkspace::import(chanGLR2d) importing RooHistFunc::mtt_costhetastar_r_chanGLR2d_nominal
[#0] ERROR:ObjectHandling – RooWorkSpace::import(chanGLR2d) ERROR importing object named mtt_costhetastar_r_chanGLR2d_epsilon: another instance with same name already in the workspace and no conflict resolution protocol specified
mtt_costhetastar_r_chanGLR2d has no variation histograms
processing hist mtt_costhetastar_r
[#1] INFO:DataHandling – RooDataHist::adjustBinning(mtt_costhetastar_r_chanGLR2dnominalDHist): fit range of variable obs_x_chanGLR2d expanded to nearest bin boundaries: [2.025,3.975] --> [2.025,3.975]
[#1] INFO:DataHandling – RooDataHist::adjustBinning(mtt_costhetastar_r_chanGLR2dnominalDHist): fit range of variable obs_y_chanGLR2d expanded to nearest bin boundaries: [-1,1] --> [-1,1]
[#0] ERROR:ObjectHandling – RooWorkSpace::import(chanGLR2d) ERROR importing object named mtt_costhetastar_r_chanGLR2d_nominal: another instance with same name already in the workspace and no conflict resolution protocol specified
[#0] ERROR:ObjectHandling – RooWorkSpace::import(chanGLR2d) ERROR importing object named mtt_costhetastar_r_chanGLR2d_overallSyst_x_Exp: another instance with same name already in the workspace and no conflict resolution protocol specified
[#0] ERROR:ObjectHandling – RooFactoryWSTool::processExpression() ERRORS detected, transaction to workspace aborted, no objects committed
[#1] INFO:ObjectHandling – RooWorkSpace::import(chanGLR2d) Recycling existing object L_x_mtt_costhetastar_r_chanGLR2d_overallSyst_x_Exp created with identical factory specification
[#0] ERROR:InputArguments – RooRealSumPdf::RooRealSumPdf(chanGLR2d_model) number of pdfs and coefficients inconsistent, must have Nfunc=Ncoef or Nfunc=Ncoef+1
*** Break *** segmentation violation
[#0] WARNING:InputArguments – RooRealSumPdf::RooRealSumPdf(chanGLR2d_model) func Generating stack trace…
atos[71668]: atos cannot examine process 71659 (Python) for unknown reasons, even though it appears to exist; try running with sudo
.
0x000000011799396a in _ZN8RooStats11HistFactory27HistoToWorkspaceFactoryFast26MakeSingleChannelWorkspaceERNS0_11MeasurementERNS0_7ChannelE + 0x48ba from /Applications/root_v6.06.02/lib/libHistFactory.so
atos[71670]: atos cannot examine process 71659 (Python) for unknown reasons, even though it appears to exist; try running with sudo
.
0x000000011798eee0 in _ZN8RooStats11HistFactory27HistoToWorkspaceFactoryFast22MakeSingleChannelModelERNS0_11MeasurementERNS0_7ChannelE + 0x30 from /Applications/root_v6.06.02/lib/libHistFactory.so
atos[71672]: atos cannot examine process 71659 (Python) for unknown reasons, even though it appears to exist; try running with sudo
.
0x00000001179b0a41 in _ZN8RooStats11HistFactory27MakeModelAndMeasurementFastERNS0_11MeasurementE + 0xcb1 from /Applications/root_v6.06.02/lib/libHistFactory.so
0x0000000118fa1039 in
atos[71674]: atos cannot examine process 71659 (Python) for unknown reasons, even though it appears to exist; try running with sudo
.
0x00000001069fc21d in Z8FastCalllPvS_S + 0xf3d from /Applications/root_v6.06.02/lib/libPyROOT.so
atos[71676]: atos cannot examine process 71659 (Python) for unknown reasons, even though it appears to exist; try running with sudo
.
0x00000001069fc772 in ZN5Cppyy5CallRElPvS0 + 0x22 from /Applications/root_v6.06.02/lib/libPyROOT.so
atos[71678]: atos cannot examine process 71659 (Python) for unknown reasons, even though it appears to exist; try running with sudo
.
0x0000000106a037d5 in _ZN6PyROOT18TCppObjectExecutor7ExecuteElPvPNS_12TCallContextE + 0x55 from /Applications/root_v6.06.02/lib/libPyROOT.so
atos[71680]: atos cannot examine process 71659 (Python) for unknown reasons, even though it appears to exist; try running with sudo
.
0x0000000106a1f624 in _ZN6PyROOT13TMethodHolder8CallFastEPvlPNS_12TCallContextE + 0x24 from /Applications/root_v6.06.02/lib/libPyROOT.so
atos[71682]: atos cannot examine process 71659 (Python) for unknown reasons, even though it appears to exist; try running with sudo
.
0x0000000106a1f9d7 in _ZN6PyROOT13TMethodHolder8CallSafeEPvlPNS_12TCallContextE + 0xb7 from /Applications/root_v6.06.02/lib/libPyROOT.so
atos[71684]: atos cannot examine process 71659 (Python) for unknown reasons, even though it appears to exist; try running with sudo
.
0x0000000106a1f35e in _ZN6PyROOT13TMethodHolder7ExecuteEPvlPNS_12TCallContextE + 0x2e from /Applications/root_v6.06.02/lib/libPyROOT.so
atos[71686]: atos cannot examine process 71659 (Python) for unknown reasons, even though it appears to exist; try running with sudo
.
0x0000000106a06907 in ZN6PyROOT12_GLOBAL__N_17mp_callEPNS_11MethodProxyEP7_objectS4 + 0xe7 from /Applications/root_v6.06.02/lib/libPyROOT.so
atos[71688]: atos cannot examine process 71659 (Python) for unknown reasons, even though it appears to exist; try running with sudo
.
0x00000001064ae202 in PyObject_Call + 0x63 from /System/Library/Frameworks/Python.framework/Versions/2.7/Python
atos[71690]: atos cannot examine process 71659 (Python) for unknown reasons, even though it appears to exist; try running with sudo
.
0x0000000106529e37 in PyEval_EvalFrameEx + 0x2884 from /System/Library/Frameworks/Python.framework/Versions/2.7/Python
atos[71692]: atos cannot examine process 71659 (Python) for unknown reasons, even though it appears to exist; try running with sudo
.
0x000000010652d541 in _PyEval_SliceIndex + 0x1e9 from /System/Library/Frameworks/Python.framework/Versions/2.7/Python
atos[71694]: atos cannot examine process 71659 (Python) for unknown reasons, even though it appears to exist; try running with sudo
.
0x000000010652a30c in PyEval_EvalFrameEx + 0x2d59 from /System/Library/Frameworks/Python.framework/Versions/2.7/Python
atos[71696]: atos cannot examine process 71659 (Python) for unknown reasons, even though it appears to exist; try running with sudo
.
0x00000001065273c1 in PyEval_EvalCodeEx + 0x62f from /System/Library/Frameworks/Python.framework/Versions/2.7/Python
atos[71698]: atos cannot examine process 71659 (Python) for unknown reasons, even though it appears to exist; try running with sudo
.
0x0000000106526d8c in PyEval_EvalCode + 0x36 from /System/Library/Frameworks/Python.framework/Versions/2.7/Python
atos[71700]: atos cannot examine process 71659 (Python) for unknown reasons, even though it appears to exist; try running with sudo
.
0x0000000106546a42 in PyParser_ASTFromFile + 0x12c from /System/Library/Frameworks/Python.framework/Versions/2.7/Python
atos[71702]: atos cannot examine process 71659 (Python) for unknown reasons, even though it appears to exist; try running with sudo
.
0x0000000106546ae5 in PyRun_FileExFlags + 0x85 from /System/Library/Frameworks/Python.framework/Versions/2.7/Python
atos[71704]: atos cannot examine process 71659 (Python) for unknown reasons, even though it appears to exist; try running with sudo
.
0x0000000106546634 in PyRun_SimpleFileExFlags + 0x2ba from /System/Library/Frameworks/Python.framework/Versions/2.7/Python
atos[71706]: atos cannot examine process 71659 (Python) for unknown reasons, even though it appears to exist; try running with sudo
.
0x0000000106558011 in Py_Main + 0xc41 from /System/Library/Frameworks/Python.framework/Versions/2.7/Python
atos[71708]: atos cannot examine process 71659 (Python) for unknown reasons, even though it appears to exist; try running with sudo
.
0x00007fff848d15ad in start + 0x1 from /usr/lib/system/libdyld.dylib
Traceback (most recent call last):
File “runSigZPrimeV2.py”, line 147, in
main()
File “runSigZPrimeV2.py”, line 141, in main
ROOT.RooStats.HistFactory.MakeModelAndMeasurementFast(meas2d);
SystemError: RooWorkspace* RooStats::HistFactory::MakeModelAndMeasurementFast(RooStats::HistFactory::Measurement& measurement) =>
problem in C++; program state has been reset
macbookspano2016:HistDIrectory francescospano$