COSMOS v7.655  COSMOSv7655
(AirShowerMC)
chook.f
Go to the documentation of this file.
1 #include "cmain.f"
2 #include "chookHybAS.f"
3 #include "ctemplCeren.f"
4 #if defined (KEKB) || defined (KEKA)
5 #define DOMPI
6 #endif
7 ! *************************************** hook for Beginning of a Run
8 ! * At this moment, all (system-level) initialization for this run
9 ! * has been ended. After this routine is executed, the system goes into the
10 ! * event creation loop.
11 ! *
12  subroutine chookbgrun
13  implicit none
14 #include "Zmanagerp.h"
15 
16 ! If you feel writing the parameters on stderr is
17 ! a bother, comment out the next or
18 ! use other device than ErrorOut.
19 ! Also you may comment out all output routines below.
20 
21 ! namelist output
22  call cwriteparam(errorout, 0)
23 ! primary information
24  call cprintprim(errorout)
25 ! observation level information
26  call cprintobs(errorout)
27 
28 
29  end
30 
31 
32 ! *********************************** hook for Beginning of 1 event
33 ! * All system-level initialization for 1 event generation has been
34 ! * eneded at this moment.
35 ! * After this is executed, event generation starts.
36 ! *
37  subroutine chookbgevent
38  implicit none
39 #if defined (DOMPI)
40 #include "mpif.h"
41 #include "Zmpi.h"
42  real*8 etime1
43  etime1 = mpi_wtime()
44  write(0,*) 'rank=',mpirank, ' time start=',etime1
45 #endif
46  end
47 
48 
49 ! ************************************ hook for observation
50 ! * One particle information is brought here by the system.
51 ! * All information of the particle is in aTrack
52 ! *
53  subroutine chookobs(aTrack, id)
54 !
55 ! Note that every real variable is in double precision so
56 ! that you may output it in sigle precision to save the memory.
57 ! In some cases it is essential to put it in sigle (say,
58 ! for gnuplot).
59 !
60  implicit none
61 #include "Ztrack.h"
62  integer id ! input. 1 ==> aTrack is going out from
63 ! outer boundery.
64 ! 2 ==> reached at an observation level
65 ! 3 ==> reached at inner boundery.
66  type(track):: aTrack
67 !
68 ! For id =2, you need not output the z value, because it is always
69 ! 0 (within the computational accuracy).
70 !
71  if(id .eq. 2) then
72 ! output typical quantities.
73  write(*, '(3i3, 1p, 4g15.4,0p, 4f10.6)')
74  * atrack%where, ! observation level. integer*2. 1 is highest.
75  * atrack%p%code, ! ptcl code. integer*2.
76  * atrack%p%charge, ! charge, integer*2
77  * atrack%t, ! relateive arrival time in nsec (NOT sec).
78  ! if TimeStructure is F, nonsense.
79  * atrack%p%fm%p(4), ! total energy in GeV.
80  * atrack%pos%xyz%r(1), atrack%pos%xyz%r(2), ! x, y in m
81  * atrack%vec%w%r(1), ! direc. cos%x in the current detector system.
82  * atrack%vec%w%r(2), ! direc. cos%y
83  * atrack%vec%w%r(3), ! direc. cos%z
84  * atrack%vec%coszenith ! cos of zenith angle
85  endif
86 ! you may need in some case other information such as
87 ! aTrack.p.subcode ! sub code of the particle integer*2
88 ! aTrack.p.mass ! mass
89 ! aTrack.wgt ! weight of the particle (may not be 1. if
90  ! ThinSampling =T)
91 ! aTrack.p.fm.p(1) ! momentum x component. Note. Momentum is
92 ! given in the Earth xyz system.
93 
94 ! aTrack.p.fm.p(2) ! y
95 ! aTrack.p.fm.p(3) ! z
96 
97  end
98 
99 ! *********************************** hook for end of 1 event
100 ! * At this moment, 1 event generation has been ended.
101 ! *
102  subroutine chookenevent
104  implicit none
105 #include "Ztrack.h"
106 #include "Ztrackv.h"
107 #include "Zobs.h"
108 #include "Zobsp.h"
109 #include "Zobsv.h"
110 
111  integer i
112 
113  type(coord):: angle
114  type(track):: incident
115 
116 #if defined (DOMPI)
117 #include "mpif.h"
118 #include "Zmpi.h"
119  real*8 etime2
120  etime2 = mpi_wtime()
121  write(0,*) 'rank=',mpirank, ' time end=',etime2
122 #endif
123  real(8):: xs
124  integer:: IA, IZ
125 
126  if(observeas) then
127 ! electron size in B approx.
128  write(*, *) (asobssites(i)%esize, i=1, noofassites)
129 ! size weighted age
130  write(*, *) (asobssites(i)%age, i=1, noofassites)
131  endif
132  call cqincident(incident, angle)
133 
134  write(0,*) '1ry c,subc,chg, TE cos-zenith '
135  write(0,*)
136  * incident%p%code, incident%p%subcode, incident%p%charge,
137  * incident%p%fm%p(4), incident%vec%coszenith
138  call cqfirstipi(incident) ! first int point info.
139  write(0,*) ' 1st int. depth, height, coszenith'
140  write(0,*) incident%pos%depth, incident%pos%height,
141  * incident%vec%coszenith
142  call cqfirstcolmedia(ia, iz, xs)
143  write(0,*) ' first A,Z,xs=', ia, iz, xs
144  end
145 
146 
147 ! ********************************* hook for end of a run
148 ! * all events have been created or time lacks
149 ! *
150  subroutine chookenrun
152  implicit none
153 #include "Ztrack.h"
154 #include "Ztrackp.h"
155  integer klena
156  character*24 tracefile
157  character*1 qm/"'"/
158  write(*,'(a)') '# ^ ^ ^'
159  write(*,'(a)') '# | | | '
160  write(*,'(a)') '# depth indx code charge time E '//
161  * ' X (m) Y (m) Wx Wy Wz'//
162  * ' cos(zenith)'
163 
164  write(*, *)
165 
166  write(0, *)
167  * ' ****** Congratulations ****** '
168 
169  if(trace .gt. 0) then
170  tracefile = tracedir(1:klena(tracedir))//'trace?'
171  write(0, *)
172  * ' particle trace data has been created'//
173  * ' in '//tracefile
174  write(0, *)
175  * ' ?=1,2... You can see it by Geomview (or gnuplot): '
176  write(0, *)
177  * 'Geomview is faster & better; If it has been installed, do '
178  write(0, *)
179  * ' dispcosTraceByGeomv path-to-tracefile(=trace1 or 2)'
180  write(0, *) " "
181  write(0, *)
182  * ' For gnuplot, use dispcosTraceByGnup instead '
183  write(0,*) ' In both case, if no argument is given,'
184  write(0,*) ' usage will be shown'
185  write(0,*)
186  write(0,*)
187  * " ***Make Trace=0 in 'param file' for normal jobs***"
188  endif
189  write(0, *)
190  * '************ Have a nice day !! **************'
191 
192  end
193 ! ********************************* hook for trace
194 ! * This is called only when trace > 60
195 ! * User should manage the trace information here.
196 ! * If you use this, you may need some output for trace
197 ! * at the beginning of 1 event generatio and at the end of 1 event
198 ! * generation so that you can identfy each event.
199 ! *
200 ! *
201  subroutine chooktrace
202  implicit none
203 
204 #include "Ztrack.h"
205 #include "Ztrackv.h"
206 #include "Ztrackp.h"
207 #include "Zobs.h"
208 #include "Zobsv.h"
209 
210  real*4 h1, h2
211 !
212 ! Every time a particle is moved in the atmosphere, this routine is called,
213 ! if trace > 60.
214 ! For a one track segment,
215 ! TrackBefMove has track information at the beginning of the segment.
216 ! MoveTrack has track information at the end of the segment.
217 !
218 ! You can know the information a track contains in the
219 ! chookObs routine. (Note however, no conversion of coordinate
220 ! has been done. The values are in the Earth xyz system.)
221 ! Besides quantities explained there, you can use, for a given 'track'
222 !
223 ! atrack.pos.xyz.x, atrack.pos.xyz.y, atrack.pos.xyz.z (x,y.z)
224 ! atrack.pos.radiallen (distance from the center of the earth)
225 ! atrack.pos.depth (vertical depth)
226 ! atrack.pos.height (vertical heigth from sea level)
227 !
228 
229  h1 = trackbefmove%pos%height- obssites(noofsites)%pos%height
230  h2 = movedtrack%pos%height - obssites(noofsites)%pos%height
231 
232  end
233 ! ********************* this is the hook called when
234 ! an electron made an interaction.
235 !
236  subroutine chookeint(never)
237  implicit none
238 
239 #include "Ztrack.h"
240 #include "Ztrackv.h"
241 ! #include "Ztrackp.h"
242 
243  integer never ! input & output
244 
245 ! don't make never = 1, if you want to get
246 ! information after an electron made interaction
247 ! if this is made non zero, this routine will never be called.
248 !
249 ! MovedTrack is the electron that made interaction
250 ! Pwork contains produced particles.
251 ! Nproduced has the number of particles in Pwork
252 ! IntInfArray(ProcessNo) contains the type of interaction
253 !
254 ! default setting
255  never = 1
256 !
257 ! IntInfArray(ProcessNo).process will have one of
258 ! 'brems', 'mscat', 'bscat',or 'anihi'
259 !
260  end
261 
262 ! ********************* this is the hook called when
263 ! a gamma ray made an interaction.
264 !
265  subroutine chookgint(never)
266  implicit none
267 
268 #include "Ztrack.h"
269 #include "Ztrackv.h"
270 ! #include "Ztrackp.h"
271 
272  integer never ! input & output
273 
274 ! don't make never = 1, if you want to get
275 ! information after a gamma ray made interaction
276 ! if this is made non zero, this routine will never be called.
277 !
278 ! MovedTrack is the gamma that made interaction
279 ! Pwork contains produced particles.
280 ! Nproduced has the number of particles in Pwork
281 ! IntInfArray(ProcessNo) contains the type of interaction
282 !
283 ! default setting
284  never = 1
285 ! IntInfArray(ProcessNo).process will have one of
286 ! 'pair', 'comp', 'photoe' or 'photop'
287 !
288  end
289 
290 ! ********************* this is the hook called when
291 ! non e-g particle made an interaction.
292 !
293 
294  subroutine chooknepint(never)
295  use modxsecmedia
296  implicit none
297 
298 #include "Ztrack.h"
299 #include "Ztrackv.h"
300 
301  integer never ! input & output
302  integer:: A,Z
303  real(8):: xs, pabs, teta
304  integer:: i
305 
306 
307 
308 ! don't make never = 1, if you want to get
309 ! information after a non-e-g particle made interaction
310 ! if this is made non zero, this routine will never be called.
311 !
312 ! MovedTrack is the particle that made interaction
313 ! Pwork contains produced particles.
314 ! Nproduced has the 0number of particles in Pwork
315 ! IntInfArray(ProcessNo) contains the type of interaction
316 !
317 ! default setting
318  never = 1
319  end
320 
321 
322 
323 
subroutine cprintobs(io)
Definition: cprintObs.f:2
subroutine cqincident(incident, AngleAtObs)
Definition: cmkIncident.f:486
subroutine chookgint(never)
Definition: chook.f:191
subroutine chookenrun
Definition: chook.f:147
Definition: Ztrack.h:44
subroutine chooknepint(never)
Definition: chook.f:219
subroutine cprintprim(out)
Definition: cprintPrim.f:3
subroutine chookenevent
Definition: chook.f:116
subroutine cwriteparam(io, force)
Definition: cwriteParam.f:4
integer mpirank
Definition: Zmpibasic.h:1
subroutine chooktrace
Definition: chook.f:275
subroutine cqfirstcolmedia(A, Z, xs)
Definition: ciniTracking.f:211
subroutine cqfirstipi(ptrack)
Definition: ciniTracking.f:199
subroutine chookobs(aTrack, id)
Definition: chook.f:59
subroutine chookbgevent
Definition: chook.f:39
Definition: Zcoord.h:43
subroutine chookbgrun
Definition: chook.f:15
subroutine chookeint(never)
Definition: chook.f:162