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


Python RooWorkspace.function方法代码示例

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


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

示例1: __init__

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

#.........这里部分代码省略.........
        if nexp < 1:
            nexp = data.sumEntries()
        theComponents = [] 
        if self.pars.includeSignal:
            theComponents += self.pars.signals
        theComponents += self.pars.backgrounds
        data.plotOn(sframe, RooFit.Invisible(),
                    RooFit.Binning('plotBins'))
        # dataHist = RooAbsData.createHistogram(data,'dataHist_%s' % var, xvar,
        #                                       RooFit.Binning('%sBinning' % var))
        # #dataHist.Scale(1., 'width')
        # invData = RooHist(dataHist, 1., 1, RooAbsData.SumW2, 1.0, False)
        # #invData.Print('v')
        # sframe.addPlotable(invData, 'pe', True, True)
        for (idx,component) in enumerate(theComponents):
            if not Silent:
                print 'plotting',component,'...',
            if hasattr(self.pars, '%sPlotting' % (component)):
                plotCharacteristics = getattr(self.pars, '%sPlotting' % \
                                                  (component))
            else:
                plotCharacteristics = {'color' : colorwheel[idx%6],
                                       'title' : component }

            compCmd = RooCmdArg.none()
            if compList:
                compSet = RooArgSet(compList)
                if compSet.getSize() > 0:
                    compCmd = RooFit.Components(compSet)
                removals = compList.selectByName('%s*' % component)
                compList.remove(removals)

            if not Silent:
                print 'events', self.ws.function('f_%s_norm' % component).getVal()
                sys.stdout.flush()
            if abs(self.ws.function('f_%s_norm' % component).getVal()) >= 1.:
                pdf.plotOn(sframe, #RooFit.ProjWData(data),
                           RooFit.DrawOption('LF'), RooFit.FillStyle(1001),
                           RooFit.FillColor(plotCharacteristics['color']),
                           RooFit.LineColor(plotCharacteristics['color']),
                           RooFit.VLines(),
                           RooFit.Range('plotRange'),
                           RooFit.NormRange('plotRange'),
                           RooFit.Normalization(nexp, RooAbsReal.NumEvent),
                           compCmd
                           )
                tmpCurve = sframe.getCurve()
                tmpCurve.SetName(component)
                tmpCurve.SetTitle(plotCharacteristics['title'])
                if 'visible' in plotCharacteristics:
                    sframe.setInvisible(component, 
                                        plotCharacteristics['visible'])

        data.plotOn(sframe, RooFit.Name('theData'),
                    RooFit.Binning('plotBins'))
        sframe.getHist('theData').SetTitle('data')
        # theData = RooHist(dataHist, 1., 1, RooAbsData.SumW2, 1.0, True)
        # theData.SetName('theData')
        # theData.SetTitle('data')
        # sframe.addPlotable(theData, 'pe')

        if (logy):
            sframe.SetMinimum(0.01)
            sframe.SetMaximum(1.0e6)
        else:
            sframe.SetMaximum(sframe.GetMaximum()*1.35)
开发者ID:kalanand,项目名称:VPlusJets,代码行数:70,代码来源:RooWjj2DFitter.py

示例2: getattr

# 需要导入模块: from ROOT import RooWorkspace [as 别名]
# 或者: from ROOT.RooWorkspace import function [as 别名]
fitter_mWW.ws.var('r_signal').setError(0.1)
fitter_mWW.ws.var('r_signal').setRange(-3., 9.)
fitter_mWW.ws.var('r_signal').setConstant(False)

params_mWW.Print("v")
fitter_mWW.ws.defineSet("params", params_mWW)

var_name = pars_mWW.var[0]
other_var = pars_mWW.var[1]
compPdfs = []
for comp in components:
    compPdf = fitter_mWW.ws.pdf(comp)
    getattr(combinedWS, 'import')(compPdf)
    newPdf = combinedWS.pdf(comp)
    newPdf.SetName('%s_%s' % (comp, var_name))
    norm = combinedWS.function('f_%s_norm' % comp)
    combinedWS.factory('PROD::%s(%s_%s, %s)' % (comp, comp, other_var,
                                                newPdf.GetName()))
    compPdfs.append(combinedWS.factory('RooExtendPdf::%s_extended(%s, %s)' %\
                                           (comp, comp, norm.GetName())))

combinedWS.defineSet('obsSet', '%s,%s' % (other_var, var_name))

if opts.sigInject:
    combinedWS.var('r_signal').setVal(opts.sigInject)
combinedWS.var('r_signal').setError(0.1)
combinedWS.var('r_signal').setRange(-3., 9.)
combinedWS.var('r_signal').setConstant(False)

compNames = [ c.GetName() for c in compPdfs ]
compList = RooArgList(combinedWS.argSet(','.join(compNames)))
开发者ID:VPlusJetsAnalyzers,项目名称:VPlusJets,代码行数:33,代码来源:genHWW1D2FitsToy.py

示例3: _import

# 需要导入模块: from ROOT import RooWorkspace [as 别名]
# 或者: from ROOT.RooWorkspace import function [as 别名]
acceptance.SetNameTitle('acceptance_%s' % mode1,
                        '%s decay time acceptance' % mode1)
