Пример #1
0
def oneFedHcal(d={}, dump=None, crateslots=[],
               nonMatchedQie=[], nonMatchedTp=[],
               printHeaders=None, nTsMax=None, perTs=None):
    h = d["header"]
    t = d["trailer"]
    if 1 <= dump:
        fields = [" FEDid",
                  "  EvN",
                  "       OrN",
                  "    BcN",
                  "minutes",
                  "TTS",
                  "nBytesHW(   SW)",
                  "type",
                  #"CRC16",
                  "nSkip16",
                  "Blk8",
                  ]

        if printHeaders:
            headers = "  ".join(fields)
            printer.blue("-" * len(headers))
            printer.blue(headers)

        sList = [" %4d" % h["FEDid"],
                 "0x%07x" % h["EvN"],
                 "0x%08x" % h["OrN"],
                 "%4d" % h["BcN"],
                 "%7.3f" % hw.minutes(h["OrN"], h["BcN"]),
                 (" %1x" % t["TTS"]) if "TTS" in t else "  - ",
                 "    %5d(%5d)" % (t["nWord64"]*8 if "nWord64" in t else "  -1", d["nBytesSW"]),
                 "  %1d " % h["Evt_ty"],
                 #(" 0x%04x" % t["CRC16"]) if "CRC16" in t else "   - ",
                 "%7d" % d["nWord16Skipped"],
                 ]
        if h["uFoV"]:
            sList.append("  %2d" % t["Blk_no8"])

        printer.blue("  ".join(sList))
        if 2 <= dump and dump != 4:
            htrOverview(h)

    if dump <= 2:
        return

    for iBlock, block in sorted(d["htrBlocks"].iteritems()):
        if crateslots and (100*block["Crate"] + block["Slot"]) not in crateslots:
            continue
        oneHtr(iBlock=iBlock,
               p=block,
               dump=dump,
               utca=h["utca"],
               nonMatchedQie=nonMatchedQie,
               nonMatchedTp=nonMatchedTp,
               nTsMax=nTsMax,
               perTs=perTs,
        )
Пример #2
0
def category_vs_time(oMap={}, oMapBcn={}, iMap={}, iMapBcn={}, innerEvent={}):
    d = {}
    for oEntry, (evn, orn) in oMap.iteritems():
        bcn = oMapBcn[oEntry]
        time = hw.minutes(orn, bcn)
        if innerEvent.get(oEntry) is not None:
            d[time] = (3, evn, orn, bcn)
        else:
            d[time] = (2, evn, orn, bcn)

    iEntries = innerEvent.values()
    for iEntry, (evn, orn) in iMap.iteritems():
        if iEntry in iEntries:
            continue
        bcn = iMapBcn[iEntry]
        time = hw.minutes(orn, bcn)
        d[time] = (1, evn, orn, bcn)

    return d
Пример #3
0
def category_vs_time(oMap={}, oMapBcn={}, iMap={}, iMapBcn={}, innerEvent={}):
    d = {}
    for oEntry, (evn, orn) in oMap.items():
        bcn = oMapBcn[oEntry]
        time = hw.minutes(orn, bcn)
        if innerEvent.get(oEntry) is not None:
            d[time] = (3, evn, orn, bcn)
        else:
            d[time] = (2, evn, orn, bcn)

    iEntries = innerEvent.values()
    for iEntry, (evn, orn) in iMap.items():
        if iEntry in iEntries:
            continue
        bcn = iMapBcn[iEntry]
        time = hw.minutes(orn, bcn)
        d[time] = (1, evn, orn, bcn)

    return d
