Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pythru.f
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file pythru.f
1 
2 C*********************************************************************
3 
4 C...PYTHRU
5 C...Performs thrust analysis to give thrust, oblateness
6 C...and the related event axes.
7 
8  SUBROUTINE pythru(THR,OBL)
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 tdi(3),tpr(3)
24 
25 C...Take copy of particles that are to be considered in thrust analysis.
26  np=0
27  ps=0d0
28  DO 100 i=1,n
29  IF(k(i,1).LE.0.OR.k(i,1).GT.10) goto 100
30  IF(mstu(41).GE.2) THEN
31  kc=pycomp(k(i,2))
32  IF(kc.EQ.0.OR.kc.EQ.12.OR.kc.EQ.14.OR.kc.EQ.16.OR.
33  & kc.EQ.18.OR.k(i,2).EQ.ksusy1+22.OR.k(i,2).EQ.39.OR.
34  & k(i,2).EQ.ksusy1+39) goto 100
35  IF(mstu(41).GE.3.AND.kchg(kc,2).EQ.0.AND.pychge(k(i,2)).EQ.0)
36  & goto 100
37  ENDIF
38  IF(n+np+mstu(44)+15.GE.mstu(4)-mstu(32)-5) THEN
39  CALL pyerrm(11,'(PYTHRU:) no more memory left in PYJETS')
40  thr=-2d0
41  obl=-2d0
42  RETURN
43  ENDIF
44  np=np+1
45  k(n+np,1)=23
46  p(n+np,1)=p(i,1)
47  p(n+np,2)=p(i,2)
48  p(n+np,3)=p(i,3)
49  p(n+np,4)=sqrt(p(i,1)**2+p(i,2)**2+p(i,3)**2)
50  p(n+np,5)=1d0
51  IF(abs(paru(42)-1d0).GT.0.001d0) p(n+np,5)=
52  & p(n+np,4)**(paru(42)-1d0)
53  ps=ps+p(n+np,4)*p(n+np,5)
54  100 CONTINUE
55 
56 C...Very low multiplicities (0 or 1) not considered.
57  IF(np.LE.1) THEN
58  CALL pyerrm(8,'(PYTHRU:) too few particles for analysis')
59  thr=-1d0
60  obl=-1d0
61  RETURN
62  ENDIF
63 
64 C...Loop over thrust and major. T axis along z direction in latter case.
65  DO 320 ild=1,2
66  IF(ild.EQ.2) THEN
67  k(n+np+1,1)=31
68  phi=pyangl(p(n+np+1,1),p(n+np+1,2))
69  mstu(33)=1
70  CALL pyrobo(n+1,n+np+1,0d0,-phi,0d0,0d0,0d0)
71  the=pyangl(p(n+np+1,3),p(n+np+1,1))
72  CALL pyrobo(n+1,n+np+1,-the,0d0,0d0,0d0,0d0)
73  ENDIF
74 
75 C...Find and order particles with highest p (pT for major).
76  DO 110 ilf=n+np+4,n+np+mstu(44)+4
77  p(ilf,4)=0d0
78  110 CONTINUE
79  DO 160 i=n+1,n+np
80  IF(ild.EQ.2) p(i,4)=sqrt(p(i,1)**2+p(i,2)**2)
81  DO 130 ilf=n+np+mstu(44)+3,n+np+4,-1
82  IF(p(i,4).LE.p(ilf,4)) goto 140
83  DO 120 j=1,5
84  p(ilf+1,j)=p(ilf,j)
85  120 CONTINUE
86  130 CONTINUE
87  ilf=n+np+3
88  140 DO 150 j=1,5
89  p(ilf+1,j)=p(i,j)
90  150 CONTINUE
91  160 CONTINUE
92 
93 C...Find and order initial axes with highest thrust (major).
94  DO 170 ilg=n+np+mstu(44)+5,n+np+mstu(44)+15
95  p(ilg,4)=0d0
96  170 CONTINUE
97  nc=2**(min(mstu(44),np)-1)
98  DO 250 ilc=1,nc
99  DO 180 j=1,3
100  tdi(j)=0d0
101  180 CONTINUE
102  DO 200 ilf=1,min(mstu(44),np)
103  sgn=p(n+np+ilf+3,5)
104  IF(2**ilf*((ilc+2**(ilf-1)-1)/2**ilf).GE.ilc) sgn=-sgn
105  DO 190 j=1,4-ild
106  tdi(j)=tdi(j)+sgn*p(n+np+ilf+3,j)
107  190 CONTINUE
108  200 CONTINUE
109  tds=tdi(1)**2+tdi(2)**2+tdi(3)**2
110  DO 220 ilg=n+np+mstu(44)+min(ilc,10)+4,n+np+mstu(44)+5,-1
111  IF(tds.LE.p(ilg,4)) goto 230
112  DO 210 j=1,4
113  p(ilg+1,j)=p(ilg,j)
114  210 CONTINUE
115  220 CONTINUE
116  ilg=n+np+mstu(44)+4
117  230 DO 240 j=1,3
118  p(ilg+1,j)=tdi(j)
119  240 CONTINUE
120  p(ilg+1,4)=tds
121  250 CONTINUE
122 
123 C...Iterate direction of axis until stable maximum.
124  p(n+np+ild,4)=0d0
125  ilg=0
126  260 ilg=ilg+1
127  thp=0d0
128  270 thps=thp
129  DO 280 j=1,3
130  IF(thp.LE.1d-10) tdi(j)=p(n+np+mstu(44)+4+ilg,j)
131  IF(thp.GT.1d-10) tdi(j)=tpr(j)
132  tpr(j)=0d0
133  280 CONTINUE
134  DO 300 i=n+1,n+np
135  sgn=sign(p(i,5),tdi(1)*p(i,1)+tdi(2)*p(i,2)+tdi(3)*p(i,3))
136  DO 290 j=1,4-ild
137  tpr(j)=tpr(j)+sgn*p(i,j)
138  290 CONTINUE
139  300 CONTINUE
140  thp=sqrt(tpr(1)**2+tpr(2)**2+tpr(3)**2)/ps
141  IF(thp.GE.thps+paru(48)) goto 270
142 
143 C...Save good axis. Try new initial axis until a number of tries agree.
144  IF(thp.LT.p(n+np+ild,4)-paru(48).AND.ilg.LT.min(10,nc)) goto 260
145  IF(thp.GT.p(n+np+ild,4)+paru(48)) THEN
146  iagr=0
147  sgn=(-1d0)**int(pyr(0)+0.5d0)
148  DO 310 j=1,3
149  p(n+np+ild,j)=sgn*tpr(j)/(ps*thp)
150  310 CONTINUE
151  p(n+np+ild,4)=thp
152  p(n+np+ild,5)=0d0
153  ENDIF
154  iagr=iagr+1
155  IF(iagr.LT.mstu(45).AND.ilg.LT.min(10,nc)) goto 260
156  320 CONTINUE
157 
158 C...Find minor axis and value by orthogonality.
159  sgn=(-1d0)**int(pyr(0)+0.5d0)
160  p(n+np+3,1)=-sgn*p(n+np+2,2)
161  p(n+np+3,2)=sgn*p(n+np+2,1)
162  p(n+np+3,3)=0d0
163  thp=0d0
164  DO 330 i=n+1,n+np
165  thp=thp+p(i,5)*abs(p(n+np+3,1)*p(i,1)+p(n+np+3,2)*p(i,2))
166  330 CONTINUE
167  p(n+np+3,4)=thp/ps
168  p(n+np+3,5)=0d0
169 
170 C...Fill axis information. Rotate back to original coordinate system.
171  DO 350 ild=1,3
172  k(n+ild,1)=31
173  k(n+ild,2)=96
174  k(n+ild,3)=ild
175  k(n+ild,4)=0
176  k(n+ild,5)=0
177  DO 340 j=1,5
178  p(n+ild,j)=p(n+np+ild,j)
179  v(n+ild,j)=0d0
180  340 CONTINUE
181  350 CONTINUE
182  CALL pyrobo(n+1,n+3,the,phi,0d0,0d0,0d0)
183 
184 C...Calculate thrust and oblateness. Select storing option.
185  thr=p(n+1,4)
186  obl=p(n+2,4)-p(n+3,4)
187  mstu(61)=n+1
188  mstu(62)=np
189  IF(mstu(43).LE.1) mstu(3)=3
190  IF(mstu(43).GE.2) n=n+3
191 
192  RETURN
193  END