def scanThresholdByVFAT(device,gtx,vfat,
                        scanmin=0x0,scanmax=0xff,
                        stepsize=0x1,numtrigs=1000,
                        trkmode=False,debug=False):
    """ 
    Run a firmware threshold  scan on the selected VFAT
    trkmode=True requires a trigger source
    @returns an array containing the scan results
    """

    optofuncs.configureScanModule(device,gtx,
                                  optofuncs.scanmode.THRESHTRG if trkmode else optofuncs.scanmode.THRESHTRK,
                                  vfat,
                                  scanmin,scanmax,stepsize,numtrigs,
                                  debug=debug)
    optofuncs.startScanModule(device,gtx)
    if (debug):
        optofuncs.printScanConfiguration(device,gtx)
        pass

    msg = "LocalT1Controller status %d"%(optofuncs.getLocalT1Status(device,gtx))
    scanlogger.debug(colormsg(msg,logging.DEBUG))

    data_threshold = optofuncs.getScanResults(device,gtx,scanmax-scanmin,debug=debug)
    
    return data_threshold
def scanThresholdByChannel(device,gtx,vfat,channel,
                           scanmin=0x0,scanmax=0xff,
                           stepsize=0x1,numtrigs=1000,
                           debug=False):
    """ 
    Run a firmware threshold  scan on the selected VFAT/channel combination
    @returns an array containing the scan results
    """

    try:
        checkScanParams(vfat,scanmin,scanmax,stepsize)
    except ValueError:
        msg = "Invalid scan configuration specified"
        scanlogger.error(colormsg(msg,logging.ERROR))
        return None
        
    optofuncs.configureScanModule(device,gtx,
                                  optofuncs.scanmode.THRESHCH,
                                  vfat,channel,
                                  scanmin,scanmax,stepsize,numtrigs,
                                  debug=debug)
    optofuncs.startScanModule(device,gtx)
    if (debug):
        optofuncs.printScanConfiguration(device,gtx)
        pass

    msg = "LocalT1Controller status %d"%(optofuncs.getLocalT1Status(device,gtx))
    scanlogger.debug(colormsg(msg,logging.DEBUG))

    data_threshold = optofuncs.getScanResults(device,gtx,scanmax-scanmin,debug=debug)
    
    return data_threshold
def scanVCalByVFAT(device,gtx,vfat,channel,trim,
                   scanmin=0x0,scanmax=0xff,
                   stepsize=0x1,numtrigs=1000,
                   debug=False):
    """
    Run a firmware VCal  scan on the selected VFAT/channel combination
    requires a trigger source, cal pulse source, channel enabled
    @returns an array containing the scan results
    """
    
    try:
        checkScanParams(vfat,scanmin,scanmax,stepsize)
    except ValueError:
        msg = "Invalid scan configuration specified"
        scanlogger.error(colormsg(msg,logging.ERROR))
        return None
        
    originalChannel = vfatfuncs.getChannelRegister(device,gtx,vfat,channel)

    vfatfuncs.setChannelRegister(device,gtx,vfat,channel,
                                 mask=0x0,pulse=0x1,trim=trim)
    
    msg = "Channel %d register 0x%08x"%(channel,getChannelRegister(device,gtx,vfat,channel))
    scanlogger.debug(colormsg(msg,logging.DEBUG))

    optofuncs.configureScanModule(device,gtx,
                                  optofuncs.scanmode.SCURVE,
                                  vfat,
                                  channel=channel,
                                  scanmin=scanmin,
                                  scanmax=scanmax,
                                  stepsize=stepsize,
                                  numtrigs=numtrigs,
                                  debug=debug)
    optofuncs.startScanModule(device,gtx)

    if (debug):
        optofuncs.printScanConfiguration(device,gtx)
        pass

    msg = "LocalT1Controller status %d"%(optofuncs.getLocalT1Status(device,gtx))
    scanlogger.debug(colormsg(msg,logging.DEBUG))

    data_scurve = optofuncs.getScanResults(device,gtx,
                                           scanmax-scanmin,
                                           debug=debug)
    
    # return settings to start
    mask  = (originalChannel>>5)&0x1
    pulse = (originalChannel>>6)&0x1
    trim  = originalChannel&0x1f

    vfatfuncs.setChannelRegister(device,gtx,vfat,channel,
                                 mask=mask,pulse=pulse,trim=trim,
                                 debug=debug)

    msg = "Channel %d register 0x%08x"%(channel,vfatfuncs.getChannelRegister(device,gtx,vfat,channel))
    scanlogger.debug(colormsg(msg,logging.DEBUG))

    return data_scurve
