1 | SUBROUTINE LONGFT(FPARAM,CHI2)
|
---|
2 |
|
---|
3 | C-----------------------------------------------------------------------
|
---|
4 | C LONG(ITUDINAL) F(I)T
|
---|
5 | C
|
---|
6 | C THIS ROUTINE PERFORMS A FIT TO THE LONGITUDINAL DISTRIBUTION OF AN
|
---|
7 | C AIR SHOWER. DUE TO THE LARGE PARTICLE NUMBERS IN AN AIR SHOWER THE
|
---|
8 | C STATISTICAL ERRORS ON THE PARTICLE NUMBER AT A GIVEN LEVEL ARE
|
---|
9 | C MINUTE. THIS LEADS TO RATHER LARGE CHI**2/DOF FOR THE FITS EVEN IF
|
---|
10 | C THE FITTED FUNCTION MATCHES THE POINTS BETTER THAN SAY 1%.
|
---|
11 | C KEEP IN MIND THAT FITTING IS A DIFFICULT TASK AND THE RESULTS DO NOT
|
---|
12 | C NECESSARILY REPRESENT THE ABOLUTE MINIMUM OR EVEN A GOOD
|
---|
13 | C APPROXIMATION.
|
---|
14 | C
|
---|
15 | C TRY A 6 PARAMETER FIT BASED ON J. BALL'S PROPOSED CURVE REPLACING HIS
|
---|
16 | C CONSTANT WIDTH PARAMETER LAMBDA BY A POLYNOMIAL OF 3. DEGREE.
|
---|
17 | C N(T) = NMAX * ((T-T0)/(TMAX-T0))**((TMAX-T)/(P1+P2*T+P3*T**2))
|
---|
18 | C T = DEPTH IN G/CM**2
|
---|
19 | C T0 = STARTING DEPTH OF SHOWER
|
---|
20 | C TMAX = DEPTH OF SHOWER MAXIMUM
|
---|
21 | C NMAX = PARTICLE NUMBER AT TMAX
|
---|
22 | C P1 .. P3 = PARAMETERS OF A POLYNOMIAL DESCRIBING THE WIDTH
|
---|
23 | C
|
---|
24 | C THIS SUBROUTINE IS CALLED FROM MAIN
|
---|
25 | C-----------------------------------------------------------------------
|
---|
26 |
|
---|
27 | IMPLICIT NONE
|
---|
28 | *KEEP,CURVE.
|
---|
29 | COMMON /CURVE/ CHAPAR,DEP,ERR,NSTP
|
---|
30 | DOUBLE PRECISION CHAPAR(1100),DEP(1100),ERR(1100)
|
---|
31 | INTEGER NSTP
|
---|
32 | *KEEP,RUNPAR.
|
---|
33 | COMMON /RUNPAR/ FIXHEI,THICK0,HILOECM,HILOELB,
|
---|
34 | * STEPFC,NRRUN,NSHOW,PATAPE,MONIIN,
|
---|
35 | * MONIOU,MDEBUG,NUCNUC,
|
---|
36 | * CETAPE,
|
---|
37 | * SHOWNO,ISHW,NOPART,NRECS,NBLKS,MAXPRT,NDEBDL,
|
---|
38 | * N1STTR,MDBASE,
|
---|
39 | * DEBDEL,DEBUG,FDECAY,FEGS,FIRSTI,FIXINC,FIXTAR,
|
---|
40 | * FIX1I,FMUADD,FNKG,FPRINT,FDBASE
|
---|
41 | * ,GHEISH,GHESIG
|
---|
42 | COMMON /RUNPAC/ DSN,HOST,USER
|
---|
43 | DOUBLE PRECISION FIXHEI,THICK0,HILOECM,HILOELB
|
---|
44 | REAL STEPFC
|
---|
45 | INTEGER NRRUN,NSHOW,PATAPE,MONIIN,MONIOU,MDEBUG,NUCNUC,
|
---|
46 | * SHOWNO,ISHW,NOPART,NRECS,NBLKS,MAXPRT,NDEBDL,
|
---|
47 | * N1STTR,MDBASE
|
---|
48 | INTEGER CETAPE
|
---|
49 | CHARACTER*79 DSN
|
---|
50 | CHARACTER*20 HOST,USER
|
---|
51 |
|
---|
52 | LOGICAL DEBDEL,DEBUG,FDECAY,FEGS,FIRSTI,FIXINC,FIXTAR,
|
---|
53 | * FIX1I,FMUADD,FNKG,FPRINT,FDBASE
|
---|
54 | * ,GHEISH,GHESIG
|
---|
55 | *KEND.
|
---|
56 |
|
---|
57 | INTEGER NPAR
|
---|
58 | PARAMETER (NPAR=6)
|
---|
59 | DOUBLE PRECISION F(NPAR),FPARAM(NPAR),CHI2,CHISQ
|
---|
60 | DOUBLE PRECISION P(NPAR+1,NPAR),Y(NPAR+1),EPS
|
---|
61 | DOUBLE PRECISION T0,TMAX,NMAX,FAC
|
---|
62 | INTEGER I,J,JJ,K,ITER,IFLAG
|
---|
63 | EXTERNAL CHISQ
|
---|
64 | C-----------------------------------------------------------------------
|
---|
65 |
|
---|
66 | IF ( DEBUG ) WRITE(MDEBUG,*) 'LONGFT:'
|
---|
67 |
|
---|
68 | C FIND GOOD START VALUES FOR XMAX AND FMAX
|
---|
69 | NMAX = 0.D0
|
---|
70 | DO 2 I = 1,NSTP
|
---|
71 | ERR(I) = MAX( 1.D0, SQRT(CHAPAR(I)) )
|
---|
72 | IF ( CHAPAR(I) .GT. NMAX ) THEN
|
---|
73 | NMAX = CHAPAR(I)
|
---|
74 | TMAX = DEP(I)
|
---|
75 | ENDIF
|
---|
76 | 2 CONTINUE
|
---|
77 | C STARTVALUE FOR X0 IS ABOUT WHERE MORE THAN 1 PARTICLE SHOWS UP
|
---|
78 | DO 3 I = 1,NSTP
|
---|
79 | IF ( CHAPAR(I) .GT. 1.D0 ) GOTO 1
|
---|
80 | 3 CONTINUE
|
---|
81 | I = NSTP
|
---|
82 | 1 CONTINUE
|
---|
83 | T0 = DEP(I)
|
---|
84 |
|
---|
85 | C-----------------------------------------------------------------------
|
---|
86 | C FIT IS PERFORMED WITH THE ROUTINE AMOEBA FROM:
|
---|
87 | C NUMERICAL RECIPES, W.H. PRESS ET AL.,
|
---|
88 | C CAMBRIDGE UNIVERSITY PRESS, 1992 ISBN 0 521 43064 X
|
---|
89 | C SEE THERE HOW IT HAS TO BE USED.
|
---|
90 |
|
---|
91 | C CREATE A SET OF NPAR+1 STARTING VERTICES
|
---|
92 | C HERE IS THE FIRST ONE
|
---|
93 | P(1,1) = NMAX
|
---|
94 | P(1,2) = T0
|
---|
95 | P(1,3) = TMAX
|
---|
96 | P(1,4) = 200.D0
|
---|
97 | P(1,5) = 1.D-1
|
---|
98 | P(1,6) = 1.D-1
|
---|
99 |
|
---|
100 | C LOOP OVER THE FITTING ROUTINE (2 TIMES 5 FITS WITH VARYING PRECISION)
|
---|
101 | DO 10 J = 1,2
|
---|
102 | DO 9 JJ = 1,5
|
---|
103 | C START WITH CRUDE PRECISION AND IMPROVE STEP BY STEP
|
---|
104 | C AFTER FIVE STEPS ENLARGE AGAIN
|
---|
105 | EPS = 10.D0**(-3.D0-JJ*0.5D0)
|
---|
106 | FAC = 1.D0 + 2.D0**(2.1D0*(1.D0-JJ))
|
---|
107 | C GO AS WELL IN DIFFERENT DIRECTIONS
|
---|
108 | IF ( J .EQ. 2 ) FAC = 1.D0/FAC
|
---|
109 |
|
---|
110 | C GET OTHER NPAR STARTING VERTICES FROM THE STARTING POINT BY VARIATION
|
---|
111 | C OF ONLY ONE OF THE COORDINATE VALUES
|
---|
112 | DO 5 I = 2,NPAR+1
|
---|
113 | DO 4 K = 1,NPAR
|
---|
114 | P(I,K) = P(1,K)
|
---|
115 | 4 CONTINUE
|
---|
116 | IF ( P(I,I-1) .EQ. 0.D0 ) THEN
|
---|
117 | P(I,I-1) = 1.D0
|
---|
118 | ELSE
|
---|
119 | P(I,I-1) = P(I,I-1) * FAC
|
---|
120 | ENDIF
|
---|
121 | 5 CONTINUE
|
---|
122 | IF (DEBUG) WRITE(MDEBUG,*) 'LONGFT: TRIAL,FAC,EPS ',J,
|
---|
123 | * SNGL(FAC),SNGL(EPS)
|
---|
124 |
|
---|
125 | C CALCULATE FUNCTION VALUES AT THE START VERTICES
|
---|
126 | DO 7 I = 1,NPAR+1
|
---|
127 | DO 6 K = 1,NPAR
|
---|
128 | F(K) = P(I,K)
|
---|
129 | 6 CONTINUE
|
---|
130 | Y(I) = CHISQ(F)
|
---|
131 | 7 CONTINUE
|
---|
132 | C PERFORM A FIT
|
---|
133 | CALL AMOEBA(P,Y,NPAR+1,NPAR,NPAR,EPS,CHISQ,ITER,IFLAG)
|
---|
134 | IF ( DEBUG ) THEN
|
---|
135 | WRITE(MDEBUG,*) 'LONGFT: ITER/IFLAG=',ITER,IFLAG
|
---|
136 | WRITE(MDEBUG,*) 'LONGFT: PARAMETERS=',1,(P(1,K),K=1,6)
|
---|
137 | WRITE(MDEBUG,*) 'LONGFT: CHISQ =',SNGL(Y(1))
|
---|
138 | ENDIF
|
---|
139 |
|
---|
140 | C STORE VALUES AT FIRST TRIAL OR AT IMPROVED RESULT
|
---|
141 | IF ( J .EQ. 1 .OR. Y(1) .LT. CHI2 ) THEN
|
---|
142 | DO 8 I = 1,NPAR
|
---|
143 | FPARAM(I) = P(1,I)
|
---|
144 | 8 CONTINUE
|
---|
145 | CHI2 = Y(1)
|
---|
146 | ENDIF
|
---|
147 | C END OF LOOPS OVER THE FITTING ROUTINE
|
---|
148 | 9 CONTINUE
|
---|
149 | 10 CONTINUE
|
---|
150 |
|
---|
151 | RETURN
|
---|
152 | END
|
---|