Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pyofsh.f
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file pyofsh.f
1 
2 C***********************************************************************
3 
4 C...PYOFSH
5 C...Calculates partial width and differential cross-section maxima
6 C...of channels/processes not allowed on mass-shell, and selects
7 C...masses in such channels/processes.
8 
9  SUBROUTINE pyofsh(MOFSH,KFMO,KFD1,KFD2,PMMO,RET1,RET2)
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/pydat1/mstu(200),paru(200),mstj(200),parj(200)
17  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
18  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
19  common/pysubs/msel,mselpd,msub(500),kfin(2,-40:40),ckin(200)
20  common/pypars/mstp(200),parp(200),msti(200),pari(200)
21  common/pyint1/mint(400),vint(400)
22  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
23  common/pyint5/ngenpd,ngen(0:500,3),xsec(0:500,3)
24  SAVE /pydat1/,/pydat2/,/pydat3/,/pysubs/,/pypars/,/pyint1/,
25  &/pyint2/,/pyint5/
26 C...Local arrays.
27  dimension kfd(2),mbw(2),pmd(2),pgd(2),pmg(2),pml(2),pmu(2),
28  &pmh(2),atl(2),atu(2),ath(2),rmg(2),inx1(100),xpt1(100),
29  &fpt1(100),inx2(100),xpt2(100),fpt2(100),wdtp(0:400),
30  &wdte(0:400,0:5)
31 
32 C...Find if particles equal, maximum mass, matrix elements, etc.
33  mint(51)=0
34  isub=mint(1)
35  kfd(1)=iabs(kfd1)
36  kfd(2)=iabs(kfd2)
37  meql=0
38  IF(kfd(1).EQ.kfd(2)) meql=1
39  mlm=0
40  IF(mofsh.GE.2.AND.meql.EQ.1) mlm=int(1.5d0+pyr(0))
41  IF(mofsh.LE.2.OR.mofsh.EQ.5) THEN
42  noff=44
43  pmmx=pmmo
44  ELSE
45  noff=40
46  pmmx=vint(1)
47  IF(ckin(2).GT.ckin(1)) pmmx=min(ckin(2),vint(1))
48  ENDIF
49  mmed=0
50  IF((kfmo.EQ.25.OR.kfmo.EQ.35.OR.kfmo.EQ.36).AND.meql.EQ.1.AND.
51  &(kfd(1).EQ.23.OR.kfd(1).EQ.24)) mmed=1
52  IF((kfmo.EQ.32.OR.iabs(kfmo).EQ.34).AND.(kfd(1).EQ.23.OR.
53  &kfd(1).EQ.24).AND.(kfd(2).EQ.23.OR.kfd(2).EQ.24)) mmed=2
54  IF((kfmo.EQ.32.OR.iabs(kfmo).EQ.34).AND.(kfd(2).EQ.25.OR.
55  &kfd(2).EQ.35.OR.kfd(2).EQ.36)) mmed=3
56  loop=1
57 
58 C...Find where Breit-Wigners are required, else select discrete masses.
59  100 DO 110 i=1,2
60  kfca=pycomp(kfd(i))
61  IF(kfca.GT.0) THEN
62  pmd(i)=pmas(kfca,1)
63  pgd(i)=pmas(kfca,2)
64  ELSE
65  pmd(i)=0d0
66  pgd(i)=0d0
67  ENDIF
68  IF(mstp(42).LE.0.OR.pgd(i).LT.parp(41)) THEN
69  mbw(i)=0
70  pmg(i)=pmd(i)
71  rmg(i)=(pmg(i)/pmmx)**2
72  ELSE
73  mbw(i)=1
74  ENDIF
75  110 CONTINUE
76 
77 C...Find allowed mass range and Breit-Wigner parameters.
78  DO 120 i=1,2
79  IF(mofsh.EQ.1.AND.loop.EQ.1.AND.mbw(i).EQ.1) THEN
80  pml(i)=parp(42)
81  pmu(i)=pmmx-parp(42)
82  IF(mbw(3-i).EQ.0) pmu(i)=min(pmu(i),pmmx-pmd(3-i))
83  IF(pmu(i).LT.pml(i)+parj(64)) mbw(i)=-1
84  ELSEIF(mbw(i).EQ.1.AND.mofsh.NE.5) THEN
85  ilm=i
86  IF(mlm.EQ.2) ilm=3-i
87  pml(i)=max(ckin(noff+2*ilm-1),parp(42))
88  IF(mbw(3-i).EQ.0) THEN
89  pmu(i)=pmmx-pmd(3-i)
90  ELSE
91  pmu(i)=pmmx-max(ckin(noff+5-2*ilm),parp(42))
92  ENDIF
93  IF(ckin(noff+2*ilm).GT.ckin(noff+2*ilm-1)) pmu(i)=
94  & min(pmu(i),ckin(noff+2*ilm))
95  IF(i.EQ.mlm) pmu(i)=min(pmu(i),0.5d0*pmmx)
96  IF(meql.EQ.0) pmh(i)=min(pmu(i),0.5d0*pmmx)
97  IF(pmu(i).LT.pml(i)+parj(64)) mbw(i)=-1
98  IF(mbw(i).EQ.1) THEN
99  atl(i)=atan((pml(i)**2-pmd(i)**2)/(pmd(i)*pgd(i)))
100  atu(i)=atan((pmu(i)**2-pmd(i)**2)/(pmd(i)*pgd(i)))
101  IF(meql.EQ.0) ath(i)=atan((pmh(i)**2-pmd(i)**2)/(pmd(i)*
102  & pgd(i)))
103  ENDIF
104  ELSEIF(mbw(i).EQ.1.AND.mofsh.EQ.5) THEN
105  ilm=i
106  IF(mlm.EQ.2) ilm=3-i
107  pml(i)=max(ckin(48+i),parp(42))
108  pmu(i)=pmmx-max(ckin(51-i),parp(42))
109  IF(mbw(3-i).EQ.0) pmu(i)=min(pmu(i),pmmx-pmd(3-i))
110  IF(i.EQ.mlm) pmu(i)=min(pmu(i),0.5d0*pmmx)
111  IF(meql.EQ.0) pmh(i)=min(pmu(i),0.5d0*pmmx)
112  IF(pmu(i).LT.pml(i)+parj(64)) mbw(i)=-1
113  IF(mbw(i).EQ.1) THEN
114  atl(i)=atan((pml(i)**2-pmd(i)**2)/(pmd(i)*pgd(i)))
115  atu(i)=atan((pmu(i)**2-pmd(i)**2)/(pmd(i)*pgd(i)))
116  IF(meql.EQ.0) ath(i)=atan((pmh(i)**2-pmd(i)**2)/(pmd(i)*
117  & pgd(i)))
118  ENDIF
119  ENDIF
120  120 CONTINUE
121  IF(mbw(1).LT.0.OR.mbw(2).LT.0.OR.(mbw(1).EQ.0.AND.mbw(2).EQ.0))
122  &THEN
123  CALL pyerrm(3,'(PYOFSH:) no allowed decay product masses')
124  mint(51)=1
125  RETURN
126  ENDIF
127 
128 C...Calculation of partial width of resonance.
129  IF(mofsh.EQ.1) THEN
130 
131 C..If only one integration, pick that to be the inner.
132  IF(mbw(1).EQ.0) THEN
133  pm2=pmd(1)
134  pmd(1)=pmd(2)
135  pgd(1)=pgd(2)
136  pml(1)=pml(2)
137  pmu(1)=pmu(2)
138  ELSEIF(mbw(2).EQ.0) THEN
139  pm2=pmd(2)
140  ENDIF
141 
142 C...Start outer loop of integration.
143  IF(mbw(1).EQ.1.AND.mbw(2).EQ.1) THEN
144  atl2=atan((pml(2)**2-pmd(2)**2)/(pmd(2)*pgd(2)))
145  atu2=atan((pmu(2)**2-pmd(2)**2)/(pmd(2)*pgd(2)))
146  npt2=1
147  xpt2(1)=1d0
148  inx2(1)=0
149  fmax2=0d0
150  ENDIF
151  130 IF(mbw(1).EQ.1.AND.mbw(2).EQ.1) THEN
152  pm2s=pmd(2)**2+pmd(2)*pgd(2)*tan(atl2+xpt2(npt2)*(atu2-atl2))
153  pm2=min(pmu(2),max(pml(2),sqrt(max(0d0,pm2s))))
154  ENDIF
155  rm2=(pm2/pmmx)**2
156 
157 C...Start inner loop of integration.
158  pml1=pml(1)
159  pmu1=min(pmu(1),pmmx-pm2)
160  IF(meql.EQ.1) pmu1=min(pmu1,pm2)
161  atl1=atan((pml1**2-pmd(1)**2)/(pmd(1)*pgd(1)))
162  atu1=atan((pmu1**2-pmd(1)**2)/(pmd(1)*pgd(1)))
163  IF(pml1+parj(64).GE.pmu1.OR.atl1+1d-7.GE.atu1) THEN
164  func2=0d0
165  goto 180
166  ENDIF
167  npt1=1
168  xpt1(1)=1d0
169  inx1(1)=0
170  fmax1=0d0
171  140 pm1s=pmd(1)**2+pmd(1)*pgd(1)*tan(atl1+xpt1(npt1)*(atu1-atl1))
172  pm1=min(pmu1,max(pml1,sqrt(max(0d0,pm1s))))
173  rm1=(pm1/pmmx)**2
174 
175 C...Evaluate function value - inner loop.
176  func1=sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))
177  IF(mmed.EQ.1) func1=func1*((1d0-rm1-rm2)**2+8d0*rm1*rm2)
178  IF(mmed.EQ.2) func1=func1**3*(1d0+10d0*rm1+10d0*rm2+rm1**2+
179  & rm2**2+10d0*rm1*rm2)
180  IF(func1.GT.fmax1) fmax1=func1
181  fpt1(npt1)=func1
182 
183 C...Go to next position in inner loop.
184  IF(npt1.EQ.1) THEN
185  npt1=npt1+1
186  xpt1(npt1)=0d0
187  inx1(npt1)=1
188  goto 140
189  ELSEIF(npt1.LE.8) THEN
190  npt1=npt1+1
191  IF(npt1.LE.4.OR.npt1.EQ.6) ish1=1
192  ish1=ish1+1
193  xpt1(npt1)=0.5d0*(xpt1(ish1)+xpt1(inx1(ish1)))
194  inx1(npt1)=inx1(ish1)
195  inx1(ish1)=npt1
196  goto 140
197  ELSEIF(npt1.LT.100) THEN
198  isn1=ish1
199  150 ish1=ish1+1
200  IF(ish1.GT.npt1) ish1=2
201  IF(ish1.EQ.isn1) goto 160
202  dfpt1=abs(fpt1(ish1)-fpt1(inx1(ish1)))
203  IF(dfpt1.LT.parp(43)*fmax1) goto 150
204  npt1=npt1+1
205  xpt1(npt1)=0.5d0*(xpt1(ish1)+xpt1(inx1(ish1)))
206  inx1(npt1)=inx1(ish1)
207  inx1(ish1)=npt1
208  goto 140
209  ENDIF
210 
211 C...Calculate integral over inner loop.
212  160 fsum1=0d0
213  DO 170 ipt1=2,npt1
214  fsum1=fsum1+0.5d0*(fpt1(ipt1)+fpt1(inx1(ipt1)))*
215  & (xpt1(inx1(ipt1))-xpt1(ipt1))
216  170 CONTINUE
217  func2=fsum1*(atu1-atl1)/paru(1)
218  180 IF(mbw(1).EQ.1.AND.mbw(2).EQ.1) THEN
219  IF(func2.GT.fmax2) fmax2=func2
220  fpt2(npt2)=func2
221 
222 C...Go to next position in outer loop.
223  IF(npt2.EQ.1) THEN
224  npt2=npt2+1
225  xpt2(npt2)=0d0
226  inx2(npt2)=1
227  goto 130
228  ELSEIF(npt2.LE.8) THEN
229  npt2=npt2+1
230  IF(npt2.LE.4.OR.npt2.EQ.6) ish2=1
231  ish2=ish2+1
232  xpt2(npt2)=0.5d0*(xpt2(ish2)+xpt2(inx2(ish2)))
233  inx2(npt2)=inx2(ish2)
234  inx2(ish2)=npt2
235  goto 130
236  ELSEIF(npt2.LT.100) THEN
237  isn2=ish2
238  190 ish2=ish2+1
239  IF(ish2.GT.npt2) ish2=2
240  IF(ish2.EQ.isn2) goto 200
241  dfpt2=abs(fpt2(ish2)-fpt2(inx2(ish2)))
242  IF(dfpt2.LT.parp(43)*fmax2) goto 190
243  npt2=npt2+1
244  xpt2(npt2)=0.5d0*(xpt2(ish2)+xpt2(inx2(ish2)))
245  inx2(npt2)=inx2(ish2)
246  inx2(ish2)=npt2
247  goto 130
248  ENDIF
249 
250 C...Calculate integral over outer loop.
251  200 fsum2=0d0
252  DO 210 ipt2=2,npt2
253  fsum2=fsum2+0.5d0*(fpt2(ipt2)+fpt2(inx2(ipt2)))*
254  & (xpt2(inx2(ipt2))-xpt2(ipt2))
255  210 CONTINUE
256  fsum2=fsum2*(atu2-atl2)/paru(1)
257  IF(meql.EQ.1) fsum2=2d0*fsum2
258  ELSE
259  fsum2=func2
260  ENDIF
261 
262 C...Save result; second integration for user-selected mass range.
263  IF(loop.EQ.1) widw=fsum2
264  wid2=fsum2
265  IF(loop.EQ.1.AND.(ckin(46).GE.ckin(45).OR.ckin(48).GE.ckin(47)
266  & .OR.max(ckin(45),ckin(47)).GE.1.01d0*parp(42))) THEN
267  loop=2
268  goto 100
269  ENDIF
270  ret1=widw
271  ret2=wid2/widw
272 
273 C...Select two decay product masses of a resonance.
274  ELSEIF(mofsh.EQ.2.OR.mofsh.EQ.5) THEN
275  220 DO 230 i=1,2
276  IF(mbw(i).EQ.0) goto 230
277  pmbw=pmd(i)**2+pmd(i)*pgd(i)*tan(atl(i)+pyr(0)*
278  & (atu(i)-atl(i)))
279  pmg(i)=min(pmu(i),max(pml(i),sqrt(max(0d0,pmbw))))
280  rmg(i)=(pmg(i)/pmmx)**2
281  230 CONTINUE
282  IF((meql.EQ.1.AND.pmg(max(1,mlm)).GT.pmg(min(2,3-mlm))).OR.
283  & pmg(1)+pmg(2)+parj(64).GT.pmmx) goto 220
284 
285 C...Weight with matrix element (if none known, use beta factor).
286  flam=sqrt(max(0d0,(1d0-rmg(1)-rmg(2))**2-4d0*rmg(1)*rmg(2)))
287  IF(mmed.EQ.1) THEN
288  wtbe=flam*((1d0-rmg(1)-rmg(2))**2+8d0*rmg(1)*rmg(2))
289  ELSEIF(mmed.EQ.2) THEN
290  wtbe=flam**3*(1d0+10d0*rmg(1)+10d0*rmg(2)+rmg(1)**2+
291  & rmg(2)**2+10d0*rmg(1)*rmg(2))
292  ELSEIF(mmed.EQ.3) THEN
293  wtbe=flam*(rmg(1)+flam**2/12d0)
294  ELSE
295  wtbe=flam
296  ENDIF
297  IF(wtbe.LT.pyr(0)) goto 220
298  ret1=pmg(1)
299  ret2=pmg(2)
300 
301 C...Find suitable set of masses for initialization of 2 -> 2 processes.
302  ELSEIF(mofsh.EQ.3) THEN
303  IF(mbw(1).NE.0.AND.mbw(2).EQ.0) THEN
304  pmg(1)=min(pmd(1),0.5d0*(pml(1)+pmu(1)))
305  pmg(2)=pmd(2)
306  ELSEIF(mbw(2).NE.0.AND.mbw(1).EQ.0) THEN
307  pmg(1)=pmd(1)
308  pmg(2)=min(pmd(2),0.5d0*(pml(2)+pmu(2)))
309  ELSE
310  idiv=-1
311  240 idiv=idiv+1
312  pmg(1)=min(pmd(1),0.1d0*(idiv*pml(1)+(10-idiv)*pmu(1)))
313  pmg(2)=min(pmd(2),0.1d0*(idiv*pml(2)+(10-idiv)*pmu(2)))
314  IF(idiv.LE.9.AND.pmg(1)+pmg(2).GT.0.9d0*pmmx) goto 240
315  ENDIF
316  ret1=pmg(1)
317  ret2=pmg(2)
318 
319 C...Evaluate importance of excluded tails of Breit-Wigners.
320  IF(meql.EQ.0.AND.mbw(1).EQ.1.AND.mbw(2).EQ.1.AND.pmd(1)+pmd(2)
321  & .GT.pmmx.AND.pmh(1).GT.pml(1).AND.pmh(2).GT.pml(2)) meql=2
322  IF(meql.LE.1) THEN
323  vint(80)=1d0
324  DO 250 i=1,2
325  IF(mbw(i).NE.0) vint(80)=vint(80)*1.25d0*(atu(i)-atl(i))/
326  & paru(1)
327  250 CONTINUE
328  ELSE
329  vint(80)=(1.25d0/paru(1))**2*max((atu(1)-atl(1))*
330  & (ath(2)-atl(2)),(ath(1)-atl(1))*(atu(2)-atl(2)))
331  ENDIF
332  IF((isub.EQ.15.OR.isub.EQ.19.OR.isub.EQ.30.OR.isub.EQ.35).AND.
333  & mstp(43).NE.2) vint(80)=2d0*vint(80)
334  IF(isub.EQ.22.AND.mstp(43).NE.2) vint(80)=4d0*vint(80)
335  IF(meql.GE.1) vint(80)=2d0*vint(80)
336 
337 C...Pick one particle to be the lighter (if improves efficiency).
338  ELSEIF(mofsh.EQ.4) THEN
339  IF(meql.EQ.0.AND.mbw(1).EQ.1.AND.mbw(2).EQ.1.AND.pmd(1)+pmd(2)
340  & .GT.pmmx.AND.pmh(1).GT.pml(1).AND.pmh(2).GT.pml(2)) meql=2
341  260 IF(meql.EQ.2) mlm=int(1.5d0+pyr(0))
342 
343 C...Select two masses according to Breit-Wigner + flat in s + 1/s.
344  DO 270 i=1,2
345  IF(mbw(i).EQ.0) goto 270
346  pmv=pmu(i)
347  IF(meql.EQ.2.AND.i.EQ.mlm) pmv=pmh(i)
348  atv=atu(i)
349  IF(meql.EQ.2.AND.i.EQ.mlm) atv=ath(i)
350  rbr=pyr(0)
351  IF((isub.EQ.15.OR.isub.EQ.19.OR.isub.EQ.22.OR.isub.EQ.30.OR.
352  & isub.EQ.35).AND.mstp(43).NE.2) rbr=2d0*rbr
353  IF(rbr.LT.0.8d0) THEN
354  pmsr=pmd(i)**2+pmd(i)*pgd(i)*tan(atl(i)+pyr(0)*(atv-atl(i)))
355  pmg(i)=min(pmv,max(pml(i),sqrt(max(0d0,pmsr))))
356  ELSEIF(rbr.LT.0.9d0) THEN
357  pmg(i)=sqrt(max(0d0,pml(i)**2+pyr(0)*(pmv**2-pml(i)**2)))
358  ELSEIF(rbr.LT.1.5d0) THEN
359  pmg(i)=pml(i)*(pmv/pml(i))**pyr(0)
360  ELSE
361  pmg(i)=sqrt(max(0d0,pml(i)**2*pmv**2/(pml(i)**2+pyr(0)*
362  & (pmv**2-pml(i)**2))))
363  ENDIF
364  270 CONTINUE
365  IF((meql.GE.1.AND.pmg(max(1,mlm)).GT.pmg(min(2,3-mlm))).OR.
366  & pmg(1)+pmg(2)+parj(64).GT.pmmx) THEN
367  IF(mint(48).EQ.1.AND.mstp(171).EQ.0) THEN
368  ngen(0,1)=ngen(0,1)+1
369  ngen(mint(1),1)=ngen(mint(1),1)+1
370  goto 260
371  ELSE
372  mint(51)=1
373  RETURN
374  ENDIF
375  ENDIF
376  ret1=pmg(1)
377  ret2=pmg(2)
378 
379 C...Give weight for selected mass distribution.
380  vint(80)=1d0
381  DO 280 i=1,2
382  IF(mbw(i).EQ.0) goto 280
383  pmv=pmu(i)
384  IF(meql.EQ.2.AND.i.EQ.mlm) pmv=pmh(i)
385  atv=atu(i)
386  IF(meql.EQ.2.AND.i.EQ.mlm) atv=ath(i)
387  f0=pmd(i)*pgd(i)/((pmg(i)**2-pmd(i)**2)**2+
388  & (pmd(i)*pgd(i))**2)/paru(1)
389  f1=1d0
390  f2=1d0/pmg(i)**2
391  f3=1d0/pmg(i)**4
392  fi0=(atv-atl(i))/paru(1)
393  fi1=pmv**2-pml(i)**2
394  fi2=2d0*log(pmv/pml(i))
395  fi3=1d0/pml(i)**2-1d0/pmv**2
396  IF((isub.EQ.15.OR.isub.EQ.19.OR.isub.EQ.22.OR.isub.EQ.30.OR.
397  & isub.EQ.35).AND.mstp(43).NE.2) THEN
398  vint(80)=vint(80)*20d0/(8d0+(fi0/f0)*(f1/fi1+6d0*f2/fi2+
399  & 5d0*f3/fi3))
400  ELSE
401  vint(80)=vint(80)*10d0/(8d0+(fi0/f0)*(f1/fi1+f2/fi2))
402  ENDIF
403  vint(80)=vint(80)*fi0
404  280 CONTINUE
405  IF(meql.GE.1) vint(80)=2d0*vint(80)
406  ENDIF
407 
408  RETURN
409  END