from ROOT import * # Model built with Low Level Factory export_namespace=True w = RooWorkspace("CMGWs",export_namespace) w.factory("Gaussian::signal(imass[110,120],sigmean[115,105,120],sigwidth[1])") w.factory("Exponential::background(imass,exppar[-.1,-1,0])") w.factory("SUM::modelbase(nsig[50,0,120]*signal,nbkg[1000,0,10000]*background)") w.factory("Gaussian::nbkgConstraint(nbkg,1000,1)") # 0.1% background uncertainty w.factory("PROD::model(modelbase,nbkgConstraint)") #implement a systematic # Promote everithing to global scope # You could have accessed everithing via CMGWs. for name,obj in CMGWs.__dict__.items(): if type(obj) == PropertyProxy: exec("%s=CMGWs.%s" %(name,name)) imass.setBins(30) # Create an example dataset (binned is fast..) data = CMGWs.model.generateBinned(RooArgSet(imass)) # Model Config modelConfig = RooStats.ModelConfig(w) modelConfig.SetPdf(model) modelConfig.SetParametersOfInterest(RooArgSet(nsig)) # Let's use a Calculator based on the Profile Likelihood Ratio CL = .68; size = 1-CL # size of the test plc=RooStats.ProfileLikelihoodCalculator(data,modelConfig,size) lrint = plc.GetInterval() # Calculate the significance: SL2 estimator nsig.setVal(0) plc.SetNullParameters(RooArgSet(nsig)) SL2 = plc.GetHypoTest().Significance() print "Limits [%.2f-%.2f] - Significance %.2f" %(lrint.LowerLimit(nsig),lrint.UpperLimit(nsig),SL2) raw_input ("Press a key to continue")