#!/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 # # modified in May for temp+pressure+rate readout for DV tests at PSL # import icecube.domtest.ibidaq as daq import os import sys, time from getopt import getopt import socket 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, 2097, 3000, 2048, 850, 2097, 3000, 1925, 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) print " " t = q.readTemperature() if t > 32767: t -= 65536 temperature = t/256.0 print "temperature = ",t/256.0," degrees centigrade" p = q.send('readPressure .') print "pressure = ",p,"kPa" pressure=int(p) time.sleep(1.) q.setSPEDeadtime(6) # Ramp discriminator levels d = 0 discs = 7 disc = [ 500,510,525,550,575,600,700,1000 ] #disc = [ 500 ] counter = 0 avgrate=[] for d in disc: # Set discriminator level q.setDAC(9, d) rate = q.spef() # Wait a bit time.sleep(1.0) c = 1 trate = 0 while (c <= 10): time.sleep(0.1) # Read out rate rate = q.spef() trate = trate + rate # outstr = " Disc: "+str(d)+" Rate (kHz): %0.2f" % (float(rate)/100.) # print outstr c = c + 1 avgrate.append(float(trate)/1000.) outstr = "Disc: "+str(d)+" Rate (kHz): %0.2f" % (float(trate)/1000.) print outstr counter = counter + 1 #printstr = "%d %12s %-12.12s %.2f %.2f\n" % (time.time(),domid,domname,temperature,pressure) #print printstr # # %d time.time() # hub = socket.gethostname() domTU = "T" if (domAB == 1) : domTU = "U" hub = hub[-1] location = "%s%d%d%s" % (hub,card,pair,domTU) printstr = "%23s %-13.13s %4s %-20.20s %12s %.2f %d %4d %.2f %.2f %.2f %.2f %.2f %.2f %.2f\n" % (time.strftime("%F %T %Z"),time.time(), location, domname,domid,temperature,pressure,hv,avgrate[0],avgrate[1],avgrate[2],avgrate[3],avgrate[4],avgrate[5],avgrate[6]) print printstr flog=open('/home/testdaq/monitor/monitor.dat', 'a') flog.write("%23s %-13.13s %4s %-20.20s %12s %.2f %d %4d %.2f %.2f %.2f %.2f %.2f %.2f %.2f\n" % (time.strftime("%F %T %Z"), time.time(), location, domname,domid,temperature,pressure,hv,avgrate[0],avgrate[1],avgrate[2],avgrate[3],avgrate[4],avgrate[5],avgrate[6])) flog.flush() time.sleep(0.5) # 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()