当前位置: 首页>>代码示例>>Python>>正文


Python RooAddPdf.fixAddCoefRange方法代码示例

本文整理汇总了Python中ROOT.RooAddPdf.fixAddCoefRange方法的典型用法代码示例。如果您正苦于以下问题:Python RooAddPdf.fixAddCoefRange方法的具体用法?Python RooAddPdf.fixAddCoefRange怎么用?Python RooAddPdf.fixAddCoefRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ROOT.RooAddPdf的用法示例。


在下文中一共展示了RooAddPdf.fixAddCoefRange方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: RooRealVar

# 需要导入模块: from ROOT import RooAddPdf [as 别名]
# 或者: from ROOT.RooAddPdf import fixAddCoefRange [as 别名]
nGauss14 =  RooRealVar("nGauss14", "Gauss 14 ext normalization",  2000,  0., 6000)
gauss14_ext = RooExtendPdf("gauss14_ext",  "extended p.d.f", gauss14,  nGauss14)

nGauss15 =  RooRealVar("nGauss15", "Gauss 15 ext normalization",  1000,  0., 6000)
gauss15_ext = RooExtendPdf("gauss15_ext",  "extended p.d.f", gauss15,  nGauss15)

#nGauss15.setVal(nDataGauss_right_SB)
nGauss15.setVal( n_generate*(1-frac_combine4.getVal() ) )
nGauss15.setConstant(True)

# comine ext PDF

pdf_ext_combine5 = RooAddPdf("pdf_ext_combine5"," gauss14_ext + gauss15_ext ", RooArgList(gauss14_ext , gauss15_ext ), RooArgList( nGauss14 , nGauss15 ))

pdf_ext_combine5.fixAddCoefRange("whole_range")

# fit

#pdf_ext_combine5.fitTo(data4, RooFit.Range("whole_range") )
pdf_ext_combine5.fitTo(data4_SB, RooFit.Range("left_side_band_region,right_side_band_region") )

print ""
print "after fit"
print "nGauss14: ", nGauss14.getVal()
print "nGauss15: ", nGauss15.getVal()
print "nGauss14 + nGauss15: ", nGauss14.getVal() + nGauss15.getVal()
print ""

# plot
#gauss12.plotOn(xframe8, RooFit.Normalization( n_generate * frac_combine4.getVal()   ,RooAbsReal.NumEvent),RooFit.LineColor(RooFit.kOrange))
开发者ID:wvieri,项目名称:new_git,代码行数:32,代码来源:test_fit_SB_plot.py

示例2: alpha

# 需要导入模块: from ROOT import RooAddPdf [as 别名]
# 或者: from ROOT.RooAddPdf import fixAddCoefRange [as 别名]

