Ejemplo n.º 1
0
def createSinglePadGraphs(numpy_arrays, max_sample):
    
    [pulse_amplitude, gain, rise_time, time_difference_peak, time_difference_cfd, tracking] = [i for i in numpy_arrays]
    
    # Convert pulse amplitude values from [-V] to [+mV], charge from [C] to gain, rise time from [ns] to [ps]
    dm.changeIndexNumpyArray(pulse_amplitude, -1000.0)
    dm.changeIndexNumpyArray(max_sample, -1000.0)
    dm.changeIndexNumpyArray(gain, 1./(md.getChargeWithoutGainLayer()*10**-15))
    dm.changeIndexNumpyArray(rise_time, 1000.0)
    
    # Produce single pad plots
    for chan in pulse_amplitude.dtype.names:
    
        md.setChannelName(chan)
        
        if (md.getSensor() != md.sensor and md.sensor != "") or md.getSensor() == "SiPM-AFP":
            continue

        print "Single pad", md.getSensor(), "\n"

        # This function requires a ROOT file which have the center positions for each pad
        tracking_chan = t_calc.changeCenterPositionSensor(np.copy(tracking))
        
        produceTProfilePlots([np.copy(pulse_amplitude[chan]), gain[chan], rise_time[chan], time_difference_peak[chan], time_difference_cfd[chan]], max_sample[chan], tracking_chan, distance_x, distance_y)
        produceEfficiencyPlot(pulse_amplitude[chan], tracking_chan, distance_x, distance_y)
def drawAndExportResults(category, category_graph, legend_graph, zoom):

    # The zoom option creates plots for the region \sigma < 100 ps and gain < 100. Also
    # put in a separate folder

    drawOpt = "AP"

    if category.find("gain") == -1:
        drawOpt += "L"

    category_graph.Draw(drawOpt)
    positions_latex = setGraphAttributes(category_graph, category, zoom)
    r_calc.canvas.Update()
    legend_graph.Draw()

    if category == "charge":
        charge_mip = md.getChargeWithoutGainLayer()
        xmin = 0
        xmax = r_calc.bias_voltage_max
        ymin = 0.01
        ymax = category_graph.GetHistogram().GetMaximum()
        new_axis = ROOT.TGaxis(xmax, ymin, xmax, ymax, ymin,
                               int(ymax * charge_mip), 510, "+L")
        new_axis.SetTitle("Charge [fC]")
        new_axis.SetLabelFont(42)
        new_axis.SetTitleFont(42)
        new_axis.SetLabelSize(0.035)
        new_axis.SetTitleSize(0.035)
        new_axis.Draw()

    # Draw extra legend with information about the coloring
    legend_text = ROOT.TLatex()
    legend_text.SetTextSize(0.035)
    legend_text.SetNDC(True)
    legend_text.DrawLatex(positions_latex[0][0], positions_latex[0][1],
                          "Marker color")
    legend_text.DrawLatex(positions_latex[1][0], positions_latex[1][1],
                          "#color[3]{Green}  = 22 \circC")
    legend_text.DrawLatex(positions_latex[2][0], positions_latex[2][1],
                          "#color[4]{Blue}    = -30 \circC")
    legend_text.DrawLatex(positions_latex[3][0], positions_latex[3][1],
                          "#color[6]{Purple} = -40 \circC")

    if category.find("gain") != -1:
        if zoom:
            fileName = dm.getResultsPlotSourceDataPath(
            ) + "/timing_vs_gain_zoom/" + category + "_results.pdf"
        else:
            fileName = dm.getResultsPlotSourceDataPath(
            ) + "/timing_vs_gain/" + category + "_results.pdf"
    else:
        fileName = dm.getResultsPlotSourceDataPath(
        ) + "/" + category + "_results.pdf"

    r_calc.canvas.Print(fileName)
def addValuesToGraph(variables):

    [sensor_data, category, legend_graph, graph,
     category_graph] = [i for i in variables]

    doOnce = True

    for DUT_pos in r_calc.availableDUTPositions(r_calc.processed_sensor):

        if DUT_pos in ["3_0", "3_1", "3_3", "8_1", "7_2", "7_3"]:
            continue

        for temperature in md.getAvailableTemperatures():

            sensor_data[temperature][DUT_pos].sort()

            i = 0
            for data in sensor_data[temperature][DUT_pos]:

                constant = 1
                if category == "charge":
                    constant = 1. / md.getChargeWithoutGainLayer()

                graph[r_calc.processed_sensor][temperature][DUT_pos].SetPoint(
                    i, data[0], data[1][0] * constant)
                graph[r_calc.
                      processed_sensor][temperature][DUT_pos].SetPointError(
                          i, 0, data[1][1] * constant)

                i += 1

            if graph[
                    r_calc.processed_sensor][temperature][DUT_pos].GetN() != 0:
                category_graph.Add(
                    graph[r_calc.processed_sensor][temperature][DUT_pos])

                if r_calc.oneSensorInLegend:
                    if r_calc.processed_sensor == "W4-S204_6e14" and doOnce:
                        legend_graph.AddEntry(
                            graph["W4-S204_6e14"]["22"]["7_0"], "W4-S204_6e14",
                            "p")
                        doOnce = False
                    else:
                        legend_graph.AddEntry(
                            graph[r_calc.processed_sensor][temperature]
                            [DUT_pos], r_calc.processed_sensor, "p")

                r_calc.oneSensorInLegend = False
