ATLAS Offline Software
Functions
sherpaTarCreator.jobDefinitions Namespace Reference

Functions

def mkGetOpenLoopsJob (options)
 
def mkCreateLibsJob (options, prevJob)
 
def mkMakelibsJob (options, prevJob)
 
def mkIntegrateJob (options, ecm, prevJob)
 
def mkTarballmakerJob (options, ecm, prevJob)
 
def mkEvntGenTestJob (options, ecm, jodir, prevJob)
 

Function Documentation

◆ mkCreateLibsJob()

def sherpaTarCreator.jobDefinitions.mkCreateLibsJob (   options,
  prevJob 
)

Definition at line 53 of file jobDefinitions.py.

53 def mkCreateLibsJob(options, prevJob):
54  if not ("createLibs" in options.performOnly or "all" in options.performOnly):
55  return None
56 
57  procName = "Process/*.db" if os.environ["SHERPAVER"].startswith('2.') else "Process/*.zip"
58  if len(glob.glob(procName)) > 0:
59  return None
60 
61  job = options.batchSystemModule.batchJob("1.createLibs", hours=48, nCores=1, memMB=options.createLibsRAM, basedir=options.jobOptionDir[0])
62 
63  if prevJob:
64  job.dependsOnOk.append(prevJob.id)
65 
66  job.cmds += ["source $AtlasSetup/scripts/asetup.sh "+options.athenaVersion]
67  job.cmds += ["set -e"]
68 
69  if os.environ["SHERPAVER"].startswith('2.'):
70  job.cmds += ["rm -rf Process/Amegic.db Process/Comix.db Process/Sherpa.db Process/Amegic"]
71  job.cmds += ["echo 'genSeq.Sherpa_i.Parameters += [ \"INIT_ONLY=1\", \"EVENTS=0\", \"FRAGMENTATION=Off\", \"MI_HANDLER=None\", \"LOG_FILE=\"]\n' > events.py"]
72  else:
73  job.cmds += ["rm -rf Process/Amegic.zip Process/Comix.zip Process/Sherpa.zip Process/Amegic"]
74  job.cmds += ["echo 'genSeq.Sherpa_i.BaseFragment += \"\"\"\nINIT_ONLY: 1\nEVENTS: 0\nFRAGMENTATION: Off\nMI_HANDLER: None\n\"\"\"' > events.py"]
75 
76  job.cmds += ["outputEVNTFile=$(mktemp -u /tmp/XXXXXXXX.pool.root)"]
77  job.cmds += ["returncode=0"]
78  job.cmds += ["Gen_tf.py --ecmEnergy="+str(options.ecm[0]*1000.)+" --maxEvents=1 --firstEvent=1 --randomSeed=10 --jobConfig="+options.jobOptionDir[0]+" --postInclude=events.py --outputEVNTFile=${outputEVNTFile} || returncode=$?"]
79  job.cmds += ["echo Pasting log.generate ==============="]
80  job.cmds += ["cat log.generate"]
81  job.cmds += ["echo Gen_tf exited with return code $returncode"]
82  job.cmds += ["if [ $returncode -eq 251 ]; then"]
83  job.cmds += [" echo 'ERROR: OpenLoops-libary is missing: add missing OpenLoops-libary (see http://openloops.hepforge.org/process_library.php) to variable genSeq.Sherpa_i.OpenLoopsLibs in the jobOption-file, remove Process directory and start again'"]
84  job.cmds += [" exit 1"]
85  job.cmds += ["fi"]
86  job.cmds += ["if [ $returncode -eq 65 ]; then"]
87  job.cmds += [" if grep -q 'Sherpa: Sherpa::InitializeTheRun throws normal exit' log.generate || grep -q 'ERROR Have to compile Amegic libraries' log.generate; then"]
88  job.cmds += [" echo 'Libraries successfully written out. (Ignore errors above.)'"]
89  job.cmds += [" elif grep -q 'INFO Have to compile Amegic libraries' log.generate; then"]
90  job.cmds += [" echo 'Libraries successfully written out with <=2.2.1. (Ignore errors above.)'"]
91  job.cmds += [" else"]
92  job.cmds += [" echo 'ERROR: Gen_tf.py has failed in an unexpected way. This likely means your job options are incorrect. This log file will have more details.'"]
93  job.cmds += [" exit 1"]
94  job.cmds += [" fi"]
95  job.cmds += ["fi"]
96  job.cmds += ["if [ $returncode -ne 0 -a $returncode -ne 251 -a $returncode -ne 65 ]; then"]
97  job.cmds += [" echo 'ERROR: unexpexted error from Gen_tf'"]
98  job.cmds += [" exit 1"]
99  job.cmds += ["fi"]
100 
101  job.cmds += ["rm -rf ${outputEVNTFile} _joproxy* AtRndmGenSvc.out AthenaSummary_Generate.txt Generate_messageSvc_jobOptions.py Generate_runathena PoolFileCatalog.xml PoolFileCatalog.xml.BAK TransformTimer_Generate.pickle config.pickle dmesg_trf.txt hostnamelookup.tmp inputDictionary.pickle jobInfo.xml jobInfo_Generate.xml jobReport* last.Generate last.runargs.gpickle runargs.Generate.gpickle runargs.Generate.py metadata_Generate.xml metadata.xml Sherpa_References.tex ntuple.pmon.stream setupevprod.sh share ntuple.pmon.gz testHepMC.root events.py Bdecays0.dat Bs2Jpsiphi.DEC DECAY.DEC G4particle_acceptlist.txt PDGTABLE.MeV pdt.table runargs.generate.py runwrapper.generate.sh eventLoopHeartBeat.txt susyParticlePdgid.txt TestHepMC.root log.generate mem.full.generate mem.summary.generate.json env.txt Run.dat Sherpa.yaml"]
102 
103  job.write()
104  job.submit(dryRun=options.dryRun)
105  return job
106 
107 

