ATLAS Offline Software
Classes | Functions | Variables
Gen_tf Namespace Reference

Classes

class  EvgenExecutor
 

Functions

def move_files (main_dir, tmp_dir, whitelist)
 
def getTransform ()
 
def main ()
 

Variables

list ListOfDefaultPositionalKeys = ['--AMIConfig', '--AMITag', '--argJSON', '--asetup', '--athena', '--athenaMPMergeTargetSize', '--athenaopts', '--attempt', '--checkEventCount', '--command', '--dumpJSON', '--dumpPickle', '--ecmEnergy', '--env', '--eventAcceptanceEfficiency', '--evgenJobOpts', '--execOnly', '--fileValidation', '--firstEvent', '--ignoreErrors', '--ignoreFiles', '--ignorePatterns', '--imf', '--inputEVNT_PreFile', '--inputFileValidation', '--inputGenConfFile', '--inputGeneratorFile', '--jobConfig', '--jobid', '--maxEvents', '--orphanKiller', '--outputEVNTFile', '--outputEVNT_PreFile', '--outputEvtFile', '--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... More...
 

Function Documentation

◆ getTransform()

def Gen_tf.getTransform ( )

Definition at line 188 of file Gen_tf.py.

188 def getTransform():
189  exeSet = set()
190  msg.info("Transform arguments %s" % sys.argv[1:])
191  if "--outputEVNTFile" in str(sys.argv[1:]):
192  exeSet.add(EvgenExecutor(name="generate", skeleton="EvgenJobTransforms/skel.GENtoEVGEN.py", skeletonCA="EvgenJobTransforms.GENtoEVGEN_Skeleton", inData=["inNULL"], outData=["YODA", "EVNT", "EVNT_Pre", "TXT"]))
193  msg.info("Output EVNT file")
194  elif "--outputYODAFile" in str(sys.argv[1:]):
195  exeSet.add(EvgenExecutor(name="generate", skeleton="EvgenJobTransforms/skel.GENtoEVGEN.py", inData=["inNULL"], outData=["YODA", "TXT"]))
196  msg.info("Output EVNT file")
197  elif "--outputTXTFile" in str(sys.argv[1:]):
198  exeSet.add(EvgenExecutor(name="generate", skeleton="EvgenJobTransforms/skel.GENtoTXT.py", inData=["inNULL"], outData=["TXT"]))
199  msg.info("Output TXT file")
200  else:
201  msg.error("Output cannot be recognised")
202 
203  exeSet.add(EvgenExecutor(name="afterburn", skeleton="EvgenJobTransforms/skel.ABtoEVGEN.py", inData=["EVNT_Pre"], outData=["EVNT"]))
204  exeSet.add(athenaExecutor(name = "AODtoDPD", skeletonFile = "PATJobTransforms/skeleton.AODtoDPD_tf.py",
205  substep = "a2d", inData = ["EVNT"], outData = ["NTUP_TRUTH"], perfMonFile = "ntuple_AODtoDPD.pmon.gz"))
206  exeSet.add(athenaExecutor(name = 'EVNTtoHEPMC', skeletonCA = 'EvgenJobTransforms.EVNTtoHEPMC_Skeleton',
207  substep = "a2d", perfMonFile = 'ntuple.pmon.gz', inData=['EVNT'], outData=['Evt']))
208  trf = transform(executor=exeSet)
209  addAthenaArguments(trf.parser, maxEventsDefaultSubstep='all')
210  addStdEvgenArgs(trf.parser)
211  return trf
212 
213 
214 @stdTrfExceptionHandler
215 @sigUsrStackTrace

◆ main()

def Gen_tf.main ( )

Definition at line 216 of file Gen_tf.py.

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

◆ move_files()

def Gen_tf.move_files (   main_dir,
  tmp_dir,
  whitelist 
)

Definition at line 176 of file Gen_tf.py.

176 def move_files(main_dir,tmp_dir,whitelist):
177  files = os.listdir(tmp_dir)
178  files.sort()
179  for f in files:
180  for i in whitelist:
181  if i in f:
182  src = tmp_dir+"/"+f
183  dest = main_dir+"/"+f
184  os.rename(src,dest)
185  break
186 
187 

Variable Documentation

◆ ListOfDefaultPositionalKeys

list Gen_tf.ListOfDefaultPositionalKeys = ['--AMIConfig', '--AMITag', '--argJSON', '--asetup', '--athena', '--athenaMPMergeTargetSize', '--athenaopts', '--attempt', '--checkEventCount', '--command', '--dumpJSON', '--dumpPickle', '--ecmEnergy', '--env', '--eventAcceptanceEfficiency', '--evgenJobOpts', '--execOnly', '--fileValidation', '--firstEvent', '--ignoreErrors', '--ignoreFiles', '--ignorePatterns', '--imf', '--inputEVNT_PreFile', '--inputFileValidation', '--inputGenConfFile', '--inputGeneratorFile', '--jobConfig', '--jobid', '--maxEvents', '--orphanKiller', '--outputEVNTFile', '--outputEVNT_PreFile', '--outputEvtFile', '--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.

Gen_tf.move_files
def move_files(main_dir, tmp_dir, whitelist)
Definition: Gen_tf.py:176
Gen_tf.getTransform
def getTransform()
Definition: Gen_tf.py:188
python.trfArgs.addAthenaArguments
def addAthenaArguments(parser, maxEventsDefaultSubstep='first', addValgrind=True, addPerfMon=True, addVTune=True)
Options related to running athena in general TODO: Some way to mask certain options (perExec,...
Definition: trfArgs.py:59
Amg::transform
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Definition: GeoPrimitivesHelpers.h:156
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.evgenTrfArgs.addStdEvgenArgs
def addStdEvgenArgs(parser)
Definition: evgenTrfArgs.py:5
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:567
str
Definition: BTagTrackIpAccessor.cxx:11
Gen_tf.main
def main()
Definition: Gen_tf.py:216