Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[12_0_X] Backport the fix on the workflow 537 and the mergeLHE.py script #34861

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Configuration/PyReleaseValidation/python/relval_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,7 @@ def gen2018RD(fragment,howMuch):

#Herwig7
steps['TTbar_13TeV_Pow_herwig7']=genvalid('Configuration/Generator/python/TT_13TeV_Pow_Herwig7_cff',step1LHEGenDQM)
steps['DYToLL012Jets_5FS_TuneCH3_13TeV_amcatnloFxFx_herwig7']=genvalid('Configuration/Generator/python/DYToLL012Jets_5FS_TuneCH3_13TeV_amcatnloFxFx_herwig7_cff',step1LHEGenDQM)
steps['DYToLL012Jets_5FS_TuneCH3_13TeV_amcatnloFxFx_herwig7']=genvalid('Configuration/Generator/python/DYToLL012Jets_5FS_TuneCH3_13TeV_amcatnloFxFx_herwig7_cff',merge([{'-n':'12'},step1LHEGenDQM]))
steps['DYToLL01234Jets_5FS_TuneCH3_13TeV_madgraphMLM_herwig7']=genvalid('Configuration/Generator/python/DYToLL01234Jets_5FS_TuneCH3_13TeV_madgraphMLM_herwig7_cff',step1LHEGenDQM)


Expand Down
14 changes: 7 additions & 7 deletions GeneratorInterface/LHEInterface/scripts/mergeLHE.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def merge(self):
for i in range(len(self._f)):
header = []
line = next(self._f[i])
while not line.startswith('<init>') and not line.startswith('<init '):
while not re.search('\s*<init(>|\s)', line):
header.append(line)
line = next(self._f[i])
# 'header' includes all contents before reaches <init>
Expand All @@ -207,7 +207,7 @@ def merge(self):
for i in range(len(self._f)):
init = []
line = next(self._f[i])
while not line.startswith('</init>'):
while not re.search('\s*</init>', line):
init.append(line)
line = next(self._f[i])
# 'init_str' includes all contents inside <init>...</init>
Expand All @@ -220,9 +220,9 @@ def merge(self):
nevent = 0
while True:
line = next(self._f[i])
if line.startswith('</event>'):
if re.search('\s*</event>', line):
nevent += 1
if line.startswith('</LesHouchesEvents>'):
if re.search('\s*</LesHouchesEvents>', line):
break
_fwtmp.write(line)
self._nevent.append(nevent)
Expand Down Expand Up @@ -253,16 +253,16 @@ def merge(self):
sign = lambda x: -1 if x < 0 else 1
for line in ftmp:
event_line += 1
if line.startswith('<event'):
if re.search('\s*<event.*>', line):
event_line = 0
if event_line == 1:
# modify the XWGTUP appeared in the first line of the
# <event> block
orig_wgt = float(line.split()[2])
fw.write(re.sub(r'(^\s*\S+\s+\S+\s+)\S+(.+)', r'\g<1>%+.7E\g<2>' \
% (sign(orig_wgt) * self._uwgt), line))
elif line.startswith('<wgt '):
addi_wgt_str = re.search(r'^\<wgt.*\>\s*(\S+)\s*\<\/wgt\>', line).group(1)
elif re.search('\s*<wgt.*>.*</wgt>', line):
addi_wgt_str = re.search(r'\<wgt.*\>\s*(\S+)\s*\<\/wgt\>', line).group(1)
fw.write(line.replace(
addi_wgt_str, '%+.7E' % (float(addi_wgt_str) / orig_wgt * self._uwgt)))
else:
Expand Down