45 if ( filecmp.cmp(
"Settings_before.log",
"Settings_after.log") ):
46 self.msg.info(
"Settings match before and after initialisation of Pythia8.")
48 if "PartonShowers:model" in requestedsettings:
49 if (requestedsettings[
"PartonShowers:model"] !=
"1"):
50 self.msg.info(
"Settings before and after initialisation of Pythia8 don't match, because you asked PartonShowers:model = %s", requestedsettings[
"PartonShowers:model"])
52 self.msg.warning(
"Settings before and after initialisation of Pythia8 don't match.")
53 with open(
"Settings_before.log")
as f1:
54 f1_lines = f1.read().splitlines()
55 with open(
"Settings_after.log")
as f2:
56 f2_lines = f2.read().splitlines()
58 if (len(f1_lines) == len(f2_lines)):
59 for iline
in range(len(f1_lines)):
60 if (f1_lines[iline]!=f2_lines[iline]):
61 if f2_lines[iline].
split(
"=")[0]
in requestedsettings:
62 self.msg.warning(
" >> %s != %s. You requested %s.", f1_lines[iline], f2_lines[iline].
split(
"=")[1], requestedsettings[f2_lines[iline].
split(
"=")[0]])
64 self.msg.info(
" >> %s != %s", f1_lines[iline], f2_lines[iline].
split(
"=")[1])
66 self.msg.warning(
"Not even the -number- of settings before and after initialisation of Pythia8 matches, check yourself what's going wrong.")
72 if f1.endswith(
'xml'):
76 doc1 = xml.dom.minidom.parse(f1)
81 doc1 = xml.dom.minidom.parse(f1)
83 self.msg.
error(
"Bad file, exiting")
88 doc2 = xml.dom.minidom.parse(f2)
93 doc2 = xml.dom.minidom.parse(f2)
95 self.msg.
error(
"Bad file, exiting")
99 particles1 = doc1.getElementsByTagName(
"particle")
100 particles2 = doc2.getElementsByTagName(
"particle")
101 if (particles1.length == particles2.length):
102 self.msg.info(
"Number of particles before and after Pythia8 initialisation matches ( %d )", particles1.length)
104 self.msg.warning(
"Mismatch in number of particles before and after Pythia8 initialisation. Before: %d , after: %d", particles1.length, particles2.length)
105 for part1
in particles1:
106 if ( part1.getAttribute(
"id")
in pids):
107 for part2
in particles2:
108 if ( part2.getAttribute(
"id") == part1.getAttribute(
"id") ):
109 for attrk2, attrv2
in part2.attributes.items():
111 trypartprop = part2.getAttribute(
"id")+
":"+attrk2
112 if ( trypartprop
in rpd ):
113 requested = rpd[trypartprop]
114 if (
not ( attrk2
in part1.attributes.keys() ) ):
115 self.msg.info(
"You asked Pythia8 to modify properties for particle %s (%s). Attribute \"%s\" added after initialisation, check it. Requested: %s. After init: %s.", part2.getAttribute(
"name"), part2.getAttribute(
"id"), attrk2, requested, attrv2)
116 for attrk1, attrv1
in part1.attributes.items():
117 if (attrk1 == attrk2
and attrv1 != attrv2):
118 self.msg.warning(
"You asked Pythia8 to modify properties for particle %s (%s). Attribute \"%s\" modified after initialisation. Requested: %s. Before init: %s. After init: %s.", part1.getAttribute(
"name"), part1.getAttribute(
"id"), attrk1, requested, attrv1, attrv2)