◆ mkEvntGenTestJob()

def sherpaTarCreator.jobDefinitions.mkEvntGenTestJob (   options,
  ecm,
  jodir,
  prevJob 
)

Definition at line 268 of file jobDefinitions.py.

268 def mkEvntGenTestJob(options, ecm, jodir, prevJob):
269  if not ("evgen" in options.performOnly or "all" in options.performOnly):
270  return None
271 
272  ecmstring = ('{0:g}'.format(ecm)).replace(".","p")+"TeV"
273  ecmfolder = "ecm"+ecmstring
274 
275  job = options.batchSystemModule.batchJob("5.EvntGenTest", hours=24, nCores=1, memMB=1, basedir=jodir+"/"+ecmfolder)
276 
277  if prevJob:
278  job.dependsOnOk.append(prevJob.id)
279 
280  job.cmds += ["source $AtlasSetup/scripts/asetup.sh "+options.athenaVersion]
281  job.cmds += ["set -e"]
282 
283  job.cmds += ["rm -rf 5.EvntGenTest"]
284  job.cmds += ["mkdir 5.EvntGenTest"]
285  job.cmds += ["cd 5.EvntGenTest"]
286  if os.environ["SHERPAVER"].startswith('2.'):
287  job.cmds += ["echo 'genSeq.Sherpa_i.Parameters += [ \"LOG_FILE=\" ]' > events.py"]
288  job.cmds += ["outputEVNTFile=$(mktemp -u /tmp/XXXXXXXX.pool.root)"]
289  if os.environ["SHERPAVER"].startswith('2.'):
290  job.cmds += ["Gen_tf.py --ecmEnergy="+str(ecm*1000.)+" --maxEvents=1 --firstEvent=1 --randomSeed=10 --jobConfig="+jodir+" --postInclude=events.py --outputEVNTFile=${outputEVNTFile} --maxEvents="+str(options.nEvts)]
291  else:
292  job.cmds += ["Gen_tf.py --ecmEnergy="+str(ecm*1000.)+" --maxEvents=1 --firstEvent=1 --randomSeed=10 --jobConfig="+jodir+" --outputEVNTFile=${outputEVNTFile} --maxEvents="+str(options.nEvts)]
293  job.cmds += ["cat log.generate"]
294 
295 
296  job.cmds += ["post_ini_time=$(grep snapshot_post_ini log.generate | awk '{ print $5}')"]
297  job.cmds += ["post_lastevt_time=$(grep snapshot_post_lastevt log.generate | awk '{ print $5}')"]
298  job.cmds += ["nPer12h=$(awk -v a=\"$post_lastevt_time\" -v b=\"$post_ini_time\" 'BEGIN { printf \"%.0f\", "
299  +str(options.nEvts)+"*12*60*60*1000/(a-b) }' </dev/null)"]
300  job.cmds += ["finalEventsPerJob=0"]
301  job.cmds += ["for i in 1 2 5 10 20 50 100 200 500 1000 2000 5000 10000; do if test $nPer12h -gt $i; then finalEventsPerJob=$i; fi; done"]
302  job.cmds += ["echo \"Possible number of events per 12h: ${nPer12h} -> ${finalEventsPerJob} \""]
303  job.cmds += ["if grep -q evgenConfig.nEventsPerJob "+jodir+"/mc.*.py; then"]
304  job.cmds += [r' sed -e "s/evgenConfig.nEventsPerJob.*=.*\‍([0-9]*\‍)/evgenConfig.nEventsPerJob = ${finalEventsPerJob}/g" -i '+jodir+"/mc.*.py"]
305  job.cmds += ["else"]
306  job.cmds += [" echo \"evgenConfig.nEventsPerJob = ${finalEventsPerJob}\" >> "+jodir+"/mc.*.py"]
307  job.cmds += ["fi"]
308 
309  # cp log.generate to DSID dir such that commit script can run on it
310  job.cmds += ["cp log.generate ../../"]
311 
312  job.cmds += ["cd .."]
313  job.cmds += ["rm -rf 5.EvntGenTest"]
314 
315  job.write(extraDirs=[jodir])
316  job.submit(dryRun=options.dryRun)
317  return job

