Example #1
0
def inner_vars(outer, inner, mapOptions, oMapF, oMapB, oMapBcn):
    if inner:
        chainI = raw.tchain(inner)
        iMapF, iMapB, iMapBcn = eventMaps(chainI, inner)
        if mapOptions["identityMap"]:
            iMapF = oMapF
            iMapB = oMapB
            iMapBcn = oMapBcn

        innerEvent = eventToEvent(oMapF, iMapB)
        if set(innerEvent.values()) == set([None]):
            sys.exit(
                "No common events found.  Consider passing --identity-map.")

        if mapOptions['printEventMap']:
            for oEntry, iEntry in sorted(innerEvent.iteritems()):
                printer.msg(", ".join([
                    "oEntry = %s" % str(oEntry),
                    "oEvnOrn = %s" % str(oMapF[oEntry]),
                    "iEntry = %s" % str(iEntry),
                ]))
    else:
        chainI = None
        innerEvent = iMapF = iMapB = iMapBcn = {}

    return chainI, innerEvent, iMapF, iMapB, iMapBcn
Example #2
0
def go(outer={}, inner={}, outputFile="", mapOptions={}, options={}):

    raw.setup_root()
    import_plugins(outer["plugins"])
    outer.update(fileSpec(outer["fileNames"]))
    if inner:
        inner.update(fileSpec(inner["fileNames"]))
        if inner["fileNames"] == outer["fileNames"]:
            mapOptions["identityMap"] = True

    chain = raw.tchain(outer)
    oMapF, oMapB, oMapBcn = eventMaps(chain, outer, mapOptions["identityMap"])
    chainI, innerEvent, iMapF, iMapB, iMapBcn = inner_vars(
        outer, inner, mapOptions, oMapF, oMapB, oMapBcn)
    book = loop(chain=chain,
                chainI=chainI,
                outer=outer,
                inner=inner,
                innerEvent=innerEvent,
                oMapF=oMapF,
                options=options)

    utils.delete(chain)
    if chainI:
        utils.delete(chainI)

    # write results to a ROOT file
    dirName = os.path.dirname(outputFile)
    if not os.path.exists(dirName):
        print "Creating directory '%s'" % dirName
        os.mkdir(dirName)

    f = r.TFile(outputFile, "RECREATE")
    if not f.IsZombie():
        write_category_graphs(
            category_vs_time(oMap=oMapF,
                             oMapBcn=oMapBcn,
                             iMap=iMapF,
                             iMapBcn=iMapBcn,
                             innerEvent=innerEvent), outer, inner)
        for h in book.values():
            h.Write()
    f.Close()

    for h in book.values():
        utils.delete(h)

    if printEventSummary(outer, inner):
        s = "%s: %4s = %6d" % (outputFile, outer["label"], len(oMapF))
        if inner:
            nBoth = len(filter(lambda x: x is not None, innerEvent.values()))
            s += ", %4s = %6d, both = %6d" % (inner["label"], len(iMapB),
                                              nBoth)
        printer.msg(s)

    oFeds = sorted(outer.get("wargs", {}).keys())
    iFeds = sorted(inner.get("wargs", {}).keys()) if inner else []
    return not len(oMapF), oFeds, iFeds
Example #3
0
def go(outer={}, inner={}, outputFile="",
       mapOptions={}, options={}):

    raw.setup_root()
    import_plugins(outer["plugins"])
    outer.update(fileSpec(outer["fileNames"]))
    if inner:
        inner.update(fileSpec(inner["fileNames"]))
        if inner["fileNames"] == outer["fileNames"]:
            mapOptions["identityMap"] = True

    chain = raw.tchain(outer)
    oMapF, oMapB, oMapBcn = eventMaps(chain, outer, mapOptions["identityMap"])
    chainI, innerEvent, iMapF, iMapB, iMapBcn = inner_vars(outer, inner, mapOptions,
                                                           oMapF, oMapB, oMapBcn)
    book = loop(chain=chain, chainI=chainI,
                outer=outer, inner=inner,
                innerEvent=innerEvent, oMapF=oMapF,
                options=options)

    utils.delete(chain)
    if chainI:
        utils.delete(chainI)

    # write results to a ROOT file
    dirName = os.path.dirname(outputFile)
    if not os.path.exists(dirName):
        print("Creating directory '%s'" % dirName)
        os.mkdir(dirName)

    f = r.TFile(outputFile, "RECREATE")
    if not f.IsZombie():
        write_category_graphs(category_vs_time(oMap=oMapF, oMapBcn=oMapBcn,
                                               iMap=iMapF, iMapBcn=iMapBcn,
                                               innerEvent=innerEvent),
                              outer,
                              inner)
        for h in book.values():
            h.Write()
    f.Close()

    for h in book.values():
        utils.delete(h)

    if printEventSummary(outer, inner):
        s = "%s: %4s = %6d" % (outputFile, outer["label"], len(oMapF))
        if inner:
            nBoth = len([x for x in list(innerEvent.values()) if x is not None])
            s += ", %4s = %6d, both = %6d" % (inner["label"], len(iMapB), nBoth)
        printer.msg(s)

    oFeds = sorted(outer.get("wargs", {}).keys())
    iFeds = sorted(inner.get("wargs", {}).keys()) if inner else []
    return not len(oMapF), oFeds, iFeds
Example #4
0
def inner_vars(outer, inner, mapOptions, oMapF, oMapB, oMapBcn):
    if inner:
        chainI = raw.tchain(inner)
        iMapF, iMapB, iMapBcn = eventMaps(chainI, inner)
        if mapOptions["identityMap"]:
            iMapF = oMapF
            iMapB = oMapB
            iMapBcn = oMapBcn

        innerEvent = eventToEvent(oMapF, iMapB)
        if set(innerEvent.values()) == set([None]):
            sys.exit("No common events found.  Consider passing --identity-map.")

        if mapOptions['printEventMap']:
            for oEntry, iEntry in sorted(innerEvent.items()):
                printer.msg(", ".join(["oEntry = %s" % str(oEntry),
                                       "oEvnOrn = %s" % str(oMapF[oEntry]),
                                       "iEntry = %s" % str(iEntry),
                                       ]))
    else:
        chainI = None
        innerEvent = iMapF = iMapB = iMapBcn = {}

    return chainI, innerEvent, iMapF, iMapB, iMapBcn