COSMOS v7.655  COSMOSv7655
(AirShowerMC)
crot3vec.f
Go to the documentation of this file.
1 !c test crot3vec, cirot3vec
2 ! implicit none
3 !#include "Zptcl.h"
4 !
5 ! integer i
6 ! type(fmom):: wa, dc, ans
7 ! real*8 cst, snt, fai
8 ! wa.p(1)=0.1
9 ! wa.p(2)=-0.80
10 ! wa.p(3)=-sqrt(1. - (wa.p(1)**2+wa.p(2)**2))
11 !
12 ! wa.p(1:3) = wa.p(1:3)*10.
13 ! cst=0.35d0
14 ! snt=sqrt(1.-cst**2)
15 ! i = 1
16 ! do fai=0., 2*3.1415, .1
17 !
18 ! dc.p(1)=snt*cos(fai)*10.
19 ! dc.p(2)=snt*sin(fai)*10.
20 ! dc.p(3)=cst*10.
21 ! write(*,'(a,1p, 4g15.5)')
22 ! * 'bef crot', dc.p(1:3), dc.p(1)**2 + dc.p(2)**2
23 ! call crot3vec(wa, dc, ans)
24 ! write(*,'(a,1p, 4g15.5)')
25 ! * 'aft crot', ans.p(1:3), ans.p(1)**2 + ans.p(2)**2
26 ! call cirot3vec(i, wa, ans, ans)
27 ! write(*,'(a, 1p, 4g15.5)')
28 ! * 'aft cirot', ans.p(1:3), ans.p(1)**2 + ans.p(2)**2
29 ! enddo
30 ! end
31 ! ************************************
32  subroutine crot3vec(zax, vec1, vec2)
33 ! ************************************
34  implicit none
35 #include "Zptcl.h"
36  type(fmom):: zax, vec1, vec2
37 ! dangerous. vec2 dose not recieve 4th coponent !!!
38  real*8 sml, epsx, av
39 
40  parameter(sml=0.001, epsx=1.e-4, av=.985)
41 
42 !
43 ! /usage/ call crot3vec(zax, vec1, vec2)
44 ! 4 momentum vec1 are given in a system
45 ! (=R) whose z-axis has pallarel to 4 momentum (zax) in
46 ! a certain system(=B).
47 ! This subroutine transform the angles so that (vec1)
48 ! be the 4 momeuntum in the B-system,
49 ! and put the result into vec2.
50 ! (Note 4th component is acutally not needed and not changed)
51 ! The x and y
52 ! axes of the R-system are chosen so that the transformation
53 ! becomes simplest. This does not guarantee that the vec2
54 ! have the same sing as the original one when xax(1) is
55 ! 1.0 or close to 1.0.
56 ! vec2 can be the same one as vec1, or zax.
57 ! This is essentially the same as ctransVectZ.
58 !
59  real*8 el2, em2, d, a, b, c
60  real*8 tmpa, tmpb, tmpc, pabs
61  type(fmom):: zaxdir
62 !
63 ! get direction cos from zax
64  pabs = sqrt(zax%p(1)**2 + zax%p(2)**2 + zax%p(3)**2)
65  if(pabs .eq. 0.) then
66  zaxdir%p(1) = 0.
67  zaxdir%p(2) = 0.
68  zaxdir%p(3) = 1.
69  else
70  zaxdir%p(1) = zax%p(1)/pabs
71  zaxdir%p(2) = zax%p(2)/pabs
72  zaxdir%p(3) = zax%p(3)/pabs
73  endif
74 !
75  el2=zaxdir%p(1)**2
76  em2=zaxdir%p(2)**2
77  d=1.+zaxdir%p(3)
78  if(abs(d) .gt. epsx) then
79  a=el2/d - 1.
80  b=zaxdir%p(1)*zaxdir%p(2)/d
81  c=em2/d - 1.
82  tmpa=a*vec1%p(1) + b*vec1%p(2) + zaxdir%p(1)*vec1%p(3)
83  tmpb=b*vec1%p(1) + c*vec1%p(2) + zaxdir%p(2)*vec1%p(3)
84  else
85  tmpa= vec1%p(2)
86  tmpb= vec1%p(1)
87  endif
88  tmpc=zaxdir%p(1)*vec1%p(1) + zaxdir%p(2)*vec1%p(2) +
89  * zaxdir%p(3)*vec1%p(3)
90  vec2%p(1) = tmpa
91  vec2%p(2) = tmpb
92  vec2%p(3) = tmpc
93  end
94 
95 ! ***************************************
96  subroutine cirot3vec(init, p1, p2, po)
97  implicit none
98 #include "Zptcl.h"
99 ! ***************************************
100 !
101 ! suppose p1 and p2 are given in the same system.
102 ! This program rotate the z-axis so that
103 ! it coinsides with p1 and transform p2 as seen from p1.
104 ! The result is put in po.
105 ! Note that the x and y are arbitrary chosen.
106 ! the 4-th comp. is not used and unchanged.
107 !
108  integer init ! input. give 1 if p1 is diff. from prev. call.
109  type(fmom)::p1 ! input.
110  type(fmom)::p2 ! input.
111  type(fmom)::po ! output. po may be p2
112 !
113  type(fmom)::x, y, px
114  real*8 xnorm, ynorm, pnorm, sum, ax, ay, az
115 
116 !c #ifdef USESAVE
117  save x, y, xnorm, ynorm, pnorm
118 !c #endif
119 
120 !
121 ! form x and y with p1 being z.
122 !
123  if(init .eq. 1) then
124  pnorm = sqrt(p1%p(1)**2 + p1%p(2)**2 + p1%p(3)**2)
125  endif
126  if( pnorm .eq. 0.0 ) then
127  po = p2
128  else
129  if(init .eq. 1) then
130  ax = abs(p1%p(1))
131  ay = abs(p1%p(2))
132  az = abs(p1%p(3))
133 
134  if(az .gt. ay) then
135  if(az .gt. ax) then
136  sum = -(p1%p(1) + p1%p(2))
137  x%p(1) = 1.
138  x%p(2) = 1.
139  x%p(3) = sum/p1%p(3)
140  else
141  sum = -(p1%p(2) + p1%p(3))
142  x%p(2) = 1.
143  x%p(3) = 1.
144  x%p(1) = sum/p1%p(1)
145  endif
146  elseif(ay .gt. ax ) then
147  sum = -(p1%p(1) + p1%p(3))
148  x%p(1) = 1.
149  x%p(3) = 1.
150  x%p(2) = sum/p1%p(2)
151  else
152  sum = -(p1%p(2) + p1%p(3))
153  x%p(2) = 1.
154  x%p(3) = 1.
155  x%p(1) = sum/p1%p(1)
156  endif
157 ! form y
158  y%p(1) = p1%p(2)* x%p(3) - p1%p(3) * x%p(2)
159  y%p(2) = p1%p(3)* x%p(1) - p1%p(1) * x%p(3)
160  y%p(3) = p1%p(1)* x%p(2) - p1%p(2) * x%p(1)
161 !
162 ! since p1, x, y are not unit vector, we have to normalize
163 !
164  xnorm = sqrt(x%p(1)**2 + x%p(2)**2 + x%p(3)**2)
165  ynorm = sqrt(y%p(1)**2 + y%p(2)**2 + y%p(3)**2)
166  endif
167 !
168 ! if init != 1, we come here directly
169 !
170 ! get projection of p2 on to x, y, p1
171 !
172  px%p(1) = (p2%p(1)* x%p(1) + p2%p(2)* x%p(2) +
173  * p2%p(3) * x%p(3))/xnorm
174  px%p(2) = (p2%p(1)* y%p(1) + p2%p(2)* y%p(2) +
175  * p2%p(3) * y%p(3))/ynorm
176  px%p(3) = (p2%p(1)* p1%p(1) + p2%p(2)* p1%p(2) +
177  * p2%p(3) * p1%p(3))/pnorm
178 !
179  po%p(1:3) = px%p(1:3)
180  po%p(4) = p2%p(4)
181  endif
182  end
183 
184 
185 
186 
187 
188 
189 
190 
integer npitbl real *nx parameter(n=101, npitbl=46, nx=n-1) real *8 uconst
dE dx *! Nuc Int sampling table e
Definition: cblkMuInt.h:130
Definition: Zptcl.h:72
subroutine cirot3vec(init, p1, p2, po)
Definition: crot3vec.f:97
subroutine crot3vec(zax, vec1, vec2)
Definition: crot3vec.f:33