-
Notifications
You must be signed in to change notification settings - Fork 2
/
getXsecTable.py
95 lines (80 loc) · 2.45 KB
/
getXsecTable.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
#! /usr/bin/env python
#-------------------------------------------------------------
# File: getXsecTable.py
# Created: 15 July 2016 Fang-Ying Tsai
#-------------------------------------------------------------
import glob
import errno
from ROOT import TGraph, TFile, TCanvas, TH2F, gStyle
from ROOT import TGraph2D
from array import array
class GetValue():
def __init__(self):
self.fileNum = []
self.zpMass = []
self.ma0Mass = []
self.mdmMass = []
self.weight = []
self.tanbeta = []
hAList = []
hApath = 'run_*.txt'
hA_files = glob.glob(hApath)
def getFile(fileName):
num = str(fileName).split("_")[1].split(".")[0]
global s
s = GetValue()
s.fileNum = int(num)
return s
def getMZpValue(readLine):
mzpValue = float(readLine.strip().split(' # ')[0].split('32 ')[1])
return mzpValue
def getMA0Value(readLine):
ma0Value = float(readLine.strip().split(' # ')[0].split('28 ')[1])
return ma0Value
def getMDMValue(readLine):
mdmValue = float(readLine.strip().split(' # ')[0].split('1000022 ')[1])
return mdmValue
def getWeightValue(readLine):
weightValue = float(readLine.split(' : ')[1])
return weightValue
def getTanBeta(readLine):
tbValue = float(readLine.split(' # ')[0].split()[1])
return tbValue
def gethAList(lhefile):
for name in lhefile:
s = getFile(name)
try:
with open(name) as f:
for lheFile in f:
if lheFile.find('mzp') > 0:
s.zpMass = getMZpValue(lheFile)
elif lheFile.find('ma0') > 0:
s.ma0Mass = getMA0Value(lheFile)
elif lheFile.find('mx') > 0:
s.mdmMass = getMDMValue(lheFile)
elif lheFile.find('Integrated weight') > 0:
s.weight = getWeightValue(lheFile)
elif lheFile.find('tb') > 0 and lheFile.find('#') > 0:
s.tanbeta = getTanBeta(lheFile)
hAList.append(s)
except IOError as exc:
if exc.errno != errno.EISDIR:
raise
return hAList
def main():
f = TFile("ScanXsec.root","recreate")
c1 = TCanvas( 'c1', 'A Simple Graph', 200, 10, 700, 500 )
c1.SetGrid()
hAList = gethAList(hA_files)
histo_hA0 = TH2F('xsec1','Xsec(gz=formula) pdf setting 653000', 12, 500,2800,8,200,900)
histo_hA0.SetXTitle("M_Zp (GeV)")
histo_hA0.SetYTitle("M_A0 (GeV)")
histo_hA0.SetStats(0)
for a in hAList:
histo_hA0.Fill(a.zpMass,a.ma0Mass,a.weight)
gStyle.SetPalette(1)
f.Write()
f.Close()
c1.Update()
if __name__ == "__main__":
main()