try:
import ROOT
except:
print("It seems that pyROOT isn't properly configured")
return
"""
Create a HistFactory measurement from python
"""
InputFile = "./data/example.root"
meas = ROOT.RooStats.HistFactory.Measurement("meas", "meas")
meas.SetOutputFilePrefix( "./results/example_UsingPy" )
meas.SetPOI( "SigXsecOverSM" )
meas.AddConstantParam("Lumi")
meas.AddConstantParam("alpha_syst1")
meas.SetLumi( 1.0 )
meas.SetLumiRelErr( 0.10 )
meas.SetExportOnly( False )
chan = ROOT.RooStats.HistFactory.Channel( "channel1" )
chan.SetData( "data", InputFile )
chan.SetStatErrorConfig( 0.05, "Poisson" )
signal = ROOT.RooStats.HistFactory.Sample( "signal", "signal", InputFile )
signal.AddOverallSys( "syst1", 0.95, 1.05 )
signal.AddNormFactor( "SigXsecOverSM", 1, 0, 3 )
chan.AddSample( signal )
background1 = ROOT.RooStats.HistFactory.Sample( "background1", "background1", InputFile )
background1.ActivateStatError( "background1_statUncert", InputFile )
background1.AddOverallSys( "syst2", 0.95, 1.05 )
chan.AddSample( background1 )
background2 = ROOT.RooStats.HistFactory.Sample( "background2", "background2", InputFile )
background2.ActivateStatError()
background2.AddOverallSys( "syst3", 0.95, 1.05 )
chan.AddSample( background2 )
meas.AddChannel( chan )
meas.CollectHistograms()
meas.PrintTree();
meas.PrintXML( "xmlFromPy", meas.GetOutputFilePrefix() );
ROOT.RooStats.HistFactory.MakeModelAndMeasurementFast( meas );
pass
if __name__ == "__main__":
int main(int argc, char **argv)
␛[1mRooFit v3.60 -- Developed by Wouter Verkerke and David Kirkby␛[0m
Copyright (C) 2000-2013 NIKHEF, University of California & Stanford University
All rights reserved, please read http://roofit.sourceforge.net/license.txt
[#2] PROGRESS:HistFactory -- Getting histogram ./data/example.root:/data
[#2] ERROR:HistFactory -- Error: Unable to open input file: ./data/example.root