2 from helperFunctions
import replaceByMap, parsecolor, parsestyle
4 from TkAlExceptions
import AllInOneError
7 def __init__(self, name, config, runGeomComp = "1"):
9 "TrackerAlignmentErrorExtendedRcd": {
11 "connectString":(
"frontier://FrontierProd"
13 "tagName":
"TrackerIdealGeometryErrorsExtended210_mc",
17 "TrackerSurfaceDeformationRcd": {
19 "connectString":(
"frontier://FrontierProd"
21 "tagName":
"TrackerSurfaceDeformations_zero",
26 section =
"alignment:%s"%name
27 if not config.has_section( section ):
28 raise AllInOneError(
"section %s not found. Please define the "
30 config.checkInput(section,
31 knownSimpleOptions = [
'globaltag',
'style',
'color',
'title'],
32 knownKeywords = [
'condition'])
34 if config.exists(section,
"title"):
35 self.
title = config.get(section,
"title")
38 if (int(runGeomComp) != 1):
39 self.
name +=
"_run" + runGeomComp
40 self.
title +=
" run " + runGeomComp
42 msg =
"The characters '|', '\"', and ',' cannot be used in the alignment title!"
48 self.
color = config.get(section,
"color")
49 self.
style = config.get(section,
"style")
55 """Method which checks, if `theShorthand` is a valid shorthand for the
59 - `theRcdName`: String which specifies the database record.
60 - `theShorthand`: String which specifies the shorthand to check.
72 for option
in theConfig.options( theSection ):
73 if option.startswith(
"condition " ):
74 rcdName = option.split(
"condition " )[1]
75 condPars = theConfig.get( theSection, option ).
split(
"," )
76 if len(condPars) == 1:
77 if len(condPars[0])==0:
78 msg = (
"In section [%s]: '%s' is used with too few "
79 "arguments. A connect_string and a tag are "
80 "required!"%(theSection, option))
83 shorthand = condPars[0]
85 self.
condShorts[rcdName][shorthand][
"connectString"],
86 self.
condShorts[rcdName][shorthand][
"tagName"],
87 self.
condShorts[rcdName][shorthand][
"labelName"]]
89 msg = (
"In section [%s]: '%s' is used with '%s', "
90 "which is an unknown shorthand for '%s'. Either "
91 "provide at least a connect_string and a tag or "
92 "use a known shorthand.\n"
93 %(theSection, option, condPars[0], rcdName))
95 msg +=
"Known shorthands for '%s':\n"%(rcdName)
97 knownShorts = [(
"\t"+key+
": "
98 +theShorts[key][
"connectString"]+
","
99 +theShorts[key][
"tagName"]+
","
100 +theShorts[key][
"labelName"]) \
101 for key
in theShorts]
102 msg+=
"\n".
join(knownShorts)
104 msg += (
"There are no known shorthands for '%s'."
107 if len( condPars ) == 2:
108 condPars.append(
"" )
109 if len(condPars) > 3:
110 msg = (
"In section [%s]: '%s' is used with too many "
111 "arguments. A maximum of 3 arguments is allowed."
112 %(theSection, option))
114 conditions.append({
"rcdName": rcdName.strip(),
115 "connectString": condPars[0].strip(),
116 "tagName": condPars[1].strip(),
117 "labelName": condPars[2].strip()})
123 if not dbpath.startswith(
"sqlite_file:"):
124 print "WARNING: could not check existence for",dbpath
126 if not os.path.exists( dbpath.split(
"sqlite_file:")[1] ):
127 raise "could not find file: '%s'"%dbpath.split(
"sqlite_file:")[1]
131 if not restriction ==
None:
132 for mode
in self.
mode:
133 if mode
in restriction:
134 result.append( mode )
149 """This function creates the configuration snippet to override
150 global tag conditions.
153 loadCond = (
"\nimport CalibTracker.Configuration."
154 "Common.PoolDBESSource_cfi\n")
156 if not cond[
"labelName"] ==
"":
157 temp = configTemplates.conditionsTemplate.replace(
158 "tag = cms.string('.oO[tagName]Oo.')",
159 (
"tag = cms.string('.oO[tagName]Oo.'),"
160 "\nlabel = cms.untracked.string('.oO[labelName]Oo.')"))
162 temp = configTemplates.conditionsTemplate
static std::string join(char **cmd)
def replaceByMap
— Helpers —############################