コード例 #1
0
def getSystDict(cardFnames, region, sig = "", lep = "lep", uncert = "default"):
    yields = {}
    for cardFname in cardFnames:
        binname = os.path.basename(cardFname)
        binname = binname.replace('.merge.root','')
        tfile = TFile(cardFname,"READ")
        if 'Scan' in sig:
            sampleDict = getScanYieldDict(tfile, sig ,region, lep)

            if type(uncert) == float:
                sampleDict.update({key: ( uncert, 0)  for key in sampleDict.keys() } )
            
            yields[binname] = sampleDict


        else:
            tfile.cd(region)
            dirList = gDirectory.GetListOfKeys()
            sourceYield = {}

            for k1 in dirList:
                h1 = k1.ReadObj().GetName()
                
                (yd, yerr)  = getYield(tfile, h1, region, (lep,'sele'))
                if type(uncert) == float:
                    sourceYield[h1] = (uncert , 0)

                yields[binname] = sourceYield
    return yields
コード例 #2
0
def getYieldDict(cardFnames, region, sig = "", lep = "lep"):
    print "getting dict", sig
    yields = {}
    for cardFname in cardFnames:
        binname = os.path.basename(cardFname)
        binname = binname.replace('.merge.root','')
        tfile = TFile(cardFname,"READ")
        if 'Scan' in sig:
            yields[binname] = getScanYieldDict(tfile, sig ,region, lep)
            
        else:
            tfile.cd(region)
            dirList = gDirectory.GetListOfKeys()
            sourceYield = {}

            for k1 in dirList:
                print k1, k1.ReadObj().GetName()
                if 'Name' in k1.ReadObj().GetName() or 'name' in k1.ReadObj().GetName(): continue
                h1 = k1.ReadObj().GetName()
                
                (yd, yerr)  = getYield(tfile, h1, region, (lep,'sele'))
                if 'dummy' in sig:
                    sourceYield[h1] = (0.3, 0)
                else:
                    sourceYield[h1] = (yd, yerr)
                yields[binname] = sourceYield
    return yields
コード例 #3
0
ファイル: printTableDataCards.py プロジェクト: smdogra/mTop
def getSystDict(cardFnames, region, sig="", lep="lep", uncert="default"):
    yields = {}
    for cardFname in cardFnames:
        binname = os.path.basename(cardFname)
        binname = binname.replace('.merge.root', '')
        tfile = TFile(cardFname, "READ")
        if 'Scan' in sig:
            sampleDict = getScanYieldDict(tfile, sig, region, lep)

            if type(uncert) == float:
                sampleDict.update(
                    {key: (uncert, 0)
                     for key in sampleDict.keys()})

            yields[binname] = sampleDict

        else:
            tfile.cd(region)
            dirList = gDirectory.GetListOfKeys()
            sourceYield = {}

            for k1 in dirList:
                h1 = k1.ReadObj().GetName()

                (yd, yerr) = getYield(tfile, h1, region, (lep, 'sele'))
                if type(uncert) == float:
                    sourceYield[h1] = (uncert, 0)

                yields[binname] = sourceYield
    return yields
コード例 #4
0
ファイル: printTableDataCards.py プロジェクト: smdogra/mTop
def getYieldDict(cardFnames, region, sig="", lep="lep"):
    print "getting dict", sig
    yields = {}
    for cardFname in cardFnames:
        binname = os.path.basename(cardFname)
        binname = binname.replace('.merge.root', '')
        tfile = TFile(cardFname, "READ")
        if 'Scan' in sig:
            yields[binname] = getScanYieldDict(tfile, sig, region, lep)

        else:
            tfile.cd(region)
            dirList = gDirectory.GetListOfKeys()
            sourceYield = {}

            for k1 in dirList:
                print k1, k1.ReadObj().GetName()
                if 'Name' in k1.ReadObj().GetName() or 'name' in k1.ReadObj(
                ).GetName():
                    continue
                h1 = k1.ReadObj().GetName()

                (yd, yerr) = getYield(tfile, h1, region, (lep, 'sele'))
                if 'dummy' in sig:
                    sourceYield[h1] = (0.3, 0)
                else:
                    sourceYield[h1] = (yd, yerr)
                yields[binname] = sourceYield
    return yields
