Beispiel #1
0
def main():
    dirEmbs = ["."] + [os.path.join("..", d) for d in result.dirEmbs[1:]]

    tauEmbedding.normalize = True
    tauEmbedding.era = "Run2011A"

    table = counter.CounterTable()
    for i in xrange(len(dirEmbs)):
        tmp = dirEmbs[:]
        del tmp[i]
        row = doCounters(tmp)
        row.setName("Removed embedding %d" % i)
        table.appendRow(row)

    arows = []
    arows.append(counter.meanRow(table))
    arows.append(counter.maxRow(table))
    arows.append(counter.minRow(table))
    arows.append(counter.subtractRow("Max-mean", arows[1], arows[0]))
    arows.append(counter.subtractRow("Mean-min", arows[0], arows[2]))
    for r in arows:
        table.appendRow(r)

    cellFormat = counter.TableFormatText(
        counter.CellFormatTeX(valueFormat='%.3f'))
    print "DeltaPhi < 160"
    print
    print table.format(cellFormat)
def main():
    dirEmbs = ["."] + [os.path.join("..", d) for d in result.dirEmbs[1:]]

    tauEmbedding.normalize=True
    tauEmbedding.era = "Run2011A"
 
    table = counter.CounterTable()
    for i in xrange(len(dirEmbs)):
        tmp = dirEmbs[:]
        del tmp[i]
        row = doCounters(tmp)
        row.setName("Removed embedding %d"%i)
        table.appendRow(row)

    arows = []
    arows.append(counter.meanRow(table))
    arows.append(counter.maxRow(table))
    arows.append(counter.minRow(table))
    arows.append(counter.subtractRow("Max-mean", arows[1], arows[0]))
    arows.append(counter.subtractRow("Mean-min", arows[0], arows[2]))
    for r in arows:
        table.appendRow(r)

    cellFormat = counter.TableFormatText(counter.CellFormatTeX(valueFormat='%.3f'))
    print "DeltaPhi < 160"
    print
    print table.format(cellFormat)
def main():
    dirEmbs = result.dirEmbs[:]
    if onlyWjets:
        dirEmbs.extend(dirEmbsWjets)
    dirEmbs = ["."] + [os.path.join("..", d) for d in dirEmbs[1:]]
#    dirEmbs = dirEmbs[0:2]

    style = tdrstyle.TDRStyle()

    tauEmbedding.normalize=normalize
    tauEmbedding.era = "Run2011A"

    ts = dataset.TreeScan(analysisEmb+"/tree", function=None, selection=And(metCut, bTaggingCut, deltaPhi160Cut))
    def printPickEvent(f, tree):
        f.write("%d:%d:%d\n" % (tree.run, tree.lumi, tree.event))

    table = counter.CounterTable()

    for i, d in enumerate(dirEmbs):
        datasets = dataset.getDatasetsFromMulticrabCfg(cfgfile=d+"/multicrab.cfg", counters=analysisEmb+"Counters")
        datasets.updateNAllEventsToPUWeighted()
        if onlyWjets:
            datasets.remove(filter(lambda n: n != "WJets_TuneZ2_Summer11", datasets.getAllDatasetNames()))
        else:
            if mcEvents:
                datasets.remove(filter(lambda n: n != "WJets_TuneZ2_Summer11" and n != "TTJets_TuneZ2_Summer11" and not "SingleMu" in n, datasets.getAllDatasetNames()))
            datasets.loadLuminosities()
        datasets.remove(filter(lambda name: "HplusTB" in name, datasets.getAllDatasetNames()))
        datasets.remove(filter(lambda name: "TTToHplus" in name, datasets.getAllDatasetNames()))
        plots.mergeRenameReorderForDataMC(datasets)

        # for ds in datasets.getAllDatasets():
        #     f = open("pickEvents_%s_%d.txt" % (ds.getName(), i), "w")
        #     ds.getDatasetRootHisto(ts.clone(function=lambda tree: printPickEvent(f, tree)))
        #     f.close()

        row = doCounters(datasets)
        row.setName("Embedding %d" % i)
        table.appendRow(row)

    doPlots(table)

    arows = []
    arows.append(counter.meanRow(table))
    arows.extend(counter.meanRowFit(table))
    arows.append(counter.maxRow(table))
    arows.append(counter.minRow(table))
    for r in arows:
        table.appendRow(r)

