-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgenbeam.F
More file actions
executable file
·54 lines (42 loc) · 1.57 KB
/
Copy pathgenbeam.F
File metadata and controls
executable file
·54 lines (42 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
subroutine genbeam (vertex, p)
c This routine is called to generate the coordinates and momentum of an
c electron according to the specifications in the BEAM data card.
c Outputs:
c vertex(3): coordinates of beam particle at chicane entrance (cm)
c p(3): incident momentum of beam particle at chicane entrance (GeV/c)
c
c Richard Jones June 19, 2003
c - original code by Pat Welch extracted from gukine.F
c - got rid of "fortran structure" references in favour of standard f77
c - replaced trig intrinsics based on degrees (sind,cosd,tand..) with
c local versions because g77 does not support them
c - replaced all custom random generators with Geant versions
c
implicit none
#include "geant321/gclist.inc"
include 'user.inc'
include 'params.inc'
real vertex(3), p(3)
real random1, random2, grnd ! random numbers
real*8 thetax, thetay ! beam divergence in radians
real*8 px, py, momentum ! electron momentum
c First define the electron vertex at the beginning of the chicane
c random1 = grnd()
c random2 = grnd()
call granor (random1, random2)
vertex(1) = random1 * beam_sigmax
vertex(2) = chicane_drop + random2 * beam_sigmay
vertex(3) = -chicane_length / 2. + 0.8
c Now define the beam electron momentum
call granor (random1, random2)
thetax = random1 * beam_thetax
thetay = random2 * beam_thetay
call granor (random1, random2)
momentum = sqrt((beam_E + beam_dE * random1)**2
& - mass_electron**2)
px = momentum * sin(thetax)
py = momentum * sin(thetay)
p(1) = px
p(2) = py
p(3) = momentum - sqrt(px**2 + py**2)
end