Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pytabu.f
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file pytabu.f
1 
2 C*********************************************************************
3 
4 C...PYTABU
5 C...Evaluates various properties of an event, with statistics
6 C...accumulated during the course of the run and
7 C...printed at the end.
8 
9  SUBROUTINE pytabu(MTABU)
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...Parameter statement to help give large particle numbers.
16  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
17  &kexcit=4000000,kdimen=5000000)
18 C...Commonblocks.
19  common/pyjets/n,npad,k(4000,5),p(4000,5),v(4000,5)
20  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
21  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
22  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
23  SAVE /pyjets/,/pydat1/,/pydat2/,/pydat3/
24 C...Local arrays, character variables, saved variables and data.
25  dimension kfis(100,2),npis(100,0:10),kffs(400),npfs(400,4),
26  &fevfm(10,4),fm1fm(3,10,4),fm2fm(3,10,4),fmoma(4),fmoms(4),
27  &fevee(50),fe1ec(50),fe2ec(50),fe1ea(25),fe2ea(25),
28  &kfdm(8),kfdc(200,0:8),npdc(200)
29  SAVE nevis,nkfis,kfis,npis,nevfs,nprfs,nfifs,nchfs,nkffs,
30  &kffs,npfs,nevfm,nmufm,fm1fm,fm2fm,nevee,fe1ec,fe2ec,fe1ea,
31  &fe2ea,nevdc,nkfdc,nredc,kfdc,npdc
32  CHARACTER chau*16,chis(2)*12,chdc(8)*12
33  DATA nevis/0/,nkfis/0/,nevfs/0/,nprfs/0/,nfifs/0/,nchfs/0/,
34  &nkffs/0/,nevfm/0/,nmufm/0/,fm1fm/120*0d0/,fm2fm/120*0d0/,
35  &nevee/0/,fe1ec/50*0d0/,fe2ec/50*0d0/,fe1ea/25*0d0/,fe2ea/25*0d0/,
36  &nevdc/0/,nkfdc/0/,nredc/0/
37 
38 C...Reset statistics on initial parton state.
39  IF(mtabu.EQ.10) THEN
40  nevis=0
41  nkfis=0
42 
43 C...Identify and order flavour content of initial state.
44  ELSEIF(mtabu.EQ.11) THEN
45  nevis=nevis+1
46  kfm1=2*iabs(mstu(161))
47  IF(mstu(161).GT.0) kfm1=kfm1-1
48  kfm2=2*iabs(mstu(162))
49  IF(mstu(162).GT.0) kfm2=kfm2-1
50  kfmn=min(kfm1,kfm2)
51  kfmx=max(kfm1,kfm2)
52  DO 100 i=1,nkfis
53  IF(kfmn.EQ.kfis(i,1).AND.kfmx.EQ.kfis(i,2)) THEN
54  ikfis=-i
55  goto 110
56  ELSEIF(kfmn.LT.kfis(i,1).OR.(kfmn.EQ.kfis(i,1).AND.
57  & kfmx.LT.kfis(i,2))) THEN
58  ikfis=i
59  goto 110
60  ENDIF
61  100 CONTINUE
62  ikfis=nkfis+1
63  110 IF(ikfis.LT.0) THEN
64  ikfis=-ikfis
65  ELSE
66  IF(nkfis.GE.100) RETURN
67  DO 130 i=nkfis,ikfis,-1
68  kfis(i+1,1)=kfis(i,1)
69  kfis(i+1,2)=kfis(i,2)
70  DO 120 j=0,10
71  npis(i+1,j)=npis(i,j)
72  120 CONTINUE
73  130 CONTINUE
74  nkfis=nkfis+1
75  kfis(ikfis,1)=kfmn
76  kfis(ikfis,2)=kfmx
77  DO 140 j=0,10
78  npis(ikfis,j)=0
79  140 CONTINUE
80  ENDIF
81  npis(ikfis,0)=npis(ikfis,0)+1
82 
83 C...Count number of partons in initial state.
84  np=0
85  DO 160 i=1,n
86  IF(k(i,1).LE.0.OR.k(i,1).GT.12) THEN
87  ELSEIF(iabs(k(i,2)).GT.80.AND.iabs(k(i,2)).LE.100) THEN
88  ELSEIF(iabs(k(i,2)).GT.100.AND.mod(iabs(k(i,2))/10,10).NE.0)
89  & THEN
90  ELSE
91  im=i
92  150 im=k(im,3)
93  IF(im.LE.0.OR.im.GT.n) THEN
94  np=np+1
95  ELSEIF(k(im,1).LE.0.OR.k(im,1).GT.20) THEN
96  np=np+1
97  ELSEIF(iabs(k(im,2)).GT.80.AND.iabs(k(im,2)).LE.100) THEN
98  ELSEIF(iabs(k(im,2)).GT.100.AND.mod(iabs(k(im,2))/10,10)
99  & .NE.0) THEN
100  ELSE
101  goto 150
102  ENDIF
103  ENDIF
104  160 CONTINUE
105  npco=max(np,1)
106  IF(np.GE.6) npco=6
107  IF(np.GE.8) npco=7
108  IF(np.GE.11) npco=8
109  IF(np.GE.16) npco=9
110  IF(np.GE.26) npco=10
111  npis(ikfis,npco)=npis(ikfis,npco)+1
112  mstu(62)=np
113 
114 C...Write statistics on initial parton state.
115  ELSEIF(mtabu.EQ.12) THEN
116  fac=1d0/max(1,nevis)
117  WRITE(mstu(11),5000) nevis
118  DO 170 i=1,nkfis
119  kfmn=kfis(i,1)
120  IF(kfmn.EQ.0) kfmn=kfis(i,2)
121  kfm1=(kfmn+1)/2
122  IF(2*kfm1.EQ.kfmn) kfm1=-kfm1
123  CALL pyname(kfm1,chau)
124  chis(1)=chau(1:12)
125  IF(chau(13:13).NE.' ') chis(1)(12:12)='?'
126  kfmx=kfis(i,2)
127  IF(kfis(i,1).EQ.0) kfmx=0
128  kfm2=(kfmx+1)/2
129  IF(2*kfm2.EQ.kfmx) kfm2=-kfm2
130  CALL pyname(kfm2,chau)
131  chis(2)=chau(1:12)
132  IF(chau(13:13).NE.' ') chis(2)(12:12)='?'
133  WRITE(mstu(11),5100) chis(1),chis(2),fac*npis(i,0),
134  & (npis(i,j)/dble(npis(i,0)),j=1,10)
135  170 CONTINUE
136 
137 C...Copy statistics on initial parton state into /PYJETS/.
138  ELSEIF(mtabu.EQ.13) THEN
139  fac=1d0/max(1,nevis)
140  DO 190 i=1,nkfis
141  kfmn=kfis(i,1)
142  IF(kfmn.EQ.0) kfmn=kfis(i,2)
143  kfm1=(kfmn+1)/2
144  IF(2*kfm1.EQ.kfmn) kfm1=-kfm1
145  kfmx=kfis(i,2)
146  IF(kfis(i,1).EQ.0) kfmx=0
147  kfm2=(kfmx+1)/2
148  IF(2*kfm2.EQ.kfmx) kfm2=-kfm2
149  k(i,1)=32
150  k(i,2)=99
151  k(i,3)=kfm1
152  k(i,4)=kfm2
153  k(i,5)=npis(i,0)
154  DO 180 j=1,5
155  p(i,j)=fac*npis(i,j)
156  v(i,j)=fac*npis(i,j+5)
157  180 CONTINUE
158  190 CONTINUE
159  n=nkfis
160  DO 200 j=1,5
161  k(n+1,j)=0
162  p(n+1,j)=0d0
163  v(n+1,j)=0d0
164  200 CONTINUE
165  k(n+1,1)=32
166  k(n+1,2)=99
167  k(n+1,5)=nevis
168  mstu(3)=1
169 
170 C...Reset statistics on number of particles/partons.
171  ELSEIF(mtabu.EQ.20) THEN
172  nevfs=0
173  nprfs=0
174  nfifs=0
175  nchfs=0
176  nkffs=0
177 
178 C...Identify whether particle/parton is primary or not.
179  ELSEIF(mtabu.EQ.21) THEN
180  nevfs=nevfs+1
181  mstu(62)=0
182  DO 260 i=1,n
183  IF(k(i,1).LE.0.OR.k(i,1).GT.20.OR.k(i,1).EQ.13) goto 260
184  mstu(62)=mstu(62)+1
185  kc=pycomp(k(i,2))
186  mpri=0
187  IF(k(i,3).LE.0.OR.k(i,3).GT.n) THEN
188  mpri=1
189  ELSEIF(k(k(i,3),1).LE.0.OR.k(k(i,3),1).GT.20) THEN
190  mpri=1
191  ELSEIF(k(k(i,3),2).GE.91.AND.k(k(i,3),2).LE.93) THEN
192  mpri=1
193  ELSEIF(kc.EQ.0) THEN
194  ELSEIF(k(k(i,3),1).EQ.13) THEN
195  im=k(k(i,3),3)
196  IF(im.LE.0.OR.im.GT.n) THEN
197  mpri=1
198  ELSEIF(k(im,1).LE.0.OR.k(im,1).GT.20) THEN
199  mpri=1
200  ENDIF
201  ELSEIF(kchg(kc,2).EQ.0) THEN
202  kcm=pycomp(k(k(i,3),2))
203  IF(kcm.NE.0) THEN
204  IF(kchg(kcm,2).NE.0) mpri=1
205  ENDIF
206  ENDIF
207  IF(kc.NE.0.AND.mpri.EQ.1) THEN
208  IF(kchg(kc,2).EQ.0) nprfs=nprfs+1
209  ENDIF
210  IF(k(i,1).LE.10) THEN
211  nfifs=nfifs+1
212  IF(pychge(k(i,2)).NE.0) nchfs=nchfs+1
213  ENDIF
214 
215 C...Fill statistics on number of particles/partons in event.
216  kfa=iabs(k(i,2))
217  kfs=3-isign(1,k(i,2))-mpri
218  DO 210 ip=1,nkffs
219  IF(kfa.EQ.kffs(ip)) THEN
220  ikffs=-ip
221  goto 220
222  ELSEIF(kfa.LT.kffs(ip)) THEN
223  ikffs=ip
224  goto 220
225  ENDIF
226  210 CONTINUE
227  ikffs=nkffs+1
228  220 IF(ikffs.LT.0) THEN
229  ikffs=-ikffs
230  ELSE
231  IF(nkffs.GE.400) RETURN
232  DO 240 ip=nkffs,ikffs,-1
233  kffs(ip+1)=kffs(ip)
234  DO 230 j=1,4
235  npfs(ip+1,j)=npfs(ip,j)
236  230 CONTINUE
237  240 CONTINUE
238  nkffs=nkffs+1
239  kffs(ikffs)=kfa
240  DO 250 j=1,4
241  npfs(ikffs,j)=0
242  250 CONTINUE
243  ENDIF
244  npfs(ikffs,kfs)=npfs(ikffs,kfs)+1
245  260 CONTINUE
246 
247 C...Write statistics on particle/parton composition of events.
248  ELSEIF(mtabu.EQ.22) THEN
249  fac=1d0/max(1,nevfs)
250  WRITE(mstu(11),5200) nevfs,fac*nprfs,fac*nfifs,fac*nchfs
251  DO 270 i=1,nkffs
252  CALL pyname(kffs(i),chau)
253  kc=pycomp(kffs(i))
254  mdcyf=0
255  IF(kc.NE.0) mdcyf=mdcy(kc,1)
256  WRITE(mstu(11),5300) kffs(i),chau,mdcyf,(fac*npfs(i,j),j=1,4),
257  & fac*(npfs(i,1)+npfs(i,2)+npfs(i,3)+npfs(i,4))
258  270 CONTINUE
259 
260 C...Copy particle/parton composition information into /PYJETS/.
261  ELSEIF(mtabu.EQ.23) THEN
262  fac=1d0/max(1,nevfs)
263  DO 290 i=1,nkffs
264  k(i,1)=32
265  k(i,2)=99
266  k(i,3)=kffs(i)
267  k(i,4)=0
268  k(i,5)=npfs(i,1)+npfs(i,2)+npfs(i,3)+npfs(i,4)
269  DO 280 j=1,4
270  p(i,j)=fac*npfs(i,j)
271  v(i,j)=0d0
272  280 CONTINUE
273  p(i,5)=fac*k(i,5)
274  v(i,5)=0d0
275  290 CONTINUE
276  n=nkffs
277  DO 300 j=1,5
278  k(n+1,j)=0
279  p(n+1,j)=0d0
280  v(n+1,j)=0d0
281  300 CONTINUE
282  k(n+1,1)=32
283  k(n+1,2)=99
284  k(n+1,5)=nevfs
285  p(n+1,1)=fac*nprfs
286  p(n+1,2)=fac*nfifs
287  p(n+1,3)=fac*nchfs
288  mstu(3)=1
289 
290 C...Reset factorial moments statistics.
291  ELSEIF(mtabu.EQ.30) THEN
292  nevfm=0
293  nmufm=0
294  DO 330 im=1,3
295  DO 320 ib=1,10
296  DO 310 ip=1,4
297  fm1fm(im,ib,ip)=0d0
298  fm2fm(im,ib,ip)=0d0
299  310 CONTINUE
300  320 CONTINUE
301  330 CONTINUE
302 
303 C...Find particles to include, with (pion,pseudo)rapidity and azimuth.
304  ELSEIF(mtabu.EQ.31) THEN
305  nevfm=nevfm+1
306  nlow=n+mstu(3)
307  nupp=nlow
308  DO 410 i=1,n
309  IF(k(i,1).LE.0.OR.k(i,1).GT.10) goto 410
310  IF(mstu(41).GE.2) THEN
311  kc=pycomp(k(i,2))
312  IF(kc.EQ.0.OR.kc.EQ.12.OR.kc.EQ.14.OR.kc.EQ.16.OR.
313  & kc.EQ.18.OR.k(i,2).EQ.ksusy1+22.OR.k(i,2).EQ.39.OR.
314  & k(i,2).EQ.ksusy1+39) goto 410
315  IF(mstu(41).GE.3.AND.kchg(kc,2).EQ.0.AND.
316  & pychge(k(i,2)).EQ.0) goto 410
317  ENDIF
318  pmr=0d0
319  IF(mstu(42).EQ.1.AND.k(i,2).NE.22) pmr=pymass(211)
320  IF(mstu(42).GE.2) pmr=p(i,5)
321  pr=max(1d-20,pmr**2+p(i,1)**2+p(i,2)**2)
322  yeta=sign(log(min((sqrt(pr+p(i,3)**2)+abs(p(i,3)))/sqrt(pr),
323  & 1d20)),p(i,3))
324  IF(abs(yeta).GT.paru(57)) goto 410
325  phi=pyangl(p(i,1),p(i,2))
326  iyeta=512d0*(yeta+paru(57))/(2d0*paru(57))
327  iyeta=max(0,min(511,iyeta))
328  iphi=512d0*(phi+paru(1))/paru(2)
329  iphi=max(0,min(511,iphi))
330  iyep=0
331  DO 340 ib=0,9
332  iyep=iyep+4**ib*(2*mod(iyeta/2**ib,2)+mod(iphi/2**ib,2))
333  340 CONTINUE
334 
335 C...Order particles in (pseudo)rapidity and/or azimuth.
336  IF(nupp.GT.mstu(4)-5-mstu(32)) THEN
337  CALL pyerrm(11,'(PYTABU:) no more memory left in PYJETS')
338  RETURN
339  ENDIF
340  nupp=nupp+1
341  IF(nupp.EQ.nlow+1) THEN
342  k(nupp,1)=iyeta
343  k(nupp,2)=iphi
344  k(nupp,3)=iyep
345  ELSE
346  DO 350 i1=nupp-1,nlow+1,-1
347  IF(iyeta.GE.k(i1,1)) goto 360
348  k(i1+1,1)=k(i1,1)
349  350 CONTINUE
350  360 k(i1+1,1)=iyeta
351  DO 370 i1=nupp-1,nlow+1,-1
352  IF(iphi.GE.k(i1,2)) goto 380
353  k(i1+1,2)=k(i1,2)
354  370 CONTINUE
355  380 k(i1+1,2)=iphi
356  DO 390 i1=nupp-1,nlow+1,-1
357  IF(iyep.GE.k(i1,3)) goto 400
358  k(i1+1,3)=k(i1,3)
359  390 CONTINUE
360  400 k(i1+1,3)=iyep
361  ENDIF
362  410 CONTINUE
363  k(nupp+1,1)=2**10
364  k(nupp+1,2)=2**10
365  k(nupp+1,3)=4**10
366 
367 C...Calculate sum of factorial moments in event.
368  DO 480 im=1,3
369  DO 430 ib=1,10
370  DO 420 ip=1,4
371  fevfm(ib,ip)=0d0
372  420 CONTINUE
373  430 CONTINUE
374  DO 450 ib=1,10
375  IF(im.LE.2) ibin=2**(10-ib)
376  IF(im.EQ.3) ibin=4**(10-ib)
377  iagr=k(nlow+1,im)/ibin
378  nagr=1
379  DO 440 i=nlow+2,nupp+1
380  icut=k(i,im)/ibin
381  IF(icut.EQ.iagr) THEN
382  nagr=nagr+1
383  ELSE
384  IF(nagr.EQ.1) THEN
385  ELSEIF(nagr.EQ.2) THEN
386  fevfm(ib,1)=fevfm(ib,1)+2d0
387  ELSEIF(nagr.EQ.3) THEN
388  fevfm(ib,1)=fevfm(ib,1)+6d0
389  fevfm(ib,2)=fevfm(ib,2)+6d0
390  ELSEIF(nagr.EQ.4) THEN
391  fevfm(ib,1)=fevfm(ib,1)+12d0
392  fevfm(ib,2)=fevfm(ib,2)+24d0
393  fevfm(ib,3)=fevfm(ib,3)+24d0
394  ELSE
395  fevfm(ib,1)=fevfm(ib,1)+nagr*(nagr-1d0)
396  fevfm(ib,2)=fevfm(ib,2)+nagr*(nagr-1d0)*(nagr-2d0)
397  fevfm(ib,3)=fevfm(ib,3)+nagr*(nagr-1d0)*(nagr-2d0)*
398  & (nagr-3d0)
399  fevfm(ib,4)=fevfm(ib,4)+nagr*(nagr-1d0)*(nagr-2d0)*
400  & (nagr-3d0)*(nagr-4d0)
401  ENDIF
402  iagr=icut
403  nagr=1
404  ENDIF
405  440 CONTINUE
406  450 CONTINUE
407 
408 C...Add results to total statistics.
409  DO 470 ib=10,1,-1
410  DO 460 ip=1,4
411  IF(fevfm(1,ip).LT.0.5d0) THEN
412  fevfm(ib,ip)=0d0
413  ELSEIF(im.LE.2) THEN
414  fevfm(ib,ip)=2d0**((ib-1)*ip)*fevfm(ib,ip)/fevfm(1,ip)
415  ELSE
416  fevfm(ib,ip)=4d0**((ib-1)*ip)*fevfm(ib,ip)/fevfm(1,ip)
417  ENDIF
418  fm1fm(im,ib,ip)=fm1fm(im,ib,ip)+fevfm(ib,ip)
419  fm2fm(im,ib,ip)=fm2fm(im,ib,ip)+fevfm(ib,ip)**2
420  460 CONTINUE
421  470 CONTINUE
422  480 CONTINUE
423  nmufm=nmufm+(nupp-nlow)
424  mstu(62)=nupp-nlow
425 
426 C...Write accumulated statistics on factorial moments.
427  ELSEIF(mtabu.EQ.32) THEN
428  fac=1d0/max(1,nevfm)
429  IF(mstu(42).LE.0) WRITE(mstu(11),5400) nevfm,'eta'
430  IF(mstu(42).EQ.1) WRITE(mstu(11),5400) nevfm,'ypi'
431  IF(mstu(42).GE.2) WRITE(mstu(11),5400) nevfm,'y '
432  DO 510 im=1,3
433  WRITE(mstu(11),5500)
434  DO 500 ib=1,10
435  byeta=2d0*paru(57)
436  IF(im.NE.2) byeta=byeta/2**(ib-1)
437  bphi=paru(2)
438  IF(im.NE.1) bphi=bphi/2**(ib-1)
439  IF(im.LE.2) bnave=fac*nmufm/dble(2**(ib-1))
440  IF(im.EQ.3) bnave=fac*nmufm/dble(4**(ib-1))
441  DO 490 ip=1,4
442  fmoma(ip)=fac*fm1fm(im,ib,ip)
443  fmoms(ip)=sqrt(max(0d0,fac*(fac*fm2fm(im,ib,ip)-
444  & fmoma(ip)**2)))
445  490 CONTINUE
446  WRITE(mstu(11),5600) byeta,bphi,bnave,(fmoma(ip),fmoms(ip),
447  & ip=1,4)
448  500 CONTINUE
449  510 CONTINUE
450 
451 C...Copy statistics on factorial moments into /PYJETS/.
452  ELSEIF(mtabu.EQ.33) THEN
453  fac=1d0/max(1,nevfm)
454  DO 540 im=1,3
455  DO 530 ib=1,10
456  i=10*(im-1)+ib
457  k(i,1)=32
458  k(i,2)=99
459  k(i,3)=1
460  IF(im.NE.2) k(i,3)=2**(ib-1)
461  k(i,4)=1
462  IF(im.NE.1) k(i,4)=2**(ib-1)
463  k(i,5)=0
464  p(i,1)=2d0*paru(57)/k(i,3)
465  v(i,1)=paru(2)/k(i,4)
466  DO 520 ip=1,4
467  p(i,ip+1)=fac*fm1fm(im,ib,ip)
468  v(i,ip+1)=sqrt(max(0d0,fac*(fac*fm2fm(im,ib,ip)-
469  & p(i,ip+1)**2)))
470  520 CONTINUE
471  530 CONTINUE
472  540 CONTINUE
473  n=30
474  DO 550 j=1,5
475  k(n+1,j)=0
476  p(n+1,j)=0d0
477  v(n+1,j)=0d0
478  550 CONTINUE
479  k(n+1,1)=32
480  k(n+1,2)=99
481  k(n+1,5)=nevfm
482  mstu(3)=1
483 
484 C...Reset statistics on Energy-Energy Correlation.
485  ELSEIF(mtabu.EQ.40) THEN
486  nevee=0
487  DO 560 j=1,25
488  fe1ec(j)=0d0
489  fe2ec(j)=0d0
490  fe1ec(51-j)=0d0
491  fe2ec(51-j)=0d0
492  fe1ea(j)=0d0
493  fe2ea(j)=0d0
494  560 CONTINUE
495 
496 C...Find particles to include, with proper assumed mass.
497  ELSEIF(mtabu.EQ.41) THEN
498  nevee=nevee+1
499  nlow=n+mstu(3)
500  nupp=nlow
501  ecm=0d0
502  DO 570 i=1,n
503  IF(k(i,1).LE.0.OR.k(i,1).GT.10) goto 570
504  IF(mstu(41).GE.2) THEN
505  kc=pycomp(k(i,2))
506  IF(kc.EQ.0.OR.kc.EQ.12.OR.kc.EQ.14.OR.kc.EQ.16.OR.
507  & kc.EQ.18.OR.k(i,2).EQ.ksusy1+22.OR.k(i,2).EQ.39.OR.
508  & k(i,2).EQ.ksusy1+39) goto 570
509  IF(mstu(41).GE.3.AND.kchg(kc,2).EQ.0.AND.
510  & pychge(k(i,2)).EQ.0) goto 570
511  ENDIF
512  pmr=0d0
513  IF(mstu(42).EQ.1.AND.k(i,2).NE.22) pmr=pymass(211)
514  IF(mstu(42).GE.2) pmr=p(i,5)
515  IF(nupp.GT.mstu(4)-5-mstu(32)) THEN
516  CALL pyerrm(11,'(PYTABU:) no more memory left in PYJETS')
517  RETURN
518  ENDIF
519  nupp=nupp+1
520  p(nupp,1)=p(i,1)
521  p(nupp,2)=p(i,2)
522  p(nupp,3)=p(i,3)
523  p(nupp,4)=sqrt(pmr**2+p(i,1)**2+p(i,2)**2+p(i,3)**2)
524  p(nupp,5)=max(1d-10,sqrt(p(i,1)**2+p(i,2)**2+p(i,3)**2))
525  ecm=ecm+p(nupp,4)
526  570 CONTINUE
527  IF(nupp.EQ.nlow) RETURN
528 
529 C...Analyze Energy-Energy Correlation in event.
530  fac=(2d0/ecm**2)*50d0/paru(1)
531  DO 580 j=1,50
532  fevee(j)=0d0
533  580 CONTINUE
534  DO 600 i1=nlow+2,nupp
535  DO 590 i2=nlow+1,i1-1
536  cthe=(p(i1,1)*p(i2,1)+p(i1,2)*p(i2,2)+p(i1,3)*p(i2,3))/
537  & (p(i1,5)*p(i2,5))
538  the=acos(max(-1d0,min(1d0,cthe)))
539  ithe=max(1,min(50,1+int(50d0*the/paru(1))))
540  fevee(ithe)=fevee(ithe)+fac*p(i1,4)*p(i2,4)
541  590 CONTINUE
542  600 CONTINUE
543  DO 610 j=1,25
544  fe1ec(j)=fe1ec(j)+fevee(j)
545  fe2ec(j)=fe2ec(j)+fevee(j)**2
546  fe1ec(51-j)=fe1ec(51-j)+fevee(51-j)
547  fe2ec(51-j)=fe2ec(51-j)+fevee(51-j)**2
548  fe1ea(j)=fe1ea(j)+(fevee(51-j)-fevee(j))
549  fe2ea(j)=fe2ea(j)+(fevee(51-j)-fevee(j))**2
550  610 CONTINUE
551  mstu(62)=nupp-nlow
552 
553 C...Write statistics on Energy-Energy Correlation.
554  ELSEIF(mtabu.EQ.42) THEN
555  fac=1d0/max(1,nevee)
556  WRITE(mstu(11),5700) nevee
557  DO 620 j=1,25
558  feec1=fac*fe1ec(j)
559  fees1=sqrt(max(0d0,fac*(fac*fe2ec(j)-feec1**2)))
560  feec2=fac*fe1ec(51-j)
561  fees2=sqrt(max(0d0,fac*(fac*fe2ec(51-j)-feec2**2)))
562  feeca=fac*fe1ea(j)
563  feesa=sqrt(max(0d0,fac*(fac*fe2ea(j)-feeca**2)))
564  WRITE(mstu(11),5800) 3.6d0*(j-1),3.6d0*j,feec1,fees1,
565  & feec2,fees2,feeca,feesa
566  620 CONTINUE
567 
568 C...Copy statistics on Energy-Energy Correlation into /PYJETS/.
569  ELSEIF(mtabu.EQ.43) THEN
570  fac=1d0/max(1,nevee)
571  DO 630 i=1,25
572  k(i,1)=32
573  k(i,2)=99
574  k(i,3)=0
575  k(i,4)=0
576  k(i,5)=0
577  p(i,1)=fac*fe1ec(i)
578  v(i,1)=sqrt(max(0d0,fac*(fac*fe2ec(i)-p(i,1)**2)))
579  p(i,2)=fac*fe1ec(51-i)
580  v(i,2)=sqrt(max(0d0,fac*(fac*fe2ec(51-i)-p(i,2)**2)))
581  p(i,3)=fac*fe1ea(i)
582  v(i,3)=sqrt(max(0d0,fac*(fac*fe2ea(i)-p(i,3)**2)))
583  p(i,4)=paru(1)*(i-1)/50d0
584  p(i,5)=paru(1)*i/50d0
585  v(i,4)=3.6d0*(i-1)
586  v(i,5)=3.6d0*i
587  630 CONTINUE
588  n=25
589  DO 640 j=1,5
590  k(n+1,j)=0
591  p(n+1,j)=0d0
592  v(n+1,j)=0d0
593  640 CONTINUE
594  k(n+1,1)=32
595  k(n+1,2)=99
596  k(n+1,5)=nevee
597  mstu(3)=1
598 
599 C...Reset statistics on decay channels.
600  ELSEIF(mtabu.EQ.50) THEN
601  nevdc=0
602  nkfdc=0
603  nredc=0
604 
605 C...Identify and order flavour content of final state.
606  ELSEIF(mtabu.EQ.51) THEN
607  nevdc=nevdc+1
608  nds=0
609  DO 670 i=1,n
610  IF(k(i,1).LE.0.OR.k(i,1).GE.6) goto 670
611  nds=nds+1
612  IF(nds.GT.8) THEN
613  nredc=nredc+1
614  RETURN
615  ENDIF
616  kfm=2*iabs(k(i,2))
617  IF(k(i,2).LT.0) kfm=kfm-1
618  DO 650 ids=nds-1,1,-1
619  iin=ids+1
620  IF(kfm.LT.kfdm(ids)) goto 660
621  kfdm(ids+1)=kfdm(ids)
622  650 CONTINUE
623  iin=1
624  660 kfdm(iin)=kfm
625  670 CONTINUE
626 
627 C...Find whether old or new final state.
628  DO 690 idc=1,nkfdc
629  IF(nds.LT.kfdc(idc,0)) THEN
630  ikfdc=idc
631  goto 700
632  ELSEIF(nds.EQ.kfdc(idc,0)) THEN
633  DO 680 i=1,nds
634  IF(kfdm(i).LT.kfdc(idc,i)) THEN
635  ikfdc=idc
636  goto 700
637  ELSEIF(kfdm(i).GT.kfdc(idc,i)) THEN
638  goto 690
639  ENDIF
640  680 CONTINUE
641  ikfdc=-idc
642  goto 700
643  ENDIF
644  690 CONTINUE
645  ikfdc=nkfdc+1
646  700 IF(ikfdc.LT.0) THEN
647  ikfdc=-ikfdc
648  ELSEIF(nkfdc.GE.200) THEN
649  nredc=nredc+1
650  RETURN
651  ELSE
652  DO 720 idc=nkfdc,ikfdc,-1
653  npdc(idc+1)=npdc(idc)
654  DO 710 i=0,8
655  kfdc(idc+1,i)=kfdc(idc,i)
656  710 CONTINUE
657  720 CONTINUE
658  nkfdc=nkfdc+1
659  kfdc(ikfdc,0)=nds
660  DO 730 i=1,nds
661  kfdc(ikfdc,i)=kfdm(i)
662  730 CONTINUE
663  npdc(ikfdc)=0
664  ENDIF
665  npdc(ikfdc)=npdc(ikfdc)+1
666 
667 C...Write statistics on decay channels.
668  ELSEIF(mtabu.EQ.52) THEN
669  fac=1d0/max(1,nevdc)
670  WRITE(mstu(11),5900) nevdc
671  DO 750 idc=1,nkfdc
672  DO 740 i=1,kfdc(idc,0)
673  kfm=kfdc(idc,i)
674  kf=(kfm+1)/2
675  IF(2*kf.NE.kfm) kf=-kf
676  CALL pyname(kf,chau)
677  chdc(i)=chau(1:12)
678  IF(chau(13:13).NE.' ') chdc(i)(12:12)='?'
679  740 CONTINUE
680  WRITE(mstu(11),6000) fac*npdc(idc),(chdc(i),i=1,kfdc(idc,0))
681  750 CONTINUE
682  IF(nredc.NE.0) WRITE(mstu(11),6100) fac*nredc
683 
684 C...Copy statistics on decay channels into /PYJETS/.
685  ELSEIF(mtabu.EQ.53) THEN
686  fac=1d0/max(1,nevdc)
687  DO 780 idc=1,nkfdc
688  k(idc,1)=32
689  k(idc,2)=99
690  k(idc,3)=0
691  k(idc,4)=0
692  k(idc,5)=kfdc(idc,0)
693  DO 760 j=1,5
694  p(idc,j)=0d0
695  v(idc,j)=0d0
696  760 CONTINUE
697  DO 770 i=1,kfdc(idc,0)
698  kfm=kfdc(idc,i)
699  kf=(kfm+1)/2
700  IF(2*kf.NE.kfm) kf=-kf
701  IF(i.LE.5) p(idc,i)=kf
702  IF(i.GE.6) v(idc,i-5)=kf
703  770 CONTINUE
704  v(idc,5)=fac*npdc(idc)
705  780 CONTINUE
706  n=nkfdc
707  DO 790 j=1,5
708  k(n+1,j)=0
709  p(n+1,j)=0d0
710  v(n+1,j)=0d0
711  790 CONTINUE
712  k(n+1,1)=32
713  k(n+1,2)=99
714  k(n+1,5)=nevdc
715  v(n+1,5)=fac*nredc
716  mstu(3)=1
717  ENDIF
718 
719 C...Format statements for output on unit MSTU(11) (default 6).
720  5000 FORMAT(///20x,'Event statistics - initial state'/
721  &20x,'based on an analysis of ',i6,' events'//
722  &3x,'Main flavours after',8x,'Fraction',4x,'Subfractions ',
723  &'according to fragmenting system multiplicity'/
724  &4x,'hard interaction',24x,'1',7x,'2',7x,'3',7x,'4',7x,'5',
725  &6x,'6-7',5x,'8-10',3x,'11-15',3x,'16-25',4x,'>25'/)
726  5100 FORMAT(3x,a12,1x,a12,f10.5,1x,10f8.4)
727  5200 FORMAT(///20x,'Event statistics - final state'/
728  &20x,'based on an analysis of ',i7,' events'//
729  &5x,'Mean primary multiplicity =',f10.4/
730  &5x,'Mean final multiplicity =',f10.4/
731  &5x,'Mean charged multiplicity =',f10.4//
732  &5x,'Number of particles produced per event (directly and via ',
733  &'decays/branchings)'/
734  &8x,'KF Particle/jet MDCY',10x,'Particles',13x,'Antiparticles',
735  &8x,'Total'/35x,'prim seco prim seco'/)
736  5300 FORMAT(1x,i9,4x,a16,i2,5(1x,f11.6))
737  5400 FORMAT(///20x,'Factorial moments analysis of multiplicity'/
738  &20x,'based on an analysis of ',i6,' events'//
739  &3x,'delta-',a3,' delta-phi <n>/bin',10x,'<F2>',18x,'<F3>',
740  &18x,'<F4>',18x,'<F5>'/35x,4(' value error '))
741  5500 FORMAT(10x)
742  5600 FORMAT(2x,2f10.4,f12.4,4(f12.4,f10.4))
743  5700 FORMAT(///20x,'Energy-Energy Correlation and Asymmetry'/
744  &20x,'based on an analysis of ',i6,' events'//
745  &2x,'theta range',8x,'EEC(theta)',8x,'EEC(180-theta)',7x,
746  &'EECA(theta)'/2x,'in degrees ',3(' value error')/)
747  5800 FORMAT(2x,f4.1,' - ',f4.1,3(f11.4,f9.4))
748  5900 FORMAT(///20x,'Decay channel analysis - final state'/
749  &20x,'based on an analysis of ',i6,' events'//
750  &2x,'Probability',10x,'Complete final state'/)
751  6000 FORMAT(2x,f9.5,5x,8(a12,1x))
752  6100 FORMAT(2x,f9.5,5x,'into other channels (more than 8 particles ',
753  &'or table overflow)')
754 
755  RETURN
756  END