15 print(
"It seems that pyROOT isn't properly configured")
19 Create a HistFactory measurement from python
22 InputFile =
"./data/example.root"
25 meas = ROOT.RooStats.HistFactory.Measurement(
"meas",
"meas")
27 meas.SetOutputFilePrefix(
"./results/example_UsingPy" )
28 meas.SetPOI(
"SigXsecOverSM" )
29 meas.AddConstantParam(
"Lumi")
30 meas.AddConstantParam(
"alpha_syst1")
33 meas.SetLumiRelErr( 0.10 )
34 meas.SetExportOnly(
False )
38 chan = ROOT.RooStats.HistFactory.Channel(
"channel1" )
39 chan.SetData(
"data", InputFile )
40 chan.SetStatErrorConfig( 0.05,
"Poisson" )
45 signal = ROOT.RooStats.HistFactory.Sample(
"signal",
"signal", InputFile )
46 signal.AddOverallSys(
"syst1", 0.95, 1.05 )
47 signal.AddNormFactor(
"SigXsecOverSM", 1, 0, 3 )
48 chan.AddSample( signal )
52 background1 = ROOT.RooStats.HistFactory.Sample(
"background1",
"background1", InputFile )
53 background1.ActivateStatError(
"background1_statUncert", InputFile )
54 background1.AddOverallSys(
"syst2", 0.95, 1.05 )
55 chan.AddSample( background1 )
59 background2 = ROOT.RooStats.HistFactory.Sample(
"background2",
"background2", InputFile )
60 background2.ActivateStatError()
61 background2.AddOverallSys(
"syst3", 0.95, 1.05 )
62 chan.AddSample( background2 )
68 meas.AddChannel( chan )
72 meas.CollectHistograms()
79 meas.PrintXML(
"xmlFromPy", meas.GetOutputFilePrefix() );
82 ROOT.RooStats.HistFactory.MakeModelAndMeasurementFast( meas );
87if __name__ ==
"__main__":