CMS 3D CMS Logo

MTS.py
Go to the documentation of this file.
1 import copy
2 import os
3 
4 def MTS(config, validationDir):
5 
6  jobs = []
7  mtsType = "single"
8 
9 
10  IOVs = {}
11 
12 
13  isDataMerged = {}
14 
15 
16  if not mtsType in config["validations"]["MTS"]:
17  raise Exception("No 'single' key word in config for MTS")
18 
19  for singleName in config["validations"]["MTS"][mtsType]:
20  aux_IOV = config["validations"]["MTS"][mtsType][singleName]["IOV"]
21  if not isinstance(aux_IOV, list) and aux_IOV.endswith(".txt"):
22  config["validations"]["MTS"][mtsType][singleName]["IOV"] = []
23  with open(aux_IOV, 'r') as IOVfile: for line in IOVfile.readlines():
24  if len(line) != 0: config["validations"]["MTS"][mtsType][singleName]["IOV"].append(int(line))
25  for IOV in config["validations"]["MTS"][mtsType][singleName]["IOV"]:
26 
27  if singleName not in IOVs.keys():
28  IOVs[singleName] = []
29  if IOV not in IOVs[singleName]:
30  IOVs[singleName].append(IOV)
31 
32  for alignment in config["validations"]["MTS"][mtsType][singleName]["alignments"]:
33 
34  workDir = "{}/MTS/{}/{}/{}/{}".format(validationDir, mtsType, singleName, alignment, IOV)
35 
36 
37  local = {}
38  local["output"] = "{}/{}/MTS/{}/{}/{}/{}".format(config["LFS"], config["name"], mtsType, alignment, singleName, IOV)
39  local["alignment"] = copy.deepcopy(config["alignments"][alignment])
40  local["alignment"]["name"] = alignment
41  local["validation"] = copy.deepcopy(config["validations"]["MTS"][mtsType][singleName])
42  local["validation"].pop("alignments")
43  local["validation"]["IOV"] = IOV
44  if "dataset" in local["validation"]:
45  local["validation"]["dataset"] = local["validation"]["dataset"].format(IOV)
46  if "goodlumi" in local["validation"]:
47  local["validation"]["goodlumi"] = local["validation"]["goodlumi"].format(IOV)
48 
49 
50  job = {
51  "name": "MTS_{}_{}_{}_{}".format(mtsType, alignment, singleName, IOV),
52  "dir": workDir,
53  "exe": "cmsRun",
54  "cms-config": "{}/src/Alignment/OfflineValidation/python/TkAlAllInOneTool/MTS_cfg.py".format(os.environ["CMSSW_BASE"]),
55  "run-mode": "Condor",
56  "dependencies": [],
57  "config": local,
58  }
59 
60  jobs.append(job)
61 
62 
63  if "merge" in config["validations"]["MTS"]:
64 
65  mergeJobs = []
66  pvType = "merge"
67 
68 
69  for mergeName in config["validations"]["MTS"][pvType]:
70 
71  for iname,singleName in enumerate(config["validations"]["MTS"][pvType][mergeName]['singles']):
72  for IOV in IOVs[singleName]:
73 
74 
75  workDir = "{}/MTS/{}/{}/{}".format(validationDir, pvType, mergeName, IOV) #Different (DATA) single jobs must contain different set of IOVs
76 
77 
78  local = {}
79 
80  job = {
81  "name": "MTS_{}_{}_{}".format(pvType, mergeName, IOV),
82  "dir": workDir,
83  "exe": "MTSmerge",
84  "run-mode": "Condor",
85  "dependencies": [],
86  "config": local,
87  }
88 
89 
90  for alignment in config["alignments"]:
91  local.setdefault("alignments", {})
92  if alignment in config["validations"]["MTS"]["single"][singleName]["alignments"]: #Cover all DATA validations
93  local["alignments"][alignment] = copy.deepcopy(config["alignments"][alignment])
94  local["alignments"][alignment]['index'] = config["validations"]["MTS"]["single"][singleName]["alignments"].index(alignment)
95  local["alignments"][alignment]['isMC'] = False
96  local["validation"] = copy.deepcopy(config["validations"]["MTS"][pvType][mergeName])
97  local["validation"]["IOV"] = IOV
98  if "customrighttitle" in local["validation"].keys():
99  if "IOV" in local["validation"]["customrighttitle"]:
100  local["validation"]["customrighttitle"] = local["validation"]["customrighttitle"].replace("IOV",str(IOV))
101  local["output"] = "{}/{}/MTS/{}/{}/{}".format(config["LFS"], config["name"], pvType, mergeName, IOV)
102 
103 
104  if "style" in config.keys():
105  if "MTS" in config['style'].keys():
106  if pvType in config['style']['MTS'].keys():
107  local["style"] = copy.deepcopy(config["style"]["MTS"][pvType])
108  if "Rlabel" in local["style"] and "customrighttitle" in local["validation"].keys():
109  print("WARNING: custom right label is overwritten by global settings")
110 
111 
112  for singleJob in jobs:
113 
114  _alignment, _singleName, _singleIOV = singleJob["name"].split("_")[2:]
115  if _singleName in config["validations"]["MTS"][pvType][mergeName]["singles"]:
116  if (int(_singleIOV) == IOV): #matching DATA job or any MC single job
117  local["alignments"][_alignment]["file"] = singleJob["config"]["output"]
118  job["dependencies"].append(singleJob["name"])
119 
120  mergeJobs.append(job)
121 
122  jobs.extend(mergeJobs)
123 
124  return jobs
125 
def replace(string, replacements)
def MTS(config, validationDir)
Definition: MTS.py:4
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
#define str(s)