◆ mkGetOpenLoopsJob()

def sherpaTarCreator.jobDefinitions.mkGetOpenLoopsJob (   options)

Definition at line 5 of file jobDefinitions.py.

5 def mkGetOpenLoopsJob(options):
6  if not ("getOpenLoops" in options.performOnly or "all" in options.performOnly):
7  return None
8 
9  if len(options.Sherpa_i.OpenLoopsLibs) == 0:
10  return None
11 
12  # check availability of OL libs in /cvmfs and warn user
13  if not options.OLskipcvmfs:
14  olpath = str(os.environ['OPENLOOPSPATH'])
15  cvmfsInstalledOpenLoopsLibs = glob.glob(olpath + "/proclib/*.so")
16  if not any(not any(x in fil for fil in cvmfsInstalledOpenLoopsLibs) for x in options.Sherpa_i.OpenLoopsLibs):
17  print("You requested the inclusion of OpenLoops libs in the tarball (genSeq.Sherpa_i.OpenLoopsLibs), but all of them are available centrally in /cvmfs. Will continue without including them in the tarball, and you can remove the genSeq.Sherpa_i.OpenLoopsLibs line from your JO.")
18  return None
19 
20  # alternatively check wether all needed openLoops libaries are installed
21  installedOpenLoopsLibs = glob.glob("Process/OpenLoops/proclib/*.so")
22  #each string in openLoopsLibs has to be part of one string in installedOpenLoopsLibs
23  if len(options.Sherpa_i.OpenLoopsLibs) == len(installedOpenLoopsLibs) and not any(not any(x in fil for fil in installedOpenLoopsLibs) for x in options.Sherpa_i.OpenLoopsLibs):
24  return None
25 
26  #delete openloops folder if it exists
27  if os.path.exists("Process/OpenLoops"):
28  shutil.rmtree("Process/OpenLoops")
29 
30  job = options.batchSystemModule.batchJob("0.getOpenLoops", hours=2, nCores=options.ncoresScons, memMB=1, basedir=options.jobOptionDir[0])
31 
32  job.cmds += ["source $AtlasSetup/scripts/asetup.sh "+options.athenaVersion]
33  job.cmds += ["set -e"]
34 
35  olbranch = options.OLbranch if options.OLbranch is not None else ('OpenLoops-'+os.environ['OPENLOOPSVER'])
36  job.cmds += ["git clone -b "+olbranch+" https://gitlab.com/openloops/OpenLoops.git"]
37 
38  job.cmds += ["cd OpenLoops"]
39  job.cmds += ["./scons num_jobs="+str(options.ncoresScons)]
40  job.cmds += ["./openloops libinstall process_repositories="+options.OLprocessrepos+" num_jobs="+str(options.ncoresScons)+" "+' '.join(options.Sherpa_i.OpenLoopsLibs)]
41  job.cmds += ["cd .."]
42 
43  job.cmds += ["rm -rf Process/OpenLoops"]
44  job.cmds += ["mkdir -p Process/OpenLoops"]
45  job.cmds += ["mv OpenLoops/proclib OpenLoops/lib Process/OpenLoops/"]
46  job.cmds += ["rm -rf OpenLoops"]
47 
48  job.write()
49  job.submit(dryRun=options.dryRun)
50  return job
51 
52 