#.........这里部分代码省略.........
    frTop = modelTop.fitTo(setTop, RooFit.SumW2Error(True), RooFit.Range("h_reasonable_range"), RooFit.Strategy(2), RooFit.Minimizer("Minuit2"), RooFit.Save(1), RooFit.PrintLevel(1 if VERBOSE else -1))
    
    # integrals and number of events
    iSBTop = modelTop.createIntegral(jetMassArg, RooFit.NormSet(jetMassArg), RooFit.Range("LSBrange,HSBrange"))
    iLSBTop = modelTop.createIntegral(jetMassArg, RooFit.NormSet(jetMassArg), RooFit.Range("LSBrange"))
    iHSBTop = modelTop.createIntegral(jetMassArg, RooFit.NormSet(jetMassArg), RooFit.Range("HSBrange"))
    iSRTop = modelTop.createIntegral(jetMassArg, RooFit.NormSet(jetMassArg), RooFit.Range("SRrange"))
    iVRTop = modelTop.createIntegral(jetMassArg, RooFit.NormSet(jetMassArg), RooFit.Range("VRrange"))
    # Do not remove the following lines, integrals are computed here
    iALTop = modelTop.createIntegral(jetMassArg, RooFit.NormSet(jetMassArg))
    nSBTop = iSBTop.getVal()/iALTop.getVal()*setTop.sumEntries(SBcut)
    nLSBTop = iLSBTop.getVal()/iALTop.getVal()*setTop.sumEntries(LSBcut)
    nHSBTop = iHSBTop.getVal()/iALTop.getVal()*setTop.sumEntries(HSBcut)
    nSRTop = iSRTop.getVal()/iALTop.getVal()*setTop.sumEntries(SRcut)
    
    drawPlot("JetMass_Top", channel, J_mass, modelTop, setTop, binsJmass, frTop)
    
    if VERBOSE: print "********** Fit result [JET MASS TOP] ***"+"*"*40, "\n", frTop.Print(), "\n", "*"*80
    
    #*******************************************************#
    #                                                       #
    #                 All bkg normalization                 #
    #                                                       #
    #*******************************************************#
    
    constVjet.setConstant(True)
    offsetVjet.setConstant(True)
    widthVjet.setConstant(True)
    a0Vjet.setConstant(True)
    a1Vjet.setConstant(True)
    a2Vjet.setConstant(True)
    
    constVV.setConstant(True)
    offsetVV.setConstant(True)
    widthVV.setConstant(True)
    meanVV.setConstant(True)
    sigmaVV.setConstant(True)
    fracVV.setConstant(True)
    meanVH.setConstant(True)
    sigmaVH.setConstant(True)
    fracVH.setConstant(True)
    
    constTop.setConstant(True)
    offsetTop.setConstant(True)
    widthTop.setConstant(True)
    meanW.setConstant(True)
    sigmaW.setConstant(True)
    fracW.setConstant(True)
    meanT.setConstant(True)
    sigmaT.setConstant(True)
    fracT.setConstant(True)
    
    
    # Final background model by adding the main+secondary pdfs (using 'coef': ratio of the secondary/main, from MC)
    model = RooAddPdf("model", "model", RooArgList(modelTop, modelVV, modelVjet), RooArgList(coef_Top_VVVjet, coef_VV_Vjet))#FIXME
    model.fixAddCoefRange("h_reasonable_range")
    
    # Extended fit model to data in SB
    # all the 3 sidebands (Low / High / the 2 combined) could be used
    # currently using the LOW+HIGH (the others are commented out)
    yieldLSB = RooRealVar("yieldLSB", "Lower SB normalization",  10, 0., 1.e6)
    yieldHSB = RooRealVar("yieldHSB", "Higher SB normalization", 10, 0., 1.e6)
    yieldSB  = RooRealVar("yieldSB",  "All SB normalization",    10, 0., 1.e6)
    #model_ext = RooExtendPdf("model_ext", "extended p.d.f",   model,  yieldLSB)
    #model_ext = RooExtendPdf("model_ext", "extended p.d.f",   model,  yieldHSB)
    model_ext = RooExtendPdf("model_ext", "extended p.d.f",   model,  yieldSB)
    #frMass = model_ext.fitTo(setDataSB, RooFit.ConditionalObservables(RooArgSet(J_mass)),RooFit.SumW2Error(True),RooFit.Extended(True),RooFit.Range("LSBrange"),RooFit.PrintLevel(-1))
    #frMass = model_ext.fitTo(setDataSB, RooFit.ConditionalObservables(RooArgSet(J_mass)),RooFit.SumW2Error(True),RooFit.Extended(True),RooFit.Range("HSBrange"),RooFit.PrintLevel(-1))
    #frMass = model_ext.fitTo(setDataSB, RooFit.ConditionalObservables(RooArgSet(J_mass)), RooFit.SumW2Error(True), RooFit.Extended(True), RooFit.Range("LSBrange,HSBrange"), RooFit.Strategy(2), RooFit.Minimizer("Minuit2"), RooFit.PrintLevel(1 if VERBOSE else -1))
    
    #print "********** Fit result [JET MASS DATA] **"+"*"*40
    #print frMass.Print()
    #print "*"*80
    
    # Calculate integral of the model obtained from the fit to data (fraction of PDF that is within a given region)
    #nSB = model_ext.createIntegral(jetMassArg, RooFit.NormSet(jetMassArg), RooFit.Range("LSBrange,HSBrange"))
    #nSB = model_ext.createIntegral(jetMassArg, RooFit.NormSet(jetMassArg), RooFit.Range("LSBrange"))
    #nSB = model_ext.createIntegral(jetMassArg, RooFit.NormSet(jetMassArg), RooFit.Range("HSBrange"))
    #nSR = model_ext.createIntegral(jetMassArg, RooFit.NormSet(jetMassArg), RooFit.Range("SRrange"))
    #nVR = model_ext.createIntegral(jetMassArg, RooFit.NormSet(jetMassArg), RooFit.Range("VRrange"))
    
    # scale the yieldSB from SB to SR using the ratio of the PDFs defined by the two integrals
    SRyield = RooFormulaVar("SRyield", "extrapolation to SR","(@[email protected]*@[email protected]*@4) * @5/@6 [email protected]*@[email protected]*@8", RooArgList(entrySB, entryVV, entryTop, iSBVV, iSBTop, iSRVjet, iSBVjet, iSRVV, iSRTop))
    VRyield = RooFormulaVar("VRyield", "extrapolation to VR","(@[email protected]*@[email protected]*@4) * @5/@6 [email protected]*@[email protected]*@8", RooArgList(entrySB, entryVV, entryTop, iSBVV, iSBTop, iVRVjet, iSBVjet, iVRVV, iVRTop))
    HSByield = RooFormulaVar("SRyield", "extrapolation to SR","(@[email protected]*@[email protected]*@4) * @5/@6 [email protected]*@[email protected]*@8", RooArgList(entryLSB, entryVV, entryTop, iLSBVV, iLSBTop, iHSBVjet, iLSBVjet, iHSBVV, iHSBTop))
    #   RooFormulaVar SRyield("SRyield","extrapolation to SR","(@0/@1)*@2",RooArgList(*nSR,*nSB,yieldLowerSB))
    #   RooFormulaVar SRyield("SRyield","extrapolation to SR","(@0/@1)*@2",RooArgList(*nSR,*nSB,yieldHigherSB))
    #SRyield = RooFormulaVar("SRyield", "extrapolation to SR","(@0/@1)*@2", RooArgList(nSR, nSB, entrySB))
    
    bkgYield            = SRyield.getVal()
    bkgYield_error      = math.sqrt(SRyield.getPropagatedError(frVjet)**2 + SRyield.getPropagatedError(frVV)**2 + SRyield.getPropagatedError(frTop)**2 + (entrySB.getError()*rSBSRVV)**2)
    bkgNorm             = entrySB.getVal() + SRyield.getVal() + VRyield.getVal()
    bkgYield_eig_norm   = RooRealVar("predSR_eig_norm", "expected yield in SR", bkgYield, 0., 1.e6)
    bkgYieldExt         = HSByield.getVal()
    
    drawPlot("JetMass", channel, J_mass, model, setDataSB, binsJmass, None, None, "", bkgNorm, True)

    
    print channel, "normalization = %.3f +/- %.3f, observed = %.0f" % (bkgYield, bkgYield_error, setDataSR.sumEntries() if not BLIND else -1)
    if VERBOSE: raw_input("Press Enter to continue...")
