-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplateCreation.py
More file actions
63 lines (53 loc) · 2 KB
/
templateCreation.py
File metadata and controls
63 lines (53 loc) · 2 KB
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
import os
import sys
def createDirIfNotExist(path):
if not os.path.exists(path):
print("CREATING DIR: ", path)
os.makedirs(path)
iDir = sys.argv[1]
sample = sys.argv[2]
outDir = sys.argv[3]
wpUp = sys.argv[4]
wpLo = sys.argv[5]
if("2016/" in iDir):
year="2016"
if("2016APV/" in iDir):
year="2016APV"
if("2017/" in iDir):
year="2017"
if("2018/" in iDir):
year="2018"
if "_CR" in outDir:
CRflag = True
else:
CRflag = False
#variations = ["nom","jesUp","jesDown","jerUp","jerDown","jmsUp","jmsDown","jmrUp","jmrDown","pnetUp","pnetDown","photonEsUp","photonEsDown","photonErUp","photonErDown"]
#no pnet
variations = ["nom","jesUp","jesDown","jerUp","jerDown","jmsUp","jmsDown","jmrUp","jmrDown","photonEsUp","photonEsDown","photonErUp","photonErDown"]
varProcessesSR = ["Hgamma", "ZGamma", "WGamma"]
for variation in variations:
if(variation!="nom"):
#only run variations on some processes
if(CRflag and ("JetHT" in sample or "TTbar" in sample or "QCD" in sample)):
continue
if(not CRflag and not ("Hgamma" in sample or "ZGamma" in sample or "WGamma" in sample)):
continue
if("photon" in variation and CRflag):
#Don't run photon variations in no-photon CR
continue
inputTag = variation
inputFile = "{0}/{1}_{2}.root".format(iDir,sample,inputTag)
outputFile = os.path.join(outDir,"nonScaled/",sample)
outputFile = outputFile+".root"
createDirIfNotExist(outDir+"/nonScaled")
createDirIfNotExist(outDir+"/scaled")
if(variation=="nom"):
mode="RECREATE"
else:
mode="UPDATE"
if CRflag:
cmd = "python templateMaker_CR.py -i {0} -o {1} -y {2} -p {3} -v {4} -m {5} -w {6} -w {7}".format(inputFile,outputFile,year,sample,variation,mode,wpUp,wpLo)
else:
cmd = "python templateMaker.py -i {0} -o {1} -y {2} -p {3} -v {4} -m {5} -w {6} -w {7}".format(inputFile,outputFile,year,sample,variation,mode,wpUp,wpLo)
print(cmd)
os.system(cmd)