Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
py4frm.f
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file py4frm.f
1 
2 C*********************************************************************
3 
4 C...PY4FRM
5 C...An interface from a four-fermion generator to include
6 C...parton showers and hadronization.
7 
8  SUBROUTINE py4frm(ATOTSQ,A1SQ,A2SQ,ISTRAT,IRAD,ITAU,ICOM)
9 
10 C...Double precision and integer declarations.
11  IMPLICIT DOUBLE PRECISION(a-h, o-z)
12  IMPLICIT INTEGER(i-n)
13  INTEGER pyk,pychge,pycomp
14 C...Commonblocks.
15  common/pyjets/n,npad,k(4000,5),p(4000,5),v(4000,5)
16  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
17  common/pypars/mstp(200),parp(200),msti(200),pari(200)
18  common/pyint1/mint(400),vint(400)
19  SAVE /pyjets/,/pydat1/,/pypars/,/pyint1/
20 C...Local arrays.
21  dimension ijoin(2),intau(4)
22 
23 C...Call PYHEPC to convert input from HEPEVT to PYJETS common.
24  IF(icom.EQ.0) THEN
25  mstu(28)=0
26  CALL pyhepc(2)
27  ENDIF
28 
29 C...Loop through entries and pick up all final fermions/antifermions.
30  i1=0
31  i2=0
32  i3=0
33  i4=0
34  DO 100 i=1,n
35  IF(k(i,1).LE.0.OR.k(i,1).GT.10) goto 100
36  kfa=iabs(k(i,2))
37  IF((kfa.GE.1.AND.kfa.LE.6).OR.(kfa.GE.11.AND.kfa.LE.16)) THEN
38  IF(k(i,2).GT.0) THEN
39  IF(i1.EQ.0) THEN
40  i1=i
41  ELSEIF(i3.EQ.0) THEN
42  i3=i
43  ELSE
44  CALL pyerrm(16,'(PY4FRM:) more than two fermions')
45  ENDIF
46  ELSE
47  IF(i2.EQ.0) THEN
48  i2=i
49  ELSEIF(i4.EQ.0) THEN
50  i4=i
51  ELSE
52  CALL pyerrm(16,'(PY4FRM:) more than two antifermions')
53  ENDIF
54  ENDIF
55  ENDIF
56  100 CONTINUE
57 
58 C...Check that event is arranged according to conventions.
59  IF(i3.EQ.0.OR.i4.EQ.0) THEN
60  CALL pyerrm(16,'(PY4FRM:) event contains too few fermions')
61  ENDIF
62  IF(i2.LT.i1.OR.i3.LT.i2.OR.i4.LT.i3) THEN
63  CALL pyerrm(6,'(PY4FRM:) fermions arranged in wrong order')
64  ENDIF
65 
66 C...Check which fermion pairs are quarks and which leptons.
67  IF(iabs(k(i1,2)).LT.10.AND.iabs(k(i2,2)).LT.10) THEN
68  iql12=1
69  ELSEIF(iabs(k(i1,2)).GT.10.AND.iabs(k(i2,2)).GT.10) THEN
70  iql12=2
71  ELSE
72  CALL pyerrm(16,'(PY4FRM:) first fermion pair inconsistent')
73  ENDIF
74  IF(iabs(k(i3,2)).LT.10.AND.iabs(k(i4,2)).LT.10) THEN
75  iql34=1
76  ELSEIF(iabs(k(i3,2)).GT.10.AND.iabs(k(i4,2)).GT.10) THEN
77  iql34=2
78  ELSE
79  CALL pyerrm(16,'(PY4FRM:) second fermion pair inconsistent')
80  ENDIF
81 
82 C...Decide whether to allow or not photon radiation in showers.
83  mstj(41)=2
84  IF(irad.EQ.0) mstj(41)=1
85 
86 C...Decide on dipole pairing.
87  ip1=i1
88  ip2=i2
89  ip3=i3
90  ip4=i4
91  IF(iql12.EQ.iql34) THEN
92  r1sq=a1sq
93  r2sq=a2sq
94  delta=atotsq-a1sq-a2sq
95  IF(istrat.EQ.1) THEN
96  IF(delta.GT.0d0) r1sq=r1sq+delta
97  IF(delta.LT.0d0) r2sq=max(0d0,r2sq+delta)
98  ELSEIF(istrat.EQ.2) THEN
99  IF(delta.GT.0d0) r2sq=r2sq+delta
100  IF(delta.LT.0d0) r1sq=max(0d0,r1sq+delta)
101  ENDIF
102  IF(r2sq.GT.pyr(0)*(r1sq+r2sq)) THEN
103  ip2=i4
104  ip4=i2
105  ENDIF
106  ENDIF
107 
108 C...If colour reconnection then bookkeep W+W- or Z0Z0
109 C...and copy q qbar q qbar consecutively.
110  IF(mstp(115).GE.1.AND.iql12.EQ.1.AND.iql34.EQ.1) THEN
111  k(n+1,1)=11
112  k(n+1,3)=ip1
113  k(n+1,4)=n+3
114  k(n+1,5)=n+4
115  k(n+2,1)=11
116  k(n+2,3)=ip3
117  k(n+2,4)=n+5
118  k(n+2,5)=n+6
119  IF(k(ip1,2)+k(ip2,2).EQ.0) THEN
120  k(n+1,2)=23
121  k(n+2,2)=23
122  mint(1)=22
123  ELSEIF(pychge(k(ip1,2)).GT.0) THEN
124  k(n+1,2)=24
125  k(n+2,2)=-24
126  mint(1)=25
127  ELSE
128  k(n+1,2)=-24
129  k(n+2,2)=24
130  mint(1)=25
131  ENDIF
132  DO 110 j=1,5
133  k(n+3,j)=k(ip1,j)
134  k(n+4,j)=k(ip2,j)
135  k(n+5,j)=k(ip3,j)
136  k(n+6,j)=k(ip4,j)
137  p(n+1,j)=p(ip1,j)+p(ip2,j)
138  p(n+2,j)=p(ip3,j)+p(ip4,j)
139  p(n+3,j)=p(ip1,j)
140  p(n+4,j)=p(ip2,j)
141  p(n+5,j)=p(ip3,j)
142  p(n+6,j)=p(ip4,j)
143  v(n+1,j)=v(ip1,j)
144  v(n+2,j)=v(ip3,j)
145  v(n+3,j)=v(ip1,j)
146  v(n+4,j)=v(ip2,j)
147  v(n+5,j)=v(ip3,j)
148  v(n+6,j)=v(ip4,j)
149  110 CONTINUE
150  p(n+1,5)=sqrt(max(0d0,p(n+1,4)**2-p(n+1,1)**2-p(n+1,2)**2-
151  & p(n+1,3)**2))
152  p(n+2,5)=sqrt(max(0d0,p(n+2,4)**2-p(n+2,1)**2-p(n+2,2)**2-
153  & p(n+2,3)**2))
154  k(n+3,3)=n+1
155  k(n+4,3)=n+1
156  k(n+5,3)=n+2
157  k(n+6,3)=n+2
158 C...Remove original q qbar q qbar and update counters.
159  k(ip1,1)=k(ip1,1)+10
160  k(ip2,1)=k(ip2,1)+10
161  k(ip3,1)=k(ip3,1)+10
162  k(ip4,1)=k(ip4,1)+10
163  iw1=n+1
164  iw2=n+2
165  nsd1=n+2
166  ip1=n+3
167  ip2=n+4
168  ip3=n+5
169  ip4=n+6
170  n=n+6
171  ENDIF
172 
173 C...Do colour joinings and parton showers.
174  IF(iql12.EQ.1) THEN
175  ijoin(1)=ip1
176  ijoin(2)=ip2
177  CALL pyjoin(2,ijoin)
178  ENDIF
179  IF(iql12.EQ.1.OR.irad.EQ.1) THEN
180  pm12s=(p(ip1,4)+p(ip2,4))**2-(p(ip1,1)+p(ip2,1))**2-
181  & (p(ip1,2)+p(ip2,2))**2-(p(ip1,3)+p(ip2,3))**2
182  CALL pyshow(ip1,ip2,sqrt(max(0d0,pm12s)))
183  ENDIF
184  naft1=n
185  IF(iql34.EQ.1) THEN
186  ijoin(1)=ip3
187  ijoin(2)=ip4
188  CALL pyjoin(2,ijoin)
189  ENDIF
190  IF(iql34.EQ.1.OR.irad.EQ.1) THEN
191  pm34s=(p(ip3,4)+p(ip4,4))**2-(p(ip3,1)+p(ip4,1))**2-
192  & (p(ip3,2)+p(ip4,2))**2-(p(ip3,3)+p(ip4,3))**2
193  CALL pyshow(ip3,ip4,sqrt(max(0d0,pm34s)))
194  ENDIF
195 
196 C...Optionally do colour reconnection.
197  mint(32)=0
198  msti(32)=0
199  IF(mstp(115).GE.1.AND.iql12.EQ.1.AND.iql34.EQ.1) THEN
200  CALL pyreco(iw1,iw2,nsd1,naft1)
201  msti(32)=mint(32)
202  ENDIF
203 
204 C...Do fragmentation and decays. Possibly except tau decay.
205  IF(itau.EQ.0) THEN
206  ntau=0
207  DO 120 i=1,n
208  IF(iabs(k(i,2)).EQ.15.AND.k(i,1).EQ.1) THEN
209  ntau=ntau+1
210  intau(ntau)=i
211  k(i,1)=11
212  ENDIF
213  120 CONTINUE
214  ENDIF
215  CALL pyexec
216  IF(itau.EQ.0) THEN
217  DO 130 i=1,ntau
218  k(intau(i),1)=1
219  130 CONTINUE
220  ENDIF
221 
222 C...Call PYHEPC to convert output from PYJETS to HEPEVT common.
223  IF(icom.EQ.0) THEN
224  mstu(28)=0
225  CALL pyhepc(1)
226  ENDIF
227 
228  END