def scanLatencyByVFAT(device,gtx,vfat,
                      scanmin=0x0,scanmax=0xff,
                      stepsize=0x1,numtrigs=1000,
                      debug=False):
    """
    Run a firmware latency  scan on the selected VFAT
    requires a trigger source
    @returns an array containing the scan results
    """

    try:
        checkScanParams(vfat,scanmin,scanmax,stepsize)
    except ValueError:
        msg = "Invalid scan configuration specified"
        scanlogger.error(colormsg(msg,logging.ERROR))
        return None
        
    channel = 10
    originalChannel = vfatfuncs.getChannelRegister(device,gtx,vfat,channel)
    originalVCal    = vfatfuncs.readVFAT(device,gtx,vfat,"VCal")

    vfatfuncs.setChannelRegister(device,gtx,vfat,channel,
                                 mask=0x0,pulse=0x1,trim=trim)
    vfatfuncs.writeVFAT(device,gtx,vfat,"VCal",0xff)

    optofuncs.configureScanModule(device,gtx,
                                  optofuncs.scanmode.LATENCY,
                                  vfat,
                                  scanmin,scanmax,
                                  stepsize=1,numtrigs=numtrigs,
                                  debug=debug)
    optofuncs.startScanModule(device,gtx)
    if (debug):
        optofuncs.printScanConfiguration(device,gtx)
        pass

    msg = "LocalT1Controller status %d"%(optofuncs.getLocalT1Status(device,gtx))
    scanlogger.debug(colormsg(msg,logging.DEBUG))

    data_latency = optofuncs.getScanResults(device,gtx,scanmax-scanmin,debug=debug)
    
    # return settings to start
    mask  = (originalChannel>>5)&0x1
    pulse = (originalChannel>>6)&0x1
    trim  = originalChannel&0x1f

    vfatfuncs.setChannelRegister(device,gtx,vfat,channel,
                                 mask=mask,pulse=pulse,trim=trim,
                                 debug=debug)
    vfatfuncs.writeVFAT(device,gtx,vfat,"VCal",originalVcal)

    return data_latency
Ejemplo n.º 5
0
def scanThresholdByChannel(device,
                           gtx,
                           vfat,
                           channel,
                           scanmin=0x0,
                           scanmax=0xff,
                           stepsize=0x1,
                           numtrigs=1000,
                           debug=False):
    """ 
    Run a firmware threshold  scan on the selected VFAT/channel combination
    @returns an array containing the scan results
    """

    try:
        checkScanParams(vfat, scanmin, scanmax, stepsize)
    except ValueError:
        msg = "Invalid scan configuration specified"
        scanlogger.error(colormsg(msg, logging.ERROR))
        return None

    optofuncs.configureScanModule(device,
                                  gtx,
                                  optofuncs.scanmode.THRESHCH,
                                  vfat,
                                  channel,
                                  scanmin,
                                  scanmax,
                                  stepsize,
                                  numtrigs,
                                  debug=debug)
    optofuncs.startScanModule(device, gtx)
    if (debug):
        optofuncs.printScanConfiguration(device, gtx)
        pass

    msg = "LocalT1Controller status %d" % (optofuncs.getLocalT1Status(
        device, gtx))
    scanlogger.debug(colormsg(msg, logging.DEBUG))

    data_threshold = optofuncs.getScanResults(device,
                                              gtx,
                                              scanmax - scanmin,
                                              debug=debug)

    return data_threshold
Ejemplo n.º 6
0
def scanThresholdByVFAT(device,
                        gtx,
                        vfat,
                        scanmin=0x0,
                        scanmax=0xff,
                        stepsize=0x1,
                        numtrigs=1000,
                        trkmode=False,
                        debug=False):
    """ 
    Run a firmware threshold  scan on the selected VFAT
    trkmode=True requires a trigger source
    @returns an array containing the scan results
    """

    optofuncs.configureScanModule(device,
                                  gtx,
                                  optofuncs.scanmode.THRESHTRG
                                  if trkmode else optofuncs.scanmode.THRESHTRK,
                                  vfat,
                                  scanmin,
                                  scanmax,
                                  stepsize,
                                  numtrigs,
                                  debug=debug)
    optofuncs.startScanModule(device, gtx)
    if (debug):
        optofuncs.printScanConfiguration(device, gtx)
        pass

    msg = "LocalT1Controller status %d" % (optofuncs.getLocalT1Status(
        device, gtx))
    scanlogger.debug(colormsg(msg, logging.DEBUG))

    data_threshold = optofuncs.getScanResults(device,
                                              gtx,
                                              scanmax - scanmin,
                                              debug=debug)

    return data_threshold
