3 from helperFunctions
import replaceByMap
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!"
47 self.
color = config.get(section,
"color")
48 self.
style = config.get(section,
"style")
52 """Method which checks, if `theShorthand` is a valid shorthand for the
56 - `theRcdName`: String which specifies the database record.
57 - `theShorthand`: String which specifies the shorthand to check.
69 for option
in theConfig.options( theSection ):
70 if option.startswith(
"condition " ):
71 rcdName = option.split(
"condition " )[1]
72 condPars = theConfig.get( theSection, option ).
split(
"," )
73 if len(condPars) == 1:
74 if len(condPars[0])==0:
75 msg = (
"In section [%s]: '%s' is used with too few "
76 "arguments. A connect_string and a tag are "
77 "required!"%(theSection, option))
80 shorthand = condPars[0]
82 self.
condShorts[rcdName][shorthand][
"connectString"],
83 self.
condShorts[rcdName][shorthand][
"tagName"],
84 self.
condShorts[rcdName][shorthand][
"labelName"]]
86 msg = (
"In section [%s]: '%s' is used with '%s', "
87 "which is an unknown shorthand for '%s'. Either "
88 "provide at least a connect_string and a tag or "
89 "use a known shorthand.\n"
90 %(theSection, option, condPars[0], rcdName))
92 msg +=
"Known shorthands for '%s':\n"%(rcdName)
94 knownShorts = [(
"\t"+key+
": "
95 +theShorts[key][
"connectString"]+
","
96 +theShorts[key][
"tagName"]+
","
97 +theShorts[key][
"labelName"]) \
99 msg+=
"\n".
join(knownShorts)
101 msg += (
"There are no known shorthands for '%s'."
104 if len( condPars ) == 2:
105 condPars.append(
"" )
106 if len(condPars) > 3:
107 msg = (
"In section [%s]: '%s' is used with too many "
108 "arguments. A maximum of 3 arguments is allowed."
109 %(theSection, option))
111 conditions.append({
"rcdName": rcdName.strip(),
112 "connectString": condPars[0].strip(),
113 "tagName": condPars[1].strip(),
114 "labelName": condPars[2].strip()})
120 if not dbpath.startswith(
"sqlite_file:"):
121 print "WARNING: could not check existence for",dbpath
123 if not os.path.exists( dbpath.split(
"sqlite_file:")[1] ):
124 raise "could not find file: '%s'"%dbpath.split(
"sqlite_file:")[1]
128 if not restriction ==
None:
129 for mode
in self.
mode:
130 if mode
in restriction:
131 result.append( mode )
146 """This function creates the configuration snippet to override
147 global tag conditions.
150 loadCond = (
"\nimport CalibTracker.Configuration."
151 "Common.PoolDBESSource_cfi\n")
153 if not cond[
"labelName"] ==
"":
154 temp = configTemplates.conditionsTemplate.replace(
155 "tag = cms.string('.oO[tagName]Oo.')",
156 (
"tag = cms.string('.oO[tagName]Oo.'),"
157 "\nlabel = cms.untracked.string('.oO[labelName]Oo.')"))
159 temp = configTemplates.conditionsTemplate
static std::string join(char **cmd)
def replaceByMap
— Helpers —############################