Ejemplo n.º 1
0
def summary(fileName="", berMin=None, berMax=1.0, nRuns=5, samplePoint=None):
    assert fileName
    assert berMin

    grs = common.graphs(uhtrs=[105],
                        runs=["a", "b", "c", "c2", "d"],
                        gtxes=[12, 21, 16],
                        csvFileNameFunc=csvFileName,
                        )
    c = r.TCanvas()
    c.Divide(2, 2)


    #h = r.TH2D("h", ";Horizontal Offset (UI); BER", 1, -0.5, 0.5, 1, berMin, 1.0)
    h = r.TH2D("h", ";Horizontal Offset (UI); BER", 1, 0.0, 1.0, 1, berMin, berMax)
    h.SetStats(False)

    keep = []
    drawn = {1: False,
             2: False,
             3: False,
             4: False
             }

    colorsLegs = {"a": (r.kBlack, "no jumper (1s)"),
                  "b": (r.kRed, "no jumper (pc) (1s)"),
                  "c": (r.kBlue, "jumper (1s)"),
                  "c2": (r.kGreen, "jumper (10s)"),
                  "d": (r.kMagenta, "no jumper (1s)"),
                  }

    line = r.TLine()
    line.SetLineStyle(2)
    for key, g in sorted(grs.iteritems()):
        #iPad = key[0] - 102
        iPad = {12: 1, 21: 2, 16:3}[key[1]]
        c.cd(iPad)
        if not drawn[iPad]:
            h2 = h.DrawClone()
            h2.SetTitle("uHTR 105 GTX %d" % key[1])
            keep.append(h2)
            drawn[iPad] = True
            leg = r.TLegend(0.14, 0.85, 0.44, 0.15)
            leg.SetBorderSize(0)
            leg.SetFillStyle(0)
            #leg.SetHeader("run")
            keep.append(leg)
            if samplePoint is not None:
                line.DrawLine(samplePoint, berMin, samplePoint, berMax)
                leg.AddEntry(line, "IBERT sampling point", "l")
            leg.Draw("same")

        run = key[-1]
        color, name = colorsLegs[run]
        g.SetLineColor(color)
        g.SetMarkerColor(color)
        g.Draw("lpsame")
        
        r.gPad.SetLogy()
        r.gPad.SetTickx()
        r.gPad.SetTicky()
        
        leg.AddEntry(g, name, "lp")

#        if leg.GetNRows() == nRuns:
#            if samplePoint is not None:
#                line = r.TLine()
#                line.SetLineStyle(2)
#                line.DrawLine(samplePoint, berMin, samplePoint, berMax)
#                leg.AddEntry(line, "IBERT sampling point", "l")
#            leg.Draw("same")

    c.cd(0)
    c.Print(fileName)
Ejemplo n.º 2
0
def summary(fileName="", uhtrs=[], runs=[""], pad=lambda x: 1,
            berMin=1.863e-13, berMax=1.0,
            ctp7=False, begin=False, end=False):

    assert fileName
    assert berMin
    assert runs

    if ctp7:
        xMin = -0.5
        xMax = 0.5
        samplePoint = None
        berMax = 1.0
    else:
        xMin = 0.0
        xMax = 1.0
        samplePoint = 0.598

    grs = common.graphs(uhtrs=uhtrs,
                        runs=runs,
                        xMin=xMin,
                        xMax=xMax,
                        ctp7=ctp7)
    c = r.TCanvas()
    c.Divide(2, 2)

    if begin:
        c.cd(0)
        c.Print(fileName+"[")

    h = r.TH2D("h", ";Horizontal Offset (UI); BER", 1, xMin, xMax, 1, berMin, berMax)
    h.SetStats(False)

    keep = []
    drawn = {1: False,
             2: False,
             3: False,
             4: False
             }

    line = r.TLine()
    line.SetLineStyle(2)

    for (uhtr, gtx100, gtx4, run), g in sorted(grs.iteritems()):
        iPad = pad(uhtr)
        c.cd(iPad)
        if not drawn[iPad]:
            h2 = h.DrawClone()
            title = "uHTR%d - CTP7" % uhtr if ctp7 else "%s, optical loop-back" % common.versions(uhtr)
            h2.SetTitle("%s, 6.4 Gbps" % title)
            keep.append(h2)

            drawn[iPad] = True
            if ctp7:
                leg = r.TLegend(0.44, 0.85, 0.64, 0.15)
            else:
                leg = r.TLegend(0.14, 0.80, 0.44, 0.15)
            leg.SetBorderSize(0)
            leg.SetFillStyle(0)
            if ctp7:
                leg.SetHeader("CTP7 GTH")
            keep.append(leg)
            if samplePoint is not None:
                line.DrawLine(samplePoint, berMin, samplePoint, berMax)
                leg.AddEntry(line, "IBERT sampling point", "l")
            leg.Draw("same")

        offset = 113 if ctp7 else 112
        iColor = 1 + gtx4 + 4*(gtx100 - offset)
        color = r.TColor.GetColorPalette(2 * iColor)

        g.SetLineStyle(1 + ((iColor-1) % 3))
        g.SetLineColor(color)
        g.SetMarkerColor(color)
        g.Draw("lsame")
        
        r.gPad.SetLogy()
        r.gPad.SetTickx()
        r.gPad.SetTicky()
        
        name = "_".join(g.GetName().split("_")[1:3])
        if run == "_1":
            name += " (100s)"
        elif not ctp7:
            name += " (1s)"
        leg.AddEntry(g, name, "l")

        nFibers = leg.GetNRows() - 2
        if nFibers == 24:
            leg.SetHeader("%d" % nFibers)
        else:
            leg.SetHeader("#color[2]{%d}" % nFibers)

    c.cd(0)
    c.Print(fileName)

    if end:
        c.cd(0)
        c.Print(fileName+"]")