2 from helperFunctions
import replaceByMap
5 from TkAlExceptions
import AllInOneError
8 def __init__(self, name, config, runGeomComp = "1"):
10 "TrackerAlignmentErrorExtendedRcd": {
12 "connectString":(
"frontier://FrontierProd"
14 "tagName":
"TrackerIdealGeometryErrorsExtended210_mc",
18 "TrackerSurfaceDeformationRcd": {
20 "connectString":(
"frontier://FrontierProd"
22 "tagName":
"TrackerSurfaceDeformations_zero",
27 section =
"alignment:%s"%name
28 if not config.has_section( section ):
29 raise AllInOneError, (
"section %s not found. Please define the "
31 config.checkInput(section,
32 knownSimpleOptions = [
'globaltag',
'style',
'color',
'title'],
33 knownKeywords = [
'condition'])
35 if config.exists(section,
"title"):
36 self.
title = config.get(section,
"title")
39 if (int(runGeomComp) != 1):
40 self.
name +=
"_run" + runGeomComp
41 self.
title +=
" run " + runGeomComp
43 msg =
"The characters '|', '\"', and ',' cannot be used in the alignment title!"
49 self.
color = config.get(section,
"color")
50 self.
style = config.get(section,
"style")
57 except (AttributeError, ValueError):
58 raise ValueError(
"color has to be an integer or a ROOT constant (kRed, kBlue, ...)!")
62 raise ValueError(
"style has to be an integer!")
65 """Method which checks, if `theShorthand` is a valid shorthand for the
69 - `theRcdName`: String which specifies the database record.
70 - `theShorthand`: String which specifies the shorthand to check.
82 for option
in theConfig.options( theSection ):
83 if option.startswith(
"condition " ):
84 rcdName = option.split(
"condition " )[1]
85 condPars = theConfig.get( theSection, option ).
split(
"," )
86 if len(condPars) == 1:
87 if len(condPars[0])==0:
88 msg = (
"In section [%s]: '%s' is used with too few "
89 "arguments. A connect_string and a tag are "
90 "required!"%(theSection, option))
93 shorthand = condPars[0]
95 self.
condShorts[rcdName][shorthand][
"connectString"],
96 self.
condShorts[rcdName][shorthand][
"tagName"],
97 self.
condShorts[rcdName][shorthand][
"labelName"]]
99 msg = (
"In section [%s]: '%s' is used with '%s', "
100 "which is an unknown shorthand for '%s'. Either "
101 "provide at least a connect_string and a tag or "
102 "use a known shorthand.\n"
103 %(theSection, option, condPars[0], rcdName))
105 msg +=
"Known shorthands for '%s':\n"%(rcdName)
107 knownShorts = [(
"\t"+key+
": "
108 +theShorts[key][
"connectString"]+
","
109 +theShorts[key][
"tagName"]+
","
110 +theShorts[key][
"labelName"]) \
111 for key
in theShorts]
112 msg+=
"\n".
join(knownShorts)
114 msg += (
"There are no known shorthands for '%s'."
117 if len( condPars ) == 2:
118 condPars.append(
"" )
119 if len(condPars) > 3:
120 msg = (
"In section [%s]: '%s' is used with too many "
121 "arguments. A maximum of 3 arguments is allowed."
122 %(theSection, option))
124 conditions.append({
"rcdName": rcdName.strip(),
125 "connectString": condPars[0].strip(),
126 "tagName": condPars[1].strip(),
127 "labelName": condPars[2].strip()})
133 if not dbpath.startswith(
"sqlite_file:"):
134 print "WARNING: could not check existence for",dbpath
136 if not os.path.exists( dbpath.split(
"sqlite_file:")[1] ):
137 raise "could not find file: '%s'"%dbpath.split(
"sqlite_file:")[1]
141 if not restriction ==
None:
142 for mode
in self.
mode:
143 if mode
in restriction:
144 result.append( mode )
159 """This function creates the configuration snippet to override
160 global tag conditions.
163 loadCond = (
"\nimport CalibTracker.Configuration."
164 "Common.PoolDBESSource_cfi\n")
166 if not cond[
"labelName"] ==
"":
167 temp = configTemplates.conditionsTemplate.replace(
168 "tag = cms.string('.oO[tagName]Oo.')",
169 (
"tag = cms.string('.oO[tagName]Oo.'),"
170 "\nlabel = cms.untracked.string('.oO[labelName]Oo.')"))
172 temp = configTemplates.conditionsTemplate
static std::string join(char **cmd)
def replaceByMap
— Helpers —############################