/
visualize.py
executable file
·123 lines (93 loc) · 3.43 KB
/
visualize.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
#!/usr/bin/env python
import sys, getopt
import ROOT
import numpy.testing as npt
from myTypes import RootFile
def main(argv):
print argv
f = RootFile(fn=argv[1], hn=argv[2])
f.fillUpAllVariables()
f.fileObj.Print()
f.writePlanesToPngFiles()
title="title..."
h2_sum_x = ROOT.TH2D("h2_sum_x","Cumulative yz-projection",f.binN.y,f.minL.y,f.maxL.y,f.binN.z,f.minL.z,f.maxL.z)
h2_sum_y = ROOT.TH2D("h2_sum_y","Cumulative xz-projection",f.binN.x,f.minL.x,f.maxL.x,f.binN.z,f.minL.z,f.maxL.z)
h2_sum_z = ROOT.TH2D("h2_sum_z","Cumulative xy-projection",f.binN.x,f.minL.x,f.maxL.x,f.binN.y,f.minL.y,f.maxL.y)
dose_max=f.histObj.Project3D("xy").GetBinContent(f.histObj.Project3D("xy").GetMaximumBin())
c1=ROOT.TCanvas("c1", title ,2000,2000)
c1.Divide(3,2)
c1.cd(1)
hist2Dxy=f.histObj.Project3D("yz")
h2_sum_x.Add(hist2Dxy,1.);
h2_sum_x.Smooth()
# h2_sum_x.Smooth()
# h2_sum_x.Smooth()
h2_sum_x.SetTitle(title+"dose deposition yz projection")
h2_sum_x.DrawCopy("colz")
h2_sum_x.SetContour(10)
h2_sum_x.GetXaxis().SetTitle("Distance in mm")
h2_sum_x.Draw("cont3 same")
xmin = h2_sum_x.GetXaxis().GetXmin()
xmax = h2_sum_x.GetXaxis().GetXmax()
line_x=ROOT.TLine(xmin,0,xmax,0)
line_x.SetLineColor(ROOT.kRed)
line_x.Draw()
c1.cd(2)
hist2Dxz=f.histObj.Project3D("xz")
h2_sum_y.Add(hist2Dxz,1.);
h2_sum_y.Smooth()
# h2_sum_x.Smooth()
# h2_sum_x.Smooth()
h2_sum_y.SetTitle(title+"dose deposition xz projection")
h2_sum_y.DrawCopy("colz")
h2_sum_y.SetContour(10)
h2_sum_y.GetXaxis().SetTitle("Distance in mm")
h2_sum_y.Draw("cont3 same")
xmin = h2_sum_y.GetXaxis().GetXmin()
xmax = h2_sum_y.GetXaxis().GetXmax()
line_x=ROOT.TLine(xmin,0,xmax,0)
line_x.SetLineColor(ROOT.kRed)
line_x.Draw()
c1.cd(3)
hist2Dxy=f.histObj.Project3D("xy")
h2_sum_z.Add(hist2Dxy,1.);
h2_sum_z.Smooth()
# h2_sum_z.Smooth()
# h2_sum_z.Smooth()
h2_sum_z.SetTitle(title+ "dose deposition xy projection")
h2_sum_z.DrawCopy("colz")
h2_sum_z.SetContour(10)
h2_sum_z.GetXaxis().SetTitle("Distance in mm")
h2_sum_z.Draw("cont3 same")
zmin = h2_sum_z.GetXaxis().GetXmin()
zmax = h2_sum_z.GetXaxis().GetXmax()
line_z=ROOT.TLine(zmin,0,zmax,0)
line_z.SetLineColor(ROOT.kViolet)
line_z.Draw()
c1.cd(4)
projX=h2_sum_x.ProjectionX("Profile x-axis",f.binN.x/2,f.binN.x/2)
projX.SetTitle("Profile x-axis; Position [u.u]; Intensity [u.u]")
projX.GetXaxis().SetTitle("Distance in mm")
projX.SetLineColor(ROOT.kRed)
projX.Draw()
maxiX=projX.GetMaximum()
print "maxiX=",maxiX
c1.cd(5)
projY=h2_sum_y.ProjectionX("Profile y-axis",f.binN.y/2,f.binN.y/2)
projY.SetTitle("Profile y-axis; Position [u.u]; Intensity [u.u]")
projY.GetXaxis().SetTitle("Distance in mm")
projY.SetLineColor(ROOT.kRed)
projY.Draw()
maxiY=projY.GetMaximum()
print "maxiX=",maxiX
c1.cd(6)
projZ=h2_sum_z.ProjectionX("Profile z-axis",f.binN.z/2,f.binN.z/2)#.Clone("projX")
projZ.SetTitle("Profile z-axis; Position [u.u]; Intensity [u.u]")
projZ.GetXaxis().SetTitle("Distance in mm")
projZ.SetLineColor(ROOT.kViolet)
projZ.Draw()
maxiZ=projZ.GetMaximum()
print "maxiZ=",maxiZ
c1.Print("doseline.png")
if __name__ == "__main__":
main(sys.argv)