本文整理汇总了Python中ROOT.RooArgList.add方法的典型用法代码示例。如果您正苦于以下问题:Python RooArgList.add方法的具体用法?Python RooArgList.add怎么用?Python RooArgList.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ROOT.RooArgList
的用法示例。
在下文中一共展示了RooArgList.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_arglist
# 需要导入模块: from ROOT import RooArgList [as 别名]
# 或者: from ROOT.RooArgList import add [as 别名]
def get_arglist(args):
"""Return and arglist of the RooFit objects."""
arglist = RooArgList()
for arg in args:
if arg.InheritsFrom(RooAbsArg.Class()): arglist.add(arg)
else: TypeError('%s should inherit from RooAbsArg' % arg.GetName())
return arglist
示例2: main
# 需要导入模块: from ROOT import RooArgList [as 别名]
# 或者: from ROOT.RooArgList import add [as 别名]
def main ():
N_bkg1 = 9000
N_signal = 1000
N_bkg1_obs = 10000
N_signal_obs = 2000
N_data = N_bkg1_obs + N_signal_obs
mu1, mu2, sigma1, sigma2 = 100, 140, 15, 5
x1 = mu1 + sigma1 * np.random.randn( N_bkg1 )
x2 = mu2 + sigma2 * np.random.randn( N_signal )
x1_obs = mu1 + sigma1 * np.random.randn( N_bkg1_obs )
x2_obs = mu2 + sigma2 * np.random.randn( N_signal_obs )
h1 = Hist( 100, 40, 200, title = 'Background' )
h2 = h1.Clone( title = 'Signal' )
h3 = h1.Clone( title = 'Data' )
h3.markersize = 1.2
# fill the histograms with our distributions
map( h1.Fill, x1 )
map( h2.Fill, x2 )
map( h3.Fill, x1_obs )
map( h3.Fill, x2_obs )
histograms_1 = {'signal': h2,
'bkg1': h1,
'data': h3}
histograms_2 = {'signal': h2,
'bkg1': h1,
'data': h3}
# roofit_histograms contains RooDataHist
# model = RooAddPdf
model1, roofit_histograms_1,fit_variable_1 = get_roofit_model( histograms_1, fit_boundaries = ( 40, 200 ), name = 'm1' )
model2, roofit_histograms_2, fit_variable_2 = get_roofit_model( histograms_2, fit_boundaries = ( 40, 200 ), name = 'm2' )
sample = RooCategory( 'sample', 'sample' )
sample.defineType( 'm1', 1 )
sample.defineType( 'm2', 2 )
combined_data = deepcopy( roofit_histograms_1['data'] )
combined_data.add( roofit_histograms_2['data'] )
# RooDataHist(const char* name, const char* title, const RooArgList& vars, RooCategory& indexCat, map<std::string,TH1*> histMap, Double_t initWgt = 1.0)
sim_pdf = RooSimultaneous( "simPdf", "simultaneous pdf", sample )
sim_pdf.addPdf( model1, 'm1' )
sim_pdf.addPdf( model2, 'm2' )
variables = RooArgList()
variables.add(fit_variable_1)
variables.add(fit_variable_2)
# combined_data = RooDataHist('combined_data', 'combined_data',
# variables, RooFit.Index(sample),
# RooFit.Import('m1', roofit_histograms_1['data']),
# RooFit.Import('m2', roofit_histograms_2['data']))
fitResult = sim_pdf.fitTo( combined_data,
# RooFit.Minimizer( "Minuit2", "Migrad" ),
# RooFit.NumCPU( 1 ),
# RooFit.Extended(),
RooFit.Save(),
)
示例3: getPdfInRegions
# 需要导入模块: from ROOT import RooArgList [as 别名]
# 或者: from ROOT.RooArgList import add [as 别名]
def getPdfInRegions(w,sample,region):
if isinstance(sample,list):
sampleArgList = RooArgList()
sample_str="group"
for s in sample:
componentTmp = Util.GetComponent(w,s,region,True)
sample_str=sample_str+"_"+s
sampleArgList.add(componentTmp)
pass
pdfInRegion = RooAddition(sample_str,sample_str,sampleArgList)
else:
pdfInRegion = Util.GetComponent(w,sample,region)
pass
return pdfInRegion
示例4: PlotSignalShapes
# 需要导入模块: from ROOT import RooArgList [as 别名]
# 或者: from ROOT.RooArgList import add [as 别名]
def PlotSignalShapes(Selection):
f__ = TFile.Open( "datacards/22June/2dPlots.root")
signal_fname_1 = ("signals/22June/out_{sample:s}_syst.root", "cms_hgg_13TeV" )
signal_fname_2 = ("signals/22June/out_ctcv_{sample:s}_syst.root" , "ctcv" )
samples = {"thw":signal_fname_2, "thq":signal_fname_2, "tth":signal_fname_1 , "vh":signal_fname_1 }
purity_h_name = "{sample:s}/"+Selection+"/h{sample:s}_"+Selection+"_purity_CtCv"
purities = RooArgList()
signalshapes = RooArgList()
ctOverCvs = []
mVar = None
ctovercv_vals = None
for sample in samples :
purity = CtCvCpInfo("purity_" + sample)
ctovercv_vals = sorted(purity.AllCtOverCVs.keys())
purity.FillFrom2DHisto( f__.Get( purity_h_name.format( sample=sample ) ) )
purity.GetCtOverCv()
purities.add( purity.CtOverCvDataHistFunc )
objsToKeep.append( purity )
sFile = TFile.Open( samples[sample][0].format( sample=sample ) )
ws = sFile.Get( samples[sample][1] )
pdf = ws.pdf("RV{sample:s}_mh125".format( sample=sample) )
objsToKeep.append(sFile)
objsToKeep.append(ws)
objsToKeep.append(pdf)
signalshapes.add( pdf )
ctOverCvs.append( ws.var( "CtOverCv" ) )
mVar = ws.var("CMS_hgg_mass")
ret = RooAddPdf("signal" , "signal" , signalshapes , purities )
objsToKeep.append( ret )
plot = mVar.frame()
options = ""
for ctovercv in ctovercv_vals :
for var in ctOverCvs:
var.setVal( ctovercv )
name = "name%g" % ctovercv
ret.plotOn( plot , RooFit.DrawOption(options) , RooFit.Name(name) )
c = TCanvas()
plot.Draw()
c.SaveAs("a.gif+")
if not "same" in options :
options += " same"
return c
示例5: addTrackMomenta
# 需要导入模块: from ROOT import RooArgList [as 别名]
# 或者: from ROOT.RooArgList import add [as 别名]
def addTrackMomenta( dataSet ):
""" add K+, K-, mu+ and mu- momentum magnitudes to data set
"""
# get observables from data set
from ROOT import RooArgList, RooFormulaVar
KplusList = RooArgList('KplusList')
KminusList = RooArgList('KminusList')
muplusList = RooArgList('muplusList')
muminusList = RooArgList('muminusList')
for suf in [ 'X','Y','Z' ] :
KplusList.add( dataSet.get().find('Kplus_P' + suf) )
KminusList.add( dataSet.get().find('Kminus_P' + suf) )
muplusList.add( dataSet.get().find('muplus_P' + suf) )
muminusList.add( dataSet.get().find('muminus_P' + suf) )
# create formulas
KplusMomFunc = RooFormulaVar( 'Kplus_P', 'Kplus_P', 'TMath::Sqrt(Kplus_PX**2 + Kplus_PY**2 + Kplus_PZ**2)', KplusList )
KminusMomFunc = RooFormulaVar( 'Kminus_P', 'Kminus_P', 'TMath::Sqrt(Kminus_PX**2 + Kminus_PY**2 + Kminus_PZ**2)', KminusList )
muplusMomFunc = RooFormulaVar( 'muplus_P', 'muplus_P', 'TMath::Sqrt(muplus_PX**2 + muplus_PY**2 + muplus_PZ**2)', muplusList )
muminusMomFunc = RooFormulaVar( 'muminus_P','muminus_P', 'TMath::Sqrt(muminus_PX**2 + muminus_PY**2 + muminus_PZ**2)', muminusList )
# create new columns in data set
dataSet.addColumn(KplusMomFunc)
dataSet.addColumn(KminusMomFunc)
dataSet.addColumn(muplusMomFunc)
dataSet.addColumn(muminusMomFunc)
示例6: getPdfInRegionsWithRangeName
# 需要导入模块: from ROOT import RooArgList [as 别名]
# 或者: from ROOT.RooArgList import add [as 别名]
def getPdfInRegionsWithRangeName(w,sample,region,rangeName):
"""
Should be moved to $HF/src/Utils.h -- FIXME
"""
if isinstance(sample,list):
sampleArgList = RooArgList()
sample_str="group"
for s in sample:
componentTmp = Util.GetComponent(w,s,region,True,rangeName)
sample_str=sample_str+"_"+s
sampleArgList.add(componentTmp)
pass
pdfInRegion = RooAddition(sample_str,sample_str,sampleArgList)
else:
pdfInRegion = Util.GetComponent(w,sample,region,False,rangeName)
pass
return pdfInRegion
示例7: addHistData
# 需要导入模块: from ROOT import RooArgList [as 别名]
# 或者: from ROOT.RooArgList import add [as 别名]
def addHistData(self, ws, ds_name, item_title, var_set_name, var_set_type, ds_object, sets = None):
legend = '[exostConfig::addHistData]:'
arg_list = RooArgList()
if (var_set_type == 'set'):
#arg_list.add(ws.set(var_set_name))
arg_list.add(sets[var_set_name])
elif (var_set_type == 'var'):
arg_list.add(ws.var(var_set_name))
else:
print legend, 'error: unknown var_set_type, cannot create dataset', ds_name
return -1
#create the hist dataset
ds = RooDataHist(ds_name, item_title, arg_list, ds_object, 1)
# import the datahist. Note workaround 'import' being a reserved word
getattr(ws, 'import')(ds)
示例8: Hist2Pdf
# 需要导入模块: from ROOT import RooArgList [as 别名]
# 或者: from ROOT.RooArgList import add [as 别名]
def Hist2Pdf(self, hist, pdfName, ws, order = 0):
if ws.pdf(pdfName):
return ws.pdf(pdfName)
try:
obs = [ self.pars.varNames[x] for x in self.pars.var ]
except AttributeError:
obs = self.pars.var
varList = RooArgList()
for v in obs:
varList.add(ws.var(v))
newHist = RooDataHist(pdfName + '_hist', pdfName + '_hist',
varList, hist)
thePdf = RooHistPdf(pdfName, pdfName, RooArgSet(varList),
newHist, order)
getattr(ws, 'import')(thePdf)
return ws.pdf(pdfName)
示例9: getPdfInRegions
# 需要导入模块: from ROOT import RooArgList [as 别名]
# 或者: from ROOT.RooArgList import add [as 别名]
def getPdfInRegions(w,sample,region):
"""
Return the PDF in a region for a sample
Should be moved to $HF/src/Utils.h -- FIXME
@param sample The sample to find
@param region The region to use
"""
if isinstance(sample,list):
sampleArgList = RooArgList()
sample_str="group"
for s in sample:
componentTmp = Util.GetComponent(w,s,region,True)
sample_str=sample_str+"_"+s
sampleArgList.add(componentTmp)
pass
pdfInRegion = RooAddition(sample_str,sample_str,sampleArgList)
else:
pdfInRegion = Util.GetComponent(w,sample,region)
pass
return pdfInRegion
示例10: performFitInLeptonAbsEta
# 需要导入模块: from ROOT import RooArgList [as 别名]
# 或者: from ROOT.RooArgList import add [as 别名]
def performFitInLeptonAbsEta(data_histogram, signal_histogram, bkg1_histogram, bkg2_histogram):
N_Data = data_histogram.Integral()
N_signal = signal_histogram.Integral()
N_bkg1 = bkg1_histogram.Integral()
N_bkg2 = bkg2_histogram.Integral()
leptonAbsEta = RooRealVar("leptonAbsEta", "leptonAbsEta", 0., 3.)
variables = RooArgList()
variables.add(leptonAbsEta)
variable_set = RooArgSet()
variable_set.add(leptonAbsEta)
lowerBound = 0
upperBound = N_Data*2
data_RooDataHist = RooDataHist("data", "dataset with leptonAbsEta", variables, data_histogram)
signal_RooDataHist = RooDataHist("rh_signal", "signal", variables, signal_histogram);
bkg1_RooDataHist = RooDataHist("rh_bkg1", "bkg1", variables, bkg1_histogram);
bkg2_RooDataHist = RooDataHist("rh_bkg2", "bkg2", variables, bkg2_histogram);
signal_RooHistPdf = RooHistPdf("pdf_signal", "Signal PDF", variable_set, signal_RooDataHist, 0)
signal_RooHistPdf = RooHistPdf("pdf_signal", "Signal PDF", variable_set, signal_RooDataHist, 0)
示例11: get_roofit_model
# 需要导入模块: from ROOT import RooArgList [as 别名]
# 或者: from ROOT.RooArgList import add [as 别名]
def get_roofit_model( histograms, fit_boundaries, name = 'model' ):
data_label = 'data'
samples = sorted( histograms.keys() )
samples.remove( data_label )
roofit_histograms = {}
roofit_pdfs = {}
roofit_variables = {}
variables = RooArgList()
variable_set = RooArgSet()
fit_variable = RooRealVar( name , name, fit_boundaries[0], fit_boundaries[1] )
variables.add( fit_variable )
variable_set.add( fit_variable )
roofit_histograms[data_label] = RooDataHist( data_label,
data_label,
variables,
histograms[data_label] )
pdf_arglist = RooArgList()
variable_arglist = RooArgList()
N_total = histograms[data_label].Integral() * 2
N_min = 0
for sample in samples:
roofit_histogram = RooDataHist( sample, sample, variables, histograms[sample] )
roofit_histograms[sample] = roofit_histogram
roofit_pdf = RooHistPdf ( 'pdf' + sample, 'pdf' + sample, variable_set, roofit_histogram, 0 )
roofit_pdfs[sample] = roofit_pdf
roofit_variable = RooRealVar( sample, "number of " + sample + " events", histograms[sample].Integral(), N_min, N_total, "event" )
roofit_variables[sample] = roofit_variable
pdf_arglist.add( roofit_pdf )
variable_arglist.add( roofit_variable )
model = RooAddPdf( name, name, pdf_arglist, variable_arglist )
return model, roofit_histograms, fit_variable
示例12: plotFitModel
# 需要导入模块: from ROOT import RooArgList [as 别名]
# 或者: from ROOT.RooArgList import add [as 别名]
def plotFitModel(model, frame, wksp, myconfigfile, log) :
if debug :
model.Print('t')
frame.Print('v')
dataset = w.data(dataSetToPlot)
# plot model itself
fr = model.plotOn(frame,
RooFit.LineColor(kBlue+3),RooFit.Name("FullPdf"))
var = []
tacc_list = RooArgList()
numKnots = myconfigfile["Acceptance"]["knots"].__len__()
for i in range(0,numKnots+1):
varName = "var%d"%(int(i+1))
var.append(wksp.var(varName))
print "[INFO] Load %s with value %0.3lf"%(var[i].GetName(),var[i].getValV())
tacc_list.add(var[i])
varAdd = RooAddition(wksp.obj("var%d"%(numKnots+2)))
#varAdd = RooRealVar(wksp.obj("var%d"%(numKnots+2)))
print "[INFO] Load %s with value %0.3lf"%(varAdd.GetName(),varAdd.getValV())
tacc_list.add(varAdd)
#len = var.__len__()
#tacc_list.add(var[len])
spl = RooCubicSplineFun("splinePdf", "splinePdf", time, "splineBinning", tacc_list)
if log:
rel = 200
else:
rel = 1000
rel = 40
fr = spl.plotOn(frame, RooFit.LineColor(kRed), RooFit.Normalization(rel, RooAbsReal.Relative),RooFit.Name("sPline"))
fr = model.plotOn(frame,
RooFit.LineColor(kBlue+3), RooFit.Name("FullPdf"))
示例13: fit
# 需要导入模块: from ROOT import RooArgList [as 别名]
# 或者: from ROOT.RooArgList import add [as 别名]
def fit(self):
fit_variable = RooRealVar("fit_variable", "fit_variable", self.fit_boundaries[0], self.fit_boundaries[1])
fit_variable.setBins(self.histograms[self.data_label].nbins())
variables = RooArgList()
variables.add(fit_variable)
variable_set = RooArgSet()
variable_set.add(fit_variable)
roofit_histograms = {}
roofit_pdfs = {}
roofit_variables = {}
N_min = 0.0
N_max = self.normalisation[self.data_label] * 2.0
pdf_arglist = RooArgList()
variable_arglist = RooArgList()
roofit_histograms[self.data_label] = RooDataHist(
self.data_label, self.data_label, variables, self.histograms[self.data_label]
)
for sample in self.samples:
roofit_histogram = RooDataHist(sample, sample, variables, self.histograms[sample])
roofit_histograms[sample] = roofit_histogram
roofit_pdf = RooHistPdf("pdf" + sample, "pdf" + sample, variable_set, roofit_histogram)
roofit_pdfs[sample] = roofit_pdf
roofit_variable = RooRealVar(sample, sample + " events", self.normalisation[sample], N_min, N_max)
roofit_variables[sample] = roofit_variable
pdf_arglist.add(roofit_pdf)
variable_arglist.add(roofit_variable)
model = RooAddPdf("model", "sum of all known", pdf_arglist, variable_arglist)
use_model = model
if self.constraints:
arg_set = RooArgSet(model)
constraints = self.get_fit_normalisation_constraints(model, roofit_variables)
for constraint in constraints:
arg_set.add(constraint)
model_with_constraints = RooProdPdf(
"model_with_constraints", "model with gaussian constraints", arg_set, RooLinkedList()
)
use_model = model_with_constraints
if self.method == "TMinuit":
# WARNING: number of cores changes the results!!!
self.saved_result = use_model.fitTo(
roofit_histograms[self.data_label],
RooFit.Minimizer("Minuit2", "Migrad"),
RooFit.NumCPU(1),
RooFit.Extended(),
RooFit.Save(),
)
results = {}
for sample in self.samples:
results[sample] = (roofit_variables[sample].getVal(), roofit_variables[sample].getError())
self.results = results
示例14: fit_gau2_che
# 需要导入模块: from ROOT import RooArgList [as 别名]
# 或者: from ROOT.RooArgList import add [as 别名]
def fit_gau2_che(var, dataset, title='', print_pars=False, test=False,
mean_=None, sigma_=None, sigma1_=None, sigmaFraction_=None):
# define background
c0 = RooRealVar('c0', 'constant', 0.1, -1, 1)
c1 = RooRealVar('c1', 'linear', 0.6, -1, 1)
c2 = RooRealVar('c2', 'quadratic', 0.1, -1, 1)
c3 = RooRealVar('c3', 'c3', 0.1, -1, 1)
bkg = RooChebychev('bkg', 'background pdf', var,
RooArgList(c0, c1, c2, c3))
# define signal
val = 5.28
dmean = 0.05
valL = val - dmean
valR = val + dmean
if mean_ is None:
mean = RooRealVar("mean", "mean", val, valL, valR)
else:
mean = RooRealVar("mean", "mean", mean_)
val = 0.05
dmean = 0.02
valL = val - dmean
valR = val + dmean
if sigma_ is None:
sigma = RooRealVar('sigma', 'sigma', val, valL, valR)
else:
sigma = RooRealVar('sigma', 'sigma', sigma_)
if sigma1_ is None:
sigma1 = RooRealVar('sigma1', 'sigma1', val, valL, valR)
else:
sigma1 = RooRealVar('sigma1', 'sigma1', sigma1_)
peakGaus = RooGaussian("peakGaus", "peakGaus", var, mean, sigma)
peakGaus1 = RooGaussian("peakGaus1", "peakGaus1", var, mean, sigma1)
if sigmaFraction_ is None:
sigmaFraction = RooRealVar("sigmaFraction", "Sigma Fraction", 0.5, 0., 1.)
else:
sigmaFraction = RooRealVar("sigmaFraction", "Sigma Fraction", sigmaFraction_)
glist = RooArgList(peakGaus, peakGaus1)
peakG = RooAddPdf("peakG","peakG", glist, RooArgList(sigmaFraction))
listPeak = RooArgList("listPeak")
listPeak.add(peakG)
listPeak.add(bkg)
fbkg = 0.45
nEntries = dataset.numEntries()
val=(1-fbkg)* nEntries
listArea = RooArgList("listArea")
areaPeak = RooRealVar("areaPeak", "areaPeak", val, 0.,nEntries)
listArea.add(areaPeak)
nBkg = fbkg*nEntries
areaBkg = RooRealVar("areaBkg","areaBkg", nBkg, 0.,nEntries)
listArea.add(areaBkg)
model = RooAddPdf("model", "fit model", listPeak, listArea)
if not test:
fitres = model.fitTo(dataset, RooFit.Extended(kTRUE),
RooFit.Minos(kTRUE),RooFit.Save(kTRUE))
nbins = 35
frame = var.frame(nbins)
frame.GetXaxis().SetTitle("B^{0} mass (GeV/c^{2})")
frame.GetXaxis().CenterTitle()
frame.GetYaxis().CenterTitle()
frame.SetTitle(title)
mk_size = RooFit.MarkerSize(0.3)
mk_style = RooFit.MarkerStyle(kFullCircle)
dataset.plotOn(frame, mk_size, mk_style)
model.plotOn(frame)
as_bkg = RooArgSet(bkg)
cp_bkg = RooFit.Components(as_bkg)
line_style = RooFit.LineStyle(kDashed)
model.plotOn(frame, cp_bkg, line_style)
if print_pars:
fmt = RooFit.Format('NEU')
lyt = RooFit.Layout(0.65, 0.95, 0.92)
param = model.paramOn(frame, fmt, lyt)
param.getAttText().SetTextSize(0.02)
param.getAttText().SetTextFont(60)
frame.Draw()
#.........这里部分代码省略.........
示例15: buildMassAndLifetimePDF
# 需要导入模块: from ROOT import RooArgList [as 别名]
# 或者: from ROOT.RooArgList import add [as 别名]
def buildMassAndLifetimePDF(ws):
#define mass shape
ws.factory('RooCBShape::massCBShape(JpsiMass,CBmass[3.1,3.05,3.15],CBsigma[0.02,0.0001,1],CBalpha[1,.0001,5],CBn[10,.0001,50])')
#ws.factory('RooGaussian::massCBShape(JpsiMass,CBmass[3.1,3.05,3.15],CBsigma[0.02,0.0001,1])')
ws.factory('RooExponential::bkgMassShape(JpsiMass,bkgLambda[0,-5,5])')
#ws.factory('RooChebychev::bkgMassShape(JpsiMass,{p0[1,-10,10],p1[1,-10,10],p2[1,-10,10]})')
#lifetime
ws.factory('RooGaussModel::promptLifetimeRaw(Jpsict,promptMean[0,-1,1],ctResolution[1,.001,5],1,JpsictErr)')
ws.pdf('promptLifetimeRaw').advertiseFlatScaleFactorIntegral(True)
ws.factory('RooDecay::nonPromptSSDRaw(Jpsict,nonPromptTau[.3,.01,3],promptLifetimeRaw,RooDecay::SingleSided)')
ws.factory('RooDecay::backgroundSSDRawL(Jpsict,bkgTauSSDL[.3,0,3],promptLifetimeRaw,RooDecay::SingleSided)')
#ws.factory('RooDecay::backgroundFDRaw(Jpsict,bkgTauFD[.3,.0001,3],promptLifetimeRaw,RooDecay::Flipped)')
ws.factory('RooDecay::backgroundDSDRawL(Jpsict,bkgTauDSDL[.3,0,3],promptLifetimeRaw,RooDecay::DoubleSided)')
ws.factory('SUM::backgroundRawL(fBkgSSDL[.5,0,1]*backgroundSSDRawL,backgroundDSDRawL)')
ws.factory('RooDecay::backgroundSSDRawR(Jpsict,bkgTauSSDR[.3,0,3],promptLifetimeRaw,RooDecay::SingleSided)')
#ws.factory('RooDecay::backgroundFDRaw(Jpsict,bkgTauFD[.3,.0001,3],promptLifetimeRaw,RooDecay::Flipped)')
ws.factory('RooDecay::backgroundDSDRawR(Jpsict,bkgTauDSDR[.3,0,3],promptLifetimeRaw,RooDecay::DoubleSided)')
ws.factory('SUM::backgroundRawR(fBkgSSDR[.5,0,1]*backgroundSSDRawR,backgroundDSDRawR)')
ws.factory('SUM::backgroundRaw(fBkgLR[.5]*backgroundRawL,backgroundDSDRawR)')
ws.factory('PROD::promptRawMass(massCBShape)') #,promptLifetimeRaw|JpsictErr
ws.factory('PROD::nonpromptRawMass(massCBShape)') #,nonPromptSSDRaw|JpsictErr
ws.factory('PROD::backgroundRawMass(bkgMassShape)') #,backgroundDSDRaw|JpsictErr
ws.factory('PROD::promptRawCTau(promptLifetimeRaw|JpsictErr)')
ws.factory('PROD::nonpromptRawCTau(nonPromptSSDRaw|JpsictErr)')
ws.factory('PROD::backgroundRawCTauL(backgroundRawL|JpsictErr)')
ws.factory('PROD::backgroundRawCTauR(backgroundRawR|JpsictErr)')
ws.factory('PROD::backgroundRawCTau(backgroundRaw|JpsictErr)')
#extended pdfs
ws.factory('RooExtendPdf::promptExtMass(promptRawMass,sum::nPrompt(nPromptSignal[1000,0,1000000]))') #,nPromptL[1000,0,1000000],nPromptR[1000,0,1000000]
ws.factory('RooExtendPdf::nonpromptExtMass(nonpromptRawMass,sum::nNonPrompt(nNonPromptSignal[500,0,1000000]))')
#[500,0,1000000],,nNonPromptL[500,0,1000000],nNonPromptR[500,0,1000000]
ws.factory('RooExtendPdf::backgroundExtMass(backgroundRawMass,sum::nBackground(nBackgroundSignal[100,0,1000000],nBackgroundL[100,0,1000000],nBackgroundR[100,0,1000000]))') #
ws.factory('RooExtendPdf::promptExtCTauL(promptRawCTau,0)') #nPromptL[1,0,1000000]
ws.factory('RooExtendPdf::promptExtCTauR(promptRawCTau,0)')#nPromptR[1,0,1000000]
ws.factory('RooExtendPdf::nonpromptExtCTauL(nonpromptRawCTau,0)') #nNonPromptL[1,0,1000000]
ws.factory('RooExtendPdf::nonpromptExtCTauR(nonpromptRawCTau,0)') #nNonPromptR[1,0,1000000]
ws.factory('RooExtendPdf::backgroundExtCTauL(backgroundRawCTauL,nBackgroundL)')
ws.factory('RooExtendPdf::backgroundExtCTauR(backgroundRawCTauR,nBackgroundR)')
ws.factory('RooExtendPdf::promptExtCTau(promptRawCTau,nPromptSignal)')
ws.factory('RooExtendPdf::nonpromptExtCTau(nonpromptRawCTau,nNonPromptSignal)')
ws.factory('RooExtendPdf::backgroundExtCTau(backgroundRawCTau,nBackgroundSignal)')
#final AddPdfs
promptMArgList = RooArgList(ws.pdf('promptExtMass'))
nonPromptMArgList = RooArgList(ws.pdf('promptExtMass'),
ws.pdf('nonpromptExtMass'))
if options.doNonPrompt:
promptMArgList.add(ws.pdf('nonpromptExtMass'))
if options.doBackground:
promptMArgList.add(ws.pdf('backgroundExtMass'))
nonPromptMArgList.add(ws.pdf('backgroundExtMass'))
promptM = RooAddPdf('promptMass','prompt',promptMArgList)
nonpromptM = RooAddPdf('nonpromptMass','nonprompt',nonPromptMArgList)
backgroundM = RooAddPdf('backgroundMass','background',RooArgList(ws.pdf('promptExtMass'),
ws.pdf('nonpromptExtMass'),
ws.pdf('backgroundExtMass')))
promptCTArgList = RooArgList(ws.pdf('promptExtCTau'))
nonPromptCTArgList = RooArgList(ws.pdf('promptExtCTau'),
ws.pdf('nonpromptExtCTau'))
if options.doNonPrompt:
promptCTArgList.add(ws.pdf('nonpromptExtCTau'))
if options.doBackground:
promptCTArgList.add(ws.pdf('backgroundExtCTau'))
nonPromptCTArgList.add(ws.pdf('backgroundExtCTau'))
promptCT = RooAddPdf('promptCTau','prompt',promptCTArgList)
nonpromptCT = RooAddPdf('nonpromptCTau','nonprompt',nonPromptCTArgList)
backgroundCT = RooAddPdf('backgroundCTau','background',RooArgList(ws.pdf('promptExtCTau'),
ws.pdf('nonpromptExtCTau'),
ws.pdf('backgroundExtCTau')))
#playing around with signal in left sideband
backgroundCTL = RooAddPdf('backgroundCTauL','background',RooArgList(ws.pdf('promptExtCTauL'),
ws.pdf('nonpromptExtCTauL'),
ws.pdf('backgroundExtCTauL')))
backgroundCTR = RooAddPdf('backgroundCTauR','background',RooArgList(ws.pdf('promptExtCTauR'),
ws.pdf('nonpromptExtCTauR'),
ws.pdf('backgroundExtCTauR')))
getattr(ws,'import')(promptM)
getattr(ws,'import')(nonpromptM)
getattr(ws,'import')(backgroundM)
getattr(ws,'import')(promptCT)
getattr(ws,'import')(nonpromptCT)
getattr(ws,'import')(backgroundCT)
#.........这里部分代码省略.........