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 """Return a boolean of whether this set of generators requires the steering command line flag"""
52 if "EvtGen" not in gennames:
return False
53 if any((
"Pythia" in gen
and "Pythia8" not in gen)
for gen
in gennames):
return True
54 if any((
"Herwig" in gen
and "Herwig7" not in gen)
for gen
in gennames):
return True
58 """Return whether a generator name is known"""
59 return genname
in KnownGenerators
62 """Return whether all generator names are known"""
66 """Return whether a generator uses LHEF input files"""
67 return genname
in LHEFGenerators
70 """Return whether any of the generators uses LHEF input files"""
71 return any(
gen_lhef(g)
for g
in gennames)
74 """Return whether a generator should be sanity tested with TestHepMC"""
75 return genname
not in NoTestHepMCGenerators
78 """Return whether all of the generators should be sanity tested with TestHepMC"""
82 """Return whether a generator is allowed to not provide PDF and tune information"""
83 return genname
not in NoTuneGenerators
86 """Return whether all of the generators are allowed to not provide PDF and tune information"""
90 """Return a key suitable for sorting a generator name by stage, then alphabetically"""
94 for istage, gens
in enumerate([LHEFGenerators, HIMainGenerators, MainGenerators,AfterburnerGenerators]):
100 return (genstage, genname)
104 import os, sys, string
106 joparts = (os.path.basename(jofile)).
split(
".")
108 if joparts[0].startswith(
"mc")
and all(c
in string.digits
for c
in joparts[0][2:]):
111 if len(joparts) != 3:
112 evgenLog.error(jofile +
" name format is wrong: must be of the form mc.<physicsShort>.py: please rename.")
115 jo_physshortpart = joparts[1]
116 if len(jo_physshortpart) > 50:
117 evgenLog.error(jofile +
" contains a physicsShort field of more than 60 characters: please rename.")
120 jo_physshortparts = jo_physshortpart.split(
"_")
121 if len(jo_physshortparts) < 2:
122 evgenLog.error(jofile +
" has too few physicsShort fields separated by '_': should contain <generators>(_<tune+PDF_if_available>)_<process>. Please rename.")
126 check_jofiles=
"/cvmfs/atlas.cern.ch/repo/sw/Generators/MC16JobOptions/scripts"
127 sys.path.append(check_jofiles)
128 from check_jo_consistency
import check_naming
129 if os.path.exists(check_jofiles):
130 check_naming(os.path.basename(jofile))
132 evgenLog.error(
"check_jo_consistency.py not found")
137 if sample.nEventsPerJob < 1:
138 raise RuntimeError(
"nEventsPerJob must be at least 1")
139 elif sample.nEventsPerJob > 100000:
140 raise RuntimeError(
"nEventsPerJob can be max. 100000")
142 allowed_nEventsPerJob_lt1000 = [1, 2, 5, 10, 20, 25, 50, 100, 200, 500, 1000]
143 if sample.nEventsPerJob >= 1000
and sample.nEventsPerJob <= 10000
and \
144 (sample.nEventsPerJob % 1000 != 0
or 10000 % sample.nEventsPerJob != 0):
145 raise RuntimeError(
"nEventsPerJob in range [1K, 10K] must be a multiple of 1K and a divisor of 10K")
146 elif sample.nEventsPerJob > 10000
and sample.nEventsPerJob % 10000 != 0:
147 raise RuntimeError(
"nEventsPerJob >10K must be a multiple of 10K")
148 elif sample.nEventsPerJob < 1000
and sample.nEventsPerJob
not in allowed_nEventsPerJob_lt1000:
149 raise RuntimeError(
"nEventsPerJob in range <= 1000 must be one of %s" % allowed_nEventsPerJob_lt1000)
153 from AthenaCommon.Utils.unixtools
import find_datafile
157 allowed_keywords = []
159 evgenLog.info(
"evgenkeywords = %s", kwpath)
160 kwf =
open(kwpath,
"r")
162 allowed_keywords += l.strip().lower().
split()
165 for k
in sample.keywords:
166 if k.lower()
not in allowed_keywords:
167 evil_keywords.append(k)
169 msg =
"keywords contains non-standard keywords: %s. " %
", ".
join(evil_keywords)
170 msg +=
"Please check the allowed keywords list and fix."
176 evgenLog.warning(
"evgenkeywords.txt not found ")
180 from AthenaCommon.Utils.unixtools
import find_datafile
186 from ast
import literal_eval
187 with open(lkwpath,
'r')
as catlist:
189 allowed_list = literal_eval(line)
190 allowed_cat.append(allowed_list)
194 it =
iter(sample.categories)
198 if "L1:" in l2
and "L2:" in l1:
200 print (
"first",l1,
"second",l2)
201 bad_cat.extend([l1, l2])
202 for a1,a2
in allowed_cat:
203 if l1.strip().lower()==a1.strip().lower()
and l2.strip().lower()==a2.strip().lower():
206 msg =
"categories contains non-standard category: %s. " %
", ".
join(bad_cat)
207 msg +=
"Please check the allowed categories list and fix."
213 evgenLog.warning(
"Could not find CategoryList.txt file ", lkwpath,
" in $DATAPATH")