Beispiel #1
0
def printCounters(counters):
    countTotalBkg(counters)
    blindGroups   = [g for g in counters.keys() if g!='data']
    unblindGroups = [g for g in counters.keys()]
    tableSr  = CutflowTable(samples=blindGroups,   selections=signalRegions(), countsSampleSel=counters)
    tablePre = CutflowTable(samples=blindGroups,   selections=controlRegions(), countsSampleSel=counters)
    tableBld = CutflowTable(samples=unblindGroups, selections=blindRegions(), countsSampleSel=counters)
    for table in [tableSr, tablePre, tableBld] : table.nDecimal = 6
    print 4*'-',' sig regions ',4*'-'
    print tableSr.csv()
    print 4*'-',' pre regions ',4*'-'
    print tablePre.csv()
    print 4*'-',' blind regions ',4*'-'
    print tableBld.csv()
Beispiel #2
0
def printCounters(counters):
    countTotalBkg(counters)
    blindGroups = [g for g in counters.keys() if g != 'data']
    unblindGroups = [g for g in counters.keys()]
    tableSr = CutflowTable(samples=blindGroups,
                           selections=signalRegions(),
                           countsSampleSel=counters)
    tablePre = CutflowTable(samples=blindGroups,
                            selections=controlRegions(),
                            countsSampleSel=counters)
    tableBld = CutflowTable(samples=unblindGroups,
                            selections=blindRegions(),
                            countsSampleSel=counters)
    for table in [tableSr, tablePre, tableBld]:
        table.nDecimal = 6
    print 4 * '-', ' sig regions ', 4 * '-'
    print tableSr.csv()
    print 4 * '-', ' pre regions ', 4 * '-'
    print tablePre.csv()
    print 4 * '-', ' blind regions ', 4 * '-'
    print tableBld.csv()
allSamples += ['totbkg'] if printTotBkg else []
allSelects = sorted(list(set([k.pr for k in histosByType.keys()])))
if verbose : print 'allSamples : ',allSamples
if verbose : print 'allSelects : ',allSelects

# get the counts (adding up what needs to be merged by samplename)
sampleCountsPerSel = dict() # counts[sample][sel]
countsSampleSel = dict([(s, collections.defaultdict(float)) for s in allSamples])
for t, histos in refHistos.iteritems() :
    if t.ch != channel : continue
    for h in histos :
        sample, sel = h.sample, h.type.pr
        cnt = h.GetEntries() if rawcnt else h.Integral()
        skipIt = not printData and sample=='data'
        countIt = not skipIt
        countsSampleSel[sample][sel] += cnt if countIt else 0.0
        if printTotBkg and isBkgSample(sample) :
            countsSampleSel['totbkg'][sel] += cnt

ct = CutflowTable(allSamples, allSelects, countsSampleSel,
                  isRawCount=rawcnt, selectionRegexp=selRegexp)
csv = ct.csv()
print csv
if csvFile :
    with open(csvFile, 'w') as f : f.write(csv)
if texFile :
    with open(texFile, 'w') as f : f.write(ct.latex())
if pklFile :
    dumpToPickle(pklFile, countsSampleSel)