Commit ba60a495 authored by Chen Peng's avatar Chen Peng Committed by Spyros Argyropoulos
Browse files

Add Generator List file and update checkconsistency function [skip ci]

parent 53dabbea
Pipeline #1078312 skipped
aMcAtNlo aMC
McAtNlo McAtNlo
Powheg Ph
PowHel PH
MadGraph MG
CompHep CompHep
CalcHep CalcHep
Geneva Geneva
Whizard Whizard
MCFM MCFM
JHU JHU
MEtop MEtop
Charybdis CharyBdis
Charybdis2 Charybdis2
BCVEGPY BCVEGPY
Dire4Pythia8 Dire4Pythia8
BlackMax BlackMax
QBH QBH
gg2ww gg2ww
gg2zz gg2zz
gg2vv gg2vv
HvyN HvyN
VBFNLO VBFNLO
FPMC FPMC
ProtosLHEF ProtosLHEF
BCVEGPY BCVEGPY
STRINGS STRINGS
Pythia8 Py8
Pythia8B Pythia8B
Herwig7 H7
Matchig Matchig
Pohweg Ph
Sherpa Sh
Epos Epos
QGSJet QGSJet
ParticleGenerator ParticleGenerator
ParticleGun PG
CosmicGenerator CosmicGenerator
BeamHaloGenerator BeamHaloGenerator
Starlight Starlight
Hijing Hijing
Hydjet Hydjet
Reldis Reldis
Pyquen Pyquen
HepMCAscii HepMC
EvtGen EG
ParticleDecayer PD
\ No newline at end of file
......@@ -25,11 +25,11 @@ def check_consistency(jofile):
## Check the length limit on the physicsShort portion of the filename
jo_physshortpart = joparts[1]
if len(jo_physshortpart) > 60:
print("ERROR: " + jo_physshortpart + " contains a physicsShort field of more than 60 characters: please rename.")
if len(jo_physshortpart) > 50:
print("ERROR: " + jo_physshortpart + " contains a physicsShort field of more than 50 characters: please rename.")
sys.exit(1)
else:
print("OK:" + jo_physshortpart + " physicsShort less than 60 characters long")
print("OK:" + jo_physshortpart + " physicsShort less than 50 characters long")
jo_physshortparts = jo_physshortpart.split("_")
## There must be at least 2 physicsShort sub-parts separated by '_': gens, (tune)+PDF, and process
......@@ -40,25 +40,48 @@ def check_consistency(jofile):
print("OK: 2 physicsShort parts found")
## NOTE: Further checks for generators - these need modification to work properly
# if joparts[0].startswith("mc"): #< if this is an "official" JO
# genpart = jo_physshortparts[0]
# expectedgenpart = ''.join(gennames)
# ## We want to record that HERWIG was used in metadata, but in the JO naming we just use a "Herwig" label
# expectedgenpart = expectedgenpart.replace("HerwigJimmy", "Herwig")
# def _norm(s):
# # TODO: add EvtGen to this normalization for MC14?
# return s.replace("Photospp", "").replace("Photos", "").replace("TauolaPP", "").replace("Tauolapp", "").replace("Tauola", "")
# def _norm2(s):
# return s.replace("Py", "Pythia").replace("MG","MadGraph").replace("Ph","Powheg").replace("Hpp","Herwigpp").replace("H7","Herwig7").replace("Sh","Sherpa").replace("Ag","Alpgen").replace("EG","EvtGen").replace("PG","ParticleGun").replace("Gva","Geneva")
#
# def _short2(s):
# return s.replace("Pythia","Py").replace("MadGraph","MG").replace("Powheg","Ph").replace("Herwigpp","Hpp").replace("Herwig7","H7").replace("Sherpa","Sh").replace("Alpgen","Ag").replace("EvtGen","EG").replace("PG","ParticleGun").replace("Geneva","Gva")
#
# if genpart != _norm(expectedgenpart) and _norm2(genpart) != _norm(expectedgenpart):
# print("ERROR: Expected first part of JO name to be '%s' or '%s', but found '%s'" % (_norm(expectedgenpart), _norm(_short2(expectedgenpart)), genpart))
# print("gennames '%s' " %(expectedgenpart))
# sys.exit(1)
#
#Where the Generator list files are located, need to change if the txt file is placed somewhere else.
File_path = os.path.dirname(os.path.abspath(__file__))
GenListFile = File_path+'/../common/GeneratorList.txt'
#read Generator name in a txt file in common folder.
Generators = {}
with open(GenListFile) as f:
for line in f:
(key, val) = line.split()
Generators[key] = val
print ('Generators full list:', Generators)
Generators_abb = list(Generators.values())
if joparts[0].startswith("mc"): #< if this is an "official" JO
genpart = jo_physshortparts[0]
#Check No Generator full name in physicsshort. except the for some generator doesn't have short name.
GenFullNameNo = 0
for Generator, Generator_abb in Generators.items():
if genpart.find(Generator)!=-1 and Generator!=Generator_abb:
print ("ERROR: Generator full name "+Generator+" is found, please use abbreviation "+Generator_abb)
GenFullNameNo += 1
if GenFullNameNo>0:
print ("ERROR: %s generator full names are found! Please use abbreviation instead." %GenFullNameNo)
sys.exit(1)
else:
print ("OK: No generator full name is found")
#Check No unrecognized generator abbreviation in physicsshort.
generator_list=[]
i = 0
while i<len(genpart):
for step in range(1, len(genpart)+1-i):
if genpart[i:i+step] in Generators_abb:
print ("Find "+ genpart[i:i+step])
generator_list.append(genpart[i:i+step])
i+=step
break
elif step==len(genpart)-i:
print ("Error: Not recognised generator abbreviation " + genpart[i:i+step])
sys.exit(1)
print ("Generator used: ", generator_list)
# del _norm
# ## Check if the tune/PDF part is needed, and if so whether it's present
# if not gens_notune(gennames) and len(jo_physshortparts) < 3:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment