ATLAS Offline Software
Public Member Functions | List of all members
AfterBurner_tf.EvgenExecutor Class Reference
Inheritance diagram for AfterBurner_tf.EvgenExecutor:
Collaboration diagram for AfterBurner_tf.EvgenExecutor:

Public Member Functions

def __init__ (self, skeleton)
 
def preExecute (self, input=set(), output=set())
 

Detailed Description

Definition at line 24 of file AfterBurner_tf.py.

Constructor & Destructor Documentation

◆ __init__()

def AfterBurner_tf.EvgenExecutor.__init__ (   self,
  skeleton 
)

Definition at line 27 of file AfterBurner_tf.py.

27  def __init__(self, skeleton):
28  athenaExecutor.__init__(self, name="generate", skeletonFile=skeleton, substep="gen2evnt", tryDropAndReload=False, inData=["EVNT_Pre"], outData=["EVNT"])
29 

Member Function Documentation

◆ preExecute()

def AfterBurner_tf.EvgenExecutor.preExecute (   self,
  input = set(),
  output = set() 
)

Definition at line 30 of file AfterBurner_tf.py.

30  def preExecute(self, input=set(), output=set()):
31  "Get input tarball, unpack and set up env if an evgenJobOpts arg was provided."
32 
33 
34  super(EvgenExecutor, self).preExecute(input, output)
35 
36  def expand_if_archive(filename):
37  "Function to expand a file if it is a zip archive or tarball"
38  if ".tar" in filename:
39  import tarfile
40  tf = tarfile.open(filename)
41  tf.extractall()
42  tf.close()
43  elif filename.endswith(".zip"):
44  import zipfile
45  zf = zipfile.ZipFile(filename)
46  zf.extractall()
47  zf.close()
48 
50  return [name for name in os.listdir(a_dir)
51  if os.path.isdir(os.path.join(a_dir, name))]
52 
53  def mk_jo_proxy(targetbasepath, pkgname, proxypath, addtosearch=True):
54  "Make a JO proxy dir such that the MCxxJobOptions/dddd dirs contents are found via include(MCxxJobOptions/yyyy)"
55  if proxypath:
56  if os.path.exists(proxypath):
57  shutil.rmtree(proxypath)
58  os.mkdir(proxypath)
59  os.environ['LOCAL_INSTALL_DIR'] = (os.environ['JOBOPTSEARCHPATH']).split(":")[0]
60  comdir = os.path.join(targetbasepath, "common")
61  subdirlist = get_immediate_subdirectories(comdir)
62  subdirlist1 = ['common/%s' % item for item in subdirlist]
63  dirlist = ['common','share','gencontrol','susycontrol']
64  for d in (dirlist+subdirlist1):
65  # TODO: we could _maybe_ add the appropriate share/DSIDxxxx/ dir to the path based on the jobConfig arg... too much magic?
66  if (d != 'common/.svn'):
67  dpath = os.path.join(proxypath, d)
68 
69  if proxypath:
70  os.mkdir(dpath)
71  os.symlink(os.path.join(targetbasepath, d), os.path.join(dpath, pkgname))
72  if addtosearch:
73  os.environ["JOBOPTSEARCHPATH"] = dpath+":"+os.environ["JOBOPTSEARCHPATH"]
74  os.environ["DATAPATH"] =os.path.join(targetbasepath, d)+":"+os.environ["DATAPATH"]
75 
76  os.environ["JOBOPTSEARCHPATH"] = os.environ['LOCAL_INSTALL_DIR']+":"+os.environ["JOBOPTSEARCHPATH"]
77 
78 
79 
80  if "evgenJobOpts" in self._trf.argdict:
81  tarball = self._trf.argdict["evgenJobOpts"].value
82 
84  if tarball.startswith("http"):
85  url = tarball
86  tarball = os.basename(tarball)
87  else:
88  url = "http://cern.ch/atlas-computing/links/kitsDirectory/EvgenJobOpts/" + tarball
89 
90  if not os.path.exists(tarball):
91  from EvgenJobTransforms.download import downloadUsingProxy
92  status, output = downloadUsingProxy(url)
93  if status != 0:
94  raise EnvironmentError('Error downloading tarball %s. Downloader reports: %s' % (tarball, output))
95  msg.info('Evgen tarball download success: %s' % output)
96 
97  expand_if_archive(tarball)
98  mk_jo_proxy(os.getcwd(), "MC14JobOptions", "_joproxy14")
99  mk_jo_proxy(os.getcwd(), "MC15JobOptions", "_joproxy15")
100 
106 
107  else:
108  if os.path.exists("/cvmfs/atlas.cern.ch"):
109  # TODO: Make the package name configurable
110  mk_jo_proxy("/cvmfs/atlas.cern.ch/repo/sw/Generators/MC14JobOptions/latest/", "MC14JobOptions","_joproxy14")
111  mk_jo_proxy("/cvmfs/atlas.cern.ch/repo/sw/Generators/MC15JobOptions/latest/", "MC15JobOptions","_joproxy15")
112  msg.info("No evgenJobOpts tarball specified, using JOBOPTSEARCHPATH = '%s'" % os.environ["JOBOPTSEARCHPATH"])
113  elif os.path.exists("/afs/cern.ch/atlas/groups/Generators"):
114  mk_jo_proxy("/afs/cern.ch/atlas/groups/Generators/MC14JobOptions/latest/", "MC14JobOptions","_joproxy14")
115  mk_jo_proxy("/afs/cern.ch/atlas/groups/Generators/MC15JobOptions/latest/", "MC15JobOptions","_joproxy15")
116  msg.info("No evgenJobOpts tarball specified, no cvmfs, using JOBOPTSEARCHPATH = '%s'" % os.environ["JOBOPTSEARCHPATH"])
117 
118 
119  if "inputGeneratorFile" in self._trf.argdict:
120  expand_if_archive(self._trf.argdict["inputGeneratorFile"].value)
121  if "inputGenConfFile" in self._trf.argdict:
122  expand_if_archive(self._trf.argdict["inputGenConfFile"].value)
123 
124 

The documentation for this class was generated from the following file:
python.jo_proxy.get_immediate_subdirectories
def get_immediate_subdirectories(a_dir)
Definition: jo_proxy.py:6
python.download.downloadUsingProxy
def downloadUsingProxy(url, filename=None)
Definition: download.py:5
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
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
Trk::split
@ split
Definition: LayerMaterialProperties.h:38
python.jo_proxy.mk_jo_proxy
def mk_jo_proxy(targetbasepath, pkgname, proxypath, addtosearch=True)
Definition: jo_proxy.py:10