COSMOS v7.655  COSMOSv7655
(AirShowerMC)
ciniTracking.f
Go to the documentation of this file.
1  subroutine cinitracking( incident )
2 ! this is called after primary is fixed.
3  implicit none
4 
5 #include "Zmanagerp.h"
6 #include "Ztrack.h"
7 #include "Ztrackp.h"
8 #include "Ztrackv.h"
9 #include "Zobs.h"
10 #include "Zobsp.h"
11 #include "Zobsv.h"
12 #include "Zatmos.h"
13 #include "Zincidentv.h"
14 #include "Zearth.h"
15 
16  external cxyz2prim, cxyz2det
17  integer klena, leng, icon
18  real*8 zAngleSave, r1, r2, cosx, lengx
19  real*8 clenbetween2h, cnewcos
20  character*80 tracefile
21  type(track)::incident
22  type(coord)::xyz
23  integer i
24  data zanglesave/-1.d30/
25  save zanglesave
26 
27 
28  zfirst%pos%depth = 0.
29  zsave = -1.d30
30 #if LABELING > 0
31  labelcounter = 0
32 #endif
33 !
34  if(job .eq. 'flesh') then
35  call csetemin(generate2, keminobs2(1), kemin2, kemincas2)
36  call csetemin(generate, keminobs(1), kemin, kemincas)
37  else
38  call csetemin(generate, keminobs(1), kemin, kemincas)
39  kemin2 = kemin
40  kemincas2 = kemincas
41  endif
42 
43 
44  call cprimxyz ! compute primary x,y,z axis in 'xyz' system
45  if((trace .gt. 0 .and. trace .lt. 60) .or.
46  * (trace .gt. 100 .and. trace .lt. 160) ) then
47 ! default trace output is requested. Open disk file
48  write(tracefile, *) tracedir(1:klena(tracedir))//'/trace',
49  * eventno
50  call kseblk(tracefile, ' ', leng)
51  call copenfw(tracedev, tracefile(1:leng), icon)
52  if(icon .ne. 0) then
53  call cerrormsg('tracefile couldnot be opened',0)
54  endif
55  elseif(trace .gt. 60 .and. trace .lt. 100 .or.
56  * trace .gt. 160 .and. trace .lt. 200) then
57  call cputcerenkovs ! cerenkov output header for each event
58  endif
59 !
60  call ciniasobs
61  if(abs(obsplane) .eq. horizontal .or.
62  * obsplane .eq. spherical) then
63  call csetobsz(cxyz2det)
64  elseif(abs(obsplane) .eq. perpendicular ) then
65  call csetobsz(cxyz2prim)
66 ! inicident.where can be fixed here. not in cmkIncidnt
67  call cxyz2prim(obssites(noofsites)%pos%xyz,
68  * incident%pos%xyz, xyz)
69  do i = 1, noofsites
70  if(xyz%r(3) .gt. obssites(i)%zpl ) then
71  incident%where = i
72  goto 222
73  endif
74  enddo
75  incident%where = noofsites + 1
76  incidentcopy%where = incident%where
77  222 continue
78  elseif(obsplane .eq. notused ) then
79 ! Nothing to do. observation is at height =
80 ! BorderHeighL. (for neutrino)
81  else
82  call cerrormsg('ObsPlane value is wrong', 0)
83  endif
84 ! check some parameters
85  call cexamparam
86 ! if one dimensional and large angle, use table method
87 ! for lenth <--> thickness conversion. make table for that
88  usetbl = onedim .eq. 3 .or.
89  * ( onedim .eq. 2 .and.
90  * abs( angleatobscopy%r(3) ) .lt. 0.5 )
91  usetbl = usetbl .and. .not. upgoing
92  if(usetbl .and. zanglesave .ne. angleatobscopy%r(3) ) then
93  hbase = heightlist(noofsites) - 0.3d0 ! make little bit smaller
94  htop =100.d3 ! old value was 30d3
95  r1 = htop + eradius
96  r2 = hbase + eradius
97  lengx = clenbetween2h(r2, r1, -angleatobscopy%r(3))
98  cosx = cnewcos(r2, -angleatobscopy%r(3), lengx)
99  call cl2ttbl(htop, hbase, cosx, -angleatobscopy%r(3),
100  * lenstep,
101  * lentbl, heighttbl, costbl, thicktbl, maxl2t, numstep)
102  zanglesave = angleatobscopy%r(3)
103  endif
104 ! fix B at the starting point
105  if( howgeomag .le. 2 .or. howgeomag .eq. 31 ) then
106  call cgeomag(yearofgeomag, incident%pos%xyz, mag, icon)
107  call ctransmagto('xyz', incident%pos%xyz, mag, mag)
108  else
109  mag = magfieldxyz
110  endif
111 
112  end
113 ! --------- compute primary system, x,y,z.
114 ! The deepest detector is the reference.
115  subroutine cprimxyz
116  implicit none
117 #include "Ztrack.h"
118 #include "Zincidentv.h"
119 #include "Zobs.h"
120 #include "Zobsv.h"
121 ! all are unit vector in 'xyz' system.
122 !
123 ! X = Z x V ( Z is primary direction; V is vertical axis )
124 ! = V x(-Z)
125 ! = V x DcAtObsXyz = DetZaxis.r(1) DcAtObsXyz
126 ! Y = Z x X = X x (-Z)
127 ! = X x DcAtObsXyz
128 !
129 ! compute Xprimary, Yprimary, Zprimary in 'xyz' system.
130 
131  real*8 temp
132 !
133  zprimary%r(:) = - dcatobsxyz%r(:)
134  call cvecprod(zprimary, detzaxis, xprimary)
135 ! see if Zprimary // DetZaxis; if so reset Xprimary
136  temp= sum( xprimary%r(:)**2 )
137  if(temp .lt. 1.e-12) then
138  xprimary = detxaxis
139  else
140  temp =sqrt(temp)
141 ! ifort v14 dies here if (:) is used
142  xprimary%r(1) = xprimary%r(1)/temp
143  xprimary%r(2) = xprimary%r(2)/temp
144  xprimary%r(3) = xprimary%r(3)/temp
145  endif
146  call cvecprod(zprimary, xprimary, yprimary)
147  txyz2prim(1,:) = xprimary%r(:)
148  txyz2prim(2,:) = yprimary%r(:)
149  txyz2prim(3,:) = zprimary%r(:)
150  tprim2xyz(:,:) = transpose(txyz2prim(:,:))
151 
152  end
153 ! ******************************
154  subroutine csetobsz(converter)
155 ! *****************************
156 ! compute Z of observation plane
157 !
158  implicit none
159 #include "Zcoord.h"
160 #include "Zpos.h"
161 #include "Zmagfield.h"
162 #include "Zobs.h"
163 #include "Zobsp.h"
164 #include "Zobsv.h"
165 
166  external converter ! cxyz2prim or cxyz2det
167 ! depending on |ObsPlane| =2, 1
168 ! or cxyz2det for ObsPlane=3
169  integer i
170  type(coord)::temp
171 ! compute z from the base detector.
172  do i = 1, noofsites
173  call converter(obssites(noofsites)%pos%xyz,
174  * obssites(i)%pos%xyz,
175  * temp)
176  obssites(i)%zpl = temp%r(3)
177  enddo
178 ! this is for A.S
179  do i = 1, noofassites
180  call converter(asobssites(noofassites)%pos%xyz,
181  * asobssites(i)%pos%xyz,
182  * temp)
183  asobssites(i)%zpl = temp%r(3)
184  enddo
185  end
186 ! **************************
187  subroutine cqfirstid(depth)
188 ! inquire the first interaction depth
189  implicit none
190 
191 #include "Ztrack.h"
192 #include "Ztrackv.h"
193  real*8 depth ! output. to get the first I%D
194 
195  depth = zfirst%pos%depth ! vertical depth
196  end
197 ! **************************
198  subroutine cqfirstipi(ptrack)
199 ! inquire the complete first interaction point info.
200 ! as a track of the primary.
201  implicit none
202 
203 #include "Ztrack.h"
204 #include "Ztrackv.h"
205  type(track)::ptrack ! output. if ptrack%pos%depth=0.
206  ! no interaction has been occurred
207 
208  ptrack = zfirst
209  end
210  subroutine cqfirstcolmedia(A, Z, xs)
211 ! retrns first col. element and Xsecion on it
212  implicit none
213 #include "Ztrack.h"
214 #include "Ztrackv.h"
215  integer,intent(out):: A
216  integer,intent(out):: Z
217  real(8),intent(out):: xs
218  a = firstcola
219  z = firstcolz
220  xs = firstcolxs
221  end
222 ! --------------------------------
223  subroutine ciniasobs
224  implicit none
225 
226 #include "Zcoord.h"
227 #include "Zpos.h"
228 #include "Zmagfield.h"
229 #include "Zobs.h"
230 #include "Zobsp.h"
231 #include "Zobsv.h"
232 
233  integer i
234 
235  do i = 1, noofassites
236  asobssites(i)%esize = 0.
237  asobssites(i)%age = 0.
238  enddo
239  end
240 ! ***********************
241  subroutine csetemin(gen, eminob, emin, emCas)
242 ! ***********************
243  implicit none
244 #include "Zmanagerp.h"
245 #include "Zcode.h"
246 #include "Ztrack.h"
247 #include "Ztrackp.h"
248 #include "Ztrackv.h"
249 #include "Zincidentv.h"
250 #include "Zheavyc.h"
251 #include "Zheavyp.h"
252 !
253  character*(*) gen ! input. a copy of Generate.
254  real*8 eminob ! input. minim observational energy (kientic)
255  real*8 emin ! output. Minimum energy to be followed for non e-g
256  ! ptcls.
257  real*8 emCas ! output. Minimum energy to be followed for e-g
258 !
259 !
260  real*8 ergpn ! energy / nucleon
261  logical cas !
262  logical obas !
263 
264 !
265  cas = index(gen, 'em') .gt. 0
266  obas = index(gen, 'as') .gt. 0 .or.
267  * index(gen, 'lat') .gt. 0
268 
269 
270 ! energy / nucleon for heavy
271  if(incidentcopy%p%code .eq. kgnuc) then
272  ergpn =
273  * incidentcopy%p%fm%p(4)/incidentcopy%p%subcode
274  elseif(incidentcopy%p%code .ge. kalfa .and.
275  * incidentcopy%p%code .le. khvymax) then
276 ! will not come here
277  ergpn =
278  * incidentcopy%p%fm%p(4)/code2massn(incidentcopy%p%code)
279  else
280  ergpn = incidentcopy%p%fm%p(4)
281  endif
282  if(obas ) then
283  ! wait until electon energy becomes < EasWait for AS
284  ! generation. WaitRatio < 1 should be used when 1ry is
285  ! g or e. (say, 0.01)
286  easwait =ergpn * waitratio
287  endif
288 
289 
290  emcas = 1.d30
291 
292  if(obas) then
293  emcas = easwait
294  endif
295  if(cas) then
296  emcas =min(eminob, emcas)
297  endif
298  emin = eminob
299  if(obas) then
300  emin = min(emin, max(ratiotoe0* ergpn, 1.d0) )
301  endif
302 
303  if(thinsampling) then
304 ! thin sampling
305  if(ethinratio(1) .lt. 0.) then
306  ethin(1) = abs(ethinratio(1))
307  else
308  ethin(1) = ethinratio(1)*ergpn
309  endif
310  if(ethinratio(3) .lt. 0.) then
311  ethin(3) = abs(ethinratio(3))
312  elseif(ethinratio(3) .eq. 0.) then
313  ethin(3) = ethin(1)/10.
314  else
315  ethin(3) = ethinratio(3)*ergpn
316  endif
317 
318 
319 ! if(EthinRatio(2) .lt. 0.) then
320 ! Ethin(2) = abs(EthinRatio(2))
321 ! else
322 ! Ethin(2) = EthinRatio(2)*ergpn
323 ! endif
324 ! maximum weight above which no thinning
325  ethin(2) = ethinratio(2)
326  if( ethinratio(4) .eq. 0.) then
327  ethin(4) = ethin(2)/10.
328  else
329  ethin(4) = ethinratio(4)
330  endif
331 !///////////////////
332 ! write(0, *) ' ****** Ethin1,2=', Ethin
333 ! write(0, *) ' ergpn=', ergpn, ' EthinRatio=',EthinRatio
334 !////////////////
335 
336  else
337  ethin(1) = 0.
338  ethin(2) = 0.
339  ethin(3) = 0.
340  ethin(4) = 0.
341  endif
342  end
343  subroutine cexamparam
344  implicit none
345 #include "Ztrackp.h"
346 #include "Zelemagp.h"
347 
348  end
subroutine cerrormsg(msg, needrtn)
Definition: cerrorMsg.f:4
dE dx *! Nuc Int sampling table e
Definition: cblkMuInt.h:130
max ptcl codes in the kgnuc
Definition: Zcode.h:2
block data cblkIncident data *Za1ry *HeightOfInj d3
Definition: cblkIncident.h:7
const int notused
Definition: Zobs.h:16
Definition: Ztrack.h:44
subroutine csetobsz(converter)
Definition: ciniTracking.f:155
subroutine cgeomag(yearin, llh, h, icon)
Definition: cgeomag.f:25
subroutine cxyz2prim(base, a, b)
Definition: cxyz2prim.f:5
subroutine cvecprod(a, b, c)
Definition: cvecProd.f:4
********************block data cblkHeavy ********************integer j data *HeavyG2symbol *data *HeavyG2code kalfa
Definition: cblkHeavy.h:7
subroutine ciniasobs
Definition: ciniTracking.f:224
subroutine csetemin(gen, eminob, emin, emCas)
Definition: ciniTracking.f:242
! Zobs h header file for observation sites definition ! integer horizontal
Definition: Zobs.h:4
subroutine cqfirstid(depth)
Definition: ciniTracking.f:188
block data cblkEvhnp ! currently usable models data RegMdls ad *special data *Cekaon d0
Definition: cblkEvhnp.h:5
subroutine cqfirstcolmedia(A, Z, xs)
Definition: ciniTracking.f:211
subroutine cqfirstipi(ptrack)
Definition: ciniTracking.f:199
subroutine cinitracking(incident)
Definition: ciniTracking.f:2
! for length to thickness conversion or v v ! integer maxl2t
Definition: Zatmos.h:3
subroutine copenfw(io, fnin, icon)
Definition: copenf.f:122
max ptcl codes in the khvymax
Definition: Zcode.h:2
subroutine cexamparam
Definition: ciniTracking.f:344
subroutine ctransmagto(sys, pos, a, b)
Definition: ctransMagTo.f:11
Definition: Zcoord.h:43
subroutine cprimxyz
Definition: ciniTracking.f:116
subroutine cxyz2det(det, a, b)
Definition: cxyz2det.f:7
! Zobs h header file for observation sites definition ! integer * perpendicular
Definition: Zobs.h:4
subroutine kseblk(text, c, lc)
Definition: kseblk.f:18
subroutine cl2ttbl(h1, h2, cosz1, cosz2, step, lengtb, htb, costb, thicktb, maxsize, tblsize)
Definition: cl2tTbl.f:8
const int spherical
Definition: Zobs.h:19