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["validation"] = copy.deepcopy(config["validations"]["MTS"][mtsType][singleName])
41  local["validation"].pop("alignments")
42  local["validation"]["IOV"] = IOV
43  if "dataset" in local["validation"]:
44  local["validation"]["dataset"] = local["validation"]["dataset"].format(IOV)
45  if "goodlumi" in local["validation"]:
46  local["validation"]["goodlumi"] = local["validation"]["goodlumi"].format(IOV)
47 
48 
49  job = {
50  "name": "MTS_{}_{}_{}_{}".format(mtsType, alignment, singleName, IOV),
51  "dir": workDir,
52  "exe": "cmsRun",
53  "cms-config": "{}/src/Alignment/OfflineValidation/python/TkAlAllInOneTool/MTS_cfg.py".format(os.environ["CMSSW_BASE"]),
54  "run-mode": "Condor",
55  "dependencies": [],
56  "config": local,
57  }
58 
59  jobs.append(job)
60 
61 
62  if "merge" in config["validations"]["MTS"]:
63 
64  mergeJobs = []
65  pvType = "merge"
66 
67 
68  for mergeName in config["validations"]["MTS"][pvType]:
69 
70  for iname,singleName in enumerate(config["validations"]["MTS"][pvType][mergeName]['singles']):
71  for IOV in IOVs[singleName]:
72 
73 
74  workDir = "{}/MTS/{}/{}/{}".format(validationDir, pvType, mergeName, IOV) #Different (DATA) single jobs must contain different set of IOVs
75 
76 
77  local = {}
78 
79  job = {
80  "name": "MTS_{}_{}_{}".format(pvType, mergeName, IOV),
81  "dir": workDir,
82  "exe": "MTSmerge",
83  "run-mode": "Condor",
84  "dependencies": [],
85  "config": local,
86  }
87 
88 
89  for alignment in config["alignments"]:
90  local.setdefault("alignments", {})
91  if alignment in config["validations"]["MTS"]["single"][singleName]["alignments"]: #Cover all DATA validations
92  local["alignments"][alignment] = copy.deepcopy(config["alignments"][alignment])
93  local["alignments"][alignment]['index'] = config["validations"]["MTS"]["single"][singleName]["alignments"].index(alignment)
94  local["alignments"][alignment]['isMC'] = False
95  local["validation"] = copy.deepcopy(config["validations"]["MTS"][pvType][mergeName])
96  local["validation"]["IOV"] = IOV
97  if "customrighttitle" in local["validation"].keys():
98  if "IOV" in local["validation"]["customrighttitle"]:
99  local["validation"]["customrighttitle"] = local["validation"]["customrighttitle"].replace("IOV",str(IOV))
100  local["output"] = "{}/{}/MTS/{}/{}/{}".format(config["LFS"], config["name"], pvType, mergeName, IOV)
101 
102 
103  if "style" in config.keys():
104  if "MTS" in config['style'].keys():
105  if pvType in config['style']['MTS'].keys():
106  local["style"] = copy.deepcopy(config["style"]["MTS"][pvType])
107  if "Rlabel" in local["style"] and "customrighttitle" in local["validation"].keys():
108  print("WARNING: custom right label is overwritten by global settings")
109 
110 
111  for singleJob in jobs:
112 
113  _alignment, _singleName, _singleIOV = singleJob["name"].split("_")[2:]
114  if _singleName in config["validations"]["MTS"][pvType][mergeName]["singles"]:
115  if (int(_singleIOV) == IOV): #matching DATA job or any MC single job
116  local["alignments"][_alignment]["file"] = singleJob["config"]["output"]
117  job["dependencies"].append(singleJob["name"])
118 
119  mergeJobs.append(job)
120 
121  jobs.extend(mergeJobs)
122 
123  return jobs
124 
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)