-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrunSystematics_unfolding_int.py
159 lines (150 loc) · 7.74 KB
/
runSystematics_unfolding_int.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/bin/python
import fileinput,sys,os,subprocess,re,time
from datetime import datetime, timedelta
from random import choice
from os import listdir
from os.path import isfile, join
import time
pwd = os.getcwd()
listOfFiles=[]
typesList=[]
MClist=["ZZ", "Zgamma", "WV", "WZZJets", "ZZZJets", "WWZJets", "WWWJets", "TTWJets", "TTZJets", "TTWWJets", "TTGJets", "WWGJets"]
#MClist=[]
OtherList=["pu_syst", "ele_scale_syst", "mu_scale_syst", "ele_SF", "mu_SF"]
#DDlist=["dataDriven"]
DDlist=["dataDriven_el", "dataDriven_mu"]
METlist=["met_elEn", "met_jetEn", "met_jetRes", "met_muEn", "met_tauEn", "met_unEn"]
#METlist=[]
#ktermList=["kterm_up", "kterm_down"]
ktermDict={'kterm_up':6,'kterm_down':4}
other=["JER", "JES", "UnfoldingStat"]
submit = True
#submit = False
sysList = open('sysrun2.def', 'r').read().split('\n')
#sysList = open('sysrunTEST.def', 'r').read().split('\n')
outputNom="sys_nominal.def"
listOfFiles.append(outputNom)
sysList = sysList[:-1]
newfileNom=open(outputNom,'w')
for line in sysList:
if line[:1]=="#":
continue
if len(line)==0:
continue
types= line.split()
typesList.append(types[0])
####
newfileNom.write(line+'\n')
outputUp="sys_"+types[0]+"_UP.def"
outputDown="sys_"+types[0]+"_DOWN.def"
if types[0] in MClist:
listOfFiles.append(outputDown)
listOfFiles.append(outputUp)
newfileUp=open(outputUp,'w')
newfileDown=open(outputDown,'w')
for line2 in sysList:
if line2!=line:
newfileUp.write(line2+'\n')
newfileDown.write(line2+'\n')
else:
newfileUp.write(types[0]+'\t'+'1 \n')
newfileDown.write(types[0]+'\t'+'-1 \n')
newfileUp.close()
newfileDown.close()
variations=["UP", "DOWN"]
variables=["Njets", "LeadingJetPt", "Zpt"]
#variables=["LeadingJetPt"]
algorithm="Bayes"
#global command
for v in variables:
for var in variations:
for nameMET in METlist:
response= "sysResults/response_"+nameMET+"_"+var+".root"
dataFile="inputHistograms2/forVukoNew/binning06/data_driven.root"
WZfile="inputHistograms2/forVukoNew/binning06/"+nameMET+"_"+var+"/WZ.root"
backgroundListName ="backgroundList06"
outputFile="sysResults/unfolding_"+nameMET+"_"+v+"_"+var+".root"
systFileName="sys_nominal.def"
command = "./wzDataUnfold -r "+ response + " -d " + dataFile + " -B "+ backgroundListName + " -t "+ WZfile+ " -v "+ v + " -a "+algorithm+" -o "+ outputFile + " -S "+ systFileName
print command
if submit:
p=subprocess.call(command,shell=True)
for name in ktermDict:
response="sysResults/response_sys_nominal.root"
dataFile="inputHistograms2/forVukoNew/binning06/data_driven.root"
WZfile= "inputHistograms2/forVukoNew/binning06/WZ.root"
backgroundListName ="backgroundList06"
outputFile="sysResults/unfolding_"+name+"_"+v+".root"
command = "./wzDataUnfold -r "+ response + " -d " + dataFile + " -B "+ backgroundListName + " -t "+ WZfile+ " -v "+ v + " -a "+algorithm+" -o "+ outputFile + " -k "+ str(ktermDict[name])
print command
if submit:
p=subprocess.call(command,shell=True)
for name in typesList:
outputFile = "sysResults/unfolding_"+ name +"_"+ v + ".root"
if name in DDlist:
response= "sysResults/response_sys_nominal.root"
dataFile= "inputHistograms2/forVukoNew/binning06/dataDrivenSys/data_driven_"+name+".root"
WZfile= "inputHistograms2/forVukoNew/binning06/WZ.root"
backgroundListName ="backgroundList06"
outputFile = "sysResults/unfolding_"+ name +"_"+ v + ".root"
systFileName="nominal.def"
command = "./wzDataUnfold -r "+ response + " -d " + dataFile + " -B "+ backgroundListName + " -t "+ WZfile+ " -v "+ v + " -a "+algorithm+" -o "+ outputFile + " -S "+ systFileName
print command
if submit:
p = subprocess.call(command,shell=True)
else:
for var in variations:
if name in MClist:
response= "sysResults/response_sys_nominal.root"
dataFile= "inputHistograms2/forVukoNew/binning06/data_driven.root"
WZfile= "inputHistograms2/forVukoNew/binning06/WZ.root"
backgroundListName ="backgroundList_syst"
outputFile = "sysResults/unfolding_"+ name +"_"+ v +"_"+var+ ".root"
systFileName="sys_"+name+"_"+var+".def"
command = "./wzDataUnfold -r "+ response + " -d " + dataFile + " -B "+ backgroundListName + " -t "+ WZfile+ " -v "+ v + " -a "+algorithm+" -o "+ outputFile + " -S "+ systFileName
print command
if submit:
p=subprocess.call(command, shell=True)
if name in OtherList:
response= "sysResults/response_sys_"+name+"_"+var+".root"
dataFile= "inputHistograms2/forVukoNew/binning06/data_driven.root"
WZfile= "inputHistograms2/forVukoNew/binning06/"+name+"_"+var+"/WZ.root"
backgroundListName ="backgroundList06"+name+"_"+var
outputFile = "sysResults/unfolding_"+ name +"_"+ v +"_"+var+ ".root"
systFileName="sys_"+name+"_"+var+".def"
systFileName="sys_nominal.def"
command = "./wzDataUnfold -r "+ response + " -d " + dataFile + " -B "+ backgroundListName + " -t "+ WZfile+ " -v "+ v + " -a "+algorithm+" -o "+ outputFile + " -S "+ systFileName
print command
if submit:
p=subprocess.call(command, shell=True)
if name in other:
response= "sysResults/response_sys_"+name+"_"+var+".root"
dataFile= "inputHistograms2/forVukoNew/binning06/data_driven.root"
WZfile= "inputHistograms2/forVukoNew/binning06/WZ.root"
backgroundListName ="backgroundList06"
outputFile = "sysResults/unfolding_"+ name +"_"+ v +"_"+var+ ".root"
systFileName="sys_"+name+"_"+var+".def"
systFileName="sys_nominal.def"
command = "./wzDataUnfold -r "+ response + " -d " + dataFile + " -B "+ backgroundListName + " -t "+ WZfile+ " -v "+ v + " -a "+algorithm+" -o "+ outputFile + " -S "+ systFileName
if submit:
p = subprocess.call(command,shell=True)
response= "sysResults/response_sys_nominal.root"
dataFile= "inputHistograms2/forVukoNew/binning06/data_driven.root"
WZfile= "inputHistograms2/forVukoNew/binning06/WZ.root"
backgroundListName ="backgroundList06"
outputFile = "sysResults/unfolding_nominal_"+v+".root"
systFileName="sys_nominal.def"
command = "./wzDataUnfold -r "+ response + " -d " + dataFile + " -B "+ backgroundListName + " -t "+ WZfile+ " -v "+ v + " -a "+algorithm+" -o "+ outputFile + " -S "+ systFileName
print command
if submit:
p = subprocess.call(command,shell=True)
response= "sysResults/response_met_nominal.root"
dataFile="inputHistograms2/forVukoNew/binning06/data_driven.root"
WZfile="inputHistograms2/forVukoNew/binning06/met_nominal/WZ.root"
backgroundListName ="backgroundList06"
outputFile="sysResults/unfolding_met_nominal_"+v+".root"
systFileName="nominal.def"
command = "./wzDataUnfold -r "+ response + " -d " + dataFile + " -B "+ backgroundListName + " -t "+ WZfile+ " -v "+ v + " -a "+algorithm+" -o "+ outputFile + " -S "+ systFileName
print command
if submit:
p = subprocess.call(command,shell=True)