source: trunk/MagicSoft/Simulation/Corsika/Mmcs/chisq.f@ 6525

Last change on this file since 6525 was 286, checked in by harald, 25 years ago
This is the start point for further developments of the Magic Monte Carlo Simulation written by Jose Carlos Gonzales. Now it is under control of one CVS repository for the whole collaboration. Everyone should use this CVS repository for further developments.
File size: 2.9 KB
Line 
1 DOUBLE PRECISION FUNCTION CHISQ(F)
2
3C-----------------------------------------------------------------------
4C CHI SQ(UARE)
5C
6C THIS FUNCTION CALCULATES THE CHI**2 OBTAINED WITH THE FITFUNCTION
7C AMOEBA USING THE PARAMETER SET F
8C F(1) = HEIGHT AT MAXIMUM
9C F(2) = SHOWER STARTING POINT
10C F(3) = T AT MAXIMUM
11C F(4) = WIDTH PARAMETER 1
12C F(5) = WIDTH PARAMETER 2 T
13C F(6) = WIDTH PARAMETER 3 T**2
14C THIS FUNCTION IS CALLED FROM LONGFT AND FROM AMOEBA
15C-----------------------------------------------------------------------
16
17 IMPLICIT NONE
18*KEEP,CURVE.
19 COMMON /CURVE/ CHAPAR,DEP,ERR,NSTP
20 DOUBLE PRECISION CHAPAR(1100),DEP(1100),ERR(1100)
21 INTEGER NSTP
22*KEEP,RUNPAR.
23 COMMON /RUNPAR/ FIXHEI,THICK0,HILOECM,HILOELB,
24 * STEPFC,NRRUN,NSHOW,PATAPE,MONIIN,
25 * MONIOU,MDEBUG,NUCNUC,
26 * CETAPE,
27 * SHOWNO,ISHW,NOPART,NRECS,NBLKS,MAXPRT,NDEBDL,
28 * N1STTR,MDBASE,
29 * DEBDEL,DEBUG,FDECAY,FEGS,FIRSTI,FIXINC,FIXTAR,
30 * FIX1I,FMUADD,FNKG,FPRINT,FDBASE
31 * ,GHEISH,GHESIG
32 COMMON /RUNPAC/ DSN,HOST,USER
33 DOUBLE PRECISION FIXHEI,THICK0,HILOECM,HILOELB
34 REAL STEPFC
35 INTEGER NRRUN,NSHOW,PATAPE,MONIIN,MONIOU,MDEBUG,NUCNUC,
36 * SHOWNO,ISHW,NOPART,NRECS,NBLKS,MAXPRT,NDEBDL,
37 * N1STTR,MDBASE
38 INTEGER CETAPE
39 CHARACTER*79 DSN
40 CHARACTER*20 HOST,USER
41
42 LOGICAL DEBDEL,DEBUG,FDECAY,FEGS,FIRSTI,FIXINC,FIXTAR,
43 * FIX1I,FMUADD,FNKG,FPRINT,FDBASE
44 * ,GHEISH,GHESIG
45*KEND.
46
47 DOUBLE PRECISION AUXIL,BALL,BASE,EXPO,F(6),T
48 INTEGER I
49C-----------------------------------------------------------------------
50
51 IF ( DEBUG ) WRITE(MDEBUG,*) 'CHISQ : PARAMETERS =',F
52
53C EXCLUDE PATHOLOGICAL PARAMETER SETTINGS
54 IF ( F(1) .LE. 0.D0 .OR. F(2) .GE. F(3) .OR.
55 * (F(4).EQ.0.D0 .AND. F(5).EQ.0.D0 .AND. F(6).EQ.0.D0) ) THEN
56 CHISQ = 1.D16
57 RETURN
58 ENDIF
59
60 CHISQ = 0.D0
61C LOOP OVER THE LONGITUDINAL DISTRIBUTION
62 DO 1 I=1,NSTP
63 T = DEP(I)
64 IF ( T .GT. F(2) ) THEN
65 BASE = (T-F(2)) / (F(3)-F(2))
66 AUXIL = F(4) + T*F(5) + T**2*F(6)
67 IF ( AUXIL .LT. 1.D-20 ) THEN
68 CHISQ = CHISQ + 1.D16
69 GOTO 1
70 ENDIF
71 EXPO = (F(3)-T) / AUXIL
72CC IF(DEBUG)WRITE(MDEBUG,*)'CHISQ : I,BASE,EXPO=',I,
73CC * SNGL(BASE),SNGL(EXPO)
74 BALL = F(1) * BASE ** EXPO
75 ELSE
76 BALL = 0.D0
77 ENDIF
78 CHISQ = CHISQ + ((BALL-CHAPAR(I))/ERR(I))**2
79 1 CONTINUE
80 CHISQ = CHISQ / (NSTP-6)
81
82 IF ( DEBUG ) WRITE(MDEBUG,*) 'CHISQ : CHI**2 =',SNGL(CHISQ)
83
84 RETURN
85 END
Note: See TracBrowser for help on using the repository browser.