source: trunk/MagicSoft/Simulation/Corsika/Mmcs/uphi.f@ 597

Last change on this file since 597 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: 4.8 KB
Line 
1 SUBROUTINE UPHI(IENTRY,LVL)
2C VERSION 4.00 -- 26 JAN 1986/1900
3C******************************************************************
4C UPHI STANDS FOR 'UNIFORM PHI DISTRIBUTION'.
5C SET COORDINATES FOR NEW PARTICLE OR RESET DIRECTION COSINES OF
6C OLD ONE. GENERATE RANDOM AZIMUTH SELECTION AND REPLACE THE
7C DIRECTION COSINES WITH THEIR NEW VALUES.
8C******************************************************************
9*KEEP,EPCONT.
10 COMMON/EPCONT/ EDEP,RATIO,TSTEP,TUSTEP,USTEP,TVSTEP,VSTEP,IDISC,
11 * IROLD,IRNEW,RHOFAC, EOLD,ENEW,EKE,ELKE,BETA2,GLE,
12 * TSCAT,IAUSFL
13 DOUBLE PRECISION EDEP,RATIO
14 REAL TSTEP,TUSTEP,USTEP,TVSTEP,VSTEP,RHOFAC,EOLD,ENEW,
15 * EKE,ELKE,BETA2,GLE,TSCAT
16 INTEGER IDISC,IROLD,IRNEW,IAUSFL(29)
17*KEEP,RANDPA.
18 COMMON /RANDPA/ FAC,U1,U2,RD,NSEQ,ISEED,KNOR
19 DOUBLE PRECISION FAC,U1,U2
20 REAL RD(3000)
21 INTEGER ISEED(103,10),NSEQ
22 LOGICAL KNOR
23*KEEP,RUNPAR.
24 COMMON /RUNPAR/ FIXHEI,THICK0,HILOECM,HILOELB,
25 * STEPFC,NRRUN,NSHOW,PATAPE,MONIIN,
26 * MONIOU,MDEBUG,NUCNUC,
27 * CETAPE,
28 * SHOWNO,ISHW,NOPART,NRECS,NBLKS,MAXPRT,NDEBDL,
29 * N1STTR,MDBASE,
30 * DEBDEL,DEBUG,FDECAY,FEGS,FIRSTI,FIXINC,FIXTAR,
31 * FIX1I,FMUADD,FNKG,FPRINT,FDBASE
32 * ,GHEISH,GHESIG
33 COMMON /RUNPAC/ DSN,HOST,USER
34 DOUBLE PRECISION FIXHEI,THICK0,HILOECM,HILOELB
35 REAL STEPFC
36 INTEGER NRRUN,NSHOW,PATAPE,MONIIN,MONIOU,MDEBUG,NUCNUC,
37 * SHOWNO,ISHW,NOPART,NRECS,NBLKS,MAXPRT,NDEBDL,
38 * N1STTR,MDBASE
39 INTEGER CETAPE
40 CHARACTER*79 DSN
41 CHARACTER*20 HOST,USER
42
43 LOGICAL DEBDEL,DEBUG,FDECAY,FEGS,FIRSTI,FIXINC,FIXTAR,
44 * FIX1I,FMUADD,FNKG,FPRINT,FDBASE
45 * ,GHEISH,GHESIG
46*KEEP,STACKE.
47 COMMON/STACKE/ E,TIME,X,Y,Z,U,V,W,DNEAR,IQ,IGEN,IR,IOBS,LPCTE,NP
48 DOUBLE PRECISION E(60),TIME(60)
49 REAL X(60),Y(60),Z(60),U(60),V(60),W(60),DNEAR(60)
50 INTEGER IQ(60),IGEN(60),IR(60),IOBS(60),LPCTE(60),NP
51*KEND.
52 COMMON/UPHIIN/SINC0,SINC1,SIN0(20002),SIN1(20002)
53 COMMON/UPHIOT/THETA,SINTHE,COSTHE,SINPHI, COSPHI,PI,TWOPI,PI5D2
54 SAVE A,B,C
55 IF((IENTRY.EQ.2))GO TO1070
56 IF((IENTRY.EQ.3))GO TO1080
571090 LTHETA=SINC1*THETA+SINC0
58 SINTHE=SIN1(LTHETA)*THETA+SIN0(LTHETA)
59 CTHET=PI5D2-THETA
60 LCTHET=SINC1*CTHET+SINC0
61 COSTHE=SIN1(LCTHET)*CTHET+SIN0(LCTHET)
62C USE THE FOLLOWING ENTRY IF SINTHE AND COSTHE ARE ALREADY KNOWN.
63C SELECT PHI UNIFORMLY OVER THE INTERVAL (0,TWO PI). THEN USE
64C PWLF OF SIN FUNCTION TO GET SIN(PHI) AND COS(PHI). THE COSINE
65C IS GOTTEN BY COS(PHI)=SIN(9*PI/4 - PHI).
661070 CALL RMMAR(RNNO38,1,2)
67 PHI=RNNO38*TWOPI
68 LPHI=SINC1*PHI+SINC0
69 SINPHI=SIN1(LPHI)*PHI+SIN0(LPHI)
70 CPHI=PI5D2-PHI
71 LCPHI=SINC1*CPHI+SINC0
72 COSPHI=SIN1(LCPHI)*CPHI+SIN0(LCPHI)
73C USE THE FOLLOWING ENTRY FOR THE SECOND OF TWO PARTICLES WHEN WE
74C KNOW TWO PARTICLES HAVE A RELATIONSHIP IN THEIR CORRECTIONS.
75C NOTE: SINTHE AND COSTHE CAN BE CHANGED OUTSIDE THROUGH COMMON.
76C LVL IS A PARAMETER TELLING WHICH PARTICLES TO WORK WITH.
77C THETA (SINTHE AND COSTHE) ARE ALWAYS RELATIVE TO THE DIRECTION
78C OF THE INCIDENT PARTICLE BEFORE ITS DIRECTION WAS ADJUSTED.
79C THUS WHEN TWO PARTICLES NEED TO HAVE THEIR DIRECTIONS COMPUTED,
80C THE ORIGINAL INCIDENT DIRECTION IS SAVED IN THE VARIABLE A,B,C
81C SO THAT IT CAN BE USED ON BOTH CALLS.
82C LVL=1 -- OLD PARTICLE, SAVE ITS DIRECTION AND ADJUST IT
83C LVL=2 -- NEW PARTICLE. ADJUST DIRECTION USING SAVED A,B,C
84C LVL=3 -- BREMSSTRAHLUNG GAMMA. SAVE ELECTRON DIRECTION (NEXT
85C TO TOP OF STACK), AND THEN ADJUST GAMMA DIRECTION.
861080 IF (LVL.EQ.2) GO TO1100
87 IF((LVL.EQ.3))GO TO1110
881120 A=U(NP)
89 B=V(NP)
90 C=W(NP)
91 GO TO 1130
921110 A=U(NP-1)
93 B=V(NP-1)
94 C=W(NP-1)
951100 X(NP)=X(NP-1)
96 Y(NP)=Y(NP-1)
97 Z(NP)=Z(NP-1)
98 LPCTE(NP)=LPCTE(NP-1)
99 IR(NP)=IR(NP-1)
100 DNEAR(NP)=DNEAR(NP-1)
101 TIME(NP)=TIME(NP-1)
102 IGEN(NP)=IGEN(NP-1)
103 IOBS(NP)=IOBS(NP-1)
1041130 SINPS2=A*A+B*B
105 IF (SINPS2.LT.1.0E-10) THEN
106 U(NP)=SINTHE*COSPHI
107 V(NP)=SINTHE*SINPHI
108 W(NP)=C*COSTHE
109 ELSE
110 SINPSI=SQRT(SINPS2)
111 US=SINTHE*COSPHI
112 VS=SINTHE*SINPHI
113 SINDEL=B*(1./SINPSI)
114 COSDEL=A*(1./SINPSI)
115 U(NP)=C*COSDEL*US-SINDEL*VS+A*COSTHE
116 V(NP)=C*SINDEL*US+COSDEL*VS+B*COSTHE
117 W(NP)=-SINPSI*US+C*COSTHE
118 END IF
119 RADINV=1.5-0.5*(U(NP)**2+V(NP)**2+W(NP)**2)
120 U(NP)=U(NP)*RADINV
121 V(NP)=V(NP)*RADINV
122 W(NP)=W(NP)*RADINV
123 RETURN
124 END
Note: See TracBrowser for help on using the repository browser.