COSMOS v7.655  COSMOSv7655
(AirShowerMC)
timeFit.f
Go to the documentation of this file.
1 #include "BlockData/cblkGene.h"
2  include "ZfitBD.h"
3  program timefit
4  implicit none
5  include "Zfit.h"
6 
7  real*8 xin(maxbin), yin(maxbin)
8  character*128 buf
9  integer nbin0, icon, code
10  integer count, status, cond
11  nbin0 = 0
12  count = nargs()
13  if(count .eq. 3) cond=1
14  if(count .eq. 2) cond=0
15  if( count .ne. 2 .and. count .ne. 3 ) then
16  write(0,*) 'Usage: timeFit.. code [c] < inputfile > outfile'
17  write(0,*) ' code = particle code,',
18  * ' inputfile is output from mkRvsT.csh '
19  write(0,*) ' c: if exists, write only coeff. on stdout '
20  write(0,*) ' if omitted, coeff. is output on stderr,',
21  * ' fitted (x,y) on stdout'
22  stop
23  endif
24  call getarg(1, buf, status)
25  read(buf, *) code
26  if(code .le. 3) then
27  code = 1
28  else
29 c code = 2
30 c with negative c hadron can be treated same as e,g,mu
31 c
32  code = 1
33  endif
34 
35  do while(.true.)
36  read(*,*,end=100) xin(nbin0+1), yin(nbin0+1)
37  nbin0 = nbin0 +1
38  enddo
39 100 continue
40  if(nbin0 .gt. maxbin) then
41  write(0,*) ' too many time data> ', maxbin
42  stop
43  endif
44 
45 c call copenfw2(minout, "./minout_@_#_%", 1, icon)
46  call copenfw2(minout, "/dev/null", 1, icon)
47 cccc call copenfw2(minsave, "./minsave_@_#_%", 1, icon) !!!
48 
49 
50  call fittime0(cond, code, xin, yin, nbin0)
51  end
52 
53  subroutine fittime0(cond, code, xin, yin, nbin)
54  implicit none
55  include "Zfit.h"
56  integer cond
57  integer nbin, code
58  real*8 xin(nbin), yin(nbin)
59  real*8 xuse(nbin), yuse(nbin)
60  real*8 prmout(nparam, nregion)
61 
62  integer i
63  integer n1, n2, region
64  real*8 xx, f, xb
65 
66 c fitting at region
67  do region=1, nregion
68 c for hadron fitting is done only at region2
69  if(code .eq. 2 .and. region .eq. 1) cycle
70  n1 =0
71  do i = 1, nbin
72  if(xin(i) .gt. x2(region) ) exit
73  if(xin(i) .lt. x1(region) ) cycle
74  if(code .eq. 2 .and. xin(i) .lt. x1h ) cycle
75  n1 = n1 +1
76  xuse(n1) = xin(i)
77  yuse(n1) = yin(i)
78  enddo
79 c////////////
80 c write(0,*) ' region=',region, ' points=', n1
81 c write(0,*) ' param(1,region)=', param(1, region)
82 c write(0,*) ' param(2,region)=', param(2, region)
83 c write(0,*) ' param(3,region)=', param(3, region)
84 c//////////
85 c region, x, y, #, output param
86  call fittime1(region, code, xuse, yuse, n1, param(1, region),
87  * prmout(1, region))
88 
89  if(cond .eq. 1) then
90 c only coeff. is put on stdout
91  write(*,'(3g12.4)') prmout(1, region), prmout(2, region),
92  * prmout(3, region)
93  if(code .eq. 2) then
94 c for hadron, region 1 is mssing so we repeat region 2 data
95  write(*,'(3g12.4)')
96  * prmout(1, region), prmout(2, region), prmout(3, region)
97  endif
98  else
99 c coeff is put on stderr
100  write(0,'(3g12.4)') prmout(1, region), prmout(2, region),
101  * prmout(3, region)
102  endif
103  if(cond .eq. 0) then
104 c to see fitted result (r, t) is put on stdout
105  xx = drx1( region)
106  do while ( xx .le. drx2(region) )
107  f=prmout(1,region)*xx**(prmout(2,region) +
108  * prmout(3,region)*log(xx))
109  write(*,*) xx, f
110  xx = xx*10.0**0.02
111  enddo
112  endif
113  enddo
114  end
115 c ***************************************************
116  subroutine fittime1(region, code, xin, yin, n, prmin, prmout )
117  implicit none
118  include "Zfit.h"
119  integer region, code
120  real*8 prmin(nparam), prmout(nparam)
121  integer n
122  real*8 xin(n), yin(n)
123 
124  integer nlabel(nparam)
125  character*10 pname(nparam)
126  real*8 initval(nparam)
127  real*8 step(nparam)
128 
129  data nlabel/ 1, 2, 3/
130  data pname/ 'p', 'q', 'r'/
131  data step/ 1., 0.001d0, 0.0001d0/
132  real*8 zero, one, three, four, five
133  data zero,one,three,four, five / 0., 1., 3.,4., 5. /
134  real*8 fval, xx
135  integer i, ierflg
136 
137  external timefnc
138 
139 c
140 c in fortran mode, this must be called for a new fnc
141 c
142  npoint = n
143  do i = 1, npoint
144  x(i) = xin(i)
145  y(i) = yin(i)
146  enddo
147 
148  do i = 1, nparam
149  initval(i) = prmin(i)
150  enddo
151 
152  call mninit( 5, minout, minsave)
153 
154  do i= 1, nparam
155 c nprm: a number given to a parameter: (label)
156 c pnam: name of the parameer
157 c vstrt: initial value of the parameter
158 c stp: initial step size of the //
159 c next two: zero-->the parameter is not bounded (lower or upper)
160 c ierflg: retrun value; cond code. 0--> ok
161 
162  call mnparm(nlabel(i), pname(i), initval(i), step(i),
163  * low(i, code), up(i, code), ierflg)
164 
165  if (ierflg .ne. 0) then
166  write (0,'(a,i3)') ' unable to define parameter no.',i
167  stop
168  endif
169  enddo
170 c
171  call mnseti('tf as a function of core distance')
172 c request fcn to read in (or generate random) data (iflag=1)
173 c fcnk0: function to be minimuzed is calculated. also
174 c there are other funcitons
175 c one is the argument to fcnk0. seems to be converted to
176 c integer inside.
177 c 1 number of argument in one (one could be array)
178 c ierflf: ouptut. 0-->ok
179 c 0: no external function is used in fcnk0
180 
181  call mnexcm(timefnc, 'call fcn', one ,1,ierflg, 0)
182 c fix the 3,4,5-th parameters,
183 c call mnexcm(timefnc,'fix', fixlist ,3, ierflg,0)
184 c print minumum things
185  call mnexcm(timefnc,'set print', zero ,1,ierflg,0)
186 c use migrad method for minimization
187 c with default condtions
188  call mnexcm(timefnc,'migrad', zero ,0,ierflg,0)
189 c analysis of errors for all parameters
190  call mnexcm(timefnc,'minos', zero ,0,ierflg,0)
191 c 5th parameter is now set to a variable parameter
192 c call mnexcm(timefnc,'release', five ,1,ierflg,0)
193 c release 3,4
194 c call mnexcm(timefnc,'release', fixlist ,2,ierflg,0)
195 c
196 c and use migrad again
197 c call mnexcm(timefnc,'migrad', zero ,0,ierflg,0)
198 c error analysis
199 c call mnexcm(timefnc,'minos', zero ,0,ierflg,0)
200 c
201 c
202 c call mnexcm(timefnc,'migrad', zero ,0,ierflg,0)
203 c error analysis
204 c call mnexcm(timefnc,'minos', zero ,0,ierflg,0)
205 c
206 c call fcn with 3. i.e, ouput etc.
207  call mnexcm(timefnc,'call fcn', three , 1,ierflg, 0)
208 
209  do i = 1, nparam
210  prmout(i) = oparam(i)
211  enddo
212 
213  end
program timefit
Definition: timeFit.f:3
block data include Zlatfit h c fitting region data x1(1)/0.03/
block data include Zlatfit h c fitting region data data data data data d0 data data d0 data data h g *is for param c g data up(2, 1)/7.0d0/
subroutine mnexcm(FCN, COMAND, PLIST, LLIST, IERFLG, FUTIL)
Definition: mnexcm.f:25
subroutine mnseti(TIT)
Definition: mnseti.f:10
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 copenfw2(io, fnin, form, icon)
Definition: copenf.f:205
integer maxbin nregion c minsave drx2 ! drawing region real maxdep integer maxpos integer op real x1h common Zfitc * param
Definition: Zfit.h:15
integer maxbin nregion c minsave drx2 ! drawing region real maxdep integer maxpos integer op real x1h common Zfitc drx1
Definition: Zfit.h:15
block data include Zlatfit h c fitting region data data data data data d0 data data d0 data data h g *is for param c g data low(1, 1)/1.d-5/
block data cblkEvhnp ! currently usable models data RegMdls ad *special data *Cekaon d0
Definition: cblkEvhnp.h:5
integer maxbin nregion c minsave drx2 ! drawing region real maxdep integer maxpos integer npoint
Definition: Zfit.h:15
integer maxbin nregion c minsave drx2 ! drawing region real maxdep integer maxpos integer op real x1h common Zfitc x1h
Definition: Zfit.h:15
latitude latitude this system is used *****************************************************************! type coord sequence union map real y
Definition: Zcoord.h:25
subroutine mnparm(K, CNAMJ, UK, WK, A, B, IERFLG)
Definition: mnparm.f:25
subroutine timefnc(npar, gin, f, paramx, iflag)
Definition: timefnc.f:2
block data include Zlatfit h c fitting region data x2(1)/0.5/data x1(2)/0.3/
subroutine mninit(I1, I2, I3)
Definition: mninit.f:34
integer maxbin nregion c minsave drx2 ! drawing region real maxdep integer maxpos integer op real x1h common Zfitc * oparam
Definition: Zfit.h:15
integer maxbin nregion c minsave drx2 ! drawing region real maxdep integer maxpos integer op real x1h common Zfitc drx2
Definition: Zfit.h:15
subroutine fittime1(region, code, xin, yin, n, prmin, prmout)
Definition: timeFit.f:117
! structure defining a particle at production ! Basic idea of what is to be contained in ! the particle structue is that dynamical ones should be included those derivable from the particle code ! is not included ******************************************************type fmom momentum sequence union map real e endmap map real * x
Definition: Zptcl.h:21
subroutine fittime0(cond, code, xin, yin, nbin)
Definition: timeFit.f:54