예제 #1
0
sigMassComps += signalBMass.pdf()

# build the combinatorial background mass PDF
from P2VV.Parameterizations.MassPDFs import LP2011_Background_Mass as BackgroundBMass
backgroundBMass = BackgroundBMass( Name = 'cbkg_m', mass = observables['mass'] )
cbkgMassComps += backgroundBMass.pdf()

# build total mass PDF
from P2VV.RooFitWrappers import buildPdf
massPdf = buildPdf( massComps, Observables = [ observables['mass'] ], Name = 'JpsiKKMass' )

# get splitting categories and parameters
yieldNames  = [ par.GetName() for par in massPdf.Parameters() if par.getAttribute('Yield') ]
allParNames = [ par.GetName() for par in massPdf.Parameters() if not par.getAttribute('Yield') if not par.isConstant() ]
sigParNames = [ par.GetName() for par in signalBMass.parameters() if not par.isConstant() ]
bkgParNames = [ par.GetName() for par in backgroundBMass.parameters() if not par.isConstant() ]
splitCats = {  observables['runPeriod'].GetName() : set( yieldNames + bkgParNames )
             , observables['KKMassCat'].GetName() : set( yieldNames               )
            }
if not biasedOnly :
    splitCats[ observables['hlt2B'].GetName() ] = set( yieldNames + bkgParNames )
if model == 'ipatia2' :
    # split Ipatia 2 signal parameters
    hlt2BName = observables['hlt2B'].GetName()
    KKCatName = observables['KKMassCat'].GetName()
    for parName in sigParNames :
        if not biasedOnly and 'sigma' in parName : splitCats[hlt2BName].add(parName)
        splitCats[KKCatName].add(parName)
    for parName in constSplitPars :
        splitCats[KKCatName].add(parName)
예제 #2
0
print 120 * '='
print 'P2VV - INFO: createB2CCFitNTuple: fitting with mass PDF'
massFitResult = massPdf.fitTo( dataSets['pre'][0], Save = True, **fitOpts )

from P2VV.Imports import parNames
massFitResult.PrintSpecial( text = True, ParNames = parNames )

if runPeriods or triggerSel in ['paper2012', 'timeEffFit'] or len(KKMassBinBounds) > 2 :
    # get splitting categories and parameters
    splitCats = { }
    yieldNames = [ par.GetName() for par in massPdf.Parameters() if par.getAttribute('Yield') ]
    if runPeriods :
        splitCats[observables['runPeriod'].GetName()] = set([ par.GetName() for par in massPdf.Parameters() if not par.isConstant() ])
    if len(KKMassBinBounds) > 2 :
        splitCats[ observables['KKMassCat'].GetName() ] = set(yieldNames)
        for par in backgroundBMass.parameters() :
            if not par.isConstant() : splitCats[ observables['KKMassCat'].GetName() ].add( par.GetName() )
    if triggerSel == 'paper2012' or triggerSel == 'timeEffFit' :
        splitCats[ observables['hlt1ExclB'].GetName() ] = set(yieldNames)
    if triggerSel == 'timeEffFit' :
        splitCats[ observables['hlt2B'].GetName() ] = set(yieldNames)

    splitParsDict = { }
    pdfVars = massPdf.getVariables()
    for cat, params in splitCats.iteritems() :
        assert ws.cat(cat), 'P2VV - ERROR: createB2CCFitNTuple: category "%s" not in workspace' % cat
        for par in params :
            assert ws.var(par), 'P2VV - ERROR: createB2CCFitNTuple: no variable "%s" in workspace' % par
            assert pdfVars.find(par), 'P2VV - ERROR: createB2CCFitNTuple: variable "%s" not in PDF' % par
            if ws[par] not in splitParsDict :
                splitParsDict[ ws[par] ] = set( [ ws[cat] ] )