Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pykmap.f
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file pykmap.f
1 
2 C*********************************************************************
3 
4 C...PYKMAP
5 C...Maps a uniform distribution into a distribution of a kinematical
6 C...variable according to one of the possibilities allowed. It is
7 C...assumed that kinematical limits have been set by a PYKLIM call.
8 
9  SUBROUTINE pykmap(IVAR,MVAR,VVAR)
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/pysubs/msel,mselpd,msub(500),kfin(2,-40:40),ckin(200)
19  common/pypars/mstp(200),parp(200),msti(200),pari(200)
20  common/pyint1/mint(400),vint(400)
21  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
22  SAVE /pydat1/,/pydat2/,/pysubs/,/pypars/,/pyint1/,/pyint2/
23 
24 C...Convert VVAR to tau variable.
25  isub=mint(1)
26  istsb=iset(isub)
27  IF(ivar.EQ.1) THEN
28  taumin=vint(11)
29  taumax=vint(31)
30  IF(mvar.EQ.3.OR.mvar.EQ.4) THEN
31  taure=vint(73)
32  gamre=vint(74)
33  ELSEIF(mvar.EQ.5.OR.mvar.EQ.6) THEN
34  taure=vint(75)
35  gamre=vint(76)
36  ENDIF
37  IF(mint(47).EQ.1.AND.(istsb.EQ.1.OR.istsb.EQ.2)) THEN
38  tau=1d0
39  ELSEIF(mvar.EQ.1) THEN
40  tau=taumin*(taumax/taumin)**vvar
41  ELSEIF(mvar.EQ.2) THEN
42  tau=taumax*taumin/(taumin+(taumax-taumin)*vvar)
43  ELSEIF(mvar.EQ.3.OR.mvar.EQ.5) THEN
44  ratgen=(taure+taumax)/(taure+taumin)*taumin/taumax
45  tau=taure*taumin/((taure+taumin)*ratgen**vvar-taumin)
46  ELSEIF(mvar.EQ.4.OR.mvar.EQ.6) THEN
47  aupp=atan((taumax-taure)/gamre)
48  alow=atan((taumin-taure)/gamre)
49  tau=taure+gamre*tan(alow+(aupp-alow)*vvar)
50  ELSEIF(mint(47).EQ.5) THEN
51  aupp=log(max(2d-10,1d0-taumax))
52  alow=log(max(2d-10,1d0-taumin))
53  tau=1d0-exp(aupp+vvar*(alow-aupp))
54  ELSE
55  aupp=log(max(1d-10,1d0-taumax))
56  alow=log(max(1d-10,1d0-taumin))
57  tau=1d0-exp(aupp+vvar*(alow-aupp))
58  ENDIF
59  vint(21)=min(taumax,max(taumin,tau))
60 
61 C...Convert VVAR to y* variable.
62  ELSEIF(ivar.EQ.2) THEN
63  ystmin=vint(12)
64  ystmax=vint(32)
65  taue=vint(21)
66  IF(istsb.GE.3.AND.istsb.LE.5) taue=vint(26)
67  IF(mint(47).EQ.1) THEN
68  yst=0d0
69  ELSEIF(mint(47).EQ.2.OR.mint(47).EQ.6) THEN
70  yst=-0.5d0*log(taue)
71  ELSEIF(mint(47).EQ.3.OR.mint(47).EQ.7) THEN
72  yst=0.5d0*log(taue)
73  ELSEIF(mvar.EQ.1) THEN
74  yst=ystmin+(ystmax-ystmin)*sqrt(vvar)
75  ELSEIF(mvar.EQ.2) THEN
76  yst=ystmax-(ystmax-ystmin)*sqrt(1d0-vvar)
77  ELSEIF(mvar.EQ.3) THEN
78  aupp=atan(exp(ystmax))
79  alow=atan(exp(ystmin))
80  yst=log(tan(alow+(aupp-alow)*vvar))
81  ELSEIF(mvar.EQ.4) THEN
82  yst0=-0.5d0*log(taue)
83  aupp=log(max(1d-10,exp(yst0-ystmin)-1d0))
84  alow=log(max(1d-10,exp(yst0-ystmax)-1d0))
85  yst=yst0-log(1d0+exp(alow+vvar*(aupp-alow)))
86  ELSE
87  yst0=-0.5d0*log(taue)
88  aupp=log(max(1d-10,exp(yst0+ystmin)-1d0))
89  alow=log(max(1d-10,exp(yst0+ystmax)-1d0))
90  yst=log(1d0+exp(aupp+vvar*(alow-aupp)))-yst0
91  ENDIF
92  vint(22)=min(ystmax,max(ystmin,yst))
93 
94 C...Convert VVAR to cos(theta-hat) variable.
95  ELSEIF(ivar.EQ.3) THEN
96  rm34=max(1d-20,2d0*vint(63)*vint(64)/(vint(21)*vint(2))**2)
97  rsqm=1d0+rm34
98  IF(2d0*vint(71)**2/(vint(21)*vint(2)).LT.0.0001d0)
99  & rm34=max(rm34,2d0*vint(71)**2/(vint(21)*vint(2)))
100  ctnmin=vint(13)
101  ctnmax=vint(33)
102  ctpmin=vint(14)
103  ctpmax=vint(34)
104  IF(mvar.EQ.1) THEN
105  aneg=ctnmax-ctnmin
106  apos=ctpmax-ctpmin
107  IF(aneg.GT.0d0.AND.vvar*(aneg+apos).LE.aneg) THEN
108  vctn=vvar*(aneg+apos)/aneg
109  cth=ctnmin+(ctnmax-ctnmin)*vctn
110  ELSE
111  vctp=(vvar*(aneg+apos)-aneg)/apos
112  cth=ctpmin+(ctpmax-ctpmin)*vctp
113  ENDIF
114  ELSEIF(mvar.EQ.2) THEN
115  rmnmin=max(rm34,rsqm-ctnmin)
116  rmnmax=max(rm34,rsqm-ctnmax)
117  rmpmin=max(rm34,rsqm-ctpmin)
118  rmpmax=max(rm34,rsqm-ctpmax)
119  aneg=log(rmnmin/rmnmax)
120  apos=log(rmpmin/rmpmax)
121  IF(aneg.GT.0d0.AND.vvar*(aneg+apos).LE.aneg) THEN
122  vctn=vvar*(aneg+apos)/aneg
123  cth=rsqm-rmnmin*(rmnmax/rmnmin)**vctn
124  ELSE
125  vctp=(vvar*(aneg+apos)-aneg)/apos
126  cth=rsqm-rmpmin*(rmpmax/rmpmin)**vctp
127  ENDIF
128  ELSEIF(mvar.EQ.3) THEN
129  rmnmin=max(rm34,rsqm+ctnmin)
130  rmnmax=max(rm34,rsqm+ctnmax)
131  rmpmin=max(rm34,rsqm+ctpmin)
132  rmpmax=max(rm34,rsqm+ctpmax)
133  aneg=log(rmnmax/rmnmin)
134  apos=log(rmpmax/rmpmin)
135  IF(aneg.GT.0d0.AND.vvar*(aneg+apos).LE.aneg) THEN
136  vctn=vvar*(aneg+apos)/aneg
137  cth=rmnmin*(rmnmax/rmnmin)**vctn-rsqm
138  ELSE
139  vctp=(vvar*(aneg+apos)-aneg)/apos
140  cth=rmpmin*(rmpmax/rmpmin)**vctp-rsqm
141  ENDIF
142  ELSEIF(mvar.EQ.4) THEN
143  rmnmin=max(rm34,rsqm-ctnmin)
144  rmnmax=max(rm34,rsqm-ctnmax)
145  rmpmin=max(rm34,rsqm-ctpmin)
146  rmpmax=max(rm34,rsqm-ctpmax)
147  aneg=1d0/rmnmax-1d0/rmnmin
148  apos=1d0/rmpmax-1d0/rmpmin
149  IF(aneg.GT.0d0.AND.vvar*(aneg+apos).LE.aneg) THEN
150  vctn=vvar*(aneg+apos)/aneg
151  cth=rsqm-1d0/(1d0/rmnmin+aneg*vctn)
152  ELSE
153  vctp=(vvar*(aneg+apos)-aneg)/apos
154  cth=rsqm-1d0/(1d0/rmpmin+apos*vctp)
155  ENDIF
156  ELSEIF(mvar.EQ.5) THEN
157  rmnmin=max(rm34,rsqm+ctnmin)
158  rmnmax=max(rm34,rsqm+ctnmax)
159  rmpmin=max(rm34,rsqm+ctpmin)
160  rmpmax=max(rm34,rsqm+ctpmax)
161  aneg=1d0/rmnmin-1d0/rmnmax
162  apos=1d0/rmpmin-1d0/rmpmax
163  IF(aneg.GT.0d0.AND.vvar*(aneg+apos).LE.aneg) THEN
164  vctn=vvar*(aneg+apos)/aneg
165  cth=1d0/(1d0/rmnmin-aneg*vctn)-rsqm
166  ELSE
167  vctp=(vvar*(aneg+apos)-aneg)/apos
168  cth=1d0/(1d0/rmpmin-apos*vctp)-rsqm
169  ENDIF
170  ENDIF
171  IF(cth.LT.0d0) cth=min(ctnmax,max(ctnmin,cth))
172  IF(cth.GT.0d0) cth=min(ctpmax,max(ctpmin,cth))
173  vint(23)=cth
174 
175 C...Convert VVAR to tau' variable.
176  ELSEIF(ivar.EQ.4) THEN
177  tau=vint(21)
178  taupmn=vint(16)
179  taupmx=vint(36)
180  IF(mint(47).EQ.1) THEN
181  taup=1d0
182  ELSEIF(mvar.EQ.1) THEN
183  taup=taupmn*(taupmx/taupmn)**vvar
184  ELSEIF(mvar.EQ.2) THEN
185  aupp=(1d0-tau/taupmx)**4
186  alow=(1d0-tau/taupmn)**4
187  taup=tau/max(1d-10,1d0-(alow+(aupp-alow)*vvar)**0.25d0)
188  ELSEIF(mint(47).EQ.5) THEN
189  aupp=log(max(2d-10,1d0-taupmx))
190  alow=log(max(2d-10,1d0-taupmn))
191  taup=1d0-exp(aupp+vvar*(alow-aupp))
192  ELSE
193  aupp=log(max(1d-10,1d0-taupmx))
194  alow=log(max(1d-10,1d0-taupmn))
195  taup=1d0-exp(aupp+vvar*(alow-aupp))
196  ENDIF
197  vint(26)=min(taupmx,max(taupmn,taup))
198 
199 C...Selection of extra variables needed in 2 -> 3 process:
200 C...pT1, pT2, phi1, phi2, y3 for three outgoing particles.
201 C...Since no options are available, the functions of PYKLIM
202 C...and PYKMAP are joint for these choices.
203  ELSEIF(ivar.EQ.5) THEN
204 
205 C...Read out total energy and particle masses.
206  mint(51)=0
207  mptpk=1
208  IF(isub.EQ.123.OR.isub.EQ.124.OR.isub.EQ.173.OR.isub.EQ.174
209  & .OR.isub.EQ.178.OR.isub.EQ.179.OR.isub.EQ.351.OR.isub.EQ.352)
210  & mptpk=2
211  shp=vint(26)*vint(2)
212  shpr=sqrt(shp)
213  pm1=vint(201)
214  pm2=vint(206)
215  pm3=sqrt(vint(21))*vint(1)
216  IF(pm1+pm2+pm3.GT.0.9999d0*shpr) THEN
217  mint(51)=1
218  RETURN
219  ENDIF
220  pmrs1=vint(204)**2
221  pmrs2=vint(209)**2
222 
223 C...Specify coefficients of pT choice; upper and lower limits.
224  IF(mptpk.EQ.1) THEN
225  hwt1=0.4d0
226  hwt2=0.4d0
227  ELSE
228  hwt1=0.05d0
229  hwt2=0.05d0
230  ENDIF
231  hwt3=1d0-hwt1-hwt2
232  ptsmx1=((shp-pm1**2-(pm2+pm3)**2)**2-(2d0*pm1*(pm2+pm3))**2)/
233  & (4d0*shp)
234  IF(ckin(52).GT.0d0) ptsmx1=min(ptsmx1,ckin(52)**2)
235  ptsmn1=ckin(51)**2
236  ptsmx2=((shp-pm2**2-(pm1+pm3)**2)**2-(2d0*pm2*(pm1+pm3))**2)/
237  & (4d0*shp)
238  IF(ckin(54).GT.0d0) ptsmx2=min(ptsmx2,ckin(54)**2)
239  ptsmn2=ckin(53)**2
240 
241 C...Select transverse momenta according to
242 C...dp_T^2 * (a + b/(M^2 + p_T^2) + c/(M^2 + p_T^2)^2).
243  hmx=pmrs1+ptsmx1
244  hmn=pmrs1+ptsmn1
245  IF(hmx.LT.1.0001d0*hmn) THEN
246  mint(51)=1
247  RETURN
248  ENDIF
249  hde=ptsmx1-ptsmn1
250  rpt=pyr(0)
251  IF(rpt.LT.hwt1) THEN
252  pts1=ptsmn1+pyr(0)*hde
253  ELSEIF(rpt.LT.hwt1+hwt2) THEN
254  pts1=max(ptsmn1,hmn*(hmx/hmn)**pyr(0)-pmrs1)
255  ELSE
256  pts1=max(ptsmn1,hmn*hmx/(hmn+pyr(0)*hde)-pmrs1)
257  ENDIF
258  wtpts1=hde/(hwt1+hwt2*hde/(log(hmx/hmn)*(pmrs1+pts1))+
259  & hwt3*hmn*hmx/(pmrs1+pts1)**2)
260  hmx=pmrs2+ptsmx2
261  hmn=pmrs2+ptsmn2
262  IF(hmx.LT.1.0001d0*hmn) THEN
263  mint(51)=1
264  RETURN
265  ENDIF
266  hde=ptsmx2-ptsmn2
267  rpt=pyr(0)
268  IF(rpt.LT.hwt1) THEN
269  pts2=ptsmn2+pyr(0)*hde
270  ELSEIF(rpt.LT.hwt1+hwt2) THEN
271  pts2=max(ptsmn2,hmn*(hmx/hmn)**pyr(0)-pmrs2)
272  ELSE
273  pts2=max(ptsmn2,hmn*hmx/(hmn+pyr(0)*hde)-pmrs2)
274  ENDIF
275  wtpts2=hde/(hwt1+hwt2*hde/(log(hmx/hmn)*(pmrs2+pts2))+
276  & hwt3*hmn*hmx/(pmrs2+pts2)**2)
277 
278 C...Select azimuthal angles and check pT choice.
279  phi1=paru(2)*pyr(0)
280  phi2=paru(2)*pyr(0)
281  phir=phi2-phi1
282  pts3=max(0d0,pts1+pts2+2d0*sqrt(pts1*pts2)*cos(phir))
283  IF(pts3.LT.ckin(55)**2.OR.(ckin(56).GT.0d0.AND.pts3.GT.
284  & ckin(56)**2)) THEN
285  mint(51)=1
286  RETURN
287  ENDIF
288 
289 C...Calculate transverse masses and check phase space not closed.
290  pms1=pm1**2+pts1
291  pms2=pm2**2+pts2
292  pms3=pm3**2+pts3
293  pmt1=sqrt(pms1)
294  pmt2=sqrt(pms2)
295  pmt3=sqrt(pms3)
296  pm12=(pmt1+pmt2)**2
297  IF(pmt1+pmt2+pmt3.GT.0.9999d0*shpr) THEN
298  mint(51)=1
299  RETURN
300  ENDIF
301 
302 C...Select rapidity for particle 3 and check phase space not closed.
303  y3max=log((shp+pms3-pm12+sqrt(max(0d0,(shp-pms3-pm12)**2-
304  & 4d0*pms3*pm12)))/(2d0*shpr*pmt3))
305  IF(y3max.LT.1d-6) THEN
306  mint(51)=1
307  RETURN
308  ENDIF
309  y3=(2d0*pyr(0)-1d0)*0.999999d0*y3max
310  pz3=pmt3*sinh(y3)
311  pe3=pmt3*cosh(y3)
312 
313 C...Find momentum transfers in two mirror solutions (in 1-2 frame).
314  pz12=-pz3
315  pe12=shpr-pe3
316  pms12=pe12**2-pz12**2
317  sql12=sqrt(max(0d0,(pms12-pms1-pms2)**2-4d0*pms1*pms2))
318  IF(sql12.LT.1d-6*shp) THEN
319  mint(51)=1
320  RETURN
321  ENDIF
322  pmm1=pms12+pms1-pms2
323  pmm2=pms12+pms2-pms1
324  tfac=-shpr/(2d0*pms12)
325  t1p=tfac*(pe12-pz12)*(pmm1-sql12)
326  t1n=tfac*(pe12-pz12)*(pmm1+sql12)
327  t2p=tfac*(pe12+pz12)*(pmm2-sql12)
328  t2n=tfac*(pe12+pz12)*(pmm2+sql12)
329 
330 C...Construct relative mirror weights and make choice.
331  IF(mptpk.EQ.1.OR.isub.EQ.351.OR.isub.EQ.352) THEN
332  wtpu=1d0
333  wtnu=1d0
334  ELSE
335  wtpu=1d0/((t1p-pmrs1)*(t2p-pmrs2))**2
336  wtnu=1d0/((t1n-pmrs1)*(t2n-pmrs2))**2
337  ENDIF
338  wtp=wtpu/(wtpu+wtnu)
339  wtn=wtnu/(wtpu+wtnu)
340  eps=1d0
341  IF(wtn.GT.pyr(0)) eps=-1d0
342 
343 C...Store result of variable choice and associated weights.
344  vint(202)=pts1
345  vint(207)=pts2
346  vint(203)=phi1
347  vint(208)=phi2
348  vint(205)=wtpts1
349  vint(210)=wtpts2
350  vint(211)=y3
351  vint(212)=y3max
352  vint(213)=eps
353  IF(eps.GT.0d0) THEN
354  vint(214)=1d0/wtp
355  vint(215)=t1p
356  vint(216)=t2p
357  ELSE
358  vint(214)=1d0/wtn
359  vint(215)=t1n
360  vint(216)=t2n
361  ENDIF
362  vint(217)=-0.5d0*tfac*(pe12-pz12)*(pmm2+eps*sql12)
363  vint(218)=-0.5d0*tfac*(pe12+pz12)*(pmm1+eps*sql12)
364  vint(219)=0.5d0*(pms12-pts3)
365  vint(220)=sql12
366  ENDIF
367 
368  RETURN
369  END