本文整理汇总了Python中Plotter.Plotter.initializeDataSamples方法的典型用法代码示例。如果您正苦于以下问题:Python Plotter.initializeDataSamples方法的具体用法?Python Plotter.initializeDataSamples怎么用?Python Plotter.initializeDataSamples使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plotter.Plotter
的用法示例。
在下文中一共展示了Plotter.initializeDataSamples方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getSignalOverBackground
# 需要导入模块: from Plotter import Plotter [as 别名]
# 或者: from Plotter.Plotter import initializeDataSamples [as 别名]
def getSignalOverBackground(analysis,region,period,cut,**kwargs):
doDataDriven = kwargs.pop('doDataDriven',True)
scalefactor = kwargs.pop('scalefactor','event.gen_weight*event.pu_weight*event.lep_scale*event.trig_scale')
nl = 3
sigMap = getSigMap(nl)
intLumiMap = getIntLumiMap()
mergeDict = getMergeDict(period)
channelBackground = getChannelBackgrounds(period)
channels, leptons = getChannels(nl)
saves = '%s_%s_%iTeV' % (analysis,region,period)
ntuples = getNtupleDirectory(analysis,region,period)
plotter = Plotter(region,ntupleDir=ntuples,saveDir=saves,period=period,rootName='plots_sOverB',mergeDict=mergeDict,scaleFactor=scalefactor,datadriven=doDataDriven)
plotter.initializeBackgroundSamples([sigMap[period][x] for x in channelBackground[region+'datadriven' if doDataDriven else region]])
plotter.initializeDataSamples([sigMap[period]['data']])
plotter.setIntLumi(intLumiMap[period])
sig = 0.
sigErr2 = 0.
bg = 0.
bgErr2 = 0.
for b in plotter.backgrounds:
val, err = plotter.getNumEntries(cut,b,doError=True)
if b=='WZJets':
sig += val
sigErr2 += err**2
else:
bg += val
bgErr2 += err**2
sigErr = sigErr2**0.5
bgErr = bgErr2**0.5
return sig/bg if bg else -1.
示例2: getYieldsErrors
# 需要导入模块: from Plotter import Plotter [as 别名]
# 或者: from Plotter.Plotter import initializeDataSamples [as 别名]
def getYieldsErrors(analysis,region,period,cut,**kwargs):
doDataDriven = kwargs.pop('doDataDriven',True)
scalefactor = kwargs.pop('scalefactor','event.gen_weight*event.pu_weight*event.lep_scale*event.trig_scale')
nl = 3
sigMap = getSigMap(nl)
intLumiMap = getIntLumiMap()
mergeDict = getMergeDict(period)
channelBackground = getChannelBackgrounds(period)
channels, leptons = getChannels(nl)
saves = '%s_%s_%iTeV' % (analysis,region,period)
ntuples = getNtupleDirectory(analysis,region,period)
plotter = Plotter(region,ntupleDir=ntuples,saveDir=saves,period=period,rootName='plots_statUnc',mergeDict=mergeDict,scaleFactor=scalefactor,datadriven=doDataDriven)
plotter.initializeBackgroundSamples([sigMap[period][x] for x in channelBackground[region+'datadriven' if doDataDriven else region]])
plotter.initializeDataSamples([sigMap[period]['data']])
plotter.setIntLumi(intLumiMap[period])
yields = {}
for chan in ['eee','eem','mme','mmm']:
yields[chan] = {}
chanCut = '{0} && channel=="{1}"'.format(cut,chan)
sig = 0.
sigErr2 = 0.
bg = 0.
bgErr2 = 0.
for b in plotter.backgrounds:
val, err = plotter.getNumEntries(chanCut,b,doError=True)
if b=='WZJets':
sig += val
sigErr2 += err**2
else:
bg += val
bgErr2 += err**2
sigErr = sigErr2**0.5
bgErr = bgErr2**0.5
data, dataErr = plotter.getDataEntries(chanCut,doError=True)
dataErr2 = dataErr**2
yields[chan]['sig'] = [sig, sigErr]
yields[chan]['bg'] = [bg, bgErr]
yields[chan]['data'] = [data, dataErr]
yields['wz'] = {}
for i in ['sig','bg','data']:
tot = sum([yields[chan][i][0] for chan in ['eee','eem','mme','mmm']])
totErr = sum([yields[chan][i][1]**2 for chan in ['eee','eem','mme','mmm']])**0.5
yields['wz'][i] = [tot, totErr]
return yields
示例3: getBackgroundEstimation
# 需要导入模块: from Plotter import Plotter [as 别名]
# 或者: from Plotter.Plotter import initializeDataSamples [as 别名]
def getBackgroundEstimation(analysis,region,period,cut,**kwargs):
doDataDriven = kwargs.pop('doDataDriven',True)
scalefactor = kwargs.pop('scalefactor','event.gen_weight*event.pu_weight*event.lep_scale*event.trig_scale')
nl = 3
sigMap = getSigMap(nl)
intLumiMap = getIntLumiMap()
mergeDict = getMergeDict(period)
channelBackground = getChannelBackgrounds(period)
channels, leptons = getChannels(nl)
saves = '%s_%s_%iTeV' % (analysis,region,period)
ntuples = getNtupleDirectory(analysis,region,period)
bgChannels = [sigMap[period][x] for x in channelBackground[region+'datadriven' if doDataDriven else region]]
plotter = Plotter(region,ntupleDir=ntuples,saveDir=saves,period=period,rootName='plots_bgEstimation',mergeDict=mergeDict,scaleFactor=scalefactor,datadriven=doDataDriven)
plotter.initializeBackgroundSamples(bgChannels)
plotter.initializeDataSamples([sigMap[period]['data']])
plotter.setIntLumi(intLumiMap[period])
estimates = {}
for chan in channels:
thisCut = '{0} && channel=="{1}"'.format(cut,chan)
estimates[chan] = {}
obs, obsErr = plotter.getDataEntries(thisCut,doError=True)
obsErr2 = obsErr**2
dd = 0.
ddErr2 = 0.
mc = 0.
mcErr2 = 0.
for bg in bgChannels + ['datadriven']:
val, err = plotter.getNumEntries(thisCut,bg,doError=True)
if bg in ['datadriven']:
dd += val
ddErr2 += err**2
else:
mc += val
mcErr2 += err**2
fromMC = [obs - mc, (obsErr2 + mcErr2)**0.5]
fromDD = [dd, ddErr2**0.5]
estimates[chan]['mc'] = fromMC
estimates[chan]['datadriven'] = fromDD
estimates['total'] = {}
estimates['total']['mc'] = [sum([estimates[x]['mc'][0] for x in channels]), sum([estimates[x]['mc'][1]**2 for x in channels])**0.5]
estimates['total']['datadriven'] = [sum([estimates[x]['datadriven'][0] for x in channels]), sum([estimates[x]['datadriven'][1]**2 for x in channels])**0.5]
return estimates