Esempio n. 1
0
calibration.automaticBondTest(resolution=2, voltMin=0)

voltArray, fwhmPerVolt = calibration.bondTestGetFwhmPerVolt()  # MPA[Pix[Volt]]

## Data from measurement with Sr90 source on MPA5 to allow comparison with confirmed dead pixels
hits = [
    24535, 15100, 16743, 14068, 17042, 14568, 22333, 17551, 0, 19322, 0, 19147,
    0, 0, 19984, 24712, 24401, 15963, 15078, 16422, 13774, 14310, 13577, 15085,
    11354, 14313, 13706, 14324, 12457, 14413, 14432, 23665, 24579, 12675,
    13340, 12612, 15251, 10976, 15562, 0, 16572, 0, 16463, 13214, 15304, 13793,
    15967, 24799
]
colors = [1 if pix > 10 else 2 for pix in hits]

for nMPA, MPA in enumerate(fwhmPerVolt):  # Loop over MPAs
    plot = MPAPlot()
    for fwhm in MPA:  # Loop over pix
        plot.createGraph(voltArray, fwhm)
    plot.setTitle(
        "Bond test for MPA" + str(assembly[nMPA]) +
        " ; Bias voltage / V ; FWHM of noise from threshold scan / thrDACs")
    if nMPA == 1:  # Mark MPA5 with confirmed bad bonds
        plot.setLineColor(colors)
    plot.setRange(yRange=[0, 100])
    plot.draw()

#thrScansPerBiasVolt = calibration.bondTestGetThrScanPerVolt()
#
#bondTestGraphs = []
#for volt in thrScansPerBiasVolt:
#    plot = MPAPlot()
Esempio n. 2
0
#!/usr/bin/python

from array import array
from MPACalibration import MPACalibration 
from MPAPlot import MPAPlot
from KeithleyControl.keithleyControl import keithley
import ROOT

k = keithley()
k.init()
plot = MPAPlot()
k.setVoltage(110)
# Calibrate MPA (only use MPA 5 as it has confirmed failed bonds)
calibration = MPACalibration([2,5]) # Argument reflects assembly which is actually on board 
calibration.thresholdScan(calEnbl = 1) 
calibration.writeCalibrationToMPA()


# Start scan
resolution = 30 

calibration.thresholdScan()
counter, _ = calibration.getThrScanPerPix()
_,_, threshold = calibration.getThrScanMetadata()
for pix in counter[0]:
    plot.createGraph(array('d',threshold[0]), array('d', pix))


maxHitsPerVolts = []
edgesPerVolt = []
thresholdScansPerBiasVolt = []
                                               assembly=args.assembly))
    mpaConfig.append(ET.parse(filename))

calibration.thresholdScan(calEnbl=True)
calibration.writeCalibrationToMPA()

calibration.thresholdScan()
counter, _ = calibration.getThrScanPerPix()
preScanEdges = calibration.findFallingEdges()

rootFile = TFile("plots_kit/Trim_Scan_results.root", "recreate")

RMS = []

for iMPA, edge in enumerate(preScanEdges):
    plot = MPAPlot()
    plot.fillHisto(edge)
    plot.setTitle(
        'Falling edges of MPA ' + str(assembly[iMPA]) +
        ' after calibration with fixed ThrDAC/TrimDAC-ratio; Threshold (DAC);# of Pixels'
    )
    plot.draw()
    histo = plot.getPlot(0)
    RMS.append(histo.GetRMS())
    histo.Write()

calibration.trimScan(resolution=1)

trimScanEdges = calibration.getTrimScanEdges()  # MPA[trim[pix]]
trimArray = calibration.getTrimScanMetadata()
from MPACalibration import MPACalibration
from MPAPlot import MPAPlot
from ROOT import TCanvas,TFile, TLine, gStyle, TDirectory

assembly = [2,5]
gStyle.SetOptFit()
rootFile = TFile("plots_kit/Threshold_scan_before_and_after_calibration.root", "recreate")

calibration = MPACalibration(assembly)
calibration.thresholdScan(calEnbl = 1, calNum = 5000)