Ejemplo n.º 7
0
        writeRegister(ohboard,"%s.RESET"%(scanBase),0x1)
        time.sleep(0.1)
        pass
    amc13nL1A = (amc13board.read(amc13board.Board.T1, "STATUS.GENERAL.L1A_COUNT_HI") << 32) | (amc13board.read(amc13board.Board.T1, "STATUS.GENERAL.L1A_COUNT_LO"))
    amcnL1A = amc.getL1ACount(amcboard)
    ohnL1A = oh.getL1ACount(ohboard,options.gtx)
    print "Initial L1A counts:"
    print "AMC13: %s"%(amc13nL1A)
    print "AMC: %s"%(amcnL1A)
    print "OH%s: %s"%(options.gtx,ohnL1A)
    oh.configureScanModule(ohboard, options.gtx, mode, mask,
                        scanmin=LATENCY_MIN, scanmax=LATENCY_MAX,
                        stepsize=step,
                        numtrigs=int(options.nevts),
                        useUltra=True, debug=True)
    oh.printScanConfiguration(ohboard, options.gtx, useUltra=True, debug=options.debug)
    sys.stdout.flush()
    amc13board.enableLocalL1A(True)

    if options.internal:
        amc.blockL1A(amcboard)
        oh.setTriggerSource(ohboard,options.gtx,0x1)
        oh.sendL1ACalPulse(ohboard, options.gtx, delay=20, interval=400, number=0)
        chanReg = ((1&0x1) << 6)|((0&0x1) << 5)|(0&0x1f)
        writeAllVFATs(ohboard, options.gtx, "VFATChannels.ChanReg0", chanReg, mask)
        writeAllVFATs(ohboard, options.gtx, "VCal",     250, mask)
    else:
        if options.amc13local:
            amc.enableL1A(amcboard)
            amcMask = amc13board.parseInputEnableList("%s"%(options.slot), True)
            amc13board.reset(amc13board.Board.T1)
Ejemplo n.º 8
0
    print "Initial L1A counts:"
    print "AMC13: %s" % (amc13nL1A)
    print "AMC: %s" % (amcnL1A)
    print "OH%s: %s" % (options.gtx, ohnL1A)
    oh.configureScanModule(ohboard,
                           options.gtx,
                           gemData.getMode(),
                           mask,
                           scanmin=LATENCY_MIN,
                           scanmax=LATENCY_MAX,
                           stepsize=step,
                           numtrigs=int(options.nevts),
                           useUltra=True,
                           debug=True)
    oh.printScanConfiguration(ohboard,
                              options.gtx,
                              useUltra=True,
                              debug=options.debug)
    sys.stdout.flush()
    amc13board.enableLocalL1A(True)

    if options.internal:
        amc.blockL1A(amcboard)
        oh.setTriggerSource(ohboard, options.gtx, 0x1)
        oh.sendL1ACalPulse(ohboard,
                           options.gtx,
                           delay=20,
                           interval=400,
                           number=0)
        chanReg = ((1 & 0x1) << 6) | ((0 & 0x1) << 5) | (0 & 0x1f)
        writeAllVFATs(ohboard, options.gtx, "VFATChannels.ChanReg0", chanReg,
                      mask)
