Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pyjmas.f
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file pyjmas.f
1 
2 C*********************************************************************
3 
4 C...PYJMAS
5 C...Determines, approximately, the two jet masses that minimize
6 C...the sum m_H^2 + m_L^2, a la Clavelli and Wyler.
7 
8  SUBROUTINE pyjmas(PMH,PML)
9 
10 C...Double precision and integer declarations.
11  IMPLICIT DOUBLE PRECISION(a-h, o-z)
12  IMPLICIT INTEGER(i-n)
13  INTEGER pyk,pychge,pycomp
14 C...Parameter statement to help give large particle numbers.
15  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
16  &kexcit=4000000,kdimen=5000000)
17 C...Commonblocks.
18  common/pyjets/n,npad,k(4000,5),p(4000,5),v(4000,5)
19  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
20  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
21  SAVE /pyjets/,/pydat1/,/pydat2/
22 C...Local arrays.
23  dimension sm(3,3),sax(3),ps(3,5)
24 
25 C...Reset.
26  np=0
27  DO 120 j1=1,3
28  DO 100 j2=j1,3
29  sm(j1,j2)=0d0
30  100 CONTINUE
31  DO 110 j2=1,4
32  ps(j1,j2)=0d0
33  110 CONTINUE
34  120 CONTINUE
35  pss=0d0
36  pimass=pmas(pycomp(211),1)
37 
38 C...Take copy of particles that are to be considered in mass analysis.
39  DO 170 i=1,n
40  IF(k(i,1).LE.0.OR.k(i,1).GT.10) goto 170
41  IF(mstu(41).GE.2) THEN
42  kc=pycomp(k(i,2))
43  IF(kc.EQ.0.OR.kc.EQ.12.OR.kc.EQ.14.OR.kc.EQ.16.OR.
44  & kc.EQ.18.OR.k(i,2).EQ.ksusy1+22.OR.k(i,2).EQ.39.OR.
45  & k(i,2).EQ.ksusy1+39) goto 170
46  IF(mstu(41).GE.3.AND.kchg(kc,2).EQ.0.AND.pychge(k(i,2)).EQ.0)
47  & goto 170
48  ENDIF
49  IF(n+np+1.GE.mstu(4)-mstu(32)-5) THEN
50  CALL pyerrm(11,'(PYJMAS:) no more memory left in PYJETS')
51  pmh=-2d0
52  pml=-2d0
53  RETURN
54  ENDIF
55  np=np+1
56  DO 130 j=1,5
57  p(n+np,j)=p(i,j)
58  130 CONTINUE
59  IF(mstu(42).EQ.0) p(n+np,5)=0d0
60  IF(mstu(42).EQ.1.AND.k(i,2).NE.22) p(n+np,5)=pimass
61  p(n+np,4)=sqrt(p(n+np,5)**2+p(i,1)**2+p(i,2)**2+p(i,3)**2)
62 
63 C...Fill information in sphericity tensor and total momentum vector.
64  DO 150 j1=1,3
65  DO 140 j2=j1,3
66  sm(j1,j2)=sm(j1,j2)+p(i,j1)*p(i,j2)
67  140 CONTINUE
68  150 CONTINUE
69  pss=pss+(p(i,1)**2+p(i,2)**2+p(i,3)**2)
70  DO 160 j=1,4
71  ps(3,j)=ps(3,j)+p(n+np,j)
72  160 CONTINUE
73  170 CONTINUE
74 
75 C...Very low multiplicities (0 or 1) not considered.
76  IF(np.LE.1) THEN
77  CALL pyerrm(8,'(PYJMAS:) too few particles for analysis')
78  pmh=-1d0
79  pml=-1d0
80  RETURN
81  ENDIF
82  paru(61)=sqrt(max(0d0,ps(3,4)**2-ps(3,1)**2-ps(3,2)**2-
83  &ps(3,3)**2))
84 
85 C...Find largest eigenvalue to matrix (third degree equation).
86  DO 190 j1=1,3
87  DO 180 j2=j1,3
88  sm(j1,j2)=sm(j1,j2)/pss
89  180 CONTINUE
90  190 CONTINUE
91  sq=(sm(1,1)*sm(2,2)+sm(1,1)*sm(3,3)+sm(2,2)*sm(3,3)-
92  &sm(1,2)**2-sm(1,3)**2-sm(2,3)**2)/3d0-1d0/9d0
93  sr=-0.5d0*(sq+1d0/9d0+sm(1,1)*sm(2,3)**2+sm(2,2)*sm(1,3)**2+
94  &sm(3,3)*sm(1,2)**2-sm(1,1)*sm(2,2)*sm(3,3))+
95  &sm(1,2)*sm(1,3)*sm(2,3)+1d0/27d0
96  sp=cos(acos(max(min(sr/sqrt(-sq**3),1d0),-1d0))/3d0)
97  sma=1d0/3d0+sqrt(-sq)*max(2d0*sp,sqrt(3d0*(1d0-sp**2))-sp)
98 
99 C...Find largest eigenvector by solving equation system.
100  DO 210 j1=1,3
101  sm(j1,j1)=sm(j1,j1)-sma
102  DO 200 j2=j1+1,3
103  sm(j2,j1)=sm(j1,j2)
104  200 CONTINUE
105  210 CONTINUE
106  smax=0d0
107  DO 230 j1=1,3
108  DO 220 j2=1,3
109  IF(abs(sm(j1,j2)).LE.smax) goto 220
110  ja=j1
111  jb=j2
112  smax=abs(sm(j1,j2))
113  220 CONTINUE
114  230 CONTINUE
115  smax=0d0
116  DO 250 j3=ja+1,ja+2
117  j1=j3-3*((j3-1)/3)
118  rl=sm(j1,jb)/sm(ja,jb)
119  DO 240 j2=1,3
120  sm(j1,j2)=sm(j1,j2)-rl*sm(ja,j2)
121  IF(abs(sm(j1,j2)).LE.smax) goto 240
122  jc=j1
123  smax=abs(sm(j1,j2))
124  240 CONTINUE
125  250 CONTINUE
126  jb1=jb+1-3*(jb/3)
127  jb2=jb+2-3*((jb+1)/3)
128  sax(jb1)=-sm(jc,jb2)
129  sax(jb2)=sm(jc,jb1)
130  sax(jb)=-(sm(ja,jb1)*sax(jb1)+sm(ja,jb2)*sax(jb2))/sm(ja,jb)
131 
132 C...Divide particles into two initial clusters by hemisphere.
133  DO 270 i=n+1,n+np
134  psax=p(i,1)*sax(1)+p(i,2)*sax(2)+p(i,3)*sax(3)
135  is=1
136  IF(psax.LT.0d0) is=2
137  k(i,3)=is
138  DO 260 j=1,4
139  ps(is,j)=ps(is,j)+p(i,j)
140  260 CONTINUE
141  270 CONTINUE
142  pms=max(1d-10,ps(1,4)**2-ps(1,1)**2-ps(1,2)**2-ps(1,3)**2)+
143  &max(1d-10,ps(2,4)**2-ps(2,1)**2-ps(2,2)**2-ps(2,3)**2)
144 
145 C...Reassign one particle at a time; find maximum decrease of m^2 sum.
146  280 pmd=0d0
147  im=0
148  DO 290 j=1,4
149  ps(3,j)=ps(1,j)-ps(2,j)
150  290 CONTINUE
151  DO 300 i=n+1,n+np
152  pps=p(i,4)*ps(3,4)-p(i,1)*ps(3,1)-p(i,2)*ps(3,2)-p(i,3)*ps(3,3)
153  IF(k(i,3).EQ.1) pmdi=2d0*(p(i,5)**2-pps)
154  IF(k(i,3).EQ.2) pmdi=2d0*(p(i,5)**2+pps)
155  IF(pmdi.LT.pmd) THEN
156  pmd=pmdi
157  im=i
158  ENDIF
159  300 CONTINUE
160 
161 C...Loop back if significant reduction in sum of m^2.
162  IF(pmd.LT.-paru(48)*pms) THEN
163  pms=pms+pmd
164  is=k(im,3)
165  DO 310 j=1,4
166  ps(is,j)=ps(is,j)-p(im,j)
167  ps(3-is,j)=ps(3-is,j)+p(im,j)
168  310 CONTINUE
169  k(im,3)=3-is
170  goto 280
171  ENDIF
172 
173 C...Final masses and output.
174  mstu(61)=n+1
175  mstu(62)=np
176  ps(1,5)=sqrt(max(0d0,ps(1,4)**2-ps(1,1)**2-ps(1,2)**2-ps(1,3)**2))
177  ps(2,5)=sqrt(max(0d0,ps(2,4)**2-ps(2,1)**2-ps(2,2)**2-ps(2,3)**2))
178  pmh=max(ps(1,5),ps(2,5))
179  pml=min(ps(1,5),ps(2,5))
180 
181  RETURN
182  END