# build simultaneous mass PDF
    print 'P2VV - INFO: createB2CCFitNTuple: building simultaneous PDF "%s":' % ( massPdf.GetName() + '_simul' )
    print 13 * ' ' + 'splitting categories: [ %s ]' % ' ], [ '.join(', '.join(cat.GetName() for cat in cats) for cats in splitCats)
    print 13 * ' ' + 'split parameters:     [ %s ]' % ' ], [ '.join(', '.join(par.GetName() for par in pars) for pars in splitPars)
    from P2VV.RooFitWrappers import SimultaneousPdf
    sWeightMassPdf = SimultaneousPdf(  massPdf.GetName() + '_simul'
                                     , MasterPdf       = massPdf
                                     , SplitCategories = splitCats
                                     , SplitParameters = splitPars
                                    )

    # set yields for categories
    splitCat      = sWeightMassPdf.indexCat()
    splitCatIter  = splitCat.typeIterator()
    splitCatState = splitCatIter.Next()
    massPdfPars   = sWeightMassPdf.getVariables()
    from P2VV.Utilities.General import getSplitPar
    from math import sqrt
    while splitCatState :
        KKMassState = -1
        if splitCat.isFundamental() :
            selStr = '!(%s-%d)' % ( splitCat.GetName(), splitCatState.getVal() )
            if splitCat.GetName() == observables['KKMassCat'].GetName() : KKMassState = splitCatState.getVal()
        else :
            splitCat.setLabel( splitCatState.GetName() )
            selStr = ' && '.join( '!(%s-%d)' % ( cat.GetName(), cat.getIndex() ) for cat in splitCat.inputCatList() )
            if observables['KKMassCat'] in splitCats[0] :
                for cat in splitCat.inputCatList() :
                    if cat.GetName() == observables['KKMassCat'].GetName() : KKMassState = cat.getIndex()

        nEv    = dataSets['pre'][0].sumEntries()
Exemple #2
0
# categories for splitting the PDF
if not options.prescaled:
    split_cats = [[excl_biased]]
    # get mass parameters that are split
    split_params = [[par for par in mass_pdf.Parameters() if par.getAttribute("Yield")]]

    # build simultaneous mass PDF
    from P2VV.RooFitWrappers import SimultaneousPdf

    sWeight_mass_pdf = SimultaneousPdf(
        mass_pdf.GetName() + "_simul", MasterPdf=mass_pdf, SplitCategories=split_cats, SplitParameters=split_params
    )

    # set yields for categories
    split_cat = sWeight_mass_pdf.indexCat()
    split_vars = sWeight_mass_pdf.getVariables()
    from P2VV.Utilities.General import getSplitPar
    from math import sqrt

    for state in split_cat:
        sigYield = getSplitPar("N_signal", state.GetName(), split_vars)
        bkgYield = getSplitPar("N_background", state.GetName(), split_vars)

        selStr = "{0} == {0}::{1}".format(split_cat.GetName(), state.GetName())

        nEv = data.sumEntries()
        nEvBin = data.sumEntries(selStr)

        sigYield.setVal(sigYield.getVal() * nEvBin / nEv)
        sigYield.setError(sqrt(sigYield.getVal()))
        sigYield.setMin(0.0)