Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pyupev.f
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file pyupev.f
1 
2 C*********************************************************************
3 
4 C...PYUPEV
5 C...Administers the hard-process generation required for output to the
6 C...Les Houches event record.
7 
8  SUBROUTINE pyupev
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 
15 C...Commonblocks.
16  common/pyjets/n,npad,k(4000,5),p(4000,5),v(4000,5)
17  common/pyctag/nct,mct(4000,2)
18  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
19  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
20  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
21  common/pypars/mstp(200),parp(200),msti(200),pari(200)
22  common/pyint1/mint(400),vint(400)
23  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
24  common/pyint4/mwid(500),wids(500,5)
25  SAVE /pyjets/,/pyctag/,/pydat1/,/pydat2/,/pydat3/,/pypars/,
26  &/pyint1/,/pyint2/,/pyint4/
27 
28 C...HEPEUP for output.
29  INTEGER maxnup
30  parameter(maxnup=500)
31  INTEGER nup,idprup,idup,istup,mothup,icolup
32  DOUBLE PRECISION xwgtup,scalup,aqedup,aqcdup,pup,vtimup,spinup
33  common/hepeup/nup,idprup,xwgtup,scalup,aqedup,aqcdup,idup(maxnup),
34  &istup(maxnup),mothup(2,maxnup),icolup(2,maxnup),pup(5,maxnup),
35  &vtimup(maxnup),spinup(maxnup)
36  SAVE /hepeup/
37 
38 C...Stop if no subprocesses on.
39  IF(mint(121).EQ.1.AND.msti(53).EQ.1) THEN
40  WRITE(mstu(11),5100)
41  stop
42  ENDIF
43 
44 C...Special flags for hard-process generation only.
45  mstp71=mstp(71)
46  mstp(71)=0
47  mst128=mstp(128)
48  mstp(128)=1
49 
50 C...Initial values for some counters.
51  n=0
52  mint(5)=mint(5)+1
53  mint(7)=0
54  mint(8)=0
55  mint(30)=0
56  mint(83)=0
57  mint(84)=mstp(126)
58  mstu(24)=0
59  mstu70=0
60  mstj14=mstj(14)
61 C...Normally, use K(I,4:5) colour info rather than /PYCTAG/.
62  mint(33)=0
63 
64 C...If variable energies: redo incoming kinematics and cross-section.
65  msti(61)=0
66  IF(mstp(171).EQ.1) THEN
67  CALL pyinki(1)
68  IF(msti(61).EQ.1) THEN
69  mint(5)=mint(5)-1
70  RETURN
71  ENDIF
72  IF(mint(121).GT.1) CALL pysave(3,1)
73  CALL pyxtot
74  ENDIF
75 
76 C...Do not allow pileup events.
77  mint(82)=1
78 
79 C...Generate variables of hard scattering.
80  mint(51)=0
81  msti(52)=0
82  100 CONTINUE
83  IF(mint(51).NE.0.OR.mstu(24).NE.0) msti(52)=msti(52)+1
84  mint(31)=0
85  mint(51)=0
86  mint(57)=0
87  CALL pyrand
88  IF(msti(61).EQ.1) THEN
89  mint(5)=mint(5)-1
90  RETURN
91  ENDIF
92  IF(mint(51).EQ.2) RETURN
93  isub=mint(1)
94 
95  IF((isub.LE.90.OR.isub.GE.95).AND.isub.NE.99) THEN
96 C...Hard scattering (including low-pT):
97 C...reconstruct kinematics and colour flow of hard scattering.
98  mint31=mint(31)
99  110 mint(31)=mint31
100  mint(51)=0
101  CALL pyscat
102  IF(mint(51).EQ.1) goto 100
103  ipu1=mint(84)+1
104  ipu2=mint(84)+2
105 
106 C...Decay of final state resonances.
107  mint(32)=0
108  IF(mstp(41).GE.1.AND.iset(isub).LE.10.AND.isub.NE.95)
109  & CALL pyresd(0)
110  IF(mint(51).EQ.1) goto 100
111  mint(52)=n
112 
113 C...Longitudinal boost of hard scattering.
114  betaz=(vint(41)-vint(42))/(vint(41)+vint(42))
115  CALL pyrobo(mint(84)+1,n,0d0,0d0,0d0,0d0,betaz)
116 
117  ELSEIF(isub.NE.99) THEN
118 C...Diffractive and elastic scattering.
119  CALL pydiff
120 
121  ELSE
122 C...DIS scattering (photon flux external).
123  CALL pydisg
124  IF(mint(51).EQ.1) goto 100
125  ENDIF
126 
127 C...Check that no odd resonance left undecayed.
128  mint(54)=n
129  nfix=n
130  DO 120 i=mint(84)+1,nfix
131  IF(k(i,1).GE.1.AND.k(i,1).LE.10.AND.k(i,2).NE.21.AND.
132  & k(i,2).NE.22) THEN
133  kca=pycomp(k(i,2))
134  IF(mwid(kca).NE.0.AND.mdcy(kca,1).GE.1) THEN
135  CALL pyresd(i)
136  IF(mint(51).EQ.1) goto 100
137  ENDIF
138  ENDIF
139  120 CONTINUE
140 
141 C...Boost hadronic subsystem to overall rest frame.
142 C..(Only relevant when photon inside lepton beam.)
143  IF(mint(141).NE.0.OR.mint(142).NE.0) CALL pygaga(4,wtgaga)
144 
145 C...Store event information and calculate Monte Carlo estimates of
146 C...subprocess cross-sections.
147  130 CALL pydocu
148 
149 C...Transform to the desired coordinate frame.
150  140 CALL pyfram(mstp(124))
151  mstu(70)=mstu70
152  paru(21)=vint(1)
153 
154 C...Restore special flags for hard-process generation only.
155  mstp(71)=mstp71
156  mstp(128)=mst128
157 
158 C...Trace colour tags; convert to LHA style labels.
159  nct=100
160  DO 150 i=mint(84)+1,n
161  mct(i,1)=0
162  mct(i,2)=0
163  150 CONTINUE
164  DO 160 i=mint(84)+1,n
165  kq=kchg(pycomp(k(i,2)),2)*isign(1,k(i,2))
166  IF(k(i,1).EQ.3.OR.k(i,1).EQ.13.OR.k(i,1).EQ.14) THEN
167  IF(k(i,4).NE.0.AND.(kq.EQ.1.OR.kq.EQ.2).AND.mct(i,1).EQ.0)
168  & THEN
169  imo=mod(k(i,4)/mstu(5),mstu(5))
170  ida=mod(k(i,4),mstu(5))
171  IF(imo.NE.0.AND.mod(k(imo,5)/mstu(5),mstu(5)).EQ.i.AND.
172  & mct(imo,2).NE.0) THEN
173  mct(i,1)=mct(imo,2)
174  ELSEIF(imo.NE.0.AND.mod(k(imo,4),mstu(5)).EQ.i.AND.
175  & mct(imo,1).NE.0) THEN
176  mct(i,1)=mct(imo,1)
177  ELSEIF(ida.NE.0.AND.mod(k(ida,5),mstu(5)).EQ.i.AND.
178  & mct(ida,2).NE.0) THEN
179  mct(i,1)=mct(ida,2)
180  ELSE
181  nct=nct+1
182  mct(i,1)=nct
183  ENDIF
184  ENDIF
185  IF(k(i,5).NE.0.AND.(kq.EQ.-1.OR.kq.EQ.2).AND.mct(i,2).EQ.0)
186  & THEN
187  imo=mod(k(i,5)/mstu(5),mstu(5))
188  ida=mod(k(i,5),mstu(5))
189  IF(imo.NE.0.AND.mod(k(imo,4)/mstu(5),mstu(5)).EQ.i.AND.
190  & mct(imo,1).NE.0) THEN
191  mct(i,2)=mct(imo,1)
192  ELSEIF(imo.NE.0.AND.mod(k(imo,5),mstu(5)).EQ.i.AND.
193  & mct(imo,2).NE.0) THEN
194  mct(i,2)=mct(imo,2)
195  ELSEIF(ida.NE.0.AND.mod(k(ida,4),mstu(5)).EQ.i.AND.
196  & mct(ida,1).NE.0) THEN
197  mct(i,2)=mct(ida,1)
198  ELSE
199  nct=nct+1
200  mct(i,2)=nct
201  ENDIF
202  ENDIF
203  ENDIF
204  160 CONTINUE
205 
206 C...Put event in HEPEUP commonblock.
207  nup=n-mint(84)
208  idprup=mint(1)
209  xwgtup=1d0
210  scalup=vint(53)
211  aqedup=vint(57)
212  aqcdup=vint(58)
213  DO 180 i=1,nup
214  idup(i)=k(i+mint(84),2)
215  IF(i.LE.2) THEN
216  istup(i)=-1
217  mothup(1,i)=0
218  mothup(2,i)=0
219  ELSEIF(k(i+4,3).EQ.0) THEN
220  istup(i)=1
221  mothup(1,i)=1
222  mothup(2,i)=2
223  ELSE
224  istup(i)=1
225  mothup(1,i)=k(i+mint(84),3)-mint(84)
226  mothup(2,i)=0
227  ENDIF
228  IF(i.GE.3.AND.k(i+mint(84),3).GT.0)
229  & istup(k(i+mint(84),3)-mint(84))=2
230  icolup(1,i)=mct(i+mint(84),1)
231  icolup(2,i)=mct(i+mint(84),2)
232  DO 170 j=1,5
233  pup(j,i)=p(i+mint(84),j)
234  170 CONTINUE
235  vtimup(i)=v(i,5)
236  spinup(i)=9d0
237  180 CONTINUE
238 
239 C...Optionally write out event to disk. Minimal size for time/spin fields.
240  IF(mstp(162).GT.0) THEN
241  WRITE(mstp(162),5200) nup,idprup,xwgtup,scalup,aqedup,aqcdup
242  DO 190 i=1,nup
243  IF(vtimup(i).EQ.0d0) THEN
244  WRITE(mstp(162),5300) idup(i),istup(i),mothup(1,i),
245  & mothup(2,i),icolup(1,i),icolup(2,i),(pup(j,i),j=1,5),
246  & ' 0. 9.'
247  ELSE
248  WRITE(mstp(162),5400) idup(i),istup(i),mothup(1,i),
249  & mothup(2,i),icolup(1,i),icolup(2,i),(pup(j,i),j=1,5),
250  & vtimup(i),' 9.'
251  ENDIF
252  190 CONTINUE
253 
254 C...Optional extra line with parton-density information.
255  IF(mstp(165).GE.1) WRITE(mstp(162),5500) msti(15),msti(16),
256  & pari(33),pari(34),pari(23),pari(29),pari(30)
257  ENDIF
258 
259 C...Error messages and other print formats.
260  5100 FORMAT(1x,'Error: no subprocess switched on.'/
261  &1x,'Execution stopped.')
262  5200 FORMAT(1p,2i6,4e14.6)
263  5300 FORMAT(1p,i8,5i5,5e18.10,a6)
264  5400 FORMAT(1p,i8,5i5,5e18.10,e12.4,a3)
265  5500 FORMAT(1p,'#pdf ',2i5,5e18.10)
266 
267  RETURN
268  END