Ejemplo n.º 4
0
def importResultsValues(sensor_data, category_subcategory):

    global oneSensorInLegend

    if category_subcategory.endswith('gain'):
        category_subcategory = category_subcategory[:-5]
        gain_category = True

    else:
        gain_category = False

    # here are imported all files, that is for each pad, temperature and bias voltage
    for batchNumber in md.getAllBatchNumbers():
        for chan in md.getAllChannelsForSensor(batchNumber, processed_sensor):

            if batchNumber not in md.getAllBatchNumberForSensor(
                    processed_sensor) or omitBadData(batchNumber,
                                                     category_subcategory):
                continue

            md.defineRunInfo(
                md.getRowForRunNumber(md.getAllRunNumbers(batchNumber)[0]))

            md.setChannelName(chan)

            if md.getDUTPos() in ["3_0", "3_1", "3_3", "8_1", "7_2", "7_3"]:
                continue

            # Define the name for the histogram, depending on type
            if category_subcategory.find(
                    "pulse_amplitude") == -1 and category_subcategory.find(
                        "charge") == -1:

                group = "timing"
                chan2 = ""
                parameter_number = 2

                if category_subcategory.find("system") != -1:
                    if md.chan_name not in [
                            "chan0", "chan1", "chan2", "chan3"
                    ]:
                        continue

                    category = "system"
                    chan2 = "chan" + str((int(md.chan_name[-1]) + 1) % 4)

                else:
                    category = "normal"

                if category_subcategory.endswith('cfd'):

                    subcategory = "cfd"

                else:

                    subcategory = "peak"

                if category_subcategory.find(
                        "rise_time") != -1 or category_subcategory.find(
                            "noise") != -1:
                    group = "pulse"
                    category = category_subcategory
                    subcategory = ""
                    chan2 = ""

                # Here, import the histogram which contain the results
                histogram = dm.exportImportROOTHistogram(
                    group, category, subcategory, chan2)

                if histogram:
                    fit_function = histogram.GetFunction("gaus")

                    if category_subcategory.find(
                            "noise") != -1 or category_subcategory.find(
                                "rise_time") != -1:
                        parameter_number = 1

                    results = [
                        fit_function.GetParameter(parameter_number),
                        fit_function.GetParError(parameter_number)
                    ]

                else:
                    continue

            # pulse and gain
            else:

                histogram = dm.exportImportROOTHistogram(
                    "pulse", category_subcategory)
                if histogram:
                    th_name = "_" + str(
                        md.getBatchNumber()) + "_" + md.chan_name
                    function_name = "Fitfcn_" + category_subcategory + th_name
                    fit_function = histogram.GetFunction(function_name)
                    try:
                        fit_function.GetTitle()
                    except:
                        continue
                    results = [
                        fit_function.GetParameter(1),
                        fit_function.GetParError(1)
                    ]
                else:
                    continue

            if category_subcategory.find(
                    "normal") != -1 or category_subcategory.find(
                        "system") != -1:

                results[0] = np.sqrt(
                    np.power(results[0], 2) - np.power(md.getSigmaSiPM(), 2))

            value_error = [results[0], results[1]]
            voltage = md.getBiasVoltage()

            # For the timing resolution vs gain, replace the bias voltage with gain
            if (category_subcategory.find("system") != -1
                    or category_subcategory.find("normal") != -1
                ) and gain_category:

                histogram = dm.exportImportROOTHistogram("pulse", "charge")
                th_name = "_" + str(md.getBatchNumber()) + "_" + md.chan_name
                function_name = "Fitfcn_" + "charge" + th_name
                fit_function = histogram.GetFunction(function_name)

                gain = fit_function.GetParameter(
                    1) / md.getChargeWithoutGainLayer()

                voltage = int(
                    gain
                )  # this takes the even number of gain (to select better values)

            temperature = str(md.getTemperature())

            DUT_pos = md.getDUTPos()

            omitRun = False

            # Among the all batches, choose one with smallest error.
            for index in range(0, len(sensor_data[temperature][DUT_pos])):
                sensor_results = sensor_data[temperature][DUT_pos][index]

                # Check if there is an earlier filled bias voltage, otherwise fill
                if voltage == sensor_results[0]:

                    omitRun = True

                    # For the same voltage, choose the one with smallest error.
                    if value_error[1] < sensor_results[1][1]:

                        sensor_data[temperature][DUT_pos][index] = [
                            voltage, value_error
                        ]

            if not omitRun:
                sensor_data[temperature][DUT_pos].append(
                    [voltage, value_error])

    oneSensorInLegend = True