#    csvSplitter = counter.TableSplitter([" \pm "])
#    cellFormat = counter.TableFormatText(counter.CellFormatTeX(valueFormat='%.3f'), columnSeparator=",")
    cellFormat = counter.TableFormatText(counter.CellFormatTeX(valueFormat='%.3f'))
    print "DeltaPhi < 160"
    print
    print table.format(cellFormat)
def do(onlyWjets, mcEvents, normalize, formatCounters, formatPlots):
    dirEmbs = tauEmbedding.dirEmbs[:]
    if onlyWjets:
        dirEmbs.extend(dirEmbsWjets)
    dirEmbs = ["."] + [os.path.join("..", d) for d in dirEmbs[1:]]
#    dirEmbs = dirEmbs[0:2]

    # Read luminosity
    datasets = dataset.getDatasetsFromMulticrabCfg(cfgfile=dirEmbs[0]+"/multicrab.cfg", counters=analysisEmb+"Counters", weightedCounters=False)
    datasets.loadLuminosities()
    plots.mergeRenameReorderForDataMC(datasets)
    lumi = datasets.getDataset("Data").getLuminosity()


    style = tdrstyle.TDRStyle()
    histograms.cmsTextMode = histograms.CMSMode.SIMULATION
    histograms.cmsText[histograms.cmsTextMode] = "Simulation"

    tauEmbedding.normalize=normalize
    tauEmbedding.era = "Run2011A"

    table = counter.CounterTable()
    for i, d in enumerate(dirEmbs):
        datasets = dataset.getDatasetsFromMulticrabCfg(cfgfile=d+"/multicrab.cfg", counters=analysisEmb+"Counters", weightedCounters=False)
        if onlyWjets:
            datasets.remove(filter(lambda n: n != "WJets_TuneZ2_Summer11", datasets.getAllDatasetNames()))
        else:
            if mcEvents:
                datasets.remove(filter(lambda n: n != "WJets_TuneZ2_Summer11" and n != "TTJets_TuneZ2_Summer11" and not "SingleMu" in n, datasets.getAllDatasetNames()))
            datasets.loadLuminosities()
        datasets.remove(filter(lambda name: "HplusTB" in name, datasets.getAllDatasetNames()))
        datasets.remove(filter(lambda name: "TTToHplus" in name, datasets.getAllDatasetNames()))
        tauEmbedding.updateAllEventsToWeighted(datasets)
        plots.mergeRenameReorderForDataMC(datasets)

        row = doCounters(datasets, onlyWjets, mcEvents, normalize, lumi)
        row.setName("Embedding %d" % i)
        table.appendRow(row)

    if formatPlots:
        doPlots(table, onlyWjets, mcEvents, normalize, lumi)

    if not formatCounters:
        return

    arows = []
    arows.append(counter.meanRow(table))
    arows.extend(counter.meanRowFit(table))
    arows.append(counter.maxRow(table))
    arows.append(counter.minRow(table))
    for r in arows:
        table.appendRow(r)

    print table.format()

    ftable = counter.CounterTable()
    def addRow(name):
        col = table.getColumn(name=name)

        minimum = col.getCount(name="Min")
        maximum = col.getCount(name="Max")
        mean = col.getCount(name="Mean")

        ftable.appendRow(counter.CounterRow(name,
                                            ["Mean", "Minimum", "Maximum"],
                                            [mean, minimum, maximum]))
    addRow("Data")
    addRow("EWKMCsum")
    addRow("TTJets")
    addRow("WJets")
    addRow("DYJetsToLL")
    addRow("SingleTop")
    addRow("Diboson")

    cellFormat2 = counter.TableFormatLaTeX(counter.CellFormatTeX(valueFormat="%.4f", withPrecision=2))
    print ftable.format(cellFormat2)
