965
964
self.check_plot(args)
966
965
logger.info('plot for run %s' % self.run_name)
968
self.ask_edit_cards([], args, plot=True)
968
self.ask_edit_cards([], args, plot=True)
970
970
if any([arg in ['parton'] for arg in args]):
971
971
filename = pjoin(self.me_dir, 'Events', self.run_name, 'events.lhe')
972
972
if os.path.exists(filename+'.gz'):
973
os.system('gunzip -f %s' % (filename+'.gz') )
973
misc.gunzip(filename)
974
974
if os.path.exists(filename):
975
975
logger.info('Found events.lhe file for run %s' % self.run_name)
976
976
shutil.move(filename, pjoin(self.me_dir, 'Events', 'unweighted_events.lhe'))
977
977
self.create_plot('parton')
978
978
shutil.move(pjoin(self.me_dir, 'Events', 'unweighted_events.lhe'), filename)
979
os.system('gzip -f %s' % filename)
981
981
if any([arg in ['all','parton'] for arg in args]):
982
982
filename = pjoin(self.me_dir, 'Events', self.run_name, 'MADatNLO.top')
1022
1022
filename = filenames[0]
1023
os.system('gunzip -c -f %s > %s' % (filename,
1024
pjoin(self.me_dir, 'Events','pythia_events.hep')))
1023
misc.gunzip(filename, keep=True, stdout=pjoin(self.me_dir, 'Events','pythia_events.hep'))
1026
1025
if not os.path.exists(pjoin(self.me_dir, 'Cards', 'pythia_card.dat')):
1027
files.cp(pjoin(self.me_dir, 'Cards', 'pythia_card_default.dat'),
1026
if aMCatNLO and not self.options['mg5_path']:
1027
raise "plotting NLO HEP file needs MG5 utilities"
1029
files.cp(pjoin(self.options['mg5_path'], 'Template','LO', 'Cards', 'pythia_card_default.dat'),
1028
1030
pjoin(self.me_dir, 'Cards', 'pythia_card.dat'))
1029
1031
self.run_hep2lhe()
1031
1033
filename = filenames[0]
1032
os.system('gunzip -c -f %s > %s' % (filename,
1033
pjoin(self.me_dir, 'Events','pythia_events.lhe')))
1034
self.create_plot('Pythia')
1034
misc.gunzip(filename, keep=True, stdout=pjoin(self.me_dir, 'Events','pythia_events.hep'))
1036
self.create_plot('shower')
1035
1037
lhe_file_name = filename.replace('.hep.gz', '.lhe')
1036
1038
shutil.move(pjoin(self.me_dir, 'Events','pythia_events.lhe'),
1038
os.system('gzip -f %s' % lhe_file_name)
1040
misc.gzip(lhe_file_name)
1040
1042
if any([arg in ['all','pgs'] for arg in args]):
1041
1043
filename = pjoin(self.me_dir, 'Events', self.run_name,
1042
1044
'%s_pgs_events.lhco' % self.run_tag)
1043
1045
if os.path.exists(filename+'.gz'):
1044
os.system('gunzip -f %s' % (filename+'.gz') )
1046
misc.gunzip(filename)
1045
1047
if os.path.exists(filename):
1046
1048
self.create_plot('PGS')
1047
os.system('gzip -f %s' % filename)
1049
1051
logger.info('No valid files for pgs plot')
1052
1054
filename = pjoin(self.me_dir, 'Events', self.run_name,
1053
1055
'%s_delphes_events.lhco' % self.run_tag)
1054
1056
if os.path.exists(filename+'.gz'):
1055
os.system('gunzip -f %s' % (filename+'.gz') )
1057
misc.gunzip(filename)
1056
1058
if os.path.exists(filename):
1057
1059
#shutil.move(filename, pjoin(self.me_dir, 'Events','delphes_events.lhco'))
1058
1060
self.create_plot('Delphes')
1059
1061
#shutil.move(pjoin(self.me_dir, 'Events','delphes_events.lhco'), filename)
1060
os.system('gzip -f %s' % filename)
1062
1064
logger.info('No valid files for delphes plot')
1230
1235
self.update_status('', level='all', update_results=True)
1237
def print_results_in_shell(self, data):
1238
"""Have a nice results prints in the shell,
1239
data should be of type: gen_crossxhtml.OneTagResults"""
1242
logger.info(" === Results Summary for run: %s tag: %s ===\n" % (data['run_name'],data['tag']))
1243
if self.ninitial == 1:
1244
logger.info(" Width : %.4g +- %.4g GeV" % (data['cross'], data['error']))
1246
logger.info(" Cross-section : %.4g +- %.4g pb" % (data['cross'], data['error']))
1247
logger.info(" Nb of events : %s" % data['nb_event'] )
1248
#if data['cross_pythia'] and data['nb_event_pythia']:
1249
# if self.ninitial == 1:
1250
# logger.info(" Matched Width : %.4g +- %.4g GeV" % (data['cross_pythia'], data['error_pythia']))
1252
# logger.info(" Matched Cross-section : %.4g +- %.4g pb" % (data['cross_pythia'], data['error_pythia']))
1253
# logger.info(" Nb of events after Matching : %s" % data['nb_event_pythia'])
1254
# if self.run_card['use_syst'] in self.true:
1255
# logger.info(" Be carefull that matched information are here NOT for the central value. Refer to SysCalc output for it")
1258
def print_results_in_file(self, data, path, mode='w'):
1259
"""Have a nice results prints in the shell,
1260
data should be of type: gen_crossxhtml.OneTagResults"""
1264
fsock = open(path, mode)
1266
fsock.write(" === Results Summary for run: %s tag: %s process: %s ===\n" % \
1267
(data['run_name'],data['tag'], os.path.basename(self.me_dir)))
1269
if self.ninitial == 1:
1270
fsock.write(" Width : %.4g +- %.4g GeV\n" % (data['cross'], data['error']))
1272
fsock.write(" Cross-section : %.4g +- %.4g pb\n" % (data['cross'], data['error']))
1273
fsock.write(" Nb of events : %s\n" % data['nb_event'] )
1274
#if data['cross_pythia'] and data['nb_event_pythia']:
1275
# if self.ninitial == 1:
1276
# fsock.write(" Matched Width : %.4g +- %.4g GeV\n" % (data['cross_pythia'], data['error_pythia']))
1278
# fsock.write(" Matched Cross-section : %.4g +- %.4g pb\n" % (data['cross_pythia'], data['error_pythia']))
1279
# fsock.write(" Nb of events after Matching : %s\n" % data['nb_event_pythia'])
1234
1286
def update_random_seed(self):
1318
1372
if not options['only_generation'] and not options['reweightonly']:
1319
1373
to_always_rm.extend(to_rm)
1374
if os.path.exists(pjoin(self.me_dir, 'SubProcesses', dir,'MadLoop5_resources.tar.gz')):
1375
to_always_rm.append(pjoin(self.me_dir, 'SubProcesses', dir,'MadLoop5_resources.tar.gz'))
1320
1376
files.rm([pjoin(self.me_dir, 'SubProcesses', dir, d) for d in to_always_rm])
1322
1378
mcatnlo_status = ['Setting up grid', 'Computing upper envelope', 'Generating events']
1380
if self.run_card['iappl']=='2':
1381
self.applgrid_distribute(options,mode,p_dirs)
1324
1383
if options['reweightonly']:
1325
1384
event_norm=self.run_card['event_norm']
1326
1385
nevents=int(self.run_card['nevents'])
1327
self.reweight_and_collect_events(options, mode, nevents, event_norm)
1386
return self.reweight_and_collect_events(options, mode, nevents, event_norm)
1330
1388
devnull = os.open(os.devnull, os.O_RDWR)
1331
1389
if mode in ['LO', 'NLO']:
1529
1589
return self.reweight_and_collect_events(options, mode, nevents, event_norm)
1592
def applgrid_combine(self,cross,error):
1593
"""Combines the APPLgrids in all the SubProcess/P*/all_G*/ directories"""
1594
logger.debug('Combining APPLgrids \n')
1595
applcomb=pjoin(self.options['applgrid'].rstrip('applgrid-config'),'applgrid-combine')
1596
with open(pjoin(self.me_dir,'SubProcesses','dirs.txt')) as dirf:
1597
all_jobs=dirf.readlines()
1598
ngrids=len(all_jobs)
1599
nobs =len([name for name in os.listdir(pjoin(self.me_dir,'SubProcesses',all_jobs[0].rstrip())) \
1600
if name.endswith("_out.root")])
1601
for obs in range(0,nobs):
1602
gdir = [pjoin(self.me_dir,'SubProcesses',job.rstrip(),"grid_obs_"+str(obs)+"_out.root") for job in all_jobs]
1603
# combine APPLgrids from different channels for observable 'obs'
1604
if self.run_card["iappl"] == "1":
1605
misc.call([applcomb,'-o', pjoin(self.me_dir,"Events",self.run_name,"aMCfast_obs_"+str(obs)+"_starting_grid.root"), '--optimise']+ gdir)
1606
elif self.run_card["iappl"] == "2":
1607
unc2_inv=pow(cross/error,2)
1608
unc2_inv_ngrids=pow(cross/error,2)*ngrids
1609
misc.call([applcomb,'-o', pjoin(self.me_dir,"Events",self.run_name,"aMCfast_obs_"+str(obs)+".root"),'-s',str(unc2_inv),'--weight',str(unc2_inv)]+ gdir)
1610
for job in all_jobs:
1611
os.remove(pjoin(self.me_dir,'SubProcesses',job.rstrip(),"grid_obs_"+str(obs)+"_in.root"))
1613
raise aMCatNLOError('iappl parameter can only be 0, 1 or 2')
1614
# after combining, delete the original grids
1619
def applgrid_distribute(self,options,mode,p_dirs):
1620
"""Distributes the APPLgrids ready to be filled by a second run of the code"""
1621
# if no appl_start_grid argument given, guess it from the time stamps of the starting grid files
1622
if not('appl_start_grid' in options.keys() and options['appl_start_grid']):
1623
gfiles=glob.glob(pjoin(self.me_dir, 'Events','*','aMCfast_obs_0_starting_grid.root'))
1625
for root_file in gfiles:
1626
time_stamps[root_file]=os.path.getmtime(root_file)
1627
options['appl_start_grid']= \
1628
max(time_stamps.iterkeys(), key=(lambda key: time_stamps[key])).split('/')[-2]
1629
logger.info('No --appl_start_grid option given. Guessing that start grid from run "%s" should be used.' \
1630
% options['appl_start_grid'])
1632
if 'appl_start_grid' in options.keys() and options['appl_start_grid']:
1633
self.appl_start_grid = options['appl_start_grid']
1634
start_grid_dir=pjoin(self.me_dir, 'Events', self.appl_start_grid)
1635
# check that this dir exists and at least one grid file is there
1636
if not os.path.exists(pjoin(start_grid_dir,'aMCfast_obs_0_starting_grid.root')):
1637
raise self.InvalidCmd('APPLgrid file not found: %s' % \
1638
pjoin(start_grid_dir,'aMCfast_obs_0_starting_grid.root'))
1640
all_grids=[pjoin(start_grid_dir,name) for name in os.listdir(start_grid_dir) \
1641
if name.endswith("_starting_grid.root")]
1642
nobs =len(all_grids)
1643
gstring=" ".join(all_grids)
1644
if not hasattr(self, 'appl_start_grid') or not self.appl_start_grid:
1645
raise self.InvalidCmd('No APPLgrid name currently defined. Please provide this information.')
1650
#copy the grid to all relevant directories
1652
g_dirs = [file for file in os.listdir(pjoin(self.me_dir,"SubProcesses",pdir)) \
1653
if file.startswith(gdir) and os.path.isdir(pjoin(self.me_dir,"SubProcesses",pdir, file))]
1654
for g_dir in g_dirs:
1655
for grid in all_grids:
1656
obs=grid.split('_')[-3]
1657
files.cp(grid,pjoin(self.me_dir,"SubProcesses",pdir,g_dir,'grid_obs_'+obs+'_in.root'))
1532
1660
def collect_log_files(self, folders, istep):
1533
1661
"""collect the log files and put them in a single, html-friendly file inside the run_...
1617
1745
proc_card_lines = open(pjoin(self.me_dir, 'Cards', 'proc_card_mg5.dat')).read().split('\n')
1619
1747
for line in proc_card_lines:
1620
if line.startswith('generate'):
1621
process = line.replace('generate ', '')
1748
if line.startswith('generate') or line.startswith('add process'):
1749
process = process+(line.replace('generate ', '')).replace('add process ','')+' ; '
1622
1750
lpp = {'0':'l', '1':'p', '-1':'pbar'}
1623
1751
proc_info = '\n Process %s\n Run at %s-%s collider (%s + %s GeV)' % \
1624
(process, lpp[self.run_card['lpp1']], lpp[self.run_card['lpp2']],
1752
(process[:-3], lpp[self.run_card['lpp1']], lpp[self.run_card['lpp2']],
1625
1753
self.run_card['ebeam1'], self.run_card['ebeam2'])
1627
1755
# Gather some basic statistics for the run and extracted from the log files.
1776
1904
r"Quadruple precision used\:\s+(?P<nqdp>\d+).*"+\
1777
1905
r"Initialization phase\-space points\:\s+(?P<nini>\d+).*"+\
1778
1906
r"Unknown return code \(100\)\:\s+(?P<n100>\d+).*"+\
1779
r"Unknown return code \(10\)\:\s+(?P<n10>\d+).*"+\
1780
r"Unknown return code \(1\)\:\s+(?P<n1>\d+)",re.DOTALL)
1907
r"Unknown return code \(10\)\:\s+(?P<n10>\d+).*",re.DOTALL)
1909
unit_code_meaning = { 0 : 'Not identified (CTModeRun != -1)',
1910
1 : 'CutTools (double precision)',
1914
9 : 'CutTools (quadruple precision)'}
1915
RetUnit_finder =re.compile(
1916
r"#Unit\s*(?P<unit>\d+)\s*=\s*(?P<n_occurences>\d+)")
1782
1919
for gv_log in log_GV_files:
1783
logfile=open(gv_log,'r')
1784
UPS_stats = re.search(UPS_stat_finder,logfile.read())
1920
channel_name = '/'.join(gv_log.split('/')[-5:-1])
1921
log=open(gv_log,'r').read()
1922
UPS_stats = re.search(UPS_stat_finder,log)
1923
for retunit_stats in re.finditer(RetUnit_finder, log):
1924
if channel_name not in stats['UPS'].keys():
1925
stats['UPS'][channel_name] = [0]*10+[[0]*10]
1926
stats['UPS'][channel_name][10][int(retunit_stats.group('unit'))] \
1927
+= int(retunit_stats.group('n_occurences'))
1786
1928
if not UPS_stats is None:
1787
channel_name = '/'.join(gv_log.split('/')[-5:-1])
1789
1930
stats['UPS'][channel_name][0] += int(UPS_stats.group('ntot'))
1790
1931
stats['UPS'][channel_name][1] += int(UPS_stats.group('nsun'))
1796
1937
stats['UPS'][channel_name][7] += int(UPS_stats.group('nini'))
1797
1938
stats['UPS'][channel_name][8] += int(UPS_stats.group('n100'))
1798
1939
stats['UPS'][channel_name][9] += int(UPS_stats.group('n10'))
1799
stats['UPS'][channel_name][10] += int(UPS_stats.group('n1'))
1800
1940
except KeyError:
1801
1941
stats['UPS'][channel_name] = [int(UPS_stats.group('ntot')),
1802
1942
int(UPS_stats.group('nsun')),int(UPS_stats.group('nsps')),
1803
1943
int(UPS_stats.group('nups')),int(UPS_stats.group('neps')),
1804
1944
int(UPS_stats.group('nddp')),int(UPS_stats.group('nqdp')),
1805
1945
int(UPS_stats.group('nini')),int(UPS_stats.group('n100')),
1806
int(UPS_stats.group('n10')),int(UPS_stats.group('n1'))]
1946
int(UPS_stats.group('n10')),[0]*10]
1808
1948
if len(stats['UPS'].keys())>0:
1809
1949
nTotPS = sum([chan[0] for chan in stats['UPS'].values()],0)
1830
1971
tmpStr += '\n Only double precision used: %d'%nTotddp
1831
1972
tmpStr += '\n Quadruple precision used: %d'%nTotqdp
1832
1973
tmpStr += '\n Initialization phase-space points: %d'%nTotini
1974
tmpStr += '\n Reduction methods used:'
1975
red_methods = [(unit_code_meaning[i],nTot1[i]) for i in \
1976
unit_code_meaning.keys() if nTot1[i]>0]
1977
for method, n in sorted(red_methods, key= lambda l: l[1], reverse=True):
1978
tmpStr += '\n > %s%s%s'%(method,' '*(33-len(method)),n)
1833
1979
if nTot100 != 0:
1834
1980
debug_msg += '\n Unknown return code (100): %d'%nTot100
1835
1981
if nTot10 != 0:
1836
1982
debug_msg += '\n Unknown return code (10): %d'%nTot10
1838
debug_msg += '\n Unknown return code (1): %d'%nTot1
1983
nUnknownUnit = sum(nTot1[u] for u in range(10) if u \
1984
not in unit_code_meaning.keys())
1985
if nUnknownUnit != 0:
1986
debug_msg += '\n Unknown return code (1): %d'\
1840
1989
if maxUPS[1]>0.001:
1841
1990
message += tmpStr
2158
2309
if not os.path.exists(pjoin(self.me_dir, 'SubProcesses', filename)):
2159
2310
raise aMCatNLOError('An error occurred during event generation. ' + \
2160
2311
'The event file has not been created. Check collect_events.log')
2161
evt_file = pjoin(self.me_dir, 'Events', self.run_name, 'events.lhe')
2162
files.mv(pjoin(self.me_dir, 'SubProcesses', filename), evt_file)
2163
misc.call(['gzip', evt_file])
2312
evt_file = pjoin(self.me_dir, 'Events', self.run_name, 'events.lhe.gz')
2313
misc.gzip(pjoin(self.me_dir, 'SubProcesses', filename), stdout=evt_file)
2164
2314
if not options['reweightonly']:
2165
2315
self.print_summary(options, 2, mode, scale_pdf_info)
2166
logger.info('The %s.gz file has been generated.\n' \
2316
logger.info('The %s file has been generated.\n' % (evt_file))
2168
2317
self.results.add_detail('nb_event', nevents)
2169
2318
self.update_status('Events generated', level='parton', update_results=True)
2319
return evt_file[:-3]
2173
2322
def run_mcatnlo(self, evt_file):
2174
2323
"""runs mcatnlo on the generated event file, to produce showered-events
2176
2325
logger.info('Prepairing MCatNLO run')
2178
misc.call(['gunzip', evt_file])
2327
misc.gunzip(evt_file)
2179
2328
except Exception:
2644
2800
tag = self.run_card['run_tag']
2645
# if 'pythia' in self.to_store:
2646
# self.update_status('Storing Pythia files of Previous run', level='pythia', error=True)
2647
# os.system('mv -f %(path)s/pythia_events.hep %(path)s/%(name)s/%(tag)s_pythia_events.hep' %
2648
# {'name': self.run_name, 'path' : pjoin(self.me_dir,'Events'),
2650
# os.system('gzip -f %s/%s_pythia_events.hep' % (
2651
# pjoin(self.me_dir,'Events',self.run_name), tag))
2652
# self.to_store.remove('pythia')
2653
# self.update_status('Done', level='pythia',makehtml=False,error=True)
2655
2802
self.to_store = []
2719
2866
content += 'PDLABEL=%s\n' % pdlabel
2720
2867
content += 'ALPHAEW=%s\n' % self.banner.get_detail('param_card', 'sminputs', 1).value
2721
2868
#content += 'PDFSET=%s\n' % self.banner.get_detail('run_card', 'lhaid')
2722
content += 'PDFSET=%s\n' % max([init_dict['pdfsup1'],init_dict['pdfsup2']])
2869
#content += 'PDFSET=%s\n' % max([init_dict['pdfsup1'],init_dict['pdfsup2']])
2723
2870
content += 'TMASS=%s\n' % self.banner.get_detail('param_card', 'mass', 6).value
2724
2871
content += 'TWIDTH=%s\n' % self.banner.get_detail('param_card', 'decay', 6).value
2725
2872
content += 'ZMASS=%s\n' % self.banner.get_detail('param_card', 'mass', 23).value
2759
2906
content += 'TAUMASS=%s\n' % new_mcmass_dict['mcmass(15)']
2761
2908
content += 'GMASS=%s\n' % mcmass_dict[21]
2762
content += 'EVENT_NORM=%s\n' % self.banner.get_detail('run_card', 'event_norm')
2909
content += 'EVENT_NORM=%s\n' % self.banner.get_detail('run_card', 'event_norm').lower()
2763
2910
# check if need to link lhapdf
2764
if pdlabel == 'lhapdf':
2911
if int(self.shower_card['pdfcode']) > 1 or \
2912
(pdlabel=='lhapdf' and int(self.shower_card['pdfcode'])==1):
2913
# Use LHAPDF (should be correctly installed, because
2914
# either events were already generated with them, or the
2915
# user explicitly gives an LHAPDF number in the
2765
2917
self.link_lhapdf(pjoin(self.me_dir, 'lib'))
2766
2918
lhapdfpath = subprocess.Popen([self.options['lhapdf'], '--prefix'],
2767
stdout = subprocess.PIPE).stdout.read().strip()
2919
stdout = subprocess.PIPE).stdout.read().strip()
2768
2920
content += 'LHAPDFPATH=%s\n' % lhapdfpath
2769
2921
pdfsetsdir = self.get_lhapdf_pdfsetsdir()
2770
lhaid_list = [max([init_dict['pdfsup1'],init_dict['pdfsup2']])]
2922
if self.shower_card['pdfcode']==1:
2923
lhaid_list = [max([init_dict['pdfsup1'],init_dict['pdfsup2']])]
2924
content += 'PDFCODE=%s\n' % max([init_dict['pdfsup1'],init_dict['pdfsup2']])
2926
lhaid_list = [abs(int(self.shower_card['pdfcode']))]
2927
content += 'PDFCODE=%s\n' % self.shower_card['pdfcode']
2771
2928
self.copy_lhapdf_set(lhaid_list, pdfsetsdir)
2929
elif int(self.shower_card['pdfcode'])==1:
2930
# Try to use LHAPDF because user wants to use the same PDF
2931
# as was used for the event generation. However, for the
2932
# event generation, LHAPDF was not used, so non-trivial to
2933
# see if if LHAPDF is available with the corresponding PDF
2934
# set. If not found, give a warning and use build-in PDF
2937
lhapdfpath = subprocess.Popen([self.options['lhapdf'], '--prefix'],
2938
stdout = subprocess.PIPE).stdout.read().strip()
2939
self.link_lhapdf(pjoin(self.me_dir, 'lib'))
2940
content += 'LHAPDFPATH=%s\n' % lhapdfpath
2941
pdfsetsdir = self.get_lhapdf_pdfsetsdir()
2942
lhaid_list = [max([init_dict['pdfsup1'],init_dict['pdfsup2']])]
2943
content += 'PDFCODE=%s\n' % max([init_dict['pdfsup1'],init_dict['pdfsup2']])
2944
self.copy_lhapdf_set(lhaid_list, pdfsetsdir)
2946
logger.warning('Trying to shower events using the same PDF in the shower as used in the generation'+\
2947
' of the events using LHAPDF. However, no valid LHAPDF installation found with the'+\
2948
' needed PDF set. Will use default internal PDF for the shower instead. To use the'+\
2949
' same set as was used in the event generation install LHAPDF and set the path using'+\
2950
' "set /path_to_lhapdf/bin/lhapdf-config" from the MadGraph5_aMC@NLO python shell')
2951
content += 'LHAPDFPATH=\n'
2952
content += 'PDFCODE=0\n'
2773
#overwrite the PDFCODE variable in order to use internal pdf
2774
2954
content += 'LHAPDFPATH=\n'
2775
2955
content += 'PDFCODE=0\n'
2957
content += 'ICKKW=%s\n' % self.banner.get_detail('run_card', 'ickkw')
2958
content += 'PTJCUT=%s\n' % self.banner.get_detail('run_card', 'ptj')
2777
2959
# add the pythia8/hwpp path(s)
2778
2960
if self.options['pythia8_path']:
2779
2961
content+='PY8PATH=%s\n' % self.options['pythia8_path']
3159
3342
if os.path.exists(pjoin(self.me_dir,'SubProcesses','OLE_order.olc')):
3160
3343
input_files.append(pjoin(cwd, 'OLE_order.olc'))
3162
# LHAPDF dynamic libraries (needed for lhapdf6)
3163
lhalibs = ['libLHAPDF.dylib', 'libLHAPDF.so']
3164
for lib in [pjoin(self.me_dir, 'lib', l) for l in lhalibs \
3165
if os.path.exists(pjoin(self.me_dir, 'lib', l))]:
3166
input_files.append(lib)
3168
3345
# File for the loop (might not be present if MadLoop is not used)
3169
if os.path.exists(pjoin(cwd, 'MadLoopParams.dat')):
3170
to_add = ['MadLoopParams.dat', 'ColorDenomFactors.dat',
3171
'ColorNumFactors.dat','HelConfigs.dat']
3173
input_files.append(pjoin(cwd, name))
3175
to_check = ['HelFilter.dat','LoopFilter.dat']
3176
for name in to_check:
3177
if os.path.exists(pjoin(cwd, name)):
3178
input_files.append(pjoin(cwd, name))
3346
if os.path.exists(pjoin(cwd,'MadLoop5_resources')):
3347
input_files.append(pjoin(cwd, 'MadLoop5_resources.tar.gz'))
3348
if not os.path.exists(pjoin(cwd,'MadLoop5_resources.tar.gz')):
3349
tf=tarfile.open(pjoin(cwd,'MadLoop5_resources.tar.gz'),'w:gz',
3351
tf.add(pjoin(cwd,'MadLoop5_resources'),arcname='MadLoop5_resources')
3180
3354
Ire = re.compile("for i in ([\d\s]*) ; do")
3388
3566
except KeyError:
3569
# read the run_card to find if applgrid is used or not
3570
if self.run_card['iappl'] != '0':
3571
os.environ['applgrid'] = 'True'
3572
# check versions of applgrid and amcfast
3573
for code in ['applgrid','amcfast']:
3575
p = subprocess.Popen([self.options[code], '--version'], \
3576
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
3577
output, error = p.communicate()
3578
if code is 'applgrid' and output < '1.4.63':
3579
raise aMCatNLOError('Version of APPLgrid is too old. Use 1.4.69 or later.'\
3580
+' You are using %s',output)
3581
if code is 'amcfast' and output < '1.1.1':
3582
raise aMCatNLOError('Version of aMCfast is too old. Use 1.1.1 or later.'\
3583
+' You are using %s',output)
3585
raise aMCatNLOError(('No valid %s installation found. \n' + \
3586
'Please set the path to %s-config by using \n' + \
3587
'MG5_aMC> set <absolute-path-to-%s>/bin/%s-config \n') % (code,code,code,code))
3588
# set-up the Source/make_opts with the correct applgrid-config file
3589
appllibs=" APPLLIBS=$(shell %s --ldcflags) $(shell %s --ldflags) \n" \
3590
% (self.options['applgrid'],self.options['amcfast'])
3591
text=open(pjoin(self.me_dir,'Source','make_opts'),'r').readlines()
3594
if line.strip().startswith('APPLLIBS=$'):
3596
text_out.append(line)
3597
open(pjoin(self.me_dir,'Source','make_opts'),'w').writelines(text_out)
3600
del os.environ['applgrid']
3392
3605
os.environ['fastjet_config'] = self.options['fastjet']
3393
3606
except (TypeError, KeyError):
3455
3668
" seems to have been compiled with a different compiler than"+\
3456
3669
" the one specified in MG5_aMC. Please recompile CutTools.")
3458
# check if virtuals have been generated
3459
proc_card = open(pjoin(self.me_dir, 'Cards', 'proc_card_mg5.dat')).read()
3671
# make IREGI (only necessary with MG option output_dependencies='internal')
3672
if not os.path.exists(os.path.realpath(pjoin(libdir, 'libiregi.a'))) \
3673
and os.path.exists(pjoin(sourcedir,'IREGI')):
3674
logger.info('Compiling IREGI (can take a couple of minutes) ...')
3675
misc.compile(['IREGI'], cwd = sourcedir)
3676
logger.info(' ...done.')
3678
if os.path.exists(pjoin(libdir, 'libiregi.a')):
3679
# Verify compatibility between current compiler and the one which was
3680
# used when last compiling IREGI (if specified).
3681
compiler_log_path = pjoin(os.path.dirname((os.path.realpath(pjoin(
3682
libdir, 'libiregi.a')))),'compiler_version.log')
3683
if os.path.exists(compiler_log_path):
3684
compiler_version_used = open(compiler_log_path,'r').read()
3685
if not str(misc.get_gfortran_version(misc.detect_current_compiler(\
3686
pjoin(sourcedir,'make_opts')))) in compiler_version_used:
3687
if os.path.exists(pjoin(sourcedir,'IREGI')):
3688
logger.info('IREGI was compiled with a different fortran'+\
3689
' compiler. Re-compiling it now...')
3690
misc.compile(['cleanIR'], cwd = sourcedir)
3691
misc.compile(['IREGI'], cwd = sourcedir)
3692
logger.info(' ...done.')
3694
raise aMCatNLOError("IREGI installation in %s"\
3695
%os.path.realpath(pjoin(libdir, 'libiregi.a'))+\
3696
" seems to have been compiled with a different compiler than"+\
3697
" the one specified in MG5_aMC. Please recompile IREGI.")
3699
# check if MadLoop virtuals have been generated
3460
3700
if self.proc_characteristics['has_loops'].lower() == 'true' and \
3461
mode in ['NLO', 'aMC@NLO', 'noshower']:
3462
tests.append('check_poles')
3701
not os.path.exists(pjoin(self.me_dir,'OLP_virtuals')):
3702
os.environ['madloop'] = 'true'
3703
if mode in ['NLO', 'aMC@NLO', 'noshower']:
3704
tests.append('check_poles')
3706
os.unsetenv('madloop')
3464
3708
# make and run tests (if asked for), gensym and make madevent in each dir
3465
3709
self.update_status('Compiling directories...', level=None)
3946
4192
help="Skip compilation. Ignored if no executable is found")
3947
4193
_calculate_xsect_parser.add_option("-n", "--name", default=False, dest='run_name',
3948
4194
help="Provide a name to the run")
4195
_calculate_xsect_parser.add_option("-a", "--appl_start_grid", default=False, dest='appl_start_grid',
4196
help="For use with APPLgrid only: start from existing grids")
4197
_calculate_xsect_parser.add_option("-o", "--only_generation", default=False, action='store_true',
4198
help="Skip grid set up, just generate events starting from " + \
4199
"the last available results")
3950
4201
_shower_usage = 'shower run_name [options]\n' + \
3951
4202
'-- do shower/hadronization on parton-level file generated for run run_name\n' + \