Пример #4
0
def singleFedPlots(fedId=None, d={}, book={}, nTsMax=None, **other):
    book.fill(d["nWord16Skipped"],
              "nWord16Skipped_%d" % fedId,
              14,
              -0.5,
              13.5,
              title="FED %d;nWord16 skipped during unpacking;Events / bin" %
              fedId)

    h = d["header"]
    t = d["trailer"]
    if "TTS" in t:
        book.fill(t["TTS"],
                  "TTS_%d" % fedId,
                  16,
                  -0.5,
                  15.5,
                  title="FED %d;TTS state;Events / bin" % fedId)

    if "BcN" in h:
        book.fill(h["BcN"] / 100.0,
                  "BcN_%d" % fedId,
                  hw.nBx,
                  0,
                  hw.nBx / 100.0,
                  title="FED %d;BcN / 100;Events / bin" % fedId)

    msg = "FED %d" % fedId
    fedEvn = h.get("EvN")
    fedOrn = h.get("OrN")
    fedBcn = h.get("BcN")

    if fedEvn is None:
        printer.error("FED %d lacks EvN.  Keys: %s" % str(h.keys()))
        msg = ""
    else:
        msg = msg_coords(fedId, fedEvn, fedOrn, fedBcn)

    htrOverviewBits(h, book, fedId, msg=msg, warn=other["warn"])

    fedTime = hw.minutes(fedOrn, fedBcn)

    nBadHtrs, ErrF, caps, adcs, fracEvN, fracADC, fracTP = htrSummary(
        blocks=d["htrBlocks"].values(),
        book=book,
        fedId=fedId,
        fedEvn=fedEvn,
        fedOrn5=fedOrn & 0x1f,
        fedBcn=fedBcn,
        msg=msg,
        fedTime=fedTime,
        nTsMax=nTsMax,
        **other)

    errFSum = 0.0 + sum(ErrF.values())

    if errFSum:
        for code, n in ErrF.iteritems():
            title = "FED %d;frac. chan. with ErrF == %d;Events / bin" % (fedId,
                                                                         code)
            book.fill(n / errFSum,
                      "ErrF%d_%d" % (code, fedId),
                      44,
                      0.0,
                      1.1,
                      title=title)

        frac0 = ErrF[0] / errFSum
    else:
        frac0 = -999.  # dummy

    book.fillGraph((fedTime, frac0),
                   "frac0_vs_time_%d" % fedId,
                   title=("FED %d" % fedId) +
                   ";time (minutes);frac. chan. with ErrF == 0")

    if fracEvN is not None:
        book.fillGraph((fedTime, fracEvN),
                       "fracEvN_vs_time_%d" % fedId,
                       title=("FED %d" % fedId) +
                       ";time (minutes);frac. HTRs with EvN == FED's")

    if fracADC is not None:
        book.fillGraph(
            (fedTime, fracADC),
            "ADC_misMatch_vs_time_%d" % fedId,
            title=("FED %d" % fedId) +
            ";time (minutes);#splitline{(# ch. match. ADCs) /}{(# ch. match. + ch. mismatch.)}"
        )

    if fracTP is not None:
        book.fillGraph(
            (fedTime, fracTP),
            "TP_misMatch_vs_time_%d" % fedId,
            title=("FED %d" % fedId) +
            ";time (minutes);#splitline{(# match. TPs) /}{(# match. + mismatch. TPs)}"
        )

    if "nWord64" in t:
        book.fillGraph((fedTime, t["nWord64"] * 8.0 / 1024),
                       "kB_vs_time_%d" % fedId,
                       title=("FED %d" % fedId) + ";time (minutes);kB")

    book.fill(
        (fedBcn / 100.0, frac0),
        "frac0_vs_BcN_%d" % fedId, (hw.nBx, 6), (0.0, 0.0),
        (hw.nBx / 100.0, 1.2),
        title=";FED %d   (BcN / 100);frac. chan. with ErrF == 0;Events / bin" %
        fedId)

    capSum = 0.0 + sum(caps.values())
    if capSum:
        book.fill(max(caps.values()) / capSum,
                  "PopCapFrac_%d" % fedId,
                  44,
                  0.0,
                  1.1,
                  title=("FED %d" % fedId) +
                  ";frac. ErrF=0 chans w/most pop. capId;Events / bin")

    book.fill(nBadHtrs,
              "nBadHtrs_%d" % fedId,
              16,
              -0.5,
              15.5,
              title="FED %d; N bad HTRs;Events / bin" % fedId)
    return nBadHtrs, adcs
