-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add lhe numbering to allow get correct matching between lhe and herwi…
…g events Read lhe event numbers in, if present Add HadroniserFilter to Herwig which correctly matches LHE numbers between CMSSW and herwig Add option to Herwig input fragements to use LHE numbering Change test examples to use new HadroniserFilter+ LHE numbering code style code style Call addLHEnumbers from mergeLHE.py if asked to number events and not using the DefaultLHEMerger Number events before merge (so numbers are also available to LHEReader) Include evtnum in LHEEventProduct (necesary for multithreading)
- Loading branch information
1 parent
3d761d8
commit 2494ca5
Showing
15 changed files
with
137 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from __future__ import print_function | ||
import logging | ||
import argparse | ||
import sys | ||
import os | ||
import re | ||
|
||
|
||
def number_events(input_file, output_file=None, offset=0): | ||
if output_file is None: | ||
output_file = input_file | ||
if not os.path.exists(os.path.dirname(os.path.realpath(output_file))): | ||
os.makedirs(os.path.dirname(os.path.realpath(output_file))) | ||
|
||
nevent = offset | ||
with open('tmp.txt', 'w') as fw: | ||
with open(input_file, 'r') as ftmp: | ||
for line in ftmp: | ||
if re.search('\s*</event>', line): | ||
nevent += 1 | ||
fw.write('<event_num num="' + str(nevent) + '"> ' + str(nevent) + '</event_num>\n') | ||
fw.write(line) | ||
if output_file is not None: | ||
os.rename("tmp.txt", output_file) | ||
else: | ||
os.rename("tmp.txt", input_file) | ||
return nevent | ||
|
||
|
||
if __name__=="__main__": | ||
|
||
parser = argparse.ArgumentParser( | ||
description="Add numbers to lhe") | ||
parser.add_argument("input_file", type=str, | ||
help="Input LHE file path.") | ||
parser.add_argument("-o", "--output-file", default=None, type=str, | ||
help="Output LHE file path. If not specified, output to input file") | ||
args = parser.parse_args() | ||
|
||
logging.info('>>> launch addLHEnumbers.py in %s' % os.path.abspath(os.getcwd())) | ||
|
||
logging.info('>>> Input file: [%s]' % args.input_file) | ||
logging.info('>>> Write to output: %s ' % args.output_file) | ||
|
||
number_events(args.input_file, args.output_file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters