ATLAS Offline Software
Loading...
Searching...
No Matches
merge_output.py
Go to the documentation of this file.
1# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
2
3from AthenaCommon import Logging
4from ...decorators import timed
5from ...utility import FileParser, LHE
6import glob
7import subprocess
8
9
10logger = Logging.logging.getLogger("PowhegControl")
11
12
13@timed("merge output")
14def merge_output(cores, n_events_unscaled, powheg_LHE_output):
15 """! Merge output events if running in multicore mode.
16
17 @param cores Number of cores in use.
18 @param n_events_unscaled Total number of events generated.
19 @param powheg_LHE_output Name of LHE file produced by PowhegBox.
20
21 @author James Robinson <james.robinson@cern.ch>
22 """
23 logger.info("Concatenating output LHE files: expecting {}, found {}".format(cores, len(glob.glob("pwgevents*.lhe"))))
24 LHE.merge("pwgevents*.lhe", powheg_LHE_output)
25 subprocess.call("rm pwgevents-*.lhe 2> /dev/null", shell=True)
26 # Unscale nEvents in case this is needed later on
27 FileParser("powheg*.input").text_replace("numevts .*", "numevts {}".format(n_events_unscaled))
Utility class to perform simple operations on files.