source: trunk/MagicSoft/Simulation/Corsika/Mmcs/jadach.f@ 5059

Last change on this file since 5059 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: 5.0 KB
Line 
1 SUBROUTINE JADACH( ECMJAD,JADFLG )
2
3C-----------------------------------------------------------------------
4C JADACH (FILTER)
5C
6C ADJUSTS THE RAPIDITIES OF ALL SECONDARIES SUCH THAT
7C ENERGY AND LONGITUDINAL MOMENTUM ARE CONSERVED AT THE SAME TIME
8C THE ALGORITHM IS TAKEN FROM S.JADACH, COM.PHYS.COMM. 9 (1975) 297
9C THE ROUTINE MUST BE CALLED AFTER THE PT IS CONSERVED AND BEFORE
10C THE TRANSFORMATION TO THE LAB SYSTEM IS DONE
11C THIS SUBROUTINE IS CALLED FROM HDPM
12C ARGUMENTS:
13C ECMJAD = CM ENERGY IN THE PROJECTILE -- GNU*NUCLEONS SYSTEM
14C JADFLG = 0 JADACH FILTER CORRECTLY ENDED
15C = 1 BAD RAPIDITIES, SELECT RAPIDITIES AGAIN
16C =-1 SUM OF TRANSVERSE MASSES EXCEEDS AVAILABLE CM ENERGY
17C-----------------------------------------------------------------------
18
19 IMPLICIT DOUBLE PRECISION (A-H,O-Z)
20*KEEP,INTER.
21 COMMON /INTER/ AVCH,AVCH3,DC0,DLOG,DMLOG,ECMDIF,ECMDPM,ELAB,
22 * FNEUT,FNEUT2,GNU,PLAB,POSC2,POSC3,POSN2,POSN3,
23 * RC3TO2,S,SEUGF,SEUGP,SLOG,SLOGSQ,SMLOG,
24 * WIDC2,WIDC3,WIDN2,WIDN3,YCM,YY0,ZN,
25 * IDIF,ITAR
26 DOUBLE PRECISION AVCH,AVCH3,DC0,DLOG,DMLOG,ECMDIF,ECMDPM,ELAB,
27 * FNEUT,FNEUT2,GNU,PLAB,POSC2,POSC3,POSN2,POSN3,
28 * RC3TO2,S,SEUGF,SEUGP,SLOG,SLOGSQ,SMLOG,
29 * WIDC2,WIDC3,WIDN2,WIDN3,YCM,YY0,ZN
30 INTEGER IDIF,ITAR
31*KEEP,NEWPAR.
32 COMMON /NEWPAR/ EA,PT2,PX,PY,TMAS,YR,ITYP,
33 * IA1,IA2,IB1,IB2,IC1,IC2,ID1,ID2,IE1,IE2,IF1,IF2,
34 * IG1,IG2,IH1,IH2,II1,II2,IJ1,NTOT
35 DOUBLE PRECISION EA(3000),PT2(3000),PX(3000),PY(3000),TMAS(3000),
36 * YR(3000)
37 INTEGER ITYP(3000),
38 * IA1,IA2,IB1,IB2,IC1,IC2,ID1,ID2,IE1,IE2,IF1,IF2,
39 * IG1,IG2,IH1,IH2,II1,II2,IJ1,NTOT
40*KEEP,PAM.
41 COMMON /PAM/ PAMA,SIGNUM
42 DOUBLE PRECISION PAMA(6000),SIGNUM(6000)
43*KEEP,RUNPAR.
44 COMMON /RUNPAR/ FIXHEI,THICK0,HILOECM,HILOELB,
45 * STEPFC,NRRUN,NSHOW,PATAPE,MONIIN,
46 * MONIOU,MDEBUG,NUCNUC,
47 * CETAPE,
48 * SHOWNO,ISHW,NOPART,NRECS,NBLKS,MAXPRT,NDEBDL,
49 * N1STTR,MDBASE,
50 * DEBDEL,DEBUG,FDECAY,FEGS,FIRSTI,FIXINC,FIXTAR,
51 * FIX1I,FMUADD,FNKG,FPRINT,FDBASE
52 * ,GHEISH,GHESIG
53 COMMON /RUNPAC/ DSN,HOST,USER
54 DOUBLE PRECISION FIXHEI,THICK0,HILOECM,HILOELB
55 REAL STEPFC
56 INTEGER NRRUN,NSHOW,PATAPE,MONIIN,MONIOU,MDEBUG,NUCNUC,
57 * SHOWNO,ISHW,NOPART,NRECS,NBLKS,MAXPRT,NDEBDL,
58 * N1STTR,MDBASE
59 INTEGER CETAPE
60 CHARACTER*79 DSN
61 CHARACTER*20 HOST,USER
62
63 LOGICAL DEBDEL,DEBUG,FDECAY,FEGS,FIRSTI,FIXINC,FIXTAR,
64 * FIX1I,FMUADD,FNKG,FPRINT,FDBASE
65 * ,GHEISH,GHESIG
66*KEND.
67
68 DIMENSION YRJAD(3000)
69 DATA EPS / 1.D-7 /
70C-----------------------------------------------------------------------
71
72 IF ( DEBUG ) WRITE(MDEBUG,*) 'JADACH: NTOT=',NTOT
73
74 JADFLG = 0
75
76C SUM UP TRANSVERSE MOMENTA AND COMPARE WITH AVAILABLE C.M.ENERGY
77 STMAS = 0.D0
78 ECMI = 1.D0 / ECMJAD
79 DO 4 I = 1,NTOT
80 STMAS = STMAS + TMAS(I)
81 YRJAD(I) = YR(I)
82 4 CONTINUE
83 REST = ( ECMJAD - STMAS ) * ECMI
84 IF ( REST .LE. 0.D0 ) THEN
85C SUMMED TRANSVERSE MASS > AVAILABLE C.M. ENERGY
86 JADFLG = -1
87 RETURN
88 ENDIF
89 FACT = 1.5D0 / REST
90 AA = 1.D0
91 DIFOLD = 0.D0
92 ICOUNT = 0
93C OPTIMIZATION LOOP TO DEFINE PARAMETER AA
94 1 CONTINUE
95 ICOUNT = ICOUNT + 1
96 IF ( ICOUNT .GE. 50 ) GOTO 999
97C FORM SUMS S1 AND S2
98 S1 = 0.D0
99 S2 = 0.D0
100 DO 5 I = 1,NTOT
101 EXPO = EXP( AA * YR(I) )
102 S1 = S1 + TMAS(I) * ECMI * EXPO
103 S2 = S2 + TMAS(I) * ECMI / EXPO
104 5 CONTINUE
105 DIFF = 0.1D0 * LOG(S1*S2)
106C ACCELERATING OF CONVERGENCE IF NO CHANGE OF SIGN IN DIFF
107 IF ( DIFOLD*DIFF .GE. 0.D0 ) DIFF = DIFF * FACT
108 DIFOLD = DIFF
109 IF ( DEBUG ) WRITE(MDEBUG,*) ' DIFF=',SNGL(DIFF)
110 AA = AA * MAX( 0.1D0, (1.D0 - DIFF) )
111 IF ( ABS(DIFF) .GT. EPS ) GOTO 1
112
113C ITERATION HAS CONVERGED, CALCULATE PARAMETER BB
114 BB = 0.5D0 * LOG(S2/S1)
115
116 IF ( DEBUG ) WRITE (MDEBUG,110) ICOUNT,STMAS,REST
117 110 FORMAT(' ICOUNT, STMAS, REST = ',I5,2E13.5,/
118 * ' NUM ITYP TMAS YR(OLD) YR(NEW)')
119C CORRECT RAPIDITIES
120 DO 10 I = 1,NTOT
121 YR(I) = AA * YR(I) + BB
122 IF ( DEBUG ) WRITE(MDEBUG,111) I,ITYP(I),TMAS(I),YRJAD(I),YR(I)
123 111 FORMAT(' ',I4,I6,F12.5,2F16.8)
124C IMPOSSIBLE RAPIDITY, DETERMINE AGAIN THE RAPIDITIES
125 IF ( ABS(YR(I)) .GT. LOG(ECMJAD/PAMA(ITYP(I))) ) GOTO 999
126 10 CONTINUE
127 RETURN
128
129
130C ERROR EXIT
131 999 JADFLG = 1
132C NO CONVERGENCE AFTER 50 ITERATIONS OR IMPOSSIBLE RAPIDITY
133 RETURN
134
135 END
Note: See TracBrowser for help on using the repository browser.