Newer
Older
Master_thesis / job.py
import os
import sys


njobs = 1
batchdir = '/disk/data12/lhcb/saslie/batch/lhcb/data'

for njob in xrange(njobs):
  jobnumber = njob+1000
  runnumber = '00000'+str(jobnumber)
  if jobnumber >= 10:
   runnumber = '0000'+str(jobnumber)
  if jobnumber >= 100:
   runnumber = '000'+str(jobnumber)
  if jobnumber >= 1000:
   runnumber = '00'+str(jobnumber)
  f = open('job%s.sh'%jobnumber,'w')
  f.write(str(runnumber))
  f.write("#!/bin/sh -xe \n")
  f.write("source ~/setup-grid-ui.sh \n")
  #f.write("source ~/mu3e_latest/mu3e/install/activate.sh \n")
  f.write("mkdir -p data \n")
  f.write("mkdir -p results \n")
  f.write("python test.py")
  #f.write("cp ~/mu3e_latest/mu3e/tests/digi_bg.json digi.json \n")
  #f.write("echo '/lhcb/run/setRunNumber '%s > pipeline%s.mac \n"%(jobnumber,jobnumber))
  #f.write("echo '/run/beamOn 20000' >> pipeline%s.mac \n"%jobnumber)
  #f.write("mu3eSim --script ~/mu3e_latest/mu3e/tests/pipeline%s.mac --output '%s/mu3e_run_%s.root' \n"%(jobnumber,batchdir,runnumber))
  #f.write("""mu3eSort \\
  #  '%s/mu3e_run_%s.root' \\
   # '%s/run%s-sort.root' \n"""%(batchdir,runnumber,batchdir,runnumber))
  #f.write("""mu3eTrirec \\
   # --input %s/run%s-sort.root \\
   # --output %s/run%s-reco.root \n"""%(batchdir,runnumber,batchdir,runnumber))
  #f.write("""mu3eAnaVertexfit \\
  #   %s/run%s-reco.root \\
   #  %s/run%s-ana_vertexfit.root \n"""%(batchdir,runnumber,batchdir,runnumber))
  #f.write("""mu3eAnaSignalnorm \\
  #  %s/run%s-sort.root \n"""%(batchdir,runnumber))
  #f.write("nsignal=$(cat signalnorm.txt) \n")
  #f.write("""mu3eAnaSignalana \\
   #   %s/run%s-ana_vertexfit.root \\
   #   signal%s \\
   #   "I" \\
   #   "$nsignal" \\
   #   1 \n"""%(batchdir,runnumber,runnumber))
  #f.write("rm %s/*_run_*%s*.root \n"%(batchdir,runnumber))
  #f.write("rm %s/*%s*reco.root \n"%(batchdir,runnumber))
  #f.write("rm %s/*%s*sort.root \n"%(batchdir,runnumber))
  #f.write("rm %s/*%s*vertexfit.root \n"%(batchdir,runnumber))
  #f.write("cp -R skims/skim_signal%s.root /disk/data12/lhcb/powen/batch/mu3e/ \n"%runnumber)
  #f.write("rm -r skims/skim_signal%s.root \n"%runnumber)
  #f.write("cp -R results/signal%s /disk/data12/lhcb/powen/batch/mu3e/ \n"%runnumber)
  #f.write("rm -r results/signal%s \n"%runnumber)
  f.close()
  os.system('chmod 755 job%s.sh'%jobnumber)
  #os.system('qsub -q express job%s.sh'%jobnumber)