4 from AthenaCommon.Logging
import logging
5 evgenLog = logging.getLogger(
'GenConfigHelpers')
9 LHEFGenerators = [
"Lhef",
10 "aMcAtNlo",
"McAtNlo",
"Powheg",
"MadGraph",
"CompHep",
"Geneva",
11 "MCFM",
"JHU",
"MEtop",
"BCVEGPY",
"Dire4Pythia8",
12 "BlackMax",
"QBH",
"gg2ww",
"gg2zz",
"gg2vv",
"HvyN",
13 "VBFNLO",
"FPMC",
"ProtosLHEF",
14 "BCVEGPY",
"STRINGS",
"Phantom"]
18 MainGenerators = [
"Herwig7"]
20 MainGenerators += [
"Pythia8",
"Pythia8B"]
22 MainGenerators += [
"Sherpa"]
24 MainGenerators += [
"Epos"]
26 MainGenerators += [
"ParticleGun"]
27 MainGenerators += [
"CosmicGenerator",
"BeamHaloGenerator"]
29 HIMainGenerators = [
"AMPT",
"SuperChic",
"Starlight",
"Hijing",
"Hydjet"]
32 MainGenerators += [
"HepMCAscii"]
36 AfterburnerGenerators = [
"Photospp",
"TauolaPP",
"EvtGen",
"ParticleDecayer"]
40 KnownGenerators = LHEFGenerators + HIMainGenerators +MainGenerators + AfterburnerGenerators
43 NoTestHepMCGenerators = [
"Superchic",
"ParticleDecayer",
"ParticleGun",
"CosmicGenerator",
44 "BeamHaloGenerator",
"FPMC",
"Hijing",
"Hydjet",
"Starlight"]
47 NoTuneGenerators = [
"ParticleGun",
"CosmicGenerator",
"BeamHaloGenerator",
"HepMCAscii"]
51 PurgeNoEndVtxGenerators = [
"Pythia8-Angantyr",
"Herwig7",
"Hijing"]
54 """Return a boolean of whether this set of generators requires the steering command line flag"""
55 if "EvtGen" not in gennames:
return False
56 if any((
"Pythia" in gen
and "Pythia8" not in gen)
for gen
in gennames):
return True
57 if any((
"Herwig" in gen
and "Herwig7" not in gen)
for gen
in gennames):
return True
61 """Return whether a generator name is known"""
62 return genname
in KnownGenerators
65 """Return whether all generator names are known"""
69 """Return whether a generator uses LHEF input files"""
70 return genname
in LHEFGenerators
73 """Return whether any of the generators uses LHEF input files"""
74 return any(
gen_lhef(g)
for g
in gennames)
77 """Return whether a generator should be sanity tested with TestHepMC"""
78 return genname
not in NoTestHepMCGenerators
81 """Return whether all of the generators should be sanity tested with TestHepMC"""
85 """Return whether a generator is allowed to not provide PDF and tune information"""
86 return genname
not in NoTuneGenerators
89 """Return whether all of the generators are allowed to not provide PDF and tune information"""
93 """Return whether a generator may produce unstable particles
94 without end vertex that have to be purged"""
95 return genname
in PurgeNoEndVtxGenerators
98 """Return whether any of the generators may produce unstable particles
99 without end vertex that have to be purged"""
103 """Return a key suitable for sorting a generator name by stage, then alphabetically"""
107 for istage, gens
in enumerate([LHEFGenerators, HIMainGenerators, MainGenerators,AfterburnerGenerators]):
113 return (genstage, genname)
117 import os, sys, string
119 joparts = (os.path.basename(jofile)).
split(
".")
121 if joparts[0].startswith(
"mc")
and all(c
in string.digits
for c
in joparts[0][2:]):
124 if len(joparts) != 3:
125 evgenLog.error(jofile +
" name format is wrong: must be of the form mc.<physicsShort>.py: please rename.")
128 jo_physshortpart = joparts[1]
129 if len(jo_physshortpart) > 50:
130 evgenLog.error(jofile +
" contains a physicsShort field of more than 60 characters: please rename.")
133 jo_physshortparts = jo_physshortpart.split(
"_")
134 if len(jo_physshortparts) < 2:
135 evgenLog.error(jofile +
" has too few physicsShort fields separated by '_': should contain <generators>(_<tune+PDF_if_available>)_<process>. Please rename.")
139 check_jofiles=
"/cvmfs/atlas.cern.ch/repo/sw/Generators/MC16JobOptions/scripts"
140 sys.path.append(check_jofiles)
141 from check_jo_consistency
import check_naming
142 if os.path.exists(check_jofiles):
143 check_naming(os.path.basename(jofile))
145 evgenLog.error(
"check_jo_consistency.py not found")
150 if sample.nEventsPerJob < 1:
151 raise RuntimeError(
"nEventsPerJob must be at least 1")
152 elif sample.nEventsPerJob > 100000:
153 raise RuntimeError(
"nEventsPerJob can be max. 100000")
155 allowed_nEventsPerJob_lt1000 = [1, 2, 5, 10, 20, 25, 50, 100, 200, 500, 1000]
156 if sample.nEventsPerJob >= 1000
and sample.nEventsPerJob <= 10000
and \
157 (sample.nEventsPerJob % 1000 != 0
or 10000 % sample.nEventsPerJob != 0):
158 raise RuntimeError(
"nEventsPerJob in range [1K, 10K] must be a multiple of 1K and a divisor of 10K")
159 elif sample.nEventsPerJob > 10000
and sample.nEventsPerJob % 10000 != 0:
160 raise RuntimeError(
"nEventsPerJob >10K must be a multiple of 10K")
161 elif sample.nEventsPerJob < 1000
and sample.nEventsPerJob
not in allowed_nEventsPerJob_lt1000:
162 raise RuntimeError(
"nEventsPerJob in range <= 1000 must be one of %s" % allowed_nEventsPerJob_lt1000)
166 from AthenaCommon.Utils.unixtools
import find_datafile
170 allowed_keywords = []
172 evgenLog.info(
"evgenkeywords = %s", kwpath)
173 kwf =
open(kwpath,
"r")
175 allowed_keywords += l.strip().lower().
split()
178 for k
in sample.keywords:
179 if k.lower()
not in allowed_keywords:
180 evil_keywords.append(k)
182 msg =
"keywords contains non-standard keywords: %s. " %
", ".
join(evil_keywords)
183 msg +=
"Please check the allowed keywords list and fix."
189 evgenLog.warning(
"evgenkeywords.txt not found ")
193 from AthenaCommon.Utils.unixtools
import find_datafile
199 from ast
import literal_eval
200 with open(lkwpath,
'r')
as catlist:
202 allowed_list = literal_eval(line)
203 allowed_cat.append(allowed_list)
207 it =
iter(sample.categories)
211 if "L1:" in l2
and "L2:" in l1:
213 print (
"first",l1,
"second",l2)
214 bad_cat.extend([l1, l2])
215 for a1,a2
in allowed_cat:
216 if l1.strip().lower()==a1.strip().lower()
and l2.strip().lower()==a2.strip().lower():
219 msg =
"categories contains non-standard category: %s. " %
", ".
join(bad_cat)
220 msg +=
"Please check the allowed categories list and fix."
226 evgenLog.warning(
"Could not find CategoryList.txt file ", lkwpath,
" in $DATAPATH")