COSMOS v7.655  COSMOSv7655
(AirShowerMC)
det2prim2.f
Go to the documentation of this file.
1 !
2 ! This is for such a case when you forgot the initinial random
3 ! number to reproduce primary diretion, but you have
4 ! the incident position in detector system.
5 ! param file is read via file no. 10 and
6 ! incident position is read via stdin.
7 !
8 ! get transformation matrix for converting detector system vector
9 ! into primary system vector.
10 ! Since primary system depends on each sampled primary,
11 ! This program gets the conversion matrix for the condition
12 ! specified in the param and input incident pos.
13 !
14 
15 #include "BlockData/cblkGene.h"
16  implicit none
17 
18 #include "Zglobalc.h"
19 #include "Ztrack.h"
20 #include "Ztrackp.h"
21 #include "Ztrackv.h"
22 #include "Zobs.h"
23 #include "Zobsv.h"
24 
25 
26 
27 
28  type(coord):: aa, bb, cc, det, detyaxis
29  integer fin
30  real*8 xin, yin, zin, temp
31  type(track):: inci
32 
33  open(10, file="param")
34 
35  call creadparam(10)
36 !
37 ! xin, yin, zin, incident point in Detector system.
38 !
39  read(*,*) xin, yin, zin
40  write(0,*) ' input inci pos='
41  write(0,*) xin, yin, zin
42 !
43  cc%x = xin
44  cc%y = yin
45  cc%z = zin
46 
47  call cbeginrun
48  call cmkincident(inci, fin)
49  call cinitracking(inci)
50 ! Above will make some incident but different from
51 ! the stdin.
52  det = obssites(noofsites)%pos%xyz
53 
54  write(0, *) ' detector base pos in Exyz'
55  write(0,'(3g17.9)') det%x, det%y, det%z
56  call cdet2xyz(det, cc, inci%pos%xyz)
57  write(0,*) 'incident position in Exyz'
58  write(0,*) inci%pos%xyz%x, inci%pos%xyz%y,
59  * inci%pos%xyz%z
60  call cxyz2det(det, inci%pos%xyz, cc)
61  write(0,*) 'incident position in Det; must be same as input '
62  write(0,*) cc%x, cc%y, cc%z
63 
64  call cvecprod(detzaxis, detxaxis, detyaxis)
65  write(0,*) ' '
66  write(0,*) ' detector X,Y,Z axis vecgor in Exyz'
67  write(0,'(3g17.9)') detxaxis%x, detxaxis%y, detxaxis%z
68  write(0,'(3g17.9)') detyaxis%x, detyaxis%y, detyaxis%z
69  write(0,'(3g17.9)') detzaxis%x, detzaxis%y, detzaxis%z
70  write(0,*)
71  temp = sqrt(xin**2 + yin**2 + zin**2)
72 ! Zprimary in Det. system.
73  cc%x = xin/temp
74  cc%y = yin/temp
75  cc%z = zin/temp
76 ! in Exyz
77  call cdet2xyzd(cc, zprimary)
78 
79  call cvecprod(zprimary, detzaxis, xprimary)
80 ! see if Zprimary // DetZaxis; if so reset Xprimary
81  temp= xprimary%x**2 + xprimary%y**2 + xprimary%z**2
82  if(temp .lt. 1.e-12) then
83  xprimary = detxaxis
84  else
85  temp =sqrt(temp)
86  xprimary%r(1) = xprimary%r(1)/temp
87  xprimary%r(2) = xprimary%r(2)/temp
88  xprimary%r(3) = xprimary%r(3)/temp
89  endif
90  call cvecprod(zprimary, xprimary, yprimary)
91 !
92 ! we try to convert {X,Y,Z}primary into the one in
93 ! detector system-->a,b,c.
94  call citransvectzx(1, detzaxis, detxaxis, xprimary, aa)
95  call citransvectzx(2, detzaxis, detxaxis, yprimary, bb)
96 
97 ! primary etc is the vector representing the primary system axes
98 ! in the Detector system. Then, a given vector R in Detector system,
99 ! its component to the a,b,c is Rx, Ry, Rz in the Primary is primary
100 ! system.
101 !
102  write(0,*) ' Primary system X,Y,Z axis unit vector in Exyz'
103  write(0,'(3g17.9)') xprimary%x, xprimary%y, xprimary%z
104  write(0,'(3g17.9)') yprimary%x, yprimary%y, yprimary%z
105  write(0,'(3g17.9)') zprimary%x, zprimary%y, zprimary%z
106 
107  write(0,*) ' For a given vector in the Detector system'
108  write(0,*)
109  * ' take scaler product of the following unit vector to get'
110  write(0,*) ' its x value in the primary system. For y, z, use '
111  write(0,*) ' 2nd, 3rd row'
112  write(*,'(3g17.9)') aa%x, aa%y, aa%z
113  write(*,'(3g17.9)') bb%x, bb%y, bb%z
114  write(*,'(3g17.9)') cc%x, cc%y, cc%z
115 
116  call citransvectzx(2, detzaxis, detxaxis, zprimary, cc)
117  write(0,*) ' this must be the same as above'
118  write(0,'(3g17.9)') cc%x, cc%y, cc%z
119  end
120  subroutine chooktrace
121  end
122  subroutine chookceren
123  end
124  subroutine chookcerens
125  end
126  subroutine chookcerene
127  end
128  subroutine chookbgrun
129  end
130 
131 
132 
dE dx *! Nuc Int sampling table e
Definition: cblkMuInt.h:130
Definition: Ztrack.h:44
subroutine cmkincident(incident, fin)
Definition: cmkIncident.f:5
subroutine cvecprod(a, b, c)
Definition: cvecProd.f:4
subroutine chookceren
Definition: det2Exyz.f:63
subroutine creadparam(io)
Definition: creadParam.f:5
subroutine chooktrace
Definition: chook.f:275
subroutine cdet2xyzd(a, b)
Definition: cxyz2det.f:101
subroutine chookcerene
Definition: det2Exyz.f:67
subroutine cinitracking(incident)
Definition: ciniTracking.f:2
subroutine chookcerens(no, primary, angle)
Definition: ctemplCeren.f:19
subroutine cdet2xyz(det, a, b)
Definition: cxyz2det.f:48
subroutine citransvectzx(init, zax, xax, dir1, dir2)
Definition: ctransVectZx.f:102
Definition: Zcoord.h:43
subroutine cbeginrun
Definition: cbeginRun.f:7
subroutine cxyz2det(det, a, b)
Definition: cxyz2det.f:7
subroutine chookbgrun
Definition: chook.f:15