This repository has been archived by the owner on Jun 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SuperimposeTagrates4.py
141 lines (110 loc) · 3.56 KB
/
SuperimposeTagrates4.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import ROOT
from ROOT import *
import array
from array import array
import math
from math import sqrt
import Bstar_Functions_local
from Bstar_Functions_local import TTR_Init, LoadConstants
Constants = LoadConstants()
Lumi = str(int(Constants["lumi"]))+'pb'
tagrates_H0 = ROOT.TFile("../plots/TWrate_Maker_QCD_35851pb_PSET_rate_sideband1H0.root")
tagrates_H1 = ROOT.TFile("../plots/TWrate_Maker_QCD_35851pb_PSET_rate_sideband1H1.root")
c4 = TCanvas('c4', 'Pt fitted tagrate in 0.0 < Eta <0.8', 800, 500)
cuts = { "rate_sideband1H0": {
"graphBP": [],
"graphBPerrh": [],
"graphBPerrl": []
},
"rate_sideband1H1": {
"graphBP": [],
"graphBPerrh": [],
"graphBPerrl": []
}
}
# Make two sets of fits
for cut in cuts.keys():
TTR = TTR_Init('Bifpoly',cut,'QCD','tpt','../','')
TTR_err = TTR_Init('Bifpoly_err',cut,'QCD','tpt','../','')
x = array( 'd' )
BPy = []
BPerryh = []
BPerryl = []
# Initilize lists with empty arrays
for eta in range(0,2):
BPy.append(array( 'd' ))
BPerryh.append(array( 'd' ))
BPerryl.append(array( 'd' ))
# For each x (pt) increment store the y values for each non-BP fit and then the BP fit and errors
for j in range(0,2000):
x.append(j)
for eta in range(0,2):
BPy[eta].append(TTR[eta].Eval(x[j]))
BPerryh[eta].append(TTR[eta].Eval(x[j])+sqrt(TTR_err[eta].Eval(x[j])))
BPerryl[eta].append(TTR[eta].Eval(x[j])-sqrt(TTR_err[eta].Eval(x[j])))
graphBP = []
graphBPerrh = []
graphBPerrl = []
for eta in range(0,2):
graphBP.append(TGraph(len(x),x,BPy[eta]))
if cut == "rate_sideband1H0":
graphBP[eta].SetLineColor(kBlue)
if cut == "rate_sideband1H1":
graphBP[eta].SetLineColor(kRed)
graphBPerrh.append(TGraph(len(x),x,BPerryh[eta]))
graphBPerrl.append(TGraph(len(x),x,BPerryl[eta]))
if cut == "rate_sideband1H0":
graphBPerrh[eta].SetLineColor(kBlue)
graphBPerrl[eta].SetLineColor(kBlue)
elif cut == "rate_sideband1H1":
graphBPerrh[eta].SetLineColor(kRed)
graphBPerrl[eta].SetLineColor(kRed)
graphBP[eta].SetLineWidth(2)
graphBPerrh[eta].SetLineWidth(2)
graphBPerrl[eta].SetLineWidth(2)
graphBPerrh[eta].SetLineStyle(2)
graphBPerrl[eta].SetLineStyle(2)
cuts[cut]["graphBP"] = graphBP
cuts[cut]["graphBPerrh"] = graphBPerrh
cuts[cut]["graphBPerrl"] = graphBPerrl
trsLow = [None]*2
trsHigh = [None]*2
trsList = [trsLow, trsHigh]
trsLow[0]= tagrates_H0.Get("tagrateeta1")
trsLow[1]= tagrates_H0.Get("tagrateeta2")
trsHigh[0]= tagrates_H1.Get("tagrateeta1")
trsHigh[1]= tagrates_H1.Get("tagrateeta2")
c4.cd()
c4.SetLeftMargin(0.16)
etastring = [
'0.00 < |#eta| < 0.80',
'0.80 < |#eta| < 2.40'
]
for eta in range(0,2):
first = True
for trs in trsList:
trs[eta].SetTitle(';p_{T} (GeV);R_{P/F}')
trs[eta].GetYaxis().SetTitleOffset(0.8)
trs[eta].SetMaximum(0.20)
trs[eta].SetMinimum(0.0)
trs[eta].GetXaxis().SetRangeUser(400,1200)
trs[eta].SetStats(0)
#c4.cd()
if first == True:
trs[eta].SetLineColor(kBlue)
trs[eta].Draw("histe")
first = False
elif first == False:
trs[eta].SetLineColor(kRed)
trs[eta].Draw("samehiste")
cuts["rate_sideband1H0"]["graphBP"][eta].Draw("same")
cuts["rate_sideband1H0"]["graphBPerrh"][eta].Draw("same")
cuts["rate_sideband1H0"]["graphBPerrl"][eta].Draw("same")
cuts["rate_sideband1H1"]["graphBP"][eta].Draw("same")
cuts["rate_sideband1H1"]["graphBPerrh"][eta].Draw("same")
cuts["rate_sideband1H1"]["graphBPerrl"][eta].Draw("same")
c4.RedrawAxis()
c4.Print('plots/tagrateeta'+str(eta+1)+'QCDfitBP_cheat.pdf', 'pdf')
c4.Print('plots/tagrateeta'+str(eta+1)+'QCDfitBP_cheat.png', 'png')
tagrates_H0.Close()
tagrates_H1.Close()