Example #1
0
def tp_vme_hf(crate=2, slb=6):
    l = []

    for slot in [2, 4, 6] + [13, 15, 17]:
        for top, chs in {"t": [2, 3], "b": [6, 7]}.items():
            for ch in chs:
                key = (slb, ch)
                c1 = (crate, slot, top, key)
                c2 = hw.transformed_tp(*c1)
                # c3 = hw.transformed_tp(*c2)
                # if c3 != c1:
                #     print c1, c2, c3
                l.append(c2)

    for slot in [3, 5, 7] + [14, 16, 18]:
        for top, chs in {"t": [0, 1], "b": [4, 5]}.items():
            for ch in chs:
                key = (slb, ch)
                c1 = (crate, slot, top, key)
                c2 = hw.transformed_tp(*c1)
                # c3 = hw.transformed_tp(*c2)
                # if c3 != c1:
                #     print c1, c2, c3
                l.append(c2)
    check(l)
Example #2
0
def tp_vme_hf(crate=2, slb=6):
    l = []

    for slot in [2, 4, 6] + [13, 15, 17]:
        for top, chs in {"t": [2, 3], "b": [6, 7]}.iteritems():
            for ch in chs:
                key = (slb, ch)
                c1 = (crate, slot, top, key)
                c2 = transformed_tp(*c1)
                # c3 = transformed_tp(*c2)
                # if c3 != c1:
                #     print c1, c2, c3
                l.append(c2)

    for slot in [3, 5, 7] + [14, 16, 18]:
        for top, chs in {"t": [0, 1], "b": [4, 5]}.iteritems():
            for ch in chs:
                key = (slb, ch)
                c1 = (crate, slot, top, key)
                c2 = transformed_tp(*c1)
                # c3 = transformed_tp(*c2)
                # if c3 != c1:
                #     print c1, c2, c3
                l.append(c2)
    check(l)
Example #3
0
def histogramTriggerData(book, block, triggerData, triggerKey, fedId,
                         crate2bin, crateFail, slotCrate, misMatchMapBins, yAxisLabels,
                         tpMatches=None, # tpMismatches,
                         ):

    book.fill(len(triggerData["TP"]), "nTpSamples_%d" % fedId, 14, -0.5, 13.5,
              title="FED %d;number of TP samples;Towers / bin" % fedId)

    maxTp = -1
    for tp in triggerData["TP"]:
        tp8 = tp & 0xff  # ignore fine-grain bit
        if maxTp < tp8:
            maxTp = tp8
    if 0 <= maxTp:
        book.fill(maxTp, "channel_peak_tp_%d" % fedId, 14, -0.5, 13.5,
                  title="FED %d;Peak TP E;Towers / bin" % fedId)

    tpCoords = (block["Crate"], block["Slot"], block["Top"], triggerKey)
    tpCoords2 = hw.transformed_tp(*tpCoords)
    if tpCoords2 is None:
        book.fill(slotCrate, "TP_unmatchable_vs_slot_crate", *misMatchMapBins,
                  title="TP unmatchable;slot;crate;Towers / bin",
                  yAxisLabels=yAxisLabels)
        return

    crate2, slot2, top2 = tpCoords2[:3]
    slotsCrates = [slotCrate,
                   (slot2bin(slot2), crate2bin.get((crate2, top2), crateFail)),
                   ]

    for t in slotsCrates:
        book.fill(t, "TP_matchable_vs_slot_crate", *misMatchMapBins,
                  title="TP matchable;slot;crate;Towers / bin",
                  yAxisLabels=yAxisLabels)

    if tpCoords in tpMatches:
        return True
    else:
        for t in slotsCrates:
            book.fill(t, "TP_mismatch_vs_slot_crate", *misMatchMapBins,
                      title="TP mismatch;slot;crate;Towers / bin",
                      yAxisLabels=yAxisLabels)
        return False
