source: trunk/MagicSoft/Simulation/Corsika/Mmcs/addani.f@ 13408

Last change on this file since 13408 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.8 KB
Line 
1 SUBROUTINE ADDANI( COST0,PHI0, COST1,PHI1, DCTH,DPHI )
2
3C-----------------------------------------------------------------------
4C ADD(ITION OF) AN(GLES) I(NVERTED)
5C
6C GIVEN TWO DIRECTIONS (0 AND 1) IN A COMMON SYSTEM OF REFERENCE.
7C FIND DCTH AND DPHI SUCH, THAT THE ROUTINE ADDANG TRANSFORMS
8C (COST0,PHI0) BY ADDING (DCTH,DPHI) INTO (COST1,PHI1).
9C CALCULATION IS DONE BY SEQUENTIAL ROTATIONS :
10C 1. ROTATE VECTOR AROUND Z AXIS BY -PHI1
11C 2. ROTATE VECTOR AROUND Y AXIS BY -THETA1
12C NOW VECTOR IS (X,Y,Z) WITH DCTH = Z
13C AND TAN(DPHI) = Y/X
14C THIS SUBROUTINE IS CALLED FROM MUDECY
15C ARGUMENTS:
16C COST0 = COSINE THETA OF PARTICLE BEFORE
17C PHI0 = PHI OF PARTICLE BEFORE
18C COST1 = COSINE THETA OF PARTICLE
19C PHI1 = PHI OF PARTICLE
20C DCTH = COSINE THETA OF ANGLE
21C DPHI = PHI OF ANGLE
22C-----------------------------------------------------------------------
23
24 IMPLICIT NONE
25*KEEP,CONST.
26 COMMON /CONST/ PI,PI2,OB3,TB3,ENEPER
27 DOUBLE PRECISION PI,PI2,OB3,TB3,ENEPER
28*KEEP,RUNPAR.
29 COMMON /RUNPAR/ FIXHEI,THICK0,HILOECM,HILOELB,
30 * STEPFC,NRRUN,NSHOW,PATAPE,MONIIN,
31 * MONIOU,MDEBUG,NUCNUC,
32 * CETAPE,
33 * SHOWNO,ISHW,NOPART,NRECS,NBLKS,MAXPRT,NDEBDL,
34 * N1STTR,MDBASE,
35 * DEBDEL,DEBUG,FDECAY,FEGS,FIRSTI,FIXINC,FIXTAR,
36 * FIX1I,FMUADD,FNKG,FPRINT,FDBASE
37 * ,GHEISH,GHESIG
38 COMMON /RUNPAC/ DSN,HOST,USER
39 DOUBLE PRECISION FIXHEI,THICK0,HILOECM,HILOELB
40 REAL STEPFC
41 INTEGER NRRUN,NSHOW,PATAPE,MONIIN,MONIOU,MDEBUG,NUCNUC,
42 * SHOWNO,ISHW,NOPART,NRECS,NBLKS,MAXPRT,NDEBDL,
43 * N1STTR,MDBASE
44 INTEGER CETAPE
45 CHARACTER*79 DSN
46 CHARACTER*20 HOST,USER
47
48 LOGICAL DEBDEL,DEBUG,FDECAY,FEGS,FIRSTI,FIXINC,FIXTAR,
49 * FIX1I,FMUADD,FNKG,FPRINT,FDBASE
50 * ,GHEISH,GHESIG
51*KEND.
52
53 DOUBLE PRECISION COST0,COST1,CP,CP1,CT,CT1,DCTH,DPHI,PHI0,PHI1,
54 * SP,SP1,ST,ST1,X,XX,Y,YY,Z,ZZ
55C-----------------------------------------------------------------------
56
57CC IF ( DEBUG ) WRITE(MDEBUG,*) 'ADDANI:'
58
59 CT = COST0
60 ST = SQRT(1.D0-CT**2)
61 CP = COS(PHI0)
62 SP = SIN(PHI0)
63 CT1 = COST1
64 ST1 = SQRT(1.D0-CT1**2)
65 CP1 = COS(PHI1)
66 SP1 = SIN(PHI1)
67
68 X = ST1 * CP1
69 Y = ST1 * SP1
70 Z = CT1
71
72 XX = CT*CP*X + CT*SP*Y - ST*Z
73 YY = -SP *X + CP *Y
74 ZZ = ST*CP*X + ST*SP*Y + CT*Z
75
76C GET NEW COSINE(THETA) AND PHI
77 DCTH = ZZ
78 IF ( YY .NE. 0.D0 .OR. XX .NE. 0.D0 ) THEN
79 DPHI = ATAN2( YY, XX )
80 ELSE
81 DPHI = 0.D0
82 ENDIF
83
84 RETURN
85 END
Note: See TracBrowser for help on using the repository browser.