counter, mem = calibration.getThrScanPerPix()
_,_,threshold = calibration.getThrScanMetadata()
for nMPA, MPA in enumerate(assembly):
    mpaDir = rootFile.mkdir("Threshold scans before calibration with MPA "+str(MPA), "Threshold scans before calibration with MPA "+str(MPA))
    plot = MPAPlot()
    for pix in counter[nMPA]:
        plot.createGraph(threshold[nMPA], pix)
    plot.setTitle('MPA ' + str(MPA) + ' threshold scan before calibration; Threshold (DAC);Number of Hits')
    plot.draw()
    graphList = plot.getPlot()
    for graph in graphList:
        mpaDir.Add(graph)
    mpaDir.Write()

edgesBeforeCal = calibration.findFallingEdges()
trimDac = calibration.getTrimBits(minimize = False)
calibration.writeCalibrationToMPA(trimDAC = trimDac)

for nMPA, MPA in enumerate(assembly):
    plot = MPAPlot()
Esempio n. 5
0
calScanEdges = []
for calDAC in range(0, 255, 10):

    calibration.thresholdScan(calEnbl=True, calCharge=calDAC)

    calScanEdges.append(calibration.findFallingEdges())

MAPSACalPix = [list(cal) for cal in zip(*calScanEdges)]

MAPSAPixCal = []
for MPA in MAPSACalPix:

    MAPSAPixCal.append([list(pix) for pix in zip(*MPA)])

for i, MPA in enumerate(MAPSAPixCal):
    plot = MPAPlot()

    for pix in MPA:
        plot.createGraph(range(0, 255, 10), pix)
    if i == 1:
        plot.setLineColor(colors)
    plot.setTitle(
        "Caldac linearity scan for MPA " + str(assembly[i]) +
        "; Calibration charge / calDACs; Falling edge position / thrDACs")
    plot.draw()

    graphs = plot.getPlot()
    mpaDir = rootFile.mkdir("MPA " + str(assembly[i]),
                            "MPA " + str(assembly[i]))
    for graph in graphs:
        mpaDir.Add(graph)
# Take connection, GLIB and MPA from calibration
glib = calibration._glib
mapsaClasses = calibration._mapsaClasses

mpa = calibration._mpa
conf = calibration._conf

# Define default config
calibration.thresholdScan()

counter, _ = calibration.getThrScanPerPix()
_, _, thresholds = calibration.getThrScanMetadata()

for iMPA in range(0, 2):
    plot = MPAPlot()
    for pix in counter[iMPA]:
        plot.createGraph(thresholds[iMPA], pix)
    #plot.draw()

    #threshold = input("Which global threshold should be set?")
    threshold = 150
    calibration._conf[iMPA].modifyperiphery(
        'THDAC', threshold)  # Write threshold to MPA 'iMPA'
    calibration._conf[iMPA].upload()
    calibration._glib.getNode("Configuration").getNode("mode").write(
        calibration._nMPA - 1)
    calibration._conf[iMPA].spi_wait()  # includes dispatch

shutterDur = 0xFFFFF  #0xFFFFFFFF is maximum, in clock cycles
Esempio n. 7
0
    mapsaClasses.daq().Sequencer_init(0, shutterDur)
    mpaArrayCounter = []
    for iMPA, _ in enumerate(assembly): 

        counter  = glib.getNode("Readout").getNode("Counter").getNode("MPA"+str(iMPA + 1)).getNode("buffer_1").readBlock(25) 
        glib.dispatch()
        
        counterArray = []
        for x in range(1,len(counter)): # Skip header at [0]
                counterArray.append(counter[x] & 0x7FFF) # Mask to select left pixel 
                counterArray.append((counter[x] >> 16) & 0x7FFF) # Mask to select right pixel
        mpaArrayCounter.append(counterArray)

    hitArrayVolt.append(mpaArrayCounter)
    time.sleep(2)
    print voltSource.readVoltage()
    print voltSource.readCurrent()

