ATLAS Offline Software
ttZ.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
2 
3 from AthenaCommon import Logging
4 from ..powheg_V2 import PowhegV2
5 from ..external import ExternalMadSpin
6 
7 
8 logger = Logging.logging.getLogger("PowhegControl")
9 
10 
11 
12 # Dictionary to convert the PowhegControl decay mode names to the appropriate
13 # decay mode numbers understood by Powheg
14 _decay_mode_lookup = {
15  "t t~ z > all [MadSpin]" : "00000", # switch off decays in Powheg and let MadSpin handle them!
16  't t~ z > all' : '22222',
17  't t~ z > b j j b~ j j emu+ emu-' : '00022',
18  't t~ z > b l+ vl b~ l- vl~ emu+ emu-' : '22200',
19  "t t~ z > b emu+ vemu b~ emu- vemu~ emu+ emu-": "22000",
20  't t~ z > semileptonic + emu+ emu-': '11111', # additionally need to set the "semileptonic" parameter
21  't t~ z > undecayed' : '00000',
22 }
23 
24 
25 
26 class ttZ(PowhegV2):
27  """
28  Powheg interface for ttZ production.
29 
30  Reference for this process: https://arxiv.org/abs/2112.08892
31 
32  @author Timothee Theveneaux-Pelzer <tpelzer@cern.ch>
33  """
34 
35  def __init__(self, base_directory, **kwargs):
36  """! Constructor: all process options are set here.
37 
38  @param base_directory: path to PowhegBox code.
39  @param kwargs dictionary of arguments from Gen_tf.
40  """
41  super(ttZ, self).__init__(base_directory, "ttZ", **kwargs)
42 
43  # List of allowed decay modes
44  # (The sorting of the list is just to increase readability when it's printed)
45  self.allowed_decay_modes = sorted(_decay_mode_lookup.keys())
46 
47  # Add algorithms to the sequence
48  self.add_algorithm(ExternalMadSpin(process="generate p p > t t~ e+ e- [QCD]\nadd process p p > t t~ mu+ mu- [QCD]"))
49 
50  self.validation_functions.append("validate_decays")
51  self.validation_functions.append("get_nlox_params_file")
52 
53  # Add all keywords for this process, overriding defaults if required
54  self.add_keyword("bornonly")
55  self.add_keyword("elbranching")
56  self.add_keyword("btlscalect", 1)
57  self.add_keyword("btlscalereal", 1)
58  self.add_keyword("bmass")
59  self.add_keyword("CKM_Vcd")
60  self.add_keyword("CKM_Vcs")
61  self.add_keyword("CKM_Vud")
62  self.add_keyword("CKM_Vus")
63  self.add_keyword("clobberlhe")
64  self.add_keyword("colltest")
65  self.add_keyword("compress_lhe")
66  self.add_keyword("compress_upb")
67  self.add_keyword("compute_rwgt")
68  self.add_keyword("delta_mttmin")
69  self.add_keyword("dynamic_hdamp")
70  self.add_keyword("facscfact", self.default_scales[0])
71  self.add_keyword("fakevirt")
72  self.add_keyword("fastbtlbound")
73  self.add_keyword("foldcsi", 2)
74  self.add_keyword("foldphi", 2)
75  self.add_keyword("foldy", 2)
76  self.add_keyword("for_reweighting")
77  self.add_keyword("gfermi")
78  self.add_keyword("hbzd")
79  self.add_keyword("hdamp")
80  self.add_keyword("hmass")
81  self.add_keyword("hwidth")
82  self.add_keyword("icsimax", 3)
83  self.add_keyword("ih1")
84  self.add_keyword("ih2")
85  self.add_keyword("itmx1", 5)
86  self.add_keyword("itmx2", 5)
87  self.add_keyword("iymax", 3)
88  self.add_keyword("lhans1", self.default_PDFs)
89  self.add_keyword("lhans2", self.default_PDFs)
90  self.add_keyword("lhfm/bmass")
91  self.add_keyword("lhfm/cmass")
92  self.add_keyword("lhfm/emass")
93  self.add_keyword("lhfm/mumass")
94  self.add_keyword("lhfm/smass")
95  self.add_keyword("lhfm/taumass")
96  self.add_keyword("lhfm/umass")
97  self.add_keyword("lhrwgt_descr")
98  self.add_keyword("lhrwgt_group_combine")
99  self.add_keyword("lhrwgt_group_name")
100  self.add_keyword("lhrwgt_id")
101  self.add_keyword("LOevents")
102  self.add_keyword("manyseeds")
103  self.add_keyword("maxseeds", 1000)
104  self.add_keyword("ncall1", 100000)
105  self.add_keyword("ncall2", 100000)
106  self.add_keyword("ncall2rm")
107  self.add_keyword("nubound", 100000)
108  self.add_keyword("parallelstage")
109  self.add_keyword("renscfact", self.default_scales[1])
110  self.add_keyword("runningscales", 0) # 0: no running scales; 1: use running scales
111  self.add_keyword("rwl_add")
112  self.add_keyword("rwl_file")
113  self.add_keyword("rwl_format_rwgt")
114  self.add_keyword("rwl_group_events")
115  self.add_keyword("semileptonic")
116  self.add_keyword("storeinfo_rwgt", 1)
117  self.add_keyword("storemintupb")
118  self.add_keyword("tmass")
119  self.add_keyword("topdecaymode", "t t~ z > all", name="decay_mode")
120  self.add_keyword("twidth")
121  self.add_keyword("use-old-grid", 1)
122  self.add_keyword("use-old-ubound", 1)
123  self.add_keyword("withdamp", 1)
124  self.add_keyword("wmass")
125  self.add_keyword("wwidth")
126  self.add_keyword("xgriditeration")
127  self.add_keyword("xupbound", 2)
128  self.add_keyword("zerowidth")
129  self.add_keyword("zmass")
130  self.add_keyword("zwidth")
131 
133  """
134  Retrives nlox parameters file, copy it in local directory, and edit some of the parameters
135  """
136  import os
137  import shutil
138 
139  # copy original file to current directory
140  original = os.path.dirname(self.executable) + '/testrun/nlox_parameters.par'
141  shutil.copyfile(original,'./nlox_parameters.par-old')
142 
143  # edit some of the parameters
144  lines = []
145  with open('./nlox_parameters.par-old') as f:
146  lines = f.readlines()
147  update_dict = {
148  '# mb =':'mb = {}'.format(self.parameters_by_keyword('bmass')[0].value),
149  '# mt =':'mt = {}'.format(self.parameters_by_keyword('tmass')[0].value),
150  '# wt =':'wt = {}'.format(self.parameters_by_keyword('twidth')[0].value),
151  '# mW =':'mW = {}'.format(self.parameters_by_keyword('wmass')[0].value),
152  '# wW =':'wW = {}'.format(self.parameters_by_keyword('wwidth')[0].value),
153  '# mZ =':'mZ = {}'.format(self.parameters_by_keyword('zmass')[0].value),
154  '# wZ =':'wZ = {}'.format(self.parameters_by_keyword('zwidth')[0].value),
155  '# mH =':'mH = {}'.format(self.parameters_by_keyword('hmass')[0].value),
156  '# wH =':'wH = {}'.format(self.parameters_by_keyword('hwidth')[0].value),
157  '# GF =':'GF = {}'.format(self.parameters_by_keyword('gfermi')[0].value),
158  }
159  with open('./nlox_parameters.par','w') as f:
160  for line in lines:
161  for pattern, replacement in update_dict.items():
162  if pattern in line:
163  line = replacement+'\n'
164  break
165  f.write(line)
166  logger.info('New file ./nlox_parameters.par created locally with updated parameters')
167 
168  def validate_decays(self):
169  """
170  Validate decay_mode keywords and translate them from ATLAS input to Powheg input
171  """
172  self.expose() # convenience call to simplify syntax
173  if self.decay_mode not in self.allowed_decay_modes:
174  error_message = "Decay mode '{given}' not recognised, valid choices are: '{choices}'!".format(given=self.decay_mode, choices="', '".join(self.allowed_decay_modes))
175  logger.warning(error_message)
176  raise ValueError(error_message)
177 
178  # Check if MadSpin decays are requested.
179  # Accordingly, MadSpin will run or not run.
180  if "MadSpin" in self.decay_mode:
181  self.externals["MadSpin"].parameters_by_keyword("powheg_top_decays_enabled")[0].value = False
182  self.externals["MadSpin"].parameters_by_keyword("MadSpin_model")[0].value = "loop_sm-no_b_mass"
183  self.externals["MadSpin"].parameters_by_keyword("MadSpin_nFlavours")[0].value = 5
184 
185  self.parameters_by_keyword("topdecaymode")[0].value = _decay_mode_lookup[self.decay_mode]
186  if self.decay_mode == 't t~ z > semileptonic emu+ emu-':
187  # Parameter semileptonic must be set to 1
188  self.parameters_by_keyword("semileptonic")[0].value = 1
python.processes.configurable.Configurable.expose
def expose(self)
Add all names to the interface of this object.
Definition: configurable.py:46
python.processes.powheg_base.PowhegBase.add_algorithm
def add_algorithm(self, alg_or_process)
Add an algorithm or external process to the sequence.
Definition: powheg_base.py:208
vtune_athena.format
format
Definition: vtune_athena.py:14
python.processes.powheg.ttZ.ttZ.decay_mode
decay_mode
Definition: ttZ.py:186
python.processes.powheg_base.PowhegBase.default_scales
def default_scales(self)
Default scale variations for this process.
Definition: powheg_base.py:246
python.processes.configurable.Configurable.add_keyword
def add_keyword(self, keyword, value=None, name=None, frozen=None, hidden=None, description=None, **kwargs)
Register configurable parameter that is exposed to the user.
Definition: configurable.py:21
python.processes.external.external_madspin.ExternalMadSpin
Class for running external MadSpin process.
Definition: external_madspin.py:11
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
python.processes.configurable.Configurable.parameters_by_keyword
def parameters_by_keyword(self, keyword)
Retrieve all parameters that use a given keyword.
Definition: configurable.py:57
python.processes.powheg.ttZ.ttZ
Definition: ttZ.py:26
python.processes.powheg_base.PowhegBase.validation_functions
validation_functions
List of validation functions to run before preparing runcard.
Definition: powheg_base.py:179
python.processes.powheg.ttZ.ttZ.get_nlox_params_file
def get_nlox_params_file(self)
Definition: ttZ.py:132
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.processes.powheg_base.PowhegBase.externals
externals
List of external processes to schedule.
Definition: powheg_base.py:176
python.processes.powheg_base.PowhegBase.default_PDFs
def default_PDFs(self)
Default PDFs for this process.
Definition: powheg_base.py:241
Trk::open
@ open
Definition: BinningType.h:40
python.processes.powheg_V2.PowhegV2
Base class for PowhegBox V2 processes.
Definition: powheg_V2.py:6
python.processes.powheg_base.PowhegBase.executable
executable
Powheg executable that will be used.
Definition: powheg_base.py:154
python.processes.powheg.ttZ.ttZ.allowed_decay_modes
allowed_decay_modes
Definition: ttZ.py:45
python.processes.powheg.ttZ.ttZ.validate_decays
def validate_decays(self)
Definition: ttZ.py:168
python.processes.powheg.ttZ.ttZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ttZ.py:35