_import(workspace, acceptance,
        RooFit.RenameAllVariablesExcept(mode1, 'time'),
        RooFit.RecycleConflictNodes())

acceptance = workspace2.function('acceptance') # Dsπ
acceptance.SetNameTitle('acceptance_%s' % mode2,
                        '%s decay time acceptance' % mode2)
_import(workspace, acceptance,
        RooFit.RenameAllVariablesExcept(mode2, 'time'),
        RooFit.RecycleConflictNodes())


# retrieve acceptance functions
acceptance1 = workspace.function('acceptance_%s' % mode1) # DsK
acceptance2 = workspace.function('acceptance_%s' % mode2) # Dsπ

# Acceptance ratio FIXME: hardcoded ROOT file
rfile = TFile('data/acceptance-ratio-hists.root', 'read')
hcorr = rfile.Get('haccratio_cpowerlaw')

ardhist = RooDataHist('ardhist', 'DsK/DsPi acceptance ratio datahist',
                      RooArgList(time), RooFit.Import(hcorr, False))
accratio = RooHistFunc('accratio', 'DsK/DsPi acceptance ratio',
                       RooArgSet(time), ardhist)
cacceptance = PowLawAcceptance(acceptance2, 'cacceptance', accratio)
# cacceptance = PowLawAcceptance('cacceptance', 'Corrected Power law acceptance',
#                                turnon, time, offset, exponent, beta, accratio)

ratio = RooFormulaVar('ratio', '@0/@1', RooArgList(acceptance1, cacceptance))
开发者ID:lbel,项目名称:Bs2DsKTools,代码行数:33,代码来源:flat-test.py

示例4: RooWorkspace

# 需要导入模块: from ROOT import RooWorkspace [as 别名]
# 或者: from ROOT.RooWorkspace import function [as 别名]
simparamfile = opts.paramfile
useKeys = opts.keys

ws = RooWorkspace("ws","ws")

readData(ws, hidatafile, ppdatafile, cuts)

buildPdf(ws, False, 1, True)
buildPdf(ws, True, 0, True)
simPdf = buildSimPdf(ws, ws.cat('dataCat'))

pars = simPdf.getParameters(ws.data('data'))
pars.readFromFile(simparamfile)

Npp_tot = Long(ws.var("nsig1_pp").getVal() + \
               ws.function("nsig2_pp").getVal() + \
               ws.function("nsig3_pp").getVal() + \
               ws.var("nbkg_pp").getVal() + 0.5)
Nhi_tot = Long(ws.var("nsig1_hi").getVal() + \
               ws.function("nsig2_hi").getVal() + \
               ws.function("nsig3_hi").getVal() + \
               ws.var("nbkg_hi").getVal() + 0.5)
dataCat = ws.cat('dataCat')
QQsign = ws.cat('QQsign')
reducedCols = RooArgSet(dataCat,QQsign)

dsToGen = ['os']
if useKeys:
    dsToGen.insert(0, 'ss')

for signStr in dsToGen:
开发者ID:TENorbert,项目名称:usercode-2,代码行数:33,代码来源:toyFit.py

示例5: RooWorkspace

# 需要导入模块: from ROOT import RooWorkspace [as 别名]
# 或者: from ROOT.RooWorkspace import function [as 别名]
from ROOT import RooFit, RooWorkspace, RooDataSet, kDashed, TBrowser

w = RooWorkspace("w", True)
w.factory("Gaussian::gauss(mes[5.20,5.30],mean[5.28,5.2,5.3],width[0.0027,0.001,1])")
w.factory("ArgusBG::argus(mes,5.291,argpar[-20,-100,-1])")
w.factory("SUM::sum(nsig[200,0,10000]*gauss,nbkg[800,0,10000]*argus)")

#--- Generate a toyMC sample from composite PDF ---
data = w.function('sum').generate(w.argSet('mes'), 2000)
#--- Perform extended ML fit of composite PDF to toy data ---
w.function('sum').fitTo(data)
# --- Plot toy data and composite PDF overlaid ---
mesframe = w.var('mes').frame()
data.plotOn(mesframe)
w.function('sum').plotOn(mesframe)
w.function('sum').plotOn(mesframe, RooFit.Components('argus'), RooFit.LineStyle(kDashed))
 
mesframe.Draw()
mesframe.Browse(TBrowser())

print 'nsig:',w.var('nsig').getValV(), '+-', w.var('nsig').getError()
print 'nbkg:', w.var('nbkg').getValV(), '+-', w.var('nbkg').getError()
print 'mes:', w.var('mes').getValV(), '+-', w.var('mes').getError()
print 'mean:', w.var('mean').getValV(), '+-', w.var('mean').getError()
print 'width:', w.var('width').getValV(), '+-', w.var('width').getError()
print 'argpar:', w.var('argpar').getValV(), '+-', w.var('argpar').getError()

from time import sleep
sleep(5)
开发者ID:BristolTopGroup,项目名称:DailyPythonScripts,代码行数:31,代码来源:roofit_beginner.py


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