Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pyadsh.f
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file pyadsh.f
1 
2 C*********************************************************************
3 
4 C...PYADSH
5 C...Administers the generation of successive final-state showers
6 C...in external processes.
7 
8  SUBROUTINE pyadsh(NFIN)
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 for maximum size of showers.
15  parameter(maxnur=1000)
16 C...Commonblocks.
17  common/pypart/npart,npartd,ipart(maxnur),ptpart(maxnur)
18  common/pyjets/n,npad,k(4000,5),p(4000,5),v(4000,5)
19  common/pyctag/nct,mct(4000,2)
20  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
21  common/pypars/mstp(200),parp(200),msti(200),pari(200)
22  common/pyint1/mint(400),vint(400)
23  SAVE /pypart/,/pyjets/,/pyctag/,/pydat1/,/pypars/,/pyint1/
24 C...Local array.
25  dimension ibeg(100),ksav(100,5),psum(4),beta(3)
26 
27 C...Set primary vertex.
28  DO 100 j=1,5
29  v(mint(83)+5,j)=0d0
30  v(mint(83)+6,j)=0d0
31  v(mint(84)+1,j)=0d0
32  v(mint(84)+2,j)=0d0
33  100 CONTINUE
34 
35 C...Isolate systems of particles with the same mother.
36  nsys=0
37  ims=-1
38  DO 140 i=mint(84)+3,nfin
39  im=k(i,3)
40  IF(im.GT.0.AND.im.LE.mint(84)) im=k(im,3)
41  IF(im.NE.ims) THEN
42  nsys=nsys+1
43  ibeg(nsys)=i
44  ims=im
45  ENDIF
46 
47 C...Set production vertices.
48  IF(im.LE.mint(83)+6.OR.(im.GT.mint(84).AND.im.LE.mint(84)+2))
49  & THEN
50  DO 110 j=1,4
51  v(i,j)=0d0
52  110 CONTINUE
53  ELSE
54  DO 120 j=1,4
55  v(i,j)=v(im,j)+v(im,5)*p(im,j)/p(im,5)
56  120 CONTINUE
57  ENDIF
58  IF(mstp(125).GE.1) THEN
59  idoc=i-mstp(126)+4
60  DO 130 j=1,5
61  v(idoc,j)=v(i,j)
62  130 CONTINUE
63  ENDIF
64  140 CONTINUE
65 
66 C...End loop over systems. Return if no showers to be performed.
67  ibeg(nsys+1)=nfin+1
68  IF(mstp(71).LE.0) RETURN
69 
70 C...Loop through systems of particles; check that sensible size.
71  DO 270 isys=1,nsys
72  nsiz=ibeg(isys+1)-ibeg(isys)
73  IF(mint(35).LE.1) THEN
74  IF(nsiz.EQ.1.AND.isys.EQ.1) THEN
75  goto 270
76  ELSEIF(nsiz.LE.1) THEN
77  CALL pyerrm(2,'(PYADSH:) only one particle in system')
78  goto 270
79  ELSEIF(nsiz.GT.80) THEN
80  CALL pyerrm(2,'(PYADSH:) more than 80 particles in system')
81  goto 270
82  ENDIF
83  ENDIF
84 
85 C...Save status codes and daughters of showering particles; reset them.
86  DO 150 j=1,4
87  psum(j)=0d0
88  150 CONTINUE
89  DO 170 ii=1,nsiz
90  i=ibeg(isys)-1+ii
91  ksav(ii,1)=k(i,1)
92  IF(k(i,1).GT.10) THEN
93  k(i,1)=1
94  IF(ksav(ii,1).EQ.14) k(i,1)=3
95  ENDIF
96  IF(ksav(ii,1).LE.10) THEN
97  ELSEIF(k(i,1).EQ.1) THEN
98  ksav(ii,4)=k(i,4)
99  ksav(ii,5)=k(i,5)
100  k(i,4)=0
101  k(i,5)=0
102  ELSE
103  ksav(ii,4)=mod(k(i,4),mstu(5))
104  ksav(ii,5)=mod(k(i,5),mstu(5))
105  k(i,4)=k(i,4)-ksav(ii,4)
106  k(i,5)=k(i,5)-ksav(ii,5)
107  ENDIF
108  DO 160 j=1,4
109  psum(j)=psum(j)+p(i,j)
110  160 CONTINUE
111  170 CONTINUE
112 
113 C...Perform shower.
114  qmax=sqrt(max(0d0,psum(4)**2-psum(1)**2-psum(2)**2-
115  & psum(3)**2))
116  IF(isys.EQ.1) qmax=min(qmax,sqrt(parp(71))*vint(55))
117  nsav=n
118  IF(mint(35).LE.1) THEN
119  IF(nsiz.EQ.2) THEN
120  CALL pyshow(ibeg(isys),ibeg(isys)+1,qmax)
121  ELSE
122  CALL pyshow(ibeg(isys),-nsiz,qmax)
123  ENDIF
124 
125 C...For external processes, first call, also ISR partons radiate.
126 C...Can use existing PYPART list, removing partons that radiate later.
127  ELSEIF(isys.EQ.1) THEN
128  npartn=0
129  DO 175 ii=1,npart
130  IF(ipart(ii).LT.ibeg(2).OR.ipart(ii).GE.ibeg(nsys+1)) THEN
131  npartn=npartn+1
132  ipart(npartn)=ipart(ii)
133  ptpart(npartn)=ptpart(ii)
134  ENDIF
135  175 CONTINUE
136  npart=npartn
137  CALL pyptfs(1,0.5d0*qmax,0d0,ptgen)
138  ELSE
139 C...For subsequent calls use the systems excluded above.
140  npart=nsiz
141  npartd=0
142  DO 180 ii=1,nsiz
143  i=ibeg(isys)-1+ii
144  ipart(ii)=i
145  ptpart(ii)=0.5d0*qmax
146  180 CONTINUE
147  CALL pyptfs(2,0.5d0*qmax,0d0,ptgen)
148  ENDIF
149 
150 C...Look up showered copies of original showering particles.
151  DO 260 ii=1,nsiz
152  i=ibeg(isys)-1+ii
153  imv=i
154 C...Particles without daughters need not be studied.
155  IF(ksav(ii,1).LE.10) goto 260
156  IF(n.EQ.nsav.OR.k(i,1).LE.10) THEN
157  ELSEIF(k(i,1).EQ.11) THEN
158  190 imv=mod(k(imv,4),mstu(5))
159  IF(k(imv,1).EQ.11) goto 190
160  ELSE
161  kda1=mod(k(i,4),mstu(5))
162  IF(kda1.GT.0) THEN
163  IF(k(kda1,2).EQ.21) kda1=k(kda1,5)/mstu(5)
164  ENDIF
165  kda2=mod(k(i,5),mstu(5))
166  IF(kda2.GT.0) THEN
167  IF(k(kda2,2).EQ.21) kda2=k(kda2,4)/mstu(5)
168  ENDIF
169  DO 200 i3=i+1,n
170  IF(k(i3,2).EQ.k(i,2).AND.(i3.EQ.kda1.OR.i3.EQ.kda2))
171  & THEN
172  imv=i3
173  kda1=mod(k(i3,4),mstu(5))
174  IF(kda1.GT.0) THEN
175  IF(k(kda1,2).EQ.21) kda1=k(kda1,5)/mstu(5)
176  ENDIF
177  kda2=mod(k(i3,5),mstu(5))
178  IF(kda2.GT.0) THEN
179  IF(k(kda2,2).EQ.21) kda2=k(kda2,4)/mstu(5)
180  ENDIF
181  ENDIF
182  200 CONTINUE
183  ENDIF
184 
185 C...Restore daughter info of original partons to showered copies.
186  IF(ksav(ii,1).GT.10) k(imv,1)=ksav(ii,1)
187  IF(ksav(ii,1).LE.10) THEN
188  ELSEIF(k(i,1).EQ.1) THEN
189  k(imv,4)=ksav(ii,4)
190  k(imv,5)=ksav(ii,5)
191  ELSE
192  k(imv,4)=k(imv,4)+ksav(ii,4)
193  k(imv,5)=k(imv,5)+ksav(ii,5)
194  ENDIF
195 
196 C...Reset mother info of existing daughters to showered copies.
197  DO 210 i3=ibeg(isys+1),nfin
198  IF(k(i3,3).EQ.i) k(i3,3)=imv
199  IF(k(i3,1).EQ.3.OR.k(i3,1).EQ.14) THEN
200  IF(k(i3,4)/mstu(5).EQ.i) k(i3,4)=k(i3,4)+mstu(5)*(imv-i)
201  IF(k(i3,5)/mstu(5).EQ.i) k(i3,5)=k(i3,5)+mstu(5)*(imv-i)
202  ENDIF
203  210 CONTINUE
204 
205 C...Boost all original daughters to new frame of showered copy.
206 C...Also update their colour tags.
207  IF(imv.NE.i) THEN
208  DO 220 j=1,3
209  beta(j)=(p(imv,j)-p(i,j))/(p(imv,4)+p(i,4))
210  220 CONTINUE
211  fac=2d0/(1d0+beta(1)**2+beta(2)**2+beta(3)**2)
212  DO 230 j=1,3
213  beta(j)=fac*beta(j)
214  230 CONTINUE
215  DO 250 i3=ibeg(isys+1),nfin
216  imo=i3
217  240 imo=k(imo,3)
218  IF(mstp(128).LE.0) THEN
219  IF(imo.GT.0.AND.imo.NE.i.AND.imo.NE.k(i,3)) goto 240
220  IF(imo.EQ.i.OR.(k(i,3).LE.mint(84).AND.imo.EQ.k(i,3)))
221  & THEN
222  CALL pyrobo(i3,i3,0d0,0d0,beta(1),beta(2),beta(3))
223  IF(mct(i3,1).EQ.mct(i,1)) mct(i3,1)=mct(imv,1)
224  IF(mct(i3,2).EQ.mct(i,2)) mct(i3,2)=mct(imv,2)
225  ENDIF
226  ELSE
227  IF(imo.EQ.imv) THEN
228  CALL pyrobo(i3,i3,0d0,0d0,beta(1),beta(2),beta(3))
229  IF(mct(i3,1).EQ.mct(i,1)) mct(i3,1)=mct(imv,1)
230  IF(mct(i3,2).EQ.mct(i,2)) mct(i3,2)=mct(imv,2)
231  ELSEIF(imo.GT.0.AND.imo.NE.i.AND.imo.NE.k(i,3)) THEN
232  goto 240
233  ENDIF
234  ENDIF
235  250 CONTINUE
236  ENDIF
237  260 CONTINUE
238 
239 C...End of loop over showering systems
240  270 CONTINUE
241 
242  RETURN
243  END