-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocessAllSignals.py
104 lines (80 loc) · 2.84 KB
/
processAllSignals.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
from array import array
from optparse import OptionParser
from optparse import OptionGroup
import ROOT
ROOT.PyConfig.IgnoreCommandLineOptions = True
import sys
import os
import stat
import subprocess
import time
import shutil
import imp
ROOT.gROOT.SetBatch(True)
ROOT.gDirectory.cd('PyROOT:/')
directory = os.path.dirname(os.path.abspath(sys.argv[0]))
basefolder = os.path.abspath(os.path.join(directory, "base"))
if not basefolder in sys.path:
sys.path.append(basefolder)
pathToCMSSWsetup="/nfs/dust/cms/user/swieland/Darkmatter/CombineStuff/unfoldedlimits/setupCMSSW_8_1_0.txt"
usage = "usage: %prog [options]"
parser = OptionParser(usage = usage)
parser.add_option("--generateOnly",
dest="generateOnly",
action="store_true",
help="only generate Script, don't automatically submit them",
metavar = "generateOnly",
default = False
)
parser.add_option("--SamplePath",
dest="SamplePath",
action="store_true",
help="Path of Samples, default=/nfs/dust/cms/user/swieland/Darkmatter/ntuples_signal_madgraph_tagging",
metavar = "SamplePath",
default = "/nfs/dust/cms/user/swieland/Darkmatter/ntuples_signal_madgraph_tagging"
)
(options, args) = parser.parse_args()
SamplePath = options.SamplePath
generateOnly = options.generateOnly
axialsamples = []
vectorsamples = []
pseudosamples = []
scalarsamples = []
listnames = ["Axial", "Vector", "Pseudo", "Scalar"]
lists = [axialsamples, vectorsamples, pseudosamples, scalarsamples]
for x in os.listdir(SamplePath):
for i,listname in enumerate(listnames):
if x.startswith(listname):
lists[i].append(x)
# print axialsamples
os.system("rm /nfs/dust/cms/user/swieland/Darkmatter/DM_Unfolding/rootfiles/signals.root")
os.system("mkdir -p rootfiles/signals")
commands=[]
script = """#!/bin/bash
cd /nfs/dust/cms/user/swieland/Darkmatter/CMSSW_8_0_26_patch2/src
eval `scramv1 runtime -sh`
cd -
"""
samplescript = ""
print len(lists)
for samples, listname in zip(lists, listnames):
for i, sample in enumerate(samples):
samplescript += "echo '" + sample + "'\n"
samplescript += """root -l -b -q '/nfs/dust/cms/user/swieland/Darkmatter/DM_Unfolding/processSignalSamples.C(\"""" + sample + """\","/nfs/dust/cms/user/swieland/Darkmatter/DM_Unfolding/rootfiles/signals.root" )'\n"""
directory = "/nfs/dust/cms/user/swieland/Darkmatter/DM_Unfolding/scripts/"
filename = directory+"Job_"+listname+str(i)+".sh"
if not os.path.exists(directory):
os.makedirs(directory)
f = open(filename, 'w')
f.write(script+samplescript)
f.close()
samplescript = ""
print filename
commands.append(filename)
print "created scripts in ", directory
if not generateOnly:
submitstring = "python submit.py -a SignalsArrayJob.sh "
for command in commands:
submitstring += command
submitstring += " "
os.system(submitstring)