ATLAS Offline Software
ggF_HH_quartic.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 import os
3 import glob
4 from AthenaCommon import Logging
5 from ..powheg_V2 import PowhegV2
6 
7 
8 logger = Logging.logging.getLogger("PowhegControl")
9 
10 
12  """! Default Powheg configuration for gluon-fusion Higgs boson production with quark mass and EW effects.
13 
14  Create a configurable object with all applicable Powheg options.
15 
16  @author James Robinson <james.robinson@cern.ch>, <andrii.verbytskyi@mpp.mpg.de>
17  """
18 
19  def __init__(self, base_directory, **kwargs):
20  """! Constructor: all process options are set here.
21 
22  @param base_directory: path to PowhegBox code.
23  @param kwargs dictionary of arguments from Generate_tf.
24  """
25  super(ggF_HH_quartic, self).__init__(base_directory, "ggHH_quartic", **kwargs)
26 
27  # Add grid file creation function
28  self.validation_functions.append("create_grid_file")
29 
30  # This process uses a python script which uses .grid files searched for in $PYTHONPATH
31  # By appending the folder that they live in to PYTHONPATH it is able to find them
32  # At the moment these files are stored or linked locally, so we use ${PWD}
33  # but we may use self.executable.replace("pwhg_main", "Virtual") instead at some point
34  os.environ["PYTHONPATH"] += ":" + os.environ["PWD"]
35 
36  # Add all keywords for this process, overriding defaults if required
37  self.add_keyword("alphas_from_lhapdf")
38  self.add_keyword("bornktmin")
39  self.add_keyword("bornonly")
40  self.add_keyword("bornsuppfact")
41  self.add_keyword("bornzerodamp")
42  self.add_keyword("bottomthr")
43  self.add_keyword("bottomthrpdf")
44  self.add_keyword("btildeborn")
45  self.add_keyword("btildecoll")
46  self.add_keyword("btildereal")
47  self.add_keyword("btildevirt")
48  self.add_keyword("btlscalect")
49  self.add_keyword("btlscalereal")
50  self.add_keyword("charmthr")
51  self.add_keyword("charmthrpdf")
52  self.add_keyword("check_bad_st1")
53  self.add_keyword("check_bad_st2")
54  self.add_keyword("chhh", 1.0)
55  self.add_keyword("ct", 1.0)
56  self.add_keyword("ctt", 0.)
57  self.add_keyword("cggh", 0.)
58  self.add_keyword("cgghh", 0.)
59  self.add_keyword("clobberlhe")
60  self.add_keyword("colltest")
61  self.add_keyword("compress_lhe")
62  self.add_keyword("compress_upb")
63  self.add_keyword("compute_rwgt")
64  self.add_keyword("doublefsr")
65  self.add_keyword("evenmaxrat")
66  self.add_keyword("facscfact", self.default_scales[0])
67  self.add_keyword("fastbtlbound")
68  self.add_keyword("fixedgrid")
69  self.add_keyword("fixedscale", description="Set renormalisation and factorisation scales to 2*m_H")
70  self.add_keyword("flg_debug")
71  self.add_keyword("foldcsi", 2)
72  self.add_keyword("foldphi", 2)
73  self.add_keyword("foldy", 5)
74  self.add_keyword("fullrwgt")
75  self.add_keyword("gfermi")
76  self.add_keyword("hdamp")
77  self.add_keyword("hdecaymode")
78  self.add_keyword("hfact")
79  self.add_keyword("hmass", 125.)
80  self.add_keyword("icsimax", 2)
81  self.add_keyword("ih1")
82  self.add_keyword("ih2")
83  self.add_keyword("itmx1", 2)
84  self.add_keyword("itmx1rm")
85  self.add_keyword("itmx2", 4)
86  self.add_keyword("itmx2rm")
87  self.add_keyword("iupperfsr")
88  self.add_keyword("iupperisr")
89  self.add_keyword("iymax", 2)
90  self.add_keyword("lhans1", self.default_PDFs)
91  self.add_keyword("lhans2", self.default_PDFs)
92  self.add_keyword("lhapdf6maxsets")
93  self.add_keyword("lhrwgt_descr")
94  self.add_keyword("lhrwgt_group_combine")
95  self.add_keyword("lhrwgt_group_name")
96  self.add_keyword("lhrwgt_id")
97  self.add_keyword("LOevents")
98  self.add_keyword("manyseeds")
99  self.add_keyword("max_io_bufsize")
100  self.add_keyword("maxseeds")
101  self.add_keyword("minlo", frozen=True)
102  self.add_keyword("mintupbratlim")
103  self.add_keyword("mintupbxless")
104  self.add_keyword("mtdep", 3)
105  self.add_keyword("ncall1", 200000)
106  self.add_keyword("ncall1rm")
107  self.add_keyword("ncall2", 150000)
108  self.add_keyword("ncall2rm")
109  self.add_keyword("ncallfrominput")
110  self.add_keyword("noevents")
111  self.add_keyword("novirtual")
112  self.add_keyword("nubound", 200000)
113  self.add_keyword("olddij")
114  self.add_keyword("par_2gsupp")
115  self.add_keyword("par_diexp")
116  self.add_keyword("par_dijexp")
117  self.add_keyword("parallelstage")
118  self.add_keyword("pdfreweight")
119  self.add_keyword("ptHHcut_CT")
120  self.add_keyword("ptHHcut")
121  self.add_keyword("ptsqmin")
122  self.add_keyword("ptsupp")
123  self.add_keyword("radregion")
124  self.add_keyword("rand1")
125  self.add_keyword("rand2")
126  self.add_keyword("renscfact", self.default_scales[1])
127  self.add_keyword("rescue_reals")
128  self.add_keyword("rwl_add")
129  self.add_keyword("rwl_file")
130  self.add_keyword("rwl_format_rwgt")
131  self.add_keyword("rwl_group_events")
132  self.add_keyword("skipextratests")
133  self.add_keyword("smartsig")
134  self.add_keyword("softtest")
135  self.add_keyword("stage2init")
136  self.add_keyword("storeinfo_rwgt")
137  self.add_keyword("storemintupb")
138  self.add_keyword("testplots")
139  self.add_keyword("testsuda")
140  self.add_keyword("topmass", 173.) # this value is hardcoded in the virtual matrix element, and for consistency has not to be changed when running full theory prediction (i.e. mtdep=3)
141  self.add_keyword("ubexcess_correct")
142  self.add_keyword("ubsigmadetails")
143  self.add_keyword("use-old-grid")
144  self.add_keyword("use-old-ubound")
145  self.add_keyword("withdamp")
146  self.add_keyword("withnegweights")
147  self.add_keyword("withsubtr")
148  self.add_keyword("Wmass")
149  self.add_keyword("Wwidth")
150  self.add_keyword("xgriditeration")
151  self.add_keyword("xupbound")
152  self.add_keyword("zerowidth")
153  self.add_keyword("Zmass")
154  self.add_keyword("Zwidth")
155 
156  def create_grid_file(self):
157  """! Creates the .grid file needed by this process."""
158  """! This function calls a python script provided by the authors, which is linked to the local directory."""
159  """! The code of this function is adapted from the script ${POWHEGPATH}/POWHEG-BOX-V2/ggHH/testrun/run.sh"""
160  self.expose() # convenience call to simplify syntax
161 
162  logger.info('Now attempting to link locally the files needed by this Powheg process')
163  try:
164  os.system("ln -s " + os.environ["POWHEGPATH"] + "/POWHEG-BOX-V2/ggHH_quartic/Virtual/events.cdf events.cdf")
165  os.system("ln -s " + os.environ["POWHEGPATH"] + "/POWHEG-BOX-V2/ggHH_quartic/Virtual/creategrid.py creategrid.py")
166  os.system("for grid in " + os.environ["POWHEGPATH"] + "/POWHEG-BOX-V2/ggHH_quartic/Virtual/Virt_full_*E*.grid; do ln -s $grid ${grid##*/}; done")
167  except RuntimeError:
168  logger.error('Impossible to link the needed files locally')
169  raise
170 
171  # need to override lhapdf python path while the powheg process has been compiled in a different platform
172  py_path_save = os.environ["PYTHONPATH"]
173  base_path = os.environ["LHAPDF_INSTAL_PATH"]
174 
175  # Search for the Python version in the lib folder
176  python_lib_path = glob.glob(os.path.join(base_path, "lib", "python*"))
177 
178  # Ensure at least one matching path is found
179  if python_lib_path:
180  python_lib_path = python_lib_path[0]
181  else:
182  raise ValueError("No Python version found in lib folder")
183 
184  # Build the temporary path
185  py_path_temp = python_lib_path + "/site-packages" + ":" + py_path_save
186  os.environ["PYTHONPATH"] = py_path_temp
187  logger.debug(f'Temporarily setting PYTHONPATH to:\n{py_path_temp}')
188 
189  # handling the parameters of this process
190  # these parameters need to be parsed in a specific format
191  chhh_str = f'{list(self.parameters_by_keyword("chhh"))[0].value:+.4E}'
192  ct_str = f'{0.0:+.4E}'
193  ctt_str = f'{0.0:+.4E}'
194  cggh_str = f'{0.0:+.4E}'
195  cgghh_str = f'{0.0:+.4E}'
196  grid_file_name = f'Virt_full_{chhh_str}_{ct_str}_{ctt_str}_{cggh_str}_{cgghh_str}.grid'
197 
198  logger.info('Now trying to use creategrid.py to create the Virt_full_*.grid file')
199  logger.info(f'File name: {grid_file_name}')
200  logger.info(f'Parameters are: chhh={chhh_str}, ct={ct_str}, ctt={ctt_str}, cggh={cggh_str}, cgghh={cgghh_str}')
201  try:
202  #import creategrid as cg
203  #cg.combinegrids(grid_file_name, chhh_str, ct_str, ctt_str, cggh_str, cgghh_str)
204  pythoncmd=f"import creategrid as cg; cg.combinegrids('{grid_file_name}', {chhh_str}, {ct_str}, {ctt_str}, {cggh_str}, {cgghh_str})"
205  os.system("python3 -c \""+pythoncmd+"\"")
206  except RuntimeError:
207  logger.error('Impossible to use creategrid.py to create the Virt_full_*.grid file')
208  raise
209 
210  # setting PYTHONPATH back to its original value
211  os.environ["PYTHONPATH"] = py_path_save
212  logger.debug(f'Setting PYTHONPATH back to:\n{py_path_save}')
213 
214  logger.info('Although the produced Virt_full_*.grid file now exists in the local directory, Powheg will later try to find it in all directories contained in $PYTHONPATH. This will produce several "not found" info messages which can safely be ignored.')
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.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
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
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.ggF_HH_quartic.ggF_HH_quartic
Default Powheg configuration for gluon-fusion Higgs boson production with quark mass and EW effects.
Definition: ggF_HH_quartic.py:11
python.processes.powheg_base.PowhegBase.default_PDFs
def default_PDFs(self)
Default PDFs for this process.
Definition: powheg_base.py:241
python.processes.powheg_V2.PowhegV2
Base class for PowhegBox V2 processes.
Definition: powheg_V2.py:6
python.processes.powheg.ggF_HH_quartic.ggF_HH_quartic.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ggF_HH_quartic.py:19
python.processes.powheg.ggF_HH_quartic.ggF_HH_quartic.create_grid_file
def create_grid_file(self)
Creates the .grid file needed by this process.
Definition: ggF_HH_quartic.py:156