File indexing completed on 2025-01-18 10:17:18
0001
0002
0003
0004
0005
0006 import zmq, pickle, random
0007 import numpy as np
0008 import matplotlib.pyplot as plt
0009
0010
0011 subPort = 5558
0012
0013 subContext = zmq.Context()
0014 subscriber = subContext.socket(zmq.SUB)
0015 subscriber.setsockopt(zmq.SUBSCRIBE, b'')
0016 subscriber.connect('tcp://127.0.0.1:%d' % subPort)
0017 print('\nSubscribing to tcp://127.0.0.1:%d\n' % subPort)
0018
0019
0020 numRows = 6; numCols = 6; numChans = 80
0021 fig, axs = plt.subplots(numRows, numCols)
0022 fig.set_size_inches(18.5, 10.5, forward = True)
0023
0024
0025 cl = ['tab:blue', 'tab:orange', 'tab:green', 'tab:red', 'tab:purple',
0026 'tab:brown', 'tab:pink', 'tab:gray', 'tab:olive', 'tab:cyan']
0027 ml = ['o', '^', 's', 'p', 'P', '*', 'X', 'd']
0028
0029
0030 rcl = random.sample(range(1, numChans + 1), numRows*numCols)
0031 rcl.sort()
0032
0033
0034 enl = []; hitThresh = 100
0035
0036 ec = 0
0037
0038 while True :
0039
0040 picklePacket = subscriber.recv_pyobj()
0041 print('picklePacket received!')
0042 eventDataDict = pickle.loads(picklePacket)
0043 ec += 1
0044 ic = 0
0045 for row in range(numRows) :
0046 for column in range(numCols) :
0047 axs[row, column].cla()
0048 axs[row, column].plot(eventDataDict['tdcSamplesChan_%d' % rcl[ic]],
0049 eventDataDict['adcSamplesChan_%d' % rcl[ic]],
0050 color = cl[ic % len(cl)], marker = ml[ic % len(ml)],
0051 ls = '', label = 'Channel %d' % rcl[ic])
0052 hitLoc = np.where(eventDataDict['adcSamplesChan_%d' % rcl[ic]]>100)[0] + np.min(eventDataDict['tdcSamplesChan_%d' % rcl[ic]])
0053 if len(hitLoc) != 0 : axs[row, column].set_xlim(np.min(hitLoc) - 10, np.max(hitLoc) + 20)
0054 axs[row, column].set_ylim(0, 1024)
0055 if column == 0 : axs[row, column].set_ylabel('ADC Value')
0056 if row == numRows - 1 : axs[row, column].set_xlabel('TDC Sample Number')
0057 axs[row, column].legend(loc = 'best', markerscale = 0, handletextpad = 0, handlelength = 0)
0058 ic += 1
0059 plt.tight_layout()
0060
0061 plt.pause(0.05)