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

Public Member Functions

def __init__ (self, name="generate", skeleton=None, skeletonCA=None, substep=None, inData=set(), outData=set())
 
def preExecute (self, input=set(), output=set())
 

Detailed Description

Definition at line 21 of file Gen_tf.py.

Constructor & Destructor Documentation

◆ __init__()

def Gen_tf.EvgenExecutor.__init__ (   self,
  name = "generate",
  skeleton = None,
  skeletonCA = None,
  substep = None,
  inData = set(),
  outData = set() 
)

Definition at line 23 of file Gen_tf.py.

23  def __init__(self, name="generate", skeleton=None, skeletonCA=None, substep=None, inData=set(), outData=set()):
24  athenaExecutor.__init__(self, name=name, skeletonFile=skeleton, skeletonCA=skeletonCA,
25  substep=substep, inputEventTest=False, tryDropAndReload=False,
26  inData=inData, outData=outData)
27 

Member Function Documentation

◆ preExecute()

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

Definition at line 28 of file Gen_tf.py.

28  def preExecute(self, input=set(), output=set()):
29  "Get input tarball, unpack and set up env if an evgenJobOpts arg was provided."
30 
31 
32  super(EvgenExecutor, self).preExecute(input, output)
33 
34  def expand_if_archive(filename):
35  "Function to expand a file if it is a zip archive or tarball"
36  if ".tar" in filename:
37  import tarfile
38  with tarfile.open(filename) as tf:
39  tf.extractall()
40  elif filename.endswith(".zip"):
41  import zipfile
42  zf = zipfile.ZipFile(filename)
43  zf.extractall()
44  zf.close()
45 
47  return [name for name in os.listdir(a_dir)
48  if os.path.isdir(os.path.join(a_dir, name))]
49 
50 
52  os.environ['LOCAL_INSTALL_DIR'] = (os.environ['JOBOPTSEARCHPATH']).split(":")[0]
53  if os.path.exists('/cvmfs/atlas.cern.ch/repo/sw/Generators/MCJobOptions/common'):
54  CommonCvmfsDir = '/cvmfs/atlas.cern.ch/repo/sw/Generators/MCJobOptions/common'
55  os.environ["JOBOPTSEARCHPATH"] = CommonCvmfsDir+":"+os.environ["JOBOPTSEARCHPATH"]
56  if os.path.exists('/cvmfs/atlas.cern.ch/repo/sw/Generators/MCJobOptions/common/MadGraphControl/dat/'):
57  datCvmfsDir = '/cvmfs/atlas.cern.ch/repo/sw/Generators/MCJobOptions/common/MadGraphControl/dat/'
58  os.environ["DATAPATH"] = datCvmfsDir+":"+os.environ["DATAPATH"]
59 # dsidparam = (self._trf.argdict["jobConfig"].value).values()[0][0]
60  dsidpar = (self._trf.argdict["jobConfig"].value).values()
61  dsidparam = list(dsidpar)[0][0]
62  # Adding cvmfs path to JOBOPTSEARCHPATH
63  if os.path.exists('/cvmfs/atlas.cern.ch/repo/sw/Generators/MCJobOptions/'):
64  BaseCvmfsPath = "/cvmfs/atlas.cern.ch/repo/sw/Generators/MCJobOptions/"
65 
66  if dsidparam.isdigit() and (len(dsidparam)==6 or len(dsidparam)==7):
67  #only dsid is provided, add cvmfs folder like 123xxx to JOBOPTSEARCHPATH
68  Jodir = dsidparam[:3]+'xxx'
69  if len(dsidparam)==7:
70  Jodir = dsidparam[0] + '/' + dsidparam[:4]+'xxx'
71  cwdir = os.getcwd()
72  cwd_ful = os.path.join(cwdir, dsidparam)
73  if (os.path.isdir(cwd_ful)):
74  os.environ["JOBOPTSEARCHPATH"] = cwd_ful+":"+os.environ["JOBOPTSEARCHPATH"]
75  os.environ["DATAPATH"] = cwd_ful+":"+os.environ["DATAPATH"]
76  else:
77  cwd_Jodir = os.path.join(cwdir,Jodir)
78  cwd_Jodir_ful = os.path.join(cwd_Jodir,dsidparam)
79  if (os.path.isdir(cwd_Jodir_ful)):
80  os.environ["JOBOPTSEARCHPATH"] = cwd_Jodir_ful+":"+os.environ["JOBOPTSEARCHPATH"]
81  os.environ["DATAPATH"] = cwd_Jodir_ful+":"+os.environ["DATAPATH"]
82  else:
83  if (os.path.isdir(BaseCvmfsPath)):
84  JoCvmfsPath = os.path.join(BaseCvmfsPath, Jodir)
85  JoCvmfsPath_ful = os.path.join(JoCvmfsPath, dsidparam)
86  os.environ["JOBOPTSEARCHPATH"] = JoCvmfsPath_ful+":"+os.environ["JOBOPTSEARCHPATH"]
87  os.environ["DATAPATH"] = JoCvmfsPath_ful+":"+os.environ["DATAPATH"]
88  else:
89  msg.error("No access to JOs cvmfs location. JOs should be placed in working directory or full path should be given.")
90  raise RuntimeError("JOs not found - no cvmfs access")
91  else: #Suppose full path of dsid folder is provided(/afs/.../123xxx/123456), add cvmfs floder and local path(/afs/.../123xxx) to JOBOPTSEARCHPATH
92  if dsidparam.startswith("Test"): # for testing
93  for token in (os.environ['JOBOPTSEARCHPATH']).split(":"):
94  if "jobOptions" in token:
95  search_token = token
96  break
97  search_token += "/EvgenJobTransforms/EvgenTest/" + dsidparam.split("Test")[-1]
98  os.environ["JOBOPTSEARCHPATH"] = search_token+":"+os.environ["JOBOPTSEARCHPATH"]
99  os.environ["DATAPATH"] = search_token+":"+os.environ["DATAPATH"]
100  elif (os.path.isdir(dsidparam)):
101  os.environ["JOBOPTSEARCHPATH"] = dsidparam+":"+os.environ["JOBOPTSEARCHPATH"]
102  os.environ["DATAPATH"] = dsidparam+":"+os.environ["DATAPATH"]
103  else:
104  msg.error("JOs not found, please check = '%s'" % dsidparam)
105  raise RuntimeError("JOs not found")
106 
107  msg.info("Using JOBOPTSEARCHPATH = '%s'" % os.environ["JOBOPTSEARCHPATH"])
108  msg.info("Using DATAPATH = '%s'" % os.environ["DATAPATH"])
109 
110  if "evgenJobOpts" in self._trf.argdict:
111  tarball = self._trf.argdict["evgenJobOpts"].value
112 
114  if tarball.startswith("http"):
115  url = tarball
116  tarball = os.basename(tarball)
117  else:
118  url = "http://cern.ch/atlas-computing/links/kitsDirectory/EvgenJobOpts/" + tarball
119 
120  if not os.path.exists(tarball):
121  from EvgenJobTransforms.download import downloadUsingProxy
122  status, output = downloadUsingProxy(url)
123  if status != 0:
124  raise EnvironmentError('Error downloading tarball %s. Downloader reports: %s' % (tarball, output))
125  msg.info('Evgen tarball download success: %s' % output)
126 
127  expand_if_archive(tarball)
128 
130 
131  # copy config files to cwd
132  FIRST_DIR = (os.environ['JOBOPTSEARCHPATH']).split(":")[0]
133  configFiles = [f for f in os.listdir(FIRST_DIR) if ( "GRID" in f)]
134  confFile=None
135  if len(configFiles) == 1:
136  confFile = os.path.join(FIRST_DIR, configFiles[0])
137  elif len(configFiles) >1:
138  msg.info("more then one gridpack ! ")
139  if "--ecmEnergy" in str(sys.argv[1:]):
140  split_args=str(sys.argv[1:]).split("ecmEnergy=",1)[1]
141  ener_GeV=split_args.split(",")[0].strip("\'")
142  energy=str(float(ener_GeV)/1000.0).replace('.','p').strip(" =0\p']")
143  msg.info("Should be used gridpack for energy "+energy)
144  else:
145  energy="13"
146  for x in configFiles:
147  gridS="mc_"+energy+"TeV"
148  msg.info("Gridpack should start from "+gridS)
149  if x.startswith(gridS):
150  confFile = os.path.join(FIRST_DIR, x)
151  msg.info("using gridpack = "+confFile)
152  if confFile is None:
153  msg.error("No *GRID* config files, for requested energy = '%s' please check = '%s'" %(energy,dsidparam))
154 
155  if confFile is not None:
156  expand_if_archive(confFile)
157 # os.system("cp %s ." % confFile)
158  msg.info("Configuration input gridpack found " + confFile)
159 
160  #Expand if a tarball is found in local directory
161  loc_files = os.listdir(os.getcwd())
162  for loc_file in loc_files:
163  if "GRID" not in loc_file:
164  expand_if_archive(loc_file)
165 
166 
167  if "inputGeneratorFile" in self._trf.argdict:
168 # expand_if_archive(self._trf.argdict["inputGeneratorFile"].value)
169  myinputfiles = self._trf.argdict["inputGeneratorFile"].value
170  genInputFiles = myinputfiles.split(',')
171  for file in genInputFiles:
172  expand_if_archive(file)
173  if "inputGenConfFile" in self._trf.argdict:
174  expand_if_archive(self._trf.argdict["inputGenConfFile"].value)
175 

The documentation for this class was generated from the following file:
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
python.jo_proxy.get_immediate_subdirectories
def get_immediate_subdirectories(a_dir)
Definition: jo_proxy.py:6
python.Bindings.values
values
Definition: Control/AthenaPython/python/Bindings.py:805
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
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
str
Definition: BTagTrackIpAccessor.cxx:11
readCCLHist.float
float
Definition: readCCLHist.py:83
Trk::split
@ split
Definition: LayerMaterialProperties.h:38