Пример #1
0
for it, pars in enumerate(splitPars) :
    print 13 * ' ' + '%2d: pars: [ %s ]' % ( it, ', '.join( par.GetName() for par in pars[0] ) )
    print 13 * ' ' + '    cats: [ %s ]' % ', '.join( cat.GetName() for cat in pars[1] )
from P2VV.RooFitWrappers import SimultaneousPdf
sWeightMassPdf = SimultaneousPdf(  massPdf.GetName() + '_simul'
                                 , MasterPdf       = massPdf
                                 , SplitCategories = [ pars[1] for pars in splitPars ]
                                 , SplitParameters = [ pars[0] for pars in splitPars ]
                                )
massPdfObs  = sWeightMassPdf.getObservables(preDataSet)
massPdfPars = sWeightMassPdf.getParameters(preDataSet)

if model == 'ipatia2' :
    # set values of constant Ipatia 2 parameters
    from P2VV.Utilities.General import getSplitPar
    for splitCat in sWeightMassPdf.indexCat() :
        sWeightMassPdf.indexCat().setIndex( splitCat.getVal() )
        KKState = observables['KKMassCat'].getLabel()
        for it, parName in enumerate(constSplitPars) :
            par = getSplitPar( parName, KKState, massPdfPars )
            par.setVal( constSplitVals[KKState][it] )

if parFileIn or parFileOut :
    # create PDF configuration object
    from P2VV.Parameterizations.FullPDFs import PdfConfiguration as PdfConfig
    pdfConfig = PdfConfig()

print 120 * '='
if parFileIn :
    # read parameters from file
    pdfConfig.readParametersFromFile( filePath = parFileIn )
Пример #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()))
Пример #3
0
                splitPars[-1].add(par1)
                splitParsDict.pop(par1)

    # 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() :
Пример #4
0
###########################################################################################################################################
## split data into signal and background ##
###########################################

# create integration sets
from ROOT import RooArgSet
intSet = RooArgSet()
normSet = RooArgSet( massPdfObs.find('mass') )

# get signal and background mass PDFs
comps = [ 'sig', 'cbkg' ]
yields = dict( sig = { }, cbkg = { } )
pdfs   = dict( sig = { }, cbkg = { } )
from P2VV.Utilities.General import getSplitPar
splitCat = simMassPdf.indexCat()
for state in splitCat :
    stateName = state.GetName()
    yields['sig'][stateName]  = getSplitPar( 'N_sigMass',  stateName, massPdfPars ).getVal()
    yields['cbkg'][stateName] = getSplitPar( 'N_cbkgMass', stateName, massPdfPars ).getVal()
    if genMass :
        pdfs['sig'][stateName]  = simMassPdf.getPdf(stateName).pdfList().at(0)
        pdfs['cbkg'][stateName] = simMassPdf.getPdf(stateName).pdfList().at(1)
    else :
        pdfs['sig'][stateName]  = simMassPdf.getPdf(stateName).pdfList().at(0).createIntegral( intSet, normSet )
        pdfs['cbkg'][stateName] = simMassPdf.getPdf(stateName).pdfList().at(1).createIntegral( intSet, normSet )
for comp in comps :
    yields[comp]['total'] = sum( y for y in yields[comp].itervalues() )

print 'P2VV - INFO: signal and background yields:'
for comp in comps :