def qie(crate=None, fibCh=None, slots=[], tops="", fibers=[]):
    l = []
    for slot in slots:
        for top in tops:
            for fiber in fibers:
                c1 = (crate, slot, top, fiber, fibCh)
                c2 = hw.transformed_qie(*c1)
                c3 = hw.transformed_qie(*c2)
                if c3 != c1:
                    print(c1, c2, c3)
                l.append(c2)
    check(l)
Exemple #2
0
def qie(crate=None, fibCh=None, slots=[], tops="", fibers=[]):
    l = []
    for slot in slots:
        for top in tops:
            for fiber in fibers:
                c1 = (crate, slot, top, fiber, fibCh)
                c2 = transformed_qie(*c1)
                c3 = transformed_qie(*c2)
                if c3 != c1:
                    print c1, c2, c3
                l.append(c2)
    check(l)
Exemple #3
0
def histogramChannelData(book, block, channelData, fedId, caps, ErrF, adcs,
                         crate2bin, slotCrate, misMatchMapBins, xAxisLabels,
                         yAxisLabels, fedTime, nTsMax, warn, **other):

    nAdcMatch = 0
    nAdcMisMatch = 0

    ErrF[channelData["ErrF"]] += 1
    book.fill(len(channelData["QIE"]),
              "nQieSamples_%d" % fedId,
              14,
              -0.5,
              13.5,
              title="FED %d;number of QIE samples;Channels / bin" % fedId)

    book.fill(slotCrate,
              "ErrFAny_vs_slot_crate",
              *misMatchMapBins,
              title="any;slot;crate;Channels / bin",
              xAxisLabels=xAxisLabels,
              yAxisLabels=yAxisLabels)

    if channelData["ErrF"]:
        for name, title in [
            ("ErrFNZ", "ErrF != 0"),
            ("ErrF%d" % channelData["ErrF"],
             "ErrF == %d" % channelData["ErrF"]),
        ]:
            book.fill(slotCrate,
                      "%s_vs_slot_crate" % name,
                      *misMatchMapBins,
                      title="%s;slot;crate;Channels / bin" % title,
                      xAxisLabels=xAxisLabels,
                      yAxisLabels=yAxisLabels)
        return nAdcMatch, nAdcMisMatch

    book.fill(slotCrate,
              "ErrF0_vs_slot_crate",
              *misMatchMapBins,
              title="ErrF == 0;slot;crate;Channels / bin",
              xAxisLabels=xAxisLabels,
              yAxisLabels=yAxisLabels)

    book.fill((block["Slot"], channelData["Fiber"]),
              "fiber_vs_slot_%d" % fedId, (12, 24), (0.5, -0.5), (12.5, 23.5),
              title="FED %d;Slot;Fiber;Channels (ErrF == 0) / bin" % fedId)

    coords = (block["Crate"], block["Slot"], block["Top"],
              channelData["Fiber"], channelData["FibCh"])
    if coords in other.get("misMatched", []):
        nAdcMisMatch = 1
        crate2, slot2, top2 = hw.transformed_qie(*coords)[:3]
        for t in [slotCrate, (slot2, crate2bin[crate2])]:
            book.fill(t,
                      "ADC_mismatch_vs_slot_crate",
                      *misMatchMapBins,
                      title="ADC mismatch;slot;crate;Channels / bin",
                      xAxisLabels=xAxisLabels,
                      yAxisLabels=yAxisLabels)
    elif coords in other.get("matched", []):
        nAdcMatch = 1

    caps[channelData["CapId"][0]] += 1

    try:
        tsSoi = channelData["SOI"].index(1)
    except ValueError:
        if warn:
            printer.warning("%2d:%2d:%2d:%d SoI not found" %
                            (block["Crate"], block["Slot"],
                             channelData["Fiber"], channelData["FibCh"]))
        tsSoi = None

    if channelData["QIE"]:
        errf = "ErrFNZ" if channelData["ErrF"] else "ErrF0"
        eq = "!=" if channelData["ErrF"] else "=="

        histogramAdcs(book, fedId, block, channelData, adcs, nTsMax, errf, eq)
        histogramCaps(book, fedId, block, channelData["CapId"], tsSoi)
        if fedTime:
            histogramTsVsTime(book, fedTime, fedId, channelData["QIE"])

    if channelData.get("TDC"):
        histogramTdcs(book, fedId, block, channelData["TDC"], nTsMax, errf, eq,
                      tsSoi)

    return nAdcMatch, nAdcMisMatch
