3 from helperFunctions
import replaceByMap
4 from TkAlExceptions
import AllInOneError
7 def __init__(self, name, config, runGeomComp = "1"):
9 "TrackerAlignmentErrorRcd":
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'],
20 knownKeywords = [
'condition'])
25 self.
color = config.get(section,
"color")
26 self.
style = config.get(section,
"style")
30 """Method which checks, if `theShorthand` is a valid shorthand for the
34 - `theRcdName`: String which specifies the database record.
35 - `theShorthand`: String which specifies the shorthand to check.
47 for option
in theConfig.options( theSection ):
48 if option.startswith(
"condition " ):
49 rcdName = option.split(
"condition " )[1]
50 condPars = theConfig.get( theSection, option ).
split(
"," )
51 if len(condPars) == 1:
52 if len(condPars[0])==0:
53 msg = (
"In section [%s]: '%s' is used with too few "
54 "arguments. A connect_string and a tag are "
55 "required!"%(theSection, option))
58 shorthand = condPars[0]
60 self.
condShorts[rcdName][shorthand][
"connectString"],
61 self.
condShorts[rcdName][shorthand][
"tagName"],
62 self.
condShorts[rcdName][shorthand][
"labelName"]]
64 msg = (
"In section [%s]: '%s' is used with '%s', "
65 "which is an unknown shorthand for '%s'. Either "
66 "provide at least a connect_string and a tag or "
67 "use a known shorthand.\n"
68 %(theSection, option, condPars[0], rcdName))
70 msg +=
"Known shorthands for '%s':\n"%(rcdName)
72 knownShorts = [(
"\t"+key+
": "
73 +theShorts[key][
"connectString"]+
","
74 +theShorts[key][
"tagName"]+
","
75 +theShorts[key][
"labelName"]) \
77 msg+=
"\n".
join(knownShorts)
79 msg += (
"There are no known shorthands for '%s'."
82 if len( condPars ) == 2:
85 msg = (
"In section [%s]: '%s' is used with too many "
86 "arguments. A maximum of 3 arguments is allowed."
87 %(theSection, option))
89 conditions.append({
"rcdName": rcdName.strip(),
90 "connectString": condPars[0].
strip(),
91 "tagName": condPars[1].
strip(),
92 "labelName": condPars[2].
strip()})
98 if not dbpath.startswith(
"sqlite_file:"):
99 print "WARNING: could not check existence for",dbpath
101 if not os.path.exists( dbpath.split(
"sqlite_file:")[1] ):
102 raise "could not find file: '%s'"%dbpath.split(
"sqlite_file:")[1]
106 if not restriction ==
None:
107 for mode
in self.
mode:
108 if mode
in restriction:
109 result.append( mode )
123 """This function creates the configuration snippet to override
124 global tag conditions.
127 loadCond = (
"\nimport CalibTracker.Configuration."
128 "Common.PoolDBESSource_cfi\n")
130 if not cond[
"labelName"] ==
"":
131 temp = configTemplates.conditionsTemplate.replace(
132 "tag = cms.string('.oO[tagName]Oo.')",
133 (
"tag = cms.string('.oO[tagName]Oo.'),"
134 "\nlabel = cms.untracked.string('.oO[labelName]Oo.')"))
136 temp = configTemplates.conditionsTemplate
static std::string join(char **cmd)
def replaceByMap
— Helpers —############################