Beispiel #5
0
def main():
    dirEmbs = result.dirEmbs[:]
    if onlyWjets:
        dirEmbs.extend(dirEmbsWjets)
    dirEmbs = ["."] + [os.path.join("..", d) for d in dirEmbs[1:]]
    #    dirEmbs = dirEmbs[0:2]

    style = tdrstyle.TDRStyle()

    tauEmbedding.normalize = normalize
    tauEmbedding.era = "Run2011A"

    ts = dataset.TreeScan(analysisEmb + "/tree",
                          function=None,
                          selection=And(metCut, bTaggingCut, deltaPhi160Cut))

    def printPickEvent(f, tree):
        f.write("%d:%d:%d\n" % (tree.run, tree.lumi, tree.event))

    table = counter.CounterTable()

    for i, d in enumerate(dirEmbs):
        datasets = dataset.getDatasetsFromMulticrabCfg(
            cfgfile=d + "/multicrab.cfg", counters=analysisEmb + "Counters")
        if onlyWjets:
            datasets.remove(
                filter(lambda n: n != "WJets_TuneZ2_Summer11",
                       datasets.getAllDatasetNames()))
        else:
            if mcEvents:
                datasets.remove(
                    filter(
                        lambda n: n != "WJets_TuneZ2_Summer11" and n !=
                        "TTJets_TuneZ2_Summer11" and not "SingleMu" in n,
                        datasets.getAllDatasetNames()))
            datasets.loadLuminosities()
        datasets.remove(
            filter(lambda name: "HplusTB" in name,
                   datasets.getAllDatasetNames()))
        datasets.remove(
            filter(lambda name: "TTToHplus" in name,
                   datasets.getAllDatasetNames()))
        tauEmbedding.updateAllEventsToWeighted(datasets)
        plots.mergeRenameReorderForDataMC(datasets)

        # for ds in datasets.getAllDatasets():
        #     f = open("pickEvents_%s_%d.txt" % (ds.getName(), i), "w")
        #     ds.getDatasetRootHisto(ts.clone(function=lambda tree: printPickEvent(f, tree)))
        #     f.close()

        row = doCounters(datasets)
        row.setName("Embedding %d" % i)
        table.appendRow(row)

    doPlots(table)

    arows = []
    arows.append(counter.meanRow(table))
    arows.extend(counter.meanRowFit(table))
    arows.append(counter.maxRow(table))
    arows.append(counter.minRow(table))
    for r in arows:
        table.appendRow(r)

#    csvSplitter = counter.TableSplitter([" \pm "])
#    cellFormat = counter.TableFormatText(counter.CellFormatTeX(valueFormat='%.3f'), columnSeparator=",")
    cellFormat = counter.TableFormatText(
        counter.CellFormatTeX(valueFormat='%.3f'))
    print "DeltaPhi < 160"
    print
    print table.format(cellFormat)
Beispiel #6
0
def main():
    dirEmbs = ["."] + [os.path.join("..", d) for d in tauEmbedding.dirEmbs[1:]]
#    dirEmbs = dirEmbs[:2]

    tauEmbedding.normalize=True
    tauEmbedding.era = "Run2011A"
 
    table = counter.CounterTable()
    for i in xrange(len(dirEmbs)):
        tmp = dirEmbs[:]
        del tmp[i]
        row = doCounters(tmp)
        row.setName("Removed embedding %d"%i)
        table.appendRow(row)

    arows = []
    arows.append(counter.meanRow(table))
    arows.append(counter.maxRow(table))
    arows.append(counter.minRow(table))
    arows.append(counter.subtractRow("Max-mean", arows[1], arows[0]))
    arows.append(counter.subtractRow("Mean-min", arows[0], arows[2]))
    for r in arows:
        table.appendRow(r)

    cellFormat = counter.TableFormatText(counter.CellFormatTeX(valueFormat='%.3f'))
    print "DeltaPhi < 160"
    print
    print table.format(cellFormat)
    print
    print

    # Format the table as in AN
    ftable = counter.CounterTable()
    def addRow(name):
        col = table.getColumn(name=name)

        minimum = col.getCount(name="Min")
        maximum = col.getCount(name="Max")

        # Maximum deviation from average
        dev1 = col.getCount(name="Max-mean")
        dev2 = col.getCount(name="Mean-min")
        if dev2.value() > dev1.value():
            dev1 = dev2

        dev1.divide(col.getCount(name="Mean"))
        dev1.multiply(dataset.Count(100))

        ftable.appendRow(counter.CounterRow(name,
                                            ["Minimum", "Maximum", "Largest deviation from average (%)"],
                                            [minimum, maximum, dev1]))

    addRow("Data")
    addRow("EWKMCsum")
    addRow("TTJets")
    addRow("WJets")
    addRow("DYJetsToLL")
    addRow("SingleTop")
    addRow("Diboson")

    cellFormat2 = counter.TableFormatLaTeX(counter.CellFormatTeX(valueFormat="%.4f", withPrecision=2))
    cellFormat2.setColumnFormat(counter.CellFormatTeX(valueFormat="%.1f", valueOnly=True), index=2)
    print ftable.format(cellFormat2)