COSMOS v7.655  COSMOSv7655
(AirShowerMC)
add2hyb.f
Go to the documentation of this file.
1  implicit none
2 ! Suppose we have n hybrid data
3 ! h1, h2, h3, ....hn
4 ! 1) cp h1 h0
5 ! 2) h0 + h2 --> h; mv h h0
6 ! 3) h0 + h3 --> h; mv h h0
7 ! ..
8 ! n) h0 + hn --> h; mv h h0
9 !
10 ! This program add two hybrid data; h0 + hx--> h
11 ! environmental variable
12 ! file h0: HYBFILE0
13 ! file hx: HYBFILEX
14 ! file h: HYBFILET
15 !
16 
17  integer ndepth
18  parameter(ndepth= 50)
19  real*8 ASdep(ndepth), muunit(ndepth), sumEsize, sumEsize2
20  real*8 Esize0(ndepth),
21  * age0(ndepth), cogdep0(ndepth),
22  * seloss0(ndepth),
23  * ng0(ndepth), ne0(ndepth), nmu0(ndepth), nhad0(ndepth),
24  * cog0, cog20
25  real*8 Esizex(ndepth),
26  * agex(ndepth), cogdepx(ndepth),
27  * selossx(ndepth),
28  * ngx(ndepth), nex(ndepth), nmux(ndepth), nhadx(ndepth),
29  * cogx, cog2x
30 
31  real*8 Esizet(ndepth),
32  * aget(ndepth), cogdept(ndepth),
33  * selosst(ndepth),
34  * ngt(ndepth), net(ndepth), nmut(ndepth), nhadt(ndepth),
35  * cogt, cog2t
36 
37  integer EvNo0, EvNox
38  integer fn0, fnx, fnt
39  integer kgetenv2
40  integer klena
41  integer code, subcode, charge
42  integer leng, i, j, lengflesh
43  integer icon0, iconx, icont
44  real dd, firstz, w1, w2, w3, E0
45  character*128 hyb0, hybx, hybt, flesher
46  character*128 input0, inputx, inputt
47  fn0 = 2
48  fnx = 3
49  fnt = 4
50  leng = kgetenv2("HYBFILE0", hyb0)
51  call copenfw2(fn0, hyb0, 1, icon0)
52  if(icon0 .ne. 1) then
53  write(0,*) hyb0(1:leng)
54  if( icon0 .eq. 0) then
55  write(0,*) 'not exists'
56  else
57  write(0,*) ' cannot be opened '
58  endif
59  write(0,*) ' icon=',icon0
60  stop 9999
61  else
62  write(0,*) hyb0(1:leng), ' opened'
63  endif
64  leng = kgetenv2("HYBFILEX", hybx)
65  call copenfw2(fnx, hybx, 1, iconx)
66  if(iconx .ne. 1) then
67  write(0,*) hybx(1:leng)
68  if( iconx .eq. 0) then
69  write(0,*) 'not exists'
70  else
71  write(0,*) ' cannot be opened '
72  endif
73  write(0,*) ' icon=',iconx
74  stop 9999
75  else
76  write(0,*) hybx(1:leng), ' opened'
77  endif
78 
79 
80  leng = kgetenv2("HYBFILET", hybt)
81  call copenfw2(fnt, hybt, 1, icont)
82  if(icont .ne. 0) then
83  write(0,*) hybt(1:leng)
84  write(0,*) ' cannot be opened '
85  write(0,*) ' icon=',icont
86  stop 9999
87  else
88  write(0,*) hybt(1:leng), ' opened'
89  endif
90  lengflesh = kgetenv2("FLESHDIR", flesher)
91 
92  i =0
93  do while(.true.)
94  input0 = ' '
95  read( fn0, '(a)', end=1000 ) input0
96  inputx = ' '
97  read( fnx, '(a)' ) inputx
98  if(input0 .ne. " ") then
99  if(flesher(1:lengflesh) .eq. "FleshHist") then
100  if(input0(1:1) .eq. "h" ) then
101  read(input0(3:klena(input0)),* ) evno0, code,
102  * subcode, charge, e0, w1, w2, w3,firstz,
103  * cog0, cog20
104 
105  read(inputx(3:klena(inputx)),*) evnox, code,
106  * subcode, charge, e0, w1, w2, w3,firstz,
107  * cogx, cog2x
108 
109  else
110  read(input0(3:klena(input0)), *)
111  * i, asdep(i), muunit(i), age0(i), cogdep0(i),
112  * ng0(i), ne0(i), nmu0(i), nhad0(i),
113  * esize0(i), seloss0(i)
114 
115  read(inputx(3:klena(inputx)), *)
116  * i, asdep(i), muunit(i), agex(i), cogdepx(i),
117  * ngx(i), nex(i), nmux(i), nhadx(i),
118  * esizex(i), selossx(i)
119  endif
120  else
121  read(input0(3:klena(input0)), *)
122  * i, asdep(i), muunit(i), age0(i), cogdep0(i),
123  * ng0(i), ne0(i), nmu0(i), nhad0(i),
124  * esize0(i)
125  selossx(i) =0.
126 
127  read(inputx(3:klena(inputx)), *)
128  * i, asdep(i), muunit(i), agex(i), cogdepx(i),
129  * ngx(i), nex(i), nmux(i), nhadx(i),
130  * esizex(i)
131  selossx(i) =0.
132  endif
133  else
134 ! 1 event read
135  if(inputx .ne. " ") then
136  write(0,*) ' event differ', inputx
137  stop 1111
138  endif
139  do j = 1, i
140  esizet(j) = esize0(j) + esizex(j)
141  if(esizet(j) .gt. 0.) then
142  aget(j) = ( esize0(j)*age0(j) + esizex(j)*agex(j))/
143  * esizet(j)
144  else
145  aget(j)= 0.
146  endif
147  selosst(j) = seloss0(j) + selossx(j)
148  ngt(j) = ng0(j) + ngx(j)
149  net(j) = ne0(j) + nex(j)
150  nmut(j) = nmu0(j) + nmux(j)
151  nhadt(j) = nhad0(j) + nhadx(j)
152  enddo
153  cogt =0.
154  cog2t =0.
155  sumesize = 0.
156  sumesize2 = 0.
157  do j = 1, i
158  if(j .gt. 1 .and. j .lt. i ) then
159  dd =( asdep(j+1) - asdep(j-1))/2.0
160  elseif(j .eq. 1) then
161  dd =(asdep(2) - asdep(1))
162  else
163  dd =(asdep(i) - asdep(i-1))
164  endif
165  cogt = cogt + esizet(j)*asdep(j)*dd
166  sumesize = sumesize + esizet(j)*dd
167 
168  if( aget(j) .gt. 2.0-aget(i) ) then
169  if(j .gt. 1 .and. j .lt. i ) then
170  dd =( asdep(j+1) - asdep(j-1))/2.0
171  elseif(j .eq. 1) then
172  dd =(asdep(2) - asdep(1))
173  else
174  dd =(asdep(i) - asdep(i-1))
175  endif
176  cog2t = cog2t + esizet(j)*asdep(j)*dd
177  sumesize2= sumesize2 + esizet(j)*dd
178  endif
179  enddo
180  cogt = cogt / sumesize
181  if(sumesize2 .gt. 0.) then
182  cog2t = cog2t / sumesize2
183  else
184  cog2t = asdep(i)
185  endif
186  do j = 1, i
187  cogdept(j) = asdep(j)/cog2t
188  enddo
189  write(fnt,
190  * '("h ", i4, 3i3, 1pE11.3, 0p 3f11.7, f7.2, 2f7.0)')
191  * evno0, code,
192  * subcode, charge, e0, w1, w2, w3,firstz,
193  * cogt, cog2t
194  do j = 1, i
195  if(flesher(1:lengflesh) .eq. "FleshHist") then
196  write(fnt, '("t ", i3, 2f7.1, 2f6.3,
197  * 1p6E11.3)')
198  * j,
199  * asdep(j), muunit(j),
200  * aget(j), cogdept(j),
201  * ngt(j), net(j), nmut(j), nhadt(j),
202  * esizet(j), selosst(j)
203  else
204  write(fnt, '("t ", i3, 2f7.1, 2f6.3,
205  * 1p5E11.3)')
206  * j,
207  * asdep(j), muunit(j),
208  * aget(j), cogdept(j),
209  * ngt(j), net(j), nmut(j), nhadt(j),
210  * esizet(j)
211  endif
212  enddo
213  write(fnt, *)
214  endif
215  enddo
216  1000 continue
217  write(0,*) 'all events processed '
218  end
219 
220 
221 
integer npitbl real *nx parameter(n=101, npitbl=46, nx=n-1) real *8 uconst
integer function kgetenv2(envname, envresult)
Definition: cgetLoginN.f:77
nodes i
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
integer leng
Definition: interface2.h:1
********************block data cblkHeavy ********************integer j data *HeavyG2symbol *data *HeavyG2code kiron data j
Definition: cblkHeavy.h:36
subroutine copenfw2(io, fnin, form, icon)
Definition: copenf.f:205
*Zfirst p fm *Zfirst p Zfirst p code
Definition: ZavoidUnionMap.h:1
*Zfirst p fm *Zfirst p Zfirst p Zfirst p *Zfirst p charge
Definition: ZavoidUnionMap.h:1
integer function klena(cha)
Definition: klena.f:20
*Zfirst p fm *Zfirst p Zfirst p Zfirst p subcode
Definition: ZavoidUnionMap.h:1