コード例 #1
0
def doScan(ts, scanRange = range(30), qieRange=0, sepCapID = True, SkipScan = False, outputDirectory = ""):

	print 'SepCap', sepCapID
        setFixRangeModeOn(ts,slotDict,qieRange)

	print orbitDelay
	getGoodLinks(ts, orbitDelay=orbitDelay, GTXreset = GTXreset, CDRreset = CDRreset, forceInit=True)

        relayOn = False
        if qieRange==0: relayOn = True

	results = {}
	for i in scanRange:

		histName = ""
		histName = "Calibration_LSB_{0}".format( i )
		if not SkipScan:
			print 'LSB', i, relayOn
			setDAC(i,relayOn=relayOn)
			getGoodLinks(ts, orbitDelay=orbitDelay, GTXreset = GTXreset, CDRreset = CDRreset)
			print 'GettingHist'
			fName = outputDirectory+histName

			while not os.path.exists(fName):
				if sepCapID:
					fName = uhtr.get_histos(ts,n_orbits=4000, sepCapID=1, file_out_base=outputDirectory+histName)
				else:
					fName = uhtr.get_histos(ts,n_orbits=4000, sepCapID=0, file_out_base=outputDirectory+histName)
		else:
			fName = outputDirectory+histName
		print 'ReadingHist'
		vals = read_histo(fName,sepCapID,int(qieRange))
		results[i] = vals

#		print_links(ts)
	if not SkipScan:
		setDAC(0,relayOn=relayOn)
                setFixRangeModeOff(ts,slotDict)

	getGoodLinks(ts, orbitDelay=orbitDelay, GTXreset = GTXreset, CDRreset = CDRreset, forceInit=True)

	# for i_crate in ts.fe_crates:
	# 	for i_slot in ts.qie_slots[0]:
	# 		print '-'*20
	# 		print 'Crate %i Slot %i Status'%(i_crate,i_slot)
	# 		print_qie_status(ts,i_crate,i_slot)


	return results
コード例 #2
0
def mapInjectorToQIE(ts, linkMap, outputDirectory = ''):
	"""
	Finds the mapping of which injector card is connected to which QIE card (and which half)
	
        Inject with one channel and see which QIE is read out (injects at a very high value, all other channels will be pedestals)
	"""
	print 'Set DAC, get good links'
	setDAC(dacLSB = 30000, dacChannel = 0,relayOn=False)
	getGoodLinks(ts, orbitDelay=orbitDelay, GTXreset = GTXreset, CDRreset = CDRreset, forceInit=True)


	print 'Get/Read Histos'
	fName = uhtr.get_histos(ts,n_orbits=300, sepCapID=0, file_out_base = outputDirectory+"mappingHist")
	vals = read_histo(fName,False)

	setDAC(dacLSB = 0,relayOn=False)

	getGoodLinks(ts, orbitDelay=orbitDelay, GTXreset = GTXreset, CDRreset = CDRreset, forceInit=True)

	mapping = {}

	simpleCardMap = {}
	for i in vals:
		# set to fixed range, not sep capID
		# setting to fixed range 1, injecting at a range 3 value
		# filled histograms should be at 127, empty histograms should at 64
		if vals[i]['mean'] > 96:
			histNum = i
			filledQIE = histNum%12 + 1
			injectionCardSlot = dac13Mapping[filledQIE]
			link = vals[i]['link']
			if link%6 < 3: half = 'TOP'
			else: half = 'BOTTOM'
			mapping[injectionCardSlot] = {'link' : link,
						      'id'   : linkMap[link],
						      'half' : half,
						      'connector' : int(histNum/12)
						      }
			print int(histNum/12), injectionCardSlot
			simpleCardMap[int(histNum/12)] = injectionCardSlotMapping[injectionCardSlot]

			
#	print_links(ts)

	return mapping, simpleCardMap