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 202 of file Gen_tf.py.

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

◆ main()

Gen_tf.main ( )

Definition at line 230 of file Gen_tf.py.

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

◆ move_files()

Gen_tf.move_files ( main_dir,
tmp_dir,
allowedlist )

Definition at line 190 of file Gen_tf.py.

190def move_files(main_dir,tmp_dir,allowedlist):
191 files = os.listdir(tmp_dir)
192 files.sort()
193 for f in files:
194 for i in allowedlist:
195 if i in f:
196 src = tmp_dir+"/"+f
197 dest = main_dir+"/"+f
198 os.rename(src,dest)
199 break
200
201

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']

Prodsys1 hack... TODO: Remove!

Definition at line 19 of file Gen_tf.py.