Ejemplo n.º 5
0
def getLimitsForEachSensorAndBatch():

    if md.getSensor() == "50D-GBGR2" and md.getBatchNumber() == 108:
        
        # not used
        gain_limits = [20, 70]
        pulse_amplitude_limits = [100, 160]
        rise_time_limits = [400, 460]
        
        timing_res_cfd_limits = [22, 40]
        timing_res_peak_limits = [27, 47]
    
    
    elif md.getSensor() == "50D-GBGR2" and md.getBatchNumber() == 207:
        
        gain_limits = [20, 55]
        pulse_amplitude_limits = [80, 150]
        rise_time_limits = [415, 450]
        
        # not used
        timing_res_cfd_limits = [22, 60]
        timing_res_peak_limits = [25, 65]
    
    elif md.getSensor() == "W4-LG12" and md.getBatchNumber() == 108:
        
        # not used
        gain_limits = [20, 90]
        pulse_amplitude_limits = [60, 160]
        rise_time_limits = [520, 560]
        
        timing_res_cfd_limits = [18, 32]
        timing_res_peak_limits = [30, 46]
    
    elif md.getSensor() == "W4-LG12" and md.getBatchNumber() == 207:
        
        gain_limits = [30, 90]
        pulse_amplitude_limits = [60, 155]
        rise_time_limits = [520, 565]
        
        # not used
        timing_res_cfd_limits = [20, 70]
        timing_res_peak_limits = [25, 75]
    
    elif md.getSensor() == "W4-RD01" and md.getBatchNumber() == 306:
        
        gain_limits = [340, 500]
        pulse_amplitude_limits = [160, 310]
        rise_time_limits = [820, 870]
        
        timing_res_peak_limits = [58, 80]
        timing_res_cfd_limits = [20, 40]
    
    elif md.getSensor() == "W4-RD01" and md.getBatchNumber() == 601:
        
        gain_limits = [330, 440]
        pulse_amplitude_limits = [140, 240]
        rise_time_limits = [1220, 1300]
        
        timing_res_peak_limits = [70, 130]
        timing_res_cfd_limits = [30, 75]
    
    elif md.getSensor() == "W4-S1022" and md.getBatchNumber() == 306:
        
        gain_limits = [20, 38]
        pulse_amplitude_limits = [35, 75]
        rise_time_limits = [600, 680]
        
        timing_res_peak_limits = [90, 160]
        timing_res_cfd_limits = [30, 80]
    
    elif md.getSensor() == "W4-S1022" and md.getBatchNumber() == 507:
        
        gain_limits = [40, 85]
        pulse_amplitude_limits = [80, 160]
        rise_time_limits = [505, 545]
        
        timing_res_peak_limits = [90, 160]
        timing_res_cfd_limits = [30, 80]
    
    elif md.getSensor() == "W4-S1022" and md.getBatchNumber() == 707:
        
        gain_limits = [35, 85]
        pulse_amplitude_limits = [80, 160]
        rise_time_limits = [525, 565]
        
        timing_res_cfd_limits = [30, 80]
        timing_res_peak_limits = [90, 160]
    
    elif md.getSensor() == "W4-S1061" and md.getBatchNumber() == 306:
        
        gain_limits = [35, 65]
        pulse_amplitude_limits = [85, 145]
        rise_time_limits = [490, 530]
        
        timing_res_cfd_limits = [30, 80]
        timing_res_peak_limits = [90, 160]
    
    elif md.getSensor() == "W4-S1061" and md.getBatchNumber() == 507:
        
        gain_limits = [35, 65]
        pulse_amplitude_limits = [80, 140]
        rise_time_limits = [535, 570]
        
        timing_res_cfd_limits = [30, 80]
        timing_res_peak_limits = [90, 160]
    
    elif md.getSensor() == "W4-S1061" and md.getBatchNumber() == 707:
        
        gain_limits = [30, 80]
        pulse_amplitude_limits = [70, 150]
        rise_time_limits = [540, 575]
        
        timing_res_cfd_limits = [30, 80]
        timing_res_peak_limits = [90, 160]
    
    elif md.getSensor() == "W4-S203" and md.getBatchNumber() == 306:
        
        gain_limits = [40, 70]
        pulse_amplitude_limits = [90, 150]
        rise_time_limits = [515, 540]
        
        timing_res_cfd_limits = [30, 80]
        timing_res_peak_limits = [90, 160]
    
    elif md.getSensor() == "W4-S203" and md.getBatchNumber() == 507:
        
        gain_limits = [35, 70]
        pulse_amplitude_limits = [50, 100]
        rise_time_limits = [680, 780]
        
        timing_res_cfd_limits = [30, 80]
        timing_res_peak_limits = [90, 160]
    
    elif md.getSensor() == "W4-S203" and md.getBatchNumber() == 707:
        
        gain_limits = [40, 80]
        pulse_amplitude_limits = [50, 110]
        rise_time_limits = [725, 830]
        
        timing_res_cfd_limits = [30, 80]
        timing_res_peak_limits = [90, 160]
    
    elif md.getSensor() == "W4-S204_6e14" and md.getBatchNumber() == 507:
        
        gain_limits = [5, 26]
        pulse_amplitude_limits = [40, 80]
        rise_time_limits = [315, 390]
        
        timing_res_cfd_limits = [36, 60]
        timing_res_peak_limits = [44, 65]
    
    elif md.getSensor() == "W4-S204_6e14" and md.getBatchNumber() == 707:
        
        gain_limits = [8, 28]
        pulse_amplitude_limits = [40, 90]
        rise_time_limits = [315, 390]
        
        timing_res_cfd_limits = [34, 48]
        timing_res_peak_limits = [40, 60]
    
    elif md.getSensor() == "W4-S215" and md.getBatchNumber() == 207:
        
        gain_limits = [70, 130]
        pulse_amplitude_limits = [160, 260]
        rise_time_limits = [490, 540]
        
        timing_res_cfd_limits = [25, 45]
        timing_res_peak_limits = [25, 50]
    
    elif md.getSensor() == "W4-S215" and md.getBatchNumber() == 507:
        
        gain_limits = [110, 210]
        pulse_amplitude_limits = [200, 330]
        rise_time_limits = [520, 590]
        
        # not used
        timing_res_cfd_limits = [20, 70]
        timing_res_peak_limits = [30, 80]
    
    elif md.getSensor() == "W4-S215" and md.getBatchNumber() == 707:
        
        gain_limits = [100, 190]
        pulse_amplitude_limits = [140, 240]
        rise_time_limits = [700, 825]
        
        # not used
        timing_res_cfd_limits = [20, 70]
        timing_res_peak_limits = [30, 80]
    
    elif md.getSensor() == "W9-LGA35" and md.getBatchNumber() == 108:
        
        # not used
        gain_limits = [30, 50]
        pulse_amplitude_limits = [60, 110]
        rise_time_limits = [415, 455]
        
        timing_res_cfd_limits = [20, 40]
        timing_res_peak_limits = [24, 46]
    
    elif md.getSensor() == "W9-LGA35" and md.getBatchNumber() == 207:
        
        gain_limits = [20, 45]
        pulse_amplitude_limits = [50, 115]
        rise_time_limits = [415, 455]
        
        # not used
        timing_res_cfd_limits = [20, 70]
        timing_res_peak_limits = [25, 75]

    # This method is modular to adapt for other batches
    else:
        
        th_name = "_"+str(md.getBatchNumber())+"_"+md.chan_name
        
        pulse_amplitude_mean =  dm.exportImportROOTHistogram("pulse", "pulse_amplitude").GetFunction("Fitfcn_pulse_amplitude"+th_name).GetParameter(1)
        gain_mean =             dm.exportImportROOTHistogram("pulse", "charge").GetFunction("Fitfcn_charge"+th_name).GetParameter(1)/md.getChargeWithoutGainLayer()
        
        rise_time_mean = dm.exportImportROOTHistogram("pulse", "rise_time").GetFunction("gaus").GetParameter(1)
        timing_res_peak_mean = np.sqrt(np.power(dm.exportImportROOTHistogram("timing", "normal", "peak").GetFunction("gaus").GetParameter(2),2) - np.power(md.getSigmaSiPM(),2))
        timing_res_cfd_mean = np.sqrt(np.power(dm.exportImportROOTHistogram("timing", "normal", "cfd").GetFunction("gaus").GetParameter(2), 2) - np.power(md.getSigmaSiPM(), 2))
        
        [pulse_amplitude_limits, gain_limits, rise_time_limits, timing_res_peak_limits, timing_res_cfd_limits] = [[max(pulse_amplitude_mean-50,0), pulse_amplitude_mean+50], [max(gain_mean-30, 0), gain_mean+30], [max(rise_time_mean-30, 0), rise_time_mean+30], [max(timing_res_peak_mean-50, 0), timing_res_peak_mean+50], [max(timing_res_cfd_mean-50, 0), timing_res_cfd_mean+50]]
    
    
    limits_graph = [pulse_amplitude_limits, gain_limits, rise_time_limits, timing_res_peak_limits, timing_res_cfd_limits]

    return limits_graph