ATLAS Offline Software
Loading...
Searching...
No Matches
Gen_tf Namespace Reference

Classes

class  EvgenExecutor

Functions

 move_files (main_dir, tmp_dir, allowedlist)
 getTransform ()
 main ()

Variables

list ListOfDefaultPositionalKeys
 Prodsys1 hack... TODO: Remove!

Detailed Description

# Run event generation and produce an EVNT file.

Function Documentation

◆ getTransform()

Gen_tf.getTransform ( )

Definition at line 208 of file Gen_tf.py.

208def getTransform():
209 exeSet = set()
210 msg.info("Transform arguments %s", sys.argv[1:])
211 if "--outputEVNTFile" in str(sys.argv[1:]):
212 exeSet.add(EvgenExecutor(name="generate", skeleton="EvgenJobTransforms/skel.GENtoEVGEN.py", skeletonCA="EvgenJobTransforms.GEN_Skeleton", inData=["inNULL"], outData=["YODA", "EVNT", "EVNT_Pre", "TXT"]))
213 msg.info("Output EVNT file")
214 elif "--outputYODAFile" in str(sys.argv[1:]):
215 exeSet.add(EvgenExecutor(name="generate", skeleton="EvgenJobTransforms/skel.GENtoEVGEN.py", skeletonCA="EvgenJobTransforms.GEN_Skeleton", inData=["inNULL"], outData=["YODA", "TXT"]))
216 msg.info("Output EVNT file")
217 elif "--outputTXTFile" in str(sys.argv[1:]):
218 exeSet.add(EvgenExecutor(name="generate", skeleton="EvgenJobTransforms/skel.GENtoTXT.py", skeletonCA="EvgenJobTransforms.GEN_Skeleton", inData=["inNULL"], outData=["TXT"]))
219 msg.info("Output TXT file")
220 elif "--outputHEPMCFile" not in str(sys.argv[1:]):
221 msg.error("Output cannot be recognised")
222
223 exeSet.add(EvgenExecutor(name="afterburn", skeleton="EvgenJobTransforms/skel.ABtoEVGEN.py", skeletonCA="EvgenJobTransforms.GEN_Skeleton", inData=["EVNT_Pre"], outData=["EVNT"]))
224 exeSet.add(athenaExecutor(name = "AODtoDPD", skeletonFile = "PATJobTransforms/skeleton.AODtoDPD_tf.py",
225 substep = "a2d", inData = ["EVNT"], outData = ["NTUP_TRUTH"], perfMonFile = "ntuple_AODtoDPD.pmon.gz"))
226 exeSet.add(athenaExecutor(name = 'EVNTtoHEPMC', skeletonCA = 'EvgenJobTransforms.POOLtoHEPMC_Skeleton',
227 substep = "a2d", perfMonFile = 'ntuple.pmon.gz', inData=['EVNT'], outData=['HEPMC']))
228 trf = transform(executor=exeSet)
229 addAthenaArguments(trf.parser, maxEventsDefaultSubstep='all')
230 addStdEvgenArgs(trf.parser)
231 return trf
232
233
234@stdTrfExceptionHandler
235@sigUsrStackTrace
STL class.

◆ main()

Gen_tf.main ( )

Definition at line 236 of file Gen_tf.py.

