CMS 3D CMS Logo

Functions
Zmumu Namespace Reference

Functions

def Zmumu (config, validationDir)
 

Function Documentation

◆ Zmumu()

def Zmumu.Zmumu (   config,
  validationDir 
)

Definition at line 4 of file Zmumu.py.

References mps_setup.append, createfilelist.int, relativeConstraints.keys, print(), python.rootplot.root2matplotlib.replace(), submitPVValidationJobs.split(), and str.

4 def Zmumu(config, validationDir):
5 
6  jobs, singleJobs = [], []
7  zmumuType = "single"
8 
9 
10  IOVs = {}
11 
12 
13  isDataMerged = {}
14 
15 
16  if not zmumuType in config["validations"]["Zmumu"]:
17  raise Exception("No 'single' key word in config for Zmumu")
18 
19  for singleName in config["validations"]["Zmumu"][zmumuType]:
20  aux_IOV = config["validations"]["Zmumu"][zmumuType][singleName]["IOV"]
21  if not isinstance(aux_IOV, list) and aux_IOV.endswith(".txt"):
22  config["validations"]["Zmumu"][zmumuType][singleName]["IOV"] = []
23  with open(aux_IOV, 'r') as IOVfile: for line in IOVfile.readlines():
24  if len(line) != 0: config["validations"]["Zmumu"][zmumuType][singleName]["IOV"].append(int(line))
25  for IOV in config["validations"]["Zmumu"][zmumuType][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"]["Zmumu"][zmumuType][singleName]["alignments"]:
33 
34  workDir = "{}/Zmumu/{}/{}/{}/{}".format(validationDir, zmumuType, singleName, alignment, IOV)
35 
36 
37  local = {}
38  local["output"] = "{}/{}/Zmumu/{}/{}/{}/{}".format(config["LFS"], config["name"], zmumuType, alignment, singleName, IOV)
39  local["alignment"] = copy.deepcopy(config["alignments"][alignment])
40  local["alignment"]["name"] = alignment
41  local["validation"] = copy.deepcopy(config["validations"]["Zmumu"][zmumuType][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": "Zmumu_{}_{}_{}_{}".format(zmumuType, alignment, singleName, IOV),
52  "dir": workDir,
53  "exe": "cmsRun",
54  "cms-config": "{}/src/Alignment/OfflineValidation/python/TkAlAllInOneTool/Zmumu_cfg.py".format(os.environ["CMSSW_BASE"]),
55  "run-mode": "Condor",
56  "dependencies": [],
57  "config": local,
58  }
59 
60  singleJobs.append(job)
61 
62  jobs.extend(singleJobs)
63 
64 
65  if "merge" in config["validations"]["Zmumu"]:
66 
67  mergeJobs = []
68  zmumuType = "merge"
69 
70 
71  for mergeName in config["validations"]["Zmumu"][zmumuType]:
72 
73  singlesMC = []
74  for singleName in config["validations"]["Zmumu"][zmumuType][mergeName]['singles']:
75  if len(IOVs[singleName]) == 1 and int(IOVs[singleName][0]) == 1: singlesMC.append(singleName)
76  isMConly = (len(singlesMC) == len(config["validations"]["Zmumu"][zmumuType][mergeName]['singles']))
77  if isMConly:
78  isDataMerged[mergeName] = 0
79  elif len(singlesMC) == 0:
80  isDataMerged[mergeName] = 1
81  else:
82  isDataMerged[mergeName] = -1
83 
84 
85  for iname,singleName in enumerate(config["validations"]["Zmumu"][zmumuType][mergeName]['singles']):
86  isMC = (singleName in singlesMC)
87  if isMConly and iname > 0: continue #special case for MC only comparison
88  elif isMConly: singlesMC.pop(singlesMC.index(singleName))
89 
90  for IOV in IOVs[singleName]:
91 
92  workDir = "{}/Zmumu/{}/{}/{}".format(validationDir, zmumuType, mergeName, IOV)
93 
94 
95  local = {}
96 
97  job = {
98  "name": "Zmumu_{}_{}_{}".format(zmumuType, mergeName, IOV),
99  "dir": workDir,
100  "exe": "Zmumumerge",
101  "run-mode": "Condor",
102  "dependencies": [],
103  "config": local,
104  }
105 
106 
107  for alignment in config["alignments"]:
108  idxIncrement = 0
109  local.setdefault("alignments", {})
110  if alignment in config["validations"]["Zmumu"]["single"][singleName]["alignments"]: #Cover all DATA validations
111  local["alignments"][alignment] = copy.deepcopy(config["alignments"][alignment])
112  local["alignments"][alignment]['index'] = config["validations"]["Zmumu"]["single"][singleName]["alignments"].index(alignment)
113  local["alignments"][alignment]['isMC'] = False
114  for singleMCname in singlesMC:
115  if alignment in config["validations"]["Zmumu"]["single"][singleMCname]["alignments"]: #Add MC objects
116  local["alignments"][alignment] = copy.deepcopy(config["alignments"][alignment])
117  local["alignments"][alignment]['index'] = len(config["validations"]["Zmumu"]["single"][singleName]["alignments"])
118  local["alignments"][alignment]['index'] += idxIncrement + config["validations"]["Zmumu"]["single"][singleMCname]["alignments"].index(alignment)
119  local["alignments"][alignment]['isMC'] = True
120  idxIncrement += len(config["validations"]["Zmumu"]["single"][singleMCname]["alignments"])
121  local["validation"] = copy.deepcopy(config["validations"]["Zmumu"][zmumuType][mergeName])
122  local["validation"]["IOV"] = IOV
123  if "customrighttitle" in local["validation"].keys():
124  if "IOV" in local["validation"]["customrighttitle"]:
125  local["validation"]["customrighttitle"] = local["validation"]["customrighttitle"].replace("IOV",str(IOV))
126  local["output"] = "{}/{}/Zmumu/{}/{}/{}".format(config["LFS"], config["name"], zmumuType, mergeName, IOV)
127 
128 
129  if "style" in config.keys():
130  if "Zmumu" in config['style'].keys():
131  if zmumuType in config['style']['Zmumu'].keys():
132  local["style"] = copy.deepcopy(config["style"]["Zmumu"][zmumuType])
133  if "Rlabel" in local["style"] and "customrighttitle" in local["validation"].keys():
134  print("WARNING: custom right label is overwritten by global settings")
135 
136 
137  for singleJob in jobs:
138 
139  _alignment, _singleName, _singleIOV = singleJob["name"].split("_")[2:]
140  if _singleName in config["validations"]["Zmumu"][zmumuType][mergeName]["singles"]:
141  if int(_singleIOV) == IOV or (int(_singleIOV) == 1 and _singleName in singlesMC): #matching DATA job or any MC single job
142  local["alignments"][_alignment]["file"] = singleJob["config"]["output"]
143  job["dependencies"].append(singleJob["name"])
144 
145  mergeJobs.append(job)
146 
147  jobs.extend(mergeJobs)
148 
149  if "trends" in config["validations"]["Zmumu"]:
150  print("[WARNING] Zmumu trends are not implemented yet. Nothing to do here...")
151 
152  return jobs
153 
def replace(string, replacements)
def Zmumu(config, validationDir)
Definition: Zmumu.py:4
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
#define str(s)