本文整理汇总了Python中ROOT.RooArgList.remove方法的典型用法代码示例。如果您正苦于以下问题:Python RooArgList.remove方法的具体用法?Python RooArgList.remove怎么用?Python RooArgList.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ROOT.RooArgList
的用法示例。
在下文中一共展示了RooArgList.remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: stackedPlot
# 需要导入模块: from ROOT import RooArgList [as 别名]
# 或者: from ROOT.RooArgList import remove [as 别名]
def stackedPlot(self, var, logy = False, pdfName = None, Silent = False):
if not pdfName:
pdfName = 'total'
xvar = self.ws.var(var)
nbins = xvar.getBins()
# if hasattr(self.pars, 'plotRanges') and not xvar.hasRange('plotRange'):
# xvar.setRange('plotRange', self.pars.plotRanges[var][1],
# self.pars.plotRanges[var][2])
# xvar.setBins(self.pars.plotRanges[var][0], 'plotBins')
# elif not xvar.hasRange('plotRange'):
# xvar.setRange('plotRange', xvar.getMin(), xvar.getMax())
# xvar.setBins(nbins, 'plotBins')
sframe = xvar.frame(RooFit.Range('plotRange'),
RooFit.Bins(xvar.getBins('plotBins')))
sframe.SetName("%s_stacked" % var)
pdf = self.ws.pdf(pdfName)
if isinstance(pdf, RooAddPdf):
compList = RooArgList(pdf.pdfList())
else:
compList = None
data = self.ws.data('data_obs')
nexp = pdf.expectedEvents(self.ws.set('obsSet'))
if not Silent:
print pdf.GetName(),'expected: %.0f' % (nexp)
print 'data events: %.0f' % (data.sumEntries())
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)
pass
excluded = (var in self.pars.exclude)
#.........这里部分代码省略.........
示例2: findOnePe
# 需要导入模块: from ROOT import RooArgList [as 别名]
# 或者: from ROOT.RooArgList import remove [as 别名]
def findOnePe(hist, ws, name='x', Npe = 1):
fitPed(hist, ws, name)
x = ws.var(name)
ped = ws.pdf('ped')
pedWidth = ws.var('pedWidth')
pdfs = RooArgList(ped)
pdfList = []
fped = RooRealVar('fped', 'f_{ped}', 0.8, 0., 1.)
fractions = RooArgList(fped)
fList = []
peList = []
peMean = RooRealVar('peMean', 'mean_{pe}', 6., 0., 20.)
peWidth = RooRealVar('peWidth', 'width_{pe}', pedWidth.getVal(), 0., 10.)
for i in range(0, Npe):
pem = RooFormulaVar('pem{0}'.format(i+1), '@0+{0}*@1'.format(i+1),
RooArgList(ws.var('pedMean'), peMean))
peList.append(pem)
npepdf = RooGaussian('pe{0}pdf'.format(i+1), 'pe{0}pdf'.format(i+1),
x, pem, pedWidth)
pdfs.add(npepdf)
pdfList.append(npepdf)
fnpe = RooRealVar('fpe{0}'.format(i+1), 'fpe{0}'.format(i+1),
0.5, -0.1, 1.0)
fractions.add(fnpe)
fList.append(fnpe)
#bgMean = RooRealVar("bgMean", "bgMean", 6.0, x.getMin(), x.getMax())
bgScale = RooRealVar("bgScale", "bgScale", 0.5, -1.0, Npe + 1.0)
bgMean = RooFormulaVar("bgMean", "@[email protected]*@2",
RooArgList(peMean, ws.var('pedMean'), bgScale))
bgWidthL = RooRealVar("bgWidthL", "bgWidthL", pedWidth.getVal()*2,
0., 25.)
bgWidthR = RooRealVar("bgWidthR", "bgWidthR", pedWidth.getVal()*7,
0., 25.)
bgGauss = RooBifurGauss("bgGauss", "bgGauss", x, bgMean,
bgWidthR, bgWidthR)
if (Npe > 1):
pdfs.add(bgGauss)
else:
fractions.remove(fractions.at(fractions.getSize()-1))
## pem = RooFormulaVar('pem', '@[email protected]', RooArgList(peMean, ws.var('pedMean')))
## firstPe = RooGaussian('firstPe', 'firstPe', x, pem, peWidth)
## pdfs.Print("v")
## fractions.Print("v")
pedPlusOne = RooAddPdf('pedPlusOne', 'pedPlusOne', pdfs, fractions, True)
## pedWidth = ped.GetParameter(2)
## pedMean = ped.GetParameter(1)
## pedA = ped.GetParameter(0)
secondMax = hist.GetMaximumBin() + 1
goingDown = True
maxVal = hist.GetBinContent(secondMax)
foundMax = False
while (not foundMax) and (secondMax < hist.GetNbinsX()):
tmpVal = hist.GetBinContent(secondMax+1)
if (tmpVal < maxVal):
if not goingDown:
foundMax = True
else:
goingDown = True
maxVal = tmpVal
secondMax += 1
elif (tmpVal > maxVal):
goingDown = False
maxVal = tmpVal
secondMax += 1
else:
maxVal = tmpVal
secondMax += 1
secondMaxx = hist.GetBinCenter(secondMax)
print 'found 2nd maximum in bin',secondMax,'value',secondMaxx
## peMean.setVal(secondMaxx)
## bgMean.setVal(secondMaxx*0.6)
x.setRange('pedPlus_fit', x.getMin(), ws.var('pedMean').getVal()+pedWidth.getVal()*6.*(Npe+0))
pedPlusOne.fitTo(ws.data('ds'), RooFit.Minos(False),
RooFit.Range('pedPlus_fit'),
RooFit.PrintLevel(1))
getattr(ws, 'import')(pedPlusOne)