-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_weights.py
More file actions
55 lines (38 loc) · 953 Bytes
/
plot_weights.py
File metadata and controls
55 lines (38 loc) · 953 Bytes
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
from ROOT import *
import sys
from array import array
f=TFile('test.root','recreate')
mytree=TTree("tree","tree")
w=array('f',[0])
mytree.Branch('weight',w,'weight/F')
f_input=open("delete_this.txt",'r')
binning=array('f')
print len(binning)
#for p in range(-2,6):
# for k in range(1,10):
# binning.extend([k* pow(10,p)])
factor=1.02
min_bin=0.000001
min_width=0.000001
current_bin=min_bin
current_width=min_width
binning.extend([current_bin])
for i in range(1,1000):
binning.extend([current_bin+current_width])
current_bin=current_bin+current_width
current_width=current_width*factor
print "last bin edge:"
print binning[len(binning)-1]
for i in binning:
print i
for line in f_input:
w[0]=float(line)/3.5925000e-04
#print w[0]
mytree.Fill()
print len(binning)
f.cd()
hist=TH1F("my_hist","reweight/SM weight",len(binning)-1,binning)
mytree.Draw("weight>>my_hist")
hist.Draw()
f.Write()
f.Close()