◆ mkIntegrateJob()

def sherpaTarCreator.jobDefinitions.mkIntegrateJob (   options,
  ecm,
  prevJob 
)

Definition at line 141 of file jobDefinitions.py.

141 def mkIntegrateJob(options, ecm, prevJob):
142  ecmfolder = "ecm"+('{0:g}'.format(ecm)).replace(".","p")+"TeV"
143 
144  if not ("integrate" in options.performOnly or "all" in options.performOnly):
145  return None
146 
147  resname = "Results.db" if os.environ["SHERPAVER"].startswith('2.') else "Results.zip"
148  if os.path.isfile(ecmfolder+"/"+resname) and os.path.isfile(ecmfolder+"/3.integrate.log"):
149  return None
150 
151  # calculate integration time
152  targetHours = 24
153  targetCores = options.Sherpa_i.NCores
154  if options.maxCores < options.Sherpa_i.NCores:
155  targetHours = int(round(24.*options.Sherpa_i.NCores/options.maxCores))
156  targetCores = options.maxCores
157 
158  if options.RAM > 100:
159  options.Sherpa_i.MemoryMB = options.RAM
160  job = options.batchSystemModule.batchJob("3.integrate", hours=targetHours, nCores=targetCores, memMB=options.Sherpa_i.MemoryMB, basedir=options.jobOptionDir[0]+"/"+ecmfolder)
161 
162  if prevJob:
163  job.dependsOnOk.append(prevJob.id)
164 
165  job.cmds += ["source $AtlasSetup/scripts/asetup.sh "+options.athenaVersion]
166  job.cmds += ["set -e"]
167 
168  if os.environ["SHERPAVER"].startswith('3.'):
169  # write base fragment into Base.yaml
170  job.cmds += ["cat > Base.yaml <<EOL"]
171  job.cmds += [options.Sherpa_i.BaseFragment]
172  job.cmds += ["EOL"]
173  # disable ATLAS RNG as integration job runs outside Athena
174  job.cmds += [r"sed '/.*EXTERNAL_RNG.*/d' -i Base.yaml"]
175  #write rundata into Run.dat/Sherpa.yaml file for integration
176  configname = "Run.dat" if os.environ["SHERPAVER"].startswith('2.') else "Sherpa.yaml"
177  job.cmds += ["cat > "+configname+" <<EOL"]
178  job.cmds += [options.Sherpa_i.RunCard]
179  job.cmds += ["EOL"]
180  #append infos in options
181  ecmopt = ["BEAM_ENERGY_1="+str(ecm/2.*1000), "BEAM_ENERGY_2="+str(ecm/2.*1000)] \
182  if os.environ["SHERPAVER"].startswith('2.') else ["BEAM_ENERGIES: "+str(ecm/2.*1000)]
183  ignoreopt = ["RUNDATA","LOG_FILE","NNPDF_GRID_PATH","RESULT_DIRECTORY"]
184  totopt = options.Sherpa_i.Parameters + ecmopt
185  if options.Sherpa_i.PluginCode != "":
186  if os.environ["SHERPAVER"].startswith('2.'):
187  totopt.append("SHERPA_LDADD=Sherpa_iPlugin")
188  else:
189  totopt.append("SHERPA_LDADD: Sherpa_iPlugin")
190  for s in totopt:
191  if not (re.split(r'\W',s)[0] in ignoreopt):
192  if os.environ["SHERPAVER"].startswith('2.'):
193  job.cmds += [r"sed '/.*\}(run).*/i\ \ "+s+"' -i Run.dat"]
194  else:
195  job.cmds += [r"sed '/.*PROCESSES:.*/i"+s+"\\n' -i Sherpa.yaml"]
196 
197  olpath = str(os.environ['OPENLOOPSPATH'])
198  lcglayer = olpath[olpath.find("LCG_"):olpath.find("/MCGenerators")]
199  sftlayer = "/cvmfs/sft.cern.ch/lcg/releases/" + lcglayer
200  lcgbase = "_".join(lcglayer.split('_')[:2]) # without postfix
201  sftbase = "/cvmfs/sft.cern.ch/lcg/releases/" + lcgbase
202 
203  if not options.sherpaInstallPath:
204  options.sherpaInstallPath = sftlayer+"/MCGenerators/sherpa/${SHERPAVER}.openmpi3/${LCG_PLATFORM}"
205 
206 
207  LCG_PLATFORM = str(os.environ['LCG_PLATFORM'])
208 
209  openmpi_path = ":".join(glob.glob(sftbase+"/openmpi/*/"+LCG_PLATFORM+"/bin"))
210  opal_prefix = ":".join(glob.glob(sftbase+"/openmpi/*/"+LCG_PLATFORM))
211  ld_library_path = ":".join(glob.glob(sftbase+"/openmpi/*/"+LCG_PLATFORM+"/lib"))
212  gccpath = str(os.environ['COMPILER_PATH'])
213 
214  job.cmds += ["source "+gccpath+"/setup.sh" ]
215  job.cmds += ["export PATH="+openmpi_path+":$PATH"]
216  job.cmds += ["export LHAPATH=/cvmfs/sft.cern.ch/lcg/external/lhapdfsets/current:/cvmfs/atlas.cern.ch/repo/sw/Generators/lhapdfsets/current/"]
217  job.cmds += ["export OPAL_PREFIX="+opal_prefix]
218  job.cmds += ["export LD_LIBRARY_PATH="+ld_library_path+":" \
219  +sftbase+"/zlib/*/${LCG_PLATFORM}/lib:" \
220  +sftbase+"/sqlite/*/${LCG_PLATFORM}/lib:" \
221  +sftbase+"/HepMC/*/${LCG_PLATFORM}/lib:" \
222  +sftlayer+"/MCGenerators/lhapdf/*/${LCG_PLATFORM}/lib:" \
223  +sftlayer+"/fastjet/*/${LCG_PLATFORM}/lib:" \
224  +olpath+"/lib:"+olpath+"/proclib:" \
225  +options.sherpaInstallPath+"/lib64/SHERPA-MC:" \
226  +options.sherpaInstallPath+"/lib/SHERPA-MC:$LD_LIBRARY_PATH"]
227 
228  cmdLineOpts = "EVENTS=0 FRAGMENTATION=Off MI_HANDLER=None"
229  if os.environ["SHERPAVER"].startswith('2.'):
230  cmdLineOpts += " BEAM_ENERGY_1="+str(ecm/2.*1000)+" BEAM_ENERGY_2="+str(ecm/2.*1000)
231  else:
232  cmdLineOpts += " \"RUNDATA: [Base.yaml, Sherpa.yaml]\" BEAM_ENERGIES="+str(ecm/2.*1000)
233  job.cmds += ["mpirun -n {0} ".format(str(targetCores))+options.sherpaInstallPath+"/bin/Sherpa "+cmdLineOpts]
234 
235  job.write(extraDirs=[options.jobOptionDir[0]])
236  job.submit(dryRun=options.dryRun)
237  return job
238 
239 
240 

