1583
1583
logger.info(" --start_id= # define the starting digit for the additial weight. If not specify it is determine automatically")
1584
1584
logger.info(" --only_beam=0 # only apply the new pdf set to the beam selected.")
1585
1585
logger.info(" --ion_scaling=True# if original sample was using rescaled PDF: apply the same rescaling for all PDF sets.")
1586
logger.info(" --weight_format=\"%(id)i\" # allow to customise the name of the weight. The resulting name SHOULD be unique.")
1587
logger.info(" --weight_info= # allow to customise the text describing the weights.")
1586
1588
logger.info("")
1587
1589
logger.info(" Allowed value for the pdf options:", '$MG:BOLD')
1588
1590
logger.info(" central : Do not perform any pdf variation" )
1601
1603
logger.info(" id1,id2 : keep/remove all the weights between those two values --included--")
1602
1604
logger.info(" PATTERN : keep/remove all the weights matching the (python) regular expression.")
1603
1605
logger.info(" note that multiple entry of those arguments are allowed")
1607
logger.info(" Input for weight format")
1608
logger.info(" The parameter will be interpreted by python using: https://docs.python.org/2/library/stdtypes.html#string-formatting")
1609
logger.info(" The allowed parameters are 'muf','mur','pdf','dyn','alps','id'")
1604
1610
def complete_systematics(self, text, line, begidx, endidx):
1605
1611
"""auto completion for the systematics command"""
1667
1673
#check sanity of options
1668
1674
if any(not o.startswith(('--mur=', '--muf=', '--alps=','--dyn=','--together=','--from_card','--pdf=',
1669
'--remove_wgts=', '--keep_wgts','--start_id='))
1675
'--remove_wgts=', '--keep_wgts','--start_id=', '--weight_format=',
1670
1677
for o in opts):
1671
1678
raise self.InvalidCmd, "command systematics called with invalid option syntax. Please retry."
4124
4131
if not lhapdf_version:
4125
lhapdf_version = subprocess.Popen([lhapdf_config, '--version'],
4126
stdout = subprocess.PIPE).stdout.read().strip()
4132
lhapdf_version = CommonRunCmd.get_lhapdf_version_static(lhapdf_config)
4129
4134
if not pdfsets_dir:
4130
if 'LHAPATH' in os.environ:
4131
for p in os.environ['LHAPATH'].split(':'):
4132
if os.path.exists(p):
4136
del os.environ['LHAPATH']
4137
pdfsets_dir = subprocess.Popen([lhapdf_config, '--datadir'],
4138
stdout = subprocess.PIPE).stdout.read().strip()
4140
pdfsets_dir = subprocess.Popen([lhapdf_config, '--datadir'],
4141
stdout = subprocess.PIPE).stdout.read().strip()
4135
pdfsets_dir = CommonRunCmd.get_lhapdf_pdfsetsdir_static(lhapdf_config, lhapdf_version)
4143
4137
if isinstance(filename, int):
4144
4138
pdf_info = CommonRunCmd.get_lhapdf_pdfsets_list_static(pdfsets_dir, lhapdf_version)
4185
4179
os.path.isdir(pjoin(pdfsets_dir, filename)):
4186
4180
logger.info('%s successfully downloaded and stored in %s' \
4187
4181
% (filename, pdfsets_dir))
4188
4183
#otherwise (if v5) save it locally
4189
4184
elif lhapdf_version.startswith('5.'):
4190
4185
logger.warning('Could not download %s into %s. Trying to save it locally' \
4207
4202
os.path.isdir(pjoin(pdfsets_dir, filename)):
4208
4203
logger.info('%s successfully downloaded and stored in %s' \
4209
4204
% (filename, pdfsets_dir))
4205
elif 'LHAPDF_DATA_PATH' in os.environ and os.environ['LHAPDF_DATA_PATH']:
4207
if pdfsets_dir in os.environ['LHAPDF_DATA_PATH'].split(':'):
4208
lhapath = os.environ['LHAPDF_DATA_PATH'].split(':')
4209
lhapath = [p for p in lhapath if os.path.exists(p)]
4210
lhapath.remove(pdfsets_dir)
4211
os.environ['LHAPDF_DATA_PATH'] = ':'.join(lhapath)
4213
return CommonRunCmd.install_lhapdf_pdfset_static(lhapdf_config, None,
4215
lhapdf_version, alternate_path)
4216
elif 'LHAPATH' in os.environ and os.environ['LHAPATH']:
4217
return CommonRunCmd.install_lhapdf_pdfset_static(lhapdf_config, None,
4219
lhapdf_version, alternate_path)
4221
raise MadGraph5Error, \
4222
'Could not download %s into %s. Please try to install it manually.' \
4223
% (filename, pdfsets_dir)
4225
return CommonRunCmd.install_lhapdf_pdfset_static(lhapdf_config, None,
4227
lhapdf_version, alternate_path)
4210
4228
elif 'LHAPATH' in os.environ and os.environ['LHAPATH']:
4211
4229
misc.sprint(os.environ['LHAPATH'], '-> retry')
4212
4230
if pdfsets_dir in os.environ['LHAPATH'].split(':'):
4283
4301
return lhapdf_pdfsets
4304
def get_lhapdf_version_static(lhapdf_config):
4305
"""returns the lhapdf version number"""
4309
subprocess.Popen([lhapdf_config, '--version'],
4310
stdout = subprocess.PIPE).stdout.read().strip()
4311
except OSError, error:
4312
if error.errno == 2:
4313
raise Exception, 'lhapdf executable (%s) is not found on your system. Please install it and/or indicate the path to the correct executable in input/mg5_configuration.txt' % self.options['lhapdf']
4317
# this will be removed once some issues in lhapdf6 will be fixed
4318
if lhapdf_version.startswith('6.0'):
4319
raise MadGraph5Error('LHAPDF 6.0.x not supported. Please use v6.1 or later')
4320
return lhapdf_version
4286
4323
def get_lhapdf_version(self):
4287
4324
"""returns the lhapdf version number"""
4288
4325
if not hasattr(self, 'lhapdfversion'):
4290
self.lhapdf_version = \
4291
subprocess.Popen([self.options['lhapdf'], '--version'],
4292
stdout = subprocess.PIPE).stdout.read().strip()
4293
except OSError, error:
4294
if error.errno == 2:
4295
raise Exception, 'lhapdf executable (%s) is not found on your system. Please install it and/or indicate the path to the correct executable in input/mg5_configuration.txt' % self.options['lhapdf']
4299
# this will be removed once some issues in lhapdf6 will be fixed
4300
if self.lhapdf_version.startswith('6.0'):
4301
raise MadGraph5Error('LHAPDF 6.0.x not supported. Please use v6.1 or later')
4326
self.lhapdf_version = self.get_lhapdf_version_static(self.options['lhapdf'])
4302
4327
return self.lhapdf_version
4305
def get_lhapdf_pdfsetsdir(self):
4306
lhapdf_version = self.get_lhapdf_version()
4330
def get_lhapdf_pdfsetsdir_static(lhapdf_config, lhapdf_version=None):
4332
if not lhapdf_version:
4333
lhapdf_version = CommonRunCmd.get_lhapdf_version_static(lhapdf_config)
4308
4335
# check if the LHAPDF_DATA_PATH variable is defined
4309
4336
if 'LHAPDF_DATA_PATH' in os.environ.keys() and os.environ['LHAPDF_DATA_PATH']:
4310
4337
datadir = os.environ['LHAPDF_DATA_PATH']
4311
4338
elif lhapdf_version.startswith('5.'):
4312
datadir = subprocess.Popen([self.options['lhapdf'], '--pdfsets-path'],
4339
datadir = subprocess.Popen([lhapdf_config, '--pdfsets-path'],
4313
4340
stdout = subprocess.PIPE).stdout.read().strip()
4315
4342
elif lhapdf_version.startswith('6.'):
4316
datadir = subprocess.Popen([self.options['lhapdf'], '--datadir'],
4343
datadir = subprocess.Popen([lhapdf_config, '--datadir'],
4317
4344
stdout = subprocess.PIPE).stdout.read().strip()
4319
4346
if ':' in datadir:
4355
def get_lhapdf_pdfsetsdir(self):
4357
lhapdf_version = self.get_lhapdf_version()
4358
return self.get_lhapdf_pdfsetsdir_static(self.options['lhapdf'], lhapdf_version)
4328
4360
############################################################################
4329
4361
def get_Pdir(self):
4330
4362
"""get the list of Pdirectory if not yet saved."""