236def main():
237 msg.info("This is %s", sys.argv[0])
238
239 main_dir = os.getcwd()
240 trf = getTransform()
241 trf.parseCmdLineArgs(sys.argv[1:])
242 if (("cleanOut" in trf.argdict) and (trf.argdict["cleanOut"].value != 0)):
243 name_tmpdir = "tmprun"
244 tmp_dir = os.path.join(main_dir, name_tmpdir)
245 if os.path.isdir(tmp_dir):
246 shutil.rmtree(tmp_dir, ignore_errors=True)
247 os.mkdir("tmprun")
248 os.chdir("tmprun")
249 tmp_dir = os.getcwd()
250 allowedlist_in = ['MC','group','TXT']
251 move_files(tmp_dir,main_dir,allowedlist_in)
252
253 trf.execute()
254 trf.generateReport()
255 msg.info("%s stopped at %s, trf exit code %d", sys.argv[0], time.asctime(), trf.exitCode)
256
257
258# read files/dirs that should be saved and if present in cwd - remove
259
260 if (("cleanOut" in trf.argdict) and (trf.argdict["cleanOut"].value!=0)):
261 allowedlist_out = ['log.generate','.root']
262 if "outputTXTFile" in trf.argdict:
263 allowedlist_out.append('TXT')
264 if "saveList" in trf.argdict:
265 saveList_dic= trf.argdict["saveList"].value
266 saveList_str= str(saveList_dic)
267 saveList_str=saveList_str[10:-3]
268 saveList= saveList_str.split(",")
269 for item in saveList:
270 test_ex = os.path.join(main_dir,str(item))
271 if os.path.isdir(test_ex):
272 shutil.rmtree(test_ex, ignore_errors=True)
273 elif os.path.isfile(test_ex):
274 os.remove(test_ex)
275 if not saveList[0].isdigit():
276 allowedlist_out=allowedlist_out+saveList
277
278 move_files(main_dir,tmp_dir,allowedlist_out)
279 os.chdir(main_dir)
280 if "saveList" not in trf.argdict:
281 shutil.rmtree(tmp_dir, ignore_errors=True)
282 elif not saveList[0].isdigit():
283 shutil.rmtree(tmp_dir, ignore_errors=True)
284# if cleanOut is not defined and multipleinput preset, remove the merged file
285 elif ("inputGeneratorFile" in trf.argdict):
286 myinputfiles = trf.argdict["inputGeneratorFile"].value
287 genInputFiles = myinputfiles.split(',')
288 numberOfFiles = len(genInputFiles)
289 merge_file = 'merged_lhef._0.events'
290 if((numberOfFiles>1) and (os.path.exists(merge_file))):
291 os.remove(merge_file)
292#
293 if (("lheOnly" in trf.argdict ) and (trf.argdict["lheOnly"].value == 1)):
294 outputName = ''.join(trf.argdict["outputEVNTFile"].value)
295 os.remove(outputName)
296 sys.exit(trf.exitCode)
297
298
299# TODO: Open resulting EVNT file to extract cross-section, generator names+versions, etc. from the HepMC::GenRun or whatever... in an executor postExecute?
300
301
if(pathvar)
int main()
Definition hello.cxx:18

◆ move_files()

Gen_tf.move_files ( main_dir,
tmp_dir,
allowedlist )

Definition at line 196 of file Gen_tf.py.

196def move_files(main_dir,tmp_dir,allowedlist):
197 files = os.listdir(tmp_dir)
198 files.sort()
199 for f in files:
200 for i in allowedlist:
201 if i in f:
202 src = tmp_dir+"/"+f
203 dest = main_dir+"/"+f
204 os.rename(src,dest)
205 break
206
207

Variable Documentation

◆ ListOfDefaultPositionalKeys

list Gen_tf.ListOfDefaultPositionalKeys
Initial value:
1= ['--AMIConfig', '--AMITag', '--argJSON', '--asetup', '--athena',
2'--athenaMPMergeTargetSize', '--athenaopts', '--attempt', '--checkEventCount', '--command',
3'--dumpJSON', '--dumpPickle', '--ecmEnergy', '--env', '--eventAcceptanceEfficiency',
4'--evgenJobOpts', '--execOnly', '--fileValidation', '--firstEvent', '--ignoreErrors',
5'--ignoreFiles', '--ignorePatterns', '--imf', '--inputEVNT_PreFile', '--inputFileValidation',
6'--inputGenConfFile', '--inputGeneratorFile', '--jobConfig', '--jobid', '--maxEvents', '--orphanKiller', '--outputEVNTFile', '--outputEVNT_PreFile', '--outputHEPMCFile', '--outputFileValidation', '--outputNTUP_TRUTHFile', '--outputTXTFile', '--parallelFileValidation', '--postExec', '--postInclude', '--preExec', '--preInclude', '--wprintEvts', '--randomSeed', '--reportName', '--reportType', '--rivetAnas', '--runNumber', '--showGraph', '--showPath', '--showSteps', '--skipEvents', '--skipFileValidation', '--skipInputFileValidation', '--skipOutputFileValidation', '--steering', '--taskid', '--tcmalloc', '--valgrind', '--valgrindbasicopts', '--valgrindextraopts', '--lheOnly', '--localPath', '--cleanOut', '--saveList', '--avoidExtracting']

Prodsys1 hack... TODO: Remove!

Definition at line 19 of file Gen_tf.py.