Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pyjurf.f
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file pyjurf.f
1 
2 C*********************************************************************
3 
4 C...PYJURF
5 C...From three given input vectors in PJU the boost VJU from
6 C...the "lab frame" to the junction rest frame is constructed.
7 
8  SUBROUTINE pyjurf(PJU,VJU)
9 
10 C...Double precision and integer declarations.
11  IMPLICIT DOUBLE PRECISION(a-h, o-z)
12  IMPLICIT INTEGER(i-n)
13 
14 C...Input, output and local arrays.
15  dimension pju(3,5),vju(5),psum(5),a(3,3),penew(3),pcm(5,5)
16  DATA twopi/6.283186d0/
17 
18 C...Calculate masses and other invariants.
19  DO 100 j=1,4
20  psum(j)=pju(1,j)+pju(2,j)+pju(3,j)
21  100 CONTINUE
22  psum2=psum(4)**2-psum(1)**2-psum(2)**2-psum(3)**2
23  psum(5)=sqrt(psum2)
24  DO 120 i=1,3
25  DO 110 j=1,3
26  a(i,j)=pju(i,4)*pju(j,4)-pju(i,1)*pju(j,1)-
27  & pju(i,2)*pju(j,2)-pju(i,3)*pju(j,3)
28  110 CONTINUE
29  120 CONTINUE
30 
31 C...Pick I to be most massive parton and J to be the one closest to I.
32  itry=0
33  i=1
34  IF(a(2,2).GT.a(1,1)) i=2
35  IF(a(3,3).GT.max(a(1,1),a(2,2))) i=3
36  130 itry=itry+1
37  j=1+mod(i,3)
38  k=1+mod(j,3)
39  IF(a(i,k)**2*a(j,j).LT.a(i,j)**2*a(k,k)) THEN
40  k=1+mod(i,3)
41  j=1+mod(k,3)
42  ENDIF
43  pmi2=a(i,i)
44  pmj2=a(j,j)
45  pmk2=a(k,k)
46  aij=a(i,j)
47  aik=a(i,k)
48  ajk=a(j,k)
49 
50 C...Trivial find new parton energies if all three partons are massless.
51  IF(pmi2.LT.1d-4) THEN
52  pei=sqrt(2d0*aik*aij/(3d0*ajk))
53  pej=sqrt(2d0*ajk*aij/(3d0*aik))
54  pek=sqrt(2d0*aik*ajk/(3d0*aij))
55 
56 C...Else find momentum range for parton I and values at extremes.
57  ELSE
58  paimin=0d0
59  peimin=sqrt(pmi2)
60  pejmin=aij/peimin
61  pekmin=aik/peimin
62  pajmin=sqrt(max(0d0,pejmin**2-pmj2))
63  pakmin=sqrt(max(0d0,pekmin**2-pmk2))
64  fmin=pejmin*pekmin+0.5d0*pajmin*pakmin-ajk
65  peimax=(aij+aik)/sqrt(pmj2+pmk2+2d0*ajk)
66  IF(pmj2.GT.1d-4) peimax=aij/sqrt(pmj2)
67  paimax=sqrt(max(0d0,peimax**2-pmi2))
68  hi=peimax**2-0.25d0*paimax**2
69  pajmax=(peimax*sqrt(max(0d0,aij**2-pmj2*hi))-
70  & 0.5d0*paimax*aij)/hi
71  pakmax=(peimax*sqrt(max(0d0,aik**2-pmk2*hi))-
72  & 0.5d0*paimax*aik)/hi
73  pejmax=sqrt(pajmax**2+pmj2)
74  pekmax=sqrt(pakmax**2+pmk2)
75  fmax=pejmax*pekmax+0.5d0*pajmax*pakmax-ajk
76 
77 C...If unexpected values at upper endpoint then pick another parton.
78  IF(fmax.GT.0d0.AND.itry.LE.2) THEN
79  i1=1+mod(i,3)
80  IF(a(i1,i1).GE.1d-4) THEN
81  i=i1
82  goto 130
83  ENDIF
84  itry=itry+1
85  i1=1+mod(i,3)
86  IF(itry.LE.2.AND.a(i1,i1).GE.1d-4) THEN
87  i=i1
88  goto 130
89  ENDIF
90  ENDIF
91 
92 C..Start binary + linear search to find solution inside range.
93  iter=0
94  itmin=0
95  itmax=0
96  pai=0.5d0*(paimin+paimax)
97  140 iter=iter+1
98 
99 C...Derive momentum of other two partons and distance to root.
100  pei=sqrt(pai**2+pmi2)
101  hi=pei**2-0.25d0*pai**2
102  paj=(pei*sqrt(max(0d0,aij**2-pmj2*hi))-0.5d0*pai*aij)/hi
103  pej=sqrt(paj**2+pmj2)
104  pak=(pei*sqrt(max(0d0,aik**2-pmk2*hi))-0.5d0*pai*aik)/hi
105  pek=sqrt(pak**2+pmk2)
106  fnow=pej*pek+0.5d0*paj*pak-ajk
107 
108 C...Pick next I momentum to explore, hopefully closer to root.
109  IF(fnow.GT.0d0) THEN
110  paimin=pai
111  fmin=fnow
112  itmin=itmin+1
113  ELSE
114  paimax=pai
115  fmax=fnow
116  itmax=itmax+1
117  ENDIF
118  IF((iter.LT.10.OR.itmin.LE.1.OR.itmax.LE.1).AND.iter.LT.20)
119  & THEN
120  pai=0.5d0*(paimin+paimax)
121  goto 140
122  ELSEIF(iter.LT.40.AND.fmin.GT.0d0.AND.fmax.LT.0d0.AND.
123  & abs(fnow).GT.1d-12*psum2) THEN
124  pai=paimin+(paimax-paimin)*fmin/(fmin-fmax)
125  goto 140
126  ENDIF
127  ENDIF
128 
129 C...Now know energies in junction rest frame.
130  penew(i)=pei
131  penew(j)=pej
132  penew(k)=pek
133 
134 C...Boost (copy of) partons to their rest frame.
135  vxcm=-psum(1)/psum(5)
136  vycm=-psum(2)/psum(5)
137  vzcm=-psum(3)/psum(5)
138  gamcm=sqrt(1d0+vxcm**2+vycm**2+vzcm**2)
139  DO 150 i=1,3
140  fac1=pju(i,1)*vxcm+pju(i,2)*vycm+pju(i,3)*vzcm
141  fac2=fac1/(1d0+gamcm)+pju(i,4)
142  pcm(i,1)=pju(i,1)+fac2*vxcm
143  pcm(i,2)=pju(i,2)+fac2*vycm
144  pcm(i,3)=pju(i,3)+fac2*vzcm
145  pcm(i,4)=pju(i,4)*gamcm+fac1
146  pcm(i,5)=sqrt(pcm(i,1)**2+pcm(i,2)**2+pcm(i,3)**2)
147  150 CONTINUE
148 
149 C...Construct difference vectors and boost to junction rest frame.
150  DO 160 j=1,3
151  pcm(4,j)=pcm(1,j)/pcm(1,4)-pcm(2,j)/pcm(2,4)
152  pcm(5,j)=pcm(1,j)/pcm(1,4)-pcm(3,j)/pcm(3,4)
153  160 CONTINUE
154  pcm(4,4)=penew(1)/pcm(1,4)-penew(2)/pcm(2,4)
155  pcm(5,4)=penew(1)/pcm(1,4)-penew(3)/pcm(3,4)
156  pcm4s=pcm(4,1)**2+pcm(4,2)**2+pcm(4,3)**2
157  pcm5s=pcm(5,1)**2+pcm(5,2)**2+pcm(5,3)**2
158  pcm45=pcm(4,1)*pcm(5,1)+pcm(4,2)*pcm(5,2)+pcm(4,3)*pcm(5,3)
159  c4=(pcm5s*pcm(4,4)-pcm45*pcm(5,4))/(pcm4s*pcm5s-pcm45**2)
160  c5=(pcm4s*pcm(5,4)-pcm45*pcm(4,4))/(pcm4s*pcm5s-pcm45**2)
161  vxju=c4*pcm(4,1)+c5*pcm(5,1)
162  vyju=c4*pcm(4,2)+c5*pcm(5,2)
163  vzju=c4*pcm(4,3)+c5*pcm(5,3)
164  gamju=sqrt(1d0+vxju**2+vyju**2+vzju**2)
165 
166 C...Add two boosts, giving final result.
167  fcm=(vxju*vxcm+vyju*vycm+vzju*vzcm)/(1+gamcm)+gamju
168  vju(1)=vxju+fcm*vxcm
169  vju(2)=vyju+fcm*vycm
170  vju(3)=vzju+fcm*vzcm
171  vju(4)=sqrt(1d0+vju(1)**2+vju(2)**2+vju(3)**2)
172  vju(5)=1d0
173 
174 C...In case of error in reconstruction: revert to CM frame of system.
175  cth12=(pcm(1,1)*pcm(2,1)+pcm(1,2)*pcm(2,2)+pcm(1,3)*pcm(2,3))/
176  &(pcm(1,5)*pcm(2,5))
177  cth13=(pcm(1,1)*pcm(3,1)+pcm(1,2)*pcm(3,2)+pcm(1,3)*pcm(3,3))/
178  &(pcm(1,5)*pcm(3,5))
179  cth23=(pcm(2,1)*pcm(3,1)+pcm(2,2)*pcm(3,2)+pcm(2,3)*pcm(3,3))/
180  &(pcm(2,5)*pcm(3,5))
181  errccm=(cth12+0.5d0)**2+(cth13+0.5d0)**2+(cth23+0.5d0)**2
182  errtcm=twopi-acos(cth12)-acos(cth13)-acos(cth23)
183  DO 170 i=1,3
184  fac1=pju(i,1)*vju(1)+pju(i,2)*vju(2)+pju(i,3)*vju(3)
185  fac2=fac1/(1d0+vju(4))+pju(i,4)
186  pcm(i,1)=pju(i,1)+fac2*vju(1)
187  pcm(i,2)=pju(i,2)+fac2*vju(2)
188  pcm(i,3)=pju(i,3)+fac2*vju(3)
189  pcm(i,4)=pju(i,4)*vju(4)+fac1
190  pcm(i,5)=sqrt(pcm(i,1)**2+pcm(i,2)**2+pcm(i,3)**2)
191  170 CONTINUE
192  cth12=(pcm(1,1)*pcm(2,1)+pcm(1,2)*pcm(2,2)+pcm(1,3)*pcm(2,3))/
193  &(pcm(1,5)*pcm(2,5))
194  cth13=(pcm(1,1)*pcm(3,1)+pcm(1,2)*pcm(3,2)+pcm(1,3)*pcm(3,3))/
195  &(pcm(1,5)*pcm(3,5))
196  cth23=(pcm(2,1)*pcm(3,1)+pcm(2,2)*pcm(3,2)+pcm(2,3)*pcm(3,3))/
197  &(pcm(2,5)*pcm(3,5))
198  errcju=(cth12+0.5d0)**2+(cth13+0.5d0)**2+(cth23+0.5d0)**2
199  errtju=twopi-acos(cth12)-acos(cth13)-acos(cth23)
200  IF(errcju+errtju.GT.errccm+errtcm) THEN
201  vju(1)=vxcm
202  vju(2)=vycm
203  vju(3)=vzcm
204  vju(4)=gamcm
205  ENDIF
206 
207  RETURN
208  END