Exemple #4
0
def histogramChannelData(book, block, channelData, fedId, caps, ErrF, adcs,
                         adcMatches, adcMismatches, crate2bin, crateFail,
                         slotCrate, misMatchMapBins, yAxisLabels, fedTime):

    nAdcMatch = 0
    nAdcMisMatch = 0

    ErrF[channelData["ErrF"]] += 1
    book.fill(len(channelData["QIE"]),
              "nQieSamples_%d" % fedId,
              14,
              -0.5,
              13.5,
              title="FED %d;number of QIE samples;Channels / bin" % fedId)

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

    if channelData["ErrF"]:
        for name, title in [
            ("ErrFNZ", "ErrF != 0"),
            ("ErrF%d" % channelData["ErrF"],
             "ErrF == %d" % channelData["ErrF"]),
        ]:
            book.fill(slotCrate,
                      "%s_vs_slot_crate" % name,
                      *misMatchMapBins,
                      title="%s;slot;crate;Channels / bin" % title,
                      yAxisLabels=yAxisLabels)
        return nAdcMatch, nAdcMisMatch

    book.fill(slotCrate,
              "ErrF0_vs_slot_crate",
              *misMatchMapBins,
              title="ErrF == 0;slot;crate;Channels / bin",
              yAxisLabels=yAxisLabels)

    book.fill((block["Slot"], channelData["Fiber"]),
              "fiber_vs_slot_%d" % fedId, (12, 24), (0.5, -0.5), (12.5, 23.5),
              title="FED %d;Slot;Fiber;Channels (ErrF == 0) / bin" % fedId)

    coords = (block["Crate"], block["Slot"], block["Top"],
              channelData["Fiber"], channelData["FibCh"])
    if coords in adcMismatches:
        nAdcMisMatch = 1
        crate2, slot2, top2 = hw.transformed_qie(*coords)[:3]
        for t in [
                slotCrate,
            (slot2bin(slot2), crate2bin.get((crate2, top2), crateFail)),
        ]:
            book.fill(t,
                      "ADC_mismatch_vs_slot_crate",
                      *misMatchMapBins,
                      title="ADC mismatch;slot;crate;Channels / bin",
                      yAxisLabels=yAxisLabels)
    elif coords in adcMatches:
        nAdcMatch = 1

    caps[channelData["CapId0"]] += 1

    if channelData["QIE"]:
        adc = max(channelData["QIE"])
        adcs.add(adc)
        mp = channelData.get("M&P", 0)
        book.fill(adc,
                  "channel_peak_adc_mp%d_%d" % (mp, fedId),
                  14,
                  -0.5,
                  13.5,
                  title="FED %d;Peak ADC (ErrF == 0);Channels / bin" % fedId)

        if fedTime:
            histogramTsVsTime(book, fedTime, fedId, channelData["QIE"])
    return nAdcMatch, nAdcMisMatch
Exemple #5
0
def histogramChannelData(book, block, channelData, fedId,
                         caps, ErrF, adcs, crate2bin, crateFail,
                         slotCrate, misMatchMapBins,
                         yAxisLabels, fedTime, **other):

    nAdcMatch = 0
    nAdcMisMatch = 0

    ErrF[channelData["ErrF"]] += 1
    book.fill(len(channelData["QIE"]), "nQieSamples_%d" % fedId, 14, -0.5, 13.5,
              title="FED %d;number of QIE samples;Channels / bin" % fedId)

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

    # if block["Slot"] == 9 and block["Crate"] == 41 and channelData["Fiber"] == 2 and channelData["FibCh"] == 3:
    #     for i in [0, 1]:
    #         title = "cr41_sl9_fib2_fibch3_ts%d" % i
    #         book.fill(channelData["QIE"][i], title, 256, -0.5, 255.5,
    #                   title="%s;ADC;Counts / bin" % title)

    if channelData["ErrF"]:
        for name, title in [("ErrFNZ", "ErrF != 0"),
                            ("ErrF%d" % channelData["ErrF"], "ErrF == %d" % channelData["ErrF"]),
                            ]:
            book.fill(slotCrate,
                      "%s_vs_slot_crate" % name, *misMatchMapBins,
                      title="%s;slot;crate;Channels / bin" % title,
                      yAxisLabels=yAxisLabels)
        return nAdcMatch, nAdcMisMatch

    book.fill(slotCrate,
              "ErrF0_vs_slot_crate", *misMatchMapBins,
              title="ErrF == 0;slot;crate;Channels / bin",
              yAxisLabels=yAxisLabels)

    book.fill((block["Slot"], channelData["Fiber"]),
              "fiber_vs_slot_%d" % fedId, (12, 24), (0.5, -0.5), (12.5, 23.5),
              title="FED %d;Slot;Fiber;Channels (ErrF == 0) / bin" % fedId)

    coords = (block["Crate"], block["Slot"], block["Top"], channelData["Fiber"], channelData["FibCh"])
    if coords in other.get("misMatched", []):
        nAdcMisMatch = 1
        crate2, slot2, top2 = hw.transformed_qie(*coords)[:3]
        for t in [slotCrate,
                  (slot2bin(slot2), crate2bin.get((crate2, top2), crateFail)),
                 ]:
            book.fill(t, "ADC_mismatch_vs_slot_crate", *misMatchMapBins,
                      title="ADC mismatch;slot;crate;Channels / bin",
                      yAxisLabels=yAxisLabels)
    elif coords in other.get("matched", []):
        nAdcMatch = 1

    caps[channelData["CapId0"]] += 1

    if channelData["QIE"]:
        adc = max(channelData["QIE"])
        adcs.add(adc)
        mp = channelData.get("M&P", 0)
        book.fill(adc, "channel_peak_adc_mp%d_%d" % (mp, fedId), 14, -0.5, 13.5,
                  title="FED %d;Peak ADC (ErrF == 0);Channels / bin" % fedId)

        if fedTime:
            histogramTsVsTime(book, fedTime, fedId, channelData["QIE"])
    return nAdcMatch, nAdcMisMatch