COSMOS v7.655  COSMOSv7655
(AirShowerMC)
tranfnc.f
Go to the documentation of this file.
1  subroutine tranfnc(npar,gin,f,paramx,iflag)
2  implicit none
3  include "Zfit.h"
4 * npar: input. number of current variable parameters
5 * gin: optional output of gradient
6 * f: output. function value to be minimized
7 * paramx: input. vector of const and variable parameters
8 * iflag: input. depending on this value, what to do
9 * is determined.
10 * 1--> some preparation for computing f
11 * 2--> compute gin
12 * 3--> fittng finished
13 * for all other cases: we must compute f
14 *
15  integer npar
16  real*8 gin(*)
17  real*8 f
18  real*8 paramx(*)
19  integer iflag
20 c
21  integer i
22  real*8 fval, xx
23  real*8 a, b, c, d, z, x0
24  save
25  if (iflag .eq. 1) then
26 c write(0,*) 'current npar=',npar, ' npoint=',npoint
27 c write(0,*) ' param=',(paramx(i), i=1,npar)
28  endif
29  if(iflag .eq. 2 ) then
30  write(0,*) ' no grad computed'
31  stop
32  endif
33 c compute f
34 
35  chisq = 0.
36 c f(x)= a*(x/x0)**b * exp(-c*(x/x0)**d)
37 c z = x/x0
38 c f'(z) = ab z**(b-1)* exp(-c*z**d) - acdz**b*exp(-cz**d)*z**(d-1)
39 c =0
40 c --> b - cdz**d=0 ; z=(b/cd)**(1./d);
41 c x = x0 (b/cd)**(1./d)
42 c ccc not used: if we use x0=max pos. cd=b
43 c ccc fmax = a*exp(-c)
44 
45  do i= 1, npoint
46  x0 = paramx(2)
47  z = x(i)/x0
48  a = paramx(1)
49  b = paramx(3)
50  c = paramx(4)
51  d = paramx(5)
52  fval = a*z**b*exp(-c*z**d)
53 c chisq= chisq + (fval-y(i))**2
54 c if(y(i) .lt. 3.) then
55 c chisq= chisq + ( fval/y(i) - 1.0 )**2
56 c else
57 c chisq= chisq + ( y(i)/fval - 1.0 )**2
58 c chisq= chisq + ( fval/y(i) - 1.0 )**2
59  chisq= chisq + (fval-y(i))**2/y(i)
60 c endif
61  enddo
62  f = chisq
63 
64  if(iflag .eq. 3) then
65 c do i = 1, npoint
66 c fval = paramx(1)*x(i)**(paramx(2) +
67 c write(*,*) x(i), y(i), fval
68 c enddo
69  do i = 1, npar
70  oparam(i) = paramx(i)
71  enddo
72  endif
73  end
integer maxbin nregion c minsave drx2 ! drawing region real maxdep integer maxpos integer op real * chisq
Definition: Zfit.h:15
integer maxbin nregion c minsave drx2 ! drawing region real maxdep integer maxpos integer npoint
Definition: Zfit.h:15
latitude latitude this system is used *****************************************************************! type coord sequence union map real y
Definition: Zcoord.h:25
subroutine tranfnc(npar, gin, f, paramx, iflag)
Definition: tranfnc.f:2
integer maxbin nregion c minsave drx2 ! drawing region real maxdep integer maxpos integer op real x1h common Zfitc * oparam
Definition: Zfit.h:15
! 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