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. kaisq
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 !
21  integer i
22  real*8 ff, xx
23  real*8 a, s, x0
24  save
25  if (iflag .eq. 1) then
26 ! write(0,*) 'current npar=',npar, ' npoint=',npoint
27 ! 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 ! compute f
34 
35  chisq = 0.
36 ! f(x)= a*(x/x0)**b * exp(-c*(x/x0)**d)
37 ! z = x/x0
38 ! f'(z) = ab z**(b-1)* exp(-c*z**d) - acdz**b*exp(-cz**d)*z**(d-1)
39 ! =0
40 ! --> b - cdz**d=0 ; z=(b/cd)**(1./d);
41 ! x = x0 (b/cd)**(1./d)
42 ! ccc not used: if we use x0=max pos. cd=b
43 ! ccc fmax = a*exp(-c)
44 
45  do i= 1, npoint
46  a = paramx(1)
47  s = paramx(2)
48  x0 = paramx(3)
49  ff = a*exp(-((x(i)-x0)/s)**2/2.)
50 ! chisq= chisq + (ff-y(i))**2
51 ! if(y(i) .lt. 3.) then
52 ! chisq= chisq + ( ff/y(i) - 1.0 )**2
53 ! else
54 ! chisq= chisq + ( y(i)/ff - 1.0 )**2
55 ! chisq= chisq + ( ff/y(i) - 1.0 )**2
56  chisq= chisq + (ff-y(i))**2/y(i)
57 
58 ! endif
59  enddo
60  f = chisq
61 
62  if(iflag .eq. 3) then
63 ! do i = 1, npoint
64 ! ff = paramx(1)*x(i)**(paramx(2) +
65 ! write(*,*) x(i), y(i), ff
66 ! enddo
67  do i = 1, npar
68  oparam(i) = paramx(i)
69  enddo
70  endif
71  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