Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pycomp.f
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file pycomp.f
1 
2 C*********************************************************************
3 
4 C...PYCOMP
5 C...Compress the standard KF codes for use in mass and decay arrays;
6 C...also checks whether a given code actually is defined.
7 
8  FUNCTION pycomp(KF)
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...Commonblocks.
15  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
16  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
17  SAVE /pydat1/,/pydat2/
18 C...Local arrays and saved data.
19  dimension kford(100:500),kcord(101:500)
20  SAVE kford,kcord,nford,kflast,kclast
21 
22 C...Whenever necessary reorder codes for faster search.
23  IF(mstu(20).EQ.0) THEN
24  nford=100
25  kford(100)=0
26  DO 120 i=101,500
27  kfa=kchg(i,4)
28  IF(kfa.LE.100) goto 120
29  nford=nford+1
30  DO 100 i1=nford-1,0,-1
31  IF(kfa.GE.kford(i1)) goto 110
32  kford(i1+1)=kford(i1)
33  kcord(i1+1)=kcord(i1)
34  100 CONTINUE
35  110 kford(i1+1)=kfa
36  kcord(i1+1)=i
37  120 CONTINUE
38  mstu(20)=1
39  kflast=0
40  kclast=0
41  ENDIF
42 
43 C...Fast action if same code as in latest call.
44  IF(kf.EQ.kflast) THEN
45  pycomp=kclast
46  RETURN
47  ENDIF
48 
49 C...Starting values. Remove internal diquark flags.
50  pycomp=0
51  kfa=iabs(kf)
52  IF(mod(kfa/10,10).EQ.0.AND.kfa.LT.100000
53  & .AND.mod(kfa/1000,10).GT.0) kfa=mod(kfa,10000)
54 
55 C...Simple cases: direct translation.
56  IF(kfa.GT.kford(nford)) THEN
57  ELSEIF(kfa.LE.100) THEN
58  pycomp=kfa
59 
60 C...Else binary search.
61  ELSE
62  imin=100
63  imax=nford+1
64  130 iavg=(imin+imax)/2
65  IF(kford(iavg).GT.kfa) THEN
66  imax=iavg
67  IF(imax.GT.imin+1) goto 130
68  ELSEIF(kford(iavg).LT.kfa) THEN
69  imin=iavg
70  IF(imax.GT.imin+1) goto 130
71  ELSE
72  pycomp=kcord(iavg)
73  ENDIF
74  ENDIF
75 
76 C...Check if antiparticle allowed.
77  IF(pycomp.NE.0.AND.kf.LT.0) THEN
78  IF(kchg(pycomp,3).EQ.0) pycomp=0
79  ENDIF
80 
81 C...Save codes for possible future fast action.
82  kflast=kf
83  kclast=pycomp
84 
85  RETURN
86  END