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


Python RooWorkspace.loadSnapshot方法代码示例

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


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

示例1: __init__

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

#.........这里部分代码省略.........
        pdfs = other.allPdfs()
        pdfIter = pdfs.createIterator()
        pdf = pdfIter.Next()
        while pdf:
            if pdf.IsA().InheritsFrom('RooHistPdf'):
                print 'importing',pdf.GetName(),'from old workspace'
                getattr(self.ws, 'import')(pdf)
            pdf = pdfIter.Next()

    def loadWorkspaceFromFile(self, filename, wsname = 'w', 
                              getFloatPars = True):
        print 'loading data workspace %s from file %s' % (wsname, filename)
        fin = TFile.Open(filename)
        if not fin:
            print 'failed to open the file',filename
            import os
            print 'cwd:',os.getcwd()
            print 'access of',filename,os.access(filename, os.R_OK)
            print 'list of root files in cwd'
            for f in os.listdir(os.getcwd()):
                if f[-5:] == '.root':
                    print f,len(f),len(filename)
            fin = TFile.Open(os.getcwd() + '/' + filename)
            assert(fin)

        other = fin.Get(wsname)

        #pull unbinned data from other workspace
        self.loadDataFromWorkspace(other)

        #pull in histogram pdfs to save time
        self.loadHistogramsFromWorkspace(other)

        if getFloatPars and other.loadSnapshot('fitPars'):
            self.useImportPars = True
            self.ws.saveSnapshot('importParams', other.set('floatingParams'), 
                                 True)

        # self.ws.Print()
    
    # put together a fitting model and return the pdf
    def makeFitter(self, useAlternateModels = False):
        if self.ws.pdf('total'):
            return self.ws.pdf('total')

        compPdfs = []

        for component in self.pars.backgrounds:
            # print 'getting compModels'
            compModels = getattr(self.pars, '%sModels' % component)
            if hasattr(self.pars, '%sConvModels' % component):
                convModels = getattr(self.pars, '%sConvModels' % component)
            else:
                convModels = None
            if useAlternateModels:
                print 'loading Alternate Models'
                compModels = getattr(self.pars, '%sModelsAlt' % component)
                convModels = getattr(self.pars, '%sConvModelsAlt' % component)
            # print 'compModels = %s' % compModels
            compFiles = getattr(self.pars, '%sFiles' % component)
            compPdf = self.makeComponentPdf(component, compFiles, compModels,
                                            useAlternateModels, convModels)
                
            norm = self.ws.factory('prod::f_%s_norm' % component + \
                                       '(n_%s[0.,1e6],' % component + \
                                       '%s_nrm[1.,-0.5,5.])' % component)
开发者ID:kalanand,项目名称:VPlusJets,代码行数:70,代码来源:RooWjj2DFitter.py

示例2:

# 需要导入模块: from ROOT import RooWorkspace [as 别名]
# 或者: from ROOT.RooWorkspace import loadSnapshot [as 别名]
mc = RooStats.ModelConfig('mc')
mc.SetWorkspace(ws)
mc.SetPdf(simPdf)
mc.SetObservables(obs)
mc.SetParametersOfInterest(poi)
mc.SetNuisanceParameters(nuis)

plc = RooStats.ProfileLikelihoodCalculator(data, mc)
plc.SetConfidenceLevel(0.68)

NullSnapshotName = 'null_snapshot'
ws.defineSet('params', pars, False)
ws.saveSnapshot(NullSnapshotName, nullPars, True)
#ws.Print()

ws.loadSnapshot(NullSnapshotName)

nullSet = ws.set('params')
#nullSet.Print('v')
plc.SetNullParameters(nullSet)

htr = plc.GetHypoTest()
signif = htr.Significance()

pars.Print("v")
print "suppression significance:",signif

interval = plc.GetInterval()

# plPlot = RooStats.LikelihoodIntervalPlot(interval)
# plPlot.SetNPoints(20)
开发者ID:TENorbert,项目名称:usercode-2,代码行数:33,代码来源:nullSimFit.py


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