ATLAS Offline Software
Generators
PowhegControl
python
algorithms
postprocessors
quark_colour_fixer.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
2
3
from
AthenaCommon
import
Logging
4
from
...decorators
import
timed
5
from
...utility
import
LHE
6
import
shutil
7
8
9
logger = Logging.logging.getLogger(
"PowhegControl"
)
10
11
12
@
timed
(
"quark colour fixer"
)
13
def
quark_colour_fixer
(process, powheg_LHE_output):
14
"""! Post-process existing events to ensure that all quarks are coloured.
15
16
@param process PowhegBox process.
17
@param powheg_LHE_output Name of LHE file produced by PowhegBox.
18
19
@author James Robinson <james.robinson@cern.ch>
20
"""
21
# Check whether vdecaymode is one of the hadronic modes
22
if
all
(p.value
in
[0, 10]
for
p
in
process.parameters_by_keyword(
"vdecaymode"
)):
23
logger.info(
"Checking for presence of colourless quarks!"
)
24
25
# Get opening and closing strings
26
preamble = LHE.preamble(powheg_LHE_output)
27
postamble = LHE.postamble(powheg_LHE_output)
28
29
# Check events for colourless final-state quarks and colour them
30
n_events = 0
31
logger.info(
"Checking events for colourless final-state quarks"
)
32
powheg_LHE_recoloured =
"{}.recoloured"
.
format
(powheg_LHE_output)
33
with
open
(powheg_LHE_recoloured,
"w"
)
as
f_output:
34
f_output.write(
"{}\n"
.
format
(preamble))
35
for
input_event
in
LHE.event_iterator(powheg_LHE_output):
36
is_event_changed, output_event = LHE.ensure_coloured_quarks(input_event)
37
f_output.write(output_event)
38
n_events += [0, 1][is_event_changed]
39
f_output.write(postamble)
40
logger.info(
"Re-coloured final-state quarks in {} events!"
.
format
(n_events))
41
42
# Make a backup of the original events
43
shutil.move(powheg_LHE_output,
"{}.quark_colour_fixer_backup"
.
format
(powheg_LHE_output))
44
shutil.move(powheg_LHE_recoloured, powheg_LHE_output)
python.decorators.timed.timed
def timed(name)
Decorator to output function execution time.
Definition:
timed.py:12
vtune_athena.format
format
Definition:
vtune_athena.py:14
python.algorithms.postprocessors.quark_colour_fixer.quark_colour_fixer
def quark_colour_fixer(process, powheg_LHE_output)
Post-process existing events to ensure that all quarks are coloured.
Definition:
quark_colour_fixer.py:13
Trk::open
@ open
Definition:
BinningType.h:40
Cut::all
@ all
Definition:
SUSYToolsAlg.cxx:67
Generated on Tue Sep 2 2025 21:19:16 for ATLAS Offline Software by
1.8.18