Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F7878584
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
18 KB
Subscribers
None
View Options
diff --git a/MatrixElement/Matchbox/External/GoSam/GoSamHelper.py b/MatrixElement/Matchbox/External/GoSam/GoSamHelper.py
--- a/MatrixElement/Matchbox/External/GoSam/GoSamHelper.py
+++ b/MatrixElement/Matchbox/External/GoSam/GoSamHelper.py
@@ -1,63 +1,79 @@
#! /usr/bin/env python
-import os,sys,glob,errno,shutil,argparse,time
+import os,sys,glob,errno,shutil,time
+from optparse import OptionParser # should be argparse replace options by args
+
# helper to replace all sourceText in fileName with replaceText
def replacetext(fileName, sourceText, replaceText):
file = open(fileName, "r")
text = file.read()
file.close()
file = open(fileName, "w")
file.write(text.replace(sourceText, replaceText))
file.close()
# helper to build recursivly path
def mkdir_p(path):
try:
os.makedirs(path)
except OSError as exc: # Python >2.5
if exc.errno == errno.EEXIST and os.path.isdir(path):
pass
else: raise
# helper to find all files of with name in path
def find(name, path):
for root, dirs, files in os.walk(path):
if name in files:
return os.path.join(root, name)
-parser = argparse.ArgumentParser()
-parser.add_argument('--usrinfile', help='usrinfile')
-parser.add_argument('--infile', help='infile')
-parser.add_argument('--definfile', help='definfile')
-parser.add_argument('--formtempdir', help='formtempdir')
-parser.add_argument('--reduction', help='reduction')
-parser.add_argument('--formopt', help='formopt')
-parser.add_argument('--higgseff', help='higgseff')
-parser.add_argument('--makelink', help='makelink', action="store_true")
-parser.add_argument('--makelinkfrom', help='makelinkfrom')
-parser.add_argument('--makelinkto', help='makelinkto')
+#parser = argparse.ArgumentParser()
+#parser.add_argument('--usrinfile', help='usrinfile')
+#parser.add_argument('--infile', help='infile')
+#parser.add_argument('--definfile', help='definfile')
+#parser.add_argument('--formtempdir', help='formtempdir')
+#parser.add_argument('--reduction', help='reduction')
+#parser.add_argument('--formopt', help='formopt')
+#parser.add_argument('--higgseff', help='higgseff')
+#parser.add_argument('--makelink', help='makelink', action="store_true")
+#parser.add_argument('--makelinkfrom', help='makelinkfrom')
+#parser.add_argument('--makelinkto', help='makelinkto')
+#args = parser.parse_args()
-args = parser.parse_args()
+
+parser = OptionParser()
+parser.add_option("-a",'--usrinfile' ,dest='usrinfile' , help='usrinfile')
+parser.add_option("-b",'--infile' ,dest='infile' , help='infile')
+parser.add_option("-c",'--definfile' ,dest='definfile' , help='definfile')
+parser.add_option("-d",'--formtempdir' ,dest='formtempdir' , help='formtempdir')
+parser.add_option("-e",'--reduction' ,dest='reduction' , help='reduction')
+parser.add_option("-f",'--formopt' ,dest='formopt' , help='formopt')
+parser.add_option("-g",'--higgseff' ,dest='higgseff' , help='higgseff')
+parser.add_option("-i",'--makelink' ,dest='makelink' , default=False, help='makelink', action="store_true")
+parser.add_option("-j",'--makelinkfrom',dest='makelinkfrom' , help='makelinkfrom')
+parser.add_option("-k",'--makelinkto' ,dest='makelinkto' , help='makelinkto')
+(options, args) = parser.parse_args()
-if args.makelink and not os.path.islink(args.makelinkto):
- os.symlink(args.makelinkfrom,args.makelinkto)
+
+if options.makelink and not os.path.islink(options.makelinkto):
+ os.symlink(options.makelinkfrom,options.makelinkto)
exit()
-if not os.path.isfile(args.usrinfile):
- shutil.copyfile(args.definfile, args.infile)
+if not os.path.isfile(options.usrinfile):
+ shutil.copyfile(options.definfile, options.infile)
-if os.path.isfile(args.usrinfile):
- shutil.copyfile(args.usrinfile, args.infile)
+if os.path.isfile(options.usrinfile):
+ shutil.copyfile(options.usrinfile, options.infile)
-replacetext(args.infile,"@MODEL@", "model="+args.higgseff)
-replacetext(args.infile,"@REDUCTIONPROGRAMS@", args.reduction)
-replacetext(args.infile, "@FORMOPT@", args.formopt)
-replacetext(args.infile, "@FORMTEMPDIR@", args.formtempdir)
+replacetext(options.infile,"@MODEL@", "model="+options.higgseff)
+replacetext(options.infile,"@REDUCTIONPROGRAMS@", options.reduction)
+replacetext(options.infile, "@FORMOPT@", options.formopt)
+replacetext(options.infile, "@FORMTEMPDIR@", options.formtempdir)
diff --git a/MatrixElement/Matchbox/External/MadGraph/mg2Matchbox.py.in b/MatrixElement/Matchbox/External/MadGraph/mg2Matchbox.py.in
--- a/MatrixElement/Matchbox/External/MadGraph/mg2Matchbox.py.in
+++ b/MatrixElement/Matchbox/External/MadGraph/mg2Matchbox.py.in
@@ -1,336 +1,355 @@
#! /usr/bin/env python
-import os,sys,glob,errno,shutil,argparse,time
-
+import os,sys,glob,errno,shutil,time #argparse
+from optparse import OptionParser
# helper to replace all sourceText in fileName with replaceText
def replacetext(fileName, sourceText, replaceText):
file = open(fileName, "r")
text = file.read()
file.close()
file = open(fileName, "w")
file.write(text.replace(sourceText, replaceText))
file.close()
# helper to build recursivly path
def mkdir_p(path):
try:
os.makedirs(path)
except OSError as exc: # Python >2.5
if exc.errno == errno.EEXIST and os.path.isdir(path):
pass
else: raise
# helper to find all files of with name in path
def find(name, path):
for root, dirs, files in os.walk(path):
if name in files:
return os.path.join(root, name)
# fill the proc.dat file from BornAmplitudes.dat and VirtAmplitudes.dat.
def fillprocs(model,oras,orew):
bornlist=[]
virtlist=[]
fileproc=open("proc.dat","w")
fileproc.write("set fortran_compiler @FC@\n")
fileproc.write("import model "+model+"\n")
borns="BornAmplitudes.dat"
virts="VirtAmplitudes.dat"
first=True
procnr=0
virtlines=""
bornlines=""
minlegs=100
legs=0
for i in [borns, virts]:
file = open(i, "r")
for line in file:
if (len(line.split(" "))<minlegs):
minlegs=len(line.split(" "))
for it in line.split(" "):
if it.replace("-","").isdigit():
legs+=1
file.close()
#conversion for heft model to go from (2QCD+1QED)->1HIG for each FS HIGGS.
HIG=0
if (model=="heft"):
HIG=(int(oras)+int(orew)-legs+2)/2
if (int(oras)+int(orew)-legs+2)%2!=0:
print "Warning: No possible coupling power:(int(oras)+int(orew)-legs+2)%2!=0 "
exit()
return
file = open(borns, "r")
for line in file:
#this assumes extra QCD emmissions
addalphas=len(line.split(" "))-minlegs
linetmp=line.rstrip()
procnr+=1
bornlist+=[str(procnr)]
if first:
if HIG ==0 :
bornlines+="generate "+linetmp+" QCD="+str(int(oras)+addalphas)+" QED="+str(orew)+" @"+str(procnr)+"\n"
else:
bornlines+="generate "+linetmp+" HIG="+str(HIG)+" QCD="+str(int(oras)+addalphas-2*HIG)+" QED="+str(int(orew)-HIG)+" @"+str(procnr)+"\n"
first=False
else:
if HIG ==0 :
bornlines+="add process "+linetmp+" QCD="+str(int(oras)+addalphas)+" QED="+str(orew)+" @"+str(procnr)+"\n"
else:
bornlines+="add process "+linetmp+" HIG="+str(HIG)+" QCD="+str(int(oras)+addalphas-2*HIG)+" QED="+str(int(orew)-HIG)+" @"+str(procnr)+"\n"
file.close()
first=True
file = open(virts, "r")
for line in file:
addalphas=len(line.split(" "))-minlegs
linetmp=line.rstrip()+" QED="+str(int(orew))+" [ virt=QCD ]"
procnr+=1
virtlist+=[str(procnr)]
if first:
virtlines+="generate "+linetmp+" @"+str(procnr)+"\n"
first=False
else:
virtlines+="add process "+linetmp+" @"+str(procnr)+"\n"
file.close()
fileproc.write(bornlines)
if virtlines!="" and bornlines!="":
fileproc.write("output matchbox MG5 --postpone_model\n")
fileproc.write(virtlines)
fileproc.write("output matchbox MG5 -f\n")
fileproc.close()
return bornlist,virtlist
def build_matchbox_tmp(pwd,buildpath):
cwd=os.getcwd()
os.chdir(pwd)
mkdir_p(pwd+"/Herwig/MG_tmp/")
if not buildpath.startswith("/"):
buildpath=pwd+"/"+buildpath.lstrip("./")
resources=glob.glob(buildpath +"/MG5/SubProcesses/MadLoop5_resources/*")
resources+=glob.glob(buildpath +"/MG5/Cards/*")
resources+=glob.glob(buildpath +"/MG5/Cards/SubProcesses/*")
for i in resources:
if not os.path.isfile( pwd+"/Herwig/MG_tmp/"+os.path.basename(i)) \
and not os.path.islink( pwd+"/Herwig/MG_tmp/"+os.path.basename(i)):
os.symlink(i, pwd+"/Herwig/MG_tmp/"+os.path.basename(i))
os.chdir(cwd)
-
-parser = argparse.ArgumentParser()
-parser.add_argument('--buildpath', help='installpath')
-parser.add_argument('--build', help='build', action="store_true")
-parser.add_argument('--madgraph', help='madgraph_installpath')
-parser.add_argument('--runpath', help='runpath')
-parser.add_argument('--model', help='model')
-parser.add_argument('--orderas', help='orderas')
-parser.add_argument('--orderew', help='orderew')
-parser.add_argument('--datadir', help='datadir')
-args = parser.parse_args()
+
+
+parser = OptionParser()
+parser.add_option("-a", "--buildpath", dest="buildpath",help="Do not use this script. Only for Herwig internal use. ")
+parser.add_option("-b", "--build", action="store_true", dest="build", default=True,help="Do not use this script. Only for Herwig internal use.")
+parser.add_option("-c", "--madgraph", dest="madgraph",help="Do not use this script. Only for Herwig internal use.")
+parser.add_option("-d", "--runpath", dest="runpath",help="Do not use this script. Only for Herwig internal use.")
+parser.add_option("-e", "--model", dest="model",help="Do not use this script. Only for Herwig internal use.")
+parser.add_option("-f", "--orderas", dest="orderas",help="Do not use this script. Only for Herwig internal use.")
+parser.add_option("-g", "--orderew", dest="orderew",help="Do not use this script. Only for Herwig internal use.")
+parser.add_option("-i", "--datadir",dest="datadir",help="Do not use this script. Only for Herwig internal use.")
+
+
+(options, args) = parser.parse_args()
+
+
+
+
+
+
+#parser = argparse.ArgumentParser()
+#parser.add_argument('--buildpath', help='installpath')
+#parser.add_argument('--build', help='build', action="store_true")
+#parser.add_argument('--madgraph', help='madgraph_installpath')
+#parser.add_argument('--runpath', help='runpath')
+#parser.add_argument('--model', help='model')
+#parser.add_argument('--orderas', help='orderas')
+#parser.add_argument('--orderew', help='orderew')
+#parser.add_argument('--datadir', help='datadir')
+#args = parser.parse_args()
pwd=os.getcwd()
param_card=""
mkdir_p(pwd+"/Herwig/MG_tmp/")
-if args.model=="loop_sm" or args.model=="heft":
+if options.model=="loop_sm" or options.model=="heft":
- if args.model=="loop_sm":
+ if options.model=="loop_sm":
param_card="param_card.dat"
else:
- param_card="param_card_"+args.model+".dat"
+ param_card="param_card_"+options.model+".dat"
- file = open("%s/MadGraphInterface/%s.in" % (args.datadir,param_card) , "r")
+ file = open("%s/MadGraphInterface/%s.in" % (options.datadir,param_card) , "r")
paramcard = file.read()
file.close()
- file = open(args.runpath+"/"+param_card, "w")
+ file = open(options.runpath+"/"+param_card, "w")
- params=open(args.runpath+"/MG-Parameter.dat", "r")
+ params=open(options.runpath+"/MG-Parameter.dat", "r")
for line in params:
a=line.split()
paramcard=paramcard.replace(a[0],a[1])
params.close()
file.write(paramcard)
file.close()
else:
print "---------------------------------------------------------------"
print "---------------------------------------------------------------"
print "Warning: The model set for the MadGraph Interface "
print " needs a parameter setting by hand."
- print " Please fill the param_card_"+args.model+".dat"
+ print " Please fill the param_card_"+options.model+".dat"
print " with your favourite assumptions."
print " And make sure Herwig uses the same parameters."
print "---------------------------------------------------------------"
print "---------------------------------------------------------------"
- if os.path.isfile(args.buildpath +"/MG5/Cards/param_card.dat") and not os.path.isfile(args.runpath+"/"+"param_card_"+args.model+".dat"):
- shutil.copyfile(args.buildpath +"/MG5/Cards/param_card.dat", args.runpath+"/"+"param_card_"+args.model+".dat")
+ if os.path.isfile(options.buildpath +"/MG5/Cards/param_card.dat") and not os.path.isfile(options.runpath+"/"+"param_card_"+options.model+".dat"):
+ shutil.copyfile(options.buildpath +"/MG5/Cards/param_card.dat", options.runpath+"/"+"param_card_"+options.model+".dat")
time.sleep(1)
-if not os.path.isdir(args.buildpath):
+if not os.path.isdir(options.buildpath):
print "The MadGraph Install path was not existend. It has been created for you."
print "Just start Herwig++ read again.."
- mkdir_p(args.buildpath)
+ mkdir_p(options.buildpath)
exit()
-os.chdir(args.buildpath)
+os.chdir(options.buildpath)
if os.path.isfile("InterfaceMadGraph.so"):
- build_matchbox_tmp(pwd,args.buildpath)
+ build_matchbox_tmp(pwd,options.buildpath)
exit()
-Bornlist,Virtlist=fillprocs(args.model,args.orderas,args.orderew)
+Bornlist,Virtlist=fillprocs(options.model,options.orderas,options.orderew)
-if not args.madgraph and not os.path.isfile("InterfaceMadGraph.so"):
+if not options.madgraph and not os.path.isfile("InterfaceMadGraph.so"):
print "*** warning *** MadGraph build failed, check logfile for details"
exit()
-os.system("python "+args.madgraph+"/mg5_aMC proc.dat")
+os.system("python "+options.madgraph+"/mg5_aMC proc.dat")
routines=[["","BORN(momenta,hel)"],
["","SLOOPMATRIX(momenta,virt)"],
["","GET_JAMP(color,Jamp)"],
["","GET_LNJAMP(color,Jamp)"],
["","GET_NCOL(color)"],
["","GET_NCOLOR(i,j,color)"]]
for routine in routines:
for i in Bornlist + list(set(Virtlist) - set(Bornlist)):
if routine[1]=="Virt(amp)" or routine[1]=="SLOOPMATRIX(momenta,virt)" and i not in Virtlist:
continue
if routine[0]=="":
routine[0]+=" SELECT CASE (proc) \n"
routine[0]+=" CASE("+i+") \n CALL "
routine[0]+= "MG5_"+i+"_"+routine[1]+"\n"
else:
routine[0]+=" CASE("+i+") \n"\
" CALL "
routine[0]+= "MG5_"+i+"_"+routine[1]+"\n"
if routine[0]!="":
routine[0]+=" CASE DEFAULT\n"
routine[0]+=" WRITE(*,*) '##W02A WARNING No id found '\n"
routine[0]+=" END SELECT \n"
-shutil.copyfile("%s/MadGraphInterface/InterfaceMadGraph.f.in" % args.datadir, "InterfaceMadGraph.f")
+shutil.copyfile("%s/MadGraphInterface/InterfaceMadGraph.f.in" % options.datadir, "InterfaceMadGraph.f")
replacetext("InterfaceMadGraph.f","MG_CalculateBORNtxt",routines[0][0])
replacetext("InterfaceMadGraph.f","MG_CalculateVIRTtxt",routines[1][0])
replacetext("InterfaceMadGraph.f","MG_Jamptxt", routines[2][0])
replacetext("InterfaceMadGraph.f","MG_LNJamptxt", routines[3][0])
replacetext("InterfaceMadGraph.f","MG_NColtxt", routines[4][0])
replacetext("InterfaceMadGraph.f","MG_ColourMattxt",routines[5][0])
MG_vxxxxxtxt=""
if routines[1][0]!="":
MG_vxxxxxtxt=""" subroutine MG_vxxxxx(p, n,inc,VC)
$ bind(c, name='MG_vxxxxx')
IMPLICIT NONE
double precision p(0:3)
double precision n(0:3)
INTEGER inc
double precision VC(0:7)
double complex VCtmp(8)
call vxxxxx(p, 0d0,1,inc ,VCtmp)
VC(0)= real(VCtmp(5))
VC(1)=aimag(VCtmp(5))
VC(2)= real(VCtmp(6))
VC(3)=aimag(VCtmp(6))
VC(4)= real(VCtmp(7))
VC(5)=aimag(VCtmp(7))
VC(6)= real(VCtmp(8))
VC(7)=aimag(VCtmp(8))
END"""
else:
MG_vxxxxxtxt=""" subroutine MG_vxxxxx(p, n,inc,VC)
$ bind(c, name='MG_vxxxxx')
IMPLICIT NONE
double precision p(0:3)
double precision n(0:3)
INTEGER inc
double precision VC(0:7)
double complex VCtmp(6)
call vxxxxx(p, 0d0,1,inc ,VCtmp)
VC(0)= real(VCtmp(3))
VC(1)=aimag(VCtmp(3))
VC(2)= real(VCtmp(4))
VC(3)=aimag(VCtmp(4))
VC(4)= real(VCtmp(5))
VC(5)=aimag(VCtmp(5))
VC(6)= real(VCtmp(6))
VC(7)=aimag(VCtmp(6))
END"""
replacetext("InterfaceMadGraph.f","MG_vxxxxxtxt",MG_vxxxxxtxt)
make=" "
fortanfiles=glob.glob('*/*/*.f')+glob.glob('*/*/*/*.f')
for i in fortanfiles:
if "check_sa" not in i:
if not os.path.islink(i):
make += " "+i+"\\\n "
incfiles=glob.glob('*/*/*.inc')+glob.glob('*/*/*/*.inc')
coefdir=""
for i in incfiles:
if "nexternal.inc" in i:
coefdir+=" -I"+i.replace("nexternal.inc"," ")
file=open("makefile","w")
file.write("include MG5/Source/make_opts ")
if Virtlist!=[]:
file.write("\nLIBDIR = MG5/lib\nLINKLIBS = -L$(LIBDIR) -lcts -liregi -L$(LIBDIR)/golem95_lib -lgolem")
file.write("\nLIBS = $(LIBDIR)libcts.$(libext) $(LIBDIR)libgolem.$(libext) $(LIBDIR)libiregi.$(libext)")
file.write("\nPROCESS= InterfaceMadGraph.f "+make+"\n\nall: \n\t @FC@ @FFLAGS@ -w -fbounds-check -ffixed-line-length-132 -fPIC -fno-f2c -shared -s -o InterfaceMadGraph.so -IMG5/SubProcesses/" )
if Virtlist!=[]:
file.write(" -IMG5/lib/golem95_include ")
if coefdir != "":
file.write(coefdir)
file.write(" $(PROCESS) $(LINKLIBS) ")
file.close()
os.chdir(pwd)
-os.chdir(args.buildpath)
+os.chdir(options.buildpath)
replacetext("MG5/Source/MODEL/lha_read.f", "ident_card.dat","Herwig/MG_tmp/ident_card.dat")
replacetext("MG5/Source/MODEL/lha_read.f", "param.log","Herwig/MG_tmp/param.log")
if Virtlist!=[]:
replacetext("MG5/SubProcesses/MadLoopCommons.f", "PREFIX='./'","PREFIX='./Herwig/MG_tmp/'")
os.system("make")
-build_matchbox_tmp(pwd,args.buildpath)
+build_matchbox_tmp(pwd,options.buildpath)
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Tue, Nov 19, 6:22 PM (1 d, 21 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3805574
Default Alt Text
(18 KB)
Attached To
rHERWIGHG herwighg
Event Timeline
Log In to Comment