开发者ID:wvieri,项目名称:new_git,代码行数:104,代码来源:alpha.py

示例3: alpha

# 需要导入模块: from ROOT import RooAddPdf [as 别名]
# 或者: from ROOT.RooAddPdf import fixAddCoefRange [as 别名]

#.........这里部分代码省略.........
    meanVV.setConstant(True)
    sigmaVV.setConstant(True)
    fracVV.setConstant(True)
    meanVH.setConstant(True)
    sigmaVH.setConstant(True)
    fracVH.setConstant(True)

    constTop.setConstant(True)
    offsetTop.setConstant(True)
    widthTop.setConstant(True)
    meanW.setConstant(True)
    sigmaW.setConstant(True)
    fracW.setConstant(True)
    meanT.setConstant(True)
    sigmaT.setConstant(True)
    fracT.setConstant(True)

    nVV.setConstant(True)
    nTop.setConstant(True)
    nVjet.setConstant(False)
    nVjet2.setConstant(False)

    # Final background model by adding the main+secondary pdfs (using 'coef': ratio of the secondary/main, from MC)
    TopMass_ext = RooExtendPdf("TopMass_ext", "extended p.d.f", TopMass, nTop)
    VVMass_ext = RooExtendPdf("VVMass_ext", "extended p.d.f", VVMass, nVV)
    VjetMass_ext = RooExtendPdf("VjetMass_ext", "extended p.d.f", VjetMass, nVjet)
    VjetMass2_ext = RooExtendPdf("VjetMass_ext", "extended p.d.f", VjetMass, nVjet2)
    BkgMass = RooAddPdf(
        "BkgMass", "BkgMass", RooArgList(TopMass_ext, VVMass_ext, VjetMass_ext), RooArgList(nTop, nVV, nVjet)
    )
    BkgMass2 = RooAddPdf(
        "BkgMass2", "BkgMass2", RooArgList(TopMass_ext, VVMass_ext, VjetMass2_ext), RooArgList(nTop, nVV, nVjet2)
    )
    BkgMass.fixAddCoefRange("h_reasonable_range")
    BkgMass2.fixAddCoefRange("h_reasonable_range")

    # Extended fit model to data in SB
    frMass = BkgMass.fitTo(
        setDataSB,
        RooFit.SumW2Error(True),
        RooFit.Extended(True),
        RooFit.Range("LSBrange,HSBrange"),
        RooFit.Strategy(2),
        RooFit.Minimizer("Minuit"),
        RooFit.Save(1),
        RooFit.PrintLevel(1 if VERBOSE else -1),
    )  # , RooFit.NumCPU(10)
    if VERBOSE:
        print "********** Fit result [JET MASS DATA] **" + "*" * 40, "\n", frMass.Print(), "\n", "*" * 80
    frMass2 = BkgMass2.fitTo(
        setDataSB,
        RooFit.SumW2Error(True),
        RooFit.Extended(True),
        RooFit.Range("LSBrange,HSBrange"),
        RooFit.Strategy(2),
        RooFit.Minimizer("Minuit"),
        RooFit.Save(1),
        RooFit.PrintLevel(1 if VERBOSE else -1),
    )
    if VERBOSE:
        print "********** Fit result [JET MASS DATA] **" + "*" * 40, "\n", frMass2.Print(), "\n", "*" * 80

    # if SCAN:
    #    likelihoodScan(VjetMass, setVjet, [constVjet, offsetVjet, widthVjet])

    # Fix normalization and parameters of V+jets after the fit to data
开发者ID:yuchanggit,项目名称:new_git,代码行数:70,代码来源:alpha_Yu_new.py


注:本文中的ROOT.RooAddPdf.fixAddCoefRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。