Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pysphe.f
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file pysphe.f
1 
2 C*********************************************************************
3 
4 C...PYSPHE
5 C...Performs sphericity tensor analysis to give sphericity,
6 C...aplanarity and the related event axes.
7 
8  SUBROUTINE pysphe(SPH,APL)
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),sv(3,3)
24 
25 C...Calculate matrix to be diagonalized.
26  np=0
27  DO 110 j1=1,3
28  DO 100 j2=j1,3
29  sm(j1,j2)=0d0
30  100 CONTINUE
31  110 CONTINUE
32  ps=0d0
33  DO 140 i=1,n
34  IF(k(i,1).LE.0.OR.k(i,1).GT.10) goto 140
35  IF(mstu(41).GE.2) THEN
36  kc=pycomp(k(i,2))
37  IF(kc.EQ.0.OR.kc.EQ.12.OR.kc.EQ.14.OR.kc.EQ.16.OR.
38  & kc.EQ.18.OR.k(i,2).EQ.ksusy1+22.OR.k(i,2).EQ.39.OR.
39  & k(i,2).EQ.ksusy1+39) goto 140
40  IF(mstu(41).GE.3.AND.kchg(kc,2).EQ.0.AND.pychge(k(i,2)).EQ.0)
41  & goto 140
42  ENDIF
43  np=np+1
44  pa=sqrt(p(i,1)**2+p(i,2)**2+p(i,3)**2)
45  pwt=1d0
46  IF(abs(paru(41)-2d0).GT.0.001d0) pwt=
47  & max(1d-10,pa)**(paru(41)-2d0)
48  DO 130 j1=1,3
49  DO 120 j2=j1,3
50  sm(j1,j2)=sm(j1,j2)+pwt*p(i,j1)*p(i,j2)
51  120 CONTINUE
52  130 CONTINUE
53  ps=ps+pwt*pa**2
54  140 CONTINUE
55 
56 C...Very low multiplicities (0 or 1) not considered.
57  IF(np.LE.1) THEN
58  CALL pyerrm(8,'(PYSPHE:) too few particles for analysis')
59  sph=-1d0
60  apl=-1d0
61  RETURN
62  ENDIF
63  DO 160 j1=1,3
64  DO 150 j2=j1,3
65  sm(j1,j2)=sm(j1,j2)/ps
66  150 CONTINUE
67  160 CONTINUE
68 
69 C...Find eigenvalues to matrix (third degree equation).
70  sq=(sm(1,1)*sm(2,2)+sm(1,1)*sm(3,3)+sm(2,2)*sm(3,3)-
71  &sm(1,2)**2-sm(1,3)**2-sm(2,3)**2)/3d0-1d0/9d0
72  sr=-0.5d0*(sq+1d0/9d0+sm(1,1)*sm(2,3)**2+sm(2,2)*sm(1,3)**2+
73  &sm(3,3)*sm(1,2)**2-sm(1,1)*sm(2,2)*sm(3,3))+
74  &sm(1,2)*sm(1,3)*sm(2,3)+1d0/27d0
75  sp=cos(acos(max(min(sr/sqrt(-sq**3),1d0),-1d0))/3d0)
76  p(n+1,4)=1d0/3d0+sqrt(-sq)*max(2d0*sp,sqrt(3d0*(1d0-sp**2))-sp)
77  p(n+3,4)=1d0/3d0+sqrt(-sq)*min(2d0*sp,-sqrt(3d0*(1d0-sp**2))-sp)
78  p(n+2,4)=1d0-p(n+1,4)-p(n+3,4)
79  IF(p(n+2,4).LT.1d-5) THEN
80  CALL pyerrm(8,'(PYSPHE:) all particles back-to-back')
81  sph=-1d0
82  apl=-1d0
83  RETURN
84  ENDIF
85 
86 C...Find first and last eigenvector by solving equation system.
87  DO 240 i=1,3,2
88  DO 180 j1=1,3
89  sv(j1,j1)=sm(j1,j1)-p(n+i,4)
90  DO 170 j2=j1+1,3
91  sv(j1,j2)=sm(j1,j2)
92  sv(j2,j1)=sm(j1,j2)
93  170 CONTINUE
94  180 CONTINUE
95  smax=0d0
96  DO 200 j1=1,3
97  DO 190 j2=1,3
98  IF(abs(sv(j1,j2)).LE.smax) goto 190
99  ja=j1
100  jb=j2
101  smax=abs(sv(j1,j2))
102  190 CONTINUE
103  200 CONTINUE
104  smax=0d0
105  DO 220 j3=ja+1,ja+2
106  j1=j3-3*((j3-1)/3)
107  rl=sv(j1,jb)/sv(ja,jb)
108  DO 210 j2=1,3
109  sv(j1,j2)=sv(j1,j2)-rl*sv(ja,j2)
110  IF(abs(sv(j1,j2)).LE.smax) goto 210
111  jc=j1
112  smax=abs(sv(j1,j2))
113  210 CONTINUE
114  220 CONTINUE
115  jb1=jb+1-3*(jb/3)
116  jb2=jb+2-3*((jb+1)/3)
117  p(n+i,jb1)=-sv(jc,jb2)
118  p(n+i,jb2)=sv(jc,jb1)
119  p(n+i,jb)=-(sv(ja,jb1)*p(n+i,jb1)+sv(ja,jb2)*p(n+i,jb2))/
120  & sv(ja,jb)
121  pa=sqrt(p(n+i,1)**2+p(n+i,2)**2+p(n+i,3)**2)
122  sgn=(-1d0)**int(pyr(0)+0.5d0)
123  DO 230 j=1,3
124  p(n+i,j)=sgn*p(n+i,j)/pa
125  230 CONTINUE
126  240 CONTINUE
127 
128 C...Middle axis orthogonal to other two. Fill other codes.
129  sgn=(-1d0)**int(pyr(0)+0.5d0)
130  p(n+2,1)=sgn*(p(n+1,2)*p(n+3,3)-p(n+1,3)*p(n+3,2))
131  p(n+2,2)=sgn*(p(n+1,3)*p(n+3,1)-p(n+1,1)*p(n+3,3))
132  p(n+2,3)=sgn*(p(n+1,1)*p(n+3,2)-p(n+1,2)*p(n+3,1))
133  DO 260 i=1,3
134  k(n+i,1)=31
135  k(n+i,2)=95
136  k(n+i,3)=i
137  k(n+i,4)=0
138  k(n+i,5)=0
139  p(n+i,5)=0d0
140  DO 250 j=1,5
141  v(i,j)=0d0
142  250 CONTINUE
143  260 CONTINUE
144 
145 C...Calculate sphericity and aplanarity. Select storing option.
146  sph=1.5d0*(p(n+2,4)+p(n+3,4))
147  apl=1.5d0*p(n+3,4)
148  mstu(61)=n+1
149  mstu(62)=np
150  IF(mstu(43).LE.1) mstu(3)=3
151  IF(mstu(43).GE.2) n=n+3
152 
153  RETURN
154  END