Example #1
0
def read_ConfigurationFromSimulationCandles(path, step, is_pileup):
    # Here we parse SimulationCandles_<version: e.g. CMSSW_3_2_0>.txt which contains
    # release:TODO, release_base [path] - we can put it to release [but it's of different granularity]
    # how to reproduce stuff: TODO

    try:
        """ get the acual file """
        SimulationCandles_file = [
            os.path.join(path, f) for f in os.listdir(path)
            if os.path.isfile(os.path.join(path, f))
            and f.startswith("SimulationCandles_")
        ][0]
    except IndexError:
        return None
    """ read and parse it;  format: #Version     : CMSSW_3_2_0 """
    f = open(SimulationCandles_file, 'r')

    lines = [s.strip() for s in f.readlines()]
    f.close()
    """ we call a shared helper to parse the file """

    for line in lines:
        #print line
        #print simCandlesRules[2][1].match(line) and simCandlesRules[2][1].match(line).groups() or ""

        info, missing_fields = parsingRulesHelper.rulesParser(
            simCandlesRules, [line], compileRules=False)
        #print info
        #Massaging the info dictionary conditions entry to allow for new cmsDriver.py --conditions option:
        if 'auto:' in info['conditions']:
            from Configuration.AlCa.autoCond import autoCond
            info['conditions'] = autoCond[info['conditions'].split(':')
                                          [1]].split("::")[0]
        else:
            if 'FrontierConditions_GlobalTag' in info['conditions']:
                info['conditions'] = info['conditions'].split(",")[1]
        #print (info, missing_fields)
        #if we successfully parsed the line of simulation candles:
        if not missing_fields:
            #we have to match only step and
            if info["step"].strip() == step.strip() and (
                (not is_pileup and not info["pileup_type"]) or
                (is_pileup and info["pileup_type"])):
                # if it's pile up or not:
                #print "Info for <<%s, %s>>: %s" % (str(step), str(is_pileup), str(info))
                return info
	def _applyParsingRules(self, parsing_rules, lines):
		""" 
			Applies the (provided) regular expression rules (=rule[1] for rule in parsing_rules)
			to each line and if it matches the line,
			puts the mached information to the dictionary as the specified keys (=rule[0]) which is later returned
			Rule[3] contains whether the field is required to be found. If so and it isn't found the exception would be raised.
			rules = [
			  ( (field_name_1_to_match, field_name_2), regular expression, /optionaly: is the field required? if so "req"/ )
			]
		 """
		""" we call a shared parsing helper """
		#parsing_rules = map(parsingRulesHelper.rulesRegexpCompileFunction, parsing_rules)
		#print parsing_rules
		(info, missing_fields) = parsingRulesHelper.rulesParser(parsing_rules, lines, compileRules = True)

		self.missing_fields.extend(missing_fields)

		return info
Example #3
0
	def _applyParsingRules(self, parsing_rules, lines):
		""" 
			Applies the (provided) regular expression rules (=rule[1] for rule in parsing_rules)
			to each line and if it matches the line,
			puts the mached information to the dictionary as the specified keys (=rule[0]) which is later returned
			Rule[3] contains whether the field is required to be found. If so and it isn't found the exception would be raised.
			rules = [
			  ( (field_name_1_to_match, field_name_2), regular expression, /optionaly: is the field required? if so "req"/ )
			]
		 """
		""" we call a shared parsing helper """
		#parsing_rules = map(parsingRulesHelper.rulesRegexpCompileFunction, parsing_rules)
		#print parsing_rules
		(info, missing_fields) = parsingRulesHelper.rulesParser(parsing_rules, lines, compileRules = True)

		self.missing_fields.extend(missing_fields)

		return info
Example #4
0
def read_ConfigurationFromSimulationCandles(path, step, is_pileup):
	# Here we parse SimulationCandles_<version: e.g. CMSSW_3_2_0>.txt which contains
	# release:TODO, release_base [path] - we can put it to release [but it's of different granularity]
	# how to reproduce stuff: TODO

	try:
		""" get the acual file """
		SimulationCandles_file = [os.path.join(path, f) for f in os.listdir(path)
					 if os.path.isfile(os.path.join(path, f)) and f.startswith("SimulationCandles_")][0]
	except IndexError:
		return None

	""" read and parse it;  format: #Version     : CMSSW_3_2_0 """
	f = open(SimulationCandles_file, 'r')	

	lines =  [s.strip() for s in f.readlines()]
	f.close()



	""" we call a shared helper to parse the file """

	for line in lines:
		#print line
		#print simCandlesRules[2][1].match(line) and simCandlesRules[2][1].match(line).groups() or ""

		info, missing_fields = parsingRulesHelper.rulesParser(simCandlesRules, [line], compileRules = False)
		#print info
		#Massaging the info dictionary conditions entry to allow for new cmsDriver.py --conditions option:
		if 'auto:' in info['conditions']:
			from Configuration.AlCa.autoCond import autoCond
			info['conditions'] = autoCond[ info['conditions'].split(':')[1] ].split("::")[0] 
		else:
			if 'FrontierConditions_GlobalTag' in info['conditions']:
				info['conditions']=info['conditions'].split(",")[1]
		#print (info, missing_fields)
		#if we successfully parsed the line of simulation candles:
		if not missing_fields:
			#we have to match only step and 
			if info["step"].strip() == step.strip() and ((not is_pileup and not info["pileup_type"]) or (is_pileup and info["pileup_type"])):
				# if it's pile up or not:
				#print "Info for <<%s, %s>>: %s" % (str(step), str(is_pileup), str(info))
				return info