◆ mkMakelibsJob()

def sherpaTarCreator.jobDefinitions.mkMakelibsJob (   options,
  prevJob 
)

Definition at line 108 of file jobDefinitions.py.

108 def mkMakelibsJob(options, prevJob):
109  if not ("makelibs" in options.performOnly or "all" in options.performOnly):
110  return None
111 
112  if os.path.exists("Process/Amegic/lib"):
113  return None
114 
115  job = options.batchSystemModule.batchJob("2.makelibs", hours=48, nCores=options.ncoresMakelibs, memMB=1, basedir=options.jobOptionDir[0])
116 
117  if prevJob:
118  job.dependsOnOk.append(prevJob.id)
119 
120  job.cmds += ["if ! test -f makelibs; then echo INFO: No makelibs file found; exit 0; fi"]
121 
122  job.cmds += ["source $AtlasSetup/scripts/asetup.sh "+options.athenaVersion]
123 
124 
125  job.cmds += ["wget http://prdownloads.sourceforge.net/scons/scons-local-3.1.2.tar.gz"]
126  job.cmds += ["tar xzf scons-local-*.tar.gz"]
127  job.cmds += ["ln -s scons.py scons"]
128  job.cmds += ["export PATH=$PATH:$PWD"]
129 
130  job.cmds += ["set -e"]
131  job.cmds += ["./makelibs -j"+str(options.ncoresMakelibs)]
132  job.cmds += ["rm -rf Process/Amegic/P2_*"]
133 
134  job.cmds += ["rm -rf scons*"]
135 
136  job.write()
137  job.submit(dryRun=options.dryRun)
138  return job
139 
140 