Example #4
0
def histogramTriggerData(book, block, triggerData, triggerKey, fedId,
                         crate2bin, slotCrate, misMatchMapBins, xAxisLabels, yAxisLabels,
                         tpMatches=None, # tpMismatches,
                         ):

    book.fill(len(triggerData["TP"]), "nTpSamples_%d" % fedId, 14, -0.5, 13.5,
              title="FED %d;number of TP samples;Towers / bin" % fedId)

    maxTp = -1
    for tp in triggerData["TP"]:
        tp8 = tp & 0xff  # ignore fine-grain bit
        if maxTp < tp8:
            maxTp = tp8
    if 0 <= maxTp:
        book.fill(maxTp, "channel_peak_tp_%d" % fedId, 14, -0.5, 13.5,
                  title="FED %d;Peak TP E;Towers / bin" % fedId)

    tpCoords = (block["Crate"], block["Slot"], block["Top"], triggerKey)
    tpCoords2 = hw.transformed_tp(*tpCoords)
    if tpCoords2 is None:
        book.fill(slotCrate, "TP_unmatchable_vs_slot_crate", *misMatchMapBins,
                  title="TP unmatchable;slot;crate;Towers / bin",
                  xAxisLabels=xAxisLabels, yAxisLabels=yAxisLabels)
        return

    crate2, slot2, top2 = tpCoords2[:3]
    slotsCrates = [slotCrate,
                   (slot2, crate2bin[crate2]),
                   ]

    for t in slotsCrates:
        book.fill(t, "TP_matchable_vs_slot_crate", *misMatchMapBins,
                  title="TP matchable;slot;crate;Towers / bin",
                  xAxisLabels=xAxisLabels, yAxisLabels=yAxisLabels)

    if tpCoords in tpMatches:
        return True
    else:
        for t in slotsCrates:
            book.fill(t, "TP_mismatch_vs_slot_crate", *misMatchMapBins,
                      title="TP mismatch;slot;crate;Towers / bin",
                      xAxisLabels=xAxisLabels, yAxisLabels=yAxisLabels)
        return False
