Debian Codegraph @

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