EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
lysspa.F
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file lysspa.F
1 C ********************************************************************
2 
3  SUBROUTINE lysspa(IPU1,IPU2)
4 
5  IMPLICIT NONE
6 
7 C...NEW X REDEFINITION
8 C...GENERATES SPACELIKE PARTON SHOWERS
9 *
10 * to avoid variable conflictions, a second keep element is necessary
11 * with the same common block name (see LEPTO2)
12 *
13 
14  COMMON /leptou/ cut(14),lst(40),parl(30),
15  & xlp,ylp,w2lp,q2lp,ulp
16  REAL cut,parl,xlp,ylp,w2lp,q2lp,ulp
17  INTEGER lst
18  SAVE /leptou/
19 
20  INTEGER nlupdm,nplbuf
21  parameter(nlupdm=4000,nplbuf=5)
22  common/lujets/n,k(nlupdm,5),p(nlupdm,nplbuf),v(nlupdm,5)
23  INTEGER n,k
24  REAL p,v
25  SAVE /lujets/
26 
27  common/ludat1/mstu(200),paru(200),mstj(200),parj(200)
28  INTEGER mstu,mstj
29  REAL paru,parj
30  SAVE /ludat1/
31 
32  common/ludat2/kchg(500,3),pmas(500,4),parf(2000),vckm(4,4)
33  INTEGER kchg
34  REAL pmas,parf,vckm
35  SAVE /ludat2/
36 
37  COMMON /pypara/ ipy(80),pypar(80),pyvar(80)
38  REAL pypar,pyvar
39  INTEGER ipy
40  SAVE /pypara/
41 
42 *
43 * to avoid variable conflictions, a second keep element is necessary
44 * with the same common block name (see LYPRO2)
45 *
46  COMMON /lyproc/ isub,kfl(3,2),x(2),sh,th,uh,q2,xsec(0:40)
47  REAL x,sh,th,uh,q2,xsec
48  INTEGER isub,kfl
49  SAVE /lyproc/
50 
51  COMMON /lyint1/ xq(2,-6:6),dsig(-6:6,-6:6,5),fsig(10,10,3)
52  REAL xq,dsig,fsig
53  SAVE /lyint1/
54 
55 
56 
57  INTEGER ipu1,ipu2,ifls,is,nq,ilep,ifla,ns,ifl,jt,ihfc,ihfx,
58  +i,j,jr,iflb,ihft,ipo,i1,i2,itemp,it,ikin,id1,kn1,kd1,id2,
59  +ir,jb,ntry,n145, njr
60  REAL xs,zs,q2s,tevs,robo,xfs,xfa,xfb,wtap,wtsf,z,xe0,xa,
61  +tmax,qmax,q2e,b0,xbmin,xb,q2b,tevb,qmass,xe,wtapq,wtsum,tevxp,
62  +q2ref,wtran,wtz,xbnew,rsoft,zu,q2max,alprat,the
63  REAL ulmass,rlu,ulangl,xt,searatio
64 
65  dimension ifls(4),is(2),xs(2),zs(2),q2s(2),tevs(2),robo(5),
66  &xfs(2,-6:6),xfa(-6:6),xfb(-6:6),wtap(-6:6),wtsf(-6:6)
67  DOUBLE PRECISION dq2(3),dsh,dshz,dshr,dplcm,dpc(3),dpd(4),dms,
68  &dmsma,dpt2,dpb(4),dbe1(4),dbe2(4),dbep,dgabep,dpq(4),dpqs(2),
69  &dm2,dq2b,drobo(5),dbez,dtemp
70 C-GI &DQ23,DPH(4),DM2,DQ2B,DQM2
71 CJR--begin
72  LOGICAL seaquark,split
73  REAL xft(-6:6)
74  REAL xquark,xgluon,xsea,zsplit,zsoft,zmax
75  COMMON /seaqte/ xquark,xgluon,xsea,zsplit,zsoft,zmax,split
76  INTEGER lastfl,seafl
77  COMMON /flavor/ lastfl,seafl
78 CJR--end
79  DATA ifla,nq/0,0/,z,xe0,xa/3*0./,dshz,dmsma,dpt2,dshr/4*0.d0/
80 
81 C...COMMON CONSTANTS, SET UP INITIAL VALUES
82  ilep=0
83  IF(ipu1.EQ.0) ilep=1
84  IF(ipu2.EQ.0) ilep=2
85  q2e=q2
86 C-GI IF(ISET(ISUB).EQ.2.OR.ISET(ISUB).EQ.3) Q2E=Q2E/PYPAR(26)
87  IF(isub.EQ.27) q2e=pmas(23,1)**2
88  IF(isub.EQ.28) q2e=pmas(24,1)**2
89  tmax=alog(pypar(26)*pypar(27)*q2e/pypar(21)**2)
90  IF(ilep.GE.1) THEN
91  sh=p(25,5)**2
92  IF(n.GE.27) sh=p(27,5)**2
93  CALL lscale(-1,qmax)
94  q2e=qmax**2
95  q2e=max(pypar(21)**2,min(q2e,(0.95/x(3-ilep)-1.)*q2-sh,
96  & q2/2.+sh))
97  tmax=alog(q2e/pypar(21)**2)
98  ENDIF
99 CJR--begin
100  IF (mod(lst(8),10).EQ.4 .OR. mod(lst(8),10).EQ.5) THEN
101  q2e=pypar(22)
102  tmax=alog(q2e/pypar(21)**2)
103  ELSEIF(pypar(26)*q2e.LT.max(pypar(22),2.*pypar(21)**2).OR.
104  &tmax.LT.0.2) THEN
105  RETURN
106  ENDIF
107 CJR--end
108  IF(ilep.EQ.0) xe0=2.*pypar(23)/pyvar(1)
109  b0=(33.-2.*ipy(8))/6.
110  ns=n
111  mstu(2)=0
112 CJR--begin
113  ntry=0
114  100 n=ns
115  ntry=ntry+1
116  IF (ntry.GT.100) THEN
117  lst(21)=17
118  RETURN
119  ENDIF
120 CJR--end
121 CJR 100 N=NS
122 CJR--begin
123  seaquark=.false.
124  split=.false.
125 CJR--end
126  IF(ilep.GE.1) THEN
127  nq=ipu2-2
128  IF(ilep.EQ.2) nq=ipu1+2
129  dpqs(1)=dble(p(nq,3))
130  dpqs(2)=dble(p(nq,4))
131  xbmin=x(3-ilep)*max(0.5,sh/q2)
132  CALL lystfu(ipy(43-ilep),xbmin,q2,xfb)
133  DO 110 ifl=-6,6
134  110 xq(3-ilep,ifl)=xfb(ifl)
135  ENDIF
136  DO 120 jt=1,2
137  ifls(jt)=kfl(2,jt)
138  IF(kfl(2,jt).EQ.21) ifls(jt)=0
139  ifls(jt+2)=ifls(jt)
140  xs(jt)=x(jt)
141  zs(jt)=1.
142  IF(ilep.EQ.0) q2s(jt)=pypar(26)*q2e
143  tevs(jt)=tmax
144  DO 120 ifl=-6,6
145  120 xfs(jt,ifl)=xq(jt,ifl)
146  IF(ilep.GE.1) THEN
147  q2s(ilep)=p(nq,5)**2
148  dq2(ilep)=q2s(ilep)
149  q2s(3-ilep)=q2e
150  ENDIF
151  dsh=sh
152  ihfc=0
153  ihfx=0
154 
155 C...PICK UP LEG WITH HIGHEST VIRTUALITY
156  130 CONTINUE
157  IF(n.GT.mstu(4)-10) THEN
158  WRITE(6,*) ' LYSSPA: no more memory in LUJETS'
159  lst(21)=18
160  RETURN
161  ENDIF
162  DO 133 i=n+1,n+8
163  DO 133 j=1,5
164  k(i,j)=0
165  133 p(i,j)=0.
166 C CALL GULIST(21,2)
167  n=n+2
168  jt=1
169  IF((n.GT.ns+2.AND.q2s(2).GT.q2s(1).AND.ilep.EQ.0).OR.ilep.EQ.1)
170  &jt=2
171  jr=3-jt
172  iflb=ifls(jt)
173  xb=xs(jt)
174  IF(ilep.GE.1.AND.n.EQ.ns+2) xb=xs(jt)*max(sh/q2,0.5)
175  DO 140 ifl=-6,6
176  140 xfb(ifl)=xfs(jt,ifl)
177  q2b=q2s(jt)
178  tevb=tevs(jt)
179  IF(ipy(14).GE.9.AND.n.GT.ns+4) THEN
180  q2b=0.5*(1./zs(jt)+1.)*q2s(jt)+0.5*(1./zs(jt)-1.)*(q2s(3-jt)-
181  & sngl(dsh)+sqrt((sngl(dsh)+q2s(1)+q2s(2))**2+8.*q2s(1)*q2s(2)*
182  & zs(jt)/(1.-zs(jt))))
183  tevb=alog(pypar(27)*q2b/pypar(21)**2)
184  ENDIF
185  IF(ilep.EQ.0) THEN
186  dshr=2.*dsqrt(dsh)
187  dshz=dsh/dble(zs(jt))
188  ELSEIF(ilep.GE.1) THEN
189  dshz=dsh
190  IF(n.GT.ns+4) dshz=(dsh+dq2(jr)-dq2(jt))/zs(jt)-dq2(jr)+
191  & pypar(22)
192  dpd(2)=dshz+dq2(jr)+dble(pypar(22))
193 
194  mstj(93)=1
195  qmass=ulmass(iabs(iflb))
196  IF(iabs(iflb).EQ.0) qmass=ulmass(21)
197 C...CHECK IF QUARK PAIR CREATION ONLY POSSIBILITY
198  IF(dq2(jr).LT.4.*qmass**2) THEN
199  dm2=qmass**2
200  dpc(1)=dq2(jr)*(dble(pypar(22))+dm2)**2
201  dpc(2)=dpd(2)*(dpd(2)-2d0*pypar(22))*(pypar(22)+dm2)
202  dpc(3)=pypar(22)*(dpd(2)-2d0*pypar(22))**2
203  xe0=1d0-(dpc(2)-dsqrt(dpc(2)**2-4d0*dpc(1)*dpc(3)))/
204  & (2d0*dpc(1))
205 CJR--begin
206  zmax=(dpc(2)-dsqrt(dpc(2)**2-4d0*dpc(1)*dpc(3)))/(2d0*dpc(1))
207  xe0=xb*(1./zmax-1.)
208 CJR--end
209  ELSE
210  xe0=1d0-(dpd(2)-2d0*dble(pypar(22)))*(dpd(2)-dsqrt(dpd(2)**2-
211  & 4d0*dq2(jr)*dble(pypar(22))))/(2d0*dq2(jr)*dble(pypar(22)))
212 CJR--begin
213  zmax=(dpd(2)-2d0*dble(pypar(22)))*(dpd(2)-dsqrt(dpd(2)**2-
214  & 4d0*dq2(jr)*dble(pypar(22))))/(2d0*dq2(jr)*dble(pypar(22)))
215  xe0=xb*(1./zmax-1.)
216 CJR--end
217  ENDIF
218 CJR--begin
219 CJR-- radiated parton energy cut
220 C XE0=MAX(XE0,2.*PYPAR(23)/SQRT(W2LP))
221 CJR--end
222  ENDIF
223 CJR 145 XE=MAX(XE0,XB*(1./(1.-PYPAR(24))-1.))
224 CJR--begin
225  n145=0
226 145 CONTINUE
227  n145=n145+1
228  IF (n145.GT.100) THEN
229 CJR WRITE(*,*) '145'
230  goto 100
231  ENDIF
232  xe=max(xe0,xb*(1./(1.-pypar(24))-1.))
233  zmax=xb/(xb+xe)
234 CJR--end
235  IF(xb+xe.GE.0.999) THEN
236  q2b=0.
237  goto 210
238  ENDIF
239 
240 C...CALCULATE ALTARELLI-PARISI AND STRUCTURE FUNCTION WEIGHTS
241  DO 150 ifl=-6,6
242  wtap(ifl)=0.
243  150 wtsf(ifl)=0.
244  IF(iflb.EQ.0) THEN
245  wtapq=16.*(1.-sqrt(xb+xe))/(3.*sqrt(xb))
246  DO 160 ifl=-ipy(8),ipy(8)
247  IF(ifl.EQ.0) wtap(ifl)=6.*alog((1.-xb)/xe)
248  160 IF(ifl.NE.0) wtap(ifl)=wtapq
249  ELSE
250  wtap(0)=0.5*xb*(1./(xb+xe)-1.)
251  wtap(iflb)=8.*alog((1.-xb)*(xb+xe)/xe)/3.
252  ENDIF
253  170 wtsum=0.
254  IF(ihfc.EQ.0) THEN
255  DO 180 ifl=-ipy(8),ipy(8)
256  wtsf(ifl)=xfb(ifl)/max(1e-10,xfb(iflb))
257  180 wtsum=wtsum+wtap(ifl)*wtsf(ifl)
258  IF(iabs(iflb).GE.4.AND.wtsum.GT.1e3) THEN
259  ihfx=1
260  DO 185 ifl=-ipy(8),ipy(8)
261  185 wtsf(ifl)=wtsf(ifl)*1e3/wtsum
262  wtsum=1e3
263  ENDIF
264  ENDIF
265 
266 C...CHOOSE NEW T AND FLAVOUR
267 CJR 190 IF(IPY(14).LE.6.OR.IPY(14).GE.9) THEN
268 CJR--begin
269  njr=0
270 190 CONTINUE
271  seaquark=.false.
272  njr=njr+1
273  IF (njr.GT.100) THEN
274 CJR WRITE(*,*) '190'
275  goto 100
276  ENDIF
277 CJR--end
278  IF(ipy(14).LE.6.OR.ipy(14).GE.9) THEN
279  tevxp=b0/max(0.0001,wtsum)
280  ELSE
281  tevxp=b0/max(0.0001,5.*wtsum)
282  ENDIF
283  tevb=tevb*exp(max(-100.,alog(rlu(0))*tevxp))
284  q2ref=pypar(21)**2*exp(tevb)/pypar(27)
285  q2b=q2ref/pypar(27)
286  dq2b=q2b
287  IF(ilep.GE.1) THEN
288  dshz=dsh
289  IF(n.GT.ns+4) dshz=(dsh+dq2(jr)-dq2(jt))/dble(zs(jt))-dq2(jr)+
290  & dq2b
291  ENDIF
292 CJR--begin --
293 CAE--seaquarks up to LST(12), if the quark density != 0
294  IF( lst(35).EQ.1) THEN
295  IF( q2b.LT.pypar(22) .AND.
296  & (abs(iflb).LE.lst(12).AND.abs(iflb).GE.1)) THEN
297  q2ref=min(pypar(22),q2s(jt))
298  q2b=min(pypar(22),q2s(jt))
299  IF(ilep.GE.1.AND.n.EQ.ns+2) THEN
300  xt=x(jt)*(1.+(dsh-q2b)/dq2(jr))
301  ELSE
302  xt=xb
303  ENDIF
304  CALL lystfu(ipy(40+jt),xt,q2ref,xft)
305  IF(xft(iflb).EQ.0.0.AND.xft(-iflb).EQ.0.0) THEN
306  searatio=1.0
307  ELSEIF(xft(abs(iflb)).EQ.0.0) THEN
308  searatio=1.0
309  ELSE
310  searatio=xft(-abs(iflb))/xft(abs(iflb))
311  ENDIF
312 CJR-- (protons only)
313  IF (rlu(0).LT.searatio) THEN
314  seaquark=.true.
315  xquark=xt
316  ELSE
317  q2b=0.
318  seaquark=.false.
319  ENDIF
320  ENDIF
321  ENDIF
322 CJR--end
323  IF(q2b.LT.pypar(22)) THEN
324  q2b=0.
325 CJR--begin
326  seaquark=.false.
327 CJR--end
328  ELSE
329  wtran=rlu(0)*wtsum
330  ifla=-ipy(8)-1
331  200 ifla=ifla+1
332  wtran=wtran-wtap(ifla)*wtsf(ifla)
333  IF(ifla.LT.ipy(8).AND.wtran.GT.0.) goto 200
334 
335 CJR--begin
336  IF (seaquark) THEN
337  seafl=-iflb
338  ifla=0
339 CT XE=XB*(1./(1.-0.001)-1.)
340  ENDIF
341 CJR--end
342 
343 C...CHOOSE Z VALUE AND CORRECTIVE WEIGHT
344  IF(iflb.EQ.0.AND.ifla.EQ.0) THEN
345  z=1./(1.+((1.-xb)/xb)*(xe/(1.-xb))**rlu(0))
346  wtz=(1.-z*(1.-z))**2
347  ELSEIF(iflb.EQ.0) THEN
348  z=xb/(1.-rlu(0)*(1.-sqrt(xb+xe)))**2
349  wtz=0.5*(1.+(1.-z)**2)*sqrt(z)
350  ELSEIF(ifla.EQ.0) THEN
351  z=xb*(1.+rlu(0)*(1./(xb+xe)-1.))
352  wtz=1.-2.*z*(1.-z)
353  ELSE
354  z=1.-(1.-xb)*(xe/((xb+xe)*(1.-xb)))**rlu(0)
355  wtz=0.5*(1.+z**2)
356  ENDIF
357 CJR--begin
358 C IF (SEAQUARK) THEN
359 C XSEA=LEXSEA(0.15*XT,Q2B)
360 C XE=MIN(XE,XSEA)
361 C Z=XT/(XSEA+XT)
362 C ENDIF
363 CJR--end
364 C...REWEIGHT FIRST LEG BECAUSE OF MODIFIED XB OR CHECK PHASE SPACE
365  IF(ilep.GE.1.AND.n.EQ.ns+2) THEN
366  xbnew=x(jt)*(1.+(dsh-q2b)/dq2(jr))
367  IF(xbnew.GT.min(z,0.999)) goto 190
368  xb=xbnew
369  ENDIF
370 C...SUM UP SOFT GLUON EMISSION AS EFFECTIVE Z SHIFT
371 CJR-- should this realy always be done ??
372  IF(ipy(15).GE.1) THEN
373  rsoft=6.
374  IF(iflb.NE.0) rsoft=8./3.
375  z=z*(tevb/tevs(jt))**(rsoft*xe/((xb+xe)*b0))
376  IF(z.LE.xb) goto 190
377 CJR--begin
378  zsoft=(tevb/tevs(jt))**(rsoft*xe/((xb+xe)*b0))
379  zmax=xb/(xb+xe)
380 CJR--end
381  ENDIF
382 C...CHECK IF HEAVY FLAVOUR BELOW THRESHOLD
383  ihft=0
384 CIC...Skip for intrinsic charm/bottom simulation, charm quark should
385 CIC...not come from gluon but is non-perturbative part of proton.
386  IF(lst(15).EQ.-4.OR.lst(15).EQ.-5) goto 205
387  mstj(93)=1
388  IF(ilep.GE.1.AND.iabs(iflb).GE.4.AND.(xfb(iflb).LT.1e-10.OR.
389  & q2b.LT.5.*ulmass(iabs(iflb))**2)) THEN
390  ihft=1
391  ifla=0
392  ENDIF
393  205 CONTINUE
394 
395 C...FOR LEPTOPRODUCTION, CHECK Z AGAINST NEW LIMIT
396  IF(ilep.GE.1) THEN
397  dpd(2)=dshz+dq2(jr)+dq2b
398  mstj(93)=1
399  dm2=ulmass(iabs(ifla-iflb))**2
400  IF(iabs(ifla-iflb).EQ.0) dm2=ulmass(21)**2
401  dpc(1)=dq2(jr)*(dq2b+dm2)**2
402  dpc(2)=dpd(2)*(dpd(2)-2d0*dq2b)*(dq2b+dm2)
403  dpc(3)=dq2b*(dpd(2)-2d0*dq2b)**2
404  zu=(dpc(2)-dsqrt(dpc(2)**2-4d0*dpc(1)*dpc(3)))/(2d0*dpc(1))
405  IF(z.GE.zu) goto 190
406  ENDIF
407 
408 C...OPTION WITH EVOLUTION IN KT2=(1-Z)Q2:
409  IF(ipy(14).GE.5.AND.ipy(14).LE.6.AND.n.LE.ns+4) THEN
410 C...CHECK THAT (Q2)LAST BRANCHING < (Q2)HARD
411  IF(q2b/(1.-z).GT.pypar(26)*q2) goto 190
412  ELSEIF(ipy(14).GE.3.AND.ipy(14).LE.6.AND.n.GE.ns+6) THEN
413 C...CHECK THAT Z,Q2 COMBINATION IS KINEMATICALLY ALLOWED
414  q2max=0.5*(1./zs(jt)+1.)*dq2(jt)+0.5*(1./zs(jt)-1.)*
415  & (dq2(3-jt)-dsh+sqrt((dsh+dq2(1)+dq2(2))**2+8.*dq2(1)*dq2(2)*
416  & zs(jt)/(1.-zs(jt))))
417  IF(q2b/(1.-z).GE.q2max) goto 190
418 
419  ELSEIF(ipy(14).EQ.7.OR.ipy(14).EQ.8) THEN
420 C...OPTION WITH ALPHAS((1-Z)Q2): DEMAND KT2 > CUTOFF, REWEIGHT
421  IF((1.-z)*q2b.LT.pypar(22)) goto 190
422  alprat=tevb/(tevb+alog(1.-z))
423  IF(alprat.LT.5.*rlu(0)) goto 190
424  IF(alprat.GT.5.) wtz=wtz*alprat/5.
425  ENDIF
426 
427 C...WEIGHTING WITH NEW STRUCTURE FUNCTIONS
428  CALL lystfu(ipy(40+jt),xb,q2ref,xfb)
429  xa=xb/z
430  CALL lystfu(ipy(40+jt),xa,q2ref,xfa)
431  IF(ihft.EQ.1.OR.ihfx.EQ.1) THEN
432  IF(xfa(ifla).LT.1e-10) ihfc=1
433  goto 210
434  ELSEIF(xfb(iflb).LT.1e-20) THEN
435  goto 100
436  ENDIF
437  IF(wtz*xfa(ifla)/xfb(iflb).LT.rlu(0)*wtsf(ifla)) THEN
438  IF(ilep.GE.1.AND.n.EQ.ns+2) goto 145
439  goto 170
440  ENDIF
441 CJR--begin
442  IF (seaquark) THEN
443  split=.true.
444  xgluon=xa
445  xsea=xa-xb
446  zsplit=z
447  seaquark=.false.
448  ENDIF
449 CJR--end
450  ENDIF
451 
452 210 CONTINUE
453  IF(n.EQ.ns+4-2*min(1,ilep)) THEN
454 C...DEFINE TWO HARD SCATTERERS IN THEIR CM-FRAME
455  dq2(jt)=q2b
456  IF(ipy(14).GE.3.AND.ipy(14).LE.6) dq2(jt)=q2b/(1.-z)
457  IF(ilep.EQ.0) THEN
458  dplcm=dsqrt((dsh+dq2(1)+dq2(2))**2-4.*dq2(1)*dq2(2))/dshr
459  DO 220 jr=1,2
460  i=ns+2*jr-1
461  ipo=19+2*jr
462  k(i,1)=14
463  k(i,2)=ifls(jr+2)
464  IF(ifls(jr+2).EQ.0) k(i,2)=21
465  k(i,3)=0
466  k(i,4)=ipo
467  k(i,5)=ipo
468  p(i,1)=0.
469  p(i,2)=0.
470  p(i,3)=dplcm*(-1)**(jr+1)
471  p(i,4)=(dsh+dq2(3-jr)-dq2(jr))/dshr
472  p(i,5)=-sqrt(sngl(dq2(jr)))
473  k(i+1,1)=-1
474  k(i+1,2)=k(ipo+1,2)
475  k(i+1,3)=i
476  k(i+1,4)=0
477  k(i+1,5)=0
478  p(i+1,1)=0.
479  p(i+1,2)=0.
480  p(i+1,3)=ipo
481  p(i+1,4)=ipo
482  p(i+1,5)=0.
483  p(ipo+1,1)=i
484  p(ipo+1,2)=i
485  k(ipo,4)=mod(k(ipo,4),mstu(5))+i*mstu(5)
486  k(ipo,5)=mod(k(ipo,5),mstu(5))+i*mstu(5)
487  220 CONTINUE
488  ELSE
489 C..LEPTOPRODUCTION EVENTS: BOSON AND HADRON REST FRAME
490  i1=ns+2*ilep-1
491  i2=ns-2*ilep+5
492  DO 225 itemp=ns+1,ns+4
493  DO 225 j=1,5
494  k(itemp,j)=0
495  225 p(itemp,j)=0.
496  DO 230 j=1,5
497  230 p(i1,j)=p(nq,j)
498  k(ns+1,1)=11
499  k(ns+3,1)=14
500  IF(ilep.EQ.2) THEN
501  k(ns+1,1)=14
502  k(ns+3,1)=11
503  ENDIF
504  k(ns+2,1)=-1
505  k(ns+4,1)=-1
506  k(ns+1,3)=0
507  k(ns+2,3)=ns+1
508  k(ns+3,3)=0
509  k(ns+4,3)=ns+3
510  k(i1,2)=kfl(2,ilep)
511  k(i2,2)=kfl(2,3-ilep)
512  dpd(1)=dsh+dq2(1)+dq2(2)
513  dpd(3)=(3-2*ilep)*dsqrt(dpd(1)**2-4d0*dq2(1)*dq2(2))
514  p(i2,3)=(dpqs(2)*dpd(3)-dpqs(1)*dpd(1))/
515  & (2d0*dq2(jr))
516  p(i2,4)=(dpqs(1)*dpd(3)-dpqs(2)*dpd(1))/
517  & (2d0*dq2(jr))
518  p(i2,5)=-sqrt(sngl(dq2(3-ilep)))
519  p(i2+1,3)=max(ipu1,ipu2)
520  p(i2+1,4)=max(ipu1,ipu2)
521  k(i2,4)=k(i2,4)-mod(k(i2,4),mstu(5))+max(ipu1,ipu2)
522  k(i2,5)=k(i2,5)-mod(k(i2,5),mstu(5))+max(ipu1,ipu2)
523  p(26-2*ilep,1)=i2
524  p(26-2*ilep,2)=i2
525  k(25-2*ilep,4)=mod(k(25-2*ilep,4),mstu(5))+i2*mstu(5)
526  k(25-2*ilep,5)=mod(k(25-2*ilep,5),mstu(5))+i2*mstu(5)
527  n=n+2
528  ENDIF
529 
530  ELSEIF(n.GT.ns+4) THEN
531 C...FIND MAXIMUM ALLOWED MASS OF TIMELIKE PARTON
532  dq2(3)=q2b
533  IF(ipy(14).GE.3.AND.ipy(14).LE.6) dq2(3)=q2b/(1.-z)
534  IF(is(1).GE.1.AND.is(1).LE.mstu(4)) THEN
535  dpc(1)=p(is(1),4)
536  dpc(3)=0.5*(abs(p(is(1),3))+abs(p(is(2),3)))
537  ELSE
538 C...IS(1) not initialized
539  dpc(1)=0.
540  dpc(3)=0.5*( 0. +abs(p(is(2),3)))
541  ENDIF
542  dpc(2)=p(is(2),4)
543  dpd(1)=dsh+dq2(jr)+dq2(jt)
544  dpd(2)=dshz+dq2(jr)+dq2(3)
545  dpd(3)=dsqrt(dpd(1)**2-4.*dq2(jr)*dq2(jt))
546  dpd(4)=dsqrt(dpd(2)**2-4.*dq2(jr)*dq2(3))
547  ikin=0
548  IF((q2s(jr).GE.0.5*pypar(22).AND.dpd(1)-dpd(3).GE.1d-10*dpd(1))
549  & .OR.ilep.GE.1) ikin=1
550  IF(ikin.EQ.0) dmsma=(dq2(jt)/dble(zs(jt))-dq2(3))*(dsh/
551  & (dsh+dq2(jt))-dsh/(dshz+dq2(3)))
552  IF(ikin.EQ.1) dmsma=(dpd(1)*dpd(2)-dpd(3)*dpd(4))/(2.*
553  & dq2(jr))-dq2(jt)-dq2(3)
554 
555 C...GENERATE TIMELIKE PARTON SHOWER (IF REQUIRED)
556  it=n-1
557  k(it,1)=3
558  k(it,2)=iflb-ifls(jt+2)
559  IF(iflb-ifls(jt+2).EQ.0) k(it,2)=21
560  mstj(93)=1
561  p(it,5)=ulmass(k(it,2))
562  IF(sngl(dmsma).LE.p(it,5)**2) goto 100
563  p(it,2)=0.
564  DO 240 j=1,5
565  k(it+1,j)=0
566  240 p(it+1,j)=0.
567  k(it+1,1)=-1
568  k(it+1,2)=k(is(jt)+1,2)
569  k(it+1,3)=it
570  IF(mod(ipy(14),2).EQ.0) THEN
571  p(it,1)=0.
572  IF(ilep.EQ.0) p(it,4)=(dshz-dsh-p(it,5)**2)/dshr
573  IF(ilep.GE.1) p(it,4)=0.5*(p(is(jt),3)*dpd(2)+
574  & dpqs(1)*(dq2(jt)+dq2(3)+p(it,5)**2))/(p(is(jt),3)*dpqs(2)-
575  & p(is(jt),4)*dpqs(1))-dpc(jt)
576  p(it,3)=sqrt(max(0.,p(it,4)**2-p(it,5)**2))
577  CALL lushow(it,0,sqrt(min(sngl(dmsma),pypar(25)*q2)))
578  IF(n.GE.it+2) p(it,5)=p(it+2,5)
579  IF(n.GT.mstu(4)-10) THEN
580  WRITE(6,*) ' LYSSPA: no more memory in LUJETS'
581  lst(21)=19
582  RETURN
583  ENDIF
584  DO 243 i=n+1,n+8
585  DO 243 j=1,5
586  k(i,j)=0
587  243 p(i,j)=0.
588  ENDIF
589 
590 C...RECONSTRUCT KINEMATICS OF BRANCHING: TIMELIKE PARTON SHOWER
591  dms=p(it,5)**2
592  IF(ikin.EQ.0.AND.ilep.EQ.0) dpt2=(dmsma-dms)*(dshz+dq2(3))/
593  & (dsh+dq2(jt))
594  IF(ikin.EQ.1.AND.ilep.EQ.0) dpt2=(dmsma-dms)*(0.5*dpd(1)*
595  & dpd(2)+0.5*dpd(3)*dpd(4)-dq2(jr)*(dq2(jt)+dq2(3)+dms))/
596  & (4.*dsh*dpc(3)**2)
597  IF(ikin.EQ.1.AND.ilep.GE.1) dpt2=(dmsma-dms)*(0.5*dpd(1)*
598  & dpd(2)+0.5*dpd(3)*dpd(4)-dq2(jr)*(dq2(jt)+dq2(3)+dms))/
599  & dpd(3)**2
600  IF(dpt2.LT.0.) goto 100
601  k(it,3)=n+1
602  p(it,1)=sqrt(sngl(dpt2))
603  IF(ilep.EQ.0) THEN
604  dpb(1)=(0.5*dpd(2)-dpc(jr)*(dshz+dq2(jr)-dq2(jt)-dms)/
605  & dshr)/dpc(3)-dpc(3)
606  p(it,3)=dpb(1)*(-1)**(jt+1)
607  p(it,4)=(dshz-dsh-dms)/dshr
608  ELSE
609  dpc(3)=dq2(jt)+dq2(3)+dms
610  dpb(2)=dpqs(2)*dble(p(is(jt),3))-dpqs(1)*dpc(jt)
611  dpb(1)=0.5d0*(dpc(jt)*dpd(2)+dpqs(2)*dpc(3))/dpb(2)-
612  & dble(p(is(jt),3))
613  p(it,3)=dpb(1)
614  p(it,4)=0.5d0*(dble(p(is(jt),3))*dpd(2)+
615  & dpqs(1)*dpc(3))/dpb(2)-dpc(jt)
616  ENDIF
617  IF(n.GE.it+2) THEN
618  mstu(1)=it+2
619  dpb(1)=dsqrt(dpb(1)**2+dpt2)
620  dpb(2)=dsqrt(dpb(1)**2+dms)
621  dpb(3)=p(it+2,3)
622  dpb(4)=dsqrt(dpb(3)**2+dms)
623  dbez=(dpb(4)*dpb(1)-dpb(3)*dpb(2))/(dpb(4)*dpb(2)-dpb(3)*
624  & dpb(1))
625  CALL ludbrb(mstu(1),mstu(2),0.,0.,0.d0,0.d0,dbez)
626  the=ulangl(p(it,3),p(it,1))
627  CALL ludbrb(mstu(1),mstu(2),the,0.,0.d0,0.d0,0.d0)
628  ENDIF
629 
630 C...RECONSTRUCT KINEMATICS OF BRANCHING: SPACELIKE PARTON
631  k(n+1,1)=14
632  k(n+1,2)=iflb
633  IF(iflb.EQ.0) k(n+1,2)=21
634  k(n+1,3)=0
635 CJR--begin
636 CJR-- give all radiated partons 5 as mother particle
637  k(n+1,3)=5
638 CJR--end
639  p(n+1,1)=p(it,1)
640  p(n+1,2)=0.
641  p(n+1,3)=p(it,3)+p(is(jt),3)
642  p(n+1,4)=p(it,4)+p(is(jt),4)
643  p(n+1,5)=-sqrt(sngl(dq2(3)))
644  DO 250 j=1,5
645  k(n+2,j)=0
646  250 p(n+2,j)=0.
647  k(n+2,1)=-1
648  k(n+2,2)=k(is(jt)+1,2)
649  k(n+2,3)=n+1
650 
651 C...DEFINE COLOUR FLOW OF BRANCHING
652  k(is(jt),1)=14
653  k(is(jt),3)=n+1
654  id1=it
655  kn1=isign(500+iabs(k(n+1,2)),2*k(n+1,2)+1)
656  kd1=isign(500+iabs(k(id1,2)),2*k(id1,2)+1)
657  IF(k(n+1,2).EQ.21) kn1=500
658  IF(k(id1,2).EQ.21) kd1=500
659  IF((kn1.GE.501.AND.kd1.GE.501).OR.(kn1.LT.0.AND.
660  & kd1.EQ.500).OR.(kn1.EQ.500.AND.kd1.EQ.500.AND.
661  & rlu(0).GT.0.5).OR.(kn1.EQ.500.AND.kd1.LT.0))
662  & id1=is(jt)
663  id2=it+is(jt)-id1
664  p(n+2,3)=id1
665  p(n+2,4)=id2
666  p(id1+1,1)=n+1
667  p(id1+1,2)=id2
668  p(id2+1,1)=id1
669  p(id2+1,2)=n+1
670  k(n+1,4)=k(n+1,4)-mod(k(n+1,4),mstu(5))+id1
671  k(n+1,5)=k(n+1,5)-mod(k(n+1,5),mstu(5))+id2
672  k(id1,4)=mod(k(id1,4),mstu(5))+(n+1)*mstu(5)
673  k(id1,5)=mod(k(id1,5),mstu(5))+id2*mstu(5)
674  k(id2,4)=mod(k(id2,4),mstu(5))+id1*mstu(5)
675  k(id2,5)=mod(k(id2,5),mstu(5))+(n+1)*mstu(5)
676  n=n+2
677 C CALL GULIST(22,2)
678 
679 C...BOOST TO NEW CM-FRAME
680  mstu(1)=ns+1
681  IF(ilep.EQ.0) THEN
682  CALL ludbrb(mstu(1),mstu(2),0.,0.,
683  & -dble(p(n-1,1)+p(is(jr),1))/dble(p(n-1,4)+p(is(jr),4)),
684  & 0.d0,-dble(p(n-1,3)+p(is(jr),3))/dble(p(n-1,4)+p(is(jr),4)))
685  ir=n-1+(jt-1)*(is(1)-n+1)
686  CALL ludbrb(mstu(1),mstu(2),
687  & -ulangl(p(ir,3),p(ir,1)),paru(2)*rlu(0),0.d0,0.d0,0.d0)
688  ELSE
689 C...REORIENTATE EVENT WITHOUT CHANGING THE BOSON FOUR MOMENTUM
690  DO 260 j=1,4
691  260 dpq(j)=p(nq,j)
692  dbe1(4)=dpq(4)+dble(p(n-1,4))
693  DO 270 j=1,3,2
694  270 dbe1(j)=-(dpq(j)+dble(p(n-1,j)))/dbe1(4)
695  dtemp=1.d0-dbe1(1)**2-dbe1(3)**2
696  IF(dtemp.LE.0.d0) THEN
697  lst(21)=20
698  IF(lst(3).GE.1) WRITE(6,*) ' Warning from LYSSPA: sqrt of',
699  & dtemp,' New event generated.'
700  RETURN
701  ENDIF
702  dbe1(4)=1.d0/dsqrt(dtemp)
703  dbep=dbe1(1)*dpq(1)+dbe1(3)*dpq(3)
704  dgabep=dbe1(4)*(dbe1(4)*dbep/(1d0+dbe1(4))+dpq(4))
705  DO 280 j=1,3,2
706  280 dpq(j)=dpq(j)+dgabep*dbe1(j)
707  dpq(4)=dbe1(4)*(dpq(4)+dbep)
708  dpc(1)=dsqrt(dpq(1)**2+dpq(3)**2)
709  dbe2(4)=-(dpq(4)*dpc(1)-dpqs(2)*dsqrt(dpqs(2)**2+dpc(1)**2-
710  & dpq(4)**2))/(dpc(1)**2+dpqs(2)**2)
711  the=ulangl(sngl(dpq(3)),sngl(dpq(1)))
712  dbe2(1)=dbe2(4)*dsin(dble(the))
713  dbe2(3)=dbe2(4)*dcos(dble(the))
714  dbe2(4)=1d0/(1d0-dbe2(1)**2-dbe2(3)*2)
715 
716 C...CONSTRUCT THE COMBINED BOOST
717  dpb(1)=dbe1(4)**2*dbe2(4)/(1d0+dbe1(4))
718  dpb(2)=dbe1(1)*dbe2(1)+dbe1(3)*dbe2(3)
719  dpb(3)=dbe1(4)*dbe2(4)*(1d0+dpb(2))
720  DO 290 jb=1,3,2
721  290 drobo(jb+2)=(dbe1(4)*dbe2(4)*dbe1(jb)+dbe2(4)*dbe2(jb)+
722  & dpb(1)*dbe1(jb)*dpb(2))/dpb(3)
723  CALL ludbrb(mstu(1),mstu(2),0.,0.,drobo(3),0.d0,drobo(5))
724  IF(ilep.EQ.1) the=ulangl(p(ns+1,3),p(ns+1,1))
725  IF(ilep.EQ.2) the=paru(1)+ulangl(p(ns+3,3),p(ns+3,1))
726  CALL ludbrb(mstu(1),mstu(2),-the,paru(2)*rlu(0),0d0,0d0,0d0)
727  ENDIF
728  mstu(1)=0
729  ENDIF
730 
731 C...SAVE QUANTITIES, LOOP BACK
732  is(jt)=n-1
733  IF(ilep.EQ.2.AND.n.EQ.ns+4) is(jt)=n-3
734  q2s(jt)=q2b
735  dq2(jt)=q2b
736  IF(ipy(14).GE.3.AND.ipy(14).LE.6) dq2(jt)=q2b/(1.-z)
737  dsh=dshz
738  IF(q2b.GE.0.5*pypar(22)) THEN
739  ifls(jt+2)=ifls(jt)
740  ifls(jt)=ifla
741  xs(jt)=xa
742  zs(jt)=z
743  DO 300 ifl=-6,6
744  300 xfs(jt,ifl)=xfa(ifl)
745  tevs(jt)=tevb
746  ELSE
747  IF(jt.EQ.1) ipu1=n-1
748  IF(jt.EQ.2) ipu2=n-1
749  ENDIF
750  IF(max(iabs(1-ilep)*q2s(1),min(1,2-ilep)*q2s(2)).GE.0.5*pypar(22)
751  &.OR.n.LE.ns+2) goto 130
752 
753  IF(ilep.EQ.0) THEN
754 C...BOOST HARD SCATTERING PARTONS TO FRAME OF SHOWER INITIATORS
755  DO 310 j=1,3
756  310 drobo(j+2)=(p(ns+1,j)+p(ns+3,j))/(p(ns+1,4)+p(ns+3,4))
757  DO 320 j=1,5
758  320 p(n+2,j)=p(ns+1,j)
759  mstu(1)=n+2
760  mstu(2)=n+2
761  CALL ludbrb(n+2,n+2,0.,0.,-drobo(3),-drobo(4),-drobo(5))
762  robo(2)=ulangl(p(n+2,1),p(n+2,2))
763  robo(1)=ulangl(p(n+2,3),sqrt(p(n+2,1)**2+p(n+2,2)**2))
764  mstu(1)=4
765  mstu(2)=ns
766  CALL ludbrb(4,ns,robo(1),robo(2),drobo(3),drobo(4),drobo(5))
767  mstu(1)=0
768  mstu(2)=0
769  ENDIF
770 
771 C...STORE USER INFORMATION
772  k(21,1)=14
773  IF(ilep.NE.0) k(21,1)=11
774  k(23,1)=14
775  k(21,3)=ns+1
776  k(23,3)=ns+3
777  DO 330 jt=1,2
778  kfl(1,jt)=ifls(jt)
779  IF(ifls(jt).EQ.0) kfl(1,jt)=21
780  330 pyvar(30+jt)=xs(jt)
781 
782  DO 340 i=ns+1,n
783  DO 340 j=1,5
784  340 v(i,j)=0.
785 
786 CJR--begin
787  lastfl=ifla
788 CJR--end
789 
790  RETURN
791  END