Skip to content

Instantly share code, notes, and snippets.

@swang373
Created June 12, 2018 18:18
Show Gist options
  • Save swang373/0ad38b479f0f506eb38b170495dcd6d8 to your computer and use it in GitHub Desktop.
Save swang373/0ad38b479f0f506eb38b170495dcd6d8 to your computer and use it in GitHub Desktop.
Split an AnalysisTools resubmission job into more subjobs and calculate the starts and stops
import sys
# The only command line argument should be the path to a file
# where each line is a set of arguments for resubmission.
with open(sys.argv[1]) as f:
lines = f.read().splitlines()
for line in lines:
start, stop = line.split()[-3:-1]
start = float(start)
stop = float(stop)
step = (stop - start) / 20.
current_start = start
for i in range(20):
newargs = line.split()
newargs[-4] = newargs[-4].replace('.root', 'part{0!s}.root'.format(i))
newargs[-3] = str(current_start)
newargs[-2] = str(current_start + step)
current_start += step
print ' '.join(newargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment