Debian Codegraph @

devtools/plot/plotpardep.py

raw symbols SCIP
1 # script to plot the form factor
2 # after the ROOT window with plots appear,
3 # just save the picture in that format which you need
4
5 import ROOT
6 from libBornAgainCore import *
7
8 # define a form factor, I recommend a 10--20 nm diameter
9 #ff = FormFactorFullSphere(10.0*nanometer)
10 ff05 = FormFactorSphere(10.0*nanometer, 5.0*nanometer)
11 ff10 = FormFactorSphere(10.0*nanometer, 10.0*nanometer)
12 ff15 = FormFactorSphere(10.0*nanometer, 15.0*nanometer)
13
14 # zero q vector
15 zero = cvector_t(0,0,0)
16 # volume of particles
17 V05 = abs(ff05.evaluate_for_q(zero))
18 V10 = abs(ff10.evaluate_for_q(zero))
19 V15 = abs(ff15.evaluate_for_q(zero))
20
21
22 # number of bins for qx, qy, qz
23 # I recommend to put at least 400 for a better picture quality
24 nqy = 100
25 nqz = 100
26 nqx = 100
27
28 # minimum and maximum values for qx, qy qz
29 qymin = -2.0
30 qymax = 2.0
31 qzmin = -2.0
32 qzmax = 2.0
33 qxmin = -2.0
34 qxmax = 2.0
35
36 # first and last bin for the projection slice
37 # if number of bins=400, then fbin should be set to 200 and lbin to 201
38 #fbin=50
39 #lbin=51
40
41 # step for qx, qy, qz
42 stepqy = (qymax - qymin)/(nqy-1)
43 stepqz = (qzmax - qzmin)/(nqz-1)
44 stepqx = (qxmax - qxmin)/(nqx-1)
45
46 # define style of the diagram
47 ROOT.gROOT.SetStyle("Plain")
48 ROOT.gStyle.SetOptStat(0);
49 ROOT.gStyle.SetOptTitle(1);
50 ROOT.gStyle.SetLabelSize(0.06, "xyz");
51 ROOT.gStyle.SetTitleSize(0.06, "xyz");
52 ROOT.gStyle.SetTitleFontSize(0.1);
53 #ROOT.gStyle.SetPadRightMargin(0.19)
54 ROOT.gStyle.SetPadLeftMargin(0.18)
55 ROOT.gStyle.SetPadBottomMargin(0.18)
56 ROOT.gStyle.SetTitleX(0.3);
57 #ROOT.gStyle.SetTitleW(0.5);
58
59
60 #t = ROOT.TText()
61 # create ROOT histograms
62 h05 = ROOT.TH2D("h05nm","H = 5 nm",nqy,qymin,qymax, nqz, qzmin, qzmax)
63 h10 = ROOT.TH2D("h10nm","H = 10 nm",nqy,qymin,qymax, nqz, qzmin, qzmax)
64 h15 = ROOT.TH2D("h15nm","H = 15 nm",nqy,qymin,qymax, nqz, qzmin, qzmax)
65
66 # and fill them with the values
67 for i in range(nqy):
68 qy = qymin + i*stepqy
69 for j in range(nqz):
70 qz = qzmin + j*stepqz
71 k = cvector_t(0,qy,qz)
72 h05.Fill(qy,qz,(abs(ff05.evaluate_for_q(k))/V05)**2)
73 h10.Fill(qy,qz,(abs(ff10.evaluate_for_q(k))/V10)**2)
74 h15.Fill(qy,qz,(abs(ff15.evaluate_for_q(k))/V15)**2)
75
76
77
78 # create a ROOT canvas and put all plots on it
79 c = ROOT.TCanvas("FormfactorSphere","Formfactor Sphere", 1200,400)
80
81 c.Divide(3,1)
82 h05.SetMinimum(5e-8)
83 #h05.SetMaximum(V05**2)
84 h05.SetMaximum(1)
85 h10.SetMinimum(5e-8)
86 #h10.SetMaximum(V10**2)
87 h10.SetMaximum(1)
88 h15.SetMinimum(5e-8)
89 #h15.SetMaximum(V15**2)
90 h15.SetMaximum(1)
91 h05.SetContour(50)
92 h10.SetContour(50)
93 h15.SetContour(50)
94 #h05.GetZaxis().SetTitle(" |F|^{2} ")
95 #h10.GetZaxis().SetTitle(" |F|^{2} ")
96 #h15.GetZaxis().SetTitle(" |F|^{2} ")
97
98
99 c.cd(1)
100 ROOT.gPad.SetLogz()
101 h05.GetXaxis().SetTitle(" q_{y} [nm^{-1}] ")
102 h05.GetXaxis().CenterTitle()
103 h05.GetXaxis().SetTitleOffset(1.1)
104 h05.GetYaxis().SetTitle(" q_{z} [nm^{-1}] ")
105 h05.GetYaxis().CenterTitle()
106 h05.GetYaxis().SetTitleOffset(1.4)
107 h05.GetZaxis().SetTitleOffset(1.3)
108 h05.Draw("col")
109 #t.SetNDC(1)
110 #t.SetTextSize(8.0e-2)
111 #t.DrawText(0.1, 0.01, "H = 5 nm")
112
113 c.cd(2)
114 ROOT.gPad.SetLogz()
115 h10.GetXaxis().SetTitle(" q_{y} [nm^{-1}] ")
116 h10.GetXaxis().CenterTitle()
117 h10.GetXaxis().SetTitleOffset(1.1)
118 h10.GetYaxis().SetTitle(" q_{z} [nm^{-1}] ")
119 h10.GetYaxis().CenterTitle()
120 h10.GetYaxis().SetTitleOffset(1.4)
121 h10.GetZaxis().SetTitleOffset(1.3)
122 h10.Draw("col")
123 #t.SetNDC(1)
124 #t.SetTextSize(8.0e-2)
125 #t.DrawText(0.1, 0.01, "H = 10 nm")
126
127 c.cd(3)
128 ROOT.gPad.SetLogz()
129 h15.GetXaxis().SetTitle(" q_{y} [nm^{-1}] ")
130 h15.GetXaxis().CenterTitle()
131 h15.GetXaxis().SetTitleOffset(1.1)
132 h15.GetYaxis().SetTitle(" q_{z} [nm^{-1}] ")
133 h15.GetYaxis().CenterTitle()
134 h15.GetYaxis().SetTitleOffset(1.4)
135 h15.GetZaxis().SetTitleOffset(1.3)
136 h15.Draw("col")
137 #t.SetNDC(1)
138 #t.SetTextSize(8.0e-2)
139 #t.DrawText(0.1, 0.01, "H = 15 nm")
140
141 # draw projections
142 #c.cd(4)
143 #ROOT.gPad.SetLogy()
144 #p05 = h05.ProjectionX("p05", fbin, lbin, 'o')
145 #p05.GetYaxis().SetTitle(" |F|^{2} ")
146 #p05.GetYaxis().SetTitleOffset(1.3)
147 #p05.Draw()
148 #t.DrawText(0.1, 0.01, "d")
149
150 #c.cd(5)
151 #ROOT.gPad.SetLogy()
152 #p10 = h10.ProjectionX("p10", fbin, lbin, 'o')
153 #p10.GetYaxis().SetTitle(" |F|^{2} ")
154 #p10.GetYaxis().SetTitleOffset(1.3)
155 #p10.Draw()
156 #t.DrawText(0.1, 0.01, "e")
157
158 #c.cd(6)
159 #ROOT.gPad.SetLogy()
160 #p15 = h15.ProjectionX("p15", fbin, lbin, 'o')
161 #p15.GetYaxis().SetTitle(" |F|^{2} ")
162 #p15.GetYaxis().SetTitleOffset(1.3)
163 #p15.Draw()
164 #t.DrawText(0.1, 0.01, "f")
165
166
167
168 c.Update()
169 ROOT.gApplication.Run()
170
171
172