35affectedDSID = range(502198, 502354) + range(302266, 302291) + range(307731, 307748) + range(450765, 450774) + range(367515, 367671) + range(502198, 502354) + [309529, 312655, 412006]
52def hes(gen, dictionary, weight_dict):
53 hessian = dict((key, value)
for (key, value)
in dictionary.items()
if 'hessian' in key)
56 h = dict((key, value)
for (key, value)
in dictionary.items()
if '_0_hessian' in key)
58 key = key.replace(
'_0_hessian',
'')
59 pdf = next(re.finditer(
r'\d+$', hessian.keys()[0].
split(
'_')[0])).group(0)
61 weight_dict.update({gen +
'_ME_PDF' + pdf +
'_Hessian': {
'weights': sorted(hessian.values()),
'combination':
'lhapdf',
'type':
'PDF_ME',
'nominal': h.values()[0],
'nominal_pdf': pdf}})
62 dictionary = dict(
set(dictionary.items()) -
set(hessian.items()))
63 hess_dict.update({key: h.values()[0]})
64 dictionary.update(hess_dict)
65 return dictionary, weight_dict, hess_dict
68def nom(gen, dictionary, weight_dict):
69 nominal = dict((key, value)
for (key, value)
in dictionary.items()
if 'Nominal' in key)
72 n = nominal.values()[0].
strip()
74 n = nominal.values()[1].
strip()
78 p_var = str(int(pdf) % 100)
79 if any(str(int(pdf) - int(p_var)) == pdfset
for pdfset
in pdfsets):
80 p_nom = str(int(pdf) - int(p_var))
82 p_var = str(int(pdf) % 1000)
83 p_nom = str(int(pdf) - (int(p_var)))
85 weight_dict.update({gen +
'_ME_PDF' + p_nom +
'_var': {
'weights': sorted(nominal.values()),
'combination':
'lhapdf',
'type':
'PDF_ME',
'nominal': nominal.get(
'Nominal'),
'nominal_pdf': p_nom}})
87 weight_dict.update({gen +
'_ME_PDF' + p_nom: {
'weights': sorted(nominal.values()),
'combination':
'lhapdf',
'type':
'PDF_ME',
'nominal': nominal.get(
'Nominal'),
'nominal_pdf': p_nom}})
88 dictionary = dict(
set(dictionary.items()) -
set(nominal.items()))
89 return dictionary, weight_dict, p_nom
92def alph(gen, dictionary, weight_dict, nom_pdf, p_nom):
93 alpha = dict((key, value)
for (key, value)
in dictionary.items()
if key.endswith(
'_alphaS'))
97 for a
in alpha.keys():
98 pdf = next(re.finditer(
r'\d+$', a.split(
'_')[0])).group(0)
99 w.append(alpha_S.get(pdf))
100 k = a.replace(
'_alphaS',
'')
101 alpha_dict.update({k: alpha.get(a)})
104 weight_dict.update({gen +
'_ME_PDF' + p_nom +
'_alphaS_' + astr: {
'weights': sorted(alpha.values()),
'combination':
'alphaS',
'type':
'alphaS',
'nominal': nom_pdf,
'nominal_pdf': p_nom}})
105 dictionary = dict(
set(dictionary.items()) -
set(alpha.items()))
106 dictionary.update(alpha_dict)
107 return dictionary, weight_dict, alpha_dict
184 PDFset = {
'262000':
"NNPDF30_lo_as_0118",
'261000':
"NNPDF30_nnlo_as_0118",
'263000':
"NNPDF30_lo_as_0130"}
189 nom_pdf = dictionary.get(
'Nominal')
192 for key, val
in PDFset.items():
195 print(
"Nominal PDF =" + p_nom)
197 if ((did >= 502198)
and (did <= 502353))
or ((did > 367514)
and (did < 367671))
or ((did > 502197)
and (did < 502354))
or did == 412006:
200 elif ((did >= 302266)
and (did <= 302290))
or ((did > 307730)
and (did < 307749))
or (did == 309529)
or ((did > 450764)
and (did < 450775)):
202 print(
"got HVT" + p_nom)
207 if flag2
is True and p_nom ==
'-1':
208 d = str(int(dsid) / 1000)
209 filename =
'/cvmfs/atlas.cern.ch/repo/sw/Generators/MC15JobOptions/latest/share/DSID' + d +
'xxx/'
210 for files
in os.listdir(filename):
212 filename = filename + files
217 f = open(filename,
'r')
218 for fline
in iter(f):
220 fline = fline.replace(
'\'',
'&').
replace(
'\"',
'&')
221 p_nom = re.findall(
r'\d+', fline)[0]
223 elif "include" in fline
and "MC15JobOptions/MadGraphControl" in fline:
227 mgfile = bfline.split(
'\'')[1].
replace(
'MC15JobOptions',
'/cvmfs/atlas.cern.ch/repo/sw/Generators/MC15JobOptions/latest/common/MadGraph')
229 mgfile = bfline.split(
'\"')[1].
replace(
'MC15JobOptions',
'/cvmfs/atlas.cern.ch/repo/sw/Generators/MC15JobOptions/latest/common/MadGraph')
231 mgfile = bfline.replace(
'MC15JobOptions',
'/cvmfs/atlas.cern.ch/repo/sw/Generators/MC15JobOptions/latest/common/MadGraph')
232 if os.path.exists(mgfile):
233 cf = open(mgfile,
'r')
234 for fline
in iter(cf):
236 fline = fline.replace(
'\'',
'&').
replace(
'\"',
'&')
237 p_nom = re.findall(
r'\d+', fline)[0]
238 scale = dict((key, value)
for (key, value)
in dictionary.items()
if key.endswith(
'scale')
or key ==
'Nominal')
239 if (p_nom ==
'-1' and len(dictionary) == 1):
242 weight_dict.update({
'MadGraph_ME_PDF' + p_nom +
'_scale': {
'weights': sorted(scale.values()),
'combination':
'envelope',
'type':
'scale_ME',
'nominal': nom_pdf,
'nominal_pdf': p_nom}})
243 dictionary = dict(
set(dictionary.items()) -
set(scale.items()))
244 dictionary.update({
'Nominal': nom_pdf})
245 nominal = dict((key, value)
for (key, value)
in dictionary.items()
if 'Nominal' in key)
247 weight_dict.update({
'MadGraph_ME_PDF' + p_nom +
'_var': {
'weights': sorted(nominal.values()),
'combination':
'lhapdf',
'type':
'PDF_ME',
'nominal': nominal.get(
'Nominal'),
'nominal_pdf': p_nom}})
248 weight_dict.update({
'MadGraph_PDF' + p_nom +
'_Nominal': {
'type':
'Nominal',
'weights': [nom_pdf],
'combination':
'none',
'nominal': nom_pdf,
'nominal_pdf': p_nom}})
249 dictionary = dict(
set(dictionary.items()) -
set(nominal.items()))
251 weight_dict.update({
'MadGraph_Other': {
'weights': sorted(dictionary.values()),
'combination':
'none',
'type':
'unknown'}})
258 if gen ==
'Sherpa' or gen ==
'MGPy':
259 nom_pdf = dictionary.get(
'Nominal')
262 me_weights = dict((key, value)
for (key, value)
in dictionary.items()
if key.startswith(
'ME_ONLY_'))
263 dictionary = dict(
set(dictionary.items()) -
set(me_weights.items()))
264 scale = dict((key, value)
for (key, value)
in dictionary.items()
if key.endswith(
'scale')
or key ==
'Nominal')
265 pdf = str(
getPDF(scale.values()[0]))
267 weight_dict.update({
'Sherpa_ME_ONLY_PDF' + pdf: {
'weights': sorted(me_weights.values()),
'combination':
'none',
'type':
'matrix element'}})
268 weight_dict.update({
'Sherpa_ME_PDF' + pdf +
'_scale': {
'weights': sorted(scale.values()),
'combination':
'envelope',
'type':
'scale_ME',
'nominal': nom_pdf,
'nominal_pdf': pdf}})
269 dictionary = dict(
set(dictionary.items()) -
set(scale.items()))
270 dictionary.update({
'Nominal': nom_pdf})
271 dictionary, weight_dict, p_nom =
nom(
'Sherpa', dictionary, weight_dict)
272 weight_dict.update({
'Sherpa_PDF' + pdf +
'_Nominal': {
'type':
'Nominal',
'weights': [nom_pdf],
'combination':
'none',
'nominal': nom_pdf,
'nominal_pdf': pdf}})
273 dictionary, weight_dict, alpha_dict =
alph(
'Sherpa', dictionary, weight_dict, nom_pdf, pdf)
274 dictionary, weight_dict, hess_dict =
hes(
'Sherpa', dictionary, weight_dict)
275 dictionary = dict(
set(dictionary.items()) -
set(alpha_dict.items()))
276 dictionary = dict(
set(dictionary.items()) -
set(hess_dict.items()))
277 other = dict((key, value)
for (key, value)
in dictionary.items()
if key.startswith(
'other_'))
278 dictionary = dict(
set(dictionary.items()) -
set(other.items()))
279 dictionary, weight_dict =
alternate(
'Sherpa', dictionary, weight_dict, nom_pdf)
280 if dictionary
or other:
281 dictionary.update(other)
282 weight_dict.update({
'Sherpa_Other': {
'weights': sorted(dictionary.values()),
'combination':
'none',
'type':
'unknown'}})
283 elif gen ==
'Powheg' or gen ==
'aMcAtNlo' or gen ==
'MadGraph':
284 nom_pdf = dictionary.get(
'Nominal')
286 dictionary, weight_dict, p_nom =
nom(gen, dictionary, weight_dict)
288 weight_dict.update({gen +
'_PDF' + p_nom +
'_Nominal': {
'type':
'Nominal',
'weights': [nom_pdf],
'combination':
'none',
'nominal': nom_pdf,
'nominal_pdf': p_nom}})
289 dictionary.update({
'Nominal': nom_pdf})
290 dictionary, weight_dict =
pyth(dictionary, weight_dict, p_nom, nom_pdf)
291 scale = dict((key, value)
for (key, value)
in dictionary.items()
if key.endswith(
'scale')
or key ==
'Nominal')
292 weight_dict.update({gen +
'_ME_PDF' + p_nom +
'_scale': {
'weights': sorted(scale.values()),
'combination':
'envelope',
'type':
'scale_ME',
'nominal': nom_pdf,
'nominal_pdf': p_nom}})
293 dictionary = dict(
set(dictionary.items()) -
set(scale.items()))
294 dictionary, weight_dict, alpha_dict =
alph(gen, dictionary, weight_dict, nom_pdf, p_nom)
295 dictionary, weight_dict, hess_dict =
hes(gen, dictionary, weight_dict)
296 for pdf
in list_of_NNLOPDF:
297 temp = dict((key, value)
for (key, value)
in dictionary.items()
if key.endswith(pdf))
299 weight_dict.update({gen +
'_ME_PDF' + pdf +
'_scale': {
'weights': sorted(temp.values()),
'combination':
'envelope',
'type':
'Scale_ME',
'nominal': sorted(temp.values())[-1],
'nominal_pdf': pdf}})
300 dictionary = dict(
set(dictionary.items()) -
set(temp.items()))
301 if any(pdf
in d
for d
in dictionary.keys()):
302 dictionary.update({
'PDF' + pdf: sorted(temp.values())[-1]})
304 dictionary = dict(
set(dictionary.items()) -
set(alpha_dict.items()))
306 temp = dict((key, value)
for (key, value)
in dictionary.items()
if key.startswith(w))
308 container = list(k
for k, v
in temp.items()
if w
in v)[0]
309 if 'scale' in container:
310 weight_dict.update({gen +
'_' + container: {
'weights': sorted(temp.values()),
'combination':
'envelope',
'type':
'Scale_ME',
'nominal': nom_pdf,
'nominal_pdf': p_nom}})
311 elif 'NOMINAL' in container:
312 weight_dict.update({gen +
'_' + container: {
'weights': sorted(temp.values()),
'combination':
'none',
'type':
'PDF_ME',
'nominal_pdf': p_nom}})
314 weight_dict.update({gen +
'_' + container: {
'weights': sorted(temp.values()),
'combination':
'none',
'type':
'unknown',
'nominal_pdf': p_nom}})
315 dictionary = dict(
set(dictionary.items()) -
set(temp.items()))
316 dictionary = dict(
set(dictionary.items()) -
set(hess_dict.items()))
317 dictionary, weight_dict =
alternate(gen, dictionary, weight_dict, p_nom)
319 weight_dict.update({gen +
'_Other': {
'weights': sorted(dictionary.values()),
'combination':
'none',
'type':
'unknown'}})