voltSource.close()
hitArrayMAPSA = [list(MPA) for MPA in zip(*hitArrayVolt)] # Swap highest and second-higest order of nesting 
print hitArrayMAPSA[0]
print hitArrayMAPSA[1]


for MPA in hitArrayMAPSA:
    plot = MPAPlot()
    for pix in MPA:
        plot.createGraph(voltArray, pix)
    plot.setRange(yRange = [0,50])
    plot.draw()
Esempio n. 8
0
        fwhmDiffMAPSA = []
        for MPA in MAPSAFWHMVolt:
            fwhmDiff = []
            for pix in MPA:
                fwhmDiff.append(
                    sum(sorted(pix)[-2:]) / 2 - sum(sorted(pix)[:2]) /
                    2)  # Average two highest and two lowest fwhms
            fwhmDiffMAPSA.append(fwhmDiff)

        return fwhmDiffMAPSA


if __name__ == "__main__":

    from MPAPlot import MPAPlot
    plot = MPAPlot()
    assembly = [2, 5]
    nMPA = 2

    calibration = MPACalibration(assembly)
    calibration.thresholdScan(None,
                              calEnbl=False,
                              shutterDur=0xFFFF,
                              calCharge=100,
                              calNum=10000)

    counter, mem = calibration.getThrScanPerPix()
    _, _, threshold = calibration.getThrScanMetadata()
    for pix in counter[0]:
        plot.createGraph(threshold[0], pix)
    plot.draw()
Esempio n. 9
0
from ROOT import TH2S, TCanvas, TAxis, gStyle
from MPAPlot import MPAPlot

MPANum = 4  # Number of MPA, 0-indexed
memory = [
    event for event in open('data/synchronous_data_noise_MPA' +
                            str(MPANum + 1)).read().splitlines() if event
]  # Reads events from file and skips empty lines after each shutter
plot = MPAPlot()

memoryArray = []
for event in memory:
    eventArray = []
    for pix in event:
        eventArray.append(int(pix))
    memoryArray.append(eventArray)

hitsPerPixel = [sum(pix) for pix in zip(*memoryArray)]

plot.createHisto(hitsPerPixel, 0, len(hitsPerPixel), len(hitsPerPixel))

plot.draw()
Esempio n. 10
0
from testBeamAnalysis import TBAnalysis

tb = TBAnalysis()

axis = sys.argv[3]

# Input

if len(sys.argv) == 5:
    offset = int(sys.argv[4])
elif len(sys.argv) == 6:
    offset = range(int(sys.argv[4]), int(sys.argv[5]) + 1)
else:
    offset = 0

dutRaw = tb.parseFile(sys.argv[1])
refArray = tb.parseFile(sys.argv[2])

dutArray = tb.convertFormat(dutRaw, axis)

plot = MPAPlot()

# Plot
if isinstance(offset, int):
    plot.createCorrelationPlot(dutArray, refArray, axis, offset)
    plot.draw()
else:
    for iOff in offset:
        plot.createCorrelationPlot(dutArray, refArray, axis, iOff)
    plot.save("output/correlations")
Esempio n. 11
0
glib.dispatch()

# Reset all logic on GLIB
glib.getNode("Control").getNode("logic_reset").write(0x1)
glib.dispatch()

# Source all classes
mapsaClasses = MAPSA(a)

calibration = MPACalibration(assembly)

conf = []
mpa = []
for iMPA, nMPA in enumerate(assembly):
    mpa.append(MPA(
        glib, iMPA +
        1))  # List of instances of MPA, one for each MPA. SPI-chain numbering!
    conf.append(mpa[iMPA].config("data/Conf_trimcalib_MPA" + str(nMPA) +
                                 "_masked.xml"))  # Use trimcalibrated config

calibration.thresholdScan(calEnbl=False, conf=conf)

counter, mem = calibration.getThrScanPerPix()
_, _, threshold = calibration.getThrScanMetadata()

for i, nMPA in enumerate(counter):
    plot = MPAPlot()
    for pix in nMPA[1:]:
        plot.createGraph(threshold[i], pix)
    plot.draw()