Ejemplo n.º 9
0
def scanVCalByVFAT(device,
                   gtx,
                   vfat,
                   channel,
                   trim,
                   scanmin=0x0,
                   scanmax=0xff,
                   stepsize=0x1,
                   numtrigs=1000,
                   debug=False):
    """
    Run a firmware VCal  scan on the selected VFAT/channel combination
    requires a trigger source, cal pulse source, channel enabled
    @returns an array containing the scan results
    """

    try:
        checkScanParams(vfat, scanmin, scanmax, stepsize)
    except ValueError:
        msg = "Invalid scan configuration specified"
        scanlogger.error(colormsg(msg, logging.ERROR))
        return None

    originalChannel = vfatfuncs.getChannelRegister(device, gtx, vfat, channel)

    vfatfuncs.setChannelRegister(device,
                                 gtx,
                                 vfat,
                                 channel,
                                 mask=0x0,
                                 pulse=0x1,
                                 trim=trim)

    msg = "Channel %d register 0x%08x" % (
        channel, getChannelRegister(device, gtx, vfat, channel))
    scanlogger.debug(colormsg(msg, logging.DEBUG))

    optofuncs.configureScanModule(device,
                                  gtx,
                                  optofuncs.scanmode.SCURVE,
                                  vfat,
                                  channel=channel,
                                  scanmin=scanmin,
                                  scanmax=scanmax,
                                  stepsize=stepsize,
                                  numtrigs=numtrigs,
                                  debug=debug)
    optofuncs.startScanModule(device, gtx)

    if (debug):
        optofuncs.printScanConfiguration(device, gtx)
        pass

    msg = "LocalT1Controller status %d" % (optofuncs.getLocalT1Status(
        device, gtx))
    scanlogger.debug(colormsg(msg, logging.DEBUG))

    data_scurve = optofuncs.getScanResults(device,
                                           gtx,
                                           scanmax - scanmin,
                                           debug=debug)

    # return settings to start
    mask = (originalChannel >> 5) & 0x1
    pulse = (originalChannel >> 6) & 0x1
    trim = originalChannel & 0x1f

    vfatfuncs.setChannelRegister(device,
                                 gtx,
                                 vfat,
                                 channel,
                                 mask=mask,
                                 pulse=pulse,
                                 trim=trim,
                                 debug=debug)

    msg = "Channel %d register 0x%08x" % (
        channel, vfatfuncs.getChannelRegister(device, gtx, vfat, channel))
    scanlogger.debug(colormsg(msg, logging.DEBUG))

    return data_scurve
Ejemplo n.º 10
0
def scanLatencyByVFAT(device,
                      gtx,
                      vfat,
                      scanmin=0x0,
                      scanmax=0xff,
                      stepsize=0x1,
                      numtrigs=1000,
                      debug=False):
    """
    Run a firmware latency  scan on the selected VFAT
    requires a trigger source
    @returns an array containing the scan results
    """

    try:
        checkScanParams(vfat, scanmin, scanmax, stepsize)
    except ValueError:
        msg = "Invalid scan configuration specified"
        scanlogger.error(colormsg(msg, logging.ERROR))
        return None

    channel = 10
    originalChannel = vfatfuncs.getChannelRegister(device, gtx, vfat, channel)
    originalVCal = vfatfuncs.readVFAT(device, gtx, vfat, "VCal")

    vfatfuncs.setChannelRegister(device,
                                 gtx,
                                 vfat,
                                 channel,
                                 mask=0x0,
                                 pulse=0x1,
                                 trim=trim)
    vfatfuncs.writeVFAT(device, gtx, vfat, "VCal", 0xff)

    optofuncs.configureScanModule(device,
                                  gtx,
                                  optofuncs.scanmode.LATENCY,
                                  vfat,
                                  scanmin,
                                  scanmax,
                                  stepsize=1,
                                  numtrigs=numtrigs,
                                  debug=debug)
    optofuncs.startScanModule(device, gtx)
    if (debug):
        optofuncs.printScanConfiguration(device, gtx)
        pass

    msg = "LocalT1Controller status %d" % (optofuncs.getLocalT1Status(
        device, gtx))
    scanlogger.debug(colormsg(msg, logging.DEBUG))

    data_latency = optofuncs.getScanResults(device,
                                            gtx,
                                            scanmax - scanmin,
                                            debug=debug)

    # return settings to start
    mask = (originalChannel >> 5) & 0x1
    pulse = (originalChannel >> 6) & 0x1
    trim = originalChannel & 0x1f

    vfatfuncs.setChannelRegister(device,
                                 gtx,
                                 vfat,
                                 channel,
                                 mask=mask,
                                 pulse=pulse,
                                 trim=trim,
                                 debug=debug)
    vfatfuncs.writeVFAT(device, gtx, vfat, "VCal", originalVcal)

    return data_latency