COSMOS v7.655  COSMOSv7655
(AirShowerMC)
chookASbyH.f
Go to the documentation of this file.
1 #include "../chookHybAS.f"
2 #include "../ctemplCeren.f"
3 #include "ZcosmosBD.h"
4 !
5 ! chookASbyH: This is a special user hook to compute
6 ! AS generated by heavy primaries with
7 ! generate='qas'.
8 ! **Important**
9 ! You almost need not modify this file, although
10 ! you have to read this. Those parts that you
11 ! have to modify are gathered in chookASbyH2.f
12 !
13 !
14 ! If the primary is a proton, we need about only 10 min even at
15 ! 10^21 eV to produce AS by the hybrid method. The time needed
16 ! at lower energies is shorter (but not propotinal to the energy).
17 ! However, for heavy primaries such as Fe,
18 ! we need few to several hours to simulate 1 A.S even at 10^18 eV,
19 ! so we must coin out some new method.
20 ! The idea here is to use chookNEPInt where we get control
21 ! when a hadron makes an interaction. We may see interacting
22 ! nucleons there, and replace each of their further development by
23 ! a precomputed proton shower (let's call it componet shower)
24 ! and discard further development of the shower by that nucleon.
25 !
26 ! To use this routine for a heavy primary of mass A with total energy E,
27 ! you need to create AS by protons with energy E/A beforehand.
28 ! The first iteraction point of the protons should be fixed somewhere,
29 ! or should be known.
30 ! (To fix the first collision point when making c.s,
31 ! put Freec = f, and say, HeightOfInj =20000).
32 ! (As far as the one dimensional dvelopment of electrons is
33 ! concerned, the first interaction point can be almost arbitrary;
34 ! The LPM effect will not be the problem).
35 !
36 ! The number of component showers should be 100~300. For each of
37 ! component showers, you must have the first interaction point,
38 ! air shower sizes at different depths (better at equisteped depths)
39 ! In some case you need ages, muon size, etc, depending on your demands.
40 ! An arbitrary shower among them should be randomly selected as
41 ! a component shower. For this end, I recommend you to use
42 ! direct access file so that you may read an arbitrary c.s from
43 ! a disk file when a c.s is requested. Alternatively, you may
44 ! define a large array to store c.s data so that quick random
45 ! selection is possible.
46 !
47 ! Thus, (in chookASbyH2.f)
48 ! a) In chookBgRun,
49 ! you may open the component shower file.
50 ! get some overall information
51 ! b) In chookBgEvent,
52 ! you may clear the AS size counters. This is auomatically
53 ! performed if you use standard counters.
54 ! c) In chookNEPInt,
55 ! c-1) you should inquire the interacting nucleons by
56 ! calling cqIntePtcl,
57 ! c-2) get a component shower randomly
58 ! c-3) increment the size counters
59 ! You need some interpolation for this end.
60 ! c-4) Finally you must give "never = 2" to discard further
61 ! development of showers by the interacting nucleons.
62 ! d) In chookEnEvent,
63 ! you should output AS size.
64 !
65 ! In this template, we assume that log10( electron size) is stored in
66 ! a direct access file. If size is 0, log10(size) may be -1.
67 !
68 ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
69 ! All actual interface routines are in chookASbyH2.f
70 ! In this file, there are lines to call routines in chookASbyH2.f
71 ! see %%%% parts below.
72 !
73 ! *************************************** hook for Beginning of a Run
74 ! * At this moment, all (system-level) initialization for this run
75 ! * has been ended. After this routine is executed, the system goes into the
76 ! * event creation loop.
77 ! *
78  subroutine chookbgrun
79  implicit none
80 #include "Zmanagerp.h"
81 
82 !
83 ! If you feel writing the parameters on stderr is
84 ! a bother, comment out the next or
85 ! use other device than ErrorOut.
86 ! Also you may comment out all output routines below.
87 #ifdef sun4
88  external csighandler
89  integer ieeer, ieee_handler
90 
91  ieeer = ieee_handler('set', 'invalid', csighandler)
92 #endif
93 !
94 ! namelist output
95  call cwriteparam(errorout, 0)
96 ! primary information
97  call cprintprim(errorout)
98 ! observation level information
99  call cprintobs(errorout)
100 ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
101 ! open component disk file, and get some over all
102 ! informaiton such as number of component showers
103 
104  call chookbgrunas
105 
106  end
107 
108 #ifdef sun4
109  integer function csighandler(sig, code, context)
110  implicit none
111 #include "Zmanagerp.h"
112  integer sig, code, context(5)
113  write(errorout, *) ' f.p exception content=' , context(4)
114 ! call abort()
115  end
116 #endif
117 
118 ! *********************************** hook for Beginning of 1 event
119 ! * All system-level initialization for 1 event generation has been
120 ! * eneded at this moment.
121 ! * After this is executed, event generation starts.
122 ! *
123  subroutine chookbgevent
124  implicit none
125 !
126  integer seed(2)
127 ! write(*, *) ' bigin event generation'
128  call cqinirn(seed)
129 ! write(*,*) ' seed=', seed
130 
131 
132  end
133 
134 
135 ! ************************************ hook for observation
136 ! * One particel information is brought here by the system.
137 ! * All information of the particle is in aTrack
138 ! *
139  subroutine chookobs(aTrack, id)
140 !
141 ! Note that every real variable is in double precision so
142 ! that you may output it in sigle precision to save the memory.
143 ! In some cases it is essential to put it in sigle (say,
144 ! for gnuplot).
145 !
146  implicit none
147 #include "Zcode.h"
148 #include "Ztrack.h"
149  integer id ! input. 1 ==> aTrack is going out from
150 ! outer boundery.
151 ! 2 ==> reached at an observation level
152 ! 3 ==> reached at inner boundery.
153  type(track):: aTrack
154 
155 !
156 ! For id =2, you need not output the z value, because it is always
157 ! 0 (within the computational accuracy).
158 !
159  if(id .eq. 2) then
160 ! output typical quantities.
161 ! write(*, *)
162 ! * aTrack.where, ! observation level. integer*2. 1 is highest.
163 ! * aTrack.p.code, ! ptcl code. integer*2.
164 ! * aTrack.p.charge, ! charge, integer*2
165 ! * sngl(aTrack.t), ! relateive arrival time in nsec (NOT sec).
166 ! ! if TimeStructure is F, nonsense.
167 ! * sngl(aTrack.p.fm.e) ! total energy in GeV.
168 ! * sngl(aTrack.pos.xyz.x), sngl(aTrack.pos.xyz.y), ! x, y in m
169 ! * sngl(aTrack.vec.w.x), ! direc. cos.x in the current detector system.
170 ! * sngl(aTrack.vec.w.y), ! direc. cos.y
171 ! * sngl(aTrack.vec.w.z), ! direc. cos.z
172 ! * sngl(aTrack.vec.coszenith) ! cos of zenith angle
173 ! if(aTrack.p.code .eq. kelec) then
174 ! write(*, *) aTrack.where
175 ! endif
176 ! endif
177 ! you may need in some case other information such as
178 ! aTrack.p.subcode ! sub code of the particle integer*2
179 ! aTrack.p.mass ! mass
180 ! aTrack.wgt ! weight of the particle (may not be 1. if
181 ! ! ThinSampling =T)
182 ! aTrack.p.fm.x ! momentum x component. Note. Momentum is
183 ! given in the Earth xyz system.
184 
185 ! aTrack.p.fm.y ! y
186 ! aTrack.p.fm.z ! z
187 
188  endif
189  end
190 
191 ! *********************************** hook for end of 1 event
192 ! * At this moment, 1 event generation has been ended.
193 ! *
194  subroutine chookenevent
196  implicit none
197 #include "Ztrack.h"
198 #include "Ztrackv.h"
199 #include "Zobs.h"
200 #include "Zobsp.h"
201 #include "Zobsv.h"
202  include "ZASbyH.h"
203 
204 
205 
206 ! type(track):: inci
207 ! type(coord):: angle
208  integer i
209  real*8 fdepth
210 
211 !
212 
213  if(observeas) then
214  call cqfirstid(fdepth)
215 ! call cqIncident(inci, angle)
216 ! bsin = cgetBsin(inci.p, Mag)*1.e4
217 ! electron size in B approx.
218 ! write(*, *) (ASObsSites(i).esize, i=1, NoOfASSites)
219 ! size weighted age
220 ! write(*, *) (ASObsSites(i).age, i=1, NoOfASSites)
221  do i = 1, noofassites
222  write(*, *) sngl(asobssites(i).pos.depth),
223  * sngl(asobssites(i).esize),
224  * sngl(asobssites(i).age)
225 ! * ,sngl(fdepth)
226 ! * ,sngl(bsin)
227  enddo
228  write(*, *)
229  endif
230 
231 
232  end
233 
234 
235 ! ********************************* hook for end of a run
236 ! * all events have been created or time lacks
237 ! *
238  subroutine chookenrun
240  implicit none
241  end
242 ! ********************************* hook for trace
243 ! * This is called only when trace > 60
244 ! * User should manage the trace information here.
245 ! * If you use this, you may need some output for trace
246 ! * at the beginning of 1 event generatio and at the end of 1 event
247 ! * generation so that you can identfy each event.
248 ! *
249 ! *
250  subroutine chooktrace
251  implicit none
252 
253 #include "Ztrack.h"
254 #include "Ztrackv.h"
255 #include "Ztrackp.h"
256 #include "Zobs.h"
257 #include "Zobsv.h"
258 
259  real*4 h1, h2
260 !
261 ! Every time a particle is moved in the atmosphere, this routine is called,
262 ! if trace > 60.
263 ! For a one track segment,
264 ! TrackBefMove has track information at the beginning of the segment.
265 ! MoveTrack has track information at the end of the segment.
266 !
267 ! You can know the information a track contains in the
268 ! chookObs routine. (Note however, no conversion of coordinate
269 ! has been done. The values are in the Earth xyz system.)
270 ! Besides quantities explained there, you can use, for a given 'track'
271 !
272 ! atrack.pos.xyz.x, atrack.pos.xyz.y, atrack.pos.xyz.z (x,y.z)
273 ! atrack.pos.radiallen (distance from the center of the earth)
274 ! atrack.pos.depth (vertical depth)
275 ! atrack.pos.height (vertical heigth from sea level)
276 !
277 
278  h1 = trackbefmove.pos.height- obssites(noofsites).pos.height
279  h2 = movedtrack.pos.height - obssites(noofsites).pos.height
280 
281  end
282 
283 ! ********************* this is the hook called when
284 ! an electron made an interaction.
285 !
286  subroutine chookeint(never)
287  implicit none
288 
289 #include "Ztrack.h"
290 #include "Ztrackv.h"
291 ! #include "Ztrackp.h"
292 
293  integer never ! input & output
294 
295 ! don't make never = 1, if you want to get
296 ! information after an electron made interaction
297 ! if this is made non zero, this routine will never be called.
298 !
299 ! MovedTrack is the electron that made interaction
300 ! Pwork contains produced particles.
301 ! Nproduced has the number of particles in Pwork
302 ! IntInfArray(ProcessNo) contains the type of interaction
303 !
304 ! default setting
305  never = 1
306 !
307 ! IntInfArray(ProcessNo).process will have one of
308 ! 'brems', 'mscat', 'bscat', 'anihi' or 'mbrem'
309 !
310  end
311 
312 ! ********************* this is the hook called when
313 ! a gamma ray made an interaction.
314 !
315  subroutine chookgint(never)
316  implicit none
317 
318 #include "Ztrack.h"
319 #include "Ztrackv.h"
320 ! #include "Ztrackp.h"
321 
322  integer never ! input & output
323 
324 ! don't make never = 1, if you want to get
325 ! information after a gamma ray made interaction
326 ! if this is made non zero, this routine will never be called.
327 !
328 ! MovedTrack is the gamma that made interaction
329 ! Pwork contains produced particles.
330 ! Nproduced has the number of particles in Pwork
331 ! IntInfArray(ProcessNo) contains the type of interaction
332 !
333 ! default setting
334  never = 1
335 ! IntInfArray(ProcessNo).process will have one of
336 ! 'pair', 'comp', 'photoe' 'photop' 'mpair'
337 !
338  end
339 
340 ! ********************* this is the hook called when
341 ! non e-g particle made an interaction.
342 !
343  subroutine chooknepint(never)
344  implicit none
345 #include "Zcode.h"
346 #include "Ztrack.h"
347 #include "Ztrackv.h"
348 ! #include "Ztrackp.h"
349 
350  integer never ! input & output
351 
352 ! don't make never = 1, if you want to get
353 ! information after a non-e-g particle made interaction.
354 ! if this is made non zero, this routine will never be called.
355 !
356 ! MovedTrack is the particle that made interaction
357 ! Pwork contains produced particles.
358 ! Nproduced has the number of particles in Pwork
359 ! IntInfArray(ProcessNo) contains the type of interaction
360 !
361 ! IntInfArray(ProcessNo).process will have
362 ! 'col' or 'decay'
363 ! %%%%%%%%%%%%%%%%%%%%%%%%%%
364 ! replace interacting nucleons by c.s. give never = 2
365 ! so that no further development by the interacting nucleons.
366 !
367  call chooknepinta
368  never = 2
369  end
*Zfirst p fm *Zfirst p Zfirst p Zfirst p *Zfirst p *Zfirst pos xyz Zfirst pos xyz *Zfirst pos *Zfirst pos depth
Definition: ZavoidUnionMap.h:1
subroutine cprintobs(io)
Definition: cprintObs.f:2
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
subroutine cqfirstid(depth)
Definition: ciniTracking.f:188
subroutine chooktrace
Definition: chook.f:275
*Zfirst p fm *Zfirst p Zfirst p Zfirst p *Zfirst p *Zfirst pos xyz Zfirst pos xyz *Zfirst pos *Zfirst pos Zfirst pos height
Definition: ZavoidUnionMap.h:1
integer function csighandler(sig, code, context)
Definition: chook.f:63
subroutine chookobs(aTrack, id)
Definition: chook.f:59
subroutine chookbgevent
Definition: chook.f:39
subroutine cqinirn(ir)
Definition: cwriteSeed.f:4
subroutine chookbgrun
Definition: chook.f:15
subroutine chookeint(never)
Definition: chook.f:162