15 print(
"It seems that pyROOT isn't properly configured")
19 Create a HistFactory measurement from python
22 InputFile =
"./data/example.root"
23 if (ROOT.gSystem.AccessPathName(InputFile)) :
24 ROOT.Info(
"example.py", InputFile+
" does not exist")
28 meas = ROOT.RooStats.HistFactory.Measurement(
"meas",
"meas")
30 meas.SetOutputFilePrefix(
"./results/example_UsingPy" )
31 meas.SetPOI(
"SigXsecOverSM" )
32 meas.AddConstantParam(
"Lumi")
33 meas.AddConstantParam(
"alpha_syst1")
36 meas.SetLumiRelErr( 0.10 )
37 meas.SetExportOnly(
False )
41 chan = ROOT.RooStats.HistFactory.Channel(
"channel1" )
42 chan.SetData(
"data", InputFile )
43 chan.SetStatErrorConfig( 0.05,
"Poisson" )
48 signal = ROOT.RooStats.HistFactory.Sample(
"signal",
"signal", InputFile )
49 signal.AddOverallSys(
"syst1", 0.95, 1.05 )
50 signal.AddNormFactor(
"SigXsecOverSM", 1, 0, 3 )
51 chan.AddSample( signal )
55 background1 = ROOT.RooStats.HistFactory.Sample(
"background1",
"background1", InputFile )
56 background1.ActivateStatError(
"background1_statUncert", InputFile )
57 background1.AddOverallSys(
"syst2", 0.95, 1.05 )
58 chan.AddSample( background1 )
62 background2 = ROOT.RooStats.HistFactory.Sample(
"background2",
"background2", InputFile )
63 background2.ActivateStatError()
64 background2.AddOverallSys(
"syst3", 0.95, 1.05 )
65 chan.AddSample( background2 )
71 meas.AddChannel( chan )
75 meas.CollectHistograms()
82 meas.PrintXML(
"xmlFromPy", meas.GetOutputFilePrefix() );
85 ROOT.RooStats.HistFactory.MakeModelAndMeasurementFast( meas );
90if __name__ ==
"__main__":