-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_datacards.py
executable file
·100 lines (88 loc) · 2.92 KB
/
run_datacards.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
import numpy as np
import os
import sys
from threading import Thread
def readNorm(f_cscCard):
f = open(f_cscCard,"r")
norm = float(f.readline().split()[3])
return norm
def insert(originalfile,string):
with open(originalfile,'r') as f:
with open('newfile.txt','w') as f2:
f2.write(string)
f2.write(f.read())
os.rename('newfile.txt',originalfile)
if __name__ == '__main__':
input_dir='datacards_SR3_test'
tree_dir='limitTrees_SR3_test'
input_dir='mass_shape_analysis_dir'
tree_dir='mass_shape_analysis_dir_limits'
input_dir='datacards_SR3_test_UnB_v4_Raph_withGoodSignals'
tree_dir='limitTrees_SR3_test_UnB_v4_Raph_withGoodSignals'
os.system("mkdir -p {0}/".format(input_dir))
os.system("mkdir -p {0}/".format(tree_dir))
samples = [
'Gluino500_2018',
'Gluino800_2018',
'Gluino1000_2018',
'Gluino1400_2018',
'Gluino1600_2018',
'Gluino1800_2018',
'Gluino2000_2018',
'Gluino2200_2018',
'Gluino2400_2018',
'Gluino2600_2018',
'Stop400_2018',
'Stop500_2018',
'Stop800_2018',
'Stop1000_2018',
'Stop1200_2018',
'Stop1400_2018',
'Stop1600_2018',
'Stop1800_2018',
'Stop2000_2018',
'Stop2200_2018',
'Stop2400_2018',
'Stop2600_2018',
'pairStau308_2018',
'pairStau432_2018',
'pairStau557_2018',
'pairStau651_2018',
'pairStau745_2018',
'pairStau871_2018',
'pairStau1029_2018',
'DYcharge1e_500_2018',
'DYcharge1e_800_2018',
'DYcharge1e_1000_2018',
'DYcharge1e_1400_2018',
'DYcharge1e_1800_2018',
'DYcharge1e_2200_2018',
'DYcharge1e_2600_2018',
'DYcharge2e_500_2018',
#'DYcharge2e_800_2018',
'DYcharge2e_1000_2018',
'DYcharge2e_1400_2018',
'DYcharge2e_1800_2018',
'DYcharge2e_2200_2018',
'DYcharge2e_2600_2018',
]
#for sample in samples:
def task(sample):
name=sample
name2="datacard_"+sample
name2=sample
print name
run_combine = "combine -M AsymptoticLimits -n .{} -d {}/{}.txt --rRelAcc 0.000005 --rAbsAcc 0.000005 --rMin -1000.0 --rMax 1000.0".format(name, input_dir, name2)
print run_combine
#os.system(run_combine)
run_combine = "combine -M Significance -n.{} {}/{}.txt".format(name, input_dir, name2)
print run_combine
os.system(run_combine)
os.system("mv higgsCombine.{0}.AsymptoticLimits.mH120.root {1}/".format(name, tree_dir))
os.system("mv higgsCombine.{0}.Significance.mH120.root {1}/".format(name, tree_dir))
for sample in samples:
### use these two lines to run on parallel
t = Thread(target=task, args=(sample,))
#t.start()
### use this line to run one signal at once
task(sample)