Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
py4ent.f
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file py4ent.f
1 
2 C*********************************************************************
3 
4 C...PY4ENT
5 C...Stores four partons or particles in their CM frame, with
6 C...the first along the +z axis, the last in the xz plane with x > 0
7 C...and the second having y < 0 and y > 0 with equal probability.
8 
9  SUBROUTINE py4ent(IP,KF1,KF2,KF3,KF4,PECM,X1,X2,X4,X12,X14)
10 
11 C...Double precision and integer declarations.
12  IMPLICIT DOUBLE PRECISION(a-h, o-z)
13  IMPLICIT INTEGER(i-n)
14  INTEGER pyk,pychge,pycomp
15 C...Commonblocks.
16  common/pyjets/n,npad,k(4000,5),p(4000,5),v(4000,5)
17  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
18  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
19  SAVE /pyjets/,/pydat1/,/pydat2/
20 
21 C...Standard checks.
22  mstu(28)=0
23  IF(mstu(12).NE.12345) CALL pylist(0)
24  ipa=max(1,iabs(ip))
25  IF(ipa.GT.mstu(4)-3) CALL pyerrm(21,
26  &'(PY4ENT:) writing outside PYJETS momory')
27  kc1=pycomp(kf1)
28  kc2=pycomp(kf2)
29  kc3=pycomp(kf3)
30  kc4=pycomp(kf4)
31  IF(kc1.EQ.0.OR.kc2.EQ.0.OR.kc3.EQ.0.OR.kc4.EQ.0) CALL pyerrm(12,
32  &'(PY4ENT:) unknown flavour code')
33 
34 C...Find masses. Reset K, P and V vectors.
35  pm1=0d0
36  IF(mstu(10).EQ.1) pm1=p(ipa,5)
37  IF(mstu(10).GE.2) pm1=pymass(kf1)
38  pm2=0d0
39  IF(mstu(10).EQ.1) pm2=p(ipa+1,5)
40  IF(mstu(10).GE.2) pm2=pymass(kf2)
41  pm3=0d0
42  IF(mstu(10).EQ.1) pm3=p(ipa+2,5)
43  IF(mstu(10).GE.2) pm3=pymass(kf3)
44  pm4=0d0
45  IF(mstu(10).EQ.1) pm4=p(ipa+3,5)
46  IF(mstu(10).GE.2) pm4=pymass(kf4)
47  DO 110 i=ipa,ipa+3
48  DO 100 j=1,5
49  k(i,j)=0
50  p(i,j)=0d0
51  v(i,j)=0d0
52  100 CONTINUE
53  110 CONTINUE
54 
55 C...Check flavours.
56  kq1=kchg(kc1,2)*isign(1,kf1)
57  kq2=kchg(kc2,2)*isign(1,kf2)
58  kq3=kchg(kc3,2)*isign(1,kf3)
59  kq4=kchg(kc4,2)*isign(1,kf4)
60  IF(mstu(19).EQ.1) THEN
61  mstu(19)=0
62  ELSEIF(kq1.EQ.0.AND.kq2.EQ.0.AND.kq3.EQ.0.AND.kq4.EQ.0) THEN
63  ELSEIF(kq1.NE.0.AND.kq2.EQ.2.AND.kq3.EQ.2.AND.(kq1+kq4.EQ.0.OR.
64  & kq1+kq4.EQ.4)) THEN
65  ELSEIF(kq1.NE.0.AND.kq1+kq2.EQ.0.AND.kq3.NE.0.AND.kq3+kq4.EQ.0d0)
66  & THEN
67  ELSE
68  CALL pyerrm(2,'(PY4ENT:) unphysical flavour combination')
69  ENDIF
70  k(ipa,2)=kf1
71  k(ipa+1,2)=kf2
72  k(ipa+2,2)=kf3
73  k(ipa+3,2)=kf4
74 
75 C...Store partons/particles in K vectors for normal case.
76  IF(ip.GE.0) THEN
77  k(ipa,1)=1
78  IF(kq1.NE.0.AND.(kq2.NE.0.OR.kq3.NE.0.OR.kq4.NE.0)) k(ipa,1)=2
79  k(ipa+1,1)=1
80  IF(kq2.NE.0.AND.kq1+kq2.NE.0.AND.(kq3.NE.0.OR.kq4.NE.0))
81  & k(ipa+1,1)=2
82  k(ipa+2,1)=1
83  IF(kq3.NE.0.AND.kq4.NE.0) k(ipa+2,1)=2
84  k(ipa+3,1)=1
85 
86 C...Store partons for parton shower evolution from q-g-g-qbar or
87 C...g-g-g-g event.
88  ELSEIF(kq1+kq2.NE.0) THEN
89  k(ipa,1)=3
90  k(ipa+1,1)=3
91  k(ipa+2,1)=3
92  k(ipa+3,1)=3
93  kcs=4
94  IF(kq1.EQ.-1) kcs=5
95  k(ipa,kcs)=mstu(5)*(ipa+1)
96  k(ipa,9-kcs)=mstu(5)*(ipa+3)
97  k(ipa+1,kcs)=mstu(5)*(ipa+2)
98  k(ipa+1,9-kcs)=mstu(5)*ipa
99  k(ipa+2,kcs)=mstu(5)*(ipa+3)
100  k(ipa+2,9-kcs)=mstu(5)*(ipa+1)
101  k(ipa+3,kcs)=mstu(5)*ipa
102  k(ipa+3,9-kcs)=mstu(5)*(ipa+2)
103 
104 C...Store partons for parton shower evolution from q-qbar-q-qbar event.
105  ELSE
106  k(ipa,1)=3
107  k(ipa+1,1)=3
108  k(ipa+2,1)=3
109  k(ipa+3,1)=3
110  k(ipa,4)=mstu(5)*(ipa+1)
111  k(ipa,5)=k(ipa,4)
112  k(ipa+1,4)=mstu(5)*ipa
113  k(ipa+1,5)=k(ipa+1,4)
114  k(ipa+2,4)=mstu(5)*(ipa+3)
115  k(ipa+2,5)=k(ipa+2,4)
116  k(ipa+3,4)=mstu(5)*(ipa+2)
117  k(ipa+3,5)=k(ipa+3,4)
118  ENDIF
119 
120 C...Check kinematics.
121  mkerr=0
122  IF(0.5d0*x1*pecm.LE.pm1.OR.0.5d0*x2*pecm.LE.pm2.OR.
123  &0.5d0*(2d0-x1-x2-x4)*pecm.LE.pm3.OR.0.5d0*x4*pecm.LE.pm4)
124  &mkerr=1
125  pa1=sqrt(max(1d-10,(0.5d0*x1*pecm)**2-pm1**2))
126  pa2=sqrt(max(1d-10,(0.5d0*x2*pecm)**2-pm2**2))
127  pa4=sqrt(max(1d-10,(0.5d0*x4*pecm)**2-pm4**2))
128  x24=x1+x2+x4-1d0-x12-x14+(pm3**2-pm1**2-pm2**2-pm4**2)/pecm**2
129  cthe4=(x1*x4-2d0*x14)*pecm**2/(4d0*pa1*pa4)
130  IF(abs(cthe4).GE.1.002d0) mkerr=1
131  cthe4=max(-1d0,min(1d0,cthe4))
132  sthe4=sqrt(1d0-cthe4**2)
133  cthe2=(x1*x2-2d0*x12)*pecm**2/(4d0*pa1*pa2)
134  IF(abs(cthe2).GE.1.002d0) mkerr=1
135  cthe2=max(-1d0,min(1d0,cthe2))
136  sthe2=sqrt(1d0-cthe2**2)
137  cphi2=((x2*x4-2d0*x24)*pecm**2-4d0*pa2*cthe2*pa4*cthe4)/
138  &max(1d-8*pecm**2,4d0*pa2*sthe2*pa4*sthe4)
139  IF(abs(cphi2).GE.1.05d0) mkerr=1
140  cphi2=max(-1d0,min(1d0,cphi2))
141  IF(mkerr.EQ.1) CALL pyerrm(13,
142  &'(PY4ENT:) unphysical kinematical variable setup')
143 
144 C...Store partons/particles in P vectors.
145  p(ipa,3)=pa1
146  p(ipa,4)=sqrt(pa1**2+pm1**2)
147  p(ipa,5)=pm1
148  p(ipa+3,1)=pa4*sthe4
149  p(ipa+3,3)=pa4*cthe4
150  p(ipa+3,4)=sqrt(pa4**2+pm4**2)
151  p(ipa+3,5)=pm4
152  p(ipa+1,1)=pa2*sthe2*cphi2
153  p(ipa+1,2)=pa2*sthe2*sqrt(1d0-cphi2**2)*(-1d0)**int(pyr(0)+0.5d0)
154  p(ipa+1,3)=pa2*cthe2
155  p(ipa+1,4)=sqrt(pa2**2+pm2**2)
156  p(ipa+1,5)=pm2
157  p(ipa+2,1)=-p(ipa+1,1)-p(ipa+3,1)
158  p(ipa+2,2)=-p(ipa+1,2)
159  p(ipa+2,3)=-p(ipa,3)-p(ipa+1,3)-p(ipa+3,3)
160  p(ipa+2,4)=sqrt(p(ipa+2,1)**2+p(ipa+2,2)**2+p(ipa+2,3)**2+pm3**2)
161  p(ipa+2,5)=pm3
162 
163 C...Set N. Optionally fragment/decay.
164  n=ipa+3
165  IF(ip.EQ.0) CALL pyexec
166 
167  RETURN
168  END