コード例 #1
0
ファイル: compare.py プロジェクト: zeckert01/hcalraw
def histogram_deltas(raw1, raw2, book):
    fed1 = filter(lambda x: x is not None, sorted(raw1.keys()))[0]
    d1 = raw1[fed1]
    for fed2, d2 in raw2.iteritems():
        if fed2 is None:
            continue

        utca1 = d1["header"]["utca"]
        utca2 = d2["header"]["utca"]
        bcnDelta = matching.bcnDelta(utca1) - matching.bcnDelta(utca2)

        for x in ["BcN", "OrN", "EvN"]:
            title = ";".join([x+("%d" % bcnDelta if (x == "BcN" and bcnDelta) else ""),
                              "FED %s - FED %s" % (fed1, fed2),
                              "Events / bin",
                              ])
            delta = d1["header"][x] - d2["header"][x]
            book.fill(delta, "delta%s_%s_%s" % (x, fed1, fed2), 11, -5.5, 5.5, title=title)
コード例 #2
0
def histogram_deltas(raw1, raw2, book, okFeds):
    fed1 = filter(lambda x: x is not None, sorted(raw1.keys()))[0]
    d1 = raw1[fed1]
    for fed2, d2 in raw2.iteritems():
        if fed2 is None:
            continue

        utca1 = d1["header"]["utca"]
        utca2 = d2["header"]["utca"]
        bcnDelta = matching.bcnDelta(utca1) - matching.bcnDelta(utca2)

        if (fed1 in okFeds) and (fed2 in okFeds):
            for x in ["BcN", "OrN", "EvN"]:
                title = ";".join([x+("%d" % bcnDelta if (x == "BcN" and bcnDelta) else ""),
                                  "FED %s - FED %s" % (fed1, fed2),
                                  "Events / bin",
                                  ])
                delta = d1["header"][x] - d2["header"][x]
                book.fill(delta, "delta%s_%s_%s" % (x, fed1, fed2), 11, -5.5, 5.5, title=title)
コード例 #3
0
ファイル: decode.py プロジェクト: elaird/hcalraw
def ornBcn(ornIn, bcnIn, utca):
    bcnDelta = matching.bcnDelta(utca)

    if not bcnDelta:
        return ornIn, bcnIn

    orn = ornIn
    bcn = bcnIn + bcnDelta
    if bcn < 0:
        bcn += hw.nBx
        orn -= 1
    if hw.nBx - 1 < bcn:
        bcn -= hw.nBx
        orn += 1
    return orn, bcn
コード例 #4
0
ファイル: decode.py プロジェクト: jhakala/hcalraw
def ornBcn(ornIn, bcnIn, utca):
    bcnDelta = matching.bcnDelta(utca)

    if not bcnDelta:
        return ornIn, bcnIn

    orn = ornIn
    bcn = bcnIn + bcnDelta
    if bcn < 0:
        bcn += hw.nBx
        orn -= 1
    if hw.nBx - 1 < bcn:
        bcn -= hw.nBx
        orn += 1
    return orn, bcn
コード例 #5
0
def compare(raw1={},
            raw2={},
            book=None,
            anyEmap=False,
            printEmap=False,
            printMismatches=False,
            warnQuality=True,
            fewerHistos=False):
    doDump = (1 <= raw1[None]["dump"]) or raw1[None]["patterns"]

    if raw2 and anyEmap:
        mapF1, mapB1, _ = dataMap(raw1, book)
        mapF2, mapB2, _ = dataMap(raw2, book)
        matched12, nonMatched12 = matchStatsAnyMap(mapF1, mapB2, iStart=4)
        matched21, nonMatched21 = matchStatsAnyMap(mapF2, mapB1, iStart=4)
        tMatched12 = tMisMatched12 = misMatched12 = []  # dummy
        tMatched21 = tMisMatched21 = misMatched21 = []  # dummy
        if printEmap:
            reportMatched(matched12)
            reportFailed(nonMatched12)
        histogram_nMatched(book,
                           matched=matched12.keys(),
                           nonMatched=nonMatched12)
    elif raw2:
        mapF1, _, _ = dataMap(raw1, book)
        mapF2, _, _ = dataMap(raw2, book)
        titlePrefix = "ErrF == %s;ADC;ADC" % ",".join(
            ["%d" % x for x in matching.okErrF()])
        matched12, misMatched12 = adc_vs_adc(mapF1,
                                             mapF2,
                                             book=book,
                                             titlePrefix=titlePrefix,
                                             printMismatches=printMismatches,
                                             iEntry=raw1[None]["iEntry"])
        if doDump:
            matched21, misMatched21 = adc_vs_adc(mapF2,
                                                 mapF1,
                                                 book=None,
                                                 titlePrefix=titlePrefix)

        tF1 = tpMap(raw1, warnQuality, book)[0]
        tF2 = tpMap(raw2, warnQuality, book)[0]

        tMatched12, tMisMatched12 = adc_vs_adc(tF1,
                                               tF2,
                                               book=book,
                                               name="tp_vs_tp",
                                               transf=hw.transformed_tp,
                                               xMin=-20.5,
                                               xMax=275.5,
                                               printMismatches=printMismatches,
                                               iEntry=raw1[None]["iEntry"])
        tMatched21 = tMisMatched21 = []  # tp_vs_tp(tF2, tF1, book)  # FIXME

        histogram_nMatched(book,
                           matched=matched12,
                           misMatched=misMatched12,
                           tMatched=tMatched12,
                           tMisMatched=tMisMatched12)
    else:
        # dummy
        matched12 = misMatched12 = {}
        matched21 = misMatched21 = {}
        tMatched12 = tMisMatched12 = []
        tMatched21 = tMisMatched21 = []

    if doDump:
        slim1 = (raw1[None]["dump"] == 1) and (len(raw1) == 2) and not raw2
        printRaw.oneEvent(raw1,
                          nonMatchedQie=misMatched12,
                          nonMatchedTp=tMisMatched12,
                          slim1=slim1)
        printRaw.oneEvent(raw2,
                          nonMatchedQie=misMatched21,
                          nonMatchedTp=tMisMatched21)

    okFeds = loop_over_feds(
        raw1,
        book,
        adcTag="feds1",
        warn=warnQuality,
        fewerHistos=fewerHistos,
        adcMatches=matched12,
        adcMismatches=misMatched12,
        tpMatches=tMatched12,
        tpMismatches=tMisMatched12,
    )

    noGood = [[], [None]]
    if raw1.keys() in noGood or raw2.keys() in noGood:
        return

    okFeds = okFeds.union(
        loop_over_feds(raw2, book, adcTag="feds2", warn=warnQuality))

    # histogram some deltas
    fed1 = filter(lambda x: x is not None, sorted(raw1.keys()))[0]
    d1 = raw1[fed1]
    for fed2, d2 in raw2.iteritems():
        if fed2 is None:
            continue

        utca1 = d1["header"]["utca"]
        utca2 = d2["header"]["utca"]
        bcnDelta = matching.bcnDelta(utca1) - matching.bcnDelta(utca2)

        if (fed1 in okFeds) and (fed2 in okFeds):
            for x in ["BcN", "OrN", "EvN"]:
                title = ";".join([
                    x + ("%d" % bcnDelta if (x == "BcN" and bcnDelta) else ""),
                    "FED %s - FED %s" % (fed1, fed2),
                    "Events / bin",
                ])
                delta = d1["header"][x] - d2["header"][x]
                book.fill(delta,
                          "delta%s_%s_%s" % (x, fed1, fed2),
                          11,
                          -5.5,
                          5.5,
                          title=title)
