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 !
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 #include "Ztrack.h"
126 
127  type(track):: aTrack
128  type(coord):: angleAtObs
129 !
130  integer no,seed(2)
131  real*8 pOrE
132 ! write(*, *) ' bigin event generation'
133  call cqinirn(seed)
134  call cqincident(atrack,angleatobs)
135  call cqnoofprim(no)
136  call cqprime(pore)
137 
138 
139  end
140 
141 
142 ! ************************************ hook for observation
143 ! * One particel information is brought here by the system.
144 ! * All information of the particle is in aTrack
145 ! *
146  subroutine chookobs(aTrack, id)
147 !
148 ! Note that every real variable is in double precision so
149 ! that you may output it in sigle precision to save the memory.
150 ! In some cases it is essential to put it in sigle (say,
151 ! for gnuplot).
152 !
153  implicit none
154 #include "Zcode.h"
155 #include "Ztrack.h"
156  integer id ! input. 1 ==> aTrack is going out from
157 ! outer boundery.
158 ! 2 ==> reached at an observation level
159 ! 3 ==> reached at inner boundery.
160  type(track):: aTrack
161 
162 !
163 ! For id =2, you need not output the z value, because it is always
164 ! 0 (within the computational accuracy).
165 !
166  if(id .eq. 2) then
167 ! output typical quantities.
168 ! write(*, *)
169 ! * aTrack.where, ! observation level. integer*2. 1 is highest.
170 ! * aTrack.p.code, ! ptcl code. integer*2.
171 ! * aTrack.p.charge, ! charge, integer*2
172 ! * sngl(aTrack.t), ! relateive arrival time in nsec (NOT sec).
173 ! ! if TimeStructure is F, nonsense.
174 ! * sngl(aTrack.p.fm.e) ! total energy in GeV.
175 ! * sngl(aTrack.pos.xyz.x), sngl(aTrack.pos.xyz.y), ! x, y in m
176 ! * sngl(aTrack.vec.w.x), ! direc. cos.x in the current detector system.
177 ! * sngl(aTrack.vec.w.y), ! direc. cos.y
178 ! * sngl(aTrack.vec.w.z), ! direc. cos.z
179 ! * sngl(aTrack.vec.coszenith) ! cos of zenith angle
180 ! if(aTrack.p.code .eq. kelec) then
181 ! write(*, *) aTrack.where
182 ! endif
183 ! endif
184 ! you may need in some case other information such as
185 ! aTrack.p.subcode ! sub code of the particle integer*2
186 ! aTrack.p.mass ! mass
187 ! aTrack.wgt ! weight of the particle (may not be 1. if
188 ! ! ThinSampling =T)
189 ! aTrack.p.fm.x ! momentum x component. Note. Momentum is
190 ! given in the Earth xyz system.
191 
192 ! aTrack.p.fm.y ! y
193 ! aTrack.p.fm.z ! z
194 
195  endif
196  end
197 
198 ! *********************************** hook for end of 1 event
199 ! * At this moment, 1 event generation has been ended.
200 ! *
201  subroutine chookenevent
203  implicit none
204 #include "Ztrack.h"
205 #include "Ztrackv.h"
206 #include "Zobs.h"
207 #include "Zobsp.h"
208 #include "Zobsv.h"
209  include "ZASbyH.h"
210 
211 
212 
213 ! type(track):: inci
214 ! type(coord):: angle
215  integer i
216  real*8 fdepth
217 
218 !
219 
220 ! open(59,file='cosmos.dat',access='append')
221 ! write(59,*) (-1,i=1,8)
222  if(observeas) then
223  call cqfirstid(fdepth)
224 ! call cqIncident(inci, angle)
225 ! bsin = cgetBsin(inci.p, Mag)*1.e4
226 ! electron size in B approx.
227 ! write(59, *) (ASObsSites(i).esize, i=1, NoOfASSites)
228 ! size weighted age
229 ! write(*, *) (ASObsSites(i).age, i=1, NoOfASSites)
230  do i = 1, noofassites
231  write(*, *) 's ', sngl(asobssites(i).pos.depth/10.),
232  * sngl(asobssites(i).esize),
233  * sngl(asobssites(i).age)
234 ! * ,sngl(fdepth)
235 ! * ,sngl(bsin)
236  enddo
237  write(*, *)
238 ! close(59)
239  endif
240 
241 
242  end
243 
244 
245 ! ********************************* hook for end of a run
246 ! * all events have been created or time lacks
247 ! *
248  subroutine chookenrun
250  implicit none
251  end
252 ! ********************************* hook for trace
253 ! * This is called only when trace > 60
254 ! * User should manage the trace information here.
255 ! * If you use this, you may need some output for trace
256 ! * at the beginning of 1 event generatio and at the end of 1 event
257 ! * generation so that you can identfy each event.
258 ! *
259 ! *
260  subroutine chooktrace
261  implicit none
262 
263 #include "Ztrack.h"
264 #include "Ztrackv.h"
265 #include "Ztrackp.h"
266 #include "Zobs.h"
267 #include "Zobsv.h"
268 
269  real*4 h1, h2
270 !
271 ! Every time a particle is moved in the atmosphere, this routine is called,
272 ! if trace > 60.
273 ! For a one track segment,
274 ! TrackBefMove has track information at the beginning of the segment.
275 ! MoveTrack has track information at the end of the segment.
276 !
277 ! You can know the information a track contains in the
278 ! chookObs routine. (Note however, no conversion of coordinate
279 ! has been done. The values are in the Earth xyz system.)
280 ! Besides quantities explained there, you can use, for a given 'track'
281 !
282 ! atrack.pos.xyz.x, atrack.pos.xyz.y, atrack.pos.xyz.z (x,y.z)
283 ! atrack.pos.radiallen (distance from the center of the earth)
284 ! atrack.pos.depth (vertical depth)
285 ! atrack.pos.height (vertical heigth from sea level)
286 !
287 
288  h1 = trackbefmove.pos.height- obssites(noofsites).pos.height
289  h2 = movedtrack.pos.height - obssites(noofsites).pos.height
290 
291  end
292 
293 ! ********************* this is the hook called when
294 ! an electron made an interaction.
295 !
296  subroutine chookeint(never)
297  implicit none
298 
299 #include "Ztrack.h"
300 #include "Ztrackv.h"
301 ! #include "Ztrackp.h"
302 
303  integer never ! input & output
304 
305 ! don't make never = 1, if you want to get
306 ! information after an electron made interaction
307 ! if this is made non zero, this routine will never be called.
308 !
309 ! MovedTrack is the electron that made interaction
310 ! Pwork contains produced particles.
311 ! Nproduced has the number of particles in Pwork
312 ! IntInfArray(ProcessNo) contains the type of interaction
313 !
314 ! default setting
315  never = 1
316 !
317 ! IntInfArray(ProcessNo).process will have one of
318 ! 'brems', 'mscat', 'bscat', 'anihi' or 'mbrem'
319 !
320  end
321 
322 ! ********************* this is the hook called when
323 ! a gamma ray made an interaction.
324 !
325  subroutine chookgint(never)
326  implicit none
327 
328 #include "Ztrack.h"
329 #include "Ztrackv.h"
330 
331 
332  integer never ! input & output
333 
334 ! don't make never = 1, if you want to get
335 ! information after a gamma ray made interaction
336 ! if this is made non zero, this routine will never be called.
337 !
338 ! MovedTrack is the gamma that made interaction
339 ! Pwork contains produced particles.
340 ! Nproduced has the number of particles in Pwork
341 ! IntInfArray(ProcessNo) contains the type of interaction
342 !
343 ! default setting
344  never = 1
345 ! IntInfArray(ProcessNo).process will have one of
346 ! 'pair', 'comp', 'photoe' 'photop' 'mpair'
347 !
348  end
349 
350 ! ********************* this is the hook called when
351 ! non e-g particle made an interaction.
352 !
353  subroutine chooknepint(never)
354  implicit none
355 #include "Zcode.h"
356 #include "Ztrack.h"
357 #include "Ztrackv.h"
358 ! #include "Ztrackp.h"
359 
360  integer never ! input & output
361 
362 ! don't make never = 1, if you want to get
363 ! information after a non-e-g particle made interaction.
364 ! if this is made non zero, this routine will never be called.
365 !
366 ! MovedTrack is the particle that made interaction
367 ! Pwork contains produced particles.
368 ! Nproduced has the number of particles in Pwork
369 ! IntInfArray(ProcessNo) contains the type of interaction
370 !
371 ! IntInfArray(ProcessNo).process will have
372 ! 'col' or 'decay'
373 ! %%%%%%%%%%%%%%%%%%%%%%%%%%
374 ! replace interacting nucleons by c.s. give never = 2
375 ! so that no further development by the interacting nucleons.
376 !
377  call chooknepinta
378  never = 2
379  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 cqincident(incident, AngleAtObs)
Definition: cmkIncident.f:486
subroutine chookgint(never)
Definition: chook.f:191
subroutine cqnoofprim(no)
Definition: csampPrimary.f:356
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 cqprime(p_or_e)
Definition: csampPrimary.f:313
Definition: Zcoord.h:43
subroutine chookbgrun
Definition: chook.f:15
subroutine chookeint(never)
Definition: chook.f:162