Example #5
0
def htrSummary(blocks=[], book=None, fedId=None,
               fedEvn=None, fedOrn5=None, fedBcn=None,
               msg="", warn=True, fedTime=None,
               adcMatches=[], adcMismatches=[],
               tpMatches=[], tpMismatches=[]):
    nBadHtrs = 0
    caps = {}
    ErrF = {}

    nEvnMatch = 0
    nEvnMisMatch = 0

    nAdcMatch = 0
    nAdcMisMatch = 0

    nTpMatch = 0
    nTpMisMatch = 0

    adcs = set()
    for i in range(4):
        caps[i] = 0
        ErrF[i] = 0

    crate2bin = {(37, " "):  1,
                 (36, " "):  2,
                 (35, " "):  3,
                 (34, " "):  4,
                 (32, " "):  5,
                 (31, " "):  6,
                 (30, " "):  7,
                 (29, " "):  8,
                 (25, " "):  9,
                 (24, " "): 10,
                 (22, " "): 11,
                 (21, " "): 12,
                 (20, " "): 13,
                 (17, "b"): 14,
                 (17, "t"): 15,
                 (15, "b"): 16,
                 (15, "t"): 17,
                 (14, "b"): 18,
                 (14, "t"): 19,
                 (11, "b"): 20,
                 (11, "t"): 21,
                 (10, "b"): 22,
                 (10, "t"): 23,
                 ( 5, "b"): 24,
                 ( 5, "t"): 25,
                 ( 4, "b"): 26,
                 ( 4, "t"): 27,
                 ( 2, "b"): 28,
                 ( 2, "t"): 29,
                 ( 1, "b"): 30,
                 ( 1, "t"): 31,
                 ( 0, "b"): 32,
                 ( 0, "t"): 33,
                 }
    crateFail = 1 + max(crate2bin.values())
    yAxisLabels = labels(crate2bin)
    misMatchMapBins = ((23, crateFail), (-0.5, 0.5), (22.5, 0.5 + crateFail))

    for block in blocks:
        if type(block) is not dict:
            printer.warning("%s block is not dict" % msg)
            nBadHtrs += 1
            continue
        elif "channelData" not in block:
            printer.warning("%s block has no channelData" % msg)
            nBadHtrs += 1
            continue

        if block["EvN"] == fedEvn:
            nEvnMatch += 1
        else:
            nEvnMisMatch += 1
            if warn:
                printer.warning("%s / crate %2d slot %2d%1s has EvN 0x%06x" % (msg, block["Crate"], block["Slot"], block["Top"], block["EvN"]))

        evnMask = 0x7f
        book.fill((fedEvn & evnMask, block["EvN"] & evnMask), "EvN_HTR_vs_FED_%d" % fedId,
                  (evnMask, evnMask), (-0.5, -0.5), (evnMask - 0.5, evnMask - 0.5),
                  title="FED %d;FED EvN & 0x%x;HTR EvN & 0x%x;HTRs / bin" % (fedId, evnMask, evnMask))

        ornMask = 0x1f
        book.fill((fedOrn5, block["OrN5"]), "OrN5_HTR_vs_FED_%d" % fedId,
                  (ornMask, ornMask), (-0.5, -0.5), (ornMask - 0.5, ornMask - 0.5),
                  title="FED %d;FED OrN5;HTR OrN5;HTRs / bin" % fedId)

        book.fill(block["EvN"] - fedEvn, "EvN_HTRs_%d" % fedId,
                  11, -5.5, 5.5,
                  title="FED %d;HTR EvN - FED EvN;HTRs / bin" % fedId)

        book.fill(block["OrN5"] - fedOrn5, "OrN5_HTRs_%d" % fedId,
                  11, -5.5, 5.5,
                  title="FED %d;HTR OrN5 - FED OrN5;HTRs / bin" % fedId)

        book.fill(block["BcN"] - fedBcn, "BcN_HTRs_%d" % fedId,
                  11, -5.5, 5.5,
                  title="FED %d;HTR BcN - FED BcN;HTRs / bin" % fedId)


        slotCrate = (slot2bin(block["Slot"]), crate2bin.get((block["Crate"], block["Top"]), crateFail))

        book.fill(slotCrate,
                  "block_vs_slot_crate",
                  *misMatchMapBins,
                  title="any;slot;crate;HTR / bin",
                  yAxisLabels=yAxisLabels)

        for key, fedVar in [("EvN", fedEvn),
                            ("OrN5", fedOrn5),
                            ("BcN", fedBcn),
                         ]:
            if (block[key] - fedVar):
                book.fill(slotCrate,
                          "%s_mismatch_vs_slot_crate" % key,
                          *misMatchMapBins,
                          title="%s mismatch;slot;crate;HTR - FED   mismatches / bin" % key,
                          yAxisLabels=yAxisLabels)

        for otherData in block["otherData"].values():
            flavor(book, otherData, fedId)

        for techData in block["technicalData"].values():
            # remove uHTR pad words from flavor histogram
            if techData["technicalDataType"] or techData["channelId"] or techData["words"]:
                flavor(book, techData, fedId)

        for triggerKey, triggerData in block["triggerData"].iteritems():
            if "Flavor" in triggerData:
                flavor(book, triggerData, fedId)

            book.fill(len(triggerData["TP"]), "nTpSamples_%d" % fedId, 14, -0.5, 13.5,
                      title="FED %d;number of TP samples;Towers / bin" % fedId)

            maxTp = -1
            for tp in triggerData["TP"]:
                tp8 = tp & 0xff  # ignore fine-grain bit
                if maxTp < tp8:
                    maxTp = tp8
            if 0 <= maxTp:
                book.fill(maxTp, "channel_peak_tp_%d" % fedId, 14, -0.5, 13.5,
                          title="FED %d;Peak TP E;Towers / bin" % fedId)

            tpCoords = (block["Crate"], block["Slot"], block["Top"], triggerKey)
            tpCoords2 = hw.transformed_tp(*tpCoords)
            if tpCoords2 is None:
                continue

            crate2, slot2, top2 = tpCoords2[:3]
            slotsCrates = [slotCrate,
                          (slot2bin(slot2), crate2bin.get((crate2, top2), crateFail)),
                          ]

            for t in slotsCrates:
                book.fill(t, "TP_matchable_vs_slot_crate", *misMatchMapBins,
                          title="TP matchable;slot;crate;Towers / bin",
                          yAxisLabels=yAxisLabels)

            if tpCoords in tpMatches:
                nTpMatch += 1
            else:
                nTpMisMatch += 1
                for t in slotsCrates:
                    book.fill(t, "TP_mismatch_vs_slot_crate", *misMatchMapBins,
                              title="TP mismatch;slot;crate;Towers / bin",
                              yAxisLabels=yAxisLabels)


        for channelData in block["channelData"].values():
            flavor(book, channelData, fedId)
            a, b = histogramChannelData(book, block, channelData, fedId,
                                        caps, ErrF, adcs, adcMatches, adcMismatches,
                                        slotCrate, misMatchMapBins, yAxisLabels,
                                        fedTime)
            nAdcMatch += a
            nAdcMisMatch += b

    return [nBadHtrs, ErrF, caps, adcs,
            matchFrac(nEvnMatch, nEvnMisMatch),
            matchFrac(nAdcMatch, nAdcMisMatch),
            matchFrac(nTpMatch, nTpMisMatch),
            ]