COSMOS v7.655  COSMOSv7655
(AirShowerMC)
cthinning.f
Go to the documentation of this file.
1  subroutine cthinning(Tracks, n, iTrack, nout)
2 !
3 ! The user may replace this routine by his/her own thinning method.
4 ! For 'n' tracks in 'Tracks', change weight if necessary or remove it.
5 ! If a track is removed, the user must move the remaining tracks
6 ! to the upper position in Tracks.
7 ! This will be done simply as
8 ! nout = 0
9 ! do i = 1, n
10 ! Examine Tracks(i)
11 ! if it is accepted, (do neceeary weight change)
12 ! nout++
13 ! store it in Tracks(nout)
14 ! else do nothing
15 ! enddo
16 !
17 ! The standard thinning routine is supploed as csetThinwgt
18 ! A paremeter in $Hparam, EthinRatio, is used as follows.
19 ! EthinRation(1) to (4) are used as (Ethin, MaxWgt) for e/g
20 ! and for mu/had. If EthiRatio(3) and (4) are not given
21 ! (1)/10 and (2)/10 are used.
22 ! Others are hard wired and can be chaged in csetThinwgt
23 ! (see top part of csetThinwgt. They are in the lines
24 ! above ^^^^^^^^^^^^^^^^^^^^^^^^^.
25 !
26 
27  implicit none
28 #include "Zcode.h"
29 #include "Ztrack.h"
30 #include "Ztrackp.h"
31 #include "Ztrackv.h"
32 #include "Zincidentv.h"
33  integer n ! input. no. of produced particles and stored in Tracks
34  type(track):: Tracks(n) ! input and outut. track info.
35  type(track):: iTrack ! input. incident particle track info. for the coll.
36  integer nout ! output. number of particles accepted in the
37  ! thinning
38 !
39 !
40  integer i
41  type(track):: aTrack
42  integer icon
43 
44  nout = 0
45  do i = 1, n
46  atrack=tracks(i)
47  call csetthinwgt(itrack, atrack, icon)
48  if(icon .eq. 0 ) then
49  nout = nout +1
50  tracks(nout)=atrack
51  endif
52  enddo
53  end
54 
55  subroutine csetthinwgt(iTrack, aTrack, icon)
56  implicit none
57 #include "Zcode.h"
58 #include "Ztrack.h"
59 #include "Ztrackp.h"
60 #include "Ztrackv.h"
61 #include "Zincidentv.h"
62 #include "Zelemagp.h"
63 #include "Zobs.h"
64 #include "Zobsp.h"
65 #include "Zobsv.h"
66 !
67 ! **************** if you want to limit the max wwight exactly
68 ! give 1 to the next line
69 ! else give 0.
70 ! For exact max limit, you have to give larger
71 ! weight in EthinRatio(2) and EthinRatio(4) for
72 ! defending cpu time increase. (~10 times)
73 ! If you give 0 then if the weight is > the max weight,
74 ! no more thinning is tried. However, if the weight is < max,
75 ! thinning is tried and resultant weight may be
76 ! larger than max limit.
77 ! If 1, the weight managed so that it never exceeds
78 ! the max. 0 has probably better performance.
79 #define EXACTWGT 0
80 ! Define `far` by DETAILFAR. (particle location is far
81 ! from the axis or not.)
82 ! 0: far is judged at depeth1<depth<depth2 for e/g
83 ! and mu/h
84 ! 1: far is judged at depeth1<depth<depth2 for e/g
85 ! at all depths < depth2 for mu/h
86 #define DETAILFAR 0
87 
88  real*8 big ! if you don't want to control the thinnig
89  ! by the distance of the current particle
90  ! from the shower axis, give big to rfar
91  parameter(big=1.d20)
92 ! ******************************************************************
93 ! **************************** fix the following *******************
94 !
95  real*8 depth1/4000.d0/ ! between depth1 and depth2, check if
96  real*8 depth2/8750.d0/ ! a ptcl is far from the core. If so
97  ! we employ lesser thinning or no thinning.
98  ! depth2 should be the last obs. depth where lateral
99  ! information is taken.
100  ! the unit is kg/m2 (devide by 10 for g/cm2)
101  real*8 rfar ! r>rfar is regared as "far from axis" (m).
102  ! if want to skip distance dependent thinning
103  ! set this to be "big" (see below)
104  real*8 rfar2 ! rfar**2
105  parameter(rfar =20.0, rfar2= rfar*rfar)
106  real*8 deepfactor/10./ ! at depth > depht2, stronger thinning
107  ! by factor 'deepfactor' than standard thinning
108  ! specified by EthinRatio.
109  ! Ethin and Weight are multiplied by this factor.
110  real*8 farfactor/0.01/ ! thinning factor is weekened by this factor
111  ! than standard one at far points.
112  ! Ethin and Weight are multiplied by this factor.
113 !
114 !
115 ! ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
116 !
117 
118 
119 
120 
121  type(track):: iTrack ! input parent particle
122  type(track):: aTrack ! input child particle
123 ! ! output. wgt
124  integer icon ! output. 0 if this is not tobe discarded
125  ! 1 if this is to be discarded
126  real*8 u, p
127  real*8 iergpn, aergpn
128  logical dothin
129  real*8 dd, rhoE
130  real*8 cvh2den
131  real*8 Z1, E0
132  integer ii, jj ! ii is for incident and jj is for child; for e/g 1, for mu/had 3
133  data z1/-1./, e0/-1./
134  save z1, e0, rhoe, dd
135  type(coord):: oxyz, axisxyz
136  real*8 len, h, relax, dist
137  logical far
138 !
139 !
140  if(incidentcopy%p%code .eq. kphoton .and.
141  * photoprod ) then
142 ! photon primary and muon is interested
143 ! so thinsamling must be carfull
144 ! we apply thinning only if current depth is
145 ! > 120 g/cm2 from the first col. point.
146  if(z1 .ne. zfirst%pos%depth .or.
147  * e0 .ne. incidentcopy%p%fm%p(4) ) then
148  z1 = zfirst%pos%depth
149  e0 = incidentcopy%p%fm%p(4)
150  if( lpmeffect ) then
151  rhoe=cvh2den( zfirst%pos%height )* 1.e-3 *
152  * incidentcopy%p%fm%p(4)
153  if(rhoe .lt. 1.e6) then
154  dd = 200.
155  else
156  dd =min( 200.* sqrt(rhoe/1.e6), 1000.d0)
157  endif
158  else
159  dd = 200.
160  endif
161  endif
162 
163  if( magbrem .eq. 2 .and. z1 .lt. 1.e-6 ) then
164  dothin = itrack%pos%depth/zfirst%vec%coszenith
165  * .gt. 300.
166  else
167  dothin=( itrack%pos%depth-zfirst%pos%depth)/
168  * zfirst%vec%coszenith .gt. (1000.+ dd)
169  endif
170  else
171  dothin = .true.
172  endif
173 !
174 !
175 !
176 !
177 !
178 #if DETAILFAR == 0
179  if( dothin .and. rfar .lt. big .and.
180  * itrack%pos%depth .lt. depth2 .and.
181  * itrack%pos%depth .gt. depth1 ) then
182 #elif DETAILFAR == 1
183  if( dothin .and. rfar .lt. big .and.
184  * itrack%pos%depth .lt. depth2 .and.
185  * (itrack%p%code .gt. kelec .or.
186  * itrack%pos%depth .gt. depth1 ) ) then
187 #endif
188 ! compute distance form the shower axis
189  h = itrack%pos%height - obssites(atrack%where)%pos%height
190  len = h / (-angleatobscopy%r(3))
191  axisxyz%r(1:3) = obssites(atrack%where)%pos%xyz%r(1:3) -
192  * len*dcatobsxyz%r(1:3)
193 ! axisxyz%r(2) = ObsSites(aTrack%where)%pos%xyz%y -
194 ! * len*DcAtObsXyz%r(2)
195 ! axisxyz%z = ObsSites(aTrack%where)%pos%xyz%z -
196 ! * len*DcAtObsXyz%r(3)
197 !
198 !ok write(0,*) ' h=',h, ' len =',len, ' cos=',
199 !ok * -AngleAtObsCopy.r(3)
200 !ok write(0,*) ' axis at depth =',
201 !ok * ObsSites(aTrack.where).pos.depth
202 !ok write(0,*) ' is x,y,z=', ObsSites(aTrack.where).pos.xyz.x,
203 !ok * ObsSites(aTrack.where).pos.xyz.y,
204 !ok * ObsSites(aTrack.where).pos.xyz.z
205 !ok write(0,*) ' ptcl pos=',iTrack.pos.xyz.x,
206 !ok * iTrack.pos.xyz.y, iTrack.pos.xyz.z
207 !ok write(0,*) ' dz=',DcAtObsXyz.r(3)
208 !ok write(0,*) ' axisxyz.x, y, z=', axisxyz.x,
209 !ok * axisxyz.y, axisxyz.z
210 
211  if(obsplane .eq. horizontal) then
212  call cxyz2det(axisxyz,
213  * atrack%pos%xyz, oxyz)
214  elseif(obsplane .eq. perpendicular) then
215  call cxyz2prim(axisxyz,
216  * atrack%pos%xyz, oxyz)
217  endif
218  dist = sqrt( oxyz%r(1)**2+ oxyz%r(2)**2)
219  far= dist .gt. rfar
220  else
221  far=.false.
222  endif
223 ! ////////////////
224 
225  if(dothin) then
226  if(itrack%pos%depth .gt. depth2) then
227  relax = deepfactor
228  elseif(far) then
229  relax = farfactor
230 ! if( dist .lt. 10.) then
231 ! relax = farfactor
232 ! elseif ( dist .lt. 20.) then
233 ! relax = farfactor*0.3
234 ! elseif ( dist .lt. 100.) then
235 ! relax = farfactor*0.1
236 ! else
237 ! relax = farfactor*0.03
238 ! endif
239  else
240  relax = 1.
241  endif
242  iergpn = itrack%p%fm%p(4)
243 !cc kinetic or total energy ?
244 !cc by 100 TeV e- pirmary case, total seems better.
245 !cc if( iTrack.p.code .eq. knuc .and.
246 !cc * iTrack.p.subcode .ne. antip) then
247 !cc iergpn = iTrack.p.fm.p(4) - iTrack.p.mass
248  if(itrack%p%code .eq. kgnuc) then
249 ! iergpn = (iergpn-iTrack.p.mass)/iTrack.p.subcode
250  iergpn = iergpn/itrack%p%subcode
251  endif
252 
253 ! if(aTrack.p.code .eq. knuc .and.
254 ! * aTrack.p.subcode .ne. antip) then
255 ! aergpn = aTrack.p.fm.p(4) - aTrack.p.mass
256 ! elseif(aTrack.p.code .eq. kgnuc) then
257  aergpn = atrack%p%fm%p(4)
258  if(atrack%p%code .eq. kgnuc) then
259 ! aergpn = (aergpn-aTrack.p.mass) / aTrack.p.subcode
260  aergpn = aergpn / atrack%p%subcode
261  endif
262 ! ----------------
263  if( atrack%p%code .le. kelec ) then
264  jj = 1
265  else
266  jj = 3
267  endif
268  if( itrack%p%code .le. kelec ) then
269  ii = 1
270  else
271  ii = 3
272  endif
273 !
274 !
275  if(iergpn .gt. ethin(ii)*relax ) then
276  if(aergpn .gt. ethin(jj)*relax) then
277 ! Both Ei, Ec> Ethin1; no thinning
278  icon = 0
279  atrack%wgt = itrack%wgt
280 ! elseif(aergpn .gt. Ethin(2)) then
281  else
282 #if EXACTWGT == 1
283  p = aergpn/(ethin(jj)*relax)
284  if( itrack%wgt/p .lt. ethin(jj+1)*relax) then
285 #else
286  if( atrack%wgt .lt. ethin(jj+1)*relax) then
287  p = aergpn/(ethin(jj)*relax)
288 #endif
289 
290  call rndc(u)
291  if(u .lt. p) then
292  icon = 0
293  atrack%wgt = itrack%wgt / p
294  else
295  icon = 1
296  endif
297  else
298  icon = 0
299  atrack%wgt = itrack%wgt
300  endif
301  endif
302  else
303  if(aergpn .gt. ethin(jj)*relax) then
304  atrack%wgt = itrack%wgt
305  icon = 0
306  else
307 #if EXACTWGT == 1
308  p = aergpn/iergpn
309  if( itrack%wgt/p .lt. ethin(jj+1)*relax ) then
310 #else
311  if( atrack%wgt .lt. ethin(jj+1)*relax ) then
312  p = aergpn/iergpn
313 #endif
314 
315  call rndc(u)
316  if(u .lt. p ) then
317  icon = 0
318  atrack%wgt = itrack%wgt / p
319  else
320  icon = 1
321  endif
322  else
323  icon =0
324  atrack%wgt = itrack%wgt
325  endif
326  endif
327  endif
328  else
329  icon = 0
330  atrack%wgt = itrack%wgt
331  endif
332 
333  end
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
max ptcl codes in the kgnuc
Definition: Zcode.h:2
const int kphoton
Definition: Zcode.h:6
Definition: Ztrack.h:44
max ptcl codes in the kelec
Definition: Zcode.h:2
block data cblkElemag data *AnihiE ! Eposi< 1 TeV, anihilation considered *X0/365.667/, ! radiation length of air in kg/m2 *Ecrit/81.e-3/, ! critical energy of air in GeV *MaxComptonE/1./, ! compton is considered below 1 GeV *MaxPhotoE/1.e-3/, ! above this, PhotoElectric effect neg. *MinPhotoProdE/153.e-3/, ! below 153 MeV, no gp --> hadrons ! scattering const not MeV *Knockon true
Definition: cblkElemag.h:7
subroutine cxyz2prim(base, a, b)
Definition: cxyz2prim.f:5
subroutine rndc(u)
Definition: rnd.f:91
! Zobs h header file for observation sites definition ! integer horizontal
Definition: Zobs.h:4
block data cblkElemag data *AnihiE ! Eposi< 1 TeV, anihilation considered *X0/365.667/, ! radiation length of air in kg/m2 *Ecrit/81.e-3/, ! critical energy of air in GeV *MaxComptonE/1./, ! compton is considered below 1 GeV *MaxPhotoE/1.e-3/, ! above this, PhotoElectric effect neg. *MinPhotoProdE/153.e-3/, ! below 153 MeV, no gp --> hadrons ! scattering const not MeV *Knockon ! knockon is considered Obsolete *PhotoProd false
Definition: cblkElemag.h:7
subroutine cthinning(Tracks, n, iTrack, nout)
Definition: cthinning.f:2
Definition: Zcoord.h:43
subroutine cxyz2det(det, a, b)
Definition: cxyz2det.f:7
! Zobs h header file for observation sites definition ! integer * perpendicular
Definition: Zobs.h:4
subroutine csetthinwgt(iTrack, aTrack, icon)
Definition: cthinning.f:56