示例#1
0
def getWaveDescThresFromWaveList(waveListFileName, waveDescriptions):
    printInfo("reading amplitude names and thresholds from wave list file " +
              "'" + waveListFileName + "'.")
    waveDescThres = []
    with open(waveListFileName, 'r') as waveListFile:
        lineNmb = 0
        for line in waveListFile:
            line = line.strip()
            if line[0] == '#':  # comments start with #
                continue
            lineArray = line.split(" ")
            if len(lineArray) in [1, 2]:
                waveName = lineArray[0]
                if len(lineArray) == 1:
                    threshold = 0
                else:
                    threshold = lineArray[1]
                waveDesc = waveDescriptions[waveName]
                waveDescThres.append((waveName, waveDesc, float(threshold)))
            else:
                printWarn("cannot parse line '" + line +
                          "' in wave list file " + "'" + waveListFileName +
                          "'.")
            lineNmb += 1
        printInfo("read " + str(lineNmb) + " lines from wave list file " +
                  "'" + waveListFileName + "'")
    return waveDescThres
示例#2
0
def getWaveDescThresFromWaveList(waveListFileName, keyFiles):
	printInfo("reading amplitude names and thresholds from wave list file "
	          + "'" + waveListFileName + "'.")
	waveDescThres = []
	with open(waveListFileName, 'r') as waveListFile:
		lineNmb = 0
		for line in waveListFile:
			if line[0] == '#':  # comments start with #
				continue
			line = line.replace('\n', '')
			lineArray = line.split(" ")
			if len(lineArray) in [1, 2]:
				waveName = lineArray[0]
				if len(lineArray) == 1:
					threshold = 0
				else:
					threshold = lineArray[1]
				waveDesc = pyRootPwa.core.waveDescription.parseKeyFile(keyFiles[waveName][0])[keyFiles[waveName][1]]
				waveDescThres.append( (waveName, waveDesc, float(threshold)) )
			else:
				printWarn("cannot parse line '" + line + "' in wave list file "
				          + "'" + waveListFileName + "'.")
			lineNmb += 1
		printInfo("read " + str(lineNmb) + " lines from wave list file " + "'" + waveListFileName + "'")
	return waveDescThres
def binningMapFromArgList(argList):
	binningMap = {}
	if argList:
		for binArg in argList:
			try:
				splitUp = binArg.split(";")
				if len(splitUp)==3:
					binningMap[splitUp[0]] = (float(splitUp[1]), float(splitUp[2]))
					printInfo("adding to binning map: " + splitUp[0] + " -> (" + splitUp[1] + "," + splitUp[2] + ")")
				else:
					printErr("did not get the right amount of semicolon seperated values for " + splitUp[0] + "-bin.")
					return False
			except ValueError:
				printErr("could not convert binning map boundaries of " + splitUp[0] + "-bin to float. Aborting...")
				return False
	return binningMap
def multibinBoundariesFromArgList(argList):
	multibinBoundaries = {}
	if argList:
		for binArg in argList:
			try:
				splitUp = binArg.split(";")
				if len(splitUp)==3:
					multibinBoundaries[splitUp[0]] = (float(splitUp[1]), float(splitUp[2]))
					printInfo("adding to multibin boundaries: " + splitUp[0] + " -> (" + splitUp[1] + "," + splitUp[2] + ")")
				else:
					printErr("did not get the right amount of semicolon seperated values for " + splitUp[0] + "-bin.")
					return False
			except ValueError:
				printErr("could not convert multibin boundaries of " + splitUp[0] + "-bin to float. Aborting...")
				return False
	return multibinBoundaries