5 def PV(config, validationDir):
7 jobs, singleJobs = [], []
17 if not pvType
in config[
"validations"][
"PV"]:
18 raise Exception(
"No 'single' key word in config for PV")
20 for singleName
in config[
"validations"][
"PV"][pvType]:
22 aux_IOV = config[
"validations"][
"PV"][pvType][singleName][
"IOV"]
23 if not isinstance(aux_IOV, list)
and aux_IOV.endswith(
".txt"):
24 config[
"validations"][
"PV"][pvType][singleName][
"IOV"] = []
25 with open(aux_IOV,
'r') as IOVfile: for line
in IOVfile.readlines():
26 if len(line) != 0: config[
"validations"][
"PV"][pvType][singleName][
"IOV"].
append(
int(line))
27 for IOV
in config[
"validations"][
"PV"][pvType][singleName][
"IOV"]:
29 if singleName
not in IOVs.keys():
31 if IOV
not in IOVs[singleName]:
32 IOVs[singleName].
append(IOV)
34 for alignment
in config[
"validations"][
"PV"][pvType][singleName][
"alignments"]:
36 workDir =
"{}/PV/{}/{}/{}/{}".
format(validationDir, pvType, singleName, alignment, IOV)
40 local[
"output"] =
"{}/{}/PV/{}/{}/{}/{}".
format(config[
"LFS"], config[
"name"], pvType, alignment, singleName, IOV)
41 local[
"alignment"] = copy.deepcopy(config[
"alignments"][alignment])
42 local[
"alignment"][
"name"] = alignment
43 local[
"validation"] = copy.deepcopy(config[
"validations"][
"PV"][pvType][singleName])
44 local[
"validation"].pop(
"alignments")
45 local[
"validation"][
"IOV"] = IOV
46 if "dataset" in local[
"validation"]:
47 local[
"validation"][
"dataset"] = local[
"validation"][
"dataset"].
format(IOV)
48 if "goodlumi" in local[
"validation"]:
49 local[
"validation"][
"goodlumi"] = local[
"validation"][
"goodlumi"].
format(IOV)
53 "name":
"PV_{}_{}_{}_{}".
format(pvType, alignment, singleName, IOV),
56 "cms-config":
"{}/src/Alignment/OfflineValidation/python/TkAlAllInOneTool/PV_cfg.py".
format(os.environ[
"CMSSW_BASE"]),
63 singleJobs.append(job)
65 jobs.extend(singleJobs)
68 if "merge" in config[
"validations"][
"PV"]:
74 for mergeName
in config[
"validations"][
"PV"][pvType]:
77 for singleName
in config[
"validations"][
"PV"][pvType][mergeName][
'singles']:
78 if len(IOVs[singleName]) == 1
and int(IOVs[singleName][0]) == 1: singlesMC.append(singleName)
79 isMConly = (len(singlesMC) == len(config[
"validations"][
"PV"][pvType][mergeName][
'singles']))
81 isDataMerged[mergeName] = 0
82 elif len(singlesMC) == 0:
83 isDataMerged[mergeName] = 1
85 isDataMerged[mergeName] = -1
88 for iname,singleName
in enumerate(config[
"validations"][
"PV"][pvType][mergeName][
'singles']):
89 isMC = (singleName
in singlesMC)
90 if isMConly
and iname > 0:
continue 91 elif isMConly: singlesMC.pop(singlesMC.index(singleName))
93 for IOV
in IOVs[singleName]:
94 if isMC
and not isMConly:
continue 98 workDir =
"{}/PV/{}/{}/{}".
format(validationDir, pvType, mergeName, IOV)
104 "name":
"PV_{}_{}_{}".
format(pvType, mergeName, IOV),
107 "run-mode":
"Condor",
113 for alignment
in config[
"alignments"]:
115 local.setdefault(
"alignments", {})
116 if alignment
in config[
"validations"][
"PV"][
"single"][singleName][
"alignments"]:
117 local[
"alignments"][alignment] = copy.deepcopy(config[
"alignments"][alignment])
118 local[
"alignments"][alignment][
'index'] = config[
"validations"][
"PV"][
"single"][singleName][
"alignments"].
index(alignment)
119 local[
"alignments"][alignment][
'isMC'] =
False 120 for singleMCname
in singlesMC:
121 if alignment
in config[
"validations"][
"PV"][
"single"][singleMCname][
"alignments"]:
122 local[
"alignments"][alignment] = copy.deepcopy(config[
"alignments"][alignment])
123 local[
"alignments"][alignment][
'index'] = len(config[
"validations"][
"PV"][
"single"][singleName][
"alignments"])
124 local[
"alignments"][alignment][
'index'] += idxIncrement + config[
"validations"][
"PV"][
"single"][singleMCname][
"alignments"].
index(alignment)
125 local[
"alignments"][alignment][
'isMC'] =
True 126 idxIncrement += len(config[
"validations"][
"PV"][
"single"][singleMCname][
"alignments"])
127 local[
"validation"] = copy.deepcopy(config[
"validations"][
"PV"][pvType][mergeName])
128 local[
"validation"][
"IOV"] = IOV
129 if "customrighttitle" in local[
"validation"].
keys():
130 if "IOV" in local[
"validation"][
"customrighttitle"]:
131 local[
"validation"][
"customrighttitle"] = local[
"validation"][
"customrighttitle"].
replace(
"IOV",
str(IOV))
132 local[
"output"] =
"{}/{}/PV/{}/{}/{}".
format(config[
"LFS"], config[
"name"], pvType, mergeName, IOV)
135 if "style" in config.keys():
136 if "PV" in config[
'style'].
keys():
137 if pvType
in config[
'style'][
'PV'].
keys():
138 local[
"style"] = copy.deepcopy(config[
"style"][
"PV"][pvType])
139 if "Rlabel" in local[
"style"]
and "customrighttitle" in local[
"validation"].
keys():
140 print(
"WARNING: custom right label is overwritten by global settings")
143 for singleJob
in jobs:
145 _alignment, _singleName, _singleIOV = singleJob[
"name"].
split(
"_")[2:]
146 if _singleName
in config[
"validations"][
"PV"][pvType][mergeName][
"singles"]:
147 if int(_singleIOV) == IOV
or (
int(_singleIOV) == 1
and _singleName
in singlesMC):
148 local[
"alignments"][_alignment][
"file"] = singleJob[
"config"][
"output"]
149 job[
"dependencies"].
append(singleJob[
"name"])
151 mergeJobs.append(job)
153 jobs.extend(mergeJobs)
155 if "trends" in config[
"validations"][
"PV"]:
161 for trendName
in config[
"validations"][
"PV"][pvType]:
165 workDir =
"{}/PV/{}/{}".
format(validationDir, pvType, trendName)
171 "name":
"PV_{}_{}".
format(pvType, trendName),
174 "run-mode":
"Condor",
180 if 'merges' in config[
"validations"][
"PV"][pvType][trendName].
keys()\
181 or 'singles' not in config[
"validations"][
"PV"][pvType][trendName].
keys():
182 raise Exception(
"Specify list of \'singles\' to run PV trends.")
186 for iname, singleName
in enumerate(config[
"validations"][
"PV"][pvType][trendName][
"singles"]):
187 isMC = (len(IOVs[singleName]) == 1
and int(IOVs[singleName][0]) == 1)
189 raise Exception(
"Trend jobs are not implemented for treating MC.")
191 trendIOVs = IOVs[singleName]
193 for IOV
in IOVs[singleName]:
194 if IOV
not in trendIOVs
or (len(IOVs[singleName]) != len(trendIOVs)):
195 raise Exception(
"List of IOVs must be the same for each single job.")
196 for alignment
in config[
"validations"][
"PV"][
"single"][singleName][
"alignments"]:
197 if alignment
not in alignmentList
and alignment
in config[
"alignments"]:
198 local.setdefault(
"alignments", {})
199 alignmentList.append(alignment)
200 local[
"alignments"][alignment] = copy.deepcopy(config[
"alignments"][alignment])
201 local[
"alignments"][alignment][
"file"] =
"{}/{}/PV/{}/{}/{}/{}".
format(config[
"LFS"], config[
"name"],
"single", alignment, singleName,
"{}")
203 local[
"validation"] = copy.deepcopy(config[
"validations"][
"PV"][pvType][trendName])
204 local[
"validation"][
"IOV"] = trendIOVs
205 if "label" in config[
"validations"][
"PV"][pvType][trendName]:
206 local[
"validation"][
"label"] = copy.deepcopy(config[
"validations"][
"PV"][pvType][trendName][
"label"])
207 local[
"output"] =
"{}/{}/PV/{}/{}/".
format(config[
"LFS"], config[
"name"], pvType, trendName)
208 if "style" in config.keys()
and "trends" in config[
"style"].
keys():
209 local[
"style"] = copy.deepcopy(config[
"style"])
210 if "PV" in local[
"style"].
keys(): local[
"style"].pop(
"PV")
211 if "CMSlabel" in config[
"style"][
"trends"].
keys(): local[
"style"][
"CMSlabel"] = config[
"style"][
"trends"][
"CMSlabel"]
212 if "Rlabel" in config[
"style"][
"trends"].
keys():
213 local[
"style"][
"trends"].pop(
"Rlabel")
214 local[
"style"][
"trends"][
"TitleCanvas"] = config[
"style"][
"trends"][
"Rlabel"]
216 raise Exception(
"You want to create 'trends' jobs, but there are no 'lines' section in the config for pixel updates!")
219 for singleJob
in singleJobs:
221 alignment, singleName, singleIOV = singleJob[
"name"].
split(
"_")[2:]
223 if singleName
in config[
"validations"][
"PV"][pvType][trendName][
"singles"]\
224 and int(singleIOV)
in trendIOVs:
225 job[
"dependencies"].
append(singleJob[
"name"])
227 trendJobs.append(job)
229 jobs.extend(trendJobs)
232 def replace(string, replacements)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def split(sequence, size)
def PV(config, validationDir)