3"""Functionality core of the Generate_tf transform"""
13import os, re, string, subprocess
14import AthenaCommon.AlgSequence
as acas
15import AthenaCommon.AppMgr
as acam
16from AthenaCommon.AthenaCommonFlags
import jobproperties
17from AthenaCommon.AthenaCommonFlags
import athenaCommonFlags
18from AthenaCommon.AthenaCommonFlags
import jobproperties
20from xAODEventInfoCnv.xAODEventInfoCnvConf
import xAODMaker__EventInfoCnvAlg
21acam.athMasterSeq += xAODMaker__EventInfoCnvAlg(xAODKey=
"TMPEvtInfo")
24acam.athMasterSeq += acas.AlgSequence(
"EvgenGenSeq")
25genSeq = acam.athMasterSeq.EvgenGenSeq
26acam.athMasterSeq += acas.AlgSequence(
"EvgenFixSeq")
27fixSeq = acam.athMasterSeq.EvgenFixSeq
28acam.athMasterSeq += acas.AlgSequence(
"EvgenPreFilterSeq")
29prefiltSeq = acam.athMasterSeq.EvgenPreFilterSeq
30acam.athMasterSeq += acas.AlgSequence(
"EvgenTestSeq")
31testSeq = acam.athMasterSeq.EvgenTestSeq
33from EvgenProdTools.LogicalExpressionFilter
import LogicalExpressionFilter
35filtSeq = acam.athMasterSeq.EvgenFilterSeq
36topSeq = acas.AlgSequence()
38topSeq += acas.AlgSequence(
"EvgenPostSeq")
39postSeq = topSeq.EvgenPostSeq
45import AthenaCommon.AtlasUnixGeneratorJob
46include(
"PartPropSvc/PartPropSvc.py")
49from PerfMonComps.PerfMonFlags
import jobproperties
as perfmonjp
50perfmonjp.PerfMonFlags.doFastMonMT =
True
52from RngComps.RngCompsConf
import AthRNGSvc
56jobproperties.AthenaCommonFlags.AllowIgnoreConfigError =
False
59from AthenaCommon.Logging
import logging
60evgenLog = logging.getLogger(
'Gen_tf')
67evgenLog.debug(
"****************** CHECKING EVENT GENERATION ARGS *****************")
68evgenLog.debug(str(runArgs))
69evgenLog.info (
"****************** CHECKING EVENT GENERATION ARGS *****************")
72if not hasattr(runArgs,
"ecmEnergy"):
73 raise RuntimeError(
"No center of mass energy provided.")
75 evgenLog.info(
'ecmEnergy = ' + str(runArgs.ecmEnergy) )
81evgenLog.debug(
"****************** CONFIGURING MATRIX ELEMENT GENERATION *****************")
82evgenLog.info(
"****************** CONFIGURING MATRIX ELEMENT GENERATION *****************")
86from EvgenJobTransforms.EvgenConfig
import evgenConfig
87from GeneratorConfig.GenConfigHelpers
import gens_known, gen_lhef, gens_lhef, gen_sortkey, gens_testhepmc, gens_notune, gen_require_steering
91from EvgenProdTools.EvgenProdToolsConf
import CountHepMC
92if (runArgs.firstEvent <= 0):
93 evgenLog.warning(
"Run argument firstEvent should be > 0")
95svcMgr.EventSelector.FirstEvent = runArgs.firstEvent
99if not hasattr(postSeq,
"CountHepMC"):
100 postSeq +=
CountHepMC(InputEventInfo=
"TMPEvtInfo",
101 OutputEventInfo=
"EventInfo",
102 mcEventWeightsKey=
"")
104postSeq.CountHepMC.FirstEvent = runArgs.firstEvent
105postSeq.CountHepMC.CorrectHepMC =
True
106postSeq.CountHepMC.CorrectEventID =
True
114evgenLog.debug(
"****************** LOADING PRE-INCLUDES AND JOB CONFIG *****************")
115evgenLog.info(
"****************** LOADING PRE-INCLUDES AND JOB CONFIG *****************")
118if hasattr(runArgs,
"preInclude"):
119 for fragment
in runArgs.preInclude:
123if hasattr(runArgs,
"preExec"):
124 evgenLog.info(
"Transform pre-exec")
125 for cmd
in runArgs.preExec:
129def get_immediate_subdirectories(a_dir):
130 return [name
for name
in os.listdir(a_dir)
131 if os.path.isdir(os.path.join(a_dir, name))]
137 if hasattr(runArgs,
"outputTXTFile"): outputTXTFile=runArgs.outputTXTFile
143if len(runArgs.jobConfig) != 1:
144 evgenLog.info(
"runArgs.jobConfig = " + runArgs.jobConfig)
145 evgenLog.error(
"You must supply one and only one jobConfig file argument. It has to start from mc. and end with .py")
148print (
"Using JOBOPTSEARCHPATH (as seen in skeleton) = '%s'" % (os.environ[
"JOBOPTSEARCHPATH"]))
149FIRST_DIR = (os.environ[
'JOBOPTSEARCHPATH']).
split(
":")[0]
151dsid_param = runArgs.jobConfig[0]
152evgenLog.info(
"dsid_param = " + dsid_param)
153dsid = os.path.basename(dsid_param)
154evgenLog.info(
"dsid = " + dsid)
155jofiles = [f
for f
in os.listdir(FIRST_DIR)
if (f.startswith(
'mc')
and f.endswith(
'.py'))]
158 evgenLog.info(
"runArgs.jobConfig wrong " + runArgs.jobConfig)
159 evgenLog.error(
"You must supply one and only one jobOption file in DSID directory. It has to start with mc. and end with .py")
162joparts = (os.path.basename(jofile)).
split(
".")
164if joparts[0].startswith(
"mc")
and all(c
in string.digits
for c
in joparts[0][2:]):
166 if len(joparts) != 3:
167 evgenLog.error(jofile +
" name format is wrong: must be of the form MC<xx>.<physicsShort>.py: please rename.")
171 jo_physshortpart = joparts[1]
172 max_jo_physshort_length = 50
173 if len(jo_physshortpart) > max_jo_physshort_length:
174 evgenLog.error(f
"{jofile} contains a physicsShort field of more than {max_jo_physshort_length} characters: please rename.")
177 jo_physshortparts = jo_physshortpart.split(
"_")
178 if len(jo_physshortparts) < 2:
179 evgenLog.error(jofile +
" has too few physicsShort fields separated by '_': should contain <generators>(_<tune+PDF_if_available>)_<process>. Please rename.")
182 check_jofiles=
"/cvmfs/atlas.cern.ch/repo/sw/Generators/MCJobOptions/scripts/check_jo_consistency.py"
183 if os.path.exists(check_jofiles):
184 evgenLog.info(
"Checking offical JO file name consistency")
185 include(check_jofiles)
186 check_naming(os.path.basename(jofile))
188 evgenLog.warning(
"check_jo_consistency.py not found, will proceed without JOs consistency check")
190 evgenLog.error(jofile +
" should be named mc.XXXXXX.*")
195include(
"EvgenJobTransforms/LHEonly.py")
202evgenLog.debug(
"****************** CHECKING EVGEN CONFIGURATION *****************")
203evgenLog.info(
"****************** CHECKING EVGEN CONFIGURATION *****************")
206for opt
in str(evgenConfig).
split(os.linesep):
208evgenLog.info(
".transform = Gen_tf")
211evgenLog.info(
".platform = "+str(os.environ[
'BINARY_TAG']))
216if evgenConfig.obsolete:
217 evgenLog.error(
"JOs or icludes are obsolete, please check them")
220if not evgenConfig.generators:
221 evgenLog.error(
"No entries in evgenConfig.generators: invalid configuration, please check your JO")
224if len(evgenConfig.generators) > len(
set(evgenConfig.generators)):
225 evgenLog.error(
"Duplicate entries in evgenConfig.generators: invalid configuration, please check your JO")
228gennames = sorted(evgenConfig.generators, key=gen_sortkey)
230if joparts[0].startswith(
"MC"):
231 genpart = jo_physshortparts[0]
232 expectedgenpart =
''.join(gennames)
234 expectedgenpart = expectedgenpart.replace(
"HerwigJimmy",
"Herwig")
239 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")
242 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")
245 if genpart !=
_norm(expectedgenpart)
and _norm2(genpart) !=
_norm(expectedgenpart):
246 evgenLog.error(
"Expected first part of JO name to be '%s' or '%s', but found '%s'" % (
_norm(expectedgenpart),
_norm(
_short2(expectedgenpart)), genpart))
247 evgenLog.error(
"gennames '%s' " %(expectedgenpart))
252 if not gens_notune(gennames)
and len(jo_physshortparts) < 3:
253 evgenLog.error(jofile +
" with generators " + expectedgenpart +
254 " has too few physicsShort fields separated by '_'." +
255 " It should contain <generators>_<tune+PDF_<process>. Please rename.")
260if gen_require_steering(gennames):
261 if hasattr(runArgs,
"outputEVNTFile")
and not hasattr(runArgs,
"outputEVNT_PreFile"):
262 raise RuntimeError(
"'EvtGen' found in job options name, please set '--steering=afterburn'")
268if hasattr(runArgs,
'inputGeneratorFile')
and ',' in runArgs.inputGeneratorFile: multiInput = runArgs.inputGeneratorFile.count(
',')+1
273if not evgenConfig.nEventsPerJob:
274 evgenLog.info(
'#############################################################')
275 evgenLog.info(
' !!!! no nEventsPerJob set !!! The default 10000 used. !!! ')
276 evgenLog.info(
'#############################################################')
278 evgenLog.info(
' nEventsPerJob set to ' + str(evgenConfig.nEventsPerJob) )
280if evgenConfig.minevents > 0 :
281 raise RuntimeError(
"evgenConfig.minevents is obsolete and should be removed from the JOs")
283if evgenConfig.nEventsPerJob < 1:
284 raise RunTimeError(
"evgenConfig.nEventsPerJob must be at least 1")
286 evgenLog.info(
"evgenConfig.nEventsPerJob = {}, but only {} (dummy) event(s) will be generated by Pythia8 for lhe-only production".format(evgenConfig.nEventsPerJob, postSeq.CountHepMC.RequestedOutput))
290if not evgenConfig.keywords:
291 evgenLog.warning(
"No entries in evgenConfig.keywords: invalid configuration, please check your JO !!")
294if evgenConfig.keywords:
295 from GeneratorConfig.GenConfigHelpers
import checkKeywords
296 checkKeywords(evgenConfig, evgenLog)
299if not evgenConfig.categories:
300 evgenLog.warning(
"No entries in evgenConfig.categories: invalid configuration, please check your JO !!")
303if evgenConfig.categories:
306 lkwfile =
"CategoryList.txt"
308 for p
in os.environ[
"DATAPATH"].
split(
":"):
309 lkwpath = os.path.join(p, lkwfile)
310 if os.path.exists(lkwpath):
316 with open(lkwpath,
'r')
as catlist:
318 allowed_list = ast.literal_eval(line)
319 allowed_cat.append(allowed_list)
323 it = iter(evgenConfig.categories)
327 if "L1:" in l2
and "L2:" in l1:
329 print(
"first",l1,
"second",l2)
330 bad_cat.extend([l1, l2])
331 for a1,a2
in allowed_cat:
332 if l1.strip().lower()==a1.strip().lower()
and l2.strip().lower()==a2.strip().lower():
335 msg =
"evgenConfig.categories contains non-standard category: %s. " %
", ".join(bad_cat)
336 msg +=
"Please check the allowed categories list and fix."
340 evgenLog.warning(
"Could not find CategoryList.txt file %s in DATAPATH" % lkwfile)
343dsid = os.path.basename(runArgs.jobConfig[0])
344if not dsid.isdigit():
346svcMgr.EventSelector.RunNumber = int(dsid)
349from GeneratorConfig.Versioning
import generatorsGetInitialVersionedDictionary, generatorsVersionedStringList
350gendict = generatorsGetInitialVersionedDictionary(gennames)
351gennamesvers = generatorsVersionedStringList(gendict)
353import EventInfoMgt.EventInfoMgtInit
354svcMgr.TagInfoMgr.ExtraTagValuePairs.update({
"hepmc_version":
"HepMC" + str(os.environ[
'HEPMCVER'])})
355svcMgr.TagInfoMgr.ExtraTagValuePairs.update({
"mc_channel_number":str(dsid)})
356svcMgr.TagInfoMgr.ExtraTagValuePairs.update({
"lhefGenerator":
'+'.join( filter( gen_lhef, gennames ) ) })
357svcMgr.TagInfoMgr.ExtraTagValuePairs.update({
"generators":
'+'.join(gennamesvers)})
358svcMgr.TagInfoMgr.ExtraTagValuePairs.update({
"evgenProcess": evgenConfig.process})
359svcMgr.TagInfoMgr.ExtraTagValuePairs.update({
"evgenTune": evgenConfig.tune})
360svcMgr.TagInfoMgr.ExtraTagValuePairs.update({
"hadronizationModel": evgenConfig.hadronizationModel})
361svcMgr.TagInfoMgr.ExtraTagValuePairs.update({
"partonShowerModel": evgenConfig.partonShowerModel})
362if hasattr( evgenConfig,
"hardPDF" ) : svcMgr.TagInfoMgr.ExtraTagValuePairs.update({
"hardPDF": evgenConfig.hardPDF})
363if hasattr( evgenConfig,
"softPDF" ) : svcMgr.TagInfoMgr.ExtraTagValuePairs.update({
"softPDF": evgenConfig.softPDF})
364if hasattr( runArgs,
"randomSeed") : svcMgr.TagInfoMgr.ExtraTagValuePairs.update({
"randomSeed": str(runArgs.randomSeed)})
365svcMgr.TagInfoMgr.ExtraTagValuePairs.update({
"keywords":
", ".join(evgenConfig.keywords).lower()})
368evgenLog.info(
"HepMC version " + str(os.environ[
'HEPMCVER']))
371from PyUtils
import AMITagHelper
372AMITagHelper.SetAMITag(runArgs=runArgs)
375svcMgr.TagInfoMgr.ExtraTagValuePairs.update({
"beam_energy": str(int(runArgs.ecmEnergy*Units.GeV/2.0))})
376svcMgr.TagInfoMgr.ExtraTagValuePairs.update({
"beam_type":
'collisions'})
380include(
"EvgenJobTransforms/Generate_ecmenergies.py")
383include(
"EvgenJobTransforms/Generate_dsid_ranseed.py")
386if (hasattr( runArgs,
"VERBOSE")
and runArgs.VERBOSE )
or (hasattr( runArgs,
"loglevel")
and runArgs.loglevel ==
"DEBUG")
or (hasattr( runArgs,
"loglevel")
and runArgs.loglevel ==
"VERBOSE"):
387 include(
"EvgenJobTransforms/Generate_debug_level.py")
395 with open(
'/cvmfs/atlas.cern.ch/repo/sw/Generators/MCJobOptions/common/BlackList_caches.txt')
as bfile:
396 for line
in bfile.readlines():
400 badRelFlav=line.split(
',')[0].
strip()
402 badCache=line.split(
',')[1].
strip()
404 badGens=line.split(
',')[2].
strip()
406 used_gens =
','.join(generatorName)
408 if relFlavour==badRelFlav
and cache==badCache
and re.search(badGens,used_gens)
is not None:
409 if badGens==
"": badGens=
"all generators"
410 isError=relFlavour+
","+cache+
" is blocklisted for " + badGens
416 with open(
'/cvmfs/atlas.cern.ch/repo/sw/Generators/MCJobOptions/common/PurpleList_generators.txt')
as bfile:
417 for line
in bfile.readlines():
421 purpleRelFlav=line.split(
',')[0].
strip()
423 purpleCache=line.split(
',')[1].
strip()
425 purpleGens=line.split(
',')[2].
strip()
427 purpleProcess=line.split(
',')[3].
strip()
429 used_gens =
','.join(generatorName)
431 if relFlavour==purpleRelFlav
and cache==purpleCache
and re.search(purpleGens,used_gens)
is not None:
432 isError=relFlavour+
","+cache+
" is blocklisted for " + purpleGens +
" if it uses " + purpleProcess
437evgenLog.debug(
"****************** CHECKING RELEASE IS NOT BLACKLISTED *****************")
438rel = os.popen(
"echo $AtlasVersion").
read()
440if os.path.exists(
'/cvmfs/atlas.cern.ch/repo/sw/Generators/MCJobOptions/common'):
443 if (hasattr( runArgs,
"ignoreBlackList")
and runArgs.ignoreBlackList):
444 evgenLog.warning(
"This run is blocklisted for this generator, please use a different one for production !! "+ errorBL )
446 raise RuntimeError(
"This run is blocklisted for this generator, please use a different one !! "+ errorBL)
450 evgenLog.warning(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
451 evgenLog.warning(
"!!! WARNING !!! "+ errorPL )
452 evgenLog.warning(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
454 msg.waring(
"No access to cvmfs, so blocklisted runs will not be checked")
458svcMgr.TagInfoMgr.ExtraTagValuePairs.update({
"specialConfiguration": evgenConfig.specialConfig})
469if hasattr(runArgs,
"postInclude"):
470 for fragment
in runArgs.postInclude:
473if hasattr(runArgs,
"postExec"):
474 evgenLog.info(
"Transform post-exec")
475 for cmd
in runArgs.postExec:
482acas.dumpMasterSequence()
490evgenLog.debug(
"****************** HANDLING EVGEN INPUT FILES *****************")
491print(
"****************** HANDLING EVGEN INPUT FILES *****************")
494if "McAtNlo" in evgenConfig.generators
and "Herwig" in evgenConfig.generators:
495 datFile =
"inparmMcAtNlo.dat"
496elif "Alpgen" in evgenConfig.generators:
497 datFile =
"inparmAlpGen.dat"
498elif "Protos" in evgenConfig.generators:
499 datFile =
"protos.dat"
500elif "ProtosLHEF" in evgenConfig.generators:
501 datFile =
"protoslhef.dat"
502elif "AcerMC" in evgenConfig.generators:
503 datFile =
"inparmAcerMC.dat"
504elif "CompHep" in evgenConfig.generators:
505 datFile =
"inparmCompHep.dat"
508if "Alpgen" in evgenConfig.generators:
509 eventsFile =
"alpgen.unw_events"
510elif "Protos" in evgenConfig.generators:
511 eventsFile =
"protos.events"
512elif "ProtosLHEF" in evgenConfig.generators:
513 eventsFile =
"protoslhef.events"
514elif "BeamHaloGenerator" in evgenConfig.generators:
515 eventsFile =
"beamhalogen.events"
516elif "HepMCAscii" in evgenConfig.generators:
517 eventsFile =
"events.hepmc"
518elif "ReadMcAscii" in evgenConfig.generators:
519 eventsFile =
"events.hepmc"
520elif gens_lhef(evgenConfig.generators):
522 eventsFile =
"events.lhe"
527 "Return a matching file, provided it is unique"
529 files = glob.glob(pattern)
532 raise RuntimeError(
"No '%s' file found" % pattern)
534 raise RuntimeError(
"More than one '%s' file found" % pattern)
540 if(os.path.exists(outputFile)):
541 print (
"outputFile ",outputFile,
" already exists. Will rename to ",outputFile,
".OLD")
542 os.rename(outputFile,outputFile+
".OLD")
543 output = open(outputFile,
'w')
546 for file
in listOfFiles:
547 cmd =
"grep /event "+file+
" | wc -l"
548 nevents+=int(subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=
True))
550 for file
in listOfFiles:
553 print (
"*** Starting file ",file)
554 for line
in open(file,
"r"):
560 if(
"<event" in line
and inHeader):
562 if(len(holdHeader)<1):
568 elif(
not inHeader
and not (
"</LesHouchesEvents>" in line)):
572 if(
"nevents" in line):
574 tmp = line.split(
"=")
575 line = line.replace(tmp[0],str(nevents))
576 elif(
"numevts" in line):
578 tmp = line.split(
" ")
580 line = line.replace(tmp[1],nnn)
582 output.write(
"</LesHouchesEvents>\n")
586 "Make a symlink safely"
588 if os.path.exists(dstfile)
and not os.path.samefile(dstfile, srcfile):
590 if not os.path.exists(dstfile):
591 evgenLog.info(
"Symlinking %s to %s" % (srcfile, dstfile))
592 os.symlink(srcfile, dstfile)
594 evgenLog.debug(
"Symlinking: %s is already the same as %s" % (dstfile, srcfile))
597if eventsFile
or datFile:
598 if not hasattr(runArgs,
"inputGeneratorFile")
or runArgs.inputGeneratorFile ==
"NONE":
599 raise RuntimeError(
"%s needs input file (argument inputGeneratorFile)" % runArgs.jobConfig)
600 if evgenConfig.inputfilecheck
and not re.search(evgenConfig.inputfilecheck, runArgs.inputGeneratorFile):
601 raise RuntimeError(
"inputGeneratorFile=%s is incompatible with inputfilecheck '%s' in %s" %
602 (runArgs.inputGeneratorFile, evgenConfig.inputfilecheck, runArgs.jobConfig))
604 if ".tar" in os.path.basename(runArgs.inputGeneratorFile):
605 inputroot = os.path.basename(runArgs.inputGeneratorFile).
split(
".tar.")[0]
606 elif ".tgz" in os.path.basename(runArgs.inputGeneratorFile):
607 inputroot = os.path.basename(runArgs.inputGeneratorFile).
split(
".tgz")[0]
608 elif ".gz" in os.path.basename(runArgs.inputGeneratorFile):
609 inputroot = os.path.basename(runArgs.inputGeneratorFile).
split(
".gz")[0]
611 inputroot = os.path.basename(runArgs.inputGeneratorFile).
split(
"._")[0]
616 myinputfiles = runArgs.inputGeneratorFile
617 genInputFiles = myinputfiles.split(
',')
618 numberOfFiles = len(genInputFiles)
621 if ".tar" in os.path.basename(runArgs.inputGeneratorFile):
622 inputroot = os.path.basename(runArgs.inputGeneratorFile).
split(
".tar.")[0]
623 elif ".tgz" in os.path.basename(runArgs.inputGeneratorFile):
624 inputroot = os.path.basename(runArgs.inputGeneratorFile).
split(
".tgz")[0]
625 elif ".gz" in os.path.basename(runArgs.inputGeneratorFile):
626 inputroot = os.path.basename(runArgs.inputGeneratorFile).
split(
".gz")[0]
628 inputroot = os.path.basename(runArgs.inputGeneratorFile).
split(
"._")[0]
630 if "events" in inputroot :
631 inputroot = inputroot.replace(
".events",
"")
636 for file
in genInputFiles:
639 if ".tar" in os.path.basename(runArgs.inputGeneratorFile):
640 inputroot = os.path.basename(runArgs.inputGeneratorFile).
split(
".tar.")[0]
641 elif ".tgz" in os.path.basename(runArgs.inputGeneratorFile):
642 inputroot = os.path.basename(runArgs.inputGeneratorFile).
split(
".tgz")[0]
643 elif ".gz" in os.path.basename(runArgs.inputGeneratorFile):
644 inputroot = os.path.basename(runArgs.inputGeneratorFile).
split(
".gz")[0]
646 input0 = os.path.basename(file).
split(
"._")[0]
647 input1 = (os.path.basename(file).
split(
"._")[1]).
split(
".")[0]
648 inputroot = input0+
"._"+input1
651 with open(realEventsFile,
'r')
as f:
652 first_line = f.readline()
653 if(
not (
"LesHouche" in first_line)):
654 raise RuntimeError(
"%s is NOT a LesHouche file" % realEventsFile)
655 allFiles.append(realEventsFile)
659 if hasattr(runArgs,
"inputGeneratorFile")
and runArgs.inputGeneratorFile !=
"NONE":
660 raise RuntimeError(
"inputGeneratorFile arg specified for %s, but generators %s do not require an input file" %
661 (runArgs.jobConfig, str(gennames)))
667if evgenConfig.auxfiles:
669 get_files(evgenConfig.auxfiles, keepDir=
False, errorIfNotFound=
True)
676 if not hasattr(evgenConfig, attr)
or not getattr(evgenConfig, attr):
677 msg =
"evgenConfig attribute '%s' not found." % attr
679 raise RuntimeError(
"Required " + msg)
684with open(eventsFile)
as f:
686 count_ev += line.count(
'/event')
688evgenLog.info(
'Requested output events = '+str(count_ev))
689print(
"MetaData: %s = %s" % (
"Number of produced LHE events ", count_ev))
692 msg = evgenConfig.description
694 msg +=
" " + evgenConfig.notes
695 print(
"MetaData: %s = %s" % (
"physicsComment", msg))
697 print (
"MetaData: %s = %s" % (
"generatorName",
"+".join(gennamesvers)))
699 print (
"MetaData: %s = %s" % (
"physicsProcess", evgenConfig.process))
701 print (
"MetaData: %s = %s" % (
"generatorTune", evgenConfig.tune))
703 print (
"MetaData: %s = %s" % (
"hadronizationModel", evgenConfig.hadronizationModel))
705 print (
"MetaData: %s = %s" % (
"partonShowerModel", evgenConfig.partonShowerModel))
707 print (
"MetaData: %s = %s" % (
"hardPDF", evgenConfig.hardPDF))
709 print (
"MetaData: %s = %s" % (
"softPDF", evgenConfig.softPDF))
711 print (
"MetaData: %s = %s" % (
"nEventsPerJob", evgenConfig.nEventsPerJob))
713 print (
"MetaData: %s = %s" % (
"keywords",
", ".join(evgenConfig.keywords).lower() ))
715 print (
", " +
", ".join(evgenConfig.categories))
722 print (
"MetaData: %s = %s" % (
"specialConfig", evgenConfig.specialConfig))
725 print (
"MetaData: %s = %s" % (
"contactPhysicist",
", ".join(evgenConfig.contact)))
727print (
"MetaData: %s = %s" % (
"randomSeed", str(runArgs.randomSeed)))
733filterNames = [alg.getType()
for alg
in acas.iter_algseq(filtSeq)]
734excludedNames = [
'AthSequencer',
'PyAthena::Alg',
'TestHepMC']
735filterNames = list(
set(filterNames) -
set(excludedNames))
736print (
"MetaData: %s = %s" % (
"genFilterNames",
", ".join(filterNames)))
743from PyJobTransformsCore.runargs
import RunArguments
744runPars = RunArguments()
745runPars.nEventsPerJob = evgenConfig.nEventsPerJob
746runPars.maxeventsstrategy = evgenConfig.maxeventsstrategy
747with open(
"config.pickle",
"wb")
as f:
749 pickle.dump(runPars, f)
756evgenLog.debug(
"****************** STARTING EVENT GENERATION *****************")
757print (
"****************** STARTING EVENT GENERATION *****************")
758print (
"**************************************************************")
759print (
"****************** PLEASE IGNORE THE LOG FROM PYTHIA ************")
760print (
"****************** GENERATION OF ONE PYTHIA EVENT ***************")
761print (
"******************** IS NEEDED TO MAKE *************")
762print (
"****************** THE TRANSFORM WORK ***************************")
763print (
"**************************************************************")
void print(char *figname, TCanvas *c1)
A service to manage multiple RNG streams in thread-safe way.
Count the number of events to pass all algorithms/filters.
std::string replace(std::string s, const std::string &s2, const std::string &s3)
std::vector< std::string > split(const std::string &s, const std::string &t=":")
checkBlockList(relFlavour, cache, generatorName)
Add special config option (extended model info for BSM scenarios).
checkPurpleList(relFlavour, cache, generatorName)
_checkattr(attr, required=False)
==============================================================
mk_symlink(srcfile, dstfile)
IovVectorMap_t read(const Folder &theFolder, const SelectionCriterion &choice, const unsigned int limit=10)