susy_cfa  b611ccad937ea179f86a1f5663960264616c0a20
data_combine.py
Go to the documentation of this file.
1 #! /usr/bin/env python
2 
3 ### Script to send batch jobs of combinations for data PDs
4 
5 import sys
6 import subprocess
7 import os
8 from glob import glob
9 
10 if len(sys.argv) < 2:
11  print "\nFormat is: ./run/data_combine.py infolder <outfolder=out> <datasets.txt>\n"
12  sys.exit()
13 else:
14  infolder = sys.argv[1]
15 
16 if len(sys.argv) < 3:
17  outfolder = 'out/'
18 else:
19  outfolder = sys.argv[2]
20 
21 if len(sys.argv) < 4:
22  filename = 'txt/datasamples/singlelep.txt'
23 else:
24  filename = sys.argv[3]
25 
26 sample_file = open(filename, 'r')
27 
28 
29 lines = sample_file.readlines()
30 
31 # We split datasets by run ranges to be able to make the combination in parallel
32 # Finding unique run ranges
33 files = infolder+"/*"+lines[0].strip()+"*"
34 flist = glob(files)
35 runset = set()
36 print "Files matching "+files
37 for file in flist:
38  runs = file.split("Run")[1]
39  runs = runs.split("_")[0]
40  runset.add(runs+"_")
41 
42 runset = list(runset) # Converting set to list
43 for run in runset:
44  command = "JobSubmit.csh ./run/wrapper.sh combine_datasets.exe -i "+infolder+" -t "+run+" -f "+filename+" -o "+outfolder
45  print command
46  os.system(command)