コード例 #6
0
ファイル: compare.py プロジェクト: lucien1011/hcalraw
def compare(raw1={}, raw2={}, book={}, anyEmap=False,  printEmap=False, warnQuality=True):
    doDump = (1 <= raw1[None]["dump"]) or raw1[None]["patterns"]

    if anyEmap:
        mapF1, mapB1, _ = dataMap(raw1, book)
        mapF2, mapB2, _ = dataMap(raw2, book)
        matched12, nonMatched12 = matchStats(mapF1, mapB2)
        matched21, nonMatched21 = matchStats(mapF2, mapB1)
        tMatched12 = tMisMatched12 = misMatched12 = []  # passed to loop_over_feds
        if printEmap:
           reportMatched(matched12)
           reportFailed(nonMatched12)
        histogram_nMatched(book, matched=matched12.keys(), nonMatched=nonMatched12)
    else:
        mapF1, _, _ = dataMap(raw1, book)
        mapF2, _, _ = dataMap(raw2, book)
        titlePrefix = "ErrF == %s;ADC;ADC" % ",".join(["%d" % x for x in matching.okErrF()])
        matched12, misMatched12 = adc_vs_adc(mapF1, mapF2, book=book, titlePrefix=titlePrefix)
        if doDump:
            matched21, misMatched21 = adc_vs_adc(mapF2, mapF1, titlePrefix=titlePrefix)

        tF1 = tpMap(raw1, warnQuality, book)[0]
        tF2 = tpMap(raw2, warnQuality, book)[0]

        tMatched12, tMisMatched12 = adc_vs_adc(tF1, tF2, book=book,
                                               name="tp_vs_tp",
                                               transf=hw.transformed_tp,
                                               xMin=-20.5, xMax=255.5)
        tMatched21 = tMisMatched21 = []  # tp_vs_tp(tF2, tF1, book)  # FIXME

        histogram_nMatched(book,
                           matched=matched12, misMatched=misMatched12,
                           tMatched=tMatched12,
                           tMisMatched=tMisMatched12)


    if doDump:
        slim1 = (raw1[None]["dump"] == 1) and (len(raw1) == 2) and not raw2
        printRaw.oneEvent(raw1, nonMatchedQie=misMatched12, nonMatchedTp=tMisMatched12, slim1=slim1)
        printRaw.oneEvent(raw2, nonMatchedQie=misMatched21, nonMatchedTp=tMisMatched21)

    okFeds = loop_over_feds(raw1, book, adcTag="feds1", warn=warnQuality,
                            adcMatches=matched12, adcMismatches=misMatched12,
                            tpMatches=tMatched12, tpMismatches=tMisMatched12,
                            )

    noGood = [[], [None]]
    if raw1.keys() in noGood or raw2.keys() in noGood:
        return

    okFeds = okFeds.union(loop_over_feds(raw2, book, adcTag="feds2", warn=warnQuality))

    # histogram some deltas
    fed1 = filter(lambda x: x is not None, sorted(raw1.keys()))[0]
    d1 = raw1[fed1]
    for fed2, d2 in raw2.iteritems():
        if fed2 is None:
            continue

        utca1 = d1["header"]["utca"]
        utca2 = d2["header"]["utca"]
        bcnDelta = matching.bcnDelta(utca1) - matching.bcnDelta(utca2)

        if (fed1 in okFeds) and (fed2 in okFeds):
            for x in ["BcN", "OrN", "EvN"]:
                title = ";".join([x+("%d" % bcnDelta if (x == "BcN" and bcnDelta) else ""),
                                  "FED %s - FED %s" % (fed1, fed2),
                                  "Events / bin",
                                  ])
                delta = d1["header"][x] - d2["header"][x]
                book.fill(delta, "delta%s_%s_%s" % (x, fed1, fed2), 11, -5.5, 5.5, title=title)