コード例 #5
0
ファイル: printTableDataCards.py プロジェクト: smdogra/mTop
def getPredDict(cardFnames, lep='lep'):
    yields = {}
    for cardFname in cardFnames:
        binname = os.path.basename(cardFname)
        binname = binname.replace('.merge.root', '')
        tfile = TFile(cardFname, "READ")
        h1 = "background"

        (ySR_MB, ySR_MBerr) = getYield(tfile, h1, "SR_MB", (lep, 'sele'))

        (yCR_MB, yCR_MBerr) = getYield(tfile, h1, "CR_MB", ('lep', 'sele'))

        (yCR_SB, yCR_SBerr) = getYield(tfile, h1, "CR_SB", ('lep', 'sele'))
        (ySR_SB, ySR_SBerr) = getYield(tfile, h1, "SR_SB", ('lep', 'sele'))
        (Rcs_SB, Rcs_SBerr) = getYield(tfile, h1, "Rcs_SB", ('lep', 'sele'))
        (kappa, kappaerr) = getYield(tfile, h1, "Kappa", ('lep', 'sele'))

        #        print  binname, "CR_SB", (yCR_SB, yCR_SBerr), "SR_SB", (ySR_SB, ySR_SBerr),"RCS_SB",(Rcs_SB, Rcs_SBerr), "Kappa", (kappa, kappaerr)

        #predSR_MB = yCR_MB * Rcs_SB * kappa
        predSR_MB = yCR_MB * Rcs_SB
        if yCR_MB > 0.01 and kappa > 0.01 and Rcs_SB > 0.01:
            #            predSR_MBerr = predSR_MB * math.sqrt( (yCR_MBerr/yCR_MB)**2 + (kappaerr/kappa)**2 + (Rcs_SBerr/Rcs_SB)**2)
            predSR_MBerr = predSR_MB * math.sqrt((yCR_MBerr / yCR_MB)**2 +
                                                 (kappaerr / kappa)**2 +
                                                 (Rcs_SBerr / Rcs_SB)**2)
        else:
            predSR_MBerr = 1.0 * predSR_MB
        if predSR_MB < 0.001:
            predSR_MB = 0.01
            predSR_MBerr = 0.01
            #        print  binname, predSR_MB, ySR_MB, yCR_MB, Rcs_SB, kappa
        sourceYield = {}
        sourceYield['data'] = getYield(tfile, 'data', "SR_MB", (lep, 'sele'))
        sourceYield['RcsPred'] = (predSR_MB, predSR_MBerr)

        yields[binname] = sourceYield

    return yields
コード例 #6
0
def getPredDict(cardFnames, lep = 'lep'):
    yields = {}
    for cardFname in cardFnames:
        binname = os.path.basename(cardFname)
        binname = binname.replace('.merge.root','')
        tfile = TFile(cardFname,"READ")
        h1 = "background"
 
        (ySR_MB, ySR_MBerr) = getYield(tfile, h1, "SR_MB", (lep,'sele'))

        (yCR_MB, yCR_MBerr) = getYield(tfile, h1, "CR_MB", ('lep','sele'))

        (yCR_SB, yCR_SBerr) = getYield(tfile, h1, "CR_SB", ('lep','sele'))
        (ySR_SB, ySR_SBerr) = getYield(tfile, h1, "SR_SB", ('lep','sele'))
        (Rcs_SB, Rcs_SBerr) = getYield(tfile, h1, "Rcs_SB", ('lep','sele'))
        (kappa, kappaerr) = getYield(tfile, h1, "Kappa", ('lep','sele'))
        
#        print  binname, "CR_SB", (yCR_SB, yCR_SBerr), "SR_SB", (ySR_SB, ySR_SBerr),"RCS_SB",(Rcs_SB, Rcs_SBerr), "Kappa", (kappa, kappaerr)

        #predSR_MB = yCR_MB * Rcs_SB * kappa
        predSR_MB = yCR_MB * Rcs_SB
        if  yCR_MB > 0.01  and kappa > 0.01 and Rcs_SB > 0.01:
#            predSR_MBerr = predSR_MB * math.sqrt( (yCR_MBerr/yCR_MB)**2 + (kappaerr/kappa)**2 + (Rcs_SBerr/Rcs_SB)**2)
            predSR_MBerr = predSR_MB * math.sqrt( (yCR_MBerr/yCR_MB)**2 + (kappaerr/kappa)**2 + (Rcs_SBerr/Rcs_SB)**2)
        else: predSR_MBerr =  1.0 * predSR_MB
        if predSR_MB < 0.001 :
            predSR_MB = 0.01
            predSR_MBerr = 0.01
            #        print  binname, predSR_MB, ySR_MB, yCR_MB, Rcs_SB, kappa
        sourceYield = {}
        sourceYield['data'] = getYield(tfile, 'data', "SR_MB", (lep,'sele'))
        sourceYield['RcsPred'] = (predSR_MB, predSR_MBerr)

        yields[binname] = sourceYield

    return yields