◆ mkTarballmakerJob()

def sherpaTarCreator.jobDefinitions.mkTarballmakerJob (   options,
  ecm,
  prevJob 
)

Definition at line 241 of file jobDefinitions.py.

241 def mkTarballmakerJob(options, ecm, prevJob):
242  if not ("makeTarball" in options.performOnly or "all" in options.performOnly):
243  return None
244 
245  physicsShort = options.mainJOfile.split(".")[1]
246  ecmstring = ('{0:g}'.format(ecm)).replace(".","p")+"TeV"
247  ecmfolder = "ecm"+ecmstring
248  tarballname = "mc_"+ecmstring+"."+physicsShort+".GRID.tar.gz"
249 
250  job = options.batchSystemModule.batchJob("4.makeTarball", hours=1, nCores=1, memMB=1, basedir=options.jobOptionDir[0]+"/"+ecmfolder)
251  job.cmds += ["set -e"]
252 
253  if prevJob:
254  job.dependsOnOk.append(prevJob.id)
255 
256  resname = "Results.db" if os.environ["SHERPAVER"].startswith('2.') else "Results.zip"
257  job.cmds += ["tar czhf "+options.jobOptionDir[0]+"/"+tarballname+" $(ls -d "+resname+" Process 3.integrate.log 2>/dev/null) "+" ".join(options.Sherpa_i.ExtraFiles)]
258  for jodir in options.jobOptionDir[1:]:
259  job.cmds += ["ln -s "+options.jobOptionDir[0]+"/"+tarballname+" "+jodir]
260 
261  job.write(useSingularity=False, extraDirs=options.jobOptionDir)
262  job.submit(dryRun=options.dryRun)
263  return job
264 
265 
266 
267 
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
vtune_athena.format
format
Definition: vtune_athena.py:14
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
sherpaTarCreator.jobDefinitions.mkTarballmakerJob
def mkTarballmakerJob(options, ecm, prevJob)
Definition: jobDefinitions.py:241
MuonGM::round
float round(const float toRound, const unsigned int decimals)
Definition: Mdt.cxx:27
sherpaTarCreator.jobDefinitions.mkIntegrateJob
def mkIntegrateJob(options, ecm, prevJob)
Definition: jobDefinitions.py:141
sherpaTarCreator.jobDefinitions.mkMakelibsJob
def mkMakelibsJob(options, prevJob)
Definition: jobDefinitions.py:108
sherpaTarCreator.jobDefinitions.mkEvntGenTestJob
def mkEvntGenTestJob(options, ecm, jodir, prevJob)
Definition: jobDefinitions.py:268
sherpaTarCreator.jobDefinitions.mkCreateLibsJob
def mkCreateLibsJob(options, prevJob)
Definition: jobDefinitions.py:53
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
sherpaTarCreator.jobDefinitions.mkGetOpenLoopsJob
def mkGetOpenLoopsJob(options)
Definition: jobDefinitions.py:5
str
Definition: BTagTrackIpAccessor.cxx:11