3 from helperFunctions
import replaceByMap
4 from TkAlExceptions
import AllInOneError
7 def __init__(self, name, config, runGeomComp = "1"):
9 "TrackerAlignmentErrorExtendedRcd":
10 {
"zeroAPE":{
"connectString": (
"frontier://FrontierProd"
11 "/CMS_COND_31X_FROM21X"),
12 "tagName":
"TrackerIdealGeometryErrors210_mc",
14 section =
"alignment:%s"%name
15 if not config.has_section( section ):
16 raise AllInOneError, (
"section %s not found. Please define the "
18 config.checkInput(section,
19 knownSimpleOptions = [
'globaltag',
'style',
'color',
'title'],
20 knownKeywords = [
'condition'])
22 if config.exists(section,
"title"):
23 self.
title = config.get(section,
"title")
27 msg =
"The characters '|', '\"', and ',' cannot be used in the alignment title!"
32 self.
color = config.get(section,
"color")
33 self.
style = config.get(section,
"style")
37 """Method which checks, if `theShorthand` is a valid shorthand for the
41 - `theRcdName`: String which specifies the database record.
42 - `theShorthand`: String which specifies the shorthand to check.
54 for option
in theConfig.options( theSection ):
55 if option.startswith(
"condition " ):
56 rcdName = option.split(
"condition " )[1]
57 condPars = theConfig.get( theSection, option ).
split(
"," )
58 if len(condPars) == 1:
59 if len(condPars[0])==0:
60 msg = (
"In section [%s]: '%s' is used with too few "
61 "arguments. A connect_string and a tag are "
62 "required!"%(theSection, option))
65 shorthand = condPars[0]
67 self.
condShorts[rcdName][shorthand][
"connectString"],
68 self.
condShorts[rcdName][shorthand][
"tagName"],
69 self.
condShorts[rcdName][shorthand][
"labelName"]]
71 msg = (
"In section [%s]: '%s' is used with '%s', "
72 "which is an unknown shorthand for '%s'. Either "
73 "provide at least a connect_string and a tag or "
74 "use a known shorthand.\n"
75 %(theSection, option, condPars[0], rcdName))
77 msg +=
"Known shorthands for '%s':\n"%(rcdName)
79 knownShorts = [(
"\t"+key+
": "
80 +theShorts[key][
"connectString"]+
","
81 +theShorts[key][
"tagName"]+
","
82 +theShorts[key][
"labelName"]) \
84 msg+=
"\n".
join(knownShorts)
86 msg += (
"There are no known shorthands for '%s'."
89 if len( condPars ) == 2:
92 msg = (
"In section [%s]: '%s' is used with too many "
93 "arguments. A maximum of 3 arguments is allowed."
94 %(theSection, option))
96 conditions.append({
"rcdName": rcdName.strip(),
97 "connectString": condPars[0].strip(),
98 "tagName": condPars[1].strip(),
99 "labelName": condPars[2].strip()})
105 if not dbpath.startswith(
"sqlite_file:"):
106 print "WARNING: could not check existence for",dbpath
108 if not os.path.exists( dbpath.split(
"sqlite_file:")[1] ):
109 raise "could not find file: '%s'"%dbpath.split(
"sqlite_file:")[1]
113 if not restriction ==
None:
114 for mode
in self.
mode:
115 if mode
in restriction:
116 result.append( mode )
131 """This function creates the configuration snippet to override
132 global tag conditions.
135 loadCond = (
"\nimport CalibTracker.Configuration."
136 "Common.PoolDBESSource_cfi\n")
138 if not cond[
"labelName"] ==
"":
139 temp = configTemplates.conditionsTemplate.replace(
140 "tag = cms.string('.oO[tagName]Oo.')",
141 (
"tag = cms.string('.oO[tagName]Oo.'),"
142 "\nlabel = cms.untracked.string('.oO[labelName]Oo.')"))
144 temp = configTemplates.conditionsTemplate
static std::string join(char **cmd)
def replaceByMap
— Helpers —############################