Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pyhepc.f
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file pyhepc.f
1 
2 C*********************************************************************
3 
4 C...PYHEPC
5 C...Converts PYTHIA event record contents to or from
6 C...the standard event record commonblock.
7 
8  SUBROUTINE pyhepc(MCONV)
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/pyjets/n,npad,k(4000,5),p(4000,5),v(4000,5)
16  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
17  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
18  SAVE /pyjets/,/pydat1/,/pydat2/
19 C...HEPEVT commonblock.
20  parameter(nmxhep=4000)
21  common/hepevt/nevhep,nhep,isthep(nmxhep),idhep(nmxhep),
22  &jmohep(2,nmxhep),jdahep(2,nmxhep),phep(5,nmxhep),vhep(4,nmxhep)
23  DOUBLE PRECISION phep,vhep
24  SAVE /hepevt/
25 
26 C...Store HEPEVT commonblock size (for interfacing issues).
27  mstu(8)=nmxhep
28 
29 C...Conversion from PYTHIA to standard, the easy part.
30  IF(mconv.EQ.1) THEN
31  nevhep=0
32  IF(n.GT.nmxhep) CALL pyerrm(8,
33  & '(PYHEPC:) no more space in /HEPEVT/')
34  nhep=min(n,nmxhep)
35  DO 150 i=1,nhep
36  isthep(i)=0
37  IF(k(i,1).GE.1.AND.k(i,1).LE.10) isthep(i)=1
38  IF(k(i,1).GE.11.AND.k(i,1).LE.20) isthep(i)=2
39  IF(k(i,1).GE.21.AND.k(i,1).LE.30) isthep(i)=3
40  IF(k(i,1).GE.31.AND.k(i,1).LE.100) isthep(i)=k(i,1)
41  idhep(i)=k(i,2)
42  jmohep(1,i)=k(i,3)
43  jmohep(2,i)=0
44  IF(k(i,1).NE.3.AND.k(i,1).NE.13.AND.k(i,1).NE.14) THEN
45  jdahep(1,i)=k(i,4)
46  jdahep(2,i)=k(i,5)
47  ELSE
48  jdahep(1,i)=0
49  jdahep(2,i)=0
50  ENDIF
51  DO 100 j=1,5
52  phep(j,i)=p(i,j)
53  100 CONTINUE
54  DO 110 j=1,4
55  vhep(j,i)=v(i,j)
56  110 CONTINUE
57 
58 C...Check if new event (from pileup).
59  IF(i.EQ.1) THEN
60  inew=1
61  ELSE
62  IF(k(i,1).EQ.21.AND.k(i-1,1).NE.21) inew=i
63  ENDIF
64 
65 C...Fill in missing mother information.
66  IF(i.GE.inew+2.AND.k(i,1).EQ.21.AND.k(i,3).EQ.0) THEN
67  imo1=i-2
68  120 IF(imo1.GT.inew.AND.k(imo1+1,1).EQ.21.AND.k(imo1+1,3).EQ.0)
69  & THEN
70  imo1=imo1-1
71  goto 120
72  ENDIF
73  jmohep(1,i)=imo1
74  jmohep(2,i)=imo1+1
75  ELSEIF(k(i,2).GE.91.AND.k(i,2).LE.93) THEN
76  i1=k(i,3)-1
77  130 i1=i1+1
78  IF(i1.GE.i) CALL pyerrm(8,
79  & '(PYHEPC:) translation of inconsistent event history')
80  IF(i1.LT.i.AND.k(i1,1).NE.1.AND.k(i1,1).NE.11) goto 130
81  kc=pycomp(k(i1,2))
82  IF(i1.LT.i.AND.kc.EQ.0) goto 130
83  IF(i1.LT.i.AND.kchg(kc,2).EQ.0) goto 130
84  jmohep(2,i)=i1
85  ELSEIF(k(i,2).EQ.94) THEN
86  njet=2
87  IF(nhep.GE.i+3.AND.k(i+3,3).LE.i) njet=3
88  IF(nhep.GE.i+4.AND.k(i+4,3).LE.i) njet=4
89  jmohep(2,i)=mod(k(i+njet,4)/mstu(5),mstu(5))
90  IF(jmohep(2,i).EQ.jmohep(1,i)) jmohep(2,i)=
91  & mod(k(i+1,4)/mstu(5),mstu(5))
92  ENDIF
93 
94 C...Fill in missing daughter information.
95  IF(k(i,2).EQ.94.AND.mstu(16).NE.2) THEN
96  DO 140 i1=jdahep(1,i),jdahep(2,i)
97  i2=mod(k(i1,4)/mstu(5),mstu(5))
98  jdahep(1,i2)=i
99  140 CONTINUE
100  ENDIF
101  IF(k(i,2).GE.91.AND.k(i,2).LE.94) goto 150
102  i1=jmohep(1,i)
103  IF(i1.LE.0.OR.i1.GT.nhep) goto 150
104  IF(k(i1,1).NE.13.AND.k(i1,1).NE.14) goto 150
105  IF(jdahep(1,i1).EQ.0) THEN
106  jdahep(1,i1)=i
107  ELSE
108  jdahep(2,i1)=i
109  ENDIF
110  150 CONTINUE
111  DO 160 i=1,nhep
112  IF(k(i,1).NE.13.AND.k(i,1).NE.14) goto 160
113  IF(jdahep(2,i).EQ.0) jdahep(2,i)=jdahep(1,i)
114  160 CONTINUE
115 
116 C...Conversion from standard to PYTHIA, the easy part.
117  ELSE
118  IF(nhep.GT.mstu(4)) CALL pyerrm(8,
119  & '(PYHEPC:) no more space in /PYJETS/')
120  n=min(nhep,mstu(4))
121  nkq=0
122  kqsum=0
123  DO 190 i=1,n
124  k(i,1)=0
125  IF(isthep(i).EQ.1) k(i,1)=1
126  IF(isthep(i).EQ.2) k(i,1)=11
127  IF(isthep(i).EQ.3) k(i,1)=21
128  k(i,2)=idhep(i)
129  k(i,3)=jmohep(1,i)
130  k(i,4)=jdahep(1,i)
131  k(i,5)=jdahep(2,i)
132  DO 170 j=1,5
133  p(i,j)=phep(j,i)
134  170 CONTINUE
135  DO 180 j=1,4
136  v(i,j)=vhep(j,i)
137  180 CONTINUE
138  v(i,5)=0d0
139  IF(isthep(i).EQ.2.AND.phep(4,i).GT.phep(5,i)) THEN
140  i1=jdahep(1,i)
141  IF(i1.GT.0.AND.i1.LE.nhep) v(i,5)=(vhep(4,i1)-vhep(4,i))*
142  & phep(5,i)/phep(4,i)
143  ENDIF
144 
145 C...Fill in missing information on colour connection in jet systems.
146  IF(isthep(i).EQ.1) THEN
147  kc=pycomp(k(i,2))
148  kq=0
149  IF(kc.NE.0) kq=kchg(kc,2)*isign(1,k(i,2))
150  IF(kq.NE.0) nkq=nkq+1
151  IF(kq.NE.2) kqsum=kqsum+kq
152  IF(kq.NE.0.AND.kqsum.NE.0) THEN
153  k(i,1)=2
154  ELSEIF(kq.EQ.2.AND.i.LT.n) THEN
155  IF(k(i+1,2).EQ.21) k(i,1)=2
156  ENDIF
157  ENDIF
158  190 CONTINUE
159  IF(nkq.EQ.1.OR.kqsum.NE.0) CALL pyerrm(8,
160  & '(PYHEPC:) input parton configuration not colour singlet')
161  ENDIF
162 
163  END