-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPlotGenCF.py
267 lines (230 loc) · 8.42 KB
/
PlotGenCF.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
import argparse
from ROOT import (
TFile,
TCanvas,
TLatex,
gStyle,
kBlue,
kGray,
kOrange,
TLegend,
TGraphErrors,
kWhite,
kRed,
kGreen,
kBlack
)
from fempy.utils.format import TranslateToLatex
def LoadObjects(pair, suffix):
objs = {
'sc': {},
'oc': {},
}
if pair == 'DstarK':
file = TFile(f'/home/daniel/an/DstarK/2_luuksel/GenCFCorr_{suffix}.root')
for comb in ['sc', 'oc']:
objs[comb] = {
'hstat': file.Get(f'{comb}/hCFGenStat'),
'stat': file.Get(f'{comb}/gCFGenStat'),
'syst': file.Get(f'{comb}/gCFGenSyst'),
'llstat': file.Get(f'{comb}/gLLStat'),
'lltot': file.Get(f'{comb}/gLLTot'),
'coulomb': file.Get(f'{comb}/gCoulomb'),
}
objs[comb]['hstat'].SetDirectory(0)
objs['sc']['a0'] = -0.305
objs['sc']['a0stat'] = 0.235
objs['sc']['a0syst'] = 0.083
objs['oc']['a0'] = -0.232
objs['oc']['a0stat'] = 0.181
objs['oc']['a0syst'] = 0.062
config = {
'pltRangeX': [0, 299.9999],
'pltRangeY': [-0.2, 3.4999],
}
file.Close()
elif pair == 'DstarPi':
file = TFile(f'/home/daniel/an/DstarPi/20_luuksel/GenCFCorr_{suffix}.root')
for comb in ['sc', 'oc']:
objs[comb] = {
'hstat': file.Get(f'{comb}/hCFGenStat'),
'stat': file.Get(f'{comb}/gCFGenStat'),
'syst': file.Get(f'{comb}/gCFGenSyst'),
'llstat': file.Get(f'{comb}/gLLStat'),
'lltot': file.Get(f'{comb}/gLLTot'),
'coulomb': file.Get(f'{comb}/gCoulomb'),
}
objs[comb]['hstat'].SetDirectory(0)
# old values obtained from non simul fit
objs['sc']['a0'] = 0.112
objs['sc']['a0stat'] = 0.035
objs['sc']['a0syst'] = 0.026
objs['oc']['a0'] = -0.047
objs['oc']['a0stat'] = 0.033
objs['oc']['a0syst'] = 0.019
# from simul fit
objs['3/2'] = {}
objs['3/2']['a0'] = 0.12
objs['3/2']['a0stat'] = 0.04
objs['3/2']['a0syst'] = 0.02
objs['1/2'] = {}
objs['1/2']['a0'] = -0.12
objs['1/2']['a0stat'] = 0.06
objs['1/2']['a0syst'] = 0.03
config = {
'pltRangeX': [0, 300],
'pltRangeY': [0.7, 1.9],
}
file.Close()
return objs, config
def Setstyle():
gStyle.SetTextFont(42)
gStyle.SetPadBottomMargin(0.15)
gStyle.SetPadLeftMargin(0.15)
gStyle.Reset("Plain")
gStyle.SetOptTitle(False)
gStyle.SetTitleBorderSize(0)
gStyle.SetOptStat(0)
gStyle.SetCanvasColor(10)
gStyle.SetCanvasBorderMode(0)
gStyle.SetFrameLineWidth(1)
gStyle.SetFrameFillColor(kWhite)
gStyle.SetPadColor(10)
gStyle.SetPadTickX(1)
gStyle.SetPadTickY(1)
gStyle.SetPadBottomMargin(0.15)
gStyle.SetPadLeftMargin(0.15)
gStyle.SetHistLineWidth(1)
gStyle.SetHistLineColor(kRed)
gStyle.SetFuncWidth(2)
gStyle.SetFuncColor(kGreen)
gStyle.SetLineWidth(2)
gStyle.SetLabelSize(0.045, "xyz")
gStyle.SetLabelOffset(0.01, "y")
gStyle.SetLabelOffset(0.01, "x")
gStyle.SetLabelColor(kBlack, "xyz")
gStyle.SetTitleSize(0.05, "xyz")
gStyle.SetTitleOffset(1.25, "y")
gStyle.SetTitleOffset(1.2, "x")
gStyle.SetTitleFillColor(kWhite)
gStyle.SetTextSizePixels(26)
gStyle.SetTextFont(42)
gStyle.SetLegendFillColor(kWhite)
gStyle.SetLegendFont(42)
gStyle.SetLegendBorderSize(0)
gStyle.SetErrorX(0.005)
# gStyle.SetPalette(kBird)
def SetHistStyle(hist):
hist.GetXaxis().SetLabelSize(0.045)
hist.GetXaxis().SetTitleSize(0.05)
hist.GetXaxis().SetLabelOffset(0.01)
hist.GetXaxis().SetTitleOffset(1.2)
hist.GetXaxis().SetLabelFont(42)
hist.GetYaxis().SetLabelSize(0.045)
hist.GetYaxis().SetTitleSize(0.05)
hist.GetYaxis().SetLabelOffset(0.01)
hist.GetYaxis().SetTitleOffset(1.25)
hist.SetMarkerStyle(20)
hist.SetMarkerSize(1)
def ComputeBinBrackets(hist):
gBrackets = TGraphErrors(1)
print(hist)
for iBin in range(hist.GetNbinsX()):
gBrackets.SetPoint(iBin, hist.GetBinCenter(iBin+1), hist.GetBinContent(iBin+1))
gBrackets.SetPointError(iBin, hist.GetBinWidth(iBin+1)/2, 0)
return gBrackets
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--pair', choices=('DstarK', 'DstarPi'))
parser.add_argument('--simfit', default=False, action='store_true')
args = parser.parse_args()
if args.pair == 'DstarPi':
suffix = 'nopc_kStarBW50MeV_bs5000syst'
else:
suffix = 'nopc_kStarBW50MeV_fromq_bs5000syst'
Setstyle()
objects, cfg = LoadObjects(args.pair, suffix)
cCF = TCanvas('cCF', '', 1000, 500)
cCF.Divide(2, 1)
for iPad, comb in enumerate(['sc', 'oc']):
objs = objects[comb]
pad = cCF.cd(iPad+1)
pad.SetRightMargin(0.03)
pad.SetTopMargin(0.03)
pad.SetFrameLineWidth(1)
pad.DrawFrame(
cfg['pltRangeX'][0],
cfg['pltRangeY'][0],
cfg['pltRangeX'][1],
cfg['pltRangeY'][1], TranslateToLatex(';__kStarMeV__;__C__'))
objs['lltot'].SetFillColorAlpha(kBlue+1, 0.7)
objs['lltot'].SetLineColorAlpha(0, 0)
objs['lltot'].Draw('same e3')
objs['fit'] = objs['lltot'].Clone()
objs['fit'].SetName('gFit')
objs['fit'].Write('gFit')
# objs['llstat'].SetFillColorAlpha(kBlue+1, 0.7)
# objs['llstat'].SetLineColorAlpha(0, 0)
# objs['llstat'].Draw('same e3')
objs['coulomb'].SetLineColor(kOrange+7)
objs['coulomb'].SetLineStyle(1)
objs['coulomb'].SetLineWidth(2)
objs['coulomb'].Draw('same l')
objs['syst'].SetFillColorAlpha(kGray+2, 0.65)
objs['syst'].Draw('same e2')
objs['stat'].SetMarkerSize(1)
objs['stat'].SetMarkerStyle(24)
objs['stat'].Draw('same pez')
gBrackets = ComputeBinBrackets(objs['hstat'])
SetHistStyle(gBrackets)
gBrackets.SetLineWidth(1)
gBrackets.SetLineColorAlpha(kBlack, 0.9)
gBrackets.DrawClone("same []")
tl = TLatex()
tl.SetTextSize(0.04)
tl.SetNDC(True)
if iPad == 0:
tl.DrawLatex(0.22, 0.88, 'ALICE pp #sqrt{#it{s}} = 13 TeV')
tl.DrawLatex(0.22, 0.82, 'High-mult. (0 #minus 0.17% INEL > 0)')
tl.DrawLatex(0.22, 0.76, TranslateToLatex(f'k{args.pair}_{comb}'))
leg = TLegend(0.2, 0.55, 0.9, 0.7)
leg.SetTextSizePixels(12)
leg.SetTextSize(0.035)
leg.SetLineColorAlpha(0, 0)
leg.SetFillStyle(0)
leg.AddEntry(objs['stat'], 'Genuine CF', 'pel')
leg.AddEntry(objs['coulomb'], 'Coulomb only', 'l')
leg.AddEntry(objs['lltot'], 'Lednický-Lyuboshits model', 'f')
leg.Draw()
if not args.simfit:
text = f'a_{{0}} = {objs["a0"]:.2f} #pm {objs["a0stat"]:.2f} (stat) #pm {objs["a0syst"]:.2f} (syst) fm'
tl.DrawLatex(0.20, 0.2, text)
else:
tl.DrawLatex(0.20, 0.88, TranslateToLatex(f'k{args.pair}_{comb}'))
if args.simfit:
text3_2 = (
f'a_{{0}}(I=3/2) = {objects["3/2"]["a0"]:.2f} '
f' #pm {objects["3/2"]["a0stat"]:.2f} (stat)'
f' #pm {objects["3/2"]["a0syst"]:.2f} (syst) fm'
)
tl.DrawLatex(0.20, 0.25, text3_2)
text1_2 = (
f'a_{{0}}(I=1/2) = {objects["1/2"]["a0"]:.2f}'
f' #pm {objects["1/2"]["a0stat"]:.2f} (stat)'
f' #pm {objects["1/2"]["a0syst"]:.2f} (syst) fm'
)
tl.DrawLatex(0.20, 0.25-0.05, text1_2)
else:
text = f'a_{{0}} = {objs["a0"]:.2f} #pm {objs["a0stat"]:.2f} (stat) #pm {objs["a0syst"]:.2f} (syst) fm'
tl.DrawLatex(0.20, 0.2, text)
for ext in ['pdf', 'png', 'eps', 'root']:
if args.pair == 'DstarK':
cCF.SaveAs(f'/home/daniel/an/DstarK/2_luuksel/GenCFCorrPlot_{args.pair}_{suffix}.{ext}')
else:
oFileName = (
'/home/daniel/an/DstarPi/20_luuksel/'
f'GenCFCorrPlot_{args.pair}_{suffix}{"_simfit" if args.simfit else ""}.{ext}'
)
cCF.SaveAs(oFileName)
if __name__ == '__main__':
main()