forked from vinzenzstampf/PlotFactory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
code_snippets.py
45 lines (35 loc) · 1.11 KB
/
code_snippets.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
###################################
# counting bin content explicitly #
# and plotting result in a TGraph #
###################################
bincf1 = np.array([])
bincf0 = np.array([])
x0 = np.array([])
x1 = np.array([])
for i in range(len(binsx)):
#print("bin", i, "content", h0_smu_cf1_pT.GetBinContent(i))
bincf1 = np.append(bincf1,h1.GetBinContent(i))
bincf0 = np.append(bincf0,h0.GetBinContent(i))
if (bincf1[i]+bincf0[i])!=0:
x1 = np.append(x1,bincf1[i]/(bincf0[i]+bincf1[i]))
x0 = np.append(x0,bincf0[i]/(bincf0[i]+bincf1[i]))
print("#binsx=%i"%len(binsx),"and #x1=%i"%len(x1)," resp. #x0=%i"%len(x0))
c30.cd()
gr0 = ROOT.TGraph(len(x0),binsx,x0)
gr0.Draw("AB")
c31.cd()
gr1 = ROOT.TGraph(len(x1),binsx,x1)
gr1.Draw("AB")
#########################
# some plotting options #
########################
logspace = False
if logspace == True:
binsx = np.logspace(-6, 3, 50) # 50 evenly spaced points from -6 to 3
binsy = np.logspace(-2.2, 0.03, 50) # 50 evenly spaced points from 10^-3 to 10^3 cm
c1.SetLogx()
c1.SetLogy()
c1.SetGridx()
c1.SetGridy()
c2.SetGridx()
c2.SetGridy()