-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakeMap.py
More file actions
90 lines (78 loc) · 3.02 KB
/
makeMap.py
File metadata and controls
90 lines (78 loc) · 3.02 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
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
#!/usr/bin/env/python
import glob,gzip
import re
numbers = re.compile(r'(\d+)')
def numericalSort(value):
parts = numbers.split(value)
parts[1::2] = map(int, parts[1::2])
return parts
#############################################################
AnalysisType = "Type2"
##############################################################
MassPattern = "Mass : "
LimitPatternObs = "XSec_Obs : "
LimitPatternExp = "XSec_Exp : "
LimitPatternExpUp = "XSec_ExpUp : "
LimitPatternExpDown = "XSec_ExpDown : "
XSectionPattern = "XSec_Th : "
f = open(str('MapTable_' + AnalysisType + '_LARGE.txt'), 'w')
f.write('INDEX MASS WIDTH XSECTION OBSLIMIT EXPLIMIT EXPLIMITUP EXPLIMITDOWN\n')
outputdir = str("Results/" + AnalysisType + "/EXCLUSION8TeV/")
analysisfile = "Analysis_Samples_withWidth.txt"
# list all output dirs
outputdirs = glob.glob(outputdir + "pMSSM*_m*_width*.txt")
outputdirs = sorted(glob.glob(outputdir + "pMSSM*_m*_width*.txt"), key=numericalSort)
print "found:",len(outputdirs),"output files"
for outputfile in outputdirs[0:1000]:
# which is the slha file used?
FILE = open(outputfile)
scenarioFile = outputfile.split("EXCLUSION8TeV/")
scenarioName = scenarioFile[1][0:-4]
print scenarioName
index = scenarioName[-3:]
print "last chars :" + index
print index.find("h")
if index.find("_") >= 0:
index2 = index.split("_")
elif index.find("h") >= 0:
index2 = index.split("h")
print index2[1]
lines = FILE.read().split("\n")
FILE.close()
mass = ""
for line in lines:
if line.find(MassPattern) == 0:
mass = line[len(MassPattern):-1]
elif line.find(LimitPatternObs) == 0:
limitobs = line[len(MassPattern):-1]
if(float(limitobs)>10**9):
limitobs = -1
#print "Limit too large"
elif line.find(LimitPatternExp) == 0:
limitexp = line[len(MassPattern):-1]
if(float(limitexp)>10**9):
limitexp = -1
#print "Limit too large"
elif line.find(LimitPatternExpUp) == 0:
limitexpUp = line[len(MassPattern):-1]
if(float(limitexpUp)>10**9):
limitexpUp = -1
elif line.find(LimitPatternExpDown) == 0:
limitexpDown = line[len(MassPattern):-1]
if(float(limitexpDown)>10**9):
limitexpDown = -1
elif line.find(XSectionPattern) == 0:
xsec = line[len(XSectionPattern):-1]
FILE = open(analysisfile)
lines = FILE.read().split("\n")
FILE.close()
for line in lines:
print line
if line.find('"' + scenarioName + '"') == 0:
width = float(line.split(",")[1])
print width
#print mass
#print xsec
#print limit
#print ""
f.write(str(index2[1]) + " " + str(mass) + " " + str('%0.7E' %(width)) + " " + xsec + " " + str(limitobs) +" " + str(limitexp) +" " + str(limitexpUp) +" " + str(limitexpDown) + "\n")