#!/usr/bin/env python # # rate.py # # Get IceTop DOM trigger rate for different discriminator values # John Kelley (jkelley@amanda.wisc.edu) # January 2004 # # modified by Mark Krasberg, March 2004, to use domnames data base # import icecube.domtest.ibidaq as daq import os import sys, time from getopt import getopt import string id=[6000] name=[6000] comment=[6000] domnames = 0 if os.path.isfile("/usr/local/python/domnames.dat"): f=open('/usr/local/python/domnames.dat', 'r') line = f.readline() while line: domnames = domnames + 1 (i,n,c) = line.split("|") id.append(string.strip(i)) name.append(string.strip(n)) comment.append(string.strip(c)) # print "%12s %-30.30s %-30.30s" % (id[domnames],name[domnames],comment[domnames]) line = f.readline() f.close() print " " print "*************** This program enables the HV !!! ********************" print " " version = 1.3 def usage(): return """ rate.py version %s usage :: rate.py [ options ] -v Set high voltage (default 1500V) -l SPE discriminator low level (default 500) -h SPE discriminator high level (default 800) -s Discriminator step value (default 20) examples: rate.py 2 1 b examines card 2, wire pair 1, dom B rate.py 2 1 0 examines card 2, wire pair 1, dom A rate.py 1 1 examines card 1, wire pair 1, domA assumed rate.py 1 examines card 1, wire pair 0 and domA assumed rate.py -v 1400 1 examines c1-wp0-domA at 1400 Volts This program uses the PMT High Voltage - the DOM should be in the dark! """ % (version) hv = 1500 nevt = 10 ncyc = 1 disc_low = 500 disc_high = 800 disc_step = 20 dacs = [ 850, 2300, 3000, 2250, 850, 2300, 3000, 2130, 0, disc_low, 0, 700, 0, 800, 0, 0 ] # Process command-line arguments if (len(sys.argv) < 2): print usage() sys.exit(1) opts, args = getopt(sys.argv[1:], 'v:l:h:s:') for o, a in opts: if o == '-v': hv = int(a) elif o == '-l': disc_low = int(a) elif o == '-h': disc_high = int(a) elif o == '-s': disc_step = int(a) card = -1 pair = -1 domAB = -1 c =0 for arg in args: c = c + 1 if (c == 1) : card = int(arg) if (c == 2) : pair = int(arg) if (c == 3) : if (arg == 'A') : domAB = 0 if (arg == 'B') : domAB = 1 if (arg == 'a') : domAB = 0 if (arg == 'b') : domAB = 1 if (domAB == -1) : domAB = int(arg) if (card == -1) : card = 0 if (pair == -1) : pair = 0 if (domAB == -1) : domAB = 0 # Connect to the DOM #card = args.pop(0) #pair = args.pop(0) #domAB = args.pop(0) #card = 0 #pair = 0 #domAB = 0 #card = int(sys.argv[1]) #pair = int(sys.argv[2]) #if (defined(sys.argv[3])) domAB = int(sys.argv[3]) #domAB = int(sys.argv[3]) port = 5000+(int(card)*8)+(int(pair)*2)+int(domAB) print "card = %d pair = %d domAB = %d port is %d" % (card,pair,domAB,port) q = daq.ibx("localhost",port) # DOM ID decode for IceTop domid = q.getId() domname = "" for c in range(1,domnames): if domid == id[c] : domname = name[c] domcomment = comment[c] #if domid == '00013c6286c1': domname = "Bubble" #elif domid == '00013c627f13': domname = "Frankendom" #elif domid == '00013c627dac': domname = "Chip" #elif domid == '00013c62a821': domname = "Scarface" #print " " #print "Hello my name is",domname #print " " print " " if domname == '': print "domid= ",domid," This DOM has no name" else: print "Hello my name is",domname print " " # Set up the DACs for i in range(0, 16): q.setDAC(i, dacs[i]) # Get the current HV orig_hv_adc = q.readHV() print "HV is currently %dV" % (orig_hv_adc / 2) # Turn on high voltage print "Setting HV to %dV for rate measurement" % hv q.enableHV() q.setHV(hv*2) time.sleep(2.0) # Ramp discriminator levels disc = disc_low retries = 10 counter = 0 while (disc <= disc_high): counter = 0 while (counter < retries): # Set discriminator level q.setDAC(9, disc) rate = q.spef() # Wait a bit time.sleep(1.0) # Read out rate rate = q.spef() outstr = "Disc: "+str(disc)+" Rate (kHz): %0.2f" % (float(rate)/100) print outstr counter = counter + 1 disc += disc_step # Set HV back to what it was if (orig_hv_adc == 0): print "Turning HV back off" q.disableHV() else: print "Returning HV to %dV" % (orig_hv_adc / 2) q.setHV(orig_hv_adc) # Close DOM connection q.s.close()