Пример #5
0
def oneFedHcal(d={}, dump=None, crateslots=[],
               nonMatchedQie=[], nonMatchedTp=[],
               printHeaders=None, nTsMax=None, perTs=None):
    h = d["header"]
    t = d["trailer"]
    if 1 <= dump:
        if "htrBlocks" in d:
            fields = [" FEDid",
                      "  EvN",
                      "       OrN",
                      "    BcN",
                      "minutes",
                      "TTS",
                      "nBytesHW(nBytesSW)",
                      "type",
                      #"CRC16",
                      "nSkip16",
                      "Blk8",
                     ]
        elif "histograms" in d:
            fields = [" FEDid",
                      "  EvN",
                      "     nOrbits",
                      " minutes",
                      "TTS",
                      "nBytesHW(nBytesSW)",
                      "   L1A  ",
                      "ver",
                      "perCap",
                      "nBins",
                      "nHist",
                     ]
        else:
            fields = [" FEDid",
                      "  EvN",
                      "   nBytesHW(nBytesSW)",
                      "type",
                     ]

        if printHeaders:
            headers = "  ".join(fields)
            printer.blue("-" * len(headers))
            printer.blue(headers)

        if "htrBlocks" in d:
            sList = [" %4d" % h["FEDid"],
                     "0x%07x" % h["EvN"],
                     "0x%08x" % h["OrN"],
                     "%4d" % h["BcN"],
                     "%7.3f" % hw.minutes(h["OrN"], h["BcN"]),
                     (" %1x" % t["TTS"]) if "TTS" in t else "  - ",
                     " %8d(%8d)" % (t["nWord64"]*8 if "nWord64" in t else -1, d["nBytesSW"]),
                     "  %1d " % h["Evt_ty"],
                     #(" 0x%04x" % t["CRC16"]) if "CRC16" in t else "   - ",
                     "%7d" % d["nWord16Skipped"],
                    ]
            if h["uFoV"]:
                sList.append("  %2d" % t["Blk_no8"])

        elif "histograms" in d:
            sList = [" %4d" % h["FEDid"],
                     "0x%07x" % h["EvN"],
                     "0x%08x" % (h["OrN1"] - h["OrN0"]),
                     "%7.3f" % hw.minutes(h["OrN0"], 0),
                     (" %1x" % t["TTS"]) if "TTS" in t else "  - ",
                     " %8d(%8d)" % (t["nWord64"]*8 if "nWord64" in t else -1, d["nBytesSW"]),
                     "0x%07x" % h["L1A"],
                     "%1d" % h["version"],
                     "   %1d" % h["perCap"],
                     "   %3d" % h["nBins"],
                     "   %3d" % h["nHist"],
                    ]
        else:
            sList = [" %4d" % h["FEDid"],
                     "0x%07x" % h["EvN"],
                     "%8d(%8d)" % (t["nWord64"]*8 if "nWord64" in t else -1, d["nBytesSW"]),
                     "  %1d " % h["Evt_ty"],
                     # "%7d" % d["nWord16Skipped"],
                    ]

        printer.blue("  ".join(sList))
        if 2 <= dump and dump != 4 and "htrBlocks" in d:
            htrOverview(h)

    if dump <= 2:
        return

    if "htrBlocks" in d:
        for iBlock, block in sorted(d["htrBlocks"].items()):
            if crateslots and (100*block["Crate"] + block["Slot"]) not in crateslots:
                continue
            oneHtr(iBlock=iBlock,
                   p=block,
                   dump=dump,
                   utca=h["utca"],
                   nonMatchedQie=nonMatchedQie,
                   nonMatchedTp=nonMatchedTp,
                   nTsMax=nTsMax,
                   perTs=perTs,
                  )
    elif "histograms" in d:
        for iBlock, block in sorted(d["histograms"].items()):
            if crateslots and (100*block["Crate"] + block["Slot"]) not in crateslots:
                continue
            oneHistogram(iBlock, block, dump)