source: trunk/source/geometry/solids/test/fred/makegridscripts.f@ 1353

Last change on this file since 1353 was 1350, checked in by garnier, 15 years ago

update to last version 4.9.4

File size: 5.4 KB
Line 
1*
2* ********************************************************************
3* * License and Disclaimer *
4* * *
5* * The Geant4 software is copyright of the Copyright Holders of *
6* * the Geant4 Collaboration. It is provided under the terms and *
7* * conditions of the Geant4 Software License, included in the file *
8* * LICENSE and available at http://cern.ch/geant4/license . These *
9* * include a list of copyright holders. *
10* * *
11* * Neither the authors of this software system, nor their employing *
12* * institutes,nor the agencies providing financial support for this *
13* * work make any representation or warranty, express or implied, *
14* * regarding this software system or assume any liability for its *
15* * use. Please see the license in the file LICENSE and URL above *
16* * for the full disclaimer and the limitation of liability. *
17* * *
18* * This code implementation is the result of the scientific and *
19* * technical work of the GEANT4 collaboration. *
20* * By using, copying, modifying or distributing the software (or *
21* * any work based on the software) you agree to acknowledge its *
22* * use in resulting scientific publications, and indicate your *
23* * acceptance of all terms of the Geant4 Software license. *
24* ********************************************************************
25*
26 PROGRAM MakeGridScripts
27C ------------------------------
28C Produces a set of GEANT4 scripts using
29C the "Fred" test program "shadow" feature
30C
31 IMPLICIT NONE
32 Integer Icount, idx, idy, idxy, idz
33 Real dx, dy, dz, theta, phi
34C
35 Real ddxy(0:6)/0.0, 0.1, -0.1, 0.2, -0.2, 0.4, 0.6/
36C
37 Real zddx(14)/ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.001,
38 + -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -0.001 /
39 Real zddy(14)/ 0.0, -0.1, -0.2, -0.4, -0.6, -1.0, -100.0,
40 + 0.0, 0.1, 0.2, 0.4, 0.6, 1.0, 100.0 /
41 Real zddz(4)/ 0.0, 0.1, 0.2, 0.4 /
42C
43100 FORMAT( '/vis~/camera/viewpoint ', F13.9, ' ', F14.9 )
44101 FORMAT( '/gridGun/origin ', 3F13.8 )
45102 FORMAT( '/gridGun/direction ', 3F13.8 )
46103 FORMAT( '/run/beamOn 1' )
47104 FORMAT( '# view number ', I4 )
48105 FORMAT( '/fred/pause' )
49106 FORMAT( '/gridGun/grid1', 3F13.8 )
50107 FORMAT( '/gridGun/grid2', 3F13.8 )
51C
52 Icount = 0
53C
54C --- Scripts where the origin is a z-plane of -2
55C
56 open(unit=10,file='grids1.script',form='FORMATTED')
57 write(10,'(''/fred/gun GRID'')')
58 write(10,'(''/fred/draw SHADOW'')')
59C
60 write(10,106) 4.0, 0.0, 0.0
61 write(10,107) 0.0, 4.0, 0.0
62C
63 do idy = 0, 6
64 do idx = 0, 6
65C
66 dx = ddxy(idx)
67 dy = ddxy(idy)
68C
69 theta = atan( sqrt(dx**2+dy**2) )*180/3.14159265
70 if (idx.eq.0.and.idy.eq.0) then
71 phi = 0.0
72 else
73 phi = atan2(dy,dx)*180/3.14159265
74 endif
75C
76 write(10,100) theta, phi
77 write(10,101) -2.0-2.0*dx, -2.0-2.0*dy, -2.0
78 write(10,102) dx, dy, 1.0
79 write(10,103)
80 write(10,104) icount
81 write(10,105)
82 icount = icount + 1
83C
84 enddo
85 enddo
86 close(10)
87C
88C --- Scripts where the origin is a z-plane of +2
89C
90 open(unit=10,file='grids2.script',form='FORMATTED')
91 write(10,'(''/fred/gun GRID'')')
92 write(10,'(''/fred/draw SHADOW'')')
93C
94 write(10,106) 2.0, 0.0, 0.0
95 write(10,107) 0.0, 2.0, 0.0
96C
97 do idy = 0, 6
98 do idx = 0, 6
99C
100 dx = ddxy(idx)
101 dy = ddxy(idy)
102C
103 theta = atan( sqrt(dx**2+dy**2) )*180/3.14159265
104 if (idx.eq.0.and.idy.eq.0) then
105 phi = 0.0
106 else
107 phi = atan2(dy,dx)*180/3.14159265
108 endif
109C
110 write(10,100) theta, phi
111 write(10,101) -2.0+2.0*dx, -2.0+2.0*dy, +2.0
112 write(10,102) -dx, -dy, -1.0
113 write(10,103)
114 write(10,104) icount
115 write(10,105)
116 icount = icount + 1
117C
118 enddo
119 enddo
120 close(10)
121C
122C --- Okay: origin is a plane parallel to z-axis
123C
124 open(unit=10,file='grids3.script',form='FORMATTED')
125 write(10,'(''/fred/gun GRID'')')
126 write(10,'(''/fred/draw SHADOW'')')
127C
128 write(10,107) 0.0, 0.0, 4.0
129C
130 do idz = 1, 4
131 dz = zddz(idz)
132 do idxy = 1, 14
133C
134 dx = zddx(idxy)
135 dy = zddy(idxy)
136 if (abs(dx).lt.0.01) then
137C
138C --- Special case: origin is y-plane
139C
140 write(10,106) 4.0, 0.0, 0.0
141C
142 theta = atan( 1.0/dz )*180/3.14159265
143 if (dy.lt.0) then
144 phi = 270
145 else
146 phi = 90
147 endif
148 write(10,100) theta, phi
149 write(10,101) -2.0, sign(2.0,dy), -2.0+2.0*dz
150 write(10,102) 0.0, sign(1.0,-dy), -dz
151 write(10,103)
152 write(10,104) icount
153 write(10,105)
154 icount = icount + 1
155 else
156C
157 write(10,106) 0.0, 4.0, 0.0
158C
159 if (dz.eq.0) then
160 theta = 90.0
161 else
162 theta = atan( sqrt(dx**2+dy**2)/dz )*180/3.14159265
163 endif
164 phi = atan2(dy,dx)*180/3.14159265
165C
166 write(10,100) theta, phi
167 write(10,101) sign(2.0,-dx), -2.0-2.0*dy, -2.0-2.0*dz
168 write(10,102) dx, dy, dz
169 write(10,103)
170 write(10,104) icount
171 write(10,105)
172 icount = icount + 1
173 endif
174 enddo
175 enddo
176C
177 close(10)
178 STOP
179 END
Note: See TracBrowser for help on using the repository browser.