Changeset View
Changeset View
Standalone View
Standalone View
scripts/convertDecayFile.py
- This file was moved from convertDecayFile.py.
#!/usr/bin/python | #!/usr/bin/env python | ||||
######################################################################## | ######################################################################## | ||||
# Copyright 1998-2020 CERN for the benefit of the EvtGen authors # | # Copyright 1998-2020 CERN for the benefit of the EvtGen authors # | ||||
# # | # # | ||||
# This file is part of EvtGen. # | # This file is part of EvtGen. # | ||||
# # | # # | ||||
# EvtGen is free software: you can redistribute it and/or modify # | # EvtGen is free software: you can redistribute it and/or modify # | ||||
# it under the terms of the GNU General Public License as published by # | # it under the terms of the GNU General Public License as published by # | ||||
▲ Show 20 Lines • Show All 224 Lines • ▼ Show 20 Lines | #precheck for a semicolon to save ourselves a bit of work | ||||
previousLine = line | previousLine = line | ||||
getMore = True | getMore = True | ||||
continue | continue | ||||
for x in range(len(words)): | for x in range(len(words)): | ||||
if words[x][-1] == ';': | if words[x][-1] == ';': | ||||
daughtersList.append(words[x][:-1]) | daughtersList.append(words[x][:-1]) | ||||
if len(words) > x+1: | if len(words) > x+1: | ||||
print words[x+1:] | print(words[x+1:]) | ||||
line = " ".join(words[x+1:]) | line = " ".join(words[x+1:]) | ||||
else: | else: | ||||
getMore = True | getMore = True | ||||
break | break | ||||
else: | else: | ||||
daughtersList.append(words[x]) | daughtersList.append(words[x]) | ||||
daughters = " ".join(daughtersList) | daughters = " ".join(daughtersList) | ||||
fh2.write("\t\t<channel daughters=\""+daughters+"\"/>\n"); | fh2.write("\t\t<channel daughters=\""+daughters+"\"/>\n"); | ||||
▲ Show 20 Lines • Show All 368 Lines • ▼ Show 20 Lines | #######PYTHIA6################ | ||||
previousLine = line | previousLine = line | ||||
getMore = True | getMore = True | ||||
continue | continue | ||||
s1 = words[1].find("(") | s1 = words[1].find("(") | ||||
s2 = words[1].find(")") | s2 = words[1].find(")") | ||||
s3 = words[1].find("=") | s3 = words[1].find("=") | ||||
if s1 == -1 or s2 == -1 or s3 == -1: | if s1 == -1 or s2 == -1 or s3 == -1: | ||||
countBad += 1 | countBad += 1 | ||||
print "bad line: "+words[0]+" "+words[1]+" copied as comment, please fix manually!\n" | print("bad line: "+words[0]+" "+words[1]+" copied as comment, please fix manually!\n") | ||||
fh2.write("\t<!--TODO "+words[0]+" "+words[1]+" -->\n") | fh2.write("\t<!--TODO "+words[0]+" "+words[1]+" -->\n") | ||||
else: | else: | ||||
countPythia6 += 1 | countPythia6 += 1 | ||||
fh2.write("\t<pythia6Param generator=\"BOTH\" module=\""+ words[1][:s1] +"\" param=\""+ words[1][s1+1:s2] +"\" value=\""+ words[1][s3+1:] +"\"/>\n") | fh2.write("\t<pythia6Param generator=\"BOTH\" module=\""+ words[1][:s1] +"\" param=\""+ words[1][s1+1:s2] +"\" value=\""+ words[1][s3+1:] +"\"/>\n") | ||||
module = words[1].split("(")[0] | module = words[1].split("(")[0] | ||||
if len(words) > 2: | if len(words) > 2: | ||||
line = " ".join(words[2:]) | line = " ".join(words[2:]) | ||||
else: | else: | ||||
Show All 33 Lines | #######END#################### | ||||
if blattWeisskopfBirth: | if blattWeisskopfBirth: | ||||
toWrite += " blattWeisskopfBirth=\""+blattWeisskopfBirth+"\"" | toWrite += " blattWeisskopfBirth=\""+blattWeisskopfBirth+"\"" | ||||
toWrite += "/>\n" | toWrite += "/>\n" | ||||
fh2.write(toWrite) | fh2.write(toWrite) | ||||
fh2.write("</data>") | fh2.write("</data>") | ||||
break | break | ||||
else: | else: | ||||
countBad += 1 | countBad += 1 | ||||
print "bad line: "+line+"copied as comment, please fix manually!\n" | print("bad line: "+line+"copied as comment, please fix manually!\n") | ||||
fh2.write("<!--TODO "+line[:-1]+"-->\n") | fh2.write("<!--TODO "+line[:-1]+"-->\n") | ||||
getMore = True | getMore = True | ||||
if comments: | if comments: | ||||
print str(countComment)+" commented lines copied without modification" | print(str(countComment)+" commented lines copied without modification") | ||||
else: | else: | ||||
print str(countComment)+" commented lines ignored" | print(str(countComment)+" commented lines ignored") | ||||
print str(count)+" other lines converted including:" | print(str(count)+" other lines converted including:") | ||||
print str(countDec)+" decays" | print(str(countDec)+" decays") | ||||
print str(countParticle)+" modified particles" | print(str(countParticle)+" modified particles") | ||||
print str(countAlias)+" aliases" | print(str(countAlias)+" aliases") | ||||
print str(countModelAlias)+" model aliases" | print(str(countModelAlias)+" model aliases") | ||||
print str(countDef)+" definitions" | print(str(countDef)+" definitions") | ||||
print str(countConj)+" conjugates" | print(str(countConj)+" conjugates") | ||||
print str(countConjDecay)+" conjugate decays" | print(str(countConjDecay)+" conjugate decays") | ||||
print str(countLineShapePW)+" line shape PWs" | print(str(countLineShapePW)+" line shape PWs") | ||||
print str(countPhotos)+" PHOTOS lines" | print(str(countPhotos)+" PHOTOS lines") | ||||
print str(countCopyDec)+" copied decays" | print(str(countCopyDec)+" copied decays") | ||||
print str(countRemoveDec)+" removed decays" | print(str(countRemoveDec)+" removed decays") | ||||
print str(countPythia6)+" pythia commands" | print(str(countPythia6)+" pythia commands") | ||||
print str(countBad)+" bad lines!" | print(str(countBad)+" bad lines!") | ||||
fh1.close() | fh1.close() | ||||
fh2.close() | fh2.close() | ||||
################## | ################## | ||||
args = sys.argv | args = sys.argv | ||||
extraFiles = [] | extraFiles = [] | ||||
if len(args) == 1: | if len(args) == 1: | ||||
Show All 14 Lines |