#------- Reading and programing dc with calibrated values from file -------------------------# #--------------------------------------------------------------------------------------------# elif CalbMode == 3: print "\nReading best file for trigger rate of %d and programing all enabled asics with base values" %(IF0) infile = open(BestCalib_file, 'r') csvFile = csv.reader(infile, delimiter='\t') curr_line = 0 exth = int(exth) for line in csvFile: curr_line += 1 if curr_line > 2: ch = int(line[1]) dcnum = line[0] if asic_mask[4-int(dcnum)] == '1': dac_ch = linkEth.mppcToDAC_decoder(ch) if line[2] == "-1" or line[3] == "-1": print "No Base Value for DC%s CH%#d so setting to default(th:1550 DAC:0.95V)" %(dcnum, ch) THVal = 1550 DACVal = int(0.95/.0006105) else: THVal = int(line[3])+exth if THVal >= 4095: THVal = 4095 DACVal = int(line[2]) if DACVal >= 4095: DACVal = 4095 print "Setting DC#%s ch#%d threshold = %4d DAC = %2.3f" %(dcnum,ch,THVal,DACVal*0.0006105) cmd = dcnum+"ABCDABC"+dcnum+hex(int("B000000",16)|(2*(ch-1))*(2**16)|THVal).split('x')[1]+\ dcnum+hex(int("C000000",16)|dac_ch*2**16|DACVal).split('x')[1]
# setting current channel for ch in range(ChSrt,ChEnd): print "********** Starting scan for channel %d **********" %(ch+1) minDeltaF = [20000 for i in range(4)] # setting trim dac value for dac in range(dac_UpLim,dac_LoLim,-dac_delta): UpLim = dac+int(th_offset/2) LoLim = dac-th_offset if UpLim >= th_UpLim: UpLim = th_UpLim elif LoLim <= 0: LoLim = 0 dac_ch = linkEth.mppcToDAC_decoder(ch+1) dacVal = dac*0.0006105 cmd = "FABCDABC"+hex(int("FC000000",16)|dac_ch*2**16|dac).split('x')[1] ctrl.send(syncwd+cmd) time.sleep(0.1) #--------------------------------------------------------------------------------------------# #------- performing course threshold for all channels on all enabled asics ------------------# #--------------------------------------------------------------------------------------------# print "\nCurrent HV bias is %2.2fV [RawHV:%2.2fV, DAC:%1.2fV, TH range %d to %d]" %(rawHV-dacVal,rawHV,dacVal,UpLim,LoLim) th_c = [UpLim for i in range(4)] fmax = [-1 for i in range(4)] qc = [0 for i in range(4)] print "**********Starting baseline scan for all enabled DC**********" for th in range(UpLim,LoLim,-th_delta):
print "\nDC%s CH%d TH:%d DAC:%1.2fV trig_count:%9d, freq:%4.2fkHz" %(dc_num,ch+1,int(reg_val),dacval[int(dc_num)-1][ch],scalerCount,freq) # scan complete pograming threshold and dacs with calibrated values cmd = dc_num+"ABCDABC" for ch in range(15): THVal = th[int(dc_num)-1][ch] if THVal >= 4095: THVal = 4095 cmd += dc_num+hex(int('B000000',16)|(2*ch)*(2**16)|THVal).split('x')[1] ctrl.send(syncwd+cmd) #----------------------------------------------------------------------------------------------------# #---------------- Programing single MPPC channel and counting trigger rate --------------------------# #----------------------------------------------------------------------------------------------------# elif com_type == "C": dac_ch = linkEth.mppcToDAC_decoder(reg_num) ctrl.send(syncwd+cmd_th_zero) time.sleep(.5) cmd = dc_num+"ABCDABC" if float(reg_val) <= 2.5: dac_val = float(reg_val) cmd = dc_num+hex(int("B000000",16)|(2*ch)*2**16|th[int(dc_num)-1][int(reg_num)-1]).split('x')[1]+\ dc_num+hex(int("C000000",16)|dac_ch*2**16|int(float(reg_val)/.0006105)).split('x')[1]+\ dc_num+"F130001"+dc_num+"E000020"+dc_num+"F130000" else: dac_val = float(reg_val)*.0006105 cmd = dc_num+hex(int("B000000",16)|(2*ch)*2**16|th[int(dc_num)-1][int(reg_num)-1]).split('x')[1]+\ dc_num+hex(int("C000000",16)|dac_ch*2**16|int(reg_val)).split('x')[1]+\ dc_num+"F130001"+dc_num+"E000020"+dc_num+"F130000"
hvBest = [[1605 for i in range(15)] for j in range(4)] f_best = [[-1 for i in range(16)] for j in range(4)] f0 = 500 #SET HV to selected value, Trim DACs to zero, and Thereshold to 4095 ctrl.send(syncwd + cmd_dac_max) time.sleep(.5) ctrl.send(syncwd + cmd_th_max) time.sleep(.5) # ctrl.send(syncwd+cmd_wbais_config) # time.sleep(.5) for ch in range(ch2start, ch2scan - 1): minDeltaF = [20000 for i in range(4)] quit_count = 0 dac_ch = linkEth.mppcToDAC_decoder(ch + 1) if ch == 69: break # setting thereshold of current channel on all dc to 1500 cmd_th = "FABCDABC" + hex( int('FB000000', 16) | (2 * ch) * (2**16) | 1500).split('x')[1] ctrl.send(syncwd + cmd_th) time.sleep(.2) #-------------------------------------------------------------------------------------# #-- doing course scan for trim DACs --------------------------------------------------# #-------------------------------------------------------------------------------------# print "\n*********** -Course Scan for MPPC Ch%d- ***********" % ( ch + 1) for trim in range(c_up_lim, c_lo_lim, -c_delta): cmdHV = "FABCDABC" + hex(