Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pykfdi.f
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file pykfdi.f
1 
2 C********************************************************************
3 
4 C...PYKFDI
5 C...Generates a new flavour pair and combines off a hadron
6 
7  SUBROUTINE pykfdi(KFL1,KFL2,KFL3,KF)
8 
9 C...Double precision and integer declarations.
10  IMPLICIT DOUBLE PRECISION(a-h, o-z)
11  IMPLICIT INTEGER(i-n)
12  INTEGER pyk,pychge,pycomp
13 C...Commonblocks.
14  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
15  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
16  SAVE /pydat1/,/pydat2/
17 C...Local arrays.
18  dimension pd(7)
19 
20  IF(mstu(123).EQ.0.AND.mstj(12).GE.0) CALL pykfin
21 
22 C...Default flavour values. Input consistency checks.
23  kf1a=iabs(kfl1)
24  kf2a=iabs(kfl2)
25  kfl3=0
26  kf=0
27  IF(kf1a.EQ.0) RETURN
28  IF(kf2a.NE.0)THEN
29  IF(kf1a.LE.10.AND.kf2a.LE.10.AND.kfl1*kfl2.GT.0) RETURN
30  IF(kf1a.GT.10.AND.kf2a.GT.10) RETURN
31  IF((kf1a.GT.10.OR.kf2a.GT.10).AND.kfl1*kfl2.LT.0) RETURN
32  ENDIF
33 
34 C...Check if tabulated flavour probabilities are to be used.
35  IF(mstj(15).EQ.1) THEN
36  IF(mstj(12).GE.5) CALL pyerrm(29,
37  & '(PYKFDI:) Sorry, option MSTJ(15)=1 not available' //
38  & ' together with MSTJ(12)>=5 modification')
39  ktab1=-1
40  IF(kf1a.GE.1.AND.kf1a.LE.6) ktab1=kf1a
41  kfl1a=mod(kf1a/1000,10)
42  kfl1b=mod(kf1a/100,10)
43  kfl1s=mod(kf1a,10)
44  IF(kfl1a.GE.1.AND.kfl1a.LE.4.AND.kfl1b.GE.1.AND.kfl1b.LE.4)
45  & ktab1=6+kfl1a*(kfl1a-2)+2*kfl1b+(kfl1s-1)/2
46  IF(kfl1a.GE.1.AND.kfl1a.LE.4.AND.kfl1a.EQ.kfl1b) ktab1=ktab1-1
47  IF(kf1a.GE.1.AND.kf1a.LE.6) kfl1a=kf1a
48  ktab2=0
49  IF(kf2a.NE.0) THEN
50  ktab2=-1
51  IF(kf2a.GE.1.AND.kf2a.LE.6) ktab2=kf2a
52  kfl2a=mod(kf2a/1000,10)
53  kfl2b=mod(kf2a/100,10)
54  kfl2s=mod(kf2a,10)
55  IF(kfl2a.GE.1.AND.kfl2a.LE.4.AND.kfl2b.GE.1.AND.kfl2b.LE.4)
56  & ktab2=6+kfl2a*(kfl2a-2)+2*kfl2b+(kfl2s-1)/2
57  IF(kfl2a.GE.1.AND.kfl2a.LE.4.AND.kfl2a.EQ.kfl2b) ktab2=ktab2-1
58  ENDIF
59  IF(ktab1.GE.0.AND.ktab2.GE.0) goto 140
60  ENDIF
61 
62 C.. Recognize rank 0 diquark case
63  100 irank=1
64  kfdiq=max(kf1a,kf2a)
65  IF(kfdiq.GT.10.AND.kfdiq.LT.10000) irank=0
66 
67 C.. Join two flavours to meson or baryon. Test for popcorn.
68  IF(kf2a.GT.0)THEN
69  mbary=0
70  IF(kfdiq.GT.10) THEN
71  IF(irank.EQ.0.AND.mstj(12).LT.5)
72  & CALL pynmes(kfdiq)
73  IF(mstu(121).NE.0) THEN
74  mstu(121)=0
75  RETURN
76  ENDIF
77  mbary=2
78  ENDIF
79  kfqold=kf1a
80  kfqver=kf2a
81  goto 130
82  ENDIF
83 
84 C.. Separate incoming flavours, curtain flavour consistency check
85  kfin=kfl1
86  kfqold=kf1a
87  kfqpop=kf1a/10000
88  IF(kf1a.GT.10)THEN
89  kfin=-kfl1
90  kfl1a=mod(kf1a/1000,10)
91  kfl1b=mod(kf1a/100,10)
92  IF(irank.EQ.0)THEN
93  qawt=1d0
94  IF(kfl1a.GE.3) qawt=parf(136+kfl1a/4)
95  IF(kfl1b.GE.3) qawt=qawt/parf(136+kfl1b/4)
96  kfqpop=kfl1a+(kfl1b-kfl1a)*int(1d0/(qawt+1d0)+pyr(0))
97  ENDIF
98  IF(kfqpop.NE.kfl1b.AND.kfqpop.NE.kfl1a) THEN
99  mstu(121)=0
100  RETURN
101  ENDIF
102  kfqold=kfl1a+kfl1b-kfqpop
103  ENDIF
104 
105 C...Meson/baryon choice. Set number of mesons if starting a popcorn
106 C...system.
107  110 mbary=0
108  IF(kf1a.LE.10.AND.mstj(12).GT.0)THEN
109  IF(mstu(121).EQ.-1.OR.(1d0+parj(1))*pyr(0).GT.1d0)THEN
110  mbary=1
111  CALL pynmes(0)
112  ENDIF
113  ELSEIF(kf1a.GT.10)THEN
114  mbary=2
115  IF(irank.EQ.0) CALL pynmes(kf1a)
116  IF(mstu(121).GT.0) mbary=-1
117  ENDIF
118 
119 C..x->H+q: Choose single vertex quark. Jump to form hadron.
120  IF(mbary.EQ.0.OR.mbary.EQ.2)THEN
121  kfqver=1+int((2d0+parj(2))*pyr(0))
122  kfl3=isign(kfqver,-kfin)
123  goto 130
124  ENDIF
125 
126 C..x->H+qq: (IDW=proper PARF position for diquark weights)
127  idw=160
128  IF(mbary.EQ.1)THEN
129  IF(mstu(121).EQ.0) idw=150
130  sqwt=parf(idw+1)
131  IF(mstu(121).GT.0) sqwt=sqwt*parf(135)*parf(138)**mstu(121)
132  kfqpop=1+int((2d0+sqwt)*pyr(0))
133 C.. Shift to s-curtain parameters if needed
134  IF(kfqpop.GE.3.AND.mstj(12).GE.5)THEN
135  parf(194)=parf(138)*parf(139)
136  parf(193)=parj(8)+parj(9)
137  ENDIF
138  ENDIF
139 
140 C.. x->H+qq: Get vertex quark
141  IF(mbary.EQ.-1.AND.mstj(12).GE.5)THEN
142  idw=mstu(122)
143  mstu(121)=mstu(121)-1
144  IF(idw.EQ.170) THEN
145  IF(mstu(121).EQ.0)THEN
146  ipos=3*min(kfqpop-1,2)+min(kfqold-1,2)
147  ELSE
148  ipos=3*3+3*max(0,min(kfqpop-2,1))+min(kfqold-1,2)
149  ENDIF
150  ELSE
151  IF(mstu(121).EQ.0)THEN
152  ipos=3*5+5*min(kfqpop-1,3)+min(kfqold-1,4)
153  ELSE
154  ipos=3*5+5*4+min(kfqold-1,4)
155  ENDIF
156  ENDIF
157  ipos=200+30*ipos+1
158 
159  imes=-1
160  rmes=pyr(0)*parf(194)
161  120 imes=imes+1
162  rmes=rmes-parf(ipos+imes)
163  IF(imes.EQ.30) THEN
164  mstu(121)=-1
165  kf=-111
166  RETURN
167  ENDIF
168  IF(rmes.GT.0d0) goto 120
169  kmul=imes/5
170  kfj=2*kmul+1
171  IF(kmul.EQ.2) kfj=10003
172  IF(kmul.EQ.3) kfj=10001
173  IF(kmul.EQ.4) kfj=20003
174  IF(kmul.EQ.5) kfj=5
175  idiag=0
176  kfqver=mod(imes,5)+1
177  IF(kfqver.GE.kfqold) kfqver=kfqver+1
178  IF(kfqver.GT.3)THEN
179  idiag=kfqver-3
180  kfqver=kfqold
181  ENDIF
182  ELSE
183  IF(mbary.EQ.-1) idw=170
184  sqwt=parf(idw+2)
185  IF(kfqpop.EQ.3) sqwt=parf(idw+3)
186  IF(kfqpop.GT.3) sqwt=parf(idw+3)*(1d0/parf(idw+5)+1d0)/2d0
187  kfqver=min(3,1+int((2d0+sqwt)*pyr(0)))
188  IF(kfqpop.LT.3.AND.kfqver.LT.3)THEN
189  kfqver=kfqpop
190  IF(pyr(0).GT.parf(idw+4)) kfqver=3-kfqpop
191  ENDIF
192  ENDIF
193 
194 C..x->H+qq: form outgoing diquark with KFQPOP flag at 10000-pos
195  kflds=3
196  IF(kfqpop.NE.kfqver)THEN
197  swt=parf(idw+7)
198  IF(kfqver.EQ.3) swt=parf(idw+6)
199  IF(kfqpop.GE.3) swt=parf(idw+5)
200  IF((1d0+swt)*pyr(0).LT.1d0) kflds=1
201  ENDIF
202  kfdiq=900*max(kfqver,kfqpop)+100*(kfqver+kfqpop)+kflds
203  & +10000*kfqpop
204  kfl3=isign(kfdiq,kfin)
205 
206 C..x->M+y: flavour for meson.
207  130 IF(mbary.LE.0)THEN
208  kfla=max(kfqold,kfqver)
209  kflb=min(kfqold,kfqver)
210  kfs=isign(1,kfl1)
211  IF(kfla.NE.kfqold) kfs=-kfs
212 C... Form meson, with spin and flavour mixing for diagonal states.
213  IF(mbary.EQ.-1.AND.mstj(12).GE.5)THEN
214  IF(idiag.GT.0) kf=110*idiag+kfj
215  IF(idiag.EQ.0) kf=(100*kfla+10*kflb+kfj)*kfs*(-1)**kfla
216  RETURN
217  ENDIF
218  IF(kfla.LE.2) kmul=int(parj(11)+pyr(0))
219  IF(kfla.EQ.3) kmul=int(parj(12)+pyr(0))
220  IF(kfla.GE.4) kmul=int(parj(13)+pyr(0))
221  IF(kmul.EQ.0.AND.parj(14).GT.0d0)THEN
222  IF(pyr(0).LT.parj(14)) kmul=2
223  ELSEIF(kmul.EQ.1.AND.parj(15)+parj(16)+parj(17).GT.0d0)THEN
224  rmul=pyr(0)
225  IF(rmul.LT.parj(15)) kmul=3
226  IF(kmul.EQ.1.AND.rmul.LT.parj(15)+parj(16)) kmul=4
227  IF(kmul.EQ.1.AND.rmul.LT.parj(15)+parj(16)+parj(17)) kmul=5
228  ENDIF
229  kfls=3
230  IF(kmul.EQ.0.OR.kmul.EQ.3) kfls=1
231  IF(kmul.EQ.5) kfls=5
232  IF(kfla.NE.kflb)THEN
233  kf=(100*kfla+10*kflb+kfls)*kfs*(-1)**kfla
234  ELSE
235  rmix=pyr(0)
236  imix=2*kfla+10*kmul
237  IF(kfla.LE.3) kf=110*(1+int(rmix+parf(imix-1))+
238  & int(rmix+parf(imix)))+kfls
239  IF(kfla.GE.4) kf=110*kfla+kfls
240  ENDIF
241  IF(kmul.EQ.2.OR.kmul.EQ.3) kf=kf+isign(10000,kf)
242  IF(kmul.EQ.4) kf=kf+isign(20000,kf)
243 
244 C..Optional extra suppression of eta and eta'.
245 C..Allow shift to qq->B+q in old version (set IRANK to 0)
246  IF(kf.EQ.221.OR.kf.EQ.331)THEN
247  IF(pyr(0).GT.parj(25+kf/300))THEN
248  IF(kf2a.GT.0) goto 130
249  IF(mstj(12).LT.4) irank=0
250  goto 110
251  ENDIF
252  ENDIF
253  mstu(121)=0
254 
255 C.. x->B+y: Flavour for baryon
256  ELSE
257  kfla=kfqver
258  IF(kf1a.LE.10) kfla=kfqold
259  kflb=mod(kfdiq/1000,10)
260  kflc=mod(kfdiq/100,10)
261  kflds=mod(kfdiq,10)
262  kfld=max(kfla,kflb,kflc)
263  kflf=min(kfla,kflb,kflc)
264  kfle=kfla+kflb+kflc-kfld-kflf
265 
266 C... SU(6) factors for formation of baryon.
267  kbary=3
268  kdmax=5
269  kflg=kflb
270  IF(kflb.NE.kflc)THEN
271  kbary=2*kflds-1
272  kdmax=1+kflds/2
273  IF(kflb.GT.2) kdmax=kdmax+2
274  ENDIF
275  IF(kfla.NE.kflb.AND.kfla.NE.kflc)THEN
276  kbary=kbary+1
277  kflg=kfla
278  ENDIF
279 
280  su6max=parf(140+kdmax)
281  su6dec=parj(18)
282  su6s =parf(146)
283  IF(mstj(12).GE.5.AND.irank.EQ.0) THEN
284  su6max=1d0
285  su6dec=1d0
286  su6s =1d0
287  ENDIF
288  su6oct=parf(60+kbary)
289  IF(kflg.GT.max(kfla+kflb-kflg,2))THEN
290  su6oct=su6oct*4*su6s/(3*su6s+1)
291  IF(kbary.EQ.2) su6oct=parf(60+kbary)*4/(3*su6s+1)
292  ELSE
293  IF(kbary.EQ.6) su6oct=su6oct*(3+su6s)/(3*su6s+1)
294  ENDIF
295  su6wt=su6oct+su6dec*parf(70+kbary)
296 
297 C.. SU(6) test. Old options enforce new baryon if q->B+qq is rejected.
298  IF(su6wt.LT.pyr(0)*su6max.AND.kf2a.EQ.0)THEN
299  mstu(121)=0
300  IF(mstj(12).LE.2.AND.mbary.EQ.1) mstu(121)=-1
301  goto 110
302  ENDIF
303 
304 C.. Form baryon. Distinguish Lambda- and Sigmalike baryons.
305  ksig=1
306  kfls=2
307  IF(su6wt*pyr(0).GT.su6oct) kfls=4
308  IF(kfls.EQ.2.AND.kfld.GT.kfle.AND.kfle.GT.kflf)THEN
309  ksig=kflds/3
310  IF(kfla.NE.kfld) ksig=int(3*su6s/(3*su6s+kflds**2)+pyr(0))
311  ENDIF
312  kf=isign(1000*kfld+100*kfle+10*kflf+kfls,kfl1)
313  IF(ksig.EQ.0) kf=isign(1000*kfld+100*kflf+10*kfle+kfls,kfl1)
314  ENDIF
315  RETURN
316 
317 C...Use tabulated probabilities to select new flavour and hadron.
318  140 IF(ktab2.EQ.0.AND.mstj(12).LE.0) THEN
319  kt3l=1
320  kt3u=6
321  ELSEIF(ktab2.EQ.0.AND.ktab1.GE.7.AND.mstj(12).LE.1) THEN
322  kt3l=1
323  kt3u=6
324  ELSEIF(ktab2.EQ.0) THEN
325  kt3l=1
326  kt3u=22
327  ELSE
328  kt3l=ktab2
329  kt3u=ktab2
330  ENDIF
331  rfl=0d0
332  DO 160 kts=0,2
333  DO 150 kt3=kt3l,kt3u
334  rfl=rfl+parf(120+80*ktab1+25*kts+kt3)
335  150 CONTINUE
336  160 CONTINUE
337  rfl=pyr(0)*rfl
338  DO 180 kts=0,2
339  ktabs=kts
340  DO 170 kt3=kt3l,kt3u
341  ktab3=kt3
342  rfl=rfl-parf(120+80*ktab1+25*kts+kt3)
343  IF(rfl.LE.0d0) goto 190
344  170 CONTINUE
345  180 CONTINUE
346  190 CONTINUE
347 
348 C...Reconstruct flavour of produced quark/diquark.
349  IF(ktab3.LE.6) THEN
350  kfl3a=ktab3
351  kfl3b=0
352  kfl3=isign(kfl3a,kfl1*(2*ktab1-13))
353  ELSE
354  kfl3a=1
355  IF(ktab3.GE.8) kfl3a=2
356  IF(ktab3.GE.11) kfl3a=3
357  IF(ktab3.GE.16) kfl3a=4
358  kfl3b=(ktab3-6-kfl3a*(kfl3a-2))/2
359  kfl3=1000*kfl3a+100*kfl3b+1
360  IF(kfl3a.EQ.kfl3b.OR.ktab3.NE.6+kfl3a*(kfl3a-2)+2*kfl3b) kfl3=
361  & kfl3+2
362  kfl3=isign(kfl3,kfl1*(13-2*ktab1))
363  ENDIF
364 
365 C...Reconstruct meson code.
366  IF(kfl3a.EQ.kfl1a.AND.kfl3b.EQ.kfl1b.AND.(kfl3a.LE.3.OR.
367  &kfl3b.NE.0)) THEN
368  rfl=pyr(0)*(parf(143+80*ktab1+25*ktabs)+parf(144+80*ktab1+
369  & 25*ktabs)+parf(145+80*ktab1+25*ktabs))
370  kf=110+2*ktabs+1
371  IF(rfl.GT.parf(143+80*ktab1+25*ktabs)) kf=220+2*ktabs+1
372  IF(rfl.GT.parf(143+80*ktab1+25*ktabs)+parf(144+80*ktab1+
373  & 25*ktabs)) kf=330+2*ktabs+1
374  ELSEIF(ktab1.LE.6.AND.ktab3.LE.6) THEN
375  kfla=max(ktab1,ktab3)
376  kflb=min(ktab1,ktab3)
377  kfs=isign(1,kfl1)
378  IF(kfla.NE.kf1a) kfs=-kfs
379  kf=(100*kfla+10*kflb+2*ktabs+1)*kfs*(-1)**kfla
380  ELSEIF(ktab1.GE.7.AND.ktab3.GE.7) THEN
381  kfs=isign(1,kfl1)
382  IF(kfl1a.EQ.kfl3a) THEN
383  kfla=max(kfl1b,kfl3b)
384  kflb=min(kfl1b,kfl3b)
385  IF(kfla.NE.kfl1b) kfs=-kfs
386  ELSEIF(kfl1a.EQ.kfl3b) THEN
387  kfla=kfl3a
388  kflb=kfl1b
389  kfs=-kfs
390  ELSEIF(kfl1b.EQ.kfl3a) THEN
391  kfla=kfl1a
392  kflb=kfl3b
393  ELSEIF(kfl1b.EQ.kfl3b) THEN
394  kfla=max(kfl1a,kfl3a)
395  kflb=min(kfl1a,kfl3a)
396  IF(kfla.NE.kfl1a) kfs=-kfs
397  ELSE
398  CALL pyerrm(2,'(PYKFDI:) no matching flavours for qq -> qq')
399  goto 100
400  ENDIF
401  kf=(100*kfla+10*kflb+2*ktabs+1)*kfs*(-1)**kfla
402 
403 C...Reconstruct baryon code.
404  ELSE
405  IF(ktab1.GE.7) THEN
406  kfla=kfl3a
407  kflb=kfl1a
408  kflc=kfl1b
409  ELSE
410  kfla=kfl1a
411  kflb=kfl3a
412  kflc=kfl3b
413  ENDIF
414  kfld=max(kfla,kflb,kflc)
415  kflf=min(kfla,kflb,kflc)
416  kfle=kfla+kflb+kflc-kfld-kflf
417  IF(ktabs.EQ.0) kf=isign(1000*kfld+100*kflf+10*kfle+2,kfl1)
418  IF(ktabs.GE.1) kf=isign(1000*kfld+100*kfle+10*kflf+2*ktabs,kfl1)
419  ENDIF
420 
421 C...Check that constructed flavour code is an allowed one.
422  IF(kfl2.NE.0) kfl3=0
423  kc=pycomp(kf)
424  IF(kc.EQ.0) THEN
425  CALL pyerrm(2,'(PYKFDI:) user-defined flavour probabilities '//
426  & 'failed')
427  goto 100
428  ENDIF
429 
430  RETURN
431  END