This commit was generated by cvs2svn to compensate for changes in r2,
[u/mrichter/AliRoot.git] / GEANT321 / gphys / gmols.F
1 *
2 * $Id$
3 *
4 * $Log$
5 * Revision 1.1.1.1  1995/10/24 10:21:27  cernlib
6 * Geant
7 *
8 *
9 #include "geant321/pilot.h"
10 #if defined(CERNLIB_VER314)
11 *CMZ :  3.21/02 29/03/94  15.41.22  by  S.Giani
12 *-- Author :
13       SUBROUTINE GMOLS (OMEGA,CHIC,COSTH,SINTH)
14 C.
15 C.    ******************************************************************
16 C.    *                                                                *
17 C.    *  Generation of multiple scattering according to                *
18 C.    *  Moliere theory corrected for finite angle scattering          *
19 C.    *                                                                *
20 C.    *  evolved from Cern library program MLR                         *
21 C.    *                                                                *
22 C.    *  OMEGA & CHIC are number of scatterings and critical angle     *
23 C.    *  of the medium for a given incident particle                   *
24 C.    *                                                                *
25 C.    *  COSTH and SINTH are the cosine and sine of the generated      *
26 C.    *  scattering angle between 0 and 180 degrees                    *
27 C.    *                                                                *
28 C.    * THRED(NA)=reduced angles of Moliere theory                     *
29 C.    *                                                                *
30 C.    * F0I(NA),F1I(NA),F2I(NA)= integrale of Moliere functions        *
31 C.    *                                                                *
32 C.    *  4 point continued fraction interpolation is used to invert    *
33 C.    *  the total distribution function integral                      *
34 C.    *                                                                *
35 C.    * XINT= argument value                                           *
36 C.    * ARG= argument values of the table (arg,val)                    *
37 C.    * VAL= function values of the table (arg,val)                    *
38 C.    * THRI= the resulting interpolated function value                *
39 C.    *                                                                *
40 C.    *    ==>Called by : GMOLIE                                       *
41 C.    *         Author M.S. Dixit NRCC Ottawa    *********             *
42 C.    *                                                                *
43 C.    ******************************************************************
44 C.
45       DIMENSION TINT(40),ARG(4),VAL(4),THRED(40),F0I(40),F1I(40),F2I(40)
46       DIMENSION RNDM(1)
47       SAVE TINT
48       DATA TINT(1)/0./
49       DATA THRED/
50      *   0.00, 0.10, 0.20, 0.30
51      *,  0.40, 0.50, 0.60, 0.70
52      *,  0.80, 0.90, 1.00, 1.10
53      *,  1.20, 1.30, 1.40, 1.50
54      *,  1.60, 1.70, 1.80, 1.90
55      *,  2.00, 2.20, 2.40, 2.60
56      *,  2.80, 3.00, 3.20, 3.40
57      *,  3.60, 3.80, 4.00, 5.00
58      *,  6.00, 7.00, 8.00, 9.00
59      *, 10.00,11.00,12.00,13.00/
60       DATA F0I/
61      *  0.000000E+00 ,0.995016E-02 ,0.392106E-01 ,0.860688E-01
62      * ,0.147856E+00 ,0.221199E+00 ,0.302324E+00 ,0.387374E+00
63      * ,0.472708E+00 ,0.555142E+00 ,0.632121E+00 ,0.701803E+00
64      * ,0.763072E+00 ,0.815480E+00 ,0.859142E+00 ,0.894601E+00
65      * ,0.922695E+00 ,0.944424E+00 ,0.960836E+00 ,0.972948E+00
66      * ,0.981684E+00 ,0.992093E+00 ,0.996849E+00 ,0.998841E+00
67      * ,0.999606E+00 ,0.999877E+00 ,0.999964E+00 ,0.999990E+00
68      * ,0.999998E+00 ,0.999999E+00 ,0.100000E+01 ,0.100000E+01
69      * ,0.100000E+01 ,0.100000E+01 ,0.100000E+01 ,0.100000E+01
70      * ,1.,1.,1.,1./
71       DATA F1I/
72      *  0.000000E+00,0.414985E-02,0.154894E-01,0.310312E-01
73      * ,0.464438E-01,0.569008E-01,0.580763E-01,0.468264E-01
74      * ,0.217924E-01,-0.163419E-01,-0.651205E-01,-0.120503E+00
75      * ,-0.178272E+00,-0.233580E+00,-0.282442E+00,-0.321901E+00
76      * ,-0.350115E+00,-0.366534E+00,-0.371831E+00,-0.367378E+00
77      * ,-0.354994E+00,-0.314803E+00,-0.266539E+00,-0.220551E+00
78      * ,-0.181546E+00,-0.150427E+00,-0.126404E+00,-0.107830E+00
79      * ,-0.933106E-01,-0.817375E-01,-0.723389E-01,-0.436650E-01
80      * ,-0.294700E-01,-0.212940E-01,-0.161406E-01,-0.126604E-01
81      * ,-0.102042E-01,-0.840465E-02,-0.704261E-02,-0.598886E-02/
82       DATA F2I/
83      *  0.0,0.121500E-01,0.454999E-01,0.913000E-01
84      * ,0.137300E+00,0.171400E+00,0.183900E+00,0.170300E+00
85      * ,0.132200E+00,0.763000E-01,0.126500E-01,-0.473500E-01
86      * ,-0.936000E-01,-0.119750E+00,-0.123450E+00,-0.106300E+00
87      * ,-0.732800E-01,-0.312400E-01,0.128450E-01,0.528800E-01
88      * ,0.844100E-01,0.114710E+00,0.106200E+00,0.765830E-01
89      * ,0.435800E-01,0.173950E-01,0.695001E-03,-0.809500E-02
90      * ,-0.117355E-01,-0.125449E-01,-0.120280E-01,-0.686530E-02
91      * ,-0.385275E-02,-0.231115E-02,-0.147056E-02,-0.982480E-03
92      * ,-0.682440E-03,-0.489715E-03,-0.361190E-03,-0.272582E-03/
93 *
94 *     ------------------------------------------------------------------
95 *
96       CNST=LOG(OMEGA)
97       IF(CNST.LE.1.)GO TO 190
98       B=5.
99       DO 20 L=1,10
100          IF(ABS(B).LT.1.E-10)THEN
101             B=1.E-10
102          ENDIF
103          DB=-(B-LOG(ABS(B))-CNST)/(1.-1./B)
104          B=B+DB
105          IF(ABS(DB).LE.0.0001)GO TO 30
106   20  CONTINUE
107       GO TO 190
108   30  CONTINUE
109       IF(B.LE.0.)GO TO 190
110       BSQ=B*B
111   31  CONTINUE
112       CALL GRNDM(RNDM,1)
113       XINT=RNDM(1)
114       DO 50 NA=2,40
115          TINT(NA)=F0I(NA)+F1I(NA)/B+F2I(NA)/BSQ
116          S=XINT-TINT(NA)
117          IF(S.LE.0.)GO TO 60
118   50  CONTINUE
119       GO TO 180
120   60  CONTINUE
121       IF(NA.GE.40)THEN
122          NA=39
123       ELSE
124          TINT(NA+1)=F0I(NA+1)+F1I(NA+1)/B+F2I(NA+1)/BSQ
125       ENDIF
126       IF(NA.LE.2)THEN
127          NA=3
128          TINT(4)=F0I(4)+F1I(4)/B+F2I(4)/BSQ
129       ENDIF
130       NA3=NA-3
131       DO 70 M=1,4
132          NA3M=NA3+M
133          ARG(M)=TINT(NA3M)
134          VAL(M)=THRED(NA3M)**2
135    70 CONTINUE
136       F=THRED(NA)/50.
137       CALL GMOL4(THRI,XINT,VAL,ARG,F,IER)
138  200  CONTINUE
139       TH=CHIC*SQRT(ABS(B*THRI))
140       IF(TH.GT.3.141593)GO TO 31
141       SINTH=SIN(TH)
142       CALL GRNDM(RNDM,1)
143       TEST=TH*(RNDM(1))**2
144       IF(TEST.GT.SINTH)GO TO 31
145       COSTH=COS(TH)
146       RETURN
147  180  CONTINUE
148       TMP=1.-(1.-B*(1.-XINT))**5
149       IF(TMP.LE.0.)GO TO 31
150       THRI=5./TMP
151       GO TO 200
152  190  CONTINUE
153       COSTH=1.
154       SINTH=0.
155 *
156       END
157 #endif