EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pythia6425mod.f
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file pythia6425mod.f
1 C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 C++ This version of PYTHIA 6.4.25 was modified to run with the ++
3 C++ jet quenching Monte Carlo JEWEL. It is not an official release ++
4 C++ of PYTHIA and may not be used for anything else. ++
5 C++ ++
6 C++ Modifications with respect to the official PYTHIA version: ++
7 C++ * The event record was enlarged to 23000 lines. ++
8 C++ * The LHAPDF interface was activated and modified such that ++
9 C++ nuclear PDF's can be used. ++
10 C++ * A customised version of PYEVWT was introduced to allow for ++
11 C++ the generation of weighted events. ++
12 C++ ++
13 C++ Korinna Zapp ++
14 C++ (Oct. 2013) ++
15 C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
16 C
17 C*********************************************************************
18 C*********************************************************************
19 C* **
20 C* Mar 2011 **
21 C* **
22 C* The Lund Monte Carlo **
23 C* **
24 C* PYTHIA version 6.4 **
25 C* **
26 C* Torbjorn Sjostrand **
27 C* Department of Theoretical Physics **
28 C* Lund University **
29 C* Solvegatan 14A, S-223 62 Lund, Sweden **
30 C* E-mail torbjorn@thep.lu.se **
31 C* **
32 C* SUSY and Technicolor parts by **
33 C* Stephen Mrenna **
34 C* Computing Division **
35 C* Generators and Detector Simulation Group **
36 C* Fermi National Accelerator Laboratory **
37 C* MS 234, Batavia, IL 60510, USA **
38 C* phone + 1 - 630 - 840 - 2556 **
39 C* E-mail mrenna@fnal.gov **
40 C* **
41 C* New multiple interactions and more SUSY parts by **
42 C* Peter Skands **
43 C* CERN/PH, CH-1211 Geneva, Switzerland **
44 C* phone +41 - 22 - 767 2447 **
45 C* E-mail peter.skands@cern.ch **
46 C* **
47 C* Several parts are written by Hans-Uno Bengtsson **
48 C* PYSHOW is written together with Mats Bengtsson **
49 C* PYMAEL is written by Emanuel Norrbin **
50 C* advanced popcorn baryon production written by Patrik Eden **
51 C* code for virtual photons mainly written by Christer Friberg **
52 C* code for low-mass strings mainly written by Emanuel Norrbin **
53 C* Bose-Einstein code mainly written by Leif Lonnblad **
54 C* CTEQ parton distributions are by the CTEQ collaboration **
55 C* GRV 94 parton distributions are by Glueck, Reya and Vogt **
56 C* SaS photon parton distributions together with Gerhard Schuler **
57 C* g + g and q + qbar -> t + tbar + H code by Zoltan Kunszt **
58 C* MSSM Higgs mass calculation code by M. Carena, **
59 C* J.R. Espinosa, M. Quiros and C.E.M. Wagner **
60 C* UED implementation by M. Elkacimi, D. Goujdami, H. Przysiezniak **
61 C* PYGAUS adapted from CERN library (K.S. Kolbig) **
62 C* NRQCD/colour octet production of onium by S. Wolf **
63 C* **
64 C* The latest program version and documentation is found on WWW **
65 C* http://www.thep.lu.se/~torbjorn/Pythia.html **
66 C* **
67 C* Copyright Torbjorn Sjostrand, Lund 2010 **
68 C* **
69 C*********************************************************************
70 C*********************************************************************
71 C *
72 C List of subprograms in order of appearance, with main purpose *
73 C (S = subroutine, F = function, B = block data) *
74 C *
75 C B PYDATA to contain all default values *
76 C S PYCKBD to check that BLOCK DATA has been correctly loaded *
77 C S PYTEST to test the proper functioning of the package *
78 C S PYHEPC to convert between /PYJETS/ and /HEPEVT/ records *
79 C *
80 C S PYINIT to administer the initialization procedure *
81 C S PYEVNT to administer the generation of an event *
82 C S PYEVNW ditto, for new multiple interactions scenario *
83 C S PYSTAT to print cross-section and other information *
84 C S PYUPEV to administer the generation of an LHA hard process *
85 C S PYUPIN to provide initialization needed for LHA input *
86 C S PYLHEF to produce a Les Houches Event File from run *
87 C S PYINRE to initialize treatment of resonances *
88 C S PYINBM to read in beam, target and frame choices *
89 C S PYINKI to initialize kinematics of incoming particles *
90 C S PYINPR to set up the selection of included processes *
91 C S PYXTOT to give total, elastic and diffractive cross-sect. *
92 C S PYMAXI to find differential cross-section maxima *
93 C S PYPILE to select multiplicity of pileup events *
94 C S PYSAVE to save alternatives for gamma-p and gamma-gamma *
95 C S PYGAGA to handle lepton -> lepton + gamma branchings *
96 C S PYRAND to select subprocess and kinematics for event *
97 C S PYSCAT to set up kinematics and colour flow of event *
98 C S PYEVOL handler for pT-ordered ISR and multiple interactions *
99 C S PYSSPA to simulate initial state spacelike showers *
100 C S PYPTIS to do pT-ordered initial state spacelike showers *
101 C S PYMEMX auxiliary to PYSSPA/PYPTIS for ME correction maximum *
102 C S PYMEWT auxiliary to PYSSPA/.. for matrix element correction *
103 C S PYPTMI to do pT-ordered multiple interactions *
104 C F PYFCMP to give companion quark x*f distribution *
105 C F PYPCMP to calculate momentum integral for companion quarks *
106 C S PYUPRE to rearranges contents of the HEPEUP commonblock *
107 C S PYADSH to administrate sequential final-state showers *
108 C S PYVETO to allow the generation of an event to be aborted *
109 C S PYRESD to perform resonance decays *
110 C S PYMULT to generate multiple interactions - old scheme *
111 C S PYREMN to add on target remnants - old scheme *
112 C S PYMIGN to generate multiple interactions - new scheme *
113 C S PYMIHK to connect colours in mult. int. - new scheme *
114 C S PYCTTR to translate PYTHIA colour information to LHA1 tags *
115 C S PYMIHG to collapse two pairs of LHA1 colour tags. *
116 C S PYMIRM to add on target remnants in mult. int.- new scheme *
117 C S PYFSCR to perform final state colour reconnections - -"- *
118 C S PYDIFF to set up kinematics for diffractive events *
119 C S PYDISG to set up kinematics, remnant and showers for DIS *
120 C S PYDOCU to compute cross-sections and handle documentation *
121 C S PYFRAM to perform boosts between different frames *
122 C S PYWIDT to calculate full and partial widths of resonances *
123 C S PYOFSH to calculate partial width into off-shell channels *
124 C S PYRECO to handle colour reconnection in W+W- events *
125 C S PYKLIM to calculate borders of allowed kinematical region *
126 C S PYKMAP to construct value of kinematical variable *
127 C S PYSIGH to calculate differential cross-sections *
128 C S PYSGQC auxiliary to PYSIGH for QCD processes *
129 C S PYSGHF auxiliary to PYSIGH for heavy flavour processes *
130 C S PYSGWZ auxiliary to PYSIGH for W and Z processes *
131 C S PYSGHG auxiliary to PYSIGH for Higgs processes *
132 C S PYSGSU auxiliary to PYSIGH for supersymmetry processes *
133 C S PYSGTC auxiliary to PYSIGH for technicolor processes *
134 C S PYSGEX auxiliary to PYSIGH for various exotic processes *
135 C S PYPDFU to evaluate parton distributions *
136 C S PYPDFL to evaluate parton distributions at low x and Q^2 *
137 C S PYPDEL to evaluate electron parton distributions *
138 C S PYPDGA to evaluate photon parton distributions (generic) *
139 C S PYGGAM to evaluate photon parton distributions (SaS sets) *
140 C S PYGVMD to evaluate VMD part of photon parton distributions *
141 C S PYGANO to evaluate anomalous part of photon PDFs *
142 C S PYGBEH to evaluate Bethe-Heitler part of photon PDFs *
143 C S PYGDIR to evaluate direct contribution to photon PDFs *
144 C S PYPDPI to evaluate pion parton distributions *
145 C S PYPDPR to evaluate proton parton distributions *
146 C F PYCTEQ to evaluate the CTEQ 3 proton parton distributions *
147 C S PYGRVL to evaluate the GRV 94L proton parton distributions *
148 C S PYGRVM to evaluate the GRV 94M proton parton distributions *
149 C S PYGRVD to evaluate the GRV 94D proton parton distributions *
150 C F PYGRVV auxiliary to the PYGRV* routines *
151 C F PYGRVW auxiliary to the PYGRV* routines *
152 C F PYGRVS auxiliary to the PYGRV* routines *
153 C F PYCT5L to evaluate the CTEQ 5L proton parton distributions *
154 C F PYCT5M to evaluate the CTEQ 5M1 proton parton distributions *
155 C S PYPDPO to evaluate old proton parton distributions *
156 C F PYHFTH to evaluate threshold factor for heavy flavour *
157 C S PYSPLI to find flavours left in hadron when one removed *
158 C F PYGAMM to evaluate ordinary Gamma function Gamma(x) *
159 C S PYWAUX to evaluate auxiliary functions W1(s) and W2(s) *
160 C S PYI3AU to evaluate auxiliary function I3(s,t,u,v) *
161 C F PYSPEN to evaluate Spence (dilogarithm) function Sp(x) *
162 C S PYQQBH to evaluate matrix element for g + g -> Q + Qbar + H *
163 C S PYSTBH to evaluate matrix element for t + b + H processes *
164 C S PYTBHB auxiliary to PYSTBH *
165 C S PYTBHG auxiliary to PYSTBH *
166 C S PYTBHQ auxiliary to PYSTBH *
167 C F PYTBHS auxiliary to PYSTBH *
168 C *
169 C S PYMSIN to initialize the supersymmetry simulation *
170 C S PYSLHA to interface to SUSY spectrum and decay calculators *
171 C S PYAPPS to determine MSSM parameters from SUGRA input *
172 C S PYSUGI to determine MSSM parameters using ISASUSY *
173 C S PYFEYN to determine MSSM Higgs parameters using FEYNHIGGS *
174 C F PYRNMQ to determine running squark masses *
175 C S PYTHRG to calculate sfermion third-gen. mass eigenstates *
176 C S PYINOM to calculate neutralino/chargino mass eigenstates *
177 C F PYRNM3 to determine running M3, gluino mass *
178 C S PYEIG4 to calculate eigenvalues and -vectors in 4*4 matrix *
179 C S PYHGGM to determine Higgs mass spectrum *
180 C S PYSUBH to determine Higgs masses in the MSSM *
181 C S PYPOLE to determine Higgs masses in the MSSM *
182 C S PYRGHM auxiliary to PYPOLE *
183 C S PYGFXX auxiliary to PYRGHM *
184 C F PYFINT auxiliary to PYPOLE *
185 C F PYFISB auxiliary to PYFINT *
186 C S PYSFDC to calculate sfermion decay partial widths *
187 C S PYGLUI to calculate gluino decay partial widths *
188 C S PYTBBN to calculate 3-body decay of gluino to neutralino *
189 C S PYTBBC to calculate 3-body decay of gluino to chargino *
190 C S PYNJDC to calculate neutralino decay partial widths *
191 C S PYCJDC to calculate chargino decay partial widths *
192 C F PYXXZ6 auxiliary for ino 3-body decays *
193 C F PYXXGA auxiliary for ino -> ino + gamma decay *
194 C F PYX2XG auxiliary for ino -> ino + gauge boson decay *
195 C F PYX2XH auxiliary for ino -> ino + Higgs decay *
196 C S PYHEXT to calculate non-SM Higgs decay partial widths *
197 C F PYH2XX auxiliary for H -> ino + ino decay *
198 C F PYGAUS to perform Gaussian integration *
199 C F PYGAU2 copy of PYGAUS to allow two-dimensional integration *
200 C F PYSIMP to perform Simpson integration *
201 C F PYLAMF to evaluate the lambda kinematics function *
202 C S PYTBDY to perform 3-body decay of gauginos *
203 C S PYTECM to calculate techni_rho/omega masses *
204 C S PYXDIN to initialize Universal Extra Dimensions *
205 C S PYUEDC to compute UED mass radiative corrections *
206 C S PYXUED to compute UED cross sections *
207 C S PYGRAM to generate UED G* (excited graviton) mass spectrum *
208 C F PYGRAW to compute UED partial widths to G* *
209 C F PYWDKK to compute UED differential partial widths to G* *
210 C S PYEICG to calculate eigenvalues of a 4*4 complex matrix *
211 C S PYCMQR auxiliary to PYEICG *
212 C S PYCMQ2 auxiliary to PYEICG *
213 C S PYCDIV auxiliary to PYCMQR *
214 C S PYCSRT auxiliary to PYCMQR *
215 C S PYTHAG auxiliary to PYCMQR *
216 C S PYCBAL auxiliary to PYEICG *
217 C S PYCBA2 auxiliary to PYEICG *
218 C S PYCRTH auxiliary to PYEICG *
219 C S PYLDCM auxiliary to PYSIGH, for technicolor in QCD 2 -> 2 *
220 C S PYBKSB auxiliary to PYSIGH, for technicolor in QCD 2 -> 2 *
221 C S PYWIDX to calculate decay widths from within PYWIDT *
222 C S PYRVSF to calculate R-violating sfermion decay widths *
223 C S PYRVNE to calculate R-violating neutralino decay widths *
224 C S PYRVCH to calculate R-violating chargino decay widths *
225 C S PYRVGL to calculate R-violating gluino decay widths *
226 C F PYRVSB auxiliary to PYRVSF *
227 C S PYRVGW to calculate R-Violating 3-body widths *
228 C F PYRVI1 auxiliary to PYRVGW, to do PS integration for res. *
229 C F PYRVI2 auxiliary to PYRVGW, to do PS integration for LR-int.*
230 C F PYRVI3 auxiliary to PYRVGW, to do PS X integral for int. *
231 C F PYRVG1 auxiliary to PYRVI1, general matrix element, res. *
232 C F PYRVG2 auxiliary to PYRVI2, general matrix element, LR-int. *
233 C F PYRVG3 auxiliary to PYRVI3, to do PS Y integral for int. *
234 C F PYRVG4 auxiliary to PYRVG3, general matrix element, int. *
235 C F PYRVR auxiliary to PYRVG1, Breit-Wigner *
236 C F PYRVS auxiliary to PYRVG2 & PYRVG4 *
237 C *
238 C S PY1ENT to fill one entry (= parton or particle) *
239 C S PY2ENT to fill two entries *
240 C S PY3ENT to fill three entries *
241 C S PY4ENT to fill four entries *
242 C S PY2FRM to interface to generic two-fermion generator *
243 C S PY4FRM to interface to generic four-fermion generator *
244 C S PY6FRM to interface to generic six-fermion generator *
245 C S PY4JET to generate a shower from a given 4-parton config *
246 C S PY4JTW to evaluate the weight od a shower history for above *
247 C S PY4JTS to set up the parton configuration for above *
248 C S PYJOIN to connect entries with colour flow information *
249 C S PYGIVE to fill (or query) commonblock variables *
250 C S PYONOF to allow easy control of particle decay modes *
251 C S PYTUNE to select a predefined 'tune' for min-bias and UE *
252 C S PYEXEC to administrate fragmentation and decay chain *
253 C S PYPREP to rearrange showered partons along strings *
254 C S PYSTRF to do string fragmentation of jet system *
255 C S PYJURF to find boost to string junction rest frame *
256 C S PYINDF to do independent fragmentation of one or many jets *
257 C S PYDECY to do the decay of a particle *
258 C S PYDCYK to select parton and hadron flavours in decays *
259 C S PYKFDI to select parton and hadron flavours in fragm *
260 C S PYNMES to select number of popcorn mesons *
261 C S PYKFIN to calculate falvour prod. ratios from input params. *
262 C S PYPTDI to select transverse momenta in fragm *
263 C S PYZDIS to select longitudinal scaling variable in fragm *
264 C S PYSHOW to do m-ordered timelike parton shower evolution *
265 C S PYPTFS to do pT-ordered timelike parton shower evolution *
266 C F PYMAEL auxiliary to PYSHOW & PYPTFS: gluon emission ME's *
267 C S PYBOEI to include Bose-Einstein effects (crudely) *
268 C S PYBESQ auxiliary to PYBOEI *
269 C F PYMASS to give the mass of a particle or parton *
270 C F PYMRUN to give the running MSbar mass of a quark *
271 C S PYNAME to give the name of a particle or parton *
272 C F PYCHGE to give three times the electric charge *
273 C F PYCOMP to compress standard KF flavour code to internal KC *
274 C S PYERRM to write error messages and abort faulty run *
275 C F PYALEM to give the alpha_electromagnetic value *
276 C F PYALPS to give the alpha_strong value *
277 C F PYANGL to give the angle from known x and y components *
278 C F PYR to provide a random number generator *
279 C S PYRGET to save the state of the random number generator *
280 C S PYRSET to set the state of the random number generator *
281 C S PYROBO to rotate and/or boost an event *
282 C S PYEDIT to remove unwanted entries from record *
283 C S PYLIST to list event record or particle data *
284 C S PYLOGO to write a logo *
285 C S PYUPDA to update particle data *
286 C F PYK to provide integer-valued event information *
287 C F PYP to provide real-valued event information *
288 C S PYSPHE to perform sphericity analysis *
289 C S PYTHRU to perform thrust analysis *
290 C S PYCLUS to perform three-dimensional cluster analysis *
291 C S PYCELL to perform cluster analysis in (eta, phi, E_T) *
292 C S PYJMAS to give high and low jet mass of event *
293 C S PYFOWO to give Fox-Wolfram moments *
294 C S PYTABU to analyze events, with tabular output *
295 C *
296 C S PYEEVT to administrate the generation of an e+e- event *
297 C S PYXTEE to give the total cross-section at given CM energy *
298 C S PYRADK to generate initial state photon radiation *
299 C S PYXKFL to select flavour of primary qqbar pair *
300 C S PYXJET to select (matrix element) jet multiplicity *
301 C S PYX3JT to select kinematics of three-jet event *
302 C S PYX4JT to select kinematics of four-jet event *
303 C S PYXDIF to select angular orientation of event *
304 C S PYONIA to perform generation of onium decay to gluons *
305 C *
306 C S PYBOOK to book a histogram *
307 C S PYFILL to fill an entry in a histogram *
308 C S PYFACT to multiply histogram contents by a factor *
309 C S PYOPER to perform operations between histograms *
310 C S PYHIST to print and reset all histograms *
311 C S PYPLOT to print a single histogram *
312 C S PYNULL to reset contents of a single histogram *
313 C S PYDUMP to dump histogram contents onto a file *
314 C *
315 C S PYSTOP routine to handle Fortran STOP condition *
316 C *
317 C S PYKCUT dummy routine for user kinematical cuts *
318 C S PYEVWT dummy routine for weighting events *
319 C S UPINIT dummy routine to initialize user processes *
320 C S UPEVNT dummy routine to generate a user process event *
321 C S UPVETO dummy routine to abort event at parton level *
322 C S PDFSET dummy routine to be removed when using PDFLIB *
323 C S STRUCTM dummy routine to be removed when using PDFLIB *
324 C S STRUCTP dummy routine to be removed when using PDFLIB *
325 C S SUGRA dummy routine to be removed when linking with ISAJET *
326 C F VISAJE dummy functn. to be removed when linking with ISAJET *
327 C S SSMSSM dummy routine to be removed when linking with ISAJET *
328 C S FHSETFLAGS dummy routine -"- FEYNHIGGS *
329 C S FHSETPARA dummy routine -"- FEYNHIGGS *
330 C S FHHIGGSCORR dummy routine -"- FEYNHIGGS *
331 C S PYTAUD dummy routine for interface to tau decay libraries *
332 C S PYTIME dummy routine for giving date and time *
333 C *
334 C*********************************************************************
335 
336 C...PYDATA
337 C...Default values for switches and parameters,
338 C...and particle, decay and process data.
339 
340  BLOCK DATA pydata
341 
342 C...Double precision and integer declarations.
343  IMPLICIT DOUBLE PRECISION(a-h, o-z)
344  IMPLICIT INTEGER(i-n)
345  INTEGER pyk,pychge,pycomp
346 C...Commonblocks.
347  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
348  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
349  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
350  common/pydat4/chaf(500,2)
351  CHARACTER chaf*16
352  common/pydatr/mrpy(6),rrpy(100)
353  common/pysubs/msel,mselpd,msub(500),kfin(2,-40:40),ckin(200)
354  common/pypars/mstp(200),parp(200),msti(200),pari(200)
355  common/pyint1/mint(400),vint(400)
356  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
357  common/pyint3/xsfx(2,-40:40),isig(1000,3),sigh(1000)
358  common/pyint4/mwid(500),wids(500,5)
359  common/pyint5/ngenpd,ngen(0:500,3),xsec(0:500,3)
360  common/pyint6/proc(0:500)
361  CHARACTER proc*28
362  common/pyint7/sigt(0:6,0:6,0:5)
363  common/pymssm/imss(0:99),rmss(0:99)
364  common/pyssmt/zmix(4,4),umix(2,2),vmix(2,2),smz(4),smw(2),
365  &sfmix(16,4),zmixi(4,4),umixi(2,2),vmixi(2,2)
366  common/pymsrv/rvlam(3,3,3), rvlamp(3,3,3), rvlamb(3,3,3)
367  common/pytcsm/itcm(0:99),rtcm(0:99)
368  common/pypued/iued(0:99),rued(0:99)
369  common/pybins/ihist(4),indx(1000),bin(20000)
370  common/pylh3p/modsel(200),parmin(100),parext(200),rmsoft(0:100),
371  & au(3,3),ad(3,3),ae(3,3)
372  common/pylh3c/cpro(2),cver(2)
373  CHARACTER cpro*12,cver*12
374  SAVE /pydat1/,/pydat2/,/pydat3/,/pydat4/,/pydatr/,/pysubs/,
375  &/pypars/,/pyint1/,/pyint2/,/pyint3/,/pyint4/,/pyint5/,
376  &/pyint6/,/pyint7/,/pymssm/,/pyssmt/,/pymsrv/,/pytcsm/,/pypued/,
377  &/pybins/,/pylh3p/,/pylh3c/
378 
379 C...PYDAT1, containing status codes and most parameters.
380  DATA mstu/
381  & 0, 0, 0, 23000,23000, 500, 8000, 0, 0, 2,
382  1 6, 0, 1, 0, 0, 1, 0, 0, 0, 0,
383  2 2, 10, 0, 0, 1, 10, 0, 0, 0, 0,
384  3 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
385  4 2, 2, 1, 4, 2, 1, 1, 0, 0, 0,
386  5 25, 24, 0, 1, 0, 0, 0, 0, 0, 0,
387  6 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
388  7 30*0,
389  1 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
390  2 1, 5, 3, 5, 0, 0, 0, 0, 0, 0,
391  & 80*0/
392  DATA (paru(i),i=1,100)/
393  & 3.141592653589793d0, 6.283185307179586d0,
394  & 0.197327d0, 5.06773d0, 0.389380d0, 2.56819d0, 4*0d0,
395  1 0.001d0, 0.09d0, 0.01d0, 2d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0,
396  2 0d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0,
397  3 0d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0,
398  4 2.0d0, 1.0d0, 0.25d0, 2.5d0, 0.05d0,
399  4 0d0, 0d0, 0.0001d0, 0d0, 0d0,
400  5 2.5d0,1.5d0,7.0d0,1.0d0,0.5d0,2.0d0,3.2d0, 0d0, 0d0, 0d0,
401  6 40*0d0/
402  DATA (paru(i),i=101,200)/
403  & 0.00729735d0, 0.232d0, 0.007764d0, 1.0d0, 1.16639d-5,
404  & 0d0, 0d0, 0d0, 0d0, 0d0,
405  1 0.20d0, 0.25d0, 1.0d0, 4.0d0, 10d0, 0d0, 0d0, 0d0, 0d0, 0d0,
406  2 -0.693d0, -1.0d0, 0.387d0, 1.0d0, -0.08d0,
407  2 -1.0d0, 1.0d0, 1.0d0, 1.0d0, 0d0,
408  3 1.0d0,-1.0d0, 1.0d0,-1.0d0, 1.0d0, 0d0, 0d0, 0d0, 0d0, 0d0,
409  4 5.0d0, 1.0d0, 1.0d0, 0d0, 1.0d0, 1.0d0, 0d0, 0d0, 0d0, 0d0,
410  5 1.0d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0,
411  6 1.0d0, 1.0d0, 1.0d0, 1.0d0, 1.0d0, 0d0, 0d0, 0d0, 0d0, 0d0,
412  7 1.0d0, 1.0d0, 1.0d0, 1.0d0, 1.0d0, 1.0d0, 1.0d0, 0d0,0d0,0d0,
413  8 1.0d0, 1.0d0, 1.0d0, 0.0d0, 0.0d0, 1.0d0, 1.0d0, 0d0,0d0,0d0,
414  9 0d0, 0d0, 0d0, 0d0, 1.0d0, 0d0, 0d0, 0d0, 0d0, 0d0/
415  DATA mstj/
416  & 1, 3, 0, 0, 0, 0, 0, 0, 0, 0,
417  1 4, 2, 0, 1, 0, 2, 2, 20, 0, 0,
418  2 2, 1, 1, 2, 1, 2, 2, 0, 0, 0,
419  3 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
420  4 2, 2, 4, 2, 5, 3, 3, 0, 0, 3,
421  5 0, 3, 0, 2, 0, 0, 1, 0, 0, 0,
422  6 40*0,
423  & 5, 2, 7, 5, 1, 1, 0, 2, 0, 2,
424  1 0, 0, 0, 0, 1, 1, 0, 0, 0, 0,
425  2 80*0/
426  DATA parj/
427  & 0.10d0, 0.30d0, 0.40d0, 0.05d0, 0.50d0,
428  & 0.50d0, 0.50d0, 0.6d0, 1.2d0, 0.6d0,
429  1 0.50d0,0.60d0,0.75d0, 0d0, 0d0, 0d0, 0d0, 1.0d0, 1.0d0, 0d0,
430  2 0.36d0, 1.0d0,0.01d0, 2.0d0,1.0d0,0.4d0, 0d0, 0d0, 0d0, 0d0,
431  3 0.10d0, 1.0d0, 0.8d0, 1.5d0,0d0,2.0d0,0.2d0, 0d0,0.08d0,1d0,
432  4 0.3d0, 0.58d0, 0.5d0, 0.9d0,0.5d0,1.0d0,1.0d0,1.5d0,1d0,10d0,
433  5 0.77d0, 0.77d0, 0.77d0, -0.05d0, -0.005d0,
434  5 0d0, 0d0, 0d0, 1.0d0, 0d0,
435  6 4.5d0, 0.7d0, 0d0,0.003d0, 0.5d0, 0.5d0, 0d0, 0d0, 0d0, 0d0,
436  7 10d0, 1000d0, 100d0, 1000d0, 0d0, 0.7d0,10d0, 0d0,0d0,0.5d0,
437  8 0.29d0, 1.0d0, 1.0d0, 0d0, 10d0, 10d0, 0d0, 0d0, 0d0,1d-4,
438  9 0.02d0, 1.0d0, 0.2d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0,
439  & 0d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0,
440  1 0d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0,
441  2 1.0d0, 0.25d0,91.187d0,2.489d0, 0.01d0,
442  2 2.0d0, 1.0d0, 0.25d0,0.002d0, 0d0,
443  3 0d0, 0d0, 0d0, 0d0, 0.01d0, 0.99d0, 0d0, 0d0, 0.2d0, 0d0,
444  4 10*0d0,
445  5 10*0d0,
446  6 10*0d0,
447  7 0d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0, -0.693d0,
448  8 -1.0d0, 0.387d0, 1.0d0, -0.08d0, -1.0d0,
449  8 1.0d0, 1.0d0, -0.693d0, -1.0d0, 0.387d0,
450  9 1.0d0, -0.08d0, -1.0d0, 1.0d0, 1.0d0,
451  9 5*0d0/
452 
453 C...PYDAT2, with particle data and flavour treatment parameters.
454  DATA (kchg(i,1),i= 1, 500)/-1,2,-1,2,-1,2,-1,2,2*0,-3,0,-3,0,
455  &-3,0,-3,6*0,3,9*0,3,2*0,3,4*0,-1,41*0,2,-1,20*0,3*3,7*0,3*3,3*0,
456  &3*3,3*0,3*3,6*0,3*3,3*0,3*3,4*0,-2,-3,2*1,2*0,4,2*3,6,2*-2,2*-3,
457  &0,2*1,2*0,2*3,-2,2*-3,2*0,-3,2*1,2*0,3,0,2*4,2*3,2*6,3,2*1,2*0,
458  &2*3,2*0,4,2*3,2*6,2*3,6,2*-2,2*-3,0,-3,0,2*1,2*0,2*3,0,3,2*-2,
459  &2*-3,2*0,2*-3,0,2*1,2*0,2*3,2*0,2*3,-2,2*-3,2*0,2*-3,2*0,-3,2*0,
460  &2*3,4*0,2*3,2*0,2*3,2*0,2*3,4*0,2*3,2*0,2*3,3*0,3,2*0,3,0,3,0,3,
461  &2*0,3,0,3,3*0,-1,2,-1,2,-1,2,-3,0,-3,0,-3,4*0,3,2*0,3,0,-1,2,-1,
462  &2,-1,2,-3,0,-3,0,-3,2*0,3,3*0,3,8*0,-1,2,-3,6*0,3,2*6,0,3,4*0,3,
463  &7*0,3,
464 C...UED singlet and doublet quarks, leptons, and KK g, gamma, Z, and W
465  &81*0,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,
466  &3*-3,0,-3,0,-3,0,-3,
467  &3*0,3,
468  &25*0/
469  DATA (kchg(i,2),i= 1, 500)/8*1,12*0,2,20*0,1,107*0,-1,0,2*-1,
470  &2*0,-1,3*0,2*-1,3*0,2*-1,4*0,-1,5*0,2*-1,4*0,2*-1,5*0,2*-1,6*0,
471  &-1,7*0,2*-1,5*0,2*-1,6*0,2*-1,7*0,2*-1,8*0,-1,56*0,6*1,6*0,2,7*0,
472  &6*1,9*0,2,3*0,2,0,5*2,2*1,17*0,6*2,
473  &83*0,12*1,9*0,2,3*0,25*0/
474  DATA (kchg(i,3),i= 1, 500)/8*1,2*0,8*1,5*0,1,9*0,1,2*0,1,3*0,
475  &2*1,39*0,1,0,2*1,20*0,3*1,4*0,6*1,3*0,9*1,3*0,12*1,4*0,100*1,2*0,
476  &2*1,2*0,4*1,2*0,6*1,2*0,8*1,3*0,1,0,2*1,0,3*1,0,4*1,3*0,12*1,3*0,
477  &1,2*0,1,0,12*1,0,1,3*0,1,8*0,4*1,5*0,3*1,0,1,3*0,2*1,7*0,1,
478  &81*0,21*1,3*0,1,25*0/
479  DATA (kchg(i,4),i= 1, 290)/1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
480  &16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,
481  &37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,
482  &58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,
483  &79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,
484  &100,110,111,113,115,130,211,213,215,221,223,225,310,311,313,315,
485  &321,323,325,331,333,335,411,413,415,421,423,425,431,433,435,441,
486  &443,445,511,513,515,521,523,525,531,533,535,541,543,545,551,553,
487  &555,990,1103,1114,2101,2103,2112,2114,2203,2212,2214,2224,3101,
488  &3103,3112,3114,3122,3201,3203,3212,3214,3222,3224,3303,3312,3314,
489  &3322,3324,3334,4101,4103,4112,4114,4122,4132,4201,4203,4212,4214,
490  &4222,4224,4232,4301,4303,4312,4314,4322,4324,4332,4334,4403,4412,
491  &4414,4422,4424,4432,4434,4444,5101,5103,5112,5114,5122,5132,5142,
492  &5201,5203,5212,5214,5222,5224,5232,5242,5301,5303,5312,5314,5322,
493  &5324,5332,5334,5342,5401,5403,5412,5414,5422,5424,5432,5434,5442,
494  &5444,5503,5512,5514,5522,5524,5532,5534,5542,5544,5554,10111,
495  &10113,10211,10213,10221,10223,10311,10313,10321,10323,10331,
496  &10333,10411,10413,10421,10423,10431,10433,10441,10443,10511,
497  &10513,10521,10523,10531,10533,10541,10543,10551,10553,20113,
498  &20213,20223,20313,20323,20333,20413,20423,20433,20443,20513/
499  DATA (kchg(i,4),i= 291, 500)/20523,20533,20543,20553,100443,
500  &100553,1000001,1000002,1000003,1000004,1000005,1000006,1000011,
501  &1000012,1000013,1000014,1000015,1000016,1000021,1000022,1000023,
502  &1000024,1000025,1000035,1000037,1000039,2000001,2000002,2000003,
503  &2000004,2000005,2000006,2000011,2000012,2000013,2000014,2000015,
504  &2000016,3000111,3000211,3000221,3000331,3000113,3000213,3000223,
505  &3100021,3100111,3200111,3100113,3200113,3300113,3400113,4000001,
506  &4000002,4000011,4000012,5000039,9900012,9900014,9900016,9900023,
507  &9900024,9900041,9900042,9900110,9900210,9900220,9900330,9900440,
508  &9902110,9902210,9900443,9900441,9910441,9900553,9900551,9910551,
509  &3000115,3000215,
510  &81*0,
511 C...UED singlet and doublet quarks and leptons, and KK g, gamma, Z, and W.
512  &6100001,6100002,6100003,6100004,6100005,6100006,
513  &5100001,5100002,5100003,5100004,5100005,5100006,
514  &6100011,6100013,6100015,
515  &5100012,5100011,5100014,5100013,5100016,5100015,
516  &5100021,5100022,5100023,5100024,
517  &25*0/
518  DATA (pmas(i,1),i= 1, 217)/2*0.33d0,0.5d0,1.5d0,4.8d0,175d0,
519  &2*400d0,2*0d0,0.00051d0,0d0,0.10566d0,0d0,1.777d0,0d0,400d0,
520  &5*0d0,91.188d0,80.45d0,115d0,6*0d0,500d0,900d0,500d0,3*300d0,
521  &3*0d0,5000d0,200d0,40*0d0,1d0,2d0,5d0,16*0d0,0.13498d0,0.7685d0,
522  &1.318d0,0.49767d0,0.13957d0,0.7669d0,1.318d0,0.54745d0,0.78194d0,
523  &1.275d0,2*0.49767d0,0.8961d0,1.432d0,0.4936d0,0.8916d0,1.425d0,
524  &0.95777d0,1.0194d0,1.525d0,1.8693d0,2.01d0,2.46d0,1.8645d0,
525  &2.0067d0,2.46d0,1.9685d0,2.1124d0,2.5735d0,2.9798d0,3.09688d0,
526  &3.5562d0,5.2792d0,5.3248d0,5.83d0,5.2789d0,5.3248d0,5.83d0,
527  &5.3693d0,5.4163d0,6.07d0,6.594d0,6.602d0,7.35d0,9.4d0,9.4603d0,
528  &9.9132d0,0d0,0.77133d0,1.234d0,0.57933d0,0.77133d0,0.93957d0,
529  &1.233d0,0.77133d0,0.93827d0,1.232d0,1.231d0,0.80473d0,0.92953d0,
530  &1.19744d0,1.3872d0,1.11568d0,0.80473d0,0.92953d0,1.19255d0,
531  &1.3837d0,1.18937d0,1.3828d0,1.09361d0,1.3213d0,1.535d0,1.3149d0,
532  &1.5318d0,1.67245d0,1.96908d0,2.00808d0,2.4521d0,2.5d0,2.2849d0,
533  &2.4703d0,1.96908d0,2.00808d0,2.4535d0,2.5d0,2.4529d0,2.5d0,
534  &2.4656d0,2.15432d0,2.17967d0,2.55d0,2.63d0,2.55d0,2.63d0,2.704d0,
535  &2.8d0,3.27531d0,3.59798d0,3.65648d0,3.59798d0,3.65648d0,
536  &3.78663d0,3.82466d0,4.91594d0,5.38897d0,5.40145d0,5.8d0,5.81d0,
537  &5.641d0,5.84d0,7.00575d0,5.38897d0,5.40145d0,5.8d0,5.81d0,5.8d0/
538  DATA (pmas(i,1),i= 218, 500)/5.81d0,5.84d0,7.00575d0,5.56725d0,
539  &5.57536d0,5.96d0,5.97d0,5.96d0,5.97d0,6.12d0,6.13d0,7.19099d0,
540  &6.67143d0,6.67397d0,7.03724d0,7.0485d0,7.03724d0,7.0485d0,
541  &7.21101d0,7.219d0,8.30945d0,8.31325d0,10.07354d0,10.42272d0,
542  &10.44144d0,10.42272d0,10.44144d0,10.60209d0,10.61426d0,
543  &11.70767d0,11.71147d0,15.11061d0,0.9835d0,1.231d0,0.9835d0,
544  &1.231d0,1d0,1.17d0,1.429d0,1.29d0,1.429d0,1.29d0,2*1.4d0,2.272d0,
545  &2.424d0,2.272d0,2.424d0,2.5d0,2.536d0,3.4151d0,3.46d0,5.68d0,
546  &5.73d0,5.68d0,5.73d0,5.92d0,5.97d0,7.25d0,7.3d0,9.8598d0,9.875d0,
547  &2*1.23d0,1.282d0,2*1.402d0,1.427d0,2*2.372d0,2.56d0,3.5106d0,
548  &2*5.78d0,6.02d0,7.3d0,9.8919d0,3.686d0,10.0233d0,32*500d0,
549  &3*110d0,350d0,3*210d0,500d0,125d0,250d0,400d0,2*350d0,300d0,
550  &4*400d0,1000d0,3*500d0,1200d0,750d0,2*200d0,7*0d0,3*3.1d0,
551  &3*9.5d0,2*250d0,
552  &81*0,
553 C...UED
554  &586.,588.,586.,588.,586.,586.,6*598.,
555  &3*505.,6*516.,640.,501.,536.,536.,25*0.d0/
556  DATA (pmas(i,2),i= 1, 500)/5*0d0,1.39816d0,16*0d0,2.47813d0,
557  &2.07115d0,0.00367d0,6*0d0,14.54029d0,0d0,16.66099d0,8.38842d0,
558  &3.3752d0,4.17669d0,3*0d0,417.29147d0,0.39162d0,60*0d0,0.151d0,
559  &0.107d0,2*0d0,0.149d0,0.107d0,0d0,0.00843d0,0.185d0,2*0d0,
560  &0.0505d0,0.109d0,0d0,0.0498d0,0.098d0,0.0002d0,0.00443d0,0.076d0,
561  &2*0d0,0.023d0,2*0d0,0.023d0,2*0d0,0.015d0,0.0013d0,0d0,0.002d0,
562  &2*0d0,0.02d0,2*0d0,0.02d0,2*0d0,0.02d0,2*0d0,0.02d0,5*0d0,0.12d0,
563  &3*0d0,0.12d0,2*0d0,2*0.12d0,3*0d0,0.0394d0,4*0d0,0.036d0,0d0,
564  &0.0358d0,2*0d0,0.0099d0,0d0,0.0091d0,74*0d0,0.06d0,0.142d0,
565  &0.06d0,0.142d0,0d0,0.36d0,0.287d0,0.09d0,0.287d0,0.09d0,0.25d0,
566  &0.08d0,0.05d0,0.02d0,0.05d0,0.02d0,0.05d0,0d0,0.014d0,0.01d0,
567  &8*0.05d0,0d0,0.01d0,2*0.4d0,0.025d0,2*0.174d0,0.053d0,3*0.05d0,
568  &0.0009d0,4*0.05d0,3*0d0,19*1d0,0d0,7*1d0,0d0,1d0,0d0,1d0,0d0,
569  &0.0208d0,0.01195d0,0.03705d0,0.09511d0,1.89978d0,1.60746d0,
570  &0.13396d0,200.47294d0,0.02296d0,0.18886d0,94.66794d0,6.08718d0,
571  &0d0,2.17482d0,2.59359d0,2.59687d0,0.42896d0,0.41912d0,0.14153d0,
572  &2*0.00098d0,0.00097d0,26.7245d0,21.74916d0,0.88159d0,0.88001d0,
573  &7*0d0,6*0.01d0,0.25499d0,0.28446d0,131*0d0/
574  DATA (pmas(i,3),i= 1, 500)/5*0d0,13.98156d0,16*0d0,24.78129d0,
575  &20.71149d0,0.03669d0,6*0d0,145.40294d0,0d0,166.60993d0,
576  &83.88423d0,33.75195d0,41.76694d0,3*0d0,4172.91467d0,3.91621d0,
577  &60*0d0,0.4d0,0.25d0,2*0d0,0.4d0,0.25d0,0d0,0.1d0,0.17d0,2*0d0,
578  &0.2d0,0.12d0,0d0,0.2d0,0.12d0,0.002d0,0.015d0,0.2d0,2*0d0,0.12d0,
579  &2*0d0,0.12d0,2*0d0,0.05d0,0.005d0,0d0,0.01d0,2*0d0,0.05d0,2*0d0,
580  &0.05d0,2*0d0,0.05d0,2*0d0,0.05d0,5*0d0,0.14d0,3*0d0,0.14d0,2*0d0,
581  &2*0.14d0,3*0d0,0.04d0,4*0d0,0.035d0,0d0,0.035d0,2*0d0,0.05d0,0d0,
582  &0.05d0,74*0d0,0.05d0,0.25d0,0.05d0,0.25d0,0d0,0.2d0,0.4d0,
583  &0.005d0,0.4d0,0.01d0,0.35d0,0.001d0,0.1d0,0.08d0,0.1d0,0.08d0,
584  &0.1d0,0d0,0.05d0,0.02d0,6*0.1d0,0.05d0,0.1d0,0d0,0.02d0,2*0.3d0,
585  &0.05d0,2*0.3d0,0.02d0,2*0.1d0,0.03d0,0.001d0,4*0.1d0,3*0d0,
586  &19*10d0,0.00001d0,7*10d0,0.00001d0,10d0,0.00001d0,10d0,0.00001d0,
587  &0.20797d0,0.11949d0,0.37048d0,0.95114d0,18.99785d0,16.07463d0,
588  &1.33964d0,450d0,0.22959d0,1.88863d0,360d0,60.8718d0,0d0,
589  &21.74824d0,25.93594d0,25.96873d0,4.28961d0,4.19124d0,1.41528d0,
590  &0.00977d0,0.00976d0,0.00973d0,267.24501d0,217.49162d0,8.81592d0,
591  &8.80013d0,13*0d0,2.54987d0,2.84456d0,
592  &81*0,
593 C...UED
594  &12*0.2d0,9*0.1d0,0.2,10.,0.07,0.3,25*0.d0/
595  DATA (pmas(i,4),i= 1, 500)/12*0d0,658654d0,0d0,0.0872d0,68*0d0,
596  &0.1d0,0.387d0,16*0d0,0.00003d0,2*0d0,15500d0,7804.5d0,5*0d0,
597  &26.762d0,3*0d0,3709d0,5*0d0,0.317d0,2*0d0,0.1244d0,2*0d0,0.14d0,
598  &5*0d0,0.468d0,2*0d0,0.462d0,2*0d0,0.483d0,2*0d0,0.15d0,18*0d0,
599  &44.34d0,0d0,78.88d0,4*0d0,23.96d0,2*0d0,49.1d0,0d0,87.1d0,0d0,
600  &24.6d0,4*0d0,0.0618d0,0.029d0,6*0d0,0.106d0,6*0d0,0.019d0,2*0d0,
601  &7*0.1d0,4*0d0,0.342d0,2*0.387d0,6*0d0,2*0.387d0,6*0d0,0.387d0,
602  &0d0,0.387d0,2*0d0,8*0.387d0,0d0,9*0.387d0,120*0d0,131*0d0/
603 
604  DATA parf/
605  & 0.5d0,0.25d0, 0.5d0,0.25d0, 1d0, 0.5d0, 0d0, 0d0, 0d0, 0d0,
606  1 0.5d0, 0d0, 0.5d0, 0d0, 1d0, 1d0, 0d0, 0d0, 0d0, 0d0,
607  2 0.5d0, 0d0, 0.5d0, 0d0, 1d0, 1d0, 0d0, 0d0, 0d0, 0d0,
608  3 0.5d0, 0d0, 0.5d0, 0d0, 1d0, 1d0, 0d0, 0d0, 0d0, 0d0,
609  4 0.5d0, 0d0, 0.5d0, 0d0, 1d0, 1d0, 0d0, 0d0, 0d0, 0d0,
610  5 0.5d0, 0d0, 0.5d0, 0d0, 1d0, 1d0, 0d0, 0d0, 0d0, 0d0,
611  6 0.75d0, 0.5d0, 0d0,0.1667d0,0.0833d0,0.1667d0,0d0,0d0,0d0, 0d0,
612  7 0d0, 0d0, 1d0,0.3333d0,0.6667d0,0.3333d0,0d0,0d0,0d0, 0d0,
613  8 0d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0,
614  9 0.0099d0, 0.0056d0, 0.199d0, 1.23d0, 4.17d0, 165d0, 4*0d0,
615  & 0.325d0,0.325d0,0.5d0,1.6d0, 5.0d0, 0d0, 0d0, 0d0, 0d0, 0d0,
616  1 0d0,0.11d0,0.16d0,0.048d0,0.50d0,0.45d0,0.55d0,0.60d0,0d0,0d0,
617  2 0.2d0, 0.1d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0,
618  3 60*0d0,
619  4 0.2d0, 0.5d0, 8*0d0,
620  5 1800*0d0/
621  DATA ((vckm(i,j),j=1,4),i=1,4)/
622  & 0.95113d0, 0.04884d0, 0.00003d0, 0.00000d0,
623  & 0.04884d0, 0.94940d0, 0.00176d0, 0.00000d0,
624  & 0.00003d0, 0.00176d0, 0.99821d0, 0.00000d0,
625  & 0.00000d0, 0.00000d0, 0.00000d0, 1.00000d0/
626 
627 C...PYDAT3, with particle decay parameters and data.
628  DATA (mdcy(i,1),i= 1, 500)/5*0,3*1,6*0,1,0,1,5*0,3*1,6*0,1,0,
629  &4*1,3*0,2*1,40*0,3*1,16*0,3*1,2*0,9*1,0,32*1,2*0,1,3*0,1,2*0,2*1,
630  &2*0,3*1,2*0,4*1,0,5*1,2*0,4*1,2*0,5*1,2*0,6*1,0,7*1,2*0,5*1,2*0,
631  &6*1,2*0,7*1,2*0,8*1,0,75*1,0,7*1,0,1,0,1,0,26*1,7*0,8*1,
632  &81*0,
633 C...UED
634  &5*1,0,5*1,0,13*1,25*0/
635  DATA (mdcy(i,2),i= 1, 351)/1,9,17,25,33,41,56,66,2*0,76,80,82,
636  &87,89,143,145,150,2*0,153,162,174,190,210,6*0,289,0,311,334,420,
637  &503,3*0,530,539,40*0,540,541,545,16*0,554,556,561,570,579,581,
638  &583,590,598,604,613,615,617,620,630,636,639,650,656,667,673,736,
639  &739,747,808,810,818,851,853,857,858,861,863,899,900,908,944,945,
640  &953,992,993,997,1028,1029,1033,1034,1043,2*0,1045,3*0,1046,2*0,
641  &1049,1052,2*0,1053,1055,1058,2*0,1062,1063,1066,1069,0,1072,1077,
642  &1079,1082,1084,2*0,1088,1089,1090,1166,2*0,1170,1171,1172,1173,
643  &1174,2*0,1178,1179,1181,1182,1184,1188,0,1189,1193,1197,1201,
644  &1205,1209,1213,2*0,1217,1218,1219,1236,1245,2*0,1254,1255,1256,
645  &1257,1258,1267,2*0,1276,1277,1278,1279,1280,1289,1290,2*0,1299,
646  &1308,1317,1326,1335,1344,1353,1362,0,1371,1380,1389,1398,1407,
647  &1416,1425,1434,1443,1452,1453,1454,1455,1456,1461,1464,1466,1471,
648  &1473,1478,1485,1489,1491,1493,1495,1497,1499,1501,1503,1504,1506,
649  &1508,1510,1512,1514,1516,1518,1520,1522,1523,1525,1527,1541,1543,
650  &1545,1549,1551,1553,1555,1557,1559,1561,1563,1565,1567,1578,1592,
651  &1637,1661,1706,1730,1775,1802,1833,1859,1891,1917,1949,1975,2162,
652  &2331,2595,2826,3106,3402,0,3657,3706,3734,3783,3811,3860,3888,0,
653  &3924,0,3960,0,3996,4004,4012,4020,4217,4243,4270,4023,4029,4036,
654  &4043,4050,4056,4062,4071,4075,4079,4082,4084,4104,4126,4148,4170/
655  DATA (mdcy(i,2),i= 352, 500)/4185,4197,4204,7*0,4211,4212,4213,
656  &4214,4215,4216,4296,4322,
657  &81*0,
658 C...UED
659  %5001,5003,5005,5007,5009,5011,5013,5016,5019,5022,5025,5028,
660  &5031,5032,5033,
661  &5034,5035,5036,5037,5038,5039,5040,5064,5065,5083,
662  &25*0/
663  DATA (mdcy(i,3),i= 1, 500)/5*8,15,2*10,2*0,4,2,5,2,54,2,5,3,
664  &2*0,9,12,16,20,79,6*0,22,0,23,86,83,27,3*0,9,1,40*0,1,4,9,16*0,2,
665  &5,2*9,2*2,7,8,6,9,2*2,3,10,6,3,11,6,11,6,63,3,8,61,2,8,33,2,4,1,
666  &3,2,36,1,8,36,1,8,39,1,4,31,1,4,1,9,2,2*0,1,3*0,3,2*0,3,1,2*0,2,
667  &3,4,2*0,1,3*3,0,5,2,3,2,4,2*0,2*1,76,4,2*0,4*1,4,2*0,1,2,1,2,4,1,
668  &0,7*4,2*0,2*1,17,2*9,2*0,4*1,2*9,2*0,4*1,9,1,9,2*0,8*9,0,9*9,4*1,
669  &5,3,2,5,2,5,7,4,7*2,1,9*2,1,2*2,14,2*2,4,9*2,11,14,45,24,45,24,
670  &45,27,31,26,32,26,32,26,187,169,264,231,280,296,255,0,49,28,49,
671  &28,49,28,36,0,36,0,36,0,3*8,3,26,27,26,6,3*7,2*6,9,2*4,3,2,20,
672  &3*22,15,12,2*7,7*0,6*1,26,30,
673  &81*0,
674 C...UED
675  &6*2,6*3,9*1,24,1,18,6,25*0/
676  DATA (mdme(i,1),i= 1,8000)/6*1,-1,7*1,-1,7*1,-1,7*1,-1,7*1,-1,
677  &7*1,-1,1,7*-1,8*1,2*-1,8*1,2*-1,73*1,-1,2*1,-1,5*1,0,2*-1,6*1,0,
678  &2*-1,3*1,-1,6*1,2*-1,6*1,2*-1,3*1,-1,3*1,-1,3*1,5*-1,3*1,-1,6*1,
679  &2*-1,3*1,-1,5*1,62*1,6*1,2*-1,6*1,8*-1,3*1,-1,3*1,-1,3*1,5*-1,
680  &3*1,4*-1,6*1,2*-1,3*1,-1,12*1,62*1,6*1,2*-1,3*1,-1,9*1,62*1,
681  &3*1,-1,3*1,-1,1,18*1,4*1,2*-1,2*1,-1,1249*1,2*-1,377*1,2*-1,
682  &1921*1,2*-1,6*1,2*-1,133*1,2*-1,6*1,2*-1,10*1,-1,3*1,-1,3*1,5*-1,
683  &3*1,-1,16*1,2*-1,6*1,2*-1,16*1,2*-1,6*1,2*-1,13*1,-1,3*1,-1,3*1,
684  &5*-1,3*1,-1,
685  &649*0,
686 C...UED
687  &10*1,2*0,15*1,3*0,9*1,5*1,0,5*1,0,5*1,0,5*1,0,
688  &1,24*1,2912*0/
689  DATA (mdme(i,2),i= 1,8000)/43*102,4*0,102,0,6*53,3*102,4*0,102,
690  &2*0,3*102,4*0,102,2*0,6*102,42,6*102,2*42,2*0,8*41,2*0,36*41,
691  &8*102,0,102,0,102,2*0,21*102,8*32,8*0,16*32,4*0,8*32,9*0,62*53,
692  &8*32,14*0,16*32,7*0,8*32,16*0,62*53,8*32,13*0,62*53,4*32,5*0,
693  &18*53,6*32,4*0,12,2*42,2*11,9*42,0,2,3,15*0,4*42,5*0,3,12*0,2,
694  &3*0,1,0,3,16*0,2*3,15*0,2*42,2*3,18*0,2*3,3*0,1,11*0,22*42,41*0,
695  &2*3,9*0,16*42,45*0,3,10*0,10*42,20*0,2*13,6*0,12,2*0,12,0,12,
696  &14*42,16*0,48,3*13,2*42,9*0,14*42,16*0,48,3*13,2*42,9*0,14*42,
697  &19*0,48,3*13,2*42,6*0,2*11,28*42,5*0,32,3*0,4*32,2*4,0,32,45*0,
698  &14*42,52*0,10*13,2*42,2*11,4*0,2*42,2*11,6*0,2*42,2*11,0,2*42,
699  &2*11,2*42,2*11,2*42,2*11,2*42,2*11,2*42,2*11,2*42,2*11,2*42,2*11,
700  &2*0,3*42,8*0,48,3*13,20*42,4*0,18*42,4*0,9*42,0,162*42,50*0,2*12,
701  &17*0,2*32,33*0,12,9*0,32,2*0,12,11*0,4*32,2*4,5*0,2404*53,4*32,
702  &3*0,6*32,3*0,4*32,3*0,50*32,3*53,12*0,8*32,12*0,66*51,6*32,9*0,
703  &9*32,17*0,6*51,10*0,8*32,15*0,16*32,14*0,8*32,18*0,8*32,18*0,
704  &16*32,
705 C...UED
706  &653*0,30*0,9*0,12*0,37*0,2912*0/
707  DATA (brat(i) ,i= 1, 348)/43*0d0,0.00003d0,0.001765d0,
708  &0.998205d0,35*0d0,1d0,6*0d0,0.1783d0,0.1735d0,0.1131d0,0.2494d0,
709  &0.003d0,0.09d0,0.0027d0,0.01d0,0.0014d0,0.0012d0,2*0.00025d0,
710  &0.0071d0,0.012d0,0.0004d0,0.00075d0,0.00006d0,2*0.00078d0,
711  &0.0034d0,0.08d0,0.011d0,0.0191d0,0.00006d0,0.005d0,0.0133d0,
712  &0.0067d0,0.0005d0,0.0035d0,0.0006d0,0.0015d0,0.00021d0,0.0002d0,
713  &0.00075d0,0.0001d0,0.0002d0,0.0011d0,3*0.0002d0,0.00022d0,
714  &0.0004d0,0.0001d0,2*0.00205d0,2*0.00069d0,0.00025d0,0.00051d0,
715  &0.00025d0,35*0d0,0.153995d0,0.11942d0,0.153984d0,0.119259d0,
716  &0.152272d0,3*0d0,0.033576d0,0.066806d0,0.033576d0,0.066806d0,
717  &0.0335d0,0.066806d0,2*0d0,0.321369d0,0.016494d0,2*0d0,0.016502d0,
718  &0.320615d0,2*0d0,0.00001d0,0.000591d0,6*0d0,2*0.108166d0,
719  &0.108087d0,0d0,0.000001d0,0d0,0.000353d0,0.04359d0,0.795274d0,
720  &4*0d0,0.000339d0,0.095746d0,0d0,0.060724d0,0.003054d0,0.000919d0,
721  &64*0d0,0.145835d0,0.113276d0,0.145835d0,0.113271d0,0.145781d0,
722  &0.049002d0,2*0d0,0.032025d0,0.063642d0,0.032025d0,0.063642d0,
723  &0.032022d0,0.063642d0,8*0d0,0.251225d0,0.0129d0,0.000006d0,0d0,
724  &0.0129d0,0.250764d0,0.00038d0,0d0,0.000008d0,0.000465d0,
725  &0.215418d0,5*0d0,2*0.085312d0,0.08531d0,7*0d0,0.000029d0,
726  &0.000536d0,5*0d0,0.000074d0,0d0,0.000417d0,0.000015d0,0.000061d0/
727  DATA (brat(i) ,i= 349, 655)/0.306789d0,0.689189d0,0d0,0.00289d0,
728  &69*0d0,0.000001d0,0.000072d0,0.001333d0,4*0d0,0.000001d0,
729  &0.000184d0,0d0,0.003108d0,0.000015d0,0.000003d0,2*0d0,0.995284d0,
730  &66*0d0,0.000014d0,0.082234d0,2*0d0,0.000013d0,0.003746d0,0d0,
731  &0.913992d0,18*0d0,3*0.215119d0,0.214724d0,2*0d0,0.06996d0,
732  &0.069959d0,0d0,2*1d0,2*0.08d0,0.76d0,0.08d0,2*0.105d0,0.04d0,
733  &0.5d0,0.08d0,0.14d0,0.01d0,0.015d0,0.005d0,0.988d0,0.012d0,
734  &0.998739d0,0.00079d0,0.00038d0,0.000046d0,0.000045d0,2*0.34725d0,
735  &0.144d0,0.104d0,0.0245d0,2*0.01225d0,0.0028d0,0.0057d0,0.2112d0,
736  &0.1256d0,2*0.1939d0,2*0.1359d0,0.002d0,0.001d0,0.0006d0,
737  &0.999877d0,0.000123d0,0.99955d0,0.00045d0,2*0.34725d0,0.144d0,
738  &0.104d0,0.049d0,0.0028d0,0.0057d0,0.3923d0,0.321d0,0.2317d0,
739  &0.0478d0,0.0049d0,0.0013d0,0.0003d0,0.0007d0,0.89d0,0.08693d0,
740  &0.0221d0,0.00083d0,2*0.00007d0,0.564d0,0.282d0,0.072d0,0.028d0,
741  &0.023d0,2*0.0115d0,0.005d0,0.003d0,0.6861d0,0.3139d0,2*0.5d0,
742  &0.665d0,0.333d0,0.002d0,0.333d0,0.166d0,0.168d0,0.084d0,0.087d0,
743  &0.043d0,0.059d0,2*0.029d0,0.002d0,0.6352d0,0.2116d0,0.0559d0,
744  &0.0173d0,0.0482d0,0.0318d0,0.666d0,0.333d0,0.001d0,0.332d0,
745  &0.166d0,0.168d0,0.084d0,0.086d0,0.043d0,0.059d0,2*0.029d0,
746  &2*0.002d0,0.437d0,0.208d0,0.302d0,0.0302d0,0.0212d0,0.0016d0/
747  DATA (brat(i) ,i= 656, 831)/0.48947d0,0.34d0,3*0.043d0,0.027d0,
748  &0.0126d0,0.0013d0,0.0003d0,0.00025d0,0.00008d0,0.444d0,2*0.222d0,
749  &0.104d0,2*0.004d0,0.07d0,0.065d0,2*0.005d0,2*0.011d0,5*0.001d0,
750  &0.07d0,0.065d0,2*0.005d0,2*0.011d0,5*0.001d0,0.026d0,0.019d0,
751  &0.066d0,0.041d0,0.045d0,0.076d0,0.0073d0,2*0.0047d0,0.026d0,
752  &0.001d0,0.0006d0,0.0066d0,0.005d0,2*0.003d0,2*0.0006d0,2*0.001d0,
753  &0.006d0,0.005d0,0.012d0,0.0057d0,0.067d0,0.008d0,0.0022d0,
754  &0.027d0,0.004d0,0.019d0,0.012d0,0.002d0,0.009d0,0.0218d0,0.001d0,
755  &0.022d0,0.087d0,0.001d0,0.0019d0,0.0015d0,0.0028d0,0.683d0,
756  &0.306d0,0.011d0,0.3d0,0.15d0,0.16d0,0.08d0,0.13d0,0.06d0,0.08d0,
757  &0.04d0,0.034d0,0.027d0,2*0.002d0,2*0.004d0,2*0.002d0,0.034d0,
758  &0.027d0,2*0.002d0,2*0.004d0,2*0.002d0,0.0365d0,0.045d0,0.073d0,
759  &0.062d0,3*0.021d0,0.0061d0,0.015d0,0.025d0,0.0088d0,0.074d0,
760  &0.0109d0,0.0041d0,0.002d0,0.0035d0,0.0011d0,0.001d0,0.0027d0,
761  &2*0.0016d0,0.0018d0,0.011d0,0.0063d0,0.0052d0,0.018d0,0.016d0,
762  &0.0034d0,0.0036d0,0.0009d0,0.0006d0,0.015d0,0.0923d0,0.018d0,
763  &0.022d0,0.0077d0,0.009d0,0.0075d0,0.024d0,0.0085d0,0.067d0,
764  &0.0511d0,0.017d0,0.0004d0,0.0028d0,0.619d0,0.381d0,0.3d0,0.15d0,
765  &0.16d0,0.08d0,0.13d0,0.06d0,0.08d0,0.04d0,0.01d0,2*0.02d0,0.03d0,
766  &2*0.005d0,2*0.02d0,0.03d0,2*0.005d0,0.015d0,0.037d0,0.028d0/
767  DATA (brat(i) ,i= 832, 997)/0.079d0,0.095d0,0.052d0,0.0078d0,
768  &4*0.001d0,0.028d0,0.033d0,0.026d0,0.05d0,0.01d0,4*0.005d0,0.25d0,
769  &0.0952d0,0.94d0,0.06d0,2*0.4d0,2*0.1d0,1d0,0.0602d0,0.0601d0,
770  &0.8797d0,0.135d0,0.865d0,0.02d0,0.055d0,2*0.005d0,0.008d0,
771  &0.012d0,0.02d0,0.055d0,2*0.005d0,0.008d0,0.012d0,0.01d0,0.03d0,
772  &0.0035d0,0.011d0,0.0055d0,0.0042d0,0.009d0,0.018d0,0.015d0,
773  &0.0185d0,0.0135d0,0.025d0,0.0004d0,0.0007d0,0.0008d0,0.0014d0,
774  &0.0019d0,0.0025d0,0.4291d0,0.08d0,0.07d0,0.02d0,0.015d0,0.005d0,
775  &1d0,0.3d0,0.15d0,0.16d0,0.08d0,0.13d0,0.06d0,0.08d0,0.04d0,
776  &0.02d0,0.055d0,2*0.005d0,0.008d0,0.012d0,0.02d0,0.055d0,
777  &2*0.005d0,0.008d0,0.012d0,0.01d0,0.03d0,0.0035d0,0.011d0,
778  &0.0055d0,0.0042d0,0.009d0,0.018d0,0.015d0,0.0185d0,0.0135d0,
779  &0.025d0,0.0004d0,0.0007d0,0.0008d0,0.0014d0,0.0019d0,0.0025d0,
780  &0.4291d0,0.08d0,0.07d0,0.02d0,0.015d0,0.005d0,1d0,0.3d0,0.15d0,
781  &0.16d0,0.08d0,0.13d0,0.06d0,0.08d0,0.04d0,0.02d0,0.055d0,
782  &2*0.005d0,0.008d0,0.012d0,0.02d0,0.055d0,2*0.005d0,0.008d0,
783  &0.012d0,0.01d0,0.03d0,0.0035d0,0.011d0,0.0055d0,0.0042d0,0.009d0,
784  &0.018d0,0.015d0,0.0185d0,0.0135d0,0.025d0,2*0.0002d0,0.0007d0,
785  &2*0.0004d0,0.0014d0,0.001d0,0.0009d0,0.0025d0,0.4291d0,0.08d0,
786  &0.07d0,0.02d0,0.015d0,0.005d0,1d0,2*0.3d0,2*0.2d0,0.047d0/
787  DATA (brat(i) ,i= 998,1188)/0.122d0,0.006d0,0.012d0,0.035d0,
788  &0.012d0,0.035d0,0.003d0,0.007d0,0.15d0,0.037d0,0.008d0,0.002d0,
789  &0.05d0,0.015d0,0.003d0,0.001d0,0.014d0,0.042d0,0.014d0,0.042d0,
790  &0.24d0,0.065d0,0.012d0,0.003d0,0.001d0,0.002d0,0.001d0,0.002d0,
791  &0.014d0,0.003d0,1d0,2*0.3d0,2*0.2d0,1d0,0.0252d0,0.0248d0,
792  &0.0267d0,0.015d0,0.045d0,0.015d0,0.045d0,0.7743d0,0.029d0,0.22d0,
793  &0.78d0,1d0,0.331d0,0.663d0,0.006d0,0.663d0,0.331d0,0.006d0,1d0,
794  &0.999d0,0.001d0,0.88d0,2*0.06d0,0.639d0,0.358d0,0.002d0,0.001d0,
795  &1d0,0.88d0,2*0.06d0,0.516d0,0.483d0,0.001d0,0.88d0,2*0.06d0,
796  &0.9988d0,0.0001d0,0.0006d0,0.0004d0,0.0001d0,0.667d0,0.333d0,
797  &0.9954d0,0.0011d0,0.0035d0,0.333d0,0.667d0,0.676d0,0.234d0,
798  &0.085d0,0.005d0,2*1d0,0.018d0,2*0.005d0,0.003d0,0.002d0,
799  &2*0.006d0,0.018d0,2*0.005d0,0.003d0,0.002d0,2*0.006d0,0.0066d0,
800  &0.025d0,0.016d0,0.0088d0,2*0.005d0,0.0058d0,0.005d0,0.0055d0,
801  &4*0.004d0,2*0.002d0,2*0.004d0,0.003d0,0.002d0,2*0.003d0,
802  &3*0.002d0,2*0.001d0,0.002d0,2*0.001d0,2*0.002d0,0.0013d0,
803  &0.0018d0,5*0.001d0,4*0.003d0,2*0.005d0,2*0.002d0,2*0.001d0,
804  &2*0.002d0,2*0.001d0,0.2432d0,0.057d0,2*0.035d0,0.15d0,2*0.075d0,
805  &0.03d0,2*0.015d0,2*0.08d0,0.76d0,0.08d0,4*1d0,2*0.08d0,0.76d0,
806  &0.08d0,1d0,2*0.5d0,1d0,2*0.5d0,2*0.08d0,0.76d0,0.08d0,1d0/
807  DATA (brat(i) ,i=1189,1381)/2*0.08d0,0.76d0,3*0.08d0,0.76d0,
808  &3*0.08d0,0.76d0,3*0.08d0,0.76d0,3*0.08d0,0.76d0,3*0.08d0,0.76d0,
809  &3*0.08d0,0.76d0,0.08d0,2*1d0,2*0.105d0,0.04d0,0.0077d0,0.02d0,
810  &0.0235d0,0.0285d0,0.0435d0,0.0011d0,0.0022d0,0.0044d0,0.4291d0,
811  &0.08d0,0.07d0,0.02d0,0.015d0,0.005d0,2*0.105d0,0.04d0,0.5d0,
812  &0.08d0,0.14d0,0.01d0,0.015d0,0.005d0,2*0.105d0,0.04d0,0.5d0,
813  &0.08d0,0.14d0,0.01d0,0.015d0,0.005d0,4*1d0,2*0.105d0,0.04d0,
814  &0.5d0,0.08d0,0.14d0,0.01d0,0.015d0,0.005d0,2*0.105d0,0.04d0,
815  &0.5d0,0.08d0,0.14d0,0.01d0,0.015d0,0.005d0,4*1d0,2*0.105d0,
816  &0.04d0,0.5d0,0.08d0,0.14d0,0.01d0,0.015d0,0.005d0,1d0,2*0.105d0,
817  &0.04d0,0.5d0,0.08d0,0.14d0,0.01d0,0.015d0,0.005d0,2*0.105d0,
818  &0.04d0,0.5d0,0.08d0,0.14d0,0.01d0,0.015d0,0.005d0,2*0.105d0,
819  &0.04d0,0.5d0,0.08d0,0.14d0,0.01d0,0.015d0,0.005d0,2*0.105d0,
820  &0.04d0,0.5d0,0.08d0,0.14d0,0.01d0,0.015d0,0.005d0,2*0.105d0,
821  &0.04d0,0.5d0,0.08d0,0.14d0,0.01d0,0.015d0,0.005d0,2*0.105d0,
822  &0.04d0,0.5d0,0.08d0,0.14d0,0.01d0,0.015d0,0.005d0,2*0.105d0,
823  &0.04d0,0.5d0,0.08d0,0.14d0,0.01d0,0.015d0,0.005d0,2*0.105d0,
824  &0.04d0,0.5d0,0.08d0,0.14d0,0.01d0,0.015d0,0.005d0,2*0.105d0,
825  &0.04d0,0.5d0,0.08d0,0.14d0,0.01d0,0.015d0,0.005d0,2*0.105d0,
826  &0.04d0,0.5d0,0.08d0,0.14d0,0.01d0,0.015d0,0.005d0,2*0.105d0/
827  DATA (brat(i) ,i=1382,1582)/0.04d0,0.5d0,0.08d0,0.14d0,0.01d0,
828  &0.015d0,0.005d0,2*0.105d0,0.04d0,0.5d0,0.08d0,0.14d0,0.01d0,
829  &0.015d0,0.005d0,2*0.105d0,0.04d0,0.5d0,0.08d0,0.14d0,0.01d0,
830  &0.015d0,0.005d0,2*0.105d0,0.04d0,0.5d0,0.08d0,0.14d0,0.01d0,
831  &0.015d0,0.005d0,2*0.105d0,0.04d0,0.5d0,0.08d0,0.14d0,0.01d0,
832  &0.015d0,0.005d0,2*0.105d0,0.04d0,0.5d0,0.08d0,0.14d0,0.01d0,
833  &0.015d0,0.005d0,2*0.105d0,0.04d0,0.5d0,0.08d0,0.14d0,0.01d0,
834  &0.015d0,0.005d0,2*0.105d0,0.04d0,0.5d0,0.08d0,0.14d0,0.01d0,
835  &0.015d0,0.005d0,4*1d0,0.52d0,0.26d0,0.11d0,2*0.055d0,0.333d0,
836  &0.334d0,0.333d0,0.667d0,0.333d0,0.28d0,0.14d0,0.313d0,0.157d0,
837  &0.11d0,0.667d0,0.333d0,0.28d0,0.14d0,0.313d0,0.157d0,0.11d0,
838  &0.36d0,0.18d0,0.03d0,2*0.015d0,2*0.2d0,4*0.25d0,0.667d0,0.333d0,
839  &0.667d0,0.333d0,0.667d0,0.333d0,0.667d0,0.333d0,4*0.5d0,0.007d0,
840  &0.993d0,1d0,0.667d0,0.333d0,0.667d0,0.333d0,0.667d0,0.333d0,
841  &0.667d0,0.333d0,8*0.5d0,0.02d0,0.98d0,1d0,4*0.5d0,3*0.146d0,
842  &3*0.05d0,0.15d0,2*0.05d0,4*0.024d0,0.066d0,0.667d0,0.333d0,
843  &0.667d0,0.333d0,4*0.25d0,0.667d0,0.333d0,0.667d0,0.333d0,2*0.5d0,
844  &0.273d0,0.727d0,0.667d0,0.333d0,0.667d0,0.333d0,4*0.5d0,0.35d0,
845  &0.65d0,2*0.0083d0,0.1866d0,0.324d0,0.184d0,0.027d0,0.001d0,
846  &0.093d0,0.087d0,0.078d0,0.0028d0,3*0.014d0,0.008d0,0.024d0/
847  DATA (brat(i) ,i=1583,4150)/0.008d0,0.024d0,0.425d0,0.02d0,
848  &0.185d0,0.088d0,0.043d0,0.067d0,0.066d0,2404*0d0,0.024396d0,
849  &0.045285d0,0.83119d0,2*0d0,0.000349d0,0.09878d0,0d0,0.019884d0,
850  &0.02341d0,0.362776d0,0.550787d0,2*0d0,0.000152d0,0.042991d0,
851  &0.013695d0,0.025421d0,0.466595d0,2*0d0,0.000196d0,0.055451d0,
852  &0.438642d0,0.445781d0,0d0,0.554219d0,4*0.00335d0,0.522257d0,
853  &0.464343d0,6*0d0,1d0,6*0d0,1d0,4*0.013853d0,0.562703d0,
854  &0.376702d0,0.00518d0,4*0.006254d0,0.974985d0,7*0d0,4*0.148299d0,
855  &0.015351d0,0d0,0.182109d0,0.167099d0,0.042247d0,0.850973d0,
856  &0.005411d0,0.045025d0,0.098591d0,0.849898d0,0.021617d0,
857  &0.030018d0,0.098466d0,0.294448d0,0.10945d0,0.596102d0,0.389906d0,
858  &0.610094d0,3*0.0633d0,0.063299d0,0.063295d0,0.056281d0,2*0d0,
859  &6*0.020495d0,2*0d0,0.327919d0,0.04099d0,0.045236d0,0.090112d0,
860  &0.19874d0,0.010204d0,0.000003d0,0.010205d0,0.198356d0,0.000151d0,
861  &0.000006d0,0.000367d0,0.081967d0,0.19874d0,0.010204d0,0.000003d0,
862  &0.010205d0,0.198356d0,0.000151d0,0.000006d0,0.000367d0,
863  &0.081967d0,4*0d0,0.198776d0,0.010206d0,0.000003d0,0.010207d0,
864  &0.19839d0,0.000151d0,0.000006d0,0.000367d0,0.081893d0,0.198776d0,
865  &0.010206d0,0.000003d0,0.010207d0,0.19839d0,0.000151d0,0.000006d0,
866  &0.000367d0,0.081893d0,4*0d0,0.199344d0,0.010234d0,0.000003d0/
867  DATA (brat(i) ,i=4151,4281)/0.010236d0,0.198928d0,0.000149d0,
868  &0.000006d0,0.000368d0,0.080733d0,0.199344d0,0.010234d0,
869  &0.000003d0,0.010236d0,0.198928d0,0.000149d0,0.000006d0,
870  &0.000368d0,0.080733d0,4*0d0,0.184738d0,0.104588d0,0.184738d0,
871  &0.104587d0,0.184731d0,0.09582d0,0.022902d0,0.008429d0,0.015602d0,
872  &0.022902d0,0.008429d0,0.015602d0,0.022902d0,0.008429d0,
873  &0.015602d0,0.28959d0,0.01487d0,0.000008d0,0.01487d0,0.289061d0,
874  &0.000492d0,0.000009d0,0.000536d0,0.27911d0,2*0.037151d0,
875  &0.03715d0,0.090266d0,2*0.001805d0,0.090266d0,0.001805d0,
876  &0.812263d0,0.00179d0,0.090428d0,0.001809d0,0.001808d0,0.090428d0,
877  &0.001808d0,0.81372d0,0d0,6*1d0,0.095602d0,2*0.338272d0,
878  &0.156896d0,0.019193d0,0.017993d0,0.001168d0,0.001462d0,
879  &0.009608d0,0.003306d0,0.002132d0,0.003127d0,0.002132d0,
880  &0.003127d0,0.00213d0,3*0d0,0.001411d0,0.00045d0,0.001411d0,
881  &0.00045d0,0.001411d0,0.00045d0,2*0d0,0.097996d0,0.399787d0,
882  &0.262464d0,0.185427d0,0.022683d0,0.007648d0,0.004259d0,
883  &0.005925d0,0.000304d0,2*0d0,0.000304d0,0.005914d0,0.000002d0,
884  &2*0d0,0.000011d0,0.001258d0,5*0d0,3*0.002005d0,0d0,0.272178d0,
885  &0.022112d0,0.255165d0,0.015534d0,2*0.108965d0,0.031557d0,
886  &0.005562d0,0.044965d0,0.004674d0,0.007637d0,0.020597d0/
887  DATA (brat(i) ,i=4282,8000)/0.007636d0,0.020595d0,0.007616d0,
888  &3*0d0,0.017298d0,0.004782d0,0.017298d0,0.004782d0,0.017297d0,
889  &0.004782d0,2*0d0,0.055332d0,2*0.319757d0,0.121576d0,2*0.001556d0,
890  &4*0d0,0.0277d0,0.021481d0,0.027699d0,0.021477d0,0.027658d0,3*0d0,
891  &0.006071d0,0.01208d0,0.006071d0,0.01208d0,0.006069d0,0.01208d0,
892  &2*0d0,0.035891d0,0.209476d0,0.129084d0,0.286631d0,0.10742d0,
893  &0.109486d0,4*0d0,0.035282d0,0.001812d0,2*0d0,0.001812d0,
894  &0.035215d0,0.000021d0,0d0,0.000001d0,0.000065d0,0.011965d0,5*0d0,
895  &2*0.011947d0,0.011946d0,0d0,
896  &649*0.d0,
897 C....UED
898  &0.001d0,0.999d0,0.001d0,0.999d0,0.001d0,0.999d0,
899  &0.001d0,0.999d0,0.001d0,0.999d0,0.001d0,0.999d0,
900  &0.33d0,0.66d0,0.01d0,0.33d0,0.66d0,0.01d0,0.33d0,0.66d0,0.01d0,
901  &0.33d0,0.66d0,0.01d0,0.98d0,0.d0,0.02d0,0.33d0,0.66d0,0.01d0,
902  &9*1.d0,
903  &24*0.0416667,
904  &1.,
905  &3*0.d0,6*0.08333d0,
906  &3*0.d0,6*0.08333d0,
907  &6*0.166667d0,
908  &2912*0.d0/
909  DATA (kfdp(i,1),i= 1, 377)/21,22,23,4*-24,25,21,22,23,4*24,25,
910  &21,22,23,4*-24,25,21,22,23,4*24,25,21,22,23,4*-24,25,21,22,23,
911  &4*24,25,37,1000022,1000023,1000025,1000035,1000021,1000039,21,22,
912  &23,4*-24,25,2*-37,21,22,23,4*24,25,2*37,22,23,-24,25,23,24,-12,
913  &22,23,-24,25,23,24,-12,-14,48*16,22,23,-24,25,23,24,22,23,-24,25,
914  &-37,23,24,37,1,2,3,4,5,6,7,8,21,1,2,3,4,5,6,7,8,11,13,15,17,1,2,
915  &3,4,5,6,7,8,11,12,13,14,15,16,17,18,4*-1,4*-3,4*-5,4*-7,-11,-13,
916  &-15,-17,1,2,3,4,5,6,7,8,11,13,15,17,21,2*22,23,24,1000022,
917  &2*1000023,3*1000025,4*1000035,2*1000024,2*1000037,1000001,
918  &2000001,1000001,-1000001,1000002,2000002,1000002,-1000002,
919  &1000003,2000003,1000003,-1000003,1000004,2000004,1000004,
920  &-1000004,1000005,2000005,1000005,-1000005,1000006,2000006,
921  &1000006,-1000006,1000011,2000011,1000011,-1000011,1000012,
922  &2000012,1000012,-1000012,1000013,2000013,1000013,-1000013,
923  &1000014,2000014,1000014,-1000014,1000015,2000015,1000015,
924  &-1000015,1000016,2000016,1000016,-1000016,1,2,3,4,5,6,7,8,11,12,
925  &13,14,15,16,17,18,24,37,2*23,25,35,4*-1,4*-3,4*-5,4*-7,-11,-13,
926  &-15,-17,3*24,1,2,3,4,5,6,7,8,11,13,15,17,21,2*22,23,24,23,25,24,
927  &37,23,25,36,1000022,2*1000023,3*1000025,4*1000035,2*1000024,
928  &2*1000037,1000001,2000001,1000001,-1000001,1000002,2000002/
929  DATA (kfdp(i,1),i= 378, 580)/1000002,-1000002,1000003,2000003,
930  &1000003,-1000003,1000004,2000004,1000004,-1000004,1000005,
931  &2000005,1000005,-1000005,1000006,2000006,1000006,-1000006,
932  &1000011,2000011,1000011,-1000011,1000012,2000012,1000012,
933  &-1000012,1000013,2000013,1000013,-1000013,1000014,2000014,
934  &1000014,-1000014,1000015,2000015,1000015,-1000015,1000016,
935  &2000016,1000016,-1000016,1,2,3,4,5,6,7,8,11,13,15,17,21,2*22,23,
936  &24,23,25,24,37,1000022,2*1000023,3*1000025,4*1000035,2*1000024,
937  &2*1000037,1000001,2000001,1000001,-1000001,1000002,2000002,
938  &1000002,-1000002,1000003,2000003,1000003,-1000003,1000004,
939  &2000004,1000004,-1000004,1000005,2000005,1000005,-1000005,
940  &1000006,2000006,1000006,-1000006,1000011,2000011,1000011,
941  &-1000011,1000012,2000012,1000012,-1000012,1000013,2000013,
942  &1000013,-1000013,1000014,2000014,1000014,-1000014,1000015,
943  &2000015,1000015,-1000015,1000016,2000016,1000016,-1000016,-1,-3,
944  &-5,-7,-11,-13,-15,-17,24,2*1000022,2*1000023,2*1000025,2*1000035,
945  &1000006,2000006,1000006,2000006,-1000001,-1000003,-1000011,
946  &-1000013,-1000015,-2000015,1,2,3,4,5,6,11,13,15,2,82,-11,-13,2*2,
947  &-12,-14,-16,2*-2,2*-4,-2,-4,2*22,211,111,221,13,11,213,-213,221,
948  &223,321,130,310,111,331,111,211,-12,12,-14,14,211,111,22,-13,-11/
949  DATA (kfdp(i,1),i= 581, 992)/2*211,213,113,221,223,321,211,331,
950  &22,111,211,2*22,211,22,111,211,22,211,221,111,11,211,111,2*211,
951  &321,130,310,221,111,211,111,130,310,321,2*311,321,311,323,313,
952  &323,313,321,3*311,-13,3*211,12,14,311,2*321,311,321,313,323,313,
953  &323,311,4*321,211,111,3*22,111,321,130,-213,113,213,211,22,111,
954  &11,13,211,321,130,310,221,211,111,11*-11,11*-13,-311,-313,-311,
955  &-313,-20313,2*-311,-313,-311,-313,2*111,2*221,2*331,2*113,2*223,
956  &2*333,-311,-313,2*-321,211,-311,-321,333,-311,-313,-321,211,
957  &2*-321,2*-311,-321,211,113,421,2*411,421,411,423,413,423,413,421,
958  &411,8*-11,8*-13,-321,-323,-321,-323,-311,2*-313,-311,-313,2*-311,
959  &-321,-10323,-321,-323,-321,-311,2*-313,211,111,333,3*-321,-311,
960  &-313,-321,-313,310,333,211,2*-321,-311,-313,-311,211,-321,3*-311,
961  &211,113,321,2*421,411,421,413,423,413,423,411,421,-15,5*-11,
962  &5*-13,221,331,333,221,331,333,10221,211,213,211,213,321,323,321,
963  &323,2212,221,331,333,221,2*2,2*431,421,411,423,413,82,11,13,82,
964  &443,82,6*12,6*14,2*16,3*-411,3*-413,2*-411,2*-413,2*441,2*443,
965  &2*20443,2*2,2*4,2,4,511,521,511,523,513,523,513,521,511,6*12,
966  &6*14,2*16,3*-421,3*-423,2*-421,2*-423,2*441,2*443,2*20443,2*2,
967  &2*4,2,4,521,511,521,513,523,513,523,511,521,6*12,6*14,2*16,
968  &3*-431,3*-433,2*-431,2*-433,3*441,3*443,3*20443,2*2,2*4,2,4,531/
969  DATA (kfdp(i,1),i= 993,1402)/521,511,523,513,16,2*4,2*12,2*14,
970  &2*16,4*2,4*4,2*-11,2*-13,2*-1,2*-3,2*-11,2*-13,2*-1,541,511,521,
971  &513,523,21,11,13,15,1,2,3,4,21,22,553,21,2112,2212,2*2112,2212,
972  &2112,2*2212,2112,-12,3122,3212,3112,2212,2*2112,-12,2*3122,3222,
973  &3112,2212,2112,2212,3122,3222,3212,3122,3112,-12,-14,-12,3322,
974  &3312,2*3122,3212,3322,3312,3122,3322,3312,-12,2*4122,7*-11,7*-13,
975  &2*2224,2*2212,2*2214,2*3122,2*3212,2*3214,5*3222,4*3224,2*3322,
976  &3324,2*2224,7*2212,5*2214,2*2112,2*2114,2*3122,2*3212,2*3214,
977  &2*3222,2*3224,4*2,3,2*2,1,2*2,-11,-13,2*2,4*4122,-11,-13,2*2,
978  &3*4132,3*4232,-11,-13,2*2,4332,-11,-13,2*2,-11,-13,2*2,-11,-13,
979  &2*2,-11,-13,2*2,-11,-13,2*2,-11,-13,2*2,-11,-13,2*2,2*5122,-12,
980  &-14,-16,5*4122,441,443,20443,2*-2,2*-4,-2,-4,-12,-14,-16,2*-2,
981  &2*-4,-2,-4,-12,-14,-16,2*-2,2*-4,-2,-4,4*5122,-12,-14,-16,2*-2,
982  &2*-4,-2,-4,-12,-14,-16,2*-2,2*-4,-2,-4,2*5132,2*5232,-12,-14,-16,
983  &2*-2,2*-4,-2,-4,5332,-12,-14,-16,2*-2,2*-4,-2,-4,-12,-14,-16,
984  &2*-2,2*-4,-2,-4,-12,-14,-16,2*-2,2*-4,-2,-4,-12,-14,-16,2*-2,
985  &2*-4,-2,-4,-12,-14,-16,2*-2,2*-4,-2,-4,-12,-14,-16,2*-2,2*-4,-2,
986  &-4,-12,-14,-16,2*-2,2*-4,-2,-4,-12,-14,-16,2*-2,2*-4,-2,-4,-12,
987  &-14,-16,2*-2,2*-4,-2,-4,-12,-14,-16,2*-2,2*-4,-2,-4,-12,-14,-16,
988  &2*-2,2*-4,-2,-4,-12,-14,-16,2*-2,2*-4,-2,-4,-12,-14,-16,2*-2/
989  DATA (kfdp(i,1),i=1403,1713)/2*-4,-2,-4,-12,-14,-16,2*-2,2*-4,-2,
990  &-4,-12,-14,-16,2*-2,2*-4,-2,-4,-12,-14,-16,2*-2,2*-4,-2,-4,-12,
991  &-14,-16,2*-2,2*-4,-2,-4,-12,-14,-16,2*-2,2*-4,-2,-4,221,223,221,
992  &223,211,111,321,130,310,213,113,-213,321,311,321,311,323,313,
993  &2*311,321,311,321,313,323,321,211,111,321,130,310,2*211,313,-313,
994  &323,-323,421,411,423,413,411,421,413,423,411,421,423,413,443,
995  &2*82,521,511,523,513,511,521,513,523,521,511,523,513,511,521,513,
996  &523,553,2*21,213,-213,113,213,10211,10111,-10211,2*221,213,2*113,
997  &-213,2*321,2*311,113,323,2*313,323,313,-313,323,-323,423,2*413,
998  &2*423,413,443,82,523,2*513,2*523,2*513,523,553,21,11,13,82,4*443,
999  &10441,20443,445,441,11,13,15,1,2,3,4,21,22,2*553,10551,20553,555,
1000  &1000039,-1000024,-1000037,1000022,1000023,1000025,1000035,
1001  &1000002,2000002,1000002,2000002,1000021,3*-12,3*-14,3*-16,12,11,
1002  &12,11,12,11,14,13,14,13,14,13,16,15,16,15,16,15,2*-2,2*-4,2*-6,
1003  &1000039,1000024,1000037,1000022,1000023,1000025,1000035,1000001,
1004  &2000001,1000001,2000001,1000021,3*-11,3*-13,3*-15,2*-1,-3,
1005  &1000039,-1000024,-1000037,1000022,1000023,1000025,1000035,
1006  &1000004,2000004,1000004,2000004,1000021,3*-12,3*-14,3*-16,12,11,
1007  &12,11,12,11,14,13,14,13,14,13,16,15,16,15,16,15,2*-2,2*-4,2*-6,
1008  &1000039,1000024,1000037,1000022,1000023,1000025,1000035,1000003/
1009  DATA (kfdp(i,1),i=1714,1984)/2000003,1000003,2000003,1000021,
1010  &3*-11,3*-13,3*-15,2*-1,-3,1000039,-1000024,-1000037,1000022,
1011  &1000023,1000025,1000035,1000006,2000006,1000006,2000006,1000021,
1012  &3*-12,3*-14,3*-16,12,11,12,11,12,11,14,13,14,13,14,13,16,15,16,
1013  &15,16,15,2*-2,2*-4,2*-6,1000039,1000024,1000037,1000022,1000023,
1014  &1000025,1000035,1000005,2000005,1000005,2000005,1000021,1000022,
1015  &1000016,-1000015,3*-11,3*-13,3*-15,2*-1,-3,1000039,-1000024,
1016  &-1000037,1000022,1000023,1000025,1000035,1000012,2000012,1000012,
1017  &2*12,2*14,2*16,3*-14,3*-16,3*-2,3*-4,3*-6,1000039,1000024,
1018  &1000037,1000022,1000023,1000025,1000035,1000011,2000011,1000011,
1019  &2000011,3*-13,3*-15,3*-1,3*-3,3*-5,1000039,-1000024,-1000037,
1020  &1000022,1000023,1000025,1000035,1000014,2000014,1000014,2000014,
1021  &2*12,2*14,2*16,3*-12,3*-16,3*-2,3*-4,3*-6,1000039,1000024,
1022  &1000037,1000022,1000023,1000025,1000035,1000013,2000013,1000013,
1023  &2000013,3*-11,3*-15,3*-1,3*-3,3*-5,1000039,-1000024,-1000037,
1024  &1000022,1000023,1000025,1000035,1000016,2000016,1000016,2000016,
1025  &2*12,2*14,2*16,3*-12,3*-14,3*-2,3*-4,3*-6,1000039,1000024,
1026  &1000037,1000022,1000023,1000025,1000035,1000015,2000015,1000015,
1027  &2000015,3*-11,3*-13,3*-1,3*-3,3*-5,1000039,1000001,-1000001,
1028  &2000001,-2000001,1000002,-1000002,2000002,-2000002,1000003/
1029  DATA (kfdp(i,1),i=1985,2321)/-1000003,2000003,-2000003,1000004,
1030  &-1000004,2000004,-2000004,1000005,-1000005,2000005,-2000005,
1031  &1000006,-1000006,2000006,-2000006,6*1000022,6*1000023,6*1000025,
1032  &6*1000035,1000024,-1000024,1000024,-1000024,1000024,-1000024,
1033  &1000037,-1000037,1000037,-1000037,1000037,-1000037,-12,12,-11,11,
1034  &-12,12,-11,11,-12,12,-11,11,-12,12,-11,11,-12,12,-11,11,-12,12,
1035  &-11,11,-12,12,-11,11,-12,12,-11,11,-12,12,-11,11,-14,14,-13,13,
1036  &-14,14,-13,13,-14,14,-13,13,-14,14,-13,13,-14,14,-13,13,-14,14,
1037  &-13,13,-14,14,-13,13,-14,14,-13,13,-14,14,-13,13,-16,16,-15,15,
1038  &-16,16,-15,15,-16,16,-15,15,-16,16,-15,15,-16,16,-15,15,-16,16,
1039  &-15,15,-16,16,-15,15,-16,16,-15,15,-16,16,-15,15,-2,2,-2,2,-2,2,
1040  &-4,4,-4,4,-4,4,-6,6,-6,6,-6,6,5*1000039,4,1,-12,12,-12,12,-12,12,
1041  &-12,12,-12,12,-12,12,-14,14,-14,14,-14,14,-14,14,-14,14,-14,14,
1042  &-16,16,-16,16,-16,16,-16,16,-16,16,-16,16,-12,12,-11,11,-12,12,
1043  &-11,11,-12,12,-11,11,-12,12,-11,11,-12,12,-11,11,-12,12,-11,11,
1044  &-12,12,-11,11,-12,12,-11,11,-12,12,-11,11,-14,14,-13,13,-14,14,
1045  &-13,13,-14,14,-13,13,-14,14,-13,13,-14,14,-13,13,-14,14,-13,13,
1046  &-14,14,-13,13,-14,14,-13,13,-14,14,-13,13,-16,16,-15,15,-16,16,
1047  &-15,15,-16,16,-15,15,-16,16,-15,15,-16,16,-15,15,-16,16,-15,15,
1048  &-16,16,-15,15,-16,16,-15,15,-16,16,-15,15,-2,2,-2,2,-2,2,-4,4,-4/
1049  DATA (kfdp(i,1),i=2322,2573)/4,-4,4,-6,6,-6,6,-6,6,5*1000039,
1050  &16*1000022,1000024,-1000024,1000024,-1000024,1000024,-1000024,
1051  &1000024,-1000024,1000024,-1000024,1000024,-1000024,1000037,
1052  &-1000037,1000037,-1000037,1000037,-1000037,1000037,-1000037,
1053  &1000037,-1000037,1000037,-1000037,1000024,-1000024,1000037,
1054  &-1000037,1000001,-1000001,2000001,-2000001,1000002,-1000002,
1055  &2000002,-2000002,1000003,-1000003,2000003,-2000003,1000004,
1056  &-1000004,2000004,-2000004,1000005,-1000005,2000005,-2000005,
1057  &1000006,-1000006,2000006,-2000006,1000011,-1000011,2000011,
1058  &-2000011,1000012,-1000012,2000012,-2000012,1000013,-1000013,
1059  &2000013,-2000013,1000014,-1000014,2000014,-2000014,1000015,
1060  &-1000015,2000015,-2000015,1000016,-1000016,2000016,-2000016,
1061  &5*1000021,-12,12,-12,12,-12,12,-12,12,-12,12,-12,12,-14,14,-14,
1062  &14,-14,14,-14,14,-14,14,-14,14,-16,16,-16,16,-16,16,-16,16,-16,
1063  &16,-16,16,-12,12,-11,11,-12,12,-11,11,-12,12,-11,11,-12,12,-11,
1064  &11,-12,12,-11,11,-12,12,-11,11,-12,12,-11,11,-12,12,-11,11,-12,
1065  &12,-11,11,-14,14,-13,13,-14,14,-13,13,-14,14,-13,13,-14,14,-13,
1066  &13,-14,14,-13,13,-14,14,-13,13,-14,14,-13,13,-14,14,-13,13,-14,
1067  &14,-13,13,-16,16,-15,15,-16,16,-15,15,-16,16,-15,15,-16,16,-15,
1068  &15,-16,16,-15,15,-16,16,-15,15,-16,16,-15,15,-16,16,-15,15,-16/
1069  DATA (kfdp(i,1),i=2574,2892)/16,-15,15,-2,2,-2,2,-2,2,-4,4,-4,4,
1070  &-4,4,-6,6,-6,6,-6,6,2*1000039,6*1000022,6*1000023,6*1000025,
1071  &6*1000035,1000022,1000023,1000025,1000035,1000002,2000002,
1072  &-1000001,-2000001,1000004,2000004,-1000003,-2000003,1000006,
1073  &2000006,-1000005,-2000005,1000012,2000012,-1000011,-2000011,
1074  &1000014,2000014,-1000013,-2000013,1000016,2000016,-1000015,
1075  &-2000015,2*1000021,-12,12,-11,-12,12,-11,-12,12,-11,-12,12,-11,
1076  &-12,12,-11,-12,12,-11,-14,-13,-14,-13,-14,-13,-14,14,-13,-14,14,
1077  &-13,-14,14,-13,-16,-15,-16,-15,-16,-15,-16,-15,-16,-15,-16,-15,
1078  &-12,2*-11,12,-12,2*-11,12,-12,2*-11,12,-12,2*-11,12,-12,2*-11,12,
1079  &-12,2*-11,12,-12,2*-11,12,-12,2*-11,12,-12,2*-11,12,-14,2*-13,14,
1080  &-14,2*-13,14,-14,2*-13,14,-14,2*-13,14,-14,2*-13,14,-14,2*-13,14,
1081  &-14,2*-13,14,-14,2*-13,14,-14,2*-13,14,-16,2*-15,16,-16,2*-15,16,
1082  &-16,2*-15,16,-16,2*-15,16,-16,2*-15,16,-16,2*-15,16,-16,2*-15,16,
1083  &-16,2*-15,16,-16,2*-15,16,2,-1,2,-1,2*2,-1,2,-1,3*2,-1,2*4,-3,
1084  &3*4,-3,2*6,5*1000039,16*1000022,16*1000023,1000024,-1000024,
1085  &1000024,-1000024,1000024,-1000024,1000024,-1000024,1000024,
1086  &-1000024,1000024,-1000024,1000037,-1000037,1000037,-1000037,
1087  &1000037,-1000037,1000037,-1000037,1000037,-1000037,1000037,
1088  &-1000037,1000024,-1000024,1000037,-1000037,1000001,-1000001/
1089  DATA (kfdp(i,1),i=2893,3182)/2000001,-2000001,1000002,-1000002,
1090  &2000002,-2000002,1000003,-1000003,2000003,-2000003,1000004,
1091  &-1000004,2000004,-2000004,1000005,-1000005,2000005,-2000005,
1092  &1000006,-1000006,2000006,-2000006,1000011,-1000011,2000011,
1093  &-2000011,1000012,-1000012,2000012,-2000012,1000013,-1000013,
1094  &2000013,-2000013,1000014,-1000014,2000014,-2000014,1000015,
1095  &-1000015,2000015,-2000015,1000016,-1000016,2000016,-2000016,
1096  &5*1000021,-12,12,-12,12,-12,12,-12,12,-12,12,-12,12,-14,14,-14,
1097  &14,-14,14,-14,14,-14,14,-14,14,-16,16,-16,16,-16,16,-16,16,-16,
1098  &16,-16,16,-12,12,-11,11,-12,12,-11,11,-12,12,-11,11,-12,12,-11,
1099  &11,-12,12,-11,11,-12,12,-11,11,-12,12,-11,11,-12,12,-11,11,-12,
1100  &12,-11,11,-14,14,-13,13,-14,14,-13,13,-14,14,-13,13,-14,14,-13,
1101  &13,-14,14,-13,13,-14,14,-13,13,-14,14,-13,13,-14,14,-13,13,-14,
1102  &14,-13,13,-16,16,-15,15,-16,16,-15,15,-16,16,-15,15,-16,16,-15,
1103  &15,-16,16,-15,15,-16,16,-15,15,-16,16,-15,15,-16,16,-15,15,-16,
1104  &16,-15,15,-2,2,-2,2,-2,2,-4,4,-4,4,-4,4,-6,6,-6,6,-6,6,5*1000039,
1105  &16*1000022,16*1000023,16*1000025,1000024,-1000024,1000024,
1106  &-1000024,1000024,-1000024,1000024,-1000024,1000024,-1000024,
1107  &1000024,-1000024,1000037,-1000037,1000037,-1000037,1000037,
1108  &-1000037,1000037,-1000037,1000037,-1000037,1000037,-1000037/
1109  DATA (kfdp(i,1),i=3183,3459)/1000024,-1000024,1000037,-1000037,
1110  &1000001,-1000001,2000001,-2000001,1000002,-1000002,2000002,
1111  &-2000002,1000003,-1000003,2000003,-2000003,1000004,-1000004,
1112  &2000004,-2000004,1000005,-1000005,2000005,-2000005,1000006,
1113  &-1000006,2000006,-2000006,1000011,-1000011,2000011,-2000011,
1114  &1000012,-1000012,2000012,-2000012,1000013,-1000013,2000013,
1115  &-2000013,1000014,-1000014,2000014,-2000014,1000015,-1000015,
1116  &2000015,-2000015,1000016,-1000016,2000016,-2000016,5*1000021,-12,
1117  &12,-12,12,-12,12,-12,12,-12,12,-12,12,-14,14,-14,14,-14,14,-14,
1118  &14,-14,14,-14,14,-16,16,-16,16,-16,16,-16,16,-16,16,-16,16,-12,
1119  &12,-11,11,-12,12,-11,11,-12,12,-11,11,-12,12,-11,11,-12,12,-11,
1120  &11,-12,12,-11,11,-12,12,-11,11,-12,12,-11,11,-12,12,-11,11,-14,
1121  &14,-13,13,-14,14,-13,13,-14,14,-13,13,-14,14,-13,13,-14,14,-13,
1122  &13,-14,14,-13,13,-14,14,-13,13,-14,14,-13,13,-14,14,-13,13,-16,
1123  &16,-15,15,-16,16,-15,15,-16,16,-15,15,-16,16,-15,15,-16,16,-15,
1124  &15,-16,16,-15,15,-16,16,-15,15,-16,16,-15,15,-16,16,-15,15,-2,2,
1125  &-2,2,-2,2,-4,4,-4,4,-4,4,-6,6,-6,6,-6,6,2*1000039,15*1000024,
1126  &6*1000022,6*1000023,6*1000025,6*1000035,1000022,1000023,1000025,
1127  &1000035,1000002,2000002,-1000001,-2000001,1000004,2000004,
1128  &-1000003,-2000003,1000006,2000006,-1000005,-2000005,1000012/
1129  DATA (kfdp(i,1),i=3460,3782)/2000012,-1000011,-2000011,1000014,
1130  &2000014,-1000013,-2000013,1000016,2000016,-1000015,-2000015,
1131  &2*1000021,-12,12,-11,-12,12,-11,-12,12,-11,-12,12,-11,-12,12,-11,
1132  &-12,12,-11,-14,14,-13,-14,14,-13,-14,14,-13,-14,14,-13,-14,14,
1133  &-13,-14,14,-13,-16,16,-15,-16,16,-15,-16,16,-15,-16,16,-15,-16,
1134  &16,-15,-16,16,-15,-12,2*-11,12,-12,2*-11,12,-12,2*-11,12,-12,
1135  &2*-11,12,-12,2*-11,12,-12,2*-11,12,-12,2*-11,12,-12,2*-11,12,-12,
1136  &2*-11,12,-14,2*-13,14,-14,2*-13,14,-14,2*-13,14,-14,2*-13,14,-14,
1137  &2*-13,14,-14,2*-13,14,-14,2*-13,14,-14,2*-13,14,-14,2*-13,14,-16,
1138  &2*-15,16,-16,2*-15,16,-16,2*-15,16,-16,2*-15,16,-16,2*-15,16,-16,
1139  &2*-15,16,-16,2*-15,16,-16,2*-15,16,-16,2*-15,16,2,-1,2,-1,2*2,-1,
1140  &2,-1,3*2,-1,2*4,-3,3*4,-3,2*6,1000039,-1000024,-1000037,1000022,
1141  &1000023,1000025,1000035,4*1000001,1000002,2000002,1000002,
1142  &2000002,1000021,3*-12,3*-14,3*-16,12,11,12,11,12,11,14,13,14,13,
1143  &14,13,16,15,16,15,16,15,2*-2,2*-4,2*-6,1000039,1000024,1000037,
1144  &1000022,1000023,1000025,1000035,4*1000002,1000001,2000001,
1145  &1000001,2000001,1000021,3*-11,3*-13,3*-15,2*-1,-3,1000039,
1146  &-1000024,-1000037,1000022,1000023,1000025,1000035,4*1000003,
1147  &1000004,2000004,1000004,2000004,1000021,3*-12,3*-14,3*-16,12,11,
1148  &12,11,12,11,14,13,14,13,14,13,16,15,16,15,16,15,2*-2,2*-4,2*-6/
1149  DATA (kfdp(i,1),i=3783,4156)/1000039,1000024,1000037,1000022,
1150  &1000023,1000025,1000035,4*1000004,1000003,2000003,1000003,
1151  &2000003,1000021,3*-11,3*-13,3*-15,2*-1,-3,1000039,-1000024,
1152  &-1000037,1000022,1000023,1000025,1000035,4*1000005,1000006,
1153  &2000006,1000006,2000006,1000021,3*-12,3*-14,3*-16,12,11,12,11,12,
1154  &11,14,13,14,13,14,13,16,15,16,15,16,15,2*-2,2*-4,2*-6,1000039,
1155  &1000024,1000037,1000022,1000023,1000025,1000035,4*1000006,
1156  &1000005,2000005,1000005,2000005,1000021,3*-11,3*-13,3*-15,2*-1,
1157  &-3,1000039,-1000024,-1000037,1000022,1000023,1000025,1000035,
1158  &4*1000011,1000012,2000012,1000012,2000012,2*12,2*14,2*16,3*-14,
1159  &3*-16,3*-2,3*-4,3*-6,1000039,-1000024,-1000037,1000022,1000023,
1160  &1000025,1000035,4*1000013,1000014,2000014,1000014,2000014,2*12,
1161  &2*14,2*16,3*-12,3*-16,3*-2,3*-4,3*-6,1000039,-1000024,-1000037,
1162  &1000022,1000023,1000025,1000035,4*1000015,1000016,2000016,
1163  &1000016,2000016,2*12,2*14,2*16,3*-12,3*-14,3*-2,3*-4,3*-6,3,4,5,
1164  &6,11,13,15,21,2*4,2,4,24,-11,-13,-15,3,4,5,6,11,13,15,21,5,6,21,
1165  &1,2,3,4,5,6,1,2,3,4,5,6,21,1,2,3,4,5,6,21,1,2,3,4,5,6,21,1,2,3,4,
1166  &5,6,1,2,3,4,5,6,1,2,3,4,5,6,21,3100111,3200111,21,22,23,-24,21,
1167  &22,23,24,22,23,-24,23,24,1,2,3,4,5,6,7,8,11,12,13,14,15,16,17,18,
1168  &21,22,23,24,9*11,9*-11,11,-11,11,-11,9*13,9*-13,13,-13,13,-13,
1169  &9*15/
1170  DATA (kfdp(i,1),i=4157,8000)/9*-15,15,-15,15,-15,1,2,3,4,5,6,11,
1171  &12,9900012,13,14,9900014,15,16,9900016,3*-1,3*-3,3*-5,-11,-13,-15,
1172  &3*-11,2*-13,-15,24,3*-11,2*-13,-15,9900024,3*443,3*553,2*24,
1173  &2*3000211,2*22,2*23,22,23,1,2,3,4,5,6,7,8,11,12,13,14,15,16,17,
1174  &18,2*24,3*3000211,2*24,4*-1,4*-3,4*-5,4*-7,-11,-13,-15,-17,22,23,
1175  &22,23,24,3000211,24,3000211,22,23,1,2,3,4,5,6,7,8,11,12,13,14,15,
1176  &16,17,18,2*24,-24,23,2*22,24,-24,2*23,1,2,3,4,5,6,7,8,11,12,13,
1177  &14,15,16,17,18,2*22,23,2*24,23,22,2*24,23,4*-1,4*-3,4*-5,4*-7,
1178  &-11,-13,-15,-17,
1179  &649*0,
1180 C...UED
1181  &5100023,5100022,5100023,5100022,5100023,5100022,
1182  &5100023,5100022,5100023,5100022,5100023,5100022,
1183  &5100023,-5100024,5100022,5100023,5100024,5100022,
1184  &5100023,-5100024,5100022,5100023,5100024,5100022,
1185  &5100023,-5100024,5100022,5100023,5100024,5100022,
1186  &9*5100022,
1187  &6100001,6100002,6100003,6100004,6100005,6100006,
1188  &5100001,5100002,5100003,5100004,5100005,5100006,
1189  &-6100001,-6100002,-6100003,-6100004,-6100005,-6100006,
1190  &-5100001,-5100002,-5100003,-5100004,-5100005,-5100006,
1191  &39,
1192  &6100011,6100013,6100015,
1193  &5100011,5100013,5100015,
1194  %5100012,5100014,5100016,
1195  &-6100011,-6100013,-6100015,
1196  &-5100011,-5100013,-5100015,
1197  %-5100012,-5100014,-5100016,
1198  &-5100011,-5100013,-5100015,
1199  &5100012,5100014,5100016,
1200  &2912*0/
1201  DATA (kfdp(i,2),i= 1, 339)/3*1,2,4,6,8,1,3*2,1,3,5,7,2,3*3,2,4,
1202  &6,8,3,3*4,1,3,5,7,4,3*5,2,4,6,8,5,3*6,1,3,5,7,6,5,6*1000006,3*7,
1203  &2,4,6,8,7,4,6,3*8,1,3,5,7,8,5,7,2*11,12,11,12,2*11,2*13,14,13,14,
1204  &13,11,13,-211,-213,-211,-213,-211,-213,-211,-213,2*-211,-321,
1205  &-323,-321,2*-323,3*-321,4*-211,-213,-211,-213,-211,-213,-211,
1206  &-213,-211,-213,3*-211,-213,4*-211,-323,-321,2*-211,2*-321,3*-211,
1207  &2*15,16,15,16,15,2*17,18,17,2*18,2*17,-1,-2,-3,-4,-5,-6,-7,-8,21,
1208  &-1,-2,-3,-4,-5,-6,-7,-8,-11,-13,-15,-17,-1,-2,-3,-4,-5,-6,-7,-8,
1209  &-11,-12,-13,-14,-15,-16,-17,-18,2,4,6,8,2,4,6,8,2,4,6,8,2,4,6,8,
1210  &12,14,16,18,-1,-2,-3,-4,-5,-6,-7,-8,-11,-13,-15,-17,21,22,2*23,
1211  &-24,2*1000022,1000023,1000022,1000023,1000025,1000022,1000023,
1212  &1000025,1000035,-1000024,-1000037,-1000024,-1000037,-1000001,
1213  &2*-2000001,2000001,-1000002,2*-2000002,2000002,-1000003,
1214  &2*-2000003,2000003,-1000004,2*-2000004,2000004,-1000005,
1215  &2*-2000005,2000005,-1000006,2*-2000006,2000006,-1000011,
1216  &2*-2000011,2000011,-1000012,2*-2000012,2000012,-1000013,
1217  &2*-2000013,2000013,-1000014,2*-2000014,2000014,-1000015,
1218  &2*-2000015,2000015,-1000016,2*-2000016,2000016,-1,-2,-3,-4,-5,-6,
1219  &-7,-8,-11,-12,-13,-14,-15,-16,-17,-18,-24,-37,22,25,2*36,2,4,6,8,
1220  &2,4,6,8,2,4,6,8,2,4,6,8,12,14,16,18,23,22,25,-1,-2,-3,-4,-5,-6/
1221  DATA (kfdp(i,2),i= 340, 533)/-7,-8,-11,-13,-15,-17,21,22,2*23,
1222  &-24,2*25,-37,-24,3*36,2*1000022,1000023,1000022,1000023,1000025,
1223  &1000022,1000023,1000025,1000035,-1000024,-1000037,-1000024,
1224  &-1000037,-1000001,2*-2000001,2000001,-1000002,2*-2000002,2000002,
1225  &-1000003,2*-2000003,2000003,-1000004,2*-2000004,2000004,-1000005,
1226  &2*-2000005,2000005,-1000006,2*-2000006,2000006,-1000011,
1227  &2*-2000011,2000011,-1000012,2*-2000012,2000012,-1000013,
1228  &2*-2000013,2000013,-1000014,2*-2000014,2000014,-1000015,
1229  &2*-2000015,2000015,-1000016,2*-2000016,2000016,-1,-2,-3,-4,-5,-6,
1230  &-7,-8,-11,-13,-15,-17,21,22,2*23,-24,2*25,-37,-24,2*1000022,
1231  &1000023,1000022,1000023,1000025,1000022,1000023,1000025,1000035,
1232  &-1000024,-1000037,-1000024,-1000037,-1000001,2*-2000001,2000001,
1233  &-1000002,2*-2000002,2000002,-1000003,2*-2000003,2000003,-1000004,
1234  &2*-2000004,2000004,-1000005,2*-2000005,2000005,-1000006,
1235  &2*-2000006,2000006,-1000011,2*-2000011,2000011,-1000012,
1236  &2*-2000012,2000012,-1000013,2*-2000013,2000013,-1000014,
1237  &2*-2000014,2000014,-1000015,2*-2000015,2000015,-1000016,
1238  &2*-2000016,2000016,2,4,6,8,12,14,16,18,25,1000024,1000037,
1239  &1000024,1000037,1000024,1000037,1000024,1000037,2*-1000005,
1240  &2*-2000005,1000002,1000004,1000012,1000014,2*1000016,-3,-4,-5,-6/
1241  DATA (kfdp(i,2),i= 534, 938)/-7,-8,-13,-15,-17,11,-82,12,14,-1,
1242  &-3,11,13,15,1,4,3,4,1,3,22,11,-211,2*22,-13,-11,-211,211,111,211,
1243  &-321,130,310,22,2*111,-211,11,-11,13,-13,-211,111,22,14,12,111,
1244  &22,111,3*211,-311,22,211,22,111,-211,211,11,-211,13,22,-211,111,
1245  &-211,22,111,-11,-211,111,2*-211,-321,130,310,221,111,-211,111,
1246  &2*0,-211,111,22,-211,111,-211,111,-211,211,-213,113,223,221,14,
1247  &111,211,111,-11,-13,211,111,22,211,111,211,111,2*211,213,113,223,
1248  &221,22,-211,111,113,223,22,111,-321,310,211,111,2*-211,221,22,
1249  &-11,-13,-211,-321,130,310,221,-211,111,11*12,11*14,2*211,2*213,
1250  &211,20213,2*321,2*323,211,213,211,213,211,213,211,213,211,213,
1251  &211,213,3*211,213,211,2*321,8*211,2*113,3*211,111,22,211,111,211,
1252  &111,4*211,8*12,8*14,2*211,2*213,2*111,221,2*113,223,333,20213,
1253  &211,2*321,323,2*311,313,-211,111,113,2*211,321,2*211,311,321,310,
1254  &211,-211,4*211,321,4*211,113,2*211,-321,111,22,-211,111,-211,111,
1255  &-211,211,-211,211,16,5*12,5*14,3*211,3*213,211,2*111,2*113,
1256  &2*-311,2*-313,-2112,3*321,323,2*-1,22,111,321,311,321,311,-82,
1257  &-11,-13,-82,22,-82,6*-11,6*-13,2*-15,211,213,20213,211,213,20213,
1258  &431,433,431,433,311,313,311,313,311,313,-1,-4,-3,-4,-1,-3,22,
1259  &-211,111,-211,111,-211,211,-211,211,6*-11,6*-13,2*-15,211,213,
1260  &20213,211,213,20213,431,433,431,433,321,323,321,323,321,323,-1/
1261  DATA (kfdp(i,2),i= 939,1352)/-4,-3,-4,-1,-3,22,211,111,211,111,
1262  &4*211,6*-11,6*-13,2*-15,211,213,20213,211,213,20213,431,433,431,
1263  &433,221,331,333,221,331,333,221,331,333,-1,-4,-3,-4,-1,-3,22,
1264  &-321,-311,-321,-311,-15,-3,-1,2*-11,2*-13,2*-15,-1,-4,-3,-4,-3,
1265  &-4,-1,-4,2*12,2*14,2,3,2,3,2*12,2*14,2,1,22,411,421,411,421,21,
1266  &-11,-13,-15,-1,-2,-3,-4,2*21,22,21,2*-211,111,22,111,211,22,211,
1267  &-211,11,2*-211,111,-211,111,22,11,22,111,-211,211,111,211,22,211,
1268  &111,211,-211,22,11,13,11,-211,2*111,2*22,111,211,-321,-211,111,
1269  &11,2*-211,7*12,7*14,-321,-323,-311,-313,-311,-313,211,213,211,
1270  &213,211,213,111,221,331,113,223,111,221,113,223,321,323,321,-211,
1271  &-213,111,221,331,113,223,333,10221,111,221,331,113,223,211,213,
1272  &211,213,321,323,321,323,321,323,311,313,311,313,2*-1,-3,-1,2203,
1273  &3201,3203,2203,2101,2103,12,14,-1,-3,2*111,2*211,12,14,-1,-3,22,
1274  &111,2*22,111,22,12,14,-1,-3,22,12,14,-1,-3,12,14,-1,-3,12,14,-1,
1275  &-3,12,14,-1,-3,12,14,-1,-3,12,14,-1,-3,12,14,-1,-3,2*-211,11,13,
1276  &15,-211,-213,-20213,-431,-433,3*3122,1,4,3,4,1,3,11,13,15,1,4,3,
1277  &4,1,3,11,13,15,1,4,3,4,1,3,2*111,2*211,11,13,15,1,4,3,4,1,3,11,
1278  &13,15,1,4,3,4,1,3,4*22,11,13,15,1,4,3,4,1,3,22,11,13,15,1,4,3,4,
1279  &1,3,11,13,15,1,4,3,4,1,3,11,13,15,1,4,3,4,1,3,11,13,15,1,4,3,4,1,
1280  &3,11,13,15,1,4,3,4,1,3,11,13,15,1,4,3,4,1,3,11,13,15,1,4,3,4,1,3/
1281  DATA (kfdp(i,2),i=1353,1815)/11,13,15,1,4,3,4,1,3,11,13,15,1,4,3,
1282  &4,1,3,11,13,15,1,4,3,4,1,3,11,13,15,1,4,3,4,1,3,11,13,15,1,4,3,4,
1283  &1,3,11,13,15,1,4,3,4,1,3,11,13,15,1,4,3,4,1,3,11,13,15,1,4,3,4,1,
1284  &3,11,13,15,1,4,3,4,1,3,11,13,15,1,4,3,4,1,3,11,13,15,1,4,3,4,1,3,
1285  &2*111,2*211,-211,111,-321,130,310,-211,111,211,-211,111,-213,113,
1286  &-211,111,223,211,111,213,113,211,111,223,-211,111,-321,130,310,
1287  &2*-211,-311,311,-321,321,211,111,211,111,-211,111,-211,111,311,
1288  &2*321,311,22,2*-82,-211,111,-211,111,211,111,211,111,-321,-311,
1289  &-321,-311,411,421,411,421,22,2*21,-211,2*211,111,-211,111,2*211,
1290  &111,-211,211,111,211,-321,2*-311,-321,22,-211,111,211,111,-311,
1291  &311,-321,321,211,111,-211,111,321,311,22,-82,-211,111,211,111,
1292  &-321,-311,411,421,22,21,-11,-13,-82,211,111,221,111,4*22,-11,-13,
1293  &-15,-1,-2,-3,-4,2*21,211,111,3*22,1,2*2,4*1,2*-24,2*-37,2*1,3,5,
1294  &1,3,5,1,3,5,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6,-3,-5,-3,-5,-3,
1295  &-5,2,2*1,4*2,2*24,2*37,2,1,3,5,1,3,5,1,3,5,-3,2*-5,3,2*4,4*3,
1296  &2*-24,2*-37,3,1,3,5,1,3,5,1,3,5,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,
1297  &5,6,-1,-5,-1,-5,-1,-5,4,2*3,4*4,2*24,2*37,4,1,3,5,1,3,5,1,3,5,-3,
1298  &2*-5,5,2*6,4*5,2*-24,2*-37,5,1,3,5,1,3,5,1,3,5,1,2,3,4,5,6,1,2,3,
1299  &4,5,6,1,2,3,4,5,6,-1,-3,-1,-3,-1,-3,6,2*5,4*6,2*24,2*37,6,4,-15,
1300  &16,1,3,5,1,3,5,1,3,5,-3,2*-5,11,2*12,4*11,2*-24,-37,13,15,11,15/
1301  DATA (kfdp(i,2),i=1816,2317)/11,13,11,13,15,11,13,15,1,3,5,1,3,5,
1302  &1,3,5,12,2*11,4*12,2*24,2*37,11,13,15,11,13,15,1,3,5,1,3,5,1,3,5,
1303  &13,2*14,4*13,2*-24,2*-37,13,15,11,15,11,13,11,13,15,11,13,15,1,3,
1304  &5,1,3,5,1,3,5,14,2*13,4*14,2*24,2*37,11,13,15,11,13,15,1,3,5,1,3,
1305  &5,1,3,5,15,2*16,4*15,2*-24,2*-37,13,15,11,15,11,13,11,13,15,11,
1306  &13,15,1,3,5,1,3,5,1,3,5,16,2*15,4*16,2*24,2*37,11,13,15,11,13,15,
1307  &1,3,5,1,3,5,1,3,5,21,-1,1,-1,1,-2,2,-2,2,-3,3,-3,3,-4,4,-4,4,-5,
1308  &5,-5,5,-6,6,-6,6,1,3,5,2,4,6,1,3,5,2,4,6,1,3,5,2,4,6,1,3,5,2,4,6,
1309  &1,-1,3,-3,5,-5,1,-1,3,-3,5,-5,-1,1,-2,2,-1,1,-2,2,-1,1,-2,2,-3,3,
1310  &-4,4,-3,3,-4,4,-3,3,-4,4,-5,5,-6,6,-5,5,-6,6,-5,5,-6,6,-1,1,-2,2,
1311  &-1,1,-2,2,-1,1,-2,2,-3,3,-4,4,-3,3,-4,4,-3,3,-4,4,-5,5,-6,6,-5,5,
1312  &-6,6,-5,5,-6,6,-1,1,-2,2,-1,1,-2,2,-1,1,-2,2,-3,3,-4,4,-3,3,-4,4,
1313  &-3,3,-4,4,-5,5,-6,6,-5,5,-6,6,-5,5,-6,6,-1,1,-1,1,-3,3,-1,1,-1,1,
1314  &-3,3,-1,1,-1,1,-3,3,22,23,25,35,36,-1,-3,-13,13,-13,13,-13,13,
1315  &-15,15,-15,15,-15,15,-11,11,-11,11,-11,11,-15,15,-15,15,-15,15,
1316  &-11,11,-11,11,-11,11,-13,13,-13,13,-13,13,-1,1,-2,2,-1,1,-2,2,-1,
1317  &1,-2,2,-3,3,-4,4,-3,3,-4,4,-3,3,-4,4,-5,5,-6,6,-5,5,-6,6,-5,5,-6,
1318  &6,-1,1,-2,2,-1,1,-2,2,-1,1,-2,2,-3,3,-4,4,-3,3,-4,4,-3,3,-4,4,-5,
1319  &5,-6,6,-5,5,-6,6,-5,5,-6,6,-1,1,-2,2,-1,1,-2,2,-1,1,-2,2,-3,3,-4,
1320  &4,-3,3,-4,4,-3,3,-4,4,-5,5,-6,6,-5,5,-6,6,-5,5,-6,6,-1,1,-1,1,-3/
1321  DATA (kfdp(i,2),i=2318,2770)/3,-1,1,-1,1,-3,3,-1,1,-1,1,-3,3,22,
1322  &23,25,35,36,22,23,11,13,15,12,14,16,1,3,5,2,4,25,35,36,-24,24,11,
1323  &-11,13,-13,15,-15,1,-1,3,-3,-24,24,11,-11,13,-13,15,-15,1,-1,3,
1324  &-3,-37,37,-37,37,-1,1,-1,1,-2,2,-2,2,-3,3,-3,3,-4,4,-4,4,-5,5,-5,
1325  &5,-6,6,-6,6,-11,11,-11,11,-12,12,-12,12,-13,13,-13,13,-14,14,-14,
1326  &14,-15,15,-15,15,-16,16,-16,16,1,3,5,2,4,-13,13,-13,13,-13,13,
1327  &-15,15,-15,15,-15,15,-11,11,-11,11,-11,11,-15,15,-15,15,-15,15,
1328  &-11,11,-11,11,-11,11,-13,13,-13,13,-13,13,-1,1,-2,2,-1,1,-2,2,-1,
1329  &1,-2,2,-3,3,-4,4,-3,3,-4,4,-3,3,-4,4,-5,5,-6,6,-5,5,-6,6,-5,5,-6,
1330  &6,-1,1,-2,2,-1,1,-2,2,-1,1,-2,2,-3,3,-4,4,-3,3,-4,4,-3,3,-4,4,-5,
1331  &5,-6,6,-5,5,-6,6,-5,5,-6,6,-1,1,-2,2,-1,1,-2,2,-1,1,-2,2,-3,3,-4,
1332  &4,-3,3,-4,4,-3,3,-4,4,-5,5,-6,6,-5,5,-6,6,-5,5,-6,6,-1,1,-1,1,-3,
1333  &3,-1,1,-1,1,-3,3,-1,1,-1,1,-3,3,24,37,24,-11,-13,-15,-1,-3,24,
1334  &-11,-13,-15,-1,-3,24,-11,-13,-15,-1,-3,24,-11,-13,-15,-1,-3,4*37,
1335  &2*-1,2*2,2*-3,2*4,2*-5,2*6,2*-11,2*12,2*-13,2*14,2*-15,2*16,-1,
1336  &-3,-13,14,2*-13,14,2*-13,14,-13,-15,16,2*-15,16,2*-15,16,-15,
1337  &6*-11,-15,16,2*-15,16,2*-15,16,-15,6*-11,6*-13,-1,-2,-1,2,-1,-2,
1338  &-1,2,-1,-2,-1,2,-3,-4,-3,4,-3,-4,-3,4,-3,-4,-3,4,-5,-6,-5,6,-5,
1339  &-6,-5,6,-5,-6,-5,6,-1,-2,-1,2,-1,-2,-1,2,-1,-2,-1,2,-3,-4,-3,4,
1340  &-3,-4,-3,4,-3,-4,-3,4,-5,-6,-5,6,-5,-6,-5,6,-5,-6,-5,6,-1,-2,-1/
1341  DATA (kfdp(i,2),i=2771,3221)/2,-1,-2,-1,2,-1,-2,-1,2,-3,-4,-3,4,
1342  &-3,-4,-3,4,-3,-4,-3,4,-5,-6,-5,6,-5,-6,-5,6,-5,-6,-5,6,2,-1,2,-1,
1343  &2*4,-3,4,-3,3*6,-5,2*4,-3,3*6,-5,2*6,22,23,25,35,36,22,23,11,13,
1344  &15,12,14,16,1,3,5,2,4,25,35,36,22,23,11,13,15,12,14,16,1,3,5,2,4,
1345  &25,35,36,-24,24,11,-11,13,-13,15,-15,1,-1,3,-3,-24,24,11,-11,13,
1346  &-13,15,-15,1,-1,3,-3,-37,37,-37,37,-1,1,-1,1,-2,2,-2,2,-3,3,-3,3,
1347  &-4,4,-4,4,-5,5,-5,5,-6,6,-6,6,-11,11,-11,11,-12,12,-12,12,-13,13,
1348  &-13,13,-14,14,-14,14,-15,15,-15,15,-16,16,-16,16,1,3,5,2,4,-13,
1349  &13,-13,13,-13,13,-15,15,-15,15,-15,15,-11,11,-11,11,-11,11,-15,
1350  &15,-15,15,-15,15,-11,11,-11,11,-11,11,-13,13,-13,13,-13,13,-1,1,
1351  &-2,2,-1,1,-2,2,-1,1,-2,2,-3,3,-4,4,-3,3,-4,4,-3,3,-4,4,-5,5,-6,6,
1352  &-5,5,-6,6,-5,5,-6,6,-1,1,-2,2,-1,1,-2,2,-1,1,-2,2,-3,3,-4,4,-3,3,
1353  &-4,4,-3,3,-4,4,-5,5,-6,6,-5,5,-6,6,-5,5,-6,6,-1,1,-2,2,-1,1,-2,2,
1354  &-1,1,-2,2,-3,3,-4,4,-3,3,-4,4,-3,3,-4,4,-5,5,-6,6,-5,5,-6,6,-5,5,
1355  &-6,6,-1,1,-1,1,-3,3,-1,1,-1,1,-3,3,-1,1,-1,1,-3,3,22,23,25,35,36,
1356  &22,23,11,13,15,12,14,16,1,3,5,2,4,25,35,36,22,23,11,13,15,12,14,
1357  &16,1,3,5,2,4,25,35,36,22,23,11,13,15,12,14,16,1,3,5,2,4,25,35,36,
1358  &-24,24,11,-11,13,-13,15,-15,1,-1,3,-3,-24,24,11,-11,13,-13,15,
1359  &-15,1,-1,3,-3,-37,37,-37,37,-1,1,-1,1,-2,2,-2,2,-3,3,-3,3,-4,4,
1360  &-4,4,-5,5,-5,5,-6,6,-6,6,-11,11,-11,11,-12,12,-12,12,-13,13,-13/
1361  DATA (kfdp(i,2),i=3222,3669)/13,-14,14,-14,14,-15,15,-15,15,-16,
1362  &16,-16,16,1,3,5,2,4,-13,13,-13,13,-13,13,-15,15,-15,15,-15,15,
1363  &-11,11,-11,11,-11,11,-15,15,-15,15,-15,15,-11,11,-11,11,-11,11,
1364  &-13,13,-13,13,-13,13,-1,1,-2,2,-1,1,-2,2,-1,1,-2,2,-3,3,-4,4,-3,
1365  &3,-4,4,-3,3,-4,4,-5,5,-6,6,-5,5,-6,6,-5,5,-6,6,-1,1,-2,2,-1,1,-2,
1366  &2,-1,1,-2,2,-3,3,-4,4,-3,3,-4,4,-3,3,-4,4,-5,5,-6,6,-5,5,-6,6,-5,
1367  &5,-6,6,-1,1,-2,2,-1,1,-2,2,-1,1,-2,2,-3,3,-4,4,-3,3,-4,4,-3,3,-4,
1368  &4,-5,5,-6,6,-5,5,-6,6,-5,5,-6,6,-1,1,-1,1,-3,3,-1,1,-1,1,-3,3,-1,
1369  &1,-1,1,-3,3,24,37,23,11,13,15,12,14,16,1,3,5,2,4,25,35,36,24,-11,
1370  &-13,-15,-1,-3,24,-11,-13,-15,-1,-3,24,-11,-13,-15,-1,-3,24,-11,
1371  &-13,-15,-1,-3,4*37,2*-1,2*2,2*-3,2*4,2*-5,2*6,2*-11,2*12,2*-13,
1372  &2*14,2*-15,2*16,-1,-3,-13,14,2*-13,14,2*-13,14,-13,-15,16,2*-15,
1373  &16,2*-15,16,-15,-11,12,2*-11,12,2*-11,12,-11,-15,16,2*-15,16,
1374  &2*-15,16,-15,-11,12,2*-11,12,2*-11,12,-11,-13,14,2*-13,14,2*-13,
1375  &14,-13,-1,-2,-1,2,-1,-2,-1,2,-1,-2,-1,2,-3,-4,-3,4,-3,-4,-3,4,-3,
1376  &-4,-3,4,-5,-6,-5,6,-5,-6,-5,6,-5,-6,-5,6,-1,-2,-1,2,-1,-2,-1,2,
1377  &-1,-2,-1,2,-3,-4,-3,4,-3,-4,-3,4,-3,-4,-3,4,-5,-6,-5,6,-5,-6,-5,
1378  &6,-5,-6,-5,6,-1,-2,-1,2,-1,-2,-1,2,-1,-2,-1,2,-3,-4,-3,4,-3,-4,
1379  &-3,4,-3,-4,-3,4,-5,-6,-5,6,-5,-6,-5,6,-5,-6,-5,6,2,-1,2,-1,2*4,
1380  &-3,4,-3,3*6,-5,2*4,-3,3*6,-5,2*6,1,2*2,4*1,23,25,35,36,2*-24/
1381  DATA (kfdp(i,2),i=3670,4183)/2*-37,2*1,3,5,1,3,5,1,3,5,1,2,3,4,5,
1382  &6,1,2,3,4,5,6,1,2,3,4,5,6,-3,-5,-3,-5,-3,-5,2,2*1,4*2,23,25,35,
1383  &36,2*24,2*37,2,1,3,5,1,3,5,1,3,5,-3,2*-5,3,2*4,4*3,23,25,35,36,
1384  &2*-24,2*-37,3,1,3,5,1,3,5,1,3,5,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,
1385  &5,6,-1,-5,-1,-5,-1,-5,4,2*3,4*4,23,25,35,36,2*24,2*37,4,1,3,5,1,
1386  &3,5,1,3,5,-3,2*-5,5,2*6,4*5,23,25,35,36,2*-24,2*-37,5,1,3,5,1,3,
1387  &5,1,3,5,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6,-1,-3,-1,-3,-1,-3,6,
1388  &2*5,4*6,23,25,35,36,2*24,2*37,6,1,3,5,1,3,5,1,3,5,-3,2*-5,11,
1389  &2*12,4*11,23,25,35,36,2*-24,2*-37,13,15,11,15,11,13,11,13,15,11,
1390  &13,15,1,3,5,1,3,5,1,3,5,13,2*14,4*13,23,25,35,36,2*-24,2*-37,13,
1391  &15,11,15,11,13,11,13,15,11,13,15,1,3,5,1,3,5,1,3,5,15,2*16,4*15,
1392  &23,25,35,36,2*-24,2*-37,13,15,11,15,11,13,11,13,15,11,13,15,1,3,
1393  &5,1,3,5,1,3,5,-3,-4,-5,-6,-11,-13,-15,21,-1,-3,2*-5,5,12,14,16,
1394  &-3,-4,-5,-6,-11,-13,-15,21,-5,-6,21,-1,-2,-3,-4,-5,-6,-1,-2,-3,
1395  &-4,-5,-6,21,-1,-2,-3,-4,-5,-6,21,-1,-2,-3,-4,-5,-6,21,-1,-2,-3,
1396  &-4,-5,-6,-1,-2,-3,-4,-5,-6,-1,-2,-3,-4,-5,-6,3*21,3*1,4*2,1,2*11,
1397  &2*12,11,-1,-2,-3,-4,-5,-6,-7,-8,-11,-12,-13,-14,-15,-16,-17,-18,
1398  &21,22,23,-24,3*-1,3*-3,3*-5,3*1,3*3,3*5,-13,13,-15,15,3*-1,3*-3,
1399  &3*-5,3*1,3*3,3*5,-11,11,-15,15,3*-1,3*-3,3*-5,3*1,3*3,3*5,-11,11,
1400  &-13,13,-1,-2,-3,-4,-5,-6,-11,-12,9900012,-13,-14,9900014,-15,-16/
1401  DATA (kfdp(i,2),i=4184,8000)/9900016,2,4,6,2,4,6,2,4,6,9900012,
1402  &9900014,9900016,-11,-13,-15,-13,2*-15,24,-11,-13,-15,-13,2*-15,
1403  &9900024,6*21,-24,-3000211,-24,-3000211,3000111,3000221,3000111,
1404  &3000221,2*23,-1,-2,-3,-4,-5,-6,-7,-8,-11,-12,-13,-14,-15,-16,-17,
1405  &-18,23,3000111,23,3000111,22,3000221,22,2,4,6,8,2,4,6,8,2,4,6,8,
1406  &2,4,6,8,12,14,16,18,2*3000111,2*3000221,-3000211,2*-24,-3000211,
1407  &2*23,-1,-2,-3,-4,-5,-6,-7,-8,-11,-12,-13,-14,-15,-16,-17,-18,-24,
1408  &-3000211,3000211,3000221,3000113,3000223,-3000213,3000213,
1409  &3000113,3000223,-1,-2,-3,-4,-5,-6,-7,-8,-11,-12,-13,-14,-15,-16,
1410  &-17,-18,24,3000211,24,3000111,3000221,3000211,3000213,3000113,
1411  &3000223,3000213,2,4,6,8,2,4,6,8,2,4,6,8,2,4,6,8,12,14,16,18,
1412  &649*0,
1413 C...UED
1414  &1,1,2,2,3,3,4,4,5,5,6,6,
1415  &1,2,1,2,1,2,3,4,3,4,3,4,5,6,5,6,5,6,
1416  &11,13,15,12,11,14,13,16,15,
1417  &-1,-2,-3,-4,-5,-6,-1,-2,-3,-4,-5,-6,
1418  &1,2,3,4,5,6,1,2,3,4,5,6,
1419  &22,
1420  &-11,-13,-15,-11,-13,-15,-12,-14,-16,
1421  &11,13,15,11,13,15,12,14,16,
1422  &12,14,16,-11,-13,-15,
1423  &2912*0/
1424  DATA (kfdp(i,3),i= 1,1021)/81*0,14,6*0,2*16,2*0,6*111,310,130,
1425  &2*0,3*111,310,130,321,113,211,223,221,2*113,2*211,2*223,2*221,
1426  &2*113,221,2*113,2*213,-213,113,2*111,310,130,310,130,2*310,130,
1427  &402*0,4*3,4*4,1,4,3,2*2,0,-11,8*0,-211,5*0,2*111,211,-211,211,
1428  &-211,10*0,111,4*0,2*111,-211,-11,11,-13,22,111,3*0,22,3*0,111,
1429  &211,4*0,111,11*0,111,-211,6*0,-211,3*111,7*0,111,-211,5*0,2*221,
1430  &3*0,111,5*0,111,11*0,-311,-313,-311,-321,-313,-323,111,221,331,
1431  &113,223,-311,-313,-311,-321,-313,-323,111,221,331,113,223,22*0,
1432  &111,113,2*211,-211,-311,211,111,3*211,-211,7*211,7*0,111,-211,
1433  &111,-211,-321,-323,-311,-321,-313,-323,-211,-213,-321,-323,-311,
1434  &-321,-313,-323,-211,-213,22*0,111,113,-311,2*-211,211,-211,310,
1435  &-211,2*111,211,2*-211,-321,-211,2*211,-211,111,-211,2*211,6*0,
1436  &111,-211,111,-211,0,221,331,333,321,311,221,331,333,321,311,20*0,
1437  &3,13*0,-411,-413,-10413,-10411,-20413,-415,-411,-413,-10413,
1438  &-10411,-20413,-415,-411,-413,16*0,-4,-1,-4,-3,2*-2,5*0,111,-211,
1439  &111,-211,-421,-423,-10423,-10421,-20423,-425,-421,-423,-10423,
1440  &-10421,-20423,-425,-421,-423,16*0,-4,-1,-4,-3,2*-2,5*0,111,-211,
1441  &111,-211,-431,-433,-10433,-10431,-20433,-435,-431,-433,-10433,
1442  &-10431,-20433,-435,-431,-433,19*0,-4,-1,-4,-3,2*-2,8*0,441,443,
1443  &441,443,441,443,-4,-1,-4,-3,-4,-3,-4,-1,531,533,531,533,3,2,3,2/
1444  DATA (kfdp(i,3),i=1022,2223)/511,513,511,513,1,2,13*0,2*21,11*0,
1445  &2112,6*0,2212,12*0,2*3122,3212,10*0,3322,2*0,3122,3212,3214,2112,
1446  &2114,2212,2112,3122,3212,3214,2112,2114,2212,2112,52*0,3*3,1,6*0,
1447  &4*3,4*0,4*3,6*0,4*3,0,28*3,2*0,3*4122,8*0,4,1,4,3,2*2,4*4,1,4,3,
1448  &2*2,4*4,1,4,3,2*2,4*0,4*4,1,4,3,2*2,4*4,1,4,3,2*2,4*0,4*4,1,4,3,
1449  &2*2,0,4*4,1,4,3,2*2,4*4,1,4,3,2*2,4*4,1,4,3,2*2,4*4,1,4,3,2*2,
1450  &4*4,1,4,3,2*2,4*4,1,4,3,2*2,4*4,1,4,3,2*2,4*4,1,4,3,2*2,4*4,1,4,
1451  &3,2*2,4*4,1,4,3,2*2,4*4,1,4,3,2*2,4*4,1,4,3,2*2,4*4,1,4,3,2*2,
1452  &4*4,1,4,3,2*2,4*4,1,4,3,2*2,4*4,1,4,3,2*2,4*4,1,4,3,2*2,4*4,1,4,
1453  &3,2*2,31*0,211,111,45*0,-211,2*111,-211,3*111,-211,111,211,30*0,
1454  &-211,111,13*0,2*21,-211,111,199*0,2*5,210*0,-1,-3,-5,-2,-4,-6,-1,
1455  &-3,-5,-2,-4,-6,-1,-3,-5,-2,-4,-6,-1,-3,-5,-2,-4,-6,-2,2,-4,4,-6,
1456  &6,-2,2,-4,4,-6,6,1,-1,1,-1,3,-3,3,-3,5,-5,5,-5,1,-1,1,-1,3,-3,3,
1457  &-3,5,-5,5,-5,1,-1,1,-1,3,-3,3,-3,5,-5,5,-5,1,-1,1,-1,3,-3,3,-3,5,
1458  &-5,5,-5,1,-1,1,-1,3,-3,3,-3,5,-5,5,-5,1,-1,1,-1,3,-3,3,-3,5,-5,5,
1459  &-5,1,-1,1,-1,3,-3,3,-3,5,-5,5,-5,1,-1,1,-1,3,-3,3,-3,5,-5,5,-5,1,
1460  &-1,1,-1,3,-3,3,-3,5,-5,5,-5,-3,3,-5,5,-5,5,-3,3,-5,5,-5,5,-3,3,
1461  &-5,5,-5,5,5*0,11,12,11,-11,13,-13,15,-15,11,-11,13,-13,15,-15,11,
1462  &-11,13,-13,15,-15,11,-11,13,-13,15,-15,11,-11,13,-13,15,-15,11,
1463  &-11,13,-13,15,-15,1,-1,1,-1,3,-3,3,-3,5,-5,5,-5,1,-1,1,-1,3,-3,3/
1464  DATA (kfdp(i,3),i=2224,2783)/-3,5,-5,5,-5,1,-1,1,-1,3,-3,3,-3,5,
1465  &-5,5,-5,1,-1,1,-1,3,-3,3,-3,5,-5,5,-5,1,-1,1,-1,3,-3,3,-3,5,-5,5,
1466  &-5,1,-1,1,-1,3,-3,3,-3,5,-5,5,-5,1,-1,1,-1,3,-3,3,-3,5,-5,5,-5,1,
1467  &-1,1,-1,3,-3,3,-3,5,-5,5,-5,1,-1,1,-1,3,-3,3,-3,5,-5,5,-5,-3,3,
1468  &-5,5,-5,5,-3,3,-5,5,-5,5,-3,3,-5,5,-5,5,7*0,-11,-13,-15,-12,-14,
1469  &-16,-1,-3,-5,-2,-4,5*0,-12,12,-14,14,-16,16,-2,2,-4,4,2*0,-12,12,
1470  &-14,14,-16,16,-2,2,-4,4,52*0,-1,-3,-5,-2,-4,11,-11,13,-13,15,-15,
1471  &11,-11,13,-13,15,-15,11,-11,13,-13,15,-15,11,-11,13,-13,15,-15,
1472  &11,-11,13,-13,15,-15,11,-11,13,-13,15,-15,1,-1,1,-1,3,-3,3,-3,5,
1473  &-5,5,-5,1,-1,1,-1,3,-3,3,-3,5,-5,5,-5,1,-1,1,-1,3,-3,3,-3,5,-5,5,
1474  &-5,1,-1,1,-1,3,-3,3,-3,5,-5,5,-5,1,-1,1,-1,3,-3,3,-3,5,-5,5,-5,1,
1475  &-1,1,-1,3,-3,3,-3,5,-5,5,-5,1,-1,1,-1,3,-3,3,-3,5,-5,5,-5,1,-1,1,
1476  &-1,3,-3,3,-3,5,-5,5,-5,1,-1,1,-1,3,-3,3,-3,5,-5,5,-5,-3,3,-5,5,
1477  &-5,5,-3,3,-5,5,-5,5,-3,3,-5,5,-5,5,3*0,12,14,16,2,4,0,12,14,16,2,
1478  &4,0,12,14,16,2,4,0,12,14,16,2,4,28*0,2,4,12,-11,11,14,-13,13,16,
1479  &-15,15,12,-11,11,14,-13,13,16,-15,15,12,11,14,13,16,15,12,-11,11,
1480  &14,-13,13,16,-15,15,12,11,14,13,16,15,12,11,14,13,16,15,2*2,1,-1,
1481  &2*4,3,-3,2*6,5,-5,2*2,1,-1,2*4,3,-3,2*6,5,-5,2*2,1,-1,2*4,3,-3,
1482  &2*6,5,-5,2*2,1,-1,2*4,3,-3,2*6,5,-5,2*2,1,-1,2*4,3,-3,2*6,5,-5,
1483  &2*2,1,-1,2*4,3,-3,2*6,5,-5,2*2,1,-1,2*4,3,-3,2*6,5,-5,2*2,1,-1/
1484  DATA (kfdp(i,3),i=2784,3354)/2*4,3,-3,2*6,5,-5,2*2,1,-1,2*4,3,-3,
1485  &2*6,5,-5,3,-3,5,-5,1,3,-3,5,-5,1,3,5,-5,1,5,-5,1,3,5,-5,1,3,7*0,
1486  &-11,-13,-15,-12,-14,-16,-1,-3,-5,-2,-4,5*0,-11,-13,-15,-12,-14,
1487  &-16,-1,-3,-5,-2,-4,5*0,-12,12,-14,14,-16,16,-2,2,-4,4,2*0,-12,12,
1488  &-14,14,-16,16,-2,2,-4,4,52*0,-1,-3,-5,-2,-4,11,-11,13,-13,15,-15,
1489  &11,-11,13,-13,15,-15,11,-11,13,-13,15,-15,11,-11,13,-13,15,-15,
1490  &11,-11,13,-13,15,-15,11,-11,13,-13,15,-15,1,-1,1,-1,3,-3,3,-3,5,
1491  &-5,5,-5,1,-1,1,-1,3,-3,3,-3,5,-5,5,-5,1,-1,1,-1,3,-3,3,-3,5,-5,5,
1492  &-5,1,-1,1,-1,3,-3,3,-3,5,-5,5,-5,1,-1,1,-1,3,-3,3,-3,5,-5,5,-5,1,
1493  &-1,1,-1,3,-3,3,-3,5,-5,5,-5,1,-1,1,-1,3,-3,3,-3,5,-5,5,-5,1,-1,1,
1494  &-1,3,-3,3,-3,5,-5,5,-5,1,-1,1,-1,3,-3,3,-3,5,-5,5,-5,-3,3,-5,5,
1495  &-5,5,-3,3,-5,5,-5,5,-3,3,-5,5,-5,5,7*0,-11,-13,-15,-12,-14,-16,
1496  &-1,-3,-5,-2,-4,5*0,-11,-13,-15,-12,-14,-16,-1,-3,-5,-2,-4,5*0,
1497  &-11,-13,-15,-12,-14,-16,-1,-3,-5,-2,-4,5*0,-12,12,-14,14,-16,16,
1498  &-2,2,-4,4,2*0,-12,12,-14,14,-16,16,-2,2,-4,4,52*0,-1,-3,-5,-2,-4,
1499  &11,-11,13,-13,15,-15,11,-11,13,-13,15,-15,11,-11,13,-13,15,-15,
1500  &11,-11,13,-13,15,-15,11,-11,13,-13,15,-15,11,-11,13,-13,15,-15,1,
1501  &-1,1,-1,3,-3,3,-3,5,-5,5,-5,1,-1,1,-1,3,-3,3,-3,5,-5,5,-5,1,-1,1,
1502  &-1,3,-3,3,-3,5,-5,5,-5,1,-1,1,-1,3,-3,3,-3,5,-5,5,-5,1,-1,1,-1,3,
1503  &-3,3,-3,5,-5,5,-5,1,-1,1,-1,3,-3,3,-3,5,-5,5,-5,1,-1,1,-1,3,-3,3/
1504  DATA (kfdp(i,3),i=3355,8000)/-3,5,-5,5,-5,1,-1,1,-1,3,-3,3,-3,5,
1505  &-5,5,-5,1,-1,1,-1,3,-3,3,-3,5,-5,5,-5,-3,3,-5,5,-5,5,-3,3,-5,5,
1506  &-5,5,-3,3,-5,5,-5,5,3*0,-11,-13,-15,-12,-14,-16,-1,-3,-5,-2,-4,
1507  &4*0,12,14,16,2,4,0,12,14,16,2,4,0,12,14,16,2,4,0,12,14,16,2,4,
1508  &28*0,2,4,12,-11,11,14,-13,13,16,-15,15,12,-11,11,14,-13,13,16,
1509  &-15,15,12,-11,11,14,-13,13,16,-15,15,12,-11,11,14,-13,13,16,-15,
1510  &15,12,-11,11,14,-13,13,16,-15,15,12,-11,11,14,-13,13,16,-15,15,
1511  &2*2,1,-1,2*4,3,-3,2*6,5,-5,2*2,1,-1,2*4,3,-3,2*6,5,-5,2*2,1,-1,
1512  &2*4,3,-3,2*6,5,-5,2*2,1,-1,2*4,3,-3,2*6,5,-5,2*2,1,-1,2*4,3,-3,
1513  &2*6,5,-5,2*2,1,-1,2*4,3,-3,2*6,5,-5,2*2,1,-1,2*4,3,-3,2*6,5,-5,
1514  &2*2,1,-1,2*4,3,-3,2*6,5,-5,2*2,1,-1,2*4,3,-3,2*6,5,-5,3,-3,5,-5,
1515  &1,3,-3,5,-5,1,3,5,-5,1,5,-5,1,3,5,-5,1,3,351*0,-5,95*0,2,4,6,2,4,
1516  &6,2,4,6,-2,-4,-6,-2,-4,-6,-2,-4,-6,2*9900014,2*9900016,2,4,6,2,4,
1517  &6,2,4,6,-2,-4,-6,-2,-4,-6,-2,-4,-6,2*9900012,2*9900016,2,4,6,2,4,
1518  &6,2,4,6,-2,-4,-6,-2,-4,-6,-2,-4,-6,2*9900012,2*9900014,3831*0/
1519  DATA (kfdp(i,4),i= 1,8000)/94*0,4*111,6*0,111,2*0,-211,0,-211,
1520  &3*0,111,2*-211,0,111,0,2*111,113,221,2*111,-213,-211,211,113,
1521  &6*111,310,2*130,402*0,13*81,41*0,-11,10*0,111,-211,4*0,111,62*0,
1522  &111,211,111,211,7*0,111,211,111,211,35*0,2*-211,2*111,211,111,
1523  &-211,2*211,2*-211,13*0,-211,111,-211,111,4*0,-211,111,-211,111,
1524  &34*0,111,-211,3*111,3*-211,2*111,3*-211,14*0,-321,-311,3*0,-321,
1525  &-311,20*0,-3,43*0,6*1,39*0,6*2,42*0,6*3,14*0,8*4,4*0,4*-5,4*0,
1526  &2*-5,67*0,-211,111,5*0,-211,111,52*0,2101,2103,2*2101,6*0,4*81,
1527  &4*0,4*81,6*0,4*81,0,28*81,13*0,6*2101,18*81,4*0,18*81,4*0,9*81,0,
1528  &162*81,31*0,-211,111,6516*0/
1529  DATA (kfdp(i,5),i= 1,8000)/96*0,2*111,17*0,111,7*0,2*111,0,
1530  &3*111,0,111,597*0,-211,2*111,-211,111,-211,111,65*0,111,-211,
1531  &3*111,-211,111,7193*0/
1532 
1533 C...PYDAT4, with particle names (character strings).
1534  DATA (chaf(i,1),i= 1, 202)/'d','u','s','c','b','t','b''','t''',
1535  &2*' ','e-','nu_e','mu-','nu_mu','tau-','nu_tau','tau''-',
1536  &'nu''_tau',2*' ','g','gamma','Z0','W+','h0',6*' ','Z''0','Z"0',
1537  &'W''+','H0','A0','H+',' ','Graviton',' ','R0','LQ_ue',38*' ',
1538  &'specflav','rndmflav','phasespa','c-hadron','b-hadron',2*' ',
1539  &'junction',' ','system','cluster','string','indep.','CMshower',
1540  &'SPHEaxis','THRUaxis','CLUSjet','CELLjet','table',' ','reggeon',
1541  &'pi0','rho0','a_20','K_L0','pi+','rho+','a_2+','eta','omega',
1542  &'f_2','K_S0','K0','K*0','K*_20','K+','K*+','K*_2+','eta''','phi',
1543  &'f''_2','D+','D*+','D*_2+','D0','D*0','D*_20','D_s+','D*_s+',
1544  &'D*_2s+','eta_c','J/psi','chi_2c','B0','B*0','B*_20','B+','B*+',
1545  &'B*_2+','B_s0','B*_s0','B*_2s0','B_c+','B*_c+','B*_2c+','eta_b',
1546  &'Upsilon','chi_2b','pomeron','dd_1','Delta-','ud_0','ud_1','n0',
1547  &'Delta0','uu_1','p+','Delta+','Delta++','sd_0','sd_1','Sigma-',
1548  &'Sigma*-','Lambda0','su_0','su_1','Sigma0','Sigma*0','Sigma+',
1549  &'Sigma*+','ss_1','Xi-','Xi*-','Xi0','Xi*0','Omega-','cd_0',
1550  &'cd_1','Sigma_c0','Sigma*_c0','Lambda_c+','Xi_c0','cu_0','cu_1',
1551  &'Sigma_c+','Sigma*_c+','Sigma_c++','Sigma*_c++','Xi_c+','cs_0',
1552  &'cs_1','Xi''_c0','Xi*_c0','Xi''_c+','Xi*_c+','Omega_c0',
1553  &'Omega*_c0','cc_1','Xi_cc+','Xi*_cc+','Xi_cc++','Xi*_cc++'/
1554  DATA (chaf(i,1),i= 203, 332)/'Omega_cc+','Omega*_cc+',
1555  &'Omega*_ccc++','bd_0','bd_1','Sigma_b-','Sigma*_b-','Lambda_b0',
1556  &'Xi_b-','Xi_bc0','bu_0','bu_1','Sigma_b0','Sigma*_b0','Sigma_b+',
1557  &'Sigma*_b+','Xi_b0','Xi_bc+','bs_0','bs_1','Xi''_b-','Xi*_b-',
1558  &'Xi''_b0','Xi*_b0','Omega_b-','Omega*_b-','Omega_bc0','bc_0',
1559  &'bc_1','Xi''_bc0','Xi*_bc0','Xi''_bc+','Xi*_bc+','Omega''_bc0',
1560  &'Omega*_bc0','Omega_bcc+','Omega*_bcc+','bb_1','Xi_bb-',
1561  &'Xi*_bb-','Xi_bb0','Xi*_bb0','Omega_bb-','Omega*_bb-',
1562  &'Omega_bbc0','Omega*_bbc0','Omega*_bbb-','a_00','b_10','a_0+',
1563  &'b_1+','f_0','h_1','K*_00','K_10','K*_0+','K_1+','f''_0','h''_1',
1564  &'D*_0+','D_1+','D*_00','D_10','D*_0s+','D_1s+','chi_0c','h_1c',
1565  &'B*_00','B_10','B*_0+','B_1+','B*_0s0','B_1s0','B*_0c+','B_1c+',
1566  &'chi_0b','h_1b','a_10','a_1+','f_1','K*_10','K*_1+','f''_1',
1567  &'D*_1+','D*_10','D*_1s+','chi_1c','B*_10','B*_1+','B*_1s0',
1568  &'B*_1c+','chi_1b','psi''','Upsilon''','~d_L','~u_L','~s_L',
1569  &'~c_L','~b_1','~t_1','~e_L-','~nu_eL','~mu_L-','~nu_muL',
1570  &'~tau_1-','~nu_tauL','~g','~chi_10','~chi_20','~chi_1+',
1571  &'~chi_30','~chi_40','~chi_2+','~Gravitino','~d_R','~u_R','~s_R',
1572  &'~c_R','~b_2','~t_2','~e_R-','~nu_eR','~mu_R-','~nu_muR',
1573  &'~tau_2-','~nu_tauR','pi_tc0','pi_tc+','pi''_tc0','eta_tc0'/
1574  DATA (chaf(i,1),i= 333, 500)/'rho_tc0','rho_tc+','omega_tc',
1575  &'V8_tc','pi_22_1_tc','pi_22_8_tc','rho_11_tc','rho_12_tc',
1576  &'rho_21_tc','rho_22_tc','d*','u*','e*-','nu*_e0','Graviton*',
1577  &'nu_Re','nu_Rmu','nu_Rtau','Z_R0','W_R+','H_L++','H_R++',
1578  &'rho_diff0','pi_diffr+','omega_di','phi_diff','J/psi_di',
1579  &'n_diffr0','p_diffr+','cc~[3S18]','cc~[1S08]','cc~[3P08]',
1580  &'bb~[3S18]','bb~[1S08]','bb~[3P08]','a_tc0','a_tc+',
1581  &81*' ',
1582 C...UED
1583  &'d*_S','u*_S','s*_S','c*_S','b*_S','t*_S',
1584  &'d*_D','u*_D','s*_D','c*_D','b*_D','t*_D',
1585  &'e*_S-','mu*_S-','tau*_S-',
1586  &'nu*_eD','e*_D-','nu*_muD','mu*_D-','nu*_tauD','tau*_D-',
1587  &'g*','gamma*','Z*0','W*+',25*' '/
1588  DATA (chaf(i,2),i= 1, 205)/'dbar','ubar','sbar','cbar','bbar',
1589  &'tbar','b''bar','t''bar',2*' ','e+','nu_ebar','mu+','nu_mubar',
1590  &'tau+','nu_taubar','tau''+','nu''_taubar',5*' ','W-',9*' ',
1591  &'W''-',2*' ','H-',3*' ','Rbar0','LQ_uebar',39*' ','rndmflavbar',
1592  &' ','c-hadronbar','b-hadronbar',20*' ','pi-','rho-','a_2-',4*' ',
1593  &'Kbar0','K*bar0','K*_2bar0','K-','K*-','K*_2-',3*' ','D-','D*-',
1594  &'D*_2-','Dbar0','D*bar0','D*_2bar0','D_s-','D*_s-','D*_2s-',
1595  &3*' ','Bbar0','B*bar0','B*_2bar0','B-','B*-','B*_2-','B_sbar0',
1596  &'B*_sbar0','B*_2sbar0','B_c-','B*_c-','B*_2c-',4*' ','dd_1bar',
1597  &'Deltabar+','ud_0bar','ud_1bar','nbar0','Deltabar0','uu_1bar',
1598  &'pbar-','Deltabar-','Deltabar--','sd_0bar','sd_1bar','Sigmabar+',
1599  &'Sigma*bar+','Lambdabar0','su_0bar','su_1bar','Sigmabar0',
1600  &'Sigma*bar0','Sigmabar-','Sigma*bar-','ss_1bar','Xibar+',
1601  &'Xi*bar+','Xibar0','Xi*bar0','Omegabar+','cd_0bar','cd_1bar',
1602  &'Sigma_cbar0','Sigma*_cbar0','Lambda_cbar-','Xi_cbar0','cu_0bar',
1603  &'cu_1bar','Sigma_cbar-','Sigma*_cbar-','Sigma_cbar--',
1604  &'Sigma*_cbar--','Xi_cbar-','cs_0bar','cs_1bar','Xi''_cbar0',
1605  &'Xi*_cbar0','Xi''_cbar-','Xi*_cbar-','Omega_cbar0',
1606  &'Omega*_cbar0','cc_1bar','Xi_ccbar-','Xi*_ccbar-','Xi_ccbar--',
1607  &'Xi*_ccbar--','Omega_ccbar-','Omega*_ccbar-','Omega*_cccbar-'/
1608  DATA (chaf(i,2),i= 206, 325)/'bd_0bar','bd_1bar','Sigma_bbar+',
1609  &'Sigma*_bbar+','Lambda_bbar0','Xi_bbar+','Xi_bcbar0','bu_0bar',
1610  &'bu_1bar','Sigma_bbar0','Sigma*_bbar0','Sigma_bbar-',
1611  &'Sigma*_bbar-','Xi_bbar0','Xi_bcbar-','bs_0bar','bs_1bar',
1612  &'Xi''_bbar+','Xi*_bbar+','Xi''_bbar0','Xi*_bbar0','Omega_bbar+',
1613  &'Omega*_bbar+','Omega_bcbar0','bc_0bar','bc_1bar','Xi''_bcbar0',
1614  &'Xi*_bcbar0','Xi''_bcbar-','Xi*_bcbar-','Omega''_bcba',
1615  &'Omega*_bcbar0','Omega_bccbar-','Omega*_bccbar-','bb_1bar',
1616  &'Xi_bbbar+','Xi*_bbbar+','Xi_bbbar0','Xi*_bbbar0','Omega_bbbar+',
1617  &'Omega*_bbbar+','Omega_bbcbar0','Omega*_bbcbar0',
1618  &'Omega*_bbbbar+',2*' ','a_0-','b_1-',2*' ','K*_0bar0','K_1bar0',
1619  &'K*_0-','K_1-',2*' ','D*_0-','D_1-','D*_0bar0','D_1bar0',
1620  &'D*_0s-','D_1s-',2*' ','B*_0bar0','B_1bar0','B*_0-','B_1-',
1621  &'B*_0sbar0','B_1sbar0','B*_0c-','B_1c-',3*' ','a_1-',' ',
1622  &'K*_1bar0','K*_1-',' ','D*_1-','D*_1bar0','D*_1s-',' ',
1623  &'B*_1bar0','B*_1-','B*_1sbar0','B*_1c-',3*' ','~d_Lbar',
1624  &'~u_Lbar','~s_Lbar','~c_Lbar','~b_1bar','~t_1bar','~e_L+',
1625  &'~nu_eLbar','~mu_L+','~nu_muLbar','~tau_1+','~nu_tauLbar',3*' ',
1626  &'~chi_1-',2*' ','~chi_2-',' ','~d_Rbar','~u_Rbar','~s_Rbar',
1627  &'~c_Rbar','~b_2bar','~t_2bar','~e_R+','~nu_eRbar','~mu_R+'/
1628  DATA (chaf(i,2),i= 326, 500)/'~nu_muRbar','~tau_2+',
1629  &'~nu_tauRbar',' ','pi_tc-',3*' ','rho_tc-',8*' ','d*bar','u*bar',
1630  &'e*bar+','nu*_ebar0',5*' ','W_R-','H_L--','H_R--',' ',
1631  &'pi_diffr-',3*' ','n_diffrbar0','p_diffrbar-',7*' ','a_tc-',
1632  &81*' ',
1633 C...UED
1634  &'d*_Sbar','u*_Sbar','s*_Sbar','c*_Sbar','b*_Sbar','t*_Sbar',
1635  &'d*_Dbar','u*_Dbar','s*_Dbar','c*_Dbar','b*_Dbar','t*_Dbar',
1636  &'e*_Sbar+','mu*_Sbar+','tau*_Sbar+',
1637  &'nu*_eDbar','e*_Dbar+',
1638  &'nu*_muDbar','mu*_Dbar+',
1639  &'nu*_tauDbar','tau*_Dbar+',
1640  &'g*','gamma*','Z*0','W*-',25*' '/
1641 
1642 C...PYDATR, with initial values for the random number generator.
1643  DATA mrpy/19780503,0,0,97,33,0/
1644 
1645 C...Default values for allowed processes and kinematics constraints.
1646  DATA msel/1/
1647  DATA msub/500*0/
1648  DATA ((kfin(i,j),j=-40,40),i=1,2)/16*0,4*1,4*0,6*1,5*0,5*1,0,
1649  &5*1,5*0,6*1,4*0,4*1,16*0,16*0,4*1,4*0,6*1,5*0,5*1,0,5*1,5*0,
1650  &6*1,4*0,4*1,16*0/
1651  DATA ckin/
1652  & 2.0d0, -1.0d0, 0.0d0, -1.0d0, 1.0d0,
1653  & 1.0d0, -10d0, 10d0, -40d0, 40d0,
1654  1 -40d0, 40d0, -40d0, 40d0, -40d0,
1655  1 40d0, -1.0d0, 1.0d0, -1.0d0, 1.0d0,
1656  2 0.0d0, 1.0d0, 0.0d0, 1.0d0, -1.0d0,
1657  2 1.0d0, -1.0d0, 1.0d0, 0d0, 0d0,
1658  3 2.0d0, -1.0d0, 0d0, 0d0, 0.0d0,
1659  3 -1.0d0, 0.0d0, -1.0d0, 4.0d0, -1.0d0,
1660  4 12.0d0, -1.0d0, 12.0d0, -1.0d0, 12.0d0,
1661  4 -1.0d0, 12.0d0, -1.0d0, 0d0, 0d0,
1662  5 0.0d0, -1.0d0, 0.0d0, -1.0d0, 0.0d0,
1663  5 -1.0d0, 0d0, 0d0, 0d0, 0d0,
1664  6 0.0001d0, 0.99d0, 0.0001d0, 0.99d0, 0d0,
1665  6 -1d0, 0d0, -1d0, 0d0, -1d0,
1666  7 0d0, -1d0, 0.0001d0, 0.99d0, 0.0001d0,
1667  7 0.99d0, 2d0, -1d0, 0d0, 0d0,
1668  8 120*0d0/
1669 
1670 C...Default values for main switches and parameters. Reset information.
1671  DATA (mstp(i),i=1,100)/
1672  & 3, 1, 2, 0, 0, 0, 0, 0, 0, 0,
1673  1 1, 0, 1, 30, 0, 1, 4, 3, 4, 3,
1674  2 1, 0, 1, 0, 0, 0, 0, 0, 0, 1,
1675  3 1, 8, 0, 1, 0, 2, 1, 5, 2, 0,
1676  4 2, 1, 3, 7, 3, 1, 1, 0, 1, 0,
1677  5 7, 1, 3, 1, 5, 1, 1, 5, 1, 7,
1678  6 2, 3, 2, 2, 1, 5, 2, 3, 0, 0,
1679  7 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
1680  8 1, 4, 100, 1, 1, 2, 4, 1, 1, 0,
1681  9 1, 3, 1, 3, 1, 0, 0, 0, 0, 0/
1682  DATA (mstp(i),i=101,200)/
1683  & 3, 1, 0, 0, 0, 0, 0, 0, 0, 0,
1684  1 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
1685  2 0, 1, 2, 1, 1, 100, 0, 0, 10, 0,
1686  3 0, 4, 0, 1, 0, 0, 0, 0, 0, 0,
1687  4 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
1688  5 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1689  6 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1690  7 0, 2, 0, 0, 0, 0, 0, 0, 0, 0,
1691  8 6, 425, 2011, 03, 23, 0, 0, 0, 0, 0,
1692  9 0, 0, 0, 0, 0, 0, 0, 0, 0, 0/
1693  DATA (parp(i),i=1,100)/
1694  & 0.25d0, 10d0, 8*0d0,
1695  1 0d0, 0d0, 1.0d0, 0.01d0, 0.5d0, 1.0d0, 1.0d0, 0.4d0, 2*0d0,
1696  2 10*0d0,
1697  3 1.5d0,2.0d0,0.075d0,1.0d0,0.2d0,0d0,1.0d0,0.70d0,0.006d0,0d0,
1698  4 0.02d0,2.0d0,0.10d0,1000d0,2054d0,123d0,246d0,50d0,0d0,0.054d0,
1699  5 10*0d0,
1700  6 0.25d0, 1.0d0,0.25d0, 1.0d0, 2.0d0,1d-3, 4.0d0,1d-3,2*0d0,
1701  7 4.0d0, 0.25d0, 5*0d0, 0.025d0, 2.0d0, 0.1d0,
1702  8 1.90d0, 2.0d0, 0.5d0, 0.4d0, 0.90d0,
1703  8 0.95d0, 0.7d0, 0.5d0, 1800d0, 0.25d0,
1704  9 2.0d0,0.40d0,5.0d0,1.0d0,0.0d0,3.0d0,1.0d0,0.75d0,1.0d0,5.0d0/
1705  DATA (parp(i),i=101,200)/
1706  & 0.5d0, 0.28d0, 1.0d0, 0.8d0, 0d0, 0d0, 0d0, 0d0, 0d0, 1d0,
1707  1 2.0d0, 3*0d0, 1.5d0, 0.5d0, 0.6d0, 2.5d0, 2.0d0, 1.0d0,
1708  2 1.0d0, 0.4d0, 8*0d0,
1709  3 0.01d0, 9*0d0,
1710  4 1.16d0, 0.0119d0, 0.01d0, 0.01d0, 0.05d0,
1711  4 9.28d0, 0.15d0, 0.02d0, 0.48d0, 0.09d0,
1712  5 0d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0, 0d0,
1713  6 2.20d0, 23.6d0, 18.4d0, 11.5d0, 0.5d0, 0d0, 0d0, 0d0, 2*0d0,
1714  7 0d0, 0d0, 0d0, 1.0d0, 6*0d0,
1715  8 0.1d0, 0.01d0, 0.01d0, 0.01d0, 0.1d0, 0.01d0, 0.01d0, 0.01d0,
1716  8 0.3d0, 0.64d0,
1717  9 0.64d0, 5.0d0, 1.0d4, 1.0d4, 6*0d0/
1718  DATA msti/200*0/
1719  DATA pari/200*0d0/
1720  DATA mint/400*0/
1721  DATA vint/400*0d0/
1722 
1723 C...Constants for the generation of the various processes.
1724  DATA (iset(i),i=1,100)/
1725  & 1, 1, 1, -1, 3, -1, -1, 3, -2, 2,
1726  1 2, 2, 2, 2, 2, 2, -1, 2, 2, 2,
1727  2 -1, 2, 2, 2, 2, 2, -1, 2, 2, 2,
1728  3 2, 2, 2, 2, 2, 2, -1, -1, -1, -1,
1729  4 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1730  5 -1, -1, 2, 2, -1, -1, -1, 2, -1, -1,
1731  6 -1, -1, -1, -1, -1, -1, -1, 2, 2, 2,
1732  7 4, 4, 4, -1, -1, 4, 4, -1, -1, 2,
1733  8 2, 2, 2, 2, 2, 2, 2, 2, 2, -2,
1734  9 0, 0, 0, 0, 0, 9, -2, -2, 8, -2/
1735  DATA (iset(i),i=101,200)/
1736  & -1, 1, 1, 1, 1, 2, 2, 2, -2, 2,
1737  1 2, 2, 2, 2, 2, -1, -1, -1, -2, -2,
1738  2 5, 5, 5, 5, -2, -2, -2, -2, -2, -2,
1739  3 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1740  4 1, 1, 1, 1, 1, 1, 1, 1, 1, -2,
1741  5 1, 1, 1, -2, -2, 1, 1, 1, -2, -2,
1742  6 2, 2, 2, 2, 2, 2, 2, 2, 2, -2,
1743  7 2, 2, 5, 5, -2, 2, 2, 5, 5, -2,
1744  8 5, 5, 2, 2, 2, 5, 5, 2, 2, 2,
1745  9 1, 1, 1, 2, 2, -2, -2, -2, -2, -2/
1746  DATA (iset(i),i=201,300)/
1747  & 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1748  1 2, 2, 2, 2, -2, 2, 2, 2, 2, 2,
1749  2 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1750  3 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1751  4 2, 2, 2, 2, -1, 2, 2, 2, 2, 2,
1752  5 2, 2, 2, 2, -1, 2, -1, 2, 2, -2,
1753  6 2, 2, 2, 2, 2, -1, -1, -1, -1, -1,
1754  7 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1755  8 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1756  9 2, 2, 2, 2, 2, 2, 2, 2, 2, 2/
1757  DATA (iset(i),i=301,500)/
1758  & 2, 9*-2, 9*2, 21*-2,
1759  4 1, 1, 2, 2, 2, 2, 2, 2, 2, 2,
1760  5 5, 5, 1, 1, -1, -1, -1, -1, -1, -1,
1761  6 2, 2, 2, 2, 2, 2, 2, 2, -1, 2,
1762  7 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1763  8 2, 2, 2, 2, 2, 2, 2, 2, -2, -2,
1764  9 1, 1, 2, 2, 2, 5*-2,
1765  & 5, 5, 18*-2,
1766  2 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1767  3 2, 2, 2, 2, 2, 2, 2, 2, 2, 21*-2,
1768  6 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1769  7 2, 2, 2, 2, 2, 2, 2, 2, 2, -2,
1770  8 2, 2, 18*-2/
1771  DATA ((kfpr(i,j),j=1,2),i=1,50)/
1772  & 23, 0, 24, 0, 25, 0, 24, 0, 25, 0,
1773  & 24, 0, 23, 0, 25, 0, 0, 0, 0, 0,
1774  1 0, 0, 0, 0, 21, 21, 21, 22, 21, 23,
1775  1 21, 24, 21, 25, 22, 22, 22, 23, 22, 24,
1776  2 22, 25, 23, 23, 23, 24, 23, 25, 24, 24,
1777  2 24, 25, 25, 25, 0, 21, 0, 22, 0, 23,
1778  3 0, 24, 0, 25, 0, 21, 0, 22, 0, 23,
1779  3 0, 24, 0, 25, 0, 21, 0, 22, 0, 23,
1780  4 0, 24, 0, 25, 0, 21, 0, 22, 0, 23,
1781  4 0, 24, 0, 25, 0, 21, 0, 22, 0, 23/
1782  DATA ((kfpr(i,j),j=1,2),i=51,100)/
1783  5 0, 24, 0, 25, 0, 0, 0, 0, 0, 0,
1784  5 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1785  6 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1786  6 0, 0, 0, 0, 21, 21, 24, 24, 23, 24,
1787  7 23, 23, 24, 24, 23, 24, 23, 25, 22, 22,
1788  7 23, 23, 24, 24, 24, 25, 25, 25, 0, 211,
1789  8 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1790  8 443, 21,10441, 21,20443, 21, 445, 21, 0, 0,
1791  9 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1792  9 0, 0, 0, 0, 0, 0, 0, 0, 0, 0/
1793  DATA ((kfpr(i,j),j=1,2),i=101,150)/
1794  & 23, 0, 25, 0, 25, 0,10441, 0, 445, 0,
1795  & 443, 22, 443, 21, 443, 22, 0, 0, 22, 25,
1796  1 21, 25, 0, 25, 21, 25, 22, 22, 21, 22,
1797  1 22, 23, 23, 23, 24, 24, 0, 0, 0, 0,
1798  2 25, 6, 25, 6, 25, 0, 25, 0, 0, 0,
1799  2 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1800  3 0, 21, 0, 21, 0, 22, 0, 22, 0, 0,
1801  3 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1802  4 32, 0, 34, 0, 37, 0, 41, 0, 42, 0,
1803  4 4000011, 0, 4000001, 0, 4000002, 0, 3000331, 0, 0, 0/
1804  DATA ((kfpr(i,j),j=1,2),i=151,200)/
1805  5 35, 0, 35, 0, 35, 0, 0, 0, 0, 0,
1806  5 36, 0, 36, 0, 36, 0, 0, 0, 0, 0,
1807  6 6, 37, 42, 0, 42, 42, 42, 42, 11, 0,
1808  6 11, 0, 0, 4000001, 0, 4000002, 0, 4000011, 0, 0,
1809  7 23, 35, 24, 35, 35, 0, 35, 0, 0, 0,
1810  7 23, 36, 24, 36, 36, 0, 36, 0, 0, 0,
1811  8 35, 6, 35, 6, 21, 35, 0, 35, 21, 35,
1812  8 36, 6, 36, 6, 21, 36, 0, 36, 21, 36,
1813  9 3000113, 0, 3000213, 0, 3000223, 0, 11, 0, 11, 0,
1814  9 0, 0, 0, 0, 0, 0, 0, 0, 0, 0/
1815  DATA ((kfpr(i,j),j=1,2),i=201,240)/
1816  & 1000011, 1000011, 2000011, 2000011, 1000011,
1817  & 2000011, 1000013, 1000013, 2000013, 2000013,
1818  & 1000013, 2000013, 1000015, 1000015, 2000015,
1819  & 2000015, 1000015, 2000015, 1000011, 1000012,
1820  1 1000015, 1000016, 2000015, 1000016, 1000012,
1821  1 1000012, 1000016, 1000016, 0, 0,
1822  1 1000022, 1000022, 1000023, 1000023, 1000025,
1823  1 1000025, 1000035, 1000035, 1000022, 1000023,
1824  2 1000022, 1000025, 1000022, 1000035, 1000023,
1825  2 1000025, 1000023, 1000035, 1000025, 1000035,
1826  2 1000024, 1000024, 1000037, 1000037, 1000024,
1827  2 1000037, 1000022, 1000024, 1000023, 1000024,
1828  3 1000025, 1000024, 1000035, 1000024, 1000022,
1829  3 1000037, 1000023, 1000037, 1000025, 1000037,
1830  3 1000035, 1000037, 1000021, 1000022, 1000021,
1831  3 1000023, 1000021, 1000025, 1000021, 1000035/
1832  DATA ((kfpr(i,j),j=1,2),i=241,280)/
1833  4 1000021, 1000024, 1000021, 1000037, 1000021,
1834  4 1000021, 1000021, 1000021, 0, 0,
1835  4 1000002, 1000022, 2000002, 1000022, 1000002,
1836  4 1000023, 2000002, 1000023, 1000002, 1000025,
1837  5 2000002, 1000025, 1000002, 1000035, 2000002,
1838  5 1000035, 1000001, 1000024, 2000005, 1000024,
1839  5 1000001, 1000037, 2000005, 1000037, 1000002,
1840  5 1000021, 2000002, 1000021, 0, 0,
1841  6 1000006, 1000006, 2000006, 2000006, 1000006,
1842  6 2000006, 1000006, 1000006, 2000006, 2000006,
1843  6 0, 0, 0, 0, 0,
1844  6 0, 0, 0, 0, 0,
1845  7 1000002, 1000002, 2000002, 2000002, 1000002,
1846  7 2000002, 1000002, 1000002, 2000002, 2000002,
1847  7 1000002, 2000002, 1000002, 1000002, 2000002,
1848  7 2000002, 1000002, 1000002, 2000002, 2000002/
1849  DATA ((kfpr(i,j),j=1,2),i=281,350)/
1850  8 1000005, 1000002, 2000005, 2000002, 1000005,
1851  8 2000002, 1000005, 1000002, 2000005, 2000002,
1852  8 1000005, 2000002, 1000005, 1000005, 2000005,
1853  8 2000005, 1000005, 1000005, 2000005, 2000005,
1854  9 1000005, 1000005, 2000005, 2000005, 1000005,
1855  9 2000005, 1000005, 1000021, 2000005, 1000021,
1856  9 1000005, 2000005, 37, 25, 37,
1857  9 35, 36, 25, 36, 35,
1858  & 37, 37, 18*0,
1859 C...UED: 311-319
1860  & 5100021, 5100021,
1861  & 5100002, 5100021,
1862  & 5100002, 5100001,
1863  & 5100002, -5100002,
1864  & 5100002, -5100002,
1865  & 5100002, -6100001,
1866  & 5100002, -5100001,
1867  & 5100002, 6100001,
1868  & 5100001, -5100001,
1869  & 42*0,
1870  4 9900041, 0, 9900042, 0, 9900041,
1871  4 11, 9900042, 11, 9900041, 13,
1872  4 9900042, 13, 9900041, 15, 9900042,
1873  4 15, 9900041, 9900041, 9900042, 9900042/
1874  DATA ((kfpr(i,j),j=1,2),i=351,400)/
1875  5 9900041, 0, 9900042, 0, 9900023,
1876  5 0, 9900024, 0, 0, 0,
1877  5 0, 0, 0, 0, 0,
1878  5 0, 0, 0, 0, 0,
1879  6 24, 24, 24, 3000211, 3000211,
1880  6 3000211, 22, 3000111, 22, 3000221,
1881  6 23, 3000111, 23, 3000221, 24,
1882  6 3000211, 0, 0, 24, 23,
1883  7 24, 3000111, 3000211, 23, 3000211,
1884  7 3000111, 22, 3000211, 23, 3000211,
1885  7 24, 3000111, 24, 3000221, 22,
1886  7 24, 22, 23, 23, 23,
1887  8 0, 0, 0, 0, 21, 21, 0, 21, 0, 0,
1888  8 21, 21, 0, 0, 0, 0, 0, 0, 0, 0,
1889  9 5000039, 0, 5000039, 0, 21,
1890  9 5000039, 0, 5000039, 21, 5000039,
1891  9 10*0/
1892  DATA ((kfpr(i,j),j=1,2),i=401,500)/
1893  & 37, 6, 37, 6, 36*0,
1894  2 443, 21, 9900443, 21, 9900441,
1895  2 21, 9910441, 21, 0, 9900443,
1896  2 0, 9900441, 0, 9910441, 21,
1897  2 9900443, 21, 9900441, 21, 9910441,
1898  3 10441, 21, 20443, 21, 445, 21, 0, 10441, 0, 20443,
1899  3 0, 445, 21, 10441, 21, 20443, 21, 445, 42*0,
1900  6 553, 21, 9900553, 21, 9900551,
1901  6 21, 9910551, 21, 0, 9900553,
1902  6 0, 9900551, 0, 9910551, 21,
1903  6 9900553, 21, 9900551, 21, 9910551,
1904  7 10551, 21, 20553, 21, 555, 21, 0, 10551, 0, 20553,
1905  7 0, 555, 21, 10551, 21, 20553, 21, 555, 42*0/
1906  DATA coef/10000*0d0/
1907  DATA (((icol(i,j,k),k=1,2),j=1,4),i=1,40)/
1908  &4,0,3,0,2,0,1,0,3,0,4,0,1,0,2,0,2,0,0,1,4,0,0,3,3,0,0,4,1,0,0,2,
1909  &3,0,0,4,1,4,3,2,4,0,0,3,4,2,1,3,2,0,4,1,4,0,2,3,4,0,3,4,2,0,1,2,
1910  &3,2,1,0,1,4,3,0,4,3,3,0,2,1,1,0,3,2,1,4,1,0,0,2,2,4,3,1,2,0,0,1,
1911  &3,2,1,4,1,4,3,2,4,2,1,3,4,2,1,3,3,4,4,3,1,2,2,1,2,0,3,1,2,0,0,0,
1912  &4,2,1,0,0,0,1,0,3,0,0,3,1,2,0,0,4,0,0,4,0,0,1,2,2,0,0,1,4,4,3,3,
1913  &2,2,1,1,4,4,3,3,3,3,4,4,1,1,2,2,3,2,1,3,1,2,0,0,4,2,1,4,0,0,1,2,
1914  &4,0,0,0,4,0,1,3,0,0,3,0,2,4,3,0,3,4,0,0,1,0,0,1,0,0,3,4,2,0,0,2,
1915  &3,0,0,0,1,0,0,0,0,0,3,0,2,0,0,0,2,0,3,1,2,0,0,0,3,2,1,0,1,0,0,0,
1916  &4,4,3,3,2,2,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1917  &0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0/
1918 
1919 C...Treatment of resonances.
1920  DATA (mwid(i) ,i= 1, 500)/5*0,3*1,8*0,1,5*0,3*1,6*0,1,0,4*1,
1921  &3*0,2*1,254*0,19*2,0,7*2,0,2,0,2,0,26*1,7*0,6*2,2*1,
1922  &81*0,21*1,4*1,25*0/
1923 
1924 C...Character constants: name of processes.
1925  DATA proc(0)/ 'All included subprocesses '/
1926  DATA (proc(i),i=1,20)/
1927  &'f + fbar -> gamma*/Z0 ', 'f + fbar'' -> W+/- ',
1928  &'f + fbar -> h0 ', 'gamma + W+/- -> W+/- ',
1929  &'Z0 + Z0 -> h0 ', 'Z0 + W+/- -> W+/- ',
1930  &' ', 'W+ + W- -> h0 ',
1931  &' ', 'f + f'' -> f + f'' (QFD) ',
1932  1'f + f'' -> f + f'' (QCD) ','f + fbar -> f'' + fbar'' ',
1933  1'f + fbar -> g + g ', 'f + fbar -> g + gamma ',
1934  1'f + fbar -> g + Z0 ', 'f + fbar'' -> g + W+/- ',
1935  1'f + fbar -> g + h0 ', 'f + fbar -> gamma + gamma ',
1936  1'f + fbar -> gamma + Z0 ', 'f + fbar'' -> gamma + W+/- '/
1937  DATA (proc(i),i=21,40)/
1938  2'f + fbar -> gamma + h0 ', 'f + fbar -> Z0 + Z0 ',
1939  2'f + fbar'' -> Z0 + W+/- ', 'f + fbar -> Z0 + h0 ',
1940  2'f + fbar -> W+ + W- ', 'f + fbar'' -> W+/- + h0 ',
1941  2'f + fbar -> h0 + h0 ', 'f + g -> f + g ',
1942  2'f + g -> f + gamma ', 'f + g -> f + Z0 ',
1943  3'f + g -> f'' + W+/- ', 'f + g -> f + h0 ',
1944  3'f + gamma -> f + g ', 'f + gamma -> f + gamma ',
1945  3'f + gamma -> f + Z0 ', 'f + gamma -> f'' + W+/- ',
1946  3'f + gamma -> f + h0 ', 'f + Z0 -> f + g ',
1947  3'f + Z0 -> f + gamma ', 'f + Z0 -> f + Z0 '/
1948  DATA (proc(i),i=41,60)/
1949  4'f + Z0 -> f'' + W+/- ', 'f + Z0 -> f + h0 ',
1950  4'f + W+/- -> f'' + g ', 'f + W+/- -> f'' + gamma ',
1951  4'f + W+/- -> f'' + Z0 ', 'f + W+/- -> f'' + W+/- ',
1952  4'f + W+/- -> f'' + h0 ', 'f + h0 -> f + g ',
1953  4'f + h0 -> f + gamma ', 'f + h0 -> f + Z0 ',
1954  5'f + h0 -> f'' + W+/- ', 'f + h0 -> f + h0 ',
1955  5'g + g -> f + fbar ', 'g + gamma -> f + fbar ',
1956  5'g + Z0 -> f + fbar ', 'g + W+/- -> f + fbar'' ',
1957  5'g + h0 -> f + fbar ', 'gamma + gamma -> f + fbar ',
1958  5'gamma + Z0 -> f + fbar ', 'gamma + W+/- -> f + fbar'' '/
1959  DATA (proc(i),i=61,80)/
1960  6'gamma + h0 -> f + fbar ', 'Z0 + Z0 -> f + fbar ',
1961  6'Z0 + W+/- -> f + fbar'' ', 'Z0 + h0 -> f + fbar ',
1962  6'W+ + W- -> f + fbar ', 'W+/- + h0 -> f + fbar'' ',
1963  6'h0 + h0 -> f + fbar ', 'g + g -> g + g ',
1964  6'gamma + gamma -> W+ + W- ', 'gamma + W+/- -> Z0 + W+/- ',
1965  7'Z0 + Z0 -> Z0 + Z0 ', 'Z0 + Z0 -> W+ + W- ',
1966  7'Z0 + W+/- -> Z0 + W+/- ', 'Z0 + Z0 -> Z0 + h0 ',
1967  7'W+ + W- -> gamma + gamma ', 'W+ + W- -> Z0 + Z0 ',
1968  7'W+/- + W+/- -> W+/- + W+/- ', 'W+/- + h0 -> W+/- + h0 ',
1969  7'h0 + h0 -> h0 + h0 ', 'q + gamma -> q'' + pi+/- '/
1970  DATA (proc(i),i=81,100)/
1971  8'q + qbar -> Q + Qbar, mass ', 'g + g -> Q + Qbar, massive ',
1972  8'f + q -> f'' + Q, massive ', 'g + gamma -> Q + Qbar, mass ',
1973  8'gamma + gamma -> F + Fbar, m', 'g + g -> J/Psi + g ',
1974  8'g + g -> chi_0c + g ', 'g + g -> chi_1c + g ',
1975  8'g + g -> chi_2c + g ', ' ',
1976  9'Elastic scattering ', 'Single diffractive (XB) ',
1977  9'Single diffractive (AX) ', 'Double diffractive ',
1978  9'Low-pT scattering ', 'Semihard QCD 2 -> 2 ',
1979  9' ', ' ',
1980  9'q + gamma* -> q ', ' '/
1981  DATA (proc(i),i=101,120)/
1982  &'g + g -> gamma*/Z0 ', 'g + g -> h0 ',
1983  &'gamma + gamma -> h0 ', 'g + g -> chi_0c ',
1984  &'g + g -> chi_2c ', 'g + g -> J/Psi + gamma ',
1985  &'gamma + g -> J/Psi + g ', 'gamma+gamma -> J/Psi + gamma',
1986  &' ', 'f + fbar -> gamma + h0 ',
1987  1'q + qbar -> g + h0 ', 'q + g -> q + h0 ',
1988  1'g + g -> g + h0 ', 'g + g -> gamma + gamma ',
1989  1'g + g -> g + gamma ', 'g + g -> gamma + Z0 ',
1990  1'g + g -> Z0 + Z0 ', 'g + g -> W+ + W- ',
1991  1' ', ' '/
1992  DATA (proc(i),i=121,140)/
1993  2'g + g -> Q + Qbar + h0 ', 'q + qbar -> Q + Qbar + h0 ',
1994  2'f + f'' -> f + f'' + h0 ',
1995  2'f + f'' -> f" + f"'' + h0 ',
1996  2' ', ' ',
1997  2' ', ' ',
1998  2' ', ' ',
1999  3'f + gamma*_T -> f + g ', 'f + gamma*_L -> f + g ',
2000  3'f + gamma*_T -> f + gamma ', 'f + gamma*_L -> f + gamma ',
2001  3'g + gamma*_T -> f + fbar ', 'g + gamma*_L -> f + fbar ',
2002  3'gamma*_T+gamma*_T -> f+fbar ', 'gamma*_T+gamma*_L -> f+fbar ',
2003  3'gamma*_L+gamma*_T -> f+fbar ', 'gamma*_L+gamma*_L -> f+fbar '/
2004  DATA (proc(i),i=141,160)/
2005  4'f + fbar -> gamma*/Z0/Z''0 ', 'f + fbar'' -> W''+/- ',
2006  4'f + fbar'' -> H+/- ', 'f + fbar'' -> R ',
2007  4'q + l -> LQ ', 'e + gamma -> e* ',
2008  4'd + g -> d* ', 'u + g -> u* ',
2009  4'g + g -> eta_tc ', ' ',
2010  5'f + fbar -> H0 ', 'g + g -> H0 ',
2011  5'gamma + gamma -> H0 ', ' ',
2012  5' ', 'f + fbar -> A0 ',
2013  5'g + g -> A0 ', 'gamma + gamma -> A0 ',
2014  5' ', ' '/
2015  DATA (proc(i),i=161,180)/
2016  6'f + g -> f'' + H+/- ', 'q + g -> LQ + lbar ',
2017  6'g + g -> LQ + LQbar ', 'q + qbar -> LQ + LQbar ',
2018  6'f + fbar -> f'' + fbar'' (g/Z)',
2019  6'f +fbar'' -> f" + fbar"'' (W) ',
2020  6'q + q'' -> q" + d* ', 'q + q'' -> q" + u* ',
2021  6'q + qbar -> e + e* ', ' ',
2022  7'f + fbar -> Z0 + H0 ', 'f + fbar'' -> W+/- + H0 ',
2023  7'f + f'' -> f + f'' + H0 ',
2024  7'f + f'' -> f" + f"'' + H0 ',
2025  7' ', 'f + fbar -> Z0 + A0 ',
2026  7'f + fbar'' -> W+/- + A0 ',
2027  7'f + f'' -> f + f'' + A0 ',
2028  7'f + f'' -> f" + f"'' + A0 ',
2029  7' '/
2030  DATA (proc(i),i=181,200)/
2031  8'g + g -> Q + Qbar + H0 ', 'q + qbar -> Q + Qbar + H0 ',
2032  8'q + qbar -> g + H0 ', 'q + g -> q + H0 ',
2033  8'g + g -> g + H0 ', 'g + g -> Q + Qbar + A0 ',
2034  8'q + qbar -> Q + Qbar + A0 ', 'q + qbar -> g + A0 ',
2035  8'q + g -> q + A0 ', 'g + g -> g + A0 ',
2036  9'f + fbar -> rho_tc0 ', 'f + f'' -> rho_tc+/- ',
2037  9'f + fbar -> omega_tc0 ', 'f+fbar -> f''+fbar'' (ETC) ',
2038  9'f+fbar'' -> f"+fbar"'' (ETC)',' ',
2039  9' ', ' ',
2040  9' ', ' '/
2041  DATA (proc(i),i=201,220)/
2042  &'f + fbar -> ~e_L + ~e_Lbar ', 'f + fbar -> ~e_R + ~e_Rbar ',
2043  &'f + fbar -> ~e_R + ~e_Lbar ', 'f + fbar -> ~mu_L + ~mu_Lbar',
2044  &'f + fbar -> ~mu_R + ~mu_Rbar', 'f + fbar -> ~mu_L + ~mu_Rbar',
2045  &'f+fbar -> ~tau_1 + ~tau_1bar', 'f+fbar -> ~tau_2 + ~tau_2bar',
2046  &'f+fbar -> ~tau_1 + ~tau_2bar', 'q + qbar'' -> ~l_L + ~nulbar ',
2047  1'q+qbar''-> ~tau_1 + ~nutaubar', 'q+qbar''-> ~tau_2 + ~nutaubar',
2048  1'f + fbar -> ~nul + ~nulbar ', 'f+fbar -> ~nutau + ~nutaubar',
2049  1' ', 'f + fbar -> ~chi1 + ~chi1 ',
2050  1'f + fbar -> ~chi2 + ~chi2 ', 'f + fbar -> ~chi3 + ~chi3 ',
2051  1'f + fbar -> ~chi4 + ~chi4 ', 'f + fbar -> ~chi1 + ~chi2 '/
2052  DATA (proc(i),i=221,240)/
2053  2'f + fbar -> ~chi1 + ~chi3 ', 'f + fbar -> ~chi1 + ~chi4 ',
2054  2'f + fbar -> ~chi2 + ~chi3 ', 'f + fbar -> ~chi2 + ~chi4 ',
2055  2'f + fbar -> ~chi3 + ~chi4 ', 'f+fbar -> ~chi+-1 + ~chi-+1 ',
2056  2'f+fbar -> ~chi+-2 + ~chi-+2 ', 'f+fbar -> ~chi+-1 + ~chi-+2 ',
2057  2'q + qbar'' -> ~chi1 + ~chi+-1', 'q + qbar'' -> ~chi2 + ~chi+-1',
2058  3'q + qbar'' -> ~chi3 + ~chi+-1', 'q + qbar'' -> ~chi4 + ~chi+-1',
2059  3'q + qbar'' -> ~chi1 + ~chi+-2', 'q + qbar'' -> ~chi2 + ~chi+-2',
2060  3'q + qbar'' -> ~chi3 + ~chi+-2', 'q + qbar'' -> ~chi4 + ~chi+-2',
2061  3'q + qbar -> ~chi1 + ~g ', 'q + qbar -> ~chi2 + ~g ',
2062  3'q + qbar -> ~chi3 + ~g ', 'q + qbar -> ~chi4 + ~g '/
2063  DATA (proc(i),i=241,260)/
2064  4'q + qbar'' -> ~chi+-1 + ~g ', 'q + qbar'' -> ~chi+-2 + ~g ',
2065  4'q + qbar -> ~g + ~g ', 'g + g -> ~g + ~g ',
2066  4' ', 'qj + g -> ~qj_L + ~chi1 ',
2067  4'qj + g -> ~qj_R + ~chi1 ', 'qj + g -> ~qj_L + ~chi2 ',
2068  4'qj + g -> ~qj_R + ~chi2 ', 'qj + g -> ~qj_L + ~chi3 ',
2069  5'qj + g -> ~qj_R + ~chi3 ', 'qj + g -> ~qj_L + ~chi4 ',
2070  5'qj + g -> ~qj_R + ~chi4 ', 'qj + g -> ~qk_L + ~chi+-1 ',
2071  5'qj + g -> ~qk_R + ~chi+-1 ', 'qj + g -> ~qk_L + ~chi+-2 ',
2072  5'qj + g -> ~qk_R + ~chi+-2 ', 'qj + g -> ~qj_L + ~g ',
2073  5'qj + g -> ~qj_R + ~g ', ' '/
2074  DATA (proc(i),i=261,300)/
2075  6'f + fbar -> ~t_1 + ~t_1bar ', 'f + fbar -> ~t_2 + ~t_2bar ',
2076  6'f + fbar -> ~t_1 + ~t_2bar ', 'g + g -> ~t_1 + ~t_1bar ',
2077  6'g + g -> ~t_2 + ~t_2bar ', ' ',
2078  6' ', ' ',
2079  6' ', ' ',
2080  7'qi + qj -> ~qi_L + ~qj_L ', 'qi + qj -> ~qi_R + ~qj_R ',
2081  7'qi + qj -> ~qi_L + ~qj_R ', 'qi+qjbar -> ~qi_L + ~qj_Lbar',
2082  7'qi+qjbar -> ~qi_R + ~qj_Rbar', 'qi+qjbar -> ~qi_L + ~qj_Rbar',
2083  7'f + fbar -> ~qi_L + ~qi_Lbar', 'f + fbar -> ~qi_R + ~qi_Rbar',
2084  7'g + g -> ~qi_L + ~qi_Lbar ', 'g + g -> ~qi_R + ~qi_Rbar ',
2085  8'b + qj -> ~b_1 + ~qj_L ', 'b + qj -> ~b_2 + ~qj_R ',
2086  8'b + qj -> ~b_1 + ~qj_R ', 'b + qjbar -> ~b_1 + ~qj_Lbar',
2087  8'b + qjbar -> ~b_2 + ~qj_Rbar', 'b + qjbar -> ~b_1 + ~qj_Rbar',
2088  8'f + fbar -> ~b_1 + ~b_1bar ', 'f + fbar -> ~b_2 + ~b_2bar ',
2089  8'g + g -> ~b_1 + ~b_1bar ', 'g + g -> ~b_2 + ~b_2bar ',
2090  9'b + b -> ~b_1 + ~b_1 ', 'b + b -> ~b_2 + ~b_2 ',
2091  9'b + b -> ~b_1 + ~b_2 ', 'b + g -> ~b_1 + ~g ',
2092  9'b + g -> ~b_2 + ~g ', 'b + bbar -> ~b_1 + ~b_2bar ',
2093  9'f + fbar'' -> H+/- + h0 ', 'f + fbar -> H+/- + H0 ',
2094  9'f + fbar -> A0 + h0 ', 'f + fbar -> A0 + H0 '/
2095  DATA (proc(i),i=301,340)/
2096  &'f + fbar -> H+ + H- ',
2097  &9*' ', 'g + g -> g* + g* ',
2098  &'q + g -> q*_D + g* ', 'qi + qj -> q*_Di + q*_Dj ',
2099  &'g + g -> q*_D + q*_Dbar ', 'q + qbar -> q*_D + q*_Dbar ',
2100  &'qi + qbarj -> q*Di + q*Sbarj', 'qi + qjbar -> q*Di + q*Dbarj',
2101  &'qi + qj -> q*_Di + q*_Sj ', 'qi + qibar -> q*Dj + q*Dbarj',
2102  &21*' '/
2103  DATA (proc(i),i=341,380)/
2104  4'l + l -> H_L++/-- ', 'l + l -> H_R++/-- ',
2105  4'l + gamma -> H_L++/-- e-/+ ', 'l + gamma -> H_R++/-- e-/+ ',
2106  4'l + gamma -> H_L++/-- mu-/+ ', 'l + gamma -> H_R++/-- mu-/+ ',
2107  4'l + gamma -> H_L++/-- tau-/+', 'l + gamma -> H_R++/-- tau-/+',
2108  4'f + fbar -> H_L++ + H_L-- ', 'f + fbar -> H_R++ + H_R-- ',
2109  5'f + f -> f'' + f'' + H_L++/-- ',
2110  5'f + f -> f'' + f'' + H_R++/-- ','f + fbar -> Z_R0 ',
2111  5'f + fbar'' -> W_R+/- ',5*' ',
2112  6' ', 'f + fbar -> W_L+ W_L- ',
2113  6'f + fbar -> W_L+/- pi_T-/+ ', 'f + fbar -> pi_T+ pi_T- ',
2114  6'f + fbar -> gamma pi_T0 ', 'f + fbar -> gamma pi_T0'' ',
2115  6'f + fbar -> Z0 pi_T0 ', 'f + fbar -> Z0 pi_T0'' ',
2116  6'f + fbar -> W+/- pi_T-/+ ', ' ',
2117  7'f + fbar'' -> W_L+/- Z_L0 ', 'f + fbar'' -> W_L+/- pi_T0 ',
2118  7'f + fbar'' -> pi_T+/- Z_L0 ', 'f + fbar'' -> pi_T+/- pi_T0 ',
2119  7'f + fbar'' -> gamma pi_T+/- ', 'f + fbar'' -> Z0 pi_T+/- ',
2120  7'f + fbar'' -> W+/- pi_T0 ',
2121  7'f + fbar'' -> W+/- pi_T0'' ',
2122  7'f + fbar'' -> gamma W+/-(ETC)','f + fbar -> gamma Z0 (ETC)',
2123  7'f + fbar -> Z0 Z0 (ETC) '/
2124  DATA (proc(i),i=381,420)/
2125  8'f + f'' -> f + f'' (ETC) ','f + fbar -> f'' + fbar'' (ETC)',
2126  8'f + fbar -> g + g (ETC) ', 'f + g -> f + g (ETC) ',
2127  8'g + g -> f + fbar (ETC) ', 'g + g -> g + g (ETC) ',
2128  8'q + qbar -> Q + Qbar (ETC) ', 'g + g -> Q + Qbar (ETC) ',
2129  8' ', ' ',
2130  9'f + fbar -> G* ', 'g + g -> G* ',
2131  9'q + qbar -> g + G* ', 'q + g -> q + G* ',
2132  9'g + g -> g + G* ', ' ',
2133  9 4*' ',
2134  &'g + g -> t + b + H+/- ', 'q + qbar -> t + b + H+/- ',
2135  & 18*' '/
2136  DATA (proc(i),i=421,460)/
2137  2'g + g -> cc~[3S1(1)] + g ', 'g + g -> cc~[3S1(8)] + g ',
2138  2'g + g -> cc~[1S0(8)] + g ', 'g + g -> cc~[3PJ(8)] + g ',
2139  2'g + q -> q + cc~[3S1(8)] ', 'g + q -> q + cc~[1S0(8)] ',
2140  2'g + q -> q + cc~[3PJ(8)] ', 'q + q~ -> g + cc~[3S1(8)] ',
2141  2'q + q~ -> g + cc~[1S0(8)] ', 'q + q~ -> g + cc~[3PJ(8)] ',
2142  3'g + g -> cc~[3P0(1)] + g ', 'g + g -> cc~[3P1(1)] + g ',
2143  3'g + g -> cc~[3P2(1)] + g ', 'q + g -> q + cc~[3P0(1)] ',
2144  3'q + g -> q + cc~[3P1(1)] ', 'q + g -> q + cc~[3P2(1)] ',
2145  3'q + q~ -> g + cc~[3P0(1)] ', 'q + q~ -> g + cc~[3P1(1)] ',
2146  3'q + q~ -> g + cc~[3P2(1)] ',
2147  3 21 *' '/
2148  DATA (proc(i),i=461,500)/
2149  6'g + g -> bb~[3S1(1)] + g ', 'g + g -> bb~[3S1(8)] + g ',
2150  6'g + g -> bb~[1S0(8)] + g ', 'g + g -> bb~[3PJ(8)] + g ',
2151  6'g + q -> q + bb~[3S1(8)] ', 'g + q -> q + bb~[1S0(8)] ',
2152  6'g + q -> q + bb~[3PJ(8)] ', 'q + q~ -> g + bb~[3S1(8)] ',
2153  6'q + q~ -> g + bb~[1S0(8)] ', 'q + q~ -> g + bb~[3PJ(8)] ',
2154  7'g + g -> bb~[3P0(1)] + g ', 'g + g -> bb~[3P1(1)] + g ',
2155  7'g + g -> bb~[3P2(1)] + g ', 'q + g -> q + bb~[3P0(1)] ',
2156  7'q + g -> q + bb~[3P1(1)] ', 'q + g -> q + bb~[3P2(1)] ',
2157  7'q + q~ -> g + bb~[3P0(1)] ', 'q + q~ -> g + bb~[3P1(1)] ',
2158  7'q + q~ -> g + bb~[3P2(1)] ',
2159  7 21 *' '/
2160 
2161 C...Cross sections and slope offsets.
2162  DATA sigt/294*0d0/
2163 
2164 C...Supersymmetry switches and parameters.
2165  DATA imss/0,
2166  & 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
2167  1 89*0/
2168  DATA rmss/0d0,
2169  & 80d0,160d0,500d0,800d0,2d0,250d0,200d0,800d0,700d0,800d0,
2170  1 700d0,500d0,250d0,200d0,800d0,400d0,0d0,0.1d0,850d0,0.041d0,
2171  2 1d0,800d0,1d4,1d4,1d4,0d0,0d0,0d0,24d17,0d0,
2172  3 10*0d0,
2173  4 0d0,1d0,8*0d0,
2174  5 49*0d0/
2175 C...Initial values for R-violating SUSY couplings.
2176 C...Should not be changed here. See PYMSIN.
2177  DATA rvlam/27*0d0/
2178  DATA rvlamp/27*0d0/
2179  DATA rvlamb/27*0d0/
2180 
2181 C...Technicolor switches and parameters
2182  DATA itcm/0,
2183  & 4, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2184  1 89*0/
2185  DATA rtcm/0d0,
2186  & 82d0,1.333d0,.333d0,0.408d0,1d0,1d0,.0182d0,1d0,0d0,1.333d0,
2187  1 .05d0,200d0,200d0,0d0,0d0,0d0,0d0,0d0,0d0,0d0,
2188  2 .283d0,.707d0,0d0,0d0,0d0,1.667d0,250d0,250d0,.707d0,0d0,
2189  3 .707d0,0d0,1d0,0d0,0d0,0d0,0d0,0d0,0d0,0d0,
2190  4 1000d0, 1d0, 1d0, 1d0, 1d0, 0d0, 1d0, 3*200d0,
2191  4 200d0, 48*0d0/
2192 
2193 C...UED switches and parameters.
2194 C... IUED(0) empty IUED vector element
2195 C... IUED(1) UED ON(=1)/OFF(=0) switch
2196 C... IUED(2) ON(=1)/OFF(=0) switch for gravity mediated decays
2197 C... IUED(3) NFLAVOURS Number of KK excitation quark flavours
2198 C... IUED(4) N the number of large extra dimensions
2199 C... IUED(5) Selects whether the code takes Lambda (=0)
2200 C... or Lambda*R (=1) as input.
2201 C... IUED(6) With radiative corrections to the masses (=1)
2202 C... or without (=0)
2203 C...
2204 C... RUED(0) empty RUED vector element
2205 C... RUED(1) RINV (1/R) the curvature of the extra dimension
2206 C... RUED(2) XMD the (4+N)-dimensional Planck scale
2207 C... RUED(3) LAMUED (Lambda cutoff scale)
2208 C... RUED(4) LAMUED/RINV (feasible values are order of 10-20)
2209 C...
2210  DATA iued/0,0,0,5,6,0,1,93*0/
2211  DATA rued/0.d0,1000d0,5000d0,20000.,20.,95*0d0/
2212 
2213 C...Data for histogramming routines.
2214  DATA ihist/1000,20000,55,1/
2215  DATA indx/1000*0/
2216 
2217 C...Data for SUSY Les Houches Accord.
2218  DATA cpro/'PYTHIA ','PYTHIA '/
2219  DATA cver/'6.4 ','6.4 '/
2220  DATA modsel/200*0/
2221  DATA parmin/100*0d0/
2222  DATA rmsoft/101*0d0/
2223  DATA au/9*0d0/
2224  DATA ad/9*0d0/
2225  DATA ae/9*0d0/
2226 
2227  END
2228 
2229 C*********************************************************************
2230 
2231 C...PYCKBD
2232 C...Check that BLOCK DATA PYDATA has been loaded.
2233 C...Should not be required, except that some compilers/linkers
2234 C...are pretty buggy in this respect.
2235 
2236  SUBROUTINE pyckbd
2237 
2238 C...Double precision and integer declarations.
2239  IMPLICIT DOUBLE PRECISION(a-h, o-z)
2240  IMPLICIT INTEGER(i-n)
2241  INTEGER pyk,pychge,pycomp
2242 C...Commonblocks.
2243  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
2244  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
2245  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
2246  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
2247  common/pysubs/msel,mselpd,msub(500),kfin(2,-40:40),ckin(200)
2248  common/pypars/mstp(200),parp(200),msti(200),pari(200)
2249  SAVE /pyjets/,/pydat1/,/pydat2/,/pydat3/,/pysubs/,/pypars/
2250 
2251 C...Check a few variables to see they have been sensibly initialized.
2252  IF(mstu(4).LT.10.OR.mstu(4).GT.900000.OR.pmas(2,1).LT.0.001d0
2253  &.OR.pmas(2,1).GT.1d0.OR.ckin(5).LT.0.01d0.OR.mstp(1).LT.1.OR.
2254  &mstp(1).GT.5) THEN
2255 C...If not, abort the run right away.
2256  WRITE(*,*) 'Fatal error: BLOCK DATA PYDATA has not been loaded!'
2257  WRITE(*,*) 'The program execution is stopped now!'
2258  CALL pystop(8)
2259  ENDIF
2260 
2261  RETURN
2262  END
2263 
2264 C*********************************************************************
2265 
2266 C...PYTEST
2267 C...A simple program (disguised as subroutine) to run at installation
2268 C...as a check that the program works as intended.
2269 
2270  SUBROUTINE pytest(MTEST)
2271 
2272 C...Double precision and integer declarations.
2273  IMPLICIT DOUBLE PRECISION(a-h, o-z)
2274  IMPLICIT INTEGER(i-n)
2275  INTEGER pyk,pychge,pycomp
2276 C...Commonblocks.
2277  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
2278  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
2279  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
2280  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
2281  common/pysubs/msel,mselpd,msub(500),kfin(2,-40:40),ckin(200)
2282  common/pypars/mstp(200),parp(200),msti(200),pari(200)
2283  SAVE /pyjets/,/pydat1/,/pydat2/,/pydat3/,/pysubs/,/pypars/
2284 C...Local arrays.
2285  dimension psum(5),pini(6),pfin(6)
2286 
2287 C...Save defaults for values that are changed.
2288  mstj1=mstj(1)
2289  mstj3=mstj(3)
2290  mstj11=mstj(11)
2291  mstj42=mstj(42)
2292  mstj43=mstj(43)
2293  mstj44=mstj(44)
2294  parj17=parj(17)
2295  parj22=parj(22)
2296  parj43=parj(43)
2297  parj54=parj(54)
2298  mst101=mstj(101)
2299  mst104=mstj(104)
2300  mst105=mstj(105)
2301  mst107=mstj(107)
2302  mst116=mstj(116)
2303 
2304 C...First part: loop over simple events to be generated.
2305  IF(mtest.GE.1) CALL pytabu(20)
2306  nerr=0
2307  DO 180 iev=1,500
2308 
2309 C...Reset parameter values. Switch on some nonstandard features.
2310  mstj(1)=1
2311  mstj(3)=0
2312  mstj(11)=1
2313  mstj(42)=2
2314  mstj(43)=4
2315  mstj(44)=2
2316  parj(17)=0.1d0
2317  parj(22)=1.5d0
2318  parj(43)=1d0
2319  parj(54)=-0.05d0
2320  mstj(101)=5
2321  mstj(104)=5
2322  mstj(105)=0
2323  mstj(107)=1
2324  IF(iev.EQ.301.OR.iev.EQ.351.OR.iev.EQ.401) mstj(116)=3
2325 
2326 C...Ten events each for some single jets configurations.
2327  IF(iev.LE.50) THEN
2328  ity=(iev+9)/10
2329  mstj(3)=-1
2330  IF(ity.EQ.3.OR.ity.EQ.4) mstj(11)=2
2331  IF(ity.EQ.1) CALL py1ent(1,1,15d0,0d0,0d0)
2332  IF(ity.EQ.2) CALL py1ent(1,3101,15d0,0d0,0d0)
2333  IF(ity.EQ.3) CALL py1ent(1,-2203,15d0,0d0,0d0)
2334  IF(ity.EQ.4) CALL py1ent(1,-4,30d0,0d0,0d0)
2335  IF(ity.EQ.5) CALL py1ent(1,21,15d0,0d0,0d0)
2336 
2337 C...Ten events each for some simple jet systems; string fragmentation.
2338  ELSEIF(iev.LE.130) THEN
2339  ity=(iev-41)/10
2340  IF(ity.EQ.1) CALL py2ent(1,1,-1,40d0)
2341  IF(ity.EQ.2) CALL py2ent(1,4,-4,30d0)
2342  IF(ity.EQ.3) CALL py2ent(1,2,2103,100d0)
2343  IF(ity.EQ.4) CALL py2ent(1,21,21,40d0)
2344  IF(ity.EQ.5) CALL py3ent(1,2101,21,-3203,30d0,0.6d0,0.8d0)
2345  IF(ity.EQ.6) CALL py3ent(1,5,21,-5,40d0,0.9d0,0.8d0)
2346  IF(ity.EQ.7) CALL py3ent(1,21,21,21,60d0,0.7d0,0.5d0)
2347  IF(ity.EQ.8) CALL py4ent(1,2,21,21,-2,40d0,
2348  & 0.4d0,0.64d0,0.6d0,0.12d0,0.2d0)
2349 
2350 C...Seventy events with independent fragmentation and momentum cons.
2351  ELSEIF(iev.LE.200) THEN
2352  ity=1+(iev-131)/16
2353  mstj(2)=1+mod(iev-131,4)
2354  mstj(3)=1+mod((iev-131)/4,4)
2355  IF(ity.EQ.1) CALL py2ent(1,4,-5,40d0)
2356  IF(ity.EQ.2) CALL py3ent(1,3,21,-3,40d0,0.9d0,0.4d0)
2357  IF(ity.EQ.3) CALL py4ent(1,2,21,21,-2,40d0,
2358  & 0.4d0,0.64d0,0.6d0,0.12d0,0.2d0)
2359  IF(ity.GE.4) CALL py4ent(1,2,-3,3,-2,40d0,
2360  & 0.4d0,0.64d0,0.6d0,0.12d0,0.2d0)
2361 
2362 C...A hundred events with random jets (check invariant mass).
2363  ELSEIF(iev.LE.300) THEN
2364  100 DO 110 j=1,5
2365  psum(j)=0d0
2366  110 CONTINUE
2367  njet=2d0+6d0*pyr(0)
2368  DO 130 i=1,njet
2369  kfl=21
2370  IF(i.EQ.1) kfl=int(1d0+4d0*pyr(0))
2371  IF(i.EQ.njet) kfl=-int(1d0+4d0*pyr(0))
2372  ejet=5d0+20d0*pyr(0)
2373  theta=acos(2d0*pyr(0)-1d0)
2374  phi=6.2832d0*pyr(0)
2375  IF(i.LT.njet) CALL py1ent(-i,kfl,ejet,theta,phi)
2376  IF(i.EQ.njet) CALL py1ent(i,kfl,ejet,theta,phi)
2377  IF(i.EQ.1.OR.i.EQ.njet) mstj(93)=1
2378  IF(i.EQ.1.OR.i.EQ.njet) psum(5)=psum(5)+pymass(kfl)
2379  DO 120 j=1,4
2380  psum(j)=psum(j)+p(i,j)
2381  120 CONTINUE
2382  130 CONTINUE
2383  IF(psum(4)**2-psum(1)**2-psum(2)**2-psum(3)**2.LT.
2384  & (psum(5)+parj(32))**2) goto 100
2385 
2386 C...Fifty e+e- continuum events with matrix elements.
2387  ELSEIF(iev.LE.350) THEN
2388  mstj(101)=2
2389  CALL pyeevt(0,40d0)
2390 
2391 C...Fifty e+e- continuum event with varying shower options.
2392  ELSEIF(iev.LE.400) THEN
2393  mstj(42)=1+mod(iev,2)
2394  mstj(43)=1+mod(iev/2,4)
2395  mstj(44)=mod(iev/8,3)
2396  CALL pyeevt(0,90d0)
2397 
2398 C...Fifty e+e- continuum events with coherent shower.
2399  ELSEIF(iev.LE.450) THEN
2400  CALL pyeevt(0,500d0)
2401 
2402 C...Fifty Upsilon decays to ggg or gammagg with coherent shower.
2403  ELSE
2404  CALL pyonia(5,9.46d0)
2405  ENDIF
2406 
2407 C...Generate event. Find total momentum, energy and charge.
2408  DO 140 j=1,4
2409  pini(j)=pyp(0,j)
2410  140 CONTINUE
2411  pini(6)=pyp(0,6)
2412  CALL pyexec
2413  DO 150 j=1,4
2414  pfin(j)=pyp(0,j)
2415  150 CONTINUE
2416  pfin(6)=pyp(0,6)
2417 
2418 C...Check conservation of energy, momentum and charge;
2419 C...usually exact, but only approximate for single jets.
2420  merr=0
2421  IF(iev.LE.50) THEN
2422  IF((pfin(1)-pini(1))**2+(pfin(2)-pini(2))**2.GE.10d0)
2423  & merr=merr+1
2424  epzrem=pini(4)+pini(3)-pfin(4)-pfin(3)
2425  IF(epzrem.LT.0d0.OR.epzrem.GT.2d0*parj(31)) merr=merr+1
2426  IF(abs(pfin(6)-pini(6)).GT.2.1d0) merr=merr+1
2427  ELSE
2428  DO 160 j=1,4
2429  IF(abs(pfin(j)-pini(j)).GT.0.0001d0*pini(4)) merr=merr+1
2430  160 CONTINUE
2431  IF(abs(pfin(6)-pini(6)).GT.0.1d0) merr=merr+1
2432  ENDIF
2433  IF(merr.NE.0) WRITE(mstu(11),5000) (pini(j),j=1,4),pini(6),
2434  & (pfin(j),j=1,4),pfin(6)
2435 
2436 C...Check that all KF codes are known ones, and that partons/particles
2437 C...satisfy energy-momentum-mass relation. Store particle statistics.
2438  DO 170 i=1,n
2439  IF(k(i,1).GT.20) goto 170
2440  IF(pycomp(k(i,2)).EQ.0) THEN
2441  WRITE(mstu(11),5100) i
2442  merr=merr+1
2443  ENDIF
2444  pd=p(i,4)**2-p(i,1)**2-p(i,2)**2-p(i,3)**2-p(i,5)**2
2445  IF(abs(pd).GT.max(0.1d0,0.001d0*p(i,4)**2).OR.p(i,4).LT.0d0)
2446  & THEN
2447  WRITE(mstu(11),5200) i
2448  merr=merr+1
2449  ENDIF
2450  170 CONTINUE
2451  IF(mtest.GE.1) CALL pytabu(21)
2452 
2453 C...List all erroneous events and some normal ones.
2454  IF(merr.NE.0.OR.mstu(24).NE.0.OR.mstu(28).NE.0) THEN
2455  IF(merr.GE.1) WRITE(mstu(11),6400)
2456  CALL pylist(2)
2457  ELSEIF(mtest.GE.1.AND.mod(iev-5,100).EQ.0) THEN
2458  CALL pylist(1)
2459  ENDIF
2460 
2461 C...Stop execution if too many errors.
2462  IF(merr.NE.0) nerr=nerr+1
2463  IF(nerr.GE.10) THEN
2464  WRITE(mstu(11),6300)
2465  CALL pylist(1)
2466  CALL pystop(9)
2467  ENDIF
2468  180 CONTINUE
2469 
2470 C...Summarize result of run.
2471  IF(mtest.GE.1) CALL pytabu(22)
2472 
2473 C...Reset commonblock variables changed during run.
2474  mstj(1)=mstj1
2475  mstj(3)=mstj3
2476  mstj(11)=mstj11
2477  mstj(42)=mstj42
2478  mstj(43)=mstj43
2479  mstj(44)=mstj44
2480  parj(17)=parj17
2481  parj(22)=parj22
2482  parj(43)=parj43
2483  parj(54)=parj54
2484  mstj(101)=mst101
2485  mstj(104)=mst104
2486  mstj(105)=mst105
2487  mstj(107)=mst107
2488  mstj(116)=mst116
2489 
2490 C...Second part: complete events of various kinds.
2491 C...Common initial values. Loop over initiating conditions.
2492  mstp(122)=max(0,min(2,mtest))
2493  mdcy(pycomp(111),1)=0
2494  DO 230 iproc=1,8
2495 
2496 C...Reset process type, kinematics cuts, and the flags used.
2497  msel=0
2498  DO 190 isub=1,500
2499  msub(isub)=0
2500  190 CONTINUE
2501  ckin(1)=2d0
2502  ckin(3)=0d0
2503  mstp(2)=1
2504  mstp(11)=0
2505  mstp(33)=0
2506  mstp(81)=1
2507  mstp(82)=1
2508  mstp(111)=1
2509  mstp(131)=0
2510  mstp(133)=0
2511  parp(131)=0.01d0
2512 
2513 C...Prompt photon production at fixed target.
2514  IF(iproc.EQ.1) THEN
2515  pzsum=300d0
2516  pesum=sqrt(pzsum**2+pymass(211)**2)+pymass(2212)
2517  pqsum=2d0
2518  msel=10
2519  ckin(3)=5d0
2520  CALL pyinit('FIXT','pi+','p',pzsum)
2521 
2522 C...QCD processes at ISR energies.
2523  ELSEIF(iproc.EQ.2) THEN
2524  pesum=63d0
2525  pzsum=0d0
2526  pqsum=2d0
2527  msel=1
2528  ckin(3)=5d0
2529  CALL pyinit('CMS','p','p',pesum)
2530 
2531 C...W production + multiple interactions at CERN Collider.
2532  ELSEIF(iproc.EQ.3) THEN
2533  pesum=630d0
2534  pzsum=0d0
2535  pqsum=0d0
2536  msel=12
2537  ckin(1)=20d0
2538  mstp(82)=4
2539  mstp(2)=2
2540  mstp(33)=3
2541  CALL pyinit('CMS','p','pbar',pesum)
2542 
2543 C...W/Z gauge boson pairs + pileup events at the Tevatron.
2544  ELSEIF(iproc.EQ.4) THEN
2545  pesum=1800d0
2546  pzsum=0d0
2547  pqsum=0d0
2548  msub(22)=1
2549  msub(23)=1
2550  msub(25)=1
2551  ckin(1)=200d0
2552  mstp(111)=0
2553  mstp(131)=1
2554  mstp(133)=2
2555  parp(131)=0.04d0
2556  CALL pyinit('CMS','p','pbar',pesum)
2557 
2558 C...Higgs production at LHC.
2559  ELSEIF(iproc.EQ.5) THEN
2560  pesum=15400d0
2561  pzsum=0d0
2562  pqsum=2d0
2563  msub(3)=1
2564  msub(102)=1
2565  msub(123)=1
2566  msub(124)=1
2567  pmas(25,1)=300d0
2568  ckin(1)=200d0
2569  mstp(81)=0
2570  mstp(111)=0
2571  CALL pyinit('CMS','p','p',pesum)
2572 
2573 C...Z' production at SSC.
2574  ELSEIF(iproc.EQ.6) THEN
2575  pesum=40000d0
2576  pzsum=0d0
2577  pqsum=2d0
2578  msel=21
2579  pmas(32,1)=600d0
2580  ckin(1)=400d0
2581  mstp(81)=0
2582  mstp(111)=0
2583  CALL pyinit('CMS','p','p',pesum)
2584 
2585 C...W pair production at 1 TeV e+e- collider.
2586  ELSEIF(iproc.EQ.7) THEN
2587  pesum=1000d0
2588  pzsum=0d0
2589  pqsum=0d0
2590  msub(25)=1
2591  msub(69)=1
2592  mstp(11)=1
2593  CALL pyinit('CMS','e+','e-',pesum)
2594 
2595 C...Deep inelastic scattering at a LEP+LHC ep collider.
2596  ELSEIF(iproc.EQ.8) THEN
2597  p(1,1)=0d0
2598  p(1,2)=0d0
2599  p(1,3)=8000d0
2600  p(2,1)=0d0
2601  p(2,2)=0d0
2602  p(2,3)=-80d0
2603  pesum=8080d0
2604  pzsum=7920d0
2605  pqsum=0d0
2606  msub(10)=1
2607  ckin(3)=50d0
2608  mstp(111)=0
2609  CALL pyinit('3MOM','p','e-',pesum)
2610  ENDIF
2611 
2612 C...Generate 20 events of each required type.
2613  DO 220 iev=1,20
2614  CALL pyevnt
2615  pesumm=pesum
2616  IF(iproc.EQ.4) pesumm=msti(41)*pesum
2617 
2618 C...Check conservation of energy/momentum/flavour.
2619  pini(1)=0d0
2620  pini(2)=0d0
2621  pini(3)=pzsum
2622  pini(4)=pesumm
2623  pini(6)=pqsum
2624  DO 200 j=1,4
2625  pfin(j)=pyp(0,j)
2626  200 CONTINUE
2627  pfin(6)=pyp(0,6)
2628  merr=0
2629  deve=abs(pfin(4)-pini(4))+abs(pfin(3)-pini(3))
2630  devt=abs(pfin(1)-pini(1))+abs(pfin(2)-pini(2))
2631  devq=abs(pfin(6)-pini(6))
2632  IF(deve.GT.2d-3*pesum.OR.devt.GT.max(0.01d0,1d-4*pesum).OR.
2633  & devq.GT.0.1d0) merr=1
2634  IF(merr.NE.0) WRITE(mstu(11),5000) (pini(j),j=1,4),pini(6),
2635  & (pfin(j),j=1,4),pfin(6)
2636 
2637 C...Check that all KF codes are known ones, and that partons/particles
2638 C...satisfy energy-momentum-mass relation.
2639  DO 210 i=1,n
2640  IF(k(i,1).GT.20) goto 210
2641  IF(pycomp(k(i,2)).EQ.0) THEN
2642  WRITE(mstu(11),5100) i
2643  merr=merr+1
2644  ENDIF
2645  pd=p(i,4)**2-p(i,1)**2-p(i,2)**2-p(i,3)**2-p(i,5)**2*
2646  & sign(1d0,p(i,5))
2647  IF(abs(pd).GT.max(0.1d0,0.002d0*p(i,4)**2,0.002d0*p(i,5)**2)
2648  & .OR.(p(i,5).GE.0d0.AND.p(i,4).LT.0d0)) THEN
2649  WRITE(mstu(11),5200) i
2650  merr=merr+1
2651  ENDIF
2652  210 CONTINUE
2653 
2654 C...Listing of erroneous events, and first event of each type.
2655  IF(merr.GE.1) nerr=nerr+1
2656  IF(nerr.GE.10) THEN
2657  WRITE(mstu(11),6300)
2658  CALL pylist(1)
2659  CALL pystop(9)
2660  ENDIF
2661  IF(mtest.GE.1.AND.(merr.GE.1.OR.iev.EQ.1)) THEN
2662  IF(merr.GE.1) WRITE(mstu(11),6400)
2663  CALL pylist(1)
2664  ENDIF
2665  220 CONTINUE
2666 
2667 C...List statistics for each process type.
2668  IF(mtest.GE.1) CALL pystat(1)
2669  230 CONTINUE
2670 
2671 C...Summarize result of run.
2672  IF(nerr.EQ.0) WRITE(mstu(11),6500)
2673  IF(nerr.GT.0) WRITE(mstu(11),6600) nerr
2674 
2675 C...Format statements for output.
2676  5000 FORMAT(/' Momentum, energy and/or charge were not conserved ',
2677  &'in following event'/' sum of',9x,'px',11x,'py',11x,'pz',11x,
2678  &'E',8x,'charge'/' before',2x,4(1x,f12.5),1x,f8.2/' after',3x,
2679  &4(1x,f12.5),1x,f8.2)
2680  5100 FORMAT(/5x,'Entry no.',i4,' in following event not known code')
2681  5200 FORMAT(/5x,'Entry no.',i4,' in following event has faulty ',
2682  &'kinematics')
2683  6300 FORMAT(/5x,'This is the tenth error experienced! Something is ',
2684  &'wrong.'/5x,'Execution will be stopped after listing of event.')
2685  6400 FORMAT(5x,'Faulty event follows:')
2686  6500 FORMAT(//5x,'End result of PYTEST: no errors detected.')
2687  6600 FORMAT(//5x,'End result of PYTEST:',i2,' errors detected.'/
2688  &5x,'This should not have happened!')
2689 
2690  RETURN
2691  END
2692 
2693 C*********************************************************************
2694 
2695 C...PYHEPC
2696 C...Converts PYTHIA event record contents to or from
2697 C...the standard event record commonblock.
2698 
2699  SUBROUTINE pyhepc(MCONV)
2700 
2701 C...Double precision and integer declarations.
2702  IMPLICIT DOUBLE PRECISION(a-h, o-z)
2703  IMPLICIT INTEGER(i-n)
2704  INTEGER pyk,pychge,pycomp
2705 C...Commonblocks.
2706  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
2707  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
2708  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
2709  SAVE /pyjets/,/pydat1/,/pydat2/
2710 C...HEPEVT commonblock.
2711  parameter(nmxhep=4000)
2712  common/hepevt/nevhep,nhep,isthep(nmxhep),idhep(nmxhep),
2713  &jmohep(2,nmxhep),jdahep(2,nmxhep),phep(5,nmxhep),vhep(4,nmxhep)
2714  DOUBLE PRECISION phep,vhep
2715  SAVE /hepevt/
2716 
2717 C...Store HEPEVT commonblock size (for interfacing issues).
2718  mstu(8)=nmxhep
2719 
2720 C...Initialize variable(s)
2721  inew = 1
2722 
2723 C...Conversion from PYTHIA to standard, the easy part.
2724  IF(mconv.EQ.1) THEN
2725  nevhep=0
2726  IF(n.GT.nmxhep) CALL pyerrm(8,
2727  & '(PYHEPC:) no more space in /HEPEVT/')
2728  nhep=min(n,nmxhep)
2729  DO 150 i=1,nhep
2730  isthep(i)=0
2731  IF(k(i,1).GE.1.AND.k(i,1).LE.10) isthep(i)=1
2732  IF(k(i,1).GE.11.AND.k(i,1).LE.20) isthep(i)=2
2733  IF(k(i,1).GE.21.AND.k(i,1).LE.30) isthep(i)=3
2734  IF(k(i,1).GE.31.AND.k(i,1).LE.100) isthep(i)=k(i,1)
2735  idhep(i)=k(i,2)
2736  jmohep(1,i)=k(i,3)
2737  jmohep(2,i)=0
2738  IF(k(i,1).NE.3.AND.k(i,1).NE.13.AND.k(i,1).NE.14) THEN
2739  jdahep(1,i)=k(i,4)
2740  jdahep(2,i)=k(i,5)
2741  ELSE
2742  jdahep(1,i)=0
2743  jdahep(2,i)=0
2744  ENDIF
2745  DO 100 j=1,5
2746  phep(j,i)=p(i,j)
2747  100 CONTINUE
2748  DO 110 j=1,4
2749  vhep(j,i)=v(i,j)
2750  110 CONTINUE
2751 
2752 C...Check if new event (from pileup).
2753  IF(i.EQ.1) THEN
2754  inew=1
2755  ELSE
2756  IF(k(i,1).EQ.21.AND.k(i-1,1).NE.21) inew=i
2757  ENDIF
2758 
2759 C...Fill in missing mother information.
2760  IF(i.GE.inew+2.AND.k(i,1).EQ.21.AND.k(i,3).EQ.0) THEN
2761  imo1=i-2
2762  120 IF(imo1.GT.inew.AND.k(imo1+1,1).EQ.21.AND.k(imo1+1,3).EQ.0)
2763  & THEN
2764  imo1=imo1-1
2765  goto 120
2766  ENDIF
2767  jmohep(1,i)=imo1
2768  jmohep(2,i)=imo1+1
2769  ELSEIF(k(i,2).GE.91.AND.k(i,2).LE.93) THEN
2770  i1=k(i,3)-1
2771  130 i1=i1+1
2772  IF(i1.GE.i) CALL pyerrm(8,
2773  & '(PYHEPC:) translation of inconsistent event history')
2774  IF(i1.LT.i.AND.k(i1,1).NE.1.AND.k(i1,1).NE.11) goto 130
2775  kc=pycomp(k(i1,2))
2776  IF(i1.LT.i.AND.kc.EQ.0) goto 130
2777  IF(i1.LT.i.AND.kchg(kc,2).EQ.0) goto 130
2778  jmohep(2,i)=i1
2779  ELSEIF(k(i,2).EQ.94) THEN
2780  njet=2
2781  IF(nhep.GE.i+3.AND.k(i+3,3).LE.i) njet=3
2782  IF(nhep.GE.i+4.AND.k(i+4,3).LE.i) njet=4
2783  jmohep(2,i)=mod(k(i+njet,4)/mstu(5),mstu(5))
2784  IF(jmohep(2,i).EQ.jmohep(1,i)) jmohep(2,i)=
2785  & mod(k(i+1,4)/mstu(5),mstu(5))
2786  ENDIF
2787 
2788 C...Fill in missing daughter information.
2789  IF(k(i,2).EQ.94.AND.mstu(16).NE.2) THEN
2790  DO 140 i1=jdahep(1,i),jdahep(2,i)
2791  i2=mod(k(i1,4)/mstu(5),mstu(5))
2792  jdahep(1,i2)=i
2793  140 CONTINUE
2794  ENDIF
2795  IF(k(i,2).GE.91.AND.k(i,2).LE.94) goto 150
2796  i1=jmohep(1,i)
2797  IF(i1.LE.0.OR.i1.GT.nhep) goto 150
2798  IF(k(i1,1).NE.13.AND.k(i1,1).NE.14) goto 150
2799  IF(jdahep(1,i1).EQ.0) THEN
2800  jdahep(1,i1)=i
2801  ELSE
2802  jdahep(2,i1)=i
2803  ENDIF
2804  150 CONTINUE
2805  DO 160 i=1,nhep
2806  IF(k(i,1).NE.13.AND.k(i,1).NE.14) goto 160
2807  IF(jdahep(2,i).EQ.0) jdahep(2,i)=jdahep(1,i)
2808  160 CONTINUE
2809 
2810 C...Conversion from standard to PYTHIA, the easy part.
2811  ELSE
2812  IF(nhep.GT.mstu(4)) CALL pyerrm(8,
2813  & '(PYHEPC:) no more space in /PYJETS/')
2814  n=min(nhep,mstu(4))
2815  nkq=0
2816  kqsum=0
2817  DO 190 i=1,n
2818  k(i,1)=0
2819  IF(isthep(i).EQ.1) k(i,1)=1
2820  IF(isthep(i).EQ.2) THEN
2821  k(i,1)=11
2822  IF(k(i,4).GT.0.AND.(k(i,4).EQ.k(i,5)).AND.
2823  $ (k(k(i,4),2).GE.91.AND.k(k(i,4),2).LE.93).AND.
2824  $ (i.LT.n).AND.(k(i,4).EQ.k(i+1,4))) k(i,1)=12
2825  ENDIF
2826  IF(isthep(i).EQ.3) k(i,1)=21
2827  k(i,2)=idhep(i)
2828  k(i,3)=jmohep(1,i)
2829  k(i,4)=jdahep(1,i)
2830  k(i,5)=jdahep(2,i)
2831  DO 170 j=1,5
2832  p(i,j)=phep(j,i)
2833  170 CONTINUE
2834  DO 180 j=1,4
2835  v(i,j)=vhep(j,i)
2836  180 CONTINUE
2837  v(i,5)=0d0
2838  IF(isthep(i).EQ.2.AND.phep(4,i).GT.phep(5,i)) THEN
2839  i1=jdahep(1,i)
2840  IF(i1.GT.0.AND.i1.LE.nhep) v(i,5)=(vhep(4,i1)-vhep(4,i))*
2841  & phep(5,i)/phep(4,i)
2842  ENDIF
2843 
2844 C...Fill in missing information on colour connection in jet systems.
2845  IF(isthep(i).EQ.1) THEN
2846  kc=pycomp(k(i,2))
2847  kq=0
2848  IF(kc.NE.0) kq=kchg(kc,2)*isign(1,k(i,2))
2849  IF(kq.NE.0) nkq=nkq+1
2850  IF(kq.NE.2) kqsum=kqsum+kq
2851  IF(kq.NE.0.AND.kqsum.NE.0) THEN
2852  k(i,1)=2
2853  ELSEIF(kq.EQ.2.AND.i.LT.n) THEN
2854  IF(k(i+1,2).EQ.21) k(i,1)=2
2855  ENDIF
2856  ENDIF
2857  190 CONTINUE
2858  IF(nkq.EQ.1.OR.kqsum.NE.0) CALL pyerrm(8,
2859  & '(PYHEPC:) input parton configuration not colour singlet')
2860  ENDIF
2861 
2862  END
2863 
2864 C*********************************************************************
2865 
2866 C...PYINIT
2867 C...Initializes the generation procedure; finds maxima of the
2868 C...differential cross-sections to be used for weighting.
2869 
2870  SUBROUTINE pyinit(FRAME,BEAM,TARGET,WIN)
2871 
2872 C...Double precision and integer declarations.
2873  IMPLICIT DOUBLE PRECISION(a-h, o-z)
2874  IMPLICIT INTEGER(i-n)
2875  INTEGER pyk,pychge,pycomp
2876 C...Commonblocks.
2877  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
2878  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
2879  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
2880  common/pydat4/chaf(500,2)
2881  CHARACTER chaf*16
2882  common/pysubs/msel,mselpd,msub(500),kfin(2,-40:40),ckin(200)
2883  common/pypars/mstp(200),parp(200),msti(200),pari(200)
2884  common/pyint1/mint(400),vint(400)
2885  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
2886  common/pyint5/ngenpd,ngen(0:500,3),xsec(0:500,3)
2887  common/pypued/iued(0:99),rued(0:99)
2888  SAVE /pydat1/,/pydat2/,/pydat3/,/pydat4/,/pysubs/,/pypars/,
2889  &/pyint1/,/pyint2/,/pyint5/,/pypued/
2890 C...Local arrays and character variables.
2891  dimension alamin(20),nfin(20)
2892  CHARACTER*(*) frame,beam,target
2893  CHARACTER chfram*12,chbeam*12,chtarg*12,chlh(2)*6
2894 
2895 C...Interface to PDFLIB.
2896  common/w50511/nptype,ngroup,nset,mode,nfl,lo,tmas
2897  common/w50512/qcdl4,qcdl5
2898  SAVE /w50511/,/w50512/
2899  DOUBLE PRECISION value(20),tmas,qcdl4,qcdl5
2900  CHARACTER*20 parm(20)
2901  DATA value/20*0d0/,parm/20*' '/
2902 
2903 C...Data:Lambda and n_f values for parton distributions..
2904  DATA alamin/0.177d0,0.239d0,0.247d0,0.2322d0,0.248d0,0.248d0,
2905  &0.192d0,0.326d0,2*0.2d0,0.2d0,0.2d0,0.29d0,0.2d0,0.4d0,5*0.2d0/,
2906  &nfin/20*4/
2907  DATA chlh/'lepton','hadron'/
2908 
2909 C...Check that BLOCK DATA PYDATA has been loaded.
2910  CALL pyckbd
2911 
2912 C...Reset MINT and VINT arrays. Write headers.
2913  msti(53)=0
2914  DO 100 j=1,400
2915  mint(j)=0
2916  vint(j)=0d0
2917  100 CONTINUE
2918  IF(mstu(12).NE.12345) CALL pylist(0)
2919  IF(mstp(122).GE.1) WRITE(mstu(11),5100)
2920 
2921 C...Reset error counters.
2922  mstu(23)=0
2923  mstu(27)=0
2924  mstu(30)=0
2925 
2926 C...Reset processes that should not be on.
2927  msub(96)=0
2928  msub(97)=0
2929 
2930 C...Select global FSR/ISR/UE parameter set = 'tune'
2931 C...See routine PYTUNE for details
2932  IF (mstp(5).NE.0) THEN
2933  mstp5=mstp(5)
2934  CALL pytune(mstp5)
2935  ENDIF
2936 
2937 C...Call user process initialization routine.
2938  IF(frame(1:1).EQ.'u'.OR.frame(1:1).EQ.'U') THEN
2939  msel=0
2940  CALL upinit
2941  msel=0
2942  ENDIF
2943 
2944 C...Maximum 4 generations; set maximum number of allowed flavours.
2945  mstp(1)=min(4,mstp(1))
2946  mstu(114)=min(mstu(114),2*mstp(1))
2947  mstp(58)=min(mstp(58),2*mstp(1))
2948 
2949 C...Sum up Cabibbo-Kobayashi-Maskawa factors for each quark/lepton.
2950  DO 120 i=-20,20
2951  vint(180+i)=0d0
2952  ia=iabs(i)
2953  IF(ia.GE.1.AND.ia.LE.2*mstp(1)) THEN
2954  DO 110 j=1,mstp(1)
2955  ib=2*j-1+mod(ia,2)
2956  IF(ib.GE.6.AND.mstp(9).EQ.0) goto 110
2957  ipm=(5-isign(1,i))/2
2958  idc=j+mdcy(ia,2)+2
2959  IF(mdme(idc,1).EQ.1.OR.mdme(idc,1).EQ.ipm) vint(180+i)=
2960  & vint(180+i)+vckm((ia+1)/2,(ib+1)/2)
2961  110 CONTINUE
2962  ELSEIF(ia.GE.11.AND.ia.LE.10+2*mstp(1)) THEN
2963  vint(180+i)=1d0
2964  ENDIF
2965  120 CONTINUE
2966 
2967 C...Initialize parton distributions: PDFLIB.
2968  IF(mstp(52).EQ.2) THEN
2969  parm(1)='NPTYPE'
2970  value(1)=1
2971  parm(2)='NGROUP'
2972  value(2)=mstp(51)/1000
2973  parm(3)='NSET'
2974  value(3)=mod(mstp(51),1000)
2975  parm(4)='TMAS'
2976  value(4)=pmas(6,1)
2977  call setlhaparm('SILENT')
2978  CALL pdfset(parm,value)
2979  mint(93)=1000000+mstp(51)
2980  ENDIF
2981 
2982 C...Choose Lambda value to use in alpha-strong.
2983  mstu(111)=mstp(2)
2984  IF(mstp(3).GE.2) THEN
2985  alam=0.2d0
2986  nf=4
2987  IF(mstp(52).EQ.1.AND.mstp(51).GE.1.AND.mstp(51).LE.20) THEN
2988  alam=alamin(mstp(51))
2989  nf=nfin(mstp(51))
2990  ELSEIF(mstp(52).EQ.2.AND.nfl.EQ.5) THEN
2991  alam=qcdl5
2992  nf=5
2993  ELSEIF(mstp(52).EQ.2) THEN
2994  alam=qcdl4
2995  nf=4
2996  ENDIF
2997  parp(1)=alam
2998  parp(61)=alam
2999  parp(72)=alam
3000  paru(112)=alam
3001  mstu(112)=nf
3002  IF(mstp(3).EQ.3) parj(81)=alam
3003  ENDIF
3004 
3005 C...Initialize the UED masses and widths
3006  IF (iued(1).EQ.1) CALL pyxdin
3007 
3008 C...Initialize the SUSY generation: couplings, masses,
3009 C...decay modes, branching ratios, and so on.
3010  CALL pymsin
3011 C...Initialize widths and partial widths for resonances.
3012  CALL pyinre
3013 C...Set Z0 mass and width for e+e- routines.
3014  parj(123)=pmas(23,1)
3015  parj(124)=pmas(23,2)
3016 
3017 C...Identify beam and target particles and frame of process.
3018  chfram=frame//' '
3019  chbeam=beam//' '
3020  chtarg=TARGET//' '
3021  CALL pyinbm(chfram,chbeam,chtarg,win)
3022  IF(mint(65).EQ.1) goto 170
3023 
3024 C...For gamma-p or gamma-gamma allow many (3 or 6) alternatives.
3025 C...For e-gamma allow 2 alternatives.
3026  mint(121)=1
3027  IF(mstp(14).EQ.10.AND.(msel.EQ.1.OR.msel.EQ.2)) THEN
3028  IF((mint(11).EQ.22.OR.mint(12).EQ.22).AND.
3029  & (iabs(mint(11)).GT.100.OR.iabs(mint(12)).GT.100)) mint(121)=3
3030  IF(mint(11).EQ.22.AND.mint(12).EQ.22) mint(121)=6
3031  IF((mint(11).EQ.22.OR.mint(12).EQ.22).AND.
3032  & (iabs(mint(11)).EQ.11.OR.iabs(mint(12)).EQ.11)) mint(121)=2
3033  ELSEIF(mstp(14).EQ.20.AND.(msel.EQ.1.OR.msel.EQ.2)) THEN
3034  IF((mint(11).EQ.22.OR.mint(12).EQ.22).AND.
3035  & (iabs(mint(11)).GT.100.OR.iabs(mint(12)).GT.100)) mint(121)=3
3036  IF(mint(11).EQ.22.AND.mint(12).EQ.22) mint(121)=9
3037  ELSEIF(mstp(14).EQ.25.AND.(msel.EQ.1.OR.msel.EQ.2)) THEN
3038  IF((mint(11).EQ.22.OR.mint(12).EQ.22).AND.
3039  & (iabs(mint(11)).GT.100.OR.iabs(mint(12)).GT.100)) mint(121)=2
3040  IF(mint(11).EQ.22.AND.mint(12).EQ.22) mint(121)=4
3041  ELSEIF(mstp(14).EQ.30.AND.(msel.EQ.1.OR.msel.EQ.2)) THEN
3042  IF((mint(11).EQ.22.OR.mint(12).EQ.22).AND.
3043  & (iabs(mint(11)).GT.100.OR.iabs(mint(12)).GT.100)) mint(121)=4
3044  IF(mint(11).EQ.22.AND.mint(12).EQ.22) mint(121)=13
3045  ENDIF
3046  mint(123)=mstp(14)
3047  IF((mstp(14).EQ.10.OR.mstp(14).EQ.20.OR.mstp(14).EQ.25.OR.
3048  &mstp(14).EQ.30).AND.msel.NE.1.AND.msel.NE.2) mint(123)=0
3049  IF(mstp(14).GE.11.AND.mstp(14).LE.19) THEN
3050  IF(mstp(14).EQ.11) mint(123)=0
3051  IF(mstp(14).EQ.12.OR.mstp(14).EQ.14) mint(123)=5
3052  IF(mstp(14).EQ.13.OR.mstp(14).EQ.17) mint(123)=6
3053  IF(mstp(14).EQ.15) mint(123)=2
3054  IF(mstp(14).EQ.16.OR.mstp(14).EQ.18) mint(123)=7
3055  IF(mstp(14).EQ.19) mint(123)=3
3056  ELSEIF(mstp(14).GE.21.AND.mstp(14).LE.24) THEN
3057  IF(mstp(14).EQ.21) mint(123)=0
3058  IF(mstp(14).EQ.22.OR.mstp(14).EQ.23) mint(123)=4
3059  IF(mstp(14).EQ.24) mint(123)=1
3060  ELSEIF(mstp(14).GE.26.AND.mstp(14).LE.29) THEN
3061  IF(mstp(14).EQ.26.OR.mstp(14).EQ.28) mint(123)=8
3062  IF(mstp(14).EQ.27.OR.mstp(14).EQ.29) mint(123)=9
3063  ENDIF
3064 
3065 C...Set up kinematics of process.
3066  CALL pyinki(0)
3067 
3068 C...Set up kinematics for photons inside leptons.
3069  IF(mint(141).NE.0.OR.mint(142).NE.0) CALL pygaga(1,wtgaga)
3070 
3071 C...Precalculate flavour selection weights.
3072  CALL pykfin
3073 
3074 C...Loop over gamma-p or gamma-gamma alternatives.
3075  ckin3=ckin(3)
3076  msav48=0
3077  DO 160 iga=1,mint(121)
3078  ckin(3)=ckin3
3079  mint(122)=iga
3080 
3081 C...Select partonic subprocesses to be included in the simulation.
3082  CALL pyinpr
3083  mint(101)=1
3084  mint(102)=1
3085  mint(103)=mint(11)
3086  mint(104)=mint(12)
3087 
3088 C...Count number of subprocesses on.
3089  mint(48)=0
3090  DO 130 isub=1,500
3091  IF(mint(50).EQ.0.AND.isub.GE.91.AND.isub.LE.96.AND.
3092  & msub(isub).EQ.1.AND.mint(121).GT.1) THEN
3093  msub(isub)=0
3094  ELSEIF(mint(50).EQ.0.AND.isub.GE.91.AND.isub.LE.96.AND.
3095  & msub(isub).EQ.1) THEN
3096  WRITE(mstu(11),5200) isub,chlh(mint(41)),chlh(mint(42))
3097  CALL pystop(1)
3098  ELSEIF(msub(isub).EQ.1.AND.iset(isub).EQ.-1) THEN
3099  WRITE(mstu(11),5300) isub
3100  CALL pystop(1)
3101  ELSEIF(msub(isub).EQ.1.AND.iset(isub).LE.-2) THEN
3102  WRITE(mstu(11),5400) isub
3103  CALL pystop(1)
3104  ELSEIF(msub(isub).EQ.1) THEN
3105  mint(48)=mint(48)+1
3106  ENDIF
3107  130 CONTINUE
3108 
3109 C...Stop or raise warning flag if no subprocesses on.
3110  IF(mint(121).EQ.1.AND.mint(48).EQ.0) THEN
3111  IF(mstp(127).NE.1) THEN
3112  WRITE(mstu(11),5500)
3113  CALL pystop(1)
3114  ELSE
3115  WRITE(mstu(11),5700)
3116  msti(53)=1
3117  ENDIF
3118  ENDIF
3119  mint(49)=mint(48)-msub(91)-msub(92)-msub(93)-msub(94)
3120  msav48=msav48+mint(48)
3121 
3122 C...Reset variables for cross-section calculation.
3123  DO 150 i=0,500
3124  DO 140 j=1,3
3125  ngen(i,j)=0
3126  xsec(i,j)=0d0
3127  140 CONTINUE
3128  150 CONTINUE
3129 
3130 C...Find parametrized total cross-sections.
3131  CALL pyxtot
3132  vint(318)=vint(317)
3133 
3134 C...Maxima of differential cross-sections.
3135  IF(mstp(121).LE.1) CALL pymaxi
3136 
3137 C...Initialize possibility of pileup events.
3138  IF(mint(121).GT.1) mstp(131)=0
3139  IF(mstp(131).NE.0) CALL pypile(1)
3140 
3141 C...Initialize multiple interactions with variable impact parameter.
3142  IF(mint(50).EQ.1) THEN
3143  ptmn=parp(82)*(vint(1)/parp(89))**parp(90)
3144  IF(mod(mstp(81),10).EQ.0.AND.(ckin(3).GT.ptmn.OR.
3145  & ((msel.NE.1.AND.msel.NE.2)))) mstp(82)=min(1,mstp(82))
3146  IF((mint(49).NE.0.OR.mstp(131).NE.0).AND.mstp(82).GE.2) THEN
3147  mint(35)=1
3148  CALL pymult(1)
3149  mint(35)=3
3150  CALL pymign(1)
3151  ENDIF
3152  ENDIF
3153 
3154 C...Save results for gamma-p and gamma-gamma alternatives.
3155  IF(mint(121).GT.1) CALL pysave(1,iga)
3156  160 CONTINUE
3157 
3158 C...Initialization finished.
3159  IF(msav48.EQ.0) THEN
3160  IF(mstp(127).NE.1) THEN
3161  WRITE(mstu(11),5500)
3162  CALL pystop(1)
3163  ELSE
3164  WRITE(mstu(11),5700)
3165  msti(53)=1
3166  ENDIF
3167  ENDIF
3168  170 IF(mstp(122).GE.1) WRITE(mstu(11),5600)
3169 
3170 C...Formats for initialization information.
3171  5100 FORMAT('1',18('*'),1x,'PYINIT: initialization of PYTHIA ',
3172  &'routines',1x,17('*'))
3173  5200 FORMAT(1x,'Error: process number ',i3,' not meaningful for ',a6,
3174  &'-',a6,' interactions.'/1x,'Execution stopped!')
3175  5300 FORMAT(1x,'Error: requested subprocess',i4,' not implemented.'/
3176  &1x,'Execution stopped!')
3177  5400 FORMAT(1x,'Error: requested subprocess',i4,' not existing.'/
3178  &1x,'Execution stopped!')
3179  5500 FORMAT(1x,'Error: no subprocess switched on.'/
3180  &1x,'Execution stopped.')
3181  5600 FORMAT(/1x,22('*'),1x,'PYINIT: initialization completed',1x,
3182  &22('*'))
3183  5700 FORMAT(1x,'Error: no subprocess switched on.'/
3184  &1x,'Execution will stop if you try to generate events.')
3185 
3186  RETURN
3187  END
3188 
3189 C*********************************************************************
3190 
3191 C...PYEVNT
3192 C...Administers the generation of a high-pT event via calls to
3193 C...a number of subroutines.
3194 
3195  SUBROUTINE pyevnt
3196 
3197 C...Double precision and integer declarations.
3198  IMPLICIT DOUBLE PRECISION(a-h, o-z)
3199  IMPLICIT INTEGER(i-n)
3200  INTEGER pyk,pychge,pycomp
3201  parameter(maxnur=1000)
3202 C...Commonblocks.
3203  common/pypart/npart,npartd,ipart(maxnur),ptpart(maxnur)
3204  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
3205  common/pyctag/nct,mct(4000,2)
3206  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
3207  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
3208  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
3209  common/pypars/mstp(200),parp(200),msti(200),pari(200)
3210  common/pyint1/mint(400),vint(400)
3211  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
3212  common/pyint4/mwid(500),wids(500,5)
3213  common/pyint5/ngenpd,ngen(0:500,3),xsec(0:500,3)
3214  SAVE /pyjets/,/pydat1/,/pyctag/,/pydat2/,/pydat3/,/pypars/,
3215  &/pyint1/,/pyint2/,/pyint4/,/pyint5/
3216 C...Local array.
3217  dimension vtx(4)
3218 
3219 C...Optionally let PYEVNW do the whole job.
3220  IF(mstp(81).GE.20) THEN
3221  CALL pyevnw
3222  RETURN
3223  ENDIF
3224 
3225 C...Stop if no subprocesses on.
3226  IF(mint(121).EQ.1.AND.msti(53).EQ.1) THEN
3227  WRITE(mstu(11),5100)
3228  CALL pystop(1)
3229  ENDIF
3230 
3231 C...Initial values for some counters.
3232  mstu(1)=0
3233  mstu(2)=0
3234  n=0
3235  mint(5)=mint(5)+1
3236  mint(7)=0
3237  mint(8)=0
3238  mint(30)=0
3239  mint(83)=0
3240  mint(84)=mstp(126)
3241  mstu(24)=0
3242  mstu70=0
3243  mstj14=mstj(14)
3244 C...Normally, use K(I,4:5) colour info rather than /PYCTAG/.
3245  nct=0
3246  mint(33)=0
3247 
3248 C...Let called routines know call is from PYEVNT (not PYEVNW).
3249  mint(35)=1
3250  IF (mstp(81).GE.10) mint(35)=2
3251 
3252 C...If variable energies: redo incoming kinematics and cross-section.
3253  msti(61)=0
3254  IF(mstp(171).EQ.1) THEN
3255  CALL pyinki(1)
3256  IF(msti(61).EQ.1) THEN
3257  mint(5)=mint(5)-1
3258  RETURN
3259  ENDIF
3260  IF(mint(121).GT.1) CALL pysave(3,1)
3261  CALL pyxtot
3262  ENDIF
3263 
3264 C...Loop over number of pileup events; check space left.
3265  IF(mstp(131).LE.0) THEN
3266  npile=1
3267  ELSE
3268  CALL pypile(2)
3269  npile=mint(81)
3270  ENDIF
3271  DO 270 ipile=1,npile
3272  IF(mint(84)+100.GE.mstu(4)) THEN
3273  CALL pyerrm(11,
3274  & '(PYEVNT:) no more space in PYJETS for pileup events')
3275  IF(mstu(21).GE.1) goto 280
3276  ENDIF
3277  mint(82)=ipile
3278 
3279 C...Generate variables of hard scattering.
3280  mint(51)=0
3281  msti(52)=0
3282  100 CONTINUE
3283  IF(mint(51).NE.0.OR.mstu(24).NE.0) msti(52)=msti(52)+1
3284  mint(31)=0
3285  mint(39)=0
3286  mint(51)=0
3287  mint(57)=0
3288  CALL pyrand
3289  IF(msti(61).EQ.1) THEN
3290  mint(5)=mint(5)-1
3291  RETURN
3292  ENDIF
3293  IF(mint(51).EQ.2) RETURN
3294  isub=mint(1)
3295  IF(mstp(111).EQ.-1) goto 260
3296 
3297 C...Loopback point if PYPREP fails, especially for junction topologies.
3298  nprep=0
3299  mnt31s=mint(31)
3300  110 nprep=nprep+1
3301  mint(31)=mnt31s
3302 
3303  IF((isub.LE.90.OR.isub.GE.95).AND.isub.NE.99) THEN
3304 C...Hard scattering (including low-pT):
3305 C...reconstruct kinematics and colour flow of hard scattering.
3306  mint31=mint(31)
3307  120 mint(31)=mint31
3308  mint(51)=0
3309  CALL pyscat
3310  IF(mint(51).EQ.1) goto 100
3311  ipu1=mint(84)+1
3312  ipu2=mint(84)+2
3313  IF(isub.EQ.95) goto 140
3314 
3315 C...Reset statistics on activity in event.
3316  DO 130 j=351,359
3317  mint(j)=0
3318  vint(j)=0d0
3319  130 CONTINUE
3320 
3321 C...Showering of initial state partons (optional).
3322  nfin=n
3323  alamsv=parj(81)
3324  parj(81)=parp(72)
3325  IF(mstp(61).GE.1.AND.mint(47).GE.2.AND.mint(111).NE.12)
3326  & CALL pysspa(ipu1,ipu2)
3327  parj(81)=alamsv
3328  IF(mint(51).EQ.1) goto 100
3329 
3330 C...pT-ordered FSR off ISR (optional, must have at least 2 partons)
3331  IF (npart.GE.2.AND.(mstj(41).EQ.11.OR.mstj(41).EQ.12)) THEN
3332  ptmax=0.5*sqrt(parp(71))*vint(55)
3333  CALL pyptfs(3,ptmax,0d0,ptgen)
3334  ENDIF
3335 
3336 C...Showering of final state partons (optional).
3337  alamsv=parj(81)
3338  parj(81)=parp(72)
3339  IF(mstp(71).GE.1.AND.iset(isub).GE.2.AND.iset(isub).LE.10)
3340  & THEN
3341  ipu3=mint(84)+3
3342  ipu4=mint(84)+4
3343  IF(iset(isub).EQ.5) ipu4=-3
3344  qmax=vint(55)
3345  IF(iset(isub).EQ.2) qmax=sqrt(parp(71))*vint(55)
3346  CALL pyshow(ipu3,ipu4,qmax)
3347  ELSEIF(iset(isub).EQ.11) THEN
3348  CALL pyadsh(nfin)
3349  ENDIF
3350  parj(81)=alamsv
3351 
3352 C...Allow possibility for user to abort event generation.
3353  iveto=0
3354  IF(ipile.EQ.1.AND.mstp(143).EQ.1) CALL pyveto(iveto)
3355  IF(iveto.EQ.1) goto 100
3356 
3357 C...Decay of final state resonances.
3358  mint(32)=0
3359  IF(mstp(41).GE.1.AND.iset(isub).LE.10) CALL pyresd(0)
3360  IF(mint(51).EQ.1) goto 100
3361  mint(52)=n
3362 
3363 
3364 C...Multiple interactions - PYTHIA 6.3 intermediate style.
3365  140 IF(mstp(81).GE.10.AND.mint(50).EQ.1) THEN
3366  IF(isub.EQ.95) mint(31)=mint(31)+1
3367  CALL pymign(6)
3368  IF(mint(51).EQ.1) goto 100
3369  mint(53)=n
3370 
3371 C...Beam remnant flavour and colour assignments - new scheme.
3372  CALL pymihk
3373  IF(mint(51).EQ.1.AND.mint(57).GE.1.AND.mint(57).LE.5)
3374  & goto 120
3375  IF(mint(51).EQ.1) goto 100
3376 
3377 C...Primordial kT and beam remnant momentum sharing - new scheme.
3378  CALL pymirm
3379  IF(mint(51).EQ.1.AND.mint(57).GE.1.AND.mint(57).LE.5)
3380  & goto 120
3381  IF(mint(51).EQ.1) goto 100
3382  IF(isub.EQ.95) mint(31)=mint(31)-1
3383 
3384 C...Multiple interactions - PYTHIA 6.2 style.
3385  ELSEIF(mint(111).NE.12) THEN
3386  IF (mstp(81).GE.1.AND.mint(50).EQ.1.AND.isub.NE.95) THEN
3387  CALL pymult(6)
3388  mint(53)=n
3389  ENDIF
3390 
3391 C...Hadron remnants and primordial kT.
3392  CALL pyremn(ipu1,ipu2)
3393  IF(mint(51).EQ.1.AND.mint(57).GE.1.AND.mint(57).LE.5) goto
3394  & 110
3395  IF(mint(51).EQ.1) goto 100
3396  ENDIF
3397 
3398  ELSEIF(isub.NE.99) THEN
3399 C...Diffractive and elastic scattering.
3400  CALL pydiff
3401 
3402  ELSE
3403 C...DIS scattering (photon flux external).
3404  CALL pydisg
3405  IF(mint(51).EQ.1) goto 100
3406  ENDIF
3407 
3408 C...Check that no odd resonance left undecayed.
3409  mint(54)=n
3410  IF(mstp(111).GE.1) THEN
3411  nfix=n
3412  DO 150 i=mint(84)+1,nfix
3413  IF(k(i,1).GE.1.AND.k(i,1).LE.10.AND.k(i,2).NE.21.AND.
3414  & k(i,2).NE.22) THEN
3415  kca=pycomp(k(i,2))
3416  IF(mwid(kca).NE.0.AND.mdcy(kca,1).GE.1) THEN
3417  CALL pyresd(i)
3418  IF(mint(51).EQ.1) goto 100
3419  ENDIF
3420  ENDIF
3421  150 CONTINUE
3422  ENDIF
3423 
3424 C...Boost hadronic subsystem to overall rest frame.
3425 C..(Only relevant when photon inside lepton beam.)
3426  IF(mint(141).NE.0.OR.mint(142).NE.0) CALL pygaga(4,wtgaga)
3427 
3428 C...Recalculate energies from momenta and masses (if desired).
3429  IF(mstp(113).GE.1) THEN
3430  DO 160 i=mint(83)+1,n
3431  IF(k(i,1).GT.0.AND.k(i,1).LE.10) p(i,4)=sqrt(p(i,1)**2+
3432  & p(i,2)**2+p(i,3)**2+p(i,5)**2)
3433  160 CONTINUE
3434  nrecal=n
3435  ENDIF
3436 
3437 C...Colour reconnection before string formation
3438  IF (mstp(95).GE.2) CALL pyfscr(mint(84)+1)
3439 
3440 C...Rearrange partons along strings, check invariant mass cuts.
3441  mstu(28)=0
3442  IF(mstp(111).LE.0) mstj(14)=-1
3443  CALL pyprep(mint(84)+1)
3444  mstj(14)=mstj14
3445  IF(mint(51).EQ.1.AND.mstu(24).EQ.1) THEN
3446  mstu(24)=0
3447  goto 100
3448  ENDIF
3449  IF (mint(51).EQ.1.AND.nprep.LE.5) goto 110
3450  IF (mint(51).EQ.1) goto 100
3451  IF(mstp(112).EQ.1.AND.mstu(28).EQ.3) goto 100
3452  IF(mstp(125).EQ.0.OR.mstp(125).EQ.1) THEN
3453  DO 190 i=mint(84)+1,n
3454  IF(k(i,2).EQ.94) THEN
3455  DO 180 i1=i+1,min(n,i+10)
3456  IF(k(i1,3).EQ.i) THEN
3457  k(i1,3)=mod(k(i1,4)/mstu(5),mstu(5))
3458  IF(k(i1,3).EQ.0) THEN
3459  DO 170 ii=mint(84)+1,i-1
3460  IF(k(ii,2).EQ.k(i1,2)) THEN
3461  IF(mod(k(ii,4),mstu(5)).EQ.i1.OR.
3462  & mod(k(ii,5),mstu(5)).EQ.i1) k(i1,3)=ii
3463  ENDIF
3464  170 CONTINUE
3465  IF(k(i+1,3).EQ.0) k(i+1,3)=k(i,3)
3466  ENDIF
3467  ENDIF
3468  180 CONTINUE
3469  ENDIF
3470  190 CONTINUE
3471  CALL pyedit(12)
3472  CALL pyedit(14)
3473  IF(mstp(125).EQ.0) CALL pyedit(15)
3474  IF(mstp(125).EQ.0) mint(4)=0
3475  DO 210 i=mint(83)+1,n
3476  IF(k(i,1).EQ.11.AND.k(i,4).EQ.0.AND.k(i,5).EQ.0) THEN
3477  DO 200 i1=i+1,n
3478  IF(k(i1,3).EQ.i.AND.k(i,4).EQ.0) k(i,4)=i1
3479  IF(k(i1,3).EQ.i) k(i,5)=i1
3480  200 CONTINUE
3481  ENDIF
3482  210 CONTINUE
3483  ENDIF
3484 
3485 C...Introduce separators between sections in PYLIST event listing.
3486  IF(ipile.EQ.1.AND.mstp(125).LE.0) THEN
3487  mstu70=1
3488  mstu(71)=n
3489  ELSEIF(ipile.EQ.1) THEN
3490  mstu70=3
3491  mstu(71)=2
3492  mstu(72)=mint(4)
3493  mstu(73)=n
3494  ENDIF
3495 
3496 C...Go back to lab frame (needed for vertices, also in fragmentation).
3497  CALL pyfram(1)
3498 
3499 C...Set nonvanishing production vertex (optional).
3500  IF(mstp(151).EQ.1) THEN
3501  DO 220 j=1,4
3502  vtx(j)=parp(150+j)*sqrt(-2d0*log(max(1d-10,pyr(0))))*
3503  & sin(paru(2)*pyr(0))
3504  220 CONTINUE
3505  DO 240 i=mint(83)+1,n
3506  DO 230 j=1,4
3507  v(i,j)=v(i,j)+vtx(j)
3508  230 CONTINUE
3509  240 CONTINUE
3510  ENDIF
3511 
3512 C...Perform hadronization (if desired).
3513  IF(mstp(111).GE.1) THEN
3514  CALL pyexec
3515  IF(mstu(24).NE.0) goto 100
3516  ENDIF
3517  IF(mstp(113).GE.1) THEN
3518  DO 250 i=nrecal,n
3519  IF(p(i,5).GT.0d0) p(i,4)=sqrt(p(i,1)**2+
3520  & p(i,2)**2+p(i,3)**2+p(i,5)**2)
3521  250 CONTINUE
3522  ENDIF
3523  IF(mstp(125).EQ.0.OR.mstp(125).EQ.1) CALL pyedit(14)
3524 
3525 C...Store event information and calculate Monte Carlo estimates of
3526 C...subprocess cross-sections.
3527  260 IF(ipile.EQ.1) CALL pydocu
3528 
3529 C...Set counters for current pileup event and loop to next one.
3530  msti(41)=ipile
3531  IF(ipile.GE.2.AND.ipile.LE.10) msti(40+ipile)=isub
3532  IF(mstu70.LT.10) THEN
3533  mstu70=mstu70+1
3534  mstu(70+mstu70)=n
3535  ENDIF
3536  mint(83)=n
3537  mint(84)=n+mstp(126)
3538  IF(ipile.LT.npile) CALL pyfram(2)
3539  270 CONTINUE
3540 
3541 C...Generic information on pileup events. Reconstruct missing history.
3542  IF(mstp(131).EQ.1.AND.mstp(133).GE.1) THEN
3543  pari(91)=vint(132)
3544  pari(92)=vint(133)
3545  pari(93)=vint(134)
3546  IF(mstp(133).GE.2) pari(93)=pari(93)*xsec(0,3)/vint(131)
3547  ENDIF
3548  CALL pyedit(16)
3549 
3550 C...Transform to the desired coordinate frame.
3551  280 CALL pyfram(mstp(124))
3552  mstu(70)=mstu70
3553  paru(21)=vint(1)
3554 
3555 C...Error messages
3556  5100 FORMAT(1x,'Error: no subprocess switched on.'/
3557  &1x,'Execution stopped.')
3558 
3559  RETURN
3560  END
3561 
3562 C*********************************************************************
3563 
3564 C...PYEVNW
3565 C...Administers the generation of a high-pT event via calls to
3566 C...a number of subroutines for the new multiple interactions and
3567 C...showering framework.
3568 
3569  SUBROUTINE pyevnw
3570 
3571 C...Double precision and integer declarations.
3572  IMPLICIT DOUBLE PRECISION(a-h, o-z)
3573  IMPLICIT INTEGER(i-n)
3574  INTEGER pyk,pychge,pycomp
3575  parameter(maxnur=1000)
3576 C...Commonblocks.
3577  common/pypart/npart,npartd,ipart(maxnur),ptpart(maxnur)
3578 C...Commonblocks.
3579  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
3580  common/pyctag/nct,mct(4000,2)
3581  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
3582  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
3583  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
3584  common/pypars/mstp(200),parp(200),msti(200),pari(200)
3585  common/pyint1/mint(400),vint(400)
3586  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
3587  common/pyint4/mwid(500),wids(500,5)
3588  common/pyint5/ngenpd,ngen(0:500,3),xsec(0:500,3)
3589  common/pyintm/kfival(2,3),nmi(2),imi(2,800,2),nvc(2,-6:6),
3590  & xassoc(2,-6:6,240),xpsvc(-6:6,-1:240),pvctot(2,-1:1),
3591  & xmi(2,240),pt2mi(240),imisep(0:240)
3592  SAVE /pyjets/,/pyctag/,/pydat1/,/pydat2/,/pydat3/,
3593  & /pypars/,/pyint1/,/pyint2/,/pyint4/,/pyint5/,/pyintm/
3594 C...Local arrays.
3595  dimension vtx(4)
3596 
3597 C...Stop if no subprocesses on.
3598  IF(mint(121).EQ.1.AND.msti(53).EQ.1) THEN
3599  WRITE(mstu(11),5100)
3600  CALL pystop(1)
3601  ENDIF
3602 
3603 C...Initial values for some counters.
3604  mstu(1)=0
3605  mstu(2)=0
3606  n=0
3607  mint(5)=mint(5)+1
3608  mint(7)=0
3609  mint(8)=0
3610  mint(30)=0
3611  mint(83)=0
3612  mint(84)=mstp(126)
3613  mstu(24)=0
3614  mstu70=0
3615  mstj14=mstj(14)
3616 C...Normally, use K(I,4:5) colour info rather than /PYCT/.
3617  nct=0
3618  mint(33)=0
3619 C...Zero counters for pT-ordered showers (failsafe)
3620  npart=0
3621  npartd=0
3622 
3623 C...Let called routines know call is from PYEVNW (not PYEVNT).
3624  mint(35)=3
3625 
3626 C...If variable energies: redo incoming kinematics and cross-section.
3627  msti(61)=0
3628  IF(mstp(171).EQ.1) THEN
3629  CALL pyinki(1)
3630  IF(msti(61).EQ.1) THEN
3631  mint(5)=mint(5)-1
3632  RETURN
3633  ENDIF
3634  IF(mint(121).GT.1) CALL pysave(3,1)
3635  CALL pyxtot
3636  ENDIF
3637 
3638 C...Loop over number of pileup events; check space left.
3639  IF(mstp(131).LE.0) THEN
3640  npile=1
3641  ELSE
3642  CALL pypile(2)
3643  npile=mint(81)
3644  ENDIF
3645  DO 300 ipile=1,npile
3646  IF(mint(84)+100.GE.mstu(4)) THEN
3647  CALL pyerrm(11,
3648  & '(PYEVNW:) no more space in PYJETS for pileup events')
3649  IF(mstu(21).GE.1) goto 310
3650  ENDIF
3651  mint(82)=ipile
3652 
3653 C...Generate variables of hard scattering.
3654  mint(51)=0
3655  msti(52)=0
3656  loophs =0
3657  100 CONTINUE
3658  loophs = loophs + 1
3659  IF(mint(51).NE.0.OR.mstu(24).NE.0) msti(52)=msti(52)+1
3660  IF(loophs.GE.10) THEN
3661  CALL pyerrm(19,'(PYEVNW:) failed to evolve shower or '
3662  & //'multiple interactions. Returning.')
3663  mint(51)=1
3664  RETURN
3665  ENDIF
3666  mint(31)=0
3667  mint(39)=0
3668  mint(36)=0
3669  mint(51)=0
3670  mint(57)=0
3671  CALL pyrand
3672  IF(msti(61).EQ.1) THEN
3673  mint(5)=mint(5)-1
3674  RETURN
3675  ENDIF
3676  IF(mint(51).EQ.2) RETURN
3677  isub=mint(1)
3678  IF(mstp(111).EQ.-1) goto 290
3679 
3680 C...Loopback point if PYPREP fails, especially for junction topologies.
3681  nprep=0
3682  mnt31s=mint(31)
3683  110 nprep=nprep+1
3684  mint(31)=mnt31s
3685 
3686  IF((isub.LE.90.OR.isub.GE.95).AND.isub.NE.99) THEN
3687 C...Hard scattering (including low-pT):
3688 C...reconstruct kinematics and colour flow of hard scattering.
3689  mint31=mint(31)
3690  120 mint(31)=mint31
3691  mint(51)=0
3692  CALL pyscat
3693  IF(mint(51).EQ.1) goto 100
3694  npartd=n
3695  nfin=n
3696 
3697 C...Intertwined initial state showers and multiple interactions.
3698 C...Force no IS showers if no pdfs defined: MSTP(61) -> 0 for PYEVOL.
3699 C...Force no MI if cross section not known: MSTP(81) -> 0 for PYEVOL.
3700  mstp61=mstp(61)
3701  IF (mint(47).LT.2) mstp(61)=0
3702  mstp81=mstp(81)
3703  IF (mint(50).EQ.0) mstp(81)=0
3704  IF ((mstp(61).GE.1.OR.mod(mstp(81),10).GE.0).AND.
3705  & mint(111).NE.12) THEN
3706 C...Absolute max pT2 scale for evolution: phase space limit.
3707  pt2mxs=0.25d0*vint(2)
3708 C...Check if more constrained by ISR and MI max scales:
3709  pt2mxs=min(pt2mxs,max(max(1d0,parp(67))*vint(56),vint(62)))
3710 C...Loopback point in case of failure in evolution.
3711  loop=0
3712  130 loop=loop+1
3713  mint(51)=0
3714  IF(loop.GT.100) THEN
3715  CALL pyerrm(9,'(PYEVNW:) failed to evolve shower or '
3716  & //'multiple interactions. Trying new point.')
3717  mint(51)=1
3718  RETURN
3719  ENDIF
3720 
3721 C...Pre-initialization of interleaved MI/ISR/JI evolution, only done
3722 C...once per event. (E.g. compute constants and save variables to be
3723 C...restored later in case of failure.)
3724  IF (loop.EQ.1) CALL pyevol(-1,dummy1,dummy2)
3725 
3726 C...Initialize interleaved MI/ISR/JI evolution.
3727 C...PT2MAX: absolute upper limit for evolution - Initialization may
3728 C... return a PT2MAX which is lower than this.
3729 C...PT2MIN: absolute lower limit for evolution - Initialization may
3730 C... return a PT2MIN which is larger than this (e.g. Lambda_QCD).
3731  pt2max=pt2mxs
3732  pt2min=0d0
3733  CALL pyevol(0,pt2max,pt2min)
3734 C...If failed to initialize evolution, generate a new hard process
3735  IF (mint(51).EQ.1) goto 100
3736 
3737 C...Perform interleaved MI/ISR/JI evolution from PT2MAX to PT2MIN.
3738 C...In principle factorized, so can be stopped and restarted.
3739 C...Example: stop/start at pT=10 GeV. (Commented out for now.)
3740 C PT2MED=MAX(10D0**2,PT2MIN)
3741 C CALL PYEVOL(1,PT2MAX,PT2MED)
3742 C IF (MINT(51).EQ.1) GOTO 160
3743 C PT2MAX=PT2MED
3744  CALL pyevol(1,pt2max,pt2min)
3745 C...If fatal error (e.g., massive hard-process initiator, but no available
3746 C...phase space for creation), generate a new hard process
3747  IF (mint(51).EQ.2) goto 100
3748 C...If smaller error, just try running evolution again
3749  IF (mint(51).EQ.1) goto 130
3750 
3751 C...Finalize interleaved MI/ISR/JI evolution.
3752  CALL pyevol(2,pt2max,pt2min)
3753  IF (mint(51).EQ.1) goto 130
3754 
3755  ENDIF
3756  mstp(61)=mstp61
3757  mstp(81)=mstp81
3758  IF(mint(51).EQ.1) goto 100
3759 C...(MINT(52) is actually obsolete in this routine. Set anyway
3760 C...to ensure PYDOCU stable.)
3761  mint(52)=n
3762  mint(53)=n
3763 
3764 C...Beam remnants - new scheme.
3765  140 IF(mint(50).EQ.1) THEN
3766  IF (isub.EQ.95) mint(31)=1
3767 
3768 C...Beam remnant flavour and colour assignments - new scheme.
3769  CALL pymihk
3770  IF(mint(51).EQ.1.AND.mint(57).GE.1.AND.mint(57).LE.5)
3771  & goto 120
3772  IF(mint(51).EQ.1) goto 100
3773 
3774 C...Primordial kT and beam remnant momentum sharing - new scheme.
3775  CALL pymirm
3776  IF(mint(51).EQ.1.AND.mint(57).GE.1.AND.mint(57).LE.5)
3777  & goto 120
3778  IF(mint(51).EQ.1) goto 100
3779  IF (isub.EQ.95) mint(31)=0
3780  ELSEIF(mint(111).NE.12) THEN
3781 C...Hadron remnants and primordial kT - old model.
3782 C...Happens e.g. for direct photon on one side.
3783  ipu1=imi(1,1,1)
3784  ipu2=imi(2,1,1)
3785  CALL pyremn(ipu1,ipu2)
3786  IF(mint(51).EQ.1.AND.mint(57).GE.1.AND.mint(57).LE.5) goto
3787  & 110
3788  IF(mint(51).EQ.1) goto 100
3789 C...PYREMN does not set colour tags for BRs, so needs to be done now.
3790  DO 160 i=mint(53)+1,n
3791  DO 150 kcs=4,5
3792  ida=mod(k(i,kcs),mstu(5))
3793  IF (ida.NE.0) THEN
3794  mct(i,kcs-3)=mct(ida,6-kcs)
3795  ELSE
3796  mct(i,kcs-3)=0
3797  ENDIF
3798  150 CONTINUE
3799  160 CONTINUE
3800 C...Instruct PYPREP to use colour tags
3801  mint(33)=1
3802 
3803  DO 360 mqgst=1,2
3804  DO 350 i=mint(84)+1,n
3805 
3806 C...Look for coloured string endpoint, or (later) leftover gluon.
3807  IF (k(i,1).NE.3) goto 350
3808  kc=pycomp(k(i,2))
3809  IF(kc.EQ.0) goto 350
3810  kq=kchg(kc,2)
3811  IF(kq.EQ.0.OR.(mqgst.EQ.1.AND.kq.EQ.2)) goto 350
3812 
3813 C... Pick up loose string end with no previous tag.
3814  kcs=4
3815  IF(kq*isign(1,k(i,2)).LT.0) kcs=5
3816  IF(mct(i,kcs-3).NE.0) goto 350
3817 
3818  CALL pycttr(i,kcs,i)
3819  IF(mint(51).NE.0) RETURN
3820 
3821  350 CONTINUE
3822  360 CONTINUE
3823 C...Now delete any colour processing information if set (since partons
3824 C...otherwise not FS showered!)
3825  DO 170 i=mint(84)+1,n
3826  IF (i.LE.n) THEN
3827  k(i,4)=mod(k(i,4),mstu(5)**2)
3828  k(i,5)=mod(k(i,5),mstu(5)**2)
3829  ENDIF
3830  170 CONTINUE
3831  ENDIF
3832 
3833 C...Showering of final state partons (optional).
3834  alamsv=parj(81)
3835  parj(81)=parp(72)
3836  IF(mstp(71).GE.1.AND.iset(isub).GE.1.AND.iset(isub).LE.10)
3837  & THEN
3838  qmax=vint(55)
3839  IF(iset(isub).EQ.2) qmax=sqrt(parp(71))*vint(55)
3840  CALL pyptfs(1,qmax,0d0,ptgen)
3841 C...External processes: handle successive showers.
3842  ELSEIF(iset(isub).EQ.11) THEN
3843  CALL pyadsh(nfin)
3844  ENDIF
3845  parj(81)=alamsv
3846 
3847 C...Allow possibility for user to abort event generation.
3848  iveto=0
3849  IF(ipile.EQ.1.AND.mstp(143).EQ.1) CALL pyveto(iveto) ! sm
3850  IF(iveto.EQ.1) THEN
3851 C...........No reason to count this as an error
3852  loophs = loophs-1
3853  goto 100
3854  ENDIF
3855 
3856 
3857 C...Decay of final state resonances.
3858  mint(32)=0
3859  IF(mstp(41).GE.1.AND.iset(isub).LE.10) THEN
3860  CALL pyresd(0)
3861  IF(mint(51).NE.0) goto 100
3862  ENDIF
3863 
3864  IF(mint(51).EQ.1) goto 100
3865 
3866  ELSEIF(isub.NE.99) THEN
3867 C...Diffractive and elastic scattering.
3868  CALL pydiff
3869 
3870  ELSE
3871 C...DIS scattering (photon flux external).
3872  CALL pydisg
3873  IF(mint(51).EQ.1) goto 100
3874  ENDIF
3875 
3876 C...Check that no odd resonance left undecayed.
3877  mint(54)=n
3878  IF(mstp(111).GE.1) THEN
3879  nfix=n
3880  DO 180 i=mint(84)+1,nfix
3881  IF(k(i,1).GE.1.AND.k(i,1).LE.10.AND.k(i,2).NE.21.AND.
3882  & k(i,2).NE.22) THEN
3883  kca=pycomp(k(i,2))
3884  IF(mwid(kca).NE.0.AND.mdcy(kca,1).GE.1) THEN
3885  CALL pyresd(i)
3886  IF(mint(51).EQ.1) goto 100
3887  ENDIF
3888  ENDIF
3889  180 CONTINUE
3890  ENDIF
3891 
3892 C...Boost hadronic subsystem to overall rest frame.
3893 C..(Only relevant when photon inside lepton beam.)
3894  IF(mint(141).NE.0.OR.mint(142).NE.0) CALL pygaga(4,wtgaga)
3895 
3896 C...Recalculate energies from momenta and masses (if desired).
3897  IF(mstp(113).GE.1) THEN
3898  DO 190 i=mint(83)+1,n
3899  IF(k(i,1).GT.0.AND.k(i,1).LE.10) p(i,4)=sqrt(p(i,1)**2+
3900  & p(i,2)**2+p(i,3)**2+p(i,5)**2)
3901  190 CONTINUE
3902  nrecal=n
3903  ENDIF
3904 
3905 C...Colour reconnection before string formation
3906  CALL pyfscr(mint(84)+1)
3907 
3908 C...Rearrange partons along strings, check invariant mass cuts.
3909  mstu(28)=0
3910  IF(mstp(111).LE.0) mstj(14)=-1
3911  CALL pyprep(mint(84)+1)
3912  mstj(14)=mstj14
3913  IF(mint(51).EQ.1.AND.mstu(24).EQ.1) THEN
3914  mstu(24)=0
3915  goto 100
3916  ENDIF
3917  IF(mint(51).EQ.1) goto 110
3918  IF(mstp(112).EQ.1.AND.mstu(28).EQ.3) goto 100
3919  IF(mstp(125).EQ.0.OR.mstp(125).EQ.1) THEN
3920  DO 220 i=mint(84)+1,n
3921  IF(k(i,2).EQ.94) THEN
3922  DO 210 i1=i+1,min(n,i+10)
3923  IF(k(i1,3).EQ.i) THEN
3924  k(i1,3)=mod(k(i1,4)/mstu(5),mstu(5))
3925  IF(k(i1,3).EQ.0) THEN
3926  DO 200 ii=mint(84)+1,i-1
3927  IF(k(ii,2).EQ.k(i1,2)) THEN
3928  IF(mod(k(ii,4),mstu(5)).EQ.i1.OR.
3929  & mod(k(ii,5),mstu(5)).EQ.i1) k(i1,3)=ii
3930  ENDIF
3931  200 CONTINUE
3932  IF(k(i+1,3).EQ.0) k(i+1,3)=k(i,3)
3933  ENDIF
3934  ENDIF
3935  210 CONTINUE
3936 C...Also collapse particles decaying to themselves (if same KS)
3937 C...Sep 22 2009: Commented out by PS following suggestion by TS to fix
3938 C...problem with history point-backs in new shower, where a particle is
3939 C...copied with a new momentum when it is the recoiler.
3940 C ELSEIF (K(I,1).GT.0.AND.K(I,4).EQ.K(I,5).AND.K(I,4).GT.0
3941 C & .AND.K(I,4).LT.N) THEN
3942 C IDA=K(I,4)
3943 C IF (K(IDA,1).EQ.K(I,1).AND.K(IDA,2).EQ.K(I,2)) THEN
3944 C K(I,1)=0
3945 C ENDIF
3946  ENDIF
3947  220 CONTINUE
3948  CALL pyedit(12)
3949  CALL pyedit(14)
3950  IF(mstp(125).EQ.0) CALL pyedit(15)
3951  IF(mstp(125).EQ.0) mint(4)=0
3952  DO 240 i=mint(83)+1,n
3953  IF(k(i,1).EQ.11.AND.k(i,4).EQ.0.AND.k(i,5).EQ.0) THEN
3954  DO 230 i1=i+1,n
3955  IF(k(i1,3).EQ.i.AND.k(i,4).EQ.0) k(i,4)=i1
3956  IF(k(i1,3).EQ.i) k(i,5)=i1
3957  230 CONTINUE
3958  ENDIF
3959  240 CONTINUE
3960  ENDIF
3961 
3962 C...Introduce separators between sections in PYLIST event listing.
3963  IF(ipile.EQ.1.AND.mstp(125).LE.0) THEN
3964  mstu70=1
3965  mstu(71)=n
3966  ELSEIF(ipile.EQ.1) THEN
3967  mstu70=3
3968  mstu(71)=2
3969  mstu(72)=mint(4)
3970  mstu(73)=n
3971  ENDIF
3972 
3973 C...Go back to lab frame (needed for vertices, also in fragmentation).
3974  CALL pyfram(1)
3975 
3976 C...Set nonvanishing production vertex (optional).
3977  IF(mstp(151).EQ.1) THEN
3978  DO 250 j=1,4
3979  vtx(j)=parp(150+j)*sqrt(-2d0*log(max(1d-10,pyr(0))))*
3980  & sin(paru(2)*pyr(0))
3981  250 CONTINUE
3982  DO 270 i=mint(83)+1,n
3983  DO 260 j=1,4
3984  v(i,j)=v(i,j)+vtx(j)
3985  260 CONTINUE
3986  270 CONTINUE
3987  ENDIF
3988 
3989 C...Perform hadronization (if desired).
3990  IF(mstp(111).GE.1) THEN
3991  CALL pyexec
3992  IF(mstu(24).NE.0) goto 100
3993  ENDIF
3994  IF(mstp(113).GE.1) THEN
3995  DO 280 i=nrecal,n
3996  IF(p(i,5).GT.0d0) p(i,4)=sqrt(p(i,1)**2+
3997  & p(i,2)**2+p(i,3)**2+p(i,5)**2)
3998  280 CONTINUE
3999  ENDIF
4000  IF(mstp(125).EQ.0.OR.mstp(125).EQ.1) CALL pyedit(14)
4001 
4002 C...Store event information and calculate Monte Carlo estimates of
4003 C...subprocess cross-sections.
4004  290 IF(ipile.EQ.1) CALL pydocu
4005 
4006 C...Set counters for current pileup event and loop to next one.
4007  msti(41)=ipile
4008  IF(ipile.GE.2.AND.ipile.LE.10) msti(40+ipile)=isub
4009  IF(mstu70.LT.10) THEN
4010  mstu70=mstu70+1
4011  mstu(70+mstu70)=n
4012  ENDIF
4013  mint(83)=n
4014  mint(84)=n+mstp(126)
4015  IF(ipile.LT.npile) CALL pyfram(2)
4016  300 CONTINUE
4017 
4018 C...Generic information on pileup events. Reconstruct missing history.
4019  IF(mstp(131).EQ.1.AND.mstp(133).GE.1) THEN
4020  pari(91)=vint(132)
4021  pari(92)=vint(133)
4022  pari(93)=vint(134)
4023  IF(mstp(133).GE.2) pari(93)=pari(93)*xsec(0,3)/vint(131)
4024  ENDIF
4025  CALL pyedit(16)
4026 
4027 C...Transform to the desired coordinate frame.
4028  310 CALL pyfram(mstp(124))
4029  mstu(70)=mstu70
4030  paru(21)=vint(1)
4031 
4032 C...Error messages
4033  5100 FORMAT(1x,'Error: no subprocess switched on.'/
4034  &1x,'Execution stopped.')
4035 
4036  RETURN
4037  END
4038 
4039 
4040 C***********************************************************************
4041 
4042 C...PYSTAT
4043 C...Prints out information about cross-sections, decay widths, branching
4044 C...ratios, kinematical limits, status codes and parameter values.
4045 
4046  SUBROUTINE pystat(MSTAT)
4047 
4048 C...Double precision and integer declarations.
4049  IMPLICIT DOUBLE PRECISION(a-h, o-z)
4050  IMPLICIT INTEGER(i-n)
4051  INTEGER pyk,pychge,pycomp
4052 C...Parameter statement to help give large particle numbers.
4053  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
4054  &kexcit=4000000,kdimen=5000000)
4055  parameter(eps=1d-3)
4056 C...Commonblocks.
4057  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
4058  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
4059  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
4060  common/pysubs/msel,mselpd,msub(500),kfin(2,-40:40),ckin(200)
4061  common/pypars/mstp(200),parp(200),msti(200),pari(200)
4062  common/pyint1/mint(400),vint(400)
4063  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
4064  common/pyint4/mwid(500),wids(500,5)
4065  common/pyint5/ngenpd,ngen(0:500,3),xsec(0:500,3)
4066  common/pyint6/proc(0:500)
4067  CHARACTER proc*28, chtmp*16
4068  common/pymssm/imss(0:99),rmss(0:99)
4069  common/pymsrv/rvlam(3,3,3), rvlamp(3,3,3), rvlamb(3,3,3)
4070  SAVE /pydat1/,/pydat2/,/pydat3/,/pysubs/,/pypars/,/pyint1/,
4071  &/pyint2/,/pyint4/,/pyint5/,/pyint6/,/pymssm/,/pymsrv/
4072 C...Local arrays, character variables and data.
4073  dimension wdtp(0:400),wdte(0:400,0:5),nmodes(0:20),pbrat(10)
4074  CHARACTER proga(6)*28,chau*16,chkf*16,chd1*16,chd2*16,chd3*16,
4075  &chin(2)*12,state(-1:5)*4,chkin(21)*18,disga(2)*28,
4076  &progg9(13)*28,progg4(4)*28,progg2(2)*28,progp4(4)*28
4077  CHARACTER*24 chd0, chdc(10)
4078  CHARACTER*6 dname(3)
4079  DATA proga/
4080  &'VMD/hadron * VMD ','VMD/hadron * direct ',
4081  &'VMD/hadron * anomalous ','direct * direct ',
4082  &'direct * anomalous ','anomalous * anomalous '/
4083  DATA disga/'e * VMD','e * anomalous'/
4084  DATA progg9/
4085  &'direct * direct ','direct * VMD ',
4086  &'direct * anomalous ','VMD * direct ',
4087  &'VMD * VMD ','VMD * anomalous ',
4088  &'anomalous * direct ','anomalous * VMD ',
4089  &'anomalous * anomalous ','DIS * VMD ',
4090  &'DIS * anomalous ','VMD * DIS ',
4091  &'anomalous * DIS '/
4092  DATA progg4/
4093  &'direct * direct ','direct * resolved ',
4094  &'resolved * direct ','resolved * resolved '/
4095  DATA progg2/
4096  &'direct * hadron ','resolved * hadron '/
4097  DATA progp4/
4098  &'VMD * hadron ','direct * hadron ',
4099  &'anomalous * hadron ','DIS * hadron '/
4100  DATA state/'----','off ','on ','on/+','on/-','on/1','on/2'/,
4101  &chkin/' m_hard (GeV/c^2) ',' p_T_hard (GeV/c) ',
4102  &'m_finite (GeV/c^2)',' y*_subsystem ',' y*_large ',
4103  &' y*_small ',' eta*_large ',' eta*_small ',
4104  &'cos(theta*)_large ','cos(theta*)_small ',' x_1 ',
4105  &' x_2 ',' x_F ',' cos(theta_hard) ',
4106  &'m''_hard (GeV/c^2) ',' tau ',' y* ',
4107  &'cos(theta_hard^-) ','cos(theta_hard^+) ',' x_T^2 ',
4108  &' tau'' '/
4109  DATA dname /'q ','lepton','nu '/
4110 
4111 C...Cross-sections.
4112  IF(mstat.LE.1) THEN
4113  IF(mint(121).GT.1) CALL pysave(5,0)
4114  WRITE(mstu(11),5000)
4115  WRITE(mstu(11),5100)
4116  WRITE(mstu(11),5200) 0,proc(0),ngen(0,3),ngen(0,1),xsec(0,3)
4117  DO 100 i=1,500
4118  IF(msub(i).NE.1) goto 100
4119  WRITE(mstu(11),5200) i,proc(i),ngen(i,3),ngen(i,1),xsec(i,3)
4120  100 CONTINUE
4121  IF(mint(121).GT.1) THEN
4122  WRITE(mstu(11),5300)
4123  DO 110 iga=1,mint(121)
4124  CALL pysave(3,iga)
4125  IF(mint(121).EQ.2.AND.mstp(14).EQ.10) THEN
4126  WRITE(mstu(11),5200) iga,disga(iga),ngen(0,3),ngen(0,1),
4127  & xsec(0,3)
4128  ELSEIF(mint(121).EQ.9.OR.mint(121).EQ.13) THEN
4129  WRITE(mstu(11),5200) iga,progg9(iga),ngen(0,3),ngen(0,1),
4130  & xsec(0,3)
4131  ELSEIF(mint(121).EQ.4.AND.mstp(14).EQ.30) THEN
4132  WRITE(mstu(11),5200) iga,progp4(iga),ngen(0,3),ngen(0,1),
4133  & xsec(0,3)
4134  ELSEIF(mint(121).EQ.4) THEN
4135  WRITE(mstu(11),5200) iga,progg4(iga),ngen(0,3),ngen(0,1),
4136  & xsec(0,3)
4137  ELSEIF(mint(121).EQ.2) THEN
4138  WRITE(mstu(11),5200) iga,progg2(iga),ngen(0,3),ngen(0,1),
4139  & xsec(0,3)
4140  ELSE
4141  WRITE(mstu(11),5200) iga,proga(iga),ngen(0,3),ngen(0,1),
4142  & xsec(0,3)
4143  ENDIF
4144  110 CONTINUE
4145  CALL pysave(5,0)
4146  ENDIF
4147  WRITE(mstu(11),5400) mstu(23),mstu(30),mstu(27),
4148  & 1d0-dble(ngen(0,3))/max(1d0,dble(ngen(0,2)))
4149 
4150 C...Decay widths and branching ratios.
4151  ELSEIF(mstat.EQ.2) THEN
4152  WRITE(mstu(11),5500)
4153  WRITE(mstu(11),5600)
4154  DO 140 kc=1,500
4155  kf=kchg(kc,4)
4156  CALL pyname(kf,chkf)
4157  ioff=0
4158  IF(kc.LE.22) THEN
4159  IF(kc.GT.2*mstp(1).AND.kc.LE.10) goto 140
4160  IF(kc.GT.10+2*mstp(1).AND.kc.LE.20) goto 140
4161  IF(kc.LE.5.OR.(kc.GE.11.AND.kc.LE.16)) ioff=1
4162  IF(kc.EQ.18.AND.pmas(18,1).LT.1d0) ioff=1
4163  IF(kc.EQ.21.OR.kc.EQ.22) ioff=1
4164  ELSE
4165  IF(mwid(kc).LE.0) goto 140
4166  IF(imss(1).LE.0.AND.(kf/ksusy1.EQ.1.OR.
4167  & kf/ksusy1.EQ.2)) goto 140
4168  ENDIF
4169 C...Off-shell branchings.
4170  IF(ioff.EQ.1) THEN
4171  ngp=0
4172  IF(kc.LE.20) ngp=(mod(kc,10)+1)/2
4173  IF(ngp.LE.mstp(1)) WRITE(mstu(11),5700) kf,chkf(1:10),
4174  & pmas(kc,1),0d0,0d0,state(mdcy(kc,1)),0d0
4175  DO 120 j=1,mdcy(kc,3)
4176  idc=j+mdcy(kc,2)-1
4177  ngp1=0
4178  IF(iabs(kfdp(idc,1)).LE.20) ngp1=
4179  & (mod(iabs(kfdp(idc,1)),10)+1)/2
4180  ngp2=0
4181  IF(iabs(kfdp(idc,2)).LE.20) ngp2=
4182  & (mod(iabs(kfdp(idc,2)),10)+1)/2
4183  CALL pyname(kfdp(idc,1),chd1)
4184  CALL pyname(kfdp(idc,2),chd2)
4185  IF(kfdp(idc,3).EQ.0) THEN
4186  IF(mdme(idc,2).EQ.102.AND.ngp1.LE.mstp(1).AND.
4187  & ngp2.LE.mstp(1)) WRITE(mstu(11),5800) idc,chd1(1:10),
4188  & chd2(1:10),0d0,0d0,state(mdme(idc,1)),0d0
4189  ELSE
4190  CALL pyname(kfdp(idc,3),chd3)
4191  IF(mdme(idc,2).EQ.102.AND.ngp1.LE.mstp(1).AND.
4192  & ngp2.LE.mstp(1)) WRITE(mstu(11),5900) idc,chd1(1:10),
4193  & chd2(1:10),chd3(1:10),0d0,0d0,state(mdme(idc,1)),0d0
4194  ENDIF
4195  120 CONTINUE
4196 C...On-shell decays.
4197  ELSE
4198  CALL pywidt(kf,pmas(kc,1)**2,wdtp,wdte)
4199  brfin=1d0
4200  IF(wdte(0,0).LE.0d0) brfin=0d0
4201  WRITE(mstu(11),5700) kf,chkf(1:10),pmas(kc,1),wdtp(0),1d0,
4202  & state(mdcy(kc,1)),brfin
4203  DO 130 j=1,mdcy(kc,3)
4204  idc=j+mdcy(kc,2)-1
4205  ngp1=0
4206  IF(iabs(kfdp(idc,1)).LE.20) ngp1=
4207  & (mod(iabs(kfdp(idc,1)),10)+1)/2
4208  ngp2=0
4209  IF(iabs(kfdp(idc,2)).LE.20) ngp2=
4210  & (mod(iabs(kfdp(idc,2)),10)+1)/2
4211  brpri=0d0
4212  IF(wdtp(0).GT.0d0) brpri=wdtp(j)/wdtp(0)
4213  brfin=0d0
4214  IF(wdte(0,0).GT.0d0) brfin=wdte(j,0)/wdte(0,0)
4215  CALL pyname(kfdp(idc,1),chd1)
4216  CALL pyname(kfdp(idc,2),chd2)
4217  IF(kfdp(idc,3).EQ.0) THEN
4218  IF(ngp1.LE.mstp(1).AND.ngp2.LE.mstp(1))
4219  & WRITE(mstu(11),5800) idc,chd1(1:10),
4220  & chd2(1:10),wdtp(j),brpri,
4221  & state(mdme(idc,1)),brfin
4222  ELSE
4223  CALL pyname(kfdp(idc,3),chd3)
4224  IF(ngp1.LE.mstp(1).AND.ngp2.LE.mstp(1))
4225  & WRITE(mstu(11),5900) idc,chd1(1:10),
4226  & chd2(1:10),chd3(1:10),wdtp(j),brpri,
4227  & state(mdme(idc,1)),brfin
4228  ENDIF
4229  130 CONTINUE
4230  ENDIF
4231  140 CONTINUE
4232  WRITE(mstu(11),6000)
4233 
4234 C...Allowed incoming partons/particles at hard interaction.
4235  ELSEIF(mstat.EQ.3) THEN
4236  WRITE(mstu(11),6100)
4237  CALL pyname(mint(11),chau)
4238  chin(1)=chau(1:12)
4239  CALL pyname(mint(12),chau)
4240  chin(2)=chau(1:12)
4241  WRITE(mstu(11),6200) chin(1),chin(2)
4242  DO 150 i=-20,22
4243  IF(i.EQ.0) goto 150
4244  ia=iabs(i)
4245  IF(ia.GT.mstp(58).AND.ia.LE.10) goto 150
4246  IF(ia.GT.10+2*mstp(1).AND.ia.LE.20) goto 150
4247  CALL pyname(i,chau)
4248  WRITE(mstu(11),6300) chau,state(kfin(1,i)),chau,
4249  & state(kfin(2,i))
4250  150 CONTINUE
4251  WRITE(mstu(11),6400)
4252 
4253 C...User-defined limits on kinematical variables.
4254  ELSEIF(mstat.EQ.4) THEN
4255  WRITE(mstu(11),6500)
4256  WRITE(mstu(11),6600)
4257  shrmax=ckin(2)
4258  IF(shrmax.LT.0d0) shrmax=vint(1)
4259  WRITE(mstu(11),6700) ckin(1),chkin(1),shrmax
4260  pthmin=max(ckin(3),ckin(5))
4261  pthmax=ckin(4)
4262  IF(pthmax.LT.0d0) pthmax=0.5d0*shrmax
4263  WRITE(mstu(11),6800) ckin(3),pthmin,chkin(2),pthmax
4264  WRITE(mstu(11),6900) chkin(3),ckin(6)
4265  DO 160 i=4,14
4266  WRITE(mstu(11),6700) ckin(2*i-1),chkin(i),ckin(2*i)
4267  160 CONTINUE
4268  sprmax=ckin(32)
4269  IF(sprmax.LT.0d0) sprmax=vint(1)
4270  WRITE(mstu(11),6700) ckin(31),chkin(15),sprmax
4271  WRITE(mstu(11),7000)
4272 
4273 C...Status codes and parameter values.
4274  ELSEIF(mstat.EQ.5) THEN
4275  WRITE(mstu(11),7100)
4276  WRITE(mstu(11),7200)
4277  DO 170 i=1,100
4278  WRITE(mstu(11),7300) i,mstp(i),parp(i),100+i,mstp(100+i),
4279  & parp(100+i)
4280  170 CONTINUE
4281 
4282 C...List of all processes implemented in the program.
4283  ELSEIF(mstat.EQ.6) THEN
4284  WRITE(mstu(11),7400)
4285  WRITE(mstu(11),7500)
4286  DO 180 i=1,500
4287  IF(iset(i).LT.0) goto 180
4288  WRITE(mstu(11),7600) i,proc(i),iset(i),kfpr(i,1),kfpr(i,2)
4289  180 CONTINUE
4290  WRITE(mstu(11),7700)
4291 
4292  ELSEIF(mstat.EQ.7) THEN
4293  WRITE (mstu(11),8000)
4294  nmodes(0)=0
4295  nmodes(10)=0
4296  nmodes(9)=0
4297  DO 290 ilr=1,2
4298  DO 280 kfsm=1,16
4299  kfsusy=ilr*ksusy1+kfsm
4300  nrvdc=0
4301 C...SDOWN DECAYS
4302  IF (kfsm.EQ.1.OR.kfsm.EQ.3.OR.kfsm.EQ.5) THEN
4303  nrvdc=3
4304  DO 190 i=1,nrvdc
4305  pbrat(i)=0d0
4306  nmodes(i)=0
4307  190 CONTINUE
4308  CALL pyname(kfsusy,chtmp)
4309  chd0=chtmp//' '
4310  chdc(1)=dname(3) // ' + ' // dname(1)
4311  chdc(2)=dname(2) // ' + ' // dname(1)
4312  chdc(3)=dname(1) // ' + ' // dname(1)
4313  kc=pycomp(kfsusy)
4314  DO 200 j=1,mdcy(kc,3)
4315  idc=j+mdcy(kc,2)-1
4316  id1=iabs(kfdp(idc,1))
4317  id2=iabs(kfdp(idc,2))
4318  IF (kfdp(idc,3).EQ.0) THEN
4319  IF ((id1.EQ.12.OR.id1.EQ.14.OR.id1.EQ.16).AND.(id2
4320  & .EQ.1.OR.id2.EQ.3.OR.id2.EQ.5)) THEN
4321  pbrat(1)=pbrat(1)+brat(idc)
4322  nmodes(1)=nmodes(1)+1
4323  IF (brat(idc).GT.0d0) nmodes(10)=nmodes(10)+1
4324  IF (brat(idc).GT.eps) nmodes(9)=nmodes(9)+1
4325  ELSE IF ((id1.EQ.11.OR.id1.EQ.13.OR.id1.EQ.15).and
4326  & .(id2.EQ.2.OR.id2.EQ.4.OR.id2.EQ.6)) THEN
4327  pbrat(2)=pbrat(2)+brat(idc)
4328  nmodes(2)=nmodes(2)+1
4329  IF (brat(idc).GT.0d0) nmodes(10)=nmodes(10)+1
4330  IF (brat(idc).GT.eps) nmodes(9)=nmodes(9)+1
4331  ELSE IF ((id1.EQ.2.OR.id1.EQ.4.OR.id1.EQ.6).and
4332  & .(id2.EQ.1.OR.id2.EQ.3.OR.id2.EQ.5)) THEN
4333  pbrat(3)=pbrat(3)+brat(idc)
4334  nmodes(3)=nmodes(3)+1
4335  IF (brat(idc).GT.0d0) nmodes(10)=nmodes(10)+1
4336  IF (brat(idc).GT.eps) nmodes(9)=nmodes(9)+1
4337  ENDIF
4338  ENDIF
4339  200 CONTINUE
4340  ENDIF
4341 C...SUP DECAYS
4342  IF (kfsm.EQ.2.OR.kfsm.EQ.4.OR.kfsm.EQ.6) THEN
4343  nrvdc=2
4344  DO 210 i=1,nrvdc
4345  nmodes(i)=0
4346  pbrat(i)=0d0
4347  210 CONTINUE
4348  CALL pyname(kfsusy,chtmp)
4349  chd0=chtmp//' '
4350  chdc(1)=dname(2) // ' + ' // dname(1)
4351  chdc(2)=dname(1) // ' + ' // dname(1)
4352  kc=pycomp(kfsusy)
4353  DO 220 j=1,mdcy(kc,3)
4354  idc=j+mdcy(kc,2)-1
4355  id1=iabs(kfdp(idc,1))
4356  id2=iabs(kfdp(idc,2))
4357  IF (kfdp(idc,3).EQ.0) THEN
4358  IF ((id1.EQ.11.OR.id1.EQ.13.OR.id1.EQ.15).AND.(id2
4359  & .EQ.1.OR.id2.EQ.3.OR.id2.EQ.5)) THEN
4360  pbrat(1)=pbrat(1)+brat(idc)
4361  nmodes(1)=nmodes(1)+1
4362  IF (brat(idc).GT.0d0) nmodes(10)=nmodes(10)+1
4363  IF (brat(idc).GT.eps) nmodes(9)=nmodes(9)+1
4364  ELSE IF ((id1.EQ.1.OR.id1.EQ.3.OR.id1.EQ.5).AND.(id2
4365  & .EQ.1.OR.id2.EQ.3.OR.id2.EQ.5)) THEN
4366  pbrat(2)=pbrat(2)+brat(idc)
4367  nmodes(2)=nmodes(2)+1
4368  IF (brat(idc).GT.0d0) nmodes(10)=nmodes(10)+1
4369  IF (brat(idc).GT.eps) nmodes(9)=nmodes(9)+1
4370  ENDIF
4371  ENDIF
4372  220 CONTINUE
4373  ENDIF
4374 C...SLEPTON DECAYS
4375  IF (kfsm.EQ.11.OR.kfsm.EQ.13.OR.kfsm.EQ.15) THEN
4376  nrvdc=2
4377  DO 230 i=1,nrvdc
4378  pbrat(i)=0d0
4379  nmodes(i)=0
4380  230 CONTINUE
4381  CALL pyname(kfsusy,chtmp)
4382  chd0=chtmp//' '
4383  chdc(1)=dname(3) // ' + ' // dname(2)
4384  chdc(2)=dname(1) // ' + ' // dname(1)
4385  kc=pycomp(kfsusy)
4386  DO 240 j=1,mdcy(kc,3)
4387  idc=j+mdcy(kc,2)-1
4388  id1=iabs(kfdp(idc,1))
4389  id2=iabs(kfdp(idc,2))
4390  IF (kfdp(idc,3).EQ.0) THEN
4391  IF ((id1.EQ.12.OR.id1.EQ.14.OR.id1.EQ.16).AND.(id2
4392  & .EQ.11.OR.id2.EQ.13.OR.id2.EQ.15)) THEN
4393  pbrat(1)=pbrat(1)+brat(idc)
4394  nmodes(1)=nmodes(1)+1
4395  IF (brat(idc).GT.0d0) nmodes(10)=nmodes(10)+1
4396  IF (brat(idc).GT.eps) nmodes(9)=nmodes(9)+1
4397  ENDIF
4398  IF ((id1.EQ.2.OR.id1.EQ.4.OR.id1.EQ.6).AND.(id2
4399  & .EQ.1.OR.id2.EQ.3.OR.id2.EQ.5)) THEN
4400  pbrat(2)=pbrat(2)+brat(idc)
4401  nmodes(2)=nmodes(2)+1
4402  IF (brat(idc).GT.0d0) nmodes(10)=nmodes(10)+1
4403  IF (brat(idc).GT.eps) nmodes(9)=nmodes(9)+1
4404  ENDIF
4405  ENDIF
4406  240 CONTINUE
4407  ENDIF
4408 C...SNEUTRINO DECAYS
4409  IF ((kfsm.EQ.12.OR.kfsm.EQ.14.OR.kfsm.EQ.16).AND.ilr.EQ.1)
4410  & THEN
4411  nrvdc=2
4412  DO 250 i=1,nrvdc
4413  pbrat(i)=0d0
4414  nmodes(i)=0
4415  250 CONTINUE
4416  CALL pyname(kfsusy,chtmp)
4417  chd0=chtmp//' '
4418  chdc(1)=dname(2) // ' + ' // dname(2)
4419  chdc(2)=dname(1) // ' + ' // dname(1)
4420  kc=pycomp(kfsusy)
4421  DO 260 j=1,mdcy(kc,3)
4422  idc=j+mdcy(kc,2)-1
4423  id1=iabs(kfdp(idc,1))
4424  id2=iabs(kfdp(idc,2))
4425  IF (kfdp(idc,3).EQ.0) THEN
4426  IF ((id1.EQ.11.OR.id1.EQ.13.OR.id1.EQ.15).AND.(id2
4427  & .EQ.11.OR.id2.EQ.13.OR.id2.EQ.15)) THEN
4428  pbrat(1)=pbrat(1)+brat(idc)
4429  nmodes(1)=nmodes(1)+1
4430  IF (brat(idc).GT.0d0) nmodes(10)=nmodes(10)+1
4431  IF (brat(idc).GT.eps) nmodes(9)=nmodes(9)+1
4432  ENDIF
4433  IF ((id1.EQ.1.OR.id1.EQ.3.OR.id1.EQ.5).AND.(id2
4434  & .EQ.1.OR.id2.EQ.3.OR.id2.EQ.5)) THEN
4435  nmodes(2)=nmodes(2)+1
4436  pbrat(2)=pbrat(2)+brat(idc)
4437  IF (brat(idc).GT.0d0) nmodes(10)=nmodes(10)+1
4438  IF (brat(idc).GT.eps) nmodes(9)=nmodes(9)+1
4439  ENDIF
4440  ENDIF
4441  260 CONTINUE
4442  ENDIF
4443  IF (nrvdc.NE.0) THEN
4444  DO 270 i=1,nrvdc
4445  WRITE (mstu(11),8200) chd0, chdc(i), pbrat(i), nmodes(i)
4446  nmodes(0)=nmodes(0)+nmodes(i)
4447  270 CONTINUE
4448  ENDIF
4449  280 CONTINUE
4450  290 CONTINUE
4451  DO 370 kfsm=21,37
4452  kfsusy=ksusy1+kfsm
4453  nrvdc=0
4454 C...NEUTRALINO DECAYS
4455  IF (kfsm.EQ.22.OR.kfsm.EQ.23.OR.kfsm.EQ.25.OR.kfsm.EQ.35) THEN
4456  nrvdc=4
4457  DO 300 i=1,nrvdc
4458  pbrat(i)=0d0
4459  nmodes(i)=0
4460  300 CONTINUE
4461  CALL pyname(kfsusy,chtmp)
4462  chd0=chtmp//' '
4463  chdc(1)=dname(3) // ' + ' // dname(2) // ' + ' // dname(2)
4464  chdc(2)=dname(3) // ' + ' // dname(1) // ' + ' // dname(1)
4465  chdc(3)=dname(2) // ' + ' // dname(1) // ' + ' // dname(1)
4466  chdc(4)=dname(1) // ' + ' // dname(1) // ' + ' // dname(1)
4467  kc=pycomp(kfsusy)
4468  DO 310 j=1,mdcy(kc,3)
4469  idc=j+mdcy(kc,2)-1
4470  id1=iabs(kfdp(idc,1))
4471  id2=iabs(kfdp(idc,2))
4472  id3=iabs(kfdp(idc,3))
4473  IF ((id1.EQ.12.OR.id1.EQ.14.OR.id1.EQ.16).AND.(id2
4474  & .EQ.11.OR.id2.EQ.13.OR.id2.EQ.15).AND.(id3.EQ.11.or
4475  & .id3.EQ.13.OR.id3.EQ.15)) THEN
4476  pbrat(1)=pbrat(1)+brat(idc)
4477  nmodes(1)=nmodes(1)+1
4478  IF (brat(idc).GT.0d0) nmodes(10)=nmodes(10)+1
4479  IF (brat(idc).GT.eps) nmodes(9)=nmodes(9)+1
4480  ELSE IF ((id1.EQ.12.OR.id1.EQ.14.OR.id1.EQ.16).and
4481  & .(id2.EQ.1.OR.id2.EQ.3.OR.id2.EQ.5).AND.(id3.EQ.1
4482  & .OR.id3.EQ.3.OR.id3.EQ.5)) THEN
4483  pbrat(2)=pbrat(2)+brat(idc)
4484  nmodes(2)=nmodes(2)+1
4485  IF (brat(idc).GT.0d0) nmodes(10)=nmodes(10)+1
4486  IF (brat(idc).GT.eps) nmodes(9)=nmodes(9)+1
4487  ELSE IF ((id1.EQ.11.OR.id1.EQ.13.OR.id1.EQ.15).and
4488  & .(id2.EQ.2.OR.id2.EQ.4.OR.id2.EQ.6).AND.(id3.EQ.1
4489  & .OR.id3.EQ.3.OR.id3.EQ.5)) THEN
4490  pbrat(3)=pbrat(3)+brat(idc)
4491  nmodes(3)=nmodes(3)+1
4492  IF (brat(idc).GT.0d0) nmodes(10)=nmodes(10)+1
4493  IF (brat(idc).GT.eps) nmodes(9)=nmodes(9)+1
4494  ELSE IF ((id1.EQ.2.OR.id1.EQ.4.OR.id1.EQ.6).and
4495  & .(id2.EQ.1.OR.id2.EQ.3.OR.id2.EQ.5).AND.(id3.EQ.1
4496  & .OR.id3.EQ.3.OR.id3.EQ.5)) THEN
4497  pbrat(4)=pbrat(4)+brat(idc)
4498  nmodes(4)=nmodes(4)+1
4499  IF (brat(idc).GT.0d0) nmodes(10)=nmodes(10)+1
4500  IF (brat(idc).GT.eps) nmodes(9)=nmodes(9)+1
4501  ENDIF
4502  310 CONTINUE
4503  ENDIF
4504 C...CHARGINO DECAYS
4505  IF (kfsm.EQ.24.OR.kfsm.EQ.37) THEN
4506  nrvdc=5
4507  DO 320 i=1,nrvdc
4508  pbrat(i)=0d0
4509  nmodes(i)=0
4510  320 CONTINUE
4511  CALL pyname(kfsusy,chtmp)
4512  chd0=chtmp//' '
4513  chdc(1)=dname(3) // ' + ' // dname(3) // ' + ' // dname(2)
4514  chdc(2)=dname(2) // ' + ' // dname(2) // ' + ' // dname(2)
4515  chdc(3)=dname(3) // ' + ' // dname(1) // ' + ' // dname(1)
4516  chdc(4)=dname(2) // ' + ' // dname(1) // ' + ' // dname(1)
4517  chdc(5)=dname(1) // ' + ' // dname(1) // ' + ' // dname(1)
4518  kc=pycomp(kfsusy)
4519  DO 330 j=1,mdcy(kc,3)
4520  idc=j+mdcy(kc,2)-1
4521  id1=iabs(kfdp(idc,1))
4522  id2=iabs(kfdp(idc,2))
4523  id3=iabs(kfdp(idc,3))
4524  IF ((id1.EQ.12.OR.id1.EQ.14.OR.id1.EQ.16).AND.(id2
4525  & .EQ.11.OR.id2.EQ.13.OR.id2.EQ.15).AND.(id3.EQ.12.or
4526  & .id3.EQ.14.OR.id3.EQ.16)) THEN
4527  pbrat(1)=pbrat(1)+brat(idc)
4528  nmodes(1)=nmodes(1)+1
4529  IF (brat(idc).GT.0d0) nmodes(10)=nmodes(10)+1
4530  IF (brat(idc).GT.eps) nmodes(9)=nmodes(9)+1
4531  ELSE IF ((id1.EQ.12.OR.id1.EQ.14.OR.id1.EQ.16).and
4532  & .(id2.EQ.12.OR.id2.EQ.14.OR.id2.EQ.16).AND.(id3.eq
4533  & .11.OR.id3.EQ.13.OR.id3.EQ.15)) THEN
4534  pbrat(1)=pbrat(1)+brat(idc)
4535  nmodes(1)=nmodes(1)+1
4536  IF (brat(idc).GT.0d0) nmodes(10)=nmodes(10)+1
4537  IF (brat(idc).GT.eps) nmodes(9)=nmodes(9)+1
4538  ELSE IF ((id1.EQ.11.OR.id1.EQ.13.OR.id1.EQ.15).and
4539  & .(id2.EQ.11.OR.id2.EQ.13.OR.id2.EQ.15).AND.(id3.eq
4540  & .11.OR.id3.EQ.13.OR.id3.EQ.15)) THEN
4541  pbrat(2)=pbrat(2)+brat(idc)
4542  nmodes(2)=nmodes(2)+1
4543  IF (brat(idc).GT.0d0) nmodes(10)=nmodes(10)+1
4544  IF (brat(idc).GT.eps) nmodes(9)=nmodes(9)+1
4545  ELSE IF ((id1.EQ.12.OR.id1.EQ.14.OR.id1.EQ.16).and
4546  & .(id2.EQ.1.OR.id2.EQ.3.OR.id2.EQ.5).AND.(id3.eq
4547  & .2.OR.id3.EQ.4.OR.id3.EQ.6)) THEN
4548  pbrat(3)=pbrat(3)+brat(idc)
4549  nmodes(3)=nmodes(3)+1
4550  IF (brat(idc).GT.0d0) nmodes(10)=nmodes(10)+1
4551  IF (brat(idc).GT.eps) nmodes(9)=nmodes(9)+1
4552  ELSE IF ((id1.EQ.12.OR.id1.EQ.14.OR.id1.EQ.16).and
4553  & .(id2.EQ.2.OR.id2.EQ.4.OR.id2.EQ.6).AND.(id3.eq
4554  & .1.OR.id3.EQ.3.OR.id3.EQ.5)) THEN
4555  pbrat(3)=pbrat(3)+brat(idc)
4556  nmodes(3)=nmodes(3)+1
4557  IF (brat(idc).GT.0d0) nmodes(10)=nmodes(10)+1
4558  IF (brat(idc).GT.eps) nmodes(9)=nmodes(9)+1
4559  ELSE IF ((id1.EQ.11.OR.id1.EQ.13.OR.id1.EQ.15).and
4560  & .(id2.EQ.2.OR.id2.EQ.4.OR.id2.EQ.6).AND.(id3.eq
4561  & .2.OR.id3.EQ.4.OR.id3.EQ.6)) THEN
4562  pbrat(4)=pbrat(4)+brat(idc)
4563  nmodes(4)=nmodes(4)+1
4564  IF (brat(idc).GT.0d0) nmodes(10)=nmodes(10)+1
4565  IF (brat(idc).GT.eps) nmodes(9)=nmodes(9)+1
4566  ELSE IF ((id1.EQ.11.OR.id1.EQ.13.OR.id1.EQ.15).and
4567  & .(id2.EQ.1.OR.id2.EQ.3.OR.id2.EQ.5).AND.(id3.eq
4568  & .1.OR.id3.EQ.3.OR.id3.EQ.5)) THEN
4569  pbrat(4)=pbrat(4)+brat(idc)
4570  nmodes(4)=nmodes(4)+1
4571  IF (brat(idc).GT.0d0) nmodes(10)=nmodes(10)+1
4572  IF (brat(idc).GT.eps) nmodes(9)=nmodes(9)+1
4573  ELSE IF ((id1.EQ.2.OR.id1.EQ.4.OR.id1.EQ.6).and
4574  & .(id2.EQ.2.OR.id2.EQ.4.OR.id2.EQ.6).AND.(id3.eq
4575  & .1.OR.id3.EQ.3.OR.id3.EQ.5)) THEN
4576  pbrat(5)=pbrat(5)+brat(idc)
4577  nmodes(5)=nmodes(5)+1
4578  IF (brat(idc).GT.0d0) nmodes(10)=nmodes(10)+1
4579  IF (brat(idc).GT.eps) nmodes(9)=nmodes(9)+1
4580  ELSE IF ((id1.EQ.1.OR.id1.EQ.3.OR.id1.EQ.5).and
4581  & .(id2.EQ.1.OR.id2.EQ.3.OR.id2.EQ.5).AND.(id3.eq
4582  & .1.OR.id3.EQ.3.OR.id3.EQ.5)) THEN
4583  pbrat(5)=pbrat(5)+brat(idc)
4584  nmodes(5)=nmodes(5)+1
4585  IF (brat(idc).GT.0d0) nmodes(10)=nmodes(10)+1
4586  IF (brat(idc).GT.eps) nmodes(9)=nmodes(9)+1
4587  ENDIF
4588  330 CONTINUE
4589  ENDIF
4590 C...GLUINO DECAYS
4591  IF (kfsm.EQ.21) THEN
4592  nrvdc=3
4593  DO 340 i=1,nrvdc
4594  pbrat(i)=0d0
4595  nmodes(i)=0
4596  340 CONTINUE
4597  CALL pyname(kfsusy,chtmp)
4598  chd0=chtmp//' '
4599  chdc(1)=dname(3) // ' + ' // dname(1) // ' + ' // dname(1)
4600  chdc(2)=dname(2) // ' + ' // dname(1) // ' + ' // dname(1)
4601  chdc(3)=dname(1) // ' + ' // dname(1) // ' + ' // dname(1)
4602  kc=pycomp(kfsusy)
4603  DO 350 j=1,mdcy(kc,3)
4604  idc=j+mdcy(kc,2)-1
4605  id1=iabs(kfdp(idc,1))
4606  id2=iabs(kfdp(idc,2))
4607  id3=iabs(kfdp(idc,3))
4608  IF ((id1.EQ.12.OR.id1.EQ.14.OR.id1.EQ.16).AND.(id2
4609  & .EQ.1.OR.id2.EQ.3.OR.id2.EQ.5).AND.(id3.EQ.1.or
4610  & .id3.EQ.3.OR.id3.EQ.5)) THEN
4611  pbrat(1)=pbrat(1)+brat(idc)
4612  nmodes(1)=nmodes(1)+1
4613  IF (brat(idc).GT.0d0) nmodes(10)=nmodes(10)+1
4614  IF (brat(idc).GT.eps) nmodes(9)=nmodes(9)+1
4615  ELSE IF ((id1.EQ.11.OR.id1.EQ.13.OR.id1.EQ.15).and
4616  & .(id2.EQ.2.OR.id2.EQ.4.OR.id2.EQ.6).AND.(id3.EQ.1
4617  & .OR.id3.EQ.3.OR.id3.EQ.5)) THEN
4618  pbrat(2)=pbrat(2)+brat(idc)
4619  nmodes(2)=nmodes(2)+1
4620  IF (brat(idc).GT.0d0) nmodes(10)=nmodes(10)+1
4621  IF (brat(idc).GT.eps) nmodes(9)=nmodes(9)+1
4622  ELSE IF ((id1.EQ.2.OR.id1.EQ.4.OR.id1.EQ.6).and
4623  & .(id2.EQ.1.OR.id2.EQ.3.OR.id2.EQ.5).AND.(id3.EQ.1
4624  & .OR.id3.EQ.3.OR.id3.EQ.5)) THEN
4625  pbrat(3)=pbrat(3)+brat(idc)
4626  nmodes(3)=nmodes(3)+1
4627  IF (brat(idc).GT.0d0) nmodes(10)=nmodes(10)+1
4628  IF (brat(idc).GT.eps) nmodes(9)=nmodes(9)+1
4629  ENDIF
4630  350 CONTINUE
4631  ENDIF
4632 
4633  IF (nrvdc.NE.0) THEN
4634  DO 360 i=1,nrvdc
4635  WRITE (mstu(11),8200) chd0, chdc(i), pbrat(i), nmodes(i)
4636  nmodes(0)=nmodes(0)+nmodes(i)
4637  360 CONTINUE
4638  ENDIF
4639  370 CONTINUE
4640  WRITE (mstu(11),8100) nmodes(0), nmodes(10), nmodes(9)
4641 
4642  IF (imss(51).GE.1.OR.imss(52).GE.1.OR.imss(53).GE.1) THEN
4643  WRITE (mstu(11),8500)
4644  DO 400 irv=1,3
4645  DO 390 jrv=1,3
4646  DO 380 krv=1,3
4647  WRITE (mstu(11),8700) irv,jrv,krv,rvlam(irv,jrv,krv)
4648  & ,rvlamp(irv,jrv,krv),rvlamb(irv,jrv,krv)
4649  380 CONTINUE
4650  390 CONTINUE
4651  400 CONTINUE
4652  WRITE (mstu(11),8600)
4653  ENDIF
4654  ENDIF
4655 
4656 C...Formats for printouts.
4657  5000 FORMAT('1',9('*'),1x,'PYSTAT: Statistics on Number of ',
4658  &'Events and Cross-sections',1x,9('*'))
4659  5100 FORMAT(/1x,78('=')/1x,'I',34x,'I',28x,'I',12x,'I'/1x,'I',12x,
4660  &'Subprocess',12x,'I',6x,'Number of points',6x,'I',4x,'Sigma',3x,
4661  &'I'/1x,'I',34x,'I',28x,'I',12x,'I'/1x,'I',34('-'),'I',28('-'),
4662  &'I',4x,'(mb)',4x,'I'/1x,'I',34x,'I',28x,'I',12x,'I'/1x,'I',1x,
4663  &'N:o',1x,'Type',25x,'I',4x,'Generated',9x,'Tried',1x,'I',12x,
4664  &'I'/1x,'I',34x,'I',28x,'I',12x,'I'/1x,78('=')/1x,'I',34x,'I',28x,
4665  &'I',12x,'I')
4666  5200 FORMAT(1x,'I',1x,i3,1x,a28,1x,'I',1x,i12,1x,i13,1x,'I',1x,1p,
4667  &d10.3,1x,'I')
4668  5300 FORMAT(1x,'I',34x,'I',28x,'I',12x,'I'/1x,78('=')/
4669  &1x,'I',34x,'I',28x,'I',12x,'I')
4670  5400 FORMAT(1x,'I',34x,'I',28x,'I',12x,'I'/1x,78('=')//
4671  &1x,'********* Total number of errors, excluding junctions =',
4672  &1x,i8,' *************'/
4673  &1x,'********* Total number of errors, including junctions =',
4674  &1x,i8,' *************'/
4675  &1x,'********* Total number of warnings = ',
4676  &1x,i8,' *************'/
4677  &1x,'********* Fraction of events that fail fragmentation ',
4678  &'cuts =',1x,f8.5,' *********'/)
4679  5500 FORMAT('1',27('*'),1x,'PYSTAT: Decay Widths and Branching ',
4680  &'Ratios',1x,27('*'))
4681  5600 FORMAT(/1x,98('=')/1x,'I',49x,'I',13x,'I',12x,'I',6x,'I',12x,'I'/
4682  &1x,'I',5x,'Mother --> Branching/Decay Channel',8x,'I',1x,
4683  &'Width (GeV)',1x,'I',7x,'B.R.',1x,'I',1x,'Stat',1x,'I',2x,
4684  &'Eff. B.R.',1x,'I'/1x,'I',49x,'I',13x,'I',12x,'I',6x,'I',12x,'I'/
4685  &1x,98('='))
4686  5700 FORMAT(1x,'I',49x,'I',13x,'I',12x,'I',6x,'I',12x,'I'/1x,'I',1x,
4687  &i8,2x,a10,3x,'(m =',f10.3,')',2x,'-->',5x,'I',2x,1p,d10.3,0p,1x,
4688  &'I',1x,1p,d10.3,0p,1x,'I',1x,a4,1x,'I',1x,1p,d10.3,0p,1x,'I')
4689  5800 FORMAT(1x,'I',1x,i8,2x,a10,1x,'+',1x,a10,15x,'I',2x,
4690  &1p,d10.3,0p,1x,'I',1x,1p,d10.3,0p,1x,'I',1x,a4,1x,'I',1x,
4691  &1p,d10.3,0p,1x,'I')
4692  5900 FORMAT(1x,'I',1x,i8,2x,a10,1x,'+',1x,a10,1x,'+',1x,a10,2x,'I',2x,
4693  &1p,d10.3,0p,1x,'I',1x,1p,d10.3,0p,1x,'I',1x,a4,1x,'I',1x,
4694  &1p,d10.3,0p,1x,'I')
4695  6000 FORMAT(1x,'I',49x,'I',13x,'I',12x,'I',6x,'I',12x,'I'/1x,98('='))
4696  6100 FORMAT('1',7('*'),1x,'PYSTAT: Allowed Incoming Partons/',
4697  &'Particles at Hard Interaction',1x,7('*'))
4698  6200 FORMAT(/1x,78('=')/1x,'I',38x,'I',37x,'I'/1x,'I',1x,
4699  &'Beam particle:',1x,a12,10x,'I',1x,'Target particle:',1x,a12,7x,
4700  &'I'/1x,'I',38x,'I',37x,'I'/1x,'I',1x,'Content',6x,'State',19x,
4701  &'I',1x,'Content',6x,'State',18x,'I'/1x,'I',38x,'I',37x,'I'/1x,
4702  &78('=')/1x,'I',38x,'I',37x,'I')
4703  6300 FORMAT(1x,'I',1x,a9,5x,a4,19x,'I',1x,a9,5x,a4,18x,'I')
4704  6400 FORMAT(1x,'I',38x,'I',37x,'I'/1x,78('='))
4705  6500 FORMAT('1',12('*'),1x,'PYSTAT: User-Defined Limits on ',
4706  &'Kinematical Variables',1x,12('*'))
4707  6600 FORMAT(/1x,78('=')/1x,'I',76x,'I')
4708  6700 FORMAT(1x,'I',16x,1p,d10.3,0p,1x,'<',1x,a,1x,'<',1x,1p,d10.3,0p,
4709  &16x,'I')
4710  6800 FORMAT(1x,'I',3x,1p,d10.3,0p,1x,'(',1p,d10.3,0p,')',1x,'<',1x,a,
4711  &1x,'<',1x,1p,d10.3,0p,16x,'I')
4712  6900 FORMAT(1x,'I',29x,a,1x,'=',1x,1p,d10.3,0p,16x,'I')
4713  7000 FORMAT(1x,'I',76x,'I'/1x,78('='))
4714  7100 FORMAT('1',12('*'),1x,'PYSTAT: Summary of Status Codes and ',
4715  &'Parameter Values',1x,12('*'))
4716  7200 FORMAT(/3x,'I',4x,'MSTP(I)',9x,'PARP(I)',20x,'I',4x,'MSTP(I)',9x,
4717  &'PARP(I)'/)
4718  7300 FORMAT(1x,i3,5x,i6,6x,1p,d10.3,0p,18x,i3,5x,i6,6x,1p,d10.3)
4719  7400 FORMAT('1',13('*'),1x,'PYSTAT: List of implemented processes',
4720  &1x,13('*'))
4721  7500 FORMAT(/1x,65('=')/1x,'I',34x,'I',28x,'I'/1x,'I',12x,
4722  &'Subprocess',12x,'I',1x,'ISET',2x,'KFPR(I,1)',2x,'KFPR(I,2)',1x,
4723  &'I'/1x,'I',34x,'I',28x,'I'/1x,65('=')/1x,'I',34x,'I',28x,'I')
4724  7600 FORMAT(1x,'I',1x,i3,1x,a28,1x,'I',1x,i4,1x,i10,1x,i10,1x,'I')
4725  7700 FORMAT(1x,'I',34x,'I',28x,'I'/1x,65('='))
4726  8000 FORMAT(1x/ 1x/
4727  & 17x,'Sums over R-Violating branching ratios',1x/ 1x
4728  & /1x,70('=')/1x,'I',50x,'I',11x,'I',5x,'I'/1x,'I',4x
4729  & ,'Mother --> Sum over final state flavours',4x,'I',2x
4730  & ,'BR(sum)',2x,'I',2x,'N',2x,'I'/1x,'I',50x,'I',11x,'I',5x,'I'
4731  & /1x,70('=')/1x,'I',50x,'I',11x,'I',5x,'I')
4732  8100 FORMAT(1x,'I',50x,'I',11x,'I',5x,'I'/1x,70('=')/1x,'I',1x
4733  & ,'Total number of R-Violating modes :',3x,i5,24x,'I'/
4734  & 1x,'I',1x,'Total number with non-vanishing BR :',2x,i5,24x
4735  & ,'I'/1x,'I',1x,'Total number with BR > 0.001 :',8x,i5,24x,'I'
4736  & /1x,70('='))
4737  8200 FORMAT(1x,'I',1x,a9,1x,'-->',1x,a24,11x,
4738  & 'I',2x,1p,d8.2,0p,1x,'I',2x,i2,1x,'I')
4739  8300 FORMAT(1x,'I',50x,'I',11x,'I',5x,'I')
4740  8500 FORMAT(1x/ 1x/
4741  & 1x,'R-Violating couplings',1x/ 1x /
4742  & 1x,55('=')/
4743  & 1x,'I',1x,'IJK',1x,'I',2x,'LAMBDA(IJK)',2x,'I',2x
4744  & ,'LAMBDA''(IJK)',1x,'I',1x,"LAMBDA''(IJK)",1x,'I'/1x,'I',5x
4745  & ,'I',15x,'I',15x,'I',15x,'I')
4746  8600 FORMAT(1x,55('='))
4747  8700 FORMAT(1x,'I',1x,i1,i1,i1,1x,'I',1x,1p,d13.3,0p,1x,'I',1x,1p
4748  & ,d13.3,0p,1x,'I',1x,1p,d13.3,0p,1x,'I')
4749 
4750  RETURN
4751  END
4752 
4753 C*********************************************************************
4754 
4755 C...PYUPEV
4756 C...Administers the hard-process generation required for output to the
4757 C...Les Houches event record.
4758 
4759  SUBROUTINE pyupev
4760 
4761 C...Double precision and integer declarations.
4762  IMPLICIT DOUBLE PRECISION(a-h, o-z)
4763  IMPLICIT INTEGER(i-n)
4764  INTEGER pyk,pychge,pycomp
4765 
4766 C...Commonblocks.
4767  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
4768  common/pyctag/nct,mct(4000,2)
4769  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
4770  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
4771  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
4772  common/pypars/mstp(200),parp(200),msti(200),pari(200)
4773  common/pyint1/mint(400),vint(400)
4774  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
4775  common/pyint4/mwid(500),wids(500,5)
4776  SAVE /pyjets/,/pyctag/,/pydat1/,/pydat2/,/pydat3/,/pypars/,
4777  &/pyint1/,/pyint2/,/pyint4/
4778 
4779 C...HEPEUP for output.
4780  INTEGER maxnup
4781  parameter(maxnup=500)
4782  INTEGER nup,idprup,idup,istup,mothup,icolup
4783  DOUBLE PRECISION xwgtup,scalup,aqedup,aqcdup,pup,vtimup,spinup
4784  common/hepeup/nup,idprup,xwgtup,scalup,aqedup,aqcdup,idup(maxnup),
4785  &istup(maxnup),mothup(2,maxnup),icolup(2,maxnup),pup(5,maxnup),
4786  &vtimup(maxnup),spinup(maxnup)
4787  SAVE /hepeup/
4788 
4789 C...Stop if no subprocesses on.
4790  IF(mint(121).EQ.1.AND.msti(53).EQ.1) THEN
4791  WRITE(mstu(11),5100)
4792  stop
4793  ENDIF
4794 
4795 C...Special flags for hard-process generation only.
4796  mstp71=mstp(71)
4797  mstp(71)=0
4798  mst128=mstp(128)
4799  mstp(128)=1
4800 
4801 C...Initial values for some counters.
4802  n=0
4803  mint(5)=mint(5)+1
4804  mint(7)=0
4805  mint(8)=0
4806  mint(30)=0
4807  mint(83)=0
4808  mint(84)=mstp(126)
4809  mstu(24)=0
4810  mstu70=0
4811  mstj14=mstj(14)
4812 C...Normally, use K(I,4:5) colour info rather than /PYCTAG/.
4813  mint(33)=0
4814 
4815 C...If variable energies: redo incoming kinematics and cross-section.
4816  msti(61)=0
4817  IF(mstp(171).EQ.1) THEN
4818  CALL pyinki(1)
4819  IF(msti(61).EQ.1) THEN
4820  mint(5)=mint(5)-1
4821  RETURN
4822  ENDIF
4823  IF(mint(121).GT.1) CALL pysave(3,1)
4824  CALL pyxtot
4825  ENDIF
4826 
4827 C...Do not allow pileup events.
4828  mint(82)=1
4829 
4830 C...Generate variables of hard scattering.
4831  mint(51)=0
4832  msti(52)=0
4833  100 CONTINUE
4834  IF(mint(51).NE.0.OR.mstu(24).NE.0) msti(52)=msti(52)+1
4835  mint(31)=0
4836  mint(51)=0
4837  mint(57)=0
4838  CALL pyrand
4839  IF(msti(61).EQ.1) THEN
4840  mint(5)=mint(5)-1
4841  RETURN
4842  ENDIF
4843  IF(mint(51).EQ.2) RETURN
4844  isub=mint(1)
4845 
4846  IF((isub.LE.90.OR.isub.GE.95).AND.isub.NE.99) THEN
4847 C...Hard scattering (including low-pT):
4848 C...reconstruct kinematics and colour flow of hard scattering.
4849  mint31=mint(31)
4850  110 mint(31)=mint31
4851  mint(51)=0
4852  CALL pyscat
4853  IF(mint(51).EQ.1) goto 100
4854  ipu1=mint(84)+1
4855  ipu2=mint(84)+2
4856 
4857 C...Decay of final state resonances.
4858  mint(32)=0
4859  IF(mstp(41).GE.1.AND.iset(isub).LE.10.AND.isub.NE.95)
4860  & CALL pyresd(0)
4861  IF(mint(51).EQ.1) goto 100
4862  mint(52)=n
4863 
4864 C...Longitudinal boost of hard scattering.
4865  betaz=(vint(41)-vint(42))/(vint(41)+vint(42))
4866  CALL pyrobo(mint(84)+1,n,0d0,0d0,0d0,0d0,betaz)
4867 
4868  ELSEIF(isub.NE.99) THEN
4869 C...Diffractive and elastic scattering.
4870  CALL pydiff
4871 
4872  ELSE
4873 C...DIS scattering (photon flux external).
4874  CALL pydisg
4875  IF(mint(51).EQ.1) goto 100
4876  ENDIF
4877 
4878 C...Check that no odd resonance left undecayed.
4879  mint(54)=n
4880  nfix=n
4881  DO 120 i=mint(84)+1,nfix
4882  IF(k(i,1).GE.1.AND.k(i,1).LE.10.AND.k(i,2).NE.21.AND.
4883  & k(i,2).NE.22) THEN
4884  kca=pycomp(k(i,2))
4885  IF(mwid(kca).NE.0.AND.mdcy(kca,1).GE.1) THEN
4886  CALL pyresd(i)
4887  IF(mint(51).EQ.1) goto 100
4888  ENDIF
4889  ENDIF
4890  120 CONTINUE
4891 
4892 C...Boost hadronic subsystem to overall rest frame.
4893 C..(Only relevant when photon inside lepton beam.)
4894  IF(mint(141).NE.0.OR.mint(142).NE.0) CALL pygaga(4,wtgaga)
4895 
4896 C...Store event information and calculate Monte Carlo estimates of
4897 C...subprocess cross-sections.
4898  130 CALL pydocu
4899 
4900 C...Transform to the desired coordinate frame.
4901  140 CALL pyfram(mstp(124))
4902  mstu(70)=mstu70
4903  paru(21)=vint(1)
4904 
4905 C...Restore special flags for hard-process generation only.
4906  mstp(71)=mstp71
4907  mstp(128)=mst128
4908 
4909 C...Trace colour tags; convert to LHA style labels.
4910  nct=100
4911  DO 150 i=mint(84)+1,n
4912  mct(i,1)=0
4913  mct(i,2)=0
4914  150 CONTINUE
4915  DO 160 i=mint(84)+1,n
4916  kq=kchg(pycomp(k(i,2)),2)*isign(1,k(i,2))
4917  IF(k(i,1).EQ.3.OR.k(i,1).EQ.13.OR.k(i,1).EQ.14) THEN
4918  IF(k(i,4).NE.0.AND.(kq.EQ.1.OR.kq.EQ.2).AND.mct(i,1).EQ.0)
4919  & THEN
4920  imo=mod(k(i,4)/mstu(5),mstu(5))
4921  ida=mod(k(i,4),mstu(5))
4922  IF(imo.NE.0.AND.mod(k(imo,5)/mstu(5),mstu(5)).EQ.i.AND.
4923  & mct(imo,2).NE.0) THEN
4924  mct(i,1)=mct(imo,2)
4925  ELSEIF(imo.NE.0.AND.mod(k(imo,4),mstu(5)).EQ.i.AND.
4926  & mct(imo,1).NE.0) THEN
4927  mct(i,1)=mct(imo,1)
4928  ELSEIF(ida.NE.0.AND.mod(k(ida,5),mstu(5)).EQ.i.AND.
4929  & mct(ida,2).NE.0) THEN
4930  mct(i,1)=mct(ida,2)
4931  ELSE
4932  nct=nct+1
4933  mct(i,1)=nct
4934  ENDIF
4935  ENDIF
4936  IF(k(i,5).NE.0.AND.(kq.EQ.-1.OR.kq.EQ.2).AND.mct(i,2).EQ.0)
4937  & THEN
4938  imo=mod(k(i,5)/mstu(5),mstu(5))
4939  ida=mod(k(i,5),mstu(5))
4940  IF(imo.NE.0.AND.mod(k(imo,4)/mstu(5),mstu(5)).EQ.i.AND.
4941  & mct(imo,1).NE.0) THEN
4942  mct(i,2)=mct(imo,1)
4943  ELSEIF(imo.NE.0.AND.mod(k(imo,5),mstu(5)).EQ.i.AND.
4944  & mct(imo,2).NE.0) THEN
4945  mct(i,2)=mct(imo,2)
4946  ELSEIF(ida.NE.0.AND.mod(k(ida,4),mstu(5)).EQ.i.AND.
4947  & mct(ida,1).NE.0) THEN
4948  mct(i,2)=mct(ida,1)
4949  ELSE
4950  nct=nct+1
4951  mct(i,2)=nct
4952  ENDIF
4953  ENDIF
4954  ENDIF
4955  160 CONTINUE
4956 
4957 C...Put event in HEPEUP commonblock.
4958  nup=n-mint(84)
4959  idprup=mint(1)
4960  xwgtup=1d0
4961  scalup=vint(53)
4962  aqedup=vint(57)
4963  aqcdup=vint(58)
4964  DO 180 i=1,nup
4965  idup(i)=k(i+mint(84),2)
4966  IF(i.LE.2) THEN
4967  istup(i)=-1
4968  mothup(1,i)=0
4969  mothup(2,i)=0
4970  ELSEIF(k(i+4,3).EQ.0) THEN
4971  istup(i)=1
4972  mothup(1,i)=1
4973  mothup(2,i)=2
4974  ELSE
4975  istup(i)=1
4976  mothup(1,i)=k(i+mint(84),3)-mint(84)
4977  mothup(2,i)=0
4978  ENDIF
4979  IF(i.GE.3.AND.k(i+mint(84),3).GT.0)
4980  & istup(k(i+mint(84),3)-mint(84))=2
4981  icolup(1,i)=mct(i+mint(84),1)
4982  icolup(2,i)=mct(i+mint(84),2)
4983  DO 170 j=1,5
4984  pup(j,i)=p(i+mint(84),j)
4985  170 CONTINUE
4986  vtimup(i)=v(i,5)
4987  spinup(i)=9d0
4988  180 CONTINUE
4989 
4990 C...Optionally write out event to disk. Minimal size for time/spin fields.
4991  IF(mstp(162).GT.0) THEN
4992  WRITE(mstp(162),5200) nup,idprup,xwgtup,scalup,aqedup,aqcdup
4993  DO 190 i=1,nup
4994  IF(vtimup(i).EQ.0d0) THEN
4995  WRITE(mstp(162),5300) idup(i),istup(i),mothup(1,i),
4996  & mothup(2,i),icolup(1,i),icolup(2,i),(pup(j,i),j=1,5),
4997  & ' 0. 9.'
4998  ELSE
4999  WRITE(mstp(162),5400) idup(i),istup(i),mothup(1,i),
5000  & mothup(2,i),icolup(1,i),icolup(2,i),(pup(j,i),j=1,5),
5001  & vtimup(i),' 9.'
5002  ENDIF
5003  190 CONTINUE
5004 
5005 C...Optional extra line with parton-density information.
5006  IF(mstp(165).GE.1) WRITE(mstp(162),5500) msti(15),msti(16),
5007  & pari(33),pari(34),pari(23),pari(29),pari(30)
5008  ENDIF
5009 
5010 C...Error messages and other print formats.
5011  5100 FORMAT(1x,'Error: no subprocess switched on.'/
5012  &1x,'Execution stopped.')
5013  5200 FORMAT(1p,2i6,4e14.6)
5014  5300 FORMAT(1p,i8,5i5,5e18.10,a6)
5015  5400 FORMAT(1p,i8,5i5,5e18.10,e12.4,a3)
5016  5500 FORMAT(1p,'#pdf ',2i5,5e18.10)
5017 
5018  RETURN
5019  END
5020 
5021 C*********************************************************************
5022 
5023 C...PYUPIN
5024 C...Fills the HEPRUP commonblock with info on incoming beams and allowed
5025 C...processes, and optionally stores that information on file.
5026 
5027  SUBROUTINE pyupin
5028 
5029 C...Double precision and integer declarations.
5030  IMPLICIT DOUBLE PRECISION(a-h, o-z)
5031  IMPLICIT INTEGER(i-n)
5032 
5033 C...Commonblocks.
5034  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
5035  common/pysubs/msel,mselpd,msub(500),kfin(2,-40:40),ckin(200)
5036  common/pypars/mstp(200),parp(200),msti(200),pari(200)
5037  common/pyint5/ngenpd,ngen(0:500,3),xsec(0:500,3)
5038  SAVE /pyjets/,/pysubs/,/pypars/,/pyint5/
5039 
5040 C...User process initialization commonblock.
5041  INTEGER maxpup
5042  parameter(maxpup=100)
5043  INTEGER idbmup,pdfgup,pdfsup,idwtup,nprup,lprup
5044  DOUBLE PRECISION ebmup,xsecup,xerrup,xmaxup
5045  common/heprup/idbmup(2),ebmup(2),pdfgup(2),pdfsup(2),
5046  &idwtup,nprup,xsecup(maxpup),xerrup(maxpup),xmaxup(maxpup),
5047  &lprup(maxpup)
5048  SAVE /heprup/
5049 
5050 C...Store info on incoming beams.
5051  idbmup(1)=k(1,2)
5052  idbmup(2)=k(2,2)
5053  ebmup(1)=p(1,4)
5054  ebmup(2)=p(2,4)
5055  pdfgup(1)=0
5056  pdfgup(2)=0
5057  pdfsup(1)=mstp(51)
5058  pdfsup(2)=mstp(51)
5059 
5060 C...Event weighting strategy.
5061  idwtup=3
5062 
5063 C...Info on individual processes.
5064  nprup=0
5065  DO 100 isub=1,500
5066  IF(msub(isub).EQ.1) THEN
5067  nprup=nprup+1
5068  xsecup(nprup)=1d9*xsec(isub,3)
5069  xerrup(nprup)=xsecup(nprup)/sqrt(max(1d0,dble(ngen(isub,3))))
5070  xmaxup(nprup)=1d0
5071  lprup(nprup)=isub
5072  ENDIF
5073  100 CONTINUE
5074 
5075 C...Write info to file.
5076  IF(mstp(161).GT.0) THEN
5077  WRITE(mstp(161),5100) idbmup(1),idbmup(2),ebmup(1),ebmup(2),
5078  & pdfgup(1),pdfgup(2),pdfsup(1),pdfsup(2),idwtup,nprup
5079  DO 110 ipr=1,nprup
5080  WRITE(mstp(161),5200) xsecup(ipr),xerrup(ipr),xmaxup(ipr),
5081  & lprup(ipr)
5082  110 CONTINUE
5083  ENDIF
5084 
5085 C...Formats for printout.
5086  5100 FORMAT(1p,2i8,2e14.6,6i6)
5087  5200 FORMAT(1p,3e14.6,i6)
5088 
5089  RETURN
5090  END
5091 
5092 
5093 C*********************************************************************
5094 
5095 C...Combine the two old-style Pythia initialization and event files
5096 C...into a single Les Houches Event File.
5097 
5098  SUBROUTINE pylhef
5099 
5100 C...Double precision and integer declarations.
5101  IMPLICIT DOUBLE PRECISION(a-h, o-z)
5102  IMPLICIT INTEGER(i-n)
5103 
5104 C...PYTHIA commonblock: only used to provide read/write units and version.
5105  common/pypars/mstp(200),parp(200),msti(200),pari(200)
5106  SAVE /pypars/
5107 
5108 C...User process initialization commonblock.
5109  INTEGER maxpup
5110  parameter(maxpup=100)
5111  INTEGER idbmup,pdfgup,pdfsup,idwtup,nprup,lprup
5112  DOUBLE PRECISION ebmup,xsecup,xerrup,xmaxup
5113  common/heprup/idbmup(2),ebmup(2),pdfgup(2),pdfsup(2),
5114  &idwtup,nprup,xsecup(maxpup),xerrup(maxpup),xmaxup(maxpup),
5115  &lprup(maxpup)
5116  SAVE /heprup/
5117 
5118 C...User process event common block.
5119  INTEGER maxnup
5120  parameter(maxnup=500)
5121  INTEGER nup,idprup,idup,istup,mothup,icolup
5122  DOUBLE PRECISION xwgtup,scalup,aqedup,aqcdup,pup,vtimup,spinup
5123  common/hepeup/nup,idprup,xwgtup,scalup,aqedup,aqcdup,idup(maxnup),
5124  &istup(maxnup),mothup(2,maxnup),icolup(2,maxnup),pup(5,maxnup),
5125  &vtimup(maxnup),spinup(maxnup)
5126  SAVE /hepeup/
5127 
5128 C...Lines to read in assumed never longer than 200 characters.
5129  parameter(maxlen=200)
5130  CHARACTER*(MAXLEN) string
5131 
5132 C...Format for reading lines.
5133  CHARACTER*6 strfmt
5134  strfmt='(A000)'
5135  WRITE(strfmt(3:5),'(I3)') maxlen
5136 
5137 C...Rewind initialization and event files.
5138  rewind mstp(161)
5139  rewind mstp(162)
5140 
5141 C...Write header info.
5142  WRITE(mstp(163),'(A)') '<LesHouchesEvents version="1.0">'
5143  WRITE(mstp(163),'(A)') '<!--'
5144  WRITE(mstp(163),'(A,I1,A1,I3)') 'File generated with PYTHIA ',
5145  &mstp(181),'.',mstp(182)
5146  WRITE(mstp(163),'(A)') '-->'
5147 
5148 C...Read first line of initialization info and get number of processes.
5149  READ(mstp(161),'(A)',end=400,err=400) string
5150  READ(string,*,err=400) idbmup(1),idbmup(2),ebmup(1),
5151  &ebmup(2),pdfgup(1),pdfgup(2),pdfsup(1),pdfsup(2),idwtup,nprup
5152 
5153 C...Copy initialization lines, omitting trailing blanks.
5154 C...Embed in <init> ... </init> block.
5155  WRITE(mstp(163),'(A)') '<init>'
5156  DO 140 ipr=0,nprup
5157  IF(ipr.GT.0) READ(mstp(161),'(A)',end=400,err=400) string
5158  len=maxlen+1
5159  120 len=len-1
5160  IF(len.GT.1.AND.string(len:len).EQ.' ') goto 120
5161  WRITE(mstp(163),'(A)',err=400) string(1:len)
5162  140 CONTINUE
5163  WRITE(mstp(163),'(A)') '</init>'
5164 
5165 C...Begin event loop. Read first line of event info or already done.
5166  READ(mstp(162),'(A)',end=320,err=400) string
5167  200 CONTINUE
5168 
5169 C...Look at first line to know number of particles in event.
5170  READ(string,*,err=400) nup,idprup,xwgtup,scalup,aqedup,aqcdup
5171 
5172 C...Begin an <event> block. Copy event lines, omitting trailing blanks.
5173  WRITE(mstp(163),'(A)') '<event>'
5174  DO 240 i=0,nup
5175  IF(i.GT.0) READ(mstp(162),'(A)',end=400,err=400) string
5176  len=maxlen+1
5177  220 len=len-1
5178  IF(len.GT.1.AND.string(len:len).EQ.' ') goto 220
5179  WRITE(mstp(163),'(A)',err=400) string(1:len)
5180  240 CONTINUE
5181 
5182 C...Copy trailing comment lines - with a # in the first column - as is.
5183  260 READ(mstp(162),'(A)',end=300,err=400) string
5184  IF(string(1:1).EQ.'#') THEN
5185  len=maxlen+1
5186  280 len=len-1
5187  IF(len.GT.1.AND.string(len:len).EQ.' ') goto 280
5188  WRITE(mstp(163),'(A)',err=400) string(1:len)
5189  goto 260
5190  ENDIF
5191 
5192 C..End the <event> block. Loop back to look for next event.
5193  WRITE(mstp(163),'(A)') '</event>'
5194  goto 200
5195 
5196 C...Successfully reached end of event loop: write closing tag
5197 C...and remove temporary intermediate files (unless asked not to).
5198  300 WRITE(mstp(163),'(A)') '</event>'
5199  320 WRITE(mstp(163),'(A)') '</LesHouchesEvents>'
5200  IF(mstp(164).EQ.1) RETURN
5201  CLOSE(mstp(161),err=400,status='DELETE')
5202  CLOSE(mstp(162),err=400,status='DELETE')
5203  RETURN
5204 
5205 C...Error exit.
5206  400 WRITE(*,*) ' PYLHEF file joining failed!'
5207 
5208  RETURN
5209  END
5210 
5211 C*********************************************************************
5212 
5213 C...PYINRE
5214 C...Calculates full and effective widths of gauge bosons, stores
5215 C...masses and widths, rescales coefficients to be used for
5216 C...resonance production generation.
5217 
5218  SUBROUTINE pyinre
5219 
5220 C...Double precision and integer declarations.
5221  IMPLICIT DOUBLE PRECISION(a-h, o-z)
5222  IMPLICIT INTEGER(i-n)
5223  INTEGER pyk,pychge,pycomp
5224 C...Parameter statement to help give large particle numbers.
5225  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
5226  &kexcit=4000000,kdimen=5000000)
5227 C...Commonblocks.
5228  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
5229  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
5230  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
5231  common/pydat4/chaf(500,2)
5232  CHARACTER chaf*16
5233  common/pysubs/msel,mselpd,msub(500),kfin(2,-40:40),ckin(200)
5234  common/pypars/mstp(200),parp(200),msti(200),pari(200)
5235  common/pyint1/mint(400),vint(400)
5236  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
5237  common/pyint4/mwid(500),wids(500,5)
5238  common/pyint6/proc(0:500)
5239  CHARACTER proc*28
5240  common/pymssm/imss(0:99),rmss(0:99)
5241  SAVE /pydat1/,/pydat2/,/pydat3/,/pydat4/,/pysubs/,/pypars/,
5242  &/pyint1/,/pyint2/,/pyint4/,/pyint6/,/pymssm/
5243 C...Local arrays and data.
5244  CHARACTER prtmp*9
5245  dimension wdtp(0:400),wdte(0:400,0:5),wdtpm(0:400),
5246  &wdtem(0:400,0:5),kcord(500),pmord(500)
5247 
5248 C...Born level couplings in MSSM Higgs doublet sector.
5249  xw=paru(102)
5250  xwv=xw
5251  IF(mstp(8).GE.2) xw=1d0-(pmas(24,1)/pmas(23,1))**2
5252  xw1=1d0-xw
5253  IF(mstp(4).EQ.2) THEN
5254  tanbe=paru(141)
5255  ratbe=((1d0-tanbe**2)/(1d0+tanbe**2))**2
5256  sqmz=pmas(23,1)**2
5257  sqmw=pmas(24,1)**2
5258  sqmh=pmas(25,1)**2
5259  sqma=sqmh*(sqmz-sqmh)/(sqmz*ratbe-sqmh)
5260  sqmhp=0.5d0*(sqma+sqmz+sqrt((sqma+sqmz)**2-4d0*sqma*sqmz*ratbe))
5261  sqmhc=sqma+sqmw
5262  IF(sqmh.GE.sqmz.OR.min(sqma,sqmhp,sqmhc).LE.0d0) THEN
5263  WRITE(mstu(11),5000)
5264  CALL pystop(101)
5265  ENDIF
5266  pmas(35,1)=sqrt(sqmhp)
5267  pmas(36,1)=sqrt(sqma)
5268  pmas(37,1)=sqrt(sqmhc)
5269  alsu=0.5d0*atan(2d0*tanbe*(sqma+sqmz)/((1d0-tanbe**2)*
5270  & (sqma-sqmz)))
5271  besu=atan(tanbe)
5272  paru(142)=1d0
5273  paru(143)=1d0
5274  paru(161)=-sin(alsu)/cos(besu)
5275  paru(162)=cos(alsu)/sin(besu)
5276  paru(163)=paru(161)
5277  paru(164)=sin(besu-alsu)
5278  paru(165)=paru(164)
5279  paru(168)=sin(besu-alsu)+0.5d0*cos(2d0*besu)*sin(besu+alsu)/xw
5280  paru(171)=cos(alsu)/cos(besu)
5281  paru(172)=sin(alsu)/sin(besu)
5282  paru(173)=paru(171)
5283  paru(174)=cos(besu-alsu)
5284  paru(175)=paru(174)
5285  paru(176)=cos(2d0*alsu)*cos(besu+alsu)-2d0*sin(2d0*alsu)*
5286  & sin(besu+alsu)
5287  paru(177)=cos(2d0*besu)*cos(besu+alsu)
5288  paru(178)=cos(besu-alsu)-0.5d0*cos(2d0*besu)*cos(besu+alsu)/xw
5289  paru(181)=tanbe
5290  paru(182)=1d0/tanbe
5291  paru(183)=paru(181)
5292  paru(184)=0d0
5293  paru(185)=paru(184)
5294  paru(186)=cos(besu-alsu)
5295  paru(187)=sin(besu-alsu)
5296  paru(188)=paru(186)
5297  paru(189)=paru(187)
5298  paru(190)=0d0
5299  paru(195)=cos(besu-alsu)
5300  ENDIF
5301 
5302 C...Reset effective widths of gauge bosons.
5303  DO 110 i=1,500
5304  DO 100 j=1,5
5305  wids(i,j)=1d0
5306  100 CONTINUE
5307  110 CONTINUE
5308 
5309 C...Order resonances by increasing mass (except Z0 and W+/-).
5310  nres=0
5311  DO 140 kc=1,500
5312  kf=kchg(kc,4)
5313  IF(kf.EQ.0) goto 140
5314  IF(mwid(kc).EQ.0) goto 140
5315  IF(kc.EQ.7.OR.kc.EQ.8.OR.kc.EQ.17.OR.kc.EQ.18) THEN
5316  IF(mstp(1).LE.3) goto 140
5317  ENDIF
5318  IF(kf/ksusy1.EQ.1.OR.kf/ksusy1.EQ.2) THEN
5319  IF(imss(1).LE.0) goto 140
5320  ENDIF
5321  nres=nres+1
5322  pmres=pmas(kc,1)
5323  IF(kc.EQ.23.OR.kc.EQ.24) pmres=0d0
5324  DO 120 i1=nres-1,1,-1
5325  IF(pmres.GE.pmord(i1)) goto 130
5326  kcord(i1+1)=kcord(i1)
5327  pmord(i1+1)=pmord(i1)
5328  120 CONTINUE
5329  130 kcord(i1+1)=kc
5330  pmord(i1+1)=pmres
5331  140 CONTINUE
5332 
5333 C...Loop over possible resonances.
5334  DO 180 i=1,nres
5335  kc=kcord(i)
5336  kf=kchg(kc,4)
5337 
5338 C...Check that no fourth generation channels on by mistake.
5339  IF(mstp(1).LE.3) THEN
5340  DO 150 j=1,mdcy(kc,3)
5341  idc=j+mdcy(kc,2)-1
5342  kfa1=iabs(kfdp(idc,1))
5343  kfa2=iabs(kfdp(idc,2))
5344  IF(kfa1.EQ.7.OR.kfa1.EQ.8.OR.kfa1.EQ.17.OR.kfa1.EQ.18.OR.
5345  & kfa2.EQ.7.OR.kfa2.EQ.8.OR.kfa2.EQ.17.OR.kfa2.EQ.18)
5346  & mdme(idc,1)=-1
5347  150 CONTINUE
5348  ENDIF
5349 
5350 C...Check that no supersymmetric channels on by mistake.
5351  IF(imss(1).LE.0) THEN
5352  DO 160 j=1,mdcy(kc,3)
5353  idc=j+mdcy(kc,2)-1
5354  kfa1s=iabs(kfdp(idc,1))/ksusy1
5355  kfa2s=iabs(kfdp(idc,2))/ksusy1
5356  IF(kfa1s.EQ.1.OR.kfa1s.EQ.2.OR.kfa2s.EQ.1.OR.kfa2s.EQ.2)
5357  & mdme(idc,1)=-1
5358  160 CONTINUE
5359  ENDIF
5360 
5361 C...Find mass and evaluate width.
5362  pmr=pmas(kc,1)
5363  IF(kf.EQ.25.OR.kf.EQ.35.OR.kf.EQ.36) mint(62)=1
5364  IF(mwid(kc).EQ.3) mint(63)=1
5365  CALL pywidt(kf,pmr**2,wdtp,wdte)
5366  mint(51)=0
5367 
5368 C...Evaluate suppression factors due to non-simulated channels.
5369  IF(kchg(kc,3).EQ.0) THEN
5370  wdtp0i=0d0
5371  IF(wdtp(0).GT.0d0) wdtp0i=1d0/wdtp(0)
5372  wids(kc,1)=((wdte(0,1)+wdte(0,2))**2+
5373  & 2d0*(wdte(0,1)+wdte(0,2))*(wdte(0,4)+wdte(0,5))+
5374  & 2d0*wdte(0,4)*wdte(0,5))*wdtp0i**2
5375  wids(kc,2)=(wdte(0,1)+wdte(0,2)+wdte(0,4))*wdtp0i
5376  wids(kc,3)=0d0
5377  wids(kc,4)=0d0
5378  wids(kc,5)=0d0
5379  ELSE
5380  IF(mwid(kc).EQ.3) mint(63)=1
5381  CALL pywidt(-kf,pmr**2,wdtpm,wdtem)
5382  mint(51)=0
5383  wdtp0i=0d0
5384  IF(wdtp(0).GT.0d0) wdtp0i=1d0/wdtp(0)
5385  wids(kc,1)=((wdte(0,1)+wdte(0,2))*(wdtem(0,1)+wdtem(0,3))+
5386  & (wdte(0,1)+wdte(0,2))*(wdtem(0,4)+wdtem(0,5))+
5387  & (wdte(0,4)+wdte(0,5))*(wdtem(0,1)+wdtem(0,3))+
5388  & wdte(0,4)*wdtem(0,5)+wdte(0,5)*wdtem(0,4))*wdtp0i**2
5389  wids(kc,2)=(wdte(0,1)+wdte(0,2)+wdte(0,4))*wdtp0i
5390  wids(kc,3)=(wdtem(0,1)+wdtem(0,3)+wdtem(0,4))*wdtp0i
5391  wids(kc,4)=((wdte(0,1)+wdte(0,2))**2+
5392  & 2d0*(wdte(0,1)+wdte(0,2))*(wdte(0,4)+wdte(0,5))+
5393  & 2d0*wdte(0,4)*wdte(0,5))*wdtp0i**2
5394  wids(kc,5)=((wdtem(0,1)+wdtem(0,3))**2+
5395  & 2d0*(wdtem(0,1)+wdtem(0,3))*(wdtem(0,4)+wdtem(0,5))+
5396  & 2d0*wdtem(0,4)*wdtem(0,5))*wdtp0i**2
5397  ENDIF
5398 
5399 C...Set resonance widths and branching ratios;
5400 C...also on/off switch for decays.
5401  IF(mwid(kc).EQ.1.OR.mwid(kc).EQ.3) THEN
5402  pmas(kc,2)=wdtp(0)
5403  pmas(kc,3)=min(0.9d0*pmas(kc,1),10d0*pmas(kc,2))
5404  IF(mstp(41).EQ.0.OR.mstp(41).EQ.1) mdcy(kc,1)=mstp(41)
5405  DO 170 j=1,mdcy(kc,3)
5406  idc=j+mdcy(kc,2)-1
5407  brat(idc)=0d0
5408  IF(wdtp(0).GT.0d0) brat(idc)=wdtp(j)/wdtp(0)
5409  170 CONTINUE
5410  ENDIF
5411  180 CONTINUE
5412 
5413 C...Flavours of leptoquark: redefine charge and name.
5414  kflqq=kfdp(mdcy(42,2),1)
5415  kflql=kfdp(mdcy(42,2),2)
5416  kchg(42,1)=kchg(pycomp(kflqq),1)*isign(1,kflqq)+
5417  &kchg(pycomp(kflql),1)*isign(1,kflql)
5418  ll=1
5419  IF(iabs(kflql).EQ.13) ll=2
5420  IF(iabs(kflql).EQ.15) ll=3
5421  chaf(42,1)='LQ_'//chaf(iabs(kflqq),1)(1:1)//
5422  &chaf(iabs(kflql),1)(1:ll)//' '
5423  chaf(42,2)=chaf(42,2)(1:4+ll)//'bar '
5424 
5425 C...Special cases in treatment of gamma*/Z0: redefine process name.
5426  IF(mstp(43).EQ.1) THEN
5427  proc(1)='f + fbar -> gamma*'
5428  proc(15)='f + fbar -> g + gamma*'
5429  proc(19)='f + fbar -> gamma + gamma*'
5430  proc(30)='f + g -> f + gamma*'
5431  proc(35)='f + gamma -> f + gamma*'
5432  ELSEIF(mstp(43).EQ.2) THEN
5433  proc(1)='f + fbar -> Z0'
5434  proc(15)='f + fbar -> g + Z0'
5435  proc(19)='f + fbar -> gamma + Z0'
5436  proc(30)='f + g -> f + Z0'
5437  proc(35)='f + gamma -> f + Z0'
5438  ELSEIF(mstp(43).EQ.3) THEN
5439  proc(1)='f + fbar -> gamma*/Z0'
5440  proc(15)='f + fbar -> g + gamma*/Z0'
5441  proc(19)='f+ fbar -> gamma + gamma*/Z0'
5442  proc(30)='f + g -> f + gamma*/Z0'
5443  proc(35)='f + gamma -> f + gamma*/Z0'
5444  ENDIF
5445 
5446 C...Special cases in treatment of gamma*/Z0/Z'0: redefine process name.
5447  IF(mstp(44).EQ.1) THEN
5448  proc(141)='f + fbar -> gamma*'
5449  ELSEIF(mstp(44).EQ.2) THEN
5450  proc(141)='f + fbar -> Z0'
5451  ELSEIF(mstp(44).EQ.3) THEN
5452  proc(141)='f + fbar -> Z''0'
5453  ELSEIF(mstp(44).EQ.4) THEN
5454  proc(141)='f + fbar -> gamma*/Z0'
5455  ELSEIF(mstp(44).EQ.5) THEN
5456  proc(141)='f + fbar -> gamma*/Z''0'
5457  ELSEIF(mstp(44).EQ.6) THEN
5458  proc(141)='f + fbar -> Z0/Z''0'
5459  ELSEIF(mstp(44).EQ.7) THEN
5460  proc(141)='f + fbar -> gamma*/Z0/Z''0'
5461  ENDIF
5462 
5463 C...Special cases in treatment of WW -> WW: redefine process name.
5464  IF(mstp(45).EQ.1) THEN
5465  proc(77)='W+ + W+ -> W+ + W+'
5466  ELSEIF(mstp(45).EQ.2) THEN
5467  proc(77)='W+ + W- -> W+ + W-'
5468  ELSEIF(mstp(45).EQ.3) THEN
5469  proc(77)='W+/- + W+/- -> W+/- + W+/-'
5470  ENDIF
5471 
5472 C...Initialize Generic Processes
5473  kfgen=9900001
5474  kcgen=pycomp(kfgen)
5475  IF(kcgen.GT.0) THEN
5476  idcy=mdcy(kcgen,2)
5477  IF(idcy.GT.0) THEN
5478  kff1=kfdp(idcy+1,1)
5479  kff2=kfdp(idcy+1,2)
5480  kcf1=pycomp(kff1)
5481  kcf2=pycomp(kff2)
5482  ij1=1
5483  ij2=1
5484  kci1=pycomp(kfdp(idcy,1))
5485  IF(kfdp(idcy,1).LT.0) ij1=2
5486  kci2=pycomp(kfdp(idcy,2))
5487  IF(kfdp(idcy,2).LT.0) ij2=2
5488  itmp1=0
5489  190 itmp1=itmp1+1
5490  IF(chaf(kci1,ij1)(itmp1+1:itmp1+1).NE.' '.AND.itmp1.LT.4)
5491  & goto 190
5492  itmp2=0
5493  200 itmp2=itmp2+1
5494  IF(chaf(kci2,ij2)(itmp2+1:itmp2+1).NE.' '.AND.itmp2.LT.4)
5495  & goto 200
5496  prtmp=chaf(kci1,ij1)(1:itmp1)//'+'//chaf(kci2,ij2)(1:itmp2)
5497  itmp3=0
5498  205 itmp3=itmp3+1
5499  IF(prtmp(itmp3+1:itmp3+1).NE.' '.AND.itmp3.LT.9)
5500  & goto 205
5501  proc(481)=prtmp(1:itmp3)//' -> '//chaf(kcgen,1)
5502  ij1=1
5503  ij2=1
5504  IF(kff1.LT.0) ij1=2
5505  IF(kff2.LT.0) ij2=2
5506  itmp1=0
5507  210 itmp1=itmp1+1
5508  IF(chaf(kcf1,ij1)(itmp1+1:itmp1+1).NE.' '.AND.itmp1.LT.8)
5509  & goto 210
5510  itmp2=0
5511  220 itmp2=itmp2+1
5512  IF(chaf(kcf2,ij2)(itmp2+1:itmp2+1).NE.' '.AND.itmp2.LT.8)
5513  & goto 220
5514  proc(482)=prtmp(1:itmp3)//' -> '//chaf(kcf1,ij1)(1:itmp1)//
5515  & '+'//chaf(kcf2,ij2)(1:itmp2)
5516  ENDIF
5517  ENDIF
5518 
5519 
5520 
5521 C...Format for error information.
5522  5000 FORMAT(1x,'Error: unphysical input tan^2(beta) and m_H ',
5523  &'combination'/1x,'Execution stopped!')
5524 
5525  RETURN
5526  END
5527 
5528 C*********************************************************************
5529 
5530 C...PYINBM
5531 C...Identifies the two incoming particles and the choice of frame.
5532 
5533  SUBROUTINE pyinbm(CHFRAM,CHBEAM,CHTARG,WIN)
5534 
5535 C...Double precision and integer declarations.
5536  IMPLICIT DOUBLE PRECISION(a-h, o-z)
5537  IMPLICIT INTEGER(i-n)
5538  INTEGER pyk,pychge,pycomp
5539 
5540 C...User process initialization commonblock.
5541  INTEGER maxpup
5542  parameter(maxpup=100)
5543  INTEGER idbmup,pdfgup,pdfsup,idwtup,nprup,lprup
5544  DOUBLE PRECISION ebmup,xsecup,xerrup,xmaxup
5545  common/heprup/idbmup(2),ebmup(2),pdfgup(2),pdfsup(2),
5546  &idwtup,nprup,xsecup(maxpup),xerrup(maxpup),xmaxup(maxpup),
5547  &lprup(maxpup)
5548  SAVE /heprup/
5549 
5550 C...Commonblocks.
5551  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
5552  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
5553  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
5554  common/pysubs/msel,mselpd,msub(500),kfin(2,-40:40),ckin(200)
5555  common/pypars/mstp(200),parp(200),msti(200),pari(200)
5556  common/pyint1/mint(400),vint(400)
5557  SAVE /pyjets/,/pydat1/,/pydat2/,/pysubs/,/pypars/,/pyint1/
5558 
5559 C...Local arrays, character variables and data.
5560  CHARACTER chfram*12,chbeam*12,chtarg*12,chcom(3)*12,chalp(2)*26,
5561  &chidnt(3)*12,chtemp*12,chcde(39)*12,chinit*76,chname*16
5562  dimension len(3),kcde(39),pm(2)
5563  DATA chalp/'abcdefghijklmnopqrstuvwxyz',
5564  &'ABCDEFGHIJKLMNOPQRSTUVWXYZ'/
5565  DATA chcde/ 'e- ','e+ ','nu_e ',
5566  &'nu_ebar ','mu- ','mu+ ','nu_mu ',
5567  &'nu_mubar ','tau- ','tau+ ','nu_tau ',
5568  &'nu_taubar ','pi+ ','pi- ','n0 ',
5569  &'nbar0 ','p+ ','pbar- ','gamma ',
5570  &'lambda0 ','sigma- ','sigma0 ','sigma+ ',
5571  &'xi- ','xi0 ','omega- ','pi0 ',
5572  &'reggeon ','pomeron ','gamma/e- ','gamma/e+ ',
5573  &'gamma/mu- ','gamma/mu+ ','gamma/tau- ','gamma/tau+ ',
5574  &'k+ ','k- ','ks0 ','kl0 '/
5575  DATA kcde/11,-11,12,-12,13,-13,14,-14,15,-15,16,-16,
5576  &211,-211,2112,-2112,2212,-2212,22,3122,3112,3212,3222,
5577  &3312,3322,3334,111,110,990,6*22,321,-321,310,130/
5578 
5579 C...Store initial energy. Default frame.
5580  vint(290)=win
5581  mint(111)=0
5582 
5583 C...Special user process initialization; convert to normal input.
5584  IF(chfram(1:1).EQ.'u'.OR.chfram(1:1).EQ.'U') THEN
5585  mint(111)=11
5586  IF(pdfgup(1).EQ.-9.OR.pdfgup(2).EQ.-9) mint(111)=12
5587  CALL pyname(idbmup(1),chname)
5588  chbeam=chname(1:12)
5589  CALL pyname(idbmup(2),chname)
5590  chtarg=chname(1:12)
5591  ENDIF
5592 
5593 C...Convert character variables to lowercase and find their length.
5594  chcom(1)=chfram
5595  chcom(2)=chbeam
5596  chcom(3)=chtarg
5597  DO 130 i=1,3
5598  len(i)=12
5599  DO 110 ll=12,1,-1
5600  IF(len(i).EQ.ll.AND.chcom(i)(ll:ll).EQ.' ') len(i)=ll-1
5601  DO 100 la=1,26
5602  IF(chcom(i)(ll:ll).EQ.chalp(2)(la:la)) chcom(i)(ll:ll)=
5603  & chalp(1)(la:la)
5604  100 CONTINUE
5605  110 CONTINUE
5606  chidnt(i)=chcom(i)
5607 
5608 C...Fix up bar, underscore and charge in particle name (if needed).
5609  DO 120 ll=1,10
5610  IF(chidnt(i)(ll:ll).EQ.'~') THEN
5611  chtemp=chidnt(i)
5612  chidnt(i)=chtemp(1:ll-1)//'bar'//chtemp(ll+1:10)//' '
5613  ENDIF
5614  120 CONTINUE
5615  IF(chidnt(i)(1:2).EQ.'nu'.AND.chidnt(i)(3:3).NE.'_') THEN
5616  chtemp=chidnt(i)
5617  chidnt(i)='nu_'//chtemp(3:7)
5618  ELSEIF(chidnt(i)(1:2).EQ.'n ') THEN
5619  chidnt(i)(1:3)='n0 '
5620  ELSEIF(chidnt(i)(1:4).EQ.'nbar') THEN
5621  chidnt(i)(1:5)='nbar0'
5622  ELSEIF(chidnt(i)(1:2).EQ.'p ') THEN
5623  chidnt(i)(1:3)='p+ '
5624  ELSEIF(chidnt(i)(1:4).EQ.'pbar'.OR.
5625  & chidnt(i)(1:2).EQ.'p-') THEN
5626  chidnt(i)(1:5)='pbar-'
5627  ELSEIF(chidnt(i)(1:6).EQ.'lambda') THEN
5628  chidnt(i)(7:7)='0'
5629  ELSEIF(chidnt(i)(1:3).EQ.'reg') THEN
5630  chidnt(i)(1:7)='reggeon'
5631  ELSEIF(chidnt(i)(1:3).EQ.'pom') THEN
5632  chidnt(i)(1:7)='pomeron'
5633  ENDIF
5634  130 CONTINUE
5635 
5636 C...Identify free initialization.
5637  IF(chcom(1)(1:2).EQ.'no') THEN
5638  mint(65)=1
5639  RETURN
5640  ENDIF
5641 
5642 C...Identify incoming beam and target particles.
5643  DO 160 i=1,2
5644  DO 140 j=1,39
5645  IF(chidnt(i+1).EQ.chcde(j)) mint(10+i)=kcde(j)
5646  140 CONTINUE
5647  pm(i)=pymass(mint(10+i))
5648  vint(2+i)=pm(i)
5649  mint(140+i)=0
5650  IF(mint(10+i).EQ.22.AND.chidnt(i+1)(6:6).EQ.'/') THEN
5651  chtemp=chidnt(i+1)(7:12)//' '
5652  DO 150 j=1,12
5653  IF(chtemp.EQ.chcde(j)) mint(140+i)=kcde(j)
5654  150 CONTINUE
5655  pm(i)=pymass(mint(140+i))
5656  vint(302+i)=pm(i)
5657  ENDIF
5658  160 CONTINUE
5659  IF(mint(11).EQ.0) WRITE(mstu(11),5000) chbeam(1:len(2))
5660  IF(mint(12).EQ.0) WRITE(mstu(11),5100) chtarg(1:len(3))
5661  IF(mint(11).EQ.0.OR.mint(12).EQ.0) CALL pystop(7)
5662 
5663 C...Identify choice of frame and input energies.
5664  chinit=' '
5665 
5666 C...Events defined in the CM frame.
5667  IF(chcom(1)(1:2).EQ.'cm') THEN
5668  mint(111)=1
5669  s=win**2
5670  IF(mstp(122).GE.1) THEN
5671  IF(chcom(2)(1:1).NE.'e') THEN
5672  loffs=(31-(len(2)+len(3)))/2
5673  chinit(loffs+1:76)='PYTHIA will be initialized for a '//
5674  & chcom(2)(1:len(2))//' on '//chcom(3)(1:len(3))//
5675  & ' collider'//' '
5676  ELSE
5677  loffs=(30-(len(2)+len(3)))/2
5678  chinit(loffs+1:76)='PYTHIA will be initialized for an '//
5679  & chcom(2)(1:len(2))//' on '//chcom(3)(1:len(3))//
5680  & ' collider'//' '
5681  ENDIF
5682  WRITE(mstu(11),5200) chinit
5683  WRITE(mstu(11),5300) win
5684  ENDIF
5685 
5686 C...Events defined in fixed target frame.
5687  ELSEIF(chcom(1)(1:3).EQ.'fix') THEN
5688  mint(111)=2
5689  s=pm(1)**2+pm(2)**2+2d0*pm(2)*sqrt(pm(1)**2+win**2)
5690  IF(mstp(122).GE.1) THEN
5691  loffs=(29-(len(2)+len(3)))/2
5692  chinit(loffs+1:76)='PYTHIA will be initialized for '//
5693  & chcom(2)(1:len(2))//' on '//chcom(3)(1:len(3))//
5694  & ' fixed target'//' '
5695  WRITE(mstu(11),5200) chinit
5696  WRITE(mstu(11),5400) win
5697  WRITE(mstu(11),5500) sqrt(s)
5698  ENDIF
5699 
5700 C...Frame defined by user three-vectors.
5701  ELSEIF(chcom(1)(1:1).EQ.'3') THEN
5702  mint(111)=3
5703  p(1,5)=pm(1)
5704  p(2,5)=pm(2)
5705  p(1,4)=sqrt(p(1,1)**2+p(1,2)**2+p(1,3)**2+p(1,5)**2)
5706  p(2,4)=sqrt(p(2,1)**2+p(2,2)**2+p(2,3)**2+p(2,5)**2)
5707  s=(p(1,4)+p(2,4))**2-(p(1,1)+p(2,1))**2-(p(1,2)+p(2,2))**2-
5708  & (p(1,3)+p(2,3))**2
5709  IF(mstp(122).GE.1) THEN
5710  loffs=(22-(len(2)+len(3)))/2
5711  chinit(loffs+1:76)='PYTHIA will be initialized for '//
5712  & chcom(2)(1:len(2))//' on '//chcom(3)(1:len(3))//
5713  & ' user configuration'//' '
5714  WRITE(mstu(11),5200) chinit
5715  WRITE(mstu(11),5600)
5716  WRITE(mstu(11),5700) chcom(2),p(1,1),p(1,2),p(1,3),p(1,4)
5717  WRITE(mstu(11),5700) chcom(3),p(2,1),p(2,2),p(2,3),p(2,4)
5718  WRITE(mstu(11),5500) sqrt(max(0d0,s))
5719  ENDIF
5720 
5721 C...Frame defined by user four-vectors.
5722  ELSEIF(chcom(1)(1:1).EQ.'4') THEN
5723  mint(111)=4
5724  pms1=p(1,4)**2-p(1,1)**2-p(1,2)**2-p(1,3)**2
5725  p(1,5)=sign(sqrt(abs(pms1)),pms1)
5726  pms2=p(2,4)**2-p(2,1)**2-p(2,2)**2-p(2,3)**2
5727  p(2,5)=sign(sqrt(abs(pms2)),pms2)
5728  s=(p(1,4)+p(2,4))**2-(p(1,1)+p(2,1))**2-(p(1,2)+p(2,2))**2-
5729  & (p(1,3)+p(2,3))**2
5730  IF(mstp(122).GE.1) THEN
5731  loffs=(22-(len(2)+len(3)))/2
5732  chinit(loffs+1:76)='PYTHIA will be initialized for '//
5733  & chcom(2)(1:len(2))//' on '//chcom(3)(1:len(3))//
5734  & ' user configuration'//' '
5735  WRITE(mstu(11),5200) chinit
5736  WRITE(mstu(11),5600)
5737  WRITE(mstu(11),5700) chcom(2),p(1,1),p(1,2),p(1,3),p(1,4)
5738  WRITE(mstu(11),5700) chcom(3),p(2,1),p(2,2),p(2,3),p(2,4)
5739  WRITE(mstu(11),5500) sqrt(max(0d0,s))
5740  ENDIF
5741 
5742 C...Frame defined by user five-vectors.
5743  ELSEIF(chcom(1)(1:1).EQ.'5') THEN
5744  mint(111)=5
5745  s=(p(1,4)+p(2,4))**2-(p(1,1)+p(2,1))**2-(p(1,2)+p(2,2))**2-
5746  & (p(1,3)+p(2,3))**2
5747  IF(mstp(122).GE.1) THEN
5748  loffs=(22-(len(2)+len(3)))/2
5749  chinit(loffs+1:76)='PYTHIA will be initialized for '//
5750  & chcom(2)(1:len(2))//' on '//chcom(3)(1:len(3))//
5751  & ' user configuration'//' '
5752  WRITE(mstu(11),5200) chinit
5753  WRITE(mstu(11),5600)
5754  WRITE(mstu(11),5700) chcom(2),p(1,1),p(1,2),p(1,3),p(1,4)
5755  WRITE(mstu(11),5700) chcom(3),p(2,1),p(2,2),p(2,3),p(2,4)
5756  WRITE(mstu(11),5500) sqrt(max(0d0,s))
5757  ENDIF
5758 
5759 C...Frame defined by HEPRUP common block.
5760  ELSEIF(mint(111).GE.11) THEN
5761  s=(ebmup(1)+ebmup(2))**2-(sqrt(max(0d0,ebmup(1)**2-pm(1)**2))-
5762  & sqrt(max(0d0,ebmup(2)**2-pm(2)**2)))**2
5763  IF(mstp(122).GE.1) THEN
5764  loffs=(22-(len(2)+len(3)))/2
5765  chinit(loffs+1:76)='PYTHIA will be initialized for '//
5766  & chcom(2)(1:len(2))//' on '//chcom(3)(1:len(3))//
5767  & ' user configuration'//' '
5768  WRITE(mstu(11),5200) chinit
5769  WRITE(mstu(11),6000) ebmup(1),ebmup(2)
5770  WRITE(mstu(11),5500) sqrt(max(0d0,s))
5771  ENDIF
5772 
5773 C...Unknown frame. Error for too low CM energy.
5774  ELSE
5775  WRITE(mstu(11),5800) chfram(1:len(1))
5776  CALL pystop(7)
5777  ENDIF
5778  IF(s.LT.parp(2)**2) THEN
5779  WRITE(mstu(11),5900) sqrt(s)
5780  CALL pystop(7)
5781  ENDIF
5782 
5783 C...Formats for initialization and error information.
5784  5000 FORMAT(1x,'Error: unrecognized beam particle ''',a,'''D0'/
5785  &1x,'Execution stopped!')
5786  5100 FORMAT(1x,'Error: unrecognized target particle ''',a,'''D0'/
5787  &1x,'Execution stopped!')
5788  5200 FORMAT(/1x,78('=')/1x,'I',76x,'I'/1x,'I',a76,'I')
5789  5300 FORMAT(1x,'I',18x,'at',1x,f10.3,1x,'GeV center-of-mass energy',
5790  &19x,'I'/1x,'I',76x,'I'/1x,78('='))
5791  5400 FORMAT(1x,'I',22x,'at',1x,f10.3,1x,'GeV/c lab-momentum',22x,'I')
5792  5500 FORMAT(1x,'I',76x,'I'/1x,'I',11x,'corresponding to',1x,f10.3,1x,
5793  &'GeV center-of-mass energy',12x,'I'/1x,'I',76x,'I'/1x,78('='))
5794  5600 FORMAT(1x,'I',76x,'I'/1x,'I',18x,'px (GeV/c)',3x,'py (GeV/c)',3x,
5795  &'pz (GeV/c)',6x,'E (GeV)',9x,'I')
5796  5700 FORMAT(1x,'I',8x,a8,4(2x,f10.3,1x),8x,'I')
5797  5800 FORMAT(1x,'Error: unrecognized coordinate frame ''',a,'''D0'/
5798  &1x,'Execution stopped!')
5799  5900 FORMAT(1x,'Error: too low CM energy,',f8.3,' GeV for event ',
5800  &'generation.'/1x,'Execution stopped!')
5801  6000 FORMAT(1x,'I',12x,'with',1x,f10.3,1x,'GeV on',1x,f10.3,1x,
5802  &'GeV beam energies',13x,'I')
5803 
5804  RETURN
5805  END
5806 
5807 C*********************************************************************
5808 
5809 C...PYINKI
5810 C...Sets up kinematics, including rotations and boosts to/from CM frame.
5811 
5812  SUBROUTINE pyinki(MODKI)
5813 
5814 C...Double precision and integer declarations.
5815  IMPLICIT DOUBLE PRECISION(a-h, o-z)
5816  IMPLICIT INTEGER(i-n)
5817  INTEGER pyk,pychge,pycomp
5818 
5819 C...User process initialization commonblock.
5820  INTEGER maxpup
5821  parameter(maxpup=100)
5822  INTEGER idbmup,pdfgup,pdfsup,idwtup,nprup,lprup
5823  DOUBLE PRECISION ebmup,xsecup,xerrup,xmaxup
5824  common/heprup/idbmup(2),ebmup(2),pdfgup(2),pdfsup(2),
5825  &idwtup,nprup,xsecup(maxpup),xerrup(maxpup),xmaxup(maxpup),
5826  &lprup(maxpup)
5827  SAVE /heprup/
5828 
5829 C...Commonblocks.
5830  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
5831  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
5832  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
5833  common/pysubs/msel,mselpd,msub(500),kfin(2,-40:40),ckin(200)
5834  common/pypars/mstp(200),parp(200),msti(200),pari(200)
5835  common/pyint1/mint(400),vint(400)
5836  SAVE /pyjets/,/pydat1/,/pydat2/,/pysubs/,/pypars/,/pyint1/
5837 
5838 C...Set initial flavour state.
5839  n=2
5840  DO 100 i=1,2
5841  k(i,1)=1
5842  k(i,2)=mint(10+i)
5843  IF(mint(140+i).NE.0) k(i,2)=mint(140+i)
5844  100 CONTINUE
5845 
5846 C...Reset boost. Do kinematics for various cases.
5847  DO 110 j=6,10
5848  vint(j)=0d0
5849  110 CONTINUE
5850 
5851 C...Set up kinematics for events defined in CM frame.
5852  IF(mint(111).EQ.1) THEN
5853  win=vint(290)
5854  IF(modki.EQ.1) win=parp(171)*vint(290)
5855  s=win**2
5856  p(1,5)=vint(3)
5857  p(2,5)=vint(4)
5858  IF(mint(141).NE.0) p(1,5)=vint(303)
5859  IF(mint(142).NE.0) p(2,5)=vint(304)
5860  p(1,1)=0d0
5861  p(1,2)=0d0
5862  p(2,1)=0d0
5863  p(2,2)=0d0
5864  p(1,3)=sqrt(((s-p(1,5)**2-p(2,5)**2)**2-(2d0*p(1,5)*p(2,5))**2)/
5865  & (4d0*s))
5866  p(2,3)=-p(1,3)
5867  p(1,4)=sqrt(p(1,3)**2+p(1,5)**2)
5868  p(2,4)=sqrt(p(2,3)**2+p(2,5)**2)
5869 
5870 C...Set up kinematics for fixed target events.
5871  ELSEIF(mint(111).EQ.2) THEN
5872  win=vint(290)
5873  IF(modki.EQ.1) win=parp(171)*vint(290)
5874  p(1,5)=vint(3)
5875  p(2,5)=vint(4)
5876  IF(mint(141).NE.0) p(1,5)=vint(303)
5877  IF(mint(142).NE.0) p(2,5)=vint(304)
5878  p(1,1)=0d0
5879  p(1,2)=0d0
5880  p(2,1)=0d0
5881  p(2,2)=0d0
5882  p(1,3)=win
5883  p(1,4)=sqrt(p(1,3)**2+p(1,5)**2)
5884  p(2,3)=0d0
5885  p(2,4)=p(2,5)
5886  s=p(1,5)**2+p(2,5)**2+2d0*p(2,4)*p(1,4)
5887  vint(10)=p(1,3)/(p(1,4)+p(2,4))
5888  CALL pyrobo(0,0,0d0,0d0,0d0,0d0,-vint(10))
5889 
5890 C...Set up kinematics for events in user-defined frame.
5891  ELSEIF(mint(111).EQ.3) THEN
5892  p(1,5)=vint(3)
5893  p(2,5)=vint(4)
5894  IF(mint(141).NE.0) p(1,5)=vint(303)
5895  IF(mint(142).NE.0) p(2,5)=vint(304)
5896  p(1,4)=sqrt(p(1,1)**2+p(1,2)**2+p(1,3)**2+p(1,5)**2)
5897  p(2,4)=sqrt(p(2,1)**2+p(2,2)**2+p(2,3)**2+p(2,5)**2)
5898  DO 120 j=1,3
5899  vint(7+j)=(p(1,j)+p(2,j))/(p(1,4)+p(2,4))
5900  120 CONTINUE
5901  CALL pyrobo(0,0,0d0,0d0,-vint(8),-vint(9),-vint(10))
5902  vint(7)=pyangl(p(1,1),p(1,2))
5903  CALL pyrobo(0,0,0d0,-vint(7),0d0,0d0,0d0)
5904  vint(6)=pyangl(p(1,3),p(1,1))
5905  CALL pyrobo(0,0,-vint(6),0d0,0d0,0d0,0d0)
5906  s=p(1,5)**2+p(2,5)**2+2d0*(p(1,4)*p(2,4)-p(1,3)*p(2,3))
5907 
5908 C...Set up kinematics for events with user-defined four-vectors.
5909  ELSEIF(mint(111).EQ.4) THEN
5910  pms1=p(1,4)**2-p(1,1)**2-p(1,2)**2-p(1,3)**2
5911  p(1,5)=sign(sqrt(abs(pms1)),pms1)
5912  pms2=p(2,4)**2-p(2,1)**2-p(2,2)**2-p(2,3)**2
5913  p(2,5)=sign(sqrt(abs(pms2)),pms2)
5914  DO 130 j=1,3
5915  vint(7+j)=(p(1,j)+p(2,j))/(p(1,4)+p(2,4))
5916  130 CONTINUE
5917  CALL pyrobo(0,0,0d0,0d0,-vint(8),-vint(9),-vint(10))
5918  vint(7)=pyangl(p(1,1),p(1,2))
5919  CALL pyrobo(0,0,0d0,-vint(7),0d0,0d0,0d0)
5920  vint(6)=pyangl(p(1,3),p(1,1))
5921  CALL pyrobo(0,0,-vint(6),0d0,0d0,0d0,0d0)
5922  s=(p(1,4)+p(2,4))**2
5923 
5924 C...Set up kinematics for events with user-defined five-vectors.
5925  ELSEIF(mint(111).EQ.5) THEN
5926  DO 140 j=1,3
5927  vint(7+j)=(p(1,j)+p(2,j))/(p(1,4)+p(2,4))
5928  140 CONTINUE
5929  CALL pyrobo(0,0,0d0,0d0,-vint(8),-vint(9),-vint(10))
5930  vint(7)=pyangl(p(1,1),p(1,2))
5931  CALL pyrobo(0,0,0d0,-vint(7),0d0,0d0,0d0)
5932  vint(6)=pyangl(p(1,3),p(1,1))
5933  CALL pyrobo(0,0,-vint(6),0d0,0d0,0d0,0d0)
5934  s=(p(1,4)+p(2,4))**2
5935 
5936 C...Set up kinematics for events with external user processes.
5937  ELSEIF(mint(111).GE.11) THEN
5938  p(1,5)=vint(3)
5939  p(2,5)=vint(4)
5940  IF(mint(141).NE.0) p(1,5)=vint(303)
5941  IF(mint(142).NE.0) p(2,5)=vint(304)
5942  p(1,1)=0d0
5943  p(1,2)=0d0
5944  p(2,1)=0d0
5945  p(2,2)=0d0
5946  p(1,3)=sqrt(max(0d0,ebmup(1)**2-p(1,5)**2))
5947  p(2,3)=-sqrt(max(0d0,ebmup(2)**2-p(2,5)**2))
5948  p(1,4)=ebmup(1)
5949  p(2,4)=ebmup(2)
5950  vint(10)=(p(1,3)+p(2,3))/(p(1,4)+p(2,4))
5951  CALL pyrobo(0,0,0d0,0d0,0d0,0d0,-vint(10))
5952  s=(p(1,4)+p(2,4))**2
5953  ENDIF
5954 
5955 C...Return or error for too low CM energy.
5956  IF(modki.EQ.1.AND.s.LT.parp(2)**2) THEN
5957  IF(mstp(172).LE.1) THEN
5958  CALL pyerrm(23,
5959  & '(PYINKI:) too low invariant mass in this event')
5960  ELSE
5961  msti(61)=1
5962  RETURN
5963  ENDIF
5964  ENDIF
5965 
5966 C...Save information on incoming particles.
5967  vint(1)=sqrt(s)
5968  vint(2)=s
5969  IF(mint(111).GE.4) THEN
5970  IF(mint(141).EQ.0) THEN
5971  vint(3)=p(1,5)
5972  IF(mint(11).EQ.22.AND.p(1,5).LT.0) vint(307)=p(1,5)**2
5973  ELSE
5974  vint(303)=p(1,5)
5975  ENDIF
5976  IF(mint(142).EQ.0) THEN
5977  vint(4)=p(2,5)
5978  IF(mint(12).EQ.22.AND.p(2,5).LT.0) vint(308)=p(2,5)**2
5979  ELSE
5980  vint(304)=p(2,5)
5981  ENDIF
5982  ENDIF
5983  vint(5)=p(1,3)
5984  IF(modki.EQ.0) vint(289)=s
5985  DO 150 j=1,5
5986  v(1,j)=0d0
5987  v(2,j)=0d0
5988  vint(290+j)=p(1,j)
5989  vint(295+j)=p(2,j)
5990  150 CONTINUE
5991 
5992 C...Store pT cut-off and related constants to be used in generation.
5993  IF(modki.EQ.0) vint(285)=ckin(3)
5994  IF(mstp(82).LE.1) THEN
5995  ptmn=parp(81)*(vint(1)/parp(89))**parp(90)
5996  ELSE
5997  ptmn=parp(82)*(vint(1)/parp(89))**parp(90)
5998  ENDIF
5999  vint(149)=4d0*ptmn**2/s
6000  vint(154)=ptmn
6001 
6002  RETURN
6003  END
6004 
6005 C*********************************************************************
6006 
6007 C...PYINPR
6008 C...Selects partonic subprocesses to be included in the simulation.
6009 
6010  SUBROUTINE pyinpr
6011 
6012 C...Double precision and integer declarations.
6013  IMPLICIT DOUBLE PRECISION(a-h, o-z)
6014  IMPLICIT INTEGER(i-n)
6015  INTEGER pyk,pychge,pycomp
6016 
6017 C...User process initialization commonblock.
6018  INTEGER maxpup
6019  parameter(maxpup=100)
6020  INTEGER idbmup,pdfgup,pdfsup,idwtup,nprup,lprup
6021  DOUBLE PRECISION ebmup,xsecup,xerrup,xmaxup
6022  common/heprup/idbmup(2),ebmup(2),pdfgup(2),pdfsup(2),
6023  &idwtup,nprup,xsecup(maxpup),xerrup(maxpup),xmaxup(maxpup),
6024  &lprup(maxpup)
6025  SAVE /heprup/
6026 
6027 C...Commonblocks and character variables.
6028  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
6029  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
6030  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
6031  common/pysubs/msel,mselpd,msub(500),kfin(2,-40:40),ckin(200)
6032  common/pypars/mstp(200),parp(200),msti(200),pari(200)
6033  common/pyint1/mint(400),vint(400)
6034  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
6035  common/pyint6/proc(0:500)
6036  CHARACTER proc*28
6037  SAVE /pydat1/,/pydat2/,/pydat3/,/pysubs/,/pypars/,/pyint1/,
6038  &/pyint2/,/pyint6/
6039  CHARACTER chipr*10
6040 
6041 
6042 C...Reset processes to be included.
6043  IF(msel.NE.0) THEN
6044  DO 100 i=1,500
6045  msub(i)=0
6046  100 CONTINUE
6047  ENDIF
6048 
6049 C...Set running pTmin scale.
6050  IF(mstp(82).LE.1) THEN
6051  ptmrun=parp(81)*(vint(1)/parp(89))**parp(90)
6052  ELSE
6053  ptmrun=parp(82)*(vint(1)/parp(89))**parp(90)
6054  ENDIF
6055 
6056 C...Begin by assuming incoming photon to enter subprocess.
6057  IF(mint(11).EQ.22) mint(15)=22
6058  IF(mint(12).EQ.22) mint(16)=22
6059 
6060 C...For e-gamma with MSTP(14)=10 allow mixture of VMD and anomalous.
6061  IF(mint(121).EQ.2.AND.mstp(14).EQ.10) THEN
6062  msub(10)=1
6063  mint(123)=mint(122)+1
6064 
6065 C...For gamma-p or gamma-gamma with MSTP(14) = 10, 20, 25 or 30
6066 C...allow mixture.
6067 C...Here also set a few parameters otherwise normally not touched.
6068  ELSEIF(mint(121).GT.1) THEN
6069 
6070 C...Parton distributions dampened at small Q2; go to low energies,
6071 C...alpha_s <1; no minimum pT cut-off a priori.
6072  IF(mstp(18).EQ.2) THEN
6073  mstp(57)=3
6074  parp(2)=2d0
6075  paru(115)=1d0
6076  ckin(5)=0.2d0
6077  ckin(6)=0.2d0
6078  ENDIF
6079 
6080 C...Define pT cut-off parameters and whether run involves low-pT.
6081  ptmvmd=ptmrun
6082  vint(154)=ptmvmd
6083  ptmdir=ptmvmd
6084  IF(mstp(18).EQ.2) ptmdir=parp(15)
6085  ptmano=ptmvmd
6086  IF(mstp(15).EQ.5) ptmano=0.60d0+
6087  & 0.125d0*log(1d0+0.10d0*vint(1))**2
6088  iptl=1
6089  IF(vint(285).GT.max(ptmvmd,ptmdir,ptmano)) iptl=0
6090  IF(msel.EQ.2) iptl=1
6091 
6092 C...Set up for p/gamma * gamma; real or virtual photons.
6093  IF(mint(121).EQ.3.OR.mint(121).EQ.6.OR.(mint(121).EQ.4.AND.
6094  & mstp(14).EQ.30)) THEN
6095 
6096 C...Set up for p/VMD * VMD.
6097  IF(mint(122).EQ.1) THEN
6098  mint(123)=2
6099  msub(11)=1
6100  msub(12)=1
6101  msub(13)=1
6102  msub(28)=1
6103  msub(53)=1
6104  msub(68)=1
6105  IF(iptl.EQ.1) msub(95)=1
6106  IF(msel.EQ.2) THEN
6107  msub(91)=1
6108  msub(92)=1
6109  msub(93)=1
6110  msub(94)=1
6111  ENDIF
6112  IF(iptl.EQ.1) ckin(3)=0d0
6113 
6114 C...Set up for p/VMD * direct gamma.
6115  ELSEIF(mint(122).EQ.2) THEN
6116  mint(123)=0
6117  IF(mint(121).EQ.6) mint(123)=5
6118  msub(131)=1
6119  msub(132)=1
6120  msub(135)=1
6121  msub(136)=1
6122  IF(iptl.EQ.1) ckin(3)=ptmdir
6123 
6124 C...Set up for p/VMD * anomalous gamma.
6125  ELSEIF(mint(122).EQ.3) THEN
6126  mint(123)=3
6127  IF(mint(121).EQ.6) mint(123)=7
6128  msub(11)=1
6129  msub(12)=1
6130  msub(13)=1
6131  msub(28)=1
6132  msub(53)=1
6133  msub(68)=1
6134  IF(iptl.EQ.1) msub(95)=1
6135  IF(msel.EQ.2) THEN
6136  msub(91)=1
6137  msub(92)=1
6138  msub(93)=1
6139  msub(94)=1
6140  ENDIF
6141  IF(iptl.EQ.1) ckin(3)=0d0
6142 
6143 C...Set up for DIS * p.
6144  ELSEIF(mint(122).EQ.4.AND.(iabs(mint(11)).GT.100.OR.
6145  & iabs(mint(12)).GT.100)) THEN
6146  mint(123)=8
6147  IF(iptl.EQ.1) msub(99)=1
6148 
6149 C...Set up for direct * direct gamma (switch off leptons).
6150  ELSEIF(mint(122).EQ.4) THEN
6151  mint(123)=0
6152  msub(137)=1
6153  msub(138)=1
6154  msub(139)=1
6155  msub(140)=1
6156  DO 110 ii=mdcy(22,2),mdcy(22,2)+mdcy(22,3)-1
6157  IF(iabs(kfdp(ii,1)).GE.10) mdme(ii,1)=min(0,mdme(ii,1))
6158  110 CONTINUE
6159  IF(iptl.EQ.1) ckin(3)=ptmdir
6160 
6161 C...Set up for direct * anomalous gamma.
6162  ELSEIF(mint(122).EQ.5) THEN
6163  mint(123)=6
6164  msub(131)=1
6165  msub(132)=1
6166  msub(135)=1
6167  msub(136)=1
6168  IF(iptl.EQ.1) ckin(3)=ptmano
6169 
6170 C...Set up for anomalous * anomalous gamma.
6171  ELSEIF(mint(122).EQ.6) THEN
6172  mint(123)=3
6173  msub(11)=1
6174  msub(12)=1
6175  msub(13)=1
6176  msub(28)=1
6177  msub(53)=1
6178  msub(68)=1
6179  IF(iptl.EQ.1) msub(95)=1
6180  IF(msel.EQ.2) THEN
6181  msub(91)=1
6182  msub(92)=1
6183  msub(93)=1
6184  msub(94)=1
6185  ENDIF
6186  IF(iptl.EQ.1) ckin(3)=0d0
6187  ENDIF
6188 
6189 C...Set up for gamma* * gamma*; virtual photons = dir, VMD, anom.
6190  ELSEIF(mint(121).EQ.9.OR.mint(121).EQ.13) THEN
6191 
6192 C...Set up for direct * direct gamma (switch off leptons).
6193  IF(mint(122).EQ.1) THEN
6194  mint(123)=0
6195  msub(137)=1
6196  msub(138)=1
6197  msub(139)=1
6198  msub(140)=1
6199  DO 120 ii=mdcy(22,2),mdcy(22,2)+mdcy(22,3)-1
6200  IF(iabs(kfdp(ii,1)).GE.10) mdme(ii,1)=min(0,mdme(ii,1))
6201  120 CONTINUE
6202  IF(iptl.EQ.1) ckin(3)=ptmdir
6203 
6204 C...Set up for direct * VMD and VMD * direct gamma.
6205  ELSEIF(mint(122).EQ.2.OR.mint(122).EQ.4) THEN
6206  mint(123)=5
6207  msub(131)=1
6208  msub(132)=1
6209  msub(135)=1
6210  msub(136)=1
6211  IF(iptl.EQ.1) ckin(3)=ptmdir
6212 
6213 C...Set up for direct * anomalous and anomalous * direct gamma.
6214  ELSEIF(mint(122).EQ.3.OR.mint(122).EQ.7) THEN
6215  mint(123)=6
6216  msub(131)=1
6217  msub(132)=1
6218  msub(135)=1
6219  msub(136)=1
6220  IF(iptl.EQ.1) ckin(3)=ptmano
6221 
6222 C...Set up for VMD*VMD.
6223  ELSEIF(mint(122).EQ.5) THEN
6224  mint(123)=2
6225  msub(11)=1
6226  msub(12)=1
6227  msub(13)=1
6228  msub(28)=1
6229  msub(53)=1
6230  msub(68)=1
6231  IF(iptl.EQ.1) msub(95)=1
6232  IF(msel.EQ.2) THEN
6233  msub(91)=1
6234  msub(92)=1
6235  msub(93)=1
6236  msub(94)=1
6237  ENDIF
6238  IF(iptl.EQ.1) ckin(3)=0d0
6239 
6240 C...Set up for VMD * anomalous and anomalous * VMD gamma.
6241  ELSEIF(mint(122).EQ.6.OR.mint(122).EQ.8) THEN
6242  mint(123)=7
6243  msub(11)=1
6244  msub(12)=1
6245  msub(13)=1
6246  msub(28)=1
6247  msub(53)=1
6248  msub(68)=1
6249  IF(iptl.EQ.1) msub(95)=1
6250  IF(msel.EQ.2) THEN
6251  msub(91)=1
6252  msub(92)=1
6253  msub(93)=1
6254  msub(94)=1
6255  ENDIF
6256  IF(iptl.EQ.1) ckin(3)=0d0
6257 
6258 C...Set up for anomalous * anomalous gamma.
6259  ELSEIF(mint(122).EQ.9) THEN
6260  mint(123)=3
6261  msub(11)=1
6262  msub(12)=1
6263  msub(13)=1
6264  msub(28)=1
6265  msub(53)=1
6266  msub(68)=1
6267  IF(iptl.EQ.1) msub(95)=1
6268  IF(msel.EQ.2) THEN
6269  msub(91)=1
6270  msub(92)=1
6271  msub(93)=1
6272  msub(94)=1
6273  ENDIF
6274  IF(iptl.EQ.1) ckin(3)=0d0
6275 
6276 C...Set up for DIS * VMD and VMD * DIS gamma.
6277  ELSEIF(mint(122).EQ.10.OR.mint(122).EQ.12) THEN
6278  mint(123)=8
6279  IF(iptl.EQ.1) msub(99)=1
6280 
6281 C...Set up for DIS * anomalous and anomalous * DIS gamma.
6282  ELSEIF(mint(122).EQ.11.OR.mint(122).EQ.13) THEN
6283  mint(123)=9
6284  IF(iptl.EQ.1) msub(99)=1
6285  ENDIF
6286 
6287 C...Set up for gamma* * p; virtual photons = dir, res.
6288  ELSEIF(mint(121).EQ.2) THEN
6289 
6290 C...Set up for direct * p.
6291  IF(mint(122).EQ.1) THEN
6292  mint(123)=0
6293  msub(131)=1
6294  msub(132)=1
6295  msub(135)=1
6296  msub(136)=1
6297  IF(iptl.EQ.1) ckin(3)=ptmdir
6298 
6299 C...Set up for resolved * p.
6300  ELSEIF(mint(122).EQ.2) THEN
6301  mint(123)=1
6302  msub(11)=1
6303  msub(12)=1
6304  msub(13)=1
6305  msub(28)=1
6306  msub(53)=1
6307  msub(68)=1
6308  IF(iptl.EQ.1) msub(95)=1
6309  IF(msel.EQ.2) THEN
6310  msub(91)=1
6311  msub(92)=1
6312  msub(93)=1
6313  msub(94)=1
6314  ENDIF
6315  IF(iptl.EQ.1) ckin(3)=0d0
6316  ENDIF
6317 
6318 C...Set up for gamma* * gamma*; virtual photons = dir, res.
6319  ELSEIF(mint(121).EQ.4) THEN
6320 
6321 C...Set up for direct * direct gamma (switch off leptons).
6322  IF(mint(122).EQ.1) THEN
6323  mint(123)=0
6324  msub(137)=1
6325  msub(138)=1
6326  msub(139)=1
6327  msub(140)=1
6328  DO 130 ii=mdcy(22,2),mdcy(22,2)+mdcy(22,3)-1
6329  IF(iabs(kfdp(ii,1)).GE.10) mdme(ii,1)=min(0,mdme(ii,1))
6330  130 CONTINUE
6331  IF(iptl.EQ.1) ckin(3)=ptmdir
6332 
6333 C...Set up for direct * resolved and resolved * direct gamma.
6334  ELSEIF(mint(122).EQ.2.OR.mint(122).EQ.3) THEN
6335  mint(123)=5
6336  msub(131)=1
6337  msub(132)=1
6338  msub(135)=1
6339  msub(136)=1
6340  IF(iptl.EQ.1) ckin(3)=ptmdir
6341 
6342 C...Set up for resolved * resolved gamma.
6343  ELSEIF(mint(122).EQ.4) THEN
6344  mint(123)=2
6345  msub(11)=1
6346  msub(12)=1
6347  msub(13)=1
6348  msub(28)=1
6349  msub(53)=1
6350  msub(68)=1
6351  IF(iptl.EQ.1) msub(95)=1
6352  IF(msel.EQ.2) THEN
6353  msub(91)=1
6354  msub(92)=1
6355  msub(93)=1
6356  msub(94)=1
6357  ENDIF
6358  IF(iptl.EQ.1) ckin(3)=0d0
6359  ENDIF
6360 
6361 C...End of special set up for gamma-p and gamma-gamma.
6362  ENDIF
6363  ckin(1)=2d0*ckin(3)
6364  ENDIF
6365 
6366 C...Flavour information for individual beams.
6367  DO 140 i=1,2
6368  mint(40+i)=1
6369  IF(mint(123).GE.1.AND.mint(10+i).EQ.22) mint(40+i)=2
6370  IF(iabs(mint(10+i)).GT.100) mint(40+i)=2
6371  mint(44+i)=mint(40+i)
6372  IF(mstp(11).GE.1.AND.(iabs(mint(10+i)).EQ.11.OR.
6373  & iabs(mint(10+i)).EQ.13.OR.iabs(mint(10+i)).EQ.15)) mint(44+i)=3
6374  140 CONTINUE
6375 
6376 C...If two real gammas, whereof one direct, pick the first.
6377 C...For two virtual photons, keep requested order.
6378  IF(mint(11).EQ.22.AND.mint(12).EQ.22) THEN
6379  IF(mstp(14).LE.10.AND.mint(123).GE.4.AND.mint(123).LE.6) THEN
6380  mint(41)=1
6381  mint(45)=1
6382  ELSEIF(mstp(14).EQ.12.OR.mstp(14).EQ.13.OR.mstp(14).EQ.22.OR.
6383  & mstp(14).EQ.26.OR.mstp(14).EQ.27) THEN
6384  mint(41)=1
6385  mint(45)=1
6386  ELSEIF(mstp(14).EQ.14.OR.mstp(14).EQ.17.OR.mstp(14).EQ.23.OR.
6387  & mstp(14).EQ.28.OR.mstp(14).EQ.29) THEN
6388  mint(42)=1
6389  mint(46)=1
6390  ELSEIF((mstp(14).EQ.20.OR.mstp(14).EQ.30).AND.(mint(122).EQ.2
6391  & .OR.mint(122).EQ.3.OR.mint(122).EQ.10.OR.mint(122).EQ.11)) THEN
6392  mint(41)=1
6393  mint(45)=1
6394  ELSEIF((mstp(14).EQ.20.OR.mstp(14).EQ.30).AND.(mint(122).EQ.4
6395  & .OR.mint(122).EQ.7.OR.mint(122).EQ.12.OR.mint(122).EQ.13)) THEN
6396  mint(42)=1
6397  mint(46)=1
6398  ELSEIF(mstp(14).EQ.25.AND.mint(122).EQ.2) THEN
6399  mint(41)=1
6400  mint(45)=1
6401  ELSEIF(mstp(14).EQ.25.AND.mint(122).EQ.3) THEN
6402  mint(42)=1
6403  mint(46)=1
6404  ENDIF
6405  ELSEIF(mint(11).EQ.22.OR.mint(12).EQ.22) THEN
6406  IF(mstp(14).EQ.26.OR.mstp(14).EQ.28.OR.mint(122).EQ.4) THEN
6407  IF(mint(11).EQ.22) THEN
6408  mint(41)=1
6409  mint(45)=1
6410  ELSE
6411  mint(42)=1
6412  mint(46)=1
6413  ENDIF
6414  ENDIF
6415  IF(mint(123).GE.4.AND.mint(123).LE.7) CALL pyerrm(26,
6416  & '(PYINPR:) unallowed MSTP(14) code for single photon')
6417  ENDIF
6418 
6419 C...Flavour information on combination of incoming particles.
6420  mint(43)=2*mint(41)+mint(42)-2
6421  mint(44)=mint(43)
6422  IF(mint(123).LE.0) THEN
6423  IF(mint(11).EQ.22) mint(43)=mint(43)+2
6424  IF(mint(12).EQ.22) mint(43)=mint(43)+1
6425  ELSEIF(mint(123).LE.3) THEN
6426  IF(mint(11).EQ.22) mint(44)=mint(44)-2
6427  IF(mint(12).EQ.22) mint(44)=mint(44)-1
6428  ELSEIF(mint(11).EQ.22.AND.mint(12).EQ.22) THEN
6429  mint(43)=4
6430  mint(44)=1
6431  ENDIF
6432  mint(47)=2*min(2,mint(45))+min(2,mint(46))-2
6433  IF(min(mint(45),mint(46)).EQ.3) mint(47)=5
6434  IF(mint(45).EQ.1.AND.mint(46).EQ.3) mint(47)=6
6435  IF(mint(45).EQ.3.AND.mint(46).EQ.1) mint(47)=7
6436  mint(50)=0
6437  IF(mint(41).EQ.2.AND.mint(42).EQ.2.AND.mint(111).NE.12) mint(50)=1
6438  mint(107)=0
6439  mint(108)=0
6440  IF(mint(121).EQ.9.OR.mint(121).EQ.13) THEN
6441  IF((mint(122).GE.4.AND.mint(122).LE.6).OR.mint(122).EQ.12)
6442  & mint(107)=2
6443  IF((mint(122).GE.7.AND.mint(122).LE.9).OR.mint(122).EQ.13)
6444  & mint(107)=3
6445  IF(mint(122).EQ.10.OR.mint(122).EQ.11) mint(107)=4
6446  IF(mint(122).EQ.2.OR.mint(122).EQ.5.OR.mint(122).EQ.8.OR.
6447  & mint(122).EQ.10) mint(108)=2
6448  IF(mint(122).EQ.3.OR.mint(122).EQ.6.OR.mint(122).EQ.9.OR.
6449  & mint(122).EQ.11) mint(108)=3
6450  IF(mint(122).EQ.12.OR.mint(122).EQ.13) mint(108)=4
6451  ELSEIF(mint(121).EQ.4.AND.mstp(14).EQ.25) THEN
6452  IF(mint(122).GE.3) mint(107)=1
6453  IF(mint(122).EQ.2.OR.mint(122).EQ.4) mint(108)=1
6454  ELSEIF(mint(121).EQ.2) THEN
6455  IF(mint(122).EQ.2.AND.mint(11).EQ.22) mint(107)=1
6456  IF(mint(122).EQ.2.AND.mint(12).EQ.22) mint(108)=1
6457  ELSE
6458  IF(mint(11).EQ.22) THEN
6459  mint(107)=mint(123)
6460  IF(mint(123).GE.4) mint(107)=0
6461  IF(mint(123).EQ.7) mint(107)=2
6462  IF(mstp(14).EQ.26.OR.mstp(14).EQ.27) mint(107)=4
6463  IF(mstp(14).EQ.28) mint(107)=2
6464  IF(mstp(14).EQ.29) mint(107)=3
6465  IF(mstp(14).EQ.30.AND.mint(121).EQ.4.AND.mint(122).EQ.4)
6466  & mint(107)=4
6467  ENDIF
6468  IF(mint(12).EQ.22) THEN
6469  mint(108)=mint(123)
6470  IF(mint(123).GE.4) mint(108)=mint(123)-3
6471  IF(mint(123).EQ.7) mint(108)=3
6472  IF(mstp(14).EQ.26) mint(108)=2
6473  IF(mstp(14).EQ.27) mint(108)=3
6474  IF(mstp(14).EQ.28.OR.mstp(14).EQ.29) mint(108)=4
6475  IF(mstp(14).EQ.30.AND.mint(121).EQ.4.AND.mint(122).EQ.4)
6476  & mint(108)=4
6477  ENDIF
6478  IF(mint(11).EQ.22.AND.mint(12).EQ.22.AND.(mstp(14).EQ.14.OR.
6479  & mstp(14).EQ.17.OR.mstp(14).EQ.18.OR.mstp(14).EQ.23)) THEN
6480  minttp=mint(107)
6481  mint(107)=mint(108)
6482  mint(108)=minttp
6483  ENDIF
6484  ENDIF
6485  IF(mint(15).EQ.22.AND.mint(41).EQ.2) mint(15)=0
6486  IF(mint(16).EQ.22.AND.mint(42).EQ.2) mint(16)=0
6487 
6488 C...Select default processes according to incoming beams
6489 C...(already done for gamma-p and gamma-gamma with
6490 C...MSTP(14) = 10, 20, 25 or 30).
6491  IF(mint(121).GT.1) THEN
6492  ELSEIF(msel.EQ.1.OR.msel.EQ.2) THEN
6493 
6494  IF(mint(43).EQ.1) THEN
6495 C...Lepton + lepton -> gamma/Z0 or W.
6496  IF(mint(11)+mint(12).EQ.0) msub(1)=1
6497  IF(mint(11)+mint(12).NE.0) msub(2)=1
6498 
6499  ELSEIF(mint(43).LE.3.AND.mint(123).EQ.0.AND.
6500  & (mint(11).EQ.22.OR.mint(12).EQ.22)) THEN
6501 C...Unresolved photon + lepton: Compton scattering.
6502  msub(133)=1
6503  msub(134)=1
6504 
6505  ELSEIF((mint(123).EQ.8.OR.mint(123).EQ.9).AND.(mint(11).EQ.22
6506  & .OR.mint(12).EQ.22)) THEN
6507 C...DIS as pure gamma* + f -> f process.
6508  msub(99)=1
6509 
6510  ELSEIF(mint(43).LE.3) THEN
6511 C...Lepton + hadron: deep inelastic scattering.
6512  msub(10)=1
6513 
6514  ELSEIF(mint(123).EQ.0.AND.mint(11).EQ.22.AND.
6515  & mint(12).EQ.22) THEN
6516 C...Two unresolved photons: fermion pair production,
6517 C...exclude lepton pairs.
6518  DO 150 isub=137,140
6519  msub(isub)=1
6520  150 CONTINUE
6521  DO 160 ii=mdcy(22,2),mdcy(22,2)+mdcy(22,3)-1
6522  IF(iabs(kfdp(ii,1)).GE.10) mdme(ii,1)=min(0,mdme(ii,1))
6523  160 CONTINUE
6524  ptmdir=ptmrun
6525  IF(mstp(18).EQ.2) ptmdir=parp(15)
6526  IF(ckin(3).LT.ptmrun.OR.msel.EQ.2) ckin(3)=ptmdir
6527  ckin(1)=max(ckin(1),2d0*ckin(3))
6528 
6529  ELSEIF((mint(123).EQ.0.AND.(mint(11).EQ.22.OR.mint(12).EQ.22))
6530  & .OR.(mint(123).GE.4.AND.mint(123).LE.6.AND.mint(11).EQ.22.AND.
6531  & mint(12).EQ.22)) THEN
6532 C...Unresolved photon + hadron: photon-parton scattering.
6533  DO 170 isub=131,136
6534  msub(isub)=1
6535  170 CONTINUE
6536 
6537  ELSEIF(msel.EQ.1) THEN
6538 C...High-pT QCD processes:
6539  msub(11)=1
6540  msub(12)=1
6541  msub(13)=1
6542  msub(28)=1
6543  msub(53)=1
6544  msub(68)=1
6545  ptmn=ptmrun
6546  vint(154)=ptmn
6547  IF(ckin(3).LT.ptmn) msub(95)=1
6548  IF(msub(95).EQ.1.AND.mint(50).EQ.0) msub(95)=0
6549 
6550  ELSE
6551 C...All QCD processes:
6552  msub(11)=1
6553  msub(12)=1
6554  msub(13)=1
6555  msub(28)=1
6556  msub(53)=1
6557  msub(68)=1
6558  msub(91)=1
6559  msub(92)=1
6560  msub(93)=1
6561  msub(94)=1
6562  msub(95)=1
6563  ENDIF
6564 
6565  ELSEIF(msel.GE.4.AND.msel.LE.8) THEN
6566 C...Heavy quark production.
6567  msub(81)=1
6568  msub(82)=1
6569  msub(84)=1
6570  DO 180 j=1,min(8,mdcy(21,3))
6571  mdme(mdcy(21,2)+j-1,1)=0
6572  180 CONTINUE
6573  mdme(mdcy(21,2)+msel-1,1)=1
6574  msub(85)=1
6575  DO 190 j=1,min(12,mdcy(22,3))
6576  mdme(mdcy(22,2)+j-1,1)=0
6577  190 CONTINUE
6578  mdme(mdcy(22,2)+msel-1,1)=1
6579 
6580  ELSEIF(msel.EQ.10) THEN
6581 C...Prompt photon production:
6582  msub(14)=1
6583  msub(18)=1
6584  msub(29)=1
6585 
6586  ELSEIF(msel.EQ.11) THEN
6587 C...Z0/gamma* production:
6588  msub(1)=1
6589 
6590  ELSEIF(msel.EQ.12) THEN
6591 C...W+/- production:
6592  msub(2)=1
6593 
6594  ELSEIF(msel.EQ.13) THEN
6595 C...Z0 + jet:
6596  msub(15)=1
6597  msub(30)=1
6598 
6599  ELSEIF(msel.EQ.14) THEN
6600 C...W+/- + jet:
6601  msub(16)=1
6602  msub(31)=1
6603 
6604  ELSEIF(msel.EQ.15) THEN
6605 C...Z0 & W+/- pair production:
6606  msub(19)=1
6607  msub(20)=1
6608  msub(22)=1
6609  msub(23)=1
6610  msub(25)=1
6611 
6612  ELSEIF(msel.EQ.16) THEN
6613 C...h0 production:
6614  msub(3)=1
6615  msub(102)=1
6616  msub(103)=1
6617  msub(123)=1
6618  msub(124)=1
6619 
6620  ELSEIF(msel.EQ.17) THEN
6621 C...h0 & Z0 or W+/- pair production:
6622  msub(24)=1
6623  msub(26)=1
6624 
6625  ELSEIF(msel.EQ.18) THEN
6626 C...h0 production; interesting processes in e+e-.
6627  msub(24)=1
6628  msub(103)=1
6629  msub(123)=1
6630  msub(124)=1
6631 
6632  ELSEIF(msel.EQ.19) THEN
6633 C...h0, H0 and A0 production; interesting processes in e+e-.
6634  msub(24)=1
6635  msub(103)=1
6636  msub(123)=1
6637  msub(124)=1
6638  msub(153)=1
6639  msub(171)=1
6640  msub(173)=1
6641  msub(174)=1
6642  msub(158)=1
6643  msub(176)=1
6644  msub(178)=1
6645  msub(179)=1
6646 
6647  ELSEIF(msel.EQ.21) THEN
6648 C...Z'0 production:
6649  msub(141)=1
6650 
6651  ELSEIF(msel.EQ.22) THEN
6652 C...W'+/- production:
6653  msub(142)=1
6654 
6655  ELSEIF(msel.EQ.23) THEN
6656 C...H+/- production:
6657  msub(143)=1
6658 
6659  ELSEIF(msel.EQ.24) THEN
6660 C...R production:
6661  msub(144)=1
6662 
6663  ELSEIF(msel.EQ.25) THEN
6664 C...LQ (leptoquark) production.
6665  msub(145)=1
6666  msub(162)=1
6667  msub(163)=1
6668  msub(164)=1
6669 
6670  ELSEIF(msel.GE.35.AND.msel.LE.38) THEN
6671 C...Production of one heavy quark (W exchange):
6672  msub(83)=1
6673  DO 200 j=1,min(8,mdcy(21,3))
6674  mdme(mdcy(21,2)+j-1,1)=0
6675  200 CONTINUE
6676  mdme(mdcy(21,2)+msel-31,1)=1
6677 
6678 CMRENNA++Define SUSY alternatives.
6679  ELSEIF(msel.EQ.39) THEN
6680 C...Turn on all SUSY processes.
6681  IF(mint(43).EQ.4) THEN
6682 C...Hadron-hadron processes.
6683  DO 210 i=201,296
6684  IF(iset(i).GE.0) msub(i)=1
6685  210 CONTINUE
6686  ELSEIF(mint(43).EQ.1) THEN
6687 C...Lepton-lepton processes: QED production of squarks.
6688  DO 220 i=201,214
6689  msub(i)=1
6690  220 CONTINUE
6691  msub(210)=0
6692  msub(211)=0
6693  msub(212)=0
6694  DO 230 i=216,228
6695  msub(i)=1
6696  230 CONTINUE
6697  DO 240 i=261,263
6698  msub(i)=1
6699  240 CONTINUE
6700  msub(277)=1
6701  msub(278)=1
6702  ENDIF
6703 
6704  ELSEIF(msel.EQ.40) THEN
6705 C...Gluinos and squarks.
6706  IF(mint(43).EQ.4) THEN
6707  msub(243)=1
6708  msub(244)=1
6709  msub(258)=1
6710  msub(259)=1
6711  msub(261)=1
6712  msub(262)=1
6713  msub(264)=1
6714  msub(265)=1
6715  DO 250 i=271,296
6716  msub(i)=1
6717  250 CONTINUE
6718  ELSEIF(mint(43).EQ.1) THEN
6719  msub(277)=1
6720  msub(278)=1
6721  ENDIF
6722 
6723  ELSEIF(msel.EQ.41) THEN
6724 C...Stop production.
6725  msub(261)=1
6726  msub(262)=1
6727  msub(263)=1
6728  IF(mint(43).EQ.4) THEN
6729  msub(264)=1
6730  msub(265)=1
6731  ENDIF
6732 
6733  ELSEIF(msel.EQ.42) THEN
6734 C...Slepton production.
6735  DO 260 i=201,214
6736  msub(i)=1
6737  260 CONTINUE
6738  IF(mint(43).NE.4) THEN
6739  msub(210)=0
6740  msub(211)=0
6741  msub(212)=0
6742  ENDIF
6743 
6744  ELSEIF(msel.EQ.43) THEN
6745 C...Neutralino/Chargino + Gluino/Squark.
6746  IF(mint(43).EQ.4) THEN
6747  DO 270 i=237,242
6748  msub(i)=1
6749  270 CONTINUE
6750  DO 280 i=246,254
6751  msub(i)=1
6752  280 CONTINUE
6753  msub(256)=1
6754  ENDIF
6755 
6756  ELSEIF(msel.EQ.44) THEN
6757 C...Neutralino/Chargino pair production.
6758  IF(mint(43).EQ.4) THEN
6759  DO 290 i=216,236
6760  msub(i)=1
6761  290 CONTINUE
6762  ELSEIF(mint(43).EQ.1) THEN
6763  DO 300 i=216,228
6764  msub(i)=1
6765  300 CONTINUE
6766  ENDIF
6767 
6768  ELSEIF(msel.EQ.45) THEN
6769 C...Sbottom production.
6770  msub(287)=1
6771  msub(288)=1
6772  IF(mint(43).EQ.4) THEN
6773  DO 310 i=281,296
6774  msub(i)=1
6775  310 CONTINUE
6776  ENDIF
6777 
6778  ELSEIF(msel.EQ.50) THEN
6779 C...Pair production of technipions and gauge bosons.
6780  DO 320 i=361,368
6781  msub(i)=1
6782  320 CONTINUE
6783  IF(mint(43).EQ.4) THEN
6784  DO 330 i=370,377
6785  msub(i)=1
6786  330 CONTINUE
6787  ENDIF
6788 
6789  ELSEIF(msel.EQ.51) THEN
6790 C...QCD 2 -> 2 processes with compositeness/technicolor modifications.
6791  DO 340 i=381,386
6792  msub(i)=1
6793  340 CONTINUE
6794 
6795  ELSEIF(msel.EQ.61) THEN
6796 C...Charmonium production in colour octet model, with recoiling parton.
6797  DO 342 i=421,439
6798  msub(i)=1
6799  342 CONTINUE
6800 
6801  ELSEIF(msel.EQ.62) THEN
6802 C...Bottomonium production in colour octet model, with recoiling parton.
6803  DO 344 i=461,479
6804  msub(i)=1
6805  344 CONTINUE
6806 
6807  ELSEIF(msel.EQ.63) THEN
6808 C...Charmonium and bottomonium production in colour octet model.
6809  DO 346 i=421,439
6810  msub(i)=1
6811  msub(i+40)=1
6812  346 CONTINUE
6813  ENDIF
6814 
6815 C...Find heaviest new quark flavour allowed in processes 81-84.
6816  kflqm=1
6817  DO 350 i=1,min(8,mdcy(21,3))
6818  idc=i+mdcy(21,2)-1
6819  IF(mdme(idc,1).LE.0) goto 350
6820  kflqm=i
6821  350 CONTINUE
6822  IF(mstp(7).GE.1.AND.mstp(7).LE.8.AND.(msel.LE.3.OR.msel.GE.9))
6823  &kflqm=mstp(7)
6824  mint(55)=kflqm
6825  kfpr(81,1)=kflqm
6826  kfpr(81,2)=kflqm
6827  kfpr(82,1)=kflqm
6828  kfpr(82,2)=kflqm
6829  kfpr(83,1)=kflqm
6830  kfpr(84,1)=kflqm
6831  kfpr(84,2)=kflqm
6832 
6833 C...Find heaviest new fermion flavour allowed in process 85.
6834  kflfm=1
6835  DO 360 i=1,min(12,mdcy(22,3))
6836  idc=i+mdcy(22,2)-1
6837  IF(mdme(idc,1).LE.0) goto 360
6838  kflfm=kfdp(idc,1)
6839  360 CONTINUE
6840  IF(((mstp(7).GE.1.AND.mstp(7).LE.8).OR.(mstp(7).GE.11.AND.
6841  &mstp(7).LE.18)).AND.(msel.LE.3.OR.msel.GE.9)) kflfm=mstp(7)
6842  mint(56)=kflfm
6843  kfpr(85,1)=kflfm
6844  kfpr(85,2)=kflfm
6845 
6846 C...Initialize Generic Processes
6847  kfgen=9900001
6848  kcgen=pycomp(kfgen)
6849  IF(kcgen.GT.0) THEN
6850  idcy=mdcy(kcgen,2)
6851  IF(idcy.GT.0) THEN
6852  kff1=kfdp(idcy+1,1)
6853  kff2=kfdp(idcy+1,2)
6854  kcf1=pycomp(kff1)
6855  kcf2=pycomp(kff2)
6856  jcol1=iabs(kchg(kcf1,2))
6857  IF(jcol1.EQ.1) THEN
6858  kf1=kff1
6859  kf2=kff2
6860  ELSE
6861  kf1=kff2
6862  kf2=kff1
6863  ENDIF
6864  kfpr(481,1)=kf1
6865  kfpr(481,2)=kf2
6866  kfpr(482,1)=kf1
6867  kfpr(482,2)=kf2
6868  ENDIF
6869  IF(kfdp(idcy,1).EQ.21.OR.kfdp(idcy,2).EQ.21) THEN
6870  kfin(1,0)=1
6871  kfin(2,0)=1
6872  ENDIF
6873  ENDIF
6874 
6875 C...Import relevant information on external user processes.
6876  IF(mint(111).GE.11) THEN
6877  ipypr=0
6878  DO 390 iup=1,nprup
6879 C...Find next empty PYTHIA process number slot and enable it.
6880  370 ipypr=ipypr+1
6881  IF(ipypr.GT.500) CALL pyerrm(26,
6882  & '(PYINPR.) no more empty slots for user processes')
6883  IF(iset(ipypr).GE.0.AND.iset(ipypr).LE.9) goto 370
6884  IF(ipypr.GE.91.AND.ipypr.LE.100) goto 370
6885  iset(ipypr)=11
6886 C...Overwrite KFPR with references back to process number and ID.
6887  kfpr(ipypr,1)=iup
6888  kfpr(ipypr,2)=lprup(iup)
6889 C...Process title.
6890  WRITE(chipr,'(I10)') lprup(iup)
6891  ichin=1
6892  DO 380 ich=1,9
6893  IF(chipr(ich:ich).EQ.' ') ichin=ich+1
6894  380 CONTINUE
6895  proc(ipypr)='User process '//chipr(ichin:10)//' '
6896 C...Switch on process.
6897  msub(ipypr)=1
6898  390 CONTINUE
6899  ENDIF
6900 
6901  RETURN
6902  END
6903 
6904 C*********************************************************************
6905 
6906 C...PYXTOT
6907 C...Parametrizes total, elastic and diffractive cross-sections
6908 C...for different energies and beams. Donnachie-Landshoff for
6909 C...total and Schuler-Sjostrand for elastic and diffractive.
6910 C...Process code IPROC:
6911 C...= 1 : p + p;
6912 C...= 2 : pbar + p;
6913 C...= 3 : pi+ + p;
6914 C...= 4 : pi- + p;
6915 C...= 5 : pi0 + p;
6916 C...= 6 : phi + p;
6917 C...= 7 : J/psi + p;
6918 C...= 11 : rho + rho;
6919 C...= 12 : rho + phi;
6920 C...= 13 : rho + J/psi;
6921 C...= 14 : phi + phi;
6922 C...= 15 : phi + J/psi;
6923 C...= 16 : J/psi + J/psi;
6924 C...= 21 : gamma + p (DL);
6925 C...= 22 : gamma + p (VDM).
6926 C...= 23 : gamma + pi (DL);
6927 C...= 24 : gamma + pi (VDM);
6928 C...= 25 : gamma + gamma (DL);
6929 C...= 26 : gamma + gamma (VDM).
6930 
6931  SUBROUTINE pyxtot
6932 
6933 C...Double precision and integer declarations.
6934  IMPLICIT DOUBLE PRECISION(a-h, o-z)
6935  IMPLICIT INTEGER(i-n)
6936  INTEGER pyk,pychge,pycomp
6937 C...Commonblocks.
6938  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
6939  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
6940  common/pypars/mstp(200),parp(200),msti(200),pari(200)
6941  common/pyint1/mint(400),vint(400)
6942  common/pyint5/ngenpd,ngen(0:500,3),xsec(0:500,3)
6943  common/pyint7/sigt(0:6,0:6,0:5)
6944  SAVE /pydat1/,/pydat2/,/pypars/,/pyint1/,/pyint5/,/pyint7/
6945 C...Local arrays.
6946  dimension nproc(30),xpar(30),ypar(30),ihada(20),ihadb(20),
6947  &pmhad(4),bhad(4),betp(4),ifitsd(20),ifitdd(20),ceffs(10,8),
6948  &ceffd(10,9),sigtmp(6,0:5)
6949 
6950 C...Common constants.
6951  DATA eps/0.0808d0/, eta/-0.4525d0/, alp/0.25d0/, cres/2d0/,
6952  &pmrc/1.062d0/, smp/0.880d0/, facel/0.0511d0/, facsd/0.0336d0/,
6953  &facdd/0.0084d0/
6954 
6955 C...Number of multiple processes to be evaluated (= 0 : undefined).
6956  DATA nproc/7*1,3*0,6*1,4*0,4*3,2*6,4*0/
6957 C...X and Y parameters of sigmatot = X * s**epsilon + Y * s**(-eta).
6958  DATA xpar/2*21.70d0,3*13.63d0,10.01d0,0.970d0,3*0d0,
6959  &8.56d0,6.29d0,0.609d0,4.62d0,0.447d0,0.0434d0,4*0d0,
6960  &0.0677d0,0.0534d0,0.0425d0,0.0335d0,2.11d-4,1.31d-4,4*0d0/
6961  DATA ypar/
6962  &56.08d0,98.39d0,27.56d0,36.02d0,31.79d0,-1.51d0,-0.146d0,3*0d0,
6963  &13.08d0,-0.62d0,-0.060d0,0.030d0,-0.0028d0,0.00028d0,4*0d0,
6964  &0.129d0,0.115d0,0.081d0,0.072d0,2.15d-4,1.70d-4,4*0d0/
6965 
6966 C...Beam and target hadron class:
6967 C...= 1 : p/n ; = 2 : pi/rho/omega; = 3 : phi; = 4 : J/psi.
6968  DATA ihada/2*1,3*2,3,4,3*0,3*2,2*3,4,4*0/
6969  DATA ihadb/7*1,3*0,2,3,4,3,2*4,4*0/
6970 C...Characteristic class masses, slope parameters, beta = sqrt(X).
6971  DATA pmhad/0.938d0,0.770d0,1.020d0,3.097d0/
6972  DATA bhad/2.3d0,1.4d0,1.4d0,0.23d0/
6973  DATA betp/4.658d0,2.926d0,2.149d0,0.208d0/
6974 
6975 C...Fitting constants used in parametrizations of diffractive results.
6976  DATA ifitsd/2*1,3*2,3,4,3*0,5,6,7,8,9,10,4*0/
6977  DATA ifitdd/2*1,3*2,3,4,3*0,5,6,7,8,9,10,4*0/
6978  DATA ((ceffs(j1,j2),j2=1,8),j1=1,10)/
6979  &0.213d0, 0.0d0, -0.47d0, 150d0, 0.213d0, 0.0d0, -0.47d0, 150d0,
6980  &0.213d0, 0.0d0, -0.47d0, 150d0, 0.267d0, 0.0d0, -0.47d0, 100d0,
6981  &0.213d0, 0.0d0, -0.47d0, 150d0, 0.232d0, 0.0d0, -0.47d0, 110d0,
6982  &0.213d0, 7.0d0, -0.55d0, 800d0, 0.115d0, 0.0d0, -0.47d0, 110d0,
6983  &0.267d0, 0.0d0, -0.46d0, 75d0, 0.267d0, 0.0d0, -0.46d0, 75d0,
6984  &0.232d0, 0.0d0, -0.46d0, 85d0, 0.267d0, 0.0d0, -0.48d0, 100d0,
6985  &0.115d0, 0.0d0, -0.50d0, 90d0, 0.267d0, 6.0d0, -0.56d0, 420d0,
6986  &0.232d0, 0.0d0, -0.48d0, 110d0, 0.232d0, 0.0d0, -0.48d0, 110d0,
6987  &0.115d0, 0.0d0, -0.52d0, 120d0, 0.232d0, 6.0d0, -0.56d0, 470d0,
6988  &0.115d0, 5.5d0, -0.58d0, 570d0, 0.115d0, 5.5d0, -0.58d0, 570d0/
6989  DATA ((ceffd(j1,j2),j2=1,9),j1=1,10)/
6990  &3.11d0, -7.34d0, 9.71d0, 0.068d0, -0.42d0, 1.31d0,
6991  &-1.37d0, 35.0d0, 118d0, 3.11d0, -7.10d0, 10.6d0,
6992  &0.073d0, -0.41d0, 1.17d0, -1.41d0, 31.6d0, 95d0,
6993  &3.12d0, -7.43d0, 9.21d0, 0.067d0, -0.44d0, 1.41d0,
6994  &-1.35d0, 36.5d0, 132d0, 3.13d0, -8.18d0, -4.20d0,
6995  &0.056d0, -0.71d0, 3.12d0, -1.12d0, 55.2d0, 1298d0,
6996  &3.11d0, -6.90d0, 11.4d0, 0.078d0, -0.40d0, 1.05d0,
6997  &-1.40d0, 28.4d0, 78d0, 3.11d0, -7.13d0, 10.0d0,
6998  &0.071d0, -0.41d0, 1.23d0, -1.34d0, 33.1d0, 105d0,
6999  &3.12d0, -7.90d0, -1.49d0, 0.054d0, -0.64d0, 2.72d0,
7000  &-1.13d0, 53.1d0, 995d0, 3.11d0, -7.39d0, 8.22d0,
7001  &0.065d0, -0.44d0, 1.45d0, -1.36d0, 38.1d0, 148d0,
7002  &3.18d0, -8.95d0, -3.37d0, 0.057d0, -0.76d0, 3.32d0,
7003  &-1.12d0, 55.6d0, 1472d0, 4.18d0, -29.2d0, 56.2d0,
7004  &0.074d0, -1.36d0, 6.67d0, -1.14d0, 116.2d0, 6532d0/
7005 
7006 C...Parameters. Combinations of the energy.
7007  aem=paru(101)
7008  pmth=parp(102)
7009  s=vint(2)
7010  srt=vint(1)
7011  seps=s**eps
7012  seta=s**eta
7013  slog=log(s)
7014 
7015 C...Ratio of gamma/pi (for rescaling in parton distributions).
7016  vint(281)=(xpar(22)*seps+ypar(22)*seta)/
7017  &(xpar(5)*seps+ypar(5)*seta)
7018  vint(317)=1d0
7019  IF(mint(50).NE.1) RETURN
7020 
7021 C...Order flavours of incoming particles: KF1 < KF2.
7022  IF(iabs(mint(11)).LE.iabs(mint(12))) THEN
7023  kf1=iabs(mint(11))
7024  kf2=iabs(mint(12))
7025  iord=1
7026  ELSE
7027  kf1=iabs(mint(12))
7028  kf2=iabs(mint(11))
7029  iord=2
7030  ENDIF
7031  isgn12=isign(1,mint(11)*mint(12))
7032 
7033 C...Find process number (for lookup tables).
7034  IF(kf1.GT.1000) THEN
7035  iproc=1
7036  IF(isgn12.LT.0) iproc=2
7037  ELSEIF(kf1.GT.100.AND.kf2.GT.1000) THEN
7038  iproc=3
7039  IF(isgn12.LT.0) iproc=4
7040  IF(kf1.EQ.111) iproc=5
7041  ELSEIF(kf1.GT.100) THEN
7042  iproc=11
7043  ELSEIF(kf2.GT.1000) THEN
7044  iproc=21
7045  IF(mint(123).EQ.2.OR.mint(123).EQ.3) iproc=22
7046  ELSEIF(kf2.GT.100) THEN
7047  iproc=23
7048  IF(mint(123).EQ.2.OR.mint(123).EQ.3) iproc=24
7049  ELSE
7050  iproc=25
7051  IF(mint(123).EQ.2.OR.mint(123).EQ.3.OR.mint(123).EQ.7) iproc=26
7052  ENDIF
7053 
7054 C... Number of multiple processes to be stored; beam/target side.
7055  npr=nproc(iproc)
7056  mint(101)=1
7057  mint(102)=1
7058  IF(npr.EQ.3) THEN
7059  mint(100+iord)=4
7060  ELSEIF(npr.EQ.6) THEN
7061  mint(101)=4
7062  mint(102)=4
7063  ENDIF
7064  n1=0
7065  IF(mint(101).EQ.4) n1=4
7066  n2=0
7067  IF(mint(102).EQ.4) n2=4
7068 
7069 C...Do not do any more for user-set or undefined cross-sections.
7070  IF(mstp(31).LE.0) RETURN
7071  IF(npr.EQ.0) CALL pyerrm(26,
7072  &'(PYXTOT:) cross section for this process not yet implemented')
7073 
7074 C...Parameters. Combinations of the energy.
7075  aem=paru(101)
7076  pmth=parp(102)
7077  s=vint(2)
7078  srt=vint(1)
7079  seps=s**eps
7080  seta=s**eta
7081  slog=log(s)
7082 
7083 C...Loop over multiple processes (for VDM).
7084  DO 110 i=1,npr
7085  IF(npr.EQ.1) THEN
7086  ipr=iproc
7087  ELSEIF(npr.EQ.3) THEN
7088  ipr=i+4
7089  IF(kf2.LT.1000) ipr=i+10
7090  ELSEIF(npr.EQ.6) THEN
7091  ipr=i+10
7092  ENDIF
7093 
7094 C...Evaluate hadron species, mass, slope contribution and fit number.
7095  iha=ihada(ipr)
7096  ihb=ihadb(ipr)
7097  pma=pmhad(iha)
7098  pmb=pmhad(ihb)
7099  bha=bhad(iha)
7100  bhb=bhad(ihb)
7101  isd=ifitsd(ipr)
7102  idd=ifitdd(ipr)
7103 
7104 C...Skip if energy too low relative to masses.
7105  DO 100 j=0,5
7106  sigtmp(i,j)=0d0
7107  100 CONTINUE
7108  IF(srt.LT.pma+pmb+parp(104)) goto 110
7109 
7110 C...Total cross-section. Elastic slope parameter and cross-section.
7111  sigtmp(i,0)=xpar(ipr)*seps+ypar(ipr)*seta
7112  bel=2d0*bha+2d0*bhb+4d0*seps-4.2d0
7113  sigtmp(i,1)=facel*sigtmp(i,0)**2/bel
7114 
7115 C...Diffractive scattering A + B -> X + B.
7116  bsd=2d0*bhb
7117  sqml=(pma+pmth)**2
7118  sqmu=s*ceffs(isd,1)+ceffs(isd,2)
7119  sum1=log((bsd+2d0*alp*log(s/sqml))/
7120  & (bsd+2d0*alp*log(s/sqmu)))/(2d0*alp)
7121  bxb=ceffs(isd,3)+ceffs(isd,4)/s
7122  sum2=cres*log(1d0+((pma+pmrc)/(pma+pmth))**2)/
7123  & (bsd+2d0*alp*log(s/((pma+pmth)*(pma+pmrc)))+bxb)
7124  sigtmp(i,2)=facsd*xpar(ipr)*betp(ihb)*max(0d0,sum1+sum2)
7125 
7126 C...Diffractive scattering A + B -> A + X.
7127  bsd=2d0*bha
7128  sqml=(pmb+pmth)**2
7129  sqmu=s*ceffs(isd,5)+ceffs(isd,6)
7130  sum1=log((bsd+2d0*alp*log(s/sqml))/
7131  & (bsd+2d0*alp*log(s/sqmu)))/(2d0*alp)
7132  bax=ceffs(isd,7)+ceffs(isd,8)/s
7133  sum2=cres*log(1d0+((pmb+pmrc)/(pmb+pmth))**2)/
7134  & (bsd+2d0*alp*log(s/((pmb+pmth)*(pmb+pmrc)))+bax)
7135  sigtmp(i,3)=facsd*xpar(ipr)*betp(iha)*max(0d0,sum1+sum2)
7136 
7137 C...Order single diffractive correctly.
7138  IF(iord.EQ.2) THEN
7139  sigsav=sigtmp(i,2)
7140  sigtmp(i,2)=sigtmp(i,3)
7141  sigtmp(i,3)=sigsav
7142  ENDIF
7143 
7144 C...Double diffractive scattering A + B -> X1 + X2.
7145  yeff=log(s*smp/((pma+pmth)*(pmb+pmth))**2)
7146  deff=ceffd(idd,1)+ceffd(idd,2)/slog+ceffd(idd,3)/slog**2
7147  sum1=(deff+yeff*(log(max(1d-10,yeff/deff))-1d0))/(2d0*alp)
7148  IF(yeff.LE.0) sum1=0d0
7149  sqmu=s*(ceffd(idd,4)+ceffd(idd,5)/slog+ceffd(idd,6)/slog**2)
7150  slup=log(max(1.1d0,s/(alp*(pma+pmth)**2*(pmb+pmth)*(pmb+pmrc))))
7151  sldn=log(max(1.1d0,s/(alp*sqmu*(pmb+pmth)*(pmb+pmrc))))
7152  sum2=cres*log(1d0+((pmb+pmrc)/(pmb+pmth))**2)*log(slup/sldn)/
7153  & (2d0*alp)
7154  slup=log(max(1.1d0,s/(alp*(pmb+pmth)**2*(pma+pmth)*(pma+pmrc))))
7155  sldn=log(max(1.1d0,s/(alp*sqmu*(pma+pmth)*(pma+pmrc))))
7156  sum3=cres*log(1d0+((pma+pmrc)/(pma+pmth))**2)*log(slup/sldn)/
7157  & (2d0*alp)
7158  bxx=ceffd(idd,7)+ceffd(idd,8)/srt+ceffd(idd,9)/s
7159  slrr=log(s/(alp*(pma+pmth)*(pma+pmrc)*(pmb+pmth)*(pmb+pmrc)))
7160  sum4=cres**2*log(1d0+((pma+pmrc)/(pma+pmth))**2)*
7161  & log(1d0+((pmb+pmrc)/(pmb+pmth))**2)/max(0.1d0,2d0*alp*slrr+bxx)
7162  sigtmp(i,4)=facdd*xpar(ipr)*max(0d0,sum1+sum2+sum3+sum4)
7163 
7164 C...Non-diffractive by unitarity.
7165  sigtmp(i,5)=sigtmp(i,0)-sigtmp(i,1)-sigtmp(i,2)-sigtmp(i,3)-
7166  & sigtmp(i,4)
7167  110 CONTINUE
7168 
7169 C...Put temporary results in output array: only one process.
7170  IF(mint(101).EQ.1.AND.mint(102).EQ.1) THEN
7171  DO 120 j=0,5
7172  sigt(0,0,j)=sigtmp(1,j)
7173  120 CONTINUE
7174 
7175 C...Beam multiple processes.
7176  ELSEIF(mint(101).EQ.4.AND.mint(102).EQ.1) THEN
7177  IF(mint(107).EQ.2) THEN
7178  vint(317)=(pmhad(2)**2/(pmhad(2)**2+vint(307)))**2
7179  ELSE
7180  vint(317)=16d0*parp(15)**2*vint(154)**2/
7181  & ((4d0*parp(15)**2+vint(307))*(4d0*vint(154)**2+vint(307)))
7182  ENDIF
7183  IF(mstp(20).GT.0) THEN
7184  vint(317)=vint(317)*(vint(2)/(vint(2)+vint(307)))**mstp(20)
7185  ENDIF
7186  DO 140 i=1,4
7187  IF(mint(107).EQ.2) THEN
7188  conv=(aem/parp(160+i))*vint(317)
7189  ELSEIF(vint(154).GT.parp(15)) THEN
7190  conv=(aem/paru(1))*(kchg(i,1)/3d0)**2*parp(18)**2*
7191  & (1d0/parp(15)**2-1d0/vint(154)**2)*vint(317)
7192  ELSE
7193  conv=0d0
7194  ENDIF
7195  i1=max(1,i-1)
7196  DO 130 j=0,5
7197  sigt(i,0,j)=conv*sigtmp(i1,j)
7198  130 CONTINUE
7199  140 CONTINUE
7200  DO 150 j=0,5
7201  sigt(0,0,j)=sigt(1,0,j)+sigt(2,0,j)+sigt(3,0,j)+sigt(4,0,j)
7202  150 CONTINUE
7203 
7204 C...Target multiple processes.
7205  ELSEIF(mint(101).EQ.1.AND.mint(102).EQ.4) THEN
7206  IF(mint(108).EQ.2) THEN
7207  vint(317)=(pmhad(2)**2/(pmhad(2)**2+vint(308)))**2
7208  ELSE
7209  vint(317)=16d0*parp(15)**2*vint(154)**2/
7210  & ((4d0*parp(15)**2+vint(308))*(4d0*vint(154)**2+vint(308)))
7211  ENDIF
7212  IF(mstp(20).GT.0) THEN
7213  vint(317)=vint(317)*(vint(2)/(vint(2)+vint(308)))**mstp(20)
7214  ENDIF
7215  DO 170 i=1,4
7216  IF(mint(108).EQ.2) THEN
7217  conv=(aem/parp(160+i))*vint(317)
7218  ELSEIF(vint(154).GT.parp(15)) THEN
7219  conv=(aem/paru(1))*(kchg(i,1)/3d0)**2*parp(18)**2*
7220  & (1d0/parp(15)**2-1d0/vint(154)**2)*vint(317)
7221  ELSE
7222  conv=0d0
7223  ENDIF
7224  iv=max(1,i-1)
7225  DO 160 j=0,5
7226  sigt(0,i,j)=conv*sigtmp(iv,j)
7227  160 CONTINUE
7228  170 CONTINUE
7229  DO 180 j=0,5
7230  sigt(0,0,j)=sigt(0,1,j)+sigt(0,2,j)+sigt(0,3,j)+sigt(0,4,j)
7231  180 CONTINUE
7232 
7233 C...Both beam and target multiple processes.
7234  ELSE
7235  IF(mint(107).EQ.2) THEN
7236  vint(317)=(pmhad(2)**2/(pmhad(2)**2+vint(307)))**2
7237  ELSE
7238  vint(317)=16d0*parp(15)**2*vint(154)**2/
7239  & ((4d0*parp(15)**2+vint(307))*(4d0*vint(154)**2+vint(307)))
7240  ENDIF
7241  IF(mint(108).EQ.2) THEN
7242  vint(317)=vint(317)*(pmhad(2)**2/(pmhad(2)**2+vint(308)))**2
7243  ELSE
7244  vint(317)=vint(317)*16d0*parp(15)**2*vint(154)**2/
7245  & ((4d0*parp(15)**2+vint(308))*(4d0*vint(154)**2+vint(308)))
7246  ENDIF
7247  IF(mstp(20).GT.0) THEN
7248  vint(317)=vint(317)*(vint(2)/(vint(2)+vint(307)+
7249  & vint(308)))**mstp(20)
7250  ENDIF
7251  DO 210 i1=1,4
7252  DO 200 i2=1,4
7253  IF(mint(107).EQ.2) THEN
7254  conv=(aem/parp(160+i1))*vint(317)
7255  ELSEIF(vint(154).GT.parp(15)) THEN
7256  conv=(aem/paru(1))*(kchg(i1,1)/3d0)**2*parp(18)**2*
7257  & (1d0/parp(15)**2-1d0/vint(154)**2)*vint(317)
7258  ELSE
7259  conv=0d0
7260  ENDIF
7261  IF(mint(108).EQ.2) THEN
7262  conv=conv*(aem/parp(160+i2))
7263  ELSEIF(vint(154).GT.parp(15)) THEN
7264  conv=conv*(aem/paru(1))*(kchg(i2,1)/3d0)**2*parp(18)**2*
7265  & (1d0/parp(15)**2-1d0/vint(154)**2)
7266  ELSE
7267  conv=0d0
7268  ENDIF
7269  IF(i1.LE.2) THEN
7270  iv=max(1,i2-1)
7271  ELSEIF(i2.LE.2) THEN
7272  iv=max(1,i1-1)
7273  ELSEIF(i1.EQ.i2) THEN
7274  iv=2*i1-2
7275  ELSE
7276  iv=5
7277  ENDIF
7278  DO 190 j=0,5
7279  jv=j
7280  IF(i2.GT.i1.AND.(j.EQ.2.OR.j.EQ.3)) jv=5-j
7281  sigt(i1,i2,j)=conv*sigtmp(iv,jv)
7282  190 CONTINUE
7283  200 CONTINUE
7284  210 CONTINUE
7285  DO 230 j=0,5
7286  DO 220 i=1,4
7287  sigt(i,0,j)=sigt(i,1,j)+sigt(i,2,j)+sigt(i,3,j)+sigt(i,4,j)
7288  sigt(0,i,j)=sigt(1,i,j)+sigt(2,i,j)+sigt(3,i,j)+sigt(4,i,j)
7289  220 CONTINUE
7290  sigt(0,0,j)=sigt(1,0,j)+sigt(2,0,j)+sigt(3,0,j)+sigt(4,0,j)
7291  230 CONTINUE
7292  ENDIF
7293 
7294 C...Scale up uniformly for Donnachie-Landshoff parametrization.
7295  IF(iproc.EQ.21.OR.iproc.EQ.23.OR.iproc.EQ.25) THEN
7296  rfac=(xpar(iproc)*seps+ypar(iproc)*seta)/sigt(0,0,0)
7297  DO 260 i1=0,n1
7298  DO 250 i2=0,n2
7299  DO 240 j=0,5
7300  sigt(i1,i2,j)=rfac*sigt(i1,i2,j)
7301  240 CONTINUE
7302  250 CONTINUE
7303  260 CONTINUE
7304  ENDIF
7305 
7306  RETURN
7307  END
7308 
7309 C*********************************************************************
7310 
7311 C...PYMAXI
7312 C...Finds optimal set of coefficients for kinematical variable selection
7313 C...and the maximum of the part of the differential cross-section used
7314 C...in the event weighting.
7315 
7316  SUBROUTINE pymaxi
7317 
7318 C...Double precision and integer declarations.
7319  IMPLICIT DOUBLE PRECISION(a-h, o-z)
7320  IMPLICIT INTEGER(i-n)
7321  INTEGER pyk,pychge,pycomp
7322 C...Parameter statement to help give large particle numbers.
7323  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
7324  &kexcit=4000000,kdimen=5000000)
7325 
7326 C...User process initialization commonblock.
7327  INTEGER maxpup
7328  parameter(maxpup=100)
7329  INTEGER idbmup,pdfgup,pdfsup,idwtup,nprup,lprup
7330  DOUBLE PRECISION ebmup,xsecup,xerrup,xmaxup
7331  common/heprup/idbmup(2),ebmup(2),pdfgup(2),pdfsup(2),
7332  &idwtup,nprup,xsecup(maxpup),xerrup(maxpup),xmaxup(maxpup),
7333  &lprup(maxpup)
7334  SAVE /heprup/
7335 
7336 C...Commonblocks.
7337  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
7338  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
7339  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
7340  common/pysubs/msel,mselpd,msub(500),kfin(2,-40:40),ckin(200)
7341  common/pypars/mstp(200),parp(200),msti(200),pari(200)
7342  common/pyint1/mint(400),vint(400)
7343  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
7344  common/pyint3/xsfx(2,-40:40),isig(1000,3),sigh(1000)
7345  common/pyint4/mwid(500),wids(500,5)
7346  common/pyint5/ngenpd,ngen(0:500,3),xsec(0:500,3)
7347  common/pyint6/proc(0:500)
7348  CHARACTER proc*28
7349  common/pyint7/sigt(0:6,0:6,0:5)
7350  common/pytcsm/itcm(0:99),rtcm(0:99)
7351  common/pytcco/coefx(194:380,2)
7352  common/tcpara/ires,jres,xmas(3),xwid(3),ymas(2),ywid(2)
7353  SAVE /pydat1/,/pydat2/,/pydat3/,/pysubs/,/pypars/,/pyint1/,
7354  &/pyint2/,/pyint3/,/pyint4/,/pyint5/,/pyint6/,/pyint7/,/pytcco/,
7355  &/pytcsm/,/tcpara/
7356 C...Local arrays, character variables and data.
7357  LOGICAL iok
7358  CHARACTER cvar(4)*4
7359  dimension npts(4),mvarpt(500,4),vintpt(500,30),sigspt(500),
7360  &narel(9),wtrel(9),wtmat(9,9),wtreln(9),coefu(9),coefo(9),
7361  &iaccmx(4),sigsmx(4),sigssm(3),pmmn(2),wtrsav(9),tempc(9),
7362  &iq(9),ip(9)
7363  DATA cvar/'tau ','tau''','y* ','cth '/
7364  DATA sigssm/3*0d0/
7365 
7366 C...Initial values and loop over subprocesses.
7367  nposi=0
7368  vint(143)=1d0
7369  vint(144)=1d0
7370  xsec(0,1)=0d0
7371  itech=0
7372  DO 460 isub=1,500
7373  mint(1)=isub
7374  mint(51)=0
7375 
7376 C...Find maximum weight factors for photon flux.
7377  IF(msub(isub).EQ.1.OR.(isub.GE.91.AND.isub.LE.100)) THEN
7378  IF(mint(141).NE.0.OR.mint(142).NE.0) CALL pygaga(2,wtgaga)
7379  ENDIF
7380 
7381 C...Select subprocess to study: skip cases not applicable.
7382  IF(iset(isub).EQ.11) THEN
7383  IF(msub(isub).NE.1) goto 460
7384 C...User process intialization: cross section model dependent.
7385  IF(iabs(idwtup).EQ.1) THEN
7386  IF(idwtup.GT.0.AND.xmaxup(kfpr(isub,1)).LT.0d0) CALL
7387  & pyerrm(26,'(PYMAXI:) Negative XMAXUP for user process')
7388  xsec(isub,1)=1.00000001d-9*abs(xmaxup(kfpr(isub,1)))
7389  ELSE
7390  IF((idwtup.EQ.2.OR.idwtup.EQ.3).AND.
7391  & xsecup(kfpr(isub,1)).LT.0d0) CALL
7392  & pyerrm(26,'(PYMAXI:) Negative XSECUP for user process')
7393  IF(idwtup.EQ.2.AND.xmaxup(kfpr(isub,1)).LT.0d0) CALL
7394  & pyerrm(26,'(PYMAXI:) Negative XMAXUP for user process')
7395  xsec(isub,1)=1.00000001d-9*abs(xsecup(kfpr(isub,1)))
7396  ENDIF
7397  IF(mint(141).NE.0.OR.mint(142).NE.0) xsec(isub,1)=
7398  & wtgaga*xsec(isub,1)
7399  nposi=nposi+1
7400  goto 450
7401  ELSEIF(isub.GE.91.AND.isub.LE.95) THEN
7402  CALL pysigh(nchn,sigs)
7403  xsec(isub,1)=sigs
7404  IF(mint(141).NE.0.OR.mint(142).NE.0) xsec(isub,1)=
7405  & wtgaga*xsec(isub,1)
7406  IF(msub(isub).NE.1) goto 460
7407  nposi=nposi+1
7408  goto 450
7409  ELSEIF(isub.EQ.99.AND.msub(isub).EQ.1) THEN
7410  CALL pysigh(nchn,sigs)
7411  xsec(isub,1)=sigs
7412  IF(mint(141).NE.0.OR.mint(142).NE.0) xsec(isub,1)=
7413  & wtgaga*xsec(isub,1)
7414  IF(xsec(isub,1).EQ.0d0) THEN
7415  msub(isub)=0
7416  ELSE
7417  nposi=nposi+1
7418  ENDIF
7419  goto 450
7420  ELSEIF(isub.EQ.96) THEN
7421  IF(mint(50).EQ.0) goto 460
7422  IF(msub(95).NE.1.AND.mod(mstp(81),10).LE.0.AND.mstp(131).LE.0)
7423  & goto 460
7424  IF(mint(49).EQ.0.AND.mstp(131).EQ.0) goto 460
7425  ELSEIF(isub.EQ.11.OR.isub.EQ.12.OR.isub.EQ.13.OR.isub.EQ.28.OR.
7426  & isub.EQ.53.OR.isub.EQ.68) THEN
7427  IF(msub(isub).NE.1.OR.msub(95).EQ.1) goto 460
7428  ELSEIF(isub.GE.381.AND.isub.LE.386) THEN
7429  IF(msub(isub).NE.1.OR.msub(95).EQ.1) goto 460
7430  ELSE
7431  IF(msub(isub).NE.1) goto 460
7432  ENDIF
7433  istsb=iset(isub)
7434  IF(isub.EQ.96) istsb=2
7435  IF(mstp(122).GE.2) WRITE(mstu(11),5000) isub
7436  mwtxs=0
7437  IF(mstp(142).GE.1.AND.isub.NE.96.AND.msub(91)+msub(92)+msub(93)+
7438  & msub(94)+msub(95).EQ.0) mwtxs=1
7439 
7440 C...Find resonances (explicit or implicit in cross-section).
7441  mint(72)=0
7442  kfr1=0
7443  IF(istsb.EQ.1.OR.istsb.EQ.3.OR.istsb.EQ.5) THEN
7444  kfr1=kfpr(isub,1)
7445  ELSEIF(isub.EQ.24.OR.isub.EQ.25.OR.isub.EQ.110.OR.isub.EQ.165
7446  & .OR.isub.EQ.171.OR.isub.EQ.176) THEN
7447  kfr1=23
7448  ELSEIF(isub.EQ.23.OR.isub.EQ.26.OR.isub.EQ.166.OR.isub.EQ.172
7449  & .OR.isub.EQ.177) THEN
7450  kfr1=24
7451  ELSEIF(isub.GE.71.AND.isub.LE.77) THEN
7452  kfr1=25
7453  IF(mstp(46).EQ.5) THEN
7454  kfr1=89
7455  pmas(89,1)=parp(45)
7456  pmas(89,2)=parp(45)**3/(96d0*paru(1)*parp(47)**2)
7457  ENDIF
7458  ELSEIF(isub.EQ.481) THEN
7459  kfr1=9900001
7460  ENDIF
7461  ckmx=ckin(2)
7462  IF(ckmx.LE.0d0) ckmx=vint(1)
7463  kcr1=pycomp(kfr1)
7464  IF(kcr1.EQ.0) kfr1=0
7465  IF(kfr1.NE.0) THEN
7466  IF(ckin(1).GT.pmas(kcr1,1)+20d0*pmas(kcr1,2).OR.
7467  & ckmx.LT.pmas(kcr1,1)-20d0*pmas(kcr1,2)) kfr1=0
7468  ENDIF
7469  IF(kfr1.NE.0) THEN
7470  taur1=pmas(kcr1,1)**2/vint(2)
7471  gamr1=pmas(kcr1,1)*pmas(kcr1,2)/vint(2)
7472  mint(72)=1
7473  mint(73)=kfr1
7474  vint(73)=taur1
7475  vint(74)=gamr1
7476  ENDIF
7477  kfr2=0
7478  kfr3=0
7479  IF(isub.EQ.141.OR.isub.EQ.194.OR.isub.EQ.195.OR.
7480  $ (isub.GE.361.AND.isub.LE.380))
7481  $ THEN
7482  kfr2=23
7483  IF(isub.EQ.141) THEN
7484  kcr2=pycomp(kfr2)
7485  IF(ckin(1).GT.pmas(kcr2,1)+20d0*pmas(kcr2,2).OR.
7486  & ckmx.LT.pmas(kcr2,1)-20d0*pmas(kcr2,2)) THEN
7487  kfr2=0
7488  ELSE
7489  taur2=pmas(kcr2,1)**2/vint(2)
7490  gamr2=pmas(kcr2,1)*pmas(kcr2,2)/vint(2)
7491  mint(72)=2
7492  mint(74)=kfr2
7493  vint(75)=taur2
7494  vint(76)=gamr2
7495  ENDIF
7496  ELSEIF(itech.EQ.0) THEN
7497  alprht=2.16d0*(3d0/dble(itcm(1)))
7498  itech=1
7499  kfr1=ktechn+113
7500  kcr1=pycomp(kfr1)
7501  kfr2=ktechn+223
7502  kcr2=pycomp(kfr2)
7503  kfr3=ktechn+115
7504  kcr3=pycomp(kfr3)
7505  ires=0
7506 C...Order the resonances
7507  IF(pmas(kcr3,1).LT.pmas(kcr2,1)) THEN
7508  kct=kcr3
7509  kcr3=kcr2
7510  kcr2=kct
7511  ENDIF
7512  IF(pmas(kcr3,1).LT.pmas(kcr1,1)) THEN
7513  kct=kcr3
7514  kcr3=kcr1
7515  kcr1=kct
7516  ENDIF
7517  IF(pmas(kcr2,1).LT.pmas(kcr1,1)) THEN
7518  kct=kcr2
7519  kcr2=kcr1
7520  kcr1=kct
7521  ENDIF
7522  DO 101 i=1,3
7523  IF(i.EQ.1) THEN
7524  shn0=pmas(kcr1,1)**2
7525  ELSEIF(i.EQ.2) THEN
7526  IF(abs(pmas(kcr2,1)-pmas(kcr1,1)).LE.1d-6) goto 101
7527  shn0=pmas(kcr2,1)**2
7528  ELSEIF(i.EQ.3) THEN
7529  IF(abs(pmas(kcr3,1)-pmas(kcr3,1)).LE.1d-6) goto 101
7530  shn0=pmas(kcr3,1)**2
7531  ENDIF
7532  aem=pyalem(shn0)
7533  far=sqrt(aem/alprht)
7534  shn=shn0*(1d0-far)
7535  CALL pytecm(shn,s1,wido,1)
7536  res=shn-s1
7537  shn=s1*.99d0
7538  shstep=2d0
7539  102 shn=shn+shstep
7540  CALL pytecm(shn,s1,wido,1)
7541  IF(res.LT.0d0.AND.shn-s1.GE.0d0) THEN
7542  iok=.false.
7543  IF(ires.GT.0) THEN
7544  IF(abs(sqrt(s1)-xmas(ires)).GT.1d-6) iok=.true.
7545  ELSEIF(ires.EQ.0) THEN
7546  iok=.true.
7547  ENDIF
7548  IF(iok) THEN
7549  ires=ires+1
7550  xmas(ires)=sqrt(s1)
7551  xwid(ires)=wido
7552  ENDIF
7553  ENDIF
7554  res=shn-s1
7555  IF(ires.LT.3.AND.shn.LT.shn0*(1d0+far)) goto 102
7556  101 CONTINUE
7557  jres=0
7558  kfr1=ktechn+213
7559  kcr1=pycomp(kfr1)
7560  kfr2=ktechn+215
7561  kcr2=pycomp(kfr2)
7562  IF(pmas(kcr2,1).LT.pmas(kcr1,1)) THEN
7563  kct=kcr2
7564  kcr2=kcr1
7565  kcr1=kct
7566  ENDIF
7567  DO 103 i=1,2
7568  IF(i.EQ.1) THEN
7569  shn0=pmas(kcr1,1)**2
7570  ELSEIF(i.EQ.2) THEN
7571  IF(abs(pmas(kcr2,1)-pmas(kcr1,1)).LE.1d-6) goto 103
7572  shn0=pmas(kcr2,1)**2
7573  ENDIF
7574  aem=pyalem(shn0)
7575  far=sqrt(aem/alprht)
7576  shn=shn0*(1d0-far)
7577  CALL pytecm(shn,s1,wido,2)
7578  res=shn-s1
7579  shn=s1*.99d0
7580  shstep=2d0
7581  104 shn=shn+shstep
7582  CALL pytecm(shn,s1,wido,2)
7583  IF(res.LT.0d0.AND.shn-s1.GE.0d0) THEN
7584  iok=.false.
7585  IF(jres.GT.0) THEN
7586  IF(abs(sqrt(s1)-xmas(ires)).GT.1d-6) iok=.true.
7587  ELSEIF(jres.EQ.0) THEN
7588  iok=.true.
7589  ENDIF
7590  IF(iok) THEN
7591  jres=jres+1
7592  ymas(jres)=sqrt(s1)
7593  ywid(jres)=wido
7594  ENDIF
7595  ENDIF
7596  res=shn-s1
7597  IF(jres.LT.2.AND.shn.LT.shn0*(1d0+far)) goto 104
7598  103 CONTINUE
7599  ENDIF
7600  IF(isub.EQ.194.OR.(isub.GE.361.AND.isub.LE.368).OR.
7601  & isub.EQ.379.OR.isub.EQ.380) THEN
7602  mint(72)=ires
7603  IF(ires.GE.1) THEN
7604  vint(73)=xmas(1)**2/vint(2)
7605  vint(74)=xmas(1)*xwid(1)/vint(2)
7606  taur1=vint(73)
7607  gamr1=vint(74)
7608  xm1=xmas(1)
7609  xg1=xwid(1)
7610  kfr1=1
7611  ENDIF
7612  IF(ires.GE.2) THEN
7613  vint(75)=xmas(2)**2/vint(2)
7614  vint(76)=xmas(2)*xwid(2)/vint(2)
7615  taur2=vint(75)
7616  gamr2=vint(76)
7617  xm2=xmas(2)
7618  xg2=xwid(2)
7619  kfr2=2
7620  ENDIF
7621  IF(ires.EQ.3) THEN
7622  vint(77)=xmas(3)**2/vint(2)
7623  vint(78)=xmas(3)*xwid(3)/vint(2)
7624  taur3=vint(77)
7625  gamr3=vint(78)
7626  xm3=xmas(3)
7627  xg3=xwid(3)
7628  kfr3=3
7629  ENDIF
7630 C...Charged current: rho+- and a+-
7631  ELSEIF(isub.EQ.195.OR.isub.GE.370.AND.isub.LE.378) THEN
7632  mint(72)=ires
7633  IF(jres.GE.1) THEN
7634  vint(73)=ymas(1)**2/vint(2)
7635  vint(74)=ymas(1)*ywid(1)/vint(2)
7636  kfr1=1
7637  taur1=vint(73)
7638  gamr1=vint(74)
7639  xm1=ymas(1)
7640  xg1=ywid(1)
7641  ENDIF
7642  IF(jres.GE.2) THEN
7643  vint(75)=ymas(2)**2/vint(2)
7644  vint(76)=ymas(2)*ywid(2)/vint(2)
7645  kfr2=2
7646  taur2=vint(73)
7647  gamr2=vint(74)
7648  xm2=ymas(2)
7649  xg2=ywid(2)
7650  ENDIF
7651  kfr3=0
7652  ENDIF
7653  IF(isub.NE.141) THEN
7654  IF(kfr1.NE.0.AND.(ckin(1).GT.(xm1+20d0*xg1)
7655  & .OR.ckmx.LT.(xm1-20d0*xg1))) kfr1=0
7656  IF(kfr2.NE.0.AND.(ckin(1).GT.(xm2+20d0*xg2)
7657  & .OR.ckmx.LT.(xm2-20d0*xg2))) kfr2=0
7658  IF(kfr3.NE.0.AND.(ckin(1).GT.(xm3+20d0*xg3)
7659  & .OR.ckmx.LT.(xm3-20d0*xg3))) kfr3=0
7660  IF(kfr3.NE.0.AND.kfr2.NE.0.AND.kfr1.NE.0) THEN
7661 
7662  ELSEIF(kfr1.NE.0.AND.kfr2.NE.0) THEN
7663  mint(72)=2
7664  ELSEIF(kfr1.NE.0.AND.kfr3.NE.0) THEN
7665  mint(72)=2
7666  mint(74)=kfr3
7667  vint(75)=taur3
7668  vint(76)=gamr3
7669  ELSEIF(kfr2.NE.0.AND.kfr3.NE.0) THEN
7670  mint(72)=2
7671  mint(73)=kfr2
7672  vint(73)=taur2
7673  vint(74)=gamr2
7674  mint(74)=kfr3
7675  vint(75)=taur3
7676  vint(76)=gamr3
7677  ELSEIF(kfr1.NE.0) THEN
7678  mint(72)=1
7679  ELSEIF(kfr2.NE.0) THEN
7680  mint(72)=1
7681  mint(73)=kfr2
7682  vint(73)=taur2
7683  vint(74)=gamr2
7684  ELSEIF(kfr3.NE.0) THEN
7685  mint(72)=1
7686  mint(73)=kfr3
7687  vint(73)=taur3
7688  vint(74)=gamr3
7689  ELSE
7690  mint(72)=0
7691  ENDIF
7692  ELSE
7693  IF(kfr2.NE.0.AND.kfr1.NE.0) THEN
7694 
7695  ELSEIF(kfr2.NE.0) THEN
7696  kfr1=kfr2
7697  taur1=taur2
7698  gamr1=gamr2
7699  mint(72)=1
7700  mint(73)=kfr1
7701  vint(73)=taur1
7702  vint(74)=gamr1
7703  kfr2=0
7704  ELSE
7705  mint(72)=0
7706  ENDIF
7707  ENDIF
7708  ENDIF
7709 
7710 C...Find product masses and minimum pT of process.
7711  sqm3=0d0
7712  sqm4=0d0
7713  mint(71)=0
7714  vint(71)=ckin(3)
7715  vint(80)=1d0
7716  IF(istsb.EQ.2.OR.istsb.EQ.4) THEN
7717  nbw=0
7718  DO 110 i=1,2
7719  pmmn(i)=0d0
7720  IF(kfpr(isub,i).EQ.0) THEN
7721  ELSEIF(mstp(42).LE.0.OR.pmas(pycomp(kfpr(isub,i)),2).LT.
7722  & parp(41)) THEN
7723  IF(i.EQ.1) sqm3=pmas(pycomp(kfpr(isub,i)),1)**2
7724  IF(i.EQ.2) sqm4=pmas(pycomp(kfpr(isub,i)),1)**2
7725  ELSE
7726  nbw=nbw+1
7727 C...This prevents SUSY/t particles from becoming too light.
7728  kflw=kfpr(isub,i)
7729  IF(kflw/ksusy1.EQ.1.OR.kflw/ksusy1.EQ.2) THEN
7730  kcw=pycomp(kflw)
7731  pmmn(i)=pmas(kcw,1)
7732  DO 100 idc=mdcy(kcw,2),mdcy(kcw,2)+mdcy(kcw,3)-1
7733  IF(mdme(idc,1).GT.0.AND.brat(idc).GT.1e-4) THEN
7734  pmsum=pmas(pycomp(kfdp(idc,1)),1)+
7735  & pmas(pycomp(kfdp(idc,2)),1)
7736  IF(kfdp(idc,3).NE.0) pmsum=pmsum+
7737  & pmas(pycomp(kfdp(idc,3)),1)
7738  pmmn(i)=min(pmmn(i),pmsum)
7739  ENDIF
7740  100 CONTINUE
7741  ELSEIF(kflw.EQ.6) THEN
7742  pmmn(i)=pmas(24,1)+pmas(5,1)
7743  ENDIF
7744  ENDIF
7745  110 CONTINUE
7746  IF(nbw.GE.1) THEN
7747  ckin41=ckin(41)
7748  ckin43=ckin(43)
7749  ckin(41)=max(pmmn(1),ckin(41))
7750  ckin(43)=max(pmmn(2),ckin(43))
7751  CALL pyofsh(3,0,kfpr(isub,1),kfpr(isub,2),0d0,pqm3,pqm4)
7752  ckin(41)=ckin41
7753  ckin(43)=ckin43
7754  IF(mint(51).EQ.1) THEN
7755  WRITE(mstu(11),5100) isub
7756  msub(isub)=0
7757  goto 460
7758  ENDIF
7759  sqm3=pqm3**2
7760  sqm4=pqm4**2
7761  ENDIF
7762  IF(min(sqm3,sqm4).LT.ckin(6)**2) mint(71)=1
7763  IF(mint(71).EQ.1) vint(71)=max(ckin(3),ckin(5))
7764  IF(isub.EQ.96.AND.mstp(82).LE.1) THEN
7765  vint(71)=parp(81)*(vint(1)/parp(89))**parp(90)
7766  ELSEIF(isub.EQ.96) THEN
7767  vint(71)=0.08d0*parp(82)*(vint(1)/parp(89))**parp(90)
7768  ENDIF
7769  ENDIF
7770  vint(63)=sqm3
7771  vint(64)=sqm4
7772 
7773 C...Prepare for additional variable choices in 2 -> 3.
7774  IF(istsb.EQ.5) THEN
7775  vint(201)=0d0
7776  IF(kfpr(isub,2).GT.0) vint(201)=pmas(pycomp(kfpr(isub,2)),1)
7777  vint(206)=vint(201)
7778  IF(isub.EQ.401.OR.isub.EQ.402) vint(206)=pmas(5,1)
7779  vint(204)=pmas(23,1)
7780  IF(isub.EQ.124.OR.isub.EQ.351) vint(204)=pmas(24,1)
7781  IF(isub.EQ.352) vint(204)=pmas(pycomp(9900024),1)
7782  IF(isub.EQ.121.OR.isub.EQ.122.OR.isub.EQ.181.OR.isub.EQ.182
7783  & .OR.isub.EQ.186.OR.isub.EQ.187.OR.isub.EQ.401.OR.isub.EQ.402)
7784  & vint(204)=vint(201)
7785  vint(209)=vint(204)
7786  IF(isub.EQ.401.OR.isub.EQ.402) vint(209)=vint(206)
7787  ENDIF
7788 
7789 C...Number of points for each variable: tau, tau', y*, cos(theta-hat).
7790  ipeak7=0
7791  npts(1)=2+2*mint(72)
7792  IF(mint(47).EQ.1) THEN
7793  IF(istsb.EQ.1.OR.istsb.EQ.2) npts(1)=1
7794  ELSEIF(mint(47).GE.5) THEN
7795  IF(istsb.LE.2.OR.istsb.GT.5) THEN
7796  npts(1)=npts(1)+1
7797  ipeak7=1
7798  ENDIF
7799  ENDIF
7800  npts(2)=1
7801  IF(istsb.GE.3.AND.istsb.LE.5) THEN
7802  IF(mint(47).GE.2) npts(2)=2
7803  IF(mint(47).GE.5) npts(2)=3
7804  ENDIF
7805  npts(3)=1
7806  IF(mint(47).EQ.4.OR.mint(47).EQ.5) THEN
7807  npts(3)=3
7808  IF(mint(45).EQ.3) npts(3)=npts(3)+1
7809  IF(mint(46).EQ.3) npts(3)=npts(3)+1
7810  ENDIF
7811  npts(4)=1
7812  IF(istsb.EQ.2.OR.istsb.EQ.4) npts(4)=5
7813  ntry=npts(1)*npts(2)*npts(3)*npts(4)
7814 
7815 C...Reset coefficients of cross-section weighting.
7816  DO 120 j=1,20
7817  coef(isub,j)=0d0
7818  120 CONTINUE
7819  IF(isub.EQ.194.OR.isub.EQ.195.OR.(isub.GE.361
7820  & .AND.isub.LE.380)) THEN
7821  DO 125 j=1,2
7822  coefx(isub,j)=0d0
7823  125 CONTINUE
7824  ENDIF
7825  coef(isub,1)=1d0
7826  coef(isub,8)=0.5d0
7827  coef(isub,9)=0.5d0
7828  coef(isub,13)=1d0
7829  coef(isub,18)=1d0
7830  mcth=0
7831  mtaup=0
7832  metaup=0
7833  vint(23)=0d0
7834  vint(26)=0d0
7835  sigsam=0d0
7836 
7837 C...Find limits and select tau, y*, cos(theta-hat) and tau' values,
7838 C...in grid of phase space points.
7839  CALL pyklim(1)
7840  metau=mint(51)
7841  nacc=0
7842  DO 150 itry=1,ntry
7843  mint(51)=0
7844  IF(metau.EQ.1) goto 150
7845  IF(mod(itry-1,npts(2)*npts(3)*npts(4)).EQ.0) THEN
7846  mtau=1+(itry-1)/(npts(2)*npts(3)*npts(4))
7847  IF(mint(72).LE.2.AND.mtau.GT.2+2*mint(72)) THEN
7848  mtau=7
7849  ELSEIF(mint(72).EQ.3.AND.ipeak7.EQ.0.AND.mtau.GE.7) THEN
7850  mtau=mtau+1
7851  ENDIF
7852  rtau=0.5d0
7853 C...Special case when both resonances have same mass,
7854 C...as is often the case in process 194.
7855 c IF(MINT(72).GE.2) THEN
7856 c IF(ABS(PMAS(KCR2,1)-PMAS(KCR1,1)).LT.
7857 c & 0.01D0*(PMAS(KCR2,1)+PMAS(KCR1,1))) THEN
7858 c IF(MTAU.EQ.3.OR.MTAU.EQ.4) THEN
7859 c RTAU=0.4D0
7860 c ELSEIF(MTAU.EQ.5.OR.MTAU.EQ.6) THEN
7861 c RTAU=0.6D0
7862 c ENDIF
7863 c ENDIF
7864 c ENDIF
7865  CALL pykmap(1,mtau,rtau)
7866  IF(istsb.GE.3.AND.istsb.LE.5) CALL pyklim(4)
7867  metaup=mint(51)
7868  ENDIF
7869  IF(metaup.EQ.1) goto 150
7870  IF(istsb.GE.3.AND.istsb.LE.5.AND.mod(itry-1,npts(3)*npts(4))
7871  & .EQ.0) THEN
7872  mtaup=1+mod((itry-1)/(npts(3)*npts(4)),npts(2))
7873  CALL pykmap(4,mtaup,0.5d0)
7874  ENDIF
7875  IF(mod(itry-1,npts(3)*npts(4)).EQ.0) THEN
7876  CALL pyklim(2)
7877  meyst=mint(51)
7878  ENDIF
7879  IF(meyst.EQ.1) goto 150
7880  IF(mod(itry-1,npts(4)).EQ.0) THEN
7881  myst=1+mod((itry-1)/npts(4),npts(3))
7882  IF(myst.EQ.4.AND.mint(45).NE.3) myst=5
7883  CALL pykmap(2,myst,0.5d0)
7884  CALL pyklim(3)
7885  mecth=mint(51)
7886  ENDIF
7887  IF(mecth.EQ.1) goto 150
7888  IF(istsb.EQ.2.OR.istsb.EQ.4) THEN
7889  mcth=1+mod(itry-1,npts(4))
7890  CALL pykmap(3,mcth,0.5d0)
7891  ENDIF
7892  IF(isub.EQ.96) vint(25)=vint(21)*(1d0-vint(23)**2)
7893 
7894 C...Store position and limits.
7895  mint(51)=0
7896  CALL pyklim(0)
7897  IF(mint(51).EQ.1) goto 150
7898  nacc=nacc+1
7899  mvarpt(nacc,1)=mtau
7900  mvarpt(nacc,2)=mtaup
7901  mvarpt(nacc,3)=myst
7902  mvarpt(nacc,4)=mcth
7903  DO 130 j=1,30
7904  vintpt(nacc,j)=vint(10+j)
7905  130 CONTINUE
7906 
7907 C...Normal case: calculate cross-section.
7908  IF(istsb.NE.5) THEN
7909  CALL pysigh(nchn,sigs)
7910  IF(mwtxs.EQ.1) THEN
7911  CALL pyevwt(wtxs)
7912  sigs=wtxs*sigs
7913  ENDIF
7914 
7915 C..2 -> 3: find highest value out of a number of tries.
7916  ELSE
7917  sigs=0d0
7918  DO 140 ikin3=1,mstp(129)
7919  CALL pykmap(5,0,0d0)
7920  IF(mint(51).EQ.1) goto 140
7921  CALL pysigh(nchn,sigtmp)
7922  IF(mwtxs.EQ.1) THEN
7923  CALL pyevwt(wtxs)
7924  sigtmp=wtxs*sigtmp
7925  ENDIF
7926  IF(sigtmp.GT.sigs) sigs=sigtmp
7927  140 CONTINUE
7928  ENDIF
7929 
7930 C...Store cross-section.
7931  sigspt(nacc)=sigs
7932  IF(sigs.GT.sigsam) sigsam=sigs
7933  IF(mstp(122).GE.2) WRITE(mstu(11),5200) mtau,myst,mcth,mtaup,
7934  & vint(21),vint(22),vint(23),vint(26),sigs
7935  150 CONTINUE
7936  IF(nacc.EQ.0) THEN
7937  WRITE(mstu(11),5100) isub
7938  msub(isub)=0
7939  goto 460
7940  ELSEIF(sigsam.EQ.0d0) THEN
7941  WRITE(mstu(11),5300) isub
7942  msub(isub)=0
7943  goto 460
7944  ENDIF
7945  IF(isub.NE.96) nposi=nposi+1
7946 
7947 C...Calculate integrals in tau over maximal phase space limits.
7948  taumin=vint(11)
7949  taumax=vint(31)
7950  atau1=log(taumax/taumin)
7951  IF(npts(1).GE.2) THEN
7952  atau2=(taumax-taumin)/(taumax*taumin)
7953  ENDIF
7954  IF(npts(1).GE.4) THEN
7955  atau3=log(taumax/taumin*(taumin+taur1)/(taumax+taur1))/taur1
7956  atau4=(atan((taumax-taur1)/gamr1)-atan((taumin-taur1)/gamr1))/
7957  & gamr1
7958  ENDIF
7959  IF(npts(1).GE.6) THEN
7960  atau5=log(taumax/taumin*(taumin+taur2)/(taumax+taur2))/taur2
7961  atau6=(atan((taumax-taur2)/gamr2)-atan((taumin-taur2)/gamr2))/
7962  & gamr2
7963  ENDIF
7964  IF(npts(1).GE.8) THEN
7965  atau8=log(taumax/taumin*(taumin+taur3)/(taumax+taur3))/taur3
7966  atau9=(atan((taumax-taur3)/gamr3)-atan((taumin-taur3)/gamr3))/
7967  & gamr3
7968  ENDIF
7969  IF(ipeak7.EQ.1) THEN
7970  atau7=log(max(2d-10,1d0-taumin)/max(2d-10,1d0-taumax))
7971  ENDIF
7972 
7973 C...Reset. Sum up cross-sections in points calculated.
7974  DO 320 ivar=1,4
7975  IF(npts(ivar).EQ.1) goto 320
7976  IF(isub.EQ.96.AND.ivar.EQ.4) goto 320
7977  nbin=npts(ivar)
7978  DO 170 j1=1,nbin
7979  narel(j1)=0
7980  wtrel(j1)=0d0
7981  coefu(j1)=0d0
7982  DO 160 j2=1,nbin
7983  wtmat(j1,j2)=0d0
7984  160 CONTINUE
7985  170 CONTINUE
7986  DO 180 iacc=1,nacc
7987  ibin=mvarpt(iacc,ivar)
7988  IF(ivar.EQ.1) THEN
7989  IF(ibin.GT.7.AND.ipeak7.EQ.0) THEN
7990  ibin=ibin-1
7991  ELSEIF(ibin.EQ.7.AND.ipeak7.EQ.1.AND.mstp(72).LT.3) THEN
7992  ibin=3+2*mint(72)
7993  ENDIF
7994  ENDIF
7995  IF(ivar.EQ.3.AND.ibin.EQ.5.AND.mint(45).NE.3) ibin=4
7996  narel(ibin)=narel(ibin)+1
7997  wtrel(ibin)=wtrel(ibin)+sigspt(iacc)
7998 
7999 C...Sum up tau cross-section pieces in points used.
8000  IF(ivar.EQ.1) THEN
8001  tau=vintpt(iacc,11)
8002  wtmat(ibin,1)=wtmat(ibin,1)+1d0
8003  wtmat(ibin,2)=wtmat(ibin,2)+(atau1/atau2)/tau
8004  IF(nbin.GE.4) THEN
8005  wtmat(ibin,3)=wtmat(ibin,3)+(atau1/atau3)/(tau+taur1)
8006  wtmat(ibin,4)=wtmat(ibin,4)+(atau1/atau4)*tau/
8007  & ((tau-taur1)**2+gamr1**2)
8008  ENDIF
8009  IF(nbin.GE.6) THEN
8010  wtmat(ibin,5)=wtmat(ibin,5)+(atau1/atau5)/(tau+taur2)
8011  wtmat(ibin,6)=wtmat(ibin,6)+(atau1/atau6)*tau/
8012  & ((tau-taur2)**2+gamr2**2)
8013  ENDIF
8014  IF(mint(72).LE.2.AND.ipeak7.EQ.1) THEN
8015  wtmat(ibin,3+2*mint(72))=wtmat(ibin,3+2*mint(72))
8016  & +(atau1/atau7)*tau/max(2d-10,1d0-tau)
8017  ELSEIF(mint(72).EQ.3.AND.ipeak7.EQ.1) THEN
8018  wtmat(ibin,7)=wtmat(ibin,7)
8019  & +(atau1/atau7)*tau/max(2d-10,1d0-tau)
8020  ENDIF
8021  IF(mint(72).EQ.3) THEN
8022  wtmat(ibin,7+ipeak7)=wtmat(ibin,7+ipeak7)
8023  & +(atau1/atau8)/(tau+taur3)
8024  wtmat(ibin,8+ipeak7)=wtmat(ibin,8+ipeak7)
8025  & +(atau1/atau9)*tau/((tau-taur3)**2+gamr3**2)
8026  ENDIF
8027 C...Sum up tau' cross-section pieces in points used.
8028  ELSEIF(ivar.EQ.2) THEN
8029  tau=vintpt(iacc,11)
8030  taup=vintpt(iacc,16)
8031  taupmn=vintpt(iacc,6)
8032  taupmx=vintpt(iacc,26)
8033  ataup1=log(taupmx/taupmn)
8034  ataup2=((1d0-tau/taupmx)**4-(1d0-tau/taupmn)**4)/(4d0*tau)
8035  wtmat(ibin,1)=wtmat(ibin,1)+1d0
8036  wtmat(ibin,2)=wtmat(ibin,2)+(ataup1/ataup2)*
8037  & (1d0-tau/taup)**3/taup
8038  IF(nbin.GE.3) THEN
8039  ataup3=log(max(2d-10,1d0-taupmn)/max(2d-10,1d0-taupmx))
8040  wtmat(ibin,3)=wtmat(ibin,3)+(ataup1/ataup3)*
8041  & taup/max(2d-10,1d0-taup)
8042  ENDIF
8043 
8044 C...Sum up y* cross-section pieces in points used.
8045  ELSEIF(ivar.EQ.3) THEN
8046  yst=vintpt(iacc,12)
8047  ystmin=vintpt(iacc,2)
8048  ystmax=vintpt(iacc,22)
8049  ayst0=ystmax-ystmin
8050  ayst1=0.5d0*(ystmax-ystmin)**2
8051  ayst2=ayst1
8052  ayst3=2d0*(atan(exp(ystmax))-atan(exp(ystmin)))
8053  wtmat(ibin,1)=wtmat(ibin,1)+(ayst0/ayst1)*(yst-ystmin)
8054  wtmat(ibin,2)=wtmat(ibin,2)+(ayst0/ayst2)*(ystmax-yst)
8055  wtmat(ibin,3)=wtmat(ibin,3)+(ayst0/ayst3)/cosh(yst)
8056  IF(mint(45).EQ.3) THEN
8057  taue=vintpt(iacc,11)
8058  IF(istsb.GE.3.AND.istsb.LE.5) taue=vintpt(iacc,16)
8059  yst0=-0.5d0*log(taue)
8060  ayst4=log(max(1d-10,exp(yst0-ystmin)-1d0)/
8061  & max(1d-10,exp(yst0-ystmax)-1d0))
8062  wtmat(ibin,4)=wtmat(ibin,4)+(ayst0/ayst4)/
8063  & max(1d-10,1d0-exp(yst-yst0))
8064  ENDIF
8065  IF(mint(46).EQ.3) THEN
8066  taue=vintpt(iacc,11)
8067  IF(istsb.GE.3.AND.istsb.LE.5) taue=vintpt(iacc,16)
8068  yst0=-0.5d0*log(taue)
8069  ayst5=log(max(1d-10,exp(yst0+ystmax)-1d0)/
8070  & max(1d-10,exp(yst0+ystmin)-1d0))
8071  wtmat(ibin,nbin)=wtmat(ibin,nbin)+(ayst0/ayst5)/
8072  & max(1d-10,1d0-exp(-yst-yst0))
8073  ENDIF
8074 
8075 C...Sum up cos(theta-hat) cross-section pieces in points used.
8076  ELSE
8077  rm34=max(1d-20,2d0*sqm3*sqm4/(vintpt(iacc,11)*vint(2))**2)
8078  rsqm=1d0+rm34
8079  cthmax=sqrt(1d0-4d0*vint(71)**2/(taumax*vint(2)))
8080  cthmin=-cthmax
8081  IF(cthmax.GT.0.9999d0) rm34=max(rm34,2d0*vint(71)**2/
8082  & (taumax*vint(2)))
8083  acth1=cthmax-cthmin
8084  acth2=log(max(rm34,rsqm-cthmin)/max(rm34,rsqm-cthmax))
8085  acth3=log(max(rm34,rsqm+cthmax)/max(rm34,rsqm+cthmin))
8086  acth4=1d0/max(rm34,rsqm-cthmax)-1d0/max(rm34,rsqm-cthmin)
8087  acth5=1d0/max(rm34,rsqm+cthmin)-1d0/max(rm34,rsqm+cthmax)
8088  cth=vintpt(iacc,13)
8089  wtmat(ibin,1)=wtmat(ibin,1)+1d0
8090  wtmat(ibin,2)=wtmat(ibin,2)+(acth1/acth2)/
8091  & max(rm34,rsqm-cth)
8092  wtmat(ibin,3)=wtmat(ibin,3)+(acth1/acth3)/
8093  & max(rm34,rsqm+cth)
8094  wtmat(ibin,4)=wtmat(ibin,4)+(acth1/acth4)/
8095  & max(rm34,rsqm-cth)**2
8096  wtmat(ibin,5)=wtmat(ibin,5)+(acth1/acth5)/
8097  & max(rm34,rsqm+cth)**2
8098  ENDIF
8099  180 CONTINUE
8100 
8101 C...Check that equation system solvable.
8102  IF(mstp(122).GE.2) WRITE(mstu(11),5400) cvar(ivar)
8103  msolv=1
8104  wtrels=0d0
8105  DO 190 ibin=1,nbin
8106  IF(mstp(122).GE.2) WRITE(mstu(11),5500) (wtmat(ibin,ired),
8107  & ired=1,nbin),wtrel(ibin)
8108  IF(narel(ibin).EQ.0) msolv=0
8109  wtrels=wtrels+wtrel(ibin)
8110  190 CONTINUE
8111  IF(abs(wtrels).LT.1d-20) msolv=0
8112 
8113 C...Solve to find relative importance of cross-section pieces.
8114  IF(msolv.EQ.1) THEN
8115  DO 200 ibin=1,nbin
8116  wtreln(ibin)=max(0.1d0,wtrel(ibin)/wtrels)
8117  wtrsav(ibin)=wtrel(ibin)
8118  200 CONTINUE
8119 C...Auxiliary vectors to record order of permutations
8120  DO i=1,nbin
8121  ip(i) = i
8122  iq(i) = i
8123  ENDDO
8124  DO 230 ired=1,nbin-1
8125  mrow=ired
8126  resmax=abs(wtrel(mrow))
8127 C...Find row with largest residual
8128  DO jbin=ired+1,nbin
8129  IF(resmax.LT.abs(wtrel(jbin))) THEN
8130  mrow=jbin
8131  resmax=abs(wtrel(mrow))
8132  ENDIF
8133  ENDDO
8134  IF(resmax.LT.1d-20) THEN
8135  msolv=0
8136  goto 260
8137  ENDIF
8138  mcol = ired
8139  amax = abs(wtmat(mrow,mcol))
8140 C...Find column with largest entry
8141  DO jbin=ired+1,nbin
8142  IF (amax.LT.abs(wtmat(mrow,jbin))) THEN
8143  mcol = jbin
8144  amax = abs(wtmat(mrow,mcol))
8145  ENDIF
8146  ENDDO
8147 C...Swap rows if necessary
8148  IF(mrow.NE.ired) THEN
8149  DO jbin=1,nbin
8150  tmpe=wtmat(ired,jbin)
8151  wtmat(ired,jbin)=wtmat(mrow,jbin)
8152  wtmat(mrow,jbin)=tmpe
8153  ENDDO
8154  tmpe=wtrel(ired)
8155  wtrel(ired)=wtrel(mrow)
8156  wtrel(mrow)=tmpe
8157  mtmp=iq(ired)
8158  iq(ired)=iq(mrow)
8159  iq(mrow)=mtmp
8160  ENDIF
8161 C...Swap columns if necessary
8162  IF(mcol.NE.ired) THEN
8163  DO jbin=1,nbin
8164  tmpe=wtmat(jbin,ired)
8165  wtmat(jbin,ired)=wtmat(jbin,mcol)
8166  wtmat(jbin,mcol)=tmpe
8167  ENDDO
8168  mtmp=ip(ired)
8169  ip(ired)=ip(mcol)
8170  ip(mcol)=mtmp
8171  ENDIF
8172 C...Begin eliminating equations
8173  DO 220 ibin=ired+1,nbin
8174  IF(abs(wtmat(ired,ired)).LT.1d-20) THEN
8175  msolv=0
8176  goto 260
8177  ENDIF
8178 C RQT=WTMAT(IBIN,IRED)/WTMAT(IRED,IRED)
8179  rqtu=wtmat(ibin,ired)
8180  rqtl=wtmat(ired,ired)
8181 C...Switch order of operations
8182  wtrel(ibin)=wtrel(ibin)-rqtu*
8183  $ (wtrel(ired)/rqtl)
8184  DO 210 icoe=ired,nbin
8185  wtmat(ibin,icoe)=wtmat(ibin,icoe)-
8186  $ rqtu*(wtmat(ired,icoe)/rqtl)
8187  210 CONTINUE
8188  220 CONTINUE
8189  230 CONTINUE
8190  DO 250 ired=nbin,1,-1
8191  DO 240 icoe=ired+1,nbin
8192  wtrel(ired)=wtrel(ired)-wtmat(ired,icoe)*coefu(icoe)
8193  240 CONTINUE
8194  IF(abs(wtmat(ired,ired)).LT.1d-20) THEN
8195  msolv=0
8196  goto 260
8197  ENDIF
8198  coefu(ired)=wtrel(ired)/wtmat(ired,ired)
8199  tempc(ired)=coefu(ired)
8200  250 CONTINUE
8201 C...Return to original order
8202  DO ibin=1,nbin
8203  mtmp=ip(ibin)
8204  coefu(mtmp)=tempc(ibin)
8205  ENDDO
8206  ENDIF
8207 
8208 C...Share evenly if failure.
8209  260 IF(msolv.EQ.0) THEN
8210  DO 270 ibin=1,nbin
8211  coefu(ibin)=1d0
8212  wtreln(ibin)=0.1d0
8213  IF(wtrels.GT.0d0) wtreln(ibin)=max(0.1d0,
8214  & wtrsav(ibin)/wtrels)
8215  270 CONTINUE
8216  ENDIF
8217 
8218 C...Normalize coefficients, with piece shared democratically.
8219  coefsu=0d0
8220  wtrels=0d0
8221  DO 280 ibin=1,nbin
8222  coefu(ibin)=max(0d0,coefu(ibin))
8223  coefsu=coefsu+coefu(ibin)
8224  wtrels=wtrels+wtreln(ibin)
8225  280 CONTINUE
8226  IF(coefsu.GT.0d0) THEN
8227  DO 290 ibin=1,nbin
8228  coefo(ibin)=parp(122)/nbin+(1d0-parp(122))*0.5d0*
8229  & (coefu(ibin)/coefsu+wtreln(ibin)/wtrels)
8230  290 CONTINUE
8231  ELSE
8232  DO 300 ibin=1,nbin
8233  coefo(ibin)=1d0/nbin
8234  300 CONTINUE
8235  ENDIF
8236  IF(ivar.EQ.1) ioff=0
8237  IF(ivar.EQ.2) ioff=17
8238  IF(ivar.EQ.3) ioff=7
8239  IF(ivar.EQ.4) ioff=12
8240  DO 310 ibin=1,nbin
8241  icof=ioff+ibin
8242  IF(ivar.EQ.1) THEN
8243  IF(ibin.EQ.nbin.AND.(mint(72).LE.2.AND.ipeak7.EQ.1)) THEN
8244  icof=7
8245  ENDIF
8246  ENDIF
8247  IF(ivar.EQ.3.AND.ibin.EQ.4.AND.mint(45).NE.3) icof=icof+1
8248  IF(ivar.EQ.1.AND.ibin.GE.7+ipeak7.AND.mint(72).EQ.3) THEN
8249  coefx(isub,ibin-6-ipeak7)=coefo(ibin)
8250  ELSE
8251  coef(isub,icof)=coefo(ibin)
8252  ENDIF
8253  310 CONTINUE
8254 
8255  IF(mstp(122).GE.2) WRITE(mstu(11),5600) cvar(ivar),
8256  & (coefo(ibin),ibin=1,nbin)
8257 
8258  320 CONTINUE
8259 
8260 C...Find two most promising maxima among points previously determined.
8261  DO 330 j=1,4
8262  iaccmx(j)=0
8263  sigsmx(j)=0d0
8264  330 CONTINUE
8265  nmax=0
8266  DO 390 iacc=1,nacc
8267  DO 340 j=1,30
8268  vint(10+j)=vintpt(iacc,j)
8269  340 CONTINUE
8270  IF(istsb.NE.5) THEN
8271  CALL pysigh(nchn,sigs)
8272  IF(mwtxs.EQ.1) THEN
8273  CALL pyevwt(wtxs)
8274  sigs=wtxs*sigs
8275  ENDIF
8276  ELSE
8277  sigs=0d0
8278  DO 350 ikin3=1,mstp(129)
8279  CALL pykmap(5,0,0d0)
8280  IF(mint(51).EQ.1) goto 350
8281  CALL pysigh(nchn,sigtmp)
8282  IF(mwtxs.EQ.1) THEN
8283  CALL pyevwt(wtxs)
8284  sigtmp=wtxs*sigtmp
8285  ENDIF
8286  IF(sigtmp.GT.sigs) sigs=sigtmp
8287  350 CONTINUE
8288  ENDIF
8289  ieq=0
8290  DO 360 imv=1,nmax
8291  IF(abs(sigs-sigsmx(imv)).LT.1d-4*(sigs+sigsmx(imv))) ieq=imv
8292  360 CONTINUE
8293  IF(ieq.EQ.0) THEN
8294  DO 370 imv=nmax,1,-1
8295  iin=imv+1
8296  IF(sigs.LE.sigsmx(imv)) goto 380
8297  iaccmx(imv+1)=iaccmx(imv)
8298  sigsmx(imv+1)=sigsmx(imv)
8299  370 CONTINUE
8300  iin=1
8301  380 iaccmx(iin)=iacc
8302  sigsmx(iin)=sigs
8303  IF(nmax.LE.1) nmax=nmax+1
8304  ENDIF
8305  390 CONTINUE
8306 
8307 C...Read out starting position for search.
8308  IF(mstp(122).GE.2) WRITE(mstu(11),5700)
8309  sigsam=sigsmx(1)
8310  DO 440 imax=1,nmax
8311  iacc=iaccmx(imax)
8312  mtau=mvarpt(iacc,1)
8313  mtaup=mvarpt(iacc,2)
8314  myst=mvarpt(iacc,3)
8315  mcth=mvarpt(iacc,4)
8316  vtau=0.5d0
8317  vyst=0.5d0
8318  vcth=0.5d0
8319  vtaup=0.5d0
8320 
8321 C...Starting point and step size in parameter space.
8322  DO 430 irpt=1,2
8323  DO 420 ivar=1,4
8324  IF(npts(ivar).EQ.1) goto 420
8325  IF(ivar.EQ.1) vvar=vtau
8326  IF(ivar.EQ.2) vvar=vtaup
8327  IF(ivar.EQ.3) vvar=vyst
8328  IF(ivar.EQ.4) vvar=vcth
8329  IF(ivar.EQ.1) mvar=mtau
8330  IF(ivar.EQ.2) mvar=mtaup
8331  IF(ivar.EQ.3) mvar=myst
8332  IF(ivar.EQ.4) mvar=mcth
8333  IF(irpt.EQ.1) vdel=0.1d0
8334  IF(irpt.EQ.2) vdel=max(0.01d0,min(0.05d0,vvar-0.02d0,
8335  & 0.98d0-vvar))
8336  IF(irpt.EQ.1) vmar=0.02d0
8337  IF(irpt.EQ.2) vmar=0.002d0
8338  imov0=1
8339  IF(irpt.EQ.1.AND.ivar.EQ.1) imov0=0
8340  DO 410 imov=imov0,8
8341 
8342 C...Define new point in parameter space.
8343  IF(imov.EQ.0) THEN
8344  inew=2
8345  vnew=vvar
8346  ELSEIF(imov.EQ.1) THEN
8347  inew=3
8348  vnew=vvar+vdel
8349  ELSEIF(imov.EQ.2) THEN
8350  inew=1
8351  vnew=vvar-vdel
8352  ELSEIF(sigssm(3).GE.max(sigssm(1),sigssm(2)).AND.
8353  & vvar+2d0*vdel.LT.1d0-vmar) THEN
8354  vvar=vvar+vdel
8355  sigssm(1)=sigssm(2)
8356  sigssm(2)=sigssm(3)
8357  inew=3
8358  vnew=vvar+vdel
8359  ELSEIF(sigssm(1).GE.max(sigssm(2),sigssm(3)).AND.
8360  & vvar-2d0*vdel.GT.vmar) THEN
8361  vvar=vvar-vdel
8362  sigssm(3)=sigssm(2)
8363  sigssm(2)=sigssm(1)
8364  inew=1
8365  vnew=vvar-vdel
8366  ELSEIF(sigssm(3).GE.sigssm(1)) THEN
8367  vdel=0.5d0*vdel
8368  vvar=vvar+vdel
8369  sigssm(1)=sigssm(2)
8370  inew=2
8371  vnew=vvar
8372  ELSE
8373  vdel=0.5d0*vdel
8374  vvar=vvar-vdel
8375  sigssm(3)=sigssm(2)
8376  inew=2
8377  vnew=vvar
8378  ENDIF
8379 
8380 C...Convert to relevant variables and find derived new limits.
8381  ilerr=0
8382  IF(ivar.EQ.1) THEN
8383  vtau=vnew
8384  CALL pykmap(1,mtau,vtau)
8385  IF(istsb.GE.3.AND.istsb.LE.5) THEN
8386  CALL pyklim(4)
8387  IF(mint(51).EQ.1) ilerr=1
8388  ENDIF
8389  ENDIF
8390  IF(ivar.LE.2.AND.istsb.GE.3.AND.istsb.LE.5.AND.
8391  & ilerr.EQ.0) THEN
8392  IF(ivar.EQ.2) vtaup=vnew
8393  CALL pykmap(4,mtaup,vtaup)
8394  ENDIF
8395  IF(ivar.LE.2.AND.ilerr.EQ.0) THEN
8396  CALL pyklim(2)
8397  IF(mint(51).EQ.1) ilerr=1
8398  ENDIF
8399  IF(ivar.LE.3.AND.ilerr.EQ.0) THEN
8400  IF(ivar.EQ.3) vyst=vnew
8401  CALL pykmap(2,myst,vyst)
8402  CALL pyklim(3)
8403  IF(mint(51).EQ.1) ilerr=1
8404  ENDIF
8405  IF((istsb.EQ.2.OR.istsb.EQ.4.OR.istsb.EQ.6).AND.
8406  & ilerr.EQ.0) THEN
8407  IF(ivar.EQ.4) vcth=vnew
8408  CALL pykmap(3,mcth,vcth)
8409  ENDIF
8410  IF(isub.EQ.96) vint(25)=vint(21)*(1.-vint(23)**2)
8411 
8412 C...Evaluate cross-section. Save new maximum. Final maximum.
8413  IF(ilerr.NE.0) THEN
8414  sigs=0.
8415  ELSEIF(istsb.NE.5) THEN
8416  CALL pysigh(nchn,sigs)
8417  IF(mwtxs.EQ.1) THEN
8418  CALL pyevwt(wtxs)
8419  sigs=wtxs*sigs
8420  ENDIF
8421  ELSE
8422  sigs=0d0
8423  DO 400 ikin3=1,mstp(129)
8424  CALL pykmap(5,0,0d0)
8425  IF(mint(51).EQ.1) goto 400
8426  CALL pysigh(nchn,sigtmp)
8427  IF(mwtxs.EQ.1) THEN
8428  CALL pyevwt(wtxs)
8429  sigtmp=wtxs*sigtmp
8430  ENDIF
8431  IF(sigtmp.GT.sigs) sigs=sigtmp
8432  400 CONTINUE
8433  ENDIF
8434  sigssm(inew)=sigs
8435  IF(sigs.GT.sigsam) sigsam=sigs
8436  IF(mstp(122).GE.2) WRITE(mstu(11),5800) imax,ivar,mvar,
8437  & imov,vnew,vint(21),vint(22),vint(23),vint(26),sigs
8438  410 CONTINUE
8439  420 CONTINUE
8440  430 CONTINUE
8441  440 CONTINUE
8442  IF(mstp(121).EQ.1) sigsam=parp(121)*sigsam
8443  xsec(isub,1)=1.05d0*sigsam
8444 C...Add extra headroom for UED
8445  IF(isub.GT.310.AND.isub.LT.320) xsec(isub,1)=xsec(isub,1)*1.1d0
8446  IF(mint(141).NE.0.OR.mint(142).NE.0) xsec(isub,1)=
8447  & wtgaga*xsec(isub,1)
8448  450 CONTINUE
8449  IF(mstp(173).EQ.1.AND.isub.NE.96) xsec(isub,1)=
8450  & parp(174)*xsec(isub,1)
8451  IF(isub.NE.96) xsec(0,1)=xsec(0,1)+xsec(isub,1)
8452  460 CONTINUE
8453  mint(51)=0
8454 
8455 C...Print summary table.
8456  IF(mint(121).EQ.1.AND.nposi.EQ.0) THEN
8457  IF(mstp(127).NE.1) THEN
8458  WRITE(mstu(11),5900)
8459  CALL pystop(1)
8460  ELSE
8461  WRITE(mstu(11),6400)
8462  msti(53)=1
8463  ENDIF
8464  ENDIF
8465  IF(mstp(122).GE.1) THEN
8466  WRITE(mstu(11),6000)
8467  WRITE(mstu(11),6100)
8468  DO 470 isub=1,500
8469  IF(msub(isub).NE.1.AND.isub.NE.96) goto 470
8470  IF(isub.EQ.96.AND.mint(50).EQ.0) goto 470
8471  IF(isub.EQ.96.AND.msub(95).NE.1.AND.mod(mstp(81),10).LE.0)
8472  & goto 470
8473  IF(isub.EQ.96.AND.mint(49).EQ.0.AND.mstp(131).EQ.0) goto 470
8474  IF(msub(95).EQ.1.AND.(isub.EQ.11.OR.isub.EQ.12.OR.isub.EQ.13
8475  & .OR.isub.EQ.28.OR.isub.EQ.53.OR.isub.EQ.68)) goto 470
8476  IF(msub(95).EQ.1.AND.isub.GE.381.AND.isub.LE.386) goto 470
8477  WRITE(mstu(11),6200) isub,proc(isub),xsec(isub,1)
8478  470 CONTINUE
8479  WRITE(mstu(11),6300)
8480  ENDIF
8481 
8482 C...Format statements for maximization results.
8483  5000 FORMAT(/1x,'Coefficient optimization and maximum search for ',
8484  &'subprocess no',i4/1x,'Coefficient modes tau',10x,'y*',9x,
8485  &'cth',9x,'tau''',7x,'sigma')
8486  5100 FORMAT(1x,'Warning: requested subprocess ',i3,' has no allowed ',
8487  &'phase space.'/1x,'Process switched off!')
8488  5200 FORMAT(1x,4i4,f12.8,f12.6,f12.7,f12.8,1p,d12.4)
8489  5300 FORMAT(1x,'Warning: requested subprocess ',i3,' has vanishing ',
8490  &'cross-section.'/1x,'Process switched off!')
8491  5400 FORMAT(1x,'Coefficients of equation system to be solved for ',a4)
8492  5500 FORMAT(1x,1p,10d11.3)
8493  5600 FORMAT(1x,'Result for ',a4,':',9f9.4)
8494  5700 FORMAT(1x,'Maximum search for given coefficients'/2x,'MAX VAR ',
8495  &'MOD MOV VNEW',7x,'tau',7x,'y*',8x,'cth',7x,'tau''',7x,'sigma')
8496  5800 FORMAT(1x,4i4,f8.4,f11.7,f9.3,f11.6,f11.7,1p,d12.4)
8497  5900 FORMAT(1x,'Error: no requested process has non-vanishing ',
8498  &'cross-section.'/1x,'Execution stopped!')
8499  6000 FORMAT(/1x,8('*'),1x,'PYMAXI: summary of differential ',
8500  &'cross-section maximum search',1x,8('*'))
8501  6100 FORMAT(/11x,58('=')/11x,'I',38x,'I',17x,'I'/11x,'I ISUB ',
8502  &'Subprocess name',15x,'I Maximum value I'/11x,'I',38x,'I',
8503  &17x,'I'/11x,58('=')/11x,'I',38x,'I',17x,'I')
8504  6200 FORMAT(11x,'I',2x,i3,3x,a28,2x,'I',2x,1p,d12.4,3x,'I')
8505  6300 FORMAT(11x,'I',38x,'I',17x,'I'/11x,58('='))
8506  6400 FORMAT(1x,'Error: no requested process has non-vanishing ',
8507  &'cross-section.'/
8508  &1x,'Execution will stop if you try to generate events.')
8509 
8510  RETURN
8511  END
8512 
8513 C*********************************************************************
8514 
8515 C...PYPILE
8516 C...Initializes multiplicity distribution and selects mutliplicity
8517 C...of pileup events, i.e. several events occuring at the same
8518 C...beam crossing.
8519 
8520  SUBROUTINE pypile(MPILE)
8521 
8522 C...Double precision and integer declarations.
8523  IMPLICIT DOUBLE PRECISION(a-h, o-z)
8524  IMPLICIT INTEGER(i-n)
8525  INTEGER pyk,pychge,pycomp
8526 C...Commonblocks.
8527  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
8528  common/pypars/mstp(200),parp(200),msti(200),pari(200)
8529  common/pyint1/mint(400),vint(400)
8530  common/pyint7/sigt(0:6,0:6,0:5)
8531  SAVE /pydat1/,/pypars/,/pyint1/,/pyint7/
8532 C...Local arrays and saved variables.
8533  dimension wti(0:200)
8534  SAVE imin,imax,wti,wts
8535 
8536 C...Sum of allowed cross-sections for pileup events.
8537  IF(mpile.EQ.1) THEN
8538  vint(131)=sigt(0,0,5)
8539  IF(mstp(132).GE.2) vint(131)=vint(131)+sigt(0,0,4)
8540  IF(mstp(132).GE.3) vint(131)=vint(131)+sigt(0,0,2)+sigt(0,0,3)
8541  IF(mstp(132).GE.4) vint(131)=vint(131)+sigt(0,0,1)
8542  IF(mstp(133).LE.0) RETURN
8543 
8544 C...Initialize multiplicity distribution at maximum.
8545  xnave=vint(131)*parp(131)
8546  IF(xnave.GT.120d0) WRITE(mstu(11),5000) xnave
8547  inave=max(1,min(200,nint(xnave)))
8548  wti(inave)=1d0
8549  wts=wti(inave)
8550  wtn=wti(inave)*inave
8551 
8552 C...Find shape of multiplicity distribution below maximum.
8553  imin=inave
8554  DO 100 i=inave-1,1,-1
8555  IF(mstp(133).EQ.1) wti(i)=wti(i+1)*(i+1)/xnave
8556  IF(mstp(133).GE.2) wti(i)=wti(i+1)*i/xnave
8557  IF(wti(i).LT.1d-6) goto 110
8558  wts=wts+wti(i)
8559  wtn=wtn+wti(i)*i
8560  imin=i
8561  100 CONTINUE
8562 
8563 C...Find shape of multiplicity distribution above maximum.
8564  110 imax=inave
8565  DO 120 i=inave+1,200
8566  IF(mstp(133).EQ.1) wti(i)=wti(i-1)*xnave/i
8567  IF(mstp(133).GE.2) wti(i)=wti(i-1)*xnave/(i-1)
8568  IF(wti(i).LT.1d-6) goto 130
8569  wts=wts+wti(i)
8570  wtn=wtn+wti(i)*i
8571  imax=i
8572  120 CONTINUE
8573  130 vint(132)=xnave
8574  vint(133)=wtn/wts
8575  IF(mstp(133).EQ.1.AND.imin.EQ.1) vint(134)=
8576  & wts/(wts+wti(1)/xnave)
8577  IF(mstp(133).EQ.1.AND.imin.GT.1) vint(134)=1d0
8578  IF(mstp(133).GE.2) vint(134)=xnave
8579 
8580 C...Pick multiplicity of pileup events.
8581  ELSE
8582  IF(mstp(133).LE.0) THEN
8583  mint(81)=max(1,mstp(134))
8584  ELSE
8585  wtr=wts*pyr(0)
8586  DO 140 i=imin,imax
8587  mint(81)=i
8588  wtr=wtr-wti(i)
8589  IF(wtr.LE.0d0) goto 150
8590  140 CONTINUE
8591  150 CONTINUE
8592  ENDIF
8593  ENDIF
8594 
8595 C...Format statement for error message.
8596  5000 FORMAT(1x,'Warning: requested average number of events per bunch',
8597  &'crossing too large, ',1p,d12.4)
8598 
8599  RETURN
8600  END
8601 
8602 C*********************************************************************
8603 
8604 C...PYSAVE
8605 C...Saves and restores parameter and cross section values for the
8606 C...3 gamma-p and 6 (or 4, or 9, or 13) gamma-gamma alternatives.
8607 C...Also makes random choice between alternatives.
8608 
8609  SUBROUTINE pysave(ISAVE,IGA)
8610 
8611 C...Double precision and integer declarations.
8612  IMPLICIT DOUBLE PRECISION(a-h, o-z)
8613  IMPLICIT INTEGER(i-n)
8614  INTEGER pyk,pychge,pycomp
8615 C...Commonblocks.
8616  common/pysubs/msel,mselpd,msub(500),kfin(2,-40:40),ckin(200)
8617  common/pypars/mstp(200),parp(200),msti(200),pari(200)
8618  common/pyint1/mint(400),vint(400)
8619  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
8620  common/pyint5/ngenpd,ngen(0:500,3),xsec(0:500,3)
8621  common/pyint7/sigt(0:6,0:6,0:5)
8622  SAVE /pysubs/,/pypars/,/pyint1/,/pyint2/,/pyint5/,/pyint7/
8623 C...Local arrays and saved variables.
8624  dimension ncp(15),nsubcp(15,20),msubcp(15,20),coefcp(15,20,20),
8625  &ngencp(15,0:20,3),xseccp(15,0:20,3),sigtcp(15,0:6,0:6,0:5),
8626  &intcp(15,20),recp(15,20)
8627  SAVE ncp,nsubcp,msubcp,coefcp,ngencp,xseccp,sigtcp,intcp,recp
8628 
8629 C...Save list of subprocesses and cross-section information.
8630  IF(isave.EQ.1) THEN
8631  icp=0
8632  DO 120 i=1,500
8633  IF(msub(i).EQ.0.AND.i.NE.96.AND.i.NE.97) goto 120
8634  icp=icp+1
8635  nsubcp(iga,icp)=i
8636  msubcp(iga,icp)=msub(i)
8637  DO 100 j=1,20
8638  coefcp(iga,icp,j)=coef(i,j)
8639  100 CONTINUE
8640  DO 110 j=1,3
8641  ngencp(iga,icp,j)=ngen(i,j)
8642  xseccp(iga,icp,j)=xsec(i,j)
8643  110 CONTINUE
8644  120 CONTINUE
8645  ncp(iga)=icp
8646  DO 130 j=1,3
8647  ngencp(iga,0,j)=ngen(0,j)
8648  xseccp(iga,0,j)=xsec(0,j)
8649  130 CONTINUE
8650  DO 160 i1=0,6
8651  DO 150 i2=0,6
8652  DO 140 j=0,5
8653  sigtcp(iga,i1,i2,j)=sigt(i1,i2,j)
8654  140 CONTINUE
8655  150 CONTINUE
8656  160 CONTINUE
8657 
8658 C...Save various common process variables.
8659  DO 170 j=1,10
8660  intcp(iga,j)=mint(40+j)
8661  170 CONTINUE
8662  intcp(iga,11)=mint(101)
8663  intcp(iga,12)=mint(102)
8664  intcp(iga,13)=mint(107)
8665  intcp(iga,14)=mint(108)
8666  intcp(iga,15)=mint(123)
8667  recp(iga,1)=ckin(3)
8668  recp(iga,2)=vint(318)
8669 
8670 C...Save cross-section information only.
8671  ELSEIF(isave.EQ.2) THEN
8672  DO 190 icp=1,ncp(iga)
8673  i=nsubcp(iga,icp)
8674  DO 180 j=1,3
8675  ngencp(iga,icp,j)=ngen(i,j)
8676  xseccp(iga,icp,j)=xsec(i,j)
8677  180 CONTINUE
8678  190 CONTINUE
8679  DO 200 j=1,3
8680  ngencp(iga,0,j)=ngen(0,j)
8681  xseccp(iga,0,j)=xsec(0,j)
8682  200 CONTINUE
8683 
8684 C...Choose between allowed alternatives.
8685  ELSEIF(isave.EQ.3.OR.isave.EQ.4) THEN
8686  IF(isave.EQ.4) THEN
8687  xsumcp=0d0
8688  DO 210 ig=1,mint(121)
8689  xsumcp=xsumcp+xseccp(ig,0,1)
8690  210 CONTINUE
8691  xsumcp=xsumcp*pyr(0)
8692  DO 220 ig=1,mint(121)
8693  iga=ig
8694  xsumcp=xsumcp-xseccp(ig,0,1)
8695  IF(xsumcp.LE.0d0) goto 230
8696  220 CONTINUE
8697  230 CONTINUE
8698  ENDIF
8699 
8700 C...Restore cross-section information.
8701  DO 240 i=1,500
8702  msub(i)=0
8703  240 CONTINUE
8704  DO 270 icp=1,ncp(iga)
8705  i=nsubcp(iga,icp)
8706  msub(i)=msubcp(iga,icp)
8707  DO 250 j=1,20
8708  coef(i,j)=coefcp(iga,icp,j)
8709  250 CONTINUE
8710  DO 260 j=1,3
8711  ngen(i,j)=ngencp(iga,icp,j)
8712  xsec(i,j)=xseccp(iga,icp,j)
8713  260 CONTINUE
8714  270 CONTINUE
8715  DO 280 j=1,3
8716  ngen(0,j)=ngencp(iga,0,j)
8717  xsec(0,j)=xseccp(iga,0,j)
8718  280 CONTINUE
8719  DO 310 i1=0,6
8720  DO 300 i2=0,6
8721  DO 290 j=0,5
8722  sigt(i1,i2,j)=sigtcp(iga,i1,i2,j)
8723  290 CONTINUE
8724  300 CONTINUE
8725  310 CONTINUE
8726 
8727 C...Restore various common process variables.
8728  DO 320 j=1,10
8729  mint(40+j)=intcp(iga,j)
8730  320 CONTINUE
8731  mint(101)=intcp(iga,11)
8732  mint(102)=intcp(iga,12)
8733  mint(107)=intcp(iga,13)
8734  mint(108)=intcp(iga,14)
8735  mint(123)=intcp(iga,15)
8736  ckin(3)=recp(iga,1)
8737  ckin(1)=2d0*ckin(3)
8738  vint(318)=recp(iga,2)
8739 
8740 C...Sum up cross-section info (for PYSTAT).
8741  ELSEIF(isave.EQ.5) THEN
8742  DO 330 i=1,500
8743  msub(i)=0
8744  ngen(i,1)=0
8745  ngen(i,3)=0
8746  xsec(i,3)=0d0
8747  330 CONTINUE
8748  ngen(0,1)=0
8749  ngen(0,2)=0
8750  ngen(0,3)=0
8751  xsec(0,3)=0
8752  DO 350 ig=1,mint(121)
8753  DO 340 icp=1,ncp(ig)
8754  i=nsubcp(ig,icp)
8755  IF(msubcp(ig,icp).EQ.1) msub(i)=1
8756  ngen(i,1)=ngen(i,1)+ngencp(ig,icp,1)
8757  ngen(i,3)=ngen(i,3)+ngencp(ig,icp,3)
8758  xsec(i,3)=xsec(i,3)+xseccp(ig,icp,3)
8759  340 CONTINUE
8760  ngen(0,1)=ngen(0,1)+ngencp(ig,0,1)
8761  ngen(0,2)=ngen(0,2)+ngencp(ig,0,2)
8762  ngen(0,3)=ngen(0,3)+ngencp(ig,0,3)
8763  xsec(0,3)=xsec(0,3)+xseccp(ig,0,3)
8764  350 CONTINUE
8765  ENDIF
8766 
8767  RETURN
8768  END
8769 
8770 C*********************************************************************
8771 
8772 C...PYGAGA
8773 C...For lepton beams it gives photon-hadron or photon-photon systems
8774 C...to be treated with the ordinary machinery and combines this with a
8775 C...description of the lepton -> lepton + photon branching.
8776 
8777  SUBROUTINE pygaga(IGAGA,WTGAGA)
8778 
8779 C...Double precision and integer declarations.
8780  IMPLICIT DOUBLE PRECISION(a-h, o-z)
8781  IMPLICIT INTEGER(i-n)
8782  INTEGER pyk,pychge,pycomp
8783 C...Commonblocks.
8784  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
8785  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
8786  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
8787  common/pysubs/msel,mselpd,msub(500),kfin(2,-40:40),ckin(200)
8788  common/pypars/mstp(200),parp(200),msti(200),pari(200)
8789  common/pyint1/mint(400),vint(400)
8790  common/pyint5/ngenpd,ngen(0:500,3),xsec(0:500,3)
8791  SAVE /pyjets/,/pydat1/,/pydat2/,/pysubs/,/pypars/,/pyint1/,
8792  &/pyint5/
8793 C...Local variables and data statement.
8794  dimension pms(2),xmin(2),xmax(2),q2min(2),q2max(2),pmc(3),
8795  &x(2),q2(2),y(2),theta(2),phi(2),pt(2),beta(3)
8796  SAVE pms,xmin,xmax,q2min,q2max,pmc,x,q2,theta,phi,pt,w2min
8797  DATA eps/1d-4/
8798 
8799 C...Initialize generation of photons inside leptons.
8800  IF(igaga.EQ.1) THEN
8801 
8802 C...Save quantities on incoming lepton system.
8803  vint(301)=vint(1)
8804  vint(302)=vint(2)
8805  pms(1)=vint(303)**2
8806  IF(mint(141).EQ.0) pms(1)=sign(vint(3)**2,vint(3))
8807  pms(2)=vint(304)**2
8808  IF(mint(142).EQ.0) pms(2)=sign(vint(4)**2,vint(4))
8809  pmc(3)=vint(302)-pms(1)-pms(2)
8810  w2min=max(ckin(77),2d0*ckin(3),2d0*ckin(5))**2
8811 
8812 C...Calculate range of x and Q2 values allowed in generation.
8813  DO 100 i=1,2
8814  pmc(i)=vint(302)+pms(i)-pms(3-i)
8815  IF(mint(140+i).NE.0) THEN
8816  xmin(i)=max(ckin(59+2*i),eps)
8817  xmax(i)=min(ckin(60+2*i),1d0-2d0*vint(301)*sqrt(pms(i))/
8818  & pmc(i),1d0-eps)
8819  ymin=max(ckin(71+2*i),eps)
8820  ymax=min(ckin(72+2*i),1d0-eps)
8821  IF(ckin(64+2*i).GT.0d0) xmin(i)=max(xmin(i),
8822  & (ymin*pmc(3)-ckin(64+2*i))/pmc(i))
8823  xmax(i)=min(xmax(i),(ymax*pmc(3)-ckin(63+2*i))/pmc(i))
8824  themin=max(ckin(67+2*i),0d0)
8825  themax=min(ckin(68+2*i),paru(1))
8826  IF(ckin(68+2*i).LT.0d0) themax=paru(1)
8827  q2min(i)=max(ckin(63+2*i),xmin(i)**2*pms(i)/(1d0-xmin(i))+
8828  & ((1d0-xmax(i))*(vint(302)-2d0*pms(3-i))-
8829  & 2d0*pms(i)/(1d0-xmax(i)))*sin(themin/2d0)**2,0d0)
8830  q2max(i)=xmax(i)**2*pms(i)/(1d0-xmax(i))+
8831  & ((1d0-xmin(i))*(vint(302)-2d0*pms(3-i))-
8832  & 2d0*pms(i)/(1d0-xmin(i)))*sin(themax/2d0)**2
8833  IF(ckin(64+2*i).GT.0d0) q2max(i)=min(ckin(64+2*i),q2max(i))
8834 C...W limits when lepton on one side only.
8835  IF(mint(143-i).EQ.0) THEN
8836  xmin(i)=max(xmin(i),(w2min-pms(3-i))/pmc(i))
8837  IF(ckin(78).GT.0d0) xmax(i)=min(xmax(i),
8838  & (ckin(78)**2-pms(3-i))/pmc(i))
8839  ENDIF
8840  ENDIF
8841  100 CONTINUE
8842 
8843 C...W limits when lepton on both sides.
8844  IF(mint(141).NE.0.AND.mint(142).NE.0) THEN
8845  IF(ckin(78).GT.0d0) xmax(1)=min(xmax(1),
8846  & (ckin(78)**2+pmc(3)-pmc(2)*xmin(2))/pmc(1))
8847  IF(ckin(78).GT.0d0) xmax(2)=min(xmax(2),
8848  & (ckin(78)**2+pmc(3)-pmc(1)*xmin(1))/pmc(2))
8849  IF(iabs(mint(141)).NE.iabs(mint(142))) THEN
8850  xmin(1)=max(xmin(1),(pms(1)-pms(2)+vint(302)*(w2min-
8851  & pms(1)-pms(2))/(pmc(2)*xmax(2)+pms(1)-pms(2)))/pmc(1))
8852  xmin(2)=max(xmin(2),(pms(2)-pms(1)+vint(302)*(w2min-
8853  & pms(1)-pms(2))/(pmc(1)*xmax(1)+pms(2)-pms(1)))/pmc(2))
8854  ELSE
8855  xmin(1)=max(xmin(1),w2min/(vint(302)*xmax(2)))
8856  xmin(2)=max(xmin(2),w2min/(vint(302)*xmax(1)))
8857  ENDIF
8858  ENDIF
8859 
8860 C...Q2 and W values and photon flux weight factors for initialization.
8861  ELSEIF(igaga.EQ.2) THEN
8862  isub=mint(1)
8863  mint(15)=0
8864  mint(16)=0
8865 
8866 C...W value for photon on one or both sides, and for processes
8867 C...with gamma-gamma cross section peaked at small shat.
8868  IF(mint(141).NE.0.AND.mint(142).EQ.0) THEN
8869  vint(2)=vint(302)+pms(1)-pmc(1)*(1d0-xmax(1))
8870  ELSEIF(mint(141).EQ.0.AND.mint(142).NE.0) THEN
8871  vint(2)=vint(302)+pms(2)-pmc(2)*(1d0-xmax(2))
8872  ELSEIF(isub.GE.137.AND.isub.LE.140) THEN
8873  vint(2)=max(ckin(77)**2,12d0*max(ckin(3),ckin(5))**2)
8874  IF(ckin(78).GT.0d0) vint(2)=min(vint(2),ckin(78)**2)
8875  ELSE
8876  vint(2)=xmax(1)*xmax(2)*vint(302)
8877  IF(ckin(78).GT.0d0) vint(2)=min(vint(2),ckin(78)**2)
8878  ENDIF
8879  vint(1)=sqrt(max(0d0,vint(2)))
8880 
8881 C...Upper estimate of photon flux weight factor.
8882 C...Initialization Q2 scale. Flag incoming unresolved photon.
8883  wtgaga=1d0
8884  DO 110 i=1,2
8885  IF(mint(140+i).NE.0) THEN
8886  wtgaga=wtgaga*2d0*(paru(101)/paru(2))*
8887  & log(xmax(i)/xmin(i))*log(q2max(i)/q2min(i))
8888  IF(isub.EQ.99.AND.mint(106+i).EQ.4.AND.mint(109-i).EQ.3)
8889  & THEN
8890  q2init=5d0+q2min(3-i)
8891  ELSEIF(isub.EQ.99.AND.mint(106+i).EQ.4) THEN
8892  q2init=pmas(pycomp(113),1)**2+q2min(3-i)
8893  ELSEIF(isub.EQ.132.OR.isub.EQ.134.OR.isub.EQ.136) THEN
8894  q2init=max(ckin(1),2d0*ckin(3),2d0*ckin(5))**2/3d0
8895  ELSEIF((isub.EQ.138.AND.i.EQ.2).OR.
8896  & (isub.EQ.139.AND.i.EQ.1)) THEN
8897  q2init=vint(2)/3d0
8898  ELSEIF(isub.EQ.140) THEN
8899  q2init=vint(2)/2d0
8900  ELSE
8901  q2init=q2min(i)
8902  ENDIF
8903  vint(2+i)=-sqrt(max(q2min(i),min(q2max(i),q2init)))
8904  IF(mstp(14).EQ.0.OR.(isub.GE.131.AND.isub.LE.140))
8905  & mint(14+i)=22
8906  vint(306+i)=vint(2+i)**2
8907  ENDIF
8908  110 CONTINUE
8909  vint(320)=wtgaga
8910 
8911 C...Update pTmin and cross section information.
8912  IF(mstp(82).LE.1) THEN
8913  ptmn=parp(81)*(vint(1)/parp(89))**parp(90)
8914  ELSE
8915  ptmn=parp(82)*(vint(1)/parp(89))**parp(90)
8916  ENDIF
8917  vint(149)=4d0*ptmn**2/vint(2)
8918  vint(154)=ptmn
8919  CALL pyxtot
8920  vint(318)=vint(317)
8921 
8922 C...Generate photons inside leptons and
8923 C...calculate photon flux weight factors.
8924  ELSEIF(igaga.EQ.3) THEN
8925  isub=mint(1)
8926  mint(15)=0
8927  mint(16)=0
8928 
8929 C...Generate phase space point and check against cuts.
8930  loop=0
8931  120 loop=loop+1
8932  DO 130 i=1,2
8933  IF(mint(140+i).NE.0) THEN
8934 C...Pick x and Q2
8935  x(i)=xmin(i)*(xmax(i)/xmin(i))**pyr(0)
8936  q2(i)=q2min(i)*(q2max(i)/q2min(i))**pyr(0)
8937 C...Cuts on internal consistency in x and Q2.
8938  IF(q2(i).LT.x(i)**2*pms(i)/(1d0-x(i))) goto 120
8939  IF(q2(i).GT.(1d0-x(i))*(vint(302)-2d0*pms(3-i))-
8940  & (2d0-x(i)**2)*pms(i)/(1d0-x(i))) goto 120
8941 C...Cuts on y and theta.
8942  y(i)=(pmc(i)*x(i)+q2(i))/pmc(3)
8943  IF(y(i).LT.ckin(71+2*i).OR.y(i).GT.ckin(72+2*i)) goto 120
8944  rat=((1d0-x(i))*q2(i)-x(i)**2*pms(i))/
8945  & ((1d0-x(i))**2*(vint(302)-2d0*pms(3-i)-2d0*pms(i)))
8946  theta(i)=2d0*asin(sqrt(max(0d0,min(1d0,rat))))
8947  IF(theta(i).LT.ckin(67+2*i)) goto 120
8948  IF(ckin(68+2*i).GT.0d0.AND.theta(i).GT.ckin(68+2*i))
8949  & goto 120
8950 
8951 C...Phi angle isotropic. Reconstruct pT.
8952  phi(i)=paru(2)*pyr(0)
8953  pt(i)=sqrt(((1d0-x(i))*pmc(i))**2/(4d0*vint(302))-
8954  & pms(i))*sin(theta(i))
8955 
8956 C...Store info on variables selected, for documentation purposes.
8957  vint(2+i)=-sqrt(q2(i))
8958  vint(304+i)=x(i)
8959  vint(306+i)=q2(i)
8960  vint(308+i)=y(i)
8961  vint(310+i)=theta(i)
8962  vint(312+i)=phi(i)
8963  ELSE
8964  vint(304+i)=1d0
8965  vint(306+i)=0d0
8966  vint(308+i)=1d0
8967  vint(310+i)=0d0
8968  vint(312+i)=0d0
8969  ENDIF
8970  130 CONTINUE
8971 
8972 C...Cut on W combines info from two sides.
8973  IF(mint(141).NE.0.AND.mint(142).NE.0) THEN
8974  w2=-q2(1)-q2(2)+0.5d0*x(1)*pmc(1)*x(2)*pmc(2)/vint(302)-
8975  & 2d0*pt(1)*pt(2)*cos(phi(1)-phi(2))+2d0*
8976  & sqrt((0.5d0*x(1)*pmc(1)/vint(301))**2+q2(1)-pt(1)**2)*
8977  & sqrt((0.5d0*x(2)*pmc(2)/vint(301))**2+q2(2)-pt(2)**2)
8978  IF(w2.LT.w2min) goto 120
8979  IF(ckin(78).GT.0d0.AND.w2.GT.ckin(78)**2) goto 120
8980  pms1=-q2(1)
8981  pms2=-q2(2)
8982  ELSEIF(mint(141).NE.0) THEN
8983  w2=(vint(302)+pms(1))*x(1)+pms(2)*(1d0-x(1))
8984  pms1=-q2(1)
8985  pms2=pms(2)
8986  ELSEIF(mint(142).NE.0) THEN
8987  w2=(vint(302)+pms(2))*x(2)+pms(1)*(1d0-x(2))
8988  pms1=pms(1)
8989  pms2=-q2(2)
8990  ENDIF
8991 
8992 C...Store kinematics info for photon(s) in subsystem cm frame.
8993  vint(2)=w2
8994  vint(1)=sqrt(w2)
8995  vint(291)=0d0
8996  vint(292)=0d0
8997  vint(293)=0.5d0*sqrt((w2-pms1-pms2)**2-4d0*pms1*pms2)/vint(1)
8998  vint(294)=0.5d0*(w2+pms1-pms2)/vint(1)
8999  vint(295)=sign(sqrt(abs(pms1)),pms1)
9000  vint(296)=0d0
9001  vint(297)=0d0
9002  vint(298)=-vint(293)
9003  vint(299)=0.5d0*(w2+pms2-pms1)/vint(1)
9004  vint(300)=sign(sqrt(abs(pms2)),pms2)
9005 
9006 C...Assign weight for photon flux; different for transverse and
9007 C...longitudinal photons. Flag incoming unresolved photon.
9008  wtgaga=1d0
9009  DO 140 i=1,2
9010  IF(mint(140+i).NE.0) THEN
9011  wtgaga=wtgaga*2d0*(paru(101)/paru(2))*
9012  & log(xmax(i)/xmin(i))*log(q2max(i)/q2min(i))
9013  IF(mstp(16).EQ.0) THEN
9014  xy=x(i)
9015  ELSE
9016  wtgaga=wtgaga*x(i)/y(i)
9017  xy=y(i)
9018  ENDIF
9019  IF(isub.EQ.132.OR.isub.EQ.134.OR.isub.EQ.136) THEN
9020  wtgaga=wtgaga*(1d0-xy)
9021  ELSEIF(i.EQ.1.AND.(isub.EQ.139.OR.isub.EQ.140)) THEN
9022  wtgaga=wtgaga*(1d0-xy)
9023  ELSEIF(i.EQ.2.AND.(isub.EQ.138.OR.isub.EQ.140)) THEN
9024  wtgaga=wtgaga*(1d0-xy)
9025  ELSE
9026  wtgaga=wtgaga*(0.5d0*(1d0+(1d0-xy)**2)-
9027  & pms(i)*xy**2/q2(i))
9028  ENDIF
9029  IF(mint(106+i).EQ.0) mint(14+i)=22
9030  ENDIF
9031  140 CONTINUE
9032  vint(319)=wtgaga
9033  mint(143)=loop
9034 
9035 C...Update pTmin and cross section information.
9036  IF(mstp(82).LE.1) THEN
9037  ptmn=parp(81)*(vint(1)/parp(89))**parp(90)
9038  ELSE
9039  ptmn=parp(82)*(vint(1)/parp(89))**parp(90)
9040  ENDIF
9041  vint(149)=4d0*ptmn**2/vint(2)
9042  vint(154)=ptmn
9043  CALL pyxtot
9044 
9045 C...Reconstruct kinematics of photons inside leptons.
9046  ELSEIF(igaga.EQ.4) THEN
9047 
9048 C...Make place for incoming particles and scattered leptons.
9049  move=3
9050  IF(mint(141).NE.0.AND.mint(142).NE.0) move=4
9051  mint(4)=mint(4)+move
9052  DO 160 i=mint(84)-move,mint(83)+1,-1
9053  IF(k(i,1).EQ.21) THEN
9054  DO 150 j=1,5
9055  k(i+move,j)=k(i,j)
9056  p(i+move,j)=p(i,j)
9057  v(i+move,j)=v(i,j)
9058  150 CONTINUE
9059  IF(k(i,3).GT.mint(83).AND.k(i,3).LE.mint(84))
9060  & k(i+move,3)=k(i,3)+move
9061  IF(k(i,4).GT.mint(83).AND.k(i,4).LE.mint(84))
9062  & k(i+move,4)=k(i,4)+move
9063  IF(k(i,5).GT.mint(83).AND.k(i,5).LE.mint(84))
9064  & k(i+move,5)=k(i,5)+move
9065  ENDIF
9066  160 CONTINUE
9067  DO 170 i=mint(84)+1,n
9068  IF(k(i,3).GT.mint(83).AND.k(i,3).LE.mint(84))
9069  & k(i,3)=k(i,3)+move
9070  170 CONTINUE
9071 
9072 C...Fill in incoming particles.
9073  DO 190 i=mint(83)+1,mint(83)+move
9074  DO 180 j=1,5
9075  k(i,j)=0
9076  p(i,j)=0d0
9077  v(i,j)=0d0
9078  180 CONTINUE
9079  190 CONTINUE
9080  DO 200 i=1,2
9081  k(mint(83)+i,1)=21
9082  IF(mint(140+i).NE.0) THEN
9083  k(mint(83)+i,2)=mint(140+i)
9084  p(mint(83)+i,5)=vint(302+i)
9085  ELSE
9086  k(mint(83)+i,2)=mint(10+i)
9087  p(mint(83)+i,5)=vint(2+i)
9088  ENDIF
9089  p(mint(83)+i,3)=0.5d0*sqrt((pmc(3)**2-4d0*pms(1)*pms(2))/
9090  & vint(302))*(-1d0)**(i+1)
9091  p(mint(83)+i,4)=0.5d0*pmc(i)/vint(301)
9092  200 CONTINUE
9093 
9094 C...New mother-daughter relations in documentation section.
9095  IF(mint(141).NE.0.AND.mint(142).NE.0) THEN
9096  k(mint(83)+1,4)=mint(83)+3
9097  k(mint(83)+1,5)=mint(83)+5
9098  k(mint(83)+2,4)=mint(83)+4
9099  k(mint(83)+2,5)=mint(83)+6
9100  k(mint(83)+3,3)=mint(83)+1
9101  k(mint(83)+5,3)=mint(83)+1
9102  k(mint(83)+4,3)=mint(83)+2
9103  k(mint(83)+6,3)=mint(83)+2
9104  ELSEIF(mint(141).NE.0) THEN
9105  k(mint(83)+1,4)=mint(83)+3
9106  k(mint(83)+1,5)=mint(83)+4
9107  k(mint(83)+2,4)=mint(83)+5
9108  k(mint(83)+3,3)=mint(83)+1
9109  k(mint(83)+4,3)=mint(83)+1
9110  k(mint(83)+5,3)=mint(83)+2
9111  ELSEIF(mint(142).NE.0) THEN
9112  k(mint(83)+1,4)=mint(83)+4
9113  k(mint(83)+2,4)=mint(83)+3
9114  k(mint(83)+2,5)=mint(83)+5
9115  k(mint(83)+3,3)=mint(83)+2
9116  k(mint(83)+4,3)=mint(83)+1
9117  k(mint(83)+5,3)=mint(83)+2
9118  ENDIF
9119 
9120 C...Fill scattered lepton(s).
9121  DO 210 i=1,2
9122  IF(mint(140+i).NE.0) THEN
9123  lsc=mint(83)+min(i+2,move)
9124  k(lsc,1)=21
9125  k(lsc,2)=mint(140+i)
9126  p(lsc,1)=pt(i)*cos(phi(i))
9127  p(lsc,2)=pt(i)*sin(phi(i))
9128  p(lsc,4)=(1d0-x(i))*p(mint(83)+i,4)
9129  p(lsc,3)=sqrt(p(lsc,4)**2-pms(i))*cos(theta(i))*
9130  & (-1d0)**(i-1)
9131  p(lsc,5)=vint(302+i)
9132  ENDIF
9133  210 CONTINUE
9134 
9135 C...Find incoming four-vectors to subprocess.
9136  k(n+1,1)=21
9137  IF(mint(141).NE.0) THEN
9138  DO 220 j=1,4
9139  p(n+1,j)=p(mint(83)+1,j)-p(mint(83)+3,j)
9140  220 CONTINUE
9141  ELSE
9142  DO 230 j=1,4
9143  p(n+1,j)=p(mint(83)+1,j)
9144  230 CONTINUE
9145  ENDIF
9146  k(n+2,1)=21
9147  IF(mint(142).NE.0) THEN
9148  DO 240 j=1,4
9149  p(n+2,j)=p(mint(83)+2,j)-p(mint(83)+move,j)
9150  240 CONTINUE
9151  ELSE
9152  DO 250 j=1,4
9153  p(n+2,j)=p(mint(83)+2,j)
9154  250 CONTINUE
9155  ENDIF
9156 
9157 C...Define boost and rotation between hadronic subsystem and
9158 C...collision rest frame; boost hadronic subsystem to this frame.
9159  DO 260 j=1,3
9160  beta(j)=(p(n+1,j)+p(n+2,j))/(p(n+1,4)+p(n+2,4))
9161  260 CONTINUE
9162  CALL pyrobo(n+1,n+2,0d0,0d0,-beta(1),-beta(2),-beta(3))
9163  bphi=pyangl(p(n+1,1),p(n+1,2))
9164  CALL pyrobo(n+1,n+2,0d0,-bphi,0d0,0d0,0d0)
9165  btheta=pyangl(p(n+1,3),p(n+1,1))
9166  CALL pyrobo(mint(83)+move+1,n,btheta,bphi,beta(1),beta(2),
9167  & beta(3))
9168 
9169 C...Add on scattered leptons to final state.
9170  DO 280 i=1,2
9171  IF(mint(140+i).NE.0) THEN
9172  lsc=mint(83)+min(i+2,move)
9173  n=n+1
9174  DO 270 j=1,5
9175  k(n,j)=k(lsc,j)
9176  p(n,j)=p(lsc,j)
9177  v(n,j)=v(lsc,j)
9178  270 CONTINUE
9179  k(n,1)=1
9180  k(n,3)=lsc
9181  ENDIF
9182  280 CONTINUE
9183  ENDIF
9184 
9185  RETURN
9186  END
9187 
9188 C*********************************************************************
9189 
9190 C...PYRAND
9191 C...Generates quantities characterizing the high-pT scattering at the
9192 C...parton level according to the matrix elements. Chooses incoming,
9193 C...reacting partons, their momentum fractions and one of the possible
9194 C...subprocesses.
9195 
9196  SUBROUTINE pyrand
9197 
9198 C...Double precision and integer declarations.
9199  IMPLICIT DOUBLE PRECISION(a-h, o-z)
9200  IMPLICIT INTEGER(i-n)
9201  INTEGER pyk,pychge,pycomp
9202 C...Parameter statement to help give large particle numbers.
9203  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
9204  &kexcit=4000000,kdimen=5000000)
9205 
9206 C...User process initialization and event commonblocks.
9207  INTEGER maxpup
9208  parameter(maxpup=100)
9209  INTEGER idbmup,pdfgup,pdfsup,idwtup,nprup,lprup
9210  DOUBLE PRECISION ebmup,xsecup,xerrup,xmaxup
9211  common/heprup/idbmup(2),ebmup(2),pdfgup(2),pdfsup(2),
9212  &idwtup,nprup,xsecup(maxpup),xerrup(maxpup),xmaxup(maxpup),
9213  &lprup(maxpup)
9214  INTEGER maxnup
9215  parameter(maxnup=500)
9216  INTEGER nup,idprup,idup,istup,mothup,icolup
9217  DOUBLE PRECISION xwgtup,scalup,aqedup,aqcdup,pup,vtimup,spinup
9218  common/hepeup/nup,idprup,xwgtup,scalup,aqedup,aqcdup,idup(maxnup),
9219  &istup(maxnup),mothup(2,maxnup),icolup(2,maxnup),pup(5,maxnup),
9220  &vtimup(maxnup),spinup(maxnup)
9221  SAVE /heprup/,/hepeup/
9222 
9223 C...Commonblocks.
9224  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
9225  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
9226  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
9227  common/pysubs/msel,mselpd,msub(500),kfin(2,-40:40),ckin(200)
9228  common/pypars/mstp(200),parp(200),msti(200),pari(200)
9229  common/pyint1/mint(400),vint(400)
9230  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
9231  common/pyint3/xsfx(2,-40:40),isig(1000,3),sigh(1000)
9232  common/pyint4/mwid(500),wids(500,5)
9233  common/pyint5/ngenpd,ngen(0:500,3),xsec(0:500,3)
9234  common/pyint7/sigt(0:6,0:6,0:5)
9235  common/pymssm/imss(0:99),rmss(0:99)
9236  common/pytcco/coefx(194:380,2)
9237  common/tcpara/ires,jres,xmas(3),xwid(3),ymas(2),ywid(2)
9238  SAVE /pydat1/,/pydat2/,/pydat3/,/pysubs/,/pypars/,/pyint1/,
9239  &/pyint2/,/pyint3/,/pyint4/,/pyint5/,/pyint7/,/pymssm/,/pytcco/,
9240  &/tcpara/
9241 C...Local arrays.
9242  dimension xpq(-25:25),pmm(2),pdif(4),bhad(4),pmmn(2)
9243 
9244 C...Parameters and data used in elastic/diffractive treatment.
9245  DATA eps/0.0808d0/, alp/0.25d0/, cres/2d0/, pmrc/1.062d0/,
9246  &smp/0.880d0/, bhad/2.3d0,1.4d0,1.4d0,0.23d0/
9247 
9248 C...Initial values, specifically for (first) semihard interaction.
9249  mint(10)=0
9250  mint(17)=0
9251  mint(18)=0
9252  vint(143)=1d0
9253  vint(144)=1d0
9254  vint(157)=0d0
9255  vint(158)=0d0
9256  mfail=0
9257  IF(mstp(171).EQ.1.AND.mstp(172).EQ.2) mfail=1
9258  isub=0
9259  istsb=0
9260  loop=0
9261  100 loop=loop+1
9262  mint(51)=0
9263  mint(143)=1
9264  vint(97)=1d0
9265 
9266 C...Start by assuming incoming photon is entering subprocess.
9267  IF(mint(11).EQ.22) THEN
9268  mint(15)=22
9269  vint(307)=vint(3)**2
9270  ENDIF
9271  IF(mint(12).EQ.22) THEN
9272  mint(16)=22
9273  vint(308)=vint(4)**2
9274  ENDIF
9275  mint(103)=mint(11)
9276  mint(104)=mint(12)
9277 
9278 C...Choice of process type - first event of pileup.
9279  inmult=0
9280  IF(mint(82).EQ.1.AND.isub.GE.91.AND.isub.LE.96) THEN
9281  ELSEIF(mint(82).EQ.1) THEN
9282 
9283 C...For gamma-p or gamma-gamma first pick between alternatives.
9284  iga=0
9285  IF(mint(121).GT.1) CALL pysave(4,iga)
9286  mint(122)=iga
9287 
9288 C...For real gamma + gamma with different nature, flip at random.
9289  IF(mint(11).EQ.22.AND.mint(12).EQ.22.AND.mint(123).GE.4.AND.
9290  & mstp(14).LE.10.AND.pyr(0).GT.0.5d0) THEN
9291  mintsv=mint(41)
9292  mint(41)=mint(42)
9293  mint(42)=mintsv
9294  mintsv=mint(45)
9295  mint(45)=mint(46)
9296  mint(46)=mintsv
9297  mintsv=mint(107)
9298  mint(107)=mint(108)
9299  mint(108)=mintsv
9300  IF(mint(47).EQ.2.OR.mint(47).EQ.3) mint(47)=5-mint(47)
9301  ENDIF
9302 
9303 C...Pick process type, possibly by user process machinery.
9304 C...(If the latter, also event will be picked here.)
9305  IF(mint(111).GE.11.AND.iabs(idwtup).EQ.2.AND.loop.GE.2) THEN
9306  CALL upevnt
9307  CALL pyupre
9308  ELSEIF(mint(111).GE.11.AND.iabs(idwtup).GE.3) THEN
9309  CALL upevnt
9310  CALL pyupre
9311  isub=0
9312  110 isub=isub+1
9313  IF((iset(isub).NE.11.OR.kfpr(isub,2).NE.idprup).AND.
9314  & isub.LT.500) goto 110
9315  ELSE
9316  rsub=xsec(0,1)*pyr(0)
9317  DO 120 i=1,500
9318  IF(msub(i).NE.1.OR.i.EQ.96) goto 120
9319  isub=i
9320  rsub=rsub-xsec(i,1)
9321  IF(rsub.LE.0d0) goto 130
9322  120 CONTINUE
9323  130 IF(isub.EQ.95) isub=96
9324  IF(isub.EQ.96) inmult=1
9325  IF(iset(isub).EQ.11) THEN
9326  idprup=kfpr(isub,2)
9327  CALL upevnt
9328  CALL pyupre
9329  ENDIF
9330  ENDIF
9331 
9332 C...Choice of inclusive process type - pileup events.
9333  ELSEIF(mint(82).GE.2.AND.isub.EQ.0) THEN
9334  rsub=vint(131)*pyr(0)
9335  isub=96
9336  IF(rsub.GT.sigt(0,0,5)) isub=94
9337  IF(rsub.GT.sigt(0,0,5)+sigt(0,0,4)) isub=93
9338  IF(rsub.GT.sigt(0,0,5)+sigt(0,0,4)+sigt(0,0,3)) isub=92
9339  IF(rsub.GT.sigt(0,0,5)+sigt(0,0,4)+sigt(0,0,3)+sigt(0,0,2))
9340  & isub=91
9341  IF(isub.EQ.96) inmult=1
9342  ENDIF
9343 
9344 C...Choice of photon energy and flux factor inside lepton.
9345  IF(mint(141).NE.0.OR.mint(142).NE.0) THEN
9346  CALL pygaga(3,wtgaga)
9347  IF(isub.GE.131.AND.isub.LE.140) THEN
9348  ckin(3)=max(vint(285),vint(154))
9349  ckin(1)=2d0*ckin(3)
9350  ENDIF
9351 C...When necessary set direct/resolved photon by hand.
9352  ELSEIF(mint(15).EQ.22.OR.mint(16).EQ.22) THEN
9353  IF(mint(15).EQ.22.AND.mint(41).EQ.2) mint(15)=0
9354  IF(mint(16).EQ.22.AND.mint(42).EQ.2) mint(16)=0
9355  ENDIF
9356 
9357 C...Restrict direct*resolved processes to pTmin >= Q,
9358 C...to avoid doublecounting with DIS.
9359  IF(mstp(18).EQ.3.AND.isub.GE.131.AND.isub.LE.136) THEN
9360  IF(mint(15).EQ.22) THEN
9361  ckin(3)=max(vint(285),vint(154),abs(vint(3)))
9362  ELSE
9363  ckin(3)=max(vint(285),vint(154),abs(vint(4)))
9364  ENDIF
9365  ckin(1)=2d0*ckin(3)
9366  ENDIF
9367 
9368 C...Set up for multiple interactions (may include impact parameter).
9369  IF(inmult.EQ.1) THEN
9370  IF(mint(35).LE.1) CALL pymult(2)
9371  IF(mint(35).GE.2) CALL pymign(2)
9372  ENDIF
9373 
9374 C...Loopback point for minimum bias in photon physics.
9375  loop2=0
9376  140 loop2=loop2+1
9377  IF(mint(82).EQ.1) ngen(0,1)=ngen(0,1)+mint(143)
9378  IF(mint(82).EQ.1) ngen(isub,1)=ngen(isub,1)+mint(143)
9379  IF(isub.EQ.96.AND.loop2.EQ.1.AND.mint(82).EQ.1)
9380  &ngen(97,1)=ngen(97,1)+mint(143)
9381  mint(1)=isub
9382  istsb=iset(isub)
9383 
9384 C...Random choice of flavour for some SUSY processes.
9385  IF(isub.GE.201.AND.isub.LE.301) THEN
9386 C...~e_L ~nu_e or ~mu_L ~nu_mu.
9387  IF(isub.EQ.210) THEN
9388  kfpr(isub,1)=ksusy1+11+2*int(0.5d0+pyr(0))
9389  kfpr(isub,2)=kfpr(isub,1)+1
9390 C...~nu_e ~nu_e(bar) or ~nu_mu ~nu_mu(bar).
9391  ELSEIF(isub.EQ.213) THEN
9392  kfpr(isub,1)=ksusy1+12+2*int(0.5d0+pyr(0))
9393  kfpr(isub,2)=kfpr(isub,1)
9394 C...~q ~chi/~g; ~q = ~d, ~u, ~s, ~c or ~b.
9395  ELSEIF(isub.GE.246.AND.isub.LE.259.AND.isub.NE.255.AND.
9396  & isub.NE.257) THEN
9397  IF(isub.GE.258) THEN
9398  rkf=4d0
9399  ELSE
9400  rkf=5d0
9401  ENDIF
9402  IF(mod(isub,2).EQ.0) THEN
9403  kfpr(isub,1)=ksusy1+1+int(rkf*pyr(0))
9404  ELSE
9405  kfpr(isub,1)=ksusy2+1+int(rkf*pyr(0))
9406  ENDIF
9407 C...~q1 ~q2; ~q = ~d, ~u, ~s, or ~c.
9408  ELSEIF(isub.GE.271.AND.isub.LE.276) THEN
9409  IF(isub.EQ.271.OR.isub.EQ.274) THEN
9410  ksu1=ksusy1
9411  ksu2=ksusy1
9412  ELSEIF(isub.EQ.272.OR.isub.EQ.275) THEN
9413  ksu1=ksusy2
9414  ksu2=ksusy2
9415  ELSEIF(pyr(0).LT.0.5d0) THEN
9416  ksu1=ksusy1
9417  ksu2=ksusy2
9418  ELSE
9419  ksu1=ksusy2
9420  ksu2=ksusy1
9421  ENDIF
9422  kfpr(isub,1)=ksu1+1+int(4d0*pyr(0))
9423  kfpr(isub,2)=ksu2+1+int(4d0*pyr(0))
9424 C...~q ~q(bar); ~q = ~d, ~u, ~s, or ~c.
9425  ELSEIF(isub.EQ.277.OR.isub.EQ.279) THEN
9426  kfpr(isub,1)=ksusy1+1+int(4d0*pyr(0))
9427  kfpr(isub,2)=kfpr(isub,1)
9428  ELSEIF(isub.EQ.278.OR.isub.EQ.280) THEN
9429  kfpr(isub,1)=ksusy2+1+int(4d0*pyr(0))
9430  kfpr(isub,2)=kfpr(isub,1)
9431 C...~q1 ~q2; ~q = ~d, ~u, ~s, or ~c.
9432  ELSEIF(isub.GE.281.AND.isub.LE.286) THEN
9433  IF(isub.EQ.281.OR.isub.EQ.284) THEN
9434  ksu1=ksusy1
9435  ksu2=ksusy1
9436  ELSEIF(isub.EQ.282.OR.isub.EQ.285) THEN
9437  ksu1=ksusy2
9438  ksu2=ksusy2
9439  ELSEIF(pyr(0).LT.0.5d0) THEN
9440  ksu1=ksusy1
9441  ksu2=ksusy2
9442  ELSE
9443  ksu1=ksusy2
9444  ksu2=ksusy1
9445  ENDIF
9446  IF(isub.EQ.281.OR.isub.LE.283) THEN
9447  rkf=5d0
9448  ELSE
9449  rkf=4d0
9450  ENDIF
9451  kfpr(isub,2)=ksu2+1+int(rkf*pyr(0))
9452  ENDIF
9453  ENDIF
9454 
9455 C...Random choice of flavours for some UED processes
9456 c...The production processes can generate a doublet pair,
9457 c...a singlet pair, or a doublet + singlet.
9458  IF(isub.EQ.313)THEN
9459 C...q + q -> q*_Di + q*_Dj, q*_Si + q*_Sj
9460  IF(pyr(0).LE.0.1)THEN
9461  kfpr(isub,1)=5100001
9462  ELSE
9463  kfpr(isub,1)=5100002
9464  ENDIF
9465  kfpr(isub,2)=kfpr(isub,1)
9466  ELSEIF(isub.EQ.314.OR.isub.EQ.315)THEN
9467 C...g + g -> q*_D + q*_Dbar, q*_S + q*_Sbar
9468 C...q + qbar -> q*_D + q*_Dbar, q*_S + q*_Sbar
9469  IF(pyr(0).LE.0.1)THEN
9470  kfpr(isub,1)=5100001
9471  ELSE
9472  kfpr(isub,1)=5100002
9473  ENDIF
9474  kfpr(isub,2)=-kfpr(isub,1)
9475  ELSEIF(isub.EQ.316)THEN
9476 C...qi + qbarj -> q*_Di + q*_Sbarj
9477  IF(pyr(0).LE.0.5)THEN
9478  kfpr(isub,1)=5100001
9479 c Changed from private pythia6410_ued code
9480 c KFPR(ISUB,2)=-5010001
9481  kfpr(isub,2)=-6100002
9482  ELSE
9483  kfpr(isub,1)=5100002
9484 c Changed from private pythia6410_ued code
9485 c KFPR(ISUB,2)=-5010002
9486  kfpr(isub,2)=-6100001
9487  ENDIF
9488  ELSEIF(isub.EQ.317)THEN
9489 C...qi + qbarj -> q*_Di + q*_Dbarj, q*_Si + q*_Dbarj
9490  IF(pyr(0).LE.0.5)THEN
9491  kfpr(isub,1)=5100001
9492  kfpr(isub,2)=-5100002
9493  ELSE
9494  kfpr(isub,1)=5100002
9495  kfpr(isub,2)=-5100001
9496  ENDIF
9497  ELSEIF(isub.EQ.318)THEN
9498 C...qi + qj -> q*_Di + q*_Sj
9499  IF(pyr(0).LE.0.5)THEN
9500  kfpr(isub,1)=5100001
9501  kfpr(isub,2)=6100002
9502  ELSE
9503  kfpr(isub,1)=5100002
9504  kfpr(isub,2)=6100001
9505  ENDIF
9506  ENDIF
9507 
9508 C...Find resonances (explicit or implicit in cross-section).
9509  mint(72)=0
9510  kfr1=0
9511  IF(istsb.EQ.1.OR.istsb.EQ.3.OR.istsb.EQ.5) THEN
9512  kfr1=kfpr(isub,1)
9513  ELSEIF(isub.EQ.24.OR.isub.EQ.25.OR.isub.EQ.110.OR.isub.EQ.165.OR.
9514  & isub.EQ.171.OR.isub.EQ.176) THEN
9515  kfr1=23
9516  ELSEIF(isub.EQ.23.OR.isub.EQ.26.OR.isub.EQ.166.OR.isub.EQ.172.OR.
9517  & isub.EQ.177) THEN
9518  kfr1=24
9519  ELSEIF(isub.GE.71.AND.isub.LE.77) THEN
9520  kfr1=25
9521  IF(mstp(46).EQ.5) THEN
9522  kfr1=89
9523  pmas(89,1)=parp(45)
9524  pmas(89,2)=parp(45)**3/(96d0*paru(1)*parp(47)**2)
9525  ENDIF
9526  ELSEIF(isub.EQ.481) THEN
9527  kfr1=9900001
9528  ENDIF
9529  ckmx=ckin(2)
9530  IF(ckmx.LE.0d0) ckmx=vint(1)
9531  kcr1=pycomp(kfr1)
9532  IF(kcr1.EQ.0) kfr1=0
9533  IF(kfr1.NE.0) THEN
9534  IF(ckin(1).GT.pmas(kcr1,1)+20d0*pmas(kcr1,2).OR.
9535  & ckmx.LT.pmas(kcr1,1)-20d0*pmas(kcr1,2)) kfr1=0
9536  ENDIF
9537  IF(kfr1.NE.0) THEN
9538  taur1=pmas(kcr1,1)**2/vint(2)
9539  gamr1=pmas(kcr1,1)*pmas(kcr1,2)/vint(2)
9540  mint(72)=1
9541  mint(73)=kfr1
9542  vint(73)=taur1
9543  vint(74)=gamr1
9544  ENDIF
9545  kfr2=0
9546  kfr3=0
9547  IF(isub.EQ.141.OR.isub.EQ.194.OR.isub.EQ.195.OR.
9548  $(isub.GE.361.AND.isub.LE.380))
9549  $THEN
9550  kfr2=23
9551  IF(isub.EQ.141) THEN
9552  kcr2=pycomp(kfr2)
9553  IF(ckin(1).GT.pmas(kcr2,1)+20d0*pmas(kcr2,2).OR.
9554  & ckmx.LT.pmas(kcr2,1)-20d0*pmas(kcr2,2)) THEN
9555  kfr2=0
9556  ELSE
9557  taur2=pmas(kcr2,1)**2/vint(2)
9558  gamr2=pmas(kcr2,1)*pmas(kcr2,2)/vint(2)
9559  mint(72)=2
9560  mint(74)=kfr2
9561  vint(75)=taur2
9562  vint(76)=gamr2
9563  ENDIF
9564 C...3 resonances at work: rho, omega, a
9565  ELSEIF(isub.EQ.194.OR.(isub.GE.361.AND.isub.LE.368)
9566  & .OR.isub.EQ.379.OR.isub.EQ.380) THEN
9567  mint(72)=ires
9568  IF(ires.GE.1) THEN
9569  vint(73)=xmas(1)**2/vint(2)
9570  vint(74)=xmas(1)*xwid(1)/vint(2)
9571  taur1=vint(73)
9572  gamr1=vint(74)
9573  kfr1=1
9574  ENDIF
9575  IF(ires.GE.2) THEN
9576  vint(75)=xmas(2)**2/vint(2)
9577  vint(76)=xmas(2)*xwid(2)/vint(2)
9578  taur2=vint(75)
9579  gamr2=vint(76)
9580  kfr2=2
9581  ENDIF
9582  IF(ires.EQ.3) THEN
9583  vint(77)=xmas(3)**2/vint(2)
9584  vint(78)=xmas(3)*xwid(3)/vint(2)
9585  taur3=vint(77)
9586  gamr3=vint(78)
9587  kfr3=3
9588  ENDIF
9589 C...Charged current: rho+- and a+-
9590  ELSEIF(isub.EQ.195.OR.isub.GE.370.AND.isub.LE.378) THEN
9591  mint(72)=ires
9592  IF(jres.GE.1) THEN
9593  vint(73)=ymas(1)**2/vint(2)
9594  vint(74)=ymas(1)*ywid(1)/vint(2)
9595  kfr1=1
9596  taur1=vint(73)
9597  gamr1=vint(74)
9598  ENDIF
9599  IF(jres.GE.2) THEN
9600  vint(75)=ymas(2)**2/vint(2)
9601  vint(76)=ymas(2)*ywid(2)/vint(2)
9602  kfr2=2
9603  taur2=vint(73)
9604  gamr2=vint(74)
9605  ENDIF
9606  kfr3=0
9607  ENDIF
9608  IF(isub.NE.141) THEN
9609  IF(kfr3.NE.0.AND.kfr2.NE.0.AND.kfr1.NE.0) THEN
9610 
9611  ELSEIF(kfr1.NE.0.AND.kfr2.NE.0) THEN
9612  mint(72)=2
9613  ELSEIF(kfr1.NE.0.AND.kfr3.NE.0) THEN
9614  mint(72)=2
9615  mint(74)=kfr3
9616  vint(75)=taur3
9617  vint(76)=gamr3
9618  ELSEIF(kfr2.NE.0.AND.kfr3.NE.0) THEN
9619  mint(72)=2
9620  mint(73)=kfr2
9621  vint(73)=taur2
9622  vint(74)=gamr2
9623  mint(74)=kfr3
9624  vint(75)=taur3
9625  vint(76)=gamr3
9626  ELSEIF(kfr1.NE.0) THEN
9627  mint(72)=1
9628  ELSEIF(kfr2.NE.0) THEN
9629  mint(72)=1
9630  mint(73)=kfr2
9631  vint(73)=taur2
9632  vint(74)=gamr2
9633  ELSEIF(kfr3.NE.0) THEN
9634  mint(72)=1
9635  mint(73)=kfr3
9636  vint(73)=taur3
9637  vint(74)=gamr3
9638  ELSE
9639  mint(72)=0
9640  ENDIF
9641  ELSE
9642  IF(kfr2.NE.0.AND.kfr1.NE.0) THEN
9643 
9644  ELSEIF(kfr2.NE.0) THEN
9645  kfr1=kfr2
9646  taur1=taur2
9647  gamr1=gamr2
9648  mint(72)=1
9649  mint(73)=kfr1
9650  vint(73)=taur1
9651  vint(74)=gamr1
9652  kfr2=0
9653  ELSE
9654  mint(72)=0
9655  ENDIF
9656  ENDIF
9657  ENDIF
9658 
9659 C...Find product masses and minimum pT of process,
9660 C...optionally with broadening according to a truncated Breit-Wigner.
9661  vint(63)=0d0
9662  vint(64)=0d0
9663  mint(71)=0
9664  vint(71)=ckin(3)
9665  IF(mint(82).GE.2) vint(71)=0d0
9666  vint(80)=1d0
9667  IF(istsb.EQ.2.OR.istsb.EQ.4) THEN
9668  nbw=0
9669  DO 160 i=1,2
9670  pmmn(i)=0d0
9671  IF(kfpr(isub,i).EQ.0) THEN
9672  ELSEIF(mstp(42).LE.0.OR.pmas(pycomp(kfpr(isub,i)),2).LT.
9673  & parp(41)) THEN
9674  vint(62+i)=pmas(pycomp(kfpr(isub,i)),1)**2
9675  ELSE
9676  nbw=nbw+1
9677 C...This prevents SUSY/t particles from becoming too light.
9678  kflw=kfpr(isub,i)
9679  IF(kflw/ksusy1.EQ.1.OR.kflw/ksusy1.EQ.2) THEN
9680  kcw=pycomp(kflw)
9681  pmmn(i)=pmas(kcw,1)
9682  DO 150 idc=mdcy(kcw,2),mdcy(kcw,2)+mdcy(kcw,3)-1
9683  IF(mdme(idc,1).GT.0.AND.brat(idc).GT.1e-4) THEN
9684  pmsum=pmas(pycomp(kfdp(idc,1)),1)+
9685  & pmas(pycomp(kfdp(idc,2)),1)
9686  IF(kfdp(idc,3).NE.0) pmsum=pmsum+
9687  & pmas(pycomp(kfdp(idc,3)),1)
9688  pmmn(i)=min(pmmn(i),pmsum)
9689  ENDIF
9690  150 CONTINUE
9691  ELSEIF(kflw.EQ.6) THEN
9692  pmmn(i)=pmas(24,1)+pmas(5,1)
9693  ENDIF
9694  ENDIF
9695  160 CONTINUE
9696  IF(nbw.GE.1) THEN
9697  ckin41=ckin(41)
9698  ckin43=ckin(43)
9699  ckin(41)=max(pmmn(1),ckin(41))
9700  ckin(43)=max(pmmn(2),ckin(43))
9701  CALL pyofsh(4,0,kfpr(isub,1),kfpr(isub,2),0d0,pqm3,pqm4)
9702  ckin(41)=ckin41
9703  ckin(43)=ckin43
9704  IF(mint(51).EQ.1) THEN
9705  IF(mint(121).GT.1) CALL pysave(2,iga)
9706  IF(mfail.EQ.1) THEN
9707  msti(61)=1
9708  RETURN
9709  ENDIF
9710  goto 100
9711  ENDIF
9712  vint(63)=pqm3**2
9713  vint(64)=pqm4**2
9714  ENDIF
9715  IF(min(vint(63),vint(64)).LT.ckin(6)**2) mint(71)=1
9716  IF(mint(71).EQ.1) vint(71)=max(ckin(3),ckin(5))
9717  ENDIF
9718 
9719 C...Prepare for additional variable choices in 2 -> 3.
9720  IF(istsb.EQ.5) THEN
9721  vint(201)=0d0
9722  IF(kfpr(isub,2).GT.0) vint(201)=pmas(pycomp(kfpr(isub,2)),1)
9723  vint(206)=vint(201)
9724  IF(isub.EQ.401.OR.isub.EQ.402) vint(206)=pmas(5,1)
9725  vint(204)=pmas(23,1)
9726  IF(isub.EQ.124.OR.isub.EQ.174.OR.isub.EQ.179.OR.isub.EQ.351)
9727  & vint(204)=pmas(24,1)
9728  IF(isub.EQ.352) vint(204)=pmas(pycomp(9900024),1)
9729  IF(isub.EQ.121.OR.isub.EQ.122.OR.isub.EQ.181.OR.isub.EQ.182.OR.
9730  & isub.EQ.186.OR.isub.EQ.187.OR.isub.EQ.401.OR.isub.EQ.402)
9731  & vint(204)=vint(201)
9732  vint(209)=vint(204)
9733  IF(isub.EQ.401.OR.isub.EQ.402) vint(209)=vint(206)
9734  ENDIF
9735 
9736 C...Select incoming VDM particle (rho/omega/phi/J/psi).
9737  IF(istsb.NE.0.AND.(mint(101).GE.2.OR.mint(102).GE.2).AND.
9738  &(mint(123).EQ.2.OR.mint(123).EQ.3.OR.mint(123).EQ.7)) THEN
9739  vrn=pyr(0)*sigt(0,0,5)
9740  IF(mint(101).LE.1) THEN
9741  i1mn=0
9742  i1mx=0
9743  ELSE
9744  i1mn=1
9745  i1mx=mint(101)
9746  ENDIF
9747  IF(mint(102).LE.1) THEN
9748  i2mn=0
9749  i2mx=0
9750  ELSE
9751  i2mn=1
9752  i2mx=mint(102)
9753  ENDIF
9754  DO 180 i1=i1mn,i1mx
9755  kfv1=110*i1+3
9756  DO 170 i2=i2mn,i2mx
9757  kfv2=110*i2+3
9758  vrn=vrn-sigt(i1,i2,5)
9759  IF(vrn.LE.0d0) goto 190
9760  170 CONTINUE
9761  180 CONTINUE
9762  190 IF(mint(101).GE.2) mint(103)=kfv1
9763  IF(mint(102).GE.2) mint(104)=kfv2
9764  ENDIF
9765 
9766  IF(istsb.EQ.0) THEN
9767 C...Elastic scattering or single or double diffractive scattering.
9768 
9769 C...Select incoming particle (rho/omega/phi/J/psi for VDM) and mass.
9770  mint(103)=mint(11)
9771  mint(104)=mint(12)
9772  pmm(1)=vint(3)
9773  pmm(2)=vint(4)
9774  IF(mint(101).GE.2.OR.mint(102).GE.2) THEN
9775  jj=isub-90
9776  vrn=pyr(0)*sigt(0,0,jj)
9777  IF(mint(101).LE.1) THEN
9778  i1mn=0
9779  i1mx=0
9780  ELSE
9781  i1mn=1
9782  i1mx=mint(101)
9783  ENDIF
9784  IF(mint(102).LE.1) THEN
9785  i2mn=0
9786  i2mx=0
9787  ELSE
9788  i2mn=1
9789  i2mx=mint(102)
9790  ENDIF
9791  DO 210 i1=i1mn,i1mx
9792  kfv1=110*i1+3
9793  DO 200 i2=i2mn,i2mx
9794  kfv2=110*i2+3
9795  vrn=vrn-sigt(i1,i2,jj)
9796  IF(vrn.LE.0d0) goto 220
9797  200 CONTINUE
9798  210 CONTINUE
9799  220 IF(mint(101).GE.2) THEN
9800  mint(103)=kfv1
9801  pmm(1)=pymass(kfv1)
9802  ENDIF
9803  IF(mint(102).GE.2) THEN
9804  mint(104)=kfv2
9805  pmm(2)=pymass(kfv2)
9806  ENDIF
9807  ENDIF
9808  vint(67)=pmm(1)
9809  vint(68)=pmm(2)
9810 
9811 C...Select mass for GVMD states (rejecting previous assignment).
9812  q0s=4d0*parp(15)**2
9813  q1s=4d0*vint(154)**2
9814  loop3=0
9815  230 loop3=loop3+1
9816  DO 240 jt=1,2
9817  IF(mint(106+jt).EQ.3) THEN
9818  ps=vint(2+jt)**2
9819  pmm(jt)=sqrt((q0s+ps)*(q1s+ps)/
9820  & (q0s+pyr(0)*(q1s-q0s)+ps)-ps)
9821  IF(mint(102+jt).GE.333) pmm(jt)=pmm(jt)-
9822  & pmas(pycomp(113),1)+pmas(pycomp(mint(102+jt)),1)
9823  ENDIF
9824  240 CONTINUE
9825  IF(pmm(1)+pmm(2)+parp(104).GE.vint(1)) THEN
9826  IF(loop3.LT.100.AND.(mint(107).EQ.3.OR.mint(108).EQ.3))
9827  & goto 230
9828  goto 100
9829  ENDIF
9830 
9831 C...Side/sides of diffractive system.
9832  mint(17)=0
9833  mint(18)=0
9834  IF(isub.EQ.92.OR.isub.EQ.94) mint(17)=1
9835  IF(isub.EQ.93.OR.isub.EQ.94) mint(18)=1
9836 
9837 C...Find masses of particles and minimal masses of diffractive states.
9838  DO 250 jt=1,2
9839  pdif(jt)=pmm(jt)
9840  vint(68+jt)=pdif(jt)
9841  IF(mint(16+jt).EQ.1) pdif(jt)=pdif(jt)+parp(102)
9842  250 CONTINUE
9843  sh=vint(2)
9844  sqm1=pmm(1)**2
9845  sqm2=pmm(2)**2
9846  sqm3=pdif(1)**2
9847  sqm4=pdif(2)**2
9848  smres1=(pmm(1)+pmrc)**2
9849  smres2=(pmm(2)+pmrc)**2
9850 
9851 C...Find elastic slope and lower limit diffractive slope.
9852  iha=max(2,iabs(mint(103))/110)
9853  IF(iha.GE.5) iha=1
9854  ihb=max(2,iabs(mint(104))/110)
9855  IF(ihb.GE.5) ihb=1
9856  IF(isub.EQ.91) THEN
9857  bmn=2d0*bhad(iha)+2d0*bhad(ihb)+4d0*sh**eps-4.2d0
9858  ELSEIF(isub.EQ.92) THEN
9859  bmn=max(2d0,2d0*bhad(ihb))
9860  ELSEIF(isub.EQ.93) THEN
9861  bmn=max(2d0,2d0*bhad(iha))
9862  ELSEIF(isub.EQ.94) THEN
9863  bmn=2d0*alp*4d0
9864  ENDIF
9865 
9866 C...Determine maximum possible t range and coefficient of generation.
9867  sqla12=(sh-sqm1-sqm2)**2-4d0*sqm1*sqm2
9868  sqla34=(sh-sqm3-sqm4)**2-4d0*sqm3*sqm4
9869  tha=sh-(sqm1+sqm2+sqm3+sqm4)+(sqm1-sqm2)*(sqm3-sqm4)/sh
9870  thb=sqrt(max(0d0,sqla12))*sqrt(max(0d0,sqla34))/sh
9871  thc=(sqm3-sqm1)*(sqm4-sqm2)+(sqm1+sqm4-sqm2-sqm3)*
9872  & (sqm1*sqm4-sqm2*sqm3)/sh
9873  thl=-0.5d0*(tha+thb)
9874  thu=thc/thl
9875  thrnd=exp(max(-50d0,bmn*(thl-thu)))-1d0
9876 
9877 C...Select diffractive mass/masses according to dm^2/m^2.
9878  loop3=0
9879  260 loop3=loop3+1
9880  DO 270 jt=1,2
9881  IF(mint(16+jt).EQ.0) THEN
9882  pdif(2+jt)=pdif(jt)
9883  ELSE
9884  pmmin=pdif(jt)
9885  pmmax=max(vint(2+jt),vint(1)-pdif(3-jt))
9886  pdif(2+jt)=pmmin*(pmmax/pmmin)**pyr(0)
9887  ENDIF
9888  270 CONTINUE
9889  sqm3=pdif(3)**2
9890  sqm4=pdif(4)**2
9891 
9892 C..Additional mass factors, including resonance enhancement.
9893  IF(pdif(3)+pdif(4).GE.vint(1)) THEN
9894  IF(loop3.LT.100) goto 260
9895  goto 100
9896  ENDIF
9897  IF(isub.EQ.92) THEN
9898  fsd=(1d0-sqm3/sh)*(1d0+cres*smres1/(smres1+sqm3))
9899  IF(fsd.LT.pyr(0)*(1d0+cres)) goto 260
9900  ELSEIF(isub.EQ.93) THEN
9901  fsd=(1d0-sqm4/sh)*(1d0+cres*smres2/(smres2+sqm4))
9902  IF(fsd.LT.pyr(0)*(1d0+cres)) goto 260
9903  ELSEIF(isub.EQ.94) THEN
9904  fdd=(1d0-(pdif(3)+pdif(4))**2/sh)*(sh*smp/
9905  & (sh*smp+sqm3*sqm4))*(1d0+cres*smres1/(smres1+sqm3))*
9906  & (1d0+cres*smres2/(smres2+sqm4))
9907  IF(fdd.LT.pyr(0)*(1d0+cres)**2) goto 260
9908  ENDIF
9909 
9910 C...Select t according to exp(Bmn*t) and correct to right slope.
9911  th=thu+log(1d0+thrnd*pyr(0))/bmn
9912  IF(isub.GE.92) THEN
9913  IF(isub.EQ.92) THEN
9914  badd=2d0*alp*log(sh/sqm3)
9915  IF(bhad(ihb).LT.1d0) badd=max(0d0,badd+2d0*bhad(ihb)-2d0)
9916  ELSEIF(isub.EQ.93) THEN
9917  badd=2d0*alp*log(sh/sqm4)
9918  IF(bhad(iha).LT.1d0) badd=max(0d0,badd+2d0*bhad(iha)-2d0)
9919  ELSEIF(isub.EQ.94) THEN
9920  badd=2d0*alp*(log(exp(4d0)+sh/(alp*sqm3*sqm4))-4d0)
9921  ENDIF
9922  IF(exp(max(-50d0,badd*(th-thu))).LT.pyr(0)) goto 260
9923  ENDIF
9924 
9925 C...Check whether m^2 and t choices are consistent.
9926  sqla34=(sh-sqm3-sqm4)**2-4d0*sqm3*sqm4
9927  tha=sh-(sqm1+sqm2+sqm3+sqm4)+(sqm1-sqm2)*(sqm3-sqm4)/sh
9928  thb=sqrt(max(0d0,sqla12))*sqrt(max(0d0,sqla34))/sh
9929  IF(thb.LE.1d-8) goto 260
9930  thc=(sqm3-sqm1)*(sqm4-sqm2)+(sqm1+sqm4-sqm2-sqm3)*
9931  & (sqm1*sqm4-sqm2*sqm3)/sh
9932  thlm=-0.5d0*(tha+thb)
9933  thum=thc/thlm
9934  IF(th.LT.thlm.OR.th.GT.thum) goto 260
9935 
9936 C...Information to output.
9937  vint(21)=1d0
9938  vint(22)=0d0
9939  vint(23)=min(1d0,max(-1d0,(tha+2d0*th)/thb))
9940  vint(45)=th
9941  vint(59)=2d0*sqrt(max(0d0,-(thc+tha*th+th**2)))/thb
9942  vint(63)=pdif(3)**2
9943  vint(64)=pdif(4)**2
9944  vint(283)=pmm(1)**2/4d0
9945  vint(284)=pmm(2)**2/4d0
9946 
9947 C...Note: in the following, by In is meant the integral over the
9948 C...quantity multiplying coefficient cn.
9949 C...Choose tau according to h1(tau)/tau, where
9950 C...h1(tau) = c1 + I1/I2*c2*1/tau + I1/I3*c3*1/(tau+tau_R) +
9951 C...I1/I4*c4*tau/((s*tau-m^2)^2+(m*Gamma)^2) +
9952 C...I1/I5*c5*1/(tau+tau_R') +
9953 C...I1/I6*c6*tau/((s*tau-m'^2)^2+(m'*Gamma')^2) +
9954 C...I1/I7*c7*tau/(1.-tau), and
9955 C...c1 + c2 + c3 + c4 + c5 + c6 + c7 = 1.
9956  ELSEIF(istsb.GE.1.AND.istsb.LE.5) THEN
9957  CALL pyklim(1)
9958  IF(mint(51).NE.0) THEN
9959  IF(mint(121).GT.1) CALL pysave(2,iga)
9960  IF(mfail.EQ.1) THEN
9961  msti(61)=1
9962  RETURN
9963  ENDIF
9964  goto 100
9965  ENDIF
9966  rtau=pyr(0)
9967  mtau=1
9968  IF(rtau.GT.coef(isub,1)) mtau=2
9969  IF(rtau.GT.coef(isub,1)+coef(isub,2)) mtau=3
9970  IF(rtau.GT.coef(isub,1)+coef(isub,2)+coef(isub,3)) mtau=4
9971  IF(rtau.GT.coef(isub,1)+coef(isub,2)+coef(isub,3)+coef(isub,4))
9972  & mtau=5
9973  IF(rtau.GT.coef(isub,1)+coef(isub,2)+coef(isub,3)+coef(isub,4)+
9974  & coef(isub,5)) mtau=6
9975  IF(rtau.GT.coef(isub,1)+coef(isub,2)+coef(isub,3)+coef(isub,4)+
9976  & coef(isub,5)+coef(isub,6)) mtau=7
9977 C...Additional check to handle techni-processes with extra resonance
9978 C....Only modify tau treatment
9979  IF(isub.EQ.194.OR.isub.EQ.195.OR.(isub.GE.361.AND.isub.LE.380))
9980  & THEN
9981  IF(rtau.GT.coef(isub,1)+coef(isub,2)+coef(isub,3)
9982  & +coef(isub,4)+coef(isub,5)+coef(isub,6)+coef(isub,7)) mtau=8
9983  IF(rtau.GT.coef(isub,1)+coef(isub,2)+coef(isub,3)
9984  & +coef(isub,4)+coef(isub,5)+coef(isub,6)+coef(isub,7)
9985  & +coefx(isub,1)) mtau=9
9986  ENDIF
9987  CALL pykmap(1,mtau,pyr(0))
9988 
9989 C...2 -> 3, 4 processes:
9990 C...Choose tau' according to h4(tau,tau')/tau', where
9991 C...h4(tau,tau') = c1 + I1/I2*c2*(1 - tau/tau')^3/tau' +
9992 C...I1/I3*c3*1/(1 - tau'), and c1 + c2 + c3 = 1.
9993  IF(istsb.GE.3.AND.istsb.LE.5) THEN
9994  CALL pyklim(4)
9995  IF(mint(51).NE.0) THEN
9996  IF(mint(121).GT.1) CALL pysave(2,iga)
9997  IF(mfail.EQ.1) THEN
9998  msti(61)=1
9999  RETURN
10000  ENDIF
10001  goto 100
10002  ENDIF
10003  rtaup=pyr(0)
10004  mtaup=1
10005  IF(rtaup.GT.coef(isub,18)) mtaup=2
10006  IF(rtaup.GT.coef(isub,18)+coef(isub,19)) mtaup=3
10007  CALL pykmap(4,mtaup,pyr(0))
10008  ENDIF
10009 
10010 C...Choose y* according to h2(y*), where
10011 C...h2(y*) = I0/I1*c1*(y*-y*min) + I0/I2*c2*(y*max-y*) +
10012 C...I0/I3*c3*1/cosh(y*) + I0/I4*c4*1/(1-exp(y*-y*max)) +
10013 C...I0/I5*c5*1/(1-exp(-y*-y*min)), I0 = y*max-y*min,
10014 C...and c1 + c2 + c3 + c4 + c5 = 1.
10015  CALL pyklim(2)
10016  IF(mint(51).NE.0) THEN
10017  IF(mint(121).GT.1) CALL pysave(2,iga)
10018  IF(mfail.EQ.1) THEN
10019  msti(61)=1
10020  RETURN
10021  ENDIF
10022  goto 100
10023  ENDIF
10024  ryst=pyr(0)
10025  myst=1
10026  IF(ryst.GT.coef(isub,8)) myst=2
10027  IF(ryst.GT.coef(isub,8)+coef(isub,9)) myst=3
10028  IF(ryst.GT.coef(isub,8)+coef(isub,9)+coef(isub,10)) myst=4
10029  IF(ryst.GT.coef(isub,8)+coef(isub,9)+coef(isub,10)+
10030  & coef(isub,11)) myst=5
10031  CALL pykmap(2,myst,pyr(0))
10032 
10033 C...2 -> 2 processes:
10034 C...Choose cos(theta-hat) (cth) according to h3(cth), where
10035 C...h3(cth) = c0 + I0/I1*c1*1/(A - cth) + I0/I2*c2*1/(A + cth) +
10036 C...I0/I3*c3*1/(A - cth)^2 + I0/I4*c4*1/(A + cth)^2,
10037 C...A = 1 + 2*(m3*m4/sh)^2 (= 1 for massless products),
10038 C...and c0 + c1 + c2 + c3 + c4 = 1.
10039  CALL pyklim(3)
10040  IF(mint(51).NE.0) THEN
10041  IF(mint(121).GT.1) CALL pysave(2,iga)
10042  IF(mfail.EQ.1) THEN
10043  msti(61)=1
10044  RETURN
10045  ENDIF
10046  goto 100
10047  ENDIF
10048  IF(istsb.EQ.2.OR.istsb.EQ.4) THEN
10049  rcth=pyr(0)
10050  mcth=1
10051  IF(rcth.GT.coef(isub,13)) mcth=2
10052  IF(rcth.GT.coef(isub,13)+coef(isub,14)) mcth=3
10053  IF(rcth.GT.coef(isub,13)+coef(isub,14)+coef(isub,15)) mcth=4
10054  IF(rcth.GT.coef(isub,13)+coef(isub,14)+coef(isub,15)+
10055  & coef(isub,16)) mcth=5
10056  CALL pykmap(3,mcth,pyr(0))
10057  ENDIF
10058 
10059 C...2 -> 3 : select pT1, phi1, pT2, phi2, y3 for 3 outgoing.
10060  IF(istsb.EQ.5) THEN
10061  CALL pykmap(5,0,0d0)
10062  IF(mint(51).NE.0) THEN
10063  IF(mint(121).GT.1) CALL pysave(2,iga)
10064  IF(mfail.EQ.1) THEN
10065  msti(61)=1
10066  RETURN
10067  ENDIF
10068  goto 100
10069  ENDIF
10070  ENDIF
10071 
10072 C...DIS as f + gamma* -> f process: set dummy values.
10073  ELSEIF(istsb.EQ.8) THEN
10074  vint(21)=0.9d0
10075  vint(22)=0d0
10076  vint(23)=0d0
10077  vint(47)=0d0
10078  vint(48)=0d0
10079 
10080 C...Low-pT or multiple interactions (first semihard interaction).
10081  ELSEIF(istsb.EQ.9) THEN
10082  IF(mint(35).LE.1) CALL pymult(3)
10083  IF(mint(35).GE.2) CALL pymign(3)
10084  isub=mint(1)
10085 
10086 C...Study user-defined process: kinematics plus weight.
10087  ELSEIF(istsb.EQ.11) THEN
10088  IF(idwtup.GT.0.AND.xwgtup.LT.0d0) CALL
10089  & pyerrm(26,'(PYRAND:) Negative XWGTUP for user process')
10090  msti(51)=0
10091  IF(nup.LE.0) THEN
10092  mint(51)=2
10093  msti(51)=1
10094  IF(mint(82).EQ.1) THEN
10095  ngen(0,1)=ngen(0,1)-1
10096  ngen(isub,1)=ngen(isub,1)-1
10097  ENDIF
10098  IF(mint(121).GT.1) CALL pysave(2,iga)
10099  RETURN
10100  ENDIF
10101 
10102 C...Extract cross section event weight.
10103  IF(iabs(idwtup).EQ.1.OR.iabs(idwtup).EQ.4) THEN
10104  sigs=1d-9*xwgtup
10105  ELSE
10106  sigs=1d-9*xsecup(kfpr(isub,1))
10107  ENDIF
10108  IF(iabs(idwtup).GE.1.AND.iabs(idwtup).LE.3) THEN
10109  vint(97)=sign(1d0,xwgtup)
10110  ELSE
10111  vint(97)=1d-9*xwgtup
10112  ENDIF
10113 
10114 C...Construct 'trivial' kinematical variables needed.
10115  kfl1=idup(1)
10116  kfl2=idup(2)
10117  vint(41)=pup(4,1)/ebmup(1)
10118  vint(42)=pup(4,2)/ebmup(2)
10119  IF (vint(41).GT.1.000001.OR.vint(42).GT.1.000001) THEN
10120  CALL pyerrm(9,'(PYRAND:) x > 1 in external event '//
10121  & '(listing follows):')
10122  CALL pylist(7)
10123  ENDIF
10124  vint(21)=vint(41)*vint(42)
10125  vint(22)=0.5d0*log(vint(41)/vint(42))
10126  vint(44)=vint(21)*vint(2)
10127  vint(43)=sqrt(max(0d0,vint(44)))
10128  vint(55)=scalup
10129  IF(scalup.LE.0d0) vint(55)=vint(43)
10130  vint(56)=vint(55)**2
10131  vint(57)=aqedup
10132  vint(58)=aqcdup
10133 
10134 C...Construct other kinematical variables needed (approximately).
10135  vint(23)=0d0
10136  vint(26)=vint(21)
10137  vint(45)=-0.5d0*vint(44)
10138  vint(46)=-0.5d0*vint(44)
10139  vint(49)=vint(43)
10140  vint(50)=vint(44)
10141  vint(51)=vint(55)
10142  vint(52)=vint(56)
10143  vint(53)=vint(55)
10144  vint(54)=vint(56)
10145  vint(25)=0d0
10146  vint(48)=0d0
10147  IF(istup(1).NE.-1.OR.istup(2).NE.-1) CALL pyerrm(26,
10148  & '(PYRAND:) unacceptable ISTUP code for incoming particles')
10149  DO 280 iup=3,nup
10150  IF(istup(iup).LT.1.OR.istup(iup).GT.3) CALL pyerrm(26,
10151  & '(PYRAND:) unacceptable ISTUP code for particles')
10152  IF(istup(iup).EQ.1) vint(25)=vint(25)+2d0*(pup(5,iup)**2+
10153  & pup(1,iup)**2+pup(2,iup)**2)/vint(2)
10154  IF(istup(iup).EQ.1) vint(48)=vint(48)+0.5d0*(pup(1,iup)**2+
10155  & pup(2,iup)**2)
10156  280 CONTINUE
10157  vint(47)=sqrt(vint(48))
10158  ENDIF
10159 
10160 C...Choose azimuthal angle.
10161  vint(24)=0d0
10162  IF(istsb.NE.11) vint(24)=paru(2)*pyr(0)
10163 
10164 C...Check against user cuts on kinematics at parton level.
10165  mint(51)=0
10166  IF((isub.LE.90.OR.isub.GT.100).AND.istsb.LE.10) CALL pyklim(0)
10167  IF(mint(51).NE.0) THEN
10168  IF(mint(121).GT.1) CALL pysave(2,iga)
10169  IF(mfail.EQ.1) THEN
10170  msti(61)=1
10171  RETURN
10172  ENDIF
10173  goto 100
10174  ENDIF
10175  IF(mint(82).EQ.1.AND.mstp(141).GE.1.AND.istsb.LE.10) THEN
10176  mcut=0
10177  IF(msub(91)+msub(92)+msub(93)+msub(94)+msub(95).EQ.0)
10178  & CALL pykcut(mcut)
10179  IF(mcut.NE.0) THEN
10180  IF(mint(121).GT.1) CALL pysave(2,iga)
10181  IF(mfail.EQ.1) THEN
10182  msti(61)=1
10183  RETURN
10184  ENDIF
10185  goto 100
10186  ENDIF
10187  ENDIF
10188 
10189  IF(istsb.LE.10) THEN
10190 C... If internal process, call PYSIGH
10191  CALL pysigh(nchn,sigs)
10192  ELSE
10193 C... If external process, still have to set MI starting scale
10194  IF (mstp(86).EQ.1) THEN
10195 C... Limit phase space by xT2 of hard interaction
10196 C... (gives undercounting of MI when ext proc != dijets)
10197  xt2gmx = vint(25)
10198  ELSE
10199 C... All accessible phase space allowed
10200 C... (gives double counting of MI when ext proc = dijets)
10201  xt2gmx = (1d0-vint(41))*(1d0-vint(42))
10202  ENDIF
10203  vint(62)=0.25d0*xt2gmx*vint(2)
10204  vint(61)=sqrt(max(0d0,vint(62)))
10205  ENDIF
10206 
10207  sigsor=sigs
10208  siglpt=sigt(0,0,5)*vint(315)*vint(316)
10209 
10210 C...Multiply cross section by lepton -> photon flux factor.
10211  IF(mint(141).NE.0.OR.mint(142).NE.0) THEN
10212  sigs=wtgaga*sigs
10213  DO 290 ichn=1,nchn
10214  sigh(ichn)=wtgaga*sigh(ichn)
10215  290 CONTINUE
10216  siglpt=wtgaga*siglpt
10217  ENDIF
10218 
10219 C...Multiply cross-section by user-defined weights.
10220  IF(mstp(173).EQ.1) THEN
10221  sigs=parp(173)*sigs
10222  DO 300 ichn=1,nchn
10223  sigh(ichn)=parp(173)*sigh(ichn)
10224  300 CONTINUE
10225  siglpt=parp(173)*siglpt
10226  ENDIF
10227  wtxs=1d0
10228  sigswt=sigs
10229  vint(99)=1d0
10230  vint(100)=1d0
10231  IF(mint(82).EQ.1.AND.mstp(142).GE.1) THEN
10232  IF(isub.NE.96.AND.msub(91)+msub(92)+msub(93)+msub(94)+
10233  & msub(95).EQ.0) CALL pyevwt(wtxs)
10234  sigswt=wtxs*sigs
10235  vint(99)=wtxs
10236  IF(mstp(142).EQ.1) vint(100)=1d0/wtxs
10237  ENDIF
10238 
10239 C...Calculations for Monte Carlo estimate of all cross-sections.
10240  IF(mint(82).EQ.1.AND.isub.LE.90.OR.isub.GE.96) THEN
10241  IF(mstp(142).LE.1) THEN
10242  xsec(isub,2)=xsec(isub,2)+sigs
10243  ELSE
10244  xsec(isub,2)=xsec(isub,2)+sigswt
10245  ENDIF
10246  ELSEIF(mint(82).EQ.1) THEN
10247  xsec(isub,2)=xsec(isub,2)+sigs
10248  ENDIF
10249  IF((isub.EQ.95.OR.isub.EQ.96).AND.loop2.EQ.1.AND.
10250  &mint(82).EQ.1) xsec(97,2)=xsec(97,2)+siglpt
10251 
10252 C...Multiple interactions: store results of cross-section calculation.
10253  IF(mint(50).EQ.1.AND.mstp(82).GE.3) THEN
10254  vint(153)=sigsor
10255  IF(mint(35).LE.1) CALL pymult(4)
10256  IF(mint(35).GE.2) CALL pymign(4)
10257  ENDIF
10258 
10259 C...Ratio of actual to maximum cross section.
10260  IF(istsb.NE.11) THEN
10261  viol=sigswt/xsec(isub,1)
10262  IF(isub.EQ.96.AND.mstp(173).EQ.1) viol=viol/parp(174)
10263  ELSEIF(idwtup.EQ.1.OR.idwtup.EQ.2) THEN
10264  viol=xwgtup/xmaxup(kfpr(isub,1))
10265  ELSEIF(idwtup.EQ.-1.OR.idwtup.EQ.-2) THEN
10266  viol=abs(xwgtup)/abs(xmaxup(kfpr(isub,1)))
10267  ELSE
10268  viol=1d0
10269  ENDIF
10270 
10271 C...Check that weight not negative.
10272  IF(mstp(123).LE.0) THEN
10273  IF(viol.LT.-1d-3) THEN
10274  WRITE(mstu(11),5000) viol,ngen(0,3)+1
10275  IF(mstp(122).GE.1) WRITE(mstu(11),5100) isub,vint(21),
10276  & vint(22),vint(23),vint(26)
10277  CALL pystop(2)
10278  ENDIF
10279  ELSE
10280  IF(viol.LT.min(-1d-3,vint(109))) THEN
10281  vint(109)=viol
10282  IF(mstp(123).LE.2) WRITE(mstu(11),5200) viol,ngen(0,3)+1
10283  IF(mstp(122).GE.1) WRITE(mstu(11),5100) isub,vint(21),
10284  & vint(22),vint(23),vint(26)
10285  ENDIF
10286  ENDIF
10287 
10288 C...Weighting using estimate of maximum of differential cross-section.
10289  ratnd=1d0
10290  IF(mfail.EQ.0.AND.isub.NE.95.AND.isub.NE.96) THEN
10291  IF(viol.LT.pyr(0)) THEN
10292  IF(mint(121).GT.1) CALL pysave(2,iga)
10293  IF(isub.GE.91.AND.isub.LE.94) isub=0
10294  goto 100
10295  ENDIF
10296  ELSEIF(mfail.EQ.0) THEN
10297  ratnd=siglpt/xsec(95,1)
10298  viol=viol/ratnd
10299  IF(loop2.EQ.1.AND.ratnd.LT.pyr(0)) THEN
10300  IF(viol.GT.pyr(0).AND.mint(82).EQ.1.AND.msub(95).EQ.1.AND.
10301  & (isub.LE.90.OR.isub.GE.95)) ngen(95,1)=ngen(95,1)+mint(143)
10302  IF(mint(121).GT.1) CALL pysave(2,iga)
10303  isub=0
10304  goto 100
10305  ENDIF
10306  IF(viol.LT.pyr(0)) THEN
10307  goto 140
10308  ENDIF
10309  ELSEIF(isub.NE.95.AND.isub.NE.96) THEN
10310  IF(viol.LT.pyr(0)) THEN
10311  msti(61)=1
10312  IF(mint(121).GT.1) CALL pysave(2,iga)
10313  RETURN
10314  ENDIF
10315  ELSE
10316  ratnd=siglpt/xsec(95,1)
10317  IF(loop.EQ.1.AND.ratnd.LT.pyr(0)) THEN
10318  msti(61)=1
10319  IF(mint(121).GT.1) CALL pysave(2,iga)
10320  RETURN
10321  ENDIF
10322  viol=viol/ratnd
10323  IF(viol.LT.pyr(0)) THEN
10324  IF(mint(121).GT.1) CALL pysave(2,iga)
10325  goto 100
10326  ENDIF
10327  ENDIF
10328 
10329 C...Check for possible violation of estimated maximum of differential
10330 C...cross-section used in weighting.
10331  IF(mstp(123).LE.0) THEN
10332  IF(viol.GT.1d0) THEN
10333  WRITE(mstu(11),5300) viol,ngen(0,3)+1
10334  IF(mstp(122).GE.2) WRITE(mstu(11),5100) isub,vint(21),
10335  & vint(22),vint(23),vint(26)
10336  CALL pystop(2)
10337  ENDIF
10338  ELSEIF(mstp(123).EQ.1) THEN
10339  IF(viol.GT.vint(108)) THEN
10340  vint(108)=viol
10341  IF(viol.GT.1.0001d0) THEN
10342  mint(10)=1
10343  WRITE(mstu(11),5400) viol,ngen(0,3)+1
10344  IF(mstp(122).GE.2) WRITE(mstu(11),5100) isub,vint(21),
10345  & vint(22),vint(23),vint(26)
10346  ENDIF
10347  ENDIF
10348  ELSEIF(viol.GT.vint(108)) THEN
10349  vint(108)=viol
10350  IF(viol.GT.1d0) THEN
10351  mint(10)=1
10352  IF(mstp(123).EQ.2) WRITE(mstu(11),5400) viol,ngen(0,3)+1
10353  IF(istsb.EQ.11.AND.(iabs(idwtup).EQ.1.OR.iabs(idwtup).EQ.2))
10354  & THEN
10355  xmaxup(kfpr(isub,1))=viol*xmaxup(kfpr(isub,1))
10356  IF(kfpr(isub,1).LE.9) THEN
10357  IF(mstp(123).EQ.2) WRITE(mstu(11),5800) kfpr(isub,1),
10358  & xmaxup(kfpr(isub,1))
10359  ELSEIF(kfpr(isub,1).LE.99) THEN
10360  IF(mstp(123).EQ.2) WRITE(mstu(11),5900) kfpr(isub,1),
10361  & xmaxup(kfpr(isub,1))
10362  ELSE
10363  IF(mstp(123).EQ.2) WRITE(mstu(11),6000) kfpr(isub,1),
10364  & xmaxup(kfpr(isub,1))
10365  ENDIF
10366  ENDIF
10367  IF(istsb.NE.11.OR.iabs(idwtup).EQ.1) THEN
10368  xdif=xsec(isub,1)*(viol-1d0)
10369  xsec(isub,1)=xsec(isub,1)+xdif
10370  IF(msub(isub).EQ.1.AND.(isub.LE.90.OR.isub.GT.96))
10371  & xsec(0,1)=xsec(0,1)+xdif
10372  IF(mstp(122).GE.2) WRITE(mstu(11),5100) isub,vint(21),
10373  & vint(22),vint(23),vint(26)
10374  IF(isub.LE.9) THEN
10375  IF(mstp(123).EQ.2) WRITE(mstu(11),5500) isub,xsec(isub,1)
10376  ELSEIF(isub.LE.99) THEN
10377  IF(mstp(123).EQ.2) WRITE(mstu(11),5600) isub,xsec(isub,1)
10378  ELSE
10379  IF(mstp(123).EQ.2) WRITE(mstu(11),5700) isub,xsec(isub,1)
10380  ENDIF
10381  ENDIF
10382  vint(108)=1d0
10383  ENDIF
10384  ENDIF
10385 
10386 C...Multiple interactions: choose impact parameter (if not already done).
10387  IF(mint(39).EQ.0) vint(148)=1d0
10388  IF(mint(50).EQ.1.AND.(isub.LE.90.OR.isub.GE.96).AND.
10389  &mstp(82).GE.3) THEN
10390  IF(mint(35).LE.1) CALL pymult(5)
10391  IF(mint(35).GE.2) CALL pymign(5)
10392  IF(vint(150).LT.pyr(0)) THEN
10393  IF(mint(121).GT.1) CALL pysave(2,iga)
10394  IF(mfail.EQ.1) THEN
10395  msti(61)=1
10396  RETURN
10397  ENDIF
10398  goto 100
10399  ENDIF
10400  ENDIF
10401  IF(mint(82).EQ.1) ngen(0,2)=ngen(0,2)+1
10402  IF(mint(82).EQ.1.AND.msub(95).EQ.1) THEN
10403  IF(isub.LE.90.OR.isub.GE.95) ngen(95,1)=ngen(95,1)+mint(143)
10404  IF(isub.LE.90.OR.isub.GE.96) ngen(96,2)=ngen(96,2)+1
10405  ENDIF
10406  IF(isub.LE.90.OR.isub.GE.96) mint(31)=mint(31)+1
10407 
10408 C...Choose flavour of reacting partons (and subprocess).
10409  IF(istsb.GE.11) goto 320
10410  rsigs=sigs*pyr(0)
10411  qt2=vint(48)
10412  rqqbar=parp(87)*(1d0-(qt2/(qt2+(parp(88)*parp(82)*
10413  &(vint(1)/parp(89))**parp(90))**2))**2)
10414  IF(isub.NE.95.AND.(isub.NE.96.OR.mstp(82).LE.1.OR.
10415  &pyr(0).GT.rqqbar)) THEN
10416  DO 310 ichn=1,nchn
10417  kfl1=isig(ichn,1)
10418  kfl2=isig(ichn,2)
10419  mint(2)=isig(ichn,3)
10420  rsigs=rsigs-sigh(ichn)
10421  IF(rsigs.LE.0d0) goto 320
10422  310 CONTINUE
10423 
10424 C...Multiple interactions: choose qqbar preferentially at small pT.
10425  ELSEIF(isub.EQ.96) THEN
10426  mint(105)=mint(103)
10427  mint(109)=mint(107)
10428  CALL pyspli(mint(11),21,kfl1,kfldum)
10429  mint(105)=mint(104)
10430  mint(109)=mint(108)
10431  CALL pyspli(mint(12),21,kfl2,kfldum)
10432  mint(1)=11
10433  mint(2)=1
10434  IF(kfl1.EQ.kfl2.AND.pyr(0).LT.0.5d0) mint(2)=2
10435 
10436 C...Low-pT: choose string drawing configuration.
10437  ELSE
10438  kfl1=21
10439  kfl2=21
10440  rsigs=6d0*pyr(0)
10441  mint(2)=1
10442  IF(rsigs.GT.1d0) mint(2)=2
10443  IF(rsigs.GT.2d0) mint(2)=3
10444  ENDIF
10445 
10446 C...Reassign QCD process. Partons before initial state radiation.
10447  320 IF(mint(2).GT.10) THEN
10448  mint(1)=mint(2)/10
10449  mint(2)=mod(mint(2),10)
10450  ENDIF
10451  IF(mint(82).EQ.1.AND.mstp(111).GE.0) ngen(mint(1),2)=
10452  &ngen(mint(1),2)+1
10453  mint(15)=kfl1
10454  mint(16)=kfl2
10455  mint(13)=mint(15)
10456  mint(14)=mint(16)
10457  vint(141)=vint(41)
10458  vint(142)=vint(42)
10459  vint(151)=0d0
10460  vint(152)=0d0
10461 
10462 C...Calculate x value of photon for parton inside photon inside e.
10463  DO 350 jt=1,2
10464  mint(18+jt)=0
10465  vint(154+jt)=0d0
10466  mspli=0
10467  IF(jt.EQ.1.AND.mint(43).LE.2) mspli=1
10468  IF(jt.EQ.2.AND.mod(mint(43),2).EQ.1) mspli=1
10469  IF(iabs(mint(14+jt)).LE.8.OR.mint(14+jt).EQ.21) mspli=mspli+1
10470  IF(mspli.EQ.2) THEN
10471  kflh=mint(14+jt)
10472  xhrd=vint(140+jt)
10473  q2hrd=vint(54)
10474  mint(105)=mint(102+jt)
10475  mint(109)=mint(106+jt)
10476  vint(120)=vint(2+jt)
10477  IF(mstp(57).LE.1) THEN
10478  CALL pypdfu(22,xhrd,q2hrd,xpq)
10479  ELSE
10480  CALL pypdfl(22,xhrd,q2hrd,xpq)
10481  ENDIF
10482  wtmx=4d0*xpq(kflh)
10483  IF(mstp(13).EQ.2) THEN
10484  q2pms=q2hrd/pmas(11,1)**2
10485  wtmx=wtmx*log(max(2d0,q2pms*(1d0-xhrd)/xhrd**2))
10486  ENDIF
10487  330 xe=xhrd**pyr(0)
10488  xg=min(1d0-1d-10,xhrd/xe)
10489  IF(mstp(57).LE.1) THEN
10490  CALL pypdfu(22,xg,q2hrd,xpq)
10491  ELSE
10492  CALL pypdfl(22,xg,q2hrd,xpq)
10493  ENDIF
10494  wt=(1d0+(1d0-xe)**2)*xpq(kflh)
10495  IF(mstp(13).EQ.2) wt=wt*log(max(2d0,q2pms*(1d0-xe)/xe**2))
10496  IF(wt.LT.pyr(0)*wtmx) goto 330
10497  mint(18+jt)=1
10498  vint(154+jt)=xe
10499  DO 340 kfls=-25,25
10500  xsfx(jt,kfls)=xpq(kfls)
10501  340 CONTINUE
10502  ENDIF
10503  350 CONTINUE
10504 
10505 C...Pick scale where photon is resolved.
10506  q0s=parp(15)**2
10507  q1s=vint(154)**2
10508  vint(283)=0d0
10509  IF(mint(107).EQ.3) THEN
10510  IF(mstp(66).EQ.1) THEN
10511  vint(283)=q0s*(vint(54)/q0s)**pyr(0)
10512  ELSEIF(mstp(66).EQ.2) THEN
10513  ps=vint(3)**2
10514  q2eff=vint(54)*((q0s+ps)/(vint(54)+ps))*
10515  & exp(ps*(vint(54)-q0s)/((vint(54)+ps)*(q0s+ps)))
10516  q2int=sqrt(q0s*q2eff)
10517  vint(283)=q2int*(vint(54)/q2int)**pyr(0)
10518  ELSEIF(mstp(66).EQ.3) THEN
10519  vint(283)=q0s*(q1s/q0s)**pyr(0)
10520  ELSEIF(mstp(66).GE.4) THEN
10521  ps=0.25d0*vint(3)**2
10522  vint(283)=(q0s+ps)*(q1s+ps)/
10523  & (q0s+pyr(0)*(q1s-q0s)+ps)-ps
10524  ENDIF
10525  ENDIF
10526  vint(284)=0d0
10527  IF(mint(108).EQ.3) THEN
10528  IF(mstp(66).EQ.1) THEN
10529  vint(284)=q0s*(vint(54)/q0s)**pyr(0)
10530  ELSEIF(mstp(66).EQ.2) THEN
10531  ps=vint(4)**2
10532  q2eff=vint(54)*((q0s+ps)/(vint(54)+ps))*
10533  & exp(ps*(vint(54)-q0s)/((vint(54)+ps)*(q0s+ps)))
10534  q2int=sqrt(q0s*q2eff)
10535  vint(284)=q2int*(vint(54)/q2int)**pyr(0)
10536  ELSEIF(mstp(66).EQ.3) THEN
10537  vint(284)=q0s*(q1s/q0s)**pyr(0)
10538  ELSEIF(mstp(66).GE.4) THEN
10539  ps=0.25d0*vint(4)**2
10540  vint(284)=(q0s+ps)*(q1s+ps)/
10541  & (q0s+pyr(0)*(q1s-q0s)+ps)-ps
10542  ENDIF
10543  ENDIF
10544  IF(mint(121).GT.1) CALL pysave(2,iga)
10545 
10546 C...Format statements for differential cross-section maximum violations.
10547  5000 FORMAT(/1x,'Error: negative cross-section fraction',1p,d11.3,1x,
10548  &'in event',1x,i7,'D0'/1x,'Execution stopped!')
10549  5100 FORMAT(1x,'ISUB = ',i3,'; Point of violation:'/1x,'tau =',1p,
10550  &d11.3,', y* =',d11.3,', cthe = ',0p,f11.7,', tau'' =',1p,d11.3)
10551  5200 FORMAT(/1x,'Warning: negative cross-section fraction',1p,d11.3,1x,
10552  &'in event',1x,i7)
10553  5300 FORMAT(/1x,'Error: maximum violated by',1p,d11.3,1x,
10554  &'in event',1x,i7,'D0'/1x,'Execution stopped!')
10555  5400 FORMAT(/1x,'Advisory warning: maximum violated by',1p,d11.3,1x,
10556  &'in event',1x,i7)
10557  5500 FORMAT(1x,'XSEC(',i1,',1) increased to',1p,d11.3)
10558  5600 FORMAT(1x,'XSEC(',i2,',1) increased to',1p,d11.3)
10559  5700 FORMAT(1x,'XSEC(',i3,',1) increased to',1p,d11.3)
10560  5800 FORMAT(1x,'XMAXUP(',i1,') increased to',1p,d11.3)
10561  5900 FORMAT(1x,'XMAXUP(',i2,') increased to',1p,d11.3)
10562  6000 FORMAT(1x,'XMAXUP(',i3,') increased to',1p,d11.3)
10563 
10564  RETURN
10565  END
10566 
10567 C*********************************************************************
10568 
10569 C...PYSCAT
10570 C...Finds outgoing flavours and event type; sets up the kinematics
10571 C...and colour flow of the hard scattering
10572 
10573  SUBROUTINE pyscat
10574 
10575 C...Double precision and integer declarations
10576  IMPLICIT DOUBLE PRECISION(a-h, o-z)
10577  IMPLICIT INTEGER(i-n)
10578  INTEGER pyk,pychge,pycomp
10579 C...Parameter statement to help give large particle numbers.
10580  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
10581  &kexcit=4000000,kdimen=5000000)
10582 C...Parameter statement for maximum size of showers.
10583  parameter(maxnur=1000)
10584 
10585 C...User process event common block.
10586  INTEGER maxnup
10587  parameter(maxnup=500)
10588  INTEGER nup,idprup,idup,istup,mothup,icolup
10589  DOUBLE PRECISION xwgtup,scalup,aqedup,aqcdup,pup,vtimup,spinup
10590  common/hepeup/nup,idprup,xwgtup,scalup,aqedup,aqcdup,idup(maxnup),
10591  &istup(maxnup),mothup(2,maxnup),icolup(2,maxnup),pup(5,maxnup),
10592  &vtimup(maxnup),spinup(maxnup)
10593  SAVE /hepeup/
10594 
10595 C...Commonblocks.
10596  common/pypart/npart,npartd,ipart(maxnur),ptpart(maxnur)
10597  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
10598  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
10599  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
10600  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
10601  common/pysubs/msel,mselpd,msub(500),kfin(2,-40:40),ckin(200)
10602  common/pypars/mstp(200),parp(200),msti(200),pari(200)
10603  common/pyint1/mint(400),vint(400)
10604  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
10605  common/pyint3/xsfx(2,-40:40),isig(1000,3),sigh(1000)
10606  common/pyint4/mwid(500),wids(500,5)
10607  common/pyint5/ngenpd,ngen(0:500,3),xsec(0:500,3)
10608  common/pyssmt/zmix(4,4),umix(2,2),vmix(2,2),smz(4),smw(2),
10609  &sfmix(16,4),zmixi(4,4),umixi(2,2),vmixi(2,2)
10610  common/pytcsm/itcm(0:99),rtcm(0:99)
10611  common/pypued/iued(0:99),rued(0:99)
10612  SAVE /pypart/,/pyjets/,/pydat1/,/pydat2/,/pydat3/,/pysubs/,
10613  &/pypars/,/pyint1/,/pyint2/,/pyint3/,/pyint4/,/pyint5/,/pyssmt/,
10614  &/pytcsm/,/pypued/
10615 C...Local arrays and saved variables
10616  dimension wdtp(0:400),wdte(0:400,0:5),pmq(2),z(2),cthe(2),
10617  &phi(2),kuppo(100),vintsv(41:66),ilab(100)
10618  INTEGER iokfla(6),iiflav
10619 C...UED related declarations:
10620 C...equivalences between ordered particles (451->475)
10621 C...and UED particle code (5 000 000 + id)
10622  dimension iuedeq(475),mued(2)
10623  DATA (iuedeq(i),i=451,475)/
10624  & 6100001,6100002,6100003,6100004,6100005,6100006,
10625  & 5100001,5100002,5100003,5100004,5100005,5100006,
10626  & 6100011,6100013,6100015,
10627  & 5100012,5100011,5100014,5100013,5100016,5100015,
10628  & 5100021,5100022,5100023,5100024/
10629  SAVE vintsv
10630 
10631 C...Read out process
10632  isub=mint(1)
10633  isubsv=isub
10634 
10635 C...Restore information for low-pT processes
10636  IF(isub.EQ.95.AND.mint(57).GE.1) THEN
10637  DO 100 j=41,66
10638  100 vint(j)=vintsv(j)
10639  ENDIF
10640 
10641 C...Convert H' or A process into equivalent H one
10642  ihigg=1
10643  kfhigg=25
10644  IF((isub.GE.151.AND.isub.LE.160).OR.(isub.GE.171.AND.
10645  &isub.LE.190)) THEN
10646  ihigg=2
10647  IF(mod(isub-1,10).GE.5) ihigg=3
10648  kfhigg=33+ihigg
10649  IF(isub.EQ.151.OR.isub.EQ.156) isub=3
10650  IF(isub.EQ.152.OR.isub.EQ.157) isub=102
10651  IF(isub.EQ.153.OR.isub.EQ.158) isub=103
10652  IF(isub.EQ.171.OR.isub.EQ.176) isub=24
10653  IF(isub.EQ.172.OR.isub.EQ.177) isub=26
10654  IF(isub.EQ.173.OR.isub.EQ.178) isub=123
10655  IF(isub.EQ.174.OR.isub.EQ.179) isub=124
10656  IF(isub.EQ.181.OR.isub.EQ.186) isub=121
10657  IF(isub.EQ.182.OR.isub.EQ.187) isub=122
10658  IF(isub.EQ.183.OR.isub.EQ.188) isub=111
10659  IF(isub.EQ.184.OR.isub.EQ.189) isub=112
10660  IF(isub.EQ.185.OR.isub.EQ.190) isub=113
10661  ENDIF
10662 
10663  IF(isub.EQ.401.OR.isub.EQ.402) kfhigg=kfpr(isub,1)
10664 
10665 C...Convert bottomonium process into equivalent charmonium ones.
10666  IF(isub.GE.461.AND.isub.LE.479) isub=isub-40
10667 
10668 C...Choice of subprocess, number of documentation lines
10669  idoc=6+iset(isub)
10670  IF(isub.EQ.95) idoc=8
10671  IF(iset(isub).EQ.5) idoc=9
10672  IF(iset(isub).EQ.11) idoc=4+nup
10673  mint(3)=idoc-6
10674  IF(idoc.GE.9.AND.iset(isub).LE.4) idoc=idoc+2
10675  mint(4)=idoc
10676  ipu1=mint(84)+1
10677  ipu2=mint(84)+2
10678  ipu3=mint(84)+3
10679  ipu4=mint(84)+4
10680  ipu5=mint(84)+5
10681  ipu6=mint(84)+6
10682 
10683 C...Reset K, P and V vectors. Store incoming particles
10684  DO 120 jt=1,mstp(126)+100
10685  i=mint(83)+jt
10686  IF(i.GT.mstu(4)) goto 120
10687  DO 110 j=1,5
10688  k(i,j)=0
10689  p(i,j)=0d0
10690  v(i,j)=0d0
10691  110 CONTINUE
10692  120 CONTINUE
10693  DO 140 jt=1,2
10694  i=mint(83)+jt
10695  k(i,1)=21
10696  k(i,2)=mint(10+jt)
10697  DO 130 j=1,5
10698  p(i,j)=vint(285+5*jt+j)
10699  130 CONTINUE
10700  140 CONTINUE
10701  mint(6)=2
10702  kfres=0
10703 
10704 C...Store incoming partons in their CM-frame. Save pdf value.
10705  sh=vint(44)
10706  shr=sqrt(sh)
10707  shp=vint(26)*vint(2)
10708  shpr=sqrt(shp)
10709  shuser=shr
10710  IF(iset(isub).GE.3.AND.iset(isub).LE.5) shuser=shpr
10711  DO 150 jt=1,2
10712  i=mint(84)+jt
10713  k(i,1)=14
10714  k(i,2)=mint(14+jt)
10715  k(i,3)=mint(83)+2+jt
10716  p(i,3)=0.5d0*shuser*(-1d0)**(jt-1)
10717  p(i,4)=0.5d0*shuser
10718  IF(mint(14+jt).GE.-40.AND.mint(14+jt).LE.40) THEN
10719  vint(38+jt)=xsfx(jt,mint(14+jt))
10720  ELSE
10721  vint(38+jt)=1d0
10722  ENDIF
10723  150 CONTINUE
10724 
10725 C...Copy incoming partons to documentation lines
10726  DO 170 jt=1,2
10727  i1=mint(83)+4+jt
10728  i2=mint(84)+jt
10729  k(i1,1)=21
10730  k(i1,2)=k(i2,2)
10731  k(i1,3)=i1-2
10732  DO 160 j=1,5
10733  p(i1,j)=p(i2,j)
10734  160 CONTINUE
10735  170 CONTINUE
10736 
10737 C...Choose new quark/lepton flavour for relevant annihilation graphs
10738  IF(isub.EQ.12.OR.isub.EQ.53.OR.isub.EQ.54.OR.isub.EQ.58.OR.
10739  &isub.EQ.314.OR.isub.EQ.319.OR.isub.EQ.316.OR.
10740  &(isub.GE.135.AND.isub.LE.140).OR.isub.EQ.382.OR.isub.EQ.385) THEN
10741  iglga=21
10742  IF(isub.EQ.58.OR.(isub.GE.137.AND.isub.LE.140)) iglga=22
10743  CALL pywidt(iglga,sh,wdtp,wdte)
10744  180 rkfl=(wdte(0,1)+wdte(0,2)+wdte(0,4))*pyr(0)
10745  DO 190 i=1,mdcy(iglga,3)
10746  kflf=kfdp(i+mdcy(iglga,2)-1,1)
10747  rkfl=rkfl-(wdte(i,1)+wdte(i,2)+wdte(i,4))
10748  IF(rkfl.LE.0d0) goto 200
10749  190 CONTINUE
10750  200 CONTINUE
10751  IF((isub.EQ.53.OR.isub.EQ.385.OR.isub.EQ.314.OR.isub.EQ.319
10752  & .OR.isub.EQ.316).AND.mint(2).LE.2) THEN
10753  IF(kflf.GE.4) goto 180
10754  ELSEIF((isub.EQ.53.OR.isub.EQ.385.OR.isub.EQ.314.OR.isub.EQ.319.
10755  & or.isub.EQ.316).AND.mint(2).LE.4) THEN
10756  kflf=4
10757  mint(2)=mint(2)-2
10758  ELSEIF(isub.EQ.53.OR.isub.EQ.385.OR.isub.EQ.314.OR.isub.EQ.319.
10759  & or.isub.EQ.316) THEN
10760  kflf=5
10761  mint(2)=mint(2)-4
10762  ELSEIF(isub.EQ.382.AND.itcm(5).EQ.1.AND.iabs(mint(15)).LE.2
10763  & .AND.iabs(kflf).GE.3) THEN
10764  facqqb=vint(58)**2*4d0/9d0*(vint(45)**2+vint(46)**2)/
10765  & vint(44)**2
10766  faccib=vint(46)**2/rtcm(41)**4
10767  IF(facqqb/(facqqb+faccib).LT.pyr(0)) goto 180
10768  ELSEIF(isub.EQ.382.AND.itcm(5).EQ.5.AND.mint(2).EQ.2) THEN
10769  kflf=5
10770  mint(2)=1
10771  ELSEIF(isub.EQ.382.AND.itcm(5).EQ.5.AND.mint(2).EQ.1) THEN
10772  IF(kflf.EQ.5) goto 180
10773  ELSEIF(isub.EQ.54.OR.isub.EQ.135.OR.isub.EQ.136) THEN
10774  IF((kchg(pycomp(kflf),1)/2d0)**2.LT.pyr(0)) goto 180
10775  ELSEIF(isub.EQ.58.OR.(isub.GE.137.AND.isub.LE.140)) THEN
10776  IF((kchg(pycomp(kflf),1)/3d0)**2.LT.pyr(0)) goto 180
10777  ENDIF
10778  ENDIF
10779 
10780 C...Final state flavours and colour flow: default values
10781  js=1
10782  mint(21)=mint(15)
10783  mint(22)=mint(16)
10784  mint(23)=0
10785  mint(24)=0
10786  kcc=20
10787  kcs=isign(1,mint(15))
10788 
10789  IF(iset(isub).EQ.11) THEN
10790 C...User-defined processes: find products
10791  mint(3)=0
10792  DO 210 iup=3,nup
10793  IF(istup(iup).LT.1.OR.istup(iup).GT.3) THEN
10794  ELSEIF(nup.EQ.5.AND.iup.GE.4.AND.mothup(1,4).EQ.3) THEN
10795  mint(21+iup)=idup(iup)
10796  ELSEIF(istup(iup).EQ.1.AND.(istup(mothup(1,iup)).EQ.2.OR.
10797  & istup(mothup(1,iup)).EQ.3).AND.idup(mothup(1,iup)).NE.0) THEN
10798  ELSEIF(idup(iup).EQ.0) THEN
10799  ELSE
10800  mint(3)=mint(3)+1
10801  IF(mint(3).LE.6) mint(20+mint(3))=idup(iup)
10802  ENDIF
10803  210 CONTINUE
10804 
10805  ELSEIF(isub.LE.10) THEN
10806  IF(isub.EQ.1) THEN
10807 C...f + fbar -> gamma*/Z0
10808  kfres=23
10809 
10810  ELSEIF(isub.EQ.2) THEN
10811 C...f + fbar' -> W+/-
10812  kch1=kchg(iabs(mint(15)),1)*isign(1,mint(15))
10813  kch2=kchg(iabs(mint(16)),1)*isign(1,mint(16))
10814  kfres=isign(24,kch1+kch2)
10815 
10816  ELSEIF(isub.EQ.3) THEN
10817 C...f + fbar -> h0 (or H0, or A0)
10818  kfres=kfhigg
10819 
10820  ELSEIF(isub.EQ.4) THEN
10821 C...gamma + W+/- -> W+/-
10822 
10823  ELSEIF(isub.EQ.5) THEN
10824 C...Z0 + Z0 -> h0
10825  xh=sh/shp
10826  mint(21)=mint(15)
10827  mint(22)=mint(16)
10828  pmq(1)=pymass(mint(21))
10829  pmq(2)=pymass(mint(22))
10830  220 jt=int(1.5d0+pyr(0))
10831  zmin=2d0*pmq(jt)/shpr
10832  zmax=1d0-pmq(3-jt)/shpr-(sh-pmq(jt)**2)/
10833  & (shpr*(shpr-pmq(3-jt)))
10834  zmax=min(1d0-xh,zmax)
10835  z(jt)=zmin+(zmax-zmin)*pyr(0)
10836  IF(-1d0+(1d0+xh)/(1d0-z(jt))-xh/(1d0-z(jt))**2.LT.
10837  & (1d0-xh)**2/(4d0*xh)*pyr(0)) goto 220
10838  sqc1=1d0-4d0*pmq(jt)**2/(z(jt)**2*shp)
10839  IF(sqc1.LT.1d-8) goto 220
10840  c1=sqrt(sqc1)
10841  c2=1d0+2d0*(pmas(23,1)**2-pmq(jt)**2)/(z(jt)*shp)
10842  cthe(jt)=(c2-(c2**2-c1**2)/(c2+(2d0*pyr(0)-1d0)*c1))/c1
10843  cthe(jt)=min(1d0,max(-1d0,cthe(jt)))
10844  z(3-jt)=1d0-xh/(1d0-z(jt))
10845  sqc1=1d0-4d0*pmq(3-jt)**2/(z(3-jt)**2*shp)
10846  IF(sqc1.LT.1d-8) goto 220
10847  c1=sqrt(sqc1)
10848  c2=1d0+2d0*(pmas(23,1)**2-pmq(3-jt)**2)/(z(3-jt)*shp)
10849  cthe(3-jt)=(c2-(c2**2-c1**2)/(c2+(2d0*pyr(0)-1d0)*c1))/c1
10850  cthe(3-jt)=min(1d0,max(-1d0,cthe(3-jt)))
10851  phir=paru(2)*pyr(0)
10852  cphi=cos(phir)
10853  ang=cthe(1)*cthe(2)-sqrt(1d0-cthe(1)**2)*
10854  & sqrt(1d0-cthe(2)**2)*cphi
10855  z1=2d0-z(jt)
10856  z2=ang*sqrt(z(jt)**2-4d0*pmq(jt)**2/shp)
10857  z3=1d0-z(jt)-xh+(pmq(1)**2+pmq(2)**2)/shp
10858  z(3-jt)=2d0/(z1**2-z2**2)*(z1*z3+z2*sqrt(z3**2-(z1**2-z2**2)*
10859  & pmq(3-jt)**2/shp))
10860  zmin=2d0*pmq(3-jt)/shpr
10861  zmax=1d0-pmq(jt)/shpr-(sh-pmq(3-jt)**2)/(shpr*(shpr-pmq(jt)))
10862  zmax=min(1d0-xh,zmax)
10863  IF(z(3-jt).LT.zmin.OR.z(3-jt).GT.zmax) goto 220
10864  kcc=22
10865  kfres=25
10866 
10867  ELSEIF(isub.EQ.6) THEN
10868 C...Z0 + W+/- -> W+/-
10869 
10870  ELSEIF(isub.EQ.7) THEN
10871 C...W+ + W- -> Z0
10872 
10873  ELSEIF(isub.EQ.8) THEN
10874 C...W+ + W- -> h0
10875  xh=sh/shp
10876  230 DO 260 jt=1,2
10877  i=mint(14+jt)
10878  ia=iabs(i)
10879  IF(ia.LE.10) THEN
10880  rvckm=vint(180+i)*pyr(0)
10881  DO 240 j=1,mstp(1)
10882  ib=2*j-1+mod(ia,2)
10883  ipm=(5-isign(1,i))/2
10884  idc=j+mdcy(ia,2)+2
10885  IF(mdme(idc,1).NE.1.AND.mdme(idc,1).NE.ipm) goto 240
10886  mint(20+jt)=isign(ib,i)
10887  rvckm=rvckm-vckm((ia+1)/2,(ib+1)/2)
10888  IF(rvckm.LE.0d0) goto 250
10889  240 CONTINUE
10890  ELSE
10891  ib=2*((ia+1)/2)-1+mod(ia,2)
10892  mint(20+jt)=isign(ib,i)
10893  ENDIF
10894  250 pmq(jt)=pymass(mint(20+jt))
10895  260 CONTINUE
10896  jt=int(1.5d0+pyr(0))
10897  zmin=2d0*pmq(jt)/shpr
10898  zmax=1d0-pmq(3-jt)/shpr-(sh-pmq(jt)**2)/
10899  & (shpr*(shpr-pmq(3-jt)))
10900  zmax=min(1d0-xh,zmax)
10901  IF(zmin.GE.zmax) goto 230
10902  z(jt)=zmin+(zmax-zmin)*pyr(0)
10903  IF(-1d0+(1d0+xh)/(1d0-z(jt))-xh/(1d0-z(jt))**2.LT.
10904  & (1d0-xh)**2/(4d0*xh)*pyr(0)) goto 230
10905  sqc1=1d0-4d0*pmq(jt)**2/(z(jt)**2*shp)
10906  IF(sqc1.LT.1d-8) goto 230
10907  c1=sqrt(sqc1)
10908  c2=1d0+2d0*(pmas(24,1)**2-pmq(jt)**2)/(z(jt)*shp)
10909  cthe(jt)=(c2-(c2**2-c1**2)/(c2+(2d0*pyr(0)-1d0)*c1))/c1
10910  cthe(jt)=min(1d0,max(-1d0,cthe(jt)))
10911  z(3-jt)=1d0-xh/(1d0-z(jt))
10912  sqc1=1d0-4d0*pmq(3-jt)**2/(z(3-jt)**2*shp)
10913  IF(sqc1.LT.1d-8) goto 230
10914  c1=sqrt(sqc1)
10915  c2=1d0+2d0*(pmas(24,1)**2-pmq(3-jt)**2)/(z(3-jt)*shp)
10916  cthe(3-jt)=(c2-(c2**2-c1**2)/(c2+(2d0*pyr(0)-1d0)*c1))/c1
10917  cthe(3-jt)=min(1d0,max(-1d0,cthe(3-jt)))
10918  phir=paru(2)*pyr(0)
10919  cphi=cos(phir)
10920  ang=cthe(1)*cthe(2)-sqrt(1d0-cthe(1)**2)*
10921  & sqrt(1d0-cthe(2)**2)*cphi
10922  z1=2d0-z(jt)
10923  z2=ang*sqrt(z(jt)**2-4d0*pmq(jt)**2/shp)
10924  z3=1d0-z(jt)-xh+(pmq(1)**2+pmq(2)**2)/shp
10925  z(3-jt)=2d0/(z1**2-z2**2)*(z1*z3+z2*sqrt(z3**2-(z1**2-z2**2)*
10926  & pmq(3-jt)**2/shp))
10927  zmin=2d0*pmq(3-jt)/shpr
10928  zmax=1d0-pmq(jt)/shpr-(sh-pmq(3-jt)**2)/(shpr*(shpr-pmq(jt)))
10929  zmax=min(1d0-xh,zmax)
10930  IF(z(3-jt).LT.zmin.OR.z(3-jt).GT.zmax) goto 230
10931  kcc=22
10932  kfres=25
10933 
10934  ELSEIF(isub.EQ.10) THEN
10935 C...f + f' -> f + f' (gamma/Z/W exchange); th = (p(f)-p(f))**2
10936  IF(mint(2).EQ.1) THEN
10937  kcc=22
10938  ELSE
10939 C...W exchange: need to mix flavours according to CKM matrix
10940  DO 280 jt=1,2
10941  i=mint(14+jt)
10942  ia=iabs(i)
10943  IF(ia.LE.10) THEN
10944  rvckm=vint(180+i)*pyr(0)
10945  DO 270 j=1,mstp(1)
10946  ib=2*j-1+mod(ia,2)
10947  ipm=(5-isign(1,i))/2
10948  idc=j+mdcy(ia,2)+2
10949  IF(mdme(idc,1).NE.1.AND.mdme(idc,1).NE.ipm) goto 270
10950  mint(20+jt)=isign(ib,i)
10951  rvckm=rvckm-vckm((ia+1)/2,(ib+1)/2)
10952  IF(rvckm.LE.0d0) goto 280
10953  270 CONTINUE
10954  ELSE
10955  ib=2*((ia+1)/2)-1+mod(ia,2)
10956  mint(20+jt)=isign(ib,i)
10957  ENDIF
10958  280 CONTINUE
10959  kcc=22
10960  ENDIF
10961  ENDIF
10962 
10963  ELSEIF(isub.LE.20) THEN
10964  IF(isub.EQ.11) THEN
10965 C...f + f' -> f + f' (g exchange); th = (p(f)-p(f))**2
10966  kcc=mint(2)
10967  IF(mint(15)*mint(16).LT.0) kcc=kcc+2
10968 
10969  ELSEIF(isub.EQ.12) THEN
10970 C...f + fbar -> f' + fbar'; th = (p(f)-p(f'))**2
10971  mint(21)=isign(kflf,mint(15))
10972  mint(22)=-mint(21)
10973  kcc=4
10974 
10975  ELSEIF(isub.EQ.13) THEN
10976 C...f + fbar -> g + g; th arbitrary
10977  mint(21)=21
10978  mint(22)=21
10979  kcc=mint(2)+4
10980 
10981  ELSEIF(isub.EQ.14) THEN
10982 C...f + fbar -> g + gamma; th arbitrary
10983  IF(pyr(0).GT.0.5d0) js=2
10984  mint(20+js)=21
10985  mint(23-js)=22
10986  kcc=17+js
10987 
10988  ELSEIF(isub.EQ.15) THEN
10989 C...f + fbar -> g + Z0; th arbitrary
10990  IF(pyr(0).GT.0.5d0) js=2
10991  mint(20+js)=21
10992  mint(23-js)=23
10993  kcc=17+js
10994 
10995  ELSEIF(isub.EQ.16) THEN
10996 C...f + fbar' -> g + W+/-; th = (p(f)-p(W-))**2 or (p(fbar')-p(W+))**2
10997  kch1=kchg(iabs(mint(15)),1)*isign(1,mint(15))
10998  kch2=kchg(iabs(mint(16)),1)*isign(1,mint(16))
10999  IF(mint(15)*(kch1+kch2).LT.0) js=2
11000  mint(20+js)=21
11001  mint(23-js)=isign(24,kch1+kch2)
11002  kcc=17+js
11003 
11004  ELSEIF(isub.EQ.17) THEN
11005 C...f + fbar -> g + h0; th arbitrary
11006  IF(pyr(0).GT.0.5d0) js=2
11007  mint(20+js)=21
11008  mint(23-js)=25
11009  kcc=17+js
11010 
11011  ELSEIF(isub.EQ.18) THEN
11012 C...f + fbar -> gamma + gamma; th arbitrary
11013  mint(21)=22
11014  mint(22)=22
11015 
11016  ELSEIF(isub.EQ.19) THEN
11017 C...f + fbar -> gamma + Z0; th arbitrary
11018  IF(pyr(0).GT.0.5d0) js=2
11019  mint(20+js)=22
11020  mint(23-js)=23
11021 
11022  ELSEIF(isub.EQ.20) THEN
11023 C...f + fbar' -> gamma + W+/-; th = (p(f)-p(W-))**2 or
11024 C...(p(fbar')-p(W+))**2
11025  kch1=kchg(iabs(mint(15)),1)*isign(1,mint(15))
11026  kch2=kchg(iabs(mint(16)),1)*isign(1,mint(16))
11027  IF(mint(15)*(kch1+kch2).LT.0) js=2
11028  mint(20+js)=22
11029  mint(23-js)=isign(24,kch1+kch2)
11030  ENDIF
11031 
11032  ELSEIF(isub.LE.30) THEN
11033  IF(isub.EQ.21) THEN
11034 C...f + fbar -> gamma + h0; th arbitrary
11035  IF(pyr(0).GT.0.5d0) js=2
11036  mint(20+js)=22
11037  mint(23-js)=25
11038 
11039  ELSEIF(isub.EQ.22) THEN
11040 C...f + fbar -> Z0 + Z0; th arbitrary
11041  mint(21)=23
11042  mint(22)=23
11043 
11044  ELSEIF(isub.EQ.23) THEN
11045 C...f + fbar' -> Z0 + W+/-; th = (p(f)-p(W-))**2 or (p(fbar')-p(W+))**2
11046  kch1=kchg(iabs(mint(15)),1)*isign(1,mint(15))
11047  kch2=kchg(iabs(mint(16)),1)*isign(1,mint(16))
11048  IF(mint(15)*(kch1+kch2).LT.0) js=2
11049  mint(20+js)=23
11050  mint(23-js)=isign(24,kch1+kch2)
11051 
11052  ELSEIF(isub.EQ.24) THEN
11053 C...f + fbar -> Z0 + h0 (or H0, or A0); th arbitrary
11054  IF(pyr(0).GT.0.5d0) js=2
11055  mint(20+js)=23
11056  mint(23-js)=kfhigg
11057 
11058  ELSEIF(isub.EQ.25) THEN
11059 C...f + fbar -> W+ + W-; th = (p(f)-p(W-))**2
11060  mint(21)=-isign(24,mint(15))
11061  mint(22)=-mint(21)
11062 
11063  ELSEIF(isub.EQ.26) THEN
11064 C...f + fbar' -> W+/- + h0 (or H0, or A0);
11065 C...th = (p(f)-p(W-))**2 or (p(fbar')-p(W+))**2
11066  kch1=kchg(iabs(mint(15)),1)*isign(1,mint(15))
11067  kch2=kchg(iabs(mint(16)),1)*isign(1,mint(16))
11068  IF(mint(15)*(kch1+kch2).GT.0) js=2
11069  mint(20+js)=isign(24,kch1+kch2)
11070  mint(23-js)=kfhigg
11071 
11072  ELSEIF(isub.EQ.27) THEN
11073 C...f + fbar -> h0 + h0
11074 
11075  ELSEIF(isub.EQ.28) THEN
11076 C...f + g -> f + g; th = (p(f)-p(f))**2
11077  IF(mint(15).EQ.21) js=2
11078  kcc=mint(2)+6
11079  IF(mint(15).EQ.21) kcc=kcc+2
11080  IF(mint(15).NE.21) kcs=isign(1,mint(15))
11081  IF(mint(16).NE.21) kcs=isign(1,mint(16))
11082 
11083  ELSEIF(isub.EQ.29) THEN
11084 C...f + g -> f + gamma; th = (p(f)-p(f))**2
11085  IF(mint(15).EQ.21) js=2
11086  mint(23-js)=22
11087  kcc=15+js
11088  kcs=isign(1,mint(14+js))
11089 
11090  ELSEIF(isub.EQ.30) THEN
11091 C...f + g -> f + Z0; th = (p(f)-p(f))**2
11092  IF(mint(15).EQ.21) js=2
11093  mint(23-js)=23
11094  kcc=15+js
11095  kcs=isign(1,mint(14+js))
11096  ENDIF
11097 
11098  ELSEIF(isub.LE.40) THEN
11099  IF(isub.EQ.31) THEN
11100 C...f + g -> f' + W+/-; th = (p(f)-p(f'))**2; choose flavour f'
11101  IF(mint(15).EQ.21) js=2
11102  i=mint(14+js)
11103  ia=iabs(i)
11104  mint(23-js)=isign(24,kchg(ia,1)*i)
11105  rvckm=vint(180+i)*pyr(0)
11106  DO 290 j=1,mstp(1)
11107  ib=2*j-1+mod(ia,2)
11108  ipm=(5-isign(1,i))/2
11109  idc=j+mdcy(ia,2)+2
11110  IF(mdme(idc,1).NE.1.AND.mdme(idc,1).NE.ipm) goto 290
11111  mint(20+js)=isign(ib,i)
11112  rvckm=rvckm-vckm((ia+1)/2,(ib+1)/2)
11113  IF(rvckm.LE.0d0) goto 300
11114  290 CONTINUE
11115  300 kcc=15+js
11116  kcs=isign(1,mint(14+js))
11117 
11118  ELSEIF(isub.EQ.32) THEN
11119 C...f + g -> f + h0; th = (p(f)-p(f))**2
11120  IF(mint(15).EQ.21) js=2
11121  mint(23-js)=25
11122  kcc=15+js
11123  kcs=isign(1,mint(14+js))
11124 
11125  ELSEIF(isub.EQ.33) THEN
11126 C...f + gamma -> f + g; th=(p(f)-p(f))**2
11127  IF(mint(15).EQ.22) js=2
11128  mint(23-js)=21
11129  kcc=24+js
11130  kcs=isign(1,mint(14+js))
11131 
11132  ELSEIF(isub.EQ.34) THEN
11133 C...f + gamma -> f + gamma; th=(p(f)-p(f))**2
11134  IF(mint(15).EQ.22) js=2
11135  kcc=22
11136  kcs=isign(1,mint(14+js))
11137 
11138  ELSEIF(isub.EQ.35) THEN
11139 C...f + gamma -> f + Z0; th=(p(f)-p(f))**2
11140  IF(mint(15).EQ.22) js=2
11141  mint(23-js)=23
11142  kcc=22
11143 
11144  ELSEIF(isub.EQ.36) THEN
11145 C...f + gamma -> f' + W+/-; th=(p(f)-p(f'))**2
11146  IF(mint(15).EQ.22) js=2
11147  i=mint(14+js)
11148  ia=iabs(i)
11149  mint(23-js)=isign(24,kchg(ia,1)*i)
11150  IF(ia.LE.10) THEN
11151  rvckm=vint(180+i)*pyr(0)
11152  DO 310 j=1,mstp(1)
11153  ib=2*j-1+mod(ia,2)
11154  ipm=(5-isign(1,i))/2
11155  idc=j+mdcy(ia,2)+2
11156  IF(mdme(idc,1).NE.1.AND.mdme(idc,1).NE.ipm) goto 310
11157  mint(20+js)=isign(ib,i)
11158  rvckm=rvckm-vckm((ia+1)/2,(ib+1)/2)
11159  IF(rvckm.LE.0d0) goto 320
11160  310 CONTINUE
11161  ELSE
11162  ib=2*((ia+1)/2)-1+mod(ia,2)
11163  mint(20+js)=isign(ib,i)
11164  ENDIF
11165  320 kcc=22
11166 
11167  ELSEIF(isub.EQ.37) THEN
11168 C...f + gamma -> f + h0
11169 
11170  ELSEIF(isub.EQ.38) THEN
11171 C...f + Z0 -> f + g
11172 
11173  ELSEIF(isub.EQ.39) THEN
11174 C...f + Z0 -> f + gamma
11175 
11176  ELSEIF(isub.EQ.40) THEN
11177 C...f + Z0 -> f + Z0
11178  ENDIF
11179 
11180  ELSEIF(isub.LE.50) THEN
11181  IF(isub.EQ.41) THEN
11182 C...f + Z0 -> f' + W+/-
11183 
11184  ELSEIF(isub.EQ.42) THEN
11185 C...f + Z0 -> f + h0
11186 
11187  ELSEIF(isub.EQ.43) THEN
11188 C...f + W+/- -> f' + g
11189 
11190  ELSEIF(isub.EQ.44) THEN
11191 C...f + W+/- -> f' + gamma
11192 
11193  ELSEIF(isub.EQ.45) THEN
11194 C...f + W+/- -> f' + Z0
11195 
11196  ELSEIF(isub.EQ.46) THEN
11197 C...f + W+/- -> f' + W+/-
11198 
11199  ELSEIF(isub.EQ.47) THEN
11200 C...f + W+/- -> f' + h0
11201 
11202  ELSEIF(isub.EQ.48) THEN
11203 C...f + h0 -> f + g
11204 
11205  ELSEIF(isub.EQ.49) THEN
11206 C...f + h0 -> f + gamma
11207 
11208  ELSEIF(isub.EQ.50) THEN
11209 C...f + h0 -> f + Z0
11210  ENDIF
11211 
11212  ELSEIF(isub.LE.60) THEN
11213  IF(isub.EQ.51) THEN
11214 C...f + h0 -> f' + W+/-
11215 
11216  ELSEIF(isub.EQ.52) THEN
11217 C...f + h0 -> f + h0
11218 
11219  ELSEIF(isub.EQ.53) THEN
11220 C...g + g -> f + fbar; th arbitrary
11221  kcs=(-1)**int(1.5d0+pyr(0))
11222  mint(21)=isign(kflf,kcs)
11223  mint(22)=-mint(21)
11224  kcc=mint(2)+10
11225 
11226  ELSEIF(isub.EQ.54) THEN
11227 C...g + gamma -> f + fbar; th arbitrary
11228  kcs=(-1)**int(1.5d0+pyr(0))
11229  mint(21)=isign(kflf,kcs)
11230  mint(22)=-mint(21)
11231  kcc=27
11232  IF(mint(16).EQ.21) kcc=28
11233 
11234  ELSEIF(isub.EQ.55) THEN
11235 C...g + Z0 -> f + fbar
11236 
11237  ELSEIF(isub.EQ.56) THEN
11238 C...g + W+/- -> f + fbar'
11239 
11240  ELSEIF(isub.EQ.57) THEN
11241 C...g + h0 -> f + fbar
11242 
11243  ELSEIF(isub.EQ.58) THEN
11244 C...gamma + gamma -> f + fbar; th arbitrary
11245  kcs=(-1)**int(1.5d0+pyr(0))
11246  mint(21)=isign(kflf,kcs)
11247  mint(22)=-mint(21)
11248  kcc=21
11249 
11250  ELSEIF(isub.EQ.59) THEN
11251 C...gamma + Z0 -> f + fbar
11252 
11253  ELSEIF(isub.EQ.60) THEN
11254 C...gamma + W+/- -> f + fbar'
11255  ENDIF
11256 
11257  ELSEIF(isub.LE.70) THEN
11258  IF(isub.EQ.61) THEN
11259 C...gamma + h0 -> f + fbar
11260 
11261  ELSEIF(isub.EQ.62) THEN
11262 C...Z0 + Z0 -> f + fbar
11263 
11264  ELSEIF(isub.EQ.63) THEN
11265 C...Z0 + W+/- -> f + fbar'
11266 
11267  ELSEIF(isub.EQ.64) THEN
11268 C...Z0 + h0 -> f + fbar
11269 
11270  ELSEIF(isub.EQ.65) THEN
11271 C...W+ + W- -> f + fbar
11272 
11273  ELSEIF(isub.EQ.66) THEN
11274 C...W+/- + h0 -> f + fbar'
11275 
11276  ELSEIF(isub.EQ.67) THEN
11277 C...h0 + h0 -> f + fbar
11278 
11279  ELSEIF(isub.EQ.68) THEN
11280 C...g + g -> g + g; th arbitrary
11281  kcc=mint(2)+12
11282  kcs=(-1)**int(1.5d0+pyr(0))
11283 
11284  ELSEIF(isub.EQ.69) THEN
11285 C...gamma + gamma -> W+ + W-; th arbitrary
11286  mint(21)=24
11287  mint(22)=-24
11288  kcc=21
11289 
11290  ELSEIF(isub.EQ.70) THEN
11291 C...gamma + W+/- -> Z0 + W+/-; th=(p(W)-p(W))**2
11292  IF(mint(15).EQ.22) mint(21)=23
11293  IF(mint(16).EQ.22) mint(22)=23
11294  kcc=21
11295  ENDIF
11296 
11297  ELSEIF(isub.LE.80) THEN
11298  IF(isub.EQ.71.OR.isub.EQ.72) THEN
11299 C...Z0 + Z0 -> Z0 + Z0; Z0 + Z0 -> W+ + W-
11300  xh=sh/shp
11301  mint(21)=mint(15)
11302  mint(22)=mint(16)
11303  pmq(1)=pymass(mint(21))
11304  pmq(2)=pymass(mint(22))
11305  330 jt=int(1.5d0+pyr(0))
11306  zmin=2d0*pmq(jt)/shpr
11307  zmax=1d0-pmq(3-jt)/shpr-(sh-pmq(jt)**2)/
11308  & (shpr*(shpr-pmq(3-jt)))
11309  zmax=min(1d0-xh,zmax)
11310  z(jt)=zmin+(zmax-zmin)*pyr(0)
11311  IF(-1d0+(1d0+xh)/(1d0-z(jt))-xh/(1d0-z(jt))**2.LT.
11312  & (1d0-xh)**2/(4d0*xh)*pyr(0)) goto 330
11313  sqc1=1d0-4d0*pmq(jt)**2/(z(jt)**2*shp)
11314  IF(sqc1.LT.1d-8) goto 330
11315  c1=sqrt(sqc1)
11316  c2=1d0+2d0*(pmas(23,1)**2-pmq(jt)**2)/(z(jt)*shp)
11317  cthe(jt)=(c2-(c2**2-c1**2)/(c2+(2d0*pyr(0)-1d0)*c1))/c1
11318  cthe(jt)=min(1d0,max(-1d0,cthe(jt)))
11319  z(3-jt)=1d0-xh/(1d0-z(jt))
11320  sqc1=1d0-4d0*pmq(3-jt)**2/(z(3-jt)**2*shp)
11321  IF(sqc1.LT.1d-8) goto 330
11322  c1=sqrt(sqc1)
11323  c2=1d0+2d0*(pmas(23,1)**2-pmq(3-jt)**2)/(z(3-jt)*shp)
11324  cthe(3-jt)=(c2-(c2**2-c1**2)/(c2+(2d0*pyr(0)-1d0)*c1))/c1
11325  cthe(3-jt)=min(1d0,max(-1d0,cthe(3-jt)))
11326  phir=paru(2)*pyr(0)
11327  cphi=cos(phir)
11328  ang=cthe(1)*cthe(2)-sqrt(1d0-cthe(1)**2)*
11329  & sqrt(1d0-cthe(2)**2)*cphi
11330  z1=2d0-z(jt)
11331  z2=ang*sqrt(z(jt)**2-4d0*pmq(jt)**2/shp)
11332  z3=1d0-z(jt)-xh+(pmq(1)**2+pmq(2)**2)/shp
11333  z(3-jt)=2d0/(z1**2-z2**2)*(z1*z3+z2*sqrt(z3**2-(z1**2-z2**2)*
11334  & pmq(3-jt)**2/shp))
11335  zmin=2d0*pmq(3-jt)/shpr
11336  zmax=1d0-pmq(jt)/shpr-(sh-pmq(3-jt)**2)/(shpr*(shpr-pmq(jt)))
11337  zmax=min(1d0-xh,zmax)
11338  IF(z(3-jt).LT.zmin.OR.z(3-jt).GT.zmax) goto 330
11339  kcc=22
11340 
11341  ELSEIF(isub.EQ.73) THEN
11342 C...Z0 + W+/- -> Z0 + W+/-
11343  js=mint(2)
11344  xh=sh/shp
11345  340 jt=3-mint(2)
11346  i=mint(14+jt)
11347  ia=iabs(i)
11348  IF(ia.LE.10) THEN
11349  rvckm=vint(180+i)*pyr(0)
11350  DO 350 j=1,mstp(1)
11351  ib=2*j-1+mod(ia,2)
11352  ipm=(5-isign(1,i))/2
11353  idc=j+mdcy(ia,2)+2
11354  IF(mdme(idc,1).NE.1.AND.mdme(idc,1).NE.ipm) goto 350
11355  mint(20+jt)=isign(ib,i)
11356  rvckm=rvckm-vckm((ia+1)/2,(ib+1)/2)
11357  IF(rvckm.LE.0d0) goto 360
11358  350 CONTINUE
11359  ELSE
11360  ib=2*((ia+1)/2)-1+mod(ia,2)
11361  mint(20+jt)=isign(ib,i)
11362  ENDIF
11363  360 pmq(jt)=pymass(mint(20+jt))
11364  mint(23-jt)=mint(17-jt)
11365  pmq(3-jt)=pymass(mint(23-jt))
11366  jt=int(1.5d0+pyr(0))
11367  zmin=2d0*pmq(jt)/shpr
11368  zmax=1d0-pmq(3-jt)/shpr-(sh-pmq(jt)**2)/
11369  & (shpr*(shpr-pmq(3-jt)))
11370  zmax=min(1d0-xh,zmax)
11371  IF(zmin.GE.zmax) goto 340
11372  z(jt)=zmin+(zmax-zmin)*pyr(0)
11373  IF(-1d0+(1d0+xh)/(1d0-z(jt))-xh/(1d0-z(jt))**2.LT.
11374  & (1d0-xh)**2/(4d0*xh)*pyr(0)) goto 340
11375  sqc1=1d0-4d0*pmq(jt)**2/(z(jt)**2*shp)
11376  IF(sqc1.LT.1d-8) goto 340
11377  c1=sqrt(sqc1)
11378  c2=1d0+2d0*(pmas(23,1)**2-pmq(jt)**2)/(z(jt)*shp)
11379  cthe(jt)=(c2-(c2**2-c1**2)/(c2+(2d0*pyr(0)-1d0)*c1))/c1
11380  cthe(jt)=min(1d0,max(-1d0,cthe(jt)))
11381  z(3-jt)=1d0-xh/(1d0-z(jt))
11382  sqc1=1d0-4d0*pmq(3-jt)**2/(z(3-jt)**2*shp)
11383  IF(sqc1.LT.1d-8) goto 340
11384  c1=sqrt(sqc1)
11385  c2=1d0+2d0*(pmas(23,1)**2-pmq(3-jt)**2)/(z(3-jt)*shp)
11386  cthe(3-jt)=(c2-(c2**2-c1**2)/(c2+(2d0*pyr(0)-1d0)*c1))/c1
11387  cthe(3-jt)=min(1d0,max(-1d0,cthe(3-jt)))
11388  phir=paru(2)*pyr(0)
11389  cphi=cos(phir)
11390  ang=cthe(1)*cthe(2)-sqrt(1d0-cthe(1)**2)*
11391  & sqrt(1d0-cthe(2)**2)*cphi
11392  z1=2d0-z(jt)
11393  z2=ang*sqrt(z(jt)**2-4d0*pmq(jt)**2/shp)
11394  z3=1d0-z(jt)-xh+(pmq(1)**2+pmq(2)**2)/shp
11395  z(3-jt)=2d0/(z1**2-z2**2)*(z1*z3+z2*sqrt(z3**2-(z1**2-z2**2)*
11396  & pmq(3-jt)**2/shp))
11397  zmin=2d0*pmq(3-jt)/shpr
11398  zmax=1d0-pmq(jt)/shpr-(sh-pmq(3-jt)**2)/(shpr*(shpr-pmq(jt)))
11399  zmax=min(1d0-xh,zmax)
11400  IF(z(3-jt).LT.zmin.OR.z(3-jt).GT.zmax) goto 340
11401  kcc=22
11402 
11403  ELSEIF(isub.EQ.74) THEN
11404 C...Z0 + h0 -> Z0 + h0
11405 
11406  ELSEIF(isub.EQ.75) THEN
11407 C...W+ + W- -> gamma + gamma
11408 
11409  ELSEIF(isub.EQ.76.OR.isub.EQ.77) THEN
11410 C...W+ + W- -> Z0 + Z0; W+ + W- -> W+ + W-
11411  xh=sh/shp
11412  370 DO 400 jt=1,2
11413  i=mint(14+jt)
11414  ia=iabs(i)
11415  IF(ia.LE.10) THEN
11416  rvckm=vint(180+i)*pyr(0)
11417  DO 380 j=1,mstp(1)
11418  ib=2*j-1+mod(ia,2)
11419  ipm=(5-isign(1,i))/2
11420  idc=j+mdcy(ia,2)+2
11421  IF(mdme(idc,1).NE.1.AND.mdme(idc,1).NE.ipm) goto 380
11422  mint(20+jt)=isign(ib,i)
11423  rvckm=rvckm-vckm((ia+1)/2,(ib+1)/2)
11424  IF(rvckm.LE.0d0) goto 390
11425  380 CONTINUE
11426  ELSE
11427  ib=2*((ia+1)/2)-1+mod(ia,2)
11428  mint(20+jt)=isign(ib,i)
11429  ENDIF
11430  390 pmq(jt)=pymass(mint(20+jt))
11431  400 CONTINUE
11432  jt=int(1.5d0+pyr(0))
11433  zmin=2d0*pmq(jt)/shpr
11434  zmax=1d0-pmq(3-jt)/shpr-(sh-pmq(jt)**2)/
11435  & (shpr*(shpr-pmq(3-jt)))
11436  zmax=min(1d0-xh,zmax)
11437  IF(zmin.GE.zmax) goto 370
11438  z(jt)=zmin+(zmax-zmin)*pyr(0)
11439  IF(-1d0+(1d0+xh)/(1d0-z(jt))-xh/(1d0-z(jt))**2.LT.
11440  & (1d0-xh)**2/(4d0*xh)*pyr(0)) goto 370
11441  sqc1=1d0-4d0*pmq(jt)**2/(z(jt)**2*shp)
11442  IF(sqc1.LT.1d-8) goto 370
11443  c1=sqrt(sqc1)
11444  c2=1d0+2d0*(pmas(24,1)**2-pmq(jt)**2)/(z(jt)*shp)
11445  cthe(jt)=(c2-(c2**2-c1**2)/(c2+(2d0*pyr(0)-1d0)*c1))/c1
11446  cthe(jt)=min(1d0,max(-1d0,cthe(jt)))
11447  z(3-jt)=1d0-xh/(1d0-z(jt))
11448  sqc1=1d0-4d0*pmq(3-jt)**2/(z(3-jt)**2*shp)
11449  IF(sqc1.LT.1d-8) goto 370
11450  c1=sqrt(sqc1)
11451  c2=1d0+2d0*(pmas(24,1)**2-pmq(3-jt)**2)/(z(3-jt)*shp)
11452  cthe(3-jt)=(c2-(c2**2-c1**2)/(c2+(2d0*pyr(0)-1d0)*c1))/c1
11453  cthe(3-jt)=min(1d0,max(-1d0,cthe(3-jt)))
11454  phir=paru(2)*pyr(0)
11455  cphi=cos(phir)
11456  ang=cthe(1)*cthe(2)-sqrt(1d0-cthe(1)**2)*
11457  & sqrt(1d0-cthe(2)**2)*cphi
11458  z1=2d0-z(jt)
11459  z2=ang*sqrt(z(jt)**2-4d0*pmq(jt)**2/shp)
11460  z3=1d0-z(jt)-xh+(pmq(1)**2+pmq(2)**2)/shp
11461  z(3-jt)=2d0/(z1**2-z2**2)*(z1*z3+z2*sqrt(z3**2-(z1**2-z2**2)*
11462  & pmq(3-jt)**2/shp))
11463  zmin=2d0*pmq(3-jt)/shpr
11464  zmax=1d0-pmq(jt)/shpr-(sh-pmq(3-jt)**2)/(shpr*(shpr-pmq(jt)))
11465  zmax=min(1d0-xh,zmax)
11466  IF(z(3-jt).LT.zmin.OR.z(3-jt).GT.zmax) goto 370
11467  kcc=22
11468 
11469  ELSEIF(isub.EQ.78) THEN
11470 C...W+/- + h0 -> W+/- + h0
11471 
11472  ELSEIF(isub.EQ.79) THEN
11473 C...h0 + h0 -> h0 + h0
11474 
11475  ELSEIF(isub.EQ.80) THEN
11476 C...q + gamma -> q' + pi+/-; th=(p(q)-p(q'))**2
11477  IF(mint(15).EQ.22) js=2
11478  i=mint(14+js)
11479  ia=iabs(i)
11480  mint(23-js)=isign(211,kchg(ia,1)*i)
11481  ib=3-ia
11482  mint(20+js)=isign(ib,i)
11483  kcc=22
11484  ENDIF
11485 
11486  ELSEIF(isub.LE.90) THEN
11487  IF(isub.EQ.81) THEN
11488 C...q + qbar -> Q + Qbar; th = (p(q)-p(Q))**2
11489  mint(21)=isign(mint(55),mint(15))
11490  mint(22)=-mint(21)
11491  kcc=4
11492 
11493  ELSEIF(isub.EQ.82) THEN
11494 C...g + g -> Q + Qbar; th arbitrary
11495  kcs=(-1)**int(1.5d0+pyr(0))
11496  mint(21)=isign(mint(55),kcs)
11497  mint(22)=-mint(21)
11498  kcc=mint(2)+10
11499 
11500  ELSEIF(isub.EQ.83) THEN
11501 C...f + q -> f' + Q; th = (p(f) - p(f'))**2
11502  kfold=mint(16)
11503  IF(mint(2).EQ.2) kfold=mint(15)
11504  kfaold=iabs(kfold)
11505  IF(kfaold.GT.10) THEN
11506  kfanew=kfaold+2*mod(kfaold,2)-1
11507  ELSE
11508  rckm=vint(180+kfold)*pyr(0)
11509  ipm=(5-isign(1,kfold))/2
11510  kfanew=-mod(kfaold+1,2)
11511  410 kfanew=kfanew+2
11512  idc=mdcy(kfaold,2)+(kfanew+1)/2+2
11513  IF(mdme(idc,1).EQ.1.OR.mdme(idc,1).EQ.ipm) THEN
11514  IF(mod(kfaold,2).EQ.0) rckm=rckm-
11515  & vckm(kfaold/2,(kfanew+1)/2)
11516  IF(mod(kfaold,2).EQ.1) rckm=rckm-
11517  & vckm(kfanew/2,(kfaold+1)/2)
11518  ENDIF
11519  IF(kfanew.LE.6.AND.rckm.GT.0d0) goto 410
11520  ENDIF
11521  IF(mint(2).EQ.1) THEN
11522  mint(21)=isign(mint(55),mint(15))
11523  mint(22)=isign(kfanew,mint(16))
11524  ELSE
11525  mint(21)=isign(kfanew,mint(15))
11526  mint(22)=isign(mint(55),mint(16))
11527  js=2
11528  ENDIF
11529  kcc=22
11530 
11531  ELSEIF(isub.EQ.84) THEN
11532 C...g + gamma -> Q + Qbar; th arbitary
11533  kcs=(-1)**int(1.5d0+pyr(0))
11534  mint(21)=isign(mint(55),kcs)
11535  mint(22)=-mint(21)
11536  kcc=27
11537  IF(mint(16).EQ.21) kcc=28
11538 
11539  ELSEIF(isub.EQ.85) THEN
11540 C...gamma + gamma -> F + Fbar; th arbitary
11541  kcs=(-1)**int(1.5d0+pyr(0))
11542  mint(21)=isign(mint(56),kcs)
11543  mint(22)=-mint(21)
11544  kcc=21
11545 
11546  ELSEIF(isub.GE.86.AND.isub.LE.89) THEN
11547 C...g + g -> (J/Psi, chi_0c, chi_1c or chi_2c) + g
11548  mint(21)=kfpr(isub,1)
11549  mint(22)=kfpr(isub,2)
11550  kcc=24
11551  kcs=(-1)**int(1.5d0+pyr(0))
11552  ENDIF
11553 
11554  ELSEIF(isub.LE.100) THEN
11555  IF(isub.EQ.95) THEN
11556 C...Low-pT ( = energyless g + g -> g + g)
11557  kcc=mint(2)+12
11558  kcs=(-1)**int(1.5d0+pyr(0))
11559 
11560  ELSEIF(isub.EQ.96) THEN
11561 C...Multiple interactions (should be reassigned to QCD process)
11562  ENDIF
11563 
11564  ELSEIF(isub.LE.110) THEN
11565  IF(isub.EQ.101) THEN
11566 C...g + g -> gamma*/Z0
11567  kcc=21
11568  kfres=22
11569 
11570  ELSEIF(isub.EQ.102) THEN
11571 C...g + g -> h0 (or H0, or A0)
11572  kcc=21
11573  kfres=kfhigg
11574 
11575  ELSEIF(isub.EQ.103) THEN
11576 C...gamma + gamma -> h0 (or H0, or A0)
11577  kcc=21
11578  kfres=kfhigg
11579 
11580  ELSEIF(isub.EQ.104.OR.isub.EQ.105) THEN
11581 C...g + g -> chi_0c or chi_2c.
11582  kcc=21
11583  kfres=kfpr(isub,1)
11584 
11585  ELSEIF(isub.EQ.106) THEN
11586 C...g + g -> J/Psi + gamma
11587  mint(21)=kfpr(isub,1)
11588  mint(22)=kfpr(isub,2)
11589  kcc=21
11590 
11591  ELSEIF(isub.EQ.107) THEN
11592 C...g + gamma -> J/Psi + g
11593  mint(21)=kfpr(isub,1)
11594  mint(22)=kfpr(isub,2)
11595  kcc=22
11596  IF(mint(16).EQ.22) kcc=33
11597 
11598  ELSEIF(isub.EQ.108) THEN
11599 C...gamma + gamma -> J/Psi + gamma
11600  mint(21)=kfpr(isub,1)
11601  mint(22)=kfpr(isub,2)
11602 
11603  ELSEIF(isub.EQ.110) THEN
11604 C...f + fbar -> gamma + h0; th arbitrary
11605  IF(pyr(0).GT.0.5d0) js=2
11606  mint(20+js)=22
11607  mint(23-js)=kfhigg
11608  ENDIF
11609 
11610  ELSEIF(isub.LE.120) THEN
11611  IF(isub.EQ.111) THEN
11612 C...f + fbar -> g + h0; th arbitrary
11613  IF(pyr(0).GT.0.5d0) js=2
11614  mint(20+js)=21
11615  mint(23-js)=kfhigg
11616  kcc=17+js
11617 
11618  ELSEIF(isub.EQ.112) THEN
11619 C...f + g -> f + h0; th = (p(f) - p(f))**2
11620  IF(mint(15).EQ.21) js=2
11621  mint(23-js)=kfhigg
11622  kcc=15+js
11623  kcs=isign(1,mint(14+js))
11624 
11625  ELSEIF(isub.EQ.113) THEN
11626 C...g + g -> g + h0; th arbitrary
11627  IF(pyr(0).GT.0.5d0) js=2
11628  mint(23-js)=kfhigg
11629  kcc=22+js
11630  kcs=(-1)**int(1.5d0+pyr(0))
11631 
11632  ELSEIF(isub.EQ.114) THEN
11633 C...g + g -> gamma + gamma; th arbitrary
11634  IF(pyr(0).GT.0.5d0) js=2
11635  mint(21)=22
11636  mint(22)=22
11637  kcc=21
11638 
11639  ELSEIF(isub.EQ.115) THEN
11640 C...g + g -> g + gamma; th arbitrary
11641  IF(pyr(0).GT.0.5d0) js=2
11642  mint(23-js)=22
11643  kcc=22+js
11644  kcs=(-1)**int(1.5d0+pyr(0))
11645 
11646  ELSEIF(isub.EQ.116) THEN
11647 C...g + g -> gamma + Z0
11648 
11649  ELSEIF(isub.EQ.117) THEN
11650 C...g + g -> Z0 + Z0
11651 
11652  ELSEIF(isub.EQ.118) THEN
11653 C...g + g -> W+ + W-
11654  ENDIF
11655 
11656  ELSEIF(isub.LE.140) THEN
11657  IF(isub.EQ.121) THEN
11658 C...g + g -> Q + Qbar + h0
11659  kcs=(-1)**int(1.5d0+pyr(0))
11660  mint(21)=isign(kfpr(isubsv,2),kcs)
11661  mint(22)=-mint(21)
11662  kcc=11+int(0.5d0+pyr(0))
11663  kfres=kfhigg
11664 
11665  ELSEIF(isub.EQ.122) THEN
11666 C...q + qbar -> Q + Qbar + h0
11667  mint(21)=isign(kfpr(isubsv,2),mint(15))
11668  mint(22)=-mint(21)
11669  kcc=4
11670  kfres=kfhigg
11671 
11672  ELSEIF(isub.EQ.123) THEN
11673 C...f + f' -> f + f' + h0 (or H0, or A0) (Z0 + Z0 -> h0 as
11674 C...inner process)
11675  kcc=22
11676  kfres=kfhigg
11677 
11678  ELSEIF(isub.EQ.124) THEN
11679 C...f + f' -> f" + f"' + h0 (or H0, or A) (W+ + W- -> h0 as
11680 C...inner process)
11681  DO 430 jt=1,2
11682  i=mint(14+jt)
11683  ia=iabs(i)
11684  IF(ia.LE.10) THEN
11685  rvckm=vint(180+i)*pyr(0)
11686  DO 420 j=1,mstp(1)
11687  ib=2*j-1+mod(ia,2)
11688  ipm=(5-isign(1,i))/2
11689  idc=j+mdcy(ia,2)+2
11690  IF(mdme(idc,1).NE.1.AND.mdme(idc,1).NE.ipm) goto 420
11691  mint(20+jt)=isign(ib,i)
11692  rvckm=rvckm-vckm((ia+1)/2,(ib+1)/2)
11693  IF(rvckm.LE.0d0) goto 430
11694  420 CONTINUE
11695  ELSE
11696  ib=2*((ia+1)/2)-1+mod(ia,2)
11697  mint(20+jt)=isign(ib,i)
11698  ENDIF
11699  430 CONTINUE
11700  kcc=22
11701  kfres=kfhigg
11702 
11703  ELSEIF(isub.EQ.131.OR.isub.EQ.132) THEN
11704 C...f + gamma*_(T,L) -> f + g; th=(p(f)-p(f))**2
11705  IF(mint(15).EQ.22) js=2
11706  mint(23-js)=21
11707  kcc=24+js
11708  kcs=isign(1,mint(14+js))
11709 
11710  ELSEIF(isub.EQ.133.OR.isub.EQ.134) THEN
11711 C...f + gamma*_(T,L) -> f + gamma; th=(p(f)-p(f))**2
11712  IF(mint(15).EQ.22) js=2
11713  kcc=22
11714  kcs=isign(1,mint(14+js))
11715 
11716  ELSEIF(isub.EQ.135.OR.isub.EQ.136) THEN
11717 C...g + gamma*_(T,L) -> f + fbar; th arbitrary
11718  kcs=(-1)**int(1.5d0+pyr(0))
11719  mint(21)=isign(kflf,kcs)
11720  mint(22)=-mint(21)
11721  kcc=27
11722  IF(mint(16).EQ.21) kcc=28
11723 
11724  ELSEIF(isub.GE.137.AND.isub.LE.140) THEN
11725 C...gamma*_(T,L) + gamma*_(T,L) -> f + fbar; th arbitrary
11726  kcs=(-1)**int(1.5d0+pyr(0))
11727  mint(21)=isign(kflf,kcs)
11728  mint(22)=-mint(21)
11729  kcc=21
11730 
11731  ENDIF
11732 
11733  ELSEIF(isub.LE.160) THEN
11734  IF(isub.EQ.141) THEN
11735 C...f + fbar -> gamma*/Z0/Z'0
11736  kfres=32
11737 
11738  ELSEIF(isub.EQ.142) THEN
11739 C...f + fbar' -> W'+/-
11740  kch1=kchg(iabs(mint(15)),1)*isign(1,mint(15))
11741  kch2=kchg(iabs(mint(16)),1)*isign(1,mint(16))
11742  kfres=isign(34,kch1+kch2)
11743 
11744  ELSEIF(isub.EQ.143) THEN
11745 C...f + fbar' -> H+/-
11746  kch1=kchg(iabs(mint(15)),1)*isign(1,mint(15))
11747  kch2=kchg(iabs(mint(16)),1)*isign(1,mint(16))
11748  kfres=isign(37,kch1+kch2)
11749 
11750  ELSEIF(isub.EQ.144) THEN
11751 C...f + fbar' -> R
11752  kfres=isign(41,mint(15)+mint(16))
11753 
11754  ELSEIF(isub.EQ.145) THEN
11755 C...q + l -> LQ (leptoquark)
11756  IF(iabs(mint(16)).LE.8) js=2
11757  kfres=isign(42,mint(14+js))
11758  kcc=28+js
11759  kcs=isign(1,mint(14+js))
11760 
11761  ELSEIF(isub.EQ.146) THEN
11762 C...e + gamma -> e* (excited lepton)
11763  IF(mint(15).EQ.22) js=2
11764  kfres=isign(kfpr(isub,1),mint(14+js))
11765  kcc=22
11766 
11767  ELSEIF(isub.EQ.147.OR.isub.EQ.148) THEN
11768 C...q + g -> q* (excited quark)
11769  IF(mint(15).EQ.21) js=2
11770  kfres=isign(kfpr(isub,1),mint(14+js))
11771  kcc=30+js
11772  kcs=isign(1,mint(14+js))
11773 
11774  ELSEIF(isub.EQ.149) THEN
11775 C...g + g -> eta_tc
11776  kfres=ktechn+331
11777  kcc=23
11778  kcs=(-1)**int(1.5d0+pyr(0))
11779  ENDIF
11780 
11781  ELSEIF(isub.LE.200) THEN
11782  IF(isub.EQ.161) THEN
11783 C...f + g -> f' + H+/-; th = (p(f)-p(f'))**2
11784  IF(mint(15).EQ.21) js=2
11785  i=mint(14+js)
11786  ia=iabs(i)
11787  mint(23-js)=isign(37,kchg(ia,1)*i)
11788  ib=ia+mod(ia,2)-mod(ia+1,2)
11789  mint(20+js)=isign(ib,i)
11790  kcc=15+js
11791  kcs=isign(1,mint(14+js))
11792 
11793  ELSEIF(isub.EQ.162) THEN
11794 C...q + g -> LQ + lbar; LQ=leptoquark; th=(p(q)-p(LQ))^2
11795  IF(mint(15).EQ.21) js=2
11796  mint(20+js)=isign(42,mint(14+js))
11797  kflql=kfdp(mdcy(42,2),2)
11798  mint(23-js)=-isign(kflql,mint(14+js))
11799  kcc=15+js
11800  kcs=isign(1,mint(14+js))
11801 
11802  ELSEIF(isub.EQ.163) THEN
11803 C...g + g -> LQ + LQbar; LQ=leptoquark; th arbitrary
11804  kcs=(-1)**int(1.5d0+pyr(0))
11805  mint(21)=isign(42,kcs)
11806  mint(22)=-mint(21)
11807  kcc=mint(2)+10
11808 
11809  ELSEIF(isub.EQ.164) THEN
11810 C...q + qbar -> LQ + LQbar; LQ=leptoquark; th=(p(q)-p(LQ))**2
11811  mint(21)=isign(42,mint(15))
11812  mint(22)=-mint(21)
11813  kcc=4
11814 
11815  ELSEIF(isub.EQ.165) THEN
11816 C...q + qbar -> l- + l+; th=(p(q)-p(l-))**2
11817  mint(21)=isign(kfpr(isub,1),mint(15))
11818  mint(22)=-mint(21)
11819 
11820  ELSEIF(isub.EQ.166) THEN
11821 C...q + qbar' -> l + nu; th=(p(u)-p(nu))**2 or (p(ubar)-p(nubar))**2
11822  IF(mod(mint(15),2).EQ.0) THEN
11823  mint(21)=isign(kfpr(isub,1)+1,mint(15))
11824  mint(22)=isign(kfpr(isub,1),mint(16))
11825  ELSE
11826  mint(21)=isign(kfpr(isub,1),mint(15))
11827  mint(22)=isign(kfpr(isub,1)+1,mint(16))
11828  ENDIF
11829 
11830  ELSEIF(isub.EQ.167.OR.isub.EQ.168) THEN
11831 C...q + q' -> q" + q* (excited quark)
11832  kfqstr=kfpr(isub,2)
11833  kfqexc=mod(kfqstr,kexcit)
11834  js=mint(2)
11835  mint(20+js)=isign(kfqstr,mint(14+js))
11836  IF(iabs(mint(15)).NE.kfqexc.AND.iabs(mint(16)).NE.kfqexc)
11837  & mint(23-js)=isign(kfqexc,mint(17-js))
11838  kcc=22
11839  js=3-js
11840 
11841  ELSEIF(isub.EQ.169) THEN
11842 C...q + qbar -> e + e* (excited lepton)
11843  kfqstr=kfpr(isub,2)
11844  kfqexc=mod(kfqstr,kexcit)
11845  js=mint(2)
11846  mint(20+js)=isign(kfqstr,mint(14+js))
11847  mint(23-js)=isign(kfqexc,mint(17-js))
11848  js=3-js
11849 
11850  ELSEIF(isub.EQ.191) THEN
11851 C...f + fbar -> rho_tc0.
11852  kfres=ktechn+113
11853 
11854  ELSEIF(isub.EQ.192) THEN
11855 C...f + fbar' -> rho_tc+/-
11856  kch1=kchg(iabs(mint(15)),1)*isign(1,mint(15))
11857  kch2=kchg(iabs(mint(16)),1)*isign(1,mint(16))
11858  kfres=isign(ktechn+213,kch1+kch2)
11859 
11860  ELSEIF(isub.EQ.193) THEN
11861 C...f + fbar -> omega_tc0.
11862  kfres=ktechn+223
11863 
11864  ELSEIF(isub.EQ.194) THEN
11865 C...f + fbar -> f' + fbar' via mixture of s-channel
11866 C...rho_tc and omega_tc; th=(p(f)-p(f'))**2
11867  mint(21)=isign(kfpr(isub,1),mint(15))
11868  mint(22)=-mint(21)
11869 
11870  ELSEIF(isub.EQ.195) THEN
11871 C...f + fbar' -> f'' + fbar''' via s-channel
11872 C...rho_tc+ th=(p(f)-p(f'))**2
11873 C...q + qbar' -> l + nu; th=(p(u)-p(nu))**2 or (p(ubar)-p(nubar))**2
11874  IF(mod(mint(15),2).EQ.0) THEN
11875  mint(21)=isign(kfpr(isub,1)+1,mint(15))
11876  mint(22)=isign(kfpr(isub,1),mint(16))
11877  ELSE
11878  mint(21)=isign(kfpr(isub,1),mint(15))
11879  mint(22)=isign(kfpr(isub,1)+1,mint(16))
11880  ENDIF
11881  ENDIF
11882 
11883 CMRENNA++
11884  ELSEIF(isub.LE.215) THEN
11885  IF(isub.EQ.201) THEN
11886 C...f + fbar -> ~e_L + ~e_Lbar
11887  mint(21)=isign(ksusy1+11,kcs)
11888  mint(22)=-mint(21)
11889 
11890  ELSEIF(isub.EQ.202) THEN
11891 C...f + fbar -> ~e_R + ~e_Rbar
11892  mint(21)=isign(ksusy2+11,kcs)
11893  mint(22)=-mint(21)
11894 
11895  ELSEIF(isub.EQ.203) THEN
11896 C...f + fbar -> ~e_L + ~e_Rbar
11897  IF(mint(15).LT.0) js=2
11898  IF(mint(2).EQ.1) THEN
11899  mint(20+js)=kfpr(isub,1)
11900  mint(23-js)=-kfpr(isub,2)
11901  ELSE
11902  mint(20+js)=-kfpr(isub,1)
11903  mint(23-js)=kfpr(isub,2)
11904  ENDIF
11905 
11906  ELSEIF(isub.EQ.204) THEN
11907 C...f + fbar -> ~mu_L + ~mu_Lbar
11908  mint(21)=isign(ksusy1+13,kcs)
11909  mint(22)=-mint(21)
11910 
11911  ELSEIF(isub.EQ.205) THEN
11912 C...f + fbar -> ~mu_R + ~mu_Rbar
11913  mint(21)=isign(ksusy2+13,kcs)
11914  mint(22)=-mint(21)
11915 
11916  ELSEIF(isub.EQ.206) THEN
11917 C...f + fbar -> ~mu_L + ~mu_Rbar
11918  IF(mint(15).LT.0) js=2
11919  IF(mint(2).EQ.1) THEN
11920  mint(20+js)=kfpr(isub,1)
11921  mint(23-js)=-kfpr(isub,2)
11922  ELSE
11923  mint(20+js)=-kfpr(isub,1)
11924  mint(23-js)=kfpr(isub,2)
11925  ENDIF
11926 
11927  ELSEIF(isub.EQ.207) THEN
11928 C...f + fbar -> ~tau_1 + ~tau_1bar
11929  mint(21)=isign(ksusy1+15,kcs)
11930  mint(22)=-mint(21)
11931 
11932  ELSEIF(isub.EQ.208) THEN
11933 C...f + fbar -> ~tau_2 + ~tau_2bar
11934  mint(21)=isign(ksusy2+15,kcs)
11935  mint(22)=-mint(21)
11936 
11937  ELSEIF(isub.EQ.209) THEN
11938 C...f + fbar -> ~tau_1 + ~tau_2bar
11939  IF(mint(15).LT.0) js=2
11940  IF(mint(2).EQ.1) THEN
11941  mint(20+js)=kfpr(isub,1)
11942  mint(23-js)=-kfpr(isub,2)
11943  ELSE
11944  mint(20+js)=-kfpr(isub,1)
11945  mint(23-js)=kfpr(isub,2)
11946  ENDIF
11947 
11948  ELSEIF(isub.EQ.210) THEN
11949 C...q + qbar' -> ~l_L + ~nulbar; th arbitrary
11950  kch1=kchg(iabs(mint(15)),1)*isign(1,mint(15))
11951  kch2=kchg(iabs(mint(16)),1)*isign(1,mint(16))
11952  mint(21)=-isign(kfpr(isub,1),kch1+kch2)
11953  mint(22)=isign(kfpr(isub,2),kch1+kch2)
11954 
11955  ELSEIF(isub.EQ.211) THEN
11956 C...q + qbar'-> ~tau_1 + ~nutaubar; th arbitrary
11957  kch1=kchg(iabs(mint(15)),1)*isign(1,mint(15))
11958  kch2=kchg(iabs(mint(16)),1)*isign(1,mint(16))
11959  mint(21)=-isign(ksusy1+15,kch1+kch2)
11960  mint(22)=isign(ksusy1+16,kch1+kch2)
11961 
11962  ELSEIF(isub.EQ.212) THEN
11963 C...q + qbar'-> ~tau_2 + ~nutaubar; th arbitrary
11964  kch1=kchg(iabs(mint(15)),1)*isign(1,mint(15))
11965  kch2=kchg(iabs(mint(16)),1)*isign(1,mint(16))
11966  mint(21)=-isign(ksusy2+15,kch1+kch2)
11967  mint(22)=isign(ksusy1+16,kch1+kch2)
11968 
11969  ELSEIF(isub.EQ.213) THEN
11970 C...f + fbar -> ~nul + ~nulbar
11971  mint(21)=isign(kfpr(isub,1),kcs)
11972  mint(22)=-mint(21)
11973 
11974  ELSEIF(isub.EQ.214) THEN
11975 C...f + fbar -> ~nutau + ~nutaubar
11976  mint(21)=isign(ksusy1+16,kcs)
11977  mint(22)=-mint(21)
11978  ENDIF
11979 
11980  ELSEIF(isub.LE.225) THEN
11981  IF(isub.EQ.216) THEN
11982 C...f + fbar -> ~chi01 + ~chi01
11983  mint(21)=ksusy1+22
11984  mint(22)=ksusy1+22
11985 
11986  ELSEIF(isub.EQ.217) THEN
11987 C...f + fbar -> ~chi02 + ~chi02
11988  mint(21)=ksusy1+23
11989  mint(22)=ksusy1+23
11990 
11991  ELSEIF(isub.EQ.218 ) THEN
11992 C...f + fbar -> ~chi03 + ~chi03
11993  mint(21)=ksusy1+25
11994  mint(22)=ksusy1+25
11995 
11996  ELSEIF(isub.EQ.219 ) THEN
11997 C...f + fbar -> ~chi04 + ~chi04
11998  mint(21)=ksusy1+35
11999  mint(22)=ksusy1+35
12000 
12001  ELSEIF(isub.EQ.220 ) THEN
12002 C...f + fbar -> ~chi01 + ~chi02
12003  IF(mint(15).LT.0) js=2
12004 C IF(PYR(0).GT.0.5D0) JS=2
12005  mint(20+js)=ksusy1+22
12006  mint(23-js)=ksusy1+23
12007 
12008  ELSEIF(isub.EQ.221 ) THEN
12009 C...f + fbar -> ~chi01 + ~chi03
12010  IF(mint(15).LT.0) js=2
12011 C IF(PYR(0).GT.0.5D0) JS=2
12012  mint(20+js)=ksusy1+22
12013  mint(23-js)=ksusy1+25
12014 
12015  ELSEIF(isub.EQ.222) THEN
12016 C...f + fbar -> ~chi01 + ~chi04
12017  IF(mint(15).LT.0) js=2
12018 C IF(PYR(0).GT.0.5D0) JS=2
12019  mint(20+js)=ksusy1+22
12020  mint(23-js)=ksusy1+35
12021 
12022  ELSEIF(isub.EQ.223) THEN
12023 C...f + fbar -> ~chi02 + ~chi03
12024  IF(mint(15).LT.0) js=2
12025 C IF(PYR(0).GT.0.5D0) JS=2
12026  mint(20+js)=ksusy1+23
12027  mint(23-js)=ksusy1+25
12028 
12029  ELSEIF(isub.EQ.224) THEN
12030 C...f + fbar -> ~chi02 + ~chi04
12031  IF(mint(15).LT.0) js=2
12032 C IF(PYR(0).GT.0.5D0) JS=2
12033  mint(20+js)=ksusy1+23
12034  mint(23-js)=ksusy1+35
12035 
12036  ELSEIF(isub.EQ.225) THEN
12037 C...f + fbar -> ~chi03 + ~chi04
12038  IF(mint(15).LT.0) js=2
12039 C IF(PYR(0).GT.0.5D0) JS=2
12040  mint(20+js)=ksusy1+25
12041  mint(23-js)=ksusy1+35
12042  ENDIF
12043 
12044  ELSEIF(isub.LE.236) THEN
12045  IF(isub.EQ.226) THEN
12046 C...f + fbar -> ~chi+-1 + ~chi-+1
12047 C...th=(p(q)-p(chi+))**2 or (p(qbar)-p(chi-))**2
12048  kch1=kchg(iabs(mint(15)),1)*isign(1,mint(15))
12049  mint(21)=isign(ksusy1+24,kch1)
12050  mint(22)=-mint(21)
12051 
12052  ELSEIF(isub.EQ.227) THEN
12053 C...f + fbar -> ~chi+-2 + ~chi-+2
12054  kch1=kchg(iabs(mint(15)),1)*isign(1,mint(15))
12055  mint(21)=isign(ksusy1+37,kch1)
12056  mint(22)=-mint(21)
12057 
12058  ELSEIF(isub.EQ.228) THEN
12059 C...f + fbar -> ~chi+-1 + ~chi-+2
12060 C...th=(p(q)-p(chi1+))**2 or th=(p(qbar)-p(chi1-))**2
12061 C...js=1 if pyr<.5, js=2 if pyr>.5
12062 C...if 15=q, 16=qbar and js=1, chi1+ + chi2-, th=(q-chi1+)**2
12063 C...if 15=qbar, 16=q and js=1, chi2- + chi1+, th=(q-chi1+)**2
12064 C...if 15=q, 16=qbar and js=2, chi1- + chi2+, th=(qbar-chi1-)**2
12065 C...if 15=qbar, 16=q and js=2, chi2+ + chi1-, th=(q-chi1-)**2
12066  kch1=kchg(iabs(mint(15)),1)*isign(1,mint(15))
12067  kch2=int(1-kch1)/2
12068  IF(mint(2).EQ.1) THEN
12069  mint(21)= isign(ksusy1+24,kch1)
12070  mint(22)= -isign(ksusy1+37,kch1)
12071 c IF(KCH2.EQ.0) JS=2
12072  ELSE
12073  mint(21)= isign(ksusy1+37,kch1)
12074  mint(22)= -isign(ksusy1+24,kch1)
12075  js=2
12076 c IF(KCH2.EQ.1) JS=2
12077  ENDIF
12078 
12079  ELSEIF(isub.EQ.229) THEN
12080 C...q + qbar' -> ~chi01 + ~chi+-1
12081 C...th=(p(u)-p(chi+))**2 or (p(ubar)-p(chi-))**2
12082  kch1=kchg(iabs(mint(15)),1)*isign(1,mint(15))
12083  kch2=kchg(iabs(mint(16)),1)*isign(1,mint(16))
12084 C...CHECK THIS
12085  IF(mod(mint(15),2).EQ.0) js=2
12086  mint(20+js)=ksusy1+22
12087  mint(23-js)=isign(ksusy1+24,kch1+kch2)
12088 
12089  ELSEIF(isub.EQ.230) THEN
12090 C...q + qbar' -> ~chi02 + ~chi+-1
12091  kch1=kchg(iabs(mint(15)),1)*isign(1,mint(15))
12092  kch2=kchg(iabs(mint(16)),1)*isign(1,mint(16))
12093  IF(mod(mint(15),2).EQ.0) js=2
12094  mint(20+js)=ksusy1+23
12095  mint(23-js)=isign(ksusy1+24,kch1+kch2)
12096 
12097  ELSEIF(isub.EQ.231) THEN
12098 C...q + qbar' -> ~chi03 + ~chi+-1
12099  kch1=kchg(iabs(mint(15)),1)*isign(1,mint(15))
12100  kch2=kchg(iabs(mint(16)),1)*isign(1,mint(16))
12101  IF(mod(mint(15),2).EQ.0) js=2
12102  mint(20+js)=ksusy1+25
12103  mint(23-js)=isign(ksusy1+24,kch1+kch2)
12104 
12105  ELSEIF(isub.EQ.232) THEN
12106 C...q + qbar' -> ~chi04 + ~chi+-1
12107  kch1=kchg(iabs(mint(15)),1)*isign(1,mint(15))
12108  kch2=kchg(iabs(mint(16)),1)*isign(1,mint(16))
12109  IF(mod(mint(15),2).EQ.0) js=2
12110  mint(20+js)=ksusy1+35
12111  mint(23-js)=isign(ksusy1+24,kch1+kch2)
12112 
12113  ELSEIF(isub.EQ.233) THEN
12114 C...q + qbar' -> ~chi01 + ~chi+-2
12115  kch1=kchg(iabs(mint(15)),1)*isign(1,mint(15))
12116  kch2=kchg(iabs(mint(16)),1)*isign(1,mint(16))
12117  IF(mod(mint(15),2).EQ.0) js=2
12118  mint(20+js)=ksusy1+22
12119  mint(23-js)=isign(ksusy1+37,kch1+kch2)
12120 
12121  ELSEIF(isub.EQ.234) THEN
12122 C...q + qbar' -> ~chi02 + ~chi+-2
12123  kch1=kchg(iabs(mint(15)),1)*isign(1,mint(15))
12124  kch2=kchg(iabs(mint(16)),1)*isign(1,mint(16))
12125  IF(mod(mint(15),2).EQ.0) js=2
12126  mint(20+js)=ksusy1+23
12127  mint(23-js)=isign(ksusy1+37,kch1+kch2)
12128 
12129  ELSEIF(isub.EQ.235) THEN
12130 C...q + qbar' -> ~chi03 + ~chi+-2
12131  kch1=kchg(iabs(mint(15)),1)*isign(1,mint(15))
12132  kch2=kchg(iabs(mint(16)),1)*isign(1,mint(16))
12133  IF(mod(mint(15),2).EQ.0) js=2
12134  mint(20+js)=ksusy1+25
12135  mint(23-js)=isign(ksusy1+37,kch1+kch2)
12136 
12137  ELSEIF(isub.EQ.236) THEN
12138 C...q + qbar' -> ~chi04 + ~chi+-2
12139  kch1=kchg(iabs(mint(15)),1)*isign(1,mint(15))
12140  kch2=kchg(iabs(mint(16)),1)*isign(1,mint(16))
12141  IF(mod(mint(15),2).EQ.0) js=2
12142  mint(20+js)=ksusy1+35
12143  mint(23-js)=isign(ksusy1+37,kch1+kch2)
12144  ENDIF
12145 
12146  ELSEIF(isub.LE.245) THEN
12147  IF(isub.EQ.237) THEN
12148 C...q + qbar -> ~chi01 + ~g
12149 C...th arbitrary
12150  IF(pyr(0).GT.0.5d0) js=2
12151  mint(20+js)=ksusy1+21
12152  mint(23-js)=ksusy1+22
12153  kcc=17+js
12154 
12155  ELSEIF(isub.EQ.238) THEN
12156 C...q + qbar -> ~chi02 + ~g
12157 C...th arbitrary
12158  IF(pyr(0).GT.0.5d0) js=2
12159  mint(20+js)=ksusy1+21
12160  mint(23-js)=ksusy1+23
12161  kcc=17+js
12162 
12163  ELSEIF(isub.EQ.239) THEN
12164 C...q + qbar -> ~chi03 + ~g
12165 C...th arbitrary
12166  IF(pyr(0).GT.0.5d0) js=2
12167  mint(20+js)=ksusy1+21
12168  mint(23-js)=ksusy1+25
12169  kcc=17+js
12170 
12171  ELSEIF(isub.EQ.240) THEN
12172 C...q + qbar -> ~chi04 + ~g
12173 C...th arbitrary
12174  IF(pyr(0).GT.0.5d0) js=2
12175  mint(20+js)=ksusy1+21
12176  mint(23-js)=ksusy1+35
12177  kcc=17+js
12178 
12179  ELSEIF(isub.EQ.241) THEN
12180 C...q + qbar' -> ~chi+-1 + ~g
12181 C...if 15=u, 16=dbar, then (kch1+kch2)>0, js=1, chi+
12182 C...if 15=d, 16=ubar, then (kch1+kch2)<0, js=2, chi-
12183 C...if 15=ubar, 16=d, then (kch1+kch2)<0, js=1, chi-
12184 C...if 15=dbar, 16=u, then (kch1+kch2)>0, js=2, chi+
12185 C...th=(p(q)-p(chi+))**2 or (p(qbar')-p(chi-))**2
12186  kch1=kchg(iabs(mint(15)),1)*isign(1,mint(15))
12187  kch2=kchg(iabs(mint(16)),1)*isign(1,mint(16))
12188  js=1
12189  IF(mint(15)*(kch1+kch2).GT.0) js=2
12190  mint(20+js)=ksusy1+21
12191  mint(23-js)=isign(ksusy1+24,kch1+kch2)
12192  kcc=17+js
12193 
12194  ELSEIF(isub.EQ.242) THEN
12195 C...q + qbar' -> ~chi+-2 + ~g
12196 C...if 15=u, 16=dbar, then (kch1+kch2)>0, js=1, chi+
12197 C...if 15=d, 16=ubar, then (kch1+kch2)<0, js=2, chi-
12198 C...if 15=ubar, 16=d, then (kch1+kch2)<0, js=1, chi-
12199 C...if 15=dbar, 16=u, then (kch1+kch2)>0, js=2, chi+
12200 C...th=(p(q)-p(chi+))**2 or (p(qbar')-p(chi-))**2
12201  kch1=kchg(iabs(mint(15)),1)*isign(1,mint(15))
12202  kch2=kchg(iabs(mint(16)),1)*isign(1,mint(16))
12203  js=1
12204  IF(mint(15)*(kch1+kch2).GT.0) js=2
12205  mint(20+js)=ksusy1+21
12206  mint(23-js)=isign(ksusy1+37,kch1+kch2)
12207  kcc=17+js
12208 
12209  ELSEIF(isub.EQ.243) THEN
12210 C...q + qbar -> ~g + ~g ; th arbitrary
12211  mint(21)=ksusy1+21
12212  mint(22)=ksusy1+21
12213  kcc=mint(2)+4
12214 
12215  ELSEIF(isub.EQ.244) THEN
12216 C...g + g -> ~g + ~g ; th arbitrary
12217  kcc=mint(2)+12
12218  kcs=(-1)**int(1.5d0+pyr(0))
12219  mint(21)=ksusy1+21
12220  mint(22)=ksusy1+21
12221  ENDIF
12222 
12223  ELSEIF(isub.LE.260) THEN
12224  IF(isub.EQ.246) THEN
12225 C...qj + g -> ~qj_L + ~chi01
12226  IF(mint(15).EQ.21) js=2
12227  i=mint(14+js)
12228  ia=iabs(i)
12229  mint(20+js)=isign(ksusy1+ia,i)
12230  mint(23-js)=ksusy1+22
12231  kcc=15+js
12232  kcs=isign(1,mint(14+js))
12233 
12234  ELSEIF(isub.EQ.247) THEN
12235 C...qj + g -> ~qj_R + ~chi01
12236  IF(mint(15).EQ.21) js=2
12237  i=mint(14+js)
12238  ia=iabs(i)
12239  mint(20+js)=isign(ksusy2+ia,i)
12240  mint(23-js)=ksusy1+22
12241  kcc=15+js
12242  kcs=isign(1,mint(14+js))
12243 
12244  ELSEIF(isub.EQ.248) THEN
12245 C...qj + g -> ~qj_L + ~chi02
12246  IF(mint(15).EQ.21) js=2
12247  i=mint(14+js)
12248  ia=iabs(i)
12249  mint(20+js)=isign(ksusy1+ia,i)
12250  mint(23-js)=ksusy1+23
12251  kcc=15+js
12252  kcs=isign(1,mint(14+js))
12253 
12254  ELSEIF(isub.EQ.249) THEN
12255 C...qj + g -> ~qj_R + ~chi02
12256  IF(mint(15).EQ.21) js=2
12257  i=mint(14+js)
12258  ia=iabs(i)
12259  mint(20+js)=isign(ksusy2+ia,i)
12260  mint(23-js)=ksusy1+23
12261  kcc=15+js
12262  kcs=isign(1,mint(14+js))
12263 
12264  ELSEIF(isub.EQ.250) THEN
12265 C...qj + g -> ~qj_L + ~chi03
12266  IF(mint(15).EQ.21) js=2
12267  i=mint(14+js)
12268  ia=iabs(i)
12269  mint(20+js)=isign(ksusy1+ia,i)
12270  mint(23-js)=ksusy1+25
12271  kcc=15+js
12272  kcs=isign(1,mint(14+js))
12273 
12274  ELSEIF(isub.EQ.251) THEN
12275 C...qj + g -> ~qj_R + ~chi03
12276  IF(mint(15).EQ.21) js=2
12277  i=mint(14+js)
12278  ia=iabs(i)
12279  mint(20+js)=isign(ksusy2+ia,i)
12280  mint(23-js)=ksusy1+25
12281  kcc=15+js
12282  kcs=isign(1,mint(14+js))
12283 
12284  ELSEIF(isub.EQ.252) THEN
12285 C...qj + g -> ~qj_L + ~chi04
12286  IF(mint(15).EQ.21) js=2
12287  i=mint(14+js)
12288  ia=iabs(i)
12289  mint(20+js)=isign(ksusy1+ia,i)
12290  mint(23-js)=ksusy1+35
12291  kcc=15+js
12292  kcs=isign(1,mint(14+js))
12293 
12294  ELSEIF(isub.EQ.253) THEN
12295 C...qj + g -> ~qj_R + ~chi04
12296  IF(mint(15).EQ.21) js=2
12297  i=mint(14+js)
12298  ia=iabs(i)
12299  mint(20+js)=isign(ksusy2+ia,i)
12300  mint(23-js)=ksusy1+35
12301  kcc=15+js
12302  kcs=isign(1,mint(14+js))
12303 
12304  ELSEIF(isub.EQ.254) THEN
12305 C...qj + g -> ~qk_L + ~chi+-1
12306  IF(mint(15).EQ.21) js=2
12307  i=mint(14+js)
12308  ia=iabs(i)
12309  mint(23-js)=isign(ksusy1+24,kchg(ia,1)*i)
12310  ib=-ia+int((ia+1)/2)*4-1
12311  mint(20+js)=isign(ksusy1+ib,i)
12312  kcc=15+js
12313  kcs=isign(1,mint(14+js))
12314 
12315  ELSEIF(isub.EQ.255) THEN
12316 C...qj + g -> ~qk_L + ~chi+-1
12317  IF(mint(15).EQ.21) js=2
12318  i=mint(14+js)
12319  ia=iabs(i)
12320  mint(23-js)=isign(ksusy1+24,kchg(ia,1)*i)
12321  ib=-ia+int((ia+1)/2)*4-1
12322  mint(20+js)=isign(ksusy2+ib,i)
12323  kcc=15+js
12324  kcs=isign(1,mint(14+js))
12325 
12326  ELSEIF(isub.EQ.256) THEN
12327 C...qj + g -> ~qk_L + ~chi+-2
12328  IF(mint(15).EQ.21) js=2
12329  i=mint(14+js)
12330  ia=iabs(i)
12331  ib=-ia+int((ia+1)/2)*4-1
12332  mint(20+js)=isign(ksusy1+ib,i)
12333  mint(23-js)=isign(ksusy1+37,kchg(ia,1)*i)
12334  kcc=15+js
12335  kcs=isign(1,mint(14+js))
12336 
12337  ELSEIF(isub.EQ.257) THEN
12338 C...qj + g -> ~qk_R + ~chi+-2
12339  IF(mint(15).EQ.21) js=2
12340  i=mint(14+js)
12341  ia=iabs(i)
12342  ib=-ia+int((ia+1)/2)*4-1
12343  mint(20+js)=isign(ksusy2+ib,i)
12344  mint(23-js)=isign(ksusy1+37,kchg(ia,1)*i)
12345  kcc=15+js
12346  kcs=isign(1,mint(14+js))
12347 
12348  ELSEIF(isub.EQ.258) THEN
12349 C...qj + g -> ~qj_L + ~g
12350  IF(mint(15).EQ.21) js=2
12351  i=mint(14+js)
12352  ia=iabs(i)
12353  mint(20+js)=isign(ksusy1+ia,i)
12354  mint(23-js)=ksusy1+21
12355  kcc=mint(2)+6
12356  IF(js.EQ.2) kcc=kcc+2
12357  kcs=isign(1,i)
12358 
12359  ELSEIF(isub.EQ.259) THEN
12360 C...qj + g -> ~qj_R + ~g
12361  IF(mint(15).EQ.21) js=2
12362  i=mint(14+js)
12363  ia=iabs(i)
12364  mint(20+js)=isign(ksusy2+ia,i)
12365  mint(23-js)=ksusy1+21
12366  kcc=mint(2)+6
12367  IF(js.EQ.2) kcc=kcc+2
12368  kcs=isign(1,i)
12369  ENDIF
12370 
12371  ELSEIF(isub.LE.270) THEN
12372  IF(isub.EQ.261) THEN
12373 C...f + fbar -> ~t_1 + ~t_1bar; th = (p(q)-p(sq))**2
12374  isgn=1
12375  IF(mint(43).EQ.1.AND.pyr(0).GT.0.5d0) isgn=-1
12376  mint(21)=isgn*isign(kfpr(isub,1),kcs)
12377  mint(22)=-mint(21)
12378 C...Correct color combination
12379  IF(mint(43).EQ.4) kcc=4
12380 
12381  ELSEIF(isub.EQ.262) THEN
12382 C...f + fbar -> ~t_2 + ~t_2bar; th = (p(q)-p(sq))**2
12383  isgn=1
12384  IF(mint(43).EQ.1.AND.pyr(0).GT.0.5d0) isgn=-1
12385  mint(21)=isgn*isign(kfpr(isub,1),kcs)
12386  mint(22)=-mint(21)
12387 C...Correct color combination
12388  IF(mint(43).EQ.4) kcc=4
12389 
12390  ELSEIF(isub.EQ.263) THEN
12391 C...f + fbar -> ~t_1 + ~t_2bar; th = (p(q)-p(sq))**2
12392  IF((kcs.GT.0.AND.mint(2).EQ.1).OR.
12393  & (kcs.LT.0.AND.mint(2).EQ.2)) THEN
12394  mint(21)=isign(kfpr(isub,1),kcs)
12395  mint(22)=-isign(kfpr(isub,2),kcs)
12396  ELSE
12397  js=2
12398  mint(21)=isign(kfpr(isub,2),kcs)
12399  mint(22)=-isign(kfpr(isub,1),kcs)
12400  ENDIF
12401 C...Correct color combination
12402  IF(mint(43).EQ.4) kcc=4
12403 
12404  ELSEIF(isub.EQ.264) THEN
12405 C...g + g -> ~t_1 + ~t_1bar; th arbitrary
12406  kcs=(-1)**int(1.5d0+pyr(0))
12407  mint(21)=isign(kfpr(isub,1),kcs)
12408  mint(22)=-mint(21)
12409  kcc=mint(2)+10
12410 
12411  ELSEIF(isub.EQ.265) THEN
12412 C...g + g -> ~t_2 + ~t_2bar; th arbitrary
12413  kcs=(-1)**int(1.5d0+pyr(0))
12414  mint(21)=isign(kfpr(isub,1),kcs)
12415  mint(22)=-mint(21)
12416  kcc=mint(2)+10
12417  ENDIF
12418 
12419  ELSEIF(isub.LE.301) THEN
12420  IF(isub.EQ.271.OR.isub.EQ.281.OR.isub.EQ.291) THEN
12421 C...qi + qj -> ~qi_L + ~qj_L
12422  kcc=mint(2)
12423  IF(mint(15)*mint(16).LT.0) kcc=kcc+2
12424  mint(21)=isign(ksusy1+iabs(mint(15)),mint(15))
12425  mint(22)=isign(ksusy1+iabs(mint(16)),mint(16))
12426 
12427  ELSEIF(isub.EQ.272.OR.isub.EQ.282.OR.isub.EQ.292) THEN
12428 C...qi + qj -> ~qi_R + ~qj_R
12429  kcc=mint(2)
12430  IF(mint(15)*mint(16).LT.0) kcc=kcc+2
12431  mint(21)=isign(ksusy2+iabs(mint(15)),mint(15))
12432  mint(22)=isign(ksusy2+iabs(mint(16)),mint(16))
12433 
12434  ELSEIF(isub.EQ.273.OR.isub.EQ.283.OR.isub.EQ.293) THEN
12435 C...qi + qj -> ~qi_L + ~qj_R
12436  mint(21)=isign(kfpr(isub,1),mint(15))
12437  mint(22)=isign(kfpr(isub,2),mint(16))
12438  kcc=mint(2)
12439  IF(mint(15)*mint(16).LT.0) kcc=kcc+2
12440 
12441  ELSEIF(isub.EQ.274.OR.isub.EQ.284) THEN
12442 C...qi + qjbar -> ~qi_L + ~qj_Lbar; th = (p(f)-p(sf'))**2
12443  mint(21)=isign(ksusy1+iabs(mint(15)),mint(15))
12444  mint(22)=isign(ksusy1+iabs(mint(16)),mint(16))
12445  kcc=mint(2)
12446  IF(mint(15)*mint(16).LT.0) kcc=kcc+2
12447 
12448  ELSEIF(isub.EQ.275.OR.isub.EQ.285) THEN
12449 C...qi + qjbar -> ~qi_R + ~qj_Rbar ; th = (p(f)-p(sf'))**2
12450  mint(21)=isign(ksusy2+iabs(mint(15)),mint(15))
12451  mint(22)=isign(ksusy2+iabs(mint(16)),mint(16))
12452  kcc=mint(2)
12453  IF(mint(15)*mint(16).LT.0) kcc=kcc+2
12454 
12455  ELSEIF(isub.EQ.276.OR.isub.EQ.286.OR.isub.EQ.296) THEN
12456 C...qi + qjbar -> ~qi_L + ~qj_Rbar ; th = (p(f)-p(sf'))**2
12457  mint(21)=isign(kfpr(isub,1),mint(15))
12458  mint(22)=isign(kfpr(isub,2),mint(16))
12459  kcc=mint(2)
12460  IF(mint(15)*mint(16).LT.0) kcc=kcc+2
12461 
12462  ELSEIF(isub.EQ.277.OR.isub.EQ.287) THEN
12463 C...f + fbar -> ~qi_L + ~qi_Lbar ; th = (p(q)-p(sq))**2
12464  isgn=1
12465  IF(mint(43).EQ.1.AND.pyr(0).GT.0.5d0) isgn=-1
12466  mint(21)=isgn*isign(kfpr(isub,1),kcs)
12467  mint(22)=-mint(21)
12468  IF(mint(43).EQ.4) kcc=4
12469 
12470  ELSEIF(isub.EQ.278.OR.isub.EQ.288) THEN
12471 C...f + fbar -> ~qi_R + ~qi_Rbar; th = (p(q)-p(sq))**2
12472  isgn=1
12473  IF(mint(43).EQ.1.AND.pyr(0).GT.0.5d0) isgn=-1
12474  mint(21)=isgn*isign(kfpr(isub,1),kcs)
12475  mint(22)=-mint(21)
12476  IF(mint(43).EQ.4) kcc=4
12477 
12478  ELSEIF(isub.EQ.279.OR.isub.EQ.289) THEN
12479 C...g + g -> ~qi_L + ~qi_Lbar ; th arbitrary
12480 C...pure LL + RR
12481  kcs=(-1)**int(1.5d0+pyr(0))
12482  mint(21)=isign(kfpr(isub,1),kcs)
12483  mint(22)=-mint(21)
12484  kcc=mint(2)+10
12485 
12486  ELSEIF(isub.EQ.280.OR.isub.EQ.290) THEN
12487 C...g + g -> ~qi_R + ~qi_Rbar ; th arbitrary
12488  kcs=(-1)**int(1.5d0+pyr(0))
12489  mint(21)=isign(kfpr(isub,1),kcs)
12490  mint(22)=-mint(21)
12491  kcc=mint(2)+10
12492 
12493  ELSEIF(isub.EQ.294) THEN
12494 C...qj + g -> ~qj_L + ~g
12495  IF(mint(15).EQ.21) js=2
12496  i=mint(14+js)
12497  ia=iabs(i)
12498  mint(20+js)=isign(ksusy1+ia,i)
12499  mint(23-js)=ksusy1+21
12500  kcc=mint(2)+6
12501  IF(js.EQ.2) kcc=kcc+2
12502  kcs=isign(1,i)
12503 
12504  ELSEIF(isub.EQ.295) THEN
12505 C...qj + g -> ~qj_R + ~g
12506  IF(mint(15).EQ.21) js=2
12507  i=mint(14+js)
12508  ia=iabs(i)
12509  mint(20+js)=isign(ksusy2+ia,i)
12510  mint(23-js)=ksusy1+21
12511  kcc=mint(2)+6
12512  IF(js.EQ.2) kcc=kcc+2
12513  kcs=isign(1,i)
12514 
12515  ELSEIF(isub.EQ.297.OR.isub.EQ.298) THEN
12516 C...q + qbar' -> H+ + H0
12517  kch1=kchg(iabs(mint(15)),1)*isign(1,mint(15))
12518  kch2=kchg(iabs(mint(16)),1)*isign(1,mint(16))
12519  IF(mint(15)*(kch1+kch2).GT.0) js=2
12520  mint(20+js)=isign(37,kch1+kch2)
12521  mint(23-js)=kfpr(isub,2)
12522  ELSEIF(isub.EQ.299.OR.isub.EQ.300) THEN
12523 C...f + fbar -> A0 + H0; th arbitrary
12524  IF(pyr(0).GT.0.5d0) js=2
12525  mint(20+js)=kfpr(isub,1)
12526  mint(23-js)=kfpr(isub,2)
12527  ELSEIF(isub.EQ.301) THEN
12528 C...f + fbar -> H+ H-
12529  mint(21)=isign(kfpr(isub,1),kcs)
12530  mint(22)=-mint(21)
12531  ENDIF
12532 CMRENNA--
12533  ELSEIF(isub.LE.330) THEN
12534  IF(isub.EQ.311)THEN
12535 C...g + g -> g* + g* (UED)
12536  kcc=mint(2)+12
12537  kcs=(-1)**int(1.5d0+pyr(0))
12538  mued(1)=472
12539  mued(2)=472
12540  mint(21)=iuedeq(472)
12541  mint(22)=iuedeq(472)
12542  ELSEIF(isub.EQ.312)THEN
12543 C...q + g -> q*_D + g*, q*_S + g*
12544 C...The two channels have the same cross section
12545  kkflmi=450
12546  IF(pyr(0).GT.0.5)kkflmi=456
12547  IF(mint(15).EQ.21) js=2
12548  kcc=mint(2)+6
12549  IF(mint(15).EQ.21)kcc=kcc+2
12550  IF(mint(15).NE.21)THEN
12551  kcs=isign(1,mint(15))
12552  mued(2)=472
12553  mued(1)=kcs*(kkflmi+iabs(mint(15)))
12554  mint(22)=iuedeq(472)
12555  mint(21)=kcs*iuedeq(kkflmi+iabs(mint(15)))
12556  ENDIF
12557  IF(mint(16).NE.21)THEN
12558  kcs=isign(1,mint(16))
12559  mued(2)=kcs*(kkflmi+iabs(mint(16)))
12560  mued(1)=472
12561  mint(22)=kcs*iuedeq(kkflmi+iabs(mint(16)))
12562  mint(21)=iuedeq(472)
12563  ENDIF
12564  ELSEIF(isub.EQ.313)THEN
12565 C...q + q' -> q*_D + q*_D',q*_S+q*_S'
12566 C...The two channels have the same cross section
12567  kkflmi=450
12568  IF(pyr(0).GT.0.5)kkflmi=456
12569  kcc=mint(2)
12570  IF(mint(15).EQ.mint(16))THEN
12571  mued(1)=sign(1,mint(15))*(kkflmi+iabs(mint(15)))
12572  mued(2)=mint(21)
12573  mint(21)=sign(1,mint(15))*iuedeq(kkflmi+iabs(mint(15)))
12574  mint(22)=mint(21)
12575  ELSE
12576  mued(1)=sign(1,mint(15))*(kkflmi+iabs(mint(15)))
12577  mued(2)=sign(1,mint(16))*(kkflmi+iabs(mint(16)))
12578  mint(21)=sign(1,mint(15))*iuedeq(kkflmi+iabs(mint(15)))
12579  mint(22)=sign(1,mint(16))*iuedeq(kkflmi+iabs(mint(16)))
12580  ENDIF
12581  IF(mint(15)*mint(16).LT.0) kcc=kcc+2
12582  ELSEIF(isub.EQ.314)THEN
12583 C...g + g -> q*_D + q*_D_bar, q*_S + q*_S_bar
12584 C...The two channels have the same cross section
12585  kkflmi=450
12586  IF(pyr(0).GT.0.5)kkflmi=456
12587  kcs=(-1)**int(1.5d0+pyr(0))
12588  xflaout=pyr(0)
12589  IF(xflaout.LE.0.2)THEN
12590  mued(1)=isign(1,kcs)*(kkflmi+1)
12591  mint(21)=isign(1,kcs)*iuedeq(kkflmi+1)
12592  ELSEIF(xflaout.LE.0.4)THEN
12593  mued(1)=isign(1,kcs)*(kkflmi+2)
12594  mint(21)=isign(1,kcs)*iuedeq(kkflmi+2)
12595  ELSEIF(xflaout.LE.0.6)THEN
12596  mued(1)=isign(1,kcs)*(kkflmi+3)
12597  mint(21)=isign(1,kcs)*iuedeq(kkflmi+3)
12598  ELSEIF(xflaout.LE.0.8)THEN
12599  mued(1)=isign(1,kcs)*(kkflmi+4)
12600  mint(21)=isign(1,kcs)*iuedeq(kkflmi+4)
12601  ELSE
12602  mued(1)=isign(1,kcs)*(kkflmi+5)
12603  mint(21)=isign(1,kcs)*iuedeq(kkflmi+5)
12604  ENDIF
12605  mint(22)=-mint(21)
12606  mued(2)=-mued(1)
12607  kcc=mint(2)+10
12608  ELSEIF(isub.EQ.315)THEN
12609 C...q + qbar -> q*_D + q*_D_bar, q*_S + q*_S_bar
12610 C...The two channels have the same cross section
12611  kkflmi=450
12612  IF(pyr(0).GT.0.5)kkflmi=456
12613  mued(1)=isign(1,mint(15))*(kkflmi+iabs(mint(15)))
12614  mued(2)=-mint(21)
12615  mint(21)=isign(1,mint(15))*iuedeq(kkflmi+iabs(mint(15)))
12616  mint(22)=-mint(21)
12617  kcc=4
12618  ELSEIF(isub.EQ.316)THEN
12619 C...q + qbar' -> q*_D + q*_S_bar'
12620  mued(1)=isign(1,mint(15))*(456+iabs(mint(15)))
12621  mued(2)=isign(1,mint(16))*(450+iabs(mint(16)))
12622  mint(21)=isign(1,mint(15))*iuedeq(456+iabs(mint(15)))
12623  mint(22)=isign(1,mint(16))*iuedeq(450+iabs(mint(16)))
12624  kcc=mint(2)+2
12625  ELSEIF(isub.EQ.317)THEN
12626 C...q + qbar' -> q*_D + q*_D_bar', q*_S + q*_S_bar
12627 C...The two channels have the same cross section
12628  kkflmi=450
12629  IF(pyr(0).GT.0.5)kkflmi=456
12630  mued(1)=isign(1,mint(15))*(kkflmi+iabs(mint(15)))
12631  mued(2)=isign(1,mint(16))*(kkflmi+iabs(mint(16)))
12632  mint(21)=isign(1,mint(15))*iuedeq(kkflmi+iabs(mint(15)))
12633  mint(22)=isign(1,mint(16))*iuedeq(kkflmi+iabs(mint(16)))
12634  kcc=mint(2)+2
12635  ELSEIF(isub.EQ.318)THEN
12636 C...q + q' -> q*_D + q*_S'
12637  kcc=mint(2)
12638  mued(1)=sign(1,mint(15))*(456+iabs(mint(15)))
12639  mued(2)=sign(1,mint(16))*(450+iabs(mint(16)))
12640  mint(21)=sign(1,mint(15))*iuedeq(456+iabs(mint(15)))
12641  mint(22)=sign(1,mint(16))*iuedeq(450+iabs(mint(16)))
12642  ELSEIF(isub.EQ.319)THEN
12643 C...q + qbar -> q*_D' + q*_D_bar', q*_S' + q*_S_bar'
12644 C...The two channels have the same cross section
12645  kkflmi=450
12646  IF(pyr(0).GT.0.5)kkflmi=456
12647  xflaout=pyr(0)
12648  iiflav=0
12649 C...N.B. NFLAVOURS=IUED(3)
12650 C DO I=1,NFLAVOURS
12651  DO 433 i=1,iued(3)
12652  IF(i.NE.iabs(mint(15)))THEN
12653  iiflav=iiflav+1
12654  iokfla(iiflav)=i
12655  ENDIF
12656  433 CONTINUE
12657  flastep=1./(iued(3)-1)
12658  DO i=1,iued(3)-1
12659  flavv=flastep*i
12660  IF(xflaout.LE.flavv)THEN
12661  mued(1)=isign(1,mint(15))*(kkflmi+iokfla(i))
12662  mint(21)=isign(1,mint(15))*iuedeq(kkflmi+iokfla(i))
12663  goto 435
12664  ENDIF
12665  ENDDO
12666  435 CONTINUE
12667  IF(iabs(mued(1)).LT.451.AND.iabs(mued(1)).GT.462)THEN
12668  WRITE(mstu(11),*) 'IN PYSCAT: KK FLAVORS PROBLEM !!!'
12669  CALL pystop(5000000)
12670  ENDIF
12671  mint(22)=-mint(21)
12672  kcc=4
12673  ENDIF
12674 
12675  ELSEIF(isub.LE.360) THEN
12676 
12677  IF(isub.EQ.341.OR.isub.EQ.342) THEN
12678 C...l + l -> H_L++/--, H_R++/--
12679  kch1=kchg(iabs(mint(15)),1)*isign(1,mint(15))
12680  kch2=kchg(iabs(mint(16)),1)*isign(1,mint(16))
12681  kfres=isign(kfpr(isub,1),kch1+kch2)
12682 
12683  ELSEIF(isub.GE.343.AND.isub.LE.348) THEN
12684 C...l + gamma -> l' + H++/--; th=(p(l)-p(H))**2
12685  IF(mint(15).EQ.22) js=2
12686  mint(20+js)=isign(kfpr(isub,1),-mint(14+js))
12687  mint(23-js)=isign(kfpr(isub,2),-mint(14+js))
12688  kcc=22
12689 
12690  ELSEIF(isub.EQ.349.OR.isub.EQ.350) THEN
12691 C...f + fbar -> H++ + H--; th = (p(f)-p(H--))**2
12692  mint(21)=-isign(kfpr(isub,1),mint(15))
12693  mint(22)=-mint(21)
12694 
12695  ELSEIF(isub.EQ.351.OR.isub.EQ.352) THEN
12696 C...f + f' -> f" + f"' + H++/-- (W+/- + W+/- -> H++/--
12697 C...as inner process).
12698  DO 450 jt=1,2
12699  i=mint(14+jt)
12700  ia=iabs(i)
12701  IF(ia.LE.10) THEN
12702  rvckm=vint(180+i)*pyr(0)
12703  DO 440 j=1,mstp(1)
12704  ib=2*j-1+mod(ia,2)
12705  ipm=(5-isign(1,i))/2
12706  idc=j+mdcy(ia,2)+2
12707  IF(mdme(idc,1).NE.1.AND.mdme(idc,1).NE.ipm) goto 440
12708  mint(20+jt)=isign(ib,i)
12709  rvckm=rvckm-vckm((ia+1)/2,(ib+1)/2)
12710  IF(rvckm.LE.0d0) goto 450
12711  440 CONTINUE
12712  ELSE
12713  ib=2*((ia+1)/2)-1+mod(ia,2)
12714  mint(20+jt)=isign(ib,i)
12715  ENDIF
12716  450 CONTINUE
12717  kcc=22
12718  kfres=isign(kfpr(isub,1),mint(15))
12719  IF(mod(mint(15),2).EQ.1) kfres=-kfres
12720 
12721  ELSEIF(isub.EQ.353) THEN
12722 C...f + fbar -> Z_R0
12723  kfres=kfpr(isub,1)
12724 
12725  ELSEIF(isub.EQ.354) THEN
12726 C...f + fbar' -> W+/-
12727  kch1=kchg(iabs(mint(15)),1)*isign(1,mint(15))
12728  kch2=kchg(iabs(mint(16)),1)*isign(1,mint(16))
12729  kfres=isign(kfpr(isub,1),kch1+kch2)
12730 
12731  ENDIF
12732 
12733  ELSEIF(isub.LE.380) THEN
12734 
12735  IF(isub.LE.363.OR.isub.EQ.368) THEN
12736 C...f + fbar -> charged+ charged- technicolor
12737  ksw=(-1)**int(1.5d0+pyr(0))
12738  mint(21)=isign(kfpr(isub,1),ksw)
12739  mint(22)=-isign(kfpr(isub,2),ksw)
12740 
12741  ELSEIF(isub.LE.367.OR.isub.EQ.379.OR.isub.EQ.380) THEN
12742 C...f + fbar -> neutral neutral technicolor
12743  mint(21)=kfpr(isub,1)
12744  mint(22)=kfpr(isub,2)
12745 
12746  ELSEIF(isub.EQ.374.OR.isub.EQ.375.OR.isub.EQ.378) THEN
12747 C...f + fbar' -> neutral charged technicolor
12748  in=1
12749  ic=2
12750  kch1=kchg(iabs(mint(15)),1)*isign(1,mint(15))
12751  kch2=kchg(iabs(mint(16)),1)*isign(1,mint(16))
12752  IF(mint(15)*(kch1+kch2).LT.0) js=2
12753  mint(23-js)=isign(kfpr(isub,ic),kch1+kch2)
12754  mint(20+js)=kfpr(isub,in)
12755 
12756  ELSEIF(isub.GE.370.AND.isub.LE.377) THEN
12757 C...f + fbar' -> charged neutral technicolor
12758  in=2
12759  ic=1
12760  kch1=kchg(iabs(mint(15)),1)*isign(1,mint(15))
12761  kch2=kchg(iabs(mint(16)),1)*isign(1,mint(16))
12762  IF(mint(15)*(kch1+kch2).GT.0) js=2
12763  mint(20+js)=isign(kfpr(isub,ic),kch1+kch2)
12764  mint(23-js)=kfpr(isub,in)
12765  ENDIF
12766 
12767  ELSEIF(isub.LE.400) THEN
12768  IF(isub.EQ.381) THEN
12769 C...f + f' -> f + f' (g exchange); th = (p(f)-p(f))**2, TC extensions
12770  kcc=mint(2)
12771  IF(mint(15)*mint(16).LT.0) kcc=kcc+2
12772 
12773  ELSEIF(isub.EQ.382) THEN
12774 C...f + fbar -> f' + fbar'; th = (p(f)-p(f'))**2, TC extensions
12775  mint(21)=isign(kflf,mint(15))
12776  mint(22)=-mint(21)
12777  kcc=4
12778 
12779  ELSEIF(isub.EQ.383) THEN
12780 C...f + fbar -> g + g; th arbitrary, TC extensions
12781  mint(21)=21
12782  mint(22)=21
12783  kcc=mint(2)+4
12784 
12785  ELSEIF(isub.EQ.384) THEN
12786 C...f + g -> f + g; th = (p(f)-p(f))**2, TC extensions
12787  IF(mint(15).EQ.21) js=2
12788  kcc=mint(2)+6
12789  IF(mint(15).EQ.21) kcc=kcc+2
12790  IF(mint(15).NE.21) kcs=isign(1,mint(15))
12791  IF(mint(16).NE.21) kcs=isign(1,mint(16))
12792 
12793  ELSEIF(isub.EQ.385) THEN
12794 C...g + g -> f + fbar; th arbitrary, TC extensions
12795  kcs=(-1)**int(1.5d0+pyr(0))
12796  mint(21)=isign(kflf,kcs)
12797  mint(22)=-mint(21)
12798  kcc=mint(2)+10
12799 
12800  ELSEIF(isub.EQ.386) THEN
12801 C...g + g -> g + g; th arbitrary, TC extensions
12802  kcc=mint(2)+12
12803  kcs=(-1)**int(1.5d0+pyr(0))
12804 
12805  ELSEIF(isub.EQ.387) THEN
12806 C...q + qbar -> Q + Qbar; th = (p(q)-p(Q))**2, TC extensions
12807  mint(21)=isign(mint(55),mint(15))
12808  mint(22)=-mint(21)
12809  kcc=4
12810 
12811  ELSEIF(isub.EQ.388) THEN
12812 C...g + g -> Q + Qbar; th arbitrary, TC extensions
12813  kcs=(-1)**int(1.5d0+pyr(0))
12814  mint(21)=isign(mint(55),kcs)
12815  mint(22)=-mint(21)
12816  kcc=mint(2)+10
12817 
12818  ELSEIF(isub.EQ.391) THEN
12819 C...f + fbar -> G*.
12820  kfres=kfpr(isub,1)
12821 
12822  ELSEIF(isub.EQ.392) THEN
12823 C...g + g -> G*.
12824  kcc=21
12825  kfres=kfpr(isub,1)
12826 
12827  ELSEIF(isub.EQ.393) THEN
12828 C...q + qbar -> g + G*; th arbitrary.
12829  IF(pyr(0).GT.0.5d0) js=2
12830  mint(20+js)=kfpr(isub,1)
12831  mint(23-js)=kfpr(isub,2)
12832  kcc=17+js
12833 
12834  ELSEIF(isub.EQ.394) THEN
12835 C...q + g -> q + G*; th = (p(f) - p(f))**2
12836  IF(mint(15).EQ.21) js=2
12837  mint(23-js)=kfpr(isub,2)
12838  kcc=15+js
12839  kcs=isign(1,mint(14+js))
12840 
12841  ELSEIF(isub.EQ.395) THEN
12842 C...g + g -> G* + g; th arbitrary.
12843  IF(pyr(0).GT.0.5d0) js=2
12844  mint(23-js)=kfpr(isub,2)
12845  kcc=22+js
12846  ENDIF
12847 
12848  ELSEIF(isub.LE.420) THEN
12849  IF(isub.EQ.401) THEN
12850 C...g + g -> t + b + H+/-
12851  kcs=(-1)**int(1.5d0+pyr(0))
12852  mint(21)=isign(kfpr(isubsv,2),kcs)
12853  mint(22)=isign(5,-kcs)
12854  kcc=11+int(0.5d0+pyr(0))
12855  kfres=isign(kfhigg,-kcs)
12856 
12857  ELSEIF(isub.EQ.402) THEN
12858 C...q + qbar -> t + b + H+/-
12859  kfl=(-1)**int(1.5d0+pyr(0))
12860  mint(21)=isign(int(6.+.5*kfl),kcs)
12861  mint(22)=isign(int(6.-.5*kfl),-kcs)
12862  kcc=4
12863  kfres=isign(kfhigg,-kfl*kcs)
12864  ENDIF
12865 
12866 C...QUARKONIA+++
12867 C...Additional code by Stefan Wolf
12868  ELSEIF(isub.LE.430) THEN
12869  IF(isub.GE.421.AND.isub.LE.424) THEN
12870 C...g + g -> QQ~[n] + g
12871 C...MINT(21), MINT(22) copied from ISUB.EQ.86-89
12872 C...[g + g -> (J/Psi, chi_0c, chi_1c or chi_2c) + g]
12873 C...KCC and KCS copied from ISUB.EQ.86-89 (for ISUB.EQ.421)
12874 C...[g + g -> (J/Psi, chi_0c, chi_1c or chi_2c) + g]
12875 C...or from ISUB.EQ.68 (for ISUB.NE.421)
12876 C...[g + g -> g + g; th arbitrary]
12877  mint(21)=kfpr(isubsv,1)
12878  mint(22)=kfpr(isubsv,2)
12879  IF(isub.EQ.421) THEN
12880  kcc=24
12881  kcs=(-1)**int(1.5d0+pyr(0))
12882  ELSE
12883  kcc=mint(2)+12
12884  kcs=(-1)**int(1.5d0+pyr(0))
12885  ENDIF
12886 
12887  ELSEIF(isub.GE.425.AND.isub.LE.427) THEN
12888 C...q + g -> q + QQ~[n]
12889 C...MINT(21), MINT(22) "copied" from ISUB.EQ.112
12890 C...[f + g -> f + h0; th = (p(f)-p(f))**2; (q + g -> q + h0 only)]
12891 C...KCC copied from ISUB.EQ.28
12892 C...[f + g -> f + g; th = (p(f)-p(f))**2; (q + g -> q + g only)]
12893  IF(mint(15).EQ.21) js=2
12894  mint(23-js)=kfpr(isubsv,2)
12895  kcc=mint(2)+6
12896  IF(mint(15).EQ.21) kcc=kcc+2
12897  IF(mint(15).NE.21) kcs=isign(1,mint(15))
12898  IF(mint(16).NE.21) kcs=isign(1,mint(16))
12899 
12900  ELSEIF(isub.GE.428.AND.isub.LE.430) THEN
12901 C...q + q~ -> g + QQ~[n]
12902 C...MINT(21), MINT(22) "copied" from ISUB.EQ.111
12903 C...[f + fbar -> g + h0; th arbitrary; (q + qbar -> g + h0 only)]
12904 C...KCC copied from ISUB.EQ.13
12905 C...[f + fbar -> g + g; th arbitrary; (q + qbar -> g + g only)]
12906  IF(pyr(0).GT.0.5) js=2
12907  mint(20+js)=21
12908  mint(23-js)=kfpr(isubsv,2)
12909  kcc=mint(2)+4
12910  ENDIF
12911 
12912  ELSEIF(isub.LE.440) THEN
12913  IF(isub.GE.431.AND.isub.LE.433) THEN
12914 C...g + g -> QQ~[n] + g
12915 C...MINT(21), MINT(22) copied from ISUB.EQ.86-89
12916 C...[g + g -> (J/Psi, chi_0c, chi_1c or chi_2c) + g]
12917 C...KCC and KCS copied from ISUB.EQ.86-89
12918 C...[g + g -> (J/Psi, chi_0c, chi_1c or chi_2c) + g]
12919  mint(21)=kfpr(isubsv,1)
12920  mint(22)=kfpr(isubsv,2)
12921  kcc=24
12922  kcs=(-1)**int(1.5d0+pyr(0))
12923 
12924  ELSEIF(isub.GE.434.AND.isub.LE.436) THEN
12925 C...q + g -> q + QQ~[n]
12926 C...MINT(21), MINT(22) "copied" from ISUB.EQ.112
12927 C...[f + g -> f + h0; th = (p(f)-p(f))**2; (q + g -> q + h0 only)]
12928 C...KCC and KCS copied from ISUB.EQ.112
12929 C...[f + g -> f + h0; th = (p(f)-p(f))**2; (q + g -> q + h0 only)]
12930  IF(mint(15).EQ.21) js=2
12931  mint(23-js)=kfpr(isubsv,2)
12932  kcc=15+js
12933  kcs=isign(1,mint(14+js))
12934 
12935  ELSEIF(isub.GE.437.AND.isub.LE.439) THEN
12936 C...q + q~ -> g + QQ~[n]
12937 C...MINT(21), MINT(22) "copied" from ISUB.EQ.111
12938 C...[f + fbar -> g + h0; th arbitrary; (q + qbar -> g + h0 only)]
12939 C...KCC copied from ISUB.EQ.111
12940 C...[f + fbar -> g + h0; th arbitrary; (q + qbar -> g + h0 only)]
12941  IF(pyr(0).GT.0.5) js=2
12942  mint(20+js)=21
12943  mint(23-js)=kfpr(isubsv,2)
12944  kcc=17+js
12945 C...QUARKONIA---
12946  ENDIF
12947  ELSEIF(isub.LE.500) THEN
12948  IF(isub.EQ.481.OR.isub.EQ.482) THEN
12949  kfres=9900001
12950  kcres=pycomp(kfres)
12951  mcol=kchg(kcres,2)
12952  mchg=kchg(kcres,1)
12953  IF(kcres.EQ.0)
12954  $ CALL pyerrm(21,"No resonance for Generic 2-> 2 Process")
12955  idcy=mdcy(kcres,2)
12956  IF(idcy.EQ.0)
12957  $ CALL pyerrm(21,"No decays for resonance in Generic 2->2")
12958  kci1=pycomp(mint(15))
12959  kci2=pycomp(mint(16))
12960  icol1=isign(kchg(kci1,2),mint(15))
12961  icol2=isign(kchg(kci2,2),mint(16))
12962  kff1=kfpr(isub,1)
12963  kff2=kfpr(isub,2)
12964  kcf1=pycomp(kff1)
12965  kcf2=pycomp(kff2)
12966  jcol1=sign(kchg(kcf1,2),kff1)
12967  IF(jcol1.EQ.-2) jcol1=2
12968  jcol2=sign(kchg(kcf2,2),kff2)
12969  IF(jcol2.EQ.-2) jcol2=2
12970  kch1=kchg(iabs(mint(15)),1)*isign(1,mint(15))
12971  kch2=kchg(iabs(mint(16)),1)*isign(1,mint(16))
12972  kchw=kch1+kch2
12973  krel=1
12974  IF(mchg.NE.0.AND.kchw.EQ.-mchg) krel=-1
12975  IF(kchg(kcf1,3).NE.0) kff1=kff1*krel
12976  IF(kchg(kcf2,3).NE.0) kff2=kff2*krel
12977  IF(jcol1.EQ.1.OR.jcol1.EQ.-1) jcol1=jcol1*krel
12978  IF(jcol2.EQ.1.OR.jcol2.EQ.-1) jcol2=jcol2*krel
12979  IF((icol1.EQ.1.AND.icol2.EQ.-1).OR.
12980  $ (icol2.EQ.1.AND.icol1.EQ.-1)) THEN
12981  IF(pyr(0).GT.0.5d0) js=2
12982  mint(20+js)=kff1
12983  mint(23-js)=kff2
12984  IF(jcol1.EQ.0.AND.jcol2.EQ.0) THEN
12985 
12986  ELSEIF(jcol1.EQ.0.AND.jcol2.EQ.2) THEN
12987  kcc=17+js
12988  mint(20+js)=kff2
12989  mint(23-js)=kff1
12990  ELSEIF(jcol1.EQ.2.AND.jcol2.EQ.0) THEN
12991  kcc=17+js
12992  mint(20+js)=kff1
12993  mint(23-js)=kff2
12994  ELSEIF(jcol1.EQ.2.AND.jcol2.EQ.2.AND.mcol.EQ.0) THEN
12995 
12996  ELSEIF(jcol1.EQ.2.AND.jcol2.EQ.2) THEN
12997  kcc=mint(2)+4
12998  ELSEIF((jcol1.EQ.1.AND.jcol2.EQ.-1).OR.
12999  $ (jcol1.EQ.-1.AND.jcol2.EQ.1)) THEN
13000  IF(icol1.EQ.jcol1) THEN
13001  js=1
13002  mint(21)=kff1
13003  mint(22)=kff2
13004  ELSE
13005  js=2
13006  mint(21)=kff2
13007  mint(22)=kff1
13008  ENDIF
13009  IF(mcol.EQ.0) THEN
13010 
13011  ELSE
13012  kcc=4
13013  ENDIF
13014  ENDIF
13015  ELSEIF((icol1.EQ.2.AND.(icol2.EQ.1.OR.icol2.EQ.-1)).OR.
13016  $ (icol2.EQ.2.AND.(icol1.EQ.1.OR.icol1.EQ.-1))) THEN
13017  IF((jcol1.EQ.2.AND.abs(jcol2).EQ.1).OR.
13018  $ (jcol2.EQ.2.AND.abs(jcol1).EQ.1)) THEN
13019  IF(mint(15).EQ.21) js=2
13020  kcc=mint(2)+6
13021  IF(mint(15).EQ.21) kcc=kcc+2
13022  IF(mint(15).NE.21) kcs=isign(1,mint(15))
13023  IF(mint(16).NE.21) kcs=isign(1,mint(16))
13024  IF(jcol1.EQ.2) THEN
13025  mint(20+js)=kff2
13026  mint(23-js)=kff1
13027  ELSE
13028  mint(20+js)=kff1
13029  mint(23-js)=kff2
13030  ENDIF
13031  ELSEIF((abs(jcol1).EQ.1.AND.jcol2.EQ.0).OR.
13032  $ (abs(jcol2).EQ.1.AND.jcol1.EQ.0)) THEN
13033  IF(mint(15).EQ.21) js=2
13034  kcc=15+js
13035  kcs=isign(1,mint(14+js))
13036  IF(jcol1.EQ.0) THEN
13037  mint(23-js)=kff1
13038  mint(20+js)=kff2
13039  ELSE
13040  mint(23-js)=kff2
13041  mint(20+js)=kff1
13042  ENDIF
13043  ENDIF
13044  ELSEIF(icol1.EQ.2.AND.icol2.EQ.2.AND.
13045  $ jcol1.EQ.0.AND.jcol2.EQ.0) THEN
13046  IF(pyr(0).GT.0.5d0) js=2
13047  kcc=21
13048  mint(20+js)=kff1
13049  mint(23-js)=kff2
13050  ELSEIF(icol1.EQ.2.AND.icol2.EQ.2.AND.
13051  $ ((jcol1.EQ.0.AND.jcol2.EQ.2).OR.
13052  $ ((jcol2.EQ.0.AND.jcol1.EQ.2)))) THEN
13053  IF(pyr(0).GT.0.5d0) js=2
13054  kcc=22+js
13055  kcs=(-1)**int(1.5d0+pyr(0))
13056  IF(jcol1.EQ.0) THEN
13057  mint(23-js)=kff1
13058  mint(20+js)=kff2
13059  ELSE
13060  mint(23-js)=kff2
13061  mint(20+js)=kff1
13062  ENDIF
13063  ELSEIF(icol1.EQ.2.AND.icol2.EQ.2.AND.
13064  $ ((jcol1.EQ.1.AND.jcol2.EQ.-1).OR.
13065  $ ((jcol2.EQ.1.AND.jcol1.EQ.-1)))) THEN
13066 C....two choices, 0 or 2 depending upon mother properties
13067  IF(mcol.EQ.2) THEN
13068  kcs=(-1)**int(1.5d0+pyr(0))
13069  kcc=mint(2)+10
13070  IF(jcol1.EQ.1) THEN
13071  mint(21)=kff1*kcs
13072  mint(22)=kff2*kcs
13073  ELSE
13074  mint(22)=kff1*kcs
13075  mint(21)=kff2*kcs
13076  ENDIF
13077 c MINT(20+JS)=KFF1*KCS
13078 c MINT(23-JS)=KFF2*KCS
13079  ELSEIF(mcol.EQ.0) THEN
13080  kcc=21
13081  mint(20+js)=kff1*kcs
13082  mint(23-js)=kff2*kcs
13083  ENDIF
13084 
13085  ELSEIF(icol1.EQ.2.AND.icol2.EQ.2.AND.
13086  $ jcol1.EQ.2.AND.jcol2.EQ.2) THEN
13087 C....two choices, 0 or 2 depending upon mother properties
13088  IF(mcol.EQ.0) THEN
13089  kcc=21
13090  IF(pyr(0).GT.0.5d0) js=2
13091  mint(20+js)=kff1
13092  mint(23-js)=kff2
13093  ELSEIF(mcol.EQ.2) THEN
13094  IF(pyr(0).GT.0.5d0) js=2
13095  kcc=mint(2)+12
13096  kcs=(-1)**int(1.5d0+pyr(0))
13097  mint(20+js)=kff1
13098  mint(23-js)=kff2
13099  ENDIF
13100  ELSEIF((icol1.EQ.1.AND.icol2.EQ.1).OR.
13101  $ (icol1.EQ.-1.AND.icol2.EQ.-1)) THEN
13102  kcc=mint(2)
13103  IF(pyr(0).GT.0.5d0) js=2
13104  mint(20+js)=kff1
13105  mint(23-js)=kff2
13106  ELSEIF(icol1.EQ.0.AND.icol2.EQ.0.AND.mcol.EQ.0) THEN
13107  kcc=20
13108  IF(pyr(0).GT.0.5d0) js=2
13109  mint(20+js)=kff1
13110  mint(23-js)=kff2
13111  ELSE
13112  CALL pyerrm(21,"PYSCAT: No recognized Generic Process")
13113  ENDIF
13114  IF(isubsv.EQ.482) kfres=0
13115  ENDIF
13116  ENDIF
13117 
13118  IF(iset(isub).EQ.11) THEN
13119 C...Store documentation for user-defined processes
13120  bezup=(pup(3,1)+pup(3,2))/(pup(4,1)+pup(4,2))
13121  kuppo(1)=mint(83)+5
13122  kuppo(2)=mint(83)+6
13123  i=mint(83)+6
13124  DO 470 iup=3,nup
13125  kuppo(iup)=0
13126  IF(mstp(128).GE.2.AND.mothup(1,iup).GE.3) THEN
13127  idoc=idoc-1
13128  mint(4)=mint(4)-1
13129  goto 470
13130  ENDIF
13131  i=i+1
13132  kuppo(iup)=i
13133  k(i,1)=21
13134  k(i,2)=idup(iup)
13135  IF(idup(iup).EQ.0) k(i,2)=90
13136  k(i,3)=0
13137  IF(mothup(1,iup).GE.3) k(i,3)=kuppo(mothup(1,iup))
13138  k(i,4)=0
13139  k(i,5)=0
13140  DO 460 j=1,5
13141  p(i,j)=pup(j,iup)
13142  460 CONTINUE
13143  v(i,5)=vtimup(iup)
13144  470 CONTINUE
13145  CALL pyrobo(mint(83)+7,mint(83)+4+nup,0d0,vint(24),0d0,0d0,
13146  & -bezup)
13147 
13148 C...Store final state partons for user-defined processes
13149  n=ipu2
13150  DO 490 iup=3,nup
13151  n=n+1
13152  k(n,1)=1
13153  IF(istup(iup).EQ.2.OR.istup(iup).EQ.3) k(n,1)=11
13154  k(n,2)=idup(iup)
13155  IF(idup(iup).EQ.0) k(n,2)=90
13156  IF(mstp(128).LE.0.OR.mothup(1,iup).EQ.0) THEN
13157  k(n,3)=kuppo(iup)
13158  ELSE
13159  k(n,3)=mint(84)+mothup(1,iup)
13160  ENDIF
13161  k(n,4)=0
13162  k(n,5)=0
13163 C...Search for daughters of intermediate colourless particles.
13164  IF(k(n,1).EQ.11.AND.kchg(pycomp(k(n,2)),2).EQ.0) THEN
13165  DO 475 iupdau=iup+1,nup
13166  IF(mothup(1,iupdau).EQ.iup.AND.k(n,4).EQ.0) k(n,4)=
13167  & n+iupdau-iup
13168  IF(mothup(1,iupdau).EQ.iup) k(n,5)=n+iupdau-iup
13169  475 CONTINUE
13170  ENDIF
13171  DO 480 j=1,5
13172  p(n,j)=pup(j,iup)
13173  480 CONTINUE
13174  v(n,5)=vtimup(iup)
13175  490 CONTINUE
13176  CALL pyrobo(ipu3,n,0d0,vint(24),0d0,0d0,-bezup)
13177 
13178 C...Arrange colour flow for user-defined processes
13179  nlbl=0
13180  DO 540 iup1=1,nup
13181  i1=mint(84)+iup1
13182  IF(kchg(pycomp(k(i1,2)),2).EQ.0) goto 540
13183  IF(k(i1,1).EQ.1) k(i1,1)=3
13184  IF(k(i1,1).EQ.11) k(i1,1)=14
13185 C...Find a not yet considered colour/anticolour line.
13186  DO 530 isde1=1,2
13187  IF(icolup(isde1,iup1).EQ.0) goto 530
13188  nmat=0
13189  DO 500 ilbl=1,nlbl
13190  IF(icolup(isde1,iup1).EQ.ilab(ilbl)) nmat=1
13191  500 CONTINUE
13192  IF(nmat.EQ.0) THEN
13193  nlbl=nlbl+1
13194  ilab(nlbl)=icolup(isde1,iup1)
13195 C...Find all others belonging to same line.
13196  i3=i1
13197  i4=0
13198  DO 520 iup2=iup1+1,nup
13199  i2=mint(84)+iup2
13200  DO 510 isde2=1,2
13201  IF(icolup(isde2,iup2).EQ.icolup(isde1,iup1)) THEN
13202  IF(isde2.EQ.isde1) THEN
13203  k(i3,3+isde2)=k(i3,3+isde2)+i2
13204  k(i2,3+isde2)=k(i2,3+isde2)+mstu(5)*i3
13205  i3=i2
13206  ELSEIF(i4.NE.0) THEN
13207  k(i4,3+isde2)=k(i4,3+isde2)+i2
13208  k(i2,3+isde2)=k(i2,3+isde2)+mstu(5)*i4
13209  i4=i2
13210  ELSEIF(iup2.LE.2) THEN
13211  k(i1,3+isde1)=k(i1,3+isde1)+i2
13212  k(i2,3+isde2)=k(i2,3+isde2)+i1
13213  i4=i2
13214  ELSE
13215  k(i1,3+isde1)=k(i1,3+isde1)+mstu(5)*i2
13216  k(i2,3+isde2)=k(i2,3+isde2)+mstu(5)*i1
13217  i4=i2
13218  ENDIF
13219  ENDIF
13220  510 CONTINUE
13221  520 CONTINUE
13222  ENDIF
13223  530 CONTINUE
13224  540 CONTINUE
13225 
13226  ELSEIF(idoc.EQ.7) THEN
13227 C...Resonance not decaying; store kinematics
13228  i=mint(83)+7
13229  k(ipu3,1)=1
13230  k(ipu3,2)=kfres
13231  k(ipu3,3)=i
13232  p(ipu3,4)=shuser
13233  p(ipu3,5)=shuser
13234  k(i,1)=21
13235  k(i,2)=kfres
13236  p(i,4)=shuser
13237  p(i,5)=shuser
13238  n=ipu3
13239  mint(21)=kfres
13240  mint(22)=0
13241 
13242 C...Special cases: colour flow in coloured resonances
13243  kcres=pycomp(kfres)
13244  IF(kchg(kcres,2).NE.0) THEN
13245  k(ipu3,1)=3
13246  DO 550 j=1,2
13247  jc=j
13248  IF(kcs.EQ.-1) jc=3-j
13249  IF(icol(kcc,1,jc).NE.0.AND.k(ipu1,1).EQ.14) k(ipu1,j+3)=
13250  & mint(84)+icol(kcc,1,jc)
13251  IF(icol(kcc,2,jc).NE.0.AND.k(ipu2,1).EQ.14) k(ipu2,j+3)=
13252  & mint(84)+icol(kcc,2,jc)
13253  IF(icol(kcc,3,jc).NE.0.AND.k(ipu3,1).EQ.3) k(ipu3,j+3)=
13254  & mstu(5)*(mint(84)+icol(kcc,3,jc))
13255  550 CONTINUE
13256  ELSE
13257  k(ipu1,4)=ipu2
13258  k(ipu1,5)=ipu2
13259  k(ipu2,4)=ipu1
13260  k(ipu2,5)=ipu1
13261  ENDIF
13262 
13263  ELSEIF(idoc.EQ.8) THEN
13264 C...2 -> 2 processes: store outgoing partons in their CM-frame
13265  DO 560 jt=1,2
13266  i=mint(84)+2+jt
13267  kca=pycomp(mint(20+jt))
13268  k(i,1)=1
13269  IF(kchg(kca,2).NE.0) k(i,1)=3
13270  k(i,2)=mint(20+jt)
13271  k(i,3)=mint(83)+idoc+jt-2
13272  kfaa=iabs(k(i,2))
13273  IF(kfpr(isubsv,1+mod(js+jt,2)).NE.0) THEN
13274  p(i,5)=sqrt(vint(63+mod(js+jt,2)))
13275  ELSE
13276  p(i,5)=pymass(k(i,2))
13277  ENDIF
13278  IF((kfaa.EQ.6.OR.kfaa.EQ.7.OR.kfaa.EQ.8).AND.
13279  & p(i,5).LT.parp(42)) p(i,5)=pymass(k(i,2))
13280  560 CONTINUE
13281  IF(p(ipu3,5)+p(ipu4,5).GE.shr) THEN
13282  kfa1=iabs(mint(21))
13283  kfa2=iabs(mint(22))
13284  IF((kfa1.GT.3.AND.kfa1.NE.21).OR.(kfa2.GT.3.AND.kfa2.NE.21))
13285  & THEN
13286  mint(51)=1
13287  RETURN
13288  ENDIF
13289  p(ipu3,5)=0d0
13290  p(ipu4,5)=0d0
13291  ENDIF
13292  p(ipu3,4)=0.5d0*(shr+(p(ipu3,5)**2-p(ipu4,5)**2)/shr)
13293  p(ipu3,3)=sqrt(max(0d0,p(ipu3,4)**2-p(ipu3,5)**2))
13294  p(ipu4,4)=shr-p(ipu3,4)
13295  p(ipu4,3)=-p(ipu3,3)
13296  n=ipu4
13297  mint(7)=mint(83)+7
13298  mint(8)=mint(83)+8
13299 
13300 C...Rotate outgoing partons using cos(theta)=(th-uh)/lam(sh,sqm3,sqm4)
13301  CALL pyrobo(ipu3,ipu4,acos(vint(23)),vint(24),0d0,0d0,0d0)
13302 
13303  ELSEIF(idoc.EQ.9) THEN
13304 C...2 -> 3 processes: store outgoing partons in their CM frame
13305  DO 570 jt=1,2
13306  i=mint(84)+2+jt
13307  kca=pycomp(mint(20+jt))
13308  k(i,1)=1
13309  IF(kchg(kca,2).NE.0) k(i,1)=3
13310  k(i,2)=mint(20+jt)
13311  k(i,3)=mint(83)+idoc+jt-3
13312  jta=jt
13313 C...t and b in opposide order in event list as compared to
13314 C...matrix element?
13315  IF(isub.EQ.402.AND.iabs(mint(21)).EQ.5) jta=3-jt
13316  IF(iabs(k(i,2)).LE.22) THEN
13317  p(i,5)=pymass(k(i,2))
13318  ELSE
13319  p(i,5)=sqrt(vint(63+mod(js+jta,2)))
13320  ENDIF
13321  pt=sqrt(max(0d0,vint(197+5*jta)-p(i,5)**2+vint(196+5*jta)**2))
13322  p(i,1)=pt*cos(vint(198+5*jta))
13323  p(i,2)=pt*sin(vint(198+5*jta))
13324  570 CONTINUE
13325  k(ipu5,1)=1
13326  k(ipu5,2)=kfres
13327  k(ipu5,3)=mint(83)+idoc
13328  p(ipu5,5)=shr
13329  p(ipu5,1)=-p(ipu3,1)-p(ipu4,1)
13330  p(ipu5,2)=-p(ipu3,2)-p(ipu4,2)
13331  pms1=p(ipu3,5)**2+p(ipu3,1)**2+p(ipu3,2)**2
13332  pms2=p(ipu4,5)**2+p(ipu4,1)**2+p(ipu4,2)**2
13333  pms3=p(ipu5,5)**2+p(ipu5,1)**2+p(ipu5,2)**2
13334  pmt3=sqrt(pms3)
13335  p(ipu5,3)=pmt3*sinh(vint(211))
13336  p(ipu5,4)=pmt3*cosh(vint(211))
13337  pms12=(shpr-p(ipu5,4))**2-p(ipu5,3)**2
13338  sql12=(pms12-pms1-pms2)**2-4d0*pms1*pms2
13339  IF(sql12.LE.0d0) THEN
13340  mint(51)=1
13341  RETURN
13342  ENDIF
13343  p(ipu3,3)=(-p(ipu5,3)*(pms12+pms1-pms2)+
13344  & vint(213)*(shpr-p(ipu5,4))*sqrt(sql12))/(2d0*pms12)
13345  p(ipu4,3)=-p(ipu3,3)-p(ipu5,3)
13346  IF(isub.EQ.402.AND.iabs(mint(21)).EQ.5) THEN
13347 C...t and b in opposide order in event list as compared to
13348 C...matrix element
13349  p(ipu4,3)=(-p(ipu5,3)*(pms12+pms2-pms1)+
13350  & vint(213)*(shpr-p(ipu5,4))*sqrt(sql12))/(2d0*pms12)
13351  p(ipu3,3)=-p(ipu4,3)-p(ipu5,3)
13352  END IF
13353  p(ipu3,4)=sqrt(pms1+p(ipu3,3)**2)
13354  p(ipu4,4)=sqrt(pms2+p(ipu4,3)**2)
13355  mint(23)=kfres
13356  n=ipu5
13357  mint(7)=mint(83)+7
13358  mint(8)=mint(83)+8
13359 
13360  ELSEIF(idoc.EQ.11) THEN
13361 C...Z0 + Z0 -> h0, W+ + W- -> h0: store Higgs and outgoing partons
13362  phi(1)=paru(2)*pyr(0)
13363  phi(2)=phi(1)-phir
13364  DO 580 jt=1,2
13365  i=mint(84)+2+jt
13366  k(i,1)=1
13367  IF(kchg(pycomp(mint(20+jt)),2).NE.0) k(i,1)=3
13368  k(i,2)=mint(20+jt)
13369  k(i,3)=mint(83)+idoc+jt-2
13370  p(i,5)=pymass(k(i,2))
13371  IF(0.5d0*shpr*z(jt).LE.p(i,5)) THEN
13372  mint(51)=1
13373  RETURN
13374  ENDIF
13375  pabs=sqrt(max(0d0,(0.5d0*shpr*z(jt))**2-p(i,5)**2))
13376  ptabs=pabs*sqrt(max(0d0,1d0-cthe(jt)**2))
13377  p(i,1)=ptabs*cos(phi(jt))
13378  p(i,2)=ptabs*sin(phi(jt))
13379  p(i,3)=pabs*cthe(jt)*(-1)**(jt+1)
13380  p(i,4)=0.5d0*shpr*z(jt)
13381  izw=mint(83)+6+jt
13382  k(izw,1)=21
13383  k(izw,2)=23
13384  IF(isub.EQ.8) k(izw,2)=isign(24,pychge(mint(14+jt)))
13385  k(izw,3)=izw-2
13386  p(izw,1)=-p(i,1)
13387  p(izw,2)=-p(i,2)
13388  p(izw,3)=(0.5d0*shpr-pabs*cthe(jt))*(-1)**(jt+1)
13389  p(izw,4)=0.5d0*shpr*(1d0-z(jt))
13390  p(izw,5)=-sqrt(max(0d0,p(izw,3)**2+ptabs**2-p(izw,4)**2))
13391  580 CONTINUE
13392  i=mint(83)+9
13393  k(ipu5,1)=1
13394  k(ipu5,2)=kfres
13395  k(ipu5,3)=i
13396  p(ipu5,5)=shr
13397  p(ipu5,1)=-p(ipu3,1)-p(ipu4,1)
13398  p(ipu5,2)=-p(ipu3,2)-p(ipu4,2)
13399  p(ipu5,3)=-p(ipu3,3)-p(ipu4,3)
13400  p(ipu5,4)=shpr-p(ipu3,4)-p(ipu4,4)
13401  k(i,1)=21
13402  k(i,2)=kfres
13403  DO 590 j=1,5
13404  p(i,j)=p(ipu5,j)
13405  590 CONTINUE
13406  n=ipu5
13407  mint(23)=kfres
13408 
13409  ELSEIF(idoc.EQ.12) THEN
13410 C...Z0 and W+/- scattering: store bosons and outgoing partons
13411  phi(1)=paru(2)*pyr(0)
13412  phi(2)=phi(1)-phir
13413  jtran=int(1.5d0+pyr(0))
13414  DO 600 jt=1,2
13415  i=mint(84)+2+jt
13416  k(i,1)=1
13417  IF(kchg(pycomp(mint(20+jt)),2).NE.0) k(i,1)=3
13418  k(i,2)=mint(20+jt)
13419  k(i,3)=mint(83)+idoc+jt-2
13420  p(i,5)=pymass(k(i,2))
13421  IF(0.5d0*shpr*z(jt).LE.p(i,5)) p(i,5)=0d0
13422  pabs=sqrt(max(0d0,(0.5d0*shpr*z(jt))**2-p(i,5)**2))
13423  ptabs=pabs*sqrt(max(0d0,1d0-cthe(jt)**2))
13424  p(i,1)=ptabs*cos(phi(jt))
13425  p(i,2)=ptabs*sin(phi(jt))
13426  p(i,3)=pabs*cthe(jt)*(-1)**(jt+1)
13427  p(i,4)=0.5d0*shpr*z(jt)
13428  izw=mint(83)+6+jt
13429  k(izw,1)=21
13430  IF(mint(14+jt).EQ.mint(20+jt)) THEN
13431  k(izw,2)=23
13432  ELSE
13433  k(izw,2)=isign(24,pychge(mint(14+jt))-pychge(mint(20+jt)))
13434  ENDIF
13435  k(izw,3)=izw-2
13436  p(izw,1)=-p(i,1)
13437  p(izw,2)=-p(i,2)
13438  p(izw,3)=(0.5d0*shpr-pabs*cthe(jt))*(-1)**(jt+1)
13439  p(izw,4)=0.5d0*shpr*(1d0-z(jt))
13440  p(izw,5)=-sqrt(max(0d0,p(izw,3)**2+ptabs**2-p(izw,4)**2))
13441  ipu=mint(84)+4+jt
13442  k(ipu,1)=3
13443  k(ipu,2)=kfpr(isub,jt)
13444  IF(isub.EQ.72.AND.jt.EQ.jtran) k(ipu,2)=-k(ipu,2)
13445  IF(isub.EQ.73.OR.isub.EQ.77) k(ipu,2)=k(izw,2)
13446  k(ipu,3)=mint(83)+8+jt
13447  IF(iabs(k(ipu,2)).LE.10.OR.k(ipu,2).EQ.21) THEN
13448  p(ipu,5)=pymass(k(ipu,2))
13449  ELSE
13450  p(ipu,5)=sqrt(vint(63+mod(js+jt,2)))
13451  ENDIF
13452  mint(22+jt)=k(ipu,2)
13453  600 CONTINUE
13454 C...Find rotation and boost for hard scattering subsystem
13455  i1=mint(83)+7
13456  i2=mint(83)+8
13457  bexcm=(p(i1,1)+p(i2,1))/(p(i1,4)+p(i2,4))
13458  beycm=(p(i1,2)+p(i2,2))/(p(i1,4)+p(i2,4))
13459  bezcm=(p(i1,3)+p(i2,3))/(p(i1,4)+p(i2,4))
13460  gamcm=(p(i1,4)+p(i2,4))/shr
13461  bepcm=bexcm*p(i1,1)+beycm*p(i1,2)+bezcm*p(i1,3)
13462  px=p(i1,1)+gamcm*(gamcm/(1d0+gamcm)*bepcm-p(i1,4))*bexcm
13463  py=p(i1,2)+gamcm*(gamcm/(1d0+gamcm)*bepcm-p(i1,4))*beycm
13464  pz=p(i1,3)+gamcm*(gamcm/(1d0+gamcm)*bepcm-p(i1,4))*bezcm
13465  thecm=pyangl(pz,sqrt(px**2+py**2))
13466  phicm=pyangl(px,py)
13467 C...Store hard scattering subsystem. Rotate and boost it
13468  sqlam=(sh-p(ipu5,5)**2-p(ipu6,5)**2)**2-4d0*p(ipu5,5)**2*
13469  & p(ipu6,5)**2
13470  pabs=sqrt(max(0d0,sqlam/(4d0*sh)))
13471  cthwz=vint(23)
13472  sthwz=sqrt(max(0d0,1d0-cthwz**2))
13473  phiwz=vint(24)-phicm
13474  p(ipu5,1)=pabs*sthwz*cos(phiwz)
13475  p(ipu5,2)=pabs*sthwz*sin(phiwz)
13476  p(ipu5,3)=pabs*cthwz
13477  p(ipu5,4)=sqrt(pabs**2+p(ipu5,5)**2)
13478  p(ipu6,1)=-p(ipu5,1)
13479  p(ipu6,2)=-p(ipu5,2)
13480  p(ipu6,3)=-p(ipu5,3)
13481  p(ipu6,4)=sqrt(pabs**2+p(ipu6,5)**2)
13482  CALL pyrobo(ipu5,ipu6,thecm,phicm,bexcm,beycm,bezcm)
13483  DO 620 jt=1,2
13484  i1=mint(83)+8+jt
13485  i2=mint(84)+4+jt
13486  k(i1,1)=21
13487  k(i1,2)=k(i2,2)
13488  DO 610 j=1,5
13489  p(i1,j)=p(i2,j)
13490  610 CONTINUE
13491  620 CONTINUE
13492  n=ipu6
13493  mint(7)=mint(83)+9
13494  mint(8)=mint(83)+10
13495  ENDIF
13496 
13497  IF(iset(isub).EQ.11) THEN
13498  ELSEIF(idoc.GE.8) THEN
13499 C...Store colour connection indices
13500  DO 630 j=1,2
13501  jc=j
13502  IF(kcs.EQ.-1) jc=3-j
13503  IF(icol(kcc,1,jc).NE.0.AND.k(ipu1,1).EQ.14) k(ipu1,j+3)=
13504  & k(ipu1,j+3)+mint(84)+icol(kcc,1,jc)
13505  IF(icol(kcc,2,jc).NE.0.AND.k(ipu2,1).EQ.14) k(ipu2,j+3)=
13506  & k(ipu2,j+3)+mint(84)+icol(kcc,2,jc)
13507  IF(icol(kcc,3,jc).NE.0.AND.k(ipu3,1).EQ.3) k(ipu3,j+3)=
13508  & mstu(5)*(mint(84)+icol(kcc,3,jc))
13509  IF(icol(kcc,4,jc).NE.0.AND.k(ipu4,1).EQ.3) k(ipu4,j+3)=
13510  & mstu(5)*(mint(84)+icol(kcc,4,jc))
13511  630 CONTINUE
13512 
13513 C...Copy outgoing partons to documentation lines
13514  imax=2
13515  IF(idoc.EQ.9) imax=3
13516  DO 650 i=1,imax
13517  i1=mint(83)+idoc-imax+i
13518  i2=mint(84)+2+i
13519  k(i1,1)=21
13520  k(i1,2)=k(i2,2)
13521  IF(idoc.LE.9) k(i1,3)=0
13522  IF(idoc.GE.11) k(i1,3)=mint(83)+2+i
13523  DO 640 j=1,5
13524  p(i1,j)=p(i2,j)
13525  640 CONTINUE
13526  650 CONTINUE
13527 
13528  ELSEIF(idoc.EQ.9) THEN
13529 C...Store colour connection indices
13530  DO 660 j=1,2
13531  jc=j
13532  IF(kcs.EQ.-1) jc=3-j
13533  IF(icol(kcc,1,jc).NE.0.AND.k(ipu1,1).EQ.14) k(ipu1,j+3)=
13534  & k(ipu1,j+3)+mint(84)+icol(kcc,1,jc)+
13535  & max(0,min(1,icol(kcc,1,jc)-2))
13536  IF(icol(kcc,2,jc).NE.0.AND.k(ipu2,1).EQ.14) k(ipu2,j+3)=
13537  & k(ipu2,j+3)+mint(84)+icol(kcc,2,jc)+
13538  & max(0,min(1,icol(kcc,2,jc)-2))
13539  IF(icol(kcc,3,jc).NE.0.AND.k(ipu4,1).EQ.3) k(ipu4,j+3)=
13540  & mstu(5)*(mint(84)+icol(kcc,3,jc))
13541  IF(icol(kcc,4,jc).NE.0.AND.k(ipu5,1).EQ.3) k(ipu5,j+3)=
13542  & mstu(5)*(mint(84)+icol(kcc,4,jc))
13543  660 CONTINUE
13544 
13545 C...Copy outgoing partons to documentation lines
13546  DO 680 i=1,3
13547  i1=mint(83)+idoc-3+i
13548  i2=mint(84)+2+i
13549  k(i1,1)=21
13550  k(i1,2)=k(i2,2)
13551  k(i1,3)=0
13552  DO 670 j=1,5
13553  p(i1,j)=p(i2,j)
13554  670 CONTINUE
13555  680 CONTINUE
13556  ENDIF
13557 
13558 C...Copy outgoing partons to list of allowed radiators.
13559  npart=0
13560  IF(mint(35).GE.2.AND.iset(isub).NE.0) THEN
13561  DO 690 i=mint(84)+3,n
13562  npart=npart+1
13563  ipart(npart)=i
13564  ptpart(npart)=sqrt(p(i,5)**2+p(i,1)**2+p(i,2)**2)
13565  690 CONTINUE
13566  ENDIF
13567 
13568 C...Low-pT events: remove gluons used for string drawing purposes
13569  IF(isub.EQ.95) THEN
13570  IF(mint(35).LE.1) THEN
13571  k(ipu3,1)=k(ipu3,1)+10
13572  k(ipu4,1)=k(ipu4,1)+10
13573  ENDIF
13574  DO 700 j=41,66
13575  vintsv(j)=vint(j)
13576  vint(j)=0d0
13577  700 CONTINUE
13578  DO 720 i=mint(83)+5,mint(83)+8
13579  DO 710 j=1,5
13580  p(i,j)=0d0
13581  710 CONTINUE
13582  720 CONTINUE
13583  ENDIF
13584 
13585  RETURN
13586  END
13587 
13588 C***********************************************************************
13589 
13590 C...PYEVOL
13591 C...Handles intertwined pT-ordered spacelike initial-state parton
13592 C...and multiple interactions.
13593 
13594  SUBROUTINE pyevol(MODE,PT2MAX,PT2MIN)
13595 C...Mode = -1 : Initialize first time. Determine MAX and MIN scales.
13596 C...MODE = 0 : (Re-)initialize ISR/MI evolution.
13597 C...Mode = 1 : Evolve event from PT2MAX to PT2MIN.
13598 
13599 C...Double precision and integer declarations.
13600  IMPLICIT DOUBLE PRECISION(a-h, o-z)
13601  IMPLICIT INTEGER(i-n)
13602  INTEGER pyk,pychge,pycomp
13603 C...External
13604  EXTERNAL pyalps
13605  DOUBLE PRECISION pyalps
13606 C...Parameter statement for maximum size of showers.
13607  parameter(maxnur=1000)
13608 C...Commonblocks.
13609  common/pypart/npart,npartd,ipart(maxnur),ptpart(maxnur)
13610  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
13611  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
13612  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
13613  common/pypars/mstp(200),parp(200),msti(200),pari(200)
13614  common/pyint1/mint(400),vint(400)
13615  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
13616  common/pyint3/xsfx(2,-40:40),isig(1000,3),sigh(1000)
13617  common/pyintm/kfival(2,3),nmi(2),imi(2,800,2),nvc(2,-6:6),
13618  & xassoc(2,-6:6,240),xpsvc(-6:6,-1:240),pvctot(2,-1:1),
13619  & xmi(2,240),pt2mi(240),imisep(0:240)
13620  common/pyctag/nct,mct(4000,2)
13621  common/pyismx/mimx,jsmx,kflamx,kflcmx,kfbeam(2),nisgen(2,240),
13622  & pt2mx,pt2amx,zmx,rm2cmx,q2bmx,phimx
13623  common/pyisjn/mjn1mx,mjn2mx,mjoind(2,240)
13624 C...Local arrays and saved variables.
13625  dimension vintsv(11:80),ksav(4,5),psav(4,5),vsav(4,5),shat(240)
13626  SAVE nsav,nparts,m15sv,m16sv,m21sv,m22sv,vintsv,shat,isubhd,alam3
13627  & ,psav,ksav,vsav
13628 
13629  SAVE /pypart/,/pyjets/,/pydat1/,/pydat2/,/pypars/,/pyint1/,
13630  & /pyint2/,/pyint3/,/pyintm/,/pyctag/,/pyismx/,/pyisjn/
13631 
13632 C----------------------------------------------------------------------
13633 C...MODE=-1: Pre-initialization. Store info on hard scattering etc,
13634 C...done only once per event, while MODE=0 is repeated each time the
13635 C...evolution needs to be restarted.
13636  IF (mode.EQ.-1) THEN
13637  isubhd=mint(1)
13638  nsav=n
13639  nparts=npart
13640 C...Store hard scattering variables
13641  m15sv=mint(15)
13642  m16sv=mint(16)
13643  m21sv=mint(21)
13644  m22sv=mint(22)
13645  DO 100 j=11,80
13646  vintsv(j)=vint(j)
13647  100 CONTINUE
13648  DO 120 j=1,5
13649  DO 110 is=1,4
13650  i=is+mint(84)
13651  psav(is,j)=p(i,j)
13652  ksav(is,j)=k(i,j)
13653  vsav(is,j)=v(i,j)
13654  110 CONTINUE
13655  120 CONTINUE
13656 
13657 C...Set shat for hardest scattering
13658  shat(1)=vint(44)
13659  IF(iset(isubhd).GE.3.AND.iset(isubhd).LE.5) shat(1)=vint(26)
13660  & *vint(2)
13661 
13662 C...Compute 3-Flavour Lambda_QCD (sets absolute lowest PT scale below)
13663  rmc=pmas(4,1)
13664  rmb=pmas(5,1)
13665  alam4=parp(61)
13666  IF(mstu(112).LT.4) alam4=parp(61)*(parp(61)/rmc)**(2d0/25d0)
13667  IF(mstu(112).GT.4) alam4=parp(61)*(rmb/parp(61))**(2d0/25d0)
13668  alam3=alam4*(rmc/alam4)**(2d0/27d0)
13669 
13670 C----------------------------------------------------------------------
13671 C...MODE= 0: Initialize ISR/MI evolution, i.e. begin from hardest
13672 C...interaction initiators, with no previous evolution. Check the input
13673 C...PT2MAX and PT2MIN and impose extra constraints on minimum PT2 (e.g.
13674 C...must be larger than Lambda_QCD) and maximum PT2 (e.g. must be
13675 C...smaller than the CM energy / 2.)
13676  ELSEIF (mode.EQ.0) THEN
13677 C...Reset counters and switches
13678  n=nsav
13679  npart=nparts
13680  mint(30)=0
13681  mint(31)=1
13682  mint(36)=1
13683 C...Reset hard scattering variables
13684  mint(1)=isubhd
13685  DO 130 j=11,80
13686  vint(j)=vintsv(j)
13687  130 CONTINUE
13688  DO 150 j=1,5
13689  DO 140 is=1,4
13690  i=is+mint(84)
13691  p(i,j)=psav(is,j)
13692  k(i,j)=ksav(is,j)
13693  v(i,j)=vsav(is,j)
13694  p(mint(83)+4+is,j)=psav(is,j)
13695  v(mint(83)+4+is,j)=vsav(is,j)
13696  140 CONTINUE
13697  150 CONTINUE
13698 C...Reset statistics on activity in event.
13699  DO 160 j=351,359
13700  mint(j)=0
13701  vint(j)=0d0
13702  160 CONTINUE
13703 C...Reset extra companion reweighting factor
13704  vint(140)=1d0
13705 
13706 C...We do not generate MI for soft process (ISUB=95), but the
13707 C...initialization must be done regardless, for later purposes.
13708  mint(36)=1
13709 
13710 C...Initialize multiple interactions.
13711  CALL pyptmi(-1,ptdum1,ptdum2,ptdum3,idum)
13712  IF(mint(51).NE.0) RETURN
13713 
13714 C...Decide whether quarks in hard scattering were valence or sea
13715  pt2hd=vint(54)
13716  DO 170 js=1,2
13717  mint(30)=js
13718  CALL pyptmi(2,pt2hd,ptdum2,ptdum3,idum)
13719  IF(mint(51).NE.0) RETURN
13720  170 CONTINUE
13721 
13722 C...Set lower cutoff for PT2 iteration and colour interference PT2 scale
13723  vint(18)=0d0
13724  pt2min=max(pt2min,(1.1d0*alam3)**2)
13725  IF (mstp(70).EQ.2) THEN
13726 C...VINT(18) is freezeout scale of alpha_s: alpha_eff(0) = alpha_s(VINT(18))
13727  vint(18)=(parp(82)*(vint(1)/parp(89))**parp(90))**2
13728  ELSEIF (mstp(70).EQ.3) THEN
13729 C...MSTP(70) = 3 : Derive VINT(18) from alpha_eff(Lambda3) = PARP(73)
13730  alpha0 = max(1d-6,parp(73))
13731  q20 = alam3**2/parp(64)
13732  IF (mstp(64).EQ.3) q20 = q20 * 1.661**2
13733  vint(18) = q20 * (exp(12*paru(1)/27d0/alpha0)-1d0)
13734  ENDIF
13735 C...Also store PT2MIN in VINT(17).
13736  180 vint(17)=pt2min
13737 
13738 C...Set FS masses zero now.
13739  vint(63)=0d0
13740  vint(64)=0d0
13741 
13742 C...Initialize IS showers with VINT(56) as max scale.
13743  pt2isr=vint(56)
13744  pt20=pt2min
13745  IF (mstp(70).EQ.0) THEN
13746  pt20=max(pt2min,parp(62)**2)
13747  ELSEIF (mstp(70).EQ.1) THEN
13748  pt20=max(pt2min,(parp(81)*(vint(1)/parp(89))**parp(90))**2)
13749  ENDIF
13750  CALL pyptis(-1,pt2isr,pt20,pt2dum,ifail)
13751  IF(mint(51).NE.0) RETURN
13752 
13753  RETURN
13754 
13755 C----------------------------------------------------------------------
13756 C...MODE= 1: Evolve event from PTMAX to PTMIN.
13757  ELSEIF (mode.EQ.1) THEN
13758 
13759 C...Skip if no phase space.
13760  190 IF (pt2max.LE.pt2min) goto 330
13761 
13762 C...Starting pT2 max scale (to be udpated successively).
13763  pt2cmx=pt2max
13764 
13765 C...Evolve two sides of the event to find which branches at highest pT.
13766  200 jsmx=-1
13767  mimx=0
13768  pt2mx=0d0
13769 
13770 C...Loop over current shower initiators.
13771  IF (mstp(61).GE.1) THEN
13772  DO 230 mi=1,mint(31)
13773  IF (mi.GE.2.AND.mstp(84).LE.0) goto 230
13774  isub=96
13775  IF (mi.EQ.1) isub=isubhd
13776  mint(1)=isub
13777  mint(36)=mi
13778 C...Set up shat, initiator x values, and x remaining in BR.
13779  vint(44)=shat(mi)
13780  vint(141)=xmi(1,mi)
13781  vint(142)=xmi(2,mi)
13782  vint(143)=1d0
13783  vint(144)=1d0
13784  DO 210 ji=1,mint(31)
13785  IF (ji.EQ.mint(36)) goto 210
13786  vint(143)=vint(143)-xmi(1,ji)
13787  vint(144)=vint(144)-xmi(2,ji)
13788  210 CONTINUE
13789 C...Loop over sides.
13790 C...Generate trial branchings for this interaction. The hardest
13791 C...branching so far is automatically updated if necessary in /PYISMX/.
13792  DO 220 js=1,2
13793  mint(30)=js
13794  pt20=pt2min
13795  IF (mstp(70).EQ.0) THEN
13796  pt20=max(pt2min,parp(62)**2)
13797  ELSEIF (mstp(70).EQ.1) THEN
13798  pt20=max(pt2min,
13799  & (parp(81)*(vint(1)/parp(89))**parp(90))**2)
13800  ENDIF
13801  CALL pyptis(0,pt2cmx,pt20,pt2new,ifail)
13802  IF (mint(51).NE.0) RETURN
13803  220 CONTINUE
13804  230 CONTINUE
13805  ENDIF
13806 
13807 C...Generate trial additional interaction.
13808  mint(36)=mint(31)+1
13809  240 IF (mod(mstp(81),10).GE.1) THEN
13810  mint(1)=96
13811 C...Set up X remaining in BR.
13812  vint(143)=1d0
13813  vint(144)=1d0
13814  DO 250 ji=1,mint(31)
13815  vint(143)=vint(143)-xmi(1,ji)
13816  vint(144)=vint(144)-xmi(2,ji)
13817  250 CONTINUE
13818 C...Generate trial interaction
13819  260 CALL pyptmi(0,pt2cmx,pt2min,pt2new,ifail)
13820  IF (mint(51).EQ.1) RETURN
13821  ENDIF
13822 
13823 C...And the winner is:
13824  IF (pt2mx.LT.pt2min) THEN
13825  goto 330
13826  ELSEIF (jsmx.EQ.0) THEN
13827 C...Accept additional interaction (may still fail).
13828  CALL pyptmi(1,pt2new,pt2min,pt2dum,ifail)
13829  IF(mint(51).NE.0) RETURN
13830  IF (ifail.EQ.0) THEN
13831  shat(mint(36))=vint(44)
13832 C...Decide on flavours (valence/sea/companion).
13833  DO 270 js=1,2
13834  mint(30)=js
13835  CALL pyptmi(2,pt2new,pt2min,pt2dum,ifail)
13836  IF(mint(51).NE.0) RETURN
13837  270 CONTINUE
13838  ENDIF
13839  ELSEIF (jsmx.EQ.1.OR.jsmx.EQ.2) THEN
13840 C...Reconstruct kinematics of acceptable ISR branching.
13841 C...Set up shat, initiator x values, and x remaining in BR.
13842  mint(30)=jsmx
13843  mint(36)=mimx
13844  vint(44)=shat(mint(36))
13845  vint(141)=xmi(1,mint(36))
13846  vint(142)=xmi(2,mint(36))
13847  vint(143)=1d0
13848  vint(144)=1d0
13849  DO 280 ji=1,mint(31)
13850  IF (ji.EQ.mint(36)) goto 280
13851  vint(143)=vint(143)-xmi(1,ji)
13852  vint(144)=vint(144)-xmi(2,ji)
13853  280 CONTINUE
13854  pt2new=pt2mx
13855  CALL pyptis(1,pt2new,pt2dm1,pt2dm2,ifail)
13856  IF (mint(51).EQ.1) RETURN
13857  ELSEIF (jsmx.EQ.3.OR.jsmx.EQ.4) THEN
13858 C...Bookeep joining. Cannot (yet) be constructed kinematically.
13859  mint(354)=mint(354)+1
13860  vint(354)=vint(354)+sqrt(pt2mx)
13861  IF (mint(354).EQ.1) vint(359)=sqrt(pt2mx)
13862  mjoind(jsmx-2,mjn1mx)=mjn2mx
13863  mjoind(jsmx-2,mjn2mx)=mjn1mx
13864  ENDIF
13865 
13866 C...Update PT2 iteration scale.
13867  pt2cmx=pt2mx
13868 
13869 C...Loop back to continue evolution.
13870  IF(n.GT.mstu(4)-mstu(32)-10) THEN
13871  CALL pyerrm(11,'(PYEVOL:) no more memory left in PYJETS')
13872  ELSE
13873  IF (jsmx.GE.0.AND.pt2cmx.GE.pt2min) goto 200
13874  ENDIF
13875 
13876 C----------------------------------------------------------------------
13877 C...MODE= 2: (Re-)store user information on hardest interaction etc.
13878  ELSEIF (mode.EQ.2) THEN
13879 
13880 C...Revert to "ordinary" meanings of some parameters.
13881  290 DO 310 js=1,2
13882  mint(12+js)=k(imi(js,1,1),2)
13883  vint(140+js)=xmi(js,1)
13884  IF(mint(18+js).EQ.1) vint(140+js)=vint(154+js)*xmi(js,1)
13885  vint(142+js)=1d0
13886  DO 300 mi=1,mint(31)
13887  vint(142+js)=vint(142+js)-xmi(js,mi)
13888  300 CONTINUE
13889  310 CONTINUE
13890 
13891 C...Restore saved quantities for hardest interaction.
13892  mint(1)=isubhd
13893  mint(15)=m15sv
13894  mint(16)=m16sv
13895  mint(21)=m21sv
13896  mint(22)=m22sv
13897  DO 320 j=11,80
13898  vint(j)=vintsv(j)
13899  320 CONTINUE
13900 
13901  ENDIF
13902 
13903  330 RETURN
13904  END
13905 
13906 C*********************************************************************
13907 
13908 C...PYSSPA
13909 C...Generates spacelike parton showers.
13910 
13911  SUBROUTINE pysspa(IPU1,IPU2)
13912 
13913 C...Double precision and integer declarations.
13914  IMPLICIT DOUBLE PRECISION(a-h, o-z)
13915  IMPLICIT INTEGER(i-n)
13916  INTEGER pyk,pychge,pycomp
13917  parameter(maxnur=1000)
13918 C...Commonblocks.
13919  common/pypart/npart,npartd,ipart(maxnur),ptpart(maxnur)
13920  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
13921  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
13922  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
13923  common/pysubs/msel,mselpd,msub(500),kfin(2,-40:40),ckin(200)
13924  common/pypars/mstp(200),parp(200),msti(200),pari(200)
13925  common/pyint1/mint(400),vint(400)
13926  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
13927  common/pyint3/xsfx(2,-40:40),isig(1000,3),sigh(1000)
13928  common/pyctag/nct,mct(4000,2)
13929  SAVE /pypart/,/pyjets/,/pydat1/,/pydat2/,/pysubs/,/pypars/,
13930  &/pyint1/,/pyint2/,/pyint3/,/pyctag/
13931 C...Local arrays and data.
13932  dimension kfls(4),is(2),xs(2),zs(2),q2s(2),tevcsv(2),tevesv(2),
13933  &xfs(2,-25:25),xfa(-25:25),xfb(-25:25),xfn(-25:25),wtapc(-25:25),
13934  &wtape(-25:25),wtsf(-25:25),the2(2),alam(2),dq2(3),dpc(3),dpd(4),
13935  &dpb(4),robo(5),more(2),kfbeam(2),q2mncs(2),kcfi(2),nfis(2),
13936  &thefis(2,2),isfi(2),dphi(2),mcesv(2)
13937  DATA is/2*0/
13938 
13939 C...Read out basic information; set global Q^2 scale.
13940  ipus1=ipu1
13941  ipus2=ipu2
13942  isub=mint(1)
13943  q2mx=vint(56)
13944  vint2r=vint(2)*vint(143)*vint(144)
13945  IF(iset(isub).EQ.2.OR.iset(isub).EQ.9.OR.iset(isub).EQ.11) q2mx=
13946  &min(vint2r,parp(67)*vint(56))
13947  fcq2mx=1d0
13948 
13949 C...Define which processes ME corrections have been implemented for.
13950  mecor=0
13951  IF(mstp(68).EQ.1.OR.mstp(68).EQ.3) THEN
13952  IF(isub.EQ.1.OR.isub.EQ.2.OR.isub.EQ.141.OR.isub.EQ.142.OR.
13953  & isub.EQ.144) mecor=1
13954  IF(isub.EQ.102.OR.isub.EQ.152.OR.isub.EQ.157) mecor=2
13955  IF(isub.EQ.3.OR.isub.EQ.151.OR.isub.EQ.156) mecor=3
13956  ENDIF
13957 
13958 C...Initialize QCD evolution and check phase space.
13959  q2mnc=parp(62)**2
13960  q2mncs(1)=q2mnc
13961  q2mncs(2)=q2mnc
13962  IF(mint(107).EQ.2.AND.mstp(66).EQ.2) THEN
13963  q0s=parp(15)**2
13964  ps=vint(3)**2
13965  q2eff=vint(54)*((q0s+ps)/(vint(54)+ps))*
13966  & exp(ps*(vint(54)-q0s)/((vint(54)+ps)*(q0s+ps)))
13967  q2int=sqrt(q0s*q2eff)
13968  q2mncs(1)=max(q2mnc,q2int)
13969  ELSEIF(mint(107).EQ.3.AND.mstp(66).GE.1) THEN
13970  q2mncs(1)=max(q2mnc,vint(283))
13971  ENDIF
13972  IF(mint(108).EQ.2.AND.mstp(66).EQ.2) THEN
13973  q0s=parp(15)**2
13974  ps=vint(4)**2
13975  q2eff=vint(54)*((q0s+ps)/(vint(54)+ps))*
13976  & exp(ps*(vint(54)-q0s)/((vint(54)+ps)*(q0s+ps)))
13977  q2int=sqrt(q0s*q2eff)
13978  q2mncs(2)=max(q2mnc,q2int)
13979  ELSEIF(mint(108).EQ.3.AND.mstp(66).GE.1) THEN
13980  q2mncs(2)=max(q2mnc,vint(284))
13981  ENDIF
13982  mcev=0
13983  alams=paru(112)
13984  paru(112)=parp(61)
13985  fq2c=1d0
13986  tcmx=0d0
13987  IF(mint(47).GE.2.AND.(mint(47).LT.5.OR.mstp(12).GE.1)) THEN
13988  mcev=1
13989  IF(mstp(64).EQ.1) fq2c=parp(63)
13990  IF(mstp(64).EQ.2) fq2c=parp(64)
13991  tcmx=log(fq2c*q2mx/parp(61)**2)
13992  IF(q2mx.LT.max(q2mnc,2d0*parp(61)**2).OR.tcmx.LT.0.2d0)
13993  & mcev=0
13994  ENDIF
13995 
13996 C...Initialize QED evolution and check phase space.
13997  meev=0
13998  xee=1d-10
13999  spme=pmas(11,1)**2
14000  IF(iabs(mint(11)).EQ.13.OR.iabs(mint(12)).EQ.13)
14001  &spme=pmas(13,1)**2
14002  IF(iabs(mint(11)).EQ.15.OR.iabs(mint(12)).EQ.15)
14003  &spme=pmas(15,1)**2
14004  q2mne=max(parp(68)**2,2d0*spme)
14005  temx=0d0
14006  fwte=10d0
14007  IF(mint(45).EQ.3.OR.mint(46).EQ.3) THEN
14008  meev=1
14009  temx=log(q2mx/spme)
14010  IF(q2mx.LE.q2mne.OR.temx.LT.0.2d0) meev=0
14011  ENDIF
14012  IF(mstp(61).GE.2.AND.mcev.EQ.1.AND.meev.EQ.0) THEN
14013  meev=2
14014  temx=tcmx
14015  fwte=1d0
14016  ENDIF
14017  IF(mcev.EQ.0.AND.meev.EQ.0) RETURN
14018 
14019 C...Loopback point in case of failure to reconstruct kinematics.
14020  ns=n
14021  nparts=npart
14022  loop=0
14023  mnt352=mint(352)
14024  mnt353=mint(353)
14025  vnt352=vint(352)
14026  vnt353=vint(353)
14027  100 loop=loop+1
14028  IF(loop.GT.100) THEN
14029  mint(51)=1
14030  RETURN
14031  ENDIF
14032  n=ns
14033  npart=nparts
14034  mint(352)=mnt352
14035  mint(353)=mnt353
14036  vint(352)=vnt352
14037  vint(353)=vnt353
14038 
14039 C...Initial values: flavours, momenta, virtualities.
14040  DO 120 jt=1,2
14041  more(jt)=1
14042  kfbeam(jt)=mint(10+jt)
14043  IF(mint(18+jt).EQ.1)kfbeam(jt)=22
14044  kfls(jt)=mint(14+jt)
14045  kfls(jt+2)=kfls(jt)
14046  xs(jt)=vint(40+jt)
14047  IF(mint(18+jt).EQ.1) xs(jt)=vint(40+jt)/vint(154+jt)
14048  IF(mint(31).GE.2) xs(jt)=xs(jt)/vint(142+jt)
14049  zs(jt)=1d0
14050  q2s(jt)=fcq2mx*q2mx
14051  dq2(jt)=0d0
14052  tevcsv(jt)=tcmx
14053  alam(jt)=parp(61)
14054  the2(jt)=1d0
14055  tevesv(jt)=temx
14056  mcesv(jt)=0
14057 C...Calculate initial parton distribution weights.
14058  mint(105)=mint(102+jt)
14059  mint(109)=mint(106+jt)
14060  vint(120)=vint(2+jt)
14061  IF(xs(jt).LT.1d0-xee) THEN
14062  IF(mint(31).GE.2) mint(30)=jt
14063  IF(mstp(57).LE.1) THEN
14064  CALL pypdfu(kfbeam(jt),xs(jt),q2s(jt),xfb)
14065  ELSE
14066  CALL pypdfl(kfbeam(jt),xs(jt),q2s(jt),xfb)
14067  ENDIF
14068  ENDIF
14069  DO 110 kfl=-25,25
14070  xfs(jt,kfl)=xfb(kfl)
14071  110 CONTINUE
14072 C...Special kinematics check for c/b quarks (that g -> c cbar or
14073 C...b bbar kinematically possible).
14074  kflcb=iabs(kfls(jt))
14075  IF(kfbeam(jt).NE.22.AND.(kflcb.EQ.4.OR.kflcb.EQ.5)) THEN
14076  IF(xs(jt).GT.0.9d0*q2s(jt)/(pmas(kflcb,1)**2+q2s(jt))) THEN
14077  mint(51)=1
14078  RETURN
14079  ENDIF
14080  ENDIF
14081  120 CONTINUE
14082  dsh=vint(44)
14083  IF(iset(isub).GE.3.AND.iset(isub).LE.5) dsh=vint(26)*vint(2)
14084 
14085 C...Find if interference with final state partons.
14086  mfis=0
14087  IF(mstp(67).GE.1.AND.mstp(67).LE.3) mfis=mstp(67)
14088  IF(mfis.NE.0) THEN
14089  DO 140 i=1,2
14090  kcfi(i)=0
14091  kca=pycomp(iabs(kfls(i)))
14092  IF(kca.NE.0) kcfi(i)=kchg(kca,2)*isign(1,kfls(i))
14093  nfis(i)=0
14094  IF(kcfi(i).NE.0) THEN
14095  IF(i.EQ.1) ipfs=ipus1
14096  IF(i.EQ.2) ipfs=ipus2
14097  DO 130 j=1,2
14098  icsi=mod(k(ipfs,3+j),mstu(5))
14099  IF(icsi.GT.0.AND.icsi.NE.ipus1.AND.icsi.NE.ipus2.AND.
14100  & (kcfi(i).EQ.(-1)**(j+1).OR.kcfi(i).EQ.2)) THEN
14101  nfis(i)=nfis(i)+1
14102  thefis(i,nfis(i))=pyangl(p(icsi,3),sqrt(p(icsi,1)**2+
14103  & p(icsi,2)**2))
14104  IF(i.EQ.2) thefis(i,nfis(i))=paru(1)-thefis(i,nfis(i))
14105  ENDIF
14106  130 CONTINUE
14107  ENDIF
14108  140 CONTINUE
14109  IF(nfis(1)+nfis(2).EQ.0) mfis=0
14110  ENDIF
14111 
14112 C...Pick up leg with highest virtuality.
14113  jtold=1
14114  150 n=n+1
14115  jt=1
14116  IF(n.GT.ns+1.AND.q2s(2).GT.q2s(1)) jt=2
14117  IF(n.EQ.ns+2.AND.jt.EQ.jtold) jt=3-jt
14118  IF(more(jt).EQ.0) jt=3-jt
14119  jtold=jt
14120  kflb=kfls(jt)
14121  xb=xs(jt)
14122  DO 160 kfl=-25,25
14123  xfb(kfl)=xfs(jt,kfl)
14124  160 CONTINUE
14125  dshr=2d0*sqrt(dsh)
14126  dshz=dsh/zs(jt)
14127 
14128 C...Check if allowed to branch.
14129  mcev=0
14130  IF(iabs(kflb).LE.10.OR.kflb.EQ.21) THEN
14131  mcev=1
14132  xec=max(parp(65)*dshr/vint2r,xb*(1d0/(1d0-parp(66))-1d0))
14133  IF(xb.GE.1d0-2d0*xec) mcev=0
14134  ENDIF
14135  meev=0
14136  IF(mint(44+jt).EQ.3) THEN
14137  meev=1
14138  IF(xb.GE.1d0-2d0*xee) meev=0
14139  IF((iabs(kflb).LE.10.OR.kflb.EQ.21).AND.xb.GE.1d0-2d0*xec)
14140  & meev=0
14141 C***Currently kill QED shower for resolved photoproduction.
14142  IF(mint(18+jt).EQ.1) meev=0
14143 C***Currently kill shower for W inside electron.
14144  IF(iabs(kflb).EQ.24) THEN
14145  mcev=0
14146  meev=0
14147  ENDIF
14148  ENDIF
14149  IF(mstp(61).GE.2.AND.mcev.EQ.1.AND.meev.EQ.0.AND.iabs(kflb).LE.10)
14150  &meev=2
14151  IF(mcev.EQ.0.AND.meev.EQ.0) THEN
14152  q2b=0d0
14153  goto 260
14154  ENDIF
14155 
14156 C...Maximum Q2 with or without Q2 ordering. Effective Lambda and n_f.
14157  q2b=q2s(jt)
14158  tevcb=tevcsv(jt)
14159  teveb=tevesv(jt)
14160  IF(mstp(62).LE.1) THEN
14161  IF(zs(jt).GT.0.99999d0) THEN
14162  q2b=q2s(jt)
14163  ELSE
14164  q2b=0.5d0*(1d0/zs(jt)+1d0)*q2s(jt)+0.5d0*(1d0/zs(jt)-1d0)*
14165  & (q2s(3-jt)-dsh+sqrt((dsh+q2s(1)+q2s(2))**2+
14166  & 8d0*q2s(1)*q2s(2)*zs(jt)/(1d0-zs(jt))))
14167  ENDIF
14168  IF(mcev.EQ.1) tevcb=log(fq2c*q2b/alam(jt)**2)
14169  IF(meev.EQ.1) teveb=log(q2b/spme)
14170  ENDIF
14171  IF(mcev.EQ.1) THEN
14172  alsdum=pyalps(fq2c*q2b)
14173  tevcb=tevcb+2d0*log(alam(jt)/paru(117))
14174  alam(jt)=paru(117)
14175  b0=(33d0-2d0*mstu(118))/6d0
14176  ENDIF
14177  IF(meev.EQ.2) teveb=tevcb
14178  tevcbs=tevcb
14179  tevebs=teveb
14180 
14181 C...Select side for interference with final state partons.
14182  IF(mfis.GE.1.AND.n.LE.ns+2) THEN
14183  ifi=n-ns
14184  isfi(ifi)=0
14185  IF(iabs(kcfi(ifi)).EQ.1.AND.nfis(ifi).EQ.1) THEN
14186  isfi(ifi)=1
14187  ELSEIF(kcfi(ifi).EQ.2.AND.nfis(ifi).EQ.1) THEN
14188  IF(pyr(0).GT.0.5d0) isfi(ifi)=1
14189  ELSEIF(kcfi(ifi).EQ.2.AND.nfis(ifi).EQ.2) THEN
14190  isfi(ifi)=1
14191  IF(pyr(0).GT.0.5d0) isfi(ifi)=2
14192  ENDIF
14193  ENDIF
14194 
14195 C...Calculate preweighting factor for ME-corrected processes.
14196  IF(mecor.GE.1) CALL pymemx(mecor,wtff,wtgf,wtfg,wtgg)
14197 
14198 C...Calculate Altarelli-Parisi weights.
14199  DO 170 kfl=-25,25
14200  wtapc(kfl)=0d0
14201  wtape(kfl)=0d0
14202  wtsf(kfl)=0d0
14203  170 CONTINUE
14204 C...q -> q (g or gamma emission), g -> q.
14205  IF(iabs(kflb).LE.10) THEN
14206  wtapc(kflb)=(8d0/3d0)*log((1d0-xec-xb)*(xb+xec)/(xec*(1d0-xec)))
14207  wtapc(21)=0.5d0*(xb/(xb+xec)-xb/(1d0-xec))
14208  eq2=1d0/9d0
14209  IF(mod(iabs(kflb),2).EQ.0) eq2=4d0*eq2
14210  IF(meev.EQ.2) wtape(kflb)=2.*eq2*log((1d0-xec-xb)*(xb+xec)/
14211  & (xec*(1d0-xec)))
14212  IF(mecor.GE.1.AND.(n.EQ.ns+1.OR.n.EQ.ns+2)) THEN
14213  wtapc(kflb)=wtff*wtapc(kflb)
14214  wtapc(21)=wtgf*wtapc(21)
14215  wtape(kflb)=wtff*wtape(kflb)
14216  ENDIF
14217 C...f -> f, gamma -> f.
14218  ELSEIF(iabs(kflb).LE.20) THEN
14219  wtapf1=log((1d0-xee-xb)*(xb+xee)/(xee*(1d0-xee)))
14220  wtapf2=log((1d0-xee-xb)*(1d0-xee)/(xee*(xb+xee)))
14221  wtape(kflb)=2d0*(wtapf1+wtapf2)
14222  IF(mstp(12).GE.1) wtape(22)=xb/(xb+xee)-xb/(1d0-xee)
14223  IF(mecor.GE.1.AND.(n.EQ.ns+1.OR.n.EQ.ns+2)) THEN
14224  wtape(kflb)=wtff*wtape(kflb)
14225  wtape(22)=wtgf*wtape(22)
14226  ENDIF
14227 C...f -> g, g -> g.
14228  ELSEIF(kflb.EQ.21) THEN
14229  wtapq=(16d0/3d0)*(sqrt((1d0-xec)/xb)-sqrt((xb+xec)/xb))
14230  DO 180 kfl=1,mstp(58)
14231  wtapc(kfl)=wtapq
14232  wtapc(-kfl)=wtapq
14233  180 CONTINUE
14234  wtapc(21)=6d0*log((1d0-xec-xb)/xec)
14235  IF(mecor.GE.1.AND.(n.EQ.ns+1.OR.n.EQ.ns+2)) THEN
14236  DO 190 kfl=1,mstp(58)
14237  wtapc(kfl)=wtfg*wtapc(kfl)
14238  wtapc(-kfl)=wtfg*wtapc(-kfl)
14239  190 CONTINUE
14240  wtapc(21)=wtgg*wtapc(21)
14241  ENDIF
14242 C...f -> gamma, W+, W-.
14243  ELSEIF(kflb.EQ.22) THEN
14244  wtapf=log((1d0-xee-xb)*(1d0-xee)/(xee*(xb+xee)))/xb
14245  wtape(11)=wtapf
14246  wtape(-11)=wtapf
14247  IF(mecor.GE.1.AND.(n.EQ.ns+1.OR.n.EQ.ns+2)) THEN
14248  wtape(11)=wtfg*wtape(11)
14249  wtape(-11)=wtfg*wtape(-11)
14250  ENDIF
14251  ELSEIF(kflb.EQ.24) THEN
14252  wtape(-11)=1d0/(4d0*paru(102))*log((1d0-xee-xb)*(1d0-xee)/
14253  & (xee*(xb+xee)))/xb
14254  ELSEIF(kflb.EQ.-24) THEN
14255  wtape(11)=1d0/(4d0*paru(102))*log((1d0-xee-xb)*(1d0-xee)/
14256  & (xee*(xb+xee)))/xb
14257  ENDIF
14258 
14259 C...Calculate parton distribution weights and sum.
14260  ntry=0
14261  200 ntry=ntry+1
14262  IF(ntry.GT.500) THEN
14263  mint(51)=1
14264  RETURN
14265  ENDIF
14266  wtsumc=0d0
14267  wtsume=0d0
14268  xfbo=max(1d-10,xfb(kflb))
14269  DO 210 kfl=-25,25
14270  wtsf(kfl)=xfb(kfl)/xfbo
14271  wtsumc=wtsumc+wtapc(kfl)*wtsf(kfl)
14272  wtsume=wtsume+wtape(kfl)*wtsf(kfl)
14273  210 CONTINUE
14274  wtsumc=max(0.0001d0,wtsumc)
14275  wtsume=max(0.0001d0/fwte,wtsume)
14276 
14277 C...Choose new t: fix alpha_s, alpha_s(Q^2), alpha_s(k_T^2).
14278  ntry2=0
14279  220 ntry2=ntry2+1
14280  IF(ntry2.GT.500) THEN
14281  mint(51)=1
14282  RETURN
14283  ENDIF
14284  IF(mcev.EQ.1) THEN
14285  IF(mstp(64).LE.0) THEN
14286  tevcb=tevcb+log(pyr(0))*paru(2)/(paru(111)*wtsumc)
14287  ELSEIF(mstp(64).EQ.1) THEN
14288  tevcb=tevcb*exp(max(-50d0,log(pyr(0))*b0/wtsumc))
14289  ELSE
14290  tevcb=tevcb*exp(max(-50d0,log(pyr(0))*b0/(5d0*wtsumc)))
14291  ENDIF
14292  ENDIF
14293  IF(meev.EQ.1) THEN
14294  teveb=teveb*exp(max(-50d0,log(pyr(0))*paru(2)/
14295  & (paru(101)*fwte*wtsume*temx)))
14296  ELSEIF(meev.EQ.2) THEN
14297  teveb=teveb+log(pyr(0))*paru(2)/(paru(101)*wtsume)
14298  ENDIF
14299 
14300 C...Translate t into Q2 scale; choose between QCD and QED evolution.
14301  230 IF(mcev.EQ.1) q2cb=alam(jt)**2*exp(max(-50d0,tevcb))/fq2c
14302  IF(meev.EQ.1) q2eb=spme*exp(max(-50d0,teveb))
14303  IF(meev.EQ.2) q2eb=alam(jt)**2*exp(max(-50d0,teveb))/fq2c
14304 C...Ensure that Q2 is above threshold for charm/bottom.
14305  kflcb=iabs(kflb)
14306  IF(kfbeam(jt).NE.22.AND.(kflcb.EQ.4.OR.kflcb.EQ.5).AND.
14307  &mcev.EQ.1) THEN
14308  IF(q2cb.LT.pmas(kflcb,1)**2) THEN
14309  q2cb=1.1d0*pmas(kflcb,1)**2
14310  tevcb=log(fq2c*q2b/alam(jt)**2)
14311  fcq2mx=min(2d0,1.05d0*fcq2mx)
14312  ENDIF
14313  ENDIF
14314  IF(kfbeam(jt).NE.22.AND.(kflcb.EQ.4.OR.kflcb.EQ.5).AND.
14315  &meev.EQ.2) THEN
14316  IF(q2eb.LT.pmas(kflcb,1)**2) meev=0
14317  ENDIF
14318  mce=0
14319  IF(mcev.EQ.0.AND.meev.EQ.0) THEN
14320  ELSEIF(mcev.EQ.1.AND.meev.EQ.0) THEN
14321  IF(q2cb.GT.q2mncs(jt)) mce=1
14322  ELSEIF(mcev.EQ.0.AND.meev.EQ.1) THEN
14323  IF(q2eb.GT.q2mne) mce=2
14324  ELSEIF(mcev.EQ.0.AND.meev.EQ.2) THEN
14325  IF(q2eb.GT.q2mncs(jt)) mce=2
14326  ELSEIF(mcev.EQ.1.AND.meev.EQ.2) THEN
14327  IF(q2cb.GT.q2eb.AND.q2cb.GT.q2mncs(jt)) mce=1
14328  IF(q2eb.GT.q2cb.AND.q2eb.GT.q2mncs(jt)) mce=2
14329  ELSEIF(q2mncs(jt).GT.q2mne) THEN
14330  mce=1
14331  IF(q2eb.GT.q2cb.OR.q2cb.LE.q2mncs(jt)) mce=2
14332  IF(mce.EQ.2.AND.q2eb.LE.q2mne) mce=0
14333  ELSE
14334  mce=2
14335  IF(q2cb.GT.q2eb.OR.q2eb.LE.q2mne) mce=1
14336  IF(mce.EQ.1.AND.q2cb.LE.q2mncs(jt)) mce=0
14337  ENDIF
14338 
14339 C...Evolution possibly ended. Update t values.
14340  IF(mce.EQ.0) THEN
14341  q2b=0d0
14342  goto 260
14343  ELSEIF(mce.EQ.1) THEN
14344  q2b=q2cb
14345  q2ref=fq2c*q2b
14346  IF(meev.EQ.1) teveb=log(q2b/spme)
14347  IF(meev.EQ.2) teveb=log(fq2c*q2b/alam(jt)**2)
14348  ELSE
14349  q2b=q2eb
14350  q2ref=q2b
14351  IF(mcev.EQ.1) tevcb=log(fq2c*q2b/alam(jt)**2)
14352  ENDIF
14353 
14354 C...Select flavour for branching parton.
14355  IF(mce.EQ.1) wtran=pyr(0)*wtsumc
14356  IF(mce.EQ.2) wtran=pyr(0)*wtsume
14357  kfla=-25
14358  240 kfla=kfla+1
14359  IF(mce.EQ.1) wtran=wtran-wtapc(kfla)*wtsf(kfla)
14360  IF(mce.EQ.2) wtran=wtran-wtape(kfla)*wtsf(kfla)
14361  IF(kfla.LE.24.AND.wtran.GT.0d0) goto 240
14362  IF(kfla.EQ.25) THEN
14363  q2b=0d0
14364  goto 260
14365  ENDIF
14366 
14367 C...Choose z value and corrective weight.
14368  wtz=0d0
14369 C...q -> q + g or q -> q + gamma.
14370  IF(iabs(kfla).LE.10.AND.iabs(kflb).LE.10) THEN
14371  z=1d0-((1d0-xb-xec)/(1d0-xec))*
14372  & (xec*(1d0-xec)/((xb+xec)*(1d0-xb-xec)))**pyr(0)
14373  wtz=0.5d0*(1d0+z**2)
14374 C...q -> g + q.
14375  ELSEIF(iabs(kfla).LE.10.AND.kflb.EQ.21) THEN
14376  z=xb/(sqrt(xb+xec)+pyr(0)*(sqrt(1d0-xec)-sqrt(xb+xec)))**2
14377  wtz=0.5d0*(1d0+(1d0-z)**2)*sqrt(z)
14378 C...f -> f + gamma.
14379  ELSEIF(iabs(kfla).LE.20.AND.iabs(kflb).LE.20) THEN
14380  IF(wtapf1.GT.pyr(0)*(wtapf1+wtapf2)) THEN
14381  z=1d0-((1d0-xb-xee)/(1d0-xee))*
14382  & (xee*(1d0-xee)/((xb+xee)*(1d0-xb-xee)))**pyr(0)
14383  ELSE
14384  z=xb+xb*(xee/(1d0-xee))*
14385  & ((1d0-xb-xee)*(1d0-xee)/(xee*(xb+xee)))**pyr(0)
14386  ENDIF
14387  wtz=0.5d0*(1d0+z**2)*(z-xb)/(1d0-xb)
14388 C...f -> gamma + f.
14389  ELSEIF(iabs(kfla).LE.20.AND.kflb.EQ.22) THEN
14390  z=xb+xb*(xee/(1d0-xee))*
14391  & ((1d0-xb-xee)*(1d0-xee)/(xee*(xb+xee)))**pyr(0)
14392  wtz=0.5d0*(1d0+(1d0-z)**2)*xb*(z-xb)/z
14393 C...f -> W+- + f.
14394  ELSEIF(iabs(kfla).LE.20.AND.iabs(kflb).EQ.24) THEN
14395  z=xb+xb*(xee/(1d0-xee))*
14396  & ((1d0-xb-xee)*(1d0-xee)/(xee*(xb+xee)))**pyr(0)
14397  wtz=0.5d0*(1d0+(1d0-z)**2)*(xb*(z-xb)/z)*
14398  & (q2b/(q2b+pmas(24,1)**2))
14399 C...g -> q + qbar.
14400  ELSEIF(kfla.EQ.21.AND.iabs(kflb).LE.10) THEN
14401  z=xb/(1d0-xec)+pyr(0)*(xb/(xb+xec)-xb/(1d0-xec))
14402  wtz=1d0-2d0*z*(1d0-z)
14403 C...g -> g + g.
14404  ELSEIF(kfla.EQ.21.AND.kflb.EQ.21) THEN
14405  z=1d0/(1d0+((1d0-xec-xb)/xb)*(xec/(1d0-xec-xb))**pyr(0))
14406  wtz=(1d0-z*(1d0-z))**2
14407 C...gamma -> f + fbar.
14408  ELSEIF(kfla.EQ.22.AND.iabs(kflb).LE.20) THEN
14409  z=xb/(1d0-xee)+pyr(0)*(xb/(xb+xee)-xb/(1d0-xee))
14410  wtz=1d0-2d0*z*(1d0-z)
14411  ENDIF
14412  IF(mce.EQ.2.AND.meev.EQ.1) wtz=(wtz/fwte)*(teveb/temx)
14413 
14414 C...Option with resummation of soft gluon emission as effective z shift.
14415  IF(mce.EQ.1) THEN
14416  IF(mstp(65).GE.1) THEN
14417  rsoft=6d0
14418  IF(kflb.NE.21) rsoft=8d0/3d0
14419  z=z*(tevcb/tevcsv(jt))**(rsoft*xec/((xb+xec)*b0))
14420  IF(z.LE.xb) goto 220
14421  ENDIF
14422 
14423 C...Option with alpha_s(k_T^2): demand k_T^2 > cutoff, reweight.
14424  IF(mstp(64).GE.2) THEN
14425  IF((1d0-z)*q2b.LT.q2mncs(jt)) goto 220
14426  alprat=tevcb/(tevcb+log(1d0-z))
14427  IF(alprat.LT.5d0*pyr(0)) goto 220
14428  IF(alprat.GT.5d0) wtz=wtz*alprat/5d0
14429  ENDIF
14430  ENDIF
14431 
14432 C...Remove kinematically impossible branchings.
14433  uhat=q2b-dsh*(1d0-z)/z
14434  IF(mstp(68).GE.0.AND.uhat.GT.0d0) goto 220
14435 
14436 C...Select phi angle of branching at random.
14437  phibr=paru(2)*pyr(0)
14438 
14439 C...Matrix-element corrections for some processes.
14440  IF(mecor.GE.1.AND.(n.EQ.ns+1.OR.n.EQ.ns+2)) THEN
14441  IF(iabs(kfla).LE.20.AND.iabs(kflb).LE.20) THEN
14442  CALL pymewt(mecor,1,q2b,z,phibr,wtme)
14443  wtz=wtz*wtme/wtff
14444  ELSEIF((kfla.EQ.21.OR.kfla.EQ.22).AND.iabs(kflb).LE.20) THEN
14445  CALL pymewt(mecor,2,q2b,z,phibr,wtme)
14446  wtz=wtz*wtme/wtgf
14447  ELSEIF(iabs(kfla).LE.20.AND.(kflb.EQ.21.OR.kflb.EQ.22)) THEN
14448  CALL pymewt(mecor,3,q2b,z,phibr,wtme)
14449  wtz=wtz*wtme/wtfg
14450  ELSEIF(kfla.EQ.21.AND.kflb.EQ.21) THEN
14451  CALL pymewt(mecor,4,q2b,z,phibr,wtme)
14452  wtz=wtz*wtme/wtgg
14453  ENDIF
14454  ENDIF
14455 
14456 C...Impose angular constraint in first branching from interference
14457 C...with final state partons.
14458  IF(mce.EQ.1) THEN
14459  IF(mfis.GE.1.AND.n.LE.ns+2.AND.ntry2.LT.200) THEN
14460  the2d=(4d0*q2b)/(dsh*(1d0-z))
14461  IF(n.EQ.ns+1.AND.isfi(1).GE.1) THEN
14462  IF(the2d.GT.thefis(1,isfi(1))**2) goto 220
14463  ELSEIF(n.EQ.ns+2.AND.isfi(2).GE.1) THEN
14464  IF(the2d.GT.thefis(2,isfi(2))**2) goto 220
14465  ENDIF
14466  ENDIF
14467 
14468 C...Option with angular ordering requirement.
14469  IF(mstp(62).GE.3.AND.ntry2.LT.200) THEN
14470  the2t=(4d0*z**2*q2b)/(4d0*z**2*q2b+(1d0-z)*xb**2*vint2r)
14471  IF(the2t.GT.the2(jt)) goto 220
14472  ENDIF
14473  ENDIF
14474 
14475 C...Weighting with new parton distributions.
14476  mint(105)=mint(102+jt)
14477  mint(109)=mint(106+jt)
14478  vint(120)=vint(2+jt)
14479  IF(mint(31).GE.2) mint(30)=jt
14480  IF(mstp(57).LE.1) THEN
14481  CALL pypdfu(kfbeam(jt),xb,q2ref,xfn)
14482  ELSE
14483  CALL pypdfl(kfbeam(jt),xb,q2ref,xfn)
14484  ENDIF
14485  xfbn=xfn(kflb)
14486  IF(xfbn.LT.1d-20) THEN
14487  IF(kfla.EQ.kflb) THEN
14488  tevcb=tevcbs
14489  teveb=tevebs
14490  wtapc(kflb)=0d0
14491  wtape(kflb)=0d0
14492  goto 200
14493  ELSEIF(mce.EQ.1.AND.tevcbs-tevcb.GT.0.2d0) THEN
14494  tevcb=0.5d0*(tevcbs+tevcb)
14495  goto 230
14496  ELSEIF(mce.EQ.2.AND.tevebs-teveb.GT.0.2d0) THEN
14497  teveb=0.5d0*(tevebs+teveb)
14498  goto 230
14499  ELSE
14500  xfbn=1d-10
14501  xfn(kflb)=xfbn
14502  ENDIF
14503  ENDIF
14504  DO 250 kfl=-25,25
14505  xfb(kfl)=xfn(kfl)
14506  250 CONTINUE
14507  xa=xb/z
14508  IF(mint(31).GE.2) mint(30)=jt
14509  IF(mstp(57).LE.1) THEN
14510  CALL pypdfu(kfbeam(jt),xa,q2ref,xfa)
14511  ELSE
14512  CALL pypdfl(kfbeam(jt),xa,q2ref,xfa)
14513  ENDIF
14514  xfan=xfa(kfla)
14515  IF(xfan.LT.1d-20) goto 200
14516  wtsfa=wtsf(kfla)
14517  IF(wtz*xfan/xfbn.LT.pyr(0)*wtsfa) goto 200
14518 
14519 C...Define two hard scatterers in their CM-frame.
14520  260 IF(n.EQ.ns+2) THEN
14521  dq2(jt)=q2b
14522  dplcm=sqrt((dsh+dq2(1)+dq2(2))**2-4d0*dq2(1)*dq2(2))/dshr
14523  DO 280 jr=1,2
14524  i=ns+jr
14525  IF(jr.EQ.1) ipo=ipus1
14526  IF(jr.EQ.2) ipo=ipus2
14527  DO 270 j=1,5
14528  k(i,j)=0
14529  p(i,j)=0d0
14530  v(i,j)=0d0
14531  270 CONTINUE
14532  k(i,1)=14
14533  k(i,2)=kfls(jr+2)
14534  k(i,4)=ipo
14535  k(i,5)=ipo
14536  p(i,3)=dplcm*(-1)**(jr+1)
14537  p(i,4)=(dsh+dq2(3-jr)-dq2(jr))/dshr
14538  p(i,5)=-sqrt(dq2(jr))
14539  k(ipo,1)=14
14540  k(ipo,3)=i
14541  k(ipo,4)=mod(k(ipo,4),mstu(5))+mstu(5)*i
14542  k(ipo,5)=mod(k(ipo,5),mstu(5))+mstu(5)*i
14543  mct(i,1)=mct(ipo,1)
14544  mct(i,2)=mct(ipo,2)
14545  280 CONTINUE
14546 
14547 C...Find maximum allowed mass of timelike parton.
14548  ELSEIF(n.GT.ns+2) THEN
14549  jr=3-jt
14550  dq2(3)=q2b
14551  dpc(1)=p(is(1),4)
14552  dpc(2)=p(is(2),4)
14553  dpc(3)=0.5d0*(abs(p(is(1),3))+abs(p(is(2),3)))
14554  dpd(1)=dsh+dq2(jr)+dq2(jt)
14555  dpd(2)=dshz+dq2(jr)+dq2(3)
14556  dpd(3)=sqrt(dpd(1)**2-4d0*dq2(jr)*dq2(jt))
14557  dpd(4)=sqrt(dpd(2)**2-4d0*dq2(jr)*dq2(3))
14558  ikin=0
14559  IF(q2s(jr).GE.0.25d0*q2mnc.AND.dpd(1)-dpd(3).GE.
14560  & 1d-10*dpd(1)) ikin=1
14561  IF(ikin.EQ.0) dmsma=(dq2(jt)/zs(jt)-dq2(3))*
14562  & (dsh/(dsh+dq2(jt))-dsh/(dshz+dq2(3)))
14563  IF(ikin.EQ.1) dmsma=(dpd(1)*dpd(2)-dpd(3)*dpd(4))/
14564  & (2d0*dq2(jr))-dq2(jt)-dq2(3)
14565 
14566 C...Generate timelike parton shower (if required).
14567  it=n
14568  DO 290 j=1,5
14569  k(it,j)=0
14570  p(it,j)=0d0
14571  v(it,j)=0d0
14572  290 CONTINUE
14573 C...f -> f + g (gamma).
14574  IF(iabs(kflb).LE.20.AND.iabs(kfls(jt+2)).LE.20) THEN
14575  k(it,2)=21
14576  IF(mcesv(jt).EQ.2.OR.iabs(kflb).GE.11) k(it,2)=22
14577 C...f -> g (gamma, W+-) + f.
14578  ELSEIF(iabs(kflb).LE.20.AND.iabs(kfls(jt+2)).GT.20) THEN
14579  k(it,2)=kflb
14580  IF(kfls(jt+2).EQ.24) THEN
14581  k(it,2)=-12
14582  ELSEIF(kfls(jt+2).EQ.-24) THEN
14583  k(it,2)=12
14584  ENDIF
14585 C...g (gamma) -> f + fbar, g + g.
14586  ELSE
14587  k(it,2)=-kfls(jt+2)
14588  IF(kfls(jt+2).GT.20) k(it,2)=kfls(jt+2)
14589  ENDIF
14590  k(it,1)=3
14591  IF((iabs(k(it,2)).GE.11.AND.iabs(k(it,2)).LE.18).OR.
14592  & iabs(k(it,2)).EQ.22) k(it,1)=1
14593  p(it,5)=pymass(k(it,2))
14594  IF(dmsma.LE.p(it,5)**2) goto 100
14595  IF(mstp(63).GE.1.AND.mcesv(jt).EQ.1) THEN
14596  mstj48=mstj(48)
14597  parj85=parj(85)
14598  p(it,4)=(dshz-dsh-p(it,5)**2)/dshr
14599  p(it,3)=sqrt(p(it,4)**2-p(it,5)**2)
14600  IF(mstp(63).EQ.1) THEN
14601  q2tim=dmsma
14602  ELSEIF(mstp(63).EQ.2) THEN
14603  q2tim=min(dmsma,parp(71)*q2s(jt))
14604  ELSE
14605  q2tim=dmsma
14606  mstj(48)=1
14607  IF(ikin.EQ.0) dpt2=dmsma*(dshz+dq2(3))/(dsh+dq2(jt))
14608  IF(ikin.EQ.1) dpt2=dmsma*(0.5d0*dpd(1)*dpd(2)+0.5d0*dpd(3)*
14609  & dpd(4)-dq2(jr)*(dq2(jt)+dq2(3)))/(4d0*dsh*dpc(3)**2)
14610  parj(85)=sqrt(max(0d0,dpt2))*
14611  & (1d0/p(it,4)+1d0/p(is(jt),4))
14612  ENDIF
14613 C...Only do timelike shower here if using PYSHOW
14614  IF (mstj(41).NE.11.AND.mstj(41).NE.12) THEN
14615  CALL pyshow(it,0,sqrt(q2tim))
14616  ENDIF
14617  mstj(48)=mstj48
14618  parj(85)=parj85
14619  IF(n.GE.it+1) p(it,5)=p(it+1,5)
14620  ENDIF
14621 
14622 C...Reconstruct kinematics of branching: timelike parton shower.
14623  dms=p(it,5)**2
14624  IF(ikin.EQ.0) dpt2=(dmsma-dms)*(dshz+dq2(3))/(dsh+dq2(jt))
14625  IF(ikin.EQ.1) dpt2=(dmsma-dms)*(0.5d0*dpd(1)*dpd(2)+
14626  & 0.5d0*dpd(3)*dpd(4)-dq2(jr)*(dq2(jt)+dq2(3)+dms))/
14627  & (4d0*dsh*dpc(3)**2)
14628  IF(dpt2.LT.0d0) goto 100
14629  dpb(1)=(0.5d0*dpd(2)-dpc(jr)*(dshz+dq2(jr)-dq2(jt)-dms)/
14630  & dshr)/dpc(3)-dpc(3)
14631  p(it,1)=sqrt(dpt2)
14632  p(it,3)=dpb(1)*(-1)**(jt+1)
14633  p(it,4)=sqrt(dpt2+dpb(1)**2+dms)
14634  IF(n.GE.it+1) THEN
14635  dpb(1)=sqrt(dpb(1)**2+dpt2)
14636  dpb(2)=sqrt(dpb(1)**2+dms)
14637  dpb(3)=p(it+1,3)
14638  dpb(4)=sqrt(dpb(3)**2+dms)
14639  dbez=(dpb(4)*dpb(1)-dpb(3)*dpb(2))/(dpb(4)*dpb(2)-dpb(3)*
14640  & dpb(1))
14641  CALL pyrobo(it+1,n,0d0,0d0,0d0,0d0,dbez)
14642  the=pyangl(p(it,3),p(it,1))
14643  CALL pyrobo(it+1,n,the,0d0,0d0,0d0,0d0)
14644  ENDIF
14645 
14646 C...Reconstruct kinematics of branching: spacelike parton.
14647  DO 300 j=1,5
14648  k(n+1,j)=0
14649  p(n+1,j)=0d0
14650  v(n+1,j)=0d0
14651  300 CONTINUE
14652  k(n+1,1)=14
14653  k(n+1,2)=kflb
14654  p(n+1,1)=p(it,1)
14655  p(n+1,3)=p(it,3)+p(is(jt),3)
14656  p(n+1,4)=p(it,4)+p(is(jt),4)
14657  p(n+1,5)=-sqrt(dq2(3))
14658  mct(n+1,1)=0
14659  mct(n+1,2)=0
14660 
14661 C...Define colour flow of branching.
14662  k(is(jt),3)=n+1
14663  k(it,3)=n+1
14664  im1=n+1
14665  im2=n+1
14666 C...f -> f + gamma (Z, W).
14667  IF(iabs(k(it,2)).GE.22) THEN
14668  k(it,1)=1
14669  id1=is(jt)
14670  id2=is(jt)
14671 C...f -> gamma (Z, W) + f.
14672  ELSEIF(iabs(k(is(jt),2)).GE.22) THEN
14673  id1=it
14674  id2=it
14675 C...gamma -> q + qbar, g + g.
14676  ELSEIF(k(n+1,2).EQ.22) THEN
14677  id1=is(jt)
14678  id2=it
14679  im1=id2
14680  im2=id1
14681 C...q -> q + g.
14682  ELSEIF(k(n+1,2).GT.0.AND.k(n+1,2).NE.21.AND.k(it,2).EQ.21) THEN
14683  id1=it
14684  id2=is(jt)
14685 C...q -> g + q.
14686  ELSEIF(k(n+1,2).GT.0.AND.k(n+1,2).NE.21) THEN
14687  id1=is(jt)
14688  id2=it
14689 C...qbar -> qbar + g.
14690  ELSEIF(k(n+1,2).LT.0.AND.k(it,2).EQ.21) THEN
14691  id1=is(jt)
14692  id2=it
14693 C...qbar -> g + qbar.
14694  ELSEIF(k(n+1,2).LT.0) THEN
14695  id1=it
14696  id2=is(jt)
14697 C...g -> g + g; g -> q + qbar.
14698  ELSEIF((k(it,2).EQ.21.AND.pyr(0).GT.0.5d0).OR.k(it,2).LT.0) THEN
14699  id1=is(jt)
14700  id2=it
14701  ELSE
14702  id1=it
14703  id2=is(jt)
14704  ENDIF
14705  IF(im1.EQ.n+1) k(im1,4)=k(im1,4)+id1
14706  IF(im2.EQ.n+1) k(im2,5)=k(im2,5)+id2
14707  k(id1,4)=k(id1,4)+mstu(5)*im1
14708  k(id2,5)=k(id2,5)+mstu(5)*im2
14709  IF(id1.NE.id2) THEN
14710  k(id1,5)=k(id1,5)+mstu(5)*id2
14711  k(id2,4)=k(id2,4)+mstu(5)*id1
14712  ENDIF
14713  n=n+1
14714  IF(k(it,1).EQ.1) THEN
14715  k(it,4)=0
14716  k(it,5)=0
14717  ENDIF
14718 
14719 C...Boost to new CM-frame.
14720  dbsvx=(p(n,1)+p(is(jr),1))/(p(n,4)+p(is(jr),4))
14721  dbsvz=(p(n,3)+p(is(jr),3))/(p(n,4)+p(is(jr),4))
14722  IF(dbsvx**2+dbsvz**2.GE.1d0) goto 100
14723  CALL pyrobo(ns+1,n,0d0,0d0,-dbsvx,0d0,-dbsvz)
14724  ir=n+(jt-1)*(is(1)-n)
14725  CALL pyrobo(ns+1,n,-pyangl(p(ir,3),p(ir,1)),dphi(jt),
14726  & 0d0,0d0,0d0)
14727 
14728 C...Save timelike parton in PYPART if doing pT-ordered FSR off ISR
14729  IF (mstj(41).EQ.11.OR.mstj(41).EQ.12) THEN
14730  npart=npart+1
14731  ipart(npart)=it
14732  ptpart(npart)=sqrt(parp(71)*dpt2)
14733  ENDIF
14734 
14735 C...Global statistics.
14736  mint(352)=mint(352)+1
14737  vint(352)=vint(352)+sqrt(p(it,1)**2+p(it,2)**2)
14738  IF (mint(352).EQ.1) vint(357)=sqrt(p(it,1)**2+p(it,2)**2)
14739 
14740  ENDIF
14741 
14742 C...Update kinematics variables.
14743  is(jt)=n
14744  dq2(jt)=q2b
14745  IF(mstp(62).GE.3.AND.ntry2.LT.200.AND.mce.EQ.1) the2(jt)=the2t
14746  dsh=dshz
14747 
14748 C...Save quantities; loop back.
14749  q2s(jt)=q2b
14750  dphi(jt)=phibr
14751  mcesv(jt)=mce
14752  IF((mcev.EQ.1.AND.q2b.GE.0.25d0*q2mnc).OR.
14753  &(meev.EQ.1.AND.q2b.GE.q2mne)) THEN
14754  kfls(jt+2)=kfls(jt)
14755  kfls(jt)=kfla
14756  xs(jt)=xa
14757  zs(jt)=z
14758  DO 310 kfl=-25,25
14759  xfs(jt,kfl)=xfa(kfl)
14760  310 CONTINUE
14761  tevcsv(jt)=tevcb
14762  tevesv(jt)=teveb
14763  ELSE
14764  more(jt)=0
14765  IF(jt.EQ.1) ipu1=n
14766  IF(jt.EQ.2) ipu2=n
14767  ENDIF
14768  IF(n.GT.mstu(4)-mstu(32)-10) THEN
14769  CALL pyerrm(11,'(PYSSPA:) no more memory left in PYJETS')
14770  IF(mstu(21).GE.1) n=ns
14771  IF(mstu(21).GE.1) RETURN
14772  ENDIF
14773  IF(more(1).EQ.1.OR.more(2).EQ.1) goto 150
14774 
14775 C...Boost hard scattering partons to frame of shower initiators.
14776  DO 320 j=1,3
14777  robo(j+2)=(p(ns+1,j)+p(ns+2,j))/(p(ns+1,4)+p(ns+2,4))
14778  320 CONTINUE
14779  k(n+2,1)=1
14780  DO 330 j=1,5
14781  p(n+2,j)=p(ns+1,j)
14782  330 CONTINUE
14783  CALL pyrobo(n+2,n+2,0d0,0d0,-robo(3),-robo(4),-robo(5))
14784  robo(2)=pyangl(p(n+2,1),p(n+2,2))
14785  robo(1)=pyangl(p(n+2,3),sqrt(p(n+2,1)**2+p(n+2,2)**2))
14786  imin=mint(83)+5
14787  IF(mint(31).GE.2) imin=min(ipus1,ipus2)
14788  CALL pyrobo(imin,ns,0d0,-robo(2),0d0,0d0,0d0)
14789  CALL pyrobo(imin,ns,robo(1),robo(2),robo(3),robo(4),robo(5))
14790 
14791 C...Store user information. Reset Lambda value.
14792  IF(mint(31).LE.1) THEN
14793  k(ipu1,3)=mint(83)+3
14794  k(ipu2,3)=mint(83)+4
14795  ELSE
14796  k(ipu1,3)=mint(83)+1
14797  k(ipu2,3)=mint(83)+2
14798  ENDIF
14799  DO 340 jt=1,2
14800  mint(12+jt)=kfls(jt)
14801  vint(140+jt)=xs(jt)
14802  IF(mint(18+jt).EQ.1) vint(140+jt)=vint(154+jt)*xs(jt)
14803  IF(mint(31).GE.2) vint(140+jt)=vint(140+jt)*vint(142+jt)
14804  340 CONTINUE
14805  paru(112)=alams
14806 
14807  RETURN
14808  END
14809 
14810 C*********************************************************************
14811 
14812 C...PYPTIS
14813 C...Generates pT-ordered spacelike initial-state parton showers and
14814 C...trial joinings.
14815 C...MODE=-1: Initialize ISR from scratch, starting from the hardest
14816 C... interaction initiators at PT2NOW.
14817 C...MODE= 0: Generate a trial branching on interaction MINT(36), side
14818 C... MINT(30). Start evolution at PT2NOW, solve Sudakov for PT2.
14819 C... Store in /PYISMX/ if PT2 is largest so far. Abort if PT2
14820 C... is below PT2CUT.
14821 C... (Also generate test joinings if MSTP(96)=1.)
14822 C...MODE= 1: Accept stored shower branching. Update event record etc.
14823 C...PT2NOW : Starting (max) PT2 scale for evolution.
14824 C...PT2CUT : Lower limit for evolution.
14825 C...PT2 : Result of evolution. Generated PT2 for trial emission.
14826 C...IFAIL : Status return code. IFAIL=0 when all is well.
14827 
14828  SUBROUTINE pyptis(MODE,PT2NOW,PT2CUT,PT2,IFAIL)
14829 
14830 C...Double precision and integer declarations.
14831  IMPLICIT DOUBLE PRECISION(a-h, o-z)
14832  IMPLICIT INTEGER(i-n)
14833  INTEGER pyk,pychge,pycomp
14834 C...Parameter statement for maximum size of showers.
14835  parameter(maxnur=1000)
14836 C...Commonblocks.
14837  common/pypart/npart,npartd,ipart(maxnur),ptpart(maxnur)
14838  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
14839  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
14840  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
14841  common/pypars/mstp(200),parp(200),msti(200),pari(200)
14842  common/pyint1/mint(400),vint(400)
14843  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
14844  common/pyintm/kfival(2,3),nmi(2),imi(2,800,2),nvc(2,-6:6),
14845  & xassoc(2,-6:6,240),xpsvc(-6:6,-1:240),pvctot(2,-1:1),
14846  & xmi(2,240),pt2mi(240),imisep(0:240)
14847  common/pyismx/mimx,jsmx,kflamx,kflcmx,kfbeam(2),nisgen(2,240),
14848  & pt2mx,pt2amx,zmx,rm2cmx,q2bmx,phimx
14849  common/pyctag/nct,mct(4000,2)
14850  common/pyisjn/mjn1mx,mjn2mx,mjoind(2,240)
14851  SAVE /pypart/,/pyjets/,/pydat1/,/pydat2/,/pypars/,/pyint1/,
14852  & /pyint2/,/pyintm/,/pyismx/,/pyctag/,/pyisjn/
14853 C...Local variables
14854  dimension zsav(2,240),pt2sav(2,240),
14855  & xfb(-25:25),xfa(-25:25),xfn(-25:25),xfj(-25:25),
14856  & wtap(-25:25),wtpdf(-25:25),shtnow(240),
14857  & wtapj(240),wtpdfj(240),x1(240),y(240)
14858  SAVE zsav,pt2sav,xfb,xfa,xfn,wtap,wtpdf,xmxc,shtnow,
14859  & rmb2,rmc2,alam3,alam4,alam5,tmin,ptemax,wtemax,aem2pi
14860 C...For check on excessive weights.
14861  CHARACTER chwt*12
14862 
14863 C...Only give errors for very large weights, otherwise just warnings
14864  DATA wtemax /1.5d0/
14865 C...Only give errors for large pT, otherwise just warnings
14866  DATA ptemax /5d0/
14867 
14868  ifail=-1
14869 
14870 C----------------------------------------------------------------------
14871 C...MODE=-1: Initialize initial state showers from scratch, i.e.
14872 C...starting from the hardest interaction initiators.
14873  IF (mode.EQ.-1) THEN
14874 C...Set hard scattering SHAT.
14875  shtnow(1)=vint(44)
14876 C...Mass thresholds and Lambda for QCD evolution.
14877  aem2pi=paru(101)/paru(2)
14878  rmb=pmas(5,1)
14879  rmc=pmas(4,1)
14880  alam4=parp(61)
14881  IF(mstu(112).LT.4) alam4=parp(61)*(parp(61)/rmc)**(2d0/25d0)
14882  IF(mstu(112).GT.4) alam4=parp(61)*(rmb/parp(61))**(2d0/25d0)
14883  alam5=alam4*(alam4/rmb)**(2d0/23d0)
14884  alam3=alam4*(rmc/alam4)**(2d0/27d0)
14885 C...Optionally use Lambda_MC = Lambda_CMW
14886  IF (mstp(64).EQ.3) THEN
14887  alam5 = alam5 * 1.569
14888  alam4 = alam4 * 1.618
14889  alam3 = alam3 * 1.661
14890  ENDIF
14891  rmb2=rmb**2
14892  rmc2=rmc**2
14893 C...Massive quark forced creation threshold (in M**2).
14894  tmin=1.01d0
14895 C...Set upper limit for X (ensures some X left for beam remnant).
14896  xmxc=1d0-2d0*parp(111)/vint(1)
14897 
14898  IF (mstp(61).GE.1) THEN
14899 C...Initial values: flavours, momenta, virtualities.
14900  DO 100 js=1,2
14901  nisgen(js,1)=0
14902 
14903 C...Special kinematics check for c/b quarks (that g -> c cbar or
14904 C...b bbar kinematically possible).
14905  kflb=k(imi(js,1,1),2)
14906  kflcb=iabs(kflb)
14907  IF(kfbeam(js).NE.22.AND.(kflcb.EQ.4.OR.kflcb.EQ.5)) THEN
14908 C...Check PT2MAX > mQ^2
14909  IF (vint(56).LT.1.05d0*pmas(pycomp(kflcb),1)**2) THEN
14910  CALL pyerrm(9,'(PYPTIS:) PT2MAX < 1.05 * MQ**2. '//
14911  & 'No Q creation possible.')
14912  mint(51)=1
14913  RETURN
14914  ELSE
14915 C...Check for physical z values (m == MQ / sqrt(s))
14916 C...For creation diagram, x < z < (1-m)/(1+m(1-m))
14917  fmq=pmas(kflcb,1)/sqrt(shtnow(1))
14918  zmxcr=(1d0-fmq)/(1d0+fmq*(1d0-fmq))
14919  IF (xmi(js,1).GT.0.9d0*zmxcr) THEN
14920  CALL pyerrm(9,'(PYPTIS:) No physical z value for '//
14921  & 'Q creation.')
14922  mint(51)=1
14923  RETURN
14924  ENDIF
14925  ENDIF
14926  ENDIF
14927  100 CONTINUE
14928  ENDIF
14929 
14930  mint(354)=0
14931 C...Zero joining array
14932  DO 110 mj=1,240
14933  mjoind(1,mj)=0
14934  mjoind(2,mj)=0
14935  110 CONTINUE
14936 
14937 C----------------------------------------------------------------------
14938 C...MODE= 0: Generate a trial branching on interaction MINT(36) side
14939 C...MINT(30). Store if emission PT2 scale is largest so far.
14940 C...Also generate test joinings if MSTP(96)=1.
14941  ELSEIF(mode.EQ.0) THEN
14942  ifail=-1
14943  mecor=0
14944  isub=mint(1)
14945  js=mint(30)
14946 C...No shower for structureless beam
14947  IF (mint(44+js).EQ.1) RETURN
14948  mi=mint(36)
14949  shat=vint(44)
14950 C...Absolute shower max scale = VINT(56)
14951  IF (mstp(67).NE.0) THEN
14952  pt2 = min(pt2now,vint(56))
14953  ELSE
14954 C...For MSTP(67)=0, adjust starting scale by PARP(67)
14955  pt2=min(pt2now,parp(67)*vint(56))
14956  ENDIF
14957  IF (nisgen(1,mi).EQ.0.AND.nisgen(2,mi).EQ.0) shtnow(mi)=shat
14958 C...Define for which processes ME corrections have been implemented.
14959  IF(mstp(68).EQ.1.OR.mstp(68).EQ.3) THEN
14960  IF(isub.EQ.1.OR.isub.EQ.2.OR.isub.EQ.141.OR.isub.eq
14961  & .142.OR.isub.EQ.144) mecor=1
14962  IF(isub.EQ.102.OR.isub.EQ.152.OR.isub.EQ.157) mecor=2
14963  IF(isub.EQ.3.OR.isub.EQ.151.OR.isub.EQ.156) mecor=3
14964 C...Calculate preweighting factor for ME-corrected processes.
14965  IF(mecor.GE.1) CALL pymemx(mecor,wtff,wtgf,wtfg,wtgg)
14966  ENDIF
14967 C...Basic info on daughter for which to find mother.
14968  kflb=k(imi(js,mi,1),2)
14969  kflba=iabs(kflb)
14970 C...KSVCB: -1 for sea or first companion, 0 for valence or gluon, >1 for
14971 C...second companion.
14972  ksvcb=max(-1,imi(js,mi,2))
14973 C...Treat "first" companion of a pair like an ordinary sea quark
14974 C...(except that creation diagram is not allowed)
14975  IF(imi(js,mi,2).GT.imisep(mi)) ksvcb=-1
14976 C...X (rescaled to [0,1])
14977  xb=xmi(js,mi)/vint(142+js)
14978 C...Massive quarks (use physical masses.)
14979  rmq2=0d0
14980  mqmass=0
14981  IF (kflba.EQ.4.OR.kflba.EQ.5) THEN
14982  rmq2=rmc2
14983  IF (kflba.EQ.5) rmq2=rmb2
14984 C...Special threshold treatment for non-photon beams
14985  IF (kfbeam(js).NE.22) mqmass=kflba
14986 C...Check that not below mass threshold.
14987  IF(mqmass.GT.0.AND.pt2.LT.tmin*rmq2) THEN
14988  CALL pyerrm(9,'(PYPTIS:) PT2 < 1.01 * MQ**2. '//
14989  & 'No Q creation possible.')
14990  mint(51)=1
14991 C...Special return code if failing before any evolution at all: bad event
14992  IF (nisgen(1,mi).EQ.0.AND.nisgen(2,mi).EQ.0) mint(51)=2
14993  RETURN
14994  ENDIF
14995 
14996  ENDIF
14997 
14998 C...Flags for parton distribution calls.
14999  mint(105)=mint(102+js)
15000  mint(109)=mint(106+js)
15001  vint(120)=vint(2+js)
15002 
15003 C...Calculate initial parton distribution weights.
15004  IF(xb.GE.xmxc) THEN
15005  RETURN
15006  ELSEIF(mqmass.EQ.0) THEN
15007  CALL pypdfu(kfbeam(js),xb,pt2,xfb)
15008  ELSE
15009 C...Initialize massive quark PT2 dependent pdf underestimate.
15010  pt20=pt2
15011  CALL pypdfu(kfbeam(js),xb,pt20,xfb)
15012 C.!.Tentative treatment of massive valence quarks.
15013  xq0=max(1d-10,xpsvc(kflb,ksvcb))
15014  xg0=xfb(21)
15015  tpm0=log(pt20/rmq2)
15016  wpdf0=tpm0*xg0/xq0
15017  ENDIF
15018  IF (kflba.LE.6) THEN
15019 C...For quarks, only include respective sea, val, or cmp part.
15020  IF (ksvcb.LE.0) THEN
15021  xfb(kflb)=xpsvc(kflb,ksvcb)
15022  ELSE
15023 C...Find companion's companion
15024  misea=0
15025  120 misea=misea+1
15026  IF (imi(js,misea,2).NE.imi(js,mi,1)) goto 120
15027  xs=xmi(js,misea)
15028  xrem=vint(142+js)
15029  ys=xs/(xrem+xs)
15030 C...Momentum fraction of the companion quark.
15031 C...Rescale from XB = x/XREM to YB = x/(1-Sum_rest) -> factor (1-YS).
15032  yb=xb*(1d0-ys)
15033  xfb(kflb)=pyfcmp(yb/vint(140),ys/vint(140),mstp(87))
15034  ENDIF
15035  ENDIF
15036 
15037 C...Determine overestimated z range: switch at c and b masses.
15038  130 IF (pt2.GT.tmin*rmb2) THEN
15039  izrg=3
15040  pt2mne=max(tmin*rmb2,pt2cut)
15041  b0=23d0/6d0
15042  alam2=alam5**2
15043  ELSEIF(pt2.GT.tmin*rmc2) THEN
15044  izrg=2
15045  pt2mne=max(tmin*rmc2,pt2cut)
15046  b0=25d0/6d0
15047  alam2=alam4**2
15048  ELSE
15049  izrg=1
15050  pt2mne=pt2cut
15051  b0=27d0/6d0
15052  alam2=alam3**2
15053  ENDIF
15054 C...Divide Lambda by PARP(64) (equivalent to mult pT2 by PARP(64))
15055  alam2=alam2/parp(64)
15056 C...Overestimated ZMAX:
15057  IF (mqmass.EQ.0) THEN
15058 C...Massless
15059  zmax=1d0-0.5d0*(pt2mne/shtnow(mi))*(sqrt(1d0+4d0*shtnow(mi)
15060  & /pt2mne)-1d0)
15061  ELSE
15062 C...Massive (limit for bremsstrahlung diagram > creation)
15063  fmq=sqrt(rmq2/shtnow(mi))
15064  zmax=1d0/(1d0+fmq)
15065  ENDIF
15066  zmin=xb/xmxc
15067 
15068 C...If kinematically impossible then do not evolve.
15069  IF(pt2.LT.pt2cut.OR.zmax.LE.zmin) RETURN
15070 
15071 C...Reset Altarelli-Parisi and PDF weights.
15072  DO 140 kfl=-5,5
15073  wtap(kfl)=0d0
15074  wtpdf(kfl)=0d0
15075  140 CONTINUE
15076  wtap(21)=0d0
15077  wtpdf(21)=0d0
15078 C...Zero joining weights and compute X(partner) and X(mother) values.
15079  njn=0
15080  IF (mstp(96).NE.0) THEN
15081  DO 150 mj=1,mint(31)
15082  wtapj(mj)=0d0
15083  wtpdfj(mj)=0d0
15084  x1(mj)=xmi(js,mj)/(vint(142+js)+xmi(js,mj))
15085  y(mj)=(xmi(js,mi)+xmi(js,mj))/(vint(142+js)+xmi(js,mj)
15086  & +xmi(js,mi))
15087  150 CONTINUE
15088  ENDIF
15089 
15090 C...Approximate Altarelli-Parisi weights (integrated AP dz).
15091 C...q -> q, g -> q or q -> q + gamma (already set which).
15092  IF(kflba.LE.5) THEN
15093 C...Val and cmp quarks get an extra sqrt(z) to smooth their bumps.
15094  IF (ksvcb.LT.0) THEN
15095  wtap(kflb)=(8d0/3d0)*log((1d0-zmin)/(1d0-zmax))
15096  ELSE
15097  rmin=(1+sqrt(zmin))/(1-sqrt(zmin))
15098  rmax=(1+sqrt(zmax))/(1-sqrt(zmax))
15099  wtap(kflb)=(8d0/3d0)*log(rmax/rmin)
15100  ENDIF
15101  wtap(21)=0.5d0*(zmax-zmin)
15102  wtape=(2d0/9d0)*log((1d0-zmin)/(1d0-zmax))
15103  IF(mod(kflba,2).EQ.0) wtape=4d0*wtape
15104  IF(mecor.GE.1.AND.nisgen(js,mi).EQ.0) THEN
15105  wtap(kflb)=wtff*wtap(kflb)
15106  wtap(21)=wtgf*wtap(21)
15107  wtape=wtff*wtape
15108  ENDIF
15109  IF(mstp(61).EQ.1) wtape=0d0
15110  IF (ksvcb.GE.1) THEN
15111 C...Kill normal creation but add joining diagrams for cmp quark.
15112  wtap(21)=0d0
15113  IF (kflba.EQ.4.OR.kflba.EQ.5) THEN
15114  CALL pyerrm(9,'(PYPTIS:) Sorry, I got a heavy companion'//
15115  & " quark here. Not handled yet, giving up!")
15116  pt2=0d0
15117  mint(51)=1
15118  RETURN
15119  ENDIF
15120 C...Check for possible joinings
15121  IF (mstp(96).NE.0.AND.mjoind(js,mi).EQ.0) THEN
15122 C...Find companion's companion.
15123  mj=0
15124  160 mj=mj+1
15125  IF (imi(js,mj,2).NE.imi(js,mi,1)) goto 160
15126  IF (mjoind(js,mj).EQ.0) THEN
15127  y(mi)=yb+ys
15128  z=yb/y(mi)
15129  wtapj(mj)=z*(1d0-z)*0.5d0*(z**2+(1d0-z)**2)
15130  IF (wtapj(mj).GT.1d-6) THEN
15131  njn=1
15132  ELSE
15133  wtapj(mj)=0d0
15134  ENDIF
15135  ENDIF
15136 C...Add trial gluon joinings.
15137  DO 170 mj=1,mint(31)
15138  kflc=k(imi(js,mj,1),2)
15139  IF (kflc.NE.21.OR.mjoind(js,mj).NE.0) goto 170
15140  z=xmi(js,mj)/(xmi(js,mi)+xmi(js,mj))
15141  wtapj(mj)=6d0*(z**2+(1d0-z)**2)
15142  IF (wtapj(mj).GT.1d-6) THEN
15143  njn=njn+1
15144  ELSE
15145  wtapj(mj)=0d0
15146  ENDIF
15147  170 CONTINUE
15148  ENDIF
15149  ELSEIF (imi(js,mi,2).GE.0) THEN
15150 C...Kill creation diagram for val quarks and sea quarks with companions.
15151  wtap(21)=0d0
15152  ELSEIF (mqmass.EQ.0) THEN
15153 C...Extra safety factor for massless sea quark creation.
15154  wtap(21)=wtap(21)*1.25d0
15155  ENDIF
15156 
15157 C... q -> g, g -> g.
15158  ELSEIF(kflb.EQ.21) THEN
15159 C...Here we decide later whether a quark picked up is valence or
15160 C...sea, so we maintain the extra factor sqrt(z) since we deal
15161 C...with the *sum* of sea and valence in this context.
15162  wtapq=(16d0/3d0)*(sqrt(1d0/zmin)-sqrt(1d0/zmax))
15163 C...new: do not allow backwards evol to pick up heavy flavour.
15164  DO 180 kfl=1,min(3,mstp(58))
15165  wtap(kfl)=wtapq
15166  wtap(-kfl)=wtapq
15167  180 CONTINUE
15168  wtap(21)=6d0*log(zmax*(1d0-zmin)/(zmin*(1d0-zmax)))
15169  IF(mecor.GE.1.AND.nisgen(js,mi).EQ.0) THEN
15170  wtapq=wtfg*wtapq
15171  wtap(21)=wtgg*wtap(21)
15172  ENDIF
15173 C...Check for possible joinings (companions handled separately above)
15174  IF (mstp(96).NE.0.AND.mint(31).GE.2.AND.mjoind(js,mi).EQ.0)
15175  & THEN
15176  DO 190 mj=1,mint(31)
15177  IF (mj.EQ.mi.OR.mjoind(js,mj).NE.0) goto 190
15178  ksvcc=imi(js,mj,2)
15179  IF (imi(js,mj,2).GT.imisep(mj)) ksvcc=-1
15180  IF (ksvcc.GE.1) goto 190
15181  kflc=k(imi(js,mj,1),2)
15182 C...Only try g -> g + g once.
15183  IF (mj.GT.mi.AND.kflc.EQ.21) goto 190
15184  z=xmi(js,mj)/(xmi(js,mi)+xmi(js,mj))
15185  IF (kflc.EQ.21) THEN
15186  wtapj(mj)=6d0*(z**2+(1d0-z)**2)
15187  ELSE
15188  wtapj(mj)=z*4d0/3d0*(1d0+z**2)
15189  ENDIF
15190  IF (wtapj(mj).GT.1d-6) THEN
15191  njn=njn+1
15192  ELSE
15193  wtapj(mj)=0d0
15194  ENDIF
15195  190 CONTINUE
15196  ENDIF
15197  ENDIF
15198 
15199 C...Initialize massive quark evolution
15200  IF (mqmass.NE.0) THEN
15201  rml=(rmq2+vint(18))/alam2
15202  tml=log(rml)
15203  tpl=log((pt2+vint(18))/alam2)
15204  tpm=log((pt2+vint(18))/rmq2)
15205  wn=wtap(21)*wpdf0/b0
15206  ENDIF
15207 
15208 
15209 C...Loopback point for iteration
15210  ntry=0
15211  nthres=0
15212  200 ntry=ntry+1
15213  IF(ntry.GT.500) THEN
15214  CALL pyerrm(9,'(PYPTIS:) failed to evolve shower.')
15215  mint(51)=1
15216  RETURN
15217  ENDIF
15218 
15219 C... Calculate PDF weights and sum for evolution rate.
15220  wtsum=0d0
15221  xfbo=max(1d-10,xfb(kflb))
15222  DO 210 kfl=-5,5
15223  wtpdf(kfl)=xfb(kfl)/xfbo
15224  wtsum=wtsum+wtap(kfl)*wtpdf(kfl)
15225  210 CONTINUE
15226 C...Only add gluon mother diagram for massless KFLB.
15227  IF(mqmass.EQ.0) THEN
15228  wtpdf(21)=xfb(21)/xfbo
15229  wtsum=wtsum+wtap(21)*wtpdf(21)
15230  ENDIF
15231  wtsum=max(0.0001d0,wtsum)
15232  wtsums=wtsum
15233 C...Add joining diagrams where applicable.
15234  wtjoin=0d0
15235  IF (mstp(96).NE.0.AND.njn.NE.0) THEN
15236  DO 220 mj=1,mint(31)
15237  IF (wtapj(mj).LT.1d-3) goto 220
15238  wtpdfj(mj)=1d0/xfbo
15239 C...x and x*pdf (+ sea/val) for parton C.
15240  kflc=k(imi(js,mj,1),2)
15241  kflca=iabs(kflc)
15242  ksvcc=max(-1,imi(js,mj,2))
15243  IF (imi(js,mj,2).GT.imisep(mj)) ksvcc=-1
15244  mint(30)=js
15245  mint(36)=mj
15246  CALL pypdfu(kfbeam(js),x1(mj),pt2,xfj)
15247  mint(36)=mi
15248  IF (kflca.LE.6.AND.ksvcc.LE.0) THEN
15249  xfj(kflc)=xpsvc(kflc,ksvcc)
15250  ELSEIF (ksvcc.GE.1) THEN
15251  print*, 'error! parton C is companion!'
15252  ENDIF
15253  wtpdfj(mj)=wtpdfj(mj)/xfj(kflc)
15254 C...x and x*pdf (+ sea/val) for parton A.
15255  kfla=21
15256  ksvca=0
15257  IF (kflca.EQ.21.AND.kflba.LE.5) THEN
15258  kfla=kflb
15259  ksvca=ksvcb
15260  ELSEIF (kflba.EQ.21.AND.kflca.LE.5) THEN
15261  kfla=kflc
15262  ksvca=ksvcc
15263  ENDIF
15264  mint(30)=js
15265  IF (ksvca.LE.0) THEN
15266 C...Consider C the "evolved" parton if B is gluon. Val/sea
15267 C...counting will then be done correctly in PYPDFU.
15268  IF (kflba.EQ.21) mint(36)=mj
15269  CALL pypdfu(kfbeam(js),y(mj),pt2,xfj)
15270  mint(36)=mi
15271  IF (iabs(kfla).LE.6) xfj(kfla)=xpsvc(kfla,ksvca)
15272  ELSE
15273 C...If parton A is companion, use Y(MI) and YS in call to PYFCMP.
15274  xfj(kfla)=pyfcmp(y(mi)/vint(140),ys/vint(140),mstp(87))
15275  ENDIF
15276  wtpdfj(mj)=xfj(kfla)*wtpdfj(mj)
15277  wtjoin=wtjoin+wtapj(mj)*wtpdfj(mj)
15278  220 CONTINUE
15279  ENDIF
15280 
15281 C...Pick normal pT2 (in overestimated z range).
15282  230 pt2old=pt2
15283  wtsum=wtsums
15284  pt2=alam2*((pt2+vint(18))/alam2)**(pyr(0)**(b0/wtsum))-vint(18)
15285  kflc=21
15286 
15287 C...Evolve q -> q gamma separately, pick it if larger pT.
15288  IF(kflba.LE.5.AND.mstp(61).GE.2) THEN
15289  pt2qed=(pt2old+vint(18))*pyr(0)**(1d0/(aem2pi*wtape))-vint(18)
15290  IF(pt2qed.GT.pt2) THEN
15291  pt2=pt2qed
15292  kflc=22
15293  kfla=kflb
15294  ENDIF
15295  ENDIF
15296 
15297 C... Evolve massive quark creation separately.
15298  mcrqq=0
15299  IF (mqmass.NE.0) THEN
15300  pt2cr=(rmq2+vint(18))*(rml**(tpm/(tpl*pyr(0)**(-tml/wn)-tpm)))
15301  & -vint(18)
15302 C...If massive quark also on opposite side, ensure sufficient remaining
15303 C...phase space also for creation of that quark
15304  tminqq = tmin
15305  kflopp = k(imi(3-js,mi,1),2)
15306  IF (abs(kflopp).EQ.4.OR.abs(kflopp).EQ.5) tminqq = 1.05
15307 C...Ensure mininimum PT2CR and force creation near threshold.
15308  IF (pt2cr.LT.tminqq*rmq2) THEN
15309  nthres=nthres+1
15310  IF (nthres.GT.50) THEN
15311  CALL pyerrm(9,'(PYPTIS:) no phase space left for '//
15312  & 'massive quark creation. Gave up trying.')
15313  mint(51)=1
15314 C...Special return code if failing before any evolution at all: bad event
15315  IF (nisgen(1,mi).EQ.0.AND.nisgen(2,mi).EQ.0) mint(51)=2
15316  RETURN
15317  ENDIF
15318  pt2=0d0
15319  pt2cr=tminqq*rmq2
15320 C...Signal that massive quark creation is being forced
15321  mcrqq=2
15322  ENDIF
15323 C... Select largest PT2 (brems or creation):
15324  IF (pt2cr.GT.pt2) THEN
15325  mcrqq=max(mcrqq,1)
15326  wtsum=0d0
15327  pt2=pt2cr
15328  kfla=21
15329  ELSE
15330  mcrqq=0
15331  kfla=kflb
15332  ENDIF
15333 C... Compute logarithms for this PT2
15334  tpl=log((pt2+vint(18))/alam2)
15335  tpm=log((pt2+vint(18))/(rmq2+vint(18)))
15336  wtcrqq=tpm/log(pt2/rmq2)
15337  ENDIF
15338 
15339 C...Evolve joining separately
15340  mjoin=0
15341  IF (mstp(96).NE.0.AND.njn.NE.0) THEN
15342  pt2jn=alam2*((pt2old+vint(18))/alam2)**(pyr(0)**(b0/wtjoin))
15343  & -vint(18)
15344  IF (pt2jn.GE.pt2) THEN
15345  mjoin=1
15346  pt2=pt2jn
15347  ENDIF
15348  ENDIF
15349 
15350 C...Loopback if crossed c/b mass thresholds.
15351  IF(izrg.EQ.3.AND.pt2.LT.rmb2) THEN
15352  pt2=rmb2
15353  goto 130
15354  ELSEIF(izrg.EQ.2.AND.pt2.LT.rmc2) THEN
15355  pt2=rmc2
15356  goto 130
15357  ENDIF
15358 
15359 C...Speed up shower. Skip if higher-PT acceptable branching
15360 C...already found somewhere else.
15361 C...Also finish if below lower cutoff.
15362 
15363  IF ((pt2-pt2mx).LT.-0.001.OR.pt2.LT.pt2cut) RETURN
15364 
15365 C...Select parton A flavour (massive Q handled above.)
15366  IF (mqmass.EQ.0.AND.kflc.NE.22.AND.mjoin.EQ.0) THEN
15367  wtran=pyr(0)*wtsum
15368  kfla=-6
15369  240 kfla=kfla+1
15370  wtran=wtran-wtap(kfla)*wtpdf(kfla)
15371  IF(kfla.LE.5.AND.wtran.GT.0d0) goto 240
15372  IF(kfla.EQ.6) kfla=21
15373  ELSEIF (mjoin.EQ.1) THEN
15374 C...Tentative joining accept/reject.
15375  wtran=pyr(0)*wtjoin
15376  mj=0
15377  250 mj=mj+1
15378  wtran=wtran-wtapj(mj)*wtpdfj(mj)
15379  IF(mj.LE.mint(31)-1.AND.wtran.GT.0d0) goto 250
15380  IF(mjoind(js,mj).NE.0.OR.mjoind(js,mi).NE.0) THEN
15381  CALL pyerrm(9,'(PYPTIS:) Attempted double joining.'//
15382  & ' Rejected.')
15383  goto 230
15384  ENDIF
15385 C...x*pdf (+ sea/val) at new pT2 for parton B.
15386  IF (ksvcb.LE.0) THEN
15387  mint(30)=js
15388  CALL pypdfu(kfbeam(js),xb,pt2,xfb)
15389  IF (kflba.LE.6) xfb(kflb)=xpsvc(kflb,ksvcb)
15390  ELSE
15391 C...Companion distributions do not evolve.
15392  xfb(kflb)=xfbo
15393  ENDIF
15394  wtveto=1d0/wtpdfj(mj)/xfb(kflb)
15395  kflc=k(imi(js,mj,1),2)
15396  kflca=iabs(kflc)
15397  ksvcc=max(-1,imi(js,mj,2))
15398  IF (ksvcb.GE.1) ksvcc=-1
15399 C...x*pdf (+ sea/val) at new pT2 for parton C.
15400  mint(30)=js
15401  mint(36)=mj
15402  CALL pypdfu(kfbeam(js),x1(mj),pt2,xfj)
15403  mint(36)=mi
15404  IF (kflca.LE.6.AND.ksvcc.LE.0) xfj(kflc)=xpsvc(kflc,ksvcc)
15405  wtveto=wtveto/xfj(kflc)
15406 C...x and x*pdf (+ sea/val) at new pT2 for parton A.
15407  kfla=21
15408  ksvca=0
15409  IF (kflca.EQ.21.AND.kflba.LE.5) THEN
15410  kfla=kflb
15411  ksvca=ksvcb
15412  ELSEIF (kflba.EQ.21.AND.kflca.LE.5) THEN
15413  kfla=kflc
15414  ksvca=ksvcc
15415  ENDIF
15416  IF (ksvca.LE.0) THEN
15417  mint(30)=js
15418  IF (kflb.EQ.21) mint(36)=mj
15419  CALL pypdfu(kfbeam(js),y(mj),pt2,xfj)
15420  mint(36)=mi
15421  IF (iabs(kfla).LE.6) xfj(kfla)=xpsvc(kfla,ksvca)
15422  ELSE
15423  xfj(kfla)=pyfcmp(y(mj)/vint(140),ys/vint(140),mstp(87))
15424  ENDIF
15425  wtveto=wtveto*xfj(kfla)
15426 C...Monte Carlo veto.
15427  IF (wtveto.LT.pyr(0)) goto 200
15428 C...If accept, save PT2 of this joining.
15429  IF (pt2.GT.pt2mx) THEN
15430  pt2mx=pt2
15431  jsmx=2+js
15432  mjn1mx=mj
15433  mjn2mx=mi
15434  wtapj(mj)=0d0
15435  njn=0
15436  ENDIF
15437 C...Exit and continue evolution.
15438  goto 390
15439  ENDIF
15440  kflaa=iabs(kfla)
15441 
15442 C...Choose z value (still in overestimated range) and corrective weight.
15443 C...Unphysical z will be rejected below when Q2 has is computed.
15444  wtz=0d0
15445 
15446 C...Note: ME and MQ>0 give corrections to overall weights, not shapes.
15447 C...q -> q + g or q -> q + gamma (already set which).
15448  IF (kflaa.LE.5.AND.kflba.LE.5) THEN
15449  IF (ksvcb.LT.0) THEN
15450  z=1d0-(1d0-zmin)*((1d0-zmax)/(1d0-zmin))**pyr(0)
15451  ELSE
15452  zfac=rmin*(rmax/rmin)**pyr(0)
15453  z=((1-zfac)/(1+zfac))**2
15454  ENDIF
15455  wtz=0.5d0*(1d0+z**2)
15456 C...Massive weight correction.
15457  IF (kflba.GE.4) wtz=wtz-z*(1d0-z)**2*rmq2/pt2
15458 C...Valence quark weight correction (extra sqrt)
15459  IF (ksvcb.GE.0) wtz=wtz*sqrt(z)
15460 
15461 C...q -> g + q.
15462 C...NB: MQ>0 not yet implemented. Forced absent above.
15463  ELSEIF (kflaa.LE.5.AND.kflb.EQ.21) THEN
15464  kflc=kfla
15465  z=zmax/(1d0+pyr(0)*(sqrt(zmax/zmin)-1d0))**2
15466  wtz=0.5d0*(1d0+(1d0-z)**2)*sqrt(z)
15467 
15468 C...g -> q + qbar.
15469  ELSEIF (kfla.EQ.21.AND.kflba.LE.5) THEN
15470  kflc=-kflb
15471  z=zmin+pyr(0)*(zmax-zmin)
15472  wtz=z**2+(1d0-z)**2
15473 C...Massive correction
15474  IF (mqmass.NE.0) THEN
15475  wtz=wtz+2d0*z*(1d0-z)*rmq2/pt2
15476 C...Extra safety margin for light sea quark creation
15477  ELSEIF (ksvcb.LT.0) THEN
15478  wtz=wtz/1.25d0
15479  ENDIF
15480 
15481 C...g -> g + g.
15482  ELSEIF (kfla.EQ.21.AND.kflb.EQ.21) THEN
15483  kflc=21
15484  z=1d0/(1d0+((1d0-zmin)/zmin)*((1d0-zmax)*zmin/
15485  & (zmax*(1d0-zmin)))**pyr(0))
15486  wtz=(1d0-z*(1d0-z))**2
15487  ENDIF
15488 
15489 C...Derive Q2 from pT2.
15490  q2b=pt2/(1d0-z)
15491  IF (kflba.GE.4) q2b=q2b-rmq2
15492 
15493 C...Loopback if outside allowed z range for given pT2.
15494  rm2c=pymass(kflc)**2
15495  pt2adj=q2b-z*(shtnow(mi)+q2b)*(q2b+rm2c)/shtnow(mi)
15496  IF (pt2adj.LT.1d-6) goto 230
15497 
15498 C...Size of phase space and coherence suppression: MSTP(67) and MSTP(62)
15499 C...No modification for very first emission if using ME correction
15500  mstp67 = mstp(67)
15501  IF (mecor.GE.1.AND.nisgen(1,mi).EQ.0.AND.nisgen(2,mi).EQ.0) THEN
15502  mstp67 = 0
15503  ENDIF
15504 
15505 C...For 1st branching, limit phase space by s-hat with color-partner
15506  IF (mstp67.GE.1.AND.nisgen(js,mi).EQ.0) THEN
15507  mside=1
15508  idip=imi(js,mi,1)
15509 C...Use anticolor tag for antiquark, or for gluon half the time
15510  IF ((kflb.LT.0.AND.kflba.LT.10).OR.(
15511  & kflb.EQ.21.AND.pyr(0).GT.0.5)) mside=2
15512 C...Tag
15513  mctag=mct(idip,mside)
15514 C...Default is to set up phase space using the opposite incoming parton
15515  jdip=imi(3-js,mi,1)
15516  ndip=0
15517 C...Alternatively, look for final-state color partner (pick first if several)
15518  DO 260 ifs=1,npart
15519  IF (mct(ipart(ifs),mside).EQ.mctag.AND.ndip.EQ.0) THEN
15520  jdip=ipart(ifs)
15521  ndip=ndip+1
15522  ENDIF
15523  260 CONTINUE
15524 C...Compute momentum transfer: sdip = -t = - (p1 - p2)^2
15525 C...(also works for annihilation since incoming massless, so shat = -(p1 - p2)^2)
15526  sdip=abs(((p(idip,4)-p(jdip,4))**2-(p(idip,3)-p(jdip,3))**2
15527  & -(p(idip,2)-p(jdip,2))**2-(p(idip,1)-p(jdip,1))**2))
15528  IF (mstp67.EQ.1) THEN
15529 C...1 Option to completely kill radiation above s_dip * PARP(67)
15530  IF (4d0*pt2.GT.parp(67)*sdip) goto 230
15531  ELSE IF (mstp67.EQ.2) THEN
15532 C...2 Option to allow suppressed unordered radiation above s_dip * PARP(67)
15533 C... (-> improved power showers?)
15534  IF (4d0*pt2*pyr(0).GT.parp(67)*sdip) goto 230
15535  ENDIF
15536 
15537 C...For subsequent branchings, loopback if nonordered in angle/rapidity
15538  ELSE IF (mstp(62).GE.3.AND.nisgen(js,mi).GE.1) THEN
15539  IF(pt2.GT.((1d0-z)/(z*(1d0-zsav(js,mi))))**2*pt2sav(js,mi))
15540  & goto 230
15541  ENDIF
15542 
15543 C...Select phi angle of branching at random.
15544  phi=paru(2)*pyr(0)
15545 
15546 C...Matrix-element corrections for some processes.
15547  IF (mecor.GE.1.AND.nisgen(js,mi).EQ.0) THEN
15548  IF (kflaa.LE.20.AND.kflba.LE.20) THEN
15549  CALL pymewt(mecor,1,q2b*shat/shtnow(mi),z,phi,wtme)
15550  wtz=wtz*wtme/wtff
15551  ELSEIF((kfla.EQ.21.OR.kfla.EQ.22).AND.kflba.LE.20) THEN
15552  CALL pymewt(mecor,2,q2b*shat/shtnow(mi),z,phi,wtme)
15553  wtz=wtz*wtme/wtgf
15554  ELSEIF(kflaa.LE.20.AND.(kflb.EQ.21.OR.kflb.EQ.22)) THEN
15555  CALL pymewt(mecor,3,q2b*shat/shtnow(mi),z,phi,wtme)
15556  wtz=wtz*wtme/wtfg
15557  ELSEIF(kfla.EQ.21.AND.kflb.EQ.21) THEN
15558  CALL pymewt(mecor,4,q2b*shat/shtnow(mi),z,phi,wtme)
15559  wtz=wtz*wtme/wtgg
15560  ENDIF
15561  ENDIF
15562 
15563 C...Parton distributions at new pT2 but old x.
15564  mint(30)=js
15565  CALL pypdfu(kfbeam(js),xb,pt2,xfn)
15566 C...Treat val and cmp separately
15567  IF (kflba.LE.6.AND.ksvcb.LE.0) xfn(kflb)=xpsvc(kflb,ksvcb)
15568  IF (ksvcb.GE.1)
15569  & xfn(kflb)=pyfcmp(yb/vint(140),ys/vint(140),mstp(87))
15570  xfbn=xfn(kflb)
15571  IF(xfbn.LT.1d-20) THEN
15572  IF(kfla.EQ.kflb) THEN
15573  wtap(kflb)=0d0
15574  goto 200
15575  ELSE
15576  xfbn=1d-10
15577  xfn(kflb)=xfbn
15578  ENDIF
15579  ENDIF
15580  DO 270 kfl=-5,5
15581  xfb(kfl)=xfn(kfl)
15582  270 CONTINUE
15583  xfb(21)=xfn(21)
15584 
15585 C...Parton distributions at new pT2 and new x.
15586  xa=xb/z
15587  mint(30)=js
15588  CALL pypdfu(kfbeam(js),xa,pt2,xfa)
15589  IF (kflba.LE.5.AND.kflaa.LE.5) THEN
15590 C...q -> q + g: only consider respective sea, val, or cmp content.
15591  IF (ksvcb.LE.0) THEN
15592  xfa(kfla)=xpsvc(kfla,ksvcb)
15593  ELSE
15594  ya=xa*(1d0-ys)
15595  xfa(kflb)=pyfcmp(ya/vint(140),ys/vint(140),mstp(87))
15596  ENDIF
15597  ENDIF
15598  xfan=xfa(kfla)
15599  IF(xfan.LT.1d-20) THEN
15600  goto 200
15601  ENDIF
15602 
15603 C...If weighting fails continue evolution.
15604  wttot=0d0
15605  IF (mcrqq.EQ.0) THEN
15606  wtpdfa=1d0/wtpdf(kfla)
15607  wttot=wtz*xfan/xfbn*wtpdfa
15608  ELSEIF(mcrqq.EQ.1) THEN
15609  wtpdfa=tpm/wpdf0
15610  wttot=wtcrqq*wtz*xfan/xfbn*wtpdfa
15611  xbest=tpm/tpm0*xq0
15612  ELSEIF(mcrqq.EQ.2) THEN
15613 C...Force massive quark creation.
15614  wttot=1d0
15615  ENDIF
15616 
15617 C...Loop back if trial emission fails.
15618  IF(wttot.GE.0d0.AND.wttot.LT.pyr(0)) goto 200
15619  wtacc=((1d0+pt2)/(0.25d0+pt2))**2
15620  IF(wttot.LT.0d0) THEN
15621  WRITE(chwt,'(1P,E12.4)') wttot
15622  CALL pyerrm(19,'(PYPTIS:) Weight '//chwt//' negative')
15623  ELSEIF(wttot.GT.wtacc) THEN
15624  WRITE(chwt,'(1P,E12.4)') wttot
15625  IF (pt2.GT.ptemax.OR.wttot.GE.wtemax) THEN
15626 C...Too high weight: write out as error, but do not update error counter
15627  IF(mstu(29).EQ.0) mstu(23)=mstu(23)-1
15628  CALL pyerrm(19,
15629  & '(PYPTIS:) Weight '//chwt//' above unity')
15630  IF (pt2.GT.ptemax) ptemax=pt2
15631  IF (wttot.GT.wtemax) wtemax=wttot
15632  ELSE
15633  CALL pyerrm(9,
15634  & '(PYPTIS:) Weight '//chwt//' above unity')
15635  ENDIF
15636 C...Useful for debugging but commented out for distribution:
15637 C print*, 'JS, MI',JS, MI
15638 C print*, 'PT:',SQRT(PT2), ' MCRQQ',MCRQQ
15639 C print*, 'A -> B C',KFLA, KFLB, KFLC
15640 C XFAO=XFBO/WTPDFA
15641 C print*, 'WT(Z,XFA,XFB)',WTZ, XFAN/XFAO, XFBO/XFBN
15642  ENDIF
15643 
15644 C...Special for PT2 = PT2MX (e.g., if two incoming massive quarks
15645 C...simultaneously reached their creation thresholds)
15646  IF (abs(pt2-pt2mx).LT.0.001) THEN
15647  IF (pyr(0).GT.0.5) pt2=1.0001*pt2mx
15648  ENDIF
15649 
15650 C...Save acceptable branching.
15651  IF(pt2.GT.pt2mx) THEN
15652  mimx=mint(36)
15653  jsmx=js
15654  pt2mx=pt2
15655  kflamx=kfla
15656  kflcmx=kflc
15657  rm2cmx=rm2c
15658  q2bmx=q2b
15659  zmx=z
15660  pt2amx=pt2adj
15661  phimx=phi
15662  ENDIF
15663 
15664 C----------------------------------------------------------------------
15665 C...MODE= 1: Accept stored shower branching. Update event record etc.
15666  ELSEIF (mode.EQ.1) THEN
15667  mi=mimx
15668  js=jsmx
15669  shat=shtnow(mi)
15670  side=3d0-2d0*js
15671 C...Shift down rest of event record to make room for insertion.
15672  it=imisep(mi)+1
15673  im=it+1
15674  is=imi(js,mi,1)
15675  DO 290 i=n,it,-1
15676  IF (k(i,3).GE.it) k(i,3)=k(i,3)+2
15677  kt1=k(i,4)/mstu(5)**2
15678  kt2=k(i,5)/mstu(5)**2
15679  id1=mod(k(i,4),mstu(5))
15680  id2=mod(k(i,5),mstu(5))
15681  im1=mod(k(i,4)/mstu(5),mstu(5))
15682  im2=mod(k(i,5)/mstu(5),mstu(5))
15683  IF (id1.GE.it) id1=id1+2
15684  IF (id2.GE.it) id2=id2+2
15685  IF (im1.GE.it) im1=im1+2
15686  IF (im2.GE.it) im2=im2+2
15687  k(i,4)=kt1*mstu(5)**2+im1*mstu(5)+id1
15688  k(i,5)=kt2*mstu(5)**2+im2*mstu(5)+id2
15689  DO 280 ix=1,5
15690  k(i+2,ix)=k(i,ix)
15691  p(i+2,ix)=p(i,ix)
15692  v(i+2,ix)=v(i,ix)
15693  280 CONTINUE
15694  mct(i+2,1)=mct(i,1)
15695  mct(i+2,2)=mct(i,2)
15696  290 CONTINUE
15697  n=n+2
15698 C...Also update shifted-down pointers in IMI, IMISEP, and IPART.
15699  DO 300 ji=1,mint(31)
15700  IF (imi(1,ji,1).GE.it) imi(1,ji,1)=imi(1,ji,1)+2
15701  IF (imi(1,ji,2).GE.it) imi(1,ji,2)=imi(1,ji,2)+2
15702  IF (imi(2,ji,1).GE.it) imi(2,ji,1)=imi(2,ji,1)+2
15703  IF (imi(2,ji,2).GE.it) imi(2,ji,2)=imi(2,ji,2)+2
15704  IF (ji.GE.mi) imisep(ji)=imisep(ji)+2
15705 C...Also update companion pointers to the present mother.
15706  IF (imi(js,ji,2).EQ.is) imi(js,ji,2)=im
15707  300 CONTINUE
15708  DO 310 ifs=1,npart
15709  IF (ipart(ifs).GE.it) ipart(ifs)=ipart(ifs)+2
15710  310 CONTINUE
15711 C...Zero entries dedicated for new timelike and mother partons.
15712  DO 330 i=it,it+1
15713  DO 320 j=1,5
15714  k(i,j)=0
15715  p(i,j)=0d0
15716  v(i,j)=0d0
15717  320 CONTINUE
15718  mct(i,1)=0
15719  mct(i,2)=0
15720  330 CONTINUE
15721 
15722 C...Define timelike and new mother partons. History.
15723  k(it,1)=3
15724  k(it,2)=kflcmx
15725  k(im,1)=14
15726  k(im,2)=kflamx
15727  k(is,3)=im
15728  k(it,3)=im
15729 C...Set mother origin = side.
15730  k(im,3)=mint(83)+js+2
15731  IF(mi.GE.2) k(im,3)=mint(83)+js
15732 
15733 C...Define colour flow of branching.
15734  im1=im
15735  im2=im
15736 C...q -> q + gamma.
15737  IF(k(it,2).EQ.22) THEN
15738  k(it,1)=1
15739  id1=is
15740  id2=is
15741 C...q -> q + g.
15742  ELSEIF(k(im,2).GT.0.AND.k(im,2).LE.5.AND.k(it,2).EQ.21) THEN
15743  id1=it
15744  id2=is
15745 C...q -> g + q.
15746  ELSEIF(k(im,2).GT.0.AND.k(im,2).LE.5) THEN
15747  id1=is
15748  id2=it
15749 C...qbar -> qbar + g.
15750  ELSEIF(k(im,2).LT.0.AND.k(im,2).GE.-5.AND.k(it,2).EQ.21) THEN
15751  id1=is
15752  id2=it
15753 C...qbar -> g + qbar.
15754  ELSEIF(k(im,2).LT.0.AND.k(im,2).GE.-5) THEN
15755  id1=it
15756  id2=is
15757 C...g -> g + g; g -> q + qbar..
15758  ELSEIF((k(it,2).EQ.21.AND.pyr(0).GT.0.5d0).OR.k(it,2).LT.0) THEN
15759  id1=is
15760  id2=it
15761  ELSE
15762  id1=it
15763  id2=is
15764  ENDIF
15765  IF(im1.EQ.im) k(im1,4)=k(im1,4)+id1
15766  IF(im2.EQ.im) k(im2,5)=k(im2,5)+id2
15767  k(id1,4)=k(id1,4)+mstu(5)*im1
15768  k(id2,5)=k(id2,5)+mstu(5)*im2
15769  IF(id1.NE.id2) THEN
15770  k(id1,5)=k(id1,5)+mstu(5)*id2
15771  k(id2,4)=k(id2,4)+mstu(5)*id1
15772  ENDIF
15773  IF(k(it,1).EQ.1) THEN
15774  k(it,4)=0
15775  k(it,5)=0
15776  ENDIF
15777 C...Update IMI and colour tag arrays.
15778  imi(js,mi,1)=im
15779  DO 340 mc=1,2
15780  mct(it,mc)=0
15781  mct(im,mc)=0
15782  340 CONTINUE
15783  DO 350 jcs=4,5
15784  kcs=jcs
15785 C...If mother flag not yet set for spacelike parton, trace it.
15786  IF (k(is,kcs)/mstu(5)**2.LE.1) CALL pycttr(is,-kcs,im)
15787  IF(mint(51).NE.0) RETURN
15788  350 CONTINUE
15789  DO 360 jcs=4,5
15790  kcs=jcs
15791 C...If mother flag not yet set for timelike parton, trace it.
15792  IF (k(it,kcs)/mstu(5)**2.LE.1) CALL pycttr(it,kcs,im)
15793  IF(mint(51).NE.0) RETURN
15794  360 CONTINUE
15795 
15796 C...Boost recoiling parton to compensate for Q2 scale.
15797  betaz=side*(1d0-(1d0+q2bmx/shat)**2)/
15798  & (1d0+(1d0+q2bmx/shat)**2)
15799  ir=imi(3-js,mi,1)
15800  CALL pyrobo(ir,ir,0d0,0d0,0d0,0d0,betaz)
15801 
15802 C...Define system to be rotated and boosted
15803 C...(not including the 2 just added partons)
15804 C...(but including the docu lines for first interaction)
15805  imin=imisep(mi-1)+1
15806  IF (mi.EQ.1) imin=mint(83)+5
15807  imax=imisep(mi)-2
15808 
15809 C...Rotate back system in phi to compensate for subsequent rotation.
15810  CALL pyrobo(imin,imax,0d0,-phimx,0d0,0d0,0d0)
15811 
15812 C...Define kinematics of new partons in old frame.
15813  imax=imisep(mi)
15814  p(im,1)=sqrt(pt2amx)*shat/(zmx*(shat+q2bmx))
15815  p(im,3)=0.5d0*sqrt(shat)*((shat-q2bmx)/((shat
15816  & +q2bmx)*zmx)+(q2bmx+rm2cmx)/shat)*side
15817  p(im,4)=sqrt(p(im,1)**2+p(im,3)**2)
15818  p(it,1)=p(im,1)
15819  p(it,3)=p(im,3)-0.5d0*(shat+q2bmx)/sqrt(shat)*side
15820  p(it,4)=sqrt(p(it,1)**2+p(it,3)**2+rm2cmx)
15821  p(it,5)=sqrt(rm2cmx)
15822 
15823 C...Update internal line, now spacelike
15824  p(is,1)=p(im,1)-p(it,1)
15825  p(is,2)=p(im,2)-p(it,2)
15826  p(is,3)=p(im,3)-p(it,3)
15827  p(is,4)=p(im,4)-p(it,4)
15828  p(is,5)=p(is,4)**2-p(is,1)**2-p(is,2)**2-p(is,3)**2
15829 C...Represent spacelike virtualities as -sqrt(abs(Q2)) .
15830  IF (p(is,5).LT.0d0) THEN
15831  p(is,5)=-sqrt(abs(p(is,5)))
15832  ELSE
15833  p(is,5)=sqrt(p(is,5))
15834  ENDIF
15835 
15836 C...Boost entire system and rotate to new frame.
15837 C...(including docu lines)
15838  betax=(p(im,1)+p(ir,1))/(p(im,4)+p(ir,4))
15839  betaz=(p(im,3)+p(ir,3))/(p(im,4)+p(ir,4))
15840  IF(betax**2+betaz**2.GE.1d0) THEN
15841  CALL pyerrm(1,'(PYPTIS:) boost bigger than unity')
15842  mint(51)=1
15843  ifail=-1
15844  RETURN
15845  ENDIF
15846  CALL pyrobo(imin,imax,0d0,0d0,-betax,0d0,-betaz)
15847  i1=imi(1,mi,1)
15848  theta=pyangl(p(i1,3),p(i1,1))
15849  CALL pyrobo(imin,imax,-theta,phimx,0d0,0d0,0d0)
15850 
15851 C...Global statistics.
15852  mint(352)=mint(352)+1
15853  vint(352)=vint(352)+sqrt(p(it,1)**2+p(it,2)**2)
15854  IF (mint(352).EQ.1) vint(357)=sqrt(p(it,1)**2+p(it,2)**2)
15855 
15856 C...Add parton with relevant pT scale for timelike shower.
15857  IF (k(it,2).NE.22) THEN
15858  npart=npart+1
15859  ipart(npart)=it
15860  ptpart(npart)=sqrt(pt2amx)
15861  ENDIF
15862 
15863 C...Update saved variables.
15864  shtnow(mimx)=shtnow(mimx)/zmx
15865  nisgen(jsmx,mimx)=nisgen(jsmx,mimx)+1
15866  xmi(jsmx,mimx)=xmi(jsmx,mimx)/zmx
15867  pt2sav(jsmx,mimx)=pt2mx
15868  zsav(js,mimx)=zmx
15869 
15870  ksa=iabs(k(is,2))
15871  kma=iabs(k(im,2))
15872  IF (ksa.EQ.21.AND.kma.GE.1.AND.kma.LE.5) THEN
15873 C...Gluon reconstructs to quark.
15874 C...Decide whether newly created quark is valence or sea:
15875  mint(30)=js
15876  CALL pyptmi(2,pt2now,ptdum1,ptdum2,ifail)
15877  IF(mint(51).NE.0) RETURN
15878  ENDIF
15879  IF(ksa.GE.1.AND.ksa.LE.5.AND.kma.EQ.21) THEN
15880 C...Quark reconstructs to gluon.
15881 C...Now some guy may have lost his companion. Check.
15882  icmp=imi(js,mi,2)
15883  IF (icmp.GT.0) THEN
15884  CALL pyerrm(9,'(PYPTIS:) Sorry, companion quark radiated'
15885  & //' away. Cannot handle that yet. Giving up.')
15886  mint(51)=1
15887  RETURN
15888  ELSEIF(icmp.LT.0) THEN
15889 C...A sea quark with companion still in BR was reconstructed to a gluon.
15890 C...Companion should now be removed from the beam remnant.
15891 C...(Momentum integral is automatically updated in next call to PYPDFU.)
15892  icmp=-icmp
15893  ifl=-k(is,2)
15894  DO 380 jcmp=icmp,nvc(js,ifl)-1
15895  xassoc(js,ifl,jcmp)=xassoc(js,ifl,jcmp+1)
15896  DO 370 ji=1,mint(31)
15897  kmi=-imi(js,ji,2)
15898  jfl=-k(imi(js,ji,1),2)
15899  IF (kmi.EQ.jcmp+1.AND.jfl.EQ.ifl) imi(js,ji,2)=imi(js,ji
15900  & ,2)+1
15901  370 CONTINUE
15902  380 CONTINUE
15903  nvc(js,ifl)=nvc(js,ifl)-1
15904  ENDIF
15905 C...Set gluon IMI(JS,MI,2) = 0.
15906  imi(js,mi,2)=0
15907  ELSEIF(ksa.GE.1.AND.ksa.LE.5.AND.kma.NE.21) THEN
15908 C...Quark reconstructing to quark. If sea with companion still in BR
15909 C...then update associated x value.
15910 C...(Momentum integral is automatically updated in next call to PYPDFU.)
15911  IF (imi(js,mi,2).LT.0) THEN
15912  icmp=-imi(js,mi,2)
15913  ifl=-k(is,2)
15914  xassoc(js,ifl,icmp)=xmi(jsmx,mimx)
15915  ENDIF
15916  ENDIF
15917 
15918  ENDIF
15919 
15920 C...If reached this point, normal exit.
15921  390 ifail=0
15922 
15923  RETURN
15924  END
15925 
15926 C*********************************************************************
15927 
15928 C...PYMEMX
15929 C...Generates maximum ME weight in some initial-state showers.
15930 C...Inparameter MECOR: kind of hard scattering process
15931 C...Outparameter WTFF: maximum weight for fermion -> fermion
15932 C... WTGF: maximum weight for gluon/photon -> fermion
15933 C... WTFG: maximum weight for fermion -> gluon/photon
15934 C... WTGG: maximum weight for gluon -> gluon
15935 
15936  SUBROUTINE pymemx(MECOR,WTFF,WTGF,WTFG,WTGG)
15937 
15938 C...Double precision and integer declarations.
15939  IMPLICIT DOUBLE PRECISION(a-h, o-z)
15940  IMPLICIT INTEGER(i-n)
15941  INTEGER pyk,pychge,pycomp
15942 C...Commonblocks.
15943  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
15944  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
15945  common/pypars/mstp(200),parp(200),msti(200),pari(200)
15946  common/pyint1/mint(400),vint(400)
15947  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
15948  SAVE /pyjets/,/pydat1/,/pypars/,/pyint1/,/pyint2/
15949 
15950 C...Default maximum weight.
15951  wtff=1d0
15952  wtgf=1d0
15953  wtfg=1d0
15954  wtgg=1d0
15955 
15956 C...Select maximum weight by process.
15957  IF(mecor.EQ.1) THEN
15958  wtff=1d0
15959  wtgf=3d0
15960  ELSEIF(mecor.EQ.2) THEN
15961  wtfg=1d0
15962  wtgg=1d0
15963  ENDIF
15964 
15965  RETURN
15966  END
15967 
15968 C*********************************************************************
15969 
15970 C...PYMEWT
15971 C...Calculates actual ME weight in some initial-state showers.
15972 C...Inparameter MECOR: kind of hard scattering process
15973 C... IFLCB: flavour combination of branching,
15974 C... 1 for fermion -> fermion,
15975 C... 2 for gluon/photon -> fermion
15976 C... 3 for fermion -> gluon/photon,
15977 C... 4 for gluon -> gluon
15978 C... Q2: Q2 value of shower branching
15979 C... Z: Z value of branching
15980 C...In+outparameter PHIBR: azimuthal angle of branching
15981 C...Outparameter WTME: actual ME weight
15982 
15983  SUBROUTINE pymewt(MECOR,IFLCB,Q2,Z,PHIBR,WTME)
15984 
15985 C...Double precision and integer declarations.
15986  IMPLICIT DOUBLE PRECISION(a-h, o-z)
15987  IMPLICIT INTEGER(i-n)
15988  INTEGER pyk,pychge,pycomp
15989 C...Commonblocks.
15990  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
15991  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
15992  common/pypars/mstp(200),parp(200),msti(200),pari(200)
15993  common/pyint1/mint(400),vint(400)
15994  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
15995  SAVE /pyjets/,/pydat1/,/pypars/,/pyint1/,/pyint2/
15996 
15997 C...Default output.
15998  wtme=1d0
15999 
16000 C...Define kinematics of shower branching in Mandelstam variables.
16001  sqm=vint(44)
16002  sh=sqm/z
16003  th=-q2
16004  uh=q2-sqm*(1d0-z)/z
16005 
16006 C...Matrix-element corrections for f + fbar -> s-channel vector boson.
16007  IF(mecor.EQ.1) THEN
16008  IF(iflcb.EQ.1) THEN
16009  wtme=(th**2+uh**2+2d0*sqm*sh)/(sh**2+sqm**2)
16010  ELSEIF(iflcb.EQ.2) THEN
16011  wtme=(sh**2+th**2+2d0*sqm*uh)/((sh-sqm)**2+sqm**2)
16012  ENDIF
16013 
16014 C...Matrix-element corrections for g + g -> Higgs (h0, H0, A0).
16015  ELSEIF(mecor.EQ.2) THEN
16016  IF(iflcb.EQ.3) THEN
16017  wtme=(sh**2+uh**2)/(sh**2+(sh-sqm)**2)
16018  ELSEIF(iflcb.EQ.4) THEN
16019  wtme=0.5d0*(sh**4+uh**4+th**4+sqm**4)/(sh**2-sqm*(sh-sqm))**2
16020  ENDIF
16021 
16022 C...Matrix-element corrections for q + qbar -> Higgs (h0)
16023  ELSEIF(mecor.EQ.3) THEN
16024  IF(iflcb.EQ.2) THEN
16025  wtme=(sh**2+th**2+2d0*(sqm-th)*(sqm-sh))/
16026  1 (sh**2+2d0*sqm*(sqm-sh))
16027  ENDIF
16028  ENDIF
16029 
16030  RETURN
16031  END
16032 
16033 C*********************************************************************
16034 
16035 C...PYPTMI
16036 C...Handles the generation of additional interactions in the new
16037 C...multiple interactions framework.
16038 C...MODE=-1 : Initalize MI from scratch.
16039 C...MODE= 0 : Generate trial interaction. Start at PT2NOW, solve
16040 C... Sudakov for PT2, abort if below PT2CUT.
16041 C...MODE= 1 : Accept interaction at PT2NOW and store variables.
16042 C...MODE= 2 : Decide sea/val/cmp for kicked-out quark at PT2NOW
16043 C...PT2NOW : Starting (max) PT2 scale for evolution.
16044 C...PT2CUT : Lower limit for evolution.
16045 C...PT2 : Result of evolution. Generated PT2 for trial interaction.
16046 C...IFAIL : Status return code.
16047 C... = 0: All is well.
16048 C... < 0: Phase space exhausted, generation to be terminated.
16049 C... > 0: Additional interaction vetoed, but continue evolution.
16050 
16051  SUBROUTINE pyptmi(MODE,PT2NOW,PT2CUT,PT2,IFAIL)
16052 C...Double precision and integer declarations.
16053  IMPLICIT DOUBLE PRECISION(a-h, o-z)
16054  IMPLICIT INTEGER(i-n)
16055  INTEGER pyk,pychge,pycomp
16056 C...Parameter statement for maximum size of showers.
16057  parameter(maxnur=1000)
16058 C...Commonblocks.
16059  common/pypart/npart,npartd,ipart(maxnur),ptpart(maxnur)
16060  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
16061  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
16062  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
16063  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
16064  common/pypars/mstp(200),parp(200),msti(200),pari(200)
16065  common/pyint1/mint(400),vint(400)
16066  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
16067  common/pyint3/xsfx(2,-40:40),isig(1000,3),sigh(1000)
16068  common/pyint5/ngenpd,ngen(0:500,3),xsec(0:500,3)
16069  common/pyint7/sigt(0:6,0:6,0:5)
16070  common/pyintm/kfival(2,3),nmi(2),imi(2,800,2),nvc(2,-6:6),
16071  & xassoc(2,-6:6,240),xpsvc(-6:6,-1:240),pvctot(2,-1:1),
16072  & xmi(2,240),pt2mi(240),imisep(0:240)
16073  common/pyismx/mimx,jsmx,kflamx,kflcmx,kfbeam(2),nisgen(2,240),
16074  & pt2mx,pt2amx,zmx,rm2cmx,q2bmx,phimx
16075  common/pyctag/nct,mct(4000,2)
16076 C...Local arrays and saved variables.
16077  dimension wdtp(0:400),wdte(0:400,0:5),xpq(-25:25)
16078 
16079  SAVE /pypart/,/pyjets/,/pydat1/,/pydat2/,/pydat3/,/pypars/,
16080  & /pyint1/,/pyint2/,/pyint3/,/pyint5/,/pyint7/,/pyintm/,
16081  & /pyismx/,/pyctag/
16082  SAVE nchn,xt2fac,sigs
16083 
16084  ifail=0
16085 C...Set MI subprocess = QCD 2 -> 2.
16086  isub=96
16087 
16088 C----------------------------------------------------------------------
16089 C...MODE=-1: Initialize from scratch
16090  IF (mode.EQ.-1) THEN
16091 C...Initialize PT2 array.
16092  pt2mi(1)=vint(54)
16093 C...Initialize list of incoming beams and partons from two sides.
16094  DO 110 js=1,2
16095  DO 100 mi=1,240
16096  imi(js,mi,1)=0
16097  imi(js,mi,2)=0
16098  100 CONTINUE
16099  nmi(js)=1
16100  imi(js,1,1)=mint(84)+js
16101  imi(js,1,2)=0
16102  xmi(js,1)=vint(40+js)
16103 C...Rescale x values to fractions of photon energy.
16104  IF(mint(18+js).EQ.1) xmi(js,1)=vint(40+js)/vint(154+js)
16105 C...Hard reset: hard interaction initiators motherless by definition.
16106  k(mint(84)+js,3)=2+js
16107  k(mint(84)+js,4)=mod(k(mint(84)+js,4),mstu(5))
16108  k(mint(84)+js,5)=mod(k(mint(84)+js,5),mstu(5))
16109  110 CONTINUE
16110  imisep(0)=mint(84)
16111  imisep(1)=n
16112  IF (mod(mstp(81),10).GE.1) THEN
16113  IF(mstp(82).LE.1) THEN
16114  sigrat=xsec(isub,1)/max(1d-10,vint(315)*vint(316)*sigt(0,0
16115  & ,5))
16116  IF(mint(141).NE.0.OR.mint(142).NE.0) sigrat=sigrat*
16117  & vint(317)/(vint(318)*vint(320))
16118  xt2fac=sigrat*vint(149)/(1d0-vint(149))
16119  ELSE
16120  xt2fac=vint(146)*vint(148)*xsec(isub,1)/
16121  & max(1d-10,sigt(0,0,5))*vint(149)*(1d0+vint(149))
16122  ENDIF
16123  ENDIF
16124 C...Zero entries relating to scatterings beyond the first.
16125  DO 120 mi=2,240
16126  imi(1,mi,1)=0
16127  imi(2,mi,1)=0
16128  imi(1,mi,2)=0
16129  imi(2,mi,2)=0
16130  imisep(mi)=imisep(1)
16131  pt2mi(mi)=0d0
16132  xmi(1,mi)=0d0
16133  xmi(2,mi)=0d0
16134  120 CONTINUE
16135 C...Initialize factors for PDF reshaping.
16136  DO 140 js=1,2
16137  kfbeam(js)=mint(10+js)
16138  IF(mint(18+js).EQ.1) kfbeam(js)=22
16139  kfabm=iabs(kfbeam(js))
16140  kfsbm=isign(1,kfbeam(js))
16141 
16142 C...Zero flavour content of incoming beam particle.
16143  kfival(js,1)=0
16144  kfival(js,2)=0
16145  kfival(js,3)=0
16146 C... Flavour content of baryon.
16147  IF(kfabm.GT.1000) THEN
16148  kfival(js,1)=kfsbm*mod(kfabm/1000,10)
16149  kfival(js,2)=kfsbm*mod(kfabm/100,10)
16150  kfival(js,3)=kfsbm*mod(kfabm/10,10)
16151 C... Flavour content of pi+-, K+-.
16152  ELSEIF(kfabm.EQ.211) THEN
16153  kfival(js,1)=kfsbm*2
16154  kfival(js,2)=-kfsbm
16155  ELSEIF(kfabm.EQ.321) THEN
16156  kfival(js,1)=-kfsbm*3
16157  kfival(js,2)=kfsbm*2
16158 C... Flavour content of pi0, gamma, K0S, K0L not defined yet.
16159  ENDIF
16160 
16161 C...Zero initial valence and companion content.
16162  DO 130 ifl=-6,6
16163  nvc(js,ifl)=0
16164  130 CONTINUE
16165  140 CONTINUE
16166 C...Set up colour line tags starting from hard interaction initiators.
16167  nct=0
16168 C...Reset colour tag array and colour processing flags.
16169  DO 150 i=imisep(0)+1,n
16170  mct(i,1)=0
16171  mct(i,2)=0
16172  k(i,4)=mod(k(i,4),mstu(5)**2)
16173  k(i,5)=mod(k(i,5),mstu(5)**2)
16174  150 CONTINUE
16175 C... Consider each side in turn.
16176  DO 170 js=1,2
16177  i1=imi(js,1,1)
16178  i2=imi(3-js,1,1)
16179  DO 160 jcs=4,5
16180  IF (k(i1,2).NE.21.AND.(9-2*jcs).NE.isign(1,k(i1,2)))
16181  & goto 160
16182  IF (k(i1,jcs)/mstu(5)**2.NE.0) goto 160
16183  kcs=jcs
16184  CALL pycttr(i1,kcs,i2)
16185  IF(mint(51).NE.0) RETURN
16186  160 CONTINUE
16187  170 CONTINUE
16188 
16189 C...Range checking for companion quark pdf large-x param.
16190  IF (mstp(87).LT.0) THEN
16191  CALL pyerrm(19,'(PYPTMI:) MSTP(87) out of range. Forced'//
16192  & ' MSTP(87)=0')
16193  mstp(87)=0
16194  ELSEIF (mstp(87).GT.4) THEN
16195  CALL pyerrm(19,'(PYPTMI:) MSTP(87) out of range. Forced'//
16196  & ' MSTP(87)=4')
16197  mstp(87)=4
16198  ENDIF
16199 
16200 C----------------------------------------------------------------------
16201 C...MODE=0: Generate trial interaction. Return codes:
16202 C...IFAIL < 0: Phase space exhausted, generation to be terminated.
16203 C...IFAIL = 0: Additional interaction generated at PT2.
16204 C...IFAIL > 0: Additional interaction vetoed, but continue evolution.
16205  ELSEIF (mode.EQ.0) THEN
16206 C...Abolute MI max scale = VINT(62)
16207  xt2=4d0*min(pt2now,vint(62))/vint(2)
16208  180 IF(mstp(82).LE.1) THEN
16209  xt2=xt2fac*xt2/(xt2fac-xt2*log(pyr(0)))
16210  IF(xt2.LT.vint(149)) ifail=-2
16211  ELSE
16212  IF(xt2.LE.0.01001d0*vint(149)) THEN
16213  ifail=-3
16214  ELSE
16215  xt2=xt2fac*(xt2+vint(149))/(xt2fac-(xt2+vint(149))*
16216  & log(pyr(0)))-vint(149)
16217  ENDIF
16218  ENDIF
16219 C...Also exit if below lower limit or if higher trial branching
16220 C...already found.
16221  pt2=0.25d0*vint(2)*xt2
16222  IF (pt2.LE.pt2cut) ifail=-4
16223  IF (pt2.LE.pt2mx) ifail=-5
16224  IF (ifail.NE.0) THEN
16225  pt2=0d0
16226  RETURN
16227  ENDIF
16228  IF(mstp(82).GE.2) pt2=max(0.25d0*vint(2)*0.01d0*vint(149),pt2)
16229  vint(25)=4d0*pt2/vint(2)
16230  xt2=vint(25)
16231 
16232 C...Choose tau and y*. Calculate cos(theta-hat).
16233  IF(pyr(0).LE.coef(isub,1)) THEN
16234  taut=(2d0*(1d0+sqrt(1d0-xt2))/xt2-1d0)**pyr(0)
16235  tau=xt2*(1d0+taut)**2/(4d0*taut)
16236  ELSE
16237  tau=xt2*(1d0+tan(pyr(0)*atan(sqrt(1d0/xt2-1d0)))**2)
16238  ENDIF
16239  vint(21)=tau
16240 C...New: require shat > 1.
16241  IF(tau*vint(2).LT.1d0) goto 180
16242  CALL pyklim(2)
16243  ryst=pyr(0)
16244  myst=1
16245  IF(ryst.GT.coef(isub,8)) myst=2
16246  IF(ryst.GT.coef(isub,8)+coef(isub,9)) myst=3
16247  CALL pykmap(2,myst,pyr(0))
16248  vint(23)=sqrt(max(0d0,1d0-xt2/tau))*(-1)**int(1.5d0+pyr(0))
16249 
16250 C...Check that x not used up. Accept or reject kinematical variables.
16251  x1m=sqrt(tau)*exp(vint(22))
16252  x2m=sqrt(tau)*exp(-vint(22))
16253  IF(vint(143)-x1m.LT.0.01d0.OR.vint(144)-x2m.LT.0.01d0) goto 180
16254  vint(71)=0.5d0*vint(1)*sqrt(xt2)
16255  nchn=0
16256  CALL pysigh(nchn,sigs)
16257  IF(mint(141).NE.0.OR.mint(142).NE.0) sigs=sigs*vint(320)
16258  IF(sigs.LT.xsec(isub,1)*pyr(0)) goto 180
16259  IF(mint(141).NE.0.OR.mint(142).NE.0) sigs=sigs/vint(320)
16260 
16261 C...Save if highest PT so far.
16262  IF (pt2.GT.pt2mx) THEN
16263  jsmx=0
16264  mimx=mint(31)+1
16265  pt2mx=pt2
16266  ENDIF
16267 
16268 C----------------------------------------------------------------------
16269 C...MODE=1: Generate and save accepted scattering.
16270  ELSEIF (mode.EQ.1) THEN
16271  pt2=pt2now
16272 C...Reset K, P, V, and MCT vectors.
16273  DO 200 i=n+1,n+4
16274  DO 190 j=1,5
16275  k(i,j)=0
16276  p(i,j)=0d0
16277  v(i,j)=0d0
16278  190 CONTINUE
16279  mct(i,1)=0
16280  mct(i,2)=0
16281  200 CONTINUE
16282 
16283  ntry=0
16284 C...Choose flavour of reacting partons (and subprocess).
16285  210 ntry=ntry+1
16286  IF (ntry.GT.50) THEN
16287  CALL pyerrm(9,'(PYPTMI:) Unable to generate additional '
16288  & //'interaction. Giving up!')
16289  mint(51)=1
16290  RETURN
16291  ENDIF
16292  rsigs=sigs*pyr(0)
16293  DO 220 ichn=1,nchn
16294  kfl1=isig(ichn,1)
16295  kfl2=isig(ichn,2)
16296  iconmi=isig(ichn,3)
16297  rsigs=rsigs-sigh(ichn)
16298  IF(rsigs.LE.0d0) goto 230
16299  220 CONTINUE
16300 
16301 C...Reassign to appropriate process codes.
16302  230 isubmi=iconmi/10
16303  iconmi=mod(iconmi,10)
16304 
16305 C...Choose new quark flavour for annihilation graphs
16306  IF(isubmi.EQ.12.OR.isubmi.EQ.53) THEN
16307  sh=vint(21)*vint(2)
16308  CALL pywidt(21,sh,wdtp,wdte)
16309  240 rkfl=(wdte(0,1)+wdte(0,2)+wdte(0,4))*pyr(0)
16310  DO 250 i=1,mdcy(21,3)
16311  kflf=kfdp(i+mdcy(21,2)-1,1)
16312  rkfl=rkfl-(wdte(i,1)+wdte(i,2)+wdte(i,4))
16313  IF(rkfl.LE.0d0) goto 260
16314  250 CONTINUE
16315  260 IF(isubmi.EQ.53.AND.iconmi.LE.2) THEN
16316  IF(kflf.GE.4) goto 240
16317  ELSEIF(isubmi.EQ.53.AND.iconmi.LE.4) THEN
16318  kflf=4
16319  iconmi=iconmi-2
16320  ELSEIF(isubmi.EQ.53) THEN
16321  kflf=5
16322  iconmi=iconmi-4
16323  ENDIF
16324  ENDIF
16325 
16326 C...Final state flavours and colour flow: default values
16327  js=1
16328  kfl3=kfl1
16329  kfl4=kfl2
16330  kcc=20
16331  kcs=isign(1,kfl1)
16332 
16333  IF(isubmi.EQ.11) THEN
16334 C...f + f' -> f + f' (g exchange); th = (p(f)-p(f))**2
16335  kcc=iconmi
16336  IF(kfl1*kfl2.LT.0) kcc=kcc+2
16337 
16338  ELSEIF(isubmi.EQ.12) THEN
16339 C...f + fbar -> f' + fbar'; th = (p(f)-p(f'))**2
16340  kfl3=isign(kflf,kfl1)
16341  kfl4=-kfl3
16342  kcc=4
16343 
16344  ELSEIF(isubmi.EQ.13) THEN
16345 C...f + fbar -> g + g; th arbitrary
16346  kfl3=21
16347  kfl4=21
16348  kcc=iconmi+4
16349 
16350  ELSEIF(isubmi.EQ.28) THEN
16351 C...f + g -> f + g; th = (p(f)-p(f))**2
16352  IF(kfl1.EQ.21) js=2
16353  kcc=iconmi+6
16354  IF(kfl1.EQ.21) kcc=kcc+2
16355  IF(kfl1.NE.21) kcs=isign(1,kfl1)
16356  IF(kfl2.NE.21) kcs=isign(1,kfl2)
16357 
16358  ELSEIF(isubmi.EQ.53) THEN
16359 C...g + g -> f + fbar; th arbitrary
16360  kcs=(-1)**int(1.5d0+pyr(0))
16361  kfl3=isign(kflf,kcs)
16362  kfl4=-kfl3
16363  kcc=iconmi+10
16364 
16365  ELSEIF(isubmi.EQ.68) THEN
16366 C...g + g -> g + g; th arbitrary
16367  kcc=iconmi+12
16368  kcs=(-1)**int(1.5d0+pyr(0))
16369  ENDIF
16370 
16371 C...Check that massive sea quarks have non-zero phase space for g -> Q Q
16372  IF (iabs(kfl3).EQ.4.OR.iabs(kfl4).EQ.4.OR.iabs(kfl3).EQ.5
16373  & .OR.iabs(kfl4).EQ.5) THEN
16374  rmmax2=max(pmas(pycomp(kfl3),1),pmas(pycomp(kfl4),1))**2
16375  IF (pt2.LE.1.05*rmmax2) THEN
16376  IF (ntry.EQ.2) CALL pyerrm(9,'(PYPTMI:) Heavy quarks'
16377  & //' too close to threshold (2nd try).')
16378  goto 210
16379  ENDIF
16380  ENDIF
16381 
16382 C...Store flavours of scattering.
16383  mint(13)=kfl1
16384  mint(14)=kfl2
16385  mint(15)=kfl1
16386  mint(16)=kfl2
16387  mint(21)=kfl3
16388  mint(22)=kfl4
16389 
16390 C...Set flavours and mothers of scattering partons.
16391  k(n+1,1)=14
16392  k(n+2,1)=14
16393  k(n+3,1)=3
16394  k(n+4,1)=3
16395  k(n+1,2)=kfl1
16396  k(n+2,2)=kfl2
16397  k(n+3,2)=kfl3
16398  k(n+4,2)=kfl4
16399  k(n+1,3)=mint(83)+1
16400  k(n+2,3)=mint(83)+2
16401  k(n+3,3)=n+1
16402  k(n+4,3)=n+2
16403 
16404 C...Store colour connection indices.
16405  DO 270 j=1,2
16406  jc=j
16407  IF(kcs.EQ.-1) jc=3-j
16408  IF(icol(kcc,1,jc).NE.0) k(n+1,j+3)=n+icol(kcc,1,jc)
16409  IF(icol(kcc,2,jc).NE.0) k(n+2,j+3)=n+icol(kcc,2,jc)
16410  IF(icol(kcc,3,jc).NE.0) k(n+3,j+3)=mstu(5)*(n+icol(kcc,3,jc))
16411  IF(icol(kcc,4,jc).NE.0) k(n+4,j+3)=mstu(5)*(n+icol(kcc,4,jc))
16412  270 CONTINUE
16413 
16414 C...Store incoming and outgoing partons in their CM-frame.
16415  shr=sqrt(vint(21))*vint(1)
16416  p(n+1,3)=0.5d0*shr
16417  p(n+1,4)=0.5d0*shr
16418  p(n+2,3)=-0.5d0*shr
16419  p(n+2,4)=0.5d0*shr
16420  p(n+3,5)=pymass(k(n+3,2))
16421  p(n+4,5)=pymass(k(n+4,2))
16422  IF(p(n+3,5)+p(n+4,5).GE.shr) THEN
16423  ifail=1
16424  RETURN
16425  ENDIF
16426  p(n+3,4)=0.5d0*(shr+(p(n+3,5)**2-p(n+4,5)**2)/shr)
16427  p(n+3,3)=sqrt(max(0d0,p(n+3,4)**2-p(n+3,5)**2))
16428  p(n+4,4)=shr-p(n+3,4)
16429  p(n+4,3)=-p(n+3,3)
16430 
16431 C...Rotate outgoing partons using cos(theta)=(th-uh)/lam(sh,sqm3,sqm4)
16432  phi=paru(2)*pyr(0)
16433  CALL pyrobo(n+3,n+4,acos(vint(23)),phi,0d0,0d0,0d0)
16434 
16435 C...Global statistics.
16436  mint(351)=mint(351)+1
16437  vint(351)=vint(351)+sqrt(p(n+3,1)**2+p(n+3,2)**2)
16438  IF (mint(351).EQ.1) vint(356)=sqrt(p(n+3,1)**2+p(n+3,2)**2)
16439 
16440 C...Keep track of loose colour ends and information on scattering.
16441  mint(31)=mint(31)+1
16442  mint(36)=mint(31)
16443  pt2mi(mint(36))=pt2
16444  imisep(mint(31))=n+4
16445  DO 280 js=1,2
16446  imi(js,mint(31),1)=n+js
16447  imi(js,mint(31),2)=0
16448  xmi(js,mint(31))=vint(40+js)
16449  nmi(js)=nmi(js)+1
16450 C...Update cumulative counters
16451  vint(142+js)=vint(142+js)-vint(40+js)
16452  vint(150+js)=vint(150+js)+vint(40+js)
16453  280 CONTINUE
16454 
16455 C...Add to list of final state partons
16456  ipart(npart+1)=n+3
16457  ipart(npart+2)=n+4
16458  ptpart(npart+1)=sqrt(pt2)
16459  ptpart(npart+2)=sqrt(pt2)
16460  npart=npart+2
16461 
16462 C...Initialize ISR
16463  nisgen(1,mint(31))=0
16464  nisgen(2,mint(31))=0
16465 
16466 C...Update ER
16467  n=n+4
16468  IF(n.GT.mstu(4)-mstu(32)-10) THEN
16469  CALL pyerrm(11,'(PYMIGN:) no more memory left in PYJETS')
16470  mint(51)=1
16471  RETURN
16472  ENDIF
16473 
16474 C...Finally, assign colour tags to new partons
16475  DO 300 js=1,2
16476  i1=imi(js,mint(31),1)
16477  i2=imi(3-js,mint(31),1)
16478  DO 290 jcs=4,5
16479  IF (k(i1,2).NE.21.AND.(9-2*jcs).NE.isign(1,k(i1,2)))
16480  & goto 290
16481  IF (k(i1,jcs)/mstu(5)**2.NE.0) goto 290
16482  kcs=jcs
16483  CALL pycttr(i1,kcs,i2)
16484  IF(mint(51).NE.0) RETURN
16485  290 CONTINUE
16486  300 CONTINUE
16487 
16488 C----------------------------------------------------------------------
16489 C...MODE=2: Decide whether quarks in last scattering were valence,
16490 C...companion, or sea.
16491  ELSEIF (mode.EQ.2) THEN
16492  js=mint(30)
16493  mi=mint(36)
16494  pt2=pt2now
16495  kfsbm=isign(1,mint(10+js))
16496  ifl=k(imi(js,mi,1),2)
16497  imi(js,mi,2)=0
16498  IF (iabs(ifl).GE.6) THEN
16499  IF (iabs(ifl).EQ.6) THEN
16500  CALL pyerrm(29,'(PYPTMI:) top in initial state!')
16501  ENDIF
16502  RETURN
16503  ENDIF
16504 C...Get PDFs at X(rescaled) and PT2 of the current initiator.
16505 C...(Do not include the parton itself in the X rescaling.)
16506  x=xmi(js,mi)
16507  xrsc=x/(vint(142+js)+x)
16508 C...Note: XPSVC = x*pdf.
16509  mint(30)=js
16510  CALL pypdfu(kfbeam(js),xrsc,pt2,xpq)
16511  sea=xpsvc(ifl,-1)
16512  val=xpsvc(ifl,0)
16513 C...Ensure that pdfs are positive definite
16514  IF (sea.LT.0d0) THEN
16515  CALL pyerrm(9,'(PYPTMI:) Sea distribution negative.')
16516  sea=max(0d0,sea)
16517  ELSEIF (val.LT.0d0) THEN
16518  CALL pyerrm(9,'(PYPTMI:) Val distribution negative.')
16519  val=max(0d0,val)
16520  ENDIF
16521  cmp=0d0
16522  DO 310 ivc=1,nvc(js,ifl)
16523  cmp=cmp+xpsvc(ifl,ivc)
16524  310 CONTINUE
16525 
16526  ntry=0
16527 C...Decide (Extra factor x cancels in the dvision).
16528  320 rvcs=pyr(0)*(sea+val+cmp)
16529  ivnow=1
16530  ntry=ntry+1
16531  330 IF (rvcs.LE.val.AND.ivnow.GE.1) THEN
16532 C...Safety check that valence present; pi0/gamma/K0S/K0L special cases.
16533  ivnow=0
16534  IF(kfival(js,1).EQ.ifl) ivnow=ivnow+1
16535  IF(kfival(js,2).EQ.ifl) ivnow=ivnow+1
16536  IF(kfival(js,3).EQ.ifl) ivnow=ivnow+1
16537  IF(kfival(js,1).EQ.0) THEN
16538  IF(kfbeam(js).EQ.111.AND.iabs(ifl).LE.2) ivnow=1
16539  IF(kfbeam(js).EQ.22.AND.iabs(ifl).LE.5) ivnow=1
16540  IF((kfbeam(js).EQ.130.OR.kfbeam(js).EQ.310).AND.
16541  & (iabs(ifl).EQ.1.OR.iabs(ifl).EQ.3)) ivnow=1
16542  ELSE
16543 C...Count down valence remaining. Do not count current scattering.
16544  DO 340 i1=1,nmi(js)
16545  IF (i1.EQ.mint(36)) goto 340
16546  IF (k(imi(js,i1,1),2).EQ.ifl.AND.imi(js,i1,2).EQ.0)
16547  & ivnow=ivnow-1
16548  340 CONTINUE
16549  ENDIF
16550  IF(ivnow.EQ.0) goto 330
16551 C...Mark valence.
16552  imi(js,mi,2)=0
16553 C...Sets valence content of gamma, pi0, K0S, K0L if not done.
16554  IF(kfival(js,1).EQ.0) THEN
16555  IF(kfbeam(js).EQ.111.OR.kfbeam(js).EQ.22) THEN
16556  kfival(js,1)=ifl
16557  kfival(js,2)=-ifl
16558  ELSEIF(kfbeam(js).EQ.130.OR.kfbeam(js).EQ.310) THEN
16559  kfival(js,1)=ifl
16560  IF(iabs(ifl).EQ.1) kfival(js,2)=isign(3,-ifl)
16561  IF(iabs(ifl).NE.1) kfival(js,2)=isign(1,-ifl)
16562  ENDIF
16563  ENDIF
16564 
16565  ELSEIF (rvcs.LE.val+sea) THEN
16566 C...If sea, add opposite sign companion parton. Store X and I.
16567  nvc(js,-ifl)=nvc(js,-ifl)+1
16568  xassoc(js,-ifl,nvc(js,-ifl))=xmi(js,mi)
16569 C...Set pointer to companion
16570  imi(js,mi,2)=-nvc(js,-ifl)
16571 
16572  ELSE
16573 C...If companion, check whether we've got any in the books
16574  IF (nvc(js,ifl).EQ.0) THEN
16575  cmp=0d0
16576 C...Only report error first time for this event
16577  IF (ntry.EQ.1)
16578  & CALL pyerrm(9,'(PYPTMI:) No cmp quark, but pdf != 0!')
16579 C...Try a few times
16580  IF (ntry.LE.10) THEN
16581  goto 320
16582 C... But if it stil fails, abort this event
16583  ELSE
16584  mint(51)=1
16585  RETURN
16586  ENDIF
16587  ENDIF
16588 C...If several possibilities, decide which one
16589  cmpsum=val+sea
16590  isel=0
16591  350 isel=isel+1
16592  cmpsum=cmpsum+xpsvc(ifl,isel)
16593  IF (rvcs.GT.cmpsum.AND.isel.LT.nvc(js,ifl)) goto 350
16594 C...Find original sea (anti-)quark. Do not consider current scattering.
16595  iassoc=0
16596  DO 360 i1=1,nmi(js)
16597  IF (i1.EQ.mint(36)) goto 360
16598  IF (k(imi(js,i1,1),2).NE.-ifl) goto 360
16599  IF (-imi(js,i1,2).EQ.isel) THEN
16600  imi(js,mi,2)=imi(js,i1,1)
16601  imi(js,i1,2)=imi(js,mi,1)
16602  ENDIF
16603  360 CONTINUE
16604 C...Mark companion "out-kicked".
16605  xassoc(js,ifl,isel)=-xassoc(js,ifl,isel)
16606  ENDIF
16607 
16608  ENDIF
16609  RETURN
16610  END
16611 
16612 C*********************************************************************
16613 
16614 C...PYFCMP: Auxiliary to PYPDFU and PYPTIS.
16615 C...Giving the x*f pdf of a companion quark, with its partner at XS,
16616 C...using an approximate gluon density like (1-X)^NPOW/X. The value
16617 C...corresponds to an unrescaled range between 0 and 1-X.
16618 
16619  FUNCTION pyfcmp(XC,XS,NPOW)
16620  IMPLICIT NONE
16621  DOUBLE PRECISION xc, xs, y, pyfcmp,fac
16622  INTEGER npow
16623 
16624  pyfcmp=0d0
16625 C...Parent gluon momentum fraction
16626  y=xc+xs
16627  IF (y.GE.1d0) RETURN
16628 C...Common factor (includes factor XC, since PYFCMP=x*f)
16629  fac=3d0*xc*xs*(xc**2+xs**2)/(y**4)
16630 C...Store normalized companion x*f distribution.
16631  IF (npow.LE.0) THEN
16632  pyfcmp=fac/(2d0-xs*(3d0-xs*(3d0-2d0*xs)))
16633  ELSEIF (npow.EQ.1) THEN
16634  pyfcmp=fac*(1d0-y)/(2d0+xs**2*(-3d0+xs)+3d0*xs*log(xs))
16635  ELSEIF (npow.EQ.2) THEN
16636  pyfcmp=fac*(1d0-y)**2/(2d0*((1d0-xs)*(1d0+xs*(4d0+xs))
16637  & +3d0*xs*(1d0+xs)*log(xs)))
16638  ELSEIF (npow.EQ.3) THEN
16639  pyfcmp=fac*(1d0-y)**3*2d0/(4d0+27d0*xs-31d0*xs**3
16640  & +6d0*xs*log(xs)*(3d0+2d0*xs*(3d0+xs)))
16641  ELSEIF (npow.GE.4) THEN
16642  pyfcmp=fac*(1d0-y)**4/(2d0*(1d0+2d0*xs)*((1d0-xs)*(1d0+
16643  & xs*(10d0+xs))+6d0*xs*log(xs)*(1d0+xs)))
16644  ENDIF
16645  RETURN
16646  END
16647 
16648 C*********************************************************************
16649 
16650 C...PYPCMP: Auxiliary to PYPDFU.
16651 C...Giving the momentum integral of a companion quark, with its
16652 C...partner at XS, using an approximate gluon density like (1-x)^NPOW/x.
16653 C...The value corresponds to an unrescaled range between 0 and 1-XS.
16654 
16655  FUNCTION pypcmp(XS,NPOW)
16656  IMPLICIT NONE
16657  DOUBLE PRECISION xs, pypcmp
16658  INTEGER npow
16659  IF (xs.GE.1d0.OR.xs.LE.0d0) THEN
16660  pypcmp=0d0
16661  ELSEIF (npow.LE.0) THEN
16662  pypcmp=xs*(5d0+xs*(-9d0-2d0*xs*(-3d0+xs))+3d0*log(xs))
16663  pypcmp=pypcmp/((-1d0+xs)*(2d0+xs*(-1d0+2d0*xs)))
16664  ELSEIF (npow.EQ.1) THEN
16665  pypcmp=-1d0-3d0*xs+(2d0*(-1d0+xs)**2*(1d0+xs+xs**2))
16666  & /(2d0+xs**2*(xs-3d0)+3d0*xs*log(xs))
16667  ELSEIF (npow.EQ.2) THEN
16668  pypcmp=xs*((1d0-xs)*(19d0+xs*(43d0+4d0*xs))
16669  & +6d0*log(xs)*(1d0+6d0*xs+4d0*xs**2))
16670  pypcmp=pypcmp/(4d0*((xs-1d0)*(1d0+xs*(4d0+xs))
16671  & -3d0*xs*log(xs)*(1+xs)))
16672  ELSEIF (npow.EQ.3) THEN
16673  pypcmp=3d0*xs*((xs-1)*(7d0+xs*(28d0+13d0*xs))
16674  & -2d0*log(xs)*(1d0+xs*(9d0+2d0*xs*(6d0+xs))))
16675  pypcmp=pypcmp/(4d0+27d0*xs-31d0*xs**3
16676  & +6d0*xs*log(xs)*(3d0+2d0*xs*(3d0+xs)))
16677  ELSE
16678  pypcmp=(-9d0*xs*(xs**2-1d0)*(5d0+xs*(24d0+xs))+12d0*xs*log(xs)
16679  & *(1d0+2d0*xs)*(1d0+2d0*xs*(5d0+2d0*xs)))
16680  pypcmp=pypcmp/(8d0*(1d0+2d0*xs)*((xs-1d0)*(1d0+xs*(10d0+xs))
16681  & -6d0*xs*log(xs)*(1d0+xs)))
16682  ENDIF
16683  RETURN
16684  END
16685 
16686 C*********************************************************************
16687 
16688 C...PYUPRE
16689 C...Rearranges contents of the HEPEUP commonblock so that
16690 C...mothers precede daughters and daughters of a decay are
16691 C...listed consecutively.
16692 
16693  SUBROUTINE pyupre
16694 
16695 C...Double precision and integer declarations.
16696  IMPLICIT DOUBLE PRECISION(a-h, o-z)
16697  IMPLICIT INTEGER(i-n)
16698 
16699 C...User process event common block.
16700  INTEGER maxnup
16701  parameter(maxnup=500)
16702  INTEGER nup,idprup,idup,istup,mothup,icolup
16703  DOUBLE PRECISION xwgtup,scalup,aqedup,aqcdup,pup,vtimup,spinup
16704  common/hepeup/nup,idprup,xwgtup,scalup,aqedup,aqcdup,idup(maxnup),
16705  &istup(maxnup),mothup(2,maxnup),icolup(2,maxnup),pup(5,maxnup),
16706  &vtimup(maxnup),spinup(maxnup)
16707  SAVE /hepeup/
16708 
16709 C...Local arrays.
16710  dimension newpos(0:maxnup),idupt(maxnup),istupt(maxnup),
16711  &motupt(2,maxnup),icoupt(2,maxnup),pupt(5,maxnup),
16712  &vtiupt(maxnup),spiupt(maxnup)
16713 
16714 C...Check whether a rearrangement is required.
16715  need=0
16716  DO 100 iup=1,nup
16717  IF(mothup(1,iup).GT.iup) need=need+1
16718  100 CONTINUE
16719  DO 110 iup=2,nup
16720  IF(mothup(1,iup).LT.mothup(1,iup-1)) need=need+1
16721  110 CONTINUE
16722 
16723  IF(need.NE.0) THEN
16724 C...Find the new order that particles should have.
16725  newpos(0)=0
16726  nnew=0
16727  inew=-1
16728  120 inew=inew+1
16729  DO 130 iup=1,nup
16730  IF(mothup(1,iup).EQ.newpos(inew)) THEN
16731  nnew=nnew+1
16732  newpos(nnew)=iup
16733  ENDIF
16734  130 CONTINUE
16735  IF(inew.LT.nnew.AND.inew.LT.nup) goto 120
16736  IF(nnew.NE.nup) THEN
16737  CALL pyerrm(2,
16738  & '(PYUPRE:) failed to make sense of mother pointers in HEPEUP')
16739  RETURN
16740  ENDIF
16741 
16742 C...Copy old info into temporary storage.
16743  DO 150 i=1,nup
16744  idupt(i)=idup(i)
16745  istupt(i)=istup(i)
16746  motupt(1,i)=mothup(1,i)
16747  motupt(2,i)=mothup(2,i)
16748  icoupt(1,i)=icolup(1,i)
16749  icoupt(2,i)=icolup(2,i)
16750  DO 140 j=1,5
16751  pupt(j,i)=pup(j,i)
16752  140 CONTINUE
16753  vtiupt(i)=vtimup(i)
16754  spiupt(i)=spinup(i)
16755  150 CONTINUE
16756 
16757 C...Copy info back into HEPEUP in right order.
16758  DO 180 i=1,nup
16759  iold=newpos(i)
16760  idup(i)=idupt(iold)
16761  istup(i)=istupt(iold)
16762  mothup(1,i)=0
16763  mothup(2,i)=0
16764  DO 160 imot=1,i-1
16765  IF(motupt(1,iold).EQ.newpos(imot)) mothup(1,i)=imot
16766  IF(motupt(2,iold).EQ.newpos(imot)) mothup(2,i)=imot
16767  160 CONTINUE
16768  IF(mothup(2,i).GT.0.AND.mothup(2,i).LT.mothup(1,i)) THEN
16769  mothsw=mothup(1,i)
16770  mothup(1,i)=mothup(2,i)
16771  mothup(2,i)=mothsw
16772  ENDIF
16773  icolup(1,i)=icoupt(1,iold)
16774  icolup(2,i)=icoupt(2,iold)
16775  DO 170 j=1,5
16776  pup(j,i)=pupt(j,iold)
16777  170 CONTINUE
16778  vtimup(i)=vtiupt(iold)
16779  spinup(i)=spiupt(iold)
16780  180 CONTINUE
16781  ENDIF
16782 
16783 c...If incoming particles are massive recalculate to put them massless.
16784  IF(pup(5,1).NE.0d0.OR.pup(5,2).NE.0d0) THEN
16785  pplus=(pup(4,1)+pup(3,1))+(pup(4,2)+pup(3,2))
16786  pminus=(pup(4,1)-pup(3,1))+(pup(4,2)-pup(3,2))
16787  pup(4,1)=0.5d0*pplus
16788  pup(3,1)=pup(4,1)
16789  pup(5,1)=0d0
16790  pup(4,2)=0.5d0*pminus
16791  pup(3,2)=-pup(4,2)
16792  pup(5,2)=0d0
16793  ENDIF
16794 
16795  RETURN
16796  END
16797 
16798 C*********************************************************************
16799 
16800 C...PYADSH
16801 C...Administers the generation of successive final-state showers
16802 C...in external processes.
16803 
16804  SUBROUTINE pyadsh(NFIN)
16805 
16806 C...Double precision and integer declarations.
16807  IMPLICIT DOUBLE PRECISION(a-h, o-z)
16808  IMPLICIT INTEGER(i-n)
16809  INTEGER pyk,pychge,pycomp
16810 C...Parameter statement for maximum size of showers.
16811  parameter(maxnur=1000)
16812 C...Commonblocks.
16813  common/pypart/npart,npartd,ipart(maxnur),ptpart(maxnur)
16814  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
16815  common/pyctag/nct,mct(4000,2)
16816  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
16817  common/pypars/mstp(200),parp(200),msti(200),pari(200)
16818  common/pyint1/mint(400),vint(400)
16819  SAVE /pypart/,/pyjets/,/pyctag/,/pydat1/,/pypars/,/pyint1/
16820 C...Local array.
16821  dimension ibeg(100),ksav(100,5),psum(4),beta(3)
16822 
16823 C...Set primary vertex.
16824  DO 100 j=1,5
16825  v(mint(83)+5,j)=0d0
16826  v(mint(83)+6,j)=0d0
16827  v(mint(84)+1,j)=0d0
16828  v(mint(84)+2,j)=0d0
16829  100 CONTINUE
16830 
16831 C...Isolate systems of particles with the same mother.
16832  nsys=0
16833  ims=-1
16834  DO 140 i=mint(84)+3,nfin
16835  im=k(i,3)
16836  IF(im.GT.0.AND.im.LE.mint(84)) im=k(im,3)
16837  IF(im.NE.ims) THEN
16838  nsys=nsys+1
16839  ibeg(nsys)=i
16840  ims=im
16841  ENDIF
16842 
16843 C...Set production vertices.
16844  IF(im.LE.mint(83)+6.OR.(im.GT.mint(84).AND.im.LE.mint(84)+2))
16845  & THEN
16846  DO 110 j=1,4
16847  v(i,j)=0d0
16848  110 CONTINUE
16849  ELSE
16850  DO 120 j=1,4
16851  v(i,j)=v(im,j)+v(im,5)*p(im,j)/p(im,5)
16852  120 CONTINUE
16853  ENDIF
16854  IF(mstp(125).GE.1) THEN
16855  idoc=i-mstp(126)+4
16856  DO 130 j=1,5
16857  v(idoc,j)=v(i,j)
16858  130 CONTINUE
16859  ENDIF
16860  140 CONTINUE
16861 
16862 C...End loop over systems. Return if no showers to be performed.
16863  ibeg(nsys+1)=nfin+1
16864  IF(mstp(71).LE.0) RETURN
16865 
16866 C...Loop through systems of particles; check that sensible size.
16867  DO 270 isys=1,nsys
16868  nsiz=ibeg(isys+1)-ibeg(isys)
16869  IF(mint(35).LE.2) THEN
16870  IF(nsiz.EQ.1.AND.isys.EQ.1) THEN
16871  goto 270
16872  ELSEIF(nsiz.LE.1) THEN
16873  CALL pyerrm(2,'(PYADSH:) only one particle in system')
16874  goto 270
16875  ELSEIF(nsiz.GT.80) THEN
16876  CALL pyerrm(2,'(PYADSH:) more than 80 particles in system')
16877  goto 270
16878  ENDIF
16879  ENDIF
16880 
16881 C...Save status codes and daughters of showering particles; reset them.
16882  DO 150 j=1,4
16883  psum(j)=0d0
16884  150 CONTINUE
16885  DO 170 ii=1,nsiz
16886  i=ibeg(isys)-1+ii
16887  ksav(ii,1)=k(i,1)
16888  IF(k(i,1).GT.10) THEN
16889  k(i,1)=1
16890  IF(ksav(ii,1).EQ.14) k(i,1)=3
16891  ENDIF
16892  IF(ksav(ii,1).LE.10) THEN
16893  ELSEIF(k(i,1).EQ.1) THEN
16894  ksav(ii,4)=k(i,4)
16895  ksav(ii,5)=k(i,5)
16896  k(i,4)=0
16897  k(i,5)=0
16898  ELSE
16899  ksav(ii,4)=mod(k(i,4),mstu(5))
16900  ksav(ii,5)=mod(k(i,5),mstu(5))
16901  k(i,4)=k(i,4)-ksav(ii,4)
16902  k(i,5)=k(i,5)-ksav(ii,5)
16903  ENDIF
16904  DO 160 j=1,4
16905  psum(j)=psum(j)+p(i,j)
16906  160 CONTINUE
16907  170 CONTINUE
16908 
16909 C...Perform shower.
16910  qmax=sqrt(max(0d0,psum(4)**2-psum(1)**2-psum(2)**2-
16911  & psum(3)**2))
16912  IF(isys.EQ.1) qmax=min(qmax,sqrt(parp(71))*vint(55))
16913  nsav=n
16914  IF(mint(35).LE.2) THEN
16915  IF(nsiz.EQ.2) THEN
16916  CALL pyshow(ibeg(isys),ibeg(isys)+1,qmax)
16917  ELSE
16918  CALL pyshow(ibeg(isys),-nsiz,qmax)
16919  ENDIF
16920 
16921 C...For external processes, first call, also ISR partons radiate.
16922 C...Can use existing PYPART list, removing partons that radiate later.
16923  ELSEIF(isys.EQ.1) THEN
16924  npartn=0
16925  DO 175 ii=1,npart
16926  IF(ipart(ii).LT.ibeg(2).OR.ipart(ii).GE.ibeg(nsys+1)) THEN
16927  npartn=npartn+1
16928  ipart(npartn)=ipart(ii)
16929  ptpart(npartn)=ptpart(ii)
16930  ENDIF
16931  175 CONTINUE
16932  npart=npartn
16933  CALL pyptfs(1,0.5d0*qmax,0d0,ptgen)
16934  ELSE
16935 C...For subsequent calls use the systems excluded above.
16936  npart=nsiz
16937  npartd=0
16938  DO 180 ii=1,nsiz
16939  i=ibeg(isys)-1+ii
16940  ipart(ii)=i
16941  ptpart(ii)=0.5d0*qmax
16942  180 CONTINUE
16943  CALL pyptfs(2,0.5d0*qmax,0d0,ptgen)
16944  ENDIF
16945 
16946 C...Look up showered copies of original showering particles.
16947  DO 260 ii=1,nsiz
16948  i=ibeg(isys)-1+ii
16949  imv=i
16950 C...Particles without daughters need not be studied.
16951  IF(ksav(ii,1).LE.10) goto 260
16952  IF(n.EQ.nsav.OR.k(i,1).LE.10) THEN
16953  ELSEIF(k(i,1).EQ.11) THEN
16954  190 imv=mod(k(imv,4),mstu(5))
16955  IF(k(imv,1).EQ.11) goto 190
16956  ELSE
16957  kda1=mod(k(i,4),mstu(5))
16958  IF(kda1.GT.0) THEN
16959  IF(k(kda1,2).EQ.21) kda1=k(kda1,5)/mstu(5)
16960  ENDIF
16961  kda2=mod(k(i,5),mstu(5))
16962  IF(kda2.GT.0) THEN
16963  IF(k(kda2,2).EQ.21) kda2=k(kda2,4)/mstu(5)
16964  ENDIF
16965  DO 200 i3=i+1,n
16966  IF(k(i3,2).EQ.k(i,2).AND.(i3.EQ.kda1.OR.i3.EQ.kda2))
16967  & THEN
16968  imv=i3
16969  kda1=mod(k(i3,4),mstu(5))
16970  IF(kda1.GT.0) THEN
16971  IF(k(kda1,2).EQ.21) kda1=k(kda1,5)/mstu(5)
16972  ENDIF
16973  kda2=mod(k(i3,5),mstu(5))
16974  IF(kda2.GT.0) THEN
16975  IF(k(kda2,2).EQ.21) kda2=k(kda2,4)/mstu(5)
16976  ENDIF
16977  ENDIF
16978  200 CONTINUE
16979  ENDIF
16980 
16981 C...Restore daughter info of original partons to showered copies.
16982  IF(ksav(ii,1).GT.10) k(imv,1)=ksav(ii,1)
16983  IF(ksav(ii,1).LE.10) THEN
16984  ELSEIF(k(i,1).EQ.1) THEN
16985  k(imv,4)=ksav(ii,4)
16986  k(imv,5)=ksav(ii,5)
16987  ELSE
16988  k(imv,4)=k(imv,4)+ksav(ii,4)
16989  k(imv,5)=k(imv,5)+ksav(ii,5)
16990  ENDIF
16991 
16992 C...Reset mother info of existing daughters to showered copies.
16993  DO 210 i3=ibeg(isys+1),nfin
16994  IF(k(i3,3).EQ.i) k(i3,3)=imv
16995  IF(k(i3,1).EQ.3.OR.k(i3,1).EQ.14) THEN
16996  IF(k(i3,4)/mstu(5).EQ.i) k(i3,4)=k(i3,4)+mstu(5)*(imv-i)
16997  IF(k(i3,5)/mstu(5).EQ.i) k(i3,5)=k(i3,5)+mstu(5)*(imv-i)
16998  ENDIF
16999  210 CONTINUE
17000 
17001 C...Boost all original daughters to new frame of showered copy.
17002 C...Also update their colour tags.
17003  IF(imv.NE.i) THEN
17004  DO 220 j=1,3
17005  beta(j)=(p(imv,j)-p(i,j))/(p(imv,4)+p(i,4))
17006  220 CONTINUE
17007  fac=2d0/(1d0+beta(1)**2+beta(2)**2+beta(3)**2)
17008  DO 230 j=1,3
17009  beta(j)=fac*beta(j)
17010  230 CONTINUE
17011  DO 250 i3=ibeg(isys+1),nfin
17012  imo=i3
17013  240 imo=k(imo,3)
17014  IF(mstp(128).LE.0) THEN
17015  IF(imo.GT.0.AND.imo.NE.i.AND.imo.NE.k(i,3)) goto 240
17016  IF(imo.EQ.i.OR.(k(i,3).LE.mint(84).AND.imo.EQ.k(i,3)))
17017  & THEN
17018  CALL pyrobo(i3,i3,0d0,0d0,beta(1),beta(2),beta(3))
17019  IF(mct(i3,1).EQ.mct(i,1)) mct(i3,1)=mct(imv,1)
17020  IF(mct(i3,2).EQ.mct(i,2)) mct(i3,2)=mct(imv,2)
17021  ENDIF
17022  ELSE
17023  IF(imo.EQ.imv) THEN
17024  CALL pyrobo(i3,i3,0d0,0d0,beta(1),beta(2),beta(3))
17025  IF(mct(i3,1).EQ.mct(i,1)) mct(i3,1)=mct(imv,1)
17026  IF(mct(i3,2).EQ.mct(i,2)) mct(i3,2)=mct(imv,2)
17027  ELSEIF(imo.GT.0.AND.imo.NE.i.AND.imo.NE.k(i,3)) THEN
17028  goto 240
17029  ENDIF
17030  ENDIF
17031  250 CONTINUE
17032  ENDIF
17033  260 CONTINUE
17034 
17035 C...End of loop over showering systems
17036  270 CONTINUE
17037 
17038  RETURN
17039  END
17040 
17041 C*********************************************************************
17042 
17043 C...PYVETO
17044 C...Interface to UPVETO, which allows user to veto event generation
17045 C...on the parton level, after parton showers but before multiple
17046 C...interactions, beam remnants and hadronization is added.
17047 
17048  SUBROUTINE pyveto(IVETO)
17049 
17050 C...All real arithmetic in double precision.
17051  IMPLICIT DOUBLE PRECISION(a-h, o-z)
17052 C...Three Pythia functions return integers, so need declaring.
17053  INTEGER pyk,pychge,pycomp
17054 
17055 C...PYTHIA commonblocks.
17056  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
17057  common/pypars/mstp(200),parp(200),msti(200),pari(200)
17058  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
17059  common/pyint1/mint(400),vint(400)
17060  SAVE /pyjets/,/pypars/,/pyint1/
17061 C...HEPEVT commonblock.
17062  parameter(nmxhep=4000)
17063  common/hepevt/nevhep,nhep,isthep(nmxhep),idhep(nmxhep),
17064  &jmohep(2,nmxhep),jdahep(2,nmxhep),phep(5,nmxhep),vhep(4,nmxhep)
17065  DOUBLE PRECISION phep,vhep
17066  SAVE /hepevt/
17067 C...Local array.
17068  dimension ireso(100)
17069 
17070 C...Define longitudinal boost from initiator rest frame to cm frame.
17071  gamma=0.5d0*(vint(141)+vint(142))/sqrt(vint(141)*vint(142))
17072  gabez=0.5d0*(vint(141)-vint(142))/sqrt(vint(141)*vint(142))
17073 
17074 C...Presentation is different if using pT-ordered shower
17075  IF(mint(35).EQ.3) THEN
17076  gamma=1d0
17077  gabez=0d0
17078  ENDIF
17079 
17080 C... Reset counters.
17081  nevhep=0
17082  nhep=0
17083  nreso=0
17084 
17085 C...Oth pass: identify beam and incoming partons
17086  DO 140 i=mint(83)+1,mint(83)+6
17087  istore=0
17088  IF(k(i,2).EQ.94) THEN
17089 
17090  ELSE
17091  nreso=nreso+1
17092  ireso(nreso)=i
17093  imoth=k(i,3)
17094  ENDIF
17095  140 CONTINUE
17096 
17097 C...First pass: identify final locations of resonances
17098 C...and of their daughters before showering.
17099  DO 150 i=mint(84)+3,n
17100  istore=0
17101  imoth=0
17102 
17103 C...Skip shower CM frame documentation lines.
17104  IF(k(i,2).EQ.94) THEN
17105 
17106 C... Store a new intermediate product, when mother in documentation.
17107  ELSEIF(mstp(128).EQ.0.AND.k(i,3).GT.mint(83)+6.AND.
17108  & k(i,3).LE.mint(84)) THEN
17109  istore=1
17110  nhep=nhep+1
17111  ii=nhep
17112  nreso=nreso+1
17113  ireso(nreso)=i
17114  imoth=max(0,k(k(i,3),3)-(mint(83)+6))
17115 
17116 C... Store a new intermediate product, when mother in main section.
17117  ELSEIF(mstp(128).EQ.1.AND.k(i-mint(84)+mint(83)+4,1).EQ.21.AND.
17118  & k(i-mint(84)+mint(83)+4,2).EQ.k(i,2)) THEN
17119  istore=1
17120  nhep=nhep+1
17121  ii=nhep
17122  nreso=nreso+1
17123  ireso(nreso)=i
17124  imoth=max(0,k(i-mint(84)+mint(83)+4,3)-(mint(83)+6))
17125  ENDIF
17126 
17127  IF(istore.EQ.1) THEN
17128 C...Copy parton info, boosting momenta along z axis to cm frame.
17129  isthep(ii)=2
17130  idhep(ii)=k(i,2)
17131  phep(1,ii)=p(i,1)
17132  phep(2,ii)=p(i,2)
17133  phep(3,ii)=gamma*p(i,3)+gabez*p(i,4)
17134  phep(4,ii)=gamma*p(i,4)+gabez*p(i,3)
17135  phep(5,ii)=p(i,5)
17136 C...Store one mother. Rest of history and vertex info zeroed.
17137  jmohep(1,ii)=imoth
17138  jmohep(2,ii)=0
17139  jdahep(1,ii)=0
17140  jdahep(2,ii)=0
17141  vhep(1,ii)=0d0
17142  vhep(2,ii)=0d0
17143  vhep(3,ii)=0d0
17144  vhep(4,ii)=0d0
17145  ENDIF
17146  150 CONTINUE
17147 
17148 C...Second pass: identify current set of "final" partons.
17149  DO 200 i=mint(84)+3,n
17150  istore=0
17151  imoth=0
17152 
17153 C...Store a final parton.
17154  IF(k(i,1).GE.1.AND.k(i,1).LE.10) THEN
17155  istore=1
17156  nhep=nhep+1
17157  ii=nhep
17158 C..Trace it back through shower, to check if from documented particle.
17159  ihist=i
17160  isave=ihist
17161  160 CONTINUE
17162  IF(ihist.GT.mint(84)) THEN
17163  IF(k(ihist,2).EQ.94) ihist=k(ihist,3)+(isave-1-ihist)
17164  DO 170 iri=1,nreso
17165  IF(ihist.EQ.ireso(iri)) imoth=iri
17166  170 CONTINUE
17167  isave=ihist
17168  ihist=k(ihist,3)
17169  IF(imoth.EQ.0) goto 160
17170  imoth=max(0,imoth-6)
17171  ELSEIF(ihist.LE.4) THEN
17172  IF(ihist.EQ.1.OR.ihist.EQ.2) THEN
17173  istore=0
17174  nhep=nhep-1
17175  ELSE
17176  imoth=0
17177  ENDIF
17178  ENDIF
17179  ENDIF
17180 
17181  IF(istore.EQ.1) THEN
17182 C...Copy parton info, boosting momenta along z axis to cm frame.
17183  isthep(ii)=1
17184  idhep(ii)=k(i,2)
17185  phep(1,ii)=p(i,1)
17186  phep(2,ii)=p(i,2)
17187  phep(3,ii)=gamma*p(i,3)+gabez*p(i,4)
17188  phep(4,ii)=gamma*p(i,4)+gabez*p(i,3)
17189  phep(5,ii)=p(i,5)
17190 C...Store one mother. Rest of history and vertex info zeroed.
17191  jmohep(1,ii)=imoth
17192  jmohep(2,ii)=0
17193  jdahep(1,ii)=0
17194  jdahep(2,ii)=0
17195  vhep(1,ii)=0d0
17196  vhep(2,ii)=0d0
17197  vhep(3,ii)=0d0
17198  vhep(4,ii)=0d0
17199  ENDIF
17200  200 CONTINUE
17201 C...Call user-written routine to decide whether to keep events.
17202  CALL upveto(iveto)
17203  RETURN
17204  END
17205 C*********************************************************************
17206 
17207 C...PYRESD
17208 C...Allows resonances to decay (including parton showers for hadronic
17209 C...channels).
17210 
17211  SUBROUTINE pyresd(IRES)
17212 
17213 C...Double precision and integer declarations.
17214  IMPLICIT DOUBLE PRECISION(a-h, o-z)
17215  IMPLICIT INTEGER(i-n)
17216  INTEGER pyk,pychge,pycomp
17217 C...Parameter statement to help give large particle numbers.
17218  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
17219  &kexcit=4000000,kdimen=5000000)
17220 C...Parameter statement for maximum size of showers.
17221  parameter(maxnur=1000)
17222 C...Commonblocks.
17223  common/pypart/npart,npartd,ipart(maxnur),ptpart(maxnur)
17224  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
17225  common/pyctag/nct,mct(4000,2)
17226  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
17227  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
17228  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
17229  common/pysubs/msel,mselpd,msub(500),kfin(2,-40:40),ckin(200)
17230  common/pypars/mstp(200),parp(200),msti(200),pari(200)
17231  common/pyint1/mint(400),vint(400)
17232  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
17233  common/pyint4/mwid(500),wids(500,5)
17234  common/pypued/iued(0:99),rued(0:99)
17235  SAVE /pypart/,/pyjets/,/pyctag/,/pydat1/,/pydat2/,/pydat3/,
17236  &/pysubs/,/pypars/,/pyint1/,/pyint2/,/pyint4/,/pypued/
17237 C...Local arrays and complex and character variables.
17238  dimension iref(50,8),kdcy(3),kfl1(3),kfl2(3),kfl3(3),keql(3),
17239  &kcqm(3),kcq1(3),kcq2(3),kcq3(3),nsd(3),pmmn(4),ilin(6),
17240  &hgz(3,3),coup(6,4),corl(2,2,2),pk(6,4),pkk(6,6),cthe(3),
17241  &phi(3),wdtp(0:400),wdte(0:400,0:5),dpmo(5),vdcy(4),
17242  &itjunc(3),ctm2(3),kcq(0:10),iant(4),itri(4),ioct(4),kcq4(3),
17243  &kfl4(3)
17244  COMPLEX fgk,ha(6,6),hc(6,6)
17245  REAL tir,uir
17246  CHARACTER code*9,mass*9
17247 C...Local arrays.
17248  dimension pv(10,5),rord(10),ue(3),be(3),wtcor(10)
17249  DATA wtcor/2d0,5d0,15d0,60d0,250d0,1500d0,1.2d4,1.2d5,150d0,16d0/
17250 
17251 C...Functions: momentum in two-particle decays and four-product.
17252  pawt(a,b,c)=sqrt((a**2-(b+c)**2)*(a**2-(b-c)**2))/(2d0*a)
17253 
17254 C...The F, Xi and Xj functions of Gunion and Kunszt
17255 C...(Phys. Rev. D33, 665, plus errata from the authors).
17256  fgk(i1,i2,i3,i4,i5,i6)=4.*ha(i1,i3)*hc(i2,i6)*(ha(i1,i5)*
17257  &hc(i1,i4)+ha(i3,i5)*hc(i3,i4))
17258  digk(dt,du)=-4d0*d34*d56+dt*(3d0*dt+4d0*du)+dt**2*(dt*du/
17259  &(d34*d56)-2d0*(1d0/d34+1d0/d56)*(dt+du)+2d0*(d34/d56+d56/d34))
17260  djgk(dt,du)=8d0*(d34+d56)**2-8d0*(d34+d56)*(dt+du)-6d0*dt*du-
17261  &2d0*dt*du*(dt*du/(d34*d56)-2d0*(1d0/d34+1d0/d56)*(dt+du)+
17262  &2d0*(d34/d56+d56/d34))
17263 
17264 C...Some general constants.
17265  xw=paru(102)
17266  xwv=xw
17267  IF(mstp(8).GE.2) xw=1d0-(pmas(24,1)/pmas(23,1))**2
17268  xw1=1d0-xw
17269  sqmz=pmas(23,1)**2
17270 
17271  gmmz=pmas(23,1)*pmas(23,2)
17272  sqmw=pmas(24,1)**2
17273  gmmw=pmas(24,1)*pmas(24,2)
17274  sh=vint(44)
17275 
17276 C...Boost and rotate to rest frame of incoming partons,
17277 C...to get proper amount of smearing of decay angles.
17278  ibst=0
17279  IF(ires.EQ.0) THEN
17280  ibst=1
17281  iin1=mint(84)+1
17282  iin2=mint(84)+2
17283 C...Bug fix 09 OCT 2008 (PS) at 6.4.18: in new shower, the incoming partons
17284 C...(101,102) are off shell and can have inconsistent momenta, resulting
17285 C...in boosts larger than unity. However, the corresponding docu partons
17286 C...(5,6) are kept on shell, and have consistent momenta that can be used
17287 C...to derive this boost instead. Ultimately, should change the way the new
17288 C...shower stores intermediate partons, but just using partons (5,6) for now
17289 C...does define the boost and furnishes a quick and much needed solution.
17290  IF (mint(35).EQ.3) THEN
17291  iin1=mint(83)+5
17292  iin2=mint(83)+6
17293  ENDIF
17294  etotin=p(iin1,4)+p(iin2,4)
17295  bexin=(p(iin1,1)+p(iin2,1))/etotin
17296  beyin=(p(iin1,2)+p(iin2,2))/etotin
17297  bezin=(p(iin1,3)+p(iin2,3))/etotin
17298  CALL pyrobo(mint(83)+7,n,0d0,0d0,-bexin,-beyin,-bezin)
17299  phiin=pyangl(p(mint(84)+1,1),p(mint(84)+1,2))
17300  CALL pyrobo(mint(83)+7,n,0d0,-phiin,0d0,0d0,0d0)
17301  thein=pyangl(p(mint(84)+1,3),p(mint(84)+1,1))
17302  CALL pyrobo(mint(83)+7,n,-thein,0d0,0d0,0d0,0d0)
17303  ENDIF
17304 
17305 C...Reset original resonance configuration.
17306  DO 100 jt=1,8
17307  iref(1,jt)=0
17308  100 CONTINUE
17309 
17310 C...Define initial one, two or three objects for subprocess.
17311  ihdec=0
17312  IF(ires.EQ.0) THEN
17313  isub=mint(1)
17314  IF(iset(isub).EQ.1.OR.iset(isub).EQ.3) THEN
17315  iref(1,1)=mint(84)+2+iset(isub)
17316  iref(1,4)=mint(83)+6+iset(isub)
17317  jtmax=1
17318  ELSEIF(iset(isub).EQ.2.OR.iset(isub).EQ.4) THEN
17319  iref(1,1)=mint(84)+1+iset(isub)
17320  iref(1,2)=mint(84)+2+iset(isub)
17321  iref(1,4)=mint(83)+5+iset(isub)
17322  iref(1,5)=mint(83)+6+iset(isub)
17323  jtmax=2
17324  ELSEIF(iset(isub).EQ.5) THEN
17325  iref(1,1)=mint(84)+3
17326  iref(1,2)=mint(84)+4
17327  iref(1,3)=mint(84)+5
17328  iref(1,4)=mint(83)+7
17329  iref(1,5)=mint(83)+8
17330  iref(1,6)=mint(83)+9
17331  jtmax=3
17332  ENDIF
17333 
17334 C...Define original resonance for odd cases.
17335  ELSE
17336  isub=0
17337  IF(k(ires,2).EQ.25.OR.k(ires,2).EQ.35.OR.k(ires,2).EQ.36)
17338  & ihdec=1
17339  IF(ihdec.EQ.1) isub=3
17340  iref(1,1)=ires
17341  iref(1,4)=k(ires,3)
17342  irestm=ires
17343  IF(iref(1,4).GT.mint(84)) THEN
17344  110 itmpmo=iref(1,4)
17345  IF(k(itmpmo,2).EQ.94) THEN
17346  iref(1,4)=k(itmpmo,3)+(irestm-itmpmo-1)
17347  IF(k(iref(1,4),3).LE.mint(84)) iref(1,4)=k(iref(1,4),3)
17348  ELSEIF(k(itmpmo,2).EQ.k(ires,2)) THEN
17349  irestm=itmpmo
17350 C...Explicitly check that reference particle exists, otherwise stop recursion
17351  IF(itmpmo.GT.0.AND.k(itmpmo,3).GT.0) THEN
17352  iref(1,4)=k(itmpmo,3)
17353  goto 110
17354  ENDIF
17355  ENDIF
17356  ENDIF
17357  IF(iref(1,4).GT.mint(84)) THEN
17358  ematch=1d10
17359  iref14=iref(1,4)
17360  DO 120 ii=mint(83)+7,mint(83)+mint(4)
17361  IF(k(ii,2).EQ.k(ires,2).AND.abs(p(ii,4)-p(iref14,4)).LT.
17362  & ematch) THEN
17363  iref(1,4)=ii
17364  ematch=abs(p(ii,4)-p(iref14,4))
17365  ENDIF
17366  120 CONTINUE
17367  ENDIF
17368  jtmax=1
17369  ENDIF
17370 
17371 C...Check if initial resonance has been moved (in resonance + jet).
17372  DO 140 jt=1,3
17373  IF(iref(1,jt).GT.0) THEN
17374  IF(k(iref(1,jt),1).GT.10) THEN
17375  kfa=iabs(k(iref(1,jt),2))
17376  IF(kfa.GE.6.AND.kchg(pycomp(kfa),2).NE.0) THEN
17377  kda1=mod(k(iref(1,jt),4),mstu(5))
17378  kda2=mod(k(iref(1,jt),5),mstu(5))
17379  IF(kda1.GT.iref(1,jt).AND.kda1.LE.n) THEN
17380  IF(k(kda1,2).EQ.21) kda1=k(kda1,5)/mstu(5)
17381  ENDIF
17382  IF(kda2.GT.iref(1,jt).AND.kda2.LE.n) THEN
17383  IF(k(kda2,2).EQ.21) kda2=k(kda2,4)/mstu(5)
17384  ENDIF
17385  DO 130 i=iref(1,jt)+1,n
17386  IF(k(i,2).EQ.k(iref(1,jt),2).AND.(i.EQ.kda1.OR.
17387  & i.EQ.kda2)) THEN
17388  iref(1,jt)=i
17389  kda1=mod(k(iref(1,jt),4),mstu(5))
17390  kda2=mod(k(iref(1,jt),5),mstu(5))
17391  IF(kda1.GT.iref(1,jt).AND.kda1.LE.n) THEN
17392  IF(k(kda1,2).EQ.21) kda1=k(kda1,5)/mstu(5)
17393  ENDIF
17394  IF(kda2.GT.iref(1,jt).AND.kda2.LE.n) THEN
17395  IF(k(kda2,2).EQ.21) kda2=k(kda2,4)/mstu(5)
17396  ENDIF
17397  ENDIF
17398  130 CONTINUE
17399  ELSE
17400  kda=mod(k(iref(1,jt),4),mstu(5))
17401  IF(mwid(pycomp(kfa)).NE.0.AND.kda.GT.1) iref(1,jt)=kda
17402  ENDIF
17403  ENDIF
17404  ENDIF
17405  140 CONTINUE
17406 
17407 C...Set decay vertex for initial resonances
17408  DO 160 jt=1,jtmax
17409  DO 150 i=1,4
17410  v(iref(1,jt),i)=0d0
17411  150 CONTINUE
17412  160 CONTINUE
17413 
17414 C...Loop over decay history.
17415  np=1
17416  ip=0
17417  170 ip=ip+1
17418  ninh=0
17419  jtmax=2
17420  IF(iref(ip,2).EQ.0) jtmax=1
17421  IF(iref(ip,3).NE.0) jtmax=3
17422  it4=0
17423  nsav=n
17424 
17425 C...Check for Higgs which appears as decay product of user-process.
17426  IF(isub.EQ.0) THEN
17427  ihdec=0
17428  IF(iref(ip,7).EQ.25.OR.iref(ip,7).EQ.35.OR.iref(ip,7)
17429  & .EQ.36) ihdec=1
17430  IF(ihdec.EQ.1) isub=3
17431  ENDIF
17432 
17433 C...Start treatment of one, two or three resonances in parallel.
17434  180 n=nsav
17435  DO 340 jt=1,jtmax
17436  id=iref(ip,jt)
17437  kdcy(jt)=0
17438  kfl1(jt)=0
17439  kfl2(jt)=0
17440  kfl3(jt)=0
17441  kfl4(jt)=0
17442  keql(jt)=0
17443  nsd(jt)=id
17444  itjunc(jt)=0
17445 
17446 C...Check whether particle can/is allowed to decay.
17447  IF(id.EQ.0) goto 330
17448  kfa=iabs(k(id,2))
17449  kca=pycomp(kfa)
17450  IF(mwid(kca).EQ.0) goto 330
17451  IF(k(id,1).GT.10.OR.mdcy(kca,1).EQ.0) goto 330
17452  IF(kfa.EQ.6.OR.kfa.EQ.7.OR.kfa.EQ.8.OR.kfa.EQ.17.OR.
17453  & kfa.EQ.18) it4=it4+1
17454  k(id,4)=mstu(5)*(k(id,4)/mstu(5))
17455  k(id,5)=mstu(5)*(k(id,5)/mstu(5))
17456 
17457 C...Choose lifetime and determine decay vertex.
17458  IF(k(id,1).EQ.5) THEN
17459  v(id,5)=0d0
17460  ELSEIF(k(id,1).NE.4) THEN
17461  v(id,5)=-pmas(kca,4)*log(pyr(0))
17462  ENDIF
17463  DO 190 j=1,4
17464  vdcy(j)=v(id,j)+v(id,5)*p(id,j)/p(id,5)
17465  190 CONTINUE
17466 
17467 C...Determine whether decay allowed or not.
17468  mout=0
17469  IF(mstj(22).EQ.2) THEN
17470  IF(pmas(kca,4).GT.parj(71)) mout=1
17471  ELSEIF(mstj(22).EQ.3) THEN
17472  IF(vdcy(1)**2+vdcy(2)**2+vdcy(3)**2.GT.parj(72)**2) mout=1
17473  ELSEIF(mstj(22).EQ.4) THEN
17474  IF(vdcy(1)**2+vdcy(2)**2.GT.parj(73)**2) mout=1
17475  IF(abs(vdcy(3)).GT.parj(74)) mout=1
17476  ENDIF
17477  IF(mout.EQ.1.AND.k(id,1).NE.5) THEN
17478  k(id,1)=4
17479  goto 330
17480  ENDIF
17481 
17482 C...Info for selection of decay channel: sign, pairings.
17483  IF(kchg(kca,3).EQ.0) THEN
17484  ipm=2
17485  ELSE
17486  ipm=(5-isign(1,k(id,2)))/2
17487  ENDIF
17488  kfb=0
17489  IF(jtmax.EQ.2) THEN
17490  kfb=iabs(k(iref(ip,3-jt),2))
17491  ELSEIF(jtmax.EQ.3) THEN
17492  jt2=jt+1-3*(jt/3)
17493  kfb=iabs(k(iref(ip,jt2),2))
17494  IF(kfb.NE.kfa) THEN
17495  jt2=jt+2-3*((jt+1)/3)
17496  kfb=iabs(k(iref(ip,jt2),2))
17497  ENDIF
17498  ENDIF
17499 
17500 C...Select decay channel.
17501  IF(isub.EQ.1.OR.isub.EQ.15.OR.isub.EQ.19.OR.isub.EQ.22.OR.
17502  & isub.EQ.30.OR.isub.EQ.35.OR.isub.EQ.141) mint(61)=1
17503  CALL pywidt(kfa,p(id,5)**2,wdtp,wdte)
17504  wdte0s=wdte(0,1)+wdte(0,ipm)+wdte(0,4)
17505  IF(kfb.EQ.kfa) wdte0s=wdte0s+wdte(0,5)
17506  IF(wdte0s.LE.0d0) goto 330
17507  rkfl=wdte0s*pyr(0)
17508  idl=0
17509  200 idl=idl+1
17510  idc=idl+mdcy(kca,2)-1
17511  rkfl=rkfl-(wdte(idl,1)+wdte(idl,ipm)+wdte(idl,4))
17512  IF(kfb.EQ.kfa) rkfl=rkfl-wdte(idl,5)
17513  IF(idl.LT.mdcy(kca,3).AND.rkfl.GT.0d0) goto 200
17514 
17515  nprod=0
17516 C...Read out flavours and colour charges of decay channel chosen.
17517  kcqm(jt)=kchg(kca,2)*isign(1,k(id,2))
17518  IF(kcqm(jt).EQ.-2) kcqm(jt)=2
17519  kfl1(jt)=kfdp(idc,1)*isign(1,k(id,2))
17520  kfc1a=pycomp(iabs(kfl1(jt)))
17521  IF(kchg(kfc1a,3).EQ.0) kfl1(jt)=iabs(kfl1(jt))
17522  nprod=nprod+1
17523  kcq1(jt)=kchg(kfc1a,2)*isign(1,kfl1(jt))
17524  IF(kcq1(jt).EQ.-2) kcq1(jt)=2
17525  kfl2(jt)=kfdp(idc,2)*isign(1,k(id,2))
17526  kfc2a=pycomp(iabs(kfl2(jt)))
17527  IF(kchg(kfc2a,3).EQ.0) kfl2(jt)=iabs(kfl2(jt))
17528  kcq2(jt)=kchg(kfc2a,2)*isign(1,kfl2(jt))
17529  IF(kcq2(jt).EQ.-2) kcq2(jt)=2
17530  nprod=nprod+1
17531  kfl3(jt)=kfdp(idc,3)*isign(1,k(id,2))
17532  kcq3(jt)=0
17533  kfl4(jt)=kfdp(idc,4)*isign(1,k(id,2))
17534  kcq4(jt)=0
17535  IF(kfl3(jt).NE.0) THEN
17536  kfc3a=pycomp(iabs(kfl3(jt)))
17537  IF(kchg(kfc3a,3).EQ.0) kfl3(jt)=iabs(kfl3(jt))
17538  kcq3(jt)=kchg(kfc3a,2)*isign(1,kfl3(jt))
17539  IF(kcq3(jt).EQ.-2) kcq3(jt)=2
17540  nprod=nprod+1
17541  IF(kfl4(jt).NE.0) THEN
17542  kfc4a=pycomp(iabs(kfl4(jt)))
17543  IF(kchg(kfc4a,3).EQ.0) kfl4(jt)=iabs(kfl4(jt))
17544  kcq4(jt)=kchg(kfc4a,2)*isign(1,kfl4(jt))
17545  IF(kcq4(jt).EQ.-2) kcq4(jt)=2
17546  nprod=nprod+1
17547  ENDIF
17548  ENDIF
17549 
17550 C...Set/save further info on channel.
17551  kdcy(jt)=1
17552  IF(kfb.EQ.kfa) keql(jt)=mdme(idc,1)
17553  nsd(jt)=n
17554  hgz(jt,1)=vint(111)
17555  hgz(jt,2)=vint(112)
17556  hgz(jt,3)=vint(114)
17557  jtz=jt
17558 
17559  pxsum=0d0
17560 C...Select masses; to begin with assume resonances narrow.
17561  DO 220 i=1,4
17562  p(n+i,5)=0d0
17563  pmmn(i)=0d0
17564  IF(i.EQ.1) THEN
17565  kflw=iabs(kfl1(jt))
17566  kcw=kfc1a
17567  ELSEIF(i.EQ.2) THEN
17568  kflw=iabs(kfl2(jt))
17569  kcw=kfc2a
17570  ELSEIF(i.EQ.3) THEN
17571  IF(kfl3(jt).EQ.0) goto 220
17572  kflw=iabs(kfl3(jt))
17573  kcw=kfc3a
17574  ELSEIF(i.EQ.4) THEN
17575  IF(kfl4(jt).EQ.0) goto 220
17576  kflw=iabs(kfl4(jt))
17577  kcw=kfc4a
17578  ENDIF
17579  p(n+i,5)=pmas(kcw,1)
17580  pxsum=pxsum+p(n+i,5)
17581 CMRENNA++
17582 C...This prevents SUSY/t particles from becoming too light.
17583  IF(kflw/ksusy1.EQ.1.OR.kflw/ksusy1.EQ.2) THEN
17584  pmmn(i)=pmas(kcw,1)
17585  DO 210 idc=mdcy(kcw,2),mdcy(kcw,2)+mdcy(kcw,3)-1
17586  IF(mdme(idc,1).GT.0.AND.brat(idc).GT.1e-4) THEN
17587  pmsum=pmas(pycomp(kfdp(idc,1)),1)+
17588  & pmas(pycomp(kfdp(idc,2)),1)
17589  IF(kfdp(idc,3).NE.0) pmsum=pmsum+
17590  & pmas(pycomp(kfdp(idc,3)),1)
17591  IF(kfdp(idc,4).NE.0) pmsum=pmsum+
17592  & pmas(pycomp(kfdp(idc,4)),1)
17593  pmmn(i)=min(pmmn(i),pmsum)
17594  ENDIF
17595  210 CONTINUE
17596 C MRENNA--
17597  ELSEIF(kflw.EQ.6) THEN
17598  pmmn(i)=pmas(24,1)+pmas(5,1)
17599  ENDIF
17600 C...UED: select a graviton mass from continuous distribution
17601 C...(stored in PMAS(39,1) so no value returned)
17602  IF (iued(1).EQ.1.AND.iued(2).EQ.1.AND.kflw.EQ.39)
17603  & CALL pygram(1)
17604  220 CONTINUE
17605 
17606 C...Check which two out of three are widest.
17607  iwid1=1
17608  iwid2=2
17609  pwid1=pmas(kfc1a,2)
17610  pwid2=pmas(kfc2a,2)
17611  kflw1=iabs(kfl1(jt))
17612  kflw2=iabs(kfl2(jt))
17613  IF(kfl3(jt).NE.0) THEN
17614  pwid3=pmas(kfc3a,2)
17615  IF(pwid3.GT.pwid1.AND.pwid2.GE.pwid1) THEN
17616  iwid1=3
17617  pwid1=pwid3
17618  kflw1=iabs(kfl3(jt))
17619  ELSEIF(pwid3.GT.pwid2) THEN
17620  iwid2=3
17621  pwid2=pwid3
17622  kflw2=iabs(kfl3(jt))
17623  ENDIF
17624  ENDIF
17625  IF(kfl4(jt).NE.0) THEN
17626  pwid4=pmas(kfc4a,2)
17627  IF(pwid4.GT.pwid1.AND.pwid2.GE.pwid1) THEN
17628  iwid1=4
17629  pwid1=pwid4
17630  kflw1=iabs(kfl4(jt))
17631  ELSEIF(pwid4.GT.pwid2) THEN
17632  iwid2=4
17633  pwid2=pwid4
17634  kflw2=iabs(kfl4(jt))
17635  ENDIF
17636  ENDIF
17637 
17638 C...If all narrow then only check that masses consistent.
17639  IF(mstp(42).LE.0.OR.(pwid1.LT.parp(41).AND.
17640  & pwid2.LT.parp(41))) THEN
17641 CMRENNA++
17642 C....Handle near degeneracy cases.
17643  IF(kfa/ksusy1.EQ.1.OR.kfa/ksusy1.EQ.2) THEN
17644  IF(p(n+1,5)+p(n+2,5)+p(n+3,5).GT.p(id,5)) THEN
17645  p(n+1,5)=p(id,5)-p(n+2,5)-0.5d0
17646  IF(p(n+1,5).LT.0d0) p(n+1,5)=0d0
17647  ENDIF
17648  ENDIF
17649 CMRENNA--
17650  IF(pxsum.GT.p(id,5)) THEN
17651  CALL pyerrm(13,'(PYRESD:) daughter masses too large')
17652  mint(51)=1
17653  goto 720
17654  ELSEIF(pxsum+parj(64).GT.p(id,5)) THEN
17655  CALL pyerrm(3,'(PYRESD:) masses+PARJ(64) too large')
17656  mint(51)=1
17657  goto 720
17658  ENDIF
17659 
17660 C...For three wide resonances select narrower of three
17661 C...according to BW decoupled from rest.
17662  ELSE
17663  pmtot=p(id,5)
17664  IF(kfl3(jt).NE.0) THEN
17665  iwid3=6-iwid1-iwid2
17666  kflw3=iabs(kfl1(jt))+iabs(kfl2(jt))+iabs(kfl3(jt))-
17667  & kflw1-kflw2
17668  loop=0
17669  230 loop=loop+1
17670  p(n+iwid3,5)=pymass(kflw3)
17671  IF(loop.LE.10.AND. p(n+iwid3,5).LE.pmmn(iwid3)) goto 230
17672  pmtot=pmtot-p(n+iwid3,5)
17673  ENDIF
17674 C...Select other two correlated within remaining phase space.
17675  IF(ip.EQ.1) THEN
17676  ckin45=ckin(45)
17677  ckin47=ckin(47)
17678  ckin(45)=max(pmmn(iwid1),ckin(45))
17679  ckin(47)=max(pmmn(iwid2),ckin(47))
17680  CALL pyofsh(2,kfa,kflw1,kflw2,pmtot,p(n+iwid1,5),
17681  & p(n+iwid2,5))
17682  ckin(45)=ckin45
17683  ckin(47)=ckin47
17684  ELSE
17685  ckin(49)=pmmn(iwid1)
17686  ckin(50)=pmmn(iwid2)
17687  CALL pyofsh(5,kfa,kflw1,kflw2,pmtot,p(n+iwid1,5),
17688  & p(n+iwid2,5))
17689  ckin(49)=0d0
17690  ckin(50)=0d0
17691  ENDIF
17692  IF(mint(51).EQ.1) goto 720
17693  ENDIF
17694 
17695 C...Begin fill decay products, with colour flow for coloured objects.
17696  mstu10=mstu(10)
17697  mstu(10)=1
17698  mstu(19)=1
17699 
17700 
17701 C...Three-body decays
17702  IF(kfl3(jt).NE.0.OR.kfl4(jt).NE.0) THEN
17703  DO 250 i=n+1,n+nprod
17704  DO 240 j=1,5
17705  k(i,j)=0
17706  v(i,j)=0d0
17707  240 CONTINUE
17708  mct(i,1)=0
17709  mct(i,2)=0
17710  250 CONTINUE
17711  k(n+1,1)=1
17712  k(n+1,2)=kfl1(jt)
17713  k(n+2,1)=1
17714  k(n+2,2)=kfl2(jt)
17715  k(n+3,1)=1
17716  k(n+3,2)=kfl3(jt)
17717  IF(kfl4(jt).NE.0) THEN
17718  k(n+4,1)=1
17719  k(n+4,2)=kfl4(jt)
17720  ENDIF
17721  idin=id
17722 
17723 C...Generate kinematics (default is flat)
17724  IF(kfl4(jt).EQ.0) THEN
17725  CALL pytbdy(idin)
17726  ELSE
17727  ps=p(n+1,5)+p(n+2,5)+p(n+3,5)+p(n+4,5)
17728  nd=4
17729  pv(1,1)=0d0
17730  pv(1,2)=0d0
17731  pv(1,3)=0d0
17732  pv(1,4)=p(idin,5)
17733  pv(1,5)=p(idin,5)
17734 C...Calculate maximum weight ND-particle decay.
17735  pv(nd,5)=p(n+nd,5)
17736  wtmax=1d0/wtcor(nd-2)
17737  pmax=pv(1,5)-ps+p(n+nd,5)
17738  pmin=0d0
17739  DO 381 il=nd-1,1,-1
17740  pmax=pmax+p(n+il,5)
17741  pmin=pmin+p(n+il+1,5)
17742  wtmax=wtmax*pawt(pmax,pmin,p(n+il,5))
17743  381 CONTINUE
17744 
17745 C...M-generator gives weight. If rejected, try again.
17746 
17747  411 rord(1)=1d0
17748  DO 441 il1=2,nd-1
17749  rsav=pyr(0)
17750  DO 421 il2=il1-1,1,-1
17751  IF(rsav.LE.rord(il2)) goto 431
17752  rord(il2+1)=rord(il2)
17753  421 CONTINUE
17754  431 rord(il2+1)=rsav
17755  441 CONTINUE
17756  rord(nd)=0d0
17757  wt=1d0
17758  DO 451 il=nd-1,1,-1
17759  pv(il,5)=pv(il+1,5)+p(n+il,5)+(rord(il)-rord(il+1))*
17760  & (pv(1,5)-ps)
17761  wt=wt*pawt(pv(il,5),pv(il+1,5),p(n+il,5))
17762  451 CONTINUE
17763  IF(wt.LT.pyr(0)*wtmax) goto 411
17764 
17765 C...Perform two-particle decays in respective CM frame.
17766  DO 481 il=1,nd-1
17767  pa=pawt(pv(il,5),pv(il+1,5),p(n+il,5))
17768  ue(3)=2d0*pyr(0)-1d0
17769  phix=paru(2)*pyr(0)
17770  ue(1)=sqrt(1d0-ue(3)**2)*cos(phix)
17771  ue(2)=sqrt(1d0-ue(3)**2)*sin(phix)
17772  DO 471 j=1,3
17773  p(n+il,j)=pa*ue(j)
17774  pv(il+1,j)=-pa*ue(j)
17775  471 CONTINUE
17776  p(n+il,4)=sqrt(pa**2+p(n+il,5)**2)
17777  pv(il+1,4)=sqrt(pa**2+pv(il+1,5)**2)
17778  481 CONTINUE
17779 
17780 C...Lorentz transform decay products to lab frame.
17781  DO 491 j=1,4
17782  p(n+nd,j)=pv(nd,j)
17783  491 CONTINUE
17784  DO 531 il=nd-1,1,-1
17785  DO 501 j=1,3
17786  be(j)=pv(il,j)/pv(il,4)
17787  501 CONTINUE
17788  ga=pv(il,4)/pv(il,5)
17789  DO 521 i=n+il,n+nd
17790  bep=be(1)*p(i,1)+be(2)*p(i,2)+be(3)*p(i,3)
17791  DO 511 j=1,3
17792  p(i,j)=p(i,j)+ga*(ga*bep/(1d0+ga)+p(i,4))*be(j)
17793  511 CONTINUE
17794  p(i,4)=ga*(p(i,4)+bep)
17795  521 CONTINUE
17796  531 CONTINUE
17797 
17798  ENDIF
17799 
17800 C...Set generic colour flows whenever unambiguous,
17801 C...(independently of the order of the decay products)
17802 C...Sum up total colour content
17803  nant=0
17804  ntri=0
17805  noct=0
17806  kcq(0)=kcqm(jt)
17807  kcq(1)=kcq1(jt)
17808  kcq(2)=kcq2(jt)
17809  kcq(3)=kcq3(jt)
17810  kcq(4)=kcq4(jt)
17811  DO 255 j=0,nprod
17812  IF (kcq(j).EQ.-1) THEN
17813  nant=nant+1
17814  iant(nant)=n+j
17815  ELSEIF (kcq(j).EQ.1) THEN
17816  ntri=ntri+1
17817  itri(ntri)=n+j
17818  ELSEIF (kcq(j).EQ.2) THEN
17819  noct=noct+1
17820  ioct(noct)=n+j
17821  ENDIF
17822  255 CONTINUE
17823 
17824 C...Set color flow for generic 1 -> N processes (N arbitrary)
17825  IF (ntri.EQ.0.AND.nant.EQ.0.AND.noct.EQ.0) THEN
17826 C...All singlets: do nothing
17827 
17828  ELSEIF (noct.EQ.2.AND.ntri.EQ.0.AND.nant.EQ.0) THEN
17829 C...Two octets, zero triplets, n singlets:
17830  IF (kcq(0).EQ.2) THEN
17831 C...8 -> 8 + n(1)
17832  k(id,4)=k(id,4)+ioct(2)
17833  k(id,5)=k(id,5)+ioct(2)
17834  k(ioct(2),1)=3
17835  k(ioct(2),4)=mstu(5)*id
17836  k(ioct(2),5)=mstu(5)*id
17837  mct(ioct(2),1)=mct(id,1)
17838  mct(ioct(2),2)=mct(id,2)
17839  ELSE
17840 C...1 -> 8 + 8 + n(1)
17841  k(ioct(1),1)=3
17842  k(ioct(1),4)=mstu(5)*ioct(2)
17843  k(ioct(1),5)=mstu(5)*ioct(2)
17844  k(ioct(2),1)=3
17845  k(ioct(2),4)=mstu(5)*ioct(1)
17846  k(ioct(2),5)=mstu(5)*ioct(1)
17847  nct=nct+1
17848  mct(ioct(1),1)=nct
17849  mct(ioct(2),2)=nct
17850  nct=nct+1
17851  mct(ioct(2),1)=nct
17852  mct(ioct(1),2)=nct
17853  ENDIF
17854 
17855  ELSEIF (ntri+nant.EQ.2.AND.noct.EQ.0) THEN
17856 C...Two triplets, zero octets, n singlets.
17857  IF (kcq(0).EQ.1) THEN
17858 C...3 -> 3 + n(1)
17859  k(id,4)=k(id,4)+itri(2)
17860  k(itri(2),1)=3
17861  k(itri(2),4)=mstu(5)*id
17862  mct(itri(2),1)=mct(id,1)
17863  ELSEIF (kcq(0).EQ.-1) THEN
17864 C...3bar -> 3bar + n(1)
17865  k(id,5)=k(id,5)+iant(2)
17866  k(iant(2),1)=3
17867  k(iant(2),5)=mstu(5)*id
17868  mct(iant(2),2)=mct(id,2)
17869  ELSE
17870 C...1 -> 3 + 3bar + n(1)
17871  k(itri(1),1)=3
17872  k(itri(1),4)=mstu(5)*iant(1)
17873  k(iant(1),1)=3
17874  k(iant(1),5)=mstu(5)*itri(1)
17875  nct=nct+1
17876  mct(itri(1),1)=nct
17877  mct(iant(1),2)=nct
17878  ENDIF
17879 
17880  ELSEIF(ntri+nant.EQ.2.AND.noct.EQ.1) THEN
17881 C...Two triplets, one octet, n singlets.
17882  IF (kcq(0).EQ.2) THEN
17883 C...8 -> 3 + 3bar + n(1)
17884  k(id,4)=k(id,4)+itri(1)
17885  k(id,5)=k(id,5)+iant(1)
17886  k(itri(1),1)=3
17887  k(itri(1),4)=mstu(5)*id
17888  k(iant(1),1)=3
17889  k(iant(1),5)=mstu(5)*id
17890  mct(itri(1),1)=mct(id,1)
17891  mct(iant(1),2)=mct(id,2)
17892  ELSEIF (kcq(0).EQ.1) THEN
17893 C...3 -> 8 + 3 + n(1)
17894  k(id,4)=k(id,4)+ioct(1)
17895  k(ioct(1),1)=3
17896  k(ioct(1),4)=mstu(5)*id
17897  k(ioct(1),5)=mstu(5)*itri(2)
17898  k(itri(2),1)=3
17899  k(itri(2),4)=mstu(5)*ioct(1)
17900  mct(ioct(1),1)=mct(id,1)
17901  nct=nct+1
17902  mct(ioct(1),2)=nct
17903  mct(itri(2),1)=nct
17904  ELSEIF (kcq(0).EQ.-1) THEN
17905 C...3bar -> 8 + 3bar + n(1)
17906  k(id,5)=k(id,5)+ioct(1)
17907  k(ioct(1),1)=3
17908  k(ioct(1),5)=mstu(5)*id
17909  k(ioct(1),4)=mstu(5)*iant(2)
17910  k(iant(2),1)=3
17911  k(iant(2),5)=mstu(5)*ioct(1)
17912  mct(ioct(1),2)=mct(id,2)
17913  nct=nct+1
17914  mct(ioct(1),1)=nct
17915  mct(iant(2),2)=nct
17916  ELSE
17917 C...1 -> 3 + 3bar + 8 + n(1)
17918  k(itri(1),1)=3
17919  k(itri(1),4)=mstu(5)*ioct(1)
17920  k(ioct(1),1)=3
17921  k(ioct(1),5)=mstu(5)*itri(1)
17922  k(ioct(1),4)=mstu(5)*iant(1)
17923  k(iant(1),1)=3
17924  k(iant(1),5)=mstu(5)*ioct(1)
17925  nct=nct+1
17926  mct(itri(1),1)=nct
17927  mct(ioct(1),2)=nct
17928  nct=nct+1
17929  mct(ioct(1),1)=nct
17930  mct(iant(1),2)=nct
17931  ENDIF
17932  ELSEIF(ntri+nant.EQ.4) THEN
17933 C...
17934  IF (kcq(0).EQ.1) THEN
17935 C...3 -> 3 + n(1) -> 3 + 3bar
17936  k(id,4)=k(id,4)+itri(2)
17937  k(itri(2),1)=3
17938  k(itri(2),4)=mstu(5)*id
17939  mct(itri(2),1)=mct(id,1)
17940  k(itri(3),1)=3
17941  k(itri(3),4)=mstu(5)*iant(1)
17942  k(iant(1),1)=3
17943  k(iant(1),5)=mstu(5)*itri(3)
17944  nct=nct+1
17945  mct(itri(3),1)=nct
17946  mct(iant(1),2)=nct
17947  ELSEIF (kcq(0).EQ.-1) THEN
17948 C...3bar -> 3bar + n(1) -> 3 + 3bar
17949  k(id,5)=k(id,5)+iant(2)
17950  k(iant(2),1)=3
17951  k(iant(2),5)=mstu(5)*id
17952  mct(iant(2),2)=mct(id,2)
17953  k(itri(1),1)=3
17954  k(itri(1),4)=mstu(5)*iant(3)
17955  k(iant(3),1)=3
17956  k(iant(3),5)=mstu(5)*itri(1)
17957  nct=nct+1
17958  mct(itri(1),1)=nct
17959  mct(iant(3),2)=nct
17960  ENDIF
17961  ELSEIF(kfl4(jt).NE.0) THEN
17962  CALL pyerrm(21,'(PYRESD:) unknown 4-bdy decay')
17963 CPS-- End of generic cases
17964 C...(could three octets also be handled?)
17965 C...(could (some of) the RPV cases be made generic as well?)
17966 
17967 C...Special cases (= old treatment)
17968 C...Set colour flow for t -> W + b + Z.
17969  ELSEIF(kfa.EQ.6) THEN
17970  k(n+2,1)=3
17971  isid=4
17972  IF(kcqm(jt).EQ.-1) isid=5
17973  idau=n+2
17974  k(id,isid)=k(id,isid)+idau
17975  k(idau,isid)=mstu(5)*id
17976 
17977 C...Set colour flow in three-body decays - programmed as special cases.
17978 
17979  ELSEIF(kfc2a.LE.6) THEN
17980  k(n+2,1)=3
17981  k(n+3,1)=3
17982  isid=4
17983  IF(kfl2(jt).LT.0) isid=5
17984  k(n+2,isid)=mstu(5)*(n+3)
17985  k(n+3,9-isid)=mstu(5)*(n+2)
17986 C...PS++: Bugfix 16 MAR 2006 for 3-body squark decays (e.g. via SLHA)
17987  ELSEIF(kfa.GT.ksusy1.AND.mod(kfa,ksusy1).LT.10
17988  & .AND.kfl3(jt).NE.0) THEN
17989  kqsuma=iabs(kcq1(jt))+iabs(kcq2(jt))+iabs(kcq3(jt))
17990 C...3-body decays of squarks to colour singlets plus one quark
17991  IF (kqsuma.EQ.1) THEN
17992 C...Find quark
17993  iq=0
17994  IF (kcq1(jt).NE.0) iq=1
17995  IF (kcq2(jt).NE.0) iq=2
17996  IF (kcq3(jt).NE.0) iq=3
17997  isid=4
17998  IF (k(n+iq,2).LT.0) isid=5
17999  k(n+iq,1)=3
18000  k(id,isid)=k(id,isid)+(n+iq)
18001  k(n+iq,isid)=mstu(5)*id
18002  ENDIF
18003 C...PS--
18004  ELSEIF(kfl1(jt).EQ.ksusy1+21) THEN
18005  k(n+1,1)=3
18006  k(n+2,1)=3
18007  k(n+3,1)=3
18008  isid=4
18009  IF(kfl2(jt).LT.0) isid=5
18010  k(n+1,isid)=mstu(5)*(n+2)
18011  k(n+1,9-isid)=mstu(5)*(n+3)
18012  k(n+2,isid)=mstu(5)*(n+1)
18013  k(n+3,9-isid)=mstu(5)*(n+1)
18014  ELSEIF(kfa.EQ.ksusy1+21) THEN
18015  k(n+2,1)=3
18016  k(n+3,1)=3
18017  isid=4
18018  IF(kfl2(jt).LT.0) isid=5
18019  k(id,isid)=k(id,isid)+(n+2)
18020  k(id,9-isid)=k(id,9-isid)+(n+3)
18021  k(n+2,isid)=mstu(5)*id
18022  k(n+3,9-isid)=mstu(5)*id
18023 CMRENNA--
18024 
18025  ELSEIF(kfa.GE.ksusy1+22.AND.kfa.LE.ksusy1+37.AND.
18026  & iabs(kcq2(jt)).EQ.1) THEN
18027  k(n+2,1)=3
18028  k(n+3,1)=3
18029  isid=4
18030  IF(kfl2(jt).LT.0) isid=5
18031  k(n+2,isid)=mstu(5)*(n+3)
18032  k(n+3,9-isid)=mstu(5)*(n+2)
18033  ENDIF
18034 
18035  nsav=n
18036 
18037 C...Set colour flow in three-body decays with baryon number violation.
18038 C...Neutralino and chargino decays first.
18039  kcqsum=kcq1(jt)+kcq2(jt)+kcq3(jt)
18040  IF(kcqm(jt).EQ.0.AND.iabs(kcqsum).EQ.3) THEN
18041  itjunc(jt)=(1+(1-kcq1(jt))/2)
18042  k(n+4,4)=itjunc(jt)*mstu(5)
18043 C...Insert junction to keep track of colours.
18044  IF(kcq1(jt).NE.0) k(n+1,1)=3
18045  IF(kcq2(jt).NE.0) k(n+2,1)=3
18046  IF(kcq3(jt).NE.0) k(n+3,1)=3
18047 C...Set special junction codes:
18048  k(n+4,1)=42
18049  k(n+4,2)=88
18050 
18051 C...Order decay products by invariant mass. (will be used in PYSTRF).
18052  pm12=p(n+1,4)*p(n+2,4)-p(n+1,1)*p(n+2,1)-p(n+1,2)*p(n+2,2)-
18053  & p(n+1,3)*p(n+2,3)
18054  pm13=p(n+1,4)*p(n+3,4)-p(n+1,1)*p(n+3,1)-p(n+1,2)*p(n+3,2)-
18055  & p(n+1,3)*p(n+3,3)
18056  pm23=p(n+2,4)*p(n+3,4)-p(n+2,1)*p(n+3,1)-p(n+2,2)*p(n+3,2)-
18057  & p(n+2,3)*p(n+3,3)
18058  IF(pm12.LT.pm13.AND.pm12.LT.pm23) THEN
18059  k(n+4,4)=n+3+k(n+4,4)
18060  k(n+4,5)=n+1+mstu(5)*(n+2)
18061  ELSEIF(pm13.LT.pm23) THEN
18062  k(n+4,4)=n+2+k(n+4,4)
18063  k(n+4,5)=n+1+mstu(5)*(n+3)
18064  ELSE
18065  k(n+4,4)=n+1+k(n+4,4)
18066  k(n+4,5)=n+2+mstu(5)*(n+3)
18067  ENDIF
18068  DO 260 j=1,5
18069  p(n+4,j)=0d0
18070  v(n+4,j)=0d0
18071  260 CONTINUE
18072 C...Connect daughters to junction.
18073  DO 270 ii=n+1,n+3
18074  k(ii,4)=0
18075  k(ii,5)=0
18076  k(ii,itjunc(jt)+3)=mstu(5)*(n+4)
18077  270 CONTINUE
18078 C...Particle counter should be stepped up one extra for junction.
18079  n=n+1
18080 
18081 C...Gluino decays.
18082  ELSEIF (kcqm(jt).EQ.2.AND.iabs(kcqsum).EQ.3) THEN
18083  itjunc(jt)=(5+(1-kcq1(jt))/2)
18084  k(n+4,4)=itjunc(jt)*mstu(5)
18085 C...Insert junction to keep track of colours.
18086  IF(kcq1(jt).NE.0) k(n+1,1)=3
18087  IF(kcq2(jt).NE.0) k(n+2,1)=3
18088  IF(kcq3(jt).NE.0) k(n+3,1)=3
18089  k(n+4,1)=42
18090  k(n+4,2)=88
18091  DO 280 j=1,5
18092  p(n+4,j)=0d0
18093  v(n+4,j)=0d0
18094  280 CONTINUE
18095  ctmsum=0d0
18096  DO 290 ii=n+1,n+3
18097  k(ii,4)=0
18098  k(ii,5)=0
18099 C...Start by connecting all daughters to junction.
18100  k(ii,itjunc(jt)-1)=mstu(5)*(n+4)
18101 C...Only consider colour topologies with off shell resonances.
18102  rmq1=pmas(pycomp(k(ii,2)),1)
18103  rmres=pmas(pycomp(ksusy1+iabs(k(ii,2))),1)
18104  rmglu=pmas(pycomp(ksusy1+21),1)
18105  IF (rmglu-rmq1.LT.rmres) THEN
18106 C...Calculate propagators for each colour topology.
18107  rm2q23=rmglu**2+rmq1**2-2d0*(p(ii,4)*p(id,4)+p(ii,1)
18108  & *p(id,1)+p(ii,2)*p(id,2)+p(ii,3)*p(id,3))
18109  ctm2(ii-n)=1d0/(rm2q23-rmres**2)**2
18110  ELSE
18111  ctm2(ii-n)=0d0
18112  ENDIF
18113  ctmsum=ctmsum+ctm2(ii-n)
18114  290 CONTINUE
18115  ctmsum=pyr(0)*ctmsum
18116 C...Select colour topology J, with most off shell least likely.
18117  j=0
18118  300 j=j+1
18119  ctmsum=ctmsum-ctm2(j)
18120  IF (ctmsum.GT.0d0) goto 300
18121 C...The lucky winner gets its colour (anti-colour) directly from gluino.
18122  k(n+j,itjunc(jt)-1)=mstu(5)*id
18123  k(id,itjunc(jt)-1)=n+j+(k(id,itjunc(jt)-1)/mstu(5))*mstu(5)
18124 C...The other gluino colour is connected to junction
18125  k(id,10-itjunc(jt))=n+4+(k(id,10-itjunc(jt))/mstu(5))*
18126  & mstu(5)
18127  k(n+4,4)=k(n+4,4)+id
18128 C...Lastly, connect junction to remaining daughters.
18129  k(n+4,5)=n+1+mod(j,3)+mstu(5)*(n+1+mod(j+1,3))
18130 C...Particle counter should be stepped up one extra for junction.
18131  n=n+1
18132  ENDIF
18133 
18134 C...Update particle counter.
18135  n=n+nprod
18136 
18137 C...2) Everything else two-body decay.
18138  ELSE
18139  CALL py2ent(n+1,kfl1(jt),kfl2(jt),p(id,5))
18140  mct(n-1,1)=0
18141  mct(n-1,2)=0
18142  mct(n,1)=0
18143  mct(n,2)=0
18144 C...First set colour flow as if mother colour singlet.
18145  IF(kcq1(jt).NE.0) THEN
18146  k(n-1,1)=3
18147  IF(kcq1(jt).NE.-1) k(n-1,4)=mstu(5)*n
18148  IF(kcq1(jt).NE.1) k(n-1,5)=mstu(5)*n
18149  ENDIF
18150  IF(kcq2(jt).NE.0) THEN
18151  k(n,1)=3
18152  IF(kcq2(jt).NE.-1) k(n,4)=mstu(5)*(n-1)
18153  IF(kcq2(jt).NE.1) k(n,5)=mstu(5)*(n-1)
18154  ENDIF
18155 C...Then redirect colour flow if mother (anti)triplet.
18156  IF(kcqm(jt).EQ.0) THEN
18157  ELSEIF(kcqm(jt).NE.2) THEN
18158  isid=4
18159  IF(kcqm(jt).EQ.-1) isid=5
18160  idau=n-1
18161  IF(kcq1(jt).EQ.0.OR.kcq2(jt).EQ.2) idau=n
18162  k(id,isid)=k(id,isid)+idau
18163  k(idau,isid)=mstu(5)*id
18164 C...Then redirect colour flow if mother octet.
18165  ELSEIF(kcq1(jt).EQ.0.OR.kcq2(jt).EQ.0) THEN
18166  idau=n-1
18167  IF(kcq1(jt).EQ.0) idau=n
18168  k(id,4)=k(id,4)+idau
18169  k(id,5)=k(id,5)+idau
18170  k(idau,4)=mstu(5)*id
18171  k(idau,5)=mstu(5)*id
18172  ELSE
18173  isid=4
18174  IF(kcq1(jt).EQ.-1) isid=5
18175  IF(kcq1(jt).EQ.2) isid=int(4.5d0+pyr(0))
18176  k(id,isid)=k(id,isid)+(n-1)
18177  k(id,9-isid)=k(id,9-isid)+n
18178  k(n-1,isid)=mstu(5)*id
18179  k(n,9-isid)=mstu(5)*id
18180  ENDIF
18181 
18182 C...Insert junction
18183  IF(iabs(kcq1(jt)+kcq2(jt)-kcqm(jt)).EQ.3) THEN
18184  n=n+1
18185 C...~q* mother: type 3 junction. ~q mother: type 4.
18186  itjunc(jt)=(7+kcqm(jt))/2
18187 C...Specify junction KF and set colour flow from junction
18188  k(n,1)=42
18189  k(n,2)=88
18190  k(n,3)=id
18191 C...Junction type encoded together with mother:
18192  k(n,4)=id+itjunc(jt)*mstu(5)
18193  k(n,5)=n-1+mstu(5)*(n-2)
18194 C...Zero P and V for junction (V filled later)
18195  DO 310 j=1,5
18196  p(n,j)=0d0
18197  v(n,j)=0d0
18198  310 CONTINUE
18199 C...Set colour flow from mother to junction
18200  k(id,8-itjunc(jt))= n + mstu(5)*(k(id,8-itjunc(jt))/mstu(5))
18201 C...Set colour flow from daughters to junction
18202  DO 320 ii=n-2,n-1
18203  k(ii,4) = 0
18204  k(ii,5) = 0
18205 C...(Anti-)colour mother is junction.
18206  k(ii,1+itjunc(jt)) = mstu(5)*n
18207  320 CONTINUE
18208  ENDIF
18209  ENDIF
18210 
18211 C...End loop over resonances for daughter flavour and mass selection.
18212  mstu(10)=mstu10
18213  330 IF(mwid(kca).NE.0.AND.(kfl1(jt).EQ.0.OR.kfl3(jt).NE.0))
18214  & ninh=ninh+1
18215  IF(ires.GT.0.AND.mwid(kca).NE.0.AND.mdcy(kca,1).NE.0.AND.
18216  & kfl1(jt).EQ.0) THEN
18217  WRITE(code,'(I9)') k(id,2)
18218  WRITE(mass,'(F9.3)') p(id,5)
18219  CALL pyerrm(3,'(PYRESD:) Failed to decay particle'//
18220  & code//' with mass'//mass)
18221  mint(51)=1
18222  goto 720
18223  ENDIF
18224  340 CONTINUE
18225 
18226 C...Check for allowed combinations. Skip if no decays.
18227  IF(jtmax.EQ.1) THEN
18228  IF(kdcy(1).EQ.0) goto 710
18229  ELSEIF(jtmax.EQ.2) THEN
18230  IF(kdcy(1).EQ.0.AND.kdcy(2).EQ.0) goto 710
18231  IF(keql(1).EQ.4.AND.keql(2).EQ.4) goto 180
18232  IF(keql(1).EQ.5.AND.keql(2).EQ.5) goto 180
18233  ELSEIF(jtmax.EQ.3) THEN
18234  IF(kdcy(1).EQ.0.AND.kdcy(2).EQ.0.AND.kdcy(3).EQ.0) goto 710
18235  IF(keql(1).EQ.4.AND.keql(2).EQ.4) goto 180
18236  IF(keql(1).EQ.4.AND.keql(3).EQ.4) goto 180
18237  IF(keql(2).EQ.4.AND.keql(3).EQ.4) goto 180
18238  IF(keql(1).EQ.5.AND.keql(2).EQ.5) goto 180
18239  IF(keql(1).EQ.5.AND.keql(3).EQ.5) goto 180
18240  IF(keql(2).EQ.5.AND.keql(3).EQ.5) goto 180
18241  ENDIF
18242 
18243 C...Special case: matrix element option for Z0 decay to quarks.
18244  IF(mstp(48).EQ.1.AND.isub.EQ.1.AND.jtmax.EQ.1.AND.
18245  &iabs(mint(11)).EQ.11.AND.iabs(kfl1(1)).LE.5) THEN
18246 
18247 C...Check consistency of MSTJ options set.
18248  IF(mstj(109).EQ.2.AND.mstj(110).NE.1) THEN
18249  CALL pyerrm(6,
18250  & '(PYRESD:) MSTJ(109) value requires MSTJ(110) = 1')
18251  mstj(110)=1
18252  ENDIF
18253  IF(mstj(109).EQ.2.AND.mstj(111).NE.0) THEN
18254  CALL pyerrm(6,
18255  & '(PYRESD:) MSTJ(109) value requires MSTJ(111) = 0')
18256 
18257  mstj(111)=0
18258  ENDIF
18259 
18260 C...Select alpha_strong behaviour.
18261  mst111=mstu(111)
18262  par112=paru(112)
18263  mstu(111)=mstj(108)
18264  IF(mstj(108).EQ.2.AND.(mstj(101).EQ.0.OR.mstj(101).EQ.1))
18265  & mstu(111)=1
18266  paru(112)=parj(121)
18267  IF(mstu(111).EQ.2) paru(112)=parj(122)
18268 
18269 C...Find axial fraction in total cross section for scalar gluon model.
18270  parj(171)=0d0
18271  IF((iabs(mstj(101)).EQ.1.AND.mstj(109).EQ.1).OR.
18272  & (mstj(101).EQ.5.AND.mstj(49).EQ.1)) THEN
18273  poll=1d0-parj(131)*parj(132)
18274  sff=1d0/(16d0*xw*xw1)
18275  sfw=p(id,5)**4/((p(id,5)**2-parj(123)**2)**2+
18276  & (parj(123)*parj(124))**2)
18277  sfi=sfw*(1d0-(parj(123)/p(id,5))**2)
18278  ve=4d0*xw-1d0
18279  hf1i=sfi*sff*(ve*poll+parj(132)-parj(131))
18280  hf1w=sfw*sff**2*((ve**2+1d0)*poll+2d0*ve*
18281  & (parj(132)-parj(131)))
18282  kflc=iabs(kfl1(1))
18283  pmq=pymass(kflc)
18284  qf=kchg(kflc,1)/3d0
18285  vq=1d0
18286  IF(mod(mstj(103),2).EQ.1) vq=sqrt(max(0d0,
18287  & 1d0-(2d0*pmq/p(id,5))**2))
18288  vf=sign(1d0,qf)-4d0*qf*xw
18289  rfv=0.5d0*vq*(3d0-vq**2)*(qf**2*poll-2d0*qf*vf*hf1i+
18290  & vf**2*hf1w)+vq**3*hf1w
18291  IF(rfv.GT.0d0) parj(171)=min(1d0,vq**3*hf1w/rfv)
18292  ENDIF
18293 
18294 C...Choice of jet configuration.
18295  CALL pyxjet(p(id,5),njet,cut)
18296  kflc=iabs(kfl1(1))
18297  kfln=21
18298  IF(njet.EQ.4) THEN
18299  CALL pyx4jt(njet,cut,kflc,p(id,5),kfln,x1,x2,x4,x12,x14)
18300  ELSEIF(njet.EQ.3) THEN
18301  CALL pyx3jt(njet,cut,kflc,p(id,5),x1,x3)
18302  ELSE
18303  mstj(120)=1
18304  ENDIF
18305 
18306 C...Fill jet configuration; return if incorrect kinematics.
18307  nc=n-2
18308  IF(njet.EQ.2.AND.mstj(101).NE.5) THEN
18309  CALL py2ent(nc+1,kflc,-kflc,p(id,5))
18310  ELSEIF(njet.EQ.2) THEN
18311  CALL py2ent(-(nc+1),kflc,-kflc,p(id,5))
18312  ELSEIF(njet.EQ.3) THEN
18313  CALL py3ent(nc+1,kflc,21,-kflc,p(id,5),x1,x3)
18314  ELSEIF(kfln.EQ.21) THEN
18315  CALL py4ent(nc+1,kflc,kfln,kfln,-kflc,p(id,5),x1,x2,x4,
18316  & x12,x14)
18317  ELSE
18318  CALL py4ent(nc+1,kflc,-kfln,kfln,-kflc,p(id,5),x1,x2,x4,
18319  & x12,x14)
18320  ENDIF
18321  IF(mstu(24).NE.0) THEN
18322  mint(51)=1
18323  mstu(111)=mst111
18324  paru(112)=par112
18325  goto 720
18326  ENDIF
18327 
18328 C...Angular orientation according to matrix element.
18329  IF(mstj(106).EQ.1) THEN
18330  CALL pyxdif(nc,njet,kflc,p(id,5),chiz,thez,phiz)
18331  IF(mint(11).LT.0) thez=paru(1)-thez
18332  cthe(1)=cos(thez)
18333  CALL pyrobo(nc+1,n,0d0,chiz,0d0,0d0,0d0)
18334  CALL pyrobo(nc+1,n,thez,phiz,0d0,0d0,0d0)
18335  ENDIF
18336 
18337 C...Boost partons to Z0 rest frame.
18338  CALL pyrobo(nc+1,n,0d0,0d0,p(id,1)/p(id,4),
18339  & p(id,2)/p(id,4),p(id,3)/p(id,4))
18340 
18341 C...Mark decayed resonance and add documentation lines,
18342  k(id,1)=k(id,1)+10
18343  idoc=mint(83)+mint(4)
18344  DO 360 i=nc+1,n
18345  i1=mint(83)+mint(4)+1
18346  k(i,3)=i1
18347  IF(mstp(128).GE.1) k(i,3)=id
18348  IF(mstp(128).LE.1.AND.mint(4).LT.mstp(126)) THEN
18349  mint(4)=mint(4)+1
18350  k(i1,1)=21
18351  k(i1,2)=k(i,2)
18352  k(i1,3)=iref(ip,4)
18353  DO 350 j=1,5
18354  p(i1,j)=p(i,j)
18355  350 CONTINUE
18356  ENDIF
18357  360 CONTINUE
18358 
18359 C...Generate parton shower.
18360  IF(mstj(101).EQ.5.AND.mint(35).LE.1) THEN
18361  CALL pyshow(n-1,n,p(id,5))
18362  ELSEIF(mstj(101).EQ.5.AND.mint(35).GE.2) THEN
18363  npart=2
18364  ipart(1)=n-1
18365  ipart(2)=n
18366  ptpart(1)=0.5d0*p(id,5)
18367  ptpart(2)=ptpart(1)
18368  nct=nct+1
18369  IF(k(n-1,2).GT.0) THEN
18370  mct(n-1,1)=nct
18371  mct(n,2)=nct
18372  ELSE
18373  mct(n-1,2)=nct
18374  mct(n,1)=nct
18375  ENDIF
18376  CALL pyptfs(2,0.5d0*p(id,5),0d0,ptgen)
18377  ENDIF
18378 
18379 C... End special case for Z0: skip ahead.
18380  mstu(111)=mst111
18381  paru(112)=par112
18382  goto 700
18383  ENDIF
18384 
18385 C...Order incoming partons and outgoing resonances.
18386  IF(jtmax.EQ.2.AND.isub.NE.0.AND.mstp(47).GE.1.AND.
18387  &ninh.EQ.0) THEN
18388  ilin(1)=mint(84)+1
18389  IF(k(mint(84)+1,2).GT.0) ilin(1)=mint(84)+2
18390  IF(k(ilin(1),2).EQ.21.OR.k(ilin(1),2).EQ.22)
18391  & ilin(1)=2*mint(84)+3-ilin(1)
18392  ilin(2)=2*mint(84)+3-ilin(1)
18393  imin=1
18394  IF(iref(ip,7).EQ.25.OR.iref(ip,7).EQ.35.OR.iref(ip,7)
18395  & .EQ.36) imin=3
18396  imax=2
18397  iord=1
18398  IF(k(iref(ip,1),2).EQ.23) iord=2
18399  IF(k(iref(ip,1),2).EQ.24.AND.k(iref(ip,2),2).EQ.-24) iord=2
18400  iakipd=iabs(k(iref(ip,iord),2))
18401  IF(iakipd.EQ.25.OR.iakipd.EQ.35.OR.iakipd.EQ.36) iord=3-iord
18402  IF(kdcy(iord).EQ.0) iord=3-iord
18403 
18404 C...Order decay products of resonances.
18405  DO 370 jt=iord,3-iord,3-2*iord
18406  IF(kdcy(jt).EQ.0) THEN
18407  ilin(imax+1)=nsd(jt)
18408  imax=imax+1
18409  ELSEIF(k(nsd(jt)+1,2).GT.0) THEN
18410  ilin(imax+1)=n+2*jt-1
18411  ilin(imax+2)=n+2*jt
18412  imax=imax+2
18413  k(n+2*jt-1,2)=k(nsd(jt)+1,2)
18414  k(n+2*jt,2)=k(nsd(jt)+2,2)
18415  ELSE
18416  ilin(imax+1)=n+2*jt
18417 
18418  ilin(imax+2)=n+2*jt-1
18419  imax=imax+2
18420  k(n+2*jt-1,2)=k(nsd(jt)+1,2)
18421  k(n+2*jt,2)=k(nsd(jt)+2,2)
18422  ENDIF
18423  370 CONTINUE
18424 
18425 C...Find charge, isospin, left- and righthanded couplings.
18426  DO 390 i=imin,imax
18427  DO 380 j=1,4
18428  coup(i,j)=0d0
18429  380 CONTINUE
18430  kfa=iabs(k(ilin(i),2))
18431  IF(kfa.EQ.0.OR.kfa.GT.20) goto 390
18432  coup(i,1)=kchg(kfa,1)/3d0
18433  coup(i,2)=(-1)**mod(kfa,2)
18434  coup(i,4)=-2d0*coup(i,1)*xwv
18435  coup(i,3)=coup(i,2)+coup(i,4)
18436  390 CONTINUE
18437 
18438 C...Full propagator dependence and flavour correlations for 2 gamma*/Z.
18439  IF(isub.EQ.22) THEN
18440  DO 420 i=3,5,2
18441  i1=iord
18442  IF(i.EQ.5) i1=3-iord
18443  DO 410 j1=1,2
18444  DO 400 j2=1,2
18445  corl(i/2,j1,j2)=coup(1,1)**2*hgz(i1,1)*coup(i,1)**2/
18446  & 16d0+coup(1,1)*coup(1,j1+2)*hgz(i1,2)*coup(i,1)*
18447  & coup(i,j2+2)/4d0+coup(1,j1+2)**2*hgz(i1,3)*
18448  & coup(i,j2+2)**2
18449  400 CONTINUE
18450  410 CONTINUE
18451  420 CONTINUE
18452  cowt12=(corl(1,1,1)+corl(1,1,2))*(corl(2,1,1)+corl(2,1,2))+
18453  & (corl(1,2,1)+corl(1,2,2))*(corl(2,2,1)+corl(2,2,2))
18454  comx12=(corl(1,1,1)+corl(1,1,2)+corl(1,2,1)+corl(1,2,2))*
18455  & (corl(2,1,1)+corl(2,1,2)+corl(2,2,1)+corl(2,2,2))
18456 
18457  IF(cowt12.LT.pyr(0)*comx12) goto 180
18458  ENDIF
18459  ENDIF
18460 
18461 C...Select angular orientation type - Z'/W' only.
18462  mzpwp=0
18463  IF(isub.EQ.141) THEN
18464  IF(pyr(0).LT.paru(130)) mzpwp=1
18465  IF(ip.EQ.2) THEN
18466  IF(iabs(k(iref(2,1),2)).EQ.37) mzpwp=2
18467  iakir=iabs(k(iref(2,2),2))
18468  IF(iakir.EQ.25.OR.iakir.EQ.35.OR.iakir.EQ.36) mzpwp=2
18469  IF(iakir.LE.20) mzpwp=2
18470  ENDIF
18471  IF(ip.GE.3) mzpwp=2
18472  ELSEIF(isub.EQ.142) THEN
18473  IF(pyr(0).LT.paru(136)) mzpwp=1
18474  IF(ip.EQ.2) THEN
18475  iakir=iabs(k(iref(2,2),2))
18476  IF(iakir.EQ.25.OR.iakir.EQ.35.OR.iakir.EQ.36) mzpwp=2
18477  IF(iakir.LE.20) mzpwp=2
18478  ENDIF
18479  IF(ip.GE.3) mzpwp=2
18480  ENDIF
18481 
18482 C...Select random angles (begin of weighting procedure).
18483  430 DO 440 jt=1,jtmax
18484  IF(kdcy(jt).EQ.0) goto 440
18485  IF(jtmax.EQ.1.AND.isub.NE.0.AND.ihdec.EQ.0) THEN
18486  cthe(jt)=vint(13)+(vint(33)-vint(13)+vint(34)-vint(14))*pyr(0)
18487  IF(cthe(jt).GT.vint(33)) cthe(jt)=cthe(jt)+vint(14)-vint(33)
18488  phi(jt)=vint(24)
18489  ELSE
18490  cthe(jt)=2d0*pyr(0)-1d0
18491  phi(jt)=paru(2)*pyr(0)
18492  ENDIF
18493  440 CONTINUE
18494 
18495  IF(jtmax.EQ.2.AND.mstp(47).GE.1.AND.ninh.EQ.0) THEN
18496 C...Construct massless four-vectors.
18497  DO 460 i=n+1,n+4
18498  k(i,1)=1
18499  DO 450 j=1,5
18500  p(i,j)=0d0
18501  v(i,j)=0d0
18502  450 CONTINUE
18503  460 CONTINUE
18504  DO 470 jt=1,jtmax
18505  IF(kdcy(jt).EQ.0) goto 470
18506  id=iref(ip,jt)
18507  p(n+2*jt-1,3)=0.5d0*p(id,5)
18508  p(n+2*jt-1,4)=0.5d0*p(id,5)
18509  p(n+2*jt,3)=-0.5d0*p(id,5)
18510  p(n+2*jt,4)=0.5d0*p(id,5)
18511  CALL pyrobo(n+2*jt-1,n+2*jt,acos(cthe(jt)),phi(jt),
18512  & p(id,1)/p(id,4),p(id,2)/p(id,4),p(id,3)/p(id,4))
18513  470 CONTINUE
18514 
18515 C...Store incoming and outgoing momenta, with random rotation to
18516 C...avoid accidental zeroes in HA expressions.
18517  IF(isub.NE.0) THEN
18518  DO 490 i=imin,imax
18519  k(n+4+i,1)=1
18520  p(n+4+i,4)=sqrt(p(ilin(i),1)**2+p(ilin(i),2)**2+
18521  & p(ilin(i),3)**2+p(ilin(i),5)**2)
18522  p(n+4+i,5)=p(ilin(i),5)
18523  DO 480 j=1,3
18524  p(n+4+i,j)=p(ilin(i),j)
18525  480 CONTINUE
18526  490 CONTINUE
18527  500 therr=acos(2d0*pyr(0)-1d0)
18528  phirr=paru(2)*pyr(0)
18529  CALL pyrobo(n+4+imin,n+4+imax,therr,phirr,0d0,0d0,0d0)
18530  DO 520 i=imin,imax
18531  IF(p(n+4+i,1)**2+p(n+4+i,2)**2.LT.1d-4*(p(n+4+i,1)**2+
18532  & p(n+4+i,2)**2+p(n+4+i,3)**2)) goto 500
18533  DO 510 j=1,4
18534  pk(i,j)=p(n+4+i,j)
18535  510 CONTINUE
18536  520 CONTINUE
18537  ENDIF
18538 
18539 C...Calculate internal products.
18540  IF(isub.EQ.22.OR.isub.EQ.23.OR.isub.EQ.25.OR.isub.EQ.141.OR.
18541  & isub.EQ.142) THEN
18542  DO 540 i1=imin,imax-1
18543  DO 530 i2=i1+1,imax
18544  ha(i1,i2)=sngl(sqrt((pk(i1,4)-pk(i1,3))*(pk(i2,4)+
18545  & pk(i2,3))/(1d-20+pk(i1,1)**2+pk(i1,2)**2)))*
18546  & cmplx(sngl(pk(i1,1)),sngl(pk(i1,2)))-
18547  & sngl(sqrt((pk(i1,4)+pk(i1,3))*(pk(i2,4)-pk(i2,3))/
18548  & (1d-20+pk(i2,1)**2+pk(i2,2)**2)))*
18549  & cmplx(sngl(pk(i2,1)),sngl(pk(i2,2)))
18550  hc(i1,i2)=conjg(ha(i1,i2))
18551  IF(i1.LE.2) ha(i1,i2)=cmplx(0.,1.)*ha(i1,i2)
18552  IF(i1.LE.2) hc(i1,i2)=cmplx(0.,1.)*hc(i1,i2)
18553  ha(i2,i1)=-ha(i1,i2)
18554  hc(i2,i1)=-hc(i1,i2)
18555  530 CONTINUE
18556  540 CONTINUE
18557  ENDIF
18558 
18559 C...Calculate four-products.
18560  IF(isub.NE.0) THEN
18561  DO 560 i=1,2
18562  DO 550 j=1,4
18563  pk(i,j)=-pk(i,j)
18564  550 CONTINUE
18565  560 CONTINUE
18566  DO 580 i1=imin,imax-1
18567  DO 570 i2=i1+1,imax
18568  pkk(i1,i2)=2d0*(pk(i1,4)*pk(i2,4)-pk(i1,1)*pk(i2,1)-
18569  & pk(i1,2)*pk(i2,2)-pk(i1,3)*pk(i2,3))
18570  pkk(i2,i1)=pkk(i1,i2)
18571  570 CONTINUE
18572  580 CONTINUE
18573  ENDIF
18574  ENDIF
18575 
18576  kfagm=iabs(iref(ip,7))
18577  IF(mstp(47).LE.0.OR.ninh.NE.0) THEN
18578 C...Isotropic decay selected by user.
18579  wt=1d0
18580  wtmax=1d0
18581 
18582  ELSEIF(jtmax.EQ.3) THEN
18583 C...Isotropic decay when three mother particles.
18584  wt=1d0
18585  wtmax=1d0
18586 
18587  ELSEIF(it4.GE.1) THEN
18588 C... Isotropic decay t -> b + W etc for 4th generation q and l.
18589  wt=1d0
18590  wtmax=1d0
18591 
18592  ELSEIF(iref(ip,7).EQ.25.OR.iref(ip,7).EQ.35.OR.
18593  & iref(ip,7).EQ.36) THEN
18594 C...Angular weight for h0/A0 -> Z0 + Z0 or W+ + W- -> 4 quarks/leptons.
18595 C...CP-odd case added by Kari Ertresvag Myklevoll.
18596 C...Now also with mixed Higgs CP-states
18597  eta=parp(25)
18598  IF(ip.EQ.1) wtmax=sh**2
18599  IF(ip.GE.2) wtmax=p(iref(ip,8),5)**4
18600  kfa=iabs(k(iref(ip,1),2))
18601  kft=iabs(k(iref(ip,2),2))
18602 
18603  IF((kfa.EQ.kft).AND.(kfa.EQ.23.OR.kfa.EQ.24).AND.
18604  & mstp(25).GE.3) THEN
18605 C...For mixed CP states need epsilon product.
18606  p10=pk(3,4)
18607  p20=pk(4,4)
18608  p30=pk(5,4)
18609  p40=pk(6,4)
18610  p11=pk(3,1)
18611  p21=pk(4,1)
18612  p31=pk(5,1)
18613  p41=pk(6,1)
18614  p12=pk(3,2)
18615  p22=pk(4,2)
18616  p32=pk(5,2)
18617  p42=pk(6,2)
18618  p13=pk(3,3)
18619  p23=pk(4,3)
18620  p33=pk(5,3)
18621  p43=pk(6,3)
18622  epsi=p10*p21*p32*p43-p10*p21*p33*p42-p10*p22*p31*p43+p10*p22*
18623  & p33*p41+p10*p23*p31*p42-p10*p23*p32*p41-p11*p20*p32*p43+p11*
18624  & p20*p33*p42+p11*p22*p30*p43-p11*p22*p33*p40-p11*p23*p30*p42+
18625  & p11*p23*p32*p40+p12*p20*p31*p43-p12*p20*p33*p41-p12*p21*p30*
18626  & p43+p12*p21*p33*p40+p12*p23*p30*p41-p12*p23*p31*p40-p13*p20*
18627  & p31*p42+p13*p20*p32*p41+p13*p21*p30*p42-p13*p21*p32*p40-p13*
18628  & p22*p30*p41+p13*p22*p31*p40
18629 C...For mixed CP states need gauge boson masses.
18630  xma=sqrt(max(0d0,(pk(3,4)+pk(4,4))**2-(pk(3,1)+pk(4,1))**2-
18631  & (pk(3,2)+pk(4,2))**2-(pk(3,3)+pk(4,3))**2))
18632  xmb=sqrt(max(0d0,(pk(5,4)+pk(6,4))**2-(pk(5,1)+pk(6,1))**2-
18633  & (pk(5,2)+pk(6,2))**2-(pk(5,3)+pk(6,3))**2))
18634  xmv=pmas(kfa,1)
18635  ENDIF
18636 
18637 C...Z decay
18638  IF(kfa.EQ.23.AND.kfa.EQ.kft) THEN
18639  kflf1a=iabs(kfl1(1))
18640  ef1=kchg(kflf1a,1)/3d0
18641  af1=sign(1d0,ef1+0.1d0)
18642  vf1=af1-4d0*ef1*xwv
18643  kflf2a=iabs(kfl1(2))
18644  ef2=kchg(kflf2a,1)/3d0
18645  af2=sign(1d0,ef2+0.1d0)
18646  vf2=af2-4d0*ef2*xwv
18647  va12as=4d0*vf1*af1*vf2*af2/((vf1**2+af1**2)*(vf2**2+af2**2))
18648  IF((mstp(25).EQ.0.AND.iref(ip,7).NE.36).OR.mstp(25).EQ.1)
18649  & THEN
18650 C...CP-even decay
18651  wt=8d0*(1d0+va12as)*pkk(3,5)*pkk(4,6)+
18652  & 8d0*(1d0-va12as)*pkk(3,6)*pkk(4,5)
18653  ELSEIF(mstp(25).LE.2) THEN
18654 C...CP-odd decay
18655  wt=((pkk(3,5)+pkk(4,6))**2 +(pkk(3,6)+pkk(4,5))**2
18656  & -2*pkk(3,4)*pkk(5,6)
18657  & -2*(pkk(3,5)*pkk(4,6)-pkk(3,6)*pkk(4,5))**2/
18658  & (pkk(3,4)*pkk(5,6))
18659  & +va12as*(pkk(3,5)+pkk(3,6)-pkk(4,5)-pkk(4,6))*
18660  & (pkk(3,5)+pkk(4,5)-pkk(3,6)-pkk(4,6)))/(1+va12as)
18661  ELSE
18662 C...Mixed CP states.
18663  wt=32d0*(0.25d0*((1d0+va12as)*pkk(3,5)*pkk(4,6)
18664  & +(1d0-va12as)*pkk(3,6)*pkk(4,5))
18665  & -0.5d0*eta/xmv**2*epsi*((1d0+va12as)*(pkk(3,5)+pkk(4,6))
18666  & -(1d0-va12as)*(pkk(3,6)+pkk(4,5)))
18667  & +6.25d-2*eta**2/xmv**4*(-2d0*pkk(3,4)**2*pkk(5,6)**2
18668  & -2d0*(pkk(3,5)*pkk(4,6)-pkk(3,6)*pkk(4,5))**2
18669  & +pkk(3,4)*pkk(5,6)
18670  & *((pkk(3,5)+pkk(4,6))**2+(pkk(3,6)+pkk(4,5))**2)
18671  & +va12as*pkk(3,4)*pkk(5,6)
18672  & *(pkk(3,5)+pkk(3,6)-pkk(4,5)-pkk(4,6))
18673  & *(pkk(3,5)-pkk(3,6)+pkk(4,5)-pkk(4,6))))
18674  & /(1d0 +2d0*eta*xma*xmb/xmv**2
18675  & +2d0*(eta*xma*xmb/xmv**2)**2*(1d0+va12as))
18676  ENDIF
18677 
18678 C...W decay
18679  ELSEIF(kfa.EQ.24.AND.kfa.EQ.kft) THEN
18680  IF((mstp(25).EQ.0.AND.iref(ip,7).NE.36).OR.mstp(25).EQ.1)
18681  & THEN
18682 C...CP-even decay
18683  wt=16d0*pkk(3,5)*pkk(4,6)
18684  ELSEIF(mstp(25).LE.2) THEN
18685 C...CP-odd decay
18686  wt=0.5d0*((pkk(3,5)+pkk(4,6))**2 +(pkk(3,6)+pkk(4,5))**2
18687  & -2*pkk(3,4)*pkk(5,6)
18688  & -2*(pkk(3,5)*pkk(4,6)-pkk(3,6)*pkk(4,5))**2/
18689  & (pkk(3,4)*pkk(5,6))
18690  & +(pkk(3,5)+pkk(3,6)-pkk(4,5)-pkk(4,6))*
18691  & (pkk(3,5)+pkk(4,5)-pkk(3,6)-pkk(4,6)))
18692  ELSE
18693 C...Mixed CP states.
18694  wt=32d0*(0.25d0*2d0*pkk(3,5)*pkk(4,6)
18695  & -0.5d0*eta/xmv**2*epsi*2d0*(pkk(3,5)+pkk(4,6))
18696  & +6.25d-2*eta**2/xmv**4*(-2d0*pkk(3,4)**2*pkk(5,6)**2
18697  & -2d0*(pkk(3,5)*pkk(4,6)-pkk(3,6)*pkk(4,5))**2
18698  & +pkk(3,4)*pkk(5,6)
18699  & *((pkk(3,5)+pkk(4,6))**2+(pkk(3,6)+pkk(4,5))**2)
18700  & +pkk(3,4)*pkk(5,6)
18701  & *(pkk(3,5)+pkk(3,6)-pkk(4,5)-pkk(4,6))
18702  & *(pkk(3,5)-pkk(3,6)+pkk(4,5)-pkk(4,6))))
18703  & /(1d0 +2d0*eta*xma*xmb/xmv**2
18704  & +(2d0*eta*xma*xmb/xmv**2)**2)
18705  ENDIF
18706 
18707 C...No angular correlations in other Higgs decays.
18708  ELSE
18709  wt=wtmax
18710  ENDIF
18711 
18712  ELSEIF((kfagm.EQ.6.OR.kfagm.EQ.7.OR.kfagm.EQ.8.OR.
18713  & kfagm.EQ.17.OR.kfagm.EQ.18).AND.iabs(k(iref(ip,1),2)).EQ.24)
18714  & THEN
18715 C...Angular correlation in f -> f' + W -> f' + 2 quarks/leptons.
18716  i1=iref(ip,8)
18717  IF(mod(kfagm,2).EQ.0) THEN
18718  i2=n+1
18719  i3=n+2
18720  ELSE
18721  i2=n+2
18722  i3=n+1
18723  ENDIF
18724  i4=iref(ip,2)
18725  wt=(p(i1,4)*p(i2,4)-p(i1,1)*p(i2,1)-p(i1,2)*p(i2,2)-
18726  & p(i1,3)*p(i2,3))*(p(i3,4)*p(i4,4)-p(i3,1)*p(i4,1)-
18727  & p(i3,2)*p(i4,2)-p(i3,3)*p(i4,3))
18728  wtmax=(p(i1,5)**4-p(iref(ip,1),5)**4)/8d0
18729 
18730  ELSEIF(isub.EQ.1) THEN
18731 C...Angular weight for gamma*/Z0 -> 2 quarks/leptons.
18732  ei=kchg(iabs(mint(15)),1)/3d0
18733  ai=sign(1d0,ei+0.1d0)
18734  vi=ai-4d0*ei*xwv
18735  ef=kchg(iabs(kfl1(1)),1)/3d0
18736  af=sign(1d0,ef+0.1d0)
18737 
18738  vf=af-4d0*ef*xwv
18739  rmf=min(1d0,4d0*pmas(iabs(kfl1(1)),1)**2/sh)
18740  wt1=ei**2*vint(111)*ef**2+ei*vi*vint(112)*ef*vf+
18741  & (vi**2+ai**2)*vint(114)*(vf**2+(1d0-rmf)*af**2)
18742  wt2=rmf*(ei**2*vint(111)*ef**2+ei*vi*vint(112)*ef*vf+
18743  & (vi**2+ai**2)*vint(114)*vf**2)
18744  wt3=sqrt(1d0-rmf)*(ei*ai*vint(112)*ef*af+
18745  & 4d0*vi*ai*vint(114)*vf*af)
18746  wt=wt1*(1d0+cthe(1)**2)+wt2*(1d0-cthe(1)**2)+
18747  & 2d0*wt3*cthe(1)*isign(1,mint(15)*kfl1(1))
18748  wtmax=2d0*(wt1+abs(wt3))
18749 
18750  ELSEIF(isub.EQ.2) THEN
18751 C...Angular weight for W+/- -> 2 quarks/leptons.
18752  rm3=pmas(iabs(kfl1(1)),1)**2/sh
18753  rm4=pmas(iabs(kfl2(1)),1)**2/sh
18754  be34=sqrt(max(0d0,(1d0-rm3-rm4)**2-4d0*rm3*rm4))
18755  wt=(1d0+be34*cthe(1)*isign(1,mint(15)*kfl1(1)))**2-(rm3-rm4)**2
18756  wtmax=4d0
18757 
18758  ELSEIF(isub.EQ.15.OR.isub.EQ.19) THEN
18759 C...Angular weight for f + fbar -> gluon/gamma + (gamma*/Z0) ->
18760 C...-> gluon/gamma + 2 quarks/leptons.
18761  clilf=coup(1,1)**2*hgz(jtz,1)*coup(3,1)**2/16d0+
18762  & coup(1,1)*coup(1,3)*hgz(jtz,2)*coup(3,1)*coup(3,3)/4d0+
18763  & coup(1,3)**2*hgz(jtz,3)*coup(3,3)**2
18764  clirf=coup(1,1)**2*hgz(jtz,1)*coup(3,1)**2/16d0+
18765  & coup(1,1)*coup(1,3)*hgz(jtz,2)*coup(3,1)*coup(3,4)/4d0+
18766  & coup(1,3)**2*hgz(jtz,3)*coup(3,4)**2
18767  crilf=coup(1,1)**2*hgz(jtz,1)*coup(3,1)**2/16d0+
18768  & coup(1,1)*coup(1,4)*hgz(jtz,2)*coup(3,1)*coup(3,3)/4d0+
18769  & coup(1,4)**2*hgz(jtz,3)*coup(3,3)**2
18770  crirf=coup(1,1)**2*hgz(jtz,1)*coup(3,1)**2/16d0+
18771  & coup(1,1)*coup(1,4)*hgz(jtz,2)*coup(3,1)*coup(3,4)/4d0+
18772  & coup(1,4)**2*hgz(jtz,3)*coup(3,4)**2
18773  wt=(clilf+crirf)*(pkk(1,3)**2+pkk(2,4)**2)+
18774  & (clirf+crilf)*(pkk(1,4)**2+pkk(2,3)**2)
18775  wtmax=(clilf+clirf+crilf+crirf)*
18776  & ((pkk(1,3)+pkk(1,4))**2+(pkk(2,3)+pkk(2,4))**2)
18777 
18778  ELSEIF(isub.EQ.16.OR.isub.EQ.20) THEN
18779 C...Angular weight for f + fbar' -> gluon/gamma + W+/- ->
18780 C...-> gluon/gamma + 2 quarks/leptons.
18781  wt=pkk(1,3)**2+pkk(2,4)**2
18782  wtmax=(pkk(1,3)+pkk(1,4))**2+(pkk(2,3)+pkk(2,4))**2
18783 
18784  ELSEIF(isub.EQ.22) THEN
18785 C...Angular weight for f + fbar -> Z0 + Z0 -> 4 quarks/leptons.
18786  s34=p(iref(ip,iord),5)**2
18787  s56=p(iref(ip,3-iord),5)**2
18788  ti=pkk(1,3)+pkk(1,4)+s34
18789  ui=pkk(1,5)+pkk(1,6)+s56
18790  tir=REAL(ti)
18791  uir=REAL(ui)
18792  fgk135=abs(fgk(1,2,3,4,5,6)/tir+fgk(1,2,5,6,3,4)/uir)**2
18793  fgk145=abs(fgk(1,2,4,3,5,6)/tir+fgk(1,2,5,6,4,3)/uir)**2
18794  fgk136=abs(fgk(1,2,3,4,6,5)/tir+fgk(1,2,6,5,3,4)/uir)**2
18795  fgk146=abs(fgk(1,2,4,3,6,5)/tir+fgk(1,2,6,5,4,3)/uir)**2
18796  fgk253=abs(fgk(2,1,5,6,3,4)/tir+fgk(2,1,3,4,5,6)/uir)**2
18797  fgk263=abs(fgk(2,1,6,5,3,4)/tir+fgk(2,1,3,4,6,5)/uir)**2
18798  fgk254=abs(fgk(2,1,5,6,4,3)/tir+fgk(2,1,4,3,5,6)/uir)**2
18799  fgk264=abs(fgk(2,1,6,5,4,3)/tir+fgk(2,1,4,3,6,5)/uir)**2
18800 
18801  wt=
18802  & corl(1,1,1)*corl(2,1,1)*fgk135+corl(1,1,2)*corl(2,1,1)*fgk145+
18803  & corl(1,1,1)*corl(2,1,2)*fgk136+corl(1,1,2)*corl(2,1,2)*fgk146+
18804  & corl(1,2,1)*corl(2,2,1)*fgk253+corl(1,2,2)*corl(2,2,1)*fgk263+
18805  & corl(1,2,1)*corl(2,2,2)*fgk254+corl(1,2,2)*corl(2,2,2)*fgk264
18806  wtmax=16d0*((corl(1,1,1)+corl(1,1,2))*(corl(2,1,1)+corl(2,1,2))+
18807  & (corl(1,2,1)+corl(1,2,2))*(corl(2,2,1)+corl(2,2,2)))*s34*s56*
18808  & ((ti**2+ui**2+2d0*sh*(s34+s56))/(ti*ui)-s34*s56*(1d0/ti**2+
18809  & 1d0/ui**2))
18810 
18811  ELSEIF(isub.EQ.23) THEN
18812 C...Angular weight for f + fbar' -> Z0 + W+/- -> 4 quarks/leptons.
18813  d34=p(iref(ip,iord),5)**2
18814  d56=p(iref(ip,3-iord),5)**2
18815  dt=pkk(1,3)+pkk(1,4)+d34
18816  du=pkk(1,5)+pkk(1,6)+d56
18817  facbw=1d0/((sh-sqmw)**2+gmmw**2)
18818  cawz=coup(2,3)/dt-2d0*xw1*coup(1,2)*(sh-sqmw)*facbw
18819  cbwz=coup(1,3)/du+2d0*xw1*coup(1,2)*(sh-sqmw)*facbw
18820  fgk135=abs(REAL(cawz)*fgk(1,2,3,4,5,6)+
18821 
18822  & REAL(cbwz)*fgk(1,2,5,6,3,4))
18823  fgk136=abs(REAL(cawz)*fgk(1,2,3,4,6,5)+
18824  & REAL(cbwz)*fgk(1,2,6,5,3,4))
18825  wt=(coup(5,3)*fgk135)**2+(coup(5,4)*fgk136)**2
18826  wtmax=4d0*d34*d56*(coup(5,3)**2+coup(5,4)**2)*(cawz**2*
18827  & digk(dt,du)+cbwz**2*digk(du,dt)+cawz*cbwz*djgk(dt,du))
18828 
18829  ELSEIF(isub.EQ.24.OR.isub.EQ.171.OR.isub.EQ.176) THEN
18830 C...Angular weight for f + fbar -> Z0 + h0 -> 2 quarks/leptons + h0
18831 C...(or H0, or A0).
18832  wt=((coup(1,3)*coup(3,3))**2+(coup(1,4)*coup(3,4))**2)*
18833  & pkk(1,3)*pkk(2,4)+((coup(1,3)*coup(3,4))**2+(coup(1,4)*
18834  & coup(3,3))**2)*pkk(1,4)*pkk(2,3)
18835  wtmax=(coup(1,3)**2+coup(1,4)**2)*(coup(3,3)**2+coup(3,4)**2)*
18836  & (pkk(1,3)+pkk(1,4))*(pkk(2,3)+pkk(2,4))
18837 
18838  ELSEIF(isub.EQ.25) THEN
18839 C...Angular weight for f + fbar -> W+ + W- -> 4 quarks/leptons.
18840  polr=(1d0+parj(132))*(1d0-parj(131))
18841  poll=(1d0-parj(132))*(1d0+parj(131))
18842  d34=p(iref(ip,iord),5)**2
18843  d56=p(iref(ip,3-iord),5)**2
18844  dt=pkk(1,3)+pkk(1,4)+d34
18845  du=pkk(1,5)+pkk(1,6)+d56
18846  facbw=1d0/((sh-sqmz)**2+sqmz*pmas(23,2)**2)
18847  cdww=(coup(1,3)*sqmz*(sh-sqmz)*facbw+coup(1,2))/sh
18848  caww=cdww+0.5d0*(coup(1,2)+1d0)/dt
18849  cbww=cdww+0.5d0*(coup(1,2)-1d0)/du
18850  ccww=coup(1,4)*sqmz*(sh-sqmz)*facbw/sh
18851  fgk135=abs(REAL(caww)*fgk(1,2,3,4,5,6)-
18852  & REAL(cbww)*fgk(1,2,5,6,3,4))
18853  fgk253=abs(fgk(2,1,5,6,3,4)-fgk(2,1,3,4,5,6))
18854  IF(mstp(50).LE.0) THEN
18855  wt=fgk135**2+(ccww*fgk253)**2
18856  wtmax=4d0*d34*d56*(caww**2*digk(dt,du)+cbww**2*digk(du,dt)-
18857  & caww*cbww*djgk(dt,du)+ccww**2*(digk(dt,du)+digk(du,dt)-
18858  & djgk(dt,du)))
18859  ELSE
18860  wt=poll*fgk135**2+polr*(ccww*fgk253)**2
18861  wtmax=4d0*d34*d56*(poll*(caww**2*digk(dt,du)+
18862  & cbww**2*digk(du,dt)-caww*cbww*djgk(dt,du))+
18863  & polr*ccww**2*(digk(dt,du)+digk(du,dt)-djgk(dt,du)))
18864  ENDIF
18865 
18866  ELSEIF(isub.EQ.26.OR.isub.EQ.172.OR.isub.EQ.177) THEN
18867 C...Angular weight for f + fbar' -> W+/- + h0 -> 2 quarks/leptons + h0
18868 C...(or H0, or A0).
18869  wt=pkk(1,3)*pkk(2,4)
18870  wtmax=(pkk(1,3)+pkk(1,4))*(pkk(2,3)+pkk(2,4))
18871 
18872  ELSEIF(isub.EQ.30.OR.isub.EQ.35) THEN
18873 C...Angular weight for f + g/gamma -> f + (gamma*/Z0)
18874 C...-> f + 2 quarks/leptons.
18875  clilf=coup(1,1)**2*hgz(jtz,1)*coup(3,1)**2/16d0+
18876  & coup(1,1)*coup(1,3)*hgz(jtz,2)*coup(3,1)*coup(3,3)/4d0+
18877  & coup(1,3)**2*hgz(jtz,3)*coup(3,3)**2
18878  clirf=coup(1,1)**2*hgz(jtz,1)*coup(3,1)**2/16d0+
18879  & coup(1,1)*coup(1,3)*hgz(jtz,2)*coup(3,1)*coup(3,4)/4d0+
18880  & coup(1,3)**2*hgz(jtz,3)*coup(3,4)**2
18881  crilf=coup(1,1)**2*hgz(jtz,1)*coup(3,1)**2/16d0+
18882  & coup(1,1)*coup(1,4)*hgz(jtz,2)*coup(3,1)*coup(3,3)/4d0+
18883  & coup(1,4)**2*hgz(jtz,3)*coup(3,3)**2
18884  crirf=coup(1,1)**2*hgz(jtz,1)*coup(3,1)**2/16d0+
18885  & coup(1,1)*coup(1,4)*hgz(jtz,2)*coup(3,1)*coup(3,4)/4d0+
18886  & coup(1,4)**2*hgz(jtz,3)*coup(3,4)**2
18887  IF(k(ilin(1),2).GT.0) wt=(clilf+crirf)*(pkk(1,4)**2+
18888  & pkk(3,5)**2)+(clirf+crilf)*(pkk(1,3)**2+pkk(4,5)**2)
18889  IF(k(ilin(1),2).LT.0) wt=(clilf+crirf)*(pkk(1,3)**2+
18890  & pkk(4,5)**2)+(clirf+crilf)*(pkk(1,4)**2+pkk(3,5)**2)
18891  wtmax=(clilf+clirf+crilf+crirf)*
18892  & ((pkk(1,3)+pkk(1,4))**2+(pkk(3,5)+pkk(4,5))**2)
18893 
18894  ELSEIF(isub.EQ.31.OR.isub.EQ.36) THEN
18895 C...Angular weight for f + g/gamma -> f' + W+/- -> f' + 2 fermions.
18896  IF(k(ilin(1),2).GT.0) wt=pkk(1,4)**2+pkk(3,5)**2
18897  IF(k(ilin(1),2).LT.0) wt=pkk(1,3)**2+pkk(4,5)**2
18898  wtmax=(pkk(1,3)+pkk(1,4))**2+(pkk(3,5)+pkk(4,5))**2
18899 
18900  ELSEIF(isub.EQ.71.OR.isub.EQ.72.OR.isub.EQ.73.OR.isub.EQ.76.OR.
18901  & isub.EQ.77) THEN
18902 C...Angular weight for V_L1 + V_L2 -> V_L3 + V_L4 (V = Z/W).
18903  wt=16d0*pkk(3,5)*pkk(4,6)
18904  wtmax=sh**2
18905 
18906  ELSEIF(isub.EQ.110) THEN
18907 C...Angular weight for f + fbar -> gamma + h0 -> gamma + X is isotropic.
18908  wt=1d0
18909  wtmax=1d0
18910 
18911  ELSEIF(isub.EQ.141) THEN
18912 C...Special case: if only branching ratios known then isotropic decay.
18913  IF(mwid(32).EQ.2) THEN
18914  wt=1d0
18915  wtmax=1d0
18916  ELSEIF(ip.EQ.1.AND.iabs(kfl1(1)).LT.20) THEN
18917 C...Angular weight for f + fbar -> gamma*/Z0/Z'0 -> 2 quarks/leptons.
18918 C...Couplings of incoming flavour.
18919  kfai=iabs(mint(15))
18920  ei=kchg(kfai,1)/3d0
18921  ai=sign(1d0,ei+0.1d0)
18922  vi=ai-4d0*ei*xwv
18923  kfaic=1
18924  IF(kfai.LE.10.AND.mod(kfai,2).EQ.0) kfaic=2
18925  IF(kfai.GT.10.AND.mod(kfai,2).NE.0) kfaic=3
18926  IF(kfai.GT.10.AND.mod(kfai,2).EQ.0) kfaic=4
18927  IF(kfai.LE.2.OR.kfai.EQ.11.OR.kfai.EQ.12) THEN
18928  vpi=paru(119+2*kfaic)
18929  api=paru(120+2*kfaic)
18930  ELSEIF(kfai.LE.4.OR.kfai.EQ.13.OR.kfai.EQ.14) THEN
18931  vpi=parj(178+2*kfaic)
18932  api=parj(179+2*kfaic)
18933  ELSE
18934  vpi=parj(186+2*kfaic)
18935  api=parj(187+2*kfaic)
18936  ENDIF
18937 C...Couplings of final flavour.
18938  kfaf=iabs(kfl1(1))
18939  ef=kchg(kfaf,1)/3d0
18940  af=sign(1d0,ef+0.1d0)
18941  vf=af-4d0*ef*xwv
18942  kfafc=1
18943  IF(kfaf.LE.10.AND.mod(kfaf,2).EQ.0) kfafc=2
18944  IF(kfaf.GT.10.AND.mod(kfaf,2).NE.0) kfafc=3
18945  IF(kfaf.GT.10.AND.mod(kfaf,2).EQ.0) kfafc=4
18946  IF(kfaf.LE.2.OR.kfaf.EQ.11.OR.kfaf.EQ.12) THEN
18947  vpf=paru(119+2*kfafc)
18948  apf=paru(120+2*kfafc)
18949  ELSEIF(kfaf.LE.4.OR.kfaf.EQ.13.OR.kfaf.EQ.14) THEN
18950  vpf=parj(178+2*kfafc)
18951  apf=parj(179+2*kfafc)
18952  ELSE
18953  vpf=parj(186+2*kfafc)
18954  apf=parj(187+2*kfafc)
18955  ENDIF
18956 C...Asymmetry and weight.
18957  asym=2d0*(ei*ai*vint(112)*ef*af+ei*api*vint(113)*ef*apf+
18958  & 4d0*vi*ai*vint(114)*vf*af+(vi*api+vpi*ai)*vint(115)*
18959  & (vf*apf+vpf*af)+4d0*vpi*api*vint(116)*vpf*apf)/
18960  & (ei**2*vint(111)*ef**2+ei*vi*vint(112)*ef*vf+
18961  & ei*vpi*vint(113)*ef*vpf+(vi**2+ai**2)*vint(114)*
18962  & (vf**2+af**2)+(vi*vpi+ai*api)*vint(115)*(vf*vpf+af*apf)+
18963  & (vpi**2+api**2)*vint(116)*(vpf**2+apf**2))
18964  wt=1d0+asym*cthe(1)*isign(1,mint(15)*kfl1(1))+cthe(1)**2
18965  wtmax=2d0+abs(asym)
18966  ELSEIF(ip.EQ.1.AND.iabs(kfl1(1)).EQ.24) THEN
18967 C...Angular weight for f + fbar -> Z' -> W+ + W-.
18968  rm1=p(nsd(1)+1,5)**2/sh
18969  rm2=p(nsd(1)+2,5)**2/sh
18970  ccos2=-(1d0/16d0)*((1d0-rm1-rm2)**2-4d0*rm1*rm2)*
18971  & (1d0-2d0*rm1-2d0*rm2+rm1**2+rm2**2+10d0*rm1*rm2)
18972  cflat=-ccos2+0.5d0*(rm1+rm2)*(1d0-2d0*rm1-2d0*rm2+
18973  & (rm2-rm1)**2)
18974  wt=cflat+ccos2*cthe(1)**2
18975  wtmax=cflat+max(0d0,ccos2)
18976  ELSEIF(ip.EQ.1.AND.(kfl1(1).EQ.25.OR.kfl1(1).EQ.35.OR.
18977  & iabs(kfl1(1)).EQ.37)) THEN
18978 C...Angular weight for f + fbar -> Z' -> h0 + A0, H0 + A0, H+ + H-.
18979  wt=1d0-cthe(1)**2
18980  wtmax=1d0
18981  ELSEIF(ip.EQ.1.AND.kfl2(1).EQ.25) THEN
18982 C...Angular weight for f + fbar -> Z' -> Z0 + h0.
18983  rm1=p(nsd(1)+1,5)**2/sh
18984  rm2=p(nsd(1)+2,5)**2/sh
18985  flam2=max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2)
18986  wt=1d0+flam2*(1d0-cthe(1)**2)/(8d0*rm1)
18987  wtmax=1d0+flam2/(8d0*rm1)
18988  ELSEIF(mzpwp.EQ.0) THEN
18989 C...Angular weight for f + fbar -> Z' -> W+ + W- -> 4 quarks/leptons
18990 C...(W:s like if intermediate Z).
18991  d34=p(iref(ip,iord),5)**2
18992  d56=p(iref(ip,3-iord),5)**2
18993  dt=pkk(1,3)+pkk(1,4)+d34
18994  du=pkk(1,5)+pkk(1,6)+d56
18995  fgk135=abs(fgk(1,2,3,4,5,6)-fgk(1,2,5,6,3,4))
18996  fgk253=abs(fgk(2,1,5,6,3,4)-fgk(2,1,3,4,5,6))
18997  wt=(coup(1,3)*fgk135)**2+(coup(1,4)*fgk253)**2
18998  wtmax=4d0*d34*d56*(coup(1,3)**2+coup(1,4)**2)*
18999  & (digk(dt,du)+digk(du,dt)-djgk(dt,du))
19000  ELSEIF(mzpwp.EQ.1) THEN
19001 C...Angular weight for f + fbar -> Z' -> W+ + W- -> 4 quarks/leptons
19002 C...(W:s approximately longitudinal, like if intermediate H).
19003  wt=16d0*pkk(3,5)*pkk(4,6)
19004  wtmax=sh**2
19005  ELSE
19006 C...Angular weight for f + fbar -> Z' -> H+ + H-, Z0 + h0, h0 + A0,
19007 C...H0 + A0 -> 4 quarks/leptons, t + tbar -> b + W+ + bbar + W- .
19008  wt=1d0
19009  wtmax=1d0
19010  ENDIF
19011 
19012  ELSEIF(isub.EQ.142) THEN
19013 C...Special case: if only branching ratios known then isotropic decay.
19014  IF(mwid(34).EQ.2) THEN
19015  wt=1d0
19016  wtmax=1d0
19017  ELSEIF(ip.EQ.1.AND.iabs(kfl1(1)).LT.20) THEN
19018 C...Angular weight for f + fbar' -> W'+/- -> 2 quarks/leptons.
19019  kfai=iabs(mint(15))
19020  kfaic=1
19021  IF(kfai.GT.10) kfaic=2
19022  vi=paru(129+2*kfaic)
19023  ai=paru(130+2*kfaic)
19024  kfaf=iabs(kfl1(1))
19025  kfafc=1
19026  IF(kfaf.GT.10) kfafc=2
19027  vf=paru(129+2*kfafc)
19028  af=paru(130+2*kfafc)
19029  asym=8d0*vi*ai*vf*af/((vi**2+ai**2)*(vf**2+af**2))
19030  wt=1d0+asym*cthe(1)*isign(1,mint(15)*kfl1(1))+cthe(1)**2
19031  wtmax=2d0+abs(asym)
19032  ELSEIF(ip.EQ.1.AND.iabs(kfl2(1)).EQ.23) THEN
19033 C...Angular weight for f + fbar' -> W'+/- -> W+/- + Z0.
19034  rm1=p(nsd(1)+1,5)**2/sh
19035  rm2=p(nsd(1)+2,5)**2/sh
19036  ccos2=-(1d0/16d0)*((1d0-rm1-rm2)**2-4d0*rm1*rm2)*
19037  & (1d0-2d0*rm1-2d0*rm2+rm1**2+rm2**2+10d0*rm1*rm2)
19038  cflat=-ccos2+0.5d0*(rm1+rm2)*(1d0-2d0*rm1-2d0*rm2+
19039  & (rm2-rm1)**2)
19040  wt=cflat+ccos2*cthe(1)**2
19041  wtmax=cflat+max(0d0,ccos2)
19042  ELSEIF(ip.EQ.1.AND.kfl2(1).EQ.25) THEN
19043 C...Angular weight for f + fbar -> W'+/- -> W+/- + h0.
19044  rm1=p(nsd(1)+1,5)**2/sh
19045  rm2=p(nsd(1)+2,5)**2/sh
19046  flam2=max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2)
19047  wt=1d0+flam2*(1d0-cthe(1)**2)/(8d0*rm1)
19048  wtmax=1d0+flam2/(8d0*rm1)
19049  ELSEIF(mzpwp.EQ.0) THEN
19050 C...Angular weight for f + fbar' -> W' -> W + Z0 -> 4 quarks/leptons
19051 C...(W/Z like if intermediate W).
19052  d34=p(iref(ip,iord),5)**2
19053  d56=p(iref(ip,3-iord),5)**2
19054  dt=pkk(1,3)+pkk(1,4)+d34
19055  du=pkk(1,5)+pkk(1,6)+d56
19056  fgk135=abs(fgk(1,2,3,4,5,6)-fgk(1,2,5,6,3,4))
19057  fgk136=abs(fgk(1,2,3,4,6,5)-fgk(1,2,6,5,3,4))
19058  wt=(coup(5,3)*fgk135)**2+(coup(5,4)*fgk136)**2
19059  wtmax=4d0*d34*d56*(coup(5,3)**2+coup(5,4)**2)*
19060  & (digk(dt,du)+digk(du,dt)-djgk(dt,du))
19061  ELSEIF(mzpwp.EQ.1) THEN
19062 C...Angular weight for f + fbar' -> W' -> W + Z0 -> 4 quarks/leptons
19063 C...(W/Z approximately longitudinal, like if intermediate H).
19064  wt=16d0*pkk(3,5)*pkk(4,6)
19065  wtmax=sh**2
19066  ELSE
19067 C...Angular weight for f + fbar -> W' -> W + h0 -> whatever,
19068 C...t + bbar -> t + W + bbar.
19069  wt=1d0
19070  wtmax=1d0
19071  ENDIF
19072 
19073  ELSEIF(isub.EQ.145.OR.isub.EQ.162.OR.isub.EQ.163.OR.isub.EQ.164)
19074  & THEN
19075 C...Isotropic decay of leptoquarks (assumed spin 0).
19076  wt=1d0
19077  wtmax=1d0
19078 
19079  ELSEIF(isub.GE.146.AND.isub.LE.148) THEN
19080 C...Decays of (spin 1/2) q*/e* -> q/e + (g,gamma) or (Z0,W+-).
19081  side=1d0
19082  IF(mint(16).EQ.21.OR.mint(16).EQ.22) side=-1d0
19083  IF(ip.EQ.1.AND.(kfl1(1).EQ.21.OR.kfl1(1).EQ.22)) THEN
19084  wt=1d0+side*cthe(1)
19085  wtmax=2d0
19086  ELSEIF(ip.EQ.1) THEN
19087 
19088  rm1=p(nsd(1)+1,5)**2/sh
19089  wt=1d0+side*cthe(1)*(1d0-0.5d0*rm1)/(1d0+0.5d0*rm1)
19090  wtmax=1d0+(1d0-0.5d0*rm1)/(1d0+0.5d0*rm1)
19091  ELSE
19092 C...W/Z decay assumed isotropic, since not known.
19093  wt=1d0
19094  wtmax=1d0
19095  ENDIF
19096 
19097  ELSEIF(isub.EQ.149) THEN
19098 C...Isotropic decay of techni-eta.
19099  wt=1d0
19100  wtmax=1d0
19101 
19102  ELSEIF(isub.EQ.191) THEN
19103  IF(ip.EQ.1.AND.iabs(kfl1(1)).GT.21) THEN
19104 C...Angular weight for f + fbar -> rho_tc0 -> W+ W-,
19105 C...W+ pi_tc-, pi_tc+ W- or pi_tc+ pi_tc-.
19106  wt=1d0-cthe(1)**2
19107  wtmax=1d0
19108  ELSEIF(ip.EQ.1) THEN
19109 C...Angular weight for f + fbar -> rho_tc0 -> f fbar.
19110  cthesg=cthe(1)*isign(1,mint(15))
19111  xwrht=(1d0-2d0*xw)/(4d0*xw*(1d0-xw))
19112  bwzr=xwrht*sh*(sh-sqmz)/((sh-sqmz)**2+gmmz**2)
19113  bwzi=xwrht*sh*gmmz/((sh-sqmz)**2+gmmz**2)
19114  kfai=iabs(mint(15))
19115  ei=kchg(kfai,1)/3d0
19116  ai=sign(1d0,ei+0.1d0)
19117  vi=ai-4d0*ei*xwv
19118  vali=0.5d0*(vi+ai)
19119  vari=0.5d0*(vi-ai)
19120  alefti=(ei+vali*bwzr)**2+(vali*bwzi)**2
19121  arighi=(ei+vari*bwzr)**2+(vari*bwzi)**2
19122  kfaf=iabs(kfl1(1))
19123  ef=kchg(kfaf,1)/3d0
19124  af=sign(1d0,ef+0.1d0)
19125  vf=af-4d0*ef*xwv
19126  valf=0.5d0*(vf+af)
19127  varf=0.5d0*(vf-af)
19128  aleftf=(ef+valf*bwzr)**2+(valf*bwzi)**2
19129  arighf=(ef+varf*bwzr)**2+(varf*bwzi)**2
19130  asame=alefti*aleftf+arighi*arighf
19131  aflip=alefti*arighf+arighi*aleftf
19132  wt=asame*(1d0+cthesg)**2+aflip*(1d0-cthesg)**2
19133  wtmax=4d0*max(asame,aflip)
19134  ELSE
19135 C...Isotropic decay of W/pi_tc produced in rho_tc decay.
19136  wt=1d0
19137  wtmax=1d0
19138  ENDIF
19139 
19140  ELSEIF(isub.EQ.192) THEN
19141  IF(ip.EQ.1.AND.iabs(kfl1(1)).GT.21) THEN
19142 C...Angular weight for f + fbar' -> rho_tc+ -> W+ Z0,
19143 C...W+ pi_tc0, pi_tc+ Z0 or pi_tc+ pi_tc0.
19144  wt=1d0-cthe(1)**2
19145  wtmax=1d0
19146  ELSEIF(ip.EQ.1) THEN
19147 C...Angular weight for f + fbar' -> rho_tc+ -> f fbar'.
19148  cthesg=cthe(1)*isign(1,mint(15))
19149  wt=(1d0+cthesg)**2
19150  wtmax=4d0
19151  ELSE
19152 C...Isotropic decay of W/Z/pi_tc produced in rho_tc+ decay.
19153  wt=1d0
19154  wtmax=1d0
19155  ENDIF
19156 
19157  ELSEIF(isub.EQ.193) THEN
19158  IF(ip.EQ.1.AND.iabs(kfl1(1)).GT.21) THEN
19159 C...Angular weight for f + fbar -> omega_tc0 ->
19160 C...gamma pi_tc0 or Z0 pi_tc0.
19161  wt=1d0+cthe(1)**2
19162  wtmax=2d0
19163  ELSEIF(ip.EQ.1) THEN
19164 C...Angular weight for f + fbar -> omega_tc0 -> f fbar.
19165  cthesg=cthe(1)*isign(1,mint(15))
19166  bwzr=(0.5d0/(1d0-xw))*sh*(sh-sqmz)/((sh-sqmz)**2+gmmz**2)
19167  bwzi=(0.5d0/(1d0-xw))*sh*gmmz/((sh-sqmz)**2+gmmz**2)
19168  kfai=iabs(mint(15))
19169  ei=kchg(kfai,1)/3d0
19170  ai=sign(1d0,ei+0.1d0)
19171  vi=ai-4d0*ei*xwv
19172  vali=0.5d0*(vi+ai)
19173  vari=0.5d0*(vi-ai)
19174  blefti=(ei-vali*bwzr)**2+(vali*bwzi)**2
19175  brighi=(ei-vari*bwzr)**2+(vari*bwzi)**2
19176  kfaf=iabs(kfl1(1))
19177  ef=kchg(kfaf,1)/3d0
19178  af=sign(1d0,ef+0.1d0)
19179  vf=af-4d0*ef*xwv
19180  valf=0.5d0*(vf+af)
19181  varf=0.5d0*(vf-af)
19182  bleftf=(ef-valf*bwzr)**2+(valf*bwzi)**2
19183  brighf=(ef-varf*bwzr)**2+(varf*bwzi)**2
19184  bsame=blefti*bleftf+brighi*brighf
19185  bflip=blefti*brighf+brighi*bleftf
19186  wt=bsame*(1d0+cthesg)**2+bflip*(1d0-cthesg)**2
19187  wtmax=4d0*max(bsame,bflip)
19188  ELSE
19189 C...Isotropic decay of Z/pi_tc produced in omega_tc decay.
19190  wt=1d0
19191  wtmax=1d0
19192  ENDIF
19193 
19194  ELSEIF(isub.EQ.353) THEN
19195 C...Angular weight for Z_R0 -> 2 quarks/leptons.
19196  ei=kchg(iabs(mint(15)),1)/3d0
19197  ai=sign(1d0,ei+0.1d0)
19198  vi=ai-4d0*ei*xwv
19199  ef=kchg(pycomp(kfl1(1)),1)/3d0
19200  af=sign(1d0,ef+0.1d0)
19201  vf=af-4d0*ef*xwv
19202  rmf=min(1d0,4d0*pmas(pycomp(kfl1(1)),1)**2/sh)
19203  wt1=(vi**2+ai**2)*(vf**2+(1d0-rmf)*af**2)
19204  wt2=rmf*(vi**2+ai**2)*vf**2
19205  wt3=sqrt(1d0-rmf)*4d0*vi*ai*vf*af
19206  wt=wt1*(1d0+cthe(1)**2)+wt2*(1d0-cthe(1)**2)+
19207  & 2d0*wt3*cthe(1)*isign(1,mint(15)*kfl1(1))
19208  wtmax=2d0*(wt1+abs(wt3))
19209 
19210  ELSEIF(isub.EQ.354) THEN
19211 C...Angular weight for W_R+/- -> 2 quarks/leptons.
19212  rm3=pmas(pycomp(kfl1(1)),1)**2/sh
19213  rm4=pmas(pycomp(kfl2(1)),1)**2/sh
19214  be34=sqrt(max(0d0,(1d0-rm3-rm4)**2-4d0*rm3*rm4))
19215  wt=(1d0+be34*cthe(1)*isign(1,mint(15)*kfl1(1)))**2-(rm3-rm4)**2
19216  wtmax=4d0
19217 
19218  ELSEIF(isub.EQ.391) THEN
19219 C...Angular weight for f + fbar -> G* -> f + fbar
19220  IF(ip.EQ.1.AND.iabs(kfl1(1)).LE.18) THEN
19221  wt=1d0-3d0*cthe(1)**2+4d0*cthe(1)**4
19222  wtmax=2d0
19223 C...Angular weight for f + fbar -> G* -> gamma + gamma or g + g
19224 C...implemented by M.-C. Lemaire
19225  ELSEIF(ip.EQ.1.AND.(iabs(kfl1(1)).EQ.21.OR.
19226  & iabs(kfl1(1)).EQ.22)) THEN
19227  wt=1d0-cthe(1)**4
19228  wtmax=1d0
19229 C...Other G* decays not yet implemented angular distributions.
19230  ELSE
19231  wt=1d0
19232  wtmax=1d0
19233  ENDIF
19234 
19235  ELSEIF(isub.EQ.392) THEN
19236 C...Angular weight for g + g -> G* -> f + fbar
19237  IF(ip.EQ.1.AND.iabs(kfl1(1)).LE.18) THEN
19238  wt=1d0-cthe(1)**4
19239  wtmax=1d0
19240 C...Angular weight for g + g -> G* -> gamma +gamma or g + g
19241 C...implemented by M.-C. Lemaire
19242  ELSEIF(ip.EQ.1.AND.(iabs(kfl1(1)).EQ.21.OR.
19243  & iabs(kfl1(1)).EQ.22)) THEN
19244  wt=1d0+6d0*cthe(1)**2+cthe(1)**4
19245  wtmax=8d0
19246 C...Other G* decays not yet implemented angular distributions.
19247  ELSE
19248  wt=1d0
19249  wtmax=1d0
19250  ENDIF
19251 
19252 C...Obtain correct angular distribution by rejection techniques.
19253  ELSE
19254  wt=1d0
19255  wtmax=1d0
19256  ENDIF
19257  IF(wt.LT.pyr(0)*wtmax) goto 430
19258 
19259 C...Construct massive four-vectors using angles chosen.
19260  590 DO 690 jt=1,jtmax
19261  IF(kdcy(jt).EQ.0) goto 690
19262  id=iref(ip,jt)
19263  DO 600 j=1,5
19264  dpmo(j)=p(id,j)
19265  600 CONTINUE
19266  dpmo(4)=sqrt(dpmo(1)**2+dpmo(2)**2+dpmo(3)**2+dpmo(5)**2)
19267 CMRENNA++
19268  nprod=2
19269  IF(kfl3(jt).NE.0) nprod=3
19270  IF(kfl4(jt).NE.0) nprod=4
19271  CALL pyrobo(nsd(jt)+1,nsd(jt)+nprod,acos(cthe(jt)),phi(jt),
19272  & dpmo(1)/dpmo(4),dpmo(2)/dpmo(4),dpmo(3)/dpmo(4))
19273  n0=nsd(jt)+nprod
19274 
19275  DO 610 j=1,4
19276  vdcy(j)=v(id,j)+v(id,5)*p(id,j)/p(id,5)
19277  610 CONTINUE
19278 C...Fill in position of decay vertex.
19279  DO 630 i=nsd(jt)+1,n0
19280  DO 620 j=1,4
19281  v(i,j)=vdcy(j)
19282  620 CONTINUE
19283  v(i,5)=0d0
19284 
19285  630 CONTINUE
19286 CMRENNA--
19287 
19288 C...Mark decayed resonances; trace history.
19289  k(id,1)=k(id,1)+10
19290  kfa=iabs(k(id,2))
19291  kca=pycomp(kfa)
19292  IF(kcqm(jt).NE.0) THEN
19293 C...Do not kill colour flow through coloured resonance!
19294  ELSE
19295  k(id,4)=nsd(jt)+1
19296  k(id,5)=nsd(jt)+nprod
19297  IF(itjunc(jt).NE.0) k(id,5)=k(id,5)+1
19298 C...If 3-body or 2-body with junction:
19299 c IF(KFL3(JT).NE.0.OR.ITJUNC(JT).NE.0) K(ID,5)=NSD(JT)+3
19300 C...If 3-body with junction:
19301 c IF(ITJUNC(JT).NE.0.AND.KFL3(JT).NE.0) K(ID,5)=NSD(JT)+4
19302  ENDIF
19303 
19304 C...Add documentation lines.
19305  isubrg=max(1,min(500,mint(1)))
19306  IF(ires.EQ.0.OR.iset(isubrg).EQ.11) THEN
19307  idoc=mint(83)+mint(4)
19308 CMRENNA+++
19309  ihi=nsd(jt)+nprod
19310 c IF(KFL3(JT).NE.0) IHI=IHI+1
19311  DO 650 i=nsd(jt)+1,ihi
19312 CMRENNA---
19313  i1=mint(83)+mint(4)+1
19314  k(i,3)=i1
19315  IF(mstp(128).GE.1) k(i,3)=id
19316  IF(mstp(128).LE.1.AND.mint(4).LT.mstp(126)) THEN
19317  mint(4)=mint(4)+1
19318  k(i1,1)=21
19319  k(i1,2)=k(i,2)
19320  k(i1,3)=iref(ip,jt+3)
19321  DO 640 j=1,5
19322  p(i1,j)=p(i,j)
19323  640 CONTINUE
19324  ENDIF
19325  650 CONTINUE
19326  ELSE
19327  k(nsd(jt)+1,3)=id
19328  k(nsd(jt)+2,3)=id
19329 C...If 3-body or 2-body with junction:
19330  IF(kfl3(jt).NE.0.OR.itjunc(jt).GT.0) k(nsd(jt)+3,3)=id
19331 C...If 3-body with junction:
19332  IF(kfl3(jt).NE.0.AND.itjunc(jt).GT.0) k(nsd(jt)+4,3)=id
19333 C...If 4-body or 3-body with junction:
19334  IF(kfl4(jt).NE.0.OR.itjunc(jt).GT.0) k(nsd(jt)+4,3)=id
19335 C...If 4-body with junction:
19336  IF(kfl4(jt).NE.0.AND.itjunc(jt).GT.0) k(nsd(jt)+5,3)=id
19337  ENDIF
19338 
19339 C...Do showering of two or three objects.
19340  nshbef=n
19341  IF(mstp(71).GE.1.AND.mint(35).LE.1) THEN
19342  IF(kfl3(jt).EQ.0) THEN
19343  CALL pyshow(nsd(jt)+1,nsd(jt)+2,p(id,5))
19344  ELSE
19345  CALL pyshow(nsd(jt)+1,-nprod,p(id,5))
19346  ENDIF
19347 
19348 c...For pT-ordered shower need set up first, especially colour tags.
19349 C...(Need to set up colour tags even if MSTP(71) = 0)
19350  ELSEIF(mint(35).GE.2) THEN
19351  npart=nprod
19352 c IF(KFL3(JT).NE.0) NPART=3
19353  ipart(1)=nsd(jt)+1
19354  ipart(2)=nsd(jt)+2
19355  ipart(3)=nsd(jt)+3
19356  ipart(4)=nsd(jt)+4
19357  ptpart(1)=0.5d0*p(id,5)
19358  ptpart(2)=ptpart(1)
19359  ptpart(3)=ptpart(1)
19360  ptpart(4)=ptpart(1)
19361  IF(kcq1(jt).EQ.1.OR.kcq1(jt).EQ.2) THEN
19362  mother=k(nsd(jt)+1,4)/mstu(5)
19363  IF(mother.LE.nsd(jt)) THEN
19364  mct(nsd(jt)+1,1)=mct(mother,1)
19365  ELSE
19366  nct=nct+1
19367  mct(nsd(jt)+1,1)=nct
19368  mct(mother,2)=nct
19369  ENDIF
19370  ENDIF
19371  IF(kcq1(jt).EQ.-1.OR.kcq1(jt).EQ.2) THEN
19372  mother=k(nsd(jt)+1,5)/mstu(5)
19373  IF(mother.LE.nsd(jt)) THEN
19374  mct(nsd(jt)+1,2)=mct(mother,2)
19375  ELSE
19376  nct=nct+1
19377  mct(nsd(jt)+1,2)=nct
19378  mct(mother,1)=nct
19379  ENDIF
19380  ENDIF
19381  IF(mct(nsd(jt)+2,1).EQ.0.AND.(kcq2(jt).EQ.1.OR.
19382  & kcq2(jt).EQ.2)) THEN
19383  mother=k(nsd(jt)+2,4)/mstu(5)
19384  IF(mother.LE.nsd(jt)) THEN
19385  mct(nsd(jt)+2,1)=mct(mother,1)
19386  ELSE
19387  nct=nct+1
19388  mct(nsd(jt)+2,1)=nct
19389  mct(mother,2)=nct
19390  ENDIF
19391  ENDIF
19392  IF(mct(nsd(jt)+2,2).EQ.0.AND.(kcq2(jt).EQ.-1.OR.
19393  & kcq2(jt).EQ.2)) THEN
19394  mother=k(nsd(jt)+2,5)/mstu(5)
19395  IF(mother.LE.nsd(jt)) THEN
19396  mct(nsd(jt)+2,2)=mct(mother,2)
19397  ELSE
19398  nct=nct+1
19399  mct(nsd(jt)+2,2)=nct
19400  mct(mother,1)=nct
19401  ENDIF
19402  ENDIF
19403  IF(npart.EQ.3.AND.mct(nsd(jt)+3,1).EQ.0.AND.
19404  & (kcq3(jt).EQ.1.OR. kcq3(jt).EQ.2)) THEN
19405  mother=k(nsd(jt)+3,4)/mstu(5)
19406  mct(nsd(jt)+3,1)=mct(mother,1)
19407  ENDIF
19408  IF(npart.EQ.3.AND.mct(nsd(jt)+3,2).EQ.0.AND.
19409  & (kcq3(jt).EQ.-1.OR.kcq3(jt).EQ.2)) THEN
19410  mother=k(nsd(jt)+3,5)/mstu(5)
19411  mct(nsd(jt)+2,2)=mct(mother,2)
19412  ENDIF
19413  IF(npart.EQ.4.AND.mct(nsd(jt)+4,1).EQ.0.AND.
19414  & (kcq4(jt).EQ.1.OR. kcq4(jt).EQ.2)) THEN
19415  mother=k(nsd(jt)+4,4)/mstu(5)
19416  mct(nsd(jt)+4,1)=mct(mother,1)
19417  ENDIF
19418  IF(npart.EQ.4.AND.mct(nsd(jt)+4,2).EQ.0.AND.
19419  & (kcq4(jt).EQ.-1.OR.kcq4(jt).EQ.2)) THEN
19420  mother=k(nsd(jt)+4,5)/mstu(5)
19421  mct(nsd(jt)+4,2)=mct(mother,2)
19422  ENDIF
19423 
19424  IF (mstp(71).GE.1) CALL pyptfs(2,0.5d0*p(id,5),0d0,ptgen)
19425  ENDIF
19426  nshaft=n
19427  IF(jt.EQ.1) naft1=n
19428 
19429 C...Check if decay products moved by shower.
19430  nsd1=nsd(jt)+1
19431  nsd2=nsd(jt)+2
19432  nsd3=nsd(jt)+3
19433  nsd4=nsd(jt)+4
19434 C...4-body decays will only work if one of the products is "inert"
19435  IF(nshaft.GT.nshbef) THEN
19436  IF(k(nsd1,1).GT.10) THEN
19437  DO 660 i=nshbef+1,nshaft
19438  IF(k(i,1).LT.10.AND.k(i,2).EQ.k(nsd1,2)) nsd1=i
19439  660 CONTINUE
19440  ENDIF
19441  IF(k(nsd2,1).GT.10) THEN
19442  DO 670 i=nshbef+1,nshaft
19443  IF(k(i,1).LT.10.AND.k(i,2).EQ.k(nsd2,2).AND.
19444  & i.NE.nsd1) nsd2=i
19445  670 CONTINUE
19446  ENDIF
19447  IF(kfl3(jt).NE.0.AND.k(nsd3,1).GT.10) THEN
19448  DO 680 i=nshbef+1,nshaft
19449  IF(k(i,1).LT.10.AND.k(i,2).EQ.k(nsd3,2).AND.
19450  & i.NE.nsd1.AND.i.NE.nsd2) nsd3=i
19451  680 CONTINUE
19452  ENDIF
19453  IF(kfl4(jt).NE.0.AND.k(nsd4,1).GT.10) THEN
19454  DO 685 i=nshbef+1,nshaft
19455  IF(k(i,1).LT.10.AND.k(i,2).EQ.k(nsd4,2).AND.
19456  & i.NE.nsd1.AND.i.NE.nsd2.AND.i.NE.nsd3) nsd4=i
19457  685 CONTINUE
19458  ENDIF
19459  ENDIF
19460 
19461 C...Store decay products for further treatment.
19462  IF(kfl4(jt).EQ.0) THEN
19463  np=np+1
19464  iref(np,1)=nsd1
19465  iref(np,2)=nsd2
19466  iref(np,3)=0
19467  IF(kfl3(jt).NE.0) iref(np,3)=nsd3
19468  iref(np,4)=idoc+1
19469  iref(np,5)=idoc+2
19470  iref(np,6)=0
19471  IF(kfl3(jt).NE.0) iref(np,6)=idoc+3
19472  iref(np,7)=k(iref(ip,jt),2)
19473  iref(np,8)=iref(ip,jt)
19474  ELSE
19475  nsda=nsd1
19476  nsdb=nsd2
19477  nsdc=nsd3
19478  np=np+1
19479  iref(np,4)=idoc+1
19480  iref(np,5)=idoc+2
19481  iref(np,6)=idoc+3
19482  IF(k(nsd1,1).EQ.1) THEN
19483  nsda=nsd4
19484  iref(np,4)=idoc+4
19485  ELSEIF(k(nsd2,1).EQ.1) THEN
19486  nsdb=nsd4
19487  iref(np,5)=idoc+4
19488  ELSEIF(k(nsd3,1).EQ.1) THEN
19489  nsdc=nsd4
19490  iref(np,6)=idoc+4
19491  ENDIF
19492  iref(np,1)=nsda
19493  iref(np,2)=nsdb
19494  iref(np,3)=nsdc
19495  iref(np,7)=k(iref(ip,jt),2)
19496  iref(np,8)=iref(ip,jt)
19497  ENDIF
19498  690 CONTINUE
19499 
19500 
19501 C...Fill information for 2 -> 1 -> 2.
19502  700 IF(jtmax.EQ.1.AND.kdcy(1).NE.0.AND.isub.NE.0) THEN
19503  mint(7)=mint(83)+6+2*iset(isub)
19504  mint(8)=mint(83)+7+2*iset(isub)
19505  mint(25)=kfl1(1)
19506  mint(26)=kfl2(1)
19507  vint(23)=cthe(1)
19508  rm3=p(n-1,5)**2/sh
19509  rm4=p(n,5)**2/sh
19510  be34=sqrt(max(0d0,(1d0-rm3-rm4)**2-4d0*rm3*rm4))
19511  vint(45)=-0.5d0*sh*(1d0-rm3-rm4-be34*cthe(1))
19512  vint(46)=-0.5d0*sh*(1d0-rm3-rm4+be34*cthe(1))
19513  vint(48)=0.25d0*sh*be34**2*max(0d0,1d0-cthe(1)**2)
19514  vint(47)=sqrt(vint(48))
19515  ENDIF
19516 
19517 C...Possibility of colour rearrangement in W+W- events.
19518  IF((isub.EQ.25.OR.isub.EQ.22).AND.mstp(115).GE.1) THEN
19519  iakf1=iabs(kfl1(1))
19520  iakf2=iabs(kfl1(2))
19521  iakf3=iabs(kfl2(1))
19522  iakf4=iabs(kfl2(2))
19523  IF(min(iakf1,iakf2,iakf3,iakf4).GE.1.AND.
19524  & max(iakf1,iakf2,iakf3,iakf4).LE.5) CALL
19525  & pyreco(iref(1,1),iref(1,2),nsd(1),naft1)
19526  IF(mint(51).NE.0) RETURN
19527  ENDIF
19528 
19529 C...Loop back if needed.
19530  710 IF(ip.LT.np) goto 170
19531 
19532 C...Boost back to standard frame.
19533  720 IF(ibst.EQ.1) CALL pyrobo(mint(83)+7,n,thein,phiin,bexin,beyin,
19534  &bezin)
19535 
19536 
19537  RETURN
19538  END
19539 
19540 C*********************************************************************
19541 
19542 C...PYMULT
19543 C...Initializes treatment of multiple interactions, selects kinematics
19544 C...of hardest interaction if low-pT physics included in run, and
19545 C...generates all non-hardest interactions.
19546 
19547  SUBROUTINE pymult(MMUL)
19548 
19549 C...Double precision and integer declarations.
19550  IMPLICIT DOUBLE PRECISION(a-h, o-z)
19551  IMPLICIT INTEGER(i-n)
19552  INTEGER pyk,pychge,pycomp
19553 C...Commonblocks.
19554  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
19555  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
19556  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
19557  common/pysubs/msel,mselpd,msub(500),kfin(2,-40:40),ckin(200)
19558  common/pypars/mstp(200),parp(200),msti(200),pari(200)
19559  common/pyint1/mint(400),vint(400)
19560  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
19561  common/pyint3/xsfx(2,-40:40),isig(1000,3),sigh(1000)
19562  common/pyint5/ngenpd,ngen(0:500,3),xsec(0:500,3)
19563  common/pyint7/sigt(0:6,0:6,0:5)
19564  SAVE /pyjets/,/pydat1/,/pydat2/,/pysubs/,/pypars/,/pyint1/,
19565  &/pyint2/,/pyint3/,/pyint5/,/pyint7/
19566 C...Local arrays and saved variables.
19567  dimension nmul(20),sigm(20),kstr(500,2),vintsv(80)
19568  SAVE xt2,xt2fac,xc2,xts,irbin,rbin,nmul,sigm,p83a,p83b,p83c,
19569  &cq2i,cq2r,pik,bdiv,b,plowb,phighb,pallb,s4a,s4b,s4c,powip,
19570  &rpwip,b2rpdv,b2rpmx,bavg,vnt145,vnt146,vnt147
19571 
19572 C...Initialization of multiple interaction treatment.
19573  IF(mmul.EQ.1) THEN
19574  IF(mstp(122).GE.1) WRITE(mstu(11),5000) mstp(82)
19575  isub=96
19576  mint(1)=96
19577  vint(63)=0d0
19578  vint(64)=0d0
19579  vint(143)=1d0
19580  vint(144)=1d0
19581 
19582 C...Loop over phase space points: xT2 choice in 20 bins.
19583  100 sigsum=0d0
19584  DO 120 ixt2=1,20
19585  nmul(ixt2)=mstp(83)
19586  sigm(ixt2)=0d0
19587  DO 110 itry=1,mstp(83)
19588  rsca=0.05d0*((21-ixt2)-pyr(0))
19589  xt2=vint(149)*(1d0+vint(149))/(vint(149)+rsca)-vint(149)
19590  xt2=max(0.01d0*vint(149),xt2)
19591  vint(25)=xt2
19592 
19593 C...Choose tau and y*. Calculate cos(theta-hat).
19594  IF(pyr(0).LE.coef(isub,1)) THEN
19595  taut=(2d0*(1d0+sqrt(1d0-xt2))/xt2-1d0)**pyr(0)
19596  tau=xt2*(1d0+taut)**2/(4d0*taut)
19597  ELSE
19598  tau=xt2*(1d0+tan(pyr(0)*atan(sqrt(1d0/xt2-1d0)))**2)
19599  ENDIF
19600  vint(21)=tau
19601  CALL pyklim(2)
19602  ryst=pyr(0)
19603  myst=1
19604  IF(ryst.GT.coef(isub,8)) myst=2
19605  IF(ryst.GT.coef(isub,8)+coef(isub,9)) myst=3
19606  CALL pykmap(2,myst,pyr(0))
19607  vint(23)=sqrt(max(0d0,1d0-xt2/tau))*(-1)**int(1.5d0+pyr(0))
19608 
19609 C...Calculate differential cross-section.
19610  vint(71)=0.5d0*vint(1)*sqrt(xt2)
19611  CALL pysigh(nchn,sigs)
19612  sigm(ixt2)=sigm(ixt2)+sigs
19613  110 CONTINUE
19614  sigsum=sigsum+sigm(ixt2)
19615  120 CONTINUE
19616  sigsum=sigsum/(20d0*mstp(83))
19617 
19618 C...Reject result if sigma(parton-parton) is smaller than hadronic one.
19619  IF(sigsum.LT.1.1d0*sigt(0,0,5)) THEN
19620  IF(mstp(122).GE.1) WRITE(mstu(11),5100)
19621  & parp(82)*(vint(1)/parp(89))**parp(90),sigsum
19622  parp(82)=0.9d0*parp(82)
19623  vint(149)=4d0*(parp(82)*(vint(1)/parp(89))**parp(90))**2/
19624  & vint(2)
19625  goto 100
19626  ENDIF
19627  IF(mstp(122).GE.1) WRITE(mstu(11),5200)
19628  & parp(82)*(vint(1)/parp(89))**parp(90), sigsum
19629 
19630 C...Start iteration to find k factor.
19631  yke=sigsum/max(1d-10,sigt(0,0,5))
19632  p83a=(1d0-parp(83))**2
19633  p83b=2d0*parp(83)*(1d0-parp(83))
19634  p83c=parp(83)**2
19635  cq2i=1d0/parp(84)**2
19636  cq2r=2d0/(1d0+parp(84)**2)
19637  so=0.5d0
19638  xi=0d0
19639  yi=0d0
19640  xf=0d0
19641  yf=0d0
19642  xk=0.5d0
19643  iit=0
19644  130 IF(iit.EQ.0) THEN
19645  xk=2d0*xk
19646  ELSEIF(iit.EQ.1) THEN
19647  xk=0.5d0*xk
19648  ELSE
19649  xk=xi+(yke-yi)*(xf-xi)/(yf-yi)
19650  ENDIF
19651 
19652 C...Evaluate overlap integrals. Find where to divide the b range.
19653  IF(mstp(82).EQ.2) THEN
19654  sp=0.5d0*paru(1)*(1d0-exp(-xk))
19655  sop=sp/paru(1)
19656  ELSE
19657  IF(mstp(82).EQ.3) THEN
19658  deltab=0.02d0
19659  ELSEIF(mstp(82).EQ.4) THEN
19660  deltab=min(0.01d0,0.05d0*parp(84))
19661  ELSE
19662  powip=max(0.4d0,parp(83))
19663  rpwip=2d0/powip-1d0
19664  deltab=max(0.02d0,0.02d0*(2d0/powip)**(1d0/powip))
19665  so=0d0
19666  ENDIF
19667  sp=0d0
19668  sop=0d0
19669  bsp=0d0
19670  sohigh=0d0
19671  ibdiv=0
19672  b=-0.5d0*deltab
19673  140 b=b+deltab
19674  IF(mstp(82).EQ.3) THEN
19675  ov=exp(-b**2)/paru(2)
19676  ELSEIF(mstp(82).EQ.4) THEN
19677  ov=(p83a*exp(-min(50d0,b**2))+
19678  & p83b*cq2r*exp(-min(50d0,b**2*cq2r))+
19679  & p83c*cq2i*exp(-min(50d0,b**2*cq2i)))/paru(2)
19680  ELSE
19681  ov=exp(-b**powip)/paru(2)
19682  so=so+paru(2)*b*deltab*ov
19683  ENDIF
19684  IF(ibdiv.EQ.1) sohigh=sohigh+paru(2)*b*deltab*ov
19685  pacc=1d0-exp(-min(50d0,paru(1)*xk*ov))
19686  sp=sp+paru(2)*b*deltab*pacc
19687  sop=sop+paru(2)*b*deltab*ov*pacc
19688  bsp=bsp+b*paru(2)*b*deltab*pacc
19689  IF(ibdiv.EQ.0.AND.paru(1)*xk*ov.LT.1d0) THEN
19690  ibdiv=1
19691  bdiv=b+0.5d0*deltab
19692  ENDIF
19693  IF(b.LT.1d0.OR.b*pacc.GT.1d-6) goto 140
19694  ENDIF
19695  yk=paru(1)*xk*so/sp
19696 
19697 C...Continue iteration until convergence.
19698  IF(yk.LT.yke) THEN
19699  xi=xk
19700  yi=yk
19701  IF(iit.EQ.1) iit=2
19702  ELSE
19703  xf=xk
19704  yf=yk
19705  IF(iit.EQ.0) iit=1
19706  ENDIF
19707  IF(abs(yk-yke).GE.1d-5*yke) goto 130
19708 
19709 C...Store some results for subsequent use.
19710  bavg=bsp/sp
19711  vint(145)=sigsum
19712  vint(146)=sop/so
19713  vint(147)=sop/sp
19714  vnt145=vint(145)
19715  vnt146=vint(146)
19716  vnt147=vint(147)
19717 C...PIK = PARU(1)*XK = (VINT(146)/VINT(147))*sigma_jet/sigma_nondiffr.
19718  pik=(vnt146/vnt147)*yke
19719 
19720 C...Find relative weight for low and high impact parameter.
19721  plowb=paru(1)*bdiv**2
19722  IF(mstp(82).EQ.3) THEN
19723  phighb=pik*0.5*exp(-bdiv**2)
19724  ELSEIF(mstp(82).EQ.4) THEN
19725  s4a=p83a*exp(-bdiv**2)
19726  s4b=p83b*exp(-bdiv**2*cq2r)
19727  s4c=p83c*exp(-bdiv**2*cq2i)
19728  phighb=pik*0.5*(s4a+s4b+s4c)
19729  ELSEIF(parp(83).GE.1.999d0) THEN
19730  phighb=pik*sohigh
19731  b2rpdv=bdiv**powip
19732  ELSE
19733  phighb=pik*sohigh
19734  b2rpdv=bdiv**powip
19735  b2rpmx=max(2d0*rpwip,b2rpdv)
19736  ENDIF
19737  pallb=plowb+phighb
19738 
19739 C...Initialize iteration in xT2 for hardest interaction.
19740  ELSEIF(mmul.EQ.2) THEN
19741  vint(145)=vnt145
19742  vint(146)=vnt146
19743  vint(147)=vnt147
19744  IF(mstp(82).LE.0) THEN
19745  ELSEIF(mstp(82).EQ.1) THEN
19746  xt2=1d0
19747  sigrat=xsec(96,1)/max(1d-10,vint(315)*vint(316)*sigt(0,0,5))
19748  IF(mint(141).NE.0.OR.mint(142).NE.0) sigrat=sigrat*
19749  & vint(317)/(vint(318)*vint(320))
19750  xt2fac=sigrat*vint(149)/(1d0-vint(149))
19751  ELSEIF(mstp(82).EQ.2) THEN
19752  xt2=1d0
19753  xt2fac=vnt146*xsec(96,1)/max(1d-10,sigt(0,0,5))*
19754  & vint(149)*(1d0+vint(149))
19755  ELSE
19756  xc2=4d0*ckin(3)**2/vint(2)
19757  IF(ckin(3).LE.ckin(5).OR.mint(82).GE.2) xc2=0d0
19758  ENDIF
19759 
19760 C...Select impact parameter for hardest interaction.
19761  IF(mstp(82).LE.2) RETURN
19762  142 IF(pyr(0)*pallb.LT.plowb) THEN
19763 C...Treatment in low b region.
19764  mint(39)=1
19765  b=bdiv*sqrt(pyr(0))
19766  IF(mstp(82).EQ.3) THEN
19767  ov=exp(-b**2)/paru(2)
19768  ELSEIF(mstp(82).EQ.4) THEN
19769  ov=(p83a*exp(-min(50d0,b**2))+
19770  & p83b*cq2r*exp(-min(50d0,b**2*cq2r))+
19771  & p83c*cq2i*exp(-min(50d0,b**2*cq2i)))/paru(2)
19772  ELSE
19773  ov=exp(-b**powip)/paru(2)
19774  ENDIF
19775  vint(148)=ov/vnt147
19776  pacc=1d0-exp(-min(50d0,pik*ov))
19777  xt2=1d0
19778  xt2fac=vnt146*vint(148)*xsec(96,1)/max(1d-10,sigt(0,0,5))*
19779  & vint(149)*(1d0+vint(149))
19780  ELSE
19781 C...Treatment in high b region.
19782  mint(39)=2
19783  IF(mstp(82).EQ.3) THEN
19784  b=sqrt(bdiv**2-log(pyr(0)))
19785  ov=exp(-b**2)/paru(2)
19786  ELSEIF(mstp(82).EQ.4) THEN
19787  s4rndm=pyr(0)*(s4a+s4b+s4c)
19788  IF(s4rndm.LT.s4a) THEN
19789  b=sqrt(bdiv**2-log(pyr(0)))
19790  ELSEIF(s4rndm.LT.s4a+s4b) THEN
19791  b=sqrt(bdiv**2-log(pyr(0))/cq2r)
19792  ELSE
19793  b=sqrt(bdiv**2-log(pyr(0))/cq2i)
19794  ENDIF
19795  ov=(p83a*exp(-min(50d0,b**2))+
19796  & p83b*cq2r*exp(-min(50d0,b**2*cq2r))+
19797  & p83c*cq2i*exp(-min(50d0,b**2*cq2i)))/paru(2)
19798  ELSEIF(parp(83).GE.1.999d0) THEN
19799  144 b2rpw=b2rpdv-log(pyr(0))
19800  accip=(b2rpw/b2rpdv)**rpwip
19801  IF(accip.LT.pyr(0)) goto 144
19802  ov=exp(-b2rpw)/paru(2)
19803  b=b2rpw**(1d0/powip)
19804  ELSE
19805  146 b2rpw=b2rpdv-2d0*log(pyr(0))
19806  accip=(b2rpw/b2rpmx)**rpwip*exp(-0.5d0*(b2rpw-b2rpmx))
19807  IF(accip.LT.pyr(0)) goto 146
19808  ov=exp(-b2rpw)/paru(2)
19809  b=b2rpw**(1d0/powip)
19810  ENDIF
19811  vint(148)=ov/vnt147
19812  pacc=(1d0-exp(-min(50d0,pik*ov)))/(pik*ov)
19813  ENDIF
19814  IF(pacc.LT.pyr(0)) goto 142
19815  vint(139)=b/bavg
19816 
19817  ELSEIF(mmul.EQ.3) THEN
19818 C...Low-pT or multiple interactions (first semihard interaction):
19819 C...choose xT2 according to dpT2/pT2**2*exp(-(sigma above pT2)/norm)
19820 C...or (MSTP(82)>=2) dpT2/(pT2+pT0**2)**2*exp(-....).
19821  isub=mint(1)
19822  vint(145)=vnt145
19823  vint(146)=vnt146
19824  vint(147)=vnt147
19825  IF(mstp(82).LE.0) THEN
19826  xt2=0d0
19827  ELSEIF(mstp(82).EQ.1) THEN
19828  xt2=xt2fac*xt2/(xt2fac-xt2*log(pyr(0)))
19829 C...Use with "Sudakov" for low b values when impact parameter dependence.
19830  ELSEIF(mstp(82).EQ.2.OR.mint(39).EQ.1) THEN
19831  IF(xt2.LT.1d0.AND.exp(-xt2fac*xt2/(vint(149)*(xt2+
19832  & vint(149)))).GT.pyr(0)) xt2=1d0
19833  IF(xt2.GE.1d0) THEN
19834  xt2=(1d0+vint(149))*xt2fac/(xt2fac-(1d0+vint(149))*log(1d0-
19835  & pyr(0)*(1d0-exp(-xt2fac/(vint(149)*(1d0+vint(149)))))))-
19836  & vint(149)
19837  ELSE
19838  xt2=-xt2fac/log(exp(-xt2fac/(xt2+vint(149)))+pyr(0)*
19839  & (exp(-xt2fac/vint(149))-exp(-xt2fac/(xt2+vint(149)))))-
19840  & vint(149)
19841  ENDIF
19842  xt2=max(0.01d0*vint(149),xt2)
19843 C...Use without "Sudakov" for high b values when impact parameter dep.
19844  ELSE
19845  xt2=(xc2+vint(149))*(1d0+vint(149))/(1d0+vint(149)-
19846  & pyr(0)*(1d0-xc2))-vint(149)
19847  xt2=max(0.01d0*vint(149),xt2)
19848  ENDIF
19849  vint(25)=xt2
19850 
19851 C...Low-pT: choose xT2, tau, y* and cos(theta-hat) fixed.
19852  IF(mstp(82).LE.1.AND.xt2.LT.vint(149)) THEN
19853  IF(mint(82).EQ.1) ngen(0,1)=ngen(0,1)-mint(143)
19854  IF(mint(82).EQ.1) ngen(isub,1)=ngen(isub,1)-mint(143)
19855  isub=95
19856  mint(1)=isub
19857  vint(21)=0.01d0*vint(149)
19858  vint(22)=0d0
19859  vint(23)=0d0
19860  vint(25)=0.01d0*vint(149)
19861 
19862  ELSE
19863 C...Multiple interactions (first semihard interaction).
19864 C...Choose tau and y*. Calculate cos(theta-hat).
19865  IF(pyr(0).LE.coef(isub,1)) THEN
19866  taut=(2d0*(1d0+sqrt(1d0-xt2))/xt2-1d0)**pyr(0)
19867  tau=xt2*(1d0+taut)**2/(4d0*taut)
19868  ELSE
19869  tau=xt2*(1d0+tan(pyr(0)*atan(sqrt(1d0/xt2-1d0)))**2)
19870  ENDIF
19871  vint(21)=tau
19872  CALL pyklim(2)
19873  ryst=pyr(0)
19874  myst=1
19875  IF(ryst.GT.coef(isub,8)) myst=2
19876  IF(ryst.GT.coef(isub,8)+coef(isub,9)) myst=3
19877  CALL pykmap(2,myst,pyr(0))
19878  vint(23)=sqrt(max(0d0,1d0-xt2/tau))*(-1)**int(1.5d0+pyr(0))
19879  ENDIF
19880  vint(71)=0.5d0*vint(1)*sqrt(vint(25))
19881 
19882 C...Store results of cross-section calculation.
19883  ELSEIF(mmul.EQ.4) THEN
19884  isub=mint(1)
19885  vint(145)=vnt145
19886  vint(146)=vnt146
19887  vint(147)=vnt147
19888  xts=vint(25)
19889  IF(iset(isub).EQ.1) xts=vint(21)
19890  IF(iset(isub).EQ.2)
19891  & xts=(4d0*vint(48)+2d0*vint(63)+2d0*vint(64))/vint(2)
19892  IF(iset(isub).GE.3.AND.iset(isub).LE.5) xts=vint(26)
19893  rbin=max(0.000001d0,min(0.999999d0,xts*(1d0+vint(149))/
19894  & (xts+vint(149))))
19895  irbin=int(1d0+20d0*rbin)
19896  IF(isub.EQ.96.AND.mstp(171).EQ.0) THEN
19897  nmul(irbin)=nmul(irbin)+1
19898  sigm(irbin)=sigm(irbin)+vint(153)
19899  ENDIF
19900 
19901 C...Choose impact parameter if not already done.
19902  ELSEIF(mmul.EQ.5) THEN
19903  isub=mint(1)
19904  vint(145)=vnt145
19905  vint(146)=vnt146
19906  vint(147)=vnt147
19907  150 IF(mint(39).GT.0) THEN
19908  ELSEIF(mstp(82).EQ.3) THEN
19909  expb2=pyr(0)
19910  b2=-log(pyr(0))
19911  vint(148)=expb2/(paru(2)*vnt147)
19912  vint(139)=sqrt(b2)/bavg
19913  ELSEIF(mstp(82).EQ.4) THEN
19914  rtype=pyr(0)
19915  IF(rtype.LT.p83a) THEN
19916  b2=-log(pyr(0))
19917  ELSEIF(rtype.LT.p83a+p83b) THEN
19918  b2=-log(pyr(0))/cq2r
19919  ELSE
19920  b2=-log(pyr(0))/cq2i
19921  ENDIF
19922  vint(148)=(p83a*exp(-min(50d0,b2))+
19923  & p83b*cq2r*exp(-min(50d0,b2*cq2r))+
19924  & p83c*cq2i*exp(-min(50d0,b2*cq2i)))/(paru(2)*vnt147)
19925  vint(139)=sqrt(b2)/bavg
19926  ELSEIF(parp(83).GE.1.999d0) THEN
19927  powip=max(2d0,parp(83))
19928  rpwip=2d0/powip-1d0
19929  prob1=powip/(2d0*exp(-1d0)+powip)
19930  160 IF(pyr(0).LT.prob1) THEN
19931  b2rpw=pyr(0)**(0.5d0*powip)
19932  accip=exp(-b2rpw)
19933  ELSE
19934  b2rpw=1d0-log(pyr(0))
19935  accip=b2rpw**rpwip
19936  ENDIF
19937  IF(accip.LT.pyr(0)) goto 160
19938  vint(148)=exp(-b2rpw)/(paru(2)*vnt147)
19939  vint(139)=b2rpw**(1d0/powip)/bavg
19940  ELSE
19941  powip=max(0.4d0,parp(83))
19942  rpwip=2d0/powip-1d0
19943  prob1=rpwip/(rpwip+2d0**rpwip*exp(-rpwip))
19944  170 IF(pyr(0).LT.prob1) THEN
19945  b2rpw=2d0*rpwip*pyr(0)
19946  accip=(b2rpw/rpwip)**rpwip*exp(rpwip-b2rpw)
19947  ELSE
19948  b2rpw=2d0*(rpwip-log(pyr(0)))
19949  accip=(0.5d0*b2rpw/rpwip)**rpwip*exp(rpwip-0.5d0*b2rpw)
19950  ENDIF
19951  IF(accip.lt .pyr(0)) goto 170
19952  vint(148)=exp(-b2rpw)/(paru(2)*vnt147)
19953  vint(139)=b2rpw**(1d0/powip)/bavg
19954  ENDIF
19955 
19956 C...Multiple interactions (variable impact parameter) : reject with
19957 C...probability exp(-overlap*cross-section above pT/normalization).
19958 C...Does not apply to low-b region, where "Sudakov" already included.
19959  vint(150)=1d0
19960  IF(mint(39).NE.1) THEN
19961  rncor=(irbin-20d0*rbin)*nmul(irbin)
19962  sigcor=(irbin-20d0*rbin)*sigm(irbin)
19963  DO 180 ibin=irbin+1,20
19964  rncor=rncor+nmul(ibin)
19965  sigcor=sigcor+sigm(ibin)
19966  180 CONTINUE
19967  sigabv=(sigcor/rncor)*vint(149)*(1d0-xts)/(xts+vint(149))
19968  IF(mstp(171).EQ.1) sigabv=sigabv*vint(2)/vint(289)
19969  vint(150)=exp(-min(50d0,vnt146*vint(148)*
19970  & sigabv/max(1d-10,sigt(0,0,5))))
19971  ENDIF
19972  IF(mstp(86).EQ.3.OR.(mstp(86).EQ.2.AND.isub.NE.11.AND.
19973  & isub.NE.12.AND.isub.NE.13.AND.isub.NE.28.AND.isub.NE.53
19974  & .AND.isub.NE.68.AND.isub.NE.95.AND.isub.NE.96)) THEN
19975  IF(vint(150).LT.pyr(0)) goto 150
19976  vint(150)=1d0
19977  ENDIF
19978 
19979 C...Generate additional multiple semihard interactions.
19980  ELSEIF(mmul.EQ.6) THEN
19981  isubsv=mint(1)
19982  vint(145)=vnt145
19983  vint(146)=vnt146
19984  vint(147)=vnt147
19985  DO 190 j=11,80
19986  vintsv(j)=vint(j)
19987  190 CONTINUE
19988  isub=96
19989  mint(1)=96
19990  vint(151)=0d0
19991  vint(152)=0d0
19992 
19993 C...Reconstruct strings in hard scattering.
19994  nmax=mint(84)+4
19995  IF(iset(isubsv).EQ.1) nmax=mint(84)+2
19996  IF(iset(isubsv).EQ.11) nmax=mint(84)+2+mint(3)
19997  nstr=0
19998  DO 210 i=mint(84)+1,nmax
19999  kcs=kchg(pycomp(k(i,2)),2)*isign(1,k(i,2))
20000  IF(kcs.EQ.0) goto 210
20001  DO 200 j=1,4
20002  IF(kcs.EQ.1.AND.(j.EQ.2.OR.j.EQ.4)) goto 200
20003  IF(kcs.EQ.-1.AND.(j.EQ.1.OR.j.EQ.3)) goto 200
20004  IF(j.LE.2) THEN
20005  ist=mod(k(i,j+3)/mstu(5),mstu(5))
20006  ELSE
20007  ist=mod(k(i,j+1),mstu(5))
20008  ENDIF
20009  IF(ist.LT.mint(84).OR.ist.GT.i) goto 200
20010  IF(kchg(pycomp(k(ist,2)),2).EQ.0) goto 200
20011  nstr=nstr+1
20012  IF(j.EQ.1.OR.j.EQ.4) THEN
20013  kstr(nstr,1)=i
20014  kstr(nstr,2)=ist
20015  ELSE
20016  kstr(nstr,1)=ist
20017  kstr(nstr,2)=i
20018  ENDIF
20019  200 CONTINUE
20020  210 CONTINUE
20021 
20022 C...Set up starting values for iteration in xT2.
20023  xt2=4d0*vint(62)/vint(2)
20024  IF(mstp(82).LE.1) THEN
20025  sigrat=xsec(isub,1)/max(1d-10,vint(315)*vint(316)*sigt(0,0,5))
20026  IF(mint(141).NE.0.OR.mint(142).NE.0) sigrat=sigrat*
20027  & vint(317)/(vint(318)*vint(320))
20028  xt2fac=sigrat*vint(149)/(1d0-vint(149))
20029  ELSE
20030  xt2fac=vnt146*vint(148)*xsec(isub,1)/
20031  & max(1d-10,sigt(0,0,5))*vint(149)*(1d0+vint(149))
20032  ENDIF
20033  vint(63)=0d0
20034  vint(64)=0d0
20035  vint(143)=1d0-vint(141)
20036  vint(144)=1d0-vint(142)
20037 
20038 C...Iterate downwards in xT2.
20039  220 IF(mstp(82).LE.1) THEN
20040  xt2=xt2fac*xt2/(xt2fac-xt2*log(pyr(0)))
20041  IF(xt2.LT.vint(149)) goto 270
20042  ELSE
20043  IF(xt2.LE.0.01001d0*vint(149)) goto 270
20044  xt2=xt2fac*(xt2+vint(149))/(xt2fac-(xt2+vint(149))*
20045  & log(pyr(0)))-vint(149)
20046  IF(xt2.LE.0d0) goto 270
20047  xt2=max(0.01d0*vint(149),xt2)
20048  ENDIF
20049  vint(25)=xt2
20050 
20051 C...Choose tau and y*. Calculate cos(theta-hat).
20052  IF(pyr(0).LE.coef(isub,1)) THEN
20053  taut=(2d0*(1d0+sqrt(1d0-xt2))/xt2-1d0)**pyr(0)
20054  tau=xt2*(1d0+taut)**2/(4d0*taut)
20055  ELSE
20056  tau=xt2*(1d0+tan(pyr(0)*atan(sqrt(1d0/xt2-1d0)))**2)
20057  ENDIF
20058  vint(21)=tau
20059  CALL pyklim(2)
20060  ryst=pyr(0)
20061  myst=1
20062  IF(ryst.GT.coef(isub,8)) myst=2
20063  IF(ryst.GT.coef(isub,8)+coef(isub,9)) myst=3
20064  CALL pykmap(2,myst,pyr(0))
20065  vint(23)=sqrt(max(0d0,1d0-xt2/tau))*(-1)**int(1.5d0+pyr(0))
20066 
20067 C...Check that x not used up. Accept or reject kinematical variables.
20068  x1m=sqrt(tau)*exp(vint(22))
20069  x2m=sqrt(tau)*exp(-vint(22))
20070  IF(vint(143)-x1m.LT.0.01d0.OR.vint(144)-x2m.LT.0.01d0) goto 220
20071  vint(71)=0.5d0*vint(1)*sqrt(xt2)
20072  CALL pysigh(nchn,sigs)
20073  IF(mint(141).NE.0.OR.mint(142).NE.0) sigs=sigs*vint(320)
20074  IF(sigs.LT.xsec(isub,1)*pyr(0)) goto 220
20075 
20076 C...Reset K, P and V vectors. Select some variables.
20077  DO 240 i=n+1,n+2
20078  DO 230 j=1,5
20079  k(i,j)=0
20080  p(i,j)=0d0
20081  v(i,j)=0d0
20082  230 CONTINUE
20083  240 CONTINUE
20084  rflav=pyr(0)
20085  pt=0.5d0*vint(1)*sqrt(xt2)
20086  phi=paru(2)*pyr(0)
20087  cth=vint(23)
20088 
20089 C...Add first parton to event record.
20090  k(n+1,1)=3
20091  k(n+1,2)=21
20092  IF(rflav.GE.max(parp(85),parp(86))) k(n+1,2)=
20093  & 1+int((2d0+parj(2))*pyr(0))
20094  p(n+1,1)=pt*cos(phi)
20095  p(n+1,2)=pt*sin(phi)
20096  p(n+1,3)=0.25d0*vint(1)*(vint(41)*(1d0+cth)-vint(42)*(1d0-cth))
20097  p(n+1,4)=0.25d0*vint(1)*(vint(41)*(1d0+cth)+vint(42)*(1d0-cth))
20098  p(n+1,5)=0d0
20099 
20100 C...Add second parton to event record.
20101  k(n+2,1)=3
20102  k(n+2,2)=21
20103  IF(k(n+1,2).NE.21) k(n+2,2)=-k(n+1,2)
20104  p(n+2,1)=-p(n+1,1)
20105  p(n+2,2)=-p(n+1,2)
20106  p(n+2,3)=0.25d0*vint(1)*(vint(41)*(1d0-cth)-vint(42)*(1d0+cth))
20107  p(n+2,4)=0.25d0*vint(1)*(vint(41)*(1d0-cth)+vint(42)*(1d0+cth))
20108  p(n+2,5)=0d0
20109 
20110  IF(rflav.LT.parp(85).AND.nstr.GE.1) THEN
20111 C....Choose relevant string pieces to place gluons on.
20112  DO 260 i=n+1,n+2
20113  dmin=1d8
20114  DO 250 istr=1,nstr
20115  i1=kstr(istr,1)
20116  i2=kstr(istr,2)
20117  dist=(p(i,4)*p(i1,4)-p(i,1)*p(i1,1)-p(i,2)*p(i1,2)-
20118  & p(i,3)*p(i1,3))*(p(i,4)*p(i2,4)-p(i,1)*p(i2,1)-
20119  & p(i,2)*p(i2,2)-p(i,3)*p(i2,3))/max(1d0,p(i1,4)*p(i2,4)-
20120  & p(i1,1)*p(i2,1)-p(i1,2)*p(i2,2)-p(i1,3)*p(i2,3))
20121  IF(istr.EQ.1.OR.dist.LT.dmin) THEN
20122  dmin=dist
20123  ist1=i1
20124  ist2=i2
20125  istm=istr
20126  ENDIF
20127  250 CONTINUE
20128 
20129 C....Colour flow adjustments, new string pieces.
20130  IF(k(ist1,4)/mstu(5).EQ.ist2) k(ist1,4)=mstu(5)*i+
20131  & mod(k(ist1,4),mstu(5))
20132  IF(mod(k(ist1,5),mstu(5)).EQ.ist2) k(ist1,5)=
20133  & mstu(5)*(k(ist1,5)/mstu(5))+i
20134  k(i,5)=mstu(5)*ist1
20135  k(i,4)=mstu(5)*ist2
20136  IF(k(ist2,5)/mstu(5).EQ.ist1) k(ist2,5)=mstu(5)*i+
20137  & mod(k(ist2,5),mstu(5))
20138  IF(mod(k(ist2,4),mstu(5)).EQ.ist1) k(ist2,4)=
20139  & mstu(5)*(k(ist2,4)/mstu(5))+i
20140  kstr(istm,2)=i
20141  kstr(nstr+1,1)=i
20142  kstr(nstr+1,2)=ist2
20143  nstr=nstr+1
20144  260 CONTINUE
20145 
20146 C...String drawing and colour flow for gluon loop.
20147  ELSEIF(k(n+1,2).EQ.21) THEN
20148  k(n+1,4)=mstu(5)*(n+2)
20149  k(n+1,5)=mstu(5)*(n+2)
20150  k(n+2,4)=mstu(5)*(n+1)
20151  k(n+2,5)=mstu(5)*(n+1)
20152  kstr(nstr+1,1)=n+1
20153  kstr(nstr+1,2)=n+2
20154  kstr(nstr+2,1)=n+2
20155  kstr(nstr+2,2)=n+1
20156  nstr=nstr+2
20157 
20158 C...String drawing and colour flow for qqbar pair.
20159  ELSE
20160  k(n+1,4)=mstu(5)*(n+2)
20161  k(n+2,5)=mstu(5)*(n+1)
20162  kstr(nstr+1,1)=n+1
20163  kstr(nstr+1,2)=n+2
20164  nstr=nstr+1
20165  ENDIF
20166 
20167 C...Global statistics.
20168  mint(351)=mint(351)+1
20169  vint(351)=vint(351)+pt
20170  IF (mint(351).EQ.1) vint(356)=pt
20171 
20172 C...Update remaining energy; iterate.
20173  n=n+2
20174  IF(n.GT.mstu(4)-mstu(32)-10) THEN
20175  CALL pyerrm(11,'(PYMULT:) no more memory left in PYJETS')
20176  mint(51)=1
20177  RETURN
20178  ENDIF
20179  mint(31)=mint(31)+1
20180  vint(151)=vint(151)+vint(41)
20181  vint(152)=vint(152)+vint(42)
20182  vint(143)=vint(143)-vint(41)
20183  vint(144)=vint(144)-vint(42)
20184 C...Allow FSR for UE (always handle with old showers)
20185  IF(mstp(152).EQ.1) THEN
20186  m41sav=mstj(41)
20187  IF (mstj(41).EQ.10) mstj(41)=2
20188  mstj(41)=mod(mstj(41),10)
20189  CALL pyshow(n-1,n,sqrt(parp(71))*pt)
20190  mstj(41)=m41sav
20191  ENDIF
20192  IF(mint(31).LT.240) goto 220
20193  270 CONTINUE
20194  mint(1)=isubsv
20195  DO 280 j=11,80
20196  vint(j)=vintsv(j)
20197  280 CONTINUE
20198  ENDIF
20199 
20200 C...Format statements for printout.
20201  5000 FORMAT(/1x,'****** PYMULT: initialization of multiple inter',
20202  &'actions for MSTP(82) =',i2,' ******')
20203  5100 FORMAT(8x,'pT0 =',f5.2,' GeV gives sigma(parton-parton) =',1p,
20204  &d9.2,' mb: rejected')
20205  5200 FORMAT(8x,'pT0 =',f5.2,' GeV gives sigma(parton-parton) =',1p,
20206  &d9.2,' mb: accepted')
20207 
20208  RETURN
20209  END
20210 
20211 C*********************************************************************
20212 
20213 C...PYREMN
20214 C...Adds on target remnants (one or two from each side) and
20215 C...includes primordial kT for hadron beams.
20216 
20217  SUBROUTINE pyremn(IPU1,IPU2)
20218 
20219 C...Double precision and integer declarations.
20220  IMPLICIT DOUBLE PRECISION(a-h, o-z)
20221  IMPLICIT INTEGER(i-n)
20222  INTEGER pyk,pychge,pycomp
20223 C...Commonblocks.
20224  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
20225  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
20226  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
20227  common/pypars/mstp(200),parp(200),msti(200),pari(200)
20228  common/pyint1/mint(400),vint(400)
20229  SAVE /pyjets/,/pydat1/,/pydat2/,/pypars/,/pyint1/
20230 C...Local arrays.
20231  dimension kflch(2),kflsp(2),chi(2),pms(0:6),is(2),isn(2),robo(5),
20232  &psys(0:2,5),pmin(0:2),qold(4),qnew(4),dbe(3),psum(4)
20233 
20234 C...Find event type and remaining energy.
20235  isub=mint(1)
20236  ns=n
20237  IF(mint(50).EQ.0.OR.mod(mstp(81),10).LE.0) THEN
20238  vint(143)=1d0-vint(141)
20239  vint(144)=1d0-vint(142)
20240  ENDIF
20241 
20242 C...Define initial partons.
20243  ntry=0
20244  100 ntry=ntry+1
20245  DO 130 jt=1,2
20246  i=mint(83)+jt+2
20247  IF(jt.EQ.1) ipu=ipu1
20248  IF(jt.EQ.2) ipu=ipu2
20249  k(i,1)=21
20250  k(i,2)=k(ipu,2)
20251  k(i,3)=i-2
20252  pms(jt)=0d0
20253  vint(156+jt)=0d0
20254  vint(158+jt)=0d0
20255  IF(mint(47).EQ.1) THEN
20256  DO 110 j=1,5
20257  p(i,j)=p(i-2,j)
20258  110 CONTINUE
20259  ELSEIF(isub.EQ.95) THEN
20260  k(i,2)=21
20261  ELSE
20262  p(i,5)=p(ipu,5)
20263 
20264 C...No primordial kT, or chosen according to truncated Gaussian or
20265 C...exponential, or (for photon) predetermined or power law.
20266  120 IF(mint(40+jt).EQ.2.AND.mint(10+jt).NE.22) THEN
20267  IF(mstp(91).LE.0) THEN
20268  pt=0d0
20269  ELSEIF(mstp(91).EQ.1) THEN
20270  pt=parp(91)*sqrt(-log(pyr(0)))
20271  ELSE
20272  rpt1=pyr(0)
20273  rpt2=pyr(0)
20274  pt=-parp(92)*log(rpt1*rpt2)
20275  ENDIF
20276  IF(pt.GT.parp(93)) goto 120
20277  ELSEIF(mint(106+jt).EQ.3) THEN
20278  pta=sqrt(vint(282+jt))
20279  ptb=0d0
20280  IF(mstp(66).EQ.5.AND.mstp(93).EQ.1) THEN
20281  ptb=parp(99)*sqrt(-log(pyr(0)))
20282  ELSEIF(mstp(66).EQ.5.AND.mstp(93).EQ.2) THEN
20283  rpt1=pyr(0)
20284  rpt2=pyr(0)
20285  ptb=-parp(99)*log(rpt1*rpt2)
20286  ENDIF
20287  IF(ptb.GT.parp(100)) goto 120
20288  pt=sqrt(pta**2+ptb**2+2d0*pta*ptb*cos(paru(2)*pyr(0)))
20289  pt=pt*0.8d0**mint(57)
20290  IF(ntry.GT.10) pt=pt*0.8d0**(ntry-10)
20291  ELSEIF(iabs(mint(14+jt)).LE.8.OR.mint(14+jt).EQ.21) THEN
20292  IF(mstp(93).LE.0) THEN
20293  pt=0d0
20294  ELSEIF(mstp(93).EQ.1) THEN
20295  pt=parp(99)*sqrt(-log(pyr(0)))
20296  ELSEIF(mstp(93).EQ.2) THEN
20297  rpt1=pyr(0)
20298  rpt2=pyr(0)
20299  pt=-parp(99)*log(rpt1*rpt2)
20300  ELSEIF(mstp(93).EQ.3) THEN
20301  ha=parp(99)**2
20302  hb=parp(100)**2
20303  pt=sqrt(max(0d0,ha*(ha+hb)/(ha+hb-pyr(0)*hb)-ha))
20304  ELSE
20305  ha=parp(99)**2
20306  hb=parp(100)**2
20307  IF(mstp(93).EQ.5) hb=min(vint(48),parp(100)**2)
20308  pt=sqrt(max(0d0,ha*((ha+hb)/ha)**pyr(0)-ha))
20309  ENDIF
20310  IF(pt.GT.parp(100)) goto 120
20311  ELSE
20312  pt=0d0
20313  ENDIF
20314  vint(156+jt)=pt
20315  phi=paru(2)*pyr(0)
20316  p(i,1)=pt*cos(phi)
20317  p(i,2)=pt*sin(phi)
20318  pms(jt)=p(i,5)**2+p(i,1)**2+p(i,2)**2
20319  ENDIF
20320  130 CONTINUE
20321  IF(mint(47).EQ.1) RETURN
20322 
20323 C...Kinematics construction for initial partons.
20324  i1=mint(83)+3
20325  i2=mint(83)+4
20326  IF(isub.EQ.95) THEN
20327  shs=0d0
20328  shr=0d0
20329  ELSE
20330  shs=vint(141)*vint(142)*vint(2)+(p(i1,1)+p(i2,1))**2+
20331  & (p(i1,2)+p(i2,2))**2
20332  shr=sqrt(max(0d0,shs))
20333  IF((shs-pms(1)-pms(2))**2-4d0*pms(1)*pms(2).LE.0d0) goto 100
20334  p(i1,4)=0.5d0*(shr+(pms(1)-pms(2))/shr)
20335  p(i1,3)=sqrt(max(0d0,p(i1,4)**2-pms(1)))
20336  p(i2,4)=shr-p(i1,4)
20337  p(i2,3)=-p(i1,3)
20338 
20339 C...Transform partons to overall CM-frame.
20340  robo(3)=(p(i1,1)+p(i2,1))/shr
20341  robo(4)=(p(i1,2)+p(i2,2))/shr
20342  CALL pyrobo(i1,i2,0d0,0d0,-robo(3),-robo(4),0d0)
20343  robo(2)=pyangl(p(i1,1),p(i1,2))
20344  CALL pyrobo(i1,i2,0d0,-robo(2),0d0,0d0,0d0)
20345  robo(1)=pyangl(p(i1,3),p(i1,1))
20346  CALL pyrobo(i1,i2,-robo(1),0d0,0d0,0d0,0d0)
20347  CALL pyrobo(i2+1,mint(52),0d0,-robo(2),0d0,0d0,0d0)
20348  CALL pyrobo(i1,mint(52),robo(1),robo(2),robo(3),robo(4),0d0)
20349  robo(5)=(vint(141)-vint(142))/(vint(141)+vint(142))
20350  CALL pyrobo(i1,mint(52),0d0,0d0,0d0,0d0,robo(5))
20351  ENDIF
20352 
20353 C...Optionally fix up x and Q2 definitions for leptoproduction.
20354  idisxq=0
20355  IF((mint(43).EQ.2.OR.mint(43).EQ.3).AND.((isub.EQ.10.AND.
20356  &mstp(23).GE.1).OR.(isub.EQ.83.AND.mstp(23).GE.2))) idisxq=1
20357  IF(idisxq.EQ.1) THEN
20358 
20359 C...Find where incoming and outgoing leptons/partons are sitting.
20360  lesd=1
20361  IF(mint(42).EQ.1) lesd=2
20362  lpin=mint(83)+3-lesd
20363  lein=mint(84)+lesd
20364  lqin=mint(84)+3-lesd
20365  leout=mint(84)+2+lesd
20366  lqout=mint(84)+5-lesd
20367  IF(k(lein,3).GT.lein) lein=k(lein,3)
20368  IF(k(lqin,3).GT.lqin) lqin=k(lqin,3)
20369  lscms=0
20370  DO 140 i=mint(84)+5,n
20371  IF(k(i,2).EQ.94) THEN
20372  lscms=i
20373  leout=i+lesd
20374  lqout=i+3-lesd
20375  ENDIF
20376  140 CONTINUE
20377  lqbg=ipu1
20378  IF(lesd.EQ.1) lqbg=ipu2
20379 
20380 C...Calculate actual and wanted momentum transfer.
20381  xnom=vint(43-lesd)
20382  q2nom=-vint(45)
20383  hpk=2d0*(p(lpin,4)*p(lein,4)-p(lpin,1)*p(lein,1)-
20384  & p(lpin,2)*p(lein,2)-p(lpin,3)*p(lein,3))*
20385  & (p(mint(83)+lesd,4)*vint(40+lesd)/p(lein,4))
20386  hpt2=max(0d0,q2nom*(1d0-q2nom/(xnom*hpk)))
20387  fac=sqrt(hpt2/(p(leout,1)**2+p(leout,2)**2))
20388  p(n+1,1)=fac*p(leout,1)
20389  p(n+1,2)=fac*p(leout,2)
20390  p(n+1,3)=0.25d0*((hpk-q2nom/xnom)/p(lpin,4)-
20391  & q2nom/(p(mint(83)+lesd,4)*vint(40+lesd)))*(-1)**(lesd+1)
20392  p(n+1,4)=sqrt(p(leout,5)**2+p(n+1,1)**2+p(n+1,2)**2+
20393  & p(n+1,3)**2)
20394  DO 150 j=1,4
20395  qold(j)=p(lein,j)-p(leout,j)
20396  qnew(j)=p(lein,j)-p(n+1,j)
20397  150 CONTINUE
20398 
20399 C...Boost outgoing electron and daughters.
20400  IF(lscms.EQ.0) THEN
20401  DO 160 j=1,4
20402  p(leout,j)=p(n+1,j)
20403  160 CONTINUE
20404  ELSE
20405  DO 170 j=1,3
20406  p(n+2,j)=(p(n+1,j)-p(leout,j))/(p(n+1,4)+p(leout,4))
20407  170 CONTINUE
20408  pinv=2d0/(1d0+p(n+2,1)**2+p(n+2,2)**2+p(n+2,3)**2)
20409  DO 180 j=1,3
20410  dbe(j)=pinv*p(n+2,j)
20411  180 CONTINUE
20412  DO 200 i=lscms+1,n
20413  iorig=i
20414  190 iorig=k(iorig,3)
20415  IF(iorig.GT.leout) goto 190
20416  IF(i.EQ.leout.OR.iorig.EQ.leout)
20417  & CALL pyrobo(i,i,0d0,0d0,dbe(1),dbe(2),dbe(3))
20418  200 CONTINUE
20419  ENDIF
20420 
20421 C...Copy shower initiator and all outgoing partons.
20422  ncop=n+1
20423  k(ncop,3)=lqbg
20424  DO 210 j=1,5
20425  p(ncop,j)=p(lqbg,j)
20426  210 CONTINUE
20427  DO 240 i=mint(84)+1,n
20428  icop=0
20429  IF(k(i,1).GT.10) goto 240
20430  IF(i.EQ.lqbg.OR.i.EQ.lqout) THEN
20431  icop=i
20432  ELSE
20433  iorig=i
20434  220 iorig=k(iorig,3)
20435  IF(iorig.EQ.lqbg.OR.iorig.EQ.lqout) THEN
20436  icop=iorig
20437  ELSEIF(iorig.GT.mint(84).AND.iorig.LE.n) THEN
20438  goto 220
20439  ENDIF
20440  ENDIF
20441  IF(icop.NE.0) THEN
20442  ncop=ncop+1
20443  k(ncop,3)=i
20444  DO 230 j=1,5
20445  p(ncop,j)=p(i,j)
20446  230 CONTINUE
20447  ENDIF
20448  240 CONTINUE
20449 
20450 C...Calculate relative rescaling factors.
20451  slc=3-2*lesd
20452  plcsum=0d0
20453  DO 250 i=n+2,ncop
20454  plcsum=plcsum+(p(i,4)+slc*p(i,3))
20455  250 CONTINUE
20456  DO 260 i=n+2,ncop
20457  v(i,1)=(p(i,4)+slc*p(i,3))/plcsum
20458  260 CONTINUE
20459 
20460 C...Transfer extra three-momentum of current.
20461  DO 280 i=n+2,ncop
20462  DO 270 j=1,3
20463  p(i,j)=p(i,j)+v(i,1)*(qnew(j)-qold(j))
20464  270 CONTINUE
20465  p(i,4)=sqrt(p(i,5)**2+p(i,1)**2+p(i,2)**2+p(i,3)**2)
20466  280 CONTINUE
20467 
20468 C...Iterate change of initiator momentum to get energy right.
20469  iter=0
20470  290 iter=iter+1
20471  peex=-p(n+1,4)-qnew(4)
20472  pemv=-p(n+1,3)/p(n+1,4)
20473  DO 300 i=n+2,ncop
20474  peex=peex+p(i,4)
20475  pemv=pemv+v(i,1)*p(i,3)/p(i,4)
20476  300 CONTINUE
20477  IF(abs(pemv).LT.1d-10) THEN
20478  mint(51)=1
20479  mint(57)=mint(57)+1
20480  RETURN
20481  ENDIF
20482  pzch=-peex/pemv
20483  p(n+1,3)=p(n+1,3)+pzch
20484  p(n+1,4)=sqrt(p(n+1,5)**2+p(n+1,1)**2+p(n+1,2)**2+p(n+1,3)**2)
20485  DO 310 i=n+2,ncop
20486  p(i,3)=p(i,3)+v(i,1)*pzch
20487  p(i,4)=sqrt(p(i,5)**2+p(i,1)**2+p(i,2)**2+p(i,3)**2)
20488  310 CONTINUE
20489  IF(iter.LT.10.AND.abs(peex).GT.1d-6*p(n+1,4)) goto 290
20490 
20491 C...Modify momenta in event record.
20492  hbe=2d0*(p(n+1,4)+p(lqbg,4))*(p(n+1,3)-p(lqbg,3))/
20493  & ((p(n+1,4)+p(lqbg,4))**2+(p(n+1,3)-p(lqbg,3))**2)
20494  IF(abs(hbe).GE.1d0) THEN
20495  mint(51)=1
20496  mint(57)=mint(57)+1
20497  RETURN
20498  ENDIF
20499  i=mint(83)+5-lesd
20500  CALL pyrobo(i,i,0d0,0d0,0d0,0d0,hbe)
20501  DO 330 i=n+1,ncop
20502  icop=k(i,3)
20503  DO 320 j=1,4
20504  p(icop,j)=p(i,j)
20505  320 CONTINUE
20506  330 CONTINUE
20507  ENDIF
20508 
20509 C...Check minimum invariant mass of remnant system(s).
20510  psys(0,4)=p(i1,4)+p(i2,4)+0.5d0*vint(1)*(vint(151)+vint(152))
20511  psys(0,3)=p(i1,3)+p(i2,3)+0.5d0*vint(1)*(vint(151)-vint(152))
20512  pms(0)=max(0d0,psys(0,4)**2-psys(0,3)**2)
20513  pmin(0)=sqrt(pms(0))
20514  DO 340 jt=1,2
20515  psys(jt,4)=0.5d0*vint(1)*vint(142+jt)
20516  psys(jt,3)=psys(jt,4)*(-1)**(jt-1)
20517  pmin(jt)=0d0
20518  IF(mint(44+jt).EQ.1) goto 340
20519  mint(105)=mint(102+jt)
20520  mint(109)=mint(106+jt)
20521  CALL pyspli(mint(10+jt),mint(12+jt),kflch(jt),kflsp(jt))
20522  IF(mint(51).NE.0) THEN
20523  mint(57)=mint(57)+1
20524  RETURN
20525  ENDIF
20526  IF(kflch(jt).NE.0) pmin(jt)=pmin(jt)+pymass(kflch(jt))
20527  IF(kflsp(jt).NE.0) pmin(jt)=pmin(jt)+pymass(kflsp(jt))
20528  IF(kflch(jt)*kflsp(jt).NE.0) pmin(jt)=pmin(jt)+0.5d0*parp(111)
20529  pmin(jt)=sqrt(pmin(jt)**2+p(mint(83)+jt+2,1)**2+
20530  & p(mint(83)+jt+2,2)**2)
20531  340 CONTINUE
20532  IF(pmin(0)+pmin(1)+pmin(2).GT.vint(1).OR.(mint(45).GE.2.AND.
20533  &pmin(1).GT.psys(1,4)).OR.(mint(46).GE.2.AND.pmin(2).GT.
20534  &psys(2,4))) THEN
20535  mint(51)=1
20536  mint(57)=mint(57)+1
20537  RETURN
20538  ENDIF
20539 
20540 C...Loop over two remnants; skip if none there.
20541  i=ns
20542  DO 410 jt=1,2
20543  isn(jt)=0
20544  IF(mint(44+jt).EQ.1) goto 410
20545  IF(jt.EQ.1) ipu=ipu1
20546  IF(jt.EQ.2) ipu=ipu2
20547 
20548 C...Store first remnant parton.
20549  i=i+1
20550  is(jt)=i
20551  isn(jt)=1
20552  DO 350 j=1,5
20553  k(i,j)=0
20554  p(i,j)=0d0
20555  v(i,j)=0d0
20556  350 CONTINUE
20557  k(i,1)=1
20558  k(i,2)=kflsp(jt)
20559  k(i,3)=mint(83)+jt
20560  p(i,5)=pymass(k(i,2))
20561 
20562 C...First parton colour connections and kinematics.
20563  kcol=kchg(pycomp(kflsp(jt)),2)
20564  IF(kcol.EQ.2) THEN
20565  k(i,1)=3
20566  k(i,4)=mstu(5)*ipu+ipu
20567  k(i,5)=mstu(5)*ipu+ipu
20568  k(ipu,4)=mod(k(ipu,4),mstu(5))+mstu(5)*i
20569  k(ipu,5)=mod(k(ipu,5),mstu(5))+mstu(5)*i
20570  ELSEIF(kcol.NE.0) THEN
20571  k(i,1)=3
20572  kfls=(3-kcol*isign(1,kflsp(jt)))/2
20573  k(i,kfls+3)=ipu
20574  k(ipu,6-kfls)=mod(k(ipu,6-kfls),mstu(5))+mstu(5)*i
20575  ENDIF
20576  IF(kflch(jt).EQ.0) THEN
20577  p(i,1)=-p(mint(83)+jt+2,1)
20578  p(i,2)=-p(mint(83)+jt+2,2)
20579  pms(jt)=p(i,5)**2+p(i,1)**2+p(i,2)**2
20580  psys(jt,3)=sqrt(max(0d0,psys(jt,4)**2-pms(jt)))*(-1)**(jt-1)
20581  p(i,3)=psys(jt,3)
20582  p(i,4)=psys(jt,4)
20583 
20584 C...When extra remnant parton or hadron: store extra remnant.
20585  ELSE
20586  i=i+1
20587  isn(jt)=2
20588  DO 360 j=1,5
20589  k(i,j)=0
20590  p(i,j)=0d0
20591  v(i,j)=0d0
20592  360 CONTINUE
20593  k(i,1)=1
20594  k(i,2)=kflch(jt)
20595  k(i,3)=mint(83)+jt
20596  p(i,5)=pymass(k(i,2))
20597 
20598 C...Find parton colour connections of extra remnant.
20599  kcol=kchg(pycomp(kflch(jt)),2)
20600  IF(kcol.EQ.2) THEN
20601  k(i,1)=3
20602  k(i,4)=mstu(5)*ipu+ipu
20603  k(i,5)=mstu(5)*ipu+ipu
20604  k(ipu,4)=mod(k(ipu,4),mstu(5))+mstu(5)*i
20605  k(ipu,5)=mod(k(ipu,5),mstu(5))+mstu(5)*i
20606  ELSEIF(kcol.NE.0) THEN
20607  k(i,1)=3
20608  kfls=(3-kcol*isign(1,kflch(jt)))/2
20609  k(i,kfls+3)=ipu
20610  k(ipu,6-kfls)=mod(k(ipu,6-kfls),mstu(5))+mstu(5)*i
20611  ENDIF
20612 
20613 C...Relative transverse momentum when two remnants.
20614  loop=0
20615  370 loop=loop+1
20616  CALL pyptdi(1,p(i-1,1),p(i-1,2))
20617  IF(iabs(mint(10+jt)).LT.20) THEN
20618  p(i-1,1)=0d0
20619  p(i-1,2)=0d0
20620  ELSE
20621  p(i-1,1)=p(i-1,1)-0.5d0*p(mint(83)+jt+2,1)
20622  p(i-1,2)=p(i-1,2)-0.5d0*p(mint(83)+jt+2,2)
20623  ENDIF
20624  pms(jt+2)=p(i-1,5)**2+p(i-1,1)**2+p(i-1,2)**2
20625  p(i,1)=-p(mint(83)+jt+2,1)-p(i-1,1)
20626  p(i,2)=-p(mint(83)+jt+2,2)-p(i-1,2)
20627  pms(jt+4)=p(i,5)**2+p(i,1)**2+p(i,2)**2
20628 
20629 C...Meson or baryon; photon as meson. For splitup below.
20630  imb=1
20631  IF(mod(mint(10+jt)/1000,10).NE.0) imb=2
20632 
20633 C***Relative distribution for electron into two electrons. Temporary!
20634  IF(iabs(mint(10+jt)).LT.20.AND.mint(14+jt).EQ.-mint(10+jt))
20635  & THEN
20636  chi(jt)=pyr(0)
20637 
20638 C...Relative distribution of electron energy into electron plus parton.
20639  ELSEIF(iabs(mint(10+jt)).LT.20) THEN
20640  xhrd=vint(140+jt)
20641  xe=vint(154+jt)
20642  chi(jt)=(xe-xhrd)/(1d0-xhrd)
20643 
20644 C...Relative distribution of energy for particle into two jets.
20645  ELSEIF(iabs(kflch(jt)).LE.10.OR.kflch(jt).EQ.21) THEN
20646  chik=parp(92+2*imb)
20647  IF(mstp(92).LE.1) THEN
20648  IF(imb.EQ.1) chi(jt)=pyr(0)
20649  IF(imb.EQ.2) chi(jt)=1d0-sqrt(pyr(0))
20650  ELSEIF(mstp(92).EQ.2) THEN
20651  chi(jt)=1d0-pyr(0)**(1d0/(1d0+chik))
20652  ELSEIF(mstp(92).EQ.3) THEN
20653  cut=2d0*0.3d0/vint(1)
20654  380 chi(jt)=pyr(0)**2
20655  IF((chi(jt)**2/(chi(jt)**2+cut**2))**0.25d0*
20656  & (1d0-chi(jt))**chik.LT.pyr(0)) goto 380
20657  ELSEIF(mstp(92).EQ.4) THEN
20658  cut=2d0*0.3d0/vint(1)
20659  cutr=(1d0+sqrt(1d0+cut**2))/cut
20660  390 chir=cut*cutr**pyr(0)
20661  chi(jt)=(chir**2-cut**2)/(2d0*chir)
20662  IF((1d0-chi(jt))**chik.LT.pyr(0)) goto 390
20663  ELSE
20664  cut=2d0*0.3d0/vint(1)
20665  cuta=cut**(1d0-parp(98))
20666  cutb=(1d0+cut)**(1d0-parp(98))
20667  400 chi(jt)=(cuta+pyr(0)*(cutb-cuta))**(1d0/(1d0-parp(98)))
20668  IF(((chi(jt)+cut)**2/(2d0*(chi(jt)**2+cut**2)))**
20669  & (0.5d0*parp(98))*(1d0-chi(jt))**chik.LT.pyr(0)) goto 400
20670  ENDIF
20671 
20672 C...Relative distribution of energy for particle into jet plus particle.
20673  ELSE
20674  IF(mstp(94).LE.1) THEN
20675  IF(imb.EQ.1) chi(jt)=pyr(0)
20676  IF(imb.EQ.2) chi(jt)=1d0-sqrt(pyr(0))
20677  IF(mod(kflch(jt)/1000,10).NE.0) chi(jt)=1d0-chi(jt)
20678  ELSEIF(mstp(94).EQ.2) THEN
20679  chi(jt)=1d0-pyr(0)**(1d0/(1d0+parp(93+2*imb)))
20680  IF(mod(kflch(jt)/1000,10).NE.0) chi(jt)=1d0-chi(jt)
20681  ELSEIF(mstp(94).EQ.3) THEN
20682  CALL pyzdis(1,0,pms(jt+4),zz)
20683  chi(jt)=zz
20684  ELSE
20685  CALL pyzdis(1000,0,pms(jt+4),zz)
20686  chi(jt)=zz
20687  ENDIF
20688  ENDIF
20689 
20690 C...Construct total transverse mass; reject if too large.
20691  chi(jt)=max(1d-8,min(1d0-1d-8,chi(jt)))
20692  pms(jt)=pms(jt+4)/chi(jt)+pms(jt+2)/(1d0-chi(jt))
20693  IF(pms(jt).GT.psys(jt,4)**2) THEN
20694  IF(loop.LT.100) THEN
20695  goto 370
20696  ELSE
20697  mint(51)=1
20698  mint(57)=mint(57)+1
20699  RETURN
20700  ENDIF
20701  ENDIF
20702  psys(jt,3)=sqrt(max(0d0,psys(jt,4)**2-pms(jt)))*(-1)**(jt-1)
20703  vint(158+jt)=chi(jt)
20704 
20705 C...Subdivide longitudinal momentum according to value selected above.
20706  pw1=chi(jt)*(psys(jt,4)+abs(psys(jt,3)))
20707  p(is(jt)+1,4)=0.5d0*(pw1+pms(jt+4)/pw1)
20708  p(is(jt)+1,3)=0.5d0*(pw1-pms(jt+4)/pw1)*(-1)**(jt-1)
20709  p(is(jt),4)=psys(jt,4)-p(is(jt)+1,4)
20710  p(is(jt),3)=psys(jt,3)-p(is(jt)+1,3)
20711  ENDIF
20712  410 CONTINUE
20713  n=i
20714 
20715 C...Check if longitudinal boosts needed - if so pick two systems.
20716  pdev=abs(psys(0,4)+psys(1,4)+psys(2,4)-vint(1))+
20717  &abs(psys(0,3)+psys(1,3)+psys(2,3))
20718  IF(pdev.LE.1d-6*vint(1)) RETURN
20719  IF(isn(1).EQ.0) THEN
20720  ir=0
20721  il=2
20722  ELSEIF(isn(2).EQ.0) THEN
20723  ir=1
20724  il=0
20725  ELSEIF(vint(143).GT.0.2d0.AND.vint(144).GT.0.2d0) THEN
20726  ir=1
20727  il=2
20728  ELSEIF(vint(143).GT.0.2d0) THEN
20729  ir=1
20730  il=0
20731  ELSEIF(vint(144).GT.0.2d0) THEN
20732  ir=0
20733  il=2
20734  ELSEIF(pms(1)/psys(1,4)**2.GT.pms(2)/psys(2,4)**2) THEN
20735  ir=1
20736  il=0
20737  ELSE
20738  ir=0
20739  il=2
20740  ENDIF
20741  ig=3-ir-il
20742 
20743 C...E+-pL wanted for system to be modified.
20744  IF((ig.EQ.1.AND.isn(1).EQ.0).OR.(ig.EQ.2.AND.isn(2).EQ.0)) THEN
20745  ppb=vint(1)
20746  pnb=vint(1)
20747  ELSE
20748  ppb=vint(1)-(psys(ig,4)+psys(ig,3))
20749  pnb=vint(1)-(psys(ig,4)-psys(ig,3))
20750  ENDIF
20751 
20752 C...To keep x and Q2 in leptoproduction: do not count scattered lepton.
20753  IF(idisxq.EQ.1.AND.ig.NE.0) THEN
20754  ppb=ppb-(psys(0,4)+psys(0,3))
20755  pnb=pnb-(psys(0,4)-psys(0,3))
20756  DO 420 j=1,4
20757  psys(0,j)=0d0
20758  420 CONTINUE
20759  DO 450 i=mint(84)+1,ns
20760  IF(k(i,1).GT.10) goto 450
20761  incl=0
20762  iorig=i
20763  430 IF(iorig.EQ.lqout.OR.iorig.EQ.lpin+2) incl=1
20764  iorig=k(iorig,3)
20765  IF(iorig.GT.lpin) goto 430
20766  IF(incl.EQ.0) goto 450
20767  DO 440 j=1,4
20768  psys(0,j)=psys(0,j)+p(i,j)
20769  440 CONTINUE
20770  450 CONTINUE
20771  pms(0)=max(0d0,psys(0,4)**2-psys(0,3)**2)
20772  ppb=ppb+(psys(0,4)+psys(0,3))
20773  pnb=pnb+(psys(0,4)-psys(0,3))
20774  ENDIF
20775 
20776 C...Construct longitudinal boosts.
20777  dpmtb=ppb*pnb
20778  dpmtr=pms(ir)
20779  dpmtl=pms(il)
20780  dsqlam=sqrt(max(0d0,(dpmtb-dpmtr-dpmtl)**2-4d0*dpmtr*dpmtl))
20781  IF(dsqlam.LE.1d-6*dpmtb) THEN
20782  mint(51)=1
20783  mint(57)=mint(57)+1
20784  RETURN
20785  ENDIF
20786  dsqsgn=sign(1d0,psys(ir,3)*psys(il,4)-psys(il,3)*psys(ir,4))
20787  drkr=(dpmtb+dpmtr-dpmtl+dsqlam*dsqsgn)/
20788  &(2d0*(psys(ir,4)+psys(ir,3))*pnb)
20789  drkl=(dpmtb+dpmtl-dpmtr+dsqlam*dsqsgn)/
20790  &(2d0*(psys(il,4)-psys(il,3))*ppb)
20791  dber=(drkr**2-1d0)/(drkr**2+1d0)
20792  dbel=-(drkl**2-1d0)/(drkl**2+1d0)
20793 
20794 C...Perform longitudinal boosts.
20795  IF(ir.EQ.1.AND.isn(1).EQ.1.AND.dber.LE.-0.99999999d0) THEN
20796  p(is(1),3)=0d0
20797  p(is(1),4)=sqrt(p(is(1),5)**2+p(is(1),1)**2+p(is(1),2)**2)
20798  ELSEIF(ir.EQ.1) THEN
20799  CALL pyrobo(is(1),is(1)+isn(1)-1,0d0,0d0,0d0,0d0,dber)
20800  ELSEIF(idisxq.EQ.1) THEN
20801  DO 470 i=i1,ns
20802  incl=0
20803  iorig=i
20804  460 IF(iorig.EQ.lqout.OR.iorig.EQ.lpin+2) incl=1
20805  iorig=k(iorig,3)
20806  IF(iorig.GT.lpin) goto 460
20807  IF(incl.EQ.1) CALL pyrobo(i,i,0d0,0d0,0d0,0d0,dber)
20808  470 CONTINUE
20809  ELSE
20810  CALL pyrobo(i1,ns,0d0,0d0,0d0,0d0,dber)
20811  ENDIF
20812  IF(il.EQ.2.AND.isn(2).EQ.1.AND.dbel.GE.0.99999999d0) THEN
20813  p(is(2),3)=0d0
20814  p(is(2),4)=sqrt(p(is(2),5)**2+p(is(2),1)**2+p(is(2),2)**2)
20815  ELSEIF(il.EQ.2) THEN
20816  CALL pyrobo(is(2),is(2)+isn(2)-1,0d0,0d0,0d0,0d0,dbel)
20817  ELSEIF(idisxq.EQ.1) THEN
20818  DO 490 i=i1,ns
20819  incl=0
20820  iorig=i
20821  480 IF(iorig.EQ.lqout.OR.iorig.EQ.lpin+2) incl=1
20822  iorig=k(iorig,3)
20823  IF(iorig.GT.lpin) goto 480
20824  IF(incl.EQ.1) CALL pyrobo(i,i,0d0,0d0,0d0,0d0,dbel)
20825  490 CONTINUE
20826  ELSE
20827  CALL pyrobo(i1,ns,0d0,0d0,0d0,0d0,dbel)
20828  ENDIF
20829 
20830 C...Final check that energy-momentum conservation worked.
20831  pesum=0d0
20832  pzsum=0d0
20833  DO 500 i=mint(84)+1,n
20834  IF(k(i,1).GT.10) goto 500
20835  pesum=pesum+p(i,4)
20836  pzsum=pzsum+p(i,3)
20837  500 CONTINUE
20838  pdev=abs(pesum-vint(1))+abs(pzsum)
20839  IF(pdev.GT.1d-4*vint(1)) THEN
20840  mint(51)=1
20841  mint(57)=mint(57)+1
20842  RETURN
20843  ENDIF
20844 
20845 C...Calculate rotation and boost from overall CM frame to
20846 C...hadronic CM frame in leptoproduction.
20847  mint(91)=0
20848  IF(mint(82).EQ.1.AND.(mint(43).EQ.2.OR.mint(43).EQ.3)) THEN
20849  mint(91)=1
20850  lesd=1
20851  IF(mint(42).EQ.1) lesd=2
20852  lpin=mint(83)+3-lesd
20853 
20854 C...Sum upp momenta of everything not lepton or photon to define boost.
20855  DO 510 j=1,4
20856  psum(j)=0d0
20857  510 CONTINUE
20858  DO 530 i=1,n
20859  IF(k(i,1).LE.0.OR.k(i,1).GT.10) goto 530
20860  IF(iabs(k(i,2)).GE.11.AND.iabs(k(i,2)).LE.20) goto 530
20861  IF(k(i,2).EQ.22) goto 530
20862  DO 520 j=1,4
20863  psum(j)=psum(j)+p(i,j)
20864  520 CONTINUE
20865  530 CONTINUE
20866  vint(223)=-psum(1)/psum(4)
20867  vint(224)=-psum(2)/psum(4)
20868  vint(225)=-psum(3)/psum(4)
20869 
20870 C...Boost incoming hadron to hadronic CM frame to determine rotations.
20871  k(n+1,1)=1
20872  DO 540 j=1,5
20873  p(n+1,j)=p(lpin,j)
20874  v(n+1,j)=v(lpin,j)
20875  540 CONTINUE
20876  CALL pyrobo(n+1,n+1,0d0,0d0,vint(223),vint(224),vint(225))
20877  vint(222)=-pyangl(p(n+1,1),p(n+1,2))
20878  CALL pyrobo(n+1,n+1,0d0,vint(222),0d0,0d0,0d0)
20879  IF(lesd.EQ.2) THEN
20880  vint(221)=-pyangl(p(n+1,3),p(n+1,1))
20881  ELSE
20882  vint(221)=pyangl(-p(n+1,3),p(n+1,1))
20883  ENDIF
20884  ENDIF
20885 
20886  RETURN
20887  END
20888 
20889 C*********************************************************************
20890 
20891 C...PYMIGN
20892 C...Initializes treatment of new multiple interactions scenario,
20893 C...selects kinematics of hardest interaction if low-pT physics
20894 C...included in run, and generates all non-hardest interactions.
20895 
20896  SUBROUTINE pymign(MMUL)
20897 
20898 C...Double precision and integer declarations.
20899  IMPLICIT DOUBLE PRECISION(a-h, o-z)
20900  IMPLICIT INTEGER(i-n)
20901  INTEGER pyk,pychge,pycomp
20902  EXTERNAL pyalps
20903  DOUBLE PRECISION pyalps
20904 C...Commonblocks.
20905  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
20906  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
20907  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
20908  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
20909  common/pysubs/msel,mselpd,msub(500),kfin(2,-40:40),ckin(200)
20910  common/pypars/mstp(200),parp(200),msti(200),pari(200)
20911  common/pyint1/mint(400),vint(400)
20912  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
20913  common/pyint3/xsfx(2,-40:40),isig(1000,3),sigh(1000)
20914  common/pyint5/ngenpd,ngen(0:500,3),xsec(0:500,3)
20915  common/pyint7/sigt(0:6,0:6,0:5)
20916  common/pyintm/kfival(2,3),nmi(2),imi(2,800,2),nvc(2,-6:6),
20917  & xassoc(2,-6:6,240),xpsvc(-6:6,-1:240),pvctot(2,-1:1),
20918  & xmi(2,240),pt2mi(240),imisep(0:240)
20919  SAVE /pyjets/,/pydat1/,/pydat2/,/pydat3/,/pysubs/,/pypars/,
20920  &/pyint1/,/pyint2/,/pyint3/,/pyint5/,/pyint7/,/pyintm/
20921 C...Local arrays and saved variables.
20922  dimension nmul(20),sigm(20),kstr(500,2),vintsv(80),
20923  &wdtp(0:400),wdte(0:400,0:5),xpq(-25:25),ksav(4,5),psav(4,5)
20924  SAVE xt2,xt2fac,xc2,xts,irbin,rbin,nmul,sigm,p83a,p83b,p83c,
20925  &cq2i,cq2r,pik,bdiv,b,plowb,phighb,pallb,s4a,s4b,s4c,powip,
20926  &rpwip,b2rpdv,b2rpmx,bavg,vnt145,vnt146,vnt147
20927 
20928 C...Initialization of multiple interaction treatment.
20929  IF(mmul.EQ.1) THEN
20930  IF(mstp(122).GE.1) WRITE(mstu(11),5000) mstp(82)
20931  isub=96
20932  mint(1)=96
20933  vint(63)=0d0
20934  vint(64)=0d0
20935  vint(143)=1d0
20936  vint(144)=1d0
20937 
20938 C...Loop over phase space points: xT2 choice in 20 bins.
20939  100 sigsum=0d0
20940  DO 120 ixt2=1,20
20941  nmul(ixt2)=mstp(83)
20942  sigm(ixt2)=0d0
20943  DO 110 itry=1,mstp(83)
20944  rsca=0.05d0*((21-ixt2)-pyr(0))
20945  xt2=vint(149)*(1d0+vint(149))/(vint(149)+rsca)-vint(149)
20946  xt2=max(0.01d0*vint(149),xt2)
20947  vint(25)=xt2
20948 
20949 C...Choose tau and y*. Calculate cos(theta-hat).
20950  IF(pyr(0).LE.coef(isub,1)) THEN
20951  taut=(2d0*(1d0+sqrt(1d0-xt2))/xt2-1d0)**pyr(0)
20952  tau=xt2*(1d0+taut)**2/(4d0*taut)
20953  ELSE
20954  tau=xt2*(1d0+tan(pyr(0)*atan(sqrt(1d0/xt2-1d0)))**2)
20955  ENDIF
20956  vint(21)=tau
20957  CALL pyklim(2)
20958  ryst=pyr(0)
20959  myst=1
20960  IF(ryst.GT.coef(isub,8)) myst=2
20961  IF(ryst.GT.coef(isub,8)+coef(isub,9)) myst=3
20962  CALL pykmap(2,myst,pyr(0))
20963  vint(23)=sqrt(max(0d0,1d0-xt2/tau))*(-1)**int(1.5d0+pyr(0))
20964 
20965 C...Calculate differential cross-section.
20966  vint(71)=0.5d0*vint(1)*sqrt(xt2)
20967  CALL pysigh(nchn,sigs)
20968  sigm(ixt2)=sigm(ixt2)+sigs
20969  110 CONTINUE
20970  sigsum=sigsum+sigm(ixt2)
20971  120 CONTINUE
20972  sigsum=sigsum/(20d0*mstp(83))
20973 
20974 C...Reject result if sigma(parton-parton) is smaller than hadronic one.
20975  IF(sigsum.LT.1.1d0*sigt(0,0,5)) THEN
20976  IF(mstp(122).GE.1) WRITE(mstu(11),5100)
20977  & parp(82)*(vint(1)/parp(89))**parp(90),sigsum
20978  parp(82)=0.9d0*parp(82)
20979  vint(149)=4d0*(parp(82)*(vint(1)/parp(89))**parp(90))**2/
20980  & vint(2)
20981  goto 100
20982  ENDIF
20983  IF(mstp(122).GE.1) WRITE(mstu(11),5200)
20984  & parp(82)*(vint(1)/parp(89))**parp(90), sigsum
20985 
20986 C...Start iteration to find k factor.
20987  yke=sigsum/max(1d-10,sigt(0,0,5))
20988  p83a=(1d0-parp(83))**2
20989  p83b=2d0*parp(83)*(1d0-parp(83))
20990  p83c=parp(83)**2
20991  cq2i=1d0/parp(84)**2
20992  cq2r=2d0/(1d0+parp(84)**2)
20993  so=0.5d0
20994  xi=0d0
20995  yi=0d0
20996  xf=0d0
20997  yf=0d0
20998  xk=0.5d0
20999  iit=0
21000  130 IF(iit.EQ.0) THEN
21001  xk=2d0*xk
21002  ELSEIF(iit.EQ.1) THEN
21003  xk=0.5d0*xk
21004  ELSE
21005  xk=xi+(yke-yi)*(xf-xi)/(yf-yi)
21006  ENDIF
21007 
21008 C...Evaluate overlap integrals. Find where to divide the b range.
21009  IF(mstp(82).EQ.2) THEN
21010  sp=0.5d0*paru(1)*(1d0-exp(-xk))
21011  sop=sp/paru(1)
21012  ELSE
21013  IF(mstp(82).EQ.3) THEN
21014  deltab=0.02d0
21015  ELSEIF(mstp(82).EQ.4) THEN
21016  deltab=min(0.01d0,0.05d0*parp(84))
21017  ELSE
21018  powip=max(0.4d0,parp(83))
21019  rpwip=2d0/powip-1d0
21020  deltab=max(0.02d0,0.02d0*(2d0/powip)**(1d0/powip))
21021  so=0d0
21022  ENDIF
21023  sp=0d0
21024  sop=0d0
21025  bsp=0d0
21026  sohigh=0d0
21027  ibdiv=0
21028  b=-0.5d0*deltab
21029  140 b=b+deltab
21030  IF(mstp(82).EQ.3) THEN
21031  ov=exp(-b**2)/paru(2)
21032  ELSEIF(mstp(82).EQ.4) THEN
21033  ov=(p83a*exp(-min(50d0,b**2))+
21034  & p83b*cq2r*exp(-min(50d0,b**2*cq2r))+
21035  & p83c*cq2i*exp(-min(50d0,b**2*cq2i)))/paru(2)
21036  ELSE
21037  ov=exp(-b**powip)/paru(2)
21038  so=so+paru(2)*b*deltab*ov
21039  ENDIF
21040  IF(ibdiv.EQ.1) sohigh=sohigh+paru(2)*b*deltab*ov
21041  pacc=1d0-exp(-min(50d0,paru(1)*xk*ov))
21042  sp=sp+paru(2)*b*deltab*pacc
21043  sop=sop+paru(2)*b*deltab*ov*pacc
21044  bsp=bsp+b*paru(2)*b*deltab*pacc
21045  IF(ibdiv.EQ.0.AND.paru(1)*xk*ov.LT.1d0) THEN
21046  ibdiv=1
21047  bdiv=b+0.5d0*deltab
21048  ENDIF
21049  IF(b.LT.1d0.OR.b*pacc.GT.1d-6) goto 140
21050  ENDIF
21051  yk=paru(1)*xk*so/sp
21052 
21053 C...Continue iteration until convergence.
21054  IF(yk.LT.yke) THEN
21055  xi=xk
21056  yi=yk
21057  IF(iit.EQ.1) iit=2
21058  ELSE
21059  xf=xk
21060  yf=yk
21061  IF(iit.EQ.0) iit=1
21062  ENDIF
21063  IF(abs(yk-yke).GE.1d-5*yke) goto 130
21064 
21065 C...Store some results for subsequent use.
21066  bavg=bsp/sp
21067  vint(145)=sigsum
21068  vint(146)=sop/so
21069  vint(147)=sop/sp
21070  vnt145=vint(145)
21071  vnt146=vint(146)
21072  vnt147=vint(147)
21073 C...PIK = PARU(1)*XK = (VINT(146)/VINT(147))*sigma_jet/sigma_nondiffr.
21074  pik=(vnt146/vnt147)*yke
21075 
21076 C...Find relative weight for low and high impact parameter..
21077  plowb=paru(1)*bdiv**2
21078  IF(mstp(82).EQ.3) THEN
21079  phighb=pik*0.5*exp(-bdiv**2)
21080  ELSEIF(mstp(82).EQ.4) THEN
21081  s4a=p83a*exp(-bdiv**2)
21082  s4b=p83b*exp(-bdiv**2*cq2r)
21083  s4c=p83c*exp(-bdiv**2*cq2i)
21084  phighb=pik*0.5*(s4a+s4b+s4c)
21085  ELSEIF(parp(83).GE.1.999d0) THEN
21086  phighb=pik*sohigh
21087  b2rpdv=bdiv**powip
21088  ELSE
21089  phighb=pik*sohigh
21090  b2rpdv=bdiv**powip
21091  b2rpmx=max(2d0*rpwip,b2rpdv)
21092  ENDIF
21093  pallb=plowb+phighb
21094 
21095 C...Initialize iteration in xT2 for hardest interaction.
21096  ELSEIF(mmul.EQ.2) THEN
21097  vint(145)=vnt145
21098  vint(146)=vnt146
21099  vint(147)=vnt147
21100  IF(mstp(82).LE.0) THEN
21101  ELSEIF(mstp(82).EQ.1) THEN
21102  xt2=1d0
21103  sigrat=xsec(96,1)/max(1d-10,vint(315)*vint(316)*sigt(0,0,5))
21104  IF(mint(141).NE.0.OR.mint(142).NE.0) sigrat=sigrat*
21105  & vint(317)/(vint(318)*vint(320))
21106  xt2fac=sigrat*vint(149)/(1d0-vint(149))
21107  ELSEIF(mstp(82).EQ.2) THEN
21108  xt2=1d0
21109  xt2fac=vnt146*xsec(96,1)/max(1d-10,sigt(0,0,5))*
21110  & vint(149)*(1d0+vint(149))
21111  ELSE
21112  xc2=4d0*ckin(3)**2/vint(2)
21113  IF(ckin(3).LE.ckin(5).OR.mint(82).GE.2) xc2=0d0
21114  ENDIF
21115 
21116 C...Select impact parameter for hardest interaction.
21117  IF(mstp(82).LE.2) RETURN
21118  142 IF(pyr(0)*pallb.LT.plowb) THEN
21119 C...Treatment in low b region.
21120  mint(39)=1
21121  b=bdiv*sqrt(pyr(0))
21122  IF(mstp(82).EQ.3) THEN
21123  ov=exp(-b**2)/paru(2)
21124  ELSEIF(mstp(82).EQ.4) THEN
21125  ov=(p83a*exp(-min(50d0,b**2))+
21126  & p83b*cq2r*exp(-min(50d0,b**2*cq2r))+
21127  & p83c*cq2i*exp(-min(50d0,b**2*cq2i)))/paru(2)
21128  ELSE
21129  ov=exp(-b**powip)/paru(2)
21130  ENDIF
21131  vint(148)=ov/vnt147
21132  pacc=1d0-exp(-min(50d0,pik*ov))
21133  xt2=1d0
21134  xt2fac=vnt146*vint(148)*xsec(96,1)/max(1d-10,sigt(0,0,5))*
21135  & vint(149)*(1d0+vint(149))
21136  ELSE
21137 C...Treatment in high b region.
21138  mint(39)=2
21139  IF(mstp(82).EQ.3) THEN
21140  b=sqrt(bdiv**2-log(pyr(0)))
21141  ov=exp(-b**2)/paru(2)
21142  ELSEIF(mstp(82).EQ.4) THEN
21143  s4rndm=pyr(0)*(s4a+s4b+s4c)
21144  IF(s4rndm.LT.s4a) THEN
21145  b=sqrt(bdiv**2-log(pyr(0)))
21146  ELSEIF(s4rndm.LT.s4a+s4b) THEN
21147  b=sqrt(bdiv**2-log(pyr(0))/cq2r)
21148  ELSE
21149  b=sqrt(bdiv**2-log(pyr(0))/cq2i)
21150  ENDIF
21151  ov=(p83a*exp(-min(50d0,b**2))+
21152  & p83b*cq2r*exp(-min(50d0,b**2*cq2r))+
21153  & p83c*cq2i*exp(-min(50d0,b**2*cq2i)))/paru(2)
21154  ELSEIF(parp(83).GE.1.999d0) THEN
21155  144 b2rpw=b2rpdv-log(pyr(0))
21156  accip=(b2rpw/b2rpdv)**rpwip
21157  IF(accip.LT.pyr(0)) goto 144
21158  ov=exp(-b2rpw)/paru(2)
21159  b=b2rpw**(1d0/powip)
21160  ELSE
21161  146 b2rpw=b2rpdv-2d0*log(pyr(0))
21162  accip=(b2rpw/b2rpmx)**rpwip*exp(-0.5d0*(b2rpw-b2rpmx))
21163  IF(accip.LT.pyr(0)) goto 146
21164  ov=exp(-b2rpw)/paru(2)
21165  b=b2rpw**(1d0/powip)
21166  ENDIF
21167  vint(148)=ov/vnt147
21168  pacc=(1d0-exp(-min(50d0,pik*ov)))/(pik*ov)
21169  ENDIF
21170  IF(pacc.LT.pyr(0)) goto 142
21171  vint(139)=b/bavg
21172 
21173  ELSEIF(mmul.EQ.3) THEN
21174 C...Low-pT or multiple interactions (first semihard interaction):
21175 C...choose xT2 according to dpT2/pT2**2*exp(-(sigma above pT2)/norm)
21176 C...or (MSTP(82)>=2) dpT2/(pT2+pT0**2)**2*exp(-....).
21177  isub=mint(1)
21178  vint(145)=vnt145
21179  vint(146)=vnt146
21180  vint(147)=vnt147
21181  IF(mstp(82).LE.0) THEN
21182  xt2=0d0
21183  ELSEIF(mstp(82).EQ.1) THEN
21184  xt2=xt2fac*xt2/(xt2fac-xt2*log(pyr(0)))
21185 C...Use with "Sudakov" for low b values when impact parameter dependence.
21186  ELSEIF(mstp(82).EQ.2.OR.mint(39).EQ.1) THEN
21187  IF(xt2.LT.1d0.AND.exp(-xt2fac*xt2/(vint(149)*(xt2+
21188  & vint(149)))).GT.pyr(0)) xt2=1d0
21189  IF(xt2.GE.1d0) THEN
21190  xt2=(1d0+vint(149))*xt2fac/(xt2fac-(1d0+vint(149))*log(1d0-
21191  & pyr(0)*(1d0-exp(-xt2fac/(vint(149)*(1d0+vint(149)))))))-
21192  & vint(149)
21193  ELSE
21194  xt2=-xt2fac/log(exp(-xt2fac/(xt2+vint(149)))+pyr(0)*
21195  & (exp(-xt2fac/vint(149))-exp(-xt2fac/(xt2+vint(149)))))-
21196  & vint(149)
21197  ENDIF
21198  xt2=max(0.01d0*vint(149),xt2)
21199 C...Use without "Sudakov" for high b values when impact parameter dep.
21200  ELSE
21201  xt2=(xc2+vint(149))*(1d0+vint(149))/(1d0+vint(149)-
21202  & pyr(0)*(1d0-xc2))-vint(149)
21203  xt2=max(0.01d0*vint(149),xt2)
21204  ENDIF
21205  vint(25)=xt2
21206 
21207 C...Low-pT: choose xT2, tau, y* and cos(theta-hat) fixed.
21208  IF(mstp(82).LE.1.AND.xt2.LT.vint(149)) THEN
21209  IF(mint(82).EQ.1) ngen(0,1)=ngen(0,1)-mint(143)
21210  IF(mint(82).EQ.1) ngen(isub,1)=ngen(isub,1)-mint(143)
21211  isub=95
21212  mint(1)=isub
21213  vint(21)=1d-12*vint(149)
21214  vint(22)=0d0
21215  vint(23)=0d0
21216  vint(25)=1d-12*vint(149)
21217 
21218  ELSE
21219 C...Multiple interactions (first semihard interaction).
21220 C...Choose tau and y*. Calculate cos(theta-hat).
21221  IF(pyr(0).LE.coef(isub,1)) THEN
21222  taut=(2d0*(1d0+sqrt(1d0-xt2))/xt2-1d0)**pyr(0)
21223  tau=xt2*(1d0+taut)**2/(4d0*taut)
21224  ELSE
21225  tau=xt2*(1d0+tan(pyr(0)*atan(sqrt(1d0/xt2-1d0)))**2)
21226  ENDIF
21227  vint(21)=tau
21228  CALL pyklim(2)
21229  ryst=pyr(0)
21230  myst=1
21231  IF(ryst.GT.coef(isub,8)) myst=2
21232  IF(ryst.GT.coef(isub,8)+coef(isub,9)) myst=3
21233  CALL pykmap(2,myst,pyr(0))
21234  vint(23)=sqrt(max(0d0,1d0-xt2/tau))*(-1)**int(1.5d0+pyr(0))
21235  ENDIF
21236  vint(71)=0.5d0*vint(1)*sqrt(vint(25))
21237 
21238 C...Store results of cross-section calculation.
21239  ELSEIF(mmul.EQ.4) THEN
21240  isub=mint(1)
21241  vint(145)=vnt145
21242  vint(146)=vnt146
21243  vint(147)=vnt147
21244  xts=vint(25)
21245  IF(iset(isub).EQ.1) xts=vint(21)
21246  IF(iset(isub).EQ.2)
21247  & xts=(4d0*vint(48)+2d0*vint(63)+2d0*vint(64))/vint(2)
21248  IF(iset(isub).GE.3.AND.iset(isub).LE.5) xts=vint(26)
21249  rbin=max(0.000001d0,min(0.999999d0,xts*(1d0+vint(149))/
21250  & (xts+vint(149))))
21251  irbin=int(1d0+20d0*rbin)
21252  IF(isub.EQ.96.AND.mstp(171).EQ.0) THEN
21253  nmul(irbin)=nmul(irbin)+1
21254  sigm(irbin)=sigm(irbin)+vint(153)
21255  ENDIF
21256 
21257 C...Choose impact parameter if not already done.
21258  ELSEIF(mmul.EQ.5) THEN
21259  isub=mint(1)
21260  vint(145)=vnt145
21261  vint(146)=vnt146
21262  vint(147)=vnt147
21263  150 IF(mint(39).GT.0) THEN
21264  ELSEIF(mstp(82).EQ.3) THEN
21265  expb2=pyr(0)
21266  b2=-log(pyr(0))
21267  vint(148)=expb2/(paru(2)*vnt147)
21268  vint(139)=sqrt(b2)/bavg
21269  ELSEIF(mstp(82).EQ.4) THEN
21270  rtype=pyr(0)
21271  IF(rtype.LT.p83a) THEN
21272  b2=-log(pyr(0))
21273  ELSEIF(rtype.LT.p83a+p83b) THEN
21274  b2=-log(pyr(0))/cq2r
21275  ELSE
21276  b2=-log(pyr(0))/cq2i
21277  ENDIF
21278  vint(148)=(p83a*exp(-min(50d0,b2))+
21279  & p83b*cq2r*exp(-min(50d0,b2*cq2r))+
21280  & p83c*cq2i*exp(-min(50d0,b2*cq2i)))/(paru(2)*vnt147)
21281  vint(139)=sqrt(b2)/bavg
21282  ELSEIF(parp(83).GE.1.999d0) THEN
21283  powip=max(2d0,parp(83))
21284  rpwip=2d0/powip-1d0
21285  prob1=powip/(2d0*exp(-1d0)+powip)
21286  160 IF(pyr(0).LT.prob1) THEN
21287  b2rpw=pyr(0)**(0.5d0*powip)
21288  accip=exp(-b2rpw)
21289  ELSE
21290  b2rpw=1d0-log(pyr(0))
21291  accip=b2rpw**rpwip
21292  ENDIF
21293  IF(accip.LT.pyr(0)) goto 160
21294  vint(148)=exp(-b2rpw)/(paru(2)*vnt147)
21295  vint(139)=b2rpw**(1d0/powip)/bavg
21296  ELSE
21297  powip=max(0.4d0,parp(83))
21298  rpwip=2d0/powip-1d0
21299  prob1=rpwip/(rpwip+2d0**rpwip*exp(-rpwip))
21300  170 IF(pyr(0).LT.prob1) THEN
21301  b2rpw=2d0*rpwip*pyr(0)
21302  accip=(b2rpw/rpwip)**rpwip*exp(rpwip-b2rpw)
21303  ELSE
21304  b2rpw=2d0*(rpwip-log(pyr(0)))
21305  accip=(0.5d0*b2rpw/rpwip)**rpwip*exp(rpwip-0.5d0*b2rpw)
21306  ENDIF
21307  IF(accip.lt .pyr(0)) goto 170
21308  vint(148)=exp(-b2rpw)/(paru(2)*vnt147)
21309  vint(139)=b2rpw**(1d0/powip)/bavg
21310  ENDIF
21311 
21312 C...Multiple interactions (variable impact parameter) : reject with
21313 C...probability exp(-overlap*cross-section above pT/normalization).
21314 C...Does not apply to low-b region, where "Sudakov" already included.
21315  vint(150)=1d0
21316  IF(mint(39).NE.1) THEN
21317  rncor=(irbin-20d0*rbin)*nmul(irbin)
21318  sigcor=(irbin-20d0*rbin)*sigm(irbin)
21319  DO 180 ibin=irbin+1,20
21320  rncor=rncor+nmul(ibin)
21321  sigcor=sigcor+sigm(ibin)
21322  180 CONTINUE
21323  sigabv=(sigcor/rncor)*vint(149)*(1d0-xts)/(xts+vint(149))
21324  IF(mstp(171).EQ.1) sigabv=sigabv*vint(2)/vint(289)
21325  vint(150)=exp(-min(50d0,vnt146*vint(148)*
21326  & sigabv/max(1d-10,sigt(0,0,5))))
21327  ENDIF
21328  IF(mstp(86).EQ.3.OR.(mstp(86).EQ.2.AND.isub.NE.11.AND.
21329  & isub.NE.12.AND.isub.NE.13.AND.isub.NE.28.AND.isub.NE.53
21330  & .AND.isub.NE.68.AND.isub.NE.95.AND.isub.NE.96)) THEN
21331  IF(vint(150).LT.pyr(0)) goto 150
21332  vint(150)=1d0
21333  ENDIF
21334 
21335 C...Generate additional multiple semihard interactions.
21336  ELSEIF(mmul.EQ.6) THEN
21337 
21338 C...Save data for hardest initeraction, to be restored.
21339  isubsv=mint(1)
21340  vint(145)=vnt145
21341  vint(146)=vnt146
21342  vint(147)=vnt147
21343  m13sv=mint(13)
21344  m14sv=mint(14)
21345  m15sv=mint(15)
21346  m16sv=mint(16)
21347  m21sv=mint(21)
21348  m22sv=mint(22)
21349  DO 190 j=11,80
21350  vintsv(j)=vint(j)
21351  190 CONTINUE
21352  v141sv=vint(141)
21353  v142sv=vint(142)
21354 
21355 C...Store data on hardest interaction.
21356  xmi(1,1)=vint(141)
21357  xmi(2,1)=vint(142)
21358  pt2mi(1)=vint(54)
21359  imisep(0)=mint(84)
21360  imisep(1)=n
21361 
21362 C...Change process to generate; sum of x values so far.
21363  isub=96
21364  mint(1)=96
21365  vint(143)=1d0-vint(141)
21366  vint(144)=1d0-vint(142)
21367  vint(151)=0d0
21368  vint(152)=0d0
21369 
21370 C...Initialize factors for PDF reshaping.
21371  DO 230 js=1,2
21372  kfbeam=mint(10+js)
21373  kfabm=iabs(kfbeam)
21374  kfsbm=isign(1,kfbeam)
21375 
21376 C...Zero flavour content of incoming beam particle.
21377  kfival(js,1)=0
21378  kfival(js,2)=0
21379  kfival(js,3)=0
21380 C...Flavour content of baryon.
21381  IF(kfabm.GT.1000) THEN
21382  kfival(js,1)=kfsbm*mod(kfabm/1000,10)
21383  kfival(js,2)=kfsbm*mod(kfabm/100,10)
21384  kfival(js,3)=kfsbm*mod(kfabm/10,10)
21385 C...Flavour content of pi+-, K+-.
21386  ELSEIF(kfabm.EQ.211) THEN
21387  kfival(js,1)=kfsbm*2
21388  kfival(js,2)=-kfsbm
21389  ELSEIF(kfabm.EQ.321) THEN
21390  kfival(js,1)=-kfsbm*3
21391  kfival(js,2)=kfsbm*2
21392 C...Flavour content of pi0, gamma, K0S, K0L not defined yet.
21393  ENDIF
21394 
21395 C...Zero initial valence and companion content.
21396  DO 200 ifl=-6,6
21397  nvc(js,ifl)=0
21398  200 CONTINUE
21399 
21400 C...Initiate listing of all incoming partons from two sides.
21401  nmi(js)=0
21402  DO 210 i=mint(84)+1,n
21403  IF(k(i,3).EQ.mint(83)+2+js) THEN
21404  imi(js,1,1)=i
21405  imi(js,1,2)=0
21406  ENDIF
21407  210 CONTINUE
21408 
21409 C...Decide whether quarks in hard scattering were valence or sea.
21410  ifl=k(imi(js,1,1),2)
21411  IF (iabs(ifl).GT.6) goto 230
21412 
21413 C...Get PDFs at X and Q2 of the parton shower initiator for the
21414 C...hard scattering.
21415  x=vint(140+js)
21416  IF(mstp(61).GE.1) THEN
21417  q2=parp(62)**2
21418  ELSE
21419  q2=vint(54)
21420  ENDIF
21421 C...Note: XPSVC = x*pdf.
21422  mint(30)=js
21423  CALL pypdfu(kfbeam,x,q2,xpq)
21424  sea=xpsvc(ifl,-1)
21425  val=xpsvc(ifl,0)
21426 
21427 C...Decide (Extra factor x cancels in the division).
21428  rvcs=pyr(0)*(sea+val)
21429  ivnow=1
21430  220 IF (rvcs.LE.val.AND.ivnow.GE.1) THEN
21431 C...Safety check that valence present; pi0/gamma/K0S/K0L special cases.
21432  ivnow=0
21433  IF(kfival(js,1).EQ.ifl) ivnow=ivnow+1
21434  IF(kfival(js,2).EQ.ifl) ivnow=ivnow+1
21435  IF(kfival(js,3).EQ.ifl) ivnow=ivnow+1
21436  IF(kfival(js,1).EQ.0) THEN
21437  IF(kfbeam.EQ.111.AND.iabs(ifl).LE.2) ivnow=1
21438  IF(kfbeam.EQ.22.AND.iabs(ifl).LE.5) ivnow=1
21439  IF((kfbeam.EQ.130.OR.kfbeam.EQ.310).AND.
21440  & (iabs(ifl).EQ.1.OR.iabs(ifl).EQ.3)) ivnow=1
21441  ENDIF
21442  IF(ivnow.EQ.0) goto 220
21443 C...Mark valence.
21444  imi(js,1,2)=0
21445 C...Sets valence content of gamma, pi0, K0S, K0L if not done.
21446  IF(kfival(js,1).EQ.0) THEN
21447  IF(kfbeam.EQ.111.OR.kfbeam.EQ.22) THEN
21448  kfival(js,1)=ifl
21449  kfival(js,2)=-ifl
21450  ELSEIF(kfbeam.EQ.130.OR.kfbeam.EQ.310) THEN
21451  kfival(js,1)=ifl
21452  IF(iabs(ifl).EQ.1) kfival(js,2)=isign(3,-ifl)
21453  IF(iabs(ifl).NE.1) kfival(js,2)=isign(1,-ifl)
21454  ENDIF
21455  ENDIF
21456 
21457 C...If sea, add opposite sign companion parton. Store X and I.
21458  ELSE
21459  nvc(js,-ifl)=nvc(js,-ifl)+1
21460  xassoc(js,-ifl,nvc(js,-ifl))=x
21461 C...Set pointer to companion
21462  imi(js,1,2)=-nvc(js,-ifl)
21463  ENDIF
21464  230 CONTINUE
21465 
21466 C...Update counter number of multiple interactions.
21467  nmi(1)=1
21468  nmi(2)=1
21469 
21470 C...Set up starting values for iteration in xT2.
21471  IF(mstp(86).EQ.3.OR.(mstp(86).EQ.2.AND.isubsv.NE.11.AND.
21472  & isubsv.NE.12.AND.isubsv.NE.13.AND.isubsv.NE.28.AND.
21473  & isubsv.NE.53.AND.isubsv.NE.68.AND.isubsv.NE.95.AND.
21474  & isubsv.NE.96)) THEN
21475  xt2=(1d0-vint(141))*(1d0-vint(142))
21476  ELSE
21477  xt2=vint(25)
21478  IF(iset(isubsv).EQ.1) xt2=vint(21)
21479  IF(iset(isubsv).EQ.2)
21480  & xt2=(4d0*vint(48)+2d0*vint(63)+2d0*vint(64))/vint(2)
21481  IF(iset(isubsv).GE.3.AND.iset(isubsv).LE.5) xt2=vint(26)
21482  ENDIF
21483  IF(mstp(82).LE.1) THEN
21484  sigrat=xsec(isub,1)/max(1d-10,vint(315)*vint(316)*sigt(0,0,5))
21485  IF(mint(141).NE.0.OR.mint(142).NE.0) sigrat=sigrat*
21486  & vint(317)/(vint(318)*vint(320))
21487  xt2fac=sigrat*vint(149)/(1d0-vint(149))
21488  ELSE
21489  xt2fac=vnt146*vint(148)*xsec(isub,1)/
21490  & max(1d-10,sigt(0,0,5))*vint(149)*(1d0+vint(149))
21491  ENDIF
21492  vint(63)=0d0
21493  vint(64)=0d0
21494 
21495 C...Iterate downwards in xT2.
21496  240 IF((mint(35).EQ.2.AND.mstp(81).EQ.10).OR.isubsv.EQ.95) THEN
21497  xt2=0d0
21498  goto 440
21499  ELSEIF(mstp(82).LE.1) THEN
21500  xt2=xt2fac*xt2/(xt2fac-xt2*log(pyr(0)))
21501  IF(xt2.LT.vint(149)) goto 440
21502  ELSE
21503  IF(xt2.LE.0.01001d0*vint(149)) goto 440
21504  xt2=xt2fac*(xt2+vint(149))/(xt2fac-(xt2+vint(149))*
21505  & log(pyr(0)))-vint(149)
21506  IF(xt2.LE.0d0) goto 440
21507  xt2=max(0.01d0*vint(149),xt2)
21508  ENDIF
21509  vint(25)=xt2
21510 
21511 C...Choose tau and y*. Calculate cos(theta-hat).
21512  IF(pyr(0).LE.coef(isub,1)) THEN
21513  taut=(2d0*(1d0+sqrt(1d0-xt2))/xt2-1d0)**pyr(0)
21514  tau=xt2*(1d0+taut)**2/(4d0*taut)
21515  ELSE
21516  tau=xt2*(1d0+tan(pyr(0)*atan(sqrt(1d0/xt2-1d0)))**2)
21517  ENDIF
21518  vint(21)=tau
21519 C...New: require shat > 1.
21520  IF(tau*vint(2).LT.1d0) goto 240
21521  CALL pyklim(2)
21522  ryst=pyr(0)
21523  myst=1
21524  IF(ryst.GT.coef(isub,8)) myst=2
21525  IF(ryst.GT.coef(isub,8)+coef(isub,9)) myst=3
21526  CALL pykmap(2,myst,pyr(0))
21527  vint(23)=sqrt(max(0d0,1d0-xt2/tau))*(-1)**int(1.5d0+pyr(0))
21528 
21529 C...Check that x not used up. Accept or reject kinematical variables.
21530  x1m=sqrt(tau)*exp(vint(22))
21531  x2m=sqrt(tau)*exp(-vint(22))
21532  IF(vint(143)-x1m.LT.0.01d0.OR.vint(144)-x2m.LT.0.01d0) goto 240
21533  vint(71)=0.5d0*vint(1)*sqrt(xt2)
21534  CALL pysigh(nchn,sigs)
21535  IF(mint(141).NE.0.OR.mint(142).NE.0) sigs=sigs*vint(320)
21536  IF(sigs.LT.xsec(isub,1)*pyr(0)) goto 240
21537  IF(mint(141).NE.0.OR.mint(142).NE.0) sigs=sigs/vint(320)
21538 
21539 C...Reset K, P and V vectors.
21540  DO 260 i=n+1,n+4
21541  DO 250 j=1,5
21542  k(i,j)=0
21543  p(i,j)=0d0
21544  v(i,j)=0d0
21545  250 CONTINUE
21546  260 CONTINUE
21547  pt=0.5d0*vint(1)*sqrt(xt2)
21548 
21549 C...Choose flavour of reacting partons (and subprocess).
21550  rsigs=sigs*pyr(0)
21551  DO 270 ichn=1,nchn
21552  kfl1=isig(ichn,1)
21553  kfl2=isig(ichn,2)
21554  iconmi=isig(ichn,3)
21555  rsigs=rsigs-sigh(ichn)
21556  IF(rsigs.LE.0d0) goto 280
21557  270 CONTINUE
21558 
21559 C...Reassign to appropriate process codes.
21560  280 isubmi=iconmi/10
21561  iconmi=mod(iconmi,10)
21562 
21563 C...Choose new quark flavour for annihilation graphs
21564  IF(isubmi.EQ.12.OR.isubmi.EQ.53) THEN
21565  sh=tau*vint(2)
21566  CALL pywidt(21,sh,wdtp,wdte)
21567  290 rkfl=(wdte(0,1)+wdte(0,2)+wdte(0,4))*pyr(0)
21568  DO 300 i=1,mdcy(21,3)
21569  kflf=kfdp(i+mdcy(21,2)-1,1)
21570  rkfl=rkfl-(wdte(i,1)+wdte(i,2)+wdte(i,4))
21571  IF(rkfl.LE.0d0) goto 310
21572  300 CONTINUE
21573  310 IF(isubmi.EQ.53.AND.iconmi.LE.2) THEN
21574  IF(kflf.GE.4) goto 290
21575  ELSEIF(isubmi.EQ.53.AND.iconmi.LE.4) THEN
21576  kflf=4
21577  iconmi=iconmi-2
21578  ELSEIF(isubmi.EQ.53) THEN
21579  kflf=5
21580  iconmi=iconmi-4
21581  ENDIF
21582  ENDIF
21583 
21584 C...Final state flavours and colour flow: default values
21585  js=1
21586  kfl3=kfl1
21587  kfl4=kfl2
21588  kcc=20
21589  kcs=isign(1,kfl1)
21590 
21591  IF(isubmi.EQ.11) THEN
21592 C...f + f' -> f + f' (g exchange); th = (p(f)-p(f))**2
21593  kcc=iconmi
21594  IF(kfl1*kfl2.LT.0) kcc=kcc+2
21595 
21596  ELSEIF(isubmi.EQ.12) THEN
21597 C...f + fbar -> f' + fbar'; th = (p(f)-p(f'))**2
21598  kfl3=isign(kflf,kfl1)
21599  kfl4=-kfl3
21600  kcc=4
21601 
21602  ELSEIF(isubmi.EQ.13) THEN
21603 C...f + fbar -> g + g; th arbitrary
21604  kfl3=21
21605  kfl4=21
21606  kcc=iconmi+4
21607 
21608  ELSEIF(isubmi.EQ.28) THEN
21609 C...f + g -> f + g; th = (p(f)-p(f))**2
21610  IF(kfl1.EQ.21) js=2
21611  kcc=iconmi+6
21612  IF(kfl1.EQ.21) kcc=kcc+2
21613  IF(kfl1.NE.21) kcs=isign(1,kfl1)
21614  IF(kfl2.NE.21) kcs=isign(1,kfl2)
21615 
21616  ELSEIF(isubmi.EQ.53) THEN
21617 C...g + g -> f + fbar; th arbitrary
21618  kcs=(-1)**int(1.5d0+pyr(0))
21619  kfl3=isign(kflf,kcs)
21620  kfl4=-kfl3
21621  kcc=iconmi+10
21622 
21623  ELSEIF(isubmi.EQ.68) THEN
21624 C...g + g -> g + g; th arbitrary
21625  kcc=iconmi+12
21626  kcs=(-1)**int(1.5d0+pyr(0))
21627  ENDIF
21628 
21629 C...Store flavours of scattering.
21630  mint(13)=kfl1
21631  mint(14)=kfl2
21632  mint(15)=kfl1
21633  mint(16)=kfl2
21634  mint(21)=kfl3
21635  mint(22)=kfl4
21636 
21637 C...Set flavours and mothers of scattering partons.
21638  k(n+1,1)=14
21639  k(n+2,1)=14
21640  k(n+3,1)=3
21641  k(n+4,1)=3
21642  k(n+1,2)=kfl1
21643  k(n+2,2)=kfl2
21644  k(n+3,2)=kfl3
21645  k(n+4,2)=kfl4
21646  k(n+1,3)=mint(83)+1
21647  k(n+2,3)=mint(83)+2
21648  k(n+3,3)=n+1
21649  k(n+4,3)=n+2
21650 
21651 C...Store colour connection indices.
21652  DO 320 j=1,2
21653  jc=j
21654  IF(kcs.EQ.-1) jc=3-j
21655  IF(icol(kcc,1,jc).NE.0) k(n+1,j+3)=n+icol(kcc,1,jc)
21656  IF(icol(kcc,2,jc).NE.0) k(n+2,j+3)=n+icol(kcc,2,jc)
21657  IF(icol(kcc,3,jc).NE.0) k(n+3,j+3)=mstu(5)*(n+icol(kcc,3,jc))
21658  IF(icol(kcc,4,jc).NE.0) k(n+4,j+3)=mstu(5)*(n+icol(kcc,4,jc))
21659  320 CONTINUE
21660 
21661 C...Store incoming and outgoing partons in their CM-frame.
21662  shr=sqrt(tau)*vint(1)
21663  p(n+1,3)=0.5d0*shr
21664  p(n+1,4)=0.5d0*shr
21665  p(n+2,3)=-0.5d0*shr
21666  p(n+2,4)=0.5d0*shr
21667  p(n+3,5)=pymass(k(n+3,2))
21668  p(n+4,5)=pymass(k(n+4,2))
21669  IF(p(n+3,5)+p(n+4,5).GE.shr) goto 240
21670  p(n+3,4)=0.5d0*(shr+(p(n+3,5)**2-p(n+4,5)**2)/shr)
21671  p(n+3,3)=sqrt(max(0d0,p(n+3,4)**2-p(n+3,5)**2))
21672  p(n+4,4)=shr-p(n+3,4)
21673  p(n+4,3)=-p(n+3,3)
21674 
21675 C...Rotate outgoing partons using cos(theta)=(th-uh)/lam(sh,sqm3,sqm4)
21676  phi=paru(2)*pyr(0)
21677  CALL pyrobo(n+3,n+4,acos(vint(23)),phi,0d0,0d0,0d0)
21678 
21679 C...Set up default values before showers.
21680  mint(31)=mint(31)+1
21681  ipu1=n+1
21682  ipu2=n+2
21683  ipu3=n+3
21684  ipu4=n+4
21685  vint(141)=vint(41)
21686  vint(142)=vint(42)
21687  n=n+4
21688 
21689 C...Showering of initial state partons (optional).
21690 C...Note: no showering of final state partons here; it comes later.
21691  IF(mstp(84).GE.1.AND.mstp(61).GE.1) THEN
21692  mint(51)=0
21693  alamsv=parj(81)
21694  parj(81)=parp(72)
21695  nsav=n
21696  DO 340 i=1,4
21697  DO 330 j=1,5
21698  ksav(i,j)=k(n-4+i,j)
21699  psav(i,j)=p(n-4+i,j)
21700  330 CONTINUE
21701  340 CONTINUE
21702  CALL pysspa(ipu1,ipu2)
21703  parj(81)=alamsv
21704 C...If shower failed then restore to situation before shower.
21705  IF(mint(51).GE.1) THEN
21706  n=nsav
21707  DO 360 i=1,4
21708  DO 350 j=1,5
21709  k(n-4+i,j)=ksav(i,j)
21710  p(n-4+i,j)=psav(i,j)
21711  350 CONTINUE
21712  360 CONTINUE
21713  ipu1=n-3
21714  ipu2=n-2
21715  vint(141)=vint(41)
21716  vint(142)=vint(42)
21717  ENDIF
21718  ENDIF
21719 
21720 C...Keep track of loose colour ends and information on scattering.
21721  370 imi(1,mint(31),1)=ipu1
21722  imi(2,mint(31),1)=ipu2
21723  imi(1,mint(31),2)=0
21724  imi(2,mint(31),2)=0
21725  xmi(1,mint(31))=vint(141)
21726  xmi(2,mint(31))=vint(142)
21727  pt2mi(mint(31))=vint(54)
21728  imisep(mint(31))=n
21729 
21730 C...Decide whether quarks in last scattering were valence, companion or
21731 C...sea.
21732  DO 430 js=1,2
21733  kfbeam=mint(10+js)
21734  kfsbm=isign(1,mint(10+js))
21735  ifl=k(imi(js,mint(31),1),2)
21736  imi(js,mint(31),2)=0
21737  IF (iabs(ifl).GT.6) goto 430
21738 
21739 C...Get PDFs at X and Q2 of the parton shower initiator for the
21740 C...last scattering. At this point VINT(143:144) do not yet
21741 C...include the scattered x values VINT(141:142).
21742  x=vint(140+js)/vint(142+js)
21743  IF(mstp(84).GE.1.AND.mstp(61).GE.1) THEN
21744  q2=parp(62)**2
21745  ELSE
21746  q2=vint(54)
21747  ENDIF
21748 C...Note: XPSVC = x*pdf.
21749  mint(30)=js
21750  CALL pypdfu(kfbeam,x,q2,xpq)
21751  sea=xpsvc(ifl,-1)
21752  val=xpsvc(ifl,0)
21753  cmp=0d0
21754  DO 380 ivc=1,nvc(js,ifl)
21755  cmp=cmp+xpsvc(ifl,ivc)
21756  380 CONTINUE
21757 
21758 C...Decide (Extra factor x cancels in the dvision).
21759  rvcs=pyr(0)*(sea+val+cmp)
21760  ivnow=1
21761  390 IF (rvcs.LE.val.AND.ivnow.GE.1) THEN
21762 C...Safety check that valence present; pi0/gamma/K0S/K0L special cases.
21763  ivnow=0
21764  IF(kfival(js,1).EQ.ifl) ivnow=ivnow+1
21765  IF(kfival(js,2).EQ.ifl) ivnow=ivnow+1
21766  IF(kfival(js,3).EQ.ifl) ivnow=ivnow+1
21767  IF(kfival(js,1).EQ.0) THEN
21768  IF(kfbeam.EQ.111.AND.iabs(ifl).LE.2) ivnow=1
21769  IF(kfbeam.EQ.22.AND.iabs(ifl).LE.5) ivnow=1
21770  IF((kfbeam.EQ.130.OR.kfbeam.EQ.310).AND.
21771  & (iabs(ifl).EQ.1.OR.iabs(ifl).EQ.3)) ivnow=1
21772  ELSE
21773  DO 400 i1=1,nmi(js)
21774  IF (k(imi(js,i1,1),2).EQ.ifl.AND.imi(js,i1,2).EQ.0)
21775  & ivnow=ivnow-1
21776  400 CONTINUE
21777  ENDIF
21778  IF(ivnow.EQ.0) goto 390
21779 C...Mark valence.
21780  imi(js,mint(31),2)=0
21781 C...Sets valence content of gamma, pi0, K0S, K0L if not done.
21782  IF(kfival(js,1).EQ.0) THEN
21783  IF(kfbeam.EQ.111.OR.kfbeam.EQ.22) THEN
21784  kfival(js,1)=ifl
21785  kfival(js,2)=-ifl
21786  ELSEIF(kfbeam.EQ.130.OR.kfbeam.EQ.310) THEN
21787  kfival(js,1)=ifl
21788  IF(iabs(ifl).EQ.1) kfival(js,2)=isign(3,-ifl)
21789  IF(iabs(ifl).NE.1) kfival(js,2)=isign(1,-ifl)
21790  ENDIF
21791  ENDIF
21792 
21793  ELSEIF (rvcs.LE.val+sea.OR.nvc(js,ifl).EQ.0) THEN
21794 C...If sea, add opposite sign companion parton. Store X and I.
21795  nvc(js,-ifl)=nvc(js,-ifl)+1
21796  xassoc(js,-ifl,nvc(js,-ifl))=x
21797 C...Set pointer to companion
21798  imi(js,mint(31),2)=-nvc(js,-ifl)
21799  ELSE
21800 C...If companion, decide which one.
21801  cmpsum=val+sea
21802  isel=0
21803  410 isel=isel+1
21804  cmpsum=cmpsum+xpsvc(ifl,isel)
21805  IF (rvcs.GT.cmpsum.AND.isel.LT.nvc(js,ifl)) goto 410
21806 C...Find original sea (anti-)quark:
21807  iassoc=0
21808  DO 420 i1=1,nmi(js)
21809  IF (k(imi(js,i1,1),2).NE.-ifl) goto 420
21810  IF (-imi(js,i1,2).EQ.isel) THEN
21811  imi(js,mint(31),2)=imi(js,i1,1)
21812  imi(js,i1,2)=imi(js,mint(31),1)
21813  ENDIF
21814  420 CONTINUE
21815 C...Change X to what associated companion had, so that the correct
21816 C...amount of momentum can be subtracted from the companion sum below.
21817  x=xassoc(js,ifl,isel)
21818 C...Mark companion read.
21819  xassoc(js,ifl,isel)=0d0
21820  ENDIF
21821  430 CONTINUE
21822 
21823 C...Global statistics.
21824  mint(351)=mint(351)+1
21825  vint(351)=vint(351)+pt
21826  IF (mint(351).EQ.1) vint(356)=pt
21827 
21828 C...Update remaining energy and other counters.
21829  IF(n.GT.mstu(4)-mstu(32)-10) THEN
21830  CALL pyerrm(11,'(PYMIGN:) no more memory left in PYJETS')
21831  mint(51)=1
21832  RETURN
21833  ENDIF
21834  nmi(1)=nmi(1)+1
21835  nmi(2)=nmi(2)+1
21836  vint(151)=vint(151)+vint(41)
21837  vint(152)=vint(152)+vint(42)
21838  vint(143)=vint(143)-vint(141)
21839  vint(144)=vint(144)-vint(142)
21840 
21841 C...Iterate, with more interactions allowed.
21842  IF(mint(31).LT.240) goto 240
21843  440 CONTINUE
21844 
21845 C...Restore saved quantities for hardest interaction.
21846  mint(1)=isubsv
21847  mint(13)=m13sv
21848  mint(14)=m14sv
21849  mint(15)=m15sv
21850  mint(16)=m16sv
21851  mint(21)=m21sv
21852  mint(22)=m22sv
21853  DO 450 j=11,80
21854  vint(j)=vintsv(j)
21855  450 CONTINUE
21856  vint(141)=v141sv
21857  vint(142)=v142sv
21858 
21859  ENDIF
21860 
21861 C...Format statements for printout.
21862  5000 FORMAT(/1x,'****** PYMIGN: initialization of multiple inter',
21863  &'actions for MSTP(82) =',i2,' ******')
21864  5100 FORMAT(8x,'pT0 =',f5.2,' GeV gives sigma(parton-parton) =',1p,
21865  &d9.2,' mb: rejected')
21866  5200 FORMAT(8x,'pT0 =',f5.2,' GeV gives sigma(parton-parton) =',1p,
21867  &d9.2,' mb: accepted')
21868 
21869  RETURN
21870  END
21871 
21872 C*********************************************************************
21873 
21874 C...PYMIHK
21875 C...Finds left-behind remnant flavour content and hooks up
21876 C...the colour flow between the hard scattering and remnants
21877 
21878  SUBROUTINE pymihk
21879 
21880 C...Double precision and integer declarations.
21881  IMPLICIT DOUBLE PRECISION(a-h, o-z)
21882  IMPLICIT INTEGER(i-n)
21883  INTEGER pyk,pychge,pycomp
21884 C...The event record
21885  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
21886 C...Parameters
21887  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
21888  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
21889  common/pypars/mstp(200),parp(200),msti(200),pari(200)
21890  common/pyint1/mint(400),vint(400)
21891 C...The common block of dangling ends
21892  common/pyintm/kfival(2,3),nmi(2),imi(2,800,2),nvc(2,-6:6),
21893  & xassoc(2,-6:6,240),xpsvc(-6:6,-1:240),pvctot(2,-1:1),
21894  & xmi(2,240),pt2mi(240),imisep(0:240)
21895  SAVE /pyjets/,/pydat1/,/pydat2/,/pypars/,/pyint1/,/pyintm/
21896 C...Local variables
21897  parameter(nersiz=4000)
21898  COMMON /pycbls/mco(nersiz,2),ncc,jcco(nersiz,2),jccn(nersiz,2)
21899  & ,maccpt
21900  COMMON /pyctag/nct,mct(nersiz,2)
21901  SAVE /pycbls/,/pyctag/
21902  dimension jst(2,3),iv(2,3),idq(3),nvsum(2),nbrtot(2),ng(2)
21903  & ,itjunc(2),mout(2),insr(1000,3),istr(6),ymi(240)
21904  DATA nerrpr/0/
21905  SAVE nerrpr
21906  four(i,j)=p(i,4)*p(j,4)-p(i,3)*p(j,3)-p(i,2)*p(j,2)-p(i,1)*p(j,1)
21907 
21908 C...Set up error checkers
21909  iboost=0
21910 
21911 C...Initialize colour arrays: MCO (Original) and MCT (New)
21912  DO 110 i=mint(84)+1,nersiz
21913  DO 100 jc=1,2
21914  mct(i,jc)=0
21915  mco(i,jc)=0
21916  100 CONTINUE
21917 C...Also zero colour tracing information, if existed.
21918  IF (i.LE.n) THEN
21919  k(i,4)=mod(k(i,4),mstu(5)**2)
21920  k(i,5)=mod(k(i,5),mstu(5)**2)
21921  ENDIF
21922  110 CONTINUE
21923 
21924 C...Initialize colour tag collapse arrays:
21925 C...JCCO (Original) and JCCN (New).
21926  DO 130 mg=mint(84)+1,nersiz
21927  DO 120 jc=1,2
21928  jcco(mg,jc)=0
21929  jccn(mg,jc)=0
21930  120 CONTINUE
21931  130 CONTINUE
21932 
21933 C...Zero gluon insertion array
21934  DO 150 im=1,1000
21935  DO 140 j=1,3
21936  insr(im,j)=0
21937  140 CONTINUE
21938  150 CONTINUE
21939 
21940 C...Compute hard scattering system rapidities
21941  IF (mstp(89).EQ.1) THEN
21942  DO 160 im=1,240
21943  IF (im.LE.mint(31)) THEN
21944  ymi(im)=log(xmi(1,im)/xmi(2,im))
21945  ELSE
21946 C...Set (unsigned) rapidity = 100 for beam remnant systems.
21947  ymi(im)=100d0
21948  ENDIF
21949  160 CONTINUE
21950  ENDIF
21951 
21952 C...Treat each side separately
21953  DO 290 js=1,2
21954 
21955 C...Initialize side.
21956  ng(js)=0
21957  jv=0
21958  kfs=isign(1,mint(10+js))
21959 
21960 C...Set valence content of pi0, gamma, K0S, K0L if not yet done.
21961  IF(kfival(js,1).EQ.0) THEN
21962  IF(mint(10+js).EQ.111) THEN
21963  kfival(js,1)=int(1.5d0+pyr(0))
21964  kfival(js,2)=-kfival(js,1)
21965  ELSEIF(mint(10+js).EQ.22) THEN
21966  pyrkf=pyr(0)
21967  kfival(js,1)=1
21968  IF(pyrkf.GT.0.1d0) kfival(js,1)=2
21969  IF(pyrkf.GT.0.5d0) kfival(js,1)=3
21970  IF(pyrkf.GT.0.6d0) kfival(js,1)=4
21971  kfival(js,2)=-kfival(js,1)
21972  ELSEIF(mint(10+js).EQ.130.OR.mint(10+js).EQ.310) THEN
21973  IF(pyr(0).GT.0.5d0) THEN
21974  kfival(js,1)=1
21975  kfival(js,2)=-3
21976  ELSE
21977  kfival(js,1)=3
21978  kfival(js,2)=-1
21979  ENDIF
21980  ENDIF
21981  ENDIF
21982 
21983 C...Initialize beam remnant sea and valence content flavour by flavour.
21984  nvsum(js)=0
21985  nbrtot(js)=0
21986  DO 210 jfa=1,6
21987 C...Count up original number of JFA valence quarks and antiquarks.
21988  nvalq=0
21989  nvalqb=0
21990  nsea=0
21991  DO 170 j=1,3
21992  IF(kfival(js,j).EQ.jfa) nvalq=nvalq+1
21993  IF(kfival(js,j).EQ.-jfa) nvalqb=nvalqb+1
21994  170 CONTINUE
21995  nvsum(js)=nvsum(js)+nvalq+nvalqb
21996 C...Subtract kicked out valence and determine sea from flavour cons.
21997  DO 180 im=1,nmi(js)
21998  ifl = k(imi(js,im,1),2)
21999  ifa = iabs(ifl)
22000  ifs = isign(1,ifl)
22001  IF (ifl.EQ.jfa.AND.imi(js,im,2).EQ.0) THEN
22002 C...Subtract K.O. valence quark from remainder.
22003  nvalq=nvalq-1
22004  jv=nvsum(js)-nvalq-nvalqb
22005  iv(js,jv)=imi(js,im,1)
22006  ELSEIF (ifl.EQ.-jfa.AND.imi(js,im,2).EQ.0) THEN
22007 C...Subtract K.O. valence antiquark from remainder.
22008  nvalqb=nvalqb-1
22009  jv=nvsum(js)-nvalq-nvalqb
22010  iv(js,jv)=imi(js,im,1)
22011  ELSEIF (ifa.EQ.jfa) THEN
22012 C...Outside sea without companion: add opposite sea flavour inside.
22013  IF (imi(js,im,2).LT.0) nsea=nsea-ifs
22014  ENDIF
22015  180 CONTINUE
22016 C...Check if space left in PYJETS for additional BR flavours
22017  nflsum=iabs(nsea)+nvalq+nvalqb
22018  nbrtot(js)=nbrtot(js)+nflsum
22019  IF (n+nflsum+1.GT.mstu(4)) THEN
22020  CALL pyerrm(11,'(PYMIHK:) no more memory left in PYJETS')
22021  mint(51)=1
22022  RETURN
22023  ENDIF
22024 C...Add required val+sea content to beam remnant.
22025  IF (nflsum.GT.0) THEN
22026  DO 200 ia=1,nflsum
22027 C...Insert beam remnant quark as p.t. symbolic parton in ER.
22028  n=n+1
22029  DO 190 ix=1,5
22030  k(n,ix)=0
22031  p(n,ix)=0d0
22032  v(n,ix)=0d0
22033  190 CONTINUE
22034  k(n,1)=3
22035  k(n,2)=isign(jfa,nsea)
22036  IF (ia.LE.nvalq) k(n,2)=jfa
22037  IF (ia.GT.nvalq.AND.ia.LE.nvalq+nvalqb) k(n,2)=-jfa
22038  k(n,3)=mint(83)+js
22039 C...Also update NMI, IMI, and IV arrays.
22040  nmi(js)=nmi(js)+1
22041  imi(js,nmi(js),1)=n
22042  imi(js,nmi(js),2)=-1
22043  IF (ia.LE.nvalq+nvalqb) THEN
22044  imi(js,nmi(js),2)=0
22045  jv=jv+1
22046  iv(js,jv)=imi(js,nmi(js),1)
22047  ENDIF
22048  200 CONTINUE
22049  ENDIF
22050  210 CONTINUE
22051 
22052  im=0
22053  220 im=im+1
22054  IF (im.LE.nmi(js)) THEN
22055  IF (k(imi(js,im,1),2).EQ.21) THEN
22056  ng(js)=ng(js)+1
22057 C...Add fictitious parent gluons for companion pairs.
22058  ELSEIF (imi(js,im,2).NE.0.AND.k(imi(js,im,1),2).GT.0) THEN
22059 C...Randomly assign companions to sea quarks which have none.
22060  IF (imi(js,im,2).LT.0) THEN
22061  imc=pyr(0)*nmi(js)
22062  230 imc=mod(imc,nmi(js))+1
22063  IF (k(imi(js,imc,1),2).NE.-k(imi(js,im,1),2)) goto 230
22064  IF (imi(js,imc,2).GE.0) goto 230
22065  imi(js, im,2) = imi(js,imc,1)
22066  imi(js,imc,2) = imi(js, im,1)
22067  ENDIF
22068 C...Add fictitious parent gluon
22069  n=n+1
22070  DO 240 ix=1,5
22071  k(n,ix)=0
22072  p(n,ix)=0d0
22073  v(n,ix)=0d0
22074  240 CONTINUE
22075  k(n,1)=14
22076  k(n,2)=21
22077  k(n,3)=mint(83)+js
22078 C...Set gluon (anti-)colour daughter pointers
22079  k(n,4)=imi(js, im,1)
22080  k(n,5)=imi(js, im,2)
22081 C...Set quark (anti-)colour parent pointers
22082  k(imi(js, im,2),5)=k(imi(js, im,2),5)+mstu(5)*n
22083  k(imi(js, im,1),4)=k(imi(js, im,1),4)+mstu(5)*n
22084 C...Add gluon to IMI
22085  nmi(js)=nmi(js)+1
22086  imi(js,nmi(js),1)=n
22087  imi(js,nmi(js),2)=0
22088  ENDIF
22089  goto 220
22090  ENDIF
22091 
22092 C...If incoming (anti-)baryon, insert inside (anti-)junction.
22093 C...Set up initial v-v-j-v configuration. Otherwise set up
22094 C...mesonic v-vbar configuration
22095  IF (iabs(mint(10+js)).GT.1000) THEN
22096 C...Determine junction type (1: B=1 2: B=-1)
22097  itjunc(js) = (3-kfs)/2
22098 C...Insert junction.
22099  n=n+1
22100  DO 250 ix=1,5
22101  k(n,ix)=0
22102  p(n,ix)=0d0
22103  v(n,ix)=0d0
22104  250 CONTINUE
22105 C...Set special junction codes:
22106  k(n,1)=42
22107  k(n,2)=88
22108 C...Set parent to side.
22109  k(n,3)=mint(83)+js
22110  k(n,4)=itjunc(js)*mstu(5)
22111  k(n,5)=0
22112 C...Connect valence quarks to junction.
22113  mout(js)=0
22114  manti=itjunc(js)-1
22115 C...Set (anti)colour mother = junction.
22116  DO 260 jv=1,3
22117  k(iv(js,jv),4+manti)=mod(k(iv(js,jv),4+manti),mstu(5))
22118  & +mstu(5)*n
22119 C...Keep track of partons adjacent to junction:
22120  jst(js,jv)=iv(js,jv)
22121  260 CONTINUE
22122  ELSE
22123 C...Mesons: set up initial q-qbar topology
22124  itjunc(js)=0
22125  IF (k(iv(js,1),2).GT.0) THEN
22126  iq=iv(js,1)
22127  iqbar=iv(js,2)
22128  ELSE
22129  iq=iv(js,2)
22130  iqbar=iv(js,1)
22131  ENDIF
22132  iv(js,3)=0
22133  jst(js,1)=iq
22134  jst(js,2)=iqbar
22135  jst(js,3)=0
22136  k(iq,4)=mod(k(iq,4),mstu(5))+mstu(5)*iqbar
22137  k(iqbar,5)=mod(k(iqbar,5),mstu(5))+mstu(5)*iq
22138 C...Special for mesons. Insert gluon if BR empty.
22139  IF (nbrtot(js).EQ.0) THEN
22140  n=n+1
22141  DO 270 ix=1,5
22142  k(n,ix)=0
22143  p(n,ix)=0d0
22144  v(n,ix)=0d0
22145  270 CONTINUE
22146  k(n,1)=3
22147  k(n,2)=21
22148  k(n,3)=mint(83)+js
22149  k(n,4)=0
22150  k(n,5)=0
22151  nbrtot(js)=1
22152  ng(js)=ng(js)+1
22153 C...Add gluon to IMI
22154  nmi(js)=nmi(js)+1
22155  imi(js,nmi(js),1)=n
22156  imi(js,nmi(js),2)=0
22157  ENDIF
22158  mout(js)=0
22159  ENDIF
22160 
22161 C...Count up number of valence quarks outside BR.
22162  DO 280 jv=1,3
22163  IF (jst(js,jv).LE.mint(53).AND.jst(js,jv).GT.0)
22164  & mout(js)=mout(js)+1
22165  280 CONTINUE
22166 
22167  290 CONTINUE
22168 
22169 C...Now both sides have been prepared in an initial vvjv (baryonic) or
22170 C...v(g)vbar (mesonic) configuration.
22171 
22172 C...Create colour line tags starting from initiators.
22173  nct=0
22174  DO 320 im=1,mint(31)
22175 C...Consider each side in turn.
22176  DO 310 js=1,2
22177  i1=imi(js,im,1)
22178  i2=imi(3-js,im,1)
22179  DO 300 jcs=4,5
22180  IF (k(i1,2).NE.21.AND.(9-2*jcs).NE.isign(1,k(i1,2)))
22181  & goto 300
22182  IF (k(i1,jcs)/mstu(5)**2.NE.0) goto 300
22183 
22184  kcs=jcs
22185  CALL pycttr(i1,kcs,i2)
22186  IF(mint(51).NE.0) RETURN
22187 
22188  300 CONTINUE
22189  310 CONTINUE
22190  320 CONTINUE
22191 
22192  DO 340 js=1,2
22193 C...Create colour tags for beam remnant partons.
22194  DO 330 im=mint(31)+1,nmi(js)
22195  ip=imi(js,im,1)
22196  IF (k(ip,2).NE.21) THEN
22197  jc=(3-isign(1,k(ip,2)))/2
22198  IF (mct(ip,jc).EQ.0) THEN
22199  nct=nct+1
22200  mct(ip,jc)=nct
22201  ENDIF
22202  ELSE
22203 C...Gluons
22204  icd=k(ip,4)
22205  iad=k(ip,5)
22206  IF (icd.NE.0) THEN
22207 C...Fictituous gluons just inherit from their quark daughters.
22208  icc=mct(icd,1)
22209  iac=mct(iad,2)
22210  ELSE
22211 C...Real beam remnant gluons get their own colours
22212  icc=nct+1
22213  iac=nct+2
22214  nct=nct+2
22215  ENDIF
22216  mct(ip,1)=icc
22217  mct(ip,2)=iac
22218  ENDIF
22219  330 CONTINUE
22220  340 CONTINUE
22221 
22222 C...Create colour tags for colour lines which are detached from the
22223 C...initial state.
22224 
22225  DO 360 mqgst=1,2
22226  DO 350 i=mint(84)+1,n
22227 
22228 C...Look for coloured string endpoint, or (later) leftover gluon.
22229  IF (k(i,1).NE.3) goto 350
22230  kc=pycomp(k(i,2))
22231  IF(kc.EQ.0) goto 350
22232  kq=kchg(kc,2)
22233  IF(kq.EQ.0.OR.(mqgst.EQ.1.AND.kq.EQ.2)) goto 350
22234 
22235 C...Pick up loose string end with no previous tag.
22236  kcs=4
22237  IF(kq*isign(1,k(i,2)).LT.0) kcs=5
22238  IF(mct(i,kcs-3).NE.0) goto 350
22239 
22240  CALL pycttr(i,kcs,i)
22241  IF(mint(51).NE.0) RETURN
22242 
22243  350 CONTINUE
22244  360 CONTINUE
22245 
22246 C...Store original colour tags
22247  DO 370 i=mint(84)+1,n
22248  mco(i,1)=mct(i,1)
22249  mco(i,2)=mct(i,2)
22250  370 CONTINUE
22251 
22252 C...Iteratively add gluons to already existing string pieces, enforcing
22253 C...various possible orderings, and rejecting insertions that would give
22254 C...rise to singlet gluons.
22255 C...<kappa tau> normalization.
22256  rm0=1.5d0
22257  mretry=0
22258  parp80=parp(80)
22259 
22260 C...Set up simplified kinematics.
22261 C...Boost hard interaction systems.
22262  iboost=iboost+1
22263  DO 380 im=1,mint(31)
22264  beta=(xmi(1,im)-xmi(2,im))/(xmi(1,im)+xmi(2,im))
22265  CALL pyrobo(imisep(im-1)+1,imisep(im),0d0,0d0,0d0,0d0,beta)
22266  380 CONTINUE
22267 C...Assign preliminary beam remnant momenta.
22268  DO 390 i=mint(53)+1,n
22269  js=k(i,3)
22270  p(i,1)=0d0
22271  p(i,2)=0d0
22272  IF (k(i,2).NE.88) THEN
22273  p(i,4)=0.5d0*vint(142+js)*vint(1)/max(1,nmi(js)-mint(31))
22274  p(i,3)=p(i,4)
22275  IF (js.EQ.2) p(i,3)=-p(i,3)
22276  ELSE
22277 C...Junctions are wildcards for the present.
22278  p(i,4)=0d0
22279  p(i,3)=0d0
22280  ENDIF
22281  390 CONTINUE
22282 
22283 C...Reset colour processing information.
22284  400 DO 410 i=mint(84)+1,n
22285  k(i,4)=mod(k(i,4),mstu(5)**2)
22286  k(i,5)=mod(k(i,5),mstu(5)**2)
22287  410 CONTINUE
22288 
22289  ncc=0
22290  DO 430 js=1,2
22291 C...If meson, without gluon in BR, collapse q-qbar colour tags:
22292  IF (itjunc(js).EQ.0) THEN
22293  jc1=mct(jst(js,1),1)
22294  jc2=mct(jst(js,2),2)
22295  ncc=ncc+1
22296  jcco(ncc,1)=max(jc1,jc2)
22297  jcco(ncc,2)=min(jc1,jc2)
22298 C...Collapse colour tags in event record
22299  DO 420 i=mint(84)+1,n
22300  IF (mct(i,1).EQ.jcco(ncc,1)) mct(i,1)=jcco(ncc,2)
22301  IF (mct(i,2).EQ.jcco(ncc,1)) mct(i,2)=jcco(ncc,2)
22302  420 CONTINUE
22303  ENDIF
22304  430 CONTINUE
22305 
22306  440 js=1
22307  IF (pyr(0).GT.0.5d0.OR.ng(1).EQ.0) js=2
22308  IF (ng(js).GT.0) THEN
22309  nopt=0
22310  rlopt=1d9
22311 C...Start at random gluon (optimizes speed for random attachments)
22312  nmgl=0
22313  imgl=pyr(0)*nmi(js)+1
22314  450 imgl=mod(imgl,nmi(js))+1
22315  nmgl=nmgl+1
22316 C...Only loop through NMI once (with upper limit to save time)
22317  IF (nmgl.LE.nmi(js).AND.nopt.LE.3) THEN
22318  igl = imi(js,imgl,1)
22319 C...If not gluon or if already connected, try next.
22320  IF (k(igl,2).NE.21.OR.k(igl,4)/mstu(5).NE.0
22321  & .OR.k(igl,5)/mstu(5).NE.0) goto 450
22322 C...Now loop through all possible insertions of this gluon.
22323  nmp1=0
22324  imp1=pyr(0)*nmi(js)+1
22325  460 imp1=mod(imp1,nmi(js))+1
22326  nmp1=nmp1+1
22327  IF (imp1.EQ.imgl) goto 460
22328 C...Only loop through NMI once (with upper limit to save time).
22329  IF (nmp1.LE.nmi(js).AND.nopt.LE.3) THEN
22330  ip1 = imi(js,imp1,1)
22331 C...Try both colour mother and colour anti-mother.
22332 C...Randomly select which one to try first.
22333  nanti=0
22334  manti=pyr(0)*2
22335  470 manti=mod(manti+1,2)
22336  nanti=nanti+1
22337  IF (nanti.LE.2) THEN
22338  ip2 =mod(k(ip1,4+manti)/mstu(5),mstu(5))
22339 C...Reject if no appropriate mother (or if mother is fictitious
22340 C...parent gluon.)
22341  IF (ip2.LE.0) goto 470
22342  IF (k(ip2,2).EQ.21.AND.ip2.GT.mint(53)) goto 470
22343 C...Also reject if this link has already been tried.
22344  IF (k(ip1,4+manti)/mstu(5)**2.EQ.2) goto 470
22345  IF (k(ip2,5-manti)/mstu(5)**2.EQ.2) goto 470
22346 C...Set flag to indicate that this link has now been tried for this
22347 C...gluon. IP2 may be junction, which has several mothers.
22348  k(ip1,4+manti)=k(ip1,4+manti)+2*mstu(5)**2
22349  IF (k(ip2,2).NE.88) THEN
22350  k(ip2,5-manti)=k(ip2,5-manti)+2*mstu(5)**2
22351  ENDIF
22352 
22353 C...JCG1: Original colour tag of gluon on IP1 side
22354 C...JCG2: Original colour tag of gluon on IP2 side
22355 C...JCP1: Original colour tag of IP1 on gluon side
22356 C...JCP2: Original colour tag of IP2 on gluon side.
22357  jcg1=mco(igl,2-manti)
22358  jcg2=mco(igl,1+manti)
22359  jcp1=mco(ip1,1+manti)
22360  jcp2=mco(ip2,2-manti)
22361 
22362  CALL pymihg(jcp1,jcg1,jcp2,jcg2)
22363 C...Reject gluon attachments that give rise to singlet gluons.
22364  IF (maccpt.EQ.0) goto 470
22365 
22366 C...Update colours
22367  jcg1=mct(igl,2-manti)
22368  jcg2=mct(igl,1+manti)
22369  jcp1=mct(ip1,1+manti)
22370  jcp2=mct(ip2,2-manti)
22371 
22372 C...Select whether to accept this insertion
22373  IF (mstp(89).EQ.0) THEN
22374 C...Random insertions: no measure.
22375  rl=1d0
22376 C...For random ordering, we want to suppress beam remnant breakups
22377 C...already at this point.
22378  IF (ip1.GT.mint(53).AND.ip2.GT.mint(53)
22379  & .AND.mout(js).NE.0.AND.pyr(0).GT.parp80) THEN
22380  nmp1=0
22381  nmgl=0
22382  goto 470
22383  ENDIF
22384  ELSEIF (mstp(89).EQ.1) THEN
22385 C...Rapidity ordering:
22386 C...YGL = Rapidity of gluon.
22387  ygl=ymi(imgl)
22388 C...If fictitious gluon
22389  IF (ygl.EQ.100d0) THEN
22390  ygl=(3-2*js)*100d0
22391  ida1=mod(k(igl,4),mstu(5))
22392  ida2=mod(k(igl,5),mstu(5))
22393  DO 480 imt=1,nmi(js)
22394 C...Select (arbitrarily) the most central daughter.
22395  IF (imi(js,imt,1).EQ.ida1.OR.imi(js,imt,1).EQ.ida2)
22396  & THEN
22397  IF (abs(ygl).GT.abs(ymi(imt))) ygl=ymi(imt)
22398  ENDIF
22399  480 CONTINUE
22400  ENDIF
22401 C...YP1 = Rapidity IP1
22402  yp1=ymi(imp1)
22403 C...If fictitious gluon
22404  IF (yp1.EQ.100d0) THEN
22405  yp1=(3-2*js)*yp1
22406  ida1=mod(k(ip1,4),mstu(5))
22407  ida2=mod(k(ip1,5),mstu(5))
22408  DO 490 imt=1,nmi(js)
22409 C...Select (arbitrarily) the most central daughter.
22410  IF (imi(js,imt,1).EQ.ida1.OR.imi(js,imt,1).EQ.ida2)
22411  & THEN
22412  IF (abs(yp1).GT.abs(ymi(imt))) yp1=ymi(imt)
22413  ENDIF
22414  490 CONTINUE
22415  ENDIF
22416 C...YP2 = Rapidity of mother system
22417  IF (k(ip2,2).NE.88) THEN
22418  DO 500 imt=1,nmi(js)
22419  IF (imi(js,imt,1).EQ.ip2) yp2=ymi(imt)
22420  500 CONTINUE
22421 C...If fictitious gluon
22422  IF (yp2.EQ.100d0) THEN
22423  yp2=(3-2*js)*yp2
22424  ida1=mod(k(ip2,4),mstu(5))
22425  ida2=mod(k(ip2,5),mstu(5))
22426  DO 510 imt=1,nmi(js)
22427 C...Select (arbitrarily) the most central daughter.
22428  IF (imi(js,imt,1).EQ.ida1.OR.imi(js,imt,1).EQ.ida2
22429  & ) THEN
22430  IF (abs(yp2).GT.abs(ymi(imt))) yp2=ymi(imt)
22431  ENDIF
22432  510 CONTINUE
22433  ENDIF
22434 C...Assign (arbitrarily) 100D0 to junction also
22435  ELSE
22436  yp2=(3-2*js)*100d0
22437  ENDIF
22438  rl=abs(ygl-yp1)+abs(ygl-yp2)
22439  ELSEIF (mstp(89).EQ.2) THEN
22440 C...Lambda ordering:
22441 C...Compute lambda measure for this insertion.
22442  rl=1d0
22443  DO 520 ist=1,6
22444  istr(ist)=0
22445  520 CONTINUE
22446 C...If IP2 is junction, not caught below.
22447  IF (jcp2.EQ.0) THEN
22448  itju=mod(k(ip2,4)/mstu(5),mstu(5))
22449 C...Anti-junction is colour endpoint et vv., always on JCG2.
22450  istr(5-itju)=ip2
22451  ENDIF
22452  DO 530 i=mint(84)+1,n
22453  IF (k(i,1).LT.10) THEN
22454 C...The new string pieces
22455  IF (mct(i,1).EQ.jcg1) istr(1)=i
22456  IF (mct(i,2).EQ.jcg1) istr(2)=i
22457  IF (mct(i,1).EQ.jcg2) istr(3)=i
22458  IF (mct(i,2).EQ.jcg2) istr(4)=i
22459  ENDIF
22460  530 CONTINUE
22461 C...Also identify junctions as string endpoints.
22462  DO 540 i=mint(84)+1,n
22463  icmo=mod(k(i,4)/mstu(5),mstu(5))
22464  iamo=mod(k(i,5)/mstu(5),mstu(5))
22465 C...Find partons adjacent to junctions.
22466  IF (icmo.GT.0.AND.icmo.LE.n) THEN
22467  IF (k(icmo,1).EQ.42.AND.mct(i,1).EQ.jcg1.AND.istr(2)
22468  & .EQ.0) istr(2) = icmo
22469  IF (k(icmo,1).EQ.42.AND.mct(i,1).EQ.jcg2.AND.istr(4)
22470  & .EQ.0) istr(4) = icmo
22471  ENDIF
22472  IF (iamo.GT.0.AND.iamo.LE.n) THEN
22473  IF (k(iamo,1).EQ.42.AND.mct(i,2).EQ.jcg1.AND.istr(1)
22474  & .EQ.0) istr(1) = iamo
22475  IF (k(iamo,1).EQ.42.AND.mct(i,2).EQ.jcg2.AND.istr(3)
22476  & .EQ.0) istr(3) = iamo
22477  ENDIF
22478  540 CONTINUE
22479 C...The old string piece
22480  istr(5)=istr(1+2*manti)
22481  istr(6)=istr(4-2*manti)
22482  IF (istr(1).EQ.0.OR.istr(2).EQ.0.OR.istr(3).EQ.0.OR.
22483  & istr(4).EQ.0.OR.istr(5).EQ.0.OR.istr(6).EQ.0) THEN
22484 C...If one or more of the colour tags for this connection is/are still
22485 C...dangling, skip this attempt for the time being.
22486  rl=1d6
22487  ELSE
22488  rl=max(1d0,four(istr(1),istr(2)))*max(1d0,four(istr(3)
22489  & ,istr(4)))/max(1d0,four(istr(5),istr(6)))
22490  rl=log(rl)
22491  ENDIF
22492  ENDIF
22493 C...Allow some breadth to speed things up.
22494  IF (abs(1d0-rl/rlopt).LT.0.05d0) THEN
22495  nopt=nopt+1
22496  ELSEIF (rl.GT.rlopt) THEN
22497  goto 470
22498  ELSE
22499  nopt=1
22500  rlopt=rl
22501  ENDIF
22502 C...INSR(NOPT,1)=Gluon colour mother
22503 C...INSR(NOPT,2)=Gluon
22504 C...INSR(NOPT,3)=Gluon anticolour mother
22505  IF (nopt.GT.1000) goto 470
22506  insr(nopt,1+2*manti)=ip2
22507  insr(nopt,2)=igl
22508  insr(nopt,3-2*manti)=ip1
22509  IF (mstp(89).GT.0.OR.nopt.EQ.0) goto 470
22510  ENDIF
22511  IF (mstp(89).GT.0.OR.nopt.EQ.0) goto 460
22512  ENDIF
22513 C...Reset link test information.
22514  DO 550 i=mint(84)+1,n
22515  k(i,4)=mod(k(i,4),mstu(5)**2)
22516  k(i,5)=mod(k(i,5),mstu(5)**2)
22517  550 CONTINUE
22518  IF (mstp(89).GT.0.OR.nopt.EQ.0) goto 450
22519  ENDIF
22520 C...Now we have a list of best gluon insertions, none of which cause
22521 C...singlets to arise. If list is empty, try again a few times. Note:
22522 C...this should never happen if we have a meson with a gluon inserted
22523 C...in the beam remnant, since that breaks up the colour line.
22524  IF (nopt.EQ.0) THEN
22525 C...Abandon BR-g-BR suppression for retries. This is not serious, it
22526 C...just means we happened to start with trying a bad sequence.
22527  parp80=1d0
22528  IF (mretry.LE.10.AND.(itjunc(1).NE.0.OR.jst(1,3).EQ.0).and
22529  & .(itjunc(2).NE.0.OR.jst(2,3).EQ.0)) THEN
22530  mretry=mretry+1
22531  DO 590 js=1,2
22532  IF (itjunc(js).NE.0) THEN
22533  jst(js,1)=iv(js,1)
22534  jst(js,2)=iv(js,2)
22535  jst(js,3)=iv(js,3)
22536 C...Reset valence quark parent pointers
22537  DO 560 i=mint(53)+1,n
22538  IF (k(i,2).EQ.88.AND.k(i,3).EQ.js) iju=i
22539  560 CONTINUE
22540  manti=itjunc(js)-1
22541 C...Set (anti)colour mother = junction.
22542  DO 570 jv=1,3
22543  k(iv(js,jv),4+manti)=mod(k(iv(js,jv),4+manti),mstu(5))
22544  & +mstu(5)*iju
22545  570 CONTINUE
22546  ELSE
22547 C...Same for mesons. JST unchanged, so needn't be restored.
22548  iq=jst(js,1)
22549  iqbar=jst(js,2)
22550  k(iq,4)=mod(k(iq,4),mstu(5))+mstu(5)*iqbar
22551  k(iqbar,5)=mod(k(iqbar,5),mstu(5))+mstu(5)*iq
22552  ENDIF
22553 C...Also reset gluon parent pointers.
22554  ng(js)=0
22555  DO 580 im=1,nmi(js)
22556  i=imi(js,im,1)
22557  IF (k(i,2).EQ.21) THEN
22558  k(i,4)=mod(k(i,4),mstu(5))
22559  k(i,5)=mod(k(i,5),mstu(5))
22560  ng(js)=ng(js)+1
22561  ENDIF
22562  580 CONTINUE
22563  590 CONTINUE
22564 C...Reset colour tags
22565  DO 600 i=mint(84)+1,n
22566  mct(i,1)=mco(i,1)
22567  mct(i,2)=mco(i,2)
22568  600 CONTINUE
22569  goto 400
22570  ELSE
22571  IF(nerrpr.LT.5) THEN
22572  nerrpr=nerrpr+1
22573  CALL pylist(4)
22574  CALL pyerrm(19,'(PYMIHK:) No physical colour flow found!')
22575  WRITE(mstu(11),*) 'NG:', ng,' MOUT:', mout(js)
22576  ENDIF
22577 C...Kill event and start another.
22578  mint(51)=1
22579  RETURN
22580  ENDIF
22581  ELSE
22582 C...Select between insertions, suppressing insertions wholly in the BR.
22583  iin=pyr(0)*nopt+1
22584  610 iin=mod(iin,nopt)+1
22585  IF (insr(iin,1).GT.mint(53).AND.insr(iin,3).GT.mint(53)
22586  & .AND.mout(js).NE.0.AND.pyr(0).GT.parp80) goto 610
22587  ENDIF
22588 
22589 C...Now we know which gluon to insert where. Colour tags in JCCO and
22590 C...colour connection information should be updated, NG(JS) should be
22591 C...counted down, and a new loop performed if there are still gluons
22592 C...left on any side.
22593  icm=insr(iin,1)
22594  iacm=insr(iin,3)
22595  igl=insr(iin,2)
22596 C...JCG : Original gluon colour tag
22597 C...JCAG: Original gluon anticolour tag.
22598 C...JCM : Original anticolour tag of gluon colour mother
22599 C...JACM: Original colour tag of gluon anticolour mother
22600  jcg=mco(igl,1)
22601  jcm=mco(icm,2)
22602  jacg=mco(igl,2)
22603  jacm=mco(iacm,1)
22604 
22605  CALL pymihg(jacm,jacg,jcm,jcg)
22606  IF (maccpt.EQ.0) THEN
22607  IF(nerrpr.LT.5) THEN
22608  nerrpr=nerrpr+1
22609  CALL pylist(4)
22610  CALL pyerrm(11,'(PYMIHK:) Unphysical colour flow!')
22611  WRITE(mstu(11),*) 'attaching', igl,' between', icm, iacm
22612  ENDIF
22613 C...Kill event and start another.
22614  mint(51)=1
22615  RETURN
22616  ELSE
22617 C...If everything went fine, store new JCCN in JCCO.
22618  ncc=ncc+1
22619  DO 620 icc=1,ncc
22620  jcco(icc,1)=jccn(icc,1)
22621  jcco(icc,2)=jccn(icc,2)
22622  620 CONTINUE
22623  ENDIF
22624 
22625 C...One gluon attached is counted as equivalent to one end outside.
22626  mout(js)=1
22627 C...Set IGL colour mother = ICM.
22628  k(igl,4)=mod(k(igl,4),mstu(5))+mstu(5)*icm
22629 C...Set ICM anticolour mother = IGL colour.
22630  IF (k(icm,2).NE.88) THEN
22631  k(icm,5)=mod(k(icm,5),mstu(5))+mstu(5)*igl
22632  ELSE
22633 C...If ICM is junction, just update JST array for now.
22634  DO 630 msj=1,3
22635  IF (jst(js,msj).EQ.iacm) jst(js,msj)=igl
22636  630 CONTINUE
22637  ENDIF
22638 C...Set IGL anticolour mother = IACM.
22639  k(igl,5)=mod(k(igl,5),mstu(5))+mstu(5)*iacm
22640 C...Set IACM anticolour mother = IGL anticolour.
22641  IF (k(iacm,2).NE.88) THEN
22642  k(iacm,4)=mod(k(iacm,4),mstu(5))+mstu(5)*igl
22643  ELSE
22644 C...If IACM is junction, just update JST array for now.
22645  DO 640 msj=1,3
22646  IF (jst(js,msj).EQ.icm) jst(js,msj)=igl
22647  640 CONTINUE
22648  ENDIF
22649 C...Count down # unconnected gluons.
22650  ng(js)=ng(js)-1
22651  ENDIF
22652  IF (ng(1).GT.0.OR.ng(2).GT.0) goto 440
22653 
22654  DO 840 js=1,2
22655 C...Collapse fictitious gluons.
22656  DO 670 igl=mint(53)+1,n
22657  IF (k(igl,2).EQ.21.AND.k(igl,3).EQ.mint(83)+js.AND.
22658  & k(igl,1).EQ.14) THEN
22659  icm=k(igl,4)/mstu(5)
22660  iam=k(igl,5)/mstu(5)
22661  icd=mod(k(igl,4),mstu(5))
22662  iad=mod(k(igl,5),mstu(5))
22663 C...Set gluon daughters pointing to gluon mothers
22664  k(iad,5)=mod(k(iad,5),mstu(5))+mstu(5)*iam
22665  k(icd,4)=mod(k(icd,4),mstu(5))+mstu(5)*icm
22666 C...Set gluon mothers pointing to gluon daughters.
22667  IF (k(icm,2).NE.88) THEN
22668  k(icm,5)=mod(k(icm,5),mstu(5))+mstu(5)*icd
22669  ELSE
22670 C...Special case: mother=junction. Just update JST array for now.
22671  DO 650 msj=1,3
22672  IF (jst(js,msj).EQ.igl) jst(js,msj)=icd
22673  650 CONTINUE
22674  ENDIF
22675  IF (k(iam,2).NE.88) THEN
22676  k(iam,4)=mod(k(iam,4),mstu(5))+mstu(5)*iad
22677  ELSE
22678  DO 660 msj=1,3
22679  IF (jst(js,msj).EQ.igl) jst(js,msj)=iad
22680  660 CONTINUE
22681  ENDIF
22682  ENDIF
22683  670 CONTINUE
22684 
22685 C...Erase collapsed gluons from NMI and IMI (but keep them in ER)
22686  im=nmi(js)+1
22687  680 im=im-1
22688  IF (im.GT.mint(31).AND.k(imi(js,im,1),2).NE.21) goto 680
22689  IF (im.GT.mint(31)) THEN
22690  nmi(js)=nmi(js)-1
22691  DO 690 imr=im,nmi(js)
22692  imi(js,imr,1)=imi(js,imr+1,1)
22693  imi(js,imr,2)=imi(js,imr+1,2)
22694  690 CONTINUE
22695  goto 680
22696  ENDIF
22697 
22698 C...Finally, connect junction.
22699  IF (itjunc(js).NE.0) THEN
22700  DO 700 i=mint(53)+1,n
22701  IF (k(i,2).EQ.88.AND.k(i,3).EQ.mint(83)+js) iju=i
22702  700 CONTINUE
22703 C...NBRJQ counts # of jq, NBRVQ # of jv, inside BR.
22704  nbrjq =0
22705  nbrvq =0
22706  DO 720 msj=1,3
22707  idq(msj)=0
22708 C...Find jq with no glue inbetween inside beam remnant.
22709  IF (jst(js,msj).GT.mint(53).AND.iabs(k(jst(js,msj),2)).LE.5)
22710  & THEN
22711  nbrjq=nbrjq+1
22712 C...Set IDQ = -I if q non-valence and = +I if q valence.
22713  idq(nbrjq)=-jst(js,msj)
22714  DO 710 jv=1,3
22715  IF (iv(js,jv).EQ.jst(js,msj)) THEN
22716  idq(nbrjq)=jst(js,msj)
22717  nbrvq=nbrvq+1
22718  ENDIF
22719  710 CONTINUE
22720  ENDIF
22721  i12=mod(msj+1,2)
22722  i45=5
22723  IF (msj.EQ.3) i45=4
22724  k(iju,i45)=k(iju,i45)+(mstu(5)**i12)*jst(js,msj)
22725  720 CONTINUE
22726 
22727 C...Check if diquark can be formed.
22728  IF ((mstp(88).GE.0.AND.nbrvq.GE.2).OR.(nbrjq.GE.2.AND.mstp(88)
22729  & .GE.1)) THEN
22730 C...If there is less than 2 valence quarks connected to junction
22731 C...and MSTP(88)>1, use random non-valence quarks to fill up.
22732  IF (nbrvq.LE.1) THEN
22733  ndiq=nbrvq
22734  730 jflip=nbrjq*pyr(0)+1
22735  IF (idq(jflip).LT.0) THEN
22736  idq(jflip)=-idq(jflip)
22737  ndiq=ndiq+1
22738  ENDIF
22739  IF (ndiq.LE.1) goto 730
22740  ENDIF
22741 C...Place selected quarks first in IDQ, ordered in flavour.
22742  DO 740 jdq=1,3
22743  IF (idq(jdq).LE.0) THEN
22744  itemp1 = idq(jdq)
22745  idq(jdq)= idq(3)
22746  idq(3) = -itemp1
22747  IF (iabs(k(idq(1),2)).LT.iabs(k(idq(2),2))) THEN
22748  itemp1 = idq(1)
22749  idq(1) = idq(2)
22750  idq(2) = itemp1
22751  ENDIF
22752  ENDIF
22753  740 CONTINUE
22754 C...Choose diquark spin.
22755  IF (nbrvq.EQ.2) THEN
22756 C...If the selected quarks are both valence, we may use SU(6) rules
22757 C...to figure out which spin the diquark has, by a subdivision of the
22758 C...original beam hadron into the selected diquark system plus a kicked
22759 C...out quark, IKO.
22760  jko=6
22761  DO 760 jdq=1,2
22762  DO 750 jv=1,3
22763  IF (idq(jdq).EQ.iv(js,jv)) jko=jko-jv
22764  750 CONTINUE
22765  760 CONTINUE
22766  iko=iv(js,jko)
22767  CALL pyspli(mint(10+js),k(iko,2),kfdum,kfdq)
22768  ELSE
22769 C...If one or more of the selected quarks are not valence, we cannot use
22770 C...SU(6) subdivisions of the original beam hadron. Instead, with the
22771 C...flavours of the diquark already selected, we assume for now
22772 C...50:50 spin-1:spin-0 (where spin-0 possible).
22773  kfdq=1000*k(idq(1),2)+100*k(idq(2),2)
22774  is=3
22775  IF (k(idq(1),2).NE.k(idq(2),2).AND.
22776  & (1d0+3d0*parj(4))*pyr(0).LT.1d0) is=1
22777  kfdq=kfdq+isign(is,kfdq)
22778  ENDIF
22779 
22780 C...Collapse diquark-j-quark system to baryon, if allowed and possible.
22781 C...Note: third quark can per definition not also be valence,
22782 C...therefore we can only do this if we are allowed to use sea quarks.
22783  770 IF (idq(3).NE.0.AND.mstp(88).GE.2) THEN
22784  ntry=0
22785  780 ntry=ntry+1
22786  CALL pykfdi(kfdq,k(iabs(idq(3)),2),kfdum,kfbar)
22787  IF (kfbar.EQ.0.AND.ntry.LE.100) THEN
22788  goto 780
22789  ELSEIF(ntry.GT.100) THEN
22790 C...If no baryon can be found, give up and form diquark.
22791  idq(3)=0
22792  goto 770
22793  ELSE
22794 C...Replace junction by baryon.
22795  k(iju,1)=1
22796  k(iju,2)=kfbar
22797  k(iju,3)=mint(83)+js
22798  k(iju,4)=0
22799  k(iju,5)=0
22800  p(iju,5)=pymass(kfbar)
22801  DO 790 msj=1,3
22802 C...Prepare removal of participating quarks from ER.
22803  k(jst(js,msj),1)=-1
22804  790 CONTINUE
22805  ENDIF
22806  ELSE
22807 C...If collapse to baryon not possible or not allowed, replace junction
22808 C...by diquark. This way, collapsed gluons that were pointing at the
22809 C...junction will now point (correctly) at diquark.
22810  manti=itjunc(js)-1
22811  k(iju,1)=3
22812  k(iju,2)=kfdq
22813  k(iju,3)=mint(83)+js
22814  k(iju,4)=0
22815  k(iju,5)=0
22816  DO 800 msj=1,3
22817  ip=jst(js,msj)
22818  IF (ip.NE.idq(1).AND.ip.NE.idq(2)) THEN
22819  k(iju,4+manti)=0
22820  k(iju,5-manti)=ip*mstu(5)
22821  k(ip,4+manti)=mod(k(ip,4+manti),mstu(5))+
22822  & mstu(5)*iju
22823  mct(iju,2-manti)=mct(ip,1+manti)
22824  ELSE
22825 C...Prepare removal of participating quarks from ER.
22826  k(ip,1)=-1
22827  ENDIF
22828  800 CONTINUE
22829  ENDIF
22830 
22831 C...Update so ER pointers to collapsed quarks
22832 C...now go to collapsed object.
22833  DO 820 i=mint(84)+1,n
22834  IF ((k(i,3).EQ.mint(83)+js.OR.k(i,3).EQ.mint(83)+2+js).and
22835  & .k(i,1).GT.0) THEN
22836  DO 810 isid=4,5
22837  imo=k(i,isid)/mstu(5)
22838  ida=mod(k(i,isid),mstu(5))
22839  IF (imo.GT.0) THEN
22840  IF (k(imo,1).EQ.-1) imo=iju
22841  ENDIF
22842  IF (ida.GT.0) THEN
22843  IF (k(ida,1).EQ.-1) ida=iju
22844  ENDIF
22845  k(i,isid)=ida+mstu(5)*imo
22846  810 CONTINUE
22847  ENDIF
22848  820 CONTINUE
22849  ENDIF
22850  ENDIF
22851 
22852 C...Finally, if beam remnant is empty, insert a gluon in beam remnant.
22853 C...(this only happens for baryons, where we want to force the gluon
22854 C...to sit next to the junction. Mesons handled above.)
22855  IF (nbrtot(js).EQ.0) THEN
22856  n=n+1
22857  DO 830 ix=1,5
22858  k(n,ix)=0
22859  p(n,ix)=0d0
22860  v(n,ix)=0d0
22861  830 CONTINUE
22862  igl=n
22863  k(igl,1)=3
22864  k(igl,2)=21
22865  k(igl,3)=mint(83)+js
22866  IF (itjunc(js).NE.0) THEN
22867 C...Incoming baryons. Pick random leg in JST (NVSUM = 3 for baryons)
22868  jleg=pyr(0)*nvsum(js)+1
22869  i1=jst(js,jleg)
22870  jst(js,jleg)=igl
22871  jct=mct(i1,itjunc(js))
22872  mct(igl,3-itjunc(js))=jct
22873  nct=nct+1
22874  mct(igl,itjunc(js))=nct
22875  manti=itjunc(js)-1
22876  ELSE
22877 C...Meson. Should not happen.
22878  CALL pyerrm(19,'(PYMIHK:) Empty meson beam remnant')
22879  IF(nerrpr.LT.5) THEN
22880  WRITE(mstu(11),*) 'This should not have been possible!'
22881  CALL pylist(4)
22882  nerrpr=nerrpr+1
22883  ENDIF
22884  mint(51)=1
22885  RETURN
22886  ENDIF
22887  i2=mod(k(i1,4+manti)/mstu(5),mstu(5))
22888  k(i1,4+manti)=mod(k(i1,4+manti),mstu(5))+mstu(5)*igl
22889  k(igl,5-manti)=mod(k(igl,5-manti),mstu(5))+mstu(5)*i1
22890  k(igl,4+manti)=mod(k(igl,4+manti),mstu(5))+mstu(5)*i2
22891  IF (k(i2,2).NE.88) THEN
22892  k(i2,5-manti)=mod(k(i2,5-manti),mstu(5))+mstu(5)*igl
22893  ELSE
22894  IF (mod(k(i2,4),mstu(5)).EQ.i1) THEN
22895  k(i2,4)=(k(i2,4)/mstu(5))*mstu(5)+igl
22896  ELSEIF(mod(k(i2,5)/mstu(5),mstu(5)).EQ.i1) THEN
22897  k(i2,5)=mod(k(i2,5),mstu(5))+mstu(5)*igl
22898  ELSE
22899  k(i2,5)=(k(i2,5)/mstu(5))*mstu(5)+igl
22900  ENDIF
22901  ENDIF
22902  ENDIF
22903  840 CONTINUE
22904 
22905 C...Remove collapsed quarks and junctions from ER and update IMI.
22906  CALL pyedit(11)
22907 
22908 C...Also update beam remnant part of IMI.
22909  nmi(1)=mint(31)
22910  nmi(2)=mint(31)
22911  DO 850 i=mint(53)+1,n
22912  IF (k(i,1).LE.0) goto 850
22913 C...Restore BR quark/diquark/baryon pointers in IMI.
22914  IF ((k(i,2).NE.21.OR.k(i,1).NE.14).AND.k(i,2).NE.88) THEN
22915  js=k(i,3)-mint(83)
22916  nmi(js)=nmi(js)+1
22917  imi(js,nmi(js),1)=i
22918  imi(js,nmi(js),2)=0
22919  ENDIF
22920  850 CONTINUE
22921 
22922 C...Restore companion information from collapsed gluons.
22923  DO 870 i=mint(53)+1,n
22924  IF (k(i,2).EQ.21.AND.k(i,1).EQ.14) THEN
22925  js=k(i,3)-mint(83)
22926  jcd=mod(k(i,4),mstu(5))
22927  jad=mod(k(i,5),mstu(5))
22928  DO 860 im=1,nmi(js)
22929  IF (imi(js,im,1).EQ.jcd) imc=im
22930  IF (imi(js,im,1).EQ.jad) ima=im
22931  860 CONTINUE
22932  imi(js,imc,2)=imi(js,ima,1)
22933  imi(js,ima,2)=imi(js,imc,1)
22934  ENDIF
22935  870 CONTINUE
22936 
22937 C...Renumber colour lines (since some have disappeared)
22938  jct=0
22939  jcd=0
22940  880 jct=jct+1
22941  mfound=0
22942  i=mint(84)
22943  890 i=i+1
22944  IF (i.EQ.n+1) THEN
22945  IF (mfound.EQ.0) jcd=jcd+1
22946  ELSEIF (mct(i,1).EQ.jct.AND.k(i,1).GE.1) THEN
22947  mct(i,1)=jct-jcd
22948  mfound=1
22949  ELSEIF (mct(i,2).EQ.jct.AND.k(i,1).GE.1) THEN
22950  mct(i,2)=jct-jcd
22951  mfound=1
22952  ENDIF
22953  IF (i.LE.n) goto 890
22954  IF (jct.LT.nct) goto 880
22955  nct=jct-jcd
22956 
22957 C...Reset hard interaction subsystems to their CM frames.
22958  IF (iboost.EQ.1) THEN
22959  DO 900 im=1,mint(31)
22960  beta=-(xmi(1,im)-xmi(2,im))/(xmi(1,im)+xmi(2,im))
22961  CALL pyrobo(imisep(im-1)+1,imisep(im),0d0,0d0,0d0,0d0,beta)
22962  900 CONTINUE
22963 C...Zero beam remnant longitudinal momenta and energies
22964  DO 910 i=mint(53)+1,n
22965  p(i,3)=0d0
22966  p(i,4)=0d0
22967  910 CONTINUE
22968  ELSE
22969  CALL pyerrm(9
22970  & ,'(PYMIHK:) Inconsistent kinematics. Too many boosts.')
22971 C...Kill event and start another.
22972  mint(51)=1
22973  RETURN
22974  ENDIF
22975 
22976  9999 RETURN
22977  END
22978 C*********************************************************************
22979 
22980 C...PYCTTR
22981 C...Adapted from PYPREP.
22982 C...Assigns LHA1 colour tags to coloured partons based on
22983 C...K(I,4) and K(I,5) colour connection record.
22984 C...KCS negative signifies that a previous tracing should be continued.
22985 C...(in case the tag to be continued is empty, the routine exits)
22986 C...Starts at I and ends at I or IEND.
22987 C...Special considerations for systems with junctions.
22988 C...Special: if IEND=-1, means trace this parton to its color partner,
22989 C... then exit. If no partner found, exit with 0.
22990 
22991  SUBROUTINE pycttr(I,KCS,IEND)
22992 C...Double precision and integer declarations.
22993  IMPLICIT DOUBLE PRECISION(a-h, o-z)
22994  INTEGER pyk,pychge,pycomp
22995 C...Commonblocks.
22996  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
22997  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
22998  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
22999  common/pyint1/mint(400),vint(400)
23000 C...The common block of colour tags.
23001  common/pyctag/nct,mct(4000,2)
23002  SAVE /pyjets/,/pydat1/,/pydat2/,/pyint1/,/pyctag/
23003  DATA nerrpr/0/
23004  SAVE nerrpr
23005 
23006 C...Skip if parton not existing or does not have KCS
23007  IF (k(i,1).LE.0) goto 120
23008  kc=pycomp(k(i,2))
23009  IF (kc.EQ.0) goto 120
23010  kq=kchg(kc,2)
23011  IF (kq.EQ.0) goto 120
23012  IF (iabs(kq).EQ.1.AND.kq*(9-2*abs(kcs)).NE.isign(1,k(i,2)))
23013  & goto 120
23014 
23015  IF (kcs.GT.0) THEN
23016  nct=nct+1
23017 C...Set colour tag of first parton.
23018  mct(i,kcs-3)=nct
23019  ncs=nct
23020  ELSE
23021  kcs=-kcs
23022  ncs=mct(i,kcs-3)
23023  IF (ncs.EQ.0) goto 120
23024  ENDIF
23025 
23026  ia=i
23027  nstp=0
23028  100 nstp=nstp+1
23029  IF(nstp.GT.4*n) THEN
23030  CALL pyerrm(14,'(PYCTTR:) caught in infinite loop')
23031  goto 120
23032  ENDIF
23033 
23034 C...Finished if reached final-state triplet.
23035  IF(k(ia,1).EQ.3) THEN
23036  IF(nstp.GE.2.AND.kchg(pycomp(k(ia,2)),2).NE.2) goto 120
23037  ENDIF
23038 
23039 C...Also finished if reached junction.
23040  IF(k(ia,1).EQ.42) THEN
23041  goto 120
23042  ENDIF
23043 
23044 C...GOTO next parton in colour space.
23045  110 ib=ia
23046 C...If IB's KCS daughter not traced and exists, goto KCS daughter.
23047  IF(mod(k(ib,kcs)/mstu(5)**2,2).EQ.0.AND.mod(k(ib,kcs),mstu(5))
23048  & .NE.0) THEN
23049  ia=mod(k(ib,kcs),mstu(5))
23050  k(ib,kcs)=k(ib,kcs)+mstu(5)**2
23051  mrev=0
23052  ELSE
23053 C...If KCS mother traced or KCS mother nonexistent, switch colour.
23054  IF(k(ib,kcs).GE.2*mstu(5)**2.OR.mod(k(ib,kcs)/mstu(5),
23055  & mstu(5)).EQ.0) THEN
23056  kcs=9-kcs
23057  nct=nct+1
23058  ncs=nct
23059 C...Assign new colour tag on other side of old parton.
23060  mct(ib,kcs-3)=nct
23061  ENDIF
23062 C...Goto (new) KCS mother, set mother traced tag
23063  ia=mod(k(ib,kcs)/mstu(5),mstu(5))
23064  k(ib,kcs)=k(ib,kcs)+2*mstu(5)**2
23065  mrev=1
23066  ENDIF
23067  IF(ia.LE.0.OR.ia.GT.n) THEN
23068  IF (iend.EQ.-1) THEN
23069  iend=0
23070  goto 120
23071  ENDIF
23072  CALL pyerrm(12,'(PYCTTR:) colour tag tracing failed')
23073  IF(nerrpr.LT.5) THEN
23074  write(*,*) 'began at ',i
23075  write(*,*) 'ended going from', ib, ' to', ia, ' KCS=',kcs,
23076  & ' NCS=',ncs,' MREV=',mrev
23077  CALL pylist(4)
23078  nerrpr=nerrpr+1
23079  ENDIF
23080  mint(51)=1
23081  RETURN
23082  ENDIF
23083  IF(mod(k(ia,4)/mstu(5),mstu(5)).EQ.ib.OR.mod(k(ia,5)/mstu(5),
23084  & mstu(5)).EQ.ib) THEN
23085  IF(mrev.EQ.1) kcs=9-kcs
23086  IF(mod(k(ia,kcs)/mstu(5),mstu(5)).NE.ib) kcs=9-kcs
23087 C...Set KSC mother traced tag for IA
23088  k(ia,kcs)=k(ia,kcs)+2*mstu(5)**2
23089  ELSE
23090  IF(mrev.EQ.0) kcs=9-kcs
23091  IF(mod(k(ia,kcs),mstu(5)).NE.ib) kcs=9-kcs
23092 C...Set KCS daughter traced tag for IA
23093  k(ia,kcs)=k(ia,kcs)+mstu(5)**2
23094  ENDIF
23095 C...Assign new colour tag
23096  mct(ia,kcs-3)=ncs
23097 C...Finish if IEND=-1 and found final-state color partner
23098  IF (iend.EQ.-1.AND.k(ia,1).LT.10) THEN
23099  iend=ia
23100  goto 120
23101  ENDIF
23102  IF (ia.NE.i.AND.ia.NE.iend) goto 100
23103 
23104  120 RETURN
23105  END
23106 
23107 *********************************************************************
23108 
23109 C...PYMIHG
23110 C...Collapse JCP1 and connecting tags to JCG1.
23111 C...Collapse JCP2 and connecting tags to JCG2.
23112 
23113  SUBROUTINE pymihg(JCP1,JCG1,JCP2,JCG2)
23114 C...Double precision and integer declarations.
23115  IMPLICIT DOUBLE PRECISION(a-h, o-z)
23116  IMPLICIT INTEGER(i-n)
23117  INTEGER pyk,pychge,pycomp
23118 C...The event record
23119  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
23120 C...Parameters
23121  common/pyint1/mint(400),vint(400)
23122  SAVE /pyjets/,/pyint1/
23123 C...Local variables
23124  COMMON /pycbls/mco(4000,2),ncc,jcco(4000,2),jccn(4000,2),maccpt
23125  COMMON /pyctag/nct,mct(4000,2)
23126  SAVE /pycbls/,/pyctag/
23127 
23128 C...Break up JCP1<->JCP2 tag and create JCP1<->JCG1 and JCP2<->JCG2 tags
23129 C...in temporary tag collapse array JCCN. Only break up one connection.
23130  maccpt=1
23131  mclps=0
23132  DO 100 icc=1,ncc
23133  jccn(icc,1)=jcco(icc,1)
23134  jccn(icc,2)=jcco(icc,2)
23135 C...If there was a mother, it was previously connected to JCP1.
23136 C...Should be changed to JCP2.
23137  IF (mclps.EQ.0) THEN
23138  IF (jccn(icc,1).EQ.max(jcp1,jcp2).AND.jccn(icc,2).EQ.min(jcp1
23139  & ,jcp2)) THEN
23140  jccn(icc,1)=max(jcg2,jcp2)
23141  jccn(icc,2)=min(jcg2,jcp2)
23142  mclps=1
23143  ENDIF
23144  ENDIF
23145  100 CONTINUE
23146 C...Also collapse colours on JCP1 side of JCG1
23147  IF (jcp1.NE.0) THEN
23148  jccn(ncc+1,1)=max(jcp1,jcg1)
23149  jccn(ncc+1,2)=min(jcp1,jcg1)
23150  ELSE
23151  jccn(ncc+1,1)=max(jcp2,jcg2)
23152  jccn(ncc+1,2)=min(jcp2,jcg2)
23153  ENDIF
23154 
23155 C...Initialize event record colour tag array MCT array to MCO.
23156  DO 110 i=mint(84)+1,n
23157  mct(i,1)=mco(i,1)
23158  mct(i,2)=mco(i,2)
23159  110 CONTINUE
23160 
23161 C...Collapse tags:
23162 C...IS = 1 : All tags connecting to JCG1 on JCG1 side -> JCG1
23163 C...IS = 2 : All tags connecting to JCG2 on JCG2 side -> JCG2
23164 C...IS = 3 : All tags connecting to JCG1 on JCP1 side -> JCG1
23165 C...IS = 4 : All tags connecting to JCG2 on JCP2 side -> JCG2
23166  DO 160 is=1,4
23167 C...Skip if junction.
23168  IF ((is.EQ.4.AND.jcp2.EQ.0).OR.(is.EQ.3).AND.jcp1.EQ.0) goto 160
23169 C...Define starting point in tag space.
23170 C...JCA = previous tag
23171 C...JCO = present tag
23172 C...JCN = new tag
23173  IF (mod(is,2).EQ.1) THEN
23174  jco=jcp1
23175  jcn=jcg1
23176  jcall=jcg1
23177  ELSEIF (mod(is,2).EQ.0) THEN
23178  jco=jcp2
23179  jcn=jcg2
23180  jcall=jcg2
23181  ENDIF
23182  itrace=0
23183  120 itrace=itrace+1
23184  IF (itrace.GT.1000) THEN
23185 C...NB: Proper error message should be defined here.
23186  CALL pyerrm(14
23187  & ,'(PYMIHG:) Inf loop when collapsing colours.')
23188  mint(57)=mint(57)+1
23189  mint(51)=1
23190  RETURN
23191  ENDIF
23192 C...Collapse all JCN tags to JCALL
23193  DO 130 i=mint(84)+1,n
23194  IF (mco(i,1).EQ.jcn) mct(i,1)=jcall
23195  IF (mco(i,2).EQ.jcn) mct(i,2)=jcall
23196  130 CONTINUE
23197 C...IS = 1,2: first step forward. IS = 3,4: first step backward.
23198  IF (is.GT.2.AND.(jcn.EQ.jcall)) THEN
23199  jca=jcn
23200  jcn=jco
23201  ELSE
23202  jca=jco
23203  jco=jcn
23204  ENDIF
23205 C...If possible, step from JCO to new tag JCN not equal to JCA.
23206  DO 140 icc=1,ncc+1
23207  IF (jccn(icc,1).EQ.jco.AND.jccn(icc,2).NE.jca) jcn=
23208  & jccn(icc,2)
23209  IF (jccn(icc,2).EQ.jco.AND.jccn(icc,1).NE.jca) jcn=
23210  & jccn(icc,1)
23211  140 CONTINUE
23212 C...Iterate if new colour was arrived at, but don't go in circles.
23213  IF (jcn.NE.jco.AND.jcn.NE.jcall) goto 120
23214 C...Change all JCN tags in MCO to JCALL in MCT.
23215  DO 150 i=mint(84)+1,n
23216  IF (mco(i,1).EQ.jcn) mct(i,1)=jcall
23217  IF (mco(i,2).EQ.jcn) mct(i,2)=jcall
23218 C...If gluon and colour tag = anticolour tag (and not = 0) try again.
23219  IF (k(i,2).EQ.21.AND.mct(i,1).EQ.mct(i,2).AND.mct(i,1)
23220  & .NE.0) maccpt=0
23221  150 CONTINUE
23222  160 CONTINUE
23223 
23224  DO 200 jcl=nct,1,-1
23225  jca=0
23226  jcn=jcl
23227  170 jco=jcn
23228  DO 180 icc=1,ncc+1
23229  IF (jccn(icc,1).EQ.jco.AND.jccn(icc,2).NE.jca) jcn
23230  & =jccn(icc,2)
23231  IF (jccn(icc,2).EQ.jco.AND.jccn(icc,1).NE.jca) jcn
23232  & =jccn(icc,1)
23233  180 CONTINUE
23234 C...Overpaint all JCN with JCL
23235  IF (jcn.NE.jco.AND.jcn.NE.jcl) THEN
23236  DO 190 i=mint(84)+1,n
23237  IF (mct(i,1).EQ.jcn) mct(i,1)=jcl
23238  IF (mct(i,2).EQ.jcn) mct(i,2)=jcl
23239 C...If gluon and colour tag = anticolour tag (and not = 0) try again.
23240  IF (k(i,2).EQ.21.AND.mct(i,1).EQ.mct(i,2).AND.mct(i,1)
23241  & .NE.0) maccpt=0
23242  190 CONTINUE
23243  jca=jco
23244  goto 170
23245  ENDIF
23246  200 CONTINUE
23247 
23248  RETURN
23249  END
23250 
23251 C*********************************************************************
23252 
23253 C...PYMIRM
23254 C...Picks primordial kT and shares longitudinal momentum among
23255 C...beam remnants.
23256 
23257  SUBROUTINE pymirm
23258 
23259 C...Double precision and integer declarations.
23260  IMPLICIT DOUBLE PRECISION(a-h, o-z)
23261  IMPLICIT INTEGER(i-n)
23262  INTEGER pyk,pychge,pycomp
23263 C...The event record
23264  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
23265 C...Parameters
23266  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
23267  common/pypars/mstp(200),parp(200),msti(200),pari(200)
23268  common/pyint1/mint(400),vint(400)
23269 C...The common block of colour tags.
23270  common/pyctag/nct,mct(4000,2)
23271 C...The common block of dangling ends
23272  common/pyintm/kfival(2,3),nmi(2),imi(2,800,2),nvc(2,-6:6),
23273  & xassoc(2,-6:6,240),xpsvc(-6:6,-1:240),pvctot(2,-1:1),
23274  & xmi(2,240),pt2mi(240),imisep(0:240)
23275  SAVE /pyjets/,/pydat1/,/pypars/,/pyint1/,/pyintm/,/pyctag/
23276 C...Local variables
23277  dimension w(0:2,0:2),vb(3),nnxt(2),ivalq(2),icomq(2)
23278 C...W(I,J)| J=0 | 1 | 2 |
23279 C... I=0 | Wrem**2 | W+ | W- |
23280 C... 1 | W1**2 | W1+ | W1- |
23281 C... 2 | W2**2 | W2+ | W2- |
23282 C...4-product
23283  four(i,j)=p(i,4)*p(j,4)-p(i,1)*p(j,1)-p(i,2)*p(j,2)-p(i,3)*p(j,3)
23284 C...Tentative parametrization of <kT> as a function of Q.
23285  sigpt(q)=max(parj(21),2.1d0*q/(7d0+q))
23286 C SIGPT(Q)=MAX(0.36D0,4D0*SQRT(Q)/(10D0+SQRT(Q))
23287 C SIGPT(Q)=MAX(PARJ(21),3D0*SQRT(Q)/(5D0+SQRT(Q))
23288  getpt(q,sigma)=min(sigma*sqrt(-log(pyr(0))),parp(93))
23289 C...Lambda kinematic function.
23290  flam(a,b,c)=a**2+b**2+c**2-2d0*(a*b+b*c+c*a)
23291 
23292 C...Beginning and end of beam remnant partons
23293  nout=mint(53)
23294  isub=mint(1)
23295 
23296 C...Loopback point if kinematic choices gives impossible configuration.
23297  ntry=0
23298  100 ntry=ntry+1
23299 
23300 C...Assign kT values on each side separately.
23301  DO 180 js=1,2
23302 
23303 C...First zero all kT on this side. Skip if no kT to generate.
23304  DO 110 im=1,nmi(js)
23305  p(imi(js,im,1),1)=0d0
23306  p(imi(js,im,1),2)=0d0
23307  110 CONTINUE
23308  IF(mstp(91).LE.0) goto 180
23309 
23310 C...Now assign kT to each (non-collapsed) parton in IMI.
23311  DO 170 im=1,nmi(js)
23312  i=imi(js,im,1)
23313 C...Select kT according to truncated gaussian or 1/kt6 tails.
23314 C...For first interaction, either use rms width = PARP(91) or fitted.
23315  IF (im.EQ.1) THEN
23316  sigma=parp(91)
23317  IF (mstp(91).GE.11.AND.mstp(91).LE.20) THEN
23318  q=sqrt(pt2mi(im))
23319  sigma=sigpt(q)
23320  ENDIF
23321  ELSE
23322 C...For subsequent interactions and BR partons use fragmentation width.
23323  sigma=parj(21)
23324  ENDIF
23325  phi=paru(2)*pyr(0)
23326  pt=0d0
23327  IF(ntry.LE.100) THEN
23328  111 IF (mstp(91).EQ.1.OR.mstp(91).EQ.11) THEN
23329  pt=getpt(q,sigma)
23330  ptx=pt*cos(phi)
23331  pty=pt*sin(phi)
23332  ELSEIF (mstp(91).EQ.2) THEN
23333  CALL pyerrm(1,'(PYMIRM:) Sorry, MSTP(91)=2 not '//
23334  & 'available, using MSTP(91)=1.')
23335  CALL pygive('MSTP(91)=1')
23336  goto 111
23337  ELSEIF(mstp(91).EQ.3.OR.mstp(91).EQ.13) THEN
23338 C...Use distribution with kt**6 tails, rms width = PARP(91).
23339  eps=sqrt(3d0/2d0)*sigma
23340 C...Generate PTX and PTY separately, each propto 1/KT**6
23341  DO 119 ixy=1,2
23342 C...Decide which interval to try
23343  112 p12=1d0/(1d0+27d0/40d0*sigma**6/eps**6)
23344  IF (pyr(0).LT.p12) THEN
23345 C...Use flat approx with accept/reject up to EPS.
23346  pt=pyr(0)*eps
23347  wt=(3d0/2d0*sigma**2/(pt**2+3d0/2d0*sigma**2))**3
23348  IF (pyr(0).GT.wt) goto 112
23349  ELSE
23350 C...Above EPS, use 1/kt**6 approx with accept/reject.
23351  pt=eps/(pyr(0)**(1d0/5d0))
23352  wt=pt**6/(pt**2+3d0/2d0*sigma**2)**3
23353  IF (pyr(0).GT.wt) goto 112
23354  ENDIF
23355  msign=1
23356  IF (pyr(0).GT.0.5d0) msign=-1
23357  IF (ixy.EQ.1) ptx=msign*pt
23358  IF (ixy.EQ.2) pty=msign*pt
23359  119 CONTINUE
23360  ELSEIF (mstp(91).EQ.4.OR.mstp(91).EQ.14) THEN
23361  ptx=sigma*(sqrt(6d0)*pyr(0)-sqrt(3d0/2d0))
23362  pty=sigma*(sqrt(6d0)*pyr(0)-sqrt(3d0/2d0))
23363  ENDIF
23364 C...Adjust final PT. Impose upper cutoff, or zero for soft evts.
23365  pt=sqrt(ptx**2+pty**2)
23366  wt=1d0
23367  IF (pt.GT.parp(93)) wt=sqrt(parp(93)/pt)
23368  IF(isub.EQ.95.AND.im.EQ.1) wt=0d0
23369  ptx=ptx*wt
23370  pty=pty*wt
23371  pt=sqrt(ptx**2+pty**2)
23372  ENDIF
23373 
23374  p(i,1)=p(i,1)+ptx
23375  p(i,2)=p(i,2)+pty
23376 
23377 C...Compensation kicks, with varying degree of local anticorrelations.
23378  mcorr=mstp(90)
23379  IF (mcorr.EQ.0.OR.isub.EQ.95) THEN
23380  ptcx=-ptx/(nmi(js)-1)
23381  ptcy=-pty/(nmi(js)-1)
23382  IF(isub.EQ.95) THEN
23383  ptcx=-ptx/(nmi(js)-2)
23384  ptcy=-pty/(nmi(js)-2)
23385  ENDIF
23386  DO 120 imc=1,nmi(js)
23387  IF (imc.EQ.im) goto 120
23388  IF(isub.EQ.95.AND.imc.EQ.1) goto 120
23389  p(imi(js,imc,1),1)=p(imi(js,imc,1),1)+ptcx
23390  p(imi(js,imc,1),2)=p(imi(js,imc,1),2)+ptcy
23391  120 CONTINUE
23392  ELSEIF (mcorr.GE.1) THEN
23393  DO 140 msid=4,5
23394  nnxt(msid-3)=0
23395 C...Count up # of neighbours on either side
23396  imo=i
23397  130 imo=k(imo,msid)/mstu(5)
23398  IF (imo.EQ.0) goto 140
23399  nnxt(msid-3)=nnxt(msid-3)+1
23400 C...Stop at quarks and junctions
23401  IF (mcorr.EQ.1.AND.k(imo,2).EQ.21) goto 130
23402  140 CONTINUE
23403 C...How should compensation be shared when unequal numbers on the
23404 C...two sides? 50/50 regardless? N1:N2? Assume latter for now.
23405  nsum=nnxt(1)+nnxt(2)
23406  t1=0
23407  DO 160 msid=4,5
23408 C...Total momentum to be compensated on this side
23409  IF (nnxt(msid-3).EQ.0) goto 160
23410  ptcx=-(nnxt(msid-3)*ptx)/nsum
23411  ptcy=-(nnxt(msid-3)*pty)/nsum
23412 C...RS: compensation supression factor as we go out from parton I.
23413 C...Hardcoded behaviour RS=0.5, i.e. 1/2**n falloff,
23414 C...since (for now) MSTP(90) provides enough variability.
23415  rs=0.5d0
23416  fac=(1d0-rs)/(rs*(1-rs**nnxt(msid-3)))
23417  imo=i
23418  150 ida=imo
23419  imo=k(imo,msid)/mstu(5)
23420  IF (imo.EQ.0) goto 160
23421  fac=fac*rs
23422  IF (k(imo,2).NE.88) THEN
23423  p(imo,1)=p(imo,1)+fac*ptcx
23424  p(imo,2)=p(imo,2)+fac*ptcy
23425  IF (mcorr.EQ.1.AND.k(imo,2).EQ.21) goto 150
23426 C...If we reach junction, divide out the kT that would have been
23427 C...assigned to the junction on each of its other legs.
23428  ELSE
23429  l1=mod(k(imo,4),mstu(5))
23430  l2=k(imo,5)/mstu(5)
23431  l3=mod(k(imo,5),mstu(5))
23432  p(l1,1)=p(l1,1)+0.5d0*fac*ptcx
23433  p(l1,2)=p(l1,2)+0.5d0*fac*ptcy
23434  p(l2,1)=p(l2,1)+0.5d0*fac*ptcx
23435  p(l2,2)=p(l2,2)+0.5d0*fac*ptcy
23436  p(l3,1)=p(l3,1)+0.5d0*fac*ptcx
23437  p(l3,2)=p(l3,2)+0.5d0*fac*ptcy
23438  p(ida,1)=p(ida,1)-0.5d0*fac*ptcx
23439  p(ida,2)=p(ida,2)-0.5d0*fac*ptcy
23440  ENDIF
23441 
23442  160 CONTINUE
23443  ENDIF
23444  170 CONTINUE
23445 C...End assignment of kT values to initiators and remnants.
23446  180 CONTINUE
23447 
23448 C...Check kinematics constraints for non-BR partons.
23449  DO 190 im=1,mint(31)
23450  shat=xmi(1,im)*xmi(2,im)*vint(2)
23451  pt1=sqrt(p(imi(1,im,1),1)**2+p(imi(1,im,1),2)**2)
23452  pt2=sqrt(p(imi(2,im,1),1)**2+p(imi(2,im,1),2)**2)
23453  pt1pt2=p(imi(1,im,1),1)*p(imi(2,im,1),1)
23454  & +p(imi(1,im,1),2)*p(imi(2,im,1),2)
23455  IF (shat.LT.2d0*(pt1*pt2-pt1pt2).AND.ntry.LE.100) THEN
23456  IF(ntry.GE.100) THEN
23457 C...Kill this event and start another.
23458  CALL pyerrm(1,
23459  & '(PYMIRM:) No consistent (x,kT) sets found')
23460  mint(51)=1
23461  RETURN
23462  ENDIF
23463  goto 100
23464  ENDIF
23465  190 CONTINUE
23466 
23467 C...Calculate W+ and W- available for combined remnant system.
23468  w(0,1)=vint(1)
23469  w(0,2)=vint(1)
23470  DO 200 im=1,mint(31)
23471  pt2 = (p(imi(1,im,1),1)+p(imi(2,im,1),1))**2
23472  & +(p(imi(1,im,1),2)+p(imi(2,im,1),2))**2
23473  st=xmi(1,im)*xmi(2,im)*vint(2)+pt2
23474  w(0,1)=w(0,1)-sqrt(xmi(1,im)/xmi(2,im)*st)
23475  w(0,2)=w(0,2)-sqrt(xmi(2,im)/xmi(1,im)*st)
23476  200 CONTINUE
23477 C...Also store Wrem**2 = W+ * W-
23478  w(0,0)=w(0,1)*w(0,2)
23479 
23480  IF ((w(0,0).LT.0d0.OR.w(0,1)+w(0,2).LT.0d0).AND.ntry.LE.100) THEN
23481  IF(ntry.GE.100) THEN
23482 C...Kill this event and start another.
23483  CALL pyerrm(1,
23484  & '(PYMIRM:) Negative beam remnant mass squared unavoidable')
23485  mint(51)=1
23486  RETURN
23487  ENDIF
23488  goto 100
23489  ENDIF
23490 
23491 C...Assign unscaled x values to partons/hadrons in each of the
23492 C...beam remnants and calculate unscaled W+ and W- from them.
23493  ntryx=0
23494  210 ntryx=ntryx+1
23495  DO 280 js=1,2
23496  w(js,1)=0d0
23497  w(js,2)=0d0
23498  DO 270 im=mint(31)+1,nmi(js)
23499  i=imi(js,im,1)
23500  kf=k(i,2)
23501  kfa=iabs(kf)
23502  icomp=imi(js,im,2)
23503 
23504 C...Skip collapsed gluons and junctions. Reset.
23505  IF (kfa.EQ.21.AND.k(i,1).EQ.14) goto 270
23506  IF (kfa.EQ.88) goto 270
23507  x=0d0
23508  ivalq(1)=0
23509  ivalq(2)=0
23510  icomq(1)=0
23511  icomq(2)=0
23512 
23513 C...If gluon then only beam remnant, so takes all.
23514  IF(kfa.EQ.21) THEN
23515  x=1d0
23516 C...If valence quark then use parametrized valence distribution.
23517  ELSEIF(kfa.LE.6.AND.icomp.EQ.0) THEN
23518  ivalq(1)=kf
23519 C...If companion quark then derive from companion x.
23520  ELSEIF(kfa.LE.6) THEN
23521  icomq(1)=icomp
23522 C...If valence diquark then use two parametrized valence distributions.
23523  ELSEIF(kfa.GT.1000.AND.mod(kfa/10,10).EQ.0.AND.
23524  & icomp.EQ.0) THEN
23525  ivalq(1)=isign(kfa/1000,kf)
23526  ivalq(2)=isign(mod(kfa/100,10),kf)
23527 C...If valence+sea diquark then combine valence + companion choices.
23528  ELSEIF(kfa.GT.1000.AND.mod(kfa/10,10).EQ.0.AND.
23529  & icomp.LT.mstu(5)) THEN
23530  IF(kfa/1000.EQ.iabs(k(icomp,2))) THEN
23531  ivalq(1)=isign(mod(kfa/100,10),kf)
23532  ELSE
23533  ivalq(1)=isign(kfa/1000,kf)
23534  ENDIF
23535  icomq(1)=icomp
23536 C...Extra code: workaround for diquark made out of two sea
23537 C...quarks, but where not (yet) ICOMP > MSTU(5).
23538  DO 220 im1=1,mint(31)
23539  IF(imi(js,im1,2).EQ.i.AND.imi(js,im1,1).NE.icomp) THEN
23540  icomq(2)=imi(js,im1,1)
23541  ivalq(1)=0
23542  ENDIF
23543  220 CONTINUE
23544 C...If sea diquark then sum of two derived from companion x.
23545  ELSEIF(kfa.GT.1000.AND.mod(kfa/10,10).EQ.0) THEN
23546  icomq(1)=mod(icomp,mstu(5))
23547  icomq(2)=icomp/mstu(5)
23548 C...If meson or baryon then use fragmentation function.
23549 C...Somewhat arbitrary split into old and new flavour, but OK normally.
23550  ELSE
23551  kfl3=mod(kfa/10,10)
23552  IF(mod(kfa/1000,10).EQ.0) THEN
23553  kfl1=mod(kfa/100,10)
23554  ELSE
23555  kfl1=mod(kfa,10000)-10*kfl3-1
23556  IF(mod(kfa/1000,10).EQ.mod(kfa/100,10).AND.
23557  & mod(kfa,10).EQ.2) kfl1=kfl1+2
23558  ENDIF
23559  pr=p(i,5)**2+p(i,1)**2+p(i,2)**2
23560  CALL pyzdis(kfl1,kfl3,pr,x)
23561  ENDIF
23562 
23563  DO 260 iq=1,2
23564 C...Calculation of x of valence quark: assume form (1-x)^a/sqrt(x),
23565 C...where a=3.5 for u in proton, =2 for d in proton and =0.8 for meson.
23566 C...In other baryons combine u and d from proton appropriately.
23567  IF(ivalq(iq).NE.0) THEN
23568  nval=0
23569  IF(kfival(js,1).EQ.ivalq(iq)) nval=nval+1
23570  IF(kfival(js,2).EQ.ivalq(iq)) nval=nval+1
23571  IF(kfival(js,3).EQ.ivalq(iq)) nval=nval+1
23572 C...Meson.
23573  IF(kfival(js,3).EQ.0) THEN
23574  mdu=0
23575 C...Baryon with three identical quarks: mix u and d forms.
23576  ELSEIF(nval.EQ.3) THEN
23577  mdu=int(pyr(0)+5d0/3d0)
23578 C...Baryon, one of two identical quarks: u form.
23579  ELSEIF(nval.EQ.2) THEN
23580  mdu=2
23581 C...Baryon with two identical quarks, but not the one picked: d form.
23582  ELSEIF(kfival(js,1).EQ.kfival(js,2).OR.kfival(js,2).EQ.
23583  & kfival(js,3).OR.kfival(js,1).EQ.kfival(js,3)) THEN
23584  mdu=1
23585 C...Baryon with three nonidentical quarks: mix u and d forms.
23586  ELSE
23587  mdu=int(pyr(0)+5d0/3d0)
23588  ENDIF
23589  xpow=0.8d0
23590  IF(mdu.EQ.1) xpow=3.5d0
23591  IF(mdu.EQ.2) xpow=2d0
23592  230 xx=pyr(0)**2
23593  IF((1d0-xx)**xpow.LT.pyr(0)) goto 230
23594  x=x+xx
23595  ENDIF
23596 
23597 C...Calculation of x of companion quark.
23598  IF(icomq(iq).NE.0) THEN
23599  xcomp=1d-4
23600  DO 240 im1=1,mint(31)
23601  IF(imi(js,im1,1).EQ.icomq(iq)) xcomp=xmi(js,im1)
23602  240 CONTINUE
23603  npow=max(0,min(4,mstp(87)))
23604  250 xx=xcomp*(1d0/(1d0-pyr(0)*(1d0-xcomp))-1d0)
23605  corr=((1d0-xcomp-xx)/(1d0-xcomp))**npow*
23606  & (xcomp**2+xx**2)/(xcomp+xx)**2
23607  IF(corr.LT.pyr(0)) goto 250
23608  x=x+xx
23609  ENDIF
23610  260 CONTINUE
23611 
23612 C...Optionally enchance x of composite systems (e.g. diquarks)
23613  IF (kfa.GT.100) x=parp(79)*x
23614 
23615 C...Store x. Also calculate light cone energies of each system.
23616  xmi(js,im)=x
23617  w(js,js)=w(js,js)+x
23618  w(js,3-js)=w(js,3-js)+(p(i,5)**2+p(i,1)**2+p(i,2)**2)/x
23619  270 CONTINUE
23620  w(js,js)=w(js,js)*w(0,js)
23621  w(js,3-js)=w(js,3-js)/w(0,js)
23622  w(js,0)=w(js,1)*w(js,2)
23623  280 CONTINUE
23624 
23625 C...Check W1 W2 < Wrem (can be done before rescaling, since W
23626 C...insensitive to global rescalings of the BR x values).
23627  IF (sqrt(w(1,0))+sqrt(w(2,0)).GT.sqrt(w(0,0)).AND.ntryx.LE.100)
23628  & THEN
23629  goto 210
23630  ELSEIF (ntryx.GT.100.AND.ntry.LE.100) THEN
23631  goto 100
23632  ELSEIF (ntryx.GT.100) THEN
23633  CALL pyerrm(1,'(PYMIRM:) No consistent (x,kT) sets found')
23634  mint(57)=mint(57)+1
23635  mint(51)=1
23636  RETURN
23637  ENDIF
23638 
23639 C...Compute x rescaling factors
23640  comtrm=w(0,0)+sqrt(flam(w(0,0),w(1,0),w(2,0)))
23641  r1=(comtrm+w(1,0)-w(2,0))/(2d0*w(1,1)*w(0,2))
23642  r2=(comtrm+w(2,0)-w(1,0))/(2d0*w(2,2)*w(0,1))
23643 
23644  IF (r1.LT.0.OR.r2.LT.0) THEN
23645  CALL pyerrm(19,'(PYMIRM:) negative rescaling factors !')
23646  mint(57)=mint(57)+1
23647  mint(51)=1
23648  ENDIF
23649 
23650 C...Rescale W(1,*) and W(2,*) (not really necessary, but consistent).
23651  w(1,1)=w(1,1)*r1
23652  w(1,2)=w(1,2)/r1
23653  w(2,1)=w(2,1)/r2
23654  w(2,2)=w(2,2)*r2
23655 
23656 C...Rescale BR x values.
23657  DO 290 im=mint(31)+1,max(nmi(1),nmi(2))
23658  xmi(1,im)=xmi(1,im)*r1
23659  xmi(2,im)=xmi(2,im)*r2
23660  290 CONTINUE
23661 
23662 C...Now we have a consistent set of x and kT values.
23663 C...First set up the initiators and their daughters correctly.
23664  DO 300 im=1,mint(31)
23665  i1=imi(1,im,1)
23666  i2=imi(2,im,1)
23667  st=xmi(1,im)*xmi(2,im)*vint(2)+(p(i1,1)+p(i2,1))**2+
23668  & (p(i1,2)+p(i2,2))**2
23669  pt12=p(i1,1)**2+p(i1,2)**2
23670  pt22=p(i2,1)**2+p(i2,2)**2
23671 C...p_z
23672  p(i1,3)=sqrt(flam(st,pt12,pt22)/(4d0*st))
23673  p(i2,3)=-p(i1,3)
23674 C...Energies (masses should be zero at this stage)
23675  p(i1,4)=sqrt(pt12+p(i1,3)**2)
23676  p(i2,4)=sqrt(pt22+p(i2,3)**2)
23677 
23678 C...Transverse 12 system initiator velocity:
23679  vb(1)=(p(i1,1)+p(i2,1))/sqrt(st)
23680  vb(2)=(p(i1,2)+p(i2,2))/sqrt(st)
23681 C...Boost to overall initiator system rest frame
23682  CALL pyrobo(i1,i1,0d0,0d0,-vb(1),-vb(2),0d0)
23683  CALL pyrobo(i2,i2,0d0,0d0,-vb(1),-vb(2),0d0)
23684 
23685 C...Compute phi,theta coordinates of I1 and rotate z axis.
23686  phi=pyangl(p(i1,1),p(i1,2))
23687  the=pyangl(p(i1,3),sqrt(p(i1,1)**2+p(i1,2)**2))
23688  imin=imisep(im-1)+1
23689 C...(include documentation lines if MI = 1)
23690  IF (im.EQ.1) imin=mint(83)+5
23691  imax=imisep(im)
23692 C...Rotate entire system in phi
23693  CALL pyrobo(imin,imax,0d0,-phi,0d0,0d0,0d0)
23694 C...Only rotate 12 system in theta
23695  CALL pyrobo(i1,i1,-the,0d0,0d0,0d0,0d0)
23696  CALL pyrobo(i2,i2,-the,0d0,0d0,0d0,0d0)
23697 
23698 C...Now boost entire system back to LAB
23699  vb(3)=(xmi(1,im)-xmi(2,im))/(xmi(1,im)+xmi(2,im))
23700  CALL pyrobo(imin,imax,the,phi,vb(1),vb(2),0d0)
23701  CALL pyrobo(imin,imax,0d0,0d0,0d0,0d0,vb(3))
23702 
23703  300 CONTINUE
23704 
23705 
23706 C...For the beam remnant partons/hadrons, we only need to set pz and E.
23707  DO 320 js=1,2
23708  DO 310 im=mint(31)+1,nmi(js)
23709  i=imi(js,im,1)
23710 C...Skip collapsed gluons and junctions.
23711  IF (k(i,2).EQ.21.AND.k(i,1).EQ.14) goto 310
23712  IF (kfa.EQ.88) goto 310
23713  rmt2=p(i,5)**2+p(i,1)**2+p(i,2)**2
23714  p(i,4)=0.5d0*(xmi(js,im)*w(0,js)+rmt2/(xmi(js,im)*w(0,js)))
23715  p(i,3)=0.5d0*(xmi(js,im)*w(0,js)-rmt2/(xmi(js,im)*w(0,js)))
23716  IF (js.EQ.2) p(i,3)=-p(i,3)
23717  310 CONTINUE
23718  320 CONTINUE
23719 
23720 
23721 C...Documentation lines
23722  DO 340 js=1,2
23723  in=mint(83)+js+2
23724  io=imi(js,1,1)
23725  k(in,1)=21
23726  k(in,2)=k(io,2)
23727  k(in,3)=mint(83)+js
23728  k(in,4)=0
23729  k(in,5)=0
23730  DO 330 j=1,5
23731  p(in,j)=p(io,j)
23732  v(in,j)=v(io,j)
23733  330 CONTINUE
23734  mct(in,1)=mct(io,1)
23735  mct(in,2)=mct(io,2)
23736  340 CONTINUE
23737 
23738 C...Final state colour reconnections.
23739  IF (mstp(95).NE.1.OR.mint(31).LE.1) goto 380
23740 
23741 C...Number of colour tags for which a recoupling will be tried.
23742  ntot=nct
23743 C...Number of recouplings to try
23744  mint(34)=0
23745  nrecp=0
23746  niter=0
23747  350 nrecp=mint(34)
23748  niter=niter+1
23749  iiter=0
23750  360 iiter=iiter+1
23751  IF (iiter.LE.parp(78)*ntot) THEN
23752 C...Select two colour tags at random
23753 C...NB: jj strings do not have colour tags assigned to them,
23754 C...thus they are as yet not affected by anything done here.
23755  jct=pyr(0)*nct+1
23756  kct=mod(int(jct+pyr(0)*nct),nct)+1
23757  ij1=0
23758  ij2=0
23759  ik1=0
23760  ik2=0
23761 C...Find final state partons with this (anti)colour
23762  DO 370 i=mint(84)+1,n
23763  IF (k(i,1).EQ.3) THEN
23764  IF (mct(i,1).EQ.jct) ij1=i
23765  IF (mct(i,2).EQ.jct) ij2=i
23766  IF (mct(i,1).EQ.kct) ik1=i
23767  IF (mct(i,2).EQ.kct) ik2=i
23768  ENDIF
23769  370 CONTINUE
23770 C...Only consider recouplings not involving junctions for now.
23771  IF (ij1.EQ.0.OR.ij2.EQ.0.OR.ik1.EQ.0.OR.ik2.EQ.0) goto 360
23772 
23773  rlo=2d0*four(ij1,ij2)*2d0*four(ik1,ik2)
23774  rln=2d0*four(ij1,ik2)*2d0*four(ik1,ij2)
23775  IF (rln.LT.rlo.AND.mct(ij2,1).NE.kct.AND.mct(ik2,1).NE.jct) THEN
23776  mct(ij2,2)=kct
23777  mct(ik2,2)=jct
23778 C...Count up number of reconnections
23779  mint(34)=mint(34)+1
23780  ENDIF
23781  IF (mint(34).LE.1000) THEN
23782  goto 360
23783  ELSE
23784  CALL pyerrm(4,'(PYMIRM:) caught in infinite loop')
23785  goto 380
23786  ENDIF
23787  ENDIF
23788  IF (nrecp.LT.mint(34)) goto 350
23789 
23790 C...Signal PYPREP to use /PYCTAG/ information rather than K(I,KCS).
23791  380 mint(33)=1
23792 
23793  RETURN
23794  END
23795 
23796 C*********************************************************************
23797 
23798 C...PYFSCR
23799 C...Performs colour annealing.
23800 C...MSTP(95) : CR Type
23801 C... = 1 : old cut-and-paste reconnections, handled in PYMIHK
23802 C... = 2 : Type I(no gg loops); hadron-hadron only
23803 C... = 3 : Type I(no gg loops); all beams
23804 C... = 4 : Type II(gg loops) ; hadron-hadron only
23805 C... = 5 : Type II(gg loops) ; all beams
23806 C... = 6 : Type S ; hadron-hadron only
23807 C... = 7 : Type S ; all beams
23808 C... = 8 : Type P ; hadron-hadron only
23809 C... = 9 : Type P ; all beams
23810 C...Types I and II are described in Sandhoff+Skands, in hep-ph/0604120.
23811 C...Type S is driven by starting only from free triplets, not octets.
23812 C...Type P is also driven by free triplets, but the reconnect probability
23813 C...is computed from the string density per unit rapidity, where the axis
23814 C...with respect to which the rapidity is computed is the Thrust axis of the
23815 C...event.
23816 C...A string piece remains unchanged with probability
23817 C... PKEEP = (1-PARP(78))**N
23818 C...This scaling corresponds to each string piece having to go through
23819 C...N other ones, each with probability PARP(78) for reconnection.
23820 C...For types I, II, and S, N is chosen simply as the number of multiple
23821 C...interactions, for a rough scaling with the general level of activity.
23822 C...For type P, N is chosen to be the number of string pieces in a given
23823 C...interval of rapidity (minus one, since the string doesn't reconnect
23824 C...with itself), and the reconnect probability is interpreted as the
23825 C...probability per unit rapidity.
23826 C...It also also possible to apply a dampening factor to the CR strength,
23827 C...using PARP(77), which will cause reconnections among high-pT string
23828 C...pieces to be suppressed.
23829 
23830  SUBROUTINE pyfscr(IP)
23831 C...Double precision and integer declarations.
23832  IMPLICIT DOUBLE PRECISION(a-h, o-z)
23833  INTEGER pyk,pychge,pycomp
23834 C...Commonblocks.
23835  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
23836  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
23837  common/pypars/mstp(200),parp(200),msti(200),pari(200)
23838  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
23839  common/pyint1/mint(400),vint(400)
23840 C...The common block of colour tags.
23841  common/pyctag/nct,mct(4000,2)
23842  SAVE /pyjets/,/pydat1/,/pydat2/,/pyint1/,/pyctag/,
23843  &/pypars/
23844 C...MCN: Temporary storage of new colour tags
23845  INTEGER mcn(4000,2)
23846 C...Arrays for storing color strings
23847  parameter(nbiny=100)
23848  INTEGER icr(4000),mscr(4000)
23849  INTEGER iopt(4000), nstry(nbiny)
23850  DOUBLE PRECISION rloptc(4000)
23851 
23852 C...Function to give four-product.
23853  four(i,j)=p(i,4)*p(j,4)
23854  & -p(i,1)*p(j,1)-p(i,2)*p(j,2)-p(i,3)*p(j,3)
23855 
23856 C...Check valid range of MSTP(95), local copy
23857  IF (mstp(95).LE.1.OR.mstp(95).GE.10) RETURN
23858  mstp95=mod(mstp(95),10)
23859 C...Set whether CR allowed inside resonance systems or not
23860 C...(not implemented yet)
23861 C MRESCR=1
23862 C IF (MSTP(95).GE.10) MRESCR=0
23863 
23864 C...Check whether colour tags already defined
23865  IF (mint(33).EQ.0) THEN
23866 C...Erase any existing colour tags for this event
23867  DO 100 i=1,n
23868  mct(i,1)=0
23869  mct(i,2)=0
23870  100 CONTINUE
23871 C...Create colour tags for this event
23872  DO 120 i=1,n
23873  IF (k(i,1).EQ.3) THEN
23874  DO 110 kcs=4,5
23875  kcsin=kcs
23876  IF (mct(i,kcsin-3).EQ.0) THEN
23877  CALL pycttr(i,kcsin,i)
23878  ENDIF
23879  110 CONTINUE
23880  ENDIF
23881  120 CONTINUE
23882 C...Instruct PYPREP to use colour tags
23883  mint(33)=1
23884  ENDIF
23885 
23886 C...For MSTP(95) even, only apply to hadron-hadron
23887  ka1=iabs(mint(11))
23888  ka2=iabs(mint(12))
23889  IF (mod(mstp(95),2).EQ.0.AND.(ka1.LT.100.OR.ka2.LT.100)) goto 9999
23890 
23891 C...Initialize new tag array (but do not delete old yet)
23892  lct=nct
23893  DO 130 i=max(1,ip),n
23894  mcn(i,1)=0
23895  mcn(i,2)=0
23896  130 CONTINUE
23897 
23898 C...For Paquis type, determine thrust axis (default along Z axis)
23899  tx=0d0
23900  ty=0d0
23901  tz=1d0
23902  IF (mstp95.GE.8) THEN
23903  CALL pythru(thrdum,obldum)
23904  tx = p(n+1,1)
23905  ty = p(n+1,2)
23906  tz = p(n+1,3)
23907  ENDIF
23908 
23909 C...For each final-state dipole, check whether string should be
23910 C...preserved.
23911  ncr=0
23912  ia=0
23913  ic=0
23914  rapmax=0.0
23915 
23916  ictmin=nct
23917  DO 150 ict=1,nct
23918  ia=0
23919  ic=0
23920  DO 140 i=max(1,ip),n
23921  IF (k(i,1).EQ.3.AND.mct(i,1).EQ.ict) ic=i
23922  IF (k(i,1).EQ.3.AND.mct(i,2).EQ.ict) ia=i
23923  140 CONTINUE
23924  IF (ic.NE.0.AND.ia.NE.0) THEN
23925 C...Save smallest NCT value so far
23926  ictmin = min(ictmin,ict)
23927 C...For Paquis algorithm, just store all string pieces for now
23928  IF (mstp95.GE.8) THEN
23929 C... Add coloured parton
23930  ncr=ncr+1
23931  icr(ncr)=ic
23932  mscr(ncr)=1
23933  iopt(ncr)=0
23934 C... Store rapidity (along Thrust axis) in RLOPT for the time being
23935 C... Add pion mass headroom to energy for this calculation
23936  eet = p(ic,4)*sqrt(1d0+(0.135d0/p(ic,4))**2)
23937  pzt = p(ic,1)*tx+p(ic,2)*ty+p(ic,3)*tz
23938  rloptc(ncr)=log((eet+pzt)/(eet-pzt))
23939 C... Add anti-coloured parton
23940  ncr = ncr+1
23941  icr(ncr) = ia
23942  mscr(ncr) = 2
23943  iopt(ncr) = 0
23944 C... Store rapidity (along Thrust axis) in RLOPT for the time being
23945  eet = p(ia,4)*sqrt(1d0+(0.135d0/p(ia,4))**2)
23946  pzt = p(ia,1)*tx+p(ia,2)*ty+p(ia,3)*tz
23947  rloptc(ncr)=log((eet+pzt)/(eet-pzt))
23948 C... Keep track of largest endpoint "rapidity"
23949  rapmax = max(rapmax,abs(rloptc(ncr)))
23950  rapmax = max(rapmax,abs(rloptc(ncr-1)))
23951  ELSE
23952  crmodf=1d0
23953 C... Opt: suppress breakup of high-boost string pieces (i.e., let them escape)
23954 C... (so far ignores the possibility that the whole "muck" may be moving.)
23955  IF (parp(77).GT.0d0) THEN
23956  pt2str=(p(ia,1)+p(ic,1))**2+(p(ia,2)+p(ic,2))**2
23957 C... For lepton-lepton, use actual p2/m2, otherwise approximate p2 ~ 3/2 pT2
23958  IF (ka1.LT.100.AND.ka2.LT.100) THEN
23959  p2str = pt2str + (p(ia,3)+p(ic,3))**2
23960  ELSE
23961  p2str = 3d0/2d0 * pt2str
23962  ENDIF
23963  rm2str=(p(ia,4)+p(ic,4))**2-(p(ia,3)+p(ic,3))**2-pt2str
23964  rm2str=max(rm2str,pmas(pycomp(111),1)**2)
23965 C... Estimate number of particles ~ log(M2), cut off at 1.
23966  rlogm2=max(1d0,log(rm2str))
23967  p2avg=p2str/rlogm2
23968 C... Supress reconnection probability by 1/(1+P77*P2AVG)
23969  crmodf=1d0/(1d0+parp(77)**2*p2avg)
23970  ENDIF
23971  pkeep=(1d0-parp(78)*crmodf)**mint(31)
23972  IF (pyr(0).LE.pkeep) THEN
23973  lct=lct+1
23974  mcn(ic,1)=lct
23975  mcn(ia,2)=lct
23976  ELSE
23977 C... Add coloured parton
23978  ncr=ncr+1
23979  icr(ncr)=ic
23980  mscr(ncr)=1
23981  iopt(ncr)=0
23982  rloptc(ncr)=1d19
23983 C... Add anti-coloured parton
23984  ncr=ncr+1
23985  icr(ncr)=ia
23986  mscr(ncr)=2
23987  iopt(ncr)=0
23988  rloptc(ncr)=1d19
23989  ENDIF
23990  ENDIF
23991  ENDIF
23992  150 CONTINUE
23993 
23994 C...PAQUIS TYPE
23995  IF (mstp95.GE.8) THEN
23996 C... For Paquis type, make "histogram" of string densities along thrust axis
23997  rapmin = -rapmax
23998  drap = 2*rapmax/(1d0*nbiny)
23999 C... Explicitly zero histogram bin content
24000  DO 147 ibiny=1,nbiny
24001  nstry(ibiny)=0
24002  147 CONTINUE
24003  DO 152 istr=1,ncr-1,2
24004  ic = icr(istr)
24005  ia = icr(istr+1)
24006  y1 = min(rloptc(istr),rloptc(istr+1))
24007  y2 = max(rloptc(istr),rloptc(istr+1))
24008  DO 153 ibiny=1,nbiny
24009  ybinlo = rapmin + (ibiny-1)*drap
24010 C... If bin inside string piece, add 1 in this bin
24011 C... (Strictly speaking: if it starts before midpoint and ends after midpoint)
24012  IF (y1.LE.ybinlo+0.5*drap.AND.y2.GE.ybinlo+0.5*drap)
24013  & nstry(ibiny) = nstry(ibiny) + 1
24014  153 CONTINUE
24015  152 CONTINUE
24016 C... Loop over pieces to find individual reconnect probability
24017  DO 167 is=1,ncr-1,2
24018  dnsum = 0d0
24019  dnavg = 0d0
24020 C...Beginning at Y = RAPMIN = -RAPMAX, ending at Y = RAPMAX
24021  rbinlo = (min(rloptc(is),rloptc(is+1))-rapmin)/drap + 0.5
24022  rbinhi = (max(rloptc(is),rloptc(is+1))-rapmin)/drap + 0.5
24023 C...Make sure integer bin numbers lie inside proper range
24024  ibinlo = max(1,min(nbiny,nint(rbinlo)))
24025  ibinhi = max(1,min(nbiny,nint(rbinhi)))
24026 C...Size of rapidity bins (is < DRAP if piece smaller than one bin)
24027 C...(also smaller than DRAP if a one-unit wide piece is stretched
24028 C... over 2 bins, thus making the computation more accurate)
24029  drapav = (rbinhi-rbinlo)/(ibinhi-ibinlo+1)*drap
24030 C... Decide whether to suppress reconnections in high-pT string pieces
24031  crmodf = 1d0
24032  IF (parp(77).GT.0d0) THEN
24033 C... Total string piece energy, momentum squared, and components
24034  ees = p(icr(is),4) + p(icr(is+1),4)
24035  pps2 = (p(icr(is),1)+ p(icr(is+1),1))**2
24036  & + (p(icr(is),2)+ p(icr(is+1),2))**2
24037  & + (p(icr(is),3)+ p(icr(is+1),3))**2
24038  pzts = p(icr(is),1)*tx+p(icr(is),2)*ty+p(icr(is),3)*tz
24039  & + p(icr(is+1),1)*tx+p(icr(is+1),2)*ty+p(icr(is+1),3)*tz
24040  ptts = sqrt(pps2 - pzts**2)
24041 C... Mass of string piece in units of mpi (at least 1)
24042  rmpi2 = 0.135d0
24043  rm2str = max(rmpi2,ees**2 - pps2)
24044 C... Estimate number of pions ~ log(M2) (at least 1)
24045  rnpi = log(rm2str/rmpi2)+1d0
24046  pt2avg = (ptts / rnpi)**2
24047 C... Supress reconnection probability by 1/(1+P77*P2AVG)
24048  crmodf=1d0/(1d0+parp(77)**2*pt2avg)
24049  ENDIF
24050  pkeep = 1.0
24051  DO 178 ibiny=ibinlo,ibinhi
24052 C DNSUM = DNSUM + 1D0
24053  dnovl = max(0,nstry(ibiny)-1)
24054  pkeep = pkeep * (1d0-crmodf*parp(78))**(drapav*dnovl)
24055 C DNAVG = DNAVG + MAX(1,NSTRY(IBINY))
24056  178 CONTINUE
24057 C DNAVG = DNAVG / DNSUM
24058 C... If keeping string piece, save
24059  IF (pyr(0).LE.pkeep) THEN
24060  lct = lct+1
24061  mcn(icr(is),1)=lct
24062  mcn(icr(is+1),2)=lct
24063  ENDIF
24064  167 CONTINUE
24065  ENDIF
24066 
24067 C...Skip if there is only one possibility
24068  IF (ncr.LE.2) THEN
24069  goto 9999
24070  ENDIF
24071 
24072 C...Reorder, so ordered in I (in order to correspond to old algorithm)
24073  nloop=0
24074  151 nloop=nloop+1
24075  mord=1
24076  DO 155 ic1=1,ncr-1
24077  i1=icr(ic1)
24078  i2=icr(ic1+1)
24079  IF (i1.GT.i2) THEN
24080  it=i1
24081  mst=mscr(ic1)
24082  icr(ic1)=i2
24083  mscr(ic1)=mscr(ic1+1)
24084  icr(ic1+1)=it
24085  mscr(ic1+1)=mst
24086  mord=0
24087  ENDIF
24088  155 CONTINUE
24089 C...Max do 1000 reordering loops
24090  IF (mord.EQ.0.AND.nloop.LE.1000) goto 151
24091 
24092 C...PS: 03 May 2010
24093 C...For Seattle and Paquis types, check if there is a dangling tag
24094 C...Needed for special case when entire reconnected state was one or
24095 C...more gluon loops in original topology in which case these CR
24096 C...algorithms need to be told they shouldn't look for a dangling tag.
24097  m3free=0
24098  IF (mstp95.GE.6.AND.mstp95.LE.9) THEN
24099  DO 157 ic1=1,ncr
24100  i1=icr(ic1)
24101 C...Color charge
24102  mci=kchg(pycomp(k(i1,2)),2)*isign(1,k(i1,2))
24103  IF (mci.EQ.1.AND.mcn(i1,1).EQ.0) m3free=1
24104  IF (mci.EQ.-1.AND.mcn(i1,2).EQ.0) m3free=1
24105  IF (mci.EQ.2) THEN
24106  IF (mcn(i1,1).NE.0.AND.mcn(i1,2).EQ.0) m3free=1
24107  IF (mcn(i1,2).NE.0.AND.mcn(i1,1).EQ.0) m3free=1
24108  ENDIF
24109  157 CONTINUE
24110  ENDIF
24111 
24112 C...Loop over CR partons
24113 C...(Ignore junctions for now.)
24114  nloop=0
24115  160 nloop=nloop+1
24116  rlmax=0d0
24117  icrmax=0
24118 C...Loop over coloured partons
24119  DO 230 ic1=1,ncr
24120 C...Retrieve parton Event Record index and Colour Side
24121  i=icr(ic1)
24122  msi=mscr(ic1)
24123 C...Skip already connected partons
24124  IF (mcn(i,msi).NE.0) goto 230
24125 C...Shorthand for colour charge
24126  mci=kchg(pycomp(k(i,2)),2)*isign(1,k(i,2))
24127 C...For Seattle algorithm, only start from partons with one dangling
24128 C...colour tag (unless there aren't any, cf. M3FREE above.)
24129  IF (mstp(95).GE.6.AND.mstp(95).LE.9) THEN
24130  IF (mci.EQ.2.AND.mcn(i,1).EQ.0.AND.mcn(i,2).EQ.0
24131  & .AND.m3free.EQ.1) THEN
24132  goto 230
24133  ENDIF
24134  ENDIF
24135 C...Retrieve saved optimal partner
24136  io=iopt(ic1)
24137  IF (io.NE.0) THEN
24138 C...Reject saved optimal partner if latter is now connected
24139 C...(Also reject if using model S1, since saved partner may
24140 C...now give rise to gg loop.)
24141  IF (mcn(io,3-msi).NE.0.OR.mstp(95).LE.3) THEN
24142  iopt(ic1)=0
24143  rloptc(ic1)=1d19
24144  ENDIF
24145  ENDIF
24146  rlopt=rloptc(ic1)
24147 C...Search for new optimal partner if necessary
24148  IF (iopt(ic1).EQ.0) THEN
24149  mbropt=0
24150  mggopt=0
24151  rlopt=1d19
24152 C...Loop over partons you can connect to
24153  DO 210 ic2=1,ncr
24154  j=icr(ic2)
24155  msj=mscr(ic2)
24156 C...Skip if already connected
24157  IF (mcn(j,msj).NE.0) goto 210
24158 C...Skip if this not colour-anticolour pair
24159  IF (msi.EQ.msj) goto 210
24160 C...And do not let gluons connect to themselves
24161  IF (i.EQ.j) goto 210
24162 C...Suppress direct connections between partons in same Beam Remnant
24163  mbrstr=0
24164  IF (k(i,3).LE.2.AND.k(i,3).GE.1.AND.k(i,3).EQ.k(j,3))
24165  & mbrstr=1
24166 C...Shorthand for colour charge
24167  mcj=kchg(pycomp(k(j,2)),2)*isign(1,k(j,2))
24168 C...Check for gluon loops
24169  mggstr=0
24170  IF (mcj.EQ.2.AND.mci.EQ.2) THEN
24171  IF (mcn(i,2).EQ.mcn(j,1).AND.mstp(95).LE.3.AND.
24172  & mcn(i,2).NE.0) mggstr=1
24173  ENDIF
24174 C...Save connection with smallest lambda measure
24175  rl=four(i,j)
24176 C...If best so far was a BR string and this is not, also save.
24177 C...If best so far was a gg string and this is not, also save.
24178 C...NB: this is not fool-proof. If the algorithm finds a BR or gg
24179 C...string with a small Lambda measure as the last step, this connection
24180 C...will be saved regardless of whether other possibilities existed.
24181 C...I.e., there should really be a check whether another possibility has
24182 C...already been found, but since these models are now actively in use
24183 C...and uncertainties are anyway large, the algorithm is left as it is.
24184 C...(correction --> Pythia 8 ?)
24185  IF (rl.LT.rlopt.OR.(rl.EQ.rlopt.AND.pyr(0).LE.0.5d0)
24186  & .OR.(mbropt.EQ.1.AND.mbrstr.EQ.0)
24187  & .OR.(mggopt.EQ.1.AND.mggstr.EQ.0)) THEN
24188 C...Paquis type: fix problem above
24189  mpaq = 0
24190  IF (mstp95.GE.8.AND.rlopt.LE.1d18) THEN
24191  IF (mbrstr.EQ.1.AND.mbropt.EQ.0) mpaq=1
24192  IF (mggstr.EQ.1.AND.mggopt.EQ.0) mpaq=1
24193  ENDIF
24194  IF (mpaq.EQ.0) THEN
24195  rlopt=rl
24196  rloptc(ic1)=rlopt
24197  iopt(ic1)=j
24198  mbropt=mbrstr
24199  mggopt=mggstr
24200  ENDIF
24201  ENDIF
24202  210 CONTINUE
24203  ENDIF
24204  IF (iopt(ic1).NE.0) THEN
24205 C...Save pair with largest RLOPT so far
24206  IF (rlopt.GE.rlmax) THEN
24207  icrmax=ic1
24208  rlmax=rlopt
24209  ENDIF
24210  ENDIF
24211  230 CONTINUE
24212 C...Save and iterate
24213  icmax=0
24214  IF (icrmax.GT.0) THEN
24215  lct=lct+1
24216  ilmax=icr(icrmax)
24217  jlmax=iopt(icrmax)
24218  icmax=mscr(icrmax)
24219  jcmax=3-icmax
24220  mcn(ilmax,icmax)=lct
24221  mcn(jlmax,jcmax)=lct
24222  IF (nloop.LE.2*(n-ip)) THEN
24223  goto 160
24224  ELSE
24225  CALL pyerrm(31,' PYFSCR: infinite loop in color annealing')
24226  CALL pystop(11)
24227  ENDIF
24228  ELSE
24229 C...Save and exit. First check for leftover gluon(s)
24230  DO 260 i=max(1,ip),n
24231 C...Check colour charge
24232  mci=kchg(pycomp(k(i,2)),2)*isign(1,k(i,2))
24233  IF (k(i,1).NE.3.OR.mci.NE.2) goto 260
24234  IF(mcn(i,1).EQ.0.AND.mcn(i,2).EQ.0) THEN
24235 C...Decide where to put left-over gluon (minimal insertion)
24236  icmax=0
24237  rlmax=1d19
24238 C...PS: Bug fix 30 Apr 2010: try all lines, not just reconnected ones
24239  DO 250 kct=ictmin,lct
24240  ic=0
24241  ia=0
24242  DO 240 it=max(1,ip),n
24243  IF (it.EQ.i.OR.k(it,1).NE.3) goto 240
24244  IF (mcn(it,1).EQ.kct) ic=it
24245  IF (mcn(it,2).EQ.kct) ia=it
24246  240 CONTINUE
24247 C...Skip if this color tag no longer present in event record
24248  IF (ic.EQ.0.OR.ia.EQ.0) goto 250
24249  rl=four(ic,i)*four(ia,i)
24250  IF (rl.LT.rlmax) THEN
24251  rlmax=rl
24252  icmax=ic
24253  iamax=ia
24254  ENDIF
24255  250 CONTINUE
24256  lct=lct+1
24257  mcn(i,1)=mcn(icmax,1)
24258  mcn(i,2)=lct
24259  mcn(icmax,1)=lct
24260  ENDIF
24261  260 CONTINUE
24262 C...Here we need to loop over entire event.
24263  DO 270 iz=max(1,ip),n
24264 C...Do not erase parton shower colour history
24265  IF (k(iz,1).NE.3) goto 270
24266 C...Check colour charge
24267  mci=kchg(pycomp(k(iz,2)),2)*isign(1,k(iz,2))
24268  IF (mci.EQ.0) goto 270
24269  IF (mcn(iz,1).NE.0) mct(iz,1)=mcn(iz,1)
24270  IF (mcn(iz,2).NE.0) mct(iz,2)=mcn(iz,2)
24271  270 CONTINUE
24272  ENDIF
24273 
24274  9999 RETURN
24275  END
24276 
24277 C*********************************************************************
24278 
24279 C...PYDIFF
24280 C...Handles diffractive and elastic scattering.
24281 
24282  SUBROUTINE pydiff
24283 
24284 C...Double precision and integer declarations.
24285  IMPLICIT DOUBLE PRECISION(a-h, o-z)
24286  IMPLICIT INTEGER(i-n)
24287  INTEGER pyk,pychge,pycomp
24288 C...Commonblocks.
24289  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
24290  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
24291  common/pypars/mstp(200),parp(200),msti(200),pari(200)
24292  common/pyint1/mint(400),vint(400)
24293  SAVE /pyjets/,/pydat1/,/pypars/,/pyint1/
24294 
24295 C...Reset K, P and V vectors. Store incoming particles.
24296  DO 110 jt=1,mstp(126)+10
24297  i=mint(83)+jt
24298  DO 100 j=1,5
24299  k(i,j)=0
24300  p(i,j)=0d0
24301  v(i,j)=0d0
24302  100 CONTINUE
24303  110 CONTINUE
24304  n=mint(84)
24305  mint(3)=0
24306  mint(21)=0
24307  mint(22)=0
24308  mint(23)=0
24309  mint(24)=0
24310  mint(4)=4
24311  DO 130 jt=1,2
24312  i=mint(83)+jt
24313  k(i,1)=21
24314  k(i,2)=mint(10+jt)
24315  DO 120 j=1,5
24316  p(i,j)=vint(285+5*jt+j)
24317  120 CONTINUE
24318  130 CONTINUE
24319  mint(6)=2
24320 
24321 C...Subprocess; kinematics.
24322  sqlam=(vint(2)-vint(63)-vint(64))**2-4d0*vint(63)*vint(64)
24323  pz=sqrt(sqlam)/(2d0*vint(1))
24324  DO 200 jt=1,2
24325  i=mint(83)+jt
24326  pe=(vint(2)+vint(62+jt)-vint(65-jt))/(2d0*vint(1))
24327  kfh=mint(102+jt)
24328 
24329 C...Elastically scattered particle. (Except elastic GVMD states.)
24330  IF(mint(16+jt).LE.0.AND.(mint(10+jt).NE.22.OR.
24331  & mint(106+jt).NE.3)) THEN
24332  n=n+1
24333  k(n,1)=1
24334  k(n,2)=kfh
24335  k(n,3)=i+2
24336  p(n,3)=pz*(-1)**(jt+1)
24337  p(n,4)=pe
24338  p(n,5)=sqrt(vint(62+jt))
24339 
24340 C...Decay rho from elastic scattering of gamma with sin**2(theta)
24341 C...distribution of decay products (in rho rest frame).
24342  IF(kfh.EQ.113.AND.mint(10+jt).EQ.22.AND.mstp(102).EQ.1) THEN
24343  nsav=n
24344  dbetaz=p(n,3)/sqrt(p(n,3)**2+p(n,5)**2)
24345  p(n,3)=0d0
24346  p(n,4)=p(n,5)
24347  CALL pydecy(nsav)
24348  IF(n.EQ.nsav+2.AND.iabs(k(nsav+1,2)).EQ.211) THEN
24349  phi=pyangl(p(nsav+1,1),p(nsav+1,2))
24350  CALL pyrobo(nsav+1,nsav+2,0d0,-phi,0d0,0d0,0d0)
24351  the=pyangl(p(nsav+1,3),p(nsav+1,1))
24352  CALL pyrobo(nsav+1,nsav+2,-the,0d0,0d0,0d0,0d0)
24353  140 cthe=2d0*pyr(0)-1d0
24354  IF(1d0-cthe**2.LT.pyr(0)) goto 140
24355  CALL pyrobo(nsav+1,nsav+2,acos(cthe),phi,0d0,0d0,0d0)
24356  ENDIF
24357  CALL pyrobo(nsav,nsav+2,0d0,0d0,0d0,0d0,dbetaz)
24358  ENDIF
24359 
24360 C...Diffracted particle: low-mass system to two particles.
24361  ELSEIF(vint(62+jt).LT.(vint(66+jt)+parp(103))**2) THEN
24362  n=n+2
24363  k(n-1,1)=1
24364  k(n,1)=1
24365  k(n-1,3)=i+2
24366  k(n,3)=i+2
24367  pmmas=sqrt(vint(62+jt))
24368  ntry=0
24369  150 ntry=ntry+1
24370  IF(ntry.LT.20) THEN
24371  mint(105)=mint(102+jt)
24372  mint(109)=mint(106+jt)
24373  CALL pyspli(kfh,21,kfl1,kfl2)
24374  CALL pykfdi(kfl1,0,kfl3,kf1)
24375  IF(kf1.EQ.0) goto 150
24376  CALL pykfdi(kfl2,-kfl3,kfldum,kf2)
24377  IF(kf2.EQ.0) goto 150
24378  ELSE
24379  kf1=kfh
24380  kf2=111
24381  ENDIF
24382  pm1=pymass(kf1)
24383  pm2=pymass(kf2)
24384  IF(pm1+pm2+parj(64).GT.pmmas) goto 150
24385  k(n-1,2)=kf1
24386  k(n,2)=kf2
24387  p(n-1,5)=pm1
24388  p(n,5)=pm2
24389  pzp=sqrt(max(0d0,(pmmas**2-pm1**2-pm2**2)**2-
24390  & 4d0*pm1**2*pm2**2))/(2d0*pmmas)
24391  p(n-1,3)=pzp
24392  p(n,3)=-pzp
24393  p(n-1,4)=sqrt(pm1**2+pzp**2)
24394  p(n,4)=sqrt(pm2**2+pzp**2)
24395  CALL pyrobo(n-1,n,acos(2d0*pyr(0)-1d0),paru(2)*pyr(0),
24396  & 0d0,0d0,0d0)
24397  dbetaz=pz*(-1)**(jt+1)/sqrt(pz**2+pmmas**2)
24398  CALL pyrobo(n-1,n,0d0,0d0,0d0,0d0,dbetaz)
24399 
24400 C...Diffracted particle: valence quark kicked out.
24401  ELSEIF(mstp(101).EQ.1.OR.(mstp(101).EQ.3.AND.pyr(0).LT.
24402  & parp(101))) THEN
24403  n=n+2
24404  k(n-1,1)=2
24405  k(n,1)=1
24406  k(n-1,3)=i+2
24407  k(n,3)=i+2
24408  mint(105)=mint(102+jt)
24409  mint(109)=mint(106+jt)
24410  CALL pyspli(kfh,21,k(n,2),k(n-1,2))
24411  p(n-1,5)=pymass(k(n-1,2))
24412  p(n,5)=pymass(k(n,2))
24413  sqlam=(vint(62+jt)-p(n-1,5)**2-p(n,5)**2)**2-
24414  & 4d0*p(n-1,5)**2*p(n,5)**2
24415  p(n-1,3)=(pe*sqrt(sqlam)+pz*(vint(62+jt)+p(n-1,5)**2-
24416  & p(n,5)**2))/(2d0*vint(62+jt))*(-1)**(jt+1)
24417  p(n-1,4)=sqrt(p(n-1,3)**2+p(n-1,5)**2)
24418  p(n,3)=pz*(-1)**(jt+1)-p(n-1,3)
24419  p(n,4)=sqrt(p(n,3)**2+p(n,5)**2)
24420 
24421 C...Diffracted particle: gluon kicked out.
24422  ELSE
24423  n=n+3
24424  k(n-2,1)=2
24425  k(n-1,1)=2
24426  k(n,1)=1
24427  k(n-2,3)=i+2
24428  k(n-1,3)=i+2
24429  k(n,3)=i+2
24430  mint(105)=mint(102+jt)
24431  mint(109)=mint(106+jt)
24432  CALL pyspli(kfh,21,k(n,2),k(n-2,2))
24433  k(n-1,2)=21
24434  p(n-2,5)=pymass(k(n-2,2))
24435  p(n-1,5)=0d0
24436  p(n,5)=pymass(k(n,2))
24437 C...Energy distribution for particle into two jets.
24438  160 imb=1
24439  IF(mod(kfh/1000,10).NE.0) imb=2
24440  chik=parp(92+2*imb)
24441  IF(mstp(92).LE.1) THEN
24442  IF(imb.EQ.1) chi=pyr(0)
24443  IF(imb.EQ.2) chi=1d0-sqrt(pyr(0))
24444  ELSEIF(mstp(92).EQ.2) THEN
24445  chi=1d0-pyr(0)**(1d0/(1d0+chik))
24446  ELSEIF(mstp(92).EQ.3) THEN
24447  cut=2d0*0.3d0/vint(1)
24448  170 chi=pyr(0)**2
24449  IF((chi**2/(chi**2+cut**2))**0.25d0*(1d0-chi)**chik.LT.
24450  & pyr(0)) goto 170
24451  ELSEIF(mstp(92).EQ.4) THEN
24452  cut=2d0*0.3d0/vint(1)
24453  cutr=(1d0+sqrt(1d0+cut**2))/cut
24454  180 chir=cut*cutr**pyr(0)
24455  chi=(chir**2-cut**2)/(2d0*chir)
24456  IF((1d0-chi)**chik.LT.pyr(0)) goto 180
24457  ELSE
24458  cut=2d0*0.3d0/vint(1)
24459  cuta=cut**(1d0-parp(98))
24460  cutb=(1d0+cut)**(1d0-parp(98))
24461  190 chi=(cuta+pyr(0)*(cutb-cuta))**(1d0/(1d0-parp(98)))
24462  IF(((chi+cut)**2/(2d0*(chi**2+cut**2)))**
24463  & (0.5d0*parp(98))*(1d0-chi)**chik.LT.pyr(0)) goto 190
24464  ENDIF
24465  IF(chi.LT.p(n,5)**2/vint(62+jt).OR.chi.GT.1d0-p(n-2,5)**2/
24466  & vint(62+jt)) goto 160
24467  sqm=p(n-2,5)**2/(1d0-chi)+p(n,5)**2/chi
24468  pzi=(pe*(vint(62+jt)-sqm)+pz*(vint(62+jt)+sqm))/
24469  & (2d0*vint(62+jt))
24470  pei=sqrt(pzi**2+sqm)
24471  pqqp=(1d0-chi)*(pei+pzi)
24472  p(n-2,3)=0.5d0*(pqqp-p(n-2,5)**2/pqqp)*(-1)**(jt+1)
24473  p(n-2,4)=sqrt(p(n-2,3)**2+p(n-2,5)**2)
24474  p(n-1,4)=0.5d0*(vint(62+jt)-sqm)/(pei+pzi)
24475  p(n-1,3)=p(n-1,4)*(-1)**jt
24476  p(n,3)=pzi*(-1)**(jt+1)-p(n-2,3)
24477  p(n,4)=sqrt(p(n,3)**2+p(n,5)**2)
24478  ENDIF
24479 
24480 C...Documentation lines.
24481  k(i+2,1)=21
24482  IF(mint(16+jt).EQ.0) k(i+2,2)=kfh
24483  IF(mint(16+jt).NE.0.OR.(mint(10+jt).EQ.22.AND.
24484  & mint(106+jt).EQ.3)) k(i+2,2)=isign(9900000,kfh)+10*(kfh/10)
24485  k(i+2,3)=i
24486  p(i+2,3)=pz*(-1)**(jt+1)
24487  p(i+2,4)=pe
24488  p(i+2,5)=sqrt(vint(62+jt))
24489  200 CONTINUE
24490 
24491 C...Rotate outgoing partons/particles using cos(theta).
24492  IF(vint(23).LT.0.9d0) THEN
24493  CALL pyrobo(mint(83)+3,n,acos(vint(23)),vint(24),0d0,0d0,0d0)
24494  ELSE
24495  CALL pyrobo(mint(83)+3,n,asin(vint(59)),vint(24),0d0,0d0,0d0)
24496  ENDIF
24497 
24498  RETURN
24499  END
24500 
24501 C*********************************************************************
24502 
24503 C...PYDISG
24504 C...Set up a DIS process as gamma* + f -> f, with beam remnant
24505 C...and showering added consecutively. Photon flux by the PYGAGA
24506 C...routine (if at all).
24507 
24508  SUBROUTINE pydisg
24509 
24510 C...Double precision and integer declarations.
24511  IMPLICIT DOUBLE PRECISION(a-h, o-z)
24512  IMPLICIT INTEGER(i-n)
24513  INTEGER pyk,pychge,pycomp
24514 C...Parameter statement to help give large particle numbers.
24515  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
24516  &kexcit=4000000,kdimen=5000000)
24517 C...Commonblocks.
24518  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
24519  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
24520  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
24521  common/pysubs/msel,mselpd,msub(500),kfin(2,-40:40),ckin(200)
24522  common/pypars/mstp(200),parp(200),msti(200),pari(200)
24523  common/pyint1/mint(400),vint(400)
24524  SAVE /pyjets/,/pydat1/,/pydat2/,/pysubs/,/pypars/,/pyint1/
24525 C...Local arrays.
24526  dimension pms(4)
24527 
24528 C...Choice of subprocess, number of documentation lines
24529  idoc=7
24530  mint(3)=idoc-6
24531  mint(4)=idoc
24532  ipu1=mint(84)+1
24533  ipu2=mint(84)+2
24534  ipu3=mint(84)+3
24535  iside=1
24536  IF(mint(107).EQ.4) iside=2
24537 
24538 C...Reset K, P and V vectors. Store incoming particles
24539  DO 110 jt=1,mstp(126)+20
24540  i=mint(83)+jt
24541  DO 100 j=1,5
24542  k(i,j)=0
24543  p(i,j)=0d0
24544  v(i,j)=0d0
24545  100 CONTINUE
24546  110 CONTINUE
24547  DO 130 jt=1,2
24548  i=mint(83)+jt
24549  k(i,1)=21
24550  k(i,2)=mint(10+jt)
24551  DO 120 j=1,5
24552  p(i,j)=vint(285+5*jt+j)
24553  120 CONTINUE
24554  130 CONTINUE
24555  mint(6)=2
24556 
24557 C...Store incoming partons in hadronic CM-frame
24558  DO 140 jt=1,2
24559  i=mint(84)+jt
24560  k(i,1)=14
24561  k(i,2)=mint(14+jt)
24562  k(i,3)=mint(83)+2+jt
24563  140 CONTINUE
24564  IF(mint(15).EQ.22) THEN
24565  p(mint(84)+1,3)=0.5d0*(vint(1)+vint(307)/vint(1))
24566  p(mint(84)+1,4)=0.5d0*(vint(1)-vint(307)/vint(1))
24567  p(mint(84)+1,5)=-sqrt(vint(307))
24568  p(mint(84)+2,3)=-0.5d0*vint(307)/vint(1)
24569  p(mint(84)+2,4)=0.5d0*vint(307)/vint(1)
24570  kfres=mint(16)
24571  iside=2
24572  ELSE
24573  p(mint(84)+1,3)=0.5d0*vint(308)/vint(1)
24574  p(mint(84)+1,4)=0.5d0*vint(308)/vint(1)
24575  p(mint(84)+2,3)=-0.5d0*(vint(1)+vint(308)/vint(1))
24576  p(mint(84)+2,4)=0.5d0*(vint(1)-vint(308)/vint(1))
24577  p(mint(84)+1,5)=-sqrt(vint(308))
24578  kfres=mint(15)
24579  iside=1
24580  ENDIF
24581  sidesg=(-1d0)**(iside-1)
24582 
24583 C...Copy incoming partons to documentation lines.
24584  DO 170 jt=1,2
24585  i1=mint(83)+4+jt
24586  i2=mint(84)+jt
24587  k(i1,1)=21
24588  k(i1,2)=k(i2,2)
24589  k(i1,3)=i1-2
24590  DO 150 j=1,5
24591  p(i1,j)=p(i2,j)
24592  150 CONTINUE
24593 
24594 C...Second copy for partons before ISR shower, since no such.
24595  i1=mint(83)+2+jt
24596  k(i1,1)=21
24597  k(i1,2)=k(i2,2)
24598  k(i1,3)=i1-2
24599  DO 160 j=1,5
24600  p(i1,j)=p(i2,j)
24601  160 CONTINUE
24602  170 CONTINUE
24603 
24604 C...Define initial partons.
24605  ntry=0
24606  180 ntry=ntry+1
24607  IF(ntry.GT.100) THEN
24608  mint(51)=1
24609  RETURN
24610  ENDIF
24611 
24612 C...Scattered quark in hadronic CM frame.
24613  i=mint(83)+7
24614  k(ipu3,1)=3
24615  k(ipu3,2)=kfres
24616  k(ipu3,3)=i
24617  p(ipu3,5)=pymass(kfres)
24618  p(ipu3,3)=p(ipu1,3)+p(ipu2,3)
24619  p(ipu3,4)=p(ipu1,4)+p(ipu2,4)
24620  p(ipu3,5)=0d0
24621  k(i,1)=21
24622  k(i,2)=kfres
24623  k(i,3)=mint(83)+4+iside
24624  p(i,3)=p(ipu3,3)
24625  p(i,4)=p(ipu3,4)
24626  p(i,5)=p(ipu3,5)
24627  n=ipu3
24628  mint(21)=kfres
24629  mint(22)=0
24630 
24631 C...No primordial kT, or chosen according to truncated Gaussian or
24632 C...exponential, or (for photon) predetermined or power law.
24633  190 IF(mint(40+iside).EQ.2.AND.mint(10+iside).NE.22) THEN
24634  IF(mstp(91).LE.0) THEN
24635  pt=0d0
24636  ELSEIF(mstp(91).EQ.1) THEN
24637  pt=parp(91)*sqrt(-log(pyr(0)))
24638  ELSE
24639  rpt1=pyr(0)
24640  rpt2=pyr(0)
24641  pt=-parp(92)*log(rpt1*rpt2)
24642  ENDIF
24643  IF(pt.GT.parp(93)) goto 190
24644  ELSEIF(mint(106+iside).EQ.3) THEN
24645  pta=sqrt(vint(282+iside))
24646  ptb=0d0
24647  IF(mstp(66).EQ.5.AND.mstp(93).EQ.1) THEN
24648  ptb=parp(99)*sqrt(-log(pyr(0)))
24649  ELSEIF(mstp(66).EQ.5.AND.mstp(93).EQ.2) THEN
24650  rpt1=pyr(0)
24651  rpt2=pyr(0)
24652  ptb=-parp(99)*log(rpt1*rpt2)
24653  ENDIF
24654  IF(ptb.GT.parp(100)) goto 190
24655  pt=sqrt(pta**2+ptb**2+2d0*pta*ptb*cos(paru(2)*pyr(0)))
24656  IF(ntry.GT.10) pt=pt*0.8d0**(ntry-10)
24657  ELSEIF(iabs(mint(14+iside)).LE.8.OR.mint(14+iside).EQ.21) THEN
24658  IF(mstp(93).LE.0) THEN
24659  pt=0d0
24660  ELSEIF(mstp(93).EQ.1) THEN
24661  pt=parp(99)*sqrt(-log(pyr(0)))
24662  ELSEIF(mstp(93).EQ.2) THEN
24663  rpt1=pyr(0)
24664  rpt2=pyr(0)
24665  pt=-parp(99)*log(rpt1*rpt2)
24666  ELSEIF(mstp(93).EQ.3) THEN
24667  ha=parp(99)**2
24668  hb=parp(100)**2
24669  pt=sqrt(max(0d0,ha*(ha+hb)/(ha+hb-pyr(0)*hb)-ha))
24670  ELSE
24671  ha=parp(99)**2
24672  hb=parp(100)**2
24673  IF(mstp(93).EQ.5) hb=min(vint(48),parp(100)**2)
24674  pt=sqrt(max(0d0,ha*((ha+hb)/ha)**pyr(0)-ha))
24675  ENDIF
24676  IF(pt.GT.parp(100)) goto 190
24677  ELSE
24678  pt=0d0
24679  ENDIF
24680  vint(156+iside)=pt
24681  phi=paru(2)*pyr(0)
24682  p(ipu3,1)=pt*cos(phi)
24683  p(ipu3,2)=pt*sin(phi)
24684  p(ipu3,4)=sqrt(p(ipu3,5)**2+pt**2+p(ipu3,3)**2)
24685  pms(3-iside)=p(ipu3,5)**2+p(ipu3,1)**2+p(ipu3,2)**2
24686  pcp=p(ipu3,4)+abs(p(ipu3,3))
24687 
24688 C...Find one or two beam remnants.
24689  mint(105)=mint(102+iside)
24690  mint(109)=mint(106+iside)
24691  CALL pyspli(mint(10+iside),mint(12+iside),kflch,kflsp)
24692  IF(mint(51).NE.0) THEN
24693  mint(51)=0
24694  goto 180
24695  ENDIF
24696 
24697 C...Store first remnant parton, with colour info and kinematics.
24698  i=n+1
24699  k(i,1)=1
24700  k(i,2)=kflsp
24701  k(i,3)=mint(83)+iside
24702  p(i,5)=pymass(k(i,2))
24703  kcol=kchg(pycomp(kflsp),2)
24704  IF(kcol.NE.0) THEN
24705  k(i,1)=3
24706  kfls=(3-kcol*isign(1,kflsp))/2
24707  k(i,kfls+3)=mstu(5)*ipu3
24708  k(ipu3,6-kfls)=mstu(5)*i
24709  icolr=i
24710  ENDIF
24711  IF(kflch.EQ.0) THEN
24712  p(i,1)=-p(ipu3,1)
24713  p(i,2)=-p(ipu3,2)
24714  pms(iside)=p(i,5)**2+p(i,1)**2+p(i,2)**2
24715  p(i,3)=-p(ipu3,3)
24716  p(i,4)=sqrt(pms(iside)+p(i,3)**2)
24717  prp=p(i,4)+abs(p(i,3))
24718 
24719 C...When extra remnant parton or hadron: store extra remnant.
24720  ELSE
24721  i=i+1
24722  k(i,1)=1
24723  k(i,2)=kflch
24724  k(i,3)=mint(83)+iside
24725  p(i,5)=pymass(k(i,2))
24726  kcol=kchg(pycomp(kflch),2)
24727  IF(kcol.NE.0) THEN
24728  k(i,1)=3
24729  kfls=(3-kcol*isign(1,kflch))/2
24730  k(i,kfls+3)=mstu(5)*ipu3
24731  k(ipu3,6-kfls)=mstu(5)*i
24732  icolr=i
24733  ENDIF
24734 
24735 C...Relative transverse momentum when two remnants.
24736  loop=0
24737  200 loop=loop+1
24738  CALL pyptdi(1,p(i-1,1),p(i-1,2))
24739  p(i-1,1)=p(i-1,1)-0.5d0*p(ipu3,1)
24740  p(i-1,2)=p(i-1,2)-0.5d0*p(ipu3,2)
24741  pms(3)=p(i-1,5)**2+p(i-1,1)**2+p(i-1,2)**2
24742  p(i,1)=-p(ipu3,1)-p(i-1,1)
24743  p(i,2)=-p(ipu3,2)-p(i-1,2)
24744  pms(4)=p(i,5)**2+p(i,1)**2+p(i,2)**2
24745 
24746 C...Relative distribution of energy for particle into jet plus particle.
24747  imb=1
24748  IF(mod(mint(10+iside)/1000,10).NE.0) imb=2
24749  IF(mstp(94).LE.1) THEN
24750  IF(imb.EQ.1) chi=pyr(0)
24751  IF(imb.EQ.2) chi=1d0-sqrt(pyr(0))
24752  IF(mod(kflch/1000,10).NE.0) chi=1d0-chi
24753  ELSEIF(mstp(94).EQ.2) THEN
24754  chi=1d0-pyr(0)**(1d0/(1d0+parp(93+2*imb)))
24755  IF(mod(kflch/1000,10).NE.0) chi=1d0-chi
24756  ELSEIF(mstp(94).EQ.3) THEN
24757  CALL pyzdis(1,0,pms(4),zz)
24758  chi=zz
24759  ELSE
24760  CALL pyzdis(1000,0,pms(4),zz)
24761  chi=zz
24762  ENDIF
24763 
24764 C...Construct total transverse mass; reject if too large.
24765  chi=max(1d-8,min(1d0-1d-8,chi))
24766  pms(iside)=pms(4)/chi+pms(3)/(1d0-chi)
24767  IF(pms(iside).GT.p(ipu3,4)**2) THEN
24768  IF(loop.LT.10) goto 200
24769  goto 180
24770  ENDIF
24771  vint(158+iside)=chi
24772 
24773 C...Subdivide longitudinal momentum according to value selected above.
24774  prp=sqrt(pms(iside)+p(ipu3,3)**2)+abs(p(ipu3,3))
24775  pw1=(1d0-chi)*prp
24776  p(i-1,4)=0.5d0*(pw1+pms(3)/pw1)
24777  p(i-1,3)=0.5d0*(pw1-pms(3)/pw1)*sidesg
24778  pw2=chi*prp
24779  p(i,4)=0.5d0*(pw2+pms(4)/pw2)
24780  p(i,3)=0.5d0*(pw2-pms(4)/pw2)*sidesg
24781  ENDIF
24782  n=i
24783 
24784 C...Boost current and remnant systems to correct frame.
24785  IF(sqrt(pms(1))+sqrt(pms(2)).GT.0.99d0*vint(1)) goto 180
24786  dsqlam=sqrt(max(0d0,(vint(2)-pms(1)-pms(2))**2-4d0*pms(1)*pms(2)))
24787  drkc=(vint(2)+pms(3-iside)-pms(iside)+dsqlam)/
24788  &(2d0*vint(1)*pcp)
24789  drkr=(vint(2)+pms(iside)-pms(3-iside)+dsqlam)/
24790  &(2d0*vint(1)*prp)
24791  dbec=-sidesg*(drkc**2-1d0)/(drkc**2+1d0)
24792  dber=sidesg*(drkr**2-1d0)/(drkr**2+1d0)
24793  CALL pyrobo(ipu3,ipu3,0d0,0d0,0d0,0d0,dbec)
24794  CALL pyrobo(ipu3+1,n,0d0,0d0,0d0,0d0,dber)
24795 
24796 C...Let current quark shower; recoil but no showering by colour partner.
24797  qmax=2d0*sqrt(vint(309-iside))
24798  mstj48=mstj(48)
24799  mstj(48)=1
24800  parj86=parj(86)
24801  parj(86)=0d0
24802  IF(mstp(71).EQ.1) CALL pyshow(ipu3,icolr,qmax)
24803  mstj(48)=mstj48
24804  parj(86)=parj86
24805 
24806  RETURN
24807  END
24808 
24809 C*********************************************************************
24810 
24811 C...PYDOCU
24812 C...Handles the documentation of the process in MSTI and PARI,
24813 C...and also computes cross-sections based on accumulated statistics.
24814 
24815  SUBROUTINE pydocu
24816 
24817 C...Double precision and integer declarations.
24818  IMPLICIT DOUBLE PRECISION(a-h, o-z)
24819  IMPLICIT INTEGER(i-n)
24820  INTEGER pyk,pychge,pycomp
24821 C...Commonblocks.
24822  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
24823  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
24824  common/pypars/mstp(200),parp(200),msti(200),pari(200)
24825  common/pysubs/msel,mselpd,msub(500),kfin(2,-40:40),ckin(200)
24826  common/pyint1/mint(400),vint(400)
24827  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
24828  common/pyint5/ngenpd,ngen(0:500,3),xsec(0:500,3)
24829  SAVE /pyjets/,/pydat1/,/pysubs/,/pypars/,/pyint1/,/pyint2/,
24830  &/pyint5/
24831 
24832 C...Calculate Monte Carlo estimates of cross-sections.
24833  isub=mint(1)
24834  IF(mstp(111).NE.-1) ngen(isub,3)=ngen(isub,3)+1
24835  ngen(0,3)=ngen(0,3)+1
24836  xsec(0,3)=0d0
24837  DO 100 i=1,500
24838  IF(i.EQ.96.OR.i.EQ.97) THEN
24839  xsec(i,3)=0d0
24840  ELSEIF(msub(95).EQ.1.AND.(i.EQ.11.OR.i.EQ.12.OR.i.EQ.13.OR.
24841  & i.EQ.28.OR.i.EQ.53.OR.i.EQ.68)) THEN
24842  xsec(i,3)=xsec(96,2)*ngen(i,3)/max(1d0,dble(ngen(96,1))*
24843  & dble(ngen(96,2)))
24844  ELSEIF(msub(95).EQ.1.AND.i.GE.381.AND.i.LE.386) THEN
24845  xsec(i,3)=xsec(96,2)*ngen(i,3)/max(1d0,dble(ngen(96,1))*
24846  & dble(ngen(96,2)))
24847  ELSEIF(msub(i).EQ.0.OR.ngen(i,1).EQ.0) THEN
24848  xsec(i,3)=0d0
24849  ELSEIF(ngen(i,2).EQ.0) THEN
24850  xsec(i,3)=xsec(i,2)*ngen(0,3)/(dble(ngen(i,1))*
24851  & dble(ngen(0,2)))
24852  ELSE
24853  xsec(i,3)=xsec(i,2)*ngen(i,3)/(dble(ngen(i,1))*
24854  & dble(ngen(i,2)))
24855  ENDIF
24856  xsec(0,3)=xsec(0,3)+xsec(i,3)
24857  100 CONTINUE
24858 
24859 C...Rescale to known low-pT cross-section for standard QCD processes.
24860  IF(msub(95).EQ.1) THEN
24861  xsech=xsec(11,3)+xsec(12,3)+xsec(13,3)+xsec(28,3)+xsec(53,3)+
24862  & xsec(68,3)+xsec(95,3)
24863  xsecw=xsec(97,2)/max(1d0,dble(ngen(97,1)))
24864  IF(xsech.GT.1d-20.AND.xsecw.GT.1d-20) THEN
24865  fac=xsecw/xsech
24866  xsec(11,3)=fac*xsec(11,3)
24867  xsec(12,3)=fac*xsec(12,3)
24868  xsec(13,3)=fac*xsec(13,3)
24869  xsec(28,3)=fac*xsec(28,3)
24870  xsec(53,3)=fac*xsec(53,3)
24871  xsec(68,3)=fac*xsec(68,3)
24872  xsec(95,3)=fac*xsec(95,3)
24873  xsec(0,3)=xsec(0,3)-xsech+xsecw
24874  ENDIF
24875  ENDIF
24876 
24877 C...Save information for gamma-p and gamma-gamma.
24878  IF(mint(121).GT.1) THEN
24879  iga=mint(122)
24880  CALL pysave(2,iga)
24881  CALL pysave(5,0)
24882  ENDIF
24883 
24884 C...Reset information on hard interaction.
24885  DO 110 j=1,200
24886  msti(j)=0
24887  pari(j)=0d0
24888  110 CONTINUE
24889 
24890 C...Copy integer valued information from MINT into MSTI.
24891  DO 120 j=1,32
24892  msti(j)=mint(j)
24893  120 CONTINUE
24894  IF(mint(121).GT.1) msti(9)=mint(122)
24895 
24896 C...Store cross-section variables in PARI.
24897  pari(1)=xsec(0,3)
24898  pari(2)=xsec(0,3)/mint(5)
24899  pari(7)=vint(97)
24900  pari(9)=vint(99)
24901  pari(10)=vint(100)
24902  vint(98)=vint(98)+vint(100)
24903  IF(mstp(142).EQ.1) pari(2)=xsec(0,3)/vint(98)
24904 
24905 C...Store kinematics variables in PARI.
24906  pari(11)=vint(1)
24907  pari(12)=vint(2)
24908  IF(isub.NE.95) THEN
24909  DO 130 j=13,26
24910  pari(j)=vint(30+j)
24911  130 CONTINUE
24912  pari(29)=vint(39)
24913  pari(30)=vint(40)
24914  pari(31)=vint(141)
24915  pari(32)=vint(142)
24916  pari(33)=vint(41)
24917  pari(34)=vint(42)
24918  pari(35)=pari(33)-pari(34)
24919  pari(36)=vint(21)
24920  pari(37)=vint(22)
24921  pari(38)=vint(26)
24922  pari(39)=vint(157)
24923  pari(40)=vint(158)
24924  pari(41)=vint(23)
24925  pari(42)=2d0*vint(47)/vint(1)
24926  ENDIF
24927 
24928 C...Store information on scattered partons in PARI.
24929  IF(isub.NE.95.AND.mint(7)*mint(8).NE.0) THEN
24930  DO 140 is=7,8
24931  i=mint(is)
24932  pari(36+is)=p(i,3)/vint(1)
24933  pari(38+is)=p(i,4)/vint(1)
24934  pr=max(1d-20,p(i,5)**2+p(i,1)**2+p(i,2)**2)
24935  pari(40+is)=sign(log(min((sqrt(pr+p(i,3)**2)+abs(p(i,3)))/
24936  & sqrt(pr),1d20)),p(i,3))
24937  pr=max(1d-20,p(i,1)**2+p(i,2)**2)
24938  pari(42+is)=sign(log(min((sqrt(pr+p(i,3)**2)+abs(p(i,3)))/
24939  & sqrt(pr),1d20)),p(i,3))
24940  pari(44+is)=p(i,3)/sqrt(1d-20+p(i,1)**2+p(i,2)**2+p(i,3)**2)
24941  pari(46+is)=pyangl(p(i,3),sqrt(p(i,1)**2+p(i,2)**2))
24942  pari(48+is)=pyangl(p(i,1),p(i,2))
24943  140 CONTINUE
24944  ENDIF
24945 
24946 C...Store sum up transverse and longitudinal momenta.
24947  pari(65)=2d0*pari(17)
24948  IF(isub.LE.90.OR.isub.GE.95) THEN
24949  DO 150 i=mstp(126)+1,n
24950  IF(k(i,1).LE.0.OR.k(i,1).GT.10) goto 150
24951  pt=sqrt(p(i,1)**2+p(i,2)**2)
24952  pari(69)=pari(69)+pt
24953  IF(i.LE.mint(52)) pari(66)=pari(66)+pt
24954  IF(i.GT.mint(52).AND.i.LE.mint(53)) pari(68)=pari(68)+pt
24955  150 CONTINUE
24956  pari(67)=pari(68)
24957  pari(71)=vint(151)
24958  pari(72)=vint(152)
24959  pari(73)=vint(151)
24960  pari(74)=vint(152)
24961  ELSE
24962  pari(66)=pari(65)
24963  pari(69)=pari(65)
24964  ENDIF
24965 
24966 C...Store various other pieces of information into PARI.
24967  pari(61)=vint(148)
24968  pari(75)=vint(155)
24969  pari(76)=vint(156)
24970  pari(77)=vint(159)
24971  pari(78)=vint(160)
24972  pari(81)=vint(138)
24973 
24974 C...Store information on lepton -> lepton + gamma in PYGAGA.
24975  msti(71)=mint(141)
24976  msti(72)=mint(142)
24977  pari(101)=vint(301)
24978  pari(102)=vint(302)
24979  DO 160 i=103,114
24980  pari(i)=vint(i+202)
24981  160 CONTINUE
24982 
24983 C...Set information for PYTABU.
24984  IF(iset(isub).EQ.1.OR.iset(isub).EQ.3) THEN
24985  mstu(161)=mint(21)
24986  mstu(162)=0
24987  ELSEIF(iset(isub).EQ.5) THEN
24988  mstu(161)=mint(23)
24989  mstu(162)=0
24990  ELSE
24991  mstu(161)=mint(21)
24992  mstu(162)=mint(22)
24993  ENDIF
24994 
24995  RETURN
24996  END
24997 
24998 C*********************************************************************
24999 
25000 C...PYFRAM
25001 C...Performs transformations between different coordinate frames.
25002 
25003  SUBROUTINE pyfram(IFRAME)
25004 
25005 C...Double precision and integer declarations.
25006  IMPLICIT DOUBLE PRECISION(a-h, o-z)
25007  IMPLICIT INTEGER(i-n)
25008  INTEGER pyk,pychge,pycomp
25009 C...Commonblocks.
25010  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
25011  common/pypars/mstp(200),parp(200),msti(200),pari(200)
25012  common/pyint1/mint(400),vint(400)
25013  SAVE /pydat1/,/pypars/,/pyint1/
25014 
25015 C...Check that transformation can and should be done.
25016  IF(iframe.EQ.1.OR.iframe.EQ.2.OR.(iframe.EQ.3.AND.
25017  &mint(91).EQ.1)) THEN
25018  IF(iframe.EQ.mint(6)) RETURN
25019  ELSE
25020  WRITE(mstu(11),5000) iframe,mint(6)
25021  RETURN
25022  ENDIF
25023 
25024  IF(mint(6).EQ.1) THEN
25025 C...Transform from fixed target or user specified frame to
25026 C...overall CM frame.
25027  CALL pyrobo(0,0,0d0,0d0,-vint(8),-vint(9),-vint(10))
25028  CALL pyrobo(0,0,0d0,-vint(7),0d0,0d0,0d0)
25029  CALL pyrobo(0,0,-vint(6),0d0,0d0,0d0,0d0)
25030  ELSEIF(mint(6).EQ.3) THEN
25031 C...Transform from hadronic CM frame in DIS to overall CM frame.
25032  CALL pyrobo(0,0,-vint(221),-vint(222),-vint(223),-vint(224),
25033  & -vint(225))
25034  ENDIF
25035 
25036  IF(iframe.EQ.1) THEN
25037 C...Transform from overall CM frame to fixed target or user specified
25038 C...frame.
25039  CALL pyrobo(0,0,vint(6),vint(7),vint(8),vint(9),vint(10))
25040  ELSEIF(iframe.EQ.3) THEN
25041 C...Transform from overall CM frame to hadronic CM frame in DIS.
25042  CALL pyrobo(0,0,0d0,0d0,vint(223),vint(224),vint(225))
25043  CALL pyrobo(0,0,0d0,vint(222),0d0,0d0,0d0)
25044  CALL pyrobo(0,0,vint(221),0d0,0d0,0d0,0d0)
25045  ENDIF
25046 
25047 C...Set information about new frame.
25048  mint(6)=iframe
25049  msti(6)=iframe
25050 
25051  5000 FORMAT(1x,'Error: illegal values in subroutine PYFRAM.',1x,
25052  &'No transformation performed.'/1x,'IFRAME =',1x,i5,'; MINT(6) =',
25053  &1x,i5)
25054 
25055  RETURN
25056  END
25057 
25058 C*********************************************************************
25059 
25060 C...PYWIDT
25061 C...Calculates full and partial widths of resonances.
25062 
25063  SUBROUTINE pywidt(KFLR,SH,WDTP,WDTE)
25064 
25065 C...Double precision and integer declarations.
25066  IMPLICIT DOUBLE PRECISION(a-h, o-z)
25067  IMPLICIT INTEGER(i-n)
25068  INTEGER pyk,pychge,pycomp
25069 C...Parameter statement to help give large particle numbers.
25070  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
25071  &kexcit=4000000,kdimen=5000000)
25072 C...Commonblocks.
25073  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
25074  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
25075  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
25076  common/pysubs/msel,mselpd,msub(500),kfin(2,-40:40),ckin(200)
25077  common/pypars/mstp(200),parp(200),msti(200),pari(200)
25078  common/pyint1/mint(400),vint(400)
25079  common/pyint4/mwid(500),wids(500,5)
25080  common/pymssm/imss(0:99),rmss(0:99)
25081  common/pyssmt/zmix(4,4),umix(2,2),vmix(2,2),smz(4),smw(2),
25082  &sfmix(16,4),zmixi(4,4),umixi(2,2),vmixi(2,2)
25083  common/pytcsm/itcm(0:99),rtcm(0:99)
25084  common/pypued/iued(0:99),rued(0:99)
25085  SAVE /pydat1/,/pydat2/,/pydat3/,/pysubs/,/pypars/,/pyint1/,
25086  &/pyint4/,/pymssm/,/pyssmt/,/pytcsm/,/pypued/
25087 C...Local arrays and saved variables.
25088  COMPLEX*16 zmixc(4,4),al,bl,ar,br,fl,fr
25089  dimension wdtp(0:400),wdte(0:400,0:5),mofsv(3,2),widwsv(3,2),
25090  &wid2sv(3,2),wdtpp(0:400),wdtep(0:400,0:5)
25091 C...UED: equivalences between ordered particles (451->475)
25092 C...and UED particle code (5 000 000 + id)
25093  parameter(kkflmi=451,kkflma=475)
25094  dimension chidel(3), iuedpr(25)
25095  dimension iuedeq(kkflma),mued(2)
25096  common/sw1/sw21,cw21
25097  DATA (iuedeq(i),i=kkflmi,kkflma)/
25098  & 6100001,6100002,6100003,6100004,6100005,6100006,
25099  & 5100001,5100002,5100003,5100004,5100005,5100006,
25100  & 6100011,6100013,6100015,
25101  & 5100012,5100011,5100014,5100013,5100016,5100015,
25102  & 5100021,5100022,5100023,5100024/
25103 C...Save local variables
25104  SAVE mofsv,widwsv,wid2sv
25105 C...Initial values
25106  DATA mofsv/6*0/,widwsv/6*0d0/,wid2sv/6*0d0/
25107  DATA chidel/1.1d-03,1.d0,7.4d+2/
25108  DATA iuedpr/25*0/
25109 C...UED: inline functions used in kk width calculus
25110  fkac1(x,y)=1.-x**2/y**2
25111  fkac2(x,y)=2.+x**2/y**2
25112 
25113 C...Compressed code and sign; mass.
25114  kfla=iabs(kflr)
25115  kfls=isign(1,kflr)
25116  kc=pycomp(kfla)
25117  shr=sqrt(sh)
25118  pmr=pmas(kc,1)
25119 
25120 C...Reset width information.
25121  DO 110 i=0,mdcy(kc,3)
25122  wdtp(i)=0d0
25123  DO 100 j=0,5
25124  wdte(i,j)=0d0
25125  100 CONTINUE
25126  110 CONTINUE
25127 
25128 C...Allow for fudge factor to rescale resonance width.
25129  fudge=1d0
25130  IF(mstp(110).NE.0.AND.(mwid(kc).EQ.1.OR.mwid(kc).EQ.2.OR.
25131  &(mwid(kc).EQ.3.AND.mint(63).EQ.1))) THEN
25132  IF(mstp(110).EQ.kfla) THEN
25133  fudge=parp(110)
25134  ELSEIF(mstp(110).EQ.-1) THEN
25135  IF(kfla.NE.6.AND.kfla.NE.23.AND.kfla.NE.24) fudge=parp(110)
25136  ELSEIF(mstp(110).EQ.-2) THEN
25137  fudge=parp(110)
25138  ENDIF
25139  ENDIF
25140 
25141 C...Not to be treated as a resonance: return.
25142  IF((mwid(kc).LE.0.OR.mwid(kc).GE.4).AND.kfla.NE.21.AND.
25143  &kfla.NE.22) THEN
25144  wdtp(0)=1d0
25145  wdte(0,0)=1d0
25146  mint(61)=0
25147  mint(62)=0
25148  mint(63)=0
25149  RETURN
25150 
25151 C...Treatment as a resonance based on tabulated branching ratios.
25152  ELSEIF(mwid(kc).EQ.2.OR.(mwid(kc).EQ.3.AND.mint(63).EQ.0)) THEN
25153 C...Loop over possible decay channels; skip irrelevant ones.
25154  DO 120 i=1,mdcy(kc,3)
25155  idc=i+mdcy(kc,2)-1
25156  IF(mdme(idc,1).LT.0) goto 120
25157 
25158 C...Read out decay products and nominal masses.
25159  kfd1=kfdp(idc,1)
25160  kfc1=pycomp(kfd1)
25161 C...Skip dummy modes or unrecognized particles
25162  IF (kfd1.EQ.0.OR.kfc1.EQ.0) goto 120
25163  IF(kchg(kfc1,3).EQ.1) kfd1=kfls*kfd1
25164  pm1=pmas(kfc1,1)
25165  kfd2=kfdp(idc,2)
25166  kfc2=pycomp(kfd2)
25167  IF(kchg(kfc2,3).EQ.1) kfd2=kfls*kfd2
25168  pm2=pmas(kfc2,1)
25169  kfd3=kfdp(idc,3)
25170  pm3=0d0
25171  IF(kfd3.NE.0) THEN
25172  kfc3=pycomp(kfd3)
25173  IF(kchg(kfc3,3).EQ.1) kfd3=kfls*kfd3
25174  pm3=pmas(kfc3,1)
25175  ENDIF
25176 
25177 C...Naive partial width and alternative threshold factors.
25178  wdtp(i)=pmas(kc,2)*brat(idc)*(shr/pmr)
25179  IF(mdme(idc,2).GE.51.AND.mdme(idc,2).LE.53.AND.
25180  & pm1+pm2+pm3.GE.shr) THEN
25181  wdtp(i)=0d0
25182  ELSEIF(mdme(idc,2).EQ.52.AND.kfd3.EQ.0) THEN
25183  wdtp(i)=wdtp(i)*sqrt(max(0d0,(sh-pm1**2-pm2**2)**2-
25184  & 4d0*pm1**2*pm2**2))/sh
25185  ELSEIF(mdme(idc,2).EQ.52) THEN
25186  pma=max(pm1,pm2,pm3)
25187  pmc=min(pm1,pm2,pm3)
25188  pmb=pm1+pm2+pm3-pma-pmc
25189  pmbc=pmb+pmc+0.5d0*(shr-pma-pmc-pmc)
25190  pman=pma**2/sh
25191  pmbn=pmb**2/sh
25192  pmcn=pmc**2/sh
25193  pmbcn=pmbc**2/sh
25194  wdtp(i)=wdtp(i)*sqrt(max(0d0,
25195  & ((1d0-pman-pmbcn)**2-4d0*pman*pmbcn)*
25196  & ((pmbcn-pmbn-pmcn)**2-4d0*pmbn*pmcn)))*
25197  & ((shr-pma)**2-(pmb+pmc)**2)*
25198  & (1d0+0.25d0*(pma+pmb+pmc)/shr)/
25199  & ((1d0-pmbcn)*pmbcn*sh)
25200  ELSEIF(mdme(idc,2).EQ.53.AND.kfd3.EQ.0) THEN
25201  wdtp(i)=wdtp(i)*sqrt(
25202  & max(0d0,(sh-pm1**2-pm2**2)**2-4d0*pm1**2*pm2**2)/
25203  & max(1d-4,(pmr**2-pm1**2-pm2**2)**2-4d0*pm1**2*pm2**2))
25204  ELSEIF(mdme(idc,2).EQ.53) THEN
25205  pma=max(pm1,pm2,pm3)
25206  pmc=min(pm1,pm2,pm3)
25207  pmb=pm1+pm2+pm3-pma-pmc
25208  pmbc=pmb+pmc+0.5d0*(shr-pma-pmb-pmc)
25209  pman=pma**2/sh
25210  pmbn=pmb**2/sh
25211  pmcn=pmc**2/sh
25212  pmbcn=pmbc**2/sh
25213  facact=sqrt(max(0d0,
25214  & ((1d0-pman-pmbcn)**2-4d0*pman*pmbcn)*
25215  & ((pmbcn-pmbn-pmcn)**2-4d0*pmbn*pmcn)))*
25216  & ((shr-pma)**2-(pmb+pmc)**2)*
25217  & (1d0+0.25d0*(pma+pmb+pmc)/shr)/
25218  & ((1d0-pmbcn)*pmbcn*sh)
25219  pmbc=pmb+pmc+0.5d0*(pmr-pma-pmb-pmc)
25220  pman=pma**2/pmr**2
25221  pmbn=pmb**2/pmr**2
25222  pmcn=pmc**2/pmr**2
25223  pmbcn=pmbc**2/pmr**2
25224  facnom=sqrt(max(0d0,
25225  & ((1d0-pman-pmbcn)**2-4d0*pman*pmbcn)*
25226  & ((pmbcn-pmbn-pmcn)**2-4d0*pmbn*pmcn)))*
25227  & ((pmr-pma)**2-(pmb+pmc)**2)*
25228  & (1d0+0.25d0*(pma+pmb+pmc)/pmr)/
25229  & ((1d0-pmbcn)*pmbcn*pmr**2)
25230  wdtp(i)=wdtp(i)*facact/max(1d-6,facnom)
25231  ENDIF
25232  wdtp(i)=fudge*wdtp(i)
25233  wdtp(0)=wdtp(0)+wdtp(i)
25234 
25235 C...Calculate secondary width (at most two identical/opposite).
25236  wid2=1d0
25237  IF(mdme(idc,1).GT.0) THEN
25238  IF(kfd2.EQ.kfd1) THEN
25239  IF(kchg(kfc1,3).EQ.0) THEN
25240  wid2=wids(kfc1,1)
25241  ELSEIF(kfd1.GT.0) THEN
25242  wid2=wids(kfc1,4)
25243  ELSE
25244  wid2=wids(kfc1,5)
25245  ENDIF
25246  IF(kfd3.GT.0) THEN
25247  wid2=wid2*wids(kfc3,2)
25248  ELSEIF(kfd3.LT.0) THEN
25249  wid2=wid2*wids(kfc3,3)
25250  ENDIF
25251  ELSEIF(kfd2.EQ.-kfd1) THEN
25252  wid2=wids(kfc1,1)
25253  IF(kfd3.GT.0) THEN
25254  wid2=wid2*wids(kfc3,2)
25255  ELSEIF(kfd3.LT.0) THEN
25256  wid2=wid2*wids(kfc3,3)
25257  ENDIF
25258  ELSEIF(kfd3.EQ.kfd1) THEN
25259  IF(kchg(kfc1,3).EQ.0) THEN
25260  wid2=wids(kfc1,1)
25261  ELSEIF(kfd1.GT.0) THEN
25262  wid2=wids(kfc1,4)
25263  ELSE
25264  wid2=wids(kfc1,5)
25265  ENDIF
25266  IF(kfd2.GT.0) THEN
25267  wid2=wid2*wids(kfc2,2)
25268  ELSEIF(kfd2.LT.0) THEN
25269  wid2=wid2*wids(kfc2,3)
25270  ENDIF
25271  ELSEIF(kfd3.EQ.-kfd1) THEN
25272  wid2=wids(kfc1,1)
25273  IF(kfd2.GT.0) THEN
25274  wid2=wid2*wids(kfc2,2)
25275  ELSEIF(kfd2.LT.0) THEN
25276  wid2=wid2*wids(kfc2,3)
25277  ENDIF
25278  ELSEIF(kfd3.EQ.kfd2) THEN
25279  IF(kchg(kfc2,3).EQ.0) THEN
25280  wid2=wids(kfc2,1)
25281  ELSEIF(kfd2.GT.0) THEN
25282  wid2=wids(kfc2,4)
25283  ELSE
25284  wid2=wids(kfc2,5)
25285  ENDIF
25286  IF(kfd1.GT.0) THEN
25287  wid2=wid2*wids(kfc1,2)
25288  ELSEIF(kfd1.LT.0) THEN
25289  wid2=wid2*wids(kfc1,3)
25290  ENDIF
25291  ELSEIF(kfd3.EQ.-kfd2) THEN
25292  wid2=wids(kfc2,1)
25293  IF(kfd1.GT.0) THEN
25294  wid2=wid2*wids(kfc1,2)
25295  ELSEIF(kfd1.LT.0) THEN
25296  wid2=wid2*wids(kfc1,3)
25297  ENDIF
25298  ELSE
25299  IF(kfd1.GT.0) THEN
25300  wid2=wids(kfc1,2)
25301  ELSE
25302  wid2=wids(kfc1,3)
25303  ENDIF
25304  IF(kfd2.GT.0) THEN
25305  wid2=wid2*wids(kfc2,2)
25306  ELSE
25307  wid2=wid2*wids(kfc2,3)
25308  ENDIF
25309  IF(kfd3.GT.0) THEN
25310  wid2=wid2*wids(kfc3,2)
25311  ELSEIF(kfd3.LT.0) THEN
25312  wid2=wid2*wids(kfc3,3)
25313  ENDIF
25314  ENDIF
25315 
25316 C...Store effective widths according to case.
25317  wdte(i,mdme(idc,1))=wdtp(i)*wid2
25318  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
25319  wdte(i,0)=wdte(i,mdme(idc,1))
25320  wdte(0,0)=wdte(0,0)+wdte(i,0)
25321  ENDIF
25322  120 CONTINUE
25323 C...Return.
25324  mint(61)=0
25325  mint(62)=0
25326  mint(63)=0
25327  RETURN
25328  ENDIF
25329 
25330 C...Here begins detailed dynamical calculation of resonance widths.
25331 C...Shared treatment of Higgs states.
25332  kfhigg=25
25333  ihigg=1
25334  IF(kfla.EQ.35.OR.kfla.EQ.36) THEN
25335  kfhigg=kfla
25336  ihigg=kfla-33
25337  ENDIF
25338 
25339 C...Common electroweak and strong constants.
25340  xw=paru(102)
25341  xwv=xw
25342  IF(mstp(8).GE.2) xw=1d0-(pmas(24,1)/pmas(23,1))**2
25343  xw1=1d0-xw
25344  aem=pyalem(sh)
25345  IF(mstp(8).GE.1) aem=sqrt(2d0)*paru(105)*pmas(24,1)**2*xw/paru(1)
25346  as=pyalps(sh)
25347  radc=1d0+as/paru(1)
25348 
25349  IF(kfla.EQ.6) THEN
25350 C...t quark.
25351  fac=(aem/(16d0*xw))*(sh/pmas(24,1)**2)*shr
25352  radct=1d0-2.5d0*as/paru(1)
25353  DO 140 i=1,mdcy(kc,3)
25354  idc=i+mdcy(kc,2)-1
25355  IF(mdme(idc,1).LT.0) goto 140
25356  rm1=pmas(pycomp(kfdp(idc,1)),1)**2/sh
25357  rm2=pmas(pycomp(kfdp(idc,2)),1)**2/sh
25358  IF(sqrt(rm1)+sqrt(rm2).GT.1d0) goto 140
25359  wid2=1d0
25360  IF(i.GE.4.AND.i.LE.7) THEN
25361 C...t -> W + q; including approximate QCD correction factor.
25362  wdtp(i)=fac*vckm(3,i-3)*radct*
25363  & sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))*
25364  & ((1d0-rm2)**2+(1d0+rm2)*rm1-2d0*rm1**2)
25365  IF(kflr.GT.0) THEN
25366  wid2=wids(24,2)
25367  IF(i.EQ.7) wid2=wid2*wids(7,2)
25368  ELSE
25369  wid2=wids(24,3)
25370  IF(i.EQ.7) wid2=wid2*wids(7,3)
25371  ENDIF
25372  ELSEIF(i.EQ.9) THEN
25373 C...t -> H + b.
25374  rm2r=pymrun(kfdp(idc,2),sh)**2/sh
25375  wdtp(i)=fac*sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))*
25376  & ((1d0+rm2-rm1)*(rm2r*paru(141)**2+1d0/paru(141)**2)+
25377  & 4d0*sqrt(rm2r*rm2))
25378  wid2=wids(37,2)
25379  IF(kflr.LT.0) wid2=wids(37,3)
25380 CMRENNA++
25381  ELSEIF(i.GE.10.AND.i.LE.13.AND.imss(1).NE.0) THEN
25382 C...t -> ~t + ~chi_i0, i = 1, 2, 3 or 4.
25383  beta=atan(rmss(5))
25384  sinb=sin(beta)
25385  tanw=sqrt(paru(102)/(1d0-paru(102)))
25386  et=kchg(6,1)/3d0
25387  t3l=sign(0.5d0,et)
25388  kfc1=pycomp(kfdp(idc,1))
25389  kfc2=pycomp(kfdp(idc,2))
25390  pmnchi=pmas(kfc1,1)
25391  pmstop=pmas(kfc2,1)
25392  IF(shr.GT.pmnchi+pmstop) THEN
25393  iz=i-9
25394  DO 130 ik=1,4
25395  zmixc(iz,ik)=dcmplx(zmix(iz,ik),zmixi(iz,ik))
25396  130 CONTINUE
25397  al=shr*dconjg(zmixc(iz,4))/(2.0d0*pmas(24,1)*sinb)
25398  ar=-et*zmixc(iz,1)*tanw
25399  bl=t3l*(zmixc(iz,2)-zmixc(iz,1)*tanw)-ar
25400  br=al
25401  fl=sfmix(6,1)*al+sfmix(6,2)*ar
25402  fr=sfmix(6,1)*bl+sfmix(6,2)*br
25403  pcm=sqrt((sh-(pmnchi+pmstop)**2)*
25404  & (sh-(pmnchi-pmstop)**2))/(2d0*shr)
25405  wdtp(i)=(0.5d0*pyalem(sh)/paru(102))*pcm*
25406  & ((abs(fl)**2+abs(fr)**2)*(sh+pmnchi**2-pmstop**2)+
25407  & smz(iz)*4d0*shr*dble(fl*dconjg(fr)))/sh
25408  IF(kflr.GT.0) THEN
25409  wid2=wids(kfc1,2)*wids(kfc2,2)
25410  ELSE
25411  wid2=wids(kfc1,2)*wids(kfc2,3)
25412  ENDIF
25413  ENDIF
25414  ELSEIF(i.EQ.14.AND.imss(1).NE.0) THEN
25415 C...t -> ~g + ~t
25416  kfc1=pycomp(kfdp(idc,1))
25417  kfc2=pycomp(kfdp(idc,2))
25418  pmnchi=pmas(kfc1,1)
25419  pmstop=pmas(kfc2,1)
25420  IF(shr.GT.pmnchi+pmstop) THEN
25421  rl=sfmix(6,1)
25422  rr=-sfmix(6,2)
25423  pcm=sqrt((sh-(pmnchi+pmstop)**2)*
25424  & (sh-(pmnchi-pmstop)**2))/(2d0*shr)
25425  wdtp(i)=4d0/3d0*0.5d0*pyalps(sh)*pcm*((rl**2+rr**2)*
25426  & (sh+pmnchi**2-pmstop**2)+pmnchi*4d0*shr*rl*rr)/sh
25427  IF(kflr.GT.0) THEN
25428  wid2=wids(kfc1,2)*wids(kfc2,2)
25429  ELSE
25430  wid2=wids(kfc1,2)*wids(kfc2,3)
25431  ENDIF
25432  ENDIF
25433  ELSEIF(i.EQ.15.AND.imss(1).NE.0) THEN
25434 C...t -> ~gravitino + ~t
25435  xmp2=rmss(29)**2
25436  kfc1=pycomp(kfdp(idc,1))
25437  xmgr2=pmas(kfc1,1)**2
25438  wdtp(i)=sh**2*shr/(96d0*paru(1)*xmp2*xmgr2)*(1d0-rm2)**4
25439  kfc2=pycomp(kfdp(idc,2))
25440  wid2=wids(kfc2,2)
25441  IF(kflr.LT.0) wid2=wids(kfc2,3)
25442 CMRENNA--
25443  ENDIF
25444  wdtp(i)=fudge*wdtp(i)
25445  wdtp(0)=wdtp(0)+wdtp(i)
25446  IF(mdme(idc,1).GT.0) THEN
25447  wdte(i,mdme(idc,1))=wdtp(i)*wid2
25448  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
25449  wdte(i,0)=wdte(i,mdme(idc,1))
25450  wdte(0,0)=wdte(0,0)+wdte(i,0)
25451  ENDIF
25452  140 CONTINUE
25453 
25454  ELSEIF(kfla.EQ.7) THEN
25455 C...b' quark.
25456  fac=(aem/(16d0*xw))*(sh/pmas(24,1)**2)*shr
25457  DO 150 i=1,mdcy(kc,3)
25458  idc=i+mdcy(kc,2)-1
25459  IF(mdme(idc,1).LT.0) goto 150
25460  rm1=pmas(pycomp(kfdp(idc,1)),1)**2/sh
25461  rm2=pmas(pycomp(kfdp(idc,2)),1)**2/sh
25462  IF(sqrt(rm1)+sqrt(rm2).GT.1d0) goto 150
25463  wid2=1d0
25464  IF(i.GE.4.AND.i.LE.7) THEN
25465 C...b' -> W + q.
25466  wdtp(i)=fac*vckm(i-3,4)*
25467  & sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))*
25468  & ((1d0-rm2)**2+(1d0+rm2)*rm1-2d0*rm1**2)
25469  IF(kflr.GT.0) THEN
25470  wid2=wids(24,3)
25471  IF(i.EQ.6) wid2=wid2*wids(6,2)
25472  IF(i.EQ.7) wid2=wid2*wids(8,2)
25473  ELSE
25474  wid2=wids(24,2)
25475  IF(i.EQ.6) wid2=wid2*wids(6,3)
25476  IF(i.EQ.7) wid2=wid2*wids(8,3)
25477  ENDIF
25478  wid2=wids(24,3)
25479  IF(kflr.LT.0) wid2=wids(24,2)
25480  ELSEIF(i.EQ.9.OR.i.EQ.10) THEN
25481 C...b' -> H + q.
25482  wdtp(i)=fac*sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))*
25483  & ((1d0+rm2-rm1)*(paru(141)**2+rm2/paru(141)**2)+4d0*rm2)
25484  IF(kflr.GT.0) THEN
25485  wid2=wids(37,3)
25486  IF(i.EQ.10) wid2=wid2*wids(6,2)
25487  ELSE
25488  wid2=wids(37,2)
25489  IF(i.EQ.10) wid2=wid2*wids(6,3)
25490  ENDIF
25491  ENDIF
25492  wdtp(i)=fudge*wdtp(i)
25493  wdtp(0)=wdtp(0)+wdtp(i)
25494  IF(mdme(idc,1).GT.0) THEN
25495  wdte(i,mdme(idc,1))=wdtp(i)*wid2
25496  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
25497  wdte(i,0)=wdte(i,mdme(idc,1))
25498  wdte(0,0)=wdte(0,0)+wdte(i,0)
25499  ENDIF
25500  150 CONTINUE
25501 
25502  ELSEIF(kfla.EQ.8) THEN
25503 C...t' quark.
25504  fac=(aem/(16d0*xw))*(sh/pmas(24,1)**2)*shr
25505  DO 160 i=1,mdcy(kc,3)
25506  idc=i+mdcy(kc,2)-1
25507  IF(mdme(idc,1).LT.0) goto 160
25508  rm1=pmas(pycomp(kfdp(idc,1)),1)**2/sh
25509  rm2=pmas(pycomp(kfdp(idc,2)),1)**2/sh
25510  IF(sqrt(rm1)+sqrt(rm2).GT.1d0) goto 160
25511  wid2=1d0
25512  IF(i.GE.4.AND.i.LE.7) THEN
25513 C...t' -> W + q.
25514  wdtp(i)=fac*vckm(4,i-3)*
25515  & sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))*
25516  & ((1d0-rm2)**2+(1d0+rm2)*rm1-2d0*rm1**2)
25517  IF(kflr.GT.0) THEN
25518  wid2=wids(24,2)
25519  IF(i.EQ.7) wid2=wid2*wids(7,2)
25520  ELSE
25521  wid2=wids(24,3)
25522  IF(i.EQ.7) wid2=wid2*wids(7,3)
25523  ENDIF
25524  ELSEIF(i.EQ.9.OR.i.EQ.10) THEN
25525 C...t' -> H + q.
25526  wdtp(i)=fac*sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))*
25527  & ((1d0+rm2-rm1)*(rm2*paru(141)**2+1d0/paru(141)**2)+4d0*rm2)
25528  IF(kflr.GT.0) THEN
25529  wid2=wids(37,2)
25530  IF(i.EQ.10) wid2=wid2*wids(7,2)
25531  ELSE
25532  wid2=wids(37,3)
25533  IF(i.EQ.10) wid2=wid2*wids(7,3)
25534  ENDIF
25535  ENDIF
25536  wdtp(i)=fudge*wdtp(i)
25537  wdtp(0)=wdtp(0)+wdtp(i)
25538  IF(mdme(idc,1).GT.0) THEN
25539  wdte(i,mdme(idc,1))=wdtp(i)*wid2
25540  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
25541  wdte(i,0)=wdte(i,mdme(idc,1))
25542  wdte(0,0)=wdte(0,0)+wdte(i,0)
25543  ENDIF
25544  160 CONTINUE
25545 
25546  ELSEIF(kfla.EQ.17) THEN
25547 C...tau' lepton.
25548  fac=(aem/(16d0*xw))*(sh/pmas(24,1)**2)*shr
25549  DO 170 i=1,mdcy(kc,3)
25550  idc=i+mdcy(kc,2)-1
25551  IF(mdme(idc,1).LT.0) goto 170
25552  rm1=pmas(pycomp(kfdp(idc,1)),1)**2/sh
25553  rm2=pmas(pycomp(kfdp(idc,2)),1)**2/sh
25554  IF(sqrt(rm1)+sqrt(rm2).GT.1d0) goto 170
25555  wid2=1d0
25556  IF(i.EQ.3) THEN
25557 C...tau' -> W + nu'_tau.
25558  wdtp(i)=fac*sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))*
25559  & ((1d0-rm2)**2+(1d0+rm2)*rm1-2d0*rm1**2)
25560  IF(kflr.GT.0) THEN
25561  wid2=wids(24,3)
25562  wid2=wid2*wids(18,2)
25563  ELSE
25564  wid2=wids(24,2)
25565  wid2=wid2*wids(18,3)
25566  ENDIF
25567  ELSEIF(i.EQ.5) THEN
25568 C...tau' -> H + nu'_tau.
25569  wdtp(i)=fac*sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))*
25570  & ((1d0+rm2-rm1)*(paru(141)**2+rm2/paru(141)**2)+4d0*rm2)
25571  IF(kflr.GT.0) THEN
25572  wid2=wids(37,3)
25573  wid2=wid2*wids(18,2)
25574  ELSE
25575  wid2=wids(37,2)
25576  wid2=wid2*wids(18,3)
25577  ENDIF
25578  ENDIF
25579  wdtp(i)=fudge*wdtp(i)
25580  wdtp(0)=wdtp(0)+wdtp(i)
25581  IF(mdme(idc,1).GT.0) THEN
25582  wdte(i,mdme(idc,1))=wdtp(i)*wid2
25583  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
25584  wdte(i,0)=wdte(i,mdme(idc,1))
25585  wdte(0,0)=wdte(0,0)+wdte(i,0)
25586  ENDIF
25587  170 CONTINUE
25588 
25589  ELSEIF(kfla.EQ.18) THEN
25590 C...nu'_tau neutrino.
25591  fac=(aem/(16d0*xw))*(sh/pmas(24,1)**2)*shr
25592  DO 180 i=1,mdcy(kc,3)
25593  idc=i+mdcy(kc,2)-1
25594  IF(mdme(idc,1).LT.0) goto 180
25595  rm1=pmas(pycomp(kfdp(idc,1)),1)**2/sh
25596  rm2=pmas(pycomp(kfdp(idc,2)),1)**2/sh
25597  IF(sqrt(rm1)+sqrt(rm2).GT.1d0) goto 180
25598  wid2=1d0
25599  IF(i.EQ.2) THEN
25600 C...nu'_tau -> W + tau'.
25601  wdtp(i)=fac*sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))*
25602  & ((1d0-rm2)**2+(1d0+rm2)*rm1-2d0*rm1**2)
25603  IF(kflr.GT.0) THEN
25604  wid2=wids(24,2)
25605  wid2=wid2*wids(17,2)
25606  ELSE
25607  wid2=wids(24,3)
25608  wid2=wid2*wids(17,3)
25609  ENDIF
25610  ELSEIF(i.EQ.3) THEN
25611 C...nu'_tau -> H + tau'.
25612  wdtp(i)=fac*sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))*
25613  & ((1d0+rm2-rm1)*(rm2*paru(141)**2+1d0/paru(141)**2)+4d0*rm2)
25614  IF(kflr.GT.0) THEN
25615  wid2=wids(37,2)
25616  wid2=wid2*wids(17,2)
25617  ELSE
25618  wid2=wids(37,3)
25619  wid2=wid2*wids(17,3)
25620  ENDIF
25621  ENDIF
25622  wdtp(i)=fudge*wdtp(i)
25623  wdtp(0)=wdtp(0)+wdtp(i)
25624  IF(mdme(idc,1).GT.0) THEN
25625  wdte(i,mdme(idc,1))=wdtp(i)*wid2
25626  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
25627  wdte(i,0)=wdte(i,mdme(idc,1))
25628  wdte(0,0)=wdte(0,0)+wdte(i,0)
25629  ENDIF
25630  180 CONTINUE
25631 
25632  ELSEIF(kfla.EQ.21) THEN
25633 C...QCD:
25634 C***Note that widths are not given in dimensional quantities here.
25635  DO 190 i=1,mdcy(kc,3)
25636  idc=i+mdcy(kc,2)-1
25637  IF(mdme(idc,1).LT.0) goto 190
25638  rm1=pmas(iabs(kfdp(idc,1)),1)**2/sh
25639  rm2=pmas(iabs(kfdp(idc,2)),1)**2/sh
25640  IF(sqrt(rm1)+sqrt(rm2).GT.1d0) goto 190
25641  wid2=1d0
25642  IF(i.LE.8) THEN
25643 C...QCD -> q + qbar
25644  wdtp(i)=(1d0+2d0*rm1)*sqrt(max(0d0,1d0-4d0*rm1))
25645  IF(i.EQ.6) wid2=wids(6,1)
25646  IF((i.EQ.7.OR.i.EQ.8)) wid2=wids(i,1)
25647  ENDIF
25648  wdtp(i)=fudge*wdtp(i)
25649  wdtp(0)=wdtp(0)+wdtp(i)
25650  IF(mdme(idc,1).GT.0) THEN
25651  wdte(i,mdme(idc,1))=wdtp(i)*wid2
25652  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
25653  wdte(i,0)=wdte(i,mdme(idc,1))
25654  wdte(0,0)=wdte(0,0)+wdte(i,0)
25655  ENDIF
25656  190 CONTINUE
25657 
25658  ELSEIF(kfla.EQ.22) THEN
25659 C...QED photon.
25660 C***Note that widths are not given in dimensional quantities here.
25661  DO 200 i=1,mdcy(kc,3)
25662  idc=i+mdcy(kc,2)-1
25663  IF(mdme(idc,1).LT.0) goto 200
25664  rm1=pmas(iabs(kfdp(idc,1)),1)**2/sh
25665  rm2=pmas(iabs(kfdp(idc,2)),1)**2/sh
25666  IF(sqrt(rm1)+sqrt(rm2).GT.1d0) goto 200
25667  wid2=1d0
25668  IF(i.LE.8) THEN
25669 C...QED -> q + qbar.
25670  ef=kchg(i,1)/3d0
25671  fcof=3d0*radc
25672  IF(i.GE.6.AND.mstp(35).GE.1) fcof=fcof*pyhfth(sh,sh*rm1,1d0)
25673  wdtp(i)=fcof*ef**2*(1d0+2d0*rm1)*sqrt(max(0d0,1d0-4d0*rm1))
25674  IF(i.EQ.6) wid2=wids(6,1)
25675  IF((i.EQ.7.OR.i.EQ.8)) wid2=wids(i,1)
25676  ELSEIF(i.LE.12) THEN
25677 C...QED -> l+ + l-.
25678  ef=kchg(9+2*(i-8),1)/3d0
25679  wdtp(i)=ef**2*(1d0+2d0*rm1)*sqrt(max(0d0,1d0-4d0*rm1))
25680  IF(i.EQ.12) wid2=wids(17,1)
25681  ENDIF
25682  wdtp(i)=fudge*wdtp(i)
25683  wdtp(0)=wdtp(0)+wdtp(i)
25684  IF(mdme(idc,1).GT.0) THEN
25685  wdte(i,mdme(idc,1))=wdtp(i)*wid2
25686  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
25687  wdte(i,0)=wdte(i,mdme(idc,1))
25688  wdte(0,0)=wdte(0,0)+wdte(i,0)
25689  ENDIF
25690  200 CONTINUE
25691 
25692  ELSEIF(kfla.EQ.23) THEN
25693 C...Z0:
25694  icase=1
25695  xwc=1d0/(16d0*xw*xw1)
25696  fac=(aem*xwc/3d0)*shr
25697  210 CONTINUE
25698  IF(mint(61).GE.1.AND.icase.EQ.2) THEN
25699  vint(111)=0d0
25700  vint(112)=0d0
25701  vint(114)=0d0
25702  ENDIF
25703  IF(mint(61).EQ.1.AND.icase.EQ.2) THEN
25704  kfi=iabs(mint(15))
25705  IF(kfi.GT.20) kfi=iabs(mint(16))
25706  ei=kchg(kfi,1)/3d0
25707  ai=sign(1d0,ei)
25708  vi=ai-4d0*ei*xwv
25709  sqmz=pmas(23,1)**2
25710  hz=shr*wdtp(0)
25711  IF(mstp(43).EQ.1.OR.mstp(43).EQ.3) vint(111)=1d0
25712  IF(mstp(43).EQ.3) vint(112)=
25713  & 2d0*xwc*sh*(sh-sqmz)/((sh-sqmz)**2+hz**2)
25714  IF(mstp(43).EQ.2.OR.mstp(43).EQ.3) vint(114)=
25715  & xwc**2*sh**2/((sh-sqmz)**2+hz**2)
25716  ENDIF
25717  DO 220 i=1,mdcy(kc,3)
25718  idc=i+mdcy(kc,2)-1
25719  IF(mdme(idc,1).LT.0) goto 220
25720  rm1=pmas(iabs(kfdp(idc,1)),1)**2/sh
25721  rm2=pmas(iabs(kfdp(idc,2)),1)**2/sh
25722  IF(sqrt(rm1)+sqrt(rm2).GT.1d0) goto 220
25723  wid2=1d0
25724  IF(i.LE.8) THEN
25725 C...Z0 -> q + qbar
25726  ef=kchg(i,1)/3d0
25727  af=sign(1d0,ef+0.1d0)
25728  vf=af-4d0*ef*xwv
25729  fcof=3d0*radc
25730  IF(i.GE.6.AND.mstp(35).GE.1) fcof=fcof*pyhfth(sh,sh*rm1,1d0)
25731  IF(i.EQ.6) wid2=wids(6,1)
25732  IF((i.EQ.7.OR.i.EQ.8)) wid2=wids(i,1)
25733  ELSEIF(i.LE.16) THEN
25734 C...Z0 -> l+ + l-, nu + nubar
25735  ef=kchg(i+2,1)/3d0
25736  af=sign(1d0,ef+0.1d0)
25737  vf=af-4d0*ef*xwv
25738  fcof=1d0
25739  IF((i.EQ.15.OR.i.EQ.16)) wid2=wids(2+i,1)
25740  ENDIF
25741  be34=sqrt(max(0d0,1d0-4d0*rm1))
25742  IF(icase.EQ.1) THEN
25743  wdtp(i)=fac*fcof*(vf**2*(1d0+2d0*rm1)+af**2*(1d0-4d0*rm1))*
25744  & be34
25745  ELSEIF(mint(61).EQ.1.AND.icase.EQ.2) THEN
25746  wdtp(i)=fac*fcof*((ei**2*vint(111)*ef**2+ei*vi*vint(112)*
25747  & ef*vf+(vi**2+ai**2)*vint(114)*vf**2)*(1d0+2d0*rm1)+
25748  & (vi**2+ai**2)*vint(114)*af**2*(1d0-4d0*rm1))*be34
25749  ELSEIF(mint(61).EQ.2.AND.icase.EQ.2) THEN
25750  fggf=fcof*ef**2*(1d0+2d0*rm1)*be34
25751  fgzf=fcof*ef*vf*(1d0+2d0*rm1)*be34
25752  fzzf=fcof*(vf**2*(1d0+2d0*rm1)+af**2*(1d0-4d0*rm1))*be34
25753  ENDIF
25754  IF(icase.EQ.1) wdtp(i)=fudge*wdtp(i)
25755  IF(icase.EQ.1) wdtp(0)=wdtp(0)+wdtp(i)
25756  IF(mdme(idc,1).GT.0) THEN
25757  IF((icase.EQ.1.AND.mint(61).NE.1).OR.
25758  & (icase.EQ.2.AND.mint(61).EQ.1)) THEN
25759  wdte(i,mdme(idc,1))=wdtp(i)*wid2
25760  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+
25761  & wdte(i,mdme(idc,1))
25762  wdte(i,0)=wdte(i,mdme(idc,1))
25763  wdte(0,0)=wdte(0,0)+wdte(i,0)
25764  ENDIF
25765  IF(mint(61).EQ.2.AND.icase.EQ.2) THEN
25766  IF(mstp(43).EQ.1.OR.mstp(43).EQ.3) vint(111)=
25767  & vint(111)+fggf*wid2
25768  IF(mstp(43).EQ.3) vint(112)=vint(112)+fgzf*wid2
25769  IF(mstp(43).EQ.2.OR.mstp(43).EQ.3) vint(114)=
25770  & vint(114)+fzzf*wid2
25771  ENDIF
25772  ENDIF
25773  220 CONTINUE
25774  IF(mint(61).GE.1) icase=3-icase
25775  IF(icase.EQ.2) goto 210
25776 
25777  ELSEIF(kfla.EQ.24) THEN
25778 C...W+/-:
25779  fac=(aem/(24d0*xw))*shr
25780  DO 230 i=1,mdcy(kc,3)
25781  idc=i+mdcy(kc,2)-1
25782  IF(mdme(idc,1).LT.0) goto 230
25783  rm1=pmas(iabs(kfdp(idc,1)),1)**2/sh
25784  rm2=pmas(iabs(kfdp(idc,2)),1)**2/sh
25785  IF(sqrt(rm1)+sqrt(rm2).GT.1d0) goto 230
25786  wid2=1d0
25787  IF(i.LE.16) THEN
25788 C...W+/- -> q + qbar'
25789  fcof=3d0*radc*vckm((i-1)/4+1,mod(i-1,4)+1)
25790  IF(kflr.GT.0) THEN
25791  IF(mod(i,4).EQ.3) wid2=wids(6,2)
25792  IF(mod(i,4).EQ.0) wid2=wids(8,2)
25793  IF(i.GE.13) wid2=wid2*wids(7,3)
25794  ELSE
25795  IF(mod(i,4).EQ.3) wid2=wids(6,3)
25796  IF(mod(i,4).EQ.0) wid2=wids(8,3)
25797  IF(i.GE.13) wid2=wid2*wids(7,2)
25798  ENDIF
25799  ELSEIF(i.LE.20) THEN
25800 C...W+/- -> l+/- + nu
25801  fcof=1d0
25802  IF(kflr.GT.0) THEN
25803  IF(i.EQ.20) wid2=wids(17,3)*wids(18,2)
25804  ELSE
25805  IF(i.EQ.20) wid2=wids(17,2)*wids(18,3)
25806  ENDIF
25807  ENDIF
25808  wdtp(i)=fac*fcof*(2d0-rm1-rm2-(rm1-rm2)**2)*
25809  & sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))
25810  wdtp(i)=fudge*wdtp(i)
25811  wdtp(0)=wdtp(0)+wdtp(i)
25812  IF(mdme(idc,1).GT.0) THEN
25813  wdte(i,mdme(idc,1))=wdtp(i)*wid2
25814  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
25815  wdte(i,0)=wdte(i,mdme(idc,1))
25816  wdte(0,0)=wdte(0,0)+wdte(i,0)
25817  ENDIF
25818  230 CONTINUE
25819 
25820  ELSEIF(kfla.EQ.25.OR.kfla.EQ.35.OR.kfla.EQ.36) THEN
25821 C...h0 (or H0, or A0):
25822  shfs=sh
25823  fac=(aem/(8d0*xw))*(shfs/pmas(24,1)**2)*shr
25824  DO 270 i=1,mdcy(kfhigg,3)
25825  idc=i+mdcy(kfhigg,2)-1
25826  IF(mdme(idc,1).LT.0) goto 270
25827  kfc1=pycomp(kfdp(idc,1))
25828  kfc2=pycomp(kfdp(idc,2))
25829  rm1=pmas(kfc1,1)**2/sh
25830  rm2=pmas(kfc2,1)**2/sh
25831  IF(i.NE.16.AND.i.NE.17.AND.sqrt(rm1)+sqrt(rm2).GT.1d0)
25832  & goto 270
25833  wid2=1d0
25834 
25835  IF(i.LE.8) THEN
25836 C...h0 -> q + qbar
25837  wdtp(i)=fac*3d0*(pymrun(kfdp(idc,1),sh)**2/shfs)*
25838  & sqrt(max(0d0,1d0-4d0*rm1))*radc
25839 C...A0 behaves like beta, ho and H0 like beta**3.
25840  IF(ihigg.NE.3) wdtp(i)=wdtp(i)*(1d0-4d0*rm1)
25841  IF(mstp(4).GE.1.OR.ihigg.GE.2) THEN
25842  IF(mod(i,2).EQ.1) wdtp(i)=wdtp(i)*paru(151+10*ihigg)**2
25843  IF(mod(i,2).EQ.0) wdtp(i)=wdtp(i)*paru(152+10*ihigg)**2
25844  IF(imss(1).NE.0.AND.kfc1.EQ.5) THEN
25845  wdtp(i)=wdtp(i)/(1d0+rmss(41))**2
25846  IF(ihigg.NE.3) THEN
25847  wdtp(i)=wdtp(i)*(1d0+rmss(41)*paru(152+10*ihigg)/
25848  & paru(151+10*ihigg))**2
25849  ENDIF
25850  ENDIF
25851  ENDIF
25852  IF(i.EQ.6) wid2=wids(6,1)
25853  IF((i.EQ.7.OR.i.EQ.8)) wid2=wids(i,1)
25854  ELSEIF(i.LE.12) THEN
25855 C...h0 -> l+ + l-
25856  wdtp(i)=fac*rm1*sqrt(max(0d0,1d0-4d0*rm1))*(sh/shfs)
25857 C...A0 behaves like beta, ho and H0 like beta**3.
25858  IF(ihigg.NE.3) wdtp(i)=wdtp(i)*(1d0-4d0*rm1)
25859  IF(mstp(4).GE.1.OR.ihigg.GE.2) wdtp(i)=wdtp(i)*
25860  & paru(153+10*ihigg)**2
25861  IF(i.EQ.12) wid2=wids(17,1)
25862 
25863  ELSEIF(i.EQ.13) THEN
25864 C...h0 -> g + g; quark loop contribution only
25865  etare=0d0
25866  etaim=0d0
25867  DO 240 j=1,2*mstp(1)
25868  eps=(2d0*pmas(j,1))**2/sh
25869 C...Loop integral; function of eps=4m^2/shat; different for A0.
25870  IF(eps.LE.1d0) THEN
25871  IF(eps.GT.1d-4) THEN
25872  root=sqrt(1d0-eps)
25873  rln=log((1d0+root)/(1d0-root))
25874  ELSE
25875  rln=log(4d0/eps-2d0)
25876  ENDIF
25877  phire=-0.25d0*(rln**2-paru(1)**2)
25878  phiim=0.5d0*paru(1)*rln
25879  ELSE
25880  phire=(asin(1d0/sqrt(eps)))**2
25881  phiim=0d0
25882  ENDIF
25883  IF(ihigg.LE.2) THEN
25884  etarej=-0.5d0*eps*(1d0+(1d0-eps)*phire)
25885  etaimj=-0.5d0*eps*(1d0-eps)*phiim
25886  ELSE
25887  etarej=-0.5d0*eps*phire
25888  etaimj=-0.5d0*eps*phiim
25889  ENDIF
25890 C...Couplings (=1 for standard model Higgs).
25891  IF(mstp(4).GE.1.OR.ihigg.GE.2) THEN
25892  IF(mod(j,2).EQ.1) THEN
25893  etarej=etarej*paru(151+10*ihigg)
25894  etaimj=etaimj*paru(151+10*ihigg)
25895  ELSE
25896  etarej=etarej*paru(152+10*ihigg)
25897  etaimj=etaimj*paru(152+10*ihigg)
25898  ENDIF
25899  ENDIF
25900  etare=etare+etarej
25901  etaim=etaim+etaimj
25902  240 CONTINUE
25903  eta2=etare**2+etaim**2
25904  wdtp(i)=fac*(as/paru(1))**2*eta2
25905 
25906  ELSEIF(i.EQ.14) THEN
25907 C...h0 -> gamma + gamma; quark, lepton, W+- and H+- loop contributions
25908  etare=0d0
25909  etaim=0d0
25910  jmax=3*mstp(1)+1
25911  IF(mstp(4).GE.1.OR.ihigg.GE.2) jmax=jmax+1
25912  DO 250 j=1,jmax
25913  IF(j.LE.2*mstp(1)) THEN
25914  ej=kchg(j,1)/3d0
25915  eps=(2d0*pmas(j,1))**2/sh
25916  ELSEIF(j.LE.3*mstp(1)) THEN
25917  jl=2*(j-2*mstp(1))-1
25918  ej=kchg(10+jl,1)/3d0
25919  eps=(2d0*pmas(10+jl,1))**2/sh
25920  ELSEIF(j.EQ.3*mstp(1)+1) THEN
25921  eps=(2d0*pmas(24,1))**2/sh
25922  ELSE
25923  eps=(2d0*pmas(37,1))**2/sh
25924  ENDIF
25925 C...Loop integral; function of eps=4m^2/shat.
25926  IF(eps.LE.1d0) THEN
25927  IF(eps.GT.1d-4) THEN
25928  root=sqrt(1d0-eps)
25929  rln=log((1d0+root)/(1d0-root))
25930  ELSE
25931  rln=log(4d0/eps-2d0)
25932  ENDIF
25933  phire=-0.25d0*(rln**2-paru(1)**2)
25934  phiim=0.5d0*paru(1)*rln
25935  ELSE
25936  phire=(asin(1d0/sqrt(eps)))**2
25937  phiim=0d0
25938  ENDIF
25939  IF(j.LE.3*mstp(1)) THEN
25940 C...Fermion loops: loop integral different for A0; charges.
25941  IF(ihigg.LE.2) THEN
25942  phipre=-0.5d0*eps*(1d0+(1d0-eps)*phire)
25943  phipim=-0.5d0*eps*(1d0-eps)*phiim
25944  ELSE
25945  phipre=-0.5d0*eps*phire
25946  phipim=-0.5d0*eps*phiim
25947  ENDIF
25948  IF(j.LE.2*mstp(1).AND.mod(j,2).EQ.1) THEN
25949  ejc=3d0*ej**2
25950  ejh=paru(151+10*ihigg)
25951  ELSEIF(j.LE.2*mstp(1)) THEN
25952  ejc=3d0*ej**2
25953  ejh=paru(152+10*ihigg)
25954  ELSE
25955  ejc=ej**2
25956  ejh=paru(153+10*ihigg)
25957  ENDIF
25958  IF(mstp(4).EQ.0.AND.ihigg.EQ.1) ejh=1d0
25959  etarej=ejc*ejh*phipre
25960  etaimj=ejc*ejh*phipim
25961  ELSEIF(j.EQ.3*mstp(1)+1) THEN
25962 C...W loops: loop integral and charges.
25963  etarej=0.5d0+0.75d0*eps*(1d0+(2d0-eps)*phire)
25964  etaimj=0.75d0*eps*(2d0-eps)*phiim
25965  IF(mstp(4).GE.1.OR.ihigg.GE.2) THEN
25966  etarej=etarej*paru(155+10*ihigg)
25967  etaimj=etaimj*paru(155+10*ihigg)
25968  ENDIF
25969  ELSE
25970 C...Charged H loops: loop integral and charges.
25971  fachhh=(pmas(24,1)/pmas(37,1))**2*
25972  & paru(158+10*ihigg+2*(ihigg/3))
25973  etarej=eps*(1d0-eps*phire)*fachhh
25974  etaimj=-eps**2*phiim*fachhh
25975  ENDIF
25976  etare=etare+etarej
25977  etaim=etaim+etaimj
25978  250 CONTINUE
25979  eta2=etare**2+etaim**2
25980  wdtp(i)=fac*(aem/paru(1))**2*0.5d0*eta2
25981 
25982  ELSEIF(i.EQ.15) THEN
25983 C...h0 -> gamma + Z0; quark, lepton, W and H+- loop contributions
25984  etare=0d0
25985  etaim=0d0
25986  jmax=3*mstp(1)+1
25987  IF(mstp(4).GE.1.OR.ihigg.GE.2) jmax=jmax+1
25988  DO 260 j=1,jmax
25989  IF(j.LE.2*mstp(1)) THEN
25990  ej=kchg(j,1)/3d0
25991  aj=sign(1d0,ej+0.1d0)
25992  vj=aj-4d0*ej*xwv
25993  eps=(2d0*pmas(j,1))**2/sh
25994  epsp=(2d0*pmas(j,1)/pmas(23,1))**2
25995  ELSEIF(j.LE.3*mstp(1)) THEN
25996  jl=2*(j-2*mstp(1))-1
25997  ej=kchg(10+jl,1)/3d0
25998  aj=sign(1d0,ej+0.1d0)
25999  vj=aj-4d0*ej*xwv
26000  eps=(2d0*pmas(10+jl,1))**2/sh
26001  epsp=(2d0*pmas(10+jl,1)/pmas(23,1))**2
26002  ELSE
26003  eps=(2d0*pmas(24,1))**2/sh
26004  epsp=(2d0*pmas(24,1)/pmas(23,1))**2
26005  ENDIF
26006 C...Loop integrals; functions of eps=4m^2/shat and eps'=4m^2/m_Z^2.
26007  IF(eps.LE.1d0) THEN
26008  root=sqrt(1d0-eps)
26009  IF(eps.GT.1d-4) THEN
26010  rln=log((1d0+root)/(1d0-root))
26011  ELSE
26012  rln=log(4d0/eps-2d0)
26013  ENDIF
26014  phire=-0.25d0*(rln**2-paru(1)**2)
26015  phiim=0.5d0*paru(1)*rln
26016  psire=0.5d0*root*rln
26017  psiim=-0.5d0*root*paru(1)
26018  ELSE
26019  phire=(asin(1d0/sqrt(eps)))**2
26020  phiim=0d0
26021  psire=sqrt(eps-1d0)*asin(1d0/sqrt(eps))
26022  psiim=0d0
26023  ENDIF
26024  IF(epsp.LE.1d0) THEN
26025  root=sqrt(1d0-epsp)
26026  IF(epsp.GT.1d-4) THEN
26027  rln=log((1d0+root)/(1d0-root))
26028  ELSE
26029  rln=log(4d0/epsp-2d0)
26030  ENDIF
26031  phirep=-0.25d0*(rln**2-paru(1)**2)
26032  phiimp=0.5d0*paru(1)*rln
26033  psirep=0.5d0*root*rln
26034  psiimp=-0.5d0*root*paru(1)
26035  ELSE
26036  phirep=(asin(1d0/sqrt(epsp)))**2
26037  phiimp=0d0
26038  psirep=sqrt(epsp-1d0)*asin(1d0/sqrt(epsp))
26039  psiimp=0d0
26040  ENDIF
26041  fxyre=eps*epsp/(8d0*(eps-epsp))*(1d0+eps*epsp/(eps-epsp)*
26042  & (phire-phirep)+2d0*eps/(eps-epsp)*(psire-psirep))
26043  fxyim=eps**2*epsp/(8d0*(eps-epsp)**2)*
26044  & (epsp*(phiim-phiimp)+2d0*(psiim-psiimp))
26045  f1re=-eps*epsp/(2d0*(eps-epsp))*(phire-phirep)
26046  f1im=-eps*epsp/(2d0*(eps-epsp))*(phiim-phiimp)
26047  IF(j.LE.3*mstp(1)) THEN
26048 C...Fermion loops: loop integral different for A0; charges.
26049  IF(ihigg.EQ.3) fxyre=0d0
26050  IF(ihigg.EQ.3) fxyim=0d0
26051  IF(j.LE.2*mstp(1).AND.mod(j,2).EQ.1) THEN
26052  ejc=-3d0*ej*vj
26053  ejh=paru(151+10*ihigg)
26054  ELSEIF(j.LE.2*mstp(1)) THEN
26055  ejc=-3d0*ej*vj
26056  ejh=paru(152+10*ihigg)
26057  ELSE
26058  ejc=-ej*vj
26059  ejh=paru(153+10*ihigg)
26060  ENDIF
26061  IF(mstp(4).EQ.0.AND.ihigg.EQ.1) ejh=1d0
26062  etarej=ejc*ejh*(fxyre-0.25d0*f1re)
26063  etaimj=ejc*ejh*(fxyim-0.25d0*f1im)
26064  ELSEIF(j.EQ.3*mstp(1)+1) THEN
26065 C...W loops: loop integral and charges.
26066  heps=(1d0+2d0/eps)*xw/xw1-(5d0+2d0/eps)
26067  etarej=-xw1*((3d0-xw/xw1)*f1re+heps*fxyre)
26068  etaimj=-xw1*((3d0-xw/xw1)*f1im+heps*fxyim)
26069  IF(mstp(4).GE.1.OR.ihigg.GE.2) THEN
26070  etarej=etarej*paru(155+10*ihigg)
26071  etaimj=etaimj*paru(155+10*ihigg)
26072  ENDIF
26073  ELSE
26074 C...Charged H loops: loop integral and charges.
26075  fachhh=(pmas(24,1)/pmas(37,1))**2*(1d0-2d0*xw)*
26076  & paru(158+10*ihigg+2*(ihigg/3))
26077  etarej=fachhh*fxyre
26078  etaimj=fachhh*fxyim
26079  ENDIF
26080  etare=etare+etarej
26081  etaim=etaim+etaimj
26082  260 CONTINUE
26083  eta2=(etare**2+etaim**2)/(xw*xw1)
26084  wdtp(i)=fac*(aem/paru(1))**2*(1d0-pmas(23,1)**2/sh)**3*eta2
26085  wid2=wids(23,2)
26086 
26087  ELSEIF(i.LE.17) THEN
26088 C...h0 -> Z0 + Z0, W+ + W-
26089  pm1=pmas(iabs(kfdp(idc,1)),1)
26090  pg1=pmas(iabs(kfdp(idc,1)),2)
26091  IF(mint(62).GE.1) THEN
26092  IF(mstp(42).EQ.0.OR.(4d0*(pm1+10d0*pg1)**2.LT.sh.AND.
26093  & ckin(46).LT.ckin(45).AND.ckin(48).LT.ckin(47).AND.
26094  & max(ckin(45),ckin(47)).LT.pm1-10d0*pg1)) THEN
26095  mofsv(ihigg,i-15)=0
26096  widw=(1d0-4d0*rm1+12d0*rm1**2)*sqrt(max(0d0,
26097  & 1d0-4d0*rm1))
26098  wid2=1d0
26099  ELSE
26100  mofsv(ihigg,i-15)=1
26101  rmas=sqrt(max(0d0,sh))
26102  CALL pyofsh(1,kfla,kfdp(idc,1),kfdp(idc,2),rmas,widw,
26103  & wid2)
26104  widwsv(ihigg,i-15)=widw
26105  wid2sv(ihigg,i-15)=wid2
26106  ENDIF
26107  ELSE
26108  IF(mofsv(ihigg,i-15).EQ.0) THEN
26109  widw=(1d0-4d0*rm1+12d0*rm1**2)*sqrt(max(0d0,
26110  & 1d0-4d0*rm1))
26111  wid2=1d0
26112  ELSE
26113  widw=widwsv(ihigg,i-15)
26114  wid2=wid2sv(ihigg,i-15)
26115  ENDIF
26116  ENDIF
26117  wdtp(i)=fac*widw/(2d0*(18-i))
26118  IF(mstp(49).NE.0) wdtp(i)=wdtp(i)*pmas(kfhigg,1)**2/shfs
26119  IF(mstp(4).GE.1.OR.ihigg.GE.2) wdtp(i)=wdtp(i)*
26120  & paru(138+i+10*ihigg)**2
26121  wid2=wid2*wids(7+i,1)
26122 
26123  ELSEIF(i.EQ.18.AND.ihigg.GE.2) THEN
26124 C...H0 -> Z0 + h0, A0-> Z0 + h0
26125  wdtp(i)=fac*0.5d0*sqrt(max(0d0,
26126  & (1d0-rm1-rm2)**2-4d0*rm1*rm2))**3
26127  IF(ihigg.EQ.2) THEN
26128  wdtp(i)=wdtp(i)*paru(179)**2
26129  ELSEIF(ihigg.EQ.3) THEN
26130  wdtp(i)=wdtp(i)*paru(186)**2
26131  ENDIF
26132  wid2=wids(23,2)*wids(25,2)
26133 
26134  ELSEIF(i.EQ.19.AND.ihigg.GE.2) THEN
26135 C...H0 -> h0 + h0, A0-> h0 + h0
26136  wdtp(i)=fac*0.25d0*
26137  & pmas(23,1)**4/sh**2*sqrt(max(0d0,1d0-4d0*rm1))
26138  IF(ihigg.EQ.2) THEN
26139  wdtp(i)=wdtp(i)*paru(176)**2
26140  ELSEIF(ihigg.EQ.3) THEN
26141  wdtp(i)=wdtp(i)*paru(169)**2
26142  ENDIF
26143  wid2=wids(25,1)
26144  ELSEIF((i.EQ.20.OR.i.EQ.21).AND.ihigg.GE.2) THEN
26145 C...H0 -> W+/- + H-/+, A0 -> W+/- + H-/+
26146  wdtp(i)=fac*0.5d0*sqrt(max(0d0,
26147  & (1d0-rm1-rm2)**2-4d0*rm1*rm2))**3
26148  & *paru(195+ihigg)**2
26149  IF(i.EQ.20) THEN
26150  wid2=wids(24,2)*wids(37,3)
26151  ELSEIF(i.EQ.21) THEN
26152  wid2=wids(24,3)*wids(37,2)
26153  ENDIF
26154 
26155  ELSEIF(i.EQ.22.AND.ihigg.EQ.2) THEN
26156 C...H0 -> Z0 + A0.
26157  wdtp(i)=fac*0.5d0*paru(187)**2*sqrt(max(0d0,
26158  & (1d0-rm1-rm2)**2-4d0*rm1*rm2))**3
26159  wid2=wids(36,2)*wids(23,2)
26160 
26161  ELSEIF(i.EQ.23.AND.ihigg.EQ.2) THEN
26162 C...H0 -> h0 + A0.
26163  wdtp(i)=fac*0.5d0*paru(180)**2*
26164  & pmas(23,1)**4/sh**2*sqrt(max(0d0,1d0-4d0*rm1))
26165  wid2=wids(25,2)*wids(36,2)
26166 
26167  ELSEIF(i.EQ.24.AND.ihigg.EQ.2) THEN
26168 C...H0 -> A0 + A0
26169  wdtp(i)=fac*0.25d0*paru(177)**2*
26170  & pmas(23,1)**4/sh**2*sqrt(max(0d0,1d0-4d0*rm1))
26171  wid2=wids(36,1)
26172 
26173 CMRENNA++
26174  ELSE
26175 C...Add in SUSY decays (two-body) by rescaling by phase space factor.
26176  rm10=rm1*sh/pmr**2
26177  rm20=rm2*sh/pmr**2
26178  wfac0=1d0+rm10**2+rm20**2-2d0*(rm10+rm20+rm10*rm20)
26179  wfac=1d0+rm1**2+rm2**2-2d0*(rm1+rm2+rm1*rm2)
26180  IF(wfac.LE.0d0 .OR. wfac0.LE.0d0) THEN
26181  wfac=0d0
26182  ELSE
26183  wfac=wfac/wfac0
26184  ENDIF
26185  wdtp(i)=pmas(kfla,2)*brat(idc)*(shr/pmr)*sqrt(wfac)
26186 CMRENNA--
26187  IF(kfc2.EQ.kfc1) THEN
26188  wid2=wids(kfc1,1)
26189  ELSE
26190  ksgn1=2
26191  IF(kfdp(idc,1).LT.0) ksgn1=3
26192  ksgn2=2
26193  IF(kfdp(idc,2).LT.0) ksgn2=3
26194  wid2=wids(kfc1,ksgn1)*wids(kfc2,ksgn2)
26195  ENDIF
26196  ENDIF
26197  wdtp(i)=fudge*wdtp(i)
26198  wdtp(0)=wdtp(0)+wdtp(i)
26199  IF(mdme(idc,1).GT.0) THEN
26200  wdte(i,mdme(idc,1))=wdtp(i)*wid2
26201  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
26202  wdte(i,0)=wdte(i,mdme(idc,1))
26203  wdte(0,0)=wdte(0,0)+wdte(i,0)
26204  ENDIF
26205  270 CONTINUE
26206 
26207  ELSEIF(kfla.EQ.32) THEN
26208 C...Z'0:
26209  icase=1
26210  xwc=1d0/(16d0*xw*xw1)
26211  fac=(aem*xwc/3d0)*shr
26212  vint(117)=0d0
26213  280 CONTINUE
26214  IF(mint(61).GE.1.AND.icase.EQ.2) THEN
26215  vint(111)=0d0
26216  vint(112)=0d0
26217  vint(113)=0d0
26218  vint(114)=0d0
26219  vint(115)=0d0
26220  vint(116)=0d0
26221  ENDIF
26222  IF(mint(61).EQ.1.AND.icase.EQ.2) THEN
26223  kfai=iabs(mint(15))
26224  ei=kchg(kfai,1)/3d0
26225  ai=sign(1d0,ei+0.1d0)
26226  vi=ai-4d0*ei*xwv
26227  kfaic=1
26228  IF(kfai.LE.10.AND.mod(kfai,2).EQ.0) kfaic=2
26229  IF(kfai.GT.10.AND.mod(kfai,2).NE.0) kfaic=3
26230  IF(kfai.GT.10.AND.mod(kfai,2).EQ.0) kfaic=4
26231  IF(kfai.LE.2.OR.kfai.EQ.11.OR.kfai.EQ.12) THEN
26232  vpi=paru(119+2*kfaic)
26233  api=paru(120+2*kfaic)
26234  ELSEIF(kfai.LE.4.OR.kfai.EQ.13.OR.kfai.EQ.14) THEN
26235  vpi=parj(178+2*kfaic)
26236  api=parj(179+2*kfaic)
26237  ELSE
26238  vpi=parj(186+2*kfaic)
26239  api=parj(187+2*kfaic)
26240  ENDIF
26241  sqmz=pmas(23,1)**2
26242  hz=shr*vint(117)
26243  sqmzp=pmas(32,1)**2
26244  hzp=shr*wdtp(0)
26245  IF(mstp(44).EQ.1.OR.mstp(44).EQ.4.OR.mstp(44).EQ.5.OR.
26246  & mstp(44).EQ.7) vint(111)=1d0
26247  IF(mstp(44).EQ.4.OR.mstp(44).EQ.7) vint(112)=
26248  & 2d0*xwc*sh*(sh-sqmz)/((sh-sqmz)**2+hz**2)
26249  IF(mstp(44).EQ.5.OR.mstp(44).EQ.7) vint(113)=
26250  & 2d0*xwc*sh*(sh-sqmzp)/((sh-sqmzp)**2+hzp**2)
26251  IF(mstp(44).EQ.2.OR.mstp(44).EQ.4.OR.mstp(44).EQ.6.OR.
26252  & mstp(44).EQ.7) vint(114)=xwc**2*sh**2/((sh-sqmz)**2+hz**2)
26253  IF(mstp(44).EQ.6.OR.mstp(44).EQ.7) vint(115)=
26254  & 2d0*xwc**2*sh**2*((sh-sqmz)*(sh-sqmzp)+hz*hzp)/
26255  & (((sh-sqmz)**2+hz**2)*((sh-sqmzp)**2+hzp**2))
26256  IF(mstp(44).EQ.3.OR.mstp(44).EQ.5.OR.mstp(44).EQ.6.OR.
26257  & mstp(44).EQ.7) vint(116)=xwc**2*sh**2/((sh-sqmzp)**2+hzp**2)
26258  ENDIF
26259  DO 290 i=1,mdcy(kc,3)
26260  idc=i+mdcy(kc,2)-1
26261  IF(mdme(idc,1).LT.0) goto 290
26262  rm1=pmas(pycomp(kfdp(idc,1)),1)**2/sh
26263  rm2=pmas(pycomp(kfdp(idc,2)),1)**2/sh
26264  IF(sqrt(rm1)+sqrt(rm2).GT.1d0.OR.mdme(idc,1).LT.0) goto 290
26265  wid2=1d0
26266  IF(i.LE.16) THEN
26267  IF(i.LE.8) THEN
26268 C...Z'0 -> q + qbar
26269  ef=kchg(i,1)/3d0
26270  af=sign(1d0,ef+0.1d0)
26271  vf=af-4d0*ef*xwv
26272  IF(i.LE.2) THEN
26273  vpf=paru(123-2*mod(i,2))
26274  apf=paru(124-2*mod(i,2))
26275  ELSEIF(i.LE.4) THEN
26276  vpf=parj(182-2*mod(i,2))
26277  apf=parj(183-2*mod(i,2))
26278  ELSE
26279  vpf=parj(190-2*mod(i,2))
26280  apf=parj(191-2*mod(i,2))
26281  ENDIF
26282  fcof=3d0*radc
26283  IF(i.GE.6.AND.mstp(35).GE.1) fcof=fcof*
26284  & pyhfth(sh,sh*rm1,1d0)
26285  IF(i.EQ.6) wid2=wids(6,1)
26286  IF((i.EQ.7.OR.i.EQ.8)) wid2=wids(i,1)
26287  ELSEIF(i.LE.16) THEN
26288 C...Z'0 -> l+ + l-, nu + nubar
26289  ef=kchg(i+2,1)/3d0
26290  af=sign(1d0,ef+0.1d0)
26291  vf=af-4d0*ef*xwv
26292  IF(i.LE.10) THEN
26293  vpf=paru(127-2*mod(i,2))
26294  apf=paru(128-2*mod(i,2))
26295  ELSEIF(i.LE.12) THEN
26296  vpf=parj(186-2*mod(i,2))
26297  apf=parj(187-2*mod(i,2))
26298  ELSE
26299  vpf=parj(194-2*mod(i,2))
26300  apf=parj(195-2*mod(i,2))
26301  ENDIF
26302  fcof=1d0
26303  IF((i.EQ.15.OR.i.EQ.16)) wid2=wids(2+i,1)
26304  ENDIF
26305  be34=sqrt(max(0d0,1d0-4d0*rm1))
26306  IF(icase.EQ.1) THEN
26307  wdtpz=fcof*(vf**2*(1d0+2d0*rm1)+af**2*(1d0-4d0*rm1))*be34
26308  wdtp(i)=fac*fcof*(vpf**2*(1d0+2d0*rm1)+
26309  & apf**2*(1d0-4d0*rm1))*be34
26310  ELSEIF(mint(61).EQ.1.AND.icase.EQ.2) THEN
26311  wdtp(i)=fac*fcof*((ei**2*vint(111)*ef**2+ei*vi*vint(112)*
26312  & ef*vf+ei*vpi*vint(113)*ef*vpf+(vi**2+ai**2)*vint(114)*
26313  & vf**2+(vi*vpi+ai*api)*vint(115)*vf*vpf+(vpi**2+api**2)*
26314  & vint(116)*vpf**2)*(1d0+2d0*rm1)+((vi**2+ai**2)*vint(114)*
26315  & af**2+(vi*vpi+ai*api)*vint(115)*af*apf+(vpi**2+api**2)*
26316  & vint(116)*apf**2)*(1d0-4d0*rm1))*be34
26317  ELSEIF(mint(61).EQ.2) THEN
26318  fggf=fcof*ef**2*(1d0+2d0*rm1)*be34
26319  fgzf=fcof*ef*vf*(1d0+2d0*rm1)*be34
26320  fgzpf=fcof*ef*vpf*(1d0+2d0*rm1)*be34
26321  fzzf=fcof*(vf**2*(1d0+2d0*rm1)+af**2*(1d0-4d0*rm1))*be34
26322  fzzpf=fcof*(vf*vpf*(1d0+2d0*rm1)+af*apf*(1d0-4d0*rm1))*
26323  & be34
26324  fzpzpf=fcof*(vpf**2*(1d0+2d0*rm1)+apf**2*(1d0-4d0*rm1))*
26325  & be34
26326  ENDIF
26327  ELSEIF(i.EQ.17) THEN
26328 C...Z'0 -> W+ + W-
26329  wdtpzp=paru(129)**2*xw1**2*
26330  & sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3*
26331  & (1d0+10d0*rm1+10d0*rm2+rm1**2+rm2**2+10d0*rm1*rm2)
26332  IF(icase.EQ.1) THEN
26333  wdtpz=0d0
26334  wdtp(i)=fac*wdtpzp
26335  ELSEIF(mint(61).EQ.1.AND.icase.EQ.2) THEN
26336  wdtp(i)=fac*(vpi**2+api**2)*vint(116)*wdtpzp
26337  ELSEIF(mint(61).EQ.2) THEN
26338  fggf=0d0
26339  fgzf=0d0
26340  fgzpf=0d0
26341  fzzf=0d0
26342  fzzpf=0d0
26343  fzpzpf=wdtpzp
26344  ENDIF
26345  wid2=wids(24,1)
26346  ELSEIF(i.EQ.18) THEN
26347 C...Z'0 -> H+ + H-
26348  czc=2d0*(1d0-2d0*xw)
26349  be34c=(1d0-4d0*rm1)*sqrt(max(0d0,1d0-4d0*rm1))
26350  IF(icase.EQ.1) THEN
26351  wdtpz=0.25d0*paru(142)**2*czc**2*be34c
26352  wdtp(i)=fac*0.25d0*paru(143)**2*czc**2*be34c
26353  ELSEIF(mint(61).EQ.1.AND.icase.EQ.2) THEN
26354  wdtp(i)=fac*0.25d0*(ei**2*vint(111)+paru(142)*ei*vi*
26355  & vint(112)*czc+paru(143)*ei*vpi*vint(113)*czc+paru(142)**2*
26356  & (vi**2+ai**2)*vint(114)*czc**2+paru(142)*paru(143)*
26357  & (vi*vpi+ai*api)*vint(115)*czc**2+paru(143)**2*
26358  & (vpi**2+api**2)*vint(116)*czc**2)*be34c
26359  ELSEIF(mint(61).EQ.2) THEN
26360  fggf=0.25d0*be34c
26361  fgzf=0.25d0*paru(142)*czc*be34c
26362  fgzpf=0.25d0*paru(143)*czc*be34c
26363  fzzf=0.25d0*paru(142)**2*czc**2*be34c
26364  fzzpf=0.25d0*paru(142)*paru(143)*czc**2*be34c
26365  fzpzpf=0.25d0*paru(143)**2*czc**2*be34c
26366  ENDIF
26367  wid2=wids(37,1)
26368  ELSEIF(i.EQ.19) THEN
26369 C...Z'0 -> Z0 + gamma.
26370  ELSEIF(i.EQ.20) THEN
26371 C...Z'0 -> Z0 + h0
26372  flam=sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))
26373  wdtpzp=paru(145)**2*4d0*abs(1d0-2d0*xw)*
26374  & (3d0*rm1+0.25d0*flam**2)*flam
26375  IF(icase.EQ.1) THEN
26376  wdtpz=0d0
26377  wdtp(i)=fac*wdtpzp
26378  ELSEIF(mint(61).EQ.1.AND.icase.EQ.2) THEN
26379  wdtp(i)=fac*(vpi**2+api**2)*vint(116)*wdtpzp
26380  ELSEIF(mint(61).EQ.2) THEN
26381  fggf=0d0
26382  fgzf=0d0
26383  fgzpf=0d0
26384  fzzf=0d0
26385  fzzpf=0d0
26386  fzpzpf=wdtpzp
26387  ENDIF
26388  wid2=wids(23,2)*wids(25,2)
26389  ELSEIF(i.EQ.21.OR.i.EQ.22) THEN
26390 C...Z' -> h0 + A0 or H0 + A0.
26391  be34c=sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3
26392  IF(i.EQ.21) THEN
26393  czah=paru(186)
26394  czpah=paru(188)
26395  ELSE
26396  czah=paru(187)
26397  czpah=paru(189)
26398  ENDIF
26399  IF(icase.EQ.1) THEN
26400  wdtpz=czah**2*be34c
26401  wdtp(i)=fac*czpah**2*be34c
26402  ELSEIF(mint(61).EQ.1.AND.icase.EQ.2) THEN
26403  wdtp(i)=fac*(czah**2*(vi**2+ai**2)*vint(114)+czah*czpah*
26404  & (vi*vpi+ai*api)*vint(115)+czpah**2*(vpi**2+api**2)*
26405  & vint(116))*be34c
26406  ELSEIF(mint(61).EQ.2) THEN
26407  fggf=0d0
26408  fgzf=0d0
26409  fgzpf=0d0
26410  fzzf=czah**2*be34c
26411  fzzpf=czah*czpah*be34c
26412  fzpzpf=czpah**2*be34c
26413  ENDIF
26414  IF(i.EQ.21) wid2=wids(25,2)*wids(36,2)
26415  IF(i.EQ.22) wid2=wids(35,2)*wids(36,2)
26416  ENDIF
26417  IF(icase.EQ.1) THEN
26418  vint(117)=vint(117)+fac*wdtpz
26419  wdtp(i)=fudge*wdtp(i)
26420  wdtp(0)=wdtp(0)+wdtp(i)
26421  ENDIF
26422  IF(mdme(idc,1).GT.0) THEN
26423  IF((icase.EQ.1.AND.mint(61).NE.1).OR.
26424  & (icase.EQ.2.AND.mint(61).EQ.1)) THEN
26425  wdte(i,mdme(idc,1))=wdtp(i)*wid2
26426  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+
26427  & wdte(i,mdme(idc,1))
26428  wdte(i,0)=wdte(i,mdme(idc,1))
26429  wdte(0,0)=wdte(0,0)+wdte(i,0)
26430  ENDIF
26431  IF(mint(61).EQ.2.AND.icase.EQ.2) THEN
26432  IF(mstp(44).EQ.1.OR.mstp(44).EQ.4.OR.mstp(44).EQ.5.OR.
26433  & mstp(44).EQ.7) vint(111)=vint(111)+fggf*wid2
26434  IF(mstp(44).EQ.4.OR.mstp(44).EQ.7) vint(112)=vint(112)+
26435  & fgzf*wid2
26436  IF(mstp(44).EQ.5.OR.mstp(44).EQ.7) vint(113)=vint(113)+
26437  & fgzpf*wid2
26438  IF(mstp(44).EQ.2.OR.mstp(44).EQ.4.OR.mstp(44).EQ.6.OR.
26439  & mstp(44).EQ.7) vint(114)=vint(114)+fzzf*wid2
26440  IF(mstp(44).EQ.6.OR.mstp(44).EQ.7) vint(115)=vint(115)+
26441  & fzzpf*wid2
26442  IF(mstp(44).EQ.3.OR.mstp(44).EQ.5.OR.mstp(44).EQ.6.OR.
26443  & mstp(44).EQ.7) vint(116)=vint(116)+fzpzpf*wid2
26444  ENDIF
26445  ENDIF
26446  290 CONTINUE
26447  IF(mint(61).GE.1) icase=3-icase
26448  IF(icase.EQ.2) goto 280
26449 
26450  ELSEIF(kfla.EQ.34) THEN
26451 C...W'+/-:
26452  fac=(aem/(24d0*xw))*shr
26453  DO 300 i=1,mdcy(kc,3)
26454  idc=i+mdcy(kc,2)-1
26455  IF(mdme(idc,1).LT.0) goto 300
26456  rm1=pmas(pycomp(kfdp(idc,1)),1)**2/sh
26457  rm2=pmas(pycomp(kfdp(idc,2)),1)**2/sh
26458  IF(sqrt(rm1)+sqrt(rm2).GT.1d0) goto 300
26459  wid2=1d0
26460  IF(i.LE.20) THEN
26461  IF(i.LE.16) THEN
26462 C...W'+/- -> q + qbar'
26463  ckmfac = vckm((i-1)/4+1,mod(i-1,4)+1)
26464  fcof=3d0*ckmfac*radc*(paru(131)**2+paru(132)**2)
26465  fcof2=3d0*ckmfac*radc*(paru(131)**2-paru(132)**2)
26466  IF(kflr.GT.0) THEN
26467  IF(mod(i,4).EQ.3) wid2=wids(6,2)
26468  IF(mod(i,4).EQ.0) wid2=wids(8,2)
26469  IF(i.GE.13) wid2=wid2*wids(7,3)
26470  ELSE
26471  IF(mod(i,4).EQ.3) wid2=wids(6,3)
26472  IF(mod(i,4).EQ.0) wid2=wids(8,3)
26473  IF(i.GE.13) wid2=wid2*wids(7,2)
26474  ENDIF
26475  ELSEIF(i.LE.20) THEN
26476 C...W'+/- -> l+/- + nu
26477  fcof=paru(133)**2+paru(134)**2
26478  fcof2=paru(133)**2-paru(134)**2
26479  IF(kflr.GT.0) THEN
26480  IF(i.EQ.20) wid2=wids(17,3)*wids(18,2)
26481  ELSE
26482  IF(i.EQ.20) wid2=wids(17,2)*wids(18,3)
26483  ENDIF
26484  ENDIF
26485  wdtp(i)=fac*0.5*fcof*(2d0-rm1-rm2-(rm1-rm2)**2)
26486  & *sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))
26487  IF (rm1.GT.0d0.AND.rm2.GT.0d0) THEN
26488 C...PS 28/06/2010
26489 C...Inserted (gV2-gA2)*sqrt(m1*m2) term (FCOF2), following M. Chizhov
26490  wdtp(i)=wdtp(i) + fac*0.5*6d0*fcof2*sqrt(rm1*rm2)
26491  & *sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))
26492  ENDIF
26493  ELSEIF(i.EQ.21) THEN
26494 C...W'+/- -> W+/- + Z0
26495  wdtp(i)=fac*paru(135)**2*0.5d0*xw1*(rm1/rm2)*
26496  & sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3*
26497  & (1d0+10d0*rm1+10d0*rm2+rm1**2+rm2**2+10d0*rm1*rm2)
26498  IF(kflr.GT.0) wid2=wids(24,2)*wids(23,2)
26499  IF(kflr.LT.0) wid2=wids(24,3)*wids(23,2)
26500  ELSEIF(i.EQ.23) THEN
26501 C...W'+/- -> W+/- + h0
26502  flam=sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))
26503  wdtp(i)=fac*paru(146)**2*2d0*(3d0*rm1+0.25d0*flam**2)*flam
26504  IF(kflr.GT.0) wid2=wids(24,2)*wids(25,2)
26505  IF(kflr.LT.0) wid2=wids(24,3)*wids(25,2)
26506  ENDIF
26507  wdtp(i)=fudge*wdtp(i)
26508  wdtp(0)=wdtp(0)+wdtp(i)
26509  IF(mdme(idc,1).GT.0) THEN
26510  wdte(i,mdme(idc,1))=wdtp(i)*wid2
26511  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
26512  wdte(i,0)=wdte(i,mdme(idc,1))
26513  wdte(0,0)=wdte(0,0)+wdte(i,0)
26514  ENDIF
26515  300 CONTINUE
26516 
26517  ELSEIF(kfla.EQ.37) THEN
26518 C...H+/-:
26519 C IF(MSTP(49).EQ.0) THEN
26520  shfs=sh
26521 C ELSE
26522 C SHFS=PMAS(37,1)**2
26523 C ENDIF
26524  fac=(aem/(8d0*xw))*(shfs/pmas(24,1)**2)*shr
26525  DO 310 i=1,mdcy(kc,3)
26526  idc=i+mdcy(kc,2)-1
26527  IF(mdme(idc,1).LT.0) goto 310
26528  kfc1=pycomp(kfdp(idc,1))
26529  kfc2=pycomp(kfdp(idc,2))
26530  rm1=pmas(kfc1,1)**2/sh
26531  rm2=pmas(kfc2,1)**2/sh
26532  IF(sqrt(rm1)+sqrt(rm2).GT.1d0) goto 310
26533  wid2=1d0
26534  IF(i.LE.4) THEN
26535 C...H+/- -> q + qbar'
26536  rm1r=pymrun(kfdp(idc,1),sh)**2/sh
26537  rm2r=pymrun(kfdp(idc,2),sh)**2/sh
26538  wdtp(i)=fac*3d0*radc*max(0d0,(rm1r*paru(141)**2+
26539  & rm2r/paru(141)**2)*(1d0-rm1r-rm2r)-4d0*rm1r*rm2r)*
26540  & sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))*(sh/shfs)
26541  IF(kflr.GT.0) THEN
26542  IF(i.EQ.3) wid2=wids(6,2)
26543  IF(i.EQ.4) wid2=wids(7,3)*wids(8,2)
26544  ELSE
26545  IF(i.EQ.3) wid2=wids(6,3)
26546  IF(i.EQ.4) wid2=wids(7,2)*wids(8,3)
26547  ENDIF
26548  ELSEIF(i.LE.8) THEN
26549 C...H+/- -> l+/- + nu
26550  wdtp(i)=fac*((rm1*paru(141)**2+rm2/paru(141)**2)*
26551  & (1d0-rm1-rm2)-4d0*rm1*rm2)*sqrt(max(0d0,
26552  & (1d0-rm1-rm2)**2-4d0*rm1*rm2))*(sh/shfs)
26553  IF(kflr.GT.0) THEN
26554  IF(i.EQ.8) wid2=wids(17,3)*wids(18,2)
26555  ELSE
26556  IF(i.EQ.8) wid2=wids(17,2)*wids(18,3)
26557  ENDIF
26558  ELSEIF(i.EQ.9) THEN
26559 C...H+/- -> W+/- + h0.
26560  wdtp(i)=fac*paru(195)**2*0.5d0*sqrt(max(0d0,
26561  & (1d0-rm1-rm2)**2-4d0*rm1*rm2))**3
26562  IF(kflr.GT.0) wid2=wids(24,2)*wids(25,2)
26563  IF(kflr.LT.0) wid2=wids(24,3)*wids(25,2)
26564 
26565 CMRENNA++
26566  ELSE
26567 C...Add in SUSY decays (two-body) by rescaling by phase space factor.
26568  rm10=rm1*sh/pmr**2
26569  rm20=rm2*sh/pmr**2
26570  wfac0=1d0+rm10**2+rm20**2-2d0*(rm10+rm20+rm10*rm20)
26571  wfac=1d0+rm1**2+rm2**2-2d0*(rm1+rm2+rm1*rm2)
26572  IF(wfac.LE.0d0 .OR. wfac0.LE.0d0) THEN
26573  wfac=0d0
26574  ELSE
26575  wfac=wfac/wfac0
26576  ENDIF
26577  wdtp(i)=pmas(kc,2)*brat(idc)*(shr/pmr)*sqrt(wfac)
26578 CMRENNA--
26579  ksgn1=2
26580  IF(kfls*kfdp(idc,1).LT.0.AND.kchg(kfc1,3).EQ.1) ksgn1=3
26581  ksgn2=2
26582  IF(kfls*kfdp(idc,2).LT.0.AND.kchg(kfc2,3).EQ.1) ksgn2=3
26583  wid2=wids(kfc1,ksgn1)*wids(kfc2,ksgn2)
26584  ENDIF
26585  wdtp(i)=fudge*wdtp(i)
26586  wdtp(0)=wdtp(0)+wdtp(i)
26587  IF(mdme(idc,1).GT.0) THEN
26588  wdte(i,mdme(idc,1))=wdtp(i)*wid2
26589  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
26590  wdte(i,0)=wdte(i,mdme(idc,1))
26591  wdte(0,0)=wdte(0,0)+wdte(i,0)
26592  ENDIF
26593  310 CONTINUE
26594 
26595  ELSEIF(kfla.EQ.41) THEN
26596 C...R:
26597  fac=(aem/(12d0*xw))*shr
26598  DO 320 i=1,mdcy(kc,3)
26599  idc=i+mdcy(kc,2)-1
26600  IF(mdme(idc,1).LT.0) goto 320
26601  rm1=pmas(pycomp(kfdp(idc,1)),1)**2/sh
26602  rm2=pmas(pycomp(kfdp(idc,2)),1)**2/sh
26603  IF(sqrt(rm1)+sqrt(rm2).GT.1d0) goto 320
26604  wid2=1d0
26605  IF(i.LE.6) THEN
26606 C...R -> q + qbar'
26607  fcof=3d0*radc
26608  ELSEIF(i.LE.9) THEN
26609 C...R -> l+ + l'-
26610  fcof=1d0
26611  ENDIF
26612  wdtp(i)=fac*fcof*(2d0-rm1-rm2-(rm1-rm2)**2)*
26613  & sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))
26614  IF(kflr.GT.0) THEN
26615  IF(i.EQ.4) wid2=wids(6,3)
26616  IF(i.EQ.5) wid2=wids(7,3)
26617  IF(i.EQ.6) wid2=wids(6,2)*wids(8,3)
26618  IF(i.EQ.9) wid2=wids(17,3)
26619  ELSE
26620  IF(i.EQ.4) wid2=wids(6,2)
26621  IF(i.EQ.5) wid2=wids(7,2)
26622  IF(i.EQ.6) wid2=wids(6,3)*wids(8,2)
26623  IF(i.EQ.9) wid2=wids(17,2)
26624  ENDIF
26625  wdtp(i)=fudge*wdtp(i)
26626  wdtp(0)=wdtp(0)+wdtp(i)
26627  IF(mdme(idc,1).GT.0) THEN
26628  wdte(i,mdme(idc,1))=wdtp(i)*wid2
26629  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
26630  wdte(i,0)=wdte(i,mdme(idc,1))
26631  wdte(0,0)=wdte(0,0)+wdte(i,0)
26632  ENDIF
26633  320 CONTINUE
26634 
26635  ELSEIF(kfla.EQ.42) THEN
26636 C...LQ (leptoquark).
26637  fac=(aem/4d0)*paru(151)*shr
26638  DO 330 i=1,mdcy(kc,3)
26639  idc=i+mdcy(kc,2)-1
26640  IF(mdme(idc,1).LT.0) goto 330
26641  rm1=pmas(pycomp(kfdp(idc,1)),1)**2/sh
26642  rm2=pmas(pycomp(kfdp(idc,2)),1)**2/sh
26643  IF(sqrt(rm1)+sqrt(rm2).GT.1d0) goto 330
26644  wdtp(i)=fac*sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3
26645  wid2=1d0
26646  ilqq=kfdp(idc,1)*isign(1,kflr)
26647  IF(ilqq.GE.6) wid2=wids(ilqq,2)
26648  IF(ilqq.LE.-6) wid2=wids(-ilqq,3)
26649  ilql=kfdp(idc,2)*isign(1,kflr)
26650  IF(ilql.GE.17) wid2=wid2*wids(ilql,2)
26651  IF(ilql.LE.-17) wid2=wid2*wids(-ilql,3)
26652  wdtp(i)=fudge*wdtp(i)
26653  wdtp(0)=wdtp(0)+wdtp(i)
26654  IF(mdme(idc,1).GT.0) THEN
26655  wdte(i,mdme(idc,1))=wdtp(i)*wid2
26656  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
26657  wdte(i,0)=wdte(i,mdme(idc,1))
26658  wdte(0,0)=wdte(0,0)+wdte(i,0)
26659  ENDIF
26660  330 CONTINUE
26661 
26662 C...UED: kk state width decays : flav: 451 476
26663  ELSEIF(iued(1).EQ.1.AND.
26664  & pycomp(abs(kfla)).GE.kkflmi.AND.
26665  & pycomp(abs(kfla)).LE.kkflma) THEN
26666  kcla=pycomp(kfla)
26667 C...q*_S,q*_D,l*_S,l*_D,gamma*,g*,Z*,W*
26668  rmflas=pmas(kcla,1)
26669  facsh=sh/pmas(kcla,1)**2
26670  alphem=pyalem(rmflas**2)
26671  alphs=pyalps(rmflas**2)
26672 
26673 C...uedcor parameters (alpha_s is calculated at mkk scale)
26674 C...alpha_em is calculated at z pole !
26675  alphem=paru(101)
26676  facsh=1.
26677 
26678  DO 1070 i=1,mdcy(kcla,3)
26679  idc=i+mdcy(kcla,2)-1
26680 
26681  IF(mdme(idc,1).LT.0) goto 1070
26682  kfc1=pycomp(abs(kfdp(idc,1)))
26683  kfc2=pycomp(abs(kfdp(idc,2)))
26684  rm1=pmas(kfc1,1)**2/sh
26685  rm2=pmas(kfc2,1)**2/sh
26686  IF(sqrt(rm1)+sqrt(rm2).GT.1d0)
26687  & goto 1070
26688  wid2=1d0
26689 
26690 C...N.B. RINV=RUED(1)
26691  rmkk=rued(1)
26692  rmwkk=pmas(475,1)
26693  rmzkk=pmas(474,1)
26694  sw2=paru(102)
26695  cw2=1.-sw2
26696  kkcla=kcla-kkflmi+1
26697  IF(abs(kfc1).GE.kkflmi)kkpart=kfc1
26698  IF(abs(kfc2).GE.kkflmi)kkpart=kfc2
26699  IF(kkcla.LE.6) THEN
26700 C...q*_S -> q + gamma* (in first time sw21=0)
26701  fac=0.25*alphem*rmflas*0.5*cw21/cw2*kchg(kcla,1)**2/9.
26702 C...Eventually change the following by enabling a choice of open or closed.
26703 C...Only the gamma_kk channel is open.
26704  IF(mod(i,2).EQ.0)
26705  + wdtp(i)=fac*fkac2(rmflas,rmkk)*fkac1(rmkk,rmflas)**2
26706  wdtp(i)=facsh*wdtp(i)
26707  wid2=wids(473,2)
26708  ELSEIF(kkcla.GT.6.AND.kkcla.LE.12)THEN
26709 C...q*_D -> q + Z*/W*
26710  fac=0.25*alphem*rmflas/(4.*sw2)
26711  gammaw=fac*fkac2(rmflas,rmwkk)*fkac1(rmwkk,rmflas)**2
26712  IF(i.EQ.1)THEN
26713 C...q*_D -> q + Z*
26714  wdtp(i)=0.5*gammaw
26715  wid2=wids(474,2)
26716  ELSEIF(i.EQ.2)THEN
26717 C...q*_D -> q + W*
26718  wdtp(i)=gammaw
26719  wid2=wids(475,2)
26720  ENDIF
26721  wdtp(i)=facsh*wdtp(i)
26722 C...q*_D -> q + gamma* is closed
26723  ELSEIF(kkcla.GT.12.AND.kkcla.LE.21)THEN
26724 C...l*_S,l*_D -> gamma* + l*_S/l*_D(=nu_l,l)
26725  fac=alphem/4.*rmflas/cw2/8.
26726  rmgakk=pmas(473,1)
26727  wdtp(i)=fac*fkac2(rmflas,rmgakk)*
26728  + fkac1(rmgakk,rmflas)**2
26729  wdtp(i)=facsh*wdtp(i)
26730  wid2=wids(473,2)
26731  ELSEIF(kkcla.EQ.22)THEN
26732  rmqst=pmas(kkpart,1)
26733  wid2=wids(kkpart,2)
26734 C...g* -> q*_S/q*_D + q
26735  fac=10.*alphs/12.*rmflas
26736  wdtp(i)=fac*fkac1(rmqst,rmflas)**2*fkac2(rmqst,rmflas)
26737  wdtp(i)=facsh*wdtp(i)
26738  ELSEIF(kkcla.EQ.23)THEN
26739 C...gamma* decays to graviton + gamma : initial value is used
26740  ichi=iued(4)/2
26741  wdtp(i)=rmflas*(rmflas/rued(2))**(iued(4)+2)
26742  & *chidel(ichi)
26743  ELSEIF(kkcla.EQ.24)THEN
26744 C...Z* -> l*_S + l is closed
26745 C... Z* -> l*_D + l
26746  IF(i.LE.3)goto 1070
26747 c... After closing the channels for a Z* decaying into positively charged
26748 C... KK lepton singlets, close the channels for a Z* decaying into negatively
26749 C... charged KK lepton singlets + positively charged SM particles
26750  IF(i.GE.10.AND.i.LE.12)goto 1070
26751  fac=3./2.*alphem/24./sw2*rmzkk
26752  rmlst=pmas(kkpart,1)
26753  wdtp(i)=fac*fkac1(rmlst,rmzkk)**2*fkac2(rmlst,rmzkk)
26754  wdtp(i)=facsh*wdtp(i)
26755  wid2=wids(kkpart,2)
26756  ELSEIF(kkcla.EQ.25)THEN
26757 C...W* -> l*_D lbar
26758  fac=3.*alphem/12./sw2*rmwkk
26759  rmlst=pmas(kkpart,1)
26760  wdtp(i)=fac*fkac1(rmlst,rmwkk)**2*fkac2(rmlst,rmwkk)
26761  wdtp(i)=facsh*wdtp(i)
26762  wid2=wids(kkpart,2)
26763  ENDIF
26764  wdtp(0)=wdtp(0)+wdtp(i)
26765  IF(mdme(idc,1).GT.0) THEN
26766  wdte(i,mdme(idc,1))=wdtp(i)*wid2
26767  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
26768  wdte(i,0)=wdte(i,mdme(idc,1))
26769  wdte(0,0)=wdte(0,0)+wdte(i,0)
26770  ENDIF
26771  1070 CONTINUE
26772  iuedpr(kkcla)=1
26773 
26774  ELSEIF(kfla.EQ.ktechn+111.OR.kfla.EQ.ktechn+221) THEN
26775 C...Techni-pi0 and techni-pi0':
26776  fac=(1d0/(32d0*paru(1)*rtcm(1)**2))*shr
26777  DO 340 i=1,mdcy(kc,3)
26778  idc=i+mdcy(kc,2)-1
26779  IF(mdme(idc,1).LT.0) goto 340
26780  pm1=pmas(pycomp(kfdp(idc,1)),1)
26781  pm2=pmas(pycomp(kfdp(idc,2)),1)
26782  rm1=pm1**2/sh
26783  rm2=pm2**2/sh
26784  IF(sqrt(rm1)+sqrt(rm2).GT.1d0) goto 340
26785  wid2=1d0
26786 C...pi_tc -> g + g
26787  IF(i.EQ.8) THEN
26788  facp=(as/(4d0*paru(1))*itcm(1)/rtcm(1))**2
26789  & /(8d0*paru(1))*sh*shr
26790  IF(kfla.EQ.ktechn+111) THEN
26791  facp=facp*rtcm(9)
26792  ELSE
26793  facp=facp*rtcm(10)
26794  ENDIF
26795  wdtp(i)=facp
26796  ELSE
26797 C...pi_tc -> f + fbar.
26798  fcof=1d0
26799  ika=iabs(kfdp(idc,1))
26800  IF(ika.LT.10) fcof=3d0*radc
26801  hm1=pm1
26802  hm2=pm2
26803  IF(ika.GE.4.AND.ika.LE.6) THEN
26804  fcof=fcof*rtcm(1+ika)**2
26805  hm1=pymrun(kfdp(idc,1),sh)
26806  hm2=pymrun(kfdp(idc,2),sh)
26807  ELSEIF(ika.EQ.15) THEN
26808  fcof=fcof*rtcm(8)**2
26809  ENDIF
26810  wdtp(i)=fac*fcof*(hm1+hm2)**2*
26811  & sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))
26812  ENDIF
26813  wdtp(i)=fudge*wdtp(i)
26814  wdtp(0)=wdtp(0)+wdtp(i)
26815  IF(mdme(idc,1).GT.0) THEN
26816  wdte(i,mdme(idc,1))=wdtp(i)*wid2
26817  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
26818  wdte(i,0)=wdte(i,mdme(idc,1))
26819  wdte(0,0)=wdte(0,0)+wdte(i,0)
26820  ENDIF
26821  340 CONTINUE
26822 
26823  ELSEIF(kfla.EQ.ktechn+211) THEN
26824 C...pi+_tc
26825  fac=(1d0/(32d0*paru(1)*rtcm(1)**2))*shr
26826  DO 350 i=1,mdcy(kc,3)
26827  idc=i+mdcy(kc,2)-1
26828  IF(mdme(idc,1).LT.0) goto 350
26829  pm1=pmas(pycomp(kfdp(idc,1)),1)
26830  pm2=pmas(pycomp(kfdp(idc,2)),1)
26831  pm3=0d0
26832  IF(i.EQ.5) pm3=pmas(pycomp(kfdp(idc,3)),1)
26833  rm1=pm1**2/sh
26834  rm2=pm2**2/sh
26835  rm3=pm3**2/sh
26836  IF(sqrt(rm1)+sqrt(rm2)+sqrt(rm3).GT.1d0) goto 350
26837  wid2=1d0
26838 C...pi_tc -> f + f'.
26839  fcof=1d0
26840  IF(iabs(kfdp(idc,1)).LT.10) fcof=3d0*radc
26841 C...pi_tc+ -> W b b~
26842  IF(i.EQ.5.AND.shr.LT.pmas(6,1)+pmas(5,1)) THEN
26843  fcof=3d0*radc
26844  xmt2=pmas(6,1)**2/sh
26845  facp=fac/(4d0*paru(1))*fcof*xmt2*rtcm(7)**2
26846  kfc3=pycomp(kfdp(idc,3))
26847  check = sqrt(rm1)+sqrt(rm2)+sqrt(rm3)
26848  check = sqrt(rm1)
26849  t0 = (1d0-check**2)*
26850  & (xmt2*(6d0*xmt2**2+3d0*xmt2*rm1-4d0*rm1**2)-
26851  & (5d0*xmt2**2+2d0*xmt2*rm1-8d0*rm1**2))/(4d0*xmt2**2)
26852  t1 = (1d0-xmt2)*(rm1-xmt2)*((xmt2**2+xmt2*rm1+4d0*rm1**2)
26853  & -3d0*xmt2**2*(xmt2+rm1))/(2d0*xmt2**3)
26854  t3 = rm1**2/xmt2**3*(3d0*xmt2-4d0*rm1+4d0*xmt2*rm1)
26855  wdtp(i)=facp*(t0 + t1*log((xmt2-check**2)/(xmt2-1d0))
26856  & +t3*log(check))
26857  IF(kflr.GT.0) THEN
26858  wid2=wids(24,2)
26859  ELSE
26860  wid2=wids(24,3)
26861  ENDIF
26862  ELSE
26863  fcof=1d0
26864  ika=iabs(kfdp(idc,1))
26865  IF(ika.LT.10) fcof=3d0*radc
26866  hm1=pm1
26867  hm2=pm2
26868  IF(i.GE.1.AND.i.LE.5) THEN
26869  IF(i.LE.2) THEN
26870  fcof=fcof*rtcm(5)**2
26871  ELSEIF(i.LE.4) THEN
26872  fcof=fcof*rtcm(6)**2
26873  ELSEIF(i.EQ.5) THEN
26874  fcof=fcof*rtcm(7)**2
26875  ENDIF
26876  hm1=pymrun(kfdp(idc,1),sh)
26877  hm2=pymrun(kfdp(idc,2),sh)
26878  ELSEIF(i.EQ.8) THEN
26879  fcof=fcof*rtcm(8)**2
26880  ENDIF
26881  wdtp(i)=fac*fcof*(hm1+hm2)**2*
26882  & sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))
26883  ENDIF
26884  wdtp(i)=fudge*wdtp(i)
26885  wdtp(0)=wdtp(0)+wdtp(i)
26886  IF(mdme(idc,1).GT.0) THEN
26887  wdte(i,mdme(idc,1))=wdtp(i)*wid2
26888  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
26889  wdte(i,0)=wdte(i,mdme(idc,1))
26890  wdte(0,0)=wdte(0,0)+wdte(i,0)
26891  ENDIF
26892  350 CONTINUE
26893 
26894  ELSEIF(kfla.EQ.ktechn+331) THEN
26895 C...Techni-eta.
26896  fac=(sh/parp(46)**2)*shr
26897  DO 360 i=1,mdcy(kc,3)
26898  idc=i+mdcy(kc,2)-1
26899  IF(mdme(idc,1).LT.0) goto 360
26900  rm1=pmas(pycomp(kfdp(idc,1)),1)**2/sh
26901  rm2=pmas(pycomp(kfdp(idc,2)),1)**2/sh
26902  IF(sqrt(rm1)+sqrt(rm2).GT.1d0) goto 360
26903  wid2=1d0
26904  IF(i.LE.2) THEN
26905  wdtp(i)=fac*rm1*sqrt(max(0d0,1d0-4d0*rm1))/(4d0*paru(1))
26906  IF(i.EQ.2) wid2=wids(6,1)
26907  ELSE
26908  wdtp(i)=fac*5d0*as**2/(96d0*paru(1)**3)
26909  ENDIF
26910  wdtp(i)=fudge*wdtp(i)
26911  wdtp(0)=wdtp(0)+wdtp(i)
26912  IF(mdme(idc,1).GT.0) THEN
26913  wdte(i,mdme(idc,1))=wdtp(i)*wid2
26914  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
26915  wdte(i,0)=wdte(i,mdme(idc,1))
26916  wdte(0,0)=wdte(0,0)+wdte(i,0)
26917  ENDIF
26918  360 CONTINUE
26919 
26920  ELSEIF(kfla.EQ.ktechn+113) THEN
26921 C...Techni-rho0:
26922  alprht=2.16d0*(3d0/itcm(1))
26923  fac=(alprht/12d0)*shr
26924  facf=(1d0/6d0)*(aem**2/alprht)*shr
26925  sqmz=pmas(23,1)**2
26926  sqmw=pmas(24,1)**2
26927  shp=sh
26928  CALL pywidx(23,shp,wdtpp,wdtep)
26929  gmmz=shr*wdtpp(0)
26930  xwrht=(1d0-2d0*xw)/(4d0*xw*(1d0-xw))
26931  bwzr=xwrht*sh*(sh-sqmz)/((sh-sqmz)**2+gmmz**2)
26932  bwzi=xwrht*sh*gmmz/((sh-sqmz)**2+gmmz**2)
26933  DO 370 i=1,mdcy(kc,3)
26934  idc=i+mdcy(kc,2)-1
26935  IF(mdme(idc,1).LT.0) goto 370
26936  rm1=pmas(pycomp(kfdp(idc,1)),1)**2/sh
26937  rm2=pmas(pycomp(kfdp(idc,2)),1)**2/sh
26938  IF(sqrt(rm1)+sqrt(rm2).GT.1d0) goto 370
26939  wid2=1d0
26940  IF(i.EQ.1) THEN
26941 C...rho_tc0 -> W+ + W-.
26942 C... Multiplied by 2 for W^+_T W^-_L + W^+_L W^-_T
26943  wdtp(i)=fac*rtcm(3)**4*
26944  & sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3+
26945  & 2d0*aem*sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))*
26946  & ((1d0-rm1-rm2)**2-4d0*rm1*rm2 + 6d0*sqmw/sh)*
26947  & rtcm(3)**2/4d0/xw/24d0/rtcm(13)**2*shr**3
26948  wid2=wids(24,1)
26949  ELSEIF(i.EQ.2) THEN
26950 C...rho_tc0 -> W+ + pi_tc-.
26951 C... Multiplied by 2 for pi_T^+ W^-_T + pi_T^- W^+_T
26952  wdtp(i)=fac*rtcm(3)**2*(1d0-rtcm(3)**2)*
26953  & sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3+
26954  & aem*sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))*
26955  & ((1d0-rm1-rm2)**2-4d0*rm1*rm2 + 6d0*rm1)*
26956  & (1d0-rtcm(3)**2)/4d0/xw/24d0/rtcm(13)**2*shr**3
26957  wid2=wids(24,2)*wids(pycomp(ktechn+211),3)
26958  ELSEIF(i.EQ.3) THEN
26959 C...rho_tc0 -> pi_tc+ + W-.
26960  wdtp(i)=fac*rtcm(3)**2*(1d0-rtcm(3)**2)*
26961  & sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3+
26962  & aem*sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))*
26963  & ((1d0-rm1-rm2)**2-4d0*rm1*rm2 + 6d0*rm2)*
26964  & (1d0-rtcm(3)**2)/4d0/xw/24d0/rtcm(13)**2*shr**3
26965  wid2=wids(pycomp(ktechn+211),2)*wids(24,3)
26966  ELSEIF(i.EQ.4) THEN
26967 C...rho_tc0 -> pi_tc+ + pi_tc-.
26968  wdtp(i)=fac*(1d0-rtcm(3)**2)**2*
26969  & sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3
26970  wid2=wids(pycomp(ktechn+211),1)
26971  ELSEIF(i.EQ.5) THEN
26972 C...rho_tc0 -> gamma + pi_tc0
26973  wdtp(i)=aem*sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3*
26974  & (2d0*rtcm(2)-1d0)**2*(1d0-rtcm(3)**2)/24d0/rtcm(12)**2*
26975  & shr**3
26976  wid2=wids(pycomp(ktechn+111),2)
26977  ELSEIF(i.EQ.6) THEN
26978 C...rho_tc0 -> gamma + pi_tc0'
26979  wdtp(i)=aem*sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3*
26980  & (1d0-rtcm(4)**2)/24d0/rtcm(12)**2*shr**3
26981  wid2=wids(pycomp(ktechn+221),2)
26982  ELSEIF(i.EQ.7) THEN
26983 C...rho_tc0 -> Z0 + pi_tc0
26984  wdtp(i)=aem*sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3*
26985  & (2d0*rtcm(2)-1d0)**2*(1d0-rtcm(3)**2)/24d0/rtcm(12)**2*
26986  & xw/xw1*shr**3
26987  wid2=wids(23,2)*wids(pycomp(ktechn+111),2)
26988  ELSEIF(i.EQ.8) THEN
26989 C...rho_tc0 -> Z0 + pi_tc0'
26990  wdtp(i)=aem*sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3*
26991  & (1d0-rtcm(4)**2)/24d0/rtcm(12)**2*(1d0-2d0*xw)**2/4d0/
26992  & xw/xw1*shr**3
26993  wid2=wids(23,2)*wids(pycomp(ktechn+221),2)
26994  ELSEIF(i.EQ.9) THEN
26995 C...rho_tc0 -> gamma + Z0
26996  wdtp(i)=aem*sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3*
26997  & (2d0*rtcm(2)-1d0)**2*rtcm(3)**2/24d0/rtcm(12)**2*shr**3
26998  wid2=wids(23,2)
26999  ELSEIF(i.EQ.10) THEN
27000 C...rho_tc0 -> Z0 + Z0
27001  wdtp(i)=aem*sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3*
27002  & (2d0*rtcm(2)-1d0)**2*rtcm(3)**2*xw/xw1/24d0/rtcm(12)**2*
27003  & shr**3
27004  wid2=wids(23,1)
27005  ELSE
27006 C...rho_tc0 -> f + fbar.
27007  wid2=1d0
27008  IF(i.LE.18) THEN
27009  ia=i-10
27010  fcof=3d0*radc
27011  IF(ia.GE.6.AND.ia.LE.8) wid2=wids(ia,1)
27012  ELSE
27013  ia=i-6
27014  fcof=1d0
27015  IF(ia.GE.17) wid2=wids(ia,1)
27016  ENDIF
27017  ei=kchg(ia,1)/3d0
27018  ai=sign(1d0,ei+0.1d0)
27019  vi=ai-4d0*ei*xwv
27020  vali=0.5d0*(vi+ai)
27021  vari=0.5d0*(vi-ai)
27022  wdtp(i)=facf*fcof*sqrt(max(0d0,1d0-4d0*rm1))*((1d0-rm1)*
27023  & ((ei+vali*bwzr)**2+(vali*bwzi)**2+
27024  & (ei+vari*bwzr)**2+(vari*bwzi)**2)+6d0*rm1*(
27025  & (ei+vali*bwzr)*(ei+vari*bwzr)+vali*vari*bwzi**2))
27026  ENDIF
27027  wdtp(i)=fudge*wdtp(i)
27028  wdtp(0)=wdtp(0)+wdtp(i)
27029  IF(mdme(idc,1).GT.0) THEN
27030  wdte(i,mdme(idc,1))=wdtp(i)*wid2
27031  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
27032  wdte(i,0)=wdte(i,mdme(idc,1))
27033  wdte(0,0)=wdte(0,0)+wdte(i,0)
27034  ENDIF
27035  370 CONTINUE
27036 
27037  ELSEIF(kfla.EQ.ktechn+213) THEN
27038 C...Techni-rho+/-:
27039  alprht=2.16d0*(3d0/itcm(1))
27040  fac=(alprht/12d0)*shr
27041  sqmz=pmas(23,1)**2
27042  sqmw=pmas(24,1)**2
27043  shp=sh
27044  CALL pywidx(24,shp,wdtpp,wdtep)
27045  gmmw=shr*wdtpp(0)
27046  facf=(1d0/12d0)*(aem**2/alprht)*shr*
27047  & (0.125d0/xw**2)*sh**2/((sh-sqmw)**2+gmmw**2)
27048  DO 380 i=1,mdcy(kc,3)
27049  idc=i+mdcy(kc,2)-1
27050  IF(mdme(idc,1).LT.0) goto 380
27051  rm1=pmas(pycomp(kfdp(idc,1)),1)**2/sh
27052  rm2=pmas(pycomp(kfdp(idc,2)),1)**2/sh
27053  IF(sqrt(rm1)+sqrt(rm2).GT.1d0) goto 380
27054  wid2=1d0
27055  pcm=.5d0*sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))
27056 c WDTP(I)=AEM*PCM*(AA2*(PCM**2+1.5D0*RM1)+PCM**2*VA2)
27057 c & /3D0*SHR**3
27058  IF(i.EQ.1) THEN
27059 C...rho_tc+ -> W+ + Z0.
27060 C......Goldstone
27061  wdtp(i)=fac*rtcm(3)**4*
27062  & sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3
27063  va2=rtcm(3)**2*(2d0*rtcm(2)-1d0)**2*xw/xw1/rtcm(12)**2
27064  aa2=rtcm(3)**2/rtcm(13)**2/4d0/xw/xw1
27065 C......W_L Z_T
27066  wdtp(i)=wdtp(i)+aem*pcm*(aa2*(pcm**2+1.5d0*rm2)+pcm**2*va2)
27067  & /3d0*shr**3
27068  va2=0d0
27069  aa2=rtcm(3)**2/rtcm(13)**2/4d0/xw
27070 C......W_T Z_L
27071  wdtp(i)=wdtp(i)+aem*pcm*(aa2*(pcm**2+1.5d0*rm1)+pcm**2*va2)
27072  & /3d0*shr**3
27073  IF(kflr.GT.0) THEN
27074  wid2=wids(24,2)*wids(23,2)
27075  ELSE
27076  wid2=wids(24,3)*wids(23,2)
27077  ENDIF
27078  ELSEIF(i.EQ.2) THEN
27079 C...rho_tc+ -> W+ + pi_tc0.
27080  wdtp(i)=fac*rtcm(3)**2*(1d0-rtcm(3)**2)*
27081  & sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3+
27082  & aem*sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))*
27083  & ((1d0-rm1-rm2)**2-4d0*rm1*rm2 + 6d0*sqmw/sh)*
27084  & (1d0-rtcm(3)**2)/4d0/xw/24d0/rtcm(13)**2*shr**3
27085  IF(kflr.GT.0) THEN
27086  wid2=wids(24,2)*wids(pycomp(ktechn+111),2)
27087  ELSE
27088  wid2=wids(24,3)*wids(pycomp(ktechn+111),2)
27089  ENDIF
27090  ELSEIF(i.EQ.3) THEN
27091 C...rho_tc+ -> pi_tc+ + Z0.
27092  wdtp(i)=fac*rtcm(3)**2*(1d0-rtcm(3)**2)*
27093  & sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3+
27094  & aem*sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))*
27095  & ((1d0-rm1-rm2)**2-4d0*rm1*rm2 + 6d0*sqmz/sh)*
27096  & (1d0-rtcm(3)**2)/4d0/xw/xw1/24d0/rtcm(13)**2*shr**3+
27097  & aem*sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3*
27098  & (2d0*rtcm(2)-1d0)**2*(1d0-rtcm(3)**2)/24d0/rtcm(12)**2*
27099  & shr**3*xw/xw1
27100  IF(kflr.GT.0) THEN
27101  wid2=wids(pycomp(ktechn+211),2)*wids(23,2)
27102  ELSE
27103  wid2=wids(pycomp(ktechn+211),3)*wids(23,2)
27104  ENDIF
27105  ELSEIF(i.EQ.4) THEN
27106 C...rho_tc+ -> pi_tc+ + pi_tc0.
27107  wdtp(i)=fac*(1d0-rtcm(3)**2)**2*
27108  & sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3
27109  IF(kflr.GT.0) THEN
27110  wid2=wids(pycomp(ktechn+211),2)*wids(pycomp(ktechn+111),2)
27111  ELSE
27112  wid2=wids(pycomp(ktechn+211),3)*wids(pycomp(ktechn+111),2)
27113  ENDIF
27114  ELSEIF(i.EQ.5) THEN
27115 C...rho_tc+ -> pi_tc+ + gamma
27116  wdtp(i)=aem*sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3*
27117  & (2d0*rtcm(2)-1d0)**2*(1d0-rtcm(3)**2)/24d0/rtcm(12)**2*
27118  & shr**3
27119  IF(kflr.GT.0) THEN
27120  wid2=wids(pycomp(ktechn+211),2)
27121  ELSE
27122  wid2=wids(pycomp(ktechn+211),3)
27123  ENDIF
27124  ELSEIF(i.EQ.6) THEN
27125 C...rho_tc+ -> W+ + pi_tc0'
27126  wdtp(i)=aem*sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3*
27127  & (1d0-rtcm(4)**2)/4d0/xw/24d0/rtcm(12)**2*shr**3
27128  IF(kflr.GT.0) THEN
27129  wid2=wids(24,2)*wids(pycomp(ktechn+221),2)
27130  ELSE
27131  wid2=wids(24,3)*wids(pycomp(ktechn+221),2)
27132  ENDIF
27133  ELSEIF(i.EQ.7) THEN
27134 C...rho_tc+ -> W+ + gamma
27135  wdtp(i)=aem*sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3*
27136  & (2d0*rtcm(2)-1d0)**2*rtcm(3)**2/24d0/rtcm(12)**2*shr**3
27137  IF(kflr.GT.0) THEN
27138  wid2=wids(24,2)
27139  ELSE
27140  wid2=wids(24,3)
27141  ENDIF
27142  ELSE
27143 C...rho_tc+ -> f + fbar'.
27144  ia=i-7
27145  wid2=1d0
27146  IF(ia.LE.16) THEN
27147  fcof=3d0*radc*vckm((ia-1)/4+1,mod(ia-1,4)+1)
27148  IF(kflr.GT.0) THEN
27149  IF(mod(ia,4).EQ.3) wid2=wids(6,2)
27150  IF(mod(ia,4).EQ.0) wid2=wids(8,2)
27151  IF(ia.GE.13) wid2=wid2*wids(7,3)
27152  ELSE
27153  IF(mod(ia,4).EQ.3) wid2=wids(6,3)
27154  IF(mod(ia,4).EQ.0) wid2=wids(8,3)
27155  IF(ia.GE.13) wid2=wid2*wids(7,2)
27156  ENDIF
27157  ELSE
27158  fcof=1d0
27159  IF(kflr.GT.0) THEN
27160  IF(ia.EQ.20) wid2=wids(17,3)*wids(18,2)
27161  ELSE
27162  IF(ia.EQ.20) wid2=wids(17,2)*wids(18,3)
27163  ENDIF
27164  ENDIF
27165  wdtp(i)=facf*fcof*(2d0-rm1-rm2-(rm1-rm2)**2)*
27166  & sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))
27167  ENDIF
27168  wdtp(i)=fudge*wdtp(i)
27169  wdtp(0)=wdtp(0)+wdtp(i)
27170  IF(mdme(idc,1).GT.0) THEN
27171  wdte(i,mdme(idc,1))=wdtp(i)*wid2
27172  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
27173  wdte(i,0)=wdte(i,mdme(idc,1))
27174  wdte(0,0)=wdte(0,0)+wdte(i,0)
27175  ENDIF
27176  380 CONTINUE
27177 
27178  ELSEIF(kfla.EQ.ktechn+223) THEN
27179 C...Techni-omega:
27180  alprht=2.16d0*(3d0/itcm(1))
27181  fac=(alprht/12d0)*shr
27182  facf=(1d0/6d0)*(aem**2/alprht)*shr*(2d0*rtcm(2)-1d0)**2
27183  sqmz=pmas(23,1)**2
27184  shp=sh
27185  CALL pywidx(23,shp,wdtpp,wdtep)
27186  gmmz=shr*wdtpp(0)
27187  bwzr=(0.5d0/(1d0-xw))*sh*(sh-sqmz)/((sh-sqmz)**2+gmmz**2)
27188  bwzi=-(0.5d0/(1d0-xw))*sh*gmmz/((sh-sqmz)**2+gmmz**2)
27189  DO 390 i=1,mdcy(kc,3)
27190  idc=i+mdcy(kc,2)-1
27191  IF(mdme(idc,1).LT.0) goto 390
27192  rm1=pmas(pycomp(kfdp(idc,1)),1)**2/sh
27193  rm2=pmas(pycomp(kfdp(idc,2)),1)**2/sh
27194  IF(sqrt(rm1)+sqrt(rm2).GT.1d0) goto 390
27195  wid2=1d0
27196  IF(i.EQ.1) THEN
27197 C...omega_tc0 -> gamma + pi_tc0.
27198  wdtp(i)=aem/24d0/rtcm(12)**2*(1d0-rtcm(3)**2)*
27199  & sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3*shr**3
27200  wid2=wids(pycomp(ktechn+111),2)
27201  ELSEIF(i.EQ.2) THEN
27202 C...omega_tc0 -> Z0 + pi_tc0
27203  wdtp(i)=aem*sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3*
27204  & (1d0-rtcm(3)**2)/24d0/rtcm(12)**2*(1d0-2d0*xw)**2/4d0/
27205  & xw/xw1*shr**3
27206  wid2=wids(23,2)*wids(pycomp(ktechn+111),2)
27207  ELSEIF(i.EQ.3) THEN
27208 C...omega_tc0 -> gamma + pi_tc0'
27209  wdtp(i)=aem*sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3*
27210  & (2d0*rtcm(2)-1d0)**2*(1d0-rtcm(4)**2)/24d0/rtcm(12)**2*
27211  & shr**3
27212  wid2=wids(pycomp(ktechn+221),2)
27213  ELSEIF(i.EQ.4) THEN
27214 C...omega_tc0 -> Z0 + pi_tc0'
27215  wdtp(i)=aem*sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3*
27216  & (2d0*rtcm(2)-1d0)**2*(1d0-rtcm(4)**2)/24d0/rtcm(12)**2*
27217  & xw/xw1*shr**3
27218  wid2=wids(23,2)*wids(pycomp(ktechn+221),2)
27219  ELSEIF(i.EQ.5) THEN
27220 C...omega_tc0 -> W+ + pi_tc-
27221  wdtp(i)=aem*sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3*
27222  & (1d0-rtcm(3)**2)/4d0/xw/24d0/rtcm(12)**2*shr**3+
27223  & fac*rtcm(3)**2*(1d0-rtcm(3)**2)*rtcm(11)**2*
27224  & sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3
27225  wid2=wids(24,2)*wids(pycomp(ktechn+211),3)
27226  ELSEIF(i.EQ.6) THEN
27227 C...omega_tc0 -> pi_tc+ + W-
27228  wdtp(i)=aem*sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3*
27229  & (1d0-rtcm(3)**2)/4d0/xw/24d0/rtcm(12)**2*shr**3+
27230  & fac*rtcm(3)**2*(1d0-rtcm(3)**2)*rtcm(11)**2*
27231  & sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3
27232  wid2=wids(24,3)*wids(pycomp(ktechn+211),2)
27233  ELSEIF(i.EQ.7) THEN
27234 C...omega_tc0 -> W+ + W-.
27235 C... Multiplied by 2 for W^+_T W^-_L + W^+_L W^-_T
27236  wdtp(i)=fac*rtcm(3)**4*rtcm(11)**2*
27237  & sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3+
27238  & 2d0*aem*sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3*
27239  & rtcm(3)**2/4d0/xw/24d0/rtcm(12)**2*shr**3
27240  wid2=wids(24,1)
27241  ELSEIF(i.EQ.8) THEN
27242 C...omega_tc0 -> pi_tc+ + pi_tc-.
27243  wdtp(i)=fac*(1d0-rtcm(3)**2)**2*rtcm(11)**2*
27244  & sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3
27245  wid2=wids(pycomp(ktechn+211),1)
27246 C...omega_tc0 -> gamma + Z0
27247  ELSEIF(i.EQ.9) THEN
27248  wdtp(i)=aem*sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3*
27249  & rtcm(3)**2/24d0/rtcm(12)**2*shr**3
27250  wid2=wids(23,2)
27251 C...omega_tc0 -> Z0 + Z0
27252  ELSEIF(i.EQ.10) THEN
27253  wdtp(i)=aem*sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))**3*
27254  & rtcm(3)**2*(xw1-xw)**2/xw/xw1/4d0
27255  & /24d0/rtcm(12)**2*shr**3
27256  wid2=wids(23,1)
27257  ELSE
27258 C...omega_tc0 -> f + fbar.
27259  wid2=1d0
27260  IF(i.LE.18) THEN
27261  ia=i-10
27262  fcof=3d0*radc
27263  IF(ia.GE.6.AND.ia.LE.8) wid2=wids(ia,1)
27264  ELSE
27265  ia=i-8
27266  fcof=1d0
27267  IF(ia.GE.17) wid2=wids(ia,1)
27268  ENDIF
27269  ei=kchg(ia,1)/3d0
27270  ai=sign(1d0,ei+0.1d0)
27271  vi=ai-4d0*ei*xwv
27272  vali=-0.5d0*(vi+ai)
27273  vari=-0.5d0*(vi-ai)
27274  wdtp(i)=facf*fcof*sqrt(max(0d0,1d0-4d0*rm1))*((1d0-rm1)*
27275  & ((ei+vali*bwzr)**2+(vali*bwzi)**2+
27276  & (ei+vari*bwzr)**2+(vari*bwzi)**2)+6d0*rm1*(
27277  & (ei+vali*bwzr)*(ei+vari*bwzr)+vali*vari*bwzi**2))
27278  ENDIF
27279  wdtp(i)=fudge*wdtp(i)
27280  wdtp(0)=wdtp(0)+wdtp(i)
27281  IF(mdme(idc,1).GT.0) THEN
27282  wdte(i,mdme(idc,1))=wdtp(i)*wid2
27283  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
27284  wdte(i,0)=wdte(i,mdme(idc,1))
27285  wdte(0,0)=wdte(0,0)+wdte(i,0)
27286  ENDIF
27287  390 CONTINUE
27288 
27289 C.....V8 -> quark anti-quark
27290  ELSEIF(kfla.EQ.ktechn+100021) THEN
27291  fac=as/6d0*shr
27292  tant3=rtcm(21)
27293  IF(itcm(2).EQ.0) THEN
27294  imdl=1
27295  ELSEIF(itcm(2).EQ.1) THEN
27296  imdl=2
27297  ENDIF
27298  DO 400 i=1,mdcy(kc,3)
27299  idc=i+mdcy(kc,2)-1
27300  IF(mdme(idc,1).LT.0) goto 400
27301  pm1=pmas(pycomp(kfdp(idc,1)),1)
27302  rm1=pm1**2/sh
27303  IF(rm1.GT.0.25d0) goto 400
27304  wid2=1d0
27305  IF(i.EQ.5.OR.i.EQ.6.OR.imdl.EQ.2) THEN
27306  fmix=1d0/tant3**2
27307  ELSE
27308  fmix=tant3**2
27309  ENDIF
27310  wdtp(i)=fac*(1d0+2d0*rm1)*sqrt(1d0-4d0*rm1)*fmix
27311  IF(i.EQ.6) wid2=wids(6,1)
27312  wdtp(i)=fudge*wdtp(i)
27313  wdtp(0)=wdtp(0)+wdtp(i)
27314  IF(mdme(idc,1).GT.0) THEN
27315  wdte(i,mdme(idc,1))=wdtp(i)*wid2
27316  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
27317  wdte(i,0)=wdte(i,mdme(idc,1))
27318  wdte(0,0)=wdte(0,0)+wdte(i,0)
27319  ENDIF
27320  400 CONTINUE
27321 
27322  ELSEIF(kfla.EQ.ktechn+100111.OR.kfla.EQ.ktechn+200111) THEN
27323  fac=(1d0/(4d0*paru(1)*rtcm(1)**2))*shr
27324  clebf=0d0
27325  DO 410 i=1,mdcy(kc,3)
27326  idc=i+mdcy(kc,2)-1
27327  IF(mdme(idc,1).LT.0) goto 410
27328  rm1=pmas(pycomp(kfdp(idc,1)),1)**2/sh
27329  rm2=pmas(pycomp(kfdp(idc,2)),1)**2/sh
27330  IF(sqrt(rm1)+sqrt(rm2).GT.1d0) goto 410
27331  wid2=1d0
27332 C...pi_tc -> g + g
27333  IF(i.EQ.7) THEN
27334  IF(kfla.EQ.ktechn+100111) THEN
27335  clebg=4d0/3d0
27336  ELSE
27337  clebg=5d0/3d0
27338  ENDIF
27339  facp=(as/(8d0*paru(1))*itcm(1)/rtcm(1))**2
27340  & /(2d0*paru(1))*sh*shr*clebg
27341  wdtp(i)=facp
27342  ELSE
27343 C...pi_tc -> f + fbar.
27344  IF(i.EQ.6) wid2=wids(6,1)
27345  fcof=1d0
27346  ika=iabs(kfdp(idc,1))
27347  IF(ika.LT.10) fcof=3d0*radc
27348  hm1=pymrun(kfdp(idc,1),sh)
27349  wdtp(i)=fac*fcof*hm1**2*clebf*
27350  & sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))
27351  ENDIF
27352  wdtp(i)=fudge*wdtp(i)
27353  wdtp(0)=wdtp(0)+wdtp(i)
27354  IF(mdme(idc,1).GT.0) THEN
27355  wdte(i,mdme(idc,1))=wdtp(i)*wid2
27356  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
27357  wdte(i,0)=wdte(i,mdme(idc,1))
27358  wdte(0,0)=wdte(0,0)+wdte(i,0)
27359  ENDIF
27360  410 CONTINUE
27361 
27362  ELSEIF(kfla.GE.ktechn+100113.AND.kfla.LE.ktechn+400113) THEN
27363  fac=as/6d0*shr
27364  alprht=2.16d0*(3d0/itcm(1))
27365  tant3=rtcm(21)
27366  sin2t=2d0*tant3/(tant3**2+1d0)
27367  sint3=tant3/sqrt(tant3**2+1d0)
27368  csxpp=rtcm(22)
27369  rm82=rtcm(27)**2
27370  x12=(rtcm(29)*sqrt(1d0-rtcm(29)**2)*cos(rtcm(30))+
27371  & rtcm(31)*sqrt(1d0-rtcm(31)**2)*cos(rtcm(32)))/sqrt(2d0)
27372  x21=(rtcm(29)*sqrt(1d0-rtcm(29)**2)*sin(rtcm(30))+
27373  & rtcm(31)*sqrt(1d0-rtcm(31)**2)*sin(rtcm(32)))/sqrt(2d0)
27374  x11=(.25d0*(rtcm(29)**2+rtcm(31)**2+2d0)-
27375  & sint3**2)*2d0
27376  x22=(.25d0*(2d0-rtcm(29)**2-rtcm(31)**2)-
27377  & sint3**2)*2d0
27378  CALL pywidx(ktechn+100021,sh,wdtpp,wdtep)
27379 
27380  IF(wdtpp(0).GT.rtcm(33)*shr) wdtpp(0)=rtcm(33)*shr
27381  gmv8=shr*wdtpp(0)
27382  rmv8=pmas(pycomp(ktechn+100021),1)
27383  fv8re=sh*(sh-rmv8**2)/((sh-rmv8**2)**2+gmv8**2)
27384  fv8im=sh*gmv8/((sh-rmv8**2)**2+gmv8**2)
27385  IF(itcm(2).EQ.0) THEN
27386  imdl=1
27387  ELSE
27388  imdl=2
27389  ENDIF
27390  DO 420 i=1,mdcy(kc,3)
27391  IF(i.EQ.7.AND.(kfla.EQ.ktechn+200113.OR.
27392  & kfla.EQ.ktechn+300113)) goto 420
27393  idc=i+mdcy(kc,2)-1
27394  IF(mdme(idc,1).LT.0) goto 420
27395  rm1=pmas(pycomp(kfdp(idc,1)),1)**2/sh
27396  rm2=pmas(pycomp(kfdp(idc,2)),1)**2/sh
27397  IF(sqrt(rm1)+sqrt(rm2).GT.1d0) goto 420
27398  wid2=1d0
27399  IF(i.LE.6) THEN
27400  IF(i.EQ.6) wid2=wids(6,1)
27401  xig=1d0
27402  IF(kfla.EQ.ktechn+200113) THEN
27403  xig=0d0
27404  xij=x12
27405  ELSEIF(kfla.EQ.ktechn+300113) THEN
27406  xig=0d0
27407  xij=x21
27408  ELSEIF(kfla.EQ.ktechn+100113) THEN
27409  xij=x11
27410  ELSE
27411  xij=x22
27412  ENDIF
27413  IF(i.EQ.5.OR.i.EQ.6.OR.imdl.EQ.2) THEN
27414  fmix=1d0/tant3/sin2t
27415  ELSE
27416  fmix=-tant3/sin2t
27417  ENDIF
27418  xfac=(xig+fmix*xij*fv8re)**2+(fmix*xij*fv8im)**2
27419  wdtp(i)=fac*(1d0+2d0*rm1)*sqrt(1d0-4d0*rm1)*as/alprht*xfac
27420  ELSEIF(i.EQ.7) THEN
27421  wdtp(i)=shr*as**2/(4d0*alprht)
27422  ELSEIF(kfla.EQ.ktechn+400113.AND.i.LE.9) THEN
27423  psh=shr*(1d0-rm1)/2d0
27424  wdtp(i)=as/9d0*psh**3/rm82
27425  IF(i.EQ.8) THEN
27426  wdtp(i)=2d0*wdtp(i)*csxpp**2
27427  wid2=wids(pycomp(kfdp(idc,1)),2)
27428  ELSE
27429  wdtp(i)=5d0*wdtp(i)
27430  wid2=wids(pycomp(kfdp(idc,1)),2)
27431  ENDIF
27432  ENDIF
27433  wdtp(i)=fudge*wdtp(i)
27434  wdtp(0)=wdtp(0)+wdtp(i)
27435  IF(mdme(idc,1).GT.0) THEN
27436  wdte(i,mdme(idc,1))=wdtp(i)*wid2
27437  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
27438  wdte(i,0)=wdte(i,mdme(idc,1))
27439  wdte(0,0)=wdte(0,0)+wdte(i,0)
27440  ENDIF
27441  420 CONTINUE
27442 
27443  ELSEIF(kfla.EQ.kexcit+1) THEN
27444 C...d* excited quark.
27445  fac=(sh/rtcm(41)**2)*shr
27446  DO 430 i=1,mdcy(kc,3)
27447  idc=i+mdcy(kc,2)-1
27448  IF(mdme(idc,1).LT.0) goto 430
27449  rm1=pmas(pycomp(kfdp(idc,1)),1)**2/sh
27450  rm2=pmas(pycomp(kfdp(idc,2)),1)**2/sh
27451  IF(sqrt(rm1)+sqrt(rm2).GT.1d0) goto 430
27452  wid2=1d0
27453  IF(i.EQ.1) THEN
27454 C...d* -> g + d.
27455  wdtp(i)=fac*as*rtcm(45)**2/3d0
27456  wid2=1d0
27457  ELSEIF(i.EQ.2) THEN
27458 C...d* -> gamma + d.
27459  qf=-rtcm(43)/2d0+rtcm(44)/6d0
27460  wdtp(i)=fac*aem*qf**2/4d0
27461  wid2=1d0
27462  ELSEIF(i.EQ.3) THEN
27463 C...d* -> Z0 + d.
27464  qf=-rtcm(43)*xw1/2d0-rtcm(44)*xw/6d0
27465  wdtp(i)=fac*aem*qf**2/(8d0*xw*xw1)*
27466  & (1d0-rm1)**2*(2d0+rm1)
27467  wid2=wids(23,2)
27468  ELSEIF(i.EQ.4) THEN
27469 C...d* -> W- + u.
27470  wdtp(i)=fac*aem*rtcm(43)**2/(16d0*xw)*
27471  & (1d0-rm1)**2*(2d0+rm1)
27472  IF(kflr.GT.0) wid2=wids(24,3)
27473  IF(kflr.LT.0) wid2=wids(24,2)
27474  ENDIF
27475  wdtp(i)=fudge*wdtp(i)
27476  wdtp(0)=wdtp(0)+wdtp(i)
27477  IF(mdme(idc,1).GT.0) THEN
27478  wdte(i,mdme(idc,1))=wdtp(i)*wid2
27479  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
27480  wdte(i,0)=wdte(i,mdme(idc,1))
27481  wdte(0,0)=wdte(0,0)+wdte(i,0)
27482  ENDIF
27483  430 CONTINUE
27484 
27485  ELSEIF(kfla.EQ.kexcit+2) THEN
27486 C...u* excited quark.
27487  fac=(sh/rtcm(41)**2)*shr
27488  DO 440 i=1,mdcy(kc,3)
27489  idc=i+mdcy(kc,2)-1
27490  IF(mdme(idc,1).LT.0) goto 440
27491  rm1=pmas(pycomp(kfdp(idc,1)),1)**2/sh
27492  rm2=pmas(pycomp(kfdp(idc,2)),1)**2/sh
27493  IF(sqrt(rm1)+sqrt(rm2).GT.1d0) goto 440
27494  wid2=1d0
27495  IF(i.EQ.1) THEN
27496 C...u* -> g + u.
27497  wdtp(i)=fac*as*rtcm(45)**2/3d0
27498  wid2=1d0
27499  ELSEIF(i.EQ.2) THEN
27500 C...u* -> gamma + u.
27501  qf=rtcm(43)/2d0+rtcm(44)/6d0
27502  wdtp(i)=fac*aem*qf**2/4d0
27503  wid2=1d0
27504  ELSEIF(i.EQ.3) THEN
27505 C...u* -> Z0 + u.
27506  qf=rtcm(43)*xw1/2d0-rtcm(44)*xw/6d0
27507  wdtp(i)=fac*aem*qf**2/(8d0*xw*xw1)*
27508  & (1d0-rm1)**2*(2d0+rm1)
27509  wid2=wids(23,2)
27510  ELSEIF(i.EQ.4) THEN
27511 C...u* -> W+ + d.
27512  wdtp(i)=fac*aem*rtcm(43)**2/(16d0*xw)*
27513  & (1d0-rm1)**2*(2d0+rm1)
27514  IF(kflr.GT.0) wid2=wids(24,2)
27515  IF(kflr.LT.0) wid2=wids(24,3)
27516  ENDIF
27517  wdtp(i)=fudge*wdtp(i)
27518  wdtp(0)=wdtp(0)+wdtp(i)
27519  IF(mdme(idc,1).GT.0) THEN
27520  wdte(i,mdme(idc,1))=wdtp(i)*wid2
27521  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
27522  wdte(i,0)=wdte(i,mdme(idc,1))
27523  wdte(0,0)=wdte(0,0)+wdte(i,0)
27524  ENDIF
27525  440 CONTINUE
27526 
27527  ELSEIF(kfla.EQ.kexcit+11) THEN
27528 C...e* excited lepton.
27529  fac=(sh/rtcm(41)**2)*shr
27530  DO 450 i=1,mdcy(kc,3)
27531  idc=i+mdcy(kc,2)-1
27532  IF(mdme(idc,1).LT.0) goto 450
27533  rm1=pmas(pycomp(kfdp(idc,1)),1)**2/sh
27534  rm2=pmas(pycomp(kfdp(idc,2)),1)**2/sh
27535  IF(sqrt(rm1)+sqrt(rm2).GT.1d0) goto 450
27536  wid2=1d0
27537  IF(i.EQ.1) THEN
27538 C...e* -> gamma + e.
27539  qf=-rtcm(43)/2d0-rtcm(44)/2d0
27540  wdtp(i)=fac*aem*qf**2/4d0
27541  wid2=1d0
27542  ELSEIF(i.EQ.2) THEN
27543 C...e* -> Z0 + e.
27544  qf=-rtcm(43)*xw1/2d0+rtcm(44)*xw/2d0
27545  wdtp(i)=fac*aem*qf**2/(8d0*xw*xw1)*
27546  & (1d0-rm1)**2*(2d0+rm1)
27547  wid2=wids(23,2)
27548  ELSEIF(i.EQ.3) THEN
27549 C...e* -> W- + nu.
27550  wdtp(i)=fac*aem*rtcm(43)**2/(16d0*xw)*
27551  & (1d0-rm1)**2*(2d0+rm1)
27552  IF(kflr.GT.0) wid2=wids(24,3)
27553  IF(kflr.LT.0) wid2=wids(24,2)
27554  ENDIF
27555  wdtp(i)=fudge*wdtp(i)
27556  wdtp(0)=wdtp(0)+wdtp(i)
27557  IF(mdme(idc,1).GT.0) THEN
27558  wdte(i,mdme(idc,1))=wdtp(i)*wid2
27559  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
27560  wdte(i,0)=wdte(i,mdme(idc,1))
27561  wdte(0,0)=wdte(0,0)+wdte(i,0)
27562  ENDIF
27563  450 CONTINUE
27564 
27565  ELSEIF(kfla.EQ.kexcit+12) THEN
27566 C...nu*_e excited neutrino.
27567  fac=(sh/rtcm(41)**2)*shr
27568  DO 460 i=1,mdcy(kc,3)
27569  idc=i+mdcy(kc,2)-1
27570  IF(mdme(idc,1).LT.0) goto 460
27571  rm1=pmas(pycomp(kfdp(idc,1)),1)**2/sh
27572  rm2=pmas(pycomp(kfdp(idc,2)),1)**2/sh
27573  IF(sqrt(rm1)+sqrt(rm2).GT.1d0) goto 460
27574  wid2=1d0
27575  IF(i.EQ.1) THEN
27576 C...nu*_e -> Z0 + nu*_e.
27577  qf=rtcm(43)*xw1/2d0+rtcm(44)*xw/2d0
27578  wdtp(i)=fac*aem*qf**2/(8d0*xw*xw1)*
27579  & (1d0-rm1)**2*(2d0+rm1)
27580  wid2=wids(23,2)
27581  ELSEIF(i.EQ.2) THEN
27582 C...nu*_e -> W+ + e.
27583  wdtp(i)=fac*aem*rtcm(43)**2/(16d0*xw)*
27584  & (1d0-rm1)**2*(2d0+rm1)
27585  IF(kflr.GT.0) wid2=wids(24,2)
27586  IF(kflr.LT.0) wid2=wids(24,3)
27587  ENDIF
27588  wdtp(i)=fudge*wdtp(i)
27589  wdtp(0)=wdtp(0)+wdtp(i)
27590  IF(mdme(idc,1).GT.0) THEN
27591  wdte(i,mdme(idc,1))=wdtp(i)*wid2
27592  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
27593  wdte(i,0)=wdte(i,mdme(idc,1))
27594  wdte(0,0)=wdte(0,0)+wdte(i,0)
27595  ENDIF
27596  460 CONTINUE
27597 
27598  ELSEIF(kfla.EQ.kdimen+39) THEN
27599 C...G* (graviton resonance):
27600  fac=(parp(50)**2/paru(1))*shr
27601  DO 470 i=1,mdcy(kc,3)
27602  idc=i+mdcy(kc,2)-1
27603  IF(mdme(idc,1).LT.0) goto 470
27604  rm1=pmas(pycomp(kfdp(idc,1)),1)**2/sh
27605  rm2=pmas(pycomp(kfdp(idc,2)),1)**2/sh
27606  IF(sqrt(rm1)+sqrt(rm2).GT.1d0) goto 470
27607  wid2=1d0
27608  IF(i.LE.8) THEN
27609 C...G* -> q + qbar
27610  fcof=3d0*radc
27611  IF(i.GE.6.AND.mstp(35).GE.1) fcof=fcof*
27612  & pyhfth(sh,sh*rm1,1d0)
27613  wdtp(i)=fac*fcof*sqrt(max(0d0,1d0-4d0*rm1))**3*
27614  & (1d0+8d0*rm1/3d0)/320d0
27615  IF(i.EQ.6) wid2=wids(6,1)
27616  IF(i.EQ.7.OR.i.EQ.8) wid2=wids(i,1)
27617  ELSEIF(i.LE.16) THEN
27618 C...G* -> l+ + l-, nu + nubar
27619  fcof=1d0
27620  wdtp(i)=fac*sqrt(max(0d0,1d0-4d0*rm1))**3*
27621  & (1d0+8d0*rm1/3d0)/320d0
27622  IF(i.EQ.15.OR.i.EQ.16) wid2=wids(2+i,1)
27623  ELSEIF(i.EQ.17) THEN
27624 C...G* -> g + g.
27625  wdtp(i)=fac/20d0
27626  ELSEIF(i.EQ.18) THEN
27627 C...G* -> gamma + gamma.
27628  wdtp(i)=fac/160d0
27629  ELSEIF(i.EQ.19) THEN
27630 C...G* -> Z0 + Z0.
27631  wdtp(i)=fac*sqrt(max(0d0,1d0-4d0*rm1))*(13d0/12d0+
27632  & 14d0*rm1/3d0+4d0*rm1**2)/160d0
27633  wid2=wids(23,1)
27634  ELSEIF(i.EQ.20) THEN
27635 C...G* -> W+ + W-.
27636  wdtp(i)=fac*sqrt(max(0d0,1d0-4d0*rm1))*(13d0/12d0+
27637  & 14d0*rm1/3d0+4d0*rm1**2)/80d0
27638  wid2=wids(24,1)
27639  ENDIF
27640  wdtp(i)=fudge*wdtp(i)
27641  wdtp(0)=wdtp(0)+wdtp(i)
27642  IF(mdme(idc,1).GT.0) THEN
27643  wdte(i,mdme(idc,1))=wdtp(i)*wid2
27644  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
27645  wdte(i,0)=wdte(i,mdme(idc,1))
27646  wdte(0,0)=wdte(0,0)+wdte(i,0)
27647  ENDIF
27648  470 CONTINUE
27649 
27650  ELSEIF(kfla.EQ.9900012.OR.kfla.EQ.9900014.OR.kfla.EQ.9900016) THEN
27651 C...nu_eR, nu_muR, nu_tauR: righthanded Majorana neutrinos.
27652  pmwr=max(1.001d0*shr,pmas(pycomp(9900024),1))
27653  fac=(aem**2/(768d0*paru(1)*xw**2))*shr**5/pmwr**4
27654  DO 480 i=1,mdcy(kc,3)
27655  idc=i+mdcy(kc,2)-1
27656  IF(mdme(idc,1).LT.0) goto 480
27657  pm1=pmas(pycomp(kfdp(idc,1)),1)
27658  pm2=pmas(pycomp(kfdp(idc,2)),1)
27659  pm3=pmas(pycomp(kfdp(idc,3)),1)
27660  IF(pm1+pm2+pm3.GE.shr) goto 480
27661  wid2=1d0
27662  IF(i.LE.9) THEN
27663 C...nu_lR -> l- qbar q'
27664  fcof=3d0*radc*vckm((i-1)/3+1,mod(i-1,3)+1)
27665  IF(mod(i,3).EQ.0) wid2=wids(6,2)
27666  ELSEIF(i.LE.18) THEN
27667 C...nu_lR -> l+ q qbar'
27668  fcof=3d0*radc*vckm((i-10)/3+1,mod(i-10,3)+1)
27669  IF(mod(i-9,3).EQ.0) wid2=wids(6,3)
27670  ELSE
27671 C...nu_lR -> l- l'+ nu_lR' + charge conjugate.
27672  fcof=1d0
27673  wid2=wids(pycomp(kfdp(idc,3)),2)
27674  ENDIF
27675  x=(pm1+pm2+pm3)/shr
27676  fx=1d0-8d0*x**2+8d0*x**6-x**8-24d0*x**4*log(x)
27677  y=(shr/pmwr)**2
27678  fy=(12d0*(1d0-y)*log(1d0-y)+12d0*y-6d0*y**2-2d0*y**3)/y**4
27679  wdtp(i)=fac*fcof*fx*fy
27680  wdtp(i)=fudge*wdtp(i)
27681  wdtp(0)=wdtp(0)+wdtp(i)
27682  IF(mdme(idc,1).GT.0) THEN
27683  wdte(i,mdme(idc,1))=wdtp(i)*wid2
27684  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
27685  wdte(i,0)=wdte(i,mdme(idc,1))
27686  wdte(0,0)=wdte(0,0)+wdte(i,0)
27687  ENDIF
27688  480 CONTINUE
27689 
27690  ELSEIF(kfla.EQ.9900023) THEN
27691 C...Z_R0:
27692  fac=(aem/(48d0*xw*xw1*(1d0-2d0*xw)))*shr
27693  DO 490 i=1,mdcy(kc,3)
27694  idc=i+mdcy(kc,2)-1
27695  IF(mdme(idc,1).LT.0) goto 490
27696  rm1=pmas(pycomp(kfdp(idc,1)),1)**2/sh
27697  rm2=pmas(pycomp(kfdp(idc,2)),1)**2/sh
27698  IF(sqrt(rm1)+sqrt(rm2).GT.1d0) goto 490
27699  wid2=1d0
27700  symmet=1d0
27701  IF(i.LE.6) THEN
27702 C...Z_R0 -> q + qbar
27703  ef=kchg(i,1)/3d0
27704  af=sign(1d0,ef+0.1d0)*(1d0-2d0*xw)
27705  vf=sign(1d0,ef+0.1d0)-4d0*ef*xw
27706  fcof=3d0*radc
27707  IF(i.EQ.6) wid2=wids(6,1)
27708  ELSEIF(i.EQ.7.OR.i.EQ.10.OR.i.EQ.13) THEN
27709 C...Z_R0 -> l+ + l-
27710  af=-(1d0-2d0*xw)
27711  vf=-1d0+4d0*xw
27712  fcof=1d0
27713  ELSEIF(i.EQ.8.OR.i.EQ.11.OR.i.EQ.14) THEN
27714 C...Z0 -> nu_L + nu_Lbar, assumed Majorana.
27715  af=-2d0*xw
27716  vf=0d0
27717  fcof=1d0
27718  symmet=0.5d0
27719  ELSEIF(i.LE.15) THEN
27720 C...Z0 -> nu_R + nu_R, assumed Majorana.
27721  af=2d0*xw1
27722  vf=0d0
27723  fcof=1d0
27724  wid2=wids(pycomp(kfdp(idc,1)),1)
27725  symmet=0.5d0
27726  ENDIF
27727  wdtp(i)=fac*fcof*(vf**2*(1d0+2d0*rm1)+af**2*(1d0-4d0*rm1))*
27728  & sqrt(max(0d0,1d0-4d0*rm1))*symmet
27729  wdtp(i)=fudge*wdtp(i)
27730  wdtp(0)=wdtp(0)+wdtp(i)
27731  IF(mdme(idc,1).GT.0) THEN
27732  wdte(i,mdme(idc,1))=wdtp(i)*wid2
27733  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
27734  wdte(i,0)=wdte(i,mdme(idc,1))
27735  wdte(0,0)=wdte(0,0)+wdte(i,0)
27736  ENDIF
27737  490 CONTINUE
27738 
27739  ELSEIF(kfla.EQ.9900024) THEN
27740 C...W_R+/-:
27741  fac=(aem/(24d0*xw))*shr
27742  DO 500 i=1,mdcy(kc,3)
27743  idc=i+mdcy(kc,2)-1
27744  IF(mdme(idc,1).LT.0) goto 500
27745  rm1=pmas(pycomp(kfdp(idc,1)),1)**2/sh
27746  rm2=pmas(pycomp(kfdp(idc,2)),1)**2/sh
27747  IF(sqrt(rm1)+sqrt(rm2).GT.1d0) goto 500
27748  wid2=1d0
27749  IF(i.LE.9) THEN
27750 C...W_R+/- -> q + qbar'
27751  fcof=3d0*radc*vckm((i-1)/3+1,mod(i-1,3)+1)
27752  IF(kflr.GT.0) THEN
27753  IF(mod(i,3).EQ.0) wid2=wids(6,2)
27754  ELSE
27755  IF(mod(i,3).EQ.0) wid2=wids(6,3)
27756  ENDIF
27757  ELSEIF(i.LE.12) THEN
27758 C...W_R+/- -> l+/- + nu_R
27759  fcof=1d0
27760  ENDIF
27761  wdtp(i)=fac*fcof*(2d0-rm1-rm2-(rm1-rm2)**2)*
27762  & sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))
27763  wdtp(i)=fudge*wdtp(i)
27764  wdtp(0)=wdtp(0)+wdtp(i)
27765  IF(mdme(idc,1).GT.0) THEN
27766  wdte(i,mdme(idc,1))=wdtp(i)*wid2
27767  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
27768  wdte(i,0)=wdte(i,mdme(idc,1))
27769  wdte(0,0)=wdte(0,0)+wdte(i,0)
27770  ENDIF
27771  500 CONTINUE
27772 
27773  ELSEIF(kfla.EQ.9900041) THEN
27774 C...H_L++/--:
27775  fac=(1d0/(8d0*paru(1)))*shr
27776  DO 510 i=1,mdcy(kc,3)
27777  idc=i+mdcy(kc,2)-1
27778  IF(mdme(idc,1).LT.0) goto 510
27779  rm1=pmas(pycomp(kfdp(idc,1)),1)**2/sh
27780  rm2=pmas(pycomp(kfdp(idc,2)),1)**2/sh
27781  IF(sqrt(rm1)+sqrt(rm2).GT.1d0) goto 510
27782  wid2=1d0
27783  IF(i.LE.6) THEN
27784 C...H_L++/-- -> l+/- + l'+/-
27785  fcof=parp(180+3*((iabs(kfdp(idc,1))-11)/2)+
27786  & (iabs(kfdp(idc,2))-9)/2)**2
27787  IF(kfdp(idc,1).NE.kfdp(idc,2)) fcof=2d0*fcof
27788  ELSEIF(i.EQ.7) THEN
27789 C...H_L++/-- -> W_L+/- + W_L+/-
27790  fcof=0.5d0*parp(190)**4*parp(192)**2/pmas(24,1)**2*
27791  & (3d0*rm1+0.25d0/rm1-1d0)
27792  wid2=wids(24,4+(1-kfls)/2)
27793  ENDIF
27794  wdtp(i)=fac*fcof*
27795  & sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))
27796  wdtp(i)=fudge*wdtp(i)
27797  wdtp(0)=wdtp(0)+wdtp(i)
27798  IF(mdme(idc,1).GT.0) THEN
27799  wdte(i,mdme(idc,1))=wdtp(i)*wid2
27800  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
27801  wdte(i,0)=wdte(i,mdme(idc,1))
27802  wdte(0,0)=wdte(0,0)+wdte(i,0)
27803  ENDIF
27804  510 CONTINUE
27805 
27806  ELSEIF(kfla.EQ.9900042) THEN
27807 C...H_R++/--:
27808  fac=(1d0/(8d0*paru(1)))*shr
27809  DO 520 i=1,mdcy(kc,3)
27810  idc=i+mdcy(kc,2)-1
27811  IF(mdme(idc,1).LT.0) goto 520
27812  rm1=pmas(pycomp(kfdp(idc,1)),1)**2/sh
27813  rm2=pmas(pycomp(kfdp(idc,2)),1)**2/sh
27814  IF(sqrt(rm1)+sqrt(rm2).GT.1d0) goto 520
27815  wid2=1d0
27816  IF(i.LE.6) THEN
27817 C...H_R++/-- -> l+/- + l'+/-
27818  fcof=parp(180+3*((iabs(kfdp(idc,1))-11)/2)+
27819  & (iabs(kfdp(idc,2))-9)/2)**2
27820  IF(kfdp(idc,1).NE.kfdp(idc,2)) fcof=2d0*fcof
27821  ELSEIF(i.EQ.7) THEN
27822 C...H_R++/-- -> W_R+/- + W_R+/-
27823  fcof=parp(191)**2*(3d0*rm1+0.25d0/rm1-1d0)
27824  wid2=wids(pycomp(9900024),4+(1-kfls)/2)
27825  ENDIF
27826  wdtp(i)=fac*fcof*
27827  & sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))
27828  wdtp(i)=fudge*wdtp(i)
27829  wdtp(0)=wdtp(0)+wdtp(i)
27830  IF(mdme(idc,1).GT.0) THEN
27831  wdte(i,mdme(idc,1))=wdtp(i)*wid2
27832  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
27833  wdte(i,0)=wdte(i,mdme(idc,1))
27834  wdte(0,0)=wdte(0,0)+wdte(i,0)
27835  ENDIF
27836  520 CONTINUE
27837 
27838  ELSEIF(kfla.EQ.ktechn+115) THEN
27839 C...Techni-a2:
27840 C...Need to update to alpha_rho
27841  alprht=2.16d0*(3d0/itcm(1))*rtcm(47)**2
27842  fac=(alprht/12d0)*shr
27843  facf=(1d0/6d0)*(aem**2/alprht)*shr
27844  sqmz=pmas(23,1)**2
27845  sqmw=pmas(24,1)**2
27846  shp=sh
27847  CALL pywidx(23,shp,wdtpp,wdtep)
27848  gmmz=shr*wdtpp(0)
27849  xwrht=1d0/(4d0*xw*(1d0-xw))
27850  bwzr=xwrht*sh*(sh-sqmz)/((sh-sqmz)**2+gmmz**2)
27851  bwzi=xwrht*sh*gmmz/((sh-sqmz)**2+gmmz**2)
27852  DO 530 i=1,mdcy(kc,3)
27853  idc=i+mdcy(kc,2)-1
27854  IF(mdme(idc,1).LT.0) goto 530
27855  rm1=pmas(pycomp(kfdp(idc,1)),1)**2/sh
27856  rm2=pmas(pycomp(kfdp(idc,2)),1)**2/sh
27857  IF(sqrt(rm1)+sqrt(rm2).GT.1d0) goto 530
27858  wid2=1d0
27859  pcm=.5d0*sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))
27860  IF(i.LE.4) THEN
27861  facpv=pcm**2
27862  facpa=pcm**2+1.5d0*rm1
27863  va2=0d0
27864  aa2=0d0
27865 C...a2_tc0 -> W+ + W-
27866  IF(i.EQ.1) THEN
27867  aa2=2d0*rtcm(3)**2/4d0/xw/rtcm(49)**2
27868 C...Multiplied by 2 for W^+_T W^-_L + W^+_L W^-_T.(KL)
27869  wid2=wids(24,1)
27870 C...a2_tc0 -> W+ + pi_tc- + c.c.
27871  ELSEIF(i.EQ.2.OR.i.EQ.3) THEN
27872  aa2=(1d0-rtcm(3)**2)/4d0/xw/rtcm(49)**2
27873  IF(i.EQ.6) THEN
27874  wid2=wids(24,2)*wids(pycomp(ktechn+211),3)
27875  ELSE
27876  wid2=wids(24,3)*wids(pycomp(ktechn+211),2)
27877  ENDIF
27878  ELSEIF(i.EQ.4) THEN
27879 C...a2_tc0 -> Z0 + pi_tc0'
27880  va2=(1d0-rtcm(4)**2)/4d0/xw/xw1/rtcm(48)**2
27881  wid2=wids(23,2)*wids(pycomp(ktechn+221),2)
27882  ENDIF
27883  wdtp(i)=aem*shr**3*pcm/3d0*(va2*facpv+aa2*facpa)
27884  ELSEIF(i.GE.5.AND.i.LE.10) THEN
27885  facpv=pcm**2*(1d0+rm1+rm2)+3d0*rm1*rm2
27886  facpa=pcm**2*(1d0+rm1+rm2)
27887  va2=0d0
27888  aa2=0d0
27889  IF(i.EQ.5) THEN
27890 C...a_T^0 -> gamma rho_T^0
27891  va2=(2d0*rtcm(2)-1d0)**2/rtcm(50)**4
27892  wid2=wids(pycomp(ktechn+113),2)
27893  ELSEIF(i.EQ.6) THEN
27894 C...a_T^0 -> gamma omega_T
27895  va2=1d0/rtcm(50)**4
27896  wid2=wids(pycomp(ktechn+223),2)
27897  ELSEIF(i.EQ.7.OR.i.EQ.8) THEN
27898 C...a_T^0 -> W^+- rho_T^-+
27899  aa2=.25d0/xw/rtcm(51)**4
27900  IF(i.EQ.7) THEN
27901  wid2=wids(24,2)*wids(pycomp(ktechn+213),3)
27902  ELSE
27903  wid2=wids(24,3)*wids(pycomp(ktechn+213),2)
27904  ENDIF
27905  ELSEIF(i.EQ.9) THEN
27906 C...a_T^0 -> Z^0 rho_T^0
27907  va2=(2d0*rtcm(2)-1d0)**2*xw/xw1/rtcm(50)**4
27908  wid2=wids(23,2)*wids(pycomp(ktechn+113),2)
27909  ELSEIF(i.EQ.10) THEN
27910 C...a_T^0 -> Z^0 omega_T
27911  va2=.25d0*(1d0-2d0*xw)**2/xw/xw1/rtcm(50)**4
27912  wid2=wids(23,2)*wids(pycomp(ktechn+223),2)
27913  ENDIF
27914  wdtp(i)=aem*shr**5*pcm/12d0*(va2*facpv+aa2*facpa)
27915  ELSE
27916 C...a2_tc0 -> f + fbar.
27917  wid2=1d0
27918  IF(i.LE.18) THEN
27919  ia=i-10
27920  fcof=3d0*radc
27921  IF(ia.GE.6.AND.ia.LE.8) wid2=wids(ia,1)
27922  ELSE
27923  ia=i-8
27924  fcof=1d0
27925  IF(ia.GE.17) wid2=wids(ia,1)
27926  ENDIF
27927  ei=kchg(ia,1)/3d0
27928  ai=sign(1d0,ei+0.1d0)
27929  vi=ai-4d0*ei*xwv
27930  vali=0.5d0*(vi+ai)
27931  vari=0.5d0*(vi-ai)
27932  wdtp(i)=facf*fcof*sqrt(max(0d0,1d0-4d0*rm1))*((1d0-rm1)*
27933  & ((vali*bwzr)**2+(vali*bwzi)**2+
27934  & (vari*bwzr)**2+(vari*bwzi)**2)+6d0*rm1*(
27935  & (vali*bwzr)*(vari*bwzr)+vali*vari*bwzi**2))
27936  ENDIF
27937  wdtp(i)=fudge*wdtp(i)
27938  wdtp(0)=wdtp(0)+wdtp(i)
27939  IF(mdme(idc,1).GT.0) THEN
27940  wdte(i,mdme(idc,1))=wdtp(i)*wid2
27941  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
27942  wdte(i,0)=wdte(i,mdme(idc,1))
27943  wdte(0,0)=wdte(0,0)+wdte(i,0)
27944  ENDIF
27945  530 CONTINUE
27946 
27947  ELSEIF(kfla.EQ.ktechn+215) THEN
27948 C...Techni-a2+/-:
27949  alprht=2.16d0*(3d0/itcm(1))*rtcm(47)**2
27950  fac=(alprht/12d0)*shr
27951  sqmz=pmas(23,1)**2
27952  sqmw=pmas(24,1)**2
27953  shp=sh
27954  CALL pywidx(24,shp,wdtpp,wdtep)
27955  gmmw=shr*wdtpp(0)
27956  facf=(1d0/12d0)*(aem**2/alprht)*shr*
27957  & (0.125d0/xw**2)*sh**2/((sh-sqmw)**2+gmmw**2)
27958  DO 540 i=1,mdcy(kc,3)
27959  idc=i+mdcy(kc,2)-1
27960  IF(mdme(idc,1).LT.0) goto 540
27961  rm1=pmas(pycomp(kfdp(idc,1)),1)**2/sh
27962  rm2=pmas(pycomp(kfdp(idc,2)),1)**2/sh
27963  IF(sqrt(rm1)+sqrt(rm2).GT.1d0) goto 540
27964  wid2=1d0
27965  pcm=.5d0*sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))
27966  IF(kflr.GT.0) THEN
27967  ichann=2
27968  ELSE
27969  ichann=3
27970  ENDIF
27971  IF(i.LE.7) THEN
27972  aa2=0
27973  va2=0
27974 C...a2_tc+ -> gamma + W+.
27975  IF(i.EQ.1) THEN
27976  aa2=rtcm(3)**2/rtcm(49)**2
27977  wid2=wids(24,ichann)
27978 C...a2_tc+ -> gamma + pi_tc+.
27979  ELSEIF(i.EQ.2) THEN
27980  aa2=(1d0-rtcm(3)**2)/rtcm(49)**2
27981  wid2=wids(pycomp(ktechn+211),ichann)
27982 C...a2_tc+ -> W+ + Z
27983  ELSEIF(i.EQ.3) THEN
27984  aa2=rtcm(3)**2*(1d0/4d0/xw1 +
27985  & (xw-xw1)**2/4./xw/xw1)/rtcm(49)**2
27986  wid2=wids(24,ichann)*wids(23,2)
27987 C...a2_tc+ -> W+ + pi_tc0.
27988  ELSEIF(i.EQ.4) THEN
27989  aa2=(1d0-rtcm(3)**2)/4d0/xw/rtcm(49)**2
27990  wid2=wids(24,ichann)*wids(pycomp(ktechn+111),2)
27991 C...a2_tc+ -> W+ + pi_tc'0.
27992  ELSEIF(i.EQ.5) THEN
27993  va2=(1d0-rtcm(4)**2)/4d0/xw/rtcm(48)**2
27994  wid2=wids(24,ichann)*wids(pycomp(ktechn+221),2)
27995 C...a2_tc+ -> Z0 + pi_tc+.
27996  ELSEIF(i.EQ.6) THEN
27997  aa2=(1d0-rtcm(3)**2)/4d0/xw/xw1*(1d0-2d0*xw)**2/
27998  & rtcm(49)**2
27999  wid2=wids(23,2)*wids(pycomp(ktechn+211),ichann)
28000  ENDIF
28001  wdtp(i)=aem*pcm*(aa2*(pcm**2+1.5d0*rm1)+pcm**2*va2)
28002  & /3d0*shr**3
28003  ELSEIF(i.LE.10) THEN
28004  facpv=pcm**2*(1d0+rm1+rm2)+3d0*rm1*rm2
28005  facpa=pcm**2*(1d0+rm1+rm2)
28006  va2=0d0
28007  aa2=0d0
28008 C...a2_tc+ -> gamma + rho_tc+
28009  IF(i.EQ.7) THEN
28010  va2=(2d0*rtcm(2)-1d0)**2/rtcm(50)**4
28011  wid2=wids(pycomp(ktechn+213),ichann)
28012 C...a2_tc+ -> W+ + rho_T^0
28013  ELSEIF(i.EQ.8) THEN
28014  aa2=1d0/(4d0*xw)/rtcm(51)**4
28015  wid2=wids(24,ichann)*wids(pycomp(ktechn+113),2)
28016 C...a2_tc+ -> W+ + omega_T
28017  ELSEIF(i.EQ.9) THEN
28018  va2=.25d0/xw/rtcm(50)**4
28019  wid2=wids(24,ichann)*wids(pycomp(ktechn+223),2)
28020 C...a2_tc+ -> Z^0 + rho_T^+
28021  ELSEIF(i.EQ.10) THEN
28022  va2=(2d0*rtcm(2)-1d0)**2*xw/xw1/rtcm(50)**4
28023  aa2=1d0/(4d0*xw*xw1)/rtcm(51)**4
28024  wid2=wids(23,2)*wids(pycomp(ktechn+213),ichann)
28025  ENDIF
28026  wdtp(i)=aem*shr**5*pcm/12d0*(va2*facpv+aa2*facpa)
28027  ELSE
28028 C...a2_tc+ -> f + fbar'.
28029  ia=i-10
28030  wid2=1d0
28031  IF(ia.LE.16) THEN
28032  fcof=3d0*radc*vckm((ia-1)/4+1,mod(ia-1,4)+1)
28033  IF(kflr.GT.0) THEN
28034  IF(mod(ia,4).EQ.3) wid2=wids(6,2)
28035  IF(mod(ia,4).EQ.0) wid2=wids(8,2)
28036  IF(ia.GE.13) wid2=wid2*wids(7,3)
28037  ELSE
28038  IF(mod(ia,4).EQ.3) wid2=wids(6,3)
28039  IF(mod(ia,4).EQ.0) wid2=wids(8,3)
28040  IF(ia.GE.13) wid2=wid2*wids(7,2)
28041  ENDIF
28042  ELSE
28043  fcof=1d0
28044  IF(kflr.GT.0) THEN
28045  IF(ia.EQ.20) wid2=wids(17,3)*wids(18,2)
28046  ELSE
28047  IF(ia.EQ.20) wid2=wids(17,2)*wids(18,3)
28048  ENDIF
28049  ENDIF
28050  wdtp(i)=facf*fcof*(2d0-rm1-rm2-(rm1-rm2)**2)*
28051  & sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))
28052  ENDIF
28053  wdtp(i)=fudge*wdtp(i)
28054  wdtp(0)=wdtp(0)+wdtp(i)
28055  IF(mdme(idc,1).GT.0) THEN
28056  wdte(i,mdme(idc,1))=wdtp(i)*wid2
28057  wdte(0,mdme(idc,1))=wdte(0,mdme(idc,1))+wdte(i,mdme(idc,1))
28058  wdte(i,0)=wdte(i,mdme(idc,1))
28059  wdte(0,0)=wdte(0,0)+wdte(i,0)
28060  ENDIF
28061  540 CONTINUE
28062 
28063  ENDIF
28064  mint(61)=0
28065  mint(62)=0
28066  mint(63)=0
28067  RETURN
28068  END
28069 
28070 C***********************************************************************
28071 
28072 C...PYOFSH
28073 C...Calculates partial width and differential cross-section maxima
28074 C...of channels/processes not allowed on mass-shell, and selects
28075 C...masses in such channels/processes.
28076 
28077  SUBROUTINE pyofsh(MOFSH,KFMO,KFD1,KFD2,PMMO,RET1,RET2)
28078 
28079 C...Double precision and integer declarations.
28080  IMPLICIT DOUBLE PRECISION(a-h, o-z)
28081  IMPLICIT INTEGER(i-n)
28082  INTEGER pyk,pychge,pycomp
28083 C...Commonblocks.
28084  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
28085  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
28086  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
28087  common/pysubs/msel,mselpd,msub(500),kfin(2,-40:40),ckin(200)
28088  common/pypars/mstp(200),parp(200),msti(200),pari(200)
28089  common/pyint1/mint(400),vint(400)
28090  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
28091  common/pyint5/ngenpd,ngen(0:500,3),xsec(0:500,3)
28092  SAVE /pydat1/,/pydat2/,/pydat3/,/pysubs/,/pypars/,/pyint1/,
28093  &/pyint2/,/pyint5/
28094 C...Local arrays.
28095  dimension kfd(2),mbw(2),pmd(2),pgd(2),pmg(2),pml(2),pmu(2),
28096  &pmh(2),atl(2),atu(2),ath(2),rmg(2),inx1(100),xpt1(100),
28097  &fpt1(100),inx2(100),xpt2(100),fpt2(100),wdtp(0:400),
28098  &wdte(0:400,0:5)
28099 
28100 C...Find if particles equal, maximum mass, matrix elements, etc.
28101  mint(51)=0
28102  isub=mint(1)
28103  kfd(1)=iabs(kfd1)
28104  kfd(2)=iabs(kfd2)
28105  meql=0
28106  IF(kfd(1).EQ.kfd(2)) meql=1
28107  mlm=0
28108  IF(mofsh.GE.2.AND.meql.EQ.1) mlm=int(1.5d0+pyr(0))
28109  IF(mofsh.LE.2.OR.mofsh.EQ.5) THEN
28110  noff=44
28111  pmmx=pmmo
28112  ELSE
28113  noff=40
28114  pmmx=vint(1)
28115  IF(ckin(2).GT.ckin(1)) pmmx=min(ckin(2),vint(1))
28116  ENDIF
28117  mmed=0
28118  IF((kfmo.EQ.25.OR.kfmo.EQ.35.OR.kfmo.EQ.36).AND.meql.EQ.1.AND.
28119  &(kfd(1).EQ.23.OR.kfd(1).EQ.24)) mmed=1
28120  IF((kfmo.EQ.32.OR.iabs(kfmo).EQ.34).AND.(kfd(1).EQ.23.OR.
28121  &kfd(1).EQ.24).AND.(kfd(2).EQ.23.OR.kfd(2).EQ.24)) mmed=2
28122  IF((kfmo.EQ.32.OR.iabs(kfmo).EQ.34).AND.(kfd(2).EQ.25.OR.
28123  &kfd(2).EQ.35.OR.kfd(2).EQ.36)) mmed=3
28124  loop=1
28125 
28126 C...Find where Breit-Wigners are required, else select discrete masses.
28127  100 DO 110 i=1,2
28128  kfca=pycomp(kfd(i))
28129  IF(kfca.GT.0) THEN
28130  pmd(i)=pmas(kfca,1)
28131  pgd(i)=pmas(kfca,2)
28132  ELSE
28133  pmd(i)=0d0
28134  pgd(i)=0d0
28135  ENDIF
28136  IF(mstp(42).LE.0.OR.pgd(i).LT.parp(41)) THEN
28137  mbw(i)=0
28138  pmg(i)=pmd(i)
28139  rmg(i)=(pmg(i)/pmmx)**2
28140  ELSE
28141  mbw(i)=1
28142  ENDIF
28143  110 CONTINUE
28144 
28145 C...Find allowed mass range and Breit-Wigner parameters.
28146  DO 120 i=1,2
28147  IF(mofsh.EQ.1.AND.loop.EQ.1.AND.mbw(i).EQ.1) THEN
28148  pml(i)=parp(42)
28149  pmu(i)=pmmx-parp(42)
28150  IF(mbw(3-i).EQ.0) pmu(i)=min(pmu(i),pmmx-pmd(3-i))
28151  IF(pmu(i).LT.pml(i)+parj(64)) mbw(i)=-1
28152  ELSEIF(mbw(i).EQ.1.AND.mofsh.NE.5) THEN
28153  ilm=i
28154  IF(mlm.EQ.2) ilm=3-i
28155  pml(i)=max(ckin(noff+2*ilm-1),parp(42))
28156  IF(mbw(3-i).EQ.0) THEN
28157  pmu(i)=pmmx-pmd(3-i)
28158  ELSE
28159  pmu(i)=pmmx-max(ckin(noff+5-2*ilm),parp(42))
28160  ENDIF
28161  IF(ckin(noff+2*ilm).GT.ckin(noff+2*ilm-1)) pmu(i)=
28162  & min(pmu(i),ckin(noff+2*ilm))
28163  IF(i.EQ.mlm) pmu(i)=min(pmu(i),0.5d0*pmmx)
28164  IF(meql.EQ.0) pmh(i)=min(pmu(i),0.5d0*pmmx)
28165  IF(pmu(i).LT.pml(i)+parj(64)) mbw(i)=-1
28166  IF(mbw(i).EQ.1) THEN
28167  atl(i)=atan((pml(i)**2-pmd(i)**2)/(pmd(i)*pgd(i)))
28168  atu(i)=atan((pmu(i)**2-pmd(i)**2)/(pmd(i)*pgd(i)))
28169  IF(meql.EQ.0) ath(i)=atan((pmh(i)**2-pmd(i)**2)/(pmd(i)*
28170  & pgd(i)))
28171  ENDIF
28172  ELSEIF(mbw(i).EQ.1.AND.mofsh.EQ.5) THEN
28173  ilm=i
28174  IF(mlm.EQ.2) ilm=3-i
28175  pml(i)=max(ckin(48+i),parp(42))
28176  pmu(i)=pmmx-max(ckin(51-i),parp(42))
28177  IF(mbw(3-i).EQ.0) pmu(i)=min(pmu(i),pmmx-pmd(3-i))
28178  IF(i.EQ.mlm) pmu(i)=min(pmu(i),0.5d0*pmmx)
28179  IF(meql.EQ.0) pmh(i)=min(pmu(i),0.5d0*pmmx)
28180  IF(pmu(i).LT.pml(i)+parj(64)) mbw(i)=-1
28181  IF(mbw(i).EQ.1) THEN
28182  atl(i)=atan((pml(i)**2-pmd(i)**2)/(pmd(i)*pgd(i)))
28183  atu(i)=atan((pmu(i)**2-pmd(i)**2)/(pmd(i)*pgd(i)))
28184  IF(meql.EQ.0) ath(i)=atan((pmh(i)**2-pmd(i)**2)/(pmd(i)*
28185  & pgd(i)))
28186  ENDIF
28187  ENDIF
28188  120 CONTINUE
28189  IF(mbw(1).LT.0.OR.mbw(2).LT.0.OR.(mbw(1).EQ.0.AND.mbw(2).EQ.0))
28190  &THEN
28191  CALL pyerrm(3,'(PYOFSH:) no allowed decay product masses')
28192  mint(51)=1
28193  RETURN
28194  ENDIF
28195 
28196 C...Calculation of partial width of resonance.
28197  IF(mofsh.EQ.1) THEN
28198 
28199 C..If only one integration, pick that to be the inner.
28200  IF(mbw(1).EQ.0) THEN
28201  pm2=pmd(1)
28202  pmd(1)=pmd(2)
28203  pgd(1)=pgd(2)
28204  pml(1)=pml(2)
28205  pmu(1)=pmu(2)
28206  ELSEIF(mbw(2).EQ.0) THEN
28207  pm2=pmd(2)
28208  ENDIF
28209 
28210 C...Start outer loop of integration.
28211  IF(mbw(1).EQ.1.AND.mbw(2).EQ.1) THEN
28212  atl2=atan((pml(2)**2-pmd(2)**2)/(pmd(2)*pgd(2)))
28213  atu2=atan((pmu(2)**2-pmd(2)**2)/(pmd(2)*pgd(2)))
28214  npt2=1
28215  xpt2(1)=1d0
28216  inx2(1)=0
28217  fmax2=0d0
28218  ENDIF
28219  130 IF(mbw(1).EQ.1.AND.mbw(2).EQ.1) THEN
28220  pm2s=pmd(2)**2+pmd(2)*pgd(2)*tan(atl2+xpt2(npt2)*(atu2-atl2))
28221  pm2=min(pmu(2),max(pml(2),sqrt(max(0d0,pm2s))))
28222  ENDIF
28223  rm2=(pm2/pmmx)**2
28224 
28225 C...Start inner loop of integration.
28226  pml1=pml(1)
28227  pmu1=min(pmu(1),pmmx-pm2)
28228  IF(meql.EQ.1) pmu1=min(pmu1,pm2)
28229  atl1=atan((pml1**2-pmd(1)**2)/(pmd(1)*pgd(1)))
28230  atu1=atan((pmu1**2-pmd(1)**2)/(pmd(1)*pgd(1)))
28231  IF(pml1+parj(64).GE.pmu1.OR.atl1+1d-7.GE.atu1) THEN
28232  func2=0d0
28233  goto 180
28234  ENDIF
28235  npt1=1
28236  xpt1(1)=1d0
28237  inx1(1)=0
28238  fmax1=0d0
28239  140 pm1s=pmd(1)**2+pmd(1)*pgd(1)*tan(atl1+xpt1(npt1)*(atu1-atl1))
28240  pm1=min(pmu1,max(pml1,sqrt(max(0d0,pm1s))))
28241  rm1=(pm1/pmmx)**2
28242 
28243 C...Evaluate function value - inner loop.
28244  func1=sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))
28245  IF(mmed.EQ.1) func1=func1*((1d0-rm1-rm2)**2+8d0*rm1*rm2)
28246  IF(mmed.EQ.2) func1=func1**3*(1d0+10d0*rm1+10d0*rm2+rm1**2+
28247  & rm2**2+10d0*rm1*rm2)
28248  IF(func1.GT.fmax1) fmax1=func1
28249  fpt1(npt1)=func1
28250 
28251 C...Go to next position in inner loop.
28252  IF(npt1.EQ.1) THEN
28253  npt1=npt1+1
28254  xpt1(npt1)=0d0
28255  inx1(npt1)=1
28256  goto 140
28257  ELSEIF(npt1.LE.8) THEN
28258  npt1=npt1+1
28259  IF(npt1.LE.4.OR.npt1.EQ.6) ish1=1
28260  ish1=ish1+1
28261  xpt1(npt1)=0.5d0*(xpt1(ish1)+xpt1(inx1(ish1)))
28262  inx1(npt1)=inx1(ish1)
28263  inx1(ish1)=npt1
28264  goto 140
28265  ELSEIF(npt1.LT.100) THEN
28266  isn1=ish1
28267  150 ish1=ish1+1
28268  IF(ish1.GT.npt1) ish1=2
28269  IF(ish1.EQ.isn1) goto 160
28270  dfpt1=abs(fpt1(ish1)-fpt1(inx1(ish1)))
28271  IF(dfpt1.LT.parp(43)*fmax1) goto 150
28272  npt1=npt1+1
28273  xpt1(npt1)=0.5d0*(xpt1(ish1)+xpt1(inx1(ish1)))
28274  inx1(npt1)=inx1(ish1)
28275  inx1(ish1)=npt1
28276  goto 140
28277  ENDIF
28278 
28279 C...Calculate integral over inner loop.
28280  160 fsum1=0d0
28281  DO 170 ipt1=2,npt1
28282  fsum1=fsum1+0.5d0*(fpt1(ipt1)+fpt1(inx1(ipt1)))*
28283  & (xpt1(inx1(ipt1))-xpt1(ipt1))
28284  170 CONTINUE
28285  func2=fsum1*(atu1-atl1)/paru(1)
28286  180 IF(mbw(1).EQ.1.AND.mbw(2).EQ.1) THEN
28287  IF(func2.GT.fmax2) fmax2=func2
28288  fpt2(npt2)=func2
28289 
28290 C...Go to next position in outer loop.
28291  IF(npt2.EQ.1) THEN
28292  npt2=npt2+1
28293  xpt2(npt2)=0d0
28294  inx2(npt2)=1
28295  goto 130
28296  ELSEIF(npt2.LE.8) THEN
28297  npt2=npt2+1
28298  IF(npt2.LE.4.OR.npt2.EQ.6) ish2=1
28299  ish2=ish2+1
28300  xpt2(npt2)=0.5d0*(xpt2(ish2)+xpt2(inx2(ish2)))
28301  inx2(npt2)=inx2(ish2)
28302  inx2(ish2)=npt2
28303  goto 130
28304  ELSEIF(npt2.LT.100) THEN
28305  isn2=ish2
28306  190 ish2=ish2+1
28307  IF(ish2.GT.npt2) ish2=2
28308  IF(ish2.EQ.isn2) goto 200
28309  dfpt2=abs(fpt2(ish2)-fpt2(inx2(ish2)))
28310  IF(dfpt2.LT.parp(43)*fmax2) goto 190
28311  npt2=npt2+1
28312  xpt2(npt2)=0.5d0*(xpt2(ish2)+xpt2(inx2(ish2)))
28313  inx2(npt2)=inx2(ish2)
28314  inx2(ish2)=npt2
28315  goto 130
28316  ENDIF
28317 
28318 C...Calculate integral over outer loop.
28319  200 fsum2=0d0
28320  DO 210 ipt2=2,npt2
28321  fsum2=fsum2+0.5d0*(fpt2(ipt2)+fpt2(inx2(ipt2)))*
28322  & (xpt2(inx2(ipt2))-xpt2(ipt2))
28323  210 CONTINUE
28324  fsum2=fsum2*(atu2-atl2)/paru(1)
28325  IF(meql.EQ.1) fsum2=2d0*fsum2
28326  ELSE
28327  fsum2=func2
28328  ENDIF
28329 
28330 C...Save result; second integration for user-selected mass range.
28331  IF(loop.EQ.1) widw=fsum2
28332  wid2=fsum2
28333  IF(loop.EQ.1.AND.(ckin(46).GE.ckin(45).OR.ckin(48).GE.ckin(47)
28334  & .OR.max(ckin(45),ckin(47)).GE.1.01d0*parp(42))) THEN
28335  loop=2
28336  goto 100
28337  ENDIF
28338  ret1=widw
28339  ret2=wid2/widw
28340 
28341 C...Select two decay product masses of a resonance.
28342  ELSEIF(mofsh.EQ.2.OR.mofsh.EQ.5) THEN
28343  220 DO 230 i=1,2
28344  IF(mbw(i).EQ.0) goto 230
28345  pmbw=pmd(i)**2+pmd(i)*pgd(i)*tan(atl(i)+pyr(0)*
28346  & (atu(i)-atl(i)))
28347  pmg(i)=min(pmu(i),max(pml(i),sqrt(max(0d0,pmbw))))
28348  rmg(i)=(pmg(i)/pmmx)**2
28349  230 CONTINUE
28350  IF((meql.EQ.1.AND.pmg(max(1,mlm)).GT.pmg(min(2,3-mlm))).OR.
28351  & pmg(1)+pmg(2)+parj(64).GT.pmmx) goto 220
28352 
28353 C...Weight with matrix element (if none known, use beta factor).
28354  flam=sqrt(max(0d0,(1d0-rmg(1)-rmg(2))**2-4d0*rmg(1)*rmg(2)))
28355  IF(mmed.EQ.1) THEN
28356  wtbe=flam*((1d0-rmg(1)-rmg(2))**2+8d0*rmg(1)*rmg(2))
28357  ELSEIF(mmed.EQ.2) THEN
28358  wtbe=flam**3*(1d0+10d0*rmg(1)+10d0*rmg(2)+rmg(1)**2+
28359  & rmg(2)**2+10d0*rmg(1)*rmg(2))
28360  ELSEIF(mmed.EQ.3) THEN
28361  wtbe=flam*(rmg(1)+flam**2/12d0)
28362  ELSE
28363  wtbe=flam
28364  ENDIF
28365  IF(wtbe.LT.pyr(0)) goto 220
28366  ret1=pmg(1)
28367  ret2=pmg(2)
28368 
28369 C...Find suitable set of masses for initialization of 2 -> 2 processes.
28370  ELSEIF(mofsh.EQ.3) THEN
28371  IF(mbw(1).NE.0.AND.mbw(2).EQ.0) THEN
28372  pmg(1)=min(pmd(1),0.5d0*(pml(1)+pmu(1)))
28373  pmg(2)=pmd(2)
28374  ELSEIF(mbw(2).NE.0.AND.mbw(1).EQ.0) THEN
28375  pmg(1)=pmd(1)
28376  pmg(2)=min(pmd(2),0.5d0*(pml(2)+pmu(2)))
28377  ELSE
28378  idiv=-1
28379  240 idiv=idiv+1
28380  pmg(1)=min(pmd(1),0.1d0*(idiv*pml(1)+(10-idiv)*pmu(1)))
28381  pmg(2)=min(pmd(2),0.1d0*(idiv*pml(2)+(10-idiv)*pmu(2)))
28382  IF(idiv.LE.9.AND.pmg(1)+pmg(2).GT.0.9d0*pmmx) goto 240
28383  ENDIF
28384  ret1=pmg(1)
28385  ret2=pmg(2)
28386 
28387 C...Evaluate importance of excluded tails of Breit-Wigners.
28388  IF(meql.EQ.0.AND.mbw(1).EQ.1.AND.mbw(2).EQ.1.AND.pmd(1)+pmd(2)
28389  & .GT.pmmx.AND.pmh(1).GT.pml(1).AND.pmh(2).GT.pml(2)) meql=2
28390  IF(meql.LE.1) THEN
28391  vint(80)=1d0
28392  DO 250 i=1,2
28393  IF(mbw(i).NE.0) vint(80)=vint(80)*1.25d0*(atu(i)-atl(i))/
28394  & paru(1)
28395  250 CONTINUE
28396  ELSE
28397  vint(80)=(1.25d0/paru(1))**2*max((atu(1)-atl(1))*
28398  & (ath(2)-atl(2)),(ath(1)-atl(1))*(atu(2)-atl(2)))
28399  ENDIF
28400  IF((isub.EQ.15.OR.isub.EQ.19.OR.isub.EQ.30.OR.isub.EQ.35).AND.
28401  & mstp(43).NE.2) vint(80)=2d0*vint(80)
28402  IF(isub.EQ.22.AND.mstp(43).NE.2) vint(80)=4d0*vint(80)
28403  IF(meql.GE.1) vint(80)=2d0*vint(80)
28404 
28405 C...Pick one particle to be the lighter (if improves efficiency).
28406  ELSEIF(mofsh.EQ.4) THEN
28407  IF(meql.EQ.0.AND.mbw(1).EQ.1.AND.mbw(2).EQ.1.AND.pmd(1)+pmd(2)
28408  & .GT.pmmx.AND.pmh(1).GT.pml(1).AND.pmh(2).GT.pml(2)) meql=2
28409  260 IF(meql.EQ.2) mlm=int(1.5d0+pyr(0))
28410 
28411 C...Select two masses according to Breit-Wigner + flat in s + 1/s.
28412  DO 270 i=1,2
28413  IF(mbw(i).EQ.0) goto 270
28414  pmv=pmu(i)
28415  IF(meql.EQ.2.AND.i.EQ.mlm) pmv=pmh(i)
28416  atv=atu(i)
28417  IF(meql.EQ.2.AND.i.EQ.mlm) atv=ath(i)
28418  rbr=pyr(0)
28419  IF((isub.EQ.15.OR.isub.EQ.19.OR.isub.EQ.22.OR.isub.EQ.30.OR.
28420  & isub.EQ.35).AND.mstp(43).NE.2) rbr=2d0*rbr
28421  IF(rbr.LT.0.8d0) THEN
28422  pmsr=pmd(i)**2+pmd(i)*pgd(i)*tan(atl(i)+pyr(0)*(atv-atl(i)))
28423  pmg(i)=min(pmv,max(pml(i),sqrt(max(0d0,pmsr))))
28424  ELSEIF(rbr.LT.0.9d0) THEN
28425  pmg(i)=sqrt(max(0d0,pml(i)**2+pyr(0)*(pmv**2-pml(i)**2)))
28426  ELSEIF(rbr.LT.1.5d0) THEN
28427  pmg(i)=pml(i)*(pmv/pml(i))**pyr(0)
28428  ELSE
28429  pmg(i)=sqrt(max(0d0,pml(i)**2*pmv**2/(pml(i)**2+pyr(0)*
28430  & (pmv**2-pml(i)**2))))
28431  ENDIF
28432  270 CONTINUE
28433  IF((meql.GE.1.AND.pmg(max(1,mlm)).GT.pmg(min(2,3-mlm))).OR.
28434  & pmg(1)+pmg(2)+parj(64).GT.pmmx) THEN
28435  IF(mint(48).EQ.1.AND.mstp(171).EQ.0) THEN
28436  ngen(0,1)=ngen(0,1)+1
28437  ngen(mint(1),1)=ngen(mint(1),1)+1
28438  goto 260
28439  ELSE
28440  mint(51)=1
28441  RETURN
28442  ENDIF
28443  ENDIF
28444  ret1=pmg(1)
28445  ret2=pmg(2)
28446 
28447 C...Give weight for selected mass distribution.
28448  vint(80)=1d0
28449  DO 280 i=1,2
28450  IF(mbw(i).EQ.0) goto 280
28451  pmv=pmu(i)
28452  IF(meql.EQ.2.AND.i.EQ.mlm) pmv=pmh(i)
28453  atv=atu(i)
28454  IF(meql.EQ.2.AND.i.EQ.mlm) atv=ath(i)
28455  f0=pmd(i)*pgd(i)/((pmg(i)**2-pmd(i)**2)**2+
28456  & (pmd(i)*pgd(i))**2)/paru(1)
28457  f1=1d0
28458  f2=1d0/pmg(i)**2
28459  f3=1d0/pmg(i)**4
28460  fi0=(atv-atl(i))/paru(1)
28461  fi1=pmv**2-pml(i)**2
28462  fi2=2d0*log(pmv/pml(i))
28463  fi3=1d0/pml(i)**2-1d0/pmv**2
28464  IF((isub.EQ.15.OR.isub.EQ.19.OR.isub.EQ.22.OR.isub.EQ.30.OR.
28465  & isub.EQ.35).AND.mstp(43).NE.2) THEN
28466  vint(80)=vint(80)*20d0/(8d0+(fi0/f0)*(f1/fi1+6d0*f2/fi2+
28467  & 5d0*f3/fi3))
28468  ELSE
28469  vint(80)=vint(80)*10d0/(8d0+(fi0/f0)*(f1/fi1+f2/fi2))
28470  ENDIF
28471  vint(80)=vint(80)*fi0
28472  280 CONTINUE
28473  IF(meql.GE.1) vint(80)=2d0*vint(80)
28474  ENDIF
28475 
28476  RETURN
28477  END
28478 
28479 C***********************************************************************
28480 
28481 C...PYRECO
28482 C...Handles the possibility of colour reconnection in W+W- events,
28483 C...Based on the main scenarios of the Sjostrand and Khoze study:
28484 C...I, II, II', intermediate and instantaneous; plus one model
28485 C...along the lines of the Gustafson and Hakkinen: GH.
28486 C...Note: also handles Z0 Z0 and W-W+ events, but notation below
28487 C...is as if first resonance is W+ and second W-.
28488 
28489  SUBROUTINE pyreco(IW1,IW2,NSD1,NAFT1)
28490 
28491 C...Double precision and integer declarations.
28492  IMPLICIT DOUBLE PRECISION(a-h, o-z)
28493  IMPLICIT INTEGER(i-n)
28494  INTEGER pyk,pychge,pycomp
28495 C...Parameter value; number of points in MC integration.
28496  parameter(npt=100)
28497 C...Commonblocks.
28498  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
28499  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
28500  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
28501  common/pypars/mstp(200),parp(200),msti(200),pari(200)
28502  common/pyint1/mint(400),vint(400)
28503  SAVE /pyjets/,/pydat1/,/pydat2/,/pypars/,/pyint1/
28504 C...Local arrays.
28505  dimension nbeg(2),nend(2),inp(50),inm(50),beww(3),xp(3),xm(3),
28506  &v1(3),v2(3),betp(50,4),dirp(50,3),betm(50,4),dirm(50,3),
28507  &xd(4),xb(4),iap(npt),iam(npt),wta(npt),v1p(3),v2p(3),v1m(3),
28508  &v2m(3),q(4,3),xpp(3),xmm(3),ipc(20),imc(20),tc(0:20),tpc(20),
28509  &tmc(20),ijoin(100)
28510 
28511 C...Functions to give four-product and to do determinants.
28512  four(i,j)=p(i,4)*p(j,4)-p(i,1)*p(j,1)-p(i,2)*p(j,2)-p(i,3)*p(j,3)
28513  deter(i,j,l)=q(i,1)*q(j,2)*q(l,3)-q(i,1)*q(l,2)*q(j,3)+
28514  &q(j,1)*q(l,2)*q(i,3)-q(j,1)*q(i,2)*q(l,3)+
28515  &q(l,1)*q(i,2)*q(j,3)-q(l,1)*q(j,2)*q(i,3)
28516 
28517 C...Only allow fraction of recoupling for GH, intermediate and
28518 C...instantaneous.
28519  IF(mstp(115).EQ.5.OR.mstp(115).EQ.11.OR.mstp(115).EQ.12) THEN
28520  IF(pyr(0).GT.parp(120)) RETURN
28521  ENDIF
28522  isub=mint(1)
28523 
28524 C...Common part for scenarios I, II, II', and GH.
28525  IF(mstp(115).EQ.1.OR.mstp(115).EQ.2.OR.mstp(115).EQ.3.OR.
28526  &mstp(115).EQ.5) THEN
28527 
28528 C...Read out frequently-used parameters.
28529  pi=paru(1)
28530  hbar=paru(3)
28531  pmw=pmas(24,1)
28532  IF(isub.EQ.22) pmw=pmas(23,1)
28533  pgw=pmas(24,2)
28534  IF(isub.EQ.22) pgw=pmas(23,2)
28535  tfrag=parp(115)
28536  rhad=parp(116)
28537  fact=parp(117)
28538  blowr=parp(118)
28539  blowt=parp(119)
28540 
28541 C...Find range of decay products of the W's.
28542 C...Background: the W's are stored in IW1 and IW2.
28543 C...Their direct decay products in NSD1+1 through NSD1+4.
28544 C...Products after shower (if any) in NSD1+5 through NAFT1
28545 C...for first W and in NAFT1+1 through N for the second.
28546  IF(naft1.GT.nsd1+4) THEN
28547  nbeg(1)=nsd1+5
28548  nend(1)=naft1
28549  ELSE
28550  nbeg(1)=nsd1+1
28551  nend(1)=nsd1+2
28552  ENDIF
28553  IF(n.GT.naft1) THEN
28554  nbeg(2)=naft1+1
28555  nend(2)=n
28556  ELSE
28557  nbeg(2)=nsd1+3
28558  nend(2)=nsd1+4
28559  ENDIF
28560 
28561 C...Rearrange parton shower products along strings.
28562  nold=n
28563  CALL pyprep(nsd1+1)
28564  IF(mint(51).NE.0) RETURN
28565 
28566 C...Find partons pointing back to W+ and W-; store them with quark
28567 C...end of string first.
28568  nnp=0
28569  nnm=0
28570  isgp=0
28571  isgm=0
28572  DO 120 i=nold+1,n
28573  IF(k(i,1).NE.1.AND.k(i,1).NE.2) goto 120
28574  IF(iabs(k(i,2)).GE.22) goto 120
28575  IF(k(i,3).GE.nbeg(1).AND.k(i,3).LE.nend(1)) THEN
28576  IF(isgp.EQ.0) isgp=isign(1,k(i,2))
28577  nnp=nnp+1
28578  IF(isgp.EQ.1) THEN
28579  inp(nnp)=i
28580  ELSE
28581  DO 100 i1=nnp,2,-1
28582  inp(i1)=inp(i1-1)
28583  100 CONTINUE
28584  inp(1)=i
28585  ENDIF
28586  IF(k(i,1).EQ.1) isgp=0
28587  ELSEIF(k(i,3).GE.nbeg(2).AND.k(i,3).LE.nend(2)) THEN
28588  IF(isgm.EQ.0) isgm=isign(1,k(i,2))
28589  nnm=nnm+1
28590  IF(isgm.EQ.1) THEN
28591  inm(nnm)=i
28592  ELSE
28593  DO 110 i1=nnm,2,-1
28594  inm(i1)=inm(i1-1)
28595  110 CONTINUE
28596  inm(1)=i
28597  ENDIF
28598  IF(k(i,1).EQ.1) isgm=0
28599  ENDIF
28600  120 CONTINUE
28601 
28602 C...Boost to W+W- rest frame (not strictly needed).
28603  DO 130 j=1,3
28604  beww(j)=(p(iw1,j)+p(iw2,j))/(p(iw1,4)+p(iw2,4))
28605  130 CONTINUE
28606  CALL pyrobo(iw1,iw1,0d0,0d0,-beww(1),-beww(2),-beww(3))
28607  CALL pyrobo(iw2,iw2,0d0,0d0,-beww(1),-beww(2),-beww(3))
28608  CALL pyrobo(nold+1,n,0d0,0d0,-beww(1),-beww(2),-beww(3))
28609 
28610 C...Select decay vertices of W+ and W-.
28611  tp=hbar*(-log(pyr(0)))*p(iw1,4)/
28612  & sqrt((p(iw1,5)**2-pmw**2)**2+(p(iw1,5)**2*pgw/pmw)**2)
28613  tm=hbar*(-log(pyr(0)))*p(iw2,4)/
28614  & sqrt((p(iw2,5)**2-pmw**2)**2+(p(iw2,5)**2*pgw/pmw)**2)
28615  gtmax=max(tp,tm)
28616  DO 140 j=1,3
28617  xp(j)=tp*p(iw1,j)/p(iw1,4)
28618  xm(j)=tm*p(iw2,j)/p(iw2,4)
28619  140 CONTINUE
28620 
28621 C...Begin scenario I specifics.
28622  IF(mstp(115).EQ.1) THEN
28623 
28624 C...Reconstruct velocity and direction of W+ string pieces.
28625  DO 170 iip=1,nnp-1
28626  IF(k(inp(iip),2).LT.0) goto 170
28627  i1=inp(iip)
28628  i2=inp(iip+1)
28629  p1a=sqrt(p(i1,1)**2+p(i1,2)**2+p(i1,3)**2)
28630  p2a=sqrt(p(i2,1)**2+p(i2,2)**2+p(i2,3)**2)
28631  DO 150 j=1,3
28632  v1(j)=p(i1,j)/p1a
28633  v2(j)=p(i2,j)/p2a
28634  betp(iip,j)=0.5d0*(v1(j)+v2(j))
28635  dirp(iip,j)=v1(j)-v2(j)
28636  150 CONTINUE
28637  betp(iip,4)=1d0/sqrt(1d0-betp(iip,1)**2-betp(iip,2)**2-
28638  & betp(iip,3)**2)
28639  dirl=sqrt(dirp(iip,1)**2+dirp(iip,2)**2+dirp(iip,3)**2)
28640  DO 160 j=1,3
28641  dirp(iip,j)=dirp(iip,j)/dirl
28642  160 CONTINUE
28643  170 CONTINUE
28644 
28645 C...Reconstruct velocity and direction of W- string pieces.
28646  DO 200 iim=1,nnm-1
28647  IF(k(inm(iim),2).LT.0) goto 200
28648  i1=inm(iim)
28649  i2=inm(iim+1)
28650  p1a=sqrt(p(i1,1)**2+p(i1,2)**2+p(i1,3)**2)
28651  p2a=sqrt(p(i2,1)**2+p(i2,2)**2+p(i2,3)**2)
28652  DO 180 j=1,3
28653  v1(j)=p(i1,j)/p1a
28654  v2(j)=p(i2,j)/p2a
28655  betm(iim,j)=0.5d0*(v1(j)+v2(j))
28656  dirm(iim,j)=v1(j)-v2(j)
28657  180 CONTINUE
28658  betm(iim,4)=1d0/sqrt(1d0-betm(iim,1)**2-betm(iim,2)**2-
28659  & betm(iim,3)**2)
28660  dirl=sqrt(dirm(iim,1)**2+dirm(iim,2)**2+dirm(iim,3)**2)
28661  DO 190 j=1,3
28662  dirm(iim,j)=dirm(iim,j)/dirl
28663  190 CONTINUE
28664  200 CONTINUE
28665 
28666 C...Loop over number of space-time points.
28667  nacc=0
28668  sum=0d0
28669  DO 250 ipt=1,npt
28670 
28671 C...Pick x,y,z,t Gaussian (width RHAD and TFRAG, respectively).
28672  r=sqrt(-log(pyr(0)))
28673  phi=2d0*pi*pyr(0)
28674  x=blowr*rhad*r*cos(phi)
28675  y=blowr*rhad*r*sin(phi)
28676  r=sqrt(-log(pyr(0)))
28677  phi=2d0*pi*pyr(0)
28678  z=blowr*rhad*r*cos(phi)
28679  t=gtmax+blowt*sqrt(0.5d0)*tfrag*r*abs(sin(phi))
28680 
28681 C...Reject impossible points. Weight for sample distribution.
28682  IF(t**2-x**2-y**2-z**2.LT.0d0) goto 250
28683  wtsmp=exp(-(x**2+y**2+z**2)/(blowr*rhad)**2)*
28684  & exp(-2d0*(t-gtmax)**2/(blowt*tfrag)**2)
28685 
28686 C...Loop over W+ string pieces and find one with largest weight.
28687  imaxp=0
28688  wtmaxp=1d-10
28689  xd(1)=x-xp(1)
28690  xd(2)=y-xp(2)
28691  xd(3)=z-xp(3)
28692  xd(4)=t-tp
28693  DO 220 iip=1,nnp-1
28694  IF(k(inp(iip),2).LT.0) goto 220
28695  bed=betp(iip,1)*xd(1)+betp(iip,2)*xd(2)+betp(iip,3)*xd(3)
28696  bedg=betp(iip,4)*(betp(iip,4)*bed/(1d0+betp(iip,4))-xd(4))
28697  DO 210 j=1,3
28698  xb(j)=xd(j)+bedg*betp(iip,j)
28699  210 CONTINUE
28700  xb(4)=betp(iip,4)*(xd(4)-bed)
28701  sr2=xb(1)**2+xb(2)**2+xb(3)**2
28702  sz2=(dirp(iip,1)*xb(1)+dirp(iip,2)*xb(2)+
28703  & dirp(iip,3)*xb(3))**2
28704  wtp=exp(-(sr2-sz2)/(2d0*rhad**2))*exp(-(xb(4)**2-sz2)/
28705  & tfrag**2)
28706  IF(xb(4)-sqrt(sr2).LT.0d0) wtp=0d0
28707  IF(wtp.GT.wtmaxp) THEN
28708  imaxp=iip
28709  wtmaxp=wtp
28710  ENDIF
28711  220 CONTINUE
28712 
28713 C...Loop over W- string pieces and find one with largest weight.
28714  imaxm=0
28715  wtmaxm=1d-10
28716  xd(1)=x-xm(1)
28717  xd(2)=y-xm(2)
28718  xd(3)=z-xm(3)
28719  xd(4)=t-tm
28720  DO 240 iim=1,nnm-1
28721  IF(k(inm(iim),2).LT.0) goto 240
28722  bed=betm(iim,1)*xd(1)+betm(iim,2)*xd(2)+betm(iim,3)*xd(3)
28723  bedg=betm(iim,4)*(betm(iim,4)*bed/(1d0+betm(iim,4))-xd(4))
28724  DO 230 j=1,3
28725  xb(j)=xd(j)+bedg*betm(iim,j)
28726  230 CONTINUE
28727  xb(4)=betm(iim,4)*(xd(4)-bed)
28728  sr2=xb(1)**2+xb(2)**2+xb(3)**2
28729  sz2=(dirm(iim,1)*xb(1)+dirm(iim,2)*xb(2)+
28730  & dirm(iim,3)*xb(3))**2
28731  wtm=exp(-(sr2-sz2)/(2d0*rhad**2))*exp(-(xb(4)**2-sz2)/
28732  & tfrag**2)
28733  IF(xb(4)-sqrt(sr2).LT.0d0) wtm=0d0
28734  IF(wtm.GT.wtmaxm) THEN
28735  imaxm=iim
28736  wtmaxm=wtm
28737  ENDIF
28738  240 CONTINUE
28739 
28740 C...Result of integration.
28741  wt=0d0
28742  IF(imaxp.NE.0.AND.imaxm.NE.0) THEN
28743  wt=wtmaxp*wtmaxm/wtsmp
28744  sum=sum+wt
28745  nacc=nacc+1
28746  iap(nacc)=imaxp
28747  iam(nacc)=imaxm
28748  wta(nacc)=wt
28749  ENDIF
28750  250 CONTINUE
28751  res=blowr**3*blowt*sum/npt
28752 
28753 C...Decide whether to reconnect and, if so, where.
28754  iacc=0
28755  prec=1d0-exp(-fact*res)
28756  IF(prec.GT.pyr(0)) THEN
28757  rsum=pyr(0)*sum
28758  DO 260 ia=1,nacc
28759  iacc=ia
28760  rsum=rsum-wta(ia)
28761  IF(rsum.LE.0d0) goto 270
28762  260 CONTINUE
28763  270 iip=iap(iacc)
28764  iim=iam(iacc)
28765  ENDIF
28766 
28767 C...Begin scenario II and II' specifics.
28768  ELSEIF(mstp(115).EQ.2.OR.mstp(115).EQ.3) THEN
28769 
28770 C...Loop through all string pieces, one from W+ and one from W-.
28771  ncross=0
28772  tc(0)=0d0
28773  DO 340 iip=1,nnp-1
28774  IF(k(inp(iip),2).LT.0) goto 340
28775  i1p=inp(iip)
28776  i2p=inp(iip+1)
28777  DO 330 iim=1,nnm-1
28778  IF(k(inm(iim),2).LT.0) goto 330
28779  i1m=inm(iim)
28780  i2m=inm(iim+1)
28781 
28782 C...Find endpoint velocity vectors.
28783  DO 280 j=1,3
28784  v1p(j)=p(i1p,j)/p(i1p,4)
28785  v2p(j)=p(i2p,j)/p(i2p,4)
28786  v1m(j)=p(i1m,j)/p(i1m,4)
28787  v2m(j)=p(i2m,j)/p(i2m,4)
28788  280 CONTINUE
28789 
28790 C...Define q matrix and find t.
28791  DO 290 j=1,3
28792  q(1,j)=v2p(j)-v1p(j)
28793  q(2,j)=-(v2m(j)-v1m(j))
28794  q(3,j)=xp(j)-xm(j)-tp*v1p(j)+tm*v1m(j)
28795  q(4,j)=v1p(j)-v1m(j)
28796  290 CONTINUE
28797  t=-deter(1,2,3)/deter(1,2,4)
28798 
28799 C...Find alpha and beta; i.e. coordinates of crossing point.
28800  s11=q(1,1)*(t-tp)
28801  s12=q(2,1)*(t-tm)
28802  s13=q(3,1)+q(4,1)*t
28803  s21=q(1,2)*(t-tp)
28804  s22=q(2,2)*(t-tm)
28805  s23=q(3,2)+q(4,2)*t
28806  den=s11*s22-s12*s21
28807  alp=(s12*s23-s22*s13)/den
28808  bet=(s21*s13-s11*s23)/den
28809 
28810 C...Check if solution acceptable.
28811  iansw=1
28812  IF(t.LT.gtmax) iansw=0
28813  IF(alp.LT.0d0.OR.alp.GT.1d0) iansw=0
28814  IF(bet.LT.0d0.OR.bet.GT.1d0) iansw=0
28815 
28816 C...Find point of crossing and check that not inconsistent.
28817  DO 300 j=1,3
28818  xpp(j)=xp(j)+(v1p(j)+alp*(v2p(j)-v1p(j)))*(t-tp)
28819  xmm(j)=xm(j)+(v1m(j)+bet*(v2m(j)-v1m(j)))*(t-tm)
28820  300 CONTINUE
28821  d2pm=(xpp(1)-xmm(1))**2+(xpp(2)-xmm(2))**2+
28822  & (xpp(3)-xmm(3))**2
28823  d2p=xpp(1)**2+xpp(2)**2+xpp(3)**2
28824  d2m=xmm(1)**2+xmm(2)**2+xmm(3)**2
28825  IF(d2pm.GT.1d-4*(d2p+d2m)) iansw=-1
28826 
28827 C...Find string eigentimes at crossing.
28828  IF(iansw.EQ.1) THEN
28829  taup=sqrt(max(0d0,(t-tp)**2-(xpp(1)-xp(1))**2-
28830  & (xpp(2)-xp(2))**2-(xpp(3)-xp(3))**2))
28831  taum=sqrt(max(0d0,(t-tm)**2-(xmm(1)-xm(1))**2-
28832  & (xmm(2)-xm(2))**2-(xmm(3)-xm(3))**2))
28833  ELSE
28834  taup=0d0
28835  taum=0d0
28836  ENDIF
28837 
28838 C...Order crossings by time. End loop over crossings.
28839  IF(iansw.EQ.1.AND.ncross.LT.20) THEN
28840  ncross=ncross+1
28841  DO 310 i1=ncross,1,-1
28842  IF(t.GT.tc(i1-1).OR.i1.EQ.1) THEN
28843  ipc(i1)=iip
28844  imc(i1)=iim
28845  tc(i1)=t
28846  tpc(i1)=taup
28847  tmc(i1)=taum
28848  goto 320
28849  ELSE
28850  ipc(i1)=ipc(i1-1)
28851  imc(i1)=imc(i1-1)
28852  tc(i1)=tc(i1-1)
28853  tpc(i1)=tpc(i1-1)
28854  tmc(i1)=tmc(i1-1)
28855  ENDIF
28856  310 CONTINUE
28857  320 CONTINUE
28858  ENDIF
28859  330 CONTINUE
28860  340 CONTINUE
28861 
28862 C...Loop over crossings; find first (if any) acceptable one.
28863  iacc=0
28864  IF(ncross.GE.1) THEN
28865  DO 350 ic=1,ncross
28866  pnfrag=exp(-(tpc(ic)**2+tmc(ic)**2)/tfrag**2)
28867  IF(pnfrag.GT.pyr(0)) THEN
28868 C...Scenario II: only compare with fragmentation time.
28869  IF(mstp(115).EQ.2) THEN
28870  iacc=ic
28871  iip=ipc(iacc)
28872  iim=imc(iacc)
28873  goto 360
28874 C...Scenario II': also require that string length decreases.
28875  ELSE
28876  iip=ipc(ic)
28877  iim=imc(ic)
28878  i1p=inp(iip)
28879  i2p=inp(iip+1)
28880  i1m=inm(iim)
28881  i2m=inm(iim+1)
28882  elold=four(i1p,i2p)*four(i1m,i2m)
28883  elnew=four(i1p,i2m)*four(i1m,i2p)
28884  IF(elnew.LT.elold) THEN
28885  iacc=ic
28886  iip=ipc(iacc)
28887  iim=imc(iacc)
28888  goto 360
28889  ENDIF
28890  ENDIF
28891  ENDIF
28892  350 CONTINUE
28893  360 CONTINUE
28894  ENDIF
28895 
28896 C...Begin scenario GH specifics.
28897  ELSEIF(mstp(115).EQ.5) THEN
28898 
28899 C...Loop through all string pieces, one from W+ and one from W-.
28900  iacc=0
28901  elmin=1d0
28902  DO 380 iip=1,nnp-1
28903  IF(k(inp(iip),2).LT.0) goto 380
28904  i1p=inp(iip)
28905  i2p=inp(iip+1)
28906  DO 370 iim=1,nnm-1
28907  IF(k(inm(iim),2).LT.0) goto 370
28908  i1m=inm(iim)
28909  i2m=inm(iim+1)
28910 
28911 C...Look for largest decrease of (exponent of) Lambda measure.
28912  elold=four(i1p,i2p)*four(i1m,i2m)
28913  elnew=four(i1p,i2m)*four(i1m,i2p)
28914  eldif=elnew/max(1d-10,elold)
28915  IF(eldif.LT.elmin) THEN
28916  iacc=iip+iim
28917  elmin=eldif
28918  ipc(1)=iip
28919  imc(1)=iim
28920  ENDIF
28921  370 CONTINUE
28922  380 CONTINUE
28923  iip=ipc(1)
28924  iim=imc(1)
28925  ENDIF
28926 
28927 C...Common for scenarios I, II, II' and GH: reconnect strings.
28928  IF(iacc.NE.0) THEN
28929  mint(32)=1
28930  njoin=0
28931  DO 390 is=1,nnp+nnm
28932  njoin=njoin+1
28933  IF(is.LE.iip) THEN
28934  i=inp(is)
28935  ELSEIF(is.LE.iip+nnm-iim) THEN
28936  i=inm(is-iip+iim)
28937  ELSEIF(is.LE.iip+nnm) THEN
28938  i=inm(is-iip-nnm+iim)
28939  ELSE
28940  i=inp(is-nnm)
28941  ENDIF
28942  ijoin(njoin)=i
28943  IF(k(i,2).LT.0) THEN
28944  CALL pyjoin(njoin,ijoin)
28945  njoin=0
28946  ENDIF
28947  390 CONTINUE
28948 
28949 C...Restore original event record if no reconnection.
28950  ELSE
28951  DO 400 i=nsd1+1,nold
28952  IF(k(i,1).EQ.13.OR.k(i,1).EQ.14) THEN
28953  k(i,4)=mod(k(i,4),mstu(5)**2)
28954  k(i,5)=mod(k(i,5),mstu(5)**2)
28955  ENDIF
28956  400 CONTINUE
28957  DO 410 i=nold+1,n
28958  k(k(i,3),1)=3
28959  410 CONTINUE
28960  n=nold
28961  ENDIF
28962 
28963 C...Boost back system.
28964  CALL pyrobo(iw1,iw1,0d0,0d0,beww(1),beww(2),beww(3))
28965  CALL pyrobo(iw2,iw2,0d0,0d0,beww(1),beww(2),beww(3))
28966  IF(n.GT.nold) CALL pyrobo(nold+1,n,0d0,0d0,
28967  & beww(1),beww(2),beww(3))
28968 
28969 C...Common part for intermediate and instantaneous scenarios.
28970  ELSEIF(mstp(115).EQ.11.OR.mstp(115).EQ.12) THEN
28971  mint(32)=1
28972 
28973 C...Remove old shower products and reset showering ones.
28974  n=nsd1+4
28975  DO 420 i=nsd1+1,nsd1+4
28976  k(i,1)=3
28977  k(i,4)=mod(k(i,4),mstu(5)**2)
28978  k(i,5)=mod(k(i,5),mstu(5)**2)
28979  420 CONTINUE
28980 
28981 C...Identify quark-antiquark pairs.
28982  iq1=nsd1+1
28983  iq2=nsd1+2
28984  iq3=nsd1+3
28985  IF(k(iq1,2)*k(iq3,2).LT.0) iq3=nsd1+4
28986  iq4=2*nsd1+7-iq3
28987 
28988 C...Reconnect strings.
28989  ijoin(1)=iq1
28990  ijoin(2)=iq4
28991  CALL pyjoin(2,ijoin)
28992  ijoin(1)=iq3
28993  ijoin(2)=iq2
28994  CALL pyjoin(2,ijoin)
28995 
28996 C...Do new parton showers in intermediate scenario.
28997  IF(mstp(71).GE.1.AND.mstp(115).EQ.11) THEN
28998  mstj50=mstj(50)
28999  mstj(50)=0
29000  CALL pyshow(iq1,iq2,p(iw1,5))
29001  CALL pyshow(iq3,iq4,p(iw2,5))
29002  mstj(50)=mstj50
29003 
29004 C...Do new parton showers in instantaneous scenario.
29005  ELSEIF(mstp(71).GE.1.AND.mstp(115).EQ.12) THEN
29006  ppm2=(p(iq1,4)+p(iq4,4))**2-(p(iq1,1)+p(iq4,1))**2-
29007  & (p(iq1,2)+p(iq4,2))**2-(p(iq1,3)+p(iq4,3))**2
29008  ppm=sqrt(max(0d0,ppm2))
29009  CALL pyshow(iq1,iq4,ppm)
29010  ppm2=(p(iq3,4)+p(iq2,4))**2-(p(iq3,1)+p(iq2,1))**2-
29011  & (p(iq3,2)+p(iq2,2))**2-(p(iq3,3)+p(iq2,3))**2
29012  ppm=sqrt(max(0d0,ppm2))
29013  CALL pyshow(iq3,iq2,ppm)
29014  ENDIF
29015  ENDIF
29016 
29017  RETURN
29018  END
29019 
29020 C***********************************************************************
29021 
29022 C...PYKLIM
29023 C...Checks generated variables against pre-set kinematical limits;
29024 C...also calculates limits on variables used in generation.
29025 
29026  SUBROUTINE pyklim(ILIM)
29027 
29028 C...Double precision and integer declarations.
29029  IMPLICIT DOUBLE PRECISION(a-h, o-z)
29030  IMPLICIT INTEGER(i-n)
29031  INTEGER pyk,pychge,pycomp
29032 C...Commonblocks.
29033  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
29034  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
29035  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
29036  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
29037  common/pysubs/msel,mselpd,msub(500),kfin(2,-40:40),ckin(200)
29038  common/pypars/mstp(200),parp(200),msti(200),pari(200)
29039  common/pyint1/mint(400),vint(400)
29040  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
29041  SAVE /pyjets/,/pydat1/,/pydat2/,/pydat3/,/pysubs/,/pypars/,
29042  &/pyint1/,/pyint2/
29043 
29044 C...Common kinematical expressions.
29045  mint(51)=0
29046  isub=mint(1)
29047  istsb=iset(isub)
29048  IF(isub.EQ.96) goto 100
29049  sqm3=vint(63)
29050  sqm4=vint(64)
29051  IF(ilim.NE.0) THEN
29052  IF(abs(sqm3).LT.1d-4.AND.abs(sqm4).LT.1d-4) THEN
29053  ckin09=max(ckin(9),ckin(13))
29054  ckin10=min(ckin(10),ckin(14))
29055  ckin11=max(ckin(11),ckin(15))
29056  ckin12=min(ckin(12),ckin(16))
29057  ELSE
29058  ckin09=max(ckin(9),min(0d0,ckin(13)))
29059  ckin10=min(ckin(10),max(0d0,ckin(14)))
29060  ckin11=max(ckin(11),min(0d0,ckin(15)))
29061  ckin12=min(ckin(12),max(0d0,ckin(16)))
29062  ENDIF
29063  ENDIF
29064  IF(ilim.NE.1) THEN
29065  tau=vint(21)
29066  rm3=sqm3/(tau*vint(2))
29067  rm4=sqm4/(tau*vint(2))
29068  be34=sqrt(max(1d-20,(1d0-rm3-rm4)**2-4d0*rm3*rm4))
29069  ENDIF
29070  pthmin=ckin(3)
29071  IF(min(sqm3,sqm4).LT.ckin(6)**2.AND.istsb.NE.1.AND.istsb.NE.3)
29072  &pthmin=max(ckin(3),ckin(5))
29073 
29074  IF(ilim.EQ.0) THEN
29075 C...Check generated values of tau, y*, cos(theta-hat), and tau' against
29076 C...pre-set kinematical limits.
29077  yst=vint(22)
29078  cth=vint(23)
29079  taup=vint(26)
29080  taue=tau
29081  IF(istsb.GE.3.AND.istsb.LE.5) taue=taup
29082  x1=sqrt(taue)*exp(yst)
29083  x2=sqrt(taue)*exp(-yst)
29084  xf=x1-x2
29085  IF(mint(47).NE.1) THEN
29086  IF(tau*vint(2).LT.ckin(1)**2) mint(51)=1
29087  IF(ckin(2).GE.0d0.AND.tau*vint(2).GT.ckin(2)**2) mint(51)=1
29088  IF(yst.LT.ckin(7).OR.yst.GT.ckin(8)) mint(51)=1
29089  IF(xf.LT.ckin(25).OR.xf.GT.ckin(26)) mint(51)=1
29090  ENDIF
29091  IF(mint(45).NE.1) THEN
29092  IF(x1.LT.ckin(21).OR.x1.GT.ckin(22)) mint(51)=1
29093  ENDIF
29094  IF(mint(46).NE.1) THEN
29095  IF(x2.LT.ckin(23).OR.x2.GT.ckin(24)) mint(51)=1
29096  ENDIF
29097  IF(mint(45).EQ.2) THEN
29098  IF(x1.GT.1d0-2d0*parp(111)/vint(1)) mint(51)=1
29099  ENDIF
29100  IF(mint(46).EQ.2) THEN
29101  IF(x2.GT.1d0-2d0*parp(111)/vint(1)) mint(51)=1
29102  ENDIF
29103  IF(istsb.EQ.2.OR.istsb.EQ.4) THEN
29104  pth=0.5d0*be34*sqrt(tau*vint(2)*max(0d0,1d0-cth**2))
29105  expy3=max(1d-20,(1d0+rm3-rm4+be34*cth)/
29106  & max(1d-20,(1d0+rm3-rm4-be34*cth)))
29107  expy4=max(1d-20,(1d0-rm3+rm4-be34*cth)/
29108  & max(1d-20,(1d0-rm3+rm4+be34*cth)))
29109  y3=yst+0.5d0*log(expy3)
29110  y4=yst+0.5d0*log(expy4)
29111  ylarge=max(y3,y4)
29112  ysmall=min(y3,y4)
29113  etalar=20d0
29114  etasma=-20d0
29115  sth=sqrt(max(0d0,1d0-cth**2))
29116  exsq3=sqrt(max(1d-20,((1d0+rm3-rm4)*cosh(yst)+be34*sinh(yst)*
29117  & cth)**2-4d0*rm3))
29118  exsq4=sqrt(max(1d-20,((1d0-rm3+rm4)*cosh(yst)-be34*sinh(yst)*
29119  & cth)**2-4d0*rm4))
29120  IF(sth.GE.1d-10) THEN
29121  expet3=((1d0+rm3-rm4)*sinh(yst)+be34*cosh(yst)*cth+exsq3)/
29122  & (be34*sth)
29123  expet4=((1d0-rm3+rm4)*sinh(yst)-be34*cosh(yst)*cth+exsq4)/
29124  & (be34*sth)
29125  eta3=log(min(1d10,max(1d-10,expet3)))
29126  eta4=log(min(1d10,max(1d-10,expet4)))
29127  etalar=max(eta3,eta4)
29128  etasma=min(eta3,eta4)
29129  ENDIF
29130  cts3=((1d0+rm3-rm4)*sinh(yst)+be34*cosh(yst)*cth)/exsq3
29131  cts4=((1d0-rm3+rm4)*sinh(yst)-be34*cosh(yst)*cth)/exsq4
29132  ctslar=min(1d0,max(-1d0,cts3,cts4))
29133  ctssma=max(-1d0,min(1d0,cts3,cts4))
29134  sh=tau*vint(2)
29135  rpts=4d0*vint(71)**2/sh
29136  be34l=sqrt(max(0d0,(1d0-rm3-rm4)**2-4d0*rm3*rm4-rpts))
29137  rm34=max(1d-20,2d0*rm3*rm4)
29138  IF(2d0*vint(71)**2/(vint(21)*vint(2)).LT.0.0001d0)
29139  & rm34=max(rm34,2d0*vint(71)**2/(vint(21)*vint(2)))
29140  rthm=(4d0*rm3*rm4+rpts)/(1d0-rm3-rm4+be34l)
29141  tha=0.5d0*sh*max(rthm,1d0-rm3-rm4-be34*cth)
29142  uha=0.5d0*sh*max(rthm,1d0-rm3-rm4+be34*cth)
29143  IF(pth.LT.pthmin) mint(51)=1
29144  IF(ckin(4).GE.0d0.AND.pth.GT.ckin(4)) mint(51)=1
29145  IF(ylarge.LT.ckin(9).OR.ylarge.GT.ckin(10)) mint(51)=1
29146  IF(ysmall.LT.ckin(11).OR.ysmall.GT.ckin(12)) mint(51)=1
29147  IF(etalar.LT.ckin(13).OR.etalar.GT.ckin(14)) mint(51)=1
29148  IF(etasma.LT.ckin(15).OR.etasma.GT.ckin(16)) mint(51)=1
29149  IF(ctslar.LT.ckin(17).OR.ctslar.GT.ckin(18)) mint(51)=1
29150  IF(ctssma.LT.ckin(19).OR.ctssma.GT.ckin(20)) mint(51)=1
29151  IF(cth.LT.ckin(27).OR.cth.GT.ckin(28)) mint(51)=1
29152  IF(tha.LT.ckin(35)) mint(51)=1
29153  IF(ckin(36).GE.0d0.AND.tha.GT.ckin(36)) mint(51)=1
29154  IF(uha.LT.ckin(37)) mint(51)=1
29155  IF(ckin(38).GE.0d0.AND.uha.GT.ckin(38)) mint(51)=1
29156  ENDIF
29157  IF(istsb.GE.3.AND.istsb.LE.5) THEN
29158  IF(taup*vint(2).LT.ckin(31)**2) mint(51)=1
29159  IF(ckin(32).GE.0d0.AND.taup*vint(2).GT.ckin(32)**2) mint(51)=1
29160  ENDIF
29161 
29162 C...Additional cuts on W2 (approximately) in DIS.
29163  IF(isub.EQ.10.AND.mint(43).GE.2) THEN
29164  xbj=x2
29165  IF(iabs(mint(12)).LT.20) xbj=x1
29166  q2bj=tha
29167  w2bj=q2bj*(1d0-xbj)/xbj
29168  IF(w2bj.LT.ckin(39)) mint(51)=1
29169  IF(ckin(40).GT.0d0.AND.w2bj.GT.ckin(40)) mint(51)=1
29170  ENDIF
29171 
29172  ELSEIF(ilim.EQ.1) THEN
29173 C...Calculate limits on tau
29174 C...0) due to definition
29175  taumn0=0d0
29176  taumx0=1d0
29177 C...1) due to limits on subsystem mass
29178  taumn1=ckin(1)**2/vint(2)
29179  taumx1=1d0
29180  IF(ckin(2).GE.0d0) taumx1=ckin(2)**2/vint(2)
29181 C...2) due to limits on pT-hat (and non-overlapping rapidity intervals)
29182  tm3=sqrt(sqm3+pthmin**2)
29183  tm4=sqrt(sqm4+pthmin**2)
29184  ydcosh=1d0
29185  IF(ckin09.GT.ckin12) ydcosh=cosh(ckin09-ckin12)
29186  taumn2=(tm3**2+2d0*tm3*tm4*ydcosh+tm4**2)/vint(2)
29187  taumx2=1d0
29188 C...3) due to limits on pT-hat and cos(theta-hat)
29189  cth2mn=min(ckin(27)**2,ckin(28)**2)
29190  cth2mx=max(ckin(27)**2,ckin(28)**2)
29191  taumn3=0d0
29192  IF(ckin(27)*ckin(28).GT.0d0) taumn3=
29193  & (sqrt(sqm3+pthmin**2/(1d0-cth2mn))+
29194  & sqrt(sqm4+pthmin**2/(1d0-cth2mn)))**2/vint(2)
29195  taumx3=1d0
29196  IF(ckin(4).GE.0d0.AND.cth2mx.LT.1d0) taumx3=
29197  & (sqrt(sqm3+ckin(4)**2/(1d0-cth2mx))+
29198  & sqrt(sqm4+ckin(4)**2/(1d0-cth2mx)))**2/vint(2)
29199 C...4) due to limits on x1 and x2
29200  taumn4=ckin(21)*ckin(23)
29201  taumx4=ckin(22)*ckin(24)
29202 C...5) due to limits on xF
29203  taumn5=0d0
29204  taumx5=max(1d0-ckin(25),1d0+ckin(26))
29205 C...6) due to limits on that and uhat
29206  taumn6=(sqm3+sqm4+ckin(35)+ckin(37))/vint(2)
29207  taumx6=1d0
29208  IF(ckin(36).GT.0d0.AND.ckin(38).GT.0d0) taumx6=
29209  & (sqm3+sqm4+ckin(36)+ckin(38))/vint(2)
29210 
29211 C...Net effect of all separate limits.
29212  vint(11)=max(taumn0,taumn1,taumn2,taumn3,taumn4,taumn5,taumn6)
29213  vint(31)=min(taumx0,taumx1,taumx2,taumx3,taumx4,taumx5,taumx6)
29214  IF(mint(47).EQ.1.AND.(istsb.EQ.1.OR.istsb.EQ.2)) THEN
29215  vint(11)=1d0-1d-9
29216  vint(31)=1d0+1d-9
29217  ELSEIF(mint(47).EQ.5) THEN
29218  vint(31)=min(vint(31),1d0-2d-10)
29219  ELSEIF(mint(47).GE.6) THEN
29220  vint(31)=min(vint(31),1d0-1d-10)
29221  ENDIF
29222  IF(vint(31).LE.vint(11)) mint(51)=1
29223 
29224  ELSEIF(ilim.EQ.2) THEN
29225 C...Calculate limits on y*
29226  taue=tau
29227  IF(istsb.GE.3.AND.istsb.LE.5) taue=vint(26)
29228  taurt=sqrt(taue)
29229 C...0) due to kinematics
29230  ystmn0=log(taurt)
29231  ystmx0=-ystmn0
29232 C...1) due to explicit limits
29233  ystmn1=ckin(7)
29234  ystmx1=ckin(8)
29235 C...2) due to limits on x1
29236  ystmn2=log(max(taue,ckin(21))/taurt)
29237  ystmx2=log(max(taue,ckin(22))/taurt)
29238 C...3) due to limits on x2
29239  ystmn3=-log(max(taue,ckin(24))/taurt)
29240  ystmx3=-log(max(taue,ckin(23))/taurt)
29241 C...4) due to limits on xF
29242  yepmn4=0.5d0*abs(ckin(25))/taurt
29243  ystmn4=sign(log(max(1d-20,sqrt(1d0+yepmn4**2)+yepmn4)),ckin(25))
29244  yepmx4=0.5d0*abs(ckin(26))/taurt
29245  ystmx4=sign(log(max(1d-20,sqrt(1d0+yepmx4**2)+yepmx4)),ckin(26))
29246 C...5) due to simultaneous limits on y-large and y-small
29247  yepsmn=(rm3-rm4)*sinh(ckin09-ckin11)
29248  yepsmx=(rm3-rm4)*sinh(ckin10-ckin12)
29249  ydifmn=abs(log(max(1d-20,sqrt(1d0+yepsmn**2)-yepsmn)))
29250  ydifmx=abs(log(max(1d-20,sqrt(1d0+yepsmx**2)-yepsmx)))
29251  ystmn5=0.5d0*(ckin09+ckin11-ydifmn)
29252  ystmx5=0.5d0*(ckin10+ckin12+ydifmx)
29253 C...6) due to simultaneous limits on cos(theta-hat) and y-large or
29254 C... y-small
29255  cthlim=sqrt(max(0d0,1d0-4d0*pthmin**2/(be34**2*taue*vint(2))))
29256  rzmn=be34*max(ckin(27),-cthlim)
29257  rzmx=be34*min(ckin(28),cthlim)
29258  yex3mx=(1d0+rm3-rm4+rzmx)/max(1d-10,1d0+rm3-rm4-rzmx)
29259  yex4mx=(1d0+rm4-rm3-rzmn)/max(1d-10,1d0+rm4-rm3+rzmn)
29260  yex3mn=max(1d-10,1d0+rm3-rm4+rzmn)/(1d0+rm3-rm4-rzmn)
29261  yex4mn=max(1d-10,1d0+rm4-rm3-rzmx)/(1d0+rm4-rm3+rzmx)
29262  ystmn6=ckin09-0.5d0*log(max(yex3mx,yex4mx))
29263  ystmx6=ckin12-0.5d0*log(min(yex3mn,yex4mn))
29264 
29265 C...Net effect of all separate limits.
29266  vint(12)=max(ystmn0,ystmn1,ystmn2,ystmn3,ystmn4,ystmn5,ystmn6)
29267  vint(32)=min(ystmx0,ystmx1,ystmx2,ystmx3,ystmx4,ystmx5,ystmx6)
29268  IF(mint(47).EQ.1) THEN
29269  vint(12)=-1d-9
29270  vint(32)=1d-9
29271  ELSEIF(mint(47).EQ.2.OR.mint(47).EQ.6) THEN
29272  vint(12)=(1d0-1d-9)*ystmx0
29273  vint(32)=(1d0+1d-9)*ystmx0
29274  ELSEIF(mint(47).EQ.3.OR.mint(47).EQ.7) THEN
29275  vint(12)=-(1d0+1d-9)*ystmx0
29276  vint(32)=-(1d0-1d-9)*ystmx0
29277  ELSEIF(mint(47).EQ.5) THEN
29278  ystee=log((1d0-1d-10)/taurt)
29279  vint(12)=max(vint(12),-ystee)
29280  vint(32)=min(vint(32),ystee)
29281  ENDIF
29282  IF(vint(32).LE.vint(12)) mint(51)=1
29283 
29284  ELSEIF(ilim.EQ.3) THEN
29285 C...Calculate limits on cos(theta-hat)
29286  yst=vint(22)
29287 C...0) due to definition
29288  ctnmn0=-1d0
29289  ctnmx0=0d0
29290  ctpmn0=0d0
29291  ctpmx0=1d0
29292 C...1) due to explicit limits
29293  ctnmn1=min(0d0,ckin(27))
29294  ctnmx1=min(0d0,ckin(28))
29295  ctpmn1=max(0d0,ckin(27))
29296  ctpmx1=max(0d0,ckin(28))
29297 C...2) due to limits on pT-hat
29298  ctnmn2=-sqrt(max(0d0,1d0-4d0*pthmin**2/(be34**2*tau*vint(2))))
29299  ctpmx2=-ctnmn2
29300  ctnmx2=0d0
29301  ctpmn2=0d0
29302  IF(ckin(4).GE.0d0) THEN
29303  ctnmx2=-sqrt(max(0d0,1d0-4d0*ckin(4)**2/
29304  & (be34**2*tau*vint(2))))
29305  ctpmn2=-ctnmx2
29306  ENDIF
29307 C...3) due to limits on y-large and y-small
29308  ctnmn3=min(0d0,max((1d0+rm3-rm4)/be34*tanh(ckin11-yst),
29309  & -(1d0-rm3+rm4)/be34*tanh(ckin10-yst)))
29310  ctnmx3=min(0d0,(1d0+rm3-rm4)/be34*tanh(ckin12-yst),
29311  & -(1d0-rm3+rm4)/be34*tanh(ckin09-yst))
29312  ctpmn3=max(0d0,(1d0+rm3-rm4)/be34*tanh(ckin09-yst),
29313  & -(1d0-rm3+rm4)/be34*tanh(ckin12-yst))
29314  ctpmx3=max(0d0,min((1d0+rm3-rm4)/be34*tanh(ckin10-yst),
29315  & -(1d0-rm3+rm4)/be34*tanh(ckin11-yst)))
29316 C...4) due to limits on that
29317  ctnmn4=-1d0
29318  ctnmx4=0d0
29319  ctpmn4=0d0
29320  ctpmx4=1d0
29321  sh=tau*vint(2)
29322  IF(ckin(35).GT.0d0) THEN
29323  ctlim=(1d0-rm3-rm4-2d0*ckin(35)/sh)/be34
29324  IF(ctlim.GT.0d0) THEN
29325  ctpmx4=ctlim
29326  ELSE
29327  ctpmx4=0d0
29328  ctnmx4=ctlim
29329  ENDIF
29330  ENDIF
29331  IF(ckin(36).GT.0d0) THEN
29332  ctlim=(1d0-rm3-rm4-2d0*ckin(36)/sh)/be34
29333  IF(ctlim.LT.0d0) THEN
29334  ctnmn4=ctlim
29335  ELSE
29336  ctnmn4=0d0
29337  ctpmn4=ctlim
29338  ENDIF
29339  ENDIF
29340 C...5) due to limits on uhat
29341  ctnmn5=-1d0
29342  ctnmx5=0d0
29343  ctpmn5=0d0
29344  ctpmx5=1d0
29345  IF(ckin(37).GT.0d0) THEN
29346  ctlim=(2d0*ckin(37)/sh-(1d0-rm3-rm4))/be34
29347  IF(ctlim.LT.0d0) THEN
29348  ctnmn5=ctlim
29349  ELSE
29350  ctnmn5=0d0
29351  ctpmn5=ctlim
29352  ENDIF
29353  ENDIF
29354  IF(ckin(38).GT.0d0) THEN
29355  ctlim=(2d0*ckin(38)/sh-(1d0-rm3-rm4))/be34
29356  IF(ctlim.GT.0d0) THEN
29357  ctpmx5=ctlim
29358  ELSE
29359  ctpmx5=0d0
29360  ctnmx5=ctlim
29361  ENDIF
29362  ENDIF
29363 
29364 C...Net effect of all separate limits.
29365  vint(13)=max(ctnmn0,ctnmn1,ctnmn2,ctnmn3,ctnmn4,ctnmn5)
29366  vint(33)=min(ctnmx0,ctnmx1,ctnmx2,ctnmx3,ctnmx4,ctnmx5)
29367  vint(14)=max(ctpmn0,ctpmn1,ctpmn2,ctpmn3,ctpmn4,ctpmn5)
29368  vint(34)=min(ctpmx0,ctpmx1,ctpmx2,ctpmx3,ctpmx4,ctpmx5)
29369  IF(vint(33).LE.vint(13).AND.vint(34).LE.vint(14)) mint(51)=1
29370 
29371  IF(vint(14).GT.vint(34)) vint(34)=vint(14)
29372  IF(vint(13).GT.vint(33)) vint(33)=vint(13)
29373 
29374  ELSEIF(ilim.EQ.4) THEN
29375 C...Calculate limits on tau'
29376 C...0) due to kinematics
29377  tapmn0=tau
29378  IF(istsb.EQ.5.AND.vint(201).GT.0d0) THEN
29379  pqrat=(vint(201)+vint(206))/vint(1)
29380  tapmn0=(sqrt(tau)+pqrat)**2
29381  ENDIF
29382  tapmx0=1d0
29383 C...1) due to explicit limits
29384  tapmn1=ckin(31)**2/vint(2)
29385  tapmx1=1d0
29386  IF(ckin(32).GE.0d0) tapmx1=ckin(32)**2/vint(2)
29387 
29388 C...Net effect of all separate limits.
29389  vint(16)=max(tapmn0,tapmn1)
29390  vint(36)=min(tapmx0,tapmx1)
29391  IF(mint(47).EQ.1) THEN
29392  vint(16)=1d0-1d-9
29393  vint(36)=1d0+1d-9
29394  ELSEIF(mint(47).EQ.5) THEN
29395  vint(36)=min(vint(36),1d0-2d-10)
29396  ELSEIF(mint(47).EQ.6.OR.mint(47).EQ.7) THEN
29397  vint(36)=min(vint(36),1d0-1d-10)
29398  ENDIF
29399  IF(vint(36).LE.vint(16)) mint(51)=1
29400 
29401  ENDIF
29402  RETURN
29403 
29404 C...Special case for low-pT and multiple interactions:
29405 C...effective kinematical limits for tau, y*, cos(theta-hat).
29406  100 IF(ilim.EQ.0) THEN
29407  ELSEIF(ilim.EQ.1) THEN
29408  IF(mstp(82).LE.1) THEN
29409  vint(11)=4d0*(parp(81)*(vint(1)/parp(89))**parp(90))**2/
29410  & vint(2)
29411  ELSE
29412  vint(11)=(parp(82)*(vint(1)/parp(89))**parp(90))**2/vint(2)
29413  ENDIF
29414  vint(31)=1d0
29415  ELSEIF(ilim.EQ.2) THEN
29416  vint(12)=0.5d0*log(vint(21))
29417  vint(32)=-vint(12)
29418  ELSEIF(ilim.EQ.3) THEN
29419  IF(mstp(82).LE.1) THEN
29420  st2eff=4d0*(parp(81)*(vint(1)/parp(89))**parp(90))**2/
29421  & (vint(21)*vint(2))
29422  ELSE
29423  st2eff=0.01d0*(parp(82)*(vint(1)/parp(89))**parp(90))**2/
29424  & (vint(21)*vint(2))
29425  ENDIF
29426  vint(13)=-sqrt(max(0d0,1d0-st2eff))
29427  vint(33)=0d0
29428  vint(14)=0d0
29429  vint(34)=-vint(13)
29430  ENDIF
29431 
29432  RETURN
29433  END
29434 
29435 C*********************************************************************
29436 
29437 C...PYKMAP
29438 C...Maps a uniform distribution into a distribution of a kinematical
29439 C...variable according to one of the possibilities allowed. It is
29440 C...assumed that kinematical limits have been set by a PYKLIM call.
29441 
29442  SUBROUTINE pykmap(IVAR,MVAR,VVAR)
29443 
29444 C...Double precision and integer declarations.
29445  IMPLICIT DOUBLE PRECISION(a-h, o-z)
29446  IMPLICIT INTEGER(i-n)
29447  INTEGER pyk,pychge,pycomp
29448 C...Commonblocks.
29449  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
29450  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
29451  common/pysubs/msel,mselpd,msub(500),kfin(2,-40:40),ckin(200)
29452  common/pypars/mstp(200),parp(200),msti(200),pari(200)
29453  common/pyint1/mint(400),vint(400)
29454  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
29455  SAVE /pydat1/,/pydat2/,/pysubs/,/pypars/,/pyint1/,/pyint2/
29456 
29457 C...Convert VVAR to tau variable.
29458  isub=mint(1)
29459  istsb=iset(isub)
29460  IF(ivar.EQ.1) THEN
29461  taumin=vint(11)
29462  taumax=vint(31)
29463  IF(mvar.EQ.3.OR.mvar.EQ.4) THEN
29464  taure=vint(73)
29465  gamre=vint(74)
29466  ELSEIF(mvar.EQ.5.OR.mvar.EQ.6) THEN
29467  taure=vint(75)
29468  gamre=vint(76)
29469  ELSEIF(mvar.EQ.8.OR.mvar.EQ.9) THEN
29470  taure=vint(77)
29471  gamre=vint(78)
29472  ENDIF
29473  IF(mint(47).EQ.1.AND.(istsb.EQ.1.OR.istsb.EQ.2)) THEN
29474  tau=1d0
29475  ELSEIF(mvar.EQ.1) THEN
29476  tau=taumin*(taumax/taumin)**vvar
29477  ELSEIF(mvar.EQ.2) THEN
29478  tau=taumax*taumin/(taumin+(taumax-taumin)*vvar)
29479  ELSEIF(mvar.EQ.3.OR.mvar.EQ.5.OR.mvar.EQ.8) THEN
29480  ratgen=(taure+taumax)/(taure+taumin)*taumin/taumax
29481  tau=taure*taumin/((taure+taumin)*ratgen**vvar-taumin)
29482  ELSEIF(mvar.EQ.4.OR.mvar.EQ.6.OR.mvar.EQ.9) THEN
29483  aupp=atan((taumax-taure)/gamre)
29484  alow=atan((taumin-taure)/gamre)
29485  tau=taure+gamre*tan(alow+(aupp-alow)*vvar)
29486  ELSEIF(mint(47).EQ.5) THEN
29487  aupp=log(max(2d-10,1d0-taumax))
29488  alow=log(max(2d-10,1d0-taumin))
29489  tau=1d0-exp(aupp+vvar*(alow-aupp))
29490  ELSE
29491  aupp=log(max(1d-10,1d0-taumax))
29492  alow=log(max(1d-10,1d0-taumin))
29493  tau=1d0-exp(aupp+vvar*(alow-aupp))
29494  ENDIF
29495  vint(21)=min(taumax,max(taumin,tau))
29496 
29497 C...Convert VVAR to y* variable.
29498  ELSEIF(ivar.EQ.2) THEN
29499  ystmin=vint(12)
29500  ystmax=vint(32)
29501  taue=vint(21)
29502  IF(istsb.GE.3.AND.istsb.LE.5) taue=vint(26)
29503  IF(mint(47).EQ.1) THEN
29504  yst=0d0
29505  ELSEIF(mint(47).EQ.2.OR.mint(47).EQ.6) THEN
29506  yst=-0.5d0*log(taue)
29507  ELSEIF(mint(47).EQ.3.OR.mint(47).EQ.7) THEN
29508  yst=0.5d0*log(taue)
29509  ELSEIF(mvar.EQ.1) THEN
29510  yst=ystmin+(ystmax-ystmin)*sqrt(vvar)
29511  ELSEIF(mvar.EQ.2) THEN
29512  yst=ystmax-(ystmax-ystmin)*sqrt(1d0-vvar)
29513  ELSEIF(mvar.EQ.3) THEN
29514  aupp=atan(exp(ystmax))
29515  alow=atan(exp(ystmin))
29516  yst=log(tan(alow+(aupp-alow)*vvar))
29517  ELSEIF(mvar.EQ.4) THEN
29518  yst0=-0.5d0*log(taue)
29519  aupp=log(max(1d-10,exp(yst0-ystmin)-1d0))
29520  alow=log(max(1d-10,exp(yst0-ystmax)-1d0))
29521  yst=yst0-log(1d0+exp(alow+vvar*(aupp-alow)))
29522  ELSE
29523  yst0=-0.5d0*log(taue)
29524  aupp=log(max(1d-10,exp(yst0+ystmin)-1d0))
29525  alow=log(max(1d-10,exp(yst0+ystmax)-1d0))
29526  yst=log(1d0+exp(aupp+vvar*(alow-aupp)))-yst0
29527  ENDIF
29528  vint(22)=min(ystmax,max(ystmin,yst))
29529 
29530 C...Convert VVAR to cos(theta-hat) variable.
29531  ELSEIF(ivar.EQ.3) THEN
29532  rm34=max(1d-20,2d0*vint(63)*vint(64)/(vint(21)*vint(2))**2)
29533  rsqm=1d0+rm34
29534  IF(2d0*vint(71)**2/(vint(21)*vint(2)).LT.0.0001d0)
29535  & rm34=max(rm34,2d0*vint(71)**2/(vint(21)*vint(2)))
29536  ctnmin=vint(13)
29537  ctnmax=vint(33)
29538  ctpmin=vint(14)
29539  ctpmax=vint(34)
29540  IF(mvar.EQ.1) THEN
29541  aneg=ctnmax-ctnmin
29542  apos=ctpmax-ctpmin
29543  IF(aneg.GT.0d0.AND.vvar*(aneg+apos).LE.aneg) THEN
29544  vctn=vvar*(aneg+apos)/aneg
29545  cth=ctnmin+(ctnmax-ctnmin)*vctn
29546  ELSE
29547  vctp=(vvar*(aneg+apos)-aneg)/apos
29548  cth=ctpmin+(ctpmax-ctpmin)*vctp
29549  ENDIF
29550  ELSEIF(mvar.EQ.2) THEN
29551  rmnmin=max(rm34,rsqm-ctnmin)
29552  rmnmax=max(rm34,rsqm-ctnmax)
29553  rmpmin=max(rm34,rsqm-ctpmin)
29554  rmpmax=max(rm34,rsqm-ctpmax)
29555  aneg=log(rmnmin/rmnmax)
29556  apos=log(rmpmin/rmpmax)
29557  IF(aneg.GT.0d0.AND.vvar*(aneg+apos).LE.aneg) THEN
29558  vctn=vvar*(aneg+apos)/aneg
29559  cth=rsqm-rmnmin*(rmnmax/rmnmin)**vctn
29560  ELSE
29561  vctp=(vvar*(aneg+apos)-aneg)/apos
29562  cth=rsqm-rmpmin*(rmpmax/rmpmin)**vctp
29563  ENDIF
29564  ELSEIF(mvar.EQ.3) THEN
29565  rmnmin=max(rm34,rsqm+ctnmin)
29566  rmnmax=max(rm34,rsqm+ctnmax)
29567  rmpmin=max(rm34,rsqm+ctpmin)
29568  rmpmax=max(rm34,rsqm+ctpmax)
29569  aneg=log(rmnmax/rmnmin)
29570  apos=log(rmpmax/rmpmin)
29571  IF(aneg.GT.0d0.AND.vvar*(aneg+apos).LE.aneg) THEN
29572  vctn=vvar*(aneg+apos)/aneg
29573  cth=rmnmin*(rmnmax/rmnmin)**vctn-rsqm
29574  ELSE
29575  vctp=(vvar*(aneg+apos)-aneg)/apos
29576  cth=rmpmin*(rmpmax/rmpmin)**vctp-rsqm
29577  ENDIF
29578  ELSEIF(mvar.EQ.4) THEN
29579  rmnmin=max(rm34,rsqm-ctnmin)
29580  rmnmax=max(rm34,rsqm-ctnmax)
29581  rmpmin=max(rm34,rsqm-ctpmin)
29582  rmpmax=max(rm34,rsqm-ctpmax)
29583  aneg=1d0/rmnmax-1d0/rmnmin
29584  apos=1d0/rmpmax-1d0/rmpmin
29585  IF(aneg.GT.0d0.AND.vvar*(aneg+apos).LE.aneg) THEN
29586  vctn=vvar*(aneg+apos)/aneg
29587  cth=rsqm-1d0/(1d0/rmnmin+aneg*vctn)
29588  ELSE
29589  vctp=(vvar*(aneg+apos)-aneg)/apos
29590  cth=rsqm-1d0/(1d0/rmpmin+apos*vctp)
29591  ENDIF
29592  ELSEIF(mvar.EQ.5) THEN
29593  rmnmin=max(rm34,rsqm+ctnmin)
29594  rmnmax=max(rm34,rsqm+ctnmax)
29595  rmpmin=max(rm34,rsqm+ctpmin)
29596  rmpmax=max(rm34,rsqm+ctpmax)
29597  aneg=1d0/rmnmin-1d0/rmnmax
29598  apos=1d0/rmpmin-1d0/rmpmax
29599  IF(aneg.GT.0d0.AND.vvar*(aneg+apos).LE.aneg) THEN
29600  vctn=vvar*(aneg+apos)/aneg
29601  cth=1d0/(1d0/rmnmin-aneg*vctn)-rsqm
29602  ELSE
29603  vctp=(vvar*(aneg+apos)-aneg)/apos
29604  cth=1d0/(1d0/rmpmin-apos*vctp)-rsqm
29605  ENDIF
29606  ENDIF
29607  IF(cth.LT.0d0) cth=min(ctnmax,max(ctnmin,cth))
29608  IF(cth.GT.0d0) cth=min(ctpmax,max(ctpmin,cth))
29609  vint(23)=cth
29610 
29611 C...Convert VVAR to tau' variable.
29612  ELSEIF(ivar.EQ.4) THEN
29613  tau=vint(21)
29614  taupmn=vint(16)
29615  taupmx=vint(36)
29616  IF(mint(47).EQ.1) THEN
29617  taup=1d0
29618  ELSEIF(mvar.EQ.1) THEN
29619  taup=taupmn*(taupmx/taupmn)**vvar
29620  ELSEIF(mvar.EQ.2) THEN
29621  aupp=(1d0-tau/taupmx)**4
29622  alow=(1d0-tau/taupmn)**4
29623  taup=tau/max(1d-10,1d0-(alow+(aupp-alow)*vvar)**0.25d0)
29624  ELSEIF(mint(47).EQ.5) THEN
29625  aupp=log(max(2d-10,1d0-taupmx))
29626  alow=log(max(2d-10,1d0-taupmn))
29627  taup=1d0-exp(aupp+vvar*(alow-aupp))
29628  ELSE
29629  aupp=log(max(1d-10,1d0-taupmx))
29630  alow=log(max(1d-10,1d0-taupmn))
29631  taup=1d0-exp(aupp+vvar*(alow-aupp))
29632  ENDIF
29633  vint(26)=min(taupmx,max(taupmn,taup))
29634 
29635 C...Selection of extra variables needed in 2 -> 3 process:
29636 C...pT1, pT2, phi1, phi2, y3 for three outgoing particles.
29637 C...Since no options are available, the functions of PYKLIM
29638 C...and PYKMAP are joint for these choices.
29639  ELSEIF(ivar.EQ.5) THEN
29640 
29641 C...Read out total energy and particle masses.
29642  mint(51)=0
29643  mptpk=1
29644  IF(isub.EQ.123.OR.isub.EQ.124.OR.isub.EQ.173.OR.isub.EQ.174
29645  & .OR.isub.EQ.178.OR.isub.EQ.179.OR.isub.EQ.351.OR.isub.EQ.352)
29646  & mptpk=2
29647  shp=vint(26)*vint(2)
29648  shpr=sqrt(shp)
29649  pm1=vint(201)
29650  pm2=vint(206)
29651  pm3=sqrt(vint(21))*vint(1)
29652  IF(pm1+pm2+pm3.GT.0.9999d0*shpr) THEN
29653  mint(51)=1
29654  RETURN
29655  ENDIF
29656  pmrs1=vint(204)**2
29657  pmrs2=vint(209)**2
29658 
29659 C...Specify coefficients of pT choice; upper and lower limits.
29660  IF(mptpk.EQ.1) THEN
29661  hwt1=0.4d0
29662  hwt2=0.4d0
29663  ELSE
29664  hwt1=0.05d0
29665  hwt2=0.05d0
29666  ENDIF
29667  hwt3=1d0-hwt1-hwt2
29668  ptsmx1=((shp-pm1**2-(pm2+pm3)**2)**2-(2d0*pm1*(pm2+pm3))**2)/
29669  & (4d0*shp)
29670  IF(ckin(52).GT.0d0) ptsmx1=min(ptsmx1,ckin(52)**2)
29671  ptsmn1=ckin(51)**2
29672  ptsmx2=((shp-pm2**2-(pm1+pm3)**2)**2-(2d0*pm2*(pm1+pm3))**2)/
29673  & (4d0*shp)
29674  IF(ckin(54).GT.0d0) ptsmx2=min(ptsmx2,ckin(54)**2)
29675  ptsmn2=ckin(53)**2
29676 
29677 C...Select transverse momenta according to
29678 C...dp_T^2 * (a + b/(M^2 + p_T^2) + c/(M^2 + p_T^2)^2).
29679  hmx=pmrs1+ptsmx1
29680  hmn=pmrs1+ptsmn1
29681  IF(hmx.LT.1.0001d0*hmn) THEN
29682  mint(51)=1
29683  RETURN
29684  ENDIF
29685  hde=ptsmx1-ptsmn1
29686  rpt=pyr(0)
29687  IF(rpt.LT.hwt1) THEN
29688  pts1=ptsmn1+pyr(0)*hde
29689  ELSEIF(rpt.LT.hwt1+hwt2) THEN
29690  pts1=max(ptsmn1,hmn*(hmx/hmn)**pyr(0)-pmrs1)
29691  ELSE
29692  pts1=max(ptsmn1,hmn*hmx/(hmn+pyr(0)*hde)-pmrs1)
29693  ENDIF
29694  wtpts1=hde/(hwt1+hwt2*hde/(log(hmx/hmn)*(pmrs1+pts1))+
29695  & hwt3*hmn*hmx/(pmrs1+pts1)**2)
29696  hmx=pmrs2+ptsmx2
29697  hmn=pmrs2+ptsmn2
29698  IF(hmx.LT.1.0001d0*hmn) THEN
29699  mint(51)=1
29700  RETURN
29701  ENDIF
29702  hde=ptsmx2-ptsmn2
29703  rpt=pyr(0)
29704  IF(rpt.LT.hwt1) THEN
29705  pts2=ptsmn2+pyr(0)*hde
29706  ELSEIF(rpt.LT.hwt1+hwt2) THEN
29707  pts2=max(ptsmn2,hmn*(hmx/hmn)**pyr(0)-pmrs2)
29708  ELSE
29709  pts2=max(ptsmn2,hmn*hmx/(hmn+pyr(0)*hde)-pmrs2)
29710  ENDIF
29711  wtpts2=hde/(hwt1+hwt2*hde/(log(hmx/hmn)*(pmrs2+pts2))+
29712  & hwt3*hmn*hmx/(pmrs2+pts2)**2)
29713 
29714 C...Select azimuthal angles and check pT choice.
29715  phi1=paru(2)*pyr(0)
29716  phi2=paru(2)*pyr(0)
29717  phir=phi2-phi1
29718  pts3=max(0d0,pts1+pts2+2d0*sqrt(pts1*pts2)*cos(phir))
29719  IF(pts3.LT.ckin(55)**2.OR.(ckin(56).GT.0d0.AND.pts3.GT.
29720  & ckin(56)**2)) THEN
29721  mint(51)=1
29722  RETURN
29723  ENDIF
29724 
29725 C...Calculate transverse masses and check phase space not closed.
29726  pms1=pm1**2+pts1
29727  pms2=pm2**2+pts2
29728  pms3=pm3**2+pts3
29729  pmt1=sqrt(pms1)
29730  pmt2=sqrt(pms2)
29731  pmt3=sqrt(pms3)
29732  pm12=(pmt1+pmt2)**2
29733  IF(pmt1+pmt2+pmt3.GT.0.9999d0*shpr) THEN
29734  mint(51)=1
29735  RETURN
29736  ENDIF
29737 
29738 C...Select rapidity for particle 3 and check phase space not closed.
29739  y3max=log((shp+pms3-pm12+sqrt(max(0d0,(shp-pms3-pm12)**2-
29740  & 4d0*pms3*pm12)))/(2d0*shpr*pmt3))
29741  IF(y3max.LT.1d-6) THEN
29742  mint(51)=1
29743  RETURN
29744  ENDIF
29745  y3=(2d0*pyr(0)-1d0)*0.999999d0*y3max
29746  pz3=pmt3*sinh(y3)
29747  pe3=pmt3*cosh(y3)
29748 
29749 C...Find momentum transfers in two mirror solutions (in 1-2 frame).
29750  pz12=-pz3
29751  pe12=shpr-pe3
29752  pms12=pe12**2-pz12**2
29753  sql12=sqrt(max(0d0,(pms12-pms1-pms2)**2-4d0*pms1*pms2))
29754  IF(sql12.LT.1d-6*shp) THEN
29755  mint(51)=1
29756  RETURN
29757  ENDIF
29758  pmm1=pms12+pms1-pms2
29759  pmm2=pms12+pms2-pms1
29760  tfac=-shpr/(2d0*pms12)
29761  t1p=tfac*(pe12-pz12)*(pmm1-sql12)
29762  t1n=tfac*(pe12-pz12)*(pmm1+sql12)
29763  t2p=tfac*(pe12+pz12)*(pmm2-sql12)
29764  t2n=tfac*(pe12+pz12)*(pmm2+sql12)
29765 
29766 C...Construct relative mirror weights and make choice.
29767  IF(mptpk.EQ.1.OR.isub.EQ.351.OR.isub.EQ.352) THEN
29768  wtpu=1d0
29769  wtnu=1d0
29770  ELSE
29771  wtpu=1d0/((t1p-pmrs1)*(t2p-pmrs2))**2
29772  wtnu=1d0/((t1n-pmrs1)*(t2n-pmrs2))**2
29773  ENDIF
29774  wtp=wtpu/(wtpu+wtnu)
29775  wtn=wtnu/(wtpu+wtnu)
29776  eps=1d0
29777  IF(wtn.GT.pyr(0)) eps=-1d0
29778 
29779 C...Store result of variable choice and associated weights.
29780  vint(202)=pts1
29781  vint(207)=pts2
29782  vint(203)=phi1
29783  vint(208)=phi2
29784  vint(205)=wtpts1
29785  vint(210)=wtpts2
29786  vint(211)=y3
29787  vint(212)=y3max
29788  vint(213)=eps
29789  IF(eps.GT.0d0) THEN
29790  vint(214)=1d0/wtp
29791  vint(215)=t1p
29792  vint(216)=t2p
29793  ELSE
29794  vint(214)=1d0/wtn
29795  vint(215)=t1n
29796  vint(216)=t2n
29797  ENDIF
29798  vint(217)=-0.5d0*tfac*(pe12-pz12)*(pmm2+eps*sql12)
29799  vint(218)=-0.5d0*tfac*(pe12+pz12)*(pmm1+eps*sql12)
29800  vint(219)=0.5d0*(pms12-pts3)
29801  vint(220)=sql12
29802  ENDIF
29803 
29804  RETURN
29805  END
29806 
29807 C***********************************************************************
29808 
29809 C...PYSIGH
29810 C...Differential matrix elements for all included subprocesses
29811 C...Note that what is coded is (disregarding the COMFAC factor)
29812 C...1) for 2 -> 1 processes: s-hat/pi*d(sigma-hat), where,
29813 C...when d(sigma-hat) is given in the zero-width limit, the delta
29814 C...function in tau is replaced by a (modified) Breit-Wigner:
29815 C...1/pi*s*H_res/((s*tau-m_res^2)^2+H_res^2),
29816 C...where H_res = s-hat/m_res*Gamma_res(s-hat);
29817 C...2) for 2 -> 2 processes: (s-hat)**2/pi*d(sigma-hat)/d(t-hat);
29818 C...i.e., dimensionless quantities
29819 C...3) for 2 -> 3 processes: abs(M)^2, where the total cross-section is
29820 C...Integral abs(M)^2/(2shat') * (prod_(i=1)^3 d^3p_i/((2pi)^3*2E_i)) *
29821 C...(2pi)^4 delta^4(P - sum p_i)
29822 C...COMFAC contains the factor pi/s (or equivalent) and
29823 C...the conversion factor from GeV^-2 to mb
29824 
29825  SUBROUTINE pysigh(NCHN,SIGS)
29826 
29827 C...Double precision and integer declarations
29828  IMPLICIT DOUBLE PRECISION(a-h, o-z)
29829  IMPLICIT INTEGER(i-n)
29830  INTEGER pyk,pychge,pycomp
29831 C...Parameter statement to help give large particle numbers.
29832  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
29833  &kexcit=4000000,kdimen=5000000)
29834 C...Commonblocks
29835  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
29836  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
29837  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
29838  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
29839  common/pysubs/msel,mselpd,msub(500),kfin(2,-40:40),ckin(200)
29840  common/pypars/mstp(200),parp(200),msti(200),pari(200)
29841  common/pyint1/mint(400),vint(400)
29842  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
29843  common/pyint3/xsfx(2,-40:40),isig(1000,3),sigh(1000)
29844  common/pyint4/mwid(500),wids(500,5)
29845  common/pyint5/ngenpd,ngen(0:500,3),xsec(0:500,3)
29846  common/pyint7/sigt(0:6,0:6,0:5)
29847  common/pymssm/imss(0:99),rmss(0:99)
29848  common/pyssmt/zmix(4,4),umix(2,2),vmix(2,2),smz(4),smw(2),
29849  &sfmix(16,4),zmixi(4,4),umixi(2,2),vmixi(2,2)
29850  common/pytcsm/itcm(0:99),rtcm(0:99)
29851  common/pypued/iued(0:99),rued(0:99)
29852  common/pysgcm/isub,isubsv,mmin1,mmax1,mmin2,mmax2,mmina,mmaxa,
29853  &kfac(2,-40:40),comfac,fack,faca,sh,th,uh,sh2,th2,uh2,sqm3,sqm4,
29854  &shr,sqpth,taup,be34,cth,x(2),sqmz,sqmw,gmmz,gmmw,
29855  &aem,as,xw,xw1,xwc,xwv,poll,polr,polll,polrr
29856  common/pytcco/coefx(194:380,2)
29857  SAVE /pyjets/,/pydat1/,/pydat2/,/pydat3/,/pysubs/,/pypars/,
29858  &/pyint1/,/pyint2/,/pyint3/,/pyint4/,/pyint5/,/pyint7/,
29859  &/pymssm/,/pyssmt/,/pytcsm/,/pypued/,/pysgcm/,/pytcco/
29860 C...Local arrays and complex variables
29861  dimension xpq(-25:25)
29862 
29863 C...Map of processes onto which routine to call
29864 C...in order to evaluate cross section:
29865 C...0 = not implemented;
29866 C...1 = standard QCD (including photons);
29867 C...2 = heavy flavours;
29868 C...3 = W/Z;
29869 C...4 = Higgs (2 doublets; including longitudinal W/Z scattering);
29870 C...5 = SUSY;
29871 C...6 = Technicolor;
29872 C...7 = exotics (Z'/W'/LQ/R/f*/H++/Z_R/W_R/G*).
29873 C...8 = Universal Extra Dimensions
29874  dimension mappr(500)
29875  DATA (mappr(i),i=1,180)/
29876  & 3, 3, 4, 0, 4, 0, 0, 4, 0, 1,
29877  1 1, 1, 1, 1, 3, 3, 0, 1, 3, 3,
29878  2 0, 3, 3, 4, 3, 4, 0, 1, 1, 3,
29879  3 3, 4, 1, 1, 3, 3, 0, 0, 0, 0,
29880  4 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
29881  5 0, 0, 1, 1, 0, 0, 0, 1, 0, 0,
29882  6 0, 0, 0, 0, 0, 0, 0, 1, 3, 3,
29883  7 4, 4, 4, 0, 0, 4, 4, 0, 0, 1,
29884  8 2, 2, 2, 2, 2, 2, 2, 2, 2, 0,
29885  9 1, 1, 1, 1, 1, 1, 0, 0, 1, 0,
29886  & 0, 4, 4, 2, 2, 2, 2, 2, 0, 4,
29887  1 4, 4, 4, 1, 1, 0, 0, 0, 0, 0,
29888  2 4, 4, 4, 4, 0, 0, 0, 0, 0, 0,
29889  3 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
29890  4 7, 7, 4, 7, 7, 7, 7, 7, 6, 0,
29891  5 4, 4, 4, 0, 0, 4, 4, 4, 0, 0,
29892  6 4, 7, 7, 7, 6, 6, 7, 7, 7, 0,
29893  7 4, 4, 4, 4, 0, 4, 4, 4, 4, 0/
29894  DATA (mappr(i),i=181,500)/
29895  8 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
29896  9 6, 6, 6, 6, 6, 0, 0, 0, 0, 0,
29897  & 100*5,
29898  & 5, 0, 0, 0, 0, 0, 0, 0, 0, 0,
29899  & 8, 8, 8, 8, 8, 8, 8, 8, 8, 0,
29900  1 20*0,
29901  4 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
29902  5 7, 7, 7, 7, 0, 0, 0, 0, 0, 0,
29903  6 6, 6, 6, 6, 6, 6, 6, 6, 0, 6,
29904  7 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
29905  8 6, 6, 6, 6, 6, 6, 6, 6, 0, 0,
29906  9 7, 7, 7, 7, 7, 0, 0, 0, 0, 0,
29907  & 4, 4, 18*0,
29908  2 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
29909  3 2, 2, 2, 2, 2, 2, 2, 2, 2, 0,
29910  4 20*0,
29911  6 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
29912  7 2, 2, 2, 2, 2, 2, 2, 2, 2, 0,
29913  8 7, 7, 18*0/
29914 
29915 C...Reset number of channels and cross-section
29916  nchn=0
29917  sigs=0d0
29918 
29919 C...Read process to consider.
29920  isub=mint(1)
29921  isubsv=isub
29922  map=mappr(isub)
29923 
29924 C...Read kinematical variables and limits
29925  istsb=iset(isubsv)
29926  taumin=vint(11)
29927  ystmin=vint(12)
29928  ctnmin=vint(13)
29929  ctpmin=vint(14)
29930  taupmn=vint(16)
29931  tau=vint(21)
29932  yst=vint(22)
29933  cth=vint(23)
29934  xt2=vint(25)
29935  taup=vint(26)
29936  taumax=vint(31)
29937  ystmax=vint(32)
29938  ctnmax=vint(33)
29939  ctpmax=vint(34)
29940  taupmx=vint(36)
29941 
29942 C...Derive kinematical quantities
29943  taue=tau
29944  IF(istsb.GE.3.AND.istsb.LE.5) taue=taup
29945  x(1)=sqrt(taue)*exp(yst)
29946  x(2)=sqrt(taue)*exp(-yst)
29947  IF(mint(45).EQ.2.AND.istsb.GE.1) THEN
29948  IF(x(1).GT.1d0-1d-7) RETURN
29949  ELSEIF(mint(45).EQ.3) THEN
29950  x(1)=min(1d0-1.1d-10,x(1))
29951  ENDIF
29952  IF(mint(46).EQ.2.AND.istsb.GE.1) THEN
29953  IF(x(2).GT.1d0-1d-7) RETURN
29954  ELSEIF(mint(46).EQ.3) THEN
29955  x(2)=min(1d0-1.1d-10,x(2))
29956  ENDIF
29957  sh=max(1d0,tau*vint(2))
29958  sqm3=vint(63)
29959  sqm4=vint(64)
29960  rm3=sqm3/sh
29961  rm4=sqm4/sh
29962  be34=sqrt(max(0d0,(1d0-rm3-rm4)**2-4d0*rm3*rm4))
29963  rpts=4d0*vint(71)**2/sh
29964  be34l=sqrt(max(0d0,(1d0-rm3-rm4)**2-4d0*rm3*rm4-rpts))
29965  rm34=max(1d-20,2d0*rm3*rm4)
29966  rsqm=1d0+rm34
29967  IF(2d0*vint(71)**2/max(1d0,vint(21)*vint(2)).LT.0.0001d0)
29968  &rm34=max(rm34,2d0*vint(71)**2/max(1d0,vint(21)*vint(2)))
29969  rthm=(4d0*rm3*rm4+rpts)/(1d0-rm3-rm4+be34l)
29970  IF(istsb.EQ.0) THEN
29971  th=vint(45)
29972  uh=-0.5d0*sh*max(rthm,1d0-rm3-rm4+be34*cth)
29973  sqpth=max(vint(71)**2,0.25d0*sh*be34**2*vint(59)**2)
29974  ELSE
29975 C...Kinematics with incoming masses tricky: now depends on how
29976 C...subprocess has been set up w.r.t. order of incoming partons.
29977  rm1=0d0
29978  IF(mint(15).EQ.22.AND.vint(3).LT.0d0) rm1=-vint(3)**2/sh
29979  rm2=0d0
29980  IF(mint(16).EQ.22.AND.vint(4).LT.0d0) rm2=-vint(4)**2/sh
29981  IF(isub.EQ.35) THEN
29982  rm2=min(rm1,rm2)
29983  rm1=0d0
29984  ENDIF
29985  be12=sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))
29986  tucom=(1d0-rm1-rm2)*(1d0-rm3-rm4)
29987  th=-0.5d0*sh*max(rthm,tucom-2d0*rm1*rm4-2d0*rm2*rm3-
29988  & be12*be34*cth)
29989  uh=-0.5d0*sh*max(rthm,tucom-2d0*rm1*rm3-2d0*rm2*rm4+
29990  & be12*be34*cth)
29991  sqpth=max(vint(71)**2,0.25d0*sh*be34**2*(1d0-cth**2))
29992  ENDIF
29993  shr=sqrt(sh)
29994  sh2=sh**2
29995  th2=th**2
29996  uh2=uh**2
29997 
29998 C...Choice of Q2 scale for hard process (e.g. alpha_s).
29999  IF(istsb.EQ.1.OR.istsb.EQ.3.OR.istsb.EQ.5) THEN
30000  q2=sh
30001  ELSEIF(istsb.EQ.8) THEN
30002  IF(mint(107).EQ.4) q2=vint(307)
30003  IF(mint(108).EQ.4) q2=vint(308)
30004  ELSEIF(mod(istsb,2).EQ.0.OR.istsb.EQ.9) THEN
30005  q2in1=0d0
30006  IF(mint(11).EQ.22.AND.vint(3).LT.0d0) q2in1=vint(3)**2
30007  q2in2=0d0
30008  IF(mint(12).EQ.22.AND.vint(4).LT.0d0) q2in2=vint(4)**2
30009  IF(mstp(32).EQ.1) THEN
30010  q2=2d0*sh*th*uh/(sh**2+th**2+uh**2)
30011  ELSEIF(mstp(32).EQ.2) THEN
30012  q2=sqpth+0.5d0*(sqm3+sqm4)
30013  ELSEIF(mstp(32).EQ.3) THEN
30014  q2=min(-th,-uh)
30015  ELSEIF(mstp(32).EQ.4) THEN
30016  q2=sh
30017  ELSEIF(mstp(32).EQ.5) THEN
30018  q2=-th
30019  ELSEIF(mstp(32).EQ.6) THEN
30020  xsf1=x(1)
30021  IF(istsb.EQ.9) xsf1=x(1)/vint(143)
30022  xsf2=x(2)
30023  IF(istsb.EQ.9) xsf2=x(2)/vint(144)
30024  q2=(1d0+xsf1*q2in1/sh+xsf2*q2in2/sh)*
30025  & (sqpth+0.5d0*(sqm3+sqm4))
30026  ELSEIF(mstp(32).EQ.7) THEN
30027  q2=(1d0+q2in1/sh+q2in2/sh)*(sqpth+0.5d0*(sqm3+sqm4))
30028  ELSEIF(mstp(32).EQ.8) THEN
30029  q2=sqpth+0.5d0*(q2in1+q2in2+sqm3+sqm4)
30030  ELSEIF(mstp(32).EQ.9) THEN
30031  q2=sqpth+q2in1+q2in2+sqm3+sqm4
30032  ELSEIF(mstp(32).EQ.10) THEN
30033  q2=vint(2)
30034 C..Begin JA 040914
30035  ELSEIF(mstp(32).EQ.11) THEN
30036  q2=0.25*(sqm3+sqm4+2*sqrt(sqm3*sqm4))
30037  ELSEIF(mstp(32).EQ.12) THEN
30038  q2=parp(193)
30039 C..End JA
30040  ELSEIF(mstp(32).EQ.13) THEN
30041  q2=sqpth
30042  ENDIF
30043  IF(mint(35).LE.2.AND.istsb.EQ.9) q2=sqpth
30044  IF(istsb.EQ.9.AND.mstp(82).GE.2) q2=q2+
30045  & (parp(82)*(vint(1)/parp(89))**parp(90))**2
30046  ENDIF
30047 
30048 C...Choice of Q2 scale for parton densities.
30049  q2sf=q2
30050 C..Begin JA 040914
30051  IF(mstp(32).EQ.12.AND.(mod(istsb,2).EQ.0.OR.istsb.EQ.9)
30052  & .OR.mstp(39).EQ.8.AND.(istsb.GE.3.AND.istsb.LE.5))
30053  & q2=parp(194)
30054 C..End JA
30055  IF(istsb.GE.3.AND.istsb.LE.5) THEN
30056  q2sf=pmas(23,1)**2
30057  IF(isub.EQ.8.OR.isub.EQ.76.OR.isub.EQ.77.OR.isub.EQ.124.OR.
30058  & isub.EQ.174.OR.isub.EQ.179.OR.isub.EQ.351) q2sf=pmas(24,1)**2
30059  IF(isub.EQ.352) q2sf=pmas(pycomp(9900024),1)**2
30060  IF(isub.EQ.121.OR.isub.EQ.122.OR.isub.EQ.181.OR.isub.EQ.182.OR.
30061  & isub.EQ.186.OR.isub.EQ.187.OR.isub.EQ.401.OR.isub.EQ.402) THEN
30062  q2sf=pmas(pycomp(kfpr(isubsv,2)),1)**2
30063  IF(mstp(39).EQ.2) q2sf=
30064  & max(vint(201)**2+vint(202),vint(206)**2+vint(207))
30065  IF(mstp(39).EQ.3) q2sf=sh
30066  IF(mstp(39).EQ.4) q2sf=vint(26)*vint(2)
30067  IF(mstp(39).EQ.5) q2sf=pmas(pycomp(kfpr(isubsv,1)),1)**2
30068 C..Begin JA 040914
30069  IF(mstp(39).EQ.6) q2sf=0.25*(vint(201)+sqrt(sh))**2
30070  IF(mstp(39).EQ.7) q2sf=
30071  & (vint(201)**2+vint(202)+vint(206)**2+vint(207))/2d0
30072  IF(mstp(39).EQ.8) q2sf=parp(193)
30073 C..End JA
30074  ENDIF
30075  ENDIF
30076  IF(mint(35).GE.3.AND.istsb.EQ.9) q2sf=sqpth
30077 
30078  q2ps=q2sf
30079  q2sf=q2sf*parp(34)
30080  IF(mstp(69).GE.1.AND.mint(47).EQ.5) q2sf=vint(2)
30081  IF(mstp(69).GE.2) q2sf=vint(2)
30082 
30083 C...Identify to which class(es) subprocess belongs
30084  ismecr=0
30085  isqcd=0
30086  isjets=0
30087  IF (isubsv.EQ.1.OR.isubsv.EQ.2.OR.isubsv.EQ.3.OR.
30088  & isubsv.EQ.102.OR.isubsv.EQ.141.OR.isubsv.EQ.142.OR.
30089  & isubsv.EQ.144.OR.isubsv.EQ.151.OR.isubsv.EQ.152.OR.
30090  & isubsv.EQ.156.OR.isubsv.EQ.157) ismecr=1
30091  IF (isubsv.EQ.11.OR.isubsv.EQ.12.OR.isubsv.EQ.13.OR.
30092  & isubsv.EQ.28.OR.isubsv.EQ.53.OR.isubsv.EQ.68) isqcd=1
30093  IF ((isubsv.EQ.81.OR.isubsv.EQ.82).AND.mint(55).LE.5) isqcd=1
30094  IF (isubsv.GE.381.AND.isubsv.LE.386) isqcd=1
30095  IF ((isubsv.EQ.387.OR.isubsv.EQ.388).AND.mint(55).LE.5) isqcd=1
30096  IF (istsb.EQ.9) isqcd=1
30097  IF ((isubsv.GE.86.AND.isubsv.LE.89).OR.isubsv.EQ.107.OR.
30098  & (isubsv.GE.14.AND.isubsv.LE.16).OR.(isubsv.GE.29.AND.
30099  & isubsv.LE.32).OR.(isubsv.GE.111.AND.isubsv.LE.113).OR.
30100  & isubsv.EQ.115.OR.(isubsv.GE.183.AND.isubsv.LE.185).OR.
30101  & (isubsv.GE.188.AND.isubsv.LE.190).OR.isubsv.EQ.161.OR.
30102  & isubsv.EQ.167.OR.isubsv.EQ.168.OR.(isubsv.GE.393.AND.
30103  & isubsv.LE.395).OR.(isubsv.GE.421.AND.isubsv.LE.439).OR.
30104  & (isubsv.GE.461.AND.isubsv.LE.479)) isjets=1
30105 C...WBF is special case of ISJETS
30106  IF (isubsv.EQ.5.OR.isubsv.EQ.8.OR.
30107  & (isubsv.GE.71.AND.isubsv.LE.73).OR.
30108  & isubsv.EQ.76.OR.isubsv.EQ.77.OR.
30109  & (isubsv.GE.121.AND.isubsv.LE.124).OR.
30110  & isubsv.EQ.173.OR.isubsv.EQ.174.OR.
30111  & isubsv.EQ.178.OR.isubsv.EQ.179.OR.
30112  & isubsv.EQ.181.OR.isubsv.EQ.182.OR.
30113  & isubsv.EQ.186.OR.isubsv.EQ.187.OR.
30114  & isubsv.EQ.351.OR.isubsv.EQ.352) isjets=2
30115 C...Some processes with photons also belong here.
30116  IF (isubsv.EQ.10.OR.(isubsv.GE.18.AND.isubsv.LE.20).OR.
30117  & (isubsv.GE.33.AND.isubsv.LE.36).OR.isubsv.EQ.54.OR.
30118  & isubsv.EQ.58.OR.isubsv.EQ.69.OR.isubsv.EQ.70.OR.
30119  & isubsv.EQ.80.OR.(isubsv.GE.83.AND.isubsv.LE.85).OR.
30120  & (isubsv.GE.106.AND.isubsv.LE.110).OR.isubsv.EQ.114.OR.
30121  & (isubsv.GE.131.AND.isubsv.LE.140)) isjets=3
30122 
30123 C...Choice of Q2 scale for parton-shower activity.
30124  IF(mstp(22).GE.1.AND.(isub.EQ.10.OR.isub.EQ.83).AND.
30125  &(mint(43).EQ.2.OR.mint(43).EQ.3)) THEN
30126  xbj=x(2)
30127  IF(mint(43).EQ.3) xbj=x(1)
30128  IF(mstp(22).EQ.1) THEN
30129  q2ps=-th
30130  ELSEIF(mstp(22).EQ.2) THEN
30131  q2ps=((1d0-xbj)/xbj)*(-th)
30132  ELSEIF(mstp(22).EQ.3) THEN
30133  q2ps=sqrt((1d0-xbj)/xbj)*(-th)
30134  ELSE
30135  q2ps=(1d0-xbj)*max(1d0,-log(xbj))*(-th)
30136  ENDIF
30137  ENDIF
30138 C...For multiple interactions, start from scale defined above
30139 C...For all other QCD or "+jets"-type events, start shower from pThard.
30140  IF (isjets.EQ.1.OR.isqcd.EQ.1.AND.istsb.NE.9) q2ps=sqpth
30141  IF((mstp(68).EQ.1.OR.mstp(68).EQ.3).AND.ismecr.EQ.1) THEN
30142 C...Max shower scale = s for ME corrected processes.
30143 C...(pT-ordering: max pT2 is s/4)
30144  q2ps=vint(2)
30145  IF (mint(35).GE.3) q2ps=q2ps*0.25d0
30146  ELSEIF(mstp(68).GE.2.AND.isqcd.EQ.0.AND.isjets.EQ.0) THEN
30147 C...Max shower scale = s for all non-QCD, non-"+ jet" type processes.
30148 C...(pT-ordering: max pT2 is s/4)
30149  q2ps=vint(2)
30150  IF (mint(35).GE.3) q2ps=q2ps*0.25d0
30151  ENDIF
30152  IF(mint(35).EQ.2.AND.istsb.EQ.9) q2ps=sqpth
30153 
30154 C...Elastic and diffractive events not associated with scales so set 0.
30155  IF(isubsv.GE.91.AND.isubsv.LE.94) THEN
30156  q2sf=0d0
30157  q2ps=0d0
30158  ENDIF
30159 
30160 C...Store derived kinematical quantities
30161  vint(41)=x(1)
30162  vint(42)=x(2)
30163  vint(44)=sh
30164  vint(43)=sqrt(sh)
30165  vint(45)=th
30166  vint(46)=uh
30167  IF(istsb.NE.8) vint(48)=sqpth
30168  IF(istsb.NE.8) vint(47)=sqrt(sqpth)
30169  vint(50)=taup*vint(2)
30170  vint(49)=sqrt(max(0d0,vint(50)))
30171  vint(52)=q2
30172  vint(51)=sqrt(q2)
30173  vint(54)=q2sf
30174  vint(53)=sqrt(q2sf)
30175  vint(56)=q2ps
30176  vint(55)=sqrt(q2ps)
30177 
30178 C...Set starting scale for multiple interactions
30179  IF (isubsv.EQ.95) THEN
30180  xt2gmx=0d0
30181  ELSEIF(mstp(86).EQ.3.OR.(mstp(86).EQ.2.AND.isubsv.NE.11.AND.
30182  & isubsv.NE.12.AND.isubsv.NE.13.AND.isubsv.NE.28.AND.
30183  & isubsv.NE.53.AND.isubsv.NE.68.AND.isubsv.NE.95.AND.
30184  & isubsv.NE.96)) THEN
30185 C...All accessible phase space allowed.
30186  xt2gmx=(1d0-vint(41))*(1d0-vint(42))
30187  ELSE
30188 C...Scale of hard process sets limit.
30189 C...2 -> 1. Limit is tau = x1*x2.
30190 C...2 -> 2. Limit is XT2 for hard process + FS masses.
30191 C...2 -> n > 2. Limit is tau' = tau of outer process.
30192  xt2gmx=vint(25)
30193  IF(istsb.EQ.1) xt2gmx=vint(21)
30194  IF(istsb.EQ.2)
30195  & xt2gmx=(4d0*vint(48)+2d0*vint(63)+2d0*vint(64))/vint(2)
30196  IF(istsb.GE.3.AND.istsb.LE.5) xt2gmx=vint(26)
30197  ENDIF
30198  vint(62)=0.25d0*xt2gmx*vint(2)
30199  vint(61)=sqrt(max(0d0,vint(62)))
30200 
30201 C...Calculate parton distributions
30202  IF(istsb.LE.0) goto 160
30203  IF(mint(47).GE.2) THEN
30204  DO 110 i=3-min(2,mint(45)),min(2,mint(46))
30205  xsf=x(i)
30206  IF(istsb.EQ.9) xsf=x(i)/vint(142+i)
30207  IF(isub.EQ.99) THEN
30208  IF(mint(140+i).EQ.0) THEN
30209  xsf=vint(309-i)/(vint(2)+vint(309-i)-vint(i+2)**2)
30210  ELSE
30211  xsf=vint(309-i)/(vint(2)+vint(307)+vint(308))
30212  ENDIF
30213  vint(40+i)=xsf
30214  q2sf=vint(309-i)
30215  ENDIF
30216  mint(105)=mint(102+i)
30217  mint(109)=mint(106+i)
30218  vint(120)=vint(2+i)
30219 C...Default is to use standard PDFs, but for interactions after the first
30220 C...in the new multiple-parton-interactions framework, set which side to
30221 C...evaluate the MPI-modified PDFs on.
30222  mint(30)=0
30223  IF (mint(31).GE.1) mint(30)=i
30224  IF(mstp(57).LE.1) THEN
30225  CALL pypdfu(mint(10+i),xsf,q2sf,xpq)
30226  ELSE
30227  CALL pypdfl(mint(10+i),xsf,q2sf,xpq)
30228  ENDIF
30229 C...Safety margin against heavy flavour very close to threshold,
30230 C...e.g. caused by mismatch in c and b masses.
30231  IF(q2sf.LT.1.1*pmas(4,1)**2) THEN
30232  xpq(4)=0d0
30233  xpq(-4)=0d0
30234  ENDIF
30235  IF(q2sf.LT.1.1*pmas(5,1)**2) THEN
30236  xpq(5)=0d0
30237  xpq(-5)=0d0
30238  ENDIF
30239  DO 100 kfl=-25,25
30240  xsfx(i,kfl)=xpq(kfl)
30241  100 CONTINUE
30242  110 CONTINUE
30243  ENDIF
30244 
30245 C...Calculate alpha_em, alpha_strong and K-factor
30246  xw=paru(102)
30247  xwv=xw
30248  IF(mstp(8).GE.2.OR.(isub.GE.71.AND.isub.LE.77)) xw=
30249  &1d0-(pmas(24,1)/pmas(23,1))**2
30250  xw1=1d0-xw
30251  xwc=1d0/(16d0*xw*xw1)
30252  aem=pyalem(q2)
30253  IF(mstp(8).GE.1) aem=sqrt(2d0)*paru(105)*pmas(24,1)**2*xw/paru(1)
30254  IF(mstp(33).NE.3) as=pyalps(parp(34)*q2)
30255  fack=1d0
30256  faca=1d0
30257  IF(mstp(33).EQ.1) THEN
30258  fack=parp(31)
30259  ELSEIF(mstp(33).EQ.2) THEN
30260  fack=parp(31)
30261  faca=parp(32)/parp(31)
30262  ELSEIF(mstp(33).EQ.3) THEN
30263  q2as=parp(33)*q2
30264  IF(istsb.EQ.9.AND.mstp(82).GE.2) q2as=q2as+
30265  & paru(112)*parp(82)*(vint(1)/parp(89))**parp(90)
30266  as=pyalps(q2as)
30267 C...PS (12 Feb 2010)
30268 C...New options MSTP(33) = 10 and 11
30269 C... 10: use K-factor = PARP(32) only for process 96 (MPI)
30270 C... 11: as for 10, but also use K-factor = PARP(31) for other procs
30271  ELSEIF(mstp(33).GE.10) THEN
30272  IF (isub.EQ.96) THEN
30273  fack = parp(32)
30274  ELSEIF (isub.NE.96.AND.mstp(33).EQ.11) THEN
30275  fack = parp(31)
30276  ENDIF
30277  ENDIF
30278  vint(138)=1d0
30279  vint(57)=aem
30280  vint(58)=as
30281 
30282 C...Set flags for allowed reacting partons/leptons
30283  DO 140 i=1,2
30284  DO 120 j=-25,25
30285  kfac(i,j)=0
30286  120 CONTINUE
30287  IF(mint(44+i).EQ.1) THEN
30288  kfac(i,mint(10+i))=1
30289  ELSEIF(mint(40+i).EQ.1.AND.mstp(12).EQ.0) THEN
30290  kfac(i,mint(10+i))=1
30291  kfac(i,22)=1
30292  kfac(i,24)=1
30293  kfac(i,-24)=1
30294  ELSE
30295  DO 130 j=-25,25
30296  kfac(i,j)=kfin(i,j)
30297  IF(iabs(j).GT.mstp(58).AND.iabs(j).LE.10) kfac(i,j)=0
30298  IF(xsfx(i,j).LT.1d-10) kfac(i,j)=0
30299  130 CONTINUE
30300  ENDIF
30301  140 CONTINUE
30302 
30303 C...Lower and upper limit for fermion flavour loops
30304  mmin1=0
30305  mmax1=0
30306  mmin2=0
30307  mmax2=0
30308  DO 150 j=-20,20
30309  IF(kfac(1,-j).EQ.1) mmin1=-j
30310  IF(kfac(1,j).EQ.1) mmax1=j
30311  IF(kfac(2,-j).EQ.1) mmin2=-j
30312  IF(kfac(2,j).EQ.1) mmax2=j
30313  150 CONTINUE
30314  mmina=min(mmin1,mmin2)
30315  mmaxa=max(mmax1,mmax2)
30316 
30317 C...Common resonance mass and width combinations
30318  sqmz=pmas(23,1)**2
30319  sqmw=pmas(24,1)**2
30320  gmmz=pmas(23,1)*pmas(23,2)
30321  gmmw=pmas(24,1)*pmas(24,2)
30322 
30323 C...Polarization factors...implemented so far for W+W-(25)
30324  polr=(1d0+parj(132))*(1d0-parj(131))
30325  poll=(1d0-parj(132))*(1d0+parj(131))
30326  polrr=(1d0+parj(132))*(1d0+parj(131))
30327  polll=(1d0-parj(132))*(1d0-parj(131))
30328 
30329 C...Phase space integral in tau
30330  comfac=paru(1)*paru(5)/vint(2)
30331  IF(mint(41).EQ.2.AND.mint(42).EQ.2) comfac=comfac*fack
30332  IF((mint(47).GE.2.OR.(istsb.GE.3.AND.istsb.LE.5)).AND.
30333  &istsb.NE.8.AND.istsb.NE.9) THEN
30334  atau1=log(taumax/taumin)
30335  atau2=(taumax-taumin)/(taumax*taumin)
30336  h1=coef(isubsv,1)+(atau1/atau2)*coef(isubsv,2)/tau
30337  IF(mint(72).GE.1) THEN
30338  taur1=vint(73)
30339  gamr1=vint(74)
30340  ataud=log(taumax/taumin*(taumin+taur1)/(taumax+taur1))
30341  atau3=ataud/taur1
30342  IF(ataud.GT.1d-10) h1=h1+
30343  & (atau1/atau3)*coef(isubsv,3)/(tau+taur1)
30344  ataud=atan((taumax-taur1)/gamr1)-atan((taumin-taur1)/gamr1)
30345  atau4=ataud/gamr1
30346  IF(ataud.GT.1d-10) h1=h1+
30347  & (atau1/atau4)*coef(isubsv,4)*tau/((tau-taur1)**2+gamr1**2)
30348  ENDIF
30349  IF(mint(72).GE.2) THEN
30350  taur2=vint(75)
30351  gamr2=vint(76)
30352  ataud=log(taumax/taumin*(taumin+taur2)/(taumax+taur2))
30353  atau5=ataud/taur2
30354  IF(ataud.GT.1d-10) h1=h1+
30355  & (atau1/atau5)*coef(isubsv,5)/(tau+taur2)
30356  ataud=atan((taumax-taur2)/gamr2)-atan((taumin-taur2)/gamr2)
30357  atau6=ataud/gamr2
30358  IF(ataud.GT.1d-10) h1=h1+
30359  & (atau1/atau6)*coef(isubsv,6)*tau/((tau-taur2)**2+gamr2**2)
30360  ENDIF
30361  IF(mint(72).EQ.3) THEN
30362  taur3=vint(77)
30363  gamr3=vint(78)
30364  ataud=log(taumax/taumin*(taumin+taur3)/(taumax+taur3))
30365  atau50=ataud/taur3
30366  IF(ataud.GT.1d-10) h1=h1+
30367  & (atau1/atau50)*coefx(isubsv,1)/(tau+taur3)
30368  ataud=atan((taumax-taur3)/gamr3)-atan((taumin-taur3)/gamr3)
30369  atau60=ataud/gamr3
30370  IF(ataud.GT.1d-10) h1=h1+
30371  & (atau1/atau60)*coefx(isubsv,2)*tau/((tau-taur3)**2+gamr3**2)
30372  ENDIF
30373  IF(mint(47).EQ.5.AND.(istsb.LE.2.OR.istsb.GE.5)) THEN
30374  atau7=log(max(2d-10,1d0-taumin)/max(2d-10,1d0-taumax))
30375  IF(atau7.GT.1d-10) h1=h1+(atau1/atau7)*coef(isubsv,7)*tau/
30376  & max(2d-10,1d0-tau)
30377  ELSEIF(mint(47).GE.6.AND.(istsb.LE.2.OR.istsb.GE.5)) THEN
30378  atau7=log(max(1d-10,1d0-taumin)/max(1d-10,1d0-taumax))
30379  IF(atau7.GT.1d-10) h1=h1+(atau1/atau7)*coef(isubsv,7)*tau/
30380  & max(1d-10,1d0-tau)
30381  ENDIF
30382  comfac=comfac*atau1/(tau*h1)
30383  ENDIF
30384 
30385 C...Phase space integral in y*
30386  IF((mint(47).EQ.4.OR.mint(47).EQ.5).AND.istsb.NE.8.AND.istsb.NE.9)
30387  &THEN
30388  ayst0=ystmax-ystmin
30389  IF(ayst0.LT.1d-10) THEN
30390  comfac=0d0
30391  ELSE
30392  ayst1=0.5d0*(ystmax-ystmin)**2
30393  ayst2=ayst1
30394  ayst3=2d0*(atan(exp(ystmax))-atan(exp(ystmin)))
30395  h2=(ayst0/ayst1)*coef(isubsv,8)*(yst-ystmin)+
30396  & (ayst0/ayst2)*coef(isubsv,9)*(ystmax-yst)+
30397  & (ayst0/ayst3)*coef(isubsv,10)/cosh(yst)
30398  IF(mint(45).EQ.3) THEN
30399  yst0=-0.5d0*log(taue)
30400  ayst4=log(max(1d-10,exp(yst0-ystmin)-1d0)/
30401  & max(1d-10,exp(yst0-ystmax)-1d0))
30402  IF(ayst4.GT.1d-10) h2=h2+(ayst0/ayst4)*coef(isubsv,11)/
30403  & max(1d-10,1d0-exp(yst-yst0))
30404  ENDIF
30405  IF(mint(46).EQ.3) THEN
30406  yst0=-0.5d0*log(taue)
30407  ayst5=log(max(1d-10,exp(yst0+ystmax)-1d0)/
30408  & max(1d-10,exp(yst0+ystmin)-1d0))
30409  IF(ayst5.GT.1d-10) h2=h2+(ayst0/ayst5)*coef(isubsv,12)/
30410  & max(1d-10,1d0-exp(-yst-yst0))
30411  ENDIF
30412  comfac=comfac*ayst0/h2
30413  ENDIF
30414  ENDIF
30415 
30416 C...2 -> 1 processes: reduction in angular part of phase space integral
30417 C...for case of decaying resonance
30418  acth0=ctnmax-ctnmin+ctpmax-ctpmin
30419  IF((istsb.EQ.1.OR.istsb.EQ.3.OR.istsb.EQ.5)) THEN
30420  IF(mdcy(pycomp(kfpr(isubsv,1)),1).EQ.1) THEN
30421  IF(kfpr(isub,1).EQ.25.OR.kfpr(isub,1).EQ.37.OR.
30422  & kfpr(isub,1).EQ.39) THEN
30423  comfac=comfac*0.5d0*acth0
30424  ELSE
30425  comfac=comfac*0.125d0*(3d0*acth0+ctnmax**3-ctnmin**3+
30426  & ctpmax**3-ctpmin**3)
30427  ENDIF
30428  ENDIF
30429 
30430 C...2 -> 2 processes: angular part of phase space integral
30431  ELSEIF(istsb.EQ.2.OR.istsb.EQ.4) THEN
30432  acth1=log((max(rm34,rsqm-ctnmin)*max(rm34,rsqm-ctpmin))/
30433  & (max(rm34,rsqm-ctnmax)*max(rm34,rsqm-ctpmax)))
30434  acth2=log((max(rm34,rsqm+ctnmax)*max(rm34,rsqm+ctpmax))/
30435  & (max(rm34,rsqm+ctnmin)*max(rm34,rsqm+ctpmin)))
30436  acth3=1d0/max(rm34,rsqm-ctnmax)-1d0/max(rm34,rsqm-ctnmin)+
30437  & 1d0/max(rm34,rsqm-ctpmax)-1d0/max(rm34,rsqm-ctpmin)
30438  acth4=1d0/max(rm34,rsqm+ctnmin)-1d0/max(rm34,rsqm+ctnmax)+
30439  & 1d0/max(rm34,rsqm+ctpmin)-1d0/max(rm34,rsqm+ctpmax)
30440  h3=coef(isubsv,13)+
30441  & (acth0/acth1)*coef(isubsv,14)/max(rm34,rsqm-cth)+
30442  & (acth0/acth2)*coef(isubsv,15)/max(rm34,rsqm+cth)+
30443  & (acth0/acth3)*coef(isubsv,16)/max(rm34,rsqm-cth)**2+
30444  & (acth0/acth4)*coef(isubsv,17)/max(rm34,rsqm+cth)**2
30445  comfac=comfac*acth0*0.5d0*be34/h3
30446 
30447 C...2 -> 2 processes: take into account final state Breit-Wigners
30448  comfac=comfac*vint(80)
30449  ENDIF
30450 
30451 C...2 -> 3, 4 processes: phace space integral in tau'
30452  IF(mint(47).GE.2.AND.istsb.GE.3.AND.istsb.LE.5) THEN
30453  ataup1=log(taupmx/taupmn)
30454  ataup2=((1d0-tau/taupmx)**4-(1d0-tau/taupmn)**4)/(4d0*tau)
30455  h4=coef(isubsv,18)+
30456  & (ataup1/ataup2)*coef(isubsv,19)*(1d0-tau/taup)**3/taup
30457  IF(mint(47).EQ.5) THEN
30458  ataup3=log(max(2d-10,1d0-taupmn)/max(2d-10,1d0-taupmx))
30459  h4=h4+(ataup1/ataup3)*coef(isubsv,20)*taup/max(2d-10,1d0-taup)
30460  ELSEIF(mint(47).GE.6) THEN
30461  ataup3=log(max(1d-10,1d0-taupmn)/max(1d-10,1d0-taupmx))
30462  h4=h4+(ataup1/ataup3)*coef(isubsv,20)*taup/max(1d-10,1d0-taup)
30463  ENDIF
30464  comfac=comfac*ataup1/h4
30465  ENDIF
30466 
30467 C...2 -> 3, 4 processes: effective W/Z parton distributions
30468  IF(istsb.EQ.3.OR.istsb.EQ.4) THEN
30469  IF(1d0-tau/taup.GT.1d-4) THEN
30470  fzw=(1d0+tau/taup)*log(taup/tau)-2d0*(1d0-tau/taup)
30471  ELSE
30472  fzw=1d0/6d0*(1d0-tau/taup)**3*tau/taup
30473  ENDIF
30474  comfac=comfac*fzw
30475  ENDIF
30476 
30477 C...2 -> 3 processes: phase space integrals for pT1, pT2, y3, mirror
30478  IF(istsb.EQ.5) THEN
30479  comfac=comfac*vint(205)*vint(210)*vint(212)*vint(214)/
30480  & (128d0*paru(1)**4*vint(220))*(tau**2/taup)
30481  ENDIF
30482 
30483 C...Phase space integral for low-pT and multiple interactions
30484  IF(istsb.EQ.9) THEN
30485  comfac=paru(1)*paru(5)*fack*0.5d0*vint(2)/sh2
30486  atau1=log(2d0*(1d0+sqrt(1d0-xt2))/xt2-1d0)
30487  atau2=2d0*atan(1d0/xt2-1d0)/sqrt(xt2)
30488  h1=coef(isubsv,1)+(atau1/atau2)*coef(isubsv,2)/sqrt(tau)
30489  comfac=comfac*atau1/h1
30490  ayst0=ystmax-ystmin
30491  ayst1=0.5d0*(ystmax-ystmin)**2
30492  ayst3=2d0*(atan(exp(ystmax))-atan(exp(ystmin)))
30493  h2=(ayst0/ayst1)*coef(isubsv,8)*(yst-ystmin)+
30494  & (ayst0/ayst1)*coef(isubsv,9)*(ystmax-yst)+
30495  & (ayst0/ayst3)*coef(isubsv,10)/cosh(yst)
30496  comfac=comfac*ayst0/h2
30497  IF(mstp(82).LE.1) comfac=comfac*xt2**2*(1d0/vint(149)-1d0)
30498 C...For MSTP(82)>=2 an additional factor (xT2/(xT2+VINT(149))**2 is
30499 C...introduced to make cross-section finite for xT2 -> 0
30500  IF(mstp(82).GE.2) comfac=comfac*xt2**2/(vint(149)*
30501  & (1d0+vint(149)))
30502  ENDIF
30503 
30504 C...Real gamma + gamma: include factor 2 when different nature
30505  160 IF(mint(11).EQ.22.AND.mint(12).EQ.22.AND.mint(123).GE.4.AND.
30506  &mstp(14).LE.10) comfac=2d0*comfac
30507 
30508 C...Extra factors to include the effects of
30509 C...longitudinal resolved photons (but not direct or DIS ones).
30510  DO 170 isde=1,2
30511  IF(mint(10+isde).EQ.22.AND.mint(106+isde).GE.1.AND.
30512  & mint(106+isde).LE.3) THEN
30513  vint(314+isde)=1d0
30514  xy=parp(166+isde)
30515  IF(mstp(16).EQ.0) THEN
30516  IF(vint(304+isde).GT.0d0.AND.vint(304+isde).LT.1d0)
30517  & xy=vint(304+isde)
30518  ELSE
30519  IF(vint(308+isde).GT.0d0.AND.vint(308+isde).LT.1d0)
30520  & xy=vint(308+isde)
30521  ENDIF
30522  q2ga=vint(306+isde)
30523  IF(mstp(17).GT.0.AND.xy.GT.0d0.AND.xy.LT.1d0.AND.
30524  & q2ga.GT.0d0) THEN
30525  reduce=0d0
30526  IF(mstp(17).EQ.1) THEN
30527  reduce=4d0*q2*q2ga/(q2+q2ga)**2
30528  ELSEIF(mstp(17).EQ.2) THEN
30529  reduce=4d0*q2ga/(q2+q2ga)
30530  ELSEIF(mstp(17).EQ.3) THEN
30531  pmvirt=pmas(pycomp(113),1)
30532  reduce=4d0*q2ga/(pmvirt**2+q2ga)
30533  ELSEIF(mstp(17).EQ.4.AND.mint(106+isde).EQ.1) THEN
30534  pmvirt=pmas(pycomp(113),1)
30535  reduce=4d0*pmvirt**2*q2ga/(pmvirt**2+q2ga)**2
30536  ELSEIF(mstp(17).EQ.4.AND.mint(106+isde).EQ.2) THEN
30537  pmvirt=pmas(pycomp(113),1)
30538  reduce=4d0*pmvirt**2*q2ga/(pmvirt**2+q2ga)**2
30539  ELSEIF(mstp(17).EQ.4.AND.mint(106+isde).EQ.3) THEN
30540  pmvsmn=4d0*parp(15)**2
30541  pmvsmx=4d0*vint(154)**2
30542  redtra=1d0/(pmvsmn+q2ga)-1d0/(pmvsmx+q2ga)
30543  redlon=(3d0*pmvsmn+q2ga)/(pmvsmn+q2ga)**3-
30544  & (3d0*pmvsmx+q2ga)/(pmvsmx+q2ga)**3
30545  reduce=4d0*(q2ga/6d0)*redlon/redtra
30546  ELSEIF(mstp(17).EQ.5.AND.mint(106+isde).EQ.1) THEN
30547  pmvirt=pmas(pycomp(113),1)
30548  reduce=4d0*q2ga/(pmvirt**2+q2ga)
30549  ELSEIF(mstp(17).EQ.5.AND.mint(106+isde).EQ.2) THEN
30550  pmvirt=pmas(pycomp(113),1)
30551  reduce=4d0*q2ga/(pmvirt**2+q2ga)
30552  ELSEIF(mstp(17).EQ.5.AND.mint(106+isde).EQ.3) THEN
30553  pmvsmn=4d0*parp(15)**2
30554  pmvsmx=4d0*vint(154)**2
30555  redtra=1d0/(pmvsmn+q2ga)-1d0/(pmvsmx+q2ga)
30556  redlon=1d0/(pmvsmn+q2ga)**2-1d0/(pmvsmx+q2ga)**2
30557  reduce=4d0*(q2ga/2d0)*redlon/redtra
30558  ENDIF
30559  beamas=pymass(11)
30560  IF(vint(302+isde).GT.0d0) beamas=vint(302+isde)
30561  fraclt=1d0/(1d0+xy**2/2d0/(1d0-xy)*
30562  & (1d0-2d0*beamas**2/q2ga))
30563  vint(314+isde)=1d0+parp(165)*reduce*fraclt
30564  ENDIF
30565  ELSE
30566  vint(314+isde)=1d0
30567  ENDIF
30568  comfac=comfac*vint(314+isde)
30569  170 CONTINUE
30570 
30571 C...Evaluate cross sections - done in separate routines by kind
30572 C...of physics, to keep PYSIGH of sensible size.
30573  IF(map.EQ.1) THEN
30574 C...Standard QCD (including photons).
30575  CALL pysgqc(nchn,sigs)
30576  ELSEIF(map.EQ.2) THEN
30577 C...Heavy flavours.
30578  CALL pysghf(nchn,sigs)
30579  ELSEIF(map.EQ.3) THEN
30580 C...W/Z.
30581  CALL pysgwz(nchn,sigs)
30582  ELSEIF(map.EQ.4) THEN
30583 C...Higgs (2 doublets; including longitudinal W/Z scattering).
30584  CALL pysghg(nchn,sigs)
30585  ELSEIF(map.EQ.5) THEN
30586 C...SUSY.
30587  CALL pysgsu(nchn,sigs)
30588  ELSEIF(map.EQ.6) THEN
30589 C...Technicolor.
30590  CALL pysgtc(nchn,sigs)
30591  ELSEIF(map.EQ.7) THEN
30592 C...Exotics (Z'/W'/LQ/R/f*/H++/Z_R/W_R/G*).
30593  CALL pysgex(nchn,sigs)
30594  ELSEIF(map.EQ.8) THEN
30595 C... Universal Extra Dimensions
30596  CALL pyxued(nchn,sigs)
30597  ENDIF
30598 
30599 C...Multiply with parton distributions
30600  IF(isub.LE.90.OR.isub.GE.96) THEN
30601  DO 180 ichn=1,nchn
30602  IF(mint(45).GE.2) THEN
30603  kfl1=isig(ichn,1)
30604  sigh(ichn)=sigh(ichn)*xsfx(1,kfl1)
30605  ENDIF
30606  IF(mint(46).GE.2) THEN
30607  kfl2=isig(ichn,2)
30608  sigh(ichn)=sigh(ichn)*xsfx(2,kfl2)
30609  ENDIF
30610  sigs=sigs+sigh(ichn)
30611  180 CONTINUE
30612  ENDIF
30613 
30614  RETURN
30615  END
30616 
30617 C*********************************************************************
30618 
30619 C...PYSGQC
30620 C...Subprocess cross sections for QCD processes,
30621 C...including photons.
30622 C...Auxiliary to PYSIGH.
30623 
30624  SUBROUTINE pysgqc(NCHN,SIGS)
30625 
30626 C...Double precision and integer declarations
30627  IMPLICIT DOUBLE PRECISION(a-h, o-z)
30628  IMPLICIT INTEGER(i-n)
30629  INTEGER pyk,pychge,pycomp
30630 C...Parameter statement to help give large particle numbers.
30631  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
30632  &kexcit=4000000,kdimen=5000000)
30633 C...Commonblocks
30634  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
30635  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
30636  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
30637  common/pypars/mstp(200),parp(200),msti(200),pari(200)
30638  common/pyint1/mint(400),vint(400)
30639  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
30640  common/pyint3/xsfx(2,-40:40),isig(1000,3),sigh(1000)
30641  common/pyint4/mwid(500),wids(500,5)
30642  common/pyint7/sigt(0:6,0:6,0:5)
30643  common/pysgcm/isub,isubsv,mmin1,mmax1,mmin2,mmax2,mmina,mmaxa,
30644  &kfac(2,-40:40),comfac,fack,faca,sh,th,uh,sh2,th2,uh2,sqm3,sqm4,
30645  &shr,sqpth,taup,be34,cth,x(2),sqmz,sqmw,gmmz,gmmw,
30646  &aem,as,xw,xw1,xwc,xwv,poll,polr,polll,polrr
30647  SAVE /pydat1/,/pydat2/,/pydat3/,/pypars/,/pyint1/,/pyint2/,
30648  &/pyint3/,/pyint4/,/pyint7/,/pysgcm/
30649 C...Local arrays
30650  dimension wdtp(0:400),wdte(0:400,0:5)
30651 
30652 C...Differential cross section expressions.
30653 
30654  IF(isub.LE.20) THEN
30655  IF(isub.EQ.10) THEN
30656 C...f + f' -> f + f' (gamma/Z/W exchange)
30657  facggf=comfac*aem**2*2d0*(sh2+uh2)/th2
30658  facgzf=comfac*aem**2*xwc*4d0*sh2/(th*(th-sqmz))
30659  faczzf=comfac*(aem*xwc)**2*2d0*sh2/(th-sqmz)**2
30660  facwwf=comfac*(0.5d0*aem/xw)**2*sh2/(th-sqmw)**2
30661  DO 110 i=mmin1,mmax1
30662  IF(i.EQ.0.OR.kfac(1,i).EQ.0) goto 110
30663  ia=iabs(i)
30664  DO 100 j=mmin2,mmax2
30665  IF(j.EQ.0.OR.kfac(2,j).EQ.0) goto 100
30666  ja=iabs(j)
30667 C...Electroweak couplings
30668  ei=kchg(ia,1)*isign(1,i)/3d0
30669  ai=sign(1d0,kchg(ia,1)+0.5d0)*isign(1,i)
30670  vi=ai-4d0*ei*xwv
30671  ej=kchg(ja,1)*isign(1,j)/3d0
30672  aj=sign(1d0,kchg(ja,1)+0.5d0)*isign(1,j)
30673  vj=aj-4d0*ej*xwv
30674  epsij=isign(1,i*j)
30675 C...gamma/Z exchange, only gamma exchange, or only Z exchange
30676  IF(mstp(21).GE.1.AND.mstp(21).LE.4) THEN
30677  IF(mstp(21).EQ.1.OR.mstp(21).EQ.4) THEN
30678  facncf=facggf*ei**2*ej**2+facgzf*ei*ej*
30679  & (vi*vj*(1d0+uh2/sh2)+ai*aj*epsij*(1d0-uh2/sh2))+
30680  & faczzf*((vi**2+ai**2)*(vj**2+aj**2)*(1d0+uh2/sh2)+
30681  & 4d0*vi*vj*ai*aj*epsij*(1d0-uh2/sh2))
30682  ELSEIF(mstp(21).EQ.2) THEN
30683  facncf=facggf*ei**2*ej**2
30684  ELSE
30685  facncf=faczzf*((vi**2+ai**2)*(vj**2+aj**2)*
30686  & (1d0+uh2/sh2)+4d0*vi*vj*ai*aj*epsij*(1d0-uh2/sh2))
30687  ENDIF
30688 C...Extrafactor 2 for only one incoming neutrino spin state.
30689  IF(ia.GT.10.AND.mod(ia,2).EQ.0) facncf=2d0*facncf
30690  IF(ja.GT.10.AND.mod(ja,2).EQ.0) facncf=2d0*facncf
30691  nchn=nchn+1
30692  isig(nchn,1)=i
30693  isig(nchn,2)=j
30694  isig(nchn,3)=1
30695  sigh(nchn)=facncf
30696  ENDIF
30697 C...W exchange
30698  IF((mstp(21).EQ.1.OR.mstp(21).EQ.5).AND.ai*aj.LT.0d0) THEN
30699  facccf=facwwf*vint(180+i)*vint(180+j)
30700  IF(epsij.LT.0d0) facccf=facccf*uh2/sh2
30701  IF(ia.GT.10.AND.mod(ia,2).EQ.0) facccf=2d0*facccf
30702  IF(ja.GT.10.AND.mod(ja,2).EQ.0) facccf=2d0*facccf
30703  nchn=nchn+1
30704  isig(nchn,1)=i
30705  isig(nchn,2)=j
30706  isig(nchn,3)=2
30707  sigh(nchn)=facccf
30708  ENDIF
30709  100 CONTINUE
30710  110 CONTINUE
30711 
30712  ELSEIF(isub.EQ.11) THEN
30713 C...f + f' -> f + f' (g exchange)
30714  facqq1=comfac*as**2*4d0/9d0*(sh2+uh2)/th2
30715  facqqb=comfac*as**2*4d0/9d0*((sh2+uh2)/th2*faca-
30716  & mstp(34)*2d0/3d0*uh2/(sh*th))
30717  facqq2=comfac*as**2*4d0/9d0*((sh2+th2)/uh2-
30718  & mstp(34)*2d0/3d0*sh2/(th*uh))
30719  DO 130 i=mmin1,mmax1
30720  ia=iabs(i)
30721  IF(i.EQ.0.OR.ia.GT.mstp(58).OR.kfac(1,i).EQ.0) goto 130
30722  DO 120 j=mmin2,mmax2
30723  ja=iabs(j)
30724  IF(j.EQ.0.OR.ja.GT.mstp(58).OR.kfac(2,j).EQ.0) goto 120
30725  nchn=nchn+1
30726  isig(nchn,1)=i
30727  isig(nchn,2)=j
30728  isig(nchn,3)=1
30729  sigh(nchn)=facqq1
30730  IF(i.EQ.-j) sigh(nchn)=facqqb
30731  IF(i.EQ.j) THEN
30732  sigh(nchn)=0.5d0*sigh(nchn)
30733  nchn=nchn+1
30734  isig(nchn,1)=i
30735  isig(nchn,2)=j
30736  isig(nchn,3)=2
30737  sigh(nchn)=0.5d0*facqq2
30738  ENDIF
30739  120 CONTINUE
30740  130 CONTINUE
30741 
30742  ELSEIF(isub.EQ.12) THEN
30743 C...f + fbar -> f' + fbar' (q + qbar -> q' + qbar' only)
30744  CALL pywidt(21,sh,wdtp,wdte)
30745  facqqb=comfac*as**2*4d0/9d0*(th2+uh2)/sh2*
30746  & (wdte(0,1)+wdte(0,2)+wdte(0,4))
30747  DO 140 i=mmina,mmaxa
30748  IF(i.EQ.0.OR.iabs(i).GT.mstp(58).OR.
30749  & kfac(1,i)*kfac(2,-i).EQ.0) goto 140
30750  nchn=nchn+1
30751  isig(nchn,1)=i
30752  isig(nchn,2)=-i
30753  isig(nchn,3)=1
30754  sigh(nchn)=facqqb
30755  140 CONTINUE
30756 
30757  ELSEIF(isub.EQ.13) THEN
30758 C...f + fbar -> g + g (q + qbar -> g + g only)
30759  facgg1=comfac*as**2*32d0/27d0*(uh/th-(2d0+mstp(34)*1d0/4d0)*
30760  & uh2/sh2)
30761  facgg2=comfac*as**2*32d0/27d0*(th/uh-(2d0+mstp(34)*1d0/4d0)*
30762  & th2/sh2)
30763  DO 150 i=mmina,mmaxa
30764  IF(i.EQ.0.OR.iabs(i).GT.mstp(58).OR.
30765  & kfac(1,i)*kfac(2,-i).EQ.0) goto 150
30766  nchn=nchn+1
30767  isig(nchn,1)=i
30768  isig(nchn,2)=-i
30769  isig(nchn,3)=1
30770  sigh(nchn)=0.5d0*facgg1
30771  nchn=nchn+1
30772  isig(nchn,1)=i
30773  isig(nchn,2)=-i
30774  isig(nchn,3)=2
30775  sigh(nchn)=0.5d0*facgg2
30776  150 CONTINUE
30777 
30778  ELSEIF(isub.EQ.14) THEN
30779 C...f + fbar -> g + gamma (q + qbar -> g + gamma only)
30780  facgg=comfac*as*aem*8d0/9d0*(th2+uh2)/(th*uh)
30781  DO 160 i=mmina,mmaxa
30782  IF(i.EQ.0.OR.iabs(i).GT.mstp(58).OR.
30783  & kfac(1,i)*kfac(2,-i).EQ.0) goto 160
30784  ei=kchg(iabs(i),1)/3d0
30785  nchn=nchn+1
30786  isig(nchn,1)=i
30787  isig(nchn,2)=-i
30788  isig(nchn,3)=1
30789  sigh(nchn)=facgg*ei**2
30790  160 CONTINUE
30791 
30792  ELSEIF(isub.EQ.18) THEN
30793 C...f + fbar -> gamma + gamma
30794  facgg=comfac*aem**2*2d0*(th2+uh2)/(th*uh)
30795  DO 170 i=mmina,mmaxa
30796  IF(i.EQ.0.OR.kfac(1,i)*kfac(2,-i).EQ.0) goto 170
30797  ei=kchg(iabs(i),1)/3d0
30798  fcoi=1d0
30799  IF(iabs(i).LE.10) fcoi=faca/3d0
30800  nchn=nchn+1
30801  isig(nchn,1)=i
30802  isig(nchn,2)=-i
30803  isig(nchn,3)=1
30804  sigh(nchn)=0.5d0*facgg*fcoi*ei**4
30805  170 CONTINUE
30806  ENDIF
30807 
30808  ELSEIF(isub.LE.40) THEN
30809  IF(isub.EQ.28) THEN
30810 C...f + g -> f + g (q + g -> q + g only)
30811  facqg1=comfac*as**2*4d0/9d0*((2d0+mstp(34)*1d0/4d0)*uh2/th2-
30812  & uh/sh)*faca
30813  facqg2=comfac*as**2*4d0/9d0*((2d0+mstp(34)*1d0/4d0)*sh2/th2-
30814  & sh/uh)
30815  DO 190 i=mmina,mmaxa
30816  IF(i.EQ.0.OR.iabs(i).GT.10) goto 190
30817  DO 180 isde=1,2
30818  IF(isde.EQ.1.AND.kfac(1,i)*kfac(2,21).EQ.0) goto 180
30819  IF(isde.EQ.2.AND.kfac(1,21)*kfac(2,i).EQ.0) goto 180
30820  nchn=nchn+1
30821  isig(nchn,isde)=i
30822  isig(nchn,3-isde)=21
30823  isig(nchn,3)=1
30824  sigh(nchn)=facqg1
30825  nchn=nchn+1
30826  isig(nchn,isde)=i
30827  isig(nchn,3-isde)=21
30828  isig(nchn,3)=2
30829  sigh(nchn)=facqg2
30830  180 CONTINUE
30831  190 CONTINUE
30832 
30833  ELSEIF(isub.EQ.29) THEN
30834 C...f + g -> f + gamma (q + g -> q + gamma only)
30835  fgq=comfac*faca*as*aem*1d0/3d0*(sh2+uh2)/(-sh*uh)
30836  DO 210 i=mmina,mmaxa
30837  IF(i.EQ.0.OR.iabs(i).GT.mstp(58)) goto 210
30838  ei=kchg(iabs(i),1)/3d0
30839  facgq=fgq*ei**2
30840  DO 200 isde=1,2
30841  IF(isde.EQ.1.AND.kfac(1,i)*kfac(2,21).EQ.0) goto 200
30842  IF(isde.EQ.2.AND.kfac(1,21)*kfac(2,i).EQ.0) goto 200
30843  nchn=nchn+1
30844  isig(nchn,isde)=i
30845  isig(nchn,3-isde)=21
30846  isig(nchn,3)=1
30847  sigh(nchn)=facgq
30848  200 CONTINUE
30849  210 CONTINUE
30850 
30851  ELSEIF(isub.EQ.33) THEN
30852 C...f + gamma -> f + g (q + gamma -> q + g only)
30853  fgq=comfac*as*aem*8d0/3d0*(sh2+uh2)/(-sh*uh)
30854  DO 230 i=mmina,mmaxa
30855  IF(i.EQ.0.OR.iabs(i).GT.mstp(58)) goto 230
30856  ei=kchg(iabs(i),1)/3d0
30857  facgq=fgq*ei**2
30858  DO 220 isde=1,2
30859  IF(isde.EQ.1.AND.kfac(1,i)*kfac(2,22).EQ.0) goto 220
30860  IF(isde.EQ.2.AND.kfac(1,22)*kfac(2,i).EQ.0) goto 220
30861  nchn=nchn+1
30862  isig(nchn,isde)=i
30863  isig(nchn,3-isde)=22
30864  isig(nchn,3)=1
30865  sigh(nchn)=facgq
30866  220 CONTINUE
30867  230 CONTINUE
30868 
30869  ELSEIF(isub.EQ.34) THEN
30870 C...f + gamma -> f + gamma
30871  fgq=comfac*aem**2*2d0*(sh2+uh2)/(-sh*uh)
30872  DO 250 i=mmina,mmaxa
30873  IF(i.EQ.0) goto 250
30874  ei=kchg(iabs(i),1)/3d0
30875  facgq=fgq*ei**4
30876  DO 240 isde=1,2
30877  IF(isde.EQ.1.AND.kfac(1,i)*kfac(2,22).EQ.0) goto 240
30878  IF(isde.EQ.2.AND.kfac(1,22)*kfac(2,i).EQ.0) goto 240
30879  nchn=nchn+1
30880  isig(nchn,isde)=i
30881  isig(nchn,3-isde)=22
30882  isig(nchn,3)=1
30883  sigh(nchn)=facgq
30884  240 CONTINUE
30885  250 CONTINUE
30886  ENDIF
30887 
30888  ELSEIF(isub.LE.80) THEN
30889  IF(isub.EQ.53) THEN
30890 C...g + g -> f + fbar (g + g -> q + qbar only)
30891  IF(kfac(1,21)*kfac(2,21).EQ.0) goto 270
30892  idc0=mdcy(21,2)-1
30893 C...Begin by d, u, s flavours.
30894  flavwt=0d0
30895  IF(mdme(idc0+1,1).GE.1) flavwt=flavwt+
30896  & sqrt(max(0d0,1d0-4d0*pmas(1,1)**2/sh))
30897  IF(mdme(idc0+2,1).GE.1) flavwt=flavwt+
30898  & sqrt(max(0d0,1d0-4d0*pmas(2,1)**2/sh))
30899  IF(mdme(idc0+3,1).GE.1) flavwt=flavwt+
30900  & sqrt(max(0d0,1d0-4d0*pmas(3,1)**2/sh))
30901  facqq1=comfac*as**2*1d0/6d0*(uh/th-(2d0+mstp(34)*1d0/4d0)*
30902  & uh2/sh2)*flavwt*faca
30903  facqq2=comfac*as**2*1d0/6d0*(th/uh-(2d0+mstp(34)*1d0/4d0)*
30904  & th2/sh2)*flavwt*faca
30905  nchn=nchn+1
30906  isig(nchn,1)=21
30907  isig(nchn,2)=21
30908  isig(nchn,3)=1
30909  sigh(nchn)=facqq1
30910  nchn=nchn+1
30911  isig(nchn,1)=21
30912  isig(nchn,2)=21
30913  isig(nchn,3)=2
30914  sigh(nchn)=facqq2
30915 C...Next c and b flavours: modified that and uhat for fixed
30916 C...cos(theta-hat).
30917  DO 260 ifl=4,5
30918  sqmavg=pmas(ifl,1)**2
30919  IF(mdme(idc0+ifl,1).GE.1.AND.sh.GT.4.04d0*sqmavg) THEN
30920  be34=sqrt(1d0-4d0*sqmavg/sh)
30921  thq=-0.5d0*sh*(1d0-be34*cth)
30922  uhq=-0.5d0*sh*(1d0+be34*cth)
30923  thuhq=thq*uhq-sqmavg*sh
30924  IF(mstp(34).EQ.0) THEN
30925  facqq1=uhq/thq-2d0*uhq**2/sh2+4d0*(sqmavg/sh)*thuhq/thq**2
30926  facqq2=thq/uhq-2d0*thq**2/sh2+4d0*(sqmavg/sh)*thuhq/uhq**2
30927  ELSE
30928  facqq1=uhq/thq-2.25d0*uhq**2/sh2+4.5d0*(sqmavg/sh)*thuhq/
30929  & thq**2+0.5d0*sqmavg*(thq+sqmavg)/thq**2-sqmavg**2/(sh*thq)
30930  facqq2=thq/uhq-2.25d0*thq**2/sh2+4.5d0*(sqmavg/sh)*thuhq/
30931  & uhq**2+0.5d0*sqmavg*(uhq+sqmavg)/uhq**2-sqmavg**2/(sh*uhq)
30932  ENDIF
30933  facqq1=comfac*faca*as**2*(1d0/6d0)*facqq1*be34
30934  facqq2=comfac*faca*as**2*(1d0/6d0)*facqq2*be34
30935  nchn=nchn+1
30936  isig(nchn,1)=21
30937  isig(nchn,2)=21
30938  isig(nchn,3)=1+2*(ifl-3)
30939  sigh(nchn)=facqq1
30940  nchn=nchn+1
30941  isig(nchn,1)=21
30942  isig(nchn,2)=21
30943  isig(nchn,3)=2+2*(ifl-3)
30944  sigh(nchn)=facqq2
30945  ENDIF
30946  260 CONTINUE
30947  270 CONTINUE
30948 
30949  ELSEIF(isub.EQ.54) THEN
30950 C...g + gamma -> f + fbar (g + gamma -> q + qbar only)
30951  CALL pywidt(21,sh,wdtp,wdte)
30952  wdtesu=0d0
30953  DO 280 i=1,min(8,mdcy(21,3))
30954  ef=kchg(i,1)/3d0
30955  wdtesu=wdtesu+ef**2*(wdte(i,1)+wdte(i,2)+wdte(i,3)+
30956  & wdte(i,4))
30957  280 CONTINUE
30958  facqq=comfac*aem*as*wdtesu*(th2+uh2)/(th*uh)
30959  IF(kfac(1,21)*kfac(2,22).NE.0) THEN
30960  nchn=nchn+1
30961  isig(nchn,1)=21
30962  isig(nchn,2)=22
30963  isig(nchn,3)=1
30964  sigh(nchn)=facqq
30965  ENDIF
30966  IF(kfac(1,22)*kfac(2,21).NE.0) THEN
30967  nchn=nchn+1
30968  isig(nchn,1)=22
30969  isig(nchn,2)=21
30970  isig(nchn,3)=1
30971  sigh(nchn)=facqq
30972  ENDIF
30973 
30974  ELSEIF(isub.EQ.58) THEN
30975 C...gamma + gamma -> f + fbar
30976  CALL pywidt(22,sh,wdtp,wdte)
30977  wdtesu=0d0
30978  DO 290 i=1,min(12,mdcy(22,3))
30979  IF(i.LE.8) ef= kchg(i,1)/3d0
30980  IF(i.GE.9) ef= kchg(9+2*(i-8),1)/3d0
30981  wdtesu=wdtesu+ef**2*(wdte(i,1)+wdte(i,2)+wdte(i,3)+
30982  & wdte(i,4))
30983  290 CONTINUE
30984  facff=comfac*aem**2*wdtesu*2d0*(th2+uh2)/(th*uh)
30985  IF(kfac(1,22)*kfac(2,22).NE.0) THEN
30986  nchn=nchn+1
30987  isig(nchn,1)=22
30988  isig(nchn,2)=22
30989  isig(nchn,3)=1
30990  sigh(nchn)=facff
30991  ENDIF
30992 
30993  ELSEIF(isub.EQ.68) THEN
30994 C...g + g -> g + g
30995  IF(kfac(1,21)*kfac(2,21).EQ.0) goto 300
30996  facgg1=comfac*as**2*9d0/4d0*(sh2/th2+2d0*sh/th+3d0+2d0*th/sh+
30997  & th2/sh2)*faca
30998  facgg2=comfac*as**2*9d0/4d0*(uh2/sh2+2d0*uh/sh+3d0+2d0*sh/uh+
30999  & sh2/uh2)*faca
31000  facgg3=comfac*as**2*9d0/4d0*(th2/uh2+2d0*th/uh+3d0+2d0*uh/th+
31001  & uh2/th2)
31002  nchn=nchn+1
31003  isig(nchn,1)=21
31004  isig(nchn,2)=21
31005  isig(nchn,3)=1
31006  sigh(nchn)=0.5d0*facgg1
31007  nchn=nchn+1
31008  isig(nchn,1)=21
31009  isig(nchn,2)=21
31010  isig(nchn,3)=2
31011  sigh(nchn)=0.5d0*facgg2
31012  nchn=nchn+1
31013  isig(nchn,1)=21
31014  isig(nchn,2)=21
31015  isig(nchn,3)=3
31016  sigh(nchn)=0.5d0*facgg3
31017  300 CONTINUE
31018 
31019  ELSEIF(isub.EQ.80) THEN
31020 C...q + gamma -> q' + pi+/-
31021  fqpi=comfac*(2d0*aem/9d0)*(-sh/th)*(1d0/sh2+1d0/th2)
31022  assh=pyalps(max(0.5d0,0.5d0*sh))
31023  q2fpsh=0.55d0/log(max(2d0,2d0*sh))
31024  delsh=uh*sqrt(assh*q2fpsh)
31025  asuh=pyalps(max(0.5d0,-0.5d0*uh))
31026  q2fpuh=0.55d0/log(max(2d0,-2d0*uh))
31027  deluh=sh*sqrt(asuh*q2fpuh)
31028  DO 320 i=max(-2,mmina),min(2,mmaxa)
31029  IF(i.EQ.0) goto 320
31030  ei=kchg(iabs(i),1)/3d0
31031  ej=sign(1d0-abs(ei),ei)
31032  DO 310 isde=1,2
31033  IF(isde.EQ.1.AND.kfac(1,i)*kfac(2,22).EQ.0) goto 310
31034  IF(isde.EQ.2.AND.kfac(1,22)*kfac(2,i).EQ.0) goto 310
31035  nchn=nchn+1
31036  isig(nchn,isde)=i
31037  isig(nchn,3-isde)=22
31038  isig(nchn,3)=1
31039  sigh(nchn)=fqpi*(ei*delsh+ej*deluh)**2
31040  310 CONTINUE
31041  320 CONTINUE
31042  ENDIF
31043 
31044  ELSEIF(isub.LE.100) THEN
31045  IF(isub.EQ.91) THEN
31046 C...Elastic scattering
31047  sigs=vint(315)*vint(316)*sigt(0,0,1)
31048 
31049  ELSEIF(isub.EQ.92) THEN
31050 C...Single diffractive scattering (first side, i.e. XB)
31051  sigs=vint(315)*vint(316)*sigt(0,0,2)
31052 
31053  ELSEIF(isub.EQ.93) THEN
31054 C...Single diffractive scattering (second side, i.e. AX)
31055  sigs=vint(315)*vint(316)*sigt(0,0,3)
31056 
31057  ELSEIF(isub.EQ.94) THEN
31058 C...Double diffractive scattering
31059  sigs=vint(315)*vint(316)*sigt(0,0,4)
31060 
31061  ELSEIF(isub.EQ.95) THEN
31062 C...Low-pT scattering
31063  sigs=vint(315)*vint(316)*sigt(0,0,5)
31064 
31065  ELSEIF(isub.EQ.96) THEN
31066 C...Multiple interactions: sum of QCD processes
31067  CALL pywidt(21,sh,wdtp,wdte)
31068 
31069 C...q + q' -> q + q'
31070  facqq1=comfac*as**2*4d0/9d0*(sh2+uh2)/th2
31071  facqqb=comfac*as**2*4d0/9d0*((sh2+uh2)/th2*faca-
31072  & mstp(34)*2d0/3d0*uh2/(sh*th))
31073  facqq2=comfac*as**2*4d0/9d0*(sh2+th2)/uh2
31074  facqqi=-comfac*as**2*4d0/9d0*mstp(34)*2d0/3d0*sh2/(th*uh)
31075  ratqqi=(facqq1+facqq2+facqqi)/(facqq1+facqq2)
31076  DO 340 i=-5,5
31077  IF(i.EQ.0) goto 340
31078  DO 330 j=-5,5
31079  IF(j.EQ.0) goto 330
31080  nchn=nchn+1
31081  isig(nchn,1)=i
31082  isig(nchn,2)=j
31083  isig(nchn,3)=111
31084  sigh(nchn)=facqq1
31085  IF(i.EQ.-j) sigh(nchn)=facqqb
31086  IF(i.EQ.j) THEN
31087  sigh(nchn)=0.5d0*facqq1*ratqqi
31088  nchn=nchn+1
31089  isig(nchn,1)=i
31090  isig(nchn,2)=j
31091  isig(nchn,3)=112
31092  sigh(nchn)=0.5d0*facqq2*ratqqi
31093  ENDIF
31094  330 CONTINUE
31095  340 CONTINUE
31096 
31097 C...q + qbar -> q' + qbar' or g + g
31098  facqqb=comfac*as**2*4d0/9d0*(th2+uh2)/sh2*
31099  & (wdte(0,1)+wdte(0,2)+wdte(0,3)+wdte(0,4))
31100  facgg1=comfac*as**2*32d0/27d0*(uh/th-(2d0+mstp(34)*1d0/4d0)*
31101  & uh2/sh2)
31102  facgg2=comfac*as**2*32d0/27d0*(th/uh-(2d0+mstp(34)*1d0/4d0)*
31103  & th2/sh2)
31104  DO 350 i=-5,5
31105  IF(i.EQ.0) goto 350
31106  nchn=nchn+1
31107  isig(nchn,1)=i
31108  isig(nchn,2)=-i
31109  isig(nchn,3)=121
31110  sigh(nchn)=facqqb
31111  nchn=nchn+1
31112  isig(nchn,1)=i
31113  isig(nchn,2)=-i
31114  isig(nchn,3)=131
31115  sigh(nchn)=0.5d0*facgg1
31116  nchn=nchn+1
31117  isig(nchn,1)=i
31118  isig(nchn,2)=-i
31119  isig(nchn,3)=132
31120  sigh(nchn)=0.5d0*facgg2
31121  350 CONTINUE
31122 
31123 C...q + g -> q + g
31124  facqg1=comfac*as**2*4d0/9d0*((2d0+mstp(34)*1d0/4d0)*uh2/th2-
31125  & uh/sh)*faca
31126  facqg2=comfac*as**2*4d0/9d0*((2d0+mstp(34)*1d0/4d0)*sh2/th2-
31127  & sh/uh)
31128  DO 370 i=-5,5
31129  IF(i.EQ.0) goto 370
31130  DO 360 isde=1,2
31131  nchn=nchn+1
31132  isig(nchn,isde)=i
31133  isig(nchn,3-isde)=21
31134  isig(nchn,3)=281
31135  sigh(nchn)=facqg1
31136  nchn=nchn+1
31137  isig(nchn,isde)=i
31138  isig(nchn,3-isde)=21
31139  isig(nchn,3)=282
31140  sigh(nchn)=facqg2
31141  360 CONTINUE
31142  370 CONTINUE
31143 
31144 C...g + g -> q + qbar (only d, u, s)
31145  idc0=mdcy(21,2)-1
31146  flavwt=0d0
31147  IF(mdme(idc0+1,1).GE.1) flavwt=flavwt+
31148  & sqrt(max(0d0,1d0-4d0*pmas(1,1)**2/sh))
31149  IF(mdme(idc0+2,1).GE.1) flavwt=flavwt+
31150  & sqrt(max(0d0,1d0-4d0*pmas(2,1)**2/sh))
31151  IF(mdme(idc0+3,1).GE.1) flavwt=flavwt+
31152  & sqrt(max(0d0,1d0-4d0*pmas(3,1)**2/sh))
31153  facqq1=comfac*as**2*1d0/6d0*(uh/th-(2d0+mstp(34)*1d0/4d0)*
31154  & uh2/sh2)*flavwt*faca
31155  facqq2=comfac*as**2*1d0/6d0*(th/uh-(2d0+mstp(34)*1d0/4d0)*
31156  & th2/sh2)*flavwt*faca
31157  nchn=nchn+1
31158  isig(nchn,1)=21
31159  isig(nchn,2)=21
31160  isig(nchn,3)=531
31161  sigh(nchn)=facqq1
31162  nchn=nchn+1
31163  isig(nchn,1)=21
31164  isig(nchn,2)=21
31165  isig(nchn,3)=532
31166  sigh(nchn)=facqq2
31167 
31168 C...g + g -> c + cbar, b + bbar: modified that/uhat for fixed
31169 C...cos(theta-hat)
31170  DO 380 ifl=4,5
31171  sqmavg=pmas(ifl,1)**2
31172  IF(mdme(idc0+ifl,1).GE.1.AND.sh.GT.4.04d0*sqmavg) THEN
31173  be34=sqrt(1d0-4d0*sqmavg/sh)
31174  thq=-0.5d0*sh*(1d0-be34*cth)
31175  uhq=-0.5d0*sh*(1d0+be34*cth)
31176  thuhq=thq*uhq-sqmavg*sh
31177  IF(mstp(34).EQ.0) THEN
31178  facqq1=uhq/thq-2d0*uhq**2/sh2+4d0*(sqmavg/sh)*thuhq/thq**2
31179  facqq2=thq/uhq-2d0*thq**2/sh2+4d0*(sqmavg/sh)*thuhq/uhq**2
31180  ELSE
31181  facqq1=uhq/thq-2.25d0*uhq**2/sh2+4.5d0*(sqmavg/sh)*thuhq/
31182  & thq**2+0.5d0*sqmavg*(thq+sqmavg)/thq**2-sqmavg**2/(sh*thq)
31183  facqq2=thq/uhq-2.25d0*thq**2/sh2+4.5d0*(sqmavg/sh)*thuhq/
31184  & uhq**2+0.5d0*sqmavg*(uhq+sqmavg)/uhq**2-sqmavg**2/(sh*uhq)
31185  ENDIF
31186  facqq1=comfac*faca*as**2*(1d0/6d0)*facqq1*be34
31187  facqq2=comfac*faca*as**2*(1d0/6d0)*facqq2*be34
31188  nchn=nchn+1
31189  isig(nchn,1)=21
31190  isig(nchn,2)=21
31191  isig(nchn,3)=531+2*(ifl-3)
31192  sigh(nchn)=facqq1
31193  nchn=nchn+1
31194  isig(nchn,1)=21
31195  isig(nchn,2)=21
31196  isig(nchn,3)=532+2*(ifl-3)
31197  sigh(nchn)=facqq2
31198  ENDIF
31199  380 CONTINUE
31200 
31201 C...g + g -> g + g
31202  facgg1=comfac*as**2*9d0/4d0*(sh2/th2+2d0*sh/th+3d0+
31203  & 2d0*th/sh+th2/sh2)*faca
31204  facgg2=comfac*as**2*9d0/4d0*(uh2/sh2+2d0*uh/sh+3d0+
31205  & 2d0*sh/uh+sh2/uh2)*faca
31206  facgg3=comfac*as**2*9d0/4d0*(th2/uh2+2d0*th/uh+3+
31207  & 2d0*uh/th+uh2/th2)
31208  nchn=nchn+1
31209  isig(nchn,1)=21
31210  isig(nchn,2)=21
31211  isig(nchn,3)=681
31212  sigh(nchn)=0.5d0*facgg1
31213  nchn=nchn+1
31214  isig(nchn,1)=21
31215  isig(nchn,2)=21
31216  isig(nchn,3)=682
31217  sigh(nchn)=0.5d0*facgg2
31218  nchn=nchn+1
31219  isig(nchn,1)=21
31220  isig(nchn,2)=21
31221  isig(nchn,3)=683
31222  sigh(nchn)=0.5d0*facgg3
31223 
31224  ELSEIF(isub.EQ.99) THEN
31225 C...f + gamma* -> f.
31226  IF(mint(107).EQ.4) THEN
31227  q2ga=vint(307)
31228  p2ga=vint(308)
31229  isde=2
31230  ELSE
31231  q2ga=vint(308)
31232  p2ga=vint(307)
31233  isde=1
31234  ENDIF
31235  comfac=paru(5)*4d0*paru(1)**2*paru(101)*vint(315)*vint(316)
31236  pm2rho=pmas(pycomp(113),1)**2
31237  IF(mstp(19).EQ.0) THEN
31238  comfac=comfac/q2ga
31239  ELSEIF(mstp(19).EQ.1) THEN
31240  comfac=comfac/(q2ga+pm2rho)
31241  ELSEIF(mstp(19).EQ.2) THEN
31242  comfac=comfac*q2ga/(q2ga+pm2rho)**2
31243  ELSE
31244  comfac=comfac*q2ga/(q2ga+pm2rho)**2
31245  w2ga=vint(2)
31246  IF(mint(11).EQ.22.AND.mint(12).EQ.22) THEN
31247  rdrds=4.1d-3*w2ga**2.167d0/((q2ga+0.15d0*w2ga)**2*
31248  & q2ga**0.75d0)*(1d0+0.11d0*q2ga*p2ga/(1d0+0.02d0*p2ga**2))
31249  xga=q2ga/(w2ga+vint(307)+vint(308))
31250  ELSE
31251  rdrds=1.5d-4*w2ga**2.167d0/((q2ga+0.041d0*w2ga)**2*
31252  & q2ga**0.57d0)
31253  xga=q2ga/(w2ga+q2ga-pmas(pycomp(mint(10+isde)),1)**2)
31254  ENDIF
31255  comfac=comfac*exp(-max(1d-10,rdrds))
31256  IF(mstp(19).EQ.4) comfac=comfac/max(1d-2,1d0-xga)
31257  ENDIF
31258  DO 390 i=mmina,mmaxa
31259  IF(i.EQ.0.OR.kfac(isde,i).EQ.0) goto 390
31260  IF(iabs(i).LT.10.AND.iabs(i).GT.mstp(58)) goto 390
31261  ei=kchg(iabs(i),1)/3d0
31262  nchn=nchn+1
31263  isig(nchn,isde)=i
31264  isig(nchn,3-isde)=22
31265  isig(nchn,3)=1
31266  sigh(nchn)=comfac*ei**2
31267  390 CONTINUE
31268  ENDIF
31269 
31270  ELSE
31271  IF(isub.EQ.114.OR.isub.EQ.115) THEN
31272 C...g + g -> gamma + gamma or g + g -> g + gamma
31273  a0stur=0d0
31274  a0stui=0d0
31275  a0tsur=0d0
31276  a0tsui=0d0
31277  a0utsr=0d0
31278  a0utsi=0d0
31279  a1stur=0d0
31280  a1stui=0d0
31281  a2stur=0d0
31282  a2stui=0d0
31283  alst=log(-sh/th)
31284  alsu=log(-sh/uh)
31285  altu=log(th/uh)
31286  imax=2*mstp(1)
31287  IF(mstp(38).GE.1.AND.mstp(38).LE.8) imax=mstp(38)
31288  DO 400 i=1,imax
31289  ei=kchg(iabs(i),1)/3d0
31290  eiwt=ei**2
31291  IF(isub.EQ.115) eiwt=ei
31292  sqmq=pmas(i,1)**2
31293  epss=4d0*sqmq/sh
31294  epst=4d0*sqmq/th
31295  epsu=4d0*sqmq/uh
31296  IF((mstp(38).GE.1.AND.mstp(38).LE.8).OR.epss.LT.1d-4) THEN
31297  b0stur=1d0+(th-uh)/sh*altu+0.5d0*(th2+uh2)/sh2*(altu**2+
31298  & paru(1)**2)
31299  b0stui=0d0
31300  b0tsur=1d0+(sh-uh)/th*alsu+0.5d0*(sh2+uh2)/th2*alsu**2
31301  b0tsui=-paru(1)*((sh-uh)/th+(sh2+uh2)/th2*alsu)
31302  b0utsr=1d0+(sh-th)/uh*alst+0.5d0*(sh2+th2)/uh2*alst**2
31303  b0utsi=-paru(1)*((sh-th)/uh+(sh2+th2)/uh2*alst)
31304  b1stur=-1d0
31305  b1stui=0d0
31306  b2stur=-1d0
31307  b2stui=0d0
31308  ELSE
31309  CALL pywaux(1,epss,w1sr,w1si)
31310  CALL pywaux(1,epst,w1tr,w1ti)
31311  CALL pywaux(1,epsu,w1ur,w1ui)
31312  CALL pywaux(2,epss,w2sr,w2si)
31313  CALL pywaux(2,epst,w2tr,w2ti)
31314  CALL pywaux(2,epsu,w2ur,w2ui)
31315  CALL pyi3au(epss,th/uh,y3stur,y3stui)
31316  CALL pyi3au(epss,uh/th,y3sutr,y3suti)
31317  CALL pyi3au(epst,sh/uh,y3tsur,y3tsui)
31318  CALL pyi3au(epst,uh/sh,y3tusr,y3tusi)
31319  CALL pyi3au(epsu,sh/th,y3ustr,y3usti)
31320  CALL pyi3au(epsu,th/sh,y3utsr,y3utsi)
31321  b0stur=1d0+(1d0+2d0*th/sh)*w1tr+(1d0+2d0*uh/sh)*w1ur+
31322  & 0.5d0*((th2+uh2)/sh2-epss)*(w2tr+w2ur)-
31323  & 0.25d0*epst*(1d0-0.5d0*epss)*(y3sutr+y3tusr)-
31324  & 0.25d0*epsu*(1d0-0.5d0*epss)*(y3stur+y3utsr)+
31325  & 0.25d0*(-2d0*(th2+uh2)/sh2+4d0*epss+epst+epsu+
31326  & 0.5d0*epst*epsu)*(y3tsur+y3ustr)
31327  b0stui=(1d0+2d0*th/sh)*w1ti+(1d0+2d0*uh/sh)*w1ui+
31328  & 0.5d0*((th2+uh2)/sh2-epss)*(w2ti+w2ui)-
31329  & 0.25d0*epst*(1d0-0.5d0*epss)*(y3suti+y3tusi)-
31330  & 0.25d0*epsu*(1d0-0.5d0*epss)*(y3stui+y3utsi)+
31331  & 0.25d0*(-2d0*(th2+uh2)/sh2+4d0*epss+epst+epsu+
31332  & 0.5d0*epst*epsu)*(y3tsui+y3usti)
31333  b0tsur=1d0+(1d0+2d0*sh/th)*w1sr+(1d0+2d0*uh/th)*w1ur+
31334  & 0.5d0*((sh2+uh2)/th2-epst)*(w2sr+w2ur)-
31335  & 0.25d0*epss*(1d0-0.5d0*epst)*(y3tusr+y3sutr)-
31336  & 0.25d0*epsu*(1d0-0.5d0*epst)*(y3tsur+y3ustr)+
31337  & 0.25d0*(-2d0*(sh2+uh2)/th2+4d0*epst+epss+epsu+
31338  & 0.5d0*epss*epsu)*(y3stur+y3utsr)
31339  b0tsui=(1d0+2d0*sh/th)*w1si+(1d0+2d0*uh/th)*w1ui+
31340  & 0.5d0*((sh2+uh2)/th2-epst)*(w2si+w2ui)-
31341  & 0.25d0*epss*(1d0-0.5d0*epst)*(y3tusi+y3suti)-
31342  & 0.25d0*epsu*(1d0-0.5d0*epst)*(y3tsui+y3usti)+
31343  & 0.25d0*(-2d0*(sh2+uh2)/th2+4d0*epst+epss+epsu+
31344  & 0.5d0*epss*epsu)*(y3stui+y3utsi)
31345  b0utsr=1d0+(1d0+2d0*th/uh)*w1tr+(1d0+2d0*sh/uh)*w1sr+
31346  & 0.5d0*((th2+sh2)/uh2-epsu)*(w2tr+w2sr)-
31347  & 0.25d0*epst*(1d0-0.5d0*epsu)*(y3ustr+y3tsur)-
31348  & 0.25d0*epss*(1d0-0.5d0*epsu)*(y3utsr+y3stur)+
31349  & 0.25d0*(-2d0*(th2+sh2)/uh2+4d0*epsu+epst+epss+
31350  & 0.5d0*epst*epss)*(y3tusr+y3sutr)
31351  b0utsi=(1d0+2d0*th/uh)*w1ti+(1d0+2d0*sh/uh)*w1si+
31352  & 0.5d0*((th2+sh2)/uh2-epsu)*(w2ti+w2si)-
31353  & 0.25d0*epst*(1d0-0.5d0*epsu)*(y3usti+y3tsui)-
31354  & 0.25d0*epss*(1d0-0.5d0*epsu)*(y3utsi+y3stui)+
31355  & 0.25d0*(-2d0*(th2+sh2)/uh2+4d0*epsu+epst+epss+
31356  & 0.5d0*epst*epss)*(y3tusi+y3suti)
31357  b1stur=-1d0-0.25d0*(epss+epst+epsu)*(w2sr+w2tr+w2ur)+
31358  & 0.25d0*(epsu+0.5d0*epss*epst)*(y3sutr+y3tusr)+
31359  & 0.25d0*(epst+0.5d0*epss*epsu)*(y3stur+y3utsr)+
31360  & 0.25d0*(epss+0.5d0*epst*epsu)*(y3tsur+y3ustr)
31361  b1stui=-0.25d0*(epss+epst+epsu)*(w2si+w2ti+w2ui)+
31362  & 0.25d0*(epsu+0.5d0*epss*epst)*(y3suti+y3tusi)+
31363  & 0.25d0*(epst+0.5d0*epss*epsu)*(y3stui+y3utsi)+
31364  & 0.25d0*(epss+0.5d0*epst*epsu)*(y3tsui+y3usti)
31365  b2stur=-1d0+0.125d0*epss*epst*(y3sutr+y3tusr)+
31366  & 0.125d0*epss*epsu*(y3stur+y3utsr)+
31367  & 0.125d0*epst*epsu*(y3tsur+y3ustr)
31368  b2stui=0.125d0*epss*epst*(y3suti+y3tusi)+
31369  & 0.125d0*epss*epsu*(y3stui+y3utsi)+
31370  & 0.125d0*epst*epsu*(y3tsui+y3usti)
31371  ENDIF
31372  a0stur=a0stur+eiwt*b0stur
31373  a0stui=a0stui+eiwt*b0stui
31374  a0tsur=a0tsur+eiwt*b0tsur
31375  a0tsui=a0tsui+eiwt*b0tsui
31376  a0utsr=a0utsr+eiwt*b0utsr
31377  a0utsi=a0utsi+eiwt*b0utsi
31378  a1stur=a1stur+eiwt*b1stur
31379  a1stui=a1stui+eiwt*b1stui
31380  a2stur=a2stur+eiwt*b2stur
31381  a2stui=a2stui+eiwt*b2stui
31382  400 CONTINUE
31383  asqsum=a0stur**2+a0stui**2+a0tsur**2+a0tsui**2+a0utsr**2+
31384  & a0utsi**2+4d0*a1stur**2+4d0*a1stui**2+a2stur**2+a2stui**2
31385  facgg=comfac*faca/(16d0*paru(1)**2)*as**2*aem**2*asqsum
31386  facgp=comfac*faca*5d0/(192d0*paru(1)**2)*as**3*aem*asqsum
31387  IF(kfac(1,21)*kfac(2,21).EQ.0) goto 410
31388  nchn=nchn+1
31389  isig(nchn,1)=21
31390  isig(nchn,2)=21
31391  isig(nchn,3)=1
31392  IF(isub.EQ.114) sigh(nchn)=0.5d0*facgg
31393  IF(isub.EQ.115) sigh(nchn)=facgp
31394  410 CONTINUE
31395 
31396  ELSEIF(isub.EQ.131.OR.isub.EQ.132) THEN
31397 C...f + gamma*_(T,L) -> f + g (q + gamma*_(T,L) -> q + g only)
31398  ph=0d0
31399  IF(mint(15).EQ.22.AND.mint(107).EQ.0.AND.vint(3).LT.0d0)
31400  & ph=vint(3)**2
31401  IF(mint(16).EQ.22.AND.mint(108).EQ.0.AND.vint(4).LT.0d0)
31402  & ph=vint(4)**2
31403  IF(isub.EQ.131) THEN
31404  fgq=comfac*as*aem*8d0/3d0*sh**2/(sh+ph)**2*
31405  & ((sh2+uh2-2d0*ph*th)/(-sh*uh)-2d0*ph*th/(sh+ph)**2)
31406  ELSE
31407  fgq=comfac*as*aem*8d0/3d0*sh**2/(sh+ph)**4*(-4d0*ph*th)
31408  ENDIF
31409  DO 430 i=mmina,mmaxa
31410  IF(i.EQ.0.OR.iabs(i).GT.mstp(58)) goto 430
31411  ei=kchg(iabs(i),1)/3d0
31412  facgq=fgq*ei**2
31413  DO 420 isde=1,2
31414  IF(isde.EQ.1.AND.kfac(1,i)*kfac(2,22).EQ.0) goto 420
31415  IF(isde.EQ.2.AND.kfac(1,22)*kfac(2,i).EQ.0) goto 420
31416  nchn=nchn+1
31417  isig(nchn,isde)=i
31418  isig(nchn,3-isde)=22
31419  isig(nchn,3)=1
31420  sigh(nchn)=facgq
31421  420 CONTINUE
31422  430 CONTINUE
31423 
31424  ELSEIF(isub.EQ.133.OR.isub.EQ.134) THEN
31425 C...f + gamma*_(T,L) -> f + gamma
31426  ph=0d0
31427  IF(mint(15).EQ.22.AND.mint(107).EQ.0.AND.vint(3).LT.0d0)
31428  & ph=vint(3)**2
31429  IF(mint(16).EQ.22.AND.mint(108).EQ.0.AND.vint(4).LT.0d0)
31430  & ph=vint(4)**2
31431  IF(isub.EQ.133) THEN
31432  fgq=comfac*aem**2*2d0*sh**2/(sh+ph)**2*
31433  & ((sh2+uh2-2d0*ph*th)/(-sh*uh)-2d0*ph*th/(sh+ph)**2)
31434  ELSE
31435  fgq=comfac*aem**2*2d0*sh**2/(sh+ph)**4*(-4d0*ph*th)
31436  ENDIF
31437  DO 450 i=mmina,mmaxa
31438  IF(i.EQ.0) goto 450
31439  ei=kchg(iabs(i),1)/3d0
31440  facgq=fgq*ei**4
31441  DO 440 isde=1,2
31442  IF(isde.EQ.1.AND.kfac(1,i)*kfac(2,22).EQ.0) goto 440
31443  IF(isde.EQ.2.AND.kfac(1,22)*kfac(2,i).EQ.0) goto 440
31444  nchn=nchn+1
31445  isig(nchn,isde)=i
31446  isig(nchn,3-isde)=22
31447  isig(nchn,3)=1
31448  sigh(nchn)=facgq
31449  440 CONTINUE
31450  450 CONTINUE
31451 
31452  ELSEIF(isub.EQ.135.OR.isub.EQ.136) THEN
31453 C...g + gamma*_(T,L) -> f + fbar (g + gamma*_(T,L) -> q + qbar only)
31454  ph=0d0
31455  IF(mint(15).EQ.22.AND.mint(107).EQ.0.AND.vint(3).LT.0d0)
31456  & ph=vint(3)**2
31457  IF(mint(16).EQ.22.AND.mint(108).EQ.0.AND.vint(4).LT.0d0)
31458  & ph=vint(4)**2
31459  CALL pywidt(21,sh,wdtp,wdte)
31460  wdtesu=0d0
31461  DO 460 i=1,min(8,mdcy(21,3))
31462  ef=kchg(i,1)/3d0
31463  wdtesu=wdtesu+ef**2*(wdte(i,1)+wdte(i,2)+wdte(i,3)+
31464  & wdte(i,4))
31465  460 CONTINUE
31466  IF(isub.EQ.135) THEN
31467  facqq=comfac*aem*as*wdtesu*sh**2/(sh+ph)**2*
31468  & ((th2+uh2-2d0*ph*sh)/(th*uh)+4d0*ph*sh/(sh+ph)**2)
31469  ELSE
31470  facqq=comfac*aem*as*wdtesu*sh**2/(sh+ph)**4*8d0*ph*sh
31471  ENDIF
31472  IF(kfac(1,21)*kfac(2,22).NE.0) THEN
31473  nchn=nchn+1
31474  isig(nchn,1)=21
31475  isig(nchn,2)=22
31476  isig(nchn,3)=1
31477  sigh(nchn)=facqq
31478  ENDIF
31479  IF(kfac(1,22)*kfac(2,21).NE.0) THEN
31480  nchn=nchn+1
31481  isig(nchn,1)=22
31482  isig(nchn,2)=21
31483  isig(nchn,3)=1
31484  sigh(nchn)=facqq
31485  ENDIF
31486 
31487  ELSEIF(isub.GE.137.AND.isub.LE.140) THEN
31488 C...gamma*_(T,L) + gamma*_(T,L) -> f + fbar
31489  ph1=0d0
31490  IF(vint(3).LT.0d0) ph1=vint(3)**2
31491  ph2=0d0
31492  IF(vint(4).LT.0d0) ph2=vint(4)**2
31493  CALL pywidt(22,sh,wdtp,wdte)
31494  wdtesu=0d0
31495  DO 470 i=1,min(12,mdcy(22,3))
31496  IF(i.LE.8) ef= kchg(i,1)/3d0
31497  IF(i.GE.9) ef= kchg(9+2*(i-8),1)/3d0
31498  wdtesu=wdtesu+ef**2*(wdte(i,1)+wdte(i,2)+wdte(i,3)+
31499  & wdte(i,4))
31500  470 CONTINUE
31501  dlamb2=(th+uh)**2-4d0*ph1*ph2
31502  IF(isub.EQ.137) THEN
31503  fparam=-sh*(th+uh)/dlamb2
31504  facff=comfac*aem**2*wdtesu*2d0*sh2/(dlamb2*th2*uh2)*
31505  & (th*uh-ph1*ph2)*((th2+uh2)*(1d0-2d0*fparam*(1d0-fparam))-
31506  & 2d0*ph1*ph2*fparam**2)
31507  ELSEIF(isub.EQ.138) THEN
31508  facff=comfac*aem**2*wdtesu*4d0*sh2*sh/(dlamb2**2*th2*uh2)*
31509  & ph2*(4d0*(th*uh-ph1*ph2)*(th*uh+ph1*sh*(th-uh)**2/dlamb2)+
31510  & 2d0*ph1**2*(th-uh)**2)
31511  ELSEIF(isub.EQ.139) THEN
31512  facff=comfac*aem**2*wdtesu*4d0*sh2*sh/(dlamb2**2*th2*uh2)*
31513  & ph1*(4d0*(th*uh-ph1*ph2)*(th*uh+ph2*sh*(th-uh)**2/dlamb2)+
31514  & 2d0*ph2**2*(th-uh)**2)
31515  ELSE
31516  facff=comfac*aem**2*wdtesu*32d0*sh2**2/(dlamb2**3*th2*uh2)*
31517  & ph1*ph2*(th*uh-ph1*ph2)*(th-uh)**2
31518  ENDIF
31519  IF(kfac(1,22)*kfac(2,22).NE.0) THEN
31520  nchn=nchn+1
31521  isig(nchn,1)=22
31522  isig(nchn,2)=22
31523  isig(nchn,3)=1
31524  sigh(nchn)=facff
31525  ENDIF
31526 
31527  ENDIF
31528  ENDIF
31529 
31530  RETURN
31531  END
31532 
31533 C*********************************************************************
31534 
31535 C...PYSGHF
31536 C...Subprocess cross sections for heavy flavour production,
31537 C...open and closed.
31538 C...Auxiliary to PYSIGH.
31539 
31540  SUBROUTINE pysghf(NCHN,SIGS)
31541 
31542 C...Double precision and integer declarations
31543  IMPLICIT DOUBLE PRECISION(a-h, o-z)
31544  IMPLICIT INTEGER(i-n)
31545  INTEGER pyk,pychge,pycomp
31546 C...Parameter statement to help give large particle numbers.
31547  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
31548  &kexcit=4000000,kdimen=5000000)
31549 C...Commonblocks
31550  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
31551  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
31552  common/pypars/mstp(200),parp(200),msti(200),pari(200)
31553  common/pyint1/mint(400),vint(400)
31554  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
31555  common/pyint3/xsfx(2,-40:40),isig(1000,3),sigh(1000)
31556  common/pyint4/mwid(500),wids(500,5)
31557  common/pysgcm/isub,isubsv,mmin1,mmax1,mmin2,mmax2,mmina,mmaxa,
31558  &kfac(2,-40:40),comfac,fack,faca,sh,th,uh,sh2,th2,uh2,sqm3,sqm4,
31559  &shr,sqpth,taup,be34,cth,x(2),sqmz,sqmw,gmmz,gmmw,
31560  &aem,as,xw,xw1,xwc,xwv,poll,polr,polll,polrr
31561  SAVE /pydat1/,/pydat2/,/pypars/,/pyint1/,/pyint2/,/pyint3/,
31562  &/pyint4/,/pysgcm/
31563 C...Local arrays
31564  dimension wdtp(0:400),wdte(0:400,0:5)
31565 
31566 C...Determine where are charmonium/bottomonium wave function parameters.
31567  ionium=140
31568  IF(isub.GE.461.AND.isub.LE.479) ionium=145
31569 
31570 C...Convert bottomonium process into equivalent charmonium ones.
31571  IF(isub.GE.461.AND.isub.LE.479) isub=isub-40
31572 
31573 C...Differential cross section expressions.
31574 
31575  IF(isub.LE.100) THEN
31576  IF(isub.EQ.81) THEN
31577 C...q + qbar -> Q + Qbar
31578  sqmavg=0.5d0*(sqm3+sqm4)-0.25d0*(sqm3-sqm4)**2/sh
31579  thq=-0.5d0*sh*(1d0-be34*cth)
31580  uhq=-0.5d0*sh*(1d0+be34*cth)
31581  facqqb=comfac*as**2*4d0/9d0*((thq**2+uhq**2)/sh2+
31582  & 2d0*sqmavg/sh)
31583  IF(mstp(35).GE.1) facqqb=facqqb*pyhfth(sh,sqmavg,0d0)
31584  wid2=1d0
31585  IF(mint(55).EQ.6) wid2=wids(6,1)
31586  IF(mint(55).EQ.7.OR.mint(55).EQ.8) wid2=wids(mint(55),1)
31587  facqqb=facqqb*wid2
31588  DO 100 i=mmina,mmaxa
31589  IF(i.EQ.0.OR.iabs(i).GT.mstp(58).OR.
31590  & kfac(1,i)*kfac(2,-i).EQ.0) goto 100
31591  nchn=nchn+1
31592  isig(nchn,1)=i
31593  isig(nchn,2)=-i
31594  isig(nchn,3)=1
31595  sigh(nchn)=facqqb
31596  100 CONTINUE
31597 
31598  ELSEIF(isub.EQ.82) THEN
31599 C...g + g -> Q + Qbar
31600  sqmavg=0.5d0*(sqm3+sqm4)-0.25d0*(sqm3-sqm4)**2/sh
31601  thq=-0.5d0*sh*(1d0-be34*cth)
31602  uhq=-0.5d0*sh*(1d0+be34*cth)
31603  thuhq=thq*uhq-sqmavg*sh
31604  IF(mstp(34).EQ.0) THEN
31605  facqq1=uhq/thq-2d0*uhq**2/sh2+4d0*(sqmavg/sh)*thuhq/thq**2
31606  facqq2=thq/uhq-2d0*thq**2/sh2+4d0*(sqmavg/sh)*thuhq/uhq**2
31607  ELSE
31608  facqq1=uhq/thq-2.25d0*uhq**2/sh2+4.5d0*(sqmavg/sh)*thuhq/
31609  & thq**2+0.5d0*sqmavg*(thq+sqmavg)/thq**2-sqmavg**2/(sh*thq)
31610  facqq2=thq/uhq-2.25d0*thq**2/sh2+4.5d0*(sqmavg/sh)*thuhq/
31611  & uhq**2+0.5d0*sqmavg*(uhq+sqmavg)/uhq**2-sqmavg**2/(sh*uhq)
31612  ENDIF
31613  facqq1=comfac*faca*as**2*(1d0/6d0)*facqq1
31614  facqq2=comfac*faca*as**2*(1d0/6d0)*facqq2
31615  IF(mstp(35).GE.1) THEN
31616  fatre=pyhfth(sh,sqmavg,2d0/7d0)
31617  facqq1=facqq1*fatre
31618  facqq2=facqq2*fatre
31619  ENDIF
31620  wid2=1d0
31621  IF(mint(55).EQ.6) wid2=wids(6,1)
31622  IF(mint(55).EQ.7.OR.mint(55).EQ.8) wid2=wids(mint(55),1)
31623  facqq1=facqq1*wid2
31624  facqq2=facqq2*wid2
31625  IF(kfac(1,21)*kfac(2,21).EQ.0) goto 110
31626  nchn=nchn+1
31627  isig(nchn,1)=21
31628  isig(nchn,2)=21
31629  isig(nchn,3)=1
31630  sigh(nchn)=facqq1
31631  nchn=nchn+1
31632  isig(nchn,1)=21
31633  isig(nchn,2)=21
31634  isig(nchn,3)=2
31635  sigh(nchn)=facqq2
31636  110 CONTINUE
31637 
31638  ELSEIF(isub.EQ.83) THEN
31639 C...f + q -> f' + Q
31640  facqqs=comfac*(0.5d0*aem/xw)**2*sh*(sh-sqm3)/(sqmw-th)**2
31641  facqqu=comfac*(0.5d0*aem/xw)**2*uh*(uh-sqm3)/(sqmw-th)**2
31642  DO 130 i=mmin1,mmax1
31643  IF(i.EQ.0.OR.kfac(1,i).EQ.0) goto 130
31644  DO 120 j=mmin2,mmax2
31645  IF(j.EQ.0.OR.kfac(2,j).EQ.0) goto 120
31646  IF(i*j.GT.0.AND.mod(iabs(i+j),2).EQ.0) goto 120
31647  IF(i*j.LT.0.AND.mod(iabs(i+j),2).EQ.1) goto 120
31648  IF(iabs(i).LT.mint(55).AND.mod(iabs(i+mint(55)),2).EQ.1)
31649  & THEN
31650  nchn=nchn+1
31651  isig(nchn,1)=i
31652  isig(nchn,2)=j
31653  isig(nchn,3)=1
31654  IF(mod(mint(55),2).EQ.0) facckm=vckm(mint(55)/2,
31655  & (iabs(i)+1)/2)*vint(180+j)
31656  IF(mod(mint(55),2).EQ.1) facckm=vckm(iabs(i)/2,
31657  & (mint(55)+1)/2)*vint(180+j)
31658  wid2=1d0
31659  IF(i.GT.0) THEN
31660  IF(mint(55).EQ.6) wid2=wids(6,2)
31661  IF(mint(55).EQ.7.OR.mint(55).EQ.8) wid2=
31662  & wids(mint(55),2)
31663  ELSE
31664  IF(mint(55).EQ.6) wid2=wids(6,3)
31665  IF(mint(55).EQ.7.OR.mint(55).EQ.8) wid2=
31666  & wids(mint(55),3)
31667  ENDIF
31668  IF(i*j.GT.0) sigh(nchn)=facqqs*facckm*wid2
31669  IF(i*j.LT.0) sigh(nchn)=facqqu*facckm*wid2
31670  ENDIF
31671  IF(iabs(j).LT.mint(55).AND.mod(iabs(j+mint(55)),2).EQ.1)
31672  & THEN
31673  nchn=nchn+1
31674  isig(nchn,1)=i
31675  isig(nchn,2)=j
31676  isig(nchn,3)=2
31677  IF(mod(mint(55),2).EQ.0) facckm=vckm(mint(55)/2,
31678  & (iabs(j)+1)/2)*vint(180+i)
31679  IF(mod(mint(55),2).EQ.1) facckm=vckm(iabs(j)/2,
31680  & (mint(55)+1)/2)*vint(180+i)
31681  wid2=1d0
31682  IF(j.GT.0) THEN
31683  IF(mint(55).EQ.6) wid2=wids(6,2)
31684  IF(mint(55).EQ.7.OR.mint(55).EQ.8) wid2=
31685  & wids(mint(55),2)
31686  ELSE
31687  IF(mint(55).EQ.6) wid2=wids(6,3)
31688  IF(mint(55).EQ.7.OR.mint(55).EQ.8) wid2=
31689  & wids(mint(55),3)
31690  ENDIF
31691  IF(i*j.GT.0) sigh(nchn)=facqqs*facckm*wid2
31692  IF(i*j.LT.0) sigh(nchn)=facqqu*facckm*wid2
31693  ENDIF
31694  120 CONTINUE
31695  130 CONTINUE
31696 
31697  ELSEIF(isub.EQ.84) THEN
31698 C...g + gamma -> Q + Qbar
31699  sqmavg=0.5d0*(sqm3+sqm4)-0.25d0*(sqm3-sqm4)**2/sh
31700  thq=-0.5d0*sh*(1d0-be34*cth)
31701  uhq=-0.5d0*sh*(1d0+be34*cth)
31702  facqq=comfac*as*aem*(kchg(iabs(mint(55)),1)/3d0)**2*
31703  & (thq**2+uhq**2+4d0*sqmavg*sh*(1d0-sqmavg*sh/(thq*uhq)))/
31704  & (thq*uhq)
31705  IF(mstp(35).GE.1) facqq=facqq*pyhfth(sh,sqmavg,0d0)
31706  wid2=1d0
31707  IF(mint(55).EQ.6) wid2=wids(6,1)
31708  IF(mint(55).EQ.7.OR.mint(55).EQ.8) wid2=wids(mint(55),1)
31709  facqq=facqq*wid2
31710  IF(kfac(1,21)*kfac(2,22).NE.0) THEN
31711  nchn=nchn+1
31712  isig(nchn,1)=21
31713  isig(nchn,2)=22
31714  isig(nchn,3)=1
31715  sigh(nchn)=facqq
31716  ENDIF
31717  IF(kfac(1,22)*kfac(2,21).NE.0) THEN
31718  nchn=nchn+1
31719  isig(nchn,1)=22
31720  isig(nchn,2)=21
31721  isig(nchn,3)=1
31722  sigh(nchn)=facqq
31723  ENDIF
31724 
31725  ELSEIF(isub.EQ.85) THEN
31726 C...gamma + gamma -> F + Fbar (heavy fermion, quark or lepton)
31727  sqmavg=0.5d0*(sqm3+sqm4)-0.25d0*(sqm3-sqm4)**2/sh
31728  thq=-0.5d0*sh*(1d0-be34*cth)
31729  uhq=-0.5d0*sh*(1d0+be34*cth)
31730  facff=comfac*aem**2*(kchg(iabs(mint(56)),1)/3d0)**4*2d0*
31731  & ((1d0-parj(131)*parj(132))*(thq*uhq-sqmavg*sh)*
31732  & (uhq**2+thq**2+2d0*sqmavg*sh)+(1d0+parj(131)*parj(132))*
31733  & sqmavg*sh**2*(sh-2d0*sqmavg))/(thq*uhq)**2
31734  IF(iabs(mint(56)).LT.10) facff=3d0*facff
31735  IF(iabs(mint(56)).LT.10.AND.mstp(35).GE.1)
31736  & facff=facff*pyhfth(sh,sqmavg,1d0)
31737  wid2=1d0
31738  IF(mint(56).EQ.6) wid2=wids(6,1)
31739  IF(mint(56).EQ.7.OR.mint(56).EQ.8) wid2=wids(mint(56),1)
31740  IF(mint(56).EQ.17) wid2=wids(17,1)
31741  facff=facff*wid2
31742  IF(kfac(1,22)*kfac(2,22).NE.0) THEN
31743  nchn=nchn+1
31744  isig(nchn,1)=22
31745  isig(nchn,2)=22
31746  isig(nchn,3)=1
31747  sigh(nchn)=facff
31748  ENDIF
31749 
31750  ELSEIF(isub.EQ.86) THEN
31751 C...g + g -> J/Psi + g
31752  facqqg=comfac*as**3*(5d0/9d0)*parp(38)*sqrt(sqm3)*
31753  & (((sh*(sh-sqm3))**2+(th*(th-sqm3))**2+(uh*(uh-sqm3))**2)/
31754  & ((th-sqm3)*(uh-sqm3))**2)/(sh-sqm3)**2
31755  IF(kfac(1,21)*kfac(2,21).NE.0) THEN
31756  nchn=nchn+1
31757  isig(nchn,1)=21
31758  isig(nchn,2)=21
31759  isig(nchn,3)=1
31760  sigh(nchn)=facqqg
31761  ENDIF
31762 
31763  ELSEIF(isub.EQ.87) THEN
31764 C...g + g -> chi_0c + g
31765  pgtw=(sh*th+th*uh+uh*sh)/sh2
31766  qgtw=(sh*th*uh)/sh**3
31767  rgtw=sqm3/sh
31768  facqqg=comfac*as**3*4d0*(parp(39)/sqrt(sqm3))*(1d0/sh)*
31769  & (9d0*rgtw**2*pgtw**4*(rgtw**4-2d0*rgtw**2*pgtw+pgtw**2)-
31770  & 6d0*rgtw*pgtw**3*qgtw*(2d0*rgtw**4-5d0*rgtw**2*pgtw+pgtw**2)-
31771  & pgtw**2*qgtw**2*(rgtw**4+2d0*rgtw**2*pgtw-pgtw**2)+
31772  & 2d0*rgtw*pgtw*qgtw**3*(rgtw**2-pgtw)+6d0*rgtw**2*qgtw**4)/
31773  & (qgtw*(qgtw-rgtw*pgtw)**4)
31774  IF(kfac(1,21)*kfac(2,21).NE.0) THEN
31775  nchn=nchn+1
31776  isig(nchn,1)=21
31777  isig(nchn,2)=21
31778  isig(nchn,3)=1
31779  sigh(nchn)=facqqg
31780  ENDIF
31781 
31782  ELSEIF(isub.EQ.88) THEN
31783 C...g + g -> chi_1c + g
31784  pgtw=(sh*th+th*uh+uh*sh)/sh2
31785  qgtw=(sh*th*uh)/sh**3
31786  rgtw=sqm3/sh
31787  facqqg=comfac*as**3*12d0*(parp(39)/sqrt(sqm3))*(1d0/sh)*
31788  & pgtw**2*(rgtw*pgtw**2*(rgtw**2-4d0*pgtw)+2d0*qgtw*(-rgtw**4+
31789  & 5d0*rgtw**2*pgtw+pgtw**2)-15d0*rgtw*qgtw**2)/
31790  & (qgtw-rgtw*pgtw)**4
31791  IF(kfac(1,21)*kfac(2,21).NE.0) THEN
31792  nchn=nchn+1
31793  isig(nchn,1)=21
31794  isig(nchn,2)=21
31795  isig(nchn,3)=1
31796  sigh(nchn)=facqqg
31797  ENDIF
31798 
31799  ELSEIF(isub.EQ.89) THEN
31800 C...g + g -> chi_2c + g
31801  pgtw=(sh*th+th*uh+uh*sh)/sh2
31802  qgtw=(sh*th*uh)/sh**3
31803  rgtw=sqm3/sh
31804  facqqg=comfac*as**3*4d0*(parp(39)/sqrt(sqm3))*(1d0/sh)*
31805  & (12d0*rgtw**2*pgtw**4*(rgtw**4-2d0*rgtw**2*pgtw+pgtw**2)-
31806  & 3d0*rgtw*pgtw**3*qgtw*(8d0*rgtw**4-rgtw**2*pgtw+4d0*pgtw**2)+
31807  & 2d0*pgtw**2*qgtw**2*(-7d0*rgtw**4+43d0*rgtw**2*pgtw+pgtw**2)+
31808  & rgtw*pgtw*qgtw**3*(16d0*rgtw**2-61d0*pgtw)+12d0*rgtw**2*
31809  & qgtw**4)/(qgtw*(qgtw-rgtw*pgtw)**4)
31810  IF(kfac(1,21)*kfac(2,21).NE.0) THEN
31811  nchn=nchn+1
31812  isig(nchn,1)=21
31813  isig(nchn,2)=21
31814  isig(nchn,3)=1
31815  sigh(nchn)=facqqg
31816  ENDIF
31817  ENDIF
31818 
31819  ELSEIF(isub.LE.200) THEN
31820  IF(isub.EQ.104) THEN
31821 C...g + g -> chi_c0.
31822  kc=pycomp(10441)
31823  facbw=comfac*12d0*as**2*parp(39)*pmas(kc,2)/
31824  & ((sh-pmas(kc,1)**2)**2+(pmas(kc,1)*pmas(kc,2))**2)
31825  IF(abs(sqrt(sh)-pmas(kc,1)).GT.50d0*pmas(kc,2)) facbw=0d0
31826  IF(kfac(1,21)*kfac(2,21).NE.0) THEN
31827  nchn=nchn+1
31828  isig(nchn,1)=21
31829  isig(nchn,2)=21
31830  isig(nchn,3)=1
31831  sigh(nchn)=facbw
31832  ENDIF
31833 
31834  ELSEIF(isub.EQ.105) THEN
31835 C...g + g -> chi_c2.
31836  kc=pycomp(445)
31837  facbw=comfac*16d0*as**2*parp(39)*pmas(kc,2)/
31838  & ((sh-pmas(kc,1)**2)**2+(pmas(kc,1)*pmas(kc,2))**2)
31839  IF(abs(sqrt(sh)-pmas(kc,1)).GT.50d0*pmas(kc,2)) facbw=0d0
31840  IF(kfac(1,21)*kfac(2,21).NE.0) THEN
31841  nchn=nchn+1
31842  isig(nchn,1)=21
31843  isig(nchn,2)=21
31844  isig(nchn,3)=1
31845  sigh(nchn)=facbw
31846  ENDIF
31847 
31848  ELSEIF(isub.EQ.106) THEN
31849 C...g + g -> J/Psi + gamma.
31850  eq=kchg(mod(kfpr(isub,1)/10,10),1)/3d0
31851  facqqg=comfac*aem*eq**2*as**2*(4d0/3d0)*parp(38)*sqrt(sqm3)*
31852  & (((sh*(sh-sqm3))**2+(th*(th-sqm3))**2+(uh*(uh-sqm3))**2)/
31853  & ((th-sqm3)*(uh-sqm3))**2)/(sh-sqm3)**2
31854  IF(kfac(1,21)*kfac(2,21).NE.0) THEN
31855  nchn=nchn+1
31856  isig(nchn,1)=21
31857  isig(nchn,2)=21
31858  isig(nchn,3)=1
31859  sigh(nchn)=facqqg
31860  ENDIF
31861 
31862  ELSEIF(isub.EQ.107) THEN
31863 C...g + gamma -> J/Psi + g.
31864  eq=kchg(mod(kfpr(isub,1)/10,10),1)/3d0
31865  facqqg=comfac*aem*eq**2*as**2*(32d0/3d0)*parp(38)*sqrt(sqm3)*
31866  & (((sh*(sh-sqm3))**2+(th*(th-sqm3))**2+(uh*(uh-sqm3))**2)/
31867  & ((th-sqm3)*(uh-sqm3))**2)/(sh-sqm3)**2
31868  IF(kfac(1,21)*kfac(2,22).NE.0) THEN
31869  nchn=nchn+1
31870  isig(nchn,1)=21
31871  isig(nchn,2)=22
31872  isig(nchn,3)=1
31873  sigh(nchn)=facqqg
31874  ENDIF
31875  IF(kfac(1,22)*kfac(2,21).NE.0) THEN
31876  nchn=nchn+1
31877  isig(nchn,1)=22
31878  isig(nchn,2)=21
31879  isig(nchn,3)=1
31880  sigh(nchn)=facqqg
31881  ENDIF
31882 
31883  ELSEIF(isub.EQ.108) THEN
31884 C...gamma + gamma -> J/Psi + gamma.
31885  eq=kchg(mod(kfpr(isub,1)/10,10),1)/3d0
31886  facqqg=comfac*aem**3*eq**6*384d0*parp(38)*sqrt(sqm3)*
31887  & (((sh*(sh-sqm3))**2+(th*(th-sqm3))**2+(uh*(uh-sqm3))**2)/
31888  & ((th-sqm3)*(uh-sqm3))**2)/(sh-sqm3)**2
31889  IF(kfac(1,22)*kfac(2,22).NE.0) THEN
31890  nchn=nchn+1
31891  isig(nchn,1)=22
31892  isig(nchn,2)=22
31893  isig(nchn,3)=1
31894  sigh(nchn)=facqqg
31895  ENDIF
31896  ENDIF
31897 
31898 C...QUARKONIA+++
31899 C...Additional code by Stefan Wolf
31900  ELSE
31901 
31902 C...Common code for quarkonium production.
31903  shth=sh+th
31904  thuh=th+uh
31905  uhsh=uh+sh
31906  shth2=shth**2
31907  thuh2=thuh**2
31908  uhsh2=uhsh**2
31909  IF ( (isub.GE.421.AND.isub.LE.424).OR.
31910  & (isub.GE.431.AND.isub.LE.433)) THEN
31911  sqmqq=sqm3
31912  ELSEIF((isub.GE.425.AND.isub.LE.430).OR.
31913  & (isub.GE.434.AND.isub.LE.439)) THEN
31914  sqmqq=sqm4
31915  ENDIF
31916  sqmqqr=sqrt(sqmqq)
31917  IF(mstp(145).EQ.1) THEN
31918  IF ( (isub.GE.421.AND.isub.LE.427).OR.
31919  & (isub.GE.431.AND.isub.LE.436)) THEN
31920  aq=uhsh/(2d0*x(1)) + shth/(2d0*x(2))
31921  bq=uhsh/(2d0*x(1)) - shth/(2d0*x(2))
31922  atilk1=x(1)*vint(2)/2d0-uhsh/(2d0*sqmqq)*aq
31923  atilk2=x(2)*vint(2)/2d0-shth/(2d0*sqmqq)*aq
31924  btilk1=-x(1)*vint(2)/2d0-uhsh/(2d0*sqmqq)*bq
31925  btilk2=x(2)*vint(2)/2d0-shth/(2d0*sqmqq)*bq
31926  ELSEIF( (isub.GE.428.AND.isub.LE.430).OR.
31927  & isub.GE.437) THEN
31928  aq=shth/(2d0*x(1)) + uhsh/(2d0*x(2))
31929  bq=shth/(2d0*x(1)) - uhsh/(2d0*x(2))
31930  atilk1=x(1)*vint(2)/2d0-shth/(2d0*sqmqq)*aq
31931  atilk2=x(2)*vint(2)/2d0-uhsh/(2d0*sqmqq)*aq
31932  btilk1=-x(1)*vint(2)/2d0-shth/(2d0*sqmqq)*bq
31933  btilk2=x(2)*vint(2)/2d0-uhsh/(2d0*sqmqq)*bq
31934  ENDIF
31935  aq2=aq**2
31936  bq2=bq**2
31937  smqq2=sqmqq*vint(2)
31938 C...Polarisation frames
31939  IF(mstp(146).EQ.1) THEN
31940 C...Recoil frame
31941  polh1=sqrt(aq2-smqq2)
31942  polh2=sqrt(vint(2)*(aq2-bq2-smqq2))
31943  az=-sqmqqr/polh1
31944  bz=0d0
31945  ax=aq*bq/(polh1*polh2)
31946  bx=-polh1/polh2
31947  ELSEIF(mstp(146).EQ.2) THEN
31948 C...Gottfried Jackson frame
31949  polh1=aq+bq
31950  polh2=polh1*sqrt(vint(2)*(aq2-bq2-smqq2))
31951  az=sqmqqr/polh1
31952  bz=az
31953  ax=-(bq2+aq*bq+smqq2)/polh2
31954  bx=(aq2+aq*bq-smqq2)/polh2
31955  ELSEIF(mstp(146).EQ.3) THEN
31956 C...Target frame
31957  polh1=aq-bq
31958  polh2=polh1*sqrt(vint(2)*(aq2-bq2-smqq2))
31959  az=-sqmqqr/polh1
31960  bz=-az
31961  ax=-(bq2-aq*bq+smqq2)/polh2
31962  bx=-(aq2-aq*bq-smqq2)/polh2
31963  ELSEIF(mstp(146).EQ.4) THEN
31964 C...Collins Soper frame
31965  polh1=aq2-bq2
31966  polh2=sqrt(vint(2)*polh1)
31967  az=-bq/polh2
31968  bz=aq/polh2
31969  ax=-sqmqqr*aq/sqrt(polh1*(polh1-smqq2))
31970  bx=sqmqqr*bq/sqrt(polh1*(polh1-smqq2))
31971  ENDIF
31972 C...Contract EL1(lam) EL2(lam') with K1 and K2 (initial parton momenta)
31973  el1k10=az*atilk1+bz*btilk1
31974  el1k20=az*atilk2+bz*btilk2
31975  el2k10=el1k10
31976  el2k20=el1k20
31977  el1k11=1d0/sqrt(2d0)*(ax*atilk1+bx*btilk1)
31978  el1k21=1d0/sqrt(2d0)*(ax*atilk2+bx*btilk2)
31979  el2k11=el1k11
31980  el2k21=el1k21
31981  ENDIF
31982 
31983  IF(isub.EQ.421) THEN
31984 C...g + g -> QQ~[3S11] + g
31985  IF(mstp(145).EQ.0) THEN
31986 * FACQQG=COMFAC*PARU(1)*AS**3*(10D0/81D0)*SQMQQR*
31987 * & (SH2*THUH2+TH2*UHSH2+UH2*SHTH2)/(SHTH2*THUH2*UHSH2)
31988  facqqg=comfac*paru(1)*as**3*(10d0/81d0)*sqmqqr*
31989  & (sh2*thuh2+th2*uhsh2+uh2*shth2)/shth2/thuh2/uhsh2
31990 * FACQQG=COMFAC*PARU(1)*AS**3*(10D0/81D0)*SQMQQR*
31991 * & (SH2/(SHTH2*UHSH2)+TH2/(SHTH2*THUH2)+UH2/(THUH2*UHSH2))
31992  ELSE
31993  ff=-paru(1)*as**3*(10d0/81d0)*sqmqqr/thuh2/shth2/uhsh2
31994  aa=(shth2*uh2+uhsh2*th2+thuh2*sh2)/2d0
31995  bb=2d0*(sh2+th2)
31996  cc=2d0*(sh2+uh2)
31997  dd=2d0*sh2
31998  IF(mstp(147).EQ.0) THEN
31999  facqqg=-aa+sqmqq*(bb*el1k10*el2k10+cc*el1k20*el2k20
32000  & +dd*(el1k10*el2k20+el1k20*el2k10))
32001  ELSEIF(mstp(147).EQ.1) THEN
32002  facqqg=2d0*(-aa+sqmqq*(bb*el1k11*el2k11+cc*el1k21*el2k21
32003  & +dd*(el1k11*el2k21+el1k21*el2k11)))
32004  ELSEIF(mstp(147).EQ.3) THEN
32005  facqqg=-aa+sqmqq*(bb*el1k10*el2k10+cc*el1k20*el2k20
32006  & +dd*(el1k10*el2k20+el1k20*el2k10))
32007  ELSEIF(mstp(147).EQ.4) THEN
32008  facqqg=-aa+sqmqq*(bb*el1k11*el2k11+cc*el1k21*el2k21
32009  & +dd*(el1k11*el2k21+el1k21*el2k11))
32010  ELSEIF(mstp(147).EQ.5) THEN
32011  facqqg=sqmqq*(bb*el1k11*el2k10+cc*el1k21*el2k20
32012  & +dd*(el1k11*el2k20+el1k21*el2k10))
32013  ELSEIF(mstp(147).EQ.6) THEN
32014  facqqg=sqmqq*(bb*el1k11*el2k11+cc*el1k21*el2k21
32015  & +dd*(el1k11*el2k21+el1k21*el2k11))
32016  ENDIF
32017  facqqg=comfac*ff*facqqg
32018  ENDIF
32019  IF(kfac(1,21)*kfac(2,21).NE.0) THEN
32020  nchn=nchn+1
32021  isig(nchn,1)=21
32022  isig(nchn,2)=21
32023  isig(nchn,3)=1
32024  sigh(nchn)=facqqg*parp(ionium+1)
32025  ENDIF
32026 
32027  ELSEIF(isub.EQ.422) THEN
32028 C...g + g -> QQ~[3S18] + g
32029  IF(mstp(145).EQ.0) THEN
32030  facqqg=-comfac*paru(1)*as**3*(1d0/72d0)*
32031  & (16d0*sqmqq**2-27d0*(shth2+thuh2+uhsh2))/
32032  & (sqmqq*sqmqqr)*
32033  & ((sh2*thuh2+th2*uhsh2+uh2*shth2)/shth2/thuh2/uhsh2)
32034  ELSE
32035  ff=paru(1)*as**3*(16d0*sqmqq**2-27d0*(shth2+thuh2+uhsh2))/
32036  & (72d0*sqmqq*sqmqqr*shth2*thuh2*uhsh2)
32037  aa=(shth2*uh2+uhsh2*th2+thuh2*sh2)/2d0
32038  bb=2d0*(sh2+th2)
32039  cc=2d0*(sh2+uh2)
32040  dd=2d0*sh2
32041  IF(mstp(147).EQ.0) THEN
32042  facqqg=-aa+sqmqq*(bb*el1k10*el2k10+cc*el1k20*el2k20
32043  & +dd*(el1k10*el2k20+el1k20*el2k10))
32044  ELSEIF(mstp(147).EQ.1) THEN
32045  facqqg=2d0*(-aa+sqmqq*(bb*el1k11*el2k11+cc*el1k21*el2k21
32046  & +dd*(el1k11*el2k21+el1k21*el2k11)))
32047  ELSEIF(mstp(147).EQ.3) THEN
32048  facqqg=-aa+sqmqq*(bb*el1k10*el2k10+cc*el1k20*el2k20
32049  & +dd*(el1k10*el2k20+el1k20*el2k10))
32050  ELSEIF(mstp(147).EQ.4) THEN
32051  facqqg=-aa+sqmqq*(bb*el1k11*el2k11+cc*el1k21*el2k21
32052  & +dd*(el1k11*el2k21+el1k21*el2k11))
32053  ELSEIF(mstp(147).EQ.5) THEN
32054  facqqg=sqmqq*(bb*el1k11*el2k10+cc*el1k21*el2k20
32055  & +dd*(el1k11*el2k20+el1k21*el2k10))
32056  ELSEIF(mstp(147).EQ.6) THEN
32057  facqqg=sqmqq*(bb*el1k11*el2k11+cc*el1k21*el2k21
32058  & +dd*(el1k11*el2k21+el1k21*el2k11))
32059  ENDIF
32060  facqqg=comfac*ff*facqqg
32061  ENDIF
32062 C...Split total contribution into different colour flows just like
32063 C...in g g -> g g (recalculate kinematics for massless partons).
32064  thp=-0.5d0*sh*(1d0-cth)
32065  uhp=-0.5d0*sh*(1d0+cth)
32066  facgg1=(sh/thp)**2+2d0*sh/thp+3d0+2d0*thp/sh+(thp/sh)**2
32067  facgg2=(uhp/sh)**2+2d0*uhp/sh+3d0+2d0*sh/uhp+(sh/uhp)**2
32068  facgg3=(thp/uhp)**2+2d0*thp/uhp+3d0+2d0*uhp/thp+(uhp/thp)**2
32069  facggs=facgg1+facgg2+facgg3
32070  IF(kfac(1,21)*kfac(2,21).NE.0) THEN
32071  nchn=nchn+1
32072  isig(nchn,1)=21
32073  isig(nchn,2)=21
32074  isig(nchn,3)=1
32075  sigh(nchn)=facqqg*parp(ionium+2)*facgg1/facggs
32076  nchn=nchn+1
32077  isig(nchn,1)=21
32078  isig(nchn,2)=21
32079  isig(nchn,3)=2
32080  sigh(nchn)=facqqg*parp(ionium+2)*facgg2/facggs
32081  nchn=nchn+1
32082  isig(nchn,1)=21
32083  isig(nchn,2)=21
32084  isig(nchn,3)=3
32085  sigh(nchn)=facqqg*parp(ionium+2)*facgg3/facggs
32086  ENDIF
32087 
32088  ELSEIF(isub.EQ.423) THEN
32089 C...g + g -> QQ~[1S08] + g
32090  IF(mstp(145).EQ.0) THEN
32091 * FACQQG=COMFAC*PARU(1)*AS**3*(5D0/16D0)*
32092 * & (SHTH2*UH2+THUH2*SH2+UHSH2*TH2)/(SQMQQR*SH*TH*UH)*
32093 * & (12D0*SQMQQ*SH*TH*UH+SHTH2**2+THUH2**2+UHSH2**2)/
32094 * & (SHTH2*THUH2*UHSH2)
32095  facqqg=comfac*paru(1)*as**3*(5d0/16d0)*sqmqqr*
32096  & (uh2/(thuh2*uhsh2)+sh2/(shth2*uhsh2)+
32097  & th2/(shth2*thuh2))*
32098  & (12d0+(shth2**2+thuh2**2+uhsh2**2)/(sqmqq*sh*th*uh))
32099  ELSE
32100  fa=paru(1)*as**3*(5d0/48d0)*sqmqqr*
32101  & (uh2/(thuh2*uhsh2)+sh2/(shth2*uhsh2)+
32102  & th2/(shth2*thuh2))*
32103  & (12d0+(shth2**2+thuh2**2+uhsh2**2)/(sqmqq*sh*th*uh))
32104  IF(mstp(147).EQ.0) THEN
32105  facqqg=comfac*fa
32106  ELSEIF(mstp(147).EQ.1) THEN
32107  facqqg=comfac*2d0*fa
32108  ELSEIF(mstp(147).EQ.3) THEN
32109  facqqg=comfac*fa
32110  ELSEIF(mstp(147).EQ.4) THEN
32111  facqqg=comfac*fa
32112  ELSEIF(mstp(147).EQ.5) THEN
32113  facqqg=0d0
32114  ELSEIF(mstp(147).EQ.6) THEN
32115  facqqg=0d0
32116  ENDIF
32117  ENDIF
32118 C...Split total contribution into different colour flows just like
32119 C...in g g -> g g (recalculate kinematics for massless partons).
32120  thp=-0.5d0*sh*(1d0-cth)
32121  uhp=-0.5d0*sh*(1d0+cth)
32122  facgg1=(sh/thp)**2+2d0*sh/thp+3d0+2d0*thp/sh+(thp/sh)**2
32123  facgg2=(uhp/sh)**2+2d0*uhp/sh+3d0+2d0*sh/uhp+(sh/uhp)**2
32124  facgg3=(thp/uhp)**2+2d0*thp/uhp+3d0+2d0*uhp/thp+(uhp/thp)**2
32125  facggs=facgg1+facgg2+facgg3
32126  IF(kfac(1,21)*kfac(2,21).NE.0) THEN
32127  nchn=nchn+1
32128  isig(nchn,1)=21
32129  isig(nchn,2)=21
32130  isig(nchn,3)=1
32131  sigh(nchn)=facqqg*parp(ionium+3)*facgg1/facggs
32132  nchn=nchn+1
32133  isig(nchn,1)=21
32134  isig(nchn,2)=21
32135  isig(nchn,3)=2
32136  sigh(nchn)=facqqg*parp(ionium+3)*facgg2/facggs
32137  nchn=nchn+1
32138  isig(nchn,1)=21
32139  isig(nchn,2)=21
32140  isig(nchn,3)=3
32141  sigh(nchn)=facqqg*parp(ionium+3)*facgg3/facggs
32142  ENDIF
32143 
32144  ELSEIF(isub.EQ.424) THEN
32145 C...g + g -> QQ~[3PJ8] + g
32146  poly=sh2+sh*th+th2
32147  IF(mstp(145).EQ.0) THEN
32148  facqqg=comfac*5d0*paru(1)*as**3*(3d0*sh*th*shth*poly**4
32149  & -sqmqq*poly**2*(7d0*sh**6+36d0*sh**5*th+45d0*sh**4*th2
32150  & +28d0*sh**3*th**3+45d0*sh2*th**4+36d0*sh*th**5
32151  & +7d0*th**6)
32152  & +sqmqq**2*shth*(35d0*sh**8+169d0*sh**7*th
32153  & +299d0*sh**6*th2+401d0*sh**5*th**3+418d0*sh**4*th**4
32154  & +401d0*sh**3*th**5+299d0*sh2*th**6+169d0*sh*th**7
32155  & +35d0*th**8)
32156  & -sqmqq**3*(84d0*sh**8+432d0*sh**7*th+905d0*sh**6*th2
32157  & +1287d0*sh**5*th**3+1436d0*sh**4*th**4
32158  & +1287d0*sh**3*th**5+905d0*sh2*th**6+432d0*sh*th**7
32159  & +84d0*th**8)
32160  & +sqmqq**4*shth*(126d0*sh**6+451d0*sh**5*th
32161  & +677d0*sh**4*th2+836d0*sh**3*th**3+677d0*sh2*th**4
32162  & +451d0*sh*th**5+126d0*th**6)
32163  & -3d0*sqmqq**5*(42d0*sh**6+171d0*sh**5*th
32164  & +304d0*sh**4*th2+362d0*sh**3*th**3+304d0*sh2*th**4
32165  & +171d0*sh*th**5+42d0*th**6)
32166  & +2d0*sqmqq**6*shth*(42d0*sh**4+106d0*sh**3*th
32167  & +119d0*sh2*th2+106d0*sh*th**3+42d0*th**4)
32168  & -sqmqq**7*(35d0*sh**4+99d0*sh**3*th+120d0*sh2*th2
32169  & +99d0*sh*th**3+35d0*th**4)
32170  & +7d0*sqmqq**8*shth*poly)/
32171  & (sh*th*uh*sqmqqr*sqmqq*
32172  & shth*shth2*thuh*thuh2*uhsh*uhsh2)
32173  ELSE
32174  ff=-5d0*paru(1)*as**3/(sh2*th2*uh2
32175  & *sqmqqr*sqmqq*shth*shth2*thuh*thuh2*uhsh*uhsh2)
32176  aa=sh*th*uh*(sh*th*shth*poly**4
32177  & -sqmqq*shth2*poly**2*
32178  & (sh**4+6d0*sh**3*th-6d0*sh2*th2+6d0*sh*th**3+th**4)
32179  & +sqmqq**2*shth*(5d0*sh**8+35d0*sh**7*th+49d0*sh**6*th2
32180  & +57d0*sh**5*th**3+46d0*sh**4*th**4+57d0*sh**3*th**5
32181  & +49d0*sh2*th**6+35d0*sh*th**7+5d0*th**8)
32182  & -sqmqq**3*(16d0*sh**8+104d0*sh**7*th+215d0*sh**6*th2
32183  & +291d0*sh**5*th**3+316d0*sh**4*th**4+291d0*sh**3*th**5
32184  & +215d0*sh2*th**6+104d0*sh*th**7+16d0*th**8)
32185  & +sqmqq**4*shth*(34d0*sh**6+145d0*sh**5*th
32186  & +211d0*sh**4*th2+262d0*sh**3*th**3+211d0*sh2*th**4
32187  & +145d0*sh*th**5+34d0*th**6)
32188  & -sqmqq**5*(44d0*sh**6+193d0*sh**5*th+346d0*sh**4*th2
32189  & +410d0*sh**3*th**3+346d0*sh2*th**4+193d0*sh*th**5
32190  & +44d0*th**6)
32191  & +2d0*sqmqq**6*shth*(17d0*sh**4+45d0*sh**3*th
32192  & +49d0*sh2*th2+45d0*sh*th**3+17d0*th**4)
32193  & -sqmqq**7*(3d0*sh2+2d0*sh*th+3d0*th2)
32194  & *(5d0*sh2+11d0*sh*th+5d0*th2)
32195  & +3d0*sqmqq**8*shth*poly)
32196  bb=4d0*shth2*poly**3
32197  & *(sh**4+sh**3*th-sh2*th2+sh*th**3+th**4)
32198  & -sqmqq*shth*(20d0*sh**10+84d0*sh**9*th+166d0*sh**8*th2
32199  & +231d0*sh**7*th**3+250d0*sh**6*th**4+250d0*sh**5*th**5
32200  & +250d0*sh**4*th**6+231d0*sh**3*th**7+166d0*sh2*th**8
32201  & +84d0*sh*th**9+20d0*th**10)
32202  & +sqmqq**2*shth2*(40d0*sh**8+86d0*sh**7*th
32203  & +66d0*sh**6*th2+67d0*sh**5*th**3+6d0*sh**4*th**4
32204  & +67d0*sh**3*th**5+66d0*sh2*th**6+86d0*sh*th**7
32205  & +40d0*th**8)
32206  & -sqmqq**3*shth*(40d0*sh**8+57d0*sh**7*th
32207  & -110d0*sh**6*th2-263d0*sh**5*th**3-384d0*sh**4*th**4
32208  & -263d0*sh**3*th**5-110d0*sh2*th**6+57d0*sh*th**7
32209  & +40d0*th**8)
32210  & +sqmqq**4*(20d0*sh**8-33d0*sh**7*th-368d0*sh**6*th2
32211  & -751d0*sh**5*th**3-920d0*sh**4*th**4-751d0*sh**3*th**5
32212  & -368d0*sh2*th**6-33d0*sh*th**7+20d0*th**8)
32213  & -sqmqq**5*shth*(4d0*sh**6-81d0*sh**5*th-242d0*sh**4*th2
32214  & -250d0*sh**3*th**3-242d0*sh2*th**4-81d0*sh*th**5
32215  & +4d0*th**6)
32216  & -sqmqq**6*sh*th*(41d0*sh**4+120d0*sh**3*th
32217  & +142d0*sh2*th2+120d0*sh*th**3+41d0*th**4)
32218  & +8d0*sqmqq**7*sh*th*shth*poly
32219  cc=4d0*th2*poly**3
32220  & *(-sh**4-2d0*sh**3*th+2d0*sh2*th2+3d0*sh*th**3+th**4)
32221  & -sqmqq*th2*(-20d0*sh**9-56d0*sh**8*th-24d0*sh**7*th2
32222  & +147d0*sh**6*th**3+409d0*sh**5*th**4+599d0*sh**4*th**5
32223  & +571d0*sh**3*th**6+370d0*sh2*th**7+148d0*sh*th**8
32224  & +28d0*th**9)
32225  & +sqmqq**2*(4d0*sh**10+20d0*sh**9*th-16d0*sh**8*th2
32226  & -48d0*sh**7*th**3+150d0*sh**6*th**4+611d0*sh**5*th**5
32227  & +1060d0*sh**4*th**6+1155d0*sh**3*th**7+854d0*sh2*th**8
32228  & +394d0*sh*th**9+84d0*th**10)
32229  & -sqmqq**3*shth*(20d0*sh**8+68d0*sh**7*th-20d0*sh**6*th2
32230  & +32d0*sh**5*th**3+286d0*sh**4*th**4+577d0*sh**3*th**5
32231  & +618d0*sh2*th**6+443d0*sh*th**7+140d0*th**8)
32232  & +sqmqq**4*(40d0*sh**8+152d0*sh**7*th+94d0*sh**6*th2
32233  & +38d0*sh**5*th**3+290d0*sh**4*th**4+631d0*sh**3*th**5
32234  & +738d0*sh2*th**6+513d0*sh*th**7+140d0*th**8)
32235  & -sqmqq**5*(40d0*sh**7+129d0*sh**6*th+53d0*sh**5*th2
32236  & +7d0*sh**4*th**3+129d0*sh**3*th**4+264d0*sh2*th**5
32237  & +266d0*sh*th**6+84d0*th**7)
32238  & +sqmqq**6*(20d0*sh**6+55d0*sh**5*th+2d0*sh**4*th2
32239  & -15d0*sh**3*th**3+30d0*sh2*th**4+76d0*sh*th**5
32240  & +28d0*th**6)
32241  & -sqmqq**7*shth*(4d0*sh**4+7d0*sh**3*th-14d0*sh2*th2
32242  & +7d0*sh*th**3+4*th**4)
32243  & +sqmqq**8*sh*(sh-th)**2*th
32244  dd=2d0*th2*shth2*poly**3
32245  & *(-sh2+2*sh*th+2*th2)
32246  & +sqmqq*(4d0*sh**11+22d0*sh**10*th+70d0*sh**9*th2
32247  & +115d0*sh**8*th**3+71d0*sh**7*th**4-119d0*sh**6*th**5
32248  & -381d0*sh**5*th**6-552d0*sh**4*th**7-512d0*sh**3*th**8
32249  & -320d0*sh2*th**9-126d0*sh*th**10-24d0*th**11)
32250  & -sqmqq**2*shth*(20d0*sh**9+84d0*sh**8*th
32251  & +212d0*sh**7*th2+247d0*sh**6*th**3+105d0*sh**5*th**4
32252  & -178d0*sh**4*th**5-380d0*sh**3*th**6-364d0*sh2*th**7
32253  & -210d0*sh*th**8-60d0*th**9)
32254  & +sqmqq**3*shth*(40d0*sh**8+159d0*sh**7*th
32255  & +374d0*sh**6*th2+404d0*sh**5*th**3+192d0*sh**4*th**4
32256  & -141d0*sh**3*th**5-264d0*sh2*th**6-216d0*sh*th**7
32257  & -80d0*th**8)
32258  & -sqmqq**4*(40d0*sh**8+197d0*sh**7*th+506d0*sh**6*th2
32259  & +672d0*sh**5*th**3+460d0*sh**4*th**4+79d0*sh**3*th**5
32260  & -138d0*sh2*th**6-164d0*sh*th**7-60d0*th**8)
32261  & +sqmqq**5*(20d0*sh**7+107d0*sh**6*th+267d0*sh**5*th2
32262  & +307d0*sh**4*th**3+185d0*sh**3*th**4+56d0*sh2*th**5
32263  & -30d0*sh*th**6-24d0*th**7)
32264  & -sqmqq**6*(4d0*sh**6+31d0*sh**5*th+74d0*sh**4*th2
32265  & +71d0*sh**3*th**3+46d0*sh2*th**4+10d0*sh*th**5
32266  & -4d0*th**6)
32267  & +4d0*sqmqq**7*sh*th*shth*poly
32268  IF(mstp(147).EQ.0) THEN
32269  facqqg=-aa+sqmqq*(bb*el1k10*el2k10+cc*el1k20*el2k20
32270  & +dd*(el1k10*el2k20+el1k20*el2k10))
32271  ELSEIF(mstp(147).EQ.1) THEN
32272  facqqg=2d0*(-aa+sqmqq*(bb*el1k11*el2k11+cc*el1k21*el2k21
32273  & +dd*(el1k11*el2k21+el1k21*el2k11)))
32274  ELSEIF(mstp(147).EQ.3) THEN
32275  facqqg=-aa+sqmqq*(bb*el1k10*el2k10+cc*el1k20*el2k20
32276  & +dd*(el1k10*el2k20+el1k20*el2k10))
32277  ELSEIF(mstp(147).EQ.4) THEN
32278  facqqg=-aa+sqmqq*(bb*el1k11*el2k11+cc*el1k21*el2k21
32279  & +dd*(el1k11*el2k21+el1k21*el2k11))
32280  ELSEIF(mstp(147).EQ.5) THEN
32281  facqqg=sqmqq*(bb*el1k11*el2k10+cc*el1k21*el2k20
32282  & +dd*(el1k11*el2k20+el1k21*el2k10))
32283  ELSEIF(mstp(147).EQ.6) THEN
32284  facqqg=sqmqq*(bb*el1k11*el2k11+cc*el1k21*el2k21
32285  & +dd*(el1k11*el2k21+el1k21*el2k11))
32286  ENDIF
32287  facqqg=comfac*ff*facqqg
32288  ENDIF
32289 C...Split total contribution into different colour flows just like
32290 C...in g g -> g g (recalculate kinematics for massless partons).
32291  thp=-0.5d0*sh*(1d0-cth)
32292  uhp=-0.5d0*sh*(1d0+cth)
32293  facgg1=(sh/thp)**2+2d0*sh/thp+3d0+2d0*thp/sh+(thp/sh)**2
32294  facgg2=(uhp/sh)**2+2d0*uhp/sh+3d0+2d0*sh/uhp+(sh/uhp)**2
32295  facgg3=(thp/uhp)**2+2d0*thp/uhp+3d0+2d0*uhp/thp+(uhp/thp)**2
32296  facggs=facgg1+facgg2+facgg3
32297  IF(kfac(1,21)*kfac(2,21).NE.0) THEN
32298  nchn=nchn+1
32299  isig(nchn,1)=21
32300  isig(nchn,2)=21
32301  isig(nchn,3)=1
32302  sigh(nchn)=facqqg*parp(ionium+4)*facgg1/facggs
32303  nchn=nchn+1
32304  isig(nchn,1)=21
32305  isig(nchn,2)=21
32306  isig(nchn,3)=2
32307  sigh(nchn)=facqqg*parp(ionium+4)*facgg2/facggs
32308  nchn=nchn+1
32309  isig(nchn,1)=21
32310  isig(nchn,2)=21
32311  isig(nchn,3)=3
32312  sigh(nchn)=facqqg*parp(ionium+4)*facgg3/facggs
32313  ENDIF
32314 
32315  ELSEIF(isub.EQ.425) THEN
32316 C...q + g -> q + QQ~[3S18]
32317  IF(mstp(145).EQ.0) THEN
32318  facqqg=-comfac*paru(1)*as**3*(1d0/27d0)*
32319  & (4d0*(sh2+uh2)-sh*uh)*(shth2+thuh2)/
32320  & (sqmqq*sqmqqr*sh*uh*uhsh2)
32321  ELSE
32322  ff=paru(1)*as**3*(4d0*(sh2+uh2)-sh*uh)/
32323  & (54d0*sqmqq*sqmqqr*sh*uh*uhsh2)
32324  aa=shth2+thuh2
32325  bb=4d0
32326  cc=8d0
32327  dd=4d0
32328  IF(mstp(147).EQ.0) THEN
32329  facqqg=-aa+sqmqq*(bb*el1k10*el2k10+cc*el1k20*el2k20
32330  & +dd*(el1k10*el2k20+el1k20*el2k10))
32331  ELSEIF(mstp(147).EQ.1) THEN
32332  facqqg=2d0*(-aa+sqmqq*(bb*el1k11*el2k11+cc*el1k21*el2k21
32333  & +dd*(el1k11*el2k21+el1k21*el2k11)))
32334  ELSEIF(mstp(147).EQ.3) THEN
32335  facqqg=-aa+sqmqq*(bb*el1k10*el2k10+cc*el1k20*el2k20
32336  & +dd*(el1k10*el2k20+el1k20*el2k10))
32337  ELSEIF(mstp(147).EQ.4) THEN
32338  facqqg=-aa+sqmqq*(bb*el1k11*el2k11+cc*el1k21*el2k21
32339  & +dd*(el1k11*el2k21+el1k21*el2k11))
32340  ELSEIF(mstp(147).EQ.5) THEN
32341  facqqg=sqmqq*(bb*el1k11*el2k10+cc*el1k21*el2k20
32342  & +dd*(el1k11*el2k20+el1k21*el2k10))
32343  ELSEIF(mstp(147).EQ.6) THEN
32344  facqqg=sqmqq*(bb*el1k11*el2k11+cc*el1k21*el2k21
32345  & +dd*(el1k11*el2k21+el1k21*el2k11))
32346  ENDIF
32347  facqqg=comfac*ff*facqqg
32348  ENDIF
32349 C...Split total contribution into different colour flows just like
32350 C...in ISUB.EQ.28 [f + g -> f + g (q + g -> q + g only)]
32351 C...(recalculate kinematics for massless partons).
32352  thp=-0.5d0*sh*(1d0-cth)
32353  uhp=-0.5d0*sh*(1d0+cth)
32354  facqg1=9d0/4d0*(uhp/thp)**2-uhp/sh
32355  facqg2=9d0/4d0*(sh/thp)**2-sh/uhp
32356  facqgs=facqg1+facqg2
32357  DO 2442 i=mmina,mmaxa
32358  IF(i.EQ.0.OR.iabs(i).GT.mstp(58)) goto 2442
32359  DO 2441 isde=1,2
32360  IF(isde.EQ.1.AND.kfac(1,i)*kfac(2,21).EQ.0) goto 2441
32361  IF(isde.EQ.2.AND.kfac(1,21)*kfac(2,i).EQ.0) goto 2441
32362  nchn=nchn+1
32363  isig(nchn,isde)=i
32364  isig(nchn,3-isde)=21
32365  isig(nchn,3)=1
32366  sigh(nchn)=facqqg*parp(ionium+2)*facqg1/facqgs
32367  nchn=nchn+1
32368  isig(nchn,isde)=i
32369  isig(nchn,3-isde)=21
32370  isig(nchn,3)=2
32371  sigh(nchn)=facqqg*parp(ionium+2)*facqg2/facqgs
32372  2441 CONTINUE
32373  2442 CONTINUE
32374 
32375  ELSEIF(isub.EQ.426) THEN
32376 C...q + g -> q + QQ~[1S08]
32377  IF(mstp(145).EQ.0) THEN
32378  facqqg=-comfac*paru(1)*as**3*(5d0/18d0)*
32379  & (sh2+uh2)/(sqmqqr*th*uhsh2)
32380  ELSE
32381  fa=-paru(1)*as**3*(5d0/54d0)*(sh2+uh2)/(sqmqqr*th*uhsh2)
32382  IF(mstp(147).EQ.0) THEN
32383  facqqg=comfac*fa
32384  ELSEIF(mstp(147).EQ.1) THEN
32385  facqqg=comfac*2d0*fa
32386  ELSEIF(mstp(147).EQ.3) THEN
32387  facqqg=comfac*fa
32388  ELSEIF(mstp(147).EQ.4) THEN
32389  facqqg=comfac*fa
32390  ELSEIF(mstp(147).EQ.5) THEN
32391  facqqg=0d0
32392  ELSEIF(mstp(147).EQ.6) THEN
32393  facqqg=0d0
32394  ENDIF
32395  ENDIF
32396 C...Split total contribution into different colour flows just like
32397 C...in ISUB.EQ.28 [f + g -> f + g (q + g -> q + g only)]
32398 C...(recalculate kinematics for massless partons).
32399  thp=-0.5d0*sh*(1d0-cth)
32400  uhp=-0.5d0*sh*(1d0+cth)
32401  facqg1=9d0/4d0*(uhp/thp)**2-uhp/sh
32402  facqg2=9d0/4d0*(sh/thp)**2-sh/uhp
32403  facqgs=facqg1+facqg2
32404  DO 2444 i=mmina,mmaxa
32405  IF(i.EQ.0.OR.iabs(i).GT.mstp(58)) goto 2444
32406  DO 2443 isde=1,2
32407  IF(isde.EQ.1.AND.kfac(1,i)*kfac(2,21).EQ.0) goto 2443
32408  IF(isde.EQ.2.AND.kfac(1,21)*kfac(2,i).EQ.0) goto 2443
32409  nchn=nchn+1
32410  isig(nchn,isde)=i
32411  isig(nchn,3-isde)=21
32412  isig(nchn,3)=1
32413  sigh(nchn)=facqqg*parp(ionium+3)*facqg1/facqgs
32414  nchn=nchn+1
32415  isig(nchn,isde)=i
32416  isig(nchn,3-isde)=21
32417  isig(nchn,3)=2
32418  sigh(nchn)=facqqg*parp(ionium+3)*facqg2/facqgs
32419  2443 CONTINUE
32420  2444 CONTINUE
32421 
32422  ELSEIF(isub.EQ.427) THEN
32423 C...q + g -> q + QQ~[3PJ8]
32424  IF(mstp(145).EQ.0) THEN
32425  facqqg=-comfac*paru(1)*as**3*(10d0/9d0)*
32426  & ((7d0*uhsh+8d0*th)*(sh2+uh2)
32427  & +4d0*th*(2d0*sqmqq**2-shth2-thuh2))/
32428  & (sqmqq*sqmqqr*th*uhsh2*uhsh)
32429  ELSE
32430  ff=10d0*paru(1)*as**3/
32431  & (9d0*sqmqq*sqmqqr*th2*uhsh2*uhsh)
32432  aa=th*uhsh*(2d0*sqmqq**2+shth2+thuh2)
32433  bb=8d0*(shth2+th*uh)
32434  cc=8d0*uhsh*(shth+thuh)
32435  dd=4d0*(2d0*sqmqq*sh+th*uhsh)
32436  IF(mstp(147).EQ.0) THEN
32437  facqqg=-aa+sqmqq*(bb*el1k10*el2k10+cc*el1k20*el2k20
32438  & +dd*(el1k10*el2k20+el1k20*el2k10))
32439  ELSEIF(mstp(147).EQ.1) THEN
32440  facqqg=2d0*(-aa+sqmqq*(bb*el1k11*el2k11+cc*el1k21*el2k21
32441  & +dd*(el1k11*el2k21+el1k21*el2k11)))
32442  ELSEIF(mstp(147).EQ.3) THEN
32443  facqqg=-aa+sqmqq*(bb*el1k10*el2k10+cc*el1k20*el2k20
32444  & +dd*(el1k10*el2k20+el1k20*el2k10))
32445  ELSEIF(mstp(147).EQ.4) THEN
32446  facqqg=-aa+sqmqq*(bb*el1k11*el2k11+cc*el1k21*el2k21
32447  & +dd*(el1k11*el2k21+el1k21*el2k11))
32448  ELSEIF(mstp(147).EQ.5) THEN
32449  facqqg=sqmqq*(bb*el1k11*el2k10+cc*el1k21*el2k20
32450  & +dd*(el1k11*el2k20+el1k21*el2k10))
32451  ELSEIF(mstp(147).EQ.6) THEN
32452  facqqg=sqmqq*(bb*el1k11*el2k11+cc*el1k21*el2k21
32453  & +dd*(el1k11*el2k21+el1k21*el2k11))
32454  ENDIF
32455  facqqg=comfac*ff*facqqg
32456  ENDIF
32457 C...Split total contribution into different colour flows just like
32458 C...in ISUB.EQ.28 [f + g -> f + g (q + g -> q + g only)]
32459 C...(recalculate kinematics for massless partons).
32460  thp=-0.5d0*sh*(1d0-cth)
32461  uhp=-0.5d0*sh*(1d0+cth)
32462  facqg1=9d0/4d0*(uhp/thp)**2-uhp/sh
32463  facqg2=9d0/4d0*(sh/thp)**2-sh/uhp
32464  facqgs=facqg1+facqg2
32465  DO 2446 i=mmina,mmaxa
32466  IF(i.EQ.0.OR.iabs(i).GT.mstp(58)) goto 2446
32467  DO 2445 isde=1,2
32468  IF(isde.EQ.1.AND.kfac(1,i)*kfac(2,21).EQ.0) goto 2445
32469  IF(isde.EQ.2.AND.kfac(1,21)*kfac(2,i).EQ.0) goto 2445
32470  nchn=nchn+1
32471  isig(nchn,isde)=i
32472  isig(nchn,3-isde)=21
32473  isig(nchn,3)=1
32474  sigh(nchn)=facqqg*parp(ionium+4)*facqg1/facqgs
32475  nchn=nchn+1
32476  isig(nchn,isde)=i
32477  isig(nchn,3-isde)=21
32478  isig(nchn,3)=2
32479  sigh(nchn)=facqqg*parp(ionium+4)*facqg2/facqgs
32480  2445 CONTINUE
32481  2446 CONTINUE
32482 
32483  ELSEIF(isub.EQ.428) THEN
32484 C...q + q~ -> g + QQ~[3S18]
32485  IF(mstp(145).EQ.0) THEN
32486  facqqg=comfac*paru(1)*as**3*(8d0/81d0)*
32487  & (4d0*(th2+uh2)-th*uh)*(shth2+uhsh2)/
32488  & (sqmqq*sqmqqr*th*uh*thuh2)
32489  ELSE
32490  ff=-4d0*paru(1)*as**3*(4d0*(th2+uh2)-th*uh)/
32491  & (81d0*sqmqq*sqmqqr*th*uh*thuh2)
32492  aa=shth2+uhsh2
32493  bb=4d0
32494  cc=4d0
32495  dd=0d0
32496  IF(mstp(147).EQ.0) THEN
32497  facqqg=-aa+sqmqq*(bb*el1k10*el2k10+cc*el1k20*el2k20
32498  & +dd*(el1k10*el2k20+el1k20*el2k10))
32499  ELSEIF(mstp(147).EQ.1) THEN
32500  facqqg=2d0*(-aa+sqmqq*(bb*el1k11*el2k11+cc*el1k21*el2k21
32501  & +dd*(el1k11*el2k21+el1k21*el2k11)))
32502  ELSEIF(mstp(147).EQ.3) THEN
32503  facqqg=-aa+sqmqq*(bb*el1k10*el2k10+cc*el1k20*el2k20
32504  & +dd*(el1k10*el2k20+el1k20*el2k10))
32505  ELSEIF(mstp(147).EQ.4) THEN
32506  facqqg=-aa+sqmqq*(bb*el1k11*el2k11+cc*el1k21*el2k21
32507  & +dd*(el1k11*el2k21+el1k21*el2k11))
32508  ELSEIF(mstp(147).EQ.5) THEN
32509  facqqg=sqmqq*(bb*el1k11*el2k10+cc*el1k21*el2k20
32510  & +dd*(el1k11*el2k20+el1k21*el2k10))
32511  ELSEIF(mstp(147).EQ.6) THEN
32512  facqqg=sqmqq*(bb*el1k11*el2k11+cc*el1k21*el2k21
32513  & +dd*(el1k11*el2k21+el1k21*el2k11))
32514  ENDIF
32515  facqqg=comfac*ff*facqqg
32516  ENDIF
32517 C...Split total contribution into different colour flows just like
32518 C...in ISUB.EQ.13 [f + fbar -> g + g (q + qbar -> g + g only)]
32519 C...(recalculate kinematics for massless partons).
32520  thp=-0.5d0*sh*(1d0-cth)
32521  uhp=-0.5d0*sh*(1d0+cth)
32522  facgg1=uh/th-9d0/4d0*uh2/sh2
32523  facgg2=th/uh-9d0/4d0*th2/sh2
32524  facggs=facgg1+facgg2
32525  DO 2447 i=mmina,mmaxa
32526  IF(i.EQ.0.OR.iabs(i).GT.mstp(58).OR.
32527  & kfac(1,i)*kfac(2,-i).EQ.0) goto 2447
32528  nchn=nchn+1
32529  isig(nchn,1)=i
32530  isig(nchn,2)=-i
32531  isig(nchn,3)=1
32532  sigh(nchn)=facqqg*parp(ionium+2)*facgg1/facggs
32533  nchn=nchn+1
32534  isig(nchn,1)=i
32535  isig(nchn,2)=-i
32536  isig(nchn,3)=2
32537  sigh(nchn)=facqqg*parp(ionium+2)*facgg2/facggs
32538  2447 CONTINUE
32539 
32540  ELSEIF(isub.EQ.429) THEN
32541 C...q + q~ -> g + QQ~[1S08]
32542  IF(mstp(145).EQ.0) THEN
32543  facqqg=comfac*paru(1)*as**3*(20d0/27d0)*
32544  & (th2+uh2)/(sqmqqr*sh*thuh2)
32545  ELSE
32546  fa=paru(1)*as**3*(20d0/81d0)*(th2+uh2)/(sqmqqr*sh*thuh2)
32547  IF(mstp(147).EQ.0) THEN
32548  facqqg=comfac*fa
32549  ELSEIF(mstp(147).EQ.1) THEN
32550  facqqg=comfac*2d0*fa
32551  ELSEIF(mstp(147).EQ.3) THEN
32552  facqqg=comfac*fa
32553  ELSEIF(mstp(147).EQ.4) THEN
32554  facqqg=comfac*fa
32555  ELSEIF(mstp(147).EQ.5) THEN
32556  facqqg=0d0
32557  ELSEIF(mstp(147).EQ.6) THEN
32558  facqqg=0d0
32559  ENDIF
32560  ENDIF
32561 C...Split total contribution into different colour flows just like
32562 C...in ISUB.EQ.13 [f + fbar -> g + g (q + qbar -> g + g only)]
32563 C...(recalculate kinematics for massless partons).
32564  thp=-0.5d0*sh*(1d0-cth)
32565  uhp=-0.5d0*sh*(1d0+cth)
32566  facgg1=uh/th-9d0/4d0*uh2/sh2
32567  facgg2=th/uh-9d0/4d0*th2/sh2
32568  facggs=facgg1+facgg2
32569  DO 2448 i=mmina,mmaxa
32570  IF(i.EQ.0.OR.iabs(i).GT.mstp(58).OR.
32571  & kfac(1,i)*kfac(2,-i).EQ.0) goto 2448
32572  nchn=nchn+1
32573  isig(nchn,1)=i
32574  isig(nchn,2)=-i
32575  isig(nchn,3)=1
32576  sigh(nchn)=facqqg*parp(ionium+3)*facgg1/facggs
32577  nchn=nchn+1
32578  isig(nchn,1)=i
32579  isig(nchn,2)=-i
32580  isig(nchn,3)=2
32581  sigh(nchn)=facqqg*parp(ionium+3)*facgg2/facggs
32582  2448 CONTINUE
32583 
32584  ELSEIF(isub.EQ.430) THEN
32585 C...q + q~ -> g + QQ~[3PJ8]
32586  IF(mstp(145).EQ.0) THEN
32587  facqqg=comfac*paru(1)*as**3*(80d0/27d0)*
32588  & ((7d0*thuh+8d0*sh)*(th2+uh2)
32589  & +4d0*sh*(2d0*sqmqq**2-shth2-uhsh2))/
32590  & (sqmqq*sqmqqr*sh*thuh2*thuh)
32591  ELSE
32592  ff=-80d0*paru(1)*as**3/(27d0*sqmqq*sqmqqr*sh2*thuh2*thuh)
32593  aa=sh*thuh*(2d0*sqmqq**2+shth2+uhsh2)
32594  bb=8d0*(uhsh2+sh*th)
32595  cc=8d0*(shth2+sh*uh)
32596  dd=4d0*(shth2+uhsh2+sh*sqmqq-sqmqq**2)
32597  IF(mstp(147).EQ.0) THEN
32598  facqqg=-aa+sqmqq*(bb*el1k10*el2k10+cc*el1k20*el2k20
32599  & +dd*(el1k10*el2k20+el1k20*el2k10))
32600  ELSEIF(mstp(147).EQ.1) THEN
32601  facqqg=2d0*(-aa+sqmqq*(bb*el1k11*el2k11+cc*el1k21*el2k21
32602  & +dd*(el1k11*el2k21+el1k21*el2k11)))
32603  ELSEIF(mstp(147).EQ.3) THEN
32604  facqqg=-aa+sqmqq*(bb*el1k10*el2k10+cc*el1k20*el2k20
32605  & +dd*(el1k10*el2k20+el1k20*el2k10))
32606  ELSEIF(mstp(147).EQ.4) THEN
32607  facqqg=-aa+sqmqq*(bb*el1k11*el2k11+cc*el1k21*el2k21
32608  & +dd*(el1k11*el2k21+el1k21*el2k11))
32609  ELSEIF(mstp(147).EQ.5) THEN
32610  facqqg=sqmqq*(bb*el1k11*el2k10+cc*el1k21*el2k20
32611  & +dd*(el1k11*el2k20+el1k21*el2k10))
32612  ELSEIF(mstp(147).EQ.6) THEN
32613  facqqg=sqmqq*(bb*el1k11*el2k11+cc*el1k21*el2k21
32614  & +dd*(el1k11*el2k21+el1k21*el2k11))
32615  ENDIF
32616  facqqg=comfac*ff*facqqg
32617  ENDIF
32618 C...Split total contribution into different colour flows just like
32619 C...in ISUB.EQ.13 [f + fbar -> g + g (q + qbar -> g + g only)]
32620 C...(recalculate kinematics for massless partons).
32621  thp=-0.5d0*sh*(1d0-cth)
32622  uhp=-0.5d0*sh*(1d0+cth)
32623  facgg1=uh/th-9d0/4d0*uh2/sh2
32624  facgg2=th/uh-9d0/4d0*th2/sh2
32625  facggs=facgg1+facgg2
32626  DO 2449 i=mmina,mmaxa
32627  IF(i.EQ.0.OR.iabs(i).GT.mstp(58).OR.
32628  & kfac(1,i)*kfac(2,-i).EQ.0) goto 2449
32629  nchn=nchn+1
32630  isig(nchn,1)=i
32631  isig(nchn,2)=-i
32632  isig(nchn,3)=1
32633  sigh(nchn)=facqqg*parp(ionium+4)*facgg1/facggs
32634  nchn=nchn+1
32635  isig(nchn,1)=i
32636  isig(nchn,2)=-i
32637  isig(nchn,3)=2
32638  sigh(nchn)=facqqg*parp(ionium+4)*facgg2/facggs
32639  2449 CONTINUE
32640 
32641  ELSEIF(isub.EQ.431) THEN
32642 C...g + g -> QQ~[3P01] + g
32643  pgtw=(sh*th+th*uh+uh*sh)/sh2
32644  qgtw=(sh*th*uh)/sh**3
32645  rgtw=sqmqq/sh
32646  IF(mstp(145).EQ.0) THEN
32647  facqqg=comfac*paru(1)*as**3*8d0/(9d0*sqmqqr*sh)*
32648  & (9d0*rgtw**2*pgtw**4*
32649  & (rgtw**4-2d0*rgtw**2*pgtw+pgtw**2)
32650  & -6d0*rgtw*pgtw**3*qgtw*
32651  & (2d0*rgtw**4-5d0*rgtw**2*pgtw+pgtw**2)
32652  & -pgtw**2*qgtw**2*(rgtw**4+2d0*rgtw**2*pgtw-pgtw**2)
32653  & +2d0*rgtw*pgtw*qgtw**3*(rgtw**2-pgtw)
32654  & +6d0*rgtw**2*qgtw**4)/(qgtw*(qgtw-rgtw*pgtw)**4)
32655  ELSE
32656  fc1=paru(1)*as**3*8d0/(27d0*sqmqqr*sh)*
32657  & (9d0*rgtw**2*pgtw**4*
32658  & (rgtw**4-2d0*rgtw**2*pgtw+pgtw**2)
32659  & -6d0*rgtw*pgtw**3*qgtw*
32660  & (2d0*rgtw**4-5d0*rgtw**2*pgtw+pgtw**2)
32661  & -pgtw**2*qgtw**2*(rgtw**4+2d0*rgtw**2*pgtw-pgtw**2)
32662  & +2d0*rgtw*pgtw*qgtw**3*(rgtw**2-pgtw)
32663  & +6d0*rgtw**2*qgtw**4)/(qgtw*(qgtw-rgtw*pgtw)**4)
32664  IF(mstp(147).EQ.0) THEN
32665  facqqg=comfac*fc1
32666  ELSEIF(mstp(147).EQ.1) THEN
32667  facqqg=comfac*2d0*fc1
32668  ELSEIF(mstp(147).EQ.3) THEN
32669  facqqg=comfac*fc1
32670  ELSEIF(mstp(147).EQ.4) THEN
32671  facqqg=comfac*fc1
32672  ELSEIF(mstp(147).EQ.5) THEN
32673  facqqg=0d0
32674  ELSEIF(mstp(147).EQ.6) THEN
32675  facqqg=0d0
32676  ENDIF
32677  ENDIF
32678  IF(kfac(1,21)*kfac(2,21).NE.0) THEN
32679  nchn=nchn+1
32680  isig(nchn,1)=21
32681  isig(nchn,2)=21
32682  isig(nchn,3)=1
32683  sigh(nchn)=facqqg*parp(ionium+5)
32684  ENDIF
32685 
32686  ELSEIF(isub.EQ.432) THEN
32687 C...g + g -> QQ~[3P11] + g
32688  pgtw=(sh*th+th*uh+uh*sh)/sh2
32689  qgtw=(sh*th*uh)/sh**3
32690  rgtw=sqmqq/sh
32691  IF(mstp(145).EQ.0) THEN
32692  facqqg=comfac*paru(1)*as**3*8d0/(3d0*sqmqqr*sh)*
32693  & pgtw**2*(rgtw*pgtw**2*(rgtw**2-4d0*pgtw)
32694  & +2d0*qgtw*(-rgtw**4+5d0*rgtw**2*pgtw+pgtw**2)
32695  & -15d0*rgtw*qgtw**2)/(qgtw-rgtw*pgtw)**4
32696  ELSE
32697  ff=4d0/3d0*paru(1)*as**3*sqmqqr/shth2**2/thuh2**2/uhsh2**2
32698  c1=(4d0*pgtw**5+23d0*pgtw**2*qgtw**2
32699  & +(-14d0*pgtw**3*qgtw+3d0*qgtw**3)*rgtw
32700  & -(pgtw**4+2d0*pgtw*qgtw**2)*rgtw**2
32701  & +3d0*pgtw**2*qgtw*rgtw**3)*sh2**5
32702  c2=2d0*shth2*(sh2*thuh*(sh*thuh*(sh-th)*(sh-uh)
32703  & -th*uh*(th-uh)**2)+sh2**2*(th-uh)*(th2+uh2-sh*thuh)
32704  & *(pgtw**2-qgtw*(sh+2d0*uh)/sh))
32705  c3=2d0*uhsh2*(sh2*thuh*(sh*thuh*(sh-th)*(sh-uh)
32706  & -th*uh*(th-uh)**2)-sh2**2*(th-uh)*(th2+uh2-sh*thuh)
32707  & *(pgtw**2-qgtw*(sh+2d0*th)/sh))
32708  c4=-4d0*thuh*(th-uh)**2*
32709  & (th**3*uh**3+sh2**2*(2d0*th+uh)*(th+2d0*uh)
32710  & -sh2*th*uh*(th2+uh2))
32711  & +4d0*thuh2*(sh**3*(sh2**2+th2**2+uh2**2)
32712  & -sh*th*uh*(sh2**2+th*uh*(th2-3d0*th*uh+uh2)
32713  & +sh2*(5d0*thuh2-17d0*th*uh)))
32714  IF(mstp(147).EQ.0) THEN
32715  facqqg=-c1+c2*el1k10*el2k10+c3*el1k20*el2k20
32716  & +c4*(el1k10*el2k20+el1k20*el2k10)/2d0
32717  ELSEIF(mstp(147).EQ.1) THEN
32718  facqqg=2d0*(-c1+c2*el1k11*el2k11+c3*el1k21*el2k21
32719  & +c4*(el1k11*el2k21+el1k21*el2k11)/2d0)
32720  ELSEIF(mstp(147).EQ.3) THEN
32721  facqqg=-c1+c2*el1k10*el2k10+c3*el1k20*el2k20
32722  & +c4*(el1k10*el2k20+el1k20*el2k10)/2d0
32723  ELSEIF(mstp(147).EQ.4) THEN
32724  facqqg=-c1+c2*el1k11*el2k11+c3*el1k21*el2k21
32725  & +c4*(el1k11*el2k21+el1k21*el2k11)/2d0
32726  ELSEIF(mstp(147).EQ.5) THEN
32727  facqqg=c2*el1k11*el2k10+c3*el1k21*el2k20
32728  & +c4*(el1k11*el2k20+el1k21*el2k10)/2d0
32729  ELSEIF(mstp(147).EQ.6) THEN
32730  facqqg=c2*el1k11*el2k11+c3*el1k21*el2k21
32731  & +c4*(el1k11*el2k21+el1k21*el2k11)/2d0
32732  ENDIF
32733  facqqg=comfac*ff*facqqg
32734  ENDIF
32735  IF(kfac(1,21)*kfac(2,21).NE.0) THEN
32736  nchn=nchn+1
32737  isig(nchn,1)=21
32738  isig(nchn,2)=21
32739  isig(nchn,3)=1
32740  sigh(nchn)=facqqg*parp(ionium+5)
32741  ENDIF
32742 
32743  ELSEIF(isub.EQ.433) THEN
32744 C...g + g -> QQ~[3P21] + g
32745  pgtw=(sh*th+th*uh+uh*sh)/sh2
32746  qgtw=(sh*th*uh)/sh**3
32747  rgtw=sqmqq/sh
32748  IF(mstp(145).EQ.0) THEN
32749  facqqg=comfac*paru(1)*as**3*8d0/(9d0*sqmqqr*sh)*
32750  & (12d0*rgtw**2*pgtw**4*
32751  & (rgtw**4-2d0*rgtw**2*pgtw+pgtw**2)
32752  & -3d0*rgtw*pgtw**3*qgtw*
32753  & (8d0*rgtw**4-rgtw**2*pgtw+4d0*pgtw**2)
32754  & +2d0*pgtw**2*qgtw**2*
32755  & (-7d0*rgtw**4+43d0*rgtw**2*pgtw+pgtw**2)
32756  & +rgtw*pgtw*qgtw**3*(16d0*rgtw**2-61d0*pgtw)
32757  & +12d0*rgtw**2*qgtw**4)/(qgtw*(qgtw-rgtw*pgtw)**4)
32758  ELSE
32759  ff=(16d0*paru(1)*as**3*sqmqq*sqmqqr)/
32760  & (3d0*sh2*th2*uh2*shth2**2*thuh2**2*uhsh2**2)
32761  c1=pgtw**2*qgtw*(pgtw*rgtw-qgtw)**2*(rgtw**2-2d0*pgtw)
32762  & *sh*sh2**7
32763  c2=2d0*shth2*(-sh2**3*th2**3-sh**5*th**5*uh*shth
32764  & +sh2**2*th2**2*uh2*(8d0*shth2-5d0*sh*th)
32765  & +sh**3*th**3*uh**3*shth*(17d0*shth2-2d0*sh*th)
32766  & +sh2*th2*uh2**2*(105d0*sh2*th2+64d0*sh*th*(sh2+th2)
32767  & +10d0*(sh2**2+th2**2))
32768  & +sh2*th2*uh**5*shth*(32d0*shth2+7d0*sh*th)
32769  & -uh2**3*(sh2**3-87d0*sh**3*th**3+th2**3
32770  & -45d0*sh2*th2*(sh2+th2)-5d0*sh*th*(sh2**2+th2**2))
32771  & +sh*th*uh**7*shth*(7d0*shth2+12d0*sh*th)
32772  & +4d0*sh*th*uh2**4*shth2)
32773  c3=2d0*uhsh2*(-sh2**3*uh2**3-sh**5*uh**5*th*uhsh
32774  & +sh2**2*uh2**2*th2*(8d0*uhsh2-5d0*sh*uh)
32775  & +sh**3*uh**3*th**3*uhsh*(17d0*uhsh2-2d0*sh*uh)
32776  & +sh2*uh2*th2**2*(105d0*sh2*uh2+64d0*sh*uh*(sh2+uh2)
32777  & +10d0*(sh2**2+uh2**2))
32778  & +sh2*uh2*th**5*uhsh*(32d0*uhsh2+7d0*sh*uh)
32779  & -th2**3*(sh2**3-87d0*sh**3*uh**3+uh2**3
32780  & -45d0*sh2*uh2*(sh2+uh2)-5d0*sh*uh*(sh2**2+uh2**2))
32781  & +sh*uh*th**7*uhsh*(7d0*uhsh2+12d0*sh*uh)
32782  & +4d0*sh*uh*th2**4*uhsh2)
32783  c4=-2d0*shth*uhsh*(-2d0*th2**3*uh2**3
32784  & -sh**5*th2*uh2*thuh*(5d0*th+3d0*uh)*(3d0*th+5d0*uh)
32785  & +sh2**3*(2d0*th+uh)*(th+2d0*uh)*(th2-uh2)**2
32786  & -sh*th2**2*uh2**2*thuh*(5d0*thuh2-4d0*th*uh)
32787  & -sh2*th**3*uh**3*thuh2*(13d0*thuh2-16d0*th*uh)
32788  & -sh**3*th2*uh2*(92d0*th2*uh2*thuh
32789  & +53d0*th*uh*(th**3+uh**3)+11d0*(th**5+uh**5))
32790  & -sh2**2*th*uh*(114d0*th**3*uh**3
32791  & +83d0*th2*uh2*(th2+uh2)+28d0*th*uh*(th2**2+uh2**2)
32792  & +3d0*(th2**3+uh2**3)))
32793  c5=4d0*sh*th*uh2*shth2*(2d0*sh*th+sh*uh+th*uh)**2
32794  & *(2d0*uh*sqmqq**2+shth*(sh*th-uh2))
32795  c6=4d0*sh*uh*th2*uhsh2*(2d0*sh*uh+sh*th+th*uh)**2
32796  & *(2d0*th*sqmqq**2+uhsh*(sh*uh-th2))
32797  c7=4d0*sh*th*uh2*shth*(sh2**2*th**3*(11d0*sh+16d0*th)
32798  & +sh**3*th2*uh*(31d0*sh2+83d0*sh*th+61d0*th2)
32799  & +sh2*th*uh2*(19d0*sh**3+110d0*sh2*th+156d0*sh*th2+
32800  & 82d0*th**3)
32801  & +sh*th*uh**3*(43d0*sh**3+132d0*sh2*th+124d0*sh*th2
32802  & +45d0*th**3)
32803  & +th*uh2**2*(37d0*sh**3+68d0*sh2*th+43d0*sh*th2+
32804  & 8d0*th**3)
32805  & +th*uh**5*(11d0*sh2+13d0*sh*th+5d0*th2)
32806  & +sh**3*uh**3*(3d0*uhsh2-2d0*sh*uh)
32807  & +th**5*uhsh*(5d0*uhsh2+2d0*sh*uh))
32808  c8=4d0*sh*uh*th2*uhsh*(sh2**2*uh**3*(11d0*sh+16d0*uh)
32809  & +sh**3*uh2*th*(31d0*sh2+83d0*sh*uh+61d0*uh2)
32810  & +sh2*uh*th2*(19d0*sh**3+110d0*sh2*uh+156d0*sh*uh2+
32811  & 82d0*uh**3)
32812  & +sh*uh*th**3*(43d0*sh**3+132d0*sh2*uh+124d0*sh*uh2
32813  & +45d0*uh**3)
32814  & +uh*th2**2*(37d0*sh**3+68d0*sh2*uh+43d0*sh*uh2+
32815  & 8d0*uh**3)
32816  & +uh*th**5*(11d0*sh2+13d0*sh*uh+5d0*uh2)
32817  & +sh**3*th**3*(3d0*shth2-2d0*sh*th)
32818  & +uh**5*shth*(5d0*shth2+2d0*sh*th))
32819  c9=4d0*shth*uhsh*(2d0*th**5*uh**5*thuh
32820  & +4d0*sh*th2**2*uh2**2*thuh2
32821  & -sh2*th**3*uh**3*thuh*(th2+uh2)
32822  & -2d0*sh**3*th2*uh2*(thuh2**2+2d0*th*uh*thuh2-th2*uh2)
32823  & +sh2**2*th*uh*thuh*(-th*uh*thuh2+3d0*(th2**2+uh2**2))
32824  & +sh**5*(4d0*th2*uh2*(thuh2-th*uh)
32825  & +5d0*th*uh*(th2**2+uh2**2)+2d0*(th2**3+uh2**3)))
32826  c0=-4d0*(2d0*th2**3*uh2**3*sqmqq
32827  & -sh2*th2**2*uh2**2*thuh*(19d0*thuh2-4d0*th*uh)
32828  & -sh**3*th**3*uh**3*thuh2*(32d0*thuh2+29d0*th*uh)
32829  & -sh2**2*th2*uh2*thuh*(264d0*th2*uh2
32830  & +136d0*th*uh*(th2+uh2)+15d0*(th2**2+uh2**2))
32831  & +sh**5*th*uh*(-428d0*th**3*uh**3
32832  & -256d0*th2*uh2*(th2+uh2)-43d0*th*uh*(th2**2+uh2**2)
32833  & +2d0*(th2**3+uh2**3))
32834  & +sh**7*(-46d0*th**3*uh**3-21d0*th2*uh2*(th2+uh2)
32835  & +2d0*th*uh*(th2**2+uh2**2)+2d0*(th2**3+uh2**3))
32836  & +sh2**3*thuh*(-134*th**3*uh**3-53d0*th2*uh2*(th2+uh2)
32837  & +4d0*th*uh*(th2**2+uh2**2)+2d0*(th2**3+uh2**3)))
32838  IF(mstp(147).EQ.0) THEN
32839  facqqg=1d0/3d0*(c1*3d0
32840  & -c2*(2d0*el1k10*el2k10+el1k11*el2k11)
32841  & -c3*(2d0*el1k20*el2k20+el1k21*el2k21)
32842  & -c4*(2d0*el1k10*el2k20+el1k11*el2k21)
32843  & +c5*2d0*(el1k10*el2k10-el1k11*el2k11)**2
32844  & +c6*2d0*(el1k20*el2k20-el1k21*el2k21)**2
32845  & +c7*2d0*(el1k10*el2k10-el1k11*el2k11)
32846  & *(el1k10*el2k20-el1k11*el2k21)
32847  & +c8*2d0*(el1k20*el2k20-el1k21*el2k21)
32848  & *(el1k10*el2k20-el1k11*el2k21)
32849  & +c9*2d0*(el1k10*el2k10-el1k11*el2k11)
32850  & *(el1k20*el2k20-el1k21*el2k21)
32851  & +c0*2d0*(el1k10*el2k20-el1k11*el2k21)**2)
32852  ELSEIF(mstp(147).EQ.1) THEN
32853  facqqg=c1*2d0
32854  & -c2*(el1k10*el2k10+el1k11*el2k11)
32855  & -c3*(el1k20*el2k20+el1k21*el2k21)
32856  & -c4*(el1k10*el2k20+el1k11*el2k21)
32857  & +c5*4d0*el1k10*el2k10*el1k11*el2k11
32858  & +c6*4d0*el1k20*el2k20*el1k21*el2k21
32859  & +c7*2d0*(el1k10*el2k10*el1k11*el2k21
32860  & +el1k10*el2k20*el1k11*el2k11)
32861  & +c8*2d0*(el1k20*el2k20*el1k11*el2k21
32862  & +el1k10*el2k20*el1k21*el2k21)
32863  & +c9*4d0*el1k10*el2k20*el1k11*el2k21
32864  & +c0*(el1k10*el2k10*el1k21*el2k21
32865  & +2d0*el1k10*el2k20*el1k11*el2k21
32866  & +el1k20*el2k20*el1k11*el2k11)
32867  ELSEIF(mstp(147).EQ.2) THEN
32868  facqqg=2d0*(c1
32869  & -c2*el1k11*el2k11
32870  & -c3*el1k21*el2k21
32871  & -c4*el1k11*el2k21
32872  & +c5*(el1k11*el2k11)**2
32873  & +c6*(el1k21*el2k21)**2
32874  & +c7*el1k11*el2k11*el1k11*el2k21
32875  & +c8*el1k21*el2k21*el1k11*el2k21
32876  & +(c9+c0)*(el1k11*el2k21)**2)
32877  ENDIF
32878  facqqg=comfac*ff*facqqg
32879  ENDIF
32880  IF(kfac(1,21)*kfac(2,21).NE.0) THEN
32881  nchn=nchn+1
32882  isig(nchn,1)=21
32883  isig(nchn,2)=21
32884  isig(nchn,3)=1
32885  sigh(nchn)=facqqg*parp(ionium+5)
32886  ENDIF
32887 
32888  ELSEIF(isub.EQ.434) THEN
32889 C...q + g -> q + QQ~[3P01]
32890  IF(mstp(145).EQ.0) THEN
32891  facqqg=-comfac*paru(1)*as**3*(16d0/81d0)*
32892  & (th-3d0*sqmqq)**2*(sh2+uh2)/(sqmqqr*th*uhsh2**2)
32893  ELSE
32894  fa=-paru(1)*as**3*(16d0/243d0)*
32895  & (th-3d0*sqmqq)**2*(sh2+uh2)/(sqmqqr*th*uhsh2**2)
32896  IF(mstp(147).EQ.0) THEN
32897  facqqg=comfac*fa
32898  ELSEIF(mstp(147).EQ.1) THEN
32899  facqqg=comfac*2d0*fa
32900  ELSEIF(mstp(147).EQ.3) THEN
32901  facqqg=comfac*fa
32902  ELSEIF(mstp(147).EQ.4) THEN
32903  facqqg=comfac*fa
32904  ELSEIF(mstp(147).EQ.5) THEN
32905  facqqg=0d0
32906  ELSEIF(mstp(147).EQ.6) THEN
32907  facqqg=0d0
32908  ENDIF
32909  ENDIF
32910  DO 2452 i=mmina,mmaxa
32911  IF(i.EQ.0.OR.iabs(i).GT.mstp(58)) goto 2452
32912  DO 2451 isde=1,2
32913  IF(isde.EQ.1.AND.kfac(1,i)*kfac(2,21).EQ.0) goto 2451
32914  IF(isde.EQ.2.AND.kfac(1,21)*kfac(2,i).EQ.0) goto 2451
32915  nchn=nchn+1
32916  isig(nchn,isde)=i
32917  isig(nchn,3-isde)=21
32918  isig(nchn,3)=1
32919  sigh(nchn)=facqqg*parp(ionium+5)
32920  2451 CONTINUE
32921  2452 CONTINUE
32922 
32923  ELSEIF(isub.EQ.435) THEN
32924 C...q + g -> q + QQ~[3P11]
32925  IF(mstp(145).EQ.0) THEN
32926  facqqg=-comfac*paru(1)*as**3*(32d0/27d0)*
32927  & (4d0*sqmqq*sh*uh+th*(sh2+uh2))/(sqmqqr*uhsh2**2)
32928  ELSE
32929  ff=(64d0*paru(1)*as**3*sqmqqr)/(27d0*uhsh2**2)
32930  c1=sh*uh
32931  c2=2d0*sh
32932  c3=0d0
32933  c4=2d0*(sh-uh)
32934  IF(mstp(147).EQ.0) THEN
32935  facqqg=-c1+c2*el1k10*el2k10+c3*el1k20*el2k20
32936  & +c4*(el1k10*el2k20+el1k20*el2k10)/2d0
32937  ELSEIF(mstp(147).EQ.1) THEN
32938  facqqg=2d0*(-c1+c2*el1k11*el2k11+c3*el1k21*el2k21
32939  & +c4*(el1k11*el2k21+el1k21*el2k11)/2d0)
32940  ELSEIF(mstp(147).EQ.3) THEN
32941  facqqg=-c1+c2*el1k10*el2k10+c3*el1k20*el2k20
32942  & +c4*(el1k10*el2k20+el1k20*el2k10)/2d0
32943  ELSEIF(mstp(147).EQ.4) THEN
32944  facqqg=-c1+c2*el1k11*el2k11+c3*el1k21*el2k21
32945  & +c4*(el1k11*el2k21+el1k21*el2k11)/2d0
32946  ELSEIF(mstp(147).EQ.5) THEN
32947  facqqg=c2*el1k11*el2k10+c3*el1k21*el2k20
32948  & +c4*(el1k11*el2k20+el1k21*el2k10)/2d0
32949  ELSEIF(mstp(147).EQ.6) THEN
32950  facqqg=c2*el1k11*el2k11+c3*el1k21*el2k21
32951  & +c4*(el1k11*el2k21+el1k21*el2k11)/2d0
32952  ENDIF
32953  facqqg=comfac*ff*facqqg
32954  ENDIF
32955  DO 2454 i=mmina,mmaxa
32956  IF(i.EQ.0.OR.iabs(i).GT.mstp(58)) goto 2454
32957  DO 2453 isde=1,2
32958  IF(isde.EQ.1.AND.kfac(1,i)*kfac(2,21).EQ.0) goto 2453
32959  IF(isde.EQ.2.AND.kfac(1,21)*kfac(2,i).EQ.0) goto 2453
32960  nchn=nchn+1
32961  isig(nchn,isde)=i
32962  isig(nchn,3-isde)=21
32963  isig(nchn,3)=1
32964  sigh(nchn)=facqqg*parp(ionium+5)
32965  2453 CONTINUE
32966  2454 CONTINUE
32967 
32968  ELSEIF(isub.EQ.436) THEN
32969 C...q + g -> q + QQ~[3P21]
32970  IF(mstp(145).EQ.0) THEN
32971  facqqg=-comfac*paru(1)*as**3*(32d0/81d0)*
32972  & ((6d0*sqmqq**2+th2)*uhsh2
32973  & -2d0*sh*uh*(th2+6d0*sqmqq*uhsh))/
32974  & (sqmqqr*th*uhsh2**2)
32975  ELSE
32976  ff=-(32d0*paru(1)*as**3*sqmqq*sqmqqr)/(27d0*th2*uhsh2**2)
32977  c1=th*uhsh2
32978  c2=4d0*(sh2+th2+2d0*th*uhsh)
32979  c3=4d0*uhsh2
32980  c4=8d0*sh*uhsh
32981  c5=8d0*th
32982  c6=0d0
32983  c7=16d0*th
32984  c8=0d0
32985  c9=-16d0*uhsh
32986  c0=16d0*sqmqq
32987  IF(mstp(147).EQ.0) THEN
32988  facqqg=1d0/3d0*(c1*3d0
32989  & -c2*(2d0*el1k10*el2k10+el1k11*el2k11)
32990  & -c3*(2d0*el1k20*el2k20+el1k21*el2k21)
32991  & -c4*(2d0*el1k10*el2k20+el1k11*el2k21)
32992  & +c5*2d0*(el1k10*el2k10-el1k11*el2k11)**2
32993  & +c6*2d0*(el1k20*el2k20-el1k21*el2k21)**2
32994  & +c7*2d0*(el1k10*el2k10-el1k11*el2k11)
32995  & *(el1k10*el2k20-el1k11*el2k21)
32996  & +c8*2d0*(el1k20*el2k20-el1k21*el2k21)
32997  & *(el1k10*el2k20-el1k11*el2k21)
32998  & +c9*2d0*(el1k10*el2k10-el1k11*el2k11)
32999  & *(el1k20*el2k20-el1k21*el2k21)
33000  & +c0*2d0*(el1k10*el2k20-el1k11*el2k21)**2)
33001  ELSEIF(mstp(147).EQ.1) THEN
33002  facqqg=c1*2d0
33003  & -c2*(el1k10*el2k10+el1k11*el2k11)
33004  & -c3*(el1k20*el2k20+el1k21*el2k21)
33005  & -c4*(el1k10*el2k20+el1k11*el2k21)
33006  & +c5*4d0*el1k10*el2k10*el1k11*el2k11
33007  & +c6*4d0*el1k20*el2k20*el1k21*el2k21
33008  & +c7*2d0*(el1k10*el2k10*el1k11*el2k21
33009  & +el1k10*el2k20*el1k11*el2k11)
33010  & +c8*2d0*(el1k20*el2k20*el1k11*el2k21
33011  & +el1k10*el2k20*el1k21*el2k21)
33012  & +c9*4d0*el1k10*el2k20*el1k11*el2k21
33013  & +c0*(el1k10*el2k10*el1k21*el2k21
33014  & +2d0*el1k10*el2k20*el1k11*el2k21
33015  & +el1k20*el2k20*el1k11*el2k11)
33016  ELSEIF(mstp(147).EQ.2) THEN
33017  facqqg=2d0*(c1
33018  & -c2*el1k11*el2k11
33019  & -c3*el1k21*el2k21
33020  & -c4*el1k11*el2k21
33021  & +c5*(el1k11*el2k11)**2
33022  & +c6*(el1k21*el2k21)**2
33023  & +c7*el1k11*el2k11*el1k11*el2k21
33024  & +c8*el1k21*el2k21*el1k11*el2k21
33025  & +(c9+c0)*(el1k11*el2k21)**2)
33026  ENDIF
33027  facqqg=comfac*ff*facqqg
33028  ENDIF
33029  DO 2456 i=mmina,mmaxa
33030  IF(i.EQ.0.OR.iabs(i).GT.mstp(58)) goto 2456
33031  DO 2455 isde=1,2
33032  IF(isde.EQ.1.AND.kfac(1,i)*kfac(2,21).EQ.0) goto 2455
33033  IF(isde.EQ.2.AND.kfac(1,21)*kfac(2,i).EQ.0) goto 2455
33034  nchn=nchn+1
33035  isig(nchn,isde)=i
33036  isig(nchn,3-isde)=21
33037  isig(nchn,3)=1
33038  sigh(nchn)=facqqg*parp(ionium+5)
33039  2455 CONTINUE
33040  2456 CONTINUE
33041 
33042  ELSEIF(isub.EQ.437) THEN
33043 C...q + q~ -> g + QQ~[3P01]
33044  IF(mstp(145).EQ.0) THEN
33045  facqqg=comfac*paru(1)*as**3*(128d0/243d0)*
33046  & (sh-3d0*sqmqq)**2*(th2+uh2)/(sqmqqr*sh*thuh2**2)
33047  ELSE
33048  fa=paru(1)*as**3*(128d0/729d0)*
33049  & (sh-3d0*sqmqq)**2*(th2+uh2)/(sqmqqr*sh*thuh2**2)
33050  IF(mstp(147).EQ.0) THEN
33051  facqqg=comfac*fa
33052  ELSEIF(mstp(147).EQ.1) THEN
33053  facqqg=comfac*2d0*fa
33054  ELSEIF(mstp(147).EQ.3) THEN
33055  facqqg=comfac*fa
33056  ELSEIF(mstp(147).EQ.4) THEN
33057  facqqg=comfac*fa
33058  ELSEIF(mstp(147).EQ.5) THEN
33059  facqqg=0d0
33060  ELSEIF(mstp(147).EQ.6) THEN
33061  facqqg=0d0
33062  ENDIF
33063  ENDIF
33064  DO 2457 i=mmina,mmaxa
33065  IF(i.EQ.0.OR.iabs(i).GT.mstp(58).OR.
33066  & kfac(1,i)*kfac(2,-i).EQ.0) goto 2457
33067  nchn=nchn+1
33068  isig(nchn,1)=i
33069  isig(nchn,2)=-i
33070  isig(nchn,3)=1
33071  sigh(nchn)=facqqg*parp(ionium+5)
33072  2457 CONTINUE
33073 
33074  ELSEIF(isub.EQ.438) THEN
33075 C...q + q~ -> g + QQ~[3P11]
33076  IF(mstp(145).EQ.0) THEN
33077  facqqg=comfac*paru(1)*as**3*256d0/81d0*
33078  & (4d0*sqmqq*th*uh+sh*(th2+uh2))/(sqmqqr*thuh2**2)
33079  ELSE
33080  ff=-(512d0*paru(1)*as**3*sqmqqr)/(81d0*thuh2**2)
33081  c1=th*uh
33082  c2=2d0*uh
33083  c3=2d0*th
33084  c4=2d0*thuh
33085  IF(mstp(147).EQ.0) THEN
33086  facqqg=-c1+c2*el1k10*el2k10+c3*el1k20*el2k20
33087  & +c4*(el1k10*el2k20+el1k20*el2k10)/2d0
33088  ELSEIF(mstp(147).EQ.1) THEN
33089  facqqg=2d0*(-c1+c2*el1k11*el2k11+c3*el1k21*el2k21
33090  & +c4*(el1k11*el2k21+el1k21*el2k11)/2d0)
33091  ELSEIF(mstp(147).EQ.3) THEN
33092  facqqg=-c1+c2*el1k10*el2k10+c3*el1k20*el2k20
33093  & +c4*(el1k10*el2k20+el1k20*el2k10)/2d0
33094  ELSEIF(mstp(147).EQ.4) THEN
33095  facqqg=-c1+c2*el1k11*el2k11+c3*el1k21*el2k21
33096  & +c4*(el1k11*el2k21+el1k21*el2k11)/2d0
33097  ELSEIF(mstp(147).EQ.5) THEN
33098  facqqg=c2*el1k11*el2k10+c3*el1k21*el2k20
33099  & +c4*(el1k11*el2k20+el1k21*el2k10)/2d0
33100  ELSEIF(mstp(147).EQ.6) THEN
33101  facqqg=c2*el1k11*el2k11+c3*el1k21*el2k21
33102  & +c4*(el1k11*el2k21+el1k21*el2k11)/2d0
33103  ENDIF
33104  facqqg=comfac*ff*facqqg
33105  ENDIF
33106  DO 2458 i=mmina,mmaxa
33107  IF(i.EQ.0.OR.iabs(i).GT.mstp(58).OR.
33108  & kfac(1,i)*kfac(2,-i).EQ.0) goto 2458
33109  nchn=nchn+1
33110  isig(nchn,1)=i
33111  isig(nchn,2)=-i
33112  isig(nchn,3)=1
33113  sigh(nchn)=facqqg*parp(ionium+5)
33114  2458 CONTINUE
33115 
33116  ELSEIF(isub.EQ.439) THEN
33117 C...q + q~ -> g + QQ~[3P21]
33118  IF(mstp(145).EQ.0) THEN
33119  facqqg=comfac*paru(1)*as**3*(256d0/243d0)*
33120  & ((6d0*sqmqq**2+sh2)*thuh2
33121  & -2d0*th*uh*(sh2+6d0*sqmqq*thuh))/
33122  & (sqmqqr*sh*thuh2**2)
33123  ELSE
33124  ff=(256d0*paru(1)*as**3*sqmqq*sqmqqr)/(81d0*sh2*thuh2**2)
33125  c1=sh*thuh2
33126  c2=4d0*(sh2+uh2+2d0*sh*thuh)
33127  c3=4d0*(sh2+th2+2d0*sh*thuh)
33128  c4=8d0*(sh2-th*uh+2d0*sh*thuh)
33129  c5=8d0*sh
33130  c6=c5
33131  c7=16d0*sh
33132  c8=c7
33133  c9=-16d0*thuh
33134  c0=16d0*sqmqq
33135  IF(mstp(147).EQ.0) THEN
33136  facqqg=1d0/3d0*(c1*3d0
33137  & -c2*(2d0*el1k10*el2k10+el1k11*el2k11)
33138  & -c3*(2d0*el1k20*el2k20+el1k21*el2k21)
33139  & -c4*(2d0*el1k10*el2k20+el1k11*el2k21)
33140  & +c5*2d0*(el1k10*el2k10-el1k11*el2k11)**2
33141  & +c6*2d0*(el1k20*el2k20-el1k21*el2k21)**2
33142  & +c7*2d0*(el1k10*el2k10-el1k11*el2k11)
33143  & *(el1k10*el2k20-el1k11*el2k21)
33144  & +c8*2d0*(el1k20*el2k20-el1k21*el2k21)
33145  & *(el1k10*el2k20-el1k11*el2k21)
33146  & +c9*2d0*(el1k10*el2k10-el1k11*el2k11)
33147  & *(el1k20*el2k20-el1k21*el2k21)
33148  & +c0*2d0*(el1k10*el2k20-el1k11*el2k21)**2)
33149  ELSEIF(mstp(147).EQ.1) THEN
33150  facqqg=c1*2d0
33151  & -c2*(el1k10*el2k10+el1k11*el2k11)
33152  & -c3*(el1k20*el2k20+el1k21*el2k21)
33153  & -c4*(el1k10*el2k20+el1k11*el2k21)
33154  & +c5*4d0*el1k10*el2k10*el1k11*el2k11
33155  & +c6*4d0*el1k20*el2k20*el1k21*el2k21
33156  & +c7*2d0*(el1k10*el2k10*el1k11*el2k21
33157  & +el1k10*el2k20*el1k11*el2k11)
33158  & +c8*2d0*(el1k20*el2k20*el1k11*el2k21
33159  & +el1k10*el2k20*el1k21*el2k21)
33160  & +c9*4d0*el1k10*el2k20*el1k11*el2k21
33161  & +c0*(el1k10*el2k10*el1k21*el2k21
33162  & +2d0*el1k10*el2k20*el1k11*el2k21
33163  & +el1k20*el2k20*el1k11*el2k11)
33164  ELSEIF(mstp(147).EQ.2) THEN
33165  facqqg=2d0*(c1
33166  & -c2*el1k11*el2k11
33167  & -c3*el1k21*el2k21
33168  & -c4*el1k11*el2k21
33169  & +c5*(el1k11*el2k11)**2
33170  & +c6*(el1k21*el2k21)**2
33171  & +c7*el1k11*el2k11*el1k11*el2k21
33172  & +c8*el1k21*el2k21*el1k11*el2k21
33173  & +(c9+c0)*(el1k11*el2k21)**2)
33174  ENDIF
33175  facqqg=comfac*ff*facqqg
33176  ENDIF
33177  DO 2459 i=mmina,mmaxa
33178  IF(i.EQ.0.OR.iabs(i).GT.mstp(58).OR.
33179  & kfac(1,i)*kfac(2,-i).EQ.0) goto 2459
33180  nchn=nchn+1
33181  isig(nchn,1)=i
33182  isig(nchn,2)=-i
33183  isig(nchn,3)=1
33184  sigh(nchn)=facqqg*parp(ionium+5)
33185  2459 CONTINUE
33186  ENDIF
33187 C...QUARKONIA---
33188 
33189  ENDIF
33190 
33191  RETURN
33192  END
33193 
33194 C*********************************************************************
33195 
33196 C...PYSGWZ
33197 C...Subprocess cross sections for W/Z processes,
33198 C...except that longitudinal WW scattering is in Higgs sector.
33199 C...Auxiliary to PYSIGH.
33200 
33201  SUBROUTINE pysgwz(NCHN,SIGS)
33202 
33203 C...Double precision and integer declarations
33204  IMPLICIT DOUBLE PRECISION(a-h, o-z)
33205  IMPLICIT INTEGER(i-n)
33206  INTEGER pyk,pychge,pycomp
33207 C...Parameter statement to help give large particle numbers.
33208  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
33209  &kexcit=4000000,kdimen=5000000)
33210 C...Commonblocks
33211  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
33212  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
33213  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
33214  common/pysubs/msel,mselpd,msub(500),kfin(2,-40:40),ckin(200)
33215  common/pypars/mstp(200),parp(200),msti(200),pari(200)
33216  common/pyint1/mint(400),vint(400)
33217  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
33218  common/pyint3/xsfx(2,-40:40),isig(1000,3),sigh(1000)
33219  common/pyint4/mwid(500),wids(500,5)
33220  common/pytcsm/itcm(0:99),rtcm(0:99)
33221  common/pysgcm/isub,isubsv,mmin1,mmax1,mmin2,mmax2,mmina,mmaxa,
33222  &kfac(2,-40:40),comfac,fack,faca,sh,th,uh,sh2,th2,uh2,sqm3,sqm4,
33223  &shr,sqpth,taup,be34,cth,x(2),sqmz,sqmw,gmmz,gmmw,
33224  &aem,as,xw,xw1,xwc,xwv,poll,polr,polll,polrr
33225  SAVE /pydat1/,/pydat2/,/pydat3/,/pysubs/,/pypars/,/pyint1/,
33226  &/pyint2/,/pyint3/,/pyint4/,/pytcsm/,/pysgcm/
33227 C...Local arrays and complex numbers
33228  dimension wdtp(0:400),wdte(0:400,0:5),hgz(6,3),hl3(3),hr3(3),
33229  &hl4(3),hr4(3)
33230  COMPLEX*16 coulck,coulcp,coulcd,coulcr,coulcs
33231 
33232 C...Differential cross section expressions.
33233 
33234  IF(isub.LE.20) THEN
33235  IF(isub.EQ.1) THEN
33236 C...f + fbar -> gamma*/Z0
33237  mint(61)=2
33238  CALL pywidt(23,sh,wdtp,wdte)
33239  hs=shr*wdtp(0)
33240  facz=4d0*comfac*3d0
33241  hp0=aem/3d0*sh
33242  hp1=aem/3d0*xwc*sh
33243  DO 100 i=mmina,mmaxa
33244  IF(i.EQ.0.OR.kfac(1,i)*kfac(2,-i).EQ.0) goto 100
33245  ei=kchg(iabs(i),1)/3d0
33246  ai=sign(1d0,ei)
33247  vi=ai-4d0*ei*xwv
33248  hi0=hp0
33249  IF(iabs(i).LE.10) hi0=hi0*faca/3d0
33250  hi1=hp1
33251  IF(iabs(i).LE.10) hi1=hi1*faca/3d0
33252  nchn=nchn+1
33253  isig(nchn,1)=i
33254  isig(nchn,2)=-i
33255  isig(nchn,3)=1
33256  sigh(nchn)=facz*(ei**2/sh2*hi0*hp0*vint(111)+
33257  & ei*vi*(1d0-sqmz/sh)/((sh-sqmz)**2+hs**2)*
33258  & (hi0*hp1+hi1*hp0)*vint(112)+(vi**2+ai**2)/
33259  & ((sh-sqmz)**2+hs**2)*hi1*hp1*vint(114))
33260  100 CONTINUE
33261 
33262  ELSEIF(isub.EQ.2) THEN
33263 C...f + fbar' -> W+/-
33264  CALL pywidt(24,sh,wdtp,wdte)
33265  hs=shr*wdtp(0)
33266  facbw=4d0*comfac/((sh-sqmw)**2+hs**2)*3d0
33267  hp=aem/(24d0*xw)*sh
33268  DO 120 i=mmin1,mmax1
33269  IF(i.EQ.0.OR.kfac(1,i).EQ.0) goto 120
33270  ia=iabs(i)
33271  DO 110 j=mmin2,mmax2
33272  IF(j.EQ.0.OR.kfac(2,j).EQ.0) goto 110
33273  ja=iabs(j)
33274  IF(i*j.GT.0.OR.mod(ia+ja,2).EQ.0) goto 110
33275  IF((ia.LE.10.AND.ja.GT.10).OR.(ia.GT.10.AND.ja.LE.10))
33276  & goto 110
33277  kchw=(kchg(ia,1)*isign(1,i)+kchg(ja,1)*isign(1,j))/3
33278  hi=hp*2d0
33279  IF(ia.LE.10) hi=hi*vckm((ia+1)/2,(ja+1)/2)*faca/3d0
33280  nchn=nchn+1
33281  isig(nchn,1)=i
33282  isig(nchn,2)=j
33283  isig(nchn,3)=1
33284  hf=shr*(wdte(0,1)+wdte(0,(5-kchw)/2)+wdte(0,4))
33285  sigh(nchn)=hi*facbw*hf
33286  110 CONTINUE
33287  120 CONTINUE
33288 
33289  ELSEIF(isub.EQ.15) THEN
33290 C...f + fbar -> g + (gamma*/Z0) (q + qbar -> g + (gamma*/Z0) only)
33291  faczg=comfac*as*aem*(8d0/9d0)*(th2+uh2+2d0*sqm4*sh)/(th*uh)
33292 C...gamma, gamma/Z interference and Z couplings to final fermion pairs
33293  hfgg=0d0
33294  hfgz=0d0
33295  hfzz=0d0
33296  radc4=1d0+pyalps(sqm4)/paru(1)
33297  DO 130 i=1,min(16,mdcy(23,3))
33298  idc=i+mdcy(23,2)-1
33299  IF(mdme(idc,1).LT.0) goto 130
33300  imdm=0
33301  IF(mdme(idc,1).EQ.1.OR.mdme(idc,1).EQ.2.OR.mdme(idc,1).EQ.4)
33302  & imdm=1
33303  IF(i.LE.8) THEN
33304  ef=kchg(i,1)/3d0
33305  af=sign(1d0,ef+0.1d0)
33306  vf=af-4d0*ef*xwv
33307  ELSEIF(i.LE.16) THEN
33308  ef=kchg(i+2,1)/3d0
33309  af=sign(1d0,ef+0.1d0)
33310  vf=af-4d0*ef*xwv
33311  ENDIF
33312  rm1=pmas(iabs(kfdp(idc,1)),1)**2/sqm4
33313  IF(4d0*rm1.LT.1d0) THEN
33314  fcof=1d0
33315  IF(i.LE.8) fcof=3d0*radc4
33316  be34=sqrt(max(0d0,1d0-4d0*rm1))
33317  IF(imdm.EQ.1) THEN
33318  hfgg=hfgg+fcof*ef**2*(1d0+2d0*rm1)*be34
33319  hfgz=hfgz+fcof*ef*vf*(1d0+2d0*rm1)*be34
33320  hfzz=hfzz+fcof*(vf**2*(1d0+2d0*rm1)+
33321  & af**2*(1d0-4d0*rm1))*be34
33322  ENDIF
33323  ENDIF
33324  130 CONTINUE
33325 C...Propagators: as simulated in PYOFSH and as desired
33326  hbw4=(1d0/paru(1))*gmmz/((sqm4-sqmz)**2+gmmz**2)
33327  mint15=mint(15)
33328  mint(15)=1
33329  mint(61)=1
33330  CALL pywidt(23,sqm4,wdtp,wdte)
33331  mint(15)=mint15
33332  hfaem=(paru(108)/paru(2))*(2d0/3d0)
33333  hfgg=hfgg*hfaem*vint(111)/sqm4
33334  hfgz=hfgz*hfaem*vint(112)/sqm4
33335  hfzz=hfzz*hfaem*vint(114)/sqm4
33336 C...Loop over flavours; consider full gamma/Z structure
33337  DO 140 i=mmina,mmaxa
33338  IF(i.EQ.0.OR.iabs(i).GT.mstp(58).OR.
33339  & kfac(1,i)*kfac(2,-i).EQ.0) goto 140
33340  ei=kchg(iabs(i),1)/3d0
33341  ai=sign(1d0,ei)
33342  vi=ai-4d0*ei*xwv
33343  nchn=nchn+1
33344  isig(nchn,1)=i
33345  isig(nchn,2)=-i
33346  isig(nchn,3)=1
33347  sigh(nchn)=faczg*(ei**2*hfgg+ei*vi*hfgz+
33348  & (vi**2+ai**2)*hfzz)/hbw4
33349  140 CONTINUE
33350 
33351  ELSEIF(isub.EQ.16) THEN
33352 C...f + fbar' -> g + W+/- (q + qbar' -> g + W+/- only)
33353  facwg=comfac*as*aem/xw*2d0/9d0*(th2+uh2+2d0*sqm4*sh)/(th*uh)
33354 C...Propagators: as simulated in PYOFSH and as desired
33355  hbw4=gmmw/((sqm4-sqmw)**2+gmmw**2)
33356  CALL pywidt(24,sqm4,wdtp,wdte)
33357  gmmwc=sqrt(sqm4)*wdtp(0)
33358  hbw4c=gmmwc/((sqm4-sqmw)**2+gmmwc**2)
33359  facwg=facwg*hbw4c/hbw4
33360  DO 160 i=mmin1,mmax1
33361  ia=iabs(i)
33362  IF(i.EQ.0.OR.ia.GT.10.OR.kfac(1,i).EQ.0) goto 160
33363  DO 150 j=mmin2,mmax2
33364  ja=iabs(j)
33365  IF(j.EQ.0.OR.ja.GT.10.OR.kfac(2,j).EQ.0) goto 150
33366  IF(i*j.GT.0.OR.mod(ia+ja,2).EQ.0) goto 150
33367  kchw=(kchg(ia,1)*isign(1,i)+kchg(ja,1)*isign(1,j))/3
33368  widsc=(wdte(0,1)+wdte(0,(5-kchw)/2)+wdte(0,4))/wdtp(0)
33369  fckm=vckm((ia+1)/2,(ja+1)/2)
33370  nchn=nchn+1
33371  isig(nchn,1)=i
33372  isig(nchn,2)=j
33373  isig(nchn,3)=1
33374  sigh(nchn)=facwg*fckm*widsc
33375  150 CONTINUE
33376  160 CONTINUE
33377 
33378  ELSEIF(isub.EQ.19) THEN
33379 C...f + fbar -> gamma + (gamma*/Z0)
33380  facgz=comfac*2d0*aem**2*(th2+uh2+2d0*sqm4*sh)/(th*uh)
33381 C...gamma, gamma/Z interference and Z couplings to final fermion pairs
33382  hfgg=0d0
33383  hfgz=0d0
33384  hfzz=0d0
33385  radc4=1d0+pyalps(sqm4)/paru(1)
33386  DO 170 i=1,min(16,mdcy(23,3))
33387  idc=i+mdcy(23,2)-1
33388  IF(mdme(idc,1).LT.0) goto 170
33389  imdm=0
33390  IF(mdme(idc,1).EQ.1.OR.mdme(idc,1).EQ.2.OR.mdme(idc,1).EQ.4)
33391  & imdm=1
33392  IF(i.LE.8) THEN
33393  ef=kchg(i,1)/3d0
33394  af=sign(1d0,ef+0.1d0)
33395  vf=af-4d0*ef*xwv
33396  ELSEIF(i.LE.16) THEN
33397  ef=kchg(i+2,1)/3d0
33398  af=sign(1d0,ef+0.1d0)
33399  vf=af-4d0*ef*xwv
33400  ENDIF
33401  rm1=pmas(iabs(kfdp(idc,1)),1)**2/sqm4
33402  IF(4d0*rm1.LT.1d0) THEN
33403  fcof=1d0
33404  IF(i.LE.8) fcof=3d0*radc4
33405  be34=sqrt(max(0d0,1d0-4d0*rm1))
33406  IF(imdm.EQ.1) THEN
33407  hfgg=hfgg+fcof*ef**2*(1d0+2d0*rm1)*be34
33408  hfgz=hfgz+fcof*ef*vf*(1d0+2d0*rm1)*be34
33409  hfzz=hfzz+fcof*(vf**2*(1d0+2d0*rm1)+
33410  & af**2*(1d0-4d0*rm1))*be34
33411  ENDIF
33412  ENDIF
33413  170 CONTINUE
33414 C...Propagators: as simulated in PYOFSH and as desired
33415  hbw4=(1d0/paru(1))*gmmz/((sqm4-sqmz)**2+gmmz**2)
33416  mint15=mint(15)
33417  mint(15)=1
33418  mint(61)=1
33419  CALL pywidt(23,sqm4,wdtp,wdte)
33420  mint(15)=mint15
33421  hfaem=(paru(108)/paru(2))*(2d0/3d0)
33422  hfgg=hfgg*hfaem*vint(111)/sqm4
33423  hfgz=hfgz*hfaem*vint(112)/sqm4
33424  hfzz=hfzz*hfaem*vint(114)/sqm4
33425 C...Loop over flavours; consider full gamma/Z structure
33426  DO 180 i=mmina,mmaxa
33427  IF(i.EQ.0.OR.kfac(1,i)*kfac(2,-i).EQ.0) goto 180
33428  ei=kchg(iabs(i),1)/3d0
33429  ai=sign(1d0,ei)
33430  vi=ai-4d0*ei*xwv
33431  fcoi=1d0
33432  IF(iabs(i).LE.10) fcoi=faca/3d0
33433  nchn=nchn+1
33434  isig(nchn,1)=i
33435  isig(nchn,2)=-i
33436  isig(nchn,3)=1
33437  sigh(nchn)=facgz*fcoi*ei**2*(ei**2*hfgg+ei*vi*hfgz+
33438  & (vi**2+ai**2)*hfzz)/hbw4
33439  180 CONTINUE
33440 
33441  ELSEIF(isub.EQ.20) THEN
33442 C...f + fbar' -> gamma + W+/-
33443  facgw=comfac*0.5d0*aem**2/xw
33444 C...Propagators: as simulated in PYOFSH and as desired
33445  hbw4=gmmw/((sqm4-sqmw)**2+gmmw**2)
33446  CALL pywidt(24,sqm4,wdtp,wdte)
33447  gmmwc=sqrt(sqm4)*wdtp(0)
33448  hbw4c=gmmwc/((sqm4-sqmw)**2+gmmwc**2)
33449  facgw=facgw*hbw4c/hbw4
33450 C...Anomalous couplings
33451  term1=(th2+uh2+2d0*sqm4*sh)/(th*uh)
33452  term2=0d0
33453  term3=0d0
33454  IF(itcm(5).GE.1.AND.itcm(5).LE.4) THEN
33455  term2=rtcm(46)*(th-uh)/(th+uh)
33456  term3=0.5d0*rtcm(46)**2*(th*uh+(th2+uh2)*sh/
33457  & (4d0*sqmw))/(th+uh)**2
33458  ENDIF
33459  DO 200 i=mmin1,mmax1
33460  ia=iabs(i)
33461  IF(i.EQ.0.OR.ia.GT.20.OR.kfac(1,i).EQ.0) goto 200
33462  DO 190 j=mmin2,mmax2
33463  ja=iabs(j)
33464  IF(j.EQ.0.OR.ja.GT.20.OR.kfac(2,j).EQ.0) goto 190
33465  IF(i*j.GT.0.OR.mod(ia+ja,2).EQ.0) goto 190
33466  IF((ia.LE.10.AND.ja.GT.10).OR.(ia.GT.10.AND.ja.LE.10))
33467  & goto 190
33468  kchw=(kchg(ia,1)*isign(1,i)+kchg(ja,1)*isign(1,j))/3
33469  widsc=(wdte(0,1)+wdte(0,(5-kchw)/2)+wdte(0,4))/wdtp(0)
33470  IF(ia.LE.10) THEN
33471  facwr=uh/(th+uh)-1d0/3d0
33472  fckm=vckm((ia+1)/2,(ja+1)/2)
33473  fcoi=faca/3d0
33474  ELSE
33475  facwr=-th/(th+uh)
33476  fckm=1d0
33477  fcoi=1d0
33478  ENDIF
33479  facwk=term1*facwr**2+term2*facwr+term3
33480  nchn=nchn+1
33481  isig(nchn,1)=i
33482  isig(nchn,2)=j
33483  isig(nchn,3)=1
33484  sigh(nchn)=facgw*facwk*fcoi*fckm*widsc
33485  190 CONTINUE
33486  200 CONTINUE
33487  ENDIF
33488 
33489  ELSEIF(isub.LE.40) THEN
33490  IF(isub.EQ.22) THEN
33491 C...f + fbar -> (gamma*/Z0) + (gamma*/Z0)
33492 C...Kinematics dependence
33493  faczz=comfac*aem**2*((th2+uh2+2d0*(sqm3+sqm4)*sh)/(th*uh)-
33494  & sqm3*sqm4*(1d0/th2+1d0/uh2))
33495 C...gamma, gamma/Z interference and Z couplings to final fermion pairs
33496  DO 220 i=1,6
33497  DO 210 j=1,3
33498  hgz(i,j)=0d0
33499  210 CONTINUE
33500  220 CONTINUE
33501  radc3=1d0+pyalps(sqm3)/paru(1)
33502  radc4=1d0+pyalps(sqm4)/paru(1)
33503  DO 230 i=1,min(16,mdcy(23,3))
33504  idc=i+mdcy(23,2)-1
33505  IF(mdme(idc,1).LT.0) goto 230
33506  imdm=0
33507  IF(mdme(idc,1).EQ.1.OR.mdme(idc,1).EQ.2) imdm=1
33508  IF(mdme(idc,1).EQ.4.OR.mdme(idc,1).EQ.5) imdm=mdme(idc,1)-2
33509  IF(i.LE.8) THEN
33510  ef=kchg(i,1)/3d0
33511  af=sign(1d0,ef+0.1d0)
33512  vf=af-4d0*ef*xwv
33513  ELSEIF(i.LE.16) THEN
33514  ef=kchg(i+2,1)/3d0
33515  af=sign(1d0,ef+0.1d0)
33516  vf=af-4d0*ef*xwv
33517  ENDIF
33518  rm1=pmas(iabs(kfdp(idc,1)),1)**2/sqm3
33519  IF(4d0*rm1.LT.1d0) THEN
33520  fcof=1d0
33521  IF(i.LE.8) fcof=3d0*radc3
33522  be34=sqrt(max(0d0,1d0-4d0*rm1))
33523  IF(imdm.GE.1) THEN
33524  hgz(1,imdm)=hgz(1,imdm)+fcof*ef**2*(1d0+2d0*rm1)*be34
33525  hgz(2,imdm)=hgz(2,imdm)+fcof*ef*vf*(1d0+2d0*rm1)*be34
33526  hgz(3,imdm)=hgz(3,imdm)+fcof*(vf**2*(1d0+2d0*rm1)+
33527  & af**2*(1d0-4d0*rm1))*be34
33528  ENDIF
33529  ENDIF
33530  rm1=pmas(iabs(kfdp(idc,1)),1)**2/sqm4
33531  IF(4d0*rm1.LT.1d0) THEN
33532  fcof=1d0
33533  IF(i.LE.8) fcof=3d0*radc4
33534  be34=sqrt(max(0d0,1d0-4d0*rm1))
33535  IF(imdm.GE.1) THEN
33536  hgz(4,imdm)=hgz(4,imdm)+fcof*ef**2*(1d0+2d0*rm1)*be34
33537  hgz(5,imdm)=hgz(5,imdm)+fcof*ef*vf*(1d0+2d0*rm1)*be34
33538  hgz(6,imdm)=hgz(6,imdm)+fcof*(vf**2*(1d0+2d0*rm1)+
33539  & af**2*(1d0-4d0*rm1))*be34
33540  ENDIF
33541  ENDIF
33542  230 CONTINUE
33543 C...Propagators: as simulated in PYOFSH and as desired
33544  hbw3=(1d0/paru(1))*gmmz/((sqm3-sqmz)**2+gmmz**2)
33545  hbw4=(1d0/paru(1))*gmmz/((sqm4-sqmz)**2+gmmz**2)
33546  mint15=mint(15)
33547  mint(15)=1
33548  mint(61)=1
33549  CALL pywidt(23,sqm3,wdtp,wdte)
33550  mint(15)=mint15
33551  hfaem=(paru(108)/paru(2))*(2d0/3d0)
33552  DO 240 j=1,3
33553  hgz(1,j)=hgz(1,j)*hfaem*vint(111)/sqm3
33554  hgz(2,j)=hgz(2,j)*hfaem*vint(112)/sqm3
33555  hgz(3,j)=hgz(3,j)*hfaem*vint(114)/sqm3
33556  240 CONTINUE
33557  mint15=mint(15)
33558  mint(15)=1
33559  mint(61)=1
33560  CALL pywidt(23,sqm4,wdtp,wdte)
33561  mint(15)=mint15
33562  hfaem=(paru(108)/paru(2))*(2d0/3d0)
33563  DO 250 j=1,3
33564  hgz(4,j)=hgz(4,j)*hfaem*vint(111)/sqm4
33565  hgz(5,j)=hgz(5,j)*hfaem*vint(112)/sqm4
33566  hgz(6,j)=hgz(6,j)*hfaem*vint(114)/sqm4
33567  250 CONTINUE
33568 C...Loop over flavours; separate left- and right-handed couplings
33569  DO 270 i=mmina,mmaxa
33570  IF(i.EQ.0.OR.kfac(1,i)*kfac(2,-i).EQ.0) goto 270
33571  ei=kchg(iabs(i),1)/3d0
33572  ai=sign(1d0,ei)
33573  vi=ai-4d0*ei*xwv
33574  vali=vi-ai
33575  vari=vi+ai
33576  fcoi=1d0
33577  IF(iabs(i).LE.10) fcoi=faca/3d0
33578  DO 260 j=1,3
33579  hl3(j)=ei**2*hgz(1,j)+ei*vali*hgz(2,j)+vali**2*hgz(3,j)
33580  hr3(j)=ei**2*hgz(1,j)+ei*vari*hgz(2,j)+vari**2*hgz(3,j)
33581  hl4(j)=ei**2*hgz(4,j)+ei*vali*hgz(5,j)+vali**2*hgz(6,j)
33582  hr4(j)=ei**2*hgz(4,j)+ei*vari*hgz(5,j)+vari**2*hgz(6,j)
33583  260 CONTINUE
33584  faclr=hl3(1)*hl4(1)+hl3(1)*(hl4(2)+hl4(3))+
33585  & hl4(1)*(hl3(2)+hl3(3))+hl3(2)*hl4(3)+hl4(2)*hl3(3)+
33586  & hr3(1)*hr4(1)+hr3(1)*(hr4(2)+hr4(3))+
33587  & hr4(1)*(hr3(2)+hr3(3))+hr3(2)*hr4(3)+hr4(2)*hr3(3)
33588  nchn=nchn+1
33589  isig(nchn,1)=i
33590  isig(nchn,2)=-i
33591  isig(nchn,3)=1
33592  sigh(nchn)=0.5d0*faczz*fcoi*faclr/(hbw3*hbw4)
33593  270 CONTINUE
33594 
33595  ELSEIF(isub.EQ.23) THEN
33596 C...f + fbar' -> Z0 + W+/- (Z0 only, i.e. no gamma* admixture.)
33597  faczw=comfac*0.5d0*(aem/xw)**2
33598  faczw=faczw*wids(23,2)
33599  thuh=max(th*uh-sqm3*sqm4,sh*ckin(3)**2)
33600  facbw=1d0/((sh-sqmw)**2+gmmw**2)
33601  DO 290 i=mmin1,mmax1
33602  ia=iabs(i)
33603  IF(i.EQ.0.OR.ia.GT.20.OR.kfac(1,i).EQ.0) goto 290
33604  DO 280 j=mmin2,mmax2
33605  ja=iabs(j)
33606  IF(j.EQ.0.OR.ja.GT.20.OR.kfac(2,j).EQ.0) goto 280
33607  IF(i*j.GT.0.OR.mod(ia+ja,2).EQ.0) goto 280
33608  IF((ia.LE.10.AND.ja.GT.10).OR.(ia.GT.10.AND.ja.LE.10))
33609  & goto 280
33610  kchw=(kchg(ia,1)*isign(1,i)+kchg(ja,1)*isign(1,j))/3
33611  ei=kchg(ia,1)/3d0
33612  ai=sign(1d0,ei+0.1d0)
33613  vi=ai-4d0*ei*xwv
33614  ej=kchg(ja,1)/3d0
33615  aj=sign(1d0,ej+0.1d0)
33616  vj=aj-4d0*ej*xwv
33617  IF(vi+ai.GT.0) THEN
33618  visav=vi
33619  aisav=ai
33620  vi=vj
33621  ai=aj
33622  vj=visav
33623  aj=aisav
33624  ENDIF
33625  fckm=1d0
33626  IF(ia.LE.10) fckm=vckm((ia+1)/2,(ja+1)/2)
33627  fcoi=1d0
33628  IF(ia.LE.10) fcoi=faca/3d0
33629  nchn=nchn+1
33630  isig(nchn,1)=i
33631  isig(nchn,2)=j
33632  isig(nchn,3)=1
33633  sigh(nchn)=faczw*fcoi*fckm*(facbw*((9d0-8d0*xw)/4d0*thuh+
33634  & (8d0*xw-6d0)/4d0*sh*(sqm3+sqm4))+(thuh-sh*(sqm3+sqm4))*
33635  & (sh-sqmw)*facbw*0.5d0*((vj+aj)/th-(vi+ai)/uh)+
33636  & thuh/(16d0*xw1)*((vj+aj)**2/th2+(vi+ai)**2/uh2)+
33637  & sh*(sqm3+sqm4)/(8d0*xw1)*(vi+ai)*(vj+aj)/(th*uh))*
33638  & wids(24,(5-kchw)/2)
33639 C***Protect against slightly negative cross sections. (Reason yet to be
33640 C***sorted out. One possibility: addition of width to the W propagator.)
33641  sigh(nchn)=max(0d0,sigh(nchn))
33642  280 CONTINUE
33643  290 CONTINUE
33644 
33645  ELSEIF(isub.EQ.25) THEN
33646 C...f + fbar -> W+ + W-
33647 C...Propagators: Z0, W+- as simulated in PYOFSH and as desired
33648  gmmzc=gmmz
33649  hbwzc=sh**2/((sh-sqmz)**2+gmmzc**2)
33650  hbw3=gmmw/((sqm3-sqmw)**2+gmmw**2)
33651  CALL pywidt(24,sqm3,wdtp,wdte)
33652  gmmw3=sqrt(sqm3)*wdtp(0)
33653  hbw3c=gmmw3/((sqm3-sqmw)**2+gmmw3**2)
33654  hbw4=gmmw/((sqm4-sqmw)**2+gmmw**2)
33655  CALL pywidt(24,sqm4,wdtp,wdte)
33656  gmmw4=sqrt(sqm4)*wdtp(0)
33657  hbw4c=gmmw4/((sqm4-sqmw)**2+gmmw4**2)
33658 C...Kinematical functions
33659  thuh=max(th*uh-sqm3*sqm4,sh*ckin(3)**2)
33660  thuh34=(2d0*sh*(sqm3+sqm4)+thuh)/(sqm3*sqm4)
33661  gs=(((sh-sqm3-sqm4)**2-4d0*sqm3*sqm4)*thuh34+12d0*thuh)/sh2
33662  gt=thuh34+4d0*thuh/th2
33663  gst=((sh-sqm3-sqm4)*thuh34+4d0*(sh*(sqm3+sqm4)-thuh)/th)/sh
33664  gu=thuh34+4d0*thuh/uh2
33665  gsu=((sh-sqm3-sqm4)*thuh34+4d0*(sh*(sqm3+sqm4)-thuh)/uh)/sh
33666 C...Common factors and couplings
33667  facww=comfac*(hbw3c/hbw3)*(hbw4c/hbw4)
33668  facww=facww*wids(24,1)
33669  cgg=aem**2/2d0
33670  cgz=aem**2/(4d0*xw)*hbwzc*(1d0-sqmz/sh)
33671  czz=aem**2/(32d0*xw**2)*hbwzc
33672  cng=aem**2/(4d0*xw)
33673  cnz=aem**2/(16d0*xw**2)*hbwzc*(1d0-sqmz/sh)
33674  cnn=aem**2/(16d0*xw**2)
33675 C...Coulomb factor for W+W- pair
33676  IF(mstp(40).GE.1.AND.mstp(40).LE.3) THEN
33677  coule=(sh-4d0*sqmw)/(4d0*pmas(24,1))
33678  coulp=max(1d-10,0.5d0*be34*sqrt(sh))
33679  IF(coule.LT.100d0*pmas(24,2)) THEN
33680  coulp1=sqrt(0.5d0*pmas(24,1)*(sqrt(coule**2+
33681  & pmas(24,2)**2)-coule))
33682  ELSE
33683  coulp1=sqrt(0.5d0*pmas(24,1)*(0.5d0*pmas(24,2)**2/coule))
33684  ENDIF
33685  IF(coule.GT.-100d0*pmas(24,2)) THEN
33686  coulp2=sqrt(0.5d0*pmas(24,1)*(sqrt(coule**2+
33687  & pmas(24,2)**2)+coule))
33688  ELSE
33689  coulp2=sqrt(0.5d0*pmas(24,1)*(0.5d0*pmas(24,2)**2/
33690  & abs(coule)))
33691  ENDIF
33692  IF(mstp(40).EQ.1) THEN
33693  couldc=paru(1)-2d0*atan((coulp1**2+coulp2**2-coulp**2)/
33694  & max(1d-10,2d0*coulp*coulp1))
33695  faccou=1d0+0.5d0*paru(101)*couldc/max(1d-5,be34)
33696  ELSEIF(mstp(40).EQ.2) THEN
33697  coulck=dcmplx(dble(coulp1),dble(coulp2))
33698  coulcp=dcmplx(0d0,dble(coulp))
33699  coulcd=(coulck+coulcp)/(coulck-coulcp)
33700  coulcr=1d0+dble(paru(101)*sqrt(sh))/
33701  & (4d0*coulcp)*log(coulcd)
33702  coulcs=dcmplx(0d0,0d0)
33703  nstp=100
33704  DO 300 istp=1,nstp
33705  coulxx=(istp-0.5)/nstp
33706  coulcs=coulcs+(1d0/coulxx)*log((1d0+coulxx*coulcd)/
33707  & (1d0+coulxx/coulcd))
33708  300 CONTINUE
33709  coulcr=coulcr+dble(paru(101)**2*sh)/(16d0*coulcp*coulck)*
33710  & (coulcs/nstp)
33711  faccou=abs(coulcr)**2
33712  ELSEIF(mstp(40).EQ.3) THEN
33713  couldc=paru(1)-2d0*(1d0-be34)**2*atan((coulp1**2+
33714  & coulp2**2-coulp**2)/max(1d-10,2d0*coulp*coulp1))
33715  faccou=1d0+0.5d0*paru(101)*couldc/max(1d-5,be34)
33716  ENDIF
33717  ELSEIF(mstp(40).EQ.4) THEN
33718  faccou=1d0+0.5d0*paru(101)*paru(1)/max(1d-5,be34)
33719  ELSE
33720  faccou=1d0
33721  ENDIF
33722  vint(95)=faccou
33723  facww=facww*faccou
33724 C...Loop over allowed flavours
33725  DO 310 i=mmina,mmaxa
33726  IF(i.EQ.0.OR.kfac(1,i)*kfac(2,-i).EQ.0) goto 310
33727  ei=kchg(iabs(i),1)/3d0
33728  ai=sign(1d0,ei+0.1d0)
33729  vi=ai-4d0*ei*xwv
33730  fcoi=1d0
33731  IF(iabs(i).LE.10) fcoi=faca/3d0
33732  IF(mstp(50).LE.0.OR.iabs(i).LE.10) THEN
33733  IF(ai.LT.0d0) THEN
33734  dsigww=(cgg*ei**2+cgz*vi*ei+czz*(vi**2+ai**2))*gs+
33735  & (cng*ei+cnz*(vi+ai))*gst+cnn*gt
33736  ELSE
33737  dsigww=(cgg*ei**2+cgz*vi*ei+czz*(vi**2+ai**2))*gs-
33738  & (cng*ei+cnz*(vi+ai))*gsu+cnn*gu
33739  ENDIF
33740  ELSE
33741  xmw02=0.5d0*(sqm3+sqm4)-0.25d0*(sqm3-sqm4)**2/sh
33742  bet=sqrt(1d0-4d0*xmw02/sh)
33743  gat=1d0/sqrt(1d0-bet**2)
33744  sthe2=1d0-cth**2
33745  ampzg=bet**3*(16d0+(4d0*bet**2*gat**2+3d0/gat**2)*sthe2)
33746  ampnu=bet*(2d0+bet**2*gat**2*sthe2/2d0+
33747  & 2d0*bet**2*(1d0-bet**2)*sthe2/(1d0-2d0*bet*cth+bet**2)**2)
33748  ampng=bet*((1d0+bet**2)*(4d0+bet**2*gat**2*sthe2)+
33749  & 2d0*(1d0-bet**2)*(bet**2*sthe2-2d0*(1d0-bet**2))/
33750  & (1d0-2d0*bet*cth+bet**2))
33751  propi1=(0.25d0*sqmz/xmw02)*hbwzc*(1d0-sqmz/sh)
33752  propi2=(0.25d0*sqmz/xmw02)**2*hbwzc
33753  a0=(2d0*(xmw02/sqmz)-(1d0-bet**2)*xw)*poll
33754  a1=(2d0*(xmw02/sqmz)**2-2*xmw02/sqmz*(1d0-bet**2)*xw)*poll
33755  a2=(1d0-bet**2)**2*xw**2*(polr+poll)/2d0
33756  atot=ampnu*poll+(a1+a2)*propi2*ampzg-a0*propi1*ampng
33757  atot=atot*cnn/sqmw*sh/bet*2d0
33758  dsigww=atot
33759  ENDIF
33760  nchn=nchn+1
33761  isig(nchn,1)=i
33762  isig(nchn,2)=-i
33763  isig(nchn,3)=1
33764  sigh(nchn)=facww*fcoi*dsigww
33765  310 CONTINUE
33766 
33767  ELSEIF(isub.EQ.30) THEN
33768 C...f + g -> f + (gamma*/Z0) (q + g -> q + (gamma*/Z0) only)
33769  fzq=comfac*faca*as*aem*(1d0/3d0)*(sh2+uh2+2d0*sqm4*th)/
33770  & (-sh*uh)
33771 C...gamma, gamma/Z interference and Z couplings to final fermion pairs
33772  hfgg=0d0
33773  hfgz=0d0
33774  hfzz=0d0
33775  radc4=1d0+pyalps(sqm4)/paru(1)
33776  DO 320 i=1,min(16,mdcy(23,3))
33777  idc=i+mdcy(23,2)-1
33778  IF(mdme(idc,1).LT.0) goto 320
33779  imdm=0
33780  IF(mdme(idc,1).EQ.1.OR.mdme(idc,1).EQ.2.OR.mdme(idc,1).EQ.4)
33781  & imdm=1
33782  IF(i.LE.8) THEN
33783  ef=kchg(i,1)/3d0
33784  af=sign(1d0,ef+0.1d0)
33785  vf=af-4d0*ef*xwv
33786  ELSEIF(i.LE.16) THEN
33787  ef=kchg(i+2,1)/3d0
33788  af=sign(1d0,ef+0.1d0)
33789  vf=af-4d0*ef*xwv
33790  ENDIF
33791  rm1=pmas(iabs(kfdp(idc,1)),1)**2/sqm4
33792  IF(4d0*rm1.LT.1d0) THEN
33793  fcof=1d0
33794  IF(i.LE.8) fcof=3d0*radc4
33795  be34=sqrt(max(0d0,1d0-4d0*rm1))
33796  IF(imdm.EQ.1) THEN
33797  hfgg=hfgg+fcof*ef**2*(1d0+2d0*rm1)*be34
33798  hfgz=hfgz+fcof*ef*vf*(1d0+2d0*rm1)*be34
33799  hfzz=hfzz+fcof*(vf**2*(1d0+2d0*rm1)+
33800  & af**2*(1d0-4d0*rm1))*be34
33801  ENDIF
33802  ENDIF
33803  320 CONTINUE
33804 C...Propagators: as simulated in PYOFSH and as desired
33805  hbw4=(1d0/paru(1))*gmmz/((sqm4-sqmz)**2+gmmz**2)
33806  mint15=mint(15)
33807  mint(15)=1
33808  mint(61)=1
33809  CALL pywidt(23,sqm4,wdtp,wdte)
33810  mint(15)=mint15
33811  hfaem=(paru(108)/paru(2))*(2d0/3d0)
33812  hfgg=hfgg*hfaem*vint(111)/sqm4
33813  hfgz=hfgz*hfaem*vint(112)/sqm4
33814  hfzz=hfzz*hfaem*vint(114)/sqm4
33815 C...Loop over flavours; consider full gamma/Z structure
33816  DO 340 i=mmina,mmaxa
33817  IF(i.EQ.0.OR.iabs(i).GT.mstp(58)) goto 340
33818  ei=kchg(iabs(i),1)/3d0
33819  ai=sign(1d0,ei)
33820  vi=ai-4d0*ei*xwv
33821  faczq=fzq*(ei**2*hfgg+ei*vi*hfgz+
33822  & (vi**2+ai**2)*hfzz)/hbw4
33823  DO 330 isde=1,2
33824  IF(isde.EQ.1.AND.kfac(1,i)*kfac(2,21).EQ.0) goto 330
33825  IF(isde.EQ.2.AND.kfac(1,21)*kfac(2,i).EQ.0) goto 330
33826  nchn=nchn+1
33827  isig(nchn,isde)=i
33828  isig(nchn,3-isde)=21
33829  isig(nchn,3)=1
33830  sigh(nchn)=faczq
33831  330 CONTINUE
33832  340 CONTINUE
33833 
33834  ELSEIF(isub.EQ.31) THEN
33835 C...f + g -> f' + W+/- (q + g -> q' + W+/- only)
33836  facwq=comfac*faca*as*aem/xw*1d0/12d0*
33837  & (sh2+uh2+2d0*sqm4*th)/(-sh*uh)
33838 C...Propagators: as simulated in PYOFSH and as desired
33839  hbw4=gmmw/((sqm4-sqmw)**2+gmmw**2)
33840  CALL pywidt(24,sqm4,wdtp,wdte)
33841  gmmwc=sqrt(sqm4)*wdtp(0)
33842  hbw4c=gmmwc/((sqm4-sqmw)**2+gmmwc**2)
33843  facwq=facwq*hbw4c/hbw4
33844  DO 360 i=mmina,mmaxa
33845  IF(i.EQ.0.OR.iabs(i).GT.mstp(58)) goto 360
33846  ia=iabs(i)
33847  kchw=isign(1,kchg(ia,1)*isign(1,i))
33848  widsc=(wdte(0,1)+wdte(0,(5-kchw)/2)+wdte(0,4))/wdtp(0)
33849  DO 350 isde=1,2
33850  IF(isde.EQ.1.AND.kfac(1,i)*kfac(2,21).EQ.0) goto 350
33851  IF(isde.EQ.2.AND.kfac(1,21)*kfac(2,i).EQ.0) goto 350
33852  nchn=nchn+1
33853  isig(nchn,isde)=i
33854  isig(nchn,3-isde)=21
33855  isig(nchn,3)=1
33856  sigh(nchn)=facwq*vint(180+i)*widsc
33857  350 CONTINUE
33858  360 CONTINUE
33859 
33860  ELSEIF(isub.EQ.35) THEN
33861 C...f + gamma -> f + (gamma*/Z0)
33862  IF(mint(15).EQ.22.AND.vint(3).LT.0d0) THEN
33863  fzqn=sh2+uh2+2d0*(sqm4-vint(3)**2)*th
33864  fzqdtm=vint(3)**2*sqm4-sh*(uh-vint(4)**2)
33865  ELSEIF(mint(16).EQ.22.AND.vint(4).LT.0d0) THEN
33866  fzqn=sh2+uh2+2d0*(sqm4-vint(4)**2)*th
33867  fzqdtm=vint(4)**2*sqm4-sh*(uh-vint(3)**2)
33868  ELSE
33869  fzqn=sh2+uh2+2d0*sqm4*th
33870  fzqdtm=-sh*uh
33871  ENDIF
33872  fzqn=comfac*2d0*aem**2*max(0d0,fzqn)
33873 C...gamma, gamma/Z interference and Z couplings to final fermion pairs
33874  hfgg=0d0
33875  hfgz=0d0
33876  hfzz=0d0
33877  radc4=1d0+pyalps(sqm4)/paru(1)
33878  DO 370 i=1,min(16,mdcy(23,3))
33879  idc=i+mdcy(23,2)-1
33880  IF(mdme(idc,1).LT.0) goto 370
33881  imdm=0
33882  IF(mdme(idc,1).EQ.1.OR.mdme(idc,1).EQ.2.OR.mdme(idc,1).EQ.4)
33883  & imdm=1
33884  IF(i.LE.8) THEN
33885  ef=kchg(i,1)/3d0
33886  af=sign(1d0,ef+0.1d0)
33887  vf=af-4d0*ef*xwv
33888  ELSEIF(i.LE.16) THEN
33889  ef=kchg(i+2,1)/3d0
33890  af=sign(1d0,ef+0.1d0)
33891  vf=af-4d0*ef*xwv
33892  ENDIF
33893  rm1=pmas(iabs(kfdp(idc,1)),1)**2/sqm4
33894  IF(4d0*rm1.LT.1d0) THEN
33895  fcof=1d0
33896  IF(i.LE.8) fcof=3d0*radc4
33897  be34=sqrt(max(0d0,1d0-4d0*rm1))
33898  IF(imdm.EQ.1) THEN
33899  hfgg=hfgg+fcof*ef**2*(1d0+2d0*rm1)*be34
33900  hfgz=hfgz+fcof*ef*vf*(1d0+2d0*rm1)*be34
33901  hfzz=hfzz+fcof*(vf**2*(1d0+2d0*rm1)+
33902  & af**2*(1d0-4d0*rm1))*be34
33903  ENDIF
33904  ENDIF
33905  370 CONTINUE
33906 C...Propagators: as simulated in PYOFSH and as desired
33907  hbw4=(1d0/paru(1))*gmmz/((sqm4-sqmz)**2+gmmz**2)
33908  mint15=mint(15)
33909  mint(15)=1
33910  mint(61)=1
33911  CALL pywidt(23,sqm4,wdtp,wdte)
33912  mint(15)=mint15
33913  hfaem=(paru(108)/paru(2))*(2d0/3d0)
33914  hfgg=hfgg*hfaem*vint(111)/sqm4
33915  hfgz=hfgz*hfaem*vint(112)/sqm4
33916  hfzz=hfzz*hfaem*vint(114)/sqm4
33917 C...Loop over flavours; consider full gamma/Z structure
33918  DO 390 i=mmina,mmaxa
33919  IF(i.EQ.0) goto 390
33920  ei=kchg(iabs(i),1)/3d0
33921  ai=sign(1d0,ei)
33922  vi=ai-4d0*ei*xwv
33923  faczq=ei**2*(ei**2*hfgg+ei*vi*hfgz+
33924  & (vi**2+ai**2)*hfzz)/hbw4
33925  fzqd=max(pmas(iabs(i),1)**2*sqm4,fzqdtm)
33926  DO 380 isde=1,2
33927  IF(isde.EQ.1.AND.kfac(1,i)*kfac(2,22).EQ.0) goto 380
33928  IF(isde.EQ.2.AND.kfac(1,22)*kfac(2,i).EQ.0) goto 380
33929  nchn=nchn+1
33930  isig(nchn,isde)=i
33931  isig(nchn,3-isde)=22
33932  isig(nchn,3)=1
33933  sigh(nchn)=faczq*fzqn/fzqd
33934  380 CONTINUE
33935  390 CONTINUE
33936 
33937  ELSEIF(isub.EQ.36) THEN
33938 C...f + gamma -> f' + W+/-
33939  fwq=comfac*aem**2/(2d0*xw)*
33940  & (sh2+uh2+2d0*sqm4*th)/(sqpth*sqm4-sh*uh)
33941 C...Propagators: as simulated in PYOFSH and as desired
33942  hbw4=gmmw/((sqm4-sqmw)**2+gmmw**2)
33943  CALL pywidt(24,sqm4,wdtp,wdte)
33944  gmmwc=sqrt(sqm4)*wdtp(0)
33945  hbw4c=gmmwc/((sqm4-sqmw)**2+gmmwc**2)
33946  fwq=fwq*hbw4c/hbw4
33947  DO 410 i=mmina,mmaxa
33948  IF(i.EQ.0) goto 410
33949  ia=iabs(i)
33950  eia=abs(kchg(iabs(i),1)/3d0)
33951  facwq=fwq*(eia-sh/(sh+uh))**2
33952  kchw=isign(1,kchg(ia,1)*isign(1,i))
33953  widsc=(wdte(0,1)+wdte(0,(5-kchw)/2)+wdte(0,4))/wdtp(0)
33954  DO 400 isde=1,2
33955  IF(isde.EQ.1.AND.kfac(1,i)*kfac(2,22).EQ.0) goto 400
33956  IF(isde.EQ.2.AND.kfac(1,22)*kfac(2,i).EQ.0) goto 400
33957  nchn=nchn+1
33958  isig(nchn,isde)=i
33959  isig(nchn,3-isde)=22
33960  isig(nchn,3)=1
33961  sigh(nchn)=facwq*vint(180+i)*widsc
33962  400 CONTINUE
33963  410 CONTINUE
33964  ENDIF
33965 
33966  ELSEIF(isub.LE.100) THEN
33967  IF(isub.EQ.69) THEN
33968 C...gamma + gamma -> W+ + W-
33969  sqmwe=max(0.5d0*sqmw,sqrt(sqm3*sqm4))
33970  fprop=sh2/((sqmwe-th)*(sqmwe-uh))
33971  facww=comfac*6d0*aem**2*(1d0-fprop*(4d0/3d0+2d0*sqmwe/sh)+
33972  & fprop**2*(2d0/3d0+2d0*(sqmwe/sh)**2))*wids(24,1)
33973  IF(kfac(1,22)*kfac(2,22).EQ.0) goto 420
33974  nchn=nchn+1
33975  isig(nchn,1)=22
33976  isig(nchn,2)=22
33977  isig(nchn,3)=1
33978  sigh(nchn)=facww
33979  420 CONTINUE
33980 
33981  ELSEIF(isub.EQ.70) THEN
33982 C...gamma + W+/- -> Z0 + W+/-
33983  sqmwe=max(0.5d0*sqmw,sqrt(sqm3*sqm4))
33984  fprop=(th-sqmwe)**2/(-sh*(sqmwe-uh))
33985  faczw=comfac*6d0*aem**2*(xw1/xw)*
33986  & (1d0-fprop*(4d0/3d0+2d0*sqmwe/(th-sqmwe))+
33987  & fprop**2*(2d0/3d0+2d0*(sqmwe/(th-sqmwe))**2))*wids(23,2)
33988  DO 440 kchw=1,-1,-2
33989  DO 430 isde=1,2
33990  IF(kfac(isde,22)*kfac(3-isde,24*kchw).EQ.0) goto 430
33991  nchn=nchn+1
33992  isig(nchn,isde)=22
33993  isig(nchn,3-isde)=24*kchw
33994  isig(nchn,3)=1
33995  sigh(nchn)=faczw*wids(24,(5-kchw)/2)
33996  430 CONTINUE
33997  440 CONTINUE
33998  ENDIF
33999  ENDIF
34000 
34001  RETURN
34002  END
34003 
34004 C*********************************************************************
34005 
34006 C...PYSGHG
34007 C...Subprocess cross sections for Higgs processes,
34008 C...except Higgs pairs in PYSGSU, but including WW scattering.
34009 C...Auxiliary to PYSIGH.
34010 
34011  SUBROUTINE pysghg(NCHN,SIGS)
34012 
34013 C...Double precision and integer declarations
34014  IMPLICIT DOUBLE PRECISION(a-h, o-z)
34015  IMPLICIT INTEGER(i-n)
34016  INTEGER pyk,pychge,pycomp
34017 C...Parameter statement to help give large particle numbers.
34018  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
34019  &kexcit=4000000,kdimen=5000000)
34020 C...Commonblocks
34021  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
34022  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
34023  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
34024  common/pypars/mstp(200),parp(200),msti(200),pari(200)
34025  common/pyint1/mint(400),vint(400)
34026  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
34027  common/pyint3/xsfx(2,-40:40),isig(1000,3),sigh(1000)
34028  common/pyint4/mwid(500),wids(500,5)
34029  common/pysubs/msel,mselpd,msub(500),kfin(2,-40:40),ckin(200)
34030  common/pymssm/imss(0:99),rmss(0:99)
34031  common/pysgcm/isub,isubsv,mmin1,mmax1,mmin2,mmax2,mmina,mmaxa,
34032  &kfac(2,-40:40),comfac,fack,faca,sh,th,uh,sh2,th2,uh2,sqm3,sqm4,
34033  &shr,sqpth,taup,be34,cth,x(2),sqmz,sqmw,gmmz,gmmw,
34034  &aem,as,xw,xw1,xwc,xwv,poll,polr,polll,polrr
34035  SAVE /pydat1/,/pydat2/,/pydat3/,/pypars/,/pyint1/,/pyint2/,
34036  &/pyint3/,/pyint4/,/pysubs/,/pymssm/,/pysgcm/
34037 C...Local arrays and complex variables
34038  dimension wdtp(0:400),wdte(0:400,0:5)
34039  COMPLEX*16 a004,a204,a114,a00u,a20u,a11u
34040  COMPLEX*16 cigtot,ciztot,f0alp,f1alp,f2alp,f0bet,f1bet,f2bet,fif
34041 
34042 C...Convert H or A process into equivalent h one
34043  ihigg=1
34044  kfhigg=25
34045  IF(isub.EQ.401.OR.isub.EQ.402) THEN
34046  kfhigg=kfpr(isub,1)
34047  END IF
34048  IF((isub.GE.151.AND.isub.LE.160).OR.(isub.GE.171.AND.
34049  &isub.LE.190)) THEN
34050  ihigg=2
34051  IF(mod(isub-1,10).GE.5) ihigg=3
34052  kfhigg=33+ihigg
34053  IF(isub.EQ.151.OR.isub.EQ.156) isub=3
34054  IF(isub.EQ.152.OR.isub.EQ.157) isub=102
34055  IF(isub.EQ.153.OR.isub.EQ.158) isub=103
34056  IF(isub.EQ.171.OR.isub.EQ.176) isub=24
34057  IF(isub.EQ.172.OR.isub.EQ.177) isub=26
34058  IF(isub.EQ.173.OR.isub.EQ.178) isub=123
34059  IF(isub.EQ.174.OR.isub.EQ.179) isub=124
34060  IF(isub.EQ.181.OR.isub.EQ.186) isub=121
34061  IF(isub.EQ.182.OR.isub.EQ.187) isub=122
34062  IF(isub.EQ.183.OR.isub.EQ.188) isub=111
34063  IF(isub.EQ.184.OR.isub.EQ.189) isub=112
34064  IF(isub.EQ.185.OR.isub.EQ.190) isub=113
34065  ENDIF
34066  sqmh=pmas(kfhigg,1)**2
34067  gmmh=pmas(kfhigg,1)*pmas(kfhigg,2)
34068 
34069 C...Strongly interacting Z_L/W_L model of Dobado, Herrero, Terron
34070  IF((mstp(46).GE.3.AND.mstp(46).LE.6).AND.(isub.EQ.71.OR.isub.EQ.
34071  &72.OR.isub.EQ.73.OR.isub.EQ.76.OR.isub.EQ.77)) THEN
34072 C...Calculate M_R and N_R functions for Higgs-like and QCD-like models
34073  IF(mstp(46).LE.4) THEN
34074  hdtlh=log(pmas(25,1)/parp(44))
34075  hdtmr=(4.5d0*paru(1)/sqrt(3d0)-74d0/9d0)/8d0+hdtlh/12d0
34076  hdtnr=-1d0/18d0+hdtlh/6d0
34077  ELSE
34078  hdtnm=0.125d0*(1d0/(288d0*paru(1)**2)+(parp(47)/parp(45))**2)
34079  hdtlq=log(parp(45)/parp(44))
34080  hdtmr=-(4d0*paru(1))**2*0.5d0*hdtnm+hdtlq/12d0
34081  hdtnr=(4d0*paru(1))**2*hdtnm+hdtlq/6d0
34082  ENDIF
34083 
34084 C...Calculate lowest and next-to-lowest order partial wave amplitudes
34085  hdtv=1d0/(16d0*paru(1)*parp(47)**2)
34086  a00l=dble(hdtv*sh)
34087  a20l=-0.5d0*a00l
34088  a11l=a00l/6d0
34089  hdtls=log(sh/parp(44)**2)
34090  a004=dble((hdtv*sh)**2/(4d0*paru(1)))*
34091  & cmplx(dble((176d0*hdtmr+112d0*hdtnr)/3d0+11d0/27d0-
34092  & (50d0/9d0)*hdtls),dble(4d0*paru(1)))
34093  a204=dble((hdtv*sh)**2/(4d0*paru(1)))*
34094  & cmplx(dble(32d0*(hdtmr+2d0*hdtnr)/3d0+25d0/54d0-
34095  & (20d0/9d0)*hdtls),dble(paru(1)))
34096  a114=dble((hdtv*sh)**2/(6d0*paru(1)))*
34097  & cmplx(dble(4d0*(-2d0*hdtmr+hdtnr)-1d0/18d0),dble(paru(1)/6d0))
34098 
34099 C...Unitarize partial wave amplitudes with Pade or K-matrix method
34100  IF(mstp(46).EQ.3.OR.mstp(46).EQ.5) THEN
34101  a00u=a00l/(1d0-a004/a00l)
34102  a20u=a20l/(1d0-a204/a20l)
34103  a11u=a11l/(1d0-a114/a11l)
34104  ELSE
34105  a00u=(a00l+dble(a004))/(1d0-dcmplx(0.d0,a00l+dble(a004)))
34106  a20u=(a20l+dble(a204))/(1d0-dcmplx(0.d0,a20l+dble(a204)))
34107  a11u=(a11l+dble(a114))/(1d0-dcmplx(0.d0,a11l+dble(a114)))
34108  ENDIF
34109  ENDIF
34110 
34111 C...Differential cross section expressions.
34112 
34113  IF(isub.LE.60) THEN
34114  IF(isub.EQ.3) THEN
34115 C...f + fbar -> h0 (or H0, or A0)
34116  CALL pywidt(kfhigg,sh,wdtp,wdte)
34117  hs=shr*wdtp(0)
34118  facbw=4d0*comfac/((sh-sqmh)**2+hs**2)
34119  IF(abs(shr-pmas(kfhigg,1)).GT.parp(48)*pmas(kfhigg,2))
34120  & facbw=0d0
34121  hp=aem/(8d0*xw)*sh/sqmw*sh
34122  hf=shr*(wdte(0,1)+wdte(0,2)+wdte(0,4))
34123  DO 100 i=mmina,mmaxa
34124  IF(i.EQ.0.OR.kfac(1,i)*kfac(2,-i).EQ.0) goto 100
34125  ia=iabs(i)
34126  rmq=pymrun(ia,sh)**2/sh
34127  hi=hp*rmq
34128  IF(ia.LE.10) hi=hp*rmq*faca/3d0
34129  IF(mstp(4).GE.1.OR.ihigg.GE.2) THEN
34130  ikfi=1
34131  IF(ia.LE.10.AND.mod(ia,2).EQ.0) ikfi=2
34132  IF(ia.GT.10) ikfi=3
34133  hi=hi*paru(150+10*ihigg+ikfi)**2
34134  IF(imss(1).NE.0.AND.ia.EQ.5) THEN
34135  hi=hi/(1d0+rmss(41))**2
34136  IF(ihigg.NE.3) THEN
34137  hi=hi*(1d0+rmss(41)*paru(152+10*ihigg)/
34138  & paru(151+10*ihigg))**2
34139  ENDIF
34140  ENDIF
34141  ENDIF
34142  nchn=nchn+1
34143  isig(nchn,1)=i
34144  isig(nchn,2)=-i
34145  isig(nchn,3)=1
34146  sigh(nchn)=hi*facbw*hf
34147  100 CONTINUE
34148 
34149  ELSEIF(isub.EQ.5) THEN
34150 C...Z0 + Z0 -> h0
34151  CALL pywidt(25,sh,wdtp,wdte)
34152  hs=shr*wdtp(0)
34153  facbw=4d0*comfac/((sh-sqmh)**2+hs**2)
34154  IF(abs(shr-pmas(25,1)).GT.parp(48)*pmas(25,2)) facbw=0d0
34155  hp=aem/(8d0*xw)*sh/sqmw*sh
34156  hf=shr*(wdte(0,1)+wdte(0,2)+wdte(0,4))
34157  hi=hp/4d0
34158  faci=8d0/(paru(1)**2*xw1)*(aem*xwc)**2
34159  DO 120 i=mmin1,mmax1
34160  IF(i.EQ.0.OR.kfac(1,i).EQ.0) goto 120
34161  DO 110 j=mmin2,mmax2
34162  IF(j.EQ.0.OR.kfac(2,j).EQ.0) goto 110
34163  ei=kchg(iabs(i),1)/3d0
34164  ai=sign(1d0,ei)
34165  vi=ai-4d0*ei*xwv
34166  ej=kchg(iabs(j),1)/3d0
34167  aj=sign(1d0,ej)
34168  vj=aj-4d0*ej*xwv
34169  nchn=nchn+1
34170  isig(nchn,1)=i
34171  isig(nchn,2)=j
34172  isig(nchn,3)=1
34173  sigh(nchn)=faci*(vi**2+ai**2)*(vj**2+aj**2)*hi*facbw*hf
34174  110 CONTINUE
34175  120 CONTINUE
34176 
34177  ELSEIF(isub.EQ.8) THEN
34178 C...W+ + W- -> h0
34179  CALL pywidt(25,sh,wdtp,wdte)
34180  hs=shr*wdtp(0)
34181  facbw=4d0*comfac/((sh-sqmh)**2+hs**2)
34182  IF(abs(shr-pmas(25,1)).GT.parp(48)*pmas(25,2)) facbw=0d0
34183  hp=aem/(8d0*xw)*sh/sqmw*sh
34184  hf=shr*(wdte(0,1)+wdte(0,2)+wdte(0,4))
34185  hi=hp/2d0
34186  faci=1d0/(4d0*paru(1)**2)*(aem/xw)**2
34187  DO 140 i=mmin1,mmax1
34188  IF(i.EQ.0.OR.kfac(1,i).EQ.0) goto 140
34189  ei=sign(1d0,dble(i))*kchg(iabs(i),1)
34190  DO 130 j=mmin2,mmax2
34191  IF(j.EQ.0.OR.kfac(2,j).EQ.0) goto 130
34192  ej=sign(1d0,dble(j))*kchg(iabs(j),1)
34193  IF(ei*ej.GT.0d0) goto 130
34194  nchn=nchn+1
34195  isig(nchn,1)=i
34196  isig(nchn,2)=j
34197  isig(nchn,3)=1
34198  sigh(nchn)=faci*vint(180+i)*vint(180+j)*hi*facbw*hf
34199  130 CONTINUE
34200  140 CONTINUE
34201 
34202  ELSEIF(isub.EQ.24) THEN
34203 C...f + fbar -> Z0 + h0 (or H0, or A0)
34204 C...Propagators: Z0, h0 as simulated in PYOFSH and as desired
34205  hbw3=gmmz/((sqm3-sqmz)**2+gmmz**2)
34206  CALL pywidt(23,sqm3,wdtp,wdte)
34207  gmmz3=sqrt(sqm3)*wdtp(0)
34208  hbw3c=gmmz3/((sqm3-sqmz)**2+gmmz3**2)
34209  hbw4=gmmh/((sqm4-sqmh)**2+gmmh**2)
34210  CALL pywidt(kfhigg,sqm4,wdtp,wdte)
34211  gmmh4=sqrt(sqm4)*wdtp(0)
34212  hbw4c=gmmh4/((sqm4-sqmh)**2+gmmh4**2)
34213  thuh=max(th*uh-sqm3*sqm4,sh*ckin(3)**2)
34214  fachz=comfac*(hbw3c/hbw3)*(hbw4c/hbw4)*8d0*(aem*xwc)**2*
34215  & (thuh+2d0*sh*sqm3)/((sh-sqmz)**2+gmmz**2)
34216  fachz=fachz*wids(23,2)*wids(kfhigg,2)
34217  IF(mstp(4).GE.1.OR.ihigg.GE.2) fachz=fachz*
34218  & paru(154+10*ihigg)**2
34219  DO 150 i=mmina,mmaxa
34220  IF(i.EQ.0.OR.kfac(1,i)*kfac(2,-i).EQ.0) goto 150
34221  ei=kchg(iabs(i),1)/3d0
34222  ai=sign(1d0,ei)
34223  vi=ai-4d0*ei*xwv
34224  fcoi=1d0
34225  IF(iabs(i).LE.10) fcoi=faca/3d0
34226  nchn=nchn+1
34227  isig(nchn,1)=i
34228  isig(nchn,2)=-i
34229  isig(nchn,3)=1
34230  sigh(nchn)=fachz*fcoi*(vi**2+ai**2)
34231  150 CONTINUE
34232 
34233  ELSEIF(isub.EQ.26) THEN
34234 C...f + fbar' -> W+/- + h0 (or H0, or A0)
34235 C...Propagators: W+-, h0 as simulated in PYOFSH and as desired
34236  hbw3=gmmw/((sqm3-sqmw)**2+gmmw**2)
34237  CALL pywidt(24,sqm3,wdtp,wdte)
34238  gmmw3=sqrt(sqm3)*wdtp(0)
34239  hbw3c=gmmw3/((sqm3-sqmw)**2+gmmw3**2)
34240  hbw4=gmmh/((sqm4-sqmh)**2+gmmh**2)
34241  CALL pywidt(kfhigg,sqm4,wdtp,wdte)
34242  gmmh4=sqrt(sqm4)*wdtp(0)
34243  hbw4c=gmmh4/((sqm4-sqmh)**2+gmmh4**2)
34244  thuh=max(th*uh-sqm3*sqm4,sh*ckin(3)**2)
34245  fachw=comfac*0.125d0*(aem/xw)**2*(thuh+2d0*sh*sqm3)/
34246  & ((sh-sqmw)**2+gmmw**2)*(hbw3c/hbw3)*(hbw4c/hbw4)
34247  fachw=fachw*wids(kfhigg,2)
34248  IF(mstp(4).GE.1.OR.ihigg.GE.2) fachw=fachw*
34249  & paru(155+10*ihigg)**2
34250  DO 170 i=mmin1,mmax1
34251  ia=iabs(i)
34252  IF(i.EQ.0.OR.ia.GT.20.OR.kfac(1,i).EQ.0) goto 170
34253  DO 160 j=mmin2,mmax2
34254  ja=iabs(j)
34255  IF(j.EQ.0.OR.ja.GT.20.OR.kfac(1,j).EQ.0) goto 160
34256  IF(i*j.GT.0.OR.mod(ia+ja,2).EQ.0) goto 160
34257  IF((ia.LE.10.AND.ja.GT.10).OR.(ia.GT.10.AND.ja.LE.10))
34258  & goto 160
34259  kchw=(kchg(ia,1)*isign(1,i)+kchg(ja,1)*isign(1,j))/3
34260  fckm=1d0
34261  IF(ia.LE.10) fckm=vckm((ia+1)/2,(ja+1)/2)
34262  fcoi=1d0
34263  IF(ia.LE.10) fcoi=faca/3d0
34264  nchn=nchn+1
34265  isig(nchn,1)=i
34266  isig(nchn,2)=j
34267  isig(nchn,3)=1
34268  sigh(nchn)=fachw*fcoi*fckm*wids(24,(5-kchw)/2)
34269  160 CONTINUE
34270  170 CONTINUE
34271 
34272  ELSEIF(isub.EQ.32) THEN
34273 C...f + g -> f + h0 (q + g -> q + h0 only)
34274  fhcq=comfac*faca*as*aem/xw*1d0/24d0
34275 C...H propagator: as simulated in PYOFSH and as desired
34276  sqmhc=pmas(25,1)**2
34277  gmmhc=pmas(25,1)*pmas(25,2)
34278  hbw4=gmmhc/((sqm4-sqmhc)**2+gmmhc**2)
34279  CALL pywidt(25,sqm4,wdtp,wdte)
34280  gmmhcc=sqrt(sqm4)*wdtp(0)
34281  hbw4c=gmmhcc/((sqm4-sqmhc)**2+gmmhcc**2)
34282  fhcq=fhcq*hbw4c/hbw4
34283  DO 190 i=mmina,mmaxa
34284  ia=iabs(i)
34285  IF(ia.NE.5) goto 190
34286  sqml=pymrun(ia,sh)**2
34287  sqmq=pmas(ia,1)**2
34288  fachcq=fhcq*sqml/sqmw*
34289  & (sh/(sqmq-uh)+2d0*sqmq*(sqm4-uh)/(sqmq-uh)**2+(sqmq-uh)/sh-
34290  & 2d0*sqmq/(sqmq-uh)+2d0*(sqm4-uh)/(sqmq-uh)*
34291  & (sqm4-sqmq-sh)/sh)
34292  DO 180 isde=1,2
34293  IF(isde.EQ.1.AND.kfac(1,i)*kfac(2,21).EQ.0) goto 180
34294  IF(isde.EQ.2.AND.kfac(1,21)*kfac(2,i).EQ.0) goto 180
34295  nchn=nchn+1
34296  isig(nchn,isde)=i
34297  isig(nchn,3-isde)=21
34298  isig(nchn,3)=1
34299  sigh(nchn)=fachcq*wids(25,2)
34300  180 CONTINUE
34301  190 CONTINUE
34302  ENDIF
34303 
34304  ELSEIF(isub.LE.80) THEN
34305  IF(isub.EQ.71) THEN
34306 C...Z0 + Z0 -> Z0 + Z0
34307  IF(sh.LE.4.01d0*sqmz) goto 220
34308 
34309  IF(mstp(46).LE.2) THEN
34310 C...Exact scattering ME:s for on-mass-shell gauge bosons
34311  be2=1d0-4d0*sqmz/sh
34312  th=-0.5d0*sh*be2*(1d0-cth)
34313  uh=-0.5d0*sh*be2*(1d0+cth)
34314  IF(max(th,uh).GT.-1d0) goto 220
34315  shang=1d0/xw1*sqmw/sqmz*(1d0+be2)**2
34316  ashre=(sh-sqmh)/((sh-sqmh)**2+gmmh**2)*shang
34317  ashim=-gmmh/((sh-sqmh)**2+gmmh**2)*shang
34318  thang=1d0/xw1*sqmw/sqmz*(be2-cth)**2
34319  athre=(th-sqmh)/((th-sqmh)**2+gmmh**2)*thang
34320  athim=-gmmh/((th-sqmh)**2+gmmh**2)*thang
34321  uhang=1d0/xw1*sqmw/sqmz*(be2+cth)**2
34322  auhre=(uh-sqmh)/((uh-sqmh)**2+gmmh**2)*uhang
34323  auhim=-gmmh/((uh-sqmh)**2+gmmh**2)*uhang
34324  faczz=comfac*1d0/(4096d0*paru(1)**2*16d0*xw1**2)*
34325  & (aem/xw)**4*(sh/sqmw)**2*(sqmz/sqmw)*sh2
34326  IF(mstp(46).LE.0) faczz=faczz*(ashre**2+ashim**2)
34327  IF(mstp(46).EQ.1) faczz=faczz*((ashre+athre+auhre)**2+
34328  & (ashim+athim+auhim)**2)
34329  IF(mstp(46).EQ.2) faczz=0d0
34330 
34331  ELSE
34332 C...Strongly interacting Z_L/W_L model of Dobado, Herrero, Terron
34333  faczz=comfac*(aem/(16d0*paru(1)*xw*xw1))**2*(64d0/9d0)*
34334  & abs(a00u+2d0*a20u)**2
34335  ENDIF
34336  faczz=faczz*wids(23,1)
34337 
34338  DO 210 i=mmin1,mmax1
34339  IF(i.EQ.0.OR.kfac(1,i).EQ.0) goto 210
34340  ei=kchg(iabs(i),1)/3d0
34341  ai=sign(1d0,ei)
34342  vi=ai-4d0*ei*xwv
34343  avi=ai**2+vi**2
34344  DO 200 j=mmin2,mmax2
34345  IF(j.EQ.0.OR.kfac(2,j).EQ.0) goto 200
34346  ej=kchg(iabs(j),1)/3d0
34347  aj=sign(1d0,ej)
34348  vj=aj-4d0*ej*xwv
34349  avj=aj**2+vj**2
34350  nchn=nchn+1
34351  isig(nchn,1)=i
34352  isig(nchn,2)=j
34353  isig(nchn,3)=1
34354  sigh(nchn)=0.5d0*faczz*avi*avj
34355  200 CONTINUE
34356  210 CONTINUE
34357  220 CONTINUE
34358 
34359  ELSEIF(isub.EQ.72) THEN
34360 C...Z0 + Z0 -> W+ + W-
34361  IF(sh.LE.4.01d0*sqmz) goto 250
34362 
34363  IF(mstp(46).LE.2) THEN
34364 C...Exact scattering ME:s for on-mass-shell gauge bosons
34365  be2=sqrt((1d0-4d0*sqmw/sh)*(1d0-4d0*sqmz/sh))
34366  cth2=cth**2
34367  th=-0.5d0*sh*(1d0-2d0*(sqmw+sqmz)/sh-be2*cth)
34368  uh=-0.5d0*sh*(1d0-2d0*(sqmw+sqmz)/sh+be2*cth)
34369  IF(max(th,uh).GT.-1d0) goto 250
34370  shang=4d0*sqrt(sqmw/(sqmz*xw1))*(1d0-2d0*sqmw/sh)*
34371  & (1d0-2d0*sqmz/sh)
34372  ashre=(sh-sqmh)/((sh-sqmh)**2+gmmh**2)*shang
34373  ashim=-gmmh/((sh-sqmh)**2+gmmh**2)*shang
34374  atwre=xw1/sqmz*sh/(th-sqmw)*((cth-be2)**2*(3d0/2d0+be2/2d0*
34375  & cth-(sqmw+sqmz)/sh+(sqmw-sqmz)**2/(sh*sqmw))+4d0*
34376  & ((sqmw+sqmz)/sh*(1d0-3d0*cth2)+8d0*sqmw*sqmz/sh2*
34377  & (2d0*cth2-1d0)+4d0*(sqmw**2+sqmz**2)/sh2*cth2+
34378  & 2d0*(sqmw+sqmz)/sh*be2*cth))
34379  atwim=0d0
34380  auwre=xw1/sqmz*sh/(uh-sqmw)*((cth+be2)**2*(3d0/2d0-be2/2d0*
34381  & cth-(sqmw+sqmz)/sh+(sqmw-sqmz)**2/(sh*sqmw))+4d0*
34382  & ((sqmw+sqmz)/sh*(1d0-3d0*cth2)+8d0*sqmw*sqmz/sh2*
34383  & (2d0*cth2-1d0)+4d0*(sqmw**2+sqmz**2)/sh2*cth2-
34384  & 2d0*(sqmw+sqmz)/sh*be2*cth))
34385  auwim=0d0
34386  a4re=2d0*xw1/sqmz*(3d0-cth2-4d0*(sqmw+sqmz)/sh)
34387  a4im=0d0
34388  facww=comfac*1d0/(4096d0*paru(1)**2*16d0*xw1**2)*
34389  & (aem/xw)**4*(sh/sqmw)**2*(sqmz/sqmw)*sh2
34390  IF(mstp(46).LE.0) facww=facww*(ashre**2+ashim**2)
34391  IF(mstp(46).EQ.1) facww=facww*((ashre+atwre+auwre+a4re)**2+
34392  & (ashim+atwim+auwim+a4im)**2)
34393  IF(mstp(46).EQ.2) facww=facww*((atwre+auwre+a4re)**2+
34394  & (atwim+auwim+a4im)**2)
34395 
34396  ELSE
34397 C...Strongly interacting Z_L/W_L model of Dobado, Herrero, Terron
34398  facww=comfac*(aem/(16d0*paru(1)*xw*xw1))**2*(64d0/9d0)*
34399  & abs(a00u-a20u)**2
34400  ENDIF
34401  facww=facww*wids(24,1)
34402 
34403  DO 240 i=mmin1,mmax1
34404  IF(i.EQ.0.OR.kfac(1,i).EQ.0) goto 240
34405  ei=kchg(iabs(i),1)/3d0
34406  ai=sign(1d0,ei)
34407  vi=ai-4d0*ei*xwv
34408  avi=ai**2+vi**2
34409  DO 230 j=mmin2,mmax2
34410  IF(j.EQ.0.OR.kfac(2,j).EQ.0) goto 230
34411  ej=kchg(iabs(j),1)/3d0
34412  aj=sign(1d0,ej)
34413  vj=aj-4d0*ej*xwv
34414  avj=aj**2+vj**2
34415  nchn=nchn+1
34416  isig(nchn,1)=i
34417  isig(nchn,2)=j
34418  isig(nchn,3)=1
34419  sigh(nchn)=facww*avi*avj
34420  230 CONTINUE
34421  240 CONTINUE
34422  250 CONTINUE
34423 
34424  ELSEIF(isub.EQ.73) THEN
34425 C...Z0 + W+/- -> Z0 + W+/-
34426  IF(sh.LE.2d0*sqmz+2d0*sqmw) goto 280
34427 
34428  IF(mstp(46).LE.2) THEN
34429 C...Exact scattering ME:s for on-mass-shell gauge bosons
34430  be2=1d0-2d0*(sqmz+sqmw)/sh+((sqmz-sqmw)/sh)**2
34431  ep1=1d0-(sqmz-sqmw)/sh
34432  ep2=1d0+(sqmz-sqmw)/sh
34433  th=-0.5d0*sh*be2*(1d0-cth)
34434  uh=(sqmz-sqmw)**2/sh-0.5d0*sh*be2*(1d0+cth)
34435  IF(max(th,uh).GT.-1d0) goto 280
34436  thang=(be2-ep1*cth)*(be2-ep2*cth)
34437  athre=(th-sqmh)/((th-sqmh)**2+gmmh**2)*thang
34438  athim=-gmmh/((th-sqmh)**2+gmmh**2)*thang
34439  aswre=-xw1/sqmz*sh/(sh-sqmw)*(-be2*(ep1+ep2)**4*cth+
34440  & 1d0/4d0*(be2+ep1*ep2)**2*((ep1-ep2)**2-4d0*be2*cth)+
34441  & 2d0*be2*(be2+ep1*ep2)*(ep1+ep2)**2*cth-
34442  & 1d0/16d0*sh/sqmw*(ep1**2-ep2**2)**2*(be2+ep1*ep2)**2)
34443  aswim=0d0
34444  auwre=xw1/sqmz*sh/(uh-sqmw)*(-be2*(ep2+ep1*cth)*
34445  & (ep1+ep2*cth)*(be2+ep1*ep2)+be2*(ep2+ep1*cth)*
34446  & (be2+ep1*ep2*cth)*(2d0*ep2-ep2*cth+ep1)-
34447  & be2*(ep2+ep1*cth)**2*(be2-ep2**2*cth)-1d0/8d0*
34448  & (be2+ep1*ep2*cth)**2*((ep1+ep2)**2+2d0*be2*(1d0-cth))+
34449  & 1d0/32d0*sh/sqmw*(be2+ep1*ep2*cth)**2*
34450  & (ep1**2-ep2**2)**2-be2*(ep1+ep2*cth)*(ep2+ep1*cth)*
34451  & (be2+ep1*ep2)+be2*(ep1+ep2*cth)*(be2+ep1*ep2*cth)*
34452  & (2d0*ep1-ep1*cth+ep2)-be2*(ep1+ep2*cth)**2*
34453  & (be2-ep1**2*cth)-1d0/8d0*(be2+ep1*ep2*cth)**2*
34454  & ((ep1+ep2)**2+2d0*be2*(1d0-cth))+1d0/32d0*sh/sqmw*
34455  & (be2+ep1*ep2*cth)**2*(ep1**2-ep2**2)**2)
34456  auwim=0d0
34457  a4re=xw1/sqmz*(ep1**2*ep2**2*(cth**2-1d0)-
34458  & 2d0*be2*(ep1**2+ep2**2+ep1*ep2)*cth-2d0*be2*ep1*ep2)
34459  a4im=0d0
34460  faczw=comfac*1d0/(4096d0*paru(1)**2*4d0*xw1)*(aem/xw)**4*
34461  & (sh/sqmw)**2*sqrt(sqmz/sqmw)*sh2
34462  IF(mstp(46).LE.0) faczw=0d0
34463  IF(mstp(46).EQ.1) faczw=faczw*((athre+aswre+auwre+a4re)**2+
34464  & (athim+aswim+auwim+a4im)**2)
34465  IF(mstp(46).EQ.2) faczw=faczw*((aswre+auwre+a4re)**2+
34466  & (aswim+auwim+a4im)**2)
34467 
34468  ELSE
34469 C...Strongly interacting Z_L/W_L model of Dobado, Herrero, Terron
34470  faczw=comfac*aem**2/(64d0*paru(1)**2*xw**2*xw1)*16d0*
34471  & abs(a20u+3d0*a11u*dble(cth))**2
34472  ENDIF
34473  faczw=faczw*wids(23,2)
34474 
34475  DO 270 i=mmin1,mmax1
34476  IF(i.EQ.0.OR.kfac(1,i).EQ.0) goto 270
34477  ei=kchg(iabs(i),1)/3d0
34478  ai=sign(1d0,ei)
34479  vi=ai-4d0*ei*xwv
34480  avi=ai**2+vi**2
34481  kchwi=isign(1,kchg(iabs(i),1)*isign(1,i))
34482  DO 260 j=mmin2,mmax2
34483  IF(j.EQ.0.OR.kfac(2,j).EQ.0) goto 260
34484  ej=kchg(iabs(j),1)/3d0
34485  aj=sign(1d0,ej)
34486  vj=ai-4d0*ej*xwv
34487  avj=aj**2+vj**2
34488  kchwj=isign(1,kchg(iabs(j),1)*isign(1,j))
34489  nchn=nchn+1
34490  isig(nchn,1)=i
34491  isig(nchn,2)=j
34492  isig(nchn,3)=1
34493  sigh(nchn)=faczw*avi*vint(180+j)*wids(24,(5-kchwj)/2)
34494  nchn=nchn+1
34495  isig(nchn,1)=i
34496  isig(nchn,2)=j
34497  isig(nchn,3)=2
34498  sigh(nchn)=faczw*vint(180+i)*wids(24,(5-kchwi)/2)*avj
34499  260 CONTINUE
34500  270 CONTINUE
34501  280 CONTINUE
34502 
34503  ELSEIF(isub.EQ.75) THEN
34504 C...W+ + W- -> gamma + gamma
34505 
34506  ELSEIF(isub.EQ.76) THEN
34507 C...W+ + W- -> Z0 + Z0
34508  IF(sh.LE.4.01d0*sqmz) goto 310
34509 
34510  IF(mstp(46).LE.2) THEN
34511 C...Exact scattering ME:s for on-mass-shell gauge bosons
34512  be2=sqrt((1d0-4d0*sqmw/sh)*(1d0-4d0*sqmz/sh))
34513  cth2=cth**2
34514  th=-0.5d0*sh*(1d0-2d0*(sqmw+sqmz)/sh-be2*cth)
34515  uh=-0.5d0*sh*(1d0-2d0*(sqmw+sqmz)/sh+be2*cth)
34516  IF(max(th,uh).GT.-1d0) goto 310
34517  shang=4d0*sqrt(sqmw/(sqmz*xw1))*(1d0-2d0*sqmw/sh)*
34518  & (1d0-2d0*sqmz/sh)
34519  ashre=(sh-sqmh)/((sh-sqmh)**2+gmmh**2)*shang
34520  ashim=-gmmh/((sh-sqmh)**2+gmmh**2)*shang
34521  atwre=xw1/sqmz*sh/(th-sqmw)*((cth-be2)**2*(3d0/2d0+be2/2d0*
34522  & cth-(sqmw+sqmz)/sh+(sqmw-sqmz)**2/(sh*sqmw))+4d0*
34523  & ((sqmw+sqmz)/sh*(1d0-3d0*cth2)+8d0*sqmw*sqmz/sh2*
34524  & (2d0*cth2-1d0)+4d0*(sqmw**2+sqmz**2)/sh2*cth2+
34525  & 2d0*(sqmw+sqmz)/sh*be2*cth))
34526  atwim=0d0
34527  auwre=xw1/sqmz*sh/(uh-sqmw)*((cth+be2)**2*(3d0/2d0-be2/2d0*
34528  & cth-(sqmw+sqmz)/sh+(sqmw-sqmz)**2/(sh*sqmw))+4d0*
34529  & ((sqmw+sqmz)/sh*(1d0-3d0*cth2)+8d0*sqmw*sqmz/sh2*
34530  & (2d0*cth2-1d0)+4d0*(sqmw**2+sqmz**2)/sh2*cth2-
34531  & 2d0*(sqmw+sqmz)/sh*be2*cth))
34532  auwim=0d0
34533  a4re=2d0*xw1/sqmz*(3d0-cth2-4d0*(sqmw+sqmz)/sh)
34534  a4im=0d0
34535  faczz=comfac*1d0/(4096d0*paru(1)**2)*(aem/xw)**4*
34536  & (sh/sqmw)**2*sh2
34537  IF(mstp(46).LE.0) faczz=faczz*(ashre**2+ashim**2)
34538  IF(mstp(46).EQ.1) faczz=faczz*((ashre+atwre+auwre+a4re)**2+
34539  & (ashim+atwim+auwim+a4im)**2)
34540  IF(mstp(46).EQ.2) faczz=faczz*((atwre+auwre+a4re)**2+
34541  & (atwim+auwim+a4im)**2)
34542 
34543  ELSE
34544 C...Strongly interacting Z_L/W_L model of Dobado, Herrero, Terron
34545  faczz=comfac*(aem/(4d0*paru(1)*xw))**2*(64d0/9d0)*
34546  & abs(a00u-a20u)**2
34547  ENDIF
34548  faczz=faczz*wids(23,1)
34549 
34550  DO 300 i=mmin1,mmax1
34551  IF(i.EQ.0.OR.kfac(1,i).EQ.0) goto 300
34552  ei=sign(1d0,dble(i))*kchg(iabs(i),1)
34553  DO 290 j=mmin2,mmax2
34554  IF(j.EQ.0.OR.kfac(2,j).EQ.0) goto 290
34555  ej=sign(1d0,dble(j))*kchg(iabs(j),1)
34556  IF(ei*ej.GT.0d0) goto 290
34557  nchn=nchn+1
34558  isig(nchn,1)=i
34559  isig(nchn,2)=j
34560  isig(nchn,3)=1
34561  sigh(nchn)=0.5d0*faczz*vint(180+i)*vint(180+j)
34562  290 CONTINUE
34563  300 CONTINUE
34564  310 CONTINUE
34565 
34566  ELSEIF(isub.EQ.77) THEN
34567 C...W+/- + W+/- -> W+/- + W+/-
34568  IF(sh.LE.4.01d0*sqmw) goto 340
34569 
34570  IF(mstp(46).LE.2) THEN
34571 C...Exact scattering ME:s for on-mass-shell gauge bosons
34572  be2=1d0-4d0*sqmw/sh
34573  be4=be2**2
34574  cth2=cth**2
34575  cth3=cth**3
34576  th=-0.5d0*sh*be2*(1d0-cth)
34577  uh=-0.5d0*sh*be2*(1d0+cth)
34578  IF(max(th,uh).GT.-1d0) goto 340
34579  shang=(1d0+be2)**2
34580  ashre=(sh-sqmh)/((sh-sqmh)**2+gmmh**2)*shang
34581  ashim=-gmmh/((sh-sqmh)**2+gmmh**2)*shang
34582  thang=(be2-cth)**2
34583  athre=(th-sqmh)/((th-sqmh)**2+gmmh**2)*thang
34584  athim=-gmmh/((th-sqmh)**2+gmmh**2)*thang
34585  uhang=(be2+cth)**2
34586  auhre=(uh-sqmh)/((uh-sqmh)**2+gmmh**2)*uhang
34587  auhim=-gmmh/((uh-sqmh)**2+gmmh**2)*uhang
34588  sgzang=1d0/sqmw*be2*(3d0-be2)**2*cth
34589  asgre=xw*sgzang
34590  asgim=0d0
34591  aszre=xw1*sh/(sh-sqmz)*sgzang
34592  aszim=0d0
34593  tgzang=1d0/sqmw*(be2*(4d0-2d0*be2+be4)+be2*(4d0-10d0*be2+
34594  & be4)*cth+(2d0-11d0*be2+10d0*be4)*cth2+be2*cth3)
34595  atgre=0.5d0*xw*sh/th*tgzang
34596  atgim=0d0
34597  atzre=0.5d0*xw1*sh/(th-sqmz)*tgzang
34598  atzim=0d0
34599  ugzang=1d0/sqmw*(be2*(4d0-2d0*be2+be4)-be2*(4d0-10d0*be2+
34600  & be4)*cth+(2d0-11d0*be2+10d0*be4)*cth2-be2*cth3)
34601  augre=0.5d0*xw*sh/uh*ugzang
34602  augim=0d0
34603  auzre=0.5d0*xw1*sh/(uh-sqmz)*ugzang
34604  auzim=0d0
34605  a4are=1d0/sqmw*(1d0+2d0*be2-6d0*be2*cth-cth2)
34606  a4aim=0d0
34607  a4sre=2d0/sqmw*(1d0+2d0*be2-cth2)
34608  a4sim=0d0
34609  fww=comfac*1d0/(4096d0*paru(1)**2)*(aem/xw)**4*
34610  & (sh/sqmw)**2*sh2
34611  IF(mstp(46).LE.0) THEN
34612  awware=ashre
34613  awwaim=ashim
34614  awwsre=0d0
34615  awwsim=0d0
34616  ELSEIF(mstp(46).EQ.1) THEN
34617  awware=ashre+athre+asgre+aszre+atgre+atzre+a4are
34618  awwaim=ashim+athim+asgim+aszim+atgim+atzim+a4aim
34619  awwsre=-athre-auhre+atgre+atzre+augre+auzre+a4sre
34620  awwsim=-athim-auhim+atgim+atzim+augim+auzim+a4sim
34621  ELSE
34622  awware=asgre+aszre+atgre+atzre+a4are
34623  awwaim=asgim+aszim+atgim+atzim+a4aim
34624  awwsre=atgre+atzre+augre+auzre+a4sre
34625  awwsim=atgim+atzim+augim+auzim+a4sim
34626  ENDIF
34627  awwa2=awware**2+awwaim**2
34628  awws2=awwsre**2+awwsim**2
34629 
34630  ELSE
34631 C...Strongly interacting Z_L/W_L model of Dobado, Herrero, Terron
34632  fwwa=comfac*(aem/(4d0*paru(1)*xw))**2*(64d0/9d0)*
34633  & abs(a00u+0.5d0*a20u+4.5d0*a11u*dble(cth))**2
34634  fwws=comfac*(aem/(4d0*paru(1)*xw))**2*64d0*abs(a20u)**2
34635  ENDIF
34636 
34637  DO 330 i=mmin1,mmax1
34638  IF(i.EQ.0.OR.kfac(1,i).EQ.0) goto 330
34639  ei=sign(1d0,dble(i))*kchg(iabs(i),1)
34640  DO 320 j=mmin2,mmax2
34641  IF(j.EQ.0.OR.kfac(2,j).EQ.0) goto 320
34642  ej=sign(1d0,dble(j))*kchg(iabs(j),1)
34643  IF(ei*ej.LT.0d0) THEN
34644 C...W+W-
34645  IF(mstp(45).EQ.1) goto 320
34646  IF(mstp(46).LE.2) facww=fww*awwa2*wids(24,1)
34647  IF(mstp(46).GE.3) facww=fwwa*wids(24,1)
34648  ELSE
34649 C...W+W+/W-W-
34650  IF(mstp(45).EQ.2) goto 320
34651  IF(mstp(46).LE.2) facww=fww*awws2
34652  IF(mstp(46).GE.3) facww=fwws
34653  IF(ei.GT.0d0) facww=facww*wids(24,4)
34654  IF(ei.LT.0d0) facww=facww*wids(24,5)
34655  ENDIF
34656  nchn=nchn+1
34657  isig(nchn,1)=i
34658  isig(nchn,2)=j
34659  isig(nchn,3)=1
34660  sigh(nchn)=facww*vint(180+i)*vint(180+j)
34661  IF(ei*ej.GT.0d0) sigh(nchn)=0.5d0*sigh(nchn)
34662  320 CONTINUE
34663  330 CONTINUE
34664  340 CONTINUE
34665  ENDIF
34666 
34667  ELSEIF(isub.LE.120) THEN
34668  IF(isub.EQ.102) THEN
34669 C...g + g -> h0 (or H0, or A0)
34670  CALL pywidt(kfhigg,sh,wdtp,wdte)
34671  hs=shr*wdtp(0)
34672  hf=shr*(wdte(0,1)+wdte(0,2)+wdte(0,4))
34673  facbw=4d0*comfac/((sh-sqmh)**2+hs**2)
34674  IF(abs(shr-pmas(kfhigg,1)).GT.parp(48)*pmas(kfhigg,2))
34675  & facbw=0d0
34676 C...PS: Only use fixed-width when using SLHA decay table for this Higgs
34677  IF (imss(22).GE.1.AND.mwid(kfhigg).EQ.2) THEN
34678  wdtp13=0d0
34679  DO 345 idc=mdcy(kfhigg,2),mdcy(kfhigg,2)+mdcy(kfhigg,3)-1
34680  IF(kfdp(idc,1).EQ.21.AND.kfdp(idc,2).EQ.21.AND.
34681  & kfdp(idc,3).EQ.0) wdtp13=pmas(kfhigg,2)*brat(idc)
34682  345 CONTINUE
34683  IF(wdtp13.EQ.0d0) CALL pyerrm(26,
34684  & '(PYSGHG:) did not find Higgs -> g g channel')
34685  hi=shr*wdtp13/32d0
34686  ELSE
34687  hi=shr*wdtp(13)/32d0
34688  ENDIF
34689  IF(kfac(1,21)*kfac(2,21).EQ.0) goto 350
34690  nchn=nchn+1
34691  isig(nchn,1)=21
34692  isig(nchn,2)=21
34693  isig(nchn,3)=1
34694  sigh(nchn)=hi*facbw*hf
34695  350 CONTINUE
34696 
34697  ELSEIF(isub.EQ.103) THEN
34698 C...gamma + gamma -> h0 (or H0, or A0)
34699  CALL pywidt(kfhigg,sh,wdtp,wdte)
34700  hs=shr*wdtp(0)
34701  hf=shr*(wdte(0,1)+wdte(0,2)+wdte(0,4))
34702  facbw=4d0*comfac/((sh-sqmh)**2+hs**2)
34703  IF(abs(shr-pmas(kfhigg,1)).GT.parp(48)*pmas(kfhigg,2))
34704  & facbw=0d0
34705 C...PS: Only use fixed-width when using SLHA decay table for this Higgs
34706  IF (imss(22).GE.1.AND.mwid(kfhigg).EQ.2) THEN
34707  wdtp14=0d0
34708  DO 355 idc=mdcy(kfhigg,2),mdcy(kfhigg,2)+mdcy(kfhigg,3)-1
34709  IF(kfdp(idc,1).EQ.22.AND.kfdp(idc,2).EQ.22.AND.
34710  & kfdp(idc,3).EQ.0) wdtp14=pmas(kfhigg,2)*brat(idc)
34711  355 CONTINUE
34712  IF(wdtp14.EQ.0d0) CALL pyerrm(26,
34713  & '(PYSGHG:) did not find Higgs -> gamma gamma channel')
34714  hi=shr*wdtp14*2d0
34715  ELSE
34716  hi=shr*wdtp(14)*2d0
34717  ENDIF
34718  IF(kfac(1,22)*kfac(2,22).EQ.0) goto 360
34719  nchn=nchn+1
34720  isig(nchn,1)=22
34721  isig(nchn,2)=22
34722  isig(nchn,3)=1
34723  sigh(nchn)=hi*facbw*hf
34724  360 CONTINUE
34725 
34726  ELSEIF(isub.EQ.110) THEN
34727 C...f + fbar -> gamma + h0
34728  thuh=max(th*uh,sh*ckin(3)**2)
34729  fachg=comfac*(3d0*aem**4)/(2d0*paru(1)**2*xw*sqmw)*sh*thuh
34730  fachg=fachg*wids(kfhigg,2)
34731 C...Calculate loop contributions for intermediate gamma* and Z0
34732  cigtot=dcmplx(0d0,0d0)
34733  ciztot=dcmplx(0d0,0d0)
34734  jmax=3*mstp(1)+1
34735  DO 370 j=1,jmax
34736  IF(j.LE.2*mstp(1)) THEN
34737  fnc=1d0
34738  ej=kchg(j,1)/3d0
34739  aj=sign(1d0,ej+0.1d0)
34740  vj=aj-4d0*ej*xwv
34741  balp=sqm4/(2d0*pmas(j,1))**2
34742  bbet=sh/(2d0*pmas(j,1))**2
34743  ELSEIF(j.LE.3*mstp(1)) THEN
34744  fnc=3d0
34745  jl=2*(j-2*mstp(1))-1
34746  ej=kchg(10+jl,1)/3d0
34747  aj=sign(1d0,ej+0.1d0)
34748  vj=aj-4d0*ej*xwv
34749  balp=sqm4/(2d0*pmas(10+jl,1))**2
34750  bbet=sh/(2d0*pmas(10+jl,1))**2
34751  ELSE
34752  balp=sqm4/(2d0*pmas(24,1))**2
34753  bbet=sh/(2d0*pmas(24,1))**2
34754  ENDIF
34755  babi=1d0/(balp-bbet)
34756  IF(balp.LT.1d0) THEN
34757  f0alp=dcmplx(dble(asin(sqrt(balp))),0d0)
34758  f1alp=f0alp**2
34759  ELSE
34760  f0alp=dcmplx(dble(log(sqrt(balp)+sqrt(balp-1d0))),
34761  & -dble(0.5d0*paru(1)))
34762  f1alp=-f0alp**2
34763  ENDIF
34764  f2alp=dble(sqrt(abs(balp-1d0)/balp))*f0alp
34765  IF(bbet.LT.1d0) THEN
34766  f0bet=dcmplx(dble(asin(sqrt(bbet))),0d0)
34767  f1bet=f0bet**2
34768  ELSE
34769  f0bet=dcmplx(dble(log(sqrt(bbet)+sqrt(bbet-1d0))),
34770  & -dble(0.5d0*paru(1)))
34771  f1bet=-f0bet**2
34772  ENDIF
34773  f2bet=dble(sqrt(abs(bbet-1d0)/bbet))*f0bet
34774  IF(j.LE.3*mstp(1)) THEN
34775  fif=dble(0.5d0*babi)+dble(babi**2)*(dble(0.5d0*(1d0-balp+
34776  & bbet))*(f1bet-f1alp)+dble(bbet)*(f2bet-f2alp))
34777  cigtot=cigtot+dble(fnc*ej**2)*fif
34778  ciztot=ciztot+dble(fnc*ej*vj)*fif
34779  ELSE
34780  txw=xw/xw1
34781  cigtot=cigtot-0.5*(dble(babi*(1.5d0+balp))+dble(babi**2)*
34782  & (dble(1.5d0-3d0*balp+4d0*bbet)*(f1bet-f1alp)+
34783  & dble(bbet*(2d0*balp+3d0))*(f2bet-f2alp)))
34784  ciztot=ciztot-dble(0.5d0*babi*xw1)*(dble(5d0-txw+2d0*balp*
34785  & (1d0-txw))*(1d0+dble(2d0*babi*bbet)*(f2bet-f2alp))+
34786  & dble(babi*(4d0*bbet*(3d0-txw)-(2d0*balp-1d0)*(5d0-txw)))*
34787  & (f1bet-f1alp))
34788  ENDIF
34789  370 CONTINUE
34790  cigtot=cigtot/dble(sh)
34791  ciztot=ciztot*dble(xwc)/dcmplx(dble(sh-sqmz),dble(gmmz))
34792 C...Loop over initial flavours
34793  DO 380 i=mmina,mmaxa
34794  IF(i.EQ.0.OR.kfac(1,i)*kfac(2,-i).EQ.0) goto 380
34795  ei=kchg(iabs(i),1)/3d0
34796  ai=sign(1d0,ei)
34797  vi=ai-4d0*ei*xwv
34798  fcoi=1d0
34799  IF(iabs(i).LE.10) fcoi=faca/3d0
34800  nchn=nchn+1
34801  isig(nchn,1)=i
34802  isig(nchn,2)=-i
34803  isig(nchn,3)=1
34804  sigh(nchn)=fachg*fcoi*(abs(dble(ei)*cigtot+dble(vi)*
34805  & ciztot)**2+ai**2*abs(ciztot)**2)
34806  380 CONTINUE
34807 
34808  ELSEIF(isub.EQ.111) THEN
34809 C...f + fbar -> g + h0 (q + qbar -> g + h0 only)
34810  IF(mstp(38).NE.0) THEN
34811 C...Simple case: only do gg <-> h exactly.
34812  CALL pywidt(kfhigg,sqm4,wdtp,wdte)
34813 C...PS: Only use fixed-width when using SLHA decay table for this Higgs
34814  IF (imss(22).GE.1.AND.mwid(kfhigg).EQ.2) THEN
34815  wdtp13=0d0
34816  DO 385 idc=mdcy(kfhigg,2),mdcy(kfhigg,2)+mdcy(kfhigg,3)-1
34817  IF(kfdp(idc,1).EQ.21.AND.kfdp(idc,2).EQ.21.AND.
34818  & kfdp(idc,3).EQ.0) wdtp13=pmas(kfhigg,2)*brat(idc)
34819  385 CONTINUE
34820  IF(wdtp13.EQ.0d0) CALL pyerrm(26,
34821  & '(PYSGHG:) did not find Higgs -> g g channel')
34822  facgh=comfac*faca*(2d0/9d0)*as*(wdtp13/sqrt(sqm4))*
34823  & (th**2+uh**2)/(sh*sqm4)
34824  ELSE
34825  facgh=comfac*faca*(2d0/9d0)*as*(wdtp(13)/sqrt(sqm4))*
34826  & (th**2+uh**2)/(sh*sqm4)
34827  ENDIF
34828 C...Propagators: as simulated in PYOFSH and as desired
34829  hbw4=gmmh/((sqm4-sqmh)**2+gmmh**2)
34830  gmmhc=sqrt(sqm4)*wdtp(0)
34831  hbw4c=sqrt(sqm4)*(wdte(0,1)+wdte(0,2)+wdte(0,4))/
34832  & ((sqm4-sqmh)**2+gmmhc**2)
34833  facgh=facgh*hbw4c/hbw4
34834  ELSE
34835 C...Messy case: do full loop integrals
34836  a5stur=0d0
34837  a5stui=0d0
34838  DO 390 i=1,2*mstp(1)
34839  sqmq=pmas(i,1)**2
34840  epss=4d0*sqmq/sh
34841  epsh=4d0*sqmq/sqmh
34842  CALL pywaux(1,epss,w1sr,w1si)
34843  CALL pywaux(1,epsh,w1hr,w1hi)
34844  CALL pywaux(2,epss,w2sr,w2si)
34845  CALL pywaux(2,epsh,w2hr,w2hi)
34846  a5stur=a5stur+epsh*(1d0+sh/(th+uh)*(w1sr-w1hr)+
34847  & (0.25d0-sqmq/(th+uh))*(w2sr-w2hr))
34848  a5stui=a5stui+epsh*(sh/(th+uh)*(w1si-w1hi)+
34849  & (0.25d0-sqmq/(th+uh))*(w2si-w2hi))
34850  390 CONTINUE
34851  facgh=comfac*faca/(144d0*paru(1)**2)*aem/xw*as**3*sqmh/sqmw*
34852  & sqmh/sh*(uh**2+th**2)/(uh+th)**2*(a5stur**2+a5stui**2)
34853  facgh=facgh*wids(25,2)
34854  ENDIF
34855  DO 400 i=mmina,mmaxa
34856  IF(i.EQ.0.OR.iabs(i).GT.mstp(58).OR.
34857  & kfac(1,i)*kfac(2,-i).EQ.0) goto 400
34858  nchn=nchn+1
34859  isig(nchn,1)=i
34860  isig(nchn,2)=-i
34861  isig(nchn,3)=1
34862  sigh(nchn)=facgh
34863  400 CONTINUE
34864 
34865  ELSEIF(isub.EQ.112) THEN
34866 C...f + g -> f + h0 (q + g -> q + h0 only)
34867  IF(mstp(38).NE.0) THEN
34868 C...Simple case: only do gg <-> h exactly.
34869  CALL pywidt(kfhigg,sqm4,wdtp,wdte)
34870 C...PS: Only use fixed-width when using SLHA decay table for this Higgs
34871  IF (imss(22).GE.1.AND.mwid(kfhigg).EQ.2) THEN
34872  wdtp13=0d0
34873  DO 405 idc=mdcy(kfhigg,2),mdcy(kfhigg,2)+mdcy(kfhigg,3)-1
34874  IF(kfdp(idc,1).EQ.21.AND.kfdp(idc,2).EQ.21.AND.
34875  & kfdp(idc,3).EQ.0) wdtp13=pmas(kfhigg,2)*brat(idc)
34876  405 CONTINUE
34877  IF(wdtp13.EQ.0d0) CALL pyerrm(26,
34878  & '(PYSGHG:) did not find Higgs -> g g channel')
34879  facqh=comfac*faca*(1d0/12d0)*as*(wdtp13/sqrt(sqm4))*
34880  & (sh**2+uh**2)/(-th*sqm4)
34881  ELSE
34882  facqh=comfac*faca*(1d0/12d0)*as*(wdtp(13)/sqrt(sqm4))*
34883  & (sh**2+uh**2)/(-th*sqm4)
34884  ENDIF
34885 C...Propagators: as simulated in PYOFSH and as desired
34886  hbw4=gmmh/((sqm4-sqmh)**2+gmmh**2)
34887  gmmhc=sqrt(sqm4)*wdtp(0)
34888  hbw4c=sqrt(sqm4)*(wdte(0,1)+wdte(0,2)+wdte(0,4))/
34889  & ((sqm4-sqmh)**2+gmmhc**2)
34890  facqh=facqh*hbw4c/hbw4
34891  ELSE
34892 C...Messy case: do full loop integrals
34893  a5tsur=0d0
34894  a5tsui=0d0
34895  DO 410 i=1,2*mstp(1)
34896  sqmq=pmas(i,1)**2
34897  epst=4d0*sqmq/th
34898  epsh=4d0*sqmq/sqmh
34899  CALL pywaux(1,epst,w1tr,w1ti)
34900  CALL pywaux(1,epsh,w1hr,w1hi)
34901  CALL pywaux(2,epst,w2tr,w2ti)
34902  CALL pywaux(2,epsh,w2hr,w2hi)
34903  a5tsur=a5tsur+epsh*(1d0+th/(sh+uh)*(w1tr-w1hr)+
34904  & (0.25d0-sqmq/(sh+uh))*(w2tr-w2hr))
34905  a5tsui=a5tsui+epsh*(th/(sh+uh)*(w1ti-w1hi)+
34906  & (0.25d0-sqmq/(sh+uh))*(w2ti-w2hi))
34907  410 CONTINUE
34908  facqh=comfac*faca/(384d0*paru(1)**2)*aem/xw*as**3*sqmh/sqmw*
34909  & sqmh/(-th)*(uh**2+sh**2)/(uh+sh)**2*(a5tsur**2+a5tsui**2)
34910  facqh=facqh*wids(25,2)
34911  ENDIF
34912  DO 430 i=mmina,mmaxa
34913  IF(i.EQ.0.OR.iabs(i).GT.mstp(58)) goto 430
34914  DO 420 isde=1,2
34915  IF(isde.EQ.1.AND.kfac(1,i)*kfac(2,21).EQ.0) goto 420
34916  IF(isde.EQ.2.AND.kfac(1,21)*kfac(2,i).EQ.0) goto 420
34917  nchn=nchn+1
34918  isig(nchn,isde)=i
34919  isig(nchn,3-isde)=21
34920  isig(nchn,3)=1
34921  sigh(nchn)=facqh
34922  420 CONTINUE
34923  430 CONTINUE
34924 
34925  ELSEIF(isub.EQ.113) THEN
34926 C...g + g -> g + h0
34927  IF(mstp(38).NE.0) THEN
34928 C...Simple case: only do gg <-> h exactly.
34929  CALL pywidt(kfhigg,sqm4,wdtp,wdte)
34930 C...PS: Only use fixed-width when using SLHA decay table for this Higgs
34931  IF (imss(22).GE.1.AND.mwid(kfhigg).EQ.2) THEN
34932  wdtp13=0d0
34933  DO 435 idc=mdcy(kfhigg,2),mdcy(kfhigg,2)+mdcy(kfhigg,3)-1
34934  IF(kfdp(idc,1).EQ.21.AND.kfdp(idc,2).EQ.21.AND.
34935  & kfdp(idc,3).EQ.0) wdtp13=pmas(kfhigg,2)*brat(idc)
34936  435 CONTINUE
34937  IF(wdtp13.EQ.0d0) CALL pyerrm(26,
34938  & '(PYSGHG:) did not find Higgs -> g g channel')
34939  facgh=comfac*faca*(3d0/16d0)*as*(wdtp13/sqrt(sqm4))*
34940  & (sh**4+th**4+uh**4+sqm4**4)/(sh*th*uh*sqm4)
34941  ELSE
34942  facgh=comfac*faca*(3d0/16d0)*as*(wdtp(13)/sqrt(sqm4))*
34943  & (sh**4+th**4+uh**4+sqm4**4)/(sh*th*uh*sqm4)
34944  ENDIF
34945 C...Propagators: as simulated in PYOFSH and as desired
34946  hbw4=gmmh/((sqm4-sqmh)**2+gmmh**2)
34947  gmmhc=sqrt(sqm4)*wdtp(0)
34948  hbw4c=sqrt(sqm4)*(wdte(0,1)+wdte(0,2)+wdte(0,4))/
34949  & ((sqm4-sqmh)**2+gmmhc**2)
34950  facgh=facgh*hbw4c/hbw4
34951  ELSE
34952 C...Messy case: do full loop integrals
34953  a2stur=0d0
34954  a2stui=0d0
34955  a2ustr=0d0
34956  a2usti=0d0
34957  a2tusr=0d0
34958  a2tusi=0d0
34959  a4stur=0d0
34960  a4stui=0d0
34961  DO 440 i=1,2*mstp(1)
34962  sqmq=pmas(i,1)**2
34963  epss=4d0*sqmq/sh
34964  epst=4d0*sqmq/th
34965  epsu=4d0*sqmq/uh
34966  epsh=4d0*sqmq/sqmh
34967  IF(epsh.LT.1d-6) goto 440
34968  CALL pywaux(1,epss,w1sr,w1si)
34969  CALL pywaux(1,epst,w1tr,w1ti)
34970  CALL pywaux(1,epsu,w1ur,w1ui)
34971  CALL pywaux(1,epsh,w1hr,w1hi)
34972  CALL pywaux(2,epss,w2sr,w2si)
34973  CALL pywaux(2,epst,w2tr,w2ti)
34974  CALL pywaux(2,epsu,w2ur,w2ui)
34975  CALL pywaux(2,epsh,w2hr,w2hi)
34976  CALL pyi3au(epss,th/uh,y3stur,y3stui)
34977  CALL pyi3au(epss,uh/th,y3sutr,y3suti)
34978  CALL pyi3au(epst,sh/uh,y3tsur,y3tsui)
34979  CALL pyi3au(epst,uh/sh,y3tusr,y3tusi)
34980  CALL pyi3au(epsu,sh/th,y3ustr,y3usti)
34981  CALL pyi3au(epsu,th/sh,y3utsr,y3utsi)
34982  CALL pyi3au(epsh,sqmh/sh*th/uh,yhstur,yhstui)
34983  CALL pyi3au(epsh,sqmh/sh*uh/th,yhsutr,yhsuti)
34984  CALL pyi3au(epsh,sqmh/th*sh/uh,yhtsur,yhtsui)
34985  CALL pyi3au(epsh,sqmh/th*uh/sh,yhtusr,yhtusi)
34986  CALL pyi3au(epsh,sqmh/uh*sh/th,yhustr,yhusti)
34987  CALL pyi3au(epsh,sqmh/uh*th/sh,yhutsr,yhutsi)
34988  w3stur=yhstur-y3stur-y3utsr
34989  w3stui=yhstui-y3stui-y3utsi
34990  w3sutr=yhsutr-y3sutr-y3tusr
34991  w3suti=yhsuti-y3suti-y3tusi
34992  w3tsur=yhtsur-y3tsur-y3ustr
34993  w3tsui=yhtsui-y3tsui-y3usti
34994  w3tusr=yhtusr-y3tusr-y3sutr
34995  w3tusi=yhtusi-y3tusi-y3suti
34996  w3ustr=yhustr-y3ustr-y3tsur
34997  w3usti=yhusti-y3usti-y3tsui
34998  w3utsr=yhutsr-y3utsr-y3stur
34999  w3utsi=yhutsi-y3utsi-y3stui
35000  b2stur=sqmq/sqmh**2*(sh*(uh-sh)/(sh+uh)+2d0*th*uh*
35001  & (uh+2d0*sh)/(sh+uh)**2*(w1tr-w1hr)+(sqmq-sh/4d0)*
35002  & (0.5d0*w2sr+0.5d0*w2hr-w2tr+w3stur)+sh2*(2d0*sqmq/
35003  & (sh+uh)**2-0.5d0/(sh+uh))*(w2tr-w2hr)+0.5d0*th*uh/sh*
35004  & (w2hr-2d0*w2tr)+0.125d0*(sh-12d0*sqmq-4d0*th*uh/sh)*w3tsur)
35005  b2stui=sqmq/sqmh**2*(2d0*th*uh*(uh+2d0*sh)/(sh+uh)**2*
35006  & (w1ti-w1hi)+(sqmq-sh/4d0)*(0.5d0*w2si+0.5d0*w2hi-w2ti+
35007  & w3stui)+sh2*(2d0*sqmq/(sh+uh)**2-0.5d0/(sh+uh))*
35008  & (w2ti-w2hi)+0.5d0*th*uh/sh*(w2hi-2d0*w2ti)+0.125d0*
35009  & (sh-12d0*sqmq-4d0*th*uh/sh)*w3tsui)
35010  b2sutr=sqmq/sqmh**2*(sh*(th-sh)/(sh+th)+2d0*uh*th*
35011  & (th+2d0*sh)/(sh+th)**2*(w1ur-w1hr)+(sqmq-sh/4d0)*
35012  & (0.5d0*w2sr+0.5d0*w2hr-w2ur+w3sutr)+sh2*(2d0*sqmq/
35013  & (sh+th)**2-0.5d0/(sh+th))*(w2ur-w2hr)+0.5d0*uh*th/sh*
35014  & (w2hr-2d0*w2ur)+0.125d0*(sh-12d0*sqmq-4d0*uh*th/sh)*w3ustr)
35015  b2suti=sqmq/sqmh**2*(2d0*uh*th*(th+2d0*sh)/(sh+th)**2*
35016  & (w1ui-w1hi)+(sqmq-sh/4d0)*(0.5d0*w2si+0.5d0*w2hi-w2ui+
35017  & w3suti)+sh2*(2d0*sqmq/(sh+th)**2-0.5d0/(sh+th))*
35018  & (w2ui-w2hi)+0.5d0*uh*th/sh*(w2hi-2d0*w2ui)+0.125d0*
35019  & (sh-12d0*sqmq-4d0*uh*th/sh)*w3usti)
35020  b2tsur=sqmq/sqmh**2*(th*(uh-th)/(th+uh)+2d0*sh*uh*
35021  & (uh+2d0*th)/(th+uh)**2*(w1sr-w1hr)+(sqmq-th/4d0)*
35022  & (0.5d0*w2tr+0.5d0*w2hr-w2sr+w3tsur)+th2*(2d0*sqmq/
35023  & (th+uh)**2-0.5d0/(th+uh))*(w2sr-w2hr)+0.5d0*sh*uh/th*
35024  & (w2hr-2d0*w2sr)+0.125d0*(th-12d0*sqmq-4d0*sh*uh/th)*w3stur)
35025  b2tsui=sqmq/sqmh**2*(2d0*sh*uh*(uh+2d0*th)/(th+uh)**2*
35026  & (w1si-w1hi)+(sqmq-th/4d0)*(0.5d0*w2ti+0.5d0*w2hi-w2si+
35027  & w3tsui)+th2*(2d0*sqmq/(th+uh)**2-0.5d0/(th+uh))*
35028  & (w2si-w2hi)+0.5d0*sh*uh/th*(w2hi-2d0*w2si)+0.125d0*
35029  & (th-12d0*sqmq-4d0*sh*uh/th)*w3stui)
35030  b2tusr=sqmq/sqmh**2*(th*(sh-th)/(th+sh)+2d0*uh*sh*
35031  & (sh+2d0*th)/(th+sh)**2*(w1ur-w1hr)+(sqmq-th/4d0)*
35032  & (0.5d0*w2tr+0.5d0*w2hr-w2ur+w3tusr)+th2*(2d0*sqmq/
35033  & (th+sh)**2-0.5d0/(th+sh))*(w2ur-w2hr)+0.5d0*uh*sh/th*
35034  & (w2hr-2d0*w2ur)+0.125d0*(th-12d0*sqmq-4d0*uh*sh/th)*w3utsr)
35035  b2tusi=sqmq/sqmh**2*(2d0*uh*sh*(sh+2d0*th)/(th+sh)**2*
35036  & (w1ui-w1hi)+(sqmq-th/4d0)*(0.5d0*w2ti+0.5d0*w2hi-w2ui+
35037  & w3tusi)+th2*(2d0*sqmq/(th+sh)**2-0.5d0/(th+sh))*
35038  & (w2ui-w2hi)+0.5d0*uh*sh/th*(w2hi-2d0*w2ui)+0.125d0*
35039  & (th-12d0*sqmq-4d0*uh*sh/th)*w3utsi)
35040  b2ustr=sqmq/sqmh**2*(uh*(th-uh)/(uh+th)+2d0*sh*th*
35041  & (th+2d0*uh)/(uh+th)**2*(w1sr-w1hr)+(sqmq-uh/4d0)*
35042  & (0.5d0*w2ur+0.5d0*w2hr-w2sr+w3ustr)+uh2*(2d0*sqmq/
35043  & (uh+th)**2-0.5d0/(uh+th))*(w2sr-w2hr)+0.5d0*sh*th/uh*
35044  & (w2hr-2d0*w2sr)+0.125d0*(uh-12d0*sqmq-4d0*sh*th/uh)*w3sutr)
35045  b2usti=sqmq/sqmh**2*(2d0*sh*th*(th+2d0*uh)/(uh+th)**2*
35046  & (w1si-w1hi)+(sqmq-uh/4d0)*(0.5d0*w2ui+0.5d0*w2hi-w2si+
35047  & w3usti)+uh2*(2d0*sqmq/(uh+th)**2-0.5d0/(uh+th))*
35048  & (w2si-w2hi)+0.5d0*sh*th/uh*(w2hi-2d0*w2si)+0.125d0*
35049  & (uh-12d0*sqmq-4d0*sh*th/uh)*w3suti)
35050  b2utsr=sqmq/sqmh**2*(uh*(sh-uh)/(uh+sh)+2d0*th*sh*
35051  & (sh+2d0*uh)/(uh+sh)**2*(w1tr-w1hr)+(sqmq-uh/4d0)*
35052  & (0.5d0*w2ur+0.5d0*w2hr-w2tr+w3utsr)+uh2*(2d0*sqmq/
35053  & (uh+sh)**2-0.5d0/(uh+sh))*(w2tr-w2hr)+0.5d0*th*sh/uh*
35054  & (w2hr-2d0*w2tr)+0.125d0*(uh-12d0*sqmq-4d0*th*sh/uh)*w3tusr)
35055  b2utsi=sqmq/sqmh**2*(2d0*th*sh*(sh+2d0*uh)/(uh+sh)**2*
35056  & (w1ti-w1hi)+(sqmq-uh/4d0)*(0.5d0*w2ui+0.5d0*w2hi-w2ti+
35057  & w3utsi)+uh2*(2d0*sqmq/(uh+sh)**2-0.5d0/(uh+sh))*
35058  & (w2ti-w2hi)+0.5d0*th*sh/uh*(w2hi-2d0*w2ti)+0.125d0*
35059  & (uh-12d0*sqmq-4d0*th*sh/uh)*w3tusi)
35060  b4stur=0.25d0*epsh*(-2d0/3d0+0.25d0*(epsh-1d0)*
35061  & (w2sr-w2hr+w3stur))
35062  b4stui=0.25d0*epsh*0.25d0*(epsh-1d0)*(w2si-w2hi+w3stui)
35063  b4tusr=0.25d0*epsh*(-2d0/3d0+0.25d0*(epsh-1d0)*
35064  & (w2tr-w2hr+w3tusr))
35065  b4tusi=0.25d0*epsh*0.25d0*(epsh-1d0)*(w2ti-w2hi+w3tusi)
35066  b4ustr=0.25d0*epsh*(-2d0/3d0+0.25d0*(epsh-1d0)*
35067  & (w2ur-w2hr+w3ustr))
35068  b4usti=0.25d0*epsh*0.25d0*(epsh-1d0)*(w2ui-w2hi+w3usti)
35069  a2stur=a2stur+b2stur+b2sutr
35070  a2stui=a2stui+b2stui+b2suti
35071  a2ustr=a2ustr+b2ustr+b2utsr
35072  a2usti=a2usti+b2usti+b2utsi
35073  a2tusr=a2tusr+b2tusr+b2tsur
35074  a2tusi=a2tusi+b2tusi+b2tsui
35075  a4stur=a4stur+b4stur+b4ustr+b4tusr
35076  a4stui=a4stui+b4stui+b4usti+b4tusi
35077  440 CONTINUE
35078  facgh=comfac*faca*3d0/(128d0*paru(1)**2)*aem/xw*as**3*
35079  & sqmh/sqmw*sqmh**3/(sh*th*uh)*(a2stur**2+a2stui**2+a2ustr**2+
35080  & a2usti**2+a2tusr**2+a2tusi**2+a4stur**2+a4stui**2)
35081  facgh=facgh*wids(25,2)
35082  ENDIF
35083  IF(kfac(1,21)*kfac(2,21).EQ.0) goto 450
35084  nchn=nchn+1
35085  isig(nchn,1)=21
35086  isig(nchn,2)=21
35087  isig(nchn,3)=1
35088  sigh(nchn)=facgh
35089  450 CONTINUE
35090  ENDIF
35091 
35092  ELSEIF(isub.LE.170) THEN
35093  IF(isub.EQ.121) THEN
35094 C...g + g -> Q + Qbar + h0
35095  IF(kfac(1,21)*kfac(2,21).EQ.0) goto 460
35096  ia=kfpr(isubsv,2)
35097  pmf=pymrun(ia,sh)
35098  facqqh=comfac*(4d0*paru(1)*aem/xw)*(4d0*paru(1)*as)**2*
35099  & (0.5d0*pmf/pmas(24,1))**2
35100  wid2=1d0
35101  IF(ia.EQ.6.OR.ia.EQ.7.OR.ia.EQ.8) wid2=wids(ia,1)
35102  facqqh=facqqh*wid2
35103  IF(mstp(4).GE.1.OR.ihigg.GE.2) THEN
35104  ikfi=1
35105  IF(ia.LE.10.AND.mod(ia,2).EQ.0) ikfi=2
35106  IF(ia.GT.10) ikfi=3
35107  facqqh=facqqh*paru(150+10*ihigg+ikfi)**2
35108  IF(imss(1).NE.0.AND.ia.EQ.5) THEN
35109  facqqh=facqqh/(1d0+rmss(41))**2
35110  IF(ihigg.NE.3) THEN
35111  facqqh=facqqh*(1d0+rmss(41)*paru(152+10*ihigg)/
35112  & paru(151+10*ihigg))**2
35113  ENDIF
35114  ENDIF
35115  ENDIF
35116  CALL pyqqbh(wtqqbh)
35117  CALL pywidt(kfhigg,sh,wdtp,wdte)
35118  hs=shr*wdtp(0)
35119  hf=shr*(wdte(0,1)+wdte(0,2)+wdte(0,4))
35120  facbw=(1d0/paru(1))*vint(2)*hf/((sh-sqmh)**2+hs**2)
35121  IF(abs(shr-pmas(kfhigg,1)).GT.parp(48)*pmas(kfhigg,2))
35122  & facbw=0d0
35123  nchn=nchn+1
35124  isig(nchn,1)=21
35125  isig(nchn,2)=21
35126  isig(nchn,3)=1
35127  sigh(nchn)=facqqh*wtqqbh*facbw
35128  460 CONTINUE
35129 
35130  ELSEIF(isub.EQ.122) THEN
35131 C...q + qbar -> Q + Qbar + h0
35132  ia=kfpr(isubsv,2)
35133  pmf=pymrun(ia,sh)
35134  facqqh=comfac*(4d0*paru(1)*aem/xw)*(4d0*paru(1)*as)**2*
35135  & (0.5d0*pmf/pmas(24,1))**2
35136  wid2=1d0
35137  IF(ia.EQ.6.OR.ia.EQ.7.OR.ia.EQ.8) wid2=wids(ia,1)
35138  facqqh=facqqh*wid2
35139  IF(mstp(4).GE.1.OR.ihigg.GE.2) THEN
35140  ikfi=1
35141  IF(ia.LE.10.AND.mod(ia,2).EQ.0) ikfi=2
35142  IF(ia.GT.10) ikfi=3
35143  facqqh=facqqh*paru(150+10*ihigg+ikfi)**2
35144  IF(imss(1).NE.0.AND.ia.EQ.5) THEN
35145  facqqh=facqqh/(1d0+rmss(41))**2
35146  IF(ihigg.NE.3) THEN
35147  facqqh=facqqh*(1d0+rmss(41)*paru(152+10*ihigg)/
35148  & paru(151+10*ihigg))**2
35149  ENDIF
35150  ENDIF
35151  ENDIF
35152  CALL pyqqbh(wtqqbh)
35153  CALL pywidt(kfhigg,sh,wdtp,wdte)
35154  hs=shr*wdtp(0)
35155  hf=shr*(wdte(0,1)+wdte(0,2)+wdte(0,4))
35156  facbw=(1d0/paru(1))*vint(2)*hf/((sh-sqmh)**2+hs**2)
35157  IF(abs(shr-pmas(kfhigg,1)).GT.parp(48)*pmas(kfhigg,2))
35158  & facbw=0d0
35159  DO 470 i=mmina,mmaxa
35160  IF(i.EQ.0.OR.iabs(i).GT.mstp(58).OR.
35161  & kfac(1,i)*kfac(2,-i).EQ.0) goto 470
35162  nchn=nchn+1
35163  isig(nchn,1)=i
35164  isig(nchn,2)=-i
35165  isig(nchn,3)=1
35166  sigh(nchn)=facqqh*wtqqbh*facbw
35167  470 CONTINUE
35168 
35169  ELSEIF(isub.EQ.123) THEN
35170 C...f + f' -> f + f' + h0 (or H0, or A0) (Z0 + Z0 -> h0 as
35171 C...inner process)
35172  facnor=comfac*(4d0*paru(1)*aem/(xw*xw1))**3*sqmz/32d0
35173  IF(mstp(4).GE.1.OR.ihigg.GE.2) facnor=facnor*
35174  & paru(154+10*ihigg)**2
35175  facprp=1d0/((vint(215)-vint(204)**2)*
35176  & (vint(216)-vint(209)**2))**2
35177  faczz1=facnor*facprp*(0.5d0*taup*vint(2))*vint(219)
35178  faczz2=facnor*facprp*vint(217)*vint(218)
35179  CALL pywidt(kfhigg,sh,wdtp,wdte)
35180  hs=shr*wdtp(0)
35181  hf=shr*(wdte(0,1)+wdte(0,2)+wdte(0,4))
35182  facbw=(1d0/paru(1))*vint(2)*hf/((sh-sqmh)**2+hs**2)
35183  IF(abs(shr-pmas(kfhigg,1)).GT.parp(48)*pmas(kfhigg,2))
35184  & facbw=0d0
35185  DO 490 i=mmin1,mmax1
35186  IF(i.EQ.0.OR.kfac(1,i).EQ.0) goto 490
35187  ia=iabs(i)
35188  DO 480 j=mmin2,mmax2
35189  IF(j.EQ.0.OR.kfac(2,j).EQ.0) goto 480
35190  ja=iabs(j)
35191  ei=kchg(ia,1)*isign(1,i)/3d0
35192  ai=sign(1d0,kchg(ia,1)+0.5d0)*isign(1,i)
35193  vi=ai-4d0*ei*xwv
35194  ej=kchg(ja,1)*isign(1,j)/3d0
35195  aj=sign(1d0,kchg(ja,1)+0.5d0)*isign(1,j)
35196  vj=aj-4d0*ej*xwv
35197  faclr1=(vi**2+ai**2)*(vj**2+aj**2)+4d0*vi*ai*vj*aj
35198  faclr2=(vi**2+ai**2)*(vj**2+aj**2)-4d0*vi*ai*vj*aj
35199  nchn=nchn+1
35200  isig(nchn,1)=i
35201  isig(nchn,2)=j
35202  isig(nchn,3)=1
35203  sigh(nchn)=(faclr1*faczz1+faclr2*faczz2)*facbw
35204  480 CONTINUE
35205  490 CONTINUE
35206 
35207  ELSEIF(isub.EQ.124) THEN
35208 C...f + f' -> f" + f"' + h0 (or H0, or A0) (W+ + W- -> h0 as
35209 C...inner process)
35210  facnor=comfac*(4d0*paru(1)*aem/xw)**3*sqmw
35211  IF(mstp(4).GE.1.OR.ihigg.GE.2) facnor=facnor*
35212  & paru(155+10*ihigg)**2
35213  facprp=1d0/((vint(215)-vint(204)**2)*
35214  & (vint(216)-vint(209)**2))**2
35215  facww=facnor*facprp*(0.5d0*taup*vint(2))*vint(219)
35216  CALL pywidt(kfhigg,sh,wdtp,wdte)
35217  hs=shr*wdtp(0)
35218  hf=shr*(wdte(0,1)+wdte(0,2)+wdte(0,4))
35219  facbw=(1d0/paru(1))*vint(2)*hf/((sh-sqmh)**2+hs**2)
35220  IF(abs(shr-pmas(kfhigg,1)).GT.parp(48)*pmas(kfhigg,2))
35221  & facbw=0d0
35222  DO 510 i=mmin1,mmax1
35223  IF(i.EQ.0.OR.kfac(1,i).EQ.0) goto 510
35224  ei=sign(1d0,dble(i))*kchg(iabs(i),1)
35225  DO 500 j=mmin2,mmax2
35226  IF(j.EQ.0.OR.kfac(2,j).EQ.0) goto 500
35227  ej=sign(1d0,dble(j))*kchg(iabs(j),1)
35228  IF(ei*ej.GT.0d0) goto 500
35229  faclr=vint(180+i)*vint(180+j)
35230  nchn=nchn+1
35231  isig(nchn,1)=i
35232  isig(nchn,2)=j
35233  isig(nchn,3)=1
35234  sigh(nchn)=faclr*facww*facbw
35235  500 CONTINUE
35236  510 CONTINUE
35237 
35238  ELSEIF(isub.EQ.143) THEN
35239 C...f + fbar' -> H+/-
35240  sqmhc=pmas(37,1)**2
35241  CALL pywidt(37,sh,wdtp,wdte)
35242  hs=shr*wdtp(0)
35243  facbw=4d0*comfac/((sh-sqmhc)**2+hs**2)
35244  hp=aem/(8d0*xw)*sh/sqmw*sh
35245  DO 530 i=mmin1,mmax1
35246  IF(i.EQ.0.OR.kfac(1,i).EQ.0) goto 530
35247  ia=iabs(i)
35248  im=(mod(ia,10)+1)/2
35249  DO 520 j=mmin2,mmax2
35250  IF(j.EQ.0.OR.kfac(2,j).EQ.0) goto 520
35251  ja=iabs(j)
35252  jm=(mod(ja,10)+1)/2
35253  IF(i*j.GT.0.OR.ia.EQ.ja.OR.im.NE.jm) goto 520
35254  IF((ia.LE.10.AND.ja.GT.10).OR.(ia.GT.10.AND.ja.LE.10))
35255  & goto 520
35256  IF(mod(ia,2).EQ.0) THEN
35257  iu=ia
35258  il=ja
35259  ELSE
35260  iu=ja
35261  il=ia
35262  ENDIF
35263  rml=pymrun(il,sh)**2/sh
35264  rmu=pymrun(iu,sh)**2/sh
35265  hi=hp*(rml*paru(141)**2+rmu/paru(141)**2)
35266  IF(ia.LE.10) hi=hi*faca/3d0
35267  kchhc=(kchg(ia,1)*isign(1,i)+kchg(ja,1)*isign(1,j))/3
35268  hf=shr*(wdte(0,1)+wdte(0,(5-kchhc)/2)+wdte(0,4))
35269  nchn=nchn+1
35270  isig(nchn,1)=i
35271  isig(nchn,2)=j
35272  isig(nchn,3)=1
35273  sigh(nchn)=hi*facbw*hf
35274  520 CONTINUE
35275  530 CONTINUE
35276 
35277  ELSEIF(isub.EQ.161) THEN
35278 C...f + g -> f' + H+/- (b + g -> t + H+/- only)
35279 C...(choice of only b and t to avoid kinematics problems)
35280  fhcq=comfac*faca*as*aem/xw*1d0/24
35281 C...H propagator: as simulated in PYOFSH and as desired
35282  sqmhc=pmas(37,1)**2
35283  gmmhc=pmas(37,1)*pmas(37,2)
35284  hbw4=gmmhc/((sqm4-sqmhc)**2+gmmhc**2)
35285  CALL pywidt(37,sqm4,wdtp,wdte)
35286  gmmhcc=sqrt(sqm4)*wdtp(0)
35287  hbw4c=gmmhcc/((sqm4-sqmhc)**2+gmmhcc**2)
35288  fhcq=fhcq*hbw4c/hbw4
35289  q2rm=sh
35290  IF(mstp(32).EQ.12) q2rm=parp(194)
35291  DO 550 i=mmina,mmaxa
35292  ia=iabs(i)
35293  IF(ia.NE.5) goto 550
35294  sqml=pymrun(ia,q2rm)**2
35295  iua=ia+mod(ia,2)
35296  sqmq=pymrun(iua,q2rm)**2
35297  fachcq=fhcq*(sqml*paru(141)**2+sqmq/paru(141)**2)/sqmw*
35298  & (sh/(sqmq-uh)+2d0*sqmq*(sqmhc-uh)/(sqmq-uh)**2+(sqmq-uh)/sh-
35299  & 2d0*sqmq/(sqmq-uh)+2d0*(sqmhc-uh)/(sqmq-uh)*
35300  & (sqmhc-sqmq-sh)/sh)
35301  kchhc=isign(1,kchg(ia,1)*isign(1,i))
35302  DO 540 isde=1,2
35303  IF(isde.EQ.1.AND.kfac(1,i)*kfac(2,21).EQ.0) goto 540
35304  IF(isde.EQ.2.AND.kfac(1,21)*kfac(2,i).EQ.0) goto 540
35305  nchn=nchn+1
35306  isig(nchn,isde)=i
35307  isig(nchn,3-isde)=21
35308  isig(nchn,3)=1
35309  sigh(nchn)=fachcq*wids(37,(5-kchhc)/2)
35310  IF(iua.EQ.6) sigh(nchn)=sigh(nchn)*wids(6,(5+kchhc)/2)
35311  540 CONTINUE
35312  550 CONTINUE
35313  ENDIF
35314 
35315  ELSEIF(isub.LE.402) THEN
35316  IF(isub.EQ.401) THEN
35317 C... g + g -> t + bbar + H-
35318  IF(kfac(1,21)*kfac(2,21).EQ.0) goto 560
35319  ia=kfpr(isubsv,2)
35320  CALL pystbh(wttbh)
35321  CALL pywidt(kfhigg,sh,wdtp,wdte)
35322  hs=shr*wdtp(0)
35323  facbw=(1d0/paru(1))*vint(2)*hs/((sh-sqmh)**2+hs**2)
35324  IF(abs(shr-pmas(kfhigg,1)).GT.parp(48)*pmas(kfhigg,2))
35325  & facbw=0d0
35326  nchn=nchn+1
35327  isig(nchn,1)=21
35328  isig(nchn,2)=21
35329  isig(nchn,3)=1
35330  sigh(nchn)=2d0*comfac*wttbh*facbw
35331 c Since we don't know yet if H+ or H-, assume H+
35332 c when calculating suppression due to closed channels.
35333  sigh(nchn)=sigh(nchn)*wids(37,2)*wids(6,3)
35334  IF(abs(wids(37,2)-wids(37,3))
35335  & .GE.1d-6*(wids(37,2)+wids(37,3)).OR.
35336  & abs(wids(6,2)-wids(6,3))
35337  & .GE.1d-6*(wids(6,2)+wids(6,3))) THEN
35338  WRITE(*,*)'Error: Process 401 cannot handle different'
35339  WRITE(*,*)'decays for H+ and H- or t and tbar.'
35340  WRITE(*,*)'Execution stopped.'
35341  CALL pystop(108)
35342  END IF
35343  560 CONTINUE
35344 
35345  ELSEIF(isub.EQ.402) THEN
35346 C... q + qbar -> t + bbar + H-
35347  ia=kfpr(isubsv,2)
35348  CALL pystbh(wttbh)
35349  CALL pywidt(kfhigg,sh,wdtp,wdte)
35350  hs=shr*wdtp(0)
35351  facbw=(1d0/paru(1))*vint(2)*hs/((sh-sqmh)**2+hs**2)
35352  IF(abs(shr-pmas(kfhigg,1)).GT.parp(48)*pmas(kfhigg,2))
35353  & facbw=0d0
35354  DO 570 i=mmina,mmaxa
35355  IF(i.EQ.0.OR.iabs(i).GT.mstp(58).OR.
35356  & kfac(1,i)*kfac(2,-i).EQ.0) goto 570
35357  nchn=nchn+1
35358  isig(nchn,1)=i
35359  isig(nchn,2)=-i
35360  isig(nchn,3)=1
35361  sigh(nchn)=2d0*comfac*wttbh*facbw
35362 c Since we don't know yet if H+ or H-, assume H+
35363 c when calculating suppression due to closed channels.
35364  sigh(nchn)=sigh(nchn)*wids(37,2)*wids(6,3)
35365  IF(abs(wids(37,2)-wids(37,3))/(wids(37,2)+wids(37,3))
35366  & .GE.1d-6.OR.
35367  & abs(wids(6,2)-wids(6,3))/(wids(6,2)+wids(6,3))
35368  & .GE.1d-6) THEN
35369  WRITE(*,*)'Error: Process 402 cannot handle different'
35370  WRITE(*,*)'decays for H+ and H- or t and tbar.'
35371  WRITE(*,*)'Execution stopped.'
35372  CALL pystop(108)
35373  END IF
35374  570 CONTINUE
35375  ENDIF
35376  ENDIF
35377 
35378  RETURN
35379  END
35380 
35381 C*********************************************************************
35382 
35383 C...PYSGSU
35384 C...Subprocess cross sections for SUSY processes,
35385 C...including Higgs pair production.
35386 C...Auxiliary to PYSIGH.
35387 
35388  SUBROUTINE pysgsu(NCHN,SIGS)
35389 
35390 C...Double precision and integer declarations
35391  IMPLICIT DOUBLE PRECISION(a-h, o-z)
35392  IMPLICIT INTEGER(i-n)
35393  INTEGER pyk,pychge,pycomp
35394 C...Parameter statement to help give large particle numbers.
35395  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
35396  &kexcit=4000000,kdimen=5000000)
35397 C...Commonblocks
35398  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
35399  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
35400  common/pypars/mstp(200),parp(200),msti(200),pari(200)
35401  common/pyint1/mint(400),vint(400)
35402  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
35403  common/pyint3/xsfx(2,-40:40),isig(1000,3),sigh(1000)
35404  common/pyint4/mwid(500),wids(500,5)
35405  common/pymssm/imss(0:99),rmss(0:99)
35406  common/pyssmt/zmix(4,4),umix(2,2),vmix(2,2),smz(4),smw(2),
35407  &sfmix(16,4),zmixi(4,4),umixi(2,2),vmixi(2,2)
35408  common/pysgcm/isub,isubsv,mmin1,mmax1,mmin2,mmax2,mmina,mmaxa,
35409  &kfac(2,-40:40),comfac,fack,faca,sh,th,uh,sh2,th2,uh2,sqm3,sqm4,
35410  &shr,sqpth,taup,be34,cth,x(2),sqmz,sqmw,gmmz,gmmw,
35411  &aem,as,xw,xw1,xwc,xwv,poll,polr,polll,polrr
35412  SAVE /pydat1/,/pydat2/,/pypars/,/pyint1/,/pyint2/,/pyint3/,
35413  &/pyint4/,/pymssm/,/pyssmt/,/pysgcm/
35414 C...Local arrays and complex variables
35415  dimension wdtp(0:400),wdte(0:400,0:5)
35416  COMPLEX*16 olpp,orpp,olp,orp,ol,or,qll,qlr
35417  COMPLEX*16 qrr,qrl,glij,grij,propw,propz
35418  COMPLEX*16 zmixc(4,4),umixc(2,2),vmixc(2,2)
35419 
35420 CMRENNA++
35421 C...Z and W width, combinations of weak mixing angle
35422  zwid=pmas(23,2)
35423  wwid=pmas(24,2)
35424  tanw=sqrt(xw/xw1)
35425  ct2w=(1d0-2d0*xw)/(2d0*xw/tanw)
35426 
35427 C...Convert almost equivalent SUSY processes into each other
35428 C...Extract differences in flavours and couplings
35429 
35430 C...Sleptons and sneutrinos
35431  IF(isub.EQ.201.OR.isub.EQ.204.OR.isub.EQ.207) THEN
35432  kfid=mod(kfpr(isub,1),ksusy1)
35433  isub=201
35434  ilr=0
35435  ELSEIF(isub.EQ.202.OR.isub.EQ.205.OR.isub.EQ.208) THEN
35436  kfid=mod(kfpr(isub,1),ksusy1)
35437  isub=201
35438  ilr=1
35439  ELSEIF(isub.EQ.203.OR.isub.EQ.206.OR.isub.EQ.209) THEN
35440  kfid=mod(kfpr(isub,1),ksusy1)
35441  isub=203
35442  ELSEIF(isub.GE.210.AND.isub.LE.212) THEN
35443  IF(isub.EQ.210) THEN
35444  rkf=2.0d0
35445  ELSEIF(isub.EQ.211) THEN
35446  rkf=sfmix(15,1)**2
35447  ELSEIF(isub.EQ.212) THEN
35448  rkf=sfmix(15,2)**2
35449  ENDIF
35450  isub=210
35451  ELSEIF(isub.EQ.213.OR.isub.EQ.214) THEN
35452  IF(isub.EQ.213) THEN
35453  kfid=mod(kfpr(isub,1),ksusy1)
35454  rkf=2.0d0
35455  ELSEIF(isub.EQ.214) THEN
35456  kfid=16
35457  rkf=1.0d0
35458  ENDIF
35459  isub=213
35460 
35461 C...Neutralinos
35462  ELSEIF(isub.GE.216.AND.isub.LE.225) THEN
35463  IF(isub.EQ.216) THEN
35464  izid1=1
35465  izid2=1
35466  ELSEIF(isub.EQ.217) THEN
35467  izid1=2
35468  izid2=2
35469  ELSEIF(isub.EQ.218) THEN
35470  izid1=3
35471  izid2=3
35472  ELSEIF(isub.EQ.219) THEN
35473  izid1=4
35474  izid2=4
35475  ELSEIF(isub.EQ.220) THEN
35476  izid1=1
35477  izid2=2
35478  ELSEIF(isub.EQ.221) THEN
35479  izid1=1
35480  izid2=3
35481  ELSEIF(isub.EQ.222) THEN
35482  izid1=1
35483  izid2=4
35484  ELSEIF(isub.EQ.223) THEN
35485  izid1=2
35486  izid2=3
35487  ELSEIF(isub.EQ.224) THEN
35488  izid1=2
35489  izid2=4
35490  ELSEIF(isub.EQ.225) THEN
35491  izid1=3
35492  izid2=4
35493  ENDIF
35494  isub=216
35495 
35496 C...Charginos
35497  ELSEIF(isub.GE.226.AND.isub.LE.228) THEN
35498  IF(isub.EQ.226) THEN
35499  izid1=1
35500  izid2=1
35501  ELSEIF(isub.EQ.227) THEN
35502  izid1=2
35503  izid2=2
35504  ELSEIF(isub.EQ.228) THEN
35505  izid1=1
35506  izid2=2
35507  ENDIF
35508  isub=226
35509 
35510 C...Neutralino + chargino
35511  ELSEIF(isub.GE.229.AND.isub.LE.236) THEN
35512  IF(isub.EQ.229) THEN
35513  izid1=1
35514  izid2=1
35515  ELSEIF(isub.EQ.230) THEN
35516  izid1=1
35517  izid2=2
35518  ELSEIF(isub.EQ.231) THEN
35519  izid1=1
35520  izid2=3
35521  ELSEIF(isub.EQ.232) THEN
35522  izid1=1
35523  izid2=4
35524  ELSEIF(isub.EQ.233) THEN
35525  izid1=2
35526  izid2=1
35527  ELSEIF(isub.EQ.234) THEN
35528  izid1=2
35529  izid2=2
35530  ELSEIF(isub.EQ.235) THEN
35531  izid1=2
35532  izid2=3
35533  ELSEIF(isub.EQ.236) THEN
35534  izid1=2
35535  izid2=4
35536  ENDIF
35537  isub=229
35538 
35539 C...Gluino + neutralino
35540  ELSEIF(isub.GE.237.AND.isub.LE.240) THEN
35541  IF(isub.EQ.237) THEN
35542  izid=1
35543  ELSEIF(isub.EQ.238) THEN
35544  izid=2
35545  ELSEIF(isub.EQ.239) THEN
35546  izid=3
35547  ELSEIF(isub.EQ.240) THEN
35548  izid=4
35549  ENDIF
35550  isub=237
35551 
35552 C...Gluino + chargino
35553  ELSEIF(isub.GE.241.AND.isub.LE.242) THEN
35554  IF(isub.EQ.241) THEN
35555  izid=1
35556  ELSEIF(isub.EQ.242) THEN
35557  izid=2
35558  ENDIF
35559  isub=241
35560 
35561 C...Squark + neutralino
35562  ELSEIF(isub.GE.246.AND.isub.LE.253) THEN
35563  ilr=0
35564  IF(mod(isub,2).NE.0) ilr=1
35565  IF(isub.LE.247) THEN
35566  izid=1
35567  ELSEIF(isub.LE.249) THEN
35568  izid=2
35569  ELSEIF(isub.LE.251) THEN
35570  izid=3
35571  ELSEIF(isub.LE.253) THEN
35572  izid=4
35573  ENDIF
35574  isub=246
35575  rkf=5d0
35576 
35577 C...Squark + chargino
35578  ELSEIF(isub.GE.254.AND.isub.LE.257) THEN
35579  IF(isub.LE.255) THEN
35580  izid=1
35581  ELSEIF(isub.LE.257) THEN
35582  izid=2
35583  ENDIF
35584  IF(mod(isub,2).EQ.0) THEN
35585  ilr=0
35586  ELSE
35587  ilr=1
35588  ENDIF
35589  isub=254
35590  rkf=5d0
35591 
35592 C...Squark + gluino
35593  ELSEIF(isub.EQ.258.OR.isub.EQ.259) THEN
35594  isub=258
35595  rkf=4d0
35596 
35597 C...Stops
35598  ELSEIF(isub.EQ.261.OR.isub.EQ.262) THEN
35599  ilr=0
35600  IF(isub.EQ.262) ilr=1
35601  isub=261
35602  ELSEIF(isub.EQ.265) THEN
35603  isub=264
35604 
35605 C...Squarks
35606  ELSEIF(isub.GE.271.AND.isub.LE.280) THEN
35607  ilr=0
35608  IF(isub.LE.273) THEN
35609  IF(isub.EQ.273) ilr=1
35610  isub=271
35611  rkf=16d0
35612  ELSEIF(isub.LE.276) THEN
35613  IF(isub.EQ.276) ilr=1
35614  isub=274
35615  rkf=16d0
35616  ELSEIF(isub.LE.278) THEN
35617  IF(isub.EQ.278) ilr=1
35618  isub=277
35619  rkf=4d0
35620  ELSE
35621  IF(isub.EQ.280) ilr=1
35622  isub=279
35623  rkf=4d0
35624  ENDIF
35625 C...Sbottoms
35626  ELSEIF(isub.GE.281.AND.isub.LE.296) THEN
35627  ilr=0
35628  IF(isub.LE.283) THEN
35629  IF(isub.EQ.283) ilr=1
35630  isub=271
35631  rkf=4d0
35632  ELSEIF(isub.LE.286) THEN
35633  IF(isub.EQ.286) ilr=1
35634  isub=274
35635  rkf=4d0
35636  ELSEIF(isub.LE.288) THEN
35637  IF(isub.EQ.288) ilr=1
35638  isub=277
35639  rkf=1d0
35640  ELSEIF(isub.LE.290) THEN
35641  IF(isub.EQ.290) ilr=1
35642  isub=279
35643  rkf=1d0
35644  ELSEIF(isub.LE.293) THEN
35645  IF(isub.EQ.293) ilr=1
35646  isub=271
35647  rkf=1d0
35648  ELSEIF(isub.EQ.296) THEN
35649  ilr=1
35650  isub=274
35651  rkf=1d0
35652 C...Squark + gluino
35653  ELSEIF(isub.EQ.294.OR.isub.EQ.295) THEN
35654  isub=258
35655  rkf=1d0
35656  ENDIF
35657 C...H+/- + H0
35658  ELSEIF(isub.EQ.297.OR.isub.EQ.298) THEN
35659  IF(isub.EQ.297) THEN
35660  rkf=.5d0*paru(195)**2
35661  ELSEIF(isub.EQ.298) THEN
35662  rkf=.5d0*(1d0-paru(195)**2)
35663  ENDIF
35664  isub=210
35665 C...A0 + H0
35666  ELSEIF(isub.EQ.299.OR.isub.EQ.300) THEN
35667  IF(isub.EQ.299) THEN
35668  rkf=paru(186)**2
35669  kfid=25
35670  ELSEIF(isub.EQ.300) THEN
35671  rkf=paru(187)**2
35672  kfid=35
35673  ENDIF
35674  isub=213
35675 C...H+ + H-
35676  ELSEIF(isub.EQ.301) THEN
35677  kfid=37
35678  rkf=1d0
35679  isub=201
35680  ENDIF
35681 
35682 C...Supersymmetric processes - all of type 2 -> 2 :
35683 C...correct final-state Breit-Wigners from fixed to running width.
35684  IF(mstp(42).GT.0) THEN
35685  DO 100 i=1,2
35686  kflw=kfpr(isubsv,i)
35687  kcw=pycomp(kflw)
35688  IF(pmas(kcw,2).LT.parp(41)) goto 100
35689  IF(i.EQ.1) sqmi=sqm3
35690  IF(i.EQ.2) sqmi=sqm4
35691  sqms=pmas(kcw,1)**2
35692  gmms=pmas(kcw,1)*pmas(kcw,2)
35693  hbws=gmms/((sqmi-sqms)**2+gmms**2)
35694  CALL pywidt(kflw,sqmi,wdtp,wdte)
35695  gmmi=sqrt(sqmi)*wdtp(0)
35696  hbwi=gmmi/((sqmi-sqms)**2+gmmi**2)
35697  comfac=comfac*(hbwi/hbws)
35698  100 CONTINUE
35699  ENDIF
35700 
35701 C...Differential cross section expressions.
35702 
35703  IF(isub.LE.210) THEN
35704  IF(isub.EQ.201) THEN
35705 C...f + fbar -> e_L + e_Lbar
35706  comfac=comfac*wids(pycomp(kfpr(isubsv,1)),1)
35707  DO 130 i=mmin1,mmax1
35708  ia=iabs(i)
35709  IF(i.EQ.0.OR.kfac(1,i)*kfac(2,-i).EQ.0) goto 130
35710  ei=kchg(ia,1)/3d0
35711  tt3i=sign(1d0,ei+1d-6)/2d0
35712  ej=-1d0
35713  tt3j=-1d0/2d0
35714  fcol=1d0
35715 C...Color factor for e+ e-
35716  IF(ia.GE.11) fcol=3d0
35717  IF(isubsv.EQ.301) THEN
35718  a1=1d0
35719  a2=0d0
35720  ELSEIF(ilr.EQ.1) THEN
35721  a1=sfmix(kfid,3)**2
35722  a2=sfmix(kfid,4)**2
35723  ELSEIF(ilr.EQ.0) THEN
35724  a1=sfmix(kfid,1)**2
35725  a2=sfmix(kfid,2)**2
35726  ENDIF
35727  xlq=(tt3j-ej*xw)*a1
35728  xrq=(-ej*xw)*a2
35729  xlf=(tt3i-ei*xw)
35730  xrf=(-ei*xw)
35731  taa=(ei*ej)**2*(poll+polr)
35732  tzz=(xlf**2*poll+xrf**2*polr)*(xlq+xrq)**2/xw**2/xw1**2
35733  tzz=tzz/((1d0-sqmz/sh)**2+sqmz*zwid/sh**2)
35734  taz=2d0*ei*ej*(xlq+xrq)*(xlf*poll+xrf*polr)/xw/xw1
35735  taz=taz/((1d0-sqmz/sh)**2+sqmz*(zwid/sh)**2)*(1d0-sqmz/sh)
35736  tnn=0.0d0
35737  tan=0.0d0
35738  tzn=0.0d0
35739  IF(ia.GE.11.AND.ia.LE.18.AND.kfid.EQ.ia) THEN
35740  fac2=sqrt(2d0)
35741  tnn1=0d0
35742  tnn2=0d0
35743  tnn3=0d0
35744  DO 120 ii=1,4
35745  dk=1d0/(th-smz(ii)**2)
35746  flek=-fac2*(tt3i*zmix(ii,2)-tanw*(tt3i-ei)*
35747  & zmix(ii,1))
35748  frek=fac2*tanw*ei*zmix(ii,1)
35749  tnn1=tnn1+flek**2*dk
35750  tnn2=tnn2+frek**2*dk
35751  DO 110 jj=1,4
35752  dl=1d0/(th-smz(jj)**2)
35753  flel=-fac2*(tt3j*zmix(jj,2)-tanw*(tt3j-ej)*
35754  & zmix(jj,1))
35755  frel=fac2*tanw*ej*zmix(jj,1)
35756  tnn3=tnn3+flek*frek*flel*frel*dk*dl*smz(ii)*smz(jj)
35757  110 CONTINUE
35758  120 CONTINUE
35759  tnn=(uh*th-sqm3*sqm4)*(a1**2*tnn1**2*poll+
35760  & a2**2*tnn2**2*polr)
35761  tnn=(tnn+sh*a1*a2*tnn3*((1d0-parj(131))*(1d0-parj(132))+
35762  & (1d0+parj(131))*(1d0+parj(132))))/4d0/xw**2
35763  tzn=(uh*th-sqm3*sqm4)*(xlq+xrq)*
35764  & (tnn1*xlf*a1*poll+tnn2*xrf*a2*polr)
35765  tzn=tzn/((1d0-sqmz/sh)**2+sqmz*(zwid/sh)**2)*
35766  & (1d0-sqmz/sh)/sh
35767  tzn=tzn/xw**2/xw1
35768  tan=ei*ej*(uh*th-sqm3*sqm4)/sh*(a1*tnn1*poll+
35769  & a2*tnn2*polr)/xw
35770  ENDIF
35771  facqq1=comfac*aem**2*(taa+tzz+taz)*fcol/3d0
35772  facqq1=facqq1*( uh*th-sqm3*sqm4 )/sh**2
35773  facqq2=comfac*aem**2*(tnn+tzn+tan)*fcol/3d0
35774  nchn=nchn+1
35775  isig(nchn,1)=i
35776  isig(nchn,2)=-i
35777  isig(nchn,3)=1
35778  sigh(nchn)=facqq1+facqq2
35779  130 CONTINUE
35780 
35781  ELSEIF(isub.EQ.203) THEN
35782 C...f + fbar -> e_L + e_Rbar
35783  DO 160 i=mmin1,mmax1
35784  ia=iabs(i)
35785  IF(i.EQ.0.OR.kfac(1,i)*kfac(2,-i).EQ.0) goto 160
35786  ei=kchg(iabs(i),1)/3d0
35787  tt3i=sign(1d0,ei)/2d0
35788  ej=-1
35789  tt3j=-1d0/2d0
35790  fcol=1d0
35791 C...Color factor for e+ e-
35792  IF(ia.GE.11) fcol=3d0
35793  a1=sfmix(kfid,1)**2
35794  a2=sfmix(kfid,2)**2
35795  xlq=(tt3j-ej*xw)
35796  xrq=(-ej*xw)
35797  xlf=(tt3i-ei*xw)
35798  xrf=(-ei*xw)
35799  tzz=(xlf**2*poll+xrf**2*polr)*(xlq-xrq)**2
35800  & /xw**2/xw1**2*a1*a2
35801  tzz=tzz/((1d0-sqmz/sh)**2+sqmz*(zwid/sh)**2)
35802  tnn=0.0d0
35803  tzn=0.0d0
35804  tnna=0d0
35805  tnnb=0d0
35806  IF(ia.GE.11.AND.ia.LE.18.AND.kfid.EQ.ia) THEN
35807  fac2=sqrt(2d0)
35808  tnn1=0d0
35809  tnn2=0d0
35810  tnn3=0d0
35811  DO 150 ii=1,4
35812  dk=1d0/(th-smz(ii)**2)
35813  flek=-fac2*(tt3i*zmix(ii,2)-tanw*(tt3i-ei)*
35814  & zmix(ii,1))
35815  frek=fac2*tanw*ei*zmix(ii,1)
35816  tnn1=tnn1+flek**2*dk
35817  tnn2=tnn2+frek**2*dk
35818  DO 140 jj=1,4
35819  dl=1d0/(th-smz(jj)**2)
35820  flel=-fac2*(tt3j*zmix(jj,2)-tanw*(tt3j-ej)*
35821  & zmix(jj,1))
35822  frel=fac2*tanw*ej*zmix(jj,1)
35823  tnn3=tnn3+flek*frek*flel*frel*dk*dl*smz(ii)*smz(jj)
35824  140 CONTINUE
35825  150 CONTINUE
35826  tnn=(uh*th-sqm3*sqm4)*a1*a2*(tnn2**2*polr+tnn1**2*poll)
35827  tnna=(tnn+sh*(a1**2*polll+a2**2*polrr)*tnn3)/4d0
35828  tnnb=(tnn+sh*(a1**2*polrr+a2**2*polll)*tnn3)/4d0
35829  tzn=(uh*th-sqm3*sqm4)*a1*a2
35830  tzn=tzn*(xlq-xrq)*(xlf*tnn1*poll-xrf*tnn2*polr)/xw1
35831  tzn=tzn/((1d0-sqmz/sh)**2+sqmz*(zwid/sh)**2)*
35832  & (1d0-sqmz/sh)/sh
35833  ENDIF
35834  facqq0=comfac*aem**2*tzz*fcol/3d0*(uh*th-sqm3*sqm4)/sh2
35835  facqq2=comfac*aem**2/xw**2*(tnna+tzn)*fcol/3d0
35836  facqq1=comfac*aem**2/xw**2*(tnnb+tzn)*fcol/3d0
35837 C%%%%%%%%%%%
35838  nchn=nchn+1
35839  isig(nchn,1)=i
35840  isig(nchn,2)=-i
35841  isig(nchn,3)=1
35842  sigh(nchn)=(facqq0+facqq1)*wids(pycomp(kfpr(isubsv,1)),2)*
35843  & wids(pycomp(kfpr(isubsv,2)),3)
35844  nchn=nchn+1
35845  isig(nchn,1)=i
35846  isig(nchn,2)=-i
35847  isig(nchn,3)=2
35848  sigh(nchn)=(facqq0+facqq2)*wids(pycomp(kfpr(isubsv,1)),3)*
35849  & wids(pycomp(kfpr(isubsv,2)),2)
35850  160 CONTINUE
35851 
35852  ELSEIF(isub.EQ.210) THEN
35853 C...q + qbar' -> W*- > ~l_L + ~nu_L
35854  fac0=rkf*comfac*aem**2/xw**2/12d0
35855  fac1=(th*uh-sqm3*sqm4)/((sh-sqmw)**2+wwid**2*sqmw)
35856  DO 180 i=mmin1,mmax1
35857  ia=iabs(i)
35858  IF(i.EQ.0.OR.ia.GT.10.OR.kfac(1,i).EQ.0) goto 180
35859  DO 170 j=mmin2,mmax2
35860  ja=iabs(j)
35861  IF(j.EQ.0.OR.ja.GT.10.OR.kfac(2,j).EQ.0) goto 170
35862  IF(i*j.GT.0.OR.mod(ia+ja,2).EQ.0) goto 170
35863  fckm=3d0
35864  IF(ia.LE.10) fckm=vckm((ia+1)/2,(ja+1)/2)
35865  kchsum=kchg(ia,1)*isign(1,i)+kchg(ja,1)*isign(1,j)
35866  kchw=2
35867  IF(kchsum.LT.0) kchw=3
35868  nchn=nchn+1
35869  isig(nchn,1)=i
35870  isig(nchn,2)=j
35871  isig(nchn,3)=1
35872  IF(isubsv.EQ.297.OR.isubsv.EQ.298) THEN
35873  facr=wids(pycomp(kfpr(isubsv,1)),5-kchw)*
35874  & wids(pycomp(kfpr(isubsv,2)),2)
35875  ELSE
35876  facr=wids(pycomp(kfpr(isubsv,1)),5-kchw)*
35877  & wids(pycomp(kfpr(isubsv,2)),kchw)
35878  ENDIF
35879  sigh(nchn)=fac0*fac1*fckm*facr
35880  170 CONTINUE
35881  180 CONTINUE
35882  ENDIF
35883 
35884  ELSEIF(isub.LE.220) THEN
35885  IF(isub.EQ.213) THEN
35886 C...f + fbar -> ~nu_L + ~nu_Lbar
35887  IF(isubsv.EQ.299.OR.isubsv.EQ.300) THEN
35888  facr=wids(pycomp(kfpr(isubsv,1)),2)*
35889  & wids(pycomp(kfpr(isubsv,2)),2)
35890  ELSE
35891  facr=wids(pycomp(kfpr(isubsv,1)),1)
35892  ENDIF
35893  comfac=comfac*facr
35894  propz2=(sh-sqmz)**2+zwid**2*sqmz
35895  xll=0.5d0
35896  xlr=0.0d0
35897  DO 190 i=mmin1,mmax1
35898  ia=iabs(i)
35899  IF(i.EQ.0.OR.kfac(1,i)*kfac(2,-i).EQ.0) goto 190
35900  ei=kchg(ia,1)/3d0
35901  fcol=1d0
35902 C...Color factor for e+ e-
35903  IF(ia.GE.11) fcol=3d0
35904  xlq=(sign(1d0,ei)-2d0*ei*xw)/2d0
35905  xrq=-ei*xw
35906  tzc=0.0d0
35907  tcc=0.0d0
35908  IF(ia.GE.11.AND.kfid.EQ.ia+1) THEN
35909  tzc=vmix(1,1)**2/(th-smw(1)**2)+vmix(2,1)**2/
35910  & (th-smw(2)**2)
35911  tcc=tzc**2
35912  tzc=tzc/xw1*(sh-sqmz)/propz2*xlq*xll
35913  ENDIF
35914  facqq1=(xlq**2+xrq**2)*(xll+xlr)**2/xw1**2/propz2
35915  facqq2=tzc+tcc/4d0
35916  nchn=nchn+1
35917  isig(nchn,1)=i
35918  isig(nchn,2)=-i
35919  isig(nchn,3)=1
35920  sigh(nchn)=(facqq1+facqq2)*rkf*(uh*th-sqm3*sqm4)*comfac
35921  & *aem**2*fcol/3d0/xw**2
35922  190 CONTINUE
35923 
35924  ELSEIF(isub.EQ.216) THEN
35925 C...q + qbar -> ~chi0_1 + ~chi0_1
35926  IF(izid1.EQ.izid2) THEN
35927  comfac=comfac*wids(pycomp(kfpr(isubsv,1)),1)
35928  ELSE
35929  comfac=comfac*wids(pycomp(kfpr(isubsv,1)),2)*
35930  & wids(pycomp(kfpr(isubsv,2)),2)
35931  ENDIF
35932  facxx=comfac*aem**2/3d0/xw**2
35933  IF(izid1.EQ.izid2) facxx=facxx/2d0
35934  zm12=sqm3
35935  zm22=sqm4
35936  wu2 = (uh-zm12)*(uh-zm22)
35937  wt2 = (th-zm12)*(th-zm22)
35938  ws2 = smz(izid1)*smz(izid2)*sh
35939  propz2 = (sh-sqmz)**2 + sqmz*zwid**2
35940  propz=dcmplx(sh-sqmz,-zwid*pmas(23,1))/dcmplx(propz2)
35941  DO 200 i=1,4
35942  zmixc(izid1,i)=dcmplx(zmix(izid1,i),zmixi(izid1,i))
35943  IF(izid2.NE.izid1) THEN
35944  zmixc(izid2,i)=dcmplx(zmix(izid2,i),zmixi(izid2,i))
35945  ENDIF
35946  200 CONTINUE
35947  olpp=(zmixc(izid1,3)*dconjg(zmixc(izid2,3))-
35948  & zmixc(izid1,4)*dconjg(zmixc(izid2,4)))/2d0
35949  orpp=dconjg(olpp)
35950  DO 210 i=mmina,mmaxa
35951  IF(i.EQ.0.OR.kfac(1,i)*kfac(2,-i).EQ.0) goto 210
35952  ei=kchg(iabs(i),1)/3d0
35953  t3i=sign(1d0,ei+1d-6)/2d0
35954  xml2=pmas(pycomp(ksusy1+iabs(i)),1)**2
35955  xmr2=pmas(pycomp(ksusy2+iabs(i)),1)**2
35956  glij=(t3i*zmixc(izid1,2)-tanw*(t3i-ei)*zmixc(izid1,1))*
35957  & dconjg(t3i*zmixc(izid2,2)-tanw*(t3i-ei)*zmixc(izid2,1))
35958  grij=zmixc(izid1,1)*dconjg(zmixc(izid2,1))*(ei*tanw)**2
35959  qll=dcmplx((t3i-ei*xw)/xw1)*olpp*propz-glij/dcmplx(uh-xml2)
35960  qlr=-dcmplx((t3i-ei*xw)/xw1)*orpp*propz+dconjg(glij)
35961  & /dcmplx(th-xml2)
35962  qrl=-dcmplx((ei*xw)/xw1)*olpp*propz+grij/dcmplx(th-xmr2)
35963  qrr=dcmplx((ei*xw)/xw1)*orpp*propz
35964  & -dconjg(grij)/dcmplx(uh-xmr2)
35965  fcol=1d0
35966  IF(iabs(i).GE.11) fcol=3d0
35967  facgg1=(abs(qll)**2*poll+abs(qrr)**2*polr)*wu2+
35968  & (abs(qrl)**2*polr+abs(qlr)**2*poll)*wt2+
35969  & 2d0*dble(qlr*dconjg(qll)*poll+
35970  & qrl*dconjg(qrr)*polr)*ws2
35971  nchn=nchn+1
35972  isig(nchn,1)=i
35973  isig(nchn,2)=-i
35974  isig(nchn,3)=1
35975  sigh(nchn)=facxx*facgg1*fcol
35976  210 CONTINUE
35977  ENDIF
35978 
35979  ELSEIF(isub.LE.230) THEN
35980  IF(isub.EQ.226) THEN
35981 C...f + fbar -> ~chi+_1 + ~chi-_1
35982  facxx=comfac*aem**2/3d0
35983  zm12=sqm3
35984  zm22=sqm4
35985  wu2 = (uh-zm12)*(uh-zm22)
35986  wt2 = (th-zm12)*(th-zm22)
35987  ws2 = smw(izid1)*smw(izid2)*sh
35988  propz2 = (sh-sqmz)**2 + sqmz*zwid**2
35989  propz=dcmplx(sh-sqmz,-zwid*pmas(23,1))/dcmplx(propz2)
35990  diff=0d0
35991  IF(izid1.EQ.izid2) diff=1d0
35992  DO 220 i=1,2
35993  vmixc(izid1,i)=dcmplx(vmix(izid1,i),vmixi(izid1,i))
35994  umixc(izid1,i)=dcmplx(umix(izid1,i),umixi(izid1,i))
35995  IF(izid2.NE.izid1) THEN
35996  vmixc(izid2,i)=dcmplx(vmix(izid2,i),vmixi(izid2,i))
35997  umixc(izid2,i)=dcmplx(umix(izid2,i),umixi(izid2,i))
35998  ENDIF
35999  220 CONTINUE
36000  olp=-vmixc(izid2,1)*dconjg(vmixc(izid1,1))-
36001  & vmixc(izid2,2)*dconjg(vmixc(izid1,2))/2d0+dcmplx(xw*diff)
36002  orp=-umixc(izid1,1)*dconjg(umixc(izid2,1))-
36003  & umixc(izid1,2)*dconjg(umixc(izid2,2))/2d0+dcmplx(xw*diff)
36004  DO 230 i=mmina,mmaxa
36005  IF(i.EQ.0.OR.kfac(1,i)*kfac(2,-i).EQ.0) goto 230
36006  ei=kchg(iabs(i),1)/3d0
36007  t3i=sign(1d0,ei+1d-6)/2d0
36008  qrl=dcmplx(-ei/sh*diff)-dcmplx(ei/xw1)*propz*orp
36009  qll=dcmplx(-ei/sh*diff)+dcmplx((t3i-xw*ei)/xw/xw1)*propz*orp
36010  qrr=dcmplx(-ei/sh*diff)-dcmplx(ei/xw1)*propz*olp
36011  IF(mod(i,2).EQ.0) THEN
36012  xml2=pmas(pycomp(ksusy1+iabs(i)-1),1)**2
36013  qlr=dcmplx(-ei/sh*diff)+dcmplx((t3i-xw*ei)/xw/xw1)*
36014  & propz*olp-umixc(izid2,1)*dconjg(umixc(izid1,1))*
36015  & dcmplx(t3i/xw/(th-xml2))
36016  ELSE
36017  xml2=pmas(pycomp(ksusy1+iabs(i)+1),1)**2
36018  qlr=dcmplx(-ei/sh*diff)+dcmplx((t3i-xw*ei)/xw/xw1)*
36019  & propz*olp-vmixc(izid2,1)*dconjg(vmixc(izid1,1))*
36020  & dcmplx(t3i/xw/(th-xml2))
36021  ENDIF
36022  fcol=1d0
36023  IF(iabs(i).GE.11) fcol=3d0
36024  facsum=((abs(qll)**2*poll+abs(qrr)**2*polr)*wu2+
36025  & (abs(qrl)**2*polr+abs(qlr)**2*poll)*wt2+
36026  & 2d0*dble(qlr*dconjg(qll)*poll+
36027  & qrl*dconjg(qrr)*polr)*ws2)*facxx*fcol
36028  nchn=nchn+1
36029  isig(nchn,1)=i
36030  isig(nchn,2)=-i
36031  isig(nchn,3)=1
36032  IF(izid1.EQ.izid2) THEN
36033  sigh(nchn)=facsum*wids(pycomp(kfpr(isubsv,1)),1)
36034  ELSE
36035  sigh(nchn)=facsum*wids(pycomp(kfpr(isubsv,1)),3)*
36036  & wids(pycomp(kfpr(isubsv,2)),2)
36037  nchn=nchn+1
36038  isig(nchn,1)=i
36039  isig(nchn,2)=-i
36040  isig(nchn,3)=2
36041  sigh(nchn)=facsum*wids(pycomp(kfpr(isubsv,1)),2)*
36042  & wids(pycomp(kfpr(isubsv,2)),3)
36043  ENDIF
36044  230 CONTINUE
36045 
36046  ELSEIF(isub.EQ.229) THEN
36047 C...q + qbar' -> ~chi0_1 + ~chi+-_1
36048  facxx=comfac*aem**2/6d0/xw**2
36049  zm12=sqm3
36050  zm22=sqm4
36051  wu2 = (uh-zm12)*(uh-zm22)
36052  wt2 = (th-zm12)*(th-zm22)
36053  ws2 = smw(izid1)*smz(izid2)*sh
36054  rt2i = 1d0/sqrt(2d0)
36055  propw = dcmplx(sh-sqmw,-wwid*pmas(24,1))/
36056  & dcmplx((sh-sqmw)**2+wwid**2*sqmw,0d0)
36057  DO 240 i=1,2
36058  vmixc(izid1,i)=dcmplx(vmix(izid1,i),vmixi(izid1,i))
36059  umixc(izid1,i)=dcmplx(umix(izid1,i),umixi(izid1,i))
36060  240 CONTINUE
36061  DO 250 i=1,4
36062  zmixc(izid2,i)=dcmplx(zmix(izid2,i),zmixi(izid2,i))
36063  250 CONTINUE
36064  ol=(dconjg(zmixc(izid2,2))*vmixc(izid1,1)-
36065  & dconjg(zmixc(izid2,4))*vmixc(izid1,2)*rt2i)*propw
36066  or=(zmixc(izid2,2)*dconjg(umixc(izid1,1))+
36067  & zmixc(izid2,3)*dconjg(umixc(izid1,2))*rt2i)*propw
36068 
36069  DO 270 i=mmin1,mmax1
36070  ia=iabs(i)
36071  IF(i.EQ.0.OR.ia.GT.20.OR.kfac(1,i).EQ.0) goto 270
36072  ei=kchg(ia,1)/3d0
36073  t3i=sign(1d0,ei+1d-6)/2d0
36074  DO 260 j=mmin2,mmax2
36075  ja=iabs(j)
36076  IF(j.EQ.0.OR.ja.GT.20.OR.kfac(2,j).EQ.0) goto 260
36077  IF(i*j.GT.0.OR.mod(ia+ja,2).EQ.0) goto 260
36078  ej=kchg(ja,1)/3d0
36079  t3j=sign(1d0,ej+1d-6)/2d0
36080  fckm=3d0
36081  IF(ia.LE.10) fckm=vckm((ia+1)/2,(ja+1)/2)
36082  kchsum=kchg(ia,1)*isign(1,i)+kchg(ja,1)*isign(1,j)
36083  kchw=2
36084  IF(kchsum.LT.0) kchw=3
36085  IF(mod(ia,2).EQ.0) THEN
36086  zmi2 = pmas(pycomp(ksusy1+ia),1)**2
36087  zmj2 = pmas(pycomp(ksusy1+ja),1)**2
36088  qll=ol+vmixc(izid1,1)*dconjg(zmixc(izid2,1)*(ei-t3i)*
36089  & tanw+zmixc(izid2,2)*t3i)/dcmplx(uh-zmi2)
36090  qlr=or-dconjg(umixc(izid1,1))*(
36091  & zmixc(izid2,1)*(ej-t3j)*tanw+zmixc(izid2,2)*t3j)
36092  & /dcmplx(th-zmj2)
36093  ELSE
36094  zmi2 = pmas(pycomp(ksusy1+ja),1)**2
36095  zmj2 = pmas(pycomp(ksusy1+ia),1)**2
36096  qll=ol+vmixc(izid1,1)*dconjg(zmixc(izid2,1)*(ej-t3j)*
36097  & tanw+zmixc(izid2,2)*t3j)/dcmplx(uh-zmj2)
36098  qlr=or-dconjg(umixc(izid1,1))*(
36099  & zmixc(izid2,1)*(ei-t3i)*tanw+zmixc(izid2,2)*t3i)
36100  & /dcmplx(th-zmi2)
36101  ENDIF
36102  zintr=dble(qlr*dconjg(qll))
36103  facgg1=facxx*(abs(qll)**2*wu2+abs(qlr)**2*wt2+
36104  & 2d0*zintr*ws2)
36105  nchn=nchn+1
36106  isig(nchn,1)=i
36107  isig(nchn,2)=j
36108  isig(nchn,3)=1
36109  sigh(nchn)=facgg1*fckm*wids(pycomp(kfpr(isubsv,1)),2)*
36110  & wids(pycomp(kfpr(isubsv,2)),kchw)
36111  260 CONTINUE
36112  270 CONTINUE
36113  ENDIF
36114 
36115  ELSEIF(isub.LE.240) THEN
36116  IF(isub.EQ.237) THEN
36117 C...q + qbar -> gluino + ~chi0_1
36118  comfac=comfac*wids(pycomp(kfpr(isubsv,1)),2)*
36119  & wids(pycomp(kfpr(isubsv,2)),2)
36120  asyuk=rmss(42)*as
36121  fac0=comfac*asyuk*aem*4d0/9d0/xw
36122  gm2=sqm3
36123  zm2=sqm4
36124  DO 280 i=mmina,mmaxa
36125  IF(i.EQ.0.OR.iabs(i).GT.mstp(58).OR.
36126  & kfac(1,i)*kfac(2,-i).EQ.0) goto 280
36127  ei=kchg(iabs(i),1)/3d0
36128  ia=iabs(i)
36129  xlqc = -tanw*ei*zmix(izid,1)
36130  xrqc =(sign(1d0,ei)*zmix(izid,2)-tanw*
36131  & (sign(1d0,ei)-2d0*ei)*zmix(izid,1))/2d0
36132  xlq2=xlqc**2
36133  xrq2=xrqc**2
36134  xml2=pmas(pycomp(ksusy1+ia),1)**2
36135  xmr2=pmas(pycomp(ksusy2+ia),1)**2
36136  atkin=(th-gm2)*(th-zm2)/(th-xml2)**2
36137  aukin=(uh-gm2)*(uh-zm2)/(uh-xml2)**2
36138  atukin=smz(izid)*sqrt(gm2)*sh/(th-xml2)/(uh-xml2)
36139  sgchil=xlq2*(atkin+aukin-2d0*atukin)
36140  atkin=(th-gm2)*(th-zm2)/(th-xmr2)**2
36141  aukin=(uh-gm2)*(uh-zm2)/(uh-xmr2)**2
36142  atukin=smz(izid)*sqrt(gm2)*sh/(th-xmr2)/(uh-xmr2)
36143  sgchir=xrq2*(atkin+aukin-2d0*atukin)
36144  nchn=nchn+1
36145  isig(nchn,1)=i
36146  isig(nchn,2)=-i
36147  isig(nchn,3)=1
36148  sigh(nchn)=fac0*(sgchil+sgchir)
36149  280 CONTINUE
36150  ENDIF
36151 
36152  ELSEIF(isub.LE.250) THEN
36153  IF(isub.EQ.241) THEN
36154 C...q + qbar' -> ~chi+-_1 + gluino
36155  facwg=comfac*as*aem/xw*2d0/9d0
36156  gm2=sqm3
36157  zm2=sqm4
36158  fac01=2d0*umix(izid,1)*vmix(izid,1)
36159  fac0=umix(izid,1)**2
36160  fac1=vmix(izid,1)**2
36161  DO 300 i=mmin1,mmax1
36162  ia=iabs(i)
36163  IF(i.EQ.0.OR.ia.GT.10.OR.kfac(1,i).EQ.0) goto 300
36164  DO 290 j=mmin2,mmax2
36165  ja=iabs(j)
36166  IF(j.EQ.0.OR.ja.GT.10.OR.kfac(2,j).EQ.0) goto 290
36167  IF(i*j.GT.0.OR.mod(ia+ja,2).EQ.0) goto 290
36168  fckm=1d0
36169  IF(ia.LE.10) fckm=vckm((ia+1)/2,(ja+1)/2)
36170  kchsum=kchg(ia,1)*isign(1,i)+kchg(ja,1)*isign(1,j)
36171  kchw=2
36172  IF(kchsum.LT.0) kchw=3
36173  xmu2=pmas(pycomp(ksusy1+2),1)**2
36174  xmd2=pmas(pycomp(ksusy1+1),1)**2
36175  atkin=(th-gm2)*(th-zm2)/(th-xmu2)**2
36176  aukin=(uh-gm2)*(uh-zm2)/(uh-xmd2)**2
36177  atukin=smw(izid)*sqrt(gm2)*sh/(th-xmu2)/(uh-xmd2)
36178  xmu2=pmas(pycomp(ksusy2+2),1)**2
36179  xmd2=pmas(pycomp(ksusy2+1),1)**2
36180  atkin=(atkin+(th-gm2)*(th-zm2)/(th-xmu2)**2)/2d0
36181  aukin=(aukin+(uh-gm2)*(uh-zm2)/(uh-xmd2)**2)/2d0
36182  atukin=(atukin+smw(izid)*sqrt(gm2)*
36183  & sh/(th-xmu2)/(uh-xmd2))/2d0
36184  nchn=nchn+1
36185  isig(nchn,1)=i
36186  isig(nchn,2)=j
36187  isig(nchn,3)=1
36188  sigh(nchn)=facwg*fckm*(fac0*atkin+fac1*aukin-
36189  & fac01*atukin)*wids(pycomp(kfpr(isubsv,1)),2)*
36190  & wids(pycomp(kfpr(isubsv,2)),kchw)
36191  290 CONTINUE
36192  300 CONTINUE
36193 
36194  ELSEIF(isub.EQ.243) THEN
36195 C...q + qbar -> gluino + gluino
36196  comfac=comfac*wids(pycomp(kfpr(isubsv,1)),1)
36197  xmt=sqm3-th
36198  xmu=sqm3-uh
36199  DO 310 i=mmina,mmaxa
36200  IF(i.EQ.0.OR.iabs(i).GT.mstp(58).OR.
36201  & kfac(1,i)*kfac(2,-i).EQ.0) goto 310
36202  nchn=nchn+1
36203  xsu=pmas(pycomp(ksusy1+iabs(i)),1)**2-uh
36204  xst=pmas(pycomp(ksusy1+iabs(i)),1)**2-th
36205  facgg1=comfac*as**2*8d0/3d0*( (xmt**2+xmu**2+
36206  & 2d0*sqm3*sh)/sh2 + rmss(42)**2*(4d0/9d0*(xmt**2/xst**2+
36207  & xmu**2/xsu**2) + sqm3*sh/xst/xsu/9d0) - rmss(42)*(
36208  & (xmt**2+sh*sqm3)/sh/xst + (xmu**2+sh*sqm3)/sh/xsu ))
36209  xsu=pmas(pycomp(ksusy2+iabs(i)),1)**2-uh
36210  xst=pmas(pycomp(ksusy2+iabs(i)),1)**2-th
36211  facgg2=comfac*as**2*8d0/3d0*( (xmt**2+xmu**2+
36212  & 2d0*sqm3*sh)/sh2 + rmss(42)**2*(4d0/9d0*(xmt**2/xst**2+
36213  & xmu**2/xsu**2) + sqm3*sh/xst/xsu/9d0) - rmss(42)*(
36214  & (xmt**2+sh*sqm3)/sh/xst + (xmu**2+sh*sqm3)/sh/xsu ))
36215  isig(nchn,1)=i
36216  isig(nchn,2)=-i
36217  isig(nchn,3)=1
36218 C...1/2 for identical particles
36219  sigh(nchn)=0.25d0*(facgg1+facgg2)
36220  310 CONTINUE
36221 
36222  ELSEIF(isub.EQ.244) THEN
36223 C...g + g -> gluino + gluino
36224  comfac=comfac*wids(pycomp(kfpr(isubsv,1)),1)
36225  xmt=sqm3-th
36226  xmu=sqm3-uh
36227  facqq1=comfac*as**2*9d0/4d0*(
36228  & (xmt*xmu-2d0*sqm3*(th+sqm3))/xmt**2 -
36229  & (xmt*xmu+sqm3*(uh-th))/sh/xmt )
36230  facqq2=comfac*as**2*9d0/4d0*(
36231  & (xmu*xmt-2d0*sqm3*(uh+sqm3))/xmu**2 -
36232  & (xmu*xmt+sqm3*(th-uh))/sh/xmu )
36233  facqq3=comfac*as**2*9d0/4d0*(2d0*xmt*xmu/sh2 +
36234  & sqm3*(sh-4d0*sqm3)/xmt/xmu)
36235  IF(kfac(1,21)*kfac(2,21).EQ.0) goto 320
36236  nchn=nchn+1
36237  isig(nchn,1)=21
36238  isig(nchn,2)=21
36239  isig(nchn,3)=1
36240  sigh(nchn)=facqq1/2d0
36241  nchn=nchn+1
36242  isig(nchn,1)=21
36243  isig(nchn,2)=21
36244  isig(nchn,3)=2
36245  sigh(nchn)=facqq2/2d0
36246  nchn=nchn+1
36247  isig(nchn,1)=21
36248  isig(nchn,2)=21
36249  isig(nchn,3)=3
36250  sigh(nchn)=facqq3/2d0
36251  320 CONTINUE
36252 
36253  ELSEIF(isub.EQ.246) THEN
36254 C...g + q_j -> ~chi0_1 + ~q_j
36255  fac0=comfac*as*aem/6d0/xw
36256  zm2=sqm4
36257  qm2=sqm3
36258  faczq0=fac0*( (zm2-th)/sh +
36259  & (uh-zm2)*(uh+qm2)/(uh-qm2)**2 -
36260  & (sh*(uh+zm2)+2d0*(qm2-zm2)*(zm2-uh))/sh/(uh-qm2) )
36261  kfnsq=mod(kfpr(isubsv,1),ksusy1)
36262  DO 340 i=-kfnsq,kfnsq,2*kfnsq
36263  IF(i.LT.mmina.OR.i.GT.mmaxa) goto 340
36264  IF(i.EQ.0.OR.iabs(i).GT.mstp(58)) goto 340
36265  ei=kchg(iabs(i),1)/3d0
36266  ia=iabs(i)
36267  xrqz = -tanw*ei*zmix(izid,1)
36268  xlqz =(sign(1d0,ei)*zmix(izid,2)-tanw*
36269  & (sign(1d0,ei)-2d0*ei)*zmix(izid,1))/2d0
36270  IF(ilr.EQ.0) THEN
36271  bs=xlqz**2*sfmix(ia,1)**2+xrqz**2*sfmix(ia,2)**2
36272  ELSE
36273  bs=xlqz**2*sfmix(ia,3)**2+xrqz**2*sfmix(ia,4)**2
36274  ENDIF
36275  faczq=faczq0*bs
36276  kchq=2
36277  IF(i.LT.0) kchq=3
36278  DO 330 isde=1,2
36279  IF(isde.EQ.1.AND.kfac(1,i)*kfac(2,21).EQ.0) goto 330
36280  IF(isde.EQ.2.AND.kfac(1,21)*kfac(2,i).EQ.0) goto 330
36281  nchn=nchn+1
36282  isig(nchn,isde)=i
36283  isig(nchn,3-isde)=21
36284  isig(nchn,3)=1
36285  sigh(nchn)=faczq*rkf*wids(pycomp(kfpr(isubsv,1)),kchq)*
36286  & wids(pycomp(kfpr(isubsv,2)),2)
36287  330 CONTINUE
36288  340 CONTINUE
36289  ENDIF
36290 
36291  ELSEIF(isub.LE.260) THEN
36292  IF(isub.EQ.254) THEN
36293 C...g + q_j -> ~chi1_1 + ~q_i
36294  fac0=comfac*as*aem/12d0/xw
36295  zm2=sqm4
36296  qm2=sqm3
36297  au=umix(izid,1)**2
36298  ad=vmix(izid,1)**2
36299  faczq0=fac0*( (zm2-th)/sh +
36300  & (uh-zm2)*(uh+qm2)/(uh-qm2)**2 -
36301  & (sh*(uh+zm2)+2d0*(qm2-zm2)*(zm2-uh))/sh/(uh-qm2) )
36302  kfnsq1=mod(kfpr(isubsv,1),ksusy1)
36303  IF(mod(kfnsq1,2).EQ.0) THEN
36304  kfnsq=kfnsq1-1
36305  kchw=2
36306  ELSE
36307  kfnsq=kfnsq1+1
36308  kchw=3
36309  ENDIF
36310  DO 360 i=-kfnsq,kfnsq,2*kfnsq
36311  IF(i.LT.mmina.OR.i.GT.mmaxa) goto 360
36312  IF(i.EQ.0.OR.iabs(i).GT.mstp(58)) goto 360
36313  ia=iabs(i)
36314  IF(mod(ia,2).EQ.0) THEN
36315  faczq=faczq0*au
36316  ELSE
36317  faczq=faczq0*ad
36318  ENDIF
36319  faczq=faczq*sfmix(kfnsq1,1+2*ilr)**2
36320  kchq=2
36321  IF(i.LT.0) kchq=3
36322  kchwq=kchw
36323  IF(i.LT.0) kchwq=5-kchw
36324  DO 350 isde=1,2
36325  IF(isde.EQ.1.AND.kfac(1,i)*kfac(2,21).EQ.0) goto 350
36326  IF(isde.EQ.2.AND.kfac(1,21)*kfac(2,i).EQ.0) goto 350
36327  nchn=nchn+1
36328  isig(nchn,isde)=i
36329  isig(nchn,3-isde)=21
36330  isig(nchn,3)=1
36331  sigh(nchn)=faczq*rkf*wids(pycomp(kfpr(isubsv,1)),kchq)*
36332  & wids(pycomp(kfpr(isubsv,2)),kchwq)
36333  350 CONTINUE
36334  360 CONTINUE
36335 
36336  ELSEIF(isub.EQ.258) THEN
36337 C...g + q_j -> gluino + ~q_i
36338  xg2=sqm4
36339  xq2=sqm3
36340  xmt=xg2-th
36341  xmu=xg2-uh
36342  xst=xq2-th
36343  xsu=xq2-uh
36344  facqg1=0.5d0*4d0/9d0*xmt/sh + (xmt*sh+2d0*xg2*xst)/xmt**2 -
36345  & ( (sh-xq2+xg2)*(-xst)-sh*xg2 )/sh/(-xmt) +
36346  & 0.5d0*1d0/2d0*( xst*(th+2d0*uh+xg2)-xmt*(sh-2d0*xst) +
36347  & (-xmu)*(th+xg2+2d0*xq2) )/2d0/xmt/xsu
36348  facqg2= 4d0/9d0*(-xmu)*(uh+xq2)/xsu**2 + 1d0/18d0*
36349  & (sh*(uh+xg2)
36350  & +2d0*(xq2-xg2)*xmu)/sh/(-xsu) + 0.5d0*4d0/9d0*xmt/sh +
36351  & 0.5d0*1d0/2d0*(xst*(th+2d0*uh+xg2)-xmt*(sh-2d0*xst)+
36352  & (-xmu)*(th+xg2+2d0*xq2))/2d0/xmt/xsu
36353  asyuk=rmss(42)*as
36354  facqg1=comfac*as*asyuk*facqg1/2d0
36355  facqg2=comfac*as*asyuk*facqg2/2d0
36356  kfnsq=mod(kfpr(isubsv,1),ksusy1)
36357  DO 380 i=-kfnsq,kfnsq,2*kfnsq
36358  IF(i.LT.mmina.OR.i.GT.mmaxa) goto 380
36359  IF(i.EQ.0.OR.iabs(i).GT.10) goto 380
36360  kchq=2
36361  IF(i.LT.0) kchq=3
36362  facsel=rkf*wids(pycomp(kfpr(isubsv,1)),kchq)*
36363  & wids(pycomp(kfpr(isubsv,2)),2)
36364  DO 370 isde=1,2
36365  IF(isde.EQ.1.AND.kfac(1,i)*kfac(2,21).EQ.0) goto 370
36366  IF(isde.EQ.2.AND.kfac(1,21)*kfac(2,i).EQ.0) goto 370
36367  nchn=nchn+1
36368  isig(nchn,isde)=i
36369  isig(nchn,3-isde)=21
36370  isig(nchn,3)=1
36371  sigh(nchn)=facqg1*facsel
36372  nchn=nchn+1
36373  isig(nchn,isde)=i
36374  isig(nchn,3-isde)=21
36375  isig(nchn,3)=2
36376  sigh(nchn)=facqg2*facsel
36377  370 CONTINUE
36378  380 CONTINUE
36379  ENDIF
36380 
36381  ELSEIF(isub.LE.270) THEN
36382  IF(isub.EQ.261) THEN
36383 C...q_i + q_ibar -> ~t_1 + ~t_1bar
36384  facqq1=comfac*( (uh*th-sqm3*sqm4)/ sh**2 )*
36385  & wids(pycomp(kfpr(isubsv,1)),1)
36386  kfnsq=mod(kfpr(isubsv,1),ksusy1)
36387  fac0=as**2*4d0/9d0
36388  DO 390 i=mmin1,mmax1
36389  ia=iabs(i)
36390  IF(i.EQ.0.OR.kfac(1,i)*kfac(2,-i).EQ.0) goto 390
36391  IF(ia.GE.11.AND.ia.LE.18) THEN
36392  ei=kchg(ia,1)/3d0
36393  ej=kchg(kfnsq,1)/3d0
36394  t3i=sign(1d0,ei)/2d0
36395  t3j=sign(1d0,ej)/2d0
36396  xlq=2d0*(t3j-ej*xw)*sfmix(kfnsq,2*ilr+1)**2
36397  xrq=2d0*(-ej*xw)*sfmix(kfnsq,2*ilr+2)**2
36398  xlf=2d0*(t3i-ei*xw)
36399  xrf=2d0*(-ei*xw)
36400  taa=0.5d0*(ei*ej)**2
36401  tzz=(xlf**2+xrf**2)*(xlq+xrq)**2/64d0/xw**2/xw1**2
36402  tzz=tzz/((1d0-sqmz/sh)**2+sqmz*(zwid/sh)**2)
36403  taz=ei*ej*(xlq+xrq)*(xlf+xrf)/8d0/xw/xw1
36404  taz=taz/((1d0-sqmz/sh)**2+sqmz*(zwid/sh)**2)*(1d0-sqmz/sh)
36405  fac0=aem**2*12d0*(taa+tzz+taz)
36406  ENDIF
36407  nchn=nchn+1
36408  isig(nchn,1)=i
36409  isig(nchn,2)=-i
36410  isig(nchn,3)=1
36411  sigh(nchn)=facqq1*fac0
36412  390 CONTINUE
36413 
36414  ELSEIF(isub.EQ.263) THEN
36415 C...f + fbar -> ~t1 + ~t2bar
36416  DO 400 i=mmin1,mmax1
36417  ia=iabs(i)
36418  IF(i.EQ.0.OR.kfac(1,i)*kfac(2,-i).EQ.0) goto 400
36419  ei=kchg(iabs(i),1)/3d0
36420  tt3i=sign(1d0,ei)/2d0
36421  ej=2d0/3d0
36422  tt3j=1d0/2d0
36423  fcol=1d0
36424 C...Color factor for e+ e-
36425  IF(ia.GE.11) fcol=3d0
36426  xlq=2d0*(tt3j-ej*xw)
36427  xrq=2d0*(-ej*xw)
36428  xlf=2d0*(tt3i-ei*xw)
36429  xrf=2d0*(-ei*xw)
36430  tzz=(xlf**2+xrf**2)*(xlq-xrq)**2/64d0/xw**2/xw1**2
36431  tzz=tzz*(sfmix(6,1)*sfmix(6,2))**2
36432  tzz=tzz/((1d0-sqmz/sh)**2+sqmz*(zwid/sh)**2)
36433 C...Factor of 2 for t1 t2bar + t2 t1bar
36434 C...PS: bug fix 24 Aug 2010. Factor 2 accounted for by the 2 channels.
36435  facqq1=comfac*aem**2*tzz*fcol*4d0
36436  facqq1=facqq1*( uh*th-sqm3*sqm4 )/sh2
36437  nchn=nchn+1
36438  isig(nchn,1)=i
36439  isig(nchn,2)=-i
36440  isig(nchn,3)=1
36441  sigh(nchn)=facqq1*wids(pycomp(kfpr(isubsv,1)),2)*
36442  & wids(pycomp(kfpr(isubsv,2)),3)
36443  nchn=nchn+1
36444  isig(nchn,1)=i
36445  isig(nchn,2)=-i
36446  isig(nchn,3)=2
36447  sigh(nchn)=facqq1*wids(pycomp(kfpr(isubsv,1)),3)*
36448  & wids(pycomp(kfpr(isubsv,2)),2)
36449  400 CONTINUE
36450 
36451  ELSEIF(isub.EQ.264) THEN
36452 C...g + g -> ~t_1 + ~t_1bar
36453  xsu=sqm3-uh
36454  xst=sqm3-th
36455  fac0=comfac*as**2*(7d0/48d0+3d0*(uh-th)**2/16d0/sh2 )*0.5d0*
36456  & wids(pycomp(kfpr(isubsv,1)),1)
36457  facqq1=fac0*(0.5d0+2d0*sqm3*th/xst**2 + 2d0*sqm3**2/xsu/xst)
36458  facqq2=fac0*(0.5d0+2d0*sqm3*uh/xsu**2 + 2d0*sqm3**2/xsu/xst)
36459  IF(kfac(1,21)*kfac(2,21).EQ.0) goto 410
36460  nchn=nchn+1
36461  isig(nchn,1)=21
36462  isig(nchn,2)=21
36463  isig(nchn,3)=1
36464  sigh(nchn)=facqq1
36465  nchn=nchn+1
36466  isig(nchn,1)=21
36467  isig(nchn,2)=21
36468  isig(nchn,3)=2
36469  sigh(nchn)=facqq2
36470  410 CONTINUE
36471  ENDIF
36472 
36473  ELSEIF(isub.LE.280) THEN
36474  IF(isub.EQ.271) THEN
36475 C...q + q' -> ~q + ~q' (~g exchange)
36476  xmg2=pmas(pycomp(ksusy1+21),1)**2
36477  xmt=xmg2-th
36478  xmu=xmg2-uh
36479  xsu1=sqm3-uh
36480  xsu2=sqm4-uh
36481  xst1=sqm3-th
36482  xst2=sqm4-th
36483  asyuk=rmss(42)*as
36484  IF(ilr.EQ.1) THEN
36485  facqq1=comfac*asyuk**2*4d0/9d0*( -(xst1*xst2+sh*th)/xmt**2 )
36486  facqq2=comfac*asyuk**2*4d0/9d0*( -(xsu1*xsu2+sh*uh)/xmu**2 )
36487  facqqb=0.0d0
36488  ELSE
36489  facqq1=0.5d0*comfac*asyuk**2*4d0/9d0*( sh*xmg2/xmt**2 )
36490  facqq2=0.5d0*comfac*asyuk**2*4d0/9d0*( sh*xmg2/xmu**2 )
36491  facqqb=0.5d0*comfac*asyuk**2*4d0/9d0*( -2d0*sh*xmg2/3d0/
36492  & xmt/xmu )
36493  ENDIF
36494  kfnsqi=mod(kfpr(isubsv,1),ksusy1)
36495  kfnsqj=mod(kfpr(isubsv,2),ksusy1)
36496  DO 430 i=-kfnsqi,kfnsqi,2*kfnsqi
36497  IF(i.LT.mmin1.OR.i.GT.mmax1) goto 430
36498  ia=iabs(i)
36499  IF(i.EQ.0.OR.ia.GT.mstp(58).OR.kfac(1,i).EQ.0) goto 430
36500  kchq=2
36501  IF(i.LT.0) kchq=3
36502  DO 420 j=-kfnsqj,kfnsqj,2*kfnsqj
36503  IF(j.LT.mmin2.OR.j.GT.mmax2) goto 420
36504  ja=iabs(j)
36505  IF(j.EQ.0.OR.ja.GT.mstp(58).OR.kfac(2,j).EQ.0) goto 420
36506  IF(i*j.LT.0) goto 420
36507  nchn=nchn+1
36508  isig(nchn,1)=i
36509  isig(nchn,2)=j
36510  isig(nchn,3)=1
36511  sigh(nchn)=facqq1*rkf*wids(pycomp(kfpr(isubsv,1)),kchq)*
36512  & wids(pycomp(kfpr(isubsv,2)),kchq)
36513  IF(i.EQ.j) THEN
36514  IF(ilr.EQ.0) THEN
36515  sigh(nchn)=0.5d0*(facqq1+0.5d0*facqqb)*rkf*
36516  & wids(pycomp(kfpr(isubsv,1)),kchq+2)
36517  ELSE
36518  sigh(nchn)=0.5d0*facqq1*rkf*
36519  & wids(pycomp(kfpr(isubsv,1)),kchq)*
36520  & wids(pycomp(kfpr(isubsv,2)),kchq)
36521  ENDIF
36522  nchn=nchn+1
36523  isig(nchn,1)=i
36524  isig(nchn,2)=j
36525  isig(nchn,3)=2
36526  IF(ilr.EQ.0) THEN
36527  sigh(nchn)=0.5d0*(facqq2+0.5d0*facqqb)*rkf*
36528  & wids(pycomp(kfpr(isubsv,1)),kchq+2)
36529  ELSE
36530  sigh(nchn)=0.5d0*facqq2*rkf*
36531  & wids(pycomp(kfpr(isubsv,1)),kchq)*
36532  & wids(pycomp(kfpr(isubsv,2)),kchq)
36533  ENDIF
36534  ENDIF
36535  420 CONTINUE
36536  430 CONTINUE
36537 
36538  ELSEIF(isub.EQ.274) THEN
36539 C...q + qbar' -> ~q + ~qbar'
36540  xmg2=pmas(pycomp(ksusy1+21),1)**2
36541  xmt=xmg2-th
36542  xmu=xmg2-uh
36543  IF(ilr.EQ.0) THEN
36544 C...Mrenna...Normalization.and.1/XMT
36545  facqq1=comfac*as**2*2d0/9d0*(
36546  & (uh*th-sqm3*sqm4)/xmt**2 )*rmss(42)**2
36547  facqqb=comfac*as**2*4d0/9d0*(
36548  & (uh*th-sqm3*sqm4)/sh2 )
36549  facqqi=-comfac*as**2*4d0/27d0*(
36550  & (uh*th-sqm3*sqm4)/sh/xmt )*rmss(42)
36551  facqqb=facqqb+facqq1+facqqi
36552  ELSE
36553  facqq1=comfac*as**2*4d0/9d0*( xmg2*sh/xmt**2 )*rmss(42)**2
36554  facqqb=facqq1
36555  ENDIF
36556  kfnsqi=mod(kfpr(isubsv,1),ksusy1)
36557  kfnsqj=mod(kfpr(isubsv,2),ksusy1)
36558  DO 450 i=-kfnsqi,kfnsqi,2*kfnsqi
36559  IF(i.LT.mmin1.OR.i.GT.mmax1) goto 450
36560  ia=iabs(i)
36561  IF(i.EQ.0.OR.ia.GT.mstp(58).OR.kfac(1,i).EQ.0) goto 450
36562  kchq=2
36563  IF(i.LT.0) kchq=3
36564  DO 440 j=-kfnsqj,kfnsqj,2*kfnsqj
36565  IF(j.LT.mmin2.OR.j.GT.mmax2) goto 440
36566  ja=iabs(j)
36567  IF(j.EQ.0.OR.ja.GT.mstp(58).OR.kfac(2,j).EQ.0) goto 440
36568  IF(i*j.GT.0) goto 440
36569  nchn=nchn+1
36570  isig(nchn,1)=i
36571  isig(nchn,2)=j
36572  isig(nchn,3)=1
36573  sigh(nchn)=facqq1*rkf*wids(pycomp(kfpr(isubsv,1)),kchq)*
36574  & wids(pycomp(kfpr(isubsv,2)),5-kchq)
36575  IF(ilr.EQ.0.AND.i.EQ.-j) sigh(nchn)=facqqb*rkf*
36576  & wids(pycomp(kfpr(isubsv,1)),1)
36577  440 CONTINUE
36578  450 CONTINUE
36579 
36580  ELSEIF(isub.EQ.277) THEN
36581 C...q_i + q_ibar -> ~q_j + ~q_jbar ,i .ne. j
36582 C...if i .eq. j covered in 274
36583  facqq1=comfac*( (uh*th-sqm3*sqm4)/ sh**2 )
36584  kfnsq=mod(kfpr(isubsv,1),ksusy1)
36585  fac0=0d0
36586  DO 460 i=mmin1,mmax1
36587  ia=iabs(i)
36588  IF(i.EQ.0.OR.(ia.GT.mstp(58).AND.ia.LE.10).OR.
36589  & kfac(1,i)*kfac(2,-i).EQ.0) goto 460
36590  IF(ia.EQ.kfnsq) goto 460
36591  IF(ia.EQ.11.OR.ia.EQ.13.OR.ia.EQ.15) THEN
36592  ei=kchg(ia,1)/3d0
36593  ej=kchg(kfnsq,1)/3d0
36594  t3j=sign(0.5d0,ej)
36595  t3i=sign(1d0,ei)/2d0
36596  IF(ilr.EQ.0) THEN
36597  xlq=2d0*(t3j-ej*xw)*sfmix(kfnsq,1)
36598  xrq=2d0*(-ej*xw)*sfmix(kfnsq,2)
36599  ELSE
36600  xlq=2d0*(t3j-ej*xw)*sfmix(kfnsq,3)
36601  xrq=2d0*(-ej*xw)*sfmix(kfnsq,4)
36602  ENDIF
36603  xlf=2d0*(t3i-ei*xw)
36604  xrf=2d0*(-ei*xw)
36605  IF(ilr.EQ.0) THEN
36606  xrq=0d0
36607  ELSE
36608  xlq=0d0
36609  ENDIF
36610  taa=0.5d0*(ei*ej)**2
36611  tzz=(xlf**2+xrf**2)*(xlq+xrq)**2/64d0/xw**2/xw1**2
36612  tzz=tzz/((1d0-sqmz/sh)**2+sqmz*(zwid/sh)**2)
36613  taz=ei*ej*(xlq+xrq)*(xlf+xrf)/8d0/xw/xw1
36614  taz=taz/((1d0-sqmz/sh)**2+sqmz*(zwid/sh)**2)*(1d0-sqmz/sh)
36615  fac0=aem**2*12d0*(taa+tzz+taz)
36616  ELSEIF(ia.LE.6) THEN
36617  fac0=as**2*8d0/9d0/2d0
36618  ENDIF
36619  nchn=nchn+1
36620  isig(nchn,1)=i
36621  isig(nchn,2)=-i
36622  isig(nchn,3)=1
36623  sigh(nchn)=facqq1*fac0*rkf*wids(pycomp(kfpr(isubsv,1)),1)
36624  460 CONTINUE
36625 
36626  ELSEIF(isub.EQ.279) THEN
36627 C...g + g -> ~q_j + ~q_jbar
36628  xsu=sqm3-uh
36629  xst=sqm3-th
36630 C...4=RKF because ~t ~tbar and ~b ~bbar treated separately
36631  fac0=rkf*comfac*as**2*( 7d0/48d0+3d0*(uh-th)**2/16d0/sh2 )
36632  facqq1=fac0*(0.5d0+2d0*sqm3*th/xst**2 + 2d0*sqm3**2/xsu/xst)
36633  facqq2=fac0*(0.5d0+2d0*sqm3*uh/xsu**2 + 2d0*sqm3**2/xsu/xst)
36634  IF(kfac(1,21)*kfac(2,21).EQ.0) goto 470
36635  nchn=nchn+1
36636  isig(nchn,1)=21
36637  isig(nchn,2)=21
36638  isig(nchn,3)=1
36639  sigh(nchn)=facqq1/2d0*wids(pycomp(kfpr(isubsv,1)),1)
36640  nchn=nchn+1
36641  isig(nchn,1)=21
36642  isig(nchn,2)=21
36643  isig(nchn,3)=2
36644  sigh(nchn)=facqq2/2d0*wids(pycomp(kfpr(isubsv,1)),1)
36645  470 CONTINUE
36646 
36647  ENDIF
36648  ENDIF
36649 CMRENNA--
36650 
36651  RETURN
36652  END
36653 
36654 C*********************************************************************
36655 
36656 C...PYSGTC
36657 C...Subprocess cross sections for Technicolor processes.
36658 C...Auxiliary to PYSIGH.
36659 
36660  SUBROUTINE pysgtc(NCHN,SIGS)
36661 
36662 C...Double precision and integer declarations
36663  IMPLICIT DOUBLE PRECISION(a-h, o-z)
36664  IMPLICIT INTEGER(i-n)
36665  INTEGER pyk,pychge,pycomp
36666 C...Parameter statement to help give large particle numbers.
36667  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
36668  &kexcit=4000000,kdimen=5000000)
36669 C...Commonblocks
36670  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
36671  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
36672  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
36673  common/pypars/mstp(200),parp(200),msti(200),pari(200)
36674  common/pyint1/mint(400),vint(400)
36675  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
36676  common/pyint3/xsfx(2,-40:40),isig(1000,3),sigh(1000)
36677  common/pyint4/mwid(500),wids(500,5)
36678  common/pytcsm/itcm(0:99),rtcm(0:99)
36679  common/pysgcm/isub,isubsv,mmin1,mmax1,mmin2,mmax2,mmina,mmaxa,
36680  &kfac(2,-40:40),comfac,fack,faca,sh,th,uh,sh2,th2,uh2,sqm3,sqm4,
36681  &shr,sqpth,taup,be34,cth,x(2),sqmz,sqmw,gmmz,gmmw,
36682  &aem,as,xw,xw1,xwc,xwv,poll,polr,polll,polrr
36683  SAVE /pydat1/,/pydat2/,/pydat3/,/pypars/,/pyint1/,/pyint2/,
36684  &/pyint3/,/pyint4/,/pytcsm/,/pysgcm/
36685 C...Local arrays and complex variables
36686  dimension wdtp(0:400),wdte(0:400,0:5)
36687  COMPLEX*16 ssmz,ssmr,ssmo,detd,f2l,f2r,darho,dzrho,daome,dzome
36688  COMPLEX*16 ssmx,daast,dzast,dwast
36689  COMPLEX*16 daa,dzz,daz,dww,dwrho
36690  COMPLEX*16 ztc(6,6),ytc(6,6),dggs,dggt,dggu,dgvs,dgvt,dgvu
36691  COMPLEX*16 dqqs,dqqt,dqqu,dqts,dqgs,dtgs
36692  COMPLEX*16 dvvs,dvvt,dvvu
36693  INTEGER indx(6)
36694 
36695 C...Combinations of weak mixing angle.
36696  tanw=sqrt(xw/xw1)
36697  ct2w=(1d0-2d0*xw)/(2d0*xw/tanw)
36698 
36699 C...Convert almost equivalent technicolor processes into
36700 C...a few basic processes, and set distinguishing parameters.
36701  IF(isub.GE.361.AND.isub.LE.380) THEN
36702  sqtv=rtcm(12)**2
36703  sqta=rtcm(13)**2
36704  sn2w=2d0*sqrt(xw*xw1)
36705  cs2w=1d0-2d0*xw
36706  ct2w=cs2w/sn2w
36707  csxi=cos(asin(rtcm(3)))
36708  csxip=cos(asin(rtcm(4)))
36709  qupd=2d0*rtcm(2)-1d0
36710  q2ud=rtcm(2)**2+(rtcm(2)-1d0)**2
36711  cab2=0d0
36712  vogp=0d0
36713  vrgp=0d0
36714  aogp=0d0
36715  argp=0d0
36716  vxgp=0d0
36717  axgp=0d0
36718  vagp=0d0
36719  vzgp=0d0
36720  vwgp=0d0
36721 C... rho_tc0, etc. -> W_L W_L, W_L W_T
36722  IF(isub.EQ.361) THEN
36723  kfa=24
36724  kfb=24
36725  cab2=rtcm(3)**4
36726  axgp=-rtcm(3)/(2d0*sqrt(xw))/rtcm(49)
36727  argp=rtcm(3)/(2d0*sqrt(xw))/rtcm(13)
36728  vogp=rtcm(3)/(2d0*sqrt(xw))/rtcm(12)
36729 C...Multiply by sqrt(2) to account for W^+_T W^-_L + W^+_L W^-_T.
36730  axgp = sqrt(2d0)*axgp
36731  argp = sqrt(2d0)*argp
36732  vogp = sqrt(2d0)*vogp
36733 C... rho_tc0 -> W_L pi_tc-
36734  ELSEIF(isub.EQ.362) THEN
36735  kfa=24
36736  kfb=ktechn+211
36737  isub=361
36738  cab2=rtcm(3)**2*(1d0-rtcm(3)**2)
36739 C... pi_tc pi_tc
36740  ELSEIF(isub.EQ.363) THEN
36741  kfa=ktechn+211
36742  kfb=ktechn+211
36743  isub=361
36744  cab2=(1d0-rtcm(3)**2)**2
36745 C... rho_tc0/omega_tc -> gamma pi_tc
36746  ELSEIF(isub.EQ.364) THEN
36747  kfa=22
36748  kfb=ktechn+111
36749  isub=361
36750  vogp=csxi/rtcm(12)
36751  vrgp=vogp*qupd
36752  vagp=2d0*qupd*csxi
36753  vzgp=qupd*csxi*(1d0-4d0*xw)/sn2w
36754 C... gamma pi_tc'
36755  ELSEIF(isub.EQ.365) THEN
36756  kfa=22
36757  kfb=ktechn+221
36758  isub=361
36759  vrgp=csxip/rtcm(12)
36760  vogp=vrgp*qupd
36761  vagp=2d0*q2ud*csxip
36762  vzgp=csxip/sn2w*(1d0-4d0*xw*q2ud)
36763 C... Z pi_tc
36764  ELSEIF(isub.EQ.366) THEN
36765  kfa=23
36766  kfb=ktechn+111
36767  isub=361
36768  vogp=csxi*ct2w/rtcm(12)
36769  vrgp=-qupd*csxi*tanw/rtcm(12)
36770  vagp=qupd*csxi*(1d0-4d0*xw)/sn2w
36771  vzgp=-qupd*csxi*cs2w/xw1
36772 C... Z pi_tc'
36773  ELSEIF(isub.EQ.367) THEN
36774  kfa=23
36775  kfb=ktechn+221
36776  isub=361
36777 C...RTCM(48) is the M_V for the techni-a
36778  vxgp=-csxip/sn2w/rtcm(48)
36779  vrgp=csxip*ct2w/rtcm(12)
36780  vogp=-qupd*csxip*tanw/rtcm(12)
36781  vagp=csxip*(1d0-4d0*q2ud*xw)/sn2w
36782  vzgp=2d0*csxip*(cs2w+4d0*q2ud*xw**2)/sn2w**2
36783 C... W_T pi_tc
36784  ELSEIF(isub.EQ.368) THEN
36785  kfa=24
36786  kfb=ktechn+211
36787  isub=361
36788 C...RTCM(49) is the M_A for the techni-a
36789  axgp=-csxi/(2d0*sqrt(xw))/rtcm(49)
36790  vogp=csxi/(2d0*sqrt(xw))/rtcm(12)
36791  argp=csxi/(2d0*sqrt(xw))/rtcm(13)
36792  vagp=qupd*csxi/(2d0*sqrt(xw))
36793  vzgp=-qupd*csxi/(2d0*sqrt(xw1))
36794 C... rho_tc+, a_T+ -> W_L Z_L, W_T Z_L
36795  ELSEIF(isub.EQ.370) THEN
36796  kfa=24
36797  kfb=23
36798  cab2=rtcm(3)**4
36799  argp=-rtcm(3)/(2d0*sqrt(xw))/rtcm(13)
36800  axgp=rtcm(3)/(2d0*sqrt(xw))/rtcm(49)
36801 C... W_L pi_tc0
36802  ELSEIF(isub.EQ.371) THEN
36803  kfa=24
36804  kfb=ktechn+111
36805  isub=370
36806  cab2=rtcm(3)**2*(1d0-rtcm(3)**2)
36807 C... Z_L pi_tc+
36808  ELSEIF(isub.EQ.372) THEN
36809  kfa=ktechn+211
36810  kfb=23
36811  isub=370
36812  cab2=rtcm(3)**2*(1d0-rtcm(3)**2)
36813 C... pi_tc+ pi_tc0
36814  ELSEIF(isub.EQ.373) THEN
36815  kfa=ktechn+211
36816  kfb=ktechn+111
36817  isub=370
36818  cab2=(1d0-rtcm(3)**2)**2
36819 C... gamma pi_tc+
36820  ELSEIF(isub.EQ.374) THEN
36821  kfa=ktechn+211
36822  kfb=22
36823  isub=370
36824  vrgp=qupd*csxi/rtcm(12)
36825  vwgp=qupd*csxi/(2d0*sqrt(xw))
36826  axgp=-csxi/rtcm(49)
36827 C... Z_T pi_tc+
36828  ELSEIF(isub.EQ.375) THEN
36829  kfa=ktechn+211
36830  kfb=23
36831  isub=370
36832  vrgp=-qupd*csxi*tanw/rtcm(12)
36833  argp=csxi/(2d0*sqrt(xw*xw1))/rtcm(13)
36834  vwgp=-qupd*csxi/(2d0*sqrt(xw1))
36835  axgp=-csxi*ct2w/rtcm(49)
36836 C... W_T pi_tc0
36837  ELSEIF(isub.EQ.376) THEN
36838  kfa=24
36839  kfb=ktechn+111
36840  isub=370
36841  vrgp=0d0
36842  argp=-csxi/(2d0*sqrt(xw))/rtcm(13)
36843  axgp=csxi/(2d0*sqrt(xw))/rtcm(49)
36844 C... W_T pi_tc0'
36845  ELSEIF(isub.EQ.377) THEN
36846  kfa=24
36847  kfb=ktechn+221
36848  isub=370
36849  vrgp=csxip/(2d0*sqrt(xw))/rtcm(12)
36850  vwgp=csxip/(2d0*xw)
36851  vxgp=-csxip/(2d0*sqrt(xw))/rtcm(48)
36852 C... gamma W+
36853  ELSEIF(isub.EQ.378) THEN
36854  kfa=24
36855  kfb=22
36856  isub=370
36857  vrgp=qupd*rtcm(3)/rtcm(12)
36858  axgp=-rtcm(3)/rtcm(49)
36859 C... gamma Z
36860  ELSEIF(isub.EQ.379) THEN
36861  kfa=23
36862  kfb=22
36863  isub=361
36864  vogp=rtcm(3)/rtcm(12)
36865  vrgp=qupd*rtcm(3)/rtcm(12)
36866  ELSEIF(isub.EQ.380) THEN
36867  kfa=23
36868  kfb=23
36869  isub=361
36870  vogp=rtcm(3)*ct2w/rtcm(12)
36871  vrgp=-qupd*rtcm(3)*tanw/rtcm(12)
36872  ENDIF
36873  ENDIF
36874 
36875 C...QCD 2 -> 2 processes: corrections from virtual technicolor exchange.
36876  IF(isub.GE.381.AND.isub.LE.388) THEN
36877  IF(itcm(5).LE.4) THEN
36878  sqdqqs=1d0/sh2
36879  sqdqqt=1d0/th2
36880  sqdqqu=1d0/uh2
36881  sqdggs=sqdqqs
36882  sqdggt=sqdqqt
36883  sqdggu=sqdqqu
36884  redggs=1d0/sh
36885  redggt=1d0/th
36886  redggu=1d0/uh
36887  redgtu=1d0/uh/th
36888  redgsu=1d0/sh/uh
36889  redgst=1d0/sh/th
36890  redqst=1d0/sh/th
36891  redqtu=1d0/uh/th
36892  sqdlgs=0d0
36893  sqdlgt=0d0
36894  sqdqts=sqdqqs
36895  ELSEIF(itcm(5).EQ.5) THEN
36896  tant3=rtcm(21)
36897  IF(itcm(2).EQ.0) THEN
36898  imdl=1
36899  ELSE
36900  imdl=2
36901  ENDIF
36902  alprht=2.16d0*(3d0/itcm(1))
36903  sin2t=2d0*tant3/(tant3**2+1d0)
36904  sint3=tant3/sqrt(tant3**2+1d0)
36905  xig=sqrt(pyalps(sh)/alprht)
36906  x12=(rtcm(29)*sqrt(1d0-rtcm(29)**2)*cos(rtcm(30))+
36907  & rtcm(31)*sqrt(1d0-rtcm(31)**2)*cos(rtcm(32)))/sqrt(2d0)/sin2t
36908  x21=(rtcm(29)*sqrt(1d0-rtcm(29)**2)*sin(rtcm(30))+
36909  & rtcm(31)*sqrt(1d0-rtcm(31)**2)*sin(rtcm(32)))/sqrt(2d0)/sin2t
36910  x11=(.25d0*(rtcm(29)**2+rtcm(31)**2+2d0)-
36911  & sint3**2)*2d0/sin2t
36912  x22=(.25d0*(2d0-rtcm(29)**2-rtcm(31)**2)-
36913  & sint3**2)*2d0/sin2t
36914 
36915  sm1122=.5d0*(2d0-rtcm(29)**2-rtcm(31)**2)*rtcm(28)**2
36916  sm1112=x12*rtcm(28)**2*sin2t
36917  sm1121=-x21*rtcm(28)**2*sin2t
36918  sm2212=-sm1112
36919  sm2221=-sm1121
36920  sm1221=-.5d0*((1d0-rtcm(29)**2)*sin(2d0*rtcm(30))+
36921  & (1d0-rtcm(31)**2)*sin(2d0*rtcm(32)))*rtcm(28)**2
36922 
36923 C.........SH LOOP
36924  ztc(1,1)=dcmplx(sh,0d0)
36925  CALL pywidt(3100021,sh,wdtp,wdte)
36926  IF(wdtp(0).GT.rtcm(33)*shr) wdtp(0)=rtcm(33)*shr
36927  ztc(2,2)=dcmplx(sh-pmas(pycomp(3100021),1)**2,-shr*wdtp(0))
36928  CALL pywidt(3100113,sh,wdtp,wdte)
36929  ztc(3,3)=dcmplx(sh-pmas(pycomp(3100113),1)**2,-shr*wdtp(0))
36930  CALL pywidt(3400113,sh,wdtp,wdte)
36931  ztc(4,4)=dcmplx(sh-pmas(pycomp(3400113),1)**2,-shr*wdtp(0))
36932  CALL pywidt(3200113,sh,wdtp,wdte)
36933  ztc(5,5)=dcmplx(sh-pmas(pycomp(3200113),1)**2,-shr*wdtp(0))
36934  CALL pywidt(3300113,sh,wdtp,wdte)
36935  ztc(6,6)=dcmplx(sh-pmas(pycomp(3300113),1)**2,-shr*wdtp(0))
36936  ztc(1,2)=(0d0,0d0)
36937  ztc(1,3)=dcmplx(sh*xig,0d0)
36938  ztc(1,4)=ztc(1,3)
36939  ztc(1,5)=ztc(1,2)
36940  ztc(1,6)=ztc(1,2)
36941  ztc(2,3)=dcmplx(sh*xig*x11,0d0)
36942  ztc(2,4)=dcmplx(sh*xig*x22,0d0)
36943  ztc(2,5)=dcmplx(sh*xig*x12,0d0)
36944  ztc(2,6)=dcmplx(sh*xig*x21,0d0)
36945  ztc(3,4)=-sm1122
36946  ztc(3,5)=-sm1112
36947  ztc(3,6)=-sm1121
36948  ztc(4,5)=-sm2212
36949  ztc(4,6)=-sm2221
36950  ztc(5,6)=-sm1221
36951 
36952  DO 110 i=1,5
36953  DO 100 j=i+1,6
36954  ztc(j,i)=ztc(i,j)
36955  100 CONTINUE
36956  110 CONTINUE
36957  CALL pyldcm(ztc,6,6,indx,d)
36958  DO 130 i=1,6
36959  DO 120 j=1,6
36960  ytc(i,j)=(0d0,0d0)
36961  IF(i.EQ.j) ytc(i,j)=(1d0,0d0)
36962  120 CONTINUE
36963  130 CONTINUE
36964 
36965  DO 140 i=1,6
36966  CALL pybksb(ztc,6,6,indx,ytc(1,i))
36967  140 CONTINUE
36968  dggs=ytc(1,1)
36969  dvvs=ytc(2,2)
36970  dgvs=ytc(1,2)
36971 
36972  xig=sqrt(pyalps(-th)/alprht)
36973 C.........TH LOOP
36974  ztc(1,1)=dcmplx(th)
36975  ztc(2,2)=dcmplx(th-pmas(pycomp(3100021),1)**2)
36976  ztc(3,3)=dcmplx(th-pmas(pycomp(3100113),1)**2)
36977  ztc(4,4)=dcmplx(th-pmas(pycomp(3400113),1)**2)
36978  ztc(5,5)=dcmplx(th-pmas(pycomp(3200113),1)**2)
36979  ztc(6,6)=dcmplx(th-pmas(pycomp(3300113),1)**2)
36980  ztc(1,2)=(0d0,0d0)
36981  ztc(1,3)=dcmplx(th*xig,0d0)
36982  ztc(1,4)=ztc(1,3)
36983  ztc(1,5)=ztc(1,2)
36984  ztc(1,6)=ztc(1,2)
36985  ztc(2,3)=dcmplx(th*xig*x11,0d0)
36986  ztc(2,4)=dcmplx(th*xig*x22,0d0)
36987  ztc(2,5)=dcmplx(th*xig*x12,0d0)
36988  ztc(2,6)=dcmplx(th*xig*x21,0d0)
36989  ztc(3,4)=-sm1122
36990  ztc(3,5)=-sm1112
36991  ztc(3,6)=-sm1121
36992  ztc(4,5)=-sm2212
36993  ztc(4,6)=-sm2221
36994  ztc(5,6)=-sm1221
36995  DO 160 i=1,5
36996  DO 150 j=i+1,6
36997  ztc(j,i)=ztc(i,j)
36998  150 CONTINUE
36999  160 CONTINUE
37000  CALL pyldcm(ztc,6,6,indx,d)
37001  DO 180 i=1,6
37002  DO 170 j=1,6
37003  ytc(i,j)=(0d0,0d0)
37004  IF(i.EQ.j) ytc(i,j)=(1d0,0d0)
37005  170 CONTINUE
37006  180 CONTINUE
37007  DO 190 i=1,6
37008  CALL pybksb(ztc,6,6,indx,ytc(1,i))
37009  190 CONTINUE
37010  dggt=ytc(1,1)
37011  dvvt=ytc(2,2)
37012  dgvt=ytc(1,2)
37013 
37014  xig=sqrt(pyalps(-uh)/alprht)
37015 C.........UH LOOP
37016  ztc(1,1)=dcmplx(uh,0d0)
37017  ztc(2,2)=dcmplx(uh-pmas(pycomp(3100021),1)**2)
37018  ztc(3,3)=dcmplx(uh-pmas(pycomp(3100113),1)**2)
37019  ztc(4,4)=dcmplx(uh-pmas(pycomp(3400113),1)**2)
37020  ztc(5,5)=dcmplx(uh-pmas(pycomp(3200113),1)**2)
37021  ztc(6,6)=dcmplx(uh-pmas(pycomp(3300113),1)**2)
37022  ztc(1,2)=(0d0,0d0)
37023  ztc(1,3)=dcmplx(uh*xig,0d0)
37024  ztc(1,4)=ztc(1,3)
37025  ztc(1,5)=ztc(1,2)
37026  ztc(1,6)=ztc(1,2)
37027  ztc(2,3)=dcmplx(uh*xig*x11,0d0)
37028  ztc(2,4)=dcmplx(uh*xig*x22,0d0)
37029  ztc(2,5)=dcmplx(uh*xig*x12,0d0)
37030  ztc(2,6)=dcmplx(uh*xig*x21,0d0)
37031  ztc(3,4)=-sm1122
37032  ztc(3,5)=-sm1112
37033  ztc(3,6)=-sm1121
37034  ztc(4,5)=-sm2212
37035  ztc(4,6)=-sm2221
37036  ztc(5,6)=-sm1221
37037  DO 210 i=1,5
37038  DO 200 j=i+1,6
37039  ztc(j,i)=ztc(i,j)
37040  200 CONTINUE
37041  210 CONTINUE
37042  CALL pyldcm(ztc,6,6,indx,d)
37043  DO 230 i=1,6
37044  DO 220 j=1,6
37045  ytc(i,j)=(0d0,0d0)
37046  IF(i.EQ.j) ytc(i,j)=(1d0,0d0)
37047  220 CONTINUE
37048  230 CONTINUE
37049  DO 240 i=1,6
37050  CALL pybksb(ztc,6,6,indx,ytc(1,i))
37051  240 CONTINUE
37052  dggu=ytc(1,1)
37053  dvvu=ytc(2,2)
37054  dgvu=ytc(1,2)
37055 
37056  IF(imdl.EQ.1) THEN
37057  dqqs=dggs+dvvs*dcmplx(tant3**2)-dgvs*dcmplx(2d0*tant3)
37058  dqqt=dggt+dvvt*dcmplx(tant3**2)-dgvt*dcmplx(2d0*tant3)
37059  dqqu=dggu+dvvu*dcmplx(tant3**2)-dgvu*dcmplx(2d0*tant3)
37060  dqts=dggs-dvvs-dgvs*dcmplx(tant3-1d0/tant3)
37061  dqgs=dggs-dgvs*dcmplx(tant3)
37062  dtgs=dggs+dgvs*dcmplx(1d0/tant3)
37063  ELSE
37064  dqqs=dggs+dvvs*dcmplx(1d0/tant3**2)+dgvs*dcmplx(2d0/tant3)
37065  dqqt=dggt+dvvt*dcmplx(1d0/tant3**2)+dgvt*dcmplx(2d0/tant3)
37066  dqqu=dggu+dvvu*dcmplx(1d0/tant3**2)+dgvu*dcmplx(2d0/tant3)
37067  dqts=dggs+dvvs*dcmplx(1d0/tant3**2)+dgvs*dcmplx(2d0/tant3)
37068  dqgs=dggs+dgvs*dcmplx(1d0/tant3)
37069  dtgs=dggs+dgvs*dcmplx(1d0/tant3)
37070  ENDIF
37071 
37072  sqdqts=abs(dqts)**2
37073  sqdqqs=abs(dqqs)**2
37074  sqdqqt=abs(dqqt)**2
37075  sqdqqu=abs(dqqu)**2
37076  sqdlgs=abs(dcmplx(sh)*dqgs-dcmplx(1d0))**2
37077  redlgs=dble(dqgs)
37078  sqdhgs=abs(dcmplx(sh)*dtgs-dcmplx(1d0))**2
37079  redhgs=dble(dtgs)
37080  sqdlgt=abs(dcmplx(th)*dggt-dcmplx(1d0))**2
37081 
37082  sqdggs=abs(dggs)**2
37083  sqdggt=abs(dggt)**2
37084  sqdggu=abs(dggu)**2
37085  redggs=dble(dggs)
37086  redggt=dble(dggt)
37087  redggu=dble(dggu)
37088  redgtu=dble(dggu*dconjg(dggt))
37089  redgsu=dble(dggu*dconjg(dggs))
37090  redgst=dble(dggs*dconjg(dggt))
37091  redqst=dble(dqqs*dconjg(dqqt))
37092  redqtu=dble(dqqt*dconjg(dqqu))
37093  ENDIF
37094  ENDIF
37095 
37096 
37097 C...Differential cross section expressions.
37098 
37099  IF(isub.LE.190) THEN
37100  IF(isub.EQ.149) THEN
37101 C...g + g -> eta_tc
37102  kctc=pycomp(ktechn+331)
37103  CALL pywidt(ktechn+331,sh,wdtp,wdte)
37104  hs=shr*wdtp(0)
37105  facbw=comfac*0.5d0/((sh-pmas(kctc,1)**2)**2+hs**2)
37106  IF(abs(shr-pmas(kctc,1)).GT.parp(48)*pmas(kctc,2)) facbw=0d0
37107  hp=sh
37108  IF(kfac(1,21)*kfac(2,21).EQ.0) goto 250
37109  hi=hp*wdtp(3)
37110  hf=shr*(wdte(0,1)+wdte(0,2)+wdte(0,4))
37111  nchn=nchn+1
37112  isig(nchn,1)=21
37113  isig(nchn,2)=21
37114  isig(nchn,3)=1
37115  sigh(nchn)=hi*facbw*hf
37116  250 CONTINUE
37117 
37118  ELSEIF(isub.EQ.165) THEN
37119 C...q + qbar -> l+ + l- (including contact term for compositeness)
37120  zratr=xwc*sh*(sh-sqmz)/((sh-sqmz)**2+gmmz**2)
37121  zrati=xwc*sh*gmmz/((sh-sqmz)**2+gmmz**2)
37122  kff=iabs(kfpr(isub,1))
37123  ef=kchg(kff,1)/3d0
37124  af=sign(1d0,ef+0.1d0)
37125  vf=af-4d0*ef*xwv
37126  valf=vf+af
37127  varf=vf-af
37128  fcof=1d0
37129  IF(kff.LE.10) fcof=3d0
37130  wid2=1d0
37131  IF(kff.EQ.6) wid2=wids(6,1)
37132  IF(kff.EQ.7.OR.kff.EQ.8) wid2=wids(kff,1)
37133  IF(kff.EQ.17.OR.kff.EQ.18) wid2=wids(kff,1)
37134  DO 260 i=mmina,mmaxa
37135  IF(i.EQ.0.OR.kfac(1,i)*kfac(2,-i).EQ.0) goto 260
37136  ei=kchg(iabs(i),1)/3d0
37137  ai=sign(1d0,ei+0.1d0)
37138  vi=ai-4d0*ei*xwv
37139  vali=vi+ai
37140  vari=vi-ai
37141  fcoi=1d0
37142  IF(iabs(i).LE.10) fcoi=faca/3d0
37143  IF((itcm(5).EQ.1.AND.iabs(i).LE.2).OR.itcm(5).EQ.2) THEN
37144  fgza=(ei*ef+vali*valf*zratr+rtcm(42)*sh/
37145  & (aem*rtcm(41)**2))**2+(vali*valf*zrati)**2+
37146  & (ei*ef+vari*varf*zratr)**2+(vari*varf*zrati)**2
37147  ELSE
37148  fgza=(ei*ef+vali*valf*zratr)**2+(vali*valf*zrati)**2+
37149  & (ei*ef+vari*varf*zratr)**2+(vari*varf*zrati)**2
37150  ENDIF
37151  fgzb=(ei*ef+vali*varf*zratr)**2+(vali*varf*zrati)**2+
37152  & (ei*ef+vari*valf*zratr)**2+(vari*valf*zrati)**2
37153  fgzab=aem**2*(fgza*uh2/sh2+fgzb*th2/sh2)
37154  IF((itcm(5).EQ.3.AND.iabs(i).EQ.2).OR.(itcm(5).EQ.4.AND.
37155  & mod(iabs(i),2).EQ.0)) fgzab=fgzab+sh2/(2d0*rtcm(41)**4)
37156  nchn=nchn+1
37157  isig(nchn,1)=i
37158  isig(nchn,2)=-i
37159  isig(nchn,3)=1
37160  sigh(nchn)=comfac*fcoi*fcof*fgzab*wid2
37161  260 CONTINUE
37162 
37163  ELSEIF(isub.EQ.166) THEN
37164 C...q + q'bar -> l + nu_l (including contact term for compositeness)
37165  wfac=(1d0/4d0)*(aem/xw)**2*uh2/((sh-sqmw)**2+gmmw**2)
37166  wcifac=wfac+sh2/(4d0*rtcm(41)**4)
37167  kff=iabs(kfpr(isub,1))
37168  fcof=1d0
37169  IF(kff.LE.10) fcof=3d0
37170  DO 280 i=mmin1,mmax1
37171  IF(i.EQ.0.OR.kfac(1,i).EQ.0) goto 280
37172  ia=iabs(i)
37173  DO 270 j=mmin2,mmax2
37174  IF(j.EQ.0.OR.kfac(2,j).EQ.0) goto 270
37175  ja=iabs(j)
37176  IF(i*j.GT.0.OR.mod(ia+ja,2).EQ.0) goto 270
37177  IF((ia.LE.10.AND.ja.GT.10).OR.(ia.GT.10.AND.ja.LE.10))
37178  & goto 270
37179  fcoi=1d0
37180  IF(ia.LE.10) fcoi=vckm((ia+1)/2,(ja+1)/2)*faca/3d0
37181  wid2=1d0
37182  IF((i.GT.0.AND.mod(i,2).EQ.0).OR.(j.GT.0.AND.
37183  & mod(j,2).EQ.0)) THEN
37184  IF(kff.EQ.5) wid2=wids(6,2)
37185  IF(kff.EQ.7) wid2=wids(8,2)*wids(7,3)
37186  IF(kff.EQ.17) wid2=wids(18,2)*wids(17,3)
37187  ELSE
37188  IF(kff.EQ.5) wid2=wids(6,3)
37189  IF(kff.EQ.7) wid2=wids(8,3)*wids(7,2)
37190  IF(kff.EQ.17) wid2=wids(18,3)*wids(17,2)
37191  ENDIF
37192  nchn=nchn+1
37193  isig(nchn,1)=i
37194  isig(nchn,2)=j
37195  isig(nchn,3)=1
37196  sigh(nchn)=comfac*fcoi*fcof*wfac*wid2
37197  IF((itcm(5).EQ.3.AND.ia.LE.2.AND.ja.LE.2).OR.itcm(5).EQ.4)
37198  & sigh(nchn)=comfac*fcoi*fcof*wcifac*wid2
37199  270 CONTINUE
37200  280 CONTINUE
37201  ENDIF
37202 
37203  ELSEIF(isub.LE.200) THEN
37204  IF(isub.EQ.191) THEN
37205 C...q + qbar -> rho_tc0.
37206  kctc=pycomp(ktechn+113)
37207  sqmrht=pmas(kctc,1)**2
37208  CALL pywidt(ktechn+113,sh,wdtp,wdte)
37209  hs=shr*wdtp(0)
37210  facbw=12d0*comfac/((sh-sqmrht)**2+hs**2)
37211  IF(abs(shr-pmas(kctc,1)).GT.parp(48)*pmas(kctc,2)) facbw=0d0
37212  hf=shr*(wdte(0,1)+wdte(0,2)+wdte(0,4))
37213  alprht=2.16d0*(3d0/itcm(1))
37214  hp=(1d0/6d0)*(aem**2/alprht)*(sqmrht**2/sh)
37215  xwrht=(1d0-2d0*xw)/(4d0*xw*(1d0-xw))
37216  bwzr=xwrht*sh*(sh-sqmz)/((sh-sqmz)**2+gmmz**2)
37217  bwzi=xwrht*sh*gmmz/((sh-sqmz)**2+gmmz**2)
37218  DO 290 i=mmina,mmaxa
37219  IF(i.EQ.0.OR.kfac(1,i)*kfac(2,-i).EQ.0) goto 290
37220  ia=iabs(i)
37221  ei=kchg(iabs(i),1)/3d0
37222  ai=sign(1d0,ei+0.1d0)
37223  vi=ai-4d0*ei*xwv
37224  vali=0.5d0*(vi+ai)
37225  vari=0.5d0*(vi-ai)
37226  hi=hp*((ei+vali*bwzr)**2+(vali*bwzi)**2+
37227  & (ei+vari*bwzr)**2+(vari*bwzi)**2)
37228  IF(ia.LE.10) hi=hi*faca/3d0
37229  nchn=nchn+1
37230  isig(nchn,1)=i
37231  isig(nchn,2)=-i
37232  isig(nchn,3)=1
37233  sigh(nchn)=hi*facbw*hf
37234  290 CONTINUE
37235 
37236  ELSEIF(isub.EQ.192) THEN
37237 C...q + qbar' -> rho_tc+/-.
37238  kctc=pycomp(ktechn+213)
37239  sqmrht=pmas(kctc,1)**2
37240  CALL pywidt(ktechn+213,sh,wdtp,wdte)
37241  hs=shr*wdtp(0)
37242  facbw=12d0*comfac/((sh-sqmrht)**2+hs**2)
37243  IF(abs(shr-pmas(kctc,1)).GT.parp(48)*pmas(kctc,2)) facbw=0d0
37244  alprht=2.16d0*(3d0/itcm(1))
37245  hp=(1d0/6d0)*(aem**2/alprht)*(sqmrht**2/sh)*
37246  & (0.25d0/xw**2)*sh**2/((sh-sqmw)**2+gmmw**2)
37247  DO 310 i=mmin1,mmax1
37248  IF(i.EQ.0.OR.kfac(1,i).EQ.0) goto 310
37249  ia=iabs(i)
37250  DO 300 j=mmin2,mmax2
37251  IF(j.EQ.0.OR.kfac(2,j).EQ.0) goto 300
37252  ja=iabs(j)
37253  IF(i*j.GT.0.OR.mod(ia+ja,2).EQ.0) goto 300
37254  IF((ia.LE.10.AND.ja.GT.10).OR.(ia.GT.10.AND.ja.LE.10))
37255  & goto 300
37256  kchr=(kchg(ia,1)*isign(1,i)+kchg(ja,1)*isign(1,j))/3
37257  hf=shr*(wdte(0,1)+wdte(0,(5-kchr)/2)+wdte(0,4))
37258  hi=hp
37259  IF(ia.LE.10) hi=hi*vckm((ia+1)/2,(ja+1)/2)*faca/3d0
37260  nchn=nchn+1
37261  isig(nchn,1)=i
37262  isig(nchn,2)=j
37263  isig(nchn,3)=1
37264  sigh(nchn)=hi*facbw*hf
37265  300 CONTINUE
37266  310 CONTINUE
37267 
37268  ELSEIF(isub.EQ.193) THEN
37269 C...q + qbar -> omega_tc0.
37270  kctc=pycomp(ktechn+223)
37271  sqmomt=pmas(kctc,1)**2
37272  CALL pywidt(ktechn+223,sh,wdtp,wdte)
37273  hs=shr*wdtp(0)
37274  facbw=12d0*comfac/((sh-sqmomt)**2+hs**2)
37275  IF(abs(shr-pmas(kctc,1)).GT.parp(48)*pmas(kctc,2)) facbw=0d0
37276  hf=shr*(wdte(0,1)+wdte(0,2)+wdte(0,4))
37277  alprht=2.16d0*(3d0/itcm(1))
37278  hp=(1d0/6d0)*(aem**2/alprht)*(sqmomt**2/sh)*
37279  & (2d0*rtcm(2)-1d0)**2
37280  bwzr=(0.5d0/(1d0-xw))*sh*(sh-sqmz)/((sh-sqmz)**2+gmmz**2)
37281  bwzi=(0.5d0/(1d0-xw))*sh*gmmz/((sh-sqmz)**2+gmmz**2)
37282  DO 320 i=mmina,mmaxa
37283  IF(i.EQ.0.OR.kfac(1,i)*kfac(2,-i).EQ.0) goto 320
37284  ia=iabs(i)
37285  ei=kchg(iabs(i),1)/3d0
37286  ai=sign(1d0,ei+0.1d0)
37287  vi=ai-4d0*ei*xwv
37288  vali=0.5d0*(vi+ai)
37289  vari=0.5d0*(vi-ai)
37290  hi=hp*((ei-vali*bwzr)**2+(vali*bwzi)**2+
37291  & (ei-vari*bwzr)**2+(vari*bwzi)**2)
37292  IF(ia.LE.10) hi=hi*faca/3d0
37293  nchn=nchn+1
37294  isig(nchn,1)=i
37295  isig(nchn,2)=-i
37296  isig(nchn,3)=1
37297  sigh(nchn)=hi*facbw*hf
37298  320 CONTINUE
37299 
37300  ELSEIF(isub.EQ.194) THEN
37301 C...f + fbar -> f' + fbar' via s-channel rho_tc, omega_tc a_T0.
37302 C...Default final state is e+e-
37303  kfa=kfpr(isubsv,1)
37304  alprht=2.16d0*(3d0/itcm(1))
37305  hp=aem**2*comfac
37306 
37307  sn2w=2d0*sqrt(xw*xw1)
37308 C TANW=SQRT(PARU(102)/(1D0-PARU(102)))
37309 C CT2W=(1D0-2D0*PARU(102))/(2D0*PARU(102)/TANW)
37310 
37311  qupd=2d0*rtcm(2)-1d0
37312  far=sqrt(aem/alprht)
37313  fao=far*qupd
37314  fzr=far*ct2w
37315  fzo=-fao*tanw
37316 C...RTCM(47) is the ratio g_{rho_T}/g_{a_T}
37317  fzx=-far/sn2w*rtcm(47)
37318  sfar=far**2
37319  sfao=fao**2
37320  sfzr=fzr**2
37321  sfzo=fzo**2
37322  sfzx=fzx**2
37323  CALL pywidt(23,sh,wdtp,wdte)
37324  ssmz=dcmplx(1d0-pmas(23,1)**2/sh,wdtp(0)/shr)
37325  CALL pywidt(ktechn+113,sh,wdtp,wdte)
37326  ssmr=dcmplx(1d0-pmas(pycomp(ktechn+113),1)**2/sh,wdtp(0)/shr)
37327  CALL pywidt(ktechn+223,sh,wdtp,wdte)
37328  ssmo=dcmplx(1d0-pmas(pycomp(ktechn+223),1)**2/sh,wdtp(0)/shr)
37329  CALL pywidt(ktechn+115,sh,wdtp,wdte)
37330  ssmx=dcmplx(1d0-pmas(pycomp(ktechn+115),1)**2/sh,wdtp(0)/shr)
37331 C...Propagator including a_T^0
37332  detd=(far*fzo-fao*fzr)**2+ssmz*ssmr*ssmo-sfzr*ssmo-
37333  $ sfzo*ssmr-sfar*ssmo*ssmz-sfao*ssmr*ssmz
37334 C...Add in techni-a contribution
37335  detd=ssmx*detd-sfzx*(ssmr*ssmo-sfao*ssmr-sfar*ssmo)
37336  daa=(-ssmx*(sfzo*ssmr+sfzr*ssmo-ssmo*ssmr*ssmz)-
37337  $ sfzx*ssmr*ssmo)/detd/sh
37338  dzz=-(sfao*ssmr+sfar*ssmo-ssmo*ssmr)/detd/sh*ssmx
37339  daz=(far*fzr*ssmo+fao*fzo*ssmr)/detd/sh*ssmx
37340 
37341  xwrht=1d0/(4d0*xw*(1d0-xw))
37342  kff=iabs(kfpr(isub,1))
37343  ef=kchg(kff,1)/3d0
37344  af=sign(1d0,ef+0.1d0)
37345  vf=af-4d0*ef*xwv
37346  valf=0.5d0*(vf+af)
37347  varf=0.5d0*(vf-af)
37348  fcof=1d0
37349  IF(kff.LE.10) fcof=3d0
37350 
37351  wid2=1d0
37352  IF(kff.GE.6.AND.kff.LE.8) wid2=wids(kff,1)
37353  IF(kff.EQ.17.OR.kff.EQ.18) wid2=wids(kff,1)
37354  dzz=dzz*dcmplx(xwrht,0d0)
37355  daz=daz*dcmplx(sqrt(xwrht),0d0)
37356 
37357  DO 330 i=mmina,mmaxa
37358  IF(i.EQ.0.OR.kfac(1,i)*kfac(2,-i).EQ.0) goto 330
37359  ei=kchg(iabs(i),1)/3d0
37360  ai=sign(1d0,ei+0.1d0)
37361  vi=ai-4d0*ei*xwv
37362  vali=0.5d0*(vi+ai)
37363  vari=0.5d0*(vi-ai)
37364  fcoi=fcof
37365  IF(iabs(i).LE.10) fcoi=fcoi/3d0
37366  difll=abs(ei*ef*daa+vali*valf*dzz+daz*(ei*valf+ef*vali))**2
37367  difrr=abs(ei*ef*daa+vari*varf*dzz+daz*(ei*varf+ef*vari))**2
37368  diflr=abs(ei*ef*daa+vali*varf*dzz+daz*(ei*varf+ef*vali))**2
37369  difrl=abs(ei*ef*daa+vari*valf*dzz+daz*(ei*valf+ef*vari))**2
37370  facsig=(difll+difrr)*((uh-sqm4)**2+sh*sqm4)+
37371  & (diflr+difrl)*((th-sqm3)**2+sh*sqm3)
37372  nchn=nchn+1
37373  isig(nchn,1)=i
37374  isig(nchn,2)=-i
37375  isig(nchn,3)=1
37376  sigh(nchn)=hp*fcoi*facsig*wid2
37377  330 CONTINUE
37378 
37379  ELSEIF(isub.EQ.195) THEN
37380 C...f + fbar' -> f'' + fbar''' via s-channel rho_tc+, a_T+
37381  kfa=kfpr(isubsv,1)
37382  kfb=kfa+1
37383  alprht=2.16d0*(3d0/itcm(1))
37384  factc=comfac*(aem**2/12d0/xw**2)*(uh-sqm3)*(uh-sqm4)*3d0
37385 
37386  fwr=sqrt(aem/alprht)/(2d0*sqrt(xw))
37387 C...RTCM(47) is the ratio g_{rho_T}/g_{a_T}
37388 C
37389 C...Propagator including a_T^+
37390  fwx=-fwr*rtcm(47)
37391  CALL pywidt(24,sh,wdtp,wdte)
37392  ssmz=dcmplx(1d0-pmas(24,1)**2/sh,wdtp(0)/shr)
37393  CALL pywidt(ktechn+213,sh,wdtp,wdte)
37394  ssmr=dcmplx(1d0-pmas(pycomp(ktechn+213),1)**2/sh,wdtp(0)/shr)
37395  CALL pywidt(ktechn+215,sh,wdtp,wdte)
37396  ssmx=dcmplx(1d0-pmas(pycomp(ktechn+215),1)**2/sh,wdtp(0)/shr)
37397  detd=ssmx*(ssmz*ssmr-dcmplx(fwr**2,0d0))-
37398  & dcmplx(fwx**2,0d0)*ssmr
37399  dww=ssmr*ssmx/detd/sh
37400  fcof=1d0
37401  IF(kfa.LE.8) fcof=3d0
37402  hp=factc*abs(dww)**2*fcof
37403 
37404  DO 350 i=mmin1,mmax1
37405  IF(i.EQ.0.OR.kfac(1,i).EQ.0) goto 350
37406  ia=iabs(i)
37407  DO 340 j=mmin2,mmax2
37408  IF(j.EQ.0.OR.kfac(2,j).EQ.0) goto 340
37409  ja=iabs(j)
37410  IF(i*j.GT.0.OR.mod(ia+ja,2).EQ.0) goto 340
37411  IF((ia.LE.10.AND.ja.GT.10).OR.(ia.GT.10.AND.ja.LE.10))
37412  & goto 340
37413  kchr=(kchg(ia,1)*isign(1,i)+kchg(ja,1)*isign(1,j))/3
37414  hi=hp
37415  IF(ia.LE.10) hi=hi*vckm((ia+1)/2,(ja+1)/2)/3d0
37416  nchn=nchn+1
37417  isig(nchn,1)=i
37418  isig(nchn,2)=j
37419  isig(nchn,3)=1
37420  sigh(nchn)=hi*wids(kfa,(5-kchr)/2)*wids(kfb,(5+kchr)/2)
37421  340 CONTINUE
37422  350 CONTINUE
37423  ENDIF
37424 
37425  ELSEIF(isub.LE.380) THEN
37426  alprht=2.16d0*(3d0/itcm(1))
37427  IF(isub.EQ.361) THEN
37428  far=sqrt(aem/alprht)
37429  fao=far*qupd
37430  fzr=far*ct2w
37431  fzo=-fao*tanw
37432 C...RTCM(47) is the ratio g_{rho_T}/g_{a_T}
37433  fzx=-far/sn2w*rtcm(47)
37434  sfar=far**2
37435  sfao=fao**2
37436  sfzr=fzr**2
37437  sfzo=fzo**2
37438  sfzx=fzx**2
37439  CALL pywidt(23,sh,wdtp,wdte)
37440  ssmz=dcmplx(1d0-pmas(23,1)**2/sh,wdtp(0)/shr)
37441  CALL pywidt(ktechn+113,sh,wdtp,wdte)
37442  ssmr=dcmplx(1d0-pmas(pycomp(ktechn+113),1)**2/sh,wdtp(0)/shr)
37443  CALL pywidt(ktechn+223,sh,wdtp,wdte)
37444  ssmo=dcmplx(1d0-pmas(pycomp(ktechn+223),1)**2/sh,wdtp(0)/shr)
37445  CALL pywidt(ktechn+115,sh,wdtp,wdte)
37446  ssmx=dcmplx(1d0-pmas(pycomp(ktechn+115),1)**2/sh,wdtp(0)/shr)
37447  detd=(far*fzo-fao*fzr)**2+ssmz*ssmr*ssmo-sfzr*ssmo-
37448  $ sfzo*ssmr-sfar*ssmo*ssmz-sfao*ssmr*ssmz
37449 C...Add in techni-a contribution
37450  detd=ssmx*detd-sfzx*(ssmr*ssmo-sfao*ssmr-sfar*ssmo)
37451  darho=-(ssmx*(-far*sfzo+fao*fzo*fzr+far*ssmo*ssmz)-
37452  $ sfzx*far*ssmo)/detd/sh
37453  dzrho=-(-fzr*sfao+fao*fzo*far+fzr*ssmo)/detd/sh*ssmx
37454  daome=-(ssmx*(-fao*sfzr+far*fzo*fzr+fao*ssmr*ssmz)-
37455  $ sfzx*fao*ssmr)/detd/sh
37456  dzome=-(-fzo*sfar+far*fao*fzr+fzo*ssmr)/detd/sh*ssmx
37457  daast=-fzx*(fao*fzo*ssmr+far*fzr*ssmo)/detd/sh
37458  dzast=-fzx*(ssmr*ssmo-sfao*ssmr-sfar*ssmo)/detd/sh
37459  daa=(-ssmx*(sfzo*ssmr+sfzr*ssmo-ssmo*ssmr*ssmz)-
37460  $ sfzx*ssmr*ssmo)/detd/sh
37461  dzz=-(sfao*ssmr+sfar*ssmo-ssmo*ssmr)/detd/sh*ssmx
37462  daz=(far*fzr*ssmo+fao*fzo*ssmr)/detd/sh*ssmx
37463 
37464 C...f + fbar -> gamma pi_tc, gamma pi_tc', Z pi_tc, Z pi_tc',
37465 C...W+W-, W pi_tc, pi_T pi_T, etc.
37466  faca=(sh**2*be34**2-(th-uh)**2)
37467  vfac=(th**2+uh**2-2d0*sqm3*sqm4)
37468  afac=(th**2+uh**2-2d0*sqm3*sqm4+4d0*sh*sqm3)
37469  fanom=sqrt(paru(1)*aem)*itcm(1)/paru(2)**2/rtcm(1)
37470  hp=(1d0/24d0)*aem**2*comfac*3d0*sh
37471  DO 370 i=mmina,mmaxa
37472  IF(i.EQ.0.OR.kfac(1,i)*kfac(2,-i).EQ.0) goto 370
37473  ia=iabs(i)
37474  ei=kchg(iabs(i),1)/3d0
37475  ai=sign(1d0,ei+0.1d0)
37476  vi=ai-4d0*ei*xwv
37477  vali=0.25d0*(vi+ai) ! = \zeta_{iL} in PRD67-115011
37478  vari=0.25d0*(vi-ai) ! = \zeta_{iR} in PRD67-115011
37479 C...........Eqs. (5) and (6) in LSTC-rates.pdf
37480  f2l=(ei*darho+vali*dzrho/sqrt(xw*xw1))*vrgp
37481  f2l=f2l+(ei*daome+vali*dzome/sqrt(xw*xw1))*vogp
37482  f2l=f2l+(ei*daast+vali*dzast/sqrt(xw*xw1))*vxgp
37483  f2l=f2l+fanom*(vagp*(ei*daa+vali*daz/sqrt(xw*xw1))+
37484  $ vzgp*(ei*daz+vali*dzz/sqrt(xw*xw1)))
37485  f2r=(ei*darho+vari*dzrho/sqrt(xw*xw1))*vrgp
37486  f2r=f2r+(ei*daome+vari*dzome/sqrt(xw*xw1))*vogp
37487  f2r=f2r+(ei*daast+vari*dzast/sqrt(xw*xw1))*vxgp
37488  f2r=f2r+fanom*(vagp*(ei*daa+vari*daz/sqrt(xw*xw1))+
37489  $ vzgp*(ei*daz+vari*dzz/sqrt(xw*xw1)))
37490  hi=(abs(f2l)**2+abs(f2r)**2)*vfac
37491 C...........Eqs. (5) and (7) in LSTC-rates.pdf
37492  f2l=(ei*darho+vali*dzrho/sqrt(xw*xw1))*argp
37493  f2l=f2l+(ei*daome+vali*dzome/sqrt(xw*xw1))*aogp
37494  f2l=f2l+(ei*daast+vali*dzast/sqrt(xw*xw1))*axgp
37495  f2r=(ei*darho+vari*dzrho/sqrt(xw*xw1))*argp
37496  f2r=f2r+(ei*daome+vari*dzome/sqrt(xw*xw1))*aogp
37497  f2r=f2r+(ei*daast+vari*dzast/sqrt(xw*xw1))*axgp
37498  hj=(abs(f2l)**2+abs(f2r)**2)*afac
37499 C
37500 C...........Eqs. (24) in PRD67-115011 with DAA, etc.terms dropped.
37501 C
37502 c$$$ F2L=EI*(DARHO/FAR+(DAA+CT2W*DAZ))+
37503 c$$$ $ VALI*(CT2W*DZRHO/FZR+(CT2W*DZZ+DAZ))/SQRT(XW*XW1)
37504 c$$$ F2R=EI*(DARHO/FAR+(DAA+CT2W*DAZ))+
37505 c$$$ $ VARI*(CT2W*DZRHO/FZR+(CT2W*DZZ+DAZ))/SQRT(XW*XW1)
37506  f2l=ei*darho/far + vali*ct2w*dzrho/fzr/sqrt(xw*xw1)
37507  f2r=ei*darho/far + vari*ct2w*dzrho/fzr/sqrt(xw*xw1)
37508  hk=(abs(f2l)**2+abs(f2r)**2)*2d0*faca*cab2/sh
37509  hi=hi+hj+hk
37510  IF(ia.LE.10) hi=hi/3d0
37511  nchn=nchn+1
37512  isig(nchn,1)=i
37513  isig(nchn,2)=-i
37514  isig(nchn,3)=1
37515  IF(kfa.EQ.kfb) THEN
37516  sigh(nchn)=hi*hp*wids(pycomp(kfa),1)
37517  ELSEIF(isubsv.EQ.362.OR.isubsv.EQ.368) THEN
37518  sigh(nchn)=hi*hp*wids(pycomp(kfa),2)*wids(pycomp(kfb),3)
37519  nchn=nchn+1
37520  isig(nchn,1)=i
37521  isig(nchn,2)=-i
37522  isig(nchn,3)=2
37523  sigh(nchn)=hi*hp*wids(pycomp(kfa),3)*wids(pycomp(kfb),2)
37524  ELSE
37525  sigh(nchn)=hi*hp*wids(pycomp(kfa),2)*wids(pycomp(kfb),2)
37526  ENDIF
37527  370 CONTINUE
37528 
37529  ELSEIF(isub.EQ.370) THEN
37530 C...f + fbar' -> W_L Z_L, W_L Z_T, W_T, Z_L, W_L pi_tc, Z_L pi_tc, pi_tc pi_tc
37531 C...f + fbar' -> gamma pi_tc, etc.
37532  faca=(sh**2*be34**2-(th-uh)**2)
37533  fanom=sqrt(paru(1)*aem)*itcm(1)/paru(2)**2/rtcm(1)
37534  vfac=(th**2+uh**2-2d0*sqm3*sqm4)
37535  afac=(th**2+uh**2-2d0*sqm3*sqm4+4d0*sh*sqm3)
37536  alprht=2.16d0*(3d0/itcm(1))
37537  fachp=(1d0/48d0)*aem**2/xw*comfac*3d0*sh
37538  fwr=sqrt(aem/alprht)/(2d0*sqrt(xw))
37539 C...RTCM(47) is the ratio g_{rho_T}/g_{a_T}
37540  fwx=-fwr*rtcm(47)
37541  CALL pywidt(24,sh,wdtp,wdte)
37542  ssmz=dcmplx(1d0-pmas(24,1)**2/sh,wdtp(0)/shr)
37543  CALL pywidt(ktechn+213,sh,wdtp,wdte)
37544  ssmr=dcmplx(1d0-pmas(pycomp(ktechn+213),1)**2/sh,wdtp(0)/shr)
37545  CALL pywidt(ktechn+215,sh,wdtp,wdte)
37546  ssmx=dcmplx(1d0-pmas(pycomp(ktechn+215),1)**2/sh,wdtp(0)/shr)
37547  detd=ssmx*(ssmz*ssmr-dcmplx(fwr**2,0d0))-
37548  & dcmplx(fwx**2,0d0)*ssmr
37549  dww=ssmr*ssmx/detd/sh
37550  dwrho=-dcmplx(fwr,0d0)*ssmx/detd/sh
37551  dwast=-dcmplx(fwx,0d0)*ssmr/detd/sh
37552  hp=fachp*(afac*abs(dwrho*argp+dwast*axgp)**2+
37553  $ vfac*abs(fanom*dww*vwgp+dwrho*vrgp+dwast*vxgp)**2)
37554 C
37555 C...........Eq. (25) in PRD67-115011 with DWW term dropped.
37556 C
37557 c$$$ HP=HP+.5D0*FACHP*CAB2*FACA/XW/SH*ABS(DWW + DWRHO/FWR)**2
37558  hp=hp+.5d0*fachp*cab2*faca/xw/sh*abs(dwrho/fwr)**2
37559 C...Add in W_L Z_T axial and vector contributions.
37560  IF(isubsv.EQ.370) hp=hp+fachp*rtcm(3)**2*(
37561  $ (th**2+uh**2-2d0*sqm3*sqm4+4d0*sh*sqm4)* !AFAC w/ switched masses.
37562  $ abs(dwrho/rtcm(13)-dwast/rtcm(49)*cs2w)**2/sn2w**2+
37563  $ vfac*qupd**2*xw/xw1*abs(dwrho)**2/rtcm(12)**2)
37564  DO 410 i=mmin1,mmax1
37565  IF(i.EQ.0.OR.kfac(1,i).EQ.0) goto 410
37566  ia=iabs(i)
37567  DO 400 j=mmin2,mmax2
37568  IF(j.EQ.0.OR.kfac(2,j).EQ.0) goto 400
37569  ja=iabs(j)
37570  IF(i*j.GT.0.OR.mod(ia+ja,2).EQ.0) goto 400
37571  IF((ia.LE.10.AND.ja.GT.10).OR.(ia.GT.10.AND.ja.LE.10))
37572  & goto 400
37573  kchr=(kchg(ia,1)*isign(1,i)+kchg(ja,1)*isign(1,j))/3
37574  hi=hp
37575  IF(ia.LE.10) hi=hi*vckm((ia+1)/2,(ja+1)/2)/3d0
37576  nchn=nchn+1
37577  isig(nchn,1)=i
37578  isig(nchn,2)=j
37579  isig(nchn,3)=1
37580  IF(isubsv.EQ.374.OR.isubsv.EQ.378) THEN
37581  sigh(nchn)=hi*wids(pycomp(kfa),(5-kchr)/2)
37582  ELSE
37583  sigh(nchn)=hi*wids(pycomp(kfa),(5-kchr)/2)*
37584  & wids(pycomp(kfb),2)
37585  ENDIF
37586  400 CONTINUE
37587  410 CONTINUE
37588  ENDIF
37589 
37590  ELSEIF(isub.LE.390) THEN
37591  IF(isub.EQ.381) THEN
37592 C...f + f' -> f + f' (g exchange)
37593  facqq1=comfac*as**2*4d0/9d0*(sh2+uh2)*sqdqqt
37594  facqqb=comfac*as**2*4d0/9d0*((sh2+uh2)*sqdqqt*faca-
37595  & mstp(34)*2d0/3d0*uh2*redqst)
37596  facqq2=comfac*as**2*4d0/9d0*(sh2+th2)*sqdqqu
37597  facqqi=-comfac*as**2*4d0/9d0*mstp(34)*2d0/3d0*sh2/(th*uh)
37598  ratqqi=(facqq1+facqq2+facqqi)/(facqq1+facqq2)
37599  IF(itcm(5).GE.1.AND.itcm(5).LE.4) THEN
37600 C...Modifications from contact interactions (compositeness)
37601  facci1=facqq1+comfac*(sh2/rtcm(41)**4)
37602  faccib=facqqb+comfac*(8d0/9d0)*(as*rtcm(42)/rtcm(41)**2)*
37603  & (uh2/th+uh2/sh)+comfac*(5d0/3d0)*(uh2/rtcm(41)**4)
37604  facci2=facqq2+comfac*(8d0/9d0)*(as*rtcm(42)/rtcm(41)**2)*
37605  & (sh2/th+sh2/uh)+comfac*(5d0/3d0)*(sh2/rtcm(41)**4)
37606  facci3=facqq1+comfac*(uh2/rtcm(41)**4)
37607  ratcii=(facci1+facci2+facqqi)/(facci1+facci2)
37608  ELSEIF(itcm(5).EQ.5) THEN
37609  facci1=facqq1
37610  faccib=facqqb
37611  facci2=facqq2
37612  facci3=facqq1
37613 CSM.......Check this change from
37614 CSM RATCII=1D0
37615  ratcii=ratqqi
37616  ENDIF
37617  DO 430 i=mmin1,mmax1
37618  ia=iabs(i)
37619  IF(i.EQ.0.OR.ia.GT.mstp(58).OR.kfac(1,i).EQ.0) goto 430
37620  DO 420 j=mmin2,mmax2
37621  ja=iabs(j)
37622  IF(j.EQ.0.OR.ja.GT.mstp(58).OR.kfac(2,j).EQ.0) goto 420
37623  nchn=nchn+1
37624  isig(nchn,1)=i
37625  isig(nchn,2)=j
37626  isig(nchn,3)=1
37627  IF(itcm(5).LE.0.OR.(itcm(5).EQ.1.AND.(ia.GE.3.OR.
37628  & ja.GE.3))) THEN
37629  sigh(nchn)=facqq1
37630  IF(i.EQ.-j) sigh(nchn)=facqqb
37631  ELSE
37632  sigh(nchn)=facci1
37633  IF(i*j.LT.0) sigh(nchn)=facci3
37634  IF(i.EQ.-j) sigh(nchn)=faccib
37635  ENDIF
37636  IF(i.EQ.j) THEN
37637  nchn=nchn+1
37638  isig(nchn,1)=i
37639  isig(nchn,2)=j
37640  isig(nchn,3)=2
37641  IF(itcm(5).LE.0.OR.(itcm(5).EQ.1.AND.ia.GE.3)) THEN
37642  sigh(nchn-1)=0.5d0*facqq1*ratqqi
37643  sigh(nchn)=0.5d0*facqq2*ratqqi
37644  ELSE
37645  sigh(nchn-1)=0.5d0*facci1*ratcii
37646  sigh(nchn)=0.5d0*facci2*ratcii
37647  ENDIF
37648  ENDIF
37649  420 CONTINUE
37650  430 CONTINUE
37651 
37652  ELSEIF(isub.EQ.382) THEN
37653 C...f + fbar -> f' + fbar' (q + qbar -> q' + qbar' only)
37654  CALL pywidt(21,sh,wdtp,wdte)
37655  facqqf=comfac*as**2*4d0/9d0*(th2+uh2)
37656  facqqb=facqqf*sqdqqs*(wdte(0,1)+wdte(0,2)+wdte(0,4))
37657  IF(itcm(5).EQ.1) THEN
37658 C...Modifications from contact interactions (compositeness)
37659  faccib=facqqb
37660  DO 440 i=1,2
37661  faccib=faccib+comfac*(uh2/rtcm(41)**4)*(wdte(i,1)+
37662  & wdte(i,2)+wdte(i,4))
37663  440 CONTINUE
37664  ELSEIF(itcm(5).GE.2.AND.itcm(5).LE.4) THEN
37665  faccib=facqqb+comfac*(uh2/rtcm(41)**4)*
37666  & (wdte(0,1)+wdte(0,2)+wdte(0,4))
37667  ELSEIF(itcm(5).EQ.5) THEN
37668  facqqb=facqqf*sqdqqs*(wdte(0,1)+wdte(0,2)+wdte(0,4)-
37669  & wdte(5,1)-wdte(5,2)-wdte(5,4))
37670  faccib=facqqf*sqdqts*(wdte(5,1)+wdte(5,2)+wdte(5,4))
37671  ENDIF
37672  DO 450 i=mmina,mmaxa
37673  IF(i.EQ.0.OR.iabs(i).GT.mstp(58).OR.
37674  & kfac(1,i)*kfac(2,-i).EQ.0) goto 450
37675  nchn=nchn+1
37676  isig(nchn,1)=i
37677  isig(nchn,2)=-i
37678  isig(nchn,3)=1
37679  IF(itcm(5).LE.0.OR.(itcm(5).EQ.1.AND.iabs(i).GE.3)) THEN
37680  sigh(nchn)=facqqb
37681  ELSEIF(itcm(5).EQ.5) THEN
37682  sigh(nchn)=facqqb
37683  nchn=nchn+1
37684  isig(nchn,1)=i
37685  isig(nchn,2)=-i
37686  isig(nchn,3)=2
37687  sigh(nchn)=faccib
37688  ELSE
37689  sigh(nchn)=faccib
37690  ENDIF
37691  450 CONTINUE
37692 
37693  ELSEIF(isub.EQ.383) THEN
37694 C...f + fbar -> g + g (q + qbar -> g + g only)
37695  facgg1=comfac*as**2*32d0/27d0*(uh/th-(2d0+mstp(34)*1d0/4d0)*
37696  & uh2/sh2+9d0/4d0*th*uh/sh2*sqdlgs)
37697  facgg2=comfac*as**2*32d0/27d0*(th/uh-(2d0+mstp(34)*1d0/4d0)*
37698  & th2/sh2+9d0/4d0*th*uh/sh2*sqdlgs)
37699  IF(itcm(5).EQ.5) THEN
37700  facgg3=comfac*as**2*32d0/27d0*(uh/th-(2d0+mstp(34)*1d0/4d0)*
37701  & uh2/sh2+9d0/4d0*th*uh/sh2*sqdhgs)
37702  facgg4=comfac*as**2*32d0/27d0*(th/uh-(2d0+mstp(34)*1d0/4d0)*
37703  & th2/sh2+9d0/4d0*th*uh/sh2*sqdhgs)
37704  ENDIF
37705  DO 460 i=mmina,mmaxa
37706  IF(i.EQ.0.OR.iabs(i).GT.mstp(58).OR.
37707  & kfac(1,i)*kfac(2,-i).EQ.0) goto 460
37708  nchn=nchn+1
37709  isig(nchn,1)=i
37710  isig(nchn,2)=-i
37711  isig(nchn,3)=1
37712  sigh(nchn)=0.5d0*facgg1
37713  IF(itcm(5).EQ.5.AND.iabs(i).EQ.5) sigh(nchn)=0.5d0*facgg3
37714  nchn=nchn+1
37715  isig(nchn,1)=i
37716  isig(nchn,2)=-i
37717  isig(nchn,3)=2
37718  sigh(nchn)=0.5d0*facgg2
37719  IF(itcm(5).EQ.5.AND.iabs(i).EQ.5) sigh(nchn)=0.5d0*facgg4
37720  460 CONTINUE
37721 
37722  ELSEIF(isub.EQ.384) THEN
37723 C...f + g -> f + g (q + g -> q + g only)
37724  facqg1=comfac*as**2*4d0/9d0*((2d0+mstp(34)*1d0/4d0)*uh2/th2-
37725  & uh/sh-9d0/4d0*sh*uh/th2*sqdlgt)*faca
37726  facqg2=comfac*as**2*4d0/9d0*((2d0+mstp(34)*1d0/4d0)*sh2/th2-
37727  & sh/uh-9d0/4d0*sh*uh/th2*sqdlgt)
37728  DO 480 i=mmina,mmaxa
37729  IF(i.EQ.0.OR.iabs(i).GT.10) goto 480
37730  DO 470 isde=1,2
37731  IF(isde.EQ.1.AND.kfac(1,i)*kfac(2,21).EQ.0) goto 470
37732  IF(isde.EQ.2.AND.kfac(1,21)*kfac(2,i).EQ.0) goto 470
37733  nchn=nchn+1
37734  isig(nchn,isde)=i
37735  isig(nchn,3-isde)=21
37736  isig(nchn,3)=1
37737  sigh(nchn)=facqg1
37738  nchn=nchn+1
37739  isig(nchn,isde)=i
37740  isig(nchn,3-isde)=21
37741  isig(nchn,3)=2
37742  sigh(nchn)=facqg2
37743  470 CONTINUE
37744  480 CONTINUE
37745 
37746  ELSEIF(isub.EQ.385) THEN
37747 C...g + g -> f + fbar (g + g -> q + qbar only)
37748  IF(kfac(1,21)*kfac(2,21).EQ.0) goto 500
37749  idc0=mdcy(21,2)-1
37750 C...Begin by d, u, s flavours.
37751  flavwt=0d0
37752  IF(mdme(idc0+1,1).GE.1) flavwt=flavwt+
37753  & sqrt(max(0d0,1d0-4d0*pmas(1,1)**2/sh))
37754  IF(mdme(idc0+2,1).GE.1) flavwt=flavwt+
37755  & sqrt(max(0d0,1d0-4d0*pmas(2,1)**2/sh))
37756  IF(mdme(idc0+3,1).GE.1) flavwt=flavwt+
37757  & sqrt(max(0d0,1d0-4d0*pmas(3,1)**2/sh))
37758  facqq1=comfac*as**2*1d0/6d0*(uh/th-(2d0+mstp(34)*1d0/4d0)*
37759  & uh2/sh2+9d0/4d0*th*uh/sh2*sqdlgs)*flavwt*faca
37760  facqq2=comfac*as**2*1d0/6d0*(th/uh-(2d0+mstp(34)*1d0/4d0)*
37761  & th2/sh2+9d0/4d0*th*uh/sh2*sqdlgs)*flavwt*faca
37762  nchn=nchn+1
37763  isig(nchn,1)=21
37764  isig(nchn,2)=21
37765  isig(nchn,3)=1
37766  sigh(nchn)=facqq1
37767  nchn=nchn+1
37768  isig(nchn,1)=21
37769  isig(nchn,2)=21
37770  isig(nchn,3)=2
37771  sigh(nchn)=facqq2
37772 C...Next c and b flavours: modified that and uhat for fixed
37773 C...cos(theta-hat).
37774  DO 490 ifl=4,5
37775  sqmavg=pmas(ifl,1)**2
37776  IF(mdme(idc0+ifl,1).GE.1.AND.sh.GT.4.04d0*sqmavg) THEN
37777  be34=sqrt(1d0-4d0*sqmavg/sh)
37778  thq=-0.5d0*sh*(1d0-be34*cth)
37779  uhq=-0.5d0*sh*(1d0+be34*cth)
37780  thuhq=thq*uhq-sqmavg*sh
37781  IF(mstp(34).EQ.0) THEN
37782  facqq1=uhq/thq-2d0*uhq**2/sh2+4d0*(sqmavg/sh)*thuhq/thq**2
37783  facqq2=thq/uhq-2d0*thq**2/sh2+4d0*(sqmavg/sh)*thuhq/uhq**2
37784  ELSE
37785  facqq1=uhq/thq-2.25d0*uhq**2/sh2+4.5d0*(sqmavg/sh)*thuhq/
37786  & thq**2+0.5d0*sqmavg*(thq+sqmavg)/thq**2-sqmavg**2/(sh*thq)
37787  facqq2=thq/uhq-2.25d0*thq**2/sh2+4.5d0*(sqmavg/sh)*thuhq/
37788  & uhq**2+0.5d0*sqmavg*(uhq+sqmavg)/uhq**2-sqmavg**2/(sh*uhq)
37789  ENDIF
37790  IF(itcm(5).GE.5) THEN
37791  IF(ifl.EQ.4) THEN
37792  facqq1=facqq1+2.25d0*sqmavg*(thq-uhq)/(sh*thq)*redlgs+
37793  & 2.25d0*thq*uhq/sh2*sqdlgs
37794  facqq2=facqq2+2.25d0*sqmavg*(uhq-thq)/(sh*uhq)*redlgs+
37795  & 2.25d0*thq*uhq/sh2*sqdlgs
37796  ELSE
37797  facqq1=facqq1+2.25d0*sqmavg*(thq-uhq)/(sh*thq)*redhgs+
37798  & 2.25d0*thq*uhq/sh2*sqdhgs
37799  facqq2=facqq2+2.25d0*sqmavg*(uhq-thq)/(sh*uhq)*redhgs+
37800  & 2.25d0*thq*uhq/sh2*sqdhgs
37801  ENDIF
37802  ENDIF
37803  facqq1=comfac*faca*as**2*(1d0/6d0)*facqq1*be34
37804  facqq2=comfac*faca*as**2*(1d0/6d0)*facqq2*be34
37805  nchn=nchn+1
37806  isig(nchn,1)=21
37807  isig(nchn,2)=21
37808  isig(nchn,3)=1+2*(ifl-3)
37809  sigh(nchn)=facqq1
37810  nchn=nchn+1
37811  isig(nchn,1)=21
37812  isig(nchn,2)=21
37813  isig(nchn,3)=2+2*(ifl-3)
37814  sigh(nchn)=facqq2
37815  ENDIF
37816  490 CONTINUE
37817  500 CONTINUE
37818 
37819  ELSEIF(isub.EQ.386) THEN
37820 C...g + g -> g + g
37821  IF(itcm(5).LE.4) THEN
37822  facgg1=comfac*as**2*9d0/4d0*(sh2/th2+2d0*sh/th+3d0+
37823  & 2d0*th/sh+th2/sh2)*faca
37824  facgg2=comfac*as**2*9d0/4d0*(uh2/sh2+2d0*uh/sh+3d0+
37825  & 2d0*sh/uh+sh2/uh2)*faca
37826  facgg3=comfac*as**2*9d0/4d0*(th2/uh2+2d0*th/uh+3d0+
37827  & 2d0*uh/th+uh2/th2)
37828  ELSE
37829  gst= (12d0 + 40d0*th/sh + 56d0*th2/sh2 + 32d0*th**3/sh**3 +
37830  & 16d0*th**4/sh**4 + sqdggs*(4d0*sh2 + 16d0*sh*th + 16d0*th2)+
37831  & 4d0*redgst*(sh + 2d0*th)*
37832  & (2d0*sh**3 - 3d0*sh2*th - 2d0*sh*th2 + 2d0*th**3)/sh2 +
37833  & 2d0*redggs*(2d0*sh - 12d0*th2/sh - 8d0*th**3/sh2) +
37834  & 2d0*redggt*(4d0*sh - 22d0*th - 68d0*th2/sh - 60d0*th**3/sh2-
37835  & 32d0*th**4/sh**3 - 16d0*th**5/sh**4) +
37836  & sqdggt*(16d0*sh2 + 16d0*sh*th + 68d0*th2 + 144d0*th**3/sh +
37837  & 96d0*th**4/sh2 + 32d0*th**5/sh**3 + 16d0*th**6/sh**4))/16d0
37838  gsu= (12d0 + 40d0*uh/sh + 56d0*uh2/sh2 + 32d0*uh**3/sh**3 +
37839  & 16d0*uh**4/sh**4 + sqdggs*(4d0*sh2 + 16d0*sh*uh + 16d0*uh2)+
37840  & 4d0*redgsu*(sh + 2d0*uh)*
37841  & (2d0*sh**3 - 3d0*sh2*uh - 2d0*sh*uh2 + 2d0*uh**3)/sh2 +
37842  & 2d0*redggs*(2d0*sh - 12d0*uh2/sh - 8d0*uh**3/sh2) +
37843  & 2d0*redggu*(4d0*sh - 22d0*uh - 68d0*uh2/sh - 60d0*uh**3/sh2-
37844  & 32d0*uh**4/sh**3 - 16d0*uh**5/sh**4) +
37845  & sqdggu*(16d0*sh2 + 16d0*sh*uh + 68d0*uh2 + 144d0*uh**3/sh +
37846  & 96d0*uh**4/sh2 + 32d0*uh**5/sh**3 + 16d0*uh**6/sh**4))/16d0
37847  gut= (12d0 - 16d0*th*(th - uh)**2*uh/sh**4 +
37848  & 4d0*redggu*(2d0*th**5 - 15d0*th**4*uh - 48d0*th**3*uh2 -
37849  & 58d0*th2*uh**3 - 10d0*th*uh**4 + uh**5)/sh**4 +
37850  & 4d0*redggt*(th**5 - 10d0*th**4*uh - 58d0*th**3*uh2 -
37851  & 48d0*th2*uh**3 - 15d0*th*uh**4 + 2d0*uh**5)/sh**4 +
37852  & 4d0*sqdggu*(4d0*th**6 + 20d0*th**5*uh + 57d0*th**4*uh2 +
37853  & 72d0*th**3*uh**3+ 38d0*th2*uh**4+4d0*th*uh**5 +uh**6)/sh**4+
37854  & 4d0*sqdggt*(4d0*uh**6 + 4d0*th**5*uh + 38d0*th**4*uh2 +
37855  & 72d0*th**3*uh**3 +57d0*th2*uh**4+20d0*th*uh**5+th**6)/sh**4+
37856  & 2d0*redgtu*((th - uh)**2* (th**4 + 20d0*th**3*uh +
37857  & 30d0*th2*uh2 + 20d0*th*uh**3 + uh**4) +
37858  & sh2*(7d0*th**4 + 52d0*th**3*uh + 274d0*th2*uh2 +
37859  & 52d0*th*uh**3 + 7d0*uh**4))/(2d0*sh**4))/16d0
37860  facgg1=comfac*as**2*9d0/4d0*gst*faca
37861  facgg2=comfac*as**2*9d0/4d0*gsu*faca
37862  facgg3=comfac*as**2*9d0/4d0*gut
37863  ENDIF
37864  IF(kfac(1,21)*kfac(2,21).EQ.0) goto 510
37865  nchn=nchn+1
37866  isig(nchn,1)=21
37867  isig(nchn,2)=21
37868  isig(nchn,3)=1
37869  sigh(nchn)=0.5d0*facgg1
37870  nchn=nchn+1
37871  isig(nchn,1)=21
37872  isig(nchn,2)=21
37873  isig(nchn,3)=2
37874  sigh(nchn)=0.5d0*facgg2
37875  nchn=nchn+1
37876  isig(nchn,1)=21
37877  isig(nchn,2)=21
37878  isig(nchn,3)=3
37879  sigh(nchn)=0.5d0*facgg3
37880  510 CONTINUE
37881 
37882  ELSEIF(isub.EQ.387) THEN
37883 C...q + qbar -> Q + Qbar
37884  sqmavg=0.5d0*(sqm3+sqm4)-0.25d0*(sqm3-sqm4)**2/sh
37885  thq=-0.5d0*sh*(1d0-be34*cth)
37886  uhq=-0.5d0*sh*(1d0+be34*cth)
37887  facqqb=comfac*as**2*4d0/9d0*((thq**2+uhq**2)/sh2+
37888  & 2d0*sqmavg/sh)
37889  IF(itcm(5).GE.5) THEN
37890  IF(mint(55).EQ.5.OR.mint(55).EQ.6) THEN
37891  facqqb=facqqb*sh2*sqdqts
37892  ELSE
37893  facqqb=facqqb*sh2*sqdqqs
37894  ENDIF
37895  ENDIF
37896  IF(mstp(35).GE.1) facqqb=facqqb*pyhfth(sh,sqmavg,0d0)
37897  wid2=1d0
37898  IF(mint(55).EQ.6) wid2=wids(6,1)
37899  IF(mint(55).EQ.7.OR.mint(55).EQ.8) wid2=wids(mint(55),1)
37900  facqqb=facqqb*wid2
37901  DO 520 i=mmina,mmaxa
37902  IF(i.EQ.0.OR.iabs(i).GT.mstp(58).OR.
37903  & kfac(1,i)*kfac(2,-i).EQ.0) goto 520
37904  nchn=nchn+1
37905  isig(nchn,1)=i
37906  isig(nchn,2)=-i
37907  isig(nchn,3)=1
37908  sigh(nchn)=facqqb
37909  520 CONTINUE
37910 
37911  ELSEIF(isub.EQ.388) THEN
37912 C...g + g -> Q + Qbar
37913  sqmavg=0.5d0*(sqm3+sqm4)-0.25d0*(sqm3-sqm4)**2/sh
37914  thq=-0.5d0*sh*(1d0-be34*cth)
37915  uhq=-0.5d0*sh*(1d0+be34*cth)
37916  thuhq=thq*uhq-sqmavg*sh
37917  IF(mstp(34).EQ.0) THEN
37918  facqq1=uhq/thq-2d0*uhq**2/sh2+4d0*(sqmavg/sh)*thuhq/thq**2
37919  facqq2=thq/uhq-2d0*thq**2/sh2+4d0*(sqmavg/sh)*thuhq/uhq**2
37920  ELSE
37921  facqq1=uhq/thq-2.25d0*uhq**2/sh2+4.5d0*(sqmavg/sh)*thuhq/
37922  & thq**2+0.5d0*sqmavg*(thq+sqmavg)/thq**2-sqmavg**2/(sh*thq)
37923  facqq2=thq/uhq-2.25d0*thq**2/sh2+4.5d0*(sqmavg/sh)*thuhq/
37924  & uhq**2+0.5d0*sqmavg*(uhq+sqmavg)/uhq**2-sqmavg**2/(sh*uhq)
37925  ENDIF
37926  IF(itcm(5).GE.5) THEN
37927  IF(mint(55).EQ.5.OR.mint(55).EQ.6) THEN
37928  facqq1=facqq1+2.25d0*sqmavg*(thq-uhq)/(sh*thq)*redhgs+
37929  & 2.25d0*thq*uhq/sh2*sqdhgs
37930  facqq2=facqq2+2.25d0*sqmavg*(uhq-thq)/(sh*uhq)*redhgs+
37931  & 2.25d0*thq*uhq/sh2*sqdhgs
37932  ELSE
37933  facqq1=facqq1+2.25d0*sqmavg*(thq-uhq)/(sh*thq)*redlgs+
37934  & 2.25d0*thq*uhq/sh2*sqdlgs
37935  facqq2=facqq2+2.25d0*sqmavg*(uhq-thq)/(sh*uhq)*redlgs+
37936  & 2.25d0*thq*uhq/sh2*sqdlgs
37937  ENDIF
37938  ENDIF
37939  facqq1=comfac*faca*as**2*(1d0/6d0)*facqq1
37940  facqq2=comfac*faca*as**2*(1d0/6d0)*facqq2
37941  IF(mstp(35).GE.1) THEN
37942  fatre=pyhfth(sh,sqmavg,2d0/7d0)
37943  facqq1=facqq1*fatre
37944  facqq2=facqq2*fatre
37945  ENDIF
37946  wid2=1d0
37947  IF(mint(55).EQ.6) wid2=wids(6,1)
37948  IF(mint(55).EQ.7.OR.mint(55).EQ.8) wid2=wids(mint(55),1)
37949  facqq1=facqq1*wid2
37950  facqq2=facqq2*wid2
37951  IF(kfac(1,21)*kfac(2,21).EQ.0) goto 530
37952  nchn=nchn+1
37953  isig(nchn,1)=21
37954  isig(nchn,2)=21
37955  isig(nchn,3)=1
37956  sigh(nchn)=facqq1
37957  nchn=nchn+1
37958  isig(nchn,1)=21
37959  isig(nchn,2)=21
37960  isig(nchn,3)=2
37961  sigh(nchn)=facqq2
37962  530 CONTINUE
37963  ENDIF
37964  ENDIF
37965 
37966 CMRENNA--
37967 
37968  RETURN
37969  END
37970 
37971 C*********************************************************************
37972 
37973 C...PYSGEX
37974 C...Subprocess cross sections for assorted exotic processes,
37975 C...including Z'/W'/LQ/R/f*/H++/Z_R/W_R/G*.
37976 C...Auxiliary to PYSIGH.
37977 
37978  SUBROUTINE pysgex(NCHN,SIGS)
37979 
37980 C...Double precision and integer declarations
37981  IMPLICIT DOUBLE PRECISION(a-h, o-z)
37982  IMPLICIT INTEGER(i-n)
37983  INTEGER pyk,pychge,pycomp
37984 C...Parameter statement to help give large particle numbers.
37985  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
37986  &kexcit=4000000,kdimen=5000000)
37987 C...Commonblocks
37988  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
37989  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
37990  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
37991  common/pypars/mstp(200),parp(200),msti(200),pari(200)
37992  common/pyint1/mint(400),vint(400)
37993  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
37994  common/pyint3/xsfx(2,-40:40),isig(1000,3),sigh(1000)
37995  common/pyint4/mwid(500),wids(500,5)
37996  common/pytcsm/itcm(0:99),rtcm(0:99)
37997  common/pysgcm/isub,isubsv,mmin1,mmax1,mmin2,mmax2,mmina,mmaxa,
37998  &kfac(2,-40:40),comfac,fack,faca,sh,th,uh,sh2,th2,uh2,sqm3,sqm4,
37999  &shr,sqpth,taup,be34,cth,x(2),sqmz,sqmw,gmmz,gmmw,
38000  &aem,as,xw,xw1,xwc,xwv,poll,polr,polll,polrr
38001  SAVE /pydat1/,/pydat2/,/pydat3/,/pypars/,/pyint1/,/pyint2/,
38002  &/pyint3/,/pyint4/,/pytcsm/,/pysgcm/
38003 C...Local arrays
38004  dimension wdtp(0:400),wdte(0:400,0:5)
38005 
38006 C...Differential cross section expressions.
38007 
38008  IF(isub.LE.160) THEN
38009  IF(isub.EQ.141) THEN
38010 C...f + fbar -> gamma*/Z0/Z'0
38011  sqmzp=pmas(32,1)**2
38012  mint(61)=2
38013  CALL pywidt(32,sh,wdtp,wdte)
38014  hp0=aem/3d0*sh
38015  hp1=aem/3d0*xwc*sh
38016  hp2=hp1
38017  hs=shr*vint(117)
38018  hsp=shr*wdtp(0)
38019  faczp=4d0*comfac*3d0
38020  DO 100 i=mmina,mmaxa
38021  IF(i.EQ.0.OR.kfac(1,i)*kfac(2,-i).EQ.0) goto 100
38022  ei=kchg(iabs(i),1)/3d0
38023  ai=sign(1d0,ei)
38024  vi=ai-4d0*ei*xwv
38025  ia=iabs(i)
38026  IF(ia.LT.10) THEN
38027  IF(ia.LE.2) THEN
38028  vpi=paru(123-2*mod(iabs(i),2))
38029  api=paru(124-2*mod(iabs(i),2))
38030  ELSEIF(ia.LE.4) THEN
38031  vpi=parj(182-2*mod(iabs(i),2))
38032  api=parj(183-2*mod(iabs(i),2))
38033  ELSE
38034  vpi=parj(190-2*mod(iabs(i),2))
38035  api=parj(191-2*mod(iabs(i),2))
38036  ENDIF
38037  ELSE
38038  IF(ia.LE.12) THEN
38039  vpi=paru(127-2*mod(iabs(i),2))
38040  api=paru(128-2*mod(iabs(i),2))
38041  ELSEIF(ia.LE.14) THEN
38042  vpi=parj(186-2*mod(iabs(i),2))
38043  api=parj(187-2*mod(iabs(i),2))
38044  ELSE
38045  vpi=parj(194-2*mod(iabs(i),2))
38046  api=parj(195-2*mod(iabs(i),2))
38047  ENDIF
38048  ENDIF
38049  hi0=hp0
38050  IF(iabs(i).LE.10) hi0=hi0*faca/3d0
38051  hi1=hp1
38052  IF(iabs(i).LE.10) hi1=hi1*faca/3d0
38053  hi2=hp2
38054  IF(iabs(i).LE.10) hi2=hi2*faca/3d0
38055  nchn=nchn+1
38056  isig(nchn,1)=i
38057  isig(nchn,2)=-i
38058  isig(nchn,3)=1
38059 C...Special case: if only branching ratios known then use them.
38060  IF(mwid(32).EQ.2.AND.mstp(44).EQ.3) THEN
38061  hi=0d0
38062  IF(ia.LT.10) THEN
38063  hi=shr*wdtp(ia)*faca/9d0
38064  ELSEIF(ia.LT.20) THEN
38065  hi=shr*wdtp(ia-2)
38066  ENDIF
38067  hf=shr*(wdte(0,1)+wdte(0,2)+wdte(0,4))
38068  sigh(nchn)=hi*faczp*hf/((sh-sqmzp)**2+hsp**2)
38069  ELSE
38070 C...Normal cross section.
38071  sigh(nchn)=faczp*(ei**2/sh2*hi0*hp0*vint(111)+ei*vi*
38072  & (1d0-sqmz/sh)/((sh-sqmz)**2+hs**2)*(hi0*hp1+hi1*hp0)*
38073  & vint(112)+ei*vpi*(1d0-sqmzp/sh)/((sh-sqmzp)**2+hsp**2)*
38074  & (hi0*hp2+hi2*hp0)*vint(113)+(vi**2+ai**2)/
38075  & ((sh-sqmz)**2+hs**2)*hi1*hp1*vint(114)+(vi*vpi+ai*api)*
38076  & ((sh-sqmz)*(sh-sqmzp)+hs*hsp)/(((sh-sqmz)**2+hs**2)*
38077  & ((sh-sqmzp)**2+hsp**2))*(hi1*hp2+hi2*hp1)*vint(115)+
38078  & (vpi**2+api**2)/((sh-sqmzp)**2+hsp**2)*hi2*hp2*vint(116))
38079  ENDIF
38080  100 CONTINUE
38081 
38082  ELSEIF(isub.EQ.142) THEN
38083 C...f + fbar' -> W'+/-
38084  sqmwp=pmas(34,1)**2
38085  CALL pywidt(34,sh,wdtp,wdte)
38086  hs=shr*wdtp(0)
38087  facbw=4d0*comfac/((sh-sqmwp)**2+hs**2)*3d0
38088  hp=aem/(24d0*xw)*sh
38089  DO 120 i=mmin1,mmax1
38090  IF(i.EQ.0.OR.kfac(1,i).EQ.0) goto 120
38091  ia=iabs(i)
38092  DO 110 j=mmin2,mmax2
38093  IF(j.EQ.0.OR.kfac(2,j).EQ.0) goto 110
38094  ja=iabs(j)
38095  IF(i*j.GT.0.OR.mod(ia+ja,2).EQ.0) goto 110
38096  IF((ia.LE.10.AND.ja.GT.10).OR.(ia.GT.10.AND.ja.LE.10))
38097  & goto 110
38098  kchw=(kchg(ia,1)*isign(1,i)+kchg(ja,1)*isign(1,j))/3
38099 C...Special case: if only branching ratios known then use them.
38100  IF(mwid(34).EQ.2) THEN
38101  hi=0d0
38102  DO 105 idc=mdcy(34,2),mdcy(34,2)+mdcy(34,3)-1
38103  IF((ia.EQ.iabs(kfdp(idc,1)).AND.ja.EQ.
38104  & iabs(kfdp(idc,2))).OR.(ia.EQ.iabs(kfdp(idc,2))
38105  & .AND.ja.EQ.iabs(kfdp(idc,1))))
38106  & hi=shr*wdtp(idc+1-mdcy(34,2))
38107  105 CONTINUE
38108  IF(ia.LT.10) hi=hi*faca/9d0
38109  ELSE
38110 C...Normal cross section.
38111  hi=hp*(paru(133)**2+paru(134)**2)
38112  IF(ia.LE.10) hi=hp*(paru(131)**2+paru(132)**2)*
38113  & vckm((ia+1)/2,(ja+1)/2)*faca/3d0
38114  ENDIF
38115  nchn=nchn+1
38116  isig(nchn,1)=i
38117  isig(nchn,2)=j
38118  isig(nchn,3)=1
38119  hf=shr*(wdte(0,1)+wdte(0,(5-kchw)/2)+wdte(0,4))
38120  sigh(nchn)=hi*facbw*hf
38121  110 CONTINUE
38122  120 CONTINUE
38123 
38124  ELSEIF(isub.EQ.144) THEN
38125 C...f + fbar' -> R
38126  sqmr=pmas(41,1)**2
38127  CALL pywidt(41,sh,wdtp,wdte)
38128  hs=shr*wdtp(0)
38129  facbw=4d0*comfac/((sh-sqmr)**2+hs**2)*3d0
38130  hp=aem/(12d0*xw)*sh
38131  DO 140 i=mmin1,mmax1
38132  IF(i.EQ.0.OR.kfac(1,i).EQ.0) goto 140
38133  ia=iabs(i)
38134  DO 130 j=mmin2,mmax2
38135  IF(j.EQ.0.OR.kfac(2,j).EQ.0) goto 130
38136  ja=iabs(j)
38137  IF(i*j.GT.0.OR.iabs(ia-ja).NE.2) goto 130
38138  hi=hp
38139  IF(ia.LE.10) hi=hi*faca/3d0
38140  hf=shr*(wdte(0,1)+wdte(0,(10-(i+j))/4)+wdte(0,4))
38141  nchn=nchn+1
38142  isig(nchn,1)=i
38143  isig(nchn,2)=j
38144  isig(nchn,3)=1
38145  sigh(nchn)=hi*facbw*hf
38146  130 CONTINUE
38147  140 CONTINUE
38148 
38149  ELSEIF(isub.EQ.145) THEN
38150 C...q + l -> LQ (leptoquark)
38151  sqmlq=pmas(42,1)**2
38152  CALL pywidt(42,sh,wdtp,wdte)
38153  hs=shr*wdtp(0)
38154  facbw=4d0*comfac/((sh-sqmlq)**2+hs**2)
38155  IF(abs(shr-pmas(42,1)).GT.parp(48)*pmas(42,2)) facbw=0d0
38156  hp=aem/4d0*sh
38157  kflqq=kfdp(mdcy(42,2),1)
38158  kflql=kfdp(mdcy(42,2),2)
38159  DO 160 i=mmin1,mmax1
38160  IF(kfac(1,i).EQ.0) goto 160
38161  ia=iabs(i)
38162  IF(ia.NE.kflqq.AND.ia.NE.iabs(kflql)) goto 160
38163  DO 150 j=mmin2,mmax2
38164  IF(kfac(2,j).EQ.0) goto 150
38165  ja=iabs(j)
38166  IF(ja.NE.kflqq.AND.ja.NE.iabs(kflql)) goto 150
38167  IF(i*j.NE.kflqq*kflql) goto 150
38168  IF(ja.EQ.ia) goto 150
38169  IF(ia.EQ.kflqq) kchlq=isign(1,i)
38170  IF(ja.EQ.kflqq) kchlq=isign(1,j)
38171  hi=hp*paru(151)
38172  hf=shr*(wdte(0,1)+wdte(0,(5-kchlq)/2)+wdte(0,4))
38173  nchn=nchn+1
38174  isig(nchn,1)=i
38175  isig(nchn,2)=j
38176  isig(nchn,3)=1
38177  sigh(nchn)=hi*facbw*hf
38178  150 CONTINUE
38179  160 CONTINUE
38180 
38181  ELSEIF(isub.EQ.146) THEN
38182 C...e + gamma* -> e* (excited lepton)
38183  kfqstr=kfpr(isub,1)
38184  kcqstr=pycomp(kfqstr)
38185  kfqexc=mod(kfqstr,kexcit)
38186  CALL pywidt(kfqstr,sh,wdtp,wdte)
38187  hs=shr*wdtp(0)
38188  facbw=comfac/((sh-pmas(kcqstr,1)**2)**2+hs**2)
38189  qf=-rtcm(43)/2d0-rtcm(44)/2d0
38190  facbw=facbw*aem*qf**2*sh/rtcm(41)**2
38191  IF(abs(shr-pmas(kcqstr,1)).GT.parp(48)*pmas(kcqstr,2))
38192  & facbw=0d0
38193  hp=sh
38194  DO 180 i=-kfqexc,kfqexc,2*kfqexc
38195  DO 170 isde=1,2
38196  IF(isde.EQ.1.AND.kfac(1,i)*kfac(2,22).EQ.0) goto 170
38197  IF(isde.EQ.2.AND.kfac(1,22)*kfac(2,i).EQ.0) goto 170
38198  hi=hp
38199  IF(i.GT.0) hf=shr*(wdte(0,1)+wdte(0,2)+wdte(0,4))
38200  IF(i.LT.0) hf=shr*(wdte(0,1)+wdte(0,3)+wdte(0,4))
38201  nchn=nchn+1
38202  isig(nchn,isde)=i
38203  isig(nchn,3-isde)=22
38204  isig(nchn,3)=1
38205  sigh(nchn)=hi*facbw*hf
38206  170 CONTINUE
38207  180 CONTINUE
38208 
38209  ELSEIF(isub.EQ.147.OR.isub.EQ.148) THEN
38210 C...d + g -> d* and u + g -> u* (excited quarks)
38211  kfqstr=kfpr(isub,1)
38212  kcqstr=pycomp(kfqstr)
38213  kfqexc=mod(kfqstr,kexcit)
38214  CALL pywidt(kfqstr,sh,wdtp,wdte)
38215  hs=shr*wdtp(0)
38216  facbw=comfac/((sh-pmas(kcqstr,1)**2)**2+hs**2)
38217  facbw=facbw*as*rtcm(45)**2*sh/(3d0*rtcm(41)**2)
38218  IF(abs(shr-pmas(kcqstr,1)).GT.parp(48)*pmas(kcqstr,2))
38219  & facbw=0d0
38220  hp=sh
38221  DO 200 i=-kfqexc,kfqexc,2*kfqexc
38222  DO 190 isde=1,2
38223  IF(isde.EQ.1.AND.kfac(1,i)*kfac(2,21).EQ.0) goto 190
38224  IF(isde.EQ.2.AND.kfac(1,21)*kfac(2,i).EQ.0) goto 190
38225  hi=hp
38226  IF(i.GT.0) hf=shr*(wdte(0,1)+wdte(0,2)+wdte(0,4))
38227  IF(i.LT.0) hf=shr*(wdte(0,1)+wdte(0,3)+wdte(0,4))
38228  nchn=nchn+1
38229  isig(nchn,isde)=i
38230  isig(nchn,3-isde)=21
38231  isig(nchn,3)=1
38232  sigh(nchn)=hi*facbw*hf
38233  190 CONTINUE
38234  200 CONTINUE
38235  ENDIF
38236 
38237  ELSEIF(isub.LE.190) THEN
38238  IF(isub.EQ.162) THEN
38239 C...q + g -> LQ + lbar; LQ=leptoquark
38240  sqmlq=pmas(42,1)**2
38241  faclq=comfac*faca*paru(151)*(as*aem/6d0)*(-th/sh)*
38242  & (uh2+sqmlq**2)/(uh-sqmlq)**2
38243  kflqq=kfdp(mdcy(42,2),1)
38244  DO 220 i=mmina,mmaxa
38245  IF(iabs(i).NE.kflqq) goto 220
38246  kchlq=isign(1,i)
38247  DO 210 isde=1,2
38248  IF(isde.EQ.1.AND.kfac(1,i)*kfac(2,21).EQ.0) goto 210
38249  IF(isde.EQ.2.AND.kfac(1,21)*kfac(2,i).EQ.0) goto 210
38250  nchn=nchn+1
38251  isig(nchn,isde)=i
38252  isig(nchn,3-isde)=21
38253  isig(nchn,3)=1
38254  sigh(nchn)=faclq*wids(42,(5-kchlq)/2)
38255  210 CONTINUE
38256  220 CONTINUE
38257 
38258  ELSEIF(isub.EQ.163) THEN
38259 C...g + g -> LQ + LQbar; LQ=leptoquark
38260  sqmlq=pmas(42,1)**2
38261  faclq=comfac*faca*wids(42,1)*(as**2/2d0)*
38262  & (7d0/48d0+3d0*(uh-th)**2/(16d0*sh2))*(1d0+2d0*sqmlq*th/
38263  & (th-sqmlq)**2+2d0*sqmlq*uh/(uh-sqmlq)**2+4d0*sqmlq**2/
38264  & ((th-sqmlq)*(uh-sqmlq)))
38265  IF(kfac(1,21)*kfac(2,21).EQ.0) goto 230
38266  nchn=nchn+1
38267  isig(nchn,1)=21
38268  isig(nchn,2)=21
38269 C...Since don't know proper colour flow, randomize between alternatives
38270  isig(nchn,3)=int(1.5d0+pyr(0))
38271  sigh(nchn)=faclq
38272  230 CONTINUE
38273 
38274  ELSEIF(isub.EQ.164) THEN
38275 C...q + qbar -> LQ + LQbar; LQ=leptoquark
38276  delta=0.25d0*(sqm3-sqm4)**2/sh
38277  sqmlq=0.5d0*(sqm3+sqm4)-delta
38278  th=th-delta
38279  uh=uh-delta
38280 C SQMLQ=PMAS(42,1)**2
38281  faclqa=comfac*wids(42,1)*(as**2/9d0)*
38282  & (sh*(sh-4d0*sqmlq)-(uh-th)**2)/sh2
38283  faclqs=comfac*wids(42,1)*((paru(151)**2*aem**2/8d0)*
38284  & (-sh*th-(sqmlq-th)**2)/th2+(paru(151)*aem*as/18d0)*
38285  & ((sqmlq-th)*(uh-th)+sh*(sqmlq+th))/(sh*th))
38286  kflqq=kfdp(mdcy(42,2),1)
38287  DO 240 i=mmina,mmaxa
38288  IF(i.EQ.0.OR.iabs(i).GT.mstp(58).OR.
38289  & kfac(1,i)*kfac(2,-i).EQ.0) goto 240
38290  nchn=nchn+1
38291  isig(nchn,1)=i
38292  isig(nchn,2)=-i
38293  isig(nchn,3)=1
38294  sigh(nchn)=faclqa
38295  IF(iabs(i).EQ.kflqq) sigh(nchn)=faclqa+faclqs
38296  240 CONTINUE
38297 
38298  ELSEIF(isub.EQ.167.OR.isub.EQ.168) THEN
38299 C...q + q' -> q" + d* and q + q' -> q" + u* (excited quarks)
38300  kfqstr=kfpr(isub,2)
38301  kcqstr=pycomp(kfqstr)
38302  kfqexc=mod(kfqstr,kexcit)
38303  facqsa=comfac*(sh/rtcm(41)**2)**2*(1d0-sqm4/sh)
38304  facqsb=comfac*0.25d0*(sh/rtcm(41)**2)**2*(1d0-sqm4/sh)*
38305  & (1d0+sqm4/sh)*(1d0+cth)*(1d0+((sh-sqm4)/(sh+sqm4))*cth)
38306 C...Propagators: as simulated in PYOFSH and as desired
38307  gmmq=pmas(kcqstr,1)*pmas(kcqstr,2)
38308  hbw4=gmmq/((sqm4-pmas(kcqstr,1)**2)**2+gmmq**2)
38309  CALL pywidt(kfqstr,sqm4,wdtp,wdte)
38310  gmmqc=sqrt(sqm4)*wdtp(0)
38311  hbw4c=gmmqc/((sqm4-pmas(kcqstr,1)**2)**2+gmmqc**2)
38312  facqsa=facqsa*hbw4c/hbw4
38313  facqsb=facqsb*hbw4c/hbw4
38314 C...Branching ratios.
38315  brpos=(wdte(0,1)+wdte(0,2)+wdte(0,4))/wdtp(0)
38316  brneg=(wdte(0,1)+wdte(0,3)+wdte(0,4))/wdtp(0)
38317  DO 260 i=mmin1,mmax1
38318  ia=iabs(i)
38319  IF(i.EQ.0.OR.ia.GT.6.OR.kfac(1,i).EQ.0) goto 260
38320  DO 250 j=mmin2,mmax2
38321  ja=iabs(j)
38322  IF(j.EQ.0.OR.ja.GT.6.OR.kfac(2,j).EQ.0) goto 250
38323  IF(ia.EQ.kfqexc.AND.i.EQ.j) THEN
38324  nchn=nchn+1
38325  isig(nchn,1)=i
38326  isig(nchn,2)=j
38327  isig(nchn,3)=1
38328  IF(i.GT.0) sigh(nchn)=(4d0/3d0)*facqsa*brpos
38329  IF(i.LT.0) sigh(nchn)=(4d0/3d0)*facqsa*brneg
38330  nchn=nchn+1
38331  isig(nchn,1)=i
38332  isig(nchn,2)=j
38333  isig(nchn,3)=2
38334  IF(j.GT.0) sigh(nchn)=(4d0/3d0)*facqsa*brpos
38335  IF(j.LT.0) sigh(nchn)=(4d0/3d0)*facqsa*brneg
38336  ELSEIF((ia.EQ.kfqexc.OR.ja.EQ.kfqexc).AND.i*j.GT.0) THEN
38337  nchn=nchn+1
38338  isig(nchn,1)=i
38339  isig(nchn,2)=j
38340  isig(nchn,3)=1
38341  IF(ja.EQ.kfqexc) isig(nchn,3)=2
38342  IF(isig(nchn,isig(nchn,3)).GT.0) sigh(nchn)=facqsa*brpos
38343  IF(isig(nchn,isig(nchn,3)).LT.0) sigh(nchn)=facqsa*brneg
38344  ELSEIF(ia.EQ.kfqexc.AND.i.EQ.-j) THEN
38345  nchn=nchn+1
38346  isig(nchn,1)=i
38347  isig(nchn,2)=j
38348  isig(nchn,3)=1
38349  IF(i.GT.0) sigh(nchn)=(8d0/3d0)*facqsb*brpos
38350  IF(i.LT.0) sigh(nchn)=(8d0/3d0)*facqsb*brneg
38351  nchn=nchn+1
38352  isig(nchn,1)=i
38353  isig(nchn,2)=j
38354  isig(nchn,3)=2
38355  IF(j.GT.0) sigh(nchn)=(8d0/3d0)*facqsb*brpos
38356  IF(j.LT.0) sigh(nchn)=(8d0/3d0)*facqsb*brneg
38357  ELSEIF(i.EQ.-j) THEN
38358  nchn=nchn+1
38359  isig(nchn,1)=i
38360  isig(nchn,2)=j
38361  isig(nchn,3)=1
38362  IF(i.GT.0) sigh(nchn)=facqsb*brpos
38363  IF(i.LT.0) sigh(nchn)=facqsb*brneg
38364  nchn=nchn+1
38365  isig(nchn,1)=i
38366  isig(nchn,2)=j
38367  isig(nchn,3)=2
38368  IF(j.GT.0) sigh(nchn)=facqsb*brpos
38369  IF(j.LT.0) sigh(nchn)=facqsb*brneg
38370  ELSEIF(ia.EQ.kfqexc.OR.ja.EQ.kfqexc) THEN
38371  nchn=nchn+1
38372  isig(nchn,1)=i
38373  isig(nchn,2)=j
38374  isig(nchn,3)=1
38375  IF(ja.EQ.kfqexc) isig(nchn,3)=2
38376  IF(isig(nchn,isig(nchn,3)).GT.0) sigh(nchn)=facqsb*brpos
38377  IF(isig(nchn,isig(nchn,3)).LT.0) sigh(nchn)=facqsb*brneg
38378  ENDIF
38379  250 CONTINUE
38380  260 CONTINUE
38381 
38382  ELSEIF(isub.EQ.169) THEN
38383 C...q + qbar -> e + e* (excited lepton)
38384  kfqstr=kfpr(isub,2)
38385  kcqstr=pycomp(kfqstr)
38386  kfqexc=mod(kfqstr,kexcit)
38387  facqsb=(comfac/12d0)*(sh/rtcm(41)**2)**2*(1d0-sqm4/sh)*
38388  & (1d0+sqm4/sh)*(1d0+cth)*(1d0+((sh-sqm4)/(sh+sqm4))*cth)
38389 C...Propagators: as simulated in PYOFSH and as desired
38390  gmmq=pmas(kcqstr,1)*pmas(kcqstr,2)
38391  hbw4=gmmq/((sqm4-pmas(kcqstr,1)**2)**2+gmmq**2)
38392  CALL pywidt(kfqstr,sqm4,wdtp,wdte)
38393  gmmqc=sqrt(sqm4)*wdtp(0)
38394  hbw4c=gmmqc/((sqm4-pmas(kcqstr,1)**2)**2+gmmqc**2)
38395  facqsb=facqsb*hbw4c/hbw4
38396 C...Branching ratios.
38397  brpos=(wdte(0,1)+wdte(0,2)+wdte(0,4))/wdtp(0)
38398  brneg=(wdte(0,1)+wdte(0,3)+wdte(0,4))/wdtp(0)
38399  DO 270 i=mmin1,mmax1
38400  ia=iabs(i)
38401  IF(i.EQ.0.OR.ia.GT.6.OR.kfac(1,i).EQ.0) goto 270
38402  j=-i
38403  ja=iabs(j)
38404  IF(j.EQ.0.OR.ja.GT.6.OR.kfac(2,j).EQ.0) goto 270
38405  nchn=nchn+1
38406  isig(nchn,1)=i
38407  isig(nchn,2)=j
38408  isig(nchn,3)=1
38409  IF(i.GT.0) sigh(nchn)=facqsb*brpos
38410  IF(i.LT.0) sigh(nchn)=facqsb*brneg
38411  nchn=nchn+1
38412  isig(nchn,1)=i
38413  isig(nchn,2)=j
38414  isig(nchn,3)=2
38415  IF(j.GT.0) sigh(nchn)=facqsb*brpos
38416  IF(j.LT.0) sigh(nchn)=facqsb*brneg
38417  270 CONTINUE
38418  ENDIF
38419 
38420  ELSEIF(isub.LE.360) THEN
38421  IF(isub.EQ.341.OR.isub.EQ.342) THEN
38422 C...l + l -> H_L++/-- or H_R++/--.
38423  kfres=kfpr(isub,1)
38424  kfrec=pycomp(kfres)
38425  CALL pywidt(kfres,sh,wdtp,wdte)
38426  hs=shr*wdtp(0)
38427  facbw=8d0*comfac/((sh-pmas(kfrec,1)**2)**2+hs**2)
38428  DO 290 i=mmin1,mmax1
38429  ia=iabs(i)
38430  IF((ia.NE.11.AND.ia.NE.13.AND.ia.NE.15).OR.kfac(1,i).EQ.0)
38431  & goto 290
38432  DO 280 j=mmin2,mmax2
38433  ja=iabs(j)
38434  IF((ja.NE.11.AND.ja.NE.13.AND.ja.NE.15).OR.kfac(2,j).EQ.0)
38435  & goto 280
38436  IF(i*j.LT.0) goto 280
38437  kchh=(kchg(ia,1)*isign(1,i)+kchg(ja,1)*isign(1,j))/3
38438  nchn=nchn+1
38439  isig(nchn,1)=i
38440  isig(nchn,2)=j
38441  isig(nchn,3)=1
38442  hi=sh*parp(181+3*((ia-11)/2)+(ja-11)/2)**2/(8d0*paru(1))
38443  hf=shr*(wdte(0,1)+wdte(0,(5-kchh/2)/2)+wdte(0,4))
38444  sigh(nchn)=hi*facbw*hf
38445  280 CONTINUE
38446  290 CONTINUE
38447 
38448  ELSEIF(isub.GE.343.AND.isub.LE.348) THEN
38449 C...l + gamma -> H_L++/-- l' or l + gamma -> H_R++/-- l'.
38450  kfres=kfpr(isub,1)
38451  kfrec=pycomp(kfres)
38452 C...Propagators: as simulated in PYOFSH and as desired
38453  hbw3=pmas(kfrec,1)*pmas(kfrec,2)/((sqm3-pmas(kfrec,1)**2)**2+
38454  & (pmas(kfrec,1)*pmas(kfrec,2))**2)
38455  CALL pywidt(kfres,sqm3,wdtp,wdte)
38456  gmmc=sqrt(sqm3)*wdtp(0)
38457  hbw3c=gmmc/((sqm3-pmas(kfrec,1)**2)**2+gmmc**2)
38458  fhcc=comfac*aem*hbw3c/hbw3
38459  DO 310 i=mmina,mmaxa
38460  ia=iabs(i)
38461  IF(ia.NE.11.AND.ia.NE.13.AND.ia.NE.15) goto 310
38462  sqml=pmas(ia,1)**2
38463  j=isign(kfpr(isub,2),-i)
38464  kchh=isign(2,kchg(ia,1)*isign(1,i))
38465  widsc=(wdte(0,1)+wdte(0,(5-kchh/2)/2)+wdte(0,4))/wdtp(0)
38466  smm1=8d0*(sh+th-sqm3)*(sh+th-2d0*sqm3-sqml-sqm4)/
38467  & (uh-sqm3)**2
38468  smm2=2d0*((2d0*sqm3-3d0*sqml)*sqm4+(sqml-2d0*sqm4)*th-
38469  & (th-sqm4)*sh)/(th-sqm4)**2
38470  smm3=2d0*((2d0*sqm3-3d0*sqm4+th)*sqml-(2d0*sqml-sqm4+th)*
38471  & sh)/(sh-sqml)**2
38472  smm12=4d0*((2d0*sqml-sqm4-2d0*sqm3+th)*sh+(th-3d0*sqm3-
38473  & 3d0*sqm4)*th+(2d0*sqm3-2d0*sqml+3d0*sqm4)*sqm3)/
38474  & ((uh-sqm3)*(th-sqm4))
38475  smm13=-4d0*((th+sqml-2d0*sqm4)*th-(sqm3+3d0*sqml-2d0*sqm4)*
38476  & sqm3+(sqm3+3d0*sqml+th)*sh-(th-sqm3+sh)**2)/
38477  & ((uh-sqm3)*(sh-sqml))
38478  smm23=-4d0*((sqml-sqm4+sqm3)*th-sqm3**2+sqm3*(sqml+sqm4)-
38479  & 3d0*sqml*sqm4-(sqml-sqm4-sqm3+th)*sh)/
38480  & ((sh-sqml)*(th-sqm4))
38481  smm=(sh/(sh-sqml))**2*(smm1+smm2+smm3+smm12+smm13+smm23)*
38482  & parp(181+3*((ia-11)/2)+(iabs(j)-11)/2)**2/(4d0*paru(1))
38483  DO 300 isde=1,2
38484  IF(isde.EQ.1.AND.kfac(1,i)*kfac(2,22).EQ.0) goto 300
38485  IF(isde.EQ.2.AND.kfac(1,22)*kfac(2,i).EQ.0) goto 300
38486  nchn=nchn+1
38487  isig(nchn,isde)=i
38488  isig(nchn,3-isde)=22
38489  isig(nchn,3)=0
38490  sigh(nchn)=fhcc*smm*widsc
38491  300 CONTINUE
38492  310 CONTINUE
38493 
38494  ELSEIF(isub.EQ.349.OR.isub.EQ.350) THEN
38495 C...f + fbar -> H_L++ + H_L-- or H_R++ + H_R--
38496  kfres=kfpr(isub,1)
38497  kfrec=pycomp(kfres)
38498  sqmh=pmas(kfrec,1)**2
38499  gmmh=pmas(kfrec,1)*pmas(kfrec,2)
38500 C...Propagators: H++/-- as simulated in PYOFSH and as desired
38501  hbw3=gmmh/((sqm3-sqmh)**2+gmmh**2)
38502  CALL pywidt(kfres,sqm3,wdtp,wdte)
38503  gmmh3=sqrt(sqm3)*wdtp(0)
38504  hbw3c=gmmh3/((sqm3-sqmh)**2+gmmh3**2)
38505  hbw4=gmmh/((sqm4-sqmh)**2+gmmh**2)
38506  CALL pywidt(kfres,sqm4,wdtp,wdte)
38507  gmmh4=sqrt(sqm4)*wdtp(0)
38508  hbw4c=gmmh4/((sqm4-sqmh)**2+gmmh4**2)
38509 C...Kinematical and coupling functions
38510  fachh=comfac*(hbw3c/hbw3)*(hbw4c/hbw4)*(th*uh-sqm3*sqm4)
38511  xwhh=(1d0-2d0*xwv)/(8d0*xwv*(1d0-xwv))
38512 C...Loop over allowed flavours
38513  DO 320 i=mmina,mmaxa
38514  IF(i.EQ.0.OR.kfac(1,i)*kfac(2,-i).EQ.0) goto 320
38515  ei=kchg(iabs(i),1)/3d0
38516  ai=sign(1d0,ei+0.1d0)
38517  vi=ai-4d0*ei*xwv
38518  fcoi=1d0
38519  IF(iabs(i).LE.10) fcoi=faca/3d0
38520  IF(isub.EQ.349) THEN
38521  hbwz=1d0/((sh-sqmz)**2+gmmz**2)
38522  IF(iabs(i).LT.10) THEN
38523  dsighh=8d0*aem**2*(ei**2/sh2+
38524  & 2d0*ei*vi*xwhh*(sh-sqmz)*hbwz/sh+
38525  & (vi**2+ai**2)*xwhh**2*hbwz)
38526  ELSE
38527  iaoff=181+3*((iabs(i)-11)/2)
38528  hsum=(parp(iaoff)**2+parp(iaoff+1)**2+parp(iaoff+2)**2)/
38529  & (4d0*paru(1))
38530  dsighh=8d0*aem**2*(ei**2/sh2+
38531  & 2d0*ei*vi*xwhh*(sh-sqmz)*hbwz/sh+
38532  & (vi**2+ai**2)*xwhh**2*hbwz)+
38533  & 8d0*aem*(ei*hsum/(sh*th)+
38534  & (vi+ai)*xwhh*hsum*(sh-sqmz)*hbwz/th)+
38535  & 4d0*hsum**2/th2
38536  ENDIF
38537  ELSE
38538  IF(iabs(i).LT.10) THEN
38539  dsighh=8d0*aem**2*ei**2/sh2
38540  ELSE
38541  iaoff=181+3*((iabs(i)-11)/2)
38542  hsum=(parp(iaoff)**2+parp(iaoff+1)**2+parp(iaoff+2)**2)/
38543  & (4d0*paru(1))
38544  dsighh=8d0*aem**2*ei**2/sh2+8d0*aem*ei*hsum/(sh*th)+
38545  & 4d0*hsum**2/th2
38546  ENDIF
38547  ENDIF
38548  nchn=nchn+1
38549  isig(nchn,1)=i
38550  isig(nchn,2)=-i
38551  isig(nchn,3)=1
38552  sigh(nchn)=fachh*fcoi*dsighh
38553  320 CONTINUE
38554 
38555  ELSEIF(isub.EQ.351.OR.isub.EQ.352) THEN
38556 C...f + f' -> f" + f"' + H++/-- (W+/- + W+/- -> H++/-- as inner process)
38557  kfres=kfpr(isub,1)
38558  kfrec=pycomp(kfres)
38559  sqmh=pmas(kfrec,1)**2
38560  IF(isub.EQ.351) facnor=parp(190)**8*parp(192)**2
38561  IF(isub.EQ.352) facnor=parp(191)**6*2d0*
38562  & pmas(pycomp(9900024),1)**2
38563  facww=comfac*facnor*taup*vint(2)*vint(219)
38564  facprt=1d0/((vint(204)**2-vint(215))*
38565  & (vint(209)**2-vint(216)))
38566  facpru=1d0/((vint(204)**2+2d0*vint(217))*
38567  & (vint(209)**2+2d0*vint(218)))
38568  CALL pywidt(kfres,sh,wdtp,wdte)
38569  hs=shr*wdtp(0)
38570  facbw=(1d0/paru(1))*vint(2)/((sh-sqmh)**2+hs**2)
38571  IF(abs(shr-pmas(kfrec,1)).GT.parp(48)*pmas(kfrec,2))
38572  & facbw=0d0
38573  DO 340 i=mmin1,mmax1
38574  IF(i.EQ.0.OR.kfac(1,i).EQ.0) goto 340
38575  IF(isub.EQ.352.AND.iabs(i).GT.10) goto 340
38576  kchwi=(1-2*mod(iabs(i),2))*isign(1,i)
38577  DO 330 j=mmin2,mmax2
38578  IF(j.EQ.0.OR.kfac(2,j).EQ.0) goto 330
38579  IF(isub.EQ.352.AND.iabs(j).GT.10) goto 330
38580  kchwj=(1-2*mod(iabs(j),2))*isign(1,j)
38581  kchh=kchwi+kchwj
38582  IF(iabs(kchh).NE.2) goto 330
38583  faclr=vint(180+i)*vint(180+j)
38584  hf=shr*(wdte(0,1)+wdte(0,(5-kchh/2)/2)+wdte(0,4))
38585  IF(i.EQ.j.AND.iabs(i).GT.10) THEN
38586  facprp=0.5d0*(facprt+facpru)**2
38587  ELSE
38588  facprp=facprt**2
38589  ENDIF
38590  nchn=nchn+1
38591  isig(nchn,1)=i
38592  isig(nchn,2)=j
38593  isig(nchn,3)=1
38594  sigh(nchn)=faclr*facww*facprp*facbw*hf
38595  330 CONTINUE
38596  340 CONTINUE
38597 
38598  ELSEIF(isub.EQ.353) THEN
38599 C...f + fbar -> Z_R0
38600  sqmzr=pmas(pycomp(kfpr(isub,1)),1)**2
38601  CALL pywidt(kfpr(isub,1),sh,wdtp,wdte)
38602  hs=shr*wdtp(0)
38603  facbw=4d0*comfac/((sh-sqmzr)**2+hs**2)*3d0
38604  hf=shr*(wdte(0,1)+wdte(0,2)+wdte(0,4))
38605  hp=(aem/(3d0*(1d0-2d0*xw)))*xwc*sh
38606  DO 350 i=mmina,mmaxa
38607  IF(i.EQ.0.OR.kfac(1,i)*kfac(2,-i).EQ.0) goto 350
38608  IF(iabs(i).LE.8) THEN
38609  ei=kchg(iabs(i),1)/3d0
38610  ai=sign(1d0,ei+0.1d0)*(1d0-2d0*xw)
38611  vi=sign(1d0,ei+0.1d0)-4d0*ei*xw
38612  ELSE
38613  ai=-(1d0-2d0*xw)
38614  vi=-1d0+4d0*xw
38615  ENDIF
38616  hi=hp*(vi**2+ai**2)
38617  IF(iabs(i).LE.10) hi=hi*faca/3d0
38618  nchn=nchn+1
38619  isig(nchn,1)=i
38620  isig(nchn,2)=-i
38621  isig(nchn,3)=1
38622  sigh(nchn)=hi*facbw*hf
38623  350 CONTINUE
38624 
38625  ELSEIF(isub.EQ.354) THEN
38626 C...f + fbar' -> W_R+/-
38627  sqmwr=pmas(pycomp(kfpr(isub,1)),1)**2
38628  CALL pywidt(kfpr(isub,1),sh,wdtp,wdte)
38629  hs=shr*wdtp(0)
38630  facbw=4d0*comfac/((sh-sqmwr)**2+hs**2)*3d0
38631  hp=aem/(24d0*xw)*sh
38632  DO 370 i=mmin1,mmax1
38633  IF(i.EQ.0.OR.kfac(1,i).EQ.0) goto 370
38634  ia=iabs(i)
38635  DO 360 j=mmin2,mmax2
38636  IF(j.EQ.0.OR.kfac(2,j).EQ.0) goto 360
38637  ja=iabs(j)
38638  IF(i*j.GT.0.OR.mod(ia+ja,2).EQ.0) goto 360
38639  IF((ia.LE.10.AND.ja.GT.10).OR.(ia.GT.10.AND.ja.LE.10))
38640  & goto 360
38641  kchw=(kchg(ia,1)*isign(1,i)+kchg(ja,1)*isign(1,j))/3
38642  hi=hp*2d0
38643  IF(ia.LE.10) hi=hi*vckm((ia+1)/2,(ja+1)/2)*faca/3d0
38644  nchn=nchn+1
38645  isig(nchn,1)=i
38646  isig(nchn,2)=j
38647  isig(nchn,3)=1
38648  hf=shr*(wdte(0,1)+wdte(0,(5-kchw)/2)+wdte(0,4))
38649  sigh(nchn)=hi*facbw*hf
38650  360 CONTINUE
38651  370 CONTINUE
38652  ENDIF
38653 
38654  ELSEIF(isub.LE.400) THEN
38655  IF(isub.EQ.391) THEN
38656 C...f + fbar -> G*.
38657  kfgstr=kfpr(isub,1)
38658  kcgstr=pycomp(kfgstr)
38659  CALL pywidt(kfgstr,sh,wdtp,wdte)
38660  hs=shr*wdtp(0)
38661  hf=shr*(wdte(0,1)+wdte(0,2)+wdte(0,4))
38662  facg=comfac*parp(50)**2/(16d0*paru(1))*sh*hf/
38663  & ((sh-pmas(kcgstr,1)**2)**2+hs**2)
38664 C...Modify cross section in wings of peak.
38665  facg = facg * sh**2 / pmas(kcgstr,1)**4
38666  DO 380 i=mmina,mmaxa
38667  IF(i.EQ.0.OR.kfac(1,i)*kfac(2,-i).EQ.0) goto 380
38668  hi=1d0
38669  IF(iabs(i).LE.10) hi=hi*faca/3d0
38670  nchn=nchn+1
38671  isig(nchn,1)=i
38672  isig(nchn,2)=-i
38673  isig(nchn,3)=1
38674  sigh(nchn)=facg*hi
38675  380 CONTINUE
38676 
38677  ELSEIF(isub.EQ.392) THEN
38678 C...g + g -> G*.
38679  kfgstr=kfpr(isub,1)
38680  kcgstr=pycomp(kfgstr)
38681  CALL pywidt(kfgstr,sh,wdtp,wdte)
38682  hs=shr*wdtp(0)
38683  hf=shr*(wdte(0,1)+wdte(0,2)+wdte(0,4))
38684  facg=comfac*parp(50)**2/(32d0*paru(1))*sh*hf/
38685  & ((sh-pmas(kcgstr,1)**2)**2+hs**2)
38686 C...Modify cross section in wings of peak.
38687  facg = facg * sh**2 / pmas(kcgstr,1)**4
38688  IF(kfac(1,21)*kfac(2,21).EQ.0) goto 390
38689  nchn=nchn+1
38690  isig(nchn,1)=21
38691  isig(nchn,2)=21
38692  isig(nchn,3)=1
38693  sigh(nchn)=facg
38694  390 CONTINUE
38695 
38696  ELSEIF(isub.EQ.393) THEN
38697 C...q + qbar -> g + G*.
38698  kfgstr=kfpr(isub,2)
38699  kcgstr=pycomp(kfgstr)
38700  facg=comfac*parp(50)**2*as*sh/(72d0*paru(1)*sqm4)*
38701  & (4d0*(th2+uh2)/sh2+9d0*(th+uh)/sh+(th2/uh+uh2/th)/sh+
38702  & 3d0*(4d0+th/uh+uh/th)+4d0*(sh/uh+sh/th)+
38703  & 2d0*sh2/(th*uh))
38704 C...Propagators: as simulated in PYOFSH and as desired
38705  gmmg=pmas(kcgstr,1)*pmas(kcgstr,2)
38706  hbw4=gmmg/((sqm4-pmas(kcgstr,1)**2)**2+gmmg**2)
38707  CALL pywidt(kfgstr,sqm4,wdtp,wdte)
38708  hs=sqrt(sqm4)*wdtp(0)
38709  hf=sqrt(sqm4)*(wdte(0,1)+wdte(0,2)+wdte(0,4))
38710  hbw4c=hf/((sqm4-pmas(kcgstr,1)**2)**2+hs**2)
38711  facg=facg*hbw4c/hbw4
38712  DO 400 i=mmina,mmaxa
38713  IF(i.EQ.0.OR.iabs(i).GT.mstp(58).OR.
38714  & kfac(1,i)*kfac(2,-i).EQ.0) goto 400
38715  nchn=nchn+1
38716  isig(nchn,1)=i
38717  isig(nchn,2)=-i
38718  isig(nchn,3)=1
38719  sigh(nchn)=facg
38720  400 CONTINUE
38721 
38722  ELSEIF(isub.EQ.394) THEN
38723 C...q + g -> q + G*.
38724  kfgstr=kfpr(isub,2)
38725  kcgstr=pycomp(kfgstr)
38726  facg=-comfac*parp(50)**2*as*sh/(192d0*paru(1)*sqm4)*
38727  & (4d0*(sh2+uh2)/(th*sh)+9d0*(sh+uh)/sh+sh/uh+uh2/sh2+
38728  & 3d0*th*(4d0+sh/uh+uh/sh)/sh+4d0*th2*(1d0/uh+1d0/sh)/sh+
38729  & 2d0*th2*th/(uh*sh2))
38730 C...Propagators: as simulated in PYOFSH and as desired
38731  gmmg=pmas(kcgstr,1)*pmas(kcgstr,2)
38732  hbw4=gmmg/((sqm4-pmas(kcgstr,1)**2)**2+gmmg**2)
38733  CALL pywidt(kfgstr,sqm4,wdtp,wdte)
38734  hs=sqrt(sqm4)*wdtp(0)
38735  hf=sqrt(sqm4)*(wdte(0,1)+wdte(0,2)+wdte(0,4))
38736  hbw4c=hf/((sqm4-pmas(kcgstr,1)**2)**2+hs**2)
38737  facg=facg*hbw4c/hbw4
38738  DO 420 i=mmina,mmaxa
38739  IF(i.EQ.0.OR.iabs(i).GT.mstp(58)) goto 420
38740  DO 410 isde=1,2
38741  IF(isde.EQ.1.AND.kfac(1,i)*kfac(2,21).EQ.0) goto 410
38742  IF(isde.EQ.2.AND.kfac(1,21)*kfac(2,i).EQ.0) goto 410
38743  nchn=nchn+1
38744  isig(nchn,isde)=i
38745  isig(nchn,3-isde)=21
38746  isig(nchn,3)=1
38747  sigh(nchn)=facg
38748  410 CONTINUE
38749  420 CONTINUE
38750 
38751  ELSEIF(isub.EQ.395) THEN
38752 C...g + g -> g + G*.
38753  kfgstr=kfpr(isub,2)
38754  kcgstr=pycomp(kfgstr)
38755  facg=comfac*3d0*parp(50)**2*as*sh/(32d0*paru(1)*sqm4)*
38756  & ((th2+th*uh+uh2)**2/(sh2*th*uh)+2d0*(th2/uh+uh2/th)/sh+
38757  & 3d0*(th/uh+uh/th)+2d0*(sh/uh+sh/th)+sh2/(th*uh))
38758 C...Propagators: as simulated in PYOFSH and as desired
38759  gmmg=pmas(kcgstr,1)*pmas(kcgstr,2)
38760  hbw4=gmmg/((sqm4-pmas(kcgstr,1)**2)**2+gmmg**2)
38761  CALL pywidt(kfgstr,sqm4,wdtp,wdte)
38762  hs=sqrt(sqm4)*wdtp(0)
38763  hf=sqrt(sqm4)*(wdte(0,1)+wdte(0,2)+wdte(0,4))
38764  hbw4c=hf/((sqm4-pmas(kcgstr,1)**2)**2+hs**2)
38765  facg=facg*hbw4c/hbw4
38766  IF(kfac(1,21)*kfac(2,21).NE.0) THEN
38767  nchn=nchn+1
38768  isig(nchn,1)=21
38769  isig(nchn,2)=21
38770  isig(nchn,3)=1
38771  sigh(nchn)=facg
38772  ENDIF
38773  ENDIF
38774  ELSEIF(isub.LE.500) THEN
38775  IF(isubsv.EQ.481) isub=482
38776 c... GENERIC 2->(1)->2
38777  IF(isub.EQ.482) THEN
38778  kfres=9900001
38779  kcres=pycomp(kfres)
38780  IF(kcres.EQ.0) RETURN
38781  idcy=mdcy(kcres,2)
38782  kcol=kchg(kcres,2)
38783  kcem=kchg(kcres,1)
38784  fact=comfac
38785  kcf1=pycomp(kfpr(isub,1))
38786  kcf2=pycomp(kfpr(isub,2))
38787  IF(isubsv.EQ.481) THEN
38788  sqmzr=pmas(kcres,1)**2
38789  CALL pywidt(kfres,sh,wdtp,wdte)
38790  hs=shr*wdtp(0)
38791  facbw=sh2/((sh-sqmzr)**2+hs**2)
38792  fact=fact*facbw
38793  ELSE
38794  sqmh=pmas(kcf1,1)**2
38795  gmmh=pmas(kcf1,1)*pmas(kcf1,2)
38796 C...Propagators: as simulated in PYOFSH and as desired
38797  hbw3=gmmh/((sqm3-sqmh)**2+gmmh**2)
38798  CALL pywidt(kfpr(isub,1),sqm3,wdtp,wdte)
38799  gmmh3=sqrt(sqm3)*wdtp(0)
38800  hbw3c=gmmh3/((sqm3-sqmh)**2+gmmh3**2)
38801  sqmh=pmas(kcf2,1)**2
38802  gmmh=pmas(kcf2,1)*pmas(kcf2,2)
38803  hbw4=gmmh/((sqm4-sqmh)**2+gmmh**2)
38804  CALL pywidt(kfpr(isub,2),sqm4,wdtp,wdte)
38805  gmmh4=sqrt(sqm4)*wdtp(0)
38806  hbw4c=gmmh4/((sqm4-sqmh)**2+gmmh4**2)
38807  fact=fact*(hbw3c/hbw3)*(hbw4c/hbw4)
38808  ENDIF
38809 
38810  kci1=abs(pycomp(kfdp(idcy,1)))
38811  kci2=abs(pycomp(kfdp(idcy,2)))
38812  jcol1=sign(kchg(kcf1,2),kfpr(isub,1))
38813  jcol2=sign(kchg(kcf2,2),kfpr(isub,2))
38814  IF(kcol.EQ.0) THEN
38815  ncol=1
38816  ELSEIF(kci1.EQ.21.AND.kci2.EQ.21.AND.kcol.EQ.2) THEN
38817  IF(jcol1.EQ.2.AND.jcol2.EQ.2) THEN
38818  ncol=3
38819  ELSE
38820  ncol=2
38821  ENDIF
38822  ELSEIF(kcol.EQ.-1.OR.kcol.EQ.1) THEN
38823  ncol=2
38824  ELSEIF(kci1.EQ.21.AND.kci2.EQ.21.AND.jcol1.EQ.0.AND.
38825  $ jcol2.EQ.0) THEN
38826  ncol=1
38827  ELSEIF(kcol.EQ.2.AND.((jcol1.EQ.0.AND.jcol2.EQ.2).OR.
38828  $ (jcol1.EQ.2.AND.jcol2.EQ.0))) THEN
38829  ncol=1
38830  ELSE
38831  ncol=2
38832  ENDIF
38833  DO 440 i=mmin1,mmax1
38834  IF(kfac(1,i).EQ.0) goto 440
38835  ip=i
38836  IF(ip.EQ.0) ip=21
38837  ia=abs(ip)
38838  DO 430 j=mmin2,mmax2
38839  IF(kfac(2,j).EQ.0) goto 430
38840  jp=j
38841  IF(jp.EQ.0) jp=21
38842  ja=abs(jp)
38843  IF((ia.EQ.kci1.AND.ja.EQ.kci2).OR.
38844  $ (ja.EQ.kci1.AND.ia.EQ.kci2)) THEN
38845  kchw=kchg(ia,1)*isign(1,i)+kchg(ja,1)*isign(1,j)
38846  IF(abs(kchw).EQ.abs(kcem)) THEN
38847  DO ii=1,ncol
38848  nchn=nchn+1
38849  isig(nchn,1)=ip
38850  isig(nchn,2)=jp
38851  isig(nchn,3)=ii
38852  sigh(nchn)=fact/ncol
38853  ENDDO
38854  ENDIF
38855  ENDIF
38856  430 CONTINUE
38857  440 CONTINUE
38858  ENDIF
38859  ENDIF
38860 
38861  RETURN
38862  END
38863 
38864 C*********************************************************************
38865 
38866 C...PYPDFU
38867 C...Gives electron, muon, tau, photon, pi+, neutron, proton and hyperon
38868 C...parton distributions according to a few different parametrizations.
38869 C...Note that what is coded is x times the probability distribution,
38870 C...i.e. xq(x,Q2) etc.
38871 
38872  SUBROUTINE pypdfu(KF,X,Q2,XPQ)
38873 
38874 C...Double precision and integer declarations.
38875  IMPLICIT DOUBLE PRECISION(a-h, o-z)
38876  IMPLICIT INTEGER(i-n)
38877  INTEGER pyk,pychge,pycomp
38878 C...Commonblocks.
38879  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
38880  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
38881  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
38882  common/pypars/mstp(200),parp(200),msti(200),pari(200)
38883  common/pyint1/mint(400),vint(400)
38884  common/pyint8/xpvmd(-6:6),xpanl(-6:6),xpanh(-6:6),xpbeh(-6:6),
38885  &xpdir(-6:6)
38886  common/pyint9/vxpvmd(-6:6),vxpanl(-6:6),vxpanh(-6:6),vxpdgm(-6:6)
38887  common/pyintm/kfival(2,3),nmi(2),imi(2,800,2),nvc(2,-6:6),
38888  & xassoc(2,-6:6,240),xpsvc(-6:6,-1:240),pvctot(2,-1:1),
38889  & xmi(2,240),pt2mi(240),imisep(0:240)
38890  SAVE /pyjets/,/pydat1/,/pydat2/,/pypars/,/pyint1/,/pyint8/,
38891  &/pyint9/,/pyintm/
38892 C...Local arrays.
38893  dimension xpq(-25:25),xpel(-25:25),xpga(-6:6),vxpga(-6:6),
38894  &xppi(-6:6),xppr(-6:6),xpval(-6:6),ppar(6,2)
38895  SAVE ppar
38896 
38897 C...Interface to PDFLIB.
38898  common/w50513/xmin,xmax,q2min,q2max
38899  SAVE /w50513/
38900  DOUBLE PRECISION xx,qq,upv,dnv,usea,dsea,str,chm,bot,top,glu,
38901  &value(20),xmin,xmax,q2min,q2max
38902  CHARACTER*20 parm(20)
38903  DATA value/20*0d0/,parm/20*' '/
38904 C--use nuclear pdf?
38905  common/npdf/mass,nset,eps09,initstr
38906  INTEGER nset
38907  DOUBLE PRECISION mass
38908  LOGICAL eps09
38909  CHARACTER*10 initstr
38910 
38911 C...Data related to Schuler-Sjostrand photon distributions.
38912  DATA alamga/0.2d0/, pmcga/1.3d0/, pmbga/4.6d0/
38913 
38914 C...Valence PDF momentum integral parametrizations PER PARTON!
38915  DATA (ppar(1,ipar),ipar=1,2) /0.385d0,1.60d0/
38916  DATA (ppar(2,ipar),ipar=1,2) /0.480d0,1.56d0/
38917  pavg(ifl,q2)=ppar(ifl,1)/(1d0+ppar(ifl,2)*
38918  &log(log(max(q2,1d0)/0.04d0)))
38919 
38920 C...Reset parton distributions.
38921  mint(92)=0
38922  DO 100 kfl=-25,25
38923  xpq(kfl)=0d0
38924  100 CONTINUE
38925  DO 110 kfl=-6,6
38926  xpval(kfl)=0d0
38927  110 CONTINUE
38928 
38929 C...Check x and particle species.
38930  IF(x.LE.0d0.OR.x.GE.1d0) THEN
38931  WRITE(mstu(11),5000) x
38932  goto 9999
38933  ENDIF
38934  kfa=iabs(kf)
38935  IF(kfa.NE.11.AND.kfa.NE.13.AND.kfa.NE.15.AND.kfa.NE.22.AND.
38936  &kfa.NE.211.AND.kfa.NE.2112.AND.kfa.NE.2212.AND.kfa.NE.3122.AND.
38937  &kfa.NE.3112.AND.kfa.NE.3212.AND.kfa.NE.3222.AND.kfa.NE.3312.AND.
38938  &kfa.NE.3322.AND.kfa.NE.3334.AND.kfa.NE.111.AND.kfa.NE.321.AND.
38939  &kfa.NE.310.AND.kfa.NE.130) THEN
38940  WRITE(mstu(11),5100) kf
38941  goto 9999
38942  ENDIF
38943 
38944 C...Electron (or muon or tau) parton distribution call.
38945  IF(kfa.EQ.11.OR.kfa.EQ.13.OR.kfa.EQ.15) THEN
38946  CALL pypdel(kfa,x,q2,xpel)
38947  DO 120 kfl=-25,25
38948  xpq(kfl)=xpel(kfl)
38949  120 CONTINUE
38950 
38951 C...Photon parton distribution call (VDM+anomalous).
38952  ELSEIF(kfa.EQ.22.AND.mint(109).LE.1) THEN
38953  IF(mstp(56).EQ.1.AND.mstp(55).EQ.1) THEN
38954  CALL pypdga(x,q2,xpga)
38955  DO 130 kfl=-6,6
38956  xpq(kfl)=xpga(kfl)
38957  130 CONTINUE
38958  xpvu=4d0*(xpq(2)-xpq(1))/3d0
38959  xpval(1)=xpvu/4d0
38960  xpval(2)=xpvu
38961  xpval(3)=min(xpq(3),xpvu/4d0)
38962  xpval(4)=min(xpq(4),xpvu)
38963  xpval(5)=min(xpq(5),xpvu/4d0)
38964  xpval(-1)=xpval(1)
38965  xpval(-2)=xpval(2)
38966  xpval(-3)=xpval(3)
38967  xpval(-4)=xpval(4)
38968  xpval(-5)=xpval(5)
38969  ELSEIF(mstp(56).EQ.1.AND.mstp(55).GE.5.AND.mstp(55).LE.8) THEN
38970  q2mx=q2
38971  p2mx=0.36d0
38972  IF(mstp(55).GE.7) p2mx=4.0d0
38973  IF(mstp(57).EQ.0) q2mx=p2mx
38974  p2=0d0
38975  IF(vint(120).LT.0d0) p2=vint(120)**2
38976  CALL pyggam(mstp(55)-4,x,q2mx,p2,mstp(60),f2gam,xpga)
38977  DO 140 kfl=-6,6
38978  xpq(kfl)=xpga(kfl)
38979  xpval(kfl)=vxpdgm(kfl)
38980  140 CONTINUE
38981  vint(231)=p2mx
38982  ELSEIF(mstp(56).EQ.1.AND.mstp(55).GE.9.AND.mstp(55).LE.12) THEN
38983  q2mx=q2
38984  p2mx=0.36d0
38985  IF(mstp(55).GE.11) p2mx=4.0d0
38986  IF(mstp(57).EQ.0) q2mx=p2mx
38987  p2=0d0
38988  IF(vint(120).LT.0d0) p2=vint(120)**2
38989  CALL pyggam(mstp(55)-8,x,q2mx,p2,mstp(60),f2gam,xpga)
38990  DO 150 kfl=-6,6
38991  xpq(kfl)=xpvmd(kfl)+xpanl(kfl)+xpbeh(kfl)+xpdir(kfl)
38992  xpval(kfl)=vxpvmd(kfl)+vxpanl(kfl)+xpbeh(kfl)+xpdir(kfl)
38993  150 CONTINUE
38994  vint(231)=p2mx
38995  ELSEIF(mstp(56).EQ.2) THEN
38996 C...Call PDFLIB parton distributions.
38997  parm(1)='NPTYPE'
38998  value(1)=3
38999  parm(2)='NGROUP'
39000  value(2)=mstp(55)/1000
39001  parm(3)='NSET'
39002  value(3)=mod(mstp(55),1000)
39003  IF(mint(93).NE.3000000+mstp(55)) THEN
39004  CALL pdfset(parm,value)
39005  mint(93)=3000000+mstp(55)
39006  ENDIF
39007  xx=x
39008  qq2=max(0d0,q2min,q2)
39009  IF(mstp(57).EQ.0) qq2=q2min
39010  p2=0d0
39011  IF(vint(120).LT.0d0) p2=vint(120)**2
39012  ip2=mstp(60)
39013  IF(mstp(55).EQ.5004) THEN
39014  IF(5d0*p2.LT.qq2.AND.
39015  & qq2.GT.0.6d0.AND.qq2.LT.5d4.AND.
39016  & p2.GE.0d0.AND.p2.LT.10d0.AND.
39017  & xx.GT.1d-4.AND.xx.LT.1d0) THEN
39018  CALL structp(xx,qq2,p2,ip2,upv,dnv,usea,dsea,str,chm,
39019  & bot,top,glu)
39020  ELSE
39021  upv=0d0
39022  dnv=0d0
39023  usea=0d0
39024  dsea=0d0
39025  str=0d0
39026  chm=0d0
39027  bot=0d0
39028  top=0d0
39029  glu=0d0
39030  ENDIF
39031  ELSE
39032  IF(p2.LT.qq2) THEN
39033  CALL structp(xx,qq2,p2,ip2,upv,dnv,usea,dsea,str,chm,
39034  & bot,top,glu)
39035  ELSE
39036  upv=0d0
39037  dnv=0d0
39038  usea=0d0
39039  dsea=0d0
39040  str=0d0
39041  chm=0d0
39042  bot=0d0
39043  top=0d0
39044  glu=0d0
39045  ENDIF
39046  ENDIF
39047  vint(231)=q2min
39048  xpq(0)=glu
39049  xpq(1)=dnv
39050  xpq(-1)=dnv
39051  xpq(2)=upv
39052  xpq(-2)=upv
39053  xpq(3)=str
39054  xpq(-3)=str
39055  xpq(4)=chm
39056  xpq(-4)=chm
39057  xpq(5)=bot
39058  xpq(-5)=bot
39059  xpq(6)=top
39060  xpq(-6)=top
39061  xpvu=4d0*(xpq(2)-xpq(1))/3d0
39062  xpval(1)=xpvu/4d0
39063  xpval(2)=xpvu
39064  xpval(3)=min(xpq(3),xpvu/4d0)
39065  xpval(4)=min(xpq(4),xpvu)
39066  xpval(5)=min(xpq(5),xpvu/4d0)
39067  xpval(-1)=xpval(1)
39068  xpval(-2)=xpval(2)
39069  xpval(-3)=xpval(3)
39070  xpval(-4)=xpval(4)
39071  xpval(-5)=xpval(5)
39072  ELSE
39073  WRITE(mstu(11),5200) kf,mstp(56),mstp(55)
39074  ENDIF
39075 
39076 C...Pion/gammaVDM parton distribution call.
39077  ELSEIF(kfa.EQ.211.OR.kfa.EQ.111.OR.kfa.EQ.321.OR.kfa.EQ.130.OR.
39078  &kfa.EQ.310.OR.(kfa.EQ.22.AND.mint(109).EQ.2)) THEN
39079  IF(kfa.EQ.22.AND.mstp(56).EQ.1.AND.mstp(55).GE.5.AND.
39080  & mstp(55).LE.12) THEN
39081  iset=1+mod(mstp(55)-1,4)
39082  q2mx=q2
39083  p2mx=0.36d0
39084  IF(iset.GE.3) p2mx=4.0d0
39085  IF(mstp(57).EQ.0) q2mx=p2mx
39086  p2=0d0
39087  IF(vint(120).LT.0d0) p2=vint(120)**2
39088  CALL pyggam(iset,x,q2mx,p2,mstp(60),f2gam,xpga)
39089  DO 160 kfl=-6,6
39090  xpq(kfl)=xpvmd(kfl)
39091  xpval(kfl)=vxpvmd(kfl)
39092  160 CONTINUE
39093  vint(231)=p2mx
39094  ELSEIF(mstp(54).EQ.1.AND.mstp(53).GE.1.AND.mstp(53).LE.3) THEN
39095  CALL pypdpi(x,q2,xppi)
39096  DO 170 kfl=-6,6
39097  xpq(kfl)=xppi(kfl)
39098  170 CONTINUE
39099  xpval(2)=xpq(2)-xpq(-2)
39100  xpval(-1)=xpq(-1)-xpq(1)
39101  ELSEIF(mstp(54).EQ.2) THEN
39102 C...Call PDFLIB parton distributions.
39103  parm(1)='NPTYPE'
39104  value(1)=2
39105  parm(2)='NGROUP'
39106  value(2)=mstp(53)/1000
39107  parm(3)='NSET'
39108  value(3)=mod(mstp(53),1000)
39109  IF(mint(93).NE.2000000+mstp(53)) THEN
39110  CALL pdfset(parm,value)
39111  mint(93)=2000000+mstp(53)
39112  ENDIF
39113  xx=x
39114  qq=sqrt(max(0d0,q2min,q2))
39115  IF(mstp(57).EQ.0) qq=sqrt(q2min)
39116  CALL structm(xx,qq,upv,dnv,usea,dsea,str,chm,bot,top,glu)
39117  vint(231)=q2min
39118  xpq(0)=glu
39119  xpq(1)=dsea
39120  xpq(-1)=upv+dsea
39121  xpq(2)=upv+usea
39122  xpq(-2)=usea
39123  xpq(3)=str
39124  xpq(-3)=str
39125  xpq(4)=chm
39126  xpq(-4)=chm
39127  xpq(5)=bot
39128  xpq(-5)=bot
39129  xpq(6)=top
39130  xpq(-6)=top
39131  xpval(2)=upv
39132  xpval(-1)=upv
39133  ELSE
39134  WRITE(mstu(11),5200) kf,mstp(54),mstp(53)
39135  ENDIF
39136 
39137 C...Anomalous photon parton distribution call.
39138  ELSEIF(kfa.EQ.22.AND.mint(109).EQ.3) THEN
39139  q2mx=q2
39140  p2mx=parp(15)**2
39141  IF(mstp(56).EQ.1.AND.mstp(55).LE.8) THEN
39142  IF(mstp(55).EQ.5.OR.mstp(55).EQ.6) p2mx=0.36d0
39143  IF(mstp(55).EQ.7.OR.mstp(55).EQ.8) p2mx=4.0d0
39144  IF(mstp(57).EQ.0) q2mx=p2mx
39145  p2=0d0
39146  IF(vint(120).LT.0d0) p2=vint(120)**2
39147  CALL pyggam(mstp(55)-4,x,q2mx,p2,mstp(60),f2gm,xpga)
39148  DO 180 kfl=-6,6
39149  xpq(kfl)=xpanl(kfl)+xpanh(kfl)
39150  xpval(kfl)=vxpanl(kfl)+vxpanh(kfl)
39151  180 CONTINUE
39152  vint(231)=p2mx
39153  ELSEIF(mstp(56).EQ.1) THEN
39154  IF(mstp(55).EQ.9.OR.mstp(55).EQ.10) p2mx=0.36d0
39155  IF(mstp(55).EQ.11.OR.mstp(55).EQ.12) p2mx=4.0d0
39156  IF(mstp(57).EQ.0) q2mx=p2mx
39157  p2=0d0
39158  IF(vint(120).LT.0d0) p2=vint(120)**2
39159  CALL pyggam(mstp(55)-8,x,q2mx,p2,mstp(60),f2gm,xpga)
39160  DO 190 kfl=-6,6
39161  xpq(kfl)=max(0d0,xpanl(kfl)+xpbeh(kfl)+xpdir(kfl))
39162  xpval(kfl)=max(0d0,vxpanl(kfl)+xpbeh(kfl)+xpdir(kfl))
39163  190 CONTINUE
39164  vint(231)=p2mx
39165  ELSEIF(mstp(56).EQ.2) THEN
39166  IF(mstp(57).EQ.0) q2mx=p2mx
39167  CALL pygano(0,x,q2mx,p2mx,alamga,xpga,vxpga)
39168  DO 200 kfl=-6,6
39169  xpq(kfl)=xpga(kfl)
39170  xpval(kfl)=vxpga(kfl)
39171  200 CONTINUE
39172  vint(231)=p2mx
39173  ELSEIF(mstp(55).GE.1.AND.mstp(55).LE.5) THEN
39174  IF(mstp(57).EQ.0) q2mx=p2mx
39175  CALL pygvmd(0,mstp(55),x,q2mx,p2mx,parp(1),xpga,vxpga)
39176  DO 210 kfl=-6,6
39177  xpq(kfl)=xpga(kfl)
39178  xpval(kfl)=vxpga(kfl)
39179  210 CONTINUE
39180  vint(231)=p2mx
39181  ELSE
39182  220 rkf=11d0*pyr(0)
39183  kfr=1
39184  IF(rkf.GT.1d0) kfr=2
39185  IF(rkf.GT.5d0) kfr=3
39186  IF(rkf.GT.6d0) kfr=4
39187  IF(rkf.GT.10d0) kfr=5
39188  IF(kfr.EQ.4.AND.q2.LT.pmcga**2) goto 220
39189  IF(kfr.EQ.5.AND.q2.LT.pmbga**2) goto 220
39190  IF(mstp(57).EQ.0) q2mx=p2mx
39191  CALL pygvmd(0,kfr,x,q2mx,p2mx,parp(1),xpga,vxpga)
39192  DO 230 kfl=-6,6
39193  xpq(kfl)=xpga(kfl)
39194  xpval(kfl)=vxpga(kfl)
39195  230 CONTINUE
39196  vint(231)=p2mx
39197  ENDIF
39198 
39199 C...Proton parton distribution call.
39200  ELSE
39201  IF(mstp(52).EQ.1.AND.mstp(51).GE.1.AND.mstp(51).LE.20) THEN
39202  CALL pypdpr(x,q2,xppr)
39203  DO 240 kfl=-6,6
39204  xpq(kfl)=xppr(kfl)
39205  240 CONTINUE
39206 C...Force VAL > 0 (can be < 0 at very small Q2 and small x apparently)
39207  xpval(1)=max(0d0,xpq(1)-xpq(-1))
39208  xpval(2)=max(0d0,xpq(2)-xpq(-2))
39209  ELSEIF(mstp(52).EQ.2) THEN
39210 C...Call PDFLIB parton distributions.
39211  parm(1)='NPTYPE'
39212  value(1)=1
39213  parm(2)='NGROUP'
39214  value(2)=mstp(51)/1000
39215  parm(3)='NSET'
39216  value(3)=mod(mstp(51),1000)
39217  IF(mint(93).NE.1000000+mstp(51)) THEN
39218  call setlhaparm('SILENT')
39219  CALL pdfset(parm,value)
39220  mint(93)=1000000+mstp(51)
39221  ENDIF
39222  xx=x
39223  qq=sqrt(max(0d0,q2min,q2))
39224  IF(mstp(57).EQ.0) qq=sqrt(q2min)
39225  IF(eps09)THEN
39226  call setlhaparm(initstr)
39227  CALL structa(xx,qq,mass,upv,dnv,usea,dsea,str,chm,bot,top,
39228  & glu)
39229  ELSE
39230  CALL structm(xx,qq,upv,dnv,usea,dsea,str,chm,bot,top,glu)
39231  ENDIF
39232  vint(231)=q2min
39233  xpq(0)=glu
39234  xpq(1)=dnv+dsea
39235  xpq(-1)=dsea
39236  xpq(2)=upv+usea
39237  xpq(-2)=usea
39238  xpq(3)=str
39239  xpq(-3)=str
39240  xpq(4)=chm
39241  xpq(-4)=chm
39242  xpq(5)=bot
39243  xpq(-5)=bot
39244  xpq(6)=top
39245  xpq(-6)=top
39246  xpval(1)=dnv
39247  xpval(2)=upv
39248  ELSE
39249  WRITE(mstu(11),5200) kf,mstp(52),mstp(51)
39250  ENDIF
39251  ENDIF
39252 
39253 C...Isospin average for pi0/gammaVDM.
39254  IF(kfa.EQ.111.OR.(kfa.EQ.22.AND.mint(109).EQ.2)) THEN
39255  IF(kfa.EQ.22.AND.mstp(55).GE.5.AND.mstp(55).LE.12) THEN
39256  xpv=xpq(2)-xpq(1)
39257  xpq(2)=xpq(1)
39258  xpq(-2)=xpq(-1)
39259  ELSE
39260  xps=0.5d0*(xpq(1)+xpq(-2))
39261  xpv=0.5d0*(xpq(2)+xpq(-1))-xps
39262  xpq(2)=xps
39263  xpq(-1)=xps
39264  ENDIF
39265  xpvl=0.5d0*(xpval(1)+xpval(2)+xpval(-1)+xpval(-2))+
39266  & xpval(3)+xpval(4)+xpval(5)
39267  DO 250 kfl=-6,6
39268  xpval(kfl)=0d0
39269  250 CONTINUE
39270  IF(kfa.EQ.22.AND.mint(105).LE.223) THEN
39271  xpq(1)=xpq(1)+0.2d0*xpv
39272  xpq(2)=xpq(2)+0.8d0*xpv
39273  xpval(1)=0.2d0*xpvl
39274  xpval(2)=0.8d0*xpvl
39275  ELSEIF(kfa.EQ.22.AND.mint(105).EQ.333) THEN
39276  xpq(3)=xpq(3)+xpv
39277  xpval(3)=xpvl
39278  ELSEIF(kfa.EQ.22.AND.mint(105).EQ.443) THEN
39279  xpq(4)=xpq(4)+xpv
39280  xpval(4)=xpvl
39281  IF(mstp(55).GE.9) THEN
39282  DO 260 kfl=-6,6
39283  xpq(kfl)=0d0
39284  260 CONTINUE
39285  ENDIF
39286  ELSE
39287  xpq(1)=xpq(1)+0.5d0*xpv
39288  xpq(2)=xpq(2)+0.5d0*xpv
39289  xpval(1)=0.5d0*xpvl
39290  xpval(2)=0.5d0*xpvl
39291  ENDIF
39292  DO 270 kfl=1,6
39293  xpq(-kfl)=xpq(kfl)
39294  xpval(-kfl)=xpval(kfl)
39295  270 CONTINUE
39296 
39297 C...Rescale for gammaVDM by effective gamma -> rho coupling.
39298 C+++Do not rescale?
39299  IF(kfa.EQ.22.AND.mint(109).EQ.2.AND..NOT.(mstp(56).EQ.1
39300  & .AND.mstp(55).GE.5.AND.mstp(55).LE.12)) THEN
39301  DO 280 kfl=-6,6
39302  xpq(kfl)=vint(281)*xpq(kfl)
39303  xpval(kfl)=vint(281)*xpval(kfl)
39304  280 CONTINUE
39305  vint(232)=vint(281)*xpv
39306  ENDIF
39307 
39308 C...Simple recipes for kaons.
39309  ELSEIF(kfa.EQ.321) THEN
39310  xpq(-3)=xpq(-3)+xpq(-1)-xpq(1)
39311  xpq(-1)=xpq(1)
39312  xpval(-3)=xpval(-1)
39313  xpval(-1)=0d0
39314  ELSEIF(kfa.EQ.130.OR.kfa.EQ.310) THEN
39315  xps=0.5d0*(xpq(1)+xpq(-2))
39316  xpv=0.5d0*(xpq(2)+xpq(-1))-xps
39317  xpq(2)=xps
39318  xpq(-1)=xps
39319  xpq(1)=xpq(1)+0.5d0*xpv
39320  xpq(-1)=xpq(-1)+0.5d0*xpv
39321  xpq(3)=xpq(3)+0.5d0*xpv
39322  xpq(-3)=xpq(-3)+0.5d0*xpv
39323  xpv=0.5d0*(xpval(2)+xpval(-1))
39324  xpval(2)=0d0
39325  xpval(-1)=0d0
39326  xpval(1)=0.5d0*xpv
39327  xpval(-1)=0.5d0*xpv
39328  xpval(3)=0.5d0*xpv
39329  xpval(-3)=0.5d0*xpv
39330 
39331 C...Isospin conjugation for neutron.
39332  ELSEIF(kfa.EQ.2112) THEN
39333  xpsv=xpq(1)
39334  xpq(1)=xpq(2)
39335  xpq(2)=xpsv
39336  xpsv=xpq(-1)
39337  xpq(-1)=xpq(-2)
39338  xpq(-2)=xpsv
39339  xpsv=xpval(1)
39340  xpval(1)=xpval(2)
39341  xpval(2)=xpsv
39342 
39343 C...Simple recipes for hyperon (average valence parton distribution).
39344  ELSEIF(kfa.EQ.3122.OR.kfa.EQ.3112.OR.kfa.EQ.3212.OR.kfa.EQ.3222
39345  & .OR.kfa.EQ.3312.OR.kfa.EQ.3322.OR.kfa.EQ.3334) THEN
39346  xpv=(xpq(1)+xpq(2)-xpq(-1)-xpq(-2))/3d0
39347  xps=0.5d0*(xpq(-1)+xpq(-2))
39348  xpq(1)=xps
39349  xpq(2)=xps
39350  xpq(-1)=xps
39351  xpq(-2)=xps
39352  xpq(kfa/1000)=xpq(kfa/1000)+xpv
39353  xpq(mod(kfa/100,10))=xpq(mod(kfa/100,10))+xpv
39354  xpq(mod(kfa/10,10))=xpq(mod(kfa/10,10))+xpv
39355  xpv=(xpval(1)+xpval(2))/3d0
39356  xpval(1)=0d0
39357  xpval(2)=0d0
39358  xpval(kfa/1000)=xpval(kfa/1000)+xpv
39359  xpval(mod(kfa/100,10))=xpval(mod(kfa/100,10))+xpv
39360  xpval(mod(kfa/10,10))=xpval(mod(kfa/10,10))+xpv
39361  ENDIF
39362 
39363 C...Charge conjugation for antiparticle.
39364  IF(kf.LT.0) THEN
39365  DO 290 kfl=1,25
39366  IF(kfl.EQ.21.OR.kfl.EQ.22.OR.kfl.EQ.23.OR.kfl.EQ.25) goto 290
39367  xpsv=xpq(kfl)
39368  xpq(kfl)=xpq(-kfl)
39369  xpq(-kfl)=xpsv
39370  290 CONTINUE
39371  DO 300 kfl=1,6
39372  xpsv=xpval(kfl)
39373  xpval(kfl)=xpval(-kfl)
39374  xpval(-kfl)=xpsv
39375  300 CONTINUE
39376  ENDIF
39377 
39378 C...MULTIPLE INTERACTIONS - PDF RESHAPING.
39379 C...Set side.
39380  js=mint(30)
39381 C...Only reshape PDFs for the non-first interactions;
39382 C...But need valence/sea separation already from first interaction.
39383  IF ((js.EQ.1.OR.js.EQ.2).AND.mint(35).GE.2) THEN
39384  kfvsel=kfival(js,1)
39385 C...If valence quark kicked out of pi0 or gamma then that decides
39386 C...whether we should consider state as d dbar, u ubar, s sbar, etc.
39387  IF(kfvsel.NE.0.AND.(kfa.EQ.111.OR.kfa.EQ.22)) THEN
39388  xpvl=0d0
39389  DO 310 kfl=1,6
39390  xpvl=xpvl+xpval(kfl)
39391  xpq(kfl)=max(0d0,xpq(kfl)-xpval(kfl))
39392  xpval(kfl)=0d0
39393  310 CONTINUE
39394  xpq(iabs(kfvsel))=xpq(iabs(kfvsel))+xpvl
39395  xpval(iabs(kfvsel))=xpvl
39396  DO 320 kfl=1,6
39397  xpq(-kfl)=xpq(kfl)
39398  xpval(-kfl)=xpval(kfl)
39399  320 CONTINUE
39400 
39401 C...If valence quark kicked out of K0S or K0S then that decides whether
39402 C...we should consider state as d sbar or s dbar.
39403  ELSEIF(kfvsel.NE.0.AND.(kfa.EQ.130.OR.kfa.EQ.310)) THEN
39404  kfs=1
39405  IF(kfvsel.EQ.-1.OR.kfvsel.EQ.3) kfs=-1
39406  xpq(kfs)=xpq(kfs)+xpval(-kfs)
39407  xpval(kfs)=xpval(kfs)+xpval(-kfs)
39408  xpq(-kfs)=max(0d0,xpq(-kfs)-xpval(-kfs))
39409  xpval(-kfs)=0d0
39410  kfs=-3*kfs
39411  xpq(kfs)=xpq(kfs)+xpval(-kfs)
39412  xpval(kfs)=xpval(kfs)+xpval(-kfs)
39413  xpq(-kfs)=max(0d0,xpq(-kfs)-xpval(-kfs))
39414  xpval(-kfs)=0d0
39415  ENDIF
39416 
39417 C...XPQ distributions are nominal for a (signed) beam particle
39418 C...of KF type, with 1-Sum(x_prev) rescaled to 1.
39419  cmpfac=1d0
39420  nresc=0
39421  345 nresc=nresc+1
39422  pvctot(js,-1)=0d0
39423  pvctot(js, 0)=0d0
39424  pvctot(js, 1)=0d0
39425  DO 350 ifl=-6,6
39426  IF(ifl.EQ.0) goto 350
39427 
39428 C...Count up number of original IFL valence quarks.
39429  ivorg=0
39430  IF(kfival(js,1).EQ.ifl) ivorg=ivorg+1
39431  IF(kfival(js,2).EQ.ifl) ivorg=ivorg+1
39432  IF(kfival(js,3).EQ.ifl) ivorg=ivorg+1
39433 C...For pi0/gamma/K0S/K0L without valence flavour decided yet, here
39434 C...bookkeep as if d dbar (for total momentum sum in valence sector).
39435  IF(kfival(js,1).EQ.0.AND.iabs(ifl).EQ.1) ivorg=1
39436 C...Count down number of remaining IFL valence quarks. Skip current
39437 C...interaction initiator.
39438  ivrem=ivorg
39439  DO 330 i1=1,nmi(js)
39440  IF (i1.EQ.mint(36)) goto 330
39441  IF (k(imi(js,i1,1),2).EQ.ifl.AND.imi(js,i1,2).EQ.0)
39442  & ivrem=ivrem-1
39443  330 CONTINUE
39444 
39445 C...Separate out original VALENCE and SEA content.
39446  val=xpval(ifl)
39447  sea=max(0d0,xpq(ifl)-val)
39448  xpsvc(ifl,0)=val
39449  xpsvc(ifl,-1)=sea
39450 
39451 C...Rescale valence content if changed.
39452  IF (ivorg.NE.0.AND.ivrem.NE.ivorg) xpsvc(ifl,0)=
39453  & (val*ivrem)/ivorg
39454 
39455 C...Momentum integrals of original and removed valence quarks.
39456  IF(ivorg.NE.0) THEN
39457 C...For p/n/pbar/nbar beams can split into d_val and u_val.
39458 C...Isospin conjugation for neutrons
39459  IF(kfa.EQ.2212.OR.kfa.EQ.2112) THEN
39460  iaflp=iabs(ifl)
39461  IF (kfa.EQ.2112) iaflp=3-iaflp
39462  vpavg=pavg(iaflp,q2)
39463 C...For other baryons average d_val and u_val, like for PDFs.
39464  ELSEIF(kfa.GT.1000) THEN
39465  vpavg=(pavg(1,q2)+2d0*pavg(2,q2))/3d0
39466 C...For mesons and photon average d_val and u_val and scale by 3/2.
39467 C...Very crude, especially for photon.
39468  ELSE
39469  vpavg=0.5d0*(pavg(1,q2)+2d0*pavg(2,q2))
39470  ENDIF
39471  pvctot(js,-1)=pvctot(js,-1)+ivorg*vpavg
39472  pvctot(js, 0)=pvctot(js, 0)+(ivorg-ivrem)*vpavg
39473  ENDIF
39474 
39475 C...Now add companions (at X with partner having been at Z=XASSOC).
39476 C...NOTE: due to the assumed simple x scaling, the partner was at what
39477 C...corresponds to a higher Z than XASSOC, if there were intermediate
39478 C...scatterings. Nothing done about that for the moment.
39479  DO 340 ivc=1,nvc(js,ifl)
39480 C...Skip companions that have been kicked out
39481  IF (xassoc(js,ifl,ivc).LE.0d0) THEN
39482  xpsvc(ifl,ivc)=0d0
39483  goto 340
39484  ELSE
39485 C...Momentum fraction of the partner quark.
39486 C...Use rescaled YS = XS/(1-Sum_rest) where X and XS are not in "rest".
39487  xs=xassoc(js,ifl,ivc)
39488  xrem=vint(142+js)
39489  ys=xs/(xrem+xs)
39490 C...Momentum fraction of the companion quark.
39491 C...Rescale from X = x/XREM to Y = x/(1-Sum_rest) -> factor (1-YS).
39492  y=x*(1d0-ys)
39493  xpsvc(ifl,ivc)=pyfcmp(y/cmpfac,ys/cmpfac,mstp(87))
39494 C...Add to momentum sum, with rescaling compensation factor.
39495  xcfac=(xrem+xs)/xrem*cmpfac
39496  pvctot(js,1)=pvctot(js,1)+xcfac*pypcmp(ys/cmpfac,mstp(87))
39497  ENDIF
39498  340 CONTINUE
39499  350 CONTINUE
39500 
39501 C...Wait until all flavours treated, then rescale seas and gluon.
39502  xpsvc(0,-1)=xpq(0)
39503  xpsvc(0,0)=0d0
39504  rsfac=1d0+(pvctot(js,0)-pvctot(js,1))/(1d0-pvctot(js,-1))
39505  IF (rsfac.LE.0d0) THEN
39506 C...First calculate factor needed to exactly restore pz cons.
39507  IF (nresc.EQ.1) cmpfac =
39508  & (1d0-(pvctot(js,-1)-pvctot(js,0)))/pvctot(js,1)
39509 C...Add a bit of headroom
39510  cmpfac=0.99*cmpfac
39511 C...Try a few times if more headroom is needed, then print error message.
39512  IF (nresc.LE.10) goto 345
39513  CALL pyerrm(15,
39514  & '(PYPDFU:) Negative reshaping factor persists!')
39515  WRITE(mstu(11),5300) (pvctot(js,itmp),itmp=-1,1), rsfac
39516  rsfac=0d0
39517  ENDIF
39518  DO 370 ifl=-6,6
39519  xpsvc(ifl,-1)=rsfac*xpsvc(ifl,-1)
39520 C...Also store resulting distributions in XPQ
39521  xpq(ifl)=0d0
39522  DO 360 isvc=-1,nvc(js,ifl)
39523  xpq(ifl)=xpq(ifl)+xpsvc(ifl,isvc)
39524  360 CONTINUE
39525  370 CONTINUE
39526 C...Save companion reweighting factor for PYPTIS.
39527  vint(140)=cmpfac
39528  ENDIF
39529 
39530 
39531 C...Allow gluon also in position 21.
39532  xpq(21)=xpq(0)
39533 
39534 C...Check positivity and reset above maximum allowed flavour.
39535  DO 380 kfl=-25,25
39536  xpq(kfl)=max(0d0,xpq(kfl))
39537  IF(iabs(kfl).GT.mstp(58).AND.iabs(kfl).LE.8) xpq(kfl)=0d0
39538  380 CONTINUE
39539 
39540 C...Formats for error printouts.
39541  5000 FORMAT(' Error: x value outside physical range; x =',1p,d12.3)
39542  5100 FORMAT(' Error: illegal particle code for parton distribution;',
39543  &' KF =',i5)
39544  5200 FORMAT(' Error: unknown parton distribution; KF, library, set =',
39545  &3i5)
39546  5300 FORMAT(' Original valence momentum fraction : ',f6.3/
39547  & ' Removed valence momentum fraction : ',f6.3/
39548  & ' Added companion momentum fraction : ',f6.3/
39549  & ' Resulting rescale factor : ',f6.3)
39550 
39551 C...Reset side pointer and return
39552  9999 mint(30)=0
39553 
39554  RETURN
39555  END
39556 
39557 C*********************************************************************
39558 
39559 C...PYPDFL
39560 C...Gives proton parton distribution at small x and/or Q^2 according to
39561 C...correct limiting behaviour.
39562 
39563  SUBROUTINE pypdfl(KF,X,Q2,XPQ)
39564 
39565 C...Double precision and integer declarations.
39566  IMPLICIT DOUBLE PRECISION(a-h, o-z)
39567  IMPLICIT INTEGER(i-n)
39568  INTEGER pyk,pychge,pycomp
39569 C...Commonblocks.
39570  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
39571  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
39572  common/pypars/mstp(200),parp(200),msti(200),pari(200)
39573  common/pyint1/mint(400),vint(400)
39574  SAVE /pydat1/,/pydat2/,/pypars/,/pyint1/
39575 C...Local arrays.
39576  dimension xpq(-25:25),xpa(-25:25),xpb(-25:25),wtsb(-3:3)
39577  DATA rmr/0.92d0/,rmp/0.38d0/,wtsb/0.5d0,1d0,1d0,5d0,1d0,1d0,0.5d0/
39578 
39579 C...Send everything but protons/neutrons/VMD pions directly to PYPDFU.
39580  mint(92)=0
39581  kfa=iabs(kf)
39582  iacc=0
39583  IF((kfa.EQ.2212.OR.kfa.EQ.2112).AND.mstp(57).GE.2) iacc=1
39584  IF(kfa.EQ.211.AND.mstp(57).GE.3) iacc=1
39585  IF(kfa.EQ.22.AND.mint(109).EQ.2.AND.mstp(57).GE.3) iacc=1
39586  IF(iacc.EQ.0) THEN
39587  CALL pypdfu(kf,x,q2,xpq)
39588  RETURN
39589  ENDIF
39590 
39591 C...Reset. Check x.
39592  DO 100 kfl=-25,25
39593  xpq(kfl)=0d0
39594  100 CONTINUE
39595  IF(x.LE.0d0.OR.x.GE.1d0) THEN
39596  WRITE(mstu(11),5000) x
39597  RETURN
39598  ENDIF
39599 
39600 C...Define valence content.
39601  kfc=kf
39602  nv1=2
39603  nv2=1
39604  IF(kf.EQ.2212) THEN
39605  kfv1=2
39606  kfv2=1
39607  ELSEIF(kf.EQ.-2212) THEN
39608  kfv1=-2
39609  kfv2=-1
39610  ELSEIF(kf.EQ.2112) THEN
39611  kfv1=1
39612  kfv2=2
39613  ELSEIF(kf.EQ.-2112) THEN
39614  kfv1=-1
39615  kfv2=-2
39616  ELSEIF(kf.EQ.211) THEN
39617  nv1=1
39618  kfv1=2
39619  kfv2=-1
39620  ELSEIF(kf.EQ.-211) THEN
39621  nv1=1
39622  kfv1=-2
39623  kfv2=1
39624  ELSEIF(mint(105).LE.223) THEN
39625  kfv1=1
39626  wtv1=0.2d0
39627  kfv2=2
39628  wtv2=0.8d0
39629  ELSEIF(mint(105).EQ.333) THEN
39630  kfv1=3
39631  wtv1=1.0d0
39632  kfv2=1
39633  wtv2=0.0d0
39634  ELSEIF(mint(105).EQ.443) THEN
39635  kfv1=4
39636  wtv1=1.0d0
39637  kfv2=1
39638  wtv2=0.0d0
39639  ENDIF
39640 
39641 C...Do naive evaluation and find min Q^2, boundary Q^2 and x_0.
39642  mint30=mint(30)
39643  CALL pypdfu(kfc,x,q2,xpa)
39644  q2mn=max(3d0,vint(231))
39645  q2b=2d0+0.052d0**2*exp(3.56d0*sqrt(max(0d0,-log(3d0*x))))
39646  xmn=exp(-(log((q2mn-2d0)/0.052d0**2)/3.56d0)**2)/3d0
39647 
39648 C...Large Q2 and large x: naive call is enough.
39649  IF(q2.GT.q2mn.AND.q2.GT.q2b) THEN
39650  DO 110 kfl=-25,25
39651  xpq(kfl)=xpa(kfl)
39652  110 CONTINUE
39653  mint(92)=1
39654 
39655 C...Small Q2 and large x: dampen boundary value.
39656  ELSEIF(x.GT.xmn) THEN
39657 
39658 C...Evaluate at boundary and define dampening factors.
39659  mint(30)=mint30
39660  CALL pypdfu(kfc,x,q2mn,xpa)
39661  fv=(q2*(q2mn+rmr)/(q2mn*(q2+rmr)))**(0.55d0*(1d0-x)/(1d0-xmn))
39662  fs=(q2*(q2mn+rmp)/(q2mn*(q2+rmp)))**1.08d0
39663 
39664 C...Separate valence and sea parts of parton distribution.
39665  IF(kfa.NE.22) THEN
39666  xfv1=xpa(kfv1)-xpa(-kfv1)
39667  xpa(kfv1)=xpa(-kfv1)
39668  xfv2=xpa(kfv2)-xpa(-kfv2)
39669  xpa(kfv2)=xpa(-kfv2)
39670  ELSE
39671  xpa(kfv1)=xpa(kfv1)-wtv1*vint(232)
39672  xpa(-kfv1)=xpa(-kfv1)-wtv1*vint(232)
39673  xpa(kfv2)=xpa(kfv2)-wtv2*vint(232)
39674  xpa(-kfv2)=xpa(-kfv2)-wtv2*vint(232)
39675  ENDIF
39676 
39677 C...Dampen valence and sea separately. Put back together.
39678  DO 120 kfl=-25,25
39679  xpq(kfl)=fs*xpa(kfl)
39680  120 CONTINUE
39681  IF(kfa.NE.22) THEN
39682  xpq(kfv1)=xpq(kfv1)+fv*xfv1
39683  xpq(kfv2)=xpq(kfv2)+fv*xfv2
39684  ELSE
39685  xpq(kfv1)=xpq(kfv1)+fv*wtv1*vint(232)
39686  xpq(-kfv1)=xpq(-kfv1)+fv*wtv1*vint(232)
39687  xpq(kfv2)=xpq(kfv2)+fv*wtv2*vint(232)
39688  xpq(-kfv2)=xpq(-kfv2)+fv*wtv2*vint(232)
39689  ENDIF
39690  mint(92)=2
39691 
39692 C...Large Q2 and small x: interpolate behaviour.
39693  ELSEIF(q2.GT.q2mn) THEN
39694 
39695 C...Evaluate at extremes and define coefficients for interpolation.
39696  mint(30)=mint30
39697  CALL pypdfu(kfc,xmn,q2mn,xpa)
39698  vi232a=vint(232)
39699  mint(30)=mint30
39700  CALL pypdfu(kfc,x,q2b,xpb)
39701  vi232b=vint(232)
39702  fla=log(q2b/q2)/log(q2b/q2mn)
39703  fva=(x/xmn)**0.45d0*fla
39704  fsa=(x/xmn)**(-0.08d0)*fla
39705  fb=1d0-fla
39706 
39707 C...Separate valence and sea parts of parton distribution.
39708  IF(kfa.NE.22) THEN
39709  xfva1=xpa(kfv1)-xpa(-kfv1)
39710  xpa(kfv1)=xpa(-kfv1)
39711  xfva2=xpa(kfv2)-xpa(-kfv2)
39712  xpa(kfv2)=xpa(-kfv2)
39713  xfvb1=xpb(kfv1)-xpb(-kfv1)
39714  xpb(kfv1)=xpb(-kfv1)
39715  xfvb2=xpb(kfv2)-xpb(-kfv2)
39716  xpb(kfv2)=xpb(-kfv2)
39717  ELSE
39718  xpa(kfv1)=xpa(kfv1)-wtv1*vi232a
39719  xpa(-kfv1)=xpa(-kfv1)-wtv1*vi232a
39720  xpa(kfv2)=xpa(kfv2)-wtv2*vi232a
39721  xpa(-kfv2)=xpa(-kfv2)-wtv2*vi232a
39722  xpb(kfv1)=xpb(kfv1)-wtv1*vi232b
39723  xpb(-kfv1)=xpb(-kfv1)-wtv1*vi232b
39724  xpb(kfv2)=xpb(kfv2)-wtv2*vi232b
39725  xpb(-kfv2)=xpb(-kfv2)-wtv2*vi232b
39726  ENDIF
39727 
39728 C...Interpolate for valence and sea. Put back together.
39729  DO 130 kfl=-25,25
39730  xpq(kfl)=fsa*xpa(kfl)+fb*xpb(kfl)
39731  130 CONTINUE
39732  IF(kfa.NE.22) THEN
39733  xpq(kfv1)=xpq(kfv1)+(fva*xfva1+fb*xfvb1)
39734  xpq(kfv2)=xpq(kfv2)+(fva*xfva2+fb*xfvb2)
39735  ELSE
39736  xpq(kfv1)=xpq(kfv1)+wtv1*(fva*vi232a+fb*vi232b)
39737  xpq(-kfv1)=xpq(-kfv1)+wtv1*(fva*vi232a+fb*vi232b)
39738  xpq(kfv2)=xpq(kfv2)+wtv2*(fva*vi232a+fb*vi232b)
39739  xpq(-kfv2)=xpq(-kfv2)+wtv2*(fva*vi232a+fb*vi232b)
39740  ENDIF
39741  mint(92)=3
39742 
39743 C...Small Q2 and small x: dampen boundary value and add term.
39744  ELSE
39745 
39746 C...Evaluate at boundary and define dampening factors.
39747  mint(30)=mint30
39748  CALL pypdfu(kfc,xmn,q2mn,xpa)
39749  fb=(xmn-x)*(q2mn-q2)/(xmn*q2mn)
39750  fa=1d0-fb
39751  fvc=(x/xmn)**0.45d0*(q2/(q2+rmr))**0.55d0
39752  fva=fvc*fa*((q2mn+rmr)/q2mn)**0.55d0
39753  fvb=fvc*fb*1.10d0*xmn**0.45d0*0.11d0
39754  fsc=(x/xmn)**(-0.08d0)*(q2/(q2+rmp))**1.08d0
39755  fsa=fsc*fa*((q2mn+rmp)/q2mn)**1.08d0
39756  fsb=fsc*fb*0.21d0*xmn**(-0.08d0)*0.21d0
39757 
39758 C...Separate valence and sea parts of parton distribution.
39759  IF(kfa.NE.22) THEN
39760  xfv1=xpa(kfv1)-xpa(-kfv1)
39761  xpa(kfv1)=xpa(-kfv1)
39762  xfv2=xpa(kfv2)-xpa(-kfv2)
39763  xpa(kfv2)=xpa(-kfv2)
39764  ELSE
39765  xpa(kfv1)=xpa(kfv1)-wtv1*vint(232)
39766  xpa(-kfv1)=xpa(-kfv1)-wtv1*vint(232)
39767  xpa(kfv2)=xpa(kfv2)-wtv2*vint(232)
39768  xpa(-kfv2)=xpa(-kfv2)-wtv2*vint(232)
39769  ENDIF
39770 
39771 C...Dampen valence and sea separately. Add constant terms.
39772 C...Put back together.
39773  DO 140 kfl=-25,25
39774  xpq(kfl)=fsa*xpa(kfl)
39775  140 CONTINUE
39776  IF(kfa.NE.22) THEN
39777  DO 150 kfl=-3,3
39778  xpq(kfl)=xpq(kfl)+fsb*wtsb(kfl)
39779  150 CONTINUE
39780  xpq(kfv1)=xpq(kfv1)+(fva*xfv1+fvb*nv1)
39781  xpq(kfv2)=xpq(kfv2)+(fva*xfv2+fvb*nv2)
39782  ELSE
39783  DO 160 kfl=-3,3
39784  xpq(kfl)=xpq(kfl)+vint(281)*fsb*wtsb(kfl)
39785  160 CONTINUE
39786  xpq(kfv1)=xpq(kfv1)+wtv1*(fva*vint(232)+fvb*vint(281))
39787  xpq(-kfv1)=xpq(-kfv1)+wtv1*(fva*vint(232)+fvb*vint(281))
39788  xpq(kfv2)=xpq(kfv2)+wtv2*(fva*vint(232)+fvb*vint(281))
39789  xpq(-kfv2)=xpq(-kfv2)+wtv2*(fva*vint(232)+fvb*vint(281))
39790  ENDIF
39791  xpq(21)=xpq(0)
39792  mint(92)=4
39793  ENDIF
39794 
39795 C...Format for error printout.
39796  5000 FORMAT(' Error: x value outside physical range; x =',1p,d12.3)
39797 
39798  RETURN
39799  END
39800 
39801 C*********************************************************************
39802 
39803 C...PYPDEL
39804 C...Gives electron (or muon, or tau) parton distribution.
39805 
39806  SUBROUTINE pypdel(KFA,X,Q2,XPEL)
39807 
39808 C...Double precision and integer declarations.
39809  IMPLICIT DOUBLE PRECISION(a-h, o-z)
39810  IMPLICIT INTEGER(i-n)
39811  INTEGER pyk,pychge,pycomp
39812 C...Commonblocks.
39813  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
39814  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
39815  common/pypars/mstp(200),parp(200),msti(200),pari(200)
39816  common/pyint1/mint(400),vint(400)
39817  SAVE /pydat1/,/pydat2/,/pypars/,/pyint1/
39818 C...Local arrays.
39819  dimension xpel(-25:25),xpga(-6:6),sxp(0:6)
39820 
39821 C...Interface to PDFLIB.
39822  common/w50513/xmin,xmax,q2min,q2max
39823  SAVE /w50513/
39824  DOUBLE PRECISION xx,qq,upv,dnv,usea,dsea,str,chm,bot,top,glu,
39825  &value(20),xmin,xmax,q2min,q2max
39826  CHARACTER*20 parm(20)
39827  DATA value/20*0d0/,parm/20*' '/
39828 
39829 C...Some common constants.
39830  DO 100 kfl=-25,25
39831  xpel(kfl)=0d0
39832  100 CONTINUE
39833  aem=paru(101)
39834  pme=pmas(11,1)
39835  IF(kfa.EQ.13) pme=pmas(13,1)
39836  IF(kfa.EQ.15) pme=pmas(15,1)
39837  xl=log(max(1d-10,x))
39838  x1l=log(max(1d-10,1d0-x))
39839  hle=log(max(3d0,q2/pme**2))
39840  hbe2=(aem/paru(1))*(hle-1d0)
39841 
39842 C...Electron inside electron, see R. Kleiss et al., in Z physics at
39843 C...LEP 1, CERN 89-08, p. 34
39844  IF(mstp(59).LE.1) THEN
39845  hde=1d0+(aem/paru(1))*(1.5d0*hle+1.289868d0)+(aem/paru(1))**2*
39846  & (-2.164868d0*hle**2+9.840808d0*hle-10.130464d0)
39847  hee=hbe2*(1d0-x)**(hbe2-1d0)*sqrt(max(0d0,hde))-
39848  & 0.5d0*hbe2*(1d0+x)+hbe2**2/8d0*((1d0+x)*(-4d0*x1l+3d0*xl)-
39849  & 4d0*xl/(1d0-x)-5d0-x)
39850  ELSE
39851  hee=hbe2*(1d0-x)**(hbe2-1d0)*exp(0.172784d0*hbe2)/
39852  & pygamm(1d0+hbe2)-0.5d0*hbe2*(1d0+x)+hbe2**2/8d0*((1d0+x)*
39853  & (-4d0*x1l+3d0*xl)-4d0*xl/(1d0-x)-5d0-x)
39854  ENDIF
39855 C...Zero distribution for very large x and rescale it for intermediate.
39856  IF(x.GT.1d0-1d-10) THEN
39857  hee=0d0
39858  ELSEIF(x.GT.1d0-1d-7) THEN
39859  hee=hee*1000d0**hbe2/(1000d0**hbe2-1d0)
39860  ENDIF
39861  xpel(kfa)=x*hee
39862 
39863 C...Photon and (transverse) W- inside electron.
39864  aemp=pyalem(pme*sqrt(max(0d0,q2)))/paru(2)
39865  IF(mstp(13).LE.1) THEN
39866  hlg=hle
39867  ELSE
39868  hlg=log(max(1d0,(parp(13)/pme**2)*(1d0-x)/x**2))
39869  ENDIF
39870  xpel(22)=aemp*hlg*(1d0+(1d0-x)**2)
39871  hlw=log(1d0+q2/pmas(24,1)**2)/(4d0*paru(102))
39872  xpel(-24)=aemp*hlw*(1d0+(1d0-x)**2)
39873 
39874 C...Electron or positron inside photon inside electron.
39875  IF(kfa.EQ.11.AND.mstp(12).EQ.1) THEN
39876  xfsea=0.5d0*(aemp*(hle-1d0))**2*(4d0/3d0+x-x**2-4d0*x**3/3d0+
39877  & 2d0*x*(1d0+x)*xl)
39878  xpel(11)=xpel(11)+xfsea
39879  xpel(-11)=xfsea
39880 
39881 C...Initialize PDFLIB photon parton distributions.
39882  IF(mstp(56).EQ.2) THEN
39883  parm(1)='NPTYPE'
39884  value(1)=3
39885  parm(2)='NGROUP'
39886  value(2)=mstp(55)/1000
39887  parm(3)='NSET'
39888  value(3)=mod(mstp(55),1000)
39889  IF(mint(93).NE.3000000+mstp(55)) THEN
39890  CALL pdfset(parm,value)
39891  mint(93)=3000000+mstp(55)
39892  ENDIF
39893  ENDIF
39894 
39895 C...Quarks and gluons inside photon inside electron:
39896 C...numerical convolution required.
39897  DO 110 kfl=0,6
39898  sxp(kfl)=0d0
39899  110 CONTINUE
39900  sumxpp=0d0
39901  iter=-1
39902  120 iter=iter+1
39903  sumxp=sumxpp
39904  nstp=2**(iter-1)
39905  IF(iter.EQ.0) nstp=2
39906  DO 130 kfl=0,6
39907  sxp(kfl)=0.5d0*sxp(kfl)
39908  130 CONTINUE
39909  wtstp=0.5d0/nstp
39910  IF(iter.EQ.0) wtstp=0.5d0
39911 C...Pick grid of x_{gamma} values logarithmically even.
39912  DO 150 istp=1,nstp
39913  IF(iter.EQ.0) THEN
39914  xle=xl*(istp-1)
39915  ELSE
39916  xle=xl*(istp-0.5d0)/nstp
39917  ENDIF
39918  xe=min(1d0-1d-10,exp(xle))
39919  xg=min(1d0-1d-10,x/xe)
39920 C...Evaluate photon inside electron parton distribution for convolution.
39921  xpgp=1d0+(1d0-xe)**2
39922  IF(mstp(13).LE.1) THEN
39923  xpgp=xpgp*hle
39924  ELSE
39925  xpgp=xpgp*log(max(1d0,(parp(13)/pme**2)*(1d0-xe)/xe**2))
39926  ENDIF
39927 C...Evaluate photon parton distributions for convolution.
39928  IF(mstp(56).EQ.1) THEN
39929  IF(mstp(55).EQ.1) THEN
39930  CALL pypdga(xg,q2,xpga)
39931  ELSEIF(mstp(55).GE.5.AND.mstp(55).LE.8) THEN
39932  q2mx=q2
39933  p2mx=0.36d0
39934  IF(mstp(55).GE.7) p2mx=4.0d0
39935  IF(mstp(57).EQ.0) q2mx=p2mx
39936  p2=0d0
39937  IF(vint(120).LT.0d0) p2=vint(120)**2
39938  CALL pyggam(mstp(55)-4,xg,q2mx,p2,mstp(60),f2gam,xpga)
39939  vint(231)=p2mx
39940  ELSEIF(mstp(55).GE.9.AND.mstp(55).LE.12) THEN
39941  q2mx=q2
39942  p2mx=0.36d0
39943  IF(mstp(55).GE.11) p2mx=4.0d0
39944  IF(mstp(57).EQ.0) q2mx=p2mx
39945  p2=0d0
39946  IF(vint(120).LT.0d0) p2=vint(120)**2
39947  CALL pyggam(mstp(55)-8,xg,q2mx,p2,mstp(60),f2gam,xpga)
39948  vint(231)=p2mx
39949  ENDIF
39950  DO 140 kfl=0,5
39951  sxp(kfl)=sxp(kfl)+wtstp*xpgp*xpga(kfl)
39952  140 CONTINUE
39953  ELSEIF(mstp(56).EQ.2) THEN
39954 C...Call PDFLIB parton distributions.
39955  xx=xg
39956  qq=sqrt(max(0d0,q2min,q2))
39957  IF(mstp(57).EQ.0) qq=sqrt(q2min)
39958  CALL structm(xx,qq,upv,dnv,usea,dsea,str,chm,bot,top,glu)
39959  sxp(0)=sxp(0)+wtstp*xpgp*glu
39960  sxp(1)=sxp(1)+wtstp*xpgp*dnv
39961  sxp(2)=sxp(2)+wtstp*xpgp*upv
39962  sxp(3)=sxp(3)+wtstp*xpgp*str
39963  sxp(4)=sxp(4)+wtstp*xpgp*chm
39964  sxp(5)=sxp(5)+wtstp*xpgp*bot
39965  sxp(6)=sxp(6)+wtstp*xpgp*top
39966  ENDIF
39967  150 CONTINUE
39968  sumxpp=sxp(0)+2d0*sxp(1)+2d0*sxp(2)
39969  IF(iter.LE.2.OR.(iter.LE.7.AND.abs(sumxpp-sumxp).GT.
39970  & parp(14)*(sumxpp+sumxp))) goto 120
39971 
39972 C...Put convolution into output arrays.
39973  fconv=aemp*(-xl)
39974  xpel(0)=fconv*sxp(0)
39975  DO 160 kfl=1,6
39976  xpel(kfl)=fconv*sxp(kfl)
39977  xpel(-kfl)=xpel(kfl)
39978  160 CONTINUE
39979  ENDIF
39980 
39981  RETURN
39982  END
39983 
39984 C*********************************************************************
39985 
39986 C...PYPDGA
39987 C...Gives photon parton distribution.
39988 
39989  SUBROUTINE pypdga(X,Q2,XPGA)
39990 
39991 C...Double precision and integer declarations.
39992  IMPLICIT DOUBLE PRECISION(a-h, o-z)
39993  IMPLICIT INTEGER(i-n)
39994  INTEGER pyk,pychge,pycomp
39995 C...Commonblocks.
39996  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
39997  common/pypars/mstp(200),parp(200),msti(200),pari(200)
39998  common/pyint1/mint(400),vint(400)
39999  SAVE /pydat1/,/pypars/,/pyint1/
40000 C...Local arrays.
40001  dimension xpga(-6:6),dgag(4,3),dgbg(4,3),dgcg(4,3),dgan(4,3),
40002  &dgbn(4,3),dgcn(4,3),dgdn(4,3),dgen(4,3),dgas(4,3),dgbs(4,3),
40003  &dgcs(4,3),dgds(4,3),dges(4,3)
40004 
40005 C...The following data lines are coefficients needed in the
40006 C...Drees and Grassie photon parton distribution parametrization.
40007  DATA dgag/-.207d0,.6158d0,1.074d0,0.d0,.8926d-2,.6594d0,
40008  &.4766d0,.1975d-1,.03197d0,1.018d0,.2461d0,.2707d-1/
40009  DATA dgbg/-.1987d0,.6257d0,8.352d0,5.024d0,.5085d-1,.2774d0,
40010  &-.3906d0,-.3212d0,-.618d-2,.9476d0,-.6094d0,-.1067d-1/
40011  DATA dgcg/5.119d0,-.2752d0,-6.993d0,2.298d0,-.2313d0,.1382d0,
40012  &6.542d0,.5162d0,-.1216d0,.9047d0,2.653d0,.2003d-2/
40013  DATA dgan/2.285d0,-.1526d-1,1330.d0,4.219d0,-.3711d0,1.061d0,
40014  &4.758d0,-.1503d-1,15.8d0,-.9464d0,-.5d0,-.2118d0/
40015  DATA dgbn/6.073d0,-.8132d0,-41.31d0,3.165d0,-.1717d0,.7815d0,
40016  &1.535d0,.7067d-2,2.742d0,-.7332d0,.7148d0,3.287d0/
40017  DATA dgcn/-.4202d0,.1778d-1,.9216d0,.18d0,.8766d-1,.2197d-1,
40018  &.1096d0,.204d0,.2917d-1,.4657d-1,.1785d0,.4811d-1/
40019  DATA dgdn/-.8083d-1,.6346d0,1.208d0,.203d0,-.8915d0,.2857d0,
40020  &2.973d0,.1185d0,-.342d-1,.7196d0,.7338d0,.8139d-1/
40021  DATA dgen/.5526d-1,1.136d0,.9512d0,.1163d-1,-.1816d0,.5866d0,
40022  &2.421d0,.4059d0,-.2302d-1,.9229d0,.5873d0,-.79d-4/
40023  DATA dgas/16.69d0,-.7916d0,1099.d0,4.428d0,-.1207d0,1.071d0,
40024  &1.977d0,-.8625d-2,6.734d0,-1.008d0,-.8594d-1,.7625d-1/
40025  DATA dgbs/.176d0,.4794d-1,1.047d0,.25d-1,25.d0,-1.648d0,
40026  &-.1563d-1,6.438d0,59.88d0,-2.983d0,4.48d0,.9686d0/
40027  DATA dgcs/-.208d-1,.3386d-2,4.853d0,.8404d0,-.123d-1,1.162d0,
40028  &.4824d0,-.11d-1,-.3226d-2,.8432d0,.3616d0,.1383d-2/
40029  DATA dgds/-.1685d-1,1.353d0,1.426d0,1.239d0,-.9194d-1,.7912d0,
40030  &.6397d0,2.327d0,-.3321d-1,.9475d0,-.3198d0,.2132d-1/
40031  DATA dges/-.1986d0,1.1d0,1.136d0,-.2779d0,.2015d-1,.9869d0,
40032  &-.7036d-1,.1694d-1,.1059d0,.6954d0,-.6663d0,.3683d0/
40033 
40034 C...Photon parton distribution from Drees and Grassie.
40035 C...Allowed variable range: 1 GeV^2 < Q^2 < 10000 GeV^2.
40036  DO 100 kfl=-6,6
40037  xpga(kfl)=0d0
40038  100 CONTINUE
40039  vint(231)=1d0
40040  IF(mstp(57).LE.0) THEN
40041  t=log(1d0/0.16d0)
40042  ELSE
40043  t=log(min(1d4,max(1d0,q2))/0.16d0)
40044  ENDIF
40045  x1=1d0-x
40046  nf=3
40047  IF(q2.GT.25d0) nf=4
40048  IF(q2.GT.300d0) nf=5
40049  nfe=nf-2
40050  aem=paru(101)
40051 
40052 C...Evaluate gluon content.
40053  dga=dgag(1,nfe)*t**dgag(2,nfe)+dgag(3,nfe)*t**(-dgag(4,nfe))
40054  dgb=dgbg(1,nfe)*t**dgbg(2,nfe)+dgbg(3,nfe)*t**(-dgbg(4,nfe))
40055  dgc=dgcg(1,nfe)*t**dgcg(2,nfe)+dgcg(3,nfe)*t**(-dgcg(4,nfe))
40056  xpgl=dga*x**dgb*x1**dgc
40057 
40058 C...Evaluate up- and down-type quark content.
40059  dga=dgan(1,nfe)*t**dgan(2,nfe)+dgan(3,nfe)*t**(-dgan(4,nfe))
40060  dgb=dgbn(1,nfe)*t**dgbn(2,nfe)+dgbn(3,nfe)*t**(-dgbn(4,nfe))
40061  dgc=dgcn(1,nfe)*t**dgcn(2,nfe)+dgcn(3,nfe)*t**(-dgcn(4,nfe))
40062  dgd=dgdn(1,nfe)*t**dgdn(2,nfe)+dgdn(3,nfe)*t**(-dgdn(4,nfe))
40063  dge=dgen(1,nfe)*t**dgen(2,nfe)+dgen(3,nfe)*t**(-dgen(4,nfe))
40064  xpqn=x*(x**2+x1**2)/(dga-dgb*log(x1))+dgc*x**dgd*x1**dge
40065  dga=dgas(1,nfe)*t**dgas(2,nfe)+dgas(3,nfe)*t**(-dgas(4,nfe))
40066  dgb=dgbs(1,nfe)*t**dgbs(2,nfe)+dgbs(3,nfe)*t**(-dgbs(4,nfe))
40067  dgc=dgcs(1,nfe)*t**dgcs(2,nfe)+dgcs(3,nfe)*t**(-dgcs(4,nfe))
40068  dgd=dgds(1,nfe)*t**dgds(2,nfe)+dgds(3,nfe)*t**(-dgds(4,nfe))
40069  dge=dges(1,nfe)*t**dges(2,nfe)+dges(3,nfe)*t**(-dges(4,nfe))
40070  dgf=9d0
40071  IF(nf.EQ.4) dgf=10d0
40072  IF(nf.EQ.5) dgf=55d0/6d0
40073  xpqs=dgf*x*(x**2+x1**2)/(dga-dgb*log(x1))+dgc*x**dgd*x1**dge
40074  IF(nf.LE.3) THEN
40075  xpqu=(xpqs+9d0*xpqn)/6d0
40076  xpqd=(xpqs-4.5d0*xpqn)/6d0
40077  ELSEIF(nf.EQ.4) THEN
40078  xpqu=(xpqs+6d0*xpqn)/8d0
40079  xpqd=(xpqs-6d0*xpqn)/8d0
40080  ELSE
40081  xpqu=(xpqs+7.5d0*xpqn)/10d0
40082  xpqd=(xpqs-5d0*xpqn)/10d0
40083  ENDIF
40084 
40085 C...Put into output arrays.
40086  xpga(0)=aem*xpgl
40087  xpga(1)=aem*xpqd
40088  xpga(2)=aem*xpqu
40089  xpga(3)=aem*xpqd
40090  IF(nf.GE.4) xpga(4)=aem*xpqu
40091  IF(nf.GE.5) xpga(5)=aem*xpqd
40092  DO 110 kfl=1,6
40093  xpga(-kfl)=xpga(kfl)
40094  110 CONTINUE
40095 
40096  RETURN
40097  END
40098 
40099 C*********************************************************************
40100 
40101 C...PYGGAM
40102 C...Constructs the F2 and parton distributions of the photon
40103 C...by summing homogeneous (VMD) and inhomogeneous (anomalous) terms.
40104 C...For F2, c and b are included by the Bethe-Heitler formula;
40105 C...in the 'MSbar' scheme additionally a Cgamma term is added.
40106 C...Contains the SaS sets 1D, 1M, 2D and 2M.
40107 C...Adapted from SaSgam library, authors G.A. Schuler and T. Sjostrand.
40108 
40109  SUBROUTINE pyggam(ISET,X,Q2,P2,IP2,F2GM,XPDFGM)
40110 
40111 C...Double precision and integer declarations.
40112  IMPLICIT DOUBLE PRECISION(a-h, o-z)
40113  IMPLICIT INTEGER(i-n)
40114  INTEGER pyk,pychge,pycomp
40115 C...Commonblocks.
40116  common/pyint8/xpvmd(-6:6),xpanl(-6:6),xpanh(-6:6),xpbeh(-6:6),
40117  &xpdir(-6:6)
40118  common/pyint9/vxpvmd(-6:6),vxpanl(-6:6),vxpanh(-6:6),vxpdgm(-6:6)
40119  SAVE /pyint8/,/pyint9/
40120 C...Local arrays.
40121  dimension xpdfgm(-6:6),xpga(-6:6), vxpga(-6:6)
40122 C...Charm and bottom masses (low to compensate for J/psi etc.).
40123  DATA pmc/1.3d0/, pmb/4.6d0/
40124 C...alpha_em and alpha_em/(2*pi).
40125  DATA aem/0.007297d0/, aem2pi/0.0011614d0/
40126 C...Lambda value for 4 flavours.
40127  DATA alam/0.20d0/
40128 C...Mixture u/(u+d), = 0.5 for incoherent and = 0.8 for coherent sum.
40129  DATA fracu/0.8d0/
40130 C...VMD couplings f_V**2/(4*pi).
40131  DATA frho/2.20d0/, fomega/23.6d0/, fphi/18.4d0/
40132 C...Masses for rho (=omega) and phi.
40133  DATA pmrho/0.770d0/, pmphi/1.020d0/
40134 C...Number of points in integration for IP2=1.
40135  DATA nstep/100/
40136 
40137 C...Reset output.
40138  f2gm=0d0
40139  DO 100 kfl=-6,6
40140  xpdfgm(kfl)=0d0
40141  xpvmd(kfl)=0d0
40142  xpanl(kfl)=0d0
40143  xpanh(kfl)=0d0
40144  xpbeh(kfl)=0d0
40145  xpdir(kfl)=0d0
40146  vxpvmd(kfl)=0d0
40147  vxpanl(kfl)=0d0
40148  vxpanh(kfl)=0d0
40149  vxpdgm(kfl)=0d0
40150  100 CONTINUE
40151 
40152 C...Set Q0 cut-off parameter as function of set used.
40153  IF(iset.LE.2) THEN
40154  q0=0.6d0
40155  ELSE
40156  q0=2d0
40157  ENDIF
40158  q02=q0**2
40159 
40160 C...Scale choice for off-shell photon; common factors.
40161  q2a=q2
40162  facnor=1d0
40163  IF(ip2.EQ.1) THEN
40164  p2mx=p2+q02
40165  q2a=q2+p2*q02/max(q02,q2)
40166  facnor=log(q2/q02)/nstep
40167  ELSEIF(ip2.EQ.2) THEN
40168  p2mx=max(p2,q02)
40169  ELSEIF(ip2.EQ.3) THEN
40170  p2mx=p2+q02
40171  q2a=q2+p2*q02/max(q02,q2)
40172  ELSEIF(ip2.EQ.4) THEN
40173  p2mx=q2*(q02+p2)/(q2+p2)*exp(p2*(q2-q02)/
40174  & ((q2+p2)*(q02+p2)))
40175  ELSEIF(ip2.EQ.5) THEN
40176  p2mxa=q2*(q02+p2)/(q2+p2)*exp(p2*(q2-q02)/
40177  & ((q2+p2)*(q02+p2)))
40178  p2mx=q0*sqrt(p2mxa)
40179  facnor=log(q2/p2mxa)/log(q2/p2mx)
40180  ELSEIF(ip2.EQ.6) THEN
40181  p2mx=q2*(q02+p2)/(q2+p2)*exp(p2*(q2-q02)/
40182  & ((q2+p2)*(q02+p2)))
40183  p2mx=max(0d0,1d0-p2/q2)*p2mx+min(1d0,p2/q2)*max(p2,q02)
40184  ELSE
40185  p2mxa=q2*(q02+p2)/(q2+p2)*exp(p2*(q2-q02)/
40186  & ((q2+p2)*(q02+p2)))
40187  p2mx=q0*sqrt(p2mxa)
40188  p2mxb=p2mx
40189  p2mx=max(0d0,1d0-p2/q2)*p2mx+min(1d0,p2/q2)*max(p2,q02)
40190  p2mxb=max(0d0,1d0-p2/q2)*p2mxb+min(1d0,p2/q2)*p2mxa
40191  IF(abs(q2-q02).GT.1d-6) THEN
40192  facnor=log(q2/p2mxa)/log(q2/p2mxb)
40193  ELSEIF(p2.LT.q02) THEN
40194  facnor=q02**3/(q02+p2)/(q02**2-p2**2/2d0)
40195  ELSE
40196  facnor=1d0
40197  ENDIF
40198  ENDIF
40199 
40200 C...Call VMD parametrization for d quark and use to give rho, omega,
40201 C...phi. Note dipole dampening for off-shell photon.
40202  CALL pygvmd(iset,1,x,q2a,p2mx,alam,xpga,vxpga)
40203  xfval=vxpga(1)
40204  xpga(1)=xpga(2)
40205  xpga(-1)=xpga(-2)
40206  facud=aem*(1d0/frho+1d0/fomega)*(pmrho**2/(pmrho**2+p2))**2
40207  facs=aem*(1d0/fphi)*(pmphi**2/(pmphi**2+p2))**2
40208  DO 110 kfl=-5,5
40209  xpvmd(kfl)=(facud+facs)*xpga(kfl)
40210  110 CONTINUE
40211  xpvmd(1)=xpvmd(1)+(1d0-fracu)*facud*xfval
40212  xpvmd(2)=xpvmd(2)+fracu*facud*xfval
40213  xpvmd(3)=xpvmd(3)+facs*xfval
40214  xpvmd(-1)=xpvmd(-1)+(1d0-fracu)*facud*xfval
40215  xpvmd(-2)=xpvmd(-2)+fracu*facud*xfval
40216  xpvmd(-3)=xpvmd(-3)+facs*xfval
40217  vxpvmd(1)=(1d0-fracu)*facud*xfval
40218  vxpvmd(2)=fracu*facud*xfval
40219  vxpvmd(3)=facs*xfval
40220  vxpvmd(-1)=(1d0-fracu)*facud*xfval
40221  vxpvmd(-2)=fracu*facud*xfval
40222  vxpvmd(-3)=facs*xfval
40223 
40224  IF(ip2.NE.1) THEN
40225 C...Anomalous parametrizations for different strategies
40226 C...for off-shell photons; except full integration.
40227 
40228 C...Call anomalous parametrization for d + u + s.
40229  CALL pygano(-3,x,q2a,p2mx,alam,xpga,vxpga)
40230  DO 120 kfl=-5,5
40231  xpanl(kfl)=facnor*xpga(kfl)
40232  vxpanl(kfl)=facnor*vxpga(kfl)
40233  120 CONTINUE
40234 
40235 C...Call anomalous parametrization for c and b.
40236  CALL pygano(4,x,q2a,p2mx,alam,xpga,vxpga)
40237  DO 130 kfl=-5,5
40238  xpanh(kfl)=facnor*xpga(kfl)
40239  vxpanh(kfl)=facnor*vxpga(kfl)
40240  130 CONTINUE
40241  CALL pygano(5,x,q2a,p2mx,alam,xpga,vxpga)
40242  DO 140 kfl=-5,5
40243  xpanh(kfl)=xpanh(kfl)+facnor*xpga(kfl)
40244  vxpanh(kfl)=vxpanh(kfl)+facnor*vxpga(kfl)
40245  140 CONTINUE
40246 
40247  ELSE
40248 C...Special option: loop over flavours and integrate over k2.
40249  DO 170 kf=1,5
40250  DO 160 istep=1,nstep
40251  q2step=q02*(q2/q02)**((istep-0.5d0)/nstep)
40252  IF((kf.EQ.4.AND.q2step.LT.pmc**2).OR.
40253  & (kf.EQ.5.AND.q2step.LT.pmb**2)) goto 160
40254  CALL pygvmd(0,kf,x,q2,q2step,alam,xpga,vxpga)
40255  facq=aem2pi*(q2step/(q2step+p2))**2*facnor
40256  IF(mod(kf,2).EQ.0) facq=facq*(8d0/9d0)
40257  IF(mod(kf,2).EQ.1) facq=facq*(2d0/9d0)
40258  DO 150 kfl=-5,5
40259  IF(kf.LE.3) xpanl(kfl)=xpanl(kfl)+facq*xpga(kfl)
40260  IF(kf.GE.4) xpanh(kfl)=xpanh(kfl)+facq*xpga(kfl)
40261  IF(kf.LE.3) vxpanl(kfl)=vxpanl(kfl)+facq*vxpga(kfl)
40262  IF(kf.GE.4) vxpanh(kfl)=vxpanh(kfl)+facq*vxpga(kfl)
40263  150 CONTINUE
40264  160 CONTINUE
40265  170 CONTINUE
40266  ENDIF
40267 
40268 C...Call Bethe-Heitler term expression for charm and bottom.
40269  CALL pygbeh(4,x,q2,p2,pmc**2,xpbh)
40270  xpbeh(4)=xpbh
40271  xpbeh(-4)=xpbh
40272  CALL pygbeh(5,x,q2,p2,pmb**2,xpbh)
40273  xpbeh(5)=xpbh
40274  xpbeh(-5)=xpbh
40275 
40276 C...For MSbar subtraction call C^gamma term expression for d, u, s.
40277  IF(iset.EQ.2.OR.iset.EQ.4) THEN
40278  CALL pygdir(x,q2,p2,q02,xpga)
40279  DO 180 kfl=-5,5
40280  xpdir(kfl)=xpga(kfl)
40281  180 CONTINUE
40282  ENDIF
40283 
40284 C...Store result in output array.
40285  DO 190 kfl=-5,5
40286  chsq=1d0/9d0
40287  IF(iabs(kfl).EQ.2.OR.iabs(kfl).EQ.4) chsq=4d0/9d0
40288  xpf2=xpvmd(kfl)+xpanl(kfl)+xpbeh(kfl)+xpdir(kfl)
40289  IF(kfl.NE.0) f2gm=f2gm+chsq*xpf2
40290  xpdfgm(kfl)=xpvmd(kfl)+xpanl(kfl)+xpanh(kfl)
40291  vxpdgm(kfl)=vxpvmd(kfl)+vxpanl(kfl)+vxpanh(kfl)
40292  190 CONTINUE
40293 
40294  RETURN
40295  END
40296 
40297 C*********************************************************************
40298 
40299 C...PYGVMD
40300 C...Evaluates the VMD parton distributions of a photon,
40301 C...evolved homogeneously from an initial scale P2 to Q2.
40302 C...Does not include dipole suppression factor.
40303 C...ISET is parton distribution set, see above;
40304 C...additionally ISET=0 is used for the evolution of an anomalous photon
40305 C...which branched at a scale P2 and then evolved homogeneously to Q2.
40306 C...ALAM is the 4-flavour Lambda, which is automatically converted
40307 C...to 3- and 5-flavour equivalents as needed.
40308 C...Adapted from SaSgam library, authors G.A. Schuler and T. Sjostrand.
40309 
40310  SUBROUTINE pygvmd(ISET,KF,X,Q2,P2,ALAM,XPGA,VXPGA)
40311 
40312 C...Double precision and integer declarations.
40313  IMPLICIT DOUBLE PRECISION(a-h, o-z)
40314  IMPLICIT INTEGER(i-n)
40315  INTEGER pyk,pychge,pycomp
40316 C...Local arrays and data.
40317  dimension xpga(-6:6), vxpga(-6:6)
40318  DATA pmc/1.3d0/, pmb/4.6d0/, aem/0.007297d0/, aem2pi/0.0011614d0/
40319 
40320 C...Reset output.
40321  DO 100 kfl=-6,6
40322  xpga(kfl)=0d0
40323  vxpga(kfl)=0d0
40324  100 CONTINUE
40325  kfa=iabs(kf)
40326 
40327 C...Calculate Lambda; protect against unphysical Q2 and P2 input.
40328  alam3=alam*(pmc/alam)**(2d0/27d0)
40329  alam5=alam*(alam/pmb)**(2d0/23d0)
40330  p2eff=max(p2,1.2d0*alam3**2)
40331  IF(kfa.EQ.4) p2eff=max(p2eff,pmc**2)
40332  IF(kfa.EQ.5) p2eff=max(p2eff,pmb**2)
40333  q2eff=max(q2,p2eff)
40334 
40335 C...Find number of flavours at lower and upper scale.
40336  nfp=4
40337  IF(p2eff.LT.pmc**2) nfp=3
40338  IF(p2eff.GT.pmb**2) nfp=5
40339  nfq=4
40340  IF(q2eff.LT.pmc**2) nfq=3
40341  IF(q2eff.GT.pmb**2) nfq=5
40342 
40343 C...Find s as sum of 3-, 4- and 5-flavour parts.
40344  s=0d0
40345  IF(nfp.EQ.3) THEN
40346  q2div=pmc**2
40347  IF(nfq.EQ.3) q2div=q2eff
40348  s=s+(6d0/27d0)*log(log(q2div/alam3**2)/log(p2eff/alam3**2))
40349  ENDIF
40350  IF(nfp.LE.4.AND.nfq.GE.4) THEN
40351  p2div=p2eff
40352  IF(nfp.EQ.3) p2div=pmc**2
40353  q2div=q2eff
40354  IF(nfq.EQ.5) q2div=pmb**2
40355  s=s+(6d0/25d0)*log(log(q2div/alam**2)/log(p2div/alam**2))
40356  ENDIF
40357  IF(nfq.EQ.5) THEN
40358  p2div=pmb**2
40359  IF(nfp.EQ.5) p2div=p2eff
40360  s=s+(6d0/23d0)*log(log(q2eff/alam5**2)/log(p2div/alam5**2))
40361  ENDIF
40362 
40363 C...Calculate frequent combinations of x and s.
40364  x1=1d0-x
40365  xl=-log(x)
40366  s2=s**2
40367  s3=s**3
40368  s4=s**4
40369 
40370 C...Evaluate homogeneous anomalous parton distributions below or
40371 C...above threshold.
40372  IF(iset.EQ.0) THEN
40373  IF(q2.LE.p2.OR.(kfa.EQ.4.AND.q2.LT.pmc**2).OR.
40374  & (kfa.EQ.5.AND.q2.LT.pmb**2)) THEN
40375  xval = x * 1.5d0 * (x**2+x1**2)
40376  xglu = 0d0
40377  xsea = 0d0
40378  ELSE
40379  xval = (1.5d0/(1d0-0.197d0*s+4.33d0*s2)*x**2 +
40380  & (1.5d0+2.10d0*s)/(1d0+3.29d0*s)*x1**2 +
40381  & 5.23d0*s/(1d0+1.17d0*s+19.9d0*s3)*x*x1) *
40382  & x**(1d0/(1d0+1.5d0*s)) * (1d0-x**2)**(2.667d0*s)
40383  xglu = 4d0*s/(1d0+4.76d0*s+15.2d0*s2+29.3d0*s4) *
40384  & x**(-2.03d0*s/(1d0+2.44d0*s)) * (x1*xl)**(1.333d0*s) *
40385  & ((4d0*x**2+7d0*x+4d0)*x1/3d0 - 2d0*x*(1d0+x)*xl)
40386  xsea = s2/(1d0+4.54d0*s+8.19d0*s2+8.05d0*s3) *
40387  & x**(-1.54d0*s/(1d0+1.29d0*s)) * x1**(2.667d0*s) *
40388  & ((8d0-73d0*x+62d0*x**2)*x1/9d0 + (3d0-8d0*x**2/3d0)*x*xl +
40389  & (2d0*x-1d0)*x*xl**2)
40390  ENDIF
40391 
40392 C...Evaluate set 1D parton distributions below or above threshold.
40393  ELSEIF(iset.EQ.1) THEN
40394  IF(q2.LE.p2.OR.(kfa.EQ.4.AND.q2.LT.pmc**2).OR.
40395  & (kfa.EQ.5.AND.q2.LT.pmb**2)) THEN
40396  xval = 1.294d0 * x**0.80d0 * x1**0.76d0
40397  xglu = 1.273d0 * x**0.40d0 * x1**1.76d0
40398  xsea = 0.100d0 * x1**3.76d0
40399  ELSE
40400  xval = 1.294d0/(1d0+0.252d0*s+3.079d0*s2) *
40401  & x**(0.80d0-0.13d0*s) * x1**(0.76d0+0.667d0*s) * xl**(2d0*s)
40402  xglu = 7.90d0*s/(1d0+5.50d0*s) * exp(-5.16d0*s) *
40403  & x**(-1.90d0*s/(1d0+3.60d0*s)) * x1**1.30d0 *
40404  & xl**(0.50d0+3d0*s) + 1.273d0 * exp(-10d0*s) *
40405  & x**0.40d0 * x1**(1.76d0+3d0*s)
40406  xsea = (0.1d0-0.397d0*s2+1.121d0*s3)/
40407  & (1d0+5.61d0*s2+5.26d0*s3) * x**(-7.32d0*s2/(1d0+10.3d0*s2)) *
40408  & x1**((3.76d0+15d0*s+12d0*s2)/(1d0+4d0*s))
40409  xsea0 = 0.100d0 * x1**3.76d0
40410  ENDIF
40411 
40412 C...Evaluate set 1M parton distributions below or above threshold.
40413  ELSEIF(iset.EQ.2) THEN
40414  IF(q2.LE.p2.OR.(kfa.EQ.4.AND.q2.LT.pmc**2).OR.
40415  & (kfa.EQ.5.AND.q2.LT.pmb**2)) THEN
40416  xval = 0.8477d0 * x**0.51d0 * x1**1.37d0
40417  xglu = 3.42d0 * x**0.255d0 * x1**2.37d0
40418  xsea = 0d0
40419  ELSE
40420  xval = 0.8477d0/(1d0+1.37d0*s+2.18d0*s2+3.73d0*s3) *
40421  & x**(0.51d0+0.21d0*s) * x1**1.37d0 * xl**(2.667d0*s)
40422  xglu = 24d0*s/(1d0+9.6d0*s+0.92d0*s2+14.34d0*s3) *
40423  & exp(-5.94d0*s) * x**((-0.013d0-1.80d0*s)/(1d0+3.14d0*s)) *
40424  & x1**(2.37d0+0.4d0*s) * xl**(0.32d0+3.6d0*s) + 3.42d0 *
40425  & exp(-12d0*s) * x**0.255d0 * x1**(2.37d0+3d0*s)
40426  xsea = 0.842d0*s/(1d0+21.3d0*s-33.2d0*s2+229d0*s3) *
40427  & x**((0.13d0-2.90d0*s)/(1d0+5.44d0*s)) * x1**(3.45d0+0.5d0*s) *
40428  & xl**(2.8d0*s)
40429  xsea0 = 0d0
40430  ENDIF
40431 
40432 C...Evaluate set 2D parton distributions below or above threshold.
40433  ELSEIF(iset.EQ.3) THEN
40434  IF(q2.LE.p2.OR.(kfa.EQ.4.AND.q2.LT.pmc**2).OR.
40435  & (kfa.EQ.5.AND.q2.LT.pmb**2)) THEN
40436  xval = x**0.46d0 * x1**0.64d0 + 0.76d0 * x
40437  xglu = 1.925d0 * x1**2
40438  xsea = 0.242d0 * x1**4
40439  ELSE
40440  xval = (1d0+0.186d0*s)/(1d0-0.209d0*s+1.495d0*s2) *
40441  & x**(0.46d0+0.25d0*s) *
40442  & x1**((0.64d0+0.14d0*s+5d0*s2)/(1d0+s)) * xl**(1.9d0*s) +
40443  & (0.76d0+0.4d0*s) * x * x1**(2.667d0*s)
40444  xglu = (1.925d0+5.55d0*s+147d0*s2)/(1d0-3.59d0*s+3.32d0*s2) *
40445  & exp(-18.67d0*s) *
40446  & x**((-5.81d0*s-5.34d0*s2)/(1d0+29d0*s-4.26d0*s2))
40447  & * x1**((2d0-5.9d0*s)/(1d0+1.7d0*s)) *
40448  & xl**(9.3d0*s/(1d0+1.7d0*s))
40449  xsea = (0.242d0-0.252d0*s+1.19d0*s2)/
40450  & (1d0-0.607d0*s+21.95d0*s2) *
40451  & x**(-12.1d0*s2/(1d0+2.62d0*s+16.7d0*s2)) * x1**4 * xl**s
40452  xsea0 = 0.242d0 * x1**4
40453  ENDIF
40454 
40455 C...Evaluate set 2M parton distributions below or above threshold.
40456  ELSEIF(iset.EQ.4) THEN
40457  IF(q2.LE.p2.OR.(kfa.EQ.4.AND.q2.LT.pmc**2).OR.
40458  & (kfa.EQ.5.AND.q2.LT.pmb**2)) THEN
40459  xval = 1.168d0 * x**0.50d0 * x1**2.60d0 + 0.965d0 * x
40460  xglu = 1.808d0 * x1**2
40461  xsea = 0.209d0 * x1**4
40462  ELSE
40463  xval = (1.168d0+1.771d0*s+29.35d0*s2) * exp(-5.776d0*s) *
40464  & x**((0.5d0+0.208d0*s)/(1d0-0.794d0*s+1.516d0*s2)) *
40465  & x1**((2.6d0+7.6d0*s)/(1d0+5d0*s)) *
40466  & xl**(5.15d0*s/(1d0+2d0*s)) +
40467  & (0.965d0+22.35d0*s)/(1d0+18.4d0*s) * x * x1**(2.667d0*s)
40468  xglu = (1.808d0+29.9d0*s)/(1d0+26.4d0*s) * exp(-5.28d0*s) *
40469  & x**((-5.35d0*s-10.11d0*s2)/(1d0+31.71d0*s)) *
40470  & x1**((2d0-7.3d0*s+4d0*s2)/(1d0+2.5d0*s)) *
40471  & xl**(10.9d0*s/(1d0+2.5d0*s))
40472  xsea = (0.209d0+0.644d0*s2)/(1d0+0.319d0*s+17.6d0*s2) *
40473  & x**((-0.373d0*s-7.71d0*s2)/(1d0+0.815d0*s+11.0d0*s2)) *
40474  & x1**(4d0+s) * xl**(0.45d0*s)
40475  xsea0 = 0.209d0 * x1**4
40476  ENDIF
40477  ENDIF
40478 
40479 C...Threshold factors for c and b sea.
40480  sll=log(log(q2eff/alam**2)/log(p2eff/alam**2))
40481  xchm=0d0
40482  IF(q2.GT.pmc**2.AND.q2.GT.1.001d0*p2eff) THEN
40483  sch=max(0d0,log(log(pmc**2/alam**2)/log(p2eff/alam**2)))
40484  IF(iset.EQ.0) THEN
40485  xchm=xsea*(1d0-(sch/sll)**2)
40486  ELSE
40487  xchm=max(0d0,xsea-xsea0*x1**(2.667d0*s))*(1d0-sch/sll)
40488  ENDIF
40489  ENDIF
40490  xbot=0d0
40491  IF(q2.GT.pmb**2.AND.q2.GT.1.001d0*p2eff) THEN
40492  sbt=max(0d0,log(log(pmb**2/alam**2)/log(p2eff/alam**2)))
40493  IF(iset.EQ.0) THEN
40494  xbot=xsea*(1d0-(sbt/sll)**2)
40495  ELSE
40496  xbot=max(0d0,xsea-xsea0*x1**(2.667d0*s))*(1d0-sbt/sll)
40497  ENDIF
40498  ENDIF
40499 
40500 C...Fill parton distributions.
40501  xpga(0)=xglu
40502  xpga(1)=xsea
40503  xpga(2)=xsea
40504  xpga(3)=xsea
40505  xpga(4)=xchm
40506  xpga(5)=xbot
40507  xpga(kfa)=xpga(kfa)+xval
40508  DO 110 kfl=1,5
40509  xpga(-kfl)=xpga(kfl)
40510  110 CONTINUE
40511  vxpga(kfa)=xval
40512  vxpga(-kfa)=xval
40513 
40514  RETURN
40515  END
40516 
40517 C*********************************************************************
40518 
40519 C...PYGANO
40520 C...Evaluates the parton distributions of the anomalous photon,
40521 C...inhomogeneously evolved from a scale P2 (where it vanishes) to Q2.
40522 C...KF=0 gives the sum over (up to) 5 flavours,
40523 C...KF<0 limits to flavours up to abs(KF),
40524 C...KF>0 is for flavour KF only.
40525 C...ALAM is the 4-flavour Lambda, which is automatically converted
40526 C...to 3- and 5-flavour equivalents as needed.
40527 C...Adapted from SaSgam library, authors G.A. Schuler and T. Sjostrand.
40528 
40529  SUBROUTINE pygano(KF,X,Q2,P2,ALAM,XPGA,VXPGA)
40530 
40531 C...Double precision and integer declarations.
40532  IMPLICIT DOUBLE PRECISION(a-h, o-z)
40533  IMPLICIT INTEGER(i-n)
40534  INTEGER pyk,pychge,pycomp
40535 C...Local arrays and data.
40536  dimension xpga(-6:6), vxpga(-6:6), alamsq(3:5)
40537  DATA pmc/1.3d0/, pmb/4.6d0/, aem/0.007297d0/, aem2pi/0.0011614d0/
40538 
40539 C...Reset output.
40540  DO 100 kfl=-6,6
40541  xpga(kfl)=0d0
40542  vxpga(kfl)=0d0
40543  100 CONTINUE
40544  IF(q2.LE.p2) RETURN
40545  kfa=iabs(kf)
40546 
40547 C...Calculate Lambda; protect against unphysical Q2 and P2 input.
40548  alamsq(3)=(alam*(pmc/alam)**(2d0/27d0))**2
40549  alamsq(4)=alam**2
40550  alamsq(5)=(alam*(alam/pmb)**(2d0/23d0))**2
40551  p2eff=max(p2,1.2d0*alamsq(3))
40552  IF(kf.EQ.4) p2eff=max(p2eff,pmc**2)
40553  IF(kf.EQ.5) p2eff=max(p2eff,pmb**2)
40554  q2eff=max(q2,p2eff)
40555  xl=-log(x)
40556 
40557 C...Find number of flavours at lower and upper scale.
40558  nfp=4
40559  IF(p2eff.LT.pmc**2) nfp=3
40560  IF(p2eff.GT.pmb**2) nfp=5
40561  nfq=4
40562  IF(q2eff.LT.pmc**2) nfq=3
40563  IF(q2eff.GT.pmb**2) nfq=5
40564 
40565 C...Define range of flavour loop.
40566  IF(kf.EQ.0) THEN
40567  kflmn=1
40568  kflmx=5
40569  ELSEIF(kf.LT.0) THEN
40570  kflmn=1
40571  kflmx=kfa
40572  ELSE
40573  kflmn=kfa
40574  kflmx=kfa
40575  ENDIF
40576 
40577 C...Loop over flavours the photon can branch into.
40578  DO 110 kfl=kflmn,kflmx
40579 
40580 C...Light flavours: calculate t range and (approximate) s range.
40581  IF(kfl.LE.3.AND.(kfl.EQ.1.OR.kfl.EQ.kf)) THEN
40582  tdiff=log(q2eff/p2eff)
40583  s=(6d0/(33d0-2d0*nfq))*log(log(q2eff/alamsq(nfq))/
40584  & log(p2eff/alamsq(nfq)))
40585  IF(nfq.GT.nfp) THEN
40586  q2div=pmb**2
40587  IF(nfq.EQ.4) q2div=pmc**2
40588  snfq=(6d0/(33d0-2d0*nfq))*log(log(q2div/alamsq(nfq))/
40589  & log(p2eff/alamsq(nfq)))
40590  snfp=(6d0/(33d0-2d0*(nfq-1)))*log(log(q2div/alamsq(nfq-1))/
40591  & log(p2eff/alamsq(nfq-1)))
40592  s=s+(log(q2div/p2eff)/log(q2eff/p2eff))*(snfp-snfq)
40593  ENDIF
40594  IF(nfq.EQ.5.AND.nfp.EQ.3) THEN
40595  q2div=pmc**2
40596  snf4=(6d0/(33d0-2d0*4))*log(log(q2div/alamsq(4))/
40597  & log(p2eff/alamsq(4)))
40598  snf3=(6d0/(33d0-2d0*3))*log(log(q2div/alamsq(3))/
40599  & log(p2eff/alamsq(3)))
40600  s=s+(log(q2div/p2eff)/log(q2eff/p2eff))*(snf3-snf4)
40601  ENDIF
40602 
40603 C...u and s quark do not need a separate treatment when d has been done.
40604  ELSEIF(kfl.EQ.2.OR.kfl.EQ.3) THEN
40605 
40606 C...Charm: as above, but only include range above c threshold.
40607  ELSEIF(kfl.EQ.4) THEN
40608  IF(q2.LE.pmc**2) goto 110
40609  p2eff=max(p2eff,pmc**2)
40610  q2eff=max(q2eff,p2eff)
40611  tdiff=log(q2eff/p2eff)
40612  s=(6d0/(33d0-2d0*nfq))*log(log(q2eff/alamsq(nfq))/
40613  & log(p2eff/alamsq(nfq)))
40614  IF(nfq.EQ.5.AND.nfp.EQ.4) THEN
40615  q2div=pmb**2
40616  snfq=(6d0/(33d0-2d0*nfq))*log(log(q2div/alamsq(nfq))/
40617  & log(p2eff/alamsq(nfq)))
40618  snfp=(6d0/(33d0-2d0*(nfq-1)))*log(log(q2div/alamsq(nfq-1))/
40619  & log(p2eff/alamsq(nfq-1)))
40620  s=s+(log(q2div/p2eff)/log(q2eff/p2eff))*(snfp-snfq)
40621  ENDIF
40622 
40623 C...Bottom: as above, but only include range above b threshold.
40624  ELSEIF(kfl.EQ.5) THEN
40625  IF(q2.LE.pmb**2) goto 110
40626  p2eff=max(p2eff,pmb**2)
40627  q2eff=max(q2,p2eff)
40628  tdiff=log(q2eff/p2eff)
40629  s=(6d0/(33d0-2d0*nfq))*log(log(q2eff/alamsq(nfq))/
40630  & log(p2eff/alamsq(nfq)))
40631  ENDIF
40632 
40633 C...Evaluate flavour-dependent prefactor (charge^2 etc.).
40634  chsq=1d0/9d0
40635  IF(kfl.EQ.2.OR.kfl.EQ.4) chsq=4d0/9d0
40636  fac=aem2pi*2d0*chsq*tdiff
40637 
40638 C...Evaluate parton distributions (normalized to unit momentum sum).
40639  IF(kfl.EQ.1.OR.kfl.EQ.4.OR.kfl.EQ.5.OR.kfl.EQ.kf) THEN
40640  xval= ((1.5d0+2.49d0*s+26.9d0*s**2)/(1d0+32.3d0*s**2)*x**2 +
40641  & (1.5d0-0.49d0*s+7.83d0*s**2)/(1d0+7.68d0*s**2)*(1d0-x)**2 +
40642  & 1.5d0*s/(1d0-3.2d0*s+7d0*s**2)*x*(1d0-x)) *
40643  & x**(1d0/(1d0+0.58d0*s)) * (1d0-x**2)**(2.5d0*s/(1d0+10d0*s))
40644  xglu= 2d0*s/(1d0+4d0*s+7d0*s**2) *
40645  & x**(-1.67d0*s/(1d0+2d0*s)) * (1d0-x**2)**(1.2d0*s) *
40646  & ((4d0*x**2+7d0*x+4d0)*(1d0-x)/3d0 - 2d0*x*(1d0+x)*xl)
40647  xsea= 0.333d0*s**2/(1d0+4.90d0*s+4.69d0*s**2+21.4d0*s**3) *
40648  & x**(-1.18d0*s/(1d0+1.22d0*s)) * (1d0-x)**(1.2d0*s) *
40649  & ((8d0-73d0*x+62d0*x**2)*(1d0-x)/9d0 +
40650  & (3d0-8d0*x**2/3d0)*x*xl + (2d0*x-1d0)*x*xl**2)
40651 
40652 C...Threshold factors for c and b sea.
40653  sll=log(log(q2eff/alam**2)/log(p2eff/alam**2))
40654  xchm=0d0
40655  IF(q2.GT.pmc**2.AND.q2.GT.1.001d0*p2eff) THEN
40656  sch=max(0d0,log(log(pmc**2/alam**2)/log(p2eff/alam**2)))
40657  xchm=xsea*(1d0-(sch/sll)**3)
40658  ENDIF
40659  xbot=0d0
40660  IF(q2.GT.pmb**2.AND.q2.GT.1.001d0*p2eff) THEN
40661  sbt=max(0d0,log(log(pmb**2/alam**2)/log(p2eff/alam**2)))
40662  xbot=xsea*(1d0-(sbt/sll)**3)
40663  ENDIF
40664  ENDIF
40665 
40666 C...Add contribution of each valence flavour.
40667  xpga(0)=xpga(0)+fac*xglu
40668  xpga(1)=xpga(1)+fac*xsea
40669  xpga(2)=xpga(2)+fac*xsea
40670  xpga(3)=xpga(3)+fac*xsea
40671  xpga(4)=xpga(4)+fac*xchm
40672  xpga(5)=xpga(5)+fac*xbot
40673  xpga(kfl)=xpga(kfl)+fac*xval
40674  vxpga(kfl)=vxpga(kfl)+fac*xval
40675  110 CONTINUE
40676  DO 120 kfl=1,5
40677  xpga(-kfl)=xpga(kfl)
40678  vxpga(-kfl)=vxpga(kfl)
40679  120 CONTINUE
40680 
40681  RETURN
40682  END
40683 
40684 
40685 C*********************************************************************
40686 
40687 C...PYGBEH
40688 C...Evaluates the Bethe-Heitler cross section for heavy flavour
40689 C...production.
40690 C...Adapted from SaSgam library, authors G.A. Schuler and T. Sjostrand.
40691 
40692  SUBROUTINE pygbeh(KF,X,Q2,P2,PM2,XPBH)
40693 
40694 C...Double precision and integer declarations.
40695  IMPLICIT DOUBLE PRECISION(a-h, o-z)
40696  IMPLICIT INTEGER(i-n)
40697  INTEGER pyk,pychge,pycomp
40698 
40699 C...Local data.
40700  DATA aem2pi/0.0011614d0/
40701 
40702 C...Reset output.
40703  xpbh=0d0
40704  sigbh=0d0
40705 
40706 C...Check kinematics limits.
40707  IF(x.GE.q2/(4d0*pm2+q2+p2)) RETURN
40708  w2=q2*(1d0-x)/x-p2
40709  beta2=1d0-4d0*pm2/w2
40710  IF(beta2.LT.1d-10) RETURN
40711  beta=sqrt(beta2)
40712  rmq=4d0*pm2/q2
40713 
40714 C...Simple case: P2 = 0.
40715  IF(p2.LT.1d-4) THEN
40716  IF(beta.LT.0.99d0) THEN
40717  xbl=log((1d0+beta)/(1d0-beta))
40718  ELSE
40719  xbl=log((1d0+beta)**2*w2/(4d0*pm2))
40720  ENDIF
40721  sigbh=beta*(8d0*x*(1d0-x)-1d0-rmq*x*(1d0-x))+
40722  & xbl*(x**2+(1d0-x)**2+rmq*x*(1d0-3d0*x)-0.5d0*rmq**2*x**2)
40723 
40724 C...Complicated case: P2 > 0, based on approximation of
40725 C...C.T. Hill and G.G. Ross, Nucl. Phys. B148 (1979) 373
40726  ELSE
40727  rpq=1d0-4d0*x**2*p2/q2
40728  IF(rpq.GT.1d-10) THEN
40729  rpbe=sqrt(rpq*beta2)
40730  IF(rpbe.LT.0.99d0) THEN
40731  xbl=log((1d0+rpbe)/(1d0-rpbe))
40732  xbi=2d0*rpbe/(1d0-rpbe**2)
40733  ELSE
40734  rpbesn=4d0*pm2/w2+(4d0*x**2*p2/q2)*beta2
40735  xbl=log((1d0+rpbe)**2/rpbesn)
40736  xbi=2d0*rpbe/rpbesn
40737  ENDIF
40738  sigbh=beta*(6d0*x*(1d0-x)-1d0)+
40739  & xbl*(x**2+(1d0-x)**2+rmq*x*(1d0-3d0*x)-0.5d0*rmq**2*x**2)+
40740  & xbi*(2d0*x/q2)*(pm2*x*(2d0-rmq)-p2*x)
40741  ENDIF
40742  ENDIF
40743 
40744 C...Multiply by charge-squared etc. to get parton distribution.
40745  chsq=1d0/9d0
40746  IF(iabs(kf).EQ.2.OR.iabs(kf).EQ.4) chsq=4d0/9d0
40747  xpbh=3d0*chsq*aem2pi*x*sigbh
40748 
40749  RETURN
40750  END
40751 
40752 C*********************************************************************
40753 
40754 C...PYGDIR
40755 C...Evaluates the direct contribution, i.e. the C^gamma term,
40756 C...as needed in MSbar parametrizations.
40757 C...Adapted from SaSgam library, authors G.A. Schuler and T. Sjostrand.
40758 
40759  SUBROUTINE pygdir(X,Q2,P2,Q02,XPGA)
40760 
40761 C...Double precision and integer declarations.
40762  IMPLICIT DOUBLE PRECISION(a-h, o-z)
40763  IMPLICIT INTEGER(i-n)
40764  INTEGER pyk,pychge,pycomp
40765 C...Local array and data.
40766  dimension xpga(-6:6)
40767  DATA pmc/1.3d0/, pmb/4.6d0/, aem2pi/0.0011614d0/
40768 
40769 C...Reset output.
40770  DO 100 kfl=-6,6
40771  xpga(kfl)=0d0
40772  100 CONTINUE
40773 
40774 C...Evaluate common x-dependent expression.
40775  xtmp = (x**2+(1d0-x)**2) * (-log(x)) - 1d0
40776  cgam = 3d0*aem2pi*x * (xtmp*(1d0+p2/(p2+q02)) + 6d0*x*(1d0-x))
40777 
40778 C...d, u, s part by simple charge factor.
40779  xpga(1)=(1d0/9d0)*cgam
40780  xpga(2)=(4d0/9d0)*cgam
40781  xpga(3)=(1d0/9d0)*cgam
40782 
40783 C...Also fill for antiquarks.
40784  DO 110 kf=1,5
40785  xpga(-kf)=xpga(kf)
40786  110 CONTINUE
40787 
40788  RETURN
40789  END
40790 
40791 C*********************************************************************
40792 
40793 C...PYPDPI
40794 C...Gives pi+ parton distribution according to two different
40795 C...parametrizations.
40796 
40797  SUBROUTINE pypdpi(X,Q2,XPPI)
40798 
40799 C...Double precision and integer declarations.
40800  IMPLICIT DOUBLE PRECISION(a-h, o-z)
40801  IMPLICIT INTEGER(i-n)
40802  INTEGER pyk,pychge,pycomp
40803 C...Commonblocks.
40804  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
40805  common/pypars/mstp(200),parp(200),msti(200),pari(200)
40806  common/pyint1/mint(400),vint(400)
40807  SAVE /pydat1/,/pypars/,/pyint1/
40808 C...Local arrays.
40809  dimension xppi(-6:6),cow(3,5,4,2),xq(9),ts(6)
40810 
40811 C...The following data lines are coefficients needed in the
40812 C...Owens pion parton distribution parametrizations, see below.
40813 C...Expansion coefficients for up and down valence quark distributions.
40814  DATA ((cow(ip,is,1,1),is=1,5),ip=1,3)/
40815  &4.0000d-01, 7.0000d-01, 0.0000d+00, 0.0000d+00, 0.0000d+00,
40816  &-6.2120d-02, 6.4780d-01, 0.0000d+00, 0.0000d+00, 0.0000d+00,
40817  &-7.1090d-03, 1.3350d-02, 0.0000d+00, 0.0000d+00, 0.0000d+00/
40818  DATA ((cow(ip,is,1,2),is=1,5),ip=1,3)/
40819  &4.0000d-01, 6.2800d-01, 0.0000d+00, 0.0000d+00, 0.0000d+00,
40820  &-5.9090d-02, 6.4360d-01, 0.0000d+00, 0.0000d+00, 0.0000d+00,
40821  &-6.5240d-03, 1.4510d-02, 0.0000d+00, 0.0000d+00, 0.0000d+00/
40822 C...Expansion coefficients for gluon distribution.
40823  DATA ((cow(ip,is,2,1),is=1,5),ip=1,3)/
40824  &8.8800d-01, 0.0000d+00, 3.1100d+00, 6.0000d+00, 0.0000d+00,
40825  &-1.8020d+00, -1.5760d+00, -1.3170d-01, 2.8010d+00, -1.7280d+01,
40826  &1.8120d+00, 1.2000d+00, 5.0680d-01, -1.2160d+01, 2.0490d+01/
40827  DATA ((cow(ip,is,2,2),is=1,5),ip=1,3)/
40828  &7.9400d-01, 0.0000d+00, 2.8900d+00, 6.0000d+00, 0.0000d+00,
40829  &-9.1440d-01, -1.2370d+00, 5.9660d-01, -3.6710d+00, -8.1910d+00,
40830  &5.9660d-01, 6.5820d-01, -2.5500d-01, -2.3040d+00, 7.7580d+00/
40831 C...Expansion coefficients for (up+down+strange) quark sea distribution.
40832  DATA ((cow(ip,is,3,1),is=1,5),ip=1,3)/
40833  &9.0000d-01, 0.0000d+00, 5.0000d+00, 0.0000d+00, 0.0000d+00,
40834  &-2.4280d-01, -2.1200d-01, 8.6730d-01, 1.2660d+00, 2.3820d+00,
40835  &1.3860d-01, 3.6710d-03, 4.7470d-02, -2.2150d+00, 3.4820d-01/
40836  DATA ((cow(ip,is,3,2),is=1,5),ip=1,3)/
40837  &9.0000d-01, 0.0000d+00, 5.0000d+00, 0.0000d+00, 0.0000d+00,
40838  &-1.4170d-01, -1.6970d-01, -2.4740d+00, -2.5340d+00, 5.6210d-01,
40839  &-1.7400d-01, -9.6230d-02, 1.5750d+00, 1.3780d+00, -2.7010d-01/
40840 C...Expansion coefficients for charm quark sea distribution.
40841  DATA ((cow(ip,is,4,1),is=1,5),ip=1,3)/
40842  &0.0000d+00, -2.2120d-02, 2.8940d+00, 0.0000d+00, 0.0000d+00,
40843  &7.9280d-02, -3.7850d-01, 9.4330d+00, 5.2480d+00, 8.3880d+00,
40844  &-6.1340d-02, -1.0880d-01, -1.0852d+01, -7.1870d+00, -1.1610d+01/
40845  DATA ((cow(ip,is,4,2),is=1,5),ip=1,3)/
40846  &0.0000d+00, -8.8200d-02, 1.9240d+00, 0.0000d+00, 0.0000d+00,
40847  &6.2290d-02, -2.8920d-01, 2.4240d-01, -4.4630d+00, -8.3670d-01,
40848  &-4.0990d-02, -1.0820d-01, 2.0360d+00, 5.2090d+00, -4.8400d-02/
40849 
40850 C...Euler's beta function, requires ordinary Gamma function
40851  eulbet(x,y)=pygamm(x)*pygamm(y)/pygamm(x+y)
40852 
40853 C...Reset output array.
40854  DO 100 kfl=-6,6
40855  xppi(kfl)=0d0
40856  100 CONTINUE
40857 
40858  IF(mstp(53).LE.2) THEN
40859 C...Pion parton distributions from Owens.
40860 C...Allowed variable range: 4 GeV^2 < Q^2 < approx 2000 GeV^2.
40861 
40862 C...Determine set, Lambda and s expansion variable.
40863  nset=mstp(53)
40864  IF(nset.EQ.1) alam=0.2d0
40865  IF(nset.EQ.2) alam=0.4d0
40866  vint(231)=4d0
40867  IF(mstp(57).LE.0) THEN
40868  sd=0d0
40869  ELSE
40870  q2in=min(2d3,max(4d0,q2))
40871  sd=log(log(q2in/alam**2)/log(4d0/alam**2))
40872  ENDIF
40873 
40874 C...Calculate parton distributions.
40875  DO 120 kfl=1,4
40876  DO 110 is=1,5
40877  ts(is)=cow(1,is,kfl,nset)+cow(2,is,kfl,nset)*sd+
40878  & cow(3,is,kfl,nset)*sd**2
40879  110 CONTINUE
40880  IF(kfl.EQ.1) THEN
40881  xq(kfl)=x**ts(1)*(1d0-x)**ts(2)/eulbet(ts(1),ts(2)+1d0)
40882  ELSE
40883  xq(kfl)=ts(1)*x**ts(2)*(1d0-x)**ts(3)*(1d0+ts(4)*x+
40884  & ts(5)*x**2)
40885  ENDIF
40886  120 CONTINUE
40887 
40888 C...Put into output array.
40889  xppi(0)=xq(2)
40890  xppi(1)=xq(3)/6d0
40891  xppi(2)=xq(1)+xq(3)/6d0
40892  xppi(3)=xq(3)/6d0
40893  xppi(4)=xq(4)
40894  xppi(-1)=xq(1)+xq(3)/6d0
40895  xppi(-2)=xq(3)/6d0
40896  xppi(-3)=xq(3)/6d0
40897  xppi(-4)=xq(4)
40898 
40899 C...Leading order pion parton distributions from Glueck, Reya and Vogt.
40900 C...Allowed variable range: 0.25 GeV^2 < Q^2 < 10^8 GeV^2 and
40901 C...10^-5 < x < 1.
40902  ELSE
40903 
40904 C...Determine s expansion variable and some x expressions.
40905  vint(231)=0.25d0
40906  IF(mstp(57).LE.0) THEN
40907  sd=0d0
40908  ELSE
40909  q2in=min(1d8,max(0.25d0,q2))
40910  sd=log(log(q2in/0.232d0**2)/log(0.25d0/0.232d0**2))
40911  ENDIF
40912  sd2=sd**2
40913  xl=-log(x)
40914  xs=sqrt(x)
40915 
40916 C...Evaluate valence, gluon and sea distributions.
40917  xfval=(0.519d0+0.180d0*sd-0.011d0*sd2)*x**(0.499d0-0.027d0*sd)*
40918  & (1d0+(0.381d0-0.419d0*sd)*xs)*(1d0-x)**(0.367d0+0.563d0*sd)
40919  xfglu=(x**(0.482d0+0.341d0*sqrt(sd))*((0.678d0+0.877d0*
40920  & sd-0.175d0*sd2)+
40921  & (0.338d0-1.597d0*sd)*xs+(-0.233d0*sd+0.406d0*sd2)*x)+
40922  & sd**0.599d0*exp(-(0.618d0+2.070d0*sd)+sqrt(3.676d0*sd**1.263d0*
40923  & xl)))*
40924  & (1d0-x)**(0.390d0+1.053d0*sd)
40925  xfsea=sd**0.55d0*(1d0-0.748d0*xs+(0.313d0+0.935d0*sd)*x)*(1d0-
40926  & x)**3.359d0*
40927  & exp(-(4.433d0+1.301d0*sd)+sqrt((9.30d0-0.887d0*sd)*sd**0.56d0*
40928  & xl))/
40929  & xl**(2.538d0-0.763d0*sd)
40930  IF(sd.LE.0.888d0) THEN
40931  xfchm=0d0
40932  ELSE
40933  xfchm=(sd-0.888d0)**1.02d0*(1d0+1.008d0*x)*(1d0-x)**(1.208d0+
40934  & 0.771d0*sd)*
40935  & exp(-(4.40d0+1.493d0*sd)+sqrt((2.032d0+1.901d0*sd)*sd**0.39d0*
40936  & xl))
40937  ENDIF
40938  IF(sd.LE.1.351d0) THEN
40939  xfbot=0d0
40940  ELSE
40941  xfbot=(sd-1.351d0)**1.03d0*(1d0-x)**(0.697d0+0.855d0*sd)*
40942  & exp(-(4.51d0+1.490d0*sd)+sqrt((3.056d0+1.694d0*sd)*sd**0.39d0*
40943  & xl))
40944  ENDIF
40945 
40946 C...Put into output array.
40947  xppi(0)=xfglu
40948  xppi(1)=xfsea
40949  xppi(2)=xfsea
40950  xppi(3)=xfsea
40951  xppi(4)=xfchm
40952  xppi(5)=xfbot
40953  DO 130 kfl=1,5
40954  xppi(-kfl)=xppi(kfl)
40955  130 CONTINUE
40956  xppi(2)=xppi(2)+xfval
40957  xppi(-1)=xppi(-1)+xfval
40958  ENDIF
40959 
40960  RETURN
40961  END
40962 
40963 C*********************************************************************
40964 
40965 C...PYPDPR
40966 C...Gives proton parton distributions according to a few different
40967 C...parametrizations.
40968 
40969  SUBROUTINE pypdpr(X,Q2,XPPR)
40970 
40971 C...Double precision and integer declarations.
40972  IMPLICIT DOUBLE PRECISION(a-h, o-z)
40973  IMPLICIT INTEGER(i-n)
40974  INTEGER pyk,pychge,pycomp
40975 C...Commonblocks.
40976  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
40977  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
40978  common/pypars/mstp(200),parp(200),msti(200),pari(200)
40979  common/pyint1/mint(400),vint(400)
40980  SAVE /pydat1/,/pydat2/,/pypars/,/pyint1/
40981 C...Arrays and data.
40982  dimension xppr(-6:6),q2min(16)
40983  DATA q2min/ 2.56d0, 2.56d0, 2.56d0, 0.4d0, 0.4d0, 0.4d0,
40984  &1.0d0, 1.0d0, 2*0d0, 0.25d0, 5d0, 5d0, 4d0, 4d0, 0d0/
40985 
40986 C...Reset output array.
40987  DO 100 kfl=-6,6
40988  xppr(kfl)=0d0
40989  100 CONTINUE
40990 
40991 C...Common preliminaries.
40992  nset=max(1,min(16,mstp(51)))
40993  IF(nset.EQ.9.OR.nset.EQ.10) nset=6
40994  vint(231)=q2min(nset)
40995  IF(mstp(57).EQ.0) THEN
40996  q2l=q2min(nset)
40997  ELSE
40998  q2l=max(q2min(nset),q2)
40999  ENDIF
41000 
41001  IF(nset.GE.1.AND.nset.LE.3) THEN
41002 C...Interface to the CTEQ 3 parton distributions.
41003  qrt=sqrt(max(1d0,q2l))
41004 
41005 C...Loop over flavours.
41006  DO 110 i=-6,6
41007  IF(i.LE.0) THEN
41008  xppr(i)=pycteq(nset,i,x,qrt)
41009  ELSEIF(i.LE.2) THEN
41010  xppr(i)=pycteq(nset,i,x,qrt)+xppr(-i)
41011  ELSE
41012  xppr(i)=xppr(-i)
41013  ENDIF
41014  110 CONTINUE
41015 
41016  ELSEIF(nset.GE.4.AND.nset.LE.6) THEN
41017 C...Interface to the GRV 94 distributions.
41018  IF(nset.EQ.4) THEN
41019  CALL pygrvl(x, q2l, uv, dv, del, udb, sb, chm, bot, gl)
41020  ELSEIF(nset.EQ.5) THEN
41021  CALL pygrvm(x, q2l, uv, dv, del, udb, sb, chm, bot, gl)
41022  ELSE
41023  CALL pygrvd(x, q2l, uv, dv, del, udb, sb, chm, bot, gl)
41024  ENDIF
41025 
41026 C...Put into output array.
41027  xppr(0)=gl
41028  xppr(-1)=0.5d0*(udb+del)
41029  xppr(-2)=0.5d0*(udb-del)
41030  xppr(-3)=sb
41031  xppr(-4)=chm
41032  xppr(-5)=bot
41033  xppr(1)=dv+xppr(-1)
41034  xppr(2)=uv+xppr(-2)
41035  xppr(3)=sb
41036  xppr(4)=chm
41037  xppr(5)=bot
41038 
41039  ELSEIF(nset.EQ.7) THEN
41040 C...Interface to the CTEQ 5L parton distributions.
41041 C...Range of validity 10^-6 < x < 1, 1 < Q < 10^4 extended by
41042 C...freezing x*f(x,Q2) at borders.
41043  qrt=sqrt(max(1d0,min(1d8,q2l)))
41044  xin=max(1d-6,min(1d0,x))
41045 
41046 C...Loop over flavours (with u <-> d notation mismatch).
41047  sumudb=pyct5l(-1,xin,qrt)
41048  ratudb=pyct5l(-2,xin,qrt)
41049  DO 120 i=-5,2
41050  IF(i.EQ.1) THEN
41051  xppr(i)=xin*pyct5l(2,xin,qrt)
41052  ELSEIF(i.EQ.2) THEN
41053  xppr(i)=xin*pyct5l(1,xin,qrt)
41054  ELSEIF(i.EQ.-1) THEN
41055  xppr(i)=xin*sumudb*ratudb/(1d0+ratudb)
41056  ELSEIF(i.EQ.-2) THEN
41057  xppr(i)=xin*sumudb/(1d0+ratudb)
41058  ELSE
41059  xppr(i)=xin*pyct5l(i,xin,qrt)
41060  IF(i.LT.0) xppr(-i)=xppr(i)
41061  ENDIF
41062  120 CONTINUE
41063 
41064  ELSEIF(nset.EQ.8) THEN
41065 C...Interface to the CTEQ 5M1 parton distributions.
41066  qrt=sqrt(max(1d0,min(1d8,q2l)))
41067  xin=max(1d-6,min(1d0,x))
41068 
41069 C...Loop over flavours (with u <-> d notation mismatch).
41070  sumudb=pyct5m(-1,xin,qrt)
41071  ratudb=pyct5m(-2,xin,qrt)
41072  DO 130 i=-5,2
41073  IF(i.EQ.1) THEN
41074  xppr(i)=xin*pyct5m(2,xin,qrt)
41075  ELSEIF(i.EQ.2) THEN
41076  xppr(i)=xin*pyct5m(1,xin,qrt)
41077  ELSEIF(i.EQ.-1) THEN
41078  xppr(i)=xin*sumudb*ratudb/(1d0+ratudb)
41079  ELSEIF(i.EQ.-2) THEN
41080  xppr(i)=xin*sumudb/(1d0+ratudb)
41081  ELSE
41082  xppr(i)=xin*pyct5m(i,xin,qrt)
41083  IF(i.LT.0) xppr(-i)=xppr(i)
41084  ENDIF
41085  130 CONTINUE
41086 
41087  ELSEIF(nset.GE.11.AND.nset.LE.15) THEN
41088 C...GRV92LO, EHLQ1, EHLQ2, DO1 AND DO2 distributions:
41089 C...obsolete but offers backwards compatibility.
41090  CALL pypdpo(x,q2l,xppr)
41091 
41092 C...Symmetric choice for debugging only
41093  ELSEIF(nset.EQ.16) THEN
41094  xppr(0)=.5d0/x
41095  xppr(1)=.05d0/x
41096  xppr(2)=.05d0/x
41097  xppr(3)=.05d0/x
41098  xppr(4)=.05d0/x
41099  xppr(5)=.05d0/x
41100  xppr(-1)=.05d0/x
41101  xppr(-2)=.05d0/x
41102  xppr(-3)=.05d0/x
41103  xppr(-4)=.05d0/x
41104  xppr(-5)=.05d0/x
41105 
41106  ENDIF
41107 
41108  RETURN
41109  END
41110 
41111 C*********************************************************************
41112 
41113 C...PYCTEQ
41114 C...Gives the CTEQ 3 parton distribution function sets in
41115 C...parametrized form, of October 24, 1994.
41116 C...Authors: H.L. Lai, J. Botts, J. Huston, J.G. Morfin, J.F. Owens,
41117 C...J. Qiu, W.K. Tung and H. Weerts.
41118 
41119  FUNCTION pycteq (ISET, IPRT, X, Q)
41120 
41121 C...Double precision declaration.
41122  IMPLICIT DOUBLE PRECISION(a-h, o-z)
41123  IMPLICIT INTEGER(i-n)
41124 
41125 C...Data on Lambda values of fits, minimum Q and quark masses.
41126  dimension alm(3), qms(4:6)
41127  DATA alm / 0.177d0, 0.239d0, 0.247d0 /
41128  DATA qmn / 1.60d0 /, (qms(i), i=4,6) / 1.60d0, 5.00d0, 180.0d0 /
41129 
41130 C....Check flavour thresholds. Set up QI for SB.
41131  ip = iabs(iprt)
41132  IF(ip .GE. 4) THEN
41133  IF(q .LE. qms(ip)) THEN
41134  pycteq = 0d0
41135  RETURN
41136  ENDIF
41137  qi = qms(ip)
41138  ELSE
41139  qi = qmn
41140  ENDIF
41141 
41142 C...Use "standard lambda" of parametrization program for expansion.
41143  alam = alm(iset)
41144  sbl = log(q/alam) / log(qi/alam)
41145  sb = log(sbl)
41146  sb2 = sb*sb
41147  sb3 = sb2*sb
41148 
41149 C...Expansion for CTEQ3L.
41150  IF(iset .EQ. 1) THEN
41151  IF(iprt .EQ. 2) THEN
41152  a0=exp( 0.1907d+00+0.4205d-01*sb +0.2752d+00*sb2-
41153  & 0.3171d+00*sb3)
41154  a1= 0.4611d+00+0.2331d-01*sb -0.3403d-01*sb2+0.3174d-01*sb3
41155  a2= 0.3504d+01+0.5739d+00*sb +0.2676d+00*sb2-0.1553d+00*sb3
41156  a3= 0.7452d+01-0.6742d+01*sb +0.2849d+01*sb2-0.1964d+00*sb3
41157  a4= 0.1116d+01-0.3435d+00*sb +0.2865d+00*sb2-0.1288d+00*sb3
41158  a5= 0.6659d-01+0.2714d+00*sb -0.2688d+00*sb2+0.2763d+00*sb3
41159  ELSEIF(iprt .EQ. 1) THEN
41160  a0=exp( 0.1141d+00+0.4764d+00*sb -0.1745d+01*sb2+
41161  & 0.7728d+00*sb3)
41162  a1= 0.4275d+00-0.1290d+00*sb +0.3609d+00*sb2-0.1689d+00*sb3
41163  a2= 0.3000d+01+0.2946d+01*sb -0.4117d+01*sb2+0.1989d+01*sb3
41164  a3=-0.1302d+01+0.2322d+01*sb -0.4258d+01*sb2+0.2109d+01*sb3
41165  a4= 0.2586d+01-0.1920d+00*sb -0.3754d+00*sb2+0.2731d+00*sb3
41166  a5=-0.2251d+00-0.5374d+00*sb +0.2245d+01*sb2-0.1034d+01*sb3
41167  ELSEIF(iprt .EQ. 0) THEN
41168  a0=exp(-0.7631d+00-0.7241d+00*sb -0.1170d+01*sb2+
41169  & 0.5343d+00*sb3)
41170  a1=-0.3573d+00+0.3469d+00*sb -0.3396d+00*sb2+0.9188d-01*sb3
41171  a2= 0.5604d+01+0.7458d+00*sb -0.5082d+00*sb2+0.1844d+00*sb3
41172  a3= 0.1549d+02-0.1809d+02*sb +0.1162d+02*sb2-0.3483d+01*sb3
41173  a4= 0.9881d+00+0.1364d+00*sb -0.4421d+00*sb2+0.2051d+00*sb3
41174  a5=-0.9505d-01+0.3259d+01*sb -0.1547d+01*sb2+0.2918d+00*sb3
41175  ELSEIF(iprt .EQ. -1) THEN
41176  a0=exp(-0.2449d+01-0.3513d+01*sb +0.4529d+01*sb2-
41177  & 0.2031d+01*sb3)
41178  a1=-0.4050d+00+0.3411d+00*sb -0.3669d+00*sb2+0.1109d+00*sb3
41179  a2= 0.7470d+01-0.2982d+01*sb +0.5503d+01*sb2-0.2419d+01*sb3
41180  a3= 0.1503d+02+0.1638d+01*sb -0.8772d+01*sb2+0.3852d+01*sb3
41181  a4= 0.1137d+01-0.1006d+01*sb +0.1485d+01*sb2-0.6389d+00*sb3
41182  a5=-0.5299d+00+0.3160d+01*sb -0.3104d+01*sb2+0.1219d+01*sb3
41183  ELSEIF(iprt .EQ. -2) THEN
41184  a0=exp(-0.2740d+01-0.7987d-01*sb -0.9015d+00*sb2-
41185  & 0.9872d-01*sb3)
41186  a1=-0.3909d+00+0.1244d+00*sb -0.4487d-01*sb2+0.1277d-01*sb3
41187  a2= 0.9163d+01+0.2823d+00*sb -0.7720d+00*sb2-0.9360d-02*sb3
41188  a3= 0.1080d+02-0.3915d+01*sb -0.1153d+01*sb2+0.2649d+01*sb3
41189  a4= 0.9894d+00-0.1647d+00*sb -0.9426d-02*sb2+0.2945d-02*sb3
41190  a5=-0.3395d+00+0.6998d+00*sb +0.7000d+00*sb2-0.6730d-01*sb3
41191  ELSEIF(iprt .EQ. -3) THEN
41192  a0=exp(-0.3640d+01+0.1250d+01*sb -0.2914d+01*sb2+
41193  & 0.8390d+00*sb3)
41194  a1=-0.3595d+00-0.5259d-01*sb +0.3122d+00*sb2-0.1642d+00*sb3
41195  a2= 0.7305d+01+0.9727d+00*sb -0.9788d+00*sb2-0.5193d-01*sb3
41196  a3= 0.1198d+02-0.1799d+02*sb +0.2614d+02*sb2-0.1091d+02*sb3
41197  a4= 0.9882d+00-0.6101d+00*sb +0.9737d+00*sb2-0.4935d+00*sb3
41198  a5=-0.1186d+00-0.3231d+00*sb +0.3074d+01*sb2-0.1274d+01*sb3
41199  ELSEIF(iprt .EQ. -4) THEN
41200  a0=sb** 0.1122d+01*exp(-0.3718d+01-0.1335d+01*sb +
41201  & 0.1651d-01*sb2)
41202  a1=-0.4719d+00+0.7509d+00*sb -0.8420d+00*sb2+0.2901d+00*sb3
41203  a2= 0.6194d+01-0.1641d+01*sb +0.4907d+01*sb2-0.2523d+01*sb3
41204  a3= 0.4426d+01-0.4270d+01*sb +0.6581d+01*sb2-0.3474d+01*sb3
41205  a4= 0.2683d+00+0.9876d+00*sb -0.7612d+00*sb2+0.1780d+00*sb3
41206  a5=-0.4547d+00+0.4410d+01*sb -0.3712d+01*sb2+0.1245d+01*sb3
41207  ELSEIF(iprt .EQ. -5) THEN
41208  a0=sb** 0.9838d+00*exp(-0.2548d+01-0.7660d+01*sb +
41209  & 0.3702d+01*sb2)
41210  a1=-0.3122d+00-0.2120d+00*sb +0.5716d+00*sb2-0.3773d+00*sb3
41211  a2= 0.6257d+01-0.8214d-01*sb -0.2537d+01*sb2+0.2981d+01*sb3
41212  a3=-0.6723d+00+0.2131d+01*sb +0.9599d+01*sb2-0.7910d+01*sb3
41213  a4= 0.9169d-01+0.4295d-01*sb -0.5017d+00*sb2+0.3811d+00*sb3
41214  a5= 0.2402d+00+0.2656d+01*sb -0.1586d+01*sb2+0.2880d+00*sb3
41215  ELSEIF(iprt .EQ. -6) THEN
41216  a0=sb** 0.1001d+01*exp(-0.6934d+01+0.3050d+01*sb -
41217  & 0.6943d+00*sb2)
41218  a1=-0.1713d+00-0.5167d+00*sb +0.1241d+01*sb2-0.1703d+01*sb3
41219  a2= 0.6169d+01+0.3023d+01*sb -0.1972d+02*sb2+0.1069d+02*sb3
41220  a3= 0.4439d+01-0.1746d+02*sb +0.1225d+02*sb2+0.8350d+00*sb3
41221  a4= 0.5458d+00-0.4586d+00*sb +0.9089d+00*sb2-0.4049d+00*sb3
41222  a5= 0.3207d+01-0.3362d+01*sb +0.5877d+01*sb2-0.7659d+01*sb3
41223  ENDIF
41224 
41225 C...Expansion for CTEQ3M.
41226  ELSEIF(iset .EQ. 2) THEN
41227  IF(iprt .EQ. 2) THEN
41228  a0=exp( 0.2259d+00+0.1237d+00*sb +0.3035d+00*sb2-
41229  & 0.2935d+00*sb3)
41230  a1= 0.5085d+00+0.1651d-01*sb -0.3592d-01*sb2+0.2782d-01*sb3
41231  a2= 0.3732d+01+0.4901d+00*sb +0.2218d+00*sb2-0.1116d+00*sb3
41232  a3= 0.7011d+01-0.6620d+01*sb +0.2557d+01*sb2-0.1360d+00*sb3
41233  a4= 0.8969d+00-0.2429d+00*sb +0.1811d+00*sb2-0.6888d-01*sb3
41234  a5= 0.8636d-01+0.2558d+00*sb -0.3082d+00*sb2+0.2535d+00*sb3
41235  ELSEIF(iprt .EQ. 1) THEN
41236  a0=exp(-0.7266d+00-0.1584d+01*sb +0.1259d+01*sb2-
41237  & 0.4305d-01*sb3)
41238  a1= 0.5285d+00-0.3721d+00*sb +0.5150d+00*sb2-0.1697d+00*sb3
41239  a2= 0.4075d+01+0.8282d+00*sb -0.4496d+00*sb2+0.2107d+00*sb3
41240  a3= 0.3279d+01+0.5066d+01*sb -0.9134d+01*sb2+0.2897d+01*sb3
41241  a4= 0.4399d+00-0.5888d+00*sb +0.4802d+00*sb2-0.1664d+00*sb3
41242  a5= 0.3678d+00-0.8929d+00*sb +0.1592d+01*sb2-0.5713d+00*sb3
41243  ELSEIF(iprt .EQ. 0) THEN
41244  a0=exp(-0.2318d+00-0.9779d+00*sb -0.3783d+00*sb2+
41245  & 0.1037d-01*sb3)
41246  a1=-0.2916d+00+0.1754d+00*sb -0.1884d+00*sb2+0.6116d-01*sb3
41247  a2= 0.5349d+01+0.7460d+00*sb +0.2319d+00*sb2-0.2622d+00*sb3
41248  a3= 0.6920d+01-0.3454d+01*sb +0.2027d+01*sb2-0.7626d+00*sb3
41249  a4= 0.1013d+01+0.1423d+00*sb -0.1798d+00*sb2+0.1872d-01*sb3
41250  a5=-0.5465d-01+0.2303d+01*sb -0.9584d+00*sb2+0.3098d+00*sb3
41251  ELSEIF(iprt .EQ. -1) THEN
41252  a0=exp(-0.2328d+01-0.3061d+01*sb +0.3620d+01*sb2-
41253  & 0.1602d+01*sb3)
41254  a1=-0.3358d+00+0.3198d+00*sb -0.4210d+00*sb2+0.1571d+00*sb3
41255  a2= 0.8478d+01-0.3112d+01*sb +0.5243d+01*sb2-0.2255d+01*sb3
41256  a3= 0.1971d+02+0.3389d+00*sb -0.5268d+01*sb2+0.2099d+01*sb3
41257  a4= 0.1128d+01-0.4701d+00*sb +0.7779d+00*sb2-0.3506d+00*sb3
41258  a5=-0.4708d+00+0.3341d+01*sb -0.3375d+01*sb2+0.1353d+01*sb3
41259  ELSEIF(iprt .EQ. -2) THEN
41260  a0=exp(-0.2906d+01-0.1069d+00*sb -0.1055d+01*sb2+
41261  & 0.2496d+00*sb3)
41262  a1=-0.2875d+00+0.6571d-01*sb -0.1987d-01*sb2-0.1800d-02*sb3
41263  a2= 0.9854d+01-0.2715d+00*sb -0.7407d+00*sb2+0.2888d+00*sb3
41264  a3= 0.1583d+02-0.7687d+01*sb +0.3428d+01*sb2-0.3327d+00*sb3
41265  a4= 0.9763d+00+0.7599d-01*sb -0.2128d+00*sb2+0.6852d-01*sb3
41266  a5=-0.8444d-02+0.9434d+00*sb +0.4152d+00*sb2-0.1481d+00*sb3
41267  ELSEIF(iprt .EQ. -3) THEN
41268  a0=exp(-0.3780d+01+0.2499d+01*sb -0.4962d+01*sb2+
41269  & 0.1936d+01*sb3)
41270  a1=-0.2639d+00-0.1575d+00*sb +0.3584d+00*sb2-0.1646d+00*sb3
41271  a2= 0.8082d+01+0.2794d+01*sb -0.5438d+01*sb2+0.2321d+01*sb3
41272  a3= 0.1811d+02-0.2000d+02*sb +0.1951d+02*sb2-0.6904d+01*sb3
41273  a4= 0.9822d+00+0.4972d+00*sb -0.8690d+00*sb2+0.3415d+00*sb3
41274  a5= 0.1772d+00-0.6078d+00*sb +0.3341d+01*sb2-0.1473d+01*sb3
41275  ELSEIF(iprt .EQ. -4) THEN
41276  a0=sb** 0.1122d+01*exp(-0.4232d+01-0.1808d+01*sb +
41277  & 0.5348d+00*sb2)
41278  a1=-0.2824d+00+0.5846d+00*sb -0.7230d+00*sb2+0.2419d+00*sb3
41279  a2= 0.5683d+01-0.2948d+01*sb +0.5916d+01*sb2-0.2560d+01*sb3
41280  a3= 0.2051d+01+0.4795d+01*sb -0.4271d+01*sb2+0.4174d+00*sb3
41281  a4= 0.1737d+00+0.1717d+01*sb -0.1978d+01*sb2+0.6643d+00*sb3
41282  a5= 0.8689d+00+0.3500d+01*sb -0.3283d+01*sb2+0.1026d+01*sb3
41283  ELSEIF(iprt .EQ. -5) THEN
41284  a0=sb** 0.9906d+00*exp(-0.1496d+01-0.6576d+01*sb +
41285  & 0.1569d+01*sb2)
41286  a1=-0.2140d+00-0.6419d-01*sb -0.2741d-02*sb2+0.3185d-02*sb3
41287  a2= 0.5781d+01+0.1049d+00*sb -0.3930d+00*sb2+0.5174d+00*sb3
41288  a3=-0.9420d+00+0.5511d+00*sb +0.8817d+00*sb2+0.1903d+01*sb3
41289  a4= 0.2418d-01+0.4232d-01*sb -0.1244d-01*sb2-0.2365d-01*sb3
41290  a5= 0.7664d+00+0.1794d+01*sb -0.4917d+00*sb2-0.1284d+00*sb3
41291  ELSEIF(iprt .EQ. -6) THEN
41292  a0=sb** 0.1000d+01*exp(-0.8460d+01+0.1154d+01*sb +
41293  & 0.8838d+01*sb2)
41294  a1=-0.4316d-01-0.2976d+00*sb +0.3174d+00*sb2-0.1429d+01*sb3
41295  a2= 0.4910d+01+0.2273d+01*sb +0.5631d+01*sb2-0.1994d+02*sb3
41296  a3= 0.1190d+02-0.2000d+02*sb -0.2000d+02*sb2+0.1292d+02*sb3
41297  a4= 0.5771d+00-0.2552d+00*sb +0.7510d+00*sb2+0.6923d+00*sb3
41298  a5= 0.4402d+01-0.1627d+01*sb -0.2085d+01*sb2-0.6737d+01*sb3
41299  ENDIF
41300 
41301 C...Expansion for CTEQ3D.
41302  ELSEIF(iset .EQ. 3) THEN
41303  IF(iprt .EQ. 2) THEN
41304  a0=exp( 0.2148d+00+0.5814d-01*sb +0.2734d+00*sb2-
41305  & 0.2902d+00*sb3)
41306  a1= 0.4810d+00+0.1657d-01*sb -0.3800d-01*sb2+0.3125d-01*sb3
41307  a2= 0.3509d+01+0.3923d+00*sb +0.4010d+00*sb2-0.1932d+00*sb3
41308  a3= 0.7055d+01-0.6552d+01*sb +0.3466d+01*sb2-0.5657d+00*sb3
41309  a4= 0.1061d+01-0.3453d+00*sb +0.4089d+00*sb2-0.1817d+00*sb3
41310  a5= 0.8687d-01+0.2548d+00*sb -0.2967d+00*sb2+0.2647d+00*sb3
41311  ELSEIF(iprt .EQ. 1) THEN
41312  a0=exp( 0.3961d+00+0.4914d+00*sb -0.1728d+01*sb2+
41313  & 0.7257d+00*sb3)
41314  a1= 0.4162d+00-0.1419d+00*sb +0.3680d+00*sb2-0.1618d+00*sb3
41315  a2= 0.3248d+01+0.3028d+01*sb -0.4307d+01*sb2+0.1920d+01*sb3
41316  a3=-0.1100d+01+0.2184d+01*sb -0.3820d+01*sb2+0.1717d+01*sb3
41317  a4= 0.2082d+01-0.2756d+00*sb +0.3043d+00*sb2-0.1260d+00*sb3
41318  a5=-0.4822d+00-0.5706d+00*sb +0.2243d+01*sb2-0.9760d+00*sb3
41319  ELSEIF(iprt .EQ. 0) THEN
41320  a0=exp(-0.4665d+00-0.7554d+00*sb -0.3323d+00*sb2-
41321  & 0.2734d-04*sb3)
41322  a1=-0.3359d+00+0.2395d+00*sb -0.2377d+00*sb2+0.7059d-01*sb3
41323  a2= 0.5451d+01+0.6086d+00*sb +0.8606d-01*sb2-0.1425d+00*sb3
41324  a3= 0.1026d+02-0.9352d+01*sb +0.4879d+01*sb2-0.1150d+01*sb3
41325  a4= 0.9935d+00-0.5017d-01*sb -0.1707d-01*sb2-0.1464d-02*sb3
41326  a5=-0.4160d-01+0.2305d+01*sb -0.1063d+01*sb2+0.3211d+00*sb3
41327  ELSEIF(iprt .EQ. -1) THEN
41328  a0=exp(-0.2714d+01-0.2868d+01*sb +0.3700d+01*sb2-
41329  & 0.1671d+01*sb3)
41330  a1=-0.3893d+00+0.3341d+00*sb -0.3897d+00*sb2+0.1420d+00*sb3
41331  a2= 0.8359d+01-0.3267d+01*sb +0.5327d+01*sb2-0.2245d+01*sb3
41332  a3= 0.2359d+02-0.5669d+01*sb -0.4602d+01*sb2+0.3153d+01*sb3
41333  a4= 0.1106d+01-0.4745d+00*sb +0.7739d+00*sb2-0.3417d+00*sb3
41334  a5=-0.5557d+00+0.3433d+01*sb -0.3390d+01*sb2+0.1354d+01*sb3
41335  ELSEIF(iprt .EQ. -2) THEN
41336  a0=exp(-0.3323d+01+0.2296d+00*sb -0.1109d+01*sb2+
41337  & 0.2223d+00*sb3)
41338  a1=-0.3410d+00+0.8847d-01*sb -0.1111d-01*sb2-0.5927d-02*sb3
41339  a2= 0.9753d+01-0.5182d+00*sb -0.4670d+00*sb2+0.1921d+00*sb3
41340  a3= 0.1977d+02-0.1600d+02*sb +0.9481d+01*sb2-0.1864d+01*sb3
41341  a4= 0.9818d+00+0.2839d-02*sb -0.1188d+00*sb2+0.3584d-01*sb3
41342  a5=-0.7934d-01+0.1004d+01*sb +0.3704d+00*sb2-0.1220d+00*sb3
41343  ELSEIF(iprt .EQ. -3) THEN
41344  a0=exp(-0.3985d+01+0.2855d+01*sb -0.5208d+01*sb2+
41345  & 0.1937d+01*sb3)
41346  a1=-0.3337d+00-0.1150d+00*sb +0.3691d+00*sb2-0.1709d+00*sb3
41347  a2= 0.7968d+01+0.3641d+01*sb -0.6599d+01*sb2+0.2642d+01*sb3
41348  a3= 0.1873d+02-0.1999d+02*sb +0.1734d+02*sb2-0.5813d+01*sb3
41349  a4= 0.9731d+00+0.5082d+00*sb -0.8780d+00*sb2+0.3231d+00*sb3
41350  a5=-0.5542d-01-0.4189d+00*sb +0.3309d+01*sb2-0.1439d+01*sb3
41351  ELSEIF(iprt .EQ. -4) THEN
41352  a0=sb** 0.1105d+01*exp(-0.3952d+01-0.1901d+01*sb +
41353  & 0.5137d+00*sb2)
41354  a1=-0.3543d+00+0.6055d+00*sb -0.6941d+00*sb2+0.2278d+00*sb3
41355  a2= 0.5955d+01-0.2629d+01*sb +0.5337d+01*sb2-0.2300d+01*sb3
41356  a3= 0.1933d+01+0.4882d+01*sb -0.3810d+01*sb2+0.2290d+00*sb3
41357  a4= 0.1806d+00+0.1655d+01*sb -0.1893d+01*sb2+0.6395d+00*sb3
41358  a5= 0.4790d+00+0.3612d+01*sb -0.3152d+01*sb2+0.9684d+00*sb3
41359  ELSEIF(iprt .EQ. -5) THEN
41360  a0=sb** 0.9818d+00*exp(-0.1825d+01-0.7464d+01*sb +
41361  & 0.2143d+01*sb2)
41362  a1=-0.2604d+00-0.1400d+00*sb +0.1702d+00*sb2-0.8476d-01*sb3
41363  a2= 0.6005d+01+0.6275d+00*sb -0.2535d+01*sb2+0.2219d+01*sb3
41364  a3=-0.9067d+00+0.1149d+01*sb +0.1974d+01*sb2+0.4716d+01*sb3
41365  a4= 0.3915d-01+0.5945d-01*sb -0.9844d-01*sb2+0.2783d-01*sb3
41366  a5= 0.5500d+00+0.1994d+01*sb -0.6727d+00*sb2-0.1510d+00*sb3
41367  ELSEIF(iprt .EQ. -6) THEN
41368  a0=sb** 0.1002d+01*exp(-0.8553d+01+0.3793d+00*sb +
41369  & 0.9998d+01*sb2)
41370  a1=-0.5870d-01-0.2792d+00*sb +0.6526d+00*sb2-0.1984d+01*sb3
41371  a2= 0.4716d+01+0.4473d+00*sb +0.1128d+02*sb2-0.1937d+02*sb3
41372  a3= 0.1289d+02-0.1742d+02*sb -0.1983d+02*sb2-0.9274d+00*sb3
41373  a4= 0.5647d+00-0.2732d+00*sb +0.1074d+01*sb2+0.5981d+00*sb3
41374  a5= 0.4390d+01-0.1262d+01*sb -0.9026d+00*sb2-0.9394d+01*sb3
41375  ENDIF
41376  ENDIF
41377 
41378 C...Calculation of x * f(x, Q).
41379  pycteq = max(0d0, a0 *(x**a1) *((1d0-x)**a2) *(1d0+a3*(x**a4))
41380  & *(log(1d0+1d0/x))**a5 )
41381 
41382  RETURN
41383  END
41384 
41385 C*********************************************************************
41386 
41387 C...PYGRVL
41388 C...Gives the GRV 94 L (leading order) parton distribution function set
41389 C...in parametrized form.
41390 C...Authors: M. Glueck, E. Reya and A. Vogt.
41391 
41392  SUBROUTINE pygrvl (X, Q2, UV, DV, DEL, UDB, SB, CHM, BOT, GL)
41393 
41394 C...Double precision declaration.
41395  IMPLICIT DOUBLE PRECISION (a - z)
41396 
41397 C...Common expressions.
41398  mu2 = 0.23d0
41399  lam2 = 0.2322d0 * 0.2322d0
41400  s = log(log(q2/lam2) / log(mu2/lam2))
41401  ds = sqrt(s)
41402  s2 = s * s
41403  s3 = s2 * s
41404 
41405 C...uv :
41406  nu = 2.284d0 + 0.802d0 * s + 0.055d0 * s2
41407  aku = 0.590d0 - 0.024d0 * s
41408  bku = 0.131d0 + 0.063d0 * s
41409  au = -0.449d0 - 0.138d0 * s - 0.076d0 * s2
41410  bu = 0.213d0 + 2.669d0 * s - 0.728d0 * s2
41411  cu = 8.854d0 - 9.135d0 * s + 1.979d0 * s2
41412  du = 2.997d0 + 0.753d0 * s - 0.076d0 * s2
41413  uv = pygrvv(x, nu, aku, bku, au, bu, cu, du)
41414 
41415 C...dv :
41416  nd = 0.371d0 + 0.083d0 * s + 0.039d0 * s2
41417  akd = 0.376d0
41418  bkd = 0.486d0 + 0.062d0 * s
41419  ad = -0.509d0 + 3.310d0 * s - 1.248d0 * s2
41420  bd = 12.41d0 - 10.52d0 * s + 2.267d0 * s2
41421  cd = 6.373d0 - 6.208d0 * s + 1.418d0 * s2
41422  dd = 3.691d0 + 0.799d0 * s - 0.071d0 * s2
41423  dv = pygrvv(x, nd, akd, bkd, ad, bd, cd, dd)
41424 
41425 C...del :
41426  ne = 0.082d0 + 0.014d0 * s + 0.008d0 * s2
41427  ake = 0.409d0 - 0.005d0 * s
41428  bke = 0.799d0 + 0.071d0 * s
41429  ae = -38.07d0 + 36.13d0 * s - 0.656d0 * s2
41430  be = 90.31d0 - 74.15d0 * s + 7.645d0 * s2
41431  ce = 0.0d0
41432  de = 7.486d0 + 1.217d0 * s - 0.159d0 * s2
41433  del = pygrvv(x, ne, ake, bke, ae, be, ce, de)
41434 
41435 C...udb :
41436  alx = 1.451d0
41437  bex = 0.271d0
41438  akx = 0.410d0 - 0.232d0 * s
41439  bkx = 0.534d0 - 0.457d0 * s
41440  agx = 0.890d0 - 0.140d0 * s
41441  bgx = -0.981d0
41442  cx = 0.320d0 + 0.683d0 * s
41443  dx = 4.752d0 + 1.164d0 * s + 0.286d0 * s2
41444  ex = 4.119d0 + 1.713d0 * s
41445  esx = 0.682d0 + 2.978d0 * s
41446  udb = pygrvw(x, s, alx, bex, akx, bkx, agx, bgx, cx,
41447  & dx, ex, esx)
41448 
41449 C...sb :
41450  sts = 0d0
41451  als = 0.914d0
41452  bes = 0.577d0
41453  aks = 1.798d0 - 0.596d0 * s
41454  as = -5.548d0 + 3.669d0 * ds - 0.616d0 * s
41455  bs = 18.92d0 - 16.73d0 * ds + 5.168d0 * s
41456  dst = 6.379d0 - 0.350d0 * s + 0.142d0 * s2
41457  est = 3.981d0 + 1.638d0 * s
41458  ess = 6.402d0
41459  sb = pygrvs(x, s, sts, als, bes, aks, as, bs, dst, est, ess)
41460 
41461 C...cb :
41462  stc = 0.888d0
41463  alc = 1.01d0
41464  bec = 0.37d0
41465  akc = 0d0
41466  ac = 0d0
41467  bc = 4.24d0 - 0.804d0 * s
41468  dct = 3.46d0 - 1.076d0 * s
41469  ect = 4.61d0 + 1.49d0 * s
41470  esc = 2.555d0 + 1.961d0 * s
41471  chm = pygrvs(x, s, stc, alc, bec, akc, ac, bc, dct, ect, esc)
41472 
41473 C...bb :
41474  stb = 1.351d0
41475  alb = 1.00d0
41476  beb = 0.51d0
41477  akb = 0d0
41478  ab = 0d0
41479  bb = 1.848d0
41480  dbt = 2.929d0 + 1.396d0 * s
41481  ebt = 4.71d0 + 1.514d0 * s
41482  esb = 4.02d0 + 1.239d0 * s
41483  bot = pygrvs(x, s, stb, alb, beb, akb, ab, bb, dbt, ebt, esb)
41484 
41485 C...gl :
41486  alg = 0.524d0
41487  beg = 1.088d0
41488  akg = 1.742d0 - 0.930d0 * s
41489  bkg = - 0.399d0 * s2
41490  ag = 7.486d0 - 2.185d0 * s
41491  bg = 16.69d0 - 22.74d0 * s + 5.779d0 * s2
41492  cg = -25.59d0 + 29.71d0 * s - 7.296d0 * s2
41493  dg = 2.792d0 + 2.215d0 * s + 0.422d0 * s2 - 0.104d0 * s3
41494  eg = 0.807d0 + 2.005d0 * s
41495  esg = 3.841d0 + 0.316d0 * s
41496  gl = pygrvw(x, s, alg, beg, akg, bkg, ag, bg, cg,
41497  & dg, eg, esg)
41498 
41499  RETURN
41500  END
41501 
41502 C*********************************************************************
41503 
41504 C...PYGRVM
41505 C...Gives the GRV 94 M (MSbar) parton distribution function set
41506 C...in parametrized form.
41507 C...Authors: M. Glueck, E. Reya and A. Vogt.
41508 
41509  SUBROUTINE pygrvm (X, Q2, UV, DV, DEL, UDB, SB, CHM, BOT, GL)
41510 
41511 C...Double precision declaration.
41512  IMPLICIT DOUBLE PRECISION (a - z)
41513 
41514 C...Common expressions.
41515  mu2 = 0.34d0
41516  lam2 = 0.248d0 * 0.248d0
41517  s = log(log(q2/lam2) / log(mu2/lam2))
41518  ds = sqrt(s)
41519  s2 = s * s
41520  s3 = s2 * s
41521 
41522 C...uv :
41523  nu = 1.304d0 + 0.863d0 * s
41524  aku = 0.558d0 - 0.020d0 * s
41525  bku = 0.183d0 * s
41526  au = -0.113d0 + 0.283d0 * s - 0.321d0 * s2
41527  bu = 6.843d0 - 5.089d0 * s + 2.647d0 * s2 - 0.527d0 * s3
41528  cu = 7.771d0 - 10.09d0 * s + 2.630d0 * s2
41529  du = 3.315d0 + 1.145d0 * s - 0.583d0 * s2 + 0.154d0 * s3
41530  uv = pygrvv(x, nu, aku, bku, au, bu, cu, du)
41531 
41532 C...dv :
41533  nd = 0.102d0 - 0.017d0 * s + 0.005d0 * s2
41534  akd = 0.270d0 - 0.019d0 * s
41535  bkd = 0.260d0
41536  ad = 2.393d0 + 6.228d0 * s - 0.881d0 * s2
41537  bd = 46.06d0 + 4.673d0 * s - 14.98d0 * s2 + 1.331d0 * s3
41538  cd = 17.83d0 - 53.47d0 * s + 21.24d0 * s2
41539  dd = 4.081d0 + 0.976d0 * s - 0.485d0 * s2 + 0.152d0 * s3
41540  dv = pygrvv(x, nd, akd, bkd, ad, bd, cd, dd)
41541 
41542 C...del :
41543  ne = 0.070d0 + 0.042d0 * s - 0.011d0 * s2 + 0.004d0 * s3
41544  ake = 0.409d0 - 0.007d0 * s
41545  bke = 0.782d0 + 0.082d0 * s
41546  ae = -29.65d0 + 26.49d0 * s + 5.429d0 * s2
41547  be = 90.20d0 - 74.97d0 * s + 4.526d0 * s2
41548  ce = 0.0d0
41549  de = 8.122d0 + 2.120d0 * s - 1.088d0 * s2 + 0.231d0 * s3
41550  del = pygrvv(x, ne, ake, bke, ae, be, ce, de)
41551 
41552 C...udb :
41553  alx = 0.877d0
41554  bex = 0.561d0
41555  akx = 0.275d0
41556  bkx = 0.0d0
41557  agx = 0.997d0
41558  bgx = 3.210d0 - 1.866d0 * s
41559  cx = 7.300d0
41560  dx = 9.010d0 + 0.896d0 * ds + 0.222d0 * s2
41561  ex = 3.077d0 + 1.446d0 * s
41562  esx = 3.173d0 - 2.445d0 * ds + 2.207d0 * s
41563  udb = pygrvw(x, s, alx, bex, akx, bkx, agx, bgx, cx,
41564  & dx, ex, esx)
41565 
41566 C...sb :
41567  sts = 0d0
41568  als = 0.756d0
41569  bes = 0.216d0
41570  aks = 1.690d0 + 0.650d0 * ds - 0.922d0 * s
41571  as = -4.329d0 + 1.131d0 * s
41572  bs = 9.568d0 - 1.744d0 * s
41573  dst = 9.377d0 + 1.088d0 * ds - 1.320d0 * s + 0.130d0 * s2
41574  est = 3.031d0 + 1.639d0 * s
41575  ess = 5.837d0 + 0.815d0 * s
41576  sb = pygrvs(x, s, sts, als, bes, aks, as, bs, dst, est, ess)
41577 
41578 C...cb :
41579  stc = 0.820d0
41580  alc = 0.98d0
41581  bec = 0d0
41582  akc = -0.625d0 - 0.523d0 * s
41583  ac = 0d0
41584  bc = 1.896d0 + 1.616d0 * s
41585  dct = 4.12d0 + 0.683d0 * s
41586  ect = 4.36d0 + 1.328d0 * s
41587  esc = 0.677d0 + 0.679d0 * s
41588  chm = pygrvs(x, s, stc, alc, bec, akc, ac, bc, dct, ect, esc)
41589 
41590 C...bb :
41591  stb = 1.297d0
41592  alb = 0.99d0
41593  beb = 0d0
41594  akb = - 0.193d0 * s
41595  ab = 0d0
41596  bb = 0d0
41597  dbt = 3.447d0 + 0.927d0 * s
41598  ebt = 4.68d0 + 1.259d0 * s
41599  esb = 1.892d0 + 2.199d0 * s
41600  bot = pygrvs(x, s, stb, alb, beb, akb, ab, bb, dbt, ebt, esb)
41601 
41602 C...gl :
41603  alg = 1.014d0
41604  beg = 1.738d0
41605  akg = 1.724d0 + 0.157d0 * s
41606  bkg = 0.800d0 + 1.016d0 * s
41607  ag = 7.517d0 - 2.547d0 * s
41608  bg = 34.09d0 - 52.21d0 * ds + 17.47d0 * s
41609  cg = 4.039d0 + 1.491d0 * s
41610  dg = 3.404d0 + 0.830d0 * s
41611  eg = -1.112d0 + 3.438d0 * s - 0.302d0 * s2
41612  esg = 3.256d0 - 0.436d0 * s
41613  gl = pygrvw(x, s, alg, beg, akg, bkg, ag, bg, cg, dg, eg, esg)
41614 
41615  RETURN
41616  END
41617 
41618 C*********************************************************************
41619 
41620 C...PYGRVD
41621 C...Gives the GRV 94 D (DIS) parton distribution function set
41622 C...in parametrized form.
41623 C...Authors: M. Glueck, E. Reya and A. Vogt.
41624 
41625  SUBROUTINE pygrvd (X, Q2, UV, DV, DEL, UDB, SB, CHM, BOT, GL)
41626 
41627 C...Double precision declaration.
41628  IMPLICIT DOUBLE PRECISION (a - z)
41629 
41630 C...Common expressions.
41631  mu2 = 0.34d0
41632  lam2 = 0.248d0 * 0.248d0
41633  s = log(log(q2/lam2) / log(mu2/lam2))
41634  ds = sqrt(s)
41635  s2 = s * s
41636  s3 = s2 * s
41637 
41638 C...uv :
41639  nu = 2.484d0 + 0.116d0 * s + 0.093d0 * s2
41640  aku = 0.563d0 - 0.025d0 * s
41641  bku = 0.054d0 + 0.154d0 * s
41642  au = -0.326d0 - 0.058d0 * s - 0.135d0 * s2
41643  bu = -3.322d0 + 8.259d0 * s - 3.119d0 * s2 + 0.291d0 * s3
41644  cu = 11.52d0 - 12.99d0 * s + 3.161d0 * s2
41645  du = 2.808d0 + 1.400d0 * s - 0.557d0 * s2 + 0.119d0 * s3
41646  uv = pygrvv(x, nu, aku, bku, au, bu, cu, du)
41647 
41648 C...dv :
41649  nd = 0.156d0 - 0.017d0 * s
41650  akd = 0.299d0 - 0.022d0 * s
41651  bkd = 0.259d0 - 0.015d0 * s
41652  ad = 3.445d0 + 1.278d0 * s + 0.326d0 * s2
41653  bd = -6.934d0 + 37.45d0 * s - 18.95d0 * s2 + 1.463d0 * s3
41654  cd = 55.45d0 - 69.92d0 * s + 20.78d0 * s2
41655  dd = 3.577d0 + 1.441d0 * s - 0.683d0 * s2 + 0.179d0 * s3
41656  dv = pygrvv(x, nd, akd, bkd, ad, bd, cd, dd)
41657 
41658 C...del :
41659  ne = 0.099d0 + 0.019d0 * s + 0.002d0 * s2
41660  ake = 0.419d0 - 0.013d0 * s
41661  bke = 1.064d0 - 0.038d0 * s
41662  ae = -44.00d0 + 98.70d0 * s - 14.79d0 * s2
41663  be = 28.59d0 - 40.94d0 * s - 13.66d0 * s2 + 2.523d0 * s3
41664  ce = 84.57d0 - 108.8d0 * s + 31.52d0 * s2
41665  de = 7.469d0 + 2.480d0 * s - 0.866d0 * s2
41666  del = pygrvv(x, ne, ake, bke, ae, be, ce, de)
41667 
41668 C...udb :
41669  alx = 1.215d0
41670  bex = 0.466d0
41671  akx = 0.326d0 + 0.150d0 * s
41672  bkx = 0.956d0 + 0.405d0 * s
41673  agx = 0.272d0
41674  bgx = 3.794d0 - 2.359d0 * ds
41675  cx = 2.014d0
41676  dx = 7.941d0 + 0.534d0 * ds - 0.940d0 * s + 0.410d0 * s2
41677  ex = 3.049d0 + 1.597d0 * s
41678  esx = 4.396d0 - 4.594d0 * ds + 3.268d0 * s
41679  udb = pygrvw(x, s, alx, bex, akx, bkx, agx, bgx, cx,
41680  & dx, ex, esx)
41681 
41682 C...sb :
41683  sts = 0d0
41684  als = 0.175d0
41685  bes = 0.344d0
41686  aks = 1.415d0 - 0.641d0 * ds
41687  as = 0.580d0 - 9.763d0 * ds + 6.795d0 * s - 0.558d0 * s2
41688  bs = 5.617d0 + 5.709d0 * ds - 3.972d0 * s
41689  dst = 13.78d0 - 9.581d0 * s + 5.370d0 * s2 - 0.996d0 * s3
41690  est = 4.546d0 + 0.372d0 * s2
41691  ess = 5.053d0 - 1.070d0 * s + 0.805d0 * s2
41692  sb = pygrvs(x, s, sts, als, bes, aks, as, bs, dst, est, ess)
41693 
41694 C...cb :
41695  stc = 0.820d0
41696  alc = 0.98d0
41697  bec = 0d0
41698  akc = -0.625d0 - 0.523d0 * s
41699  ac = 0d0
41700  bc = 1.896d0 + 1.616d0 * s
41701  dct = 4.12d0 + 0.683d0 * s
41702  ect = 4.36d0 + 1.328d0 * s
41703  esc = 0.677d0 + 0.679d0 * s
41704  chm = pygrvs(x, s, stc, alc, bec, akc, ac, bc, dct, ect, esc)
41705 
41706 C...bb :
41707  stb = 1.297d0
41708  alb = 0.99d0
41709  beb = 0d0
41710  akb = - 0.193d0 * s
41711  ab = 0d0
41712  bb = 0d0
41713  dbt = 3.447d0 + 0.927d0 * s
41714  ebt = 4.68d0 + 1.259d0 * s
41715  esb = 1.892d0 + 2.199d0 * s
41716  bot = pygrvs(x, s, stb, alb, beb, akb, ab, bb, dbt, ebt, esb)
41717 
41718 C...gl :
41719  alg = 1.258d0
41720  beg = 1.846d0
41721  akg = 2.423d0
41722  bkg = 2.427d0 + 1.311d0 * s - 0.153d0 * s2
41723  ag = 25.09d0 - 7.935d0 * s
41724  bg = -14.84d0 - 124.3d0 * ds + 72.18d0 * s
41725  cg = 590.3d0 - 173.8d0 * s
41726  dg = 5.196d0 + 1.857d0 * s
41727  eg = -1.648d0 + 3.988d0 * s - 0.432d0 * s2
41728  esg = 3.232d0 - 0.542d0 * s
41729  gl = pygrvw(x, s, alg, beg, akg, bkg, ag, bg, cg, dg, eg, esg)
41730 
41731  RETURN
41732  END
41733 
41734 C*********************************************************************
41735 
41736 C...PYGRVV
41737 C...Auxiliary for the GRV 94 parton distribution functions
41738 C...for u and d valence and d-u sea.
41739 C...Authors: M. Glueck, E. Reya and A. Vogt.
41740 
41741  FUNCTION pygrvv (X, N, AK, BK, A, B, C, D)
41742 
41743 C...Double precision declaration.
41744  IMPLICIT DOUBLE PRECISION (a - z)
41745 
41746 C...Evaluation.
41747  dx = sqrt(x)
41748  pygrvv = n * x**ak * (1d0+ a*x**bk + x * (b + c*dx)) *
41749  & (1d0- x)**d
41750 
41751  RETURN
41752  END
41753 
41754 C*********************************************************************
41755 
41756 C...PYGRVW
41757 C...Auxiliary for the GRV 94 parton distribution functions
41758 C...for d+u sea and gluon.
41759 C...Authors: M. Glueck, E. Reya and A. Vogt.
41760 
41761  FUNCTION pygrvw (X, S, AL, BE, AK, BK, A, B, C, D, E, ES)
41762 
41763 C...Double precision declaration.
41764  IMPLICIT DOUBLE PRECISION (a - z)
41765 
41766 C...Evaluation.
41767  lx = log(1d0/x)
41768  pygrvw = (x**ak * (a + x * (b + x*c)) * lx**bk + s**al
41769  & * exp(-e + sqrt(es * s**be * lx))) * (1d0- x)**d
41770 
41771  RETURN
41772  END
41773 
41774 C*********************************************************************
41775 
41776 C...PYGRVS
41777 C...Auxiliary for the GRV 94 parton distribution functions
41778 C...for s, c and b sea.
41779 C...Authors: M. Glueck, E. Reya and A. Vogt.
41780 
41781  FUNCTION pygrvs (X, S, STH, AL, BE, AK, AG, B, D, E, ES)
41782 
41783 C...Double precision declaration.
41784  IMPLICIT DOUBLE PRECISION (a - z)
41785 
41786 C...Evaluation.
41787  IF(s.LE.sth) THEN
41788  pygrvs = 0d0
41789  ELSE
41790  dx = sqrt(x)
41791  lx = log(1d0/x)
41792  pygrvs = (s - sth)**al / lx**ak * (1d0+ ag*dx + b*x) *
41793  & (1d0- x)**d * exp(-e + sqrt(es * s**be * lx))
41794  ENDIF
41795 
41796  RETURN
41797  END
41798 
41799 C*********************************************************************
41800 
41801 C...PYCT5L
41802 C...Auxiliary function for parametrization of CTEQ5L.
41803 C...Author: J. Pumplin 9/99.
41804 
41805 C...CTEQ5M1 and CTEQ5L Parton Distribution Functions
41806 C...in Parametrized Form
41807 C... September 15, 1999
41808 C
41809 C...Ref: "GLOBAL QCD ANALYSIS OF PARTON STRUCTURE OF THE NUCLEON:
41810 C... CTEQ5 PPARTON DISTRIBUTIONS"
41811 C...hep-ph/9903282
41812 
41813 C...The CTEQ5M1 set given here is an updated version of the original
41814 C...CTEQ5M set posted, in the table version, on the Web page of CTEQ.
41815 C...The differences between CTEQ5M and CTEQ5M1 are insignificant for
41816 C...almost all applications.
41817 C...The improvement is in the QCD evolution which is now more
41818 C...accurate, and which agrees completely with the benchmark work
41819 C...of the HERA 96/97 Workshop.
41820 C...The differences between the parametrized and the corresponding
41821 C...table versions (on which it is based) are of similar order as
41822 C...between the two version.
41823 
41824 C...!! Because accurate parametrizations over a wide range of (x,Q)
41825 C...is hard to obtain, only the most widely used sets CTEQ5M and
41826 C...CTEQ5L are available in parametrized form for now.
41827 
41828 C...These parametrizations were obtained by Jon Pumplin.
41829 
41830 C Iset PDF Description Alpha_s(Mz) Lam4 Lam5
41831 C -------------------------------------------------------------------
41832 C 1 CTEQ5M1 Standard NLO MSbar scheme 0.118 326 226
41833 C 3 CTEQ5L Leading Order 0.127 192 146
41834 C -------------------------------------------------------------------
41835 C...Note the Qcd-lambda values given for CTEQ5L is for the leading
41836 C...order form of Alpha_s!! Alpha_s(Mz) gives the absolute
41837 C...calibration.
41838 
41839 C...The two Iset value are adopted to agree with the standard table
41840 C...versions.
41841 
41842 C...Range of validity:
41843 C...The range of (x, Q) covered by this parametrization of the QCD
41844 C...evolved parton distributions is 1E-6 < x < 1 ;
41845 C...1.1 GeV < Q < 10 TeV. Of course, the PDFs are constrained by
41846 C...data only in a subset of that region; and the assumed DGLAP
41847 C...evolution is unlikely to be valid for all of it either.
41848 
41849 C...The range of (x, Q) used in the CTEQ5 round of global analysis is
41850 C...approximately 0.01 < x < 0.75 ; and 4 GeV^2 < Q^2 < 400 GeV^2 for
41851 C...fixed target experiments; 0.0001 < x < 0.3 from HERA data; and
41852 C...Q^2 up to 40,000 GeV^2 from Tevatron inclusive Jet data.
41853 
41854  FUNCTION pyct5l(IFL,X,Q)
41855 
41856 C...Double precision declaration.
41857  IMPLICIT DOUBLE PRECISION(a-h, o-z)
41858  IMPLICIT INTEGER(i-n)
41859 
41860  parameter(nex=8, nlf=2)
41861  dimension am(0:nex,0:nlf,-5:2)
41862  dimension alfvec(-5:2), qmavec(-5:2)
41863  dimension mexvec(-5:2), mlfvec(-5:2)
41864  dimension ut1vec(-5:2), ut2vec(-5:2)
41865  dimension af(0:nex)
41866 
41867  DATA mexvec( 2) / 8 /
41868  DATA mlfvec( 2) / 2 /
41869  DATA ut1vec( 2) / 0.4971265e+01 /
41870  DATA ut2vec( 2) / -0.1105128e+01 /
41871  DATA alfvec( 2) / 0.2987216e+00 /
41872  DATA qmavec( 2) / 0.0000000e+00 /
41873  DATA (am( 0,k, 2),k=0, 2)
41874  & / 0.5292616e+01, -0.2751910e+01, -0.2488990e+01 /
41875  DATA (am( 1,k, 2),k=0, 2)
41876  & / 0.9714424e+00, 0.1011827e-01, -0.1023660e-01 /
41877  DATA (am( 2,k, 2),k=0, 2)
41878  & / -0.1651006e+02, 0.7959721e+01, 0.8810563e+01 /
41879  DATA (am( 3,k, 2),k=0, 2)
41880  & / -0.1643394e+02, 0.5892854e+01, 0.9348874e+01 /
41881  DATA (am( 4,k, 2),k=0, 2)
41882  & / 0.3067422e+02, 0.4235796e+01, -0.5112136e+00 /
41883  DATA (am( 5,k, 2),k=0, 2)
41884  & / 0.2352526e+02, -0.5305168e+01, -0.1169174e+02 /
41885  DATA (am( 6,k, 2),k=0, 2)
41886  & / -0.1095451e+02, 0.3006577e+01, 0.5638136e+01 /
41887  DATA (am( 7,k, 2),k=0, 2)
41888  & / -0.1172251e+02, -0.2183624e+01, 0.4955794e+01 /
41889  DATA (am( 8,k, 2),k=0, 2)
41890  & / 0.1662533e-01, 0.7622870e-02, -0.4895887e-03 /
41891 
41892  DATA mexvec( 1) / 8 /
41893  DATA mlfvec( 1) / 2 /
41894  DATA ut1vec( 1) / 0.2612618e+01 /
41895  DATA ut2vec( 1) / -0.1258304e+06 /
41896  DATA alfvec( 1) / 0.3407552e+00 /
41897  DATA qmavec( 1) / 0.0000000e+00 /
41898  DATA (am( 0,k, 1),k=0, 2)
41899  & / 0.9905300e+00, -0.4502235e+00, 0.1624441e+00 /
41900  DATA (am( 1,k, 1),k=0, 2)
41901  & / 0.8867534e+00, 0.1630829e-01, -0.4049085e-01 /
41902  DATA (am( 2,k, 1),k=0, 2)
41903  & / 0.8547974e+00, 0.3336301e+00, 0.1371388e+00 /
41904  DATA (am( 3,k, 1),k=0, 2)
41905  & / 0.2941113e+00, -0.1527905e+01, 0.2331879e+00 /
41906  DATA (am( 4,k, 1),k=0, 2)
41907  & / 0.3384235e+02, 0.3715315e+01, 0.8276930e+00 /
41908  DATA (am( 5,k, 1),k=0, 2)
41909  & / 0.6230115e+01, 0.3134639e+01, -0.1729099e+01 /
41910  DATA (am( 6,k, 1),k=0, 2)
41911  & / -0.1186928e+01, -0.3282460e+00, 0.1052020e+00 /
41912  DATA (am( 7,k, 1),k=0, 2)
41913  & / -0.8545702e+01, -0.6247947e+01, 0.3692561e+01 /
41914  DATA (am( 8,k, 1),k=0, 2)
41915  & / 0.1724598e-01, 0.7120465e-02, 0.4003646e-04 /
41916 
41917  DATA mexvec( 0) / 8 /
41918  DATA mlfvec( 0) / 2 /
41919  DATA ut1vec( 0) / -0.4656819e+00 /
41920  DATA ut2vec( 0) / -0.2742390e+03 /
41921  DATA alfvec( 0) / 0.4491863e+00 /
41922  DATA qmavec( 0) / 0.0000000e+00 /
41923  DATA (am( 0,k, 0),k=0, 2)
41924  & / 0.1193572e+03, -0.3886845e+01, -0.1133965e+01 /
41925  DATA (am( 1,k, 0),k=0, 2)
41926  & / -0.9421449e+02, 0.3995885e+01, 0.1607363e+01 /
41927  DATA (am( 2,k, 0),k=0, 2)
41928  & / 0.4206383e+01, 0.2485954e+00, 0.2497468e+00 /
41929  DATA (am( 3,k, 0),k=0, 2)
41930  & / 0.1210557e+03, -0.3015765e+01, -0.1423651e+01 /
41931  DATA (am( 4,k, 0),k=0, 2)
41932  & / -0.1013897e+03, -0.7113478e+00, 0.2621865e+00 /
41933  DATA (am( 5,k, 0),k=0, 2)
41934  & / -0.1312404e+01, -0.9297691e+00, -0.1562531e+00 /
41935  DATA (am( 6,k, 0),k=0, 2)
41936  & / 0.1627137e+01, 0.4954111e+00, -0.6387009e+00 /
41937  DATA (am( 7,k, 0),k=0, 2)
41938  & / 0.1537698e+00, -0.2487878e+00, 0.8305947e+00 /
41939  DATA (am( 8,k, 0),k=0, 2)
41940  & / 0.2496448e-01, 0.2457823e-02, 0.8234276e-03 /
41941 
41942  DATA mexvec(-1) / 8 /
41943  DATA mlfvec(-1) / 2 /
41944  DATA ut1vec(-1) / 0.3862583e+01 /
41945  DATA ut2vec(-1) / -0.1265969e+01 /
41946  DATA alfvec(-1) / 0.2457668e+00 /
41947  DATA qmavec(-1) / 0.0000000e+00 /
41948  DATA (am( 0,k,-1),k=0, 2)
41949  & / 0.2647441e+02, 0.1059277e+02, -0.9176654e+00 /
41950  DATA (am( 1,k,-1),k=0, 2)
41951  & / 0.1990636e+01, 0.8558918e-01, 0.4248667e-01 /
41952  DATA (am( 2,k,-1),k=0, 2)
41953  & / -0.1476095e+02, -0.3276255e+02, 0.1558110e+01 /
41954  DATA (am( 3,k,-1),k=0, 2)
41955  & / -0.2966889e+01, -0.3649037e+02, 0.1195914e+01 /
41956  DATA (am( 4,k,-1),k=0, 2)
41957  & / -0.1000519e+03, -0.2464635e+01, 0.1964849e+00 /
41958  DATA (am( 5,k,-1),k=0, 2)
41959  & / 0.3718331e+02, 0.4700389e+02, -0.2772142e+01 /
41960  DATA (am( 6,k,-1),k=0, 2)
41961  & / -0.1872722e+02, -0.2291189e+02, 0.1089052e+01 /
41962  DATA (am( 7,k,-1),k=0, 2)
41963  & / -0.1628146e+02, -0.1823993e+02, 0.2537369e+01 /
41964  DATA (am( 8,k,-1),k=0, 2)
41965  & / -0.1156300e+01, -0.1280495e+00, 0.5153245e-01 /
41966 
41967  DATA mexvec(-2) / 7 /
41968  DATA mlfvec(-2) / 2 /
41969  DATA ut1vec(-2) / 0.1895615e+00 /
41970  DATA ut2vec(-2) / -0.3069097e+01 /
41971  DATA alfvec(-2) / 0.5293999e+00 /
41972  DATA qmavec(-2) / 0.0000000e+00 /
41973  DATA (am( 0,k,-2),k=0, 2)
41974  & / -0.6556775e+00, 0.2490190e+00, 0.3966485e-01 /
41975  DATA (am( 1,k,-2),k=0, 2)
41976  & / 0.1305102e+01, -0.1188925e+00, -0.4600870e-02 /
41977  DATA (am( 2,k,-2),k=0, 2)
41978  & / -0.2371436e+01, 0.3566814e+00, -0.2834683e+00 /
41979  DATA (am( 3,k,-2),k=0, 2)
41980  & / -0.6152826e+01, 0.8339877e+00, -0.7233230e+00 /
41981  DATA (am( 4,k,-2),k=0, 2)
41982  & / -0.8346558e+01, 0.2892168e+01, 0.2137099e+00 /
41983  DATA (am( 5,k,-2),k=0, 2)
41984  & / 0.1279530e+02, 0.1021114e+00, 0.5787439e+00 /
41985  DATA (am( 6,k,-2),k=0, 2)
41986  & / 0.5858816e+00, -0.1940375e+01, -0.4029269e+00 /
41987  DATA (am( 7,k,-2),k=0, 2)
41988  & / -0.2795725e+02, -0.5263392e+00, 0.1290229e+01 /
41989 
41990  DATA mexvec(-3) / 7 /
41991  DATA mlfvec(-3) / 2 /
41992  DATA ut1vec(-3) / 0.3753257e+01 /
41993  DATA ut2vec(-3) / -0.1113085e+01 /
41994  DATA alfvec(-3) / 0.3713141e+00 /
41995  DATA qmavec(-3) / 0.0000000e+00 /
41996  DATA (am( 0,k,-3),k=0, 2)
41997  & / 0.1580931e+01, -0.2273826e+01, -0.1822245e+01 /
41998  DATA (am( 1,k,-3),k=0, 2)
41999  & / 0.2702644e+01, 0.6763243e+00, 0.7231586e-02 /
42000  DATA (am( 2,k,-3),k=0, 2)
42001  & / -0.1857924e+02, 0.3907500e+01, 0.5850109e+01 /
42002  DATA (am( 3,k,-3),k=0, 2)
42003  & / -0.3044793e+02, 0.2639332e+01, 0.5566644e+01 /
42004  DATA (am( 4,k,-3),k=0, 2)
42005  & / -0.4258011e+01, -0.5429244e+01, 0.4418946e+00 /
42006  DATA (am( 5,k,-3),k=0, 2)
42007  & / 0.3465259e+02, -0.5532604e+01, -0.4904153e+01 /
42008  DATA (am( 6,k,-3),k=0, 2)
42009  & / -0.1658858e+02, 0.2923275e+01, 0.2266286e+01 /
42010  DATA (am( 7,k,-3),k=0, 2)
42011  & / -0.1149263e+02, 0.2877475e+01, -0.7999105e+00 /
42012 
42013  DATA mexvec(-4) / 7 /
42014  DATA mlfvec(-4) / 2 /
42015  DATA ut1vec(-4) / 0.4400772e+01 /
42016  DATA ut2vec(-4) / -0.1356116e+01 /
42017  DATA alfvec(-4) / 0.3712017e-01 /
42018  DATA qmavec(-4) / 0.1300000e+01 /
42019  DATA (am( 0,k,-4),k=0, 2)
42020  & / -0.8293661e+00, -0.3982375e+01, -0.6494283e-01 /
42021  DATA (am( 1,k,-4),k=0, 2)
42022  & / 0.2754618e+01, 0.8338636e+00, -0.6885160e-01 /
42023  DATA (am( 2,k,-4),k=0, 2)
42024  & / -0.1657987e+02, 0.1439143e+02, -0.6887240e+00 /
42025  DATA (am( 3,k,-4),k=0, 2)
42026  & / -0.2800703e+02, 0.1535966e+02, -0.7377693e+00 /
42027  DATA (am( 4,k,-4),k=0, 2)
42028  & / -0.6460216e+01, -0.4783019e+01, 0.4913297e+00 /
42029  DATA (am( 5,k,-4),k=0, 2)
42030  & / 0.3141830e+02, -0.3178031e+02, 0.7136013e+01 /
42031  DATA (am( 6,k,-4),k=0, 2)
42032  & / -0.1802509e+02, 0.1862163e+02, -0.4632843e+01 /
42033  DATA (am( 7,k,-4),k=0, 2)
42034  & / -0.1240412e+02, 0.2565386e+02, -0.1066570e+02 /
42035 
42036  DATA mexvec(-5) / 6 /
42037  DATA mlfvec(-5) / 2 /
42038  DATA ut1vec(-5) / 0.5562568e+01 /
42039  DATA ut2vec(-5) / -0.1801317e+01 /
42040  DATA alfvec(-5) / 0.4952010e-02 /
42041  DATA qmavec(-5) / 0.4500000e+01 /
42042  DATA (am( 0,k,-5),k=0, 2)
42043  & / -0.6031237e+01, 0.1992727e+01, -0.1076331e+01 /
42044  DATA (am( 1,k,-5),k=0, 2)
42045  & / 0.2933912e+01, 0.5839674e+00, 0.7509435e-01 /
42046  DATA (am( 2,k,-5),k=0, 2)
42047  & / -0.8284919e+01, 0.1488593e+01, -0.8251678e+00 /
42048  DATA (am( 3,k,-5),k=0, 2)
42049  & / -0.1925986e+02, 0.2805753e+01, -0.3015446e+01 /
42050  DATA (am( 4,k,-5),k=0, 2)
42051  & / -0.9480483e+01, -0.9767837e+00, -0.1165544e+01 /
42052  DATA (am( 5,k,-5),k=0, 2)
42053  & / 0.2193195e+02, -0.1788518e+02, 0.9460908e+01 /
42054  DATA (am( 6,k,-5),k=0, 2)
42055  & / -0.1327377e+02, 0.1201754e+02, -0.6277844e+01 /
42056 
42057  IF(q .LE. qmavec(ifl)) THEN
42058  pyct5l = 0.d0
42059  RETURN
42060  ENDIF
42061 
42062  IF(x .GE. 1.d0) THEN
42063  pyct5l = 0.d0
42064  RETURN
42065  ENDIF
42066 
42067  tmp = log(q/alfvec(ifl))
42068  IF(tmp .LE. 0.d0) THEN
42069  pyct5l = 0.d0
42070  RETURN
42071  ENDIF
42072 
42073  sb = log(tmp)
42074  sb1 = sb - 1.2d0
42075  sb2 = sb1*sb1
42076 
42077  DO 110 i = 0, nex
42078  af(i) = 0.d0
42079  sbx = 1.d0
42080  DO 100 k = 0, mlfvec(ifl)
42081  af(i) = af(i) + sbx*am(i,k,ifl)
42082  sbx = sb1*sbx
42083  100 CONTINUE
42084  110 CONTINUE
42085 
42086  y = -log(x)
42087  u = log(x/0.00001d0)
42088 
42089  part1 = af(1)*y**(1.d0+0.01d0*af(4))*(1.d0+ af(8)*u)
42090  part2 = af(0)*(1.d0 - x) + af(3)*x
42091  part3 = x*(1.d0-x)*(af(5)+af(6)*(1.d0-x)+af(7)*x*(1.d0-x))
42092  part4 = ut1vec(ifl)*log(1.d0-x) +
42093  & af(2)*log(1.d0+exp(ut2vec(ifl))-x)
42094 
42095  pyct5l = exp(log(x) + part1 + part2 + part3 + part4)
42096 
42097 C...Include threshold factor.
42098  pyct5l = pyct5l * (1.d0 - qmavec(ifl)/q)
42099 
42100  RETURN
42101  END
42102 
42103 C*********************************************************************
42104 
42105 C...PYCT5M
42106 C...Auxiliary function for parametrization of CTEQ5M1.
42107 C...Author: J. Pumplin 9/99.
42108 
42109  FUNCTION pyct5m(IFL,X,Q)
42110 
42111 C...Double precision declaration.
42112  IMPLICIT DOUBLE PRECISION(a-h, o-z)
42113  IMPLICIT INTEGER(i-n)
42114 
42115  parameter(nex=8, nlf=2)
42116  dimension am(0:nex,0:nlf,-5:2)
42117  dimension alfvec(-5:2), qmavec(-5:2)
42118  dimension mexvec(-5:2), mlfvec(-5:2)
42119  dimension ut1vec(-5:2), ut2vec(-5:2)
42120  dimension af(0:nex)
42121 
42122  DATA mexvec( 2) / 8 /
42123  DATA mlfvec( 2) / 2 /
42124  DATA ut1vec( 2) / 0.5141718e+01 /
42125  DATA ut2vec( 2) / -0.1346944e+01 /
42126  DATA alfvec( 2) / 0.5260555e+00 /
42127  DATA qmavec( 2) / 0.0000000e+00 /
42128  DATA (am( 0,k, 2),k=0, 2)
42129  & / 0.4289071e+01, -0.2536870e+01, -0.1259948e+01 /
42130  DATA (am( 1,k, 2),k=0, 2)
42131  & / 0.9839410e+00, 0.4168426e-01, -0.5018952e-01 /
42132  DATA (am( 2,k, 2),k=0, 2)
42133  & / -0.1651961e+02, 0.9246261e+01, 0.5996400e+01 /
42134  DATA (am( 3,k, 2),k=0, 2)
42135  & / -0.2077936e+02, 0.9786469e+01, 0.7656465e+01 /
42136  DATA (am( 4,k, 2),k=0, 2)
42137  & / 0.3054926e+02, 0.1889536e+01, 0.1380541e+01 /
42138  DATA (am( 5,k, 2),k=0, 2)
42139  & / 0.3084695e+02, -0.1212303e+02, -0.1053551e+02 /
42140  DATA (am( 6,k, 2),k=0, 2)
42141  & / -0.1426778e+02, 0.6239537e+01, 0.5254819e+01 /
42142  DATA (am( 7,k, 2),k=0, 2)
42143  & / -0.1909811e+02, 0.3695678e+01, 0.5495729e+01 /
42144  DATA (am( 8,k, 2),k=0, 2)
42145  & / 0.1889751e-01, 0.5027193e-02, 0.6624896e-03 /
42146 
42147  DATA mexvec( 1) / 8 /
42148  DATA mlfvec( 1) / 2 /
42149  DATA ut1vec( 1) / 0.4138426e+01 /
42150  DATA ut2vec( 1) / -0.3221374e+01 /
42151  DATA alfvec( 1) / 0.4960962e+00 /
42152  DATA qmavec( 1) / 0.0000000e+00 /
42153  DATA (am( 0,k, 1),k=0, 2)
42154  & / 0.1332497e+01, -0.3703718e+00, 0.1288638e+00 /
42155  DATA (am( 1,k, 1),k=0, 2)
42156  & / 0.7544687e+00, 0.3255075e-01, -0.4706680e-01 /
42157  DATA (am( 2,k, 1),k=0, 2)
42158  & / -0.7638814e+00, 0.5008313e+00, -0.9237374e-01 /
42159  DATA (am( 3,k, 1),k=0, 2)
42160  & / -0.3689889e+00, -0.1055098e+01, -0.4645065e+00 /
42161  DATA (am( 4,k, 1),k=0, 2)
42162  & / 0.3991610e+02, 0.1979881e+01, 0.1775814e+01 /
42163  DATA (am( 5,k, 1),k=0, 2)
42164  & / 0.6201080e+01, 0.2046288e+01, 0.3804571e+00 /
42165  DATA (am( 6,k, 1),k=0, 2)
42166  & / -0.8027900e+00, -0.7011688e+00, -0.8049612e+00 /
42167  DATA (am( 7,k, 1),k=0, 2)
42168  & / -0.8631305e+01, -0.3981200e+01, 0.6970153e+00 /
42169  DATA (am( 8,k, 1),k=0, 2)
42170  & / 0.2371230e-01, 0.5372683e-02, 0.1118701e-02 /
42171 
42172  DATA mexvec( 0) / 8 /
42173  DATA mlfvec( 0) / 2 /
42174  DATA ut1vec( 0) / -0.1026789e+01 /
42175  DATA ut2vec( 0) / -0.9051707e+01 /
42176  DATA alfvec( 0) / 0.9462977e+00 /
42177  DATA qmavec( 0) / 0.0000000e+00 /
42178  DATA (am( 0,k, 0),k=0, 2)
42179  & / 0.1191990e+03, -0.8548739e+00, -0.1963040e+01 /
42180  DATA (am( 1,k, 0),k=0, 2)
42181  & / -0.9449972e+02, 0.1074771e+01, 0.2056055e+01 /
42182  DATA (am( 2,k, 0),k=0, 2)
42183  & / 0.3701064e+01, -0.1167947e-02, 0.1933573e+00 /
42184  DATA (am( 3,k, 0),k=0, 2)
42185  & / 0.1171345e+03, -0.1064540e+01, -0.1875312e+01 /
42186  DATA (am( 4,k, 0),k=0, 2)
42187  & / -0.1014453e+03, -0.5707427e+00, 0.4511242e-01 /
42188  DATA (am( 5,k, 0),k=0, 2)
42189  & / 0.6365168e+01, 0.1275354e+01, -0.4964081e+00 /
42190  DATA (am( 6,k, 0),k=0, 2)
42191  & / -0.3370693e+01, -0.1122020e+01, 0.5947751e-01 /
42192  DATA (am( 7,k, 0),k=0, 2)
42193  & / -0.5327270e+01, -0.9293556e+00, 0.6629940e+00 /
42194  DATA (am( 8,k, 0),k=0, 2)
42195  & / 0.2437513e-01, 0.1600939e-02, 0.6855336e-03 /
42196 
42197  DATA mexvec(-1) / 8 /
42198  DATA mlfvec(-1) / 2 /
42199  DATA ut1vec(-1) / 0.5243571e+01 /
42200  DATA ut2vec(-1) / -0.2870513e+01 /
42201  DATA alfvec(-1) / 0.6701448e+00 /
42202  DATA qmavec(-1) / 0.0000000e+00 /
42203  DATA (am( 0,k,-1),k=0, 2)
42204  & / 0.2428863e+02, 0.1907035e+01, -0.4606457e+00 /
42205  DATA (am( 1,k,-1),k=0, 2)
42206  & / 0.2006810e+01, -0.1265915e+00, 0.7153556e-02 /
42207  DATA (am( 2,k,-1),k=0, 2)
42208  & / -0.1884546e+02, -0.2339471e+01, 0.5740679e+01 /
42209  DATA (am( 3,k,-1),k=0, 2)
42210  & / -0.2527892e+02, -0.2044124e+01, 0.1280470e+02 /
42211  DATA (am( 4,k,-1),k=0, 2)
42212  & / -0.1013824e+03, -0.1594199e+01, 0.2216401e+00 /
42213  DATA (am( 5,k,-1),k=0, 2)
42214  & / 0.8070930e+02, 0.1792072e+01, -0.2164364e+02 /
42215  DATA (am( 6,k,-1),k=0, 2)
42216  & / -0.4641050e+02, 0.1977338e+00, 0.1273014e+02 /
42217  DATA (am( 7,k,-1),k=0, 2)
42218  & / -0.3910568e+02, 0.1719632e+01, 0.1086525e+02 /
42219  DATA (am( 8,k,-1),k=0, 2)
42220  & / -0.1185496e+01, -0.1905847e+00, -0.8744118e-03 /
42221 
42222  DATA mexvec(-2) / 7 /
42223  DATA mlfvec(-2) / 2 /
42224  DATA ut1vec(-2) / 0.4782210e+01 /
42225  DATA ut2vec(-2) / -0.1976856e+02 /
42226  DATA alfvec(-2) / 0.7558374e+00 /
42227  DATA qmavec(-2) / 0.0000000e+00 /
42228  DATA (am( 0,k,-2),k=0, 2)
42229  & / -0.6216935e+00, 0.2369963e+00, -0.7909949e-02 /
42230  DATA (am( 1,k,-2),k=0, 2)
42231  & / 0.1245440e+01, -0.1031510e+00, 0.4916523e-02 /
42232  DATA (am( 2,k,-2),k=0, 2)
42233  & / -0.7060824e+01, -0.3875283e-01, 0.1784981e+00 /
42234  DATA (am( 3,k,-2),k=0, 2)
42235  & / -0.7430595e+01, 0.1964572e+00, -0.1284999e+00 /
42236  DATA (am( 4,k,-2),k=0, 2)
42237  & / -0.6897810e+01, 0.2620543e+01, 0.8012553e-02 /
42238  DATA (am( 5,k,-2),k=0, 2)
42239  & / 0.1507713e+02, 0.2340307e-01, 0.2482535e+01 /
42240  DATA (am( 6,k,-2),k=0, 2)
42241  & / -0.1815341e+01, -0.1538698e+01, -0.2014208e+01 /
42242  DATA (am( 7,k,-2),k=0, 2)
42243  & / -0.2571932e+02, 0.2903941e+00, -0.2848206e+01 /
42244 
42245  DATA mexvec(-3) / 7 /
42246  DATA mlfvec(-3) / 2 /
42247  DATA ut1vec(-3) / 0.4518239e+01 /
42248  DATA ut2vec(-3) / -0.2690590e+01 /
42249  DATA alfvec(-3) / 0.6124079e+00 /
42250  DATA qmavec(-3) / 0.0000000e+00 /
42251  DATA (am( 0,k,-3),k=0, 2)
42252  & / -0.2734458e+01, -0.7245673e+00, -0.6351374e+00 /
42253  DATA (am( 1,k,-3),k=0, 2)
42254  & / 0.2927174e+01, 0.4822709e+00, -0.1088787e-01 /
42255  DATA (am( 2,k,-3),k=0, 2)
42256  & / -0.1771017e+02, -0.1416635e+01, 0.8467622e+01 /
42257  DATA (am( 3,k,-3),k=0, 2)
42258  & / -0.4972782e+02, -0.3348547e+01, 0.1767061e+02 /
42259  DATA (am( 4,k,-3),k=0, 2)
42260  & / -0.7102770e+01, -0.3205337e+01, 0.4101704e+00 /
42261  DATA (am( 5,k,-3),k=0, 2)
42262  & / 0.7169698e+02, -0.2205985e+01, -0.2463931e+02 /
42263  DATA (am( 6,k,-3),k=0, 2)
42264  & / -0.4090347e+02, 0.2103486e+01, 0.1416507e+02 /
42265  DATA (am( 7,k,-3),k=0, 2)
42266  & / -0.2952639e+02, 0.5376136e+01, 0.7825585e+01 /
42267 
42268  DATA mexvec(-4) / 7 /
42269  DATA mlfvec(-4) / 2 /
42270  DATA ut1vec(-4) / 0.2783230e+01 /
42271  DATA ut2vec(-4) / -0.1746328e+01 /
42272  DATA alfvec(-4) / 0.1115653e+01 /
42273  DATA qmavec(-4) / 0.1300000e+01 /
42274  DATA (am( 0,k,-4),k=0, 2)
42275  & / -0.1743872e+01, -0.1128921e+01, -0.2841969e+00 /
42276  DATA (am( 1,k,-4),k=0, 2)
42277  & / 0.3345755e+01, 0.3187765e+00, 0.1378124e+00 /
42278  DATA (am( 2,k,-4),k=0, 2)
42279  & / -0.2037615e+02, 0.4121687e+01, 0.2236520e+00 /
42280  DATA (am( 3,k,-4),k=0, 2)
42281  & / -0.4703104e+02, 0.5353087e+01, -0.1455347e+01 /
42282  DATA (am( 4,k,-4),k=0, 2)
42283  & / -0.1060230e+02, -0.1551122e+01, -0.1078863e+01 /
42284  DATA (am( 5,k,-4),k=0, 2)
42285  & / 0.5088892e+02, -0.8197304e+01, 0.8083451e+01 /
42286  DATA (am( 6,k,-4),k=0, 2)
42287  & / -0.2819070e+02, 0.4554086e+01, -0.5890995e+01 /
42288  DATA (am( 7,k,-4),k=0, 2)
42289  & / -0.1098238e+02, 0.2590096e+01, -0.8062879e+01 /
42290 
42291  DATA mexvec(-5) / 6 /
42292  DATA mlfvec(-5) / 2 /
42293  DATA ut1vec(-5) / 0.1619654e+02 /
42294  DATA ut2vec(-5) / -0.3367346e+01 /
42295  DATA alfvec(-5) / 0.5109891e-02 /
42296  DATA qmavec(-5) / 0.4500000e+01 /
42297  DATA (am( 0,k,-5),k=0, 2)
42298  & / -0.6800138e+01, 0.2493627e+01, -0.1075724e+01 /
42299  DATA (am( 1,k,-5),k=0, 2)
42300  & / 0.3036555e+01, 0.3324733e+00, 0.2008298e+00 /
42301  DATA (am( 2,k,-5),k=0, 2)
42302  & / -0.5203879e+01, -0.8493476e+01, -0.4523208e+01 /
42303  DATA (am( 3,k,-5),k=0, 2)
42304  & / -0.1524239e+01, -0.3411912e+01, -0.1771867e+02 /
42305  DATA (am( 4,k,-5),k=0, 2)
42306  & / -0.1099444e+02, 0.1320930e+01, -0.2353831e+01 /
42307  DATA (am( 5,k,-5),k=0, 2)
42308  & / 0.1699299e+02, -0.3565802e+02, 0.3566872e+02 /
42309  DATA (am( 6,k,-5),k=0, 2)
42310  & / -0.1465793e+02, 0.2703365e+02, -0.2176372e+02 /
42311 
42312  IF(q .LE. qmavec(ifl)) THEN
42313  pyct5m = 0.d0
42314  RETURN
42315  ENDIF
42316 
42317  IF(x .GE. 1.d0) THEN
42318  pyct5m = 0.d0
42319  RETURN
42320  ENDIF
42321 
42322  tmp = log(q/alfvec(ifl))
42323  IF(tmp .LE. 0.d0) THEN
42324  pyct5m = 0.d0
42325  RETURN
42326  ENDIF
42327 
42328  sb = log(tmp)
42329  sb1 = sb - 1.2d0
42330  sb2 = sb1*sb1
42331 
42332  DO 110 i = 0, nex
42333  af(i) = 0.d0
42334  sbx = 1.d0
42335  DO 100 k = 0, mlfvec(ifl)
42336  af(i) = af(i) + sbx*am(i,k,ifl)
42337  sbx = sb1*sbx
42338  100 CONTINUE
42339  110 CONTINUE
42340 
42341  y = -log(x)
42342  u = log(x/0.00001d0)
42343 
42344  part1 = af(1)*y**(1.d0+0.01d0*af(4))*(1.d0+ af(8)*u)
42345  part2 = af(0)*(1.d0 - x) + af(3)*x
42346  part3 = x*(1.d0-x)*(af(5)+af(6)*(1.d0-x)+af(7)*x*(1.d0-x))
42347  part4 = ut1vec(ifl)*log(1.d0-x) +
42348  & af(2)*log(1.d0+exp(ut2vec(ifl))-x)
42349 
42350  pyct5m = exp(log(x) + part1 + part2 + part3 + part4)
42351 
42352 C...Include threshold factor.
42353  pyct5m = pyct5m * (1.d0 - qmavec(ifl)/q)
42354 
42355  RETURN
42356  END
42357 
42358 C*********************************************************************
42359 
42360 C...PYPDPO
42361 C...Auxiliary to PYPDPR. Gives proton parton distributions according to
42362 C...a few older parametrizations, now obsolete but convenient for
42363 C...backwards checks.
42364 
42365  SUBROUTINE pypdpo(X,Q2,XPPR)
42366 
42367 C...Double precision and integer declarations.
42368  IMPLICIT DOUBLE PRECISION(a-h, o-z)
42369  IMPLICIT INTEGER(i-n)
42370  INTEGER pyk,pychge,pycomp
42371 C...Commonblocks.
42372  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
42373  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
42374  common/pypars/mstp(200),parp(200),msti(200),pari(200)
42375  common/pyint1/mint(400),vint(400)
42376  SAVE /pydat1/,/pydat2/,/pypars/,/pyint1/
42377  dimension xppr(-6:6),xq(9),tx(6),tt(6),ts(6),nehlq(8,2),
42378  &cehlq(6,6,2,8,2),cdo(3,6,5,2)
42379 
42380 
42381 C...The following data lines are coefficients needed in the
42382 C...Eichten, Hinchliffe, Lane, Quigg proton structure function
42383 C...parametrizations, see below.
42384 C...Powers of 1-x in different cases.
42385  DATA nehlq/3,4,7,5,7,7,7,7,3,4,7,6,7,7,7,7/
42386 C...Expansion coefficients for up valence quark distribution.
42387  DATA (((cehlq(ix,it,nx,1,1),ix=1,6),it=1,6),nx=1,2)/
42388  1 7.677d-01,-2.087d-01,-3.303d-01,-2.517d-02,-1.570d-02,-1.000d-04,
42389  2-5.326d-01,-2.661d-01, 3.201d-01, 1.192d-01, 2.434d-02, 7.620d-03,
42390  3 2.162d-01, 1.881d-01,-8.375d-02,-6.515d-02,-1.743d-02,-5.040d-03,
42391  4-9.211d-02,-9.952d-02, 1.373d-02, 2.506d-02, 8.770d-03, 2.550d-03,
42392  5 3.670d-02, 4.409d-02, 9.600d-04,-7.960d-03,-3.420d-03,-1.050d-03,
42393  6-1.549d-02,-2.026d-02,-3.060d-03, 2.220d-03, 1.240d-03, 4.100d-04,
42394  1 2.395d-01, 2.905d-01, 9.778d-02, 2.149d-02, 3.440d-03, 5.000d-04,
42395  2 1.751d-02,-6.090d-03,-2.687d-02,-1.916d-02,-7.970d-03,-2.750d-03,
42396  3-5.760d-03,-5.040d-03, 1.080d-03, 2.490d-03, 1.530d-03, 7.500d-04,
42397  4 1.740d-03, 1.960d-03, 3.000d-04,-3.400d-04,-2.900d-04,-1.800d-04,
42398  5-5.300d-04,-6.400d-04,-1.700d-04, 4.000d-05, 6.000d-05, 4.000d-05,
42399  6 1.700d-04, 2.200d-04, 8.000d-05, 1.000d-05,-1.000d-05,-1.000d-05/
42400  DATA (((cehlq(ix,it,nx,1,2),ix=1,6),it=1,6),nx=1,2)/
42401  1 7.237d-01,-2.189d-01,-2.995d-01,-1.909d-02,-1.477d-02, 2.500d-04,
42402  2-5.314d-01,-2.425d-01, 3.283d-01, 1.119d-01, 2.223d-02, 7.070d-03,
42403  3 2.289d-01, 1.890d-01,-9.859d-02,-6.900d-02,-1.747d-02,-5.080d-03,
42404  4-1.041d-01,-1.084d-01, 2.108d-02, 2.975d-02, 9.830d-03, 2.830d-03,
42405  5 4.394d-02, 5.116d-02,-1.410d-03,-1.055d-02,-4.230d-03,-1.270d-03,
42406  6-1.991d-02,-2.539d-02,-2.780d-03, 3.430d-03, 1.720d-03, 5.500d-04,
42407  1 2.410d-01, 2.884d-01, 9.369d-02, 1.900d-02, 2.530d-03, 2.400d-04,
42408  2 1.765d-02,-9.220d-03,-3.037d-02,-2.085d-02,-8.440d-03,-2.810d-03,
42409  3-6.450d-03,-5.260d-03, 1.720d-03, 3.110d-03, 1.830d-03, 8.700d-04,
42410  4 2.120d-03, 2.320d-03, 2.600d-04,-4.900d-04,-3.900d-04,-2.300d-04,
42411  5-6.900d-04,-8.200d-04,-2.000d-04, 7.000d-05, 9.000d-05, 6.000d-05,
42412  6 2.400d-04, 3.100d-04, 1.100d-04, 0.000d+00,-2.000d-05,-2.000d-05/
42413 C...Expansion coefficients for down valence quark distribution.
42414  DATA (((cehlq(ix,it,nx,2,1),ix=1,6),it=1,6),nx=1,2)/
42415  1 3.813d-01,-8.090d-02,-1.634d-01,-2.185d-02,-8.430d-03,-6.200d-04,
42416  2-2.948d-01,-1.435d-01, 1.665d-01, 6.638d-02, 1.473d-02, 4.080d-03,
42417  3 1.252d-01, 1.042d-01,-4.722d-02,-3.683d-02,-1.038d-02,-2.860d-03,
42418  4-5.478d-02,-5.678d-02, 8.900d-03, 1.484d-02, 5.340d-03, 1.520d-03,
42419  5 2.220d-02, 2.567d-02,-3.000d-05,-4.970d-03,-2.160d-03,-6.500d-04,
42420  6-9.530d-03,-1.204d-02,-1.510d-03, 1.510d-03, 8.300d-04, 2.700d-04,
42421  1 1.261d-01, 1.354d-01, 3.958d-02, 8.240d-03, 1.660d-03, 4.500d-04,
42422  2 3.890d-03,-1.159d-02,-1.625d-02,-9.610d-03,-3.710d-03,-1.260d-03,
42423  3-1.910d-03,-5.600d-04, 1.590d-03, 1.590d-03, 8.400d-04, 3.900d-04,
42424  4 6.400d-04, 4.900d-04,-1.500d-04,-2.900d-04,-1.800d-04,-1.000d-04,
42425  5-2.000d-04,-1.900d-04, 0.000d+00, 6.000d-05, 4.000d-05, 3.000d-05,
42426  6 7.000d-05, 8.000d-05, 2.000d-05,-1.000d-05,-1.000d-05,-1.000d-05/
42427  DATA (((cehlq(ix,it,nx,2,2),ix=1,6),it=1,6),nx=1,2)/
42428  1 3.578d-01,-8.622d-02,-1.480d-01,-1.840d-02,-7.820d-03,-4.500d-04,
42429  2-2.925d-01,-1.304d-01, 1.696d-01, 6.243d-02, 1.353d-02, 3.750d-03,
42430  3 1.318d-01, 1.041d-01,-5.486d-02,-3.872d-02,-1.038d-02,-2.850d-03,
42431  4-6.162d-02,-6.143d-02, 1.303d-02, 1.740d-02, 5.940d-03, 1.670d-03,
42432  5 2.643d-02, 2.957d-02,-1.490d-03,-6.450d-03,-2.630d-03,-7.700d-04,
42433  6-1.218d-02,-1.497d-02,-1.260d-03, 2.240d-03, 1.120d-03, 3.500d-04,
42434  1 1.263d-01, 1.334d-01, 3.732d-02, 7.070d-03, 1.260d-03, 3.400d-04,
42435  2 3.660d-03,-1.357d-02,-1.795d-02,-1.031d-02,-3.880d-03,-1.280d-03,
42436  3-2.100d-03,-3.600d-04, 2.050d-03, 1.920d-03, 9.800d-04, 4.400d-04,
42437  4 7.700d-04, 5.400d-04,-2.400d-04,-3.900d-04,-2.400d-04,-1.300d-04,
42438  5-2.600d-04,-2.300d-04, 2.000d-05, 9.000d-05, 6.000d-05, 4.000d-05,
42439  6 9.000d-05, 1.000d-04, 2.000d-05,-2.000d-05,-2.000d-05,-1.000d-05/
42440 C...Expansion coefficients for up and down sea quark distributions.
42441  DATA (((cehlq(ix,it,nx,3,1),ix=1,6),it=1,6),nx=1,2)/
42442  1 6.870d-02,-6.861d-02, 2.973d-02,-5.400d-03, 3.780d-03,-9.700d-04,
42443  2-1.802d-02, 1.400d-04, 6.490d-03,-8.540d-03, 1.220d-03,-1.750d-03,
42444  3-4.650d-03, 1.480d-03,-5.930d-03, 6.000d-04,-1.030d-03,-8.000d-05,
42445  4 6.440d-03, 2.570d-03, 2.830d-03, 1.150d-03, 7.100d-04, 3.300d-04,
42446  5-3.930d-03,-2.540d-03,-1.160d-03,-7.700d-04,-3.600d-04,-1.900d-04,
42447  6 2.340d-03, 1.930d-03, 5.300d-04, 3.700d-04, 1.600d-04, 9.000d-05,
42448  1 1.014d+00,-1.106d+00, 3.374d-01,-7.444d-02, 8.850d-03,-8.700d-04,
42449  2 9.233d-01,-1.285d+00, 4.475d-01,-9.786d-02, 1.419d-02,-1.120d-03,
42450  3 4.888d-02,-1.271d-01, 8.606d-02,-2.608d-02, 4.780d-03,-6.000d-04,
42451  4-2.691d-02, 4.887d-02,-1.771d-02, 1.620d-03, 2.500d-04,-6.000d-05,
42452  5 7.040d-03,-1.113d-02, 1.590d-03, 7.000d-04,-2.000d-04, 0.000d+00,
42453  6-1.710d-03, 2.290d-03, 3.800d-04,-3.500d-04, 4.000d-05, 1.000d-05/
42454  DATA (((cehlq(ix,it,nx,3,2),ix=1,6),it=1,6),nx=1,2)/
42455  1 1.008d-01,-7.100d-02, 1.973d-02,-5.710d-03, 2.930d-03,-9.900d-04,
42456  2-5.271d-02,-1.823d-02, 1.792d-02,-6.580d-03, 1.750d-03,-1.550d-03,
42457  3 1.220d-02, 1.763d-02,-8.690d-03,-8.800d-04,-1.160d-03,-2.100d-04,
42458  4-1.190d-03,-7.180d-03, 2.360d-03, 1.890d-03, 7.700d-04, 4.100d-04,
42459  5-9.100d-04, 2.040d-03,-3.100d-04,-1.050d-03,-4.000d-04,-2.400d-04,
42460  6 1.190d-03,-1.700d-04,-2.000d-04, 4.200d-04, 1.700d-04, 1.000d-04,
42461  1 1.081d+00,-1.189d+00, 3.868d-01,-8.617d-02, 1.115d-02,-1.180d-03,
42462  2 9.917d-01,-1.396d+00, 4.998d-01,-1.159d-01, 1.674d-02,-1.720d-03,
42463  3 5.099d-02,-1.338d-01, 9.173d-02,-2.885d-02, 5.890d-03,-6.500d-04,
42464  4-3.178d-02, 5.703d-02,-2.070d-02, 2.440d-03, 1.100d-04,-9.000d-05,
42465  5 8.970d-03,-1.392d-02, 2.050d-03, 6.500d-04,-2.300d-04, 2.000d-05,
42466  6-2.340d-03, 3.010d-03, 5.000d-04,-3.900d-04, 6.000d-05, 1.000d-05/
42467 C...Expansion coefficients for gluon distribution.
42468  DATA (((cehlq(ix,it,nx,4,1),ix=1,6),it=1,6),nx=1,2)/
42469  1 9.482d-01,-9.578d-01, 1.009d-01,-1.051d-01, 3.456d-02,-3.054d-02,
42470  2-9.627d-01, 5.379d-01, 3.368d-01,-9.525d-02, 1.488d-02,-2.051d-02,
42471  3 4.300d-01,-8.306d-02,-3.372d-01, 4.902d-02,-9.160d-03, 1.041d-02,
42472  4-1.925d-01,-1.790d-02, 2.183d-01, 7.490d-03, 4.140d-03,-1.860d-03,
42473  5 8.183d-02, 1.926d-02,-1.072d-01,-1.944d-02,-2.770d-03,-5.200d-04,
42474  6-3.884d-02,-1.234d-02, 5.410d-02, 1.879d-02, 3.350d-03, 1.040d-03,
42475  1 2.948d+01,-3.902d+01, 1.464d+01,-3.335d+00, 5.054d-01,-5.915d-02,
42476  2 2.559d+01,-3.955d+01, 1.661d+01,-4.299d+00, 6.904d-01,-8.243d-02,
42477  3-1.663d+00, 1.176d+00, 1.118d+00,-7.099d-01, 1.948d-01,-2.404d-02,
42478  4-2.168d-01, 8.170d-01,-7.169d-01, 1.851d-01,-1.924d-02,-3.250d-03,
42479  5 2.088d-01,-4.355d-01, 2.239d-01,-2.446d-02,-3.620d-03, 1.910d-03,
42480  6-9.097d-02, 1.601d-01,-5.681d-02,-2.500d-03, 2.580d-03,-4.700d-04/
42481  DATA (((cehlq(ix,it,nx,4,2),ix=1,6),it=1,6),nx=1,2)/
42482  1 2.367d+00, 4.453d-01, 3.660d-01, 9.467d-02, 1.341d-01, 1.661d-02,
42483  2-3.170d+00,-1.795d+00, 3.313d-02,-2.874d-01,-9.827d-02,-7.119d-02,
42484  3 1.823d+00, 1.457d+00,-2.465d-01, 3.739d-02, 6.090d-03, 1.814d-02,
42485  4-1.033d+00,-9.827d-01, 2.136d-01, 1.169d-01, 5.001d-02, 1.684d-02,
42486  5 5.133d-01, 5.259d-01,-1.173d-01,-1.139d-01,-4.988d-02,-2.021d-02,
42487  6-2.881d-01,-3.145d-01, 5.667d-02, 9.161d-02, 4.568d-02, 1.951d-02,
42488  1 3.036d+01,-4.062d+01, 1.578d+01,-3.699d+00, 6.020d-01,-7.031d-02,
42489  2 2.700d+01,-4.167d+01, 1.770d+01,-4.804d+00, 7.862d-01,-1.060d-01,
42490  3-1.909d+00, 1.357d+00, 1.127d+00,-7.181d-01, 2.232d-01,-2.481d-02,
42491  4-2.488d-01, 9.781d-01,-8.127d-01, 2.094d-01,-2.997d-02,-4.710d-03,
42492  5 2.506d-01,-5.427d-01, 2.672d-01,-3.103d-02,-1.800d-03, 2.870d-03,
42493  6-1.128d-01, 2.087d-01,-6.972d-02,-2.480d-03, 2.630d-03,-8.400d-04/
42494 C...Expansion coefficients for strange sea quark distribution.
42495  DATA (((cehlq(ix,it,nx,5,1),ix=1,6),it=1,6),nx=1,2)/
42496  1 4.968d-02,-4.173d-02, 2.102d-02,-3.270d-03, 3.240d-03,-6.700d-04,
42497  2-6.150d-03,-1.294d-02, 6.740d-03,-6.890d-03, 9.000d-04,-1.510d-03,
42498  3-8.580d-03, 5.050d-03,-4.900d-03,-1.600d-04,-9.400d-04,-1.500d-04,
42499  4 7.840d-03, 1.510d-03, 2.220d-03, 1.400d-03, 7.000d-04, 3.500d-04,
42500  5-4.410d-03,-2.220d-03,-8.900d-04,-8.500d-04,-3.600d-04,-2.000d-04,
42501  6 2.520d-03, 1.840d-03, 4.100d-04, 3.900d-04, 1.600d-04, 9.000d-05,
42502  1 9.235d-01,-1.085d+00, 3.464d-01,-7.210d-02, 9.140d-03,-9.100d-04,
42503  2 9.315d-01,-1.274d+00, 4.512d-01,-9.775d-02, 1.380d-02,-1.310d-03,
42504  3 4.739d-02,-1.296d-01, 8.482d-02,-2.642d-02, 4.760d-03,-5.700d-04,
42505  4-2.653d-02, 4.953d-02,-1.735d-02, 1.750d-03, 2.800d-04,-6.000d-05,
42506  5 6.940d-03,-1.132d-02, 1.480d-03, 6.500d-04,-2.100d-04, 0.000d+00,
42507  6-1.680d-03, 2.340d-03, 4.200d-04,-3.400d-04, 5.000d-05, 1.000d-05/
42508  DATA (((cehlq(ix,it,nx,5,2),ix=1,6),it=1,6),nx=1,2)/
42509  1 6.478d-02,-4.537d-02, 1.643d-02,-3.490d-03, 2.710d-03,-6.700d-04,
42510  2-2.223d-02,-2.126d-02, 1.247d-02,-6.290d-03, 1.120d-03,-1.440d-03,
42511  3-1.340d-03, 1.362d-02,-6.130d-03,-7.900d-04,-9.000d-04,-2.000d-04,
42512  4 5.080d-03,-3.610d-03, 1.700d-03, 1.830d-03, 6.800d-04, 4.000d-04,
42513  5-3.580d-03, 6.000d-05,-2.600d-04,-1.050d-03,-3.800d-04,-2.300d-04,
42514  6 2.420d-03, 9.300d-04,-1.000d-04, 4.500d-04, 1.700d-04, 1.100d-04,
42515  1 9.868d-01,-1.171d+00, 3.940d-01,-8.459d-02, 1.124d-02,-1.250d-03,
42516  2 1.001d+00,-1.383d+00, 5.044d-01,-1.152d-01, 1.658d-02,-1.830d-03,
42517  3 4.928d-02,-1.368d-01, 9.021d-02,-2.935d-02, 5.800d-03,-6.600d-04,
42518  4-3.133d-02, 5.785d-02,-2.023d-02, 2.630d-03, 1.600d-04,-8.000d-05,
42519  5 8.840d-03,-1.416d-02, 1.900d-03, 5.800d-04,-2.500d-04, 1.000d-05,
42520  6-2.300d-03, 3.080d-03, 5.500d-04,-3.700d-04, 7.000d-05, 1.000d-05/
42521 C...Expansion coefficients for charm sea quark distribution.
42522  DATA (((cehlq(ix,it,nx,6,1),ix=1,6),it=1,6),nx=1,2)/
42523  1 9.270d-03,-1.817d-02, 9.590d-03,-6.390d-03, 1.690d-03,-1.540d-03,
42524  2 5.710d-03,-1.188d-02, 6.090d-03,-4.650d-03, 1.240d-03,-1.310d-03,
42525  3-3.960d-03, 7.100d-03,-3.590d-03, 1.840d-03,-3.900d-04, 3.400d-04,
42526  4 1.120d-03,-1.960d-03, 1.120d-03,-4.800d-04, 1.000d-04,-4.000d-05,
42527  5 4.000d-05,-3.000d-05,-1.800d-04, 9.000d-05,-5.000d-05,-2.000d-05,
42528  6-4.200d-04, 7.300d-04,-1.600d-04, 5.000d-05, 5.000d-05, 5.000d-05,
42529  1 8.098d-01,-1.042d+00, 3.398d-01,-6.824d-02, 8.760d-03,-9.000d-04,
42530  2 8.961d-01,-1.217d+00, 4.339d-01,-9.287d-02, 1.304d-02,-1.290d-03,
42531  3 3.058d-02,-1.040d-01, 7.604d-02,-2.415d-02, 4.600d-03,-5.000d-04,
42532  4-2.451d-02, 4.432d-02,-1.651d-02, 1.430d-03, 1.200d-04,-1.000d-04,
42533  5 1.122d-02,-1.457d-02, 2.680d-03, 5.800d-04,-1.200d-04, 3.000d-05,
42534  6-7.730d-03, 7.330d-03,-7.600d-04,-2.400d-04, 1.000d-05, 0.000d+00/
42535  DATA (((cehlq(ix,it,nx,6,2),ix=1,6),it=1,6),nx=1,2)/
42536  1 9.980d-03,-1.945d-02, 1.055d-02,-6.870d-03, 1.860d-03,-1.560d-03,
42537  2 5.700d-03,-1.203d-02, 6.250d-03,-4.860d-03, 1.310d-03,-1.370d-03,
42538  3-4.490d-03, 7.990d-03,-4.170d-03, 2.050d-03,-4.400d-04, 3.300d-04,
42539  4 1.470d-03,-2.480d-03, 1.460d-03,-5.700d-04, 1.200d-04,-1.000d-05,
42540  5-9.000d-05, 1.500d-04,-3.200d-04, 1.200d-04,-6.000d-05,-4.000d-05,
42541  6-4.200d-04, 7.600d-04,-1.400d-04, 4.000d-05, 7.000d-05, 5.000d-05,
42542  1 8.698d-01,-1.131d+00, 3.836d-01,-8.111d-02, 1.048d-02,-1.300d-03,
42543  2 9.626d-01,-1.321d+00, 4.854d-01,-1.091d-01, 1.583d-02,-1.700d-03,
42544  3 3.057d-02,-1.088d-01, 8.022d-02,-2.676d-02, 5.590d-03,-5.600d-04,
42545  4-2.845d-02, 5.164d-02,-1.918d-02, 2.210d-03,-4.000d-05,-1.500d-04,
42546  5 1.311d-02,-1.751d-02, 3.310d-03, 5.100d-04,-1.200d-04, 5.000d-05,
42547  6-8.590d-03, 8.380d-03,-9.200d-04,-2.600d-04, 1.000d-05,-1.000d-05/
42548 C...Expansion coefficients for bottom sea quark distribution.
42549  DATA (((cehlq(ix,it,nx,7,1),ix=1,6),it=1,6),nx=1,2)/
42550  1 9.010d-03,-1.401d-02, 7.150d-03,-4.130d-03, 1.260d-03,-1.040d-03,
42551  2 6.280d-03,-9.320d-03, 4.780d-03,-2.890d-03, 9.100d-04,-8.200d-04,
42552  3-2.930d-03, 4.090d-03,-1.890d-03, 7.600d-04,-2.300d-04, 1.400d-04,
42553  4 3.900d-04,-1.200d-03, 4.400d-04,-2.500d-04, 2.000d-05,-2.000d-05,
42554  5 2.600d-04, 1.400d-04,-8.000d-05, 1.000d-04, 1.000d-05, 1.000d-05,
42555  6-2.600d-04, 3.200d-04, 1.000d-05,-1.000d-05, 1.000d-05,-1.000d-05,
42556  1 8.029d-01,-1.075d+00, 3.792d-01,-7.843d-02, 1.007d-02,-1.090d-03,
42557  2 7.903d-01,-1.099d+00, 4.153d-01,-9.301d-02, 1.317d-02,-1.410d-03,
42558  3-1.704d-02,-1.130d-02, 2.882d-02,-1.341d-02, 3.040d-03,-3.600d-04,
42559  4-7.200d-04, 7.230d-03,-5.160d-03, 1.080d-03,-5.000d-05,-4.000d-05,
42560  5 3.050d-03,-4.610d-03, 1.660d-03,-1.300d-04,-1.000d-05, 1.000d-05,
42561  6-4.360d-03, 5.230d-03,-1.610d-03, 2.000d-04,-2.000d-05, 0.000d+00/
42562  DATA (((cehlq(ix,it,nx,7,2),ix=1,6),it=1,6),nx=1,2)/
42563  1 8.980d-03,-1.459d-02, 7.510d-03,-4.410d-03, 1.310d-03,-1.070d-03,
42564  2 5.970d-03,-9.440d-03, 4.800d-03,-3.020d-03, 9.100d-04,-8.500d-04,
42565  3-3.050d-03, 4.440d-03,-2.100d-03, 8.500d-04,-2.400d-04, 1.400d-04,
42566  4 5.300d-04,-1.300d-03, 5.600d-04,-2.700d-04, 3.000d-05,-2.000d-05,
42567  5 2.000d-04, 1.400d-04,-1.100d-04, 1.000d-04, 0.000d+00, 0.000d+00,
42568  6-2.600d-04, 3.200d-04, 0.000d+00,-3.000d-05, 1.000d-05,-1.000d-05,
42569  1 8.672d-01,-1.174d+00, 4.265d-01,-9.252d-02, 1.244d-02,-1.460d-03,
42570  2 8.500d-01,-1.194d+00, 4.630d-01,-1.083d-01, 1.614d-02,-1.830d-03,
42571  3-2.241d-02,-5.630d-03, 2.815d-02,-1.425d-02, 3.520d-03,-4.300d-04,
42572  4-7.300d-04, 8.030d-03,-5.780d-03, 1.380d-03,-1.300d-04,-4.000d-05,
42573  5 3.460d-03,-5.380d-03, 1.960d-03,-2.100d-04, 1.000d-05, 1.000d-05,
42574  6-4.850d-03, 5.950d-03,-1.890d-03, 2.600d-04,-3.000d-05, 0.000d+00/
42575 C...Expansion coefficients for top sea quark distribution.
42576  DATA (((cehlq(ix,it,nx,8,1),ix=1,6),it=1,6),nx=1,2)/
42577  1 4.410d-03,-7.480d-03, 3.770d-03,-2.580d-03, 7.300d-04,-7.100d-04,
42578  2 3.840d-03,-6.050d-03, 3.030d-03,-2.030d-03, 5.800d-04,-5.900d-04,
42579  3-8.800d-04, 1.660d-03,-7.500d-04, 4.700d-04,-1.000d-04, 1.000d-04,
42580  4-8.000d-05,-1.500d-04, 1.200d-04,-9.000d-05, 3.000d-05, 0.000d+00,
42581  5 1.300d-04,-2.200d-04,-2.000d-05,-2.000d-05,-2.000d-05,-2.000d-05,
42582  6-7.000d-05, 1.900d-04,-4.000d-05, 2.000d-05, 0.000d+00, 0.000d+00,
42583  1 6.623d-01,-9.248d-01, 3.519d-01,-7.930d-02, 1.110d-02,-1.180d-03,
42584  2 6.380d-01,-9.062d-01, 3.582d-01,-8.479d-02, 1.265d-02,-1.390d-03,
42585  3-2.581d-02, 2.125d-02, 4.190d-03,-4.980d-03, 1.490d-03,-2.100d-04,
42586  4 7.100d-04, 5.300d-04,-1.270d-03, 3.900d-04,-5.000d-05,-1.000d-05,
42587  5 3.850d-03,-5.060d-03, 1.860d-03,-3.500d-04, 4.000d-05, 0.000d+00,
42588  6-3.530d-03, 4.460d-03,-1.500d-03, 2.700d-04,-3.000d-05, 0.000d+00/
42589  DATA (((cehlq(ix,it,nx,8,2),ix=1,6),it=1,6),nx=1,2)/
42590  1 4.260d-03,-7.530d-03, 3.830d-03,-2.680d-03, 7.600d-04,-7.300d-04,
42591  2 3.640d-03,-6.050d-03, 3.030d-03,-2.090d-03, 5.900d-04,-6.000d-04,
42592  3-9.200d-04, 1.710d-03,-8.200d-04, 5.000d-04,-1.200d-04, 1.000d-04,
42593  4-5.000d-05,-1.600d-04, 1.300d-04,-9.000d-05, 3.000d-05, 0.000d+00,
42594  5 1.300d-04,-2.100d-04,-1.000d-05,-2.000d-05,-2.000d-05,-1.000d-05,
42595  6-8.000d-05, 1.800d-04,-5.000d-05, 2.000d-05, 0.000d+00, 0.000d+00,
42596  1 7.146d-01,-1.007d+00, 3.932d-01,-9.246d-02, 1.366d-02,-1.540d-03,
42597  2 6.856d-01,-9.828d-01, 3.977d-01,-9.795d-02, 1.540d-02,-1.790d-03,
42598  3-3.053d-02, 2.758d-02, 2.150d-03,-4.880d-03, 1.640d-03,-2.500d-04,
42599  4 9.200d-04, 4.200d-04,-1.340d-03, 4.600d-04,-8.000d-05,-1.000d-05,
42600  5 4.230d-03,-5.660d-03, 2.140d-03,-4.300d-04, 6.000d-05, 0.000d+00,
42601  6-3.890d-03, 5.000d-03,-1.740d-03, 3.300d-04,-4.000d-05, 0.000d+00/
42602 
42603 C...The following data lines are coefficients needed in the
42604 C...Duke, Owens proton structure function parametrizations, see below.
42605 C...Expansion coefficients for (up+down) valence quark distribution.
42606  DATA ((cdo(ip,is,1,1),is=1,6),ip=1,3)/
42607  1 4.190d-01, 3.460d+00, 4.400d+00, 0.000d+00, 0.000d+00, 0.000d+00,
42608  2 4.000d-03, 7.240d-01,-4.860d+00, 0.000d+00, 0.000d+00, 0.000d+00,
42609  3-7.000d-03,-6.600d-02, 1.330d+00, 0.000d+00, 0.000d+00, 0.000d+00/
42610  DATA ((cdo(ip,is,1,2),is=1,6),ip=1,3)/
42611  1 3.740d-01, 3.330d+00, 6.030d+00, 0.000d+00, 0.000d+00, 0.000d+00,
42612  2 1.400d-02, 7.530d-01,-6.220d+00, 0.000d+00, 0.000d+00, 0.000d+00,
42613  3 0.000d+00,-7.600d-02, 1.560d+00, 0.000d+00, 0.000d+00, 0.000d+00/
42614 C...Expansion coefficients for down valence quark distribution.
42615  DATA ((cdo(ip,is,2,1),is=1,6),ip=1,3)/
42616  1 7.630d-01, 4.000d+00, 0.000d+00, 0.000d+00, 0.000d+00, 0.000d+00,
42617  2-2.370d-01, 6.270d-01,-4.210d-01, 0.000d+00, 0.000d+00, 0.000d+00,
42618  3 2.600d-02,-1.900d-02, 3.300d-02, 0.000d+00, 0.000d+00, 0.000d+00/
42619  DATA ((cdo(ip,is,2,2),is=1,6),ip=1,3)/
42620  1 7.610d-01, 3.830d+00, 0.000d+00, 0.000d+00, 0.000d+00, 0.000d+00,
42621  2-2.320d-01, 6.270d-01,-4.180d-01, 0.000d+00, 0.000d+00, 0.000d+00,
42622  3 2.300d-02,-1.900d-02, 3.600d-02, 0.000d+00, 0.000d+00, 0.000d+00/
42623 C...Expansion coefficients for (up+down+strange) sea quark distribution.
42624  DATA ((cdo(ip,is,3,1),is=1,6),ip=1,3)/
42625  1 1.265d+00, 0.000d+00, 8.050d+00, 0.000d+00, 0.000d+00, 0.000d+00,
42626  2-1.132d+00,-3.720d-01, 1.590d+00, 6.310d+00,-1.050d+01, 1.470d+01,
42627  3 2.930d-01,-2.900d-02,-1.530d-01,-2.730d-01,-3.170d+00, 9.800d+00/
42628  DATA ((cdo(ip,is,3,2),is=1,6),ip=1,3)/
42629  1 1.670d+00, 0.000d+00, 9.150d+00, 0.000d+00, 0.000d+00, 0.000d+00,
42630  2-1.920d+00,-2.730d-01, 5.300d-01, 1.570d+01,-1.010d+02, 2.230d+02,
42631  3 5.820d-01,-1.640d-01,-7.630d-01,-2.830d+00, 4.470d+01,-1.170d+02/
42632 C...Expansion coefficients for charm sea quark distribution.
42633  DATA ((cdo(ip,is,4,1),is=1,6),ip=1,3)/
42634  1 0.000d+00,-3.600d-02, 6.350d+00, 0.000d+00, 0.000d+00, 0.000d+00,
42635  2 1.350d-01,-2.220d-01, 3.260d+00,-3.030d+00, 1.740d+01,-1.790d+01,
42636  3-7.500d-02,-5.800d-02,-9.090d-01, 1.500d+00,-1.130d+01, 1.560d+01/
42637  DATA ((cdo(ip,is,4,2),is=1,6),ip=1,3)/
42638  1 0.000d+00,-1.200d-01, 3.510d+00, 0.000d+00, 0.000d+00, 0.000d+00,
42639  2 6.700d-02,-2.330d-01, 3.660d+00,-4.740d-01, 9.500d+00,-1.660d+01,
42640  3-3.100d-02,-2.300d-02,-4.530d-01, 3.580d-01,-5.430d+00, 1.550d+01/
42641 C...Expansion coefficients for gluon distribution.
42642  DATA ((cdo(ip,is,5,1),is=1,6),ip=1,3)/
42643  1 1.560d+00, 0.000d+00, 6.000d+00, 9.000d+00, 0.000d+00, 0.000d+00,
42644  2-1.710d+00,-9.490d-01, 1.440d+00,-7.190d+00,-1.650d+01, 1.530d+01,
42645  3 6.380d-01, 3.250d-01,-1.050d+00, 2.550d-01, 1.090d+01,-1.010d+01/
42646  DATA ((cdo(ip,is,5,2),is=1,6),ip=1,3)/
42647  1 8.790d-01, 0.000d+00, 4.000d+00, 9.000d+00, 0.000d+00, 0.000d+00,
42648  2-9.710d-01,-1.160d+00, 1.230d+00,-5.640d+00,-7.540d+00,-5.960d-01,
42649  3 4.340d-01, 4.760d-01,-2.540d-01,-8.170d-01, 5.500d+00, 1.260d-01/
42650 
42651 C...Euler's beta function, requires ordinary Gamma function
42652  eulbet(x,y)=pygamm(x)*pygamm(y)/pygamm(x+y)
42653 
42654 C...Leading order proton parton distributions from Glueck, Reya and
42655 C...Vogt. Allowed variable range: 0.25 GeV^2 < Q^2 < 10^8 GeV^2 and
42656 C...10^-5 < x < 1.
42657  IF(mstp(51).EQ.11) THEN
42658 
42659 C...Determine s expansion variable and some x expressions.
42660  q2in=min(1d8,max(0.25d0,q2))
42661  sd=log(log(q2in/0.232d0**2)/log(0.25d0/0.232d0**2))
42662  sd2=sd**2
42663  xl=-log(x)
42664  xs=sqrt(x)
42665 
42666 C...Evaluate valence, gluon and sea distributions.
42667  xfvud=(0.663d0+0.191d0*sd-0.041d0*sd2+0.031d0*sd**3)*
42668  & x**0.326d0*(1d0+(-1.97d0+6.74d0*sd-1.96d0*sd2)*xs+
42669  & (24.4d0-20.7d0*sd+4.08d0*sd2)*x)*
42670  & (1d0-x)**(2.86d0+0.70d0*sd-0.02d0*sd2)
42671  xfvdd=(0.579d0+0.283d0*sd+0.047d0*sd2)*x**(0.523d0-0.015d0*sd)*
42672  & (1d0+(2.22d0-0.59d0*sd-0.27d0*sd2)*xs+(5.95d0-6.19d0*sd+
42673  & 1.55d0*sd2)*x)*(1d0-x)**(3.57d0+0.94d0*sd-0.16d0*sd2)
42674  xfglu=(x**(1.00d0-0.17d0*sd)*((4.879d0*sd-1.383d0*sd2)+
42675  & (25.92d0-28.97d0*sd+5.596d0*sd2)*x+(-25.69d0+23.68d0*sd-
42676  & 1.975d0*sd2)*x**2)+sd**0.558d0*exp(-(0.595d0+2.138d0*sd)+
42677  & sqrt(4.066d0*sd**1.218d0*xl)))*
42678  & (1d0-x)**(2.537d0+1.718d0*sd+0.353d0*sd2)
42679  xfsea=(x**(0.412d0-0.171d0*sd)*(0.363d0-1.196d0*x+(1.029d0+
42680  & 1.785d0*sd-0.459d0*sd2)*x**2)*xl**(0.566d0-0.496d0*sd)+
42681  & sd**1.396d0*exp(-(3.838d0+1.944d0*sd)+sqrt(2.845d0*sd**1.331d0*
42682  & xl)))*(1d0-x)**(4.696d0+2.109d0*sd)
42683  xfstr=sd**0.803d0*(1d0+(-3.055d0+1.024d0*sd**0.67d0)*xs+
42684  & (27.4d0-20.0d0*sd**0.154d0)*x)*(1d0-x)**6.22d0*
42685  & exp(-(4.33d0+1.408d0*sd)+sqrt((8.27d0-0.437d0*sd)*
42686  & sd**0.563d0*xl))/xl**(2.082d0-0.577d0*sd)
42687  IF(sd.LE.0.888d0) THEN
42688  xfchm=0d0
42689  ELSE
42690  xfchm=(sd-0.888d0)**1.01d0*(1.+(4.24d0-0.804d0*sd)*x)*
42691  & (1d0-x)**(3.46d0+1.076d0*sd)*exp(-(4.61d0+1.49d0*sd)+
42692  & sqrt((2.555d0+1.961d0*sd)*sd**0.37d0*xl))
42693  ENDIF
42694  IF(sd.LE.1.351d0) THEN
42695  xfbot=0d0
42696  ELSE
42697  xfbot=(sd-1.351d0)*(1d0+1.848d0*x)*(1d0-x)**(2.929d0+
42698  & 1.396d0*sd)*exp(-(4.71d0+1.514d0*sd)+
42699  & sqrt((4.02d0+1.239d0*sd)*sd**0.51d0*xl))
42700  ENDIF
42701 
42702 C...Put into output array.
42703  xppr(0)=xfglu
42704  xppr(1)=xfvdd+xfsea
42705  xppr(2)=xfvud-xfvdd+xfsea
42706  xppr(3)=xfstr
42707  xppr(4)=xfchm
42708  xppr(5)=xfbot
42709  xppr(-1)=xfsea
42710  xppr(-2)=xfsea
42711  xppr(-3)=xfstr
42712  xppr(-4)=xfchm
42713  xppr(-5)=xfbot
42714 
42715 C...Proton parton distributions from Eichten, Hinchliffe, Lane, Quigg.
42716 C...Allowed variable range: 5 GeV^2 < Q^2 < 1E8 GeV^2; 1E-4 < x < 1
42717  ELSEIF(mstp(51).EQ.12.OR.mstp(51).EQ.13) THEN
42718 
42719 C...Determine set, Lambda and x and t expansion variables.
42720  nset=mstp(51)-11
42721  IF(nset.EQ.1) alam=0.2d0
42722  IF(nset.EQ.2) alam=0.29d0
42723  tmin=log(5d0/alam**2)
42724  tmax=log(1d8/alam**2)
42725  t=log(max(1d0,q2/alam**2))
42726  vt=max(-1d0,min(1d0,(2d0*t-tmax-tmin)/(tmax-tmin)))
42727  nx=1
42728  IF(x.LE.0.1d0) nx=2
42729  IF(nx.EQ.1) vx=(2d0*x-1.1d0)/0.9d0
42730  IF(nx.EQ.2) vx=max(-1d0,(2d0*log(x)+11.51293d0)/6.90776d0)
42731 
42732 C...Chebyshev polynomials for x and t expansion.
42733  tx(1)=1d0
42734  tx(2)=vx
42735  tx(3)=2d0*vx**2-1d0
42736  tx(4)=4d0*vx**3-3d0*vx
42737  tx(5)=8d0*vx**4-8d0*vx**2+1d0
42738  tx(6)=16d0*vx**5-20d0*vx**3+5d0*vx
42739  tt(1)=1d0
42740  tt(2)=vt
42741  tt(3)=2d0*vt**2-1d0
42742  tt(4)=4d0*vt**3-3d0*vt
42743  tt(5)=8d0*vt**4-8d0*vt**2+1d0
42744  tt(6)=16d0*vt**5-20d0*vt**3+5d0*vt
42745 
42746 C...Calculate structure functions.
42747  DO 120 kfl=1,6
42748  xqsum=0d0
42749  DO 110 it=1,6
42750  DO 100 ix=1,6
42751  xqsum=xqsum+cehlq(ix,it,nx,kfl,nset)*tx(ix)*tt(it)
42752  100 CONTINUE
42753  110 CONTINUE
42754  xq(kfl)=xqsum*(1d0-x)**nehlq(kfl,nset)
42755  120 CONTINUE
42756 
42757 C...Put into output array.
42758  xppr(0)=xq(4)
42759  xppr(1)=xq(2)+xq(3)
42760  xppr(2)=xq(1)+xq(3)
42761  xppr(3)=xq(5)
42762  xppr(4)=xq(6)
42763  xppr(-1)=xq(3)
42764  xppr(-2)=xq(3)
42765  xppr(-3)=xq(5)
42766  xppr(-4)=xq(6)
42767 
42768 C...Special expansion for bottom (threshold effects).
42769  IF(mstp(58).GE.5) THEN
42770  IF(nset.EQ.1) tmin=8.1905d0
42771  IF(nset.EQ.2) tmin=7.4474d0
42772  IF(t.GT.tmin) THEN
42773  vt=max(-1d0,min(1d0,(2d0*t-tmax-tmin)/(tmax-tmin)))
42774  tt(1)=1d0
42775  tt(2)=vt
42776  tt(3)=2d0*vt**2-1d0
42777  tt(4)=4d0*vt**3-3d0*vt
42778  tt(5)=8d0*vt**4-8d0*vt**2+1d0
42779  tt(6)=16d0*vt**5-20d0*vt**3+5d0*vt
42780  xqsum=0d0
42781  DO 140 it=1,6
42782  DO 130 ix=1,6
42783  xqsum=xqsum+cehlq(ix,it,nx,7,nset)*tx(ix)*tt(it)
42784  130 CONTINUE
42785  140 CONTINUE
42786  xppr(5)=xqsum*(1d0-x)**nehlq(7,nset)
42787  xppr(-5)=xppr(5)
42788  ENDIF
42789  ENDIF
42790 
42791 C...Special expansion for top (threshold effects).
42792  IF(mstp(58).GE.6) THEN
42793  IF(nset.EQ.1) tmin=11.5528d0
42794  IF(nset.EQ.2) tmin=10.8097d0
42795  tmin=tmin+2d0*log(pmas(6,1)/30d0)
42796  tmax=tmax+2d0*log(pmas(6,1)/30d0)
42797  IF(t.GT.tmin) THEN
42798  vt=max(-1d0,min(1d0,(2d0*t-tmax-tmin)/(tmax-tmin)))
42799  tt(1)=1d0
42800  tt(2)=vt
42801  tt(3)=2d0*vt**2-1d0
42802  tt(4)=4d0*vt**3-3d0*vt
42803  tt(5)=8d0*vt**4-8d0*vt**2+1d0
42804  tt(6)=16d0*vt**5-20d0*vt**3+5d0*vt
42805  xqsum=0d0
42806  DO 160 it=1,6
42807  DO 150 ix=1,6
42808  xqsum=xqsum+cehlq(ix,it,nx,8,nset)*tx(ix)*tt(it)
42809  150 CONTINUE
42810  160 CONTINUE
42811  xppr(6)=xqsum*(1d0-x)**nehlq(8,nset)
42812  xppr(-6)=xppr(6)
42813  ENDIF
42814  ENDIF
42815 
42816 C...Proton parton distributions from Duke, Owens.
42817 C...Allowed variable range: 4 GeV^2 < Q^2 < approx 1E6 GeV^2.
42818  ELSEIF(mstp(51).EQ.14.OR.mstp(51).EQ.15) THEN
42819 
42820 C...Determine set, Lambda and s expansion parameter.
42821  nset=mstp(51)-13
42822  IF(nset.EQ.1) alam=0.2d0
42823  IF(nset.EQ.2) alam=0.4d0
42824  q2in=min(1d6,max(4d0,q2))
42825  sd=log(log(q2in/alam**2)/log(4d0/alam**2))
42826 
42827 C...Calculate structure functions.
42828  DO 180 kfl=1,5
42829  DO 170 is=1,6
42830  ts(is)=cdo(1,is,kfl,nset)+cdo(2,is,kfl,nset)*sd+
42831  & cdo(3,is,kfl,nset)*sd**2
42832  170 CONTINUE
42833  IF(kfl.LE.2) THEN
42834  xq(kfl)=x**ts(1)*(1d0-x)**ts(2)*(1d0+ts(3)*x)/(eulbet(ts(1),
42835  & ts(2)+1d0)*(1d0+ts(3)*ts(1)/(ts(1)+ts(2)+1d0)))
42836  ELSE
42837  xq(kfl)=ts(1)*x**ts(2)*(1d0-x)**ts(3)*(1d0+ts(4)*x+
42838  & ts(5)*x**2+ts(6)*x**3)
42839  ENDIF
42840  180 CONTINUE
42841 
42842 C...Put into output arrays.
42843  xppr(0)=xq(5)
42844  xppr(1)=xq(2)+xq(3)/6d0
42845  xppr(2)=3d0*xq(1)-xq(2)+xq(3)/6d0
42846  xppr(3)=xq(3)/6d0
42847  xppr(4)=xq(4)
42848  xppr(-1)=xq(3)/6d0
42849  xppr(-2)=xq(3)/6d0
42850  xppr(-3)=xq(3)/6d0
42851  xppr(-4)=xq(4)
42852 
42853  ENDIF
42854 
42855  RETURN
42856  END
42857 
42858 C*********************************************************************
42859 
42860 C...PYHFTH
42861 C...Gives threshold attractive/repulsive factor for heavy flavour
42862 C...production.
42863 
42864  FUNCTION pyhfth(SH,SQM,FRATT)
42865 
42866 C...Double precision and integer declarations.
42867  IMPLICIT DOUBLE PRECISION(a-h, o-z)
42868  IMPLICIT INTEGER(i-n)
42869  INTEGER pyk,pychge,pycomp
42870 C...Commonblocks.
42871  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
42872  common/pypars/mstp(200),parp(200),msti(200),pari(200)
42873  common/pyint1/mint(400),vint(400)
42874  SAVE /pydat1/,/pypars/,/pyint1/
42875 
42876 C...Value for alpha_strong.
42877  IF(mstp(35).LE.1) THEN
42878  alssg=parp(35)
42879  ELSE
42880  mst115=mstu(115)
42881  mstu(115)=mstp(36)
42882  q2bn=sqrt(max(1d0,sqm*((sqrt(sh)-2d0*sqrt(sqm))**2+
42883  & parp(36)**2)))
42884  alssg=pyalps(q2bn)
42885  mstu(115)=mst115
42886  ENDIF
42887 
42888 C...Evaluate attractive and repulsive factors.
42889  xattr=4d0*paru(1)*alssg/(3d0*sqrt(max(1d-20,1d0-4d0*sqm/sh)))
42890  fattr=xattr/(1d0-exp(-min(50d0,xattr)))
42891  xrepu=paru(1)*alssg/(6d0*sqrt(max(1d-20,1d0-4d0*sqm/sh)))
42892  frepu=xrepu/(exp(min(50d0,xrepu))-1d0)
42893  pyhfth=fratt*fattr+(1d0-fratt)*frepu
42894  vint(138)=pyhfth
42895 
42896  RETURN
42897  END
42898 
42899 C*********************************************************************
42900 
42901 C...PYSPLI
42902 C...Splits a hadron remnant into two (partons or hadron + parton)
42903 C...in case it is more complicated than just a quark or a diquark.
42904 
42905  SUBROUTINE pyspli(KF,KFLIN,KFLCH,KFLSP)
42906 
42907 C...Double precision and integer declarations.
42908  IMPLICIT DOUBLE PRECISION(a-h, o-z)
42909  IMPLICIT INTEGER(i-n)
42910  INTEGER pyk,pychge,pycomp
42911 C...Commonblocks. PYDAT1 temporary
42912  common/pypars/mstp(200),parp(200),msti(200),pari(200)
42913  common/pyint1/mint(400),vint(400)
42914  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
42915  SAVE /pypars/,/pyint1/,/pydat1/
42916 C...Local array.
42917  dimension kfl(3)
42918 
42919 C...Preliminaries. Parton composition.
42920  kfa=iabs(kf)
42921  kfs=isign(1,kf)
42922  kfl(1)=mod(kfa/1000,10)
42923  kfl(2)=mod(kfa/100,10)
42924  kfl(3)=mod(kfa/10,10)
42925  IF(kfa.EQ.22.AND.mint(109).EQ.2) THEN
42926  kfl(2)=int(1.5d0+pyr(0))
42927  IF(mint(105).EQ.333) kfl(2)=3
42928  IF(mint(105).EQ.443) kfl(2)=4
42929  kfl(3)=kfl(2)
42930  ELSEIF((kfa.EQ.111.OR.kfa.EQ.113).AND.pyr(0).GT.0.5d0) THEN
42931  kfl(2)=2
42932  kfl(3)=2
42933  ELSEIF(kfa.EQ.223.AND.pyr(0).GT.0.5d0) THEN
42934  kfl(2)=1
42935  kfl(3)=1
42936  ELSEIF((kfa.EQ.130.OR.kfa.EQ.310).AND.pyr(0).GT.0.5d0) THEN
42937  kfl(2)=mod(kfa/10,10)
42938  kfl(3)=mod(kfa/100,10)
42939  ENDIF
42940  IF(kflin.NE.21.AND.kflin.NE.22.AND.kflin.NE.23) THEN
42941  kflr=kflin*kfs
42942  ELSE
42943  kflr=kflin
42944  ENDIF
42945  kflch=0
42946 
42947 C...Subdivide lepton.
42948  IF(kfa.GE.11.AND.kfa.LE.18) THEN
42949  IF(kflr.EQ.kfa) THEN
42950  kflsp=kfs*22
42951  ELSEIF(kflr.EQ.22) THEN
42952  kflsp=kfa
42953  ELSEIF(kflr.EQ.-24.AND.mod(kfa,2).EQ.1) THEN
42954  kflsp=kfa+1
42955  ELSEIF(kflr.EQ.24.AND.mod(kfa,2).EQ.0) THEN
42956  kflsp=kfa-1
42957  ELSEIF(kflr.EQ.21) THEN
42958  kflsp=kfa
42959  kflch=kfs*21
42960  ELSE
42961  kflsp=kfa
42962  kflch=-kflr
42963  ENDIF
42964 
42965 C...Subdivide photon.
42966  ELSEIF(kfa.EQ.22.AND.mint(109).NE.2) THEN
42967  IF(kflr.NE.21) THEN
42968  kflsp=-kflr
42969  ELSE
42970  ragr=0.75d0*pyr(0)
42971  kflsp=1
42972  IF(ragr.GT.0.125d0) kflsp=2
42973  IF(ragr.GT.0.625d0) kflsp=3
42974  IF(pyr(0).GT.0.5d0) kflsp=-kflsp
42975  kflch=-kflsp
42976  ENDIF
42977 
42978 C...Subdivide Reggeon or Pomeron.
42979  ELSEIF(kfa.EQ.110.OR.kfa.EQ.990) THEN
42980  IF(kflin.EQ.21) THEN
42981  kflsp=kfs*21
42982  ELSE
42983  kflsp=-kflin
42984  ENDIF
42985 
42986 C...Subdivide meson.
42987  ELSEIF(kfl(1).EQ.0) THEN
42988  kfl(2)=kfl(2)*(-1)**kfl(2)
42989  kfl(3)=-kfl(3)*(-1)**iabs(kfl(2))
42990  IF(kflr.EQ.kfl(2)) THEN
42991  kflsp=kfl(3)
42992  ELSEIF(kflr.EQ.kfl(3)) THEN
42993  kflsp=kfl(2)
42994  ELSEIF(kflr.EQ.21.AND.pyr(0).GT.0.5d0) THEN
42995  kflsp=kfl(2)
42996  kflch=kfl(3)
42997  ELSEIF(kflr.EQ.21) THEN
42998  kflsp=kfl(3)
42999  kflch=kfl(2)
43000  ELSEIF(kflr*kfl(2).GT.0) THEN
43001  ntry=0
43002  100 ntry=ntry+1
43003  CALL pykfdi(-kflr,kfl(2),kfdump,kflch)
43004  IF(kflch.EQ.0.AND.ntry.LT.100) THEN
43005  goto 100
43006  ELSEIF(kflch.EQ.0) THEN
43007  CALL pyerrm(14,'(PYSPLI:) caught in infinite loop')
43008  mint(51)=1
43009  RETURN
43010  ENDIF
43011  kflsp=kfl(3)
43012  ELSE
43013  ntry=0
43014  110 ntry=ntry+1
43015  CALL pykfdi(-kflr,kfl(3),kfdump,kflch)
43016  IF(kflch.EQ.0.AND.ntry.LT.100) THEN
43017  goto 110
43018  ELSEIF(kflch.EQ.0) THEN
43019  CALL pyerrm(14,'(PYSPLI:) caught in infinite loop')
43020  mint(51)=1
43021  RETURN
43022  ENDIF
43023  kflsp=kfl(2)
43024  ENDIF
43025 
43026 C...Special case for extracting photon from baryon without splitting
43027 C...the latter. (Currently only used by external programs.)
43028  ELSEIF(kflin.EQ.22.AND.mstp(98).EQ.1) then
43029  kflsp=kfa
43030  kflch=0
43031 
43032 C...Subdivide baryon.
43033  ELSE
43034  nagr=0
43035  DO 120 j=1,3
43036  IF(kflr.EQ.kfl(j)) nagr=nagr+1
43037  120 CONTINUE
43038  IF(nagr.GE.1) THEN
43039  ragr=0.00001d0+(nagr-0.00002d0)*pyr(0)
43040  iagr=0
43041  DO 130 j=1,3
43042  IF(kflr.EQ.kfl(j)) ragr=ragr-1d0
43043  IF(iagr.EQ.0.AND.ragr.LE.0d0) iagr=j
43044  130 CONTINUE
43045  ELSE
43046  iagr=1.00001d0+2.99998d0*pyr(0)
43047  ENDIF
43048  id1=1
43049  IF(iagr.EQ.1) id1=2
43050  IF(iagr.EQ.1.AND.kfl(3).GT.kfl(2)) id1=3
43051  id2=6-iagr-id1
43052  ksp=3
43053  IF(mod(kfa,10).EQ.2.AND.kfl(1).EQ.kfl(2)) THEN
43054  IF(iagr.NE.3.AND.pyr(0).GT.0.25d0) ksp=1
43055  ELSEIF(mod(kfa,10).EQ.2.AND.kfl(2).GE.kfl(3)) THEN
43056  IF(iagr.NE.1.AND.pyr(0).GT.0.25d0) ksp=1
43057  ELSEIF(mod(kfa,10).EQ.2) THEN
43058  IF(iagr.EQ.1) ksp=1
43059  IF(iagr.NE.1.AND.pyr(0).GT.0.75d0) ksp=1
43060  ENDIF
43061  kflsp=1000*kfl(id1)+100*kfl(id2)+ksp
43062  IF(kflr.EQ.21) THEN
43063  kflch=kfl(iagr)
43064  ELSEIF(nagr.EQ.0.AND.kflr.GT.0) THEN
43065  ntry=0
43066  140 ntry=ntry+1
43067  CALL pykfdi(-kflr,kfl(iagr),kfdump,kflch)
43068  IF(kflch.EQ.0.AND.ntry.LT.100) THEN
43069  goto 140
43070  ELSEIF(kflch.EQ.0) THEN
43071  CALL pyerrm(14,'(PYSPLI:) caught in infinite loop')
43072  mint(51)=1
43073  RETURN
43074  ENDIF
43075  ELSEIF(nagr.EQ.0) THEN
43076  ntry=0
43077  150 ntry=ntry+1
43078  CALL pykfdi(10000*kfl(id1)+kflsp,-kflr,kfdump,kflch)
43079  IF(kflch.EQ.0.AND.ntry.LT.100) THEN
43080  goto 150
43081  ELSEIF(kflch.EQ.0) THEN
43082  CALL pyerrm(14,'(PYSPLI:) caught in infinite loop')
43083  mint(51)=1
43084  RETURN
43085  ENDIF
43086  kflsp=kfl(iagr)
43087  ENDIF
43088  ENDIF
43089 
43090 C...Add on correct sign for result.
43091  kflch=kflch*kfs
43092  kflsp=kflsp*kfs
43093 
43094  RETURN
43095  END
43096 
43097 C*********************************************************************
43098 
43099 C...PYGAMM
43100 C...Gives ordinary Gamma function Gamma(x) for positive, real arguments;
43101 C...see M. Abramowitz, I. A. Stegun: Handbook of Mathematical Functions
43102 C...(Dover, 1965) 6.1.36.
43103 
43104  FUNCTION pygamm(X)
43105 
43106 C...Double precision and integer declarations.
43107  IMPLICIT DOUBLE PRECISION(a-h, o-z)
43108  IMPLICIT INTEGER(i-n)
43109  INTEGER pyk,pychge,pycomp
43110 C...Local array and data.
43111  dimension b(8)
43112  DATA b/-0.577191652d0,0.988205891d0,-0.897056937d0,0.918206857d0,
43113  &-0.756704078d0,0.482199394d0,-0.193527818d0,0.035868343d0/
43114 
43115  nx=int(x)
43116  dx=x-nx
43117 
43118  pygamm=1d0
43119  dxp=1d0
43120  DO 100 i=1,8
43121  dxp=dxp*dx
43122  pygamm=pygamm+b(i)*dxp
43123  100 CONTINUE
43124  IF(x.LT.1d0) THEN
43125  pygamm=pygamm/x
43126  ELSE
43127  DO 110 ix=1,nx-1
43128  pygamm=(x-ix)*pygamm
43129  110 CONTINUE
43130  ENDIF
43131 
43132  RETURN
43133  END
43134 
43135 C***********************************************************************
43136 
43137 C...PYWAUX
43138 C...Calculates real and imaginary parts of the auxiliary functions W1
43139 C...and W2; see R. K. Ellis, I. Hinchliffe, M. Soldate and J. J. van
43140 C...der Bij, Nucl. Phys. B297 (1988) 221.
43141 
43142  SUBROUTINE pywaux(IAUX,EPS,WRE,WIM)
43143 
43144 C...Double precision and integer declarations.
43145  IMPLICIT DOUBLE PRECISION(a-h, o-z)
43146  IMPLICIT INTEGER(i-n)
43147  INTEGER pyk,pychge,pycomp
43148 C...Commonblocks.
43149  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
43150  SAVE /pydat1/
43151 
43152  asinh(x)=log(x+sqrt(x**2+1d0))
43153  acosh(x)=log(x+sqrt(x**2-1d0))
43154 
43155  IF(eps.LT.0d0) THEN
43156  IF(iaux.EQ.1) wre=2d0*sqrt(1d0-eps)*asinh(sqrt(-1d0/eps))
43157  IF(iaux.EQ.2) wre=4d0*(asinh(sqrt(-1d0/eps)))**2
43158  wim=0d0
43159  ELSEIF(eps.LT.1d0) THEN
43160  IF(iaux.EQ.1) wre=2d0*sqrt(1d0-eps)*acosh(sqrt(1d0/eps))
43161  IF(iaux.EQ.2) wre=4d0*(acosh(sqrt(1d0/eps)))**2-paru(1)**2
43162  IF(iaux.EQ.1) wim=-paru(1)*sqrt(1d0-eps)
43163  IF(iaux.EQ.2) wim=-4d0*paru(1)*acosh(sqrt(1d0/eps))
43164  ELSE
43165  IF(iaux.EQ.1) wre=2d0*sqrt(eps-1d0)*asin(sqrt(1d0/eps))
43166  IF(iaux.EQ.2) wre=-4d0*(asin(sqrt(1d0/eps)))**2
43167  wim=0d0
43168  ENDIF
43169 
43170  RETURN
43171  END
43172 
43173 C***********************************************************************
43174 
43175 C...PYI3AU
43176 C...Calculates real and imaginary parts of the auxiliary function I3;
43177 C...see R. K. Ellis, I. Hinchliffe, M. Soldate and J. J. van der Bij,
43178 C...Nucl. Phys. B297 (1988) 221.
43179 
43180  SUBROUTINE pyi3au(EPS,RAT,Y3RE,Y3IM)
43181 
43182 C...Double precision and integer declarations.
43183  IMPLICIT DOUBLE PRECISION(a-h, o-z)
43184  IMPLICIT INTEGER(i-n)
43185  INTEGER pyk,pychge,pycomp
43186 C...Commonblocks.
43187  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
43188  SAVE /pydat1/
43189 
43190  be=0.5d0*(1d0+sqrt(1d0+rat*eps))
43191  IF(eps.LT.1d0) ga=0.5d0*(1d0+sqrt(1d0-eps))
43192 
43193  IF(eps.LT.0d0) THEN
43194  IF(abs(eps).LT.1d-4.AND.abs(rat*eps).LT.1d-4) THEN
43195  f3re=pyspen(-0.25d0*eps/(1d0+0.25d0*(rat-1d0)*eps),0d0,1)-
43196  & pyspen((1d0-0.25d0*eps)/(1d0+0.25d0*(rat-1d0)*eps),0d0,1)+
43197  & pyspen(0.25d0*(rat+1d0)*eps/(1d0+0.25d0*rat*eps),0d0,1)-
43198  & pyspen((rat+1d0)/rat,0d0,1)+0.5d0*(log(1d0+0.25d0*rat*eps)**2-
43199  & log(0.25d0*rat*eps)**2)+log(1d0-0.25d0*eps)*
43200  & log((1d0+0.25d0*(rat-1d0)*eps)/(1d0+0.25d0*rat*eps))+
43201  & log(-0.25d0*eps)*log(0.25d0*rat*eps/(1d0+0.25d0*(rat-1d0)*
43202  & eps))
43203  ELSEIF(abs(eps).LT.1d-4.AND.abs(rat*eps).GE.1d-4) THEN
43204  f3re=pyspen(-0.25d0*eps/(be-0.25d0*eps),0d0,1)-
43205  & pyspen((1d0-0.25d0*eps)/(be-0.25d0*eps),0d0,1)+
43206  & pyspen((be-1d0+0.25d0*eps)/be,0d0,1)-
43207  & pyspen((be-1d0+0.25d0*eps)/(be-1d0),0d0,1)+
43208  & 0.5d0*(log(be)**2-log(be-1d0)**2)+
43209  & log(1d0-0.25d0*eps)*log((be-0.25d0*eps)/be)+
43210  & log(-0.25d0*eps)*log((be-1d0)/(be-0.25d0*eps))
43211  ELSEIF(abs(eps).GE.1d-4.AND.abs(rat*eps).LT.1d-4) THEN
43212  f3re=pyspen((ga-1d0)/(ga+0.25d0*rat*eps),0d0,1)-
43213  & pyspen(ga/(ga+0.25d0*rat*eps),0d0,1)+
43214  & pyspen((1d0+0.25d0*rat*eps-ga)/(1d0+0.25d0*rat*eps),0d0,1)-
43215  & pyspen((1d0+0.25d0*rat*eps-ga)/(0.25d0*rat*eps),0d0,1)+
43216  & 0.5d0*(log(1d0+0.25d0*rat*eps)**2-log(0.25d0*rat*eps)**2)+
43217  & log(ga)*log((ga+0.25d0*rat*eps)/(1d0+0.25d0*rat*eps))+
43218  & log(ga-1d0)*log(0.25d0*rat*eps/(ga+0.25d0*rat*eps))
43219  ELSE
43220  f3re=pyspen((ga-1d0)/(ga+be-1d0),0d0,1)-
43221  & pyspen(ga/(ga+be-1d0),0d0,1)+pyspen((be-ga)/be,0d0,1)-
43222  & pyspen((be-ga)/(be-1d0),0d0,1)+0.5d0*(log(be)**2-
43223  & log(be-1d0)**2)+log(ga)*log((ga+be-1d0)/be)+
43224  & log(ga-1d0)*log((be-1d0)/(ga+be-1d0))
43225  ENDIF
43226  f3im=0d0
43227  ELSEIF(eps.LT.1d0) THEN
43228  IF(abs(eps).LT.1d-4.AND.abs(rat*eps).LT.1d-4) THEN
43229  f3re=pyspen(-0.25d0*eps/(1d0+0.25d0*(rat-1d0)*eps),0d0,1)-
43230  & pyspen((1d0-0.25d0*eps)/(1d0+0.25d0*(rat-1d0)*eps),0d0,1)+
43231  & pyspen((1d0-0.25d0*eps)/(-0.25d0*(rat+1d0)*eps),0d0,1)-
43232  & pyspen(1d0/(rat+1d0),0d0,1)+log((1d0-0.25d0*eps)/
43233  & (0.25d0*eps))*log((1d0+0.25d0*(rat-1d0)*eps)/
43234  & (0.25d0*(rat+1d0)*eps))
43235  f3im=-paru(1)*log((1d0+0.25d0*(rat-1d0)*eps)/
43236  & (0.25d0*(rat+1d0)*eps))
43237  ELSEIF(abs(eps).LT.1d-4.AND.abs(rat*eps).GE.1d-4) THEN
43238  f3re=pyspen(-0.25d0*eps/(be-0.25d0*eps),0d0,1)-
43239  & pyspen((1d0-0.25d0*eps)/(be-0.25d0*eps),0d0,1)+
43240  & pyspen((1d0-0.25d0*eps)/(1d0-0.25d0*eps-be),0d0,1)-
43241  & pyspen(-0.25d0*eps/(1d0-0.25d0*eps-be),0d0,1)+
43242  & log((1d0-0.25d0*eps)/(0.25d0*eps))*
43243  & log((be-0.25d0*eps)/(be-1d0+0.25d0*eps))
43244  f3im=-paru(1)*log((be-0.25d0*eps)/(be-1d0+0.25d0*eps))
43245  ELSEIF(abs(eps).GE.1d-4.AND.abs(rat*eps).LT.1d-4) THEN
43246  f3re=pyspen((ga-1d0)/(ga+0.25d0*rat*eps),0d0,1)-
43247  & pyspen(ga/(ga+0.25d0*rat*eps),0d0,1)+
43248  & pyspen(ga/(ga-1d0-0.25d0*rat*eps),0d0,1)-
43249  & pyspen((ga-1d0)/(ga-1d0-0.25d0*rat*eps),0d0,1)+
43250  & log(ga/(1d0-ga))*log((ga+0.25d0*rat*eps)/
43251  & (1d0+0.25d0*rat*eps-ga))
43252  f3im=-paru(1)*log((ga+0.25d0*rat*eps)/
43253  & (1d0+0.25d0*rat*eps-ga))
43254  ELSE
43255  f3re=pyspen((ga-1d0)/(ga+be-1d0),0d0,1)-
43256  & pyspen(ga/(ga+be-1d0),0d0,1)+pyspen(ga/(ga-be),0d0,1)-
43257  & pyspen((ga-1d0)/(ga-be),0d0,1)+log(ga/(1d0-ga))*
43258  & log((ga+be-1d0)/(be-ga))
43259  f3im=-paru(1)*log((ga+be-1d0)/(be-ga))
43260  ENDIF
43261  ELSE
43262  rsq=eps/(eps-1d0+(2d0*be-1d0)**2)
43263  rcthe=rsq*(1d0-2d0*be/eps)
43264  rsthe=sqrt(max(0d0,rsq-rcthe**2))
43265  rcphi=rsq*(1d0+2d0*(be-1d0)/eps)
43266  rsphi=sqrt(max(0d0,rsq-rcphi**2))
43267  r=sqrt(rsq)
43268  the=acos(max(-0.999999d0,min(0.999999d0,rcthe/r)))
43269  phi=acos(max(-0.999999d0,min(0.999999d0,rcphi/r)))
43270  f3re=pyspen(rcthe,rsthe,1)+pyspen(rcthe,-rsthe,1)-
43271  & pyspen(rcphi,rsphi,1)-pyspen(rcphi,-rsphi,1)+
43272  & (phi-the)*(phi+the-paru(1))
43273  f3im=pyspen(rcthe,rsthe,2)+pyspen(rcthe,-rsthe,2)-
43274  & pyspen(rcphi,rsphi,2)-pyspen(rcphi,-rsphi,2)
43275  ENDIF
43276 
43277  y3re=2d0/(2d0*be-1d0)*f3re
43278  y3im=2d0/(2d0*be-1d0)*f3im
43279 
43280  RETURN
43281  END
43282 
43283 C***********************************************************************
43284 
43285 C...PYSPEN
43286 C...Calculates real and imaginary part of Spence function; see
43287 C...G. 't Hooft and M. Veltman, Nucl. Phys. B153 (1979) 365.
43288 
43289  FUNCTION pyspen(XREIN,XIMIN,IREIM)
43290 
43291 C...Double precision and integer declarations.
43292  IMPLICIT DOUBLE PRECISION(a-h, o-z)
43293  IMPLICIT INTEGER(i-n)
43294  INTEGER pyk,pychge,pycomp
43295 C...Commonblocks.
43296  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
43297  SAVE /pydat1/
43298 C...Local array and data.
43299  dimension b(0:14)
43300  DATA b/
43301  &1.000000d+00, -5.000000d-01, 1.666667d-01,
43302  &0.000000d+00, -3.333333d-02, 0.000000d+00,
43303  &2.380952d-02, 0.000000d+00, -3.333333d-02,
43304  &0.000000d+00, 7.575757d-02, 0.000000d+00,
43305  &-2.531135d-01, 0.000000d+00, 1.166667d+00/
43306 
43307  xre=xrein
43308  xim=ximin
43309  IF(abs(1d0-xre).LT.1d-6.AND.abs(xim).LT.1d-6) THEN
43310  IF(ireim.EQ.1) pyspen=paru(1)**2/6d0
43311  IF(ireim.EQ.2) pyspen=0d0
43312  RETURN
43313  ENDIF
43314 
43315  xmod=sqrt(xre**2+xim**2)
43316  IF(xmod.LT.1d-6) THEN
43317  IF(ireim.EQ.1) pyspen=0d0
43318  IF(ireim.EQ.2) pyspen=0d0
43319  RETURN
43320  ENDIF
43321 
43322  xarg=sign(acos(xre/xmod),xim)
43323  sp0re=0d0
43324  sp0im=0d0
43325  sgn=1d0
43326  IF(xmod.GT.1d0) THEN
43327  algxre=log(xmod)
43328  algxim=xarg-sign(paru(1),xarg)
43329  sp0re=-paru(1)**2/6d0-(algxre**2-algxim**2)/2d0
43330  sp0im=-algxre*algxim
43331  sgn=-1d0
43332  xmod=1d0/xmod
43333  xarg=-xarg
43334  xre=xmod*cos(xarg)
43335  xim=xmod*sin(xarg)
43336  ENDIF
43337  IF(xre.GT.0.5d0) THEN
43338  algxre=log(xmod)
43339  algxim=xarg
43340  xre=1d0-xre
43341  xim=-xim
43342  xmod=sqrt(xre**2+xim**2)
43343  xarg=sign(acos(xre/xmod),xim)
43344  algyre=log(xmod)
43345  algyim=xarg
43346  sp0re=sp0re+sgn*(paru(1)**2/6d0-(algxre*algyre-algxim*algyim))
43347  sp0im=sp0im-sgn*(algxre*algyim+algxim*algyre)
43348  sgn=-sgn
43349  ENDIF
43350 
43351  xre=1d0-xre
43352  xim=-xim
43353  xmod=sqrt(xre**2+xim**2)
43354  xarg=sign(acos(xre/xmod),xim)
43355  zre=-log(xmod)
43356  zim=-xarg
43357 
43358  spre=0d0
43359  spim=0d0
43360  savere=1d0
43361  saveim=0d0
43362  DO 100 i=0,14
43363  IF(max(abs(savere),abs(saveim)).LT.1d-30) goto 110
43364  termre=(savere*zre-saveim*zim)/dble(i+1)
43365  termim=(savere*zim+saveim*zre)/dble(i+1)
43366  savere=termre
43367  saveim=termim
43368  spre=spre+b(i)*termre
43369  spim=spim+b(i)*termim
43370  100 CONTINUE
43371 
43372  110 IF(ireim.EQ.1) pyspen=sp0re+sgn*spre
43373  IF(ireim.EQ.2) pyspen=sp0im+sgn*spim
43374 
43375  RETURN
43376  END
43377 
43378 C***********************************************************************
43379 
43380 C...PYQQBH
43381 C...Calculates the matrix element for the processes
43382 C...g + g or q + qbar -> Q + Qbar + H (normally with Q = t).
43383 C...REDUCE output and part of the rest courtesy Z. Kunszt, see
43384 C...Z. Kunszt, Nucl. Phys. B247 (1984) 339.
43385 
43386  SUBROUTINE pyqqbh(WTQQBH)
43387 
43388 C...Double precision and integer declarations.
43389  IMPLICIT DOUBLE PRECISION(a-h, o-z)
43390  IMPLICIT INTEGER(i-n)
43391  INTEGER pyk,pychge,pycomp
43392 C...Commonblocks.
43393  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
43394  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
43395  common/pypars/mstp(200),parp(200),msti(200),pari(200)
43396  common/pyint1/mint(400),vint(400)
43397  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
43398  SAVE /pydat1/,/pydat2/,/pypars/,/pyint1/,/pyint2/
43399 C...Local arrays and function.
43400  dimension pp(15,4),clr(8,8),fm(10,10),rm(8,8),dx(8)
43401  dot(i,j)=pp(i,4)*pp(j,4)-pp(i,1)*pp(j,1)-pp(i,2)*pp(j,2)-
43402  &pp(i,3)*pp(j,3)
43403 
43404 C...Mass parameters.
43405  wtqqbh=0d0
43406  isub=mint(1)
43407  shpr=sqrt(vint(26))*vint(1)
43408  pq=pmas(pycomp(kfpr(isub,2)),1)
43409  ph=sqrt(vint(21))*vint(1)
43410  spq=pq**2
43411  sph=ph**2
43412 
43413 C...Set up outgoing kinematics: 1=t, 2=tbar, 3=H.
43414  DO 100 i=1,2
43415  pt=sqrt(max(0d0,vint(197+5*i)))
43416  pp(i,1)=pt*cos(vint(198+5*i))
43417  pp(i,2)=pt*sin(vint(198+5*i))
43418  100 CONTINUE
43419  pp(3,1)=-pp(1,1)-pp(2,1)
43420  pp(3,2)=-pp(1,2)-pp(2,2)
43421  pms1=spq+pp(1,1)**2+pp(1,2)**2
43422  pms2=spq+pp(2,1)**2+pp(2,2)**2
43423  pms3=sph+pp(3,1)**2+pp(3,2)**2
43424  pmt3=sqrt(pms3)
43425  pp(3,3)=pmt3*sinh(vint(211))
43426  pp(3,4)=pmt3*cosh(vint(211))
43427  pms12=(shpr-pp(3,4))**2-pp(3,3)**2
43428  pp(1,3)=(-pp(3,3)*(pms12+pms1-pms2)+
43429  &vint(213)*(shpr-pp(3,4))*vint(220))/(2d0*pms12)
43430  pp(2,3)=-pp(1,3)-pp(3,3)
43431  pp(1,4)=sqrt(pms1+pp(1,3)**2)
43432  pp(2,4)=sqrt(pms2+pp(2,3)**2)
43433 
43434 C...Set up incoming kinematics and derived momentum combinations.
43435  DO 110 i=4,5
43436  pp(i,1)=0d0
43437  pp(i,2)=0d0
43438  pp(i,3)=-0.5d0*shpr*(-1)**i
43439  pp(i,4)=-0.5d0*shpr
43440  110 CONTINUE
43441  DO 120 j=1,4
43442  pp(6,j)=pp(1,j)+pp(2,j)
43443  pp(7,j)=pp(1,j)+pp(3,j)
43444  pp(8,j)=pp(1,j)+pp(4,j)
43445  pp(9,j)=pp(1,j)+pp(5,j)
43446  pp(10,j)=-pp(2,j)-pp(3,j)
43447  pp(11,j)=-pp(2,j)-pp(4,j)
43448  pp(12,j)=-pp(2,j)-pp(5,j)
43449  pp(13,j)=-pp(4,j)-pp(5,j)
43450  120 CONTINUE
43451 
43452 C...Derived kinematics invariants.
43453  x1=dot(1,2)
43454  x2=dot(1,3)
43455  x3=dot(1,4)
43456  x4=dot(1,5)
43457  x5=dot(2,3)
43458  x6=dot(2,4)
43459  x7=dot(2,5)
43460  x8=dot(3,4)
43461  x9=dot(3,5)
43462  x10=dot(4,5)
43463 
43464 C...Propagators.
43465  ss1=dot(7,7)-spq
43466  ss2=dot(8,8)-spq
43467  ss3=dot(9,9)-spq
43468  ss4=dot(10,10)-spq
43469  ss5=dot(11,11)-spq
43470  ss6=dot(12,12)-spq
43471  ss7=dot(13,13)
43472  dx(1)=ss1*ss6
43473  dx(2)=ss2*ss6
43474  dx(3)=ss2*ss4
43475  dx(4)=ss1*ss5
43476  dx(5)=ss3*ss5
43477  dx(6)=ss3*ss4
43478  dx(7)=ss7*ss1
43479  dx(8)=ss7*ss4
43480 
43481 C...Define colour coefficients for g + g -> Q + Qbar + H.
43482  IF(isub.EQ.121.OR.isub.EQ.181.OR.isub.EQ.186) THEN
43483  DO 140 i=1,3
43484  DO 130 j=1,3
43485  clr(i,j)=16d0/3d0
43486  clr(i+3,j+3)=16d0/3d0
43487  clr(i,j+3)=-2d0/3d0
43488  clr(i+3,j)=-2d0/3d0
43489  130 CONTINUE
43490  140 CONTINUE
43491  DO 160 l=1,2
43492  DO 150 i=1,3
43493  clr(i,6+l)=-6d0
43494  clr(i+3,6+l)=6d0
43495  clr(6+l,i)=-6d0
43496  clr(6+l,i+3)=6d0
43497  150 CONTINUE
43498  160 CONTINUE
43499  DO 180 k1=1,2
43500  DO 170 k2=1,2
43501  clr(6+k1,6+k2)=12d0
43502  170 CONTINUE
43503  180 CONTINUE
43504 
43505 C...Evaluate matrix elements for g + g -> Q + Qbar + H.
43506  fm(1,1)=64*pq**6+16*pq**4*ph**2+32*pq**4*(x1+2*x2+x4+x9+2*
43507  & x7+x5)+8*pq**2*ph**2*(-x1-x4+2*x7)+16*pq**2*(x2*x9+4*x2*
43508  & x7+x2*x5-2*x4*x7-2*x9*x7)+8*ph**2*x4*x7-16*x2*x9*x7
43509  fm(1,2)=16*pq**6+8*pq**4*(-2*x1+x2-2*x3-2*x4-4*x10+x9-x8+2
43510  & *x7-4*x6+x5)+8*pq**2*(-2*x1*x2-2*x2*x4-2*x2*x10+x2*x7-2*
43511  & x2*x6-2*x3*x7+2*x4*x7+4*x10*x7-x9*x7-x8*x7)+16*x2*x7*(x4+
43512  & x10)
43513  fm(1,3)=16*pq**6-4*pq**4*ph**2+8*pq**4*(-2*x1+2*x2-2*x3-4*
43514  & x4-8*x10+x9+x8-2*x7-4*x6+2*x5)-(4*pq**2*ph**2)*(x1+x4+x10
43515  & +x6)+8*pq**2*(-2*x1*x2-2*x1*x10+x1*x9+x1*x8-2*x1*x5+x2**2
43516  & -4*x2*x4-5*x2*x10+x2*x8-x2*x7-3*x2*x6+x2*x5+x3*x9+2*x3*x7
43517  & -x3*x5+x4*x8+2*x4*x6-3*x4*x5-5*x10*x5+x9*x8+x9*x6+x9*x5+
43518  & x8*x7-4*x6*x5+x5**2)-(16*x2*x5)*(x1+x4+x10+x6)
43519  fm(1,4)=16*pq**6+4*pq**4*ph**2+16*pq**4*(-x1+x2-x3-x4+x10-
43520  & x9-x8+2*x7+2*x6-x5)+4*pq**2*ph**2*(x1+x3+x4+x10+2*x7+2*x6
43521  & )+8*pq**2*(4*x1*x10+4*x1*x7+4*x1*x6+2*x2*x10-x2*x9-x2*x8+
43522  & 4*x2*x7+4*x2*x6-x2*x5+4*x10*x5+4*x7*x5+4*x6*x5)-(8*ph**2*
43523  & x1)*(x10+x7+x6)+16*x2*x5*(x10+x7+x6)
43524  fm(1,5)=8*pq**4*(-2*x1-2*x4+x10-x9)+4*pq**2*(4*x1**2-2*x1*
43525  & x2+8*x1*x3+6*x1*x10-2*x1*x9+4*x1*x8+4*x1*x7+4*x1*x6+2*x1*
43526  & x5+x2*x10+4*x3*x4-x3*x9+2*x3*x7+3*x4*x8-2*x4*x6+2*x4*x5-4
43527  & *x10*x7+3*x10*x5-3*x9*x6+3*x8*x7-4*x7**2+4*x7*x5)+8*(x1**
43528  & 2*x9-x1**2*x8-x1*x2*x7+x1*x2*x6+x1*x3*x9+x1*x3*x5-x1*x4*
43529  & x8-x1*x4*x5+x1*x10*x9+x1*x9*x7+x1*x9*x6-x1*x8*x7-x2*x3*x7
43530  & +x2*x4*x6-x2*x10*x7-x2*x7**2+x3*x7*x5-x4*x10*x5-x4*x7*x5-
43531  & x4*x6*x5)
43532  fm(1,6)=16*pq**4*(-4*x1-x4+x9-x7)+4*pq**2*ph**2*(-2*x1-x4-
43533  & x7)+16*pq**2*(-2*x1**2-3*x1*x2-2*x1*x4-3*x1*x9-2*x1*x7-3*
43534  & x1*x5-2*x2*x4-2*x7*x5)-8*ph**2*x4*x7+8*(-x1*x2*x9-2*x1*x2
43535  & *x5-x1*x9**2-x1*x9*x5+x2**2*x7-x2*x4*x5+x2*x9*x7-x2*x7*x5
43536  & +x4*x9*x5+x4*x5**2)
43537  fm(1,7)=8*pq**4*(2*x3+x4+3*x10+x9+2*x8+3*x7+6*x6)+2*pq**2*
43538  & ph**2*(-2*x3-x4+3*x10+3*x7+6*x6)+4*pq**2*(4*x1*x10+4*x1*
43539  & x7+8*x1*x6+6*x2*x10+x2*x9+2*x2*x8+6*x2*x7+12*x2*x6-8*x3*
43540  & x7+4*x4*x7+4*x4*x6+4*x10*x5+4*x9*x7+4*x9*x6-8*x8*x7+4*x7*
43541  & x5+8*x6*x5)+4*ph**2*(-x1*x10-x1*x7-2*x1*x6+2*x3*x7-x4*x7-
43542  & x4*x6)+8*x2*(x10*x5+x9*x7+x9*x6-2*x8*x7+x7*x5+2*x6*x5)
43543  fm(1,8)=8*pq**4*(2*x3+x4+3*x10+2*x9+x8+3*x7+6*x6)+2*pq**2*
43544  & ph**2*(-2*x3-x4+2*x10+x7+2*x6)+4*pq**2*(4*x1*x10-2*x1*x9+
43545  & 2*x1*x8+4*x1*x7+8*x1*x6+5*x2*x10+2*x2*x9+x2*x8+4*x2*x7+8*
43546  & x2*x6-x3*x9-8*x3*x7+2*x3*x5+2*x4*x9-x4*x8+4*x4*x7+4*x4*x6
43547  & +4*x4*x5+5*x10*x5+x9**2-x9*x8+2*x9*x7+5*x9*x6+x9*x5-7*x8*
43548  & x7+2*x8*x5+2*x7*x5+10*x6*x5)+2*ph**2*(-x1*x10+x3*x7-2*x4*
43549  & x7+x4*x6)+4*(-x1*x9**2+x1*x9*x8-2*x1*x9*x5-x1*x8*x5+2*x2*
43550  & x10*x5+x2*x9*x7+x2*x9*x6-2*x2*x8*x7+3*x2*x6*x5+x3*x9*x5+
43551  & x3*x5**2+x4*x9*x5-2*x4*x8*x5+2*x4*x5**2)
43552  fm(2,2)=16*pq**6+16*pq**4*(-x1+x3-x4-x10+x7-x6)+16*pq**2*(
43553  & x3*x10+x3*x7+x3*x6+x4*x7+x10*x7)-16*x3*x10*x7
43554  fm(2,3)=16*pq**6+8*pq**4*(-2*x1+x2+2*x3-4*x4-4*x10-x9+x8-2
43555  & *x7-2*x6+x5)+8*pq**2*(-2*x1*x5+4*x3*x10-x3*x9-x3*x8-2*x3*
43556  & x7+2*x3*x6+x3*x5-2*x4*x5-2*x10*x5-2*x6*x5)+16*x3*x5*(x10+
43557  & x6)
43558  fm(2,4)=8*pq**4*(-2*x1-2*x3+x10-x8)+4*pq**2*(4*x1**2-2*x1*
43559  & x2+8*x1*x4+6*x1*x10+4*x1*x9-2*x1*x8+4*x1*x7+4*x1*x6+2*x1*
43560  & x5+x2*x10+4*x3*x4+3*x3*x9-2*x3*x7+2*x3*x5-x4*x8+2*x4*x6-4
43561  & *x10*x6+3*x10*x5+3*x9*x6-3*x8*x7-4*x6**2+4*x6*x5)+8*(-x1
43562  & **2*x9+x1**2*x8+x1*x2*x7-x1*x2*x6-x1*x3*x9-x1*x3*x5+x1*x4
43563  & *x8+x1*x4*x5+x1*x10*x8-x1*x9*x6+x1*x8*x7+x1*x8*x6+x2*x3*
43564  & x7-x2*x4*x6-x2*x10*x6-x2*x6**2-x3*x10*x5-x3*x7*x5-x3*x6*
43565  & x5+x4*x6*x5)
43566  fm(2,5)=16*pq**4*x10+8*pq**2*(2*x1**2+2*x1*x3+2*x1*x4+2*x1
43567  & *x10+2*x1*x7+2*x1*x6+x3*x7+x4*x6)+8*(-2*x1**3-2*x1**2*x3-
43568  & 2*x1**2*x4-2*x1**2*x10-2*x1**2*x7-2*x1**2*x6-2*x1*x3*x4-
43569  & x1*x3*x10-2*x1*x3*x6-x1*x4*x10-2*x1*x4*x7-x1*x10**2-x1*
43570  & x10*x7-x1*x10*x6-2*x1*x7*x6+x3**2*x7-x3*x4*x7-x3*x4*x6+x3
43571  & *x10*x7+x3*x7**2-x3*x7*x6+x4**2*x6+x4*x10*x6-x4*x7*x6+x4*
43572  & x6**2)
43573  fm(2,6)=8*pq**4*(-2*x1+x10-x9-2*x7)+4*pq**2*(4*x1**2+2*x1*
43574  & x2+4*x1*x3+4*x1*x4+6*x1*x10-2*x1*x9+4*x1*x8+8*x1*x6-2*x1*
43575  & x5+4*x2*x4+3*x2*x10+2*x2*x7-3*x3*x9-2*x3*x7-4*x4**2-4*x4*
43576  & x10+3*x4*x8+2*x4*x6+x10*x5-x9*x6+3*x8*x7+4*x7*x6)+8*(x1**
43577  & 2*x9-x1**2*x8-x1*x2*x7+x1*x2*x6+x1*x3*x9+x1*x3*x5+x1*x4*
43578  & x9-x1*x4*x8-x1*x4*x5+x1*x10*x9+x1*x9*x6-x1*x8*x7-x2*x3*x7
43579  & -x2*x4*x7+x2*x4*x6-x2*x10*x7+x3*x7*x5-x4**2*x5-x4*x10*x5-
43580  & x4*x6*x5)
43581  fm(2,7)=8*pq**4*(x3+2*x4+3*x10+x7+2*x6)+4*pq**2*(-4*x1*x3-
43582  & 2*x1*x4-2*x1*x10+x1*x9-x1*x8-4*x1*x7-2*x1*x6+x2*x3+2*x2*
43583  & x4+3*x2*x10+x2*x7+2*x2*x6-6*x3*x4-6*x3*x10-2*x3*x9-2*x3*
43584  & x7-4*x3*x6-x3*x5-6*x4**2-6*x4*x10-3*x4*x9-x4*x8-4*x4*x7-2
43585  & *x4*x6-2*x4*x5-3*x10*x9-3*x10*x8-6*x10*x7-6*x10*x6+x10*x5
43586  & +x9*x7-2*x8*x7-2*x8*x6-6*x7*x6+x7*x5-6*x6**2+2*x6*x5)+4*(
43587  & -x1**2*x9+x1**2*x8-2*x1*x2*x10-3*x1*x2*x7-3*x1*x2*x6+x1*
43588  & x3*x9-x1*x3*x5+x1*x4*x9+x1*x4*x8+x1*x4*x5+x1*x10*x9+x1*
43589  & x10*x8-x1*x9*x6+x1*x8*x6+x2*x3*x7-3*x2*x4*x7-x2*x4*x6-3*
43590  & x2*x10*x7-3*x2*x10*x6-3*x2*x7*x6-3*x2*x6**2-2*x3*x4*x5-x3
43591  & *x10*x5-x3*x6*x5-x4**2*x5-x4*x10*x5+x4*x6*x5)
43592  fm(2,8)=8*pq**4*(x3+2*x4+3*x10+x7+2*x6)+4*pq**2*(-4*x1*x3-
43593  & 2*x1*x4-2*x1*x10-x1*x9+x1*x8-4*x1*x7-2*x1*x6+x2*x3+2*x2*
43594  & x4+x2*x10-x2*x7-2*x2*x6-6*x3*x4-6*x3*x10-2*x3*x9+x3*x8-2*
43595  & x3*x7-4*x3*x6+x3*x5-6*x4**2-6*x4*x10-2*x4*x9-4*x4*x7-2*x4
43596  & *x6+2*x4*x5-3*x10*x9-3*x10*x8-6*x10*x7-6*x10*x6+3*x10*x5-
43597  & x9*x6-2*x8*x7-3*x8*x6-6*x7*x6+x7*x5-6*x6**2+2*x6*x5)+4*(
43598  & x1**2*x9-x1**2*x8-x1*x2*x7+x1*x2*x6-3*x1*x3*x5+x1*x4*x9-
43599  & x1*x4*x8-3*x1*x4*x5+x1*x10*x9+x1*x10*x8-2*x1*x10*x5+x1*x9
43600  & *x6+x1*x8*x7+x1*x8*x6-x2*x4*x7+x2*x4*x6-x2*x10*x7-x2*x10*
43601  & x6-2*x2*x7*x6-x2*x6**2-3*x3*x4*x5-3*x3*x10*x5+x3*x7*x5-3*
43602  & x3*x6*x5-3*x4**2*x5-3*x4*x10*x5-x4*x6*x5)
43603  fm(3,3)=64*pq**6+16*pq**4*ph**2+32*pq**4*(x1+x2+2*x3+x8+x6
43604  & +2*x5)+8*pq**2*ph**2*(-x1+2*x3-x6)+16*pq**2*(x2*x5-2*x3*
43605  & x8-2*x3*x6+4*x3*x5+x8*x5)+8*ph**2*x3*x6-16*x3*x8*x5
43606  fm(3,4)=16*pq**4*(-4*x1-x3+x8-x6)+4*pq**2*ph**2*(-2*x1-x3-
43607  & x6)+16*pq**2*(-2*x1**2-3*x1*x2-2*x1*x3-3*x1*x8-2*x1*x6-3*
43608  & x1*x5-2*x2*x3-2*x6*x5)-8*ph**2*x3*x6+8*(-x1*x2*x8-2*x1*x2
43609  & *x5-x1*x8**2-x1*x8*x5+x2**2*x6-x2*x3*x5+x2*x8*x6-x2*x6*x5
43610  & +x3*x8*x5+x3*x5**2)
43611  fm(3,5)=8*pq**4*(-2*x1+x10-x8-2*x6)+4*pq**2*(4*x1**2+2*x1*
43612  & x2+4*x1*x3+4*x1*x4+6*x1*x10+4*x1*x9-2*x1*x8+8*x1*x7-2*x1*
43613  & x5+4*x2*x3+3*x2*x10+2*x2*x6-4*x3**2-4*x3*x10+3*x3*x9+2*x3
43614  & *x7-3*x4*x8-2*x4*x6+x10*x5+3*x9*x6-x8*x7+4*x7*x6)+8*(-x1
43615  & **2*x9+x1**2*x8+x1*x2*x7-x1*x2*x6-x1*x3*x9+x1*x3*x8-x1*x3
43616  & *x5+x1*x4*x8+x1*x4*x5+x1*x10*x8-x1*x9*x6+x1*x8*x7+x2*x3*
43617  & x7-x2*x3*x6-x2*x4*x6-x2*x10*x6-x3**2*x5-x3*x10*x5-x3*x7*
43618  & x5+x4*x6*x5)
43619  fm(3,6)=16*pq**6+4*pq**4*ph**2+16*pq**4*(-x1-x2+2*x3+2*x4+
43620  & x10-x9-x8-x7-x6+x5)+4*pq**2*ph**2*(x1+2*x3+2*x4+x10+x7+x6
43621  & )+8*pq**2*(4*x1*x3+4*x1*x4+4*x1*x10+4*x2*x3+4*x2*x4+4*x2*
43622  & x10-x2*x5+4*x3*x5+4*x4*x5+2*x10*x5-x9*x5-x8*x5)-(8*ph**2*
43623  & x1)*(x3+x4+x10)+16*x2*x5*(x3+x4+x10)
43624  fm(3,7)=8*pq**4*(3*x3+6*x4+3*x10+x9+2*x8+2*x7+x6)+2*pq**2*
43625  & ph**2*(x3+2*x4+2*x10-2*x7-x6)+4*pq**2*(4*x1*x3+8*x1*x4+4*
43626  & x1*x10+2*x1*x9-2*x1*x8+2*x2*x3+10*x2*x4+5*x2*x10+2*x2*x9+
43627  & x2*x8+2*x2*x7+4*x2*x6-7*x3*x9+2*x3*x8-8*x3*x7+4*x3*x6+4*
43628  & x3*x5+5*x4*x8+4*x4*x6+8*x4*x5+5*x10*x5-x9*x8-x9*x6+x9*x5+
43629  & x8**2-x8*x7+2*x8*x6+2*x8*x5)+2*ph**2*(-x1*x10+x3*x7-2*x3*
43630  & x6+x4*x6)+4*(-x1*x2*x9-2*x1*x2*x8+x1*x9*x8-x1*x8**2+x2**2
43631  & *x7+2*x2**2*x6+3*x2*x4*x5+2*x2*x10*x5-2*x2*x9*x6+x2*x8*x7
43632  & +x2*x8*x6-2*x3*x9*x5+x3*x8*x5+x4*x8*x5)
43633  fm(3,8)=8*pq**4*(3*x3+6*x4+3*x10+2*x9+x8+2*x7+x6)+2*pq**2*
43634  & ph**2*(3*x3+6*x4+3*x10-2*x7-x6)+4*pq**2*(4*x1*x3+8*x1*x4+
43635  & 4*x1*x10+4*x2*x3+8*x2*x4+4*x2*x10-8*x3*x9+4*x3*x8-8*x3*x7
43636  & +4*x3*x6+6*x3*x5+4*x4*x8+4*x4*x6+12*x4*x5+6*x10*x5+2*x9*
43637  & x5+x8*x5)+4*ph**2*(-x1*x3-2*x1*x4-x1*x10+2*x3*x7-x3*x6-x4
43638  & *x6)+8*x5*(x2*x3+2*x2*x4+x2*x10-2*x3*x9+x3*x8+x4*x8)
43639  fm(4,4)=64*pq**6+16*pq**4*ph**2+32*pq**4*(x1+2*x2+x3+x8+2*
43640  & x6+x5)+8*pq**2*ph**2*(-x1-x3+2*x6)+16*pq**2*(x2*x8+4*x2*
43641  & x6+x2*x5-2*x3*x6-2*x8*x6)+8*ph**2*x3*x6-16*x2*x8*x6
43642  fm(4,5)=16*pq**6+8*pq**4*(-2*x1+x2-2*x3-2*x4-4*x10-x9+x8-4
43643  & *x7+2*x6+x5)+8*pq**2*(-2*x1*x2-2*x2*x3-2*x2*x10-2*x2*x7+
43644  & x2*x6+2*x3*x6-2*x4*x6+4*x10*x6-x9*x6-x8*x6)+16*x2*x6*(x3+
43645  & x10)
43646  fm(4,6)=16*pq**6-4*pq**4*ph**2+8*pq**4*(-2*x1+2*x2-4*x3-2*
43647  & x4-8*x10+x9+x8-4*x7-2*x6+2*x5)-(4*pq**2*ph**2)*(x1+x3+x10
43648  & +x7)+8*pq**2*(-2*x1*x2-2*x1*x10+x1*x9+x1*x8-2*x1*x5+x2**2
43649  & -4*x2*x3-5*x2*x10+x2*x9-3*x2*x7-x2*x6+x2*x5+x3*x9+2*x3*x7
43650  & -3*x3*x5+x4*x8+2*x4*x6-x4*x5-5*x10*x5+x9*x8+x9*x6+x8*x7+
43651  & x8*x5-4*x7*x5+x5**2)-(16*x2*x5)*(x1+x3+x10+x7)
43652  fm(4,7)=8*pq**4*(-x3-2*x4-3*x10-2*x9-x8-6*x7-3*x6)+2*pq**2
43653  & *ph**2*(x3+2*x4-3*x10-6*x7-3*x6)+4*pq**2*(-4*x1*x10-8*x1*
43654  & x7-4*x1*x6-6*x2*x10-2*x2*x9-x2*x8-12*x2*x7-6*x2*x6-4*x3*
43655  & x7-4*x3*x6+8*x4*x6-4*x10*x5+8*x9*x6-4*x8*x7-4*x8*x6-8*x7*
43656  & x5-4*x6*x5)+4*ph**2*(x1*x10+2*x1*x7+x1*x6+x3*x7+x3*x6-2*
43657  & x4*x6)+8*x2*(-x10*x5+2*x9*x6-x8*x7-x8*x6-2*x7*x5-x6*x5)
43658  fm(4,8)=8*pq**4*(-x3-2*x4-3*x10-x9-2*x8-6*x7-3*x6)+2*pq**2
43659  & *ph**2*(x3+2*x4-2*x10-2*x7-x6)+4*pq**2*(-4*x1*x10-2*x1*x9
43660  & +2*x1*x8-8*x1*x7-4*x1*x6-5*x2*x10-x2*x9-2*x2*x8-8*x2*x7-4
43661  & *x2*x6+x3*x9-2*x3*x8-4*x3*x7-4*x3*x6-4*x3*x5+x4*x8+8*x4*
43662  & x6-2*x4*x5-5*x10*x5+x9*x8+7*x9*x6-2*x9*x5-x8**2-5*x8*x7-2
43663  & *x8*x6-x8*x5-10*x7*x5-2*x6*x5)+2*ph**2*(x1*x10-x3*x7+2*x3
43664  & *x6-x4*x6)+4*(-x1*x9*x8+x1*x9*x5+x1*x8**2+2*x1*x8*x5-2*x2
43665  & *x10*x5+2*x2*x9*x6-x2*x8*x7-x2*x8*x6-3*x2*x7*x5+2*x3*x9*
43666  & x5-x3*x8*x5-2*x3*x5**2-x4*x8*x5-x4*x5**2)
43667  fm(5,5)=16*pq**6+16*pq**4*(-x1-x3+x4-x10-x7+x6)+16*pq**2*(
43668  & x3*x6+x4*x10+x4*x7+x4*x6+x10*x6)-16*x4*x10*x6
43669  fm(5,6)=16*pq**6+8*pq**4*(-2*x1+x2-4*x3+2*x4-4*x10+x9-x8-2
43670  & *x7-2*x6+x5)+8*pq**2*(-2*x1*x5-2*x3*x5+4*x4*x10-x4*x9-x4*
43671  & x8+2*x4*x7-2*x4*x6+x4*x5-2*x10*x5-2*x7*x5)+16*x4*x5*(x10+
43672  & x7)
43673  fm(5,7)=8*pq**4*(-2*x3-x4-3*x10-2*x7-x6)+4*pq**2*(2*x1*x3+
43674  & 4*x1*x4+2*x1*x10+x1*x9-x1*x8+2*x1*x7+4*x1*x6-2*x2*x3-x2*
43675  & x4-3*x2*x10-2*x2*x7-x2*x6+6*x3**2+6*x3*x4+6*x3*x10+x3*x9+
43676  & 3*x3*x8+2*x3*x7+4*x3*x6+2*x3*x5+6*x4*x10+2*x4*x8+4*x4*x7+
43677  & 2*x4*x6+x4*x5+3*x10*x9+3*x10*x8+6*x10*x7+6*x10*x6-x10*x5+
43678  & 2*x9*x7+2*x9*x6-x8*x6+6*x7**2+6*x7*x6-2*x7*x5-x6*x5)+4*(-
43679  & x1**2*x9+x1**2*x8+2*x1*x2*x10+3*x1*x2*x7+3*x1*x2*x6-x1*x3
43680  & *x9-x1*x3*x8-x1*x3*x5-x1*x4*x8+x1*x4*x5-x1*x10*x9-x1*x10*
43681  & x8-x1*x9*x7+x1*x8*x7+x2*x3*x7+3*x2*x3*x6-x2*x4*x6+3*x2*
43682  & x10*x7+3*x2*x10*x6+3*x2*x7**2+3*x2*x7*x6+x3**2*x5+2*x3*x4
43683  & *x5+x3*x10*x5-x3*x7*x5+x4*x10*x5+x4*x7*x5)
43684  fm(5,8)=8*pq**4*(-2*x3-x4-3*x10-2*x7-x6)+4*pq**2*(2*x1*x3+
43685  & 4*x1*x4+2*x1*x10-x1*x9+x1*x8+2*x1*x7+4*x1*x6-2*x2*x3-x2*
43686  & x4-x2*x10+2*x2*x7+x2*x6+6*x3**2+6*x3*x4+6*x3*x10+2*x3*x8+
43687  & 2*x3*x7+4*x3*x6-2*x3*x5+6*x4*x10-x4*x9+2*x4*x8+4*x4*x7+2*
43688  & x4*x6-x4*x5+3*x10*x9+3*x10*x8+6*x10*x7+6*x10*x6-3*x10*x5+
43689  & 3*x9*x7+2*x9*x6+x8*x7+6*x7**2+6*x7*x6-2*x7*x5-x6*x5)+4*(
43690  & x1**2*x9-x1**2*x8-x1*x2*x7+x1*x2*x6+x1*x3*x9-x1*x3*x8+3*
43691  & x1*x3*x5+3*x1*x4*x5-x1*x10*x9-x1*x10*x8+2*x1*x10*x5-x1*x9
43692  & *x7-x1*x9*x6-x1*x8*x7-x2*x3*x7+x2*x3*x6+x2*x10*x7+x2*x10*
43693  & x6+x2*x7**2+2*x2*x7*x6+3*x3**2*x5+3*x3*x4*x5+3*x3*x10*x5+
43694  & x3*x7*x5+3*x4*x10*x5+3*x4*x7*x5-x4*x6*x5)
43695  fm(6,6)=64*pq**6+16*pq**4*ph**2+32*pq**4*(x1+x2+2*x4+x9+x7
43696  & +2*x5)+8*pq**2*ph**2*(-x1+2*x4-x7)+16*pq**2*(x2*x5-2*x4*
43697  & x9-2*x4*x7+4*x4*x5+x9*x5)+8*ph**2*x4*x7-16*x4*x9*x5
43698  fm(6,7)=8*pq**4*(-6*x3-3*x4-3*x10-2*x9-x8-x7-2*x6)+2*pq**2
43699  & *ph**2*(-2*x3-x4-2*x10+x7+2*x6)+4*pq**2*(-8*x1*x3-4*x1*x4
43700  & -4*x1*x10+2*x1*x9-2*x1*x8-10*x2*x3-2*x2*x4-5*x2*x10-x2*x9
43701  & -2*x2*x8-4*x2*x7-2*x2*x6-5*x3*x9-4*x3*x7-8*x3*x5-2*x4*x9+
43702  & 7*x4*x8-4*x4*x7+8*x4*x6-4*x4*x5-5*x10*x5-x9**2+x9*x8-2*x9
43703  & *x7+x9*x6-2*x9*x5+x8*x7-x8*x5)+2*ph**2*(x1*x10-x3*x7+2*x4
43704  & *x7-x4*x6)+4*(2*x1*x2*x9+x1*x2*x8+x1*x9**2-x1*x9*x8-2*x2
43705  & **2*x7-x2**2*x6-3*x2*x3*x5-2*x2*x10*x5-x2*x9*x7-x2*x9*x6+
43706  & 2*x2*x8*x7-x3*x9*x5-x4*x9*x5+2*x4*x8*x5)
43707  fm(6,8)=8*pq**4*(-6*x3-3*x4-3*x10-x9-2*x8-x7-2*x6)+2*pq**2
43708  & *ph**2*(-6*x3-3*x4-3*x10+x7+2*x6)+4*pq**2*(-8*x1*x3-4*x1*
43709  & x4-4*x1*x10-8*x2*x3-4*x2*x4-4*x2*x10-4*x3*x9-4*x3*x7-12*
43710  & x3*x5-4*x4*x9+8*x4*x8-4*x4*x7+8*x4*x6-6*x4*x5-6*x10*x5-x9
43711  & *x5-2*x8*x5)+4*ph**2*(2*x1*x3+x1*x4+x1*x10+x3*x7+x4*x7-2*
43712  & x4*x6)+8*x5*(-2*x2*x3-x2*x4-x2*x10-x3*x9-x4*x9+2*x4*x8)
43713  fm(7,7)=72*pq**4*x10+18*pq**2*ph**2*x10+8*pq**2*(x1*x10+9*
43714  & x2*x10+7*x3*x7+2*x3*x6+2*x4*x7+7*x4*x6+x10*x5+2*x9*x7+7*
43715  & x9*x6+7*x8*x7+2*x8*x6)+2*ph**2*(-x1*x10-7*x3*x7-2*x3*x6-2
43716  & *x4*x7-7*x4*x6)+4*x2*(x10*x5+2*x9*x7+7*x9*x6+7*x8*x7+2*x8
43717  & *x6)
43718  fm(7,8)=72*pq**4*x10+2*pq**2*ph**2*x10+4*pq**2*(2*x1*x10+
43719  & 10*x2*x10+7*x3*x9+2*x3*x8+14*x3*x7+4*x3*x6+2*x4*x9+7*x4*
43720  & x8+4*x4*x7+14*x4*x6+10*x10*x5+x9**2+7*x9*x8+2*x9*x7+7*x9*
43721  & x6+x8**2+7*x8*x7+2*x8*x6)+2*ph**2*(7*x1*x10-7*x3*x7-2*x3*
43722  & x6-2*x4*x7-7*x4*x6)+2*(-2*x1*x9**2-14*x1*x9*x8-2*x1*x8**2
43723  & +2*x2*x10*x5+2*x2*x9*x7+7*x2*x9*x6+7*x2*x8*x7+2*x2*x8*x6+
43724  & 7*x3*x9*x5+2*x3*x8*x5+2*x4*x9*x5+7*x4*x8*x5)
43725  fm(8,8)=72*pq**4*x10+18*pq**2*ph**2*x10+8*pq**2*(x1*x10+x2
43726  & *x10+7*x3*x9+2*x3*x8+7*x3*x7+2*x3*x6+2*x4*x9+7*x4*x8+2*x4
43727  & *x7+7*x4*x6+9*x10*x5)+2*ph**2*(-x1*x10-7*x3*x7-2*x3*x6-2*
43728  & x4*x7-7*x4*x6)+4*x5*(x2*x10+7*x3*x9+2*x3*x8+2*x4*x9+7*x4*
43729  & x8)
43730  fm(9,9)=-4*pq**4*x10-pq**2*ph**2*x10+4*pq**2*(-x1*x10-x2*x10+
43731  & x3*x7+x4*x6-x10*x5+x9*x6+x8*x7)+ph**2*(x1*x10-x3*x7-x4*x6
43732  & )+2*x2*(-x10*x5+x9*x6+x8*x7)
43733  fm(9,10)=-4*pq**4*x10-pq**2*ph**2*x10+2*pq**2*(-2*x1*x10-2*x2*
43734  & x10+2*x3*x9+2*x3*x7+2*x4*x6-2*x10*x5+x9*x8+2*x8*x7)+ph**2
43735  & *(x1*x10-x3*x7-x4*x6)+2*(-x1*x9*x8-x2*x10*x5+x2*x8*x7+x3*
43736  & x9*x5)
43737  fmxx=-4*pq**4*x10-pq**2*ph**2*x10+2*pq**2*(-2*x1*x10-2*x2*
43738  & x10+2*x4*x8+2*x4*x6+2*x3*x7-2*x10*x5+x9*x8+2*x9*x6)+ph**2
43739  & *(x1*x10-x3*x7-x4*x6)+2*(-x1*x9*x8-x2*x10*x5+x2*x9*x6+x4*
43740  & x8*x5)
43741  fm(9,10)=0.5d0*(fmxx+fm(9,10))
43742  fm(10,10)=-4*pq**4*x10-pq**2*ph**2*x10+4*pq**2*(-x1*x10-x2*x10+
43743  & x3*x7+x4*x6-x10*x5+x9*x3+x8*x4)+ph**2*(x1*x10-x3*x7-x4*x6
43744  & )+2*x5*(-x10*x2+x9*x3+x8*x4)
43745 
43746 C...Repackage matrix elements.
43747  DO 200 i=1,8
43748  DO 190 j=i,8
43749  rm(i,j)=fm(i,j)
43750  190 CONTINUE
43751  200 CONTINUE
43752  rm(7,7)=fm(7,7)-2d0*fm(9,9)
43753  rm(7,8)=fm(7,8)-2d0*fm(9,10)
43754  rm(8,8)=fm(8,8)-2d0*fm(10,10)
43755 
43756 C...Produce final result: matrix elements * colours * propagators.
43757  DO 220 i=1,8
43758  DO 210 j=i,8
43759  fac=8d0
43760  IF(i.EQ.j)fac=4d0
43761  wtqqbh=wtqqbh+rm(i,j)*fac*clr(i,j)/(dx(i)*dx(j))
43762  210 CONTINUE
43763  220 CONTINUE
43764  wtqqbh=-wtqqbh/256d0
43765 
43766  ELSE
43767 C...Evaluate matrix elements for q + qbar -> Q + Qbar + H.
43768  a11=-8d0*pq**4*x10-2d0*pq**2*ph**2*x10-(8d0*pq**2)*(x2*x10+x3
43769  & *x7+x4*x6+x9*x6+x8*x7)+2d0*ph**2*(x3*x7+x4*x6)-(4d0*x2)*(x9
43770  & *x6+x8*x7)
43771  a12=-8d0*pq**4*x10+4d0*pq**2*(-x2*x10-x3*x9-2d0*x3*x7-x4*x8-
43772  & 2d0*x4*x6-x10*x5-x9*x8-x9*x6-x8*x7)+2d0*ph**2*(-x1*x10+x3*x7
43773  & +x4*x6)+2d0*(2d0*x1*x9*x8-x2*x9*x6-x2*x8*x7-x3*x9*x5-x4*x8*
43774  & x5)
43775  a22=-8d0*pq**4*x10-2d0*pq**2*ph**2*x10-(8d0*pq**2)*(x3*x9+x3*
43776  & x7+x4*x8+x4*x6+x10*x5)+2d0*ph**2*(x3*x7+x4*x6)-(4d0*x5)*(x3
43777  & *x9+x4*x8)
43778 
43779 C...Produce final result: matrix elements * propagators.
43780  a11=a11/dx(7)**2
43781  a12=a12/(dx(7)*dx(8))
43782  a22=a22/dx(8)**2
43783  wtqqbh=-(a11+a22+2d0*a12)*8d0/9d0
43784  ENDIF
43785 
43786  RETURN
43787  END
43788 
43789 C*********************************************************************
43790 
43791 C...PYSTBH (and auxiliaries)
43792 C.. Evaluates the matrix elements for t + b + H production.
43793 
43794  SUBROUTINE pystbh(WTTBH)
43795 
43796 C...DOUBLE PRECISION AND INTEGER DECLARATIONS
43797  IMPLICIT DOUBLE PRECISION(a-h, o-z)
43798  IMPLICIT INTEGER(i-n)
43799  INTEGER pyk,pychge,pycomp
43800 
43801 C...COMMONBLOCKS
43802  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
43803  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
43804  common/pypars/mstp(200),parp(200),msti(200),pari(200)
43805  common/pyint1/mint(400),vint(400)
43806  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
43807  common/pyint3/xsfx(2,-40:40),isig(1000,3),sigh(1000)
43808  common/pyint4/mwid(500),wids(500,5)
43809  common/pysubs/msel,mselpd,msub(500),kfin(2,-40:40),ckin(200)
43810  common/pymssm/imss(0:99),rmss(0:99)
43811  common/pysgcm/isub,isubsv,mmin1,mmax1,mmin2,mmax2,mmina,mmaxa,
43812  &kfac(2,-40:40),comfac,fack,faca,sh,th,uh,sh2,th2,uh2,sqm3,sqm4,
43813  &shr,sqpth,taup,be34,cth,x(2),sqmz,sqmw,gmmz,gmmw,
43814  &aem,as,xw,xw1,xwc,xwv,poll,polr,polll,polrr
43815  common/pyctbh/ alpha,alphas,sw2,mw2,tanb,vtb,v,a
43816  DOUBLE PRECISION mw2
43817  SAVE /pydat1/,/pydat2/,/pypars/,/pyint1/,/pyint2/,/pyint3/,
43818  &/pyint4/,/pysubs/,/pymssm/,/pysgcm/,/pyctbh/
43819 
43820 C...LOCAL ARRAYS AND COMPLEX VARIABLES
43821  dimension qq(4,2),pp(4,3)
43822  DATA qq/8*0d0/
43823 
43824  wttbh=0d0
43825 
43826 C...KINEMATIC PARAMETERS.
43827  shpr=sqrt(vint(26))*vint(1)
43828  ph=sqrt(vint(21))*vint(1)
43829  sph=ph**2
43830 
43831 C...SET UP OUTGOING KINEMATICS: 1=T, 2=TBAR, 3=H.
43832  DO 100 i=1,2
43833  pt=sqrt(max(0d0,vint(197+5*i)))
43834  pp(1,i)=pt*cos(vint(198+5*i))
43835  pp(2,i)=pt*sin(vint(198+5*i))
43836  100 CONTINUE
43837  pp(1,3)=-pp(1,1)-pp(1,2)
43838  pp(2,3)=-pp(2,1)-pp(2,2)
43839  pms1=vint(201)**2+pp(1,1)**2+pp(2,1)**2
43840  pms2=vint(206)**2+pp(1,2)**2+pp(2,2)**2
43841  pms3=sph+pp(1,3)**2+pp(2,3)**2
43842  pmt3=sqrt(pms3)
43843  pp(3,3)=pmt3*sinh(vint(211))
43844  pp(4,3)=pmt3*cosh(vint(211))
43845  pms12=(shpr-pp(4,3))**2-pp(3,3)**2
43846  pp(3,1)=(-pp(3,3)*(pms12+pms1-pms2)+
43847  &vint(213)*(shpr-pp(4,3))*vint(220))/(2d0*pms12)
43848  pp(3,2)=-pp(3,1)-pp(3,3)
43849  pp(4,1)=sqrt(pms1+pp(3,1)**2)
43850  pp(4,2)=sqrt(pms2+pp(3,2)**2)
43851 
43852 C...CM SYSTEM, INGOING QUARKS/GLUONS
43853  qq(3,1) = shpr/2.d0
43854  qq(4,1) = qq(3,1)
43855  qq(3,2) = -qq(3,1)
43856  qq(4,2) = qq(4,1)
43857 
43858 C...PARAMETERS FOR AMPLITUDE METHOD
43859  alpha = aem
43860  alphas = as
43861  sw2 = paru(102)
43862  mw2 = pmas(24,1)**2
43863  tanb = paru(141)
43864  vtb = vckm(3,3)
43865  rmb=pymrun(5,vint(52))
43866 
43867  isub=mint(1)
43868 
43869  IF (isub.EQ.401) THEN
43870  CALL pytbhg(qq(1,1),qq(1,2),pp(1,1),pp(1,2),pp(1,3),
43871  & vint(201),vint(206),rmb,vint(43),wttbh)
43872  ELSE IF (isub.EQ.402) THEN
43873  CALL pytbhq(qq(1,1),qq(1,2),pp(1,1),pp(1,2),pp(1,3),
43874  & vint(201),vint(206),rmb,vint(43),wttbh)
43875  END IF
43876 
43877  RETURN
43878  END
43879 C------------------------------------------------------------------
43880  SUBROUTINE pytbhb(MT,MB,MHP,BR,GAMT)
43881 C WIDTH AND BRANCHING RATIO FOR (ON-SHELL) T-> B W+, T->B H+
43882  IMPLICIT DOUBLE PRECISION(a-h, o-z)
43883  IMPLICIT INTEGER(i-n)
43884  DOUBLE PRECISION mw2,mt,mb,mhp,mw,kfun
43885  common/pyctbh/ alpha,alphas,sw2,mw2,tanb,vtb,v,a
43886  SAVE /pyctbh/
43887 
43888 C TOP WIDTH CALCULATION
43889 C VTB = 0.99
43890  mw=dsqrt(mw2)
43891  xb=(mb/mt)**2
43892  xw=(mw/mt)**2
43893  xh =(mhp/mt)**2
43894  gamtbh = 0d0
43895  IF (mt .LT. (mhp+mb)) THEN
43896 C T ->B W ONLY
43897  betw = dsqrt(1.d0-2*(xb+xw)+(xw-xb)**2)
43898  gamtbw = vtb**2*alpha/(16*sw2)*mt/xw*betw*
43899  & (2*(1.d0-xb-xw)-(1.d0+xb-xw)*(1.d0-xb -2*xw) )
43900  gamt = gamtbw
43901  ELSE
43902 C T ->BW +T ->B H^+
43903  betw = dsqrt(1.d0-2*(xb+xw)+(xw-xb)**2)
43904  gamtbw = vtb**2*alpha/(16*sw2)*mt/xw*betw*
43905  & (2*(1.d0-xb-xw)-(1.d0+xb-xw)*(1.d0-xb -2*xw) )
43906 C
43907  kfun = dsqrt( (1.d0-(mhp/mt)**2-(mb/mt)**2)**2
43908  & -4.d0*(mhp*mb/mt**2)**2 )
43909  gamtbh= alpha/sw2/8.d0*vtb**2*kfun/mt *
43910  & (v**2*((mt+mb)**2-mhp**2)+a**2*((mt-mb)**2-mhp**2))
43911  gamt = gamtbw+gamtbh
43912  ENDIF
43913 C THUS BR IS
43914  br=gamtbh/gamt
43915  RETURN
43916  END
43917 
43918 C AMPLITUDE SQUARED (MATRIX ELEMENTS) FOR THE PROCESSES:
43919 C GG->TBH^+, QQBAR->TBH^+
43920 C AS A FUNCTION OF 4-MOMENTA FOR SUITABLE INTERFACE
43921 C (FOR INSTANCE WITH PYTHIA)
43922 C------------------------------------------------------------
43923 C BASED ON F. BORZUMATI, J.-L. KNEUR, N. POLONSKY HEP-PH/9905443,
43924 C PHYS REV. D 60 (1999) 115011
43925 C (THESE FILES PREPARED BY J.-L. KNEUR)
43926 C------------------------------------------------------------
43927 C 1) GG->TBH^+
43928  SUBROUTINE pytbhg(Q1,Q2,P1,P2,P3,MT,MB,RMB,MHP,AMP2)
43929 C
43930 C CONVENTIONS AND INPUT/OUTPUT DEFINITIONS:
43931 C
43932 C INPUT: Q1,Q2 ARE ENTERING 4-MOMENTA OF INITIAL GLUONS OR QUARKS;
43933 C P1, P2 ARE THE TOP AND BOTTOM OUTGOING 4-MOMENTA;
43934 C P3 IS OUTGOING CHARGED HIGGS 4-MOMENTA.
43935 C (NB FOR ALL 4-MOMENTA P(4) IS TIME-COMPONENT)
43936 C "PHYSICAL PARAMETERS" INPUT:
43937 C MT,MB TOP AND BOTTOM MASSES;
43938 C MHP CHARGED HIGGS MASS
43939 C FURTHER PARAMETERS INPUT IS NEEDED FROM COMMON/PARAM/ (SEE BELOW)
43940 C
43941 C OUTPUT: AMP2 IS MATRIX ELEMENT (AMPLITUDE**2) FOR GG->TB H^+
43942 C (NB AMP2 IS TRULY AMPLITUDE SQUARRED, I.E. WITHOUT ANY
43943 C PHASE SPACE FACTORS INCLUDED. IT INCLUDES COLOUR AND COUPLING
43944 C FACTORS, AS EXPLICIT BELOW. ACCORDINGLY, FOR EXAMPLE THE TOTAL
43945 C CROSS-SECTION SHOULD BE (SYMBOLICALLY):
43946 C SIGMA = INTEGRATE [PARTON DENSITY FUNCTIONS * 3-PARTICLE FINAL
43947 C STATE PHASE-SPACE (STANDARDLY NORMALIZED) * AMP2 ]
43948 C
43949  IMPLICIT DOUBLE PRECISION(a-h, o-z)
43950  IMPLICIT INTEGER(i-n)
43951  DOUBLE PRECISION mw2,mt,mb,mhp,mw
43952  dimension q1(4),q2(4),p1(4),p2(4),p3(4)
43953  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
43954  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
43955  common/pymssm/imss(0:99),rmss(0:99)
43956 
43957  common/pyctbh/ alpha,alphas,sw2,mw2,tanb,vtb,v,a
43958  SAVE /pydat1/,/pydat2/,/pymssm/,/pyctbh/
43959 C !THE RELEVANT INPUT PARAMETERS ABOVE ARE NEEDED FOR CALCULATION
43960 C BUT ARE NOT DEFINED HERE SO THAT ONE MAY CHOOSE/VARY THEIR VALUES:
43961 C ACCORDINGLY, WHEN CALLING THESE SUBROUTINES, PLEASE SUPPLY VIA
43962 C THIS COMMON/PARAM/ YOUR PREFERRED ALPHA, ALPHAS,..AND TANB
43963 C (TAN BETA) VALUES
43964 C
43965 C THE NORMALIZED V,A COUPLINGS ARE DEFINED BELOW AND USED BOTH
43966 C IN THIS ROUTINE AND IN THE TOP WIDTH CALCULATION PYTBHB(..).
43967 
43968  pi = 4*datan(1.d0)
43969  mw = dsqrt(mw2)
43970 C
43971 C COLLECTING THE RELEVANT OVERALL FACTORS:
43972 C 8X8 INITIAL GLUON COLOR AVERAGE, 2X2 GLUON SPIN AVERAGE
43973  ps=1.d0/(8.d0*8.d0 *2.d0*2.d0)
43974 C COUPLING CONSTANT (OVERALL NORMALIZATION)
43975  fact=(4.d0*pi*alpha)*(4.d0*pi*alphas)**2/sw2/2.d0
43976 C NB ALPHA IS E^2/4/PI, BUT BETTER DEFINED IN TERMS OF G_FERMI:
43977 C ALPHA= DSQRT(2.D0)*GF*SW2*MW**2/PI
43978 C ALPHAS IS ALPHA_STRONG;
43979 C SW2 IS SIN(THETA_W)**2.
43980 C
43981 C VTB=.998D0
43982 C VTB IS TOP-BOTTOM CKM MATRIX ELEMENT (APPROXIMATE VALUE HERE)
43983 C
43984  v = ( mt/mw/tanb +rmb/mw*tanb)/2.d0
43985  a = (-mt/mw/tanb +rmb/mw*tanb)/2.d0
43986 C V AND A ARE (NORMALIZED) VECTOR AND AXIAL TBH^+ COUPLINGS
43987 C
43988 C REDEFINING P2 INGOING FROM OVERALL MOMENTUM CONSERVATION
43989 C (BECAUSE P2 INGOING WAS USED IN OUR GRAPH CALCULATION CONVENTIONS)
43990  DO 100 kk=1,4
43991  p2(kk)=p3(kk)-q1(kk)-q2(kk)+p1(kk)
43992  100 CONTINUE
43993 C DEFINING VARIOUS RELEVANT 4-SCALAR PRODUCTS:
43994  s = 2*pytbhs(q1,q2)
43995  p1q1=pytbhs(q1,p1)
43996  p1q2=pytbhs(p1,q2)
43997  p2q1=pytbhs(p2,q1)
43998  p2q2=pytbhs(p2,q2)
43999  p1p2=pytbhs(p1,p2)
44000 C
44001 C TOP WIDTH CALCULATION
44002  CALL pytbhb(mt,mb,mhp,br,gamt)
44003 C GAMT IS THE TOP WIDTH: T->BH^+ AND/OR T->B W^+
44004 C THEN DEFINE TOP (RESONANT) PROPAGATOR:
44005  a1inv= s -2*p1q1 -2*p1q2
44006  a1 =a1inv/(a1inv**2+ (gamt*mt)**2)
44007 C (I.E. INTRODUCE THE TOP WIDTH IN A1 TO REGULARISE THE POLE)
44008 C NB: A12 = A1*A1 BUT CORRECT EXPRESSION BELOW BECAUSE OF
44009 C THE TOP WIDTH
44010  a12 = 1.d0/(a1inv**2+ (gamt*mt)**2)
44011  a2 =1.d0/(s +2*p2q1 +2*p2q2)
44012 C NOTE A2 IS B PROPAGATOR, DOES NOT NEED A WIDTH
44013 C NOW COMES THE AMP**2:
44014 C NB COLOR FACTOR (COMING FROM GRAPHS) ALREADY INCLUDED IN
44015 C THE EXPRESSIONS BELOW
44016  v18=0.d0
44017  a18=0.d0
44018  v18= 640*a1/3+640*a2/3+32*a1*a2*mb**2-368*a12*mb*mt-
44019  &512*a1*a2*mb*mt/3-
44020  &368*a2**2*mb*mt+32*a1*a2*mt**2+496*a12*p1p2/3+
44021  &320*a1*a2*p1p2+496*a2**2*p1p2/3+128*a1*mb*mt**3/(3*p1q1**2)+
44022  &128*a1*mt**4/(3*p1q1**2)-256*a12*mb*mt**5/(3*p1q1**2)+
44023  &256*a1*mt**2*p1p2/(3*p1q1**2)-256*a12*mt**4*p1p2/(3*p1q1**2)+
44024  &8/(3*p1q1)-32*a1*mb*mt/p1q1-56*a2*mb*mt/(3*p1q1)+
44025  &88*a1*mt**2/(3*p1q1)+72*a2*mt**2/p1q1+
44026  &704*a12*mb*mt**3/(3*p1q1)-224*a1*a2*mb*mt**3/(3*p1q1)+
44027  &104*a1*p1p2/(3*p1q1)+48*a2*p1p2/p1q1+
44028  &128*a1*a2*mb*mt*p1p2/(3*p1q1)+512*a12*mt**2*p1p2/(3*p1q1)-
44029  &448*a1*a2*mt**2*p1p2/(3*p1q1)-32*a1*a2*p1p2**2/p1q1-
44030  &656*a1*a2*p1q1/3-224*a2**2*p1q1+128*a1*mb*mt**3/(3*p1q2**2)+
44031  &128*a1*mt**4/(3*p1q2**2)-256*a12*mb*mt**5/(3*p1q2**2)+
44032  &256*a1*mt**2*p1p2/(3*p1q2**2)-256*a12*mt**4*p1p2/(3*p1q2**2)+
44033  &256*a1*mt**2*p1q1/(3*p1q2**2)+256*a12*mb*mt**3*p1q1/(3*p1q2**2)+
44034  &8/(3*p1q2)-32*a1*mb*mt/p1q2-56*a2*mb*mt/(3*p1q2)
44035  v18=v18+88*a1*mt**2/(3*p1q2)+72*a2*mt**2/p1q2+
44036  &704*a12*mb*mt**3/(3*p1q2)-224*a1*a2*mb*mt**3/(3*p1q2)+
44037  &104*a1*p1p2/(3*p1q2)+48*a2*p1p2/p1q2+
44038  &128*a1*a2*mb*mt*p1p2/(3*p1q2)+512*a12*mt**2*p1p2/(3*p1q2)-
44039  &448*a1*a2*mt**2*p1p2/(3*p1q2)-32*a1*a2*p1p2**2/p1q2-
44040  &32*a1*mb*mt**3/(3*p1q1*p1q2)-32*a1*mt**4/(3*p1q1*p1q2)+
44041  &64*a12*mb*mt**5/(3*p1q1*p1q2)+16*p1p2/(3*p1q1*p1q2)-
44042  &64*a1*mt**2*p1p2/(3*p1q1*p1q2)+64*a12*mt**4*p1p2/(3*p1q1*p1q2)+
44043  &112*a1*p1q1/p1q2+272*a2*p1q1/(3*p1q2)-
44044  &272*a1*a2*mb**2*p1q1/(3*p1q2)+208*a12*mb*mt*p1q1/(3*p1q2)-
44045  &400*a1*a2*mb*mt*p1q1/(3*p1q2)-80*a1*a2*mt**2*p1q1/p1q2+
44046  &96*a12*p1p2*p1q1/p1q2-320*a1*a2*p1p2*p1q1/p1q2-
44047  &544*a1*a2*p1q1**2/(3*p1q2)-656*a1*a2*p1q2/3-224*a2**2*p1q2+
44048  &256*a1*mt**2*p1q2/(3*p1q1**2)+256*a12*mb*mt**3*p1q2/(3*p1q1**2)+
44049  &112*a1*p1q2/p1q1+272*a2*p1q2/(3*p1q1)-
44050  &272*a1*a2*mb**2*p1q2/(3*p1q1)+208*a12*mb*mt*p1q2/(3*p1q1)-
44051  &400*a1*a2*mb*mt*p1q2/(3*p1q1)-80*a1*a2*mt**2*p1q2/p1q1
44052  v18=v18+96*a12*p1p2*p1q2/p1q1-320*a1*a2*p1p2*p1q2/p1q1-
44053  &544*a1*a2*p1q2**2/(3*p1q1)+128*a2*mb**4/(3*p2q1**2)+
44054  &128*a2*mb**3*mt/(3*p2q1**2)-256*a2**2*mb**5*mt/(3*p2q1**2)+
44055  &256*a2*mb**2*p1p2/(3*p2q1**2)-256*a2**2*mb**4*p1p2/(3*p2q1**2)+
44056  &256*a2*mb**2*p1q1/(3*p2q1**2)-256*a2**2*mb**4*p1q1/(3*p2q1**2)-
44057  &64*mb**3*mt**3/(3*p1q2**2*p2q1**2)-
44058  &64*mb**2*mt**2*p1p2/(3*p1q2**2*p2q1**2)-
44059  &64*mb**2*mt**2*p1q1/(3*p1q2**2*p2q1**2)+
44060  &64*mb**3*mt/(3*p1q2*p2q1**2)+
44061  &256*a2*mb**3*mt*p1p2/(3*p1q2*p2q1**2)+
44062  &256*a2*mb**2*p1p2**2/(3*p1q2*p2q1**2)+
44063  &256*a2*mb**3*mt*p1q1/(3*p1q2*p2q1**2)+
44064  &512*a2*mb**2*p1p2*p1q1/(3*p1q2*p2q1**2)+
44065  &256*a2*mb**2*p1q1**2/(3*p1q2*p2q1**2)-
44066  &256*a2**2*mb**4*p1q2/(3*p2q1**2)-8/(3*p2q1)-72*a1*mb**2/p2q1-
44067  &88*a2*mb**2/(3*p2q1)+56*a1*mb*mt/(3*p2q1)+32*a2*mb*mt/p2q1+
44068  &224*a1*a2*mb**3*mt/(3*p2q1)-704*a2**2*mb**3*mt/(3*p2q1)
44069  v18=v18-48*a1*p1p2/p2q1-104*a2*p1p2/(3*p2q1)+
44070  &448*a1*a2*mb**2*p1p2/(3*p2q1)-512*a2**2*mb**2*p1p2/(3*p2q1)-
44071  &128*a1*a2*mb*mt*p1p2/(3*p2q1)+32*a1*a2*p1p2**2/p2q1-
44072  &16*p1p2/(3*p1q1*p2q1)-32*a1*mb*mt*p1p2/(3*p1q1*p2q1)-
44073  &32*a2*mb*mt*p1p2/(3*p1q1*p2q1)-
44074  &64*a1*a2*mb*mt*p1p2**2/(3*p1q1*p2q1)-
44075  &64*a1*a2*p1p2**3/(3*p1q1*p2q1)-256*a2*p1q1/(3*p2q1)+
44076  &448*a1*a2*mb**2*p1q1/(3*p2q1)-368*a2**2*mb**2*p1q1/(3*p2q1)+
44077  &224*a1*a2*mb*mt*p1q1/(3*p2q1)+304*a1*a2*p1p2*p1q1/(3*p2q1)-
44078  &64*mb*mt**3/(3*p1q2**2*p2q1)-
44079  &256*a1*mb*mt**3*p1p2/(3*p1q2**2*p2q1)-
44080  &256*a1*mt**2*p1p2**2/(3*p1q2**2*p2q1)+
44081  &64*mt**2*p1q1/(3*p1q2**2*p2q1)-
44082  &128*a1*mb**2*mt**2*p1q1/(3*p1q2**2*p2q1)-
44083  &128*a1*mb*mt**3*p1q1/(3*p1q2**2*p2q1)-
44084  &256*a1*mt**2*p1p2*p1q1/(3*p1q2**2*p2q1)-4*mb**2/(3*p1q2*p2q1)+
44085  &64*mb*mt/(3*p1q2*p2q1)-128*a2*mb**3*mt/(3*p1q2*p2q1)
44086  v18=v18-4*mt**2/(3*p1q2*p2q1)-128*a1*mb**2*mt**2/(3*p1q2*p2q1)-
44087  &128*a2*mb**2*mt**2/(3*p1q2*p2q1)-128*a1*mb*mt**3/(3*p1q2*p2q1)-
44088  &112*a2*mb**2*p1p2/(3*p1q2*p2q1)-32*a1*mb*mt*p1p2/(3*p1q2*p2q1)-
44089  &32*a2*mb*mt*p1p2/(3*p1q2*p2q1)-112*a1*mt**2*p1p2/(3*p1q2*p2q1)-
44090  &48*a1*p1p2**2/(p1q2*p2q1)-48*a2*p1p2**2/(p1q2*p2q1)+
44091  &512*a1*a2*mb*mt*p1p2**2/(3*p1q2*p2q1)+
44092  &512*a1*a2*p1p2**3/(3*p1q2*p2q1)-8*mb*mt*p1p2/(3*p1q1*p1q2*p2q1)-
44093  &8*mt**2*p1p2/(3*p1q1*p1q2*p2q1)+
44094  &32*a1*mb*mt**3*p1p2/(3*p1q1*p1q2*p2q1)-
44095  &16*p1p2**2/(3*p1q1*p1q2*p2q1)+
44096  &32*a1*mt**2*p1p2**2/(3*p1q1*p1q2*p2q1)+8*p1q1/(3*p1q2*p2q1)-
44097  &160*a1*mb**2*p1q1/(3*p1q2*p2q1)-272*a2*mb**2*p1q1/(3*p1q2*p2q1)+
44098  &56*a1*mb*mt*p1q1/(3*p1q2*p2q1)+200*a2*mb*mt*p1q1/(3*p1q2*p2q1)-
44099  &48*a1*p1p2*p1q1/(p1q2*p2q1)-256*a2*p1p2*p1q1/(3*p1q2*p2q1)+
44100  &256*a1*a2*mb**2*p1p2*p1q1/(3*p1q2*p2q1)+
44101  &256*a1*a2*mb*mt*p1p2*p1q1/(p1q2*p2q1)+
44102  &1024*a1*a2*p1p2**2*p1q1/(3*p1q2*p2q1)
44103  v18=v18-272*a2*p1q1**2/(3*p1q2*p2q1)+
44104  &256*a1*a2*mb**2*p1q1**2/(3*p1q2*p2q1)+
44105  &256*a1*a2*mb*mt*p1q1**2/(3*p1q2*p2q1)+
44106  &512*a1*a2*p1p2*p1q1**2/(3*p1q2*p2q1)+16*a2*p1q2/(3*p2q1)+
44107  &64*a1*a2*mb**2*p1q2/p2q1+32*a2**2*mb**2*p1q2/(3*p2q1)+
44108  &112*a1*a2*mb*mt*p1q2/(3*p2q1)+368*a1*a2*p1p2*p1q2/(3*p2q1)+
44109  &32*a2*p1p2*p1q2/(3*p1q1*p2q1)-
44110  &32*a1*a2*mb**2*p1p2*p1q2/(3*p1q1*p2q1)-
44111  &32*a1*a2*mb*mt*p1p2*p1q2/(3*p1q1*p2q1)-
44112  &64*a1*a2*p1p2**2*p1q2/(3*p1q1*p2q1)+224*a12*p2q1+
44113  &656*a1*a2*p2q1/3-256*a1*mt**2*p2q1/(3*p1q1**2)+
44114  &256*a12*mt**4*p2q1/(3*p1q1**2)-256*a1*p2q1/(3*p1q1)+
44115  &224*a1*a2*mb*mt*p2q1/(3*p1q1)-368*a12*mt**2*p2q1/(3*p1q1)+
44116  &448*a1*a2*mt**2*p2q1/(3*p1q1)+304*a1*a2*p1p2*p2q1/(3*p1q1)+
44117  &256*a12*mt**4*p2q1/(3*p1q2**2)+
44118  &256*a12*mt**2*p1q1*p2q1/(3*p1q2**2)+16*a1*p2q1/(3*p1q2)+
44119  &112*a1*a2*mb*mt*p2q1/(3*p1q2)+32*a12*mt**2*p2q1/(3*p1q2)
44120  v18=v18+64*a1*a2*mt**2*p2q1/p1q2+368*a1*a2*p1p2*p2q1/(3*p1q2)+
44121  &16*a1*mt**2*p2q1/(3*p1q1*p1q2)-64*a12*mt**4*p2q1/(3*p1q1*p1q2)+
44122  &640*a12*p1q1*p2q1/(3*p1q2)+544*a1*a2*p1q1*p2q1/(3*p1q2)+
44123  &32*a12*p1q2*p2q1/p1q1+944*a1*a2*p1q2*p2q1/(3*p1q1)+
44124  &128*a2*mb**4/(3*p2q2**2)+128*a2*mb**3*mt/(3*p2q2**2)-
44125  &256*a2**2*mb**5*mt/(3*p2q2**2)+256*a2*mb**2*p1p2/(3*p2q2**2)-
44126  &256*a2**2*mb**4*p1p2/(3*p2q2**2)-
44127  &64*mb**3*mt**3/(3*p1q1**2*p2q2**2)-
44128  &64*mb**2*mt**2*p1p2/(3*p1q1**2*p2q2**2)+
44129  &64*mb**3*mt/(3*p1q1*p2q2**2)+
44130  &256*a2*mb**3*mt*p1p2/(3*p1q1*p2q2**2)+
44131  &256*a2*mb**2*p1p2**2/(3*p1q1*p2q2**2)-
44132  &256*a2**2*mb**4*p1q1/(3*p2q2**2)+256*a2*mb**2*p1q2/(3*p2q2**2)-
44133  &256*a2**2*mb**4*p1q2/(3*p2q2**2)-
44134  &64*mb**2*mt**2*p1q2/(3*p1q1**2*p2q2**2)+
44135  &256*a2*mb**3*mt*p1q2/(3*p1q1*p2q2**2)+
44136  &512*a2*mb**2*p1p2*p1q2/(3*p1q1*p2q2**2)
44137  v18=v18+256*a2*mb**2*p1q2**2/(3*p1q1*p2q2**2)-
44138  &256*a2*mb**2*p2q1/(3*p2q2**2)-256*a2**2*mb**3*mt*p2q1/(3*p2q2**2)+
44139  &64*mb**2*mt**2*p2q1/(3*p1q1**2*p2q2**2)+
44140  &64*mb**2*p2q1/(3*p1q1*p2q2**2)-
44141  &128*a2*mb**3*mt*p2q1/(3*p1q1*p2q2**2)-
44142  &128*a2*mb**2*mt**2*p2q1/(3*p1q1*p2q2**2)-
44143  &256*a2*mb**2*p1p2*p2q1/(3*p1q1*p2q2**2)+
44144  &256*a2**2*mb**2*p1q1*p2q1/(3*p2q2**2)-
44145  &256*a2*mb**2*p1q2*p2q1/(3*p1q1*p2q2**2)-8/(3*p2q2)-
44146  &72*a1*mb**2/p2q2-88*a2*mb**2/(3*p2q2)+56*a1*mb*mt/(3*p2q2)+
44147  &32*a2*mb*mt/p2q2+224*a1*a2*mb**3*mt/(3*p2q2)-
44148  &704*a2**2*mb**3*mt/(3*p2q2)-48*a1*p1p2/p2q2-
44149  &104*a2*p1p2/(3*p2q2)+448*a1*a2*mb**2*p1p2/(3*p2q2)-
44150  &512*a2**2*mb**2*p1p2/(3*p2q2)-128*a1*a2*mb*mt*p1p2/(3*p2q2)+
44151  &32*a1*a2*p1p2**2/p2q2-64*mb*mt**3/(3*p1q1**2*p2q2)-
44152  &256*a1*mb*mt**3*p1p2/(3*p1q1**2*p2q2)-
44153  &256*a1*mt**2*p1p2**2/(3*p1q1**2*p2q2)-4*mb**2/(3*p1q1*p2q2)
44154  v18=v18+64*mb*mt/(3*p1q1*p2q2)-128*a2*mb**3*mt/(3*p1q1*p2q2)-
44155  &4*mt**2/(3*p1q1*p2q2)-128*a1*mb**2*mt**2/(3*p1q1*p2q2)-
44156  &128*a2*mb**2*mt**2/(3*p1q1*p2q2)-128*a1*mb*mt**3/(3*p1q1*p2q2)-
44157  &112*a2*mb**2*p1p2/(3*p1q1*p2q2)-32*a1*mb*mt*p1p2/(3*p1q1*p2q2)-
44158  &32*a2*mb*mt*p1p2/(3*p1q1*p2q2)-112*a1*mt**2*p1p2/(3*p1q1*p2q2)-
44159  &48*a1*p1p2**2/(p1q1*p2q2)-48*a2*p1p2**2/(p1q1*p2q2)+
44160  &512*a1*a2*mb*mt*p1p2**2/(3*p1q1*p2q2)+
44161  &512*a1*a2*p1p2**3/(3*p1q1*p2q2)+16*a2*p1q1/(3*p2q2)+
44162  &64*a1*a2*mb**2*p1q1/p2q2+32*a2**2*mb**2*p1q1/(3*p2q2)+
44163  &112*a1*a2*mb*mt*p1q1/(3*p2q2)+368*a1*a2*p1p2*p1q1/(3*p2q2)-
44164  &16*p1p2/(3*p1q2*p2q2)-32*a1*mb*mt*p1p2/(3*p1q2*p2q2)-
44165  &32*a2*mb*mt*p1p2/(3*p1q2*p2q2)-
44166  &64*a1*a2*mb*mt*p1p2**2/(3*p1q2*p2q2)-
44167  &64*a1*a2*p1p2**3/(3*p1q2*p2q2)-8*mb*mt*p1p2/(3*p1q1*p1q2*p2q2)-
44168  &8*mt**2*p1p2/(3*p1q1*p1q2*p2q2)+
44169  &32*a1*mb*mt**3*p1p2/(3*p1q1*p1q2*p2q2)-
44170  &16*p1p2**2/(3*p1q1*p1q2*p2q2)
44171  v18=v18+32*a1*mt**2*p1p2**2/(3*p1q1*p1q2*p2q2)+
44172  &32*a2*p1p2*p1q1/(3*p1q2*p2q2)-
44173  &32*a1*a2*mb**2*p1p2*p1q1/(3*p1q2*p2q2)-
44174  &32*a1*a2*mb*mt*p1p2*p1q1/(3*p1q2*p2q2)-
44175  &64*a1*a2*p1p2**2*p1q1/(3*p1q2*p2q2)-256*a2*p1q2/(3*p2q2)+
44176  &448*a1*a2*mb**2*p1q2/(3*p2q2)-368*a2**2*mb**2*p1q2/(3*p2q2)+
44177  &224*a1*a2*mb*mt*p1q2/(3*p2q2)+304*a1*a2*p1p2*p1q2/(3*p2q2)+
44178  &64*mt**2*p1q2/(3*p1q1**2*p2q2)-
44179  &128*a1*mb**2*mt**2*p1q2/(3*p1q1**2*p2q2)-
44180  &128*a1*mb*mt**3*p1q2/(3*p1q1**2*p2q2)-
44181  &256*a1*mt**2*p1p2*p1q2/(3*p1q1**2*p2q2)+8*p1q2/(3*p1q1*p2q2)-
44182  &160*a1*mb**2*p1q2/(3*p1q1*p2q2)-272*a2*mb**2*p1q2/(3*p1q1*p2q2)+
44183  &56*a1*mb*mt*p1q2/(3*p1q1*p2q2)+200*a2*mb*mt*p1q2/(3*p1q1*p2q2)-
44184  &48*a1*p1p2*p1q2/(p1q1*p2q2)-256*a2*p1p2*p1q2/(3*p1q1*p2q2)+
44185  &256*a1*a2*mb**2*p1p2*p1q2/(3*p1q1*p2q2)+
44186  &256*a1*a2*mb*mt*p1p2*p1q2/(p1q1*p2q2)+
44187  &1024*a1*a2*p1p2**2*p1q2/(3*p1q1*p2q2)
44188  v18=v18-272*a2*p1q2**2/(3*p1q1*p2q2)+
44189  &256*a1*a2*mb**2*p1q2**2/(3*p1q1*p2q2)+
44190  &256*a1*a2*mb*mt*p1q2**2/(3*p1q1*p2q2)+
44191  &512*a1*a2*p1p2*p1q2**2/(3*p1q1*p2q2)-32*a2*mb**4/(3*p2q1*p2q2)-
44192  &32*a2*mb**3*mt/(3*p2q1*p2q2)+64*a2**2*mb**5*mt/(3*p2q1*p2q2)+
44193  &16*p1p2/(3*p2q1*p2q2)-64*a2*mb**2*p1p2/(3*p2q1*p2q2)+
44194  &64*a2**2*mb**4*p1p2/(3*p2q1*p2q2)+8*mb**2*p1p2/(3*p1q1*p2q1*p2q2)+
44195  &8*mb*mt*p1p2/(3*p1q1*p2q1*p2q2)-
44196  &32*a2*mb**3*mt*p1p2/(3*p1q1*p2q1*p2q2)+
44197  &16*p1p2**2/(3*p1q1*p2q1*p2q2)-
44198  &32*a2*mb**2*p1p2**2/(3*p1q1*p2q1*p2q2)-
44199  &16*a2*mb**2*p1q1/(3*p2q1*p2q2)+64*a2**2*mb**4*p1q1/(3*p2q1*p2q2)+
44200  &8*mb**2*p1p2/(3*p1q2*p2q1*p2q2)+8*mb*mt*p1p2/(3*p1q2*p2q1*p2q2)-
44201  &32*a2*mb**3*mt*p1p2/(3*p1q2*p2q1*p2q2)+
44202  &16*p1p2**2/(3*p1q2*p2q1*p2q2)-
44203  &32*a2*mb**2*p1p2**2/(3*p1q2*p2q1*p2q2)+
44204  &16*mb*mt*p1p2**2/(3*p1q1*p1q2*p2q1*p2q2)
44205  v18=v18+16*p1p2**3/(3*p1q1*p1q2*p2q1*p2q2)-
44206  &32*a2*mb**2*p1p2*p1q1/(3*p1q2*p2q1*p2q2)-
44207  &16*a2*mb**2*p1q2/(3*p2q1*p2q2)+64*a2**2*mb**4*p1q2/(3*p2q1*p2q2)-
44208  &32*a2*mb**2*p1p2*p1q2/(3*p1q1*p2q1*p2q2)+272*a1*p2q1/(3*p2q2)+
44209  &112*a2*p2q1/p2q2-80*a1*a2*mb**2*p2q1/p2q2-
44210  &400*a1*a2*mb*mt*p2q1/(3*p2q2)+208*a2**2*mb*mt*p2q1/(3*p2q2)-
44211  &272*a1*a2*mt**2*p2q1/(3*p2q2)-320*a1*a2*p1p2*p2q1/p2q2+
44212  &96*a2**2*p1p2*p2q1/p2q2+256*a1*mb*mt**3*p2q1/(3*p1q1**2*p2q2)+
44213  &512*a1*mt**2*p1p2*p2q1/(3*p1q1**2*p2q2)-8*p2q1/(3*p1q1*p2q2)-
44214  &200*a1*mb*mt*p2q1/(3*p1q1*p2q2)-56*a2*mb*mt*p2q1/(3*p1q1*p2q2)+
44215  &272*a1*mt**2*p2q1/(3*p1q1*p2q2)+160*a2*mt**2*p2q1/(3*p1q1*p2q2)+
44216  &256*a1*p1p2*p2q1/(3*p1q1*p2q2)+48*a2*p1p2*p2q1/(p1q1*p2q2)-
44217  &256*a1*a2*mb*mt*p1p2*p2q1/(p1q1*p2q2)-
44218  &256*a1*a2*mt**2*p1p2*p2q1/(3*p1q1*p2q2)-
44219  &1024*a1*a2*p1p2**2*p2q1/(3*p1q1*p2q2)-
44220  &544*a1*a2*p1q1*p2q1/(3*p2q2)-640*a2**2*p1q1*p2q1/(3*p2q2)-
44221  &32*a1*p1p2*p2q1/(3*p1q2*p2q2)
44222  v18=v18+32*a1*a2*mb*mt*p1p2*p2q1/(3*p1q2*p2q2)+
44223  &32*a1*a2*mt**2*p1p2*p2q1/(3*p1q2*p2q2)+
44224  &64*a1*a2*p1p2**2*p2q1/(3*p1q2*p2q2)-
44225  &32*a1*mt**2*p1p2*p2q1/(3*p1q1*p1q2*p2q2)+
44226  &64*a1*a2*p1p2*p1q1*p2q1/(3*p1q2*p2q2)-
44227  &944*a1*a2*p1q2*p2q1/(3*p2q2)-32*a2**2*p1q2*p2q1/p2q2+
44228  &256*a1*mt**2*p1q2*p2q1/(3*p1q1**2*p2q2)+
44229  &96*a1*p1q2*p2q1/(p1q1*p2q2)+96*a2*p1q2*p2q1/(p1q1*p2q2)-
44230  &128*a1*a2*mb**2*p1q2*p2q1/(3*p1q1*p2q2)-
44231  &256*a1*a2*mb*mt*p1q2*p2q1/(p1q1*p2q2)-
44232  &128*a1*a2*mt**2*p1q2*p2q1/(3*p1q1*p2q2)-
44233  &512*a1*a2*p1p2*p1q2*p2q1/(p1q1*p2q2)-
44234  &512*a1*a2*p1q2**2*p2q1/(3*p1q1*p2q2)+544*a1*a2*p2q1**2/(3*p2q2)-
44235  &256*a1*mt**2*p2q1**2/(3*p1q1**2*p2q2)-
44236  &272*a1*p2q1**2/(3*p1q1*p2q2)+
44237  &256*a1*a2*mb*mt*p2q1**2/(3*p1q1*p2q2)+
44238  &256*a1*a2*mt**2*p2q1**2/(3*p1q1*p2q2)
44239  v18=v18+512*a1*a2*p1p2*p2q1**2/(3*p1q1*p2q2)+
44240  &512*a1*a2*p1q2*p2q1**2/(3*p1q1*p2q2)+224*a12*p2q2+
44241  &656*a1*a2*p2q2/3+256*a12*mt**4*p2q2/(3*p1q1**2)+
44242  &16*a1*p2q2/(3*p1q1)+112*a1*a2*mb*mt*p2q2/(3*p1q1)+
44243  &32*a12*mt**2*p2q2/(3*p1q1)+64*a1*a2*mt**2*p2q2/p1q1+
44244  &368*a1*a2*p1p2*p2q2/(3*p1q1)-256*a1*mt**2*p2q2/(3*p1q2**2)+
44245  &256*a12*mt**4*p2q2/(3*p1q2**2)-256*a1*p2q2/(3*p1q2)+
44246  &224*a1*a2*mb*mt*p2q2/(3*p1q2)-368*a12*mt**2*p2q2/(3*p1q2)+
44247  &448*a1*a2*mt**2*p2q2/(3*p1q2)+304*a1*a2*p1p2*p2q2/(3*p1q2)+
44248  &16*a1*mt**2*p2q2/(3*p1q1*p1q2)-64*a12*mt**4*p2q2/(3*p1q1*p1q2)+
44249  &32*a12*p1q1*p2q2/p1q2+944*a1*a2*p1q1*p2q2/(3*p1q2)+
44250  &256*a12*mt**2*p1q2*p2q2/(3*p1q1**2)+
44251  &640*a12*p1q2*p2q2/(3*p1q1)+544*a1*a2*p1q2*p2q2/(3*p1q1)-
44252  &256*a2*mb**2*p2q2/(3*p2q1**2)-256*a2**2*mb**3*mt*p2q2/(3*p2q1**2)+
44253  &64*mb**2*mt**2*p2q2/(3*p1q2**2*p2q1**2)+
44254  &64*mb**2*p2q2/(3*p1q2*p2q1**2)-
44255  &128*a2*mb**3*mt*p2q2/(3*p1q2*p2q1**2)
44256  v18=v18-128*a2*mb**2*mt**2*p2q2/(3*p1q2*p2q1**2)-
44257  &256*a2*mb**2*p1p2*p2q2/(3*p1q2*p2q1**2)-
44258  &256*a2*mb**2*p1q1*p2q2/(3*p1q2*p2q1**2)+
44259  &256*a2**2*mb**2*p1q2*p2q2/(3*p2q1**2)+272*a1*p2q2/(3*p2q1)+
44260  &112*a2*p2q2/p2q1-80*a1*a2*mb**2*p2q2/p2q1-
44261  &400*a1*a2*mb*mt*p2q2/(3*p2q1)+208*a2**2*mb*mt*p2q2/(3*p2q1)-
44262  &272*a1*a2*mt**2*p2q2/(3*p2q1)-320*a1*a2*p1p2*p2q2/p2q1+
44263  &96*a2**2*p1p2*p2q2/p2q1-32*a1*p1p2*p2q2/(3*p1q1*p2q1)+
44264  &32*a1*a2*mb*mt*p1p2*p2q2/(3*p1q1*p2q1)+
44265  &32*a1*a2*mt**2*p1p2*p2q2/(3*p1q1*p2q1)+
44266  &64*a1*a2*p1p2**2*p2q2/(3*p1q1*p2q1)-944*a1*a2*p1q1*p2q2/(3*p2q1)-
44267  &32*a2**2*p1q1*p2q2/p2q1+256*a1*mb*mt**3*p2q2/(3*p1q2**2*p2q1)+
44268  &512*a1*mt**2*p1p2*p2q2/(3*p1q2**2*p2q1)+
44269  &256*a1*mt**2*p1q1*p2q2/(3*p1q2**2*p2q1)-8*p2q2/(3*p1q2*p2q1)-
44270  &200*a1*mb*mt*p2q2/(3*p1q2*p2q1)-56*a2*mb*mt*p2q2/(3*p1q2*p2q1)+
44271  &272*a1*mt**2*p2q2/(3*p1q2*p2q1)+160*a2*mt**2*p2q2/(3*p1q2*p2q1)+
44272  &256*a1*p1p2*p2q2/(3*p1q2*p2q1)+48*a2*p1p2*p2q2/(p1q2*p2q1)
44273  v18=v18-256*a1*a2*mb*mt*p1p2*p2q2/(p1q2*p2q1)-
44274  &256*a1*a2*mt**2*p1p2*p2q2/(3*p1q2*p2q1)-
44275  &1024*a1*a2*p1p2**2*p2q2/(3*p1q2*p2q1)-
44276  &32*a1*mt**2*p1p2*p2q2/(3*p1q1*p1q2*p2q1)+
44277  &96*a1*p1q1*p2q2/(p1q2*p2q1)+96*a2*p1q1*p2q2/(p1q2*p2q1)-
44278  &128*a1*a2*mb**2*p1q1*p2q2/(3*p1q2*p2q1)-
44279  &256*a1*a2*mb*mt*p1q1*p2q2/(p1q2*p2q1)-
44280  &128*a1*a2*mt**2*p1q1*p2q2/(3*p1q2*p2q1)-
44281  &512*a1*a2*p1p2*p1q1*p2q2/(p1q2*p2q1)-
44282  &512*a1*a2*p1q1**2*p2q2/(3*p1q2*p2q1)-544*a1*a2*p1q2*p2q2/(3*p2q1)-
44283  &640*a2**2*p1q2*p2q2/(3*p2q1)+
44284  &64*a1*a2*p1p2*p1q2*p2q2/(3*p1q1*p2q1)+544*a1*a2*p2q2**2/(3*p2q1)-
44285  &256*a1*mt**2*p2q2**2/(3*p1q2**2*p2q1)-
44286  &272*a1*p2q2**2/(3*p1q2*p2q1)+
44287  &256*a1*a2*mb*mt*p2q2**2/(3*p1q2*p2q1)+
44288  &256*a1*a2*mt**2*p2q2**2/(3*p1q2*p2q1)+
44289  &512*a1*a2*p1p2*p2q2**2/(3*p1q2*p2q1)
44290  v18=v18+512*a1*a2*p1q1*p2q2**2/(3*p1q2*p2q1)+
44291  &384*a12*mb*mt*p1q1**2/s**2+
44292  &384*a12*p1p2*p1q1**2/s**2+2688*a12*mb*mt*p1q1*p1q2/s**2+
44293  &2688*a12*p1p2*p1q1*p1q2/s**2+384*a12*mb*mt*p1q2**2/s**2+
44294  &384*a12*p1p2*p1q2**2/s**2+768*a1*a2*mb*mt*p1q1*p2q1/s**2+
44295  &768*a1*a2*p1p2*p1q1*p2q1/s**2+2688*a1*a2*mb*mt*p1q2*p2q1/s**2+
44296  &2688*a1*a2*p1p2*p1q2*p2q1/s**2-960*a12*p1q1*p1q2*p2q1/s**2-
44297  &960*a1*a2*p1q1*p1q2*p2q1/s**2+960*a12*p1q2**2*p2q1/s**2+
44298  &960*a1*a2*p1q2**2*p2q1/s**2+384*a2**2*mb*mt*p2q1**2/s**2+
44299  &384*a2**2*p1p2*p2q1**2/s**2-960*a1*a2*p1q2*p2q1**2/s**2-
44300  &960*a2**2*p1q2*p2q1**2/s**2+2688*a1*a2*mb*mt*p1q1*p2q2/s**2+
44301  &2688*a1*a2*p1p2*p1q1*p2q2/s**2+960*a12*p1q1**2*p2q2/s**2+
44302  &960*a1*a2*p1q1**2*p2q2/s**2+768*a1*a2*mb*mt*p1q2*p2q2/s**2+
44303  &768*a1*a2*p1p2*p1q2*p2q2/s**2-960*a12*p1q1*p1q2*p2q2/s**2-
44304  &960*a1*a2*p1q1*p1q2*p2q2/s**2+2688*a2**2*mb*mt*p2q1*p2q2/s**2+
44305  &2688*a2**2*p1p2*p2q1*p2q2/s**2+960*a1*a2*p1q1*p2q1*p2q2/s**2+
44306  &960*a2**2*p1q1*p2q1*p2q2/s**2+960*a1*a2*p1q2*p2q1*p2q2/s**2+
44307  &960*a2**2*p1q2*p2q1*p2q2/s**2+384*a2**2*mb*mt*p2q2**2/s**2
44308  v18=v18+384*a2**2*p1p2*p2q2**2/s**2-960*a1*a2*p1q1*p2q2**2/s**2-
44309  &960*a2**2*p1q1*p2q2**2/s**2+96*a1*mb*mt/s+96*a2*mb*mt/s-
44310  &768*a2**2*mb**3*mt/s-768*a12*mb*mt**3/s-192*a1*p1p2/s-
44311  &192*a2*p1p2/s-768*a2**2*mb**2*p1p2/s-2304*a1*a2*mb*mt*p1p2/s-
44312  &768*a12*mt**2*p1p2/s-2304*a1*a2*p1p2**2/s-
44313  &96*a1*mb*mt**3/(p1q1*s)-192*a2*mb*mt*p1p2/(p1q1*s)-
44314  &96*a1*mt**2*p1p2/(p1q1*s)-192*a2*p1p2**2/(p1q1*s)-192*a1*p1q1/s-
44315  &144*a2*p1q1/s-384*a1*a2*mb**2*p1q1/s-480*a2**2*mb**2*p1q1/s-
44316  &480*a12*mb*mt*p1q1/s+96*a1*a2*mb*mt*p1q1/s-
44317  &864*a12*p1p2*p1q1/s-672*a1*a2*p1p2*p1q1/s-96*a1*a2*p1q1**2/s-
44318  &96*a1*mb*mt**3/(p1q2*s)-192*a2*mb*mt*p1p2/(p1q2*s)-
44319  &96*a1*mt**2*p1p2/(p1q2*s)-192*a2*p1p2**2/(p1q2*s)-
44320  &48*a1*mb*mt*p1q1/(p1q2*s)+96*a2*mb*mt*p1q1/(p1q2*s)-
44321  &48*a1*mt**2*p1q1/(p1q2*s)-192*a1*p1p2*p1q1/(p1q2*s)-
44322  &192*a2*p1p2*p1q1/(p1q2*s)+192*a1*a2*mb*mt*p1p2*p1q1/(p1q2*s)+
44323  &192*a1*a2*p1p2**2*p1q1/(p1q2*s)-192*a1*p1q1**2/(p1q2*s)-
44324  &192*a2*p1q1**2/(p1q2*s)+192*a1*a2*mb**2*p1q1**2/(p1q2*s)
44325  v18=v18-192*a12*mb*mt*p1q1**2/(p1q2*s)+
44326  &96*a1*a2*mb*mt*p1q1**2/(p1q2*s)+
44327  &192*a1*a2*p1p2*p1q1**2/(p1q2*s)-192*a1*p1q2/s-144*a2*p1q2/s-
44328  &384*a1*a2*mb**2*p1q2/s-480*a2**2*mb**2*p1q2/s-
44329  &480*a12*mb*mt*p1q2/s+96*a1*a2*mb*mt*p1q2/s-
44330  &864*a12*p1p2*p1q2/s-672*a1*a2*p1p2*p1q2/s-
44331  &48*a1*mb*mt*p1q2/(p1q1*s)+96*a2*mb*mt*p1q2/(p1q1*s)-
44332  &48*a1*mt**2*p1q2/(p1q1*s)-192*a1*p1p2*p1q2/(p1q1*s)-
44333  &192*a2*p1p2*p1q2/(p1q1*s)+192*a1*a2*mb*mt*p1p2*p1q2/(p1q1*s)+
44334  &192*a1*a2*p1p2**2*p1q2/(p1q1*s)-576*a1*a2*p1q1*p1q2/s-
44335  &96*a1*a2*p1q2**2/s-192*a1*p1q2**2/(p1q1*s)-
44336  &192*a2*p1q2**2/(p1q1*s)+192*a1*a2*mb**2*p1q2**2/(p1q1*s)-
44337  &192*a12*mb*mt*p1q2**2/(p1q1*s)+96*a1*a2*mb*mt*p1q2**2/(p1q1*s)+
44338  &192*a1*a2*p1p2*p1q2**2/(p1q1*s)+96*a2*mb**3*mt/(p2q1*s)+
44339  &96*a2*mb**2*p1p2/(p2q1*s)+192*a1*mb*mt*p1p2/(p2q1*s)+
44340  &192*a1*p1p2**2/(p2q1*s)+96*a1*mb**2*p1q1/(p2q1*s)+
44341  &192*a2*mb**2*p1q1/(p2q1*s)+96*a1*mb*mt*p1q1/(p2q1*s)+
44342  &192*a1*a2*mb**3*mt*p1q1/(p2q1*s)+192*a1*p1p2*p1q1/(p2q1*s)
44343  v18=v18+192*a1*a2*mb**2*p1p2*p1q1/(p2q1*s)+
44344  &96*a1*a2*mb**2*p1q1**2/(p2q1*s)+
44345  &192*a2*mb**3*mt*p1q1/(p1q2*p2q1*s)+
44346  &192*a2*mb**2*p1p2*p1q1/(p1q2*p2q1*s)+
44347  &96*a1*mb*mt*p1p2*p1q1/(p1q2*p2q1*s)+
44348  &96*a1*p1p2**2*p1q1/(p1q2*p2q1*s)+
44349  &96*a1*mb**2*p1q1**2/(p1q2*p2q1*s)+
44350  &192*a2*mb**2*p1q1**2/(p1q2*p2q1*s)+
44351  &48*a1*mb*mt*p1q1**2/(p1q2*p2q1*s)+
44352  &96*a1*p1p2*p1q1**2/(p1q2*p2q1*s)+96*a1*mb**2*p1q2/(p2q1*s)+
44353  &48*a2*mb**2*p1q2/(p2q1*s)-192*a1*a2*mb**3*mt*p1q2/(p2q1*s)-
44354  &192*a1*a2*mb**2*p1p2*p1q2/(p2q1*s)-
44355  &96*a1*a2*mb**2*p1q2**2/(p2q1*s)+144*a1*p2q1/s+192*a2*p2q1/s-
44356  &96*a1*a2*mb*mt*p2q1/s+480*a2**2*mb*mt*p2q1/s+
44357  &480*a12*mt**2*p2q1/s+384*a1*a2*mt**2*p2q1/s+
44358  &672*a1*a2*p1p2*p2q1/s+864*a2**2*p1p2*p2q1/s+
44359  &96*a2*mb*mt*p2q1/(p1q1*s)+192*a1*mt**2*p2q1/(p1q1*s)
44360  v18=v18+96*a2*mt**2*p2q1/(p1q1*s)+
44361  &192*a1*a2*mb*mt**3*p2q1/(p1q1*s)+
44362  &192*a2*p1p2*p2q1/(p1q1*s)+192*a1*a2*mt**2*p1p2*p2q1/(p1q1*s)-
44363  &192*a12*p1q1*p2q1/s-192*a2**2*p1q1*p2q1/s+
44364  &48*a1*mt**2*p2q1/(p1q2*s)+96*a2*mt**2*p2q1/(p1q2*s)-
44365  &192*a1*a2*mb*mt**3*p2q1/(p1q2*s)-
44366  &192*a1*a2*mt**2*p1p2*p2q1/(p1q2*s)-
44367  &96*a1*a2*mb*mt*p1q1*p2q1/(p1q2*s)-
44368  &192*a12*mt**2*p1q1*p2q1/(p1q2*s)-
44369  &96*a1*a2*mt**2*p1q1*p2q1/(p1q2*s)-
44370  &384*a1*a2*p1p2*p1q1*p2q1/(p1q2*s)-384*a12*p1q1**2*p2q1/(p1q2*s)-
44371  &384*a1*a2*p1q1**2*p2q1/(p1q2*s)-480*a12*p1q2*p2q1/s-
44372  &960*a1*a2*p1q2*p2q1/s-480*a2**2*p1q2*p2q1/s+
44373  &144*a1*p1q2*p2q1/(p1q1*s)+96*a2*p1q2*p2q1/(p1q1*s)-
44374  &384*a1*a2*mb*mt*p1q2*p2q1/(p1q1*s)-
44375  &96*a12*mt**2*p1q2*p2q1/(p1q1*s)+
44376  &96*a1*a2*mt**2*p1q2*p2q1/(p1q1*s)-
44377  &576*a1*a2*p1p2*p1q2*p2q1/(p1q1*s)-192*a12*p1q2**2*p2q1/(p1q1*s)
44378  v18=v18-384*a1*a2*p1q2**2*p2q1/(p1q1*s)-96*a1*a2*p2q1**2/s-
44379  &96*a1*a2*mt**2*p2q1**2/(p1q1*s)+96*a1*a2*mt**2*p2q1**2/(p1q2*s)+
44380  &288*a1*a2*p1q2*p2q1**2/(p1q1*s)+96*a2*mb**3*mt/(p2q2*s)+
44381  &96*a2*mb**2*p1p2/(p2q2*s)+192*a1*mb*mt*p1p2/(p2q2*s)+
44382  &192*a1*p1p2**2/(p2q2*s)+96*a1*mb**2*p1q1/(p2q2*s)+
44383  &48*a2*mb**2*p1q1/(p2q2*s)-192*a1*a2*mb**3*mt*p1q1/(p2q2*s)-
44384  &192*a1*a2*mb**2*p1p2*p1q1/(p2q2*s)-
44385  &96*a1*a2*mb**2*p1q1**2/(p2q2*s)+96*a1*mb**2*p1q2/(p2q2*s)+
44386  &192*a2*mb**2*p1q2/(p2q2*s)+96*a1*mb*mt*p1q2/(p2q2*s)+
44387  &192*a1*a2*mb**3*mt*p1q2/(p2q2*s)+192*a1*p1p2*p1q2/(p2q2*s)+
44388  &192*a1*a2*mb**2*p1p2*p1q2/(p2q2*s)+
44389  &192*a2*mb**3*mt*p1q2/(p1q1*p2q2*s)+
44390  &192*a2*mb**2*p1p2*p1q2/(p1q1*p2q2*s)+
44391  &96*a1*mb*mt*p1p2*p1q2/(p1q1*p2q2*s)+
44392  &96*a1*p1p2**2*p1q2/(p1q1*p2q2*s)+96*a1*a2*mb**2*p1q2**2/(p2q2*s)+
44393  &96*a1*mb**2*p1q2**2/(p1q1*p2q2*s)+
44394  &192*a2*mb**2*p1q2**2/(p1q1*p2q2*s)
44395  v18=v18+48*a1*mb*mt*p1q2**2/(p1q1*p2q2*s)+
44396  &96*a1*p1p2*p1q2**2/(p1q1*p2q2*s)-48*a2*mb**2*p2q1/(p2q2*s)+
44397  &96*a1*mb*mt*p2q1/(p2q2*s)-48*a2*mb*mt*p2q1/(p2q2*s)-
44398  &192*a1*p1p2*p2q1/(p2q2*s)-192*a2*p1p2*p2q1/(p2q2*s)+
44399  &192*a1*a2*mb*mt*p1p2*p2q1/(p2q2*s)+
44400  &192*a1*a2*p1p2**2*p2q1/(p2q2*s)-
44401  &192*a1*mb*mt**3*p2q1/(p1q1*p2q2*s)-
44402  &96*a2*mb*mt*p1p2*p2q1/(p1q1*p2q2*s)-
44403  &192*a1*mt**2*p1p2*p2q1/(p1q1*p2q2*s)-
44404  &96*a2*p1p2**2*p2q1/(p1q1*p2q2*s)+
44405  &96*a1*a2*mb**2*p1q1*p2q1/(p2q2*s)+
44406  &192*a2**2*mb**2*p1q1*p2q1/(p2q2*s)+
44407  &96*a1*a2*mb*mt*p1q1*p2q1/(p2q2*s)+
44408  &384*a1*a2*p1p2*p1q1*p2q1/(p2q2*s)-96*a1*p1q2*p2q1/(p2q2*s)-
44409  &144*a2*p1q2*p2q1/(p2q2*s)-96*a1*a2*mb**2*p1q2*p2q1/(p2q2*s)+
44410  &96*a2**2*mb**2*p1q2*p2q1/(p2q2*s)+
44411  &384*a1*a2*mb*mt*p1q2*p2q1/(p2q2*s)
44412  v18=v18+576*a1*a2*p1p2*p1q2*p2q1/(p2q2*s)-
44413  &96*a2*mb**2*p1q2*p2q1/(p1q1*p2q2*s)+
44414  &48*a1*mb*mt*p1q2*p2q1/(p1q1*p2q2*s)+
44415  &48*a2*mb*mt*p1q2*p2q1/(p1q1*p2q2*s)-
44416  &96*a1*mt**2*p1q2*p2q1/(p1q1*p2q2*s)-
44417  &96*a1*p1p2*p1q2*p2q1/(p1q1*p2q2*s)-
44418  &96*a2*p1p2*p1q2*p2q1/(p1q1*p2q2*s)+
44419  &96*a1*a2*p1q1*p1q2*p2q1/(p2q2*s)+288*a1*a2*p1q2**2*p2q1/(p2q2*s)-
44420  &96*a1*p1q2**2*p2q1/(p1q1*p2q2*s)-96*a2*p1q2**2*p2q1/(p1q1*p2q2*s)+
44421  &192*a1*p2q1**2/(p2q2*s)+192*a2*p2q1**2/(p2q2*s)-
44422  &96*a1*a2*mb*mt*p2q1**2/(p2q2*s)+192*a2**2*mb*mt*p2q1**2/(p2q2*s)-
44423  &192*a1*a2*mt**2*p2q1**2/(p2q2*s)-192*a1*a2*p1p2*p2q1**2/(p2q2*s)+
44424  &48*a2*mb*mt*p2q1**2/(p1q1*p2q2*s)+
44425  &192*a1*mt**2*p2q1**2/(p1q1*p2q2*s)+
44426  &96*a2*mt**2*p2q1**2/(p1q1*p2q2*s)+
44427  &96*a2*p1p2*p2q1**2/(p1q1*p2q2*s)-384*a1*a2*p1q1*p2q1**2/(p2q2*s)-
44428  &384*a2**2*p1q1*p2q1**2/(p2q2*s)-384*a1*a2*p1q2*p2q1**2/(p2q2*s)
44429  v18=v18-192*a2**2*p1q2*p2q1**2/(p2q2*s)+
44430  &96*a1*p1q2*p2q1**2/(p1q1*p2q2*s)+
44431  &96*a2*p1q2*p2q1**2/(p1q1*p2q2*s)+144*a1*p2q2/s+192*a2*p2q2/s-
44432  &96*a1*a2*mb*mt*p2q2/s+480*a2**2*mb*mt*p2q2/s+
44433  &480*a12*mt**2*p2q2/s+384*a1*a2*mt**2*p2q2/s+
44434  &672*a1*a2*p1p2*p2q2/s+864*a2**2*p1p2*p2q2/s+
44435  &48*a1*mt**2*p2q2/(p1q1*s)+96*a2*mt**2*p2q2/(p1q1*s)-
44436  &192*a1*a2*mb*mt**3*p2q2/(p1q1*s)-
44437  &192*a1*a2*mt**2*p1p2*p2q2/(p1q1*s)-480*a12*p1q1*p2q2/s-
44438  &960*a1*a2*p1q1*p2q2/s-480*a2**2*p1q1*p2q2/s+
44439  &96*a2*mb*mt*p2q2/(p1q2*s)+192*a1*mt**2*p2q2/(p1q2*s)+
44440  &96*a2*mt**2*p2q2/(p1q2*s)+192*a1*a2*mb*mt**3*p2q2/(p1q2*s)+
44441  &192*a2*p1p2*p2q2/(p1q2*s)+192*a1*a2*mt**2*p1p2*p2q2/(p1q2*s)+
44442  &144*a1*p1q1*p2q2/(p1q2*s)+96*a2*p1q1*p2q2/(p1q2*s)-
44443  &384*a1*a2*mb*mt*p1q1*p2q2/(p1q2*s)-
44444  &96*a12*mt**2*p1q1*p2q2/(p1q2*s)+
44445  &96*a1*a2*mt**2*p1q1*p2q2/(p1q2*s)
44446  v18=v18-576*a1*a2*p1p2*p1q1*p2q2/(p1q2*s)-
44447  &192*a12*p1q1**2*p2q2/(p1q2*s)-
44448  &384*a1*a2*p1q1**2*p2q2/(p1q2*s)-192*a12*p1q2*p2q2/s-
44449  &192*a2**2*p1q2*p2q2/s-96*a1*a2*mb*mt*p1q2*p2q2/(p1q1*s)-
44450  &192*a12*mt**2*p1q2*p2q2/(p1q1*s)-
44451  &96*a1*a2*mt**2*p1q2*p2q2/(p1q1*s)-
44452  &384*a1*a2*p1p2*p1q2*p2q2/(p1q1*s)-384*a12*p1q2**2*p2q2/(p1q1*s)-
44453  &384*a1*a2*p1q2**2*p2q2/(p1q1*s)-48*a2*mb**2*p2q2/(p2q1*s)+
44454  &96*a1*mb*mt*p2q2/(p2q1*s)-48*a2*mb*mt*p2q2/(p2q1*s)-
44455  &192*a1*p1p2*p2q2/(p2q1*s)-192*a2*p1p2*p2q2/(p2q1*s)+
44456  &192*a1*a2*mb*mt*p1p2*p2q2/(p2q1*s)+
44457  &192*a1*a2*p1p2**2*p2q2/(p2q1*s)-96*a1*p1q1*p2q2/(p2q1*s)-
44458  &144*a2*p1q1*p2q2/(p2q1*s)-96*a1*a2*mb**2*p1q1*p2q2/(p2q1*s)+
44459  &96*a2**2*mb**2*p1q1*p2q2/(p2q1*s)+
44460  &384*a1*a2*mb*mt*p1q1*p2q2/(p2q1*s)+
44461  &576*a1*a2*p1p2*p1q1*p2q2/(p2q1*s)+288*a1*a2*p1q1**2*p2q2/(p2q1*s)-
44462  &192*a1*mb*mt**3*p2q2/(p1q2*p2q1*s)
44463  v18=v18-96*a2*mb*mt*p1p2*p2q2/(p1q2*p2q1*s)-
44464  &192*a1*mt**2*p1p2*p2q2/(p1q2*p2q1*s)-
44465  &96*a2*p1p2**2*p2q2/(p1q2*p2q1*s)-
44466  &96*a2*mb**2*p1q1*p2q2/(p1q2*p2q1*s)+
44467  &48*a1*mb*mt*p1q1*p2q2/(p1q2*p2q1*s)
44468 
44469  v18bis=
44470  &48*a2*mb*mt*p1q1*p2q2/(p1q2*p2q1*s)-
44471  &96*a1*mt**2*p1q1*p2q2/(p1q2*p2q1*s)-
44472  &96*a1*p1p2*p1q1*p2q2/(p1q2*p2q1*s)-
44473  &96*a2*p1p2*p1q1*p2q2/(p1q2*p2q1*s)-
44474  &96*a1*p1q1**2*p2q2/(p1q2*p2q1*s)-96*a2*p1q1**2*p2q2/(p1q2*p2q1*s)+
44475  &96*a1*a2*mb**2*p1q2*p2q2/(p2q1*s)+
44476  &192*a2**2*mb**2*p1q2*p2q2/(p2q1*s)+
44477  &96*a1*a2*mb*mt*p1q2*p2q2/(p2q1*s)+
44478  &384*a1*a2*p1p2*p1q2*p2q2/(p2q1*s)+
44479  &96*a1*a2*p1q1*p1q2*p2q2/(p2q1*s)-576*a1*a2*p2q1*p2q2/s+
44480  &96*a1*a2*p1q1*p2q1*p2q2/(p1q2*s)+96*a1*a2*p1q2*p2q1*p2q2/(p1q1*s)-
44481  &96*a1*a2*p2q2**2/s+96*a1*a2*mt**2*p2q2**2/(p1q1*s)-
44482  &96*a1*a2*mt**2*p2q2**2/(p1q2*s)+288*a1*a2*p1q1*p2q2**2/(p1q2*s)+
44483  &192*a1*p2q2**2/(p2q1*s)+192*a2*p2q2**2/(p2q1*s)-
44484  &96*a1*a2*mb*mt*p2q2**2/(p2q1*s)+192*a2**2*mb*mt*p2q2**2/(p2q1*s)-
44485  &192*a1*a2*mt**2*p2q2**2/(p2q1*s)-192*a1*a2*p1p2*p2q2**2/(p2q1*s)
44486  v18bis=v18bis-384*a1*a2*p1q1*p2q2**2/(p2q1*s)-
44487  &192*a2**2*p1q1*p2q2**2/(p2q1*s)+
44488  &48*a2*mb*mt*p2q2**2/(p1q2*p2q1*s)+
44489  &192*a1*mt**2*p2q2**2/(p1q2*p2q1*s)+
44490  &96*a2*mt**2*p2q2**2/(p1q2*p2q1*s)+
44491  &96*a2*p1p2*p2q2**2/(p1q2*p2q1*s)+96*a1*p1q1*p2q2**2/(p1q2*p2q1*s)+
44492  &96*a2*p1q1*p2q2**2/(p1q2*p2q1*s)-384*a1*a2*p1q2*p2q2**2/(p2q1*s)-
44493  &384*a2**2*p1q2*p2q2**2/(p2q1*s)+512*a1*a2*s/3-
44494  &128*a1*mt**2*s/(3*p1q1**2)-128*a12*mb*mt**3*s/(3*p1q1**2)-
44495  &152*a1*s/(3*p1q1)+152*a12*mb*mt*s/(3*p1q1)+
44496  &128*a1*a2*mb*mt*s/(3*p1q1)+112*a1*a2*mt**2*s/(3*p1q1)-
44497  &16*a12*p1p2*s/p1q1+152*a1*a2*p1p2*s/(3*p1q1)-
44498  &128*a1*mt**2*s/(3*p1q2**2)-128*a12*mb*mt**3*s/(3*p1q2**2)-
44499  &152*a1*s/(3*p1q2)+152*a12*mb*mt*s/(3*p1q2)+
44500  &128*a1*a2*mb*mt*s/(3*p1q2)+112*a1*a2*mt**2*s/(3*p1q2)-
44501  &16*a12*p1p2*s/p1q2+152*a1*a2*p1p2*s/(3*p1q2)-
44502  &16*a1*mb*mt*s/(3*p1q1*p1q2)+32*a12*mb*mt**3*s/(3*p1q1*p1q2)
44503  v18bis=v18bis-16*a1*p1p2*s/(3*p1q1*p1q2)+
44504  &272*a1*a2*p1q1*s/(3*p1q2)+
44505  &272*a1*a2*p1q2*s/(3*p1q1)-128*a2*mb**2*s/(3*p2q1**2)-
44506  &128*a2**2*mb**3*mt*s/(3*p2q1**2)+
44507  &32*mb**2*mt**2*s/(3*p1q2**2*p2q1**2)+32*mb**2*s/(3*p1q2*p2q1**2)-
44508  &64*a2*mb**3*mt*s/(3*p1q2*p2q1**2)-
44509  &64*a2*mb**2*mt**2*s/(3*p1q2*p2q1**2)-
44510  &128*a2*mb**2*p1p2*s/(3*p1q2*p2q1**2)-
44511  &128*a2*mb**2*p1q1*s/(3*p1q2*p2q1**2)+
44512  &128*a2**2*mb**2*p1q2*s/(3*p2q1**2)+152*a2*s/(3*p2q1)-
44513  &112*a1*a2*mb**2*s/(3*p2q1)-128*a1*a2*mb*mt*s/(3*p2q1)-
44514  &152*a2**2*mb*mt*s/(3*p2q1)-152*a1*a2*p1p2*s/(3*p2q1)+
44515  &16*a2**2*p1p2*s/p2q1+8*a1*a2*mb**3*mt*s/(3*p1q1*p2q1)+
44516  &16*a1*a2*mb**2*mt**2*s/(3*p1q1*p2q1)+
44517  &8*a1*a2*mb*mt**3*s/(3*p1q1*p2q1)-8*a1*p1p2*s/(3*p1q1*p2q1)-
44518  &8*a2*p1p2*s/(3*p1q1*p2q1)+8*a1*a2*mb**2*p1p2*s/(3*p1q1*p2q1)+
44519  &16*a1*a2*mb*mt*p1p2*s/(3*p1q1*p2q1)
44520  v18bis=v18bis+8*a1*a2*mt**2*p1p2*s/(3*p1q1*p2q1)+
44521  &32*a1*a2*p1p2**2*s/(3*p1q1*p2q1)-32*a2**2*p1q1*s/(3*p2q1)-
44522  &32*mt**2*s/(3*p1q2**2*p2q1)+64*a1*mb**2*mt**2*s/(3*p1q2**2*p2q1)+
44523  &64*a1*mb*mt**3*s/(3*p1q2**2*p2q1)+
44524  &128*a1*mt**2*p1p2*s/(3*p1q2**2*p2q1)-12*s/(p1q2*p2q1)+
44525  &24*a1*mb**2*s/(p1q2*p2q1)-64*a1*a2*mb**3*mt*s/(3*p1q2*p2q1)+
44526  &24*a2*mt**2*s/(p1q2*p2q1)-128*a1*a2*mb**2*mt**2*s/(3*p1q2*p2q1)-
44527  &64*a1*a2*mb*mt**3*s/(3*p1q2*p2q1)+56*a1*p1p2*s/(3*p1q2*p2q1)+
44528  &56*a2*p1p2*s/(3*p1q2*p2q1)-64*a1*a2*mb**2*p1p2*s/(3*p1q2*p2q1)-
44529  &128*a1*a2*mb*mt*p1p2*s/(3*p1q2*p2q1)-
44530  &64*a1*a2*mt**2*p1p2*s/(3*p1q2*p2q1)-
44531  &256*a1*a2*p1p2**2*s/(3*p1q2*p2q1)+4*p1p2*s/(3*p1q1*p1q2*p2q1)+
44532  &8*a1*mb*mt*p1p2*s/(3*p1q1*p1q2*p2q1)-
44533  &8*a1*mt**2*p1p2*s/(3*p1q1*p1q2*p2q1)+136*a2*p1q1*s/(3*p1q2*p2q1)-
44534  &128*a1*a2*mb**2*p1q1*s/(3*p1q2*p2q1)-
44535  &128*a1*a2*mb*mt*p1q1*s/(3*p1q2*p2q1)-
44536  &256*a1*a2*p1p2*p1q1*s/(3*p1q2*p2q1)-160*a2**2*p1q2*s/(3*p2q1)
44537  v18bis=v18bis+16*a1*a2*p1p2*p1q2*s/(3*p1q1*p2q1)-
44538  &32*a12*p2q1*s/(3*p1q1)-
44539  &128*a12*mt**2*p2q1*s/(3*p1q2**2)-160*a12*p2q1*s/(3*p1q2)-
44540  &128*a2*mb**2*s/(3*p2q2**2)-128*a2**2*mb**3*mt*s/(3*p2q2**2)+
44541  &32*mb**2*mt**2*s/(3*p1q1**2*p2q2**2)+32*mb**2*s/(3*p1q1*p2q2**2)-
44542  &64*a2*mb**3*mt*s/(3*p1q1*p2q2**2)-
44543  &64*a2*mb**2*mt**2*s/(3*p1q1*p2q2**2)-
44544  &128*a2*mb**2*p1p2*s/(3*p1q1*p2q2**2)+
44545  &128*a2**2*mb**2*p1q1*s/(3*p2q2**2)-
44546  &128*a2*mb**2*p1q2*s/(3*p1q1*p2q2**2)+152*a2*s/(3*p2q2)-
44547  &112*a1*a2*mb**2*s/(3*p2q2)-128*a1*a2*mb*mt*s/(3*p2q2)-
44548  &152*a2**2*mb*mt*s/(3*p2q2)-152*a1*a2*p1p2*s/(3*p2q2)+
44549  &16*a2**2*p1p2*s/p2q2-32*mt**2*s/(3*p1q1**2*p2q2)+
44550  &64*a1*mb**2*mt**2*s/(3*p1q1**2*p2q2)+
44551  &64*a1*mb*mt**3*s/(3*p1q1**2*p2q2)+
44552  &128*a1*mt**2*p1p2*s/(3*p1q1**2*p2q2)-12*s/(p1q1*p2q2)+
44553  &24*a1*mb**2*s/(p1q1*p2q2)-64*a1*a2*mb**3*mt*s/(3*p1q1*p2q2)
44554  v18bis=v18bis+24*a2*mt**2*s/(p1q1*p2q2)-
44555  &128*a1*a2*mb**2*mt**2*s/(3*p1q1*p2q2)-
44556  &64*a1*a2*mb*mt**3*s/(3*p1q1*p2q2)+56*a1*p1p2*s/(3*p1q1*p2q2)+
44557  &56*a2*p1p2*s/(3*p1q1*p2q2)-64*a1*a2*mb**2*p1p2*s/(3*p1q1*p2q2)-
44558  &128*a1*a2*mb*mt*p1p2*s/(3*p1q1*p2q2)-
44559  &64*a1*a2*mt**2*p1p2*s/(3*p1q1*p2q2)-
44560  &256*a1*a2*p1p2**2*s/(3*p1q1*p2q2)-160*a2**2*p1q1*s/(3*p2q2)+
44561  &8*a1*a2*mb**3*mt*s/(3*p1q2*p2q2)+
44562  &16*a1*a2*mb**2*mt**2*s/(3*p1q2*p2q2)+
44563  &8*a1*a2*mb*mt**3*s/(3*p1q2*p2q2)-8*a1*p1p2*s/(3*p1q2*p2q2)-
44564  &8*a2*p1p2*s/(3*p1q2*p2q2)+8*a1*a2*mb**2*p1p2*s/(3*p1q2*p2q2)+
44565  &16*a1*a2*mb*mt*p1p2*s/(3*p1q2*p2q2)+
44566  &8*a1*a2*mt**2*p1p2*s/(3*p1q2*p2q2)+
44567  &32*a1*a2*p1p2**2*s/(3*p1q2*p2q2)+4*p1p2*s/(3*p1q1*p1q2*p2q2)+
44568  &8*a1*mb*mt*p1p2*s/(3*p1q1*p1q2*p2q2)-
44569  &8*a1*mt**2*p1p2*s/(3*p1q1*p1q2*p2q2)+
44570  &16*a1*a2*p1p2*p1q1*s/(3*p1q2*p2q2)-32*a2**2*p1q2*s/(3*p2q2)
44571  v18bis=v18bis+136*a2*p1q2*s/(3*p1q1*p2q2)-
44572  &128*a1*a2*mb**2*p1q2*s/(3*p1q1*p2q2)-
44573  &128*a1*a2*mb*mt*p1q2*s/(3*p1q1*p2q2)-
44574  &256*a1*a2*p1p2*p1q2*s/(3*p1q1*p2q2)-16*a2*mb*mt*s/(3*p2q1*p2q2)+
44575  &32*a2**2*mb**3*mt*s/(3*p2q1*p2q2)-16*a2*p1p2*s/(3*p2q1*p2q2)-
44576  &4*p1p2*s/(3*p1q1*p2q1*p2q2)+8*a2*mb**2*p1p2*s/(3*p1q1*p2q1*p2q2)-
44577  &8*a2*mb*mt*p1p2*s/(3*p1q1*p2q1*p2q2)-4*p1p2*s/(3*p1q2*p2q1*p2q2)+
44578  &8*a2*mb**2*p1p2*s/(3*p1q2*p2q1*p2q2)-
44579  &8*a2*mb*mt*p1p2*s/(3*p1q2*p2q1*p2q2)+
44580  &2*mb**3*mt*s/(3*p1q1*p1q2*p2q1*p2q2)+
44581  &4*mb**2*mt**2*s/(3*p1q1*p1q2*p2q1*p2q2)+
44582  &2*mb*mt**3*s/(3*p1q1*p1q2*p2q1*p2q2)-
44583  &2*mb**2*p1p2*s/(3*p1q1*p1q2*p2q1*p2q2)-
44584  &4*mb*mt*p1p2*s/(3*p1q1*p1q2*p2q1*p2q2)-
44585  &2*mt**2*p1p2*s/(3*p1q1*p1q2*p2q1*p2q2)-
44586  &8*p1p2**2*s/(3*p1q1*p1q2*p2q1*p2q2)+
44587  &8*a2*p1p2*p1q1*s/(3*p1q2*p2q1*p2q2)
44588  v18bis=v18bis+8*a2*p1p2*p1q2*s/(3*p1q1*p2q1*p2q2)+
44589  &272*a1*a2*p2q1*s/(3*p2q2)-
44590  &128*a1*mt**2*p2q1*s/(3*p1q1**2*p2q2)-136*a1*p2q1*s/(3*p1q1*p2q2)+
44591  &128*a1*a2*mb*mt*p2q1*s/(3*p1q1*p2q2)+
44592  &128*a1*a2*mt**2*p2q1*s/(3*p1q1*p2q2)+
44593  &256*a1*a2*p1p2*p2q1*s/(3*p1q1*p2q2)-
44594  &16*a1*a2*p1p2*p2q1*s/(3*p1q2*p2q2)+
44595  &8*a1*p1p2*p2q1*s/(3*p1q1*p1q2*p2q2)+
44596  &256*a1*a2*p1q2*p2q1*s/(3*p1q1*p2q2)-
44597  &128*a12*mt**2*p2q2*s/(3*p1q1**2)-160*a12*p2q2*s/(3*p1q1)-
44598  &32*a12*p2q2*s/(3*p1q2)+272*a1*a2*p2q2*s/(3*p2q1)-
44599  &16*a1*a2*p1p2*p2q2*s/(3*p1q1*p2q1)-
44600  &128*a1*mt**2*p2q2*s/(3*p1q2**2*p2q1)-136*a1*p2q2*s/(3*p1q2*p2q1)+
44601  &128*a1*a2*mb*mt*p2q2*s/(3*p1q2*p2q1)+
44602  &128*a1*a2*mt**2*p2q2*s/(3*p1q2*p2q1)+
44603  &256*a1*a2*p1p2*p2q2*s/(3*p1q2*p2q1)+
44604  &8*a1*p1p2*p2q2*s/(3*p1q1*p1q2*p2q1)
44605  v18bis=v18bis+256*a1*a2*p1q1*p2q2*s/(3*p1q2*p2q1)+
44606  &8*a12*mb*mt*s**2/(3*p1q1*p1q2)+16*a12*p1p2*s**2/(3*p1q1*p1q2)-
44607  &8*a1*a2*p1p2*s**2/(3*p1q1*p2q1)+4*a1*p1p2*s**2/(3*p1q1*p1q2*p2q1)-
44608  &8*a1*a2*p1p2*s**2/(3*p1q2*p2q2)+4*a1*p1p2*s**2/(3*p1q1*p1q2*p2q2)+
44609  &8*a2**2*mb*mt*s**2/(3*p2q1*p2q2)+16*a2**2*p1p2*s**2/(3*p2q1*p2q2)-
44610  &4*a2*p1p2*s**2/(3*p1q1*p2q1*p2q2)-
44611  &4*a2*p1p2*s**2/(3*p1q2*p2q1*p2q2)+
44612  &2*p1p2*s**2/(3*p1q1*p1q2*p2q1*p2q2)
44613 C
44614 
44615  a18 = 640*a1/3+640*a2/3+32*a1*a2*mb**2+368*a12*mb*mt+
44616  &512*a1*a2*mb*mt/3+
44617  &368*a2**2*mb*mt+32*a1*a2*mt**2+496*a12*p1p2/3+
44618  &320*a1*a2*p1p2+496*a2**2*p1p2/3-128*a1*mb*mt**3/(3*p1q1**2)+
44619  &128*a1*mt**4/(3*p1q1**2)+256*a12*mb*mt**5/(3*p1q1**2)+
44620  &256*a1*mt**2*p1p2/(3*p1q1**2)-256*a12*mt**4*p1p2/(3*p1q1**2)+
44621  &8/(3*p1q1)+32*a1*mb*mt/p1q1+56*a2*mb*mt/(3*p1q1)+
44622  &88*a1*mt**2/(3*p1q1)+72*a2*mt**2/p1q1-
44623  &704*a12*mb*mt**3/(3*p1q1)+224*a1*a2*mb*mt**3/(3*p1q1)+
44624  &104*a1*p1p2/(3*p1q1)+48*a2*p1p2/p1q1-
44625  &128*a1*a2*mb*mt*p1p2/(3*p1q1)+512*a12*mt**2*p1p2/(3*p1q1)-
44626  &448*a1*a2*mt**2*p1p2/(3*p1q1)-32*a1*a2*p1p2**2/p1q1-
44627  &656*a1*a2*p1q1/3-224*a2**2*p1q1-128*a1*mb*mt**3/(3*p1q2**2)+
44628  &128*a1*mt**4/(3*p1q2**2)+256*a12*mb*mt**5/(3*p1q2**2)+
44629  &256*a1*mt**2*p1p2/(3*p1q2**2)-256*a12*mt**4*p1p2/(3*p1q2**2)+
44630  &256*a1*mt**2*p1q1/(3*p1q2**2)-256*a12*mb*mt**3*p1q1/(3*p1q2**2)+
44631  &8/(3*p1q2)+32*a1*mb*mt/p1q2+56*a2*mb*mt/(3*p1q2)
44632  a18=a18+88*a1*mt**2/(3*p1q2)+72*a2*mt**2/p1q2-
44633  &704*a12*mb*mt**3/(3*p1q2)+224*a1*a2*mb*mt**3/(3*p1q2)+
44634  &104*a1*p1p2/(3*p1q2)+48*a2*p1p2/p1q2-
44635  &128*a1*a2*mb*mt*p1p2/(3*p1q2)+512*a12*mt**2*p1p2/(3*p1q2)-
44636  &448*a1*a2*mt**2*p1p2/(3*p1q2)-32*a1*a2*p1p2**2/p1q2+
44637  &32*a1*mb*mt**3/(3*p1q1*p1q2)-32*a1*mt**4/(3*p1q1*p1q2)-
44638  &64*a12*mb*mt**5/(3*p1q1*p1q2)+16*p1p2/(3*p1q1*p1q2)-
44639  &64*a1*mt**2*p1p2/(3*p1q1*p1q2)+64*a12*mt**4*p1p2/(3*p1q1*p1q2)+
44640  &112*a1*p1q1/p1q2+272*a2*p1q1/(3*p1q2)-
44641  &272*a1*a2*mb**2*p1q1/(3*p1q2)-208*a12*mb*mt*p1q1/(3*p1q2)+
44642  &400*a1*a2*mb*mt*p1q1/(3*p1q2)-80*a1*a2*mt**2*p1q1/p1q2+
44643  &96*a12*p1p2*p1q1/p1q2-320*a1*a2*p1p2*p1q1/p1q2-
44644  &544*a1*a2*p1q1**2/(3*p1q2)-656*a1*a2*p1q2/3-224*a2**2*p1q2+
44645  &256*a1*mt**2*p1q2/(3*p1q1**2)-256*a12*mb*mt**3*p1q2/(3*p1q1**2)+
44646  &112*a1*p1q2/p1q1+272*a2*p1q2/(3*p1q1)-
44647  &272*a1*a2*mb**2*p1q2/(3*p1q1)-208*a12*mb*mt*p1q2/(3*p1q1)+
44648  &400*a1*a2*mb*mt*p1q2/(3*p1q1)-80*a1*a2*mt**2*p1q2/p1q1
44649  a18=a18+96*a12*p1p2*p1q2/p1q1-320*a1*a2*p1p2*p1q2/p1q1-
44650  &544*a1*a2*p1q2**2/(3*p1q1)+128*a2*mb**4/(3*p2q1**2)-
44651  &128*a2*mb**3*mt/(3*p2q1**2)+256*a2**2*mb**5*mt/(3*p2q1**2)+
44652  &256*a2*mb**2*p1p2/(3*p2q1**2)-256*a2**2*mb**4*p1p2/(3*p2q1**2)+
44653  &256*a2*mb**2*p1q1/(3*p2q1**2)-256*a2**2*mb**4*p1q1/(3*p2q1**2)+
44654  &64*mb**3*mt**3/(3*p1q2**2*p2q1**2)-
44655  &64*mb**2*mt**2*p1p2/(3*p1q2**2*p2q1**2)-
44656  &64*mb**2*mt**2*p1q1/(3*p1q2**2*p2q1**2)-
44657  &64*mb**3*mt/(3*p1q2*p2q1**2)-
44658  &256*a2*mb**3*mt*p1p2/(3*p1q2*p2q1**2)+
44659  &256*a2*mb**2*p1p2**2/(3*p1q2*p2q1**2)-
44660  &256*a2*mb**3*mt*p1q1/(3*p1q2*p2q1**2)+
44661  &512*a2*mb**2*p1p2*p1q1/(3*p1q2*p2q1**2)+
44662  &256*a2*mb**2*p1q1**2/(3*p1q2*p2q1**2)-
44663  &256*a2**2*mb**4*p1q2/(3*p2q1**2)-8/(3*p2q1)-72*a1*mb**2/p2q1-
44664  &88*a2*mb**2/(3*p2q1)-56*a1*mb*mt/(3*p2q1)-32*a2*mb*mt/p2q1-
44665  &224*a1*a2*mb**3*mt/(3*p2q1)+704*a2**2*mb**3*mt/(3*p2q1)
44666  a18=a18-48*a1*p1p2/p2q1-104*a2*p1p2/(3*p2q1)+
44667  &448*a1*a2*mb**2*p1p2/(3*p2q1)-512*a2**2*mb**2*p1p2/(3*p2q1)+
44668  &128*a1*a2*mb*mt*p1p2/(3*p2q1)+32*a1*a2*p1p2**2/p2q1-
44669  &16*p1p2/(3*p1q1*p2q1)+32*a1*mb*mt*p1p2/(3*p1q1*p2q1)+
44670  &32*a2*mb*mt*p1p2/(3*p1q1*p2q1)+
44671  &64*a1*a2*mb*mt*p1p2**2/(3*p1q1*p2q1)-
44672  &64*a1*a2*p1p2**3/(3*p1q1*p2q1)-256*a2*p1q1/(3*p2q1)+
44673  &448*a1*a2*mb**2*p1q1/(3*p2q1)-368*a2**2*mb**2*p1q1/(3*p2q1)-
44674  &224*a1*a2*mb*mt*p1q1/(3*p2q1)+304*a1*a2*p1p2*p1q1/(3*p2q1)+
44675  &64*mb*mt**3/(3*p1q2**2*p2q1)+
44676  &256*a1*mb*mt**3*p1p2/(3*p1q2**2*p2q1)-
44677  &256*a1*mt**2*p1p2**2/(3*p1q2**2*p2q1)+
44678  &64*mt**2*p1q1/(3*p1q2**2*p2q1)-
44679  &128*a1*mb**2*mt**2*p1q1/(3*p1q2**2*p2q1)+
44680  &128*a1*mb*mt**3*p1q1/(3*p1q2**2*p2q1)-
44681  &256*a1*mt**2*p1p2*p1q1/(3*p1q2**2*p2q1)-4*mb**2/(3*p1q2*p2q1)-
44682  &64*mb*mt/(3*p1q2*p2q1)+128*a2*mb**3*mt/(3*p1q2*p2q1)
44683  a18=a18-4*mt**2/(3*p1q2*p2q1)-128*a1*mb**2*mt**2/(3*p1q2*p2q1)-
44684  &128*a2*mb**2*mt**2/(3*p1q2*p2q1)+128*a1*mb*mt**3/(3*p1q2*p2q1)-
44685  &112*a2*mb**2*p1p2/(3*p1q2*p2q1)+32*a1*mb*mt*p1p2/(3*p1q2*p2q1)+
44686  &32*a2*mb*mt*p1p2/(3*p1q2*p2q1)-112*a1*mt**2*p1p2/(3*p1q2*p2q1)-
44687  &48*a1*p1p2**2/(p1q2*p2q1)-48*a2*p1p2**2/(p1q2*p2q1)-
44688  &512*a1*a2*mb*mt*p1p2**2/(3*p1q2*p2q1)+
44689  &512*a1*a2*p1p2**3/(3*p1q2*p2q1)+8*mb*mt*p1p2/(3*p1q1*p1q2*p2q1)-
44690  &8*mt**2*p1p2/(3*p1q1*p1q2*p2q1)-
44691  &32*a1*mb*mt**3*p1p2/(3*p1q1*p1q2*p2q1)-
44692  &16*p1p2**2/(3*p1q1*p1q2*p2q1)+
44693  &32*a1*mt**2*p1p2**2/(3*p1q1*p1q2*p2q1)+8*p1q1/(3*p1q2*p2q1)-
44694  &160*a1*mb**2*p1q1/(3*p1q2*p2q1)-272*a2*mb**2*p1q1/(3*p1q2*p2q1)-
44695  &56*a1*mb*mt*p1q1/(3*p1q2*p2q1)-200*a2*mb*mt*p1q1/(3*p1q2*p2q1)-
44696  &48*a1*p1p2*p1q1/(p1q2*p2q1)-256*a2*p1p2*p1q1/(3*p1q2*p2q1)+
44697  &256*a1*a2*mb**2*p1p2*p1q1/(3*p1q2*p2q1)-
44698  &256*a1*a2*mb*mt*p1p2*p1q1/(p1q2*p2q1)+
44699  &1024*a1*a2*p1p2**2*p1q1/(3*p1q2*p2q1)
44700  a18=a18-272*a2*p1q1**2/(3*p1q2*p2q1)+
44701  &256*a1*a2*mb**2*p1q1**2/(3*p1q2*p2q1)-
44702  &256*a1*a2*mb*mt*p1q1**2/(3*p1q2*p2q1)+
44703  &512*a1*a2*p1p2*p1q1**2/(3*p1q2*p2q1)+16*a2*p1q2/(3*p2q1)+
44704  &64*a1*a2*mb**2*p1q2/p2q1+32*a2**2*mb**2*p1q2/(3*p2q1)-
44705  &112*a1*a2*mb*mt*p1q2/(3*p2q1)+368*a1*a2*p1p2*p1q2/(3*p2q1)+
44706  &32*a2*p1p2*p1q2/(3*p1q1*p2q1)-
44707  &32*a1*a2*mb**2*p1p2*p1q2/(3*p1q1*p2q1)+
44708  &32*a1*a2*mb*mt*p1p2*p1q2/(3*p1q1*p2q1)-
44709  &64*a1*a2*p1p2**2*p1q2/(3*p1q1*p2q1)+224*a12*p2q1+
44710  &656*a1*a2*p2q1/3-256*a1*mt**2*p2q1/(3*p1q1**2)+
44711  &256*a12*mt**4*p2q1/(3*p1q1**2)-256*a1*p2q1/(3*p1q1)-
44712  &224*a1*a2*mb*mt*p2q1/(3*p1q1)-368*a12*mt**2*p2q1/(3*p1q1)+
44713  &448*a1*a2*mt**2*p2q1/(3*p1q1)+304*a1*a2*p1p2*p2q1/(3*p1q1)+
44714  &256*a12*mt**4*p2q1/(3*p1q2**2)+
44715  &256*a12*mt**2*p1q1*p2q1/(3*p1q2**2)+16*a1*p2q1/(3*p1q2)-
44716  &112*a1*a2*mb*mt*p2q1/(3*p1q2)+32*a12*mt**2*p2q1/(3*p1q2)
44717  a18=a18+64*a1*a2*mt**2*p2q1/p1q2+368*a1*a2*p1p2*p2q1/(3*p1q2)+
44718  &16*a1*mt**2*p2q1/(3*p1q1*p1q2)-64*a12*mt**4*p2q1/(3*p1q1*p1q2)+
44719  &640*a12*p1q1*p2q1/(3*p1q2)+544*a1*a2*p1q1*p2q1/(3*p1q2)+
44720  &32*a12*p1q2*p2q1/p1q1+944*a1*a2*p1q2*p2q1/(3*p1q1)+
44721  &128*a2*mb**4/(3*p2q2**2)-128*a2*mb**3*mt/(3*p2q2**2)+
44722  &256*a2**2*mb**5*mt/(3*p2q2**2)+256*a2*mb**2*p1p2/(3*p2q2**2)-
44723  &256*a2**2*mb**4*p1p2/(3*p2q2**2)+
44724  &64*mb**3*mt**3/(3*p1q1**2*p2q2**2)-
44725  &64*mb**2*mt**2*p1p2/(3*p1q1**2*p2q2**2)-
44726  &64*mb**3*mt/(3*p1q1*p2q2**2)-
44727  &256*a2*mb**3*mt*p1p2/(3*p1q1*p2q2**2)+
44728  &256*a2*mb**2*p1p2**2/(3*p1q1*p2q2**2)-
44729  &256*a2**2*mb**4*p1q1/(3*p2q2**2)+256*a2*mb**2*p1q2/(3*p2q2**2)-
44730  &256*a2**2*mb**4*p1q2/(3*p2q2**2)-
44731  &64*mb**2*mt**2*p1q2/(3*p1q1**2*p2q2**2)-
44732  &256*a2*mb**3*mt*p1q2/(3*p1q1*p2q2**2)+
44733  &512*a2*mb**2*p1p2*p1q2/(3*p1q1*p2q2**2)
44734  a18=a18+256*a2*mb**2*p1q2**2/(3*p1q1*p2q2**2)-
44735  &256*a2*mb**2*p2q1/(3*p2q2**2)+256*a2**2*mb**3*mt*p2q1/(3*p2q2**2)+
44736  &64*mb**2*mt**2*p2q1/(3*p1q1**2*p2q2**2)+
44737  &64*mb**2*p2q1/(3*p1q1*p2q2**2)+
44738  &128*a2*mb**3*mt*p2q1/(3*p1q1*p2q2**2)-
44739  &128*a2*mb**2*mt**2*p2q1/(3*p1q1*p2q2**2)-
44740  &256*a2*mb**2*p1p2*p2q1/(3*p1q1*p2q2**2)+
44741  &256*a2**2*mb**2*p1q1*p2q1/(3*p2q2**2)-
44742  &256*a2*mb**2*p1q2*p2q1/(3*p1q1*p2q2**2)-8/(3*p2q2)-
44743  &72*a1*mb**2/p2q2-88*a2*mb**2/(3*p2q2)-56*a1*mb*mt/(3*p2q2)-
44744  &32*a2*mb*mt/p2q2-224*a1*a2*mb**3*mt/(3*p2q2)+
44745  &704*a2**2*mb**3*mt/(3*p2q2)-48*a1*p1p2/p2q2-
44746  &104*a2*p1p2/(3*p2q2)+448*a1*a2*mb**2*p1p2/(3*p2q2)-
44747  &512*a2**2*mb**2*p1p2/(3*p2q2)+128*a1*a2*mb*mt*p1p2/(3*p2q2)+
44748  &32*a1*a2*p1p2**2/p2q2+64*mb*mt**3/(3*p1q1**2*p2q2)+
44749  &256*a1*mb*mt**3*p1p2/(3*p1q1**2*p2q2)-
44750  &256*a1*mt**2*p1p2**2/(3*p1q1**2*p2q2)-4*mb**2/(3*p1q1*p2q2)
44751  a18=a18-64*mb*mt/(3*p1q1*p2q2)+128*a2*mb**3*mt/(3*p1q1*p2q2)-
44752  &4*mt**2/(3*p1q1*p2q2)-128*a1*mb**2*mt**2/(3*p1q1*p2q2)-
44753  &128*a2*mb**2*mt**2/(3*p1q1*p2q2)+128*a1*mb*mt**3/(3*p1q1*p2q2)-
44754  &112*a2*mb**2*p1p2/(3*p1q1*p2q2)+32*a1*mb*mt*p1p2/(3*p1q1*p2q2)+
44755  &32*a2*mb*mt*p1p2/(3*p1q1*p2q2)-112*a1*mt**2*p1p2/(3*p1q1*p2q2)-
44756  &48*a1*p1p2**2/(p1q1*p2q2)-48*a2*p1p2**2/(p1q1*p2q2)-
44757  &512*a1*a2*mb*mt*p1p2**2/(3*p1q1*p2q2)+
44758  &512*a1*a2*p1p2**3/(3*p1q1*p2q2)+16*a2*p1q1/(3*p2q2)+
44759  &64*a1*a2*mb**2*p1q1/p2q2+32*a2**2*mb**2*p1q1/(3*p2q2)-
44760  &112*a1*a2*mb*mt*p1q1/(3*p2q2)+368*a1*a2*p1p2*p1q1/(3*p2q2)-
44761  &16*p1p2/(3*p1q2*p2q2)+32*a1*mb*mt*p1p2/(3*p1q2*p2q2)+
44762  &32*a2*mb*mt*p1p2/(3*p1q2*p2q2)+
44763  &64*a1*a2*mb*mt*p1p2**2/(3*p1q2*p2q2)-
44764  &64*a1*a2*p1p2**3/(3*p1q2*p2q2)+8*mb*mt*p1p2/(3*p1q1*p1q2*p2q2)-
44765  &8*mt**2*p1p2/(3*p1q1*p1q2*p2q2)-
44766  &32*a1*mb*mt**3*p1p2/(3*p1q1*p1q2*p2q2)-
44767  &16*p1p2**2/(3*p1q1*p1q2*p2q2)
44768  a18=a18+32*a1*mt**2*p1p2**2/(3*p1q1*p1q2*p2q2)+
44769  &32*a2*p1p2*p1q1/(3*p1q2*p2q2)-
44770  &32*a1*a2*mb**2*p1p2*p1q1/(3*p1q2*p2q2)+
44771  &32*a1*a2*mb*mt*p1p2*p1q1/(3*p1q2*p2q2)-
44772  &64*a1*a2*p1p2**2*p1q1/(3*p1q2*p2q2)-256*a2*p1q2/(3*p2q2)+
44773  &448*a1*a2*mb**2*p1q2/(3*p2q2)-368*a2**2*mb**2*p1q2/(3*p2q2)-
44774  &224*a1*a2*mb*mt*p1q2/(3*p2q2)+304*a1*a2*p1p2*p1q2/(3*p2q2)+
44775  &64*mt**2*p1q2/(3*p1q1**2*p2q2)-
44776  &128*a1*mb**2*mt**2*p1q2/(3*p1q1**2*p2q2)+
44777  &128*a1*mb*mt**3*p1q2/(3*p1q1**2*p2q2)-
44778  &256*a1*mt**2*p1p2*p1q2/(3*p1q1**2*p2q2)+8*p1q2/(3*p1q1*p2q2)-
44779  &160*a1*mb**2*p1q2/(3*p1q1*p2q2)-272*a2*mb**2*p1q2/(3*p1q1*p2q2)-
44780  &56*a1*mb*mt*p1q2/(3*p1q1*p2q2)-200*a2*mb*mt*p1q2/(3*p1q1*p2q2)-
44781  &48*a1*p1p2*p1q2/(p1q1*p2q2)-256*a2*p1p2*p1q2/(3*p1q1*p2q2)+
44782  &256*a1*a2*mb**2*p1p2*p1q2/(3*p1q1*p2q2)-
44783  &256*a1*a2*mb*mt*p1p2*p1q2/(p1q1*p2q2)+
44784  &1024*a1*a2*p1p2**2*p1q2/(3*p1q1*p2q2)
44785  a18=a18-272*a2*p1q2**2/(3*p1q1*p2q2)+
44786  &256*a1*a2*mb**2*p1q2**2/(3*p1q1*p2q2)-
44787  &256*a1*a2*mb*mt*p1q2**2/(3*p1q1*p2q2)+
44788  &512*a1*a2*p1p2*p1q2**2/(3*p1q1*p2q2)-32*a2*mb**4/(3*p2q1*p2q2)+
44789  &32*a2*mb**3*mt/(3*p2q1*p2q2)-64*a2**2*mb**5*mt/(3*p2q1*p2q2)+
44790  &16*p1p2/(3*p2q1*p2q2)-64*a2*mb**2*p1p2/(3*p2q1*p2q2)+
44791  &64*a2**2*mb**4*p1p2/(3*p2q1*p2q2)+8*mb**2*p1p2/(3*p1q1*p2q1*p2q2)-
44792  &8*mb*mt*p1p2/(3*p1q1*p2q1*p2q2)+
44793  &32*a2*mb**3*mt*p1p2/(3*p1q1*p2q1*p2q2)+
44794  &16*p1p2**2/(3*p1q1*p2q1*p2q2)-
44795  &32*a2*mb**2*p1p2**2/(3*p1q1*p2q1*p2q2)-
44796  &16*a2*mb**2*p1q1/(3*p2q1*p2q2)+64*a2**2*mb**4*p1q1/(3*p2q1*p2q2)+
44797  &8*mb**2*p1p2/(3*p1q2*p2q1*p2q2)-8*mb*mt*p1p2/(3*p1q2*p2q1*p2q2)+
44798  &32*a2*mb**3*mt*p1p2/(3*p1q2*p2q1*p2q2)+
44799  &16*p1p2**2/(3*p1q2*p2q1*p2q2)-
44800  &32*a2*mb**2*p1p2**2/(3*p1q2*p2q1*p2q2)-
44801  &16*mb*mt*p1p2**2/(3*p1q1*p1q2*p2q1*p2q2)
44802  a18=a18+16*p1p2**3/(3*p1q1*p1q2*p2q1*p2q2)-
44803  &32*a2*mb**2*p1p2*p1q1/(3*p1q2*p2q1*p2q2)-
44804  &16*a2*mb**2*p1q2/(3*p2q1*p2q2)+64*a2**2*mb**4*p1q2/(3*p2q1*p2q2)-
44805  &32*a2*mb**2*p1p2*p1q2/(3*p1q1*p2q1*p2q2)+272*a1*p2q1/(3*p2q2)+
44806  &112*a2*p2q1/p2q2-80*a1*a2*mb**2*p2q1/p2q2+
44807  &400*a1*a2*mb*mt*p2q1/(3*p2q2)-208*a2**2*mb*mt*p2q1/(3*p2q2)-
44808  &272*a1*a2*mt**2*p2q1/(3*p2q2)-320*a1*a2*p1p2*p2q1/p2q2+
44809  &96*a2**2*p1p2*p2q1/p2q2-256*a1*mb*mt**3*p2q1/(3*p1q1**2*p2q2)+
44810  &512*a1*mt**2*p1p2*p2q1/(3*p1q1**2*p2q2)-8*p2q1/(3*p1q1*p2q2)+
44811  &200*a1*mb*mt*p2q1/(3*p1q1*p2q2)+56*a2*mb*mt*p2q1/(3*p1q1*p2q2)+
44812  &272*a1*mt**2*p2q1/(3*p1q1*p2q2)+160*a2*mt**2*p2q1/(3*p1q1*p2q2)+
44813  &256*a1*p1p2*p2q1/(3*p1q1*p2q2)+48*a2*p1p2*p2q1/(p1q1*p2q2)+
44814  &256*a1*a2*mb*mt*p1p2*p2q1/(p1q1*p2q2)-
44815  &256*a1*a2*mt**2*p1p2*p2q1/(3*p1q1*p2q2)-
44816  &1024*a1*a2*p1p2**2*p2q1/(3*p1q1*p2q2)-
44817  &544*a1*a2*p1q1*p2q1/(3*p2q2)-640*a2**2*p1q1*p2q1/(3*p2q2)-
44818  &32*a1*p1p2*p2q1/(3*p1q2*p2q2)
44819  a18=a18-32*a1*a2*mb*mt*p1p2*p2q1/(3*p1q2*p2q2)+
44820  &32*a1*a2*mt**2*p1p2*p2q1/(3*p1q2*p2q2)+
44821  &64*a1*a2*p1p2**2*p2q1/(3*p1q2*p2q2)-
44822  &32*a1*mt**2*p1p2*p2q1/(3*p1q1*p1q2*p2q2)+
44823  &64*a1*a2*p1p2*p1q1*p2q1/(3*p1q2*p2q2)-
44824  &944*a1*a2*p1q2*p2q1/(3*p2q2)-32*a2**2*p1q2*p2q1/p2q2+
44825  &256*a1*mt**2*p1q2*p2q1/(3*p1q1**2*p2q2)+
44826  &96*a1*p1q2*p2q1/(p1q1*p2q2)+96*a2*p1q2*p2q1/(p1q1*p2q2)-
44827  &128*a1*a2*mb**2*p1q2*p2q1/(3*p1q1*p2q2)+
44828  &256*a1*a2*mb*mt*p1q2*p2q1/(p1q1*p2q2)-
44829  &128*a1*a2*mt**2*p1q2*p2q1/(3*p1q1*p2q2)-
44830  &512*a1*a2*p1p2*p1q2*p2q1/(p1q1*p2q2)-
44831  &512*a1*a2*p1q2**2*p2q1/(3*p1q1*p2q2)+544*a1*a2*p2q1**2/(3*p2q2)-
44832  &256*a1*mt**2*p2q1**2/(3*p1q1**2*p2q2)-
44833  &272*a1*p2q1**2/(3*p1q1*p2q2)-
44834  &256*a1*a2*mb*mt*p2q1**2/(3*p1q1*p2q2)+
44835  &256*a1*a2*mt**2*p2q1**2/(3*p1q1*p2q2)
44836  a18=a18+512*a1*a2*p1p2*p2q1**2/(3*p1q1*p2q2)+
44837  &512*a1*a2*p1q2*p2q1**2/(3*p1q1*p2q2)+224*a12*p2q2+
44838  &656*a1*a2*p2q2/3+256*a12*mt**4*p2q2/(3*p1q1**2)+
44839  &16*a1*p2q2/(3*p1q1)-112*a1*a2*mb*mt*p2q2/(3*p1q1)+
44840  &32*a12*mt**2*p2q2/(3*p1q1)+64*a1*a2*mt**2*p2q2/p1q1+
44841  &368*a1*a2*p1p2*p2q2/(3*p1q1)-256*a1*mt**2*p2q2/(3*p1q2**2)+
44842  &256*a12*mt**4*p2q2/(3*p1q2**2)-256*a1*p2q2/(3*p1q2)-
44843  &224*a1*a2*mb*mt*p2q2/(3*p1q2)-368*a12*mt**2*p2q2/(3*p1q2)+
44844  &448*a1*a2*mt**2*p2q2/(3*p1q2)+304*a1*a2*p1p2*p2q2/(3*p1q2)+
44845  &16*a1*mt**2*p2q2/(3*p1q1*p1q2)-64*a12*mt**4*p2q2/(3*p1q1*p1q2)+
44846  &32*a12*p1q1*p2q2/p1q2+944*a1*a2*p1q1*p2q2/(3*p1q2)+
44847  &256*a12*mt**2*p1q2*p2q2/(3*p1q1**2)+
44848  &640*a12*p1q2*p2q2/(3*p1q1)+544*a1*a2*p1q2*p2q2/(3*p1q1)-
44849  &256*a2*mb**2*p2q2/(3*p2q1**2)+256*a2**2*mb**3*mt*p2q2/(3*p2q1**2)+
44850  &64*mb**2*mt**2*p2q2/(3*p1q2**2*p2q1**2)+
44851  &64*mb**2*p2q2/(3*p1q2*p2q1**2)+
44852  &128*a2*mb**3*mt*p2q2/(3*p1q2*p2q1**2)
44853  a18=a18-128*a2*mb**2*mt**2*p2q2/(3*p1q2*p2q1**2)-
44854  &256*a2*mb**2*p1p2*p2q2/(3*p1q2*p2q1**2)-
44855  &256*a2*mb**2*p1q1*p2q2/(3*p1q2*p2q1**2)+
44856  &256*a2**2*mb**2*p1q2*p2q2/(3*p2q1**2)+272*a1*p2q2/(3*p2q1)+
44857  &112*a2*p2q2/p2q1-80*a1*a2*mb**2*p2q2/p2q1+
44858  &400*a1*a2*mb*mt*p2q2/(3*p2q1)-208*a2**2*mb*mt*p2q2/(3*p2q1)-
44859  &272*a1*a2*mt**2*p2q2/(3*p2q1)-320*a1*a2*p1p2*p2q2/p2q1+
44860  &96*a2**2*p1p2*p2q2/p2q1-32*a1*p1p2*p2q2/(3*p1q1*p2q1)-
44861  &32*a1*a2*mb*mt*p1p2*p2q2/(3*p1q1*p2q1)+
44862  &32*a1*a2*mt**2*p1p2*p2q2/(3*p1q1*p2q1)+
44863  &64*a1*a2*p1p2**2*p2q2/(3*p1q1*p2q1)-944*a1*a2*p1q1*p2q2/(3*p2q1)-
44864  &32*a2**2*p1q1*p2q2/p2q1-256*a1*mb*mt**3*p2q2/(3*p1q2**2*p2q1)+
44865  &512*a1*mt**2*p1p2*p2q2/(3*p1q2**2*p2q1)+
44866  &256*a1*mt**2*p1q1*p2q2/(3*p1q2**2*p2q1)-8*p2q2/(3*p1q2*p2q1)+
44867  &200*a1*mb*mt*p2q2/(3*p1q2*p2q1)+56*a2*mb*mt*p2q2/(3*p1q2*p2q1)+
44868  &272*a1*mt**2*p2q2/(3*p1q2*p2q1)+160*a2*mt**2*p2q2/(3*p1q2*p2q1)+
44869  &256*a1*p1p2*p2q2/(3*p1q2*p2q1)+48*a2*p1p2*p2q2/(p1q2*p2q1)
44870  a18=a18+256*a1*a2*mb*mt*p1p2*p2q2/(p1q2*p2q1)-
44871  &256*a1*a2*mt**2*p1p2*p2q2/(3*p1q2*p2q1)-
44872  &1024*a1*a2*p1p2**2*p2q2/(3*p1q2*p2q1)-
44873  &32*a1*mt**2*p1p2*p2q2/(3*p1q1*p1q2*p2q1)+
44874  &96*a1*p1q1*p2q2/(p1q2*p2q1)+96*a2*p1q1*p2q2/(p1q2*p2q1)-
44875  &128*a1*a2*mb**2*p1q1*p2q2/(3*p1q2*p2q1)+
44876  &256*a1*a2*mb*mt*p1q1*p2q2/(p1q2*p2q1)-
44877  &128*a1*a2*mt**2*p1q1*p2q2/(3*p1q2*p2q1)-
44878  &512*a1*a2*p1p2*p1q1*p2q2/(p1q2*p2q1)-
44879  &512*a1*a2*p1q1**2*p2q2/(3*p1q2*p2q1)-544*a1*a2*p1q2*p2q2/(3*p2q1)-
44880  &640*a2**2*p1q2*p2q2/(3*p2q1)+
44881  &64*a1*a2*p1p2*p1q2*p2q2/(3*p1q1*p2q1)+544*a1*a2*p2q2**2/(3*p2q1)-
44882  &256*a1*mt**2*p2q2**2/(3*p1q2**2*p2q1)-
44883  &272*a1*p2q2**2/(3*p1q2*p2q1)-
44884  &256*a1*a2*mb*mt*p2q2**2/(3*p1q2*p2q1)+
44885  &256*a1*a2*mt**2*p2q2**2/(3*p1q2*p2q1)+
44886  &512*a1*a2*p1p2*p2q2**2/(3*p1q2*p2q1)
44887  a18=a18+512*a1*a2*p1q1*p2q2**2/(3*p1q2*p2q1)-
44888  &384*a12*mb*mt*p1q1**2/s**2+
44889  &384*a12*p1p2*p1q1**2/s**2-2688*a12*mb*mt*p1q1*p1q2/s**2+
44890  &2688*a12*p1p2*p1q1*p1q2/s**2-384*a12*mb*mt*p1q2**2/s**2+
44891  &384*a12*p1p2*p1q2**2/s**2-768*a1*a2*mb*mt*p1q1*p2q1/s**2+
44892  &768*a1*a2*p1p2*p1q1*p2q1/s**2-2688*a1*a2*mb*mt*p1q2*p2q1/s**2+
44893  &2688*a1*a2*p1p2*p1q2*p2q1/s**2-960*a12*p1q1*p1q2*p2q1/s**2-
44894  &960*a1*a2*p1q1*p1q2*p2q1/s**2+960*a12*p1q2**2*p2q1/s**2+
44895  &960*a1*a2*p1q2**2*p2q1/s**2-384*a2**2*mb*mt*p2q1**2/s**2+
44896  &384*a2**2*p1p2*p2q1**2/s**2-960*a1*a2*p1q2*p2q1**2/s**2-
44897  &960*a2**2*p1q2*p2q1**2/s**2-2688*a1*a2*mb*mt*p1q1*p2q2/s**2+
44898  &2688*a1*a2*p1p2*p1q1*p2q2/s**2+960*a12*p1q1**2*p2q2/s**2+
44899  &960*a1*a2*p1q1**2*p2q2/s**2-768*a1*a2*mb*mt*p1q2*p2q2/s**2+
44900  &768*a1*a2*p1p2*p1q2*p2q2/s**2-960*a12*p1q1*p1q2*p2q2/s**2-
44901  &960*a1*a2*p1q1*p1q2*p2q2/s**2-2688*a2**2*mb*mt*p2q1*p2q2/s**2+
44902  &2688*a2**2*p1p2*p2q1*p2q2/s**2+960*a1*a2*p1q1*p2q1*p2q2/s**2+
44903  &960*a2**2*p1q1*p2q1*p2q2/s**2+960*a1*a2*p1q2*p2q1*p2q2/s**2
44904  a18=a18+960*a2**2*p1q2*p2q1*p2q2/s**2-
44905  &384*a2**2*mb*mt*p2q2**2/s**2+
44906  &384*a2**2*p1p2*p2q2**2/s**2-960*a1*a2*p1q1*p2q2**2/s**2-
44907  &960*a2**2*p1q1*p2q2**2/s**2-96*a1*mb*mt/s-96*a2*mb*mt/s+
44908  &768*a2**2*mb**3*mt/s+768*a12*mb*mt**3/s-192*a1*p1p2/s-
44909  &192*a2*p1p2/s-768*a2**2*mb**2*p1p2/s+2304*a1*a2*mb*mt*p1p2/s-
44910  &768*a12*mt**2*p1p2/s-2304*a1*a2*p1p2**2/s+
44911  &96*a1*mb*mt**3/(p1q1*s)+192*a2*mb*mt*p1p2/(p1q1*s)-
44912  &96*a1*mt**2*p1p2/(p1q1*s)-192*a2*p1p2**2/(p1q1*s)-192*a1*p1q1/s-
44913  &144*a2*p1q1/s-384*a1*a2*mb**2*p1q1/s-480*a2**2*mb**2*p1q1/s+
44914  &480*a12*mb*mt*p1q1/s-96*a1*a2*mb*mt*p1q1/s-
44915  &864*a12*p1p2*p1q1/s-672*a1*a2*p1p2*p1q1/s-96*a1*a2*p1q1**2/s+
44916  &96*a1*mb*mt**3/(p1q2*s)+192*a2*mb*mt*p1p2/(p1q2*s)-
44917  &96*a1*mt**2*p1p2/(p1q2*s)-192*a2*p1p2**2/(p1q2*s)+
44918  &48*a1*mb*mt*p1q1/(p1q2*s)-96*a2*mb*mt*p1q1/(p1q2*s)-
44919  &48*a1*mt**2*p1q1/(p1q2*s)-192*a1*p1p2*p1q1/(p1q2*s)-
44920  &192*a2*p1p2*p1q1/(p1q2*s)-192*a1*a2*mb*mt*p1p2*p1q1/(p1q2*s)
44921  a18=a18+192*a1*a2*p1p2**2*p1q1/(p1q2*s)-192*a1*p1q1**2/(p1q2*s)-
44922  &192*a2*p1q1**2/(p1q2*s)+192*a1*a2*mb**2*p1q1**2/(p1q2*s)+
44923  &192*a12*mb*mt*p1q1**2/(p1q2*s)-96*a1*a2*mb*mt*p1q1**2/(p1q2*s)+
44924  &192*a1*a2*p1p2*p1q1**2/(p1q2*s)-192*a1*p1q2/s-144*a2*p1q2/s-
44925  &384*a1*a2*mb**2*p1q2/s-480*a2**2*mb**2*p1q2/s+
44926  &480*a12*mb*mt*p1q2/s-96*a1*a2*mb*mt*p1q2/s-
44927  &864*a12*p1p2*p1q2/s-672*a1*a2*p1p2*p1q2/s+
44928  &48*a1*mb*mt*p1q2/(p1q1*s)-96*a2*mb*mt*p1q2/(p1q1*s)-
44929  &48*a1*mt**2*p1q2/(p1q1*s)-192*a1*p1p2*p1q2/(p1q1*s)-
44930  &192*a2*p1p2*p1q2/(p1q1*s)-192*a1*a2*mb*mt*p1p2*p1q2/(p1q1*s)+
44931  &192*a1*a2*p1p2**2*p1q2/(p1q1*s)-576*a1*a2*p1q1*p1q2/s-
44932  &96*a1*a2*p1q2**2/s-192*a1*p1q2**2/(p1q1*s)-
44933  &192*a2*p1q2**2/(p1q1*s)+192*a1*a2*mb**2*p1q2**2/(p1q1*s)+
44934  &192*a12*mb*mt*p1q2**2/(p1q1*s)-96*a1*a2*mb*mt*p1q2**2/(p1q1*s)+
44935  &192*a1*a2*p1p2*p1q2**2/(p1q1*s)-96*a2*mb**3*mt/(p2q1*s)+
44936  &96*a2*mb**2*p1p2/(p2q1*s)-192*a1*mb*mt*p1p2/(p2q1*s)+
44937  &192*a1*p1p2**2/(p2q1*s)+96*a1*mb**2*p1q1/(p2q1*s)
44938  a18=a18+192*a2*mb**2*p1q1/(p2q1*s)-96*a1*mb*mt*p1q1/(p2q1*s)-
44939  &192*a1*a2*mb**3*mt*p1q1/(p2q1*s)+192*a1*p1p2*p1q1/(p2q1*s)+
44940  &192*a1*a2*mb**2*p1p2*p1q1/(p2q1*s)+
44941  &96*a1*a2*mb**2*p1q1**2/(p2q1*s)-
44942  &192*a2*mb**3*mt*p1q1/(p1q2*p2q1*s)+
44943  &192*a2*mb**2*p1p2*p1q1/(p1q2*p2q1*s)-
44944  &96*a1*mb*mt*p1p2*p1q1/(p1q2*p2q1*s)+
44945  &96*a1*p1p2**2*p1q1/(p1q2*p2q1*s)+
44946  &96*a1*mb**2*p1q1**2/(p1q2*p2q1*s)+
44947  &192*a2*mb**2*p1q1**2/(p1q2*p2q1*s)-
44948  &48*a1*mb*mt*p1q1**2/(p1q2*p2q1*s)+
44949  &96*a1*p1p2*p1q1**2/(p1q2*p2q1*s)+96*a1*mb**2*p1q2/(p2q1*s)+
44950  &48*a2*mb**2*p1q2/(p2q1*s)+192*a1*a2*mb**3*mt*p1q2/(p2q1*s)-
44951  &192*a1*a2*mb**2*p1p2*p1q2/(p2q1*s)-
44952  &96*a1*a2*mb**2*p1q2**2/(p2q1*s)+144*a1*p2q1/s+192*a2*p2q1/s+
44953  &96*a1*a2*mb*mt*p2q1/s-480*a2**2*mb*mt*p2q1/s+
44954  &480*a12*mt**2*p2q1/s+384*a1*a2*mt**2*p2q1/s
44955  a18=a18+672*a1*a2*p1p2*p2q1/s+864*a2**2*p1p2*p2q1/s-
44956  &96*a2*mb*mt*p2q1/(p1q1*s)+192*a1*mt**2*p2q1/(p1q1*s)+
44957  &96*a2*mt**2*p2q1/(p1q1*s)-192*a1*a2*mb*mt**3*p2q1/(p1q1*s)+
44958  &192*a2*p1p2*p2q1/(p1q1*s)+192*a1*a2*mt**2*p1p2*p2q1/(p1q1*s)-
44959  &192*a12*p1q1*p2q1/s-192*a2**2*p1q1*p2q1/s+
44960  &48*a1*mt**2*p2q1/(p1q2*s)+96*a2*mt**2*p2q1/(p1q2*s)+
44961  &192*a1*a2*mb*mt**3*p2q1/(p1q2*s)-
44962  &192*a1*a2*mt**2*p1p2*p2q1/(p1q2*s)+
44963  &96*a1*a2*mb*mt*p1q1*p2q1/(p1q2*s)-
44964  &192*a12*mt**2*p1q1*p2q1/(p1q2*s)-
44965  &96*a1*a2*mt**2*p1q1*p2q1/(p1q2*s)-
44966  &384*a1*a2*p1p2*p1q1*p2q1/(p1q2*s)-384*a12*p1q1**2*p2q1/(p1q2*s)-
44967  &384*a1*a2*p1q1**2*p2q1/(p1q2*s)-480*a12*p1q2*p2q1/s-
44968  &960*a1*a2*p1q2*p2q1/s-480*a2**2*p1q2*p2q1/s+
44969  &144*a1*p1q2*p2q1/(p1q1*s)+96*a2*p1q2*p2q1/(p1q1*s)+
44970  &384*a1*a2*mb*mt*p1q2*p2q1/(p1q1*s)-
44971  &96*a12*mt**2*p1q2*p2q1/(p1q1*s)
44972  a18=a18+96*a1*a2*mt**2*p1q2*p2q1/(p1q1*s)-
44973  &576*a1*a2*p1p2*p1q2*p2q1/(p1q1*s)-192*a12*p1q2**2*p2q1/(p1q1*s)-
44974  &384*a1*a2*p1q2**2*p2q1/(p1q1*s)-96*a1*a2*p2q1**2/s-
44975  &96*a1*a2*mt**2*p2q1**2/(p1q1*s)+96*a1*a2*mt**2*p2q1**2/(p1q2*s)+
44976  &288*a1*a2*p1q2*p2q1**2/(p1q1*s)-96*a2*mb**3*mt/(p2q2*s)+
44977  &96*a2*mb**2*p1p2/(p2q2*s)-192*a1*mb*mt*p1p2/(p2q2*s)+
44978  &192*a1*p1p2**2/(p2q2*s)+96*a1*mb**2*p1q1/(p2q2*s)+
44979  &48*a2*mb**2*p1q1/(p2q2*s)+192*a1*a2*mb**3*mt*p1q1/(p2q2*s)-
44980  &192*a1*a2*mb**2*p1p2*p1q1/(p2q2*s)-
44981  &96*a1*a2*mb**2*p1q1**2/(p2q2*s)+96*a1*mb**2*p1q2/(p2q2*s)+
44982  &192*a2*mb**2*p1q2/(p2q2*s)-96*a1*mb*mt*p1q2/(p2q2*s)-
44983  &192*a1*a2*mb**3*mt*p1q2/(p2q2*s)+192*a1*p1p2*p1q2/(p2q2*s)+
44984  &192*a1*a2*mb**2*p1p2*p1q2/(p2q2*s)-
44985  &192*a2*mb**3*mt*p1q2/(p1q1*p2q2*s)+
44986  &192*a2*mb**2*p1p2*p1q2/(p1q1*p2q2*s)-
44987  &96*a1*mb*mt*p1p2*p1q2/(p1q1*p2q2*s)+
44988  &96*a1*p1p2**2*p1q2/(p1q1*p2q2*s)+96*a1*a2*mb**2*p1q2**2/(p2q2*s)
44989  a18=a18+96*a1*mb**2*p1q2**2/(p1q1*p2q2*s)+
44990  &192*a2*mb**2*p1q2**2/(p1q1*p2q2*s)-
44991  &48*a1*mb*mt*p1q2**2/(p1q1*p2q2*s)+
44992  &96*a1*p1p2*p1q2**2/(p1q1*p2q2*s)-48*a2*mb**2*p2q1/(p2q2*s)-
44993  &96*a1*mb*mt*p2q1/(p2q2*s)+48*a2*mb*mt*p2q1/(p2q2*s)-
44994  &192*a1*p1p2*p2q1/(p2q2*s)-192*a2*p1p2*p2q1/(p2q2*s)-
44995  &192*a1*a2*mb*mt*p1p2*p2q1/(p2q2*s)+
44996  &192*a1*a2*p1p2**2*p2q1/(p2q2*s)+
44997  &192*a1*mb*mt**3*p2q1/(p1q1*p2q2*s)+
44998  &96*a2*mb*mt*p1p2*p2q1/(p1q1*p2q2*s)-
44999  &192*a1*mt**2*p1p2*p2q1/(p1q1*p2q2*s)-
45000  &96*a2*p1p2**2*p2q1/(p1q1*p2q2*s)+
45001  &96*a1*a2*mb**2*p1q1*p2q1/(p2q2*s)+
45002  &192*a2**2*mb**2*p1q1*p2q1/(p2q2*s)-
45003  &96*a1*a2*mb*mt*p1q1*p2q1/(p2q2*s)+
45004  &384*a1*a2*p1p2*p1q1*p2q1/(p2q2*s)-96*a1*p1q2*p2q1/(p2q2*s)-
45005  &144*a2*p1q2*p2q1/(p2q2*s)-96*a1*a2*mb**2*p1q2*p2q1/(p2q2*s)
45006  a18=a18+96*a2**2*mb**2*p1q2*p2q1/(p2q2*s)-
45007  &384*a1*a2*mb*mt*p1q2*p2q1/(p2q2*s)+
45008  &576*a1*a2*p1p2*p1q2*p2q1/(p2q2*s)-
45009  &96*a2*mb**2*p1q2*p2q1/(p1q1*p2q2*s)-
45010  &48*a1*mb*mt*p1q2*p2q1/(p1q1*p2q2*s)-
45011  &48*a2*mb*mt*p1q2*p2q1/(p1q1*p2q2*s)-
45012  &96*a1*mt**2*p1q2*p2q1/(p1q1*p2q2*s)-
45013  &96*a1*p1p2*p1q2*p2q1/(p1q1*p2q2*s)-
45014  &96*a2*p1p2*p1q2*p2q1/(p1q1*p2q2*s)+
45015  &96*a1*a2*p1q1*p1q2*p2q1/(p2q2*s)+288*a1*a2*p1q2**2*p2q1/(p2q2*s)-
45016  &96*a1*p1q2**2*p2q1/(p1q1*p2q2*s)-96*a2*p1q2**2*p2q1/(p1q1*p2q2*s)+
45017  &192*a1*p2q1**2/(p2q2*s)+192*a2*p2q1**2/(p2q2*s)+
45018  &96*a1*a2*mb*mt*p2q1**2/(p2q2*s)-192*a2**2*mb*mt*p2q1**2/(p2q2*s)-
45019  &192*a1*a2*mt**2*p2q1**2/(p2q2*s)-192*a1*a2*p1p2*p2q1**2/(p2q2*s)-
45020  &48*a2*mb*mt*p2q1**2/(p1q1*p2q2*s)+
45021  &192*a1*mt**2*p2q1**2/(p1q1*p2q2*s)+
45022  &96*a2*mt**2*p2q1**2/(p1q1*p2q2*s)
45023  a18=a18+96*a2*p1p2*p2q1**2/(p1q1*p2q2*s)-
45024  &384*a1*a2*p1q1*p2q1**2/(p2q2*s)-
45025  &384*a2**2*p1q1*p2q1**2/(p2q2*s)-384*a1*a2*p1q2*p2q1**2/(p2q2*s)-
45026  &192*a2**2*p1q2*p2q1**2/(p2q2*s)+96*a1*p1q2*p2q1**2/(p1q1*p2q2*s)+
45027  &96*a2*p1q2*p2q1**2/(p1q1*p2q2*s)+144*a1*p2q2/s+192*a2*p2q2/s+
45028  &96*a1*a2*mb*mt*p2q2/s-480*a2**2*mb*mt*p2q2/s+
45029  &480*a12*mt**2*p2q2/s+384*a1*a2*mt**2*p2q2/s+
45030  &672*a1*a2*p1p2*p2q2/s+864*a2**2*p1p2*p2q2/s+
45031  &48*a1*mt**2*p2q2/(p1q1*s)+96*a2*mt**2*p2q2/(p1q1*s)+
45032  &192*a1*a2*mb*mt**3*p2q2/(p1q1*s)-
45033  &192*a1*a2*mt**2*p1p2*p2q2/(p1q1*s)-480*a12*p1q1*p2q2/s-
45034  &960*a1*a2*p1q1*p2q2/s-480*a2**2*p1q1*p2q2/s-
45035  &96*a2*mb*mt*p2q2/(p1q2*s)+192*a1*mt**2*p2q2/(p1q2*s)+
45036  &96*a2*mt**2*p2q2/(p1q2*s)-192*a1*a2*mb*mt**3*p2q2/(p1q2*s)+
45037  &192*a2*p1p2*p2q2/(p1q2*s)+192*a1*a2*mt**2*p1p2*p2q2/(p1q2*s)+
45038  &144*a1*p1q1*p2q2/(p1q2*s)+96*a2*p1q1*p2q2/(p1q2*s)+
45039  &384*a1*a2*mb*mt*p1q1*p2q2/(p1q2*s)
45040  a18=a18-96*a12*mt**2*p1q1*p2q2/(p1q2*s)+
45041  &96*a1*a2*mt**2*p1q1*p2q2/(p1q2*s)-
45042  &576*a1*a2*p1p2*p1q1*p2q2/(p1q2*s)-192*a12*p1q1**2*p2q2/(p1q2*s)-
45043  &384*a1*a2*p1q1**2*p2q2/(p1q2*s)-192*a12*p1q2*p2q2/s-
45044  &192*a2**2*p1q2*p2q2/s+96*a1*a2*mb*mt*p1q2*p2q2/(p1q1*s)-
45045  &192*a12*mt**2*p1q2*p2q2/(p1q1*s)-
45046  &96*a1*a2*mt**2*p1q2*p2q2/(p1q1*s)-
45047  &384*a1*a2*p1p2*p1q2*p2q2/(p1q1*s)-384*a12*p1q2**2*p2q2/(p1q1*s)-
45048  &384*a1*a2*p1q2**2*p2q2/(p1q1*s)-48*a2*mb**2*p2q2/(p2q1*s)-
45049  &96*a1*mb*mt*p2q2/(p2q1*s)+48*a2*mb*mt*p2q2/(p2q1*s)-
45050  &192*a1*p1p2*p2q2/(p2q1*s)-192*a2*p1p2*p2q2/(p2q1*s)-
45051  &192*a1*a2*mb*mt*p1p2*p2q2/(p2q1*s)+
45052  &192*a1*a2*p1p2**2*p2q2/(p2q1*s)-96*a1*p1q1*p2q2/(p2q1*s)-
45053  &144*a2*p1q1*p2q2/(p2q1*s)-96*a1*a2*mb**2*p1q1*p2q2/(p2q1*s)+
45054  &96*a2**2*mb**2*p1q1*p2q2/(p2q1*s)-
45055  &384*a1*a2*mb*mt*p1q1*p2q2/(p2q1*s)+
45056  &576*a1*a2*p1p2*p1q1*p2q2/(p2q1*s)+288*a1*a2*p1q1**2*p2q2/(p2q1*s)
45057  a18=a18+192*a1*mb*mt**3*p2q2/(p1q2*p2q1*s)+
45058  &96*a2*mb*mt*p1p2*p2q2/(p1q2*p2q1*s)-
45059  &192*a1*mt**2*p1p2*p2q2/(p1q2*p2q1*s)-
45060  &96*a2*p1p2**2*p2q2/(p1q2*p2q1*s)-
45061  &96*a2*mb**2*p1q1*p2q2/(p1q2*p2q1*s)-
45062  &48*a1*mb*mt*p1q1*p2q2/(p1q2*p2q1*s)-
45063  &48*a2*mb*mt*p1q1*p2q2/(p1q2*p2q1*s)-
45064  &96*a1*mt**2*p1q1*p2q2/(p1q2*p2q1*s)-
45065  &96*a1*p1p2*p1q1*p2q2/(p1q2*p2q1*s)-
45066  &96*a2*p1p2*p1q1*p2q2/(p1q2*p2q1*s)-
45067  &96*a1*p1q1**2*p2q2/(p1q2*p2q1*s)-96*a2*p1q1**2*p2q2/(p1q2*p2q1*s)+
45068  &96*a1*a2*mb**2*p1q2*p2q2/(p2q1*s)+
45069  &192*a2**2*mb**2*p1q2*p2q2/(p2q1*s)-
45070  &96*a1*a2*mb*mt*p1q2*p2q2/(p2q1*s)+
45071  &384*a1*a2*p1p2*p1q2*p2q2/(p2q1*s)+
45072  &96*a1*a2*p1q1*p1q2*p2q2/(p2q1*s)-576*a1*a2*p2q1*p2q2/s+
45073  &96*a1*a2*p1q1*p2q1*p2q2/(p1q2*s)+96*a1*a2*p1q2*p2q1*p2q2/(p1q1*s)
45074  a18=a18-96*a1*a2*p2q2**2/s+96*a1*a2*mt**2*p2q2**2/(p1q1*s)-
45075  &96*a1*a2*mt**2*p2q2**2/(p1q2*s)+288*a1*a2*p1q1*p2q2**2/(p1q2*s)+
45076  &192*a1*p2q2**2/(p2q1*s)+192*a2*p2q2**2/(p2q1*s)+
45077  &96*a1*a2*mb*mt*p2q2**2/(p2q1*s)-192*a2**2*mb*mt*p2q2**2/(p2q1*s)-
45078  &192*a1*a2*mt**2*p2q2**2/(p2q1*s)-192*a1*a2*p1p2*p2q2**2/(p2q1*s)-
45079  &384*a1*a2*p1q1*p2q2**2/(p2q1*s)-192*a2**2*p1q1*p2q2**2/(p2q1*s)-
45080  &48*a2*mb*mt*p2q2**2/(p1q2*p2q1*s)+
45081  &192*a1*mt**2*p2q2**2/(p1q2*p2q1*s)+
45082  &96*a2*mt**2*p2q2**2/(p1q2*p2q1*s)+
45083  &96*a2*p1p2*p2q2**2/(p1q2*p2q1*s)+96*a1*p1q1*p2q2**2/(p1q2*p2q1*s)+
45084  &96*a2*p1q1*p2q2**2/(p1q2*p2q1*s)-384*a1*a2*p1q2*p2q2**2/(p2q1*s)-
45085  &384*a2**2*p1q2*p2q2**2/(p2q1*s)+512*a1*a2*s/3-
45086  &128*a1*mt**2*s/(3*p1q1**2)+128*a12*mb*mt**3*s/(3*p1q1**2)-
45087  &152*a1*s/(3*p1q1)-152*a12*mb*mt*s/(3*p1q1)-
45088  &128*a1*a2*mb*mt*s/(3*p1q1)+112*a1*a2*mt**2*s/(3*p1q1)-
45089  &16*a12*p1p2*s/p1q1+152*a1*a2*p1p2*s/(3*p1q1)-
45090  &128*a1*mt**2*s/(3*p1q2**2)+128*a12*mb*mt**3*s/(3*p1q2**2)
45091  a18=a18-152*a1*s/(3*p1q2)-152*a12*mb*mt*s/(3*p1q2)-
45092  &128*a1*a2*mb*mt*s/(3*p1q2)+112*a1*a2*mt**2*s/(3*p1q2)-
45093  &16*a12*p1p2*s/p1q2+152*a1*a2*p1p2*s/(3*p1q2)+
45094  &16*a1*mb*mt*s/(3*p1q1*p1q2)-32*a12*mb*mt**3*s/(3*p1q1*p1q2)-
45095  &16*a1*p1p2*s/(3*p1q1*p1q2)+272*a1*a2*p1q1*s/(3*p1q2)+
45096  &272*a1*a2*p1q2*s/(3*p1q1)-128*a2*mb**2*s/(3*p2q1**2)+
45097  &128*a2**2*mb**3*mt*s/(3*p2q1**2)+
45098  &32*mb**2*mt**2*s/(3*p1q2**2*p2q1**2)+32*mb**2*s/(3*p1q2*p2q1**2)
45099 
45100  a18bis=
45101  &64*a2*mb**3*mt*s/(3*p1q2*p2q1**2)-
45102  &64*a2*mb**2*mt**2*s/(3*p1q2*p2q1**2)-
45103  &128*a2*mb**2*p1p2*s/(3*p1q2*p2q1**2)-
45104  &128*a2*mb**2*p1q1*s/(3*p1q2*p2q1**2)+
45105  &128*a2**2*mb**2*p1q2*s/(3*p2q1**2)+152*a2*s/(3*p2q1)-
45106  &112*a1*a2*mb**2*s/(3*p2q1)+128*a1*a2*mb*mt*s/(3*p2q1)+
45107  &152*a2**2*mb*mt*s/(3*p2q1)-152*a1*a2*p1p2*s/(3*p2q1)+
45108  &16*a2**2*p1p2*s/p2q1-8*a1*a2*mb**3*mt*s/(3*p1q1*p2q1)+
45109  &16*a1*a2*mb**2*mt**2*s/(3*p1q1*p2q1)-
45110  &8*a1*a2*mb*mt**3*s/(3*p1q1*p2q1)-8*a1*p1p2*s/(3*p1q1*p2q1)-
45111  &8*a2*p1p2*s/(3*p1q1*p2q1)+8*a1*a2*mb**2*p1p2*s/(3*p1q1*p2q1)-
45112  &16*a1*a2*mb*mt*p1p2*s/(3*p1q1*p2q1)+
45113  &8*a1*a2*mt**2*p1p2*s/(3*p1q1*p2q1)+
45114  &32*a1*a2*p1p2**2*s/(3*p1q1*p2q1)-32*a2**2*p1q1*s/(3*p2q1)-
45115  &32*mt**2*s/(3*p1q2**2*p2q1)+64*a1*mb**2*mt**2*s/(3*p1q2**2*p2q1)-
45116  &64*a1*mb*mt**3*s/(3*p1q2**2*p2q1)
45117  a18bis=a18bis+128*a1*mt**2*p1p2*s/(3*p1q2**2*p2q1)-
45118  &12*s/(p1q2*p2q1)+
45119  &24*a1*mb**2*s/(p1q2*p2q1)+64*a1*a2*mb**3*mt*s/(3*p1q2*p2q1)+
45120  &24*a2*mt**2*s/(p1q2*p2q1)-128*a1*a2*mb**2*mt**2*s/(3*p1q2*p2q1)+
45121  &64*a1*a2*mb*mt**3*s/(3*p1q2*p2q1)+56*a1*p1p2*s/(3*p1q2*p2q1)+
45122  &56*a2*p1p2*s/(3*p1q2*p2q1)-64*a1*a2*mb**2*p1p2*s/(3*p1q2*p2q1)+
45123  &128*a1*a2*mb*mt*p1p2*s/(3*p1q2*p2q1)-
45124  &64*a1*a2*mt**2*p1p2*s/(3*p1q2*p2q1)-
45125  &256*a1*a2*p1p2**2*s/(3*p1q2*p2q1)+4*p1p2*s/(3*p1q1*p1q2*p2q1)-
45126  &8*a1*mb*mt*p1p2*s/(3*p1q1*p1q2*p2q1)-
45127  &8*a1*mt**2*p1p2*s/(3*p1q1*p1q2*p2q1)+136*a2*p1q1*s/(3*p1q2*p2q1)-
45128  &128*a1*a2*mb**2*p1q1*s/(3*p1q2*p2q1)+
45129  &128*a1*a2*mb*mt*p1q1*s/(3*p1q2*p2q1)-
45130  &256*a1*a2*p1p2*p1q1*s/(3*p1q2*p2q1)-160*a2**2*p1q2*s/(3*p2q1)+
45131  &16*a1*a2*p1p2*p1q2*s/(3*p1q1*p2q1)-32*a12*p2q1*s/(3*p1q1)-
45132  &128*a12*mt**2*p2q1*s/(3*p1q2**2)-160*a12*p2q1*s/(3*p1q2)-
45133  &128*a2*mb**2*s/(3*p2q2**2)+128*a2**2*mb**3*mt*s/(3*p2q2**2)
45134  a18bis=a18bis+32*mb**2*mt**2*s/(3*p1q1**2*p2q2**2)+
45135  &32*mb**2*s/(3*p1q1*p2q2**2)+
45136  &64*a2*mb**3*mt*s/(3*p1q1*p2q2**2)-
45137  &64*a2*mb**2*mt**2*s/(3*p1q1*p2q2**2)-
45138  &128*a2*mb**2*p1p2*s/(3*p1q1*p2q2**2)+
45139  &128*a2**2*mb**2*p1q1*s/(3*p2q2**2)-
45140  &128*a2*mb**2*p1q2*s/(3*p1q1*p2q2**2)+152*a2*s/(3*p2q2)-
45141  &112*a1*a2*mb**2*s/(3*p2q2)+128*a1*a2*mb*mt*s/(3*p2q2)+
45142  &152*a2**2*mb*mt*s/(3*p2q2)-152*a1*a2*p1p2*s/(3*p2q2)+
45143  &16*a2**2*p1p2*s/p2q2-32*mt**2*s/(3*p1q1**2*p2q2)+
45144  &64*a1*mb**2*mt**2*s/(3*p1q1**2*p2q2)-
45145  &64*a1*mb*mt**3*s/(3*p1q1**2*p2q2)+
45146  &128*a1*mt**2*p1p2*s/(3*p1q1**2*p2q2)-12*s/(p1q1*p2q2)+
45147  &24*a1*mb**2*s/(p1q1*p2q2)+64*a1*a2*mb**3*mt*s/(3*p1q1*p2q2)+
45148  &24*a2*mt**2*s/(p1q1*p2q2)-128*a1*a2*mb**2*mt**2*s/(3*p1q1*p2q2)+
45149  &64*a1*a2*mb*mt**3*s/(3*p1q1*p2q2)+56*a1*p1p2*s/(3*p1q1*p2q2)+
45150  &56*a2*p1p2*s/(3*p1q1*p2q2)-64*a1*a2*mb**2*p1p2*s/(3*p1q1*p2q2)
45151  a18bis=a18bis+128*a1*a2*mb*mt*p1p2*s/(3*p1q1*p2q2)-
45152  &64*a1*a2*mt**2*p1p2*s/(3*p1q1*p2q2)-
45153  &256*a1*a2*p1p2**2*s/(3*p1q1*p2q2)-160*a2**2*p1q1*s/(3*p2q2)-
45154  &8*a1*a2*mb**3*mt*s/(3*p1q2*p2q2)+
45155  &16*a1*a2*mb**2*mt**2*s/(3*p1q2*p2q2)-
45156  &8*a1*a2*mb*mt**3*s/(3*p1q2*p2q2)-8*a1*p1p2*s/(3*p1q2*p2q2)-
45157  &8*a2*p1p2*s/(3*p1q2*p2q2)+8*a1*a2*mb**2*p1p2*s/(3*p1q2*p2q2)-
45158  &16*a1*a2*mb*mt*p1p2*s/(3*p1q2*p2q2)+
45159  &8*a1*a2*mt**2*p1p2*s/(3*p1q2*p2q2)+
45160  &32*a1*a2*p1p2**2*s/(3*p1q2*p2q2)+4*p1p2*s/(3*p1q1*p1q2*p2q2)-
45161  &8*a1*mb*mt*p1p2*s/(3*p1q1*p1q2*p2q2)-
45162  &8*a1*mt**2*p1p2*s/(3*p1q1*p1q2*p2q2)+
45163  &16*a1*a2*p1p2*p1q1*s/(3*p1q2*p2q2)-32*a2**2*p1q2*s/(3*p2q2)+
45164  &136*a2*p1q2*s/(3*p1q1*p2q2)-128*a1*a2*mb**2*p1q2*s/(3*p1q1*p2q2)+
45165  &128*a1*a2*mb*mt*p1q2*s/(3*p1q1*p2q2)-
45166  &256*a1*a2*p1p2*p1q2*s/(3*p1q1*p2q2)+16*a2*mb*mt*s/(3*p2q1*p2q2)-
45167  &32*a2**2*mb**3*mt*s/(3*p2q1*p2q2)-16*a2*p1p2*s/(3*p2q1*p2q2)
45168  a18bis=a18bis-4*p1p2*s/(3*p1q1*p2q1*p2q2)+
45169  &8*a2*mb**2*p1p2*s/(3*p1q1*p2q1*p2q2)+
45170  &8*a2*mb*mt*p1p2*s/(3*p1q1*p2q1*p2q2)-4*p1p2*s/(3*p1q2*p2q1*p2q2)+
45171  &8*a2*mb**2*p1p2*s/(3*p1q2*p2q1*p2q2)+
45172  &8*a2*mb*mt*p1p2*s/(3*p1q2*p2q1*p2q2)-
45173  &2*mb**3*mt*s/(3*p1q1*p1q2*p2q1*p2q2)+
45174  &4*mb**2*mt**2*s/(3*p1q1*p1q2*p2q1*p2q2)-
45175  &2*mb*mt**3*s/(3*p1q1*p1q2*p2q1*p2q2)-
45176  &2*mb**2*p1p2*s/(3*p1q1*p1q2*p2q1*p2q2)+
45177  &4*mb*mt*p1p2*s/(3*p1q1*p1q2*p2q1*p2q2)-
45178  &2*mt**2*p1p2*s/(3*p1q1*p1q2*p2q1*p2q2)-
45179  &8*p1p2**2*s/(3*p1q1*p1q2*p2q1*p2q2)+
45180  &8*a2*p1p2*p1q1*s/(3*p1q2*p2q1*p2q2)+
45181  &8*a2*p1p2*p1q2*s/(3*p1q1*p2q1*p2q2)+272*a1*a2*p2q1*s/(3*p2q2)-
45182  &128*a1*mt**2*p2q1*s/(3*p1q1**2*p2q2)-136*a1*p2q1*s/(3*p1q1*p2q2)-
45183  &128*a1*a2*mb*mt*p2q1*s/(3*p1q1*p2q2)+
45184  &128*a1*a2*mt**2*p2q1*s/(3*p1q1*p2q2)
45185  a18bis=a18bis+256*a1*a2*p1p2*p2q1*s/(3*p1q1*p2q2)-
45186  &16*a1*a2*p1p2*p2q1*s/(3*p1q2*p2q2)+
45187  &8*a1*p1p2*p2q1*s/(3*p1q1*p1q2*p2q2)+
45188  &256*a1*a2*p1q2*p2q1*s/(3*p1q1*p2q2)-
45189  &128*a12*mt**2*p2q2*s/(3*p1q1**2)-160*a12*p2q2*s/(3*p1q1)-
45190  &32*a12*p2q2*s/(3*p1q2)+272*a1*a2*p2q2*s/(3*p2q1)-
45191  &16*a1*a2*p1p2*p2q2*s/(3*p1q1*p2q1)-
45192  &128*a1*mt**2*p2q2*s/(3*p1q2**2*p2q1)-136*a1*p2q2*s/(3*p1q2*p2q1)-
45193  &128*a1*a2*mb*mt*p2q2*s/(3*p1q2*p2q1)+
45194  &128*a1*a2*mt**2*p2q2*s/(3*p1q2*p2q1)+
45195  &256*a1*a2*p1p2*p2q2*s/(3*p1q2*p2q1)+
45196  &8*a1*p1p2*p2q2*s/(3*p1q1*p1q2*p2q1)+
45197  &256*a1*a2*p1q1*p2q2*s/(3*p1q2*p2q1)-
45198  &8*a12*mb*mt*s**2/(3*p1q1*p1q2)+16*a12*p1p2*s**2/(3*p1q1*p1q2)-
45199  &8*a1*a2*p1p2*s**2/(3*p1q1*p2q1)+4*a1*p1p2*s**2/(3*p1q1*p1q2*p2q1)-
45200  &8*a1*a2*p1p2*s**2/(3*p1q2*p2q2)+4*a1*p1p2*s**2/(3*p1q1*p1q2*p2q2)-
45201  &8*a2**2*mb*mt*s**2/(3*p2q1*p2q2)+16*a2**2*p1p2*s**2/(3*p2q1*p2q2)
45202  a18bis=a18bis-4*a2*p1p2*s**2/(3*p1q1*p2q1*p2q2)-
45203  &4*a2*p1p2*s**2/(3*p1q2*p2q1*p2q2)+
45204  &2*p1p2*s**2/(3*p1q1*p1q2*p2q1*p2q2)
45205 C
45206  v18=v18+v18bis
45207  a18=a18+a18bis
45208  v910 =-48*a12*mb*mt-48*a2**2*mb*mt-48*a12*p1p2-48*a2**2*p1p2-
45209  &384*a12*mb*mt*p1q1*p1q2/s**2-384*a12*p1p2*p1q1*p1q2/s**2-
45210  &384*a1*a2*mb*mt*p1q2*p2q1/s**2-384*a1*a2*p1p2*p1q2*p2q1/s**2+
45211  &192*a12*p1q1*p1q2*p2q1/s**2+192*a1*a2*p1q1*p1q2*p2q1/s**2-
45212  &192*a12*p1q2**2*p2q1/s**2-192*a1*a2*p1q2**2*p2q1/s**2+
45213  &192*a1*a2*p1q2*p2q1**2/s**2+192*a2**2*p1q2*p2q1**2/s**2-
45214  &384*a1*a2*mb*mt*p1q1*p2q2/s**2-384*a1*a2*p1p2*p1q1*p2q2/s**2-
45215  &192*a12*p1q1**2*p2q2/s**2-192*a1*a2*p1q1**2*p2q2/s**2+
45216  &192*a12*p1q1*p1q2*p2q2/s**2+192*a1*a2*p1q1*p1q2*p2q2/s**2-
45217  &384*a2**2*mb*mt*p2q1*p2q2/s**2-384*a2**2*p1p2*p2q1*p2q2/s**2-
45218  &192*a1*a2*p1q1*p2q1*p2q2/s**2-192*a2**2*p1q1*p2q1*p2q2/s**2-
45219  &192*a1*a2*p1q2*p2q1*p2q2/s**2-192*a2**2*p1q2*p2q1*p2q2/s**2+
45220  &192*a1*a2*p1q1*p2q2**2/s**2+192*a2**2*p1q1*p2q2**2/s**2+
45221  &96*a12*mb*mt*p1q1/s-96*a1*a2*mb*mt*p1q1/s+
45222  &96*a12*p1p2*p1q1/s-96*a1*a2*p1p2*p1q1/s+96*a12*mb*mt*p1q2/s-
45223  &96*a1*a2*mb*mt*p1q2/s+96*a12*p1p2*p1q2/s-96*a1*a2*p1p2*p1q2/s+
45224  &96*a1*a2*mb*mt*p2q1/s-96*a2**2*mb*mt*p2q1/s
45225  v910=v910+96*a1*a2*p1p2*p2q1/s-
45226  &96*a2**2*p1p2*p2q1/s+96*a12*p1q2*p2q1/s+
45227  &192*a1*a2*p1q2*p2q1/s+96*a2**2*p1q2*p2q1/s+
45228  &96*a1*a2*mb*mt*p2q2/s-96*a2**2*mb*mt*p2q2/s+
45229  &96*a1*a2*p1p2*p2q2/s-96*a2**2*p1p2*p2q2/s+96*a12*p1q1*p2q2/s+
45230  &192*a1*a2*p1q1*p2q2/s+96*a2**2*p1q1*p2q2/s
45231 C
45232  a910 = 48*a12*mb*mt+48*a2**2*mb*mt-48*a12*p1p2-48*a2**2*p1p2+
45233  &384*a12*mb*mt*p1q1*p1q2/s**2-384*a12*p1p2*p1q1*p1q2/s**2+
45234  &384*a1*a2*mb*mt*p1q2*p2q1/s**2-384*a1*a2*p1p2*p1q2*p2q1/s**2+
45235  &192*a12*p1q1*p1q2*p2q1/s**2+192*a1*a2*p1q1*p1q2*p2q1/s**2-
45236  &192*a12*p1q2**2*p2q1/s**2-192*a1*a2*p1q2**2*p2q1/s**2+
45237  &192*a1*a2*p1q2*p2q1**2/s**2+192*a2**2*p1q2*p2q1**2/s**2+
45238  &384*a1*a2*mb*mt*p1q1*p2q2/s**2-384*a1*a2*p1p2*p1q1*p2q2/s**2-
45239  &192*a12*p1q1**2*p2q2/s**2-192*a1*a2*p1q1**2*p2q2/s**2+
45240  &192*a12*p1q1*p1q2*p2q2/s**2+192*a1*a2*p1q1*p1q2*p2q2/s**2+
45241  &384*a2**2*mb*mt*p2q1*p2q2/s**2-384*a2**2*p1p2*p2q1*p2q2/s**2-
45242  &192*a1*a2*p1q1*p2q1*p2q2/s**2-192*a2**2*p1q1*p2q1*p2q2/s**2-
45243  &192*a1*a2*p1q2*p2q1*p2q2/s**2-192*a2**2*p1q2*p2q1*p2q2/s**2+
45244  &192*a1*a2*p1q1*p2q2**2/s**2+192*a2**2*p1q1*p2q2**2/s**2-
45245  &96*a12*mb*mt*p1q1/s+96*a1*a2*mb*mt*p1q1/s+
45246  &96*a12*p1p2*p1q1/s-96*a1*a2*p1p2*p1q1/s-96*a12*mb*mt*p1q2/s+
45247  &96*a1*a2*mb*mt*p1q2/s+96*a12*p1p2*p1q2/s-96*a1*a2*p1p2*p1q2/s-
45248  &96*a1*a2*mb*mt*p2q1/s+96*a2**2*mb*mt*p2q1/s
45249  a910=a910+96*a1*a2*p1p2*p2q1/s-
45250  &96*a2**2*p1p2*p2q1/s+96*a12*p1q2*p2q1/s+
45251  &192*a1*a2*p1q2*p2q1/s+96*a2**2*p1q2*p2q1/s-
45252  &96*a1*a2*mb*mt*p2q2/s+96*a2**2*mb*mt*p2q2/s+
45253  &96*a1*a2*p1p2*p2q2/s-96*a2**2*p1p2*p2q2/s+96*a12*p1q1*p2q2/s+
45254  &192*a1*a2*p1q1*p2q2/s+96*a2**2*p1q1*p2q2/s
45255 C
45256 C FINAL RESULT;
45257 C
45258  amp2= fact*ps*vtb**2*(v**2 *(v18 +v910)+a**2 *(a18+a910) )
45259 
45260  END
45261 C---------------------------------------------------------
45262 C 2) Q QBAR ->TBH^+
45263  SUBROUTINE pytbhq(Q1,Q2,P1,P2,P3,MT,MB,RMB,MHP,AMP2)
45264 C
45265 C AMP2(OUTPUT) =MATRIX ELEMENT (AMPLITUDE**2) FOR Q QBAR->TB H^+
45266 C (NB SAME STRUCTURE AS FOR PYTBHG ROUTINE ABOVE)
45267  IMPLICIT DOUBLE PRECISION(a-h, o-z)
45268  IMPLICIT INTEGER(i-n)
45269  DOUBLE PRECISION mw2,mt,mb,mhp,mw
45270  dimension q1(4),q2(4),p1(4),p2(4),p3(4)
45271  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
45272  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
45273  common/pymssm/imss(0:99),rmss(0:99)
45274  common/pyctbh/ alpha,alphas,sw2,mw2,tanb,vtb,v,a
45275  SAVE /pydat1/,/pydat2/,/pymssm/,/pyctbh/
45276 C !THE RELEVANT INPUT PARAMETERS ABOVE ARE NEEDED FOR CALCULATION
45277 C BUT ARE NOT DEFINED HERE SO THAT ONE MAY CHOOSE/VARY THEIR VALUES:
45278 C ACCORDINGLY, WHEN CALLING THESE SUBROUTINES, PLEASE SUPPLY VIA
45279 C THIS COMMON/PARAM/ YOUR PREFERRED ALPHA, ALPHAS,..AND TANB VALUES
45280 C
45281 C THE NORMALIZED V,A COUPLINGS ARE DEFINED BELOW AND USED BOTH
45282 C IN THIS ROUTINE AND IN THE TOP WIDTH CALCULATION PYTBHB(..).
45283 C
45284  dimension yy(2,2)
45285 
45286  pi = 4*datan(1.d0)
45287  mw = dsqrt(mw2)
45288 
45289 C COLLECTING THE RELEVANT OVERALL FACTORS:
45290 C 3X3 INITIAL QUARK COLOR AVERAGE, 2X2 QUARK SPIN AVERAGE
45291  ps=1.d0/(3.d0*3.d0 *2.d0*2.d0)
45292 C COUPLING CONSTANT (OVERALL NORMALIZATION)
45293  fact=(4.d0*pi*alpha)*(4.d0*pi*alphas)**2/sw2/2.d0
45294 C NB ALPHA IS E^2/4/PI, BUT BETTER DEFINED IN TERMS OF G_FERMI:
45295 C ALPHA= DSQRT(2.D0)*GF*SW2*MW**2/PI
45296 C ALPHAS IS ALPHA_STRONG;
45297 C SW2 IS SIN(THETA_W)**2.
45298 C
45299 C VTB=.998D0
45300 C VTB IS TOP-BOTTOM CKM MATRIX ELEMENT (APPROXIMATE VALUE HERE)
45301 C
45302  v = ( mt/mw/tanb +rmb/mw*tanb)/2.d0
45303  a = (-mt/mw/tanb +rmb/mw*tanb)/2.d0
45304 C V AND A ARE (NORMALIZED) VECTOR AND AXIAL TBH^+ COUPLINGS
45305 C
45306 C REDEFINING P2 INGOING FROM OVERALL MOMENTUM CONSERVATION
45307 C (BECAUSE P2 INGOING WAS USED IN OUR GRAPH CALCULATION CONVENTIONS)
45308  DO 100 kk=1,4
45309  p2(kk)=p3(kk)-q1(kk)-q2(kk)+p1(kk)
45310  100 CONTINUE
45311 C DEFINING VARIOUS RELEVANT 4-SCALAR PRODUCTS:
45312  s = 2*pytbhs(q1,q2)
45313  p1q1=pytbhs(q1,p1)
45314  p1q2=pytbhs(p1,q2)
45315  p2q1=pytbhs(p2,q1)
45316  p2q2=pytbhs(p2,q2)
45317  p1p2=pytbhs(p1,p2)
45318 C
45319 C TOP WIDTH CALCULATION
45320  CALL pytbhb(mt,mb,mhp,br,gamt)
45321 C GAMT IS THE TOP WIDTH: T->BH^+ AND/OR T->B W^+
45322 C THEN DEFINE TOP (RESONANT) PROPAGATOR:
45323  a1inv= s -2*p1q1 -2*p1q2
45324  a1 =a1inv/(a1inv**2+ (gamt*mt)**2)
45325 C (I.E. INTRODUCE THE TOP WIDTH IN A1 TO REGULARISE THE POLE)
45326 C NB A12 = A1*A1 BUT WITH CORRECT WIDTH TREATMENT
45327  a12 = 1.d0/(a1inv**2+ (gamt*mt)**2)
45328  a2 =1.d0/(s +2*p2q1 +2*p2q2)
45329 C NOTE A2 IS B PROPAGATOR, DOES NOT NEED A WIDTH
45330 C NOW COMES THE AMP**2:
45331 C NB COLOR FACTOR (COMING FORM GRAPHS) ALREADY INCLUDED IN
45332 C THE EXPRESSIONS BELOW
45333  yy(1, 1) = -16*a**2*a2**2*mb*mt+
45334  &64*a**2*a2**2*p1q2*p2q1**2/s**2+
45335  &128*a**2*a2**2*mb*mt*p2q1*p2q2/s**2-
45336  &128*a**2*a2**2*p1p2*p2q1*p2q2/s**2-
45337  &64*a**2*a2**2*p1q1*p2q1*p2q2/s**2-
45338  &64*a**2*a2**2*p1q2*p2q1*p2q2/s**2+
45339  &64*a**2*a2**2*p1q1*p2q2**2/s**2-
45340  &32*a**2*a2**2*mb**3*mt/s+32*a**2*a2**2*mb**2*p1p2/s+
45341  &32*a**2*a2**2*mb**2*p1q1/s+32*a**2*a2**2*mb**2*p1q2/s-
45342  &32*a**2*a2**2*p1p2*p2q1/s-32*a**2*a2**2*p1q1*p2q1/s-
45343  &32*a**2*a2**2*p1p2*p2q2/s-32*a**2*a2**2*p1q2*p2q2/s+
45344  &16*a2**2*mb*mt*v**2+64*a2**2*p1q2*p2q1**2*v**2/s**2-
45345  &128*a2**2*mb*mt*p2q1*p2q2*v**2/s**2-
45346  &128*a2**2*p1p2*p2q1*p2q2*v**2/s**2-
45347  &64*a2**2*p1q1*p2q1*p2q2*v**2/s**2-
45348  &64*a2**2*p1q2*p2q1*p2q2*v**2/s**2+
45349  &64*a2**2*p1q1*p2q2**2*v**2/s**2
45350  yy(1, 1)=yy(1, 1)+32*a2**2*mb**3*mt*v**2/s+
45351  &32*a2**2*mb**2*p1p2*v**2/s+
45352  &32*a2**2*mb**2*p1q1*v**2/s+32*a2**2*mb**2*p1q2*v**2/s-
45353  &32*a2**2*p1p2*p2q1*v**2/s-32*a2**2*p1q1*p2q1*v**2/s-
45354  &32*a2**2*p1p2*p2q2*v**2/s-32*a2**2*p1q2*p2q2*v**2/s
45355  yy(1, 1)=2*yy(1, 1)
45356 
45357  yy(1, 2) = -32*a**2*a1*a2*mb*mt+
45358  &128*a**2*a1*a2*mb*mt*p1q2*p2q1/s**2-
45359  &128*a**2*a1*a2*p1p2*p1q2*p2q1/s**2+
45360  &64*a**2*a1*a2*p1q1*p1q2*p2q1/s**2-
45361  &64*a**2*a1*a2*p1q2**2*p2q1/s**2+
45362  &64*a**2*a1*a2*p1q2*p2q1**2/s**2+
45363  &128*a**2*a1*a2*mb*mt*p1q1*p2q2/s**2-
45364  &128*a**2*a1*a2*p1p2*p1q1*p2q2/s**2-
45365  &64*a**2*a1*a2*p1q1**2*p2q2/s**2+
45366  &64*a**2*a1*a2*p1q1*p1q2*p2q2/s**2-
45367  &64*a**2*a1*a2*p1q1*p2q1*p2q2/s**2-
45368  &64*a**2*a1*a2*p1q2*p2q1*p2q2/s**2+
45369  &64*a**2*a1*a2*p1q1*p2q2**2/s**2-
45370  &64*a**2*a1*a2*mb*mt*p1p2/s+
45371  &64*a**2*a1*a2*p1p2**2/s+32*a**2*a1*a2*mb**2*p1q1/s+
45372  &32*a**2*a1*a2*p1p2*p1q1/s+32*a**2*a1*a2*mb**2*p1q2/s+
45373  &32*a**2*a1*a2*p1p2*p1q2/s-32*a**2*a1*a2*mt**2*p2q1/s
45374  yy(1, 2)=yy(1, 2)-32*a**2*a1*a2*p1p2*p2q1/s-
45375  &64*a**2*a1*a2*p1q1*p2q1/s-
45376  &32*a**2*a1*a2*mt**2*p2q2/s-32*a**2*a1*a2*p1p2*p2q2/s-
45377  &64*a**2*a1*a2*p1q2*p2q2/s+32*a1*a2*mb*mt*v**2-
45378  &128*a1*a2*mb*mt*p1q2*p2q1*v**2/s**2 -
45379  &128*a1*a2*p1p2*p1q2*p2q1*v**2/s**2+
45380  &64*a1*a2*p1q1*p1q2*p2q1*v**2/s**2-
45381  &64*a1*a2*p1q2**2*p2q1*v**2/s**2+
45382  &64*a1*a2*p1q2*p2q1**2*v**2/s**2-
45383  &128*a1*a2*mb*mt*p1q1*p2q2*v**2/s**2-
45384  &128*a1*a2*p1p2*p1q1*p2q2*v**2/s**2-
45385  &64*a1*a2*p1q1**2*p2q2*v**2/s**2+
45386  &64*a1*a2*p1q1*p1q2*p2q2*v**2/s**2-
45387  &64*a1*a2*p1q1*p2q1*p2q2*v**2/s**2-
45388  &64*a1*a2*p1q2*p2q1*p2q2*v**2/s**2+
45389  &64*a1*a2*p1q1*p2q2**2*v**2/s**2+
45390  &64*a1*a2*mb*mt*p1p2*v**2/s+64*a1*a2*p1p2**2*v**2/s
45391  yy(1, 2)=yy(1, 2)+32*a1*a2*mb**2*p1q1*v**2/s+
45392  &32*a1*a2*p1p2*p1q1*v**2/s+
45393  &32*a1*a2*mb**2*p1q2*v**2/s+32*a1*a2*p1p2*p1q2*v**2/s-
45394  &32*a1*a2*mt**2*p2q1*v**2/s-32*a1*a2*p1p2*p2q1*v**2/s-
45395  &64*a1*a2*p1q1*p2q1*v**2/s-32*a1*a2*mt**2*p2q2*v**2/s-
45396  &32*a1*a2*p1p2*p2q2*v**2/s-64*a1*a2*p1q2*p2q2*v**2/s
45397 
45398 
45399  yy(2, 2) =-16*a**2*a12*mb*mt+
45400  &128*a**2*a12*mb*mt*p1q1*p1q2/s**2-
45401  &128*a**2*a12*p1p2*p1q1*p1q2/s**2+
45402  &64*a**2*a12*p1q1*p1q2*p2q1/s**2-
45403  &64*a**2*a12*p1q2**2*p2q1/s**2-64*a**2*a12*p1q1**2*p2q2/s**2+
45404  &64*a**2*a12*p1q1*p1q2*p2q2/s**2-32*a**2*a12*mb*mt**3/s+
45405  &32*a**2*a12*mt**2*p1p2/s+32*a**2*a12*p1p2*p1q1/s+
45406  &32*a**2*a12*p1p2*p1q2/s-32*a**2*a12*mt**2*p2q1/s-
45407  &32*a**2*a12*p1q1*p2q1/s-32*a**2*a12*mt**2*p2q2/s-
45408  &32*a**2*a12*p1q2*p2q2/s+16*a12*mb*mt*v**2-
45409  &128*a12*mb*mt*p1q1*p1q2*v**2/s**2-
45410  &128*a12*p1p2*p1q1*p1q2*v**2/s**2+
45411  &64*a12*p1q1*p1q2*p2q1*v**2/s**2-
45412  &64*a12*p1q2**2*p2q1*v**2/s**2-64*a12*p1q1**2*p2q2*v**2/s**2+
45413  &64*a12*p1q1*p1q2*p2q2*v**2/s**2+32*a12*mb*mt**3*v**2/s+
45414  &32*a12*mt**2*p1p2*v**2/s+32*a12*p1p2*p1q1*v**2/s+
45415  &32*a12*p1p2*p1q2*v**2/s-32*a12*mt**2*p2q1*v**2/s
45416  yy(2, 2)=yy(2, 2)-32*a12*p1q1*p2q1*v**2/s-
45417  &32*a12*mt**2*p2q2*v**2/s-
45418  &32*a12*p1q2*p2q2*v**2/s
45419  yy(2, 2)=2*yy(2, 2)
45420 
45421  res=yy(1,1)+2*yy(1,2)+yy(2,2)
45422  amp2= fact*ps*vtb**2*res
45423 
45424  END
45425 C=====================================================================
45426 C ************* FUNCTION SCALAR PRODUCTS *************************
45427  DOUBLE PRECISION FUNCTION pytbhs(A,B)
45428  IMPLICIT DOUBLE PRECISION(a-h, o-z)
45429  IMPLICIT INTEGER(i-n)
45430  dimension a(4),b(4)
45431  dum=a(4)*b(4)
45432  DO 100 id=1,3
45433  dum=dum-a(id)*b(id)
45434  100 CONTINUE
45435  pytbhs=dum
45436  RETURN
45437  END
45438 
45439 C*********************************************************************
45440 
45441 C...PYMSIN
45442 C...Initializes supersymmetry: finds sparticle masses and
45443 C...branching ratios and stores this information.
45444 C...AUTHOR: STEPHEN MRENNA
45445 C...Author: P. Skands (SLHA + RPV + ISASUSY Interface, NMSSM)
45446 
45447  SUBROUTINE pymsin
45448 
45449 C...Double precision and integer declarations.
45450  IMPLICIT DOUBLE PRECISION(a-h, o-z)
45451  IMPLICIT INTEGER(i-n)
45452  INTEGER pyk,pychge,pycomp
45453 C...Parameter statement to help give large particle numbers.
45454  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
45455  &kexcit=4000000,kdimen=5000000)
45456 C...Commonblocks.
45457  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
45458  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
45459  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
45460  common/pydat4/chaf(500,2)
45461  CHARACTER chaf*16
45462  common/pypars/mstp(200),parp(200),msti(200),pari(200)
45463  common/pyint4/mwid(500),wids(500,5)
45464  common/pymssm/imss(0:99),rmss(0:99)
45465  common/pymsrv/rvlam(3,3,3), rvlamp(3,3,3), rvlamb(3,3,3)
45466  common/pyssmt/zmix(4,4),umix(2,2),vmix(2,2),smz(4),smw(2),
45467  &sfmix(16,4),zmixi(4,4),umixi(2,2),vmixi(2,2)
45468  common/pyhtri/hhh(7)
45469  common/pyqnum/nqnum,nqdum,kqnum(500,0:9)
45470  SAVE /pydat1/,/pydat2/,/pydat3/,/pydat4/,/pypars/,/pyint4/,
45471  &/pymssm/,/pymsrv/,/pyssmt/
45472 
45473 C...Local variables.
45474  DOUBLE PRECISION alfa,beta
45475  DOUBLE PRECISION tanb,al,be,cosa,cosb,sina,sinb,xw
45476  INTEGER i,j,j1,i1,k1
45477  INTEGER kc,lknt,idlam(400,3)
45478  DOUBLE PRECISION xlam(0:400)
45479  DOUBLE PRECISION wdtp(0:400),wdte(0:400,0:5)
45480  DOUBLE PRECISION xarg,cos2b,xmw2,xmz2
45481  DOUBLE PRECISION delm,xmdif
45482  DOUBLE PRECISION dx,dy,ds,dmu2,dma2,dq2,du2,dd2,dl2,de2,dhu2,dhd2
45483  DOUBLE PRECISION arg,sgnmu,r
45484  INTEGER imssm
45485  INTEGER irprty
45486  INTEGER kfsusy(50),mwidsu(36),mdcysu(36)
45487  SAVE mwidsu,mdcysu
45488  DATA kfsusy/
45489  &1000001,2000001,1000002,2000002,1000003,2000003,
45490  &1000004,2000004,1000005,2000005,1000006,2000006,
45491  &1000011,2000011,1000012,2000012,1000013,2000013,
45492  &1000014,2000014,1000015,2000015,1000016,2000016,
45493  &1000021,1000022,1000023,1000025,1000035,1000024,
45494  &1000037,1000039, 25, 35, 36, 37,
45495  & 6, 24, 45, 46,1000045, 9*0/
45496  DATA init/0/
45497 
45498 C...Automatically read QNUMBERS, MASS, and DECAY tables
45499  IF (imss(21).NE.0.OR.mstp(161).NE.0) THEN
45500  nqnum=0
45501  CALL pyslha(0,0,ifail)
45502  CALL pyslha(5,0,ifail)
45503  ENDIF
45504  IF (imss(22).NE.0.OR.mstp(161).NE.0) CALL pyslha(2,0,ifail)
45505 
45506 C...Do nothing further if SUSY not requested
45507  imssm=imss(1)
45508  IF(imssm.EQ.0) RETURN
45509 
45510 C...Save copy of MWID(KC) and MDCY(KC,1) values before
45511 C...they are set to zero for the LSP.
45512  IF(init.EQ.0) THEN
45513  init=1
45514  DO 100 i=1,36
45515  kf=kfsusy(i)
45516  kc=pycomp(kf)
45517  mwidsu(i)=mwid(kc)
45518  mdcysu(i)=mdcy(kc,1)
45519  100 CONTINUE
45520  ENDIF
45521 
45522 C...Restore MWID(KC) and MDCY(KC,1) values previously zeroed for LSP.
45523  DO 110 i=1,36
45524  kf=kfsusy(i)
45525  kc=pycomp(kf)
45526  IF(mdcy(kc,1).EQ.0.AND.mdcysu(i).NE.0) THEN
45527  mwid(kc)=mwidsu(i)
45528  mdcy(kc,1)=mdcysu(i)
45529  ENDIF
45530  110 CONTINUE
45531 
45532 C...First part of routine: set masses and couplings.
45533 
45534 C...Reset mixing values in sfermion sector to pure left/right.
45535  DO 120 i=1,16
45536  sfmix(i,1)=1d0
45537  sfmix(i,4)=1d0
45538  sfmix(i,2)=0d0
45539  sfmix(i,3)=0d0
45540  120 CONTINUE
45541 
45542 C...Add NMSSM states if NMSSM switched on, and change old names.
45543  IF (imss(13).NE.0.AND.pycomp(1000045).EQ.0) THEN
45544 C... Switch on NMSSM
45545  WRITE(mstu(11),*) '(PYMSIN:) switching on NMSSM'
45546 
45547  kfn=25
45548  kcn=kfn
45549  chaf(kcn,1)='h_10'
45550  chaf(kcn,2)=' '
45551 
45552  kfn=35
45553  kcn=kfn
45554  chaf(kcn,1)='h_20'
45555  chaf(kcn,2)=' '
45556 
45557  kfn=45
45558  kcn=kfn
45559  chaf(kcn,1)='h_30'
45560  chaf(kcn,2)=' '
45561 
45562  kfn=36
45563  kcn=kfn
45564  chaf(kcn,1)='A_10'
45565  chaf(kcn,2)=' '
45566 
45567  kfn=46
45568  kcn=kfn
45569  chaf(kcn,1)='A_20'
45570  chaf(kcn,2)=' '
45571 
45572  kfn=1000045
45573  kcn=pycomp(kfn)
45574  IF (kcn.EQ.0) THEN
45575  DO 123 kct=100,mstu(6)
45576  IF(kchg(kct,4).GT.100) kcn=kct
45577  123 CONTINUE
45578  kcn=kcn+1
45579  kchg(kcn,4)=kfn
45580  mstu(20)=0
45581  ENDIF
45582 C... Set stable for now
45583  pmas(kcn,2)=1d-6
45584  mwid(kcn)=0
45585  mdcy(kcn,1)=0
45586  mdcy(kcn,2)=0
45587  mdcy(kcn,3)=0
45588  chaf(kcn,1)='~chi_50'
45589  chaf(kcn,2)=' '
45590  ENDIF
45591 
45592 C...Read spectrum from SLHA file.
45593  IF (imssm.EQ.11) THEN
45594  CALL pyslha(1,0,ifail)
45595  ENDIF
45596 
45597 C...Common couplings.
45598  tanb=rmss(5)
45599  beta=atan(tanb)
45600  cosb=cos(beta)
45601  sinb=tanb*cosb
45602  cos2b=cos(2d0*beta)
45603  alfa=rmss(18)
45604  xmw2=pmas(24,1)**2
45605  xmz2=pmas(23,1)**2
45606  xw=paru(102)
45607 
45608 C...Define sparticle masses for a general MSSM simulation.
45609  IF(imssm.EQ.1) THEN
45610  IF(imss(9).EQ.0) rmss(22)=rmss(9)
45611  DO 130 i=1,5,2
45612  kc=pycomp(ksusy1+i)
45613  pmas(kc,1)=sqrt(rmss(8)**2-(2d0*xmw2+xmz2)*cos2b/6d0)
45614  kc=pycomp(ksusy2+i)
45615  pmas(kc,1)=sqrt(rmss(9)**2+(xmw2-xmz2)*cos2b/3d0)
45616  kc=pycomp(ksusy1+i+1)
45617  pmas(kc,1)=sqrt(rmss(8)**2+(4d0*xmw2-xmz2)*cos2b/6d0)
45618  kc=pycomp(ksusy2+i+1)
45619  pmas(kc,1)=sqrt(rmss(22)**2-(xmw2-xmz2)*cos2b*2d0/3d0)
45620  130 CONTINUE
45621  xarg=rmss(6)**2-pmas(24,1)**2*abs(cos(2d0*beta))
45622  IF(xarg.LT.0d0) THEN
45623  WRITE(mstu(11),*) ' SNEUTRINO MASS IS NEGATIVE'//
45624  & ' FROM THE SUM RULE. '
45625  WRITE(mstu(11),*) ' TRY A SMALLER VALUE OF TAN(BETA). '
45626  RETURN
45627  ELSE
45628  xarg=sqrt(xarg)
45629  ENDIF
45630  DO 140 i=11,15,2
45631  pmas(pycomp(ksusy1+i),1)=rmss(6)
45632  pmas(pycomp(ksusy2+i),1)=rmss(7)
45633  pmas(pycomp(ksusy1+i+1),1)=xarg
45634  pmas(pycomp(ksusy2+i+1),1)=9999d0
45635  140 CONTINUE
45636  IF(imss(8).EQ.1) THEN
45637  rmss(13)=rmss(6)
45638  rmss(14)=rmss(7)
45639  ENDIF
45640 
45641 C...Alternatively derive masses from SUGRA relations.
45642  ELSEIF(imssm.EQ.2) THEN
45643  rmss(36)=rmss(16)
45644  CALL pyapps
45645 C...Or use ISASUSY
45646  ELSEIF(imssm.EQ.12.OR.imssm.EQ.13) THEN
45647  rmss(36)=rmss(16)
45648  CALL pysugi
45649  alfa=rmss(18)
45650  goto 170
45651  ELSE
45652  goto 170
45653  ENDIF
45654 
45655 C...Add in extra D-term contributions.
45656  IF(imss(7).EQ.1) THEN
45657  r=0.43d0
45658  dx=rmss(23)
45659  dy=rmss(24)
45660  ds=rmss(25)
45661  WRITE(mstu(11),*) 'CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC'
45662  WRITE(mstu(11),*) 'C NEW DTERMS ADDED TO SCALAR MASSES '
45663  WRITE(mstu(11),*) 'C IN A U(B-L) THEORY '
45664  WRITE(mstu(11),*) 'C DX = ',dx
45665  WRITE(mstu(11),*) 'C DY = ',dy
45666  WRITE(mstu(11),*) 'C DS = ',ds
45667  WRITE(mstu(11),*) 'C '
45668  dy=r*dy-4d0/33d0*(1d0-r)*dx+(1d0-r)/33d0*ds
45669  WRITE(mstu(11),*) 'C DY AT THE WEAK SCALE = ',dy
45670  WRITE(mstu(11),*) 'CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC'
45671  dq2=dy/6d0-dx/3d0-ds/3d0
45672  du2=-2d0*dy/3d0-dx/3d0-ds/3d0
45673  dd2=dy/3d0+dx-2d0*ds/3d0
45674  dl2=-dy/2d0+dx-2d0*ds/3d0
45675  de2=dy-dx/3d0-ds/3d0
45676  dhu2=dy/2d0+2d0*dx/3d0+2d0*ds/3d0
45677  dhd2=-dy/2d0-2d0*dx/3d0+ds
45678  dmu2=(-dy/2d0-2d0/3d0*dx+(cosb**2-2d0*sinb**2/3d0)*ds)
45679  & /abs(cos2b)
45680  dma2 = 2d0*dmu2+dhu2+dhd2
45681  DO 150 i=1,5,2
45682  kc=pycomp(ksusy1+i)
45683  pmas(kc,1)=sqrt(pmas(kc,1)**2+dq2)
45684  kc=pycomp(ksusy2+i)
45685  pmas(kc,1)=sqrt(pmas(kc,1)**2+dd2)
45686  kc=pycomp(ksusy1+i+1)
45687  pmas(kc,1)=sqrt(pmas(kc,1)**2+dq2)
45688  kc=pycomp(ksusy2+i+1)
45689  pmas(kc,1)=sqrt(pmas(kc,1)**2+du2)
45690  150 CONTINUE
45691  DO 160 i=11,15,2
45692  kc=pycomp(ksusy1+i)
45693  pmas(kc,1)=sqrt(pmas(kc,1)**2+dl2)
45694  kc=pycomp(ksusy2+i)
45695  pmas(kc,1)=sqrt(pmas(kc,1)**2+de2)
45696  kc=pycomp(ksusy1+i+1)
45697  pmas(kc,1)=sqrt(pmas(kc,1)**2+dl2)
45698  160 CONTINUE
45699  IF(rmss(4)**2+dmu2.LT.0d0) THEN
45700  WRITE(mstu(11),*) ' MU2 DRIVEN NEGATIVE '
45701  CALL pystop(104)
45702  ENDIF
45703  sgnmu=sign(1d0,rmss(4))
45704  rmss(4)=sgnmu*sqrt(rmss(4)**2+dmu2)
45705  arg=rmss(10)**2*sign(1d0,rmss(10))+dq2
45706  rmss(10)=sign(sqrt(abs(arg)),arg)
45707  arg=rmss(11)**2*sign(1d0,rmss(11))+dd2
45708  rmss(11)=sign(sqrt(abs(arg)),arg)
45709  arg=rmss(12)**2*sign(1d0,rmss(12))+du2
45710  rmss(12)=sign(sqrt(abs(arg)),arg)
45711  arg=rmss(13)**2*sign(1d0,rmss(13))+dl2
45712  rmss(13)=sign(sqrt(abs(arg)),arg)
45713  arg=rmss(14)**2*sign(1d0,rmss(14))+de2
45714  rmss(14)=sign(sqrt(abs(arg)),arg)
45715  IF( rmss(19)**2 + dma2 .LE. 50d0 ) THEN
45716  WRITE(mstu(11),*) ' MA DRIVEN TOO LOW '
45717  CALL pystop(104)
45718  ENDIF
45719  rmss(19)=sqrt(rmss(19)**2+dma2)
45720  rmss(6)=sqrt(rmss(6)**2+dl2)
45721  rmss(7)=sqrt(rmss(7)**2+de2)
45722  WRITE(mstu(11),*) ' MTL = ',rmss(10)
45723  WRITE(mstu(11),*) ' MBR = ',rmss(11)
45724  WRITE(mstu(11),*) ' MTR = ',rmss(12)
45725  WRITE(mstu(11),*) ' SEL = ',rmss(6),rmss(13)
45726  WRITE(mstu(11),*) ' SER = ',rmss(7),rmss(14)
45727  ENDIF
45728 
45729 C...Fix the third generation sfermions.
45730  CALL pythrg
45731 
45732 C...Fix the neutralino--chargino--gluino sector.
45733  CALL pyinom
45734 
45735 C...Fix the Higgs sector.
45736  CALL pyhggm(alfa)
45737 
45738 C...Choose the Gunion-Haber convention.
45739  alfa=-alfa
45740  rmss(18)=alfa
45741 
45742 C...Print information on mass parameters.
45743  IF(imssm.EQ.2.AND.mstp(122).GT.0) THEN
45744  WRITE(mstu(11),*) 'CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC'
45745  WRITE(mstu(11),*) ' USING APPROXIMATE SUGRA RELATIONS '
45746  WRITE(mstu(11),*) ' M0 = ',rmss(8)
45747  WRITE(mstu(11),*) ' M1/2=',rmss(1)
45748  WRITE(mstu(11),*) ' TANB=',rmss(5)
45749  WRITE(mstu(11),*) ' MU = ',rmss(4)
45750  WRITE(mstu(11),*) ' AT = ',rmss(16)
45751  WRITE(mstu(11),*) ' MA = ',rmss(19)
45752  WRITE(mstu(11),*) ' MTOP=',pmas(6,1)
45753  WRITE(mstu(11),*) 'CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC'
45754  ENDIF
45755  IF(imss(20).EQ.1) THEN
45756  WRITE(mstu(11),*) 'CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC'
45757  WRITE(mstu(11),*) ' DEBUG MODE '
45758  WRITE(mstu(11),*) ' UMIX = ',umix(1,1),umix(1,2),
45759  & umix(2,1),umix(2,2)
45760  WRITE(mstu(11),*) ' UMIXI = ',umixi(1,1),umixi(1,2),
45761  & umixi(2,1),umixi(2,2)
45762  WRITE(mstu(11),*) ' VMIX = ',vmix(1,1),vmix(1,2),
45763  & vmix(2,1),vmix(2,2)
45764  WRITE(mstu(11),*) ' VMIXI = ',vmixi(1,1),vmixi(1,2),
45765  & vmixi(2,1),vmixi(2,2)
45766  WRITE(mstu(11),*) ' ZMIX = ',(zmix(1,i),i=1,4)
45767  WRITE(mstu(11),*) ' ZMIXI = ',(zmixi(1,i),i=1,4)
45768  WRITE(mstu(11),*) ' ZMIX = ',(zmix(2,i),i=1,4)
45769  WRITE(mstu(11),*) ' ZMIXI = ',(zmixi(2,i),i=1,4)
45770  WRITE(mstu(11),*) ' ZMIX = ',(zmix(3,i),i=1,4)
45771  WRITE(mstu(11),*) ' ZMIXI = ',(zmixi(3,i),i=1,4)
45772  WRITE(mstu(11),*) ' ZMIX = ',(zmix(4,i),i=1,4)
45773  WRITE(mstu(11),*) ' ZMIXI = ',(zmixi(4,i),i=1,4)
45774  WRITE(mstu(11),*) ' ALFA = ',alfa
45775  WRITE(mstu(11),*) ' BETA = ',beta
45776  WRITE(mstu(11),*) ' STOP = ',(sfmix(6,i),i=1,4)
45777  WRITE(mstu(11),*) ' SBOT = ',(sfmix(5,i),i=1,4)
45778  WRITE(mstu(11),*) 'CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC'
45779  ENDIF
45780 
45781 C...Set up the Higgs couplings - needed here since initialization
45782 C...in PYINRE did not yet occur when PYWIDT is called below.
45783  170 al=alfa
45784  be=beta
45785  sina=sin(al)
45786  cosa=cos(al)
45787  cosb=cos(be)
45788  sinb=tanb*cosb
45789  sbma=sin(be-al)
45790  sapb=sin(al+be)
45791  capb=cos(al+be)
45792  cbma=cos(be-al)
45793  c2a=cos(2d0*al)
45794  c2b=cosb**2-sinb**2
45795 C...tanb (used for H+)
45796  paru(141)=tanb
45797 
45798 C...Firstly: h
45799 C...Coupling to d-type quarks
45800  paru(161)=sina/cosb
45801 C...Coupling to u-type quarks
45802  paru(162)=-cosa/sinb
45803 C...Coupling to leptons
45804  paru(163)=paru(161)
45805 C...Coupling to Z
45806  paru(164)=sbma
45807 C...Coupling to W
45808  paru(165)=paru(164)
45809 
45810 C...Secondly: H
45811 C...Coupling to d-type quarks
45812  paru(171)=-cosa/cosb
45813 C...Coupling to u-type quarks
45814  paru(172)=-sina/sinb
45815 C...Coupling to leptons
45816  paru(173)=paru(171)
45817 C...Coupling to Z
45818  paru(174)=cbma
45819 C...Coupling to W
45820  paru(175)=paru(174)
45821 C...Coupling to h
45822  IF(imss(4).GE.2) THEN
45823  paru(176)=cos(2d0*al)*cos(be+al)-2d0*sin(2d0*al)*sin(be+al)
45824  ELSE
45825  hhh(3)=hhh(3)+hhh(4)+hhh(5)
45826  paru(176)=-3d0/hhh(1)*(hhh(1)*sina**2*cosb*cosa+
45827  1 hhh(2)*cosa**2*sinb*sina+hhh(3)*(sina**3*sinb+cosa**3*cosb-
45828  2 2d0/3d0*cbma)-hhh(6)*sina*(cosb*c2a+cosa*capb)+
45829  3 hhh(7)*cosa*(sinb*c2a+sina*capb))
45830  ENDIF
45831 C...Coupling to H+
45832 C...Define later
45833  IF(imss(4).GE.2) THEN
45834  paru(168)=-sbma-cos(2d0*be)*sapb/2d0/(1d0-xw)
45835  ELSE
45836  paru(168)=1d0/hhh(1)*(hhh(1)*sinb**2*cosb*sina-
45837  1 hhh(2)*cosb**2*sinb*cosa-hhh(3)*(sinb**3*cosa-cosb**3*sina)+
45838  2 2d0*hhh(5)*sbma-hhh(6)*sinb*(cosb*sapb+sina*c2b)-
45839  3 hhh(7)*cosb*(cosa*c2b-sinb*sapb)-(hhh(5)-hhh(4))*sbma)
45840  ENDIF
45841 C...Coupling to A
45842  IF(imss(4).GE.2) THEN
45843  paru(177)=cos(2d0*be)*cos(be+al)
45844  ELSE
45845  paru(177)=-1d0/hhh(1)*(hhh(1)*sinb**2*cosb*cosa+
45846  1 hhh(2)*cosb**2*sinb*sina+hhh(3)*(sinb**3*sina+cosb**3*cosa)-
45847  2 2d0*hhh(5)*cbma-hhh(6)*sinb*(cosb*capb+cosa*c2b)+
45848  3 hhh(7)*cosb*(sinb*capb+sina*c2b))
45849  ENDIF
45850 C...Coupling to H+
45851  IF(imss(4).GE.2) THEN
45852  paru(178)=paru(177)
45853  ELSE
45854  paru(178)=paru(177)-(hhh(5)-hhh(4))/hhh(1)*cbma
45855  ENDIF
45856 C...Thirdly, A
45857 C...Coupling to d-type quarks
45858  paru(181)=tanb
45859 C...Coupling to u-type quarks
45860  paru(182)=1d0/paru(181)
45861 C...Coupling to leptons
45862  paru(183)=paru(181)
45863  paru(184)=0d0
45864  paru(185)=0d0
45865 C...Coupling to Z h
45866  paru(186)=cos(be-al)
45867 C...Coupling to Z H
45868  paru(187)=sin(be-al)
45869  paru(188)=0d0
45870  paru(189)=0d0
45871  paru(190)=0d0
45872 
45873 C...Finally: H+
45874 C...Coupling to W h
45875  paru(195)=cos(be-al)
45876 
45877 C...Tell that all Higgs couplings have been set.
45878  mstp(4)=1
45879 
45880 C...Set R-Violating couplings.
45881 C...Set lambda couplings to common value or "natural values".
45882  IF ((imss(51).NE.3).AND.(imss(51).NE.0)) THEN
45883  vir3=1d0/(126d0)**3
45884  DO 200 irk=1,3
45885  DO 190 iri=1,3
45886  DO 180 irj=1,3
45887  IF (iri.NE.irj) THEN
45888  IF (iri.LT.irj) THEN
45889  rvlam(iri,irj,irk)=rmss(51)
45890  IF (imss(51).EQ.2) rvlam(iri,irj,irk)=rmss(51)*
45891  & sqrt(pmas(9+2*iri,1)*pmas(9+2*irj,1)*
45892  & pmas(9+2*irk,1)*vir3)
45893  ELSE
45894  rvlam(iri,irj,irk)=-rvlam(irj,iri,irk)
45895  ENDIF
45896  ELSE
45897  rvlam(iri,irj,irk)=0d0
45898  ENDIF
45899  180 CONTINUE
45900  190 CONTINUE
45901  200 CONTINUE
45902  ENDIF
45903 C...Set lambda' couplings to common value or "natural values".
45904  IF ((imss(52).NE.3).AND.(imss(52).NE.0)) THEN
45905  vir3=1d0/(126d0)**3
45906  DO 230 iri=1,3
45907  DO 220 irj=1,3
45908  DO 210 irk=1,3
45909  rvlamp(iri,irj,irk)=rmss(52)
45910  IF (imss(52).EQ.2) rvlamp(iri,irj,irk)=rmss(52)*
45911  & sqrt(pmas(9+2*iri,1)*0.5d0*(pmas(2*irj,1)+
45912  & pmas(2*irj-1,1))*pmas(2*irk-1,1)*vir3)
45913  210 CONTINUE
45914  220 CONTINUE
45915  230 CONTINUE
45916  ENDIF
45917 C...Set lambda'' couplings to common value or "natural values".
45918  IF ((imss(53).NE.3).AND.(imss(53).NE.0)) THEN
45919  vir3=1d0/(126d0)**3
45920  DO 260 iri=1,3
45921  DO 250 irj=1,3
45922  DO 240 irk=1,3
45923  IF (irj.NE.irk) THEN
45924  IF (irj.LT.irk) THEN
45925  rvlamb(iri,irj,irk)=rmss(53)
45926  IF (imss(53).EQ.2) rvlamb(iri,irj,irk)=
45927  & rmss(53)*sqrt(pmas(2*iri,1)*pmas(2*irj-1,1)*
45928  & pmas(2*irk-1,1)*vir3)
45929  ELSE
45930  rvlamb(iri,irj,irk)=-rvlamb(iri,irk,irj)
45931  ENDIF
45932  ELSE
45933  rvlamb(iri,irj,irk) = 0d0
45934  ENDIF
45935  240 CONTINUE
45936  250 CONTINUE
45937  260 CONTINUE
45938  ENDIF
45939 
45940 C...Antisymmetrize couplings set by user
45941  IF (imss(51).EQ.3.OR.imss(53).EQ.3) THEN
45942  DO 290 iri=1,3
45943  DO 280 irj=1,3
45944  DO 270 irk=1,3
45945  IF (rvlam(iri,irj,irk).NE.-rvlam(irj,iri,irk)) THEN
45946  rvlam(irj,iri,irk)=-rvlam(iri,irj,irk)
45947  IF (iri.EQ.irj) rvlam(iri,irj,irk)=0d0
45948  ENDIF
45949  IF (rvlamb(iri,irj,irk).NE.-rvlamb(iri,irk,irj)) THEN
45950  rvlamb(iri,irk,irj)=-rvlamb(iri,irj,irk)
45951  IF (irj.EQ.irk) rvlamb(iri,irj,irk)=0d0
45952  ENDIF
45953  270 CONTINUE
45954  280 CONTINUE
45955  290 CONTINUE
45956  ENDIF
45957 
45958 C...Write spectrum to SLHA file
45959  IF (imss(23).NE.0) THEN
45960  ifail=0
45961  CALL pyslha(3,0,ifail)
45962  ENDIF
45963 
45964 C...Second part of routine: set decay modes and branching ratios.
45965 
45966 C...Allow chi10 -> gravitino + gamma or not.
45967  kc=pycomp(ksusy1+39)
45968  IF( imss(11) .NE. 0 ) THEN
45969  pmas(kc,1)=rmss(21)/1d9
45970  pmas(kc,2)=0d0
45971  irprty=0
45972  WRITE(mstu(11),*) ' ALLOWING DECAYS TO GRAVITINOS '
45973  ELSE IF (imss(51).GE.1.OR.imss(52).GE.1.OR.imss(53).GE.1) THEN
45974  irprty=0
45975  IF (imss(51).GE.1) WRITE(mstu(11),*)
45976  & ' ALLOWING SUSY LLE DECAYS'
45977  IF (imss(52).GE.1) WRITE(mstu(11),*)
45978  & ' ALLOWING SUSY LQD DECAYS'
45979  IF (imss(53).GE.1) WRITE(mstu(11),*)
45980  & ' ALLOWING SUSY UDD DECAYS'
45981  IF (imss(53).GE.1.AND.imss(52).GE.1) WRITE(mstu(11),*)
45982  & ' --- Warning: R-Violating couplings possibly',
45983  & ' incompatible with proton decay'
45984  ELSE
45985  pmas(kc,1)=9999d0
45986  irprty=1
45987  ENDIF
45988 
45989 C...Loop over sparticle and Higgs species.
45990  pmchi1=pmas(pycomp(ksusy1+22),1)
45991 C...Find the LSP or NLSP for a gravitino LSP
45992  ilsp=0
45993  pmlsp=1d20
45994  DO 300 i=1,36
45995  kf=kfsusy(i)
45996  IF(kf.EQ.1000039) goto 300
45997  kc=pycomp(kf)
45998  IF(pmas(kc,1).LT.pmlsp) THEN
45999  ilsp=i
46000  pmlsp=pmas(kc,1)
46001  ENDIF
46002  300 CONTINUE
46003  DO 370 i=1,50
46004  IF (i.GT.39.AND.imss(13).NE.1) goto 370
46005  kf=kfsusy(i)
46006  IF (kf.EQ.0) goto 370
46007  kc=pycomp(kf)
46008  lknt=0
46009 
46010 C...Check if there are any decays listed for this sparticle
46011 C...in a file
46012  IF (imss(22).NE.0.OR.mstp(161).NE.0) THEN
46013  ifail=0
46014  CALL pyslha(2,kf,ifail)
46015  IF (ifail.EQ.0.OR.kf.EQ.6.OR.kf.EQ.24) goto 370
46016  ELSEIF (i.GE.37) THEN
46017  goto 370
46018  ENDIF
46019 
46020 C...Sfermion decays.
46021  IF(i.LE.24) THEN
46022 C...First check to see if sneutrino is lighter than chi10.
46023  IF((i.EQ.15.OR.i.EQ.19.OR.i.EQ.23).AND.
46024  & pmas(kc,1).LT.pmchi1) THEN
46025  ELSE
46026  CALL pysfdc(kf,xlam,idlam,lknt)
46027  ENDIF
46028 
46029 C...Gluino decays.
46030  ELSEIF(i.EQ.25) THEN
46031  CALL pyglui(kf,xlam,idlam,lknt)
46032  IF(i.EQ.ilsp.AND.irprty.EQ.1) lknt=0
46033 
46034 C...Neutralino decays.
46035  ELSEIF(i.GE.26.AND.i.LE.29) THEN
46036  CALL pynjdc(kf,xlam,idlam,lknt)
46037 C...chi10 stable or chi10 -> gravitino + gamma.
46038  IF(i.EQ.26.AND.irprty.EQ.1) THEN
46039  pmas(kc,2)=1d-6
46040  mdcy(kc,1)=0
46041  mwid(kc)=0
46042  ENDIF
46043 
46044 C...Chargino decays.
46045  ELSEIF(i.GE.30.AND.i.LE.31) THEN
46046  CALL pycjdc(kf,xlam,idlam,lknt)
46047 
46048 C...Gravitino is stable.
46049  ELSEIF(i.EQ.32) THEN
46050  mdcy(kc,1)=0
46051  mwid(kc)=0
46052 
46053 C...Higgs decays.
46054  ELSEIF(i.GE.33.AND.i.LE.36) THEN
46055 C...Calculate decays to non-SUSY particles.
46056  CALL pywidt(kf,pmas(kc,1)**2,wdtp,wdte)
46057  lknt=0
46058  DO 310 i1=0,100
46059  xlam(i1)=0d0
46060  310 CONTINUE
46061  DO 330 i1=1,mdcy(kc,3)
46062  k1=mdcy(kc,2)+i1-1
46063  IF(iabs(kfdp(k1,1)).GT.ksusy1.OR.
46064  & iabs(kfdp(k1,2)).GT.ksusy1) goto 330
46065  xlam(i1)=wdtp(i1)
46066  xlam(0)=xlam(0)+xlam(i1)
46067  DO 320 j1=1,3
46068  idlam(i1,j1)=kfdp(k1,j1)
46069  320 CONTINUE
46070  lknt=lknt+1
46071  330 CONTINUE
46072 C...Add the decays to SUSY particles.
46073  CALL pyhext(kf,xlam,idlam,lknt)
46074  ENDIF
46075 C...Zero the branching ratios for use in loop mode
46076 C...thanks to K. Matchev (FNAL)
46077  DO 340 idc=mdcy(kc,2),mdcy(kc,2)+mdcy(kc,3)-1
46078  brat(idc)=0d0
46079  340 CONTINUE
46080 
46081 C...Set stable particles.
46082  IF(lknt.EQ.0) THEN
46083  mdcy(kc,1)=0
46084  mwid(kc)=0
46085  pmas(kc,2)=1d-6
46086  pmas(kc,3)=1d-5
46087  pmas(kc,4)=0d0
46088 
46089 C...Store branching ratios in the standard tables.
46090  ELSE
46091  idc=mdcy(kc,2)+mdcy(kc,3)-1
46092  delm=1d6
46093  DO 360 il=1,lknt
46094  idcsv=idc
46095  350 idc=idc+1
46096  brat(idc)=0d0
46097  IF(idc.EQ.mdcy(kc,2)+mdcy(kc,3)) idc=mdcy(kc,2)
46098  IF(idlam(il,1).EQ.kfdp(idc,1).AND.idlam(il,2).EQ.
46099  & kfdp(idc,2).AND.idlam(il,3).EQ.kfdp(idc,3)) THEN
46100  brat(idc)=xlam(il)/xlam(0)
46101  xmdif=pmas(kc,1)
46102  IF(mdme(idc,1).GE.1) THEN
46103  xmdif=xmdif-pmas(pycomp(kfdp(idc,1)),1)-
46104  & pmas(pycomp(kfdp(idc,2)),1)
46105  IF(kfdp(idc,3).NE.0) xmdif=xmdif-
46106  & pmas(pycomp(kfdp(idc,3)),1)
46107  ENDIF
46108  IF(i.LE.32) THEN
46109  IF(xmdif.GE.0d0) THEN
46110  delm=min(delm,xmdif)
46111  ELSE
46112  WRITE(mstu(11),*) ' ERROR WITH DELM ',delm,xmdif
46113  WRITE(mstu(11),*) ' KF = ',kf
46114  WRITE(mstu(11),*) ' KF(decay) = ',(kfdp(idc,j),j=1,3)
46115  ENDIF
46116  ENDIF
46117  goto 360
46118  ELSEIF(idc.EQ.idcsv) THEN
46119  WRITE(mstu(11),*) ' Error in PYMSIN: SUSY decay ',
46120  & 'channel not recognized:'
46121  WRITE(mstu(11),*) kf,' -> ',(idlam(il,j),j=1,3)
46122  goto 360
46123  ELSE
46124  goto 350
46125  ENDIF
46126  360 CONTINUE
46127 
46128 C...Store width, cutoff and lifetime.
46129  pmas(kc,2)=xlam(0)
46130  IF(pmas(kc,2).LT.0.1d0*delm) THEN
46131  pmas(kc,3)=pmas(kc,2)*10d0
46132  ELSE
46133  pmas(kc,3)=0.95d0*delm
46134  ENDIF
46135  IF(pmas(kc,2).NE.0d0) THEN
46136  pmas(kc,4)=paru(3)/pmas(kc,2)*1d-12
46137  ENDIF
46138 C...Write decays to SLHA file
46139  IF (imss(24).NE.0) THEN
46140  ifail=0
46141  CALL pyslha(4,kf,ifail)
46142  ENDIF
46143 
46144  ENDIF
46145  370 CONTINUE
46146 
46147  RETURN
46148  END
46149 C*********************************************************************
46150 
46151 C...PYSLHA
46152 C...Read/write spectrum or decay data from SLHA standard file(s).
46153 C...P. Skands
46154 C...DECAY TABLE writeout by Nils-Erik Bomark (2010)
46155 
46156 C...MUPDA=0 : READ QNUMBERS/PARTICLE ON LUN=IMSS(21)
46157 C...MUPDA=1 : READ SLHA SPECTRUM ON LUN=IMSS(21)
46158 C...MUPDA=2 : LOOK FOR DECAY TABLE FOR KF=KFORIG ON LUN=IMSS(22)
46159 C... (KFORIG=0 : read all decay tables)
46160 C...MUPDA=3 : WRITE SPECTRUM ON LUN=IMSS(23)
46161 C...MUPDA=4 : WRITE DECAY TABLE FOR KF=KFORIG ON LUN=IMSS(24)
46162 C...MUPDA=5 : READ MASS FOR KF=KFORIG ONLY
46163 C... (KFORIG=0 : read all MASS entries)
46164 
46165  SUBROUTINE pyslha(MUPDA,KFORIG,IRETRN)
46166 
46167 C...Double precision and integer declarations.
46168  IMPLICIT DOUBLE PRECISION(a-h, o-z)
46169  IMPLICIT INTEGER(i-n)
46170  INTEGER pyk,pychge,pycomp
46171  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
46172  &kexcit=4000000,kdimen=5000000)
46173 C...Commonblocks.
46174  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
46175  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
46176  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
46177  common/pydat4/chaf(500,2)
46178  CHARACTER chaf*16
46179  common/pypars/mstp(200),parp(200),msti(200),pari(200)
46180  CHARACTER*40 isaver,visaje
46181  common/pyint4/mwid(500),wids(500,5)
46182  SAVE /pydat1/,/pydat2/,/pydat3/,/pydat4/,/pypars/,/pyint4/
46183 C...SUSY blocks
46184  common/pymssm/imss(0:99),rmss(0:99)
46185  common/pyssmt/zmix(4,4),umix(2,2),vmix(2,2),smz(4),smw(2),
46186  &sfmix(16,4),zmixi(4,4),umixi(2,2),vmixi(2,2)
46187  common/pymsrv/rvlam(3,3,3), rvlamp(3,3,3), rvlamb(3,3,3)
46188  SAVE /pymssm/,/pyssmt/,/pymsrv/
46189 
46190 C...Local arrays, character variables and data.
46191  common/pylh3p/modsel(200),parmin(100),parext(200),rmsoft(0:100),
46192  & au(3,3),ad(3,3),ae(3,3)
46193  common/pylh3c/cpro(2),cver(2)
46194 C...The common block of new states (QNUMBERS / PARTICLE)
46195  common/pyqnum/nqnum,nqdum,kqnum(500,0:9)
46196 C...- NQNUM : Number of QNUMBERS blocks that have been read in
46197 C...- KQNUM(I,0) : KF of new state
46198 C...- KQNUM(I,1) : 3 times electric charge
46199 C...- KQNUM(I,2) : Number of spin states: (2S + 1)
46200 C...- KQNUM(I,3) : Colour rep (1: singlet, 3: triplet, 8: octet)
46201 C...- KQNUM(I,4) : Particle/Antiparticle distinction (0=own anti)
46202 C...- KQNUM(I,5:9) : space available for further quantum numbers
46203  dimension mmod(100),mspc(100),kfdec(100)
46204  SAVE /pylh3p/,/pylh3c/,/pyqnum/,mmod,mspc,kfdec
46205 C...MMOD: flags to set for each block read in.
46206 C... 1: MODSEL 2: MINPAR 3: EXTPAR 4: SMINPUTS
46207 C...MSPC: Flags to set for each block read in.
46208 C... 1: MASS 2: NMIX 3: UMIX 4: VMIX 5: SBOTMIX
46209 C... 6: STOPMIX 7: STAUMIX 8: HMIX 9: GAUGE 10: AU
46210 C...11: AD 12: AE 13: YU 14: YD 15: YE
46211 C...16: SPINFO 17: ALPHA 18: MSOFT 19: QNUMBERS
46212  CHARACTER cpro*12,cver*12,chnlin*6
46213  CHARACTER doc*11, chdum*120, chblck*60
46214  CHARACTER chinl*120,chkf*9,chtmp*16
46215  INTEGER verbos
46216  SAVE verbos
46217 C...Date of last Change
46218  parameter(doc='10 Jun 2010')
46219 C...Local arrays and initial values
46220  dimension idc(5),kfsusy(50)
46221  SAVE kfsusy
46222  DATA nqnum /0/
46223  DATA ndecay /0/
46224  DATA verbos /1/
46225  DATA nhello /0/
46226  DATA mlhef /0/
46227  DATA mlhefd /0/
46228  DATA kfsusy/
46229  &1000001,1000002,1000003,1000004,1000005,1000006,
46230  &2000001,2000002,2000003,2000004,2000005,2000006,
46231  &1000011,1000012,1000013,1000014,1000015,1000016,
46232  &2000011,2000012,2000013,2000014,2000015,2000016,
46233  &1000021,1000022,1000023,1000025,1000035,1000024,
46234  &1000037,1000039, 25, 35, 36, 37,
46235  & 6, 24, 45, 46,1000045, 9*0/
46236  DATA kfdec/100*0/
46237  rmfun(ip)=pmas(pycomp(ip),1)
46238 
46239 C...Shorthand for spectrum and decay table unit numbers
46240  imss21=imss(21)
46241  imss22=imss(22)
46242 
46243 C...Default for LHEF input: read header information
46244  IF (imss21.EQ.0.AND.mstp(161).NE.0) imss21=mstp(161)
46245  IF (imss22.EQ.0.AND.mstp(161).NE.0) imss22=mstp(161)
46246  IF (imss21.EQ.mstp(161).AND.imss21.NE.0) mlhef=1
46247  IF (imss22.EQ.mstp(161).AND.imss22.NE.0) mlhefd=1
46248 
46249 C...Hello World
46250  IF (nhello.EQ.0) THEN
46251  IF ((mlhef.NE.1.AND.mlhefd.NE.1).OR.(imss(1).NE.0)) THEN
46252  WRITE(mstu(11),5000) doc
46253  nhello=1
46254  ENDIF
46255  ENDIF
46256 
46257 C...SLHA file assumed opened by user on unit LFN, stored in IMSS(20
46258 C...+MUPDA).
46259  lfn=imss21
46260  IF (mupda.EQ.2) lfn=imss22
46261  IF (mupda.EQ.3) lfn=imss(23)
46262  IF (mupda.EQ.4) lfn=imss(24)
46263 C...Flag that we have not yet found whatever we were asked to find.
46264  iretrn=1
46265 C...Flag that we are skipping until <slha> tag found (if LHEF)
46266  iskip=0
46267  IF (mlhef.EQ.1.OR.mlhefd.EQ.1) iskip=1
46268 
46269 C...STOP IF LFN IS ZERO (i.e. if no LFN was given).
46270  IF (lfn.EQ.0) THEN
46271  WRITE(mstu(11),*) '* (PYSLHA:) No valid unit given in IMSS'
46272  goto 9999
46273  ENDIF
46274 
46275 C...If reading LHEF header, start by rewinding file
46276  IF (mlhef.EQ.1.OR.mlhefd.EQ.1) rewind(lfn)
46277 
46278 C...If told to read spectrum, first zero all previous information.
46279  IF (mupda.EQ.1) THEN
46280 C...Zero all block read flags
46281  DO 100 m=1,100
46282  mmod(m)=0
46283  mspc(m)=0
46284  100 CONTINUE
46285 C...Zero all (MSSM) masses, widths, and lifetimes in PYTHIA
46286  DO 110 isusy=1,36
46287  kc=pycomp(kfsusy(isusy))
46288  pmas(kc,1)=0d0
46289  110 CONTINUE
46290 C...Zero all (3rd gen sfermion + gaugino/higgsino) mixing matrices.
46291  DO 130 j=1,4
46292  sfmix(5,j) =0d0
46293  sfmix(6,j) =0d0
46294  sfmix(15,j)=0d0
46295  DO 120 l=1,4
46296  zmix(l,j) =0d0
46297  zmixi(l,j)=0d0
46298  IF (j.LE.2.AND.l.LE.2) THEN
46299  umix(l,j) =0d0
46300  umixi(l,j)=0d0
46301  vmix(l,j) =0d0
46302  vmixi(l,j)=0d0
46303  ENDIF
46304  120 CONTINUE
46305 C...Zero signed masses.
46306  smz(j)=0d0
46307  IF (j.LE.2) smw(j)=0d0
46308  130 CONTINUE
46309 
46310 C...If reading decays, reset PYTHIA decay counters.
46311  ELSEIF (mupda.EQ.2) THEN
46312 C...Check if DECAY for this KF already read
46313  IF (kforig.NE.0) THEN
46314  DO 140 idec=1,ndecay
46315  IF (kforig.EQ.kfdec(idec)) THEN
46316  iretrn=0
46317  RETURN
46318  ENDIF
46319  140 CONTINUE
46320  ENDIF
46321  kcc=100
46322  ndc=0
46323  brsum=0d0
46324  DO 150 kc=1,mstu(6)
46325  IF(kc.GT.100.AND.kchg(kc,4).GT.100) kcc=kc
46326  ndc=max(ndc,mdcy(kc,2)+mdcy(kc,3)-1)
46327  150 CONTINUE
46328  ELSEIF (mupda.EQ.5) THEN
46329 C...Zero block read flags
46330  DO 160 m=1,100
46331  mspc(m)=0
46332  160 CONTINUE
46333  ENDIF
46334 
46335 C............READ
46336 C...(QNUMBERS, spectrum, or decays of KF=KFORIG or MASS of KF=KFORIG)
46337  IF(mupda.EQ.0.OR.mupda.EQ.1.OR.mupda.EQ.2.OR.mupda.EQ.5) THEN
46338 C...Initialize program and version strings
46339  IF(mupda.EQ.1.OR.mupda.EQ.2) THEN
46340  cpro(mupda)=' '
46341  cver(mupda)=' '
46342  ENDIF
46343 
46344 C...Initialize read loop
46345  merr=0
46346  nline=0
46347  chblck=' '
46348 C...READ NEW LINE INTO CHINL. GOTO 300 AT END-OF-FILE.
46349  170 chinl=' '
46350  READ(lfn,'(A120)',end=400) chinl
46351 C...Count which line number we're at.
46352  nline=nline+1
46353  WRITE(chnlin,'(I6)') nline
46354 
46355 C...Skip comment and empty lines without processing.
46356  IF (chinl(1:1).EQ.'#'.OR.chinl.EQ.' ') goto 170
46357 
46358 C...We assume all upper case below. Rewrite CHINL to all upper case.
46359  inl=0
46360  igood=0
46361  180 inl=inl+1
46362  IF (chinl(inl:inl).NE.'#') THEN
46363  DO 190 ich=97,122
46364  IF (char(ich).EQ.chinl(inl:inl)) chinl(inl:inl)=char(ich-32)
46365  190 CONTINUE
46366 C...Extra safety. Chek for sensible input on line
46367  IF (igood.EQ.0) THEN
46368  DO 200 ich=48,90
46369  IF (char(ich).EQ.chinl(inl:inl)) igood=1
46370  200 CONTINUE
46371  ENDIF
46372  IF (inl.LT.120) goto 180
46373  ENDIF
46374  IF (igood.EQ.0) goto 170
46375 
46376 C...If reading from LHEF file, skip until <slha> begin tag found
46377  IF (iskip.NE.0) THEN
46378  DO 205 i1=1,10
46379  IF (chinl(i1:i1+4).EQ.'<SLHA') iskip=0
46380  205 CONTINUE
46381  IF (iskip.NE.0) goto 170
46382  ENDIF
46383 
46384 C...Exit when </slha>, <init>, or first <event> tag reached in LHEF file
46385  DO 210 i1=1,10
46386  IF (chinl(i1:i1+5).EQ.'</SLHA'
46387  & .OR.chinl(i1:i1+5).EQ.'<EVENT'
46388  & .OR.chinl(i1:i1+4).EQ.'<INIT') THEN
46389  rewind(lfn)
46390  goto 400
46391  ENDIF
46392  210 CONTINUE
46393 
46394 C...Check for BLOCK begin statement (spectrum).
46395  IF (chinl(1:5).EQ.'BLOCK') THEN
46396  merr=0
46397  READ(chinl,'(A6,A)',err=580) chdum,chblck
46398 C...Check if another of this type of block was already read.
46399 C...(logarithmic interpolation not yet implemented, so duplicates always
46400 C...give errors)
46401  IF (chblck(1:6).EQ.'MODSEL'.AND.mmod(1).NE.0) merr=7
46402  IF (chblck(1:6).EQ.'MINPAR'.AND.mmod(2).NE.0) merr=7
46403  IF (chblck(1:6).EQ.'EXTPAR'.AND.mmod(3).NE.0) merr=7
46404  IF (chblck(1:8).EQ.'SMINPUTS'.AND.mmod(4).NE.0) merr=7
46405  IF (chblck(1:4).EQ.'MASS'.AND.mspc(1).NE.0) merr=7
46406  IF (chblck(1:4).EQ.'NMIX'.AND.mspc(2).NE.0) merr=7
46407  IF (chblck(1:4).EQ.'UMIX'.AND.mspc(3).NE.0) merr=7
46408  IF (chblck(1:4).EQ.'VMIX'.AND.mspc(4).NE.0) merr=7
46409  IF (chblck(1:7).EQ.'SBOTMIX'.AND.mspc(5).NE.0) merr=7
46410  IF (chblck(1:7).EQ.'STOPMIX'.AND.mspc(6).NE.0) merr=7
46411  IF (chblck(1:7).EQ.'STAUMIX'.AND.mspc(7).NE.0) merr=7
46412  IF (chblck(1:4).EQ.'HMIX'.AND.mspc(8).NE.0) merr=7
46413  IF (chblck(1:5).EQ.'ALPHA'.AND.mspc(17).NE.0) merr=7
46414  IF (chblck(1:5).EQ.'AU'.AND.mspc(10).NE.0) merr=7
46415  IF (chblck(1:5).EQ.'AD'.AND.mspc(11).NE.0) merr=7
46416  IF (chblck(1:5).EQ.'AE'.AND.mspc(12).NE.0) merr=7
46417  IF (chblck(1:5).EQ.'MSOFT'.AND.mspc(18).NE.0) merr=7
46418 C...Check for new particles
46419  IF (chblck(1:8).EQ.'QNUMBERS'.OR.chblck(1:8).EQ.'PARTICLE')
46420  & THEN
46421  mspc(19)=mspc(19)+1
46422 C...Read PDG code
46423  READ(chblck(9:60),*) kfq
46424 
46425  DO 220 mq=1,nqnum
46426  IF (kqnum(mq,0).EQ.kfq) THEN
46427  merr=17
46428  goto 380
46429  ENDIF
46430  220 CONTINUE
46431  IF (nhello.EQ.0) THEN
46432  WRITE(mstu(11),5000) doc
46433  nhello=1
46434  ENDIF
46435  WRITE(mstu(11),'(A,I9,A,F12.3)')
46436  & ' * (PYSLHA:) Reading '//chblck(1:8)//
46437  & ' for KF =',kfq
46438  nqnum=nqnum+1
46439  kqnum(nqnum,0)=kfq
46440  mspc(19)=mspc(19)+1
46441  kcq=pycomp(kfq)
46442 C...Only read in new codes (also OK to overwrite if KF > 3000000)
46443  IF (kcq.EQ.0.OR.iabs(kfq).GE.3000000) THEN
46444  IF (kcq.EQ.0) THEN
46445  DO 230 kct=100,mstu(6)
46446  IF(kchg(kct,4).GT.100) kcq=kct
46447  230 CONTINUE
46448  kcq=kcq+1
46449  ENDIF
46450  kcc=kcq
46451  kchg(kcq,4)=kfq
46452 C...First write PDG code as name
46453  WRITE(chtmp,*) kfq
46454  WRITE(chtmp,'(A)') chtmp(2:10)
46455 C...Then look for real name
46456  ibeg=9
46457  240 ibeg=ibeg+1
46458  IF (chblck(ibeg:ibeg).NE.'#'.AND.ibeg.LT.59) goto 240
46459  250 ibeg=ibeg+1
46460  IF (chblck(ibeg:ibeg).EQ.' '.AND.ibeg.LT.59) goto 250
46461  iend=ibeg-1
46462  260 iend=iend+1
46463  IF (chblck(iend+1:iend+1).NE.' '.AND.iend.LT.59) goto 260
46464  IF (iend.LT.59) THEN
46465  READ(chblck(ibeg:iend),'(A)',err=270) chdum
46466  IF (chdum.NE.' ') chtmp=chdum
46467  ENDIF
46468  270 READ(chtmp,'(A)') chaf(kcq,1)
46469  mstu(20)=0
46470 C...Set stable for now
46471  pmas(kcq,2)=1d-6
46472  mwid(kcq)=0
46473  mdcy(kcq,1)=0
46474  mdcy(kcq,2)=0
46475  mdcy(kcq,3)=0
46476  ELSE
46477  WRITE(mstu(11),*)
46478  & '* (PYSLHA:) KF =',kfq,' already exists: ',
46479  & chaf(kcq,1), '. Entry ignored.'
46480  merr=7
46481  ENDIF
46482  ENDIF
46483 C...Finalize this line and read next.
46484  goto 380
46485 C...Check for DECAY begin statement (decays).
46486  ELSEIF (chinl(1:3).EQ.'DEC') THEN
46487  merr=0
46488  brsum=0d0
46489  chblck='DECAY'
46490 C...Read KF code and WIDTH
46491  mpsign=1
46492  READ(chinl(7:inl),*,err=590) kf, width
46493  IF (kf.LE.0) THEN
46494  kf=-kf
46495  mpsign=-1
46496  ENDIF
46497 C...If this is not the KF we're looking for...
46498  IF ((kforig.NE.0.AND.kf.NE.kforig).OR.mupda.NE.2) THEN
46499 C...Set block skip flag and read next line.
46500  merr=16
46501  goto 380
46502  ELSE
46503 C...Check whether decay table for this particle already read in
46504  DO 280 idecay=1,ndecay
46505  IF (kfdec(idecay).EQ.kf) THEN
46506  WRITE(mstu(11),'(A,A,I9,A,A6,A)')
46507  & ' * (PYSLHA:) Ignoring DECAY table ',
46508  & 'for KF =',kf,' on line ',chnlin,
46509  & ' (duplicate)'
46510  merr=16
46511  goto 380
46512  ENDIF
46513  280 CONTINUE
46514  ENDIF
46515 
46516 C...Determine PYTHIA KC code of particle
46517  kcrep=0
46518  IF(kf.LE.100) THEN
46519  kcrep=kf
46520  ELSE
46521  DO 290 kcr=101,kcc
46522  IF(kchg(kcr,4).EQ.kf) kcrep=kcr
46523  290 CONTINUE
46524  ENDIF
46525  kc=kcrep
46526  IF (kcrep.NE.0) THEN
46527 C...Particle is already known. Do not overwrite low-mass SM particles,
46528 C...since this could give problems at hadronization / hadron decay stage.
46529  IF (iabs(kf).LT.1000000.AND.pmas(kc,1).LT.20d0) THEN
46530 C...Set block skip flag and read next line
46531  WRITE(mstu(11),'(A,I9,A,F12.3)')
46532  & ' * (PYSLHA:) Ignoring DECAY table for KF =',
46533  & kf, ' (SLHA read-in not allowed)'
46534  merr=16
46535  goto 380
46536  ELSEIF (iabs(kf).EQ.6.OR.iabs(kf).EQ.23.OR.iabs(kf).EQ.24)
46537  & THEN
46538 C...Set block skip flag and read next line
46539  WRITE(mstu(11),'(A,I9,A,F12.3)')
46540  & ' * (PYSLHA:) Allowing DECAY table for KF =',
46541  & kf, ' but this is NOT recommended.'
46542  ENDIF
46543  ELSE
46544 C... Add new particle. Actually, this should not happen.
46545 C... New particles should be added already when reading the spectrum
46546 C... information, so go under previously stable category.
46547  kcc=kcc+1
46548  kc=kcc
46549  ENDIF
46550 
46551  IF (width.LE.0d0) THEN
46552 C...Stable (i.e. LSP)
46553  WRITE(mstu(11),'(A,I9,A,A)')
46554  & ' * (PYSLHA:) Reading SLHA stable particle KF =',
46555  & kf,', ',chaf(kcrep,1)(1:16)
46556  IF (width.LT.0d0) THEN
46557  CALL pyerrm(19,'(PYSLHA:) Negative width forced to'//
46558  & ' zero !')
46559  width=0d0
46560  ENDIF
46561  pmas(kc,2)=1d-6
46562  mwid(kc)=0
46563  mdcy(kc,1)=0
46564 C...Ignore any decay lines that may be present for this KF
46565  merr=16
46566  mdcy(kc,2)=0
46567  mdcy(kc,3)=0
46568 C...Return ok
46569  iretrn=0
46570  ENDIF
46571 C...Finalize and start reading in decay modes.
46572  goto 380
46573  ELSEIF (mod(merr,10).GE.6) THEN
46574 C...If ignore block flag set, skip directly to next line.
46575  goto 170
46576  ENDIF
46577 
46578 C...READ SPECTRUM
46579  IF (mupda.EQ.0.AND.merr.EQ.0) THEN
46580  IF (chblck(1:8).EQ.'QNUMBERS'.OR.chblck(1:8).EQ.'PARTICLE')
46581  & THEN
46582  READ(chinl,*) indx, ival
46583  IF (indx.GE.1.AND.indx.LE.9) kqnum(nqnum,indx)=ival
46584  IF (indx.EQ.1) kchg(kcq,1)=ival
46585  IF (indx.EQ.3) kchg(kcq,2)=0
46586  IF (indx.EQ.3.AND.ival.EQ.3) kchg(kcq,2)=1
46587  IF (indx.EQ.3.AND.ival.EQ.-3) kchg(kcq,2)=-1
46588  IF (indx.EQ.3.AND.ival.EQ.8) kchg(kcq,2)=2
46589  IF (indx.EQ.4) THEN
46590  kchg(kcq,3)=ival
46591  IF (ival.EQ.1) THEN
46592  chtmp=chaf(kcq,1)
46593  IF (chtmp.EQ.' ') THEN
46594  WRITE(chaf(kcq,1),*) kchg(kcq,4)
46595  WRITE(chaf(kcq,2),*) -kchg(kcq,4)
46596  ELSE
46597  ilast=17
46598  300 ilast=ilast-1
46599  IF (chtmp(ilast:ilast).EQ.' ') goto 300
46600  IF (chtmp(ilast:ilast).EQ.'+') THEN
46601  chtmp(ilast:ilast)='-'
46602  ELSE
46603  chtmp(ilast+1:min(16,ilast+4))='bar'
46604  ENDIF
46605  chaf(kcq,2)=chtmp
46606  ENDIF
46607  ENDIF
46608  ENDIF
46609  ELSE
46610  merr=8
46611  ENDIF
46612  ELSEIF ((mupda.EQ.1.OR.mupda.EQ.5).AND.merr.EQ.0) THEN
46613 C...MASS: Mass spectrum
46614  IF (chblck(1:4).EQ.'MASS') THEN
46615  READ(chinl,*) kf, val
46616  merr=1
46617  kc=0
46618  IF (mupda.EQ.1.OR.kf.EQ.kforig.OR.kforig.EQ.0) THEN
46619 C...Read in masses for almost anything
46620  merr=0
46621  kc=pycomp(kf)
46622  IF (kc.NE.0) THEN
46623 C...Don't read in masses for special code particles
46624  IF (iabs(kf).GE.80.AND.iabs(kf).LT.100) THEN
46625  WRITE(mstu(11),'(A,I9,A,F12.3)')
46626  & ' * (PYSLHA:) Ignoring MASS entry for KF =',
46627  & kf, ' (KF reserved by PYTHIA)'
46628  goto 170
46629  ENDIF
46630 C...Be careful with light SM particles / hadrons
46631  IF (pmas(kc,1).LE.20d0) THEN
46632  IF (iabs(kf).LE.22) THEN
46633  WRITE(mstu(11),'(A,I9,A,F12.3)')
46634  & ' * (PYSLHA:) Ignoring MASS entry for KF =',
46635  & kf, ' (SLHA read-in not allowed)'
46636 
46637  goto 170
46638  ELSEIF (iabs(kf).GE.100.AND.iabs(kf).LT.1000000) THEN
46639  WRITE(mstu(11),'(A,I9,A,F12.3)')
46640  & ' * (PYSLHA:) Ignoring MASS entry for KF =',
46641  & kf, ' (SLHA read-in not allowed)'
46642  goto 170
46643  ENDIF
46644  ENDIF
46645  mspc(1)=mspc(1)+1
46646  pmas(kc,1) = abs(val)
46647  IF (mupda.EQ.5.AND.imss(1).EQ.0) THEN
46648  WRITE(mstu(11),'(A,I9,A,F12.3)')
46649  & ' * (PYSLHA:) Reading MASS entry for KF =',
46650  & kf, ', pole mass =', val
46651  iretrn=0
46652  ENDIF
46653 C...Check Z, W and top masses
46654  IF (kf.EQ.23.AND.abs(pmas(pycomp(23),1)-91.2d0).GT.1d0)
46655  & THEN
46656  WRITE(chtmp,8500) pmas(pycomp(23),1)
46657  CALL pyerrm(9,'(PYSLHA:) Note Z boson mass, M ='
46658  & //chtmp)
46659  ENDIF
46660  IF (kf.EQ.24.AND.abs(pmas(pycomp(24),1)-80.4d0).GT.1d0)
46661  & THEN
46662  WRITE(chtmp,8500) pmas(pycomp(24),1)
46663  CALL pyerrm(9,'(PYSLHA:) Note W boson mass, M ='
46664  & //chtmp)
46665  ENDIF
46666  IF (kf.EQ.6.AND.abs(pmas(pycomp(6),1)-175d0).GT.25d0)
46667  & THEN
46668  WRITE(chtmp,8500) pmas(pycomp(6),1)
46669  CALL pyerrm(9,'(PYSLHA:) Note top quark mass, M ='
46670  & //chtmp//'GeV')
46671  ENDIF
46672 C... Signed masses
46673  IF (kf.EQ.1000021.AND.mspc(18).EQ.0) rmss(3)=val
46674  IF (kf.EQ.1000022) smz(1)=val
46675  IF (kf.EQ.1000023) smz(2)=val
46676  IF (kf.EQ.1000025) smz(3)=val
46677  IF (kf.EQ.1000035) smz(4)=val
46678  IF (kf.EQ.1000024) smw(1)=val
46679  IF (kf.EQ.1000037) smw(2)=val
46680  ENDIF
46681  ELSEIF (mupda.EQ.5) THEN
46682  merr=0
46683  ENDIF
46684 C... MODSEL: Model selection and global switches
46685  ELSEIF (chblck(1:6).EQ.'MODSEL') THEN
46686  READ(chinl,*) indx, ival
46687  IF (indx.LE.200.AND.indx.GT.0) THEN
46688  IF (imss(1).EQ.0) imss(1)=11
46689  modsel(indx)=ival
46690  mmod(1)=mmod(1)+1
46691  IF (indx.EQ.3.AND.ival.EQ.1.AND.pycomp(1000045).EQ.0) THEN
46692 C... Switch on NMSSM
46693  WRITE(mstu(11),*) '* (PYSLHA:) switching on NMSSM'
46694  imss(13)=max(1,imss(13))
46695 C... Add NMSSM states if not already done
46696 
46697  kfn=25
46698  kcn=kfn
46699  chaf(kcn,1)='h_10'
46700  chaf(kcn,2)=' '
46701 
46702  kfn=35
46703  kcn=kfn
46704  chaf(kcn,1)='h_20'
46705  chaf(kcn,2)=' '
46706 
46707  kfn=45
46708  kcn=kfn
46709  chaf(kcn,1)='h_30'
46710  chaf(kcn,2)=' '
46711 
46712  kfn=36
46713  kcn=kfn
46714  chaf(kcn,1)='A_10'
46715  chaf(kcn,2)=' '
46716 
46717  kfn=46
46718  kcn=kfn
46719  chaf(kcn,1)='A_20'
46720  chaf(kcn,2)=' '
46721 
46722  kfn=1000045
46723  kcn=pycomp(kfn)
46724  IF (kcn.EQ.0) THEN
46725  DO 310 kct=100,mstu(6)
46726  IF(kchg(kct,4).GT.100) kcn=kct
46727  310 CONTINUE
46728  kcn=kcn+1
46729  kchg(kcn,4)=kfn
46730  mstu(20)=0
46731  ENDIF
46732 C... Set stable for now
46733  pmas(kcn,2)=1d-6
46734  mwid(kcn)=0
46735  mdcy(kcn,1)=0
46736  mdcy(kcn,2)=0
46737  mdcy(kcn,3)=0
46738  chaf(kcn,1)='~chi_50'
46739  chaf(kcn,2)=' '
46740  ENDIF
46741  ELSE
46742  merr=1
46743  ENDIF
46744  ELSEIF (mupda.EQ.5) THEN
46745 C...If MUPDA = 5, skip all except MASS, return if MODSEL
46746  merr=8
46747  ELSEIF (chblck(1:8).EQ.'QNUMBERS'.OR.
46748  & chblck(1:8).EQ.'PARTICLE') THEN
46749 C...Don't print a warning for QNUMBERS when reading spectrum
46750  merr=8
46751 C...MINPAR: Minimal model parameters
46752  ELSEIF (chblck(1:6).EQ.'MINPAR') THEN
46753  READ(chinl,*) indx, val
46754  IF (indx.LE.100.AND.indx.GT.0) THEN
46755  parmin(indx)=val
46756  mmod(2)=mmod(2)+1
46757  ELSE
46758  merr=1
46759  ENDIF
46760  IF (mmod(3).NE.0) THEN
46761  WRITE(mstu(11),*)
46762  & '* (PYSLHA:) MINPAR should come before EXTPAR !'
46763  merr=1
46764  ENDIF
46765 C...tan(beta)
46766  IF (indx.EQ.3) rmss(5)=val
46767 C...EXTPAR: non-minimal model parameters.
46768  ELSEIF (chblck(1:6).EQ.'EXTPAR') THEN
46769  IF (mmod(1).NE.0) THEN
46770  READ(chinl,*) indx, val
46771  IF (indx.LE.200.AND.indx.GT.0) THEN
46772  parext(indx)=val
46773  mmod(3)=mmod(3)+1
46774  ELSE
46775  merr=1
46776  ENDIF
46777  ELSE
46778  WRITE(mstu(11),*)
46779  & '* (PYSLHA:) Reading EXTPAR, but no MODSEL !'
46780  merr=1
46781  ENDIF
46782 C...tan(beta)
46783  IF (indx.EQ.25) rmss(5)=val
46784  ELSEIF (chblck(1:8).EQ.'SMINPUTS') THEN
46785  READ(chinl,*) indx, val
46786  IF (indx.LE.3.OR.indx.EQ.5.OR.indx.GE.7) THEN
46787  merr=1
46788  ELSEIF (indx.EQ.4) THEN
46789  pmas(pycomp(23),1)=val
46790  ELSEIF (indx.EQ.6) THEN
46791  pmas(pycomp(6),1)=val
46792  ENDIF
46793  ELSEIF (chblck(1:4).EQ.'NMIX'.OR.chblck(1:4).EQ.'VMIX'.or
46794  $ .chblck(1:4).EQ.'UMIX'.OR.chblck(1:7).EQ.'STOPMIX'.or
46795  $ .chblck(1:7).EQ.'SBOTMIX'.OR.chblck(1:7).EQ.'STAUMIX')
46796  $ THEN
46797 C...NMIX,UMIX,VMIX,STOPMIX,SBOTMIX, and STAUMIX. Mixing.
46798  im=0
46799  IF (chblck(5:6).EQ.'IM') im=1
46800  320 READ(chinl,*) indx1, indx2, val
46801  IF (chblck(1:1).EQ.'N'.AND.indx1.LE.4.AND.indx2.LE.4) THEN
46802  IF (im.EQ.0) zmix(indx1,indx2) = val
46803  IF (im.EQ.1) zmixi(indx1,indx2)= val
46804  mspc(2)=mspc(2)+1
46805  ELSEIF (chblck(1:1).EQ.'U') THEN
46806  IF (im.EQ.0) umix(indx1,indx2) = val
46807  IF (im.EQ.1) umixi(indx1,indx2)= val
46808  mspc(3)=mspc(3)+1
46809  ELSEIF (chblck(1:1).EQ.'V') THEN
46810  IF (im.EQ.0) vmix(indx1,indx2) = val
46811  IF (im.EQ.1) vmixi(indx1,indx2)= val
46812  mspc(4)=mspc(4)+1
46813  ELSEIF (chblck(1:4).EQ.'STOP'.OR.chblck(1:4).EQ.'SBOT'.or
46814  $ .chblck(1:4).EQ.'STAU') THEN
46815  IF (chblck(1:4).EQ.'STOP') THEN
46816  kfsm=6
46817  ispc=6
46818  ELSEIF (chblck(1:4).EQ.'SBOT') THEN
46819  kfsm=5
46820  ispc=5
46821  ELSEIF (chblck(1:4).EQ.'STAU') THEN
46822  kfsm=15
46823  ispc=7
46824  ENDIF
46825 C...Set SFMIX element
46826  sfmix(kfsm,2*(indx1-1)+indx2)=val
46827  mspc(ispc)=mspc(ispc)+1
46828  ENDIF
46829 C...Running parameters
46830  ELSEIF (chblck(1:4).EQ.'HMIX') THEN
46831  READ(chblck(8:25),*,err=620) q
46832  READ(chinl,*) indx, val
46833  mspc(8)=mspc(8)+1
46834  IF (indx.EQ.1) THEN
46835  rmss(4) = val
46836  ELSE
46837  merr=1
46838  mspc(8)=mspc(8)-1
46839  ENDIF
46840  ELSEIF (chblck(1:5).EQ.'ALPHA') THEN
46841  READ(chinl,*,err=630) val
46842  rmss(18)= val
46843  mspc(17)=mspc(17)+1
46844 C...Higgs parameters set manually or with FeynHiggs.
46845  imss(4)=max(2,imss(4))
46846  ELSEIF (chblck(1:2).EQ.'AU'.OR.chblck(1:2).EQ.'AD'.or
46847  & .chblck(1:2).EQ.'AE') THEN
46848  READ(chblck(9:26),*,err=620) q
46849  READ(chinl,*) indx1, indx2, val
46850  IF (chblck(2:2).EQ.'U') THEN
46851  au(indx1,indx2)=val
46852  IF (indx1.EQ.3.AND.indx2.EQ.3) rmss(16)=val
46853  mspc(11)=mspc(11)+1
46854  ELSEIF (chblck(2:2).EQ.'D') THEN
46855  ad(indx1,indx2)=val
46856  IF (indx1.EQ.3.AND.indx2.EQ.3) rmss(15)=val
46857  mspc(10)=mspc(10)+1
46858  ELSEIF (chblck(2:2).EQ.'E') THEN
46859  ae(indx1,indx2)=val
46860  IF (indx1.EQ.3.AND.indx2.EQ.3) rmss(17)=val
46861  mspc(12)=mspc(12)+1
46862  ELSE
46863  merr=1
46864  ENDIF
46865  ELSEIF (chblck(1:5).EQ.'MSOFT') THEN
46866  IF (mspc(18).EQ.0) THEN
46867  READ(chblck(9:25),*,err=620) q
46868  rmsoft(0)=q
46869  ENDIF
46870  READ(chinl,*) indx, val
46871  rmsoft(indx)=val
46872  mspc(18)=mspc(18)+1
46873  ELSEIF (chblck(1:5).EQ.'GAUGE') THEN
46874  merr=8
46875  ELSEIF (chblck(1:2).EQ.'YU'.OR.chblck(1:2).EQ.'YD'.or
46876  & .chblck(1:2).EQ.'YE') THEN
46877  merr=8
46878  ELSEIF (chblck(1:6).EQ.'SPINFO') THEN
46879  READ(chinl(1:6),*) indx
46880  it=0
46881  mird=0
46882  330 it=it+1
46883  IF (chinl(it:it).EQ.' ') goto 330
46884 C...Don't read index
46885  IF (chinl(it:it).EQ.char(indx+48).AND.mird.EQ.0) THEN
46886  mird=1
46887  goto 330
46888  ENDIF
46889  IF (indx.EQ.1) cpro(1)=chinl(it:it+12)
46890  IF (indx.EQ.2) cver(1)=chinl(it:it+12)
46891  ELSE
46892 C... Set unrecognized block flag.
46893  merr=6
46894  ENDIF
46895 
46896 C...DECAY TABLES
46897 C...Read in decay information
46898  ELSEIF (mupda.EQ.2.AND.merr.EQ.0) THEN
46899 C...Read new decay chanel
46900  IF(chinl(1:1).EQ.' '.AND.chblck(1:5).EQ.'DECAY') THEN
46901  ndc=ndc+1
46902 C...Read in branching ratio and number of daughters for this mode.
46903  READ(chinl(4:50),*,err=390) brat(ndc)
46904  READ(chinl(4:50),*,err=600) dum, nda
46905  IF (nda.LE.5) THEN
46906  IF(ndc.GT.mstu(7)) CALL pyerrm(27,
46907  & '(PYSLHA:) Decay data arrays full by KF = '
46908  $ //chaf(kc,1))
46909 C...If first decay channel, set decays start point in decay table
46910  IF(brsum.LE.0d0.AND.brat(ndc).NE.0d0) THEN
46911  IF (kforig.EQ.0) WRITE(mstu(11),'(1x,A,I9,A,A16)')
46912  & '* (PYSLHA:) Reading DECAY table for '//
46913  & 'KF =',kf,', ',chaf(kcrep,1)(1:16)
46914 C...Set particle parameters (mass set when reading BLOCK MASS above)
46915  pmas(kc,2)=width
46916  IF (kf.EQ.25.OR.kf.EQ.35.OR.kf.EQ.36) THEN
46917  WRITE(mstu(11),'(1x,A)')
46918  & '* Note: the Pythia gg->h/H/A cross section'//
46919  & ' is proportional to the h/H/A->gg width'
46920  ELSEIF (kf.EQ.23.OR.kf.EQ.24.OR.kf.EQ.6.OR.kf.EQ.32
46921  & .OR.kf.EQ.33.OR.kf.EQ.34) THEN
46922  WRITE(mstu(11),'(1x,A,A16)')
46923  & '* Warning: will use DECAY table (fixed-width,'//
46924  & ' flat PS) for ',chaf(kc,1)(1:16)
46925  ENDIF
46926  pmas(kc,3)=0d0
46927  pmas(kc,4)=paru(3)*1d-12/width
46928  mwid(kc)=2
46929  mdcy(kc,1)=1
46930  mdcy(kc,2)=ndc
46931  mdcy(kc,3)=0
46932 C...Add to list of DECAY blocks currently read
46933  ndecay=ndecay+1
46934  kfdec(ndecay)=kf
46935 C...Return ok
46936  iretrn=0
46937  ENDIF
46938 C... Count up number of decay modes for this particle
46939  mdcy(kc,3)=mdcy(kc,3)+1
46940 C... Read in decay daughters.
46941  READ(chinl(4:120),*,err=610) dum,idm, (idc(ida),ida=1,nda)
46942 C... Flip sign if reading antiparticle decays (if antipartner exists)
46943  DO 340 ida=1,nda
46944  IF (kchg(pycomp(idc(ida)),3).NE.0)
46945  & idc(ida)=mpsign*idc(ida)
46946  340 CONTINUE
46947 C...Switch on decay channel, with products ordered in decreasing ABS(KF)
46948  mdme(ndc,1)=1
46949  IF (brat(ndc).LE.0d0) mdme(ndc,1)=0
46950  brsum=brsum+abs(brat(ndc))
46951  brat(ndc)=abs(brat(ndc))
46952  350 iflip=0
46953  DO 360 ida=1,nda-1
46954  IF (iabs(idc(ida+1)).GT.iabs(idc(ida))) THEN
46955  itmp=idc(ida)
46956  idc(ida)=idc(ida+1)
46957  idc(ida+1)=itmp
46958  iflip=iflip+1
46959  ENDIF
46960  360 CONTINUE
46961  IF (iflip.GT.0) goto 350
46962 C...Treat as ordinary decay, no fancy stuff.
46963  mdme(ndc,2)=0
46964  DO 370 ida=1,5
46965  IF (ida.LE.nda) THEN
46966  kfdp(ndc,ida)=idc(ida)
46967  ELSE
46968  kfdp(ndc,ida)=0
46969  ENDIF
46970  370 CONTINUE
46971 C WRITE(MSTU(11),7510) NDC, BRAT(NDC), NDA,
46972 C & (KFDP(NDC,J),J=1,NDA)
46973  ELSE
46974  CALL pyerrm(7,'(PYSLHA:) Too many daughters on line '//
46975  & chnlin)
46976  merr=11
46977  ndc=ndc-1
46978  ENDIF
46979  ELSEIF(chinl(1:1).EQ.'+') THEN
46980  merr=11
46981  ELSEIF(chblck(1:6).EQ.'DCINFO') THEN
46982  merr=16
46983  ELSE
46984  merr=16
46985  ENDIF
46986  ENDIF
46987 C... Error check.
46988  380 IF (mod(merr,10).EQ.1.AND.(mupda.EQ.1.OR.mupda.EQ.2)) THEN
46989  WRITE(mstu(11),*) '* (PYSLHA:) Ignoring line '//chnlin//': '
46990  & //chinl(1:40)
46991  merr=0
46992  ELSEIF (merr.EQ.6.AND.mupda.EQ.1) THEN
46993  WRITE(mstu(11),*) '* (PYSLHA:) Ignoring BLOCK '//
46994  & chblck(1:min(inl,40))//'... on line '//chnlin
46995  ELSEIF (merr.EQ.8.AND.mupda.EQ.1) THEN
46996  WRITE(mstu(11),*) '* (PYSLHA:) PYTHIA will not use BLOCK '
46997  & //chblck(1:inl)//'... on line'//chnlin
46998  ELSEIF (merr.EQ.16.AND.mupda.EQ.2.AND.imss21.EQ.0.AND.
46999  & chblck(1:1).NE.'D'.AND.verbos.EQ.1) THEN
47000  WRITE(mstu(11),*) '* (PYSLHA:) Ignoring BLOCK '//chblck(1:inl)
47001  & //'... on line'//chnlin
47002  ELSEIF (merr.EQ.7.AND.mupda.EQ.1) THEN
47003  WRITE(mstu(11),*) '* (PYSLHA:) Ignoring extra BLOCK '/
47004  & /chblck(1:inl)//'... on line'//chnlin
47005  ELSEIF (merr.EQ.2.AND.mupda.EQ.1) THEN
47006  WRITE (chtmp,*) kf
47007  WRITE(mstu(11),*)
47008  & '* (PYSLHA:) Ignoring extra MASS entry for KF='//
47009  & chtmp(1:9)//' on line'//chnlin
47010  ENDIF
47011 C...Iterate read loop
47012  goto 170
47013 C...Error catching
47014  390 WRITE(*,*) '* (PYSLHA:) read BR error on line',nline,
47015  & ', ignoring subsequent lines.'
47016  WRITE(*,*) '* (PYSLHA:) Offending line:',chinl(1:46)
47017  chblck=' '
47018  goto 170
47019 C...End of read loop
47020  400 CONTINUE
47021 C...Set flag that KC codes have been rearranged.
47022  mstu(20)=0
47023  verbos=0
47024 
47025 C...Perform possible tests that new information is consistent.
47026  IF (mupda.EQ.1) THEN
47027  mstu23=mstu(23)
47028  mstu27=mstu(27)
47029 C...Check masses
47030  DO 410 isusy=1,37
47031  kf=kfsusy(isusy)
47032 C...Don't complain about right-handed neutrinos
47033  IF (kf.EQ.ksusy2+12.OR.kf.EQ.ksusy2+14.OR.kf.EQ.ksusy2
47034  & +16) goto 410
47035 C...Only check gravitino in GMSB scenarios
47036  IF (modsel(1).NE.2.AND.kf.EQ.ksusy1+39) goto 410
47037  kc=pycomp(kf)
47038  IF (pmas(kc,1).EQ.0d0) THEN
47039  WRITE(chtmp,*) kf
47040  CALL pyerrm(9
47041  & ,'(PYSLHA:) No mass information found for KF ='
47042  & //chtmp)
47043  ENDIF
47044  410 CONTINUE
47045 C...Check mixing matrices (MSSM only)
47046  IF (imss(13).EQ.0) THEN
47047  IF (mspc(2).NE.16.AND.mspc(2).NE.32) CALL pyerrm(9
47048  & ,'(PYSLHA:) Inconsistent # of elements in NMIX')
47049  IF (mspc(3).NE.4.AND.mspc(3).NE.8) CALL pyerrm(9
47050  & ,'(PYSLHA:) Inconsistent # of elements in UMIX')
47051  IF (mspc(4).NE.4.AND.mspc(4).NE.8) CALL pyerrm(9
47052  & ,'(PYSLHA:) Inconsistent # of elements in VMIX')
47053  IF (mspc(5).NE.4) CALL pyerrm(9
47054  & ,'(PYSLHA:) Inconsistent # of elements in SBOTMIX')
47055  IF (mspc(6).NE.4) CALL pyerrm(9
47056  & ,'(PYSLHA:) Inconsistent # of elements in STOPMIX')
47057  IF (mspc(7).NE.4) CALL pyerrm(9
47058  & ,'(PYSLHA:) Inconsistent # of elements in STAUMIX')
47059  IF (mspc(8).LT.1) CALL pyerrm(9
47060  & ,'(PYSLHA:) Too few elements in HMIX')
47061  IF (mspc(10).EQ.0) CALL pyerrm(9
47062  & ,'(PYSLHA:) Missing A_b trilinear coupling')
47063  IF (mspc(11).EQ.0) CALL pyerrm(9
47064  & ,'(PYSLHA:) Missing A_t trilinear coupling')
47065  IF (mspc(12).EQ.0) CALL pyerrm(9
47066  & ,'(PYSLHA:) Missing A_tau trilinear coupling')
47067  IF (mspc(17).LT.1) CALL pyerrm(9
47068  & ,'(PYSLHA:) Missing Higgs mixing angle alpha')
47069  ENDIF
47070 C...Check wavefunction normalizations.
47071 C...Sfermions
47072  DO 420 ispc=5,7
47073  IF (mspc(ispc).EQ.4) THEN
47074  kfsm=ispc
47075  IF (ispc.EQ.7) kfsm=15
47076  check=abs(sfmix(kfsm,1)*sfmix(kfsm,4)-sfmix(kfsm,2)
47077  & *sfmix(kfsm,3))
47078  IF (abs(1d0-check).GT.1d-3) THEN
47079  kcsm=pycomp(kfsm)
47080  CALL pyerrm(17
47081  & ,'(PYSLHA:) Non-orthonormal mixing matrix for ~'
47082  & //chaf(kcsm,1))
47083  ENDIF
47084 C...Bug fix 30/09 2008: PS
47085 C...Translate to Pythia's internal convention: (1,1) same sign as (2,2)
47086  IF (sfmix(kfsm,1)*sfmix(kfsm,4).LT.0d0) THEN
47087  sfmix(kfsm,3) = -sfmix(kfsm,3)
47088  sfmix(kfsm,4) = -sfmix(kfsm,4)
47089  ENDIF
47090  ENDIF
47091  420 CONTINUE
47092 C...Neutralinos + charginos
47093  DO 440 j=1,4
47094  cn1=0d0
47095  cn2=0d0
47096  cu1=0d0
47097  cu2=0d0
47098  cv1=0d0
47099  cv2=0d0
47100  DO 430 l=1,4
47101  cn1=cn1+zmix(j,l)**2
47102  cn2=cn2+zmix(l,j)**2
47103  IF (j.LE.2.AND.l.LE.2) THEN
47104  cu1=cu1+umix(j,l)**2
47105  cu2=cu2+umix(l,j)**2
47106  cv1=cv1+vmix(j,l)**2
47107  cv2=cv2+vmix(l,j)**2
47108  ENDIF
47109  430 CONTINUE
47110 C...NMIX normalization
47111  IF (mspc(2).EQ.16.AND.(abs(1d0-cn1).GT.1d-3.OR.abs(1d0-cn2)
47112  & .GT.1d-3).AND.imss(13).EQ.0) THEN
47113  CALL pyerrm(19,
47114  & '(PYSLHA:) NMIX: Inconsistent normalization.')
47115  WRITE(mstu(11),'(7x,I2,1x,":",2(1x,F7.4))') j, cn1, cn2
47116  ENDIF
47117 C...UMIX, VMIX normalizations
47118  IF (mspc(3).EQ.4.OR.mspc(4).EQ.4.AND.imss(13).EQ.0) THEN
47119  IF (j.LE.2) THEN
47120  IF (abs(1d0-cu1).GT.1d-3.OR.abs(1d0-cu2).GT.1d-3) THEN
47121  CALL pyerrm(19
47122  & ,'(PYSLHA:) UMIX: Inconsistent normalization.')
47123  WRITE(mstu(11),'(7x,I2,1x,":",2(1x,F6.2))') j, cu1,
47124  & cu2
47125  ENDIF
47126  IF (abs(1d0-cv1).GT.1d-3.OR.abs(1d0-cv2).GT.1d-3) THEN
47127  CALL pyerrm(19,
47128  & '(PYSLHA:) VMIX: Inconsistent normalization.')
47129  WRITE(mstu(11),'(7x,I2,1x,":",2(1x,F6.2))') j, cv1,
47130  & cv2
47131  ENDIF
47132  ENDIF
47133  ENDIF
47134  440 CONTINUE
47135  IF (mstu(27).EQ.mstu27.AND.mstu(23).EQ.mstu23) THEN
47136  WRITE(mstu(11),'(1x,"*"/1x,A/1x,"*")')
47137  & '* (PYSLHA:) No spectrum inconsistencies were found.'
47138  ELSE
47139  WRITE(mstu(11),'(1x,"*"/1x,A/1x,"*",A/1x,"*",A/)')
47140  & '* (PYSLHA:) INCONSISTENT SPECTRUM WARNING.'
47141  & ,' Warning: one or more (serious)'//
47142  & ' inconsistencies were found in the spectrum !'
47143  & ,' Read the error messages above and check your'//
47144  & ' input file.'
47145  ENDIF
47146 C...Increase precision in Higgs sector using FeynHiggs
47147  IF (imss(4).EQ.3) THEN
47148 C...FeynHiggs needs MSOFT.
47149  ierr=0
47150  IF (mspc(18).EQ.0) THEN
47151  WRITE(mstu(11),'(1x,"*"/1x,A/)')
47152  & '* (PYSLHA:) BLOCK MSOFT not found in SLHA file.'//
47153  & ' Cannot call FeynHiggs.'
47154  ierr=-1
47155  ELSE
47156  WRITE(mstu(11),'(1x,/1x,A/)')
47157  & '* (PYSLHA:) Now calling FeynHiggs.'
47158  CALL pyfeyn(ierr)
47159  IF (ierr.NE.0) imss(4)=2
47160  ENDIF
47161  ENDIF
47162  ELSEIF (mupda.EQ.2.AND.iretrn.EQ.0.AND.merr.NE.16) THEN
47163  ibeg=1
47164  IF (kforig.NE.0) ibeg=ndecay
47165  DO 490 idecay=ibeg,ndecay
47166  kf = kfdec(idecay)
47167  kc = pycomp(kf)
47168  WRITE(chkf,8300) kf
47169  IF(min(pmas(kc,1),pmas(kc,2),pmas(kc,3),pmas(kc,1)-pmas(kc,3
47170  $ ),pmas(kc,4)).LT.0d0.OR.mdcy(kc,3).LT.0.OR.(mdcy(kc,3)
47171  $ .EQ.0.AND.mdcy(kc,1).GE.1)) CALL pyerrm(17
47172  $ ,'(PYSLHA:) Mass/width/life/(# channels) wrong for KF='
47173  $ //chkf)
47174  brsum=0d0
47175  bropn=0d0
47176  DO 460 ida=mdcy(kc,2),mdcy(kc,2)+mdcy(kc,3)-1
47177  IF(mdme(ida,2).GT.80) goto 460
47178  kq=kchg(kc,1)
47179  pms=pmas(kc,1)-pmas(kc,3)-parj(64)
47180  merr=0
47181  DO 450 j=1,5
47182  kp=kfdp(ida,j)
47183  IF(kp.EQ.0.OR.kp.EQ.81.OR.iabs(kp).EQ.82) THEN
47184  IF(kp.EQ.81) kq=0
47185  ELSEIF(pycomp(kp).EQ.0) THEN
47186  merr=3
47187  ELSE
47188  kq=kq-pychge(kp)
47189  kpc=pycomp(kp)
47190  pms=pms-pmas(kpc,1)
47191  IF(mstj(24).GT.0) pms=pms+0.5d0*min(pmas(kpc,2),
47192  & pmas(kpc,3))
47193  ENDIF
47194  450 CONTINUE
47195  IF(kq.NE.0) merr=max(2,merr)
47196  IF(mwid(kc).EQ.0.AND.kf.NE.311.AND.pms.LT.0d0)
47197  & merr=max(1,merr)
47198  IF(merr.EQ.3) CALL pyerrm(17,
47199  & '(PYSLHA:) Unknown particle code in decay of KF ='
47200  $ //chkf)
47201  IF(merr.EQ.2) CALL pyerrm(17,
47202  & '(PYSLHA:) Charge not conserved in decay of KF ='
47203  $ //chkf)
47204  IF(merr.EQ.1) CALL pyerrm(7,
47205  & '(PYSLHA:) Kinematically unallowed decay of KF ='
47206  $ //chkf)
47207  brsum=brsum+brat(ida)
47208  IF (mdme(ida,1).GT.0) bropn=bropn+brat(ida)
47209  460 CONTINUE
47210 C...Check branching ratio sum.
47211  IF (bropn.LE.0d0) THEN
47212 C...If zero, set stable.
47213  WRITE(chtmp,8500) bropn
47214  CALL pyerrm(7
47215  & ,"(PYSLHA:) Effective BR sum for KF="//chkf//' is '//
47216  & chtmp(9:16)//'. Changed to stable.')
47217  pmas(kc,2)=1d-6
47218  mwid(kc)=0
47219 C...If BR's > 1, rescale.
47220  ELSEIF (brsum.GT.(1d0+1d-6)) THEN
47221  WRITE(chtmp,8500) brsum
47222  IF (brsum.GT.(1d0+1d-3)) CALL pyerrm(7
47223  & ,"(PYSLHA:) Forced rescaling of BR's for KF="//chkf//
47224  & ' ; sum was'//chtmp(9:16)//'.')
47225  fac=1d0/brsum
47226  DO 470 ida=mdcy(kc,2),mdcy(kc,2)+mdcy(kc,3)-1
47227  IF(mdme(ida,2).GT.80) goto 470
47228  brat(ida)=fac*brat(ida)
47229  470 CONTINUE
47230  ELSEIF (brsum.LT.(1d0-1d-6)) THEN
47231 C...If BR's < 1, insert dummy mode for proper cross section rescaling.
47232  WRITE(chtmp,8500) brsum
47233  IF (brsum.LT.(1d0-1d-3)) CALL pyerrm(7
47234  & ,"(PYSLHA:) Sum of BR's for KF="//chkf//' is '//
47235  & chtmp(9:16)//'. Dummy mode will be inserted.')
47236 C...Move table and insert dummy mode
47237  DO 480 ida=mdcy(kc,2),mdcy(kc,2)+mdcy(kc,3)-1
47238  ndc=ndc+1
47239  brat(ndc)=brat(ida)
47240  kfdp(ndc,1)=kfdp(ida,1)
47241  kfdp(ndc,2)=kfdp(ida,2)
47242  kfdp(ndc,3)=kfdp(ida,3)
47243  kfdp(ndc,4)=kfdp(ida,4)
47244  kfdp(ndc,5)=kfdp(ida,5)
47245  mdme(ndc,1)=mdme(ida,1)
47246  480 CONTINUE
47247  ndc=ndc+1
47248  brat(ndc)=1d0-brsum
47249  kfdp(ndc,1)=0
47250  kfdp(ndc,2)=0
47251  kfdp(ndc,3)=0
47252  kfdp(ndc,4)=0
47253  kfdp(ndc,5)=0
47254  mdme(ndc,1)=0
47255  brsum=1d0
47256 C...Update MDCY
47257  mdcy(kc,3)=mdcy(kc,3)+1
47258  mdcy(kc,2)=ndc-mdcy(kc,3)+1
47259  ENDIF
47260  490 CONTINUE
47261  ENDIF
47262 
47263 
47264 C...WRITE SPECTRUM ON SLHA FILE
47265  ELSEIF(mupda.EQ.3) THEN
47266 C...If SPYTHIA or ISASUSY runtime was called for SUGRA, update PARMIN.
47267  IF (imss(1).EQ.2.OR.imss(1).EQ.12) THEN
47268  modsel(1)=1
47269  parmin(1)=rmss(8)
47270  parmin(2)=rmss(1)
47271  parmin(3)=rmss(5)
47272  parmin(4)=sign(1d0,rmss(4))
47273  parmin(5)=rmss(36)
47274  ENDIF
47275 C...Write spectrum
47276  WRITE(lfn,7000) 'SLHA MSSM spectrum'
47277  WRITE(lfn,7000) 'Pythia 6.4: T. Sjostrand, S. Mrenna,'
47278  & // ' P. Skands.'
47279  WRITE(lfn,7010) 'MODSEL', 'Model selection'
47280  WRITE(lfn,7110) 1, modsel(1)
47281  WRITE(lfn,7010) 'MINPAR', 'Parameters for minimal model.'
47282  IF (modsel(1).EQ.1) THEN
47283  WRITE(lfn,7210) 1, parmin(1), 'm0'
47284  WRITE(lfn,7210) 2, parmin(2), 'm12'
47285  WRITE(lfn,7210) 3, parmin(3), 'tan(beta)'
47286  WRITE(lfn,7210) 4, parmin(4), 'sign(mu)'
47287  WRITE(lfn,7210) 5, parmin(5), 'a0'
47288  ELSEIF(modsel(2).EQ.2) THEN
47289  WRITE(lfn,7210) 1, parmin(1), 'Lambda'
47290  WRITE(lfn,7210) 2, parmin(2), 'M'
47291  WRITE(lfn,7210) 3, parmin(3), 'tan(beta)'
47292  WRITE(lfn,7210) 4, parmin(4), 'sign(mu)'
47293  WRITE(lfn,7210) 5, parmin(5), 'N5'
47294  WRITE(lfn,7210) 6, parmin(6), 'c_grav'
47295  ENDIF
47296  WRITE(lfn,7000) ' '
47297  WRITE(lfn,7010) 'MASS', 'Mass spectrum'
47298  DO 500 i=1,36
47299  kf=kfsusy(i)
47300  kc=pycomp(kf)
47301  IF (kf.EQ.1000039.AND.modsel(1).NE.2) goto 500
47302  kfsm=kf-ksusy1
47303  IF (kfsm.GE.22.AND.kfsm.LE.37) THEN
47304  IF (kfsm.EQ.22) WRITE(lfn,7220) kf, smz(1), chaf(kc,1)
47305  IF (kfsm.EQ.23) WRITE(lfn,7220) kf, smz(2), chaf(kc,1)
47306  IF (kfsm.EQ.25) WRITE(lfn,7220) kf, smz(3), chaf(kc,1)
47307  IF (kfsm.EQ.35) WRITE(lfn,7220) kf, smz(4), chaf(kc,1)
47308  IF (kfsm.EQ.24) WRITE(lfn,7220) kf, smw(1), chaf(kc,1)
47309  IF (kfsm.EQ.37) WRITE(lfn,7220) kf, smw(2), chaf(kc,1)
47310  ELSE
47311  WRITE(lfn,7220) kf, pmas(kc,1), chaf(kc,1)
47312  ENDIF
47313  500 CONTINUE
47314 C...SUSY scale
47315  rmsusy=sqrt(pmas(pycomp(ksusy1+6),1)*pmas(pycomp(ksusy2+6),1))
47316  WRITE(lfn,7020) 'HMIX',rmsusy,'Higgs parameters'
47317  WRITE(lfn,7210) 1, rmss(4),'mu'
47318  WRITE(lfn,7010) 'ALPHA',' '
47319 C WRITE(LFN,7210) 1, RMSS(18), 'alpha'
47320  WRITE(lfn,7200) rmss(18), 'alpha'
47321  WRITE(lfn,7020) 'AU',rmsusy
47322  WRITE(lfn,7410) 3, 3, rmss(16), 'A_t'
47323  WRITE(lfn,7020) 'AD',rmsusy
47324  WRITE(lfn,7410) 3, 3, rmss(15), 'A_b'
47325  WRITE(lfn,7020) 'AE',rmsusy
47326  WRITE(lfn,7410) 3, 3, rmss(17), 'A_tau'
47327  WRITE(lfn,7010) 'STOPMIX','~t mixing matrix'
47328  WRITE(lfn,7410) 1, 1, sfmix(6,1)
47329  WRITE(lfn,7410) 1, 2, sfmix(6,2)
47330  WRITE(lfn,7410) 2, 1, sfmix(6,3)
47331  WRITE(lfn,7410) 2, 2, sfmix(6,4)
47332  WRITE(lfn,7010) 'SBOTMIX','~b mixing matrix'
47333  WRITE(lfn,7410) 1, 1, sfmix(5,1)
47334  WRITE(lfn,7410) 1, 2, sfmix(5,2)
47335  WRITE(lfn,7410) 2, 1, sfmix(5,3)
47336  WRITE(lfn,7410) 2, 2, sfmix(5,4)
47337  WRITE(lfn,7010) 'STAUMIX','~tau mixing matrix'
47338  WRITE(lfn,7410) 1, 1, sfmix(15,1)
47339  WRITE(lfn,7410) 1, 2, sfmix(15,2)
47340  WRITE(lfn,7410) 2, 1, sfmix(15,3)
47341  WRITE(lfn,7410) 2, 2, sfmix(15,4)
47342  WRITE(lfn,7010) 'NMIX','~chi0 mixing matrix'
47343  DO 520 i1=1,4
47344  DO 510 i2=1,4
47345  WRITE(lfn,7410) i1, i2, zmix(i1,i2)
47346  510 CONTINUE
47347  520 CONTINUE
47348  WRITE(lfn,7010) 'UMIX','~chi^+ U mixing matrix'
47349  DO 540 i1=1,2
47350  DO 530 i2=1,2
47351  WRITE(lfn,7410) i1, i2, umix(i1,i2)
47352  530 CONTINUE
47353  540 CONTINUE
47354  WRITE(lfn,7010) 'VMIX','~chi^+ V mixing matrix'
47355  DO 560 i1=1,2
47356  DO 550 i2=1,2
47357  WRITE(lfn,7410) i1, i2, vmix(i1,i2)
47358  550 CONTINUE
47359  560 CONTINUE
47360  WRITE(lfn,7010) 'SPINFO'
47361  IF (imss(1).EQ.2) THEN
47362  cpro(1)='PYTHIA'
47363  cver(1)='6.4'
47364  ELSEIF (imss(1).EQ.12) THEN
47365  isaver=visaje()
47366  cpro(1)='ISASUSY'
47367  cver(1)=isaver(1:12)
47368  ENDIF
47369  WRITE(lfn,7310) 1, cpro(1), 'Spectrum Calculator'
47370  WRITE(lfn,7310) 2, cver(1), 'Version number'
47371  ENDIF
47372 
47373 C...Print user information about spectrum
47374  IF (mupda.EQ.1.OR.mupda.EQ.3) THEN
47375  IF (cpro(mod(mupda,2)).NE.' '.AND.cver(mod(mupda,2)).NE.' ')
47376  & WRITE(mstu(11),5030) cpro(1), cver(1)
47377  IF (imss(4).EQ.3) WRITE(mstu(11),5040)
47378  IF (mupda.EQ.1) THEN
47379  WRITE(mstu(11),5020) lfn
47380  ELSE
47381  WRITE(mstu(11),5010) lfn
47382  ENDIF
47383 
47384  WRITE(mstu(11),5400)
47385  WRITE(mstu(11),5500) 'Pole masses'
47386  WRITE(mstu(11),5700) (rmfun(ksusy1+ip),ip=1,6)
47387  $ ,(rmfun(ksusy2+ip),ip=1,6)
47388  WRITE(mstu(11),5800) (rmfun(ksusy1+ip),ip=11,16)
47389  $ ,(rmfun(ksusy2+ip),ip=11,16)
47390  IF (imss(13).EQ.0) THEN
47391  WRITE(mstu(11),5900) rmfun(ksusy1+21),rmfun(ksusy1+22)
47392  $ ,rmfun(ksusy1+23),rmfun(ksusy1+25),rmfun(ksusy1+35),
47393  $ rmfun(ksusy1+24),rmfun(ksusy1+37)
47394  WRITE(mstu(11),6000) chaf(25,1),chaf(35,1),chaf(36,1),
47395  & chaf(37,1), ' ', ' ',' ',' ',
47396  & rmfun(25), rmfun(35), rmfun(36), rmfun(37)
47397  ELSEIF (imss(13).EQ.1) THEN
47398  kf1=ksusy1+21
47399  kf2=ksusy1+22
47400  kf3=ksusy1+23
47401  kf4=ksusy1+25
47402  kf5=ksusy1+35
47403  kf6=ksusy1+45
47404  kf7=ksusy1+24
47405  kf8=ksusy1+37
47406  WRITE(mstu(11),6000) chaf(pycomp(kf1),1),chaf(pycomp(kf2),1),
47407  & chaf(pycomp(kf3),1),chaf(pycomp(kf4),1),
47408  & chaf(pycomp(kf5),1),chaf(pycomp(kf6),1),
47409  & chaf(pycomp(kf7),1),chaf(pycomp(kf8),1),
47410  & rmfun(kf1),rmfun(kf2),rmfun(kf3),rmfun(kf4),
47411  & rmfun(kf5),rmfun(kf6),rmfun(kf7),rmfun(kf8)
47412  WRITE(mstu(11),6000) chaf(25,1), chaf(35,1), chaf(45,1),
47413  & chaf(36,1), chaf(46,1), chaf(37,1),' ',' ',
47414  & rmfun(25), rmfun(35), rmfun(45), rmfun(36), rmfun(46),
47415  & rmfun(37)
47416  ENDIF
47417  WRITE(mstu(11),5400)
47418  WRITE(mstu(11),5500) 'Mixing structure'
47419  WRITE(mstu(11),6100) ((zmix(i,j), j=1,4),i=1,4)
47420  WRITE(mstu(11),6200) (umix(1,j), j=1,2),(vmix(1,j),j=1,2)
47421  & ,(umix(2,j), j=1,2),(vmix(2,j),j=1,2)
47422  WRITE(mstu(11),6300) (sfmix(5,j), j=1,2),(sfmix(6,j),j=1,2)
47423  & ,(sfmix(15,j), j=1,2),(sfmix(5,j),j=3,4),(sfmix(6,j), j=3,4
47424  & ),(sfmix(15,j),j=3,4)
47425  WRITE(mstu(11),5400)
47426  WRITE(mstu(11),5500) 'Couplings'
47427  WRITE(mstu(11),6400) rmss(15),rmss(16),rmss(17)
47428  WRITE(mstu(11),6450) rmss(18), rmss(5), rmss(4)
47429  WRITE(mstu(11),5400)
47430  WRITE(mstu(11),6500)
47431 
47432 C...DECAY TABLES writeout
47433 C...Write decay information by Nils-Erik Bomark 3/29/2010
47434  ELSEIF (mupda.EQ.4) THEN
47435  kf = kforig
47436  kc = pycomp(kf)
47437  IF (kc.NE.0) THEN
47438  WRITE(lfn,7000) ''
47439  WRITE(lfn,7000) ' PDG Width'
47440  WRITE(lfn,7500) kf,pmas(kc,2), chaf(kc,1)
47441  WRITE(lfn,7000)
47442  & ' BR NDA ID1 ID2 ID3'
47443  DO 575 i=mdcy(kc,2),mdcy(kc,2)+mdcy(kc,3)-1
47444  nda = 0
47445  DO 570 j=1,5
47446  IF (kfdp(i,j).NE.0) nda = nda+1
47447  570 CONTINUE
47448  IF (nda.EQ.2)
47449  & WRITE(lfn,7512) brat(i),nda,(kfdp(i,k),k=1,nda),
47450  & chaf(kc,1),(chaf(pycomp(kfdp(i,k)),
47451  & (3-kfdp(i,k)/abs(kfdp(i,k)))/2),k=1,nda)
47452  IF (nda.EQ.3)
47453  & WRITE(lfn,7513) brat(i),nda,(kfdp(i,k),k=1,nda),
47454  & chaf(kc,1),(chaf(pycomp(kfdp(i,k)),
47455  & (3-kfdp(i,k)/abs(kfdp(i,k)))/2),k=1,nda)
47456  IF (nda.EQ.4)
47457  & WRITE(lfn,7514) brat(i),nda,(kfdp(i,k),k=1,nda),
47458  & chaf(kc,1),(chaf(pycomp(kfdp(i,k)),
47459  & (3-kfdp(i,k)/abs(kfdp(i,k)))/2),k=1,nda)
47460  IF (nda.EQ.5)
47461  & WRITE(lfn,7515) brat(i),nda,(kfdp(i,k),k=1,nda),
47462  & chaf(kc,1),(chaf(pycomp(kfdp(i,k)),
47463  & (3-kfdp(i,k)/abs(kfdp(i,k)))/2),k=1,nda)
47464  575 CONTINUE
47465  ENDIF
47466 C....End of DECAY TABLES writeout
47467 
47468  ENDIF
47469 
47470 C...Only rewind when reading
47471  IF (mupda.LE.2.OR.mupda.EQ.5) rewind(lfn)
47472 
47473  9999 RETURN
47474 
47475 C...Serious error catching
47476  580 write(*,*) '* (PYSLHA:) read BLOCK error on line',nline
47477  write(*,*) chinl(1:80)
47478  CALL pystop(106)
47479  590 WRITE(*,*) '* (PYSLHA:) read DECAY error on line',nline
47480  WRITE(*,*) chinl(1:72)
47481  CALL pystop(106)
47482  600 WRITE(*,*) '* (PYSLHA:) read NDA error on line',nline
47483  WRITE(*,*) chinl(1:80)
47484  CALL pystop(106)
47485  610 WRITE(*,*) '* (PYSLHA:) decay daughter read error on line',nline
47486  WRITE(*,*) chinl(1:80)
47487  620 WRITE(*,*) '* (PYSLHA:) read Q error in BLOCK ',chblck
47488  CALL pystop(106)
47489  630 WRITE(*,*) '* (PYSLHA:) read error in line ',nline,':'
47490  WRITE(*,*) chinl(1:80)
47491  CALL pystop(106)
47492 
47493  8300 FORMAT(i9)
47494  8500 FORMAT(f16.5)
47495 
47496 C...Formats for user information printout.
47497  5000 FORMAT(1x,18('*'),1x,'PYSLHA v1.14: SUSY/BSM SPECTRUM '
47498  & ,'INTERFACE',1x,17('*')/1x,'*',1x
47499  & ,'(PYSLHA:) Last Change',1x,a,1x,'-',1x,'P.Z. Skands')
47500  5010 FORMAT(1x,'*',3x,'Wrote spectrum file on unit: ',i3)
47501  5020 FORMAT(1x,'*',3x,'Read spectrum file on unit: ',i3)
47502  5030 FORMAT(1x,'*',3x,'Spectrum Calculator was: ',a,' version ',a)
47503  5040 FORMAT(1x,'*',3x,'Higgs sector corrected with FeynHiggs')
47504  5100 FORMAT(1x,'*',1x,'Model parameters:'/1x,'*',1x,'----------------')
47505  5200 FORMAT(1x,'*',1x,3x,'M_0',6x,'M_1/2',5x,'A_0',3x,'Tan(beta)',
47506  & 3x,'Sgn(mu)',3x,'M_t'/1x,'*',1x,4(f8.2,1x),i8,2x,f8.2)
47507  5300 FORMAT(1x,'*'/1x,'*',1x,'Model spectrum :'/1x,'*',1x
47508  & ,'----------------')
47509  5400 FORMAT(1x,'*',1x,a)
47510  5500 FORMAT(1x,'*',1x,a,':')
47511  5600 FORMAT(1x,'*',2x,2x,'M_GUT',2x,2x,'g_GUT',2x,1x,'alpha_GUT'/
47512  & 1x,'*',2x,1p,2(1x,e8.2),2x,e8.2)
47513  5700 FORMAT(1x,'*',4x,1x,'~d',2x,1x,4x,'~u',2x,1x,4x,'~s',2x,1x,
47514  & 4x,'~c',2x,1x,4x,'~b(12)',1x,1x,1x,'~t(12)'/1x,'*',2x,'L',1x
47515  & ,6(f8.2,1x)/1x,'*',2x,'R',1x,6(f8.2,1x))
47516  5800 FORMAT(1x,'*'/1x,'*',4x,1x,'~e',2x,1x,4x,'~nu_e',2x,1x,1x,'~mu',2x
47517  & ,1x,3x,'~nu_mu',2x,1x,'~tau(12)',1x,'~nu_tau'/1x,'*',2x
47518  & ,'L',1x,6(f8.2,1x)/1x,'*',2x,'R',1x,6(f8.2,1x))
47519  5900 FORMAT(1x,'*'/1x,'*',4x,4x,'~g',2x,1x,1x,'~chi_10',1x,1x,'~chi_20'
47520  & ,1x,1x,'~chi_30',1x,1x,'~chi_40',1x,1x,'~chi_1+',1x
47521  & ,1x,'~chi_2+'/1x,'*',3x,1x,7(f8.2,1x))
47522  6000 FORMAT(1x,'*'/1x,'*',3x,1x,8(1x,a7,1x)/1x,'*',3x,1x,8(f8.2,1x))
47523  6100 FORMAT(1x,'*',11x,'|',3x,'~B',3x,'|',2x,'~W_3',2x,'|',2x
47524  & ,'~H_1',2x,'|',2x,'~H_2',2x,'|'/1x,'*',3x,'~chi_10',1x,4('|'
47525  & ,1x,f6.3,1x),'|'/1x,'*',3x,'~chi_20',1x,4('|'
47526  & ,1x,f6.3,1x),'|'/1x,'*',3x,'~chi_30',1x,4('|'
47527  & ,1x,f6.3,1x),'|'/1x,'*',3x,'~chi_40',1x,4('|'
47528  & ,1x,f6.3,1x),'|')
47529  6200 FORMAT(1x,'*'/1x,'*',6x,'L',4x,'|',3x,'~W',3x,'|',3x,'~H',3x,'|'
47530  & ,12x,'R',4x,'|',3x,'~W',3x,'|',3x,'~H',3x,'|'/1x,'*',3x
47531  & ,'~chi_1+',1x,2('|',1x,f6.3,1x),'|',9x,'~chi_1+',1x,2('|',1x
47532  & ,f6.3,1x),'|'/1x,'*',3x,'~chi_2+',1x,2('|',1x,f6.3,1x),'|',9x
47533  & ,'~chi_2+',1x,2('|',1x,f6.3,1x),'|')
47534  6300 FORMAT(1x,'*'/1x,'*',8x,'|',2x,'~b_L',2x,'|',2x,'~b_R',2x,'|',8x
47535  & ,'|',2x,'~t_L',2x,'|',2x,'~t_R',2x,'|',10x
47536  & ,'|',1x,'~tau_L',1x,'|',1x,'~tau_R',1x,'|'/
47537  & 1x,'*',3x,'~b_1',1x,2('|',1x,f6.3,1x),'|',3x,'~t_1',1x,2('|'
47538  & ,1x,f6.3,1x),'|',3x,'~tau_1',1x,2('|',1x,f6.3,1x),'|'/
47539  & 1x,'*',3x,'~b_2',1x,2('|',1x,f6.3,1x),'|',3x,'~t_2',1x,2('|'
47540  & ,1x,f6.3,1x),'|',3x,'~tau_2',1x,2('|',1x,f6.3,1x),'|')
47541  6400 FORMAT(1x,'*',3x,' A_b = ',f8.2,4x,' A_t = ',f8.2,4x
47542  & ,'A_tau = ',f8.2)
47543  6450 FORMAT(1x,'*',3x,'alpha = ',f8.2,4x,'tan(beta) = ',f8.2,4x
47544  & ,' mu = ',f8.2)
47545  6500 FORMAT(1x,32('*'),1x,'END OF PYSLHA',1x,31('*'))
47546 
47547 C...Format to use for comments
47548  7000 FORMAT('# ',a)
47549 C...Format to use for block statements
47550  7010 FORMAT('Block',1x,a,3x,'#',1x,a)
47551  7020 FORMAT('Block',1x,a,1x,'Q=',1p,e16.8,0p,3x,'#',1x,a)
47552 C...Indexed Int
47553  7110 FORMAT(1x,i4,1x,i4,3x,'#')
47554 C...Non-Indexed Double
47555  7200 FORMAT(9x,1p,e16.8,0p,3x,'#',1x,a)
47556 C...Indexed Double
47557  7210 FORMAT(1x,i4,3x,1p,e16.8,0p,3x,'#',1x,a)
47558 C...Long Indexed Double (PDG + double)
47559  7220 FORMAT(1x,i9,3x,1p,e16.8,0p,3x,'#',1x,a)
47560 C...Indexed Char(12)
47561  7310 FORMAT(1x,i4,3x,a12,3x,'#',1x,a)
47562 C...Single matrix
47563  7410 FORMAT(1x,i2,1x,i2,3x,1p,e16.8,0p,3x,'#',1x,a)
47564 C...Double Matrix
47565  7420 FORMAT(1x,i2,1x,i2,3x,1p,e16.8,3x,e16.8,0p,3x,'#',1x,a)
47566 C...Write Decay Table
47567  7500 FORMAT('Decay',1x,i9,1x,1p,e16.8,0p,3x,'#',1x,a)
47568  7510 FORMAT(4x,1p,e16.8,0p,3x,i2,3x,'IDA=',1x,5(1x,i9),3x,'#',1x,a)
47569  7512 FORMAT(4x,1p,e16.8,0p,3x,i2,3x,1x,2(1x,i9),13x,
47570  & '#',1x,'BR(',a10,1x,'->',2(1x,a10),')')
47571  7513 FORMAT(4x,1p,e16.8,0p,3x,i2,3x,1x,3(1x,i9),3x,
47572  & '#',1x,'BR(',a10,1x,'->',3(1x,a10),')')
47573  7514 FORMAT(4x,1p,e16.8,0p,3x,i2,3x,1x,4(1x,i9),3x,
47574  & '#',1x,'BR(',a10,1x,'->',4(1x,a10),')')
47575  7515 FORMAT(4x,1p,e16.8,0p,3x,i2,3x,1x,5(1x,i9),3x,
47576  & '#',1x,'BR(',a10,1x,'->',5(1x,a10),')')
47577 
47578  END
47579 
47580 
47581 C*********************************************************************
47582 
47583 C...PYAPPS
47584 C...Uses approximate analytical formulae to determine the full set of
47585 C...MSSM parameters from SUGRA input.
47586 C...See M. Drees and S.P. Martin, hep-ph/9504124
47587 
47588  SUBROUTINE pyapps
47589 
47590 C...Double precision and integer declarations.
47591  IMPLICIT DOUBLE PRECISION(a-h, o-z)
47592  IMPLICIT INTEGER(i-n)
47593  INTEGER pyk,pychge,pycomp
47594 C...Parameter statement to help give large particle numbers.
47595  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
47596  &kexcit=4000000,kdimen=5000000)
47597 C...Commonblocks.
47598  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
47599  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
47600  common/pymssm/imss(0:99),rmss(0:99)
47601  SAVE /pydat1/,/pydat2/,/pymssm/
47602 
47603  WRITE(mstu(11),*) '(PYAPPS:) approximate mSUGRA relations'//
47604  &' not intended for serious physics studies'
47605  imss(5)=0
47606  imss(8)=0
47607  xmt=pmas(6,1)
47608  xmz2=pmas(23,1)**2
47609  xmw2=pmas(24,1)**2
47610  tanb=rmss(5)
47611  beta=atan(tanb)
47612  xw=paru(102)
47613  xmg=rmss(1)
47614  xmg2=xmg*xmg
47615  xm0=rmss(8)
47616  xm02=xm0*xm0
47617 C...Temporary sign change for AT. Others unchanged.
47618  at=-rmss(16)
47619  rmss(15)=rmss(16)
47620  rmss(17)=rmss(16)
47621  sinb=tanb/sqrt(tanb**2+1d0)
47622  cosb=sinb/tanb
47623 
47624  dterm=xmz2*cos(2d0*beta)
47625  xmer=sqrt(xm02+0.15d0*xmg2-xw*dterm)
47626  xmel=sqrt(xm02+0.52d0*xmg2-(0.5d0-xw)*dterm)
47627  rmss(6)=xmel
47628  rmss(7)=xmer
47629  xmur=sqrt(pyrnmq(2,2d0/3d0*xw*dterm))
47630  xmdr=sqrt(pyrnmq(3,-1d0/3d0*xw*dterm))
47631  xmul=sqrt(pyrnmq(1,(0.5d0-2d0/3d0*xw)*dterm))
47632  xmdl=sqrt(pyrnmq(1,-(0.5d0-1d0/3d0*xw)*dterm))
47633  DO 100 i=1,5,2
47634  pmas(pycomp(ksusy1+i),1)=xmdl
47635  pmas(pycomp(ksusy2+i),1)=xmdr
47636  pmas(pycomp(ksusy1+i+1),1)=xmul
47637  pmas(pycomp(ksusy2+i+1),1)=xmur
47638  100 CONTINUE
47639  xarg=xmel**2-xmw2*abs(cos(2d0*beta))
47640  IF(xarg.LT.0d0) THEN
47641  WRITE(mstu(11),*) ' SNEUTRINO MASS IS NEGATIVE'//
47642  & ' FROM THE SUM RULE. '
47643  WRITE(mstu(11),*) ' TRY A SMALLER VALUE OF TAN(BETA). '
47644  RETURN
47645  ELSE
47646  xarg=sqrt(xarg)
47647  ENDIF
47648  DO 110 i=11,15,2
47649  pmas(pycomp(ksusy1+i),1)=xmel
47650  pmas(pycomp(ksusy2+i),1)=xmer
47651  pmas(pycomp(ksusy1+i+1),1)=xarg
47652  pmas(pycomp(ksusy2+i+1),1)=9999d0
47653  110 CONTINUE
47654  rmt=pymrun(6,pmas(6,1)**2)
47655  xtop=(rmt/150d0/sinb)**2*(.9d0*xm02+2.1d0*xmg2+
47656  &(1d0-(rmt/190d0/sinb)**3)*(.24d0*at**2+at*xmg))
47657  rmb=pymrun(5,pmas(6,1)**2)
47658  xbot=(rmb/150d0/cosb)**2*(.9d0*xm02+2.1d0*xmg2+
47659  &(1d0-(rmb/190d0/cosb)**3)*(.24d0*at**2+at*xmg))
47660  xtau=1d-4/cosb**2*(xm02+0.15d0*xmg2+at**2/3d0)
47661  atp=at*(1d0-(rmt/190d0/sinb)**2)+xmg*(3.47d0-1.9d0*(rmt/190d0/
47662  &sinb)**2)
47663  rmss(16)=-atp
47664  xmu2=-.5d0*xmz2+(sinb**2*(xm02+.52d0*xmg2-xtop)-
47665  &cosb**2*(xm02+.52d0*xmg2-xbot-xtau/3d0))/(cosb**2-sinb**2)
47666  xma2=2d0*(xm02+.52d0*xmg2+xmu2)-xtop-xbot-xtau/3d0
47667  xmu=sign(sqrt(xmu2),rmss(4))
47668  rmss(4)=xmu
47669  IF(xma2.GT.0d0) THEN
47670  rmss(19)=sqrt(xma2)
47671  ELSE
47672  WRITE(mstu(11),*) ' PYAPPS:: PSEUDOSCALAR MASS**2 < 0 '
47673  CALL pystop(102)
47674  ENDIF
47675  arg=xm02+0.15d0*xmg2-2d0*xtau/3d0-xw*dterm
47676  IF(arg.GT.0d0) THEN
47677  rmss(14)=sqrt(arg)
47678  ELSE
47679  WRITE(mstu(11),*) ' PYAPPS:: RIGHT STAU MASS**2 < 0 '
47680  CALL pystop(102)
47681  ENDIF
47682  arg=xm02+0.52d0*xmg2-xtau/3d0-(0.5d0-xw)*dterm
47683  IF(arg.GT.0d0) THEN
47684  rmss(13)=sqrt(arg)
47685  ELSE
47686  WRITE(mstu(11),*) ' PYAPPS:: LEFT STAU MASS**2 < 0 '
47687  CALL pystop(102)
47688  ENDIF
47689  arg=pyrnmq(1,-(xbot+xtop)/3d0)
47690  IF(arg.GT.0d0) THEN
47691  rmss(10)=sqrt(arg)
47692  ELSE
47693  rmss(10)=-sqrt(-arg)
47694  ENDIF
47695  arg=pyrnmq(2,-2d0*xtop/3d0)
47696  IF(arg.GT.0d0) THEN
47697  rmss(12)=sqrt(arg)
47698  ELSE
47699  rmss(12)=-sqrt(-arg)
47700  ENDIF
47701  arg=pyrnmq(3,-2d0*xbot/3d0)
47702  IF(arg.GT.0d0) THEN
47703  rmss(11)=sqrt(arg)
47704  ELSE
47705  rmss(11)=-sqrt(-arg)
47706  ENDIF
47707 
47708  RETURN
47709  END
47710 
47711 C*********************************************************************
47712 
47713 C...PYSUGI
47714 C...Interface to ISASUSY version 7.71.
47715 C...Warning: this interface should not be used with earlier versions
47716 C...of ISASUSY, since common block incompatibilities may then arise.
47717 C...Calls SUGRA (in ISAJET) to perform RGE evolution.
47718 C...Then converts to Gunion-Haber conventions.
47719 
47720  SUBROUTINE pysugi
47721  IMPLICIT DOUBLE PRECISION(a-h, o-z)
47722 
47723  INTEGER pyk,pychge,pycomp
47724  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
47725  &kexcit=4000000,kdimen=5000000)
47726 
47727 C...Date of Change
47728  CHARACTER doc*11
47729  parameter(doc='01 May 2006')
47730 
47731 C...ISASUGRA Input:
47732  REAL mzero,mhlf,azero,tanb,sgnmu,mtop
47733 C...XISAIN contains the MSSMi inputs in natural order.
47734  COMMON /sugxin/ xisain(24),xsugin(7),xgmin(14),xnrin(4),
47735  $xamin(7)
47736  REAL xisain,xsugin,xgmin,xnrin,xamin
47737  SAVE /sugxin/
47738 C...ISASUGRA Output
47739  CHARACTER*40 isaver,visaje
47740  REAL super
47741  COMMON /sspar/ super(72)
47742  COMMON /sugmg/ mss(32),gss(31),mgutss,ggutss,agutss,ftgut,
47743  $fbgut,ftagut,fngut
47744  REAL mss,gss,mgutss,ggutss,agutss,ftgut,fbgut,ftagut,fngut
47745  COMMON /sugpas/ xtanb,msusy,amt,mgut,mu,g2,gp,v,vp,xw,
47746  $a1mz,a2mz,asmz,ftamz,fbmz,b,sin2b,ftmt,g3mt,vev,higfrz,
47747  $fnmz,amnrmj,nogood,ial3un,itachy,mhpneg,asm3,
47748  $vumt,vdmt,asmtp,asmss,m3q
47749  REAL xtanb,msusy,amt,mgut,mu,g2,gp,v,vp,xw,
47750  $a1mz,a2mz,asmz,ftamz,fbmz,b,sin2b,ftmt,g3mt,vev,higfrz,
47751  $fnmz,amnrmj,asm3,vumt,vdmt,asmtp,asmss,m3q
47752  INTEGER nogood,ial3un,itachy,mhpneg
47753  INTEGER iallow
47754  SAVE /sugmg/,/sspar/
47755 C SUPER: Filled by ISASUGRA.
47756 C SUPER(1) = mass of ~g
47757 C SUPER(2:17) = mass of ~u_L,~u_R,~d_L,~d_R,~s_L,~s_R,~c_L,~c_R,~b_L
47758 C ,~b_R,~b_1,~b_2,~t_L,~t_R,~t_1,~t_2
47759 C SUPER(18:25) = mass of ~e_L,~e_R,~mu_L,~mu_R,~tau_L,~tau_R,~tau_1
47760 C ,~tau_2
47761 C SUPER(26:28) = mass of ~nu_e,~nu_mu,~nu_tau
47762 C SUPER(29) = Higgsino mass = - mu
47763 C SUPER(30) = ratio v2/v1 of vev's
47764 C SUPER(31:34) = Signed neutralino masses
47765 C SUPER(35:50) = Neutralino mixing matrix
47766 C SUPER(51:52) = Signed chargino masses
47767 C SUPER(53:54) = Chargino left, right mixing angles
47768 C SUPER(55:58) = mass of h0, H0, A0, H+
47769 C SUPER(59) = Higgs mixing angle alpha
47770 C SUPER(60:65) = A_t, theta_t, A_b, theta_b, A_tau, theta_tau
47771 C SUPER(66) = Gravitino mass
47772 C SUPER(67:69) = Top,Bottom, and Tau masses at MSUSY (not used)
47773 C SUPER(70) = b-Yukawa at mA scale (not used)
47774 C SUPER(71:72) = H_u, H_d vev's at MSUSY (not used)
47775 C GSS: Filled by ISASUGRA
47776 C GSS( 1) = g_1 GSS( 2) = g_2 GSS( 3) = g_3
47777 C GSS( 4) = y_tau GSS( 5) = y_b GSS( 6) = y_t
47778 C GSS( 7) = M_1 GSS( 8) = M_2 GSS( 9) = M_3
47779 C GSS(10) = A_tau GSS(11) = A_b GSS(12) = A_t
47780 C GSS(13) = M_h12 GSS(14) = M_h22 GSS(15) = M_er2
47781 C GSS(16) = M_el2 GSS(17) = M_dnr2 GSS(18) = M_upr2
47782 C GSS(19) = M_upl2 GSS(20) = M_taur2 GSS(21) = M_taul2
47783 C GSS(22) = M_btr2 GSS(23) = M_tpr2 GSS(24) = M_tpl2
47784 C GSS(25) = mu GSS(26) = B GSS(27) = Y_N
47785 C GSS(28) = M_nr GSS(29) = A_n GSS(30) = log(vdq)
47786 C GSS(31) = log(vuq)
47787 C MSS: Filled by ISASUGRA
47788 C MSS( 1) = glss MSS( 2) = upl MSS( 3) = upr
47789 C MSS( 4) = dnl MSS( 5) = dnr MSS( 6) = stl
47790 C MSS( 7) = str MSS( 8) = chl MSS( 9) = chr
47791 C MSS(10) = b1 MSS(11) = b2 MSS(12) = t1
47792 C MSS(13) = t2 MSS(14) = nuel MSS(15) = numl
47793 C MSS(16) = nutl MSS(17) = el- MSS(18) = er-
47794 C MSS(19) = mul- MSS(20) = mur- MSS(21) = tau1
47795 C MSS(22) = tau2 MSS(23) = z1ss MSS(24) = z2ss
47796 C MSS(25) = z3ss MSS(26) = z4ss MSS(27) = w1ss
47797 C MSS(28) = w2ss MSS(29) = hl0 MSS(30) = hh0
47798 C MSS(31) = ha0 MSS(32) = h+
47799 C Unification, filled by ISASUGRA if applicable.
47800 C MGUTSS = M_GUT GGUTSS = g_GUT AGUTSS = alpha_GUTC
47801 
47802 C...SPYTHIA Input/Output
47803  INTEGER imss
47804  DOUBLE PRECISION rmss
47805  common/pymssm/imss(0:99),rmss(0:99)
47806  common/pyssmt/zmix(4,4),umix(2,2),vmix(2,2),smz(4),smw(2),
47807  &sfmix(16,4),zmixi(4,4),umixi(2,2),vmixi(2,2)
47808 C...SLHA Input/Output
47809  common/pylh3p/modsel(200),parmin(100),parext(200),rmsoft(0:100),
47810  & au(3,3),ad(3,3),ae(3,3)
47811 C...PYTHIA common blocks
47812  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
47813  common/pypars/mstp(200),parp(200),msti(200),pari(200)
47814  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
47815 
47816  SAVE /pymssm/,/pyssmt/,/pylh3p/,/pydat1/,/pypars/,/pydat2/
47817 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
47818  INTEGER imodel
47819  REAL m0,mhf,a0,mt
47820  CHARACTER*20 chmod(5)
47821  CHARACTER*32 fname
47822 
47823  COMMON /sugnu/ xnusug(18)
47824  REAL xnusug
47825  SAVE /sugnu/
47826 
47827  DATA chmod/'mSUGRA','mGMSB','non-universal SUGRA',
47828  & 'truly unified SUGRA', 'non-minimal GMSB'/
47829 
47830 C...Start by checking for incompatibilities/inconsistencies:
47831  DO 100 ichk=2,9
47832  IF (ichk.NE.8.AND.ichk.NE.4.AND.imss(ichk).NE.0) THEN
47833  WRITE (mstu(11),*) '(PYSUGI:) IMSS(',ichk,')=',imss(ichk)
47834  & ,' option not used by PYSUGI'
47835  ENDIF
47836  100 CONTINUE
47837 C...ISAJET works with REAL numbers.
47838  mzero=REAL(rmss(8))
47839  mhlf=REAL(rmss(1))
47840  azero=REAL(rmss(16))
47841  tanb=REAL(rmss(5))
47842  sgnmu=REAL(rmss(4))
47843  mtop=REAL(pmas(6,1))
47844  imodel=0
47845  IF (imss(1).EQ.12) THEN
47846  imodel=1
47847  goto 130
47848  ELSEIF(imss(1).EQ.13) THEN
47849 C...Read from isajet par file in IMSS(20)
47850  lfn=imss(20)
47851 C...STOP IF LFN IS ZERO (i.e. if no LFN was given).
47852  IF (lfn.EQ.0) THEN
47853  WRITE(mstu(11),*) '(PYSUGI:) No valid unit given in IMSS(20)'
47854  goto 9999
47855  ENDIF
47856  WRITE(mstu(11),*) 'READING SUSY MODEL FROM FILE...'
47857 CMrenna change to allow any susy model
47858  WRITE(mstu(11),*) 'ENTER 1 for mSUGRA:'
47859  WRITE(mstu(11),*) 'ENTER 2 for mGMSB:'
47860  WRITE(mstu(11),*) 'ENTER 3 for non-universal SUGRA:'
47861  WRITE(mstu(11),*) 'ENTER 4 for SUGRA with truly unified'//
47862  & ' gauge couplings:'
47863  WRITE(mstu(11),*) 'ENTER 5 for non-minimal GMSB:'
47864  READ(lfn,*) imodel
47865  IF (imodel.EQ.4) THEN
47866  ial3un=1
47867  imodel=1
47868  ENDIF
47869  IF (imodel.EQ.1.OR.imodel.EQ.3) THEN
47870  WRITE(mstu(11),*) 'ENTER M_0, M_(1/2), A_0, tan(beta),'
47871  & //' sgn(mu), M_t:'
47872  READ(lfn,*) m0,mhf,a0,tanb,sgnmu,mt
47873  IF (imodel.EQ.3) THEN
47874  imodel=1
47875  110 WRITE(mstu(11),*) ' ENTER 1,...,5 for NUSUGx keyword;'
47876  & //' 0 to continue:'
47877  WRITE(mstu(11),*) ' NUSUG1 = GUT scale gaugino masses'
47878  WRITE(mstu(11),*) ' NUSUG2 = GUT scale A terms'
47879  WRITE(mstu(11),*) ' NUSUG3 = GUT scale Higgs masses'
47880  WRITE(mstu(11),*) ' NUSUG4 = GUT scale 1st/2nd'
47881  & //' generation masses'
47882  WRITE(mstu(11),*)
47883  & ' NUSUG5 = GUT scale 3rd generation masses'
47884  READ(lfn,*) inusug
47885  IF (inusug.EQ.0) THEN
47886  goto 120
47887  ELSEIF (inusug.EQ.1) THEN
47888  WRITE(mstu(11),*) 'Enter GUT scale M_1, M_2, M_3:'
47889  READ(lfn,*) xnusug(1),xnusug(2),xnusug(3)
47890  IF (xnusug(3).LE.0.) THEN
47891  WRITE(mstu(11),*) ' NEGATIVE M_3 IS NOT ALLOWED'
47892  CALL pystop(109)
47893  END IF
47894  ELSEIF (inusug.EQ.2) THEN
47895  WRITE(mstu(11),*) 'Enter GUT scale A_t, A_b, A_tau:'
47896  READ(lfn,*) xnusug(6),xnusug(5),xnusug(4)
47897  ELSEIF (inusug.EQ.3) THEN
47898  WRITE(mstu(11),*) 'Enter GUT scale m_Hd, m_Hu:'
47899  READ(lfn,*) xnusug(7),xnusug(8)
47900  ELSEIF (inusug.EQ.4) THEN
47901  WRITE(mstu(11),*) 'Enter GUT scale M(ul), M(dr),'
47902  & //' M(ur), M(el), M(er):'
47903  READ(lfn,*) xnusug(13),xnusug(11),xnusug(12),
47904  & xnusug(10),xnusug(9)
47905  ELSEIF (inusug.EQ.5) THEN
47906  WRITE(mstu(11),*) 'Enter GUT scale M(tl), M(br), M(tr),'
47907  & //' M(Ll), M(Lr):'
47908  READ(lfn,*) xnusug(18),xnusug(16),xnusug(17),
47909  & xnusug(15),xnusug(14)
47910  ENDIF
47911  goto 110
47912  ENDIF
47913  ELSEIF (imodel.EQ.2.OR.imodel.EQ.5) THEN
47914  imss(11)=1
47915  WRITE(mstu(11),*) 'ENTER Lambda, M_mes, N_5, tan(beta),'
47916  & ,' sgn(mu), M_t, C_gv:'
47917  READ(lfn,*) m0,mhf,a0,tanb,sgnmu,mt,xcmgv
47918  xgmin(7)=xcmgv
47919  xgmin(8)=1.
47920 C...Planck scale: AMPL = 2.4 E18 GeV = {8 pi G_newton}^{1/2}
47921  ampl=2.4d18
47922  amgvss=m0*mhf*xcmgv/sqrt(3d0)/ampl
47923  IF (imodel.EQ.5) THEN
47924  imodel=2
47925  WRITE(mstu(11),*) 'Rsl = factor multiplying gaugino'
47926  & ,' masses at M_mes'
47927  WRITE(mstu(11),*) 'dmH_d2, dmH_u2 = Higgs mass**2'
47928  & ,' shifts at M_mes'
47929  WRITE(mstu(11),*) 'd_Y = mass**2 shifts proportional to',
47930  & ' Y at M_mes'
47931  WRITE(mstu(11),*) 'n5_1,n5_2,n5_3 = n5 values for U(1),'
47932  & ,'SU(2),SU(3)'
47933  WRITE(mstu(11),*) 'ENTER Rsl, dmH_d2, dmH_u2, d_Y, n5_1,'
47934  & ,' n5_2, n5_3'
47935  READ(lfn,*) xgmin(8),xgmin(9),xgmin(10),xgmin(11),xgmin(12),
47936  $ xgmin(13),xgmin(14)
47937  ENDIF
47938  ELSE
47939  WRITE(mstu(11),*) 'Invalid model choice.'
47940  goto 9999
47941  ENDIF
47942  ENDIF
47943 
47944  120 mzero=m0
47945  mhlf=mhf
47946  azero=a0
47947 C TANB=REAL(RMSS(5))
47948 C SGNMU=REAL(RMSS(4))
47949  mtop=mt
47950 
47951 C...Initialize MSSM parameter array
47952  130 DO 140 ipar=1,72
47953  super(ipar)=0.0
47954  140 CONTINUE
47955 C...Call ISASUGRA
47956  CALL sugra(mzero,mhlf,azero,tanb,sgnmu,mtop,imodel)
47957 C...Check whether ISASUSY thought the model was OK.
47958  IF (nogood.NE.0) THEN
47959  IF (nogood.EQ.1) CALL pyerrm(26
47960  & ,'(PYSUGI:) SUSY parameters give tachyonic particles.')
47961  IF (nogood.EQ.2) CALL pyerrm(26
47962  & ,'(PYSUGI:) SUSY parameters give no EWSB.')
47963  IF (nogood.EQ.3) CALL pyerrm(26
47964  & ,'(PYSUGI:) SUSY parameters give m(A0) < 0.')
47965  IF (nogood.EQ.4) CALL pyerrm(26
47966  & ,'(PYSUGI:) SUSY parameters give Yukawa > 100.')
47967  IF (nogood.EQ.7) CALL pyerrm(26
47968  & ,'(PYSUGI:) SUSY parameters give x_T EWSB bad.')
47969  IF (nogood.EQ.8) CALL pyerrm(26
47970  & ,'(PYSUGI:) SUSY parameters give m(h0)2 < 0.')
47971 C...Give warning, but don't stop, if LSP not ~chi_10.
47972  IF (nogood.EQ.5) CALL pyerrm(16
47973  & ,'(PYSUGI:) SUSY parameters give ~chi_10 not LSP.')
47974  ENDIF
47975 C...Warn about possible GUT scale tachyons.
47976  IF (itachy.NE.0) CALL pyerrm(16,
47977  & '(PYSUGI:) Tachyonic sleptons at GUT scale.')
47978 C...Finalize spectrum (last iteration)
47979 C...(Thanks to A. Raklev for pointing this out.)
47980 C...NB: SSMSSM also calculates decays, but these are not used by Pythia.
47981  CALL ssmssm(xisain(1),xisain(2),xisain(3),
47982  $ xisain(4),xisain(5),xisain(6),xisain(7),xisain(8),xisain(9),
47983  $ xisain(10),xisain(11),xisain(12),xisain(13),xisain(14),
47984  $ xisain(15),xisain(16),xisain(17),xisain(18),xisain(19),
47985  $ xisain(20),xisain(21),xisain(22),xisain(23),xisain(24),
47986  $ mtop,iallow,1)
47987 
47988 C...M1, M2, M3.
47989  rmss(1)=dble(gss(7))
47990  rmss(2)=dble(gss(8))
47991  rmss(3)=dble(gss(9))
47992  rmsoft(1)=dble(gss(7))
47993  rmsoft(2)=dble(gss(8))
47994  rmsoft(3)=dble(gss(9))
47995 C...Mu = - Higgsino mass.
47996  rmss(4)=-super(29)
47997  rmss(5)=tanb
47998 C...Slepton and squark masses. 2 first generations.
47999  rmss(6)=0.5*(super(18)+super(20))
48000  rmss(7)=0.5*(super(19)+super(21))
48001  rmss(8)=0.25*(super(2)+super(4)+super(6)+super(8))
48002  rmss(9)=0.25*(super(3)+super(5)+super(7)+super(9))
48003 C...Third generation.
48004  rmss(10)=0.5*(super(14)+super(10))
48005  rmss(11)=super(11)
48006  rmss(12)=super(15)
48007  rmss(13)=super(22)
48008  rmss(14)=super(23)
48009 C...SLHA: store exact soft spectrum in RMSOFT
48010  rmsoft(31)=super(18)
48011  rmsoft(32)=super(20)
48012  rmsoft(33)=super(22)
48013  rmsoft(34)=super(19)
48014  rmsoft(35)=super(21)
48015  rmsoft(36)=super(23)
48016  rmsoft(41)=0.5d0*(super(2)+super(4))
48017  rmsoft(42)=0.5d0*(super(6)+super(8))
48018  rmsoft(43)=0.5d0*(super(10)+super(14))
48019  rmsoft(44)=super(3)
48020  rmsoft(45)=super(9)
48021  rmsoft(46)=super(15)
48022  rmsoft(47)=super(5)
48023  rmsoft(48)=super(7)
48024  rmsoft(49)=super(11)
48025 
48026 C...~b, ~t, and ~tau trilinear couplings and mixing angles.
48027  rmss(15)=super(62)
48028  rmss(16)=super(60)
48029  rmss(17)=super(64)
48030  rmss(26)=super(63)
48031  rmss(27)=super(61)
48032  rmss(28)=super(65)
48033 C...SLHA trilinears
48034  DO 142 k1=1,3
48035  DO 141 k2=1,3
48036  ae(k1,k2)=0d0
48037  au(k1,k2)=0d0
48038  ad(k1,k2)=0d0
48039  141 CONTINUE
48040  142 CONTINUE
48041  ae(3,3)=super(64)
48042  au(3,3)=super(60)
48043  ad(3,3)=super(62)
48044 C...Higgs mixing angle alpha (Gunion-Haber convention).
48045  rmss(18)=-super(59)
48046 C...A0 mass.
48047  rmss(19)=super(57)
48048 C...GUT scale coupling
48049  rmss(20)=agutss
48050 C...Gravitino mass (for future compatibility)
48051  rmss(21)=max(rmss(21),dble(super(66)))
48052 
48053 C...Now we're done with RMSS. Time to fill PMAS (m > 0 required).
48054 C...Higgs sector.
48055  pmas(pycomp(25),1)=abs(super(55))
48056  pmas(pycomp(35),1)=abs(super(56))
48057  pmas(pycomp(36),1)=abs(super(57))
48058  pmas(pycomp(37),1)=abs(super(58))
48059 C...Gluino.
48060  pmas(pycomp(ksusy1+21),1)=abs(super(1))
48061 C...Squarks and Sleptons.
48062  DO 150 ilr=1,2
48063  ilrm=ilr-1
48064  pmas(pycomp(ilr*ksusy1+1),1)=abs(super(4+ilrm))
48065  pmas(pycomp(ilr*ksusy1+2),1)=abs(super(2+ilrm))
48066  pmas(pycomp(ilr*ksusy1+3),1)=abs(super(6+ilrm))
48067  pmas(pycomp(ilr*ksusy1+4),1)=abs(super(8+ilrm))
48068  pmas(pycomp(ilr*ksusy1+5),1)=abs(super(12+ilrm))
48069  pmas(pycomp(ilr*ksusy1+6),1)=abs(super(16+ilrm))
48070  pmas(pycomp(ilr*ksusy1+11),1)=abs(super(18+ilrm))
48071  pmas(pycomp(ilr*ksusy1+13),1)=abs(super(20+ilrm))
48072  pmas(pycomp(ilr*ksusy1+15),1)=abs(super(24+ilrm))
48073  150 CONTINUE
48074  pmas(pycomp(ksusy1+12),1)=abs(super(26))
48075  pmas(pycomp(ksusy1+14),1)=abs(super(27))
48076  pmas(pycomp(ksusy1+16),1)=abs(super(28))
48077 C...Neutralinos.
48078  pmas(pycomp(ksusy1+22),1)=abs(super(31))
48079  pmas(pycomp(ksusy1+23),1)=abs(super(32))
48080  pmas(pycomp(ksusy1+25),1)=abs(super(33))
48081  pmas(pycomp(ksusy1+35),1)=abs(super(34))
48082 C...Signed masses (extra minus from going to G-H convention).
48083  smz(1)=-super(31)
48084  smz(2)=-super(32)
48085  smz(3)=-super(33)
48086  smz(4)=-super(34)
48087 C...Charginos
48088  pmas(pycomp(ksusy1+24),1)=abs(super(51))
48089  pmas(pycomp(ksusy1+37),1)=abs(super(52))
48090 C...Signed masses (extra minus from going to G-H convention).
48091  smw(1)=-super(51)
48092  smw(2)=-super(52)
48093 
48094 C... Neutralino Mixing.
48095  DO 160 in=1,4
48096  zmix(in,1)= super(38+4*(in-1))
48097  zmix(in,2)= super(37+4*(in-1))
48098  zmix(in,3)=-super(36+4*(in-1))
48099  zmix(in,4)=-super(35+4*(in-1))
48100  160 CONTINUE
48101 C...Chargino Mixing (PYTHIA same angle as HERWIG).
48102  thx=1d0
48103  thy=1d0
48104  IF (super(53).GT.0) thx=-1d0
48105  IF (super(54).GT.0) thy=-1d0
48106  umix(1,1) = -sin(super(53))
48107  umix(1,2) = -cos(super(53))
48108  umix(2,1) = -thx*cos(super(53))
48109  umix(2,2) = thx*sin(super(53))
48110  vmix(1,1) = -sin(super(54))
48111  vmix(1,2) = -cos(super(54))
48112  vmix(2,1) = -thy*cos(super(54))
48113  vmix(2,2) = thy*sin(super(54))
48114 C...Sfermion mixing (PYTHIA same angle as ISAJET)
48115  sfmix(5,1)=cos(super(63))
48116  sfmix(5,2)=sin(super(63))
48117  sfmix(5,3)=-sin(super(63))
48118  sfmix(5,4)=cos(super(63))
48119  sfmix(6,1)=cos(super(61))
48120  sfmix(6,2)=sin(super(61))
48121  sfmix(6,3)=-sin(super(61))
48122  sfmix(6,4)=cos(super(61))
48123  sfmix(15,1)=cos(super(65))
48124  sfmix(15,2)=sin(super(65))
48125  sfmix(15,3)=-sin(super(65))
48126  sfmix(15,4)=cos(super(65))
48127 
48128  IF (mstp(122).NE.0) THEN
48129 C...Print a few lines to make the user know what's happening
48130  isaver=visaje()
48131  WRITE(mstu(11),5000) doc, isaver
48132  WRITE(mstu(11),5100)
48133  IF (imodel.EQ.1) THEN
48134  WRITE(mstu(11),5200) mzero, mhlf, azero, tanb, nint(sgnmu),
48135  & mtop
48136  WRITE(mstu(11),5300)
48137  ENDIF
48138  WRITE(mstu(11),5500) 'Pole masses'
48139  WRITE(mstu(11),5700) (super(ip),ip=2,16,2),(super(ip),ip=3,17,2)
48140  WRITE(mstu(11),5800) (super(ip),ip=18,24,2),(super(ip),ip=26,28)
48141  & ,(super(ip),ip=19,25,2)
48142  WRITE(mstu(11),5900) super(1),(smz(ip),ip=1,4), (smw(ip)
48143  & ,ip=1,2)
48144  WRITE(mstu(11),5400)
48145  WRITE(mstu(11),6000) (super(ip),ip=55,58)
48146  WRITE(mstu(11),5400)
48147  WRITE(mstu(11),5500) 'EW scale mixing structure'
48148  WRITE(mstu(11),6100) ((zmix(i,j), j=1,4),i=1,4)
48149  WRITE(mstu(11),6200) (umix(1,j), j=1,2),(vmix(1,j),j=1,2)
48150  & ,(umix(2,j), j=1,2),(vmix(2,j),j=1,2)
48151  WRITE(mstu(11),6300) (sfmix(5,j), j=1,2),(sfmix(6,j),j=1,2)
48152  & ,(sfmix(15,j), j=1,2),(sfmix(5,j),j=3,4),(sfmix(6,j), j=3,4
48153  & ),(sfmix(15,j),j=3,4)
48154  WRITE(mstu(11),5400)
48155  WRITE(mstu(11),6450) rmss(18)
48156  WRITE(mstu(11),5400)
48157  WRITE(mstu(11),5500) 'Couplings'
48158  WRITE(mstu(11),6400) rmss(15),rmss(16),rmss(17),rmss(20)
48159  WRITE(mstu(11),5400)
48160  ENDIF
48161 
48162 C...Call FeynHiggs to improve Higgs sector if requested
48163  IF (imss(4).EQ.3) THEN
48164  IF (mstp(122).NE.0) WRITE(mstu(11),'(1x,"*"/1x,"*",A)')
48165  & ' (PYSUGI:) Now calling FeynHiggs.'
48166  CALL pyfeyn(ierr)
48167  IF (ierr.EQ.0) THEN
48168  imss(4)=2
48169  IF (mstp(122).NE.0) THEN
48170  WRITE(mstu(11),5400)
48171  WRITE(mstu(11),5500)
48172  & 'Corrected Higgs masses and mixing'
48173  WRITE(mstu(11),6000) pmas(25,1),pmas(35,1),pmas(36,1),
48174  & pmas(37,1)
48175  WRITE(mstu(11),6450) rmss(18)
48176  WRITE(mstu(11),5400)
48177  ENDIF
48178  ENDIF
48179  ENDIF
48180 
48181  IF (mstp(122).NE.0) WRITE(mstu(11),6500)
48182 
48183 C...Fix the higgs sector (in PYMSIN) using the masses and mixing angle
48184 C...output by ISASUSY.
48185  imss(4)=max(2,imss(4))
48186 
48187  5000 FORMAT(1x,19('*'),1x,'PYSUGI v1.52: PYTHIA/ISASUSY '
48188  & ,'INTERFACE',1x,19('*')/1x,'*',3x,'PYSUGI: Last Change',1x,a
48189  & ,1x,'-',1x,'P. Skands / S. Mrenna'/1x,'*',2x,a/1x,'*')
48190  5100 FORMAT(1x,'*',1x,'ISASUSY Input:'/1x,'*',1x,'----------------')
48191  5200 FORMAT(1x,'*',1x,3x,'M_0',6x,'M_1/2',5x,'A_0',3x,'Tan(beta)',
48192  & 3x,'Sgn(mu)',3x,'M_t'/1x,'*',1x,4(f8.2,1x),i8,2x,f8.2)
48193  5300 FORMAT(1x,'*'/1x,'*',1x,'ISASUSY Output:'/1x,'*',1x
48194  & ,'----------------')
48195  5400 FORMAT(1x,'*',1x,a)
48196  5500 FORMAT(1x,'*',1x,a,':')
48197  5600 FORMAT(1x,'*',2x,2x,'M_GUT',2x,2x,'g_GUT',2x,1x,'alpha_GUT'/
48198  & 1x,'*',2x,1p,2(1x,e8.2),2x,e8.2)
48199  5700 FORMAT(1x,'*',4x,4x,'~u',2x,1x,4x,'~d',2x,1x,4x,'~s',2x,1x,
48200  & 4x,'~c',2x,1x,4x,'~b',2x,1x,2x,'~b(12)',1x,4x,'~t',2x,1x, 2x,
48201  & '~t(12)'/1x,'*',2x,'L',1x,8(f8.2,1x)/1x,'*',2x,'R',1x,8(f8.2
48202  & ,1x))
48203  5800 FORMAT(1x,'*'/1x,'*',4x,4x,'~e',2x,1x,3x,'~mu',2x,1x,3x,'~tau',1x
48204  & ,1x,'~tau(12)',1x,2x,'~nu_e',1x,1x,1x,'~nu_mu',1x,1x,1x
48205  & ,'~nu_tau'/1x,'*',2x,'L',1x,7(f8.2,1x)/1x,'*',2x,'R',1x,4(f8
48206  & .2,1x))
48207  5900 FORMAT(1x,'*'/1x,'*',4x,4x,'~g',2x,1x,1x,'~chi_10',1x,1x,'~chi_20'
48208  & ,1x,1x,'~chi_30',1x,1x,'~chi_40',1x,1x,'~chi_1+',1x
48209  & ,1x,'~chi_2+'/1x,'*',3x,1x,7(f8.2,1x))
48210  6000 FORMAT(1x,'*',4x,4x,'h0',2x,1x,4x,'H0',2x,1x,4x,'A0',2x
48211  & ,1x,4x,'H+'/1x,'*',3x,1x,5(f8.2,1x))
48212  6050 FORMAT(1x,'*'/1x,'*',4x,4x,'h0',2x,1x,4x,'H0',2x,1x,4x,'A0',2x
48213  & ,1x,4x,'H+'/1x,'*',3x,1x,5(f8.2,1x),3x,'(Before FeynHiggs)')
48214  6100 FORMAT(1x,'*',11x,'|',3x,'~B',3x,'|',2x,'~W_3',2x,'|',2x
48215  & ,'~H_1',2x,'|',2x,'~H_2',2x,'|'/1x,'*',3x,'~chi_10',1x,4('|'
48216  & ,1x,f6.3,1x),'|'/1x,'*',3x,'~chi_20',1x,4('|'
48217  & ,1x,f6.3,1x),'|'/1x,'*',3x,'~chi_30',1x,4('|'
48218  & ,1x,f6.3,1x),'|'/1x,'*',3x,'~chi_40',1x,4('|'
48219  & ,1x,f6.3,1x),'|')
48220  6200 FORMAT(1x,'*'/1x,'*',6x,'L',4x,'|',3x,'~W',3x,'|',3x,'~H',3x,'|'
48221  & ,12x,'R',4x,'|',3x,'~W',3x,'|',3x,'~H',3x,'|'/1x,'*',3x
48222  & ,'~chi_1+',1x,2('|',1x,f6.3,1x),'|',9x,'~chi_1+',1x,2('|',1x
48223  & ,f6.3,1x),'|'/1x,'*',3x,'~chi_2+',1x,2('|',1x,f6.3,1x),'|',9x
48224  & ,'~chi_2+',1x,2('|',1x,f6.3,1x),'|')
48225  6300 FORMAT(1x,'*'/1x,'*',8x,'|',2x,'~b_L',2x,'|',2x,'~b_R',2x,'|',8x
48226  & ,'|',2x,'~t_L',2x,'|',2x,'~t_R',2x,'|',10x
48227  & ,'|',1x,'~tau_L',1x,'|',1x,'~tau_R',1x,'|'/
48228  & 1x,'*',3x,'~b_1',1x,2('|',1x,f6.3,1x),'|',3x,'~t_1',1x,2('|'
48229  & ,1x,f6.3,1x),'|',3x,'~tau_1',1x,2('|',1x,f6.3,1x),'|'/
48230  & 1x,'*',3x,'~b_2',1x,2('|',1x,f6.3,1x),'|',3x,'~t_2',1x,2('|'
48231  & ,1x,f6.3,1x),'|',3x,'~tau_2',1x,2('|',1x,f6.3,1x),'|')
48232  6400 FORMAT(1x,'*',3x,'A_b = ',f8.2,4x,'A_t = ',f8.2,4x,'A_tau = ',f8.2
48233  & ,4x,'Alpha_GUT = ',f8.2)
48234  6450 FORMAT(1x,'*',3x,'Alpha_Higgs = ',f8.4)
48235  6500 FORMAT(1x,32('*'),1x,'END OF PYSUGI',1x,31('*'))
48236 
48237  9999 RETURN
48238  END
48239 
48240 C*********************************************************************
48241 
48242 C...PYFEYN
48243 C...Interface to FeynHiggs for MSSM Higgs sector.
48244 C...Pythia6.402: Updated to FeynHiggs v.2.3.0+ w/ DOUBLE COMPLEX
48245 C...P. Skands
48246 
48247  SUBROUTINE pyfeyn(IERR)
48248 
48249 C...Double precision and integer declarations.
48250  IMPLICIT DOUBLE PRECISION(a-h, o-z)
48251  IMPLICIT INTEGER(i-n)
48252  INTEGER pyk,pychge,pycomp
48253 C...Commonblocks.
48254  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
48255  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
48256 C...SUSY blocks
48257  common/pymssm/imss(0:99),rmss(0:99)
48258 C...FeynHiggs variables
48259  DOUBLE PRECISION rmhigg(4)
48260  DOUBLE COMPLEX saeff, uhiggs(3,3)
48261  DOUBLE COMPLEX dmu,
48262  & ae33, au33, ad33, ae22, au22, ad22, ae11, au11, ad11,
48263  & dm1, dm2, dm3
48264 C...SLHA Common Block
48265  common/pylh3p/modsel(200),parmin(100),parext(200),rmsoft(0:100),
48266  & au(3,3),ad(3,3),ae(3,3)
48267  SAVE /pydat1/,/pydat2/,/pymssm/,/pylh3p/
48268 
48269  ierr=0
48270  CALL fhsetflags(ierr,4,0,0,2,0,2,1,1)
48271  IF (ierr.NE.0) THEN
48272  CALL pyerrm(11,'(PYHGGM:) Caught error from FHSETFLAGS.'
48273  & //'Will not use FeynHiggs for this run.')
48274  RETURN
48275  ENDIF
48276  q=rmsoft(0)
48277  dmb=pmas(5,1)
48278  dmt=pmas(6,1)
48279  dmz=pmas(23,1)
48280  dmw=pmas(24,1)
48281  dma=pmas(36,1)
48282  dm1=rmsoft(1)
48283  dm2=rmsoft(2)
48284  dm3=rmsoft(3)
48285  dtanb=rmss(5)
48286  dmu=rmss(4)
48287  dm3sl=rmsoft(33)
48288  dm3se=rmsoft(36)
48289  dm3sq=rmsoft(43)
48290  dm3su=rmsoft(46)
48291  dm3sd=rmsoft(49)
48292  dm2sl=rmsoft(32)
48293  dm2se=rmsoft(35)
48294  dm2sq=rmsoft(42)
48295  dm2su=rmsoft(45)
48296  dm2sd=rmsoft(48)
48297  dm1sl=rmsoft(31)
48298  dm1se=rmsoft(34)
48299  dm1sq=rmsoft(41)
48300  dm1su=rmsoft(44)
48301  dm1sd=rmsoft(47)
48302  ae33=ae(3,3)
48303  ae22=ae(2,2)
48304  ae11=ae(1,1)
48305  au33=au(3,3)
48306  au22=au(2,2)
48307  au11=au(1,1)
48308  ad33=ad(3,3)
48309  ad22=ad(2,2)
48310  ad11=ad(1,1)
48311  CALL fhsetpara(ierr, 1d0, dmt, dmb, dmw, dmz, dtanb,
48312  & dma,0d0, dm3sl, dm3se, dm3sq, dm3su, dm3sd,
48313  & dm2sl, dm2se, dm2sq, dm2su, dm2sd,
48314  & dm1sl, dm1se, dm1sq, dm1su, dm1sd,dmu,
48315  & ae33, au33, ad33, ae22, au22, ad22, ae11, au11, ad11,
48316  & dm1, dm2, dm3, 0d0, 0d0,q,q,q)
48317  IF (ierr.NE.0) THEN
48318  CALL pyerrm(11,'(PYHGGM:) Caught error from FHSETPARA.'
48319  & //' Will not use FeynHiggs for this run.')
48320  RETURN
48321  ENDIF
48322 C... Get Higgs masses & alpha_eff. (UHIGGS redundant here, only for CPV)
48323  saeff=0d0
48324  CALL fhhiggscorr(ierr, rmhigg, saeff, uhiggs)
48325  IF (ierr.NE.0) THEN
48326  CALL pyerrm(11,'(PYFEYN:) Caught error from FHHIG'//
48327  & 'GSCORR. Will not use FeynHiggs for this run.')
48328  RETURN
48329  ENDIF
48330  alpha = asin(dble(saeff))
48331  r=rmss(18)/alpha
48332  IF (r.LT.0d0.OR.abs(r).GT.1.2d0.OR.abs(r).LT.0.8d0) THEN
48333  CALL pyerrm(1,'(PYFEYN:) Large corrections in Higgs sector.')
48334  WRITE(mstu(11),*) ' Old Alpha:', rmss(18)
48335  WRITE(mstu(11),*) ' New Alpha:', alpha
48336  ENDIF
48337  IF (rmhigg(1).LT.0.85d0*pmas(25,1).OR.rmhigg(1).GT.
48338  & 1.15d0*pmas(25,1)) THEN
48339  CALL pyerrm(1,'(PYFEYN:) Large corrections in Higgs sector.')
48340  WRITE(mstu(11),*) ' Old m(h0):', pmas(25,1)
48341  WRITE(mstu(11),*) ' New m(h0):', rmhigg(1)
48342  ENDIF
48343  rmss(18)=alpha
48344  pmas(25,1)=rmhigg(1)
48345  pmas(35,1)=rmhigg(2)
48346  pmas(36,1)=rmhigg(3)
48347  pmas(37,1)=rmhigg(4)
48348 
48349  RETURN
48350  END
48351 
48352 C*********************************************************************
48353 
48354 C...PYRNMQ
48355 C...Determines the running mass of Squarks.
48356 
48357  FUNCTION pyrnmq(ID,DTERM)
48358 
48359 C...Double precision and integer declarations.
48360  IMPLICIT DOUBLE PRECISION(a-h, o-z)
48361  IMPLICIT INTEGER(i-n)
48362  INTEGER pyk,pychge,pycomp
48363 C...Commonblock.
48364  common/pymssm/imss(0:99),rmss(0:99)
48365  SAVE /pymssm/
48366 
48367 C...Local variables.
48368  DOUBLE PRECISION pi,r
48369  DOUBLE PRECISION tol
48370  DOUBLE PRECISION ci(3)
48371  EXTERNAL pyalps
48372  DOUBLE PRECISION pyalps
48373  DATA tol/0.001d0/
48374  DATA pi,r/3.141592654d0,.61803399d0/
48375  DATA ci/0.47d0,0.07d0,0.02d0/
48376 
48377  c=1d0-r
48378  ca=ci(id)
48379  ag=(0.71d0)**2/4d0/pi
48380  ag=rmss(20)
48381  xm0=rmss(8)
48382  xmg=rmss(1)
48383  xm02=xm0*xm0
48384  xmg2=xmg*xmg
48385 
48386  as=pyalps(xm02+6d0*xmg2)
48387  cg=8d0/9d0*((as/ag)**2-1d0)
48388  bx=xm02+(ca+cg)*xmg2+dterm
48389  ax=min(50d0**2,0.5d0*bx)
48390  cx=max(2000d0**2,2d0*bx)
48391 
48392  x0=ax
48393  x3=cx
48394  IF(abs(cx-bx).GT.abs(bx-ax))THEN
48395  x1=bx
48396  x2=bx+c*(cx-bx)
48397  ELSE
48398  x2=bx
48399  x1=bx-c*(bx-ax)
48400  ENDIF
48401  as1=pyalps(x1)
48402  cg=8d0/9d0*((as1/ag)**2-1d0)
48403  f1=abs(xm02+(ca+cg)*xmg2+dterm-x1)
48404  as2=pyalps(x2)
48405  cg=8d0/9d0*((as2/ag)**2-1d0)
48406  f2=abs(xm02+(ca+cg)*xmg2+dterm-x2)
48407  100 IF(abs(x3-x0).GT.tol*(abs(x1)+abs(x2))) THEN
48408  IF(f2.LT.f1) THEN
48409  x0=x1
48410  x1=x2
48411  x2=r*x1+c*x3
48412  f1=f2
48413  as2=pyalps(x2)
48414  cg=8d0/9d0*((as2/ag)**2-1d0)
48415  f2=abs(xm02+(ca+cg)*xmg2+dterm-x2)
48416  ELSE
48417  x3=x2
48418  x2=x1
48419  x1=r*x2+c*x0
48420  f2=f1
48421  as1=pyalps(x1)
48422  cg=8d0/9d0*((as1/ag)**2-1d0)
48423  f1=abs(xm02+(ca+cg)*xmg2+dterm-x1)
48424  ENDIF
48425  goto 100
48426  ENDIF
48427  IF(f1.LT.f2) THEN
48428  pyrnmq=x1
48429  xmin=x1
48430  ELSE
48431  pyrnmq=x2
48432  xmin=x2
48433  ENDIF
48434 
48435  RETURN
48436  END
48437 
48438 C*********************************************************************
48439 
48440 C...PYTHRG
48441 C...Calculates the mass eigenstates of the third generation sfermions.
48442 C...Created: 5-31-96
48443 
48444  SUBROUTINE pythrg
48445 
48446 C...Double precision and integer declarations.
48447  IMPLICIT DOUBLE PRECISION(a-h, o-z)
48448  IMPLICIT INTEGER(i-n)
48449  INTEGER pyk,pychge,pycomp
48450 C...Parameter statement to help give large particle numbers.
48451  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
48452  &kexcit=4000000,kdimen=5000000)
48453 C...Commonblocks.
48454  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
48455  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
48456  common/pymssm/imss(0:99),rmss(0:99)
48457  common/pyssmt/zmix(4,4),umix(2,2),vmix(2,2),smz(4),smw(2),
48458  &sfmix(16,4),zmixi(4,4),umixi(2,2),vmixi(2,2)
48459  SAVE /pydat1/,/pydat2/,/pymssm/,/pyssmt/
48460 
48461 C...Local variables.
48462  DOUBLE PRECISION beta
48463  DOUBLE PRECISION am2(2,2),rt(2,2),di(2,2)
48464  DOUBLE PRECISION xmz2,xmw2,tanb,xmu,cos2b,xmql2,xmqr2
48465  DOUBLE PRECISION xmf,xmf2,diff,same,xmf12,xmf22,small
48466  DOUBLE PRECISION atr,amqr,amql
48467  INTEGER id1(3),id2(3),id3(3),id4(3)
48468  INTEGER if,i,j,ii,jj,it,l
48469  LOGICAL dterm
48470  DATA small/1d-3/
48471  DATA id1/10,10,13/
48472  DATA id2/5,6,15/
48473  DATA id3/15,16,17/
48474  DATA id4/11,12,14/
48475  DATA dterm/.true./
48476 
48477  xmz2=pmas(23,1)**2
48478  xmw2=pmas(24,1)**2
48479  tanb=rmss(5)
48480  xmu=-rmss(4)
48481  beta=atan(tanb)
48482  cos2b=cos(2d0*beta)
48483 
48484 C...OPTION TO FIX T1, T2, B1 MASSES AND MIXINGS
48485 
48486  iopt=imss(5)
48487  IF(iopt.EQ.1) THEN
48488  ctt=dcos(rmss(27))
48489  ctt2=ctt**2
48490  stt=dsin(rmss(27))
48491  stt2=stt**2
48492  xm12=rmss(10)**2
48493  xm22=rmss(12)**2
48494  xmql2=ctt2*xm12+stt2*xm22
48495  xmqr2=stt2*xm12+ctt2*xm22
48496  xmf2=pymrun(6,pmas(6,1)**2)**2
48497  atop=-xmu/tanb+ctt*stt*(xm12-xm22)/sqrt(xmf2)
48498  rmss(16)=atop
48499 C......SUBTRACT OUT D-TERM AND FERMION MASS
48500  xmql2=xmql2-xmf2-(4d0*xmw2-xmz2)*cos2b/6d0
48501  xmqr2=xmqr2-xmf2+(xmw2-xmz2)*cos2b*2d0/3d0
48502  IF(xmql2.GE.0d0) THEN
48503  rmss(10)=sqrt(xmql2)
48504  ELSE
48505  rmss(10)=-sqrt(-xmql2)
48506  ENDIF
48507  IF(xmqr2.GE.0d0) THEN
48508  rmss(12)=sqrt(xmqr2)
48509  ELSE
48510  rmss(12)=-sqrt(-xmqr2)
48511  ENDIF
48512 
48513 C SAME FOR BOTTOM SQUARK
48514  ctt=dcos(rmss(26))
48515  ctt2=ctt**2
48516  stt=dsin(rmss(26))
48517  stt2=stt**2
48518  xm22=rmss(11)**2
48519  xmf2=pymrun(5,pmas(6,1)**2)**2
48520  xmql2=sign(rmss(10)**2,rmss(10))-(2d0*xmw2+xmz2)*cos2b/6d0+xmf2
48521  IF(abs(ctt).GE..9999d0) THEN
48522  abot=-xmu*tanb
48523  xmqr2=rmss(11)**2
48524  ELSEIF(abs(ctt).LE.1d-4) THEN
48525  abot=-xmu*tanb
48526  xmqr2=rmss(11)**2
48527  ELSE
48528  xm12=(xmql2-stt2*xm22)/ctt2
48529  xmqr2=stt2*xm12+ctt2*xm22
48530  abot=-xmu*tanb+ctt*stt*(xm12-xm22)/sqrt(xmf2)
48531  ENDIF
48532  rmss(15)=abot
48533 C......SUBTRACT OUT D-TERM AND FERMION MASS
48534  xmqr2=xmqr2-(xmw2-xmz2)*cos2b/3d0-xmf2
48535  IF(xmqr2.GE.0d0) THEN
48536  rmss(11)=sqrt(xmqr2)
48537  ELSE
48538  rmss(11)=-sqrt(-xmqr2)
48539  ENDIF
48540 C SAME FOR TAU SLEPTON
48541  ctt=dcos(rmss(28))
48542  ctt2=ctt**2
48543  stt=dsin(rmss(28))
48544  stt2=stt**2
48545  xm12=rmss(13)**2
48546  xm22=rmss(14)**2
48547  xmql2=ctt2*xm12+stt2*xm22
48548  xmqr2=stt2*xm12+ctt2*xm22
48549  xmfr=pmas(15,1)
48550  xmf2=xmfr**2
48551  atau=-xmu*tanb+ctt*stt*(xm12-xm22)/sqrt(xmf2)
48552  rmss(17)=atau
48553 C......SUBTRACT OUT D-TERM AND FERMION MASS
48554  xmql2=xmql2-xmf2+(-.5d0*xmz2+xmw2)*cos2b
48555  xmqr2=xmqr2-xmf2+(xmz2-xmw2)*cos2b
48556  IF(xmql2.GE.0d0) THEN
48557  rmss(13)=sqrt(xmql2)
48558  ELSE
48559  rmss(13)=-sqrt(-xmql2)
48560  ENDIF
48561  IF(xmqr2.GE.0d0) THEN
48562  rmss(14)=sqrt(xmqr2)
48563  ELSE
48564  rmss(14)=-sqrt(-xmqr2)
48565  ENDIF
48566  ENDIF
48567  DO 170 l=1,3
48568  amql=rmss(id1(l))
48569  IF(amql.LT.0d0) THEN
48570  xmql2=-amql**2
48571  ELSE
48572  xmql2=amql**2
48573  ENDIF
48574  atr=rmss(id3(l))
48575  amqr=rmss(id4(l))
48576  IF(amqr.LT.0d0) THEN
48577  xmqr2=-amqr**2
48578  ELSE
48579  xmqr2=amqr**2
48580  ENDIF
48581  if=id2(l)
48582  xmf=pymrun(IF,pmas(6,1)**2)
48583  xmf2=xmf**2
48584  am2(1,1)=xmql2+xmf2
48585  am2(2,2)=xmqr2+xmf2
48586  IF(am2(1,1).EQ.am2(2,2)) am2(2,2)=am2(2,2)*1.00001d0
48587  IF(dterm) THEN
48588  IF(l.EQ.1) THEN
48589  am2(1,1)=am2(1,1)-(2d0*xmw2+xmz2)*cos2b/6d0
48590  am2(2,2)=am2(2,2)+(xmw2-xmz2)*cos2b/3d0
48591  am2(1,2)=xmf*(atr+xmu*tanb)
48592  ELSEIF(l.EQ.2) THEN
48593  am2(1,1)=am2(1,1)+(4d0*xmw2-xmz2)*cos2b/6d0
48594  am2(2,2)=am2(2,2)-(xmw2-xmz2)*cos2b*2d0/3d0
48595  am2(1,2)=xmf*(atr+xmu/tanb)
48596  ELSEIF(l.EQ.3) THEN
48597  IF(imss(8).EQ.1) THEN
48598  am2(1,1)=rmss(6)**2
48599  am2(2,2)=rmss(7)**2
48600  am2(1,2)=0d0
48601  rmss(13)=rmss(6)
48602  rmss(14)=rmss(7)
48603  ELSE
48604  am2(1,1)=am2(1,1)-(-.5d0*xmz2+xmw2)*cos2b
48605  am2(2,2)=am2(2,2)-(xmz2-xmw2)*cos2b
48606  am2(1,2)=xmf*(atr+xmu*tanb)
48607  ENDIF
48608  ENDIF
48609  ENDIF
48610  am2(2,1)=am2(1,2)
48611  detm=am2(1,1)*am2(2,2)-am2(2,1)**2
48612  IF(detm.LT.0d0) THEN
48613  WRITE(mstu(11),*) id2(l),detm,am2
48614  CALL pyerrm(30,' NEGATIVE**2 MASS FOR SFERMION IN PYTHRG ')
48615  ENDIF
48616  same=0.5d0*(am2(1,1)+am2(2,2))
48617  diff=0.5d0*sqrt((am2(1,1)-am2(2,2))**2+4d0*am2(1,2)*am2(2,1))
48618  xmf12=same-diff
48619  xmf22=same+diff
48620  it=0
48621  IF(xmf22-xmf12.GT.0d0) THEN
48622  rt(1,1) = sqrt(max(0d0,(xmf22-am2(1,1))/(xmf22-xmf12)))
48623  rt(2,2) = rt(1,1)
48624  rt(1,2) = -sign(sqrt(max(0d0,1d0-rt(1,1)**2)),
48625  & am2(1,2)/(xmf22-xmf12))
48626  rt(2,1) = -rt(1,2)
48627  ELSE
48628  rt(1,1) = 1d0
48629  rt(2,2) = rt(1,1)
48630  rt(1,2) = 0d0
48631  rt(2,1) = -rt(1,2)
48632  ENDIF
48633  100 CONTINUE
48634  it=it+1
48635 
48636  DO 140 i=1,2
48637  DO 130 jj=1,2
48638  di(i,jj)=0d0
48639  DO 120 ii=1,2
48640  DO 110 j=1,2
48641  di(i,jj)=di(i,jj)+rt(i,j)*am2(j,ii)*rt(jj,ii)
48642  110 CONTINUE
48643  120 CONTINUE
48644  130 CONTINUE
48645  140 CONTINUE
48646 
48647  IF(di(1,1).GT.di(2,2)) THEN
48648  WRITE(mstu(11),*) ' ERROR IN DIAGONALIZATION '
48649  WRITE(mstu(11),*) l,sqrt(xmf12),sqrt(xmf22)
48650  WRITE(mstu(11),*) am2
48651  WRITE(mstu(11),*) di
48652  WRITE(mstu(11),*) rt
48653  di(1,1)=-rt(2,1)
48654  di(2,2)=rt(1,2)
48655  di(1,2)=-rt(2,2)
48656  di(2,1)=rt(1,1)
48657  DO 160 i=1,2
48658  DO 150 j=1,2
48659  rt(i,j)=di(i,j)
48660  150 CONTINUE
48661  160 CONTINUE
48662  goto 100
48663  ELSEIF(abs(di(1,2)*di(2,1)/di(1,1)/di(2,2)).GT.small) THEN
48664  WRITE(mstu(11),*) ' ERROR IN DIAGONALIZATION,'//
48665  & ' OFF DIAGONAL ELEMENTS '
48666  WRITE(mstu(11),*) 'MASSES = ',l,sqrt(xmf12),sqrt(xmf22)
48667  WRITE(mstu(11),*) di
48668  WRITE(mstu(11),*) ' ROTATION = ',rt
48669 C...STOP
48670  ELSEIF(di(1,1).LT.0d0.OR.di(2,2).LT.0d0) THEN
48671  WRITE(mstu(11),*) ' ERROR IN DIAGONALIZATION,'//
48672  & ' NEGATIVE MASSES '
48673  CALL pystop(111)
48674  ENDIF
48675  pmas(pycomp(ksusy1+if),1)=sqrt(xmf12)
48676  pmas(pycomp(ksusy2+if),1)=sqrt(xmf22)
48677  sfmix(IF,1)=rt(1,1)
48678  sfmix(IF,2)=rt(1,2)
48679  sfmix(IF,3)=rt(2,1)
48680  sfmix(IF,4)=rt(2,2)
48681  170 CONTINUE
48682 
48683 C.....TAU SNEUTRINO MASS...L=3
48684 
48685  xarg=am2(1,1)+xmw2*cos2b
48686  IF(xarg.LT.0d0) THEN
48687  WRITE(mstu(11),*) ' PYTHRG:: TAU SNEUTRINO MASS IS NEGATIVE'//
48688  & ' FROM THE SUM RULE. '
48689  WRITE(mstu(11),*) ' TRY A SMALLER VALUE OF TAN(BETA). '
48690  RETURN
48691  ELSE
48692  pmas(pycomp(ksusy1+16),1)=sqrt(xarg)
48693  ENDIF
48694 
48695  RETURN
48696  END
48697 C*********************************************************************
48698 
48699 C...PYINOM
48700 C...Finds the mass eigenstates and mixing matrices for neutralinos
48701 C...and charginos.
48702 
48703  SUBROUTINE pyinom
48704 
48705 C...Double precision and integer declarations.
48706  IMPLICIT DOUBLE PRECISION(a-h, o-z)
48707  IMPLICIT INTEGER(i-n)
48708  INTEGER pycomp
48709 C...Parameter statement to help give large particle numbers.
48710  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
48711  &kexcit=4000000,kdimen=5000000)
48712 C...Commonblocks.
48713  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
48714  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
48715  common/pymssm/imss(0:99),rmss(0:99)
48716  common/pyssmt/zmix(4,4),umix(2,2),vmix(2,2),smz(4),smw(2),
48717  &sfmix(16,4),zmixi(4,4),umixi(2,2),vmixi(2,2)
48718  SAVE /pydat1/,/pydat2/,/pymssm/,/pyssmt/
48719 
48720 C...Local variables.
48721  DOUBLE PRECISION xmw,xmz,xm(4)
48722  DOUBLE PRECISION ar(5,5),wr(5),zr(5,5),zi(5,5),ai(5,5)
48723  DOUBLE PRECISION wi(5),fv1(5),fv2(5),fv3(5)
48724  DOUBLE PRECISION cosw,sinw
48725  DOUBLE PRECISION xmu
48726  DOUBLE PRECISION tanb,cosb,sinb
48727  DOUBLE PRECISION xm1,xm2,xm3,beta
48728  DOUBLE PRECISION q2,aem,a1,a2,aq,rm1,rm2
48729  DOUBLE PRECISION arg,x0,x1,ax0,ax1,at,bt
48730  DOUBLE PRECISION y0,y1,amgx0,am1x0,amgx1,am1x1
48731  DOUBLE PRECISION argx0,ar1x0,argx1,ar1x1
48732  DOUBLE PRECISION pyalps,pyalem
48733  DOUBLE PRECISION pyrnm3
48734  COMPLEX*16 car(4,4),cai(4,4),ca1,ca2
48735  INTEGER ierr,index(4),i,j,k,iopt,ilr,kfnchi(4)
48736  DATA kfnchi/1000022,1000023,1000025,1000035/
48737 
48738  iopt=imss(2)
48739  IF(imss(1).EQ.2) THEN
48740  iopt=1
48741  ENDIF
48742 C...M1, M2, AND M3 ARE INDEPENDENT
48743  IF(iopt.EQ.0) THEN
48744  xm1=rmss(1)
48745  xm2=rmss(2)
48746  xm3=rmss(3)
48747  ELSEIF(iopt.GE.1) THEN
48748  q2=pmas(23,1)**2
48749  aem=pyalem(q2)
48750  a2=aem/paru(102)
48751  a1=aem/(1d0-paru(102))
48752  xm1=rmss(1)
48753  xm2=rmss(2)
48754  IF(imss(1).EQ.2) xm1=rmss(1)/rmss(20)*a1*5d0/3d0
48755  IF(iopt.EQ.1) THEN
48756  xm2=xm1*a2/a1*3d0/5d0
48757  rmss(2)=xm2
48758  ELSEIF(iopt.EQ.3) THEN
48759  xm1=xm2*5d0/3d0*a1/a2
48760  rmss(1)=xm1
48761  ENDIF
48762  xm3=pyrnm3(xm2/a2)
48763  rmss(3)=xm3
48764  IF(xm3.LE.0d0) THEN
48765  WRITE(mstu(11),*) ' ERROR WITH M3 = ',xm3
48766  CALL pystop(105)
48767  ENDIF
48768  ENDIF
48769 
48770 C...GLUINO MASS
48771  IF(imss(3).EQ.1) THEN
48772  pmas(pycomp(ksusy1+21),1)=abs(xm3)
48773  ELSE
48774  aq=0d0
48775  DO 110 i=1,4
48776  DO 100 ilr=1,2
48777  rm1=pmas(pycomp(ilr*ksusy1+i),1)**2/xm3**2
48778  aq=aq+0.5d0*((2d0-rm1)*(rm1*log(rm1)-1d0)
48779  & +(1d0-rm1)**2*log(abs(1d0-rm1)))
48780  100 CONTINUE
48781  110 CONTINUE
48782 
48783  DO 130 i=5,6
48784  DO 120 ilr=1,2
48785  rm1=pmas(pycomp(ilr*ksusy1+i),1)**2/xm3**2
48786  rm2=pmas(i,1)**2/xm3**2
48787  arg=(rm1-rm2-1d0)**2-4d0*rm2**2
48788  IF(arg.GE.0d0) THEN
48789  x0=0.5d0*(1d0+rm2-rm1-sqrt(arg))
48790  ax0=abs(x0)
48791  x1=0.5d0*(1d0+rm2-rm1+sqrt(arg))
48792  ax1=abs(x1)
48793  IF(x0.EQ.1d0) THEN
48794  at=-1d0
48795  bt=0.25d0
48796  ELSEIF(x0.EQ.0d0) THEN
48797  at=0d0
48798  bt=-0.25d0
48799  ELSE
48800  at=0.5d0*log(abs(1d0-x0))*(1d0-x0**2)+
48801  & 0.5d0*x0**2*log(ax0)
48802  bt=(-1d0-2d0*x0)/4d0
48803  ENDIF
48804  IF(x1.EQ.1d0) THEN
48805  at=-1d0+at
48806  bt=0.25d0+bt
48807  ELSEIF(x1.EQ.0d0) THEN
48808  at=0d0+at
48809  bt=-0.25d0+bt
48810  ELSE
48811  at=0.5d0*log(abs(1d0-x1))*(1d0-x1**2)+0.5d0*
48812  & x1**2*log(ax1)+at
48813  bt=(-1d0-2d0*x1)/4d0+bt
48814  ENDIF
48815  aq=aq+at+bt
48816  ELSE
48817  x0=0.5d0*(1d0+rm2-rm1)
48818  y0=-0.5d0*sqrt(-arg)
48819  amgx0=sqrt(x0**2+y0**2)
48820  am1x0=sqrt((1d0-x0)**2+y0**2)
48821  argx0=atan2(-x0,-y0)
48822  ar1x0=atan2(1d0-x0,y0)
48823  x1=x0
48824  y1=-y0
48825  amgx1=amgx0
48826  am1x1=am1x0
48827  argx1=atan2(-x1,-y1)
48828  ar1x1=atan2(1d0-x1,y1)
48829  at=0.5d0*log(am1x0)*(1d0-x0**2+3d0*y0**2)
48830  & +0.5d0*(x0**2-y0**2)*log(amgx0)
48831  bt=(-1d0-2d0*x0)/4d0+x0*y0*( ar1x0-argx0 )
48832  at=at+0.5d0*log(am1x1)*(1d0-x1**2+3d0*y1**2)
48833  & +0.5d0*(x1**2-y1**2)*log(amgx1)
48834  bt=bt+(-1d0-2d0*x1)/4d0+x1*y1*( ar1x1-argx1 )
48835  aq=aq+at+bt
48836  ENDIF
48837  120 CONTINUE
48838  130 CONTINUE
48839  pmas(pycomp(ksusy1+21),1)=abs(xm3)*(1d0+pyalps(xm3**2)
48840  & /(2d0*paru(2))*(15d0+aq))
48841  ENDIF
48842 
48843 C...NEUTRALINO MASSES
48844  DO 150 i=1,4
48845  DO 140 j=1,4
48846  ai(i,j)=0d0
48847  140 CONTINUE
48848  150 CONTINUE
48849  xmz=pmas(23,1)/100d0
48850  xmw=pmas(24,1)/100d0
48851  xmu=rmss(4)/100d0
48852  sinw=sqrt(paru(102))
48853  cosw=sqrt(1d0-paru(102))
48854  tanb=rmss(5)
48855  beta=atan(tanb)
48856  cosb=cos(beta)
48857  sinb=tanb*cosb
48858 
48859  xm2=xm2/100d0
48860  xm1=xm1/100d0
48861 
48862 
48863 C... Definitions:
48864 C... psi^0 =(-i bino^0, -i wino^0, h_d^0(=H_1^0), h_u^0(=H_2^0))
48865 C... => L_neutralino = -1/2*(psi^0)^T * [AR] * psi^0 + h.c.
48866  ar(1,1) = xm1*cos(rmss(30))
48867  ai(1,1) = xm1*sin(rmss(30))
48868  ar(2,2) = xm2*cos(rmss(31))
48869  ai(2,2) = xm2*sin(rmss(31))
48870  ar(3,3) = 0d0
48871  ar(4,4) = 0d0
48872  ar(1,2) = 0d0
48873  ar(2,1) = 0d0
48874  ar(1,3) = -xmz*sinw*cosb
48875  ar(3,1) = ar(1,3)
48876  ar(1,4) = xmz*sinw*sinb
48877  ar(4,1) = ar(1,4)
48878  ar(2,3) = xmz*cosw*cosb
48879  ar(3,2) = ar(2,3)
48880  ar(2,4) = -xmz*cosw*sinb
48881  ar(4,2) = ar(2,4)
48882  ar(3,4) = -xmu*cos(rmss(33))
48883  ai(3,4) = -xmu*sin(rmss(33))
48884  ar(4,3) = -xmu*cos(rmss(33))
48885  ai(4,3) = -xmu*sin(rmss(33))
48886 C CALL PYEIG4(AR,WR,ZR)
48887  CALL pyeicg(5,4,ar,ai,wr,wi,1,zr,zi,fv1,fv2,fv3,ierr)
48888  IF(ierr.NE.0) CALL pyerrm(18,'(PYINOM:) '//
48889  & 'PROBLEM WITH PYEICG IN PYINOM ')
48890  DO 160 i=1,4
48891  index(i)=i
48892  xm(i)=abs(wr(i))
48893  160 CONTINUE
48894  DO 180 i=2,4
48895  k=i
48896  DO 170 j=i-1,1,-1
48897  IF(xm(k).LT.xm(j)) THEN
48898  itmp=index(j)
48899  xtmp=xm(j)
48900  index(j)=index(k)
48901  xm(j)=xm(k)
48902  index(k)=itmp
48903  xm(k)=xtmp
48904  k=k-1
48905  ELSE
48906  goto 180
48907  ENDIF
48908  170 CONTINUE
48909  180 CONTINUE
48910 
48911 
48912  DO 210 i=1,4
48913  k=index(i)
48914  smz(i)=wr(k)*100d0
48915  pmas(pycomp(kfnchi(i)),1)=abs(smz(i))
48916  s=0d0
48917  DO 190 j=1,4
48918  s=s+zr(j,k)**2+zi(j,k)**2
48919  190 CONTINUE
48920  DO 200 j=1,4
48921  zmix(i,j)=zr(j,k)/sqrt(s)
48922  zmixi(i,j)=zi(j,k)/sqrt(s)
48923  IF(abs(zmix(i,j)).LT.1d-6) zmix(i,j)=0d0
48924  IF(abs(zmixi(i,j)).LT.1d-6) zmixi(i,j)=0d0
48925  200 CONTINUE
48926  210 CONTINUE
48927 
48928 C...CHARGINO MASSES
48929 C.....Find eigenvectors of X X^*
48930  DO i=1,4
48931  DO j=1,4
48932  ar(i,j)=0d0
48933  ai(i,j)=0d0
48934  ENDDO
48935  ENDDO
48936  ai(1,1) = 0d0
48937  ai(2,2) = 0d0
48938  ar(1,1) = xm2**2+2d0*xmw**2*sinb**2
48939  ar(2,2) = xmu**2+2d0*xmw**2*cosb**2
48940  ar(1,2) = sqrt(2d0)*xmw*(xm2*cos(rmss(31))*cosb+
48941  &xmu*cos(rmss(33))*sinb)
48942  ai(1,2) = sqrt(2d0)*xmw*(xm2*sin(rmss(31))*cosb-
48943  &xmu*sin(rmss(33))*sinb)
48944  ar(2,1) = sqrt(2d0)*xmw*(xm2*cos(rmss(31))*cosb+
48945  &xmu*cos(rmss(33))*sinb)
48946  ai(2,1) = sqrt(2d0)*xmw*(-xm2*sin(rmss(31))*cosb+
48947  &xmu*sin(rmss(33))*sinb)
48948  CALL pyeicg(5,2,ar,ai,wr,wi,1,zr,zi,fv1,fv2,fv3,ierr)
48949  IF(ierr.NE.0) CALL pyerrm(18,'(PYINOM:) '//
48950  & 'PROBLEM WITH PYEICG IN PYINOM ')
48951  index(1)=1
48952  index(2)=2
48953  IF(wr(2).LT.wr(1)) THEN
48954  index(1)=2
48955  index(2)=1
48956  ENDIF
48957 
48958 
48959  DO 240 i=1,2
48960  k=index(i)
48961  smw(i)=sqrt(wr(k))*100d0
48962  s=0d0
48963  DO 220 j=1,2
48964  s=s+zr(j,k)**2+zi(j,k)**2
48965  220 CONTINUE
48966  DO 230 j=1,2
48967  umix(i,j)=zr(j,k)/sqrt(s)
48968  umixi(i,j)=-zi(j,k)/sqrt(s)
48969  IF(abs(umix(i,j)).LT.1d-6) umix(i,j)=0d0
48970  IF(abs(umixi(i,j)).LT.1d-6) umixi(i,j)=0d0
48971  230 CONTINUE
48972  240 CONTINUE
48973 C...Force chargino mass > neutralino mass
48974  ifrc=0
48975  IF(abs(smw(1)).LT.abs(smz(1))+2d0*pmas(pycomp(111),1)) THEN
48976  CALL pyerrm(8,'(PYINOM:) '//
48977  & 'forcing m(~chi+_1) > m(~chi0_1) + 2m(pi0)')
48978  smw(1)=sign(abs(smz(1))+2d0*pmas(pycomp(111),1),smw(1))
48979  ifrc=1
48980  ENDIF
48981  pmas(pycomp(ksusy1+24),1)=smw(1)
48982  pmas(pycomp(ksusy1+37),1)=smw(2)
48983 
48984 C.....Find eigenvectors of X^* X
48985  DO i=1,4
48986  DO j=1,4
48987  ar(i,j)=0d0
48988  ai(i,j)=0d0
48989  zr(i,j)=0d0
48990  zi(i,j)=0d0
48991  ENDDO
48992  ENDDO
48993  ai(1,1) = 0d0
48994  ai(2,2) = 0d0
48995  ar(1,1) = xm2**2+2d0*xmw**2*cosb**2
48996  ar(2,2) = xmu**2+2d0*xmw**2*sinb**2
48997  ar(1,2) = sqrt(2d0)*xmw*(xm2*cos(rmss(31))*sinb+
48998  &xmu*cos(rmss(33))*cosb)
48999  ai(1,2) = sqrt(2d0)*xmw*(-xm2*sin(rmss(31))*sinb+
49000  &xmu*sin(rmss(33))*cosb)
49001  ar(2,1) = sqrt(2d0)*xmw*(xm2*cos(rmss(31))*sinb+
49002  &xmu*cos(rmss(33))*cosb)
49003  ai(2,1) = sqrt(2d0)*xmw*(xm2*sin(rmss(31))*sinb-
49004  &xmu*sin(rmss(33))*cosb)
49005  CALL pyeicg(5,2,ar,ai,wr,wi,1,zr,zi,fv1,fv2,fv3,ierr)
49006  IF(ierr.NE.0) CALL pyerrm(18,'(PYINOM:) '//
49007  & 'PROBLEM WITH PYEICG IN PYINOM ')
49008  index(1)=1
49009  index(2)=2
49010  IF(wr(2).LT.wr(1)) THEN
49011  index(1)=2
49012  index(2)=1
49013  ENDIF
49014 
49015  simag=0d0
49016  DO 270 i=1,2
49017  k=index(i)
49018  s=0d0
49019  DO 250 j=1,2
49020  s=s+zr(j,k)**2+zi(j,k)**2
49021  simag=simag+zi(j,k)**2
49022  250 CONTINUE
49023  DO 260 j=1,2
49024  vmix(i,j)=zr(j,k)/sqrt(s)
49025  vmixi(i,j)=-zi(j,k)/sqrt(s)
49026  IF(abs(vmix(i,j)).LT.1d-6) vmix(i,j)=0d0
49027  IF(abs(vmixi(i,j)).LT.1d-6) vmixi(i,j)=0d0
49028  260 CONTINUE
49029  270 CONTINUE
49030 
49031 C.....Simplify if no phases
49032  IF(simag.LT.1d-6) THEN
49033  ar(1,1) = xm2*cos(rmss(31))
49034  ar(2,2) = xmu*cos(rmss(33))
49035  ar(1,2) = sqrt(2d0)*xmw*sinb
49036  ar(2,1) = sqrt(2d0)*xmw*cosb
49037  iknt=0
49038  300 CONTINUE
49039  DO i=1,2
49040  DO j=1,2
49041  zr(i,j)=0d0
49042  ENDDO
49043  ENDDO
49044 
49045  DO i=1,2
49046  DO j=1,2
49047  DO k=1,2
49048  DO l=1,2
49049  zr(i,j)=zr(i,j)+umix(i,k)*ar(k,l)*vmix(j,l)
49050  ENDDO
49051  ENDDO
49052  ENDDO
49053  ENDDO
49054  vmix(1,1)=vmix(1,1)*smw(1)/zr(1,1)/100d0
49055  vmix(1,2)=vmix(1,2)*smw(1)/zr(1,1)/100d0
49056  vmix(2,1)=vmix(2,1)*smw(2)/zr(2,2)/100d0
49057  vmix(2,2)=vmix(2,2)*smw(2)/zr(2,2)/100d0
49058  IF(iknt.EQ.2.AND.ifrc.EQ.0) THEN
49059  CALL pyerrm(18,'(PYINOM:) Problem with Charginos')
49060  ELSEIF(zr(1,1).LT.0d0.OR.zr(2,2).LT.0d0) THEN
49061  iknt=iknt+1
49062  goto 300
49063  ENDIF
49064 C.....Must deal with phases
49065  ELSE
49066  car(1,1) = xm2*cmplx(cos(rmss(31)),sin(rmss(31)))
49067  car(2,2) = xmu*cmplx(cos(rmss(33)),sin(rmss(33)))
49068  car(1,2) = sqrt(2d0)*xmw*sinb*cmplx(1d0,0d0)
49069  car(2,1) = sqrt(2d0)*xmw*cosb*cmplx(1d0,0d0)
49070 
49071  iknt=0
49072  310 CONTINUE
49073  DO i=1,2
49074  DO j=1,2
49075  cai(i,j)=cmplx(0d0,0d0)
49076  ENDDO
49077  ENDDO
49078 
49079  DO i=1,2
49080  DO j=1,2
49081  DO k=1,2
49082  DO l=1,2
49083  cai(i,j)=cai(i,j)+cmplx(umix(i,k),-umixi(i,k))*car(k,l)*
49084  & cmplx(vmix(j,l),vmixi(j,l))
49085  ENDDO
49086  ENDDO
49087  ENDDO
49088  ENDDO
49089 
49090  ca1=smw(1)*cai(1,1)/abs(cai(1,1))**2/100d0
49091  ca2=smw(2)*cai(2,2)/abs(cai(2,2))**2/100d0
49092  tempr=vmix(1,1)
49093  tempi=vmixi(1,1)
49094  vmix(1,1)=tempr*dble(ca1)-tempi*dimag(ca1)
49095  vmixi(1,1)=tempi*dble(ca1)+tempr*dimag(ca1)
49096  tempr=vmix(1,2)
49097  tempi=vmixi(1,2)
49098  vmix(1,2)=tempr*dble(ca1)-tempi*dimag(ca1)
49099  vmixi(1,2)=tempi*dble(ca1)+tempr*dimag(ca1)
49100  tempr=vmix(2,1)
49101  tempi=vmixi(2,1)
49102  vmix(2,1)=tempr*dble(ca2)-tempi*dimag(ca2)
49103  vmixi(2,1)=tempi*dble(ca2)+tempr*dimag(ca2)
49104  tempr=vmix(2,2)
49105  tempi=vmixi(2,2)
49106  vmix(2,2)=tempr*dble(ca2)-tempi*dimag(ca2)
49107  vmixi(2,2)=tempi*dble(ca2)+tempr*dimag(ca2)
49108  IF(iknt.EQ.2.AND.ifrc.EQ.0) THEN
49109  CALL pyerrm(18,'(PYINOM:) Problem with Charginos')
49110  ELSEIF(dble(ca1).LT.0d0.OR.dble(ca2).LT.0d0.OR.
49111  & abs(imag(ca1)).GT.1d-3.OR.abs(imag(ca2)).GT.1d-3) THEN
49112  iknt=iknt+1
49113  goto 310
49114  ENDIF
49115  ENDIF
49116  RETURN
49117  END
49118 
49119 C*********************************************************************
49120 
49121 C...PYRNM3
49122 C...Calculates the running of M3, the SU(3) gluino mass parameter.
49123 
49124  FUNCTION pyrnm3(RGUT)
49125 
49126 C...Double precision and integer declarations.
49127  IMPLICIT DOUBLE PRECISION(a-h, o-z)
49128  IMPLICIT INTEGER(i-n)
49129  INTEGER pyk,pychge,pycomp
49130 
49131 C...Local variables.
49132  DOUBLE PRECISION r
49133  DOUBLE PRECISION tol
49134  EXTERNAL pyalps
49135  DOUBLE PRECISION pyalps
49136  DATA tol/0.001d0/
49137  DATA r/0.61803399d0/
49138 
49139  c=1d0-r
49140 
49141  bx=rgut*pyalps(rgut**2)
49142  ax=min(50d0,bx*0.5d0)
49143  cx=max(2000d0,2d0*bx)
49144 
49145  x0=ax
49146  x3=cx
49147  IF(abs(cx-bx).GT.abs(bx-ax))THEN
49148  x1=bx
49149  x2=bx+c*(cx-bx)
49150  ELSE
49151  x2=bx
49152  x1=bx-c*(bx-ax)
49153  ENDIF
49154  as1=pyalps(x1**2)
49155  f1=abs(x1-rgut*as1)
49156  as2=pyalps(x2**2)
49157  f2=abs(x2-rgut*as2)
49158  100 IF(abs(x3-x0).GT.tol*(abs(x1)+abs(x2))) THEN
49159  IF(f2.LT.f1) THEN
49160  x0=x1
49161  x1=x2
49162  x2=r*x1+c*x3
49163  f1=f2
49164  as2=pyalps(x2**2)
49165  f2=abs(x2-rgut*as2)
49166  ELSE
49167  x3=x2
49168  x2=x1
49169  x1=r*x2+c*x0
49170  f2=f1
49171  as1=pyalps(x1**2)
49172  f1=abs(x1-rgut*as1)
49173  ENDIF
49174  goto 100
49175  ENDIF
49176  IF(f1.LT.f2) THEN
49177  pyrnm3=x1
49178  xmin=x1
49179  ELSE
49180  pyrnm3=x2
49181  xmin=x2
49182  ENDIF
49183 
49184  RETURN
49185  END
49186 
49187 C*********************************************************************
49188 
49189 C...PYEIG4
49190 C...Finds eigenvalues and eigenvectors to a 4 * 4 matrix.
49191 C...Specific application: mixing in neutralino sector.
49192 
49193  SUBROUTINE pyeig4(A,W,Z)
49194 
49195 C...Double precision and integer declarations.
49196  IMPLICIT DOUBLE PRECISION(a-h, o-z)
49197  IMPLICIT INTEGER(i-n)
49198  INTEGER pyk,pychge,pycomp
49199 
49200 C...Arrays: in call and local.
49201  dimension a(4,4),w(4),z(4,4),x(4),d(4,4),e(4)
49202 
49203 C...Coefficients of fourth-degree equation from matrix.
49204 C...x**4 + b3 * x**3 + b2 * x**2 + b1 * x + b0 = 0.
49205  b3=-(a(1,1)+a(2,2)+a(3,3)+a(4,4))
49206  b2=0d0
49207  DO 110 i=1,3
49208  DO 100 j=i+1,4
49209  b2=b2+a(i,i)*a(j,j)-a(i,j)*a(j,i)
49210  100 CONTINUE
49211  110 CONTINUE
49212  b1=0d0
49213  b0=0d0
49214  DO 120 i=1,4
49215  i1=mod(i,4)+1
49216  i2=mod(i+1,4)+1
49217  i3=mod(i+2,4)+1
49218  b1=b1+a(i,i)*(-a(i1,i1)*a(i2,i2)+a(i1,i2)*a(i2,i1)+
49219  & a(i1,i3)*a(i3,i1)+a(i2,i3)*a(i3,i2))-
49220  & a(i,i1)*a(i1,i2)*a(i2,i)-a(i,i2)*a(i2,i1)*a(i1,i)
49221  b0=b0+(-1d0)**(i+1)*a(1,i)*(
49222  & a(2,i1)*(a(3,i2)*a(4,i3)-a(3,i3)*a(4,i2))+
49223  & a(2,i2)*(a(3,i3)*a(4,i1)-a(3,i1)*a(4,i3))+
49224  & a(2,i3)*(a(3,i1)*a(4,i2)-a(3,i2)*a(4,i1)))
49225  120 CONTINUE
49226 
49227 C...Coefficients of third-degree equation needed for
49228 C...separation into two second-degree equations.
49229 C...u**3 + c2 * u**2 + c1 * u + c0 = 0.
49230  c2=-b2
49231  c1=b1*b3-4d0*b0
49232  c0=-b1**2-b0*b3**2+4d0*b0*b2
49233  cq=c1/3d0-c2**2/9d0
49234  cr=c1*c2/6d0-c0/2d0-c2**3/27d0
49235  cqr=cq**3+cr**2
49236 
49237 C...Cases with one or three real roots.
49238  IF(cqr.GE.0d0) THEN
49239  s1=(cr+sqrt(cqr))**(1d0/3d0)
49240  s2=(cr-sqrt(cqr))**(1d0/3d0)
49241  u=s1+s2-c2/3d0
49242  ELSE
49243  sabs=sqrt(-cq)
49244  the=acos(cr/sabs**3)/3d0
49245  sre=sabs*cos(the)
49246  u=2d0*sre-c2/3d0
49247  ENDIF
49248 
49249 C...Find and solve two second-degree equations.
49250  p1=b3/2d0-sqrt(b3**2/4d0+u-b2)
49251  p2=b3/2d0+sqrt(b3**2/4d0+u-b2)
49252  q1=u/2d0+sqrt(u**2/4d0-b0)
49253  q2=u/2d0-sqrt(u**2/4d0-b0)
49254  IF(abs(p1*q1+p2*q2-b1).LT.abs(p1*q2+p2*q1-b1)) THEN
49255  qsav=q1
49256  q1=q2
49257  q2=qsav
49258  ENDIF
49259  x(1)=-p1/2d0+sqrt(p1**2/4d0-q1)
49260  x(2)=-p1/2d0-sqrt(p1**2/4d0-q1)
49261  x(3)=-p2/2d0+sqrt(p2**2/4d0-q2)
49262  x(4)=-p2/2d0-sqrt(p2**2/4d0-q2)
49263 
49264 C...Order eigenvalues in asceding mass.
49265  w(1)=x(1)
49266  DO 150 i1=2,4
49267  DO 130 i2=i1-1,1,-1
49268  IF(abs(x(i1)).GE.abs(w(i2))) goto 140
49269  w(i2+1)=w(i2)
49270  130 CONTINUE
49271  140 w(i2+1)=x(i1)
49272  150 CONTINUE
49273 
49274 C...Find equation system for eigenvectors.
49275  DO 250 i=1,4
49276  DO 170 j1=1,4
49277  d(j1,j1)=a(j1,j1)-w(i)
49278  DO 160 j2=j1+1,4
49279  d(j1,j2)=a(j1,j2)
49280  d(j2,j1)=a(j2,j1)
49281  160 CONTINUE
49282  170 CONTINUE
49283 
49284 C...Find largest element in matrix.
49285  damax=0d0
49286  DO 190 j1=1,4
49287  DO 180 j2=1,4
49288  IF(abs(d(j1,j2)).LE.damax) goto 180
49289  ja=j1
49290  jb=j2
49291  damax=abs(d(j1,j2))
49292  180 CONTINUE
49293  190 CONTINUE
49294 
49295 C...Subtract others by multiple of row selected above.
49296  damax=0d0
49297  DO 210 j3=ja+1,ja+3
49298  j1=j3-4*((j3-1)/4)
49299  rl=d(j1,jb)/d(ja,jb)
49300  DO 200 j2=1,4
49301  d(j1,j2)=d(j1,j2)-rl*d(ja,j2)
49302  IF(abs(d(j1,j2)).LE.damax) goto 200
49303  jc=j1
49304  jd=j2
49305  damax=abs(d(j1,j2))
49306  200 CONTINUE
49307  210 CONTINUE
49308 
49309 C...Do one more subtraction of a row.
49310  damax=0d0
49311  DO 230 j3=jc+1,jc+3
49312  j1=j3-4*((j3-1)/4)
49313  IF(j1.EQ.ja) goto 230
49314  rl=d(j1,jd)/d(jc,jd)
49315  DO 220 j2=1,4
49316  IF(j2.EQ.jb) goto 220
49317  d(j1,j2)=d(j1,j2)-rl*d(jc,j2)
49318  IF(abs(d(j1,j2)).LE.damax) goto 220
49319  je=j1
49320  damax=abs(d(j1,j2))
49321  220 CONTINUE
49322  230 CONTINUE
49323 
49324 C...Construct unnormalized eigenvector.
49325  jf1=jd+1-4*(jd/4)
49326  jf2=jd+2-4*((jd+1)/4)
49327  IF(jf1.EQ.jb) jf1=jd+3-4*((jd+2)/4)
49328  IF(jf2.EQ.jb) jf2=jd+3-4*((jd+2)/4)
49329  e(jf1)=-d(je,jf2)
49330  e(jf2)=d(je,jf1)
49331  e(jd)=-(d(jc,jf1)*e(jf1)+d(jc,jf2)*e(jf2))/d(jc,jd)
49332  e(jb)=-(d(ja,jf1)*e(jf1)+d(ja,jf2)*e(jf2)+d(ja,jd)*e(jd))/
49333  & d(ja,jb)
49334 
49335 C...Normalize and fill in final array.
49336  ea=sqrt(e(1)**2+e(2)**2+e(3)**2+e(4)**2)
49337  sgn=(-1d0)**int(pyr(0)+0.5d0)
49338  DO 240 j=1,4
49339  z(i,j)=sgn*e(j)/ea
49340  240 CONTINUE
49341  250 CONTINUE
49342 
49343  RETURN
49344  END
49345 
49346 C*********************************************************************
49347 
49348 C...PYHGGM
49349 C...Determines the Higgs boson mass spectrum using several inputs.
49350 
49351  SUBROUTINE pyhggm(ALPHA)
49352 
49353 C...Double precision and integer declarations.
49354  IMPLICIT DOUBLE PRECISION(a-h, o-z)
49355  IMPLICIT INTEGER(i-n)
49356  INTEGER pyk,pychge,pycomp
49357 C...Parameter statement to help give large particle numbers.
49358  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
49359  &kexcit=4000000,kdimen=5000000)
49360 C...Commonblocks.
49361  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
49362  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
49363  common/pypars/mstp(200),parp(200),msti(200),pari(200)
49364  common/pymssm/imss(0:99),rmss(0:99)
49365  SAVE /pydat1/,/pydat2/,/pypars/,/pymssm/
49366 
49367 C...Local variables.
49368  DOUBLE PRECISION at,ab,xmu,tanb
49369  DOUBLE PRECISION alpha
49370  INTEGER ihopt
49371  DOUBLE PRECISION dma,dtanb,dmq,dmur,dmtop,dau,dad
49372  DOUBLE PRECISION dmu,dmh,dhm,dmhch,dsa,dca,dtanba
49373  DOUBLE PRECISION dmc,dmdr,dmhp,dhmp,damp
49374  DOUBLE PRECISION dstop1,dstop2,dsbot1,dsbot2
49375 
49376  ihopt=imss(4)
49377  IF(ihopt.EQ.2) THEN
49378  alpha=rmss(18)
49379  RETURN
49380  ENDIF
49381  at=rmss(16)
49382  ab=rmss(15)
49383  dmgl=rmss(3)
49384  xmu=rmss(4)
49385  tanb=rmss(5)
49386 
49387  dma=rmss(19)
49388  dtanb=tanb
49389  dmq=rmss(10)
49390  dmur=rmss(12)
49391  dmdr=rmss(11)
49392  dmtop=pmas(6,1)
49393  dmc=pmas(pycomp(ksusy1+37),1)
49394  dau=at
49395  dad=ab
49396  dmu=xmu
49397  rmss(40)=0d0
49398  rmss(41)=0d0
49399 
49400  IF(ihopt.EQ.0) THEN
49401  CALL pysubh(dma,dtanb,dmq,dmur,dmtop,dau,dad,dmu,dmh,dhm,
49402  & dmhch,dsa,dca,dtanba)
49403  ELSEIF(ihopt.EQ.1) THEN
49404  CALL pysubh(dma,dtanb,dmq,dmur,dmtop,dau,dad,dmu,dmh,dhm,
49405  & dmhch,dsa,dca,dtanba)
49406  CALL pypole(3,dmc,dma,dtanb,dmq,dmur,dmdr,dmtop,dau,dad,dmu,
49407  & dmh,dmhp,dhm,dhmp,damp,dsa,dca,
49408  & dstop1,dstop2,dsbot1,dsbot2,dtanba,dmgl,ddt,ddb)
49409  rmss(40)=ddt
49410  rmss(41)=ddb
49411  dmh=dmhp
49412  dhm=dhmp
49413  dma=damp
49414  IF(abs(pmas(pycomp(1000006),1)-dstop2).GT.5d-1) THEN
49415  WRITE(mstu(11),*) ' STOP1 MASS DOES NOT MATCH IN PYHGGM '
49416  WRITE(mstu(11),*) ' STOP1 MASSES = ',
49417  & pmas(pycomp(1000006),1),dstop2
49418  ENDIF
49419  IF(abs(pmas(pycomp(2000006),1)-dstop1).GT.5d-1) THEN
49420  WRITE(mstu(11),*) ' STOP2 MASS DOES NOT MATCH IN PYHGGM '
49421  WRITE(mstu(11),*) ' STOP2 MASSES = ',
49422  & pmas(pycomp(2000006),1),dstop1
49423  ENDIF
49424  IF(abs(pmas(pycomp(1000005),1)-dsbot2).GT.5d-1) THEN
49425  WRITE(mstu(11),*) ' SBOT1 MASS DOES NOT MATCH IN PYHGGM '
49426  WRITE(mstu(11),*) ' SBOT1 MASSES = ',
49427  & pmas(pycomp(1000005),1),dsbot2
49428  ENDIF
49429  IF(abs(pmas(pycomp(2000005),1)-dsbot1).GT.5d-1) THEN
49430  WRITE(mstu(11),*) ' SBOT2 MASS DOES NOT MATCH IN PYHGGM '
49431  WRITE(mstu(11),*) ' SBOT2 MASSES = ',
49432  & pmas(pycomp(2000005),1),dsbot1
49433  ENDIF
49434 
49435  ELSEIF (ihopt.EQ.3) THEN
49436 c...Use FeynHiggs to fix Higgs sector (cf feynhiggs.de)
49437 C...Currently only available for SLHA spectrum read-in.
49438  IF (imss(1).NE.11.AND.imss(1).NE.12.AND.imss(1).NE.13) THEN
49439  CALL pyerrm(11,'(PYHGGM:) FeynHiggs needs SLHA or ISASUSY'
49440  & //' spectrum, change IMSS(1) or IMSS(4) option.')
49441  ENDIF
49442  alpha=rmss(18)
49443  RETURN
49444  ENDIF
49445 
49446  alpha=acos(dca)
49447 
49448  pmas(25,1)=dmh
49449  pmas(35,1)=dhm
49450  pmas(36,1)=dma
49451  pmas(37,1)=dmhch
49452 
49453  RETURN
49454  END
49455 
49456 C*********************************************************************
49457 
49458 C...PYSUBH
49459 C...This routine computes the renormalization group improved
49460 C...values of Higgs masses and couplings in the MSSM.
49461 
49462 C...Program based on the work by M. Carena, J.R. Espinosa,
49463 c...M. Quiros and C.E.M. Wagner, CERN-preprint CERN-TH/95-45
49464 
49465 C...Input: MA,TANB = TAN(BETA),MQ,MUR,MTOP,AU,AD,MU
49466 C...All masses in GeV units. MA is the CP-odd Higgs mass,
49467 C...MTOP is the physical top mass, MQ and MUR are the soft
49468 C...supersymmetry breaking mass parameters of left handed
49469 C...and right handed stops respectively, AU and AD are the
49470 C...stop and sbottom trilinear soft breaking terms,
49471 C...respectively, and MU is the supersymmetric
49472 C...Higgs mass parameter. We use the conventions from
49473 C...the physics report of Haber and Kane: left right
49474 C...stop mixing term proportional to (AU - MU/TANB)
49475 C...We use as input TANB defined at the scale MTOP
49476 
49477 C...Output: MH,HM,MHCH, SA = SIN(ALPHA), CA= COS(ALPHA), TANBA
49478 C...where MH and HM are the lightest and heaviest CP-even
49479 C...Higgs masses, MHCH is the charged Higgs mass and
49480 C...ALPHA is the Higgs mixing angle
49481 C...TANBA is the angle TANB at the CP-odd Higgs mass scale
49482 
49483 C...Range of validity:
49484 C...(STOP1**2 - STOP2**2)/(STOP2**2 + STOP1**2) < 0.5
49485 C...(SBOT1**2 - SBOT2**2)/(SBOT2**2 + SBOT2**2) < 0.5
49486 C...where STOP1, STOP2, SBOT1 and SBOT2 are the stop and
49487 C...are the sbottom mass eigenvalues, respectively. This
49488 C...range automatically excludes the existence of tachyons.
49489 C...For the charged Higgs mass computation, the method is
49490 C...valid if
49491 C...2 * |MB * AD* TANB| < M_SUSY**2, 2 * |MTOP * AU| < M_SUSY**2
49492 C...2 * |MB * MU * TANB| < M_SUSY**2, 2 * |MTOP * MU| < M_SUSY**2
49493 C...where M_SUSY**2 is the average of the squared stop mass
49494 C...eigenvalues, M_SUSY**2 = (STOP1**2 + STOP2**2)/2. The sbottom
49495 C...masses have been assumed to be of order of the stop ones
49496 C...M_SUSY**2 = (MQ**2 + MUR**2)*0.5 + MTOP**2
49497 
49498  SUBROUTINE pysubh (XMA,TANB,XMQ,XMUR,XMTOP,AU,AD,XMU,XMH,XHM,
49499  &xmhch,sa,ca,tanba)
49500 
49501 C...Double precision and integer declarations.
49502  IMPLICIT DOUBLE PRECISION(a-h, o-z)
49503  IMPLICIT INTEGER(i-n)
49504  INTEGER pyk,pychge,pycomp
49505 C...Parameter statement to help give large particle numbers.
49506  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
49507  &kexcit=4000000,kdimen=5000000)
49508 C...Commonblocks.
49509  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
49510  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
49511  common/pyhtri/hhh(7)
49512  SAVE /pydat1/,/pydat2/
49513 
49514 C...Local variables.
49515  DOUBLE PRECISION pyalem,pyalps
49516  DOUBLE PRECISION tanb,xmq,xmur,xmtop,au,ad,xmu,xmh,xhm
49517  DOUBLE PRECISION xmhch,sa,ca
49518  DOUBLE PRECISION xma,aem,alp1,alp2,alph3z,v,pi
49519  DOUBLE PRECISION q02
49520  DOUBLE PRECISION tanba,tanbt,xmb,alp3
49521  DOUBLE PRECISION rmtop,xms,t,sinb,cosb
49522  DOUBLE PRECISION xlam1,xlam2,xlam3,xlam4,xlam5,xlam6
49523  DOUBLE PRECISION xlam7,xau,xad,g1,g2,g3,hu,hd,hu2
49524  DOUBLE PRECISION hd2,hu4,hd4,sinbt,cosbt
49525  DOUBLE PRECISION trm2,detm2,xmh2,xhm2,xmhch2
49526  DOUBLE PRECISION sinalp,cosalp,aud,pi2,xms2,xms4,ad2
49527  DOUBLE PRECISION au2,xmu2,xmz,xms3
49528 
49529  xmz = pmas(23,1)
49530  q02=xmz**2
49531  aem=pyalem(q02)
49532  alp1=aem/(1d0-paru(102))
49533  alp2=aem/paru(102)
49534  alph3z=pyalps(q02)
49535 
49536  alp1 = 0.0101d0
49537  alp2 = 0.0337d0
49538  alph3z = 0.12d0
49539 
49540  v = 174.1d0
49541  pi = paru(1)
49542  tanba = tanb
49543  tanbt = tanb
49544 
49545 C...MBOTTOM(MTOP) = 3. GEV
49546  xmb = pymrun(5,xmtop**2)
49547  alp3 = alph3z/(1d0 +(11d0 - 10d0/3d0)/4d0/pi*alph3z*
49548  &log(xmtop**2/xmz**2))
49549 
49550 C...RMTOP= RUNNING TOP QUARK MASS
49551  rmtop = xmtop/(1d0+4d0*alp3/3d0/pi)
49552  xms = ((xmq**2 + xmur**2)/2d0 + xmtop**2)**0.5d0
49553  t = log(xms**2/xmtop**2)
49554  sinb = tanb/((1d0 + tanb**2)**0.5d0)
49555  cosb = sinb/tanb
49556 C...IF(MA.LE.XMTOP) TANBA = TANBT
49557  IF(xma.GT.xmtop)
49558  &tanba = tanbt*(1d0-3d0/32d0/pi**2*
49559  &(rmtop**2/v**2/sinb**2-xmb**2/v**2/cosb**2)*
49560  &log(xma**2/xmtop**2))
49561 
49562  sinbt = tanbt/sqrt(1d0 + tanbt**2)
49563  cosbt = 1d0/sqrt(1d0 + tanbt**2)
49564 C COS2BT = (TANBT**2 - 1D0)/(TANBT**2 + 1D0)
49565  g1 = sqrt(alp1*4d0*pi)
49566  g2 = sqrt(alp2*4d0*pi)
49567  g3 = sqrt(alp3*4d0*pi)
49568  hu = rmtop/v/sinbt
49569  hd = xmb/v/cosbt
49570  hu2=hu*hu
49571  hd2=hd*hd
49572  hu4=hu2*hu2
49573  hd4=hd2*hd2
49574  au2=au**2
49575  ad2=ad**2
49576  xms2=xms**2
49577  xms3=xms**3
49578  xms4=xms2*xms2
49579  xmu2=xmu*xmu
49580  pi2=pi*pi
49581 
49582  xau = (2d0*au2/xms2)*(1d0 - au2/12d0/xms2)
49583  xad = (2d0*ad2/xms2)*(1d0 - ad2/12d0/xms2)
49584  aud = (-6d0*xmu2/xms2 - ( xmu2- ad*au)**2/xms4
49585  &+ 3d0*(au + ad)**2/xms2)/6d0
49586  xlam1 = ((g1**2 + g2**2)/4d0)*(1d0-3d0*hd2*t/8d0/pi2)
49587  &+(3d0*hd4/8d0/pi2) * (t + xad/2d0 + (3d0*hd2/2d0 + hu2/2d0
49588  &- 8d0*g3**2) * (xad*t + t**2)/16d0/pi2)
49589  &-(3d0*hu4* xmu**4/96d0/pi2/xms4) * (1+ (9d0*hu2 -5d0* hd2
49590  &- 16d0*g3**2) *t/16d0/pi2)
49591  xlam2 = ((g1**2 + g2**2)/4d0)*(1d0-3d0*hu2*t/8d0/pi2)
49592  &+(3d0*hu4/8d0/pi2) * (t + xau/2d0 + (3d0*hu2/2d0 + hd2/2d0
49593  &- 8d0*g3**2) * (xau*t + t**2)/16d0/pi2)
49594  &-(3d0*hd4* xmu**4/96d0/pi2/xms4) * (1+ (9d0*hd2 -5d0* hu2
49595  &- 16d0*g3**2) *t/16d0/pi2)
49596  xlam3 = ((g2**2 - g1**2)/4d0)*(1d0-3d0*
49597  &(hu2 + hd2)*t/16d0/pi2)
49598  &+(6d0*hu2*hd2/16d0/pi2) * (t + aud/2d0 + (hu2 + hd2
49599  &- 8d0*g3**2) * (aud*t + t**2)/16d0/pi2)
49600  &+(3d0*hu4/96d0/pi2) * (3d0*xmu2/xms2 - xmu2*au2/
49601  &xms4)* (1d0+ (6d0*hu2 -2d0* hd2/2d0
49602  &- 16d0*g3**2) *t/16d0/pi2)
49603  &+(3d0*hd4/96d0/pi2) * (3d0*xmu2/xms2 - xmu2*ad2/
49604  &xms4)*(1d0+ (6d0*hd2 -2d0* hu2
49605  &- 16d0*g3**2) *t/16d0/pi2)
49606  xlam4 = (- g2**2/2d0)*(1d0-3d0*(hu2 + hd2)*t/16d0/pi2)
49607  &-(6d0*hu2*hd2/16d0/pi2) * (t + aud/2d0 + (hu2 + hd2
49608  &- 8d0*g3**2) * (aud*t + t**2)/16d0/pi2)
49609  &+(3d0*hu4/96d0/pi2) * (3d0*xmu2/xms2 - xmu2*au2/
49610  &xms4)*
49611  &(1+ (6d0*hu2 -2d0* hd2
49612  &- 16d0*g3**2) *t/16d0/pi2)
49613  &+(3d0*hd4/96d0/pi2) * (3d0*xmu2/xms2 - xmu2*ad2/
49614  &xms4)*
49615  &(1+ (6d0*hd2 -2d0* hu2/2d0
49616  &- 16d0*g3**2) *t/16d0/pi2)
49617  xlam5 = -(3d0*hu4* xmu2*au2/96d0/pi2/xms4) *
49618  &(1- (2d0*hd2 -6d0* hu2 + 16d0*g3**2) *t/16d0/pi2)
49619  &-(3d0*hd4* xmu2*ad2/96d0/pi2/xms4) *
49620  &(1- (2d0*hu2 -6d0* hd2 + 16d0*g3**2) *t/16d0/pi2)
49621  xlam6 = (3d0*hu4* xmu**3*au/96d0/pi2/xms4) *
49622  &(1- (7d0*hd2/2d0 -15d0* hu2/2d0 + 16d0*g3**2) *t/16d0/pi2)
49623  &+(3d0*hd4* xmu *(ad**3/xms3 - 6d0*ad/xms )/96d0/pi2/xms) *
49624  &(1- (hu2/2d0 -9d0* hd2/2d0 + 16d0*g3**2) *t/16d0/pi2)
49625  xlam7 = (3d0*hd4* xmu**3*ad/96d0/pi2/xms4) *
49626  &(1- (7d0*hu2/2d0 -15d0* hd2/2d0 + 16d0*g3**2) *t/16d0/pi2)
49627  &+(3d0*hu4* xmu *(au**3/xms3 - 6d0*au/xms )/96d0/pi2/xms) *
49628  &(1- (hd2/2d0 -9d0* hu2/2d0 + 16d0*g3**2) *t/16d0/pi2)
49629  hhh(1)=xlam1
49630  hhh(2)=xlam2
49631  hhh(3)=xlam3
49632  hhh(4)=xlam4
49633  hhh(5)=xlam5
49634  hhh(6)=xlam6
49635  hhh(7)=xlam7
49636  trm2 = xma**2 + 2d0*v**2* (xlam1* cosbt**2 +
49637  &2d0* xlam6*sinbt*cosbt
49638  &+ xlam5*sinbt**2 + xlam2* sinbt**2 + 2d0* xlam7*sinbt*cosbt
49639  &+ xlam5*cosbt**2)
49640  detm2 = 4d0*v**4*(-(sinbt*cosbt*(xlam3 + xlam4) +
49641  &xlam6*cosbt**2
49642  &+ xlam7* sinbt**2)**2 + (xlam1* cosbt**2 +
49643  &2d0* xlam6* cosbt*sinbt
49644  &+ xlam5*sinbt**2)*(xlam2* sinbt**2 +2d0* xlam7* cosbt*sinbt
49645  &+ xlam5*cosbt**2)) + xma**2*2d0*v**2 *
49646  &((xlam1* cosbt**2 +2d0*
49647  &xlam6* cosbt*sinbt + xlam5*sinbt**2)*cosbt**2 +
49648  &(xlam2* sinbt**2 +2d0* xlam7* cosbt*sinbt + xlam5*cosbt**2)
49649  &*sinbt**2
49650  &+2d0*sinbt*cosbt* (sinbt*cosbt*(xlam3
49651  &+ xlam4) + xlam6*cosbt**2
49652  &+ xlam7* sinbt**2))
49653 
49654  xmh2 = (trm2 - sqrt(trm2**2 - 4d0* detm2))/2d0
49655  xhm2 = (trm2 + sqrt(trm2**2 - 4d0* detm2))/2d0
49656  xhm = sqrt(xhm2)
49657  xmh = sqrt(xmh2)
49658  xmhch2 = xma**2 + (xlam5 - xlam4)* v**2
49659  xmhch = sqrt(xmhch2)
49660 
49661  sinalp = sqrt(((trm2**2 - 4d0* detm2)**0.5d0) -
49662  &((2d0*v**2*(xlam1* cosbt**2 + 2d0*
49663  &xlam6* cosbt*sinbt
49664  &+ xlam5*sinbt**2) + xma**2*sinbt**2)
49665  &- (2d0*v**2*(xlam2* sinbt**2 +2d0* xlam7* cosbt*sinbt
49666  &+ xlam5*cosbt**2) + xma**2*cosbt**2)))/
49667  &sqrt(((trm2**2 - 4d0* detm2)**0.5d0))/2d0**0.5d0
49668 
49669  cosalp = (2d0*(2d0*v**2*(sinbt*cosbt*(xlam3 + xlam4) +
49670  &xlam6*cosbt**2 + xlam7* sinbt**2) -
49671  &xma**2*sinbt*cosbt))/2d0**0.5d0/
49672  &sqrt(((trm2**2 - 4d0* detm2)**0.5d0)*
49673  &(((trm2**2 - 4d0* detm2)**0.5d0) -
49674  &((2d0*v**2*(xlam1* cosbt**2 + 2d0*
49675  &xlam6* cosbt*sinbt
49676  &+ xlam5*sinbt**2) + xma**2*sinbt**2)
49677  &- (2d0*v**2*(xlam2* sinbt**2 +2d0* xlam7* cosbt*sinbt
49678  &+ xlam5*cosbt**2) + xma**2*cosbt**2))))
49679 
49680  sa = -sinalp
49681  ca = -cosalp
49682 
49683  100 CONTINUE
49684 
49685  RETURN
49686  END
49687 
49688 C*********************************************************************
49689 
49690 C...PYPOLE
49691 C...This subroutine computes the CP-even higgs and CP-odd pole
49692 c...Higgs masses and mixing angles.
49693 
49694 C...Program based on the work by M. Carena, M. Quiros
49695 C...and C.E.M. Wagner, "Effective potential methods and
49696 C...the Higgs mass spectrum in the MSSM", CERN-TH/95-157
49697 
49698 C...Inputs: IHIGGS(explained below),MCHI,MA,TANB,MQ,MUR,MDR,MTOP,
49699 C...AT,AB,MU
49700 C...where MCHI is the largest chargino mass, MA is the running
49701 C...CP-odd higgs mass, TANB is the value of the ratio of vacuum
49702 C...expectaion values at the scale MTOP, MQ is the third generation
49703 C...left handed squark mass parameter, MUR is the third generation
49704 C...right handed stop mass parameter, MDR is the third generation
49705 C...right handed sbottom mass parameter, MTOP is the pole top quark
49706 C...mass; AT,AB are the soft supersymmetry breaking trilinear
49707 C...couplings of the stop and sbottoms, respectively, and MU is the
49708 C...supersymmetric mass parameter
49709 
49710 C...The parameter IHIGGS=0,1,2,3 corresponds to the number of
49711 C...Higgses whose pole mass is computed. If IHIGGS=0 only running
49712 C...masses are given, what makes the running of the program
49713 c...much faster and it is quite generally a good approximation
49714 c...(for a theoretical discussion see ref. above). If IHIGGS=1,
49715 C...only the pole mass for H is computed. If IHIGGS=2, then h and H,
49716 c...and if IHIGGS=3, then h,H,A polarizations are computed
49717 
49718 C...Output: MH and MHP which are the lightest CP-even Higgs running
49719 C...and pole masses, respectively; HM and HMP are the heaviest CP-even
49720 C...Higgs running and pole masses, repectively; SA and CA are the
49721 C...SIN(ALPHA) and COS(ALPHA) where ALPHA is the Higgs mixing angle
49722 C...AMP is the CP-odd Higgs pole mass. STOP1,STOP2,SBOT1 and SBOT2
49723 C...are the stop and sbottom mass eigenvalues. Finally, TANBA is
49724 C...the value of TANB at the CP-odd Higgs mass scale
49725 
49726 C...This subroutine makes use of CERN library subroutine
49727 C...integration package, which makes the computation of the
49728 C...pole Higgs masses somewhat faster. We thank P. Janot for this
49729 C...improvement. Those who are not able to call the CERN
49730 C...libraries, please use the subroutine SUBHPOLE2.F, which
49731 C...although somewhat slower, gives identical results
49732 
49733  SUBROUTINE pypole(IHIGGS,XMC,XMA,TANB,XMQ,XMUR,XMDR,XMT,AT,AB,XMU,
49734  &xmh,xmhp,hm,hmp,amp,sa,ca,stop1,stop2,sbot1,sbot2,tanba,xmg,dt,db)
49735 
49736 C...Double precision and integer declarations.
49737  IMPLICIT DOUBLE PRECISION(a-h, o-z)
49738  IMPLICIT INTEGER(i-n)
49739 
49740 C...Parameters.
49741  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
49742  SAVE /pydat1/
49743  INTEGER pyk,pychge,pycomp
49744 
49745 C...Local variables.
49746  dimension delta(2,2),coupt(2,2),t(2,2),sstop2(2),
49747  &ssbot2(2),b(2,2),coupb(2,2),
49748  &hcoupt(2,2),hcoupb(2,2),
49749  &acoupt(2,2),acoupb(2,2),pr(3), polar(3)
49750 
49751  delta(1,1) = 1d0
49752  delta(2,2) = 1d0
49753  delta(1,2) = 0d0
49754  delta(2,1) = 0d0
49755  v = 174.1d0
49756  xmz=91.18d0
49757  pi=paru(1)
49758  rxmt=pymrun(6,xmt**2)
49759  CALL pyrghm(xmc,xma,tanb,xmq,xmur,xmdr,xmt,at,ab,
49760  &xmu,xmh,hm,xmch,sa,ca,sab,cab,tanba,xmg,dt,db)
49761 
49762  sinb = tanb/(tanb**2+1d0)**0.5d0
49763  cosb = 1d0/(tanb**2+1d0)**0.5d0
49764  cos2b = sinb**2 - cosb**2
49765  sinbpa = sinb*ca + cosb*sa
49766  cosbpa = cosb*ca - sinb*sa
49767  rmbot = pymrun(5,xmt**2)
49768  xmq2 = xmq**2
49769  xmur2 = xmur**2
49770  IF(xmur.LT.0d0) xmur2=-xmur2
49771  xmdr2 = xmdr**2
49772  xmst11 = rxmt**2 + xmq2 - 0.35d0*xmz**2*cos2b
49773  xmst22 = rxmt**2 + xmur2 - 0.15d0*xmz**2*cos2b
49774  IF(xmst11.LT.0d0) goto 500
49775  IF(xmst22.LT.0d0) goto 500
49776  xmsb11 = rmbot**2 + xmq2 + 0.42d0*xmz**2*cos2b
49777  xmsb22 = rmbot**2 + xmdr2 + 0.08d0*xmz**2*cos2b
49778  IF(xmsb11.LT.0d0) goto 500
49779  IF(xmsb22.LT.0d0) goto 500
49780 C WMST11 = RXMT**2 + XMQ2
49781 C WMST22 = RXMT**2 + XMUR2
49782  xmst12 = rxmt*(at - xmu/tanb)
49783  xmsb12 = rmbot*(ab - xmu*tanb)
49784 
49785 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
49786 C...STOP EIGENVALUES CALCULATION
49787 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
49788 
49789  stop12 = 0.5d0*(xmst11+xmst22) +
49790  &0.5d0*((xmst11+xmst22)**2 -
49791  &4d0*(xmst11*xmst22 - xmst12**2))**0.5d0
49792  stop22 = 0.5d0*(xmst11+xmst22) -
49793  &0.5d0*((xmst11+xmst22)**2 - 4d0*(xmst11*xmst22 -
49794  &xmst12**2))**0.5d0
49795 
49796  IF(stop22.LT.0d0) goto 500
49797  sstop2(1) = stop12
49798  sstop2(2) = stop22
49799  stop1 = stop12**0.5d0
49800  stop2 = stop22**0.5d0
49801 C STOP1W = STOP1
49802 C STOP2W = STOP2
49803 
49804  IF(xmst12.EQ.0d0) xst11 = 1d0
49805  IF(xmst12.EQ.0d0) xst12 = 0d0
49806  IF(xmst12.EQ.0d0) xst21 = 0d0
49807  IF(xmst12.EQ.0d0) xst22 = 1d0
49808 
49809  IF(xmst12.EQ.0d0) goto 110
49810 
49811  100 xst11 = xmst12/(xmst12**2+(xmst11-stop12)**2)**0.5d0
49812  xst12 = - (xmst11-stop12)/(xmst12**2+(xmst11-stop12)**2)**0.5d0
49813  xst21 = xmst12/(xmst12**2+(xmst11-stop22)**2)**0.5d0
49814  xst22 = - (xmst11-stop22)/(xmst12**2+(xmst11-stop22)**2)**0.5d0
49815 
49816  110 t(1,1) = xst11
49817  t(2,2) = xst22
49818  t(1,2) = xst12
49819  t(2,1) = xst21
49820 
49821  sbot12 = 0.5d0*(xmsb11+xmsb22) +
49822  &0.5d0*((xmsb11+xmsb22)**2 -
49823  &4d0*(xmsb11*xmsb22 - xmsb12**2))**0.5d0
49824  sbot22 = 0.5d0*(xmsb11+xmsb22) -
49825  &0.5d0*((xmsb11+xmsb22)**2 - 4d0*(xmsb11*xmsb22 -
49826  &xmsb12**2))**0.5d0
49827  IF(sbot22.LT.0d0) goto 500
49828  sbot1 = sbot12**0.5d0
49829  sbot2 = sbot22**0.5d0
49830 
49831  ssbot2(1) = sbot12
49832  ssbot2(2) = sbot22
49833 
49834  IF(xmsb12.EQ.0d0) xsb11 = 1d0
49835  IF(xmsb12.EQ.0d0) xsb12 = 0d0
49836  IF(xmsb12.EQ.0d0) xsb21 = 0d0
49837  IF(xmsb12.EQ.0d0) xsb22 = 1d0
49838 
49839  IF(xmsb12.EQ.0d0) goto 130
49840 
49841  120 xsb11 = xmsb12/(xmsb12**2+(xmsb11-sbot12)**2)**0.5d0
49842  xsb12 = - (xmsb11-sbot12)/(xmsb12**2+(xmsb11-sbot12)**2)**0.5d0
49843  xsb21 = xmsb12/(xmsb12**2+(xmsb11-sbot22)**2)**0.5d0
49844  xsb22 = - (xmsb11-sbot22)/(xmsb12**2+(xmsb11-sbot22)**2)**0.5d0
49845 
49846  130 b(1,1) = xsb11
49847  b(2,2) = xsb22
49848  b(1,2) = xsb12
49849  b(2,1) = xsb21
49850 
49851 
49852  sint = 0.2320d0
49853  sqr = dsqrt(2d0)
49854  vp = 174.1d0*sqr
49855 
49856 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
49857 C...STARTING OF LIGHT HIGGS
49858 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
49859 
49860  IF(ihiggs.EQ.0) goto 490
49861 
49862  DO 150 i = 1,2
49863  DO 140 j = 1,2
49864  coupt(i,j) =
49865  & sint*xmz**2*2d0*sqr/174.1d0/3d0*sinbpa*(delta(i,j) +
49866  & (3d0 - 8d0*sint)/4d0/sint*t(1,i)*t(1,j))
49867  & -rxmt**2/174.1d0**2*vp/sinb*ca*delta(i,j)
49868  & -rxmt/vp/sinb*(at*ca + xmu*sa)*(t(1,i)*t(2,j) +
49869  & t(1,j)*t(2,i))
49870  140 CONTINUE
49871  150 CONTINUE
49872 
49873 
49874  DO 170 i = 1,2
49875  DO 160 j = 1,2
49876  coupb(i,j) =
49877  & -sint*xmz**2*2d0*sqr/174.1d0/6d0*sinbpa*(delta(i,j) +
49878  & (3d0 - 4d0*sint)/2d0/sint*b(1,i)*b(1,j))
49879  & +rmbot**2/174.1d0**2*vp/cosb*sa*delta(i,j)
49880  & +rmbot/vp/cosb*(ab*sa + xmu*ca)*(b(1,i)*b(2,j) +
49881  & b(1,j)*b(2,i))
49882  160 CONTINUE
49883  170 CONTINUE
49884 
49885  prun = xmh
49886  eps = 1d-4*prun
49887  iter = 0
49888  180 iter = iter + 1
49889  DO 230 i3 = 1,3
49890 
49891  pr(i3)=prun+(i3-2)*eps/2
49892  p2=pr(i3)**2
49893  polt = 0d0
49894  DO 200 i = 1,2
49895  DO 190 j = 1,2
49896  polt = polt + coupt(i,j)**2*3d0*
49897  & pyfint(p2,sstop2(i),sstop2(j))/16d0/pi**2
49898  190 CONTINUE
49899  200 CONTINUE
49900 
49901  polb = 0d0
49902  DO 220 i = 1,2
49903  DO 210 j = 1,2
49904  polb = polb + coupb(i,j)**2*3d0*
49905  & pyfint(p2,ssbot2(i),ssbot2(j))/16d0/pi**2
49906  210 CONTINUE
49907  220 CONTINUE
49908 C RXMT2 = RXMT**2
49909  xmt2=xmt**2
49910 
49911  poltt =
49912  & 3d0*rxmt**2/8d0/pi**2/ v **2*
49913  & ca**2/sinb**2 *
49914  & (-2d0*xmt**2+0.5d0*p2)*
49915  & pyfint(p2,xmt2,xmt2)
49916 
49917  pol = polt + polb + poltt
49918  polar(i3) = p2 - xmh**2 - pol
49919  230 CONTINUE
49920  deriv = (polar(3)-polar(1))/eps
49921  drun = - polar(2)/deriv
49922  prun = prun + drun
49923  p2 = prun**2
49924  IF( abs(drun) .LT. 1d-4 .OR.iter.GT.500) goto 240
49925  goto 180
49926  240 CONTINUE
49927 
49928  xmhp = dsqrt(p2)
49929 
49930 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
49931 C...END OF LIGHT HIGGS
49932 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
49933 
49934  250 IF(ihiggs.EQ.1) goto 490
49935 
49936 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
49937 C... STARTING OF HEAVY HIGGS
49938 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
49939 
49940  DO 270 i = 1,2
49941  DO 260 j = 1,2
49942  hcoupt(i,j) =
49943  & -sint*xmz**2*2d0*sqr/174.1d0/3d0*cosbpa*(delta(i,j) +
49944  & (3d0 - 8d0*sint)/4d0/sint*t(1,i)*t(1,j))
49945  & -rxmt**2/174.1d0**2*vp/sinb*sa*delta(i,j)
49946  & -rxmt/vp/sinb*(at*sa - xmu*ca)*(t(1,i)*t(2,j) +
49947  & t(1,j)*t(2,i))
49948  260 CONTINUE
49949  270 CONTINUE
49950 
49951  DO 290 i = 1,2
49952  DO 280 j = 1,2
49953  hcoupb(i,j) =
49954  & sint*xmz**2*2d0*sqr/174.1d0/6d0*cosbpa*(delta(i,j) +
49955  & (3d0 - 4d0*sint)/2d0/sint*b(1,i)*b(1,j))
49956  & -rmbot**2/174.1d0**2*vp/cosb*ca*delta(i,j)
49957  & -rmbot/vp/cosb*(ab*ca - xmu*sa)*(b(1,i)*b(2,j) +
49958  & b(1,j)*b(2,i))
49959  hcoupb(i,j)=0d0
49960  280 CONTINUE
49961  290 CONTINUE
49962 
49963  prun = hm
49964  eps = 1d-4*prun
49965  iter = 0
49966  300 iter = iter + 1
49967  DO 350 i3 = 1,3
49968  pr(i3)=prun+(i3-2)*eps/2
49969  hp2=pr(i3)**2
49970 
49971  hpolt = 0d0
49972  DO 320 i = 1,2
49973  DO 310 j = 1,2
49974  hpolt = hpolt + hcoupt(i,j)**2*3d0*
49975  & pyfint(hp2,sstop2(i),sstop2(j))/16d0/pi**2
49976  310 CONTINUE
49977  320 CONTINUE
49978 
49979  hpolb = 0d0
49980  DO 340 i = 1,2
49981  DO 330 j = 1,2
49982  hpolb = hpolb + hcoupb(i,j)**2*3d0*
49983  & pyfint(hp2,ssbot2(i),ssbot2(j))/16d0/pi**2
49984  330 CONTINUE
49985  340 CONTINUE
49986 
49987 C RXMT2 = RXMT**2
49988  xmt2 = xmt**2
49989 
49990  hpoltt =
49991  & 3d0*rxmt**2/8d0/pi**2/ v **2*
49992  & sa**2/sinb**2 *
49993  & (-2d0*xmt**2+0.5d0*hp2)*
49994  & pyfint(hp2,xmt2,xmt2)
49995 
49996  hpol = hpolt + hpolb + hpoltt
49997  polar(i3) =hp2-hm**2-hpol
49998  350 CONTINUE
49999  deriv = (polar(3)-polar(1))/eps
50000  drun = - polar(2)/deriv
50001  prun = prun + drun
50002  hp2 = prun**2
50003  IF( abs(drun) .LT. 1d-4 .OR.iter.GT.500) goto 360
50004  goto 300
50005  360 CONTINUE
50006 
50007 
50008  370 CONTINUE
50009  hmp = hp2**0.5d0
50010 
50011 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
50012 C... END OF HEAVY HIGGS
50013 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
50014 
50015  IF(ihiggs.EQ.2) goto 490
50016 
50017 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
50018 C...BEGINNING OF PSEUDOSCALAR HIGGS
50019 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
50020 
50021  DO 390 i = 1,2
50022  DO 380 j = 1,2
50023  acoupt(i,j) =
50024  & -rxmt/vp/sinb*(at*cosb + xmu*sinb)*
50025  & (t(1,i)*t(2,j) -t(1,j)*t(2,i))
50026  380 CONTINUE
50027  390 CONTINUE
50028  DO 410 i = 1,2
50029  DO 400 j = 1,2
50030  acoupb(i,j) =
50031  & rmbot/vp/cosb*(ab*sinb + xmu*cosb)*
50032  & (b(1,i)*b(2,j) -b(1,j)*b(2,i))
50033  400 CONTINUE
50034  410 CONTINUE
50035 
50036  prun = xma
50037  eps = 1d-4*prun
50038  iter = 0
50039  420 iter = iter + 1
50040  DO 470 i3 = 1,3
50041  pr(i3)=prun+(i3-2)*eps/2
50042  ap2=pr(i3)**2
50043  apolt = 0d0
50044  DO 440 i = 1,2
50045  DO 430 j = 1,2
50046  apolt = apolt + acoupt(i,j)**2*3d0*
50047  & pyfint(ap2,sstop2(i),sstop2(j))/16d0/pi**2
50048  430 CONTINUE
50049  440 CONTINUE
50050  apolb = 0d0
50051  DO 460 i = 1,2
50052  DO 450 j = 1,2
50053  apolb = apolb + acoupb(i,j)**2*3d0*
50054  & pyfint(ap2,ssbot2(i),ssbot2(j))/16d0/pi**2
50055  450 CONTINUE
50056  460 CONTINUE
50057 C RXMT2 = RXMT**2
50058  xmt2=xmt**2
50059  apoltt =
50060  & 3d0*rxmt**2/8d0/pi**2/ v **2*
50061  & cosb**2/sinb**2 *
50062  & (-0.5d0*ap2)*
50063  & pyfint(ap2,xmt2,xmt2)
50064  apol = apolt + apolb + apoltt
50065  polar(i3) = ap2 - xma**2 -apol
50066  470 CONTINUE
50067  deriv = (polar(3)-polar(1))/eps
50068  drun = - polar(2)/deriv
50069  prun = prun + drun
50070  ap2 = prun**2
50071  IF( abs(drun) .LT. 1d-4 .OR.iter.GT.500) goto 480
50072  goto 420
50073  480 CONTINUE
50074 
50075  amp = dsqrt(ap2)
50076 
50077 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
50078 C...END OF PSEUDOSCALAR HIGGS
50079 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
50080 
50081  IF(ihiggs.EQ.3) goto 490
50082 
50083  490 CONTINUE
50084  RETURN
50085  500 CONTINUE
50086  WRITE(mstu(11),*) ' EXITING IN PYPOLE '
50087  WRITE(mstu(11),*) ' XMST11,XMST22 = ',xmst11,xmst22
50088  WRITE(mstu(11),*) ' XMSB11,XMSB22 = ',xmsb11,xmsb22
50089  WRITE(mstu(11),*) ' STOP22,SBOT22 = ',stop22,sbot22
50090  CALL pystop(107)
50091  END
50092 
50093 C*********************************************************************
50094 
50095 C...PYRGHM
50096 C...Auxiliary to PYPOLE.
50097 
50098  SUBROUTINE pyrghm(MCHI,MA,TANB,MQ,MUR,MD,MTOP,AU,AD,MU,
50099  * mhp,hmp,mch,sa,ca,sab,cab,tanba,mglu,deltamt,deltamb)
50100  IMPLICIT DOUBLE PRECISION(a-h,l,m,o-z)
50101  dimension vh(2,2),m2(2,2),m2p(2,2)
50102 C...Parameters.
50103  INTEGER mstu,mstj
50104  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
50105  SAVE /pydat1/
50106 
50107  mz = 91.18d0
50108  pi = paru(1)
50109  v = 174.1d0
50110  alpha1 = 0.0101d0
50111  alpha2 = 0.0337d0
50112  alpha3z = 0.12d0
50113  tanba = tanb
50114  tanbt = tanb
50115 C MBOTTOM(MTOP) = 3. GEV
50116  mb = pymrun(5,mtop**2)
50117  alpha3 = alpha3z/(1d0 +(11d0 - 10d0/3d0)/4d0/pi*alpha3z*
50118  *log(mtop**2/mz**2))
50119 C RMTOP= RUNNING TOP QUARK MASS
50120  rmtop = mtop/(1d0+4d0*alpha3/3d0/pi)
50121  tq = log((mq**2+mtop**2)/mtop**2)
50122  tu = log((mur**2 + mtop**2)/mtop**2)
50123  td = log((md**2 + mtop**2)/mtop**2)
50124 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
50125 C
50126 C NEW DEFINITION, TGLU.
50127 C
50128 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
50129  tglu = log(mglu**2/mtop**2)
50130  sinb = tanb/dsqrt(1d0 + tanb**2)
50131  cosb = sinb/tanb
50132  IF(ma.GT.mtop)
50133  *tanba = tanb*(1d0-3d0/32d0/pi**2*
50134  *(rmtop**2/v**2/sinb**2-mb**2/v**2/cosb**2)*
50135  *log(ma**2/mtop**2))
50136  IF(ma.LT.mtop.OR.ma.EQ.mtop) tanbt = tanba
50137  sinb = tanbt/sqrt(1d0 + tanbt**2)
50138  cosb = 1d0/dsqrt(1d0 + tanbt**2)
50139  g1 = sqrt(alpha1*4d0*pi)
50140  g2 = sqrt(alpha2*4d0*pi)
50141  g3 = sqrt(alpha3*4d0*pi)
50142  hu = rmtop/v/sinb
50143  hd = mb/v/cosb
50144  CALL pygfxx(ma,tanba,mq,mur,md,mtop,au,ad,mu,mglu,vh,stop1,stop2,
50145  *sbot1,sbot2,deltamt,deltamb)
50146  IF(mq.GT.mur) tp = tq - tu
50147  IF(mq.LT.mur.OR.mq.EQ.mur) tp = tu - tq
50148  IF(mq.GT.mur) tdp = tu
50149  IF(mq.LT.mur.OR.mq.EQ.mur) tdp = tq
50150  IF(mq.GT.md) tpd = tq - td
50151  IF(mq.LT.md.OR.mq.EQ.md) tpd = td - tq
50152  IF(mq.GT.md) tdpd = td
50153  IF(mq.LT.md.OR.mq.EQ.md) tdpd = tq
50154 
50155  IF(mq.GT.md) dlambda1 = 6d0/96d0/pi**2*g1**2*hd**2*tpd
50156  IF(mq.LT.md.OR.mq.EQ.md) dlambda1 = 3d0/32d0/pi**2*
50157  * hd**2*(g1**2/3d0+g2**2)*tpd
50158 
50159  IF(mq.GT.mur) dlambda2 =12d0/96d0/pi**2*g1**2*hu**2*tp
50160  IF(mq.LT.mur.OR.mq.EQ.mur) dlambda2 = 3d0/32d0/pi**2*
50161  * hu**2*(-g1**2/3d0+g2**2)*tp
50162 
50163 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
50164 C
50165 C DLAMBDAP1 AND DLAMBDAP2 ARE THE NEW LOG CORRECTIONS DUE TO
50166 C THE PRESENCE OF THE GLUINO MASS. THEY ARE IN GENERAL VERY SMALL,
50167 C AND ONLY PRESENT IF THERE IS A HIERARCHY OF MASSES BETWEEN THE
50168 C TWO STOPS.
50169 C
50170 C
50171 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
50172 
50173  dlambdap2 = 0d0
50174  IF(mglu.LT.mur.OR.mglu.LT.mq) THEN
50175  IF(mq.GT.mur.AND.mglu.GT.mur) THEN
50176  dlambdap2 = -4d0/(16d0*pi**2)**2*hu**4*(tq**2-tglu**2)
50177  ENDIF
50178 
50179  IF(mq.GT.mur.AND.mglu.LT.mur) THEN
50180  dlambdap2 = -4d0/(16d0*pi**2)**2*hu**4*(tq**2-tu**2)
50181  ENDIF
50182 
50183  IF(mq.GT.mur.AND.mglu.EQ.mur) THEN
50184  dlambdap2 = -4d0/(16d0*pi**2)**2*hu**4*(tq**2-tu**2)
50185  ENDIF
50186 
50187  IF(mur.GT.mq.AND.mglu.GT.mq) THEN
50188  dlambdap2 = -4d0/(16d0*pi**2)**2*hu**4*(tu**2-tglu**2)
50189  ENDIF
50190 
50191  IF(mur.GT.mq.AND.mglu.LT.mq) THEN
50192  dlambdap2 = -4d0/(16d0*pi**2)**2*hu**4*(tu**2-tq**2)
50193  ENDIF
50194 
50195  IF(mur.GT.mq.AND.mglu.EQ.mq) THEN
50196  dlambdap2 = -4d0/(16d0*pi**2)**2*hu**4*(tu**2-tq**2)
50197  ENDIF
50198  ENDIF
50199  dlambda3 = 0d0
50200  dlambda4 = 0d0
50201  IF(mq.GT.md) dlambda3 = -1d0/32d0/pi**2*g1**2*hd**2*tpd
50202  IF(mq.LT.md.OR.mq.EQ.md) dlambda3 = 3d0/64d0/pi**2*hd**2*
50203  *(g2**2-g1**2/3d0)*tpd
50204  IF(mq.GT.mur) dlambda3 = dlambda3 -
50205  *1d0/16d0/pi**2*g1**2*hu**2*tp
50206  IF(mq.LT.mur.OR.mq.EQ.mur) dlambda3 = dlambda3 +
50207  * 3d0/64d0/pi**2*hu**2*(g2**2+g1**2/3d0)*tp
50208  IF(mq.LT.mur) dlambda4 = -3d0/32d0/pi**2*g2**2*hu**2*tp
50209  IF(mq.LT.md) dlambda4 = dlambda4 - 3d0/32d0/pi**2*g2**2*
50210  *hd**2*tpd
50211  lambda1 = ((g1**2 + g2**2)/4d0)*
50212  * (1d0-3d0*hd**2*(tpd + tdpd)/8d0/pi**2)
50213  *+(3d0*hd**4d0/16d0/pi**2) *tpd*(1d0
50214  *+ (3d0*hd**2/2d0 + hu**2/2d0
50215  *- 8d0*g3**2) * (tpd + 2d0*tdpd)/16d0/pi**2)
50216  *+(3d0*hd**4d0/8d0/pi**2) *tdpd*(1d0 + (3d0*hd**2/2d0 + hu**2/2d0
50217  *- 8d0*g3**2) * tdpd/16d0/pi**2) + dlambda1
50218  lambda2 = ((g1**2 + g2**2)/4d0)*(1d0-3d0*hu**2*
50219  *(tp + tdp)/8d0/pi**2)
50220  *+(3d0*hu**4d0/16d0/pi**2) *tp*(1d0
50221  *+ (3d0*hu**2/2d0 + hd**2/2d0
50222  *- 8d0*g3**2) * (tp + 2d0*tdp)/16d0/pi**2)
50223  *+(3d0*hu**4d0/8d0/pi**2) *tdp*(1d0 + (3d0*hu**2/2d0 + hd**2/2d0
50224  *- 8d0*g3**2) * tdp/16d0/pi**2) + dlambda2 + dlambdap2
50225  lambda3 = ((g2**2 - g1**2)/4d0)*(1d0-3d0*
50226  *(hu**2)*(tp + tdp)/16d0/pi**2 -3d0*
50227  *(hd**2)*(tpd + tdpd)/16d0/pi**2) +dlambda3
50228  lambda4 = (- g2**2/2d0)*(1d0
50229  *-3d0*(hu**2)*(tp + tdp)/16d0/pi**2
50230  *-3d0*(hd**2)*(tpd + tdpd)/16d0/pi**2) +dlambda4
50231 
50232  lambda5 = 0d0
50233  lambda6 = 0d0
50234  lambda7 = 0d0
50235 
50236  m2(1,1) = 2d0*v**2*(lambda1*cosb**2+2d0*lambda6*
50237  *cosb*sinb + lambda5*sinb**2) + ma**2*sinb**2
50238 
50239  m2(2,2) = 2d0*v**2*(lambda5*cosb**2+2d0*lambda7*
50240  *cosb*sinb + lambda2*sinb**2) + ma**2*cosb**2
50241  m2(1,2) = 2d0*v**2*(lambda6*cosb**2+(lambda3+lambda4)*
50242  *cosb*sinb + lambda7*sinb**2) - ma**2*sinb*cosb
50243 
50244  m2(2,1) = m2(1,2)
50245 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
50246 CCC THIS IS THE CONTRIBUTION FROM LIGHT CHARGINOS/NEUTRALINOS
50247 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
50248 
50249  mssusy=dsqrt(.5d0*(mq**2+mur**2)+mtop**2)
50250 
50251  IF(mchi.GT.mssusy) goto 100
50252  IF(mchi.LT.mtop) mchi=mtop
50253 
50254  tchar=log(mssusy**2/mchi**2)
50255 
50256  deltal12=(9d0/64d0/pi**2*g2**4+5d0/192d0/pi**2*g1**4)*tchar
50257  deltal3p4=(3d0/64d0/pi**2*g2**4+7d0/192d0/pi**2*g1**4
50258  *+4d0/32d0/pi**2*g1**2*g2**2)*tchar
50259 
50260  deltam112=2d0*deltal12*v**2*cosb**2
50261  deltam222=2d0*deltal12*v**2*sinb**2
50262  deltam122=2d0*deltal3p4*v**2*sinb*cosb
50263 
50264  m2(1,1)=m2(1,1)+deltam112
50265  m2(2,2)=m2(2,2)+deltam222
50266  m2(1,2)=m2(1,2)+deltam122
50267  m2(2,1)=m2(2,1)+deltam122
50268 
50269  100 CONTINUE
50270 
50271 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
50272 CCC END OF CHARGINOS/NEUTRALINOS
50273 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
50274 
50275  DO 120 i = 1,2
50276  DO 110 j = 1,2
50277  m2p(i,j) = m2(i,j) + vh(i,j)
50278  110 CONTINUE
50279  120 CONTINUE
50280  trm2p = m2p(1,1) + m2p(2,2)
50281  detm2p = m2p(1,1)*m2p(2,2) - m2p(1,2)*m2p(2,1)
50282  mh2p = (trm2p - dsqrt(trm2p**2 - 4d0* detm2p))/2d0
50283  hm2p = (trm2p + dsqrt(trm2p**2 - 4d0* detm2p))/2d0
50284  hmp = dsqrt(hm2p)
50285  mch2=ma**2+(lambda5-lambda4)*v**2
50286  mch=dsqrt(mch2)
50287  IF(mh2p.LT.0.) goto 130
50288  mhp = sqrt(mh2p)
50289  sin2alpha = 2d0*m2p(1,2)/sqrt(trm2p**2-4d0*detm2p)
50290  cos2alpha = (m2p(1,1)-m2p(2,2))/sqrt(trm2p**2-4d0*detm2p)
50291  IF(cos2alpha.GE.0.) THEN
50292  alpha = asin(sin2alpha)/2d0
50293  ELSE
50294  alpha = -pi/2d0-asin(sin2alpha)/2d0
50295  ENDIF
50296  sa = sin(alpha)
50297  ca = cos(alpha)
50298 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
50299 C
50300 C HERE THE VALUES OF SAB AND CAB ARE DEFINED, IN ORDER
50301 C TO DEFINE THE NEW COUPLINGS OF THE LIGHTEST AND
50302 C HEAVY CP-EVEN HIGGS TO THE BOTTOM QUARK.
50303 C
50304 C
50305 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
50306  sab = sa*(1d0-deltamb/(1d0+deltamb)*(1d0+ca/sa/tanb))
50307  cab = ca*(1d0-deltamb/(1d0+deltamb)*(1d0-sa/ca/tanb))
50308  130 CONTINUE
50309  RETURN
50310  END
50311 
50312 C*********************************************************************
50313 
50314 C...PYGFXX
50315 C...Auxiliary to PYRGHM.
50316 
50317  SUBROUTINE pygfxx(MA,TANB,MQ,MUR,MD,MTOP,AT,AB,XMU,XMGL,VH,
50318  * stop1,stop2,sbot1,sbot2,deltamt,deltamb)
50319  IMPLICIT DOUBLE PRECISION(a-h,m,o-z)
50320  dimension vh(2,2),vh3t(2,2),vh3b(2,2),al(2,2)
50321 C...Commonblocks.
50322  INTEGER mstu,mstj,kchg
50323  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
50324  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
50325  SAVE /pydat1/,/pydat2/
50326 
50327  g(x,y) = 2.d0 - (x+y)/(x-y)*dlog(x/y)
50328 
50329  t(x,y,z) = (x**2*y**2*log(x**2/y**2) + x**2*z**2*log(z**2/x**2)
50330  * + y**2*z**2*log(y**2/z**2))/((x**2-y**2)*(y**2-z**2)*(x**2-z**2))
50331 
50332  IF(dabs(xmu).LT.0.000001d0) xmu = 0.000001d0
50333  mq2 = mq**2
50334  mur2 = mur**2
50335  md2 = md**2
50336  tanba = tanb
50337  sinba = tanba/dsqrt(tanba**2+1d0)
50338  cosba = sinba/tanba
50339 
50340  sinb = tanb/dsqrt(tanb**2+1d0)
50341  cosb = sinb/tanb
50342 
50343  pi = paru(1)
50344  mz = pmas(23,1)
50345  mw = pmas(24,1)
50346  sw = 1d0-mw**2/mz**2
50347  v = 174.1d0
50348 
50349  alpha3 = 0.12d0/(1d0+23/12d0/pi*0.12d0*log(mtop**2/mz**2))
50350  g2 = dsqrt(0.0336d0*4d0*pi)
50351  g1 = dsqrt(0.0101d0*4d0*pi)
50352 
50353  IF(mq.GT.mur) mst = mq
50354  IF(mur.GT.mq.OR.mur.EQ.mq) mst = mur
50355 
50356  msusyt = dsqrt(mst**2 + mtop**2)
50357 
50358  IF(mq.GT.md) msb = mq
50359  IF(md.GT.mq.OR.md.EQ.mq) msb = md
50360 
50361  mb = pymrun(5,msb**2)
50362  msusyb = dsqrt(msb**2 + mb**2)
50363  tt = log(msusyt**2/mtop**2)
50364  tb = log(msusyb**2/mtop**2)
50365 
50366  rmtop = mtop/(1d0+4d0*alpha3/3d0/pi)
50367  ht = rmtop/(v*sinb)
50368  htst = rmtop/v
50369  hb = mb/v/cosb
50370  g32 = alpha3*4d0*pi
50371  bt2 = -(8d0*g32 - 9d0*ht**2/2d0 - hb**2/2d0)/(4d0*pi)**2
50372  bb2 = -(8d0*g32 - 9d0*hb**2/2d0 - ht**2/2d0)/(4d0*pi)**2
50373  al2 = 3d0/8d0/pi**2*ht**2
50374 C BT2ST = -(8.*G32 - 9.*HTST**2/2.)/(4.*PI)**2
50375 C ALST = 3./8./PI**2*HTST**2
50376  al1 = 3d0/8d0/pi**2*hb**2
50377 
50378  al(1,1) = al1
50379  al(1,2) = (al2+al1)/2d0
50380  al(2,1) = (al2+al1)/2d0
50381  al(2,2) = al2
50382 
50383  IF(ma.GT.mtop) THEN
50384  vi = v*(1d0 + 3d0/32d0/pi**2*htst**2*
50385  * log(mtop**2/ma**2))
50386  h1i = vi* cosba
50387  h2i = vi*sinba
50388  h1t = h1i*(1d0+3d0/8d0/pi**2*hb**2*log(ma**2/msusyt**2))**.25d0
50389  h2t = h2i*(1d0+3d0/8d0/pi**2*ht**2*log(ma**2/msusyt**2))**.25d0
50390  h1b = h1i*(1d0+3d0/8d0/pi**2*hb**2*log(ma**2/msusyb**2))**.25d0
50391  h2b = h2i*(1d0+3d0/8d0/pi**2*ht**2*log(ma**2/msusyb**2))**.25d0
50392  ELSE
50393  vi = v
50394  h1i = vi*cosb
50395  h2i = vi*sinb
50396  h1t=h1i*(1d0+3d0/8d0/pi**2*hb**2*log(mtop**2/msusyt**2))**.25d0
50397  h2t=h2i*(1d0+3d0/8d0/pi**2*ht**2*log(mtop**2/msusyt**2))**.25d0
50398  h1b=h1i*(1d0+3d0/8d0/pi**2*hb**2*log(mtop**2/msusyb**2))**.25d0
50399  h2b=h2i*(1d0+3d0/8d0/pi**2*ht**2*log(mtop**2/msusyb**2))**.25d0
50400  ENDIF
50401 
50402  tanbst = h2t/h1t
50403  sinbt = tanbst/dsqrt(1d0+tanbst**2)
50404 
50405  tanbsb = h2b/h1b
50406  sinbb = tanbsb/dsqrt(1d0+tanbsb**2)
50407  cosbb = sinbb/tanbsb
50408 
50409  deltamt = 0d0
50410  deltamb = 0d0
50411 
50412  mtop4 = rmtop**4*(1d0+2d0*bt2*tt- al2*tt - 4d0*deltamt)
50413  mtop2 = dsqrt(mtop4)
50414  mbot4 = mb**4*(1d0+2d0*bb2*tb - al1*tb)
50415  * /(1d0+deltamb)**4
50416  mbot2 = dsqrt(mbot4)
50417 
50418  stop12 = (mq2 + mur2)*.5d0 + mtop2
50419  * +1d0/8d0*(g2**2+g1**2)*(h1t**2-h2t**2)
50420  * +sqrt(((g2**2-5d0*g1**2/3d0)/4d0*(h1t**2-h2t**2) +
50421  * mq2 - mur2)**2*0.25d0 + mtop2*(at-xmu/tanbst)**2)
50422  stop22 = (mq2 + mur2)*.5d0 + mtop2
50423  * +1d0/8d0*(g2**2+g1**2)*(h1t**2-h2t**2)
50424  * - sqrt(((g2**2-5d0*g1**2/3d0)/4d0*(h1t**2-h2t**2) +
50425  * mq2 - mur2)**2*0.25d0
50426  * + mtop2*(at-xmu/tanbst)**2)
50427  IF(stop22.LT.0.) goto 120
50428  sbot12 = (mq2 + md2)*.5d0
50429  * - 1d0/8d0*(g2**2+g1**2)*(h1b**2-h2b**2)
50430  * + sqrt(((g1**2/3d0-g2**2)/4d0*(h1b**2-h2b**2) +
50431  * mq2 - md2)**2*0.25d0 + mbot2*(ab-xmu*tanbsb)**2)
50432  sbot22 = (mq2 + md2)*.5d0
50433  * - 1d0/8d0*(g2**2+g1**2)*(h1b**2-h2b**2)
50434  * - sqrt(((g1**2/3d0-g2**2)/4d0*(h1b**2-h2b**2) +
50435  * mq2 - md2)**2*0.25d0 + mbot2*(ab-xmu*tanbsb)**2)
50436  IF(sbot22.LT.0.) sbot22 = 10000d0
50437 
50438  stop1 = dsqrt(stop12)
50439  stop2 = dsqrt(stop22)
50440  sbot1 = dsqrt(sbot12)
50441  sbot2 = dsqrt(sbot22)
50442 
50443 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
50444 C
50445 C HERE IS THE DEFINITION OF DELTAMB AND DELTAMT, WHICH
50446 C ARE THE VERTEX CORRECTIONS TO THE BOTTOM AND TOP QUARK
50447 C MASS, KEEPING THE DOMINANT QCD AND TOP YUKAWA COUPLING
50448 C INDUCED CORRECTIONS.
50449 C
50450 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
50451 
50452  x=sbot1
50453  y=sbot2
50454  z=xmgl
50455  IF(x.EQ.y) x = x - 0.00001d0
50456  IF(x.EQ.z) x = x - 0.00002d0
50457  IF(y.EQ.z) y = y - 0.00003d0
50458 
50459  t1=t(x,y,z)
50460  x=stop1
50461  y=stop2
50462  z=xmu
50463  IF(x.EQ.y) x = x - 0.00001d0
50464  IF(x.EQ.z) x = x - 0.00002d0
50465  IF(y.EQ.z) y = y - 0.00003d0
50466  t2=t(x,y,z)
50467  deltamb = -2*alpha3/3d0/pi*xmgl*(ab-xmu*tanb)*t1
50468  * + ht**2/(4d0*pi)**2*(at-xmu/tanb)*xmu*tanb*t2
50469  x=stop1
50470  y=stop2
50471  z=xmgl
50472  IF(x.EQ.y) x = x - 0.00001d0
50473  IF(x.EQ.z) x = x - 0.00002d0
50474  IF(y.EQ.z) y = y - 0.00003d0
50475  t3=t(x,y,z)
50476  deltamt = -2d0*alpha3/3d0/pi*(at-xmu/tanb)*xmgl*t3
50477 
50478 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
50479 C
50480 C HERE THE NEW VALUES OF THE TOP AND BOTTOM QUARK MASSES AT
50481 C THE SCALE MS ARE DEFINED, TO BE USED IN THE EFFECTIVE
50482 C POTENTIAL APPROXIMATION. THEY ARE JUST THE OLD ONES, BUT
50483 C INCLUDING THE FINITE CORRECTIONS DELTAMT AND DELTAMB.
50484 C THE DELTAMB CORRECTIONS CAN BECOME LARGE AND ARE RESUMMED
50485 C TO ALL ORDERS, AS SUGGESTED IN THE TWO RECENT WORKS BY M. CARENA,
50486 C S. MRENNA AND C.E.M. WAGNER, AS WELL AS IN THE WORK BY M. CARENA,
50487 C D. GARCIA, U. NIERSTE AND C.E.M. WAGNER, TO APPEAR. THE TOP
50488 C QUARK MASS CORRECTIONS ARE SMALL AND ARE KEPT IN THE PERTURBATIVE
50489 C FORMULATION. THE FUNCTION T(X,Y,Z) IS NECESSARY FOR THE
50490 C CALCULATION. THE ENTRIES ARE MASSES AND NOT THEIR SQUARES !
50491 C
50492 C
50493 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
50494 
50495  mtop4 = rmtop**4*(1d0+2d0*bt2*tt- al2*tt - 4d0*deltamt)
50496  mtop2 = dsqrt(mtop4)
50497  mbot4 = mb**4*(1d0+2d0*bb2*tb - al1*tb)
50498  * /(1d0+deltamb)**4
50499  mbot2 = dsqrt(mbot4)
50500 
50501  stop12 = (mq2 + mur2)*.5d0 + mtop2
50502  * +1d0/8d0*(g2**2+g1**2)*(h1t**2-h2t**2)
50503  * +sqrt(((g2**2-5d0*g1**2/3d0)/4d0*(h1t**2-h2t**2) +
50504  * mq2 - mur2)**2*0.25d0 + mtop2*(at-xmu/tanbst)**2)
50505  stop22 = (mq2 + mur2)*.5d0 + mtop2
50506  * +1d0/8d0*(g2**2+g1**2)*(h1t**2-h2t**2)
50507  * - sqrt(((g2**2-5d0*g1**2/3d0)/4d0*(h1t**2-h2t**2) +
50508  * mq2 - mur2)**2*0.25d0
50509  * + mtop2*(at-xmu/tanbst)**2)
50510 
50511  IF(stop22.LT.0.) goto 120
50512  sbot12 = (mq2 + md2)*.5d0
50513  * - 1d0/8d0*(g2**2+g1**2)*(h1b**2-h2b**2)
50514  * + sqrt(((g1**2/3d0-g2**2)/4d0*(h1b**2-h2b**2) +
50515  * mq2 - md2)**2*0.25d0 + mbot2*(ab-xmu*tanbsb)**2)
50516  sbot22 = (mq2 + md2)*.5d0
50517  * - 1d0/8d0*(g2**2+g1**2)*(h1b**2-h2b**2)
50518  * - sqrt(((g1**2/3d0-g2**2)/4d0*(h1b**2-h2b**2) +
50519  * mq2 - md2)**2*0.25d0 + mbot2*(ab-xmu*tanbsb)**2)
50520  IF(sbot22.LT.0.) goto 120
50521 
50522 
50523  stop1 = dsqrt(stop12)
50524  stop2 = dsqrt(stop22)
50525  sbot1 = dsqrt(sbot12)
50526  sbot2 = dsqrt(sbot22)
50527 
50528 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
50529 CCC D-TERMS
50530 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
50531  stw=sw
50532 
50533  f1t=(mq2-mur2)/(stop12-stop22)*(.5d0-4d0/3d0*stw)*
50534  * log(stop1/stop2)
50535  * +(.5d0-2d0/3d0*stw)*log(stop1*stop2/(mq2+mtop2))
50536  * + 2d0/3d0*stw*log(stop1*stop2/(mur2+mtop2))
50537 
50538  f1b=(mq2-md2)/(sbot12-sbot22)*(-.5d0+2d0/3d0*stw)*
50539  * log(sbot1/sbot2)
50540  * +(-.5d0+1d0/3d0*stw)*log(sbot1*sbot2/(mq2+mbot2))
50541  * - 1d0/3d0*stw*log(sbot1*sbot2/(md2+mbot2))
50542 
50543  f2t=dsqrt(mtop2)*(at-xmu/tanbst)/(stop12-stop22)*
50544  * (-.5d0*log(stop12/stop22)
50545  * +(4d0/3d0*stw-.5d0)*(mq2-mur2)/(stop12-stop22)*
50546  * g(stop12,stop22))
50547 
50548  f2b=dsqrt(mbot2)*(ab-xmu*tanbsb)/(sbot12-sbot22)*
50549  * (.5d0*log(sbot12/sbot22)
50550  * +(-2d0/3d0*stw+.5d0)*(mq2-md2)/(sbot12-sbot22)*
50551  * g(sbot12,sbot22))
50552 
50553  vh3b(1,1) = mbot4/(cosbb**2)*(log(sbot1**2*sbot2**2/
50554  * (mq2+mbot2)/(md2+mbot2))
50555  * + 2d0*(ab*(ab-xmu*tanbsb)/(sbot1**2-sbot2**2))*
50556  * log(sbot1**2/sbot2**2)) +
50557  * mbot4/(cosbb**2)*(ab*(ab-xmu*tanbsb)/
50558  * (sbot1**2-sbot2**2))**2*g(sbot12,sbot22)
50559 
50560  vh3t(1,1) =
50561  * mtop4/(sinbt**2)*(xmu*(-at+xmu/tanbst)/(stop1**2
50562  * -stop2**2))**2*g(stop12,stop22)
50563 
50564  vh3b(1,1)=vh3b(1,1)+
50565  * mz**2*(2*mbot2*f1b-dsqrt(mbot2)*ab*f2b)
50566 
50567  vh3t(1,1) = vh3t(1,1) +
50568  * mz**2*(dsqrt(mtop2)*xmu/tanbst*f2t)
50569 
50570  vh3t(2,2) = mtop4/(sinbt**2)*(log(stop1**2*stop2**2/
50571  * (mq2+mtop2)/(mur2+mtop2))
50572  * + 2d0*(at*(at-xmu/tanbst)/(stop1**2-stop2**2))*
50573  * log(stop1**2/stop2**2)) +
50574  * mtop4/(sinbt**2)*(at*(at-xmu/tanbst)/
50575  * (stop1**2-stop2**2))**2*g(stop12,stop22)
50576 
50577  vh3b(2,2) =
50578  * mbot4/(cosbb**2)*(xmu*(-ab+xmu*tanbsb)/(sbot1**2
50579  * -sbot2**2))**2*g(sbot12,sbot22)
50580 
50581  vh3t(2,2)=vh3t(2,2)+
50582  * mz**2*(-2*mtop2*f1t+dsqrt(mtop2)*at*f2t)
50583  vh3b(2,2) = vh3b(2,2) -mz**2*dsqrt(mbot2)*xmu*tanbsb*f2b
50584  vh3t(1,2) = -
50585  * mtop4/(sinbt**2)*xmu*(at-xmu/tanbst)/
50586  * (stop1**2-stop2**2)*(log(stop1**2/stop2**2) + at*
50587  * (at - xmu/tanbst)/(stop1**2-stop2**2)*g(stop12,stop22))
50588 
50589  vh3b(1,2) =
50590  * - mbot4/(cosbb**2)*xmu*(ab-xmu*tanbsb)/
50591  * (sbot1**2-sbot2**2)*(log(sbot1**2/sbot2**2) + ab*
50592  * (ab - xmu*tanbsb)/(sbot1**2-sbot2**2)*g(sbot12,sbot22))
50593 
50594 
50595  vh3t(1,2)=vh3t(1,2) +
50596  *mz**2*(mtop2/tanbst*f1t-dsqrt(mtop2)*(at/tanbst+xmu)/2d0*f2t)
50597 
50598  vh3b(1,2)=vh3b(1,2) +
50599  *mz**2*(-mbot2*tanbsb*f1b+dsqrt(mbot2)*(ab*tanbsb+xmu)/2d0*f2b)
50600 
50601  vh3t(2,1) = vh3t(1,2)
50602  vh3b(2,1) = vh3b(1,2)
50603 
50604 C TQ = LOG((MQ2 + MTOP2)/MTOP2)
50605 C TU = LOG((MUR2+MTOP2)/MTOP2)
50606 C TQD = LOG((MQ2 + MB**2)/MB**2)
50607 C TD = LOG((MD2+MB**2)/MB**2)
50608 
50609  DO 110 i = 1,2
50610  DO 100 j = 1,2
50611  vh(i,j) =
50612  * 6d0/(8d0*pi**2*(h1t**2+h2t**2))
50613  * *vh3t(i,j)*0.5d0*(1d0-al(i,j)*tt/2d0) +
50614  * 6d0/(8d0*pi**2*(h1b**2+h2b**2))
50615  * *vh3b(i,j)*0.5d0*(1d0-al(i,j)*tb/2d0)
50616  100 CONTINUE
50617  110 CONTINUE
50618 
50619  goto 150
50620  120 DO 140 i =1,2
50621  DO 130 j = 1,2
50622  vh(i,j) = -1d15
50623  130 CONTINUE
50624  140 CONTINUE
50625 
50626 
50627  150 RETURN
50628  END
50629 
50630 
50631 
50632 
50633 
50634 C*********************************************************************
50635 
50636 C...PYFINT
50637 C...Auxiliary routine to PYPOLE for SUSY Higgs calculations.
50638 
50639  FUNCTION pyfint(A,B,C)
50640 
50641 C...Double precision and integer declarations.
50642  IMPLICIT DOUBLE PRECISION(a-h, o-z)
50643  IMPLICIT INTEGER(i-n)
50644  INTEGER pyk,pychge,pycomp
50645 C...Commonblock.
50646  common/pyints/xxm(20)
50647  SAVE/pyints/
50648 
50649 C...Local variables.
50650  EXTERNAL pyfisb
50651  DOUBLE PRECISION pyfisb
50652 
50653  xxm(1)=a
50654  xxm(2)=b
50655  xxm(3)=c
50656  xlo=0d0
50657  xhi=1d0
50658  pyfint = pygaus(pyfisb,xlo,xhi,1d-3)
50659 
50660  RETURN
50661  END
50662 
50663 C*********************************************************************
50664 
50665 C...PYFISB
50666 C...Auxiliary routine to PYFINT for SUSY Higgs calculations.
50667 
50668  FUNCTION pyfisb(X)
50669 
50670 C...Double precision and integer declarations.
50671  IMPLICIT DOUBLE PRECISION(a-h, o-z)
50672  IMPLICIT INTEGER(i-n)
50673  INTEGER pyk,pychge,pycomp
50674 C...Commonblock.
50675  common/pyints/xxm(20)
50676  SAVE/pyints/
50677 
50678  pyfisb = log(abs(x*xxm(2)+(1-x)*xxm(3)-x*(1-x)*xxm(1))/
50679  &(x*(xxm(2)-xxm(3))+xxm(3)))
50680 
50681  RETURN
50682  END
50683 
50684 C*********************************************************************
50685 
50686 C...PYSFDC
50687 C...Calculates decays of sfermions.
50688 
50689  SUBROUTINE pysfdc(KFIN,XLAM,IDLAM,IKNT)
50690 
50691 C...Double precision and integer declarations.
50692  IMPLICIT DOUBLE PRECISION(a-h, o-z)
50693  IMPLICIT INTEGER(i-n)
50694  INTEGER pyk,pychge,pycomp
50695 C...Parameter statement to help give large particle numbers.
50696  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
50697  &kexcit=4000000,kdimen=5000000)
50698 C...Commonblocks.
50699  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
50700  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
50701  common/pymssm/imss(0:99),rmss(0:99)
50702  common/pyssmt/zmix(4,4),umix(2,2),vmix(2,2),smz(4),smw(2),
50703  &sfmix(16,4),zmixi(4,4),umixi(2,2),vmixi(2,2)
50704  SAVE /pydat1/,/pydat2/,/pymssm/,/pyssmt/
50705 
50706 C...Local variables.
50707  COMPLEX*16 zmixc(4,4),vmixc(2,2),umixc(2,2)
50708  COMPLEX*16 cal,car,cbl,cbr,calp,carp,cblp,cbrp,ca,cb
50709  INTEGER kfin,kcin
50710  DOUBLE PRECISION xmi,xmj,xmf,xmsf1,xmsf2,xmw,xmw2,xmz,axmj
50711  DOUBLE PRECISION xmi2,xmi3,xma2,xmb2,xmfp
50712  DOUBLE PRECISION pylamf,xl
50713  DOUBLE PRECISION tanw,xw,aem,c1,as
50714  DOUBLE PRECISION al,ar,bl,br
50715  DOUBLE PRECISION ch1,ch2,ch3,ch4
50716  DOUBLE PRECISION xmbot,xmtop
50717  DOUBLE PRECISION xlam(0:400)
50718  INTEGER idlam(400,3)
50719  INTEGER lknt,ix,ilr,idu,j,i,iknt,ifl,ii
50720  DOUBLE PRECISION sr2
50721  DOUBLE PRECISION cbeta,sbeta
50722  DOUBLE PRECISION cw
50723  DOUBLE PRECISION beta,alfa,xmu,at,ab,atrit,atrib,atril
50724  DOUBLE PRECISION cosa,sina,tanb
50725  DOUBLE PRECISION pyalem,pi,pyalps,ei
50726  DOUBLE PRECISION ghrr,ghll,ghlr,xmb,blr
50727  INTEGER ig,kf1,kf2
50728  INTEGER igg(4),kfnchi(4),kfcchi(2)
50729  DATA igg/23,25,35,36/
50730  DATA pi/3.141592654d0/
50731  DATA sr2/1.4142136d0/
50732  DATA kfnchi/1000022,1000023,1000025,1000035/
50733  DATA kfcchi/1000024,1000037/
50734 
50735 C...COUNT THE NUMBER OF DECAY MODES
50736  lknt=0
50737 
50738 C...NO NU_R DECAYS
50739  IF(kfin.EQ.ksusy2+12.OR.kfin.EQ.ksusy2+14.OR.
50740  &kfin.EQ.ksusy2+16) RETURN
50741 
50742  xmw=pmas(24,1)
50743  xmw2=xmw**2
50744  xmz=pmas(23,1)
50745  xw=paru(102)
50746  tanw = sqrt(xw/(1d0-xw))
50747  cw=sqrt(1d0-xw)
50748 
50749  DO 110 i=1,4
50750  DO 100 j=1,4
50751  zmixc(j,i)=dcmplx(zmix(j,i),zmixi(j,i))
50752  100 CONTINUE
50753  110 CONTINUE
50754  DO 130 i=1,2
50755  DO 120 j=1,2
50756  vmixc(j,i)=dcmplx(vmix(j,i),vmixi(j,i))
50757  umixc(j,i)=dcmplx(umix(j,i),umixi(j,i))
50758  120 CONTINUE
50759  130 CONTINUE
50760 
50761 C...KCIN
50762  kcin=pycomp(kfin)
50763 C...ILR is 1 for left and 2 for right.
50764  ilr=kfin/ksusy1
50765 C...IFL is matching non-SUSY flavour.
50766  ifl=mod(kfin,ksusy1)
50767 C...IDU is weak isospin, 1 for down and 2 for up.
50768  idu=2-mod(ifl,2)
50769 
50770  xmi=pmas(kcin,1)
50771  xmi2=xmi**2
50772  aem=pyalem(xmi2)
50773  as =pyalps(xmi2)
50774  c1=aem/xw
50775  xmi3=xmi**3
50776  ei=kchg(ifl,1)/3d0
50777 
50778  xmbot=pymrun(5,xmi2)
50779  xmtop=pymrun(6,xmi2)
50780 
50781  tanb=rmss(5)
50782  beta=atan(tanb)
50783  alfa=rmss(18)
50784  cbeta=cos(beta)
50785  sbeta=tanb*cbeta
50786  sina=sin(alfa)
50787  cosa=cos(alfa)
50788  xmu=-rmss(4)
50789  atrit=rmss(16)
50790  atrib=rmss(15)
50791  atril=rmss(17)
50792 
50793 C...2-BODY DECAYS OF SFERMION -> GRAVITINO + FERMION
50794 
50795  IF(imss(11).EQ.1) THEN
50796  xmp=rmss(29)
50797  idg=39+ksusy1
50798  xmgr=pmas(pycomp(idg),1)
50799  xfac=(xmi2/(xmp*xmgr))**2*xmi/48d0/pi
50800  IF(ifl.EQ.5) THEN
50801  xmf=xmbot
50802  ELSEIF(ifl.EQ.6) THEN
50803  xmf=xmtop
50804  ELSE
50805  xmf=pmas(ifl,1)
50806  ENDIF
50807  IF(xmi.GT.xmgr+xmf) THEN
50808  lknt=lknt+1
50809  idlam(lknt,1)=idg
50810  idlam(lknt,2)=ifl
50811  idlam(lknt,3)=0
50812  xlam(lknt)=xfac*(1d0-xmf**2/xmi2)**4
50813  ENDIF
50814  ENDIF
50815 
50816 C...2-BODY DECAYS OF SFERMION -> FERMION + GAUGE/GAUGINO
50817 
50818 C...CHARGED DECAYS:
50819  DO 140 ix=1,2
50820 C...DI -> U CHI1-,CHI2-
50821  IF(idu.EQ.1) THEN
50822  xmfp=pmas(ifl+1,1)
50823  xmf =pmas(ifl,1)
50824 C...UI -> D CHI1+,CHI2+
50825  ELSE
50826  xmfp=pmas(ifl-1,1)
50827  xmf =pmas(ifl,1)
50828  ENDIF
50829  xmj=smw(ix)
50830  axmj=abs(xmj)
50831  IF(xmi.GE.axmj+xmfp) THEN
50832  xma2=xmj**2
50833  xmb2=xmfp**2
50834  IF(idu.EQ.2) THEN
50835  IF(ifl.EQ.6) THEN
50836  xmfp=xmbot
50837  xmf =xmtop
50838  ELSEIF(ifl.LT.6) THEN
50839  xmf=0d0
50840  xmfp=0d0
50841  ENDIF
50842  cbl=vmixc(ix,1)
50843  cal=-xmfp*umixc(ix,2)/sr2/xmw/cbeta
50844  cbr=-xmf*vmixc(ix,2)/sr2/xmw/sbeta
50845  car=0d0
50846  ELSE
50847  IF(ifl.EQ.5) THEN
50848  xmf =xmbot
50849  xmfp=xmtop
50850  ELSEIF(ifl.LT.5) THEN
50851  xmf=0d0
50852  xmfp=0d0
50853  ENDIF
50854  cbl=umixc(ix,1)
50855  cal=-xmfp*vmixc(ix,2)/sr2/xmw/sbeta
50856  cbr=-xmf*umixc(ix,2)/sr2/xmw/cbeta
50857  car=0d0
50858  ENDIF
50859 
50860  calp=sfmix(ifl,1)*cal + sfmix(ifl,2)*car
50861  cblp=sfmix(ifl,1)*cbl + sfmix(ifl,2)*cbr
50862  carp=sfmix(ifl,4)*car + sfmix(ifl,3)*cal
50863  cbrp=sfmix(ifl,4)*cbr + sfmix(ifl,3)*cbl
50864  cal=calp
50865  cbl=cblp
50866  car=carp
50867  cbr=cbrp
50868 
50869 C...F1 -> F` CHI
50870  IF(ilr.EQ.1) THEN
50871  ca=cal
50872  cb=cbl
50873 C...F2 -> F` CHI
50874  ELSE
50875  ca=car
50876  cb=cbr
50877  ENDIF
50878  lknt=lknt+1
50879  xl=pylamf(xmi2,xma2,xmb2)
50880 C...SPIN AVERAGE = 1/1 NOT 1/2....NO COLOR ENHANCEMENT
50881  xlam(lknt)=2d0*c1/8d0/xmi3*sqrt(xl)*((xmi2-xmb2-xma2)*
50882  & (abs(ca)**2+abs(cb)**2)-4d0*dble(ca*dconjg(cb))*xmj*xmfp)
50883  idlam(lknt,3)=0
50884  IF(idu.EQ.1) THEN
50885  idlam(lknt,1)=-kfcchi(ix)
50886  idlam(lknt,2)=ifl+1
50887  ELSE
50888  idlam(lknt,1)=kfcchi(ix)
50889  idlam(lknt,2)=ifl-1
50890  ENDIF
50891  ENDIF
50892  140 CONTINUE
50893 
50894 C...NEUTRAL DECAYS
50895  DO 150 ix=1,4
50896 C...DI -> D CHI10
50897  xmf=pmas(ifl,1)
50898  xmj=smz(ix)
50899  axmj=abs(xmj)
50900  IF(xmi.GE.axmj+xmf) THEN
50901  xma2=xmj**2
50902  xmb2=xmf**2
50903  IF(idu.EQ.1) THEN
50904  IF(ifl.EQ.5) THEN
50905  xmf=xmbot
50906  ELSEIF(ifl.LT.5) THEN
50907  xmf=0d0
50908  ENDIF
50909  cbl=-zmixc(ix,2)+tanw*zmixc(ix,1)*(2d0*ei+1)
50910  cal=xmf*zmixc(ix,3)/xmw/cbeta
50911  car=-2d0*ei*tanw*zmixc(ix,1)
50912  cbr=cal
50913  ELSE
50914  IF(ifl.EQ.6) THEN
50915  xmf=xmtop
50916  ELSEIF(ifl.LT.5) THEN
50917  xmf=0d0
50918  ENDIF
50919  cbl=zmixc(ix,2)+tanw*zmixc(ix,1)*(2d0*ei-1)
50920  cal=xmf*zmixc(ix,4)/xmw/sbeta
50921  car=-2d0*ei*tanw*zmixc(ix,1)
50922  cbr=cal
50923  ENDIF
50924 
50925  calp=sfmix(ifl,1)*cal + sfmix(ifl,2)*car
50926  cblp=sfmix(ifl,1)*cbl + sfmix(ifl,2)*cbr
50927  carp=sfmix(ifl,4)*car + sfmix(ifl,3)*cal
50928  cbrp=sfmix(ifl,4)*cbr + sfmix(ifl,3)*cbl
50929  cal=calp
50930  cbl=cblp
50931  car=carp
50932  cbr=cbrp
50933 
50934 C...F1 -> F CHI
50935  IF(ilr.EQ.1) THEN
50936  ca=cal
50937  cb=cbl
50938 C...F2 -> F CHI
50939  ELSE
50940  ca=car
50941  cb=cbr
50942  ENDIF
50943  lknt=lknt+1
50944  xl=pylamf(xmi2,xma2,xmb2)
50945 C...SPIN AVERAGE = 1/1 NOT 1/2....NO COLOR ENHANCEMENT
50946  xlam(lknt)=c1/8d0/xmi3*sqrt(xl)*((xmi2-xmb2-xma2)*
50947  & (abs(ca)**2+abs(cb)**2)-4d0*dble(ca*dconjg(cb))*xmj*xmf)
50948  idlam(lknt,1)=kfnchi(ix)
50949  idlam(lknt,2)=ifl
50950  idlam(lknt,3)=0
50951  ENDIF
50952  150 CONTINUE
50953 
50954 C...2-BODY DECAYS TO SM GAUGE AND HIGGS BOSONS
50955 C...IG=23,25,35,36
50956  DO 160 ii=1,4
50957  ig=igg(ii)
50958  IF(ilr.EQ.1) goto 160
50959  xmb=pmas(ig,1)
50960  xmsf1=pmas(pycomp(kfin-ksusy1),1)
50961  IF(xmi.LT.xmsf1+xmb) goto 160
50962  IF(ig.EQ.23) THEN
50963  bl=-sign(.5d0,ei)/cw+ei*xw/cw
50964  br=ei*xw/cw
50965  blr=0d0
50966  ELSEIF(ig.EQ.25) THEN
50967  IF(ifl.EQ.5) THEN
50968  xmf=xmbot
50969  ELSEIF(ifl.EQ.6) THEN
50970  xmf=xmtop
50971  ELSEIF(ifl.LT.5) THEN
50972  xmf=0d0
50973  ELSE
50974  xmf=pmas(ifl,1)
50975  ENDIF
50976  IF(idu.EQ.2) THEN
50977  ghll=xmz/cw*(0.5d0-ei*xw)*(-sin(alfa+beta))+
50978  & xmf**2/xmw*cosa/sbeta
50979  ghrr=xmz/cw*(ei*xw)*(-sin(alfa+beta))+
50980  & xmf**2/xmw*cosa/sbeta
50981  ELSE
50982  ghll=xmz/cw*(0.5d0-ei*xw)*(-sin(alfa+beta))+
50983  & xmf**2/xmw*(-sina)/cbeta
50984  ghrr=xmz/cw*(ei*xw)*(-sin(alfa+beta))+
50985  & xmf**2/xmw*(-sina)/cbeta
50986  ENDIF
50987  IF(ifl.EQ.5) THEN
50988  at=atrib
50989  ELSEIF(ifl.EQ.6) THEN
50990  at=atrit
50991  ELSEIF(ifl.EQ.15) THEN
50992  at=atril
50993  ELSE
50994  at=0d0
50995  ENDIF
50996 C.........need to complexify
50997  IF(idu.EQ.2) THEN
50998  ghlr=xmf/2d0/xmw/sbeta*(-xmu*sina+
50999  & at*cosa)
51000  ELSE
51001  ghlr=xmf/2d0/xmw/cbeta*(xmu*cosa-
51002  & at*sina)
51003  ENDIF
51004  bl=ghll
51005  br=ghrr
51006  blr=-ghlr
51007  ELSEIF(ig.EQ.35) THEN
51008  IF(ifl.EQ.5) THEN
51009  xmf=xmbot
51010  ELSEIF(ifl.EQ.6) THEN
51011  xmf=xmtop
51012  ELSEIF(ifl.LT.5) THEN
51013  xmf=0d0
51014  ELSE
51015  xmf=pmas(ifl,1)
51016  ENDIF
51017  IF(idu.EQ.2) THEN
51018  ghll=xmz/cw*(0.5d0-ei*xw)*cos(alfa+beta)+
51019  & xmf**2/xmw*sina/sbeta
51020  ghrr=xmz/cw*(ei*xw)*cos(alfa+beta)+
51021  & xmf**2/xmw*sina/sbeta
51022  ELSE
51023  ghll=xmz/cw*(0.5d0-ei*xw)*cos(alfa+beta)+
51024  & xmf**2/xmw*cosa/cbeta
51025  ghrr=xmz/cw*(ei*xw)*cos(alfa+beta)+
51026  & xmf**2/xmw*cosa/cbeta
51027  ENDIF
51028  IF(ifl.EQ.5) THEN
51029  at=atrib
51030  ELSEIF(ifl.EQ.6) THEN
51031  at=atrit
51032  ELSEIF(ifl.EQ.15) THEN
51033  at=atril
51034  ELSE
51035  at=0d0
51036  ENDIF
51037 C.........Need to complexify
51038  IF(idu.EQ.2) THEN
51039  ghlr=xmf/2d0/xmw/sbeta*(xmu*cosa+
51040  & at*sina)
51041  ELSE
51042  ghlr=xmf/2d0/xmw/cbeta*(xmu*sina+
51043  & at*cosa)
51044  ENDIF
51045  bl=ghll
51046  br=ghrr
51047  blr=ghlr
51048  ELSEIF(ig.EQ.36) THEN
51049  ghll=0d0
51050  ghrr=0d0
51051  IF(ifl.EQ.5) THEN
51052  xmf=xmbot
51053  ELSEIF(ifl.EQ.6) THEN
51054  xmf=xmtop
51055  ELSEIF(ifl.LT.5) THEN
51056  xmf=0d0
51057  ELSE
51058  xmf=pmas(ifl,1)
51059  ENDIF
51060  IF(ifl.EQ.5) THEN
51061  at=atrib
51062  ELSEIF(ifl.EQ.6) THEN
51063  at=atrit
51064  ELSEIF(ifl.EQ.15) THEN
51065  at=atril
51066  ELSE
51067  at=0d0
51068  ENDIF
51069 C.........Need to complexify
51070  IF(idu.EQ.2) THEN
51071  ghlr=xmf/2d0/xmw*(-xmu+at/tanb)
51072  ELSE
51073  ghlr=xmf/2d0/xmw/(-xmu+at*tanb)
51074  ENDIF
51075  bl=ghll
51076  br=ghrr
51077  blr=ghlr
51078  ENDIF
51079  al=sfmix(ifl,1)*sfmix(ifl,3)*bl+
51080  & sfmix(ifl,2)*sfmix(ifl,4)*br+
51081  & (sfmix(ifl,1)*sfmix(ifl,4)+sfmix(ifl,3)*sfmix(ifl,2))*blr
51082  xl=pylamf(xmi2,xmsf1**2,xmb**2)
51083  lknt=lknt+1
51084  IF(ig.EQ.23) THEN
51085  xlam(lknt)=c1/4d0/xmi3*xl**1.5d0/xmb**2*al**2
51086  ELSE
51087  xlam(lknt)=c1/4d0/xmi3*sqrt(xl)*al**2
51088  ENDIF
51089  idlam(lknt,3)=0
51090  idlam(lknt,1)=kfin-ksusy1
51091  idlam(lknt,2)=ig
51092  160 CONTINUE
51093 
51094 C...SF -> SF' + W
51095  xmb=pmas(24,1)
51096  IF(mod(ifl,2).EQ.0) THEN
51097  kf1=ksusy1+ifl-1
51098  ELSE
51099  kf1=ksusy1+ifl+1
51100  ENDIF
51101  kf2=kf1+ksusy1
51102  xmsf1=pmas(pycomp(kf1),1)
51103  xmsf2=pmas(pycomp(kf2),1)
51104  IF(xmi.GT.xmb+xmsf1) THEN
51105  IF(mod(ifl,2).EQ.0) THEN
51106  IF(ilr.EQ.1) THEN
51107  al=1d0/sr2*sfmix(ifl,1)*sfmix(ifl-1,1)
51108  ELSE
51109  al=1d0/sr2*sfmix(ifl,3)*sfmix(ifl-1,1)
51110  ENDIF
51111  ELSE
51112  IF(ilr.EQ.1) THEN
51113  al=1d0/sr2*sfmix(ifl,1)*sfmix(ifl+1,1)
51114  ELSE
51115  al=1d0/sr2*sfmix(ifl,3)*sfmix(ifl+1,1)
51116  ENDIF
51117  ENDIF
51118  xl=pylamf(xmi2,xmsf1**2,xmb**2)
51119  lknt=lknt+1
51120  xlam(lknt)=c1/4d0/xmi3*xl**1.5d0/xmb**2*al**2
51121  idlam(lknt,3)=0
51122  idlam(lknt,1)=kf1
51123  idlam(lknt,2)=sign(24,kchg(ifl,1))
51124  ENDIF
51125  IF(xmi.GT.xmb+xmsf2) THEN
51126  IF(mod(ifl,2).EQ.0) THEN
51127  IF(ilr.EQ.1) THEN
51128  al=1d0/sr2*sfmix(ifl,1)*sfmix(ifl-1,3)
51129  ELSE
51130  al=1d0/sr2*sfmix(ifl,3)*sfmix(ifl-1,3)
51131  ENDIF
51132  ELSE
51133  IF(ilr.EQ.1) THEN
51134  al=1d0/sr2*sfmix(ifl,1)*sfmix(ifl+1,3)
51135  ELSE
51136  al=1d0/sr2*sfmix(ifl,3)*sfmix(ifl+1,3)
51137  ENDIF
51138  ENDIF
51139  xl=pylamf(xmi2,xmsf2**2,xmb**2)
51140  lknt=lknt+1
51141  xlam(lknt)=c1/4d0/xmi3*xl**1.5d0/xmb**2*al**2
51142  idlam(lknt,3)=0
51143  idlam(lknt,1)=kf2
51144  idlam(lknt,2)=sign(24,kchg(ifl,1))
51145  ENDIF
51146 
51147 C...SF -> SF' + HC
51148  xmb=pmas(37,1)
51149  IF(mod(ifl,2).EQ.0) THEN
51150  kf1=ksusy1+ifl-1
51151  ELSE
51152  kf1=ksusy1+ifl+1
51153  ENDIF
51154  kf2=kf1+ksusy1
51155  xmsf1=pmas(pycomp(kf1),1)
51156  xmsf2=pmas(pycomp(kf2),1)
51157  IF(xmi.GT.xmb+xmsf1) THEN
51158  xmf=0d0
51159  xmfp=0d0
51160  at=0d0
51161  ab=0d0
51162  IF(mod(ifl,2).EQ.0) THEN
51163 C...T1-> B1 HC
51164  IF(ilr.EQ.1) THEN
51165  ch1=-sfmix(ifl,1)*sfmix(ifl-1,1)
51166  ch2= sfmix(ifl,2)*sfmix(ifl-1,2)
51167  ch3=-sfmix(ifl,1)*sfmix(ifl-1,2)
51168  ch4=-sfmix(ifl,2)*sfmix(ifl-1,1)
51169 C...T2-> B1 HC
51170  ELSE
51171  ch1= sfmix(ifl,3)*sfmix(ifl-1,1)
51172  ch2=-sfmix(ifl,4)*sfmix(ifl-1,2)
51173  ch3= sfmix(ifl,3)*sfmix(ifl-1,2)
51174  ch4= sfmix(ifl,4)*sfmix(ifl-1,1)
51175  ENDIF
51176  IF(ifl.EQ.6) THEN
51177  xmf=xmtop
51178  xmfp=xmbot
51179  at=atrit
51180  ab=atrib
51181  ENDIF
51182  ELSE
51183 C...B1 -> T1 HC
51184  IF(ilr.EQ.1) THEN
51185  ch1=-sfmix(ifl+1,1)*sfmix(ifl,1)
51186  ch2= sfmix(ifl+1,2)*sfmix(ifl,2)
51187  ch3=-sfmix(ifl+1,1)*sfmix(ifl,2)
51188  ch4=-sfmix(ifl+1,2)*sfmix(ifl,1)
51189 C...B2-> T1 HC
51190  ELSE
51191  ch1= sfmix(ifl,3)*sfmix(ifl+1,1)
51192  ch2=-sfmix(ifl,4)*sfmix(ifl+1,2)
51193  ch3= sfmix(ifl,4)*sfmix(ifl+1,1)
51194  ch4= sfmix(ifl,3)*sfmix(ifl+1,2)
51195  ENDIF
51196  IF(ifl.EQ.5) THEN
51197  xmf=xmtop
51198  xmfp=xmbot
51199  at=atrit
51200  ab=atrib
51201  ENDIF
51202  ENDIF
51203  xl=pylamf(xmi2,xmsf1**2,xmb**2)
51204  lknt=lknt+1
51205 C.......Need to complexify
51206  al=ch1*(xmw2*2d0*cbeta*sbeta-xmfp**2*tanb-xmf**2/tanb)+
51207  & ch2*2d0*xmf*xmfp/(2d0*cbeta*sbeta)+
51208  & ch3*xmfp*(-xmu+ab*tanb)+ch4*xmf*(-xmu+at/tanb)
51209  xlam(lknt)=c1/8d0/xmi3*sqrt(xl)/xmw2*al**2
51210  idlam(lknt,3)=0
51211  idlam(lknt,1)=kf1
51212  idlam(lknt,2)=sign(37,kchg(ifl,1))
51213  ENDIF
51214  IF(xmi.GT.xmb+xmsf2) THEN
51215  xmf=0d0
51216  xmfp=0d0
51217  at=0d0
51218  ab=0d0
51219  IF(mod(ifl,2).EQ.0) THEN
51220 C...T1-> B2 HC
51221  IF(ilr.EQ.1) THEN
51222  ch1= sfmix(ifl-1,3)*sfmix(ifl,1)
51223  ch2=-sfmix(ifl-1,4)*sfmix(ifl,2)
51224  ch3= sfmix(ifl-1,4)*sfmix(ifl,1)
51225  ch4= sfmix(ifl-1,3)*sfmix(ifl,2)
51226 C...T2-> B2 HC
51227  ELSE
51228  ch1= -sfmix(ifl,3)*sfmix(ifl-1,3)
51229  ch2= sfmix(ifl,4)*sfmix(ifl-1,4)
51230  ch3= -sfmix(ifl,3)*sfmix(ifl-1,4)
51231  ch4= -sfmix(ifl,4)*sfmix(ifl-1,3)
51232  ENDIF
51233  IF(ifl.EQ.6) THEN
51234  xmf=xmtop
51235  xmfp=xmbot
51236  at=atrit
51237  ab=atrib
51238  ENDIF
51239  ELSE
51240 C...B1 -> T2 HC
51241  IF(ilr.EQ.1) THEN
51242  ch1= sfmix(ifl+1,3)*sfmix(ifl,1)
51243  ch2=-sfmix(ifl+1,4)*sfmix(ifl,2)
51244  ch3= sfmix(ifl+1,3)*sfmix(ifl,2)
51245  ch4= sfmix(ifl+1,4)*sfmix(ifl,1)
51246 C...B2-> T2 HC
51247  ELSE
51248  ch1= -sfmix(ifl+1,3)*sfmix(ifl,3)
51249  ch2= sfmix(ifl+1,4)*sfmix(ifl,4)
51250  ch3= -sfmix(ifl+1,3)*sfmix(ifl,4)
51251  ch4= -sfmix(ifl+1,4)*sfmix(ifl,3)
51252  ENDIF
51253  IF(ifl.EQ.5) THEN
51254  xmf=xmtop
51255  xmfp=xmbot
51256  at=atrit
51257  ab=atrib
51258  ENDIF
51259  ENDIF
51260  xl=pylamf(xmi2,xmsf1**2,xmb**2)
51261  lknt=lknt+1
51262 C.......Need to complexify
51263  al=ch1*(xmw2*2d0*cbeta*sbeta-xmfp**2*tanb-xmf**2/tanb)+
51264  & ch2*2d0*xmf*xmfp/(2d0*cbeta*sbeta)+
51265  & ch3*xmfp*(-xmu+ab*tanb)+ch4*xmf*(-xmu+at/tanb)
51266  xlam(lknt)=c1/8d0/xmi3*sqrt(xl)/xmw2*al**2
51267  idlam(lknt,3)=0
51268  idlam(lknt,1)=kf2
51269  idlam(lknt,2)=sign(37,kchg(ifl,1))
51270  ENDIF
51271 
51272 C...2-BODY DECAYS OF SQUARK -> QUARK GLUINO
51273 
51274  IF(ifl.LE.6) THEN
51275  xmfp=0d0
51276  xmf=0d0
51277  IF(ifl.EQ.6) xmf=pmas(6,1)
51278  IF(ifl.EQ.5) xmf=pmas(5,1)
51279  xmj=pmas(pycomp(ksusy1+21),1)
51280  axmj=abs(xmj)
51281  IF(xmi.GE.axmj+xmf) THEN
51282  al=-sfmix(ifl,3)
51283  bl=sfmix(ifl,1)
51284  ar=-sfmix(ifl,4)
51285  br=sfmix(ifl,2)
51286 C...F1 -> F CHI
51287  IF(ilr.EQ.1) THEN
51288  xca=al
51289  xcb=bl
51290 C...F2 -> F CHI
51291  ELSE
51292  xca=ar
51293  xcb=br
51294  ENDIF
51295  lknt=lknt+1
51296  xma2=xmj**2
51297  xmb2=xmf**2
51298  xl=pylamf(xmi2,xma2,xmb2)
51299  xlam(lknt)=4d0/3d0*as/2d0/xmi3*sqrt(xl)*((xmi2-xmb2-xma2)*
51300  & (xca**2+xcb**2)+4d0*xca*xcb*xmj*xmf)
51301  idlam(lknt,1)=ksusy1+21
51302  idlam(lknt,2)=ifl
51303  idlam(lknt,3)=0
51304  ENDIF
51305  ENDIF
51306 
51307 C...IF NOTHING ELSE FOR T1, THEN T1* -> C+CHI0
51308  IF(kfin.EQ.ksusy1+6.AND.pmas(kcin,1).GT.
51309  &pmas(pycomp(ksusy1+22),1)+pmas(4,1)) THEN
51310 C...THIS IS A BACK-OF-THE-ENVELOPE ESTIMATE
51311 C...M = 1/(16PI**2)G**3 = G*2/(4PI) G/(4PI) = C1 * G/(4PI)
51312 C...M*M = C1**2 * G**2/(16PI**2)
51313 C...G = 1/(8PI)P/MI**2 * M*M = C1**3/(32PI**2)*LAM/(2*MI**3)
51314  lknt=lknt+1
51315  xl=pylamf(xmi2,0d0,pmas(pycomp(ksusy1+22),1)**2)
51316  xlam(lknt)=c1**3/64d0/pi**2/xmi3*sqrt(xl)
51317  IF(xlam(lknt).EQ.0) xlam(lknt)=1d-3
51318  idlam(lknt,1)=ksusy1+22
51319  idlam(lknt,2)=4
51320  idlam(lknt,3)=0
51321  ENDIF
51322 
51323 C...R-violating sfermion decays (SKANDS).
51324  CALL pyrvsf(kfin,xlam,idlam,lknt)
51325 
51326  iknt=lknt
51327  xlam(0)=0d0
51328  DO 170 i=1,iknt
51329  IF(xlam(i).LT.0d0) xlam(i)=0d0
51330  xlam(0)=xlam(0)+xlam(i)
51331  170 CONTINUE
51332  IF(xlam(0).EQ.0d0) xlam(0)=1d-3
51333 
51334  RETURN
51335  END
51336 
51337 C*********************************************************************
51338 
51339 C...PYGLUI
51340 C...Calculates gluino decay modes.
51341 
51342  SUBROUTINE pyglui(KFIN,XLAM,IDLAM,IKNT)
51343 
51344 C...Double precision and integer declarations.
51345  IMPLICIT DOUBLE PRECISION(a-h, o-z)
51346  IMPLICIT INTEGER(i-n)
51347  INTEGER pyk,pychge,pycomp
51348 C...Parameter statement to help give large particle numbers.
51349  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
51350  &kexcit=4000000,kdimen=5000000)
51351 C...Commonblocks.
51352  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
51353  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
51354  common/pymssm/imss(0:99),rmss(0:99)
51355  common/pyssmt/zmix(4,4),umix(2,2),vmix(2,2),smz(4),smw(2),
51356  &sfmix(16,4),zmixi(4,4),umixi(2,2),vmixi(2,2)
51357 CC &SFMIX(16,4),
51358 C COMMON/PYINTS/XXM(20)
51359  COMPLEX*16 cxc
51360  common/pyintc/xxc(10),cxc(8)
51361  SAVE /pydat1/,/pydat2/,/pymssm/,/pyssmt/,/pyintc/
51362 
51363 C...Local variables
51364  COMPLEX*16 zmixc(4,4),vmixc(2,2),umixc(2,2),olpp,orpp,glij,grij
51365  DOUBLE PRECISION xmi,xmj,xmf,axmj,axmi
51366  DOUBLE PRECISION xmi2,xmi3,xma2,xmb2,xmfp
51367  DOUBLE PRECISION pylamf,xl
51368  DOUBLE PRECISION tanw,xw,aem,c1,as,s12max,s12min
51369  DOUBLE PRECISION ca,cb,al,ar,bl,br
51370  DOUBLE PRECISION xlam(0:400)
51371  INTEGER idlam(400,3)
51372  INTEGER lknt,ix,ilr,i,iknt,ifl
51373  DOUBLE PRECISION sr2
51374  DOUBLE PRECISION gam
51375  DOUBLE PRECISION pyalem,pi,pyalps,ei,t3i
51376  EXTERNAL pygaus,pyxxz6
51377  DOUBLE PRECISION pygaus,pyxxz6
51378  DOUBLE PRECISION prec
51379  INTEGER kfnchi(4),kfcchi(2)
51380  DATA pi/3.141592654d0/
51381  DATA sr2/1.4142136d0/
51382  DATA prec/1d-2/
51383  DATA kfnchi/1000022,1000023,1000025,1000035/
51384  DATA kfcchi/1000024,1000037/
51385 
51386 C...COUNT THE NUMBER OF DECAY MODES
51387  lknt=0
51388  IF(kfin.NE.ksusy1+21) RETURN
51389  kcin=pycomp(kfin)
51390 
51391  xw=paru(102)
51392  tanw = sqrt(xw/(1d0-xw))
51393 
51394  xmi=pmas(kcin,1)
51395  axmi=abs(xmi)
51396  xmi2=xmi**2
51397  aem=pyalem(xmi2)
51398  as =pyalps(xmi2)
51399  c1=aem/xw
51400  xmi3=axmi**3
51401 
51402  xmi=sign(xmi,rmss(3))
51403 
51404 C...2-BODY DECAYS OF GLUINO -> GRAVITINO GLUON
51405 
51406  IF(imss(11).EQ.1) THEN
51407  xmp=rmss(29)
51408  idg=39+ksusy1
51409  xmgr=pmas(pycomp(idg),1)
51410  xfac=(xmi2/(xmp*xmgr))**2*axmi/48d0/pi
51411  IF(axmi.GT.xmgr) THEN
51412  lknt=lknt+1
51413  idlam(lknt,1)=idg
51414  idlam(lknt,2)=21
51415  idlam(lknt,3)=0
51416  xlam(lknt)=xfac
51417  ENDIF
51418  ENDIF
51419 
51420 C...2-BODY DECAYS OF GLUINO -> QUARK SQUARK
51421 
51422  DO 110 ifl=1,6
51423  DO 100 ilr=1,2
51424  xmj=pmas(pycomp(ilr*ksusy1+ifl),1)
51425  axmj=abs(xmj)
51426  xmf=pmas(ifl,1)
51427  IF(axmi.GE.axmj+xmf) THEN
51428 C...Minus sign difference from gluino-quark-squark feynman rules
51429  al=sfmix(ifl,1)
51430  bl=-sfmix(ifl,3)
51431  ar=sfmix(ifl,2)
51432  br=-sfmix(ifl,4)
51433 C...F1 -> F CHI
51434  IF(ilr.EQ.1) THEN
51435  ca=al
51436  cb=bl
51437 C...F2 -> F CHI
51438  ELSE
51439  ca=ar
51440  cb=br
51441  ENDIF
51442  lknt=lknt+1
51443  xma2=xmj**2
51444  xmb2=xmf**2
51445  xl=pylamf(xmi2,xma2,xmb2)
51446  xlam(lknt)=4d0/8d0*as/4d0/xmi3*sqrt(xl)*((xmi2+xmb2-xma2)*
51447  & (ca**2+cb**2)-4d0*ca*cb*xmi*xmf)
51448  idlam(lknt,1)=ilr*ksusy1+ifl
51449  idlam(lknt,2)=-ifl
51450  idlam(lknt,3)=0
51451  lknt=lknt+1
51452  xlam(lknt)=xlam(lknt-1)
51453  idlam(lknt,1)=-idlam(lknt-1,1)
51454  idlam(lknt,2)=-idlam(lknt-1,2)
51455  idlam(lknt,3)=0
51456  ENDIF
51457  100 CONTINUE
51458  110 CONTINUE
51459 
51460 C...3-BODY DECAYS TO GAUGINO FERMION-FERMION
51461 C...GLUINO -> NI Q QBAR
51462  DO 170 ix=1,4
51463  xmj=smz(ix)
51464  axmj=abs(xmj)
51465  IF(axmi.GE.axmj) THEN
51466  DO 120 i=1,4
51467  zmixc(ix,i)=dcmplx(zmix(ix,i),zmixi(ix,i))
51468  120 CONTINUE
51469  olpp=dcmplx(cos(rmss(32)),sin(rmss(32)))/sr2
51470  orpp=dconjg(olpp)
51471  xxc(1)=0d0
51472  xxc(2)=xmj
51473  xxc(3)=0d0
51474  xxc(4)=xmi
51475  ia=1
51476  xxc(5)=pmas(pycomp(ksusy1+ia),1)
51477  xxc(6)=pmas(pycomp(ksusy2+ia),1)
51478  xxc(7)=xxc(5)
51479  xxc(8)=xxc(6)
51480  xxc(9)=1d6
51481  xxc(10)=0d0
51482  ei=kchg(ia,1)/3d0
51483  t3i=sign(1d0,ei+1d-6)/2d0
51484  glij=(t3i*zmixc(ix,2)-tanw*(t3i-ei)*zmixc(ix,1))*olpp
51485  grij=zmixc(ix,1)*(ei*tanw)*orpp
51486  cxc(1)=0d0
51487  cxc(2)=-glij
51488  cxc(3)=0d0
51489  cxc(4)=dconjg(glij)
51490  cxc(5)=0d0
51491  cxc(6)=grij
51492  cxc(7)=0d0
51493  cxc(8)=-dconjg(grij)
51494  s12min=0d0
51495  s12max=(axmi-axmj)**2
51496  IF( xxc(5).LT.axmi .OR. xxc(6).LT.axmi ) goto 130
51497  IF(axmi.GE.axmj+2d0*pmas(1,1)) THEN
51498  lknt=lknt+1
51499  xlam(lknt)=c1*as/xmi3/(16d0*pi)*
51500  & pygaus(pyxxz6,s12min,s12max,1d-2)
51501  idlam(lknt,1)=kfnchi(ix)
51502  idlam(lknt,2)=1
51503  idlam(lknt,3)=-1
51504  ENDIF
51505  IF(axmi.GE.axmj+2d0*pmas(3,1)) THEN
51506  lknt=lknt+1
51507  xlam(lknt)=xlam(lknt-1)
51508  idlam(lknt,1)=kfnchi(ix)
51509  idlam(lknt,2)=3
51510  idlam(lknt,3)=-3
51511  ENDIF
51512  130 CONTINUE
51513  IF(axmi.GE.axmj+2d0*pmas(5,1)) THEN
51514  pmold=pmas(pycomp(ksusy1+5),1)
51515  IF(axmi.GT.pmas(pycomp(ksusy2+5),1)+pmas(5,1)) THEN
51516  goto 140
51517  ELSEIF(axmi.GT.pmas(pycomp(ksusy1+5),1)+pmas(5,1)) THEN
51518  pmas(pycomp(ksusy1+5),1)=100d0*xmi
51519  ENDIF
51520  CALL pytbbn(ix,100,-1d0/3d0,xmi,gam)
51521  lknt=lknt+1
51522  xlam(lknt)=gam
51523  idlam(lknt,1)=kfnchi(ix)
51524  idlam(lknt,2)=5
51525  idlam(lknt,3)=-5
51526  pmas(pycomp(ksusy1+5),1)=pmold
51527  ENDIF
51528 C...U-TYPE QUARKS
51529  140 CONTINUE
51530  ia=2
51531  xxc(5)=pmas(pycomp(ksusy1+ia),1)
51532  xxc(6)=pmas(pycomp(ksusy2+ia),1)
51533 C IF( XXC(5).LT.AXMI .OR. XXC(6).LT.AXMI ) GOTO 290
51534  xxc(7)=xxc(5)
51535  xxc(8)=xxc(6)
51536  ei=kchg(ia,1)/3d0
51537  t3i=sign(1d0,ei+1d-6)/2d0
51538  glij=(t3i*zmixc(ix,2)-tanw*(t3i-ei)*zmixc(ix,1))*olpp
51539  grij=zmixc(ix,1)*(ei*tanw)*orpp
51540  cxc(2)=-glij
51541  cxc(4)=dconjg(glij)
51542  cxc(6)=grij
51543  cxc(8)=-dconjg(grij)
51544  IF( xxc(5).LT.axmi .OR. xxc(6).LT.axmi ) goto 150
51545  IF(axmi.GE.axmj+2d0*pmas(2,1)) THEN
51546  lknt=lknt+1
51547  xlam(lknt)=c1*as/xmi3/(16d0*pi)*
51548  & pygaus(pyxxz6,s12min,s12max,1d-2)
51549  idlam(lknt,1)=kfnchi(ix)
51550  idlam(lknt,2)=2
51551  idlam(lknt,3)=-2
51552  ENDIF
51553  IF(axmi.GE.axmj+2d0*pmas(4,1)) THEN
51554  lknt=lknt+1
51555  xlam(lknt)=xlam(lknt-1)
51556  idlam(lknt,1)=kfnchi(ix)
51557  idlam(lknt,2)=4
51558  idlam(lknt,3)=-4
51559  ENDIF
51560  150 CONTINUE
51561 C...INCLUDE THE DECAY GLUINO -> NJ + T + T~
51562 C...IF THE DECAY GLUINO -> ST + T CANNOT OCCUR
51563  xmf=pmas(6,1)
51564  IF(axmi.GE.axmj+2d0*xmf) THEN
51565  pmold=pmas(pycomp(ksusy1+6),1)
51566  IF(axmi.GT.pmas(pycomp(ksusy2+6),1)+xmf) THEN
51567  goto 160
51568  ELSEIF(axmi.GT.pmas(pycomp(ksusy1+6),1)+xmf) THEN
51569  pmas(pycomp(ksusy1+6),1)=100d0*xmi
51570  ENDIF
51571  CALL pytbbn(ix,100,2d0/3d0,xmi,gam)
51572  lknt=lknt+1
51573  xlam(lknt)=gam
51574  idlam(lknt,1)=kfnchi(ix)
51575  idlam(lknt,2)=6
51576  idlam(lknt,3)=-6
51577  pmas(pycomp(ksusy1+6),1)=pmold
51578  ENDIF
51579  160 CONTINUE
51580  ENDIF
51581  170 CONTINUE
51582 
51583 C...GLUINO -> CI Q QBAR'
51584  DO 210 ix=1,2
51585  xmj=smw(ix)
51586  axmj=abs(xmj)
51587  IF(axmi.GE.axmj) THEN
51588  DO 180 i=1,2
51589  vmixc(ix,i)=dcmplx(vmix(ix,i),vmixi(ix,i))
51590  umixc(ix,i)=dcmplx(umix(ix,i),umixi(ix,i))
51591  180 CONTINUE
51592  s12min=0d0
51593  s12max=(axmi-axmj)**2
51594  xxc(1)=0d0
51595  xxc(2)=xmj
51596  xxc(3)=0d0
51597  xxc(4)=xmi
51598  xxc(5)=pmas(pycomp(ksusy1+1),1)
51599  xxc(6)=pmas(pycomp(ksusy1+2),1)
51600  xxc(9)=1d6
51601  xxc(10)=0d0
51602  olpp=dcmplx(cos(rmss(32)),sin(rmss(32)))
51603  orpp=dconjg(olpp)
51604  cxc(1)=dcmplx(0d0,0d0)
51605  cxc(3)=dcmplx(0d0,0d0)
51606  cxc(5)=dcmplx(0d0,0d0)
51607  cxc(7)=dcmplx(0d0,0d0)
51608  cxc(2)=umixc(ix,1)*olpp/sr2
51609  cxc(4)=-dconjg(vmixc(ix,1))*orpp/sr2
51610  cxc(6)=dcmplx(0d0,0d0)
51611  cxc(8)=dcmplx(0d0,0d0)
51612  IF(xxc(5).LT.axmi) THEN
51613  xxc(5)=1d6
51614  ELSEIF(xxc(6).LT.axmi) THEN
51615  xxc(6)=1d6
51616  ENDIF
51617  xxc(7)=xxc(6)
51618  xxc(8)=xxc(5)
51619  IF( xxc(5).LT.axmi .OR. xxc(6).LT.axmi ) goto 190
51620  IF(axmi.GE.axmj+pmas(1,1)+pmas(2,1)) THEN
51621  lknt=lknt+1
51622  xlam(lknt)=0.5d0*c1*as/xmi3/(16d0*pi)*
51623  & pygaus(pyxxz6,s12min,s12max,prec)
51624  idlam(lknt,1)=kfcchi(ix)
51625  idlam(lknt,2)=1
51626  idlam(lknt,3)=-2
51627  lknt=lknt+1
51628  xlam(lknt)=xlam(lknt-1)
51629  idlam(lknt,1)=-idlam(lknt-1,1)
51630  idlam(lknt,2)=-idlam(lknt-1,2)
51631  idlam(lknt,3)=-idlam(lknt-1,3)
51632  ENDIF
51633  IF(axmi.GE.axmj+pmas(3,1)+pmas(4,1)) THEN
51634  lknt=lknt+1
51635  xlam(lknt)=xlam(lknt-1)
51636  idlam(lknt,1)=kfcchi(ix)
51637  idlam(lknt,2)=3
51638  idlam(lknt,3)=-4
51639  lknt=lknt+1
51640  xlam(lknt)=xlam(lknt-1)
51641  idlam(lknt,1)=-idlam(lknt-1,1)
51642  idlam(lknt,2)=-idlam(lknt-1,2)
51643  idlam(lknt,3)=-idlam(lknt-1,3)
51644  ENDIF
51645  190 CONTINUE
51646 
51647  xmf=pmas(6,1)
51648  xmfp=pmas(5,1)
51649  IF(axmi.GE.axmj+xmf+xmfp) THEN
51650  IF(xmi.GT.min(pmas(pycomp(ksusy1+5),1)+xmfp,
51651  $ pmas(pycomp(ksusy2+6),1)+xmf)) goto 200
51652  pmolt2=pmas(pycomp(ksusy2+6),1)
51653  pmolb2=pmas(pycomp(ksusy2+5),1)
51654  pmolt1=pmas(pycomp(ksusy1+6),1)
51655  pmolb1=pmas(pycomp(ksusy1+5),1)
51656  IF(xmi.GT.pmolt2+xmf) pmas(pycomp(ksusy2+6),1)=100d0*axmi
51657  IF(xmi.GT.pmolt1+xmf) pmas(pycomp(ksusy1+6),1)=100d0*axmi
51658  IF(xmi.GT.pmolb2+xmfp) pmas(pycomp(ksusy2+5),1)=100d0*axmi
51659  IF(xmi.GT.pmolb1+xmfp) pmas(pycomp(ksusy1+5),1)=100d0*axmi
51660  CALL pytbbc(ix,100,xmi,gam)
51661  lknt=lknt+1
51662  xlam(lknt)=gam
51663  idlam(lknt,1)=kfcchi(ix)
51664  idlam(lknt,2)=5
51665  idlam(lknt,3)=-6
51666  lknt=lknt+1
51667  xlam(lknt)=xlam(lknt-1)
51668  idlam(lknt,1)=-idlam(lknt-1,1)
51669  idlam(lknt,2)=-idlam(lknt-1,2)
51670  idlam(lknt,3)=-idlam(lknt-1,3)
51671  pmas(pycomp(ksusy2+6),1)=pmolt2
51672  pmas(pycomp(ksusy2+5),1)=pmolb2
51673  pmas(pycomp(ksusy1+6),1)=pmolt1
51674  pmas(pycomp(ksusy1+5),1)=pmolb1
51675  ENDIF
51676  200 CONTINUE
51677  ENDIF
51678  210 CONTINUE
51679 
51680 C...R-parity violating (3-body) decays.
51681  CALL pyrvgl(kfin,xlam,idlam,lknt)
51682 
51683  iknt=lknt
51684  xlam(0)=0d0
51685  DO 220 i=1,iknt
51686  IF(xlam(i).LT.0d0) xlam(i)=0d0
51687  xlam(0)=xlam(0)+xlam(i)
51688  220 CONTINUE
51689  IF(xlam(0).EQ.0d0) xlam(0)=1d-6
51690 
51691  RETURN
51692  END
51693 
51694 
51695 C*********************************************************************
51696 
51697 C...PYTBBN
51698 C...Calculates the three-body decay of gluinos into
51699 C...neutralinos and third generation fermions.
51700 
51701  SUBROUTINE pytbbn(I,NN,E,XMGLU,GAM)
51702 
51703 C...Double precision and integer declarations.
51704  IMPLICIT DOUBLE PRECISION(a-h, o-z)
51705  IMPLICIT INTEGER(i-n)
51706  INTEGER pyk,pychge,pycomp
51707 C...Parameter statement to help give large particle numbers.
51708  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
51709  &kexcit=4000000,kdimen=5000000)
51710 C...Commonblocks.
51711  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
51712  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
51713  common/pymssm/imss(0:99),rmss(0:99)
51714  common/pyssmt/zmix(4,4),umix(2,2),vmix(2,2),smz(4),smw(2),
51715  &sfmix(16,4),zmixi(4,4),umixi(2,2),vmixi(2,2)
51716  SAVE /pydat1/,/pydat2/,/pymssm/,/pyssmt/
51717 
51718 C...Local variables.
51719  EXTERNAL pysimp,pylamf
51720  DOUBLE PRECISION pysimp,pylamf
51721  INTEGER lin,nn
51722  DOUBLE PRECISION cosd,sind,cosd2,sind2,cos2d,sin2d
51723  DOUBLE PRECISION hl,hr,fl,fr,hl2,hr2,fl2,fr2
51724  DOUBLE PRECISION xms2(2),xm,xm2,xmg,xmg2,xmr,xmr2
51725  DOUBLE PRECISION sbar,smin,smax,xmqa,w,grs,g(0:6),summe(0:100)
51726  DOUBLE PRECISION ff,hh,hfl,hfr,hrfl,hlfr,xmq4,xm24
51727  DOUBLE PRECISION xln1,xln2,b1,b2
51728  DOUBLE PRECISION e,xmglu,gam
51729  DOUBLE PRECISION hrb(4),hlb(4),flb(4),frb(4)
51730  SAVE hrb,hlb,flb,frb
51731  DOUBLE PRECISION alphaw,alphas
51732  DOUBLE PRECISION hlt(4),hrt(4),flt(4),frt(4)
51733  SAVE hlt,hrt,flt,frt
51734  DOUBLE PRECISION amn(4),an(4,4),zn(3)
51735  SAVE amn,an,zn
51736  DOUBLE PRECISION ambot,sinc,cosc
51737  DOUBLE PRECISION amtop,sina,cosa
51738  DOUBLE PRECISION sinw,cosw,tanw
51739  DOUBLE PRECISION rot1(4,4)
51740  LOGICAL ifirst
51741  SAVE ifirst
51742  DATA ifirst/.true./
51743 
51744  tanb=rmss(5)
51745  sinb=tanb/sqrt(1d0+tanb**2)
51746  cosb=sinb/tanb
51747  xw=paru(102)
51748  sinw=sqrt(xw)
51749  cosw=sqrt(1d0-xw)
51750  tanw=sinw/cosw
51751  amw=pmas(24,1)
51752  cosc=sfmix(5,1)
51753  sinc=sfmix(5,3)
51754  cosa=sfmix(6,1)
51755  sina=sfmix(6,3)
51756  ambot=pymrun(5,xmglu**2)
51757  amtop=pymrun(6,xmglu**2)
51758  w2=sqrt(2d0)
51759  fakt1=ambot/w2/amw/cosb
51760  fakt2=amtop/w2/amw/sinb
51761  IF(ifirst) THEN
51762  DO 110 ii=1,4
51763  amn(ii)=smz(ii)
51764  DO 100 j=1,4
51765  rot1(ii,j)=0d0
51766  an(ii,j)=0d0
51767  100 CONTINUE
51768  110 CONTINUE
51769  rot1(1,1)=cosw
51770  rot1(1,2)=-sinw
51771  rot1(2,1)=-rot1(1,2)
51772  rot1(2,2)=rot1(1,1)
51773  rot1(3,3)=cosb
51774  rot1(3,4)=sinb
51775  rot1(4,3)=-rot1(3,4)
51776  rot1(4,4)=rot1(3,3)
51777  DO 140 ii=1,4
51778  DO 130 j=1,4
51779  DO 120 jj=1,4
51780  an(ii,j)=an(ii,j)+zmix(ii,jj)*rot1(jj,j)
51781  120 CONTINUE
51782  130 CONTINUE
51783  140 CONTINUE
51784  DO 150 j=1,4
51785  zn(1)=-fakt2*(-sinb*an(j,3)+cosb*an(j,4))
51786  zn(2)=-2d0*w2/3d0*sinw*(tanw*an(j,2)-an(j,1))
51787  zn(3)=-2*w2/3d0*sinw*an(j,1)-w2*(0.5d0-2d0/3d0*
51788  & xw)*an(j,2)/cosw
51789  hrt(j)=zn(1)*cosa-zn(3)*sina
51790  hlt(j)=zn(1)*cosa+zn(2)*sina
51791  flt(j)=zn(3)*cosa+zn(1)*sina
51792  frt(j)=zn(2)*cosa-zn(1)*sina
51793 C FLU(J)=ZN(3)
51794 C FRU(J)=ZN(2)
51795  zn(1)=-fakt1*(cosb*an(j,3)+sinb*an(j,4))
51796  zn(2)=w2/3d0*sinw*(tanw*an(j,2)-an(j,1))
51797  zn(3)=w2/3d0*sinw*an(j,1)+w2*(0.5d0-xw/3d0)*an(j,2)/cosw
51798  hrb(j)=zn(1)*cosc-zn(3)*sinc
51799  hlb(j)=zn(1)*cosc+zn(2)*sinc
51800  flb(j)=zn(3)*cosc+zn(1)*sinc
51801  frb(j)=zn(2)*cosc-zn(1)*sinc
51802 C FLD(J)=ZN(3)
51803 C FRD(J)=ZN(2)
51804  150 CONTINUE
51805 C AMST(1)=PMAS(PYCOMP(KSUSY1+6),1)
51806 C AMST(2)=PMAS(PYCOMP(KSUSY2+6),1)
51807 C AMSB(1)=PMAS(PYCOMP(KSUSY1+5),1)
51808 C AMSB(2)=PMAS(PYCOMP(KSUSY2+5),1)
51809  ifirst=.false.
51810  ENDIF
51811 
51812  IF(nint(3d0*e).EQ.2) THEN
51813  hl=hlt(i)
51814  hr=hrt(i)
51815  fl=flt(i)
51816  fr=frt(i)
51817  cosd=sfmix(6,1)
51818  sind=sfmix(6,3)
51819  xms2(1)=pmas(pycomp(ksusy1+6),1)**2
51820  xms2(2)=pmas(pycomp(ksusy2+6),1)**2
51821  xm=pmas(6,1)
51822  ELSE
51823  hl=hlb(i)
51824  hr=hrb(i)
51825  fl=flb(i)
51826  fr=frb(i)
51827  cosd=sfmix(5,1)
51828  sind=sfmix(5,3)
51829  xms2(1)=pmas(pycomp(ksusy1+5),1)**2
51830  xms2(2)=pmas(pycomp(ksusy2+5),1)**2
51831  xm=pmas(5,1)
51832  ENDIF
51833  cosd2=cosd*cosd
51834  sind2=sind*sind
51835  cos2d=cosd2-sind2
51836  sin2d=sind*cosd*2d0
51837  hl2=hl*hl
51838  hr2=hr*hr
51839  fl2=fl*fl
51840  fr2=fr*fr
51841  ff=fl*fr
51842  hh=hl*hr
51843  hfl=hl*fl
51844  hfr=hr*fr
51845  hrfl=hr*fl
51846  hlfr=hl*fr
51847  xm2=xm*xm
51848  xmg=xmglu
51849  xmg2=xmg*xmg
51850  alphaw=pyalem(xmg2)
51851  alphas=pyalps(xmg2)
51852  xmr=amn(i)
51853  xmr2=xmr*xmr
51854  xmq4=xmg*xm2*xmr
51855  xm24=(xmg2+xm2)*(xm2+xmr2)
51856  smin=4d0*xm2
51857  smax=(xmg-abs(xmr))**2
51858  xmqa=xmg2+2d0*xm2+xmr2
51859  DO 170 lin=1,nn-1
51860  sbar=smin+dble(lin)*(smax-smin)/dble(nn)
51861  grs=sbar-xmqa
51862  w=pylamf(xmg2,xmr2,sbar)*(0.25d0-xm2/sbar)
51863  w=dsqrt(w)
51864  xln1=log(abs((grs/2d0+xms2(1)-w)/(grs/2d0+xms2(1)+w)))
51865  xln2=log(abs((grs/2d0+xms2(2)-w)/(grs/2d0+xms2(2)+w)))
51866  b1=1d0/(grs/2d0+xms2(1)-w)-1d0/(grs/2d0+xms2(1)+w)
51867  b2=1d0/(grs/2d0+xms2(2)-w)-1d0/(grs/2d0+xms2(2)+w)
51868  g(0)=-2d0*(hl2+fl2+hr2+fr2+(hfr-hfl)*sin2d
51869  & +2d0*(ff*sind2-hh*cosd2))*w
51870  g(1)=((hl2+fl2)*(xmqa-2d0*xms2(1)-2d0*xm*xmg*sin2d)
51871  & +4d0*hfl*xm*xmr)*xln1
51872  & +((hl2+fl2)*((xmqa-xms2(1))*xms2(1)-xm24
51873  & +2d0*xm*xmg*(xm2+xmr2-xms2(1))*sin2d)
51874  & -4d0*hfl*xmr*xm*(xmg2+xm2-xms2(1))
51875  & +8d0*hfl*xmq4*sin2d)*b1
51876  g(2)=((hr2+fr2)*(xmqa-2d0*xms2(2)+2d0*xm*xmg*sin2d)
51877  & +4d0*hfr*xmr*xm)*xln2
51878  & +((hr2+fr2)*((xmqa-xms2(2))*xms2(2)-xm24
51879  & +2d0*xmg*xm*sin2d*(xms2(2)-xm2-xmr2))
51880  & +4d0*hfr*xm*xmr*(xms2(2)-xmg2-xm2)
51881  & -8d0*hfr*xmq4*sin2d)*b2
51882  g(3)=(2d0*hfl*sin2d*(xms2(1)*(grs+xms2(1))+xm2*(sbar-xmg2-xmr2)
51883  & +xmg2*xmr2+xm2*xm2)-2d0*xmr*xmg*(hl2*sind2+fl2*cosd2)*sbar
51884  & -2d0*xmg*xm*hfl*(sbar+xmr2-xmg2)
51885  & +xmr*xm*(hl2+fl2)*sin2d*(sbar+xmg2-xmr2)
51886  & -4d0*xmq4*(hl2-fl2)*cos2d)/(grs+2d0*xms2(1))*xln1
51887  g(4)=4d0*cos2d*xm*xmg/(xms2(1)-xms2(2))*
51888  & (((hlfr+hrfl)*(xm2+xmr2)+2d0*xm*xmr*(hh+ff))*(xln1-xln2)
51889  & +(hlfr+hrfl)*(xms2(2)*xln2-xms2(1)*xln1))
51890  g(5)=(2d0*(hh*cosd2-ff*sind2)
51891  & *((xms2(2)*(xms2(2)+grs)+xm2*xm2+xmg2*xmr2)*xln2
51892  & +(xms2(1)*(xms2(1)+grs)+xm2*xm2+xmg2*xmr2)*xln1)
51893  & +xm*((hh-ff)*sin2d*xmg-(hrfl-hlfr)*xmr)
51894  & *((grs+xms2(1)*2d0)*xln1-(grs+xms2(2)*2d0)*xln2)
51895  & +((hrfl-hlfr)*xmr*(sin2d*xmg*(sbar-4d0*xm2)
51896  & +cos2d*xm*(sbar+xmg2-xmr2))
51897  & +2d0*(ff*cosd2-hh*sind2)*xm2*(sbar-xmg2-xmr2))
51898  & *(xln1+xln2))/(grs+xms2(1)+xms2(2))
51899  g(6)=(-2d0*hfr*sin2d*(xms2(2)*(grs+xms2(2))+xm2*(sbar-xmg2-xmr2)
51900  & +xmg2*xmr2+xm2*xm2)-2d0*xmr*xmg*(hr2*sind2+fr2*cosd2)*sbar
51901  & -2d0*xmg*xm*hfr*(sbar+xmr2-xmg2)
51902  & -xmr*xm*(hr2+fr2)*sin2d*(sbar+xmg2-xmr2)
51903  & -4d0*xmq4*(hr2-fr2)*cos2d)/(grs+2d0*xms2(2))*xln2
51904  summe(lin)=0d0
51905  DO 160 j=0,6
51906  summe(lin)=summe(lin)+g(j)
51907  160 CONTINUE
51908  170 CONTINUE
51909  summe(0)=0d0
51910  summe(nn)=0d0
51911  gam = alphaw * alphas * pysimp(summe,smin,smax,nn)
51912  &/ (16d0 * paru(1) * paru(102) * xmglu**3)
51913 
51914  RETURN
51915  END
51916 
51917 C*********************************************************************
51918 
51919 C...PYTBBC
51920 C...Calculates the three-body decay of gluinos into
51921 C...charginos and third generation fermions.
51922 
51923  SUBROUTINE pytbbc(I,NN,XMGLU,GAM)
51924 
51925 C...Double precision and integer declarations.
51926  IMPLICIT DOUBLE PRECISION(a-h, o-z)
51927  IMPLICIT INTEGER(i-n)
51928  INTEGER pyk,pychge,pycomp
51929 C...Parameter statement to help give large particle numbers.
51930  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
51931  &kexcit=4000000,kdimen=5000000)
51932 C...Commonblocks.
51933  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
51934  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
51935  common/pymssm/imss(0:99),rmss(0:99)
51936  common/pyssmt/zmix(4,4),umix(2,2),vmix(2,2),smz(4),smw(2),
51937  &sfmix(16,4),zmixi(4,4),umixi(2,2),vmixi(2,2)
51938  SAVE /pydat1/,/pydat2/,/pymssm/,/pyssmt/
51939 
51940 C...Local variables.
51941  EXTERNAL pysimp,pylamf
51942  DOUBLE PRECISION pysimp,pylamf
51943  INTEGER i,nn,lin
51944  DOUBLE PRECISION xmg,xmg2,xmb,xmb2,xmr,xmr2
51945  DOUBLE PRECISION xmt,xmt2,xmst(4),xmsb(4)
51946  DOUBLE PRECISION ulr(2),vlr(2),xmq2,xmq4,am,w,sbar,smin,smax
51947  DOUBLE PRECISION summe(0:100),a(4,8)
51948  DOUBLE PRECISION cos2a,sin2a,cos2c,sin2c
51949  DOUBLE PRECISION grs,xmq3,xmgbtr,xmgtbr,ant1,ant2,anb1,anb2
51950  DOUBLE PRECISION xmglu,gam
51951  DOUBLE PRECISION xx1(2),xx2(2),aaa(2),bbb(2),ccc(2),
51952  &ddd(2),eee(2),fff(2)
51953  SAVE xx1,xx2,aaa,bbb,ccc,ddd,eee,fff
51954  DOUBLE PRECISION alphaw,alphas
51955  DOUBLE PRECISION amc(2)
51956  SAVE amc
51957  DOUBLE PRECISION ambot,amsb(2),sinc,cosc
51958  DOUBLE PRECISION amtop,amst(2),sina,cosa
51959  SAVE amsb,amst
51960  LOGICAL ifirst
51961  SAVE ifirst
51962  DATA ifirst/.true./
51963 
51964  tanb=rmss(5)
51965  sinb=tanb/sqrt(1d0+tanb**2)
51966  cosb=sinb/tanb
51967  xw=paru(102)
51968  amw=pmas(24,1)
51969  cosc=sfmix(5,1)
51970  sinc=sfmix(5,3)
51971  cosa=sfmix(6,1)
51972  sina=sfmix(6,3)
51973  ambot=pymrun(5,xmglu**2)
51974  amtop=pymrun(6,xmglu**2)
51975  w2=sqrt(2d0)
51976  amw=pmas(24,1)
51977  fakt1=ambot/w2/amw/cosb
51978  fakt2=amtop/w2/amw/sinb
51979  IF(ifirst) THEN
51980  amc(1)=smw(1)
51981  amc(2)=smw(2)
51982  DO 100 jj=1,2
51983  ccc(jj)=fakt1*umix(jj,2)*sinc-umix(jj,1)*cosc
51984  eee(jj)=fakt2*vmix(jj,2)*cosc
51985  ddd(jj)=fakt1*umix(jj,2)*cosc+umix(jj,1)*sinc
51986  fff(jj)=fakt2*vmix(jj,2)*sinc
51987  xx1(jj)=fakt2*vmix(jj,2)*sina-vmix(jj,1)*cosa
51988  aaa(jj)=fakt1*umix(jj,2)*cosa
51989  xx2(jj)=fakt2*vmix(jj,2)*cosa+vmix(jj,1)*sina
51990  bbb(jj)=fakt1*umix(jj,2)*sina
51991  100 CONTINUE
51992  amst(1)=pmas(pycomp(ksusy1+6),1)
51993  amst(2)=pmas(pycomp(ksusy2+6),1)
51994  amsb(1)=pmas(pycomp(ksusy1+5),1)
51995  amsb(2)=pmas(pycomp(ksusy2+5),1)
51996  ifirst=.false.
51997  ENDIF
51998 
51999  ulr(1)=xx1(i)*xx1(i)+aaa(i)*aaa(i)
52000  ulr(2)=xx2(i)*xx2(i)+bbb(i)*bbb(i)
52001  vlr(1)=ccc(i)*ccc(i)+eee(i)*eee(i)
52002  vlr(2)=ddd(i)*ddd(i)+fff(i)*fff(i)
52003 
52004  cos2a=cosa**2-sina**2
52005  sin2a=sina*cosa*2d0
52006  cos2c=cosc**2-sinc**2
52007  sin2c=sinc*cosc*2d0
52008 
52009  xmg=xmglu
52010  xmt=pmas(6,1)
52011  xmb=pmas(5,1)
52012  xmr=amc(i)
52013  xmg2=xmg*xmg
52014  alphaw=pyalem(xmg2)
52015  alphas=pyalps(xmg2)
52016  xmt2=xmt*xmt
52017  xmb2=xmb*xmb
52018  xmr2=xmr*xmr
52019  xmq2=xmg2+xmt2+xmb2+xmr2
52020  xmq4=xmg*xmt*xmb*xmr
52021  xmq3=xmg2*xmr2+xmt2*xmb2
52022  xmgbtr=(xmg2+xmb2)*(xmt2+xmr2)
52023  xmgtbr=(xmg2+xmt2)*(xmb2+xmr2)
52024 
52025  xmst(1)=amst(1)*amst(1)
52026  xmst(2)=amst(1)*amst(1)
52027  xmst(3)=amst(2)*amst(2)
52028  xmst(4)=amst(2)*amst(2)
52029  xmsb(1)=amsb(1)*amsb(1)
52030  xmsb(2)=amsb(2)*amsb(2)
52031  xmsb(3)=amsb(1)*amsb(1)
52032  xmsb(4)=amsb(2)*amsb(2)
52033 
52034  a(1,1)=-cosa*sinc*ccc(i)*aaa(i)-sina*cosc*eee(i)*xx1(i)
52035  a(1,2)=xmg*xmb*(cosa*cosc*ccc(i)*aaa(i)+sina*sinc*eee(i)*xx1(i))
52036  a(1,3)=-xmg*xmr*(cosa*cosc*ccc(i)*xx1(i)+sina*sinc*eee(i)*aaa(i))
52037  a(1,4)=xmb*xmr*(cosa*sinc*ccc(i)*xx1(i)+sina*cosc*eee(i)*aaa(i))
52038  a(1,5)=xmg*xmt*(cosa*cosc*eee(i)*xx1(i)+sina*sinc*ccc(i)*aaa(i))
52039  a(1,6)=-xmt*xmb*(cosa*sinc*eee(i)*xx1(i)+sina*cosc*ccc(i)*aaa(i))
52040  a(1,7)=xmt*xmr*(cosa*sinc*eee(i)*aaa(i)+sina*cosc*ccc(i)*xx1(i))
52041  a(1,8)=-xmq4*(cosa*cosc*eee(i)*aaa(i)+sina*sinc*ccc(i)*xx1(i))
52042 
52043  a(2,1)=-cosa*cosc*ddd(i)*aaa(i)-sina*sinc*fff(i)*xx1(i)
52044  a(2,2)=-xmg*xmb*(cosa*sinc*ddd(i)*aaa(i)+sina*cosc*fff(i)*xx1(i))
52045  a(2,3)=xmg*xmr*(cosa*sinc*ddd(i)*xx1(i)+sina*cosc*fff(i)*aaa(i))
52046  a(2,4)=xmb*xmr*(cosa*cosc*ddd(i)*xx1(i)+sina*sinc*fff(i)*aaa(i))
52047  a(2,5)=xmg*xmt*(cosa*sinc*fff(i)*xx1(i)+sina*cosc*ddd(i)*aaa(i))
52048  a(2,6)=xmt*xmb*(cosa*cosc*fff(i)*xx1(i)+sina*sinc*ddd(i)*aaa(i))
52049  a(2,7)=-xmt*xmr*(cosa*cosc*fff(i)*aaa(i)+sina*sinc*ddd(i)*xx1(i))
52050  a(2,8)=-xmq4*(cosa*sinc*fff(i)*aaa(i)+sina*cosc*ddd(i)*xx1(i))
52051 
52052  a(3,1)=-cosa*cosc*eee(i)*xx2(i)-sina*sinc*ccc(i)*bbb(i)
52053  a(3,2)=xmg*xmb*(cosa*sinc*eee(i)*xx2(i)+sina*cosc*ccc(i)*bbb(i))
52054  a(3,3)=xmg*xmr*(cosa*sinc*eee(i)*bbb(i)+sina*cosc*ccc(i)*xx2(i))
52055  a(3,4)=-xmb*xmr*(cosa*cosc*eee(i)*bbb(i)+sina*sinc*ccc(i)*xx2(i))
52056  a(3,5)=-xmg*xmt*(cosa*sinc*ccc(i)*bbb(i)+sina*cosc*eee(i)*xx2(i))
52057  a(3,6)=xmt*xmb*(cosa*cosc*ccc(i)*bbb(i)+sina*sinc*eee(i)*xx2(i))
52058  a(3,7)=xmt*xmr*(cosa*cosc*ccc(i)*xx2(i)+sina*sinc*eee(i)*bbb(i))
52059  a(3,8)=-xmq4*(cosa*sinc*ccc(i)*xx2(i)+sina*cosc*eee(i)*bbb(i))
52060 
52061  a(4,1)=-cosa*sinc*fff(i)*xx2(i)-sina*cosc*ddd(i)*bbb(i)
52062  a(4,2)=-xmg*xmb*(cosa*cosc*fff(i)*xx2(i)+sina*sinc*ddd(i)*bbb(i))
52063  a(4,3)=-xmg*xmr*(cosa*cosc*fff(i)*bbb(i)+sina*sinc*ddd(i)*xx2(i))
52064  a(4,4)=-xmb*xmr*(cosa*sinc*fff(i)*bbb(i)+sina*cosc*ddd(i)*xx2(i))
52065  a(4,5)=-xmg*xmt*(cosa*cosc*ddd(i)*bbb(i)+sina*sinc*fff(i)*xx2(i))
52066  a(4,6)=-xmt*xmb*(cosa*sinc*ddd(i)*bbb(i)+sina*cosc*fff(i)*xx2(i))
52067  a(4,7)=-xmt*xmr*(cosa*sinc*ddd(i)*xx2(i)+sina*cosc*fff(i)*bbb(i))
52068  a(4,8)=-xmq4*(cosa*cosc*ddd(i)*xx2(i)+sina*sinc*fff(i)*bbb(i))
52069 
52070  smax=(xmg-abs(xmr))**2
52071  smin=(xmb+xmt)**2+0.1d0
52072 
52073  DO 120 lin=0,nn-1
52074  sbar=smin+dble(lin)*(smax-smin)/dble(nn)
52075  am=(xmg2-xmr2)*(xmt2-xmb2)/2d0/sbar
52076  grs=sbar-xmq2
52077  w=pylamf(sbar,xmb2,xmt2)*pylamf(sbar,xmg2,xmr2)
52078  w=dsqrt(w)/2d0/sbar
52079  ant1=log(abs((grs/2d0+am+xmst(1)-w)/(grs/2d0+am+xmst(1)+w)))
52080  ant2=log(abs((grs/2d0+am+xmst(3)-w)/(grs/2d0+am+xmst(3)+w)))
52081  anb1=log(abs((grs/2d0-am+xmsb(1)-w)/(grs/2d0-am+xmsb(1)+w)))
52082  anb2=log(abs((grs/2d0-am+xmsb(2)-w)/(grs/2d0-am+xmsb(2)+w)))
52083  summe(lin)=-ulr(1)*w+(ulr(1)*(xmq2/2d0-xmst(1)-xmg*xmt*sin2a)
52084  & +2d0*xx1(i)*aaa(i)*xmr*xmb)*ant1
52085  & +(ulr(1)/2d0*(xmst(1)*(xmq2-xmst(1))-xmgtbr
52086  & -2d0*xmg*xmt*sin2a*(xmst(1)-xmb2-xmr2))
52087  & +2d0*xx1(i)*aaa(i)*xmr*xmb*(xmst(1)-xmg2-xmt2)
52088  & +4d0*sin2a*xx1(i)*aaa(i)*xmq4)
52089  & *(1d0/(grs/2d0+am+xmst(1)-w)-1d0/(grs/2d0+am+xmst(1)+w))
52090  summe(lin)=summe(lin)-ulr(2)*w
52091  & +(ulr(2)*(xmq2/2d0-xmst(3)+xmg*xmt*sin2a)
52092  & -2d0*xx2(i)*bbb(i)*xmr*xmb)*ant2
52093  & +(ulr(2)/2d0*(xmst(3)*(xmq2-xmst(3))-xmgtbr
52094  & +2d0*xmg*xmt*sin2a*(xmst(3)-xmb2-xmr2))
52095  & -2d0*xx2(i)*bbb(i)*xmr*xmb*(xmst(3)-xmg2-xmt2)
52096  & +4d0*sin2a*xx2(i)*bbb(i)*xmq4)
52097  & *(1d0/(grs/2d0+am+xmst(3)-w)-1d0/(grs/2d0+am+xmst(3)+w))
52098  summe(lin)=summe(lin)-vlr(1)*w
52099  & +(vlr(1)*(xmq2/2d0-xmsb(1)-xmg*xmb*sin2c)
52100  & +2d0*ccc(i)*eee(i)*xmr*xmt)*anb1
52101  & +(vlr(1)/2d0*(xmsb(1)*(xmq2-xmsb(1))-xmgbtr
52102  & -2d0*xmg*xmb*sin2c*(xmsb(1)-xmt2-xmr2))
52103  & +2d0*ccc(i)*eee(i)*xmr*xmt*(xmsb(1)-xmg2-xmb2)
52104  & +4d0*sin2c*ccc(i)*eee(i)*xmq4)
52105  & *(1d0/(grs/2d0-am+xmsb(1)-w)-1d0/(grs/2d0-am+xmsb(1)+w))
52106  summe(lin)=summe(lin)-vlr(2)*w
52107  & +(vlr(2)*(xmq2/2d0-xmsb(2)+xmg*xmb*sin2c)
52108  & -2d0*ddd(i)*fff(i)*xmr*xmt)*anb2
52109  & +(vlr(2)/2d0*(xmsb(2)*(xmq2-xmsb(2))-xmgbtr
52110  & +2d0*xmg*xmb*sin2c*(xmsb(2)-xmt2-xmr2))
52111  & -2d0*ddd(i)*fff(i)*xmr*xmt*(xmsb(2)-xmg2-xmb2)
52112  & +4d0*sin2c*ddd(i)*fff(i)*xmq4)
52113  & *(1d0/(grs/2d0-am+xmsb(2)-w)-1d0/(grs/2d0-am+xmsb(2)+w))
52114  summe(lin)=summe(lin)+2d0*xmg*xmt*cos2a/(xmst(3)-xmst(1))
52115  & *((aaa(i)*bbb(i)-xx1(i)*xx2(i))
52116  & *((xmst(3)-xmb2-xmr2)*ant2-(xmst(1)-xmb2-xmr2)*ant1)
52117  & +2d0*(aaa(i)*xx2(i)-xx1(i)*bbb(i))*xmb*xmr*(ant2-ant1))
52118  summe(lin)=summe(lin)+2d0*xmg*xmb*cos2c/(xmsb(2)-xmsb(1))
52119  & *((eee(i)*fff(i)-ccc(i)*ddd(i))
52120  & *((xmsb(2)-xmt2-xmr2)*anb2-(xmsb(1)-xmt2-xmr2)*anb1)
52121  & +2d0*(eee(i)*ddd(i)-ccc(i)*fff(i))*xmt*xmr*(anb2-anb1))
52122  DO 110 j=1,4
52123  summe(lin)=summe(lin)-2d0*a(j,1)*w
52124  & +((-a(j,1)*(xmsb(j)*(grs+xmsb(j))+xmq3)
52125  & +a(j,2)*(xmsb(j)-xmt2-xmr2)+a(j,3)*(sbar-xmb2-xmt2)
52126  & +a(j,4)*(xmsb(j)+sbar-xmb2-xmr2)
52127  & -a(j,5)*(xmsb(j)+sbar-xmg2-xmt2)+a(j,6)*(xmg2+xmr2-sbar)
52128  & -a(j,7)*(xmsb(j)-xmg2-xmb2)+2d0*a(j,8))
52129  & *log(abs((grs/2d0+xmsb(j)-am-w)/(grs/2d0+xmsb(j)-am+w)))
52130  & -(a(j,1)*(xmst(j)*(grs+xmst(j))+xmq3)
52131  & +a(j,2)*(xmst(j)+sbar-xmg2-xmb2)-a(j,3)*(sbar-xmb2-xmt2)
52132  & +a(j,4)*(xmst(j)-xmg2-xmt2)-a(j,5)*(xmst(j)-xmr2-xmb2)
52133  & -a(j,6)*(xmg2+xmr2-sbar)
52134  & -a(j,7)*(xmst(j)+sbar-xmt2-xmr2)-2d0*a(j,8))
52135  & *log(abs((grs/2d0+xmst(j)+am-w)/(grs/2d0+xmst(j)+am+w))))
52136  & /(grs+xmsb(j)+xmst(j))
52137  110 CONTINUE
52138  120 CONTINUE
52139  summe(nn)=0d0
52140  gam= alphaw * alphas * pysimp(summe,smin,smax,nn)
52141  &/ (16d0 * paru(1) * paru(102) * xmglu**3)
52142 
52143  RETURN
52144  END
52145 
52146 C*********************************************************************
52147 
52148 C...PYNJDC
52149 C...Calculates decay widths for the neutralinos (admixtures of
52150 C...Bino, W3-ino, Higgs1-ino, Higgs2-ino)
52151 
52152 C...Input: KCIN = KF code for particle
52153 C...Output: XLAM = widths
52154 C... IDLAM = KF codes for decay particles
52155 C... IKNT = number of decay channels defined
52156 C...AUTHOR: STEPHEN MRENNA
52157 C...Last change:
52158 C...10-15-95: force decay chi^0_2 -> chi^0_1 + gamma
52159 C...when CHIGAMMA .NE. 0
52160 C...10 FEB 96: Calculate this decay for small tan(beta)
52161 
52162  SUBROUTINE pynjdc(KFIN,XLAM,IDLAM,IKNT)
52163 
52164 C...Double precision and integer declarations.
52165  IMPLICIT DOUBLE PRECISION(a-h, o-z)
52166  IMPLICIT INTEGER(i-n)
52167  INTEGER pyk,pychge,pycomp
52168 C...Parameter statement to help give large particle numbers.
52169  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
52170  &kexcit=4000000,kdimen=5000000)
52171 C...Commonblocks.
52172  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
52173  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
52174  common/pymssm/imss(0:99),rmss(0:99)
52175 c COMMON/PYSSMT/ZMIX(4,4),UMIX(2,2),VMIX(2,2),SMZ(4),SMW(2),
52176 c &SFMIX(16,4)
52177  common/pyssmt/zmix(4,4),umix(2,2),vmix(2,2),smz(4),smw(2),
52178  &sfmix(16,4),zmixi(4,4),umixi(2,2),vmixi(2,2)
52179 C COMMON/PYINTS/XXM(20)
52180  COMPLEX*16 cxc
52181  common/pyintc/xxc(10),cxc(8)
52182  SAVE /pydat1/,/pydat2/,/pymssm/,/pyssmt/,/pyintc/
52183 
52184 C...Local variables.
52185  COMPLEX*16 zmixc(4,4),vmixc(2,2),umixc(2,2),olpp,orpp,glij,grij
52186  COMPLEX*16 qij,rij,f21k,f12k,cal,car,cbl,cbr,ca,cb
52187  INTEGER kfin
52188  DOUBLE PRECISION xmi,xmj,xmf,xmsf1,xmsf2,xmw,xmw2,
52189  &xmz,xmz2,axmj,axmi
52190  DOUBLE PRECISION s12min,s12max
52191  DOUBLE PRECISION xmi2,xmi3,xmj2,xmh,xmh2,xmhp,xma2,xmb2
52192  DOUBLE PRECISION pylamf,xl
52193  DOUBLE PRECISION tanw,xw,aem,c1,as,ei,t3i
52194  DOUBLE PRECISION pyx2xh,pyx2xg
52195  DOUBLE PRECISION xlam(0:400)
52196  INTEGER idlam(400,3)
52197  INTEGER lknt,ix,ih,j,ij,i,iknt,fid
52198  INTEGER ith(3),kf1,kf2
52199  INTEGER ithc
52200  DOUBLE PRECISION dh(3),eh(3)
52201  DOUBLE PRECISION sr2
52202  DOUBLE PRECISION cbeta,sbeta
52203  DOUBLE PRECISION gamcon,xmt1,xmt2
52204  DOUBLE PRECISION pyalem,pi,pyalps
52205  DOUBLE PRECISION rat1,rat2
52206  DOUBLE PRECISION t3t,fcol
52207  DOUBLE PRECISION alfa,beta,tanb
52208  DOUBLE PRECISION pyxxga
52209  EXTERNAL pygaus,pyxxz6
52210  DOUBLE PRECISION pygaus,pyxxz6
52211  DOUBLE PRECISION prec
52212  INTEGER kfnchi(4),kfcchi(2)
52213  DATA ith/25,35,36/
52214  DATA ithc/37/
52215  DATA prec/1d-2/
52216  DATA pi/3.141592654d0/
52217  DATA sr2/1.4142136d0/
52218  DATA kfnchi/1000022,1000023,1000025,1000035/
52219  DATA kfcchi/1000024,1000037/
52220 
52221 C...COUNT THE NUMBER OF DECAY MODES
52222  lknt=0
52223 
52224  xmw=pmas(24,1)
52225  xmw2=xmw**2
52226  xmz=pmas(23,1)
52227  xmz2=xmz**2
52228  xw=1d0-xmw2/xmz2
52229  xw1=1d0-xw
52230  tanw = sqrt(xw/xw1)
52231 
52232 C...IX IS 1 - 4 DEPENDING ON SEQUENCE NUMBER
52233  ix=1
52234  IF(kfin.EQ.kfnchi(2)) ix=2
52235  IF(kfin.EQ.kfnchi(3)) ix=3
52236  IF(kfin.EQ.kfnchi(4)) ix=4
52237 
52238  xmi=smz(ix)
52239  xmi2=xmi**2
52240  axmi=abs(xmi)
52241  aem=pyalem(xmi2)
52242  as =pyalps(xmi2)
52243  c1=aem/xw
52244  xmi3=abs(xmi**3)
52245 
52246  tanb=rmss(5)
52247  beta=atan(tanb)
52248  alfa=rmss(18)
52249  cbeta=cos(beta)
52250  sbeta=tanb*cbeta
52251  calfa=cos(alfa)
52252  salfa=sin(alfa)
52253 
52254  DO 110 i=1,4
52255  DO 100 j=1,4
52256  zmixc(j,i)=dcmplx(zmix(j,i),zmixi(j,i))
52257  100 CONTINUE
52258  110 CONTINUE
52259  DO 130 i=1,2
52260  DO 120 j=1,2
52261  vmixc(j,i)=dcmplx(vmix(j,i),vmixi(j,i))
52262  umixc(j,i)=dcmplx(umix(j,i),umixi(j,i))
52263  120 CONTINUE
52264  130 CONTINUE
52265 
52266 C...CHECK ALL 2-BODY DECAYS TO GAUGE AND HIGGS BOSONS
52267  IF(ix.EQ.1.AND.imss(11).EQ.0) goto 300
52268 
52269 C...FORCE CHI0_2 -> CHI0_1 + GAMMA
52270  IF(ix.EQ.2 .AND. imss(10).NE.0 ) THEN
52271  xmj=smz(1)
52272  axmj=abs(xmj)
52273  lknt=lknt+1
52274  gamcon=aem**3/8d0/pi/xmw2/xw
52275  xmt1=(pmas(pycomp(ksusy1+6),1)/pmas(6,1))**2
52276  xmt2=(pmas(pycomp(ksusy2+6),1)/pmas(6,1))**2
52277  xlam(lknt)=pyxxga(gamcon,axmi,axmj,xmt1,xmt2)
52278  idlam(lknt,1)=ksusy1+22
52279  idlam(lknt,2)=22
52280  idlam(lknt,3)=0
52281  WRITE(mstu(11),*) 'FORCED N2 -> N1 + GAMMA ',xlam(lknt)
52282  goto 340
52283  ENDIF
52284 
52285 C...GRAVITINO DECAY MODES
52286 
52287  IF(imss(11).EQ.1) THEN
52288  xmp=rmss(29)
52289  idg=39+ksusy1
52290  xmgr=pmas(pycomp(idg),1)
52291  sinw=sqrt(xw)
52292  cosw=sqrt(1d0-xw)
52293  xfac=(xmi2/(xmp*xmgr))**2*axmi/48d0/pi
52294  IF(axmi.GT.xmgr+pmas(22,1)) THEN
52295  lknt=lknt+1
52296  idlam(lknt,1)=idg
52297  idlam(lknt,2)=22
52298  idlam(lknt,3)=0
52299  xlam(lknt)=xfac*abs(zmixc(ix,1)*cosw+zmixc(ix,2)*sinw)**2
52300  ENDIF
52301  IF(axmi.GT.xmgr+xmz) THEN
52302  lknt=lknt+1
52303  idlam(lknt,1)=idg
52304  idlam(lknt,2)=23
52305  idlam(lknt,3)=0
52306  xlam(lknt)=xfac*(abs(zmixc(ix,1)*sinw-zmixc(ix,2)*cosw)**2 +
52307  $ .5d0*abs(zmixc(ix,3)*cbeta-zmixc(ix,4)*sbeta)**2)*
52308  & (1d0-xmz2/xmi2)**4
52309  ENDIF
52310  IF(axmi.GT.xmgr+pmas(25,1)) THEN
52311  lknt=lknt+1
52312  idlam(lknt,1)=idg
52313  idlam(lknt,2)=25
52314  idlam(lknt,3)=0
52315  xlam(lknt)=xfac*(abs(zmixc(ix,3)*salfa-zmixc(ix,4)*calfa)**2)*
52316  $ .5d0*(1d0-pmas(25,1)**2/xmi2)**4
52317  ENDIF
52318  IF(axmi.GT.xmgr+pmas(35,1)) THEN
52319  lknt=lknt+1
52320  idlam(lknt,1)=idg
52321  idlam(lknt,2)=35
52322  idlam(lknt,3)=0
52323  xlam(lknt)=xfac*(abs(zmixc(ix,3)*calfa+zmixc(ix,4)*salfa)**2)*
52324  $ .5d0*(1d0-pmas(35,1)**2/xmi2)**4
52325  ENDIF
52326  IF(axmi.GT.xmgr+pmas(36,1)) THEN
52327  lknt=lknt+1
52328  idlam(lknt,1)=idg
52329  idlam(lknt,2)=36
52330  idlam(lknt,3)=0
52331  xlam(lknt)=xfac*(abs(zmixc(ix,3)*sbeta+zmixc(ix,4)*cbeta)**2)*
52332  $ .5d0*(1d0-pmas(36,1)**2/xmi2)**4
52333  ENDIF
52334  IF(ix.EQ.1) goto 300
52335  ENDIF
52336 
52337  DO 220 ij=1,ix-1
52338  xmj=smz(ij)
52339  axmj=abs(xmj)
52340  xmj2=xmj**2
52341 
52342 C...CHI0_I -> CHI0_J + GAMMA
52343  IF(axmi.GE.axmj.AND.sbeta/cbeta.LE.2d0) THEN
52344  rat1=abs(zmixc(ij,1))**2+abs(zmixc(ij,2))**2
52345  rat1=rat1/( 1d-6+abs(zmixc(ix,3))**2+abs(zmixc(ix,4))**2 )
52346  rat2=abs(zmixc(ix,1))**2+abs(zmixc(ix,2))**2
52347  rat2=rat2/( 1d-6+abs(zmixc(ij,3))**2+abs(zmixc(ij,4))**2 )
52348  IF((rat1.GT. 0.90d0 .AND. rat1.LT. 1.10d0) .OR.
52349  & (rat2.GT. 0.90d0 .AND. rat2.LT. 1.10d0)) THEN
52350  lknt=lknt+1
52351  idlam(lknt,1)=kfnchi(ij)
52352  idlam(lknt,2)=22
52353  idlam(lknt,3)=0
52354  gamcon=aem**3/8d0/pi/xmw2/xw
52355  xmt1=(pmas(pycomp(ksusy1+6),1)/pmas(6,1))**2
52356  xmt2=(pmas(pycomp(ksusy2+6),1)/pmas(6,1))**2
52357  xlam(lknt)=pyxxga(gamcon,axmi,axmj,xmt1,xmt2)
52358  ENDIF
52359  ENDIF
52360 
52361 C...CHI0_I -> CHI0_J + Z0
52362  IF(axmi.GE.axmj+xmz) THEN
52363  lknt=lknt+1
52364  olpp=(zmixc(ix,3)*dconjg(zmixc(ij,3))-
52365  & zmixc(ix,4)*dconjg(zmixc(ij,4)))/2d0
52366  orpp=-dconjg(olpp)
52367  gx2=abs(olpp)**2+abs(orpp)**2
52368  glr=dble(olpp*dconjg(orpp))
52369  xlam(lknt)=pyx2xg(c1/xmw2,xmi,xmj,xmz,gx2,glr)
52370  idlam(lknt,1)=kfnchi(ij)
52371  idlam(lknt,2)=23
52372  idlam(lknt,3)=0
52373  ELSEIF(axmi.GE.axmj) THEN
52374  xxc(1)=0d0
52375  xxc(2)=xmj
52376  xxc(3)=0d0
52377  xxc(4)=xmi
52378  xxc(9)=xmz
52379  xxc(10)=pmas(23,2)
52380  olpp=(zmixc(ix,3)*dconjg(zmixc(ij,3))-
52381  & zmixc(ix,4)*dconjg(zmixc(ij,4)))/2d0
52382  orpp=dconjg(olpp)
52383 C...CHARGED LEPTONS
52384  fid=11
52385  xxc(5)=pmas(pycomp(ksusy1+fid),1)
52386  xxc(6)=pmas(pycomp(ksusy2+fid),1)
52387  ei=kchg(fid,1)/3d0
52388  t3i=sign(1d0,ei+1d-6)/2d0
52389  glij=(t3i*zmixc(ix,2)-tanw*(t3i-ei)*zmixc(ix,1))*
52390  & dconjg(t3i*zmixc(ij,2)-tanw*(t3i-ei)*zmixc(ij,1))
52391  grij=zmixc(ix,1)*dconjg(zmixc(ij,1))*(ei*tanw)**2
52392  cxc(1)=dcmplx((t3i-ei*xw)/xw1)*olpp
52393  cxc(2)=-glij
52394  cxc(3)=-dcmplx((t3i-ei*xw)/xw1)*orpp
52395  cxc(4)=dconjg(glij)
52396  cxc(5)=-dcmplx((ei*xw)/xw1)*olpp
52397  cxc(6)=grij
52398  cxc(7)=dcmplx((ei*xw)/xw1)*orpp
52399  cxc(8)=-dconjg(grij)
52400  s12min=0d0
52401  s12max=(axmi-axmj)**2
52402  IF( xxc(5).LT.axmi ) THEN
52403  xxc(5)=1d6
52404  ENDIF
52405  IF(xxc(6).LT.axmi ) THEN
52406  xxc(6)=1d6
52407  ENDIF
52408  xxc(7)=xxc(5)
52409  xxc(8)=xxc(6)
52410 
52411  IF(axmi.GE.axmj+2d0*pmas(11,1)) THEN
52412  lknt=lknt+1
52413  xlam(lknt)=c1**2/xmi3/(16d0*pi)*
52414  & pygaus(pyxxz6,s12min,s12max,1d-3)
52415  idlam(lknt,1)=kfnchi(ij)
52416  idlam(lknt,2)=fid
52417  idlam(lknt,3)=-fid
52418  IF(axmi.GE.axmj+2d0*pmas(13,1)) THEN
52419  lknt=lknt+1
52420  xlam(lknt)=xlam(lknt-1)
52421  idlam(lknt,1)=kfnchi(ij)
52422  idlam(lknt,2)=13
52423  idlam(lknt,3)=-13
52424  ENDIF
52425  ENDIF
52426  140 CONTINUE
52427  IF(abs(sfmix(15,1)).GT.abs(sfmix(15,2))) THEN
52428  xxc(5)=pmas(pycomp(ksusy1+15),1)
52429  xxc(6)=pmas(pycomp(ksusy2+15),1)
52430  ELSE
52431  xxc(6)=pmas(pycomp(ksusy1+15),1)
52432  xxc(5)=pmas(pycomp(ksusy2+15),1)
52433  ENDIF
52434  IF( xxc(5).LT.axmi ) THEN
52435  xxc(5)=1d6
52436  ENDIF
52437  IF(xxc(6).LT.axmi ) THEN
52438  xxc(6)=1d6
52439  ENDIF
52440  xxc(7)=xxc(5)
52441  xxc(8)=xxc(6)
52442 
52443  IF(axmi.GE.axmj+2d0*pmas(15,1)) THEN
52444  lknt=lknt+1
52445  xlam(lknt)=c1**2/xmi3/(16d0*pi)*
52446  & pygaus(pyxxz6,s12min,s12max,1d-3)
52447  idlam(lknt,1)=kfnchi(ij)
52448  idlam(lknt,2)=15
52449  idlam(lknt,3)=-15
52450  ENDIF
52451 
52452 C...NEUTRINOS
52453  150 CONTINUE
52454  fid=12
52455  xxc(5)=pmas(pycomp(ksusy1+fid),1)
52456  xxc(6)=pmas(pycomp(ksusy2+fid),1)
52457  ei=kchg(fid,1)/3d0
52458  t3i=sign(1d0,ei+1d-6)/2d0
52459  glij=(t3i*zmixc(ix,2)-tanw*(t3i-ei)*zmixc(ix,1))*
52460  & dconjg(t3i*zmixc(ij,2)-tanw*(t3i-ei)*zmixc(ij,1))
52461  grij=zmixc(ix,1)*dconjg(zmixc(ij,1))*(ei*tanw)**2
52462  cxc(1)=dcmplx((t3i-ei*xw)/xw1)*olpp
52463  cxc(2)=-glij
52464  cxc(3)=-dcmplx((t3i-ei*xw)/xw1)*orpp
52465  cxc(4)=dconjg(glij)
52466  cxc(5)=-dcmplx((ei*xw)/xw1)*olpp
52467  cxc(6)=grij
52468  cxc(7)=dcmplx((ei*xw)/xw1)*orpp
52469  cxc(8)=-dconjg(grij)
52470  s12min=0d0
52471  s12max=(axmi-axmj)**2
52472  IF( xxc(5).LT.axmi ) THEN
52473  xxc(5)=1d6
52474  ENDIF
52475  IF( xxc(6).LT.axmi ) THEN
52476  xxc(6)=1d6
52477  ENDIF
52478  xxc(7)=xxc(5)
52479  xxc(8)=xxc(6)
52480 
52481  lknt=lknt+1
52482  xlam(lknt)=c1**2/xmi3/(16d0*pi)*
52483  & pygaus(pyxxz6,s12min,s12max,1d-3)
52484  idlam(lknt,1)=kfnchi(ij)
52485  idlam(lknt,2)=12
52486  idlam(lknt,3)=-12
52487  lknt=lknt+1
52488  xlam(lknt)=xlam(lknt-1)
52489  idlam(lknt,1)=kfnchi(ij)
52490  idlam(lknt,2)=14
52491  idlam(lknt,3)=-14
52492  160 CONTINUE
52493 
52494  IF(pmas(pycomp(ksusy1+16),1).NE.pmas(pycomp(ksusy1+12),1))
52495  & THEN
52496  xxc(5)=pmas(pycomp(ksusy1+16),1)
52497  IF( xxc(5).LT.axmi ) THEN
52498  xxc(5)=1d6
52499  ENDIF
52500  xxc(7)=xxc(5)
52501  lknt=lknt+1
52502  xlam(lknt)=c1**2/xmi3/(16d0*pi)*
52503  & pygaus(pyxxz6,s12min,s12max,1d-3)
52504  ELSE
52505  lknt=lknt+1
52506  xlam(lknt)=xlam(lknt-1)
52507  ENDIF
52508  idlam(lknt,1)=kfnchi(ij)
52509  idlam(lknt,2)=16
52510  idlam(lknt,3)=-16
52511 C...D-TYPE QUARKS
52512  170 CONTINUE
52513  fid=1
52514  xxc(5)=pmas(pycomp(ksusy1+fid),1)
52515  xxc(6)=pmas(pycomp(ksusy2+fid),1)
52516  ei=kchg(fid,1)/3d0
52517  t3i=sign(1d0,ei+1d-6)/2d0
52518  glij=(t3i*zmixc(ix,2)-tanw*(t3i-ei)*zmixc(ix,1))*
52519  & dconjg(t3i*zmixc(ij,2)-tanw*(t3i-ei)*zmixc(ij,1))
52520  grij=zmixc(ix,1)*dconjg(zmixc(ij,1))*(ei*tanw)**2
52521  cxc(1)=dcmplx((t3i-ei*xw)/xw1)*olpp
52522  cxc(2)=-glij
52523  cxc(3)=-dcmplx((t3i-ei*xw)/xw1)*orpp
52524  cxc(4)=dconjg(glij)
52525  cxc(5)=-dcmplx((ei*xw)/xw1)*olpp
52526  cxc(6)=grij
52527  cxc(7)=dcmplx((ei*xw)/xw1)*orpp
52528  cxc(8)=-dconjg(grij)
52529  s12min=0d0
52530  s12max=(axmi-axmj)**2
52531  IF( xxc(5).LT.axmi ) THEN
52532  xxc(5)=1d6
52533  ENDIF
52534  IF( xxc(6).LT.axmi ) THEN
52535  xxc(6)=1d6
52536  ENDIF
52537  xxc(7)=xxc(5)
52538  xxc(8)=xxc(6)
52539 
52540  IF(axmi.GE.axmj+2d0*pmas(1,1)) THEN
52541  lknt=lknt+1
52542  xlam(lknt)=c1**2/xmi3/(16d0*pi)*
52543  & pygaus(pyxxz6,s12min,s12max,1d-3)*3d0
52544  idlam(lknt,1)=kfnchi(ij)
52545  idlam(lknt,2)=1
52546  idlam(lknt,3)=-1
52547  IF(axmi.GE.axmj+2d0*pmas(3,1)) THEN
52548  lknt=lknt+1
52549  xlam(lknt)=xlam(lknt-1)
52550  idlam(lknt,1)=kfnchi(ij)
52551  idlam(lknt,2)=3
52552  idlam(lknt,3)=-3
52553  ENDIF
52554  ENDIF
52555  180 CONTINUE
52556  IF(abs(sfmix(5,1)).GT.abs(sfmix(5,2))) THEN
52557  xxc(5)=pmas(pycomp(ksusy1+5),1)
52558  xxc(6)=pmas(pycomp(ksusy2+5),1)
52559  ELSE
52560  xxc(6)=pmas(pycomp(ksusy1+5),1)
52561  xxc(5)=pmas(pycomp(ksusy2+5),1)
52562  ENDIF
52563  IF( xxc(5).LT.axmi .AND. xxc(6).LT.axmi ) goto 190
52564  IF(xxc(5).LT.axmi) THEN
52565  xxc(5)=1d6
52566  ELSEIF(xxc(6).LT.axmi) THEN
52567  xxc(6)=1d6
52568  ENDIF
52569  xxc(7)=xxc(5)
52570  xxc(8)=xxc(6)
52571  IF(axmi.GE.axmj+2d0*pmas(5,1)) THEN
52572  lknt=lknt+1
52573  xlam(lknt)=c1**2/xmi3/(16d0*pi)*
52574  & pygaus(pyxxz6,s12min,s12max,1d-3)*3d0
52575  idlam(lknt,1)=kfnchi(ij)
52576  idlam(lknt,2)=5
52577  idlam(lknt,3)=-5
52578  ENDIF
52579 
52580 C...U-TYPE QUARKS
52581  190 CONTINUE
52582  fid=2
52583  xxc(5)=pmas(pycomp(ksusy1+fid),1)
52584  xxc(6)=pmas(pycomp(ksusy2+fid),1)
52585  ei=kchg(fid,1)/3d0
52586  t3i=sign(1d0,ei+1d-6)/2d0
52587  glij=(t3i*zmixc(ix,2)-tanw*(t3i-ei)*zmixc(ix,1))*
52588  & dconjg(t3i*zmixc(ij,2)-tanw*(t3i-ei)*zmixc(ij,1))
52589  grij=zmixc(ix,1)*dconjg(zmixc(ij,1))*(ei*tanw)**2
52590  cxc(1)=dcmplx((t3i-ei*xw)/xw1)*olpp
52591  cxc(2)=-glij
52592  cxc(3)=-dcmplx((t3i-ei*xw)/xw1)*orpp
52593  cxc(4)=dconjg(glij)
52594  cxc(5)=-dcmplx((ei*xw)/xw1)*olpp
52595  cxc(6)=grij
52596  cxc(7)=dcmplx((ei*xw)/xw1)*orpp
52597  cxc(8)=-dconjg(grij)
52598 
52599  IF( xxc(5).LT.axmi .AND. xxc(6).LT.axmi ) goto 200
52600  IF(xxc(5).LT.axmi) THEN
52601  xxc(5)=1d6
52602  ELSEIF(xxc(6).LT.axmi) THEN
52603  xxc(6)=1d6
52604  ENDIF
52605  xxc(7)=xxc(5)
52606  xxc(8)=xxc(6)
52607 
52608  IF(axmi.GE.axmj+2d0*pmas(2,1)) THEN
52609  lknt=lknt+1
52610  xlam(lknt)=c1**2/xmi3/(16d0*pi)*
52611  & pygaus(pyxxz6,s12min,s12max,1d-3)*3d0
52612  idlam(lknt,1)=kfnchi(ij)
52613  idlam(lknt,2)=2
52614  idlam(lknt,3)=-2
52615  IF(axmi.GE.axmj+2d0*pmas(4,1)) THEN
52616  lknt=lknt+1
52617  xlam(lknt)=xlam(lknt-1)
52618  idlam(lknt,1)=kfnchi(ij)
52619  idlam(lknt,2)=4
52620  idlam(lknt,3)=-4
52621  ENDIF
52622  ENDIF
52623  200 CONTINUE
52624  ENDIF
52625 
52626 C...CHI0_I -> CHI0_J + H0_K
52627  eh(1)=sin(alfa)
52628  eh(2)=cos(alfa)
52629  eh(3)=-sin(beta)
52630  dh(1)=cos(alfa)
52631  dh(2)=-sin(alfa)
52632  dh(3)=cos(beta)
52633  qij=zmixc(ix,3)*dconjg(zmixc(ij,2))+
52634  & dconjg(zmixc(ij,3))*zmixc(ix,2)-
52635  & tanw*(zmixc(ix,3)*dconjg(zmixc(ij,1))+
52636  & dconjg(zmixc(ij,3))*zmixc(ix,1))
52637  rij=dconjg(zmixc(ix,4))*zmixc(ij,2)+
52638  & zmixc(ij,4)*dconjg(zmixc(ix,2))-
52639  & tanw*(dconjg(zmixc(ix,4))*zmixc(ij,1)+
52640  & zmixc(ij,4)*dconjg(zmixc(ix,1)))
52641  DO 210 ih=1,3
52642  xmh=pmas(ith(ih),1)
52643  xmh2=xmh**2
52644  IF(axmi.GE.axmj+xmh) THEN
52645  lknt=lknt+1
52646  xl=pylamf(xmi2,xmj2,xmh2)
52647  f21k=0.5d0*(qij*eh(ih)+rij*dh(ih))
52648  f12k=f21k
52649 C...SIGN OF MASSES I,J
52650  xmk=xmj
52651  IF(ih.EQ.3) xmk=-xmk
52652  gx2=abs(f21k)**2+abs(f12k)**2
52653  glr=dble(f21k*dconjg(f12k))
52654  xlam(lknt)=pyx2xh(c1,xmi,xmk,xmh,gx2,glr)
52655  idlam(lknt,1)=kfnchi(ij)
52656  idlam(lknt,2)=ith(ih)
52657  idlam(lknt,3)=0
52658  ENDIF
52659  210 CONTINUE
52660  220 CONTINUE
52661 
52662 C...CHI0_I -> CHI+_J + W-
52663  DO 260 ij=1,2
52664  xmj=smw(ij)
52665  axmj=abs(xmj)
52666  xmj2=xmj**2
52667  IF(axmi.GE.axmj+xmw) THEN
52668  lknt=lknt+1
52669  cxc(1)=(dconjg(zmixc(ix,2))*vmixc(ij,1)-
52670  & dconjg(zmixc(ix,4))*vmixc(ij,2)/sr2)
52671  cxc(3)=(zmixc(ix,2)*dconjg(umixc(ij,1))+
52672  & zmixc(ix,3)*dconjg(umixc(ij,2))/sr2)
52673  gx2=abs(cxc(1))**2+abs(cxc(3))**2
52674  glr=dble(cxc(1)*dconjg(cxc(3)))
52675  xlam(lknt)=pyx2xg(c1/xmw2,xmi,xmj,xmw,gx2,glr)
52676  idlam(lknt,1)=kfcchi(ij)
52677  idlam(lknt,2)=-24
52678  idlam(lknt,3)=0
52679  lknt=lknt+1
52680  xlam(lknt)=xlam(lknt-1)
52681  idlam(lknt,1)=-kfcchi(ij)
52682  idlam(lknt,2)=24
52683  idlam(lknt,3)=0
52684  ELSEIF(axmi.GE.axmj) THEN
52685  s12min=0d0
52686  s12max=(axmi-axmj)**2
52687  rt2i = 1d0/sqrt(2d0)
52688  cxc(1)=(dconjg(zmixc(ix,2))*vmixc(ij,1)-
52689  & dconjg(zmixc(ix,4))*vmixc(ij,2)*rt2i)*rt2i
52690  cxc(3)=(zmixc(ix,2)*dconjg(umixc(ij,1))+
52691  & zmixc(ix,3)*dconjg(umixc(ij,2))*rt2i)*rt2i
52692  cxc(5)=dcmplx(0d0,0d0)
52693  cxc(7)=dcmplx(0d0,0d0)
52694  ia=11
52695  ja=12
52696  ei=kchg(ia,1)/3d0
52697  t3i=sign(1d0,ei+1d-6)/2d0
52698  ej=kchg(ja,1)/3d0
52699  t3j=sign(1d0,ej+1d-6)/2d0
52700  cxc(2)=vmixc(ij,1)*dconjg(zmixc(ix,1)*(ej-t3j)*
52701  & tanw+zmixc(ix,2)*t3j)*rt2i
52702  cxc(4)=-dconjg(umixc(ij,1))*(
52703  & zmixc(ix,1)*(ei-t3i)*tanw+zmixc(ix,2)*t3i)*rt2i
52704  cxc(6)=dcmplx(0d0,0d0)
52705  cxc(8)=dcmplx(0d0,0d0)
52706  xxc(1)=0d0
52707  xxc(2)=xmj
52708  xxc(3)=0d0
52709  xxc(4)=xmi
52710  xxc(5)=pmas(pycomp(ksusy1+ja),1)
52711  xxc(6)=pmas(pycomp(ksusy1+ia),1)
52712  xxc(9)=pmas(24,1)
52713  xxc(10)=pmas(24,2)
52714  IF( xxc(5).LT.axmi .AND. xxc(6).LT.axmi ) goto 230
52715  IF(xxc(5).LT.axmi) THEN
52716  xxc(5)=1d6
52717  ELSEIF(xxc(6).LT.axmi) THEN
52718  xxc(6)=1d6
52719  ENDIF
52720  xxc(7)=xxc(6)
52721  xxc(8)=xxc(5)
52722  IF(axmi.GE.axmj+pmas(11,1)+pmas(12,1)) THEN
52723  lknt=lknt+1
52724  xlam(lknt)=c1**2/xmi3/(16d0*pi)*
52725  & pygaus(pyxxz6,s12min,s12max,prec)
52726  idlam(lknt,1)=kfcchi(ij)
52727  idlam(lknt,2)=11
52728  idlam(lknt,3)=-12
52729  lknt=lknt+1
52730  xlam(lknt)=xlam(lknt-1)
52731  idlam(lknt,1)=-idlam(lknt-1,1)
52732  idlam(lknt,2)=-idlam(lknt-1,2)
52733  idlam(lknt,3)=-idlam(lknt-1,3)
52734  IF(axmi.GE.axmj+pmas(13,1)+pmas(14,1)) THEN
52735  lknt=lknt+1
52736  xlam(lknt)=xlam(lknt-1)
52737  idlam(lknt,1)=kfcchi(ij)
52738  idlam(lknt,2)=13
52739  idlam(lknt,3)=-14
52740  lknt=lknt+1
52741  xlam(lknt)=xlam(lknt-1)
52742  idlam(lknt,1)=-idlam(lknt-1,1)
52743  idlam(lknt,2)=-idlam(lknt-1,2)
52744  idlam(lknt,3)=-idlam(lknt-1,3)
52745  ENDIF
52746  ENDIF
52747  230 CONTINUE
52748  IF(abs(sfmix(15,1)).GT.abs(sfmix(15,2))) THEN
52749  xxc(5)=pmas(pycomp(ksusy1+15),1)
52750  xxc(6)=pmas(pycomp(ksusy1+16),1)
52751  ELSE
52752  xxc(5)=pmas(pycomp(ksusy2+15),1)
52753  xxc(6)=pmas(pycomp(ksusy1+16),1)
52754  ENDIF
52755  IF(xxc(5).LT.axmi) THEN
52756  xxc(5)=1d6
52757  ENDIF
52758  IF(xxc(6).LT.axmi) THEN
52759  xxc(6)=1d6
52760  ENDIF
52761  xxc(7)=xxc(6)
52762  xxc(8)=xxc(5)
52763  IF(axmi.GE.axmj+pmas(15,1)+pmas(16,1)) THEN
52764  lknt=lknt+1
52765  xlam(lknt)=c1**2/xmi3/(16d0*pi)*
52766  & pygaus(pyxxz6,s12min,s12max,prec)
52767  xlam(lknt)=xlam(lknt-1)
52768  idlam(lknt,1)=kfcchi(ij)
52769  idlam(lknt,2)=15
52770  idlam(lknt,3)=-16
52771  lknt=lknt+1
52772  xlam(lknt)=xlam(lknt-1)
52773  idlam(lknt,1)=-idlam(lknt-1,1)
52774  idlam(lknt,2)=-idlam(lknt-1,2)
52775  idlam(lknt,3)=-idlam(lknt-1,3)
52776  ENDIF
52777 
52778 C...NOW, DO THE QUARKS
52779  240 CONTINUE
52780  ia=1
52781  ja=2
52782  ei=kchg(ia,1)/3d0
52783  t3i=sign(1d0,ei+1d-6)/2d0
52784  ej=kchg(ja,1)/3d0
52785  t3j=sign(1d0,ej+1d-6)/2d0
52786  cxc(2)=vmixc(ij,1)*dconjg(zmixc(ix,1)*(ej-t3j)*
52787  & tanw+zmixc(ix,2)*t3j)
52788  cxc(4)=-dconjg(umixc(ij,1))*(
52789  & zmixc(ix,1)*(ei-t3i)*tanw+zmixc(ix,2)*t3i)
52790  xxc(5)=pmas(pycomp(ksusy1+ia),1)
52791  xxc(6)=pmas(pycomp(ksusy1+ja),1)
52792  IF(xxc(5).LT.axmi) THEN
52793  xxc(5)=1d6
52794  ENDIF
52795  IF(xxc(6).LT.axmi) THEN
52796  xxc(6)=1d6
52797  ENDIF
52798  xxc(7)=xxc(6)
52799  xxc(8)=xxc(5)
52800  IF(axmi.GE.axmj+pmas(2,1)+pmas(1,1)) THEN
52801  lknt=lknt+1
52802  xlam(lknt)=3d0*c1**2/xmi3/(16d0*pi)*
52803  & pygaus(pyxxz6,s12min,s12max,prec)
52804  idlam(lknt,1)=kfcchi(ij)
52805  idlam(lknt,2)=1
52806  idlam(lknt,3)=-2
52807  lknt=lknt+1
52808  xlam(lknt)=xlam(lknt-1)
52809  idlam(lknt,1)=-idlam(lknt-1,1)
52810  idlam(lknt,2)=-idlam(lknt-1,2)
52811  idlam(lknt,3)=-idlam(lknt-1,3)
52812  IF(axmi.GE.axmj+pmas(3,1)+pmas(4,1)) THEN
52813  lknt=lknt+1
52814  xlam(lknt)=xlam(lknt-1)
52815  idlam(lknt,1)=kfcchi(ij)
52816  idlam(lknt,2)=3
52817  idlam(lknt,3)=-4
52818  lknt=lknt+1
52819  xlam(lknt)=xlam(lknt-1)
52820  idlam(lknt,1)=-idlam(lknt-1,1)
52821  idlam(lknt,2)=-idlam(lknt-1,2)
52822  idlam(lknt,3)=-idlam(lknt-1,3)
52823  ENDIF
52824  ENDIF
52825  250 CONTINUE
52826  ENDIF
52827  260 CONTINUE
52828  270 CONTINUE
52829 
52830 C...CHI0_I -> CHI+_I + H-
52831  DO 280 ij=1,2
52832  xmj=smw(ij)
52833  axmj=abs(xmj)
52834  xmj2=xmj**2
52835  xmhp=pmas(ithc,1)
52836  IF(axmi.GE.axmj+xmhp) THEN
52837  lknt=lknt+1
52838  olpp=cbeta*(zmixc(ix,4)*dconjg(vmixc(ij,1))+(zmixc(ix,2)+
52839  & zmixc(ix,1)*tanw)*dconjg(vmixc(ij,2))/sr2)
52840  orpp=sbeta*(dconjg(zmixc(ix,3))*umixc(ij,1)-
52841  & (dconjg(zmixc(ix,2))+dconjg(zmixc(ix,1))*tanw)*
52842  & umixc(ij,2)/sr2)
52843  gx2=abs(olpp)**2+abs(orpp)**2
52844  glr=dble(olpp*dconjg(orpp))
52845  xlam(lknt)=pyx2xh(c1,xmi,xmj,xmhp,gx2,glr)
52846  idlam(lknt,1)=kfcchi(ij)
52847  idlam(lknt,2)=-ithc
52848  idlam(lknt,3)=0
52849  lknt=lknt+1
52850  xlam(lknt)=xlam(lknt-1)
52851  idlam(lknt,1)=-idlam(lknt-1,1)
52852  idlam(lknt,2)=-idlam(lknt-1,2)
52853  idlam(lknt,3)=-idlam(lknt-1,3)
52854  ELSE
52855 
52856  ENDIF
52857  280 CONTINUE
52858 
52859 C...2-BODY DECAYS TO FERMION SFERMION
52860  DO 290 j=1,16
52861  IF(j.GE.7.AND.j.LE.10) goto 290
52862  kf1=ksusy1+j
52863  kf2=ksusy2+j
52864  xmsf1=pmas(pycomp(kf1),1)
52865  xmsf2=pmas(pycomp(kf2),1)
52866  xmf=pmas(j,1)
52867  IF(j.LE.6) THEN
52868  fcol=3d0
52869  ELSE
52870  fcol=1d0
52871  ENDIF
52872 
52873  ei=kchg(j,1)/3d0
52874  t3t=sign(1d0,ei)
52875  IF(j.EQ.12.OR.j.EQ.14.OR.j.EQ.16) t3t=1d0
52876  IF(mod(j,2).EQ.0) THEN
52877  cbl=t3t*zmixc(ix,2)+tanw*zmixc(ix,1)*(2d0*ei-t3t)
52878  cal=xmf*zmixc(ix,4)/xmw/sbeta
52879  car=-2d0*ei*tanw*zmixc(ix,1)
52880  cbr=cal
52881  ELSE
52882  cbl=t3t*zmixc(ix,2)+tanw*zmixc(ix,1)*(2d0*ei-t3t)
52883  cal=xmf*zmixc(ix,3)/xmw/cbeta
52884  car=-2d0*ei*tanw*zmixc(ix,1)
52885  cbr=cal
52886  ENDIF
52887 
52888 C...D~ D_L
52889  IF(axmi.GE.xmf+xmsf1) THEN
52890  lknt=lknt+1
52891  xma2=xmsf1**2
52892  xmb2=xmf**2
52893  xl=pylamf(xmi2,xma2,xmb2)
52894  ca=cal*sfmix(j,1)+car*sfmix(j,2)
52895  cb=cbl*sfmix(j,1)+cbr*sfmix(j,2)
52896  xlam(lknt)=0.5d0*fcol*c1/8d0/xmi3*sqrt(xl)*( (xmi2+xmb2-xma2)*
52897  & (abs(ca)**2+abs(cb)**2)+4d0*dble(ca*dconjg(cb))*xmf*xmi)
52898  idlam(lknt,1)=kf1
52899  idlam(lknt,2)=-j
52900  idlam(lknt,3)=0
52901  lknt=lknt+1
52902  xlam(lknt)=xlam(lknt-1)
52903  idlam(lknt,1)=-idlam(lknt-1,1)
52904  idlam(lknt,2)=-idlam(lknt-1,2)
52905  idlam(lknt,3)=0
52906  ENDIF
52907 
52908 C...D~ D_R
52909  IF(axmi.GE.xmf+xmsf2) THEN
52910  lknt=lknt+1
52911  xma2=xmsf2**2
52912  xmb2=xmf**2
52913  ca=cal*sfmix(j,3)+car*sfmix(j,4)
52914  cb=cbl*sfmix(j,3)+cbr*sfmix(j,4)
52915  xl=pylamf(xmi2,xma2,xmb2)
52916  xlam(lknt)=0.5d0*fcol*c1/8d0/xmi3*sqrt(xl)*( (xmi2+xmb2-xma2)*
52917  & (abs(ca)**2+abs(cb)**2)+4d0*dble(ca*dconjg(cb))*xmf*xmi)
52918  idlam(lknt,1)=kf2
52919  idlam(lknt,2)=-j
52920  idlam(lknt,3)=0
52921  lknt=lknt+1
52922  xlam(lknt)=xlam(lknt-1)
52923  idlam(lknt,1)=-idlam(lknt-1,1)
52924  idlam(lknt,2)=-idlam(lknt-1,2)
52925  idlam(lknt,3)=0
52926  ENDIF
52927  290 CONTINUE
52928  300 CONTINUE
52929 C...3-BODY DECAY TO Q Q~ GLUINO
52930  xmj=pmas(pycomp(ksusy1+21),1)
52931  IF(axmi.GE.xmj) THEN
52932  rt2i = 1d0/sqrt(2d0)
52933  olpp=dcmplx(cos(rmss(32)),sin(rmss(32)))*rt2i
52934  orpp=dconjg(olpp)
52935  axmj=abs(xmj)
52936  xxc(1)=0d0
52937  xxc(2)=xmj
52938  xxc(3)=0d0
52939  xxc(4)=xmi
52940  fid=1
52941  xxc(5)=pmas(pycomp(ksusy1+fid),1)
52942  xxc(6)=pmas(pycomp(ksusy2+fid),1)
52943  xxc(7)=xxc(5)
52944  xxc(8)=xxc(6)
52945  xxc(9)=1d6
52946  xxc(10)=0d0
52947  ei=kchg(fid,1)/3d0
52948  t3i=sign(1d0,ei+1d-6)/2d0
52949  glij=(t3i*zmixc(ix,2)-tanw*(t3i-ei)*zmixc(ix,1))*olpp
52950  grij=zmixc(ix,1)*(ei*tanw)*orpp
52951  cxc(1)=0d0
52952  cxc(2)=-glij
52953  cxc(3)=0d0
52954  cxc(4)=dconjg(glij)
52955  cxc(5)=0d0
52956  cxc(6)=grij
52957  cxc(7)=0d0
52958  cxc(8)=-dconjg(grij)
52959  s12min=0d0
52960  s12max=(axmi-axmj)**2
52961 CMRENNA.This statement must be here to define S12MAX
52962  IF( xxc(5).LT.axmi .OR. xxc(6).LT.axmi ) goto 310
52963 C...ALL QUARKS BUT T
52964  IF(axmi.GE.axmj+2d0*pmas(1,1)) THEN
52965  lknt=lknt+1
52966  xlam(lknt)=4d0*c1*as/xmi3/(16d0*pi)*
52967  & pygaus(pyxxz6,s12min,s12max,1d-3)
52968  idlam(lknt,1)=ksusy1+21
52969  idlam(lknt,2)=1
52970  idlam(lknt,3)=-1
52971  IF(axmi.GE.axmj+2d0*pmas(3,1)) THEN
52972  lknt=lknt+1
52973  xlam(lknt)=xlam(lknt-1)
52974  idlam(lknt,1)=ksusy1+21
52975  idlam(lknt,2)=3
52976  idlam(lknt,3)=-3
52977  ENDIF
52978  ENDIF
52979  310 CONTINUE
52980  IF(abs(sfmix(5,1)).GT.abs(sfmix(5,2))) THEN
52981  xxc(5)=pmas(pycomp(ksusy1+5),1)
52982  xxc(6)=pmas(pycomp(ksusy2+5),1)
52983  ELSE
52984  xxc(6)=pmas(pycomp(ksusy1+5),1)
52985  xxc(5)=pmas(pycomp(ksusy2+5),1)
52986  ENDIF
52987  IF( xxc(5).LT.axmi .OR. xxc(6).LT.axmi ) goto 320
52988  xxc(7)=xxc(5)
52989  xxc(8)=xxc(6)
52990  IF(axmi.GE.axmj+2d0*pmas(5,1)) THEN
52991  lknt=lknt+1
52992  xlam(lknt)=0.5d0*c1*as/xmi3/(16d0*pi)*
52993  & pygaus(pyxxz6,s12min,s12max,1d-3)
52994  idlam(lknt,1)=ksusy1+21
52995  idlam(lknt,2)=5
52996  idlam(lknt,3)=-5
52997  ENDIF
52998 C...U-TYPE QUARKS
52999  320 CONTINUE
53000  fid=2
53001  xxc(5)=pmas(pycomp(ksusy1+fid),1)
53002  xxc(6)=pmas(pycomp(ksusy2+fid),1)
53003  IF( xxc(5).LT.axmi .OR. xxc(6).LT.axmi ) goto 330
53004  xxc(7)=xxc(5)
53005  xxc(8)=xxc(6)
53006  ei=kchg(fid,1)/3d0
53007  t3i=sign(1d0,ei+1d-6)/2d0
53008  glij=(t3i*zmixc(ix,2)-tanw*(t3i-ei)*zmixc(ix,1))*olpp
53009  grij=zmixc(ix,1)*(ei*tanw)*orpp
53010  cxc(2)=-glij
53011  cxc(4)=dconjg(glij)
53012  cxc(6)=grij
53013  cxc(8)=-dconjg(grij)
53014  IF(axmi.GE.axmj+2d0*pmas(2,1)) THEN
53015  lknt=lknt+1
53016  xlam(lknt)=0.5d0*c1*as/xmi3/(16d0*pi)*
53017  & pygaus(pyxxz6,s12min,s12max,1d-3)
53018  idlam(lknt,1)=ksusy1+21
53019  idlam(lknt,2)=2
53020  idlam(lknt,3)=-2
53021  IF(axmi.GE.axmj+2d0*pmas(4,1)) THEN
53022  lknt=lknt+1
53023  xlam(lknt)=xlam(lknt-1)
53024  idlam(lknt,1)=ksusy1+21
53025  idlam(lknt,2)=4
53026  idlam(lknt,3)=-4
53027  ENDIF
53028  ENDIF
53029  330 CONTINUE
53030  ENDIF
53031 
53032 C...R-violating decay modes (SKANDS).
53033  CALL pyrvne(kfin,xlam,idlam,lknt)
53034 
53035  340 iknt=lknt
53036  xlam(0)=0d0
53037  DO 350 i=1,iknt
53038  IF(xlam(i).LT.0d0) xlam(i)=0d0
53039  xlam(0)=xlam(0)+xlam(i)
53040  350 CONTINUE
53041  IF(xlam(0).EQ.0d0) xlam(0)=1d-6
53042 
53043  RETURN
53044  END
53045 
53046 C*********************************************************************
53047 
53048 C...PYCJDC
53049 C...Calculate decay widths for the charginos (admixtures of
53050 C...charged Wino and charged Higgsino.
53051 
53052 C...Input: KCIN = KF code for particle
53053 C...Output: XLAM = widths
53054 C... IDLAM = KF codes for decay particles
53055 C... IKNT = number of decay channels defined
53056 C...AUTHOR: STEPHEN MRENNA
53057 C...Last change:
53058 C...10-16-95: force decay chi^+_1 -> chi^0_1 e+ nu_e
53059 C...when CHIENU .NE. 0
53060 
53061  SUBROUTINE pycjdc(KFIN,XLAM,IDLAM,IKNT)
53062 
53063 C...Double precision and integer declarations.
53064  IMPLICIT DOUBLE PRECISION(a-h, o-z)
53065  IMPLICIT INTEGER(i-n)
53066  INTEGER pyk,pychge,pycomp
53067 C...Parameter statement to help give large particle numbers.
53068  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
53069  &kexcit=4000000,kdimen=5000000)
53070 C...Commonblocks.
53071  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
53072  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
53073  common/pymssm/imss(0:99),rmss(0:99)
53074  common/pyssmt/zmix(4,4),umix(2,2),vmix(2,2),smz(4),smw(2),
53075  &sfmix(16,4),zmixi(4,4),umixi(2,2),vmixi(2,2)
53076 CC &SFMIX(16,4),
53077 C COMMON/PYINTS/XXM(20)
53078  COMPLEX*16 cxc
53079  common/pyintc/xxc(10),cxc(8)
53080  SAVE /pydat1/,/pydat2/,/pymssm/,/pyssmt/,/pyintc/
53081 
53082 C...Local variables
53083  COMPLEX*16 zmixc(4,4),vmixc(2,2),umixc(2,2),olpp,orpp
53084  COMPLEX*16 cal,cbl,car,cbr,ca,cb
53085  INTEGER kfin,kcin
53086  DOUBLE PRECISION xmi,xmj,xmf,xmsf1,xmsf2,xmw,xmw2,
53087  &xmz,xmz2,axmj,axmi
53088  DOUBLE PRECISION s12min,s12max
53089  DOUBLE PRECISION xmi2,xmi3,xmj2,xmh,xmh2,xmhp,xma2,xmb2,xmk
53090  DOUBLE PRECISION pylamf,xl
53091  DOUBLE PRECISION tanw,xw,aem,c1,as,ei,t3i,beta,alfa
53092  DOUBLE PRECISION pyx2xh,pyx2xg
53093  DOUBLE PRECISION xlam(0:400)
53094  INTEGER idlam(400,3)
53095  INTEGER lknt,ix,ih,j,ij,i,iknt
53096  INTEGER ith(3)
53097  INTEGER ithc
53098  DOUBLE PRECISION etah(3),dh(3),eh(3)
53099  DOUBLE PRECISION sr2
53100  DOUBLE PRECISION cbeta,sbeta,tanb
53101 
53102  DOUBLE PRECISION pyalem,pi,pyalps
53103  DOUBLE PRECISION fcol
53104  INTEGER kf1,kf2,isf
53105  INTEGER kfnchi(4),kfcchi(2)
53106 
53107  DOUBLE PRECISION temp
53108  EXTERNAL pygaus,pyxxz6
53109  DOUBLE PRECISION pygaus,pyxxz6
53110  DOUBLE PRECISION prec
53111  DATA ith/25,35,36/
53112  DATA ithc/37/
53113  DATA etah/1d0,1d0,-1d0/
53114  DATA sr2/1.4142136d0/
53115  DATA pi/3.141592654d0/
53116  DATA prec/1d-2/
53117  DATA kfnchi/1000022,1000023,1000025,1000035/
53118  DATA kfcchi/1000024,1000037/
53119 
53120 C...COUNT THE NUMBER OF DECAY MODES
53121  lknt=0
53122  xmw=pmas(24,1)
53123  xmw2=xmw**2
53124  xmz=pmas(23,1)
53125  xmz2=xmz**2
53126  xw=1d0-xmw2/xmz2
53127  xw1=1d0-xw
53128  tanw = sqrt(xw/xw1)
53129 
53130 C...1 OR 2 DEPENDING ON CHARGINO TYPE
53131  ix=1
53132  IF(kfin.EQ.kfcchi(2)) ix=2
53133  kcin=pycomp(kfin)
53134 
53135  xmi=smw(ix)
53136  xmi2=xmi**2
53137  axmi=abs(xmi)
53138  aem=pyalem(xmi2)
53139  as =pyalps(xmi2)
53140  c1=aem/xw
53141  xmi3=abs(xmi**3)
53142  tanb=rmss(5)
53143  beta=atan(tanb)
53144  cbeta=cos(beta)
53145  sbeta=tanb*cbeta
53146  alfa=rmss(18)
53147 
53148  DO 110 i=1,2
53149  DO 100 j=1,2
53150  vmixc(j,i)=dcmplx(vmix(j,i),vmixi(j,i))
53151  umixc(j,i)=dcmplx(umix(j,i),umixi(j,i))
53152  100 CONTINUE
53153  110 CONTINUE
53154 
53155 C...GRAVITINO DECAY MODES
53156 
53157  IF(imss(11).EQ.1) THEN
53158  xmp=rmss(29)
53159  idg=39+ksusy1
53160  xmgr=pmas(pycomp(idg),1)
53161 C SINW=SQRT(XW)
53162 C COSW=SQRT(1D0-XW)
53163  xfac=(xmi2/(xmp*xmgr))**2*axmi/48d0/pi
53164  IF(axmi.GT.xmgr+xmw) THEN
53165  lknt=lknt+1
53166  idlam(lknt,1)=idg
53167  idlam(lknt,2)=24
53168  idlam(lknt,3)=0
53169  xlam(lknt)=xfac*(
53170  & .5d0*(abs(vmixc(ix,1))**2+abs(umixc(ix,1))**2)+
53171  & .5d0*((abs(vmixc(ix,2))*sbeta)**2+(abs(umixc(ix,2))*cbeta)**2))*
53172  & (1d0-xmw2/xmi2)**4
53173  ENDIF
53174  IF(axmi.GT.xmgr+pmas(37,1)) THEN
53175  lknt=lknt+1
53176  idlam(lknt,1)=idg
53177  idlam(lknt,2)=37
53178  idlam(lknt,3)=0
53179  xlam(lknt)=xfac*(.5d0*((abs(vmixc(ix,2))*cbeta)**2+
53180  & (abs(umixc(ix,2))*sbeta)**2))
53181  & *(1d0-pmas(37,1)**2/xmi2)**4
53182  ENDIF
53183  ENDIF
53184 
53185 C...CHECK ALL 2-BODY DECAYS TO GAUGE AND HIGGS BOSONS
53186  IF(ix.EQ.1) goto 170
53187  xmj=smw(1)
53188  axmj=abs(xmj)
53189  xmj2=xmj**2
53190 
53191 C...CHI_2+ -> CHI_1+ + Z0
53192  IF(axmi.GE.axmj+xmz) THEN
53193  lknt=lknt+1
53194  ij=1
53195  olpp=-vmixc(ij,1)*dconjg(vmixc(ix,1))-
53196  & vmixc(ij,2)*dconjg(vmixc(ix,2))/2d0
53197  orpp=-umixc(ix,1)*dconjg(umixc(ij,1))-
53198  & umixc(ix,2)*dconjg(umixc(ij,2))/2d0
53199  gx2=abs(olpp)**2+abs(orpp)**2
53200  glr=dble(olpp*dconjg(orpp))
53201  xlam(lknt)=pyx2xg(c1/xmw2,xmi,xmj,xmz,gx2,glr)
53202  idlam(lknt,1)=kfcchi(1)
53203  idlam(lknt,2)=23
53204  idlam(lknt,3)=0
53205 
53206 C...CHARGED LEPTONS
53207  ELSEIF(axmi.GE.axmj) THEN
53208  s12min=0d0
53209  s12max=(axmi-axmj)**2
53210  ia=11
53211  ja=12
53212  ei=kchg(iabs(ia),1)/3d0
53213  t3i=sign(1d0,ei+1d-6)/2d0
53214  xxc(1)=0d0
53215  xxc(2)=xmj
53216  xxc(3)=0d0
53217  xxc(4)=xmi
53218  xxc(5)=pmas(pycomp(ksusy1+ja),1)
53219  xxc(6)=1d6
53220  xxc(9)=pmas(23,1)
53221  xxc(10)=pmas(23,2)
53222  ij=1
53223  olpp=-vmixc(ij,1)*dconjg(vmixc(ix,1))-
53224  & vmixc(ij,2)*dconjg(vmixc(ix,2))/2d0
53225  orpp=-umixc(ix,1)*dconjg(umixc(ij,1))-
53226  & umixc(ix,2)*dconjg(umixc(ij,2))/2d0
53227  cxc(1)=dcmplx((t3i-xw*ei)/xw/xw1)*orpp
53228  cxc(2)=dcmplx(0d0,0d0)
53229  cxc(3)=dcmplx((t3i-xw*ei)/xw/xw1)*olpp
53230  cxc(4)=-vmixc(ij,1)*dconjg(vmixc(ix,1))*dcmplx(t3i/xw)
53231  cxc(5)=-dcmplx(ei/xw1)*orpp
53232  cxc(6)=dcmplx(0d0,0d0)
53233  cxc(7)=-dcmplx(ei/xw1)*olpp
53234  cxc(8)=dcmplx(0d0,0d0)
53235  IF( xxc(5).LT.axmi ) THEN
53236  xxc(5)=1d6
53237  ENDIF
53238  xxc(7)=xxc(5)
53239  xxc(8)=xxc(6)
53240  IF(axmi.GE.axmj+2d0*pmas(11,1)) THEN
53241  lknt=lknt+1
53242  xlam(lknt)=c1**2/xmi3/(16d0*pi)*
53243  & pygaus(pyxxz6,s12min,s12max,prec)
53244  idlam(lknt,1)=kfcchi(1)
53245  idlam(lknt,2)=11
53246  idlam(lknt,3)=-11
53247  IF(axmi.GE.axmj+2d0*pmas(13,1)) THEN
53248  lknt=lknt+1
53249  xlam(lknt)=xlam(lknt-1)
53250  idlam(lknt,1)=kfcchi(1)
53251  idlam(lknt,2)=13
53252  idlam(lknt,3)=-13
53253  ENDIF
53254  IF(axmi.GE.axmj+2d0*pmas(15,1)) THEN
53255  lknt=lknt+1
53256  xlam(lknt)=xlam(lknt-1)
53257  idlam(lknt,1)=kfcchi(1)
53258  idlam(lknt,2)=15
53259  idlam(lknt,3)=-15
53260  ENDIF
53261  ENDIF
53262 
53263 C...NEUTRINOS
53264  120 CONTINUE
53265  ia=12
53266  ja=11
53267  ei=kchg(iabs(ia),1)/3d0
53268  t3i=sign(1d0,ei+1d-6)/2d0
53269  xxc(5)=pmas(pycomp(ksusy1+ja),1)
53270  xxc(6)=1d6
53271  cxc(1)=dcmplx((t3i-xw*ei)/xw/xw1)*orpp
53272  cxc(3)=dcmplx((t3i-xw*ei)/xw/xw1)*olpp
53273  cxc(4)=-umixc(ij,1)*dconjg(umixc(ix,1))*dcmplx(t3i/xw)
53274  cxc(5)=-dcmplx(ei/xw1)*orpp
53275  cxc(7)=-dcmplx(ei/xw1)*olpp
53276  IF( xxc(5).LT.axmi ) THEN
53277  xxc(5)=1d6
53278  ENDIF
53279  xxc(7)=xxc(5)
53280  xxc(8)=xxc(6)
53281  IF(axmi.GE.axmj+2d0*pmas(12,1)) THEN
53282  lknt=lknt+1
53283  xlam(lknt)=c1**2/xmi3/(16d0*pi)*
53284  & pygaus(pyxxz6,s12min,s12max,prec)
53285  idlam(lknt,1)=kfcchi(1)
53286  idlam(lknt,2)=12
53287  idlam(lknt,3)=-12
53288  lknt=lknt+1
53289  xlam(lknt)=xlam(lknt-1)
53290  idlam(lknt,1)=kfcchi(1)
53291  idlam(lknt,2)=14
53292  idlam(lknt,3)=-14
53293  ENDIF
53294  IF(axmi.GE.axmj+2d0*pmas(16,1)) THEN
53295  IF(abs(sfmix(15,1)).GT.abs(sfmix(15,2))) THEN
53296  xxc(5)=pmas(pycomp(ksusy1+15),1)
53297  ELSE
53298  xxc(5)=pmas(pycomp(ksusy2+15),1)
53299  ENDIF
53300  IF( xxc(5).LT.axmi ) THEN
53301  xxc(5)=1d6
53302  ENDIF
53303  xxc(7)=xxc(5)
53304  lknt=lknt+1
53305  xlam(lknt)=c1**2/xmi3/(16d0*pi)*
53306  & pygaus(pyxxz6,s12min,s12max,prec)
53307  idlam(lknt,1)=kfcchi(1)
53308  idlam(lknt,2)=16
53309  idlam(lknt,3)=-16
53310  ENDIF
53311 
53312 C...D-TYPE QUARKS
53313  130 CONTINUE
53314  ia=1
53315  ja=2
53316  ei=kchg(iabs(ia),1)/3d0
53317  t3i=sign(1d0,ei+1d-6)/2d0
53318  xxc(5)=pmas(pycomp(ksusy1+ja),1)
53319  xxc(6)=1d6
53320  cxc(1)=dcmplx((t3i-xw*ei)/xw/xw1)*orpp
53321  cxc(2)=dcmplx(0d0,0d0)
53322  cxc(3)=dcmplx((t3i-xw*ei)/xw/xw1)*olpp
53323  cxc(4)=-vmixc(ij,1)*dconjg(vmixc(ix,1))*dcmplx(t3i/xw)
53324  cxc(5)=-dcmplx(ei/xw1)*orpp
53325  cxc(6)=dcmplx(0d0,0d0)
53326  cxc(7)=-dcmplx(ei/xw1)*olpp
53327  cxc(8)=dcmplx(0d0,0d0)
53328  IF( xxc(5).LT.axmi ) THEN
53329  xxc(5)=1d6
53330  ENDIF
53331  xxc(7)=xxc(5)
53332  xxc(8)=xxc(6)
53333  IF(axmi.GE.axmj+2d0*pmas(1,1)) THEN
53334  lknt=lknt+1
53335  xlam(lknt)=3d0*c1**2/xmi3/(16d0*pi)*
53336  & pygaus(pyxxz6,s12min,s12max,prec)
53337  idlam(lknt,1)=kfcchi(1)
53338  idlam(lknt,2)=1
53339  idlam(lknt,3)=-1
53340  IF(axmi.GE.axmj+2d0*pmas(3,1)) THEN
53341  lknt=lknt+1
53342  xlam(lknt)=xlam(lknt-1)
53343  idlam(lknt,1)=kfcchi(1)
53344  idlam(lknt,2)=3
53345  idlam(lknt,3)=-3
53346  ENDIF
53347  ENDIF
53348  IF(axmi.GE.axmj+2d0*pmas(5,1)) THEN
53349  IF(abs(sfmix(5,1)).GT.abs(sfmix(5,2))) THEN
53350  xxc(5)=pmas(pycomp(ksusy1+5),1)
53351  ELSE
53352  xxc(5)=pmas(pycomp(ksusy2+5),1)
53353  ENDIF
53354  IF( xxc(5).LT.axmi ) THEN
53355  xxc(5)=1d6
53356  ENDIF
53357  xxc(7)=xxc(5)
53358  lknt=lknt+1
53359  xlam(lknt)=3d0*c1**2/xmi3/(16d0*pi)*
53360  & pygaus(pyxxz6,s12min,s12max,prec)
53361  idlam(lknt,1)=kfcchi(1)
53362  idlam(lknt,2)=5
53363  idlam(lknt,3)=-5
53364  ENDIF
53365 
53366 C...U-TYPE QUARKS
53367  140 CONTINUE
53368  ia=2
53369  ja=1
53370  ei=kchg(iabs(ia),1)/3d0
53371  t3i=sign(1d0,ei+1d-6)/2d0
53372  xxc(5)=pmas(pycomp(ksusy1+ja),1)
53373  xxc(6)=1d6
53374  cxc(1)=dcmplx((t3i-xw*ei)/xw/xw1)*orpp
53375  cxc(2)=dcmplx(0d0,0d0)
53376  cxc(3)=dcmplx((t3i-xw*ei)/xw/xw1)*olpp
53377  cxc(4)=-umixc(ij,1)*dconjg(umixc(ix,1))*dcmplx(t3i/xw)
53378  cxc(5)=-dcmplx(ei/xw1)*orpp
53379  cxc(6)=dcmplx(0d0,0d0)
53380  cxc(7)=-dcmplx(ei/xw1)*olpp
53381  cxc(8)=dcmplx(0d0,0d0)
53382  IF( xxc(5).LT.axmi ) THEN
53383  xxc(5)=1d6
53384  ENDIF
53385  xxc(7)=xxc(5)
53386  xxc(8)=xxc(6)
53387  IF(axmi.GE.axmj+2d0*pmas(2,1)) THEN
53388  lknt=lknt+1
53389  xlam(lknt)=3d0*c1**2/xmi3/(16d0*pi)*
53390  & pygaus(pyxxz6,s12min,s12max,prec)
53391  idlam(lknt,1)=kfcchi(1)
53392  idlam(lknt,2)=2
53393  idlam(lknt,3)=-2
53394  IF(axmi.GE.axmj+2d0*pmas(4,1)) THEN
53395  lknt=lknt+1
53396  xlam(lknt)=xlam(lknt-1)
53397  idlam(lknt,1)=kfcchi(1)
53398  idlam(lknt,2)=4
53399  idlam(lknt,3)=-4
53400  ENDIF
53401  ENDIF
53402  150 CONTINUE
53403  ENDIF
53404 
53405 C...CHI_2+ -> CHI_1+ + H0_K
53406  eh(2)=cos(alfa)
53407  eh(1)=sin(alfa)
53408  eh(3)=-sbeta
53409  dh(2)=-sin(alfa)
53410  dh(1)=cos(alfa)
53411  dh(3)=cos(beta)
53412  DO 160 ih=1,3
53413  xmh=pmas(ith(ih),1)
53414  xmh2=xmh**2
53415 C...NO 3-BODY OPTION
53416  IF(axmi.GE.axmj+xmh) THEN
53417  lknt=lknt+1
53418  xl=pylamf(xmi2,xmj2,xmh2)
53419  olpp=(vmixc(2,1)*dconjg(umixc(1,2))*eh(ih) -
53420  & vmixc(2,2)*dconjg(umixc(1,1))*dh(ih))/sr2
53421  orpp=(dconjg(vmixc(1,1))*umixc(2,2)*eh(ih) -
53422  & dconjg(vmixc(1,2))*umixc(2,1)*dh(ih))/sr2
53423  xmk=xmj*etah(ih)
53424  gx2=abs(olpp)**2+abs(orpp)**2
53425  glr=dble(olpp*dconjg(orpp))
53426  xlam(lknt)=pyx2xh(c1,xmi,xmk,xmh,gx2,glr)
53427  idlam(lknt,1)=kfcchi(1)
53428  idlam(lknt,2)=ith(ih)
53429  idlam(lknt,3)=0
53430  ENDIF
53431  160 CONTINUE
53432 
53433 C...CHI1 JUMPS TO HERE
53434  170 CONTINUE
53435 
53436 C...CHI+_I -> CHI0_J + W+
53437  DO 220 ij=1,4
53438  xmj=smz(ij)
53439  axmj=abs(xmj)
53440  xmj2=xmj**2
53441  IF(axmi.GE.axmj+xmw) THEN
53442  lknt=lknt+1
53443  DO 180 i=1,4
53444  zmixc(ij,i)=dcmplx(zmix(ij,i),zmixi(ij,i))
53445  180 CONTINUE
53446  cxc(1)=(dconjg(zmixc(ij,2))*vmixc(ix,1)-
53447  & dconjg(zmixc(ij,4))*vmixc(ix,2)/sr2)
53448  cxc(3)=(zmixc(ij,2)*dconjg(umixc(ix,1))+
53449  & zmixc(ij,3)*dconjg(umixc(ix,2))/sr2)
53450  gx2=abs(cxc(1))**2+abs(cxc(3))**2
53451  glr=dble(cxc(1)*dconjg(cxc(3)))
53452  xlam(lknt)=pyx2xg(c1/xmw2,xmi,xmj,xmw,gx2,glr)
53453  idlam(lknt,1)=kfnchi(ij)
53454  idlam(lknt,2)=24
53455  idlam(lknt,3)=0
53456 C...LEPTONS
53457  ELSEIF(axmi.GE.axmj) THEN
53458  s12min=0d0
53459  s12max=(axmi-axmj)**2
53460  DO 190 i=1,4
53461  zmixc(ij,i)=dcmplx(zmix(ij,i),zmixi(ij,i))
53462  190 CONTINUE
53463  cxc(1)=(dconjg(zmixc(ij,2))*vmixc(ix,1)-
53464  & dconjg(zmixc(ij,4))*vmixc(ix,2)/sr2)/sr2
53465  cxc(3)=(zmixc(ij,2)*dconjg(umixc(ix,1))+
53466  & zmixc(ij,3)*dconjg(umixc(ix,2))/sr2)/sr2
53467  cxc(5)=dcmplx(0d0,0d0)
53468  cxc(7)=dcmplx(0d0,0d0)
53469  ia=11
53470  ja=12
53471  ei=kchg(ia,1)/3d0
53472  t3i=sign(1d0,ei+1d-6)/2d0
53473  ej=kchg(ja,1)/3d0
53474  t3j=sign(1d0,ej+1d-6)/2d0
53475  cxc(2)=vmixc(ix,1)*dconjg(zmixc(ij,1)*(ej-t3j)*
53476  & tanw+zmixc(ij,2)*t3j)/sr2
53477  cxc(4)=-dconjg(umixc(ix,1))*(
53478  & zmixc(ij,1)*(ei-t3i)*tanw+zmixc(ij,2)*t3i)/sr2
53479  cxc(6)=dcmplx(0d0,0d0)
53480  cxc(8)=dcmplx(0d0,0d0)
53481  xxc(1)=0d0
53482  xxc(2)=xmj
53483  xxc(3)=0d0
53484  xxc(4)=xmi
53485  xxc(5)=pmas(pycomp(ksusy1+ja),1)
53486  xxc(6)=pmas(pycomp(ksusy1+ia),1)
53487  xxc(9)=pmas(24,1)
53488  xxc(10)=pmas(24,2)
53489 CCC IF( XXC(5).LT.AXMI .AND. XXC(6).LT.AXMI ) GOTO 190
53490  IF(xxc(5).LT.axmi) THEN
53491  xxc(5)=1d6
53492  ELSEIF(xxc(6).LT.axmi) THEN
53493  xxc(6)=1d6
53494  ENDIF
53495  xxc(7)=xxc(6)
53496  xxc(8)=xxc(5)
53497 C...1/(2PI)**3*/(32*M**3)*G^4, G^2/(4*PI)= AEM/XW,
53498 C...--> 1/(16PI)/M**3*(AEM/XW)**2
53499  IF(axmi.GE.axmj+pmas(11,1)+pmas(12,1)) THEN
53500  lknt=lknt+1
53501  temp=pygaus(pyxxz6,s12min,s12max,prec)
53502  xlam(lknt)=c1**2/xmi3/(16d0*pi)*temp
53503  idlam(lknt,1)=kfnchi(ij)
53504  idlam(lknt,2)=-11
53505  idlam(lknt,3)=12
53506 C...ONLY DECAY CHI+1 -> E+ NU_E
53507  IF( imss(12).NE. 0 ) goto 260
53508  IF(axmi.GE.axmj+pmas(13,1)+pmas(14,1)) THEN
53509  lknt=lknt+1
53510  xlam(lknt)=xlam(lknt-1)
53511  idlam(lknt,1)=kfnchi(ij)
53512  idlam(lknt,2)=-13
53513  idlam(lknt,3)=14
53514  ENDIF
53515  ENDIF
53516  IF(axmi.GE.axmj+pmas(15,1)+pmas(16,1)) THEN
53517  lknt=lknt+1
53518  IF(abs(sfmix(15,1)).GT.abs(sfmix(15,2))) THEN
53519  xxc(6)=pmas(pycomp(ksusy1+15),1)
53520  ELSE
53521  xxc(6)=pmas(pycomp(ksusy2+15),1)
53522  ENDIF
53523  xxc(5)=pmas(pycomp(ksusy1+16),1)
53524  IF(xxc(5).LT.axmi) THEN
53525  xxc(5)=1d6
53526  ELSEIF(xxc(6).LT.axmi) THEN
53527  xxc(6)=1d6
53528  ENDIF
53529  xxc(7)=xxc(6)
53530  xxc(8)=xxc(5)
53531  temp=pygaus(pyxxz6,s12min,s12max,prec)
53532  xlam(lknt)=c1**2/xmi3/(16d0*pi)*temp
53533  idlam(lknt,1)=kfnchi(ij)
53534  idlam(lknt,2)=-15
53535  idlam(lknt,3)=16
53536  ENDIF
53537 
53538 C...NOW, DO THE QUARKS
53539  200 CONTINUE
53540  ia=1
53541  ja=2
53542  ei=kchg(ia,1)/3d0
53543  t3i=sign(1d0,ei+1d-6)/2d0
53544  ej=kchg(ja,1)/3d0
53545  t3j=sign(1d0,ej+1d-6)/2d0
53546  cxc(2)=vmixc(ix,1)*dconjg(zmixc(ij,1)*(ej-t3j)*
53547  & tanw+zmixc(ij,2)*t3j)
53548  cxc(4)=-dconjg(umixc(ix,1))*(
53549  & zmixc(ij,1)*(ei-t3i)*tanw+zmixc(ij,2)*t3i)
53550  xxc(5)=pmas(pycomp(ksusy1+ja),1)
53551  xxc(6)=pmas(pycomp(ksusy1+ia),1)
53552  IF( xxc(5).LT.axmi .AND. xxc(6).LT.axmi ) goto 210
53553  IF(xxc(5).LT.axmi) THEN
53554  xxc(5)=1d6
53555  ENDIF
53556  IF(xxc(6).LT.axmi) THEN
53557  xxc(6)=1d6
53558  ENDIF
53559  xxc(7)=xxc(6)
53560  xxc(8)=xxc(5)
53561  IF(axmi.GE.axmj+pmas(1,1)+pmas(2,1)) THEN
53562  lknt=lknt+1
53563  xlam(lknt)=3d0*c1**2/xmi3/(16d0*pi)*
53564  & pygaus(pyxxz6,s12min,s12max,prec)
53565  idlam(lknt,1)=kfnchi(ij)
53566  idlam(lknt,2)=-1
53567  idlam(lknt,3)=2
53568  IF(axmi.GE.axmj+pmas(3,1)+pmas(4,1)) THEN
53569  lknt=lknt+1
53570  xlam(lknt)=xlam(lknt-1)
53571  idlam(lknt,1)=kfnchi(ij)
53572  idlam(lknt,2)=-3
53573  idlam(lknt,3)=4
53574  ENDIF
53575  ENDIF
53576  210 CONTINUE
53577  ENDIF
53578  220 CONTINUE
53579 
53580 C...CHI+_I -> CHI0_J + H+
53581  DO 230 ij=1,4
53582  xmj=smz(ij)
53583  axmj=abs(xmj)
53584  xmj2=xmj**2
53585  xmhp=pmas(ithc,1)
53586  IF(axmi.GE.axmj+xmhp) THEN
53587  lknt=lknt+1
53588  olpp=cbeta*(zmixc(ij,4)*dconjg(vmixc(ix,1))+(zmixc(ij,2)+
53589  & zmixc(ij,1)*tanw)*dconjg(vmixc(ix,2))/sr2)
53590  orpp=sbeta*(dconjg(zmixc(ij,3))*umixc(ix,1)-
53591  & (dconjg(zmixc(ij,2))+dconjg(zmixc(ij,1))*tanw)*
53592  & umixc(ix,2)/sr2)
53593  gx2=abs(olpp)**2+abs(orpp)**2
53594  glr=dble(olpp*dconjg(orpp))
53595  xlam(lknt)=pyx2xh(c1,xmi,xmj,xmhp,gx2,glr)
53596  idlam(lknt,1)=kfnchi(ij)
53597  idlam(lknt,2)=ithc
53598  idlam(lknt,3)=0
53599  ELSE
53600 
53601  ENDIF
53602  230 CONTINUE
53603 
53604 C...2-BODY DECAYS TO FERMION SFERMION
53605  DO 240 j=1,16
53606  IF(j.GE.7.AND.j.LE.10) goto 240
53607  IF(mod(j,2).EQ.0) THEN
53608  kf1=ksusy1+j-1
53609  ELSE
53610  kf1=ksusy1+j+1
53611  ENDIF
53612  kf2=kf1+ksusy1
53613  xmsf1=pmas(pycomp(kf1),1)
53614  xmsf2=pmas(pycomp(kf2),1)
53615  xmf=pmas(j,1)
53616  IF(j.LE.6) THEN
53617  fcol=3d0
53618  ELSE
53619  fcol=1d0
53620  ENDIF
53621 
53622 C...U~ D_L
53623  IF(mod(j,2).EQ.0) THEN
53624  xmfp=pmas(j-1,1)
53625  cal=umixc(ix,1)
53626  cbl=-xmf*vmixc(ix,2)/xmw/sbeta/sr2
53627  car=-xmfp*umixc(ix,2)/xmw/cbeta/sr2
53628  cbr=0d0
53629  isf=j-1
53630  ELSE
53631  xmfp=pmas(j+1,1)
53632  cal=vmixc(ix,1)
53633  cbl=-xmf*umixc(ix,2)/xmw/cbeta/sr2
53634  cbr=0d0
53635  car=-xmfp*vmixc(ix,2)/xmw/sbeta/sr2
53636  isf=j+1
53637  ENDIF
53638 
53639 C...~U_L D
53640  IF(axmi.GE.xmf+xmsf1) THEN
53641  lknt=lknt+1
53642  xma2=xmsf1**2
53643  xmb2=xmf**2
53644  xl=pylamf(xmi2,xma2,xmb2)
53645  ca=cal*sfmix(isf,1)+car*sfmix(isf,2)
53646  cb=cbl*sfmix(isf,1)+cbr*sfmix(isf,2)
53647  xlam(lknt)=fcol*c1/8d0/xmi3*sqrt(xl)*( (xmi2+xmb2-xma2)*
53648  & (abs(ca)**2+abs(cb)**2)+4d0*dble(ca*dconjg(cb))*xmf*xmi)
53649  idlam(lknt,3)=0
53650  IF(mod(j,2).EQ.0) THEN
53651  idlam(lknt,1)=-kf1
53652  idlam(lknt,2)=j
53653  ELSE
53654  idlam(lknt,1)=kf1
53655  idlam(lknt,2)=-j
53656  ENDIF
53657  ENDIF
53658 
53659 C...U~ D_R
53660  IF(axmi.GE.xmf+xmsf2) THEN
53661  lknt=lknt+1
53662  xma2=xmsf2**2
53663  xmb2=xmf**2
53664  ca=cal*sfmix(isf,3)+car*sfmix(isf,4)
53665  cb=cbl*sfmix(isf,3)+cbr*sfmix(isf,4)
53666  xl=pylamf(xmi2,xma2,xmb2)
53667  xlam(lknt)=fcol*c1/8d0/xmi3*sqrt(xl)*( (xmi2+xmb2-xma2)*
53668  & (abs(ca)**2+abs(cb)**2)+4d0*dble(ca*dconjg(cb))*xmf*xmi)
53669  idlam(lknt,3)=0
53670  IF(mod(j,2).EQ.0) THEN
53671  idlam(lknt,1)=-kf2
53672  idlam(lknt,2)=j
53673  ELSE
53674  idlam(lknt,1)=kf2
53675  idlam(lknt,2)=-j
53676  ENDIF
53677  ENDIF
53678  240 CONTINUE
53679 
53680 C...3-BODY DECAY TO Q Q~' GLUINO, ONLY IF IT CANNOT PROCEED THROUGH
53681 C...A 2-BODY -- 2-BODY CHAIN
53682  xmj=pmas(pycomp(ksusy1+21),1)
53683  IF(axmi.GE.xmj) THEN
53684  axmj=abs(xmj)
53685  s12min=0d0
53686  s12max=(axmi-axmj)**2
53687  xxc(1)=0d0
53688  xxc(2)=xmj
53689  xxc(3)=0d0
53690  xxc(4)=xmi
53691  xxc(5)=pmas(pycomp(ksusy1+1),1)
53692  xxc(6)=pmas(pycomp(ksusy1+2),1)
53693  xxc(9)=1d6
53694  xxc(10)=0d0
53695  olpp=dcmplx(cos(rmss(32)),sin(rmss(32)))
53696  orpp=dconjg(olpp)
53697  cxc(1)=dcmplx(0d0,0d0)
53698  cxc(3)=dcmplx(0d0,0d0)
53699  cxc(5)=dcmplx(0d0,0d0)
53700  cxc(7)=dcmplx(0d0,0d0)
53701  cxc(2)=umixc(ix,1)*olpp/sr2
53702  cxc(4)=-dconjg(vmixc(ix,1))*orpp/sr2
53703  cxc(6)=dcmplx(0d0,0d0)
53704  cxc(8)=dcmplx(0d0,0d0)
53705  IF(xxc(5).LT.axmi) THEN
53706  xxc(5)=1d6
53707  ELSEIF(xxc(6).LT.axmi) THEN
53708  xxc(6)=1d6
53709  ENDIF
53710  xxc(7)=xxc(6)
53711  xxc(8)=xxc(5)
53712  IF( xxc(5).LT.axmi .OR. xxc(6).LT.axmi ) goto 250
53713  IF(axmi.GE.axmj+pmas(1,1)+pmas(2,1)) THEN
53714  lknt=lknt+1
53715  xlam(lknt)=4d0*c1*as/xmi3/(16d0*pi)*
53716  & pygaus(pyxxz6,s12min,s12max,prec)
53717  idlam(lknt,1)=ksusy1+21
53718  idlam(lknt,2)=-1
53719  idlam(lknt,3)=2
53720  IF(axmi.GE.axmj+pmas(3,1)+pmas(4,1)) THEN
53721  lknt=lknt+1
53722  xlam(lknt)=xlam(lknt-1)
53723  idlam(lknt,1)=ksusy1+21
53724  idlam(lknt,2)=-3
53725  idlam(lknt,3)=4
53726  ENDIF
53727  ENDIF
53728  250 CONTINUE
53729  ENDIF
53730 
53731 C...R-violating decay modes (SKANDS).
53732  CALL pyrvch(kfin,xlam,idlam,lknt)
53733 
53734  260 iknt=lknt
53735  xlam(0)=0d0
53736  DO 270 i=1,iknt
53737  xlam(0)=xlam(0)+xlam(i)
53738  IF(xlam(i).LT.0d0) THEN
53739  WRITE(mstu(11),*) ' XLAM(I) = ',xlam(i),kcin,
53740  & (idlam(i,j),j=1,3)
53741  xlam(i)=0d0
53742  ENDIF
53743  270 CONTINUE
53744  IF(xlam(0).EQ.0d0) THEN
53745  xlam(0)=1d-6
53746  WRITE(mstu(11),*) ' XLAM(0) = ',xlam(0)
53747  WRITE(mstu(11),*) lknt
53748  WRITE(mstu(11),*) (xlam(j),j=1,lknt)
53749  ENDIF
53750 
53751  RETURN
53752  END
53753 
53754 C*********************************************************************
53755 
53756 C...PYXXZ6
53757 C...Used in the calculation of inoi -> inoj + f + ~f.
53758 
53759  FUNCTION pyxxz6(X)
53760 
53761 C...Double precision and integer declarations.
53762  IMPLICIT DOUBLE PRECISION(a-h, o-z)
53763  IMPLICIT INTEGER(i-n)
53764  INTEGER pyk,pychge,pycomp
53765 C...Parameter statement to help give large particle numbers.
53766  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
53767  &kexcit=4000000,kdimen=5000000)
53768 C...Commonblocks.
53769  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
53770 C COMMON/PYINTS/XXM(20)
53771  COMPLEX*16 cxc
53772  common/pyintc/xxc(10),cxc(8)
53773  SAVE /pydat1/,/pyintc/
53774 
53775 C...Local variables.
53776  COMPLEX*16 qlls,qrrs,qrls,qlrs,qllu,qrru,qlrt,qrlt
53777  DOUBLE PRECISION pyxxz6,x
53778  DOUBLE PRECISION xm12,xm22,xm32,s,s13,wprop2
53779  DOUBLE PRECISION ww,wf1,wf2,wfl1,wfl2
53780  DOUBLE PRECISION sij
53781  DOUBLE PRECISION xmv,xmg,xmsu1,xmsu2,xmsd1,xmsd2
53782  DOUBLE PRECISION ol2
53783  DOUBLE PRECISION s23min,s23max,s23ave,s23del
53784  INTEGER i
53785 
53786 C...Statement functions.
53787 C...Integral from x to y of (t-a)(b-t) dt.
53788  tint(x,y,a,b)=(x-y)*(-(x**2+x*y+y**2)/3d0+(b+a)*(x+y)/2d0-a*b)
53789 C...Integral from x to y of (t-a)(b-t)/(t-c) dt.
53790  tint2(x,y,a,b,c)=(x-y)*(-0.5d0*(x+y)+(b+a-c))-
53791  &log(abs((x-c)/(y-c)))*(c-b)*(c-a)
53792 C...Integral from x to y of (t-a)(b-t)/(t-c)**2 dt.
53793  tint3(x,y,a,b,c)=-(x-y)+(c-a)*(c-b)*(y-x)/(x-c)/(y-c)+
53794  &(b+a-2d0*c)*log(abs((x-c)/(y-c)))
53795 C...Integral from x to y of (t-a)/(b-t) dt.
53796  utint(x,y,a,b)=log(abs((x-a)/(b-x)*(b-y)/(y-a)))/(b-a)
53797 C...Integral from x to y of 1/(t-a) dt.
53798  tprop(x,y,a)=log(abs((x-a)/(y-a)))
53799 
53800  xm12=xxc(1)**2
53801  xm22=xxc(2)**2
53802  xm32=xxc(3)**2
53803  s=xxc(4)**2
53804  s13=x
53805 
53806  s23ave=xm22+xm32-0.5d0/x*(x+xm32-xm12)*(x+xm22-s)
53807  s23del=0.5d0/x*sqrt( ( (x-xm12-xm32)**2-4d0*xm12*xm32)*
53808  &( (x-xm22-s)**2 -4d0*xm22*s ) )
53809 
53810  s23min=(s23ave-s23del)
53811  s23max=(s23ave+s23del)
53812 
53813  xmsd1=xxc(5)**2
53814  xmsd2=xxc(7)**2
53815  xmsu1=xxc(6)**2
53816  xmsu2=xxc(8)**2
53817 
53818  xmv=xxc(9)
53819  xmg=xxc(10)
53820  qlls=cxc(1)
53821  qllu=cxc(2)
53822  qlrs=cxc(3)
53823  qlrt=cxc(4)
53824  qrls=cxc(5)
53825  qrlt=cxc(6)
53826  qrrs=cxc(7)
53827  qrru=cxc(8)
53828  wprop2=(s13-xmv**2)**2+(xmv*xmg)**2
53829  sij=2d0*xxc(2)*xxc(4)*s13
53830  IF(xmv.LE.1000d0) THEN
53831  ol2=abs(qlls)**2+abs(qrrs)**2+abs(qlrs)**2+abs(qrls)**2
53832  olr=-2d0*dble(qlrs*dconjg(qlls)+qrls*dconjg(qrrs))
53833  ww=(ol2*2d0*tint(s23max,s23min,xm22,s)
53834  & +olr*sij*(s23max-s23min))/wprop2
53835  IF(xxc(5).LE.10000d0) THEN
53836  wfl1=4d0*(dble(qlls*dconjg(qllu))*
53837  & tint2(s23max,s23min,xm22,s,xmsd1)-
53838  & .5d0*dble(qlls*dconjg(qlrt))*sij*tprop(s23max,s23min,xmsd2)+
53839  & dble(qlrs*dconjg(qlrt))*tint2(s23max,s23min,xm22,s,xmsd2)-
53840  & .5d0*dble(qlrs*dconjg(qllu))*sij*tprop(s23max,s23min,xmsd1))
53841  & *(s13-xmv**2)/wprop2
53842  ELSE
53843  wfl1=0d0
53844  ENDIF
53845 
53846  IF(xxc(6).LE.10000d0) THEN
53847  wfl2=4d0*(dble(qrrs*dconjg(qrru))*
53848  & tint2(s23max,s23min,xm22,s,xmsu1)-
53849  & .5d0*dble(qrrs*dconjg(qrlt))*sij*tprop(s23max,s23min,xmsu2)+
53850  & dble(qrls*dconjg(qrlt))*tint2(s23max,s23min,xm22,s,xmsu2)-
53851  & .5d0*dble(qrls*dconjg(qrru))*sij*tprop(s23max,s23min,xmsu1))
53852  & *(s13-xmv**2)/wprop2
53853  ELSE
53854  wfl2=0d0
53855  ENDIF
53856  ELSE
53857  ww=0d0
53858  wfl1=0d0
53859  wfl2=0d0
53860  ENDIF
53861  IF(xxc(5).LE.10000d0) THEN
53862  wf1=2d0*abs(qllu)**2*tint3(s23max,s23min,xm22,s,xmsd1)
53863  & +2d0*abs(qlrt)**2*tint3(s23max,s23min,xm22,s,xmsd2)
53864  & - 2d0*dble(qlrt*dconjg(qllu))*
53865  & sij*utint(s23max,s23min,xmsd1,xm22+s-s13-xmsd2)
53866  ELSE
53867  wf1=0d0
53868  ENDIF
53869  IF(xxc(6).LE.10000d0) THEN
53870  wf2=2d0*abs(qrru)**2*tint3(s23max,s23min,xm22,s,xmsu1)
53871  & +2d0*abs(qrlt)**2*tint3(s23max,s23min,xm22,s,xmsu2)
53872  & - 2d0*dble(qrlt*dconjg(qrru))*
53873  & sij*utint(s23max,s23min,xmsu1,xm22+s-s13-xmsu2)
53874  ELSE
53875  wf2=0d0
53876  ENDIF
53877 
53878  pyxxz6=(ww+wf1+wf2+wfl1+wfl2)
53879 
53880  IF(pyxxz6.LT.0d0) THEN
53881  WRITE(mstu(11),*) ' NEGATIVE WT IN PYXXZ6 '
53882  WRITE(mstu(11),*) (xxc(i),i=1,5)
53883  WRITE(mstu(11),*) (xxc(i),i=6,10)
53884  WRITE(mstu(11),*) ww,wf1,wf2,wfl1,wfl2
53885  WRITE(mstu(11),*) s23min,s23max
53886  pyxxz6=0d0
53887  ENDIF
53888 
53889  RETURN
53890  END
53891 
53892 
53893 C*********************************************************************
53894 
53895 C...PYXXGA
53896 C...Calculates chi0_i -> chi0_j + gamma.
53897 
53898  FUNCTION pyxxga(C0,XM1,XM2,XMTR,XMTL)
53899 
53900 C...Double precision and integer declarations.
53901  IMPLICIT DOUBLE PRECISION(a-h, o-z)
53902  IMPLICIT INTEGER(i-n)
53903  INTEGER pyk,pychge,pycomp
53904 
53905 C...Local variables.
53906  DOUBLE PRECISION pyxxga,c0,xm1,xm2,xmtr,xmtl
53907  DOUBLE PRECISION f1,f2
53908 
53909  f1=(1d0+xmtr/(1d0-xmtr)*log(xmtr))/(1d0-xmtr)
53910  f2=(1d0+xmtl/(1d0-xmtl)*log(xmtl))/(1d0-xmtl)
53911  pyxxga=c0*((xm1**2-xm2**2)/xm1)**3
53912  pyxxga=pyxxga*(2d0/3d0*(f1+f2)-13d0/12d0)**2
53913 
53914  RETURN
53915  END
53916 
53917 C*********************************************************************
53918 
53919 C...PYX2XG
53920 C...Calculates the decay rate for ino -> ino + gauge boson.
53921 
53922  FUNCTION pyx2xg(C1,XM1,XM2,XM3,GX2,GLR)
53923 
53924 C...Double precision and integer declarations.
53925  IMPLICIT DOUBLE PRECISION(a-h, o-z)
53926  IMPLICIT INTEGER(i-n)
53927  INTEGER pyk,pychge,pycomp
53928 
53929 C...Local variables.
53930  DOUBLE PRECISION pyx2xg,xm1,xm2,xm3,gx2,glr
53931  DOUBLE PRECISION xl,pylamf,c1
53932  DOUBLE PRECISION xmi2,xmj2,xmv2,xmi3
53933 
53934  xmi2=xm1**2
53935  xmi3=abs(xm1**3)
53936  xmj2=xm2**2
53937  xmv2=xm3**2
53938  xl=pylamf(xmi2,xmj2,xmv2)
53939  pyx2xg=c1/8d0/xmi3*sqrt(xl)
53940  &*(gx2*(xl+3d0*xmv2*(xmi2+xmj2-xmv2))-
53941  &12d0*glr*xm1*xm2*xmv2)
53942 
53943  RETURN
53944  END
53945 
53946 C*********************************************************************
53947 
53948 C...PYX2XH
53949 C...Calculates the decay rate for ino -> ino + H.
53950 
53951  FUNCTION pyx2xh(C1,XM1,XM2,XM3,GX2,GLR)
53952 
53953 C...Double precision and integer declarations.
53954  IMPLICIT DOUBLE PRECISION(a-h, o-z)
53955  IMPLICIT INTEGER(i-n)
53956  INTEGER pyk,pychge,pycomp
53957 
53958 C...Local variables.
53959  DOUBLE PRECISION pyx2xh,xm1,xm2,xm3
53960  DOUBLE PRECISION xl,pylamf,c1
53961  DOUBLE PRECISION xmi2,xmj2,xmv2,xmi3
53962 
53963  xmi2=xm1**2
53964  xmi3=abs(xm1**3)
53965  xmj2=xm2**2
53966  xmv2=xm3**2
53967  xl=pylamf(xmi2,xmj2,xmv2)
53968  pyx2xh=c1/8d0/xmi3*sqrt(xl)
53969  &*(gx2*(xmi2+xmj2-xmv2)+
53970  &4d0*glr*xm1*xm2)
53971 
53972  RETURN
53973  END
53974 
53975 C*********************************************************************
53976 
53977 C...PYHEXT
53978 C...Calculates the non-standard decay modes of the Higgs boson.
53979 C...
53980 C...Author: Stephen Mrenna
53981 C...Last Update: April 2001
53982 C......Allow complex values for Z,U, and V
53983 
53984  SUBROUTINE pyhext(KFIN,XLAM,IDLAM,IKNT)
53985 
53986 C...Double precision and integer declarations.
53987  IMPLICIT DOUBLE PRECISION(a-h, o-z)
53988  IMPLICIT INTEGER(i-n)
53989  INTEGER pyk,pychge,pycomp
53990 C...Parameter statement to help give large particle numbers.
53991  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
53992  &kexcit=4000000,kdimen=5000000)
53993 C...Commonblocks.
53994  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
53995  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
53996  common/pypars/mstp(200),parp(200),msti(200),pari(200)
53997  common/pymssm/imss(0:99),rmss(0:99)
53998  common/pyssmt/zmix(4,4),umix(2,2),vmix(2,2),smz(4),smw(2),
53999  &sfmix(16,4),zmixi(4,4),umixi(2,2),vmixi(2,2)
54000  SAVE /pydat1/,/pydat2/,/pypars/,/pymssm/,/pyssmt/
54001 
54002 C...Local variables.
54003  COMPLEX*16 zmixc(4,4),vmixc(2,2),umixc(2,2),olpp,orpp
54004  COMPLEX*16 qij,rij,f21k,f12k
54005  INTEGER kfin
54006  DOUBLE PRECISION xmi,xmj,xmf,xmw,xmw2,xmz,axmj,axmi
54007  DOUBLE PRECISION xmi2,xmi3,xmj2
54008  DOUBLE PRECISION pylamf,xl,cf,ei
54009  INTEGER idu,ifl
54010  DOUBLE PRECISION tanw,xw,aem,c1,as
54011  DOUBLE PRECISION pyh2xx,ghll,ghrr,ghlr
54012  DOUBLE PRECISION xlam(0:400)
54013  INTEGER idlam(400,3)
54014  INTEGER lknt,ih,j,ij,i,iknt,ik
54015  INTEGER ith(4)
54016  INTEGER kfnchi(4),kfcchi(2)
54017  DOUBLE PRECISION etah(3),ch(3),dh(3),eh(3)
54018  DOUBLE PRECISION sr2
54019  DOUBLE PRECISION beta,alfa
54020  DOUBLE PRECISION cbeta,sbeta,gr,gl,tanb
54021  DOUBLE PRECISION pyalem
54022  DOUBLE PRECISION al,ar,alr
54023  DOUBLE PRECISION xmk,axmk,cosa,sina,cw,xml
54024  DOUBLE PRECISION xmuz,atrit,atrib,atril
54025  DOUBLE PRECISION xmjl,xmjr,xm1,xm2
54026  DATA ith/25,35,36,37/
54027  DATA etah/1d0,1d0,-1d0/
54028  DATA sr2/1.4142136d0/
54029  DATA kfnchi/1000022,1000023,1000025,1000035/
54030  DATA kfcchi/1000024,1000037/
54031 
54032 C...COUNT THE NUMBER OF DECAY MODES
54033  lknt=iknt
54034 
54035  xmw=pmas(24,1)
54036  xmw2=xmw**2
54037  xmz=pmas(23,1)
54038  xw=paru(102)
54039  tanw = sqrt(xw/(1d0-xw))
54040  cw=sqrt(1d0-xw)
54041 
54042 C...1 - 4 DEPENDING ON Higgs species.
54043  ih=1
54044  IF(kfin.EQ.ith(2)) ih=2
54045  IF(kfin.EQ.ith(3)) ih=3
54046  IF(kfin.EQ.ith(4)) ih=4
54047 
54048  xmi=pmas(kfin,1)
54049  xmi2=xmi**2
54050  axmi=abs(xmi)
54051  aem=pyalem(xmi2)
54052  c1=aem/xw
54053  xmi3=abs(xmi**3)
54054 
54055  tanb=rmss(5)
54056  beta=atan(tanb)
54057  cbeta=cos(beta)
54058  sbeta=tanb*cbeta
54059  alfa=rmss(18)
54060  cosa=cos(alfa)
54061  sina=sin(alfa)
54062  atrit=rmss(16)
54063  atrib=rmss(15)
54064  atril=rmss(17)
54065  xmuz=-rmss(4)
54066 
54067  DO 110 i=1,4
54068  DO 100 j=1,4
54069  zmixc(j,i)=dcmplx(zmix(j,i),zmixi(j,i))
54070  100 CONTINUE
54071  110 CONTINUE
54072  DO 130 i=1,2
54073  DO 120 j=1,2
54074  vmixc(j,i)=dcmplx(vmix(j,i),vmixi(j,i))
54075  umixc(j,i)=dcmplx(umix(j,i),umixi(j,i))
54076  120 CONTINUE
54077  130 CONTINUE
54078 
54079 
54080  IF(ih.EQ.4) goto 220
54081 
54082 C...CHECK ALL 2-BODY DECAYS TO GAUGE AND HIGGS BOSONS
54083 C...H0_K -> CHI0_I + CHI0_J
54084  eh(2)=sina
54085  eh(1)=cosa
54086  eh(3)=cbeta
54087  dh(2)=cosa
54088  dh(1)=-sina
54089  dh(3)=sbeta
54090  DO 150 ij=1,4
54091  xmj=smz(ij)
54092  axmj=abs(xmj)
54093  DO 140 ik=1,ij
54094  xmk=smz(ik)
54095  axmk=abs(xmk)
54096  IF(axmi.GE.axmj+axmk) THEN
54097  lknt=lknt+1
54098  qij=zmixc(ik,3)*zmixc(ij,2)+
54099  & zmixc(ij,3)*zmixc(ik,2)-
54100  & tanw*(zmixc(ik,3)*zmixc(ij,1)+
54101  & zmixc(ij,3)*zmixc(ik,1))
54102  rij=zmixc(ik,4)*zmixc(ij,2)+
54103  & zmixc(ij,4)*zmixc(ik,2)-
54104  & tanw*(zmixc(ik,4)*zmixc(ij,1)+
54105  & zmixc(ij,4)*zmixc(ik,1))
54106  f21k=0.5d0*dconjg(qij*dh(ih)-rij*eh(ih))
54107  f12k=0.5d0*(qij*dh(ih)-rij*eh(ih))
54108 C...SIGN OF MASSES I,J
54109  xml=xmk*etah(ih)
54110  gx2=abs(f12k)**2+abs(f21k)**2
54111  glr=dble(f12k*dconjg(f21k))
54112  xlam(lknt)=pyh2xx(c1,xmi,xmj,xml,gx2,glr)
54113  IF(ij.EQ.ik) xlam(lknt)=xlam(lknt)*0.5d0
54114  idlam(lknt,1)=kfnchi(ij)
54115  idlam(lknt,2)=kfnchi(ik)
54116  idlam(lknt,3)=0
54117  ENDIF
54118  140 CONTINUE
54119  150 CONTINUE
54120 
54121 C...H0_K -> CHI+_I CHI-_J
54122  DO 170 ij=1,2
54123  xmj=smw(ij)
54124  axmj=abs(xmj)
54125  DO 160 ik=1,2
54126  xmk=smw(ik)
54127  axmk=abs(xmk)
54128  IF(axmi.GE.axmj+axmk) THEN
54129  lknt=lknt+1
54130  olpp=dconjg(vmixc(ij,1)*umixc(ik,2)*dh(ih) +
54131  & vmixc(ij,2)*umixc(ik,1)*eh(ih))/sr2
54132  orpp=(vmixc(ik,1)*umixc(ij,2)*dh(ih) +
54133  & vmixc(ik,2)*umixc(ij,1)*eh(ih))/sr2
54134  gx2=abs(olpp)**2+abs(orpp)**2
54135  glr=dble(olpp*dconjg(orpp))
54136  xml=xmk*etah(ih)
54137  xlam(lknt)=pyh2xx(c1,xmi,xmj,xml,gx2,glr)
54138  idlam(lknt,1)=kfcchi(ij)
54139  idlam(lknt,2)=-kfcchi(ik)
54140  idlam(lknt,3)=0
54141  ENDIF
54142  160 CONTINUE
54143  170 CONTINUE
54144 
54145 C...HIGGS TO SFERMION SFERMION
54146  DO 200 ifl=1,16
54147  IF(ifl.GE.7.AND.ifl.LE.10) goto 200
54148  ij=ksusy1+ifl
54149  xmjl=pmas(pycomp(ij),1)
54150  xmjr=pmas(pycomp(ij+ksusy1),1)
54151  IF(axmi.GE.2d0*min(xmjl,xmjr)) THEN
54152  xmj=xmjl
54153  xmj2=xmj**2
54154  xl=pylamf(xmi2,xmj2,xmj2)
54155  xmf=pmas(ifl,1)
54156  ei=kchg(ifl,1)/3d0
54157  idu=2-mod(ifl,2)
54158 
54159  IF(ih.EQ.1) THEN
54160  IF(idu.EQ.1) THEN
54161  ghll=-xmz/cw*(0.5d0+ei*xw)*sin(alfa+beta)+
54162  & xmf**2/xmw*sina/cbeta
54163  ghrr=xmz/cw*(ei*xw)*sin(alfa+beta)+
54164  & xmf**2/xmw*sina/cbeta
54165  IF(ifl.EQ.5) THEN
54166  ghlr=-xmf/2d0/xmw/cbeta*(xmuz*cosa-
54167  & atrib*sina)
54168  ELSEIF(ifl.EQ.15) THEN
54169  ghlr=-xmf/2d0/xmw/cbeta*(xmuz*cosa-
54170  & atril*sina)
54171  ELSE
54172  ghlr=0d0
54173  ENDIF
54174  ELSE
54175  ghll=xmz/cw*(0.5d0-ei*xw)*sin(alfa+beta)-
54176  & xmf**2/xmw*cosa/sbeta
54177  ghrr=xmz/cw*(ei*xw)*sin(alfa+beta)-
54178  & xmf**2/xmw*cosa/sbeta
54179  IF(ifl.EQ.6) THEN
54180  ghlr=xmf/2d0/xmw/sbeta*(xmuz*sina-
54181  & atrit*cosa)
54182  ELSE
54183  ghlr=0d0
54184  ENDIF
54185  ENDIF
54186 
54187  ELSEIF(ih.EQ.2) THEN
54188  IF(idu.EQ.1) THEN
54189  ghll=xmz/cw*(0.5d0+ei*xw)*cos(alfa+beta)-
54190  & xmf**2/xmw*cosa/cbeta
54191  ghrr=-xmz/cw*(ei*xw)*cos(alfa+beta)-
54192  & xmf**2/xmw*cosa/cbeta
54193  IF(ifl.EQ.5) THEN
54194  ghlr=-xmf/2d0/xmw/cbeta*(xmuz*sina+
54195  & atrib*cosa)
54196  ELSEIF(ifl.EQ.15) THEN
54197  ghlr=-xmf/2d0/xmw/cbeta*(xmuz*sina+
54198  & atril*cosa)
54199  ELSE
54200  ghlr=0d0
54201  ENDIF
54202  ELSE
54203  ghll=-xmz/cw*(0.5d0-ei*xw)*cos(alfa+beta)-
54204  & xmf**2/xmw*sina/sbeta
54205  ghrr=-xmz/cw*(ei*xw)*cos(alfa+beta)-
54206  & xmf**2/xmw*sina/sbeta
54207  IF(ifl.EQ.6) THEN
54208  ghlr=-xmf/2d0/xmw/sbeta*(xmuz*cosa+
54209  & atrit*sina)
54210  ELSE
54211  ghlr=0d0
54212  ENDIF
54213  ENDIF
54214 
54215  ELSEIF(ih.EQ.3) THEN
54216  ghll=0d0
54217  ghrr=0d0
54218  ghlr=0d0
54219  IF(idu.EQ.1) THEN
54220  IF(ifl.EQ.5) THEN
54221  ghlr=xmf/2d0/xmw*(atrib*tanb-xmuz)
54222  ELSEIF(ifl.EQ.15) THEN
54223  ghlr=xmf/2d0/xmw*(atril*tanb-xmuz)
54224  ENDIF
54225  ELSE
54226  IF(ifl.EQ.6) THEN
54227  ghlr=xmf/2d0/xmw*(atrit/tanb-xmuz)
54228  ENDIF
54229  ENDIF
54230  ENDIF
54231  IF(ih.EQ.3) goto 180
54232 
54233  al=sfmix(ifl,1)**2
54234  ar=sfmix(ifl,2)**2
54235  alr=sfmix(ifl,1)*sfmix(ifl,2)
54236  IF(ifl.LE.6) THEN
54237  cf=3d0
54238  ELSE
54239  cf=1d0
54240  ENDIF
54241 
54242  IF(axmi.GE.2d0*xmj) THEN
54243  lknt=lknt+1
54244  xlam(lknt)=cf*sqrt(xl)/4d0*c1/xmi3*
54245  & (ghll*al+ghrr*ar
54246  & +2d0*ghlr*alr)**2
54247  idlam(lknt,1)=ij
54248  idlam(lknt,2)=-ij
54249  idlam(lknt,3)=0
54250  ENDIF
54251 
54252  IF(axmi.GE.2d0*xmjr) THEN
54253  lknt=lknt+1
54254  al=sfmix(ifl,3)**2
54255  ar=sfmix(ifl,4)**2
54256  alr=sfmix(ifl,3)*sfmix(ifl,4)
54257  xmj=xmjr
54258  xmj2=xmj**2
54259  xl=pylamf(xmi2,xmj2,xmj2)
54260  xlam(lknt)=cf*sqrt(xl)/4d0*c1/xmi3*
54261  & (ghll*al+ghrr*ar
54262  & +2d0*ghlr*alr)**2
54263  idlam(lknt,1)=ij+ksusy1
54264  idlam(lknt,2)=-(ij+ksusy1)
54265  idlam(lknt,3)=0
54266  ENDIF
54267  180 CONTINUE
54268 
54269  IF(axmi.GE.xmjl+xmjr) THEN
54270  lknt=lknt+1
54271  al=sfmix(ifl,1)*sfmix(ifl,3)
54272  ar=sfmix(ifl,2)*sfmix(ifl,4)
54273  alr=sfmix(ifl,1)*sfmix(ifl,4)+sfmix(ifl,2)*sfmix(ifl,3)
54274  xmj=xmjr
54275  xmj2=xmj**2
54276  xl=pylamf(xmi2,xmj2,xmjl**2)
54277  xlam(lknt)=cf*sqrt(xl)/4d0*c1/xmi3*
54278  & (ghll*al+ghrr*ar)**2
54279  idlam(lknt,1)=ij
54280  idlam(lknt,2)=-(ij+ksusy1)
54281  idlam(lknt,3)=0
54282  lknt=lknt+1
54283  idlam(lknt,1)=-ij
54284  idlam(lknt,2)=ij+ksusy1
54285  idlam(lknt,3)=0
54286  xlam(lknt)=xlam(lknt-1)
54287  ENDIF
54288  ENDIF
54289  190 CONTINUE
54290  200 CONTINUE
54291  210 CONTINUE
54292 
54293  goto 270
54294  220 CONTINUE
54295 
54296 C...H+ -> CHI+_I + CHI0_J
54297  DO 240 ij=1,4
54298  xmj=smz(ij)
54299  axmj=abs(xmj)
54300  xmj2=xmj**2
54301  DO 230 ik=1,2
54302  xmk=smw(ik)
54303  axmk=abs(xmk)
54304  IF(axmi.GE.axmj+axmk) THEN
54305  lknt=lknt+1
54306  olpp=cbeta*dconjg(zmixc(ij,4)*vmixc(ik,1)+(zmixc(ij,2)+
54307  & zmixc(ij,1)*tanw)*vmixc(ik,2)/sr2)
54308  orpp=sbeta*(zmixc(ij,3)*umixc(ik,1)-
54309  & (zmixc(ij,2)+zmixc(ij,1)*tanw)*umixc(ik,2)/sr2)
54310  gx2=abs(olpp)**2+abs(orpp)**2
54311  glr=dble(olpp*dconjg(orpp))
54312  xlam(lknt)=pyh2xx(c1,xmi,xmj,-xmk,gx2,glr)
54313  idlam(lknt,1)=kfnchi(ij)
54314  idlam(lknt,2)=kfcchi(ik)
54315  idlam(lknt,3)=0
54316  ENDIF
54317  230 CONTINUE
54318  240 CONTINUE
54319 
54320  gl=-xmw/sr2*(sin(2d0*beta)-pmas(6,1)**2/tanb/xmw2)
54321  gr=-pmas(6,1)/sr2/xmw*(xmuz-atrit/tanb)
54322  al=0d0
54323  ar=0d0
54324  cf=3d0
54325 
54326 C...H+ -> T_1 B_1~
54327  xm1=pmas(pycomp(ksusy1+6),1)
54328  xm2=pmas(pycomp(ksusy1+5),1)
54329  IF(xmi.GE.xm1+xm2) THEN
54330  xl=pylamf(xmi2,xm1**2,xm2**2)
54331  lknt=lknt+1
54332  xlam(lknt)=cf*sqrt(xl)/4d0*c1/xmi3*
54333  & (gl*sfmix(6,1)*sfmix(5,1)+gr*sfmix(6,2)*sfmix(5,1))**2
54334  idlam(lknt,1)=ksusy1+6
54335  idlam(lknt,2)=-(ksusy1+5)
54336  idlam(lknt,3)=0
54337  ENDIF
54338 
54339 C...H+ -> T_2 B_1~
54340  xm1=pmas(pycomp(ksusy2+6),1)
54341  xm2=pmas(pycomp(ksusy1+5),1)
54342  IF(xmi.GE.xm1+xm2) THEN
54343  xl=pylamf(xmi2,xm1**2,xm2**2)
54344  lknt=lknt+1
54345  xlam(lknt)=cf*sqrt(xl)/4d0*c1/xmi3*
54346  & (gl*sfmix(6,3)*sfmix(5,1)+gr*sfmix(6,4)*sfmix(5,1))**2
54347  idlam(lknt,1)=ksusy2+6
54348  idlam(lknt,2)=-(ksusy1+5)
54349  idlam(lknt,3)=0
54350  ENDIF
54351 
54352 C...H+ -> T_1 B_2~
54353  xm1=pmas(pycomp(ksusy1+6),1)
54354  xm2=pmas(pycomp(ksusy2+5),1)
54355  IF(xmi.GE.xm1+xm2) THEN
54356  xl=pylamf(xmi2,xm1**2,xm2**2)
54357  lknt=lknt+1
54358  xlam(lknt)=cf*sqrt(xl)/4d0*c1/xmi3*
54359  & (gl*sfmix(6,1)*sfmix(5,3)+gr*sfmix(6,2)*sfmix(5,3))**2
54360  idlam(lknt,1)=ksusy1+6
54361  idlam(lknt,2)=-(ksusy2+5)
54362  idlam(lknt,3)=0
54363  ENDIF
54364 
54365 C...H+ -> T_2 B_2~
54366  xm1=pmas(pycomp(ksusy2+6),1)
54367  xm2=pmas(pycomp(ksusy2+5),1)
54368  IF(xmi.GE.xm1+xm2) THEN
54369  xl=pylamf(xmi2,xm1**2,xm2**2)
54370  lknt=lknt+1
54371  xlam(lknt)=cf*sqrt(xl)/4d0*c1/xmi3*
54372  & (gl*sfmix(6,3)*sfmix(5,3)+gr*sfmix(6,4)*sfmix(5,3))**2
54373  idlam(lknt,1)=ksusy2+6
54374  idlam(lknt,2)=-(ksusy2+5)
54375  idlam(lknt,3)=0
54376  ENDIF
54377 
54378 C...H+ -> UL DL~
54379  gl=-xmw/sr2*sin(2d0*beta)
54380  DO 250 ij=1,3,2
54381  xm1=pmas(pycomp(ksusy1+ij),1)
54382  xm2=pmas(pycomp(ksusy1+ij+1),1)
54383  IF(xmi.GE.xm1+xm2) THEN
54384  xl=pylamf(xmi2,xm1**2,xm2**2)
54385  lknt=lknt+1
54386  xlam(lknt)=cf*sqrt(xl)/4d0*c1/xmi3*gl**2
54387  idlam(lknt,1)=-(ksusy1+ij)
54388  idlam(lknt,2)=ksusy1+ij+1
54389  idlam(lknt,3)=0
54390  ENDIF
54391  250 CONTINUE
54392 
54393 C...H+ -> EL~ NUL
54394  cf=1d0
54395  DO 260 ij=11,13,2
54396  xm1=pmas(pycomp(ksusy1+ij),1)
54397  xm2=pmas(pycomp(ksusy1+ij+1),1)
54398  IF(xmi.GE.xm1+xm2) THEN
54399  xl=pylamf(xmi2,xm1**2,xm2**2)
54400  lknt=lknt+1
54401  xlam(lknt)=cf*sqrt(xl)/4d0*c1/xmi3*gl**2
54402  idlam(lknt,1)=-(ksusy1+ij)
54403  idlam(lknt,2)=ksusy1+ij+1
54404  idlam(lknt,3)=0
54405  ENDIF
54406  260 CONTINUE
54407 
54408 C...H+ -> TAU1 NUTAUL
54409  xm1=pmas(pycomp(ksusy1+15),1)
54410  xm2=pmas(pycomp(ksusy1+16),1)
54411  IF(xmi.GE.xm1+xm2) THEN
54412  xl=pylamf(xmi2,xm1**2,xm2**2)
54413  lknt=lknt+1
54414  xlam(lknt)=cf*sqrt(xl)/4d0*c1/xmi3*gl**2*sfmix(15,1)**2
54415  idlam(lknt,1)=-(ksusy1+15)
54416  idlam(lknt,2)= ksusy1+16
54417  idlam(lknt,3)=0
54418  ENDIF
54419 
54420 C...H+ -> TAU2 NUTAUL
54421  xm1=pmas(pycomp(ksusy2+15),1)
54422  xm2=pmas(pycomp(ksusy1+16),1)
54423  IF(xmi.GE.xm1+xm2) THEN
54424  xl=pylamf(xmi2,xm1**2,xm2**2)
54425  lknt=lknt+1
54426  xlam(lknt)=cf*sqrt(xl)/4d0*c1/xmi3*gl**2*sfmix(15,3)**2
54427  idlam(lknt,1)=-(ksusy2+15)
54428  idlam(lknt,2)= ksusy1+16
54429  idlam(lknt,3)=0
54430  ENDIF
54431 
54432  270 CONTINUE
54433  iknt=lknt
54434  xlam(0)=0d0
54435  DO 280 i=1,iknt
54436  IF(xlam(i).LE.0d0) xlam(i)=0d0
54437  xlam(0)=xlam(0)+xlam(i)
54438  280 CONTINUE
54439  IF(xlam(0).EQ.0d0) xlam(0)=1d-6
54440 
54441  RETURN
54442  END
54443 
54444 C*********************************************************************
54445 
54446 C...PYH2XX
54447 C...Calculates the decay rate for a Higgs to an ino pair.
54448 
54449  FUNCTION pyh2xx(C1,XM1,XM2,XM3,GX2,GLR)
54450 
54451 C...Double precision and integer declarations.
54452  IMPLICIT DOUBLE PRECISION(a-h, o-z)
54453  IMPLICIT INTEGER(i-n)
54454  INTEGER pyk,pychge,pycomp
54455 C...Commonblocks.
54456  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
54457  SAVE /pydat1/
54458 
54459 C...Local variables.
54460  DOUBLE PRECISION pyh2xx,xm1,xm2,xm3,gl,gr
54461  DOUBLE PRECISION xl,pylamf,c1
54462  DOUBLE PRECISION xmi2,xmj2,xmk2,xmi3
54463 
54464  xmi2=xm1**2
54465  xmi3=abs(xm1**3)
54466  xmj2=xm2**2
54467  xmk2=xm3**2
54468  xl=pylamf(xmi2,xmj2,xmk2)
54469  pyh2xx=c1/4d0/xmi3*sqrt(xl)
54470  &*(gx2*(xmi2-xmj2-xmk2)-
54471  &4d0*glr*xm3*xm2)
54472  IF(pyh2xx.LT.0d0) pyh2xx=0d0
54473 
54474  RETURN
54475  END
54476 
54477 C*********************************************************************
54478 
54479 C...PYGAUS
54480 C...Integration by adaptive Gaussian quadrature.
54481 C...Adapted from the CERNLIB DGAUSS routine by K.S. Kolbig.
54482 
54483  FUNCTION pygaus(F, A, B, EPS)
54484 
54485 C...Double precision and integer declarations.
54486  IMPLICIT DOUBLE PRECISION(a-h, o-z)
54487  IMPLICIT INTEGER(i-n)
54488  INTEGER pyk,pychge,pycomp
54489 
54490 C...Local declarations.
54491  EXTERNAL f
54492  DOUBLE PRECISION f,w(12), x(12)
54493  DATA x( 1) /9.6028985649753623d-1/, w( 1) /1.0122853629037626d-1/
54494  DATA x( 2) /7.9666647741362674d-1/, w( 2) /2.2238103445337447d-1/
54495  DATA x( 3) /5.2553240991632899d-1/, w( 3) /3.1370664587788729d-1/
54496  DATA x( 4) /1.8343464249564980d-1/, w( 4) /3.6268378337836198d-1/
54497  DATA x( 5) /9.8940093499164993d-1/, w( 5) /2.7152459411754095d-2/
54498  DATA x( 6) /9.4457502307323258d-1/, w( 6) /6.2253523938647893d-2/
54499  DATA x( 7) /8.6563120238783174d-1/, w( 7) /9.5158511682492785d-2/
54500  DATA x( 8) /7.5540440835500303d-1/, w( 8) /1.2462897125553387d-1/
54501  DATA x( 9) /6.1787624440264375d-1/, w( 9) /1.4959598881657673d-1/
54502  DATA x(10) /4.5801677765722739d-1/, w(10) /1.6915651939500254d-1/
54503  DATA x(11) /2.8160355077925891d-1/, w(11) /1.8260341504492359d-1/
54504  DATA x(12) /9.5012509837637440d-2/, w(12) /1.8945061045506850d-1/
54505 
54506 C...The Gaussian quadrature algorithm.
54507  h = 0d0
54508  IF(b .EQ. a) goto 140
54509  const = 5d-3 / abs(b-a)
54510  bb = a
54511  100 CONTINUE
54512  aa = bb
54513  bb = b
54514  110 CONTINUE
54515  c1 = 0.5d0*(bb+aa)
54516  c2 = 0.5d0*(bb-aa)
54517  s8 = 0d0
54518  DO 120 i = 1, 4
54519  u = c2*x(i)
54520  s8 = s8 + w(i) * (f(c1+u) + f(c1-u))
54521  120 CONTINUE
54522  s16 = 0d0
54523  DO 130 i = 5, 12
54524  u = c2*x(i)
54525  s16 = s16 + w(i) * (f(c1+u) + f(c1-u))
54526  130 CONTINUE
54527  s16 = c2*s16
54528  IF(dabs(s16-c2*s8) .LE. eps*(1d0+dabs(s16))) THEN
54529  h = h + s16
54530  IF(bb .NE. b) goto 100
54531  ELSE
54532  bb = c1
54533  IF(1d0 + const*abs(c2) .NE. 1d0) goto 110
54534  h = 0d0
54535  CALL pyerrm(18,'(PYGAUS:) too high accuracy required')
54536  goto 140
54537  ENDIF
54538  140 CONTINUE
54539  pygaus = h
54540 
54541  RETURN
54542  END
54543 
54544 C*********************************************************************
54545 
54546 C...PYGAU2
54547 C...Integration by adaptive Gaussian quadrature.
54548 C...Adapted from the CERNLIB DGAUSS routine by K.S. Kolbig.
54549 C...Carbon copy of PYGAUS, but avoids having to use it recursively.
54550 
54551  FUNCTION pygau2(F, A, B, EPS)
54552 
54553 C...Double precision and integer declarations.
54554  IMPLICIT DOUBLE PRECISION(a-h, o-z)
54555  IMPLICIT INTEGER(i-n)
54556  INTEGER pyk,pychge,pycomp
54557 
54558 C...Local declarations.
54559  EXTERNAL f
54560  DOUBLE PRECISION f,w(12), x(12)
54561  DATA x( 1) /9.6028985649753623d-1/, w( 1) /1.0122853629037626d-1/
54562  DATA x( 2) /7.9666647741362674d-1/, w( 2) /2.2238103445337447d-1/
54563  DATA x( 3) /5.2553240991632899d-1/, w( 3) /3.1370664587788729d-1/
54564  DATA x( 4) /1.8343464249564980d-1/, w( 4) /3.6268378337836198d-1/
54565  DATA x( 5) /9.8940093499164993d-1/, w( 5) /2.7152459411754095d-2/
54566  DATA x( 6) /9.4457502307323258d-1/, w( 6) /6.2253523938647893d-2/
54567  DATA x( 7) /8.6563120238783174d-1/, w( 7) /9.5158511682492785d-2/
54568  DATA x( 8) /7.5540440835500303d-1/, w( 8) /1.2462897125553387d-1/
54569  DATA x( 9) /6.1787624440264375d-1/, w( 9) /1.4959598881657673d-1/
54570  DATA x(10) /4.5801677765722739d-1/, w(10) /1.6915651939500254d-1/
54571  DATA x(11) /2.8160355077925891d-1/, w(11) /1.8260341504492359d-1/
54572  DATA x(12) /9.5012509837637440d-2/, w(12) /1.8945061045506850d-1/
54573 
54574 C...The Gaussian quadrature algorithm.
54575  h = 0d0
54576  IF(b .EQ. a) goto 140
54577  const = 5d-3 / abs(b-a)
54578  bb = a
54579  100 CONTINUE
54580  aa = bb
54581  bb = b
54582  110 CONTINUE
54583  c1 = 0.5d0*(bb+aa)
54584  c2 = 0.5d0*(bb-aa)
54585  s8 = 0d0
54586  DO 120 i = 1, 4
54587  u = c2*x(i)
54588  s8 = s8 + w(i) * (f(c1+u) + f(c1-u))
54589  120 CONTINUE
54590  s16 = 0d0
54591  DO 130 i = 5, 12
54592  u = c2*x(i)
54593  s16 = s16 + w(i) * (f(c1+u) + f(c1-u))
54594  130 CONTINUE
54595  s16 = c2*s16
54596  IF(dabs(s16-c2*s8) .LE. eps*(1d0+dabs(s16))) THEN
54597  h = h + s16
54598  IF(bb .NE. b) goto 100
54599  ELSE
54600  bb = c1
54601  IF(1d0 + const*abs(c2) .NE. 1d0) goto 110
54602  h = 0d0
54603  CALL pyerrm(18,'(PYGAU2:) too high accuracy required')
54604  goto 140
54605  ENDIF
54606  140 CONTINUE
54607  pygau2 = h
54608 
54609  RETURN
54610  END
54611 
54612 C*********************************************************************
54613 
54614 C...PYSIMP
54615 C...Simpson formula for an integral.
54616 
54617  FUNCTION pysimp(Y,X0,X1,N)
54618 
54619 C...Double precision and integer declarations.
54620  IMPLICIT DOUBLE PRECISION(a-h, o-z)
54621  IMPLICIT INTEGER(i-n)
54622  INTEGER pyk,pychge,pycomp
54623 
54624 C...Local variables.
54625  DOUBLE PRECISION y,x0,x1,h,s
54626  dimension y(0:n)
54627 
54628  s=0d0
54629  h=(x1-x0)/n
54630  DO 100 i=0,n-2,2
54631  s=s+y(i)+4d0*y(i+1)+y(i+2)
54632  100 CONTINUE
54633  pysimp=s*h/3d0
54634 
54635  RETURN
54636  END
54637 
54638 C*********************************************************************
54639 
54640 C...PYLAMF
54641 C...The standard lambda function.
54642 
54643  FUNCTION pylamf(X,Y,Z)
54644 
54645 C...Double precision and integer declarations.
54646  IMPLICIT DOUBLE PRECISION(a-h, o-z)
54647  IMPLICIT INTEGER(i-n)
54648  INTEGER pyk,pychge,pycomp
54649 
54650 C...Local variables.
54651  DOUBLE PRECISION pylamf,x,y,z
54652 
54653  pylamf=(x-(y+z))**2-4d0*y*z
54654  IF(pylamf.LT.0d0) pylamf=0d0
54655 
54656  RETURN
54657  END
54658 
54659 C*********************************************************************
54660 
54661 C...PYTBDY
54662 C...Generates 3-body decays of gauginos.
54663 
54664  SUBROUTINE pytbdy(IDIN)
54665 
54666 C...Double precision and integer declarations.
54667  IMPLICIT DOUBLE PRECISION(a-h, o-z)
54668  IMPLICIT INTEGER(i-n)
54669  INTEGER pyk,pychge,pycomp
54670 C...Parameter statement to help give large particle numbers.
54671  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
54672  &kexcit=4000000,kdimen=5000000)
54673 C...Commonblocks.
54674  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
54675  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
54676  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
54677 C COMMON/PYDAT3/MDCY(500,3),MDME(8000,2),BRAT(8000),KFDP(8000,5)
54678  common/pypars/mstp(200),parp(200),msti(200),pari(200)
54679  common/pyssmt/zmix(4,4),umix(2,2),vmix(2,2),smz(4),smw(2),
54680  &sfmix(16,4),zmixi(4,4),umixi(2,2),vmixi(2,2)
54681 C SAVE /PYJETS/,/PYDAT1/,/PYDAT2/,/PYDAT3/,/PYPARS/,/PYSSMT/
54682  SAVE /pyjets/,/pydat1/,/pydat2/,/pypars/,/pyssmt/
54683 
54684 C...Local variables.
54685  DOUBLE PRECISION xm(5)
54686  COMPLEX*16 olpp,orpp,qll,qlr,qrr,qrl,glij,grij,propz
54687  COMPLEX*16 qlls,qrrs,qlrs,qrls,qllu,qrru,qlrt,qrlt
54688  COMPLEX*16 zmixc(4,4),umixc(2,2),vmixc(2,2)
54689  DOUBLE PRECISION s12min,s12max,yjaco1,s23ave,s23df1,s23df2
54690  DOUBLE PRECISION d1,d2,d3,p1,p2,p3,cthe1,sthe1,cthe3,sthe3
54691  DOUBLE PRECISION cphi1,sphi1
54692  DOUBLE PRECISION s23del,eps
54693  DOUBLE PRECISION golden,ax,bx,cx,tol,xmin,r,c
54694  parameter(r=0.61803399d0,c=1d0-r,tol=1d-3)
54695  DOUBLE PRECISION f1,f2,x0,x1,x2,x3
54696  INTEGER inoid(4)
54697  DATA inoid/22,23,25,35/
54698  DATA eps/1d-6/
54699 
54700  id=idin
54701  iskip=1
54702  xm(1)=p(n+1,5)
54703  xm(2)=p(n+2,5)
54704  xm(3)=p(n+3,5)
54705  xm(5)=p(id,5)
54706 
54707 C...GENERATE S12
54708  s12min=(xm(1)+xm(2))**2
54709  s12max=(xm(5)-xm(3))**2
54710  yjaco1=s12max-s12min
54711 
54712 C...Initialize some parameters
54713  xw=paru(102)
54714  xw1=1d0-xw
54715  tanw=sqrt(xw/xw1)
54716  izid1=0
54717  iwid1=0
54718  izid2=0
54719  iwid2=0
54720 
54721  ia=k(n+2,2)
54722  ja=k(n+3,2)
54723 
54724 C...Mrenna: check that we are indeed decaying a SUSY particle
54725  IF(iabs(k(id,2)).LT.ksusy1.OR.iabs(k(id,2)).GE.3000000) THEN
54726 
54727  ELSE
54728  DO 100 i1=1,4
54729  IF(mod(k(n+1,2),ksusy1).EQ.inoid(i1)) izid1=i1
54730  IF(mod(k(id,2),ksusy1).EQ.inoid(i1)) izid2=i1
54731  100 CONTINUE
54732  IF(mod(k(n+1,2),ksusy1).EQ.24) iwid1=1
54733  IF(mod(k(n+1,2),ksusy1).EQ.37) iwid1=2
54734  IF(mod(k(id,2),ksusy1).EQ.24) iwid2=1
54735  IF(mod(k(id,2),ksusy1).EQ.37) iwid2=2
54736  zm12=xm(5)**2
54737  zm22=xm(1)**2
54738  ei=kchg(pycomp(iabs(ia)),1)/3d0
54739  t3i=sign(1d0,ei+1d-6)/2d0
54740  ENDIF
54741 
54742  IF(mstp(47).EQ.0) THEN
54743  iskip=0
54744  ELSEIF(max(abs(ia),abs(ja)).EQ.6) THEN
54745  iskip=0
54746  ELSEIF(izid1*izid2.NE.0) THEN
54747  sqmz=pmas(23,1)**2
54748  gmmz=pmas(23,1)*pmas(23,2)
54749  DO 110 i=1,4
54750  zmixc(izid1,i)=dcmplx(zmix(izid1,i),zmixi(izid1,i))
54751  zmixc(izid2,i)=dcmplx(zmix(izid2,i),zmixi(izid2,i))
54752  110 CONTINUE
54753  olpp=(zmixc(izid1,3)*dconjg(zmixc(izid2,3))-
54754  & zmixc(izid1,4)*dconjg(zmixc(izid2,4)))/2d0
54755  orpp=dconjg(olpp)
54756  xll2=pmas(pycomp(ksusy1+iabs(ia)),1)**2
54757  xlr2=xll2
54758  xrr2=pmas(pycomp(ksusy2+iabs(ia)),1)**2
54759  xrl2=xrr2
54760  glij=(t3i*zmixc(izid1,2)-tanw*(t3i-ei)*zmixc(izid1,1))*
54761  & dconjg(t3i*zmixc(izid2,2)-tanw*(t3i-ei)*zmixc(izid2,1))
54762  grij=zmixc(izid1,1)*dconjg(zmixc(izid2,1))*(ei*tanw)**2
54763  xm1m2=smz(izid1)*smz(izid2)
54764  qlls=dcmplx((t3i-ei*xw)/xw1)*olpp
54765  qllu=-glij
54766  qlrs=-dcmplx((t3i-ei*xw)/xw1)*orpp
54767  qlrt=dconjg(glij)
54768  qrls=-dcmplx((ei*xw)/xw1)*olpp
54769  qrlt=grij
54770  qrrs=dcmplx((ei*xw)/xw1)*orpp
54771  qrru=-dconjg(grij)
54772  ELSEIF(izid1*iwid2.NE.0.OR.izid2*iwid1.NE.0) THEN
54773  IF(izid1.NE.0) THEN
54774  xm1m2=smz(izid1)*smw(iwid2)
54775  izid1=iwid2
54776  izid2=izid1
54777  ELSE
54778  xm1m2=smz(izid2)*smw(iwid1)
54779  izid1=iwid1
54780  ENDIF
54781  rt2i = 1d0/sqrt(2d0)
54782  sqmz=pmas(24,1)**2
54783  gmmz=pmas(24,1)*pmas(24,2)
54784  DO 120 i=1,2
54785  vmixc(izid1,i)=dcmplx(vmix(izid1,i),vmixi(izid1,i))
54786  umixc(izid1,i)=dcmplx(umix(izid1,i),umixi(izid1,i))
54787  120 CONTINUE
54788  DO 130 i=1,4
54789  zmixc(izid2,i)=dcmplx(zmix(izid2,i),zmixi(izid2,i))
54790  130 CONTINUE
54791  qlls=(dconjg(zmixc(izid2,2))*vmixc(izid1,1)-
54792  & dconjg(zmixc(izid2,4))*vmixc(izid1,2)*rt2i)
54793  qlrs=(zmixc(izid2,2)*dconjg(umixc(izid1,1))+
54794  & zmixc(izid2,3)*dconjg(umixc(izid1,2))*rt2i)
54795  ej=kchg(iabs(ja),1)/3d0
54796  t3j=sign(1d0,ej+1d-6)/2d0
54797  qrls=dcmplx(0d0,0d0)
54798  qrlt=qrls
54799  qrrs=qrls
54800  qrru=qrls
54801  xrr2=1d6**2
54802  xrl2=xrr2
54803  xlr2 = pmas(pycomp(ksusy1+iabs(ja)),1)**2
54804  xll2 = pmas(pycomp(ksusy1+iabs(ia)),1)**2
54805  IF(mod(ia,2).EQ.0) THEN
54806  qllu=vmixc(izid1,1)*dconjg(zmixc(izid2,1)*(ei-t3i)*
54807  & tanw+zmixc(izid2,2)*t3i)
54808  qlrt=-dconjg(umixc(izid1,1))*(
54809  & zmixc(izid2,1)*(ej-t3j)*tanw+zmixc(izid2,2)*t3j)
54810  ELSE
54811  qllu=vmixc(izid1,1)*dconjg(zmixc(izid2,1)*(ej-t3j)*
54812  & tanw+zmixc(izid2,2)*t3j)
54813  qlrt=-dconjg(umixc(izid1,1))*(
54814  & zmixc(izid2,1)*(ei-t3i)*tanw+zmixc(izid2,2)*t3i)
54815  ENDIF
54816  ELSEIF(iwid1*iwid2.NE.0) THEN
54817  izid1=iwid1
54818  izid2=iwid2
54819  xm1m2=smw(iwid1)*smw(iwid2)
54820  sqmz=pmas(23,1)**2
54821  gmmz=pmas(23,1)*pmas(23,2)
54822  DO 140 i=1,2
54823  vmixc(izid1,i)=dcmplx(vmix(izid1,i),vmixi(izid1,i))
54824  umixc(izid1,i)=dcmplx(umix(izid1,i),umixi(izid1,i))
54825  vmixc(izid2,i)=dcmplx(vmix(izid2,i),vmixi(izid2,i))
54826  umixc(izid2,i)=dcmplx(umix(izid2,i),umixi(izid2,i))
54827  140 CONTINUE
54828  olpp=-vmixc(izid2,1)*dconjg(vmixc(izid1,1))-
54829  & vmixc(izid2,2)*dconjg(vmixc(izid1,2))/2d0
54830  orpp=-umixc(izid1,1)*dconjg(umixc(izid2,1))-
54831  & umixc(izid1,2)*dconjg(umixc(izid2,2))/2d0
54832  qrls=-dcmplx(ei/xw1)*orpp
54833  qlls=dcmplx((t3i-xw*ei)/xw/xw1)*orpp
54834  qrrs=-dcmplx(ei/xw1)*olpp
54835  qlrs=dcmplx((t3i-xw*ei)/xw/xw1)*olpp
54836  IF(mod(ia,2).EQ.0) THEN
54837  xlr2=pmas(pycomp(ksusy1+iabs(ia)-1),1)**2
54838  qlrt=-umixc(izid2,1)*dconjg(umixc(izid1,1))*dcmplx(t3i/xw)
54839  ELSE
54840  xlr2=pmas(pycomp(ksusy1+iabs(ia)+1),1)**2
54841  qlrt=-vmixc(izid2,1)*dconjg(vmixc(izid1,1))*dcmplx(t3i/xw)
54842  ENDIF
54843  ELSEIF(mod(k(n+1,2),ksusy1).EQ.21.OR.mod(k(id,2),ksusy1).EQ.21)
54844  &THEN
54845  iskip=0
54846  ELSE
54847  iskip=0
54848  ENDIF
54849 
54850  IF(iskip.NE.0) THEN
54851  wtmax=0d0
54852  DO 160 kt=1,100
54853  s12=s12min+yjaco1*(kt-1)/99
54854  s23ave=xm(2)**2+xm(3)**2-(s12+xm(2)**2-xm(1)**2)
54855  & *(s12+xm(3)**2-xm(5)**2)/(2d0*s12)
54856  s23df1=(s12-xm(2)**2-xm(1)**2)**2
54857  & -(2d0*xm(1)*xm(2))**2
54858  s23df2=(s12-xm(3)**2-xm(5)**2)**2
54859  & -(2d0*xm(3)*xm(5))**2
54860  s23df1=s23df1*eps
54861  s23df2=s23df2*eps
54862  s23del=sqrt(max(0d0,s23df1*s23df2))/(2d0*s12)
54863  s23del=s23del/eps
54864  s23min=s23ave-s23del
54865  s23max=s23ave+s23del
54866  yjaco2=s23max-s23min
54867  th=s12
54868  DO 150 ks=1,100
54869  s23=s23min+yjaco2*(ks-1)/99
54870  sh=s23
54871  uh=zm12+zm22-sh-th
54872  wu2 = (uh-zm12)*(uh-zm22)
54873  wt2 = (th-zm12)*(th-zm22)
54874  ws2 = xm1m2*sh
54875  propz2 = (sh-sqmz)**2 + gmmz**2
54876  propz=dcmplx(sh-sqmz,-gmmz)/dcmplx(propz2)
54877  qll=qlls*propz+qllu/dcmplx(uh-xll2)
54878  qlr=qlrs*propz+qlrt/dcmplx(th-xlr2)
54879  qrl=qrls*propz+qrlt/dcmplx(th-xrl2)
54880  qrr=qrrs*propz+qrru/dcmplx(uh-xrr2)
54881  wt0=-((abs(qll)**2+abs(qrr)**2)*wu2+
54882  & (abs(qrl)**2+abs(qlr)**2)*wt2+
54883  & 2d0*dble(qlr*dconjg(qll)+qrl*dconjg(qrr))*ws2)
54884  IF(wt0.GT.wtmax) wtmax=wt0
54885  150 CONTINUE
54886  160 CONTINUE
54887 
54888  wtmax=wtmax*1.05d0
54889  ENDIF
54890 
54891 C...FIND S12*
54892  ax=s12min
54893  cx=s12max
54894  bx=s12min+0.5d0*yjaco1
54895  x0=ax
54896  x3=cx
54897  IF(abs(cx-bx).GT.abs(bx-ax))THEN
54898  x1=bx
54899  x2=bx+c*(cx-bx)
54900  ELSE
54901  x2=bx
54902  x1=bx-c*(bx-ax)
54903  ENDIF
54904 
54905 C...SOLVE FOR F1 AND F2
54906  s23df1=(x1-xm(2)**2-xm(1)**2)**2
54907  &-(2d0*xm(1)*xm(2))**2
54908  s23df2=(x1-xm(3)**2-xm(5)**2)**2
54909  &-(2d0*xm(3)*xm(5))**2
54910  s23df1=s23df1*eps
54911  s23df2=s23df2*eps
54912  s23del=sqrt(max(0d0,s23df1*s23df2))/(2d0*x1)
54913  f1=-2d0*s23del/eps
54914  s23df1=(x2-xm(2)**2-xm(1)**2)**2
54915  &-(2d0*xm(1)*xm(2))**2
54916  s23df2=(x2-xm(3)**2-xm(5)**2)**2
54917  &-(2d0*xm(3)*xm(5))**2
54918  s23df1=s23df1*eps
54919  s23df2=s23df2*eps
54920  s23del=sqrt(max(0d0,s23df1*s23df2))/(2d0*x2)
54921  f2=-2d0*s23del/eps
54922 
54923  170 IF(abs(x3-x0).GT.tol*(abs(x1)+abs(x2)))THEN
54924 C...Possibility of infinite loop with .LT.; changed to .LE. (SKANDS)
54925  IF(f2.LE.f1)THEN
54926  x0=x1
54927  x1=x2
54928  x2=r*x1+c*x3
54929  f1=f2
54930  s23df1=(x2-xm(2)**2-xm(1)**2)**2
54931  & -(2d0*xm(1)*xm(2))**2
54932  s23df2=(x2-xm(3)**2-xm(5)**2)**2
54933  & -(2d0*xm(3)*xm(5))**2
54934  s23df1=s23df1*eps
54935  s23df2=s23df2*eps
54936  s23del=sqrt(max(0d0,s23df1*s23df2))/(2d0*x2)
54937  f2=-2d0*s23del/eps
54938  ELSE
54939  x3=x2
54940  x2=x1
54941  x1=r*x2+c*x0
54942  f2=f1
54943  s23df1=(x1-xm(2)**2-xm(1)**2)**2
54944  & -(2d0*xm(1)*xm(2))**2
54945  s23df2=(x1-xm(3)**2-xm(5)**2)**2
54946  & -(2d0*xm(3)*xm(5))**2
54947  s23df1=s23df1*eps
54948  s23df2=s23df2*eps
54949  s23del=sqrt(max(0d0,s23df1*s23df2))/(2d0*x1)
54950  f1=-2d0*s23del/eps
54951  ENDIF
54952  goto 170
54953  ENDIF
54954 C...WE WANT THE MAXIMUM, NOT THE MINIMUM
54955  IF(f1.LT.f2)THEN
54956  golden=-f1
54957  xmin=x1
54958  ELSE
54959  golden=-f2
54960  xmin=x2
54961  ENDIF
54962 
54963  iknt=0
54964  180 s12=s12min+pyr(0)*yjaco1
54965  iknt=iknt+1
54966 C...GENERATE S23
54967  s23ave=xm(2)**2+xm(3)**2-(s12+xm(2)**2-xm(1)**2)
54968  &*(s12+xm(3)**2-xm(5)**2)/(2d0*s12)
54969  s23df1=(s12-xm(2)**2-xm(1)**2)**2
54970  &-(2d0*xm(1)*xm(2))**2
54971  s23df2=(s12-xm(3)**2-xm(5)**2)**2
54972  &-(2d0*xm(3)*xm(5))**2
54973  s23df1=s23df1*eps
54974  s23df2=s23df2*eps
54975  s23del=sqrt(max(0d0,s23df1*s23df2))/(2d0*s12)
54976  s23del=s23del/eps
54977  s23min=s23ave-s23del
54978  s23max=s23ave+s23del
54979  yjaco2=s23max-s23min
54980  s23=s23min+pyr(0)*yjaco2
54981 
54982 C...CHECK THE SAMPLING
54983  IF(iknt.GT.100) THEN
54984  WRITE(mstu(11),*) ' IKNT > 100 IN PYTBDY '
54985  goto 190
54986  ENDIF
54987  IF(yjaco2.LT.pyr(0)*golden) goto 180
54988 
54989  IF(iskip.EQ.0) goto 190
54990 
54991  sh=s23
54992  th=s12
54993  uh=zm12+zm22-sh-th
54994 
54995  wu2 = (uh-zm12)*(uh-zm22)
54996  wt2 = (th-zm12)*(th-zm22)
54997  ws2 = xm1m2*sh
54998  propz2 = (sh-sqmz)**2 + gmmz**2
54999  propz=dcmplx(sh-sqmz,-gmmz)/dcmplx(propz2)
55000 
55001  qll=qlls*propz+qllu/dcmplx(uh-xll2)
55002  qlr=qlrs*propz+qlrt/dcmplx(th-xlr2)
55003  qrl=qrls*propz+qrlt/dcmplx(th-xrl2)
55004  qrr=qrrs*propz+qrru/dcmplx(uh-xrr2)
55005 c QLL=DCMPLX((T3I-EI*XW)/XW1)*OLPP*PROPZ-GLIJ/DCMPLX(UH-XML2)
55006 c QLR=-DCMPLX((T3I-EI*XW)/XW1)*ORPP*PROPZ+DCONJG(GLIJ)
55007 c &/DCMPLX(TH-XML2)
55008 c QRL=-DCMPLX((EI*XW)/XW1)*OLPP*PROPZ+GRIJ/DCMPLX(TH-XMR2)
55009 c QRR=DCMPLX((EI*XW)/XW1)*ORPP*PROPZ
55010 c &-DCONJG(GRIJ)/DCMPLX(UH-XMR2)
55011  wt=-((abs(qll)**2+abs(qrr)**2)*wu2+
55012  &(abs(qrl)**2+abs(qlr)**2)*wt2+
55013  &2d0*dble(qlr*dconjg(qll)+qrl*dconjg(qrr))*ws2)
55014 
55015  IF(wt.LT.pyr(0)*wtmax) goto 180
55016  IF(wt.GT.wtmax) print*,' WT > WTMAX ',wt,wtmax
55017 
55018  190 d3=(xm(5)**2+xm(3)**2-s12)/(2d0*xm(5))
55019  d1=(xm(5)**2+xm(1)**2-s23)/(2d0*xm(5))
55020  d2=xm(5)-d1-d3
55021  p1=sqrt(d1*d1-xm(1)**2)
55022  p2=sqrt(d2*d2-xm(2)**2)
55023  p3=sqrt(d3*d3-xm(3)**2)
55024  cthe1=2d0*pyr(0)-1d0
55025  ang1=2d0*pyr(0)*paru(1)
55026  cphi1=cos(ang1)
55027  sphi1=sin(ang1)
55028  arg=1d0-cthe1**2
55029  IF(arg.LT.0d0.AND.arg.GT.-1d-3) arg=0d0
55030  sthe1=sqrt(arg)
55031  p(n+1,1)=p1*sthe1*cphi1
55032  p(n+1,2)=p1*sthe1*sphi1
55033  p(n+1,3)=p1*cthe1
55034  p(n+1,4)=d1
55035 
55036 C...GET CPHI3
55037  ang3=2d0*pyr(0)*paru(1)
55038  cphi3=cos(ang3)
55039  sphi3=sin(ang3)
55040  cthe3=(p2**2-p1**2-p3**2)/2d0/p1/p3
55041  arg=1d0-cthe3**2
55042  IF(arg.LT.0d0.AND.arg.GT.-1d-3) arg=0d0
55043  sthe3=sqrt(arg)
55044  p(n+3,1)=-p3*sthe3*cphi3*cthe1*cphi1
55045  &+p3*sthe3*sphi3*sphi1
55046  &+p3*cthe3*sthe1*cphi1
55047  p(n+3,2)=-p3*sthe3*cphi3*cthe1*sphi1
55048  &-p3*sthe3*sphi3*cphi1
55049  &+p3*cthe3*sthe1*sphi1
55050  p(n+3,3)=p3*sthe3*cphi3*sthe1
55051  &+p3*cthe3*cthe1
55052  p(n+3,4)=d3
55053 
55054  DO 200 i=1,3
55055  p(n+2,i)=-p(n+1,i)-p(n+3,i)
55056  200 CONTINUE
55057  p(n+2,4)=d2
55058 
55059  RETURN
55060  END
55061 
55062 
55063 C*********************************************************************
55064 
55065 C...PYTECM
55066 C...Finds the s-hat dependent eigenvalues of the inverse propagator
55067 C...matrix for gamma, Z, techni-rho, and techni-omega to optimize the
55068 C...phase space generation. Extended to include techni-a meson, and
55069 C...to return the width.
55070 
55071  SUBROUTINE pytecm(SMIN,SMOU,WIDO,IOPT)
55072 
55073 C...Double precision and integer declarations.
55074  IMPLICIT DOUBLE PRECISION(a-h, o-z)
55075  IMPLICIT INTEGER(i-n)
55076  INTEGER pyk,pychge,pycomp
55077 C...Parameter statement to help give large particle numbers.
55078  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
55079  &kexcit=4000000,kdimen=5000000)
55080 C...Commonblocks.
55081  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
55082  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
55083  common/pypars/mstp(200),parp(200),msti(200),pari(200)
55084  common/pytcsm/itcm(0:99),rtcm(0:99)
55085  SAVE /pydat1/,/pydat2/,/pypars/,/pytcsm/
55086 
55087 C...Local variables.
55088  DOUBLE PRECISION ar(5,5),wr(5),zr(5,5),zi(5,5),work(12,12),
55089  &at(5,5),wi(5),fv1(5),fv2(5),fv3(5),sh,aem,tanw,ct2w,qupd,alprht,
55090  &far,fao,fzr,fzo,shr,r1,r2,s1,s2,wdtp(0:400),wdte(0:400,0:5),wx(5)
55091  INTEGER i,j,ierr
55092 
55093  sh=smin
55094  shr=sqrt(sh)
55095  aem=pyalem(sh)
55096 
55097  sinw=min(sqrt(paru(102)),1d0)
55098  cosw=sqrt(1d0-sinw**2)
55099  tanw=sinw/cosw
55100  ct2w=(1d0-2d0*paru(102))/(2d0*paru(102)/tanw)
55101  qupd=2d0*rtcm(2)-1d0
55102 
55103  alprht=2.16d0*(3d0/dble(itcm(1)))
55104  far=sqrt(aem/alprht)
55105  fao=far*qupd
55106  fzr=far*ct2w
55107  fzo=-fao*tanw
55108  fzx=-far/rtcm(47)/(2d0*sinw*cosw)
55109  fwr=far/(2d0*sinw)
55110  fwx=-fwr/rtcm(47)
55111 
55112  DO 110 i=1,5
55113  DO 100 j=1,5
55114  at(i,j)=0d0
55115  100 CONTINUE
55116  110 CONTINUE
55117 
55118 C...NC
55119  IF(iopt.EQ.1) THEN
55120  ar(1,1) = sh
55121  ar(2,2) = sh-pmas(23,1)**2
55122  ar(3,3) = sh-pmas(pycomp(ktechn+113),1)**2
55123  ar(4,4) = sh-pmas(pycomp(ktechn+223),1)**2
55124  ar(5,5) = sh-pmas(pycomp(ktechn+115),1)**2
55125  ar(1,2) = 0d0
55126  ar(2,1) = 0d0
55127  ar(1,3) = sh*far
55128  ar(3,1) = ar(1,3)
55129  ar(1,4) = sh*fao
55130  ar(4,1) = ar(1,4)
55131  ar(2,3) = sh*fzr
55132  ar(3,2) = ar(2,3)
55133  ar(2,4) = sh*fzo
55134  ar(4,2) = ar(2,4)
55135  ar(3,4) = 0d0
55136  ar(4,3) = 0d0
55137  ar(2,5) = sh*fzx
55138  ar(5,2) = ar(2,5)
55139  ar(1,5) = 0d0
55140  ar(5,1) = ar(1,5)
55141  ar(3,5) = 0d0
55142  ar(5,3) = ar(3,5)
55143  ar(4,5) = 0d0
55144  ar(5,4) = ar(4,5)
55145  CALL pywidt(23,sh,wdtp,wdte)
55146  at(2,2) = wdtp(0)*shr
55147  CALL pywidt(ktechn+113,sh,wdtp,wdte)
55148  at(3,3) = wdtp(0)*shr
55149  CALL pywidt(ktechn+223,sh,wdtp,wdte)
55150  at(4,4) = wdtp(0)*shr
55151  CALL pywidt(ktechn+115,sh,wdtp,wdte)
55152  at(5,5) = wdtp(0)*shr
55153  idim=5
55154 C...CC
55155  ELSE
55156  ar(1,1) = sh-pmas(24,1)**2
55157  ar(2,2) = sh-pmas(pycomp(ktechn+213),1)**2
55158  ar(3,3) = sh-pmas(pycomp(ktechn+215),1)**2
55159  ar(1,2) = sh*fwr
55160  ar(2,1) = ar(1,2)
55161  ar(1,3) = sh*fwx
55162  ar(3,1) = ar(1,3)
55163  ar(2,3) = 0d0
55164  ar(3,2) = 0d0
55165  CALL pywidt(24,sh,wdtp,wdte)
55166  at(1,1) = wdtp(0)*shr
55167  CALL pywidt(ktechn+213,sh,wdtp,wdte)
55168  at(2,2) = wdtp(0)*shr
55169  CALL pywidt(ktechn+215,sh,wdtp,wdte)
55170  at(3,3) = wdtp(0)*shr
55171  idim=3
55172  ENDIF
55173  CALL pyeicg(idim,idim,ar,at,wr,wi,0,zr,zi,fv1,fv2,fv3,ierr)
55174 
55175  imin=1
55176  sxmn=1d20
55177  DO 120 i=1,idim
55178  wx(i)=sqrt(abs(sh-wr(i)))
55179  wr(i)=abs(wr(i))
55180  IF(wr(i).LT.sxmn) THEN
55181  sxmn=wr(i)
55182  imin=i
55183  ENDIF
55184  120 CONTINUE
55185  smou=wx(imin)**2
55186  wido=wi(imin)/shr
55187 
55188  RETURN
55189  END
55190 C*********************************************************************
55191 
55192 C...PYXDIN
55193 C...Universal Extra Dimensions Model (UED)
55194 C...Initialize the xd masses and widths
55195 C...M. ELKACIMI 4/03/2006
55196 C...Modified for inclusion in Pythia Apr 2008, H. Przysiezniak, P. Skands
55197 
55198  SUBROUTINE pyxdin
55199 
55200 C...Double precision and integer declarations.
55201  IMPLICIT DOUBLE PRECISION(a-h, o-z)
55202  IMPLICIT INTEGER(i-n)
55203  INTEGER pyk,pychge,pycomp
55204 C...Commonblocks.
55205  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
55206  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
55207  common/pysubs/msel,mselpd,msub(500),kfin(2,-40:40),ckin(200)
55208 C...UED Pythia common
55209  common/pypued/iued(0:99),rued(0:99)
55210 
55211 C...SAVE statements
55212  SAVE /pydat1/,/pydat3/,/pysubs/,/pypued/
55213 
55214 C...Print out some info about the UED model
55215  WRITE(mstu(11),7000)
55216  & ' ',
55217  & '********** PYXDIN: initialization of UED ******************',
55218  & ' ',
55219  & 'Universal Extra Dimensions (UED) switched on ',
55220  & ' ',
55221  & 'This implementation is courtesy of',
55222  & ' M.Elkacimi, D.Goujdami, H.Przysiezniak, ',
55223  & ' see [hep-ph/0602198] (Les Houches 2005) ',
55224  & ' ',
55225  & 'The model follows [hep-ph/0012100] (Appelquist, Cheng, ',
55226  & 'Dobrescu), with gravity-mediated decay widths calculated in',
55227  & '[hep-ph/0001335] (DeRujula, Donini, Gavela, Rigolin) and ',
55228  & 'radiative corrections to the KK masses from [hep/ph0204342]',
55229  & '(Cheng, Matchev, Schmaltz).'
55230  WRITE(mstu(11),7000)
55231  & ' ',
55232  & 'SM particles can propagate into one small extra dimension ',
55233  & 'of size 1/R = RUED(1) GeV. For gravity-mediated decays, the',
55234  & 'graviton is further allowed to propagate into N = IUED(4)',
55235  & 'large (eV^-1) extra dimensions.'
55236  WRITE(mstu(11),7000)
55237  & ' ',
55238  & 'The switches and parameters for UED are:',
55239  & ' IUED(1): (D=0) main UED ON(=1)/OFF(=0) switch ',
55240  & ' IUED(2): (D=0) Grav. med. decays are set ON(=1)/OFF(=0)',
55241  & ' IUED(3): (D=5) number of quark flavours',
55242  & ' IUED(4): (D=6) number of large extra dimensions into',
55243  & ' which the graviton propagates',
55244  & ' IUED(5): (D=0) Lambda (=0) or Lambda*R (=1) is used',
55245  & ' IUED(6): (D=1) With/without rad.corrs. (=1/0)',
55246  & ' ',
55247  & ' RUED(1): (D=1000.) curvature 1/R of the UED (in GeV)',
55248  & ' RUED(2): (D=5000.) gravity mediated (GM) scale (in GeV)',
55249  & ' RUED(3): (D=20000.) Lambda cutoff scale (in GeV). Used',
55250  & ' when IUED(5)=0',
55251  & ' RUED(4): (D=20.) Lambda*R. Used when IUED(5)=1'
55252  WRITE(mstu(11),7000)
55253  & ' ',
55254  & 'N.B.: the Higgs mass is also a free parameter of the UED ',
55255  & 'model, but is set through pmas(25,1).',
55256  & ' '
55257 
55258 C...Hardcoded switch, required by current implementation
55259  CALL pygive('MSTP(42)=0')
55260 
55261 C...Turn the gravity mediated decay (for the KK pphoton) ON or OFF
55262  IF(iued(2).EQ.0) CALL pygive('MDCY(C5100022,1)=0')
55263 
55264 C...Calculated the radiative corrections to the KK particle masses
55265  CALL pyuedc
55266 
55267 C...Initialize the graviton mass
55268 C...only if the KK particles decays gravitationally
55269  IF(iued(2).EQ.1) CALL pygram(0)
55270 
55271  WRITE(mstu(11),7000)
55272  & '********** PYXDIN: UED initialization completed ***********'
55273 
55274 C...Format to use for comments
55275  7000 FORMAT(' * ',a)
55276 
55277  RETURN
55278  END
55279 C*********************************************************************
55280 
55281 C...PYUEDC
55282 C...Auxiliary to PYXDIN
55283 C...Mass kk states radiative corrections
55284 C...Radiative corrections are included (hep/ph0204342)
55285 
55286  SUBROUTINE pyuedc
55287 
55288 C...Double precision and integer declarations.
55289  IMPLICIT DOUBLE PRECISION(a-h, o-z)
55290  IMPLICIT INTEGER(i-n)
55291  INTEGER pyk,pychge,pycomp
55292 
55293  parameter(kkpart=25,kkfla=450)
55294 
55295 C...UED Pythia common
55296  common/pypued/iued(0:99),rued(0:99)
55297 C...Pythia common: particles properties
55298  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
55299 C...Parameters.
55300  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
55301 C...Decay information.
55302  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
55303 C...Resonance width and secondary decay treatment.
55304  common/pyint4/mwid(500),wids(500,5)
55305  common/pypars/mstp(200),parp(200),msti(200),pari(200)
55306 
55307 C...Local variables
55308  DOUBLE PRECISION pi,qup,qdw
55309  DOUBLE PRECISION wdtp,wdte
55310  dimension wdtp(0:400),wdte(0:400,0:5)
55311  DOUBLE PRECISION q2,alphem,alphs,sw2,cw2,rmkk,rmkk2,zeta3
55312  DOUBLE PRECISION dsmg2,loglam,dbmg2
55313  DOUBLE PRECISION dbmqu,dbmqd,dbmqdo,dbmldo,dbmle
55314  DOUBLE PRECISION dsma2,dsmb2,dbma2,dbmb2
55315  DOUBLE PRECISION rfact,rmw,rmz,rmz2,rmw2,a,b,c,sqrdel,dmb2,dma2
55316  DOUBLE PRECISION sww1,cww1
55317  DOUBLE PRECISION rmgst,rmphst,rmzst,rmwst
55318  DOUBLE PRECISION rmdqst,rmsqus,rmsqds,rmlsld,rmlsle
55319  DOUBLE PRECISION sw21,cw21,sw021,cw021
55320  common/sw1/sw021,cw021
55321 C...UED related declarations:
55322 C...equivalences between ordered particles (451->475)
55323 C...and UED particle code (5 000 000 + id)
55324  dimension iuedeq(475)
55325  DATA (iuedeq(i),i=451,475)/
55326 C...Singlet quarks
55327  & 6100001,6100002,6100003,6100004,6100005,6100006,
55328 C...Doublet quarks
55329  & 5100001,5100002,5100003,5100004,5100005,5100006,
55330 C...Singlet leptons
55331  & 6100011,6100013,6100015,
55332 C...Doublet leptons
55333  & 5100012,5100011,5100014,5100013,5100016,5100015,
55334 C...Gauge boson KK excitations
55335  & 5100021,5100022,5100023,5100024/
55336 
55337 C...N.B. rinv=rued(1)
55338  IF(rued(1).LE.0.)THEN
55339  WRITE(mstu(11),*) 'PYUEDC: RINV < 0 : ',rued(1)
55340  WRITE(mstu(11),*) 'DEFAULT KK STATE MASSES ARE TAKEN '
55341  RETURN
55342  ENDIF
55343 
55344  pi=dacos(-1.d0)
55345  rmz = pmas(23,1)
55346  rmz2 = rmz**2
55347  rmw = pmas(24,1)
55348  rmw2 = rmw**2
55349  alphem = paru(101)
55350  qup = 2./3.
55351  qdw = -1./3.
55352 
55353 c...qt is q-tilde, qs is q-star
55354 c...strong coupling value
55355  q2 = rued(1)**2
55356  alphs=pyalps(q2)
55357 
55358 c...weak mixing angle
55359  sw2=paru(102)
55360  cw2=1d0-paru(102)
55361 
55362 c...for the mass corrections
55363  rmkk = rued(1)
55364  rmkk2 = rmkk**2
55365  zeta3= 1.2
55366 
55367 C... Either fix the cutoff scale LAMUED
55368  IF(iued(5).EQ.0)THEN
55369  loglam = dlog((rued(3)*(1./rued(1)))**2)
55370 C... or the ratio LAMUED/RINV (=product Lambda*R)
55371  ELSEIF(iued(5).EQ.1)THEN
55372  loglam = dlog(rued(4)**2)
55373  ELSE
55374  WRITE(mstu(11),*) '(PYUEDC:) INVALID VALUE FOR IUED(5)'
55375  CALL pystop(6000)
55376  ENDIF
55377 
55378 C...Calculate the radiative corrections for the UED KK masses
55379  IF(iued(6).EQ.1)THEN
55380  rfact=1.d0
55381 C...or induce a minute mass difference
55382 C...keeping the UED KK mass values nearly equal to 1/R
55383  ELSEIF(iued(6).EQ.0)THEN
55384  rfact=0.01d0
55385  ELSE
55386  WRITE(mstu(11),*) '(PYUEDC:) INVALID VALUE FOR IUED(6)'
55387  CALL pystop(6001)
55388  ENDIF
55389 
55390 c...Take into account only the strong interactions:
55391 
55392 c...The space bulk corrections :
55393  dsmg2 = rmkk2*(-1.5)*(alphs/4./pi)*zeta3/pi**2
55394 c...The boundary terms:
55395  dbmg2 = rmkk2*(23./2.)*(alphs/4./pi)*loglam
55396 
55397 c...Mass corrections for fermions are extracted from
55398 c...Phys. Rev. D66 036005(2002)9
55399  dbmqdo=rmkk*(3.*(alphs/4./pi)+27./16.*(alphem/4./pi/sw2)
55400  . +1./16.*(alphem/4./pi/cw2))*loglam
55401  dbmqu=rmkk*(3.*(alphs/4./pi)
55402  . +(alphem/4./pi/cw2))*loglam
55403  dbmqd=rmkk*(3.*(alphs/4./pi)
55404  . +0.25*(alphem/4./pi/cw2))*loglam
55405 
55406  dbmldo=rmkk *((27./16.)*(alphem/4./pi/sw2)+9./16.*
55407  . (alphem/4./pi/cw2))*loglam
55408  dbmle=rmkk *(9./4.*(alphem/4./pi/cw2))*loglam
55409 
55410 c...Vector boson masss matrix diagonalization
55411  dbmb2 = rmkk2*(-1./6.)*(alphem/4./pi/cw2)*loglam
55412  dsmb2 = rmkk2*(-39./2.)*(alphem/4./pi**3/cw2)*zeta3
55413  dbma2 = rmkk2*(15./2.)*(alphem/4./pi/sw2)*loglam
55414  dsma2 = rmkk2*(-5./2.)*(alphem/4./pi**3/sw2)*zeta3
55415 
55416 c...Elements of the mass matrix
55417  a = rmz2*sw2 + dbmb2 + dsmb2
55418  b = rmz2*cw2 + dbma2 + dsma2
55419  c = rmz2*dsqrt(sw2*cw2)
55420  sqrdel = dsqrt( (a-b)**2 + 4*c**2 )
55421 
55422 c...Eigenvalues: corrections to X1 and Z1 masses
55423  dmb2 = (a+b-sqrdel)/2.
55424  dma2 = (a+b+sqrdel)/2.
55425 
55426 c...Rotation angles
55427  sww1 = 2*c
55428  cww1 = a-b-sqrdel
55429 C...Weinberg angle
55430  sw21= sww1**2/(sww1**2 + cww1**2)
55431  cw21= 1. - sw21
55432 
55433  sw021=sw21
55434  cw021=cw21
55435 
55436 c...Masses:
55437  rmgst = rmkk+rfact*(dsqrt(rmkk2 + dsmg2 + dbmg2)-rmkk)
55438 
55439  rmdqst=rmkk+rfact*dbmqdo
55440  rmsqus=rmkk+rfact*dbmqu
55441  rmsqds=rmkk+rfact*dbmqd
55442 
55443 C...Note: MZ mass is included in ma2
55444  rmphst= rmkk+rfact*(dsqrt(rmkk2 + dmb2)-rmkk)
55445  rmzst = rmkk+rfact*(dsqrt(rmkk2 + dma2)-rmkk)
55446  rmwst = rmkk+rfact*(dsqrt(rmkk2 + dbma2 + dsma2 + rmw**2)-rmkk)
55447 
55448  rmlsld=rmkk+rfact*dbmldo
55449  rmlsle=rmkk+rfact*dbmle
55450 
55451  DO 100 ipart=1,5,2
55452  pmas(kkfla+ipart,1)=rmsqds
55453  100 CONTINUE
55454  DO 110 ipart=2,6,2
55455  pmas(kkfla+ipart,1)=rmsqus
55456  110 CONTINUE
55457  DO 120 ipart=7,12
55458  pmas(kkfla+ipart,1)=rmdqst
55459  120 CONTINUE
55460  DO 130 ipart=13,15
55461  pmas(kkfla+ipart,1)=rmlsle
55462  130 CONTINUE
55463  DO 140 ipart=16,21
55464  pmas(kkfla+ipart,1)=rmlsld
55465  140 CONTINUE
55466  pmas(kkfla+22,1)=rmgst
55467  pmas(kkfla+23,1)=rmphst
55468  pmas(kkfla+24,1)=rmzst
55469  pmas(kkfla+25,1)=rmwst
55470 
55471  WRITE(mstu(11),7000) ' PYUEDC: ',
55472  & 'UED Mass Spectrum (GeV) :'
55473  WRITE(mstu(11),7100) ' m(d*_S,s*_S,b*_S) = ',rmsqds
55474  WRITE(mstu(11),7100) ' m(u*_S,c*_S,t*_S) = ',rmsqus
55475  WRITE(mstu(11),7100) ' m(q*_D) = ',rmdqst
55476  WRITE(mstu(11),7100) ' m(l*_S) = ',rmlsle
55477  WRITE(mstu(11),7100) ' m(l*_D) = ',rmlsld
55478  WRITE(mstu(11),7100) ' m(g*) = ',rmgst
55479  WRITE(mstu(11),7100) ' m(gamma*) = ',rmphst
55480  WRITE(mstu(11),7100) ' m(Z*) = ',rmzst
55481  WRITE(mstu(11),7100) ' m(W*) = ',rmwst
55482  WRITE(mstu(11),7000) ' '
55483 
55484 C...Initialize widths, branching ratios and life time
55485  DO 199 ipart=1,25
55486  kc=kkfla+ipart
55487  IF(mwid(kc).EQ.1.AND.mdcy(kc,1).EQ.1)THEN
55488  CALL pywidt(iuedeq(kc),pmas(kc,1)**2,wdtp,wdte)
55489  IF(wdtp(0).LE.0)THEN
55490  WRITE(mstu(11),*)
55491  + 'PYUEDC WARNING: TOTAL WIDTH = 0 --> KC ', kc
55492  WRITE(mstu(11),*) 'INITIAL VALUE IS TAKEN',pmas(kc,2)
55493  goto 199
55494  ELSE
55495  DO 180 idc=1,mdcy(kc,3)
55496  ic=idc+mdcy(kc,2)-1
55497  IF(mdme(ic,1).EQ.1.AND.wdtp(idc).GT.0.)THEN
55498 C...Life time in cm^{-1}. paru(3) gev^{-1} -> fm
55499  pmas(kc,4)=paru(3)/wdtp(idc)*1.d-12
55500  brat(ic)=wdtp(idc)/wdtp(0)
55501  ENDIF
55502  180 CONTINUE
55503  ENDIF
55504  ENDIF
55505  199 CONTINUE
55506 
55507 C...Format to use for comments
55508  7000 FORMAT(' * ',a)
55509  7100 FORMAT(' * ',a,f12.3)
55510 
55511  END
55512 C********************************************************************
55513 C...PYXUED
55514 C... Last change:
55515 C... 13/01/2009 : H. Przysiezniak Frey, P. Skands
55516 C... Original version:
55517 C... M. El Kacimi
55518 C... 05/07/2005
55519 C Universal Extra Dimensions Subprocess cross sections
55520 C The expressions used are from atl-com-phys-2005-003
55521 C What is coded here is shat**2/pi * dsigma/dt = |M|**2
55522 C For each UED subprocess, the color flow used is the same
55523 C as the equivalent QCD subprocess. Different configuration
55524 C color flows are considered to have the same probability.
55525 C
55526 C The Xsection is calculated following ATL-PHYS-PUB-2005-003
55527 C by G.Azuelos and P.H.Beauchemin.
55528 C
55529 C This routine is called from pysigh.
55530 
55531  SUBROUTINE pyxued(NCHN,SIGS)
55532 
55533 C...Double precision and integer declarations
55534  IMPLICIT DOUBLE PRECISION(a-h, o-z)
55535  IMPLICIT INTEGER(i-n)
55536 C...
55537  INTEGER ngrdec
55538  common/decmod/ngrdec
55539 C...
55540  parameter(kkpart=25,kkfla=450)
55541 C...Commonblocks
55542  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
55543  common/pypars/mstp(200),parp(200),msti(200),pari(200)
55544  common/pyint1/mint(400),vint(400)
55545  common/pyint3/xsfx(2,-40:40),isig(1000,3),sigh(1000)
55546  common/pysgcm/isub,isubsv,mmin1,mmax1,mmin2,mmax2,mmina,mmaxa,
55547  &kfac(2,-40:40),comfac,fack,faca,sh,th,uh,sh2,th2,uh2,sqm3,sqm4,
55548  &shr,sqpth,taup,be34,cth,x(2),sqmz,sqmw,gmmz,gmmw,
55549  &aem,as,xw,xw1,xwc,xwv,poll,polr,polll,polrr
55550  SAVE /pydat2/,/pyint1/,/pyint3/,/pypars/
55551 C...UED Pythia common
55552  common/pypued/iued(0:99),rued(0:99)
55553 C...Local arrays and complex variables
55554  DOUBLE PRECISION shat,sp,that,tp,uhat,up,alphas
55555  + ,fac1,xmnkk,xmued,sigs
55556  INTEGER nchn
55557 
55558 C...Return if UED not switched on
55559  IF (iued(1).LE.0) THEN
55560  RETURN
55561  ENDIF
55562 
55563 C...Energy scale of the parton processus
55564 C...taken equal to the mass of the final state kk
55565 c Q2=XMNKK**2
55566 
55567 C...Default Mandlestam variable (u/t)hatp=(u/t)hatp-xmnkk**2
55568  xmnkk=pmas(kkfla+23,1)
55569 
55570 C...To compare the cross section with phys-pub-2005-03
55571 C...(no radiative corrections),
55572 C...take xmnkk=rinv and q2=rinv**2
55573 c++lnk
55574 C...n.b. (rinv=rued(1))
55575 c IF(NGRDEC.EQ.1)XMNKK=RUED(0)
55576  IF(ngrdec.EQ.1)xmnkk=rued(1)
55577 c--lnk
55578 
55579  shat=vint(44)
55580  sp=shat
55581  that=vint(45)
55582  tp=that-xmnkk**2
55583  uhat=vint(46)
55584  up=uhat-xmnkk**2
55585  beta34=dsqrt(1.d0-4.d0*xmnkk**2/shat)
55586  pi=dacos(-1.d0)
55587 c++lnk
55588 c Q2=RUED(0)**2+(TP*UP-RUED(0)**4)/SP
55589  q2=rued(1)**2+(tp*up-rued(1)**4)/sp
55590 
55591 c IF(NGRDEC.EQ.1)Q2=RUED(0)**2
55592  IF(ngrdec.EQ.1)q2=rued(1)**2
55593 c--lnk
55594 
55595 C...Strong coupling value
55596  alphas=pyalps(q2)
55597 
55598  IF(isub.EQ.311)THEN
55599 C...gg --> g* g*
55600  fac1=9./8.*alphas**2/(sp*tp*up)**2
55601  xmued=fac1*(xmnkk**4*(6.*tp**4+18.*tp**3*up+
55602  & 24.*tp**2*up**2+18.*tp*up**3+6.*up**4)
55603  & +xmnkk**2*(6.*tp**4*up+12.*tp**3*up**2+
55604  & 12.*tp**2*up**3+6*tp*up**4)
55605  & +2.*tp**6+6*tp**5*up+13*tp**4*up**2+
55606  & 15.*tp**3*up**3+13*tp**2*up**4+
55607  & 6.*tp*up**5+2.*up**6)
55608  nchn=nchn+1
55609  isig(nchn,1)=21
55610  isig(nchn,2)=21
55611 C...Three color flow configurations (qcd g+g->g+g)
55612  xcol=pyr(0)
55613  IF(xcol.LE.1./3.)THEN
55614  isig(nchn,3)=1
55615  ELSEIF(xcol.LE.2./3.)THEN
55616  isig(nchn,3)=2
55617  ELSE
55618  isig(nchn,3)=3
55619  ENDIF
55620  sigh(nchn)=comfac*xmued
55621  ELSEIF(isub.EQ.312)THEN
55622 C...q + g -> q*_D + g*, q*_S + g*
55623 C...(the two channels have the same cross section)
55624  fac1=-1./36.*alphas**2/(sp*tp*up)**2
55625  xmued=fac1*(12.*sp*up**5+5.*sp**2*up**4+22.*sp**3*up**3+
55626  & 5.*sp**4*up**2+12.*sp**5*up)
55627  xmued=comfac*2.*xmued
55628 
55629  DO 190 i=mmina,mmaxa
55630  IF(i.EQ.0.OR.iabs(i).GT.10) goto 190
55631  DO 180 isde=1,2
55632 
55633  IF(isde.EQ.1.AND.kfac(1,i)*kfac(2,21).EQ.0) goto 180
55634  IF(isde.EQ.2.AND.kfac(1,21)*kfac(2,i).EQ.0) goto 180
55635  nchn=nchn+1
55636  isig(nchn,isde)=i
55637  isig(nchn,3-isde)=21
55638  isig(nchn,3)=1
55639  sigh(nchn)=xmued
55640  IF(pyr(0).GT.0.5)isig(nchn,3)=2
55641  180 CONTINUE
55642  190 CONTINUE
55643 
55644  ELSEIF(isub.EQ.313)THEN
55645 C...qi + qj -> q*_Di + q*_Dj, q*_Si + q*_Sj
55646 C...(the two channels have the same cross section)
55647 C...qi and qj have the same charge sign
55648  DO 100 i=mmin1,mmax1
55649  ia=iabs(i)
55650  IF(i.EQ.0.OR.ia.GT.mstp(58).OR.kfac(1,i).EQ.0) goto 100
55651  DO 101 j=mmin2,mmax2
55652  ja=iabs(j)
55653  IF(j.EQ.0.OR.ja.GT.mstp(58).OR.kfac(2,j).
55654  & eq.0) goto 101
55655  IF(j*i.LE.0)goto 101
55656  nchn=nchn+1
55657  isig(nchn,1)=i
55658  isig(nchn,2)=j
55659  IF(j.EQ.i)THEN
55660  fac1=1./72.*alphas**2/(tp*up)**2
55661  xmued=fac1*
55662  & (xmnkk**2*(8*tp**3+4./3.*tp**2*up+4./3.*tp*up**2
55663  & +8.*up**3)+8.*tp**4+56./3.*tp**3*up+
55664  & 20.*tp**2*up**2+56./3.*
55665  & tp*up**3+8.*up**4)
55666  sigh(nchn)=comfac*2.*xmued
55667  isig(nchn,3)=1
55668  IF(pyr(0).GT.0.5)isig(nchn,3)=2
55669  ELSE
55670  fac1=2./9.*alphas**2/tp**2
55671  xmued=fac1*(-xmnkk**2*sp+sp**2+0.25*tp**2)
55672  sigh(nchn)=comfac*2.*xmued
55673  isig(nchn,3)=1
55674  ENDIF
55675  101 CONTINUE
55676  100 CONTINUE
55677  ELSEIF(isub.EQ.314)THEN
55678 C...g + g -> q*_D + q*_Dbar, q*_S + q*_Sbar
55679 C...(the two channels have the same cross section)
55680  nchn=nchn+1
55681  isig(nchn,1)=21
55682  isig(nchn,2)=21
55683  isig(nchn,3)=int(1.5+pyr(0))
55684 
55685  fac1=5./6.*alphas**2/(sp*tp*up)**2
55686  xmued=fac1*(-xmnkk**4*(8.*tp*up**3+8.*tp**2*up**2+8.*tp**3*up
55687  + +4.*up**4+4*tp**4)
55688  + -xmnkk**2*(0.5*tp*up**4+4.*tp**2*up**3+15./2.*tp**3
55689  + *up**2+ 4.*tp**4*up)+tp*up**5-0.25*tp**2*up**4+
55690  + 2.*tp**3*up**3-0.25*tp**4*up**2+tp**5*up)
55691 
55692  sigh(nchn)=comfac*xmued
55693 C...has been multiplied by 5: all possible quark flavors in final state
55694 
55695  ELSEIF(isub.EQ.315)THEN
55696 C...q + qbar -> q*_D + q*_Dbar, q*_S + q*_Sbar
55697 C...(the two channels have the same cross section)
55698  DO 141 i=mmin1,mmax1
55699  IF(i.EQ.0.OR.iabs(i).GT.mstp(58).OR.
55700  & kfac(1,i)*kfac(2,-i).EQ.0) goto 141
55701  DO 142 j=mmin2,mmax2
55702  IF(j.EQ.0.OR.abs(i).NE.abs(j).OR.i*j.GE.0) goto 142
55703  fac1=2./9.*alphas**2*1./(sp*tp)**2
55704  xmued=fac1*(xmnkk**2*sp*(4.*tp**2-sp*tp-sp**2)+
55705  & 4.*tp**4+3.*sp*tp**3+11./12.*tp**2*sp**2-
55706  & 2./3.*sp**3*tp+sp**4)
55707  nchn=nchn+1
55708  isig(nchn,1)=i
55709  isig(nchn,2)=-i
55710  isig(nchn,3)=1
55711  sigh(nchn)=comfac*2.*xmued
55712  142 CONTINUE
55713  141 CONTINUE
55714  ELSEIF(isub.EQ.316)THEN
55715 C...q + qbar' -> q*_D + q*_Sbar'
55716  fac1=2./9.*alphas**2
55717  DO 300 i=mmin1,mmax1
55718  ia=iabs(i)
55719  IF(i.EQ.0.OR.ia.GT.mstp(58).OR.kfac(1,i).EQ.0) goto 300
55720  DO 301 j=mmin2,mmax2
55721  ja=iabs(j)
55722  IF(j.EQ.0.OR.ja.GT.mstp(58).OR.kfac(2,j).EQ.0) goto 301
55723  IF(j*i.GE.0.OR.ia.EQ.ja)goto 301
55724  nchn=nchn+1
55725  isig(nchn,1)=i
55726  isig(nchn,2)=j
55727  isig(nchn,3)=1
55728  fac1=2./9.*alphas**2/tp**2
55729  xmued=fac1*(-xmnkk**2*sp+sp**2+0.25*tp**2)
55730  sigh(nchn)=comfac*xmued
55731  301 CONTINUE
55732  300 CONTINUE
55733 
55734  ELSEIF(isub.EQ.317)THEN
55735 C...q + qbar' -> q*_D + q*_Dbar' , q*_S + q*_Sbar'
55736 C...(the two channels have the same cross section)
55737  DO 400 i=mmin1,mmax1
55738  ia=iabs(i)
55739  IF(i.EQ.0.OR.ia.GT.mstp(58).OR.kfac(1,i).EQ.0) goto 400
55740  DO 401 j=mmin1,mmax1
55741  ja=iabs(j)
55742  IF(j.EQ.0.OR.ja.GT.mstp(58).OR.kfac(2,j).EQ.0) goto 401
55743  IF(j*i.GE.0.OR.ia.EQ.ja)goto 401
55744  nchn=nchn+1
55745  isig(nchn,1)=i
55746  isig(nchn,2)=j
55747  isig(nchn,3)=1
55748  fac1=1./18.*alphas**2/tp**2
55749  xmued=fac1*(4.*xmnkk**2*sp+4.*sp**2+8.*sp*tp+5*tp**2)
55750  sigh(nchn)=comfac*2.*xmued
55751  401 CONTINUE
55752  400 CONTINUE
55753  ELSEIF(isub.EQ.318)THEN
55754 C...q + q' -> q*_D + q*_S'
55755  DO 500 i=mmin1,mmax1
55756  ia=iabs(i)
55757  IF(i.EQ.0.OR.ia.GT.mstp(58).OR.kfac(1,i).EQ.0) goto 500
55758  DO 501 j=mmin2,mmax2
55759  ja=iabs(j)
55760  IF(j.EQ.0.OR.ja.GT.mstp(58).OR.kfac(2,j).EQ.0) goto 501
55761  IF(j*i.LE.0)goto 501
55762  IF(ia.EQ.ja)THEN
55763  nchn=nchn+1
55764  isig(nchn,1)=i
55765  isig(nchn,2)=j
55766  isig(nchn,3)=int(1.5+pyr(0))
55767  fac1=1./36.*alphas**2/(tp*up)**2
55768  xmued=fac1*(-8.*xmnkk**2*(tp**3+tp**2*up+tp*up**2+up**3)
55769  & +8.*tp**4+4.*tp**2*up**2+8.*up**4)
55770  sigh(nchn)=comfac*xmued
55771  ELSE
55772  nchn=nchn+1
55773  isig(nchn,1)=i
55774  isig(nchn,2)=j
55775  isig(nchn,3)=1
55776  fac1=1./18.*alphas**2/tp**2
55777  xmued=fac1*(4.*xmnkk**2*sp+4.*sp**2+8.*sp*tp+5*tp**2)
55778  sigh(nchn)=comfac*2.*xmued
55779  ENDIF
55780  501 CONTINUE
55781  500 CONTINUE
55782  ELSEIF(isub.EQ.319)THEN
55783 C...q + qbar -> q*_D' +q*_Dbar' , q*_S' + q*_Sbar'
55784 C...(the two channels have the same cross section)
55785  DO 741 i=mmin1,mmax1
55786  IF(i.EQ.0.OR.iabs(i).GT.mstp(58).OR.
55787  & kfac(1,i)*kfac(2,-i).EQ.0) goto 741
55788  DO 742 j=mmin2,mmax2
55789  IF(j.EQ.0.OR.iabs(j).NE.iabs(i).OR.j*i.GT.0) goto 742
55790  fac1=16./9.*alphas**2*1./(sp)**2
55791  xmued=fac1*(2.*xmnkk**2*sp+sp**2+2.*sp*tp+2.*tp**2)
55792  nchn=nchn+1
55793  isig(nchn,1)=i
55794  isig(nchn,2)=-i
55795  isig(nchn,3)=1
55796  sigh(nchn)=comfac*2.*xmued
55797  742 CONTINUE
55798  741 CONTINUE
55799 
55800  ENDIF
55801 
55802  RETURN
55803  END
55804 C*********************************************************************
55805 
55806 C...PYGRAM
55807 C...Universal Extra Dimensions Model (UED)
55808 C...Computation of the Graviton mass.
55809 
55810  SUBROUTINE pygram(IN)
55811 
55812 C...Double precision and integer declarations
55813  IMPLICIT DOUBLE PRECISION(a-h, o-z)
55814  IMPLICIT INTEGER(i-n)
55815 
55816 C...Pythia commonblocks
55817  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
55818  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
55819 C...UED Pythia common
55820  common/pypued/iued(0:99),rued(0:99)
55821 
55822 C...Local variables
55823  INTEGER kcfla,nmax
55824  parameter(kcfla=450,nmax=5000)
55825  dimension yvec(5000),resvec(5000)
55826  common/intsav/ysav,ymax,resmax
55827  common/uedgra/xmplnk,xmd,rinv,ndim
55828  common/kappa/xkappa
55829 
55830 C...External function (used in call to PYGAUS)
55831  EXTERNAL pygraw
55832 
55833 C...SAVE statements
55834  SAVE /pydat1/,/pydat2/,/pypued/,/intsav/
55835 
55836 C...Initialization
55837  ndim=iued(4)
55838  rinv=rued(1)
55839  xmd=rued(2)
55840  pi=paru(1)
55841 
55842 C...Initialize for numerical integration
55843  xmplnk=2.4d+18
55844  xkappa=dsqrt(2.d0)/xmplnk
55845 
55846 C...For NDIM=2, compute graviton mass distribution numerically
55847  IF(ndim.EQ.2)THEN
55848 
55849 C... For first event: tabulate distribution of stepwise integrals:
55850 C... int_y1^y2 dy dGamma/dy , with y = MG*/MgammaKK
55851  IF(in.EQ.0)THEN
55852  resmax = 0d0
55853  ymax = 0d0
55854  DO 100 i=1,nmax
55855  ysav = (i-0.5)/dble(nmax)
55856  tol = 1d-6
55857 C...Integral of PYGRAW from 0 to 1, with precision TOL, for given YSAV
55858  resint = pygaus(pygraw,0d0,1d0,tol)
55859  yvec(i) = ysav
55860  resvec(i) = resint
55861 C... Save max of distribution (for accept/reject below)
55862  IF(resint.GT.resmax)THEN
55863  resmax = resint
55864  ymax = yvec(i)
55865  ENDIF
55866  100 CONTINUE
55867  ENDIF
55868 
55869 C... Generate Mg for each graviton (1D0 ensures a minimal open phase space)
55870  pcujet=1d0
55871  kcgakk=kcfla+23
55872  xmgamk=pmas(kcgakk,1)
55873 
55874 C... Pick random graviton mass, accept according to stored integrals
55875  ammax=dsqrt(xmgamk**2-2d0*xmgamk*pcujet)
55876  110 rmg=ammax*pyr(0)
55877  x=rmg/xmgamk
55878 
55879 C... Bin enumeration starts at 1, but make sure always in range
55880  ibin=int(nmax*x)+1
55881  ibin=min(ibin,nmax)
55882  IF(resvec(ibin)/resmax.LT.pyr(0)) goto 110
55883 
55884 C... For NDIM=4 and 6, the analytical expression for the
55885 C... graviton mass distribution integral is used.
55886  ELSEIF(ndim.EQ.4.OR.ndim.EQ.6)THEN
55887 
55888 C... Ensure minimal open phase space (max(mG*) < m(gamma*))
55889  pcujet=1d0
55890 
55891 C... KK photon (?) compressed code and mass
55892  kcgakk=kcfla+23
55893  xmgamk=pmas(kcgakk,1)
55894 
55895 C... Find maximum of (dGamma/dMg)
55896  IF(in.EQ.0)THEN
55897  resmax=0d0
55898  ymax=0d0
55899  DO 120 i=1,nmax-1
55900  y=i/dble(nmax)
55901  resint=y**(ndim-3)*(1d0/(1d0-y**2))*(1d0+dcos(pi*y))
55902  IF(resint.GE.resmax)THEN
55903  resmax=resint
55904  ymax=y
55905  ENDIF
55906  120 CONTINUE
55907  ENDIF
55908 
55909 C... Pick random graviton mass, accept/reject
55910  ammax=dsqrt(xmgamk**2-2d0*xmgamk*pcujet)
55911  130 rmg=ammax*pyr(0)
55912  x=rmg/xmgamk
55913  dgadmg=x**(ndim-3)*(1./(1.-x**2))*(1.+dcos(pi*x))
55914  IF(dgadmg/resmax.LT.pyr(0)) goto 130
55915 
55916 C... If the user has not chosen N=2,4 or 6, STOP
55917  ELSE
55918  WRITE(mstu(11),*) '(PYGRAM:) BAD VALUE N(LARGE XD) =',ndim,
55919  & ' (MUST BE 2, 4, OR 6) '
55920  CALL pystop(6002)
55921  ENDIF
55922 
55923 C... Now store the sampled Mg
55924  pmas(39,1)=rmg
55925 
55926  RETURN
55927  END
55928 
55929 C*********************************************************************
55930 
55931 C...PYGRAW
55932 C...Universal Extra Dimensions Model (UED)
55933 C...
55934 C...See Macesanu etal. hep-ph/0201300 eqns.31 and 34.
55935 C...
55936 C...Integrand for the KK boson -> SM boson + graviton
55937 C...graviton mass distribution (and gravity mediated total width),
55938 C...which contains (see 0201300 and below for the full product)
55939 C...the gravity mediated partial decay width Gamma(xx, yy)
55940 C... i.e. GRADEN(YY)*PYWDKK(XXA)
55941 C... where xx is exclusive to gravity
55942 C... yy=m_Graviton/m_bosonKK denotes the Universal extra dimension
55943 C... and xxa=sqrt(xx**2+yy**2) refers to all of the extra dimensions.
55944 
55945  DOUBLE PRECISION FUNCTION pygraw(YIN)
55946 
55947 C...Double precision and integer declarations
55948  IMPLICIT DOUBLE PRECISION (a-h,o-z)
55949  IMPLICIT integer(i-n)
55950 
55951 C...Pythia commonblocks
55952  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
55953 
55954 C...Local UED commonblocks and variables
55955  common/uedgra/xmplnk,xmd,rinv,ndim
55956  common/intsav/ysav,ymax,resmax
55957 
55958 C...SAVE statements
55959  SAVE /pydat1/,/intsav/
55960 
55961 C...External: Pythia's Gamma function
55962  EXTERNAL pygamm
55963 
55964 C...Pi
55965  pi=paru(1)
55966  pi2=pi*pi
55967 
55968  ymin=1.d-9/rinv
55969  yy=ysav
55970  xx=dsqrt(1.-yy**2)*yin
55971  djac=(1.-ymin)*dsqrt(1.-yy**2)
55972  fac=2.*pi**((ndim-1.)/2.)*xmplnk**2*rinv**ndim/xmd**(ndim+2)
55973  xnd=(ndim-1.)/2.
55974  gammn=pygamm(xnd)
55975  fac=fac/gammn
55976  xxa=dsqrt(xx**2+yy**2)
55977  graden=4./pi2 * (yy**2/(1.-yy**2)**2)*(1.+dcos(pi*yy))
55978 
55979  pygraw=djac*
55980  + fac*xx**(ndim-2)*graden*pywdkk(xxa)
55981 
55982  RETURN
55983  END
55984 C*********************************************************************
55985 
55986 C...PYWDKK
55987 C...Universal Extra Dimensions Model (UED)
55988 C...
55989 C...Multiplied by the square modulus of a form factor
55990 C...(see GRADEN in function PYGRAW)
55991 C...PYWDKK is the KK boson -> SM boson + graviton
55992 C...gravity mediated partial decay width Gamma(xx, yy)
55993 C... where xx is exclusive to gravity
55994 C... yy=m_Graviton/m_bosonKK denotes the Universal extra dimension
55995 C... and xxa=sqrt(xx**2+yy**2) refers to all of the extra dimensions
55996 C...
55997 C...N.B. The Feynman rules for the couplings of the graviton fields
55998 C...to the UED fields are related to the corresponding couplings of
55999 C...the graviton fields to the SM fields by the form factor.
56000 
56001  DOUBLE PRECISION FUNCTION pywdkk(X)
56002 
56003 C...Double precision and integer declarations
56004  IMPLICIT DOUBLE PRECISION (a-h,o-z)
56005  IMPLICIT integer(i-n)
56006 
56007 C...Pythia commonblocks
56008  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
56009  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
56010 
56011 C...Local UED commonblocks and variables
56012  common/uedgra/xmplnk,xmd,rinv,ndim
56013  common/kappa/xkappa
56014 
56015 C...SAVE statements
56016  SAVE /pydat1/,/pydat2/,/uedgra/,/kappa/
56017 
56018  pi=paru(1)
56019 
56020 C...gamma* mass 473
56021  kcqkk=473
56022  xmnkk=pmas(kcqkk,1)
56023 
56024 C...Bosons partial width Macesanu hep-ph/0201300
56025  pywdkk=xkappa**2/(96.*pi)*xmnkk**3/x**4*
56026  + ((1.-x**2)**2*(1.+3.*x**2+6.*x**4))
56027 
56028  RETURN
56029  END
56030 
56031 C*********************************************************************
56032 
56033 C...PYEIGC
56034 C...Finds eigenvalues of a general complex matrix
56035 C
56036 C THIS SUBROUTINE CALLS THE RECOMMENDED SEQUENCE OF
56037 C SUBROUTINES FROM THE EIGENSYSTEM SUBROUTINE PACKAGE (EISPACK)
56038 C TO FIND THE EIGENVALUES AND EIGENVECTORS (IF DESIRED)
56039 C OF A COMPLEX GENERAL MATRIX.
56040 C
56041 C ON INPUT
56042 C
56043 C NM MUST BE SET TO THE ROW DIMENSION OF THE TWO-DIMENSIONAL
56044 C ARRAY PARAMETERS AS DECLARED IN THE CALLING PROGRAM
56045 C DIMENSION STATEMENT.
56046 C
56047 C N IS THE ORDER OF THE MATRIX A=(AR,AI).
56048 C
56049 C AR AND AI CONTAIN THE REAL AND IMAGINARY PARTS,
56050 C RESPECTIVELY, OF THE COMPLEX GENERAL MATRIX.
56051 C
56052 C MATZ IS AN INTEGER VARIABLE SET EQUAL TO ZERO IF
56053 C ONLY EIGENVALUES ARE DESIRED. OTHERWISE IT IS SET TO
56054 C ANY NON-ZERO INTEGER FOR BOTH EIGENVALUES AND EIGENVECTORS.
56055 C
56056 C ON OUTPUT
56057 C
56058 C WR AND WI CONTAIN THE REAL AND IMAGINARY PARTS,
56059 C RESPECTIVELY, OF THE EIGENVALUES.
56060 C
56061 C ZR AND ZI CONTAIN THE REAL AND IMAGINARY PARTS,
56062 C RESPECTIVELY, OF THE EIGENVECTORS IF MATZ IS NOT ZERO.
56063 C
56064 C IERR IS AN INTEGER OUTPUT VARIABLE SET EQUAL TO AN ERROR
56065 C COMPLETION CODE DESCRIBED IN THE DOCUMENTATION FOR COMQR
56066 C AND COMQR2. THE NORMAL COMPLETION CODE IS ZERO.
56067 C
56068 C FV1, FV2, AND FV3 ARE TEMPORARY STORAGE ARRAYS.
56069 C
56070 C QUESTIONS AND COMMENTS SHOULD BE DIRECTED TO BURTON S. GARBOW,
56071 C MATHEMATICS AND COMPUTER SCIENCE DIV, ARGONNE NATIONAL LABORATORY
56072 C
56073 C THIS VERSION DATED AUGUST 1983.
56074 C
56075 
56076  SUBROUTINE pyeicg(NM,N,AR,AI,WR,WI,MATZ,ZR,ZI,FV1,FV2,FV3,IERR)
56077 
56078  INTEGER n,nm,is1,is2,ierr,matz
56079  DOUBLE PRECISION ar(5,5),ai(5,5),wr(5),wi(5),zr(5,5),zi(5,5),
56080  x fv1(5),fv2(5),fv3(5)
56081  IF (n .LE. nm) goto 100
56082  ierr = 10 * n
56083  goto 120
56084 C
56085  100 CALL pycbal(nm,n,ar,ai,is1,is2,fv1)
56086  CALL pycrth(nm,n,is1,is2,ar,ai,fv2,fv3)
56087  IF (matz .NE. 0) goto 110
56088 C .......... FIND EIGENVALUES ONLY ..........
56089  CALL pycmqr(nm,n,is1,is2,ar,ai,wr,wi,ierr)
56090  goto 120
56091 C .......... FIND BOTH EIGENVALUES AND EIGENVECTORS ..........
56092  110 CALL pycmq2(nm,n,is1,is2,fv2,fv3,ar,ai,wr,wi,zr,zi,ierr)
56093  IF (ierr .NE. 0) goto 120
56094  CALL pycba2(nm,n,is1,is2,fv1,n,zr,zi)
56095  120 RETURN
56096  END
56097 
56098 C*********************************************************************
56099 
56100 C...PYCMQR
56101 C...Auxiliary to PYEICG.
56102 C
56103 C THIS SUBROUTINE IS A TRANSLATION OF A UNITARY ANALOGUE OF THE
56104 C ALGOL PROCEDURE COMLR, NUM. MATH. 12, 369-376(1968) BY MARTIN
56105 C AND WILKINSON.
56106 C HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 396-403(1971).
56107 C THE UNITARY ANALOGUE SUBSTITUTES THE QR ALGORITHM OF FRANCIS
56108 C (COMP. JOUR. 4, 332-345(1962)) FOR THE LR ALGORITHM.
56109 C
56110 C THIS SUBROUTINE FINDS THE EIGENVALUES OF A COMPLEX
56111 C UPPER HESSENBERG MATRIX BY THE QR METHOD.
56112 C
56113 C ON INPUT
56114 C
56115 C NM MUST BE SET TO THE ROW DIMENSION OF TWO-DIMENSIONAL
56116 C ARRAY PARAMETERS AS DECLARED IN THE CALLING PROGRAM
56117 C DIMENSION STATEMENT.
56118 C
56119 C N IS THE ORDER OF THE MATRIX.
56120 C
56121 C LOW AND IGH ARE INTEGERS DETERMINED BY THE BALANCING
56122 C SUBROUTINE CBAL. IF CBAL HAS NOT BEEN USED,
56123 C SET LOW=1, IGH=N.
56124 C
56125 C HR AND HI CONTAIN THE REAL AND IMAGINARY PARTS,
56126 C RESPECTIVELY, OF THE COMPLEX UPPER HESSENBERG MATRIX.
56127 C THEIR LOWER TRIANGLES BELOW THE SUBDIAGONAL CONTAIN
56128 C INFORMATION ABOUT THE UNITARY TRANSFORMATIONS USED IN
56129 C THE REDUCTION BY CORTH, IF PERFORMED.
56130 C
56131 C ON OUTPUT
56132 C
56133 C THE UPPER HESSENBERG PORTIONS OF HR AND HI HAVE BEEN
56134 C DESTROYED. THEREFORE, THEY MUST BE SAVED BEFORE
56135 C CALLING COMQR IF SUBSEQUENT CALCULATION OF
56136 C EIGENVECTORS IS TO BE PERFORMED.
56137 C
56138 C WR AND WI CONTAIN THE REAL AND IMAGINARY PARTS,
56139 C RESPECTIVELY, OF THE EIGENVALUES. IF AN ERROR
56140 C EXIT IS MADE, THE EIGENVALUES SHOULD BE CORRECT
56141 C FOR INDICES IERR+1,...,N.
56142 C
56143 C IERR IS SET TO
56144 C ZERO FOR NORMAL RETURN,
56145 C J IF THE LIMIT OF 30*N ITERATIONS IS EXHAUSTED
56146 C WHILE THE J-TH EIGENVALUE IS BEING SOUGHT.
56147 C
56148 C CALLS PYCDIV FOR COMPLEX DIVISION.
56149 C CALLS PYCSRT FOR COMPLEX SQUARE ROOT.
56150 C CALLS PYTHAG FOR DSQRT(A*A + B*B) .
56151 C
56152 C QUESTIONS AND COMMENTS SHOULD BE DIRECTED TO BURTON S. GARBOW,
56153 C MATHEMATICS AND COMPUTER SCIENCE DIV, ARGONNE NATIONAL LABORATORY
56154 C
56155 C THIS VERSION DATED AUGUST 1983.
56156 C
56157 
56158  SUBROUTINE pycmqr(NM,N,LOW,IGH,HR,HI,WR,WI,IERR)
56159 
56160  INTEGER i,j,l,n,en,ll,nm,igh,itn,its,low,lp1,enm1,ierr
56161  DOUBLE PRECISION hr(5,5),hi(5,5),wr(5),wi(5)
56162  DOUBLE PRECISION si,sr,ti,tr,xi,xr,yi,yr,zzi,zzr,norm,tst1,tst2,
56163  x pythag
56164 
56165  ierr = 0
56166  IF (low .EQ. igh) goto 130
56167 C .......... CREATE REAL SUBDIAGONAL ELEMENTS ..........
56168  l = low + 1
56169 C
56170  DO 120 i = l, igh
56171  ll = min0(i+1,igh)
56172  IF (hi(i,i-1) .EQ. 0.0d0) goto 120
56173  norm = pythag(hr(i,i-1),hi(i,i-1))
56174  yr = hr(i,i-1) / norm
56175  yi = hi(i,i-1) / norm
56176  hr(i,i-1) = norm
56177  hi(i,i-1) = 0.0d0
56178 C
56179  DO 100 j = i, igh
56180  si = yr * hi(i,j) - yi * hr(i,j)
56181  hr(i,j) = yr * hr(i,j) + yi * hi(i,j)
56182  hi(i,j) = si
56183  100 CONTINUE
56184 C
56185  DO 110 j = low, ll
56186  si = yr * hi(j,i) + yi * hr(j,i)
56187  hr(j,i) = yr * hr(j,i) - yi * hi(j,i)
56188  hi(j,i) = si
56189  110 CONTINUE
56190 C
56191  120 CONTINUE
56192 C .......... STORE ROOTS ISOLATED BY CBAL ..........
56193  130 DO 140 i = 1, n
56194  IF (i .GE. low .AND. i .LE. igh) goto 140
56195  wr(i) = hr(i,i)
56196  wi(i) = hi(i,i)
56197  140 CONTINUE
56198 C
56199  en = igh
56200  tr = 0.0d0
56201  ti = 0.0d0
56202  itn = 30*n
56203 C .......... SEARCH FOR NEXT EIGENVALUE ..........
56204  150 IF (en .LT. low) goto 320
56205  its = 0
56206  enm1 = en - 1
56207 C .......... LOOK FOR SINGLE SMALL SUB-DIAGONAL ELEMENT
56208 C FOR L=EN STEP -1 UNTIL LOW D0 -- ..........
56209  160 DO 170 ll = low, en
56210  l = en + low - ll
56211  IF (l .EQ. low) goto 180
56212  tst1 = dabs(hr(l-1,l-1)) + dabs(hi(l-1,l-1))
56213  x + dabs(hr(l,l)) + dabs(hi(l,l))
56214  tst2 = tst1 + dabs(hr(l,l-1))
56215  IF (tst2 .EQ. tst1) goto 180
56216  170 CONTINUE
56217 C .......... FORM SHIFT ..........
56218  180 IF (l .EQ. en) goto 300
56219  IF (itn .EQ. 0) goto 310
56220  IF (its .EQ. 10 .OR. its .EQ. 20) goto 200
56221  sr = hr(en,en)
56222  si = hi(en,en)
56223  xr = hr(enm1,en) * hr(en,enm1)
56224  xi = hi(enm1,en) * hr(en,enm1)
56225  IF (xr .EQ. 0.0d0 .AND. xi .EQ. 0.0d0) goto 210
56226  yr = (hr(enm1,enm1) - sr) / 2.0d0
56227  yi = (hi(enm1,enm1) - si) / 2.0d0
56228  CALL pycsrt(yr**2-yi**2+xr,2.0d0*yr*yi+xi,zzr,zzi)
56229  IF (yr * zzr + yi * zzi .GE. 0.0d0) goto 190
56230  zzr = -zzr
56231  zzi = -zzi
56232  190 CALL pycdiv(xr,xi,yr+zzr,yi+zzi,xr,xi)
56233  sr = sr - xr
56234  si = si - xi
56235  goto 210
56236 C .......... FORM EXCEPTIONAL SHIFT ..........
56237  200 sr = dabs(hr(en,enm1)) + dabs(hr(enm1,en-2))
56238  si = 0.0d0
56239 C
56240  210 DO 220 i = low, en
56241  hr(i,i) = hr(i,i) - sr
56242  hi(i,i) = hi(i,i) - si
56243  220 CONTINUE
56244 C
56245  tr = tr + sr
56246  ti = ti + si
56247  its = its + 1
56248  itn = itn - 1
56249 C .......... REDUCE TO TRIANGLE (ROWS) ..........
56250  lp1 = l + 1
56251 C
56252  DO 240 i = lp1, en
56253  sr = hr(i,i-1)
56254  hr(i,i-1) = 0.0d0
56255  norm = pythag(pythag(hr(i-1,i-1),hi(i-1,i-1)),sr)
56256  xr = hr(i-1,i-1) / norm
56257  wr(i-1) = xr
56258  xi = hi(i-1,i-1) / norm
56259  wi(i-1) = xi
56260  hr(i-1,i-1) = norm
56261  hi(i-1,i-1) = 0.0d0
56262  hi(i,i-1) = sr / norm
56263 C
56264  DO 230 j = i, en
56265  yr = hr(i-1,j)
56266  yi = hi(i-1,j)
56267  zzr = hr(i,j)
56268  zzi = hi(i,j)
56269  hr(i-1,j) = xr * yr + xi * yi + hi(i,i-1) * zzr
56270  hi(i-1,j) = xr * yi - xi * yr + hi(i,i-1) * zzi
56271  hr(i,j) = xr * zzr - xi * zzi - hi(i,i-1) * yr
56272  hi(i,j) = xr * zzi + xi * zzr - hi(i,i-1) * yi
56273  230 CONTINUE
56274 C
56275  240 CONTINUE
56276 C
56277  si = hi(en,en)
56278  IF (si .EQ. 0.0d0) goto 250
56279  norm = pythag(hr(en,en),si)
56280  sr = hr(en,en) / norm
56281  si = si / norm
56282  hr(en,en) = norm
56283  hi(en,en) = 0.0d0
56284 C .......... INVERSE OPERATION (COLUMNS) ..........
56285  250 DO 280 j = lp1, en
56286  xr = wr(j-1)
56287  xi = wi(j-1)
56288 C
56289  DO 270 i = l, j
56290  yr = hr(i,j-1)
56291  yi = 0.0d0
56292  zzr = hr(i,j)
56293  zzi = hi(i,j)
56294  IF (i .EQ. j) goto 260
56295  yi = hi(i,j-1)
56296  hi(i,j-1) = xr * yi + xi * yr + hi(j,j-1) * zzi
56297  260 hr(i,j-1) = xr * yr - xi * yi + hi(j,j-1) * zzr
56298  hr(i,j) = xr * zzr + xi * zzi - hi(j,j-1) * yr
56299  hi(i,j) = xr * zzi - xi * zzr - hi(j,j-1) * yi
56300  270 CONTINUE
56301 C
56302  280 CONTINUE
56303 C
56304  IF (si .EQ. 0.0d0) goto 160
56305 C
56306  DO 290 i = l, en
56307  yr = hr(i,en)
56308  yi = hi(i,en)
56309  hr(i,en) = sr * yr - si * yi
56310  hi(i,en) = sr * yi + si * yr
56311  290 CONTINUE
56312 C
56313  goto 160
56314 C .......... A ROOT FOUND ..........
56315  300 wr(en) = hr(en,en) + tr
56316  wi(en) = hi(en,en) + ti
56317  en = enm1
56318  goto 150
56319 C .......... SET ERROR -- ALL EIGENVALUES HAVE NOT
56320 C CONVERGED AFTER 30*N ITERATIONS ..........
56321  310 ierr = en
56322  320 RETURN
56323  END
56324 
56325 C*********************************************************************
56326 
56327 C...PYCMQ2
56328 C...Auxiliary to PYEICG.
56329 C
56330 C THIS SUBROUTINE IS A TRANSLATION OF A UNITARY ANALOGUE OF THE
56331 C ALGOL PROCEDURE COMLR2, NUM. MATH. 16, 181-204(1970) BY PETERS
56332 C AND WILKINSON.
56333 C HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 372-395(1971).
56334 C THE UNITARY ANALOGUE SUBSTITUTES THE QR ALGORITHM OF FRANCIS
56335 C (COMP. JOUR. 4, 332-345(1962)) FOR THE LR ALGORITHM.
56336 C
56337 C THIS SUBROUTINE FINDS THE EIGENVALUES AND EIGENVECTORS
56338 C OF A COMPLEX UPPER HESSENBERG MATRIX BY THE QR
56339 C METHOD. THE EIGENVECTORS OF A COMPLEX GENERAL MATRIX
56340 C CAN ALSO BE FOUND IF CORTH HAS BEEN USED TO REDUCE
56341 C THIS GENERAL MATRIX TO HESSENBERG FORM.
56342 C
56343 C ON INPUT
56344 C
56345 C NM MUST BE SET TO THE ROW DIMENSION OF TWO-DIMENSIONAL
56346 C ARRAY PARAMETERS AS DECLARED IN THE CALLING PROGRAM
56347 C DIMENSION STATEMENT.
56348 C
56349 C N IS THE ORDER OF THE MATRIX.
56350 C
56351 C LOW AND IGH ARE INTEGERS DETERMINED BY THE BALANCING
56352 C SUBROUTINE CBAL. IF CBAL HAS NOT BEEN USED,
56353 C SET LOW=1, IGH=N.
56354 C
56355 C ORTR AND ORTI CONTAIN INFORMATION ABOUT THE UNITARY TRANS-
56356 C FORMATIONS USED IN THE REDUCTION BY CORTH, IF PERFORMED.
56357 C ONLY ELEMENTS LOW THROUGH IGH ARE USED. IF THE EIGENVECTORS
56358 C OF THE HESSENBERG MATRIX ARE DESIRED, SET ORTR(J) AND
56359 C ORTI(J) TO 0.0D0 FOR THESE ELEMENTS.
56360 C
56361 C HR AND HI CONTAIN THE REAL AND IMAGINARY PARTS,
56362 C RESPECTIVELY, OF THE COMPLEX UPPER HESSENBERG MATRIX.
56363 C THEIR LOWER TRIANGLES BELOW THE SUBDIAGONAL CONTAIN FURTHER
56364 C INFORMATION ABOUT THE TRANSFORMATIONS WHICH WERE USED IN THE
56365 C REDUCTION BY CORTH, IF PERFORMED. IF THE EIGENVECTORS OF
56366 C THE HESSENBERG MATRIX ARE DESIRED, THESE ELEMENTS MAY BE
56367 C ARBITRARY.
56368 C
56369 C ON OUTPUT
56370 C
56371 C ORTR, ORTI, AND THE UPPER HESSENBERG PORTIONS OF HR AND HI
56372 C HAVE BEEN DESTROYED.
56373 C
56374 C WR AND WI CONTAIN THE REAL AND IMAGINARY PARTS,
56375 C RESPECTIVELY, OF THE EIGENVALUES. IF AN ERROR
56376 C EXIT IS MADE, THE EIGENVALUES SHOULD BE CORRECT
56377 C FOR INDICES IERR+1,...,N.
56378 C
56379 C ZR AND ZI CONTAIN THE REAL AND IMAGINARY PARTS,
56380 C RESPECTIVELY, OF THE EIGENVECTORS. THE EIGENVECTORS
56381 C ARE UNNORMALIZED. IF AN ERROR EXIT IS MADE, NONE OF
56382 C THE EIGENVECTORS HAS BEEN FOUND.
56383 C
56384 C IERR IS SET TO
56385 C ZERO FOR NORMAL RETURN,
56386 C J IF THE LIMIT OF 30*N ITERATIONS IS EXHAUSTED
56387 C WHILE THE J-TH EIGENVALUE IS BEING SOUGHT.
56388 C
56389 C CALLS PYCDIV FOR COMPLEX DIVISION.
56390 C CALLS PYCSRT FOR COMPLEX SQUARE ROOT.
56391 C CALLS PYTHAG FOR DSQRT(A*A + B*B) .
56392 C
56393 C QUESTIONS AND COMMENTS SHOULD BE DIRECTED TO BURTON S. GARBOW,
56394 C MATHEMATICS AND COMPUTER SCIENCE DIV, ARGONNE NATIONAL LABORATORY
56395 C
56396 C THIS VERSION DATED OCTOBER 1989.
56397 C
56398 C MESHED OVERFLOW CONTROL WITH VECTORS OF ISOLATED ROOTS (10/19/89 BSG)
56399 C MESHED OVERFLOW CONTROL WITH TRIANGULAR MULTIPLY (10/30/89 BSG)
56400 C
56401 
56402  SUBROUTINE pycmq2(NM,N,LOW,IGH,ORTR,ORTI,HR,HI,WR,WI,ZR,ZI,IERR)
56403 
56404  INTEGER i,j,k,l,m,n,en,ii,jj,ll,nm,nn,igh,ip1,
56405  x itn,its,low,lp1,enm1,iend,ierr
56406  DOUBLE PRECISION hr(5,5),hi(5,5),wr(5),wi(5),zr(5,5),zi(5,5),
56407  x ortr(5),orti(5)
56408  DOUBLE PRECISION si,sr,ti,tr,xi,xr,yi,yr,zzi,zzr,norm,tst1,tst2,
56409  x pythag
56410 
56411  ierr = 0
56412 C .......... INITIALIZE EIGENVECTOR MATRIX ..........
56413  DO 110 j = 1, n
56414 C
56415  DO 100 i = 1, n
56416  zr(i,j) = 0.0d0
56417  zi(i,j) = 0.0d0
56418  100 CONTINUE
56419  zr(j,j) = 1.0d0
56420  110 CONTINUE
56421 C .......... FORM THE MATRIX OF ACCUMULATED TRANSFORMATIONS
56422 C FROM THE INFORMATION LEFT BY CORTH ..........
56423  iend = igh - low - 1
56424  IF (iend.LT.0) goto 220
56425  IF (iend.EQ.0) goto 170
56426 C .......... FOR I=IGH-1 STEP -1 UNTIL LOW+1 DO -- ..........
56427  DO 160 ii = 1, iend
56428  i = igh - ii
56429  IF (ortr(i) .EQ. 0.0d0 .AND. orti(i) .EQ. 0.0d0) goto 160
56430  IF (hr(i,i-1) .EQ. 0.0d0 .AND. hi(i,i-1) .EQ. 0.0d0) goto 160
56431 C .......... NORM BELOW IS NEGATIVE OF H FORMED IN CORTH ..........
56432  norm = hr(i,i-1) * ortr(i) + hi(i,i-1) * orti(i)
56433  ip1 = i + 1
56434 C
56435  DO 120 k = ip1, igh
56436  ortr(k) = hr(k,i-1)
56437  orti(k) = hi(k,i-1)
56438  120 CONTINUE
56439 C
56440  DO 150 j = i, igh
56441  sr = 0.0d0
56442  si = 0.0d0
56443 C
56444  DO 130 k = i, igh
56445  sr = sr + ortr(k) * zr(k,j) + orti(k) * zi(k,j)
56446  si = si + ortr(k) * zi(k,j) - orti(k) * zr(k,j)
56447  130 CONTINUE
56448 C
56449  sr = sr / norm
56450  si = si / norm
56451 C
56452  DO 140 k = i, igh
56453  zr(k,j) = zr(k,j) + sr * ortr(k) - si * orti(k)
56454  zi(k,j) = zi(k,j) + sr * orti(k) + si * ortr(k)
56455  140 CONTINUE
56456 C
56457  150 CONTINUE
56458 C
56459  160 CONTINUE
56460 C .......... CREATE REAL SUBDIAGONAL ELEMENTS ..........
56461  170 l = low + 1
56462 C
56463  DO 210 i = l, igh
56464  ll = min0(i+1,igh)
56465  IF (hi(i,i-1) .EQ. 0.0d0) goto 210
56466  norm = pythag(hr(i,i-1),hi(i,i-1))
56467  yr = hr(i,i-1) / norm
56468  yi = hi(i,i-1) / norm
56469  hr(i,i-1) = norm
56470  hi(i,i-1) = 0.0d0
56471 C
56472  DO 180 j = i, n
56473  si = yr * hi(i,j) - yi * hr(i,j)
56474  hr(i,j) = yr * hr(i,j) + yi * hi(i,j)
56475  hi(i,j) = si
56476  180 CONTINUE
56477 C
56478  DO 190 j = 1, ll
56479  si = yr * hi(j,i) + yi * hr(j,i)
56480  hr(j,i) = yr * hr(j,i) - yi * hi(j,i)
56481  hi(j,i) = si
56482  190 CONTINUE
56483 C
56484  DO 200 j = low, igh
56485  si = yr * zi(j,i) + yi * zr(j,i)
56486  zr(j,i) = yr * zr(j,i) - yi * zi(j,i)
56487  zi(j,i) = si
56488  200 CONTINUE
56489 C
56490  210 CONTINUE
56491 C .......... STORE ROOTS ISOLATED BY CBAL ..........
56492  220 DO 230 i = 1, n
56493  IF (i .GE. low .AND. i .LE. igh) goto 230
56494  wr(i) = hr(i,i)
56495  wi(i) = hi(i,i)
56496  230 CONTINUE
56497 C
56498  en = igh
56499  tr = 0.0d0
56500  ti = 0.0d0
56501  itn = 30*n
56502 C .......... SEARCH FOR NEXT EIGENVALUE ..........
56503  240 IF (en .LT. low) goto 430
56504  its = 0
56505  enm1 = en - 1
56506 C .......... LOOK FOR SINGLE SMALL SUB-DIAGONAL ELEMENT
56507 C FOR L=EN STEP -1 UNTIL LOW DO -- ..........
56508  250 DO 260 ll = low, en
56509  l = en + low - ll
56510  IF (l .EQ. low) goto 270
56511  tst1 = dabs(hr(l-1,l-1)) + dabs(hi(l-1,l-1))
56512  x + dabs(hr(l,l)) + dabs(hi(l,l))
56513  tst2 = tst1 + dabs(hr(l,l-1))
56514  IF (tst2 .EQ. tst1) goto 270
56515  260 CONTINUE
56516 C .......... FORM SHIFT ..........
56517  270 IF (l .EQ. en) goto 420
56518  IF (itn .EQ. 0) goto 550
56519  IF (its .EQ. 10 .OR. its .EQ. 20) goto 290
56520  sr = hr(en,en)
56521  si = hi(en,en)
56522  xr = hr(enm1,en) * hr(en,enm1)
56523  xi = hi(enm1,en) * hr(en,enm1)
56524  IF (xr .EQ. 0.0d0 .AND. xi .EQ. 0.0d0) goto 300
56525  yr = (hr(enm1,enm1) - sr) / 2.0d0
56526  yi = (hi(enm1,enm1) - si) / 2.0d0
56527  CALL pycsrt(yr**2-yi**2+xr,2.0d0*yr*yi+xi,zzr,zzi)
56528  IF (yr * zzr + yi * zzi .GE. 0.0d0) goto 280
56529  zzr = -zzr
56530  zzi = -zzi
56531  280 CALL pycdiv(xr,xi,yr+zzr,yi+zzi,xr,xi)
56532  sr = sr - xr
56533  si = si - xi
56534  goto 300
56535 C .......... FORM EXCEPTIONAL SHIFT ..........
56536  290 sr = dabs(hr(en,enm1)) + dabs(hr(enm1,en-2))
56537  si = 0.0d0
56538 C
56539  300 DO 310 i = low, en
56540  hr(i,i) = hr(i,i) - sr
56541  hi(i,i) = hi(i,i) - si
56542  310 CONTINUE
56543 C
56544  tr = tr + sr
56545  ti = ti + si
56546  its = its + 1
56547  itn = itn - 1
56548 C .......... REDUCE TO TRIANGLE (ROWS) ..........
56549  lp1 = l + 1
56550 C
56551  DO 330 i = lp1, en
56552  sr = hr(i,i-1)
56553  hr(i,i-1) = 0.0d0
56554  norm = pythag(pythag(hr(i-1,i-1),hi(i-1,i-1)),sr)
56555  xr = hr(i-1,i-1) / norm
56556  wr(i-1) = xr
56557  xi = hi(i-1,i-1) / norm
56558  wi(i-1) = xi
56559  hr(i-1,i-1) = norm
56560  hi(i-1,i-1) = 0.0d0
56561  hi(i,i-1) = sr / norm
56562 C
56563  DO 320 j = i, n
56564  yr = hr(i-1,j)
56565  yi = hi(i-1,j)
56566  zzr = hr(i,j)
56567  zzi = hi(i,j)
56568  hr(i-1,j) = xr * yr + xi * yi + hi(i,i-1) * zzr
56569  hi(i-1,j) = xr * yi - xi * yr + hi(i,i-1) * zzi
56570  hr(i,j) = xr * zzr - xi * zzi - hi(i,i-1) * yr
56571  hi(i,j) = xr * zzi + xi * zzr - hi(i,i-1) * yi
56572  320 CONTINUE
56573 C
56574  330 CONTINUE
56575 C
56576  si = hi(en,en)
56577  IF (si .EQ. 0.0d0) goto 350
56578  norm = pythag(hr(en,en),si)
56579  sr = hr(en,en) / norm
56580  si = si / norm
56581  hr(en,en) = norm
56582  hi(en,en) = 0.0d0
56583  IF (en .EQ. n) goto 350
56584  ip1 = en + 1
56585 C
56586  DO 340 j = ip1, n
56587  yr = hr(en,j)
56588  yi = hi(en,j)
56589  hr(en,j) = sr * yr + si * yi
56590  hi(en,j) = sr * yi - si * yr
56591  340 CONTINUE
56592 C .......... INVERSE OPERATION (COLUMNS) ..........
56593  350 DO 390 j = lp1, en
56594  xr = wr(j-1)
56595  xi = wi(j-1)
56596 C
56597  DO 370 i = 1, j
56598  yr = hr(i,j-1)
56599  yi = 0.0d0
56600  zzr = hr(i,j)
56601  zzi = hi(i,j)
56602  IF (i .EQ. j) goto 360
56603  yi = hi(i,j-1)
56604  hi(i,j-1) = xr * yi + xi * yr + hi(j,j-1) * zzi
56605  360 hr(i,j-1) = xr * yr - xi * yi + hi(j,j-1) * zzr
56606  hr(i,j) = xr * zzr + xi * zzi - hi(j,j-1) * yr
56607  hi(i,j) = xr * zzi - xi * zzr - hi(j,j-1) * yi
56608  370 CONTINUE
56609 C
56610  DO 380 i = low, igh
56611  yr = zr(i,j-1)
56612  yi = zi(i,j-1)
56613  zzr = zr(i,j)
56614  zzi = zi(i,j)
56615  zr(i,j-1) = xr * yr - xi * yi + hi(j,j-1) * zzr
56616  zi(i,j-1) = xr * yi + xi * yr + hi(j,j-1) * zzi
56617  zr(i,j) = xr * zzr + xi * zzi - hi(j,j-1) * yr
56618  zi(i,j) = xr * zzi - xi * zzr - hi(j,j-1) * yi
56619  380 CONTINUE
56620 C
56621  390 CONTINUE
56622 C
56623  IF (si .EQ. 0.0d0) goto 250
56624 C
56625  DO 400 i = 1, en
56626  yr = hr(i,en)
56627  yi = hi(i,en)
56628  hr(i,en) = sr * yr - si * yi
56629  hi(i,en) = sr * yi + si * yr
56630  400 CONTINUE
56631 C
56632  DO 410 i = low, igh
56633  yr = zr(i,en)
56634  yi = zi(i,en)
56635  zr(i,en) = sr * yr - si * yi
56636  zi(i,en) = sr * yi + si * yr
56637  410 CONTINUE
56638 C
56639  goto 250
56640 C .......... A ROOT FOUND ..........
56641  420 hr(en,en) = hr(en,en) + tr
56642  wr(en) = hr(en,en)
56643  hi(en,en) = hi(en,en) + ti
56644  wi(en) = hi(en,en)
56645  en = enm1
56646  goto 240
56647 C .......... ALL ROOTS FOUND. BACKSUBSTITUTE TO FIND
56648 C VECTORS OF UPPER TRIANGULAR FORM ..........
56649  430 norm = 0.0d0
56650 C
56651  DO 440 i = 1, n
56652 C
56653  DO 440 j = i, n
56654  tr = dabs(hr(i,j)) + dabs(hi(i,j))
56655  IF (tr .GT. norm) norm = tr
56656  440 CONTINUE
56657 C
56658  IF (n .EQ. 1 .OR. norm .EQ. 0.0d0) goto 560
56659 C .......... FOR EN=N STEP -1 UNTIL 2 DO -- ..........
56660  DO 500 nn = 2, n
56661  en = n + 2 - nn
56662  xr = wr(en)
56663  xi = wi(en)
56664  hr(en,en) = 1.0d0
56665  hi(en,en) = 0.0d0
56666  enm1 = en - 1
56667 C .......... FOR I=EN-1 STEP -1 UNTIL 1 DO -- ..........
56668  DO 490 ii = 1, enm1
56669  i = en - ii
56670  zzr = 0.0d0
56671  zzi = 0.0d0
56672  ip1 = i + 1
56673 C
56674  DO 450 j = ip1, en
56675  zzr = zzr + hr(i,j) * hr(j,en) - hi(i,j) * hi(j,en)
56676  zzi = zzi + hr(i,j) * hi(j,en) + hi(i,j) * hr(j,en)
56677  450 CONTINUE
56678 C
56679  yr = xr - wr(i)
56680  yi = xi - wi(i)
56681  IF (yr .NE. 0.0d0 .OR. yi .NE. 0.0d0) goto 470
56682  tst1 = norm
56683  yr = tst1
56684  460 yr = 0.01d0 * yr
56685  tst2 = norm + yr
56686  IF (tst2 .GT. tst1) goto 460
56687  470 CONTINUE
56688  CALL pycdiv(zzr,zzi,yr,yi,hr(i,en),hi(i,en))
56689 C .......... OVERFLOW CONTROL ..........
56690  tr = dabs(hr(i,en)) + dabs(hi(i,en))
56691  IF (tr .EQ. 0.0d0) goto 490
56692  tst1 = tr
56693  tst2 = tst1 + 1.0d0/tst1
56694  IF (tst2 .GT. tst1) goto 490
56695  DO 480 j = i, en
56696  hr(j,en) = hr(j,en)/tr
56697  hi(j,en) = hi(j,en)/tr
56698  480 CONTINUE
56699 C
56700  490 CONTINUE
56701 C
56702  500 CONTINUE
56703 C .......... END BACKSUBSTITUTION ..........
56704 C .......... VECTORS OF ISOLATED ROOTS ..........
56705  DO 520 i = 1, n
56706  IF (i .GE. low .AND. i .LE. igh) goto 520
56707 C
56708  DO 510 j = i, n
56709  zr(i,j) = hr(i,j)
56710  zi(i,j) = hi(i,j)
56711  510 CONTINUE
56712 C
56713  520 CONTINUE
56714 C .......... MULTIPLY BY TRANSFORMATION MATRIX TO GIVE
56715 C VECTORS OF ORIGINAL FULL MATRIX.
56716 C FOR J=N STEP -1 UNTIL LOW DO -- ..........
56717  DO 540 jj = low, n
56718  j = n + low - jj
56719  m = min0(j,igh)
56720 C
56721  DO 540 i = low, igh
56722  zzr = 0.0d0
56723  zzi = 0.0d0
56724 C
56725  DO 530 k = low, m
56726  zzr = zzr + zr(i,k) * hr(k,j) - zi(i,k) * hi(k,j)
56727  zzi = zzi + zr(i,k) * hi(k,j) + zi(i,k) * hr(k,j)
56728  530 CONTINUE
56729 C
56730  zr(i,j) = zzr
56731  zi(i,j) = zzi
56732  540 CONTINUE
56733 C
56734  goto 560
56735 C .......... SET ERROR -- ALL EIGENVALUES HAVE NOT
56736 C CONVERGED AFTER 30*N ITERATIONS ..........
56737  550 ierr = en
56738  560 RETURN
56739  END
56740 
56741 C*********************************************************************
56742 
56743 C...PYCDIV
56744 C...Auxiliary to PYCMQR
56745 C
56746 C COMPLEX DIVISION, (CR,CI) = (AR,AI)/(BR,BI)
56747 C
56748 
56749  SUBROUTINE pycdiv(AR,AI,BR,BI,CR,CI)
56750 
56751  DOUBLE PRECISION ar,ai,br,bi,cr,ci
56752  DOUBLE PRECISION s,ars,ais,brs,bis
56753 
56754  s = dabs(br) + dabs(bi)
56755  ars = ar/s
56756  ais = ai/s
56757  brs = br/s
56758  bis = bi/s
56759  s = brs**2 + bis**2
56760  cr = (ars*brs + ais*bis)/s
56761  ci = (ais*brs - ars*bis)/s
56762  RETURN
56763  END
56764 
56765 C*********************************************************************
56766 
56767 C...PYCSRT
56768 C...Auxiliary to PYCMQR
56769 C
56770 C (YR,YI) = COMPLEX DSQRT(XR,XI)
56771 C BRANCH CHOSEN SO THAT YR .GE. 0.0 AND SIGN(YI) .EQ. SIGN(XI)
56772 C
56773 
56774  SUBROUTINE pycsrt(XR,XI,YR,YI)
56775 
56776  DOUBLE PRECISION xr,xi,yr,yi
56777  DOUBLE PRECISION s,tr,ti,pythag
56778 
56779  tr = xr
56780  ti = xi
56781  s = dsqrt(0.5d0*(pythag(tr,ti) + dabs(tr)))
56782  IF (tr .GE. 0.0d0) yr = s
56783  IF (ti .LT. 0.0d0) s = -s
56784  IF (tr .LE. 0.0d0) yi = s
56785  IF (tr .LT. 0.0d0) yr = 0.5d0*(ti/yi)
56786  IF (tr .GT. 0.0d0) yi = 0.5d0*(ti/yr)
56787  RETURN
56788  END
56789 
56790  DOUBLE PRECISION FUNCTION pythag(A,B)
56791  DOUBLE PRECISION a,b
56792 C
56793 C FINDS DSQRT(A**2+B**2) WITHOUT OVERFLOW OR DESTRUCTIVE UNDERFLOW
56794 C
56795  DOUBLE PRECISION p,r,s,t,u
56796  p = dmax1(dabs(a),dabs(b))
56797  IF (p .EQ. 0.0d0) goto 110
56798  r = (dmin1(dabs(a),dabs(b))/p)**2
56799  100 CONTINUE
56800  t = 4.0d0 + r
56801  IF (t .EQ. 4.0d0) goto 110
56802  s = r/t
56803  u = 1.0d0 + 2.0d0*s
56804  p = u*p
56805  r = (s/u)**2 * r
56806  goto 100
56807  110 pythag = p
56808  RETURN
56809  END
56810 
56811 C*********************************************************************
56812 
56813 C...PYCBAL
56814 C...Auxiliary to PYEICG
56815 C
56816 C THIS SUBROUTINE IS A TRANSLATION OF THE ALGOL PROCEDURE
56817 C CBALANCE, WHICH IS A COMPLEX VERSION OF BALANCE,
56818 C NUM. MATH. 13, 293-304(1969) BY PARLETT AND REINSCH.
56819 C HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 315-326(1971).
56820 C
56821 C THIS SUBROUTINE BALANCES A COMPLEX MATRIX AND ISOLATES
56822 C EIGENVALUES WHENEVER POSSIBLE.
56823 C
56824 C ON INPUT
56825 C
56826 C NM MUST BE SET TO THE ROW DIMENSION OF TWO-DIMENSIONAL
56827 C ARRAY PARAMETERS AS DECLARED IN THE CALLING PROGRAM
56828 C DIMENSION STATEMENT.
56829 C
56830 C N IS THE ORDER OF THE MATRIX.
56831 C
56832 C AR AND AI CONTAIN THE REAL AND IMAGINARY PARTS,
56833 C RESPECTIVELY, OF THE COMPLEX MATRIX TO BE BALANCED.
56834 C
56835 C ON OUTPUT
56836 C
56837 C AR AND AI CONTAIN THE REAL AND IMAGINARY PARTS,
56838 C RESPECTIVELY, OF THE BALANCED MATRIX.
56839 C
56840 C LOW AND IGH ARE TWO INTEGERS SUCH THAT AR(I,J) AND AI(I,J)
56841 C ARE EQUAL TO ZERO IF
56842 C (1) I IS GREATER THAN J AND
56843 C (2) J=1,...,LOW-1 OR I=IGH+1,...,N.
56844 C
56845 C SCALE CONTAINS INFORMATION DETERMINING THE
56846 C PERMUTATIONS AND SCALING FACTORS USED.
56847 C
56848 C SUPPOSE THAT THE PRINCIPAL SUBMATRIX IN ROWS LOW THROUGH IGH
56849 C HAS BEEN BALANCED, THAT P(J) DENOTES THE INDEX INTERCHANGED
56850 C WITH J DURING THE PERMUTATION STEP, AND THAT THE ELEMENTS
56851 C OF THE DIAGONAL MATRIX USED ARE DENOTED BY D(I,J). THEN
56852 C SCALE(J) = P(J), FOR J = 1,...,LOW-1
56853 C = D(J,J) J = LOW,...,IGH
56854 C = P(J) J = IGH+1,...,N.
56855 C THE ORDER IN WHICH THE INTERCHANGES ARE MADE IS N TO IGH+1,
56856 C THEN 1 TO LOW-1.
56857 C
56858 C NOTE THAT 1 IS RETURNED FOR IGH IF IGH IS ZERO FORMALLY.
56859 C
56860 C THE ALGOL PROCEDURE EXC CONTAINED IN CBALANCE APPEARS IN
56861 C CBAL IN LINE. (NOTE THAT THE ALGOL ROLES OF IDENTIFIERS
56862 C K,L HAVE BEEN REVERSED.)
56863 C
56864 C ARITHMETIC IS REAL THROUGHOUT.
56865 C
56866 C QUESTIONS AND COMMENTS SHOULD BE DIRECTED TO BURTON S. GARBOW,
56867 C MATHEMATICS AND COMPUTER SCIENCE DIV, ARGONNE NATIONAL LABORATORY
56868 C
56869 C THIS VERSION DATED AUGUST 1983.
56870 C
56871 
56872  SUBROUTINE pycbal(NM,N,AR,AI,LOW,IGH,SCALE)
56873 
56874  INTEGER i,j,k,l,m,n,jj,nm,igh,low,iexc
56875  DOUBLE PRECISION ar(5,5),ai(5,5),scale(5)
56876  DOUBLE PRECISION c,f,g,r,s,b2,radix
56877  LOGICAL noconv
56878 
56879  radix = 16.0d0
56880 C
56881  b2 = radix * radix
56882  k = 1
56883  l = n
56884  goto 150
56885 C .......... IN-LINE PROCEDURE FOR ROW AND
56886 C COLUMN EXCHANGE ..........
56887  100 scale(m) = j
56888  IF (j .EQ. m) goto 130
56889 C
56890  DO 110 i = 1, l
56891  f = ar(i,j)
56892  ar(i,j) = ar(i,m)
56893  ar(i,m) = f
56894  f = ai(i,j)
56895  ai(i,j) = ai(i,m)
56896  ai(i,m) = f
56897  110 CONTINUE
56898 C
56899  DO 120 i = k, n
56900  f = ar(j,i)
56901  ar(j,i) = ar(m,i)
56902  ar(m,i) = f
56903  f = ai(j,i)
56904  ai(j,i) = ai(m,i)
56905  ai(m,i) = f
56906  120 CONTINUE
56907 C
56908  130 IF(iexc.EQ.1) goto 140
56909  IF(iexc.EQ.2) goto 180
56910 C .......... SEARCH FOR ROWS ISOLATING AN EIGENVALUE
56911 C AND PUSH THEM DOWN ..........
56912  140 IF (l .EQ. 1) goto 320
56913  l = l - 1
56914 C .......... FOR J=L STEP -1 UNTIL 1 DO -- ..........
56915  150 DO 170 jj = 1, l
56916  j = l + 1 - jj
56917 C
56918  DO 160 i = 1, l
56919  IF (i .EQ. j) goto 160
56920  IF (ar(j,i) .NE. 0.0d0 .OR. ai(j,i) .NE. 0.0d0) goto 170
56921  160 CONTINUE
56922 C
56923  m = l
56924  iexc = 1
56925  goto 100
56926  170 CONTINUE
56927 C
56928  goto 190
56929 C .......... SEARCH FOR COLUMNS ISOLATING AN EIGENVALUE
56930 C AND PUSH THEM LEFT ..........
56931  180 k = k + 1
56932 C
56933  190 DO 210 j = k, l
56934 C
56935  DO 200 i = k, l
56936  IF (i .EQ. j) goto 200
56937  IF (ar(i,j) .NE. 0.0d0 .OR. ai(i,j) .NE. 0.0d0) goto 210
56938  200 CONTINUE
56939 C
56940  m = k
56941  iexc = 2
56942  goto 100
56943  210 CONTINUE
56944 C .......... NOW BALANCE THE SUBMATRIX IN ROWS K TO L ..........
56945  DO 220 i = k, l
56946  220 scale(i) = 1.0d0
56947 C .......... ITERATIVE LOOP FOR NORM REDUCTION ..........
56948  230 noconv = .false.
56949 C
56950  DO 310 i = k, l
56951  c = 0.0d0
56952  r = 0.0d0
56953 C
56954  DO 240 j = k, l
56955  IF (j .EQ. i) goto 240
56956  c = c + dabs(ar(j,i)) + dabs(ai(j,i))
56957  r = r + dabs(ar(i,j)) + dabs(ai(i,j))
56958  240 CONTINUE
56959 C .......... GUARD AGAINST ZERO C OR R DUE TO UNDERFLOW ..........
56960  IF (c .EQ. 0.0d0 .OR. r .EQ. 0.0d0) goto 310
56961  g = r / radix
56962  f = 1.0d0
56963  s = c + r
56964  250 IF (c .GE. g) goto 260
56965  f = f * radix
56966  c = c * b2
56967  goto 250
56968  260 g = r * radix
56969  270 IF (c .LT. g) goto 280
56970  f = f / radix
56971  c = c / b2
56972  goto 270
56973 C .......... NOW BALANCE ..........
56974  280 IF ((c + r) / f .GE. 0.95d0 * s) goto 310
56975  g = 1.0d0 / f
56976  scale(i) = scale(i) * f
56977  noconv = .true.
56978 C
56979  DO 290 j = k, n
56980  ar(i,j) = ar(i,j) * g
56981  ai(i,j) = ai(i,j) * g
56982  290 CONTINUE
56983 C
56984  DO 300 j = 1, l
56985  ar(j,i) = ar(j,i) * f
56986  ai(j,i) = ai(j,i) * f
56987  300 CONTINUE
56988 C
56989  310 CONTINUE
56990 C
56991  IF (noconv) goto 230
56992 C
56993  320 low = k
56994  igh = l
56995  RETURN
56996  END
56997 
56998 C*********************************************************************
56999 
57000 C...PYCBA2
57001 C...Auxiliary to PYEICG.
57002 C
57003 C THIS SUBROUTINE IS A TRANSLATION OF THE ALGOL PROCEDURE
57004 C CBABK2, WHICH IS A COMPLEX VERSION OF BALBAK,
57005 C NUM. MATH. 13, 293-304(1969) BY PARLETT AND REINSCH.
57006 C HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 315-326(1971).
57007 C
57008 C THIS SUBROUTINE FORMS THE EIGENVECTORS OF A COMPLEX GENERAL
57009 C MATRIX BY BACK TRANSFORMING THOSE OF THE CORRESPONDING
57010 C BALANCED MATRIX DETERMINED BY CBAL.
57011 C
57012 C ON INPUT
57013 C
57014 C NM MUST BE SET TO THE ROW DIMENSION OF TWO-DIMENSIONAL
57015 C ARRAY PARAMETERS AS DECLARED IN THE CALLING PROGRAM
57016 C DIMENSION STATEMENT.
57017 C
57018 C N IS THE ORDER OF THE MATRIX.
57019 C
57020 C LOW AND IGH ARE INTEGERS DETERMINED BY CBAL.
57021 C
57022 C SCALE CONTAINS INFORMATION DETERMINING THE PERMUTATIONS
57023 C AND SCALING FACTORS USED BY CBAL.
57024 C
57025 C M IS THE NUMBER OF EIGENVECTORS TO BE BACK TRANSFORMED.
57026 C
57027 C ZR AND ZI CONTAIN THE REAL AND IMAGINARY PARTS,
57028 C RESPECTIVELY, OF THE EIGENVECTORS TO BE
57029 C BACK TRANSFORMED IN THEIR FIRST M COLUMNS.
57030 C
57031 C ON OUTPUT
57032 C
57033 C ZR AND ZI CONTAIN THE REAL AND IMAGINARY PARTS,
57034 C RESPECTIVELY, OF THE TRANSFORMED EIGENVECTORS
57035 C IN THEIR FIRST M COLUMNS.
57036 C
57037 C QUESTIONS AND COMMENTS SHOULD BE DIRECTED TO BURTON S. GARBOW,
57038 C MATHEMATICS AND COMPUTER SCIENCE DIV, ARGONNE NATIONAL LABORATORY
57039 C
57040 C THIS VERSION DATED AUGUST 1983.
57041 C
57042 
57043  SUBROUTINE pycba2(NM,N,LOW,IGH,SCALE,M,ZR,ZI)
57044 
57045  INTEGER i,j,k,m,n,ii,nm,igh,low
57046  DOUBLE PRECISION scale(5),zr(5,5),zi(5,5)
57047  DOUBLE PRECISION s
57048 
57049  IF (m .EQ. 0) goto 150
57050  IF (igh .EQ. low) goto 120
57051 C
57052  DO 110 i = low, igh
57053  s = scale(i)
57054 C .......... LEFT HAND EIGENVECTORS ARE BACK TRANSFORMED
57055 C IF THE FOREGOING STATEMENT IS REPLACED BY
57056 C S=1.0D0/SCALE(I). ..........
57057  DO 100 j = 1, m
57058  zr(i,j) = zr(i,j) * s
57059  zi(i,j) = zi(i,j) * s
57060  100 CONTINUE
57061 C
57062  110 CONTINUE
57063 C .......... FOR I=LOW-1 STEP -1 UNTIL 1,
57064 C IGH+1 STEP 1 UNTIL N DO -- ..........
57065  120 DO 140 ii = 1, n
57066  i = ii
57067  IF (i .GE. low .AND. i .LE. igh) goto 140
57068  IF (i .LT. low) i = low - ii
57069  k = scale(i)
57070  IF (k .EQ. i) goto 140
57071 C
57072  DO 130 j = 1, m
57073  s = zr(i,j)
57074  zr(i,j) = zr(k,j)
57075  zr(k,j) = s
57076  s = zi(i,j)
57077  zi(i,j) = zi(k,j)
57078  zi(k,j) = s
57079  130 CONTINUE
57080 C
57081  140 CONTINUE
57082 C
57083  150 RETURN
57084  END
57085 
57086 C*********************************************************************
57087 
57088 C...PYCRTH
57089 C...Auxiliary to PYEICG.
57090 C
57091 C THIS SUBROUTINE IS A TRANSLATION OF A COMPLEX ANALOGUE OF
57092 C THE ALGOL PROCEDURE ORTHES, NUM. MATH. 12, 349-368(1968)
57093 C BY MARTIN AND WILKINSON.
57094 C HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 339-358(1971).
57095 C
57096 C GIVEN A COMPLEX GENERAL MATRIX, THIS SUBROUTINE
57097 C REDUCES A SUBMATRIX SITUATED IN ROWS AND COLUMNS
57098 C LOW THROUGH IGH TO UPPER HESSENBERG FORM BY
57099 C UNITARY SIMILARITY TRANSFORMATIONS.
57100 C
57101 C ON INPUT
57102 C
57103 C NM MUST BE SET TO THE ROW DIMENSION OF TWO-DIMENSIONAL
57104 C ARRAY PARAMETERS AS DECLARED IN THE CALLING PROGRAM
57105 C DIMENSION STATEMENT.
57106 C
57107 C N IS THE ORDER OF THE MATRIX.
57108 C
57109 C LOW AND IGH ARE INTEGERS DETERMINED BY THE BALANCING
57110 C SUBROUTINE CBAL. IF CBAL HAS NOT BEEN USED,
57111 C SET LOW=1, IGH=N.
57112 C
57113 C AR AND AI CONTAIN THE REAL AND IMAGINARY PARTS,
57114 C RESPECTIVELY, OF THE COMPLEX INPUT MATRIX.
57115 C
57116 C ON OUTPUT
57117 C
57118 C AR AND AI CONTAIN THE REAL AND IMAGINARY PARTS,
57119 C RESPECTIVELY, OF THE HESSENBERG MATRIX. INFORMATION
57120 C ABOUT THE UNITARY TRANSFORMATIONS USED IN THE REDUCTION
57121 C IS STORED IN THE REMAINING TRIANGLES UNDER THE
57122 C HESSENBERG MATRIX.
57123 C
57124 C ORTR AND ORTI CONTAIN FURTHER INFORMATION ABOUT THE
57125 C TRANSFORMATIONS. ONLY ELEMENTS LOW THROUGH IGH ARE USED.
57126 C
57127 C CALLS PYTHAG FOR DSQRT(A*A + B*B) .
57128 C
57129 C QUESTIONS AND COMMENTS SHOULD BE DIRECTED TO BURTON S. GARBOW,
57130 C MATHEMATICS AND COMPUTER SCIENCE DIV, ARGONNE NATIONAL LABORATORY
57131 C
57132 C THIS VERSION DATED AUGUST 1983.
57133 C
57134 
57135  SUBROUTINE pycrth(NM,N,LOW,IGH,AR,AI,ORTR,ORTI)
57136 
57137  INTEGER i,j,m,n,ii,jj,la,mp,nm,igh,kp1,low
57138  DOUBLE PRECISION ar(5,5),ai(5,5),ortr(5),orti(5)
57139  DOUBLE PRECISION f,g,h,fi,fr,scale,pythag
57140 
57141  la = igh - 1
57142  kp1 = low + 1
57143  IF (la .LT. kp1) goto 210
57144 C
57145  DO 200 m = kp1, la
57146  h = 0.0d0
57147  ortr(m) = 0.0d0
57148  orti(m) = 0.0d0
57149  scale = 0.0d0
57150 C .......... SCALE COLUMN (ALGOL TOL THEN NOT NEEDED) ..........
57151  DO 100 i = m, igh
57152  100 scale = scale + dabs(ar(i,m-1)) + dabs(ai(i,m-1))
57153 C
57154  IF (scale .EQ. 0.0d0) goto 200
57155  mp = m + igh
57156 C .......... FOR I=IGH STEP -1 UNTIL M DO -- ..........
57157  DO 110 ii = m, igh
57158  i = mp - ii
57159  ortr(i) = ar(i,m-1) / scale
57160  orti(i) = ai(i,m-1) / scale
57161  h = h + ortr(i) * ortr(i) + orti(i) * orti(i)
57162  110 CONTINUE
57163 C
57164  g = dsqrt(h)
57165  f = pythag(ortr(m),orti(m))
57166  IF (f .EQ. 0.0d0) goto 120
57167  h = h + f * g
57168  g = g / f
57169  ortr(m) = (1.0d0 + g) * ortr(m)
57170  orti(m) = (1.0d0 + g) * orti(m)
57171  goto 130
57172 C
57173  120 ortr(m) = g
57174  ar(m,m-1) = scale
57175 C .......... FORM (I-(U*UT)/H) * A ..........
57176  130 DO 160 j = m, n
57177  fr = 0.0d0
57178  fi = 0.0d0
57179 C .......... FOR I=IGH STEP -1 UNTIL M DO -- ..........
57180  DO 140 ii = m, igh
57181  i = mp - ii
57182  fr = fr + ortr(i) * ar(i,j) + orti(i) * ai(i,j)
57183  fi = fi + ortr(i) * ai(i,j) - orti(i) * ar(i,j)
57184  140 CONTINUE
57185 C
57186  fr = fr / h
57187  fi = fi / h
57188 C
57189  DO 150 i = m, igh
57190  ar(i,j) = ar(i,j) - fr * ortr(i) + fi * orti(i)
57191  ai(i,j) = ai(i,j) - fr * orti(i) - fi * ortr(i)
57192  150 CONTINUE
57193 C
57194  160 CONTINUE
57195 C .......... FORM (I-(U*UT)/H)*A*(I-(U*UT)/H) ..........
57196  DO 190 i = 1, igh
57197  fr = 0.0d0
57198  fi = 0.0d0
57199 C .......... FOR J=IGH STEP -1 UNTIL M DO -- ..........
57200  DO 170 jj = m, igh
57201  j = mp - jj
57202  fr = fr + ortr(j) * ar(i,j) - orti(j) * ai(i,j)
57203  fi = fi + ortr(j) * ai(i,j) + orti(j) * ar(i,j)
57204  170 CONTINUE
57205 C
57206  fr = fr / h
57207  fi = fi / h
57208 C
57209  DO 180 j = m, igh
57210  ar(i,j) = ar(i,j) - fr * ortr(j) - fi * orti(j)
57211  ai(i,j) = ai(i,j) + fr * orti(j) - fi * ortr(j)
57212  180 CONTINUE
57213 C
57214  190 CONTINUE
57215 C
57216  ortr(m) = scale * ortr(m)
57217  orti(m) = scale * orti(m)
57218  ar(m,m-1) = -g * ar(m,m-1)
57219  ai(m,m-1) = -g * ai(m,m-1)
57220  200 CONTINUE
57221 C
57222  210 RETURN
57223  END
57224 
57225 C*********************************************************************
57226 
57227 C...PYLDCM
57228 C...Auxiliary to PYSIGH, for technicolor corrections to QCD 2 -> 2
57229 C...processes.
57230 
57231  SUBROUTINE pyldcm(A,N,NP,INDX,D)
57232  IMPLICIT NONE
57233  INTEGER n,np,indx(n)
57234  REAL*8 d,tiny
57235  COMPLEX*16 a(np,np)
57236  parameter(tiny=1.0d-20)
57237  INTEGER i,imax,j,k
57238  REAL*8 aamax,vv(6),dum
57239  COMPLEX*16 sum,dumc
57240 
57241  d=1d0
57242  DO 110 i=1,n
57243  aamax=0d0
57244  DO 100 j=1,n
57245  IF (abs(a(i,j)).GT.aamax) aamax=abs(a(i,j))
57246  100 CONTINUE
57247  IF (aamax.EQ.0d0) CALL pyerrm(28,'(PYLDCM:) singular matrix')
57248  vv(i)=1d0/aamax
57249  110 CONTINUE
57250  DO 180 j=1,n
57251  DO 130 i=1,j-1
57252  sum=a(i,j)
57253  DO 120 k=1,i-1
57254  sum=sum-a(i,k)*a(k,j)
57255  120 CONTINUE
57256  a(i,j)=sum
57257  130 CONTINUE
57258  aamax=0d0
57259  DO 150 i=j,n
57260  sum=a(i,j)
57261  DO 140 k=1,j-1
57262  sum=sum-a(i,k)*a(k,j)
57263  140 CONTINUE
57264  a(i,j)=sum
57265  dum=vv(i)*abs(sum)
57266  IF (dum.GE.aamax) THEN
57267  imax=i
57268  aamax=dum
57269  ENDIF
57270  150 CONTINUE
57271  IF (j.NE.imax)THEN
57272  DO 160 k=1,n
57273  dumc=a(imax,k)
57274  a(imax,k)=a(j,k)
57275  a(j,k)=dumc
57276  160 CONTINUE
57277  d=-d
57278  vv(imax)=vv(j)
57279  ENDIF
57280  indx(j)=imax
57281  IF(abs(a(j,j)).EQ.0d0) a(j,j)=dcmplx(tiny,0d0)
57282  IF(j.NE.n)THEN
57283  DO 170 i=j+1,n
57284  a(i,j)=a(i,j)/a(j,j)
57285  170 CONTINUE
57286  ENDIF
57287  180 CONTINUE
57288 
57289  RETURN
57290  END
57291 
57292 C*********************************************************************
57293 
57294 C...PYBKSB
57295 C...Auxiliary to PYSIGH, for technicolor corrections to QCD 2 -> 2
57296 C...processes.
57297 
57298  SUBROUTINE pybksb(A,N,NP,INDX,B)
57299  IMPLICIT NONE
57300  INTEGER n,np,indx(n)
57301  COMPLEX*16 a(np,np),b(n)
57302  INTEGER i,ii,j,ll
57303  COMPLEX*16 sum
57304 
57305  ii=0
57306  DO 110 i=1,n
57307  ll=indx(i)
57308  sum=b(ll)
57309  b(ll)=b(i)
57310  IF (ii.NE.0)THEN
57311  DO 100 j=ii,i-1
57312  sum=sum-a(i,j)*b(j)
57313  100 CONTINUE
57314  ELSE IF (abs(sum).NE.0d0) THEN
57315  ii=i
57316  ENDIF
57317  b(i)=sum
57318  110 CONTINUE
57319  DO 130 i=n,1,-1
57320  sum=b(i)
57321  DO 120 j=i+1,n
57322  sum=sum-a(i,j)*b(j)
57323  120 CONTINUE
57324  b(i)=sum/a(i,i)
57325  130 CONTINUE
57326  RETURN
57327  END
57328 
57329 C***********************************************************************
57330 
57331 C...PYWIDX
57332 C...Calculates full and partial widths of resonances.
57333 C....copy of PYWIDT, used for techniparticle widths
57334 
57335  SUBROUTINE pywidx(KFLR,SH,WDTP,WDTE)
57336 
57337 C...Double precision and integer declarations.
57338  IMPLICIT DOUBLE PRECISION(a-h, o-z)
57339  IMPLICIT INTEGER(i-n)
57340  INTEGER pyk,pychge,pycomp
57341 C...Parameter statement to help give large particle numbers.
57342  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
57343  &kexcit=4000000,kdimen=5000000)
57344 C...Commonblocks.
57345  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
57346  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
57347  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
57348  common/pysubs/msel,mselpd,msub(500),kfin(2,-40:40),ckin(200)
57349  common/pypars/mstp(200),parp(200),msti(200),pari(200)
57350  common/pyint1/mint(400),vint(400)
57351  common/pyint4/mwid(500),wids(500,5)
57352  common/pymssm/imss(0:99),rmss(0:99)
57353  common/pytcsm/itcm(0:99),rtcm(0:99)
57354  SAVE /pydat1/,/pydat2/,/pydat3/,/pysubs/,/pypars/,/pyint1/,
57355  &/pyint4/,/pymssm/,/pytcsm/
57356 C...Local arrays and saved variables.
57357  dimension wdtp(0:400),wdte(0:400,0:5),mofsv(3,2),widwsv(3,2),
57358  &wid2sv(3,2)
57359  SAVE mofsv,widwsv,wid2sv
57360  DATA mofsv/6*0/,widwsv/6*0d0/,wid2sv/6*0d0/
57361 
57362 C...Compressed code and sign; mass.
57363  kfla=iabs(kflr)
57364  kfls=isign(1,kflr)
57365  kc=pycomp(kfla)
57366  shr=sqrt(sh)
57367  pmr=pmas(kc,1)
57368 
57369 C...Reset width information.
57370  DO i=0,400
57371  wdtp(i)=0d0
57372  ENDDO
57373 
57374 C...Common electroweak and strong constants.
57375  xw=paru(102)
57376  xwv=xw
57377  IF(mstp(8).GE.2) xw=1d0-(pmas(24,1)/pmas(23,1))**2
57378  xw1=1d0-xw
57379  aem=pyalem(sh)
57380  IF(mstp(8).GE.1) aem=sqrt(2d0)*paru(105)*pmas(24,1)**2*xw/paru(1)
57381  as=pyalps(sh)
57382  radc=1d0+as/paru(1)
57383 
57384  IF(kfla.EQ.23) THEN
57385 C...Z0:
57386  xwc=1d0/(16d0*xw*xw1)
57387  fac=(aem*xwc/3d0)*shr
57388  120 CONTINUE
57389  DO 130 i=1,mdcy(kc,3)
57390  idc=i+mdcy(kc,2)-1
57391  IF(mdme(idc,1).LT.0) goto 130
57392  rm1=pmas(pycomp(kfdp(idc,1)),1)**2/sh
57393  rm2=pmas(pycomp(kfdp(idc,2)),1)**2/sh
57394  IF(sqrt(rm1)+sqrt(rm2).GT.1d0) goto 130
57395  IF(i.LE.8) THEN
57396 C...Z0 -> q + qbar
57397  ef=kchg(i,1)/3d0
57398  af=sign(1d0,ef+0.1d0)
57399  vf=af-4d0*ef*xwv
57400  fcof=3d0*radc
57401  IF(i.GE.6.AND.mstp(35).GE.1) fcof=fcof*pyhfth(sh,sh*rm1,1d0)
57402  ELSEIF(i.LE.16) THEN
57403 C...Z0 -> l+ + l-, nu + nubar
57404  ef=kchg(i+2,1)/3d0
57405  af=sign(1d0,ef+0.1d0)
57406  vf=af-4d0*ef*xwv
57407  fcof=1d0
57408  ENDIF
57409  be34=sqrt(max(0d0,1d0-4d0*rm1))
57410  wdtp(i)=fac*fcof*(vf**2*(1d0+2d0*rm1)+af**2*(1d0-4d0*rm1))*
57411  & be34
57412  wdtp(0)=wdtp(0)+wdtp(i)
57413  130 CONTINUE
57414 
57415 
57416  ELSEIF(kfla.EQ.24) THEN
57417 C...W+/-:
57418  fac=(aem/(24d0*xw))*shr
57419  DO 140 i=1,mdcy(kc,3)
57420  idc=i+mdcy(kc,2)-1
57421  IF(mdme(idc,1).LT.0) goto 140
57422  rm1=pmas(pycomp(kfdp(idc,1)),1)**2/sh
57423  rm2=pmas(pycomp(kfdp(idc,2)),1)**2/sh
57424  IF(sqrt(rm1)+sqrt(rm2).GT.1d0) goto 140
57425  wid2=1d0
57426  IF(i.LE.16) THEN
57427 C...W+/- -> q + qbar'
57428  fcof=3d0*radc*vckm((i-1)/4+1,mod(i-1,4)+1)
57429  ELSEIF(i.LE.20) THEN
57430 C...W+/- -> l+/- + nu
57431  fcof=1d0
57432  ENDIF
57433  wdtp(i)=fac*fcof*(2d0-rm1-rm2-(rm1-rm2)**2)*
57434  & sqrt(max(0d0,(1d0-rm1-rm2)**2-4d0*rm1*rm2))
57435  wdtp(0)=wdtp(0)+wdtp(i)
57436  140 CONTINUE
57437 
57438 C.....V8 -> quark anti-quark
57439  ELSEIF(kfla.EQ.ktechn+100021) THEN
57440  fac=as/6d0*shr
57441  tant3=rtcm(21)
57442  IF(itcm(2).EQ.0) THEN
57443  imdl=1
57444  ELSEIF(itcm(2).EQ.1) THEN
57445  imdl=2
57446  ENDIF
57447  DO 150 i=1,mdcy(kc,3)
57448  idc=i+mdcy(kc,2)-1
57449  IF(mdme(idc,1).LT.0) goto 150
57450  pm1=pmas(pycomp(kfdp(idc,1)),1)
57451  rm1=pm1**2/sh
57452  IF(rm1.GT.0.25d0) goto 150
57453  wid2=1d0
57454  IF(i.EQ.5.OR.i.EQ.6.OR.imdl.EQ.2) THEN
57455  fmix=1d0/tant3**2
57456  ELSE
57457  fmix=tant3**2
57458  ENDIF
57459  wdtp(i)=fac*(1d0+2d0*rm1)*sqrt(1d0-4d0*rm1)*fmix
57460  IF(i.EQ.6) wid2=wids(6,1)
57461  wdtp(0)=wdtp(0)+wdtp(i)
57462  150 CONTINUE
57463  ENDIF
57464 
57465  RETURN
57466  END
57467 
57468 C*********************************************************************
57469 
57470 C...PYRVSF
57471 C...Calculates R-violating decays of sfermions.
57472 C...P. Z. Skands
57473 
57474  SUBROUTINE pyrvsf(KFIN,XLAM,IDLAM,LKNT)
57475 
57476 C...Double precision and integer declarations.
57477  IMPLICIT DOUBLE PRECISION(a-h, o-z)
57478  IMPLICIT INTEGER(i-n)
57479 C...Parameter statement to help give large particle numbers.
57480  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
57481  &kexcit=4000000,kdimen=5000000)
57482 C...Commonblocks.
57483  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
57484  common/pymssm/imss(0:99),rmss(0:99)
57485  common/pyssmt/zmix(4,4),umix(2,2),vmix(2,2),smz(4),smw(2),
57486  &sfmix(16,4),zmixi(4,4),umixi(2,2),vmixi(2,2)
57487  common/pymsrv/rvlam(3,3,3), rvlamp(3,3,3), rvlamb(3,3,3)
57488 C...Local variables.
57489  DOUBLE PRECISION xlam(0:400)
57490  INTEGER idlam(400,3), pycomp
57491  SAVE /pymsrv/,/pyssmt/,/pymssm/,/pydat2/
57492 
57493 C...IS R-VIOLATION ON ?
57494  IF ((imss(51).GE.1).OR.(imss(52).GE.1).OR.(imss(53).GE.1)) THEN
57495 C...Mass eigenstate counter
57496  icnt=int(kfin/ksusy1)
57497 C...SM KF code of SUSY particle
57498  kfsm=kfin-icnt*ksusy1
57499 C...Squared Sparticle Mass
57500  sm=pmas(pycomp(kfin),1)**2
57501 C... Squared mass of top quark
57502  smt=pmas(pycomp(6),1)**2
57503 C...IS L-VIOLATION ON ?
57504  IF ((imss(51).GE.1).OR.(imss(52).GE.1)) THEN
57505 C...SLEPTON -> NU(BAR) + LEPTON and UBAR + D
57506  IF(icnt.NE.0.AND.(kfsm.EQ.11.OR.kfsm.EQ.13.OR.kfsm.EQ.15))
57507  & THEN
57508  k=int((kfsm-9)/2)
57509  DO 110 i=1,3
57510  DO 100 j=1,3
57511  IF(i.NE.j) THEN
57512 C...~e,~mu,~tau -> nu_I + lepton-_J
57513  lknt = lknt+1
57514  idlam(lknt,1)= 12 +2*(i-1)
57515  idlam(lknt,2)= 11 +2*(j-1)
57516  idlam(lknt,3)= 0
57517  xlam(lknt)=0d0
57518  rm2=rvlam(i,j,k)**2*sfmix(kfsm,2*icnt)**2 * sm
57519  IF (imss(51).NE.0) xlam(lknt) =
57520  & pyrvsb(kfin,idlam(lknt,1),idlam(lknt,2),rm2,4)
57521 C...KINEMATICS CHECK
57522  IF (xlam(lknt).EQ.0d0) THEN
57523  lknt=lknt-1
57524  ENDIF
57525  ENDIF
57526  100 CONTINUE
57527  110 CONTINUE
57528 C...~e,~mu,~tau -> nu_Ibar + lepton-_K
57529  j=int((kfsm-9)/2)
57530  DO 130 i=1,3
57531  IF(i.NE.j) THEN
57532  DO 120 k=1,3
57533  lknt = lknt+1
57534  idlam(lknt,1)=-12 -2*(i-1)
57535  idlam(lknt,2)= 11 +2*(k-1)
57536  idlam(lknt,3)= 0
57537  xlam(lknt)=0d0
57538  rm2=rvlam(i,j,k)**2*sfmix(kfsm,2*icnt-1)**2 * sm
57539  IF (imss(51).NE.0) xlam(lknt) =
57540  & pyrvsb(kfin,idlam(lknt,1),idlam(lknt,2),rm2,4)
57541 C...KINEMATICS CHECK
57542  IF (xlam(lknt).EQ.0d0) THEN
57543  lknt=lknt-1
57544  ENDIF
57545  120 CONTINUE
57546  ENDIF
57547  130 CONTINUE
57548 C...~e,~mu,~tau -> u_Jbar + d_K
57549  i=int((kfsm-9)/2)
57550  DO 150 j=1,3
57551  DO 140 k=1,3
57552  lknt = lknt+1
57553  idlam(lknt,1)=-2 -2*(j-1)
57554  idlam(lknt,2)= 1 +2*(k-1)
57555  idlam(lknt,3)= 0
57556  xlam(lknt)=0
57557  IF (imss(52).NE.0) THEN
57558 C...Use massive top quark
57559  IF (idlam(lknt,1).EQ.-6) THEN
57560  rm2=3*rvlamp(i,j,k)**2*sfmix(kfsm,2*icnt-1)**2
57561  & * (sm-smt)
57562  xlam(lknt) =
57563  & pyrvsb(kfin,idlam(lknt,1),idlam(lknt,2),rm2,3)
57564 C...If no top quark, all decay products massless
57565  ELSE
57566  rm2=3*rvlamp(i,j,k)**2*sfmix(kfsm,2*icnt-1)**2 * sm
57567  xlam(lknt) =
57568  & pyrvsb(kfin,idlam(lknt,1),idlam(lknt,2),rm2,4)
57569  ENDIF
57570 C...KINEMATICS CHECK
57571  IF (xlam(lknt).EQ.0d0) THEN
57572  lknt=lknt-1
57573  ENDIF
57574  ENDIF
57575  140 CONTINUE
57576  150 CONTINUE
57577  ENDIF
57578 C * SNEUTRINO -> LEPTON+ + LEPTON- and DBAR + D
57579 C...No right-handed neutrinos
57580  IF(icnt.EQ.1) THEN
57581  IF(kfsm.EQ.12.OR.kfsm.EQ.14.OR.kfsm.EQ.16) THEN
57582  j=int((kfsm-10)/2)
57583  DO 170 i=1,3
57584  DO 160 k=1,3
57585  IF (i.NE.j) THEN
57586 C...~nu_J -> lepton+_I + lepton-_K
57587  lknt = lknt+1
57588  idlam(lknt,1)=-11 -2*(i-1)
57589  idlam(lknt,2)= 11 +2*(k-1)
57590  idlam(lknt,3)= 0
57591  xlam(lknt)=0d0
57592  rm2=rvlam(i,j,k)**2 * sm
57593  IF (imss(51).NE.0) xlam(lknt) =
57594  & pyrvsb(kfin,idlam(lknt,1),idlam(lknt,2),rm2,4)
57595 C...KINEMATICS CHECK
57596  IF (xlam(lknt).EQ.0d0) THEN
57597  lknt=lknt-1
57598  ENDIF
57599  ENDIF
57600  160 CONTINUE
57601  170 CONTINUE
57602 C...~nu_I -> dbar_J + d_K
57603  i=int((kfsm-10)/2)
57604  DO 190 j=1,3
57605  DO 180 k=1,3
57606  lknt = lknt+1
57607  idlam(lknt,1)=-1 -2*(j-1)
57608  idlam(lknt,2)= 1 +2*(k-1)
57609  idlam(lknt,3)= 0
57610  xlam(lknt)=0d0
57611  rm2=3*rvlamp(i,j,k)**2 * sm
57612  IF (imss(52).NE.0) xlam(lknt) =
57613  & pyrvsb(kfin,idlam(lknt,1),idlam(lknt,2),rm2,4)
57614 C...KINEMATICS CHECK
57615  IF (xlam(lknt).EQ.0d0) THEN
57616  lknt=lknt-1
57617  ENDIF
57618  180 CONTINUE
57619  190 CONTINUE
57620  ENDIF
57621  ENDIF
57622 C * SDOWN -> NU(BAR) + D and LEPTON- + U
57623  IF(icnt.NE.0.AND.(kfsm.EQ.1.OR.kfsm.EQ.3.OR.kfsm.EQ.5)) THEN
57624  j=int((kfsm+1)/2)
57625  DO 210 i=1,3
57626  DO 200 k=1,3
57627 C...~d_J -> nu_Ibar + d_K
57628  lknt = lknt+1
57629  idlam(lknt,1)=-12 -2*(i-1)
57630  idlam(lknt,2)= 1 +2*(k-1)
57631  idlam(lknt,3)= 0
57632  xlam(lknt)=0d0
57633  rm2=rvlamp(i,j,k)**2*sfmix(kfsm,2*icnt-1)**2 * sm
57634  IF (imss(52).NE.0) xlam(lknt) =
57635  & pyrvsb(kfin,idlam(lknt,1),idlam(lknt,2),rm2,4)
57636 C...KINEMATICS CHECK
57637  IF (xlam(lknt).EQ.0d0) THEN
57638  lknt=lknt-1
57639  ENDIF
57640  200 CONTINUE
57641  210 CONTINUE
57642  k=int((kfsm+1)/2)
57643  DO 240 i=1,3
57644  DO 230 j=1,3
57645 C...~d_K -> nu_I + d_J
57646  lknt = lknt+1
57647  idlam(lknt,1)= 12 +2*(i-1)
57648  idlam(lknt,2)= 1 +2*(j-1)
57649  idlam(lknt,3)= 0
57650  xlam(lknt)=0d0
57651  rm2=rvlamp(i,j,k)**2*sfmix(kfsm,2*icnt)**2 * sm
57652  IF (imss(52).NE.0) xlam(lknt) =
57653  & pyrvsb(kfin,idlam(lknt,1),idlam(lknt,2),rm2,4)
57654 C...KINEMATICS CHECK
57655  IF (xlam(lknt).EQ.0d0) THEN
57656  lknt=lknt-1
57657  ENDIF
57658 C...~d_K -> lepton_I- + u_J
57659  220 lknt = lknt+1
57660  idlam(lknt,1)= 11 +2*(i-1)
57661  idlam(lknt,2)= 2 +2*(j-1)
57662  idlam(lknt,3)= 0
57663  xlam(lknt)=0d0
57664  IF (imss(52).NE.0) THEN
57665 C...Use massive top quark
57666  IF (idlam(lknt,2).EQ.6) THEN
57667  rm2=rvlamp(i,j,k)**2*sfmix(kfsm,2*icnt)**2*(sm-smt)
57668  xlam(lknt) =
57669  & pyrvsb(kfin,idlam(lknt,1),idlam(lknt,2),rm2,2)
57670 C...If no top quark, all decay products massless
57671  ELSE
57672  rm2=rvlamp(i,j,k)**2*sfmix(kfsm,2*icnt)**2 * sm
57673  xlam(lknt) =
57674  & pyrvsb(kfin,idlam(lknt,1),idlam(lknt,2),rm2,4)
57675  ENDIF
57676 C...KINEMATICS CHECK
57677  IF (xlam(lknt).EQ.0d0) THEN
57678  lknt=lknt-1
57679  ENDIF
57680  ENDIF
57681  230 CONTINUE
57682  240 CONTINUE
57683  ENDIF
57684 C * SUP -> LEPTON+ + D
57685  IF(icnt.NE.0.AND.(kfsm.EQ.2.OR.kfsm.EQ.4.OR.kfsm.EQ.6)) THEN
57686  j=nint(kfsm/2.)
57687  DO 260 i=1,3
57688  DO 250 k=1,3
57689 C...~u_J -> lepton_I+ + d_K
57690  lknt = lknt+1
57691  idlam(lknt,1)=-11 -2*(i-1)
57692  idlam(lknt,2)= 1 +2*(k-1)
57693  idlam(lknt,3)= 0
57694  xlam(lknt)=0d0
57695  rm2=rvlamp(i,j,k)**2*sfmix(kfsm,2*icnt-1)**2 * sm
57696  IF (imss(52).NE.0) xlam(lknt) =
57697  & pyrvsb(kfin,idlam(lknt,1),idlam(lknt,2),rm2,4)
57698 C...KINEMATICS CHECK
57699  IF (xlam(lknt).EQ.0d0) THEN
57700  lknt=lknt-1
57701  ENDIF
57702  250 CONTINUE
57703  260 CONTINUE
57704  ENDIF
57705  ENDIF
57706 C...BARYON NUMBER VIOLATING DECAYS
57707  IF (imss(53).GE.1) THEN
57708 C * SUP -> DBAR + DBAR
57709  IF(icnt.NE.0.AND.(kfsm.EQ.2.OR.kfsm.EQ.4.OR.kfsm.EQ.6)) THEN
57710  i = kfsm/2
57711  DO 280 j=1,3
57712  DO 270 k=1,3
57713 C...~u_I -> dbar_J + dbar_K
57714  IF (j.LT.k) THEN
57715 C...(anti-) symmetry J <-> K.
57716  lknt = lknt + 1
57717  idlam(lknt,1) = -1 -2*(j-1)
57718  idlam(lknt,2) = -1 -2*(k-1)
57719  idlam(lknt,3) = 0
57720  xlam(lknt) = 0d0
57721  rm2 = 2.*(rvlamb(i,j,k)**2)
57722  & * sfmix(kfsm,2*icnt)**2 * sm
57723  xlam(lknt) =
57724  & pyrvsb(kfin,idlam(lknt,1),idlam(lknt,2),rm2,4)
57725 C...KINEMATICS CHECK
57726  IF (xlam(lknt).EQ.0d0) THEN
57727  lknt = lknt-1
57728  ENDIF
57729  ENDIF
57730  270 CONTINUE
57731  280 CONTINUE
57732  ENDIF
57733 C * SDOWN -> UBAR + DBAR
57734  IF(icnt.NE.0.AND.(kfsm.EQ.1.OR.kfsm.EQ.3.OR.kfsm.EQ.5)) THEN
57735  k=(kfsm+1)/2
57736  DO 300 i=1,3
57737  DO 290 j=1,3
57738 C...LAMB coupling antisymmetric in J and K.
57739  IF (j.NE.k) THEN
57740 C...~d_K -> ubar_I + dbar_K
57741  lknt = lknt + 1
57742  idlam(lknt,1)= -2 -2*(i-1)
57743  idlam(lknt,2)= -1 -2*(j-1)
57744  idlam(lknt,3)= 0
57745  xlam(lknt)=0d0
57746 C...Use massive top quark
57747  IF (idlam(lknt,1).EQ.-6) THEN
57748  rm2=2*rvlamb(i,j,k)**2*sfmix(kfsm,2*icnt)**2*(sm-smt
57749  & )
57750  xlam(lknt) =
57751  & pyrvsb(kfin,idlam(lknt,1),idlam(lknt,2),rm2,3)
57752 C...If no top quark, all decay products massless
57753  ELSE
57754  rm2=2*rvlamb(i,j,k)**2*sfmix(kfsm,2*icnt)**2 * sm
57755  xlam(lknt) =
57756  & pyrvsb(kfin,idlam(lknt,1),idlam(lknt,2),rm2,4)
57757  ENDIF
57758 C...KINEMATICS CHECK
57759  IF (xlam(lknt).EQ.0d0) THEN
57760  lknt=lknt-1
57761  ENDIF
57762  ENDIF
57763  290 CONTINUE
57764  300 CONTINUE
57765  ENDIF
57766  ENDIF
57767  ENDIF
57768 
57769  RETURN
57770  END
57771 
57772 C*********************************************************************
57773 
57774 C...PYRVNE
57775 C...Calculates R-violating neutralino decay widths (pure 1->3 parts).
57776 C...P. Z. Skands
57777 
57778  SUBROUTINE pyrvne(KFIN,XLAM,IDLAM,LKNT)
57779 
57780 C...Double precision and integer declarations.
57781  IMPLICIT DOUBLE PRECISION(a-h, o-z)
57782  IMPLICIT INTEGER(i-n)
57783 C...Parameter statement to help give large particle numbers.
57784  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
57785  &kexcit=4000000,kdimen=5000000)
57786 C...Commonblocks.
57787  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
57788  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
57789  common/pymssm/imss(0:99),rmss(0:99)
57790  common/pyssmt/zmix(4,4),umix(2,2),vmix(2,2),smz(4),smw(2),
57791  &sfmix(16,4),zmixi(4,4),umixi(2,2),vmixi(2,2)
57792  common/pymsrv/rvlam(3,3,3), rvlamp(3,3,3), rvlamb(3,3,3)
57793 C...Local variables.
57794  common/pyrvnv/ab(2,16,2),rms(0:3),res(6,2),intres(6,3),idr,idr2
57795  & ,dcmass,kfr(3)
57796  DOUBLE PRECISION xlam(0:400)
57797  DOUBLE PRECISION zpmix(4,4), nmix(4,4), rmq(6)
57798  INTEGER idlam(400,3), pycomp
57799  LOGICAL dcmass
57800  SAVE /pydat1/,/pydat2/,/pymssm/,/pyssmt/,/pymsrv/,/pyrvnv/
57801 
57802 C...R-VIOLATING DECAYS
57803  IF ((imss(51).GE.1).OR.(imss(52).GE.1).OR.(imss(53).GE.1)) THEN
57804  kfsm=kfin-ksusy1
57805  IF(kfsm.EQ.22.OR.kfsm.EQ.23.OR.kfsm.EQ.25.OR.kfsm.EQ.35) THEN
57806 C...WHICH NEUTRALINO ?
57807  nchi=1
57808  IF (kfsm.EQ.23) nchi=2
57809  IF (kfsm.EQ.25) nchi=3
57810  IF (kfsm.EQ.35) nchi=4
57811 C...SIGN OF MASS (Opposite convention as HERWIG)
57812  ism = 1
57813  IF (smz(nchi).LT.0d0) ism = -ism
57814 
57815 C...Useful parameters for the calculation of the A and B constants.
57816  wmass = pmas(pycomp(24),1)
57817  echg = 2*sqrt(paru(103)*paru(1))
57818  cosb=1/(sqrt(1+rmss(5)**2))
57819  sinb=rmss(5)/sqrt(1+rmss(5)**2)
57820  cosw=sqrt(1-paru(102))
57821  sinw=sqrt(paru(102))
57822  gw=2d0*sqrt(paru(103)*paru(1))/sinw
57823 C...Run quark masses to neutralino mass squared (for Higgs-type
57824 C...couplings)
57825  sqmchi=pmas(pycomp(kfin),1)**2
57826  DO 100 i=1,6
57827  rmq(i)=pymrun(i,sqmchi)
57828  100 CONTINUE
57829 C...EXPRESS NEUTRALINO MIXING IN (photino,Zino,~H_u,~H_d) BASIS
57830  DO 110 nchj=1,4
57831  zpmix(nchj,1)= zmix(nchj,1)*cosw+zmix(nchj,2)*sinw
57832  zpmix(nchj,2)=-zmix(nchj,1)*sinw+zmix(nchj,2)*cosw
57833  zpmix(nchj,3)= zmix(nchj,3)
57834  zpmix(nchj,4)= zmix(nchj,4)
57835  110 CONTINUE
57836  c1=gw*zpmix(nchi,3)/(2d0*cosb*wmass)
57837  c1u=gw*zpmix(nchi,4)/(2d0*sinb*wmass)
57838  c2=echg*zpmix(nchi,1)
57839  c3=gw*zpmix(nchi,2)/cosw
57840  eu=2d0/3d0
57841  ed=-1d0/3d0
57842 C... AB(x,y,z):
57843 C x=1-2 : Select A or B constant (1:A ; 2:B)
57844 C y=1-16 : Sparticle's SM code (1-6:d,u,s,c,b,t ;
57845 C 11-16:e,nu_e,mu,...)
57846 C z=1-2 : Mass eigenstate number
57847 C...CALCULATE COUPLINGS
57848  DO 120 i = 11,15,2
57849  cms=pmas(pycomp(i),1)
57850 C...Intermediate sleptons
57851  ab(1,i,1)=ism*(cms*c1*sfmix(i,1) + sfmix(i,2)
57852  & *(c2-c3*sinw**2))
57853  ab(1,i,2)=ism*(cms*c1*sfmix(i,3) + sfmix(i,4)
57854  & *(c2-c3*sinw**2))
57855  ab(2,i,1)= cms*c1*sfmix(i,2) - sfmix(i,1)*(c2+c3*(5d-1-sinw
57856  & **2))
57857  ab(2,i,2)=cms*c1*sfmix(i,4) - sfmix(i,3)*(c2+c3*(5d-1-sinw
57858  & **2))
57859 C...Inermediate sneutrinos
57860  ab(1,i+1,1)=0d0
57861  ab(2,i+1,1)=5d-1*c3
57862  ab(1,i+1,2)=0d0
57863  ab(2,i+1,2)=0d0
57864 C...Inermediate sdown
57865  j=i-10
57866  cms=rmq(j)
57867  ab(1,j,1)=ism*(cms*c1*sfmix(j,1) - sfmix(j,2)
57868  & *ed*(c2-c3*sinw**2))
57869  ab(1,j,2)=ism*(cms*c1*sfmix(j,3) - sfmix(j,4)
57870  & *ed*(c2-c3*sinw**2))
57871  ab(2,j,1)=cms*c1*sfmix(j,2) + sfmix(j,1)
57872  & *(ed*c2-c3*(1d0/2d0+ed*sinw**2))
57873  ab(2,j,2)=cms*c1*sfmix(j,4) + sfmix(j,3)
57874  & *(ed*c2-c3*(1d0/2d0+ed*sinw**2))
57875 C...Inermediate sup
57876  j=j+1
57877  cms=rmq(j)
57878  ab(1,j,1)=ism*(cms*c1u*sfmix(j,1) - sfmix(j,2)
57879  & *eu*(c2-c3*sinw**2))
57880  ab(1,j,2)=ism*(cms*c1u*sfmix(j,3) - sfmix(j,4)
57881  & *eu*(c2-c3*sinw**2))
57882  ab(2,j,1)=cms*c1u*sfmix(j,2) + sfmix(j,1)
57883  & *(eu*c2+c3*(1d0/2d0-eu*sinw**2))
57884  ab(2,j,2)=cms*c1u*sfmix(j,4) + sfmix(j,3)
57885  & *(eu*c2+c3*(1d0/2d0-eu*sinw**2))
57886  120 CONTINUE
57887 
57888  IF (imss(51).GE.1) THEN
57889 C...LAMBDA COUPLINGS (LLE TYPE R-VIOLATION)
57890 C * CHI0_I -> NUBAR_I + LEPTON+_J + lEPTON-_K.
57891 C...STEP IN I,J,K USING SINGLE COUNTER
57892  DO 130 isc=0,26
57893 C...LAMBDA COUPLING ASYM IN I,J
57894  IF(mod(isc/9,3).NE.mod(isc/3,3)) THEN
57895  lknt = lknt+1
57896  idlam(lknt,1) =-12 -2*mod(isc/9,3)
57897  idlam(lknt,2) =-11 -2*mod(isc/3,3)
57898  idlam(lknt,3) = 11 +2*mod(isc,3)
57899  xlam(lknt) = 0d0
57900 C...Set coupling, and decay product masses on/off
57901  rvlamc = rvlam(mod(isc/9,3)+1,mod(isc/3,3)+1
57902  & ,mod(isc,3)+1)**2
57903  dcmass=.false.
57904  IF (idlam(lknt,2).EQ.-15.OR.idlam(lknt,3).EQ.15)
57905  & dcmass = .true.
57906 C...Resonance KF codes (1=I,2=J,3=K)
57907  kfr(1)=-idlam(lknt,1)
57908  kfr(2)=-idlam(lknt,2)
57909  kfr(3)=-idlam(lknt,3)
57910 C...Calculate width.
57911  CALL pyrvgw(kfin,idlam(lknt,1),idlam(lknt,2),
57912  & idlam(lknt,3),xlam(lknt))
57913  xlam(lknt)=xlam(lknt)*rvlamc/((2*paru(1)*rms(0))**3*32)
57914 C...Charge conjugate mode.
57915  lknt=lknt+1
57916  idlam(lknt,1)=-idlam(lknt-1,1)
57917  idlam(lknt,2)=-idlam(lknt-1,2)
57918  idlam(lknt,3)=-idlam(lknt-1,3)
57919  xlam(lknt)=xlam(lknt-1)
57920 C...KINEMATICS CHECK
57921  IF (xlam(lknt).EQ.0d0) THEN
57922  lknt=lknt-2
57923  ENDIF
57924  ENDIF
57925  130 CONTINUE
57926  ENDIF
57927 
57928  IF (imss(52).GE.1) THEN
57929 C...LAMBDA' COUPLINGS. (LQD TYPE R-VIOLATION)
57930 C * CHI0 -> NUBAR_I + DBAR_J + D_K
57931  DO 140 isc=0,26
57932  lknt = lknt+1
57933  idlam(lknt,1) =-12 -2*mod(isc/9,3)
57934  idlam(lknt,2) = -1 -2*mod(isc/3,3)
57935  idlam(lknt,3) = 1 +2*mod(isc,3)
57936  xlam(lknt) = 0d0
57937 C...Set coupling, and decay product masses on/off
57938  rvlamc = 3 * rvlamp(mod(isc/9,3)+1,mod(isc/3,3)+1
57939  & ,mod(isc,3)+1)**2
57940  dcmass=.false.
57941  IF (idlam(lknt,2).EQ.-5.OR.idlam(lknt,3).EQ.5)
57942  & dcmass = .true.
57943 C...Resonance KF codes (1=I,2=J,3=K)
57944  kfr(1)=-idlam(lknt,1)
57945  kfr(2)=-idlam(lknt,2)
57946  kfr(3)=-idlam(lknt,3)
57947 C...Calculate width.
57948  CALL pyrvgw(kfin,idlam(lknt,1),idlam(lknt,2),idlam(lknt,3)
57949  & ,xlam(lknt))
57950  xlam(lknt)=xlam(lknt)*rvlamc/((2*paru(1)*rms(0))**3*32)
57951 C...Charge conjugate mode.
57952  lknt=lknt+1
57953  idlam(lknt,1)=-idlam(lknt-1,1)
57954  idlam(lknt,2)=-idlam(lknt-1,2)
57955  idlam(lknt,3)=-idlam(lknt-1,3)
57956  xlam(lknt)=xlam(lknt-1)
57957 C...KINEMATICS CHECK
57958  IF (xlam(lknt).EQ.0d0) THEN
57959  lknt=lknt-2
57960  ENDIF
57961 
57962 C * CHI0 -> LEPTON_I+ + UBAR_J + D_K
57963  lknt = lknt+1
57964  idlam(lknt,1) =-11 -2*mod(isc/9,3)
57965  idlam(lknt,2) = -2 -2*mod(isc/3,3)
57966  idlam(lknt,3) = 1 +2*mod(isc,3)
57967  xlam(lknt) = 0d0
57968 C...Set coupling, and decay product masses on/off
57969  rvlamc = 3 * rvlamp(mod(isc/9,3)+1,mod(isc/3,3)+1
57970  & ,mod(isc,3)+1)**2
57971  dcmass=.false.
57972  IF (idlam(lknt,1).EQ.-15.OR.idlam(lknt,2).EQ.-6
57973  & .OR.idlam(lknt,3).EQ.5) dcmass=.true.
57974 C...Resonance KF codes (1=I,2=J,3=K)
57975  kfr(1)=-idlam(lknt,1)
57976  kfr(2)=-idlam(lknt,2)
57977  kfr(3)=-idlam(lknt,3)
57978 C...Calculate width.
57979  CALL pyrvgw(kfin,idlam(lknt,1),idlam(lknt,2),idlam(lknt,3)
57980  & ,xlam(lknt))
57981  xlam(lknt)=xlam(lknt)*rvlamc/((2*paru(1)*rms(0))**3*32)
57982 C...Charge conjugate mode.
57983  lknt=lknt+1
57984  idlam(lknt,1)=-idlam(lknt-1,1)
57985  idlam(lknt,2)=-idlam(lknt-1,2)
57986  idlam(lknt,3)=-idlam(lknt-1,3)
57987  xlam(lknt)=xlam(lknt-1)
57988 C...KINEMATICS CHECK
57989  IF (xlam(lknt).EQ.0d0) THEN
57990  lknt=lknt-2
57991  ENDIF
57992  140 CONTINUE
57993  ENDIF
57994 
57995  IF (imss(53).GE.1) THEN
57996 C...LAMBDA'' COUPLINGS. (UDD TYPE R-VIOLATION)
57997 C * CHI0 -> UBAR_I + DBAR_J + DBAR_K
57998  DO 150 isc=0,26
57999 C...Symmetry J<->K. Also, LAMB antisymmetric in J and K, so no J=K.
58000  IF (mod(isc/3,3).LT.mod(isc,3)) THEN
58001  lknt = lknt+1
58002  idlam(lknt,1) = -2 -2*mod(isc/9,3)
58003  idlam(lknt,2) = -1 -2*mod(isc/3,3)
58004  idlam(lknt,3) = -1 -2*mod(isc,3)
58005  xlam(lknt) = 0d0
58006 C...Set coupling, and decay product masses on/off
58007  rvlamc = 6. * rvlamb(mod(isc/9,3)+1,mod(isc/3,3)
58008  & +1,mod(isc,3)+1)**2
58009  dcmass=.false.
58010  IF (idlam(lknt,1).EQ.-6.OR.idlam(lknt,2).EQ.-5
58011  & .OR.idlam(lknt,3).EQ.-5) dcmass=.true.
58012 C...Resonance KF codes (1=I,2=J,3=K)
58013  kfr(1) = idlam(lknt,1)
58014  kfr(2) = idlam(lknt,2)
58015  kfr(3) = idlam(lknt,3)
58016 C...Calculate width.
58017  CALL pyrvgw(kfin,idlam(lknt,1),idlam(lknt,2),
58018  & idlam(lknt,3),xlam(lknt))
58019  xlam(lknt)=xlam(lknt)*rvlamc/((2*paru(1)*rms(0))**3*32)
58020 C...Charge conjugate mode.
58021  lknt=lknt+1
58022  idlam(lknt,1)=-idlam(lknt-1,1)
58023  idlam(lknt,2)=-idlam(lknt-1,2)
58024  idlam(lknt,3)=-idlam(lknt-1,3)
58025  xlam(lknt)=xlam(lknt-1)
58026 C...KINEMATICS CHECK
58027  IF (xlam(lknt).EQ.0d0) THEN
58028  lknt=lknt-2
58029  ENDIF
58030  ENDIF
58031  150 CONTINUE
58032  ENDIF
58033  ENDIF
58034  ENDIF
58035 
58036  RETURN
58037  END
58038 
58039 C*********************************************************************
58040 
58041 C...PYRVCH
58042 C...Calculates R-violating chargino decay widths.
58043 C...P. Z. Skands
58044 
58045  SUBROUTINE pyrvch(KFIN,XLAM,IDLAM,LKNT)
58046 
58047 C...Double precision and integer declarations.
58048  IMPLICIT DOUBLE PRECISION(a-h, o-z)
58049  IMPLICIT INTEGER(i-n)
58050 C...Parameter statement to help give large particle numbers.
58051  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
58052  &kexcit=4000000,kdimen=5000000)
58053 C...Commonblocks.
58054  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
58055  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
58056  common/pymssm/imss(0:99),rmss(0:99)
58057  common/pyssmt/zmix(4,4),umix(2,2),vmix(2,2),smz(4),smw(2),
58058  &sfmix(16,4),zmixi(4,4),umixi(2,2),vmixi(2,2)
58059  common/pymsrv/rvlam(3,3,3), rvlamp(3,3,3), rvlamb(3,3,3)
58060 C...Local variables.
58061  DOUBLE PRECISION xlam(0:400)
58062  INTEGER idlam(400,3), pycomp
58063 C...Information from main routine to PYRVGW
58064  common/pyrvnv/ab(2,16,2),rms(0:3),res(6,2),intres(6,3),idr,idr2
58065  & ,dcmass,kfr(3)
58066 C...Auxiliary variables needed for BV (RV Gauge STOre)
58067  common/rvgsto/xresi,xresj,xresk,xresij,xresik,xresjk,rvlijk,rvlkij
58068  & ,rvljki,rvljik
58069 C...Running quark masses
58070  DOUBLE PRECISION rmq(6)
58071 C...Decay product masses on/off
58072  LOGICAL dcmass
58073  SAVE /pydat1/,/pydat2/,/pymssm/,/pyssmt/,/pymsrv/,/pyrvnv/,
58074  & /rvgsto/
58075 
58076 
58077 C...IF R-VIOLATION ON.
58078  IF ((imss(51).GE.1).OR.(imss(52).GE.1).OR.(imss(53).GE.1)) THEN
58079  kfsm=kfin-ksusy1
58080  IF(kfsm.EQ.24.OR.kfsm.EQ.37) THEN
58081 C...WHICH CHARGINO ?
58082  nchi = 1
58083  IF (kfsm.EQ.37) nchi = 2
58084 
58085 C...Useful parameters for calculating the A and B constants.
58086 C...SIGN OF MASS (Opposite convention as HERWIG)
58087  ism = 1
58088  IF (smw(nchi).LT.0d0) ism = -1
58089  wmass = pmas(pycomp(24),1)
58090  cosb = 1/(sqrt(1+rmss(5)**2))
58091  sinb = rmss(5)/sqrt(1+rmss(5)**2)
58092  gw2 = 4*paru(103)*paru(1)/paru(102)
58093  c1u = umix(nchi,2)/(sqrt(2d0)*cosb*wmass)
58094  c1v = vmix(nchi,2)/(sqrt(2d0)*sinb*wmass)
58095  c2 = umix(nchi,1)
58096  c3 = vmix(nchi,1)
58097 C...Running masses at Q^2=MCHI^2.
58098  sqmchi = pmas(pycomp(kfsm),1)**2
58099  DO 100 i=1,6
58100  rmq(i)=pymrun(i,sqmchi)
58101  100 CONTINUE
58102 
58103 C... AB(x,y,z) coefficients:
58104 C x=1-2 : A or B coefficient (1:A ; 2:B)
58105 C y=1-16 : Sparticle's SM code (1-6:d,u,s,c,b,t ;
58106 C 11-16:e,nu_e,mu,...)
58107 C z=1-2 : Mass eigenstate number
58108  DO 110 i = 11,15,2
58109 C...Intermediate sleptons
58110  ab(1,i,1) = 0d0
58111  ab(1,i,2) = 0d0
58112  ab(2,i,1) = -pmas(pycomp(i),1)*c1u*sfmix(i,2) +
58113  & sfmix(i,1)*c2
58114  ab(2,i,2) = -pmas(pycomp(i),1)*c1u*sfmix(i,4) +
58115  & sfmix(i,3)*c2
58116 C...Intermediate sneutrinos
58117  ab(1,i+1,1) = -pmas(pycomp(i),1)*c1u
58118  ab(1,i+1,2) = 0d0
58119  ab(2,i+1,1) = ism*c3
58120  ab(2,i+1,2) = 0d0
58121 C...Intermediate sdown
58122  j=i-10
58123  ab(1,j,1) = -rmq(j+1)*c1v*sfmix(j,1)
58124  ab(1,j,2) = -rmq(j+1)*c1v*sfmix(j,3)
58125  ab(2,j,1) = -ism*(rmq(j)*c1u*sfmix(j,2) - sfmix(j,1)*c2)
58126  ab(2,j,2) = -ism*(rmq(j)*c1u*sfmix(j,4) - sfmix(j,3)*c2)
58127 C...Intermediate sup
58128  j=j+1
58129  ab(1,j,1) = -rmq(j-1)*c1u*sfmix(j,1)
58130  ab(1,j,2) = -rmq(j-1)*c1u*sfmix(j,3)
58131  ab(2,j,1) = -ism*(rmq(j)*c1v*sfmix(j,2) - sfmix(j,1)*c3)
58132  ab(2,j,2) = -ism*(rmq(j)*c1v*sfmix(j,4) - sfmix(j,3)*c3)
58133  110 CONTINUE
58134 
58135 C...LLE TYPE R-VIOLATION
58136  IF (imss(51).GE.1) THEN
58137 C...LOOP OVER DECAY MODES
58138  DO 140 isc=0,26
58139 
58140 C...CHI+ -> NUBAR_I + LEPTON+_J + NU_K.
58141  IF(mod(isc/9,3).NE.mod(isc/3,3)) THEN
58142  lknt = lknt+1
58143  idlam(lknt,1) = -12 -2*mod(isc/9,3)
58144  idlam(lknt,2) = -11 -2*mod(isc/3,3)
58145  idlam(lknt,3) = 12 +2*mod(isc,3)
58146  xlam(lknt) = 0d0
58147 C...Set coupling, and decay product masses on/off
58148  rvlamc = gw2 * 5d-1 *
58149  & rvlam(mod(isc/9,3)+1,mod(isc/3,3)+1,mod(isc,3)+1)
58150  & **2
58151  dcmass=.false.
58152  IF (idlam(lknt,2).EQ.-15) dcmass = .true.
58153 C...Resonance KF codes (1=I,2=J,3=K).
58154  kfr(1) = 0
58155  kfr(2) = 0
58156  kfr(3) = -idlam(lknt,3)+1
58157 C...Calculate width.
58158  CALL pyrvgw(kfin,idlam(lknt,1),idlam(lknt,2),
58159  & idlam(lknt,3),xlam(lknt))
58160  xlam(lknt)=xlam(lknt)*rvlamc/((2*paru(1)*rms(0))**3*32)
58161 C...KINEMATICS CHECK
58162  IF (xlam(lknt).EQ.0d0) THEN
58163  lknt=lknt-1
58164  ENDIF
58165 
58166 C * CHI+ -> NU_I + NU_J + LEPTON+_K. (NOTE: SYMM. IN I AND J)
58167  120 IF (mod(isc/9,3).LT.mod(isc/3,3)) THEN
58168  lknt = lknt+1
58169  idlam(lknt,1) = 12 +2*mod(isc/9,3)
58170  idlam(lknt,2) = 12 +2*mod(isc/3,3)
58171  idlam(lknt,3) =-11 -2*mod(isc,3)
58172  xlam(lknt) = 0d0
58173 C...Set coupling, and decay product masses on/off
58174  rvlamc = gw2 * 5d-1 *
58175  & rvlam(mod(isc/9,3)+1,mod(isc/3,3)+1,mod(isc,3)+1)**2
58176 C...I,J SYMMETRY => FACTOR 2
58177  rvlamc=2*rvlamc
58178  dcmass=.false.
58179  IF (idlam(lknt,3).EQ.-15) dcmass = .true.
58180 C...Resonance KF codes (1=I,2=J,3=K)
58181  kfr(1)=idlam(lknt,1)-1
58182  kfr(2)=idlam(lknt,2)-1
58183  kfr(3)=0
58184 C...Calculate width.
58185  CALL pyrvgw(kfin,idlam(lknt,1),idlam(lknt,2),
58186  & idlam(lknt,3),xlam(lknt))
58187  xlam(lknt)=xlam(lknt)*rvlamc/((2*paru(1)*rms(0))**3*32)
58188 C...KINEMATICS CHECK
58189  IF (xlam(lknt).EQ.0d0) THEN
58190  lknt=lknt-1
58191  ENDIF
58192 
58193 C * CHI+ -> LEPTON+_I + LEPTON+_J + LEPTON-_K (NOTE: SYMM. IN I AND J)
58194 C * 19/04 2010: Bug corrected. Moved channel inside the I < J IF statement
58195 C * from above, thanks to N.-E. Bomark.
58196  lknt = lknt+1
58197  idlam(lknt,1) =-11 -2*mod(isc/9,3)
58198  idlam(lknt,2) =-11 -2*mod(isc/3,3)
58199  idlam(lknt,3) = 11 +2*mod(isc,3)
58200  xlam(lknt) = 0d0
58201 C...Set coupling, and decay product masses on/off
58202  rvlamc = gw2 * 5d-1 *
58203  & rvlam(mod(isc/9,3)+1,mod(isc/3,3)+1,mod(isc,3)+1)**2
58204 C...I,J SYMMETRY => FACTOR 2
58205  rvlamc=2*rvlamc
58206  dcmass=.false.
58207  IF (idlam(lknt,1).EQ.-15.OR.idlam(lknt,2).EQ.-15
58208  & .OR.idlam(lknt,3).EQ.15) dcmass = .true.
58209 C...Resonance KF codes (1=I,2=J,3=K)
58210  kfr(1) =-idlam(lknt,1)+1
58211  kfr(2) =-idlam(lknt,2)+1
58212  kfr(3) = 0
58213 C...Calculate width.
58214  CALL pyrvgw(kfin,idlam(lknt,1),idlam(lknt,2),
58215  & idlam(lknt,3),xlam(lknt))
58216  xlam(lknt)=xlam(lknt)*rvlamc
58217  & /((2*paru(1)*rms(0))**3*32)
58218 C...KINEMATICS CHECK
58219  IF (xlam(lknt).EQ.0d0) THEN
58220  lknt=lknt-1
58221  ENDIF
58222  ENDIF
58223  ENDIF
58224  140 CONTINUE
58225  ENDIF
58226 
58227 C...LQD TYPE R-VIOLATION
58228  IF (imss(52).GE.1) THEN
58229 C...LOOP OVER DECAY MODES
58230  DO 180 isc=0,26
58231 
58232 C...CHI+ -> NUBAR_I + DBAR_J + U_K
58233  lknt = lknt+1
58234  idlam(lknt,1) =-12 -2*mod(isc/9,3)
58235  idlam(lknt,2) = -1 -2*mod(isc/3,3)
58236  idlam(lknt,3) = 2 +2*mod(isc,3)
58237  xlam(lknt) = 0d0
58238 C...Set coupling, and decay product masses on/off
58239  rvlamc = 3. * gw2 * 5d-1 *
58240  & rvlamp(mod(isc/9,3)+1,mod(isc/3,3)+1,mod(isc,3)+1)**2
58241  dcmass=.false.
58242  IF (idlam(lknt,2).EQ.-5.OR.idlam(lknt,3).EQ.6)
58243  & dcmass = .true.
58244 C...Resonance KF codes (1=I,2=J,3=K)
58245  kfr(1)=0
58246  kfr(2)=0
58247  kfr(3)=-idlam(lknt,3)+1
58248 C...Calculate width.
58249  CALL pyrvgw(kfin,idlam(lknt,1),idlam(lknt,2),idlam(lknt,3)
58250  & ,xlam(lknt))
58251  xlam(lknt)=xlam(lknt)*rvlamc/((2*paru(1)*rms(0))**3*32)
58252 C...KINEMATICS CHECK
58253  IF (xlam(lknt).EQ.0d0) THEN
58254  lknt=lknt-1
58255  ENDIF
58256 
58257 C * CHI+ -> LEPTON+_I + UBAR_J + U_K.
58258  150 lknt = lknt+1
58259  idlam(lknt,1) =-11 -2*mod(isc/9,3)
58260  idlam(lknt,2) = -2 -2*mod(isc/3,3)
58261  idlam(lknt,3) = 2 +2*mod(isc,3)
58262  xlam(lknt) = 0d0
58263 C...Set coupling, and decay product masses on/off
58264  rvlamc = 3. * gw2 * 5d-1 *
58265  & rvlamp(mod(isc/9,3)+1,mod(isc/3,3)+1,mod(isc,3)+1)**2
58266  dcmass=.false.
58267  IF (idlam(lknt,1).EQ.-11.OR.idlam(lknt,2).EQ.-6
58268  & .OR.idlam(lknt,3).EQ.6) dcmass = .true.
58269 C...Resonance KF codes (1=I,2=J,3=K)
58270  kfr(1)=0
58271  kfr(2)=0
58272  kfr(3)=-idlam(lknt,3)+1
58273 C...Calculate width.
58274  CALL pyrvgw(kfin,idlam(lknt,1),idlam(lknt,2),idlam(lknt,3)
58275  & ,xlam(lknt))
58276  xlam(lknt)=xlam(lknt)*rvlamc/((2*paru(1)*rms(0))**3*32)
58277 C...KINEMATICS CHECK
58278  IF (xlam(lknt).EQ.0d0) THEN
58279  lknt=lknt-1
58280  ENDIF
58281 
58282 C * CHI+ -> LEPTON+_I + DBAR_J + D_K.
58283  160 lknt = lknt+1
58284  idlam(lknt,1) =-11 -2*mod(isc/9,3)
58285  idlam(lknt,2) = -1 -2*mod(isc/3,3)
58286  idlam(lknt,3) = 1 +2*mod(isc,3)
58287  xlam(lknt) = 0d0
58288 C...Set coupling, and decay product masses on/off
58289  rvlamc = 3. * gw2 * 5d-1 *
58290  & rvlamp(mod(isc/9,3)+1,mod(isc/3,3)+1,mod(isc,3)+1)**2
58291  dcmass = .false.
58292  IF (idlam(lknt,1).EQ.-15.OR.idlam(lknt,2).EQ.-5
58293  & .OR.idlam(lknt,3).EQ.5) dcmass = .true.
58294 C...Resonance KF codes (1=I,2=J,3=K)
58295  kfr(1)=-idlam(lknt,1)+1
58296  kfr(2)=-idlam(lknt,2)+1
58297  kfr(3)=0
58298 C...Calculate width.
58299  CALL pyrvgw(kfin,idlam(lknt,1),idlam(lknt,2),idlam(lknt,3)
58300  & ,xlam(lknt))
58301  xlam(lknt)=xlam(lknt)*rvlamc/((2*paru(1)*rms(0))**3*32)
58302 C...KINEMATICS CHECK
58303  IF (xlam(lknt).EQ.0d0) THEN
58304  lknt=lknt-1
58305  ENDIF
58306 
58307 C * CHI+ -> NU_I + U_J + DBAR_K.
58308  170 lknt = lknt+1
58309  idlam(lknt,1) = 12 +2*mod(isc/9,3)
58310  idlam(lknt,2) = 2 +2*mod(isc/3,3)
58311  idlam(lknt,3) = -1 -2*mod(isc,3)
58312  xlam(lknt) = 0d0
58313 C...Set coupling, and decay product masses on/off
58314  dcmass = .false.
58315  rvlamc = 3. * gw2 * 5d-1 *
58316  & rvlamp(mod(isc/9,3)+1,mod(isc/3,3)+1,mod(isc,3)+1)**2
58317  IF (idlam(lknt,2).EQ.6.OR.idlam(lknt,3).EQ.-5)
58318  & dcmass = .true.
58319 C...Resonance KF codes (1=I,2=J,3=K)
58320  kfr(1)=idlam(lknt,1)-1
58321  kfr(2)=idlam(lknt,2)-1
58322  kfr(3)=0
58323 C...Calculate width.
58324  CALL pyrvgw(kfin,idlam(lknt,1),idlam(lknt,2),idlam(lknt,3)
58325  & ,xlam(lknt))
58326  xlam(lknt)=xlam(lknt)*rvlamc/((2*paru(1)*rms(0))**3*32)
58327 C...KINEMATICS CHECK
58328  IF (xlam(lknt).EQ.0d0) THEN
58329  lknt=lknt-1
58330  ENDIF
58331 
58332  180 CONTINUE
58333  ENDIF
58334 
58335 C...UDD TYPE R-VIOLATION
58336 C...These decays need special treatment since more than one BV coupling
58337 C...contributes (with interference). Consider e.g. (symbolically)
58338 C |M|^2 = |l''_{ijk}|^2*(PYRVI1(RES_I) + PYRVI2(RES_I))
58339 C +|l''_{jik}|^2*(PYRVI1(RES_J) + PYRVI2(RES_J))
58340 C +l''_{ijk}*l''_{jik}*PYRVI3(PYRVI4(RES_I,RES_J))
58341 C...The problem is that a single call to PYRVGW would evaluate all
58342 C...these terms and sum them, but without the different couplings. The
58343 C...way out is to call PYRVGW three times, once for the first line, once
58344 C...for the second line, and then once for all the lines (it is
58345 C...impossible to get just the last line out) without multiplying by
58346 C...couplings. The last line is then obtained as the result of the third
58347 C...call minus the results of the two first calls. Each term is then
58348 C...multiplied by its respective coupling before the whole thing is
58349 C...summed up in XLAM.
58350 C...Note that with three interfering resonances, this procedure becomes
58351 C...more complicated, as can be seen in the CHI+ -> 3*DBAR mode.
58352 
58353  IF (imss(53).GE.1) THEN
58354 C...LOOP OVER DECAY MODES
58355  DO 190 isc=1,25
58356 
58357 C...CHI+ -> U_I + U_J + D_K
58358 C...Decay mode I<->J symmetric.
58359  IF (mod(isc/9,3).LE.mod(isc/3,3).AND.isc.NE.13) THEN
58360  lknt = lknt+1
58361  idlam(lknt,1) = 2 +2*mod(isc/9,3)
58362  idlam(lknt,2) = 2 +2*mod(isc/3,3)
58363  idlam(lknt,3) = 1 +2*mod(isc,3)
58364  xlam(lknt) = 0d0
58365 C...Set coupling, and decay product masses on/off
58366  rvlamc= 6. * gw2 * 5d-1
58367  rvljik= rvlamb(mod(isc/3,3)+1,mod(isc/9,3)+1,mod(isc,3)
58368  & +1)
58369  rvlijk= rvlamb(mod(isc/9,3)+1,mod(isc/3,3)+1,mod(isc,3)
58370  & +1)
58371  IF (mod(isc/9,3).EQ.mod(isc/3,3)) rvlamc = 5d-1
58372  & * rvlamc
58373  dcmass=.false.
58374  IF (idlam(lknt,1).EQ.6.OR.idlam(lknt,2).EQ.6
58375  & .OR.idlam(lknt,3).EQ.5) dcmass =.true.
58376 C...Resonance KF codes (1=I,2=J,3=K)
58377  kfr(1) = -idlam(lknt,1)+1
58378  kfr(2) = 0
58379  kfr(3) = 0
58380 C...Calculate width.
58381  CALL pyrvgw(kfin,idlam(lknt,1),idlam(lknt,2),
58382  & idlam(lknt,3),xresi)
58383 C...Resonance KF codes (1=I,2=J,3=K)
58384  kfr(1) = 0
58385  kfr(2) = -idlam(lknt,2)+1
58386  kfr(3) = 0
58387 C...Calculate width.
58388  CALL pyrvgw(kfin,idlam(lknt,1),idlam(lknt,2),
58389  & idlam(lknt,3),xresj)
58390 C...Resonance KF codes (1=I,2=J,3=K)
58391  kfr(1) = -idlam(lknt,1)+1
58392  kfr(2) = -idlam(lknt,2)+1
58393  kfr(3) = 0
58394 C...Calculate width.
58395  CALL pyrvgw(kfin,idlam(lknt,1),idlam(lknt,2),
58396  & idlam(lknt,3),xresij)
58397  IF (abs(xresi+xresj-xresij).GT.1d-4*xresij) THEN
58398  xresij = xresij-xresi-xresj
58399  ELSE
58400  xresij = 0d0
58401  ENDIF
58402 C...CALCULATE TOTAL WIDTH
58403  xlam(lknt) = rvljik**2 * xresi + rvlijk**2 * xresj
58404  & + rvljik*rvlijk * xresij
58405  xlam(lknt)=xlam(lknt)*rvlamc/((2*paru(1)*rms(0))**3*32)
58406 C...KINEMATICS CHECK
58407  IF (xlam(lknt).EQ.0d0) THEN
58408  lknt=lknt-1
58409  ENDIF
58410  ENDIF
58411 C...CHI+ -> DBAR_I + DBAR_J + DBAR_K
58412 C...Symmetry I<->J<->K.
58413  IF ((mod(isc/9,3).LE.mod(isc/3,3)).AND.(mod(isc/3,3).le
58414  & .mod(isc,3)).AND.isc.NE.13) THEN
58415  lknt = lknt+1
58416  idlam(lknt,1) = -1 -2*mod(isc/9,3)
58417  idlam(lknt,2) = -1 -2*mod(isc/3,3)
58418  idlam(lknt,3) = -1 -2*mod(isc,3)
58419  xlam(lknt) = 0d0
58420 C...Set coupling, and decay product masses on/off
58421  rvlamc = 6. * gw2 * 5d-1
58422  rvlijk = rvlamb(mod(isc/9,3)+1,mod(isc/3,3)+1,mod(isc,3)
58423  & +1)
58424  rvlkij = rvlamb(mod(isc,3)+1,mod(isc/9,3)+1,mod(isc/3,3)
58425  & +1)
58426  rvljki = rvlamb(mod(isc/3,3)+1,mod(isc,3)+1,mod(isc/9,3)
58427  & +1)
58428  dcmass = .false.
58429  IF (idlam(lknt,1).EQ.-5.OR.idlam(lknt,2).EQ.-5
58430  & .OR.idlam(lknt,3).EQ.-5) dcmass = .true.
58431 C...Collect symmetry factors
58432  IF (mod(isc/9,3).EQ.mod(isc/3,3).OR.mod(isc/3,3).eq
58433  & .mod(isc,3).OR.mod(isc/9,3).EQ.mod(isc,3))
58434  & rvlamc = 5d-1 * rvlamc
58435 C...Resonance KF codes (1=I,2=J,3=K)
58436  kfr(1) = idlam(lknt,1)-1
58437  kfr(2) = 0
58438  kfr(3) = 0
58439 C...Calculate width.
58440  CALL pyrvgw(kfin,idlam(lknt,1),idlam(lknt,2),
58441  & idlam(lknt,3),xresi)
58442 C...Resonance KF codes (1=I,2=J,3=K)
58443  kfr(1) = 0
58444  kfr(2) = idlam(lknt,2)-1
58445  kfr(3) = 0
58446 C...Calculate width.
58447  CALL pyrvgw(kfin,idlam(lknt,1),idlam(lknt,2),
58448  & idlam(lknt,3),xresj)
58449 C...Resonance KF codes (1=I,2=J,3=K)
58450  kfr(1) = 0
58451  kfr(2) = 0
58452  kfr(3) = idlam(lknt,3)-1
58453 C...Calculate width.
58454  CALL pyrvgw(kfin,idlam(lknt,1),idlam(lknt,2),
58455  & idlam(lknt,3),xresk)
58456 C...Resonance KF codes (1=I,2=J,3=K)
58457  kfr(1) = idlam(lknt,1)-1
58458  kfr(2) = idlam(lknt,2)-1
58459  kfr(3) = 0
58460 C...Calculate width.
58461  CALL pyrvgw(kfin,idlam(lknt,1),idlam(lknt,2),
58462  & idlam(lknt,3),xresij)
58463  IF (abs(xresi+xresj-xresij).GT.1d-4*(xresi+xresj)) THEN
58464  xresij = xresi+xresj-xresij
58465  ELSE
58466  xresij = 0d0
58467  ENDIF
58468 C...Resonance KF codes (1=I,2=J,3=K)
58469  kfr(1) = 0
58470  kfr(2) = idlam(lknt,2)-1
58471  kfr(3) = idlam(lknt,3)-1
58472 C...Calculate width.
58473  CALL pyrvgw(kfin,idlam(lknt,1),idlam(lknt,2),
58474  & idlam(lknt,3),xresjk)
58475  IF (abs(xresj+xresk-xresjk).GT.1d-4*(xresj+xresk)) THEN
58476  xresjk = xresj+xresk-xresjk
58477  ELSE
58478  xresjk = 0d0
58479  ENDIF
58480 C...Resonance KF codes (1=I,2=J,3=K)
58481  kfr(1) = idlam(lknt,1)-1
58482  kfr(2) = 0
58483  kfr(3) = idlam(lknt,3)-1
58484 C...Calculate width.
58485  CALL pyrvgw(kfin,idlam(lknt,1),idlam(lknt,2),
58486  & idlam(lknt,3),xresik)
58487  IF (abs(xresi+xresk-xresik).GT.1d-4*(xresi+xresk)) THEN
58488  xresik = xresi+xresk-xresik
58489  ELSE
58490  xresik = 0d0
58491  ENDIF
58492 C...CALCULATE TOTAL WIDTH
58493  xlam(lknt) =
58494  & rvlijk**2 * xresi
58495  & + rvljki**2 * xresj
58496  & + rvlkij**2 * xresk
58497  & + rvlijk*rvljki * xresij
58498  & + rvlijk*rvlkij * xresik
58499  & + rvljki*rvlkij * xresjk
58500  xlam(lknt)=xlam(lknt)*rvlamc/((2.*paru(1)*rms(0))**3*32)
58501 C...KINEMATICS CHECK
58502  IF (xlam(lknt).EQ.0d0) THEN
58503  lknt=lknt-1
58504  ENDIF
58505  ENDIF
58506  190 CONTINUE
58507  ENDIF
58508  ENDIF
58509  ENDIF
58510 
58511  RETURN
58512  END
58513 
58514 C*********************************************************************
58515 
58516 C...PYRVGL
58517 C...Calculates R-violating gluino decay widths.
58518 C...See BV part of PYRVCH for comments about the way the BV decay width
58519 C...is calculated. Same comments apply here.
58520 C...P. Z. Skands
58521 
58522  SUBROUTINE pyrvgl(KFIN,XLAM,IDLAM,LKNT)
58523 
58524 C...Double precision and integer declarations.
58525  IMPLICIT DOUBLE PRECISION(a-h, o-z)
58526  IMPLICIT INTEGER(i-n)
58527 C...Parameter statement to help give large particle numbers.
58528  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
58529  &kexcit=4000000,kdimen=5000000)
58530 C...Commonblocks.
58531  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
58532  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
58533  common/pymssm/imss(0:99),rmss(0:99)
58534  common/pyssmt/zmix(4,4),umix(2,2),vmix(2,2),smz(4),smw(2),
58535  &sfmix(16,4),zmixi(4,4),umixi(2,2),vmixi(2,2)
58536  common/pymsrv/rvlam(3,3,3), rvlamp(3,3,3), rvlamb(3,3,3)
58537 C...Local variables.
58538  DOUBLE PRECISION xlam(0:400)
58539  INTEGER idlam(400,3), pycomp
58540 C...Information from main routine to PYRVGW
58541  common/pyrvnv/ab(2,16,2),rms(0:3),res(6,2),intres(6,3),idr,idr2
58542  & ,dcmass,kfr(3)
58543 C...Auxiliary variables needed for BV (RV Gauge STOre)
58544  common/rvgsto/xresi,xresj,xresk,xresij,xresik,xresjk,rvlijk,rvlkij
58545  & ,rvljki,rvljik
58546 C...Running quark masses
58547  DOUBLE PRECISION rmq(6)
58548 C...Decay product masses on/off
58549  LOGICAL dcmass
58550  SAVE /pydat1/,/pydat2/,/pymssm/,/pyssmt/,/pymsrv/,/pyrvnv/,
58551  & /rvgsto/
58552 
58553 C...IF LQD OR UDD TYPE R-VIOLATION ON.
58554  IF (imss(52).GE.1.OR.imss(53).GE.1) THEN
58555  kfsm=kfin-ksusy1
58556 
58557 C... AB(x,y,z):
58558 C x=1-2 : Select A or B coupling (1:A ; 2:B)
58559 C y=1-16 : Sparticle's SM code (1-6:d,u,s,c,b,t ;
58560 C 11-16:e,nu_e,mu,... not used here)
58561 C z=1-2 : Mass eigenstate number
58562  DO 100 i = 1,6
58563 C...A Couplings
58564  ab(1,i,1) = sfmix(i,2)
58565  ab(1,i,2) = sfmix(i,4)
58566 C...B Couplings
58567  ab(2,i,1) = -sfmix(i,1)
58568  ab(2,i,2) = -sfmix(i,3)
58569  100 CONTINUE
58570  gstr2 = 4d0*paru(1) * pyalps(pmas(pycomp(kfin),1)**2)
58571 C...LQD DECAYS.
58572  IF (imss(52).GE.1) THEN
58573 C...STEP IN I,J,K USING SINGLE COUNTER
58574  DO 120 isc=0,26
58575 C * GLUINO -> NUBAR_I + DBAR_J + D_K.
58576  lknt = lknt+1
58577  idlam(lknt,1) =-12 -2*mod(isc/9,3)
58578  idlam(lknt,2) = -1 -2*mod(isc/3,3)
58579  idlam(lknt,3) = 1 +2*mod(isc,3)
58580  xlam(lknt)=0d0
58581 C...Set coupling, and decay product masses on/off
58582  rvlamc=rvlamp(mod(isc/9,3)+1,mod(isc/3,3)+1,mod(isc,3)+1)**2
58583  & * 5d-1 * gstr2
58584  dcmass = .false.
58585  IF (idlam(lknt,2).EQ.-5.OR.idlam(lknt,3).EQ.5) dcmass=.true.
58586 C...Resonance KF codes (1=I,2=J,3=K)
58587  kfr(1) = 0
58588  kfr(2) = -idlam(lknt,2)
58589  kfr(3) = -idlam(lknt,3)
58590 C...Calculate width.
58591  CALL pyrvgw(kfin,idlam(lknt,1),idlam(lknt,2),idlam(lknt,3)
58592  & ,xlam(lknt))
58593 C...Normalize
58594  xlam(lknt)=xlam(lknt)*rvlamc/((2*paru(1)*rms(0))**3*32)
58595 C...Charge conjugate mode.
58596  110 lknt = lknt+1
58597  idlam(lknt,1) =-idlam(lknt-1,1)
58598  idlam(lknt,2) =-idlam(lknt-1,2)
58599  idlam(lknt,3) =-idlam(lknt-1,3)
58600  xlam(lknt) = xlam(lknt-1)
58601 C...KINEMATICS CHECK
58602  IF (xlam(lknt).EQ.0d0) THEN
58603  lknt=lknt-2
58604  ENDIF
58605 
58606 C * GLUINO -> LEPTON+_I + UBAR_J + D_K
58607  lknt = lknt+1
58608  idlam(lknt,1) =-11 -2*mod(isc/9,3)
58609  idlam(lknt,2) = -2 -2*mod(isc/3,3)
58610  idlam(lknt,3) = 1 +2*mod(isc,3)
58611  xlam(lknt)=0d0
58612 C...Set coupling, and decay product masses on/off
58613  rvlamc = rvlamp(mod(isc/9,3)+1,mod(isc/3,3)+1,mod(isc,3)+1)
58614  & **2* 5d-1 * gstr2
58615  dcmass = .false.
58616  IF (idlam(lknt,1).EQ.-15.OR.idlam(lknt,2).EQ.-6
58617  & .OR.idlam(lknt,3).EQ.5) dcmass = .true.
58618 C...Resonance KF codes (1=I,2=J,3=K)
58619  kfr(1) = 0
58620  kfr(2) = -idlam(lknt,2)
58621  kfr(3) = -idlam(lknt,3)
58622 C...Calculate width.
58623  CALL pyrvgw(kfin,idlam(lknt,1),idlam(lknt,2),idlam(lknt,3)
58624  & ,xlam(lknt))
58625  xlam(lknt)=xlam(lknt)*rvlamc/((2*paru(1)*rms(0))**3*32)
58626 C...Charge conjugate mode.
58627  lknt=lknt+1
58628  idlam(lknt,1) = -idlam(lknt-1,1)
58629  idlam(lknt,2) = -idlam(lknt-1,2)
58630  idlam(lknt,3) = -idlam(lknt-1,3)
58631  xlam(lknt) = xlam(lknt-1)
58632 C...KINEMATICS CHECK
58633  IF (xlam(lknt).EQ.0d0) THEN
58634  lknt=lknt-2
58635  ENDIF
58636 
58637  120 CONTINUE
58638  ENDIF
58639 
58640 C...UDD DECAYS.
58641  IF (imss(53).GE.1) THEN
58642 C...STEP IN I,J,K USING SINGLE COUNTER
58643  DO 130 isc=0,26
58644 C * GLUINO -> UBAR_I + DBAR_J + DBAR_K.
58645  IF (mod(isc/3,3).LT.mod(isc,3)) THEN
58646  lknt = lknt+1
58647  idlam(lknt,1) = -2 -2*mod(isc/9,3)
58648  idlam(lknt,2) = -1 -2*mod(isc/3,3)
58649  idlam(lknt,3) = -1 -2*mod(isc,3)
58650  xlam(lknt)=0d0
58651 C...Set coupling, and decay product masses on/off. A factor of 2 for
58652 C...(N_C-1) has been used to cancel a factor 0.5.
58653  rvlamc=rvlamb(mod(isc/9,3)+1,mod(isc/3,3)+1,mod(isc,3)+1)
58654  & **2 * gstr2
58655  dcmass = .false.
58656  IF (idlam(lknt,1).EQ.-6.OR.idlam(lknt,2).EQ.-5
58657  & .OR.idlam(lknt,3).EQ.-5) dcmass=.true.
58658 C...Resonance KF codes (1=I,2=J,3=K)
58659  kfr(1) = idlam(lknt,1)
58660  kfr(2) = 0
58661  kfr(3) = 0
58662 C...Calculate width.
58663  CALL pyrvgw(kfin,idlam(lknt,1),idlam(lknt,2),idlam(lknt,3)
58664  & ,xresi)
58665 C...Resonance KF codes (1=I,2=J,3=K)
58666  kfr(1) = 0
58667  kfr(2) = idlam(lknt,2)
58668  kfr(3) = 0
58669 C...Calculate width.
58670  CALL pyrvgw(kfin,idlam(lknt,1),idlam(lknt,2),idlam(lknt,3)
58671  & ,xresj)
58672 C...Resonance KF codes (1=I,2=J,3=K)
58673  kfr(1) = 0
58674  kfr(2) = 0
58675  kfr(3) = idlam(lknt,3)
58676 C...Calculate width.
58677  CALL pyrvgw(kfin,idlam(lknt,1),idlam(lknt,2),idlam(lknt,3)
58678  & ,xresk)
58679 C...Resonance KF codes (1=I,2=J,3=K)
58680  kfr(1) = idlam(lknt,1)
58681  kfr(2) = idlam(lknt,2)
58682  kfr(3) = 0
58683 C...Calculate width.
58684  CALL pyrvgw(kfin,idlam(lknt,1),idlam(lknt,2),idlam(lknt,3)
58685  & ,xresij)
58686 C...Calculate interference function. (Factor -1/2 to make up for factor
58687 C...-2 in PYRVGW.
58688  IF (abs(xresi+xresj-xresij).GT.1d-4*xresij) THEN
58689  xresij = 5d-1 * (xresi+xresj-xresij)
58690  ELSE
58691  xresij = 0d0
58692  ENDIF
58693 C...Resonance KF codes (1=I,2=J,3=K)
58694  kfr(1) = 0
58695  kfr(2) = idlam(lknt,2)
58696  kfr(3) = idlam(lknt,3)
58697 C...Calculate width.
58698  CALL pyrvgw(kfin,idlam(lknt,1),idlam(lknt,2),idlam(lknt,3)
58699  & ,xresjk)
58700  IF (abs(xresj+xresk-xresjk).GT.1d-4*xresjk) THEN
58701  xresjk = 5d-1 * (xresj+xresk-xresjk)
58702  ELSE
58703  xresjk = 0d0
58704  ENDIF
58705 C...Resonance KF codes (1=I,2=J,3=K)
58706  kfr(1) = idlam(lknt,1)
58707  kfr(2) = 0
58708  kfr(3) = idlam(lknt,3)
58709 C...Calculate width.
58710  CALL pyrvgw(kfin,idlam(lknt,1),idlam(lknt,2),idlam(lknt,3)
58711  & ,xresik)
58712  IF (abs(xresi+xresk-xresik).GT.1d-4*xresik) THEN
58713  xresik = 5d-1 * (xresi+xresk-xresik)
58714  ELSE
58715  xresik = 0d0
58716  ENDIF
58717 C...Calculate total width (factor 1/2 from 1/(N_C-1))
58718  xlam(lknt) = xresi + xresj + xresk
58719  & + 5d-1 * (xresij + xresik + xresjk)
58720 C...Normalize
58721  xlam(lknt) = xlam(lknt)*rvlamc/((2*paru(1)*rms(0))**3*32)
58722 C...Charge conjugate mode.
58723  lknt = lknt+1
58724  idlam(lknt,1) =-idlam(lknt-1,1)
58725  idlam(lknt,2) =-idlam(lknt-1,2)
58726  idlam(lknt,3) =-idlam(lknt-1,3)
58727  xlam(lknt) = xlam(lknt-1)
58728 C...KINEMATICS CHECK
58729  IF (xlam(lknt).EQ.0d0) THEN
58730  lknt=lknt-2
58731  ENDIF
58732  ENDIF
58733  130 CONTINUE
58734  ENDIF
58735  ENDIF
58736  RETURN
58737  END
58738 
58739 C*********************************************************************
58740 
58741 C...PYRVSB
58742 C...Auxiliary function to PYRVSF for calculating R-Violating
58743 C...sfermion widths. Though the decay products are most often treated
58744 C...as massless in the calculation, the kinematical boundary of phase
58745 C...space is tested using the true masses.
58746 C...MODE = 1: All decay products massive
58747 C...MODE = 2: Decay product 1 massless
58748 C...MODE = 3: Decay product 2 massless
58749 C...MODE = 4: All decay products massless
58750 
58751  FUNCTION pyrvsb(KFIN,ID1,ID2,RM2,MODE)
58752 
58753  IMPLICIT DOUBLE PRECISION (a-h,o-z)
58754  IMPLICIT integer(i-n)
58755  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
58756  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
58757  SAVE /pydat1/,/pydat2/
58758  DOUBLE PRECISION sm(3)
58759  INTEGER pycomp, kc(3)
58760  kc(1)=pycomp(kfin)
58761  kc(2)=pycomp(id1)
58762  kc(3)=pycomp(id2)
58763  sm(1)=pmas(kc(1),1)**2
58764  sm(2)=pmas(kc(2),1)**2
58765  sm(3)=pmas(kc(3),1)**2
58766 C...Kinematics check
58767  IF ((sm(1)-(pmas(kc(2),1)+pmas(kc(3),1))**2).LE.0d0) THEN
58768  pyrvsb=0d0
58769  RETURN
58770  ENDIF
58771 C...CM momenta squared
58772  IF (mode.EQ.1) THEN
58773  p2cm=1./(4*sm(1))*(sm(1)-(pmas(kc(2),1)+pmas(kc(3),1))**2)
58774  & * (sm(1)-(pmas(kc(2),1)-pmas(kc(3),1))**2)
58775  ELSE IF (mode.EQ.2) THEN
58776  p2cm=1./(4*sm(1))*(sm(1)-(pmas(kc(3),1))**2)**2
58777  ELSE IF (mode.EQ.3) THEN
58778  p2cm=1./(4*sm(1))*(sm(1)-(pmas(kc(2),1))**2)**2
58779  ELSE
58780  p2cm=sm(1)/4.
58781  ENDIF
58782 C...Calculate Width
58783  pyrvsb=rm2*sqrt(max(0d0,p2cm))/(8*paru(1)*sm(1))
58784  RETURN
58785  END
58786 
58787 C*********************************************************************
58788 
58789 C...PYRVGW
58790 C...Generalized Matrix Element for R-Violating 3-body widths.
58791 C...P. Z. Skands
58792  SUBROUTINE pyrvgw(KFIN,ID1,ID2,ID3,XLAM)
58793 
58794  IMPLICIT DOUBLE PRECISION (a-h,o-z)
58795  IMPLICIT integer(i-n)
58796  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
58797  &kexcit=4000000,kdimen=5000000)
58798  parameter(eps=1d-4)
58799  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
58800  common/pyrvnv/ab(2,16,2),rms(0:3),res(6,2),intres(6,3),idr,idr2
58801  & ,dcmass,kfr(3)
58802  common/pyssmt/zmix(4,4),umix(2,2),vmix(2,2),smz(4),smw(2),
58803  & sfmix(16,4),zmixi(4,4),umixi(2,2),vmixi(2,2)
58804  DOUBLE PRECISION xlim(3,3)
58805  INTEGER kc(0:3), pycomp
58806  LOGICAL dcmass, dcheck(6)
58807  SAVE /pydat2/,/pyrvnv/,/pyssmt/
58808 
58809  xlam = 0d0
58810 
58811  kc(0) = pycomp(kfin)
58812  kc(1) = pycomp(id1)
58813  kc(2) = pycomp(id2)
58814  kc(3) = pycomp(id3)
58815  rms(0) = pmas(kc(0),1)
58816  rms(1) = pymrun(id1,pmas(kc(1),1)**2)
58817  rms(2) = pymrun(id2,pmas(kc(2),1)**2)
58818  rms(3) = pymrun(id3,pmas(kc(3),1)**2)
58819 C...INITIALIZE OUTER INTEGRATION LIMITS AND KINEMATICS CHECK
58820  xlim(1,1)=(rms(1)+rms(2))**2
58821  xlim(1,2)=(rms(0)-rms(3))**2
58822  xlim(1,3)=xlim(1,2)-xlim(1,1)
58823  xlim(2,1)=(rms(2)+rms(3))**2
58824  xlim(2,2)=(rms(0)-rms(1))**2
58825  xlim(2,3)=xlim(2,2)-xlim(2,1)
58826  xlim(3,1)=(rms(1)+rms(3))**2
58827  xlim(3,2)=(rms(0)-rms(2))**2
58828  xlim(3,3)=xlim(3,2)-xlim(3,1)
58829 C...Check Phase Space
58830  IF (xlim(1,3).LT.0d0.OR.xlim(2,3).LT.0d0.OR.xlim(3,3).LT.0d0) THEN
58831  RETURN
58832  ENDIF
58833 
58834 C...INITIALIZE RESONANCE INFORMATION
58835  DO 110 jres = 1,3
58836  DO 100 imass = 1,2
58837  ires = 2*(jres-1)+imass
58838  intres(ires,1) = 0
58839  dcheck(ires) =.false.
58840 C...NO RIGHT-HANDED NEUTRINOS
58841  IF (((imass.EQ.2).AND.((iabs(kfr(jres)).EQ.12).or
58842  & .(iabs(kfr(jres)).EQ.14).OR.(iabs(kfr(jres)).EQ.16))).or
58843  & .kfr(jres).EQ.0) goto 100
58844  res(ires,1) = pmas(pycomp(imass*ksusy1+iabs(kfr(jres))),1)
58845  res(ires,2) = pmas(pycomp(imass*ksusy1+iabs(kfr(jres))),2)
58846  intres(ires,1) = iabs(kfr(jres))
58847  intres(ires,2) = imass
58848  IF (kfr(jres).LT.0) intres(ires,3) = 1
58849  IF (kfr(jres).GT.0) intres(ires,3) = 0
58850  100 CONTINUE
58851  110 CONTINUE
58852 
58853 C...SUM OVER DIAGRAMS AND INTEGRATE OVER PHASE SPACE
58854 
58855 C...RESONANCE CONTRIBUTIONS
58856 C...(Only sum contributions where the resonance is off shell).
58857 C...Store whether diagram on/off in DCHECK.
58858 C...LOOP OVER MASS STATES
58859  DO 120 j=1,2
58860  idr=j
58861  IF(intres(idr,1).NE.0) THEN
58862 
58863  tmix = sfmix(intres(idr,1),2*j+intres(idr,3)-1)**2
58864  IF ((rms(0).LT.(rms(1)+res(idr,1)).OR.(res(idr,1).LT.(rms(2)
58865  & +rms(3)))).AND.tmix.GT.eps.AND.intres(idr,1).NE.0) THEN
58866  dcheck(idr) =.true.
58867  xlam = xlam + tmix * pyrvi1(2,3,1)
58868  ENDIF
58869  ENDIF
58870 
58871  idr=j+2
58872  IF(intres(idr,1).NE.0) THEN
58873  tmix = sfmix(intres(idr,1),2*j+intres(idr,3)-1)**2
58874  IF ((rms(0).LT.(rms(2)+res(idr,1)).OR.(res(idr,1).LT.(rms(1)
58875  & +rms(3)))).AND.tmix.GT.eps.AND.intres(idr,1).NE.0) THEN
58876  dcheck(idr) =.true.
58877  xlam = xlam + tmix * pyrvi1(1,3,2)
58878  ENDIF
58879  ENDIF
58880 
58881  idr=j+4
58882  IF(intres(idr,1).NE.0) THEN
58883  tmix = sfmix(intres(idr,1),2*j+intres(idr,3)-1)**2
58884  IF ((rms(0).LT.(rms(3)+res(idr,1)).OR.(res(idr,1).LT.(rms(1)
58885  & +rms(2)))).AND.tmix.GT.eps.AND.intres(idr,1).NE.0) THEN
58886  dcheck(idr) =.true.
58887  xlam = xlam + tmix * pyrvi1(1,2,3)
58888  ENDIF
58889  ENDIF
58890  120 CONTINUE
58891 C... L-R INTERFERENCES
58892 C... (Only add contributions where both contributing diagrams
58893 C... are non-resonant).
58894  idr=1
58895  IF (dcheck(1).AND.dcheck(2)) THEN
58896 C...Bug corrected 11/12 2001. Skands.
58897  xlam = xlam + 2d0 * pyrvi2(2,3,1)
58898  & * sfmix(intres(1,1),2+intres(1,3)-1)
58899  & * sfmix(intres(2,1),4+intres(2,3)-1)
58900  ENDIF
58901 
58902  idr=3
58903  IF (dcheck(3).AND.dcheck(4)) THEN
58904  xlam = xlam + 2d0 * pyrvi2(1,3,2)
58905  & * sfmix(intres(3,1),2+intres(3,3)-1)
58906  & * sfmix(intres(4,1),4+intres(4,3)-1)
58907  ENDIF
58908 
58909  idr=5
58910  IF (dcheck(5).AND.dcheck(6)) THEN
58911  xlam = xlam + 2d0 * pyrvi2(1,2,3)
58912  & * sfmix(intres(5,1),2+intres(5,3)-1)
58913  & * sfmix(intres(6,1),4+intres(6,3)-1)
58914  ENDIF
58915 C... TRUE INTERFERENCES
58916 C... (Only add contributions where both contributing diagrams
58917 C... are non-resonant).
58918  pref=-2d0
58919  IF ((kfin-ksusy1).EQ.24.OR.(kfin-ksusy1).EQ.37) pref=2d0
58920  DO 140 ikr1 = 1,2
58921  DO 130 ikr2 = 1,2
58922  idr = ikr1+2
58923  idr2 = ikr2
58924  IF (dcheck(idr).AND.dcheck(idr2)) THEN
58925  xlam = xlam + pref*pyrvi3(1,3,2) *
58926  & sfmix(intres(idr,1),2*ikr1+intres(idr,3)-1)
58927  & *sfmix(intres(idr2,1),2*ikr2+intres(idr2,3)-1)
58928  ENDIF
58929 
58930  idr = ikr1+4
58931  idr2 = ikr2
58932  IF (dcheck(idr).AND.dcheck(idr2)) THEN
58933  xlam = xlam + pref*pyrvi3(1,2,3) *
58934  & sfmix(intres(idr,1),2*ikr1+intres(idr,3)-1)
58935  & *sfmix(intres(idr2,1),2*ikr2+intres(idr2,3)-1)
58936  ENDIF
58937 
58938  idr = ikr1+4
58939  idr2 = ikr2+2
58940  IF (dcheck(idr).AND.dcheck(idr2)) THEN
58941  xlam = xlam + pref*pyrvi3(2,1,3) *
58942  & sfmix(intres(idr,1),2*ikr1+intres(idr,3)-1)
58943  & *sfmix(intres(idr2,1),2*ikr2+intres(idr2,3)-1)
58944  ENDIF
58945  130 CONTINUE
58946  140 CONTINUE
58947 
58948  RETURN
58949  END
58950 
58951 C*********************************************************************
58952 
58953 C...PYRVI1
58954 C...Function to integrate resonance contributions
58955 
58956  FUNCTION pyrvi1(ID1,ID2,ID3)
58957 
58958  IMPLICIT NONE
58959  DOUBLE PRECISION lo,hi,pyrvi1,pyrvg1,pygaus
58960  DOUBLE PRECISION res, ab, rm, resm, resw, a, b, rms
58961  INTEGER id1,id2,id3, idr, idr2, kfr, intres
58962  LOGICAL mflag,dcmass
58963  EXTERNAL pyrvg1,pygaus
58964  common/pyrvnv/ab(2,16,2),rms(0:3),res(6,2),intres(6,3),idr,idr2
58965  & ,dcmass,kfr(3)
58966  common/pyrvpm/rm(0:3),a(2),b(2),resm(2),resw(2),mflag
58967  SAVE/pyrvnv/,/pyrvpm/
58968 C...Initialize mass and width information
58969  pyrvi1 = 0d0
58970  rm(0) = rms(0)
58971  rm(1) = rms(id1)
58972  rm(2) = rms(id2)
58973  rm(3) = rms(id3)
58974  resm(1)= res(idr,1)
58975  resw(1)= res(idr,2)
58976 C...A->B and B->A for antisparticles
58977  a(1) = ab(1+intres(idr,3),intres(idr,1),intres(idr,2))
58978  b(1) = ab(2-intres(idr,3),intres(idr,1),intres(idr,2))
58979 C...Integration boundaries and mass flag
58980  lo = (rm(1)+rm(2))**2
58981  hi = (rm(0)-rm(3))**2
58982  mflag = dcmass
58983  pyrvi1 = pygaus(pyrvg1,lo,hi,1d-3)
58984  RETURN
58985  END
58986 
58987 C*********************************************************************
58988 
58989 C...PYRVI2
58990 C...Function to integrate L-R interference contributions
58991 
58992  FUNCTION pyrvi2(ID1,ID2,ID3)
58993 
58994  IMPLICIT NONE
58995  DOUBLE PRECISION lo,hi,pyrvi2, pyrvg2, pygaus
58996  DOUBLE PRECISION res, ab, rm, resm, resw, a, b, rms
58997  INTEGER id1,id2,id3, idr, idr2, kfr, intres
58998  LOGICAL mflag,dcmass
58999  EXTERNAL pyrvg2,pygaus
59000  common/pyrvnv/ab(2,16,2),rms(0:3),res(6,2),intres(6,3),idr,idr2
59001  & ,dcmass,kfr(3)
59002  common/pyrvpm/rm(0:3),a(2),b(2),resm(2),resw(2),mflag
59003  SAVE/pyrvnv/,/pyrvpm/
59004 C...Initialize mass and width information
59005  pyrvi2 = 0d0
59006  rm(0) = rms(0)
59007  rm(1) = rms(id1)
59008  rm(2) = rms(id2)
59009  rm(3) = rms(id3)
59010  resm(1)= res(idr,1)
59011  resw(1)= res(idr,2)
59012  resm(2)= res(idr+1,1)
59013  resw(2)= res(idr+1,2)
59014 C...A->B and B->A for antisparticles
59015  a(1) = ab(1+intres(idr,3),intres(idr,1),intres(idr,2))
59016  b(1) = ab(2-intres(idr,3),intres(idr,1),intres(idr,2))
59017  a(2) = ab(1+intres(idr+1,3),intres(idr+1,1),intres(idr+1,2))
59018  b(2) = ab(2-intres(idr+1,3),intres(idr+1,1),intres(idr+1,2))
59019 C...Boundaries and mass flag
59020  lo = (rm(1)+rm(2))**2
59021  hi = (rm(0)-rm(3))**2
59022  mflag = dcmass
59023  pyrvi2 = pygaus(pyrvg2,lo,hi,1d-3)
59024  RETURN
59025  END
59026 
59027 C*********************************************************************
59028 
59029 C...PYRVI3
59030 C...Function to integrate true interference contributions
59031 
59032  FUNCTION pyrvi3(ID1,ID2,ID3)
59033 
59034  IMPLICIT NONE
59035  DOUBLE PRECISION lo,hi,pyrvi3, pyrvg3, pygaus
59036  DOUBLE PRECISION res, ab, rm, resm, resw, a, b, rms
59037  INTEGER id1,id2,id3, idr, idr2, kfr, intres
59038  LOGICAL mflag,dcmass
59039  EXTERNAL pyrvg3,pygaus
59040  common/pyrvnv/ab(2,16,2),rms(0:3),res(6,2),intres(6,3),idr,idr2
59041  & ,dcmass,kfr(3)
59042  common/pyrvpm/rm(0:3),a(2),b(2),resm(2),resw(2),mflag
59043  SAVE/pyrvnv/,/pyrvpm/
59044 C...Initialize mass and width information
59045  pyrvi3 = 0d0
59046  rm(0) = rms(0)
59047  rm(1) = rms(id1)
59048  rm(2) = rms(id2)
59049  rm(3) = rms(id3)
59050  resm(1)= res(idr,1)
59051  resw(1)= res(idr,2)
59052  resm(2)= res(idr2,1)
59053  resw(2)= res(idr2,2)
59054 C...A -> B and B -> A for antisparticles
59055  a(1) = ab(1+intres(idr,3),intres(idr,1),intres(idr,2))
59056  b(1) = ab(2-intres(idr,3),intres(idr,1),intres(idr,2))
59057  a(2) = ab(1+intres(idr2,3),intres(idr2,1),intres(idr2,2))
59058  b(2) = ab(2-intres(idr2,3),intres(idr2,1),intres(idr2,2))
59059 C...Boundaries and mass flag
59060  lo = (rm(1)+rm(2))**2
59061  hi = (rm(0)-rm(3))**2
59062  mflag = dcmass
59063  pyrvi3 = pygaus(pyrvg3,lo,hi,1d-3)
59064  RETURN
59065  END
59066 
59067 C*********************************************************************
59068 
59069 C...PYRVG1
59070 C...Integrand for resonance contributions
59071 
59072  FUNCTION pyrvg1(X)
59073 
59074  IMPLICIT NONE
59075  common/pyrvpm/rm(0:3),a(2),b(2),resm(2),resw(2),mflag
59076  DOUBLE PRECISION x, rm, a, b, resm, resw, deltay,pyrvr
59077  DOUBLE PRECISION rvr,pyrvg1,e2,e3,c1,sr1,sr2,a1,a2
59078  LOGICAL mflag
59079  SAVE/pyrvpm/
59080  rvr = pyrvr(x,resm(1),resw(1))
59081  c1 = 2d0*sqrt(max(0d0,x))
59082  IF (.NOT.mflag) THEN
59083  e2 = x/c1
59084  e3 = (rm(0)**2-x)/c1
59085  deltay = 4d0*e2*e3
59086  pyrvg1 = deltay*rvr*x*(a(1)**2+b(1)**2)*(rm(0)**2-x)
59087  ELSE
59088  e2 = (x-rm(1)**2+rm(2)**2)/c1
59089  e3 = (rm(0)**2-x-rm(3)**2)/c1
59090  sr1 = sqrt(max(0d0,e2**2-rm(2)**2))
59091  sr2 = sqrt(max(0d0,e3**2-rm(3)**2))
59092  deltay = 4d0*sr1*sr2
59093  a1 = 4.*a(1)*b(1)*rm(3)*rm(0)
59094  a2 = (a(1)**2+b(1)**2)*(rm(0)**2+rm(3)**2-x)
59095  pyrvg1 = deltay*rvr*(x-rm(1)**2-rm(2)**2)*(a1+a2)
59096  ENDIF
59097  RETURN
59098  END
59099 
59100 C*********************************************************************
59101 
59102 C...PYRVG2
59103 C...Integrand for L-R interference contributions
59104 
59105  FUNCTION pyrvg2(X)
59106 
59107  IMPLICIT NONE
59108  common/pyrvpm/rm(0:3),a(2),b(2),resm(2),resw(2),mflag
59109  DOUBLE PRECISION x, rm, a, b, resm, resw, deltay, pyrvs
59110  DOUBLE PRECISION rvs,pyrvg2,e2,e3,c1,sr1,sr2
59111  LOGICAL mflag
59112  SAVE/pyrvpm/
59113  c1 = 2d0*sqrt(max(0d0,x))
59114  rvs = pyrvs(x,x,resm(1),resw(1),resm(2),resw(2))
59115  IF (.NOT.mflag) THEN
59116  e2 = x/c1
59117  e3 = (rm(0)**2-x)/c1
59118  deltay = 4d0*e2*e3
59119  pyrvg2 = deltay*rvs*x*(a(1)*a(2)+b(1)*b(2))*(rm(0)**2-x)
59120  ELSE
59121  e2 = (x-rm(1)**2+rm(2)**2)/c1
59122  e3 = (rm(0)**2-x-rm(3)**2)/c1
59123  sr1 = sqrt(max(0d0,e2**2-rm(2)**2))
59124  sr2 = sqrt(max(0d0,e3**2-rm(3)**2))
59125  deltay = 4d0*sr1*sr2
59126  pyrvg2 = deltay*rvs*(x-rm(1)**2-rm(2)**2)*((a(1)*a(2)
59127  & + b(1)*b(2))*(rm(0)**2+rm(3)**2-x)
59128  & + 2d0*(a(1)*b(2)+a(2)*b(1))*rm(3)*rm(0))
59129  ENDIF
59130  RETURN
59131  END
59132 
59133 C*********************************************************************
59134 
59135 C...PYRVG3
59136 C...Function to do Y integration over true interference contributions
59137 
59138  FUNCTION pyrvg3(X)
59139 
59140  IMPLICIT NONE
59141  common/pyrvpm/rm(0:3),a(2),b(2),resm(2),resw(2),mflag
59142 C...Second Dalitz variable for PYRVG4
59143  common/pyg2dx/x1
59144  DOUBLE PRECISION rm, a, b, resm, resw, x, x1
59145  DOUBLE PRECISION e2, e3, c1, sq1, sr1, sr2, ymin, ymax
59146  DOUBLE PRECISION pyrvg3, pyrvg4, pygau2
59147  LOGICAL mflag
59148  EXTERNAL pygau2,pyrvg4
59149  SAVE/pyrvpm/,/pyg2dx/
59150  pyrvg3=0d0
59151  c1=2d0*sqrt(max(1d-9,x))
59152  x1=x
59153  IF (.NOT.mflag) THEN
59154  e2 = x/c1
59155  e3 = (rm(0)**2-x)/c1
59156  ymin = 0d0
59157  ymax = 4d0*e2*e3
59158  ELSE
59159  e2 = (x-rm(1)**2+rm(2)**2)/c1
59160  e3 = (rm(0)**2-x-rm(3)**2)/c1
59161  sq1 = (e2+e3)**2
59162  sr1 = sqrt(max(0d0,e2**2-rm(2)**2))
59163  sr2 = sqrt(max(0d0,e3**2-rm(3)**2))
59164  ymin = sq1-(sr1+sr2)**2
59165  ymax = sq1-(sr1-sr2)**2
59166  ENDIF
59167  pyrvg3 = pygau2(pyrvg4,ymin,ymax,1d-3)
59168  RETURN
59169  END
59170 
59171 C*********************************************************************
59172 
59173 C...PYRVG4
59174 C...Integrand for true intereference contributions
59175 
59176  FUNCTION pyrvg4(Y)
59177 
59178  IMPLICIT NONE
59179  common/pyrvpm/rm(0:3),a(2),b(2),resm(2),resw(2),mflag
59180  common/pyg2dx/x
59181  DOUBLE PRECISION x, y, pyrvg4, rm, a, b, resm, resw, rvs, pyrvs
59182  LOGICAL mflag
59183  SAVE /pyrvpm/,/pyg2dx/
59184  pyrvg4=0d0
59185  rvs=pyrvs(x,y,resm(1),resw(1),resm(2),resw(2))
59186  IF (.NOT.mflag) THEN
59187  pyrvg4 = rvs*b(1)*b(2)*x*y
59188  ELSE
59189  pyrvg4 = rvs*(rm(1)*rm(3)*a(1)*a(2)*(x+y-rm(1)**2-rm(3)**2)
59190  & + rm(1)*rm(0)*b(1)*a(2)*(y-rm(2)**2-rm(3)**2)
59191  & + rm(3)*rm(0)*a(1)*b(2)*(x-rm(1)**2-rm(2)**2)
59192  & + b(1)*b(2)*(x*y-(rm(1)*rm(3))**2-(rm(0)*rm(2))**2))
59193  ENDIF
59194  RETURN
59195  END
59196 
59197 C*********************************************************************
59198 
59199 C...PYRVR
59200 C...Breit-Wigner for resonance contributions
59201 
59202  FUNCTION pyrvr(Mab2,RM,RW)
59203 
59204  IMPLICIT NONE
59205  DOUBLE PRECISION mab2,rm,rw,pyrvr
59206  pyrvr = 1d0/((mab2-rm**2)**2+rm**2*rw**2)
59207  RETURN
59208  END
59209 
59210 C*********************************************************************
59211 
59212 C...PYRVS
59213 C...Interference function
59214 
59215  FUNCTION pyrvs(X,Y,M1,W1,M2,W2)
59216 
59217  IMPLICIT NONE
59218  DOUBLE PRECISION x, y, pyrvs, pyrvr, m1, m2, w1, w2
59219  pyrvs = pyrvr(x,m1,w1)*pyrvr(y,m2,w2)*((x-m1**2)*(y-m2**2)
59220  & +w1*w2*m1*m2)
59221  RETURN
59222  END
59223 
59224 C*********************************************************************
59225 
59226 C...PY1ENT
59227 C...Stores one parton/particle in commonblock PYJETS.
59228 
59229  SUBROUTINE py1ent(IP,KF,PE,THE,PHI)
59230 
59231 C...Double precision and integer declarations.
59232  IMPLICIT DOUBLE PRECISION(a-h, o-z)
59233  IMPLICIT INTEGER(i-n)
59234  INTEGER pyk,pychge,pycomp
59235 C...Commonblocks.
59236  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
59237  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
59238  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
59239  SAVE /pyjets/,/pydat1/,/pydat2/
59240 
59241 C...Standard checks.
59242  mstu(28)=0
59243  IF(mstu(12).NE.12345) CALL pylist(0)
59244  ipa=max(1,iabs(ip))
59245  IF(ipa.GT.mstu(4)) CALL pyerrm(21,
59246  &'(PY1ENT:) writing outside PYJETS memory')
59247  kc=pycomp(kf)
59248  IF(kc.EQ.0) CALL pyerrm(12,'(PY1ENT:) unknown flavour code')
59249 
59250 C...Find mass. Reset K, P and V vectors.
59251  pm=0d0
59252  IF(mstu(10).EQ.1) pm=p(ipa,5)
59253  IF(mstu(10).GE.2) pm=pymass(kf)
59254  DO 100 j=1,5
59255  k(ipa,j)=0
59256  p(ipa,j)=0d0
59257  v(ipa,j)=0d0
59258  100 CONTINUE
59259 
59260 C...Store parton/particle in K and P vectors.
59261  k(ipa,1)=1
59262  IF(ip.LT.0) k(ipa,1)=2
59263  k(ipa,2)=kf
59264  p(ipa,5)=pm
59265  p(ipa,4)=max(pe,pm)
59266  pa=sqrt(p(ipa,4)**2-p(ipa,5)**2)
59267  p(ipa,1)=pa*sin(the)*cos(phi)
59268  p(ipa,2)=pa*sin(the)*sin(phi)
59269  p(ipa,3)=pa*cos(the)
59270 
59271 C...Set N. Optionally fragment/decay.
59272  n=ipa
59273  IF(ip.EQ.0) CALL pyexec
59274 
59275  RETURN
59276  END
59277 
59278 C*********************************************************************
59279 
59280 C...PY2ENT
59281 C...Stores two partons/particles in their CM frame,
59282 C...with the first along the +z axis.
59283 
59284  SUBROUTINE py2ent(IP,KF1,KF2,PECM)
59285 
59286 C...Double precision and integer declarations.
59287  IMPLICIT DOUBLE PRECISION(a-h, o-z)
59288  IMPLICIT INTEGER(i-n)
59289  INTEGER pyk,pychge,pycomp
59290 C...Commonblocks.
59291  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
59292  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
59293  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
59294  SAVE /pyjets/,/pydat1/,/pydat2/
59295 
59296 C...Standard checks.
59297  mstu(28)=0
59298  IF(mstu(12).NE.12345) CALL pylist(0)
59299  ipa=max(1,iabs(ip))
59300  IF(ipa.GT.mstu(4)-1) CALL pyerrm(21,
59301  &'(PY2ENT:) writing outside PYJETS memory')
59302  kc1=pycomp(kf1)
59303  kc2=pycomp(kf2)
59304  IF(kc1.EQ.0.OR.kc2.EQ.0) CALL pyerrm(12,
59305  &'(PY2ENT:) unknown flavour code')
59306 
59307 C...Find masses. Reset K, P and V vectors.
59308  pm1=0d0
59309  IF(mstu(10).EQ.1) pm1=p(ipa,5)
59310  IF(mstu(10).GE.2) pm1=pymass(kf1)
59311  pm2=0d0
59312  IF(mstu(10).EQ.1) pm2=p(ipa+1,5)
59313  IF(mstu(10).GE.2) pm2=pymass(kf2)
59314  DO 110 i=ipa,ipa+1
59315  DO 100 j=1,5
59316  k(i,j)=0
59317  p(i,j)=0d0
59318  v(i,j)=0d0
59319  100 CONTINUE
59320  110 CONTINUE
59321 
59322 C...Check flavours.
59323  kq1=kchg(kc1,2)*isign(1,kf1)
59324  kq2=kchg(kc2,2)*isign(1,kf2)
59325  IF(mstu(19).EQ.1) THEN
59326  mstu(19)=0
59327  ELSE
59328  IF(kq1+kq2.NE.0.AND.kq1+kq2.NE.4) CALL pyerrm(2,
59329  & '(PY2ENT:) unphysical flavour combination')
59330  ENDIF
59331  k(ipa,2)=kf1
59332  k(ipa+1,2)=kf2
59333 
59334 C...Store partons/particles in K vectors for normal case.
59335  IF(ip.GE.0) THEN
59336  k(ipa,1)=1
59337  IF(kq1.NE.0.AND.kq2.NE.0) k(ipa,1)=2
59338  k(ipa+1,1)=1
59339 
59340 C...Store partons in K vectors for parton shower evolution.
59341  ELSE
59342  k(ipa,1)=3
59343  k(ipa+1,1)=3
59344  k(ipa,4)=mstu(5)*(ipa+1)
59345  k(ipa,5)=k(ipa,4)
59346  k(ipa+1,4)=mstu(5)*ipa
59347  k(ipa+1,5)=k(ipa+1,4)
59348  ENDIF
59349 
59350 C...Check kinematics and store partons/particles in P vectors.
59351  IF(pecm.LE.pm1+pm2) CALL pyerrm(13,
59352  &'(PY2ENT:) energy smaller than sum of masses')
59353  pa=sqrt(max(0d0,(pecm**2-pm1**2-pm2**2)**2-(2d0*pm1*pm2)**2))/
59354  &(2d0*pecm)
59355  p(ipa,3)=pa
59356  p(ipa,4)=sqrt(pm1**2+pa**2)
59357  p(ipa,5)=pm1
59358  p(ipa+1,3)=-pa
59359  p(ipa+1,4)=sqrt(pm2**2+pa**2)
59360  p(ipa+1,5)=pm2
59361 
59362 C...Set N. Optionally fragment/decay.
59363  n=ipa+1
59364  IF(ip.EQ.0) CALL pyexec
59365 
59366  RETURN
59367  END
59368 
59369 C*********************************************************************
59370 
59371 C...PY3ENT
59372 C...Stores three partons or particles in their CM frame,
59373 C...with the first along the +z axis and the third in the (x,z)
59374 C...plane with x > 0.
59375 
59376  SUBROUTINE py3ent(IP,KF1,KF2,KF3,PECM,X1,X3)
59377 
59378 C...Double precision and integer declarations.
59379  IMPLICIT DOUBLE PRECISION(a-h, o-z)
59380  IMPLICIT INTEGER(i-n)
59381  INTEGER pyk,pychge,pycomp
59382 C...Commonblocks.
59383  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
59384  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
59385  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
59386  SAVE /pyjets/,/pydat1/,/pydat2/
59387 
59388 C...Standard checks.
59389  mstu(28)=0
59390  IF(mstu(12).NE.12345) CALL pylist(0)
59391  ipa=max(1,iabs(ip))
59392  IF(ipa.GT.mstu(4)-2) CALL pyerrm(21,
59393  &'(PY3ENT:) writing outside PYJETS memory')
59394  kc1=pycomp(kf1)
59395  kc2=pycomp(kf2)
59396  kc3=pycomp(kf3)
59397  IF(kc1.EQ.0.OR.kc2.EQ.0.OR.kc3.EQ.0) CALL pyerrm(12,
59398  &'(PY3ENT:) unknown flavour code')
59399 
59400 C...Find masses. Reset K, P and V vectors.
59401  pm1=0d0
59402  IF(mstu(10).EQ.1) pm1=p(ipa,5)
59403  IF(mstu(10).GE.2) pm1=pymass(kf1)
59404  pm2=0d0
59405  IF(mstu(10).EQ.1) pm2=p(ipa+1,5)
59406  IF(mstu(10).GE.2) pm2=pymass(kf2)
59407  pm3=0d0
59408  IF(mstu(10).EQ.1) pm3=p(ipa+2,5)
59409  IF(mstu(10).GE.2) pm3=pymass(kf3)
59410  DO 110 i=ipa,ipa+2
59411  DO 100 j=1,5
59412  k(i,j)=0
59413  p(i,j)=0d0
59414  v(i,j)=0d0
59415  100 CONTINUE
59416  110 CONTINUE
59417 
59418 C...Check flavours.
59419  kq1=kchg(kc1,2)*isign(1,kf1)
59420  kq2=kchg(kc2,2)*isign(1,kf2)
59421  kq3=kchg(kc3,2)*isign(1,kf3)
59422  IF(mstu(19).EQ.1) THEN
59423  mstu(19)=0
59424  ELSEIF(kq1.EQ.0.AND.kq2.EQ.0.AND.kq3.EQ.0) THEN
59425  ELSEIF(kq1.NE.0.AND.kq2.EQ.2.AND.(kq1+kq3.EQ.0.OR.
59426  & kq1+kq3.EQ.4)) THEN
59427  ELSE
59428  CALL pyerrm(2,'(PY3ENT:) unphysical flavour combination')
59429  ENDIF
59430  k(ipa,2)=kf1
59431  k(ipa+1,2)=kf2
59432  k(ipa+2,2)=kf3
59433 
59434 C...Store partons/particles in K vectors for normal case.
59435  IF(ip.GE.0) THEN
59436  k(ipa,1)=1
59437  IF(kq1.NE.0.AND.(kq2.NE.0.OR.kq3.NE.0)) k(ipa,1)=2
59438  k(ipa+1,1)=1
59439  IF(kq2.NE.0.AND.kq3.NE.0) k(ipa+1,1)=2
59440  k(ipa+2,1)=1
59441 
59442 C...Store partons in K vectors for parton shower evolution.
59443  ELSE
59444  k(ipa,1)=3
59445  k(ipa+1,1)=3
59446  k(ipa+2,1)=3
59447  kcs=4
59448  IF(kq1.EQ.-1) kcs=5
59449  k(ipa,kcs)=mstu(5)*(ipa+1)
59450  k(ipa,9-kcs)=mstu(5)*(ipa+2)
59451  k(ipa+1,kcs)=mstu(5)*(ipa+2)
59452  k(ipa+1,9-kcs)=mstu(5)*ipa
59453  k(ipa+2,kcs)=mstu(5)*ipa
59454  k(ipa+2,9-kcs)=mstu(5)*(ipa+1)
59455  ENDIF
59456 
59457 C...Check kinematics.
59458  mkerr=0
59459  IF(0.5d0*x1*pecm.LE.pm1.OR.0.5d0*(2d0-x1-x3)*pecm.LE.pm2.OR.
59460  &0.5d0*x3*pecm.LE.pm3) mkerr=1
59461  pa1=sqrt(max(1d-10,(0.5d0*x1*pecm)**2-pm1**2))
59462  pa2=sqrt(max(1d-10,(0.5d0*(2d0-x1-x3)*pecm)**2-pm2**2))
59463  pa3=sqrt(max(1d-10,(0.5d0*x3*pecm)**2-pm3**2))
59464  cthe2=(pa3**2-pa1**2-pa2**2)/(2d0*pa1*pa2)
59465  cthe3=(pa2**2-pa1**2-pa3**2)/(2d0*pa1*pa3)
59466  IF(abs(cthe2).GE.1.001d0.OR.abs(cthe3).GE.1.001d0) mkerr=1
59467  cthe3=max(-1d0,min(1d0,cthe3))
59468  IF(mkerr.NE.0) CALL pyerrm(13,
59469  &'(PY3ENT:) unphysical kinematical variable setup')
59470 
59471 C...Store partons/particles in P vectors.
59472  p(ipa,3)=pa1
59473  p(ipa,4)=sqrt(pa1**2+pm1**2)
59474  p(ipa,5)=pm1
59475  p(ipa+2,1)=pa3*sqrt(1d0-cthe3**2)
59476  p(ipa+2,3)=pa3*cthe3
59477  p(ipa+2,4)=sqrt(pa3**2+pm3**2)
59478  p(ipa+2,5)=pm3
59479  p(ipa+1,1)=-p(ipa+2,1)
59480  p(ipa+1,3)=-p(ipa,3)-p(ipa+2,3)
59481  p(ipa+1,4)=sqrt(p(ipa+1,1)**2+p(ipa+1,3)**2+pm2**2)
59482  p(ipa+1,5)=pm2
59483 
59484 C...Set N. Optionally fragment/decay.
59485  n=ipa+2
59486  IF(ip.EQ.0) CALL pyexec
59487 
59488  RETURN
59489  END
59490 
59491 C*********************************************************************
59492 
59493 C...PY4ENT
59494 C...Stores four partons or particles in their CM frame, with
59495 C...the first along the +z axis, the last in the xz plane with x > 0
59496 C...and the second having y < 0 and y > 0 with equal probability.
59497 
59498  SUBROUTINE py4ent(IP,KF1,KF2,KF3,KF4,PECM,X1,X2,X4,X12,X14)
59499 
59500 C...Double precision and integer declarations.
59501  IMPLICIT DOUBLE PRECISION(a-h, o-z)
59502  IMPLICIT INTEGER(i-n)
59503  INTEGER pyk,pychge,pycomp
59504 C...Commonblocks.
59505  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
59506  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
59507  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
59508  SAVE /pyjets/,/pydat1/,/pydat2/
59509 
59510 C...Standard checks.
59511  mstu(28)=0
59512  IF(mstu(12).NE.12345) CALL pylist(0)
59513  ipa=max(1,iabs(ip))
59514  IF(ipa.GT.mstu(4)-3) CALL pyerrm(21,
59515  &'(PY4ENT:) writing outside PYJETS momory')
59516  kc1=pycomp(kf1)
59517  kc2=pycomp(kf2)
59518  kc3=pycomp(kf3)
59519  kc4=pycomp(kf4)
59520  IF(kc1.EQ.0.OR.kc2.EQ.0.OR.kc3.EQ.0.OR.kc4.EQ.0) CALL pyerrm(12,
59521  &'(PY4ENT:) unknown flavour code')
59522 
59523 C...Find masses. Reset K, P and V vectors.
59524  pm1=0d0
59525  IF(mstu(10).EQ.1) pm1=p(ipa,5)
59526  IF(mstu(10).GE.2) pm1=pymass(kf1)
59527  pm2=0d0
59528  IF(mstu(10).EQ.1) pm2=p(ipa+1,5)
59529  IF(mstu(10).GE.2) pm2=pymass(kf2)
59530  pm3=0d0
59531  IF(mstu(10).EQ.1) pm3=p(ipa+2,5)
59532  IF(mstu(10).GE.2) pm3=pymass(kf3)
59533  pm4=0d0
59534  IF(mstu(10).EQ.1) pm4=p(ipa+3,5)
59535  IF(mstu(10).GE.2) pm4=pymass(kf4)
59536  DO 110 i=ipa,ipa+3
59537  DO 100 j=1,5
59538  k(i,j)=0
59539  p(i,j)=0d0
59540  v(i,j)=0d0
59541  100 CONTINUE
59542  110 CONTINUE
59543 
59544 C...Check flavours.
59545  kq1=kchg(kc1,2)*isign(1,kf1)
59546  kq2=kchg(kc2,2)*isign(1,kf2)
59547  kq3=kchg(kc3,2)*isign(1,kf3)
59548  kq4=kchg(kc4,2)*isign(1,kf4)
59549  IF(mstu(19).EQ.1) THEN
59550  mstu(19)=0
59551  ELSEIF(kq1.EQ.0.AND.kq2.EQ.0.AND.kq3.EQ.0.AND.kq4.EQ.0) THEN
59552  ELSEIF(kq1.NE.0.AND.kq2.EQ.2.AND.kq3.EQ.2.AND.(kq1+kq4.EQ.0.OR.
59553  & kq1+kq4.EQ.4)) THEN
59554  ELSEIF(kq1.NE.0.AND.kq1+kq2.EQ.0.AND.kq3.NE.0.AND.kq3+kq4.EQ.0d0)
59555  & THEN
59556  ELSE
59557  CALL pyerrm(2,'(PY4ENT:) unphysical flavour combination')
59558  ENDIF
59559  k(ipa,2)=kf1
59560  k(ipa+1,2)=kf2
59561  k(ipa+2,2)=kf3
59562  k(ipa+3,2)=kf4
59563 
59564 C...Store partons/particles in K vectors for normal case.
59565  IF(ip.GE.0) THEN
59566  k(ipa,1)=1
59567  IF(kq1.NE.0.AND.(kq2.NE.0.OR.kq3.NE.0.OR.kq4.NE.0)) k(ipa,1)=2
59568  k(ipa+1,1)=1
59569  IF(kq2.NE.0.AND.kq1+kq2.NE.0.AND.(kq3.NE.0.OR.kq4.NE.0))
59570  & k(ipa+1,1)=2
59571  k(ipa+2,1)=1
59572  IF(kq3.NE.0.AND.kq4.NE.0) k(ipa+2,1)=2
59573  k(ipa+3,1)=1
59574 
59575 C...Store partons for parton shower evolution from q-g-g-qbar or
59576 C...g-g-g-g event.
59577  ELSEIF(kq1+kq2.NE.0) THEN
59578  k(ipa,1)=3
59579  k(ipa+1,1)=3
59580  k(ipa+2,1)=3
59581  k(ipa+3,1)=3
59582  kcs=4
59583  IF(kq1.EQ.-1) kcs=5
59584  k(ipa,kcs)=mstu(5)*(ipa+1)
59585  k(ipa,9-kcs)=mstu(5)*(ipa+3)
59586  k(ipa+1,kcs)=mstu(5)*(ipa+2)
59587  k(ipa+1,9-kcs)=mstu(5)*ipa
59588  k(ipa+2,kcs)=mstu(5)*(ipa+3)
59589  k(ipa+2,9-kcs)=mstu(5)*(ipa+1)
59590  k(ipa+3,kcs)=mstu(5)*ipa
59591  k(ipa+3,9-kcs)=mstu(5)*(ipa+2)
59592 
59593 C...Store partons for parton shower evolution from q-qbar-q-qbar event.
59594  ELSE
59595  k(ipa,1)=3
59596  k(ipa+1,1)=3
59597  k(ipa+2,1)=3
59598  k(ipa+3,1)=3
59599  k(ipa,4)=mstu(5)*(ipa+1)
59600  k(ipa,5)=k(ipa,4)
59601  k(ipa+1,4)=mstu(5)*ipa
59602  k(ipa+1,5)=k(ipa+1,4)
59603  k(ipa+2,4)=mstu(5)*(ipa+3)
59604  k(ipa+2,5)=k(ipa+2,4)
59605  k(ipa+3,4)=mstu(5)*(ipa+2)
59606  k(ipa+3,5)=k(ipa+3,4)
59607  ENDIF
59608 
59609 C...Check kinematics.
59610  mkerr=0
59611  IF(0.5d0*x1*pecm.LE.pm1.OR.0.5d0*x2*pecm.LE.pm2.OR.
59612  &0.5d0*(2d0-x1-x2-x4)*pecm.LE.pm3.OR.0.5d0*x4*pecm.LE.pm4)
59613  &mkerr=1
59614  pa1=sqrt(max(1d-10,(0.5d0*x1*pecm)**2-pm1**2))
59615  pa2=sqrt(max(1d-10,(0.5d0*x2*pecm)**2-pm2**2))
59616  pa4=sqrt(max(1d-10,(0.5d0*x4*pecm)**2-pm4**2))
59617  x24=x1+x2+x4-1d0-x12-x14+(pm3**2-pm1**2-pm2**2-pm4**2)/pecm**2
59618  cthe4=(x1*x4-2d0*x14)*pecm**2/(4d0*pa1*pa4)
59619  IF(abs(cthe4).GE.1.002d0) mkerr=1
59620  cthe4=max(-1d0,min(1d0,cthe4))
59621  sthe4=sqrt(1d0-cthe4**2)
59622  cthe2=(x1*x2-2d0*x12)*pecm**2/(4d0*pa1*pa2)
59623  IF(abs(cthe2).GE.1.002d0) mkerr=1
59624  cthe2=max(-1d0,min(1d0,cthe2))
59625  sthe2=sqrt(1d0-cthe2**2)
59626  cphi2=((x2*x4-2d0*x24)*pecm**2-4d0*pa2*cthe2*pa4*cthe4)/
59627  &max(1d-8*pecm**2,4d0*pa2*sthe2*pa4*sthe4)
59628  IF(abs(cphi2).GE.1.05d0) mkerr=1
59629  cphi2=max(-1d0,min(1d0,cphi2))
59630  IF(mkerr.EQ.1) CALL pyerrm(13,
59631  &'(PY4ENT:) unphysical kinematical variable setup')
59632 
59633 C...Store partons/particles in P vectors.
59634  p(ipa,3)=pa1
59635  p(ipa,4)=sqrt(pa1**2+pm1**2)
59636  p(ipa,5)=pm1
59637  p(ipa+3,1)=pa4*sthe4
59638  p(ipa+3,3)=pa4*cthe4
59639  p(ipa+3,4)=sqrt(pa4**2+pm4**2)
59640  p(ipa+3,5)=pm4
59641  p(ipa+1,1)=pa2*sthe2*cphi2
59642  p(ipa+1,2)=pa2*sthe2*sqrt(1d0-cphi2**2)*(-1d0)**int(pyr(0)+0.5d0)
59643  p(ipa+1,3)=pa2*cthe2
59644  p(ipa+1,4)=sqrt(pa2**2+pm2**2)
59645  p(ipa+1,5)=pm2
59646  p(ipa+2,1)=-p(ipa+1,1)-p(ipa+3,1)
59647  p(ipa+2,2)=-p(ipa+1,2)
59648  p(ipa+2,3)=-p(ipa,3)-p(ipa+1,3)-p(ipa+3,3)
59649  p(ipa+2,4)=sqrt(p(ipa+2,1)**2+p(ipa+2,2)**2+p(ipa+2,3)**2+pm3**2)
59650  p(ipa+2,5)=pm3
59651 
59652 C...Set N. Optionally fragment/decay.
59653  n=ipa+3
59654  IF(ip.EQ.0) CALL pyexec
59655 
59656  RETURN
59657  END
59658 
59659 C*********************************************************************
59660 
59661 C...PY2FRM
59662 C...An interface from a two-fermion generator to include
59663 C...parton showers and hadronization.
59664 
59665  SUBROUTINE py2frm(IRAD,ITAU,ICOM)
59666 
59667 C...Double precision and integer declarations.
59668  IMPLICIT DOUBLE PRECISION(a-h, o-z)
59669  IMPLICIT INTEGER(i-n)
59670  INTEGER pyk,pychge,pycomp
59671 C...Commonblocks.
59672  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
59673  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
59674  SAVE /pyjets/,/pydat1/
59675 C...Local arrays.
59676  dimension ijoin(2),intau(2)
59677 
59678 C...Call PYHEPC to convert input from HEPEVT to PYJETS common.
59679  IF(icom.EQ.0) THEN
59680  mstu(28)=0
59681  CALL pyhepc(2)
59682  ENDIF
59683 
59684 C...Loop through entries and pick up all final fermions/antifermions.
59685  i1=0
59686  i2=0
59687  DO 100 i=1,n
59688  IF(k(i,1).LE.0.OR.k(i,1).GT.10) goto 100
59689  kfa=iabs(k(i,2))
59690  IF((kfa.GE.1.AND.kfa.LE.6).OR.(kfa.GE.11.AND.kfa.LE.16)) THEN
59691  IF(k(i,2).GT.0) THEN
59692  IF(i1.EQ.0) THEN
59693  i1=i
59694  ELSE
59695  CALL pyerrm(16,'(PY2FRM:) more than one fermion')
59696  ENDIF
59697  ELSE
59698  IF(i2.EQ.0) THEN
59699  i2=i
59700  ELSE
59701  CALL pyerrm(16,'(PY2FRM:) more than one antifermion')
59702  ENDIF
59703  ENDIF
59704  ENDIF
59705  100 CONTINUE
59706 
59707 C...Check that event is arranged according to conventions.
59708  IF(i1.EQ.0.OR.i2.EQ.0) THEN
59709  CALL pyerrm(16,'(PY2FRM:) event contains too few fermions')
59710  ENDIF
59711  IF(i2.LT.i1) THEN
59712  CALL pyerrm(6,'(PY2FRM:) fermions arranged in wrong order')
59713  ENDIF
59714 
59715 C...Check whether fermion pair is quarks or leptons.
59716  IF(iabs(k(i1,2)).LT.10.AND.iabs(k(i2,2)).LT.10) THEN
59717  iql12=1
59718  ELSEIF(iabs(k(i1,2)).GT.10.AND.iabs(k(i2,2)).GT.10) THEN
59719  iql12=2
59720  ELSE
59721  CALL pyerrm(16,'(PY2FRM:) fermion pair inconsistent')
59722  ENDIF
59723 
59724 C...Decide whether to allow or not photon radiation in showers.
59725  mstj(41)=2
59726  IF(irad.EQ.0) mstj(41)=1
59727 
59728 C...Do colour joining and parton showers.
59729  ip1=i1
59730  ip2=i2
59731  IF(iql12.EQ.1) THEN
59732  ijoin(1)=ip1
59733  ijoin(2)=ip2
59734  CALL pyjoin(2,ijoin)
59735  ENDIF
59736  IF(iql12.EQ.1.OR.irad.EQ.1) THEN
59737  pm12s=(p(ip1,4)+p(ip2,4))**2-(p(ip1,1)+p(ip2,1))**2-
59738  & (p(ip1,2)+p(ip2,2))**2-(p(ip1,3)+p(ip2,3))**2
59739  CALL pyshow(ip1,ip2,sqrt(max(0d0,pm12s)))
59740  ENDIF
59741 
59742 C...Do fragmentation and decays. Possibly except tau decay.
59743  IF(itau.EQ.0) THEN
59744  ntau=0
59745  DO 110 i=1,n
59746  IF(iabs(k(i,2)).EQ.15.AND.k(i,1).EQ.1) THEN
59747  ntau=ntau+1
59748  intau(ntau)=i
59749  k(i,1)=11
59750  ENDIF
59751  110 CONTINUE
59752  ENDIF
59753  CALL pyexec
59754  IF(itau.EQ.0) THEN
59755  DO 120 i=1,ntau
59756  k(intau(i),1)=1
59757  120 CONTINUE
59758  ENDIF
59759 
59760 C...Call PYHEPC to convert output from PYJETS to HEPEVT common.
59761  IF(icom.EQ.0) THEN
59762  mstu(28)=0
59763  CALL pyhepc(1)
59764  ENDIF
59765 
59766  END
59767 
59768 C*********************************************************************
59769 
59770 C...PY4FRM
59771 C...An interface from a four-fermion generator to include
59772 C...parton showers and hadronization.
59773 
59774  SUBROUTINE py4frm(ATOTSQ,A1SQ,A2SQ,ISTRAT,IRAD,ITAU,ICOM)
59775 
59776 C...Double precision and integer declarations.
59777  IMPLICIT DOUBLE PRECISION(a-h, o-z)
59778  IMPLICIT INTEGER(i-n)
59779  INTEGER pyk,pychge,pycomp
59780 C...Commonblocks.
59781  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
59782  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
59783  common/pypars/mstp(200),parp(200),msti(200),pari(200)
59784  common/pyint1/mint(400),vint(400)
59785  SAVE /pyjets/,/pydat1/,/pypars/,/pyint1/
59786 C...Local arrays.
59787  dimension ijoin(2),intau(4)
59788 
59789 C...Call PYHEPC to convert input from HEPEVT to PYJETS common.
59790  IF(icom.EQ.0) THEN
59791  mstu(28)=0
59792  CALL pyhepc(2)
59793  ENDIF
59794 
59795 C...Loop through entries and pick up all final fermions/antifermions.
59796  i1=0
59797  i2=0
59798  i3=0
59799  i4=0
59800  DO 100 i=1,n
59801  IF(k(i,1).LE.0.OR.k(i,1).GT.10) goto 100
59802  kfa=iabs(k(i,2))
59803  IF((kfa.GE.1.AND.kfa.LE.6).OR.(kfa.GE.11.AND.kfa.LE.16)) THEN
59804  IF(k(i,2).GT.0) THEN
59805  IF(i1.EQ.0) THEN
59806  i1=i
59807  ELSEIF(i3.EQ.0) THEN
59808  i3=i
59809  ELSE
59810  CALL pyerrm(16,'(PY4FRM:) more than two fermions')
59811  ENDIF
59812  ELSE
59813  IF(i2.EQ.0) THEN
59814  i2=i
59815  ELSEIF(i4.EQ.0) THEN
59816  i4=i
59817  ELSE
59818  CALL pyerrm(16,'(PY4FRM:) more than two antifermions')
59819  ENDIF
59820  ENDIF
59821  ENDIF
59822  100 CONTINUE
59823 
59824 C...Check that event is arranged according to conventions.
59825  IF(i3.EQ.0.OR.i4.EQ.0) THEN
59826  CALL pyerrm(16,'(PY4FRM:) event contains too few fermions')
59827  ENDIF
59828  IF(i2.LT.i1.OR.i3.LT.i2.OR.i4.LT.i3) THEN
59829  CALL pyerrm(6,'(PY4FRM:) fermions arranged in wrong order')
59830  ENDIF
59831 
59832 C...Check which fermion pairs are quarks and which leptons.
59833  IF(iabs(k(i1,2)).LT.10.AND.iabs(k(i2,2)).LT.10) THEN
59834  iql12=1
59835  ELSEIF(iabs(k(i1,2)).GT.10.AND.iabs(k(i2,2)).GT.10) THEN
59836  iql12=2
59837  ELSE
59838  CALL pyerrm(16,'(PY4FRM:) first fermion pair inconsistent')
59839  ENDIF
59840  IF(iabs(k(i3,2)).LT.10.AND.iabs(k(i4,2)).LT.10) THEN
59841  iql34=1
59842  ELSEIF(iabs(k(i3,2)).GT.10.AND.iabs(k(i4,2)).GT.10) THEN
59843  iql34=2
59844  ELSE
59845  CALL pyerrm(16,'(PY4FRM:) second fermion pair inconsistent')
59846  ENDIF
59847 
59848 C...Decide whether to allow or not photon radiation in showers.
59849  mstj(41)=2
59850  IF(irad.EQ.0) mstj(41)=1
59851 
59852 C...Decide on dipole pairing.
59853  ip1=i1
59854  ip2=i2
59855  ip3=i3
59856  ip4=i4
59857  IF(iql12.EQ.iql34) THEN
59858  r1sq=a1sq
59859  r2sq=a2sq
59860  delta=atotsq-a1sq-a2sq
59861  IF(istrat.EQ.1) THEN
59862  IF(delta.GT.0d0) r1sq=r1sq+delta
59863  IF(delta.LT.0d0) r2sq=max(0d0,r2sq+delta)
59864  ELSEIF(istrat.EQ.2) THEN
59865  IF(delta.GT.0d0) r2sq=r2sq+delta
59866  IF(delta.LT.0d0) r1sq=max(0d0,r1sq+delta)
59867  ENDIF
59868  IF(r2sq.GT.pyr(0)*(r1sq+r2sq)) THEN
59869  ip2=i4
59870  ip4=i2
59871  ENDIF
59872  ENDIF
59873 
59874 C...If colour reconnection then bookkeep W+W- or Z0Z0
59875 C...and copy q qbar q qbar consecutively.
59876  IF(mstp(115).GE.1.AND.iql12.EQ.1.AND.iql34.EQ.1) THEN
59877  k(n+1,1)=11
59878  k(n+1,3)=ip1
59879  k(n+1,4)=n+3
59880  k(n+1,5)=n+4
59881  k(n+2,1)=11
59882  k(n+2,3)=ip3
59883  k(n+2,4)=n+5
59884  k(n+2,5)=n+6
59885  IF(k(ip1,2)+k(ip2,2).EQ.0) THEN
59886  k(n+1,2)=23
59887  k(n+2,2)=23
59888  mint(1)=22
59889  ELSEIF(pychge(k(ip1,2)).GT.0) THEN
59890  k(n+1,2)=24
59891  k(n+2,2)=-24
59892  mint(1)=25
59893  ELSE
59894  k(n+1,2)=-24
59895  k(n+2,2)=24
59896  mint(1)=25
59897  ENDIF
59898  DO 110 j=1,5
59899  k(n+3,j)=k(ip1,j)
59900  k(n+4,j)=k(ip2,j)
59901  k(n+5,j)=k(ip3,j)
59902  k(n+6,j)=k(ip4,j)
59903  p(n+1,j)=p(ip1,j)+p(ip2,j)
59904  p(n+2,j)=p(ip3,j)+p(ip4,j)
59905  p(n+3,j)=p(ip1,j)
59906  p(n+4,j)=p(ip2,j)
59907  p(n+5,j)=p(ip3,j)
59908  p(n+6,j)=p(ip4,j)
59909  v(n+1,j)=v(ip1,j)
59910  v(n+2,j)=v(ip3,j)
59911  v(n+3,j)=v(ip1,j)
59912  v(n+4,j)=v(ip2,j)
59913  v(n+5,j)=v(ip3,j)
59914  v(n+6,j)=v(ip4,j)
59915  110 CONTINUE
59916  p(n+1,5)=sqrt(max(0d0,p(n+1,4)**2-p(n+1,1)**2-p(n+1,2)**2-
59917  & p(n+1,3)**2))
59918  p(n+2,5)=sqrt(max(0d0,p(n+2,4)**2-p(n+2,1)**2-p(n+2,2)**2-
59919  & p(n+2,3)**2))
59920  k(n+3,3)=n+1
59921  k(n+4,3)=n+1
59922  k(n+5,3)=n+2
59923  k(n+6,3)=n+2
59924 C...Remove original q qbar q qbar and update counters.
59925  k(ip1,1)=k(ip1,1)+10
59926  k(ip2,1)=k(ip2,1)+10
59927  k(ip3,1)=k(ip3,1)+10
59928  k(ip4,1)=k(ip4,1)+10
59929  iw1=n+1
59930  iw2=n+2
59931  nsd1=n+2
59932  ip1=n+3
59933  ip2=n+4
59934  ip3=n+5
59935  ip4=n+6
59936  n=n+6
59937  ENDIF
59938 
59939 C...Do colour joinings and parton showers.
59940  IF(iql12.EQ.1) THEN
59941  ijoin(1)=ip1
59942  ijoin(2)=ip2
59943  CALL pyjoin(2,ijoin)
59944  ENDIF
59945  IF(iql12.EQ.1.OR.irad.EQ.1) THEN
59946  pm12s=(p(ip1,4)+p(ip2,4))**2-(p(ip1,1)+p(ip2,1))**2-
59947  & (p(ip1,2)+p(ip2,2))**2-(p(ip1,3)+p(ip2,3))**2
59948  CALL pyshow(ip1,ip2,sqrt(max(0d0,pm12s)))
59949  ENDIF
59950  naft1=n
59951  IF(iql34.EQ.1) THEN
59952  ijoin(1)=ip3
59953  ijoin(2)=ip4
59954  CALL pyjoin(2,ijoin)
59955  ENDIF
59956  IF(iql34.EQ.1.OR.irad.EQ.1) THEN
59957  pm34s=(p(ip3,4)+p(ip4,4))**2-(p(ip3,1)+p(ip4,1))**2-
59958  & (p(ip3,2)+p(ip4,2))**2-(p(ip3,3)+p(ip4,3))**2
59959  CALL pyshow(ip3,ip4,sqrt(max(0d0,pm34s)))
59960  ENDIF
59961 
59962 C...Optionally do colour reconnection.
59963  mint(32)=0
59964  msti(32)=0
59965  IF(mstp(115).GE.1.AND.iql12.EQ.1.AND.iql34.EQ.1) THEN
59966  CALL pyreco(iw1,iw2,nsd1,naft1)
59967  msti(32)=mint(32)
59968  ENDIF
59969 
59970 C...Do fragmentation and decays. Possibly except tau decay.
59971  IF(itau.EQ.0) THEN
59972  ntau=0
59973  DO 120 i=1,n
59974  IF(iabs(k(i,2)).EQ.15.AND.k(i,1).EQ.1) THEN
59975  ntau=ntau+1
59976  intau(ntau)=i
59977  k(i,1)=11
59978  ENDIF
59979  120 CONTINUE
59980  ENDIF
59981  CALL pyexec
59982  IF(itau.EQ.0) THEN
59983  DO 130 i=1,ntau
59984  k(intau(i),1)=1
59985  130 CONTINUE
59986  ENDIF
59987 
59988 C...Call PYHEPC to convert output from PYJETS to HEPEVT common.
59989  IF(icom.EQ.0) THEN
59990  mstu(28)=0
59991  CALL pyhepc(1)
59992  ENDIF
59993 
59994  END
59995 
59996 C*********************************************************************
59997 
59998 C...PY6FRM
59999 C...An interface from a six-fermion generator to include
60000 C...parton showers and hadronization.
60001 
60002  SUBROUTINE py6frm(P12,P13,P21,P23,P31,P32,PTOP,IRAD,ITAU,ICOM)
60003 
60004 C...Double precision and integer declarations.
60005  IMPLICIT DOUBLE PRECISION(a-h, o-z)
60006  IMPLICIT INTEGER(i-n)
60007  INTEGER pyk,pychge,pycomp
60008 C...Commonblocks.
60009  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
60010  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
60011  SAVE /pyjets/,/pydat1/
60012 C...Local arrays.
60013  dimension ijoin(2),intau(6),beta(3),betao(3),betan(3)
60014 
60015 C...Call PYHEPC to convert input from HEPEVT to PYJETS common.
60016  IF(icom.EQ.0) THEN
60017  mstu(28)=0
60018  CALL pyhepc(2)
60019  ENDIF
60020 
60021 C...Loop through entries and pick up all final fermions/antifermions.
60022  i1=0
60023  i2=0
60024  i3=0
60025  i4=0
60026  i5=0
60027  i6=0
60028  DO 100 i=1,n
60029  IF(k(i,1).LE.0.OR.k(i,1).GT.10) goto 100
60030  kfa=iabs(k(i,2))
60031  IF((kfa.GE.1.AND.kfa.LE.6).OR.(kfa.GE.11.AND.kfa.LE.16)) THEN
60032  IF(k(i,2).GT.0) THEN
60033  IF(i1.EQ.0) THEN
60034  i1=i
60035  ELSEIF(i3.EQ.0) THEN
60036  i3=i
60037  ELSEIF(i5.EQ.0) THEN
60038  i5=i
60039  ELSE
60040  CALL pyerrm(16,'(PY6FRM:) more than three fermions')
60041  ENDIF
60042  ELSE
60043  IF(i2.EQ.0) THEN
60044  i2=i
60045  ELSEIF(i4.EQ.0) THEN
60046  i4=i
60047  ELSEIF(i6.EQ.0) THEN
60048  i6=i
60049  ELSE
60050  CALL pyerrm(16,'(PY6FRM:) more than three antifermions')
60051  ENDIF
60052  ENDIF
60053  ENDIF
60054  100 CONTINUE
60055 
60056 C...Check that event is arranged according to conventions.
60057  IF(i5.EQ.0.OR.i6.EQ.0) THEN
60058  CALL pyerrm(16,'(PY6FRM:) event contains too few fermions')
60059  ENDIF
60060  IF(i2.LT.i1.OR.i3.LT.i2.OR.i4.LT.i3.OR.i5.LT.i4.OR.i6.LT.i5) THEN
60061  CALL pyerrm(6,'(PY6FRM:) fermions arranged in wrong order')
60062  ENDIF
60063 
60064 C...Check which fermion pairs are quarks and which leptons.
60065  IF(iabs(k(i1,2)).LT.10.AND.iabs(k(i2,2)).LT.10) THEN
60066  iql12=1
60067  ELSEIF(iabs(k(i1,2)).GT.10.AND.iabs(k(i2,2)).GT.10) THEN
60068  iql12=2
60069  ELSE
60070  CALL pyerrm(16,'(PY6FRM:) first fermion pair inconsistent')
60071  ENDIF
60072  IF(iabs(k(i3,2)).LT.10.AND.iabs(k(i4,2)).LT.10) THEN
60073  iql34=1
60074  ELSEIF(iabs(k(i3,2)).GT.10.AND.iabs(k(i4,2)).GT.10) THEN
60075  iql34=2
60076  ELSE
60077  CALL pyerrm(16,'(PY6FRM:) second fermion pair inconsistent')
60078  ENDIF
60079  IF(iabs(k(i5,2)).LT.10.AND.iabs(k(i6,2)).LT.10) THEN
60080  iql56=1
60081  ELSEIF(iabs(k(i5,2)).GT.10.AND.iabs(k(i6,2)).GT.10) THEN
60082  iql56=2
60083  ELSE
60084  CALL pyerrm(16,'(PY6FRM:) third fermion pair inconsistent')
60085  ENDIF
60086 
60087 C...Decide whether to allow or not photon radiation in showers.
60088  mstj(41)=2
60089  IF(irad.EQ.0) mstj(41)=1
60090 
60091 C...Allow dipole pairings only among leptons and quarks separately.
60092  p12d=p12
60093  p13d=0d0
60094  IF(iql34.EQ.iql56) p13d=p13
60095  p21d=0d0
60096  IF(iql12.EQ.iql34) p21d=p21
60097  p23d=0d0
60098  IF(iql12.EQ.iql34.AND.iql12.EQ.iql56) p23d=p23
60099  p31d=0d0
60100  IF(iql12.EQ.iql34.AND.iql12.EQ.iql56) p31d=p31
60101  p32d=0d0
60102  IF(iql12.EQ.iql56) p32d=p32
60103 
60104 C...Decide whether t+tbar.
60105  itop=0
60106  IF(pyr(0).LT.ptop) THEN
60107  itop=1
60108 
60109 C...If t+tbar: reconstruct t's.
60110  it=n+1
60111  itb=n+2
60112  DO 110 j=1,5
60113  k(it,j)=0
60114  k(itb,j)=0
60115  p(it,j)=p(i1,j)+p(i3,j)+p(i4,j)
60116  p(itb,j)=p(i2,j)+p(i5,j)+p(i6,j)
60117  v(it,j)=0d0
60118  v(itb,j)=0d0
60119  110 CONTINUE
60120  k(it,1)=1
60121  k(itb,1)=1
60122  k(it,2)=6
60123  k(itb,2)=-6
60124  p(it,5)=sqrt(max(0d0,p(it,4)**2-p(it,1)**2-p(it,2)**2-
60125  & p(it,3)**2))
60126  p(itb,5)=sqrt(max(0d0,p(itb,4)**2-p(itb,1)**2-p(itb,2)**2-
60127  & p(itb,3)**2))
60128  n=n+2
60129 
60130 C...If t+tbar: colour join t's and let them shower.
60131  ijoin(1)=it
60132  ijoin(2)=itb
60133  CALL pyjoin(2,ijoin)
60134  pmtts=(p(it,4)+p(itb,4))**2-(p(it,1)+p(itb,1))**2-
60135  & (p(it,2)+p(itb,2))**2-(p(it,3)+p(itb,3))**2
60136  CALL pyshow(it,itb,sqrt(max(0d0,pmtts)))
60137 
60138 C...If t+tbar: pick up the t's after shower.
60139  itnew=it
60140  itbnew=itb
60141  DO 120 i=itb+1,n
60142  IF(k(i,2).EQ.6) itnew=i
60143  IF(k(i,2).EQ.-6) itbnew=i
60144  120 CONTINUE
60145 
60146 C...If t+tbar: loop over two top systems.
60147  DO 200 it1=1,2
60148  IF(it1.EQ.1) THEN
60149  ito=it
60150  itn=itnew
60151  ibo=i1
60152  iw1=i3
60153  iw2=i4
60154  ELSE
60155  ito=itb
60156  itn=itbnew
60157  ibo=i2
60158  iw1=i5
60159  iw2=i6
60160  ENDIF
60161  IF(iabs(k(ibo,2)).NE.5) CALL pyerrm(6,
60162  & '(PY6FRM:) not b in t decay')
60163 
60164 C...If t+tbar: find boost from original to new top frame.
60165  DO 130 j=1,3
60166  betao(j)=p(ito,j)/p(ito,4)
60167  betan(j)=p(itn,j)/p(itn,4)
60168  130 CONTINUE
60169 
60170 C...If t+tbar: boost copy of b by t shower and connect it in colour.
60171  n=n+1
60172  ib=n
60173  k(ib,1)=3
60174  k(ib,2)=k(ibo,2)
60175  k(ib,3)=itn
60176  DO 140 j=1,5
60177  p(ib,j)=p(ibo,j)
60178  v(ib,j)=0d0
60179  140 CONTINUE
60180  CALL pyrobo(ib,ib,0d0,0d0,-betao(1),-betao(2),-betao(3))
60181  CALL pyrobo(ib,ib,0d0,0d0,betan(1),betan(2),betan(3))
60182  k(ib,4)=mstu(5)*itn
60183  k(ib,5)=mstu(5)*itn
60184  k(itn,4)=k(itn,4)+ib
60185  k(itn,5)=k(itn,5)+ib
60186  k(itn,1)=k(itn,1)+10
60187  k(ibo,1)=k(ibo,1)+10
60188 
60189 C...If t+tbar: construct W recoiling against b.
60190  n=n+1
60191  iw=n
60192  DO 150 j=1,5
60193  k(iw,j)=0
60194  v(iw,j)=0d0
60195  150 CONTINUE
60196  k(iw,1)=1
60197  kchw=pychge(k(iw1,2))+pychge(k(iw2,2))
60198  IF(iabs(kchw).EQ.3) THEN
60199  k(iw,2)=isign(24,kchw)
60200  ELSE
60201  CALL pyerrm(16,'(PY6FRM:) fermion pair inconsistent with W')
60202  ENDIF
60203  k(iw,3)=iw1
60204 
60205 C...If t+tbar: construct W momentum, including boost by t shower.
60206  DO 160 j=1,4
60207  p(iw,j)=p(iw1,j)+p(iw2,j)
60208  160 CONTINUE
60209  p(iw,5)=sqrt(max(0d0,p(iw,4)**2-p(iw,1)**2-p(iw,2)**2-
60210  & p(iw,3)**2))
60211  CALL pyrobo(iw,iw,0d0,0d0,-betao(1),-betao(2),-betao(3))
60212  CALL pyrobo(iw,iw,0d0,0d0,betan(1),betan(2),betan(3))
60213 
60214 C...If t+tbar: boost b and W to top rest frame.
60215  DO 170 j=1,3
60216  beta(j)=(p(ib,j)+p(iw,j))/(p(ib,4)+p(iw,4))
60217  170 CONTINUE
60218  CALL pyrobo(ib,ib,0d0,0d0,-beta(1),-beta(2),-beta(3))
60219  CALL pyrobo(iw,iw,0d0,0d0,-beta(1),-beta(2),-beta(3))
60220 
60221 C...If t+tbar: let b shower and pick up modified W.
60222  pmts=(p(ib,4)+p(iw,4))**2-(p(ib,1)+p(iw,1))**2-
60223  & (p(ib,2)+p(iw,2))**2-(p(ib,3)+p(iw,3))**2
60224  CALL pyshow(ib,iw,sqrt(max(0d0,pmts)))
60225  DO 180 i=iw,n
60226  IF(iabs(k(i,2)).EQ.24) iwm=i
60227  180 CONTINUE
60228 
60229 C...If t+tbar: take copy of W decay products.
60230  DO 190 j=1,5
60231  k(n+1,j)=k(iw1,j)
60232  p(n+1,j)=p(iw1,j)
60233  v(n+1,j)=v(iw1,j)
60234  k(n+2,j)=k(iw2,j)
60235  p(n+2,j)=p(iw2,j)
60236  v(n+2,j)=v(iw2,j)
60237  190 CONTINUE
60238  k(iw1,1)=k(iw1,1)+10
60239  k(iw2,1)=k(iw2,1)+10
60240  k(iwm,1)=k(iwm,1)+10
60241  k(iwm,4)=n+1
60242  k(iwm,5)=n+2
60243  k(n+1,3)=iwm
60244  k(n+2,3)=iwm
60245  IF(it1.EQ.1) THEN
60246  i3=n+1
60247  i4=n+2
60248  ELSE
60249  i5=n+1
60250  i6=n+2
60251  ENDIF
60252  n=n+2
60253 
60254 C...If t+tbar: boost W decay products, first by effects of t shower,
60255 C...then by those of b shower. b and its shower simple boost back.
60256  CALL pyrobo(n-1,n,0d0,0d0,-betao(1),-betao(2),-betao(3))
60257  CALL pyrobo(n-1,n,0d0,0d0,betan(1),betan(2),betan(3))
60258  CALL pyrobo(n-1,n,0d0,0d0,-beta(1),-beta(2),-beta(3))
60259  CALL pyrobo(n-1,n,0d0,0d0,-p(iw,1)/p(iw,4),
60260  & -p(iw,2)/p(iw,4),-p(iw,3)/p(iw,4))
60261  CALL pyrobo(n-1,n,0d0,0d0,p(iwm,1)/p(iwm,4),
60262  & p(iwm,2)/p(iwm,4),p(iwm,3)/p(iwm,4))
60263  CALL pyrobo(ib,ib,0d0,0d0,beta(1),beta(2),beta(3))
60264  CALL pyrobo(iw,n,0d0,0d0,beta(1),beta(2),beta(3))
60265  200 CONTINUE
60266  ENDIF
60267 
60268 C...Decide on dipole pairing.
60269  ip1=i1
60270  ip3=i3
60271  ip5=i5
60272  prn=pyr(0)*(p12d+p13d+p21d+p23d+p31d+p32d)
60273  IF(itop.EQ.1.OR.prn.LT.p12d) THEN
60274  ip2=i2
60275  ip4=i4
60276  ip6=i6
60277  ELSEIF(prn.LT.p12d+p13d) THEN
60278  ip2=i2
60279  ip4=i6
60280  ip6=i4
60281  ELSEIF(prn.LT.p12d+p13d+p21d) THEN
60282  ip2=i4
60283  ip4=i2
60284  ip6=i6
60285  ELSEIF(prn.LT.p12d+p13d+p21d+p23d) THEN
60286  ip2=i4
60287  ip4=i6
60288  ip6=i2
60289  ELSEIF(prn.LT.p12d+p13d+p21d+p23d+p31d) THEN
60290  ip2=i6
60291  ip4=i2
60292  ip6=i4
60293  ELSE
60294  ip2=i6
60295  ip4=i4
60296  ip6=i2
60297  ENDIF
60298 
60299 C...Do colour joinings and parton showers
60300 C...(except ones already made for t+tbar).
60301  IF(itop.EQ.0) THEN
60302  IF(iql12.EQ.1) THEN
60303  ijoin(1)=ip1
60304  ijoin(2)=ip2
60305  CALL pyjoin(2,ijoin)
60306  ENDIF
60307  IF(iql12.EQ.1.OR.irad.EQ.1) THEN
60308  pm12s=(p(ip1,4)+p(ip2,4))**2-(p(ip1,1)+p(ip2,1))**2-
60309  & (p(ip1,2)+p(ip2,2))**2-(p(ip1,3)+p(ip2,3))**2
60310  CALL pyshow(ip1,ip2,sqrt(max(0d0,pm12s)))
60311  ENDIF
60312  ENDIF
60313  IF(iql34.EQ.1) THEN
60314  ijoin(1)=ip3
60315  ijoin(2)=ip4
60316  CALL pyjoin(2,ijoin)
60317  ENDIF
60318  IF(iql34.EQ.1.OR.irad.EQ.1) THEN
60319  pm34s=(p(ip3,4)+p(ip4,4))**2-(p(ip3,1)+p(ip4,1))**2-
60320  & (p(ip3,2)+p(ip4,2))**2-(p(ip3,3)+p(ip4,3))**2
60321  CALL pyshow(ip3,ip4,sqrt(max(0d0,pm34s)))
60322  ENDIF
60323  IF(iql56.EQ.1) THEN
60324  ijoin(1)=ip5
60325  ijoin(2)=ip6
60326  CALL pyjoin(2,ijoin)
60327  ENDIF
60328  IF(iql56.EQ.1.OR.irad.EQ.1) THEN
60329  pm56s=(p(ip5,4)+p(ip6,4))**2-(p(ip5,1)+p(ip6,1))**2-
60330  & (p(ip5,2)+p(ip6,2))**2-(p(ip5,3)+p(ip6,3))**2
60331  CALL pyshow(ip5,ip6,sqrt(max(0d0,pm56s)))
60332  ENDIF
60333 
60334 C...Do fragmentation and decays. Possibly except tau decay.
60335  IF(itau.EQ.0) THEN
60336  ntau=0
60337  DO 210 i=1,n
60338  IF(iabs(k(i,2)).EQ.15.AND.k(i,1).EQ.1) THEN
60339  ntau=ntau+1
60340  intau(ntau)=i
60341  k(i,1)=11
60342  ENDIF
60343  210 CONTINUE
60344  ENDIF
60345  CALL pyexec
60346  IF(itau.EQ.0) THEN
60347  DO 220 i=1,ntau
60348  k(intau(i),1)=1
60349  220 CONTINUE
60350  ENDIF
60351 
60352 C...Call PYHEPC to convert output from PYJETS to HEPEVT common.
60353  IF(icom.EQ.0) THEN
60354  mstu(28)=0
60355  CALL pyhepc(1)
60356  ENDIF
60357 
60358  END
60359 
60360 C*********************************************************************
60361 
60362 C...PY4JET
60363 C...An interface from a four-parton generator to include
60364 C...parton showers and hadronization.
60365 
60366  SUBROUTINE py4jet(PMAX,IRAD,ICOM)
60367 
60368 C...Double precision and integer declarations.
60369  IMPLICIT DOUBLE PRECISION(a-h, o-z)
60370  IMPLICIT INTEGER(i-n)
60371  INTEGER pyk,pychge,pycomp
60372 C...Commonblocks.
60373  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
60374  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
60375  SAVE /pyjets/,/pydat1/
60376 C...Local arrays.
60377  dimension ijoin(2),ptot(4),beta(3)
60378 
60379 C...Call PYHEPC to convert input from HEPEVT to PYJETS common.
60380  IF(icom.EQ.0) THEN
60381  mstu(28)=0
60382  CALL pyhepc(2)
60383  ENDIF
60384 
60385 C...Loop through entries and pick up all final partons.
60386  i1=0
60387  i2=0
60388  i3=0
60389  i4=0
60390  DO 100 i=1,n
60391  IF(k(i,1).LE.0.OR.k(i,1).GT.10) goto 100
60392  kfa=iabs(k(i,2))
60393  IF((kfa.GE.1.AND.kfa.LE.6).OR.kfa.EQ.21) THEN
60394  IF(k(i,2).GT.0.AND.k(i,2).LE.6) THEN
60395  IF(i1.EQ.0) THEN
60396  i1=i
60397  ELSEIF(i3.EQ.0) THEN
60398  i3=i
60399  ELSE
60400  CALL pyerrm(16,'(PY4JET:) more than two quarks')
60401  ENDIF
60402  ELSEIF(k(i,2).LT.0) THEN
60403  IF(i2.EQ.0) THEN
60404  i2=i
60405  ELSEIF(i4.EQ.0) THEN
60406  i4=i
60407  ELSE
60408  CALL pyerrm(16,'(PY4JET:) more than two antiquarks')
60409  ENDIF
60410  ELSE
60411  IF(i3.EQ.0) THEN
60412  i3=i
60413  ELSEIF(i4.EQ.0) THEN
60414  i4=i
60415  ELSE
60416  CALL pyerrm(16,'(PY4JET:) more than two gluons')
60417  ENDIF
60418  ENDIF
60419  ENDIF
60420  100 CONTINUE
60421 
60422 C...Check that event is arranged according to conventions.
60423  IF(i1.EQ.0.OR.i2.EQ.0.OR.i3.EQ.0.OR.i4.EQ.0) THEN
60424  CALL pyerrm(16,'(PY4JET:) event contains too few partons')
60425  ENDIF
60426  IF(i2.LT.i1.OR.i3.LT.i2.OR.i4.LT.i3) THEN
60427  CALL pyerrm(6,'(PY4JET:) partons arranged in wrong order')
60428  ENDIF
60429 
60430 C...Check whether second pair are quarks or gluons.
60431  IF(iabs(k(i3,2)).LT.10.AND.iabs(k(i4,2)).LT.10) THEN
60432  iqg34=1
60433  ELSEIF(k(i3,2).EQ.21.AND.k(i4,2).EQ.21) THEN
60434  iqg34=2
60435  ELSE
60436  CALL pyerrm(16,'(PY4JET:) second parton pair inconsistent')
60437  ENDIF
60438 
60439 C...Boost partons to their cm frame.
60440  DO 110 j=1,4
60441  ptot(j)=p(i1,j)+p(i2,j)+p(i3,j)+p(i4,j)
60442  110 CONTINUE
60443  ecm=sqrt(max(0d0,ptot(4)**2-ptot(1)**2-ptot(2)**2-ptot(3)**2))
60444  DO 120 j=1,3
60445  beta(j)=ptot(j)/ptot(4)
60446  120 CONTINUE
60447  CALL pyrobo(i1,i1,0d0,0d0,-beta(1),-beta(2),-beta(3))
60448  CALL pyrobo(i2,i2,0d0,0d0,-beta(1),-beta(2),-beta(3))
60449  CALL pyrobo(i3,i3,0d0,0d0,-beta(1),-beta(2),-beta(3))
60450  CALL pyrobo(i4,i4,0d0,0d0,-beta(1),-beta(2),-beta(3))
60451  nsav=n
60452 
60453 C...Decide and set up shower history for q qbar q' qbar' events.
60454  IF(iqg34.EQ.1) THEN
60455  w1=py4jtw(0,i1,i3,i4)
60456  w2=py4jtw(0,i2,i3,i4)
60457  IF(w1.GT.pyr(0)*(w1+w2)) THEN
60458  CALL py4jts(0,i1,i3,i4,i2,qmax)
60459  ELSE
60460  CALL py4jts(0,i2,i3,i4,i1,qmax)
60461  ENDIF
60462 
60463 C...Decide and set up shower history for q qbar g g events.
60464  ELSE
60465  w1=py4jtw(i1,i3,i2,i4)
60466  w2=py4jtw(i1,i4,i2,i3)
60467  w3=py4jtw(0,i3,i1,i4)
60468  w4=py4jtw(0,i4,i1,i3)
60469  w5=py4jtw(0,i3,i2,i4)
60470  w6=py4jtw(0,i4,i2,i3)
60471  w7=py4jtw(0,i1,i3,i4)
60472  w8=py4jtw(0,i2,i3,i4)
60473  wr=(w1+w2+w3+w4+w5+w6+w7+w8)*pyr(0)
60474  IF(w1.GT.wr) THEN
60475  CALL py4jts(i1,i3,i2,i4,0,qmax)
60476  ELSEIF(w1+w2.GT.wr) THEN
60477  CALL py4jts(i1,i4,i2,i3,0,qmax)
60478  ELSEIF(w1+w2+w3.GT.wr) THEN
60479  CALL py4jts(0,i3,i1,i4,i2,qmax)
60480  ELSEIF(w1+w2+w3+w4.GT.wr) THEN
60481  CALL py4jts(0,i4,i1,i3,i2,qmax)
60482  ELSEIF(w1+w2+w3+w4+w5.GT.wr) THEN
60483  CALL py4jts(0,i3,i2,i4,i1,qmax)
60484  ELSEIF(w1+w2+w3+w4+w5+w6.GT.wr) THEN
60485  CALL py4jts(0,i4,i2,i3,i1,qmax)
60486  ELSEIF(w1+w2+w3+w4+w5+w6+w7.GT.wr) THEN
60487  CALL py4jts(0,i1,i3,i4,i2,qmax)
60488  ELSE
60489  CALL py4jts(0,i2,i3,i4,i1,qmax)
60490  ENDIF
60491  ENDIF
60492 
60493 C...Boost back original partons and mark them as deleted.
60494  CALL pyrobo(i1,i1,0d0,0d0,beta(1),beta(2),beta(3))
60495  CALL pyrobo(i2,i2,0d0,0d0,beta(1),beta(2),beta(3))
60496  CALL pyrobo(i3,i3,0d0,0d0,beta(1),beta(2),beta(3))
60497  CALL pyrobo(i4,i4,0d0,0d0,beta(1),beta(2),beta(3))
60498  k(i1,1)=k(i1,1)+10
60499  k(i2,1)=k(i2,1)+10
60500  k(i3,1)=k(i3,1)+10
60501  k(i4,1)=k(i4,1)+10
60502 
60503 C...Rotate shower initiating partons to be along z axis.
60504  phi=pyangl(p(nsav+1,1),p(nsav+1,2))
60505  CALL pyrobo(nsav+1,nsav+6,0d0,-phi,0d0,0d0,0d0)
60506  the=pyangl(p(nsav+1,3),p(nsav+1,1))
60507  CALL pyrobo(nsav+1,nsav+6,-the,0d0,0d0,0d0,0d0)
60508 
60509 C...Set up copy of shower initiating partons as on mass shell.
60510  DO 140 i=n+1,n+2
60511  DO 130 j=1,5
60512  k(i,j)=0
60513  p(i,j)=0d0
60514  v(i,j)=v(i1,j)
60515  130 CONTINUE
60516  k(i,1)=1
60517  k(i,2)=k(i-6,2)
60518  140 CONTINUE
60519  IF(k(nsav+1,2).EQ.k(i1,2)) THEN
60520  k(n+1,3)=i1
60521  p(n+1,5)=p(i1,5)
60522  k(n+2,3)=i2
60523  p(n+2,5)=p(i2,5)
60524  ELSE
60525  k(n+1,3)=i2
60526  p(n+1,5)=p(i2,5)
60527  k(n+2,3)=i1
60528  p(n+2,5)=p(i1,5)
60529  ENDIF
60530  pabs=sqrt(max(0d0,(ecm**2-p(n+1,5)**2-p(n+2,5)**2)**2-
60531  &(2d0*p(n+1,5)*p(n+2,5))**2))/(2d0*ecm)
60532  p(n+1,3)=pabs
60533  p(n+1,4)=sqrt(pabs**2+p(n+1,5)**2)
60534  p(n+2,3)=-pabs
60535  p(n+2,4)=sqrt(pabs**2+p(n+2,5)**2)
60536  n=n+2
60537 
60538 C...Decide whether to allow or not photon radiation in showers.
60539 C...Connect up colours.
60540  mstj(41)=2
60541  IF(irad.EQ.0) mstj(41)=1
60542  ijoin(1)=n-1
60543  ijoin(2)=n
60544  CALL pyjoin(2,ijoin)
60545 
60546 C...Decide on maximum virtuality and do parton shower.
60547  IF(pmax.LT.parj(82)) THEN
60548  pqmax=qmax
60549  ELSE
60550  pqmax=pmax
60551  ENDIF
60552  CALL pyshow(nsav+1,-100,pqmax)
60553 
60554 C...Rotate and boost back system.
60555  CALL pyrobo(nsav+1,n,the,phi,beta(1),beta(2),beta(3))
60556 
60557 C...Do fragmentation and decays.
60558  CALL pyexec
60559 
60560 C...Call PYHEPC to convert output from PYJETS to HEPEVT common.
60561  IF(icom.EQ.0) THEN
60562  mstu(28)=0
60563  CALL pyhepc(1)
60564  ENDIF
60565 
60566  RETURN
60567  END
60568 
60569 C*********************************************************************
60570 
60571 C...PY4JTW
60572 C...Auxiliary to PY4JET, to evaluate weight of configuration.
60573 
60574  FUNCTION py4jtw(IA1,IA2,IA3,IA4)
60575 
60576 C...Double precision and integer declarations.
60577  IMPLICIT DOUBLE PRECISION(a-h, o-z)
60578  IMPLICIT INTEGER(i-n)
60579  INTEGER pyk,pychge,pycomp
60580 C...Commonblocks.
60581  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
60582  SAVE /pyjets/
60583 
60584 C...First case: when both original partons radiate.
60585 C...IA1 /= 0: N+1 -> IA1 + IA2, N+2 -> IA3 + IA4.
60586  IF(ia1.NE.0) THEN
60587  DO 100 j=1,4
60588  p(n+1,j)=p(ia1,j)+p(ia2,j)
60589  p(n+2,j)=p(ia3,j)+p(ia4,j)
60590  100 CONTINUE
60591  p(n+1,5)=sqrt(max(0d0,p(n+1,4)**2-p(n+1,1)**2-p(n+1,2)**2-
60592  & p(n+1,3)**2))
60593  p(n+2,5)=sqrt(max(0d0,p(n+2,4)**2-p(n+2,1)**2-p(n+2,2)**2-
60594  & p(n+2,3)**2))
60595  z1=p(ia1,4)/p(n+1,4)
60596  wt1=(4d0/3d0)*((1d0+z1**2)/(1d0-z1))/(p(n+1,5)**2-p(ia1,5)**2)
60597  z2=p(ia3,4)/p(n+2,4)
60598  wt2=(4d0/3d0)*((1d0+z2**2)/(1d0-z2))/(p(n+2,5)**2-p(ia3,5)**2)
60599 
60600 C...Second case: when one original parton radiates to three.
60601 C...IA1 = 0: N+1 -> IA2 + N+2, N+2 -> IA3 + IA4.
60602  ELSE
60603  DO 110 j=1,4
60604  p(n+2,j)=p(ia3,j)+p(ia4,j)
60605  p(n+1,j)=p(n+2,j)+p(ia2,j)
60606  110 CONTINUE
60607  p(n+1,5)=sqrt(max(0d0,p(n+1,4)**2-p(n+1,1)**2-p(n+1,2)**2-
60608  & p(n+1,3)**2))
60609  p(n+2,5)=sqrt(max(0d0,p(n+2,4)**2-p(n+2,1)**2-p(n+2,2)**2-
60610  & p(n+2,3)**2))
60611  IF(k(ia2,2).EQ.21) THEN
60612  z1=p(n+2,4)/p(n+1,4)
60613  wt1=(4d0/3d0)*((1d0+z1**2)/(1d0-z1))/(p(n+1,5)**2-
60614  & p(ia3,5)**2)
60615  ELSE
60616  z1=p(ia2,4)/p(n+1,4)
60617  wt1=(4d0/3d0)*((1d0+z1**2)/(1d0-z1))/(p(n+1,5)**2-
60618  & p(ia2,5)**2)
60619  ENDIF
60620  z2=p(ia3,4)/p(n+2,4)
60621  IF(k(ia2,2).EQ.21) THEN
60622  wt2=(4d0/3d0)*((1d0+z2**2)/(1d0-z2))/(p(n+2,5)**2-
60623  & p(ia3,5)**2)
60624  ELSEIF(k(ia3,2).EQ.21) THEN
60625  wt2=3d0*((1d0-z2*(1d0-z2))**2/(z2*(1d0-z2)))/p(n+2,5)**2
60626  ELSE
60627  wt2=0.5d0*(z2**2+(1d0-z2)**2)
60628  ENDIF
60629  ENDIF
60630 
60631 C...Total weight.
60632  py4jtw=wt1*wt2
60633 
60634  RETURN
60635  END
60636 
60637 C*********************************************************************
60638 
60639 C...PY4JTS
60640 C...Auxiliary to PY4JET, to set up chosen configuration.
60641 
60642  SUBROUTINE py4jts(IA1,IA2,IA3,IA4,IA5,QMAX)
60643 
60644 C...Double precision and integer declarations.
60645  IMPLICIT DOUBLE PRECISION(a-h, o-z)
60646  IMPLICIT INTEGER(i-n)
60647  INTEGER pyk,pychge,pycomp
60648 C...Commonblocks.
60649  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
60650  SAVE /pyjets/
60651 
60652 C...Reset info.
60653  DO 110 i=n+1,n+6
60654  DO 100 j=1,5
60655  k(i,j)=0
60656  v(i,j)=v(ia2,j)
60657  100 CONTINUE
60658  k(i,1)=16
60659  110 CONTINUE
60660 
60661 C...First case: when both original partons radiate.
60662 C...N+1 -> (IA1=N+3) + (IA2=N+4), N+2 -> (IA3=N+5) + (IA4=N+6).
60663  IF(ia1.NE.0) THEN
60664 
60665 C...Set up flavour and history pointers for new partons.
60666  k(n+1,2)=k(ia1,2)
60667  k(n+2,2)=k(ia3,2)
60668  k(n+3,2)=k(ia1,2)
60669  k(n+4,2)=k(ia2,2)
60670  k(n+5,2)=k(ia3,2)
60671  k(n+6,2)=k(ia4,2)
60672  k(n+1,3)=ia1
60673  k(n+1,4)=n+3
60674  k(n+1,5)=n+4
60675  k(n+2,3)=ia3
60676  k(n+2,4)=n+5
60677  k(n+2,5)=n+6
60678  k(n+3,3)=n+1
60679  k(n+4,3)=n+1
60680  k(n+5,3)=n+2
60681  k(n+6,3)=n+2
60682 
60683 C...Set up momenta for new partons.
60684  DO 120 j=1,5
60685  p(n+1,j)=p(ia1,j)+p(ia2,j)
60686  p(n+2,j)=p(ia3,j)+p(ia4,j)
60687  p(n+3,j)=p(ia1,j)
60688  p(n+4,j)=p(ia2,j)
60689  p(n+5,j)=p(ia3,j)
60690  p(n+6,j)=p(ia4,j)
60691  120 CONTINUE
60692  p(n+1,5)=sqrt(max(0d0,p(n+1,4)**2-p(n+1,1)**2-p(n+1,2)**2-
60693  & p(n+1,3)**2))
60694  p(n+2,5)=sqrt(max(0d0,p(n+2,4)**2-p(n+2,1)**2-p(n+2,2)**2-
60695  & p(n+2,3)**2))
60696  qmax=min(p(n+1,5),p(n+2,5))
60697 
60698 C...Second case: q radiates twice.
60699 C...N+1 -> (IA2=N+4) + N+3, N+3 -> (IA3=N+5) + (IA4=N+6),
60700 C...IA5=N+2 does not radiate.
60701  ELSEIF(k(ia2,2).EQ.21) THEN
60702 
60703 C...Set up flavour and history pointers for new partons.
60704  k(n+1,2)=k(ia3,2)
60705  k(n+2,2)=k(ia5,2)
60706  k(n+3,2)=k(ia3,2)
60707  k(n+4,2)=k(ia2,2)
60708  k(n+5,2)=k(ia3,2)
60709  k(n+6,2)=k(ia4,2)
60710  k(n+1,3)=ia3
60711  k(n+1,4)=n+3
60712  k(n+1,5)=n+4
60713  k(n+2,3)=ia5
60714  k(n+3,3)=n+1
60715  k(n+3,4)=n+5
60716  k(n+3,5)=n+6
60717  k(n+4,3)=n+1
60718  k(n+5,3)=n+3
60719  k(n+6,3)=n+3
60720 
60721 C...Set up momenta for new partons.
60722  DO 130 j=1,5
60723  p(n+1,j)=p(ia2,j)+p(ia3,j)+p(ia4,j)
60724  p(n+2,j)=p(ia5,j)
60725  p(n+3,j)=p(ia3,j)+p(ia4,j)
60726  p(n+4,j)=p(ia2,j)
60727  p(n+5,j)=p(ia3,j)
60728  p(n+6,j)=p(ia4,j)
60729  130 CONTINUE
60730  p(n+1,5)=sqrt(max(0d0,p(n+1,4)**2-p(n+1,1)**2-p(n+1,2)**2-
60731  & p(n+1,3)**2))
60732  p(n+3,5)=sqrt(max(0d0,p(n+3,4)**2-p(n+3,1)**2-p(n+3,2)**2-
60733  & p(n+3,3)**2))
60734  qmax=p(n+3,5)
60735 
60736 C...Third case: q radiates g, g branches.
60737 C...N+1 -> (IA2=N+3) + N+4, N+4 -> (IA3=N+5) + (IA4=N+6),
60738 C...IA5=N+2 does not radiate.
60739  ELSE
60740 
60741 C...Set up flavour and history pointers for new partons.
60742  k(n+1,2)=k(ia2,2)
60743  k(n+2,2)=k(ia5,2)
60744  k(n+3,2)=k(ia2,2)
60745  k(n+4,2)=21
60746  k(n+5,2)=k(ia3,2)
60747  k(n+6,2)=k(ia4,2)
60748  k(n+1,3)=ia2
60749  k(n+1,4)=n+3
60750  k(n+1,5)=n+4
60751  k(n+2,3)=ia5
60752  k(n+3,3)=n+1
60753  k(n+4,3)=n+1
60754  k(n+4,4)=n+5
60755  k(n+4,5)=n+6
60756  k(n+5,3)=n+4
60757  k(n+6,3)=n+4
60758 
60759 C...Set up momenta for new partons.
60760  DO 140 j=1,5
60761  p(n+1,j)=p(ia2,j)+p(ia3,j)+p(ia4,j)
60762  p(n+2,j)=p(ia5,j)
60763  p(n+3,j)=p(ia2,j)
60764  p(n+4,j)=p(ia3,j)+p(ia4,j)
60765  p(n+5,j)=p(ia3,j)
60766  p(n+6,j)=p(ia4,j)
60767  140 CONTINUE
60768  p(n+1,5)=sqrt(max(0d0,p(n+1,4)**2-p(n+1,1)**2-p(n+1,2)**2-
60769  & p(n+1,3)**2))
60770  p(n+4,5)=sqrt(max(0d0,p(n+4,4)**2-p(n+4,1)**2-p(n+4,2)**2-
60771  & p(n+4,3)**2))
60772  qmax=p(n+4,5)
60773 
60774  ENDIF
60775  n=n+6
60776 
60777  RETURN
60778  END
60779 
60780 C*********************************************************************
60781 
60782 C...PYJOIN
60783 C...Connects a sequence of partons with colour flow indices,
60784 C...as required for subsequent shower evolution (or other operations).
60785 
60786  SUBROUTINE pyjoin(NJOIN,IJOIN)
60787 
60788 C...Double precision and integer declarations.
60789  IMPLICIT DOUBLE PRECISION(a-h, o-z)
60790  IMPLICIT INTEGER(i-n)
60791  INTEGER pyk,pychge,pycomp
60792 C...Commonblocks.
60793  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
60794  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
60795  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
60796  SAVE /pyjets/,/pydat1/,/pydat2/
60797 C...Local array.
60798  dimension ijoin(*)
60799 
60800 C...Check that partons are of right types to be connected.
60801  IF(njoin.LT.2) goto 120
60802  kqsum=0
60803  DO 100 ijn=1,njoin
60804  i=ijoin(ijn)
60805  IF(i.LE.0.OR.i.GT.n) goto 120
60806  IF(k(i,1).LT.1.OR.k(i,1).GT.3) goto 120
60807  kc=pycomp(k(i,2))
60808  IF(kc.EQ.0) goto 120
60809  kq=kchg(kc,2)*isign(1,k(i,2))
60810  IF(kq.EQ.0) goto 120
60811  IF(ijn.NE.1.AND.ijn.NE.njoin.AND.kq.NE.2) goto 120
60812  IF(kq.NE.2) kqsum=kqsum+kq
60813  IF(ijn.EQ.1) kqs=kq
60814  100 CONTINUE
60815  IF(kqsum.NE.0) goto 120
60816 
60817 C...Connect the partons sequentially (closing for gluon loop).
60818  kcs=(9-kqs)/2
60819  IF(kqs.EQ.2) kcs=int(4.5d0+pyr(0))
60820  DO 110 ijn=1,njoin
60821  i=ijoin(ijn)
60822  k(i,1)=3
60823  IF(ijn.NE.1) ip=ijoin(ijn-1)
60824  IF(ijn.EQ.1) ip=ijoin(njoin)
60825  IF(ijn.NE.njoin) in=ijoin(ijn+1)
60826  IF(ijn.EQ.njoin) in=ijoin(1)
60827  k(i,kcs)=mstu(5)*in
60828  k(i,9-kcs)=mstu(5)*ip
60829  IF(ijn.EQ.1.AND.kqs.NE.2) k(i,9-kcs)=0
60830  IF(ijn.EQ.njoin.AND.kqs.NE.2) k(i,kcs)=0
60831  110 CONTINUE
60832 
60833 C...Error exit: no action taken.
60834  RETURN
60835  120 CALL pyerrm(12,
60836  &'(PYJOIN:) given entries can not be joined by one string')
60837 
60838  RETURN
60839  END
60840 
60841 C*********************************************************************
60842 
60843 C...PYGIVE
60844 C...Sets values of commonblock variables.
60845 
60846  SUBROUTINE pygive(CHIN)
60847 
60848 C...Double precision and integer declarations.
60849  IMPLICIT DOUBLE PRECISION(a-h, o-z)
60850  IMPLICIT INTEGER(i-n)
60851  INTEGER pyk,pychge,pycomp
60852 C...Commonblocks.
60853  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
60854  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
60855  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
60856  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
60857  common/pydat4/chaf(500,2)
60858  CHARACTER chaf*16
60859  common/pydatr/mrpy(6),rrpy(100)
60860  common/pysubs/msel,mselpd,msub(500),kfin(2,-40:40),ckin(200)
60861  common/pypars/mstp(200),parp(200),msti(200),pari(200)
60862  common/pyint1/mint(400),vint(400)
60863  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
60864  common/pyint3/xsfx(2,-40:40),isig(1000,3),sigh(1000)
60865  common/pyint4/mwid(500),wids(500,5)
60866  common/pyint5/ngenpd,ngen(0:500,3),xsec(0:500,3)
60867  common/pyint6/proc(0:500)
60868  CHARACTER proc*28
60869  common/pyint7/sigt(0:6,0:6,0:5)
60870  common/pyint8/xpvmd(-6:6),xpanl(-6:6),xpanh(-6:6),xpbeh(-6:6),
60871  &xpdir(-6:6)
60872  common/pymssm/imss(0:99),rmss(0:99)
60873  common/pymsrv/rvlam(3,3,3), rvlamp(3,3,3), rvlamb(3,3,3)
60874  common/pytcsm/itcm(0:99),rtcm(0:99)
60875  common/pypued/iued(0:99),rued(0:99)
60876  SAVE /pyjets/,/pydat1/,/pydat2/,/pydat3/,/pydat4/,/pydatr/,
60877  &/pysubs/,/pypars/,/pyint1/,/pyint2/,/pyint3/,/pyint4/,/pyint5/,
60878  &/pyint6/,/pyint7/,/pyint8/,/pymssm/,/pymsrv/,/pytcsm/,/pypued/
60879 C...Local arrays and character variables.
60880  CHARACTER chin*(*),chfix*104,chbit*104,chold*8,chnew*8,chold2*28,
60881  &chnew2*28,chnam*6,chvar(56)*6,chalp(2)*26,chind*8,chini*10,
60882  &chinr*16,chdig*10
60883  dimension msvar(56,8)
60884 
60885 C...For each variable to be translated give: name,
60886 C...integer/real/character, no. of indices, lower&upper index bounds.
60887  DATA chvar/'N','K','P','V','MSTU','PARU','MSTJ','PARJ','KCHG',
60888  &'PMAS','PARF','VCKM','MDCY','MDME','BRAT','KFDP','CHAF','MRPY',
60889  &'RRPY','MSEL','MSUB','KFIN','CKIN','MSTP','PARP','MSTI','PARI',
60890  &'MINT','VINT','ISET','KFPR','COEF','ICOL','XSFX','ISIG','SIGH',
60891  &'MWID','WIDS','NGEN','XSEC','PROC','SIGT','XPVMD','XPANL',
60892  &'XPANH','XPBEH','XPDIR','IMSS','RMSS','RVLAM','RVLAMP','RVLAMB',
60893  &'ITCM','RTCM','IUED','RUED'/
60894  DATA ((msvar(i,j),j=1,8),i=1,56)/ 1,7*0, 1,2,1,4000,1,5,2*0,
60895  &2,2,1,4000,1,5,2*0, 2,2,1,4000,1,5,2*0, 1,1,1,200,4*0,
60896  &2,1,1,200,4*0, 1,1,1,200,4*0, 2,1,1,200,4*0,
60897  &1,2,1,500,1,4,2*0, 2,2,1,500,1,4,2*0, 2,1,1,2000,4*0,
60898  &2,2,1,4,1,4,2*0, 1,2,1,500,1,3,2*0, 1,2,1,8000,1,2,2*0,
60899  &2,1,1,8000,4*0, 1,2,1,8000,1,5,2*0, 3,2,1,500,1,2,2*0,
60900  &1,1,1,6,4*0, 2,1,1,100,4*0,
60901  &1,7*0, 1,1,1,500,4*0, 1,2,1,2,-40,40,2*0, 2,1,1,200,4*0,
60902  &1,1,1,200,4*0, 2,1,1,200,4*0, 1,1,1,200,4*0, 2,1,1,200,4*0,
60903  &1,1,1,400,4*0, 2,1,1,400,4*0, 1,1,1,500,4*0,
60904  &1,2,1,500,1,2,2*0, 2,2,1,500,1,20,2*0, 1,3,1,40,1,4,1,2,
60905  &2,2,1,2,-40,40,2*0, 1,2,1,1000,1,3,2*0, 2,1,1,1000,4*0,
60906  &1,1,1,500,4*0, 2,2,1,500,1,5,2*0, 1,2,0,500,1,3,2*0,
60907  &2,2,0,500,1,3,2*0, 4,1,0,500,4*0, 2,3,0,6,0,6,0,5,
60908  &2,1,-6,6,4*0, 2,1,-6,6,4*0, 2,1,-6,6,4*0,
60909  &2,1,-6,6,4*0, 2,1,-6,6,4*0, 1,1,0,99,4*0, 2,1,0,99,4*0,
60910  &2,3,1,3,1,3,1,3, 2,3,1,3,1,3,1,3, 2,3,1,3,1,3,1,3,
60911  &1,1,0,99,4*0, 2,1,0,99,4*0, 1,1,0,99,4*0, 2,1,0,99,4*0/
60912  DATA chalp/'abcdefghijklmnopqrstuvwxyz',
60913  &'ABCDEFGHIJKLMNOPQRSTUVWXYZ'/, chdig/'1234567890'/
60914 
60915 C...Length of character variable. Subdivide it into instructions.
60916  IF(mstu(12).NE.12345.AND.chin.NE.'mstu(12)=12345'.AND.
60917  &chin.NE.'MSTU(12)=12345') CALL pylist(0)
60918  chbit=chin//' '
60919  lbit=101
60920  100 lbit=lbit-1
60921  IF(chbit(lbit:lbit).EQ.' ') goto 100
60922  ltot=0
60923  DO 110 lcom=1,lbit
60924  IF(chbit(lcom:lcom).EQ.' ') goto 110
60925  ltot=ltot+1
60926  chfix(ltot:ltot)=chbit(lcom:lcom)
60927  110 CONTINUE
60928  llow=0
60929  120 lhig=llow+1
60930  130 lhig=lhig+1
60931  IF(lhig.LE.ltot.AND.chfix(lhig:lhig).NE.';') goto 130
60932  lbit=lhig-llow-1
60933  chbit(1:lbit)=chfix(llow+1:lhig-1)
60934 
60935 C...Send off decay-mode on/off commands to PYONOF.
60936  ionof=0
60937  DO 135 ldig=1,10
60938  IF(chbit(1:1).EQ.chdig(ldig:ldig)) ionof=1
60939  135 CONTINUE
60940  IF(ionof.EQ.1) THEN
60941  CALL pyonof(chin)
60942  RETURN
60943  ENDIF
60944 
60945 C...Peel off any text following exclamation mark.
60946  lhig2=lbit
60947  DO 140 llow2=lhig2,1,-1
60948  IF(chbit(llow2:llow2).EQ.'!') lbit=llow2-1
60949  140 CONTINUE
60950  IF(lbit.EQ.0) RETURN
60951 
60952 C...Identify commonblock variable.
60953  lnam=1
60954  150 lnam=lnam+1
60955  IF(chbit(lnam:lnam).NE.'('.AND.chbit(lnam:lnam).NE.'='.AND.
60956  &lnam.LE.6) goto 150
60957  chnam=chbit(1:lnam-1)//' '
60958  DO 170 lcom=1,lnam-1
60959  DO 160 lalp=1,26
60960  IF(chnam(lcom:lcom).EQ.chalp(1)(lalp:lalp)) chnam(lcom:lcom)=
60961  & chalp(2)(lalp:lalp)
60962  160 CONTINUE
60963  170 CONTINUE
60964  ivar=0
60965  DO 180 iv=1,56
60966  IF(chnam.EQ.chvar(iv)) ivar=iv
60967  180 CONTINUE
60968  IF(ivar.EQ.0) THEN
60969  CALL pyerrm(18,'(PYGIVE:) do not recognize variable '//chnam)
60970  llow=lhig
60971  IF(llow.LT.ltot) goto 120
60972  RETURN
60973  ENDIF
60974 
60975 C...Identify any indices.
60976  i1=0
60977  i2=0
60978  i3=0
60979  nindx=0
60980  IF(chbit(lnam:lnam).EQ.'(') THEN
60981  lind=lnam
60982  190 lind=lind+1
60983  IF(chbit(lind:lind).NE.')'.AND.chbit(lind:lind).NE.',') goto 190
60984  chind=' '
60985  IF((chbit(lnam+1:lnam+1).EQ.'C'.OR.chbit(lnam+1:lnam+1).EQ.'c')
60986  & .AND.(ivar.EQ.9.OR.ivar.EQ.10.OR.ivar.EQ.13.OR.ivar.EQ.17.OR.
60987  & ivar.EQ.37)) THEN
60988  chind(lnam-lind+11:8)=chbit(lnam+2:lind-1)
60989  READ(chind,'(I8)') kf
60990  i1=pycomp(kf)
60991  ELSEIF(chbit(lnam+1:lnam+1).EQ.'C'.OR.chbit(lnam+1:lnam+1).EQ.
60992  & 'c') THEN
60993  CALL pyerrm(18,'(PYGIVE:) not allowed to use C index for '//
60994  & chnam)
60995  llow=lhig
60996  IF(llow.LT.ltot) goto 120
60997  RETURN
60998  ELSE
60999  chind(lnam-lind+10:8)=chbit(lnam+1:lind-1)
61000  READ(chind,'(I8)') i1
61001  ENDIF
61002  lnam=lind
61003  IF(chbit(lnam:lnam).EQ.')') lnam=lnam+1
61004  nindx=1
61005  ENDIF
61006  IF(chbit(lnam:lnam).EQ.',') THEN
61007  lind=lnam
61008  200 lind=lind+1
61009  IF(chbit(lind:lind).NE.')'.AND.chbit(lind:lind).NE.',') goto 200
61010  chind=' '
61011  chind(lnam-lind+10:8)=chbit(lnam+1:lind-1)
61012  READ(chind,'(I8)') i2
61013  lnam=lind
61014  IF(chbit(lnam:lnam).EQ.')') lnam=lnam+1
61015  nindx=2
61016  ENDIF
61017  IF(chbit(lnam:lnam).EQ.',') THEN
61018  lind=lnam
61019  210 lind=lind+1
61020  IF(chbit(lind:lind).NE.')'.AND.chbit(lind:lind).NE.',') goto 210
61021  chind=' '
61022  chind(lnam-lind+10:8)=chbit(lnam+1:lind-1)
61023  READ(chind,'(I8)') i3
61024  lnam=lind+1
61025  nindx=3
61026  ENDIF
61027 
61028 C...Check that indices allowed.
61029  ierr=0
61030  IF(nindx.NE.msvar(ivar,2)) ierr=1
61031  IF(nindx.GE.1.AND.(i1.LT.msvar(ivar,3).OR.i1.GT.msvar(ivar,4)))
61032  &ierr=2
61033  IF(nindx.GE.2.AND.(i2.LT.msvar(ivar,5).OR.i2.GT.msvar(ivar,6)))
61034  &ierr=3
61035  IF(nindx.EQ.3.AND.(i3.LT.msvar(ivar,7).OR.i3.GT.msvar(ivar,8)))
61036  &ierr=4
61037  IF(chbit(lnam:lnam).NE.'=') ierr=5
61038  IF(ierr.GE.1) THEN
61039  CALL pyerrm(18,'(PYGIVE:) unallowed indices for '//
61040  & chbit(1:lnam-1))
61041  llow=lhig
61042  IF(llow.LT.ltot) goto 120
61043  RETURN
61044  ENDIF
61045 
61046 C...Save old value of variable.
61047  IF(ivar.EQ.1) THEN
61048  iold=n
61049  ELSEIF(ivar.EQ.2) THEN
61050  iold=k(i1,i2)
61051  ELSEIF(ivar.EQ.3) THEN
61052  rold=p(i1,i2)
61053  ELSEIF(ivar.EQ.4) THEN
61054  rold=v(i1,i2)
61055  ELSEIF(ivar.EQ.5) THEN
61056  iold=mstu(i1)
61057  ELSEIF(ivar.EQ.6) THEN
61058  rold=paru(i1)
61059  ELSEIF(ivar.EQ.7) THEN
61060  iold=mstj(i1)
61061  ELSEIF(ivar.EQ.8) THEN
61062  rold=parj(i1)
61063  ELSEIF(ivar.EQ.9) THEN
61064  iold=kchg(i1,i2)
61065  ELSEIF(ivar.EQ.10) THEN
61066  rold=pmas(i1,i2)
61067  ELSEIF(ivar.EQ.11) THEN
61068  rold=parf(i1)
61069  ELSEIF(ivar.EQ.12) THEN
61070  rold=vckm(i1,i2)
61071  ELSEIF(ivar.EQ.13) THEN
61072  iold=mdcy(i1,i2)
61073  ELSEIF(ivar.EQ.14) THEN
61074  iold=mdme(i1,i2)
61075  ELSEIF(ivar.EQ.15) THEN
61076  rold=brat(i1)
61077  ELSEIF(ivar.EQ.16) THEN
61078  iold=kfdp(i1,i2)
61079  ELSEIF(ivar.EQ.17) THEN
61080  chold=chaf(i1,i2)(1:8)
61081  ELSEIF(ivar.EQ.18) THEN
61082  iold=mrpy(i1)
61083  ELSEIF(ivar.EQ.19) THEN
61084  rold=rrpy(i1)
61085  ELSEIF(ivar.EQ.20) THEN
61086  iold=msel
61087  ELSEIF(ivar.EQ.21) THEN
61088  iold=msub(i1)
61089  ELSEIF(ivar.EQ.22) THEN
61090  iold=kfin(i1,i2)
61091  ELSEIF(ivar.EQ.23) THEN
61092  rold=ckin(i1)
61093  ELSEIF(ivar.EQ.24) THEN
61094  iold=mstp(i1)
61095  ELSEIF(ivar.EQ.25) THEN
61096  rold=parp(i1)
61097  ELSEIF(ivar.EQ.26) THEN
61098  iold=msti(i1)
61099  ELSEIF(ivar.EQ.27) THEN
61100  rold=pari(i1)
61101  ELSEIF(ivar.EQ.28) THEN
61102  iold=mint(i1)
61103  ELSEIF(ivar.EQ.29) THEN
61104  rold=vint(i1)
61105  ELSEIF(ivar.EQ.30) THEN
61106  iold=iset(i1)
61107  ELSEIF(ivar.EQ.31) THEN
61108  iold=kfpr(i1,i2)
61109  ELSEIF(ivar.EQ.32) THEN
61110  rold=coef(i1,i2)
61111  ELSEIF(ivar.EQ.33) THEN
61112  iold=icol(i1,i2,i3)
61113  ELSEIF(ivar.EQ.34) THEN
61114  rold=xsfx(i1,i2)
61115  ELSEIF(ivar.EQ.35) THEN
61116  iold=isig(i1,i2)
61117  ELSEIF(ivar.EQ.36) THEN
61118  rold=sigh(i1)
61119  ELSEIF(ivar.EQ.37) THEN
61120  iold=mwid(i1)
61121  ELSEIF(ivar.EQ.38) THEN
61122  rold=wids(i1,i2)
61123  ELSEIF(ivar.EQ.39) THEN
61124  iold=ngen(i1,i2)
61125  ELSEIF(ivar.EQ.40) THEN
61126  rold=xsec(i1,i2)
61127  ELSEIF(ivar.EQ.41) THEN
61128  chold2=proc(i1)
61129  ELSEIF(ivar.EQ.42) THEN
61130  rold=sigt(i1,i2,i3)
61131  ELSEIF(ivar.EQ.43) THEN
61132  rold=xpvmd(i1)
61133  ELSEIF(ivar.EQ.44) THEN
61134  rold=xpanl(i1)
61135  ELSEIF(ivar.EQ.45) THEN
61136  rold=xpanh(i1)
61137  ELSEIF(ivar.EQ.46) THEN
61138  rold=xpbeh(i1)
61139  ELSEIF(ivar.EQ.47) THEN
61140  rold=xpdir(i1)
61141  ELSEIF(ivar.EQ.48) THEN
61142  iold=imss(i1)
61143  ELSEIF(ivar.EQ.49) THEN
61144  rold=rmss(i1)
61145  ELSEIF(ivar.EQ.50) THEN
61146  rold=rvlam(i1,i2,i3)
61147  ELSEIF(ivar.EQ.51) THEN
61148  rold=rvlamp(i1,i2,i3)
61149  ELSEIF(ivar.EQ.52) THEN
61150  rold=rvlamb(i1,i2,i3)
61151  ELSEIF(ivar.EQ.53) THEN
61152  iold=itcm(i1)
61153  ELSEIF(ivar.EQ.54) THEN
61154  rold=rtcm(i1)
61155  ELSEIF(ivar.EQ.55) THEN
61156  iold=iued(i1)
61157  ELSEIF(ivar.EQ.56) THEN
61158  rold=rued(i1)
61159  ENDIF
61160 
61161 C...Print current value of variable. Loop back.
61162  IF(lnam.GE.lbit) THEN
61163  chbit(lnam:14)=' '
61164  chbit(15:60)=' has the value '
61165  IF(msvar(ivar,1).EQ.1) THEN
61166  WRITE(chbit(51:60),'(I10)') iold
61167  ELSEIF(msvar(ivar,1).EQ.2) THEN
61168  WRITE(chbit(47:60),'(F14.5)') rold
61169  ELSEIF(msvar(ivar,1).EQ.3) THEN
61170  chbit(53:60)=chold
61171  ELSE
61172  chbit(33:60)=chold
61173  ENDIF
61174  IF(mstu(13).GE.1) WRITE(mstu(11),5000) chbit(1:60)
61175  llow=lhig
61176  IF(llow.LT.ltot) goto 120
61177  RETURN
61178  ENDIF
61179 
61180 C...Read in new variable value.
61181  IF(msvar(ivar,1).EQ.1) THEN
61182  chini=' '
61183  chini(lnam-lbit+11:10)=chbit(lnam+1:lbit)
61184  READ(chini,'(I10)') inew
61185  ELSEIF(msvar(ivar,1).EQ.2) THEN
61186  chinr=' '
61187  chinr(lnam-lbit+17:16)=chbit(lnam+1:lbit)
61188  READ(chinr,*) rnew
61189  ELSEIF(msvar(ivar,1).EQ.3) THEN
61190  chnew=chbit(lnam+1:lbit)//' '
61191  ELSE
61192  chnew2=chbit(lnam+1:lbit)//' '
61193  ENDIF
61194 
61195 C...Store new variable value.
61196  IF(ivar.EQ.1) THEN
61197  n=inew
61198  ELSEIF(ivar.EQ.2) THEN
61199  k(i1,i2)=inew
61200  ELSEIF(ivar.EQ.3) THEN
61201  p(i1,i2)=rnew
61202  ELSEIF(ivar.EQ.4) THEN
61203  v(i1,i2)=rnew
61204  ELSEIF(ivar.EQ.5) THEN
61205  mstu(i1)=inew
61206  ELSEIF(ivar.EQ.6) THEN
61207  paru(i1)=rnew
61208  ELSEIF(ivar.EQ.7) THEN
61209  mstj(i1)=inew
61210  ELSEIF(ivar.EQ.8) THEN
61211  parj(i1)=rnew
61212  ELSEIF(ivar.EQ.9) THEN
61213  kchg(i1,i2)=inew
61214  ELSEIF(ivar.EQ.10) THEN
61215  pmas(i1,i2)=rnew
61216  ELSEIF(ivar.EQ.11) THEN
61217  parf(i1)=rnew
61218  ELSEIF(ivar.EQ.12) THEN
61219  vckm(i1,i2)=rnew
61220  ELSEIF(ivar.EQ.13) THEN
61221  mdcy(i1,i2)=inew
61222  ELSEIF(ivar.EQ.14) THEN
61223  mdme(i1,i2)=inew
61224  ELSEIF(ivar.EQ.15) THEN
61225  brat(i1)=rnew
61226  ELSEIF(ivar.EQ.16) THEN
61227  kfdp(i1,i2)=inew
61228  ELSEIF(ivar.EQ.17) THEN
61229  chaf(i1,i2)=chnew
61230  ELSEIF(ivar.EQ.18) THEN
61231  mrpy(i1)=inew
61232  ELSEIF(ivar.EQ.19) THEN
61233  rrpy(i1)=rnew
61234  ELSEIF(ivar.EQ.20) THEN
61235  msel=inew
61236  ELSEIF(ivar.EQ.21) THEN
61237  msub(i1)=inew
61238  ELSEIF(ivar.EQ.22) THEN
61239  kfin(i1,i2)=inew
61240  ELSEIF(ivar.EQ.23) THEN
61241  ckin(i1)=rnew
61242  ELSEIF(ivar.EQ.24) THEN
61243  mstp(i1)=inew
61244  ELSEIF(ivar.EQ.25) THEN
61245  parp(i1)=rnew
61246  ELSEIF(ivar.EQ.26) THEN
61247  msti(i1)=inew
61248  ELSEIF(ivar.EQ.27) THEN
61249  pari(i1)=rnew
61250  ELSEIF(ivar.EQ.28) THEN
61251  mint(i1)=inew
61252  ELSEIF(ivar.EQ.29) THEN
61253  vint(i1)=rnew
61254  ELSEIF(ivar.EQ.30) THEN
61255  iset(i1)=inew
61256  ELSEIF(ivar.EQ.31) THEN
61257  kfpr(i1,i2)=inew
61258  ELSEIF(ivar.EQ.32) THEN
61259  coef(i1,i2)=rnew
61260  ELSEIF(ivar.EQ.33) THEN
61261  icol(i1,i2,i3)=inew
61262  ELSEIF(ivar.EQ.34) THEN
61263  xsfx(i1,i2)=rnew
61264  ELSEIF(ivar.EQ.35) THEN
61265  isig(i1,i2)=inew
61266  ELSEIF(ivar.EQ.36) THEN
61267  sigh(i1)=rnew
61268  ELSEIF(ivar.EQ.37) THEN
61269  mwid(i1)=inew
61270  ELSEIF(ivar.EQ.38) THEN
61271  wids(i1,i2)=rnew
61272  ELSEIF(ivar.EQ.39) THEN
61273  ngen(i1,i2)=inew
61274  ELSEIF(ivar.EQ.40) THEN
61275  xsec(i1,i2)=rnew
61276  ELSEIF(ivar.EQ.41) THEN
61277  proc(i1)=chnew2
61278  ELSEIF(ivar.EQ.42) THEN
61279  sigt(i1,i2,i3)=rnew
61280  ELSEIF(ivar.EQ.43) THEN
61281  xpvmd(i1)=rnew
61282  ELSEIF(ivar.EQ.44) THEN
61283  xpanl(i1)=rnew
61284  ELSEIF(ivar.EQ.45) THEN
61285  xpanh(i1)=rnew
61286  ELSEIF(ivar.EQ.46) THEN
61287  xpbeh(i1)=rnew
61288  ELSEIF(ivar.EQ.47) THEN
61289  xpdir(i1)=rnew
61290  ELSEIF(ivar.EQ.48) THEN
61291  imss(i1)=inew
61292  ELSEIF(ivar.EQ.49) THEN
61293  rmss(i1)=rnew
61294  ELSEIF(ivar.EQ.50) THEN
61295  rvlam(i1,i2,i3)=rnew
61296  ELSEIF(ivar.EQ.51) THEN
61297  rvlamp(i1,i2,i3)=rnew
61298  ELSEIF(ivar.EQ.52) THEN
61299  rvlamb(i1,i2,i3)=rnew
61300  ELSEIF(ivar.EQ.53) THEN
61301  itcm(i1)=inew
61302  ELSEIF(ivar.EQ.54) THEN
61303  rtcm(i1)=rnew
61304  ELSEIF(ivar.EQ.55) THEN
61305  iued(i1)=inew
61306  ELSEIF(ivar.EQ.56) THEN
61307  rued(i1)=rnew
61308  ENDIF
61309 
61310 C...Write old and new value. Loop back.
61311  chbit(lnam:14)=' '
61312  chbit(15:60)=' changed from to '
61313  IF(msvar(ivar,1).EQ.1) THEN
61314  WRITE(chbit(33:42),'(I10)') iold
61315  WRITE(chbit(51:60),'(I10)') inew
61316  IF(mstu(13).GE.1) WRITE(mstu(11),5000) chbit(1:60)
61317  ELSEIF(msvar(ivar,1).EQ.2) THEN
61318  WRITE(chbit(29:42),'(F14.5)') rold
61319  WRITE(chbit(47:60),'(F14.5)') rnew
61320  IF(mstu(13).GE.1) WRITE(mstu(11),5000) chbit(1:60)
61321  ELSEIF(msvar(ivar,1).EQ.3) THEN
61322  chbit(35:42)=chold
61323  chbit(53:60)=chnew
61324  IF(mstu(13).GE.1) WRITE(mstu(11),5000) chbit(1:60)
61325  ELSE
61326  chbit(15:88)=' changed from '//chold2//' to '//chnew2
61327  IF(mstu(13).GE.1) WRITE(mstu(11),5100) chbit(1:88)
61328  ENDIF
61329  llow=lhig
61330  IF(llow.LT.ltot) goto 120
61331 
61332 C...Format statement for output on unit MSTU(11) (by default 6).
61333  5000 FORMAT(5x,a60)
61334  5100 FORMAT(5x,a88)
61335 
61336  RETURN
61337  END
61338 
61339 C*********************************************************************
61340 
61341 C...PYONOF
61342 C...Switches on and off decay channel by search for match.
61343 
61344  SUBROUTINE pyonof(CHIN)
61345 
61346 C...Double precision and integer declarations.
61347  IMPLICIT DOUBLE PRECISION(a-h, o-z)
61348  IMPLICIT INTEGER(i-n)
61349  INTEGER pyk,pychge,pycomp
61350 C...Commonblocks.
61351  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
61352  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
61353  SAVE /pydat1/,/pydat3/
61354 C...Local arrays and character variables.
61355  INTEGER kfcmp(10),kftmp(10)
61356  CHARACTER chin*(*),chtmp*104,chfix*104,chmode*10,chcode*8,
61357  &chalp(2)*26
61358  DATA chalp/'abcdefghijklmnopqrstuvwxyz',
61359  &'ABCDEFGHIJKLMNOPQRSTUVWXYZ'/
61360 
61361 C...Determine length of character variable.
61362  chtmp=chin//' '
61363  lbeg=0
61364  100 lbeg=lbeg+1
61365  IF(chtmp(lbeg:lbeg).EQ.' ') goto 100
61366  lend=lbeg-1
61367  105 lend=lend+1
61368  IF(lend.LE.100.AND.chtmp(lend:lend).NE.'!') goto 105
61369  110 lend=lend-1
61370  IF(chtmp(lend:lend).EQ.' ') goto 110
61371  len=1+lend-lbeg
61372  chfix(1:len)=chtmp(lbeg:lend)
61373 
61374 C...Find colon separator and particle code.
61375  lcolon=0
61376  120 lcolon=lcolon+1
61377  IF(chfix(lcolon:lcolon).NE.':') goto 120
61378  chcode=' '
61379  chcode(10-lcolon:8)=chfix(1:lcolon-1)
61380  READ(chcode,'(I8)',err=300) kf
61381  kc=pycomp(kf)
61382 
61383 C...Done if unknown code or no decay channels.
61384  IF(kc.EQ.0) THEN
61385  CALL pyerrm(18,'(PYONOF:) unrecognized particle '//chcode)
61386  RETURN
61387  ENDIF
61388  idcbeg=mdcy(kc,2)
61389  idclen=mdcy(kc,3)
61390  IF(idcbeg.EQ.0.OR.idclen.EQ.0) THEN
61391  CALL pyerrm(18,'(PYONOF:) no decay channels for '//chcode)
61392  RETURN
61393  ENDIF
61394 
61395 C...Find command name up to blank or equal sign.
61396  lsep=lcolon
61397  130 lsep=lsep+1
61398  IF(lsep.LE.len.AND.chfix(lsep:lsep).NE.' '.AND.
61399  &chfix(lsep:lsep).NE.'=') goto 130
61400  chmode=' '
61401  lmode=lsep-lcolon-1
61402  chmode(1:lmode)=chfix(lcolon+1:lsep-1)
61403 
61404 C...Convert to uppercase.
61405  DO 150 lcom=1,lmode
61406  DO 140 lalp=1,26
61407  IF(chmode(lcom:lcom).EQ.chalp(1)(lalp:lalp))
61408  & chmode(lcom:lcom)=chalp(2)(lalp:lalp)
61409  140 CONTINUE
61410  150 CONTINUE
61411 
61412 C...Identify command. Failed if not identified.
61413  mode=0
61414  IF(chmode.EQ.'ALLOFF') mode=1
61415  IF(chmode.EQ.'ALLON') mode=2
61416  IF(chmode.EQ.'OFFIFANY') mode=3
61417  IF(chmode.EQ.'ONIFANY') mode=4
61418  IF(chmode.EQ.'OFFIFALL') mode=5
61419  IF(chmode.EQ.'ONIFALL') mode=6
61420  IF(chmode.EQ.'OFFIFMATCH') mode=7
61421  IF(chmode.EQ.'ONIFMATCH') mode=8
61422  IF(mode.EQ.0) THEN
61423  CALL pyerrm(18,'(PYONOF:) unknown command '//chmode)
61424  RETURN
61425  ENDIF
61426 
61427 C...Simple cases when all on or all off.
61428  IF(mode.EQ.1.OR.mode.EQ.2) THEN
61429  WRITE(mstu(11),1000) kf,chmode
61430  DO 160 idc=idcbeg,idcbeg+idclen-1
61431  IF(mdme(idc,1).LT.0) goto 160
61432  mdme(idc,1)=mode-1
61433  160 CONTINUE
61434  RETURN
61435  ENDIF
61436 
61437 C...Identify matching list.
61438  ncmp=0
61439  lbeg=lsep
61440  170 lbeg=lbeg+1
61441  IF(lbeg.GT.len) goto 190
61442  IF(lbeg.LT.len.AND.(chfix(lbeg:lbeg).EQ.' '.OR.
61443  &chfix(lbeg:lbeg).EQ.'='.OR.chfix(lbeg:lbeg).EQ.',')) goto 170
61444  lend=lbeg-1
61445  180 lend=lend+1
61446  IF(lend.LT.len.AND.chfix(lend:lend).NE.' '.AND.
61447  &chfix(lend:lend).NE.'='.AND.chfix(lend:lend).NE.',') goto 180
61448  IF(lend.LT.len) lend=lend-1
61449  chcode=' '
61450  chcode(8-lend+lbeg:8)=chfix(lbeg:lend)
61451  READ(chcode,'(I8)',err=300) kfread
61452  ncmp=ncmp+1
61453  kfcmp(ncmp)=iabs(kfread)
61454  lbeg=lend
61455  IF(ncmp.LT.10) goto 170
61456  190 CONTINUE
61457  WRITE(mstu(11),1100) kf,chmode,(kfcmp(icmp),icmp=1,ncmp)
61458 
61459 C...Only one matching required.
61460  IF(mode.EQ.3.OR.mode.EQ.4) THEN
61461  DO 220 idc=idcbeg,idcbeg+idclen-1
61462  IF(mdme(idc,1).LT.0) goto 220
61463  DO 210 ikf=1,5
61464  kfnow=iabs(kfdp(idc,ikf))
61465  IF(kfnow.EQ.0) goto 210
61466  DO 200 icmp=1,ncmp
61467  IF(kfcmp(icmp).EQ.kfnow) THEN
61468  mdme(idc,1)=mode-3
61469  goto 220
61470  ENDIF
61471  200 CONTINUE
61472  210 CONTINUE
61473  220 CONTINUE
61474  RETURN
61475  ENDIF
61476 
61477 C...Multiple matchings required.
61478  DO 260 idc=idcbeg,idcbeg+idclen-1
61479  IF(mdme(idc,1).LT.0) goto 260
61480  ntmp=ncmp
61481  DO 230 itmp=1,ntmp
61482  kftmp(itmp)=kfcmp(itmp)
61483  230 CONTINUE
61484  nfin=0
61485  DO 250 ikf=1,5
61486  kfnow=iabs(kfdp(idc,ikf))
61487  IF(kfnow.EQ.0) goto 250
61488  nfin=nfin+1
61489  DO 240 itmp=1,ntmp
61490  IF(kftmp(itmp).EQ.kfnow) THEN
61491  kftmp(itmp)=kftmp(ntmp)
61492  ntmp=ntmp-1
61493  goto 250
61494  ENDIF
61495  240 CONTINUE
61496  250 CONTINUE
61497  IF(ntmp.EQ.0.AND.mode.LE.6) mdme(idc,1)=mode-5
61498  IF(ntmp.EQ.0.AND.nfin.EQ.ncmp.AND.mode.GE.7)
61499  & mdme(idc,1)=mode-7
61500  260 CONTINUE
61501  RETURN
61502 
61503 C...Error exit for impossible read of particle code.
61504  300 CALL pyerrm(18,'(PYONOF:) could not interpret particle code '
61505  &//chcode)
61506 
61507 C...Formats for output.
61508  1000 FORMAT(' Decays for',i8,' set ',a10)
61509  1100 FORMAT(' Decays for',i8,' set ',a10,' if match',10i8)
61510 
61511  RETURN
61512  END
61513 C*********************************************************************
61514 
61515 C...PYTUNE
61516 C...Presets for a few specific underlying-event and min-bias tunes
61517 C...Note some tunes require external pdfs to be linked (e.g. 105:QW),
61518 C...others require particular versions of pythia (e.g. the SCI and GAL
61519 C...models). See below for details.
61520  SUBROUTINE pytune(ITUNE)
61521 C
61522 C ITUNE NAME (detailed descriptions below)
61523 C 0 Default : No settings changed => defaults.
61524 C
61525 C ====== Old UE, Q2-ordered showers ====================================
61526 C 100 A : Rick Field's CDF Tune A (Oct 2002)
61527 C 101 AW : Rick Field's CDF Tune AW (Apr 2006)
61528 C 102 BW : Rick Field's CDF Tune BW (Apr 2006)
61529 C 103 DW : Rick Field's CDF Tune DW (Apr 2006)
61530 C 104 DWT : As DW but with slower UE ECM-scaling (Apr 2006)
61531 C 105 QW : Rick Field's CDF Tune QW using CTEQ6.1M (?)
61532 C 106 ATLAS-DC2: Arthur Moraes' (old) ATLAS tune ("Rome") (?)
61533 C 107 ACR : Tune A modified with new CR model (Mar 2007)
61534 C 108 D6 : Rick Field's CDF Tune D6 using CTEQ6L1 (?)
61535 C 109 D6T : Rick Field's CDF Tune D6T using CTEQ6L1 (?)
61536 C ---- Professor Tunes : 110+ (= 100+ with Professor's tune to LEP) ----
61537 C 110 A-Pro : Tune A, with LEP tune from Professor (Oct 2008)
61538 C 111 AW-Pro : Tune AW, -"- (Oct 2008)
61539 C 112 BW-Pro : Tune BW, -"- (Oct 2008)
61540 C 113 DW-Pro : Tune DW, -"- (Oct 2008)
61541 C 114 DWT-Pro : Tune DWT, -"- (Oct 2008)
61542 C 115 QW-Pro : Tune QW, -"- (Oct 2008)
61543 C 116 ATLAS-DC2-Pro: ATLAS-DC2 / Rome, -"- (Oct 2008)
61544 C 117 ACR-Pro : Tune ACR, -"- (Oct 2008)
61545 C 118 D6-Pro : Tune D6, -"- (Oct 2008)
61546 C 119 D6T-Pro : Tune D6T, -"- (Oct 2008)
61547 C ---- Professor's Q2-ordered Perugia Tune : 129 -----------------------
61548 C 129 Pro-Q2O : Professor Q2-ordered tune (Feb 2009)
61549 C
61550 C ====== Intermediate and Hybrid Models ================================
61551 C 200 IM 1 : Intermediate model: new UE, Q2-ord. showers, new CR
61552 C 201 APT : Tune A w. pT-ordered FSR (Mar 2007)
61553 C 211 APT-Pro : Tune APT, with LEP tune from Professor (Oct 2008)
61554 C 221 Perugia APT : "Perugia" update of APT-Pro (Feb 2009)
61555 C 226 Perugia APT6 : "Perugia" update of APT-Pro w. CTEQ6L1 (Feb 2009)
61556 C
61557 C ====== New UE, interleaved pT-ordered showers, annealing CR ==========
61558 C 300 S0 : Sandhoff-Skands Tune using the S0 CR model (Apr 2006)
61559 C 301 S1 : Sandhoff-Skands Tune using the S1 CR model (Apr 2006)
61560 C 302 S2 : Sandhoff-Skands Tune using the S2 CR model (Apr 2006)
61561 C 303 S0A : S0 with "Tune A" UE energy scaling (Apr 2006)
61562 C 304 NOCR : New UE "best try" without col. rec. (Apr 2006)
61563 C 305 Old : New UE, original (primitive) col. rec. (Aug 2004)
61564 C 306 ATLAS-CSC: Arthur Moraes' (new) ATLAS tune w. CTEQ6L1 (?)
61565 C ---- Professor Tunes : 310+ (= 300+ with Professor's tune to LEP)
61566 C 310 S0-Pro : S0 with updated LEP pars from Professor (Oct 2008)
61567 C 311 S1-Pro : S1 -"- (Oct 2008)
61568 C 312 S2-Pro : S2 -"- (Oct 2008)
61569 C 313 S0A-Pro : S0A -"- (Oct 2008)
61570 C 314 NOCR-Pro : NOCR -"- (Oct 2008)
61571 C 315 Old-Pro : Old -"- (Oct 2008)
61572 C 316 ATLAS MC08 : pT-ordered showers, CTEQ6L1 (2008)
61573 C ---- Peter's Perugia Tunes : 320+ ------------------------------------
61574 C 320 Perugia 0 : "Perugia" update of S0-Pro (Feb 2009)
61575 C 321 Perugia HARD : More ISR, More FSR, Less MPI, Less BR, Less HAD
61576 C 322 Perugia SOFT : Less ISR, Less FSR, More MPI, More BR, More HAD
61577 C 323 Perugia 3 : Alternative to Perugia 0, with different ISR/MPI
61578 C balance & different scaling to LHC & RHIC (Feb 2009)
61579 C 324 Perugia NOCR : "Perugia" update of NOCR-Pro (Feb 2009)
61580 C 325 Perugia * : "Perugia" Tune w. (external) MRSTLO* PDFs (Feb 2009)
61581 C 326 Perugia 6 : "Perugia" Tune w. (external) CTEQ6L1 PDFs (Feb 2009)
61582 C 327 Perugia 10: Alternative to Perugia 0, with more FSR (May 2010)
61583 C off ISR, more BR breakup, more strangeness
61584 C 328 Perugia K : Alternative to Perugia 2010, with a (May 2010)
61585 C K-factor applied to MPI cross sections
61586 C ---- Professor's pT-ordered Perugia Tune : 329 -----------------------
61587 C 329 Pro-pTO : Professor pT-ordered tune w. S0 CR model (Feb 2009)
61588 C ---- Tunes introduced in 6.4.23:
61589 C 330 ATLAS MC09 : pT-ordered showers, LO* PDFs (2009)
61590 C 331 ATLAS MC09c : pT-ordered showers, LO* PDFs, better CR (2009)
61591 C 334 Perugia 10 NOCR : Perugia 2010 with no CR, less MPI (Oct 2010)
61592 C 335 Pro-pT* : Professor Tune with LO* (Mar 2009)
61593 C 336 Pro-pT6 : Professor Tune with CTEQ6LL (Mar 2009)
61594 C 339 Pro-pT** : Professor Tune with LO** (Mar 2009)
61595 C 340 AMBT1 : First ATLAS tune including 7 TeV data (May 2010)
61596 C 341 Z1 : First CMS tune including 7 TeV data (Aug 2010)
61597 C 342 Z1-LEP : CMS tune Z1, with improved LEP parameters (Oct 2010)
61598 C 343 Z2 : Retune of Z1 by Field w CTEQ6L1 PDFs (2010)
61599 C 344 Z2-LEP : Retune of Z1 by Skands w CTEQ6L1 PDFs (Feb 2011)
61600 C 350 Perugia 2011 : Retune of Perugia 2010 incl 7-TeV data (Mar 2011)
61601 C 351 P2011 radHi : Variation with alphaS(pT/2)
61602 C 352 P2011 radLo : Variation with alphaS(2pT)
61603 C 353 P2011 mpiHi : Variation with more semi-hard MPI
61604 C 354 P2011 noCR : Variation without color reconnections
61605 C 355 P2011 LO** : Perugia 2011 using MSTW LO** PDFs (Mar 2011)
61606 C 356 P2011 C6 : Perugia 2011 using CTEQ6L1 PDFs (Mar 2011)
61607 C 357 P2011 T16 : Variation with PARP(90)=0.32 away from 7 TeV
61608 C 358 P2011 T32 : Variation with PARP(90)=0.16 awat from 7 TeV
61609 C 359 P2011 TeV : Perugia 2011 optimized for Tevatron (Mar 2011)
61610 C 360 S Global : Schulz-Skands Global fit (Mar 2011)
61611 C 361 S 7000 : Schulz-Skands at 7000 GeV (Mar 2011)
61612 C 362 S 1960 : Schulz-Skands at 1960 GeV (Mar 2011)
61613 C 363 S 1800 : Schulz-Skands at 1800 GeV (Mar 2011)
61614 C 364 S 900 : Schulz-Skands at 900 GeV (Mar 2011)
61615 C 365 S 630 : Schulz-Skands at 630 GeV (Mar 2011)
61616 C
61617 C ======= The Uppsala models ===========================================
61618 C ( NB! must be run with special modified Pythia 6.215 version )
61619 C ( available from http://www.isv.uu.se/thep/MC/scigal/ )
61620 C 400 GAL 0 : Generalized area-law model. Org pars (Dec 1998)
61621 C 401 SCI 0 : Soft-Colour-Interaction model. Org pars (Dec 1998)
61622 C 402 GAL 1 : GAL 0. Tevatron MB retuned (Skands) (Oct 2006)
61623 C 403 SCI 1 : SCI 0. Tevatron MB retuned (Skands) (Oct 2006)
61624 C
61625 C More details;
61626 C
61627 C Quick Dictionary:
61628 C BE : Bose-Einstein
61629 C BR : Beam Remnants
61630 C CR : Colour Reconnections
61631 C HAD: Hadronization
61632 C ISR/FSR: Initial-State Radiation / Final-State Radiation
61633 C FSI: Final-State Interactions (=CR+BE)
61634 C MB : Minimum-bias
61635 C MI : Multiple Interactions
61636 C UE : Underlying Event
61637 C
61638 C=======================================================================
61639 C TUNES OF OLD FRAMEWORK (Q2-ORDERED ISR AND FSR, NON-INTERLEAVED UE)
61640 C=======================================================================
61641 C
61642 C A (100) and AW (101). CTEQ5L parton distributions
61643 C...*** NB : SHOULD BE RUN WITH PYTHIA 6.2 (e.g. 6.228) ***
61644 C...*** CAN ALSO BE RUN WITH PYTHIA 6.406+
61645 C...Key feature: extensively compared to CDF data (R.D. Field).
61646 C...* Large starting scale for ISR (PARP(67)=4)
61647 C...* AW has even more radiation due to smaller mu_R choice in alpha_s.
61648 C...* See: http://www.phys.ufl.edu/~rfield/cdf/
61649 C
61650 C BW (102). CTEQ5L parton distributions
61651 C...*** NB : SHOULD BE RUN WITH PYTHIA 6.2 (e.g. 6.228) ***
61652 C...*** CAN ALSO BE RUN WITH PYTHIA 6.406+
61653 C...Key feature: extensively compared to CDF data (R.D. Field).
61654 C...NB: Can also be run with Pythia 6.2 or 6.312+
61655 C...* Small starting scale for ISR (PARP(67)=1)
61656 C...* BW has more radiation due to smaller mu_R choice in alpha_s.
61657 C...* See: http://www.phys.ufl.edu/~rfield/cdf/
61658 C
61659 C DW (103) and DWT (104). CTEQ5L parton distributions
61660 C...*** NB : SHOULD BE RUN WITH PYTHIA 6.2 (e.g. 6.228) ***
61661 C...*** CAN ALSO BE RUN WITH PYTHIA 6.406+
61662 C...Key feature: extensively compared to CDF data (R.D. Field).
61663 C...NB: Can also be run with Pythia 6.2 or 6.312+
61664 C...* Intermediate starting scale for ISR (PARP(67)=2.5)
61665 C...* DWT has a different reference energy, the same as the "S" models
61666 C... below, leading to more UE activity at the LHC, but less at RHIC.
61667 C...* See: http://www.phys.ufl.edu/~rfield/cdf/
61668 C
61669 C QW (105). CTEQ61 parton distributions
61670 C...*** NB : SHOULD BE RUN WITH PYTHIA 6.2 (e.g. 6.228) ***
61671 C...*** CAN ALSO BE RUN WITH PYTHIA 6.406+
61672 C...Key feature: uses CTEQ61 (external pdf library must be linked)
61673 C
61674 C ATLAS-DC2 (106). CTEQ5L parton distributions
61675 C...*** NB : SHOULD BE RUN WITH PYTHIA 6.2 (e.g. 6.228) ***
61676 C...*** CAN ALSO BE RUN WITH PYTHIA 6.406+
61677 C...Key feature: tune used by the ATLAS collaboration.
61678 C
61679 C ACR (107). CTEQ5L parton distributions
61680 C...*** NB : SHOULD BE RUN WITH PYTHIA 6.412+ ***
61681 C...Key feature: Tune A modified to use annealing CR.
61682 C...NB: PARP(85)=0D0 and amount of CR is regulated by PARP(78).
61683 C
61684 C D6 (108) and D6T (109). CTEQ6L parton distributions
61685 C...Key feature: Like DW and DWT but retuned to use CTEQ6L PDFs.
61686 C
61687 C A-Pro, BW-Pro, etc (111, 112, etc). CTEQ5L parton distributions
61688 C Old UE model, Q2-ordered showers.
61689 C...Key feature: Rick Field's family of tunes revamped with the
61690 C...Professor Q2-ordered final-state shower and fragmentation tunes
61691 C...presented by Hendrik Hoeth at the Perugia MPI workshop in Oct 2008.
61692 C...Key feature: improved descriptions of LEP data.
61693 C
61694 C Pro-Q2O (129). CTEQ5L parton distributions
61695 C Old UE model, Q2-ordered showers.
61696 C...Key feature: Complete retune of old model by Professor, including
61697 C...large amounts of both LEP and Tevatron data.
61698 C...Note that PARP(64) (ISR renormalization scale pre-factor) is quite
61699 C...extreme in this tune, corresponding to using mu_R = pT/3 .
61700 C
61701 C=======================================================================
61702 C INTERMEDIATE/HYBRID TUNES (MIX OF NEW AND OLD SHOWER AND UE MODELS)
61703 C=======================================================================
61704 C
61705 C IM1 (200). Intermediate model, Q2-ordered showers,
61706 C CTEQ5L parton distributions
61707 C...Key feature: new UE model w Q2-ordered showers and no interleaving.
61708 C...* "Rap" tune of hep-ph/0402078, modified with new annealing CR.
61709 C...* See: Sjostrand & Skands: JHEP 03(2004)053, hep-ph/0402078.
61710 C
61711 C APT (201). Old UE model, pT-ordered final-state showers,
61712 C CTEQ5L parton distributions
61713 C...Key feature: Rick Field's Tune A, but with new final-state showers
61714 C
61715 C APT-Pro (211). Old UE model, pT-ordered final-state showers,
61716 C CTEQ5L parton distributions
61717 C...Key feature: APT revamped with the Professor pT-ordered final-state
61718 C...shower and fragmentation tunes presented by Hendrik Hoeth at the
61719 C...Perugia MPI workshop in October 2008.
61720 C
61721 C Perugia-APT (221). Old UE model, pT-ordered final-state showers,
61722 C CTEQ5L parton distributions
61723 C...Key feature: APT-Pro with final-state showers off the MPI,
61724 C...lower ISR renormalization scale to improve agreement with the
61725 C...Tevatron Drell-Yan pT measurements and with improved energy scaling
61726 C...to min-bias at 630 GeV.
61727 C
61728 C Perugia-APT6 (226). Old UE model, pT-ordered final-state showers,
61729 C CTEQ6L1 parton distributions.
61730 C...Key feature: uses CTEQ6L1 (external pdf library must be linked),
61731 C...with a slightly lower pT0 (2.0 instead of 2.05) due to the smaller
61732 C...UE activity obtained with CTEQ6L1 relative to CTEQ5L.
61733 C
61734 C=======================================================================
61735 C TUNES OF NEW FRAMEWORK (PT-ORDERED ISR AND FSR, INTERLEAVED UE)
61736 C=======================================================================
61737 C
61738 C S0 (300) and S0A (303). CTEQ5L parton distributions
61739 C...Key feature: large amount of multiple interactions
61740 C...* Somewhat faster than the other colour annealing scenarios.
61741 C...* S0A has a faster energy scaling of the UE IR cutoff, borrowed
61742 C... from Tune A, leading to less UE at the LHC, but more at RHIC.
61743 C...* Small amount of radiation.
61744 C...* Large amount of low-pT MI
61745 C...* Low degree of proton lumpiness (broad matter dist.)
61746 C...* CR Type S (driven by free triplets), of medium strength.
61747 C...* See: Pythia6402 update notes or later.
61748 C
61749 C S1 (301). CTEQ5L parton distributions
61750 C...Key feature: large amount of radiation.
61751 C...* Large amount of low-pT perturbative ISR
61752 C...* Large amount of FSR off ISR partons
61753 C...* Small amount of low-pT multiple interactions
61754 C...* Moderate degree of proton lumpiness
61755 C...* Least aggressive CR type (S+S Type I), but with large strength
61756 C...* See: Sandhoff & Skands: FERMILAB-CONF-05-518-T, in hep-ph/0604120.
61757 C
61758 C S2 (302). CTEQ5L parton distributions
61759 C...Key feature: very lumpy proton + gg string cluster formation allowed
61760 C...* Small amount of radiation
61761 C...* Moderate amount of low-pT MI
61762 C...* High degree of proton lumpiness (more spiky matter distribution)
61763 C...* Most aggressive CR type (S+S Type II), but with small strength
61764 C...* See: Sandhoff & Skands: FERMILAB-CONF-05-518-T, in hep-ph/0604120.
61765 C
61766 C NOCR (304). CTEQ5L parton distributions
61767 C...Key feature: no colour reconnections (NB: "Best fit" only).
61768 C...* NB: <pT>(Nch) problematic in this tune.
61769 C...* Small amount of radiation
61770 C...* Small amount of low-pT MI
61771 C...* Low degree of proton lumpiness
61772 C...* Large BR composite x enhancement factor
61773 C...* Most clever colour flow without CR ("Lambda ordering")
61774 C
61775 C ATLAS-CSC (306). CTEQ6L parton distributions
61776 C...Key feature: 11-parameter ATLAS tune of the new framework.
61777 C...* Old (pre-annealing) colour reconnections a la 305.
61778 C...* Uses CTEQ6 Leading Order PDFs (must be interfaced externally)
61779 C
61780 C S0-Pro, S1-Pro, etc (310, 311, etc). CTEQ5L parton distributions.
61781 C...Key feature: the S0 family of tunes revamped with the Professor
61782 C...pT-ordered final-state shower and fragmentation tunes presented by
61783 C...Hendrik Hoeth at the Perugia MPI workshop in October 2008.
61784 C...Key feature: improved descriptions of LEP data.
61785 C
61786 C ATLAS MC08 (316). CTEQ6L1 parton distributions
61787 C...Key feature: ATLAS tune of the new framework using CTEQ6L1 PDFs
61788 C...* Warning: uses Peterson fragmentation function for heavy quarks
61789 C...* Uses CTEQ6 Leading Order PDFs (must be interfaced externally)
61790 C
61791 C Perugia-0 (320). CTEQ5L parton distributions.
61792 C...Key feature: S0-Pro retuned to more Tevatron data. Better Drell-Yan
61793 C...pT spectrum, better <pT>(Nch) in min-bias, and better scaling to
61794 C...630 GeV than S0-Pro. Also has a slightly smoother mass profile, more
61795 C...beam-remnant breakup (more baryon number transport), and suppression
61796 C...of CR in high-pT string pieces.
61797 C
61798 C Perugia-HARD (321). CTEQ5L parton distributions.
61799 C...Key feature: More ISR, More FSR, Less MPI, Less BR
61800 C...Uses pT/2 as argument of alpha_s for ISR, and a higher Lambda_FSR.
61801 C...Has higher pT0, less intrinsic kT, less beam remnant breakup (less
61802 C...baryon number transport), and more fragmentation pT.
61803 C...Multiplicity in min-bias is LOW, <pT>(Nch) is HIGH,
61804 C...DY pT spectrum is HARD.
61805 C
61806 C Perugia-SOFT (322). CTEQ5L parton distributions.
61807 C...Key feature: Less ISR, Less FSR, More MPI, More BR
61808 C...Uses sqrt(2)*pT as argument of alpha_s for ISR, and a lower
61809 C...Lambda_FSR. Has lower pT0, more beam remnant breakup (more baryon
61810 C...number transport), and less fragmentation pT.
61811 C...Multiplicity in min-bias is HIGH, <pT>(Nch) is LOW,
61812 C...DY pT spectrum is SOFT
61813 C
61814 C Perugia-3 (323). CTEQ5L parton distributions.
61815 C...Key feature: variant of Perugia-0 with more extreme energy scaling
61816 C...properties while still agreeing with Tevatron data from 630 to 1960.
61817 C...More ISR and less MPI than Perugia-0 at the Tevatron and above and
61818 C...allows FSR off the active end of dipoles stretched to the remnant.
61819 C
61820 C Perugia-NOCR (324). CTEQ5L parton distributions.
61821 C...Key feature: Retune of NOCR-Pro with better scaling properties to
61822 C...lower energies and somewhat better agreement with Tevatron data
61823 C...at 1800/1960.
61824 C
61825 C Perugia-* (325). MRST LO* parton distributions for generators
61826 C...Key feature: first attempt at using the LO* distributions
61827 C...(external pdf library must be linked).
61828 C
61829 C Perugia-6 (326). CTEQ6L1 parton distributions
61830 C...Key feature: uses CTEQ6L1 (external pdf library must be linked).
61831 C
61832 C Perugia-2010 (327). CTEQ5L parton distributions
61833 C...Key feature: Retune of Perugia 0 to attempt to better describe
61834 C...strangeness yields at RHIC and at LEP. Also increased the amount
61835 C...of FSR off ISR following the conclusions in arXiv:1001.4082.
61836 C...Increased the amount of beam blowup, causing more baryon transport
61837 C...into the detector, to further explore this possibility. Using
61838 C...a new color-reconnection model that relies on determining a thrust
61839 C...axis for the events and then computing reconnection probabilities for
61840 C...the individual string pieces based on the actual string densities
61841 C...per rapidity interval along that thrust direction.
61842 C
61843 C Perugia-K (328). CTEQ5L parton distributions
61844 C...Key feature: uses a ``K'' factor on the MPI cross sections
61845 C...This gives a larger rate of minijets and pushes the underlying-event
61846 C...activity towards higher pT. To compensate for the increased activity
61847 C...at higher pT, the infared regularization scale is larger for this tune.
61848 C
61849 C Pro-pTO (329). CTEQ5L parton distributions
61850 C...Key feature: Complete retune of new model by Professor, including
61851 C...large amounts of both LEP and Tevatron data. Similar to S0A-Pro.
61852 C
61853 C ATLAS MC09 (330). LO* parton distributions
61854 C...Key feature: Good overall agreement with Tevatron and early LHC data.
61855 C...Similar to Perugia *.
61856 C
61857 C ATLAS MC09c (331). LO* parton distributions
61858 C...Key feature: Good overall agreement with Tevatron and 900-GeV LHC data.
61859 C...Similar to Perugia *. Retuned CR model with respect to MC09.
61860 C
61861 C Pro-pT* (335) LO* parton distributions
61862 C...Key feature: Retune of Pro-PTO with MRST LO* PDFs.
61863 C
61864 C Pro-pT6 (336). CTEQ6L1 parton distributions
61865 C...Key feature: Retune of Pro-PTO with CTEQ6L1 PDFs.
61866 C
61867 C Pro-pT** (339). LO** parton distributions
61868 C...Key feature: Retune of Pro-PTO with MRST LO** PDFs.
61869 C
61870 C AMBT1 (340). LO* parton distributions
61871 C...Key feature: First ATLAS tune including 7-TeV LHC data.
61872 C...Mainly retuned CR and mass distribution with respect to MC09c.
61873 C...Note: cannot be run standalone since it uses external PDFs.
61874 C
61875 C CMSZ1 (341). CTEQ5L parton distributions
61876 C...Key feature: First CMS tune including 7-TeV LHC data.
61877 C...Uses many of the features of AMBT1, but uses CTEQ5L PDFs,
61878 C...has a lower pT0 at the Tevatron, which scales faster with energy.
61879 C
61880 C Z1-LEP (342). CTEQ5L parton distributions
61881 C...Key feature: CMS tune Z1 with improved LEP parameters, mostly
61882 C...taken from the Professor/Perugia tunes, with a few minor updates.
61883 C
61884 C=======================================================================
61885 C OTHER TUNES
61886 C=======================================================================
61887 C
61888 C...The GAL and SCI models (400+) are special and *SHOULD NOT* be run
61889 C...with an unmodified Pythia distribution.
61890 C...See http://www.isv.uu.se/thep/MC/scigal/ for more information.
61891 C
61892 C ::: + Future improvements?
61893 C Include also QCD K-factor a la M. Heinz / ATLAS TDR ? RDF's QK?
61894 C (problem: K-factor affects everything so only works as
61895 C intended for min-bias, not for UE ... probably need a
61896 C better long-term solution to handle UE as well. Anyway,
61897 C Mark uses MSTP(33) and PARP(31)-PARP(33).)
61898 
61899 C...Global statements
61900  IMPLICIT DOUBLE PRECISION(a-h, o-z)
61901  INTEGER pyk,pychge,pycomp
61902 
61903 C...Commonblocks.
61904  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
61905  common/pypars/mstp(200),parp(200),msti(200),pari(200)
61906 
61907 C...SCI and GAL Commonblocks
61908  COMMON /scipar/mswi(2),parsci(2)
61909 
61910 C...SAVE statements
61911  SAVE /pydat1/,/pypars/
61912  SAVE /scipar/
61913 
61914 C...Internal parameters
61915  parameter(mxtuns=500)
61916  CHARACTER*8 chdoc
61917  parameter(chdoc='Mar 2011')
61918  CHARACTER*16 chnams(0:mxtuns), chname
61919  CHARACTER*42 chmstj(50), chmstp(100), chparp(100),
61920  & chparj(100), chmstu(101:121), chparu(101:121), ch40
61921  CHARACTER*60 ch60
61922  CHARACTER*70 ch70
61923  DATA (chnams(i),i=0,1)/'Default',' '/
61924  DATA (chnams(i),i=100,119)/
61925  & 'Tune A','Tune AW','Tune BW','Tune DW','Tune DWT','Tune QW',
61926  & 'ATLAS DC2','Tune ACR','Tune D6','Tune D6T',
61927  1 'Tune A-Pro','Tune AW-Pro','Tune BW-Pro','Tune DW-Pro',
61928  1 'Tune DWT-Pro','Tune QW-Pro','ATLAS DC2-Pro','Tune ACR-Pro',
61929  1 'Tune D6-Pro','Tune D6T-Pro'/
61930  DATA (chnams(i),i=120,129)/
61931  & 9*' ','Pro-Q2O'/
61932  DATA (chnams(i),i=300,309)/
61933  & 'Tune S0','Tune S1','Tune S2','Tune S0A','NOCR','Old',
61934  5 'ATLAS-CSC Tune','Yale Tune','Yale-K Tune',' '/
61935  DATA (chnams(i),i=310,316)/
61936  & 'Tune S0-Pro','Tune S1-Pro','Tune S2-Pro','Tune S0A-Pro',
61937  & 'NOCR-Pro','Old-Pro','ATLAS MC08'/
61938  DATA (chnams(i),i=320,329)/
61939  & 'Perugia 0','Perugia HARD','Perugia SOFT',
61940  & 'Perugia 3','Perugia NOCR','Perugia LO*',
61941  & 'Perugia 6','Perugia 10','Perugia K','Pro-pTO'/
61942  DATA (chnams(i),i=330,349)/
61943  & 'ATLAS MC09','ATLAS MC09c',2*' ','Perugia 10 NOCR','Pro-PT*',
61944  & 'Pro-PT6',' ',' ','Pro-PT**',
61945  4 'Tune AMBT1','Tune Z1','Tune Z1-LEP','Tune Z2','Tune Z2-LEP',
61946  4 5*' '/
61947  DATA (chnams(i),i=350,359)/
61948  & 'Perugia 2011','P2011 radHi','P2011 radLo','P2011 mpiHi',
61949  & 'P2011 noCR','P2011 M(LO**)', 'P2011 CTEQ6L1',
61950  & 'P2011 T16','P2011 T32','P2011 Tevatron'/
61951  DATA (chnams(i),i=360,369)/
61952  & 'S Global','S 7000','S 1960','S 1800',
61953  & 'S 900','S 630', 4*' '/
61954  DATA (chnams(i),i=200,229)/
61955  & 'IM Tune 1','Tune APT',8*' ',
61956  & ' ','Tune APT-Pro',8*' ',
61957  & ' ','Perugia APT',4*' ','Perugia APT6',3*' '/
61958  DATA (chnams(i),i=400,409)/
61959  & 'GAL Tune 0','SCI Tune 0','GAL Tune 1','SCI Tune 1',6*' '/
61960  DATA (chmstj(i),i=11,20)/
61961  & 'HAD choice of fragmentation function(s)',4*' ',
61962  & 'HAD treatment of small-mass systems',4*' '/
61963  DATA (chmstj(i),i=41,50)/
61964  & 'FSR type (Q2 or pT) for old framework',9*' '/
61965  DATA (chmstp(i),i=1,10)/
61966  & 2*' ','INT switch for choice of LambdaQCD',7*' '/
61967  DATA (chmstp(i),i=31,40)/
61968  & 2*' ','"K" switch for K-factor on/off & type',7*' '/
61969  DATA (chmstp(i),i=51,100)/
61970  5 'PDF set','PDF set internal (=1) or pdflib (=2)',8*' ',
61971  6 'ISR master switch',2*' ','ISR alphaS type',2*' ',
61972  6 'ISR coherence option for 1st emission',
61973  6 'ISR phase space choice & ME corrections',' ',
61974  7 'ISR IR regularization scheme',' ',
61975  7 'IFSR scheme for non-decay FSR',8*' ',
61976  8 'UE model',
61977  8 'UE hadron transverse mass distribution',5*' ',
61978  8 'BR composite scheme','BR color scheme',
61979  9 'BR primordial kT compensation',
61980  9 'BR primordial kT distribution',
61981  9 'BR energy partitioning scheme',2*' ',
61982  9 'FSI color (re-)connection model',5*' '/
61983  DATA (chparp(i),i=1,10)/
61984  & 'ME/UE LambdaQCD',9*' '/
61985  DATA (chparp(i),i=31,40)/
61986  & ' ','"K" K-factor',8*' '/
61987  DATA (chparp(i),i=61,100)/
61988  6 'ISR LambdaQCD','ISR IR cutoff',' ',
61989  6 'ISR renormalization scale prefactor',
61990  6 2*' ','ISR Q2max factor',3*' ',
61991  7 'IFSR Q2max factor in non-s-channel procs',
61992  7 'IFSR LambdaQCD (outside resonance decays)',4*' ',
61993  7 'FSI color reco high-pT damping strength',
61994  7 'FSI color reconnection strength',
61995  7 'BR composite x enhancement','BR breakup suppression',
61996  8 2*'UE IR cutoff at reference ecm',
61997  8 2*'UE mass distribution parameter',
61998  8 'UE gg color correlated fraction','UE total gg fraction',
61999  8 2*' ',
62000  8 'UE IR cutoff reference ecm',
62001  8 'UE IR cutoff ecm scaling power',
62002  9 'BR primordial kT width <|kT|>',' ',
62003  9 'BR primordial kT UV cutoff',7*' '/
62004  DATA (chparj(i),i=1,30)/
62005  & 'HAD diquark suppression','HAD strangeness suppression',
62006  & 'HAD strange diquark suppression',
62007  & 'HAD vector diquark suppression','HAD P(popcorn)',
62008  & 'HAD extra popcorn B(s)-M-B(s) supp',
62009  & 'HAD extra popcorn B-M(s)-B supp',
62010  & 3*' ',
62011  1 'HAD P(vector meson), u and d only',
62012  1 'HAD P(vector meson), contains s',
62013  1 'HAD P(vector meson), heavy quarks',7*' ',
62014  2 'HAD fragmentation pT',' ',' ',' ',
62015  2 'HAD eta0 suppression',"HAD eta0' suppression",4*' '/
62016  DATA (chparj(i),i=41,90)/
62017  4 'HAD string parameter a(Meson)','HAD string parameter b',
62018  4 2*' ','HAD string a(Baryon)-a(Meson)',
62019  4 'HAD Lund(=0)-Bowler(=1) rQ (rc)',
62020  4 'HAD Lund(=0)-Bowler(=1) rb',3*' ',
62021  5 3*' ', 'HAD charm parameter','HAD bottom parameter',5*' ',
62022  6 10*' ',10*' ',
62023  8 'FSR LambdaQCD (inside resonance decays)',
62024  & 'FSR IR cutoff',8*' '/
62025  DATA (chmstu(i),i=111,120)/
62026  1 ' ','INT n(flavors) for LambdaQCD',8*' '/
62027  DATA (chparu(i),i=111,120)/
62028  1 ' ','INT LambdaQCD',8*' '/
62029 
62030 C...1) Shorthand notation
62031  m13=mstu(13)
62032  m11=mstu(11)
62033  IF (itune.LE.mxtuns.AND.itune.GE.0) THEN
62034  chname=chnams(itune)
62035  IF (itune.EQ.0) goto 9999
62036  ELSE
62037  CALL pyerrm(9,'(PYTUNE:) Tune number > max. Using defaults.')
62038  goto 9999
62039  ENDIF
62040 
62041 C...2) Hello World
62042  IF (m13.GE.1) WRITE(m11,5000) chdoc
62043 
62044 C...Hardcode some defaults
62045 C...Get Lambda from PDF
62046  mstp(3) = 2
62047 C...CTEQ5L1 PDFs
62048  mstp(52) = 1
62049  mstp(51) = 7
62050 C... No K-factor
62051  mstp(33) = 0
62052 
62053 C...3) Tune parameters
62054 
62055 C=======================================================================
62056 C...ATLAS MC08
62057 
62058  IF (itune.EQ.316) THEN
62059 
62060  IF (m13.GE.1) WRITE(m11,5010) itune, chname
62061  IF (mstp(181).LE.5.OR.(mstp(181).EQ.6.AND.mstp(182).LE.405))THEN
62062  CALL pyerrm(9,'(PYTUNE:) linked PYTHIA version incompatible'//
62063  & ' with tune.')
62064  ENDIF
62065 
62066 C...First set some explicit defaults from 6.4.20
62067 C...# Old defaults
62068  mstj(11) = 4
62069 C...# Old default flavour parameters
62070  parj(1) = 0.1
62071  parj(2) = 0.3
62072  parj(3) = 0.40
62073  parj(4) = 0.05
62074  parj(11) = 0.5
62075  parj(12) = 0.6
62076  parj(21) = 0.36
62077  parj(41) = 0.30
62078  parj(42) = 0.58
62079  parj(46) = 1.0
62080  parj(82) = 1.0
62081 
62082 C...PDFs: CTEQ6L1 for 326
62083  mstp(52)=2
62084  mstp(51)=10042
62085 
62086 C...UE and ISR switches
62087  mstp(81)=21
62088  mstp(82)=4
62089  mstp(70)=0
62090  mstp(72)=1
62091 
62092 C...CR:
62093  mstp(95)=2
62094  parp(78)=0.3
62095  parp(77)=0.0
62096  parp(80)=0.1
62097 
62098 C...Primordial kT
62099  parp(91)=2.0d0
62100  parp(93)=5.0d0
62101 
62102 C...MPI:
62103  parp(82)=2.1
62104  parp(83)=0.8
62105  parp(84)=0.7
62106  parp(89)=1800.0
62107  parp(90)=0.16
62108 
62109 C...FSR inside resonance decays
62110  parj(81)=0.29
62111 
62112 C...Fragmentation (warning: uses Peterson)
62113  mstj(11)=3
62114  parj(54)=-0.07
62115  parj(55)=-0.006
62116  mstj(22)=2
62117 
62118  IF (m13.GE.1) THEN
62119  ch60='Tuned by ATLAS, ATL-PHYS-PUB-2010-002'
62120  WRITE(m11,5030) ch60
62121  ch60='Physics model: '//
62122  & 'T. Sjostrand & P. Skands, hep-ph/0408302'
62123  WRITE(m11,5030) ch60
62124  ch60='CR by M. Sandhoff & P. Skands, in hep-ph/0604120'
62125  WRITE(m11,5030) ch60
62126 
62127 C...Output
62128  WRITE(m11,5030) ' '
62129  WRITE(m11,5040) 51, mstp(51), chmstp(51)
62130  WRITE(m11,5040) 52, mstp(52), chmstp(52)
62131  WRITE(m11,5040) 3, mstp( 3), chmstp( 3)
62132  IF (mstp(70).EQ.0) THEN
62133  WRITE(m11,5050) 62, parp(62), chparp(62)
62134  ENDIF
62135  WRITE(m11,5040) 64, mstp(64), chmstp(64)
62136  WRITE(m11,5050) 64, parp(64), chparp(64)
62137  WRITE(m11,5040) 67, mstp(67), chmstp(67)
62138  WRITE(m11,5050) 67, parp(67), chparp(67)
62139  WRITE(m11,5040) 68, mstp(68), chmstp(68)
62140  ch60='(Note: MSTP(68) is not explicitly (re-)set by PYTUNE)'
62141  WRITE(m11,5030) ch60
62142  WRITE(m11,5040) 70, mstp(70), chmstp(70)
62143  WRITE(m11,5040) 72, mstp(72), chmstp(72)
62144  WRITE(m11,5050) 71, parp(71), chparp(71)
62145  WRITE(m11,5060) 81, parj(81), chparj(81)
62146  WRITE(m11,5060) 82, parj(82), chparj(82)
62147  WRITE(m11,5040) 33, mstp(33), chmstp(33)
62148  WRITE(m11,5040) 81, mstp(81), chmstp(81)
62149  WRITE(m11,5050) 82, parp(82), chparp(82)
62150  WRITE(m11,5050) 89, parp(89), chparp(89)
62151  WRITE(m11,5050) 90, parp(90), chparp(90)
62152  WRITE(m11,5040) 82, mstp(82), chmstp(82)
62153  WRITE(m11,5050) 83, parp(83), chparp(83)
62154  WRITE(m11,5050) 84, parp(84), chparp(84)
62155  WRITE(m11,5040) 88, mstp(88), chmstp(88)
62156  WRITE(m11,5040) 89, mstp(89), chmstp(89)
62157  WRITE(m11,5050) 79, parp(79), chparp(79)
62158  WRITE(m11,5050) 80, parp(80), chparp(80)
62159  WRITE(m11,5040) 91, mstp(91), chmstp(91)
62160  WRITE(m11,5050) 91, parp(91), chparp(91)
62161  WRITE(m11,5050) 93, parp(93), chparp(93)
62162  WRITE(m11,5040) 95, mstp(95), chmstp(95)
62163  IF (mstp(95).GE.1) THEN
62164  WRITE(m11,5050) 78, parp(78), chparp(78)
62165  IF (mstp(95).GE.2) WRITE(m11,5050) 77, parp(77), chparp(77)
62166  ENDIF
62167 
62168  ENDIF
62169 
62170 C=======================================================================
62171 C...ATLAS MC09, MC09c, AMBT1
62172 C...CMS Z1 (R. Field), Z1-LEP
62173 
62174  ELSEIF (itune.EQ.330.OR.itune.EQ.331.OR.itune.EQ.340.OR.
62175  & itune.GE.341.AND.itune.LE.344) THEN
62176 
62177  IF (m13.GE.1) WRITE(m11,5010) itune, chname
62178  IF (mstp(181).LE.5.OR.(mstp(181).EQ.6.AND.mstp(182).LE.405))THEN
62179  CALL pyerrm(9,'(PYTUNE:) linked PYTHIA version incompatible'//
62180  & ' with tune.')
62181  ENDIF
62182 
62183 C...First set some explicit defaults from 6.4.20
62184  IF (itune.LE.341.OR.itune.EQ.343) THEN
62185 C... # Old defaults
62186  mstj(11) = 4
62187 C...# Old default flavour parameters
62188  parj(1) = 0.1
62189  parj(2) = 0.3
62190  parj(3) = 0.40
62191  parj(4) = 0.05
62192  parj(11) = 0.5
62193  parj(12) = 0.6
62194  parj(21) = 0.36
62195  parj(41) = 0.30
62196  parj(42) = 0.58
62197  parj(46) = 1.0
62198  parj(82) = 1.0
62199  ELSE
62200 C...# For Zn-LEP tunes, use tuned flavour parameters from Professor/Perugia
62201  parj( 1) = 0.08d0
62202  parj( 2) = 0.21d0
62203  parj(3) = 0.94
62204  parj( 4) = 0.04d0
62205  parj(11) = 0.35d0
62206  parj(12) = 0.35d0
62207  parj(13) = 0.54
62208  parj(25) = 0.63
62209  parj(26) = 0.12
62210 C...# Switch on Bowler:
62211  mstj(11) = 5
62212 C...# Fragmentation
62213  parj(21) = 0.34d0
62214  parj(41) = 0.35d0
62215  parj(42) = 0.80d0
62216  parj(47) = 1.0
62217  parj(81) = 0.26d0
62218  parj(82) = 1.0d0
62219  ENDIF
62220 
62221 C...PDFs: MRST LO*
62222  mstp(52)=2
62223  mstp(51)=20650
62224  IF (itune.EQ.341.OR.itune.EQ.342) THEN
62225 C...Z1 uses CTEQ5L
62226  mstp(52)=1
62227  mstp(51)=7
62228  ELSEIF (itune.EQ.343.OR.itune.EQ.344) THEN
62229 C...Z2 uses CTEQ6L
62230  mstp(52)=2
62231  mstp(51)=10042
62232  ENDIF
62233 
62234 C...UE and ISR switches
62235  mstp(81)=21
62236  mstp(82)=4
62237  mstp(70)=0
62238  mstp(72)=1
62239 
62240 C...CR:
62241  mstp(95)=6
62242  parp(78)=0.3
62243  parp(77)=0.0
62244  parp(80)=0.1
62245  IF (itune.EQ.331) THEN
62246  parp(78)=0.224
62247  ELSEIF (itune.EQ.340) THEN
62248 C...AMBT1
62249  parp(77)=1.016d0
62250  parp(78)=0.538d0
62251  ELSEIF (itune.GE.341.AND.itune.LE.344) THEN
62252 C...Z1 and Z2 use the AMBT1 CR values
62253  parp(77)=1.016d0
62254  parp(78)=0.538d0
62255  ENDIF
62256 
62257 C...MPI:
62258  parp(82)=2.3
62259  parp(83)=0.8
62260  parp(84)=0.7
62261  parp(89)=1800.0
62262  parp(90)=0.25
62263  IF (itune.EQ.331) THEN
62264  parp(82)=2.315
62265  parp(90)=0.2487
62266  ELSEIF (itune.EQ.340) THEN
62267  parp(82)=2.292d0
62268  parp(83)=0.356d0
62269  parp(84)=0.651
62270  parp(90)=0.25d0
62271  ELSEIF (itune.EQ.341.OR.itune.EQ.342) THEN
62272  parp(82)=1.932d0
62273  parp(83)=0.356d0
62274  parp(84)=0.651
62275  parp(90)=0.275d0
62276  ELSEIF (itune.EQ.343.OR.itune.EQ.344) THEN
62277  parp(82)=1.832d0
62278  parp(83)=0.356d0
62279  parp(84)=0.651
62280  parp(90)=0.275d0
62281  ENDIF
62282 
62283 C...Primordial kT
62284  parp(91)=2.0d0
62285  parp(93)=5d0
62286  IF (itune.GE.340) THEN
62287  parp(93)=10d0
62288  ENDIF
62289 
62290 C...ISR
62291  IF (itune.GE.340) THEN
62292  parp(62)=1.025
62293  ENDIF
62294 
62295 C...FSR inside resonance decays
62296  parj(81)=0.29
62297 
62298 C...Fragmentation (org 6.4 defs hardcoded)
62299  mstj(11)=4
62300  parj(41)=0.3
62301  parj(42)=0.58
62302  mstj(22)=2
62303 C...AMBT1 mentions 46 explicitly, but Z1 doesn't ...
62304  parj(46)=0.75
62305  IF (itune.GE.341.AND.itune.LE.344) THEN
62306 C...Reset PARJ(46) to org def value for Z1 and Z2
62307  parj(46)=1.0
62308  ENDIF
62309 
62310  IF (m13.GE.1) THEN
62311  IF (itune.LT.340) THEN
62312  ch60='Tuned by ATLAS, ATL-PHYS-PUB-2010-002'
62313  ELSEIF (itune.EQ.340) THEN
62314  ch60='Tuned by ATLAS, ATLAS-CONF-2010-031'
62315  ELSEIF (itune.EQ.341) THEN
62316  ch60='AMBT1 Tuned by ATLAS, ATLAS-CONF-2010-031'
62317  WRITE(m11,5030) ch60
62318  ch60='Z1 variation tuned by R. D. Field (CMS)'
62319  ELSEIF (itune.EQ.342) THEN
62320  ch60='AMBT1 Tuned by ATLAS, ATLAS-CONF-2010-031'
62321  WRITE(m11,5030) ch60
62322  ch60='Z1 variation retuned by R. D. Field (CMS)'
62323  WRITE(m11,5030) ch60
62324  ch60='Z1-LEP variation retuned by Professor / P. Skands'
62325  ELSEIF (itune.EQ.343) THEN
62326  ch60='AMBT1 Tuned by ATLAS, ATLAS-CONF-2010-031'
62327  WRITE(m11,5030) ch60
62328  ch60='Z2 variation retuned by R. D. Field (CMS)'
62329  ELSEIF (itune.EQ.344) THEN
62330  ch60='AMBT1 Tuned by ATLAS, ATLAS-CONF-2010-031'
62331  WRITE(m11,5030) ch60
62332  ch60='Z2 variation retuned by R. D. Field (CMS)'
62333  WRITE(m11,5030) ch60
62334  ch60='Z2-LEP variation retuned by Professor / P. Skands'
62335  ENDIF
62336  WRITE(m11,5030) ch60
62337  ch60='Physics Model: '//
62338  & 'T. Sjostrand & P. Skands, hep-ph/0408302'
62339  WRITE(m11,5030) ch60
62340  ch60='CR by M. Sandhoff & P. Skands, in hep-ph/0604120'
62341  WRITE(m11,5030) ch60
62342 
62343 C...Output
62344  WRITE(m11,5030) ' '
62345  WRITE(m11,5040) 51, mstp(51), chmstp(51)
62346  WRITE(m11,5040) 52, mstp(52), chmstp(52)
62347  WRITE(m11,5040) 3, mstp( 3), chmstp( 3)
62348  IF (mstp(70).EQ.0) THEN
62349  WRITE(m11,5050) 62, parp(62), chparp(62)
62350  ENDIF
62351  WRITE(m11,5040) 64, mstp(64), chmstp(64)
62352  WRITE(m11,5050) 64, parp(64), chparp(64)
62353  WRITE(m11,5040) 67, mstp(67), chmstp(67)
62354  WRITE(m11,5050) 67, parp(67), chparp(67)
62355  WRITE(m11,5040) 68, mstp(68), chmstp(68)
62356  ch60='(Note: MSTP(68) is not explicitly (re-)set by PYTUNE)'
62357  WRITE(m11,5030) ch60
62358  WRITE(m11,5040) 70, mstp(70), chmstp(70)
62359  WRITE(m11,5040) 72, mstp(72), chmstp(72)
62360  WRITE(m11,5050) 71, parp(71), chparp(71)
62361  WRITE(m11,5060) 81, parj(81), chparj(81)
62362  WRITE(m11,5060) 82, parj(82), chparj(82)
62363  WRITE(m11,5040) 33, mstp(33), chmstp(33)
62364  WRITE(m11,5040) 81, mstp(81), chmstp(81)
62365  WRITE(m11,5050) 82, parp(82), chparp(82)
62366  WRITE(m11,5050) 89, parp(89), chparp(89)
62367  WRITE(m11,5050) 90, parp(90), chparp(90)
62368  WRITE(m11,5040) 82, mstp(82), chmstp(82)
62369  WRITE(m11,5050) 83, parp(83), chparp(83)
62370  WRITE(m11,5050) 84, parp(84), chparp(84)
62371  WRITE(m11,5040) 88, mstp(88), chmstp(88)
62372  WRITE(m11,5040) 89, mstp(89), chmstp(89)
62373  WRITE(m11,5050) 79, parp(79), chparp(79)
62374  WRITE(m11,5050) 80, parp(80), chparp(80)
62375  WRITE(m11,5040) 91, mstp(91), chmstp(91)
62376  WRITE(m11,5050) 91, parp(91), chparp(91)
62377  WRITE(m11,5050) 93, parp(93), chparp(93)
62378  WRITE(m11,5040) 95, mstp(95), chmstp(95)
62379  IF (mstp(95).GE.1) THEN
62380  WRITE(m11,5050) 78, parp(78), chparp(78)
62381  IF (mstp(95).GE.2) WRITE(m11,5050) 77, parp(77), chparp(77)
62382  ENDIF
62383 
62384  ENDIF
62385 
62386 C=======================================================================
62387 C...S0, S1, S2, S0A, NOCR, Rap,
62388 C...S0-Pro, S1-Pro, S2-Pro, S0A-Pro, NOCR-Pro, Rap-Pro
62389 C...Perugia 0, HARD, SOFT, 3, LO*, 6, 2010, K
62390 C...Pro-pTO, Pro-PT*, Pro-PT6, Pro-PT**
62391 C...Perugia 2011 (incl variations)
62392 C...Schulz-Skands tunes
62393  ELSEIF ((itune.GE.300.AND.itune.LE.305)
62394  & .OR.(itune.GE.310.AND.itune.LE.315)
62395  & .OR.(itune.GE.320.AND.itune.LE.329)
62396  & .OR.(itune.GE.334.AND.itune.LE.336).OR.itune.EQ.339
62397  & .OR.(itune.GE.350.AND.itune.LE.365)) THEN
62398  IF (m13.GE.1) WRITE(m11,5010) itune, chname
62399  IF (mstp(181).LE.5.OR.(mstp(181).EQ.6.AND.mstp(182).LE.405))THEN
62400  CALL pyerrm(9,'(PYTUNE:) linked PYTHIA version incompatible'//
62401  & ' with tune.')
62402  ELSEIF(itune.GE.320.AND.itune.LE.339.AND.itune.NE.324.AND.
62403  & itune.NE.334.AND.
62404  & (mstp(181).LE.5.OR.(mstp(181).EQ.6.AND.mstp(182).LE.419)))
62405  & THEN
62406  CALL pyerrm(9,'(PYTUNE:) linked PYTHIA version incompatible'//
62407  & ' with tune.')
62408  ELSEIF((itune.EQ.327.OR.itune.EQ.328.OR.itune.GE.350).AND.
62409  & (mstp(181).LE.5.OR.
62410  & (mstp(181).EQ.6.AND.mstp(182).LE.422)))
62411  & THEN
62412  CALL pyerrm(9,'(PYTUNE:) linked PYTHIA version incompatible'//
62413  & ' with tune.')
62414  ENDIF
62415 
62416 C...Use 327 as base tune for 350-359 (Perugia 2011)
62417  itunsv = itune
62418  IF (itune.GE.350.AND.itune.LE.359) itune = 327
62419 C...Use 320 as base tune for 360+ (Schulz-Skands)
62420  IF (itune.GE.360) itune = 320
62421 
62422 C...HAD: Use Professor's LEP pars if ITUNE >= 310
62423 C...(i.e., for S0-Pro, S1-Pro etc, and for Perugia tunes)
62424  IF (itune.LT.310) THEN
62425 C...# Old defaults
62426  mstj(11) = 4
62427 C...# Old default flavour parameters
62428  parj(1) = 0.1
62429  parj(2) = 0.3
62430  parj(3) = 0.40
62431  parj(4) = 0.05
62432  parj(11) = 0.5
62433  parj(12) = 0.6
62434  parj(21) = 0.36
62435  parj(41) = 0.30
62436  parj(42) = 0.58
62437  parj(46) = 1.0
62438  parj(82) = 1.0
62439 
62440  ELSEIF (itune.GE.310) THEN
62441 C...# Tuned flavour parameters:
62442  parj(1) = 0.073
62443  parj(2) = 0.2
62444  parj(3) = 0.94
62445  parj(4) = 0.032
62446  parj(11) = 0.31
62447  parj(12) = 0.4
62448  parj(13) = 0.54
62449  parj(25) = 0.63
62450  parj(26) = 0.12
62451 C...# Always use pT-ordered shower:
62452  mstj(41) = 12
62453 C...# Switch on Bowler:
62454  mstj(11) = 5
62455 C...# Fragmentation
62456  parj(21) = 0.313
62457  parj(41) = 0.49
62458  parj(42) = 1.2
62459  parj(47) = 1.0
62460  parj(81) = 0.257
62461  parj(82) = 0.8
62462 
62463 C...HAD: fragmentation pT (only if not using professor) - HARD and SOFT
62464  IF (itune.EQ.321) parj(21)=0.34d0
62465  IF (itune.EQ.322) parj(21)=0.28d0
62466 
62467 C...HAD: P-2010 and P-K use different strangeness parameters
62468 C... indicated by LEP and RHIC yields.
62469 C...(only 5% different from Professor values, so should be within acceptable
62470 C...theoretical uncertainty range)
62471 C...(No attempt made to retune other flavor parameters post facto)
62472  IF (itune.EQ.327.OR.itune.EQ.328.OR.itune.EQ.334) THEN
62473  parj( 1) = 0.08d0
62474  parj( 2) = 0.21d0
62475  parj( 4) = 0.04d0
62476  parj(11) = 0.35d0
62477  parj(12) = 0.35d0
62478  parj(21) = 0.36d0
62479  parj(41) = 0.35d0
62480  parj(42) = 0.90d0
62481  parj(81) = 0.26d0
62482  parj(82) = 1.0d0
62483  ENDIF
62484  ENDIF
62485 
62486 C...Remove middle digit now for Professor variants, since identical pars
62487  ituneb=itune
62488  IF (itune.GE.310.AND.itune.LE.319) THEN
62489  ituneb=(itune/100)*100+mod(itune,10)
62490  ENDIF
62491 
62492 C...PDFs: all use CTEQ5L as starting point
62493  mstp(52)=1
62494  mstp(51)=7
62495  IF (itune.EQ.325.OR.itune.EQ.335) THEN
62496 C...MRST LO* for 325 and 335
62497  mstp(52)=2
62498  mstp(51)=20650
62499  ELSEIF (itune.EQ.326.OR.itune.EQ.336) THEN
62500 C...CTEQ6L1 for 326 and 336
62501  mstp(52)=2
62502  mstp(51)=10042
62503  ELSEIF (itune.EQ.339) THEN
62504 C...MRST LO** for 339
62505  mstp(52)=2
62506  mstp(51)=20651
62507  ENDIF
62508 
62509 C...LambdaQCD choice: 327 and 328 use hardcoded, others get from PDF
62510  mstp(3)=2
62511  IF (itune.EQ.327.OR.itune.EQ.328.OR.itune.EQ.334) THEN
62512  mstp(3) = 1
62513 C...Hardcode CTEQ5L values for ME and ISR
62514  mstu(112) = 4
62515  paru(112) = 0.192d0
62516  parp(61) = 0.192d0
62517  parp( 1) = 0.192d0
62518 C...but use LEP value also for non-res FSR
62519  parp(72) = 0.260d0
62520  ENDIF
62521 
62522 C...ISR: use Lambda_MSbar with default scale for S0(A)
62523  mstp(64)=2
62524  parp(64)=1d0
62525  IF (itune.EQ.320.OR.itune.EQ.323.OR.itune.EQ.324.OR.itune.EQ.334
62526  & .OR.itune.EQ.326.OR.itune.EQ.327.OR.itune.EQ.328) THEN
62527 C...Use Lambda_MC with muR^2=pT^2 for most central Perugia tunes
62528  mstp(64)=3
62529  parp(64)=1d0
62530  ELSEIF (itune.EQ.321) THEN
62531 C...Use Lambda_MC with muR^2=(1/2pT)^2 for Perugia HARD
62532  mstp(64)=3
62533  parp(64)=0.25d0
62534  ELSEIF (itune.EQ.322) THEN
62535 C...Use Lambda_MSbar with muR^2=2pT^2 for Perugia SOFT
62536  mstp(64)=2
62537  parp(64)=2d0
62538  ELSEIF (itune.EQ.325) THEN
62539 C...Use Lambda_MC with muR^2=2pT^2 for Perugia LO*
62540  mstp(64)=3
62541  parp(64)=2d0
62542  ELSEIF (itune.EQ.329.OR.itune.EQ.335.OR.itune.EQ.336.OR.
62543  & itune.EQ.339) THEN
62544 C...Use Lambda_MSbar with P64=1.3 for Pro-pT0
62545  mstp(64)=2
62546  parp(64)=1.3d0
62547  IF (itune.EQ.335) parp(64)=0.92d0
62548  IF (itune.EQ.336) parp(64)=0.89d0
62549  IF (itune.EQ.339) parp(64)=0.97d0
62550  ENDIF
62551 
62552 C...ISR : power-suppressed power showers above s_color (since 6.4.19)
62553  mstp(67)=2
62554  parp(67)=4d0
62555 C...Perugia tunes have stronger suppression, except HARD
62556  IF ((itune.GE.320.AND.itune.LE.328).OR.itune.EQ.334) THEN
62557  parp(67)=1d0
62558  IF (itune.EQ.321) parp(67)=4d0
62559  IF (itune.EQ.322) parp(67)=0.25d0
62560  ENDIF
62561 
62562 C...ISR IR cutoff type and FSR off ISR setting:
62563 C...Smooth ISR, low FSR-off-ISR
62564  mstp(70)=2
62565  mstp(72)=0
62566  IF (ituneb.EQ.301) THEN
62567 C...S1, S1-Pro: sharp ISR, high FSR
62568  mstp(70)=0
62569  mstp(72)=1
62570  ELSEIF (itune.EQ.320.OR.itune.EQ.324.OR.itune.EQ.326
62571  & .OR.itune.EQ.325) THEN
62572 C...Perugia default is smooth ISR, high FSR-off-ISR
62573  mstp(70)=2
62574  mstp(72)=1
62575  ELSEIF (itune.EQ.321) THEN
62576 C...Perugia HARD: sharp ISR, high FSR-off-ISR (but no dip-to-BR rad)
62577  mstp(70)=0
62578  parp(62)=1.25d0
62579  mstp(72)=1
62580  ELSEIF (itune.EQ.322) THEN
62581 C...Perugia SOFT: scaling sharp ISR, low FSR-off-ISR
62582  mstp(70)=1
62583  parp(81)=1.5d0
62584  mstp(72)=0
62585  ELSEIF (itune.EQ.323) THEN
62586 C...Perugia 3: sharp ISR, high FSR-off-ISR (with dipole-to-BR radiating)
62587  mstp(70)=0
62588  parp(62)=1.25d0
62589  mstp(72)=2
62590  ELSEIF (itune.EQ.327.OR.itune.EQ.328.OR.itune.EQ.334) THEN
62591 C...Perugia 2010/K: smooth ISR, high FSR-off-ISR (with dipole-to-BR radiating)
62592  mstp(70)=2
62593  mstp(72)=2
62594  ENDIF
62595 
62596 C...FSR activity: Perugia tunes use a lower PARP(71) as indicated
62597 C...by Professor tunes (with HARD and SOFT variations)
62598  parp(71)=4d0
62599  IF ((itune.GE.320.AND.itune.LE.328).OR.itune.EQ.334) THEN
62600  parp(71)=2d0
62601  IF (itune.EQ.321) parp(71)=4d0
62602  IF (itune.EQ.322) parp(71)=1d0
62603  ENDIF
62604  IF (itune.EQ.329) parp(71)=2d0
62605  IF (itune.EQ.335) parp(71)=1.29d0
62606  IF (itune.EQ.336) parp(71)=1.72d0
62607  IF (itune.EQ.339) parp(71)=1.20d0
62608 
62609 C...FSR: Lambda_FSR scale (only if not using professor)
62610  IF (itune.LT.310) parj(81)=0.23d0
62611  IF (itune.EQ.321) parj(81)=0.30d0
62612  IF (itune.EQ.322) parj(81)=0.20d0
62613 
62614 C...K-factor : only 328 uses a K-factor on the UE cross sections
62615  mstp(33)=0
62616  IF (itune.EQ.328) THEN
62617  mstp(33)=10
62618  parp(32)=1.5
62619  ENDIF
62620 C...UE on, new model
62621  mstp(81)=21
62622 
62623 C...UE: hadron-hadron overlap profile (expOfPow for all)
62624  mstp(82)=5
62625 C...UE: Overlap smoothness (1.0 = exponential; 2.0 = gaussian)
62626  parp(83)=1.6d0
62627  IF (ituneb.EQ.301) parp(83)=1.4d0
62628  IF (ituneb.EQ.302) parp(83)=1.2d0
62629 C...NOCR variants have very smooth distributions
62630  IF (ituneb.EQ.304) parp(83)=1.8d0
62631  IF (ituneb.EQ.305) parp(83)=2.0d0
62632  IF ((itune.GE.320.AND.itune.LE.328).OR.itune.EQ.334) THEN
62633 C...Perugia variants have slightly smoother profiles by default
62634 C...(to compensate for more tail by added radiation)
62635 C...Perugia-SOFT has more peaked distribution, NOCR less peaked
62636  parp(83)=1.7d0
62637  IF (itune.EQ.322) parp(83)=1.5d0
62638  IF (itune.EQ.327) parp(83)=1.5d0
62639  IF (itune.EQ.328) parp(83)=1.5d0
62640 C...NOCR variants have smoother mass profiles
62641  IF (itune.EQ.324) parp(83)=1.8d0
62642  IF (itune.EQ.334) parp(83)=1.8d0
62643  ENDIF
62644 C...Professor-pT0 also has very smooth distribution
62645  IF (itune.EQ.329) parp(83)=1.8
62646  IF (itune.EQ.335) parp(83)=1.68
62647  IF (itune.EQ.336) parp(83)=1.72
62648  IF (itune.EQ.339) parp(83)=1.67
62649 
62650 C...UE: pT0 = 1.85 for S0, S0A, 2.0 for Perugia version
62651  parp(82)=1.85d0
62652  IF (ituneb.EQ.301) parp(82)=2.1d0
62653  IF (ituneb.EQ.302) parp(82)=1.9d0
62654  IF (ituneb.EQ.304) parp(82)=2.05d0
62655  IF (ituneb.EQ.305) parp(82)=1.9d0
62656  IF ((itune.GE.320.AND.itune.LE.328).OR.itune.EQ.334) THEN
62657 C...Perugia tunes (def is 2.0 GeV, HARD has higher, SOFT has lower,
62658 C...Perugia-3 has more ISR, so higher pT0, NOCR can be slightly lower,
62659 C...CTEQ6L1 slightly lower, due to less activity, and LO* needs to be
62660 C...slightly higher, due to increased activity.
62661  parp(82)=2.0d0
62662  IF (itune.EQ.321) parp(82)=2.3d0
62663  IF (itune.EQ.322) parp(82)=1.9d0
62664  IF (itune.EQ.323) parp(82)=2.2d0
62665  IF (itune.EQ.324) parp(82)=1.95d0
62666  IF (itune.EQ.325) parp(82)=2.2d0
62667  IF (itune.EQ.326) parp(82)=1.95d0
62668  IF (itune.EQ.327) parp(82)=2.05d0
62669  IF (itune.EQ.328) parp(82)=2.45d0
62670  IF (itune.EQ.334) parp(82)=2.15d0
62671  ENDIF
62672 C...Professor-pT0 maintains low pT0 vaue
62673  IF (itune.EQ.329) parp(82)=1.85d0
62674  IF (itune.EQ.335) parp(82)=2.10d0
62675  IF (itune.EQ.336) parp(82)=1.83d0
62676  IF (itune.EQ.339) parp(82)=2.28d0
62677 
62678 C...UE: IR cutoff reference energy and default energy scaling pace
62679  parp(89)=1800d0
62680  parp(90)=0.16d0
62681 C...S0A, S0A-Pro have tune A energy scaling
62682  IF (ituneb.EQ.303) parp(90)=0.25d0
62683  IF ((itune.GE.320.AND.itune.LE.328).OR.itune.EQ.334) THEN
62684 C...Perugia tunes explicitly include MB at 630 to fix energy scaling
62685  parp(90)=0.26
62686  IF (itune.EQ.321) parp(90)=0.30d0
62687  IF (itune.EQ.322) parp(90)=0.24d0
62688  IF (itune.EQ.323) parp(90)=0.32d0
62689  IF (itune.EQ.324) parp(90)=0.24d0
62690 C...LO* and CTEQ6L1 tunes have slower energy scaling
62691  IF (itune.EQ.325) parp(90)=0.23d0
62692  IF (itune.EQ.326) parp(90)=0.22d0
62693  ENDIF
62694 C...Professor-pT0 has intermediate scaling
62695  IF (itune.EQ.329) parp(90)=0.22d0
62696  IF (itune.EQ.335) parp(90)=0.20d0
62697  IF (itune.EQ.336) parp(90)=0.20d0
62698  IF (itune.EQ.339) parp(90)=0.21d0
62699 
62700 C...BR: MPI initiator color connections rap-ordered by default
62701 C...NOCR variants are Lambda-ordered, Perugia SOFT & 2010 random-ordered
62702  mstp(89)=1
62703  IF (ituneb.EQ.304.OR.itune.EQ.324) mstp(89)=2
62704  IF (itune.EQ.322) mstp(89)=0
62705  IF (itune.EQ.327) mstp(89)=0
62706  IF (itune.EQ.328) mstp(89)=0
62707 
62708 C...BR: BR-g-BR suppression factor (higher values -> more beam blowup)
62709  parp(80)=0.01d0
62710  IF (itune.GE.320.AND.itune.LE.328) THEN
62711 C...Perugia tunes have more beam blowup by default
62712  parp(80)=0.05d0
62713  IF (itune.EQ.321) parp(80)=0.01
62714  IF (itune.EQ.323) parp(80)=0.03
62715  IF (itune.EQ.324) parp(80)=0.01
62716  IF (itune.EQ.327) parp(80)=0.1
62717  IF (itune.EQ.328) parp(80)=0.1
62718  ENDIF
62719 
62720 C...BR: diquarks (def = valence qq and moderate diquark x enhancement)
62721  mstp(88)=0
62722  parp(79)=2d0
62723  IF (ituneb.EQ.304) parp(79)=3d0
62724  IF (itune.EQ.329) parp(79)=1.18
62725  IF (itune.EQ.335) parp(79)=1.11
62726  IF (itune.EQ.336) parp(79)=1.10
62727  IF (itune.EQ.339) parp(79)=3.69
62728 
62729 C...BR: Primordial kT, parametrization and cutoff, default is 2 GeV
62730  mstp(91)=1
62731  parp(91)=2d0
62732  parp(93)=10d0
62733 C...Perugia-HARD only uses 1.0 GeV
62734  IF (itune.EQ.321) parp(91)=1.0d0
62735 C...Perugia-3 only uses 1.5 GeV
62736  IF (itune.EQ.323) parp(91)=1.5d0
62737 C...Professor-pT0 uses 7-GeV cutoff
62738  IF (itune.EQ.329) parp(93)=7.0
62739  IF (itune.EQ.335) THEN
62740  parp(91)=2.15
62741  parp(93)=6.79
62742  ELSEIF (itune.EQ.336) THEN
62743  parp(91)=1.85
62744  parp(93)=6.86
62745  ELSEIF (itune.EQ.339) THEN
62746  parp(91)=2.11
62747  parp(93)=5.08
62748  ENDIF
62749 
62750 C...FSI: Colour Reconnections - Seattle algorithm is default (S0)
62751  mstp(95)=6
62752 C...S1, S1-Pro: use S1
62753  IF (ituneb.EQ.301) mstp(95)=2
62754 C...S2, S2-Pro: use S2
62755  IF (ituneb.EQ.302) mstp(95)=4
62756 C...NOCR, NOCR-Pro, Perugia-NOCR: use no CR
62757  IF (itune.EQ.304.OR.itune.EQ.314.OR.itune.EQ.324.OR.
62758  & itune.EQ.334) mstp(95)=0
62759 C..."Old" and "Old"-Pro: use old CR
62760  IF (ituneb.EQ.305) mstp(95)=1
62761 C...Perugia 2010 and K use Paquis model
62762  IF (itune.EQ.327.OR.itune.EQ.328) mstp(95)=8
62763 
62764 C...FSI: CR strength and high-pT dampening, default is S0
62765  parp(77)=0d0
62766  IF (itune.LT.320.OR.itune.EQ.329.OR.itune.GE.335) THEN
62767  parp(78)=0.2d0
62768  IF (ituneb.EQ.301) parp(78)=0.35d0
62769  IF (ituneb.EQ.302) parp(78)=0.15d0
62770  IF (ituneb.EQ.304) parp(78)=0.0d0
62771  IF (ituneb.EQ.305) parp(78)=1.0d0
62772  IF (itune.EQ.329) parp(78)=0.17d0
62773  IF (itune.EQ.335) parp(78)=0.14d0
62774  IF (itune.EQ.336) parp(78)=0.17d0
62775  IF (itune.EQ.339) parp(78)=0.13d0
62776  ELSE
62777 C...Perugia tunes also use high-pT dampening : default is Perugia 0,*,6
62778  parp(78)=0.33
62779  parp(77)=0.9d0
62780  IF (itune.EQ.321) THEN
62781 C...HARD has HIGH amount of CR
62782  parp(78)=0.37d0
62783  parp(77)=0.4d0
62784  ELSEIF (itune.EQ.322) THEN
62785 C...SOFT has LOW amount of CR
62786  parp(78)=0.15d0
62787  parp(77)=0.5d0
62788  ELSEIF (itune.EQ.323) THEN
62789 C...Scaling variant appears to need slightly more than default
62790  parp(78)=0.35d0
62791  parp(77)=0.6d0
62792  ELSEIF (itune.EQ.324.OR.itune.EQ.334) THEN
62793 C...NOCR has no CR
62794  parp(78)=0d0
62795  parp(77)=0d0
62796  ELSEIF (itune.EQ.327) THEN
62797 C...2010
62798  parp(78)=0.035d0
62799  parp(77)=1d0
62800  ELSEIF (itune.EQ.328) THEN
62801 C...K
62802  parp(78)=0.033d0
62803  parp(77)=1d0
62804  ENDIF
62805  ENDIF
62806 
62807 C================
62808 C...Perugia 2011 tunes
62809 C...(written as modifications on top of Perugia 2010)
62810 C================
62811  IF (itunsv.GE.350.AND.itunsv.LE.359) THEN
62812  itune = itunsv
62813 C... Scale setting for matching applications.
62814 C... Switch to 5-flavor CMW LambdaQCD = 0.26 for all shower activity
62815 C... (equivalent to a 5-flavor MSbar LambdaQCD = 0.26/1.6 = 0.16)
62816  mstp(64)=2
62817  mstu(112)=5
62818 C... This sets the Lambda scale for ISR, IFSR, and FSR
62819  parp(61)=0.26d0
62820  parp(72)=0.26d0
62821  parj(81)=0.26d0
62822 C... This sets the Lambda scale for QCD hard interactions (important for the
62823 C... UE dijet cross sections. Here we still use an MSbar value, rather than
62824 C... a CMW one, in order not to hugely increase the UE jettiness. The CTEQ5L
62825 C... value corresponds to a Lambda5 of 0.146 for comparison, so quite close.)
62826  parp(1)=0.16d0
62827  paru(112)=0.16d0
62828 C... For matching applications, PARP(71) and PARP(67) = 1
62829  parp(67) = 1d0
62830  parp(71) = 1d0
62831 C... Primordial kT: only use 1 GeV
62832  mstp(91)=1
62833  parp(91)=1d0
62834 C... ADDITIONAL LESSONS WRT PERUGIA 2010
62835 C... ALICE taught us: need less baryon transport than SOFT
62836  mstp(89)=0
62837  parp(80)=0.015
62838 C... Small adjustments at LEP (slightly softer frag functions, esp for baryons)
62839  parj(21)=0.33
62840  parj(41)=0.35
62841  parj(42)=0.8
62842  parj(45)=0.55
62843 C... Increase Lambda/K ratio and other strange baryon yields
62844  parj(1)=0.087d0
62845  parj(3)=0.95d0
62846  parj(4)=0.043d0
62847  parj(6)=1.0d0
62848  parj(7)=1.0d0
62849 C... Also reduce total strangeness yield a bit, with higher K*/K
62850  parj(2)=0.19d0
62851  parj(12)=0.40d0
62852 C... Perugia 2011 default is sharp ISR, dipoles to BR radiating, pTmax individual
62853  mstp(70)=0
62854  mstp(72)=2
62855  parp(62)=1.5d0
62856 C... Holger taught us a smoother proton is preferred at high energies
62857 C... Just use a simple Gaussian
62858  mstp(82)=3
62859 C... Scaling of pt0 cutoff
62860  parp(90)=0.265
62861 C... Now retune pT0 to give right UE activity.
62862 C... Low CR strength indicated by LHC tunes
62863 C... (also keep low to get <pT>(Nch) a bit down for pT>100MeV samples)
62864  parp(78)=0.036d0
62865 C... Choose 7 TeV as new reference scale
62866  parp(89)=7000.0d0
62867  parp(82)=2.93d0
62868 C================
62869 C... P2011 Variations
62870 C================
62871  IF (itune.EQ.351) THEN
62872 C... radHi: high Lambda scale for ISR, IFSR, and FSR
62873 C... ( ca 10% more particles at LEP after retune )
62874  parp(61)=0.52d0
62875  parp(72)=0.52d0
62876  parj(81)=0.52d0
62877 C... Retune cutoff scales to compensate partially
62878 C... (though higher cutoff causes faster multiplicity drop at low energies)
62879  parp(62)=1.75d0
62880  parj(82)=1.75d0
62881  parp(82)=3.00d0
62882 C... Needs faster cutoff scaling than nominal variant for same <Nch> scaling
62883 C... (since more radiation otherwise generates faster mult growth)
62884  parp(90)=0.28
62885  ELSEIF (itune.EQ.352) THEN
62886 C... radLo: low Lambda scale for ISR, IFSR, and FSR
62887 C... ( ca 10% less particles at LEP after retune )
62888  parp(61)=0.13d0
62889  parp(72)=0.13d0
62890  parj(81)=0.13d0
62891 C... Retune cutoff scales to compensate partially
62892  parp(62)=1.00d0
62893  parj(82)=0.75d0
62894  parp(82)=2.95d0
62895 C... Needs slower cutoff scaling than nominal variant for same <Nch> scaling
62896 C... (since less radiation otherwise generates slower mult growth)
62897  parp(90)=0.24
62898  ELSEIF (itune.EQ.353) THEN
62899 C... mpiHi: high Lambda scale for MPI
62900  parp(1)=0.26d0
62901  paru(112)=0.26d0
62902  parp(82)=3.35d0
62903  parp(90)=0.26d0
62904  ELSEIF (itune.EQ.354) THEN
62905  mstp(95)=0
62906  parp(82)=3.05d0
62907  ELSEIF (itune.EQ.355) THEN
62908 C... LO**
62909  mstp(52)=2
62910  mstp(51)=20651
62911  parp(62)=1.5d0
62912 C... Compensate for higher <pT> with less CR
62913  parp(78)=0.034
62914  parp(82)=3.40d0
62915 C... Need slower energy scaling than CTEQ5L
62916  parp(90)=0.23d0
62917  ELSEIF (itune.EQ.356) THEN
62918 C... CTEQ6L1
62919  mstp(52)=2
62920  mstp(51)=10042
62921  parp(82)=2.65d0
62922 C... Need slower cutoff scaling than CTEQ5L
62923  parp(90)=0.22d0
62924  ELSEIF (itune.EQ.357) THEN
62925 C... T16
62926  parp(90)=0.16
62927  ELSEIF (itune.EQ.358) THEN
62928 C... T32
62929  parp(90)=0.32
62930  ELSEIF (itune.EQ.359) THEN
62931 C... Tevatron
62932  parp(89)=1800d0
62933  parp(90)=0.28
62934  parp(82)=2.10
62935  parp(78)=0.05
62936  ENDIF
62937 
62938 C================
62939 C...Schulz-Skands 2011 tunes
62940 C...(written as modifications on top of Perugia 0)
62941 C================
62942  ELSEIF (itunsv.GE.360.AND.itunsv.LE.365) THEN
62943  itune = itunsv
62944 
62945  IF (itune.EQ.360) THEN
62946  parp(78)=0.40d0
62947  parp(82)=2.19d0
62948  parp(83)=1.45d0
62949  parp(89)=1800.0d0
62950  parp(90)=0.27d0
62951  ELSEIF (itune.EQ.361) THEN
62952  parp(78)=0.20d0
62953  parp(82)=2.75d0
62954  parp(83)=1.73d0
62955  parp(89)=7000.0d0
62956  ELSEIF (itune.EQ.362) THEN
62957  parp(78)=0.31d0
62958  parp(82)=1.97d0
62959  parp(83)=1.98d0
62960  parp(89)=1960.0d0
62961  ELSEIF (itune.EQ.363) THEN
62962  parp(78)=0.35d0
62963  parp(82)=1.91d0
62964  parp(83)=2.02d0
62965  parp(89)=1800.0d0
62966  ELSEIF (itune.EQ.364) THEN
62967  parp(78)=0.33d0
62968  parp(82)=1.69d0
62969  parp(83)=1.92d0
62970  parp(89)=900.0d0
62971  ELSEIF (itune.EQ.365) THEN
62972  parp(78)=0.47d0
62973  parp(82)=1.61d0
62974  parp(83)=1.50d0
62975  parp(89)=630.0d0
62976  ENDIF
62977 
62978  ENDIF
62979 
62980 C...Switch off trial joinings
62981  mstp(96)=0
62982 
62983 C...S0 (300), S0A (303)
62984  IF (ituneb.EQ.300.OR.ituneb.EQ.303) THEN
62985  IF (m13.GE.1) THEN
62986  ch60='see P. Skands & D. Wicke, hep-ph/0703081'
62987  WRITE(m11,5030) ch60
62988  ch60='M. Sandhoff & P. Skands, in hep-ph/0604120'
62989  WRITE(m11,5030) ch60
62990  ch60='and T. Sjostrand & P. Skands, hep-ph/0408302'
62991  WRITE(m11,5030) ch60
62992  IF (itune.GE.310) THEN
62993  ch60='LEP parameters tuned by Professor,'//
62994  & ' hep-ph/0907.2973'
62995  WRITE(m11,5030) ch60
62996  ENDIF
62997  ENDIF
62998 
62999 C...S1 (301)
63000  ELSEIF(ituneb.EQ.301) THEN
63001  IF (m13.GE.1) THEN
63002  ch60='see M. Sandhoff & P. Skands, in hep-ph/0604120'
63003  WRITE(m11,5030) ch60
63004  ch60='and T. Sjostrand & P. Skands, hep-ph/0408302'
63005  WRITE(m11,5030) ch60
63006  IF (itune.GE.310) THEN
63007  ch60='LEP parameters tuned by Professor,'//
63008  & ' hep-ph/0907.2973'
63009  WRITE(m11,5030) ch60
63010  ENDIF
63011  ENDIF
63012 
63013 C...S2 (302)
63014  ELSEIF(ituneb.EQ.302) THEN
63015  IF (m13.GE.1) THEN
63016  ch60='see M. Sandhoff & P. Skands, in hep-ph/0604120'
63017  WRITE(m11,5030) ch60
63018  ch60='and T. Sjostrand & P. Skands, hep-ph/0408302'
63019  WRITE(m11,5030) ch60
63020  IF (itune.GE.310) THEN
63021  ch60='LEP parameters tuned by Professor,'//
63022  & ' hep-ph/0907.2973'
63023  WRITE(m11,5030) ch60
63024  ENDIF
63025  ENDIF
63026 
63027 C...NOCR (304)
63028  ELSEIF(ituneb.EQ.304) THEN
63029  IF (m13.GE.1) THEN
63030  ch60='"best try" without colour reconnections'
63031  WRITE(m11,5030) ch60
63032  ch60='see P. Skands & D. Wicke, hep-ph/0703081'
63033  WRITE(m11,5030) ch60
63034  ch60='and T. Sjostrand & P. Skands, hep-ph/0408302'
63035  WRITE(m11,5030) ch60
63036  IF (itune.GE.310) THEN
63037  ch60='LEP parameters tuned by Professor,'//
63038  & ' hep-ph/0907.2973'
63039  WRITE(m11,5030) ch60
63040  ENDIF
63041  ENDIF
63042 
63043 C..."Lo FSR" retune (305)
63044  ELSEIF(ituneb.EQ.305) THEN
63045  IF (m13.GE.1) THEN
63046  ch60='"Lo FSR retune" with primitive colour reconnections'
63047  WRITE(m11,5030) ch60
63048  ch60='see T. Sjostrand & P. Skands, hep-ph/0408302'
63049  WRITE(m11,5030) ch60
63050  IF (itune.GE.310) THEN
63051  ch60='LEP parameters tuned by Professor,'//
63052  & ' hep-ph/0907.2973'
63053  WRITE(m11,5030) ch60
63054  ENDIF
63055  ENDIF
63056 
63057 C...Perugia Tunes (320-328 and 334)
63058  ELSEIF((itune.GE.320.AND.itune.LE.328).OR.itune.EQ.334) THEN
63059  IF (m13.GE.1) THEN
63060  ch60='Tuned by P. Skands, hep-ph/1005.3457'
63061  WRITE(m11,5030) ch60
63062  ch60='Physics Model: '//
63063  & 'T. Sjostrand & P. Skands, hep-ph/0408302'
63064  WRITE(m11,5030) ch60
63065  IF (itune.LE.326) THEN
63066  ch60='CR by M. Sandhoff & P. Skands, in hep-ph/0604120'
63067  WRITE(m11,5030) ch60
63068  ch60='LEP parameters tuned by Professor, hep-ph/0907.2973'
63069  WRITE(m11,5030) ch60
63070  ENDIF
63071  IF (itune.EQ.325) THEN
63072  ch70='NB! This tune requires MRST LO* pdfs to be '//
63073  & 'externally linked'
63074  WRITE(m11,5035) ch70
63075  ELSEIF (itune.EQ.326) THEN
63076  ch70='NB! This tune requires CTEQ6L1 pdfs to be '//
63077  & 'externally linked'
63078  WRITE(m11,5035) ch70
63079  ELSEIF (itune.EQ.321) THEN
63080  ch60='NB! This tune has MORE ISR & FSR / LESS UE & BR'
63081  WRITE(m11,5030) ch60
63082  ELSEIF (itune.EQ.322) THEN
63083  ch60='NB! This tune has LESS ISR & FSR / MORE UE & BR'
63084  WRITE(m11,5030) ch60
63085  ENDIF
63086  ENDIF
63087 
63088 C...Professor-pTO (329)
63089  ELSEIF(itune.EQ.329.OR.itune.EQ.335.OR.itune.EQ.336.OR.
63090  & itune.EQ.339) THEN
63091  IF (m13.GE.1) THEN
63092  ch60='Tuned by Professor, hep-ph/0907.2973'
63093  WRITE(m11,5030) ch60
63094  ch60='Physics Model: '//
63095  & 'T. Sjostrand & P. Skands, hep-ph/0408302'
63096  WRITE(m11,5030) ch60
63097  ch60='CR by M. Sandhoff & P. Skands, in hep-ph/0604120'
63098  WRITE(m11,5030) ch60
63099  ENDIF
63100 
63101 C...Perugia 2011 Tunes (350-359)
63102  ELSEIF(itune.GE.350.AND.itune.LE.359) THEN
63103  IF (m13.GE.1) THEN
63104  ch60='Tuned by P. Skands, hep-ph/1005.3457'
63105  WRITE(m11,5030) ch60
63106  ch60='Physics Model: '//
63107  & 'T. Sjostrand & P. Skands, hep-ph/0408302'
63108  WRITE(m11,5030) ch60
63109  ch60='CR by M. Sandhoff & P. Skands, in hep-ph/0604120'
63110  WRITE(m11,5030) ch60
63111  IF (itune.EQ.355) THEN
63112  ch70='NB! This tune requires MRST LO** pdfs to be '//
63113  & 'externally linked'
63114  WRITE(m11,5035) ch70
63115  ELSEIF (itune.EQ.356) THEN
63116  ch70='NB! This tune requires CTEQ6L1 pdfs to be '//
63117  & 'externally linked'
63118  WRITE(m11,5035) ch70
63119  ENDIF
63120  ENDIF
63121 
63122 C...Schulz-Skands Tunes (360-365)
63123  ELSEIF(itune.GE.360.AND.itune.LE.365) THEN
63124  IF (m13.GE.1) THEN
63125  ch60='Tuned by H. Schulz & P. Skands, MCNET-11-07'
63126  WRITE(m11,5030) ch60
63127  ch60='Based on Perugia 0, hep-ph/1005.3457'
63128  WRITE(m11,5030) ch60
63129  ch60='Physics Model: '//
63130  & 'T. Sjostrand & P. Skands, hep-ph/0408302'
63131  WRITE(m11,5030) ch60
63132  ch60='CR by M. Sandhoff & P. Skands, in hep-ph/0604120'
63133  WRITE(m11,5030) ch60
63134  ENDIF
63135 
63136  ENDIF
63137 
63138 C...Output
63139  IF (m13.GE.1) THEN
63140  WRITE(m11,5030) ' '
63141  WRITE(m11,5040) 51, mstp(51), chmstp(51)
63142  WRITE(m11,5040) 52, mstp(52), chmstp(52)
63143  IF (mstp(33).GE.10) THEN
63144  WRITE(m11,5050) 32, parp(32), chparp(32)
63145  ENDIF
63146  WRITE(m11,5040) 3, mstp( 3), chmstp( 3)
63147  IF (mstp(3).EQ.1) THEN
63148  WRITE(m11,6100) 112, mstu(112), chmstu(112)
63149  WRITE(m11,6110) 112, paru(112), chparu(112)
63150  WRITE(m11,5050) 1, parp(1) , chparp( 1)
63151  ENDIF
63152  WRITE(m11,5060) 81, parj(81), chparj(81)
63153  IF (mstp(3).EQ.1)
63154  & WRITE(m11,5050) 72, parp(72) , chparp( 72)
63155  IF (mstp(3).EQ.1) THEN
63156  WRITE(m11,5050) 61, parp(61) , chparp( 61)
63157  ENDIF
63158  WRITE(m11,5040) 64, mstp(64), chmstp(64)
63159  WRITE(m11,5050) 64, parp(64), chparp(64)
63160  WRITE(m11,5040) 67, mstp(67), chmstp(67)
63161  WRITE(m11,5040) 68, mstp(68), chmstp(68)
63162  ch60='(Note: MSTP(68) is not explicitly (re-)set by PYTUNE)'
63163  WRITE(m11,5030) ch60
63164  WRITE(m11,5050) 67, parp(67), chparp(67)
63165  WRITE(m11,5040) 72, mstp(72), chmstp(72)
63166  WRITE(m11,5050) 71, parp(71), chparp(71)
63167  WRITE(m11,5040) 70, mstp(70), chmstp(70)
63168  IF (mstp(70).EQ.0) THEN
63169  WRITE(m11,5050) 62, parp(62), chparp(62)
63170  ELSEIF (mstp(70).EQ.1) THEN
63171  WRITE(m11,5050) 81, parp(81), chparp(62)
63172  ch60='(Note: PARP(81) replaces PARP(62).)'
63173  WRITE(m11,5030) ch60
63174  ENDIF
63175  WRITE(m11,5060) 82, parj(82), chparj(82)
63176  WRITE(m11,5040) 33, mstp(33), chmstp(33)
63177  WRITE(m11,5040) 81, mstp(81), chmstp(81)
63178  WRITE(m11,5050) 82, parp(82), chparp(82)
63179  IF (mstp(70).EQ.2) THEN
63180  ch60='(Note: PARP(82) replaces PARP(62).)'
63181  WRITE(m11,5030) ch60
63182  ENDIF
63183  WRITE(m11,5050) 89, parp(89), chparp(89)
63184  WRITE(m11,5050) 90, parp(90), chparp(90)
63185  WRITE(m11,5040) 82, mstp(82), chmstp(82)
63186  IF (mstp(82).EQ.5) THEN
63187  WRITE(m11,5050) 83, parp(83), chparp(83)
63188  ELSEIF (mstp(82).EQ.4) THEN
63189  WRITE(m11,5050) 83, parp(83), chparp(83)
63190  WRITE(m11,5050) 84, parp(84), chparp(84)
63191  ENDIF
63192  WRITE(m11,5040) 88, mstp(88), chmstp(88)
63193  WRITE(m11,5040) 89, mstp(89), chmstp(89)
63194  WRITE(m11,5050) 79, parp(79), chparp(79)
63195  WRITE(m11,5050) 80, parp(80), chparp(80)
63196  WRITE(m11,5040) 91, mstp(91), chmstp(91)
63197  WRITE(m11,5050) 91, parp(91), chparp(91)
63198  WRITE(m11,5050) 93, parp(93), chparp(93)
63199  WRITE(m11,5040) 95, mstp(95), chmstp(95)
63200  IF (mstp(95).GE.1) THEN
63201  WRITE(m11,5050) 78, parp(78), chparp(78)
63202  IF (mstp(95).GE.2) WRITE(m11,5050) 77, parp(77), chparp(77)
63203  ENDIF
63204 
63205  ENDIF
63206 
63207 C=======================================================================
63208 C...ATLAS-CSC 11-parameter tune (By A. Moraes)
63209  ELSEIF (itune.EQ.306) THEN
63210  IF (m13.GE.1) WRITE(m11,5010) itune, chname
63211  IF (mstp(181).LE.5.OR.(mstp(181).EQ.6.AND.mstp(182).LE.405))THEN
63212  CALL pyerrm(9,'(PYTUNE:) linked PYTHIA version incompatible'//
63213  & ' with tune.')
63214  ENDIF
63215 
63216 C...PDFs
63217  mstp(52)=2
63218  mstp(54)=2
63219  mstp(51)=10042
63220  mstp(53)=10042
63221 C...ISR
63222 C PARP(64)=1D0
63223 C...UE on, new model.
63224  mstp(81)=21
63225 C...Energy scaling
63226  parp(89)=1800d0
63227  parp(90)=0.22d0
63228 C...Switch off trial joinings
63229  mstp(96)=0
63230 C...Primordial kT cutoff
63231 
63232  IF (m13.GE.1) THEN
63233  ch60='see presentations by A. Moraes (ATLAS),'
63234  WRITE(m11,5030) ch60
63235  ch60='and T. Sjostrand & P. Skands, hep-ph/0408302'
63236  WRITE(m11,5030) ch60
63237  WRITE(m11,5030) ' '
63238  ch70='NB! This tune requires CTEQ6.1 pdfs to be '//
63239  & 'externally linked'
63240  WRITE(m11,5035) ch70
63241  ENDIF
63242 C...Smooth ISR, low FSR
63243  mstp(70)=2
63244  mstp(72)=0
63245 C...pT0
63246  parp(82)=1.9d0
63247 C...Transverse density profile.
63248  mstp(82)=4
63249  parp(83)=0.3d0
63250  parp(84)=0.5d0
63251 C...ISR & FSR in interactions after the first (default)
63252  mstp(84)=1
63253  mstp(85)=1
63254 C...No double-counting (default)
63255  mstp(86)=2
63256 C...Companion quark parent gluon (1-x) power
63257  mstp(87)=4
63258 C...Primordial kT compensation along chaings (default = 0 : uniform)
63259  mstp(90)=1
63260 C...Colour Reconnections
63261  mstp(95)=1
63262  parp(78)=0.2d0
63263 C...Lambda_FSR scale.
63264  parj(81)=0.23d0
63265 C...Rap order, Valence qq, qq x enhc, BR-g-BR supp
63266  mstp(89)=1
63267  mstp(88)=0
63268 C PARP(79)=2D0
63269  parp(80)=0.01d0
63270 C...Peterson charm frag, and c and b hadr parameters
63271  mstj(11)=3
63272  parj(54)=-0.07
63273  parj(55)=-0.006
63274 C... Output
63275  IF (m13.GE.1) THEN
63276  WRITE(m11,5030) ' '
63277  WRITE(m11,5040) 51, mstp(51), chmstp(51)
63278  WRITE(m11,5040) 52, mstp(52), chmstp(52)
63279  WRITE(m11,5040) 3, mstp( 3), chmstp( 3)
63280  WRITE(m11,5050) 64, parp(64), chparp(64)
63281  WRITE(m11,5040) 68, mstp(68), chmstp(68)
63282  ch60='(Note: MSTP(68) is not explicitly (re-)set by PYTUNE)'
63283  WRITE(m11,5030) ch60
63284  WRITE(m11,5040) 70, mstp(70), chmstp(70)
63285  WRITE(m11,5040) 72, mstp(72), chmstp(72)
63286  WRITE(m11,5050) 71, parp(71), chparp(71)
63287  WRITE(m11,5060) 81, parj(81), chparj(81)
63288  ch60='(Note: PARJ(81) changed from 0.14! See update notes)'
63289  WRITE(m11,5030) ch60
63290  WRITE(m11,5040) 33, mstp(33), chmstp(33)
63291  WRITE(m11,5040) 81, mstp(81), chmstp(81)
63292  WRITE(m11,5050) 82, parp(82), chparp(82)
63293  WRITE(m11,5050) 89, parp(89), chparp(89)
63294  WRITE(m11,5050) 90, parp(90), chparp(90)
63295  WRITE(m11,5040) 82, mstp(82), chmstp(82)
63296  WRITE(m11,5050) 83, parp(83), chparp(83)
63297  WRITE(m11,5050) 84, parp(84), chparp(84)
63298  WRITE(m11,5040) 88, mstp(88), chmstp(88)
63299  WRITE(m11,5040) 89, mstp(89), chmstp(89)
63300  WRITE(m11,5040) 90, mstp(90), chmstp(90)
63301  WRITE(m11,5050) 79, parp(79), chparp(79)
63302  WRITE(m11,5050) 80, parp(80), chparp(80)
63303  WRITE(m11,5050) 93, parp(93), chparp(93)
63304  WRITE(m11,5040) 95, mstp(95), chmstp(95)
63305  WRITE(m11,5050) 78, parp(78), chparp(78)
63306 
63307  ENDIF
63308 
63309 C=======================================================================
63310 C...Tunes A, AW, BW, DW, DWT, QW, D6, D6T (by R.D. Field, CDF)
63311 C...(100-105,108-109), ATLAS-DC2 Tune (by A. Moraes, ATLAS) (106)
63312 C...A-Pro, DW-Pro, etc (100-119), and Pro-Q2O (129)
63313  ELSEIF ((itune.GE.100.AND.itune.LE.106).OR.itune.EQ.108.OR.
63314  & itune.EQ.109.OR.(itune.GE.110.AND.itune.LE.116).OR.
63315  & itune.EQ.118.OR.itune.EQ.119.OR.itune.EQ.129) THEN
63316  IF (m13.GE.1.AND.itune.NE.106.AND.itune.NE.129) THEN
63317  WRITE(m11,5010) itune, chname
63318  ch60='see R.D. Field, in hep-ph/0610012'
63319  WRITE(m11,5030) ch60
63320  ch60='and T. Sjostrand & M. v. Zijl, PRD36(1987)2019'
63321  WRITE(m11,5030) ch60
63322  IF (itune.GE.110.AND.itune.LE.119) THEN
63323  ch60='LEP parameters tuned by Professor, hep-ph/0907.2973'
63324  WRITE(m11,5030) ch60
63325  ENDIF
63326  ELSEIF (m13.GE.1.AND.itune.EQ.129) THEN
63327  WRITE(m11,5010) itune, chname
63328  ch60='Tuned by Professor, hep-ph/0907.2973'
63329  WRITE(m11,5030) ch60
63330  ch60='Physics Model: '//
63331  & 'T. Sjostrand & M. v. Zijl, PRD36(1987)2019'
63332  WRITE(m11,5030) ch60
63333  ENDIF
63334 
63335 C...Make sure we start from old default fragmentation parameters
63336  parj(81) = 0.29
63337  parj(82) = 1.0
63338 
63339 C...Use Professor's LEP pars if ITUNE >= 110
63340 C...(i.e., for A-Pro, DW-Pro etc)
63341  IF (itune.LT.110) THEN
63342 C...# Old defaults
63343  mstj(11) = 4
63344  parj(1) = 0.1
63345  parj(2) = 0.3
63346  parj(3) = 0.40
63347  parj(4) = 0.05
63348  parj(11) = 0.5
63349  parj(12) = 0.6
63350  parj(21) = 0.36
63351  parj(41) = 0.30
63352  parj(42) = 0.58
63353  parj(46) = 1.0
63354  parj(81) = 0.29
63355  parj(82) = 1.0
63356  ELSE
63357 C...# Tuned flavour parameters:
63358  parj(1) = 0.073
63359  parj(2) = 0.2
63360  parj(3) = 0.94
63361  parj(4) = 0.032
63362  parj(11) = 0.31
63363  parj(12) = 0.4
63364  parj(13) = 0.54
63365  parj(25) = 0.63
63366  parj(26) = 0.12
63367 C...# Switch on Bowler:
63368  mstj(11) = 5
63369 C...# Fragmentation
63370  parj(21) = 0.325
63371  parj(41) = 0.5
63372  parj(42) = 0.6
63373  parj(47) = 0.67
63374  parj(81) = 0.29
63375  parj(82) = 1.65
63376  ENDIF
63377 
63378 C...Remove middle digit now for Professor variants, since identical pars
63379  ituneb=itune
63380  IF (itune.GE.110.AND.itune.LE.119) THEN
63381  ituneb=(itune/100)*100+mod(itune,10)
63382  ENDIF
63383 
63384 C...Multiple interactions on, old framework
63385  mstp(81)=1
63386 C...Fast IR cutoff energy scaling by default
63387  parp(89)=1800d0
63388  parp(90)=0.25d0
63389 C...Default CTEQ5L (internal), except for QW: CTEQ61 (external)
63390  mstp(51)=7
63391  mstp(52)=1
63392  IF (ituneb.EQ.105) THEN
63393  mstp(51)=10150
63394  mstp(52)=2
63395  ELSEIF(ituneb.EQ.108.OR.ituneb.EQ.109) THEN
63396  mstp(52)=2
63397  mstp(54)=2
63398  mstp(51)=10042
63399  mstp(53)=10042
63400  ENDIF
63401 C...Double Gaussian matter distribution.
63402  mstp(82)=4
63403  parp(83)=0.5d0
63404  parp(84)=0.4d0
63405 C...FSR activity.
63406  parp(71)=4d0
63407 C...Fragmentation functions and c and b parameters
63408 C...(only if not using Professor)
63409  IF (itune.LE.109) THEN
63410  mstj(11)=4
63411  parj(54)=-0.05
63412  parj(55)=-0.005
63413  ENDIF
63414 
63415 C...Tune A and AW
63416  IF(ituneb.EQ.100.OR.ituneb.EQ.101) THEN
63417 C...pT0.
63418  parp(82)=2.0d0
63419 c...String drawing almost completely minimizes string length.
63420  parp(85)=0.9d0
63421  parp(86)=0.95d0
63422 C...ISR cutoff, muR scale factor, and phase space size
63423  parp(62)=1d0
63424  parp(64)=1d0
63425  parp(67)=4d0
63426 C...Intrinsic kT, size, and max
63427  mstp(91)=1
63428  parp(91)=1d0
63429  parp(93)=5d0
63430 C...AW : higher ISR IR cutoff, but also larger alphaS, more intrinsic kT
63431  IF (ituneb.EQ.101) THEN
63432  parp(62)=1.25d0
63433  parp(64)=0.2d0
63434  parp(91)=2.1d0
63435  parp(92)=15.0d0
63436  ENDIF
63437 
63438 C...Tune BW (larger alphaS, more intrinsic kT. Smaller ISR phase space)
63439  ELSEIF (ituneb.EQ.102) THEN
63440 C...pT0.
63441  parp(82)=1.9d0
63442 c...String drawing completely minimizes string length.
63443  parp(85)=1.0d0
63444  parp(86)=1.0d0
63445 C...ISR cutoff, muR scale factor, and phase space size
63446  parp(62)=1.25d0
63447  parp(64)=0.2d0
63448  parp(67)=1d0
63449 C...Intrinsic kT, size, and max
63450  mstp(91)=1
63451  parp(91)=2.1d0
63452  parp(93)=15d0
63453 
63454 C...Tune DW
63455  ELSEIF (ituneb.EQ.103) THEN
63456 C...pT0.
63457  parp(82)=1.9d0
63458 c...String drawing completely minimizes string length.
63459  parp(85)=1.0d0
63460  parp(86)=1.0d0
63461 C...ISR cutoff, muR scale factor, and phase space size
63462  parp(62)=1.25d0
63463  parp(64)=0.2d0
63464  parp(67)=2.5d0
63465 C...Intrinsic kT, size, and max
63466  mstp(91)=1
63467  parp(91)=2.1d0
63468  parp(93)=15d0
63469 
63470 C...Tune DWT
63471  ELSEIF (ituneb.EQ.104) THEN
63472 C...pT0.
63473  parp(82)=1.9409d0
63474 C...Run II ref scale and slow scaling
63475  parp(89)=1960d0
63476  parp(90)=0.16d0
63477 c...String drawing completely minimizes string length.
63478  parp(85)=1.0d0
63479  parp(86)=1.0d0
63480 C...ISR cutoff, muR scale factor, and phase space size
63481  parp(62)=1.25d0
63482  parp(64)=0.2d0
63483  parp(67)=2.5d0
63484 C...Intrinsic kT, size, and max
63485  mstp(91)=1
63486  parp(91)=2.1d0
63487  parp(93)=15d0
63488 
63489 C...Tune QW
63490  ELSEIF(ituneb.EQ.105) THEN
63491  IF (m13.GE.1) THEN
63492  WRITE(m11,5030) ' '
63493  ch70='NB! This tune requires CTEQ6.1 pdfs to be '//
63494  & 'externally linked'
63495  WRITE(m11,5035) ch70
63496  ENDIF
63497 C...pT0.
63498  parp(82)=1.1d0
63499 c...String drawing completely minimizes string length.
63500  parp(85)=1.0d0
63501  parp(86)=1.0d0
63502 C...ISR cutoff, muR scale factor, and phase space size
63503  parp(62)=1.25d0
63504  parp(64)=0.2d0
63505  parp(67)=2.5d0
63506 C...Intrinsic kT, size, and max
63507  mstp(91)=1
63508  parp(91)=2.1d0
63509  parp(93)=15d0
63510 
63511 C...Tune D6 and D6T
63512  ELSEIF(ituneb.EQ.108.OR.ituneb.EQ.109) THEN
63513  IF (m13.GE.1) THEN
63514  WRITE(m11,5030) ' '
63515  ch70='NB! This tune requires CTEQ6L pdfs to be '//
63516  & 'externally linked'
63517  WRITE(m11,5035) ch70
63518  ENDIF
63519 C...The "Rick" proton, double gauss with 0.5/0.4
63520  mstp(82)=4
63521  parp(83)=0.5d0
63522  parp(84)=0.4d0
63523 c...String drawing completely minimizes string length.
63524  parp(85)=1.0d0
63525  parp(86)=1.0d0
63526  IF (ituneb.EQ.108) THEN
63527 C...D6: pT0, Run I ref scale, and fast energy scaling
63528  parp(82)=1.8d0
63529  parp(89)=1800d0
63530  parp(90)=0.25d0
63531  ELSE
63532 C...D6T: pT0, Run II ref scale, and slow energy scaling
63533  parp(82)=1.8387d0
63534  parp(89)=1960d0
63535  parp(90)=0.16d0
63536  ENDIF
63537 C...ISR cutoff, muR scale factor, and phase space size
63538  parp(62)=1.25d0
63539  parp(64)=0.2d0
63540  parp(67)=2.5d0
63541 C...Intrinsic kT, size, and max
63542  mstp(91)=1
63543  parp(91)=2.1d0
63544  parp(93)=15d0
63545 
63546 C...Old ATLAS-DC2 5-parameter tune
63547  ELSEIF(ituneb.EQ.106) THEN
63548  IF (m13.GE.1) THEN
63549  WRITE(m11,5010) itune, chname
63550  ch60='see A. Moraes et al., SN-ATLAS-2006-057,'
63551  WRITE(m11,5030) ch60
63552  ch60=' R. Field in hep-ph/0610012,'
63553  WRITE(m11,5030) ch60
63554  ch60='and T. Sjostrand & M. v. Zijl, PRD36(1987)2019'
63555  WRITE(m11,5030) ch60
63556  ENDIF
63557 C... pT0.
63558  parp(82)=1.8d0
63559 C... Different ref and rescaling pacee
63560  parp(89)=1000d0
63561  parp(90)=0.16d0
63562 C... Parameters of mass distribution
63563  parp(83)=0.5d0
63564  parp(84)=0.5d0
63565 C... Old default string drawing
63566  parp(85)=0.33d0
63567  parp(86)=0.66d0
63568 C... ISR, phase space equivalent to Tune B
63569  parp(62)=1d0
63570  parp(64)=1d0
63571  parp(67)=1d0
63572 C... FSR
63573  parp(71)=4d0
63574 C... Intrinsic kT
63575  mstp(91)=1
63576  parp(91)=1d0
63577  parp(93)=5d0
63578 
63579 C...Professor's Pro-Q2O Tune
63580  ELSEIF(itune.EQ.129) THEN
63581  parp(62)=2.9
63582  parp(64)=0.14
63583  parp(67)=2.65
63584  parp(82)=1.9
63585  parp(83)=0.83
63586  parp(84)=0.6
63587  parp(85)=0.86
63588  parp(86)=0.93
63589  parp(89)=1800d0
63590  parp(90)=0.22
63591  mstp(91)=1
63592  parp(91)=2.1
63593  parp(93)=5.0
63594 
63595  ENDIF
63596 
63597 C... Output
63598  IF (m13.GE.1) THEN
63599  WRITE(m11,5030) ' '
63600  WRITE(m11,5040) 51, mstp(51), chmstp(51)
63601  WRITE(m11,5040) 52, mstp(52), chmstp(52)
63602  WRITE(m11,5040) 3, mstp( 3), chmstp( 3)
63603  WRITE(m11,5050) 62, parp(62), chparp(62)
63604  WRITE(m11,5050) 64, parp(64), chparp(64)
63605  WRITE(m11,5050) 67, parp(67), chparp(67)
63606  WRITE(m11,5040) 68, mstp(68), chmstp(68)
63607  ch60='(Note: MSTP(68) is not explicitly (re-)set by PYTUNE)'
63608  WRITE(m11,5030) ch60
63609  WRITE(m11,5050) 71, parp(71), chparp(71)
63610  WRITE(m11,5060) 81, parj(81), chparj(81)
63611  WRITE(m11,5060) 82, parj(82), chparj(82)
63612  WRITE(m11,5040) 33, mstp(33), chmstp(33)
63613  WRITE(m11,5040) 81, mstp(81), chmstp(81)
63614  WRITE(m11,5050) 82, parp(82), chparp(82)
63615  WRITE(m11,5050) 89, parp(89), chparp(89)
63616  WRITE(m11,5050) 90, parp(90), chparp(90)
63617  WRITE(m11,5040) 82, mstp(82), chmstp(82)
63618  WRITE(m11,5050) 83, parp(83), chparp(83)
63619  WRITE(m11,5050) 84, parp(84), chparp(84)
63620  WRITE(m11,5050) 85, parp(85), chparp(85)
63621  WRITE(m11,5050) 86, parp(86), chparp(86)
63622  WRITE(m11,5040) 91, mstp(91), chmstp(91)
63623  WRITE(m11,5050) 91, parp(91), chparp(91)
63624  WRITE(m11,5050) 93, parp(93), chparp(93)
63625 
63626  ENDIF
63627 
63628 C=======================================================================
63629 C... ACR, tune A with new CR (107)
63630  ELSEIF(itune.EQ.107.OR.itune.EQ.117) THEN
63631  IF (m13.GE.1) THEN
63632  WRITE(m11,5010) itune, chname
63633  ch60='Tune A modified with new colour reconnections'
63634  WRITE(m11,5030) ch60
63635  ch60='PARP(85)=0D0 and amount of CR is regulated by PARP(78)'
63636  WRITE(m11,5030) ch60
63637  ch60='see P. Skands & D. Wicke, hep-ph/0703081,'
63638  WRITE(m11,5030) ch60
63639  ch60=' R. Field, in hep-ph/0610012 (Tune A),'
63640  WRITE(m11,5030) ch60
63641  ch60='and T. Sjostrand & M. v. Zijl, PRD36(1987)2019'
63642  WRITE(m11,5030) ch60
63643  IF (itune.EQ.117) THEN
63644  ch60='LEP parameters tuned by Professor, hep-ph/0907.2973'
63645  WRITE(m11,5030) ch60
63646  ENDIF
63647  ENDIF
63648  IF (mstp(181).LE.5.OR.(mstp(181).EQ.6.AND.mstp(182).LE.406))THEN
63649  CALL pyerrm(9,'(PYTUNE:) linked PYTHIA version incompatible'//
63650  & ' with tune. Using defaults.')
63651  goto 100
63652  ENDIF
63653 
63654 C...Make sure we start from old default fragmentation parameters
63655  parj(81) = 0.29
63656  parj(82) = 1.0
63657 
63658 C...Use Professor's LEP pars if ITUNE >= 110
63659 C...(i.e., for A-Pro, DW-Pro etc)
63660  IF (itune.LT.110) THEN
63661 C...# Old defaults
63662  mstj(11) = 4
63663 C...# Old default flavour parameters
63664  parj(21) = 0.36
63665  parj(41) = 0.30
63666  parj(42) = 0.58
63667  parj(46) = 1.0
63668  parj(82) = 1.0
63669  ELSE
63670 C...# Tuned flavour parameters:
63671  parj(1) = 0.073
63672  parj(2) = 0.2
63673  parj(3) = 0.94
63674  parj(4) = 0.032
63675  parj(11) = 0.31
63676  parj(12) = 0.4
63677  parj(13) = 0.54
63678  parj(25) = 0.63
63679  parj(26) = 0.12
63680 C...# Switch on Bowler:
63681  mstj(11) = 5
63682 C...# Fragmentation
63683  parj(21) = 0.325
63684  parj(41) = 0.5
63685  parj(42) = 0.6
63686  parj(47) = 0.67
63687  parj(81) = 0.29
63688  parj(82) = 1.65
63689  ENDIF
63690 
63691  mstp(81)=1
63692  parp(89)=1800d0
63693  parp(90)=0.25d0
63694  mstp(82)=4
63695  parp(83)=0.5d0
63696  parp(84)=0.4d0
63697  mstp(51)=7
63698  mstp(52)=1
63699  parp(71)=4d0
63700  parp(82)=2.0d0
63701  parp(85)=0.0d0
63702  parp(86)=0.66d0
63703  parp(62)=1d0
63704  parp(64)=1d0
63705  parp(67)=4d0
63706  mstp(91)=1
63707  parp(91)=1d0
63708  parp(93)=5d0
63709  mstp(95)=6
63710 C...P78 changed from 0.12 to 0.09 in 6.4.19 to improve <pT>(Nch)
63711  parp(78)=0.09d0
63712 C...Frag functions (only if not using Professor)
63713  IF (itune.LE.109) THEN
63714  mstj(11)=4
63715  parj(54)=-0.05
63716  parj(55)=-0.005
63717  ENDIF
63718 
63719 C...Output
63720  IF (m13.GE.1) THEN
63721  WRITE(m11,5030) ' '
63722  WRITE(m11,5040) 51, mstp(51), chmstp(51)
63723  WRITE(m11,5040) 52, mstp(52), chmstp(52)
63724  WRITE(m11,5040) 3, mstp( 3), chmstp( 3)
63725  WRITE(m11,5050) 62, parp(62), chparp(62)
63726  WRITE(m11,5050) 64, parp(64), chparp(64)
63727  WRITE(m11,5050) 67, parp(67), chparp(67)
63728  WRITE(m11,5040) 68, mstp(68), chmstp(68)
63729  ch60='(Note: MSTP(68) is not explicitly (re-)set by PYTUNE)'
63730  WRITE(m11,5030) ch60
63731  WRITE(m11,5050) 71, parp(71), chparp(71)
63732  WRITE(m11,5060) 81, parj(81), chparj(81)
63733  WRITE(m11,5060) 82, parj(82), chparj(82)
63734  WRITE(m11,5040) 33, mstp(33), chmstp(33)
63735  WRITE(m11,5040) 81, mstp(81), chmstp(81)
63736  WRITE(m11,5050) 82, parp(82), chparp(82)
63737  WRITE(m11,5050) 89, parp(89), chparp(89)
63738  WRITE(m11,5050) 90, parp(90), chparp(90)
63739  WRITE(m11,5040) 82, mstp(82), chmstp(82)
63740  WRITE(m11,5050) 83, parp(83), chparp(83)
63741  WRITE(m11,5050) 84, parp(84), chparp(84)
63742  WRITE(m11,5050) 85, parp(85), chparp(85)
63743  WRITE(m11,5050) 86, parp(86), chparp(86)
63744  WRITE(m11,5040) 91, mstp(91), chmstp(91)
63745  WRITE(m11,5050) 91, parp(91), chparp(91)
63746  WRITE(m11,5050) 93, parp(93), chparp(93)
63747  WRITE(m11,5040) 95, mstp(95), chmstp(95)
63748  WRITE(m11,5050) 78, parp(78), chparp(78)
63749 
63750  ENDIF
63751 
63752 C=======================================================================
63753 C...Intermediate model. Rap tune
63754 C...(retuned to post-6.406 IR factorization)
63755  ELSEIF(itune.EQ.200) THEN
63756  IF (m13.GE.1) THEN
63757  WRITE(m11,5010) itune, chname
63758  ch60='see T. Sjostrand & P. Skands, JHEP03(2004)053'
63759  WRITE(m11,5030) ch60
63760  ENDIF
63761  IF (mstp(181).LE.5.OR.(mstp(181).EQ.6.AND.mstp(182).LE.405))THEN
63762  CALL pyerrm(9,'(PYTUNE:) linked PYTHIA version incompatible'//
63763  & ' with tune.')
63764  ENDIF
63765 C...PDF
63766  mstp(51)=7
63767  mstp(52)=1
63768 C...ISR
63769  parp(62)=1d0
63770  parp(64)=1d0
63771  parp(67)=4d0
63772 C...FSR
63773  parp(71)=4d0
63774  parj(81)=0.29d0
63775 C...UE
63776  mstp(81)=11
63777  parp(82)=2.25d0
63778  parp(89)=1800d0
63779  parp(90)=0.25d0
63780 C... ExpOfPow(1.8) overlap profile
63781  mstp(82)=5
63782  parp(83)=1.8d0
63783 C... Valence qq
63784  mstp(88)=0
63785 C... Rap Tune
63786  mstp(89)=1
63787 C... Default diquark, BR-g-BR supp
63788  parp(79)=2d0
63789  parp(80)=0.01d0
63790 C... Final state reconnect.
63791  mstp(95)=1
63792  parp(78)=0.55d0
63793 C...Fragmentation functions and c and b parameters
63794  mstj(11)=4
63795  parj(54)=-0.05
63796  parj(55)=-0.005
63797 C... Output
63798  IF (m13.GE.1) THEN
63799  WRITE(m11,5030) ' '
63800  WRITE(m11,5040) 51, mstp(51), chmstp(51)
63801  WRITE(m11,5040) 52, mstp(52), chmstp(52)
63802  WRITE(m11,5040) 3, mstp( 3), chmstp( 3)
63803  WRITE(m11,5050) 62, parp(62), chparp(62)
63804  WRITE(m11,5050) 64, parp(64), chparp(64)
63805  WRITE(m11,5050) 67, parp(67), chparp(67)
63806  WRITE(m11,5040) 68, mstp(68), chmstp(68)
63807  ch60='(Note: MSTP(68) is not explicitly (re-)set by PYTUNE)'
63808  WRITE(m11,5030) ch60
63809  WRITE(m11,5050) 71, parp(71), chparp(71)
63810  WRITE(m11,5060) 81, parj(81), chparj(81)
63811  WRITE(m11,5040) 33, mstp(33), chmstp(33)
63812  WRITE(m11,5040) 81, mstp(81), chmstp(81)
63813  WRITE(m11,5050) 82, parp(82), chparp(82)
63814  WRITE(m11,5050) 89, parp(89), chparp(89)
63815  WRITE(m11,5050) 90, parp(90), chparp(90)
63816  WRITE(m11,5040) 82, mstp(82), chmstp(82)
63817  WRITE(m11,5050) 83, parp(83), chparp(83)
63818  WRITE(m11,5040) 88, mstp(88), chmstp(88)
63819  WRITE(m11,5040) 89, mstp(89), chmstp(89)
63820  WRITE(m11,5050) 79, parp(79), chparp(79)
63821  WRITE(m11,5050) 80, parp(80), chparp(80)
63822  WRITE(m11,5050) 93, parp(93), chparp(93)
63823  WRITE(m11,5040) 95, mstp(95), chmstp(95)
63824  WRITE(m11,5050) 78, parp(78), chparp(78)
63825 
63826  ENDIF
63827 
63828 C...APT(201), APT-Pro (211), Perugia-APT (221), Perugia-APT6 (226).
63829 C...Old model for ISR and UE, new pT-ordered model for FSR
63830  ELSEIF(itune.EQ.201.OR.itune.EQ.211.OR.itune.EQ.221.or
63831  & .itune.EQ.226) THEN
63832  IF (m13.GE.1) THEN
63833  WRITE(m11,5010) itune, chname
63834  ch60='see P. Skands & D. Wicke, hep-ph/0703081 (Tune APT),'
63835  WRITE(m11,5030) ch60
63836  ch60=' R.D. Field, in hep-ph/0610012 (Tune A)'
63837  WRITE(m11,5030) ch60
63838  ch60=' T. Sjostrand & M. v. Zijl, PRD36(1987)2019'
63839  WRITE(m11,5030) ch60
63840  ch60='and T. Sjostrand & P. Skands, hep-ph/0408302'
63841  WRITE(m11,5030) ch60
63842  IF (itune.EQ.211.OR.itune.GE.221) THEN
63843  ch60='LEP parameters tuned by Professor, hep-ph/0907.2973'
63844  WRITE(m11,5030) ch60
63845  ENDIF
63846  ENDIF
63847  IF (mstp(181).LE.5.OR.(mstp(181).EQ.6.AND.mstp(182).LE.411))THEN
63848  CALL pyerrm(9,'(PYTUNE:) linked PYTHIA version incompatible'//
63849  & ' with tune.')
63850  ENDIF
63851 C...First set as if Pythia tune A
63852 C...Multiple interactions on, old framework
63853  mstp(81)=1
63854 C...Fast IR cutoff energy scaling by default
63855  parp(89)=1800d0
63856  parp(90)=0.25d0
63857 C...Default CTEQ5L (internal)
63858  mstp(51)=7
63859  mstp(52)=1
63860 C...Double Gaussian matter distribution.
63861  mstp(82)=4
63862  parp(83)=0.5d0
63863  parp(84)=0.4d0
63864 C...FSR activity.
63865  parp(71)=4d0
63866 c...String drawing almost completely minimizes string length.
63867  parp(85)=0.9d0
63868  parp(86)=0.95d0
63869 C...ISR cutoff, muR scale factor, and phase space size
63870  parp(62)=1d0
63871  parp(64)=1d0
63872  parp(67)=4d0
63873 C...Intrinsic kT, size, and max
63874  mstp(91)=1
63875  parp(91)=1d0
63876  parp(93)=5d0
63877 C...Use 2 GeV of primordial kT for "Perugia" version
63878  IF (itune.EQ.221) THEN
63879  parp(91)=2d0
63880  parp(93)=10d0
63881  ENDIF
63882 C...Use pT-ordered FSR
63883  mstj(41)=12
63884 C...Lambda_FSR scale for pT-ordering
63885  parj(81)=0.23d0
63886 C...Retune pT0 (changed from 2.1 to 2.05 in 6.4.20)
63887  parp(82)=2.05d0
63888 C...Fragmentation functions and c and b parameters
63889 C...(overwritten for 211, i.e., if using Professor pars)
63890  parj(54)=-0.05
63891  parj(55)=-0.005
63892 
63893 C...Use Professor's LEP pars if ITUNE == 211, 221, 226
63894  IF (itune.LT.210) THEN
63895 C...# Old defaults
63896  mstj(11) = 4
63897 C...# Old default flavour parameters
63898  parj(21) = 0.36
63899  parj(41) = 0.30
63900  parj(42) = 0.58
63901  parj(46) = 1.0
63902  parj(82) = 1.0
63903  ELSE
63904 C...# Tuned flavour parameters:
63905  parj(1) = 0.073
63906  parj(2) = 0.2
63907  parj(3) = 0.94
63908  parj(4) = 0.032
63909  parj(11) = 0.31
63910  parj(12) = 0.4
63911  parj(13) = 0.54
63912  parj(25) = 0.63
63913  parj(26) = 0.12
63914 C...# Always use pT-ordered shower:
63915  mstj(41) = 12
63916 C...# Switch on Bowler:
63917  mstj(11) = 5
63918 C...# Fragmentation
63919  parj(21) = 3.1327e-01
63920  parj(41) = 4.8989e-01
63921  parj(42) = 1.2018e+00
63922  parj(47) = 1.0000e+00
63923  parj(81) = 2.5696e-01
63924  parj(82) = 8.0000e-01
63925  ENDIF
63926 
63927 C...221, 226 : Perugia-APT and Perugia-APT6
63928  IF (itune.EQ.221.OR.itune.EQ.226) THEN
63929 
63930  parp(64)=0.5d0
63931  parp(82)=2.05d0
63932  parp(90)=0.26d0
63933  parp(91)=2.0d0
63934 C...The Perugia variants use Steve's showers off the old MPI
63935  mstp(152)=1
63936 C...And use a lower PARP(71) as suggested by Professor tunings
63937 C...(although not certain that applies to Q2-pT2 hybrid)
63938  parp(71)=2.5d0
63939 
63940 C...Perugia-APT6 uses CTEQ6L1 and a slightly lower pT0
63941  IF (itune.EQ.226) THEN
63942  ch70='NB! This tune requires CTEQ6L1 pdfs to be '//
63943  & 'externally linked'
63944  WRITE(m11,5035) ch70
63945  mstp(52)=2
63946  mstp(51)=10042
63947  parp(82)=1.95d0
63948  ENDIF
63949 
63950  ENDIF
63951 
63952 C... Output
63953  IF (m13.GE.1) THEN
63954  WRITE(m11,5030) ' '
63955  WRITE(m11,5040) 51, mstp(51), chmstp(51)
63956  WRITE(m11,5040) 52, mstp(52), chmstp(52)
63957  WRITE(m11,5040) 3, mstp( 3), chmstp( 3)
63958  WRITE(m11,5050) 62, parp(62), chparp(62)
63959  WRITE(m11,5050) 64, parp(64), chparp(64)
63960  WRITE(m11,5050) 67, parp(67), chparp(67)
63961  WRITE(m11,5040) 68, mstp(68), chmstp(68)
63962  ch60='(Note: MSTP(68) is not explicitly (re-)set by PYTUNE)'
63963  WRITE(m11,5030) ch60
63964  WRITE(m11,5070) 41, mstj(41), chmstj(41)
63965  WRITE(m11,5050) 71, parp(71), chparp(71)
63966  WRITE(m11,5060) 81, parj(81), chparj(81)
63967  WRITE(m11,5040) 33, mstp(33), chmstp(33)
63968  WRITE(m11,5040) 81, mstp(81), chmstp(81)
63969  WRITE(m11,5050) 82, parp(82), chparp(82)
63970  WRITE(m11,5050) 89, parp(89), chparp(89)
63971  WRITE(m11,5050) 90, parp(90), chparp(90)
63972  WRITE(m11,5040) 82, mstp(82), chmstp(82)
63973  WRITE(m11,5050) 83, parp(83), chparp(83)
63974  WRITE(m11,5050) 84, parp(84), chparp(84)
63975  WRITE(m11,5050) 85, parp(85), chparp(85)
63976  WRITE(m11,5050) 86, parp(86), chparp(86)
63977  WRITE(m11,5040) 91, mstp(91), chmstp(91)
63978  WRITE(m11,5050) 91, parp(91), chparp(91)
63979  WRITE(m11,5050) 93, parp(93), chparp(93)
63980 
63981  ENDIF
63982 
63983 C======================================================================
63984 C...Uppsala models: Generalized Area Law and Soft Colour Interactions
63985  ELSEIF(chname.EQ.'GAL Tune 0'.OR.chname.EQ.'GAL Tune 1') THEN
63986  IF (m13.GE.1) THEN
63987  WRITE(m11,5010) itune, chname
63988  ch60='see J. Rathsman, PLB452(1999)364'
63989  WRITE(m11,5030) ch60
63990 C ? CH60='A. Edin, G. Ingelman, J. Rathsman, hep-ph/9912539,'
63991 C ? WRITE(M11,5030)
63992  ch60='and T. Sjostrand & M. v. Zijl, PRD36(1987)2019'
63993  WRITE(m11,5030) ch60
63994  WRITE(m11,5030) ' '
63995  ch70='NB! The GAL model must be run with modified '//
63996  & 'Pythia v6.215:'
63997  WRITE(m11,5035) ch70
63998  ch70='available from http://www.isv.uu.se/thep/MC/scigal/'
63999  WRITE(m11,5035) ch70
64000  WRITE(m11,5030) ' '
64001  ENDIF
64002 C...GAL Recommended settings from Uppsala web page (as per 22/08 2006)
64003  mswi(2) = 3
64004  parsci(2) = 0.10
64005  mswi(1) = 2
64006  parsci(1) = 0.44
64007  mstj(16) = 0
64008  parj(42) = 0.45
64009  parj(82) = 2.0
64010  parp(62) = 2.0
64011  mstp(81) = 1
64012  mstp(82) = 1
64013  parp(81) = 1.9
64014  mstp(92) = 1
64015  IF(chname.EQ.'GAL Tune 1') THEN
64016 C...GAL retune (P. Skands) to get better min-bias <Nch> at Tevatron
64017  mstp(82)=4
64018  parp(83)=0.25d0
64019  parp(84)=0.5d0
64020  parp(82) = 1.75
64021  IF (m13.GE.1) THEN
64022  WRITE(m11,5040) 81, mstp(81), chmstp(81)
64023  WRITE(m11,5050) 82, parp(82), chparp(82)
64024  WRITE(m11,5040) 82, mstp(82), chmstp(82)
64025  WRITE(m11,5050) 83, parp(83), chparp(83)
64026  WRITE(m11,5050) 84, parp(84), chparp(84)
64027  ENDIF
64028  ELSE
64029  IF (m13.GE.1) THEN
64030  WRITE(m11,5040) 81, mstp(81), chmstp(81)
64031  WRITE(m11,5050) 81, parp(81), chparp(81)
64032  WRITE(m11,5040) 82, mstp(82), chmstp(82)
64033  ENDIF
64034  ENDIF
64035 C...Output
64036  IF (m13.GE.1) THEN
64037  WRITE(m11,5050) 62, parp(62), chparp(62)
64038  WRITE(m11,5060) 82, parj(82), chparj(82)
64039  WRITE(m11,5040) 92, mstp(92), chmstp(92)
64040  ch40='FSI SCI/GAL selection'
64041  WRITE(m11,6040) 1, mswi(1), ch40
64042  ch40='FSI SCI/GAL sea quark treatment'
64043  WRITE(m11,6040) 2, mswi(2), ch40
64044  ch40='FSI SCI/GAL sea quark treatment parm'
64045  WRITE(m11,6050) 1, parsci(1), ch40
64046  ch40='FSI SCI/GAL string reco probability R_0'
64047  WRITE(m11,6050) 2, parsci(2), ch40
64048  WRITE(m11,5060) 42, parj(42), chparj(42)
64049  WRITE(m11,5070) 16, mstj(16), chmstj(16)
64050  ENDIF
64051  ELSEIF(chname.EQ.'SCI Tune 0'.OR.chname.EQ.'SCI Tune 1') THEN
64052  IF (m13.GE.1) THEN
64053  WRITE(m11,5010) itune, chname
64054  ch60='see A.Edin et al, PLB366(1996)371, Z.Phys.C75(1997)57,'
64055  WRITE(m11,5030) ch60
64056  ch60='and T. Sjostrand & M. v. Zijl, PRD36(1987)2019'
64057  WRITE(m11,5030) ch60
64058  WRITE(m11,5030) ' '
64059  ch70='NB! The SCI model must be run with modified '//
64060  & 'Pythia v6.215:'
64061  WRITE(m11,5035) ch70
64062  ch70='available from http://www.isv.uu.se/thep/MC/scigal/'
64063  WRITE(m11,5035) ch70
64064  WRITE(m11,5030) ' '
64065  ENDIF
64066 C...SCI Recommended settings from Uppsala web page (as per 22/08 2006)
64067  mstp(81)=1
64068  mstp(82)=1
64069  parp(81)=2.2
64070  mstp(92)=1
64071  mswi(2)=2
64072  parsci(2)=0.50
64073  mswi(1)=2
64074  parsci(1)=0.44
64075  mstj(16)=0
64076  IF (chname.EQ.'SCI Tune 1') THEN
64077 C...SCI retune (P. Skands) to get better min-bias <Nch> at Tevatron
64078  mstp(81) = 1
64079  mstp(82) = 3
64080  parp(82) = 2.4
64081  parp(83) = 0.5d0
64082  parp(62) = 1.5
64083  parp(84)=0.25d0
64084  IF (m13.GE.1) THEN
64085  WRITE(m11,5040) 81, mstp(81), chmstp(81)
64086  WRITE(m11,5050) 82, parp(82), chparp(82)
64087  WRITE(m11,5040) 82, mstp(82), chmstp(82)
64088  WRITE(m11,5050) 83, parp(83), chparp(83)
64089  WRITE(m11,5050) 62, parp(62), chparp(62)
64090  ENDIF
64091  ELSE
64092  IF (m13.GE.1) THEN
64093  WRITE(m11,5040) 81, mstp(81), chmstp(81)
64094  WRITE(m11,5050) 81, parp(81), chparp(81)
64095  WRITE(m11,5040) 82, mstp(82), chmstp(82)
64096  ENDIF
64097  ENDIF
64098 C...Output
64099  IF (m13.GE.1) THEN
64100  WRITE(m11,5040) 92, mstp(92), chmstp(92)
64101  ch40='FSI SCI/GAL selection'
64102  WRITE(m11,6040) 1, mswi(1), ch40
64103  ch40='FSI SCI/GAL sea quark treatment'
64104  WRITE(m11,6040) 2, mswi(2), ch40
64105  ch40='FSI SCI/GAL sea quark treatment parm'
64106  WRITE(m11,6050) 1, parsci(1), ch40
64107  ch40='FSI SCI/GAL string reco probability R_0'
64108  WRITE(m11,6050) 2, parsci(2), ch40
64109  WRITE(m11,5070) 16, mstj(16), chmstj(16)
64110  ENDIF
64111 
64112  ELSE
64113  IF (mstu(13).GE.1) WRITE(m11,5020) itune
64114 
64115  ENDIF
64116 
64117 C...Output of LEP parameters, common to all models
64118  IF (m13.GE.1) THEN
64119  WRITE(m11,5080)
64120  WRITE(m11,5070) 11, mstj(11), chmstj(11)
64121  IF (mstj(11).EQ.3) THEN
64122  ch60='Warning: using Peterson fragmentation function'
64123  WRITE(m11,5030) ch60
64124  ENDIF
64125 
64126  WRITE(m11,5060) 1, parj( 1), chparj( 1)
64127  WRITE(m11,5060) 2, parj( 2), chparj( 2)
64128  WRITE(m11,5060) 3, parj( 3), chparj( 3)
64129  WRITE(m11,5060) 4, parj( 4), chparj( 4)
64130  WRITE(m11,5060) 5, parj( 5), chparj( 5)
64131  WRITE(m11,5060) 6, parj( 6), chparj( 6)
64132  WRITE(m11,5060) 7, parj( 7), chparj( 7)
64133 
64134  WRITE(m11,5060) 11, parj(11), chparj(11)
64135  WRITE(m11,5060) 12, parj(12), chparj(12)
64136  WRITE(m11,5060) 13, parj(13), chparj(13)
64137 
64138  WRITE(m11,5060) 21, parj(21), chparj(21)
64139 
64140  WRITE(m11,5060) 25, parj(25), chparj(25)
64141  WRITE(m11,5060) 26, parj(26), chparj(26)
64142 
64143  WRITE(m11,5060) 41, parj(41), chparj(41)
64144  WRITE(m11,5060) 42, parj(42), chparj(42)
64145  WRITE(m11,5060) 45, parj(45), chparj(45)
64146 
64147  IF (mstj(11).LE.3) THEN
64148  WRITE(m11,5060) 54, parj(54), chparj(54)
64149  WRITE(m11,5060) 55, parj(55), chparj(55)
64150  ELSE
64151  WRITE(m11,5060) 46, parj(46), chparj(46)
64152  ENDIF
64153  IF (mstj(11).EQ.5) WRITE(m11,5060) 47, parj(47), chparj(47)
64154  ENDIF
64155 
64156  100 IF (mstu(13).GE.1) WRITE(m11,6000)
64157 
64158  9999 RETURN
64159 
64160  5000 FORMAT(1x,78('*')/' *',76x,'*'/' *',3x,'PYTUNE : ',
64161  & 'Presets for underlying-event (and min-bias)',21x,'*'/' *',
64162  & 12x,'Last Change : ',a8,' - P. Skands',30x,'*'/' *',76x,'*')
64163  5010 FORMAT(' *',3x,i4,1x,a16,52x,'*')
64164  5020 FORMAT(' *',3x,'Tune ',i4, ' not recognized. Using defaults.')
64165  5030 FORMAT(' *',3x,10x,a60,3x,'*')
64166  5035 FORMAT(' *',3x,a70,3x,'*')
64167  5040 FORMAT(' *',5x,'MSTP(',i2,') = ',i12,3x,a42,3x,'*')
64168  5050 FORMAT(' *',5x,'PARP(',i2,') = ',f12.4,3x,a40,5x,'*')
64169  5060 FORMAT(' *',5x,'PARJ(',i2,') = ',f12.4,3x,a40,5x,'*')
64170  5070 FORMAT(' *',5x,'MSTJ(',i2,') = ',i12,3x,a40,5x,'*')
64171  5080 FORMAT(' *',3x,'----------------------------',42('-'),3x,'*')
64172  6100 FORMAT(' *',5x,'MSTU(',i3,')= ',i12,3x,a42,3x,'*')
64173  6110 FORMAT(' *',5x,'PARU(',i3,')= ',f12.4,3x,a42,3x,'*')
64174 C 5140 FORMAT(' *',5x,'MSTP(',I3,')= ',I12,3x,A40,5x,'*')
64175 C 5150 FORMAT(' *',5x,'PARP(',I3,')= ',F12.4,3x,A40,5x,'*')
64176  6000 FORMAT(' *',76x,'*'/1x,32('*'),1x,'END OF PYTUNE',1x,31('*'))
64177  6040 FORMAT(' *',5x,'MSWI(',i1,') = ',i12,3x,a40,5x,'*')
64178  6050 FORMAT(' *',5x,'PARSCI(',i1,')= ',f12.4,3x,a40,5x,'*')
64179 
64180  END
64181 
64182 C*********************************************************************
64183 
64184 C...PYEXEC
64185 C...Administrates the fragmentation and decay chain.
64186 
64187  SUBROUTINE pyexec
64188 
64189 C...Double precision and integer declarations.
64190  IMPLICIT DOUBLE PRECISION(a-h, o-z)
64191  IMPLICIT INTEGER(i-n)
64192  INTEGER pyk,pychge,pycomp
64193 C...Commonblocks.
64194  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
64195  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
64196  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
64197  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
64198  common/pyint1/mint(400),vint(400)
64199  common/pyint4/mwid(500),wids(500,5)
64200  SAVE /pyjets/,/pydat1/,/pydat2/,/pydat3/,/pyint1/,/pyint4/
64201 C...Local array.
64202  dimension ps(2,6),ijoin(100)
64203 
64204 C...Initialize and reset.
64205  mstu(24)=0
64206  IF(mstu(12).NE.12345) CALL pylist(0)
64207  mstu(29)=0
64208  mstu(31)=mstu(31)+1
64209  mstu(1)=0
64210  mstu(2)=0
64211  mstu(3)=0
64212  IF(mstu(17).LE.0) mstu(90)=0
64213  mcons=1
64214 
64215 C...Sum up momentum, energy and charge for starting entries.
64216  nsav=n
64217  DO 110 i=1,2
64218  DO 100 j=1,6
64219  ps(i,j)=0d0
64220  100 CONTINUE
64221  110 CONTINUE
64222  DO 130 i=1,n
64223  IF(k(i,1).LE.0.OR.k(i,1).GT.10) goto 130
64224  DO 120 j=1,4
64225  ps(1,j)=ps(1,j)+p(i,j)
64226  120 CONTINUE
64227  ps(1,6)=ps(1,6)+pychge(k(i,2))
64228  130 CONTINUE
64229  paru(21)=ps(1,4)
64230 
64231 C...Start by all decays of coloured resonances involved in shower.
64232  norig=n
64233  DO 140 i=1,norig
64234  IF(k(i,1).EQ.3) THEN
64235  kc=pycomp(k(i,2))
64236  IF(mwid(kc).NE.0.AND.kchg(kc,2).NE.0) CALL pyresd(i)
64237  ENDIF
64238  140 CONTINUE
64239 
64240 C...Prepare system for subsequent fragmentation/decay.
64241  CALL pyprep(0)
64242  IF(mint(51).NE.0) RETURN
64243 
64244 C...Loop through jet fragmentation and particle decays.
64245  mbe=0
64246  150 mbe=mbe+1
64247  ip=0
64248  160 ip=ip+1
64249  kc=0
64250  IF(k(ip,1).GT.0.AND.k(ip,1).LE.10) kc=pycomp(k(ip,2))
64251  IF(kc.EQ.0) THEN
64252 
64253 C...Deal with any remaining undecayed resonance
64254 C...(normally the task of PYEVNT, so seldom used).
64255  ELSEIF(mwid(kc).NE.0) THEN
64256  ibeg=ip
64257  IF(kchg(kc,2).NE.0.AND.k(i,1).NE.3) THEN
64258  ibeg=ip+1
64259  170 ibeg=ibeg-1
64260  IF(ibeg.GE.2.AND.k(ibeg,1).EQ.2) goto 170
64261  IF(k(ibeg,1).NE.2) ibeg=ibeg+1
64262  iend=ip-1
64263  180 iend=iend+1
64264  IF(iend.LT.n.AND.k(iend,1).EQ.2) goto 180
64265  IF(iend.LT.n.AND.kchg(pycomp(k(iend,2)),2).EQ.0) goto 180
64266  njoin=0
64267  DO 190 i=ibeg,iend
64268  IF(kchg(pycomp(k(iend,2)),2).NE.0) THEN
64269  njoin=njoin+1
64270  ijoin(njoin)=i
64271  ENDIF
64272  190 CONTINUE
64273  ENDIF
64274  CALL pyresd(ip)
64275  CALL pyprep(ibeg)
64276  IF(mint(51).NE.0) RETURN
64277 
64278 C...Particle decay if unstable and allowed. Save long-lived particle
64279 C...decays until second pass after Bose-Einstein effects.
64280  ELSEIF(kchg(kc,2).EQ.0) THEN
64281  IF(mstj(21).GE.1.AND.mdcy(kc,1).GE.1.AND.(mstj(51).LE.0.OR.mbe
64282  & .EQ.2.OR.pmas(kc,2).GE.parj(91).OR.iabs(k(ip,2)).EQ.311))
64283  & CALL pydecy(ip)
64284 
64285 C...Decay products may develop a shower.
64286  IF(mstj(92).GT.0) THEN
64287  ip1=mstj(92)
64288  qmax=sqrt(max(0d0,(p(ip1,4)+p(ip1+1,4))**2-(p(ip1,1)+p(ip1+1,
64289  & 1))**2-(p(ip1,2)+p(ip1+1,2))**2-(p(ip1,3)+p(ip1+1,3))**2))
64290  mint(33)=0
64291  CALL pyshow(ip1,ip1+1,qmax)
64292  CALL pyprep(ip1)
64293  IF(mint(51).NE.0) RETURN
64294  mstj(92)=0
64295  ELSEIF(mstj(92).LT.0) THEN
64296  ip1=-mstj(92)
64297  mint(33)=0
64298  CALL pyshow(ip1,-3,p(ip,5))
64299  CALL pyprep(ip1)
64300  IF(mint(51).NE.0) RETURN
64301  mstj(92)=0
64302  ENDIF
64303 
64304 C...Jet fragmentation: string or independent fragmentation.
64305  ELSEIF(k(ip,1).EQ.1.OR.k(ip,1).EQ.2) THEN
64306  mfrag=mstj(1)
64307  IF(mfrag.GE.1.AND.k(ip,1).EQ.1) mfrag=2
64308  IF(mstj(21).GE.2.AND.k(ip,1).EQ.2.AND.n.GT.ip) THEN
64309  IF(k(ip+1,1).EQ.1.AND.k(ip+1,3).EQ.k(ip,3).AND.
64310  & k(ip,3).GT.0.AND.k(ip,3).LT.ip) THEN
64311  IF(kchg(pycomp(k(k(ip,3),2)),2).EQ.0) mfrag=min(1,mfrag)
64312  ENDIF
64313  ENDIF
64314  IF(mfrag.EQ.1) CALL pystrf(ip)
64315  IF(mfrag.EQ.2) CALL pyindf(ip)
64316  IF(mfrag.EQ.2.AND.k(ip,1).EQ.1) mcons=0
64317  IF(mfrag.EQ.2.AND.(mstj(3).LE.0.OR.mod(mstj(3),5).EQ.0)) mcons=0
64318  ENDIF
64319 
64320 C...Loop back if enough space left in PYJETS and no error abort.
64321  IF(mstu(24).NE.0.AND.mstu(21).GE.2) THEN
64322  ELSEIF(ip.LT.n.AND.n.LT.mstu(4)-20-mstu(32)) THEN
64323  goto 160
64324  ELSEIF(ip.LT.n) THEN
64325  CALL pyerrm(11,'(PYEXEC:) no more memory left in PYJETS')
64326  ENDIF
64327 
64328 C...Include simple Bose-Einstein effect parametrization if desired.
64329  IF(mbe.EQ.1.AND.mstj(51).GE.1) THEN
64330  CALL pyboei(nsav)
64331  goto 150
64332  ENDIF
64333 
64334 C...Check that momentum, energy and charge were conserved.
64335  DO 210 i=1,n
64336  IF(k(i,1).LE.0.OR.k(i,1).GT.10) goto 210
64337  DO 200 j=1,4
64338  ps(2,j)=ps(2,j)+p(i,j)
64339  200 CONTINUE
64340  ps(2,6)=ps(2,6)+pychge(k(i,2))
64341  210 CONTINUE
64342  pdev=(abs(ps(2,1)-ps(1,1))+abs(ps(2,2)-ps(1,2))+abs(ps(2,3)-
64343  &ps(1,3))+abs(ps(2,4)-ps(1,4)))/(1d0+abs(ps(2,4))+abs(ps(1,4)))
64344  IF(mcons.EQ.1.AND.pdev.GT.paru(11)) CALL pyerrm(15,
64345  &'(PYEXEC:) four-momentum was not conserved')
64346  IF(mcons.EQ.1.AND.abs(ps(2,6)-ps(1,6)).GT.0.1d0) CALL pyerrm(15,
64347  &'(PYEXEC:) charge was not conserved')
64348 
64349  RETURN
64350  END
64351 
64352 C*********************************************************************
64353 
64354 C...PYPREP
64355 C...Rearranges partons along strings.
64356 C...Special considerations for systems with junctions, with
64357 C...possibility of junction-antijunction annihilation.
64358 C...Allows small systems to collapse into one or two particles.
64359 C...Checks flavours and colour singlet invariant masses.
64360 
64361  SUBROUTINE pyprep(IP)
64362 
64363 C...Double precision and integer declarations.
64364  IMPLICIT DOUBLE PRECISION(a-h, o-z)
64365  INTEGER pyk,pychge,pycomp
64366 C...Commonblocks.
64367  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
64368  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
64369  common/pypars/mstp(200),parp(200),msti(200),pari(200)
64370  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
64371  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
64372  common/pyint1/mint(400),vint(400)
64373 C...The common block of colour tags.
64374  common/pyctag/nct,mct(4000,2)
64375  SAVE /pyjets/,/pydat1/,/pydat2/,/pydat3/,/pyint1/,/pyctag/,
64376  &/pypars/
64377  DATA nerrpr/0/
64378  SAVE nerrpr
64379 C...Local arrays.
64380  dimension dps(5),dpc(5),ue(3),pg(5),e1(3),e2(3),e3(3),e4(3),
64381  &ecl(3),ijunc(10,0:4),ipiece(30,0:4),kfend(4),kfq(4),
64382  &ijur(4),pju(4,6),irng(4,2),tjj(2,5),t(5),pul(3,5),
64383  &ijcp(0:6),tjuold(5)
64384  CHARACTER chtmp*6
64385 
64386 C...Function to give four-product.
64387  four(i,j)=p(i,4)*p(j,4)-p(i,1)*p(j,1)-p(i,2)*p(j,2)-p(i,3)*p(j,3)
64388 
64389 C...Rearrange parton shower product listing along strings: begin loop.
64390  mstu(24)=0
64391  nold=n
64392  i1=n
64393  njunc=0
64394  npiece=0
64395  njjstr=0
64396  mstu32=mstu(32)+1
64397  DO 100 i=max(1,ip),n
64398 C...First store junction positions.
64399  IF(k(i,1).EQ.42) THEN
64400  njunc=njunc+1
64401  ijunc(njunc,0)=i
64402  ijunc(njunc,4)=0
64403  ENDIF
64404  100 CONTINUE
64405 
64406  DO 250 mqgst=1,3
64407  DO 240 i=max(1,ip),n
64408 C...Special treatment for junctions
64409  IF (k(i,1).LE.0) goto 240
64410  IF(k(i,1).EQ.42) THEN
64411 C...MQGST=2: Look for junction-junction strings (not detected in the
64412 C...main search below).
64413  IF (mqgst.EQ.2.AND.npiece.NE.3*njunc) THEN
64414  IF (njjstr.EQ.0) THEN
64415  njjstr = (3*njunc-npiece)/2
64416  ENDIF
64417 C...Check how many already identified strings end on this junction
64418  ilc=0
64419  DO 110 j=1,npiece
64420  IF (ipiece(j,4).EQ.i) ilc=ilc+1
64421  110 CONTINUE
64422 C...If less than 3, remaining must be to another junction
64423  IF (ilc.LT.3) THEN
64424  IF (ilc.NE.2) THEN
64425 C...Multiple j-j connections not handled yet.
64426  CALL pyerrm(2,
64427  & '(PYPREP:) Too many junction-junction strings.')
64428  mint(51)=1
64429  RETURN
64430  ENDIF
64431 C...The colour information in the junction is unreadable for the
64432 C...colour space search further down in this routine, so we must
64433 C...start on the colour mother of this junction and then "artificially"
64434 C...prevent the colour mother from connecting here again.
64435  itjunc=mod(k(i,4)/mstu(5),mstu(5))
64436  kcs=4
64437  IF (mod(itjunc,2).EQ.0) kcs=5
64438 C...Switch colour if the junction-junction leg is presumably a
64439 C...junction mother leg rather than a junction daughter leg.
64440  IF (itjunc.GE.3) kcs=9-kcs
64441  IF (mint(33).EQ.0) THEN
64442 C...Find the unconnected leg and reorder junction daughter pointers so
64443 C...MOD(K(I,4),MSTU(5)) always points to the junction-junction string
64444 C...piece.
64445  ia=mod(k(i,4),mstu(5))
64446  IF (k(ia,kcs)/mstu(5)**2.GE.2) THEN
64447  itmp=mod(k(i,5),mstu(5))
64448  IF (k(itmp,kcs)/mstu(5)**2.GE.2) THEN
64449  itmp=mod(k(i,5)/mstu(5),mstu(5))
64450  k(i,5)=k(i,5)+(ia-itmp)*mstu(5)
64451  ELSE
64452  k(i,5)=k(i,5)+(ia-itmp)
64453  ENDIF
64454  k(i,4)=k(i,4)+(itmp-ia)
64455  ia=itmp
64456  ENDIF
64457  IF (itjunc.LE.2) THEN
64458 C...Beam baryon junction
64459  k(ia,kcs) = k(ia,kcs) + 2*mstu(5)**2
64460  k(i,kcs) = k(i,kcs) + 1*mstu(5)**2
64461 C...Else 1 -> 2 decay junction
64462  ELSE
64463  k(ia,kcs) = k(ia,kcs) + mstu(5)**2
64464  k(i,kcs) = k(i,kcs) + 2*mstu(5)**2
64465  ENDIF
64466  i1beg = i1
64467  nstp = 0
64468  goto 170
64469 C...Alternatively use colour tag information.
64470  ELSE
64471 C...Find a final state parton with appropriate dangling colour tag.
64472  jct=0
64473  ia=0
64474  ijumo=k(i,3)
64475  DO 140 j1=max(1,ip),n
64476  IF (k(j1,1).NE.3) goto 140
64477 C...Check for matching final-state colour tag
64478  imatch=0
64479  DO 120 j2=max(1,ip),n
64480  IF (k(j2,1).NE.3) goto 120
64481  IF (mct(j1,kcs-3).EQ.mct(j2,6-kcs)) imatch=1
64482  120 CONTINUE
64483  IF (imatch.EQ.1) goto 140
64484 C...Check whether this colour tag belongs to the present junction
64485 C...by seeing whether any parton with this colour tag has the same
64486 C...mother as the junction.
64487  jct=mct(j1,kcs-3)
64488  imatch=0
64489  DO 130 j2=mint(84)+1,n
64490  imo2=k(j2,3)
64491 C...First scattering partons have IMO1 = 3 and 4.
64492  IF (imo2.EQ.mint(83)+3.OR.imo2.EQ.mint(83)+4)
64493  & imo2=imo2-2
64494  IF (mct(j2,kcs-3).EQ.jct.AND.imo2.EQ.ijumo)
64495  & imatch=1
64496  130 CONTINUE
64497  IF (imatch.EQ.0) goto 140
64498  ia=j1
64499  140 CONTINUE
64500 C...Check for junction-junction strings without intermediate final state
64501 C...glue (not detected above).
64502  IF (ia.EQ.0) THEN
64503  DO 160 mju=1,njunc
64504  iju2=ijunc(mju,0)
64505  IF (iju2.EQ.i) goto 160
64506  itju2=mod(k(iju2,4)/mstu(5),mstu(5))
64507 C...Only opposite types of junctions can connect to each other.
64508  IF (mod(itju2,2).EQ.mod(itjunc,2)) goto 160
64509  is=0
64510  DO 150 j=1,npiece
64511  IF (ipiece(j,4).EQ.iju2) is=is+1
64512  150 CONTINUE
64513  IF (is.EQ.3) goto 160
64514  ib=i
64515  ia=iju2
64516  160 CONTINUE
64517  ENDIF
64518 C...Switch to other side of adjacent parton and step from there.
64519  kcs=9-kcs
64520  i1beg = i1
64521  nstp = 0
64522  goto 170
64523  ENDIF
64524  ELSE IF (ilc.NE.3) THEN
64525  ENDIF
64526  ENDIF
64527  ENDIF
64528 
64529 C...Look for coloured string endpoint, or (later) leftover gluon.
64530  IF(k(i,1).NE.3) goto 240
64531  kc=pycomp(k(i,2))
64532  IF(kc.EQ.0) goto 240
64533  kq=kchg(kc,2)
64534  IF(kq.EQ.0.OR.(mqgst.LE.2.AND.kq.EQ.2)) goto 240
64535 
64536 C...Pick up loose string end.
64537  kcs=4
64538  IF(kq*isign(1,k(i,2)).LT.0) kcs=5
64539  ia=i
64540  ib=i
64541  i1beg=i1
64542  nstp=0
64543  170 nstp=nstp+1
64544  IF(nstp.GT.4*n) THEN
64545  CALL pyerrm(14,'(PYPREP:) caught in infinite loop')
64546  mint(51)=1
64547  RETURN
64548  ENDIF
64549 
64550 C...Copy undecayed parton. Finished if reached string endpoint.
64551  IF(k(ia,1).EQ.3) THEN
64552  IF(i1.GE.mstu(4)-mstu32-5) THEN
64553  CALL pyerrm(11,'(PYPREP:) no more memory left in PYJETS')
64554  mint(51)=1
64555  mstu(24)=1
64556  RETURN
64557  ENDIF
64558  i1=i1+1
64559  k(i1,1)=2
64560  IF(nstp.GE.2.AND.kchg(pycomp(k(ia,2)),2).NE.2) k(i1,1)=1
64561  k(i1,2)=k(ia,2)
64562  k(i1,3)=ia
64563  k(i1,4)=0
64564  k(i1,5)=0
64565  DO 180 j=1,5
64566  p(i1,j)=p(ia,j)
64567  v(i1,j)=v(ia,j)
64568  180 CONTINUE
64569  k(ia,1)=k(ia,1)+10
64570  IF(k(i1,1).EQ.1) goto 240
64571  ENDIF
64572 
64573 C...Also finished (for now) if reached junction; then copy to end.
64574  IF(k(ia,1).EQ.42) THEN
64575  ncopy=i1-i1beg
64576  IF(i1.GE.mstu(4)-mstu32-ncopy-5) THEN
64577  CALL pyerrm(11,'(PYPREP:) no more memory left in PYJETS')
64578  mint(51)=1
64579  mstu(24)=1
64580  RETURN
64581  ENDIF
64582  IF (mqgst.LE.2.AND.ncopy.NE.0) THEN
64583  DO 200 icopy=1,ncopy
64584  DO 190 j=1,5
64585  k(mstu(4)-mstu32-icopy,j)=k(i1beg+icopy,j)
64586  p(mstu(4)-mstu32-icopy,j)=p(i1beg+icopy,j)
64587  v(mstu(4)-mstu32-icopy,j)=v(i1beg+icopy,j)
64588  190 CONTINUE
64589  200 CONTINUE
64590  ENDIF
64591 C...For junction-junction strings, find end leg and reorder junction
64592 C...daughter pointers so MOD(K(I,4),MSTU(5)) always points to the
64593 C...junction-junction string piece.
64594  IF (k(i,1).EQ.42.AND.mint(33).EQ.0) THEN
64595  itmp=mod(k(ia,4),mstu(5))
64596  IF (itmp.NE.ib) THEN
64597  IF (mod(k(ia,5),mstu(5)).EQ.ib) THEN
64598  k(ia,5)=k(ia,5)+(itmp-ib)
64599  ELSE
64600  k(ia,5)=k(ia,5)+(itmp-ib)*mstu(5)
64601  ENDIF
64602  k(ia,4)=k(ia,4)+(ib-itmp)
64603  ENDIF
64604  ENDIF
64605  npiece=npiece+1
64606 C...IPIECE:
64607 C...0: endpoint in original ER
64608 C...1:
64609 C...2:
64610 C...3: Parton immediately next to junction
64611 C...4: Junction
64612  ipiece(npiece,0)=i
64613  ipiece(npiece,1)=mstu32+1
64614  ipiece(npiece,2)=mstu32+ncopy
64615  ipiece(npiece,3)=ib
64616  ipiece(npiece,4)=ia
64617  mstu32=mstu32+ncopy
64618  i1=i1beg
64619  goto 240
64620  ENDIF
64621 
64622 C...GOTO next parton in colour space.
64623  ib=ia
64624  IF (mint(33).EQ.0) THEN
64625  IF(mod(k(ib,kcs)/mstu(5)**2,2).EQ.0.AND.mod(k(ib,kcs),mstu(5
64626  & )).NE.0) THEN
64627  ia=mod(k(ib,kcs),mstu(5))
64628  k(ib,kcs)=k(ib,kcs)+mstu(5)**2
64629  mrev=0
64630  ELSE
64631  IF(k(ib,kcs).GE.2*mstu(5)**2.OR.mod(k(ib,kcs)/mstu(5),
64632  & mstu(5)).EQ.0) kcs=9-kcs
64633  ia=mod(k(ib,kcs)/mstu(5),mstu(5))
64634  k(ib,kcs)=k(ib,kcs)+2*mstu(5)**2
64635  mrev=1
64636  ENDIF
64637  IF(ia.LE.0.OR.ia.GT.n) THEN
64638  CALL pyerrm(12,'(PYPREP:) colour rearrangement failed')
64639  IF(nerrpr.LT.5) THEN
64640  nerrpr=nerrpr+1
64641  WRITE(mstu(11),*) 'started at:', i
64642  WRITE(mstu(11),*) 'ended going from',ib,' to',ia
64643  WRITE(mstu(11),*) 'MQGST =',mqgst
64644  CALL pylist(4)
64645  ENDIF
64646  mint(51)=1
64647  RETURN
64648  ENDIF
64649  IF(mod(k(ia,4)/mstu(5),mstu(5)).EQ.ib.OR.mod(k(ia,5)/mstu(5)
64650  & ,mstu(5)).EQ.ib) THEN
64651  IF(mrev.EQ.1) kcs=9-kcs
64652  IF(mod(k(ia,kcs)/mstu(5),mstu(5)).NE.ib) kcs=9-kcs
64653  k(ia,kcs)=k(ia,kcs)+2*mstu(5)**2
64654  ELSE
64655  IF(mrev.EQ.0) kcs=9-kcs
64656  IF(mod(k(ia,kcs),mstu(5)).NE.ib) kcs=9-kcs
64657  k(ia,kcs)=k(ia,kcs)+mstu(5)**2
64658  ENDIF
64659  IF(ia.NE.i) goto 170
64660 C...Use colour tag information
64661  ELSE
64662 C...First create colour tags starting on IB if none already present.
64663  IF (mct(ib,kcs-3).EQ.0) THEN
64664  CALL pycttr(ib,kcs,ib)
64665  IF(mint(51).NE.0) RETURN
64666  ENDIF
64667  jct=mct(ib,kcs-3)
64668  ifound=0
64669 C...Find final state tag partner
64670  DO 210 it=max(1,ip),n
64671  IF (it.EQ.ib) goto 210
64672  IF (mct(it,6-kcs).EQ.jct.AND.k(it,1).LT.10.AND.k(it,1).gt
64673  & .0) THEN
64674  ifound=ifound+1
64675  ia=it
64676  ENDIF
64677  210 CONTINUE
64678 C...Just copy and goto next if exactly one partner found.
64679  IF (ifound.EQ.1) THEN
64680  goto 170
64681 C...When no match found, match is presumably junction.
64682  ELSEIF (ifound.EQ.0.AND.mqgst.LE.2) THEN
64683 C...Check whether this colour tag matches a junction
64684 C...by seeing whether any parton with this colour tag has the same
64685 C...mother as a junction.
64686 C...NB: Only type 1 and 2 junctions handled presently.
64687  DO 230 iju=1,njunc
64688  ijumo=k(ijunc(iju,0),3)
64689  itjunc=mod(k(ijunc(iju,0),4)/mstu(5),mstu(5))
64690 C...Colours only connect to junctions, anti-colours to antijunctions:
64691  IF (mod(itjunc+1,2)+1.NE.kcs-3) goto 230
64692  imatch=0
64693  DO 220 j1=max(1,ip),n
64694  IF (k(j1,1).LE.0) goto 220
64695 C...First scattering partons have IMO1 = 3 and 4.
64696  imo=k(j1,3)
64697  IF (imo.EQ.mint(83)+3.OR.imo.EQ.mint(83)+4)
64698  & imo=imo-2
64699  IF (mct(j1,kcs-3).EQ.jct.AND.imo.EQ.ijumo.AND.mod(k(j1
64700  & ,3+itjunc)/mstu(5),mstu(5)).EQ.ijunc(iju,0))
64701  & imatch=1
64702 C...Attempt at handling type > 3 junctions also. Not tested.
64703  IF (itjunc.GE.3.AND.mct(j1,6-kcs).EQ.jct.AND.imo.eq
64704  & .ijumo) imatch=1
64705  220 CONTINUE
64706  IF (imatch.EQ.0) goto 230
64707  ia=ijunc(iju,0)
64708  ifound=ifound+1
64709  230 CONTINUE
64710 
64711  IF (ifound.EQ.1) THEN
64712  goto 170
64713  ELSEIF (ifound.EQ.0) THEN
64714  WRITE(chtmp,'(I6)') jct
64715  CALL pyerrm(12,'(PYPREP:) no matching colour tag: '
64716  & //chtmp)
64717  IF(nerrpr.LT.5) THEN
64718  nerrpr=nerrpr+1
64719  CALL pylist(4)
64720  ENDIF
64721  mint(51)=1
64722  RETURN
64723  ENDIF
64724  ELSEIF (ifound.GE.2) THEN
64725  WRITE(chtmp,'(I6)') jct
64726  CALL pyerrm(12
64727  & ,'(PYPREP:) too many occurences of colour line: '//
64728  & chtmp)
64729  IF(nerrpr.LT.5) THEN
64730  nerrpr=nerrpr+1
64731  CALL pylist(4)
64732  ENDIF
64733  mint(51)=1
64734  RETURN
64735  ENDIF
64736  ENDIF
64737  k(i1,1)=1
64738  240 CONTINUE
64739  250 CONTINUE
64740 
64741 C...Junction systems remain.
64742  iju=0
64743  ijus=0
64744  ijucnt=0
64745  mrev=0
64746  ijjstr=0
64747  260 ijucnt=ijucnt+1
64748  IF (ijucnt.LE.njunc) THEN
64749 C...If we are not processing a j-j string, treat this junction as new.
64750  IF (ijjstr.EQ.0) THEN
64751  iju=ijunc(ijucnt,0)
64752  mrev=0
64753 C...If junction has already been read, ignore it.
64754  IF (ijunc(ijucnt,4).EQ.1) goto 260
64755 C...If we are on a j-j string, goto second j-j junction.
64756  ELSE
64757  ijucnt=ijucnt-1
64758  iju=ijus
64759  ENDIF
64760 C...Mark selected junction read.
64761  DO 270 j=1,njunc
64762  IF (ijunc(j,0).EQ.iju) ijunc(j,4)=1
64763  270 CONTINUE
64764 C...Determine junction type
64765  itjunc = mod(k(iju,4)/mstu(5),mstu(5))
64766 C...Type 1 and 2 junctions: ~chi -> q q q, ~chi -> qbar,qbar,qbar
64767 C...Type 3 and 4 junctions: ~qbar -> q q , ~q -> qbar qbar
64768 C...Type 5 and 6 junctions: ~g -> q q q, ~g -> qbar qbar qbar
64769  IF (itjunc.GE.1.AND.itjunc.LE.6) THEN
64770  ihk=0
64771  280 ihk=ihk+1
64772 C...Find which quarks belong to given junction.
64773  ihf=0
64774  DO 290 ipc=1,npiece
64775  IF (ipiece(ipc,4).EQ.iju) THEN
64776  ihf=ihf+1
64777  IF (ihf.EQ.ihk) iend=ipiece(ipc,3)
64778  ENDIF
64779  IF (ihk.EQ.3.AND.ipiece(ipc,0).EQ.iju) iend=ipiece(ipc,3)
64780  290 CONTINUE
64781 C...IHK = 3 is special. Either normal string piece, or j-j string.
64782  IF(ihk.EQ.3) THEN
64783  IF (mrev.NE.1) THEN
64784  DO 300 ipc=1,npiece
64785 C...If there is a j-j string starting on the present junction which has
64786 C...zero length, insert next junction immediately.
64787  IF (ipiece(ipc,0).EQ.iju.AND.k(ipiece(ipc,4),1)
64788  & .EQ.42.AND.ipiece(ipc,1)-1-ipiece(ipc,2).EQ.0) THEN
64789  ijjstr = 1
64790  goto 340
64791  ENDIF
64792  300 CONTINUE
64793  mrev = 1
64794 C...If MREV is 1 and IHK is 3 we are finished with this system.
64795  ELSE
64796  mrev=0
64797  goto 260
64798  ENDIF
64799  ENDIF
64800 
64801 C...If we've gotten this far, then either IHK < 3, or
64802 C...an interjunction string exists, or just a third normal string.
64803  ijunc(ijucnt,ihk)=0
64804  ijjstr = 0
64805 C..Order pieces belonging to this junction. Also look for j-j.
64806  DO 310 ipc=1,npiece
64807  IF (ipiece(ipc,3).EQ.iend) ijunc(ijucnt,ihk)=ipc
64808  IF (ihk.EQ.3.AND.ipiece(ipc,0).EQ.ijunc(ijucnt,0)
64809  & .AND.k(ipiece(ipc,4),1).EQ.42) THEN
64810  ijunc(ijucnt,ihk)=ipc
64811  ijjstr = 1
64812  mrev = 0
64813  ENDIF
64814  310 CONTINUE
64815 C...Copy back chains in proper order. MREV=0/1 : descending/ascending
64816  ipc=ijunc(ijucnt,ihk)
64817 C...Temporary solution to cover for bug.
64818  IF(ipc.LE.0) THEN
64819  CALL pyerrm(12,'(PYPREP:) fails to hook up junctions')
64820  mint(51)=1
64821  RETURN
64822  ENDIF
64823  DO 330 icp=ipiece(ipc,1+mrev),ipiece(ipc,2-mrev),1-2*mrev
64824  i1=i1+1
64825  DO 320 j=1,5
64826  k(i1,j)=k(mstu(4)-icp,j)
64827  p(i1,j)=p(mstu(4)-icp,j)
64828  v(i1,j)=v(mstu(4)-icp,j)
64829  320 CONTINUE
64830  330 CONTINUE
64831  k(i1,1)=2
64832 C...Mark last quark.
64833  IF (mrev.EQ.1.AND.ihk.GE.2) k(i1,1)=1
64834 C...Do not insert junctions at wrong places.
64835  IF(ihk.LT.2.OR.mrev.NE.0) goto 360
64836 C...Insert junction.
64837  340 ijus = iju
64838  IF (ihk.EQ.3) THEN
64839 C...Shift to end junction if a j-j string has been processed.
64840  IF (ijjstr.NE.0) ijus = ipiece(ipc,4)
64841  mrev= 1
64842  ENDIF
64843  i1=i1+1
64844  DO 350 j=1,5
64845  k(i1,j)=0
64846  p(i1,j)=0.
64847  v(i1,j)=0.
64848  350 CONTINUE
64849  k(i1,1)=41
64850  k(ijus,1)=k(ijus,1)+10
64851  k(i1,2)=k(ijus,2)
64852  k(i1,3)=ijus
64853  360 IF (ihk.LT.3) goto 280
64854  ELSE
64855  CALL pyerrm(12,'(PYPREP:) Unknown junction type')
64856  mint(51)=1
64857  RETURN
64858  ENDIF
64859  IF (ijucnt.NE.njunc) goto 260
64860  ENDIF
64861  n=i1
64862 
64863 C...Rearrange three strings from junction, e.g. in case one has been
64864 C...shortened by shower, so the last is the largest-energy one.
64865  IF(njunc.GE.1) THEN
64866 C...Find systems with exactly one junction.
64867  mjun1=0
64868  nbeg=nold+1
64869  DO 470 i=nold+1,n
64870  IF(k(i,1).NE.1.AND.k(i,1).NE.41) THEN
64871  ELSEIF(k(i,1).EQ.41) THEN
64872  mjun1=mjun1+1
64873  ELSEIF(k(i,1).EQ.1.AND.mjun1.NE.1) THEN
64874  mjun1=0
64875  nbeg=i+1
64876  ELSE
64877  nend=i
64878 C...Sum up energy-momentum in each junction string.
64879  DO 370 j=1,5
64880  pju(1,j)=0d0
64881  pju(2,j)=0d0
64882  pju(3,j)=0d0
64883  370 CONTINUE
64884  nju=0
64885  DO 390 i1=nbeg,nend
64886  IF(k(i1,2).NE.21) THEN
64887  nju=nju+1
64888  ijur(nju)=i1
64889  ENDIF
64890  DO 380 j=1,5
64891  pju(min(nju,3),j)=pju(min(nju,3),j)+p(i1,j)
64892  380 CONTINUE
64893  390 CONTINUE
64894 C...Find which of them has highest energy (minus mass) in rest frame.
64895  DO 400 j=1,5
64896  pju(4,j)=pju(1,j)+pju(2,j)+pju(3,j)
64897  400 CONTINUE
64898  pmju=sqrt(max(0d0,pju(4,4)**2-pju(4,1)**2-pju(4,2)**2-
64899  & pju(4,3)**2))
64900  DO 410 i2=1,3
64901  pju(i2,6)=(pju(4,4)*pju(i2,4)-pju(4,1)*pju(i2,1)-
64902  & pju(4,2)*pju(i2,2)-pju(4,3)*pju(i2,3))/pmju-pju(i2,5)
64903  410 CONTINUE
64904  IF(pju(3,6).LT.min(pju(1,6),pju(2,6))) THEN
64905 C...Decide how to rearrange so that new last has highest energy.
64906  IF(pju(1,6).LT.pju(2,6)) THEN
64907  irng(1,1)=ijur(1)
64908  irng(1,2)=ijur(2)-1
64909  irng(2,1)=ijur(4)
64910  irng(2,2)=ijur(3)+1
64911  irng(4,1)=ijur(3)-1
64912  irng(4,2)=ijur(2)
64913  ELSE
64914  irng(1,1)=ijur(4)
64915  irng(1,2)=ijur(3)+1
64916  irng(2,1)=ijur(2)
64917  irng(2,2)=ijur(3)-1
64918  irng(4,1)=ijur(2)-1
64919  irng(4,2)=ijur(1)
64920  ENDIF
64921  irng(3,1)=ijur(3)
64922  irng(3,2)=ijur(3)
64923 C...Copy in correct order below bottom of current event record.
64924  i2=n
64925  DO 440 ii=1,4
64926  DO 430 i1=irng(ii,1),irng(ii,2),
64927  & isign(1,irng(ii,2)-irng(ii,1))
64928  i2=i2+1
64929  IF(i2.GE.mstu(4)-mstu32-5) THEN
64930  CALL pyerrm(11,
64931  & '(PYPREP:) no more memory left in PYJETS')
64932  mint(51)=1
64933  mstu(24)=1
64934  RETURN
64935  ENDIF
64936  DO 420 j=1,5
64937  k(i2,j)=k(i1,j)
64938  p(i2,j)=p(i1,j)
64939  v(i2,j)=v(i1,j)
64940  420 CONTINUE
64941  IF(k(i2,1).EQ.1) k(i2,1)=2
64942  430 CONTINUE
64943  440 CONTINUE
64944  k(i2,1)=1
64945 C...Copy back up, overwriting but now in correct order.
64946  DO 460 i1=nbeg,nend
64947  i2=i1-nbeg+n+1
64948  DO 450 j=1,5
64949  k(i1,j)=k(i2,j)
64950  p(i1,j)=p(i2,j)
64951  v(i1,j)=v(i2,j)
64952  450 CONTINUE
64953  460 CONTINUE
64954  ENDIF
64955  mjun1=0
64956  nbeg=i+1
64957  ENDIF
64958  470 CONTINUE
64959 
64960 C...Check whether q-q-j-j-qbar-qbar systems should be collapsed
64961 C...to two q-qbar systems.
64962 C...(MSTJ(19)=1 forces q-q-j-j-qbar-qbar.)
64963  IF (mstj(19).NE.1) THEN
64964  mjun1 = 0
64965  jjglue = 0
64966  nbeg = nold+1
64967 C...Force collapse when MSTJ(19)=2.
64968  IF (mstj(19).EQ.2) THEN
64969  delmjj = 1d9
64970  delmqq = 0d0
64971  ENDIF
64972 C...Find systems with exactly two junctions.
64973  DO 700 i=nold+1,n
64974 C...Count junctions
64975  IF (k(i,1).EQ.41) THEN
64976  mjun1 = mjun1+1
64977 C...Check for interjunction gluons
64978  IF (mjun1.EQ.2.AND.k(i-1,1).NE.41) THEN
64979  jjglue = 1
64980  ENDIF
64981  ELSEIF(k(i,1).EQ.1.AND.(mjun1.NE.2)) THEN
64982 C...If end of system reached with either zero or one junction, restart
64983 C...with next system.
64984  mjun1 = 0
64985  jjglue = 0
64986  nbeg = i+1
64987  ELSEIF(k(i,1).EQ.1) THEN
64988 C...If end of system reached with exactly two junctions, compute string
64989 C...length measure for the (q-q-j-j-qbar-qbar) topology and compare with
64990 C...length measure for the (q-qbar)(q-qbar) topology.
64991  nend=i
64992 C...Loop down through chain.
64993  isid=0
64994  DO 480 i1=nbeg,nend
64995 C...Store string piece division locations in event record
64996  IF (k(i1,2).NE.21) THEN
64997  isid = isid+1
64998  ijcp(isid) = i1
64999  ENDIF
65000  480 CONTINUE
65001 C...Randomly choose between (1,3)(2,4) and (1,4)(2,3) topologies.
65002  isw=0
65003  IF (pyr(0).LT.0.5d0) isw=1
65004 C...Randomly choose which qqbar string gets the jj gluons.
65005  igs=1
65006  IF (pyr(0).GT.0.5d0) igs=2
65007 C...Only compute string lengths when no topology forced.
65008  IF (mstj(19).EQ.0) THEN
65009 C...Repeat following for each junction
65010  DO 570 iju=1,2
65011 C...Initialize iterative procedure for finding JRF
65012  ijrfit=0
65013  DO 490 ix=1,3
65014  tjuold(ix)=0d0
65015  490 CONTINUE
65016  tjuold(4)=1d0
65017 C...Start iteration. Sum up momenta in string pieces
65018  500 DO 540 ijs=1,3
65019 C...JD=-1 for first junction, +1 for second junction.
65020 C...Find out where piece starts and ends and which direction to go.
65021  jd=2*iju-3
65022  IF (ijs.LE.2) THEN
65023  ia = ijcp((iju-1)*7 - jd*(ijs+1)) + jd
65024  ib = ijcp((iju-1)*7 - jd*ijs)
65025  ELSEIF (ijs.EQ.3) THEN
65026  jd =-jd
65027  ia = ijcp((iju-1)*7 + jd*(ijs)) + jd
65028  ib = ijcp((iju-1)*7 + jd*(ijs+3))
65029  ENDIF
65030 C...Initialize junction pull 4-vector.
65031  DO 510 j=1,5
65032  pul(ijs,j)=0d0
65033  510 CONTINUE
65034 C...Initialize weight
65035  pwt = 0d0
65036  pwtold = 0d0
65037 C...Sum up (weighted) momenta along each string piece
65038  DO 530 isp=ia,ib,jd
65039 C...If present parton not last in chain
65040  IF (isp.NE.ia.AND.isp.NE.ib) THEN
65041 C...If last parton was a junction, store present weight
65042  IF (k(isp-jd,2).EQ.88) THEN
65043  pwtold = pwt
65044 C...If last parton was a quark, reset to stored weight.
65045  ELSEIF (k(isp-jd,2).NE.21) THEN
65046  pwt = pwtold
65047  ENDIF
65048  ENDIF
65049 C...Skip next parton if weight already large
65050  IF (pwt.GT.10d0) goto 530
65051 C...Compute momentum in TJUOLD frame:
65052  tdp=tjuold(1)*p(isp,1)+tjuold(2)*p(isp,2)+tjuold(3
65053  & )*p(isp,3)
65054  bfc=tdp/(1d0+tjuold(4))+p(isp,4)
65055  DO 520 j=1,3
65056  tmp=p(isp,j)+tjuold(j)*bfc
65057  pul(ijs,j)=pul(ijs,j)+tmp*exp(-pwt)
65058  520 CONTINUE
65059 C...Boosted energy
65060  tmp=tjuold(4)*p(isp,4)+tdp
65061  pul(ijs,4)=pul(ijs,j)+tmp*exp(-pwt)
65062 C...Update weight
65063  pwt=pwt+tmp/parj(48)
65064 C...Put |p| rather than m in 5th slot
65065  pul(ijs,5)=sqrt(pul(ijs,1)**2+pul(ijs,2)**2
65066  & +pul(ijs,3)**2)
65067  530 CONTINUE
65068  540 CONTINUE
65069 C...Compute boost
65070  ijrfit=ijrfit+1
65071  CALL pyjurf(pul,t)
65072 C...Combine new boost (T) with old boost (TJUOLD)
65073  tmp=t(1)*tjuold(1)+t(2)*tjuold(2)+t(3)*tjuold(3)
65074  DO 550 ix=1,3
65075  tjuold(ix)=t(ix)+tjuold(ix)*(tmp/(1d0+tjuold(4))+t(4
65076  & ))
65077  550 CONTINUE
65078  tjuold(4)=sqrt(1d0+tjuold(1)**2+tjuold(2)**2+tjuold(3)
65079  & **2)
65080 C...If last boost small, accept JRF, else iterate.
65081 C...Also prevent possibility of infinite loop.
65082  IF (abs((t(4)-1d0)/tjuold(4)).GT.0.01d0.AND.
65083  & ijrfit.LT.mstj(18))THEN
65084  goto 500
65085  ELSEIF (ijrfit.GE.mstj(18)) THEN
65086  CALL pyerrm(1,'(PYPREP:) failed to converge on JRF')
65087  ENDIF
65088 C...Store final boost, with change of sign since TJJ motion vector.
65089  DO 560 ix=1,3
65090  tjj(iju,ix)=-tjuold(ix)
65091  560 CONTINUE
65092  tjj(iju,4)=sqrt(1d0+tjj(iju,1)**2+tjj(iju,2)**2
65093  & +tjj(iju,3)**2)
65094  570 CONTINUE
65095 C...String length measure for (q-qbar)(q-qbar) topology.
65096 C...Note only momenta of nearest partons used (since rest of system
65097 C...identical).
65098  IF (jjglue.EQ.0) THEN
65099  delmqq=4d0*four(ijcp(2)-1,ijcp(4+isw)+1)*four(ijcp(3)
65100  & -1,ijcp(5-isw)+1)
65101  ELSE
65102 C...Put jj gluons on selected string (IGS selected randomly above).
65103  IF (igs.EQ.1) THEN
65104  delmqq=8d0*four(ijcp(2)-1,ijcp(4)-1)*four(ijcp(3)+1
65105  & ,ijcp(4+isw)+1)*four(ijcp(3)-1,ijcp(5-isw)+1)
65106  ELSE
65107  delmqq=8d0*four(ijcp(2)-1,ijcp(4+isw)+1)
65108  & *four(ijcp(3)-1,ijcp(4)-1)*four(ijcp(3)+1
65109  & ,ijcp(5-isw)+1)
65110  ENDIF
65111  ENDIF
65112 C...String length measure for q-q-j-j-q-q topology.
65113  t1g1=0d0
65114  t2g2=0d0
65115  t1t2=0d0
65116  t1p1=0d0
65117  t1p2=0d0
65118  t2p3=0d0
65119  t2p4=0d0
65120  isgn=-1
65121 C...Note only momenta of nearest partons used (since rest of system
65122 C...identical).
65123  DO 580 ix=1,4
65124  IF (ix.EQ.4) isgn=1
65125  t1p1=t1p1+isgn*tjj(1,ix)*p(ijcp(2)-1,ix)
65126  t1p2=t1p2+isgn*tjj(1,ix)*p(ijcp(3)-1,ix)
65127  t2p3=t2p3+isgn*tjj(2,ix)*p(ijcp(4)+1,ix)
65128  t2p4=t2p4+isgn*tjj(2,ix)*p(ijcp(5)+1,ix)
65129  IF (jjglue.EQ.0) THEN
65130 C...Junction motion vector dot product gives length when inter-junction
65131 C...gluons absent.
65132  t1t2=t1t2+isgn*tjj(1,ix)*tjj(2,ix)
65133  ELSE
65134 C...Junction motion vector dot products with gluon momenta give length
65135 C...when inter-junction gluons present.
65136  t1g1=t1g1+isgn*tjj(1,ix)*p(ijcp(3)+1,ix)
65137  t2g2=t2g2+isgn*tjj(2,ix)*p(ijcp(4)-1,ix)
65138  ENDIF
65139  580 CONTINUE
65140  delmjj=16d0*t1p1*t1p2*t2p3*t2p4
65141  IF (jjglue.EQ.0) THEN
65142  delmjj=delmjj*(t1t2+sqrt(t1t2**2-1))
65143  ELSE
65144  delmjj=delmjj*4d0*t1g1*t2g2
65145  ENDIF
65146  ENDIF
65147 C...If delmjj > delmqq collapse string system to q-qbar q-qbar
65148 C...(Always the case for MSTJ(19)=2 due to initialization above)
65149  IF (delmjj.GT.delmqq) THEN
65150 C...Put new system at end of event record
65151  ncop=n
65152  DO 650 ist=1,2
65153  DO 600 icop=ijcp(ist),ijcp(ist+1)-1
65154  ncop=ncop+1
65155  DO 590 ix=1,5
65156  p(ncop,ix)=p(icop,ix)
65157  k(ncop,ix)=k(icop,ix)
65158  590 CONTINUE
65159  600 CONTINUE
65160  IF (jjglue.NE.0.AND.ist.EQ.igs) THEN
65161 C...Insert inter-junction gluon string piece (reversed)
65162  njjgl=0
65163  DO 620 icop=ijcp(4)-1,ijcp(3)+1,-1
65164  njjgl=njjgl+1
65165  ncop=ncop+1
65166  DO 610 ix=1,5
65167  p(ncop,ix)=p(icop,ix)
65168  k(ncop,ix)=k(icop,ix)
65169  610 CONTINUE
65170  620 CONTINUE
65171  ENDIF
65172  ifc=-2*ist+3
65173  DO 640 icop=ijcp(ist+ifc*isw+3)+1,ijcp(ist+ifc*isw+4)
65174  ncop=ncop+1
65175  DO 630 ix=1,5
65176  p(ncop,ix)=p(icop,ix)
65177  k(ncop,ix)=k(icop,ix)
65178  630 CONTINUE
65179  640 CONTINUE
65180  k(ncop,1)=1
65181  650 CONTINUE
65182 C...Copy system back in right order
65183  DO 670 icop=nbeg,nend-2
65184  DO 660 ix=1,5
65185  p(icop,ix)=p(n+icop-nbeg+1,ix)
65186  k(icop,ix)=k(n+icop-nbeg+1,ix)
65187  660 CONTINUE
65188  670 CONTINUE
65189 C...Shift down rest of event record
65190  DO 690 icop=nend+1,n
65191  DO 680 ix=1,5
65192  p(icop-2,ix)=p(icop,ix)
65193  k(icop-2,ix)=k(icop,ix)
65194  680 CONTINUE
65195  690 CONTINUE
65196 C...Update length of event record.
65197  n=n-2
65198  ENDIF
65199  mjun1=0
65200  nbeg=i+1
65201  ENDIF
65202  700 CONTINUE
65203  ENDIF
65204  ENDIF
65205 
65206 C...Done if no checks on small-mass systems.
65207  IF(mstj(14).LT.0) RETURN
65208  IF(mstj(14).EQ.0) goto 1140
65209 
65210 C...Find lowest-mass colour singlet jet system.
65211  ns=n
65212  710 nsin=n-ns
65213  pdmin=1d0+parj(32)
65214  ic=0
65215  DO 770 i=max(1,ip),n
65216  IF(k(i,1).NE.1.AND.k(i,1).NE.2) THEN
65217  ELSEIF(k(i,1).EQ.2.AND.ic.EQ.0) THEN
65218  nsin=nsin+1
65219  ic=i
65220  DO 720 j=1,4
65221  dps(j)=p(i,j)
65222  720 CONTINUE
65223  mstj(93)=1
65224  dps(5)=pymass(k(i,2))
65225  ELSEIF(k(i,1).EQ.2.AND.k(i,2).NE.21) THEN
65226  DO 730 j=1,4
65227  dps(j)=dps(j)+p(i,j)
65228  730 CONTINUE
65229  mstj(93)=1
65230  dps(5)=dps(5)+pymass(k(i,2))
65231  ELSEIF(k(i,1).EQ.2) THEN
65232  DO 740 j=1,4
65233  dps(j)=dps(j)+p(i,j)
65234  740 CONTINUE
65235  ELSEIF(ic.NE.0.AND.kchg(pycomp(k(i,2)),2).NE.0) THEN
65236  DO 750 j=1,4
65237  dps(j)=dps(j)+p(i,j)
65238  750 CONTINUE
65239  mstj(93)=1
65240  dps(5)=dps(5)+pymass(k(i,2))
65241  pd=sqrt(max(0d0,dps(4)**2-dps(1)**2-dps(2)**2-dps(3)**2))-
65242  & dps(5)
65243  IF(pd.LT.pdmin) THEN
65244  pdmin=pd
65245  DO 760 j=1,5
65246  dpc(j)=dps(j)
65247  760 CONTINUE
65248  ic1=ic
65249  ic2=i
65250  ENDIF
65251  ic=0
65252  ELSE
65253  nsin=nsin+1
65254  ENDIF
65255  770 CONTINUE
65256 
65257 C...Done if lowest-mass system above threshold for string frag.
65258  IF(pdmin.GE.parj(32)) goto 1140
65259 
65260 C...Fill small-mass system as cluster.
65261  nsav=n
65262  pecm=sqrt(max(0d0,dpc(4)**2-dpc(1)**2-dpc(2)**2-dpc(3)**2))
65263  k(n+1,1)=11
65264  k(n+1,2)=91
65265  k(n+1,3)=ic1
65266  p(n+1,1)=dpc(1)
65267  p(n+1,2)=dpc(2)
65268  p(n+1,3)=dpc(3)
65269  p(n+1,4)=dpc(4)
65270  p(n+1,5)=pecm
65271 
65272 C...Set up history, assuming cluster -> 2 hadrons.
65273  nbody=2
65274  k(n+1,4)=n+2
65275  k(n+1,5)=n+3
65276  k(n+2,1)=1
65277  k(n+3,1)=1
65278  IF(mstu(16).NE.2) THEN
65279  k(n+2,3)=n+1
65280  k(n+3,3)=n+1
65281  ELSE
65282  k(n+2,3)=ic1
65283  k(n+3,3)=ic2
65284  ENDIF
65285  k(n+2,4)=0
65286  k(n+3,4)=0
65287  k(n+2,5)=0
65288  k(n+3,5)=0
65289  v(n+1,5)=0d0
65290  v(n+2,5)=0d0
65291  v(n+3,5)=0d0
65292 
65293 C...Find total flavour content - complicated by presence of junctions.
65294  nq=0
65295  ndiq=0
65296  DO 780 i=ic1,ic2
65297  IF((k(i,1).EQ.1.OR.k(i,1).EQ.2).AND.k(i,2).NE.21) THEN
65298  nq=nq+1
65299  kfq(nq)=k(i,2)
65300  IF(iabs(k(i,2)).GT.1000) ndiq=ndiq+1
65301  ENDIF
65302  780 CONTINUE
65303 
65304 C...If several diquarks, split up one to give even number of flavours.
65305  IF(nq.EQ.3.AND.ndiq.GE.2) THEN
65306  i1=3
65307  IF(iabs(kfq(3)).LT.1000) i1=1
65308  kfq(4)=isign(mod(iabs(kfq(i1))/100,10),kfq(i1))
65309  kfq(i1)=kfq(i1)/1000
65310  nq=4
65311  ndiq=ndiq-1
65312  ENDIF
65313 
65314 C...If four quark ends, join two to diquark.
65315  IF(nq.EQ.4.AND.ndiq.EQ.0) THEN
65316  i1=1
65317  i2=2
65318  IF(kfq(i1)*kfq(i2).LT.0) i2=3
65319  IF(i2.EQ.3.AND.kfq(i1)*kfq(i2).LT.0) i2=4
65320  kfls=2*int(pyr(0)+3d0*parj(4)/(1d0+3d0*parj(4)))+1
65321  IF(kfq(i1).EQ.kfq(i2)) kfls=3
65322  kfq(i1)=isign(1000*max(iabs(kfq(i1)),iabs(kfq(i2)))+
65323  & 100*min(iabs(kfq(i1)),iabs(kfq(i2)))+kfls,kfq(i1))
65324  kfq(i2)=kfq(4)
65325  nq=3
65326  ndiq=1
65327  ENDIF
65328 
65329 C...If two quark ends, plus quark or diquark, join quarks to diquark.
65330  IF(nq.EQ.3) THEN
65331  i1=1
65332  i2=2
65333  IF(iabs(kfq(i1)).GT.1000) i1=3
65334  IF(iabs(kfq(i2)).GT.1000) i2=3
65335  kfls=2*int(pyr(0)+3d0*parj(4)/(1d0+3d0*parj(4)))+1
65336  IF(kfq(i1).EQ.kfq(i2)) kfls=3
65337  kfq(i1)=isign(1000*max(iabs(kfq(i1)),iabs(kfq(i2)))+
65338  & 100*min(iabs(kfq(i1)),iabs(kfq(i2)))+kfls,kfq(i1))
65339  kfq(i2)=kfq(3)
65340  nq=2
65341  ndiq=ndiq+1
65342  ENDIF
65343 
65344 C...Form two particles from flavours of lowest-mass system, if feasible.
65345  ntry = 0
65346  790 ntry = ntry + 1
65347 
65348 C...Open string with two specified endpoint flavours.
65349  IF(nq.EQ.2) THEN
65350  kc1=pycomp(kfq(1))
65351  kc2=pycomp(kfq(2))
65352  IF(kc1.EQ.0.OR.kc2.EQ.0) goto 1140
65353  kq1=kchg(kc1,2)*isign(1,kfq(1))
65354  kq2=kchg(kc2,2)*isign(1,kfq(2))
65355  IF(kq1+kq2.NE.0) goto 1140
65356 C...Start with qq, if there is one. Only allow for rank 1 popcorn meson
65357  800 k1=kfq(1)
65358  IF(iabs(kfq(2)).GT.1000) k1=kfq(2)
65359  mstu(125)=0
65360  CALL pydcyk(k1,0,kfln,k(n+2,2))
65361  CALL pydcyk(kfq(1)+kfq(2)-k1,-kfln,kfldmp,k(n+3,2))
65362  IF(k(n+2,2).EQ.0.OR.k(n+3,2).EQ.0) goto 800
65363 
65364 C...Open string with four specified flavours.
65365  ELSEIF(nq.EQ.4) THEN
65366  kc1=pycomp(kfq(1))
65367  kc2=pycomp(kfq(2))
65368  kc3=pycomp(kfq(3))
65369  kc4=pycomp(kfq(4))
65370  IF(kc1.EQ.0.OR.kc2.EQ.0.OR.kc3.EQ.0.OR.kc4.EQ.0) goto 1140
65371  kq1=kchg(kc1,2)*isign(1,kfq(1))
65372  kq2=kchg(kc2,2)*isign(1,kfq(2))
65373  kq3=kchg(kc3,2)*isign(1,kfq(3))
65374  kq4=kchg(kc4,2)*isign(1,kfq(4))
65375  IF(kq1+kq2+kq3+kq4.NE.0) goto 1140
65376 C...Combine flavours pairwise to form two hadrons.
65377  810 i1=1
65378  i2=2
65379  IF(kq1*kq2.GT.0.OR.(iabs(kfq(1)).GT.1000.AND.
65380  & iabs(kfq(2)).GT.1000)) i2=3
65381  IF(i2.EQ.3.AND.(kq1*kq3.GT.0.OR.(iabs(kfq(1)).GT.1000.AND.
65382  & iabs(kfq(3)).GT.1000))) i2=4
65383  i3=3
65384  IF(i2.EQ.3) i3=2
65385  i4=10-i1-i2-i3
65386  CALL pydcyk(kfq(i1),kfq(i2),kfldmp,k(n+2,2))
65387  CALL pydcyk(kfq(i3),kfq(i4),kfldmp,k(n+3,2))
65388  IF(k(n+2,2).EQ.0.OR.k(n+3,2).EQ.0) goto 810
65389 
65390 C...Closed string.
65391  ELSE
65392  IF(iabs(k(ic2,2)).NE.21) goto 1140
65393 C...No room for popcorn mesons in closed string -> 2 hadrons.
65394  mstu(125)=0
65395  820 CALL pydcyk(1+int((2d0+parj(2))*pyr(0)),0,kfln,kfdmp)
65396  CALL pydcyk(kfln,0,kflm,k(n+2,2))
65397  CALL pydcyk(-kfln,-kflm,kfldmp,k(n+3,2))
65398  IF(k(n+2,2).EQ.0.OR.k(n+3,2).EQ.0) goto 820
65399  ENDIF
65400  p(n+2,5)=pymass(k(n+2,2))
65401  p(n+3,5)=pymass(k(n+3,2))
65402 
65403 C...If it does not work: try again (a number of times), give up (if no
65404 C...place to shuffle momentum or too many flavours), or form one hadron.
65405  IF(p(n+2,5)+p(n+3,5)+parj(64).GE.pecm) THEN
65406  IF(ntry.LT.mstj(17).OR.(nq.EQ.4.AND.ntry.LT.5*mstj(17))) THEN
65407  goto 790
65408  ELSEIF(nsin.EQ.1.OR.nq.EQ.4) THEN
65409  goto 1140
65410  ELSE
65411  goto 890
65412  END IF
65413  END IF
65414 
65415 C...Perform two-particle decay of jet system.
65416 C...First step: find reference axis in decaying system rest frame.
65417 C...(Borrow slot N+2 for temporary direction.)
65418  DO 830 j=1,4
65419  p(n+2,j)=p(ic1,j)
65420  830 CONTINUE
65421  DO 850 i=ic1+1,ic2-1
65422  IF((k(i,1).EQ.1.OR.k(i,1).EQ.2).AND.
65423  & kchg(pycomp(k(i,2)),2).NE.0) THEN
65424  frac1=four(ic2,i)/(four(ic1,i)+four(ic2,i))
65425  DO 840 j=1,4
65426  p(n+2,j)=p(n+2,j)+frac1*p(i,j)
65427  840 CONTINUE
65428  ENDIF
65429  850 CONTINUE
65430  CALL pyrobo(n+2,n+2,0d0,0d0,-dpc(1)/dpc(4),-dpc(2)/dpc(4),
65431  &-dpc(3)/dpc(4))
65432  the1=pyangl(p(n+2,3),sqrt(p(n+2,1)**2+p(n+2,2)**2))
65433  phi1=pyangl(p(n+2,1),p(n+2,2))
65434 
65435 C...Second step: generate isotropic/anisotropic decay.
65436  pa=sqrt((pecm**2-(p(n+2,5)+p(n+3,5))**2)*(pecm**2-
65437  &(p(n+2,5)-p(n+3,5))**2))/(2d0*pecm)
65438  860 ue(3)=pyr(0)
65439  IF(parj(21).LE.0.01d0) ue(3)=1d0
65440  pt2=(1d0-ue(3)**2)*pa**2
65441  IF(mstj(16).LE.0) THEN
65442  prev=0.5d0
65443  ELSE
65444  IF(exp(-pt2/(2d0*max(0.01d0,parj(21))**2)).LT.pyr(0)) goto 860
65445  pr1=p(n+2,5)**2+pt2
65446  pr2=p(n+3,5)**2+pt2
65447  alambd=sqrt(max(0d0,(pecm**2-pr1-pr2)**2-4d0*pr1*pr2))
65448  prevcf=parj(42)
65449  IF(mstj(11).EQ.2) prevcf=parj(39)
65450  prev=1d0/(1d0+exp(min(50d0,prevcf*alambd*parj(40))))
65451  ENDIF
65452  IF(pyr(0).LT.prev) ue(3)=-ue(3)
65453  phi=paru(2)*pyr(0)
65454  ue(1)=sqrt(1d0-ue(3)**2)*cos(phi)
65455  ue(2)=sqrt(1d0-ue(3)**2)*sin(phi)
65456  DO 870 j=1,3
65457  p(n+2,j)=pa*ue(j)
65458  p(n+3,j)=-pa*ue(j)
65459  870 CONTINUE
65460  p(n+2,4)=sqrt(pa**2+p(n+2,5)**2)
65461  p(n+3,4)=sqrt(pa**2+p(n+3,5)**2)
65462 
65463 C...Third step: move back to event frame and set production vertex.
65464  CALL pyrobo(n+2,n+3,the1,phi1,dpc(1)/dpc(4),dpc(2)/dpc(4),
65465  &dpc(3)/dpc(4))
65466  DO 880 j=1,4
65467  v(n+1,j)=v(ic1,j)
65468  v(n+2,j)=v(ic1,j)
65469  v(n+3,j)=v(ic2,j)
65470  880 CONTINUE
65471  n=n+3
65472  goto 1120
65473 
65474 C...Else form one particle, if possible.
65475  890 nbody=1
65476  k(n+1,5)=n+2
65477  DO 900 j=1,4
65478  v(n+1,j)=v(ic1,j)
65479  v(n+2,j)=v(ic1,j)
65480  900 CONTINUE
65481 
65482 C...Select hadron flavour from available quark flavours.
65483  910 IF(nq.EQ.2.AND.iabs(kfq(1)).GT.100.AND.iabs(kfq(2)).GT.100) THEN
65484  goto 1140
65485  ELSEIF(nq.EQ.2) THEN
65486  CALL pykfdi(kfq(1),kfq(2),kfldmp,k(n+2,2))
65487  ELSE
65488  kfln=1+int((2d0+parj(2))*pyr(0))
65489  CALL pykfdi(kfln,-kfln,kfldmp,k(n+2,2))
65490  ENDIF
65491  IF(k(n+2,2).EQ.0) goto 910
65492  p(n+2,5)=pymass(k(n+2,2))
65493 
65494 C...Use old algorithm for E/p conservation? (EN)
65495  IF (mstj(16).LE.0) goto 1080
65496 
65497 C...Find the string piece closest to the cluster by a loop
65498 C...over the undecayed partons not in present cluster. (EN)
65499  dglomi=1d30
65500  ibeg=0
65501  i0=0
65502  njunc=0
65503  DO 940 i1=max(1,ip),n-1
65504  IF(k(i1,1).EQ.1) njunc=0
65505  IF(k(i1,1).EQ.41) njunc=njunc+1
65506  IF(k(i1,1).EQ.41) goto 940
65507  IF(i1.GE.ic1-1.AND.i1.LE.ic2) THEN
65508  i0=0
65509  ELSEIF(k(i1,1).EQ.2) THEN
65510  IF(i0.EQ.0) i0=i1
65511  i2=i1
65512  920 i2=i2+1
65513  IF(k(i2,1).EQ.41) goto 940
65514  IF(k(i2,1).GT.10) goto 920
65515  IF(kchg(pycomp(k(i2,2)),2).EQ.0) goto 920
65516  IF(k(i1,2).EQ.21.AND.k(i2,2).NE.21.AND.k(i2,1).NE.1.AND.
65517  & njunc.EQ.0) goto 940
65518  IF(k(i1,2).NE.21.AND.k(i2,2).EQ.21.AND.njunc.NE.0) goto 940
65519  IF(k(i1,2).NE.21.AND.k(i2,2).NE.21.AND.(i1.GT.i0.OR.
65520  & k(i2,1).NE.1)) goto 940
65521 
65522 C...Define velocity vectors e1, e2, ecl and differences e3, e4.
65523  DO 930 j=1,3
65524  e1(j)=p(i1,j)/p(i1,4)
65525  e2(j)=p(i2,j)/p(i2,4)
65526  ecl(j)=p(n+1,j)/p(n+1,4)
65527  e3(j)=e2(j)-e1(j)
65528  e4(j)=ecl(j)-e1(j)
65529  930 CONTINUE
65530 
65531 C...Calculate minimal D=(e4-alpha*e3)**2 for 0<alpha<1.
65532  e3s=e3(1)**2+e3(2)**2+e3(3)**2
65533  e4s=e4(1)**2+e4(2)**2+e4(3)**2
65534  e34=e3(1)*e4(1)+e3(2)*e4(2)+e3(3)*e4(3)
65535  IF(e34.LE.0d0) THEN
65536  ddmin=e4s
65537  ELSEIF(e34.LT.e3s) THEN
65538  ddmin=e4s-e34**2/e3s
65539  ELSE
65540  ddmin=e4s-2d0*e34+e3s
65541  ENDIF
65542 
65543 C...Is this the smallest so far?
65544  IF(ddmin.LT.dglomi) THEN
65545  dglomi=ddmin
65546  ibeg=i0
65547  ipcs=i1
65548  ENDIF
65549  ELSEIF(k(i1,1).EQ.1.AND.kchg(pycomp(k(i1,2)),2).NE.0) THEN
65550  i0=0
65551  ENDIF
65552  940 CONTINUE
65553 
65554 C... Check if there are any strings to connect to the new gluon. (EN)
65555  IF (ibeg.EQ.0) goto 1080
65556 
65557 C...Delta_m = m_clus - m_had > 0: emit a 'gluon' (EN)
65558  IF (p(n+1,5).GE.p(n+2,5)) THEN
65559 
65560 C...Construct 'gluon' that is needed to put hadron on the mass shell.
65561  frac=p(n+2,5)/p(n+1,5)
65562  DO 950 j=1,5
65563  p(n+2,j)=frac*p(n+1,j)
65564  pg(j)=(1d0-frac)*p(n+1,j)
65565  950 CONTINUE
65566 
65567 C... Copy string with new gluon put in.
65568  n=n+2
65569  i=ibeg-1
65570  960 i=i+1
65571  IF(k(i,1).NE.1.AND.k(i,1).NE.2.AND.k(i,1).NE.41) goto 960
65572  IF(kchg(pycomp(k(i,2)),2).EQ.0.AND.k(i,1).NE.41) goto 960
65573  n=n+1
65574  DO 970 j=1,5
65575  k(n,j)=k(i,j)
65576  p(n,j)=p(i,j)
65577  v(n,j)=v(i,j)
65578  970 CONTINUE
65579  k(i,1)=k(i,1)+10
65580  k(i,4)=n
65581  k(i,5)=n
65582  k(n,3)=i
65583  IF(i.EQ.ipcs) THEN
65584  n=n+1
65585  DO 980 j=1,5
65586  k(n,j)=k(n-1,j)
65587  p(n,j)=pg(j)
65588  v(n,j)=v(n-1,j)
65589  980 CONTINUE
65590  k(n,2)=21
65591  k(n,3)=nsav+1
65592  ENDIF
65593  IF(k(i,1).EQ.12.OR.k(i,1).EQ.51) goto 960
65594  goto 1120
65595 
65596 C...Delta_m = m_clus - m_had < 0: have to absorb a 'gluon' instead,
65597 C...from string piece endpoints.
65598  ELSE
65599 
65600 C...Begin by copying string that should give energy to cluster.
65601  n=n+2
65602  i=ibeg-1
65603  990 i=i+1
65604  IF(k(i,1).NE.1.AND.k(i,1).NE.2.AND.k(i,1).NE.41) goto 990
65605  IF(kchg(pycomp(k(i,2)),2).EQ.0.AND.k(i,1).NE.41) goto 990
65606  n=n+1
65607  DO 1000 j=1,5
65608  k(n,j)=k(i,j)
65609  p(n,j)=p(i,j)
65610  v(n,j)=v(i,j)
65611  1000 CONTINUE
65612  k(i,1)=k(i,1)+10
65613  k(i,4)=n
65614  k(i,5)=n
65615  k(n,3)=i
65616  IF(i.EQ.ipcs) i1=n
65617  IF(k(i,1).EQ.12.OR.k(i,1).EQ.51) goto 990
65618  i2=i1+1
65619 
65620 C...Set initial Phad.
65621  DO 1010 j=1,4
65622  p(nsav+2,j)=p(nsav+1,j)
65623  1010 CONTINUE
65624 
65625 C...Calculate Pg, a part of which will be added to Phad later. (EN)
65626  1020 IF(mstj(16).EQ.1) THEN
65627  alpha=1d0
65628  beta=1d0
65629  ELSE
65630  alpha=four(nsav+1,i2)/four(i1,i2)
65631  beta=four(nsav+1,i1)/four(i1,i2)
65632  ENDIF
65633  DO 1030 j=1,4
65634  pg(j)=alpha*p(i1,j)+beta*p(i2,j)
65635  1030 CONTINUE
65636  pg(5)=sqrt(max(1d-20,pg(4)**2-pg(1)**2-pg(2)**2-pg(3)**2))
65637 
65638 C..Solve 2nd order equation, use the best (smallest) solution. (EN)
65639  pmscol=p(nsav+2,4)**2-p(nsav+2,1)**2-p(nsav+2,2)**2-
65640  & p(nsav+2,3)**2
65641  pclpg=(p(nsav+2,4)*pg(4)-p(nsav+2,1)*pg(1)-
65642  & p(nsav+2,2)*pg(2)-p(nsav+2,3)*pg(3))/pg(5)**2
65643  delta=sqrt(pclpg**2+(p(nsav+2,5)**2-pmscol)/pg(5)**2)-pclpg
65644 
65645 C...If all gluon energy eaten, zero it and take a step back.
65646  iter=0
65647  IF(delta*alpha.GT.1d0.AND.i1.GT.nsav+3.AND.k(i1,2).EQ.21) THEN
65648  iter=1
65649  DO 1040 j=1,4
65650  p(nsav+2,j)=p(nsav+2,j)+p(i1,j)
65651  p(i1,j)=0d0
65652  1040 CONTINUE
65653  p(i1,5)=0d0
65654  k(i1,1)=k(i1,1)+10
65655  i1=i1-1
65656  IF(k(i1,1).EQ.41) iter=-1
65657  ENDIF
65658  IF(delta*beta.GT.1d0.AND.i2.LT.n.AND.k(i2,2).EQ.21) THEN
65659  iter=1
65660  DO 1050 j=1,4
65661  p(nsav+2,j)=p(nsav+2,j)+p(i2,j)
65662  p(i2,j)=0d0
65663  1050 CONTINUE
65664  p(i2,5)=0d0
65665  k(i2,1)=k(i2,1)+10
65666  i2=i2+1
65667  IF(k(i2,1).EQ.41) iter=-1
65668  ENDIF
65669  IF(iter.EQ.1) goto 1020
65670 
65671 C...If also all endpoint energy eaten, revert to old procedure.
65672  IF((1d0-delta*alpha)*p(i1,4).LT.p(i1,5).OR.
65673  & (1d0-delta*beta)*p(i2,4).LT.p(i2,5).OR.iter.EQ.-1) THEN
65674  DO 1060 i=nsav+3,n
65675  im=k(i,3)
65676  k(im,1)=k(im,1)-10
65677  k(im,4)=0
65678  k(im,5)=0
65679  1060 CONTINUE
65680  n=nsav
65681  goto 1080
65682  ENDIF
65683 
65684 C... Construct the collapsed hadron and modified string partons.
65685  DO 1070 j=1,4
65686  p(nsav+2,j)=p(nsav+2,j)+delta*pg(j)
65687  p(i1,j)=(1d0-delta*alpha)*p(i1,j)
65688  p(i2,j)=(1d0-delta*beta)*p(i2,j)
65689  1070 CONTINUE
65690  p(i1,5)=(1d0-delta*alpha)*p(i1,5)
65691  p(i2,5)=(1d0-delta*beta)*p(i2,5)
65692 
65693 C...Finished with string collapse in new scheme.
65694  goto 1120
65695  ENDIF
65696 
65697 C... Use old algorithm; by choice or when in trouble.
65698  1080 CONTINUE
65699 C...Find parton/particle which combines to largest extra mass.
65700  ir=0
65701  ha=0d0
65702  hsm=0d0
65703  DO 1100 mcomb=1,3
65704  IF(ir.NE.0) goto 1100
65705  DO 1090 i=max(1,ip),n
65706  IF(k(i,1).LE.0.OR.k(i,1).GT.10.OR.(i.GE.ic1.AND.i.LE.ic2
65707  & .AND.k(i,1).GE.1.AND.k(i,1).LE.2)) goto 1090
65708  IF(mcomb.EQ.1) kci=pycomp(k(i,2))
65709  IF(mcomb.EQ.1.AND.kci.EQ.0) goto 1090
65710  IF(mcomb.EQ.1.AND.kchg(kci,2).EQ.0.AND.i.LE.ns) goto 1090
65711  IF(mcomb.EQ.2.AND.iabs(k(i,2)).GT.10.AND.iabs(k(i,2)).LE.100)
65712  & goto 1090
65713  hcr=dpc(4)*p(i,4)-dpc(1)*p(i,1)-dpc(2)*p(i,2)-dpc(3)*p(i,3)
65714  hsr=2d0*hcr+pecm**2-p(n+2,5)**2-2d0*p(n+2,5)*p(i,5)
65715  IF(hsr.GT.hsm) THEN
65716  ir=i
65717  ha=hcr
65718  hsm=hsr
65719  ENDIF
65720  1090 CONTINUE
65721  1100 CONTINUE
65722 
65723 C...Shuffle energy and momentum to put new particle on mass shell.
65724  IF(ir.NE.0) THEN
65725  hb=pecm**2+ha
65726  hc=p(n+2,5)**2+ha
65727  hd=p(ir,5)**2+ha
65728  hk2=0.5d0*(hb*sqrt(max(0d0,((hb+hc)**2-4d0*(hb+hd)*p(n+2,5)**2)/
65729  & (ha**2-(pecm*p(ir,5))**2)))-(hb+hc))/(hb+hd)
65730  hk1=(0.5d0*(p(n+2,5)**2-pecm**2)+hd*hk2)/hb
65731  DO 1110 j=1,4
65732  p(n+2,j)=(1d0+hk1)*dpc(j)-hk2*p(ir,j)
65733  p(ir,j)=(1d0+hk2)*p(ir,j)-hk1*dpc(j)
65734  1110 CONTINUE
65735  n=n+2
65736  ELSE
65737  CALL pyerrm(3,'(PYPREP:) no match for collapsing cluster')
65738  RETURN
65739  ENDIF
65740 
65741 C...Mark collapsed system and store daughter pointers. Iterate.
65742  1120 DO 1130 i=ic1,ic2
65743  IF((k(i,1).EQ.1.OR.k(i,1).EQ.2).AND.
65744  & kchg(pycomp(k(i,2)),2).NE.0) THEN
65745  k(i,1)=k(i,1)+10
65746  IF(mstu(16).NE.2) THEN
65747  k(i,4)=nsav+1
65748  k(i,5)=nsav+1
65749  ELSE
65750  k(i,4)=nsav+2
65751  k(i,5)=nsav+1+nbody
65752  ENDIF
65753  ENDIF
65754  IF(k(i,1).EQ.41) k(i,1)=k(i,1)+10
65755  1130 CONTINUE
65756  IF(n.LT.mstu(4)-mstu(32)-5) goto 710
65757 
65758 C...Check flavours and invariant masses in parton systems.
65759  1140 np=0
65760  kfn=0
65761  kqs=0
65762  nju=0
65763  DO 1150 j=1,5
65764  dps(j)=0d0
65765  1150 CONTINUE
65766  DO 1180 i=max(1,ip),n
65767  IF(k(i,1).EQ.41) nju=nju+1
65768  IF(k(i,1).LE.0.OR.k(i,1).GT.10) goto 1180
65769  kc=pycomp(k(i,2))
65770  IF(kc.EQ.0) goto 1180
65771  kq=kchg(kc,2)*isign(1,k(i,2))
65772  IF(kq.EQ.0) goto 1180
65773  np=np+1
65774  IF(kq.NE.2) THEN
65775  kfn=kfn+1
65776  kqs=kqs+kq
65777  mstj(93)=1
65778  dps(5)=dps(5)+pymass(k(i,2))
65779  ENDIF
65780  DO 1160 j=1,4
65781  dps(j)=dps(j)+p(i,j)
65782  1160 CONTINUE
65783  IF(k(i,1).EQ.1) THEN
65784  nferr=0
65785  IF(nju.EQ.0.AND.np.NE.1) THEN
65786  IF(kfn.EQ.1.OR.kfn.GE.3.OR.kqs.NE.0) nferr=1
65787  ELSEIF(nju.EQ.1) THEN
65788  IF(kfn.NE.3.OR.iabs(kqs).NE.3) nferr=1
65789  ELSEIF(nju.EQ.2) THEN
65790  IF(kfn.NE.4.OR.kqs.NE.0) nferr=1
65791  ELSEIF(nju.GE.3) THEN
65792  nferr=1
65793  ENDIF
65794  IF(nferr.EQ.1) THEN
65795  CALL pyerrm(2,'(PYPREP:) unphysical flavour combination')
65796  mint(51)=1
65797  RETURN
65798  ENDIF
65799  IF(np.NE.1.AND.dps(4)**2-dps(1)**2-dps(2)**2-dps(3)**2.LT.
65800  & (0.9d0*parj(32)+dps(5))**2) CALL pyerrm(3,
65801  & '(PYPREP:) too small mass in jet system')
65802  np=0
65803  kfn=0
65804  kqs=0
65805  nju=0
65806  DO 1170 j=1,5
65807  dps(j)=0d0
65808  1170 CONTINUE
65809  ENDIF
65810  1180 CONTINUE
65811 
65812  RETURN
65813  END
65814 
65815 C*********************************************************************
65816 
65817 C...PYSTRF
65818 C...Handles the fragmentation of an arbitrary colour singlet
65819 C...jet system according to the Lund string fragmentation model.
65820 
65821  SUBROUTINE pystrf(IP)
65822 
65823 C...Double precision and integer declarations.
65824  IMPLICIT DOUBLE PRECISION(a-h, o-z)
65825  IMPLICIT INTEGER(i-n)
65826  INTEGER pyk,pychge,pycomp
65827 C...Commonblocks.
65828  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
65829  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
65830  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
65831  SAVE /pyjets/,/pydat1/,/pydat2/
65832 C...Local arrays. All MOPS variables ends with MO
65833  dimension dps(5),kfl(3),pmq(3),px(3),py(3),gam(3),ie(2),pr(2),
65834  &in(9),dhm(4),dhg(4),dp(5,5),irank(2),mju(4),iju(6),pju(5,5),
65835  &tju(5),kfjh(2),njs(2),kfjs(2),pjs(4,5),mstu9t(8),paru9t(8),
65836  &inmo(9),pm2qmo(2),xtmo(2),ejstr(2),ijuori(2),ibarrk(2),
65837  &pbst(3,5),tjuold(5)
65838 
65839 C...Function: four-product of two vectors.
65840  four(i,j)=p(i,4)*p(j,4)-p(i,1)*p(j,1)-p(i,2)*p(j,2)-p(i,3)*p(j,3)
65841  dfour(i,j)=dp(i,4)*dp(j,4)-dp(i,1)*dp(j,1)-dp(i,2)*dp(j,2)-
65842  &dp(i,3)*dp(j,3)
65843 
65844 C...Reset counters.
65845  mstj(91)=0
65846  nsav=n
65847  mstu90=mstu(90)
65848  np=0
65849  kqsum=0
65850  DO 100 j=1,5
65851  dps(j)=0d0
65852  100 CONTINUE
65853  mju(1)=0
65854  mju(2)=0
65855  ntryfn=0
65856  ijuori(1)=0
65857  ijuori(2)=0
65858 
65859 C...Identify parton system.
65860  i=ip-1
65861  110 i=i+1
65862  IF(i.GT.min(n,mstu(4)-mstu(32))) THEN
65863  CALL pyerrm(12,'(PYSTRF:) failed to reconstruct jet system')
65864  IF(mstu(21).GE.1) RETURN
65865  ENDIF
65866  IF(k(i,1).NE.1.AND.k(i,1).NE.2.AND.k(i,1).NE.41) goto 110
65867  kc=pycomp(k(i,2))
65868  IF(kc.EQ.0) goto 110
65869  kq=kchg(kc,2)*isign(1,k(i,2))
65870  IF(kq.EQ.0.AND.k(i,1).NE.41) goto 110
65871  IF(n+5*np+11.GT.mstu(4)-mstu(32)-5) THEN
65872  CALL pyerrm(11,'(PYSTRF:) no more memory left in PYJETS')
65873  IF(mstu(21).GE.1) RETURN
65874  ENDIF
65875 
65876 C...Take copy of partons to be considered. Check flavour sum.
65877  np=np+1
65878  DO 120 j=1,5
65879  k(n+np,j)=k(i,j)
65880  p(n+np,j)=p(i,j)
65881  IF(j.NE.4) dps(j)=dps(j)+p(i,j)
65882  120 CONTINUE
65883  dps(4)=dps(4)+sqrt(p(i,1)**2+p(i,2)**2+p(i,3)**2+p(i,5)**2)
65884  k(n+np,3)=i
65885  IF(kq.NE.2) kqsum=kqsum+kq
65886  IF(k(i,1).EQ.41) THEN
65887  IF(mod(kqsum,2).EQ.0.AND.mju(1).EQ.0) THEN
65888  mju(1)=n+np
65889  ijuori(1)=i
65890  ELSE
65891  mju(2)=n+np
65892  ijuori(2)=i
65893  ENDIF
65894  ENDIF
65895  IF(k(i,1).EQ.2.OR.k(i,1).EQ.41) goto 110
65896  IF(mod(kqsum,3).NE.0) THEN
65897  CALL pyerrm(12,'(PYSTRF:) unphysical flavour combination')
65898  IF(mstu(21).GE.1) RETURN
65899  ENDIF
65900  IF(mju(1).GT.0.OR.mju(2).GT.0) mstu(29)=1
65901 
65902 C...Boost copied system to CM frame (for better numerical precision).
65903  IF(abs(dps(3)).LT.0.99d0*dps(4)) THEN
65904  mbst=0
65905  mstu(33)=1
65906  CALL pyrobo(n+1,n+np,0d0,0d0,-dps(1)/dps(4),-dps(2)/dps(4),
65907  & -dps(3)/dps(4))
65908  ELSE
65909  mbst=1
65910  hhbz=sqrt(max(1d-6,dps(4)+dps(3))/max(1d-6,dps(4)-dps(3)))
65911  DO 130 i=n+1,n+np
65912  hhpmt=p(i,1)**2+p(i,2)**2+p(i,5)**2
65913  IF(p(i,3).GT.0d0) THEN
65914  hhpez=max(1d-10,(p(i,4)+p(i,3))/hhbz)
65915  p(i,3)=0.5d0*(hhpez-hhpmt/hhpez)
65916  p(i,4)=0.5d0*(hhpez+hhpmt/hhpez)
65917  ELSE
65918  hhpez=max(1d-10,(p(i,4)-p(i,3))*hhbz)
65919  p(i,3)=-0.5d0*(hhpez-hhpmt/hhpez)
65920  p(i,4)=0.5d0*(hhpez+hhpmt/hhpez)
65921  ENDIF
65922  130 CONTINUE
65923  ENDIF
65924 
65925 C...Search for very nearby partons that may be recombined.
65926  ntryr=0
65927  ntrywr=0
65928  paru12=paru(12)
65929  paru13=paru(13)
65930  mju(3)=mju(1)
65931  mju(4)=mju(2)
65932  nr=np
65933  nrmin=2
65934  IF(mju(1).GT.0) nrmin=nrmin+2
65935  IF(mju(2).GT.0) nrmin=nrmin+2
65936  140 IF(nr.GT.nrmin) THEN
65937  pdrmin=2d0*paru12
65938  DO 150 i=n+1,n+nr
65939  IF(i.EQ.n+nr.AND.iabs(k(n+1,2)).NE.21) goto 150
65940  i1=i+1
65941  IF(i.EQ.n+nr) i1=n+1
65942  IF(k(i,1).EQ.41.OR.k(i1,1).EQ.41) goto 150
65943  IF(mju(1).NE.0.AND.i1.LT.mju(1).AND.iabs(k(i1,2)).NE.21)
65944  & goto 150
65945  IF(mju(2).NE.0.AND.i.GT.mju(2).AND.iabs(k(i,2)).NE.21)
65946  & goto 150
65947  pap=sqrt((p(i,1)**2+p(i,2)**2+p(i,3)**2)*(p(i1,1)**2+
65948  & p(i1,2)**2+p(i1,3)**2))
65949  pvp=p(i,1)*p(i1,1)+p(i,2)*p(i1,2)+p(i,3)*p(i1,3)
65950  pdr=4d0*(pap-pvp)**2/max(1d-6,paru13**2*pap+2d0*(pap-pvp))
65951  IF(pdr.LT.pdrmin) THEN
65952  ir=i
65953  pdrmin=pdr
65954  ENDIF
65955  150 CONTINUE
65956 
65957 C...Recombine very nearby partons to avoid machine precision problems.
65958  IF(pdrmin.LT.paru12.AND.ir.EQ.n+nr) THEN
65959  DO 160 j=1,4
65960  p(n+1,j)=p(n+1,j)+p(n+nr,j)
65961  160 CONTINUE
65962  p(n+1,5)=sqrt(max(0d0,p(n+1,4)**2-p(n+1,1)**2-p(n+1,2)**2-
65963  & p(n+1,3)**2))
65964  nr=nr-1
65965  goto 140
65966  ELSEIF(pdrmin.LT.paru12) THEN
65967  DO 170 j=1,4
65968  p(ir,j)=p(ir,j)+p(ir+1,j)
65969  170 CONTINUE
65970  p(ir,5)=sqrt(max(0d0,p(ir,4)**2-p(ir,1)**2-p(ir,2)**2-
65971  & p(ir,3)**2))
65972  IF(mju(2).NE.0.AND.ir.GT.mju(2)) k(ir,2)=k(ir+1,2)
65973  DO 190 i=ir+1,n+nr-1
65974  k(i,1)=k(i+1,1)
65975  k(i,2)=k(i+1,2)
65976  DO 180 j=1,5
65977  p(i,j)=p(i+1,j)
65978  180 CONTINUE
65979  190 CONTINUE
65980  IF(ir.EQ.n+nr-1) k(ir,2)=k(n+nr,2)
65981  nr=nr-1
65982  IF(mju(1).GT.ir) mju(1)=mju(1)-1
65983  IF(mju(2).GT.ir) mju(2)=mju(2)-1
65984  goto 140
65985  ENDIF
65986  ENDIF
65987  ntryr=ntryr+1
65988 
65989 C...Reset particle counter. Skip ahead if no junctions are present;
65990 C...this is usually the case!
65991  nrs=max(5*nr+11,np)
65992  ntry=0
65993  200 ntry=ntry+1
65994  IF(ntry.GT.100.AND.ntryr.LE.8.AND.nr.GT.nrmin) THEN
65995  paru12=4d0*paru12
65996  paru13=2d0*paru13
65997  goto 140
65998  ELSEIF(ntry.GT.100.OR.ntryr.GT.100) THEN
65999  CALL pyerrm(14,'(PYSTRF:) caught in infinite loop')
66000  IF(mstu(21).GE.1) RETURN
66001  ENDIF
66002  i=n+nrs
66003  mstu(90)=mstu90
66004  IF(mju(1).EQ.0.AND.mju(2).EQ.0) goto 650
66005  IF(mstj(12).GE.4) CALL pyerrm(29,'(PYSTRF:) sorry,'//
66006  & ' junction strings not handled by MSTJ(12)>3 options')
66007  DO 640 jt=1,2
66008  njs(jt)=0
66009  IF(mju(jt).EQ.0) goto 640
66010  js=3-2*jt
66011 
66012 C++SKANDS
66013 C...Find and sum up momentum on three sides of junction.
66014 C...Begin with previous boost = zero.
66015  ijrfit=0
66016  DO 210 ix=1,3
66017  tjuold(ix)=0d0
66018  210 CONTINUE
66019 C...Prevent IJU (specifically IJU(5)) from containing junk below
66020  DO 215 iu=1,6
66021  iju(iu)=0
66022  215 CONTINUE
66023  tjuold(4)=1d0
66024  220 iu=0
66025 C...Beginning and end of string system in event record.
66026  i1beg=n+1+(jt-1)*(nr-1)
66027  i1end=n+nr+(jt-1)*(1-nr)
66028 C...Look for junction string piece end points
66029  DO 230 i1=i1beg,i1end,js
66030  IF(k(i1,2).NE.21.AND.iu.LE.5.AND.ijrfit.EQ.0) THEN
66031 C...Store junction string piece end points.
66032 C 1-junction systems 2-junction systems
66033 C IU : 1 2 3 4 1 2 3 4 5 6
66034 C IJU(IU): q-g-g-q-g-g-j-g-q q-g-g-q-g-j-g-g-j-g-q-g-g-q
66035  iu=iu+1
66036  iju(iu)=i1
66037  ENDIF
66038 C...Sum over momenta, from junction outwards.
66039  230 CONTINUE
66040  DO 280 iu=1,3
66041  pwt=0d0
66042 C...Initialize junction drag and string piece 4-vectors.
66043  DO 240 j=1,5
66044  pbst(iu,j)=0d0
66045  pju(iu,j)=0d0
66046  240 CONTINUE
66047 C...First two branches. Inwards out means opposite direction to JS.
66048 C...(JS is 1 for JT=1, -1 for JT=2)
66049  IF (iu.LT.3) THEN
66050  i1a=iju(iu+1)-js
66051  i1b=iju(iu)
66052  idir=-js
66053 C...Last branch (gq or gjgqgq). Direction now reversed.
66054  ELSE
66055  i1a=iju(iu)+js
66056  i1b=i1end
66057  idir=js
66058  ENDIF
66059  DO 270 i1=i1a,i1b,idir
66060 C...Sum up momentum directions with exponential suppression
66061 C...for use in finding junction rest frame below.
66062  IF (k(i1,2).EQ.88) THEN
66063 C...gjgqgq type system encountered. Use current PWT as start
66064 C...for both strings.
66065  pwtold=pwt
66066  ELSE
66067  IF (i1.EQ.iju(5)+idir) pwt=pwtold
66068 C...Sum up string piece (boosted) 4-momenta.
66069  DO 250 j=1,4
66070  pju(iu,j)=pju(iu,j)+p(i1,j)
66071  250 CONTINUE
66072 C...Compute "junction drag" vectors from (boosted) 4-momenta (initial
66073 C...boost is zero, see above). Skip parton if suppression factor large.
66074  IF (pwt.GT.10d0) goto 270
66075 C...Compute momentum in current frame:
66076  tdp=tjuold(1)*p(i1,1)+tjuold(2)*p(i1,2)+tjuold(3)*p(i1,3)
66077  bfc=tdp/(1d0+tjuold(4))+p(i1,4)
66078  DO 260 j=1,3
66079  ptmp=p(i1,j)+tjuold(j)*bfc
66080  pbst(iu,j)=pbst(iu,j)+ptmp*exp(-pwt)
66081  260 CONTINUE
66082 C...Boosted energy
66083  ptmp=tjuold(4)*p(i1,4)+tdp
66084  pbst(iu,4)=pbst(iu,j)+ptmp*exp(-pwt)
66085  pwt=pwt+ptmp/parj(48)
66086  ENDIF
66087  270 CONTINUE
66088 C...Put |p| rather than m in 5th slot.
66089  pbst(iu,5)=sqrt(pbst(iu,1)**2+pbst(iu,2)**2+pbst(iu,3)**2)
66090  pju(iu,5)=sqrt(pju(iu,1)**2+pju(iu,2)**2+pju(iu,3)**2)
66091  280 CONTINUE
66092 
66093 C...Calculate boost from present frame to next JRF candidate.
66094  ijrfit=ijrfit+1
66095  CALL pyjurf(pbst,tju)
66096 
66097 C...After some iterations do not take full step in new direction.
66098  IF(ijrfit.GT.5) THEN
66099  reduce=0.8d0**(ijrfit-5)
66100  tju(1)=reduce*tju(1)
66101  tju(2)=reduce*tju(2)
66102  tju(3)=reduce*tju(3)
66103  tju(4)=sqrt(1d0+tju(1)**2+tju(2)**2+tju(3)**2)
66104  ENDIF
66105 
66106 C...Combine new boost (TJU) with old boost (TJUOLD)
66107  tmp=tju(1)*tjuold(1)+tju(2)*tjuold(2)+tju(3)*tjuold(3)
66108  DO 290 ix=1,3
66109  tjuold(ix)=tju(ix)+tjuold(ix)*(tmp/(1d0+tjuold(4))+tju(4))
66110  290 CONTINUE
66111  tjuold(4)=sqrt(1d0+tjuold(1)**2+tjuold(2)**2+tjuold(3)**2)
66112 
66113 C...If last boost small, accept JRF, else iterate.
66114 C...Also prevent possibility of infinite loop.
66115  IF (abs((tju(4)-1d0)/tjuold(4)).GT.0.01d0.AND.
66116  & ijrfit.LT.mstj(18)) THEN
66117  goto 220
66118  ELSEIF (ijrfit.GE.mstj(18)) THEN
66119  CALL pyerrm(1,'(PYSTRF:) failed to converge on JRF')
66120  ENDIF
66121 
66122 C...Now store total boost in TJU and change perception.
66123 C...TJUOLD = boost vector from CM of string syst -> JRF. Henceforth,
66124 C...TJU = junction motion vector in string CM, so the sign changes.
66125  DO 300 j=1,3
66126  tju(j)=-tjuold(j)
66127  300 CONTINUE
66128  tju(4)=sqrt(1d0+tju(1)**2+tju(2)**2+tju(3)**2)
66129 
66130 C--SKANDS
66131 
66132 C...Calculate string piece energies in junction rest frame.
66133  DO 310 iu=1,3
66134  pju(iu,5)=tju(4)*pju(iu,4)-tju(1)*pju(iu,1)-tju(2)*pju(iu,2)-
66135  & tju(3)*pju(iu,3)
66136  pbst(iu,5)=tju(4)*pbst(iu,4)-tju(1)*pbst(iu,1)-
66137  & tju(2)*pbst(iu,2)-tju(3)*pbst(iu,3)
66138  310 CONTINUE
66139 
66140 C...Start preparing for fragmentation of two strings from junction.
66141  ista=i
66142  ntryer=0
66143  320 ntryer=ntryer+1
66144  i=ista
66145  DO 620 iu=1,2
66146  ns=iabs(iju(iu+1)-iju(iu))
66147 
66148 C...Junction strings: find longitudinal string directions.
66149  DO 350 is=1,ns
66150  is1=iju(iu)+js*(is-1)
66151  is2=iju(iu)+js*is
66152  DO 330 j=1,5
66153  dp(1,j)=0.5d0*p(is1,j)
66154  IF(is.EQ.1) dp(1,j)=p(is1,j)
66155  dp(2,j)=0.5d0*p(is2,j)
66156  IF(is.EQ.ns) dp(2,j)=(-pbst(iu,j)+2d0*pbst(iu,5)*tju(j))*
66157  & (pju(iu,5)/pbst(iu,5))
66158  330 CONTINUE
66159  IF(is.EQ.ns) dp(2,5)=sqrt(max(0d0,pju(iu,4)**2-
66160  & pju(iu,1)**2-pju(iu,2)**2-pju(iu,3)**2))
66161  dp(3,5)=dfour(1,1)
66162  dp(4,5)=dfour(2,2)
66163  dhkc=dfour(1,2)
66164  IF(dp(3,5)+2d0*dhkc+dp(4,5).LE.0d0) THEN
66165  dp(1,4)=sqrt(dp(1,1)**2+dp(1,2)**2+dp(1,3)**2)
66166  dp(2,4)=sqrt(dp(2,1)**2+dp(2,2)**2+dp(2,3)**2)
66167  dp(3,5)=0d0
66168  dp(4,5)=0d0
66169  dhkc=dfour(1,2)
66170  ENDIF
66171  dhks=sqrt(dhkc**2-dp(3,5)*dp(4,5))
66172  dhk1=0.5d0*((dp(4,5)+dhkc)/dhks-1d0)
66173  dhk2=0.5d0*((dp(3,5)+dhkc)/dhks-1d0)
66174  in1=n+nr+4*is-3
66175  p(in1,5)=sqrt(dp(3,5)+2d0*dhkc+dp(4,5))
66176  DO 340 j=1,4
66177  p(in1,j)=(1d0+dhk1)*dp(1,j)-dhk2*dp(2,j)
66178  p(in1+1,j)=(1d0+dhk2)*dp(2,j)-dhk1*dp(1,j)
66179  340 CONTINUE
66180  350 CONTINUE
66181 
66182 C...Junction strings: initialize flavour, momentum and starting pos.
66183  isav=i
66184  mstu91=mstu(90)
66185  360 ntry=ntry+1
66186  IF(ntry.GT.100.AND.ntryr.LE.8.AND.nr.GT.nrmin) THEN
66187  paru12=4d0*paru12
66188  paru13=2d0*paru13
66189  goto 140
66190  ELSEIF(ntry.GT.100) THEN
66191  CALL pyerrm(14,'(PYSTRF:) caught in infinite loop')
66192  IF(mstu(21).GE.1) RETURN
66193  ENDIF
66194  i=isav
66195  mstu(90)=mstu91
66196  irankj=0
66197  ie(1)=k(n+1+(jt/2)*(np-1),3)
66198  IF (mod(jt+iu,2).NE.0) THEN
66199  ie(1)=k(iju(iu),3)
66200  IF (np-nr.NE.0) THEN
66201 C...If gluons have disappeared. Original IJU must be used.
66202  it=ip
66203  ne=1
66204  370 it=it+1
66205  IF (k(it,2).NE.21) THEN
66206  ne=ne+1
66207  ENDIF
66208  IF (ne.EQ.iu+4*(jt-1)) THEN
66209  ie(1)=it
66210  ELSEIF (it.LE.ip+np) THEN
66211  goto 370
66212  ELSE
66213  CALL pyerrm(14,'(PYSTRF:) '//
66214  & 'Original IJU could not be reconstructed!')
66215  ENDIF
66216  ENDIF
66217  ENDIF
66218  in(4)=n+nr+1
66219  in(5)=in(4)+1
66220  in(6)=n+nr+4*ns+1
66221  DO 390 jq=1,2
66222  DO 380 in1=n+nr+2+jq,n+nr+4*ns-2+jq,4
66223  p(in1,1)=2-jq
66224  p(in1,2)=jq-1
66225  p(in1,3)=1d0
66226  380 CONTINUE
66227  390 CONTINUE
66228  kfl(1)=k(iju(iu),2)
66229  px(1)=0d0
66230  py(1)=0d0
66231  gam(1)=0d0
66232  DO 400 j=1,5
66233  pju(iu+3,j)=0d0
66234  400 CONTINUE
66235 
66236 C...Junction strings: find initial transverse directions.
66237  DO 410 j=1,4
66238  dp(1,j)=p(in(4),j)
66239  dp(2,j)=p(in(4)+1,j)
66240  dp(3,j)=0d0
66241  dp(4,j)=0d0
66242  410 CONTINUE
66243  dp(1,4)=sqrt(dp(1,1)**2+dp(1,2)**2+dp(1,3)**2)
66244  dp(2,4)=sqrt(dp(2,1)**2+dp(2,2)**2+dp(2,3)**2)
66245  dp(5,1)=dp(1,1)/dp(1,4)-dp(2,1)/dp(2,4)
66246  dp(5,2)=dp(1,2)/dp(1,4)-dp(2,2)/dp(2,4)
66247  dp(5,3)=dp(1,3)/dp(1,4)-dp(2,3)/dp(2,4)
66248  IF(dp(5,1)**2.LE.dp(5,2)**2+dp(5,3)**2) dp(3,1)=1d0
66249  IF(dp(5,1)**2.GT.dp(5,2)**2+dp(5,3)**2) dp(3,3)=1d0
66250  IF(dp(5,2)**2.LE.dp(5,1)**2+dp(5,3)**2) dp(4,2)=1d0
66251  IF(dp(5,2)**2.GT.dp(5,1)**2+dp(5,3)**2) dp(4,3)=1d0
66252  dhc12=dfour(1,2)
66253  dhcx1=dfour(3,1)/dhc12
66254  dhcx2=dfour(3,2)/dhc12
66255  dhcxx=1d0/sqrt(1d0+2d0*dhcx1*dhcx2*dhc12)
66256  dhcy1=dfour(4,1)/dhc12
66257  dhcy2=dfour(4,2)/dhc12
66258  dhcyx=dhcxx*(dhcx1*dhcy2+dhcx2*dhcy1)*dhc12
66259  dhcyy=1d0/sqrt(1d0+2d0*dhcy1*dhcy2*dhc12-dhcyx**2)
66260  DO 420 j=1,4
66261  dp(3,j)=dhcxx*(dp(3,j)-dhcx2*dp(1,j)-dhcx1*dp(2,j))
66262  p(in(6),j)=dp(3,j)
66263  p(in(6)+1,j)=dhcyy*(dp(4,j)-dhcy2*dp(1,j)-dhcy1*dp(2,j)-
66264  & dhcyx*dp(3,j))
66265  420 CONTINUE
66266 
66267 C...Junction strings: produce new particle, origin.
66268  430 i=i+1
66269  IF(2*i-nsav.GE.mstu(4)-mstu(32)-5) THEN
66270  CALL pyerrm(11,'(PYSTRF:) no more memory left in PYJETS')
66271  IF(mstu(21).GE.1) RETURN
66272  ENDIF
66273  irankj=irankj+1
66274  k(i,1)=1
66275  k(i,3)=ie(1)
66276  k(i,4)=0
66277  k(i,5)=0
66278 
66279 C...Junction strings: generate flavour, hadron, pT, z and Gamma.
66280  440 CALL pykfdi(kfl(1),0,kfl(3),k(i,2))
66281  IF(k(i,2).EQ.0) goto 360
66282  IF(irankj.EQ.1.AND.iabs(kfl(1)).LE.10.AND.
66283  & iabs(kfl(3)).GT.10) THEN
66284  IF(pyr(0).GT.parj(19)) goto 440
66285  ENDIF
66286  p(i,5)=pymass(k(i,2))
66287  CALL pyptdi(kfl(1),px(3),py(3))
66288  pr(1)=p(i,5)**2+(px(1)+px(3))**2+(py(1)+py(3))**2
66289  CALL pyzdis(kfl(1),kfl(3),pr(1),z)
66290  IF(iabs(kfl(1)).GE.4.AND.iabs(kfl(1)).LE.8.AND.
66291  & mstu(90).LT.8) THEN
66292  mstu(90)=mstu(90)+1
66293  mstu(90+mstu(90))=i
66294  paru(90+mstu(90))=z
66295  ENDIF
66296  gam(3)=(1d0-z)*(gam(1)+pr(1)/z)
66297  DO 450 j=1,3
66298  in(j)=in(3+j)
66299  450 CONTINUE
66300 
66301 C...Junction strings: stepping within 'low' string region.
66302  IF(in(1)+1.EQ.in(2).AND.z*p(in(1)+2,3)*p(in(2)+2,3)*
66303  & p(in(1),5)**2.GE.pr(1)) THEN
66304  p(in(1)+2,4)=z*p(in(1)+2,3)
66305  p(in(2)+2,4)=pr(1)/(p(in(1)+2,4)*p(in(1),5)**2)
66306  DO 460 j=1,4
66307  p(i,j)=(px(1)+px(3))*p(in(3),j)+(py(1)+py(3))*p(in(3)+1,j)
66308  460 CONTINUE
66309  goto 560
66310 C...Has used up energy of junction string, i.e. no more hadrons in it.
66311  ELSEIF(in(1)+1.EQ.in(2).AND.in(1).EQ.n+nr+4*ns-3) THEN
66312  DO 470 j=1,5
66313  p(i,j)=0d0
66314  470 CONTINUE
66315  goto 600
66316 C...Stepping from 'low' string region
66317  ELSEIF(in(1)+1.EQ.in(2)) THEN
66318  p(in(2)+2,4)=p(in(2)+2,3)
66319  p(in(2)+2,1)=1d0
66320  in(2)=in(2)+4
66321  IF(in(2).GT.n+nr+4*ns) goto 360
66322  IF(four(in(1),in(2)).LE.1d-2) THEN
66323  p(in(1)+2,4)=p(in(1)+2,3)
66324  p(in(1)+2,1)=0d0
66325  in(1)=in(1)+4
66326  ENDIF
66327  ENDIF
66328 
66329 C...Junction strings: find new transverse directions.
66330  480 IF(in(1).GT.n+nr+4*ns.OR.in(2).GT.n+nr+4*ns.OR.
66331  & in(1).GT.in(2)) goto 360
66332  IF(in(1).NE.in(4).OR.in(2).NE.in(5)) THEN
66333  DO 490 j=1,4
66334  dp(1,j)=p(in(1),j)
66335  dp(2,j)=p(in(2),j)
66336  dp(3,j)=0d0
66337  dp(4,j)=0d0
66338  490 CONTINUE
66339  dp(1,4)=sqrt(dp(1,1)**2+dp(1,2)**2+dp(1,3)**2)
66340  dp(2,4)=sqrt(dp(2,1)**2+dp(2,2)**2+dp(2,3)**2)
66341  dhc12=dfour(1,2)
66342  IF(dhc12.LE.1d-2) THEN
66343  p(in(1)+2,4)=p(in(1)+2,3)
66344  p(in(1)+2,1)=0d0
66345  in(1)=in(1)+4
66346  goto 480
66347  ENDIF
66348  in(3)=n+nr+4*ns+5
66349  dp(5,1)=dp(1,1)/dp(1,4)-dp(2,1)/dp(2,4)
66350  dp(5,2)=dp(1,2)/dp(1,4)-dp(2,2)/dp(2,4)
66351  dp(5,3)=dp(1,3)/dp(1,4)-dp(2,3)/dp(2,4)
66352  IF(dp(5,1)**2.LE.dp(5,2)**2+dp(5,3)**2) dp(3,1)=1d0
66353  IF(dp(5,1)**2.GT.dp(5,2)**2+dp(5,3)**2) dp(3,3)=1d0
66354  IF(dp(5,2)**2.LE.dp(5,1)**2+dp(5,3)**2) dp(4,2)=1d0
66355  IF(dp(5,2)**2.GT.dp(5,1)**2+dp(5,3)**2) dp(4,3)=1d0
66356  dhcx1=dfour(3,1)/dhc12
66357  dhcx2=dfour(3,2)/dhc12
66358  dhcxx=1d0/sqrt(1d0+2d0*dhcx1*dhcx2*dhc12)
66359  dhcy1=dfour(4,1)/dhc12
66360  dhcy2=dfour(4,2)/dhc12
66361  dhcyx=dhcxx*(dhcx1*dhcy2+dhcx2*dhcy1)*dhc12
66362  dhcyy=1d0/sqrt(1d0+2d0*dhcy1*dhcy2*dhc12-dhcyx**2)
66363  DO 500 j=1,4
66364  dp(3,j)=dhcxx*(dp(3,j)-dhcx2*dp(1,j)-dhcx1*dp(2,j))
66365  p(in(3),j)=dp(3,j)
66366  p(in(3)+1,j)=dhcyy*(dp(4,j)-dhcy2*dp(1,j)-dhcy1*dp(2,j)-
66367  & dhcyx*dp(3,j))
66368  500 CONTINUE
66369 C...Express pT with respect to new axes, if sensible.
66370  pxp=-(px(3)*four(in(6),in(3))+py(3)*four(in(6)+1,in(3)))
66371  pyp=-(px(3)*four(in(6),in(3)+1)+py(3)*four(in(6)+1,in(3)+1))
66372  IF(abs(pxp**2+pyp**2-px(3)**2-py(3)**2).LT.0.01d0) THEN
66373  px(3)=pxp
66374  py(3)=pyp
66375  ENDIF
66376  ENDIF
66377 
66378 C...Junction strings: sum up known four-momentum, coefficients for m2.
66379  DO 530 j=1,4
66380  dhg(j)=0d0
66381  p(i,j)=px(1)*p(in(6),j)+py(1)*p(in(6)+1,j)+px(3)*p(in(3),j)+
66382  & py(3)*p(in(3)+1,j)
66383  DO 510 in1=in(4),in(1)-4,4
66384  p(i,j)=p(i,j)+p(in1+2,3)*p(in1,j)
66385  510 CONTINUE
66386  DO 520 in2=in(5),in(2)-4,4
66387  p(i,j)=p(i,j)+p(in2+2,3)*p(in2,j)
66388  520 CONTINUE
66389  530 CONTINUE
66390  dhm(1)=four(i,i)
66391  dhm(2)=2d0*four(i,in(1))
66392  dhm(3)=2d0*four(i,in(2))
66393  dhm(4)=2d0*four(in(1),in(2))
66394 
66395 C...Junction strings: find coefficients for Gamma expression.
66396  DO 550 in2=in(1)+1,in(2),4
66397  DO 540 in1=in(1),in2-1,4
66398  dhc=2d0*four(in1,in2)
66399  dhg(1)=dhg(1)+p(in1+2,1)*p(in2+2,1)*dhc
66400  IF(in1.EQ.in(1)) dhg(2)=dhg(2)-p(in2+2,1)*dhc
66401  IF(in2.EQ.in(2)) dhg(3)=dhg(3)+p(in1+2,1)*dhc
66402  IF(in1.EQ.in(1).AND.in2.EQ.in(2)) dhg(4)=dhg(4)-dhc
66403  540 CONTINUE
66404  550 CONTINUE
66405 
66406 C...Junction strings: solve (m2, Gamma) equation system for energies.
66407  dhs1=dhm(3)*dhg(4)-dhm(4)*dhg(3)
66408  IF(abs(dhs1).LT.1d-4) goto 360
66409  dhs2=dhm(4)*(gam(3)-dhg(1))-dhm(2)*dhg(3)-dhg(4)*
66410  & (p(i,5)**2-dhm(1))+dhg(2)*dhm(3)
66411  dhs3=dhm(2)*(gam(3)-dhg(1))-dhg(2)*(p(i,5)**2-dhm(1))
66412  p(in(2)+2,4)=0.5d0*(sqrt(max(0d0,dhs2**2-4d0*dhs1*dhs3))/
66413  & abs(dhs1)-dhs2/dhs1)
66414  IF(dhm(2)+dhm(4)*p(in(2)+2,4).LE.0d0) goto 360
66415  p(in(1)+2,4)=(p(i,5)**2-dhm(1)-dhm(3)*p(in(2)+2,4))/
66416  & (dhm(2)+dhm(4)*p(in(2)+2,4))
66417 
66418 C...Junction strings: step to new region if necessary.
66419  IF(p(in(2)+2,4).GT.p(in(2)+2,3)) THEN
66420  p(in(2)+2,4)=p(in(2)+2,3)
66421  p(in(2)+2,1)=1d0
66422  in(2)=in(2)+4
66423  IF(in(2).GT.n+nr+4*ns) goto 360
66424  IF(four(in(1),in(2)).LE.1d-2) THEN
66425  p(in(1)+2,4)=p(in(1)+2,3)
66426  p(in(1)+2,1)=0d0
66427  in(1)=in(1)+4
66428  ENDIF
66429  goto 480
66430  ELSEIF(p(in(1)+2,4).GT.p(in(1)+2,3)) THEN
66431  p(in(1)+2,4)=p(in(1)+2,3)
66432  p(in(1)+2,1)=0d0
66433  in(1)=in(1)+4
66434  goto 480
66435  ENDIF
66436 
66437 C...Junction strings: particle four-momentum, remainder, loop back.
66438  560 DO 570 j=1,4
66439  p(i,j)=p(i,j)+p(in(1)+2,4)*p(in(1),j)+
66440  & p(in(2)+2,4)*p(in(2),j)
66441  pju(iu+3,j)=pju(iu+3,j)+p(i,j)
66442  570 CONTINUE
66443  IF(p(i,4).LT.p(i,5)) goto 360
66444  pju(iu+3,5)=tju(4)*pju(iu+3,4)-tju(1)*pju(iu+3,1)-
66445  & tju(2)*pju(iu+3,2)-tju(3)*pju(iu+3,3)
66446  IF(pju(iu+3,5).LT.pju(iu,5)) THEN
66447  kfl(1)=-kfl(3)
66448  px(1)=-px(3)
66449  py(1)=-py(3)
66450  gam(1)=gam(3)
66451  IF(in(3).NE.in(6)) THEN
66452  DO 580 j=1,4
66453  p(in(6),j)=p(in(3),j)
66454  p(in(6)+1,j)=p(in(3)+1,j)
66455  580 CONTINUE
66456  ENDIF
66457  DO 590 jq=1,2
66458  in(3+jq)=in(jq)
66459  p(in(jq)+2,3)=p(in(jq)+2,3)-p(in(jq)+2,4)
66460  p(in(jq)+2,1)=p(in(jq)+2,1)-(3-2*jq)*p(in(jq)+2,4)
66461  590 CONTINUE
66462  goto 430
66463  ENDIF
66464 
66465 C...Junction strings: save quantities left after each string.
66466  IF(iabs(kfl(1)).GT.10) goto 360
66467  600 i=i-1
66468  kfjh(iu)=kfl(1)
66469  DO 610 j=1,4
66470  pju(iu+3,j)=pju(iu+3,j)-p(i+1,j)
66471  610 CONTINUE
66472 
66473 C...Junction strings: loopback if much unused energy in both strings.
66474  pju(iu+3,5)=tju(4)*pju(iu+3,4)-tju(1)*pju(iu+3,1)-
66475  & tju(2)*pju(iu+3,2)-tju(3)*pju(iu+3,3)
66476  ejstr(iu)=pju(iu,5)-pju(iu+3,5)
66477  620 CONTINUE
66478  IF((min(ejstr(1),ejstr(2)).GT.parj(49).OR.
66479  & ejstr(1).GT.parj(49)+pyr(0)*parj(50).OR.
66480  & ejstr(2).GT.parj(49)+pyr(0)*parj(50))
66481  & .AND.ntryer.LT.10) goto 320
66482 
66483 C...Junction strings: put together to new effective string endpoint.
66484  njs(jt)=i-ista
66485  kfls=2*int(pyr(0)+3d0*parj(4)/(1d0+3d0*parj(4)))+1
66486  IF(kfjh(1).EQ.kfjh(2)) kfls=3
66487  kfjs(jt)=isign(1000*max(iabs(kfjh(1)),iabs(kfjh(2)))+
66488  & 100*min(iabs(kfjh(1)),iabs(kfjh(2)))+kfls,kfjh(1))
66489  DO 630 j=1,4
66490  pjs(jt,j)=pju(1,j)+pju(2,j)+p(mju(jt),j)
66491  pjs(jt+2,j)=pju(4,j)+pju(5,j)
66492  630 CONTINUE
66493  pjs(jt,5)=sqrt(max(0d0,pjs(jt,4)**2-pjs(jt,1)**2-pjs(jt,2)**2-
66494  & pjs(jt,3)**2))
66495  pjs(jt+2,5)=0d0
66496  640 CONTINUE
66497 
66498 C...Open versus closed strings. Choose breakup region for latter.
66499  650 IF(mju(1).NE.0.AND.mju(2).NE.0) THEN
66500  ns=mju(2)-mju(1)
66501  nb=mju(1)-n
66502  ELSEIF(mju(1).NE.0) THEN
66503  ns=n+nr-mju(1)
66504  nb=mju(1)-n
66505  ELSEIF(mju(2).NE.0) THEN
66506  ns=mju(2)-n
66507  nb=1
66508  ELSEIF(iabs(k(n+1,2)).NE.21) THEN
66509  ns=nr-1
66510  nb=1
66511  ELSE
66512  ns=nr+1
66513  w2sum=0d0
66514  DO 660 is=1,nr
66515  p(n+nr+is,1)=0.5d0*four(n+is,n+is+1-nr*(is/nr))
66516  w2sum=w2sum+p(n+nr+is,1)
66517  660 CONTINUE
66518  w2ran=pyr(0)*w2sum
66519  nb=0
66520  670 nb=nb+1
66521  w2sum=w2sum-p(n+nr+nb,1)
66522  IF(w2sum.GT.w2ran.AND.nb.LT.nr) goto 670
66523  ENDIF
66524 
66525 C...Find longitudinal string directions (i.e. lightlike four-vectors).
66526  DO 700 is=1,ns
66527  is1=n+is+nb-1-nr*((is+nb-2)/nr)
66528  is2=n+is+nb-nr*((is+nb-1)/nr)
66529  DO 680 j=1,5
66530  dp(1,j)=p(is1,j)
66531  IF(iabs(k(is1,2)).EQ.21) dp(1,j)=0.5d0*dp(1,j)
66532  IF(is1.EQ.mju(1)) dp(1,j)=pjs(1,j)-pjs(3,j)
66533  dp(2,j)=p(is2,j)
66534  IF(iabs(k(is2,2)).EQ.21) dp(2,j)=0.5d0*dp(2,j)
66535  IF(is2.EQ.mju(2)) dp(2,j)=pjs(2,j)-pjs(4,j)
66536  680 CONTINUE
66537  IF(is1.EQ.mju(1)) dp(1,5)=sqrt(max(0d0,dp(1,4)**2-dp(1,1)**2-
66538  & dp(1,2)**2-dp(1,3)**2))
66539  IF(is2.EQ.mju(2)) dp(2,5)=sqrt(max(0d0,dp(2,4)**2-dp(2,1)**2-
66540  & dp(2,2)**2-dp(2,3)**2))
66541  dp(3,5)=dfour(1,1)
66542  dp(4,5)=dfour(2,2)
66543  dhkc=dfour(1,2)
66544  IF(dp(3,5)+2d0*dhkc+dp(4,5).LE.0d0) goto 200
66545  dhks=sqrt(dhkc**2-dp(3,5)*dp(4,5))
66546  dhk1=0.5d0*((dp(4,5)+dhkc)/dhks-1d0)
66547  dhk2=0.5d0*((dp(3,5)+dhkc)/dhks-1d0)
66548  in1=n+nr+4*is-3
66549  p(in1,5)=sqrt(dp(3,5)+2d0*dhkc+dp(4,5))
66550  DO 690 j=1,4
66551  p(in1,j)=(1d0+dhk1)*dp(1,j)-dhk2*dp(2,j)
66552  p(in1+1,j)=(1d0+dhk2)*dp(2,j)-dhk1*dp(1,j)
66553  690 CONTINUE
66554  700 CONTINUE
66555 
66556 C...Begin initialization: sum up energy, set starting position.
66557  isav=i
66558  mstu91=mstu(90)
66559  710 ntry=ntry+1
66560  IF(ntry.GT.100.AND.ntryr.LE.8.AND.nr.GT.nrmin) THEN
66561  paru12=4d0*paru12
66562  paru13=2d0*paru13
66563  goto 140
66564  ELSEIF(ntry.GT.100) THEN
66565  CALL pyerrm(14,'(PYSTRF:) caught in infinite loop')
66566  IF(mstu(21).GE.1) RETURN
66567  ENDIF
66568  i=isav
66569  mstu(90)=mstu91
66570  DO 730 j=1,4
66571  p(n+nrs,j)=0d0
66572  DO 720 is=1,nr
66573  p(n+nrs,j)=p(n+nrs,j)+p(n+is,j)
66574  720 CONTINUE
66575  730 CONTINUE
66576  DO 750 jt=1,2
66577  irank(jt)=0
66578  IF(mju(jt).NE.0) irank(jt)=njs(jt)
66579  IF(ns.GT.nr) irank(jt)=1
66580  ibarrk(jt)=0
66581  ie(jt)=k(n+1+(jt/2)*(np-1),3)
66582  in(3*jt+1)=n+nr+1+4*(jt/2)*(ns-1)
66583  in(3*jt+2)=in(3*jt+1)+1
66584  in(3*jt+3)=n+nr+4*ns+2*jt-1
66585  DO 740 in1=n+nr+2+jt,n+nr+4*ns-2+jt,4
66586  p(in1,1)=2-jt
66587  p(in1,2)=jt-1
66588  p(in1,3)=1d0
66589  740 CONTINUE
66590  750 CONTINUE
66591 
66592 C.. MOPS variables and switches
66593  nrvmo=0
66594  xbmo=1d0
66595  mstu(121)=0
66596  mstu(122)=0
66597 
66598 C...Initialize flavour and pT variables for open string.
66599  IF(ns.LT.nr) THEN
66600  px(1)=0d0
66601  py(1)=0d0
66602  IF(ns.EQ.1.AND.mju(1)+mju(2).EQ.0) CALL pyptdi(0,px(1),py(1))
66603  px(2)=-px(1)
66604  py(2)=-py(1)
66605  DO 760 jt=1,2
66606  kfl(jt)=k(ie(jt),2)
66607  IF(mju(jt).NE.0) kfl(jt)=kfjs(jt)
66608  IF(mju(jt).NE.0.AND.iabs(kfl(jt)).GT.1000) ibarrk(jt)=1
66609  mstj(93)=1
66610  pmq(jt)=pymass(kfl(jt))
66611  gam(jt)=0d0
66612  760 CONTINUE
66613 
66614 C...Closed string: random initial breakup flavour, pT and vertex.
66615  ELSE
66616  kfl(3)=int(1d0+(2d0+parj(2))*pyr(0))*(-1)**int(pyr(0)+0.5d0)
66617  ibmo=0
66618  770 CALL pykfdi(kfl(3),0,kfl(1),kdump)
66619 C.. Closed string: first vertex diq attempt => enforced second
66620 C.. vertex diq
66621  IF(iabs(kfl(1)).GT.10)THEN
66622  ibmo=1
66623  mstu(121)=0
66624  goto 770
66625  ENDIF
66626  IF(ibmo.EQ.1) mstu(121)=-1
66627  kfl(2)=-kfl(1)
66628  CALL pyptdi(kfl(1),px(1),py(1))
66629  px(2)=-px(1)
66630  py(2)=-py(1)
66631  pr3=min(25d0,0.1d0*p(n+nr+1,5)**2)
66632  780 CALL pyzdis(kfl(1),kfl(2),pr3,z)
66633  zr=pr3/(z*p(n+nr+1,5)**2)
66634  IF(zr.GE.1d0) goto 780
66635  DO 790 jt=1,2
66636  mstj(93)=1
66637  pmq(jt)=pymass(kfl(jt))
66638  gam(jt)=pr3*(1d0-z)/z
66639  in1=n+nr+3+4*(jt/2)*(ns-1)
66640  p(in1,jt)=1d0-z
66641  p(in1,3-jt)=jt-1
66642  p(in1,3)=(2-jt)*(1d0-z)+(jt-1)*z
66643  p(in1+1,jt)=zr
66644  p(in1+1,3-jt)=2-jt
66645  p(in1+1,3)=(2-jt)*(1d0-zr)+(jt-1)*zr
66646  790 CONTINUE
66647  ENDIF
66648 C.. MOPS variables
66649  DO 800 jt=1,2
66650  xtmo(jt)=1d0
66651  pm2qmo(jt)=pmq(jt)**2
66652  IF(iabs(kfl(jt)).GT.10) pm2qmo(jt)=0d0
66653  800 CONTINUE
66654 
66655 C...Find initial transverse directions (i.e. spacelike four-vectors).
66656  DO 840 jt=1,2
66657  IF(jt.EQ.1.OR.ns.EQ.nr-1.OR.mju(1)+mju(2).NE.0) THEN
66658  in1=in(3*jt+1)
66659  in3=in(3*jt+3)
66660  DO 810 j=1,4
66661  dp(1,j)=p(in1,j)
66662  dp(2,j)=p(in1+1,j)
66663  dp(3,j)=0d0
66664  dp(4,j)=0d0
66665  810 CONTINUE
66666  dp(1,4)=sqrt(dp(1,1)**2+dp(1,2)**2+dp(1,3)**2)
66667  dp(2,4)=sqrt(dp(2,1)**2+dp(2,2)**2+dp(2,3)**2)
66668  dp(5,1)=dp(1,1)/dp(1,4)-dp(2,1)/dp(2,4)
66669  dp(5,2)=dp(1,2)/dp(1,4)-dp(2,2)/dp(2,4)
66670  dp(5,3)=dp(1,3)/dp(1,4)-dp(2,3)/dp(2,4)
66671  IF(dp(5,1)**2.LE.dp(5,2)**2+dp(5,3)**2) dp(3,1)=1d0
66672  IF(dp(5,1)**2.GT.dp(5,2)**2+dp(5,3)**2) dp(3,3)=1d0
66673  IF(dp(5,2)**2.LE.dp(5,1)**2+dp(5,3)**2) dp(4,2)=1d0
66674  IF(dp(5,2)**2.GT.dp(5,1)**2+dp(5,3)**2) dp(4,3)=1d0
66675  dhc12=dfour(1,2)
66676  dhcx1=dfour(3,1)/dhc12
66677  dhcx2=dfour(3,2)/dhc12
66678  dhcxx=1d0/sqrt(1d0+2d0*dhcx1*dhcx2*dhc12)
66679  dhcy1=dfour(4,1)/dhc12
66680  dhcy2=dfour(4,2)/dhc12
66681  dhcyx=dhcxx*(dhcx1*dhcy2+dhcx2*dhcy1)*dhc12
66682  dhcyy=1d0/sqrt(1d0+2d0*dhcy1*dhcy2*dhc12-dhcyx**2)
66683  DO 820 j=1,4
66684  dp(3,j)=dhcxx*(dp(3,j)-dhcx2*dp(1,j)-dhcx1*dp(2,j))
66685  p(in3,j)=dp(3,j)
66686  p(in3+1,j)=dhcyy*(dp(4,j)-dhcy2*dp(1,j)-dhcy1*dp(2,j)-
66687  & dhcyx*dp(3,j))
66688  820 CONTINUE
66689  ELSE
66690  DO 830 j=1,4
66691  p(in3+2,j)=p(in3,j)
66692  p(in3+3,j)=p(in3+1,j)
66693  830 CONTINUE
66694  ENDIF
66695  840 CONTINUE
66696 
66697 C...Remove energy used up in junction string fragmentation.
66698  IF(mju(1)+mju(2).GT.0) THEN
66699  DO 860 jt=1,2
66700  IF(njs(jt).EQ.0) goto 860
66701  DO 850 j=1,4
66702  p(n+nrs,j)=p(n+nrs,j)-pjs(jt+2,j)
66703  850 CONTINUE
66704  860 CONTINUE
66705  parjst=parj(33)
66706  IF(mstj(11).EQ.2) parjst=parj(34)
66707  wmin=parjst+pmq(1)+pmq(2)
66708  wrem2=four(n+nrs,n+nrs)
66709  IF(p(n+nrs,4).LT.0d0.OR.wrem2.LT.wmin**2) THEN
66710  ntrywr=ntrywr+1
66711  IF(mod(ntrywr,20).NE.0) ntryr=ntryr-1
66712  goto 140
66713  ENDIF
66714  ENDIF
66715 
66716 C...Produce new particle: side, origin.
66717  870 i=i+1
66718  IF(2*i-nsav.GE.mstu(4)-mstu(32)-5) THEN
66719  CALL pyerrm(11,'(PYSTRF:) no more memory left in PYJETS')
66720  IF(mstu(21).GE.1) RETURN
66721  ENDIF
66722 C.. New side priority for popcorn systems
66723  IF(mstu(121).LE.0)THEN
66724  jt=1.5d0+pyr(0)
66725  IF(iabs(kfl(3-jt)).GT.10) jt=3-jt
66726  IF(iabs(kfl(3-jt)).GE.4.AND.iabs(kfl(3-jt)).LE.8) jt=3-jt
66727  ENDIF
66728  jr=3-jt
66729  js=3-2*jt
66730  irank(jt)=irank(jt)+1
66731  k(i,1)=1
66732  k(i,4)=0
66733  k(i,5)=0
66734 
66735 C...Generate flavour, hadron and pT.
66736  880 k(i,3)=ie(jt)
66737  CALL pykfdi(kfl(jt),0,kfl(3),k(i,2))
66738  IF(k(i,2).EQ.0) goto 710
66739  mu90mo=mstu(90)
66740  IF(mstu(121).EQ.-1) goto 910
66741  IF(irank(jt).EQ.1.AND.iabs(kfl(jt)).LE.10.AND.
66742  &iabs(kfl(3)).GT.10) THEN
66743  IF(pyr(0).GT.parj(19)) goto 880
66744  ENDIF
66745  IF(ibarrk(jt).EQ.1.AND.mod(iabs(k(i,2)),10000).GT.1000)
66746  &k(i,3)=ijuori(jt)
66747  p(i,5)=pymass(k(i,2))
66748  CALL pyptdi(kfl(jt),px(3),py(3))
66749  pr(jt)=p(i,5)**2+(px(jt)+px(3))**2+(py(jt)+py(3))**2
66750 
66751 C...Final hadrons for small invariant mass.
66752  mstj(93)=1
66753  pmq(3)=pymass(kfl(3))
66754  parjst=parj(33)
66755  IF(mstj(11).EQ.2) parjst=parj(34)
66756  wmin=parjst+pmq(1)+pmq(2)+parj(36)*pmq(3)
66757  IF(iabs(kfl(jt)).GT.10.AND.iabs(kfl(3)).GT.10) wmin=
66758  &wmin-0.5d0*parj(36)*pmq(3)
66759  wrem2=four(n+nrs,n+nrs)
66760  IF(wrem2.LT.0.10d0) goto 710
66761  IF(wrem2.LT.max(wmin*(1d0+(2d0*pyr(0)-1d0)*parj(37)),
66762  &parj(32)+pmq(1)+pmq(2))**2) goto 1080
66763 
66764 C...Choose z, which gives Gamma. Shift z for heavy flavours.
66765  CALL pyzdis(kfl(jt),kfl(3),pr(jt),z)
66766  IF(iabs(kfl(jt)).GE.4.AND.iabs(kfl(jt)).LE.8.AND.
66767  &mstu(90).LT.8) THEN
66768  mstu(90)=mstu(90)+1
66769  mstu(90+mstu(90))=i
66770  paru(90+mstu(90))=z
66771  ENDIF
66772  kfl1a=iabs(kfl(1))
66773  kfl2a=iabs(kfl(2))
66774  IF(max(mod(kfl1a,10),mod(kfl1a/1000,10),mod(kfl2a,10),
66775  &mod(kfl2a/1000,10)).GE.4) THEN
66776  pr(jr)=(pmq(jr)+pmq(3))**2+(px(jr)-px(3))**2+(py(jr)-py(3))**2
66777  pw12=sqrt(max(0d0,(wrem2-pr(1)-pr(2))**2-4d0*pr(1)*pr(2)))
66778  z=(wrem2+pr(jt)-pr(jr)+pw12*(2d0*z-1d0))/(2d0*wrem2)
66779  pr(jr)=(pmq(jr)+parjst)**2+(px(jr)-px(3))**2+(py(jr)-py(3))**2
66780  IF((1d0-z)*(wrem2-pr(jt)/z).LT.pr(jr)) goto 1080
66781  ENDIF
66782  gam(3)=(1d0-z)*(gam(jt)+pr(jt)/z)
66783 
66784 C.. MOPS baryon model modification
66785  xtmo3=(1d0-z)*xtmo(jt)
66786  IF(iabs(kfl(3)).LE.10) nrvmo=0
66787  IF(iabs(kfl(3)).GT.10.AND.mstj(12).GE.4) THEN
66788  gtstmo=1d0
66789  ptstmo=1d0
66790  rtstmo=pyr(0)
66791  IF(iabs(kfl(jt)).LE.10)THEN
66792  xbmo=min(xtmo3,1d0-(2d-10))
66793  gbmo=gam(3)
66794  pmmo=0d0
66795  pgmo=gbmo+log(1d0-xbmo)*pm2qmo(jt)
66796  gtstmo=1d0-parf(192)**pgmo
66797  ELSE
66798  IF(irank(jt).EQ.1) THEN
66799  gbmo=gam(jt)
66800  pmmo=0d0
66801  xbmo=1d0
66802  ENDIF
66803  IF(xbmo.LT.1d0-(1d-10))THEN
66804  pgnmo=gbmo*xtmo3/xbmo+pm2qmo(jt)*log(1d0-xtmo3)
66805  gtstmo=(1d0-parf(192)**pgnmo)/(1d0-parf(192)**pgmo)
66806  pgmo=pgnmo
66807  ENDIF
66808  IF(mstj(12).GE.5)THEN
66809  pmnmo=sqrt((xbmo-xtmo3)*(gam(3)/xtmo3-gbmo/xbmo))
66810  pmmo=pmmo+pmas(pycomp(k(i,2)),1)-pmas(pycomp(k(i,2)),3)
66811  ptstmo=exp((pmmo-pmnmo)*parf(193))
66812  pmmo=pmnmo
66813  ENDIF
66814  ENDIF
66815 
66816 C.. MOPS Accepting popcorn system hadron.
66817  IF(ptstmo*gtstmo.GT.rtstmo) THEN
66818  IF(irank(jt).EQ.1.OR.iabs(kfl(jt)).LE.10) THEN
66819  nrvmo=i-n-nr
66820  IF(i+nrvmo.GT.mstu(4)-mstu(32)-5) THEN
66821  CALL pyerrm(11,
66822  & '(PYSTRF:) no more memory left in PYJETS')
66823  IF(mstu(21).GE.1) RETURN
66824  ENDIF
66825  imo=i
66826  kflmo=kfl(jt)
66827  pmqmo=pmq(jt)
66828  pxmo=px(jt)
66829  pymo=py(jt)
66830  gammo=gam(jt)
66831  irmo=irank(jt)
66832  xmo=xtmo(jt)
66833  DO 900 j=1,9
66834  IF(j.LE.5) THEN
66835  DO 890 line=1,i-n-nr
66836  p(mstu(4)-mstu(32)-line,j)=p(n+nr+line,j)
66837  k(mstu(4)-mstu(32)-line,j)=k(n+nr+line,j)
66838  890 CONTINUE
66839  ENDIF
66840  inmo(j)=in(j)
66841  900 CONTINUE
66842  ENDIF
66843  ELSE
66844 C..Reject popcorn system, flag=-1 if enforcing new one
66845  mstu(121)=-1
66846  IF(ptstmo.GT.rtstmo) mstu(121)=-2
66847  ENDIF
66848  ENDIF
66849 
66850 
66851 C..Lift restoring string outside MOPS block
66852  910 IF(mstu(121).LT.0) THEN
66853  IF(mstu(121).EQ.-2) mstu(121)=0
66854  mstu(90)=mu90mo
66855  nrvmo=0
66856  IF(irank(jt).EQ.1.OR.iabs(kfl(jt)).LE.10) goto 880
66857  i=imo
66858  kfl(jt)=kflmo
66859  pmq(jt)=pmqmo
66860  px(jt)=pxmo
66861  py(jt)=pymo
66862  gam(jt)=gammo
66863  irank(jt)=irmo
66864  xtmo(jt)=xmo
66865  DO 930 j=1,9
66866  IF(j.LE.5) THEN
66867  DO 920 line=1,i-n-nr
66868  p(n+nr+line,j)=p(mstu(4)-mstu(32)-line,j)
66869  k(n+nr+line,j)=k(mstu(4)-mstu(32)-line,j)
66870  920 CONTINUE
66871  ENDIF
66872  in(j)=inmo(j)
66873  930 CONTINUE
66874  goto 880
66875  ENDIF
66876  xtmo(jt)=xtmo3
66877 C.. MOPS end of modification
66878 
66879  DO 940 j=1,3
66880  in(j)=in(3*jt+j)
66881  940 CONTINUE
66882 
66883 C...Stepping within or from 'low' string region easy.
66884  IF(in(1)+1.EQ.in(2).AND.z*p(in(1)+2,3)*p(in(2)+2,3)*
66885  &p(in(1),5)**2.GE.pr(jt)) THEN
66886  p(in(jt)+2,4)=z*p(in(jt)+2,3)
66887  p(in(jr)+2,4)=pr(jt)/(p(in(jt)+2,4)*p(in(1),5)**2)
66888  DO 950 j=1,4
66889  p(i,j)=(px(jt)+px(3))*p(in(3),j)+(py(jt)+py(3))*p(in(3)+1,j)
66890  950 CONTINUE
66891  goto 1040
66892  ELSEIF(in(1)+1.EQ.in(2)) THEN
66893  p(in(jr)+2,4)=p(in(jr)+2,3)
66894  p(in(jr)+2,jt)=1d0
66895  in(jr)=in(jr)+4*js
66896  IF(js*in(jr).GT.js*in(4*jr)) goto 710
66897  IF(four(in(1),in(2)).LE.1d-2) THEN
66898  p(in(jt)+2,4)=p(in(jt)+2,3)
66899  p(in(jt)+2,jt)=0d0
66900  in(jt)=in(jt)+4*js
66901  ENDIF
66902  ENDIF
66903 
66904 C...Find new transverse directions (i.e. spacelike string vectors).
66905  960 IF(js*in(1).GT.js*in(3*jr+1).OR.js*in(2).GT.js*in(3*jr+2).OR.
66906  &in(1).GT.in(2)) goto 710
66907  IF(in(1).NE.in(3*jt+1).OR.in(2).NE.in(3*jt+2)) THEN
66908  DO 970 j=1,4
66909  dp(1,j)=p(in(1),j)
66910  dp(2,j)=p(in(2),j)
66911  dp(3,j)=0d0
66912  dp(4,j)=0d0
66913  970 CONTINUE
66914  dp(1,4)=sqrt(dp(1,1)**2+dp(1,2)**2+dp(1,3)**2)
66915  dp(2,4)=sqrt(dp(2,1)**2+dp(2,2)**2+dp(2,3)**2)
66916  dhc12=dfour(1,2)
66917  IF(dhc12.LE.1d-2) THEN
66918  p(in(jt)+2,4)=p(in(jt)+2,3)
66919  p(in(jt)+2,jt)=0d0
66920  in(jt)=in(jt)+4*js
66921  goto 960
66922  ENDIF
66923  in(3)=n+nr+4*ns+5
66924  dp(5,1)=dp(1,1)/dp(1,4)-dp(2,1)/dp(2,4)
66925  dp(5,2)=dp(1,2)/dp(1,4)-dp(2,2)/dp(2,4)
66926  dp(5,3)=dp(1,3)/dp(1,4)-dp(2,3)/dp(2,4)
66927  IF(dp(5,1)**2.LE.dp(5,2)**2+dp(5,3)**2) dp(3,1)=1d0
66928  IF(dp(5,1)**2.GT.dp(5,2)**2+dp(5,3)**2) dp(3,3)=1d0
66929  IF(dp(5,2)**2.LE.dp(5,1)**2+dp(5,3)**2) dp(4,2)=1d0
66930  IF(dp(5,2)**2.GT.dp(5,1)**2+dp(5,3)**2) dp(4,3)=1d0
66931  dhcx1=dfour(3,1)/dhc12
66932  dhcx2=dfour(3,2)/dhc12
66933  dhcxx=1d0/sqrt(1d0+2d0*dhcx1*dhcx2*dhc12)
66934  dhcy1=dfour(4,1)/dhc12
66935  dhcy2=dfour(4,2)/dhc12
66936  dhcyx=dhcxx*(dhcx1*dhcy2+dhcx2*dhcy1)*dhc12
66937  dhcyy=1d0/sqrt(1d0+2d0*dhcy1*dhcy2*dhc12-dhcyx**2)
66938  DO 980 j=1,4
66939  dp(3,j)=dhcxx*(dp(3,j)-dhcx2*dp(1,j)-dhcx1*dp(2,j))
66940  p(in(3),j)=dp(3,j)
66941  p(in(3)+1,j)=dhcyy*(dp(4,j)-dhcy2*dp(1,j)-dhcy1*dp(2,j)-
66942  & dhcyx*dp(3,j))
66943  980 CONTINUE
66944 C...Express pT with respect to new axes, if sensible.
66945  pxp=-(px(3)*four(in(3*jt+3),in(3))+py(3)*
66946  & four(in(3*jt+3)+1,in(3)))
66947  pyp=-(px(3)*four(in(3*jt+3),in(3)+1)+py(3)*
66948  & four(in(3*jt+3)+1,in(3)+1))
66949  IF(abs(pxp**2+pyp**2-px(3)**2-py(3)**2).LT.0.01d0) THEN
66950  px(3)=pxp
66951  py(3)=pyp
66952  ENDIF
66953  ENDIF
66954 
66955 C...Sum up known four-momentum. Gives coefficients for m2 expression.
66956  DO 1010 j=1,4
66957  dhg(j)=0d0
66958  p(i,j)=px(jt)*p(in(3*jt+3),j)+py(jt)*p(in(3*jt+3)+1,j)+
66959  & px(3)*p(in(3),j)+py(3)*p(in(3)+1,j)
66960  DO 990 in1=in(3*jt+1),in(1)-4*js,4*js
66961  p(i,j)=p(i,j)+p(in1+2,3)*p(in1,j)
66962  990 CONTINUE
66963  DO 1000 in2=in(3*jt+2),in(2)-4*js,4*js
66964  p(i,j)=p(i,j)+p(in2+2,3)*p(in2,j)
66965  1000 CONTINUE
66966  1010 CONTINUE
66967  dhm(1)=four(i,i)
66968  dhm(2)=2d0*four(i,in(1))
66969  dhm(3)=2d0*four(i,in(2))
66970  dhm(4)=2d0*four(in(1),in(2))
66971 
66972 C...Find coefficients for Gamma expression.
66973  DO 1030 in2=in(1)+1,in(2),4
66974  DO 1020 in1=in(1),in2-1,4
66975  dhc=2d0*four(in1,in2)
66976  dhg(1)=dhg(1)+p(in1+2,jt)*p(in2+2,jt)*dhc
66977  IF(in1.EQ.in(1)) dhg(2)=dhg(2)-js*p(in2+2,jt)*dhc
66978  IF(in2.EQ.in(2)) dhg(3)=dhg(3)+js*p(in1+2,jt)*dhc
66979  IF(in1.EQ.in(1).AND.in2.EQ.in(2)) dhg(4)=dhg(4)-dhc
66980  1020 CONTINUE
66981  1030 CONTINUE
66982 
66983 C...Solve (m2, Gamma) equation system for energies taken.
66984  dhs1=dhm(jr+1)*dhg(4)-dhm(4)*dhg(jr+1)
66985  IF(abs(dhs1).LT.1d-4) goto 710
66986  dhs2=dhm(4)*(gam(3)-dhg(1))-dhm(jt+1)*dhg(jr+1)-dhg(4)*
66987  &(p(i,5)**2-dhm(1))+dhg(jt+1)*dhm(jr+1)
66988  dhs3=dhm(jt+1)*(gam(3)-dhg(1))-dhg(jt+1)*(p(i,5)**2-dhm(1))
66989  p(in(jr)+2,4)=0.5d0*(sqrt(max(0d0,dhs2**2-4d0*dhs1*dhs3))/
66990  &abs(dhs1)-dhs2/dhs1)
66991  IF(dhm(jt+1)+dhm(4)*p(in(jr)+2,4).LE.0d0) goto 710
66992  p(in(jt)+2,4)=(p(i,5)**2-dhm(1)-dhm(jr+1)*p(in(jr)+2,4))/
66993  &(dhm(jt+1)+dhm(4)*p(in(jr)+2,4))
66994 
66995 C...Step to new region if necessary.
66996  IF(p(in(jr)+2,4).GT.p(in(jr)+2,3)) THEN
66997  p(in(jr)+2,4)=p(in(jr)+2,3)
66998  p(in(jr)+2,jt)=1d0
66999  in(jr)=in(jr)+4*js
67000  IF(js*in(jr).GT.js*in(4*jr)) goto 710
67001  IF(four(in(1),in(2)).LE.1d-2) THEN
67002  p(in(jt)+2,4)=p(in(jt)+2,3)
67003  p(in(jt)+2,jt)=0d0
67004  in(jt)=in(jt)+4*js
67005  ENDIF
67006  goto 960
67007  ELSEIF(p(in(jt)+2,4).GT.p(in(jt)+2,3)) THEN
67008  p(in(jt)+2,4)=p(in(jt)+2,3)
67009  p(in(jt)+2,jt)=0d0
67010  in(jt)=in(jt)+4*js
67011  goto 960
67012  ENDIF
67013 
67014 C...Four-momentum of particle. Remaining quantities. Loop back.
67015  1040 DO 1050 j=1,4
67016  p(i,j)=p(i,j)+p(in(1)+2,4)*p(in(1),j)+p(in(2)+2,4)*p(in(2),j)
67017  p(n+nrs,j)=p(n+nrs,j)-p(i,j)
67018  1050 CONTINUE
67019  IF(p(in(1)+2,4).GT.1d0+paru(14).OR.p(in(1)+2,4).LT.-paru(14).OR.
67020  &p(in(2)+2,4).GT.1d0+paru(14).OR.p(in(2)+2,4).LT.-paru(14))
67021  &goto 200
67022  IF(p(i,4).LT.p(i,5)) goto 710
67023  kfl(jt)=-kfl(3)
67024  pmq(jt)=pmq(3)
67025  px(jt)=-px(3)
67026  py(jt)=-py(3)
67027  gam(jt)=gam(3)
67028  IF(in(3).NE.in(3*jt+3)) THEN
67029  DO 1060 j=1,4
67030  p(in(3*jt+3),j)=p(in(3),j)
67031  p(in(3*jt+3)+1,j)=p(in(3)+1,j)
67032  1060 CONTINUE
67033  ENDIF
67034  DO 1070 jq=1,2
67035  in(3*jt+jq)=in(jq)
67036  p(in(jq)+2,3)=p(in(jq)+2,3)-p(in(jq)+2,4)
67037  p(in(jq)+2,jt)=p(in(jq)+2,jt)-js*(3-2*jq)*p(in(jq)+2,4)
67038  1070 CONTINUE
67039  IF(ibarrk(jt).EQ.1.AND.mod(iabs(k(i,2)),10000).GT.1000)
67040  &ibarrk(jt)=0
67041  goto 870
67042 
67043 C...Final hadron: side, flavour, hadron, mass.
67044  1080 i=i+1
67045  k(i,1)=1
67046  k(i,3)=ie(jr)
67047  k(i,4)=0
67048  k(i,5)=0
67049  CALL pykfdi(kfl(jr),-kfl(3),kfldmp,k(i,2))
67050  IF(k(i,2).EQ.0) goto 710
67051  IF(ibarrk(jt).EQ.1.AND.mod(iabs(k(i-1,2)),10000).GT.1000)
67052  &ibarrk(jt)=0
67053  IF(ibarrk(jt).EQ.1.AND.mod(iabs(k(i,2)),10000).GT.1000)
67054  &k(i,3)=ijuori(jt)
67055  IF(ibarrk(jr).EQ.1.AND.mod(iabs(k(i,2)),10000).GT.1000)
67056  &k(i,3)=ijuori(jr)
67057  p(i,5)=pymass(k(i,2))
67058  pr(jr)=p(i,5)**2+(px(jr)-px(3))**2+(py(jr)-py(3))**2
67059 
67060 C...Final two hadrons: find common setup of four-vectors.
67061  jq=1
67062  IF(p(in(4)+2,3)*p(in(5)+2,3)*four(in(4),in(5)).LT.
67063  &p(in(7)+2,3)*p(in(8)+2,3)*four(in(7),in(8))) jq=2
67064  dhc12=four(in(3*jq+1),in(3*jq+2))
67065  dhr1=four(n+nrs,in(3*jq+2))/dhc12
67066  dhr2=four(n+nrs,in(3*jq+1))/dhc12
67067  IF(in(4).NE.in(7).OR.in(5).NE.in(8)) THEN
67068  px(3-jq)=-four(n+nrs,in(3*jq+3))-px(jq)
67069  py(3-jq)=-four(n+nrs,in(3*jq+3)+1)-py(jq)
67070  pr(3-jq)=p(i+(jt+jq-3)**2-1,5)**2+(px(3-jq)+(2*jq-3)*js*
67071  & px(3))**2+(py(3-jq)+(2*jq-3)*js*py(3))**2
67072  ENDIF
67073 
67074 C...Solve kinematics for final two hadrons, if possible.
67075  wrem2=2d0*dhr1*dhr2*dhc12
67076  fd=(sqrt(pr(1))+sqrt(pr(2)))/sqrt(wrem2)
67077  IF(mju(1)+mju(2).NE.0.AND.i.EQ.isav+2.AND.fd.GE.1d0) goto 200
67078  IF(fd.GE.1d0) goto 710
67079  fa=wrem2+pr(jt)-pr(jr)
67080  fb=sqrt(max(0d0,fa**2-4d0*wrem2*pr(jt)))
67081  prevcf=parj(42)
67082  IF(mstj(11).EQ.2) prevcf=parj(39)
67083  prev=1d0/(1d0+exp(min(50d0,prevcf*fb*parj(40))))
67084  fb=sign(fb,js*(pyr(0)-prev))
67085  kfl1a=iabs(kfl(1))
67086  kfl2a=iabs(kfl(2))
67087  IF(max(mod(kfl1a,10),mod(kfl1a/1000,10),mod(kfl2a,10),
67088  &mod(kfl2a/1000,10)).GE.6) fb=sign(sqrt(max(0d0,fa**2-
67089  &4d0*wrem2*pr(jt))),dble(js))
67090  DO 1090 j=1,4
67091  p(i-1,j)=(px(jt)+px(3))*p(in(3*jq+3),j)+(py(jt)+py(3))*
67092  & p(in(3*jq+3)+1,j)+0.5d0*(dhr1*(fa+fb)*p(in(3*jq+1),j)+
67093  & dhr2*(fa-fb)*p(in(3*jq+2),j))/wrem2
67094  p(i,j)=p(n+nrs,j)-p(i-1,j)
67095  1090 CONTINUE
67096  IF(p(i-1,4).LT.p(i-1,5).OR.p(i,4).LT.p(i,5)) goto 710
67097  dm2f1=p(i-1,4)**2-p(i-1,1)**2-p(i-1,2)**2-p(i-1,3)**2-p(i-1,5)**2
67098  dm2f2=p(i,4)**2-p(i,1)**2-p(i,2)**2-p(i,3)**2-p(i,5)**2
67099  IF(dm2f1.GT.1d-10*p(i-1,4)**2.OR.dm2f2.GT.1d-10*p(i,4)**2) THEN
67100  ntryfn=ntryfn+1
67101  IF(ntryfn.LT.100) goto 140
67102  CALL pyerrm(13,'(PYSTRF:) bad energies for final two hadrons')
67103  ENDIF
67104 
67105 C...Mark jets as fragmented and give daughter pointers.
67106  n=i-nrs+1
67107  DO 1100 i=nsav+1,nsav+np
67108  im=k(i,3)
67109  k(im,1)=k(im,1)+10
67110  IF(mstu(16).NE.2) THEN
67111  k(im,4)=nsav+1
67112  k(im,5)=nsav+1
67113  ELSE
67114  k(im,4)=nsav+2
67115  k(im,5)=n
67116  ENDIF
67117  1100 CONTINUE
67118 
67119 C...Document string system. Move up particles.
67120  nsav=nsav+1
67121  k(nsav,1)=11
67122  k(nsav,2)=92
67123  k(nsav,3)=ip
67124  k(nsav,4)=nsav+1
67125  k(nsav,5)=n
67126  DO 1110 j=1,4
67127  p(nsav,j)=dps(j)
67128  v(nsav,j)=v(ip,j)
67129  1110 CONTINUE
67130  p(nsav,5)=sqrt(max(0d0,dps(4)**2-dps(1)**2-dps(2)**2-dps(3)**2))
67131  v(nsav,5)=0d0
67132  DO 1130 i=nsav+1,n
67133  DO 1120 j=1,5
67134  k(i,j)=k(i+nrs-1,j)
67135  p(i,j)=p(i+nrs-1,j)
67136  v(i,j)=0d0
67137  1120 CONTINUE
67138  1130 CONTINUE
67139  mstu91=mstu(90)
67140  DO 1140 iz=mstu90+1,mstu91
67141  mstu9t(iz)=mstu(90+iz)-nrs+1-nsav+n
67142  paru9t(iz)=paru(90+iz)
67143  1140 CONTINUE
67144  mstu(90)=mstu90
67145 
67146 C...Order particles in rank along the chain. Update mother pointer.
67147  DO 1160 i=nsav+1,n
67148  DO 1150 j=1,5
67149  k(i-nsav+n,j)=k(i,j)
67150  p(i-nsav+n,j)=p(i,j)
67151  1150 CONTINUE
67152  1160 CONTINUE
67153  i1=nsav
67154  DO 1190 i=n+1,2*n-nsav
67155  IF(k(i,3).NE.ie(1).AND.k(i,3).NE.ijuori(1)) goto 1190
67156  i1=i1+1
67157  DO 1170 j=1,5
67158  k(i1,j)=k(i,j)
67159  p(i1,j)=p(i,j)
67160  1170 CONTINUE
67161  IF(mstu(16).NE.2) k(i1,3)=nsav
67162  DO 1180 iz=mstu90+1,mstu91
67163  IF(mstu9t(iz).EQ.i) THEN
67164  mstu(90)=mstu(90)+1
67165  mstu(90+mstu(90))=i1
67166  paru(90+mstu(90))=paru9t(iz)
67167  ENDIF
67168  1180 CONTINUE
67169  1190 CONTINUE
67170  DO 1220 i=2*n-nsav,n+1,-1
67171  IF(k(i,3).EQ.ie(1).OR.k(i,3).EQ.ijuori(1)) goto 1220
67172  i1=i1+1
67173  DO 1200 j=1,5
67174  k(i1,j)=k(i,j)
67175  p(i1,j)=p(i,j)
67176  1200 CONTINUE
67177  IF(mstu(16).NE.2) k(i1,3)=nsav
67178  DO 1210 iz=mstu90+1,mstu91
67179  IF(mstu9t(iz).EQ.i) THEN
67180  mstu(90)=mstu(90)+1
67181  mstu(90+mstu(90))=i1
67182  paru(90+mstu(90))=paru9t(iz)
67183  ENDIF
67184  1210 CONTINUE
67185  1220 CONTINUE
67186 
67187 C...Boost back particle system. Set production vertices.
67188  IF(mbst.EQ.0) THEN
67189  mstu(33)=1
67190  CALL pyrobo(nsav+1,n,0d0,0d0,dps(1)/dps(4),dps(2)/dps(4),
67191  & dps(3)/dps(4))
67192  ELSE
67193  DO 1230 i=nsav+1,n
67194  hhpmt=p(i,1)**2+p(i,2)**2+p(i,5)**2
67195  IF(p(i,3).GT.0d0) THEN
67196  hhpez=(p(i,4)+p(i,3))*hhbz
67197  p(i,3)=0.5d0*(hhpez-hhpmt/hhpez)
67198  p(i,4)=0.5d0*(hhpez+hhpmt/hhpez)
67199  ELSE
67200  hhpez=(p(i,4)-p(i,3))/hhbz
67201  p(i,3)=-0.5d0*(hhpez-hhpmt/hhpez)
67202  p(i,4)=0.5d0*(hhpez+hhpmt/hhpez)
67203  ENDIF
67204  1230 CONTINUE
67205  ENDIF
67206  DO 1250 i=nsav+1,n
67207  DO 1240 j=1,4
67208  v(i,j)=v(ip,j)
67209  1240 CONTINUE
67210  1250 CONTINUE
67211 
67212  RETURN
67213  END
67214 
67215 C*********************************************************************
67216 
67217 C...PYJURF
67218 C...From three given input vectors in PJU the boost VJU from
67219 C...the "lab frame" to the junction rest frame is constructed.
67220 
67221  SUBROUTINE pyjurf(PJU,VJU)
67222 
67223 C...Double precision and integer declarations.
67224  IMPLICIT DOUBLE PRECISION(a-h, o-z)
67225  IMPLICIT INTEGER(i-n)
67226 
67227 C...Input, output and local arrays.
67228  dimension pju(3,5),vju(5),psum(5),a(3,3),penew(3),pcm(5,5)
67229  DATA twopi/6.283186d0/
67230 
67231 C...Calculate masses and other invariants.
67232  DO 100 j=1,4
67233  psum(j)=pju(1,j)+pju(2,j)+pju(3,j)
67234  100 CONTINUE
67235  psum2=psum(4)**2-psum(1)**2-psum(2)**2-psum(3)**2
67236  psum(5)=sqrt(psum2)
67237  DO 120 i=1,3
67238  DO 110 j=1,3
67239  a(i,j)=pju(i,4)*pju(j,4)-pju(i,1)*pju(j,1)-
67240  & pju(i,2)*pju(j,2)-pju(i,3)*pju(j,3)
67241  110 CONTINUE
67242  120 CONTINUE
67243 
67244 C...Pick I to be most massive parton and J to be the one closest to I.
67245  itry=0
67246  i=1
67247  IF(a(2,2).GT.a(1,1)) i=2
67248  IF(a(3,3).GT.max(a(1,1),a(2,2))) i=3
67249  130 itry=itry+1
67250  j=1+mod(i,3)
67251  k=1+mod(j,3)
67252  IF(a(i,k)**2*a(j,j).LT.a(i,j)**2*a(k,k)) THEN
67253  k=1+mod(i,3)
67254  j=1+mod(k,3)
67255  ENDIF
67256  pmi2=a(i,i)
67257  pmj2=a(j,j)
67258  pmk2=a(k,k)
67259  aij=a(i,j)
67260  aik=a(i,k)
67261  ajk=a(j,k)
67262 
67263 C...Trivial find new parton energies if all three partons are massless.
67264  IF(pmi2.LT.1d-4) THEN
67265  pei=sqrt(2d0*aik*aij/(3d0*ajk))
67266  pej=sqrt(2d0*ajk*aij/(3d0*aik))
67267  pek=sqrt(2d0*aik*ajk/(3d0*aij))
67268 
67269 C...Else find momentum range for parton I and values at extremes.
67270  ELSE
67271  paimin=0d0
67272  peimin=sqrt(pmi2)
67273  pejmin=aij/peimin
67274  pekmin=aik/peimin
67275  pajmin=sqrt(max(0d0,pejmin**2-pmj2))
67276  pakmin=sqrt(max(0d0,pekmin**2-pmk2))
67277  fmin=pejmin*pekmin+0.5d0*pajmin*pakmin-ajk
67278  peimax=(aij+aik)/sqrt(pmj2+pmk2+2d0*ajk)
67279  IF(pmj2.GT.1d-4) peimax=aij/sqrt(pmj2)
67280  paimax=sqrt(max(0d0,peimax**2-pmi2))
67281  hi=peimax**2-0.25d0*paimax**2
67282  pajmax=(peimax*sqrt(max(0d0,aij**2-pmj2*hi))-
67283  & 0.5d0*paimax*aij)/hi
67284  pakmax=(peimax*sqrt(max(0d0,aik**2-pmk2*hi))-
67285  & 0.5d0*paimax*aik)/hi
67286  pejmax=sqrt(pajmax**2+pmj2)
67287  pekmax=sqrt(pakmax**2+pmk2)
67288  fmax=pejmax*pekmax+0.5d0*pajmax*pakmax-ajk
67289 
67290 C...If unexpected values at upper endpoint then pick another parton.
67291  IF(fmax.GT.0d0.AND.itry.LE.2) THEN
67292  i1=1+mod(i,3)
67293  IF(a(i1,i1).GE.1d-4) THEN
67294  i=i1
67295  goto 130
67296  ENDIF
67297  itry=itry+1
67298  i1=1+mod(i,3)
67299  IF(itry.LE.2.AND.a(i1,i1).GE.1d-4) THEN
67300  i=i1
67301  goto 130
67302  ENDIF
67303  ENDIF
67304 
67305 C..Start binary + linear search to find solution inside range.
67306  iter=0
67307  itmin=0
67308  itmax=0
67309  pai=0.5d0*(paimin+paimax)
67310  140 iter=iter+1
67311 
67312 C...Derive momentum of other two partons and distance to root.
67313  pei=sqrt(pai**2+pmi2)
67314  hi=pei**2-0.25d0*pai**2
67315  paj=(pei*sqrt(max(0d0,aij**2-pmj2*hi))-0.5d0*pai*aij)/hi
67316  pej=sqrt(paj**2+pmj2)
67317  pak=(pei*sqrt(max(0d0,aik**2-pmk2*hi))-0.5d0*pai*aik)/hi
67318  pek=sqrt(pak**2+pmk2)
67319  fnow=pej*pek+0.5d0*paj*pak-ajk
67320 
67321 C...Pick next I momentum to explore, hopefully closer to root.
67322  IF(fnow.GT.0d0) THEN
67323  paimin=pai
67324  fmin=fnow
67325  itmin=itmin+1
67326  ELSE
67327  paimax=pai
67328  fmax=fnow
67329  itmax=itmax+1
67330  ENDIF
67331  IF((iter.LT.10.OR.itmin.LE.1.OR.itmax.LE.1).AND.iter.LT.20)
67332  & THEN
67333  pai=0.5d0*(paimin+paimax)
67334  goto 140
67335  ELSEIF(iter.LT.40.AND.fmin.GT.0d0.AND.fmax.LT.0d0.AND.
67336  & abs(fnow).GT.1d-12*psum2) THEN
67337  pai=paimin+(paimax-paimin)*fmin/(fmin-fmax)
67338  goto 140
67339  ENDIF
67340  ENDIF
67341 
67342 C...Now know energies in junction rest frame.
67343  penew(i)=pei
67344  penew(j)=pej
67345  penew(k)=pek
67346 
67347 C...Boost (copy of) partons to their rest frame.
67348  vxcm=-psum(1)/psum(5)
67349  vycm=-psum(2)/psum(5)
67350  vzcm=-psum(3)/psum(5)
67351  gamcm=sqrt(1d0+vxcm**2+vycm**2+vzcm**2)
67352  DO 150 i=1,3
67353  fac1=pju(i,1)*vxcm+pju(i,2)*vycm+pju(i,3)*vzcm
67354  fac2=fac1/(1d0+gamcm)+pju(i,4)
67355  pcm(i,1)=pju(i,1)+fac2*vxcm
67356  pcm(i,2)=pju(i,2)+fac2*vycm
67357  pcm(i,3)=pju(i,3)+fac2*vzcm
67358  pcm(i,4)=pju(i,4)*gamcm+fac1
67359  pcm(i,5)=sqrt(pcm(i,1)**2+pcm(i,2)**2+pcm(i,3)**2)
67360  150 CONTINUE
67361 
67362 C...Construct difference vectors and boost to junction rest frame.
67363  DO 160 j=1,3
67364  pcm(4,j)=pcm(1,j)/pcm(1,4)-pcm(2,j)/pcm(2,4)
67365  pcm(5,j)=pcm(1,j)/pcm(1,4)-pcm(3,j)/pcm(3,4)
67366  160 CONTINUE
67367  pcm(4,4)=penew(1)/pcm(1,4)-penew(2)/pcm(2,4)
67368  pcm(5,4)=penew(1)/pcm(1,4)-penew(3)/pcm(3,4)
67369  pcm4s=pcm(4,1)**2+pcm(4,2)**2+pcm(4,3)**2
67370  pcm5s=pcm(5,1)**2+pcm(5,2)**2+pcm(5,3)**2
67371  pcm45=pcm(4,1)*pcm(5,1)+pcm(4,2)*pcm(5,2)+pcm(4,3)*pcm(5,3)
67372  c4=(pcm5s*pcm(4,4)-pcm45*pcm(5,4))/(pcm4s*pcm5s-pcm45**2)
67373  c5=(pcm4s*pcm(5,4)-pcm45*pcm(4,4))/(pcm4s*pcm5s-pcm45**2)
67374  vxju=c4*pcm(4,1)+c5*pcm(5,1)
67375  vyju=c4*pcm(4,2)+c5*pcm(5,2)
67376  vzju=c4*pcm(4,3)+c5*pcm(5,3)
67377  gamju=sqrt(1d0+vxju**2+vyju**2+vzju**2)
67378 
67379 C...Add two boosts, giving final result.
67380  fcm=(vxju*vxcm+vyju*vycm+vzju*vzcm)/(1+gamcm)+gamju
67381  vju(1)=vxju+fcm*vxcm
67382  vju(2)=vyju+fcm*vycm
67383  vju(3)=vzju+fcm*vzcm
67384  vju(4)=sqrt(1d0+vju(1)**2+vju(2)**2+vju(3)**2)
67385  vju(5)=1d0
67386 
67387 C...In case of error in reconstruction: revert to CM frame of system.
67388  cth12=(pcm(1,1)*pcm(2,1)+pcm(1,2)*pcm(2,2)+pcm(1,3)*pcm(2,3))/
67389  &(pcm(1,5)*pcm(2,5))
67390  cth13=(pcm(1,1)*pcm(3,1)+pcm(1,2)*pcm(3,2)+pcm(1,3)*pcm(3,3))/
67391  &(pcm(1,5)*pcm(3,5))
67392  cth23=(pcm(2,1)*pcm(3,1)+pcm(2,2)*pcm(3,2)+pcm(2,3)*pcm(3,3))/
67393  &(pcm(2,5)*pcm(3,5))
67394  errccm=(cth12+0.5d0)**2+(cth13+0.5d0)**2+(cth23+0.5d0)**2
67395  errtcm=twopi-acos(cth12)-acos(cth13)-acos(cth23)
67396  DO 170 i=1,3
67397  fac1=pju(i,1)*vju(1)+pju(i,2)*vju(2)+pju(i,3)*vju(3)
67398  fac2=fac1/(1d0+vju(4))+pju(i,4)
67399  pcm(i,1)=pju(i,1)+fac2*vju(1)
67400  pcm(i,2)=pju(i,2)+fac2*vju(2)
67401  pcm(i,3)=pju(i,3)+fac2*vju(3)
67402  pcm(i,4)=pju(i,4)*vju(4)+fac1
67403  pcm(i,5)=sqrt(pcm(i,1)**2+pcm(i,2)**2+pcm(i,3)**2)
67404  170 CONTINUE
67405  cth12=(pcm(1,1)*pcm(2,1)+pcm(1,2)*pcm(2,2)+pcm(1,3)*pcm(2,3))/
67406  &(pcm(1,5)*pcm(2,5))
67407  cth13=(pcm(1,1)*pcm(3,1)+pcm(1,2)*pcm(3,2)+pcm(1,3)*pcm(3,3))/
67408  &(pcm(1,5)*pcm(3,5))
67409  cth23=(pcm(2,1)*pcm(3,1)+pcm(2,2)*pcm(3,2)+pcm(2,3)*pcm(3,3))/
67410  &(pcm(2,5)*pcm(3,5))
67411  errcju=(cth12+0.5d0)**2+(cth13+0.5d0)**2+(cth23+0.5d0)**2
67412  errtju=twopi-acos(cth12)-acos(cth13)-acos(cth23)
67413  IF(errcju+errtju.GT.errccm+errtcm) THEN
67414  vju(1)=vxcm
67415  vju(2)=vycm
67416  vju(3)=vzcm
67417  vju(4)=gamcm
67418  ENDIF
67419 
67420  RETURN
67421  END
67422 
67423 C*********************************************************************
67424 
67425 C...PYINDF
67426 C...Handles the fragmentation of a jet system (or a single
67427 C...jet) according to independent fragmentation models.
67428 
67429  SUBROUTINE pyindf(IP)
67430 
67431 C...Double precision and integer declarations.
67432  IMPLICIT DOUBLE PRECISION(a-h, o-z)
67433  IMPLICIT INTEGER(i-n)
67434  INTEGER pyk,pychge,pycomp
67435 C...Commonblocks.
67436  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
67437  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
67438  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
67439  SAVE /pyjets/,/pydat1/,/pydat2/
67440 C...Local arrays.
67441  dimension dps(5),psi(4),nfi(3),nfl(3),ifet(3),kflf(3),
67442  &kflo(2),pxo(2),pyo(2),wo(2)
67443 
67444 C.. MOPS error message
67445  IF(mstj(12).GT.3) CALL pyerrm(9,'(PYINDF:) MSTJ(12)>3 options'//
67446  &' are not treated as expected in independent fragmentation')
67447 
67448 C...Reset counters. Identify parton system and take copy. Check flavour.
67449  nsav=n
67450  mstu90=mstu(90)
67451  njet=0
67452  kqsum=0
67453  DO 100 j=1,5
67454  dps(j)=0d0
67455  100 CONTINUE
67456  i=ip-1
67457  110 i=i+1
67458  IF(i.GT.min(n,mstu(4)-mstu(32))) THEN
67459  CALL pyerrm(12,'(PYINDF:) failed to reconstruct jet system')
67460  IF(mstu(21).GE.1) RETURN
67461  ENDIF
67462  IF(k(i,1).NE.1.AND.k(i,1).NE.2) goto 110
67463  kc=pycomp(k(i,2))
67464  IF(kc.EQ.0) goto 110
67465  kq=kchg(kc,2)*isign(1,k(i,2))
67466  IF(kq.EQ.0) goto 110
67467  njet=njet+1
67468  IF(kq.NE.2) kqsum=kqsum+kq
67469  DO 120 j=1,5
67470  k(nsav+njet,j)=k(i,j)
67471  p(nsav+njet,j)=p(i,j)
67472  dps(j)=dps(j)+p(i,j)
67473  120 CONTINUE
67474  k(nsav+njet,3)=i
67475  IF(k(i,1).EQ.2.OR.(mstj(3).LE.5.AND.n.GT.i.AND.
67476  &k(i+1,1).EQ.2)) goto 110
67477  IF(njet.NE.1.AND.kqsum.NE.0) THEN
67478  CALL pyerrm(12,'(PYINDF:) unphysical flavour combination')
67479  IF(mstu(21).GE.1) RETURN
67480  ENDIF
67481 
67482 C...Boost copied system to CM frame. Find CM energy and sum flavours.
67483  IF(njet.NE.1) THEN
67484  mstu(33)=1
67485  CALL pyrobo(nsav+1,nsav+njet,0d0,0d0,-dps(1)/dps(4),
67486  & -dps(2)/dps(4),-dps(3)/dps(4))
67487  ENDIF
67488  pecm=0d0
67489  DO 130 j=1,3
67490  nfi(j)=0
67491  130 CONTINUE
67492  DO 140 i=nsav+1,nsav+njet
67493  pecm=pecm+p(i,4)
67494  kfa=iabs(k(i,2))
67495  IF(kfa.LE.3) THEN
67496  nfi(kfa)=nfi(kfa)+isign(1,k(i,2))
67497  ELSEIF(kfa.GT.1000) THEN
67498  kfla=mod(kfa/1000,10)
67499  kflb=mod(kfa/100,10)
67500  IF(kfla.LE.3) nfi(kfla)=nfi(kfla)+isign(1,k(i,2))
67501  IF(kflb.LE.3) nfi(kflb)=nfi(kflb)+isign(1,k(i,2))
67502  ENDIF
67503  140 CONTINUE
67504 
67505 C...Loop over attempts made. Reset counters.
67506  ntry=0
67507  150 ntry=ntry+1
67508  IF(ntry.GT.200) THEN
67509  CALL pyerrm(14,'(PYINDF:) caught in infinite loop')
67510  IF(mstu(21).GE.1) RETURN
67511  ENDIF
67512  n=nsav+njet
67513  mstu(90)=mstu90
67514  DO 160 j=1,3
67515  nfl(j)=nfi(j)
67516  ifet(j)=0
67517  kflf(j)=0
67518  160 CONTINUE
67519 
67520 C...Loop over jets to be fragmented.
67521  DO 230 ip1=nsav+1,nsav+njet
67522  mstj(91)=0
67523  nsav1=n
67524  mstu91=mstu(90)
67525 
67526 C...Initial flavour and momentum values. Jet along +z axis.
67527  kflh=iabs(k(ip1,2))
67528  IF(kflh.GT.10) kflh=mod(kflh/1000,10)
67529  kflo(2)=0
67530  wf=p(ip1,4)+sqrt(p(ip1,1)**2+p(ip1,2)**2+p(ip1,3)**2)
67531 
67532 C...Initial values for quark or diquark jet.
67533  170 IF(iabs(k(ip1,2)).NE.21) THEN
67534  nstr=1
67535  kflo(1)=k(ip1,2)
67536  CALL pyptdi(0,pxo(1),pyo(1))
67537  wo(1)=wf
67538 
67539 C...Initial values for gluon treated like random quark jet.
67540  ELSEIF(mstj(2).LE.2) THEN
67541  nstr=1
67542  IF(mstj(2).EQ.2) mstj(91)=1
67543  kflo(1)=int(1d0+(2d0+parj(2))*pyr(0))*(-1)**int(pyr(0)+0.5d0)
67544  CALL pyptdi(0,pxo(1),pyo(1))
67545  wo(1)=wf
67546 
67547 C...Initial values for gluon treated like quark-antiquark jet pair,
67548 C...sharing energy according to Altarelli-Parisi splitting function.
67549  ELSE
67550  nstr=2
67551  IF(mstj(2).EQ.4) mstj(91)=1
67552  kflo(1)=int(1d0+(2d0+parj(2))*pyr(0))*(-1)**int(pyr(0)+0.5d0)
67553  kflo(2)=-kflo(1)
67554  CALL pyptdi(0,pxo(1),pyo(1))
67555  pxo(2)=-pxo(1)
67556  pyo(2)=-pyo(1)
67557  wo(1)=wf*pyr(0)**(1d0/3d0)
67558  wo(2)=wf-wo(1)
67559  ENDIF
67560 
67561 C...Initial values for rank, flavour, pT and W+.
67562  DO 220 istr=1,nstr
67563  180 i=n
67564  mstu(90)=mstu91
67565  irank=0
67566  kfl1=kflo(istr)
67567  px1=pxo(istr)
67568  py1=pyo(istr)
67569  w=wo(istr)
67570 
67571 C...New hadron. Generate flavour and hadron species.
67572  190 i=i+1
67573  IF(i.GE.mstu(4)-mstu(32)-njet-5) THEN
67574  CALL pyerrm(11,'(PYINDF:) no more memory left in PYJETS')
67575  IF(mstu(21).GE.1) RETURN
67576  ENDIF
67577  irank=irank+1
67578  k(i,1)=1
67579  k(i,3)=ip1
67580  k(i,4)=0
67581  k(i,5)=0
67582  200 CALL pykfdi(kfl1,0,kfl2,k(i,2))
67583  IF(k(i,2).EQ.0) goto 180
67584  IF(irank.EQ.1.AND.iabs(kfl1).LE.10.AND.iabs(kfl2).GT.10) THEN
67585  IF(pyr(0).GT.parj(19)) goto 200
67586  ENDIF
67587 
67588 C...Find hadron mass. Generate four-momentum.
67589  p(i,5)=pymass(k(i,2))
67590  CALL pyptdi(kfl1,px2,py2)
67591  p(i,1)=px1+px2
67592  p(i,2)=py1+py2
67593  pr=p(i,5)**2+p(i,1)**2+p(i,2)**2
67594  CALL pyzdis(kfl1,kfl2,pr,z)
67595  mzsav=0
67596  IF(iabs(kfl1).GE.4.AND.iabs(kfl1).LE.8.AND.mstu(90).LT.8) THEN
67597  mzsav=1
67598  mstu(90)=mstu(90)+1
67599  mstu(90+mstu(90))=i
67600  paru(90+mstu(90))=z
67601  ENDIF
67602  p(i,3)=0.5d0*(z*w-pr/max(1d-4,z*w))
67603  p(i,4)=0.5d0*(z*w+pr/max(1d-4,z*w))
67604  IF(mstj(3).GE.1.AND.irank.EQ.1.AND.kflh.GE.4.AND.
67605  & p(i,3).LE.0.001d0) THEN
67606  IF(w.GE.p(i,5)+0.5d0*parj(32)) goto 180
67607  p(i,3)=0.0001d0
67608  p(i,4)=sqrt(pr)
67609  z=p(i,4)/w
67610  ENDIF
67611 
67612 C...Remaining flavour and momentum.
67613  kfl1=-kfl2
67614  px1=-px2
67615  py1=-py2
67616  w=(1d0-z)*w
67617  DO 210 j=1,5
67618  v(i,j)=0d0
67619  210 CONTINUE
67620 
67621 C...Check if pL acceptable. Go back for new hadron if enough energy.
67622  IF(mstj(3).GE.0.AND.p(i,3).LT.0d0) THEN
67623  i=i-1
67624  IF(mzsav.EQ.1) mstu(90)=mstu(90)-1
67625  ENDIF
67626  IF(w.GT.parj(31)) goto 190
67627  n=i
67628  220 CONTINUE
67629  IF(mod(mstj(3),5).EQ.4.AND.n.EQ.nsav1) wf=wf+0.1d0*parj(32)
67630  IF(mod(mstj(3),5).EQ.4.AND.n.EQ.nsav1) goto 170
67631 
67632 C...Rotate jet to new direction.
67633  the=pyangl(p(ip1,3),sqrt(p(ip1,1)**2+p(ip1,2)**2))
67634  phi=pyangl(p(ip1,1),p(ip1,2))
67635  mstu(33)=1
67636  CALL pyrobo(nsav1+1,n,the,phi,0d0,0d0,0d0)
67637  k(k(ip1,3),4)=nsav1+1
67638  k(k(ip1,3),5)=n
67639 
67640 C...End of jet generation loop. Skip conservation in some cases.
67641  230 CONTINUE
67642  IF(njet.EQ.1.OR.mstj(3).LE.0) goto 490
67643  IF(mod(mstj(3),5).NE.0.AND.n-nsav-njet.LT.2) goto 150
67644 
67645 C...Subtract off produced hadron flavours, finished if zero.
67646  DO 240 i=nsav+njet+1,n
67647  kfa=iabs(k(i,2))
67648  kfla=mod(kfa/1000,10)
67649  kflb=mod(kfa/100,10)
67650  kflc=mod(kfa/10,10)
67651  IF(kfla.EQ.0) THEN
67652  IF(kflb.LE.3) nfl(kflb)=nfl(kflb)-isign(1,k(i,2))*(-1)**kflb
67653  IF(kflc.LE.3) nfl(kflc)=nfl(kflc)+isign(1,k(i,2))*(-1)**kflb
67654  ELSE
67655  IF(kfla.LE.3) nfl(kfla)=nfl(kfla)-isign(1,k(i,2))
67656  IF(kflb.LE.3) nfl(kflb)=nfl(kflb)-isign(1,k(i,2))
67657  IF(kflc.LE.3) nfl(kflc)=nfl(kflc)-isign(1,k(i,2))
67658  ENDIF
67659  240 CONTINUE
67660  nreq=(iabs(nfl(1))+iabs(nfl(2))+iabs(nfl(3))-iabs(nfl(1)+
67661  &nfl(2)+nfl(3)))/2+iabs(nfl(1)+nfl(2)+nfl(3))/3
67662  IF(nreq.EQ.0) goto 320
67663 
67664 C...Take away flavour of low-momentum particles until enough freedom.
67665  nrem=0
67666  250 irem=0
67667  p2min=pecm**2
67668  DO 260 i=nsav+njet+1,n
67669  p2=p(i,1)**2+p(i,2)**2+p(i,3)**2
67670  IF(k(i,1).EQ.1.AND.p2.LT.p2min) irem=i
67671  IF(k(i,1).EQ.1.AND.p2.LT.p2min) p2min=p2
67672  260 CONTINUE
67673  IF(irem.EQ.0) goto 150
67674  k(irem,1)=7
67675  kfa=iabs(k(irem,2))
67676  kfla=mod(kfa/1000,10)
67677  kflb=mod(kfa/100,10)
67678  kflc=mod(kfa/10,10)
67679  IF(kfla.GE.4.OR.kflb.GE.4) k(irem,1)=8
67680  IF(k(irem,1).EQ.8) goto 250
67681  IF(kfla.EQ.0) THEN
67682  isgn=isign(1,k(irem,2))*(-1)**kflb
67683  IF(kflb.LE.3) nfl(kflb)=nfl(kflb)+isgn
67684  IF(kflc.LE.3) nfl(kflc)=nfl(kflc)-isgn
67685  ELSE
67686  IF(kfla.LE.3) nfl(kfla)=nfl(kfla)+isign(1,k(irem,2))
67687  IF(kflb.LE.3) nfl(kflb)=nfl(kflb)+isign(1,k(irem,2))
67688  IF(kflc.LE.3) nfl(kflc)=nfl(kflc)+isign(1,k(irem,2))
67689  ENDIF
67690  nrem=nrem+1
67691  nreq=(iabs(nfl(1))+iabs(nfl(2))+iabs(nfl(3))-iabs(nfl(1)+
67692  &nfl(2)+nfl(3)))/2+iabs(nfl(1)+nfl(2)+nfl(3))/3
67693  IF(nreq.GT.nrem) goto 250
67694  DO 270 i=nsav+njet+1,n
67695  IF(k(i,1).EQ.8) k(i,1)=1
67696  270 CONTINUE
67697 
67698 C...Find combination of existing and new flavours for hadron.
67699  280 nfet=2
67700  IF(nfl(1)+nfl(2)+nfl(3).NE.0) nfet=3
67701  IF(nreq.LT.nrem) nfet=1
67702  IF(iabs(nfl(1))+iabs(nfl(2))+iabs(nfl(3)).EQ.0) nfet=0
67703  DO 290 j=1,nfet
67704  ifet(j)=1+(iabs(nfl(1))+iabs(nfl(2))+iabs(nfl(3)))*pyr(0)
67705  kflf(j)=isign(1,nfl(1))
67706  IF(ifet(j).GT.iabs(nfl(1))) kflf(j)=isign(2,nfl(2))
67707  IF(ifet(j).GT.iabs(nfl(1))+iabs(nfl(2))) kflf(j)=isign(3,nfl(3))
67708  290 CONTINUE
67709  IF(nfet.EQ.2.AND.(ifet(1).EQ.ifet(2).OR.kflf(1)*kflf(2).GT.0))
67710  &goto 280
67711  IF(nfet.EQ.3.AND.(ifet(1).EQ.ifet(2).OR.ifet(1).EQ.ifet(3).OR.
67712  &ifet(2).EQ.ifet(3).OR.kflf(1)*kflf(2).LT.0.OR.kflf(1)*kflf(3)
67713  &.LT.0.OR.kflf(1)*(nfl(1)+nfl(2)+nfl(3)).LT.0)) goto 280
67714  IF(nfet.EQ.0) kflf(1)=1+int((2d0+parj(2))*pyr(0))
67715  IF(nfet.EQ.0) kflf(2)=-kflf(1)
67716  IF(nfet.EQ.1) kflf(2)=isign(1+int((2d0+parj(2))*pyr(0)),-kflf(1))
67717  IF(nfet.LE.2) kflf(3)=0
67718  IF(kflf(3).NE.0) THEN
67719  kflfc=isign(1000*max(iabs(kflf(1)),iabs(kflf(3)))+
67720  & 100*min(iabs(kflf(1)),iabs(kflf(3)))+1,kflf(1))
67721  IF(kflf(1).EQ.kflf(3).OR.(1d0+3d0*parj(4))*pyr(0).GT.1d0)
67722  & kflfc=kflfc+isign(2,kflfc)
67723  ELSE
67724  kflfc=kflf(1)
67725  ENDIF
67726  CALL pykfdi(kflfc,kflf(2),kfldmp,kf)
67727  IF(kf.EQ.0) goto 280
67728  DO 300 j=1,max(2,nfet)
67729  nfl(iabs(kflf(j)))=nfl(iabs(kflf(j)))-isign(1,kflf(j))
67730  300 CONTINUE
67731 
67732 C...Store hadron at random among free positions.
67733  npos=min(1+int(pyr(0)*nrem),nrem)
67734  DO 310 i=nsav+njet+1,n
67735  IF(k(i,1).EQ.7) npos=npos-1
67736  IF(k(i,1).EQ.1.OR.npos.NE.0) goto 310
67737  k(i,1)=1
67738  k(i,2)=kf
67739  p(i,5)=pymass(k(i,2))
67740  p(i,4)=sqrt(p(i,1)**2+p(i,2)**2+p(i,3)**2+p(i,5)**2)
67741  310 CONTINUE
67742  nrem=nrem-1
67743  nreq=(iabs(nfl(1))+iabs(nfl(2))+iabs(nfl(3))-iabs(nfl(1)+
67744  &nfl(2)+nfl(3)))/2+iabs(nfl(1)+nfl(2)+nfl(3))/3
67745  IF(nrem.GT.0) goto 280
67746 
67747 C...Compensate for missing momentum in global scheme (3 options).
67748  320 IF(mod(mstj(3),5).NE.0.AND.mod(mstj(3),5).NE.4) THEN
67749  DO 340 j=1,3
67750  psi(j)=0d0
67751  DO 330 i=nsav+njet+1,n
67752  psi(j)=psi(j)+p(i,j)
67753  330 CONTINUE
67754  340 CONTINUE
67755  psi(4)=psi(1)**2+psi(2)**2+psi(3)**2
67756  pws=0d0
67757  DO 350 i=nsav+njet+1,n
67758  IF(mod(mstj(3),5).EQ.1) pws=pws+p(i,4)
67759  IF(mod(mstj(3),5).EQ.2) pws=pws+sqrt(p(i,5)**2+(psi(1)*p(i,1)+
67760  & psi(2)*p(i,2)+psi(3)*p(i,3))**2/psi(4))
67761  IF(mod(mstj(3),5).EQ.3) pws=pws+1d0
67762  350 CONTINUE
67763  DO 370 i=nsav+njet+1,n
67764  IF(mod(mstj(3),5).EQ.1) pw=p(i,4)
67765  IF(mod(mstj(3),5).EQ.2) pw=sqrt(p(i,5)**2+(psi(1)*p(i,1)+
67766  & psi(2)*p(i,2)+psi(3)*p(i,3))**2/psi(4))
67767  IF(mod(mstj(3),5).EQ.3) pw=1d0
67768  DO 360 j=1,3
67769  p(i,j)=p(i,j)-psi(j)*pw/pws
67770  360 CONTINUE
67771  p(i,4)=sqrt(p(i,1)**2+p(i,2)**2+p(i,3)**2+p(i,5)**2)
67772  370 CONTINUE
67773 
67774 C...Compensate for missing momentum withing each jet separately.
67775  ELSEIF(mod(mstj(3),5).EQ.4) THEN
67776  DO 390 i=n+1,n+njet
67777  k(i,1)=0
67778  DO 380 j=1,5
67779  p(i,j)=0d0
67780  380 CONTINUE
67781  390 CONTINUE
67782  DO 410 i=nsav+njet+1,n
67783  ir1=k(i,3)
67784  ir2=n+ir1-nsav
67785  k(ir2,1)=k(ir2,1)+1
67786  pls=(p(i,1)*p(ir1,1)+p(i,2)*p(ir1,2)+p(i,3)*p(ir1,3))/
67787  & (p(ir1,1)**2+p(ir1,2)**2+p(ir1,3)**2)
67788  DO 400 j=1,3
67789  p(ir2,j)=p(ir2,j)+p(i,j)-pls*p(ir1,j)
67790  400 CONTINUE
67791  p(ir2,4)=p(ir2,4)+p(i,4)
67792  p(ir2,5)=p(ir2,5)+pls
67793  410 CONTINUE
67794  pss=0d0
67795  DO 420 i=n+1,n+njet
67796  IF(k(i,1).NE.0) pss=pss+p(i,4)/(pecm*(0.8d0*p(i,5)+0.2d0))
67797  420 CONTINUE
67798  DO 440 i=nsav+njet+1,n
67799  ir1=k(i,3)
67800  ir2=n+ir1-nsav
67801  pls=(p(i,1)*p(ir1,1)+p(i,2)*p(ir1,2)+p(i,3)*p(ir1,3))/
67802  & (p(ir1,1)**2+p(ir1,2)**2+p(ir1,3)**2)
67803  DO 430 j=1,3
67804  p(i,j)=p(i,j)-p(ir2,j)/k(ir2,1)+(1d0/(p(ir2,5)*pss)-1d0)*
67805  & pls*p(ir1,j)
67806  430 CONTINUE
67807  p(i,4)=sqrt(p(i,1)**2+p(i,2)**2+p(i,3)**2+p(i,5)**2)
67808  440 CONTINUE
67809  ENDIF
67810 
67811 C...Scale momenta for energy conservation.
67812  IF(mod(mstj(3),5).NE.0) THEN
67813  pms=0d0
67814  pes=0d0
67815  pqs=0d0
67816  DO 450 i=nsav+njet+1,n
67817  pms=pms+p(i,5)
67818  pes=pes+p(i,4)
67819  pqs=pqs+p(i,5)**2/p(i,4)
67820  450 CONTINUE
67821  IF(pms.GE.pecm) goto 150
67822  neco=0
67823  460 neco=neco+1
67824  pfac=(pecm-pqs)/(pes-pqs)
67825  pes=0d0
67826  pqs=0d0
67827  DO 480 i=nsav+njet+1,n
67828  DO 470 j=1,3
67829  p(i,j)=pfac*p(i,j)
67830  470 CONTINUE
67831  p(i,4)=sqrt(p(i,1)**2+p(i,2)**2+p(i,3)**2+p(i,5)**2)
67832  pes=pes+p(i,4)
67833  pqs=pqs+p(i,5)**2/p(i,4)
67834  480 CONTINUE
67835  IF(neco.LT.10.AND.abs(pecm-pes).GT.2d-6*pecm) goto 460
67836  ENDIF
67837 
67838 C...Origin of produced particles and parton daughter pointers.
67839  490 DO 500 i=nsav+njet+1,n
67840  IF(mstu(16).NE.2) k(i,3)=nsav+1
67841  IF(mstu(16).EQ.2) k(i,3)=k(k(i,3),3)
67842  500 CONTINUE
67843  DO 510 i=nsav+1,nsav+njet
67844  i1=k(i,3)
67845  k(i1,1)=k(i1,1)+10
67846  IF(mstu(16).NE.2) THEN
67847  k(i1,4)=nsav+1
67848  k(i1,5)=nsav+1
67849  ELSE
67850  k(i1,4)=k(i1,4)-njet+1
67851  k(i1,5)=k(i1,5)-njet+1
67852  IF(k(i1,5).LT.k(i1,4)) THEN
67853  k(i1,4)=0
67854  k(i1,5)=0
67855  ENDIF
67856  ENDIF
67857  510 CONTINUE
67858 
67859 C...Document independent fragmentation system. Remove copy of jets.
67860  nsav=nsav+1
67861  k(nsav,1)=11
67862  k(nsav,2)=93
67863  k(nsav,3)=ip
67864  k(nsav,4)=nsav+1
67865  k(nsav,5)=n-njet+1
67866  DO 520 j=1,4
67867  p(nsav,j)=dps(j)
67868  v(nsav,j)=v(ip,j)
67869  520 CONTINUE
67870  p(nsav,5)=sqrt(max(0d0,dps(4)**2-dps(1)**2-dps(2)**2-dps(3)**2))
67871  v(nsav,5)=0d0
67872  DO 540 i=nsav+njet,n
67873  DO 530 j=1,5
67874  k(i-njet+1,j)=k(i,j)
67875  p(i-njet+1,j)=p(i,j)
67876  v(i-njet+1,j)=v(i,j)
67877  530 CONTINUE
67878  540 CONTINUE
67879  n=n-njet+1
67880  DO 550 iz=mstu90+1,mstu(90)
67881  mstu(90+iz)=mstu(90+iz)-njet+1
67882  550 CONTINUE
67883 
67884 C...Boost back particle system. Set production vertices.
67885  IF(njet.NE.1) CALL pyrobo(nsav+1,n,0d0,0d0,dps(1)/dps(4),
67886  &dps(2)/dps(4),dps(3)/dps(4))
67887  DO 570 i=nsav+1,n
67888  DO 560 j=1,4
67889  v(i,j)=v(ip,j)
67890  560 CONTINUE
67891  570 CONTINUE
67892 
67893  RETURN
67894  END
67895 
67896 C*********************************************************************
67897 
67898 C...PYDECY
67899 C...Handles the decay of unstable particles.
67900 
67901  SUBROUTINE pydecy(IP)
67902 
67903 C...Double precision and integer declarations.
67904  IMPLICIT DOUBLE PRECISION(a-h, o-z)
67905  IMPLICIT INTEGER(i-n)
67906  INTEGER pyk,pychge,pycomp
67907 C...Commonblocks.
67908  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
67909  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
67910  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
67911  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
67912  SAVE /pyjets/,/pydat1/,/pydat2/,/pydat3/
67913 C...Local arrays.
67914  dimension vdcy(4),kflo(4),kfl1(4),pv(10,5),rord(10),ue(3),be(3),
67915  &wtcor(10),ptau(4),pcmtau(4),dbetau(3)
67916  CHARACTER cidc*4
67917  DATA wtcor/2d0,5d0,15d0,60d0,250d0,1500d0,1.2d4,1.2d5,150d0,16d0/
67918 
67919 C...Functions: momentum in two-particle decays and four-product.
67920  pawt(a,b,c)=sqrt((a**2-(b+c)**2)*(a**2-(b-c)**2))/(2d0*a)
67921  four(i,j)=p(i,4)*p(j,4)-p(i,1)*p(j,1)-p(i,2)*p(j,2)-p(i,3)*p(j,3)
67922 
67923 C...Initial values.
67924  ntry=0
67925  nsav=n
67926  kfa=iabs(k(ip,2))
67927  kfs=isign(1,k(ip,2))
67928  kc=pycomp(kfa)
67929  mstj(92)=0
67930 
67931 C...Choose lifetime and determine decay vertex.
67932  IF(k(ip,1).EQ.5) THEN
67933  v(ip,5)=0d0
67934  ELSEIF(k(ip,1).NE.4) THEN
67935  v(ip,5)=-pmas(kc,4)*log(pyr(0))
67936  ENDIF
67937  DO 100 j=1,4
67938  vdcy(j)=v(ip,j)+v(ip,5)*p(ip,j)/p(ip,5)
67939  100 CONTINUE
67940 
67941 C...Determine whether decay allowed or not.
67942  mout=0
67943  IF(mstj(22).EQ.2) THEN
67944  IF(pmas(kc,4).GT.parj(71)) mout=1
67945  ELSEIF(mstj(22).EQ.3) THEN
67946  IF(vdcy(1)**2+vdcy(2)**2+vdcy(3)**2.GT.parj(72)**2) mout=1
67947  ELSEIF(mstj(22).EQ.4) THEN
67948  IF(vdcy(1)**2+vdcy(2)**2.GT.parj(73)**2) mout=1
67949  IF(abs(vdcy(3)).GT.parj(74)) mout=1
67950  ENDIF
67951  IF(mout.EQ.1.AND.k(ip,1).NE.5) THEN
67952  k(ip,1)=4
67953  RETURN
67954  ENDIF
67955 
67956 C...Interface to external tau decay library (for tau polarization).
67957  IF(kfa.EQ.15.AND.mstj(28).GE.1) THEN
67958 
67959 C...Starting values for pointers and momenta.
67960  itau=ip
67961  DO 110 j=1,4
67962  ptau(j)=p(itau,j)
67963  pcmtau(j)=p(itau,j)
67964  110 CONTINUE
67965 
67966 C...Iterate to find position and code of mother of tau.
67967  imtau=itau
67968  120 imtau=k(imtau,3)
67969 
67970  IF(imtau.EQ.0) THEN
67971 C...If no known origin then impossible to do anything further.
67972  kforig=0
67973  iorig=0
67974 
67975  ELSEIF(k(imtau,2).EQ.k(itau,2)) THEN
67976 C...If tau -> tau + gamma then add gamma energy and loop.
67977  IF(k(k(imtau,4),2).EQ.22) THEN
67978  DO 130 j=1,4
67979  pcmtau(j)=pcmtau(j)+p(k(imtau,4),j)
67980  130 CONTINUE
67981  ELSEIF(k(k(imtau,5),2).EQ.22) THEN
67982  DO 140 j=1,4
67983  pcmtau(j)=pcmtau(j)+p(k(imtau,5),j)
67984  140 CONTINUE
67985  ENDIF
67986  goto 120
67987 
67988  ELSEIF(iabs(k(imtau,2)).GT.100) THEN
67989 C...If coming from weak decay of hadron then W is not stored in record,
67990 C...but can be reconstructed by adding neutrino momentum.
67991  kforig=-isign(24,k(itau,2))
67992  iorig=0
67993  DO 160 ii=k(imtau,4),k(imtau,5)
67994  IF(k(ii,2)*isign(1,k(itau,2)).EQ.-16) THEN
67995  DO 150 j=1,4
67996  pcmtau(j)=pcmtau(j)+p(ii,j)
67997  150 CONTINUE
67998  ENDIF
67999  160 CONTINUE
68000 
68001  ELSE
68002 C...If coming from resonance decay then find latest copy of this
68003 C...resonance (may not completely agree).
68004  kforig=k(imtau,2)
68005  iorig=imtau
68006  DO 170 ii=imtau+1,ip-1
68007  IF(k(ii,2).EQ.kforig.AND.k(ii,3).EQ.iorig.AND.
68008  & abs(p(ii,5)-p(iorig,5)).LT.1d-5*p(iorig,5)) iorig=ii
68009  170 CONTINUE
68010  DO 180 j=1,4
68011  pcmtau(j)=p(iorig,j)
68012  180 CONTINUE
68013  ENDIF
68014 
68015 C...Boost tau to rest frame of production process (where known)
68016 C...and rotate it to sit along +z axis.
68017  DO 190 j=1,3
68018  dbetau(j)=pcmtau(j)/pcmtau(4)
68019  190 CONTINUE
68020  IF(kforig.NE.0) CALL pyrobo(itau,itau,0d0,0d0,-dbetau(1),
68021  & -dbetau(2),-dbetau(3))
68022  phitau=pyangl(p(itau,1),p(itau,2))
68023  CALL pyrobo(itau,itau,0d0,-phitau,0d0,0d0,0d0)
68024  thetau=pyangl(p(itau,3),p(itau,1))
68025  CALL pyrobo(itau,itau,-thetau,0d0,0d0,0d0,0d0)
68026 
68027 C...Call tau decay routine (if meaningful) and fill extra info.
68028  IF(kforig.NE.0.OR.mstj(28).EQ.2) THEN
68029  CALL pytaud(itau,iorig,kforig,ndecay)
68030  DO 200 ii=nsav+1,nsav+ndecay
68031  k(ii,1)=1
68032  k(ii,3)=ip
68033  k(ii,4)=0
68034  k(ii,5)=0
68035  200 CONTINUE
68036  n=nsav+ndecay
68037  ENDIF
68038 
68039 C...Boost back decay tau and decay products.
68040  DO 210 j=1,4
68041  p(itau,j)=ptau(j)
68042  210 CONTINUE
68043  IF(kforig.NE.0.OR.mstj(28).EQ.2) THEN
68044  CALL pyrobo(nsav+1,n,thetau,phitau,0d0,0d0,0d0)
68045  IF(kforig.NE.0) CALL pyrobo(nsav+1,n,0d0,0d0,dbetau(1),
68046  & dbetau(2),dbetau(3))
68047 
68048 C...Skip past ordinary tau decay treatment.
68049  mmat=0
68050  mbst=0
68051  nd=0
68052  goto 630
68053  ENDIF
68054  ENDIF
68055 
68056 C...B-Bbar mixing: flip sign of meson appropriately.
68057  mmix=0
68058  IF((kfa.EQ.511.OR.kfa.EQ.531).AND.mstj(26).GE.1) THEN
68059  xbbmix=parj(76)
68060  IF(kfa.EQ.531) xbbmix=parj(77)
68061  IF(sin(0.5d0*xbbmix*v(ip,5)/pmas(kc,4))**2.GT.pyr(0)) mmix=1
68062  IF(mmix.EQ.1) kfs=-kfs
68063  ENDIF
68064 
68065 C...Check existence of decay channels. Particle/antiparticle rules.
68066  kca=kc
68067  IF(mdcy(kc,2).GT.0) THEN
68068  mdmdcy=mdme(mdcy(kc,2),2)
68069  IF(mdmdcy.GT.80.AND.mdmdcy.LE.90) kca=mdmdcy
68070  ENDIF
68071  IF(mdcy(kca,2).LE.0.OR.mdcy(kca,3).LE.0) THEN
68072  CALL pyerrm(9,'(PYDECY:) no decay channel defined')
68073  RETURN
68074  ENDIF
68075  IF(mod(kfa/1000,10).EQ.0.AND.kca.EQ.85) kfs=-kfs
68076  IF(kchg(kc,3).EQ.0) THEN
68077  kfsp=1
68078  kfsn=0
68079  IF(pyr(0).GT.0.5d0) kfs=-kfs
68080  ELSEIF(kfs.GT.0) THEN
68081  kfsp=1
68082  kfsn=0
68083  ELSE
68084  kfsp=0
68085  kfsn=1
68086  ENDIF
68087 
68088 C...Sum branching ratios of allowed decay channels.
68089  220 nope=0
68090  brsu=0d0
68091  DO 230 idl=mdcy(kca,2),mdcy(kca,2)+mdcy(kca,3)-1
68092  IF(mdme(idl,1).NE.1.AND.kfsp*mdme(idl,1).NE.2.AND.
68093  & kfsn*mdme(idl,1).NE.3) goto 230
68094  IF(mdme(idl,2).GT.100) goto 230
68095  nope=nope+1
68096  brsu=brsu+brat(idl)
68097  230 CONTINUE
68098  IF(nope.EQ.0) THEN
68099  CALL pyerrm(2,'(PYDECY:) all decay channels closed by user')
68100  RETURN
68101  ENDIF
68102 
68103 C...Select decay channel among allowed ones.
68104  240 rbr=brsu*pyr(0)
68105  idl=mdcy(kca,2)-1
68106  250 idl=idl+1
68107  IF(mdme(idl,1).NE.1.AND.kfsp*mdme(idl,1).NE.2.AND.
68108  &kfsn*mdme(idl,1).NE.3) THEN
68109  IF(idl.LT.mdcy(kca,2)+mdcy(kca,3)-1) goto 250
68110  ELSEIF(mdme(idl,2).GT.100) THEN
68111  IF(idl.LT.mdcy(kca,2)+mdcy(kca,3)-1) goto 250
68112  ELSE
68113  idc=idl
68114  rbr=rbr-brat(idl)
68115  IF(idl.LT.mdcy(kca,2)+mdcy(kca,3)-1.AND.rbr.GT.0d0) goto 250
68116  ENDIF
68117 
68118 C...Start readout of decay channel: matrix element, reset counters.
68119  mmat=mdme(idc,2)
68120  260 ntry=ntry+1
68121  IF(mod(ntry,200).EQ.0) THEN
68122  WRITE(cidc,'(I4)') idc
68123 C...Do not print warning for some well-known special cases.
68124  IF(kfa.NE.113.AND.kfa.NE.115.AND.kfa.NE.215)
68125  & CALL pyerrm(4,'(PYDECY:) caught in loop for decay channel'//
68126  & cidc)
68127  goto 240
68128  ENDIF
68129  IF(ntry.GT.1000) THEN
68130  CALL pyerrm(14,'(PYDECY:) caught in infinite loop')
68131  IF(mstu(21).GE.1) RETURN
68132  ENDIF
68133  i=n
68134  np=0
68135  nq=0
68136  mbst=0
68137  IF(mmat.GE.11.AND.p(ip,4).GT.20d0*p(ip,5)) mbst=1
68138  DO 270 j=1,4
68139  pv(1,j)=0d0
68140  IF(mbst.EQ.0) pv(1,j)=p(ip,j)
68141  270 CONTINUE
68142  IF(mbst.EQ.1) pv(1,4)=p(ip,5)
68143  pv(1,5)=p(ip,5)
68144  ps=0d0
68145  psq=0d0
68146  mrem=0
68147  mhaddy=0
68148  IF(kfa.GT.80) mhaddy=1
68149 C.. Random flavour and popcorn system memory.
68150  irndmo=0
68151  jtmo=0
68152  mstu(121)=0
68153  mstu(125)=10
68154 
68155 C...Read out decay products. Convert to standard flavour code.
68156  jtmax=5
68157  IF(mdme(idc+1,2).EQ.101) jtmax=10
68158  DO 280 jt=1,jtmax
68159  IF(jt.LE.5) kp=kfdp(idc,jt)
68160  IF(jt.GE.6) kp=kfdp(idc+1,jt-5)
68161  IF(kp.EQ.0) goto 280
68162  kpa=iabs(kp)
68163  kcp=pycomp(kpa)
68164  IF(kpa.GT.80) mhaddy=1
68165  IF(kchg(kcp,3).EQ.0.AND.kpa.NE.81.AND.kpa.NE.82) THEN
68166  kfp=kp
68167  ELSEIF(kpa.NE.81.AND.kpa.NE.82) THEN
68168  kfp=kfs*kp
68169  ELSEIF(kpa.EQ.81.AND.mod(kfa/1000,10).EQ.0) THEN
68170  kfp=-kfs*mod(kfa/10,10)
68171  ELSEIF(kpa.EQ.81.AND.mod(kfa/100,10).GE.mod(kfa/10,10)) THEN
68172  kfp=kfs*(100*mod(kfa/10,100)+3)
68173  ELSEIF(kpa.EQ.81) THEN
68174  kfp=kfs*(1000*mod(kfa/10,10)+100*mod(kfa/100,10)+1)
68175  ELSEIF(kp.EQ.82) THEN
68176  CALL pydcyk(-kfs*int(1d0+(2d0+parj(2))*pyr(0)),0,kfp,kdump)
68177  IF(kfp.EQ.0) goto 260
68178  kfp=-kfp
68179  irndmo=1
68180  mstj(93)=1
68181  IF(pv(1,5).LT.parj(32)+2d0*pymass(kfp)) goto 260
68182  ELSEIF(kp.EQ.-82) THEN
68183  kfp=mstu(124)
68184  ENDIF
68185  IF(kpa.EQ.81.OR.kpa.EQ.82) kcp=pycomp(kfp)
68186 
68187 C...Add decay product to event record or to quark flavour list.
68188  kfpa=iabs(kfp)
68189  kqp=kchg(kcp,2)
68190  IF(mmat.GE.11.AND.mmat.LE.30.AND.kqp.NE.0) THEN
68191  nq=nq+1
68192  kflo(nq)=kfp
68193 C...set rndmflav popcorn system pointer
68194  IF(kp.EQ.82.AND.mstu(121).GT.0) jtmo=nq
68195  mstj(93)=2
68196  psq=psq+pymass(kflo(nq))
68197  ELSEIF((mmat.EQ.42.OR.mmat.EQ.43.OR.mmat.EQ.48).AND.np.EQ.3.AND.
68198  & mod(nq,2).EQ.1) THEN
68199  nq=nq-1
68200  ps=ps-p(i,5)
68201  k(i,1)=1
68202  kfi=k(i,2)
68203  CALL pykfdi(kfp,kfi,kfldmp,k(i,2))
68204  IF(k(i,2).EQ.0) goto 260
68205  mstj(93)=1
68206  p(i,5)=pymass(k(i,2))
68207  ps=ps+p(i,5)
68208  ELSE
68209  i=i+1
68210  np=np+1
68211  IF(mmat.NE.33.AND.kqp.NE.0) nq=nq+1
68212  IF(mmat.EQ.33.AND.kqp.NE.0.AND.kqp.NE.2) nq=nq+1
68213  k(i,1)=1+mod(nq,2)
68214  IF(mmat.EQ.4.AND.jt.LE.2.AND.kfp.EQ.21) k(i,1)=2
68215  IF(mmat.EQ.4.AND.jt.EQ.3) k(i,1)=1
68216  k(i,2)=kfp
68217  k(i,3)=ip
68218  k(i,4)=0
68219  k(i,5)=0
68220  p(i,5)=pymass(kfp)
68221  ps=ps+p(i,5)
68222  ENDIF
68223  280 CONTINUE
68224 
68225 C...Check masses for resonance decays.
68226  IF(mhaddy.EQ.0) THEN
68227  IF(ps+parj(64).GT.pv(1,5)) goto 240
68228  ENDIF
68229 
68230 C...Choose decay multiplicity in phase space model.
68231  290 IF(mmat.GE.11.AND.mmat.LE.30) THEN
68232  psp=ps
68233  cnde=parj(61)*log(max((pv(1,5)-ps-psq)/parj(62),1.1d0))
68234  IF(mmat.EQ.12) cnde=cnde+parj(63)
68235  300 ntry=ntry+1
68236 C...Reset popcorn flags if new attempt. Re-select rndmflav if failed.
68237  IF(irndmo.EQ.0) THEN
68238  mstu(121)=0
68239  jtmo=0
68240  ELSEIF(irndmo.EQ.1) THEN
68241  irndmo=2
68242  ELSE
68243  goto 260
68244  ENDIF
68245  IF(ntry.GT.1000) THEN
68246  CALL pyerrm(14,'(PYDECY:) caught in infinite loop')
68247  IF(mstu(21).GE.1) RETURN
68248  ENDIF
68249  IF(mmat.LE.20) THEN
68250  gauss=sqrt(-2d0*cnde*log(max(1d-10,pyr(0))))*
68251  & sin(paru(2)*pyr(0))
68252  nd=0.5d0+0.5d0*np+0.25d0*nq+cnde+gauss
68253  IF(nd.LT.np+nq/2.OR.nd.LT.2.OR.nd.GT.10) goto 300
68254  IF(mmat.EQ.13.AND.nd.EQ.2) goto 300
68255  IF(mmat.EQ.14.AND.nd.LE.3) goto 300
68256  IF(mmat.EQ.15.AND.nd.LE.4) goto 300
68257  ELSE
68258  nd=mmat-20
68259  ENDIF
68260 C.. Set maximum popcorn meson number. Test rndmflav popcorn size.
68261  mstu(125)=nd-nq/2
68262  IF(mstu(121).GT.mstu(125)) goto 300
68263 
68264 C...Form hadrons from flavour content.
68265  DO 310 jt=1,nq
68266  kfl1(jt)=kflo(jt)
68267  310 CONTINUE
68268  IF(nd.EQ.np+nq/2) goto 330
68269  DO 320 i=n+np+1,n+nd-nq/2
68270 C.. Stick to started popcorn system, else pick side at random
68271  jt=jtmo
68272  IF(jt.EQ.0) jt=1+int((nq-1)*pyr(0))
68273  CALL pydcyk(kfl1(jt),0,kfl2,k(i,2))
68274  IF(k(i,2).EQ.0) goto 300
68275  mstu(125)=mstu(125)-1
68276  jtmo=0
68277  IF(mstu(121).GT.0) jtmo=jt
68278  kfl1(jt)=-kfl2
68279  320 CONTINUE
68280  330 jt=2
68281  jt2=3
68282  jt3=4
68283  IF(nq.EQ.4.AND.pyr(0).LT.parj(66)) jt=4
68284  IF(jt.EQ.4.AND.isign(1,kfl1(1)*(10-iabs(kfl1(1))))*
68285  & isign(1,kfl1(jt)*(10-iabs(kfl1(jt)))).GT.0) jt=3
68286  IF(jt.EQ.3) jt2=2
68287  IF(jt.EQ.4) jt3=2
68288  CALL pydcyk(kfl1(1),kfl1(jt),kfldmp,k(n+nd-nq/2+1,2))
68289  IF(k(n+nd-nq/2+1,2).EQ.0) goto 300
68290  IF(nq.EQ.4) CALL pydcyk(kfl1(jt2),kfl1(jt3),kfldmp,k(n+nd,2))
68291  IF(nq.EQ.4.AND.k(n+nd,2).EQ.0) goto 300
68292 
68293 C...Check that sum of decay product masses not too large.
68294  ps=psp
68295  DO 340 i=n+np+1,n+nd
68296  k(i,1)=1
68297  k(i,3)=ip
68298  k(i,4)=0
68299  k(i,5)=0
68300  p(i,5)=pymass(k(i,2))
68301  ps=ps+p(i,5)
68302  340 CONTINUE
68303  IF(ps+parj(64).GT.pv(1,5)) goto 300
68304 
68305 C...Rescale energy to subtract off spectator quark mass.
68306  ELSEIF((mmat.EQ.31.OR.mmat.EQ.33.OR.mmat.EQ.44)
68307  & .AND.np.GE.3) THEN
68308  ps=ps-p(n+np,5)
68309  pqt=(p(n+np,5)+parj(65))/pv(1,5)
68310  DO 350 j=1,5
68311  p(n+np,j)=pqt*pv(1,j)
68312  pv(1,j)=(1d0-pqt)*pv(1,j)
68313  350 CONTINUE
68314  IF(ps+parj(64).GT.pv(1,5)) goto 260
68315  nd=np-1
68316  mrem=1
68317 
68318 C...Fully specified final state: check mass broadening effects.
68319  ELSE
68320  IF(np.GE.2.AND.ps+parj(64).GT.pv(1,5)) goto 260
68321  nd=np
68322  ENDIF
68323 
68324 C...Determine position of grandmother, number of sisters.
68325  nm=0
68326  kfas=0
68327  msgn=0
68328  IF(mmat.EQ.3) THEN
68329  im=k(ip,3)
68330  IF(im.LT.0.OR.im.GE.ip) im=0
68331  IF(im.NE.0) kfam=iabs(k(im,2))
68332  IF(im.NE.0) THEN
68333  DO 360 il=max(ip-2,im+1),min(ip+2,n)
68334  IF(k(il,3).EQ.im) nm=nm+1
68335  IF(k(il,3).EQ.im.AND.il.NE.ip) isis=il
68336  360 CONTINUE
68337  IF(nm.NE.2.OR.kfam.LE.100.OR.mod(kfam,10).NE.1.OR.
68338  & mod(kfam/1000,10).NE.0) nm=0
68339  IF(nm.EQ.2) THEN
68340  kfas=iabs(k(isis,2))
68341  IF((kfas.LE.100.OR.mod(kfas,10).NE.1.OR.
68342  & mod(kfas/1000,10).NE.0).AND.kfas.NE.22) nm=0
68343  ENDIF
68344  ENDIF
68345  ENDIF
68346 
68347 C...Kinematics of one-particle decays.
68348  IF(nd.EQ.1) THEN
68349  DO 370 j=1,4
68350  p(n+1,j)=p(ip,j)
68351  370 CONTINUE
68352  goto 630
68353  ENDIF
68354 
68355 C...Calculate maximum weight ND-particle decay.
68356  pv(nd,5)=p(n+nd,5)
68357  IF(nd.GE.3) THEN
68358  wtmax=1d0/wtcor(nd-2)
68359  pmax=pv(1,5)-ps+p(n+nd,5)
68360  pmin=0d0
68361  DO 380 il=nd-1,1,-1
68362  pmax=pmax+p(n+il,5)
68363  pmin=pmin+p(n+il+1,5)
68364  wtmax=wtmax*pawt(pmax,pmin,p(n+il,5))
68365  380 CONTINUE
68366  ENDIF
68367 
68368 C...Find virtual gamma mass in Dalitz decay.
68369  390 IF(nd.EQ.2) THEN
68370  ELSEIF(mmat.EQ.2) THEN
68371  pmes=4d0*pmas(11,1)**2
68372  pmrho2=pmas(131,1)**2
68373  pgrho2=pmas(131,2)**2
68374  400 pmst=pmes*(p(ip,5)**2/pmes)**pyr(0)
68375  wt=(1+0.5d0*pmes/pmst)*sqrt(max(0d0,1d0-pmes/pmst))*
68376  & (1d0-pmst/p(ip,5)**2)**3*(1d0+pgrho2/pmrho2)/
68377  & ((1d0-pmst/pmrho2)**2+pgrho2/pmrho2)
68378  IF(wt.LT.pyr(0)) goto 400
68379  pv(2,5)=max(2.00001d0*pmas(11,1),sqrt(pmst))
68380 
68381 C...M-generator gives weight. If rejected, try again.
68382  ELSE
68383  410 rord(1)=1d0
68384  DO 440 il1=2,nd-1
68385  rsav=pyr(0)
68386  DO 420 il2=il1-1,1,-1
68387  IF(rsav.LE.rord(il2)) goto 430
68388  rord(il2+1)=rord(il2)
68389  420 CONTINUE
68390  430 rord(il2+1)=rsav
68391  440 CONTINUE
68392  rord(nd)=0d0
68393  wt=1d0
68394  DO 450 il=nd-1,1,-1
68395  pv(il,5)=pv(il+1,5)+p(n+il,5)+(rord(il)-rord(il+1))*
68396  & (pv(1,5)-ps)
68397  wt=wt*pawt(pv(il,5),pv(il+1,5),p(n+il,5))
68398  450 CONTINUE
68399  IF(wt.LT.pyr(0)*wtmax) goto 410
68400  ENDIF
68401 
68402 C...Perform two-particle decays in respective CM frame.
68403  460 DO 480 il=1,nd-1
68404  pa=pawt(pv(il,5),pv(il+1,5),p(n+il,5))
68405  ue(3)=2d0*pyr(0)-1d0
68406  phi=paru(2)*pyr(0)
68407  ue(1)=sqrt(1d0-ue(3)**2)*cos(phi)
68408  ue(2)=sqrt(1d0-ue(3)**2)*sin(phi)
68409  DO 470 j=1,3
68410  p(n+il,j)=pa*ue(j)
68411  pv(il+1,j)=-pa*ue(j)
68412  470 CONTINUE
68413  p(n+il,4)=sqrt(pa**2+p(n+il,5)**2)
68414  pv(il+1,4)=sqrt(pa**2+pv(il+1,5)**2)
68415  480 CONTINUE
68416 
68417 C...Lorentz transform decay products to lab frame.
68418  DO 490 j=1,4
68419  p(n+nd,j)=pv(nd,j)
68420  490 CONTINUE
68421  DO 530 il=nd-1,1,-1
68422  DO 500 j=1,3
68423  be(j)=pv(il,j)/pv(il,4)
68424  500 CONTINUE
68425  ga=pv(il,4)/pv(il,5)
68426  DO 520 i=n+il,n+nd
68427  bep=be(1)*p(i,1)+be(2)*p(i,2)+be(3)*p(i,3)
68428  DO 510 j=1,3
68429  p(i,j)=p(i,j)+ga*(ga*bep/(1d0+ga)+p(i,4))*be(j)
68430  510 CONTINUE
68431  p(i,4)=ga*(p(i,4)+bep)
68432  520 CONTINUE
68433  530 CONTINUE
68434 
68435 C...Check that no infinite loop in matrix element weight.
68436  ntry=ntry+1
68437  IF(ntry.GT.800) goto 560
68438 
68439 C...Matrix elements for omega and phi decays.
68440  IF(mmat.EQ.1) THEN
68441  wt=(p(n+1,5)*p(n+2,5)*p(n+3,5))**2-(p(n+1,5)*four(n+2,n+3))**2
68442  & -(p(n+2,5)*four(n+1,n+3))**2-(p(n+3,5)*four(n+1,n+2))**2
68443  & +2d0*four(n+1,n+2)*four(n+1,n+3)*four(n+2,n+3)
68444  IF(max(wt*wtcor(9)/p(ip,5)**6,0.001d0).LT.pyr(0)) goto 390
68445 
68446 C...Matrix elements for pi0 or eta Dalitz decay to gamma e+ e-.
68447  ELSEIF(mmat.EQ.2) THEN
68448  four12=four(n+1,n+2)
68449  four13=four(n+1,n+3)
68450  wt=(pmst-0.5d0*pmes)*(four12**2+four13**2)+
68451  & pmes*(four12*four13+four12**2+four13**2)
68452  IF(wt.LT.pyr(0)*0.25d0*pmst*(p(ip,5)**2-pmst)**2) goto 460
68453 
68454 C...Matrix element for S0 -> S1 + V1 -> S1 + S2 + S3 (S scalar,
68455 C...V vector), of form cos**2(theta02) in V1 rest frame, and for
68456 C...S0 -> gamma + V1 -> gamma + S2 + S3, of form sin**2(theta02).
68457  ELSEIF(mmat.EQ.3.AND.nm.EQ.2) THEN
68458  four10=four(ip,im)
68459  four12=four(ip,n+1)
68460  four02=four(im,n+1)
68461  pms1=p(ip,5)**2
68462  pms0=p(im,5)**2
68463  pms2=p(n+1,5)**2
68464  IF(kfas.NE.22) hnum=(four10*four12-pms1*four02)**2
68465  IF(kfas.EQ.22) hnum=pms1*(2d0*four10*four12*four02-
68466  & pms1*four02**2-pms0*four12**2-pms2*four10**2+pms1*pms0*pms2)
68467  hnum=max(1d-6*pms1**2*pms0*pms2,hnum)
68468  hden=(four10**2-pms1*pms0)*(four12**2-pms1*pms2)
68469  IF(hnum.LT.pyr(0)*hden) goto 460
68470 
68471 C...Matrix element for "onium" -> g + g + g or gamma + g + g.
68472  ELSEIF(mmat.EQ.4) THEN
68473  hx1=2d0*four(ip,n+1)/p(ip,5)**2
68474  hx2=2d0*four(ip,n+2)/p(ip,5)**2
68475  hx3=2d0*four(ip,n+3)/p(ip,5)**2
68476  wt=((1d0-hx1)/(hx2*hx3))**2+((1d0-hx2)/(hx1*hx3))**2+
68477  & ((1d0-hx3)/(hx1*hx2))**2
68478  IF(wt.LT.2d0*pyr(0)) goto 390
68479  IF(k(ip+1,2).EQ.22.AND.(1d0-hx1)*p(ip,5)**2.LT.4d0*parj(32)**2)
68480  & goto 390
68481 
68482 C...Effective matrix element for nu spectrum in tau -> nu + hadrons.
68483  ELSEIF(mmat.EQ.41) THEN
68484  IF(mbst.EQ.0) hx1=2d0*four(ip,n+1)/p(ip,5)**2
68485  IF(mbst.EQ.1) hx1=2d0*p(n+1,4)/p(ip,5)
68486  hxm=min(0.75d0,2d0*(1d0-ps/p(ip,5)))
68487  IF(hx1*(3d0-2d0*hx1).LT.pyr(0)*hxm*(3d0-2d0*hxm)) goto 390
68488 
68489 C...Matrix elements for weak decays (only semileptonic for c and b)
68490  ELSEIF((mmat.EQ.42.OR.mmat.EQ.43.OR.mmat.EQ.44.OR.mmat.EQ.48)
68491  & .AND.nd.EQ.3) THEN
68492  IF(mbst.EQ.0) wt=four(ip,n+1)*four(n+2,n+3)
68493  IF(mbst.EQ.1) wt=p(ip,5)*p(n+1,4)*four(n+2,n+3)
68494  IF(wt.LT.pyr(0)*p(ip,5)*pv(1,5)**3/wtcor(10)) goto 390
68495  ELSEIF(mmat.EQ.42.OR.mmat.EQ.43.OR.mmat.EQ.44.OR.mmat.EQ.48) THEN
68496  DO 550 j=1,4
68497  p(n+np+1,j)=0d0
68498  DO 540 is=n+3,n+np
68499  p(n+np+1,j)=p(n+np+1,j)+p(is,j)
68500  540 CONTINUE
68501  550 CONTINUE
68502  IF(mbst.EQ.0) wt=four(ip,n+1)*four(n+2,n+np+1)
68503  IF(mbst.EQ.1) wt=p(ip,5)*p(n+1,4)*four(n+2,n+np+1)
68504  IF(wt.LT.pyr(0)*p(ip,5)*pv(1,5)**3/wtcor(10)) goto 390
68505  ENDIF
68506 
68507 C...Scale back energy and reattach spectator.
68508  560 IF(mrem.EQ.1) THEN
68509  DO 570 j=1,5
68510  pv(1,j)=pv(1,j)/(1d0-pqt)
68511  570 CONTINUE
68512  nd=nd+1
68513  mrem=0
68514  ENDIF
68515 
68516 C...Low invariant mass for system with spectator quark gives particle,
68517 C...not two jets. Readjust momenta accordingly.
68518  IF(mmat.EQ.31.AND.nd.EQ.3) THEN
68519  mstj(93)=1
68520  pm2=pymass(k(n+2,2))
68521  mstj(93)=1
68522  pm3=pymass(k(n+3,2))
68523  IF(p(n+2,5)**2+p(n+3,5)**2+2d0*four(n+2,n+3).GE.
68524  & (parj(32)+pm2+pm3)**2) goto 630
68525  k(n+2,1)=1
68526  kftemp=k(n+2,2)
68527  CALL pykfdi(kftemp,k(n+3,2),kfldmp,k(n+2,2))
68528  IF(k(n+2,2).EQ.0) goto 260
68529  p(n+2,5)=pymass(k(n+2,2))
68530  ps=p(n+1,5)+p(n+2,5)
68531  pv(2,5)=p(n+2,5)
68532  mmat=0
68533  nd=2
68534  goto 460
68535  ELSEIF(mmat.EQ.44) THEN
68536  mstj(93)=1
68537  pm3=pymass(k(n+3,2))
68538  mstj(93)=1
68539  pm4=pymass(k(n+4,2))
68540  IF(p(n+3,5)**2+p(n+4,5)**2+2d0*four(n+3,n+4).GE.
68541  & (parj(32)+pm3+pm4)**2) goto 600
68542  k(n+3,1)=1
68543  kftemp=k(n+3,2)
68544  CALL pykfdi(kftemp,k(n+4,2),kfldmp,k(n+3,2))
68545  IF(k(n+3,2).EQ.0) goto 260
68546  p(n+3,5)=pymass(k(n+3,2))
68547  DO 580 j=1,3
68548  p(n+3,j)=p(n+3,j)+p(n+4,j)
68549  580 CONTINUE
68550  p(n+3,4)=sqrt(p(n+3,1)**2+p(n+3,2)**2+p(n+3,3)**2+p(n+3,5)**2)
68551  ha=p(n+1,4)**2-p(n+2,4)**2
68552  hb=ha-(p(n+1,5)**2-p(n+2,5)**2)
68553  hc=(p(n+1,1)-p(n+2,1))**2+(p(n+1,2)-p(n+2,2))**2+
68554  & (p(n+1,3)-p(n+2,3))**2
68555  hd=(pv(1,4)-p(n+3,4))**2
68556  he=ha**2-2d0*hd*(p(n+1,4)**2+p(n+2,4)**2)+hd**2
68557  hf=hd*hc-hb**2
68558  hg=hd*hc-ha*hb
68559  hh=(sqrt(hg**2+he*hf)-hg)/(2d0*hf)
68560  DO 590 j=1,3
68561  pcor=hh*(p(n+1,j)-p(n+2,j))
68562  p(n+1,j)=p(n+1,j)+pcor
68563  p(n+2,j)=p(n+2,j)-pcor
68564  590 CONTINUE
68565  p(n+1,4)=sqrt(p(n+1,1)**2+p(n+1,2)**2+p(n+1,3)**2+p(n+1,5)**2)
68566  p(n+2,4)=sqrt(p(n+2,1)**2+p(n+2,2)**2+p(n+2,3)**2+p(n+2,5)**2)
68567  nd=nd-1
68568  ENDIF
68569 
68570 C...Check invariant mass of W jets. May give one particle or start over.
68571  600 IF((mmat.EQ.42.OR.mmat.EQ.43.OR.mmat.EQ.44.OR.mmat.EQ.48)
68572  &.AND.iabs(k(n+1,2)).LT.10) THEN
68573  pmr=sqrt(max(0d0,p(n+1,5)**2+p(n+2,5)**2+2d0*four(n+1,n+2)))
68574  mstj(93)=1
68575  pm1=pymass(k(n+1,2))
68576  mstj(93)=1
68577  pm2=pymass(k(n+2,2))
68578  IF(pmr.GT.parj(32)+pm1+pm2) goto 610
68579  kfldum=int(1.5d0+pyr(0))
68580  CALL pykfdi(k(n+1,2),-isign(kfldum,k(n+1,2)),kfldmp,kf1)
68581  CALL pykfdi(k(n+2,2),-isign(kfldum,k(n+2,2)),kfldmp,kf2)
68582  IF(kf1.EQ.0.OR.kf2.EQ.0) goto 260
68583  psm=pymass(kf1)+pymass(kf2)
68584  IF((mmat.EQ.42.OR.mmat.EQ.48).AND.pmr.GT.parj(64)+psm) goto 610
68585  IF(mmat.GE.43.AND.pmr.GT.0.2d0*parj(32)+psm) goto 610
68586  IF(mmat.EQ.48) goto 390
68587  IF(nd.EQ.4.OR.kfa.EQ.15) goto 260
68588  k(n+1,1)=1
68589  kftemp=k(n+1,2)
68590  CALL pykfdi(kftemp,k(n+2,2),kfldmp,k(n+1,2))
68591  IF(k(n+1,2).EQ.0) goto 260
68592  p(n+1,5)=pymass(k(n+1,2))
68593  k(n+2,2)=k(n+3,2)
68594  p(n+2,5)=p(n+3,5)
68595  ps=p(n+1,5)+p(n+2,5)
68596  IF(ps+parj(64).GT.pv(1,5)) goto 260
68597  pv(2,5)=p(n+3,5)
68598  mmat=0
68599  nd=2
68600  goto 460
68601  ENDIF
68602 
68603 C...Phase space decay of partons from W decay.
68604  610 IF((mmat.EQ.42.OR.mmat.EQ.48).AND.iabs(k(n+1,2)).LT.10) THEN
68605  kflo(1)=k(n+1,2)
68606  kflo(2)=k(n+2,2)
68607  k(n+1,1)=k(n+3,1)
68608  k(n+1,2)=k(n+3,2)
68609  DO 620 j=1,5
68610  pv(1,j)=p(n+1,j)+p(n+2,j)
68611  p(n+1,j)=p(n+3,j)
68612  620 CONTINUE
68613  pv(1,5)=pmr
68614  n=n+1
68615  np=0
68616  nq=2
68617  ps=0d0
68618  mstj(93)=2
68619  psq=pymass(kflo(1))
68620  mstj(93)=2
68621  psq=psq+pymass(kflo(2))
68622  mmat=11
68623  goto 290
68624  ENDIF
68625 
68626 C...Boost back for rapidly moving particle.
68627  630 n=n+nd
68628  IF(mbst.EQ.1) THEN
68629  DO 640 j=1,3
68630  be(j)=p(ip,j)/p(ip,4)
68631  640 CONTINUE
68632  ga=p(ip,4)/p(ip,5)
68633  DO 660 i=nsav+1,n
68634  bep=be(1)*p(i,1)+be(2)*p(i,2)+be(3)*p(i,3)
68635  DO 650 j=1,3
68636  p(i,j)=p(i,j)+ga*(ga*bep/(1d0+ga)+p(i,4))*be(j)
68637  650 CONTINUE
68638  p(i,4)=ga*(p(i,4)+bep)
68639  660 CONTINUE
68640  ENDIF
68641 
68642 C...Fill in position of decay vertex.
68643  DO 680 i=nsav+1,n
68644  DO 670 j=1,4
68645  v(i,j)=vdcy(j)
68646  670 CONTINUE
68647  v(i,5)=0d0
68648  680 CONTINUE
68649 
68650 C...Set up for parton shower evolution from jets.
68651  IF(mstj(23).GE.1.AND.mmat.EQ.4.AND.k(nsav+1,2).EQ.21) THEN
68652  k(nsav+1,1)=3
68653  k(nsav+2,1)=3
68654  k(nsav+3,1)=3
68655  k(nsav+1,4)=mstu(5)*(nsav+2)
68656  k(nsav+1,5)=mstu(5)*(nsav+3)
68657  k(nsav+2,4)=mstu(5)*(nsav+3)
68658  k(nsav+2,5)=mstu(5)*(nsav+1)
68659  k(nsav+3,4)=mstu(5)*(nsav+1)
68660  k(nsav+3,5)=mstu(5)*(nsav+2)
68661  mstj(92)=-(nsav+1)
68662  ELSEIF(mstj(23).GE.1.AND.mmat.EQ.4) THEN
68663  k(nsav+2,1)=3
68664  k(nsav+3,1)=3
68665  k(nsav+2,4)=mstu(5)*(nsav+3)
68666  k(nsav+2,5)=mstu(5)*(nsav+3)
68667  k(nsav+3,4)=mstu(5)*(nsav+2)
68668  k(nsav+3,5)=mstu(5)*(nsav+2)
68669  mstj(92)=nsav+2
68670  ELSEIF(mstj(23).GE.1.AND.(mmat.EQ.32.OR.mmat.EQ.44).AND.
68671  & iabs(k(nsav+1,2)).LE.10.AND.iabs(k(nsav+2,2)).LE.10) THEN
68672  k(nsav+1,1)=3
68673  k(nsav+2,1)=3
68674  k(nsav+1,4)=mstu(5)*(nsav+2)
68675  k(nsav+1,5)=mstu(5)*(nsav+2)
68676  k(nsav+2,4)=mstu(5)*(nsav+1)
68677  k(nsav+2,5)=mstu(5)*(nsav+1)
68678  mstj(92)=nsav+1
68679  ELSEIF(mstj(23).GE.1.AND.(mmat.EQ.32.OR.mmat.EQ.44).AND.
68680  & iabs(k(nsav+1,2)).LE.20.AND.iabs(k(nsav+2,2)).LE.20) THEN
68681  mstj(92)=nsav+1
68682  ELSEIF(mstj(23).GE.1.AND.mmat.EQ.33.AND.iabs(k(nsav+2,2)).EQ.21)
68683  & THEN
68684  k(nsav+1,1)=3
68685  k(nsav+2,1)=3
68686  k(nsav+3,1)=3
68687  kcp=pycomp(k(nsav+1,2))
68688  kqp=kchg(kcp,2)*isign(1,k(nsav+1,2))
68689  jcon=4
68690  IF(kqp.LT.0) jcon=5
68691  k(nsav+1,jcon)=mstu(5)*(nsav+2)
68692  k(nsav+2,9-jcon)=mstu(5)*(nsav+1)
68693  k(nsav+2,jcon)=mstu(5)*(nsav+3)
68694  k(nsav+3,9-jcon)=mstu(5)*(nsav+2)
68695  mstj(92)=nsav+1
68696  ELSEIF(mstj(23).GE.1.AND.mmat.EQ.33) THEN
68697  k(nsav+1,1)=3
68698  k(nsav+3,1)=3
68699  k(nsav+1,4)=mstu(5)*(nsav+3)
68700  k(nsav+1,5)=mstu(5)*(nsav+3)
68701  k(nsav+3,4)=mstu(5)*(nsav+1)
68702  k(nsav+3,5)=mstu(5)*(nsav+1)
68703  mstj(92)=nsav+1
68704  ENDIF
68705 
68706 C...Mark decayed particle; special option for B-Bbar mixing.
68707  IF(k(ip,1).EQ.5) k(ip,1)=15
68708  IF(k(ip,1).LE.10) k(ip,1)=11
68709  IF(mmix.EQ.1.AND.mstj(26).EQ.2.AND.k(ip,1).EQ.11) k(ip,1)=12
68710  k(ip,4)=nsav+1
68711  k(ip,5)=n
68712 
68713  RETURN
68714  END
68715 
68716 
68717 C*********************************************************************
68718 
68719 C...PYDCYK
68720 C...Handles flavour production in the decay of unstable particles
68721 C...and small string clusters.
68722 
68723  SUBROUTINE pydcyk(KFL1,KFL2,KFL3,KF)
68724 
68725 C...Double precision and integer declarations.
68726  IMPLICIT DOUBLE PRECISION(a-h, o-z)
68727  IMPLICIT INTEGER(i-n)
68728  INTEGER pyk,pychge,pycomp
68729 C...Commonblocks.
68730  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
68731  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
68732  SAVE /pydat1/,/pydat2/
68733 
68734 
68735 C.. Call PYKFDI directly if no popcorn option is on
68736  IF(mstj(12).LT.2) THEN
68737  CALL pykfdi(kfl1,kfl2,kfl3,kf)
68738  mstu(124)=kfl3
68739  RETURN
68740  ENDIF
68741 
68742  kfl3=0
68743  kf=0
68744  IF(kfl1.EQ.0) RETURN
68745  kf1a=iabs(kfl1)
68746  kf2a=iabs(kfl2)
68747 
68748  nsto=130
68749  nmax=min(mstu(125),10)
68750 
68751 C.. Identify rank 0 cluster qq
68752  irank=1
68753  IF(kf1a.GT.10.AND.kf1a.LT.10000) irank=0
68754 
68755  IF(kf2a.GT.0)THEN
68756 C.. Join jets: Fails if store not empty
68757  IF(mstu(121).GT.0) THEN
68758  mstu(121)=0
68759  RETURN
68760  ENDIF
68761  CALL pykfdi(kfl1,kfl2,kfl3,kf)
68762  ELSEIF(kf1a.GT.10.AND.mstu(121).GT.0)THEN
68763 C.. Pick popcorn meson from store, return same qq, decrease store
68764  kf=mstu(nsto+mstu(121))
68765  kfl3=-kfl1
68766  mstu(121)=mstu(121)-1
68767  ELSE
68768 C.. Generate new flavour. Then done if no diquark is generated
68769  100 CALL pykfdi(kfl1,0,kfl3,kf)
68770  IF(mstu(121).EQ.-1) goto 100
68771  mstu(124)=kfl3
68772  IF(kf.EQ.0.OR.iabs(kfl3).LE.10) RETURN
68773 
68774 C.. Simple case if no dynamical popcorn suppressions are considered
68775  IF(mstj(12).LT.4) THEN
68776  IF(mstu(121).EQ.0) RETURN
68777  nmes=1
68778  kfprev=-kfl3
68779  CALL pykfdi(kfprev,0,kfl3,kfm)
68780 C.. Due to eta+eta' suppr., a qq->M+qq attempt might end as qq->B+q
68781  IF(iabs(kfl3).LE.10)THEN
68782  kfl3=-kfprev
68783  RETURN
68784  ENDIF
68785  goto 120
68786  ENDIF
68787 
68788 C test output qq against fake Gamma, then return if no popcorn.
68789  gb=2d0
68790  IF(irank.NE.0)THEN
68791  CALL pyzdis(1,2103,5d0,z)
68792  gb=5d0*(1d0-z)/z
68793  IF(1d0-parf(192)**gb.LT.pyr(0)) THEN
68794  mstu(121)=0
68795  goto 100
68796  ENDIF
68797  ENDIF
68798  IF(mstu(121).EQ.0) RETURN
68799 
68800 C..Set store size memory. Pick fake dynamical variables of qq.
68801  nmes=mstu(121)
68802  CALL pyptdi(1,px3,py3)
68803  x=1d0
68804  popm=0d0
68805  g=gb
68806  popg=gb
68807 
68808 C.. Pick next popcorn meson, test with fake dynamical variables
68809  110 kfprev=-kfl3
68810  px1=-px3
68811  py1=-py3
68812  CALL pykfdi(kfprev,0,kfl3,kfm)
68813  IF(mstu(121).EQ.-1) goto 100
68814  CALL pyptdi(kfl3,px3,py3)
68815  pm=pymass(kfm)**2+(px1+px3)**2+(py1+py3)**2
68816  CALL pyzdis(kfprev,kfl3,pm,z)
68817  g=(1d0-z)*(g+pm/z)
68818  x=(1d0-z)*x
68819 
68820  ptst=1d0
68821  gtst=1d0
68822  rtst=pyr(0)
68823  IF(mstj(12).GT.4)THEN
68824  popmn=sqrt((1d0-x)*(g/x-gb))
68825  popm=popm+pmas(pycomp(kfm),1)-pmas(pycomp(kfm),3)
68826  ptst=exp((popm-popmn)*parf(193))
68827  popm=popmn
68828  ENDIF
68829  IF(irank.NE.0)THEN
68830  popgn=x*gb
68831  gtst=(1d0-parf(192)**popgn)/(1d0-parf(192)**popg)
68832  popg=popgn
68833  ENDIF
68834  IF(rtst.GT.ptst*gtst)THEN
68835  mstu(121)=0
68836  IF(rtst.GT.ptst) mstu(121)=-1
68837  goto 100
68838  ENDIF
68839 
68840 C.. Store meson
68841  120 IF(nmes.LE.nmax) mstu(nsto+mstu(121)+1)=kfm
68842  IF(mstu(121).GT.0) goto 110
68843 
68844 C.. Test accepted system size. If OK set global popcorn size variable.
68845  IF(nmes.GT.nmax)THEN
68846  kf=0
68847  kfl3=0
68848  RETURN
68849  ENDIF
68850  mstu(121)=nmes
68851  ENDIF
68852 
68853  RETURN
68854  END
68855 
68856 C********************************************************************
68857 
68858 C...PYKFDI
68859 C...Generates a new flavour pair and combines off a hadron
68860 
68861  SUBROUTINE pykfdi(KFL1,KFL2,KFL3,KF)
68862 
68863 C...Double precision and integer declarations.
68864  IMPLICIT DOUBLE PRECISION(a-h, o-z)
68865  IMPLICIT INTEGER(i-n)
68866  INTEGER pyk,pychge,pycomp
68867 C...Commonblocks.
68868  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
68869  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
68870  SAVE /pydat1/,/pydat2/
68871 C...Local arrays.
68872  dimension pd(7)
68873 
68874  IF(mstu(123).EQ.0.AND.mstj(12).GE.0) CALL pykfin
68875 
68876 C...Default flavour values. Input consistency checks.
68877  kf1a=iabs(kfl1)
68878  kf2a=iabs(kfl2)
68879  kfl3=0
68880  kf=0
68881  IF(kf1a.EQ.0) RETURN
68882  IF(kf2a.NE.0)THEN
68883  IF(kf1a.LE.10.AND.kf2a.LE.10.AND.kfl1*kfl2.GT.0) RETURN
68884  IF(kf1a.GT.10.AND.kf2a.GT.10) RETURN
68885  IF((kf1a.GT.10.OR.kf2a.GT.10).AND.kfl1*kfl2.LT.0) RETURN
68886  ENDIF
68887 
68888 C...Check if tabulated flavour probabilities are to be used.
68889  IF(mstj(15).EQ.1) THEN
68890  IF(mstj(12).GE.5) CALL pyerrm(29,
68891  & '(PYKFDI:) Sorry, option MSTJ(15)=1 not available' //
68892  & ' together with MSTJ(12)>=5 modification')
68893  ktab1=-1
68894  IF(kf1a.GE.1.AND.kf1a.LE.6) ktab1=kf1a
68895  kfl1a=mod(kf1a/1000,10)
68896  kfl1b=mod(kf1a/100,10)
68897  kfl1s=mod(kf1a,10)
68898  IF(kfl1a.GE.1.AND.kfl1a.LE.4.AND.kfl1b.GE.1.AND.kfl1b.LE.4)
68899  & ktab1=6+kfl1a*(kfl1a-2)+2*kfl1b+(kfl1s-1)/2
68900  IF(kfl1a.GE.1.AND.kfl1a.LE.4.AND.kfl1a.EQ.kfl1b) ktab1=ktab1-1
68901  IF(kf1a.GE.1.AND.kf1a.LE.6) kfl1a=kf1a
68902  ktab2=0
68903  IF(kf2a.NE.0) THEN
68904  ktab2=-1
68905  IF(kf2a.GE.1.AND.kf2a.LE.6) ktab2=kf2a
68906  kfl2a=mod(kf2a/1000,10)
68907  kfl2b=mod(kf2a/100,10)
68908  kfl2s=mod(kf2a,10)
68909  IF(kfl2a.GE.1.AND.kfl2a.LE.4.AND.kfl2b.GE.1.AND.kfl2b.LE.4)
68910  & ktab2=6+kfl2a*(kfl2a-2)+2*kfl2b+(kfl2s-1)/2
68911  IF(kfl2a.GE.1.AND.kfl2a.LE.4.AND.kfl2a.EQ.kfl2b) ktab2=ktab2-1
68912  ENDIF
68913  IF(ktab1.GE.0.AND.ktab2.GE.0) goto 140
68914  ENDIF
68915 
68916 C.. Recognize rank 0 diquark case
68917  100 irank=1
68918  kfdiq=max(kf1a,kf2a)
68919  IF(kfdiq.GT.10.AND.kfdiq.LT.10000) irank=0
68920 
68921 C.. Join two flavours to meson or baryon. Test for popcorn.
68922  IF(kf2a.GT.0)THEN
68923  mbary=0
68924  IF(kfdiq.GT.10) THEN
68925  IF(irank.EQ.0.AND.mstj(12).LT.5)
68926  & CALL pynmes(kfdiq)
68927  IF(mstu(121).NE.0) THEN
68928  mstu(121)=0
68929  RETURN
68930  ENDIF
68931  mbary=2
68932  ENDIF
68933  kfqold=kf1a
68934  kfqver=kf2a
68935  goto 130
68936  ENDIF
68937 
68938 C.. Separate incoming flavours, curtain flavour consistency check
68939  kfin=kfl1
68940  kfqold=kf1a
68941  kfqpop=kf1a/10000
68942  IF(kf1a.GT.10)THEN
68943  kfin=-kfl1
68944  kfl1a=mod(kf1a/1000,10)
68945  kfl1b=mod(kf1a/100,10)
68946  IF(irank.EQ.0)THEN
68947  qawt=1d0
68948  IF(kfl1a.GE.3) qawt=parf(136+kfl1a/4)
68949  IF(kfl1b.GE.3) qawt=qawt/parf(136+kfl1b/4)
68950  kfqpop=kfl1a+(kfl1b-kfl1a)*int(1d0/(qawt+1d0)+pyr(0))
68951  ENDIF
68952  IF(kfqpop.NE.kfl1b.AND.kfqpop.NE.kfl1a) THEN
68953  mstu(121)=0
68954  RETURN
68955  ENDIF
68956  kfqold=kfl1a+kfl1b-kfqpop
68957  ENDIF
68958 
68959 C...Meson/baryon choice. Set number of mesons if starting a popcorn
68960 C...system.
68961  110 mbary=0
68962  IF(kf1a.LE.10.AND.mstj(12).GT.0)THEN
68963  IF(mstu(121).EQ.-1.OR.(1d0+parj(1))*pyr(0).GT.1d0)THEN
68964  mbary=1
68965  CALL pynmes(0)
68966  ENDIF
68967  ELSEIF(kf1a.GT.10)THEN
68968  mbary=2
68969  IF(irank.EQ.0) CALL pynmes(kf1a)
68970  IF(mstu(121).GT.0) mbary=-1
68971  ENDIF
68972 
68973 C..x->H+q: Choose single vertex quark. Jump to form hadron.
68974  IF(mbary.EQ.0.OR.mbary.EQ.2)THEN
68975  kfqver=1+int((2d0+parj(2))*pyr(0))
68976  kfl3=isign(kfqver,-kfin)
68977  goto 130
68978  ENDIF
68979 
68980 C..x->H+qq: (IDW=proper PARF position for diquark weights)
68981  idw=160
68982  IF(mbary.EQ.1)THEN
68983  IF(mstu(121).EQ.0) idw=150
68984  sqwt=parf(idw+1)
68985  IF(mstu(121).GT.0) sqwt=sqwt*parf(135)*parf(138)**mstu(121)
68986  kfqpop=1+int((2d0+sqwt)*pyr(0))
68987 C.. Shift to s-curtain parameters if needed
68988  IF(kfqpop.GE.3.AND.mstj(12).GE.5)THEN
68989  parf(194)=parf(138)*parf(139)
68990  parf(193)=parj(8)+parj(9)
68991  ENDIF
68992  ENDIF
68993 
68994 C.. x->H+qq: Get vertex quark
68995  IF(mbary.EQ.-1.AND.mstj(12).GE.5)THEN
68996  idw=mstu(122)
68997  mstu(121)=mstu(121)-1
68998  IF(idw.EQ.170) THEN
68999  IF(mstu(121).EQ.0)THEN
69000  ipos=3*min(kfqpop-1,2)+min(kfqold-1,2)
69001  ELSE
69002  ipos=3*3+3*max(0,min(kfqpop-2,1))+min(kfqold-1,2)
69003  ENDIF
69004  ELSE
69005  IF(mstu(121).EQ.0)THEN
69006  ipos=3*5+5*min(kfqpop-1,3)+min(kfqold-1,4)
69007  ELSE
69008  ipos=3*5+5*4+min(kfqold-1,4)
69009  ENDIF
69010  ENDIF
69011  ipos=200+30*ipos+1
69012 
69013  imes=-1
69014  rmes=pyr(0)*parf(194)
69015  120 imes=imes+1
69016  rmes=rmes-parf(ipos+imes)
69017  IF(imes.EQ.30) THEN
69018  mstu(121)=-1
69019  kf=-111
69020  RETURN
69021  ENDIF
69022  IF(rmes.GT.0d0) goto 120
69023  kmul=imes/5
69024  kfj=2*kmul+1
69025  IF(kmul.EQ.2) kfj=10003
69026  IF(kmul.EQ.3) kfj=10001
69027  IF(kmul.EQ.4) kfj=20003
69028  IF(kmul.EQ.5) kfj=5
69029  idiag=0
69030  kfqver=mod(imes,5)+1
69031  IF(kfqver.GE.kfqold) kfqver=kfqver+1
69032  IF(kfqver.GT.3)THEN
69033  idiag=kfqver-3
69034  kfqver=kfqold
69035  ENDIF
69036  ELSE
69037  IF(mbary.EQ.-1) idw=170
69038  sqwt=parf(idw+2)
69039  IF(kfqpop.EQ.3) sqwt=parf(idw+3)
69040  IF(kfqpop.GT.3) sqwt=parf(idw+3)*(1d0/parf(idw+5)+1d0)/2d0
69041  kfqver=min(3,1+int((2d0+sqwt)*pyr(0)))
69042  IF(kfqpop.LT.3.AND.kfqver.LT.3)THEN
69043  kfqver=kfqpop
69044  IF(pyr(0).GT.parf(idw+4)) kfqver=3-kfqpop
69045  ENDIF
69046  ENDIF
69047 
69048 C..x->H+qq: form outgoing diquark with KFQPOP flag at 10000-pos
69049  kflds=3
69050  IF(kfqpop.NE.kfqver)THEN
69051  swt=parf(idw+7)
69052  IF(kfqver.EQ.3) swt=parf(idw+6)
69053  IF(kfqpop.GE.3) swt=parf(idw+5)
69054  IF((1d0+swt)*pyr(0).LT.1d0) kflds=1
69055  ENDIF
69056  kfdiq=900*max(kfqver,kfqpop)+100*(kfqver+kfqpop)+kflds
69057  & +10000*kfqpop
69058  kfl3=isign(kfdiq,kfin)
69059 
69060 C..x->M+y: flavour for meson.
69061  130 IF(mbary.LE.0)THEN
69062  kfla=max(kfqold,kfqver)
69063  kflb=min(kfqold,kfqver)
69064  kfs=isign(1,kfl1)
69065  IF(kfla.NE.kfqold) kfs=-kfs
69066 C... Form meson, with spin and flavour mixing for diagonal states.
69067  IF(mbary.EQ.-1.AND.mstj(12).GE.5)THEN
69068  IF(idiag.GT.0) kf=110*idiag+kfj
69069  IF(idiag.EQ.0) kf=(100*kfla+10*kflb+kfj)*kfs*(-1)**kfla
69070  RETURN
69071  ENDIF
69072  IF(kfla.LE.2) kmul=int(parj(11)+pyr(0))
69073  IF(kfla.EQ.3) kmul=int(parj(12)+pyr(0))
69074  IF(kfla.GE.4) kmul=int(parj(13)+pyr(0))
69075  IF(kmul.EQ.0.AND.parj(14).GT.0d0)THEN
69076  IF(pyr(0).LT.parj(14)) kmul=2
69077  ELSEIF(kmul.EQ.1.AND.parj(15)+parj(16)+parj(17).GT.0d0)THEN
69078  rmul=pyr(0)
69079  IF(rmul.LT.parj(15)) kmul=3
69080  IF(kmul.EQ.1.AND.rmul.LT.parj(15)+parj(16)) kmul=4
69081  IF(kmul.EQ.1.AND.rmul.LT.parj(15)+parj(16)+parj(17)) kmul=5
69082  ENDIF
69083  kfls=3
69084  IF(kmul.EQ.0.OR.kmul.EQ.3) kfls=1
69085  IF(kmul.EQ.5) kfls=5
69086  IF(kfla.NE.kflb)THEN
69087  kf=(100*kfla+10*kflb+kfls)*kfs*(-1)**kfla
69088  ELSE
69089  rmix=pyr(0)
69090  imix=2*kfla+10*kmul
69091  IF(kfla.LE.3) kf=110*(1+int(rmix+parf(imix-1))+
69092  & int(rmix+parf(imix)))+kfls
69093  IF(kfla.GE.4) kf=110*kfla+kfls
69094  ENDIF
69095  IF(kmul.EQ.2.OR.kmul.EQ.3) kf=kf+isign(10000,kf)
69096  IF(kmul.EQ.4) kf=kf+isign(20000,kf)
69097 
69098 C..Optional extra suppression of eta and eta'.
69099 C..Allow shift to qq->B+q in old version (set IRANK to 0)
69100  IF(kf.EQ.221.OR.kf.EQ.331)THEN
69101  IF(pyr(0).GT.parj(25+kf/300))THEN
69102  IF(kf2a.GT.0) goto 130
69103  IF(mstj(12).LT.4) irank=0
69104  goto 110
69105  ENDIF
69106  ENDIF
69107  mstu(121)=0
69108 
69109 C.. x->B+y: Flavour for baryon
69110  ELSE
69111  kfla=kfqver
69112  IF(kf1a.LE.10) kfla=kfqold
69113  kflb=mod(kfdiq/1000,10)
69114  kflc=mod(kfdiq/100,10)
69115  kflds=mod(kfdiq,10)
69116  kfld=max(kfla,kflb,kflc)
69117  kflf=min(kfla,kflb,kflc)
69118  kfle=kfla+kflb+kflc-kfld-kflf
69119 
69120 C... SU(6) factors for formation of baryon.
69121  kbary=3
69122  kdmax=5
69123  kflg=kflb
69124  IF(kflb.NE.kflc)THEN
69125  kbary=2*kflds-1
69126  kdmax=1+kflds/2
69127  IF(kflb.GT.2) kdmax=kdmax+2
69128  ENDIF
69129  IF(kfla.NE.kflb.AND.kfla.NE.kflc)THEN
69130  kbary=kbary+1
69131  kflg=kfla
69132  ENDIF
69133 
69134  su6max=parf(140+kdmax)
69135  su6dec=parj(18)
69136  su6s =parf(146)
69137  IF(mstj(12).GE.5.AND.irank.EQ.0) THEN
69138  su6max=1d0
69139  su6dec=1d0
69140  su6s =1d0
69141  ENDIF
69142  su6oct=parf(60+kbary)
69143  IF(kflg.GT.max(kfla+kflb-kflg,2))THEN
69144  su6oct=su6oct*4*su6s/(3*su6s+1)
69145  IF(kbary.EQ.2) su6oct=parf(60+kbary)*4/(3*su6s+1)
69146  ELSE
69147  IF(kbary.EQ.6) su6oct=su6oct*(3+su6s)/(3*su6s+1)
69148  ENDIF
69149  su6wt=su6oct+su6dec*parf(70+kbary)
69150 
69151 C.. SU(6) test. Old options enforce new baryon if q->B+qq is rejected.
69152  IF(su6wt.LT.pyr(0)*su6max.AND.kf2a.EQ.0)THEN
69153  mstu(121)=0
69154  IF(mstj(12).LE.2.AND.mbary.EQ.1) mstu(121)=-1
69155  goto 110
69156  ENDIF
69157 
69158 C.. Form baryon. Distinguish Lambda- and Sigmalike baryons.
69159  ksig=1
69160  kfls=2
69161  IF(su6wt*pyr(0).GT.su6oct) kfls=4
69162  IF(kfls.EQ.2.AND.kfld.GT.kfle.AND.kfle.GT.kflf)THEN
69163  ksig=kflds/3
69164  IF(kfla.NE.kfld) ksig=int(3*su6s/(3*su6s+kflds**2)+pyr(0))
69165  ENDIF
69166  kf=isign(1000*kfld+100*kfle+10*kflf+kfls,kfl1)
69167  IF(ksig.EQ.0) kf=isign(1000*kfld+100*kflf+10*kfle+kfls,kfl1)
69168  ENDIF
69169  RETURN
69170 
69171 C...Use tabulated probabilities to select new flavour and hadron.
69172  140 IF(ktab2.EQ.0.AND.mstj(12).LE.0) THEN
69173  kt3l=1
69174  kt3u=6
69175  ELSEIF(ktab2.EQ.0.AND.ktab1.GE.7.AND.mstj(12).LE.1) THEN
69176  kt3l=1
69177  kt3u=6
69178  ELSEIF(ktab2.EQ.0) THEN
69179  kt3l=1
69180  kt3u=22
69181  ELSE
69182  kt3l=ktab2
69183  kt3u=ktab2
69184  ENDIF
69185  rfl=0d0
69186  DO 160 kts=0,2
69187  DO 150 kt3=kt3l,kt3u
69188  rfl=rfl+parf(120+80*ktab1+25*kts+kt3)
69189  150 CONTINUE
69190  160 CONTINUE
69191  rfl=pyr(0)*rfl
69192  DO 180 kts=0,2
69193  ktabs=kts
69194  DO 170 kt3=kt3l,kt3u
69195  ktab3=kt3
69196  rfl=rfl-parf(120+80*ktab1+25*kts+kt3)
69197  IF(rfl.LE.0d0) goto 190
69198  170 CONTINUE
69199  180 CONTINUE
69200  190 CONTINUE
69201 
69202 C...Reconstruct flavour of produced quark/diquark.
69203  IF(ktab3.LE.6) THEN
69204  kfl3a=ktab3
69205  kfl3b=0
69206  kfl3=isign(kfl3a,kfl1*(2*ktab1-13))
69207  ELSE
69208  kfl3a=1
69209  IF(ktab3.GE.8) kfl3a=2
69210  IF(ktab3.GE.11) kfl3a=3
69211  IF(ktab3.GE.16) kfl3a=4
69212  kfl3b=(ktab3-6-kfl3a*(kfl3a-2))/2
69213  kfl3=1000*kfl3a+100*kfl3b+1
69214  IF(kfl3a.EQ.kfl3b.OR.ktab3.NE.6+kfl3a*(kfl3a-2)+2*kfl3b) kfl3=
69215  & kfl3+2
69216  kfl3=isign(kfl3,kfl1*(13-2*ktab1))
69217  ENDIF
69218 
69219 C...Reconstruct meson code.
69220  IF(kfl3a.EQ.kfl1a.AND.kfl3b.EQ.kfl1b.AND.(kfl3a.LE.3.OR.
69221  &kfl3b.NE.0)) THEN
69222  rfl=pyr(0)*(parf(143+80*ktab1+25*ktabs)+parf(144+80*ktab1+
69223  & 25*ktabs)+parf(145+80*ktab1+25*ktabs))
69224  kf=110+2*ktabs+1
69225  IF(rfl.GT.parf(143+80*ktab1+25*ktabs)) kf=220+2*ktabs+1
69226  IF(rfl.GT.parf(143+80*ktab1+25*ktabs)+parf(144+80*ktab1+
69227  & 25*ktabs)) kf=330+2*ktabs+1
69228  ELSEIF(ktab1.LE.6.AND.ktab3.LE.6) THEN
69229  kfla=max(ktab1,ktab3)
69230  kflb=min(ktab1,ktab3)
69231  kfs=isign(1,kfl1)
69232  IF(kfla.NE.kf1a) kfs=-kfs
69233  kf=(100*kfla+10*kflb+2*ktabs+1)*kfs*(-1)**kfla
69234  ELSEIF(ktab1.GE.7.AND.ktab3.GE.7) THEN
69235  kfs=isign(1,kfl1)
69236  IF(kfl1a.EQ.kfl3a) THEN
69237  kfla=max(kfl1b,kfl3b)
69238  kflb=min(kfl1b,kfl3b)
69239  IF(kfla.NE.kfl1b) kfs=-kfs
69240  ELSEIF(kfl1a.EQ.kfl3b) THEN
69241  kfla=kfl3a
69242  kflb=kfl1b
69243  kfs=-kfs
69244  ELSEIF(kfl1b.EQ.kfl3a) THEN
69245  kfla=kfl1a
69246  kflb=kfl3b
69247  ELSEIF(kfl1b.EQ.kfl3b) THEN
69248  kfla=max(kfl1a,kfl3a)
69249  kflb=min(kfl1a,kfl3a)
69250  IF(kfla.NE.kfl1a) kfs=-kfs
69251  ELSE
69252  CALL pyerrm(2,'(PYKFDI:) no matching flavours for qq -> qq')
69253  goto 100
69254  ENDIF
69255  kf=(100*kfla+10*kflb+2*ktabs+1)*kfs*(-1)**kfla
69256 
69257 C...Reconstruct baryon code.
69258  ELSE
69259  IF(ktab1.GE.7) THEN
69260  kfla=kfl3a
69261  kflb=kfl1a
69262  kflc=kfl1b
69263  ELSE
69264  kfla=kfl1a
69265  kflb=kfl3a
69266  kflc=kfl3b
69267  ENDIF
69268  kfld=max(kfla,kflb,kflc)
69269  kflf=min(kfla,kflb,kflc)
69270  kfle=kfla+kflb+kflc-kfld-kflf
69271  IF(ktabs.EQ.0) kf=isign(1000*kfld+100*kflf+10*kfle+2,kfl1)
69272  IF(ktabs.GE.1) kf=isign(1000*kfld+100*kfle+10*kflf+2*ktabs,kfl1)
69273  ENDIF
69274 
69275 C...Check that constructed flavour code is an allowed one.
69276  IF(kfl2.NE.0) kfl3=0
69277  kc=pycomp(kf)
69278  IF(kc.EQ.0) THEN
69279  CALL pyerrm(2,'(PYKFDI:) user-defined flavour probabilities '//
69280  & 'failed')
69281  goto 100
69282  ENDIF
69283 
69284  RETURN
69285  END
69286 
69287 C*********************************************************************
69288 
69289 C...PYNMES
69290 C...Generates number of popcorn mesons and stores some relevant
69291 C...parameters.
69292 
69293  SUBROUTINE pynmes(KFDIQ)
69294 
69295 C...Double precision and integer declarations.
69296  IMPLICIT DOUBLE PRECISION(a-h, o-z)
69297  IMPLICIT INTEGER(i-n)
69298  INTEGER pyk,pychge,pycomp
69299 C...Commonblocks.
69300  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
69301  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
69302  SAVE /pydat1/,/pydat2/
69303 
69304  mstu(121)=0
69305  IF(mstj(12).LT.2) RETURN
69306 
69307 C..Old version: Get 1 or 0 popcorn mesons
69308  IF(mstj(12).LT.5)THEN
69309  popwt=parf(131)
69310  IF(kfdiq.NE.0) THEN
69311  kfdiqa=iabs(kfdiq)
69312  kfa=mod(kfdiqa/1000,10)
69313  kfb=mod(kfdiqa/100,10)
69314  kfs=mod(kfdiqa,10)
69315  popwt=parf(132)
69316  IF(kfa.EQ.3) popwt=parf(133)
69317  IF(kfb.EQ.3) popwt=parf(134)
69318  IF(kfs.EQ.1) popwt=popwt*sqrt(parj(4))
69319  ENDIF
69320  mstu(121)=int(popwt/(1d0+popwt)+pyr(0))
69321  RETURN
69322  ENDIF
69323 
69324 C..New version: Store popcorn- or rank 0 diquark parameters
69325  mstu(122)=170
69326  parf(193)=parj(8)
69327  parf(194)=parf(139)
69328  IF(kfdiq.NE.0) THEN
69329  mstu(122)=180
69330  parf(193)=parj(10)
69331  parf(194)=parf(140)
69332  ENDIF
69333  IF(parf(194).LT.1d-5.OR.parf(194).GT.1d0-1d-5) THEN
69334  IF(parf(194).GT.1d0-1d-5) CALL pyerrm(9,
69335  & '(PYNMES:) Neglecting too large popcorn possibility')
69336  RETURN
69337  ENDIF
69338 
69339 C..New version: Get number of popcorn mesons
69340  100 rtst=pyr(0)
69341  mstu(121)=-1
69342  110 mstu(121)=mstu(121)+1
69343  rtst=rtst/parf(194)
69344  IF(rtst.LT.1d0) goto 110
69345  IF(kfdiq.EQ.0.AND.pyr(0)*(2d0+parf(135)*parf(161)).GT.
69346  & (2d0+parf(135)*parf(161)*parf(138)**mstu(121))) goto 100
69347  RETURN
69348  END
69349 
69350 C***************************************************************
69351 
69352 C...PYKFIN
69353 C...Precalculates a set of diquark and popcorn weights.
69354 
69355  SUBROUTINE pykfin
69356 
69357 C...Double precision and integer declarations.
69358  IMPLICIT DOUBLE PRECISION(a-h, o-z)
69359  IMPLICIT INTEGER(i-n)
69360  INTEGER pyk,pychge,pycomp
69361 C...Commonblocks.
69362  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
69363  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
69364  SAVE /pydat1/,/pydat2/
69365 
69366  dimension su6(12),su6m(7),qbb(7),qbm(7),dmb(14)
69367 
69368 
69369  mstu(123)=1
69370 C..Diquark indices for dimensional variables
69371  iud1=1
69372  iuu1=2
69373  ius0=3
69374  isu0=4
69375  ius1=5
69376  isu1=6
69377  iss1=7
69378 
69379 C.. *** SU(6) factors **
69380 C..Modify with decuplet- (and Sigma/Lambda-) suppression.
69381  parf(146)=1d0
69382  IF(mstj(12).GE.5) parf(146)=3d0*parj(18)/(2d0*parj(18)+1d0)
69383  IF(parj(18).LT.1d0-1d-5.AND.mstj(12).LT.5) CALL pyerrm(9,
69384  & '(PYKFIN:) PARJ(18)<1 combined with 0<MSTJ(12)<5 option')
69385  DO 100 i=1,6
69386  su6(i)=parf(60+i)
69387  su6(6+i)=su6(i)*4*parf(146)/(3*parf(146)+1)
69388  100 CONTINUE
69389  su6(8)=su6(2)*4/(3*parf(146)+1)
69390  su6(6)=su6(6)*(3+parf(146))/(3*parf(146)+1)
69391  DO 110 i=1,6
69392  su6(i)=su6(i)+parj(18)*parf(70+i)
69393  su6(6+i)=su6(6+i)+parj(18)*parf(70+i)
69394  110 CONTINUE
69395 
69396 C..SU(6)max q q' s,c,b
69397  su6mud =max(su6(1) , su6(8) )
69398  su6m(iud1)=max(su6(5) , su6(12))
69399  su6m(isu0)=max(su6(7) ,su6(2),su6mud )
69400  su6m(iuu1)=max(su6(3) ,su6(4),su6(10))
69401  su6m(isu1)=max(su6(11),su6(6),su6m(iud1))
69402  su6m(ius0)=su6m(isu0)
69403  su6m(iss1)=su6m(iuu1)
69404  su6m(ius1)=su6m(isu1)
69405 
69406 C..Store SU(6)max, in order UD0,UD1,US0,US1,QQ1
69407  parf(141)=su6mud
69408  parf(142)=su6m(iud1)
69409  parf(143)=su6m(isu0)
69410  parf(144)=su6m(isu1)
69411  parf(145)=su6m(iss1)
69412 
69413 C..diquark SU(6) survival =
69414 C..sum over quark (quark tunnel weight)*(SU(6)).
69415  pud0=(2d0*su6(1)+parj(2)*su6(8))
69416  dmb(isu0)=(su6(7)+su6(2)+parj(2)*su6(1))/pud0
69417  dmb(ius0)=dmb(isu0)
69418  dmb(iss1)=(2d0*su6(4)+parj(2)*su6(3))/pud0
69419  dmb(iuu1)=(su6(3)+su6(4)+parj(2)*su6(10))/pud0
69420  dmb(isu1)=(su6(11)+su6(6)+parj(2)*su6(5))/pud0
69421  dmb(ius1)=dmb(isu1)
69422  dmb(iud1)=(2d0*su6(5)+parj(2)*su6(12))/pud0
69423 
69424 C.. *** Tunneling factors for Diquark production***
69425 C.. T: half a curtain pair = sqrt(curtain pair factor)
69426  IF(mstj(12).GE.5) THEN
69427  pmud0=pymass(2101)
69428  pmud1=pymass(2103)-pmud0
69429  pmus0=pymass(3201)-pmud0
69430  pmus1=pymass(3203)-pmus0-pmud0
69431  pmss1=pymass(3303)-pmus0-pmud0
69432  qbb(isu0)=exp(-(parj(9)+parj(8))*pmus0-parj(9)*parf(191))
69433  qbb(ius0)=exp(-parj(8)*pmus0)
69434  qbb(iss1)=exp(-(parj(9)+parj(8))*pmss1)*qbb(isu0)
69435  qbb(iuu1)=exp(-parj(8)*pmud1)
69436  qbb(isu1)=exp(-(parj(9)+parj(8))*pmus1)*qbb(isu0)
69437  qbb(ius1)=exp(-parj(8)*pmus1)*qbb(ius0)
69438  qbb(iud1)=qbb(iuu1)
69439  ELSE
69440  par2m=sqrt(parj(2))
69441  par3m=sqrt(parj(3))
69442  par4m=sqrt(parj(4))
69443  qbb(isu0)=par2m*par3m
69444  qbb(ius0)=par3m
69445  qbb(iss1)=par2m*parj(3)*par4m
69446  qbb(iuu1)=par4m
69447  qbb(isu1)=par4m*qbb(isu0)
69448  qbb(ius1)=par4m*qbb(ius0)
69449  qbb(iud1)=par4m
69450  ENDIF
69451 
69452 C.. tau: spin*(vertex factor)*(T = half-curtain factor)
69453  qbm(isu0)=qbb(isu0)
69454  qbm(ius0)=parj(2)*qbb(ius0)
69455  qbm(iss1)=parj(2)*6d0*qbb(iss1)
69456  qbm(iuu1)=6d0*qbb(iuu1)
69457  qbm(isu1)=3d0*qbb(isu1)
69458  qbm(ius1)=parj(2)*3d0*qbb(ius1)
69459  qbm(iud1)=3d0*qbb(iud1)
69460 
69461 C.. Combine T and tau to diquark weight for q-> B+B+..
69462  DO 120 i=1,7
69463  qbb(i)=qbb(i)*qbm(i)
69464  120 CONTINUE
69465 
69466  IF(mstj(12).GE.5)THEN
69467 C..New version: tau for rank 0 diquark.
69468  dmb(7+isu0)=exp(-parj(10)*pmus0)
69469  dmb(7+ius0)=parj(2)*dmb(7+isu0)
69470  dmb(7+iss1)=6d0*parj(2)*exp(-parj(10)*pmss1)*dmb(7+isu0)
69471  dmb(7+iuu1)=6d0*exp(-parj(10)*pmud1)
69472  dmb(7+isu1)=3d0*exp(-parj(10)*pmus1)*dmb(7+isu0)
69473  dmb(7+ius1)=parj(2)*dmb(7+isu1)
69474  dmb(7+iud1)=dmb(7+iuu1)/2d0
69475 
69476 C..New version: curtain flavour ratios.
69477 C.. s/u for q->B+M+...
69478 C.. s/u for rank 0 diquark: su -> ...M+B+...
69479 C.. Q/q for heavy rank 0 diquark: Qu -> ...M+B+...
69480  wu=1d0+qbm(iud1)+qbm(ius0)+qbm(ius1)+qbm(iuu1)
69481  parf(135)=(2d0*(qbm(isu0)+qbm(isu1))+qbm(iss1))/wu
69482  wu=1d0+dmb(7+iud1)+dmb(7+ius0)+dmb(7+ius1)+dmb(7+iuu1)
69483  parf(136)=(2d0*(dmb(7+isu0)+dmb(7+isu1))+dmb(7+iss1))/wu
69484  parf(137)=(dmb(7+isu0)+dmb(7+isu1))*
69485  & (2d0+dmb(7+iss1)/(2d0*dmb(7+isu1)))/wu
69486  ELSE
69487 C..Old version: reset unused rank 0 diquark weights and
69488 C.. unused diquark SU(6) survival weights
69489  DO 130 i=1,7
69490  IF(mstj(12).LT.3) dmb(i)=1d0
69491  dmb(7+i)=1d0
69492  130 CONTINUE
69493 
69494 C..Old version: Shuffle PARJ(7) into tau
69495  qbm(ius0)=qbm(ius0)*parj(7)
69496  qbm(iss1)=qbm(iss1)*parj(7)
69497  qbm(ius1)=qbm(ius1)*parj(7)
69498 
69499 C..Old version: curtain flavour ratios.
69500 C.. s/u for q->B+M+...
69501 C.. s/u for rank 0 diquark: su -> ...M+B+...
69502 C.. Q/q for heavy rank 0 diquark: Qu -> ...M+B+...
69503  wu=1d0+qbm(iud1)+qbm(ius0)+qbm(ius1)+qbm(iuu1)
69504  parf(135)=(2d0*(qbm(isu0)+qbm(isu1))+qbm(iss1))/wu
69505  parf(136)=parf(135)*parj(6)*qbm(isu0)/qbm(ius0)
69506  parf(137)=(1d0+qbm(iud1))*(2d0+qbm(ius0))/wu
69507  ENDIF
69508 
69509 C..Combine diquark SU(6) survival, SU(6)max, tau and T into factors for:
69510 C.. rank0 D->M+B+..; D->M+B+..; q->B+M+..; q->B+B..
69511  DO 140 i=1,7
69512  dmb(7+i)=dmb(7+i)*dmb(i)
69513  dmb(i)=dmb(i)*qbm(i)
69514  qbm(i)=qbm(i)*su6m(i)/su6mud
69515  qbb(i)=qbb(i)*su6m(i)/su6mud
69516  140 CONTINUE
69517 
69518 C.. *** Popcorn factors ***
69519 
69520  IF(mstj(12).LT.5)THEN
69521 C.. Old version: Resulting popcorn weights.
69522  parf(138)=parj(6)
69523  ws=parf(135)*parf(138)
69524  wq=wu*parj(5)/3d0
69525  parf(132)=wq*qbm(iud1)/qbb(iud1)
69526  parf(133)=wq*
69527  & (qbm(ius1)/qbb(ius1)+ws*qbm(isu1)/qbb(isu1))/2d0
69528  parf(134)=wq*ws*qbm(iss1)/qbb(iss1)
69529  parf(131)=wq*(1d0+qbm(iud1)+qbm(iuu1)+qbm(ius0)+qbm(ius1)+
69530  & ws*(qbm(isu0)+qbm(isu1)+qbm(iss1)/2d0))/
69531  & (1d0+qbb(iud1)+qbb(iuu1)+
69532  & 2d0*(qbb(ius0)+qbb(ius1))+qbb(iss1)/2d0)
69533  ELSE
69534 C..New version: Store weights for popcorn mesons,
69535 C..get prel. popcorn weights.
69536  DO 150 ipos=201,1400
69537  parf(ipos)=0d0
69538  150 CONTINUE
69539  DO 160 i=138,140
69540  parf(i)=0d0
69541  160 CONTINUE
69542  ipos=200
69543  parf(193)=parj(8)
69544  DO 240 mr=0,7,7
69545  IF(mr.EQ.7) parf(193)=parj(10)
69546  sqwt=2d0*(dmb(mr+ius0)+dmb(mr+ius1))/
69547  & (1d0+dmb(mr+iud1)+dmb(mr+iuu1))
69548  qqwt=dmb(mr+iuu1)/(1d0+dmb(mr+iud1)+dmb(mr+iuu1))
69549  DO 230 nmes=0,1
69550  IF(nmes.EQ.1) sqwt=parj(2)
69551  DO 220 kfqpop=1,4
69552  IF(mr.EQ.0.AND.kfqpop.GT.3) goto 220
69553  IF(nmes.EQ.0.AND.kfqpop.GE.3)THEN
69554  sqwt=dmb(mr+iss1)/(dmb(mr+isu0)+dmb(mr+isu1))
69555  qqwt=0.5d0
69556  IF(mr.EQ.0) parf(193)=parj(8)+parj(9)
69557  IF(kfqpop.EQ.4) sqwt=sqwt*(1d0/dmb(7+isu1)+1d0)/2d0
69558  ENDIF
69559  DO 210 kfqold =1,5
69560  IF(mr.EQ.0.AND.kfqold.GT.3) goto 210
69561  IF(nmes.EQ.1) THEN
69562  IF(mr.EQ.0.AND.kfqpop.EQ.1) goto 210
69563  IF(mr.EQ.7.AND.kfqpop.NE.1) goto 210
69564  ENDIF
69565  wttot=0d0
69566  wtfail=0d0
69567  DO 190 kmul=0,5
69568  pjwt=parj(12+kmul)
69569  IF(kmul.EQ.0) pjwt=1d0-parj(14)
69570  IF(kmul.EQ.1) pjwt=1d0-parj(15)-parj(16)-parj(17)
69571  IF(pjwt.LE.0d0) goto 190
69572  IF(pjwt.GT.1d0) pjwt=1d0
69573  imes=5*kmul
69574  imix=2*kfqold+10*kmul
69575  kfj=2*kmul+1
69576  IF(kmul.EQ.2) kfj=10003
69577  IF(kmul.EQ.3) kfj=10001
69578  IF(kmul.EQ.4) kfj=20003
69579  IF(kmul.EQ.5) kfj=5
69580  DO 180 kfqver =1,3
69581  kfla=max(kfqold,kfqver)
69582  kflb=min(kfqold,kfqver)
69583  swt=parj(11+kfla/3+kfla/4)
69584  IF(kmul.EQ.0.OR.kmul.EQ.2) swt=1d0-swt
69585  swt=swt*pjwt
69586  qwt=sqwt/(2d0+sqwt)
69587  IF(kfqver.LT.3)THEN
69588  IF(kfqver.EQ.kfqpop) qwt=(1d0-qwt)*qqwt
69589  IF(kfqver.NE.kfqpop) qwt=(1d0-qwt)*(1d0-qqwt)
69590  ENDIF
69591  IF(kfqver.NE.kfqold)THEN
69592  imes=imes+1
69593  kfm=100*kfla+10*kflb+kfj
69594  pmm=pmas(pycomp(kfm),1)-pmas(pycomp(kfm),3)
69595  parf(ipos+imes)=qwt*swt*exp(-parf(193)*pmm)
69596  wttot=wttot+parf(ipos+imes)
69597  ELSE
69598  DO 170 id=3,5
69599  IF(id.EQ.3) dwt=1d0-parf(imix-1)
69600  IF(id.EQ.4) dwt=parf(imix-1)-parf(imix)
69601  IF(id.EQ.5) dwt=parf(imix)
69602  kfm=110*(id-2)+kfj
69603  pmm=pmas(pycomp(kfm),1)-pmas(pycomp(kfm),3)
69604  parf(ipos+5*kmul+id)=qwt*swt*dwt*exp(-parf(193)*pmm)
69605  IF(kmul.EQ.0.AND.id.GT.3) THEN
69606  wtfail=wtfail+qwt*swt*dwt*(1d0-parj(21+id))
69607  parf(ipos+5*kmul+id)=
69608  & parf(ipos+5*kmul+id)*parj(21+id)
69609  ENDIF
69610  wttot=wttot+parf(ipos+5*kmul+id)
69611  170 CONTINUE
69612  ENDIF
69613  180 CONTINUE
69614  190 CONTINUE
69615  DO 200 imes=1,30
69616  parf(ipos+imes)=parf(ipos+imes)/(1d0-wtfail)
69617  200 CONTINUE
69618  IF(mr.EQ.7) parf(140)=
69619  & max(parf(140),wttot/(1d0-wtfail))
69620  IF(mr.EQ.0) parf(139-kfqpop/3)=
69621  & max(parf(139-kfqpop/3),wttot/(1d0-wtfail))
69622  ipos=ipos+30
69623  210 CONTINUE
69624  220 CONTINUE
69625  230 CONTINUE
69626  240 CONTINUE
69627  IF(parf(139).GT.1d-10) parf(138)=parf(138)/parf(139)
69628  mstu(121)=0
69629 
69630  ENDIF
69631 
69632 C..Recombine diquark weights to flavour and spin ratios
69633  parf(151)=(2d0*(qbb(isu0)+qbb(isu1))+qbb(iss1))/
69634  & (1d0+qbb(iud1)+qbb(iuu1)+qbb(ius0)+qbb(ius1))
69635  parf(152)=2d0*(qbb(ius0)+qbb(ius1))/(1d0+qbb(iud1)+qbb(iuu1))
69636  parf(153)=qbb(iss1)/(qbb(isu0)+qbb(isu1))
69637  parf(154)=qbb(iuu1)/(1d0+qbb(iud1)+qbb(iuu1))
69638  parf(155)=qbb(isu1)/qbb(isu0)
69639  parf(156)=qbb(ius1)/qbb(ius0)
69640  parf(157)=qbb(iud1)
69641 
69642  parf(161)=(2d0*(qbm(isu0)+qbm(isu1))+qbm(iss1))/
69643  & (1d0+qbm(iud1)+qbm(iuu1)+qbm(ius0)+qbm(ius1))
69644  parf(162)=2d0*(qbm(ius0)+qbm(ius1))/(1d0+qbm(iud1)+qbm(iuu1))
69645  parf(163)=qbm(iss1)/(qbm(isu0)+qbm(isu1))
69646  parf(164)=qbm(iuu1)/(1d0+qbm(iud1)+qbm(iuu1))
69647  parf(165)=qbm(isu1)/qbm(isu0)
69648  parf(166)=qbm(ius1)/qbm(ius0)
69649  parf(167)=qbm(iud1)
69650 
69651  parf(171)=(2d0*(dmb(isu0)+dmb(isu1))+dmb(iss1))/
69652  & (1d0+dmb(iud1)+dmb(iuu1)+dmb(ius0)+dmb(ius1))
69653  parf(172)=2d0*(dmb(ius0)+dmb(ius1))/(1d0+dmb(iud1)+dmb(iuu1))
69654  parf(173)=dmb(iss1)/(dmb(isu0)+dmb(isu1))
69655  parf(174)=dmb(iuu1)/(1d0+dmb(iud1)+dmb(iuu1))
69656  parf(175)=dmb(isu1)/dmb(isu0)
69657  parf(176)=dmb(ius1)/dmb(ius0)
69658  parf(177)=dmb(iud1)
69659 
69660  parf(185)=dmb(7+isu1)/dmb(7+isu0)
69661  parf(186)=dmb(7+ius1)/dmb(7+ius0)
69662  parf(187)=dmb(7+iud1)
69663 
69664  RETURN
69665  END
69666 
69667 
69668 C*********************************************************************
69669 
69670 C...PYPTDI
69671 C...Generates transverse momentum according to a Gaussian.
69672 
69673  SUBROUTINE pyptdi(KFL,PX,PY)
69674 
69675 C...Double precision and integer declarations.
69676  IMPLICIT DOUBLE PRECISION(a-h, o-z)
69677  IMPLICIT INTEGER(i-n)
69678  INTEGER pyk,pychge,pycomp
69679 C...Commonblocks.
69680  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
69681  SAVE /pydat1/
69682 
69683 C...Generate p_T and azimuthal angle, gives p_x and p_y.
69684  kfla=iabs(kfl)
69685  pt=parj(21)*sqrt(-log(max(1d-10,pyr(0))))
69686  IF(parj(23).GT.pyr(0)) pt=parj(24)*pt
69687  IF(mstj(91).EQ.1) pt=parj(22)*pt
69688  IF(kfla.EQ.0.AND.mstj(13).LE.0) pt=0d0
69689  phi=paru(2)*pyr(0)
69690  px=pt*cos(phi)
69691  py=pt*sin(phi)
69692 
69693  RETURN
69694  END
69695 
69696 C*********************************************************************
69697 
69698 C...PYZDIS
69699 C...Generates the longitudinal splitting variable z.
69700 
69701  SUBROUTINE pyzdis(KFL1,KFL2,PR,Z)
69702 
69703 C...Double precision and integer declarations.
69704  IMPLICIT DOUBLE PRECISION(a-h, o-z)
69705  IMPLICIT INTEGER(i-n)
69706  INTEGER pyk,pychge,pycomp
69707 C...Commonblocks.
69708  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
69709  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
69710  SAVE /pydat1/,/pydat2/
69711 
69712 C...Check if heavy flavour fragmentation.
69713  kfla=iabs(kfl1)
69714  kflb=iabs(kfl2)
69715  kflh=kfla
69716  IF(kfla.GE.10) kflh=mod(kfla/1000,10)
69717 
69718 C...Lund symmetric scaling function: determine parameters of shape.
69719  IF(mstj(11).EQ.1.OR.(mstj(11).EQ.3.AND.kflh.LE.3).OR.
69720  &mstj(11).GE.4) THEN
69721  fa=parj(41)
69722  IF(mstj(91).EQ.1) fa=parj(43)
69723  IF(kflb.GE.10) fa=fa+parj(45)
69724  fbb=parj(42)
69725  IF(mstj(91).EQ.1) fbb=parj(44)
69726  fb=fbb*pr
69727  fc=1d0
69728  IF(kfla.GE.10) fc=fc-parj(45)
69729  IF(kflb.GE.10) fc=fc+parj(45)
69730  IF(mstj(11).GE.4.AND.(kflh.EQ.4.OR.kflh.EQ.5)) THEN
69731  fred=parj(46)
69732  IF(mstj(11).EQ.5.AND.kflh.EQ.5) fred=parj(47)
69733  fc=fc+fred*fbb*parf(100+kflh)**2
69734  ENDIF
69735  mc=1
69736  IF(abs(fc-1d0).GT.0.01d0) mc=2
69737 
69738 C...Determine position of maximum. Special cases for a = 0 or a = c.
69739  IF(fa.LT.0.02d0) THEN
69740  ma=1
69741  zmax=1d0
69742  IF(fc.GT.fb) zmax=fb/fc
69743  ELSEIF(abs(fc-fa).LT.0.01d0) THEN
69744  ma=2
69745  zmax=fb/(fb+fc)
69746  ELSE
69747  ma=3
69748  zmax=0.5d0*(fb+fc-sqrt((fb-fc)**2+4d0*fa*fb))/(fc-fa)
69749  IF(zmax.GT.0.9999d0.AND.fb.GT.100d0) zmax=min(zmax,1d0-fa/fb)
69750  ENDIF
69751 
69752 C...Subdivide z range if distribution very peaked near endpoint.
69753  mmax=2
69754  IF(zmax.LT.0.1d0) THEN
69755  mmax=1
69756  zdiv=2.75d0*zmax
69757  IF(mc.EQ.1) THEN
69758  fint=1d0-log(zdiv)
69759  ELSE
69760  zdivc=zdiv**(1d0-fc)
69761  fint=1d0+(1d0-1d0/zdivc)/(fc-1d0)
69762  ENDIF
69763  ELSEIF(zmax.GT.0.85d0.AND.fb.GT.1d0) THEN
69764  mmax=3
69765  fscb=sqrt(4d0+(fc/fb)**2)
69766  zdiv=fscb-1d0/zmax-(fc/fb)*log(zmax*0.5d0*(fscb+fc/fb))
69767  IF(ma.GE.2) zdiv=zdiv+(fa/fb)*log(1d0-zmax)
69768  zdiv=min(zmax,max(0d0,zdiv))
69769  fint=1d0+fb*(1d0-zdiv)
69770  ENDIF
69771 
69772 C...Choice of z, preweighted for peaks at low or high z.
69773  100 z=pyr(0)
69774  fpre=1d0
69775  IF(mmax.EQ.1) THEN
69776  IF(fint*pyr(0).LE.1d0) THEN
69777  z=zdiv*z
69778  ELSEIF(mc.EQ.1) THEN
69779  z=zdiv**z
69780  fpre=zdiv/z
69781  ELSE
69782  z=(zdivc+z*(1d0-zdivc))**(1d0/(1d0-fc))
69783  fpre=(zdiv/z)**fc
69784  ENDIF
69785  ELSEIF(mmax.EQ.3) THEN
69786  IF(fint*pyr(0).LE.1d0) THEN
69787  z=zdiv+log(z)/fb
69788  fpre=exp(fb*(z-zdiv))
69789  ELSE
69790  z=zdiv+z*(1d0-zdiv)
69791  ENDIF
69792  ENDIF
69793 
69794 C...Weighting according to correct formula.
69795  IF(z.LE.0d0.OR.z.GE.1d0) goto 100
69796  fexp=fc*log(zmax/z)+fb*(1d0/zmax-1d0/z)
69797  IF(ma.GE.2) fexp=fexp+fa*log((1d0-z)/(1d0-zmax))
69798  fval=exp(max(-50d0,min(50d0,fexp)))
69799  IF(fval.LT.pyr(0)*fpre) goto 100
69800 
69801 C...Generate z according to Field-Feynman, SLAC, (1-z)**c OR z**c.
69802  ELSE
69803  fc=parj(50+max(1,kflh))
69804  IF(mstj(91).EQ.1) fc=parj(59)
69805  110 z=pyr(0)
69806  IF(fc.GE.0d0.AND.fc.LE.1d0) THEN
69807  IF(fc.GT.pyr(0)) z=1d0-z**(1d0/3d0)
69808  ELSEIF(fc.GT.-1.AND.fc.LT.0d0) THEN
69809  IF(-4d0*fc*z*(1d0-z)**2.LT.pyr(0)*((1d0-z)**2-fc*z)**2)
69810  & goto 110
69811  ELSE
69812  IF(fc.GT.0d0) z=1d0-z**(1d0/fc)
69813  IF(fc.LT.0d0) z=z**(-1d0/fc)
69814  ENDIF
69815  ENDIF
69816 
69817  RETURN
69818  END
69819 
69820 C*********************************************************************
69821 
69822 C...PYSHOW
69823 C...Generates timelike parton showers from given partons.
69824 
69825  SUBROUTINE pyshow(IP1,IP2,QMAX)
69826 
69827 C...Double precision and integer declarations.
69828  IMPLICIT DOUBLE PRECISION(a-h, o-z)
69829  IMPLICIT INTEGER(i-n)
69830  INTEGER pyk,pychge,pycomp
69831 C...Parameter statement to help give large particle numbers.
69832  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
69833  &kexcit=4000000,kdimen=5000000)
69834  parameter(maxnur=1000)
69835 C...Commonblocks.
69836  common/pypart/npart,npartd,ipart(maxnur),ptpart(maxnur)
69837  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
69838  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
69839  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
69840  common/pypars/mstp(200),parp(200),msti(200),pari(200)
69841  common/pyint1/mint(400),vint(400)
69842  SAVE /pypart/,/pyjets/,/pydat1/,/pydat2/,/pypars/,/pyint1/
69843 C...Local arrays.
69844  dimension pmth(5,140),ps(5),pma(100),pmsd(100),iep(100),ipa(100),
69845  &kfla(100),kfld(100),kfl(100),itry(100),isi(100),isl(100),dp(100),
69846  &dpt(5,4),ksh(0:140),kcii(2),niis(2),iiis(2,2),theiis(2,2),
69847  &phiiis(2,2),isii(2),isset(2),iscol(0:140),ischg(0:140),
69848  &iref(1000)
69849 
69850 C...Check that QMAX not too low.
69851  IF(mstj(41).LE.0) THEN
69852  RETURN
69853  ELSEIF(mstj(41).EQ.1.OR.mstj(41).EQ.11) THEN
69854  IF(qmax.LE.parj(82).AND.ip2.GE.-80) RETURN
69855  ELSE
69856  IF(qmax.LE.min(parj(82),parj(83),parj(90)).AND.ip2.GE.-80)
69857  & RETURN
69858  ENDIF
69859 
69860 C...Store positions of shower initiating partons.
69861  mpspd=0
69862  IF(ip1.GT.0.AND.ip1.LE.min(n,mstu(4)-mstu(32)).AND.ip2.EQ.0) THEN
69863  npa=1
69864  ipa(1)=ip1
69865  ELSEIF(min(ip1,ip2).GT.0.AND.max(ip1,ip2).LE.min(n,mstu(4)-
69866  & mstu(32))) THEN
69867  npa=2
69868  ipa(1)=ip1
69869  ipa(2)=ip2
69870  ELSEIF(ip1.GT.0.AND.ip1.LE.min(n,mstu(4)-mstu(32)).AND.ip2.LT.0
69871  & .AND.ip2.GE.-80) THEN
69872  npa=iabs(ip2)
69873  DO 100 i=1,npa
69874  ipa(i)=ip1+i-1
69875  100 CONTINUE
69876  ELSEIF(ip1.GT.0.AND.ip1.LE.min(n,mstu(4)-mstu(32)).AND.
69877  &ip2.EQ.-100) THEN
69878  mpspd=1
69879  npa=2
69880  ipa(1)=ip1+6
69881  ipa(2)=ip1+7
69882  ELSE
69883  CALL pyerrm(12,
69884  & '(PYSHOW:) failed to reconstruct showering system')
69885  IF(mstu(21).GE.1) RETURN
69886  ENDIF
69887 
69888 C...Send off to PYPTFS for pT-ordered evolution if requested,
69889 C...if at least 2 partons, and without predefined shower branchings.
69890  IF((mstj(41).EQ.11.OR.mstj(41).EQ.12).AND.npa.GE.2.AND.
69891  &mpspd.EQ.0) THEN
69892  npart=npa
69893  DO 110 ii=1,npart
69894  ipart(ii)=ipa(ii)
69895  ptpart(ii)=0.5d0*qmax
69896  110 CONTINUE
69897  CALL pyptfs(2,0.5d0*qmax,0d0,ptgen)
69898  RETURN
69899  ENDIF
69900 
69901 C...Initialization of cutoff masses etc.
69902  DO 120 ifl=0,40
69903  iscol(ifl)=0
69904  ischg(ifl)=0
69905  ksh(ifl)=0
69906  120 CONTINUE
69907  iscol(21)=1
69908  ksh(21)=1
69909  pmth(1,21)=pymass(21)
69910  pmth(2,21)=sqrt(pmth(1,21)**2+0.25d0*parj(82)**2)
69911  pmth(3,21)=2d0*pmth(2,21)
69912  pmth(4,21)=pmth(3,21)
69913  pmth(5,21)=pmth(3,21)
69914  pmth(1,22)=pymass(22)
69915  pmth(2,22)=sqrt(pmth(1,22)**2+0.25d0*parj(83)**2)
69916  pmth(3,22)=2d0*pmth(2,22)
69917  pmth(4,22)=pmth(3,22)
69918  pmth(5,22)=pmth(3,22)
69919  pmqth1=parj(82)
69920  IF(mstj(41).GE.2) pmqth1=min(parj(82),parj(83))
69921  pmqt1e=min(pmqth1,parj(90))
69922  pmqth2=pmth(2,21)
69923  IF(mstj(41).GE.2) pmqth2=min(pmth(2,21),pmth(2,22))
69924  pmqt2e=min(pmqth2,0.5d0*parj(90))
69925  DO 130 ifl=1,5
69926  iscol(ifl)=1
69927  IF(mstj(41).GE.2) ischg(ifl)=1
69928  ksh(ifl)=1
69929  pmth(1,ifl)=pymass(ifl)
69930  pmth(2,ifl)=sqrt(pmth(1,ifl)**2+0.25d0*pmqth1**2)
69931  pmth(3,ifl)=pmth(2,ifl)+pmqth2
69932  pmth(4,ifl)=sqrt(pmth(1,ifl)**2+0.25d0*parj(82)**2)+pmth(2,21)
69933  pmth(5,ifl)=sqrt(pmth(1,ifl)**2+0.25d0*parj(83)**2)+pmth(2,22)
69934  130 CONTINUE
69935  DO 140 ifl=11,15,2
69936  IF(mstj(41).EQ.2.OR.mstj(41).GE.4) ischg(ifl)=1
69937  IF(mstj(41).EQ.2.OR.mstj(41).GE.4) ksh(ifl)=1
69938  pmth(1,ifl)=pymass(ifl)
69939  pmth(2,ifl)=sqrt(pmth(1,ifl)**2+0.25d0*parj(90)**2)
69940  pmth(3,ifl)=pmth(2,ifl)+0.5d0*parj(90)
69941  pmth(4,ifl)=pmth(3,ifl)
69942  pmth(5,ifl)=pmth(3,ifl)
69943  140 CONTINUE
69944  pt2min=max(0.5d0*parj(82),1.1d0*parj(81))**2
69945  alams=parj(81)**2
69946  alfm=log(pt2min/alams)
69947 
69948 C...Check on phase space available for emission.
69949  irej=0
69950  DO 150 j=1,5
69951  ps(j)=0d0
69952  150 CONTINUE
69953  pm=0d0
69954  kfla(2)=0
69955  DO 170 i=1,npa
69956  kfla(i)=iabs(k(ipa(i),2))
69957  pma(i)=p(ipa(i),5)
69958 C...Special cutoff masses for initial partons (may be a heavy quark,
69959 C...squark, ..., and need not be on the mass shell).
69960  ir=30+i
69961  IF(npa.LE.1) iref(i)=ir
69962  IF(npa.GE.2) iref(i+1)=ir
69963  iscol(ir)=0
69964  ischg(ir)=0
69965  ksh(ir)=0
69966  IF(kfla(i).LE.8) THEN
69967  iscol(ir)=1
69968  IF(mstj(41).GE.2) ischg(ir)=1
69969  ELSEIF(kfla(i).EQ.11.OR.kfla(i).EQ.13.OR.kfla(i).EQ.15.OR.
69970  & kfla(i).EQ.17) THEN
69971  IF(mstj(41).EQ.2.OR.mstj(41).GE.4) ischg(ir)=1
69972  ELSEIF(kfla(i).EQ.21) THEN
69973  iscol(ir)=1
69974  ELSEIF((kfla(i).GE.ksusy1+1.AND.kfla(i).LE.ksusy1+8).OR.
69975  & (kfla(i).GE.ksusy2+1.AND.kfla(i).LE.ksusy2+8)) THEN
69976  iscol(ir)=1
69977  ELSEIF(kfla(i).EQ.ksusy1+21) THEN
69978  iscol(ir)=1
69979 C...QUARKONIA+++
69980 C...same for QQ~[3S18]
69981  ELSEIF(mstp(148).GE.1.AND.(kfla(i).EQ.9900443.OR.
69982  & kfla(i).EQ.9900553)) THEN
69983  iscol(ir)=1
69984 C...QUARKONIA---
69985  ENDIF
69986 
69987 C...Option to switch off radiation from particle KF = MSTJ(39) entirely
69988 C...(only intended for studying the effects of switching such rad on/off)
69989  IF (mstj(39).GT.0.AND.kfla(i).EQ.mstj(39)) THEN
69990  iscol(ir)=0
69991  ischg(ir)=0
69992  ENDIF
69993 
69994  IF(iscol(ir).EQ.1.OR.ischg(ir).EQ.1) ksh(ir)=1
69995  pmth(1,ir)=pma(i)
69996  IF(iscol(ir).EQ.1.AND.ischg(ir).EQ.1) THEN
69997  pmth(2,ir)=sqrt(pmth(1,ir)**2+0.25d0*pmqth1**2)
69998  pmth(3,ir)=pmth(2,ir)+pmqth2
69999  pmth(4,ir)=sqrt(pmth(1,ir)**2+0.25d0*parj(82)**2)+pmth(2,21)
70000  pmth(5,ir)=sqrt(pmth(1,ir)**2+0.25d0*parj(83)**2)+pmth(2,22)
70001  ELSEIF(iscol(ir).EQ.1) THEN
70002  pmth(2,ir)=sqrt(pmth(1,ir)**2+0.25d0*parj(82)**2)
70003  pmth(3,ir)=pmth(2,ir)+0.5d0*parj(82)
70004  pmth(4,ir)=pmth(3,ir)
70005  pmth(5,ir)=pmth(3,ir)
70006  ELSEIF(ischg(ir).EQ.1) THEN
70007  pmth(2,ir)=sqrt(pmth(1,ir)**2+0.25d0*parj(90)**2)
70008  pmth(3,ir)=pmth(2,ir)+0.5d0*parj(90)
70009  pmth(4,ir)=pmth(3,ir)
70010  pmth(5,ir)=pmth(3,ir)
70011  ENDIF
70012  IF(ksh(ir).EQ.1) pma(i)=pmth(3,ir)
70013  pm=pm+pma(i)
70014  IF(ksh(ir).EQ.0.OR.pma(i).GT.10d0*qmax) irej=irej+1
70015  DO 160 j=1,4
70016  ps(j)=ps(j)+p(ipa(i),j)
70017  160 CONTINUE
70018  170 CONTINUE
70019  IF(irej.EQ.npa.AND.ip2.GE.-7) RETURN
70020  ps(5)=sqrt(max(0d0,ps(4)**2-ps(1)**2-ps(2)**2-ps(3)**2))
70021  IF(npa.EQ.1) ps(5)=ps(4)
70022  IF(ps(5).LE.pm+pmqt1e) RETURN
70023 
70024 C...Identify source: q(1), ~q(2), V(3), S(4), chi(5), ~g(6), unknown(0).
70025  kfsrce=0
70026  IF(ip2.LE.0) THEN
70027  ELSEIF(k(ip1,3).EQ.k(ip2,3).AND.k(ip1,3).GT.0) THEN
70028  kfsrce=iabs(k(k(ip1,3),2))
70029  ELSE
70030  ipar1=max(1,k(ip1,3))
70031  ipar2=max(1,k(ip2,3))
70032  IF(k(ipar1,3).EQ.k(ipar2,3).AND.k(ipar1,3).GT.0)
70033  & kfsrce=iabs(k(k(ipar1,3),2))
70034  ENDIF
70035  itypes=0
70036  IF(kfsrce.GE.1.AND.kfsrce.LE.8) itypes=1
70037  IF(kfsrce.GE.ksusy1+1.AND.kfsrce.LE.ksusy1+8) itypes=2
70038  IF(kfsrce.GE.ksusy2+1.AND.kfsrce.LE.ksusy2+8) itypes=2
70039  IF(kfsrce.GE.21.AND.kfsrce.LE.24) itypes=3
70040  IF(kfsrce.GE.32.AND.kfsrce.LE.34) itypes=3
70041  IF(kfsrce.EQ.25.OR.(kfsrce.GE.35.AND.kfsrce.LE.37)) itypes=4
70042  IF(kfsrce.GE.ksusy1+22.AND.kfsrce.LE.ksusy1+37) itypes=5
70043  IF(kfsrce.EQ.ksusy1+21) itypes=6
70044 
70045 C...Identify two primary showerers.
70046  itype1=0
70047  IF(kfla(1).GE.1.AND.kfla(1).LE.8) itype1=1
70048  IF(kfla(1).GE.ksusy1+1.AND.kfla(1).LE.ksusy1+8) itype1=2
70049  IF(kfla(1).GE.ksusy2+1.AND.kfla(1).LE.ksusy2+8) itype1=2
70050  IF(kfla(1).GE.21.AND.kfla(1).LE.24) itype1=3
70051  IF(kfla(1).GE.32.AND.kfla(1).LE.34) itype1=3
70052  IF(kfla(1).EQ.25.OR.(kfla(1).GE.35.AND.kfla(1).LE.37)) itype1=4
70053  IF(kfla(1).GE.ksusy1+22.AND.kfla(1).LE.ksusy1+37) itype1=5
70054  IF(kfla(1).EQ.ksusy1+21) itype1=6
70055  itype2=0
70056  IF(kfla(2).GE.1.AND.kfla(2).LE.8) itype2=1
70057  IF(kfla(2).GE.ksusy1+1.AND.kfla(2).LE.ksusy1+8) itype2=2
70058  IF(kfla(2).GE.ksusy2+1.AND.kfla(2).LE.ksusy2+8) itype2=2
70059  IF(kfla(2).GE.21.AND.kfla(2).LE.24) itype2=3
70060  IF(kfla(2).GE.32.AND.kfla(2).LE.34) itype2=3
70061  IF(kfla(2).EQ.25.OR.(kfla(2).GE.35.AND.kfla(2).LE.37)) itype2=4
70062  IF(kfla(2).GE.ksusy1+22.AND.kfla(2).LE.ksusy1+37) itype2=5
70063  IF(kfla(2).EQ.ksusy1+21) itype2=6
70064 
70065 C...Order of showerers. Presence of gluino.
70066  itypmn=min(itype1,itype2)
70067  itypmx=max(itype1,itype2)
70068  iord=1
70069  IF(itype1.GT.itype2) iord=2
70070  iglui=0
70071  IF(itype1.EQ.6.OR.itype2.EQ.6) iglui=1
70072 
70073 C...Check if 3-jet matrix elements to be used.
70074  m3jc=0
70075  alpha=0.5d0
70076  IF(npa.EQ.2.AND.mstj(47).GE.1.AND.mpspd.EQ.0) THEN
70077  IF(mstj(38).NE.0) THEN
70078  m3jc=mstj(38)
70079  alpha=parj(80)
70080  mstj(38)=0
70081  ELSEIF(mstj(47).GE.6) THEN
70082  m3jc=mstj(47)
70083  ELSE
70084  iclass=1
70085  icombi=4
70086 
70087 C...Vector/axial vector -> q + qbar; q -> q + V.
70088  IF(itypmn.EQ.1.AND.itypmx.EQ.1.AND.(itypes.EQ.0.OR.
70089  & itypes.EQ.3)) THEN
70090  iclass=2
70091  IF(kfsrce.EQ.21.OR.kfsrce.EQ.22) THEN
70092  icombi=1
70093  ELSEIF(kfsrce.EQ.23.OR.(kfsrce.EQ.0.AND.
70094  & k(ipa(1),2)+k(ipa(2),2).EQ.0)) THEN
70095 C...gamma*/Z0: assume e+e- initial state if unknown.
70096  ei=-1d0
70097  IF(kfsrce.EQ.23) THEN
70098  iannfl=k(k(ip1,3),3)
70099  IF(iannfl.NE.0) THEN
70100  kannfl=iabs(k(iannfl,2))
70101  IF(kannfl.GE.1.AND.kannfl.LE.18) ei=kchg(kannfl,1)/3d0
70102  ENDIF
70103  ENDIF
70104  ai=sign(1d0,ei+0.1d0)
70105  vi=ai-4d0*ei*paru(102)
70106  ef=kchg(kfla(1),1)/3d0
70107  af=sign(1d0,ef+0.1d0)
70108  vf=af-4d0*ef*paru(102)
70109  xwc=1d0/(16d0*paru(102)*(1d0-paru(102)))
70110  sh=ps(5)**2
70111  sqmz=pmas(23,1)**2
70112  sqwz=ps(5)*pmas(23,2)
70113  sbwz=1d0/((sh-sqmz)**2+sqwz**2)
70114  vect=ei**2*ef**2+2d0*ei*vi*ef*vf*xwc*sh*(sh-sqmz)*sbwz+
70115  & (vi**2+ai**2)*vf**2*xwc**2*sh**2*sbwz
70116  axiv=(vi**2+ai**2)*af**2*xwc**2*sh**2*sbwz
70117  icombi=3
70118  alpha=vect/(vect+axiv)
70119  ELSEIF(kfsrce.EQ.24.OR.kfsrce.EQ.0) THEN
70120  icombi=4
70121  ENDIF
70122 C...For chi -> chi q qbar, use V/A -> q qbar as first approximation.
70123  ELSEIF(itypmn.EQ.1.AND.itypmx.EQ.1.AND.itypes.EQ.5) THEN
70124  iclass=2
70125  ELSEIF(itypmn.EQ.1.AND.itypmx.EQ.3.AND.(itypes.EQ.0.OR.
70126  & itypes.EQ.1)) THEN
70127  iclass=3
70128 
70129 C...Scalar/pseudoscalar -> q + qbar; q -> q + S.
70130  ELSEIF(itypmn.EQ.1.AND.itypmx.EQ.1.AND.itypes.EQ.4) THEN
70131  iclass=4
70132  IF(kfsrce.EQ.25.OR.kfsrce.EQ.35.OR.kfsrce.EQ.37) THEN
70133  icombi=1
70134  ELSEIF(kfsrce.EQ.36) THEN
70135  icombi=2
70136  ENDIF
70137  ELSEIF(itypmn.EQ.1.AND.itypmx.EQ.4.AND.(itypes.EQ.0.OR.
70138  & itypes.EQ.1)) THEN
70139  iclass=5
70140 
70141 C...V -> ~q + ~qbar; ~q -> ~q + V; S -> ~q + ~qbar; ~q -> ~q + S.
70142  ELSEIF(itypmn.EQ.2.AND.itypmx.EQ.2.AND.(itypes.EQ.0.OR.
70143  & itypes.EQ.3)) THEN
70144  iclass=6
70145  ELSEIF(itypmn.EQ.2.AND.itypmx.EQ.3.AND.(itypes.EQ.0.OR.
70146  & itypes.EQ.2)) THEN
70147  iclass=7
70148  ELSEIF(itypmn.EQ.2.AND.itypmx.EQ.2.AND.itypes.EQ.4) THEN
70149  iclass=8
70150  ELSEIF(itypmn.EQ.2.AND.itypmx.EQ.4.AND.(itypes.EQ.0.OR.
70151  & itypes.EQ.2)) THEN
70152  iclass=9
70153 
70154 C...chi -> q + ~qbar; ~q -> q + chi; q -> ~q + chi.
70155  ELSEIF(itypmn.EQ.1.AND.itypmx.EQ.2.AND.(itypes.EQ.0.OR.
70156  & itypes.EQ.5)) THEN
70157  iclass=10
70158  ELSEIF(itypmn.EQ.1.AND.itypmx.EQ.5.AND.(itypes.EQ.0.OR.
70159  & itypes.EQ.2)) THEN
70160  iclass=11
70161  ELSEIF(itypmn.EQ.2.AND.itypmx.EQ.5.AND.(itypes.EQ.0.OR.
70162  & itypes.EQ.1)) THEN
70163  iclass=12
70164 
70165 C...~g -> q + ~qbar; ~q -> q + ~g; q -> ~q + ~g.
70166  ELSEIF(itypmn.EQ.1.AND.itypmx.EQ.2.AND.itypes.EQ.6) THEN
70167  iclass=13
70168  ELSEIF(itypmn.EQ.1.AND.itypmx.EQ.6.AND.(itypes.EQ.0.OR.
70169  & itypes.EQ.2)) THEN
70170  iclass=14
70171  ELSEIF(itypmn.EQ.2.AND.itypmx.EQ.6.AND.(itypes.EQ.0.OR.
70172  & itypes.EQ.1)) THEN
70173  iclass=15
70174 
70175 C...g -> ~g + ~g (eikonal approximation).
70176  ELSEIF(itypmn.EQ.6.AND.itypmx.EQ.6.AND.itypes.EQ.0) THEN
70177  iclass=16
70178  ENDIF
70179  m3jc=5*iclass+icombi
70180  ENDIF
70181  ENDIF
70182 
70183 C...Find if interference with initial state partons.
70184  miis=0
70185  IF(mstj(50).GE.1.AND.mstj(50).LE.3.AND.npa.EQ.2.AND.kfsrce.EQ.0
70186  &.AND.mpspd.EQ.0) miis=mstj(50)
70187  IF(mstj(50).GE.4.AND.mstj(50).LE.6.AND.npa.EQ.2.AND.mpspd.EQ.0)
70188  &miis=mstj(50)-3
70189  IF(miis.NE.0) THEN
70190  DO 190 i=1,2
70191  kcii(i)=0
70192  kca=pycomp(kfla(i))
70193  IF(kca.NE.0) kcii(i)=kchg(kca,2)*isign(1,k(ipa(i),2))
70194  niis(i)=0
70195  IF(kcii(i).NE.0) THEN
70196  DO 180 j=1,2
70197  icsi=mod(k(ipa(i),3+j)/mstu(5),mstu(5))
70198  IF(icsi.GT.0.AND.icsi.NE.ipa(1).AND.icsi.NE.ipa(2).AND.
70199  & (kcii(i).EQ.(-1)**(j+1).OR.kcii(i).EQ.2)) THEN
70200  niis(i)=niis(i)+1
70201  iiis(i,niis(i))=icsi
70202  ENDIF
70203  180 CONTINUE
70204  ENDIF
70205  190 CONTINUE
70206  IF(niis(1)+niis(2).EQ.0) miis=0
70207  ENDIF
70208 
70209 C...Boost interfering initial partons to rest frame
70210 C...and reconstruct their polar and azimuthal angles.
70211  IF(miis.NE.0) THEN
70212  DO 210 i=1,2
70213  DO 200 j=1,5
70214  k(n+i,j)=k(ipa(i),j)
70215  p(n+i,j)=p(ipa(i),j)
70216  v(n+i,j)=0d0
70217  200 CONTINUE
70218  210 CONTINUE
70219  DO 230 i=3,2+niis(1)
70220  DO 220 j=1,5
70221  k(n+i,j)=k(iiis(1,i-2),j)
70222  p(n+i,j)=p(iiis(1,i-2),j)
70223  v(n+i,j)=0d0
70224  220 CONTINUE
70225  230 CONTINUE
70226  DO 250 i=3+niis(1),2+niis(1)+niis(2)
70227  DO 240 j=1,5
70228  k(n+i,j)=k(iiis(2,i-2-niis(1)),j)
70229  p(n+i,j)=p(iiis(2,i-2-niis(1)),j)
70230  v(n+i,j)=0d0
70231  240 CONTINUE
70232  250 CONTINUE
70233  CALL pyrobo(n+1,n+2+niis(1)+niis(2),0d0,0d0,-ps(1)/ps(4),
70234  & -ps(2)/ps(4),-ps(3)/ps(4))
70235  phi=pyangl(p(n+1,1),p(n+1,2))
70236  CALL pyrobo(n+1,n+2+niis(1)+niis(2),0d0,-phi,0d0,0d0,0d0)
70237  the=pyangl(p(n+1,3),p(n+1,1))
70238  CALL pyrobo(n+1,n+2+niis(1)+niis(2),-the,0d0,0d0,0d0,0d0)
70239  DO 260 i=3,2+niis(1)
70240  theiis(1,i-2)=pyangl(p(n+i,3),sqrt(p(n+i,1)**2+p(n+i,2)**2))
70241  phiiis(1,i-2)=pyangl(p(n+i,1),p(n+i,2))
70242  260 CONTINUE
70243  DO 270 i=3+niis(1),2+niis(1)+niis(2)
70244  theiis(2,i-2-niis(1))=paru(1)-pyangl(p(n+i,3),
70245  & sqrt(p(n+i,1)**2+p(n+i,2)**2))
70246  phiiis(2,i-2-niis(1))=pyangl(p(n+i,1),p(n+i,2))
70247  270 CONTINUE
70248  ENDIF
70249 
70250 C...Boost 3 or more partons to their rest frame.
70251  IF(npa.GE.3) CALL pyrobo(ipa(1),ipa(npa),0d0,0d0,-ps(1)/ps(4),
70252  &-ps(2)/ps(4),-ps(3)/ps(4))
70253 
70254 C...Define imagined single initiator of shower for parton system.
70255  ns=n
70256  IF(n.GT.mstu(4)-mstu(32)-10) THEN
70257  CALL pyerrm(11,'(PYSHOW:) no more memory left in PYJETS')
70258  IF(mstu(21).GE.1) RETURN
70259  ENDIF
70260  280 n=ns
70261  IF(npa.GE.2) THEN
70262  k(n+1,1)=11
70263  k(n+1,2)=21
70264  k(n+1,3)=0
70265  k(n+1,4)=0
70266  k(n+1,5)=0
70267  p(n+1,1)=0d0
70268  p(n+1,2)=0d0
70269  p(n+1,3)=0d0
70270  p(n+1,4)=ps(5)
70271  p(n+1,5)=ps(5)
70272  v(n+1,5)=ps(5)**2
70273  n=n+1
70274  iref(1)=21
70275  ENDIF
70276 
70277 C...Loop over partons that may branch.
70278  nep=npa
70279  im=ns
70280  IF(npa.EQ.1) im=ns-1
70281  290 im=im+1
70282  IF(n.GT.ns) THEN
70283  IF(im.GT.n) goto 600
70284  kflm=iabs(k(im,2))
70285  ir=iref(im-ns)
70286  IF(ksh(ir).EQ.0) goto 290
70287  IF(p(im,5).LT.pmth(2,ir)) goto 290
70288  igm=k(im,3)
70289  ELSE
70290  igm=-1
70291  ENDIF
70292  IF(n+nep.GT.mstu(4)-mstu(32)-10) THEN
70293  CALL pyerrm(11,'(PYSHOW:) no more memory left in PYJETS')
70294  IF(mstu(21).GE.1) RETURN
70295  ENDIF
70296 
70297 C...Position of aunt (sister to branching parton).
70298 C...Origin and flavour of daughters.
70299  iau=0
70300  IF(igm.GT.0) THEN
70301  IF(k(im-1,3).EQ.igm) iau=im-1
70302  IF(n.GE.im+1.AND.k(im+1,3).EQ.igm) iau=im+1
70303  ENDIF
70304  IF(igm.GE.0) THEN
70305  k(im,4)=n+1
70306  DO 300 i=1,nep
70307  k(n+i,3)=im
70308  300 CONTINUE
70309  ELSE
70310  k(n+1,3)=ipa(1)
70311  ENDIF
70312  IF(igm.LE.0) THEN
70313  DO 310 i=1,nep
70314  k(n+i,2)=k(ipa(i),2)
70315  310 CONTINUE
70316  ELSEIF(kflm.NE.21) THEN
70317  k(n+1,2)=k(im,2)
70318  k(n+2,2)=k(im,5)
70319  iref(n+1-ns)=iref(im-ns)
70320  iref(n+2-ns)=iabs(k(n+2,2))
70321  ELSEIF(k(im,5).EQ.21) THEN
70322  k(n+1,2)=21
70323  k(n+2,2)=21
70324  iref(n+1-ns)=21
70325  iref(n+2-ns)=21
70326  ELSE
70327  k(n+1,2)=k(im,5)
70328  k(n+2,2)=-k(im,5)
70329  iref(n+1-ns)=iabs(k(n+1,2))
70330  iref(n+2-ns)=iabs(k(n+2,2))
70331  ENDIF
70332 
70333 C...Reset flags on daughters and tries made.
70334  DO 320 ip=1,nep
70335  k(n+ip,1)=3
70336  k(n+ip,4)=0
70337  k(n+ip,5)=0
70338  kfld(ip)=iabs(k(n+ip,2))
70339  IF(kchg(pycomp(kfld(ip)),2).EQ.0) k(n+ip,1)=1
70340  itry(ip)=0
70341  isl(ip)=0
70342  isi(ip)=0
70343  IF(ksh(iref(n+ip-ns)).EQ.1) isi(ip)=1
70344  320 CONTINUE
70345  islm=0
70346 
70347 C...Maximum virtuality of daughters.
70348  IF(igm.LE.0) THEN
70349  DO 330 i=1,npa
70350  IF(npa.GE.3) p(n+i,4)=p(ipa(i),4)
70351  p(n+i,5)=min(qmax,ps(5))
70352  ir=iref(n+i-ns)
70353  IF(ip2.LE.-8) p(n+i,5)=max(p(n+i,5),2d0*pmth(3,ir))
70354  IF(isi(i).EQ.0) p(n+i,5)=p(ipa(i),5)
70355  330 CONTINUE
70356  ELSE
70357  IF(mstj(43).LE.2) pem=v(im,2)
70358  IF(mstj(43).GE.3) pem=p(im,4)
70359  p(n+1,5)=min(p(im,5),v(im,1)*pem)
70360  p(n+2,5)=min(p(im,5),(1d0-v(im,1))*pem)
70361  IF(k(n+2,2).EQ.22) p(n+2,5)=pmth(1,22)
70362  ENDIF
70363  DO 340 i=1,nep
70364  pmsd(i)=p(n+i,5)
70365  IF(isi(i).EQ.1) THEN
70366  ir=iref(n+i-ns)
70367  IF(p(n+i,5).LE.pmth(3,ir)) p(n+i,5)=pmth(1,ir)
70368  ENDIF
70369  v(n+i,5)=p(n+i,5)**2
70370  340 CONTINUE
70371 
70372 C...Choose one of the daughters for evolution.
70373  350 inum=0
70374  IF(nep.EQ.1) inum=1
70375  DO 360 i=1,nep
70376  IF(inum.EQ.0.AND.isl(i).EQ.1) inum=i
70377  360 CONTINUE
70378  DO 370 i=1,nep
70379  IF(inum.EQ.0.AND.itry(i).EQ.0.AND.isi(i).EQ.1) THEN
70380  ir=iref(n+i-ns)
70381  IF(p(n+i,5).GE.pmth(2,ir)) inum=i
70382  ENDIF
70383  370 CONTINUE
70384  IF(inum.EQ.0) THEN
70385  rmax=0d0
70386  DO 380 i=1,nep
70387  IF(isi(i).EQ.1.AND.pmsd(i).GE.pmqt2e) THEN
70388  rpm=p(n+i,5)/pmsd(i)
70389  ir=iref(n+i-ns)
70390  IF(rpm.GT.rmax.AND.p(n+i,5).GE.pmth(2,ir)) THEN
70391  rmax=rpm
70392  inum=i
70393  ENDIF
70394  ENDIF
70395  380 CONTINUE
70396  ENDIF
70397 
70398 C...Cancel choice of predetermined daughter already treated.
70399  inum=max(1,inum)
70400  inumt=inum
70401  IF(mpspd.EQ.1.AND.igm.EQ.0.AND.itry(inumt).GE.1) THEN
70402  IF(k(ip1-1+inum,4).GT.0) inum=3-inum
70403  ELSEIF(mpspd.EQ.1.AND.im.EQ.ns+2.AND.itry(inumt).GE.1) THEN
70404  IF(kfld(inumt).NE.21.AND.k(ip1+2,4).GT.0) inum=3-inum
70405  IF(kfld(inumt).EQ.21.AND.k(ip1+3,4).GT.0) inum=3-inum
70406  ENDIF
70407 
70408 C...Store information on choice of evolving daughter.
70409  iep(1)=n+inum
70410  DO 390 i=2,nep
70411  iep(i)=iep(i-1)+1
70412  IF(iep(i).GT.n+nep) iep(i)=n+1
70413  390 CONTINUE
70414  DO 400 i=1,nep
70415  kfl(i)=iabs(k(iep(i),2))
70416  400 CONTINUE
70417  itry(inum)=itry(inum)+1
70418  IF(itry(inum).GT.200) THEN
70419  CALL pyerrm(14,'(PYSHOW:) caught in infinite loop')
70420  IF(mstu(21).GE.1) RETURN
70421  ENDIF
70422  z=0.5d0
70423  ir=iref(iep(1)-ns)
70424  IF(ksh(ir).EQ.0) goto 450
70425  IF(p(iep(1),5).LT.pmth(2,ir)) goto 450
70426 
70427 C...Check if evolution already predetermined for daughter.
70428  ipspd=0
70429  IF(mpspd.EQ.1.AND.igm.EQ.0) THEN
70430  IF(k(ip1-1+inum,4).GT.0) ipspd=ip1-1+inum
70431  ELSEIF(mpspd.EQ.1.AND.im.EQ.ns+2) THEN
70432  IF(kfl(1).NE.21.AND.k(ip1+2,4).GT.0) ipspd=ip1+2
70433  IF(kfl(1).EQ.21.AND.k(ip1+3,4).GT.0) ipspd=ip1+3
70434  ENDIF
70435  IF(inum.EQ.1.OR.inum.EQ.2) THEN
70436  isset(inum)=0
70437  IF(ipspd.NE.0) isset(inum)=1
70438  ENDIF
70439 
70440 C...Select side for interference with initial state partons.
70441  IF(miis.GE.1.AND.iep(1).LE.ns+3) THEN
70442  iii=iep(1)-ns-1
70443  isii(iii)=0
70444  IF(iabs(kcii(iii)).EQ.1.AND.niis(iii).EQ.1) THEN
70445  isii(iii)=1
70446  ELSEIF(kcii(iii).EQ.2.AND.niis(iii).EQ.1) THEN
70447  IF(pyr(0).GT.0.5d0) isii(iii)=1
70448  ELSEIF(kcii(iii).EQ.2.AND.niis(iii).EQ.2) THEN
70449  isii(iii)=1
70450  IF(pyr(0).GT.0.5d0) isii(iii)=2
70451  ENDIF
70452  ENDIF
70453 
70454 C...Calculate allowed z range.
70455  IF(nep.EQ.1) THEN
70456  pmed=ps(4)
70457  ELSEIF(igm.EQ.0.OR.mstj(43).LE.2) THEN
70458  pmed=p(im,5)
70459  ELSE
70460  IF(inum.EQ.1) pmed=v(im,1)*pem
70461  IF(inum.EQ.2) pmed=(1d0-v(im,1))*pem
70462  ENDIF
70463  IF(mod(mstj(43),2).EQ.1) THEN
70464  zc=pmth(2,21)/pmed
70465  zce=pmth(2,22)/pmed
70466  IF(iscol(ir).EQ.0) zce=0.5d0*parj(90)/pmed
70467  ELSE
70468  zc=0.5d0*(1d0-sqrt(max(0d0,1d0-(2d0*pmth(2,21)/pmed)**2)))
70469  IF(zc.LT.1d-6) zc=(pmth(2,21)/pmed)**2
70470  pmtmpe=pmth(2,22)
70471  IF(iscol(ir).EQ.0) pmtmpe=0.5d0*parj(90)
70472  zce=0.5d0*(1d0-sqrt(max(0d0,1d0-(2d0*pmtmpe/pmed)**2)))
70473  IF(zce.LT.1d-6) zce=(pmtmpe/pmed)**2
70474  ENDIF
70475  zc=min(zc,0.491d0)
70476  zce=min(zce,0.49991d0)
70477  IF(((mstj(41).EQ.1.AND.zc.GT.0.49d0).OR.(mstj(41).GE.2.AND.
70478  &min(zc,zce).GT.0.4999d0)).AND.ipspd.EQ.0) THEN
70479  p(iep(1),5)=pmth(1,ir)
70480  v(iep(1),5)=p(iep(1),5)**2
70481  goto 450
70482  ENDIF
70483 
70484 C...Integral of Altarelli-Parisi z kernel for QCD.
70485 C...(Includes squark and gluino; with factor N_C/C_F extra for latter).
70486  IF(mstj(49).EQ.0.AND.kfl(1).EQ.21) THEN
70487  fbr=6d0*log((1d0-zc)/zc)+mstj(45)*0.5d0
70488 C...QUARKONIA+++
70489 C...Evolution of QQ~[3S18] state if MSTP(148)=1.
70490  ELSEIF(mstj(49).EQ.0.AND.mstp(149).GE.0.AND.
70491  & (kfl(1).EQ.9900443.OR.kfl(1).EQ.9900553)) THEN
70492  fbr=6d0*log((1d0-zc)/zc)
70493 C...QUARKONIA---
70494  ELSEIF(mstj(49).EQ.0) THEN
70495  fbr=(8d0/3d0)*log((1d0-zc)/zc)
70496  IF(iglui.EQ.1.AND.ir.GE.31) fbr=fbr*(9d0/4d0)
70497 
70498 C...Integral of Altarelli-Parisi z kernel for scalar gluon.
70499  ELSEIF(mstj(49).EQ.1.AND.kfl(1).EQ.21) THEN
70500  fbr=(parj(87)+mstj(45)*parj(88))*(1d0-2d0*zc)
70501  ELSEIF(mstj(49).EQ.1) THEN
70502  fbr=(1d0-2d0*zc)/3d0
70503  IF(igm.EQ.0.AND.m3jc.GE.1) fbr=4d0*fbr
70504 
70505 C...Integral of Altarelli-Parisi z kernel for Abelian vector gluon.
70506  ELSEIF(kfl(1).EQ.21) THEN
70507  fbr=6d0*mstj(45)*(0.5d0-zc)
70508  ELSE
70509  fbr=2d0*log((1d0-zc)/zc)
70510  ENDIF
70511 
70512 C...Reset QCD probability for colourless.
70513  IF(iscol(ir).EQ.0) fbr=0d0
70514 
70515 C...Integral of Altarelli-Parisi kernel for photon emission.
70516  fbre=0d0
70517  IF(mstj(41).GE.2.AND.ischg(ir).EQ.1) THEN
70518  IF(kfl(1).LE.18) THEN
70519  fbre=(kchg(kfl(1),1)/3d0)**2*2d0*log((1d0-zce)/zce)
70520  ENDIF
70521  IF(mstj(41).EQ.10) fbre=parj(84)*fbre
70522  ENDIF
70523 
70524 C...Inner veto algorithm starts. Find maximum mass for evolution.
70525  410 pms=v(iep(1),5)
70526  IF(igm.GE.0) THEN
70527  pm2=0d0
70528  DO 420 i=2,nep
70529  pm=p(iep(i),5)
70530  iri=iref(iep(i)-ns)
70531  IF(ksh(iri).EQ.1) pm=pmth(2,iri)
70532  pm2=pm2+pm
70533  420 CONTINUE
70534  pms=min(pms,(p(im,5)-pm2)**2)
70535  ENDIF
70536 
70537 C...Select mass for daughter in QCD evolution.
70538  b0=27d0/6d0
70539  DO 430 iff=4,mstj(45)
70540  IF(pms.GT.4d0*pmth(2,iff)**2) b0=(33d0-2d0*iff)/6d0
70541  430 CONTINUE
70542 C...Shift m^2 for evolution in Q^2 = m^2 - m(onshell)^2.
70543  pmsc=max(0.5d0*parj(82),pms-pmth(1,ir)**2)
70544 C...Already predetermined choice.
70545  IF(ipspd.NE.0) THEN
70546  pmsqcd=p(ipspd,5)**2
70547  ELSEIF(fbr.LT.1d-3) THEN
70548  pmsqcd=0d0
70549  ELSEIF(mstj(44).LE.0) THEN
70550  pmsqcd=pmsc*exp(max(-50d0,log(pyr(0))*paru(2)/(paru(111)*fbr)))
70551  ELSEIF(mstj(44).EQ.1) THEN
70552  pmsqcd=4d0*alams*(0.25d0*pmsc/alams)**(pyr(0)**(b0/fbr))
70553  ELSE
70554  pmsqcd=pmsc*exp(max(-50d0,alfm*b0*log(pyr(0))/fbr))
70555  ENDIF
70556 C...Shift back m^2 from evolution in Q^2 = m^2 - m(onshell)^2.
70557  IF(ipspd.EQ.0) pmsqcd=pmsqcd+pmth(1,ir)**2
70558  IF(zc.GT.0.49d0.OR.pmsqcd.LE.pmth(4,ir)**2) pmsqcd=pmth(2,ir)**2
70559  v(iep(1),5)=pmsqcd
70560  mce=1
70561 
70562 C...Select mass for daughter in QED evolution.
70563  IF(mstj(41).GE.2.AND.ischg(ir).EQ.1.AND.ipspd.EQ.0) THEN
70564 C...Shift m^2 for evolution in Q^2 = m^2 - m(onshell)^2.
70565  pmse=max(0.5d0*parj(83),pms-pmth(1,ir)**2)
70566  IF(fbre.LT.1d-3) THEN
70567  pmsqed=0d0
70568  ELSE
70569  pmsqed=pmse*exp(max(-50d0,log(pyr(0))*paru(2)/
70570  & (paru(101)*fbre)))
70571  ENDIF
70572 C...Shift back m^2 from evolution in Q^2 = m^2 - m(onshell)^2.
70573  pmsqed=pmsqed+pmth(1,ir)**2
70574  IF(zce.GT.0.4999d0.OR.pmsqed.LE.pmth(5,ir)**2) pmsqed=
70575  & pmth(2,ir)**2
70576  IF(pmsqed.GT.pmsqcd) THEN
70577  v(iep(1),5)=pmsqed
70578  mce=2
70579  ENDIF
70580  ENDIF
70581 
70582 C...Check whether daughter mass below cutoff.
70583  p(iep(1),5)=sqrt(v(iep(1),5))
70584  IF(p(iep(1),5).LE.pmth(3,ir)) THEN
70585  p(iep(1),5)=pmth(1,ir)
70586  v(iep(1),5)=p(iep(1),5)**2
70587  goto 450
70588  ENDIF
70589 
70590 C...Already predetermined choice of z, and flavour in g -> qqbar.
70591  IF(ipspd.NE.0) THEN
70592  ipsgd1=k(ipspd,4)
70593  ipsgd2=k(ipspd,5)
70594  pmsgd1=p(ipsgd1,5)**2
70595  pmsgd2=p(ipsgd2,5)**2
70596  alamps=sqrt(max(1d-10,(pmsqcd-pmsgd1-pmsgd2)**2-
70597  & 4d0*pmsgd1*pmsgd2))
70598  z=0.5d0*(pmsqcd*(2d0*p(ipsgd1,4)/p(ipspd,4)-1d0)+alamps-
70599  & pmsgd1+pmsgd2)/alamps
70600  z=max(0.00001d0,min(0.99999d0,z))
70601  IF(kfl(1).NE.21) THEN
70602  k(iep(1),5)=21
70603  ELSE
70604  k(iep(1),5)=iabs(k(ipsgd1,2))
70605  ENDIF
70606 
70607 C...Select z value of branching: q -> qgamma.
70608  ELSEIF(mce.EQ.2) THEN
70609  z=1d0-(1d0-zce)*(zce/(1d0-zce))**pyr(0)
70610  IF(1d0+z**2.LT.2d0*pyr(0)) goto 410
70611  k(iep(1),5)=22
70612 
70613 C...QUARKONIA+++
70614 C...Select z value of branching: QQ~[3S18] -> QQ~[3S18]g.
70615  ELSEIF(mstj(49).EQ.0.AND.
70616  & (kfl(1).EQ.9900443.OR.kfl(1).EQ.9900553)) THEN
70617  z=(1d0-zc)*(zc/(1d0-zc))**pyr(0)
70618 C...Select always the harder 'gluon' if the switch MSTP(149)<=0.
70619  IF(mstp(149).LE.0.OR.pyr(0).GT.0.5d0) z=1d0-z
70620  IF((1d0-z*(1d0-z))**2.LT.pyr(0)) goto 410
70621  k(iep(1),5)=21
70622 C...QUARKONIA---
70623 
70624 C...Select z value of branching: q -> qg, g -> gg, g -> qqbar.
70625  ELSEIF(mstj(49).NE.1.AND.kfl(1).NE.21) THEN
70626  z=1d0-(1d0-zc)*(zc/(1d0-zc))**pyr(0)
70627 C...Only do z weighting when no ME correction afterwards.
70628  IF(m3jc.EQ.0.AND.1d0+z**2.LT.2d0*pyr(0)) goto 410
70629  k(iep(1),5)=21
70630  ELSEIF(mstj(49).EQ.0.AND.mstj(45)*0.5d0.LT.pyr(0)*fbr) THEN
70631  z=(1d0-zc)*(zc/(1d0-zc))**pyr(0)
70632  IF(pyr(0).GT.0.5d0) z=1d0-z
70633  IF((1d0-z*(1d0-z))**2.LT.pyr(0)) goto 410
70634  k(iep(1),5)=21
70635  ELSEIF(mstj(49).NE.1) THEN
70636  z=pyr(0)
70637  IF(z**2+(1d0-z)**2.LT.pyr(0)) goto 410
70638  kflb=1+int(mstj(45)*pyr(0))
70639  pmq=4d0*pmth(2,kflb)**2/v(iep(1),5)
70640  IF(pmq.GE.1d0) goto 410
70641  IF(mstj(44).LE.2.OR.mstj(44).EQ.4) THEN
70642  IF(z.LT.zc.OR.z.GT.1d0-zc) goto 410
70643  pmq0=4d0*pmth(2,21)**2/v(iep(1),5)
70644  IF(mod(mstj(43),2).EQ.0.AND.(1d0+0.5d0*pmq)*sqrt(1d0-pmq)
70645  & .LT.pyr(0)*(1d0+0.5d0*pmq0)*sqrt(1d0-pmq0)) goto 410
70646  ELSE
70647  IF((1d0+0.5d0*pmq)*sqrt(1d0-pmq).LT.pyr(0)) goto 410
70648  ENDIF
70649  k(iep(1),5)=kflb
70650 
70651 C...Ditto for scalar gluon model.
70652  ELSEIF(kfl(1).NE.21) THEN
70653  z=1d0-sqrt(zc**2+pyr(0)*(1d0-2d0*zc))
70654  k(iep(1),5)=21
70655  ELSEIF(pyr(0)*(parj(87)+mstj(45)*parj(88)).LE.parj(87)) THEN
70656  z=zc+(1d0-2d0*zc)*pyr(0)
70657  k(iep(1),5)=21
70658  ELSE
70659  z=zc+(1d0-2d0*zc)*pyr(0)
70660  kflb=1+int(mstj(45)*pyr(0))
70661  pmq=4d0*pmth(2,kflb)**2/v(iep(1),5)
70662  IF(pmq.GE.1d0) goto 410
70663  k(iep(1),5)=kflb
70664  ENDIF
70665 
70666 C...Correct to alpha_s(pT^2) (optionally m^2/4 for g -> q qbar).
70667  IF(mce.EQ.1.AND.mstj(44).GE.2.AND.ipspd.EQ.0) THEN
70668  IF(kfl(1).EQ.21.AND.k(iep(1),5).LT.10.AND.
70669  & (mstj(44).EQ.3.OR.mstj(44).EQ.5)) THEN
70670  IF(alfm/log(v(iep(1),5)*0.25d0/alams).LT.pyr(0)) goto 410
70671  ELSE
70672  pt2app=z*(1d0-z)*v(iep(1),5)
70673  IF(mstj(44).GE.4) pt2app=pt2app*
70674  & (1d0-pmth(1,ir)**2/v(iep(1),5))**2
70675  IF(pt2app.LT.pt2min) goto 410
70676  IF(alfm/log(pt2app/alams).LT.pyr(0)) goto 410
70677  ENDIF
70678  ENDIF
70679 
70680 C...Check if z consistent with chosen m.
70681  IF(kfl(1).EQ.21) THEN
70682  irgd1=iabs(k(iep(1),5))
70683  irgd2=irgd1
70684  ELSE
70685  irgd1=ir
70686  irgd2=iabs(k(iep(1),5))
70687  ENDIF
70688  IF(nep.EQ.1) THEN
70689  ped=ps(4)
70690  ELSEIF(nep.GE.3) THEN
70691  ped=p(iep(1),4)
70692  ELSEIF(igm.EQ.0.OR.mstj(43).LE.2) THEN
70693  ped=0.5d0*(v(im,5)+v(iep(1),5)-pm2**2)/p(im,5)
70694  ELSE
70695  IF(iep(1).EQ.n+1) ped=v(im,1)*pem
70696  IF(iep(1).EQ.n+2) ped=(1d0-v(im,1))*pem
70697  ENDIF
70698  IF(mod(mstj(43),2).EQ.1) THEN
70699  pmqth3=0.5d0*parj(82)
70700  IF(irgd2.EQ.22) pmqth3=0.5d0*parj(83)
70701  IF(irgd2.EQ.22.AND.iscol(ir).EQ.0) pmqth3=0.5d0*parj(90)
70702  pmq1=(pmth(1,irgd1)**2+pmqth3**2)/v(iep(1),5)
70703  pmq2=(pmth(1,irgd2)**2+pmqth3**2)/v(iep(1),5)
70704  zd=sqrt(max(0d0,(1d0-v(iep(1),5)/ped**2)*((1d0-pmq1-pmq2)**2-
70705  & 4d0*pmq1*pmq2)))
70706  zh=1d0+pmq1-pmq2
70707  ELSE
70708  zd=sqrt(max(0d0,1d0-v(iep(1),5)/ped**2))
70709  zh=1d0
70710  ENDIF
70711  IF(kfl(1).EQ.21.AND.k(iep(1),5).LT.10.AND.
70712  &(mstj(44).EQ.3.OR.mstj(44).EQ.5)) THEN
70713  ELSEIF(ipspd.NE.0) THEN
70714  ELSE
70715  zl=0.5d0*(zh-zd)
70716  zu=0.5d0*(zh+zd)
70717  IF(z.LT.zl.OR.z.GT.zu) goto 410
70718  ENDIF
70719  IF(kfl(1).EQ.21) v(iep(1),3)=log(zu*(1d0-zl)/max(1d-20,zl*
70720  &(1d0-zu)))
70721  IF(kfl(1).NE.21) v(iep(1),3)=log((1d0-zl)/max(1d-10,1d0-zu))
70722 
70723 C...Width suppression for q -> q + g.
70724  IF(mstj(40).NE.0.AND.kfl(1).NE.21.AND.ipspd.EQ.0) THEN
70725  IF(igm.EQ.0) THEN
70726  eglu=0.5d0*ps(5)*(1d0-z)*(1d0+v(iep(1),5)/v(ns+1,5))
70727  ELSE
70728  eglu=pmed*(1d0-z)
70729  ENDIF
70730  chi=parj(89)**2/(parj(89)**2+eglu**2)
70731  IF(mstj(40).EQ.1) THEN
70732  IF(chi.LT.pyr(0)) goto 410
70733  ELSEIF(mstj(40).EQ.2) THEN
70734  IF(1d0-chi.LT.pyr(0)) goto 410
70735  ENDIF
70736  ENDIF
70737 
70738 C...Three-jet matrix element correction.
70739  IF(m3jc.GE.1) THEN
70740  wme=1d0
70741  wshow=1d0
70742 
70743 C...QED matrix elements: only for massless case so far.
70744  IF(mce.EQ.2.AND.igm.EQ.0) THEN
70745  x1=z*(1d0+v(iep(1),5)/v(ns+1,5))
70746  x2=1d0-v(iep(1),5)/v(ns+1,5)
70747  x3=(1d0-x1)+(1d0-x2)
70748  ki1=k(ipa(inum),2)
70749  ki2=k(ipa(3-inum),2)
70750  qf1=kchg(pycomp(ki1),1)*isign(1,ki1)/3d0
70751  qf2=kchg(pycomp(ki2),1)*isign(1,ki2)/3d0
70752  wshow=qf1**2*(1d0-x1)/x3*(1d0+(x1/(2d0-x2))**2)+
70753  & qf2**2*(1d0-x2)/x3*(1d0+(x2/(2d0-x1))**2)
70754  wme=(qf1*(1d0-x1)/x3-qf2*(1d0-x2)/x3)**2*(x1**2+x2**2)
70755  ELSEIF(mce.EQ.2) THEN
70756 
70757 C...QCD matrix elements, including mass effects.
70758  ELSEIF(mstj(49).NE.1.AND.k(iep(1),2).NE.21) THEN
70759  ps1me=v(iep(1),5)
70760  pm1me=pmth(1,ir)
70761  m3jcc=m3jc
70762  IF(ir.GE.31.AND.igm.EQ.0) THEN
70763 C...QCD ME: original parton, first branching.
70764  pm2me=pmth(1,63-ir)
70765  ecmme=ps(5)
70766  ELSEIF(ir.GE.31) THEN
70767 C...QCD ME: original parton, subsequent branchings.
70768  pm2me=pmth(1,63-ir)
70769  pedme=pem*(v(im,1)+(1d0-v(im,1))*ps1me/v(im,5))
70770  ecmme=pedme+sqrt(max(0d0,pedme**2-ps1me+pm2me**2))
70771  ELSEIF(k(im,2).EQ.21) THEN
70772 C...QCD ME: secondary partons, first branching.
70773  pm2me=pm1me
70774  zmme=v(im,1)
70775  IF(iep(1).GT.iep(2)) zmme=1d0-zmme
70776  pmlme=sqrt(max(0d0,(v(im,5)-ps1me-pm2me**2)**2-
70777  & 4d0*ps1me*pm2me**2))
70778  pedme=pem*(0.5d0*(v(im,5)-pmlme+ps1me-pm2me**2)+pmlme*zmme)/
70779  & v(im,5)
70780  ecmme=pedme+sqrt(max(0d0,pedme**2-ps1me+pm2me**2))
70781  m3jcc=66
70782  ELSE
70783 C...QCD ME: secondary partons, subsequent branchings.
70784  pm2me=pm1me
70785  pedme=pem*(v(im,1)+(1d0-v(im,1))*ps1me/v(im,5))
70786  ecmme=pedme+sqrt(max(0d0,pedme**2-ps1me+pm2me**2))
70787  m3jcc=66
70788  ENDIF
70789 C...Construct ME variables.
70790  r1me=pm1me/ecmme
70791  r2me=pm2me/ecmme
70792  x1=(1d0+ps1me/ecmme**2-r2me**2)*(z+(1d0-z)*pm1me**2/ps1me)
70793  x2=1d0+r2me**2-ps1me/ecmme**2
70794 C...Call ME, with right order important for two inequivalent showerers.
70795  IF(ir.EQ.iord+30) THEN
70796  wme=pymael(m3jcc,x1,x2,r1me,r2me,alpha)
70797  ELSE
70798  wme=pymael(m3jcc,x2,x1,r2me,r1me,alpha)
70799  ENDIF
70800 C...Split up total ME when two radiating partons.
70801  isprad=1
70802  IF((m3jcc.GE.16.AND.m3jcc.LE.19).OR.
70803  & (m3jcc.GE.26.AND.m3jcc.LE.29).OR.
70804  & (m3jcc.GE.36.AND.m3jcc.LE.39).OR.
70805  & (m3jcc.GE.46.AND.m3jcc.LE.49).OR.
70806  & (m3jcc.GE.56.AND.m3jcc.LE.64)) isprad=0
70807  IF(isprad.EQ.1) wme=wme*max(1d-10,1d0+r1me**2-r2me**2-x1)/
70808  & max(1d-10,2d0-x1-x2)
70809 C...Evaluate shower rate to be compared with.
70810  wshow=2d0/(max(1d-10,2d0-x1-x2)*
70811  & max(1d-10,1d0+r2me**2-r1me**2-x2))
70812  IF(iglui.EQ.1.AND.ir.GE.31) wshow=(9d0/4d0)*wshow
70813  ELSEIF(mstj(49).NE.1) THEN
70814 
70815 C...Toy model scalar theory matrix elements; no mass effects.
70816  ELSE
70817  x1=z*(1d0+v(iep(1),5)/v(ns+1,5))
70818  x2=1d0-v(iep(1),5)/v(ns+1,5)
70819  x3=(1d0-x1)+(1d0-x2)
70820  wshow=4d0*x3*((1d0-x1)/(2d0-x2)**2+(1d0-x2)/(2d0-x1)**2)
70821  wme=x3**2
70822  IF(mstj(102).GE.2) wme=x3**2-2d0*(1d0+x3)*(1d0-x1)*(1d0-x2)*
70823  & parj(171)
70824  ENDIF
70825 
70826  IF(wme.LT.pyr(0)*wshow) goto 410
70827  ENDIF
70828 
70829 C...Impose angular ordering by rejection of nonordered emission.
70830  IF(mce.EQ.1.AND.igm.GT.0.AND.mstj(42).GE.2.AND.ipspd.EQ.0) THEN
70831  pemao=v(im,1)*p(im,4)
70832  IF(iep(1).EQ.n+2) pemao=(1d0-v(im,1))*p(im,4)
70833  IF(ir.GE.31.AND.mstj(42).GE.5) THEN
70834  maod=0
70835  ELSEIF(kfl(1).EQ.21.AND.k(iep(1),5).LE.10.AND.(mstj(42).EQ.4
70836  & .OR.mstj(42).EQ.7)) THEN
70837  maod=0
70838  ELSEIF(kfl(1).EQ.21.AND.k(iep(1),5).LE.10.AND.(mstj(42).EQ.3
70839  & .OR.mstj(42).EQ.6)) THEN
70840  maod=1
70841  pmdao=pmth(2,k(iep(1),5))
70842  the2id=z*(1d0-z)*pemao**2/(v(iep(1),5)-4d0*pmdao**2)
70843  ELSE
70844  maod=1
70845  the2id=z*(1d0-z)*pemao**2/v(iep(1),5)
70846  IF(mstj(42).GE.3.AND.mstj(42).NE.5) the2id=the2id*
70847  & (1d0+pmth(1,ir)**2*(1d0-z)/(v(iep(1),5)*z))**2
70848  ENDIF
70849  maom=1
70850  iaom=im
70851  440 IF(k(iaom,5).EQ.22) THEN
70852  iaom=k(iaom,3)
70853  IF(k(iaom,3).LE.ns) maom=0
70854  IF(maom.EQ.1) goto 440
70855  ENDIF
70856  IF(maom.EQ.1.AND.maod.EQ.1) THEN
70857  the2im=v(iaom,1)*(1d0-v(iaom,1))*p(iaom,4)**2/v(iaom,5)
70858  IF(the2id.LT.the2im) goto 410
70859  ENDIF
70860  ENDIF
70861 
70862 C...Impose user-defined maximum angle at first branching.
70863  IF(mstj(48).EQ.1.AND.ipspd.EQ.0) THEN
70864  IF(nep.EQ.1.AND.im.EQ.ns) THEN
70865  the2id=z*(1d0-z)*ps(4)**2/v(iep(1),5)
70866  IF(parj(85)**2*the2id.LT.1d0) goto 410
70867  ELSEIF(nep.EQ.2.AND.iep(1).EQ.ns+2) THEN
70868  the2id=z*(1d0-z)*(0.5d0*p(im,4))**2/v(iep(1),5)
70869  IF(parj(85)**2*the2id.LT.1d0) goto 410
70870  ELSEIF(nep.EQ.2.AND.iep(1).EQ.ns+3) THEN
70871  the2id=z*(1d0-z)*(0.5d0*p(im,4))**2/v(iep(1),5)
70872  IF(parj(86)**2*the2id.LT.1d0) goto 410
70873  ENDIF
70874  ENDIF
70875 
70876 C...Impose angular constraint in first branching from interference
70877 C...with initial state partons.
70878  IF(miis.GE.2.AND.iep(1).LE.ns+3) THEN
70879  the2d=max((1d0-z)/z,z/(1d0-z))*v(iep(1),5)/(0.5d0*p(im,4))**2
70880  IF(iep(1).EQ.ns+2.AND.isii(1).GE.1) THEN
70881  IF(the2d.GT.theiis(1,isii(1))**2) goto 410
70882  ELSEIF(iep(1).EQ.ns+3.AND.isii(2).GE.1) THEN
70883  IF(the2d.GT.theiis(2,isii(2))**2) goto 410
70884  ENDIF
70885  ENDIF
70886 
70887 C...End of inner veto algorithm. Check if only one leg evolved so far.
70888  450 v(iep(1),1)=z
70889  isl(1)=0
70890  isl(2)=0
70891  IF(nep.EQ.1) goto 490
70892  IF(nep.EQ.2.AND.p(iep(1),5)+p(iep(2),5).GE.p(im,5)) goto 350
70893  DO 460 i=1,nep
70894  ir=iref(n+i-ns)
70895  IF(itry(i).EQ.0.AND.ksh(ir).EQ.1) THEN
70896  IF(p(n+i,5).GE.pmth(2,ir)) goto 350
70897  ENDIF
70898  460 CONTINUE
70899 
70900 C...Check if chosen multiplet m1,m2,z1,z2 is physical.
70901  IF(nep.GE.3) THEN
70902  pmsum=0d0
70903  DO 470 i=1,nep
70904  pmsum=pmsum+p(n+i,5)
70905  470 CONTINUE
70906  IF(pmsum.GE.ps(5)) goto 350
70907  ELSEIF(igm.EQ.0.OR.mstj(43).LE.2.OR.mod(mstj(43),2).EQ.0) THEN
70908  DO 480 i1=n+1,n+2
70909  irda=iref(i1-ns)
70910  IF(ksh(irda).EQ.0) goto 480
70911  IF(p(i1,5).LT.pmth(2,irda)) goto 480
70912  IF(irda.EQ.21) THEN
70913  irgd1=iabs(k(i1,5))
70914  irgd2=irgd1
70915  ELSE
70916  irgd1=irda
70917  irgd2=iabs(k(i1,5))
70918  ENDIF
70919  i2=2*n+3-i1
70920  IF(igm.EQ.0.OR.mstj(43).LE.2) THEN
70921  ped=0.5d0*(v(im,5)+v(i1,5)-v(i2,5))/p(im,5)
70922  ELSE
70923  IF(i1.EQ.n+1) zm=v(im,1)
70924  IF(i1.EQ.n+2) zm=1d0-v(im,1)
70925  pml=sqrt((v(im,5)-v(n+1,5)-v(n+2,5))**2-
70926  & 4d0*v(n+1,5)*v(n+2,5))
70927  ped=pem*(0.5d0*(v(im,5)-pml+v(i1,5)-v(i2,5))+pml*zm)/
70928  & v(im,5)
70929  ENDIF
70930  IF(mod(mstj(43),2).EQ.1) THEN
70931  pmqth3=0.5d0*parj(82)
70932  IF(irgd2.EQ.22) pmqth3=0.5d0*parj(83)
70933  IF(irgd2.EQ.22.AND.iscol(irda).EQ.0) pmqth3=0.5d0*parj(90)
70934  pmq1=(pmth(1,irgd1)**2+pmqth3**2)/v(i1,5)
70935  pmq2=(pmth(1,irgd2)**2+pmqth3**2)/v(i1,5)
70936  zd=sqrt(max(0d0,(1d0-v(i1,5)/ped**2)*((1d0-pmq1-pmq2)**2-
70937  & 4d0*pmq1*pmq2)))
70938  zh=1d0+pmq1-pmq2
70939  ELSE
70940  zd=sqrt(max(0d0,1d0-v(i1,5)/ped**2))
70941  zh=1d0
70942  ENDIF
70943  IF(irda.EQ.21.AND.irgd1.LT.10.AND.
70944  & (mstj(44).EQ.3.OR.mstj(44).EQ.5)) THEN
70945  ELSE
70946  zl=0.5d0*(zh-zd)
70947  zu=0.5d0*(zh+zd)
70948  IF(i1.EQ.n+1.AND.(v(i1,1).LT.zl.OR.v(i1,1).GT.zu).AND.
70949  & isset(1).EQ.0) THEN
70950  isl(1)=1
70951  ELSEIF(i1.EQ.n+2.AND.(v(i1,1).LT.zl.OR.v(i1,1).GT.zu).AND.
70952  & isset(2).EQ.0) THEN
70953  isl(2)=1
70954  ENDIF
70955  ENDIF
70956  IF(irda.EQ.21) v(i1,4)=log(zu*(1d0-zl)/max(1d-20,
70957  & zl*(1d0-zu)))
70958  IF(irda.NE.21) v(i1,4)=log((1d0-zl)/max(1d-10,1d0-zu))
70959  480 CONTINUE
70960  IF(isl(1).EQ.1.AND.isl(2).EQ.1.AND.islm.NE.0) THEN
70961  isl(3-islm)=0
70962  islm=3-islm
70963  ELSEIF(isl(1).EQ.1.AND.isl(2).EQ.1) THEN
70964  zdr1=max(0d0,v(n+1,3)/max(1d-6,v(n+1,4))-1d0)
70965  zdr2=max(0d0,v(n+2,3)/max(1d-6,v(n+2,4))-1d0)
70966  IF(zdr2.GT.pyr(0)*(zdr1+zdr2)) isl(1)=0
70967  IF(isl(1).EQ.1) isl(2)=0
70968  IF(isl(1).EQ.0) islm=1
70969  IF(isl(2).EQ.0) islm=2
70970  ENDIF
70971  IF(isl(1).EQ.1.OR.isl(2).EQ.1) goto 350
70972  ENDIF
70973  ird1=iref(n+1-ns)
70974  ird2=iref(n+2-ns)
70975  IF(igm.GT.0) THEN
70976  IF(mod(mstj(43),2).EQ.1.AND.(p(n+1,5).GE.
70977  & pmth(2,ird1).OR.p(n+2,5).GE.pmth(2,ird2))) THEN
70978  pmq1=v(n+1,5)/v(im,5)
70979  pmq2=v(n+2,5)/v(im,5)
70980  zd=sqrt(max(0d0,(1d0-v(im,5)/pem**2)*((1d0-pmq1-pmq2)**2-
70981  & 4d0*pmq1*pmq2)))
70982  zh=1d0+pmq1-pmq2
70983  zl=0.5d0*(zh-zd)
70984  zu=0.5d0*(zh+zd)
70985  IF(v(im,1).LT.zl.OR.v(im,1).GT.zu) goto 350
70986  ENDIF
70987  ENDIF
70988 
70989 C...Accepted branch. Construct four-momentum for initial partons.
70990  490 mazip=0
70991  mazic=0
70992  IF(nep.EQ.1) THEN
70993  p(n+1,1)=0d0
70994  p(n+1,2)=0d0
70995  p(n+1,3)=sqrt(max(0d0,(p(ipa(1),4)+p(n+1,5))*(p(ipa(1),4)-
70996  & p(n+1,5))))
70997  p(n+1,4)=p(ipa(1),4)
70998  v(n+1,2)=p(n+1,4)
70999  ELSEIF(igm.EQ.0.AND.nep.EQ.2) THEN
71000  ped1=0.5d0*(v(im,5)+v(n+1,5)-v(n+2,5))/p(im,5)
71001  p(n+1,1)=0d0
71002  p(n+1,2)=0d0
71003  p(n+1,3)=sqrt(max(0d0,(ped1+p(n+1,5))*(ped1-p(n+1,5))))
71004  p(n+1,4)=ped1
71005  p(n+2,1)=0d0
71006  p(n+2,2)=0d0
71007  p(n+2,3)=-p(n+1,3)
71008  p(n+2,4)=p(im,5)-ped1
71009  v(n+1,2)=p(n+1,4)
71010  v(n+2,2)=p(n+2,4)
71011  ELSEIF(nep.GE.3) THEN
71012 C...Rescale all momenta for energy conservation.
71013  loop=0
71014  pes=0d0
71015  pqs=0d0
71016  DO 510 i=1,nep
71017  DO 500 j=1,4
71018  p(n+i,j)=p(ipa(i),j)
71019  500 CONTINUE
71020  pes=pes+p(n+i,4)
71021  pqs=pqs+p(n+i,5)**2/p(n+i,4)
71022  510 CONTINUE
71023  520 loop=loop+1
71024  fac=(ps(5)-pqs)/(pes-pqs)
71025  pes=0d0
71026  pqs=0d0
71027  DO 540 i=1,nep
71028  DO 530 j=1,3
71029  p(n+i,j)=fac*p(n+i,j)
71030  530 CONTINUE
71031  p(n+i,4)=sqrt(p(n+i,5)**2+p(n+i,1)**2+p(n+i,2)**2+p(n+i,3)**2)
71032  v(n+i,2)=p(n+i,4)
71033  pes=pes+p(n+i,4)
71034  pqs=pqs+p(n+i,5)**2/p(n+i,4)
71035  540 CONTINUE
71036  IF(loop.LT.10.AND.abs(pes-ps(5)).GT.1d-12*ps(5)) goto 520
71037 
71038 C...Construct transverse momentum for ordinary branching in shower.
71039  ELSE
71040  zm=v(im,1)
71041  looppt=0
71042  550 looppt=looppt+1
71043  pzm=sqrt(max(0d0,(pem+p(im,5))*(pem-p(im,5))))
71044  pmls=(v(im,5)-v(n+1,5)-v(n+2,5))**2-4d0*v(n+1,5)*v(n+2,5)
71045  IF(pzm.LE.0d0) THEN
71046  pts=0d0
71047  ELSEIF(k(im,2).EQ.21.AND.iabs(k(n+1,2)).LE.10.AND.
71048  & (mstj(44).EQ.3.OR.mstj(44).EQ.5)) THEN
71049  pts=pmls*zm*(1d0-zm)/v(im,5)
71050  ELSEIF(mod(mstj(43),2).EQ.1) THEN
71051  pts=(pem**2*(zm*(1d0-zm)*v(im,5)-(1d0-zm)*v(n+1,5)-
71052  & zm*v(n+2,5))-0.25d0*pmls)/pzm**2
71053  ELSE
71054  pts=pmls*(zm*(1d0-zm)*pem**2/v(im,5)-0.25d0)/pzm**2
71055  ENDIF
71056  IF(pts.LT.0d0.AND.looppt.LT.10) THEN
71057  zm=0.05d0+0.9d0*zm
71058  goto 550
71059  ELSEIF(pts.LT.0d0) THEN
71060  goto 280
71061  ENDIF
71062  pt=sqrt(max(0d0,pts))
71063 
71064 C...Global statistics.
71065  mint(353)=mint(353)+1
71066  vint(353)=vint(353)+pt
71067  IF (mint(353).EQ.1) vint(358)=pt
71068 
71069 C...Find coefficient of azimuthal asymmetry due to gluon polarization.
71070  hazip=0d0
71071  IF(mstj(49).NE.1.AND.mod(mstj(46),2).EQ.1.AND.k(im,2).EQ.21
71072  & .AND.iau.NE.0) THEN
71073  IF(k(igm,3).NE.0) mazip=1
71074  zau=v(igm,1)
71075  IF(iau.EQ.im+1) zau=1d0-v(igm,1)
71076  IF(mazip.EQ.0) zau=0d0
71077  IF(k(igm,2).NE.21) THEN
71078  hazip=2d0*zau/(1d0+zau**2)
71079  ELSE
71080  hazip=(zau/(1d0-zau*(1d0-zau)))**2
71081  ENDIF
71082  IF(k(n+1,2).NE.21) THEN
71083  hazip=hazip*(-2d0*zm*(1d0-zm))/(1d0-2d0*zm*(1d0-zm))
71084  ELSE
71085  hazip=hazip*(zm*(1d0-zm)/(1d0-zm*(1d0-zm)))**2
71086  ENDIF
71087  ENDIF
71088 
71089 C...Find coefficient of azimuthal asymmetry due to soft gluon
71090 C...interference.
71091  hazic=0d0
71092  IF(mstj(49).NE.2.AND.mstj(46).GE.2.AND.(k(n+1,2).EQ.21.OR.
71093  & k(n+2,2).EQ.21).AND.iau.NE.0) THEN
71094  IF(k(igm,3).NE.0) mazic=n+1
71095  IF(k(igm,3).NE.0.AND.k(n+1,2).NE.21) mazic=n+2
71096  IF(k(igm,3).NE.0.AND.k(n+1,2).EQ.21.AND.k(n+2,2).EQ.21.AND.
71097  & zm.GT.0.5d0) mazic=n+2
71098  IF(k(iau,2).EQ.22) mazic=0
71099  zs=zm
71100  IF(mazic.EQ.n+2) zs=1d0-zm
71101  zgm=v(igm,1)
71102  IF(iau.EQ.im-1) zgm=1d0-v(igm,1)
71103  IF(mazic.EQ.0) zgm=1d0
71104  IF(mazic.NE.0) hazic=(p(im,5)/p(igm,5))*
71105  & sqrt((1d0-zs)*(1d0-zgm)/(zs*zgm))
71106  hazic=min(0.95d0,hazic)
71107  ENDIF
71108  ENDIF
71109 
71110 C...Construct energies for ordinary branching in shower.
71111  560 IF(nep.EQ.2.AND.igm.GT.0) THEN
71112  IF(k(im,2).EQ.21.AND.iabs(k(n+1,2)).LE.10.AND.
71113  & (mstj(44).EQ.3.OR.mstj(44).EQ.5)) THEN
71114  p(n+1,4)=0.5d0*(pem*(v(im,5)+v(n+1,5)-v(n+2,5))+
71115  & pzm*sqrt(max(0d0,pmls))*(2d0*zm-1d0))/v(im,5)
71116  ELSEIF(mod(mstj(43),2).EQ.1) THEN
71117  p(n+1,4)=pem*v(im,1)
71118  ELSE
71119  p(n+1,4)=pem*(0.5d0*(v(im,5)-sqrt(pmls)+v(n+1,5)-v(n+2,5))+
71120  & sqrt(pmls)*zm)/v(im,5)
71121  ENDIF
71122 
71123 C...Already predetermined choice of phi angle or not
71124  phi=paru(2)*pyr(0)
71125  IF(mpspd.EQ.1.AND.igm.EQ.ns+1) THEN
71126  ipspd=ip1+im-ns-2
71127  IF(k(ipspd,4).GT.0) THEN
71128  ipsgd1=k(ipspd,4)
71129  IF(im.EQ.ns+2) THEN
71130  phi=pyangl(p(ipsgd1,1),p(ipsgd1,2))
71131  ELSE
71132  phi=pyangl(-p(ipsgd1,1),p(ipsgd1,2))
71133  ENDIF
71134  ENDIF
71135  ELSEIF(mpspd.EQ.1.AND.igm.EQ.ns+2) THEN
71136  ipspd=ip1+im-ns-2
71137  IF(k(ipspd,4).GT.0) THEN
71138  ipsgd1=k(ipspd,4)
71139  phipsm=pyangl(p(ipspd,1),p(ipspd,2))
71140  thepsm=pyangl(p(ipspd,3),sqrt(p(ipspd,1)**2+p(ipspd,2)**2))
71141  CALL pyrobo(ipsgd1,ipsgd1,0d0,-phipsm,0d0,0d0,0d0)
71142  CALL pyrobo(ipsgd1,ipsgd1,-thepsm,0d0,0d0,0d0,0d0)
71143  phi=pyangl(p(ipsgd1,1),p(ipsgd1,2))
71144  CALL pyrobo(ipsgd1,ipsgd1,thepsm,phipsm,0d0,0d0,0d0)
71145  ENDIF
71146  ENDIF
71147 
71148 C...Construct momenta for ordinary branching in shower.
71149  p(n+1,1)=pt*cos(phi)
71150  p(n+1,2)=pt*sin(phi)
71151  IF(k(im,2).EQ.21.AND.iabs(k(n+1,2)).LE.10.AND.
71152  & (mstj(44).EQ.3.OR.mstj(44).EQ.5)) THEN
71153  p(n+1,3)=0.5d0*(pzm*(v(im,5)+v(n+1,5)-v(n+2,5))+
71154  & pem*sqrt(max(0d0,pmls))*(2d0*zm-1d0))/v(im,5)
71155  ELSEIF(pzm.GT.0d0) THEN
71156  p(n+1,3)=0.5d0*(v(n+2,5)-v(n+1,5)-v(im,5)+
71157  & 2d0*pem*p(n+1,4))/pzm
71158  ELSE
71159  p(n+1,3)=0d0
71160  ENDIF
71161  p(n+2,1)=-p(n+1,1)
71162  p(n+2,2)=-p(n+1,2)
71163  p(n+2,3)=pzm-p(n+1,3)
71164  p(n+2,4)=pem-p(n+1,4)
71165  IF(mstj(43).LE.2) THEN
71166  v(n+1,2)=(pem*p(n+1,4)-pzm*p(n+1,3))/p(im,5)
71167  v(n+2,2)=(pem*p(n+2,4)-pzm*p(n+2,3))/p(im,5)
71168  ENDIF
71169  ENDIF
71170 
71171 C...Rotate and boost daughters.
71172  IF(igm.GT.0) THEN
71173  IF(mstj(43).LE.2) THEN
71174  bex=p(igm,1)/p(igm,4)
71175  bey=p(igm,2)/p(igm,4)
71176  bez=p(igm,3)/p(igm,4)
71177  ga=p(igm,4)/p(igm,5)
71178  gabep=ga*(ga*(bex*p(im,1)+bey*p(im,2)+bez*p(im,3))/(1d0+ga)-
71179  & p(im,4))
71180  ELSE
71181  bex=0d0
71182  bey=0d0
71183  bez=0d0
71184  ga=1d0
71185  gabep=0d0
71186  ENDIF
71187  ptimb=sqrt((p(im,1)+gabep*bex)**2+(p(im,2)+gabep*bey)**2)
71188  the=pyangl(p(im,3)+gabep*bez,ptimb)
71189  IF(ptimb.GT.1d-4) THEN
71190  phi=pyangl(p(im,1)+gabep*bex,p(im,2)+gabep*bey)
71191  ELSE
71192  phi=0d0
71193  ENDIF
71194  DO 570 i=n+1,n+2
71195  dp(1)=cos(the)*cos(phi)*p(i,1)-sin(phi)*p(i,2)+
71196  & sin(the)*cos(phi)*p(i,3)
71197  dp(2)=cos(the)*sin(phi)*p(i,1)+cos(phi)*p(i,2)+
71198  & sin(the)*sin(phi)*p(i,3)
71199  dp(3)=-sin(the)*p(i,1)+cos(the)*p(i,3)
71200  dp(4)=p(i,4)
71201  dbp=bex*dp(1)+bey*dp(2)+bez*dp(3)
71202  dgabp=ga*(ga*dbp/(1d0+ga)+dp(4))
71203  p(i,1)=dp(1)+dgabp*bex
71204  p(i,2)=dp(2)+dgabp*bey
71205  p(i,3)=dp(3)+dgabp*bez
71206  p(i,4)=ga*(dp(4)+dbp)
71207  570 CONTINUE
71208  ENDIF
71209 
71210 C...Weight with azimuthal distribution, if required.
71211  IF(mazip.NE.0.OR.mazic.NE.0) THEN
71212  DO 580 j=1,3
71213  dpt(1,j)=p(im,j)
71214  dpt(2,j)=p(iau,j)
71215  dpt(3,j)=p(n+1,j)
71216  580 CONTINUE
71217  dpma=dpt(1,1)*dpt(2,1)+dpt(1,2)*dpt(2,2)+dpt(1,3)*dpt(2,3)
71218  dpmd=dpt(1,1)*dpt(3,1)+dpt(1,2)*dpt(3,2)+dpt(1,3)*dpt(3,3)
71219  dpmm=dpt(1,1)**2+dpt(1,2)**2+dpt(1,3)**2
71220  DO 590 j=1,3
71221  dpt(4,j)=dpt(2,j)-dpma*dpt(1,j)/max(1d-10,dpmm)
71222  dpt(5,j)=dpt(3,j)-dpmd*dpt(1,j)/max(1d-10,dpmm)
71223  590 CONTINUE
71224  dpt(4,4)=sqrt(dpt(4,1)**2+dpt(4,2)**2+dpt(4,3)**2)
71225  dpt(5,4)=sqrt(dpt(5,1)**2+dpt(5,2)**2+dpt(5,3)**2)
71226  IF(min(dpt(4,4),dpt(5,4)).GT.0.1d0*parj(82)) THEN
71227  cad=(dpt(4,1)*dpt(5,1)+dpt(4,2)*dpt(5,2)+
71228  & dpt(4,3)*dpt(5,3))/(dpt(4,4)*dpt(5,4))
71229  IF(mazip.NE.0) THEN
71230  IF(1d0+hazip*(2d0*cad**2-1d0).LT.pyr(0)*(1d0+abs(hazip)))
71231  & goto 560
71232  ENDIF
71233  IF(mazic.NE.0) THEN
71234  IF(mazic.EQ.n+2) cad=-cad
71235  IF((1d0-hazic)*(1d0-hazic*cad)/(1d0+hazic**2-2d0*hazic*cad)
71236  & .LT.pyr(0)) goto 560
71237  ENDIF
71238  ENDIF
71239  ENDIF
71240 
71241 C...Azimuthal anisotropy due to interference with initial state partons.
71242  IF(mod(miis,2).EQ.1.AND.igm.EQ.ns+1.AND.(k(n+1,2).EQ.21.OR.
71243  &k(n+2,2).EQ.21)) THEN
71244  iii=im-ns-1
71245  IF(isii(iii).GE.1) THEN
71246  iaziid=n+1
71247  IF(k(n+1,2).NE.21) iaziid=n+2
71248  IF(k(n+1,2).EQ.21.AND.k(n+2,2).EQ.21.AND.
71249  & p(n+1,4).GT.p(n+2,4)) iaziid=n+2
71250  theiid=pyangl(p(iaziid,3),sqrt(p(iaziid,1)**2+p(iaziid,2)**2))
71251  IF(iii.EQ.2) theiid=paru(1)-theiid
71252  phiiid=pyangl(p(iaziid,1),p(iaziid,2))
71253  hazii=min(0.95d0,theiid/theiis(iii,isii(iii)))
71254  cad=cos(phiiid-phiiis(iii,isii(iii)))
71255  phirel=abs(phiiid-phiiis(iii,isii(iii)))
71256  IF(phirel.GT.paru(1)) phirel=paru(2)-phirel
71257  IF((1d0-hazii)*(1d0-hazii*cad)/(1d0+hazii**2-2d0*hazii*cad)
71258  & .LT.pyr(0)) goto 560
71259  ENDIF
71260  ENDIF
71261 
71262 C...Continue loop over partons that may branch, until none left.
71263  IF(igm.GE.0) k(im,1)=14
71264  n=n+nep
71265  nep=2
71266  IF(n.GT.mstu(4)-mstu(32)-10) THEN
71267  CALL pyerrm(11,'(PYSHOW:) no more memory left in PYJETS')
71268  IF(mstu(21).GE.1) n=ns
71269  IF(mstu(21).GE.1) RETURN
71270  ENDIF
71271  goto 290
71272 
71273 C...Set information on imagined shower initiator.
71274  600 IF(npa.GE.2) THEN
71275  k(ns+1,1)=11
71276  k(ns+1,2)=94
71277  k(ns+1,3)=ip1
71278  IF(ip2.GT.0.AND.ip2.LT.ip1) k(ns+1,3)=ip2
71279  k(ns+1,4)=ns+2
71280  k(ns+1,5)=ns+1+npa
71281  iim=1
71282  ELSE
71283  iim=0
71284  ENDIF
71285 
71286 C...Reconstruct string drawing information.
71287  DO 610 i=ns+1+iim,n
71288  kq=kchg(pycomp(k(i,2)),2)
71289  IF(k(i,1).LE.10.AND.k(i,2).EQ.22) THEN
71290  k(i,1)=1
71291  ELSEIF(k(i,1).LE.10.AND.iabs(k(i,2)).GE.11.AND.
71292  & iabs(k(i,2)).LE.18) THEN
71293  k(i,1)=1
71294  ELSEIF(k(i,1).LE.10) THEN
71295  k(i,4)=mstu(5)*(k(i,4)/mstu(5))
71296  k(i,5)=mstu(5)*(k(i,5)/mstu(5))
71297  ELSEIF(k(mod(k(i,4),mstu(5))+1,2).NE.22) THEN
71298  id1=mod(k(i,4),mstu(5))
71299  IF(kq.EQ.1.AND.k(i,2).GT.0) id1=mod(k(i,4),mstu(5))+1
71300  IF(kq.EQ.2.AND.(k(id1,2).EQ.21.OR.k(id1+1,2).EQ.21).AND.
71301  & pyr(0).GT.0.5d0) id1=mod(k(i,4),mstu(5))+1
71302  id2=2*mod(k(i,4),mstu(5))+1-id1
71303  k(i,4)=mstu(5)*(k(i,4)/mstu(5))+id1
71304  k(i,5)=mstu(5)*(k(i,5)/mstu(5))+id2
71305  k(id1,4)=k(id1,4)+mstu(5)*i
71306  k(id1,5)=k(id1,5)+mstu(5)*id2
71307  k(id2,4)=k(id2,4)+mstu(5)*id1
71308  k(id2,5)=k(id2,5)+mstu(5)*i
71309  ELSE
71310  id1=mod(k(i,4),mstu(5))
71311  id2=id1+1
71312  k(i,4)=mstu(5)*(k(i,4)/mstu(5))+id1
71313  k(i,5)=mstu(5)*(k(i,5)/mstu(5))+id1
71314  IF(kq.EQ.1.OR.k(id1,1).GE.11) THEN
71315  k(id1,4)=k(id1,4)+mstu(5)*i
71316  k(id1,5)=k(id1,5)+mstu(5)*i
71317  ELSE
71318  k(id1,4)=0
71319  k(id1,5)=0
71320  ENDIF
71321  k(id2,4)=0
71322  k(id2,5)=0
71323  ENDIF
71324  610 CONTINUE
71325 
71326 C...Transformation from CM frame.
71327  IF(npa.EQ.1) THEN
71328  the=pyangl(p(ipa(1),3),sqrt(p(ipa(1),1)**2+p(ipa(1),2)**2))
71329  phi=pyangl(p(ipa(1),1),p(ipa(1),2))
71330  mstu(33)=1
71331  CALL pyrobo(ns+1,n,the,phi,0d0,0d0,0d0)
71332  ELSEIF(npa.EQ.2) THEN
71333  bex=ps(1)/ps(4)
71334  bey=ps(2)/ps(4)
71335  bez=ps(3)/ps(4)
71336  ga=ps(4)/ps(5)
71337  gabep=ga*(ga*(bex*p(ipa(1),1)+bey*p(ipa(1),2)+bez*p(ipa(1),3))
71338  & /(1d0+ga)-p(ipa(1),4))
71339  the=pyangl(p(ipa(1),3)+gabep*bez,sqrt((p(ipa(1),1)
71340  & +gabep*bex)**2+(p(ipa(1),2)+gabep*bey)**2))
71341  phi=pyangl(p(ipa(1),1)+gabep*bex,p(ipa(1),2)+gabep*bey)
71342  mstu(33)=1
71343  CALL pyrobo(ns+1,n,the,phi,bex,bey,bez)
71344  ELSE
71345  CALL pyrobo(ipa(1),ipa(npa),0d0,0d0,ps(1)/ps(4),ps(2)/ps(4),
71346  & ps(3)/ps(4))
71347  mstu(33)=1
71348  CALL pyrobo(ns+1,n,0d0,0d0,ps(1)/ps(4),ps(2)/ps(4),ps(3)/ps(4))
71349  ENDIF
71350 
71351 C...Decay vertex of shower.
71352  DO 630 i=ns+1,n
71353  DO 620 j=1,5
71354  v(i,j)=v(ip1,j)
71355  620 CONTINUE
71356  630 CONTINUE
71357 
71358 C...Delete trivial shower, else connect initiators.
71359  IF(n.LE.ns+npa+iim) THEN
71360  n=ns
71361  ELSE
71362  DO 640 ip=1,npa
71363  k(ipa(ip),1)=14
71364  k(ipa(ip),4)=k(ipa(ip),4)+ns+iim+ip
71365  k(ipa(ip),5)=k(ipa(ip),5)+ns+iim+ip
71366  k(ns+iim+ip,3)=ipa(ip)
71367  IF(iim.EQ.1.AND.mstu(16).NE.2) k(ns+iim+ip,3)=ns+1
71368  IF(k(ns+iim+ip,1).NE.1) THEN
71369  k(ns+iim+ip,4)=mstu(5)*ipa(ip)+k(ns+iim+ip,4)
71370  k(ns+iim+ip,5)=mstu(5)*ipa(ip)+k(ns+iim+ip,5)
71371  ENDIF
71372  640 CONTINUE
71373  ENDIF
71374 
71375  RETURN
71376  END
71377 
71378 C*********************************************************************
71379 
71380 C...PYPTFS
71381 C...Generates pT-ordered timelike final-state parton showers.
71382 
71383 C...MODE defines how to find radiators and recoilers.
71384 C... = 0 : based on colour flow between undecayed partons.
71385 C... = 1 : for IPART <= NPARTD only consider primary partons,
71386 C... whether decayed or not; else as above.
71387 C... = 2 : based on common history, whether decayed or not.
71388 C... = 3 : use (or create) MCT color information to shower partons
71389 
71390  SUBROUTINE pyptfs(MODE,PTMAX,PTMIN,PTGEN)
71391 
71392 C...Double precision and integer declarations.
71393  IMPLICIT DOUBLE PRECISION(a-h, o-z)
71394  IMPLICIT INTEGER(i-n)
71395  INTEGER pyk,pychge,pycomp
71396 C...Parameter statement to help give large particle numbers.
71397  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
71398  &kexcit=4000000,kdimen=5000000)
71399 C...Parameter statement for maximum size of showers.
71400  parameter(maxnur=1000)
71401 C...Commonblocks.
71402  common/pypart/npart,npartd,ipart(maxnur),ptpart(maxnur)
71403  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
71404  common/pyctag/nct,mct(4000,2)
71405  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
71406  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
71407  common/pypars/mstp(200),parp(200),msti(200),pari(200)
71408  common/pyint1/mint(400),vint(400)
71409  SAVE /pypart/,/pyjets/,/pyctag/,/pydat1/,/pydat2/,/pypars/,
71410  &/pyint1/
71411 C...Local arrays.
71412  dimension ipos(2*maxnur),irec(2*maxnur),iflg(2*maxnur),
71413  &iscol(2*maxnur),ischg(2*maxnur),ptsca(2*maxnur),imesav(2*maxnur),
71414  &pt2sav(2*maxnur),zsav(2*maxnur),shtsav(2*maxnur),
71415  &mesys(maxnur,0:2),psum(5),dpt(5,4)
71416 C...Statement functions.
71417  shat(l,j)=(p(l,4)+p(j,4))**2-(p(l,1)+p(j,1))**2-
71418  &(p(l,2)+p(j,2))**2-(p(l,3)+p(j,3))**2
71419  dotp(l,j)=p(l,4)*p(j,4)-p(l,1)*p(j,1)-p(l,2)*p(j,2)-p(l,3)*p(j,3)
71420 
71421 C...Initial values. Check that valid system.
71422  ptgen=0d0
71423  IF(mstj(41).NE.1.AND.mstj(41).NE.2.AND.mstj(41).NE.11.AND.
71424  &mstj(41).NE.12) RETURN
71425  IF(npart.LE.0) THEN
71426  CALL pyerrm(2,'(PYPTFS:) showering system too small')
71427  RETURN
71428  ENDIF
71429  pt2cmx=ptmax**2
71430  iord=1
71431 
71432 C...Mass thresholds and Lambda for QCD evolution.
71433  pmb=pmas(5,1)
71434  pmc=pmas(4,1)
71435  alam5=parj(81)
71436  alam4=alam5*(pmb/alam5)**(2d0/25d0)
71437  alam3=alam4*(pmc/alam4)**(2d0/27d0)
71438  pmbs=pmb**2
71439  pmcs=pmc**2
71440  alam5s=alam5**2
71441  alam4s=alam4**2
71442  alam3s=alam3**2
71443 
71444 C...Cutoff scale for QCD evolution. Starting pT2.
71445  nflav=max(0,min(5,mstj(45)))
71446  pt0c=0.5d0*parj(82)
71447  pt2cmn=max(ptmin,pt0c,1.1d0*alam3)**2
71448 
71449 C...Parameters for QED evolution.
71450  aem2pi=paru(101)/paru(2)
71451  pt0eq=0.5d0*parj(83)
71452  pt0el=0.5d0*parj(90)
71453 
71454 C...Reset. Remove irrelevant colour tags.
71455  nevol=0
71456  DO 100 j=1,4
71457  psum(j)=0d0
71458  100 CONTINUE
71459  DO 110 i=mint(84)+1,n
71460  IF(k(i,2).GT.0.AND.k(i,2).LT.6) THEN
71461  k(i,5)=0
71462  mct(i,2)=0
71463  ENDIF
71464  IF(k(i,2).LT.0.AND.k(i,2).GT.-6) THEN
71465  k(i,4)=0
71466  mct(i,1)=0
71467  ENDIF
71468  110 CONTINUE
71469  nparts=npart
71470 
71471 C...Begin loop to set up showering partons. Sum four-momenta.
71472  DO 230 ip=1,npart
71473  i=ipart(ip)
71474  IF(mode.NE.1.OR.i.GT.npartd) THEN
71475  IF(k(i,1).GT.10) goto 230
71476  ELSEIF(k(i,3).GT.mint(84)) THEN
71477  IF(k(i,3).GT.mint(84)+2) goto 230
71478  ELSE
71479  IF(k(k(i,3),3).GT.mint(83)+6) goto 230
71480  ENDIF
71481  DO 120 j=1,4
71482  psum(j)=psum(j)+p(i,j)
71483  120 CONTINUE
71484 
71485 C...Find colour and charge, but skip diquarks.
71486  IF(iabs(k(i,2)).GT.1000.AND.iabs(k(i,2)).LT.10000) goto 230
71487  kcol=pyk(i,12)
71488  kcha=pyk(i,6)
71489 
71490 C...QUARKONIA++
71491  IF (iabs(k(i,2)).GE.9900101.AND.iabs(k(i,2)).LE.9910555) THEN
71492  IF (mstp(148).GE.1) THEN
71493 C...Temporary: force no radiation from quarkonia since not yet treated
71494  CALL pyerrm(11,'(PYPTFS:) quarkonia showers not yet in'
71495  & //' PYPTFS, switched off')
71496  CALL pygive('MSTP(148)=0')
71497  ENDIF
71498  IF (mstp(148).EQ.0) THEN
71499 C...Skip quarkonia if radiation switched off
71500  goto 230
71501  ENDIF
71502  ENDIF
71503 C...QUARKONIA--
71504 
71505 C...Option to switch off radiation from particle KF = MSTJ(39) entirely
71506 C...(only intended for studying the effects of switching such rad on/off)
71507  IF (mstj(39).GT.0.AND.iabs(k(i,2)).EQ.mstj(39)) THEN
71508  goto 230
71509  ENDIF
71510 
71511 C...Either colour or anticolour charge radiates; for gluon both.
71512  DO 180 jsgcol=1,-1,-2
71513  IF(kcol.EQ.jsgcol.OR.kcol.EQ.2) THEN
71514  jcol=4+(1-jsgcol)/2
71515  jcolr=9-jcol
71516 
71517 C...Basic info about radiating parton.
71518  nevol=nevol+1
71519  ipos(nevol)=i
71520  iflg(nevol)=0
71521  iscol(nevol)=jsgcol
71522  ischg(nevol)=0
71523  ptsca(nevol)=ptpart(ip)
71524 
71525 C...Begin search for colour recoiler when MODE = 0 or 1.
71526  IF(mode.LE.1) THEN
71527 C...Find sister with matching anticolour to the radiating parton.
71528  irold=i
71529  irnew=k(irold,jcol)/mstu(5)
71530  move=1
71531 
71532 C...Skip radiation off loose colour ends.
71533  130 IF(irnew.EQ.0) THEN
71534  nevol=nevol-1
71535  goto 180
71536 
71537 C...Optionally skip radiation on dipole to beam remnant.
71538  ELSEIF(mstp(72).LE.1.AND.irnew.GT.mint(53)) THEN
71539  nevol=nevol-1
71540  goto 180
71541 
71542 C...For now always skip radiation on dipole to junction.
71543  ELSEIF(k(irnew,2).EQ.88) THEN
71544  nevol=nevol-1
71545  goto 180
71546 
71547 C...For MODE=1: if reached primary then done.
71548  ELSEIF(mode.EQ.1.AND.irnew.GT.mint(84)+2.AND.
71549  & irnew.LE.npartd) THEN
71550 
71551 C...If sister stable and points back then done.
71552  ELSEIF(move.EQ.1.AND.k(irnew,jcolr)/mstu(5).EQ.irold)
71553  & THEN
71554  IF(k(irnew,1).LT.10) THEN
71555 
71556 C...If sister unstable then go to her daughter.
71557  ELSE
71558  irold=irnew
71559  irnew=mod(k(irnew,jcolr),mstu(5))
71560  move=2
71561  goto 130
71562  ENDIF
71563 
71564 C...If found mother then look for aunt.
71565  ELSEIF(move.EQ.1.AND.mod(k(irnew,jcol),mstu(5)).EQ.
71566  & irold) THEN
71567  irold=irnew
71568  irnew=k(irold,jcol)/mstu(5)
71569  goto 130
71570 
71571 C...If daughter stable then done.
71572  ELSEIF(move.EQ.2.AND.k(irnew,jcolr)/mstu(5).EQ.irold)
71573  & THEN
71574  IF(k(irnew,1).LT.10) THEN
71575 
71576 C...If daughter unstable then go to granddaughter.
71577  ELSE
71578  irold=irnew
71579  irnew=mod(k(irnew,jcolr),mstu(5))
71580  move=2
71581  goto 130
71582  ENDIF
71583 
71584 C...If daughter points to another daughter then done or move up.
71585  ELSEIF(move.EQ.2.AND.mod(k(irnew,jcol),mstu(5)).EQ.
71586  & irold) THEN
71587  IF(k(irnew,1).LT.10) THEN
71588  ELSE
71589  irold=irnew
71590  irnew=k(irnew,jcol)/mstu(5)
71591  move=1
71592  goto 130
71593  ENDIF
71594  ENDIF
71595 
71596 C...Begin search for colour recoiler when MODE = 2.
71597  ELSEIF (mode.EQ.2) THEN
71598  irold=i
71599  irnew=k(irold,jcol)/mstu(5)
71600  140 IF (irnew.LE.0.OR.irnew.GT.n) THEN
71601 C...If no color partner found, pick at random among other primaries
71602 C...(e.g., when the color line is traced all the way to the beam)
71603  istep=max(1,min(npart-1,int(1d0+(npart-1)*pyr(0))))
71604  irnew=ipart(1+mod(ip+istep-1,npart))
71605  ELSEIF(k(irnew,jcolr)/mstu(5).NE.irold) THEN
71606 C...Step up to mother if radiating parton already branched.
71607  IF(k(irnew,2).EQ.k(irold,2)) THEN
71608  irold=irnew
71609  irnew=k(irold,jcol)/mstu(5)
71610  goto 140
71611 C...Pick sister by history if no anticolour available.
71612  ELSE
71613  IF(irold.GT.1.AND.k(irold-1,3).EQ.k(irold,3)) THEN
71614  irnew=irold-1
71615  ELSEIF(irold.LT.n.AND.k(irold+1,3).EQ.k(irold,3))
71616  & THEN
71617  irnew=irold+1
71618 C...Last resort: pick at random among other primaries.
71619  ELSE
71620  istep=max(1,min(npart-1,int(1d0+(npart-1)*pyr(0))))
71621  irnew=ipart(1+mod(ip+istep-1,npart))
71622  ENDIF
71623  ENDIF
71624  ENDIF
71625 C...Trace down if sister branched.
71626  150 IF(k(irnew,1).GT.10) THEN
71627  irtmp=mod(k(irnew,jcolr),mstu(5))
71628 C...If no correct color-daughter found, swap.
71629  IF (irtmp.EQ.0) THEN
71630  jcol=9-jcol
71631  jcolr=9-jcolr
71632  irtmp=mod(k(irnew,jcolr),mstu(5))
71633  ENDIF
71634  irnew=irtmp
71635  goto 150
71636  ENDIF
71637  ELSEIF (mode.EQ.3) THEN
71638 C...The following will add MCT colour tracing for unprepped events
71639 C...If not done, trace Les Houches colour tags for this dipole
71640  jcolsv=jcol
71641  IF (mct(i,jcol-3).EQ.0) THEN
71642 C...Special end code -1 : trace to color partner or 0, return in IEND
71643  iend=-1
71644  CALL pycttr(i,jcol,iend)
71645 C...Clean up mother/daughter 'read' tags set by PYCTTR
71646  jcol=jcolsv
71647  DO 160 ir=1,n
71648  k(ir,4)=mod(k(ir,4),mstu(5)**2)
71649  k(ir,5)=mod(k(ir,5),mstu(5)**2)
71650  mct(ir,1)=0
71651  mct(ir,2)=0
71652  160 CONTINUE
71653  ELSE
71654  iend=0
71655  DO 170 ir=1,n
71656  IF (k(ir,1).GT.0.AND.mct(ir,6-jcol).EQ.mct(i,jcol-3))
71657  & iend=ir
71658  170 CONTINUE
71659  ENDIF
71660 C...If no color partner, then we hit beam
71661  IF (iend.LE.0) THEN
71662 C...For MSTP(72) <= 1, do not allow dipoles stretched to beam to radiate
71663  IF (mstp(72).LE.1) THEN
71664  nevol=nevol-1
71665  goto 180
71666  ELSE
71667 C...Else try a random partner
71668  istep=max(1,min(npart-1,int(1d0+(npart-1)*pyr(0))))
71669  irnew=ipart(1+mod(ip+istep-1,npart))
71670  ENDIF
71671  ELSE
71672 C...Else save recoiling colour partner
71673  irnew=iend
71674  ENDIF
71675 
71676  ENDIF
71677 
71678 C...Now found other end of colour dipole.
71679  irec(nevol)=irnew
71680  ENDIF
71681  180 CONTINUE
71682 
71683 C...Also electrical charge may radiate; so far only quarks and leptons.
71684  IF((mstj(41).EQ.2.OR.mstj(41).EQ.12).AND.kcha.NE.0.AND.
71685  & iabs(k(i,2)).LE.18) THEN
71686 
71687 C...Basic info about radiating parton.
71688  nevol=nevol+1
71689  ipos(nevol)=i
71690  iflg(nevol)=0
71691  iscol(nevol)=0
71692  ischg(nevol)=kcha
71693  ptsca(nevol)=ptpart(ip)
71694 
71695 C...Pick nearest (= smallest invariant mass) charged particle
71696 C...as recoiler when MODE = 0 or 1 (but for latter among primaries).
71697  IF(mode.LE.1) THEN
71698  irnew=0
71699  pm2min=vint(2)
71700  DO 190 ip2=1,npart+n-mint(53)
71701  IF(ip2.EQ.ip) goto 190
71702  IF(ip2.LE.npart) THEN
71703  i2=ipart(ip2)
71704  IF(mode.NE.1.OR.i2.GT.npartd) THEN
71705  IF(k(i2,1).GT.10) goto 190
71706  ELSEIF(k(i2,3).GT.mint(84)) THEN
71707  IF(k(i2,3).GT.mint(84)+2) goto 190
71708  ELSE
71709  IF(k(k(i2,3),3).GT.mint(83)+6) goto 190
71710  ENDIF
71711  ELSE
71712  i2=mint(53)+ip2-npart
71713  ENDIF
71714  IF(kchg(pycomp(k(i2,2)),1).EQ.0) goto 190
71715  pm2inv=(p(i,4)+p(i2,4))**2-(p(i,1)+p(i2,1))**2-
71716  & (p(i,2)+p(i2,2))**2-(p(i,3)+p(i2,3))**2
71717  IF(pm2inv.LT.pm2min) THEN
71718  irnew=i2
71719  pm2min=pm2inv
71720  ENDIF
71721  190 CONTINUE
71722  IF(irnew.EQ.0) THEN
71723  nevol=nevol-1
71724  goto 230
71725  ENDIF
71726 
71727 C...Begin search for charge recoiler when MODE = 2.
71728  ELSE
71729  irold=i
71730 C...Pick sister by history; step up if parton already branched.
71731  200 IF(k(irold,3).GT.0.AND.k(k(irold,3),2).EQ.k(irold,2)) THEN
71732  irold=k(irold,3)
71733  goto 200
71734  ENDIF
71735  IF(irold.GT.1.AND.k(irold-1,3).EQ.k(irold,3)) THEN
71736  irnew=irold-1
71737  ELSEIF(irold.LT.n.AND.k(irold+1,3).EQ.k(irold,3)) THEN
71738  irnew=irold+1
71739 C...Last resort: pick at random among other primaries.
71740  ELSE
71741  istep=max(1,min(npart-1,int(1d0+(npart-1)*pyr(0))))
71742  irnew=ipart(1+mod(ip+istep-1,npart))
71743  ENDIF
71744 C...Trace down if sister branched.
71745  210 IF(k(irnew,1).GT.10) THEN
71746  DO 220 ir=irnew+1,n
71747  IF(k(ir,3).EQ.irnew.AND.k(ir,2).EQ.k(irnew,2)) THEN
71748  irnew=ir
71749  goto 210
71750  ENDIF
71751  220 CONTINUE
71752  ENDIF
71753  ENDIF
71754  irec(nevol)=irnew
71755  ENDIF
71756 
71757 C...End loop to set up showering partons. System invariant mass.
71758  230 CONTINUE
71759  IF(nevol.LE.0) RETURN
71760  IF (mode.EQ.3.AND.nevol.LE.1) RETURN
71761  psum(5)=sqrt(max(0d0,psum(4)**2-psum(1)**2-psum(2)**2-psum(3)**2))
71762 
71763 C...Check if 3-jet matrix elements to be used.
71764  m3jc=0
71765  alpha=0.5d0
71766  nmesys=0
71767  IF(mstj(47).GE.1) THEN
71768 
71769 C...Identify source: q(1), ~q(2), V(3), S(4), chi(5), ~g(6), unknown(0).
71770  kfsrce=0
71771  ipart1=k(ipart(1),3)
71772  ipart2=k(ipart(2),3)
71773  240 IF(ipart1.EQ.ipart2.AND.ipart1.GT.0) THEN
71774  kfsrce=iabs(k(ipart1,2))
71775  ELSEIF(ipart1.GT.ipart2.AND.ipart2.GT.0) THEN
71776  ipart1=k(ipart1,3)
71777  goto 240
71778  ELSEIF(ipart2.GT.ipart1.AND.ipart1.GT.0) THEN
71779  ipart2=k(ipart2,3)
71780  goto 240
71781  ENDIF
71782  itypes=0
71783  IF(kfsrce.GE.1.AND.kfsrce.LE.8) itypes=1
71784  IF(kfsrce.GE.ksusy1+1.AND.kfsrce.LE.ksusy1+8) itypes=2
71785  IF(kfsrce.GE.ksusy2+1.AND.kfsrce.LE.ksusy2+8) itypes=2
71786  IF(kfsrce.GE.21.AND.kfsrce.LE.24) itypes=3
71787  IF(kfsrce.GE.32.AND.kfsrce.LE.34) itypes=3
71788  IF(kfsrce.EQ.25.OR.(kfsrce.GE.35.AND.kfsrce.LE.37)) itypes=4
71789  IF(kfsrce.GE.ksusy1+22.AND.kfsrce.LE.ksusy1+37) itypes=5
71790  IF(kfsrce.EQ.ksusy1+21) itypes=6
71791 
71792 C...Identify two primary showerers.
71793  kfla1=iabs(k(ipart(1),2))
71794  itype1=0
71795  IF(kfla1.GE.1.AND.kfla1.LE.8) itype1=1
71796  IF(kfla1.GE.ksusy1+1.AND.kfla1.LE.ksusy1+8) itype1=2
71797  IF(kfla1.GE.ksusy2+1.AND.kfla1.LE.ksusy2+8) itype1=2
71798  IF(kfla1.GE.21.AND.kfla1.LE.24) itype1=3
71799  IF(kfla1.GE.32.AND.kfla1.LE.34) itype1=3
71800  IF(kfla1.EQ.25.OR.(kfla1.GE.35.AND.kfla1.LE.37)) itype1=4
71801  IF(kfla1.GE.ksusy1+22.AND.kfla1.LE.ksusy1+37) itype1=5
71802  IF(kfla1.EQ.ksusy1+21) itype1=6
71803  kfla2=iabs(k(ipart(2),2))
71804  itype2=0
71805  IF(kfla2.GE.1.AND.kfla2.LE.8) itype2=1
71806  IF(kfla2.GE.ksusy1+1.AND.kfla2.LE.ksusy1+8) itype2=2
71807  IF(kfla2.GE.ksusy2+1.AND.kfla2.LE.ksusy2+8) itype2=2
71808  IF(kfla2.GE.21.AND.kfla2.LE.24) itype2=3
71809  IF(kfla2.GE.32.AND.kfla2.LE.34) itype2=3
71810  IF(kfla2.EQ.25.OR.(kfla2.GE.35.AND.kfla2.LE.37)) itype2=4
71811  IF(kfla2.GE.ksusy1+22.AND.kfla2.LE.ksusy1+37) itype2=5
71812  IF(kfla2.EQ.ksusy1+21) itype2=6
71813 
71814 C...Order of showerers. Presence of gluino.
71815  itypmn=min(itype1,itype2)
71816  itypmx=max(itype1,itype2)
71817  iord=1
71818  IF(itype1.GT.itype2) iord=2
71819  iglui=0
71820  IF(itype1.EQ.6.OR.itype2.EQ.6) iglui=1
71821 
71822 C...Require exactly two primary showerers for ME corrections.
71823  nprim=0
71824  IF(ipart1.GT.0) THEN
71825  DO 250 i=1,n
71826  IF(k(i,3).EQ.ipart1.AND.k(i,2).NE.k(ipart1,2)) nprim=nprim+1
71827  250 CONTINUE
71828  ENDIF
71829  IF(nprim.NE.2) THEN
71830 
71831 C...Predetermined and default matrix element kinds.
71832  ELSEIF(mstj(38).NE.0) THEN
71833  m3jc=mstj(38)
71834  alpha=parj(80)
71835  mstj(38)=0
71836  ELSEIF(mstj(47).GE.6) THEN
71837  m3jc=mstj(47)
71838  ELSE
71839  iclass=1
71840  icombi=4
71841 
71842 C...Vector/axial vector -> q + qbar; q -> q + V.
71843  IF(itypmn.EQ.1.AND.itypmx.EQ.1.AND.(itypes.EQ.0.OR.
71844  & itypes.EQ.3)) THEN
71845  iclass=2
71846  IF(kfsrce.EQ.21.OR.kfsrce.EQ.22) THEN
71847  icombi=1
71848  ELSEIF(kfsrce.EQ.23.OR.(kfsrce.EQ.0.AND.
71849  & k(ipart(1),2)+k(ipart(2),2).EQ.0)) THEN
71850 C...gamma*/Z0: assume e+e- initial state if unknown.
71851  ei=-1d0
71852  IF(kfsrce.EQ.23) THEN
71853  iannfl=ipart1
71854  IF(k(iannfl,2).EQ.23) iannfl=k(iannfl,3)
71855  IF(iannfl.GT.0) THEN
71856  IF(k(iannfl,2).EQ.23) iannfl=k(iannfl,3)
71857  ENDIF
71858  IF(iannfl.NE.0) THEN
71859  kannfl=iabs(k(iannfl,2))
71860  IF(kannfl.GE.1.AND.kannfl.LE.18) ei=kchg(kannfl,1)/3d0
71861  ENDIF
71862  ENDIF
71863  ai=sign(1d0,ei+0.1d0)
71864  vi=ai-4d0*ei*paru(102)
71865  ef=kchg(kfla1,1)/3d0
71866  af=sign(1d0,ef+0.1d0)
71867  vf=af-4d0*ef*paru(102)
71868  xwc=1d0/(16d0*paru(102)*(1d0-paru(102)))
71869  sh=psum(5)**2
71870  sqmz=pmas(23,1)**2
71871  sqwz=psum(5)*pmas(23,2)
71872  sbwz=1d0/((sh-sqmz)**2+sqwz**2)
71873  vect=ei**2*ef**2+2d0*ei*vi*ef*vf*xwc*sh*(sh-sqmz)*sbwz+
71874  & (vi**2+ai**2)*vf**2*xwc**2*sh**2*sbwz
71875  axiv=(vi**2+ai**2)*af**2*xwc**2*sh**2*sbwz
71876  icombi=3
71877  alpha=vect/(vect+axiv)
71878  ELSEIF(kfsrce.EQ.24.OR.kfsrce.EQ.0) THEN
71879  icombi=4
71880  ENDIF
71881 C...For chi -> chi q qbar, use V/A -> q qbar as first approximation.
71882  ELSEIF(itypmn.EQ.1.AND.itypmx.EQ.1.AND.itypes.EQ.5) THEN
71883  iclass=2
71884  ELSEIF(itypmn.EQ.1.AND.itypmx.EQ.3.AND.(itypes.EQ.0.OR.
71885  & itypes.EQ.1)) THEN
71886  iclass=3
71887 
71888 C...Scalar/pseudoscalar -> q + qbar; q -> q + S.
71889  ELSEIF(itypmn.EQ.1.AND.itypmx.EQ.1.AND.itypes.EQ.4) THEN
71890  iclass=4
71891  IF(kfsrce.EQ.25.OR.kfsrce.EQ.35.OR.kfsrce.EQ.37) THEN
71892  icombi=1
71893  ELSEIF(kfsrce.EQ.36) THEN
71894  icombi=2
71895  ENDIF
71896  ELSEIF(itypmn.EQ.1.AND.itypmx.EQ.4.AND.(itypes.EQ.0.OR.
71897  & itypes.EQ.1)) THEN
71898  iclass=5
71899 
71900 C...V -> ~q + ~qbar; ~q -> ~q + V; S -> ~q + ~qbar; ~q -> ~q + S.
71901  ELSEIF(itypmn.EQ.2.AND.itypmx.EQ.2.AND.(itypes.EQ.0.OR.
71902  & itypes.EQ.3)) THEN
71903  iclass=6
71904  ELSEIF(itypmn.EQ.2.AND.itypmx.EQ.3.AND.(itypes.EQ.0.OR.
71905  & itypes.EQ.2)) THEN
71906  iclass=7
71907  ELSEIF(itypmn.EQ.2.AND.itypmx.EQ.2.AND.itypes.EQ.4) THEN
71908  iclass=8
71909  ELSEIF(itypmn.EQ.2.AND.itypmx.EQ.4.AND.(itypes.EQ.0.OR.
71910  & itypes.EQ.2)) THEN
71911  iclass=9
71912 
71913 C...chi -> q + ~qbar; ~q -> q + chi; q -> ~q + chi.
71914  ELSEIF(itypmn.EQ.1.AND.itypmx.EQ.2.AND.(itypes.EQ.0.OR.
71915  & itypes.EQ.5)) THEN
71916  iclass=10
71917  ELSEIF(itypmn.EQ.1.AND.itypmx.EQ.5.AND.(itypes.EQ.0.OR.
71918  & itypes.EQ.2)) THEN
71919  iclass=11
71920  ELSEIF(itypmn.EQ.2.AND.itypmx.EQ.5.AND.(itypes.EQ.0.OR.
71921  & itypes.EQ.1)) THEN
71922  iclass=12
71923 
71924 C...~g -> q + ~qbar; ~q -> q + ~g; q -> ~q + ~g.
71925  ELSEIF(itypmn.EQ.1.AND.itypmx.EQ.2.AND.itypes.EQ.6) THEN
71926  iclass=13
71927  ELSEIF(itypmn.EQ.1.AND.itypmx.EQ.6.AND.(itypes.EQ.0.OR.
71928  & itypes.EQ.2)) THEN
71929  iclass=14
71930  ELSEIF(itypmn.EQ.2.AND.itypmx.EQ.6.AND.(itypes.EQ.0.OR.
71931  & itypes.EQ.1)) THEN
71932  iclass=15
71933 
71934 C...g -> ~g + ~g (eikonal approximation).
71935  ELSEIF(itypmn.EQ.6.AND.itypmx.EQ.6.AND.itypes.EQ.0) THEN
71936  iclass=16
71937  ENDIF
71938  m3jc=5*iclass+icombi
71939  ENDIF
71940 
71941 C...Store pair that together define matrix element treatment.
71942  IF(m3jc.NE.0) THEN
71943  nmesys=1
71944  mesys(nmesys,0)=m3jc
71945  mesys(nmesys,1)=ipart(1)
71946  mesys(nmesys,2)=ipart(2)
71947  ENDIF
71948 
71949 C...Store qqbar or l+l- pairs for QED radiation.
71950  IF(kfla1.LE.18.AND.kfla2.LE.18) THEN
71951  nmesys=nmesys+1
71952  mesys(nmesys,0)=101
71953  IF(k(ipart(1),2)+k(ipart(2),2).EQ.0) mesys(nmesys,0)=102
71954  mesys(nmesys,1)=ipart(1)
71955  mesys(nmesys,2)=ipart(2)
71956  ENDIF
71957 
71958 C...Store other qqbar/l+l- pairs from g/gamma branchings.
71959  DO 290 i1=1,n
71960  IF(k(i1,1).GT.10.OR.iabs(k(i1,2)).GT.18) goto 290
71961  i1m=k(i1,3)
71962  260 IF(i1m.GT.0) THEN
71963  IF(k(i1m,2).EQ.k(i1,2)) THEN
71964  i1m=k(i1m,3)
71965  goto 260
71966  ENDIF
71967  ENDIF
71968 C...Move up this check to avoid out-of-bounds.
71969  IF(i1m.EQ.0) goto 290
71970  IF(k(i1m,2).NE.21.AND.k(i1m,2).NE.22) goto 290
71971  DO 280 i2=i1+1,n
71972  IF(k(i2,1).GT.10.OR.k(i2,2)+k(i1,2).NE.0) goto 280
71973  i2m=k(i2,3)
71974  270 IF(i2m.GT.0) THEN
71975  IF(k(i2m,2).EQ.k(i2,2)) THEN
71976  i2m=k(i2m,3)
71977  goto 270
71978  ENDIF
71979  ENDIF
71980  IF(i1m.EQ.i2m.AND.i1m.GT.0) THEN
71981  nmesys=nmesys+1
71982  mesys(nmesys,0)=66
71983  mesys(nmesys,1)=i1
71984  mesys(nmesys,2)=i2
71985  nmesys=nmesys+1
71986  mesys(nmesys,0)=102
71987  mesys(nmesys,1)=i1
71988  mesys(nmesys,2)=i2
71989  ENDIF
71990  280 CONTINUE
71991  290 CONTINUE
71992  ENDIF
71993 
71994 C..Loopback point for counting number of emissions.
71995  ngen=0
71996  300 ngen=ngen+1
71997 
71998 C...Begin loop to evolve all existing partons, if required.
71999  310 imx=0
72000  pt2mx=0d0
72001  DO 380 ievol=1,nevol
72002  IF(iflg(ievol).EQ.0) THEN
72003 
72004 C...Basic info on radiator and recoil.
72005  i=ipos(ievol)
72006  ir=irec(ievol)
72007  sht=shat(i,ir)
72008  pm2i=p(i,5)**2
72009  pm2r=p(ir,5)**2
72010 
72011 C...Skip any particles that are "turned off"
72012  IF (mstj(39).GT.0.AND.iabs(k(i,2)).EQ.mstj(39)) goto 380
72013 
72014 C...Invariant mass of "dipole".Starting value for pT evolution.
72015  shtcor=(sqrt(sht)-p(ir,5))**2-pm2i
72016  pt2=min(pt2cmx,0.25d0*shtcor,ptsca(ievol)**2)
72017 
72018 C...Case of evolution by QCD branching.
72019  IF(iscol(ievol).NE.0) THEN
72020 
72021 C...Parton-by-parton maximum scale from initial conditions.
72022  IF(mstp(72).EQ.0) THEN
72023  DO 320 iprt=1,nparts
72024  IF(ir.EQ.ipart(iprt)) pt2=min(pt2,ptpart(iprt)**2)
72025  320 CONTINUE
72026  ENDIF
72027 
72028 C...If kinematically impossible then do not evolve.
72029  IF(pt2.LT.pt2cmn) THEN
72030  iflg(ievol)=-1
72031  goto 380
72032  ENDIF
72033 
72034 C...Check if part of system for which ME corrections should be applied.
72035  imesys=0
72036  DO 330 ime=1,nmesys
72037  IF((i.EQ.mesys(ime,1).OR.i.EQ.mesys(ime,2)).AND.
72038  & mesys(ime,0).LT.100) imesys=ime
72039  330 CONTINUE
72040 
72041 C...Special flag for colour octet states.
72042 C...MOCT=1: can do gluon splitting g->qqbar; MOCT=2: cannot.
72043  moct=0
72044  kc = pycomp(k(i,2))
72045  IF(k(i,2).EQ.21) THEN
72046  moct=1
72047  ELSEIF(kchg(kc,2).EQ.2) THEN
72048  moct=2
72049  ENDIF
72050 C...QUARKONIA++
72051  IF(mstp(148).GE.1.AND.iabs(k(i,2)).EQ.9900101.AND.
72052  & iabs(k(i,2)).LE.9910555) moct=2
72053 C...QUARKONIA--
72054 
72055 
72056 C...Upper estimate for matrix element weighting and colour factor.
72057 C...Note that g->gg and g->qqbar is split on two sides = "dipoles".
72058  wtpsgl=2d0
72059  colfac=4d0/3d0
72060  IF(moct.GE.1) colfac=3d0/2d0
72061  IF(iglui.EQ.1.AND.imesys.EQ.1.AND.moct.EQ.0) colfac=3d0
72062  wtpsqq=0.5d0*0.5d0*nflav
72063 
72064 C...Determine overestimated z range: switch at c and b masses.
72065  340 izrg=1
72066  pt2mne=pt2cmn
72067  b0=27d0/6d0
72068  alams=alam3s
72069  IF(pt2.GT.1.01d0*pmcs) THEN
72070  izrg=2
72071  pt2mne=pmcs
72072  b0=25d0/6d0
72073  alams=alam4s
72074  ENDIF
72075  IF(pt2.GT.1.01d0*pmbs) THEN
72076  izrg=3
72077  pt2mne=pmbs
72078  b0=23d0/6d0
72079  alams=alam5s
72080  ENDIF
72081  zmncut=0.5d0-sqrt(max(0d0,0.25d0-pt2mne/shtcor))
72082  IF(zmncut.LT.1d-8) zmncut=pt2mne/shtcor
72083 
72084 C...Find evolution coefficients for q->qg/g->gg and g->qqbar.
72085  evemgl=wtpsgl*colfac*log(1d0/zmncut-1d0)/b0
72086  evcoef=evemgl
72087  IF(moct.EQ.1) THEN
72088  evemqq=wtpsqq*(1d0-2d0*zmncut)/b0
72089  evcoef=evcoef+evemqq
72090  ENDIF
72091 
72092 C...Pick pT2 (in overestimated z range).
72093  350 pt2=alams*(pt2/alams)**(pyr(0)**(1d0/evcoef))
72094 
72095 C...Loopback if crossed c/b mass thresholds.
72096  IF(izrg.EQ.3.AND.pt2.LT.pmbs) THEN
72097  pt2=pmbs
72098  goto 340
72099  ENDIF
72100  IF(izrg.EQ.2.AND.pt2.LT.pmcs) THEN
72101  pt2=pmcs
72102  goto 340
72103  ENDIF
72104 
72105 C...Finish if below lower cutoff.
72106  IF(pt2.LT.pt2cmn) THEN
72107  iflg(ievol)=-1
72108  goto 380
72109  ENDIF
72110 
72111 C...Pick kind of branching: q->qg/g->gg/X->Xg or g->qqbar.
72112 C...IFLAG=1: gluon emission; IFLAG=2: gluon splitting
72113  iflag=1
72114  IF(moct.EQ.1.AND.evemgl.LT.pyr(0)*evcoef) iflag=2
72115 
72116 C...Pick z: dz/(1-z) or dz.
72117  IF(iflag.EQ.1) THEN
72118  z=1d0-zmncut*(1d0/zmncut-1d0)**pyr(0)
72119  ELSE
72120  z=zmncut+pyr(0)*(1d0-2d0*zmncut)
72121  ENDIF
72122 
72123 C...Loopback if outside allowed range for given pT2.
72124  zmnnow=0.5d0-sqrt(max(0d0,0.25d0-pt2/shtcor))
72125  IF(zmnnow.LT.1d-8) zmnnow=pt2/shtcor
72126  IF(z.LE.zmnnow.OR.z.GE.1d0-zmnnow) goto 350
72127  pm2=pm2i+pt2/(z*(1d0-z))
72128  IF(z*(1d0-z).LE.pm2*sht/(sht+pm2-pm2r)**2) goto 350
72129 
72130 C...No weighting for primary partons; to be done later on.
72131  IF(imesys.GT.0) THEN
72132 
72133 C...Weighting of q->qg/X->Xg branching.
72134  ELSEIF(iflag.EQ.1.AND.moct.NE.1) THEN
72135  IF(1d0+z**2.LT.wtpsgl*pyr(0)) goto 350
72136 
72137 C...Weighting of g->gg branching.
72138  ELSEIF(iflag.EQ.1) THEN
72139  IF(1d0+z**3.LT.wtpsgl*pyr(0)) goto 350
72140 
72141 C...Flavour choice and weighting of g->qqbar branching.
72142  ELSE
72143  kfq=min(5,1+int(nflav*pyr(0)))
72144  pmq=pmas(kfq,1)
72145  rootqq=sqrt(max(0d0,1d0-4d0*pmq**2/pm2))
72146  wtme=rootqq*(z**2+(1d0-z)**2)
72147  IF(wtme.LT.pyr(0)) goto 350
72148  iflag=10+kfq
72149  ENDIF
72150 
72151 C...Case of evolution by QED branching.
72152  ELSEIF(ischg(ievol).NE.0) THEN
72153 
72154 C...If kinematically impossible then do not evolve.
72155  pt2emn=pt0eq**2
72156  IF(iabs(k(i,2)).GT.10) pt2emn=pt0el**2
72157  IF(pt2.LT.pt2emn) THEN
72158  iflg(ievol)=-1
72159  goto 380
72160  ENDIF
72161 
72162 C...Check if part of system for which ME corrections should be applied.
72163  imesys=0
72164  DO 360 ime=1,nmesys
72165  IF((i.EQ.mesys(ime,1).OR.i.EQ.mesys(ime,2)).AND.
72166  & mesys(ime,0).GT.100) imesys=ime
72167  360 CONTINUE
72168 
72169 C...Charge. Matrix element weighting factor.
72170  chg=ischg(ievol)/3d0
72171  wtpsga=2d0
72172 
72173 C...Determine overestimated z range. Find evolution coefficient.
72174  zmncut=0.5d0-sqrt(max(0d0,0.25d0-pt2emn/shtcor))
72175  IF(zmncut.LT.1d-8) zmncut=pt2emn/shtcor
72176  evcoef=aem2pi*chg**2*wtpsga*log(1d0/zmncut-1d0)
72177 
72178 C...Pick pT2 (in overestimated z range).
72179  370 pt2=pt2*pyr(0)**(1d0/evcoef)
72180 
72181 C...Finish if below lower cutoff.
72182  IF(pt2.LT.pt2emn) THEN
72183  iflg(ievol)=-1
72184  goto 380
72185  ENDIF
72186 
72187 C...Pick z: dz/(1-z).
72188  z=1d0-zmncut*(1d0/zmncut-1d0)**pyr(0)
72189 
72190 C...Loopback if outside allowed range for given pT2.
72191  zmnnow=0.5d0-sqrt(max(0d0,0.25d0-pt2/shtcor))
72192  IF(zmnnow.LT.1d-8) zmnnow=pt2/shtcor
72193  IF(z.LE.zmnnow.OR.z.GE.1d0-zmnnow) goto 370
72194  pm2=pm2i+pt2/(z*(1d0-z))
72195  IF(z*(1d0-z).LE.pm2*sht/(sht+pm2-pm2r)**2) goto 370
72196 
72197 C...Weighting by branching kernel, except if ME weighting later.
72198  IF(imesys.EQ.0) THEN
72199  IF(1d0+z**2.LT.wtpsga*pyr(0)) goto 370
72200  ENDIF
72201  iflag=3
72202  ENDIF
72203 
72204 C...Save acceptable branching.
72205  iflg(ievol)=iflag
72206  imesav(ievol)=imesys
72207  pt2sav(ievol)=pt2
72208  zsav(ievol)=z
72209  shtsav(ievol)=sht
72210  ENDIF
72211 
72212 C...Check if branching has highest pT.
72213  IF(iflg(ievol).GE.1.AND.pt2sav(ievol).GT.pt2mx) THEN
72214  imx=ievol
72215  pt2mx=pt2sav(ievol)
72216  ENDIF
72217  380 CONTINUE
72218 
72219 C...Finished if no more branchings to be done.
72220  IF(imx.EQ.0) goto 520
72221 
72222 C...Restore info on hardest branching to be processed.
72223  i=ipos(imx)
72224  ir=irec(imx)
72225  kcol=iscol(imx)
72226  kcha=ischg(imx)
72227  imesys=imesav(imx)
72228  pt2=pt2sav(imx)
72229  z=zsav(imx)
72230  sht=shtsav(imx)
72231  pm2i=p(i,5)**2
72232  pm2r=p(ir,5)**2
72233  pm2=pm2i+pt2/(z*(1d0-z))
72234 
72235 C...Special flag for colour octet states.
72236  moct=0
72237  kc = pycomp(k(i,2))
72238  IF(k(i,2).EQ.21) THEN
72239  moct=1
72240  ELSEIF(kchg(kc,2).EQ.2) THEN
72241  moct=2
72242  ENDIF
72243 C...QUARKONIA++
72244  IF(mstp(148).GE.1.AND.iabs(k(i,2)).GE.9900101.AND.
72245  & iabs(k(i,2)).LE.9910555) moct=2
72246 C...QUARKONIA--
72247 
72248 C...Restore further info for g->qqbar branching.
72249  kfq=0
72250  IF(iflg(imx).GT.10) THEN
72251  kfq=iflg(imx)-10
72252  pmq=pmas(kfq,1)
72253  rootqq=sqrt(max(0d0,1d0-4d0*pmq**2/pm2))
72254  ENDIF
72255 
72256 C...For branching g include azimuthal asymmetries from polarization.
72257  asypol=0d0
72258  IF(moct.EQ.1.AND.mod(mstj(46),2).EQ.1) THEN
72259 C...Trace grandmother via intermediate recoil copies.
72260  kfgm=0
72261  im=i
72262  390 IF(k(im,3).NE.k(im-1,3).AND.k(im,3).NE.k(im+1,3).AND.
72263  & k(im,3).GT.0) THEN
72264  im=k(im,3)
72265  IF(im.GT.mint(84)) goto 390
72266  ENDIF
72267  igm=k(im,3)
72268  IF(igm.GT.mint(84).AND.igm.LT.im.AND.im.LE.i)
72269  & kfgm=iabs(k(igm,2))
72270 C...Define approximate energy sharing by identifying aunt.
72271  iau=im+1
72272  IF(iau.GT.n-3.OR.k(iau,3).NE.igm) iau=im-1
72273  IF(kfgm.NE.0.AND.(kfgm.LE.6.OR.kfgm.EQ.21)) THEN
72274  zold=p(im,4)/(p(im,4)+p(iau,4))
72275 C...Coefficient from gluon production.
72276  IF(kfgm.LE.6) THEN
72277  asypol=2d0*(1d0-zold)/(1d0+(1d0-zold)**2)
72278  ELSE
72279  asypol=((1d0-zold)/(1d0-zold*(1d0-zold)))**2
72280  ENDIF
72281 C...Coefficient from gluon decay.
72282  IF(kfq.EQ.0) THEN
72283  asypol=asypol*(z*(1d0-z)/(1d0-z*(1d0-z)))**2
72284  ELSE
72285  asypol=-asypol*2d0*z*(1d0-z)/(1d0-2d0*z*(1d0-z))
72286  ENDIF
72287  ENDIF
72288  ENDIF
72289 
72290 C...Create new slots for branching products and recoil.
72291  inew=n+1
72292  ignew=n+2
72293  irnew=n+3
72294  n=n+3
72295 
72296 C...Set status, flavour and mother of new ones.
72297  k(inew,1)=k(i,1)
72298  k(ignew,1)=3
72299  IF(kcha.NE.0) k(ignew,1)=1
72300  k(irnew,1)=k(ir,1)
72301  IF(kfq.EQ.0) THEN
72302  k(inew,2)=k(i,2)
72303  k(ignew,2)=21
72304  IF(kcha.NE.0) k(ignew,2)=22
72305  ELSE
72306  k(inew,2)=-isign(kfq,kcol)
72307  k(ignew,2)=-k(inew,2)
72308  ENDIF
72309  k(irnew,2)=k(ir,2)
72310  k(inew,3)=i
72311  k(ignew,3)=i
72312  k(irnew,3)=ir
72313 
72314 C...Find rest frame and angles of branching+recoil.
72315  DO 400 j=1,5
72316  p(inew,j)=p(i,j)
72317  p(ignew,j)=0d0
72318  p(irnew,j)=p(ir,j)
72319  400 CONTINUE
72320  betax=(p(inew,1)+p(irnew,1))/(p(inew,4)+p(irnew,4))
72321  betay=(p(inew,2)+p(irnew,2))/(p(inew,4)+p(irnew,4))
72322  betaz=(p(inew,3)+p(irnew,3))/(p(inew,4)+p(irnew,4))
72323  CALL pyrobo(inew,irnew,0d0,0d0,-betax,-betay,-betaz)
72324  phi=pyangl(p(inew,1),p(inew,2))
72325  theta=pyangl(p(inew,3),sqrt(p(inew,1)**2+p(inew,2)**2))
72326 
72327 C...Derive kinematics of branching: generics (like g->gg).
72328  DO 410 j=1,4
72329  p(inew,j)=0d0
72330  p(irnew,j)=0d0
72331  410 CONTINUE
72332  pem=0.5d0*(sht+pm2-pm2r)/sqrt(sht)
72333  pzm=0.5d0*sqrt(max(0d0,(sht-pm2-pm2r)**2-4d0*pm2*pm2r)/sht)
72334  pt2cor=pm2*(pem**2*z*(1d0-z)-0.25d0*pm2)/pzm**2
72335  ptcor=sqrt(max(0d0,pt2cor))
72336  pzn=(pem**2*z-0.5d0*pm2)/pzm
72337  pzg=(pem**2*(1d0-z)-0.5d0*pm2)/pzm
72338 C...Specific kinematics reduction for q->qg with m_q > 0.
72339  IF(moct.NE.1) THEN
72340  ptcor=(1d0-pm2i/pm2)*ptcor
72341  pzn=pzn+pm2i*pzg/pm2
72342  pzg=(1d0-pm2i/pm2)*pzg
72343 C...Specific kinematics reduction for g->qqbar with m_q > 0.
72344  ELSEIF(kfq.NE.0) THEN
72345  p(inew,5)=pmq
72346  p(ignew,5)=pmq
72347  ptcor=rootqq*ptcor
72348  pzn=0.5d0*((1d0+rootqq)*pzn+(1d0-rootqq)*pzg)
72349  pzg=pzm-pzn
72350  ENDIF
72351 
72352 C...Pick phi and construct kinematics of branching.
72353  420 phirot=paru(2)*pyr(0)
72354  p(inew,1)=ptcor*cos(phirot)
72355  p(inew,2)=ptcor*sin(phirot)
72356  p(inew,3)=pzn
72357  p(inew,4)=sqrt(ptcor**2+p(inew,3)**2+p(inew,5)**2)
72358  p(ignew,1)=-p(inew,1)
72359  p(ignew,2)=-p(inew,2)
72360  p(ignew,3)=pzg
72361  p(ignew,4)=sqrt(ptcor**2+p(ignew,3)**2+p(ignew,5)**2)
72362  p(irnew,1)=0d0
72363  p(irnew,2)=0d0
72364  p(irnew,3)=-pzm
72365  p(irnew,4)=0.5d0*(sht+pm2r-pm2)/sqrt(sht)
72366 
72367 C...Boost branching system to lab frame.
72368  CALL pyrobo(inew,irnew,theta,phi,betax,betay,betaz)
72369 
72370 C...Renew choice of phi angle according to polarization asymmetry.
72371  IF(abs(asypol).GT.1d-3) THEN
72372  DO 430 j=1,3
72373  dpt(1,j)=p(i,j)
72374  dpt(2,j)=p(iau,j)
72375  dpt(3,j)=p(inew,j)
72376  430 CONTINUE
72377  dpma=dpt(1,1)*dpt(2,1)+dpt(1,2)*dpt(2,2)+dpt(1,3)*dpt(2,3)
72378  dpmd=dpt(1,1)*dpt(3,1)+dpt(1,2)*dpt(3,2)+dpt(1,3)*dpt(3,3)
72379  dpmm=dpt(1,1)**2+dpt(1,2)**2+dpt(1,3)**2
72380  DO 440 j=1,3
72381  dpt(4,j)=dpt(2,j)-dpma*dpt(1,j)/max(1d-10,dpmm)
72382  dpt(5,j)=dpt(3,j)-dpmd*dpt(1,j)/max(1d-10,dpmm)
72383  440 CONTINUE
72384  dpt(4,4)=sqrt(dpt(4,1)**2+dpt(4,2)**2+dpt(4,3)**2)
72385  dpt(5,4)=sqrt(dpt(5,1)**2+dpt(5,2)**2+dpt(5,3)**2)
72386  IF(min(dpt(4,4),dpt(5,4)).GT.0.1d0*parj(82)) THEN
72387  cad=(dpt(4,1)*dpt(5,1)+dpt(4,2)*dpt(5,2)+
72388  & dpt(4,3)*dpt(5,3))/(dpt(4,4)*dpt(5,4))
72389  IF(1d0+asypol*(2d0*cad**2-1d0).LT.pyr(0)*(1d0+abs(asypol)))
72390  & goto 420
72391  ENDIF
72392  ENDIF
72393 
72394 C...Matrix element corrections for primary partons when requested.
72395  IF(imesys.GT.0) THEN
72396  m3jc=mesys(imesys,0)
72397 
72398 C...Identify recoiling partner and set up three-body kinematics.
72399  irp=mesys(imesys,1)
72400  IF(irp.EQ.i) irp=mesys(imesys,2)
72401  IF(irp.EQ.ir) irp=irnew
72402  DO 450 j=1,4
72403  psum(j)=p(inew,j)+p(irp,j)+p(ignew,j)
72404  450 CONTINUE
72405  psum(5)=sqrt(max(0d0,psum(4)**2-psum(1)**2-psum(2)**2-
72406  & psum(3)**2))
72407  x1=2d0*(psum(4)*p(inew,4)-psum(1)*p(inew,1)-psum(2)*p(inew,2)-
72408  & psum(3)*p(inew,3))/psum(5)**2
72409  x2=2d0*(psum(4)*p(irp,4)-psum(1)*p(irp,1)-psum(2)*p(irp,2)-
72410  & psum(3)*p(irp,3))/psum(5)**2
72411  x3=2d0-x1-x2
72412  r1me=p(inew,5)/psum(5)
72413  r2me=p(irp,5)/psum(5)
72414 
72415 C...Matrix elements for gluon emission.
72416  IF(m3jc.LT.100) THEN
72417 
72418 C...Call ME, with right order important for two inequivalent showerers.
72419  IF(mesys(imesys,iord).EQ.i) THEN
72420  wme=pymael(m3jc,x1,x2,r1me,r2me,alpha)
72421  ELSE
72422  wme=pymael(m3jc,x2,x1,r2me,r1me,alpha)
72423  ENDIF
72424 
72425 C...Split up total ME when two radiating partons.
72426  isprad=1
72427  IF((m3jc.GE.16.AND.m3jc.LE.19).OR.(m3jc.GE.26.AND.m3jc.LE.29)
72428  & .OR.(m3jc.GE.36.AND.m3jc.LE.39).OR.(m3jc.GE.46.AND.m3jc.LE.49)
72429  & .OR.(m3jc.GE.56.AND.m3jc.LE.64)) isprad=0
72430  IF(isprad.EQ.1) wme=wme*max(1d-10,1d0+r1me**2-r2me**2-x1)/
72431  & max(1d-10,2d0-x1-x2)
72432 
72433 C...Evaluate shower rate.
72434  wps=2d0/(max(1d-10,2d0-x1-x2)*
72435  & max(1d-10,1d0+r2me**2-r1me**2-x2))
72436  IF(iglui.EQ.1) wps=(9d0/4d0)*wps
72437 
72438 C...Matrix elements for photon emission: still rather primitive.
72439  ELSE
72440 
72441 C...For generic charge combination currently only massless expression.
72442  IF(m3jc.EQ.101) THEN
72443  chg1=kchg(pycomp(k(i,2)),1)*isign(1,k(i,2))/3d0
72444  chg2=kchg(pycomp(k(irp,2)),1)*isign(1,k(irp,2))/3d0
72445  wme=(chg1*(1d0-x1)/x3-chg2*(1d0-x2)/x3)**2*(x1**2+x2**2)
72446  wps=2d0*(chg1**2*(1d0-x1)/x3+chg2**2*(1d0-x2)/x3)
72447 
72448 C...For flavour neutral system assume vector source and include masses.
72449  ELSE
72450  wme=pymael(11,x1,x2,r1me,r2me,0d0)*max(1d-10,
72451  & 1d0+r1me**2-r2me**2-x1)/max(1d-10,2d0-x1-x2)
72452  wps=2d0/(max(1d-10,2d0-x1-x2)*
72453  & max(1d-10,1d0+r2me**2-r1me**2-x2))
72454  ENDIF
72455  ENDIF
72456 
72457 C...Perform weighting with W_ME/W_PS.
72458  IF(wme.LT.pyr(0)*wps) THEN
72459  n=n-3
72460  iflg(imx)=0
72461  pt2cmx=pt2
72462  goto 310
72463  ENDIF
72464  ENDIF
72465 
72466 C...Now for sure accepted branching. Save highest pT.
72467  IF(ngen.EQ.1) ptgen=sqrt(pt2)
72468 
72469 C...Update status for obsolete ones. Bookkkep the moved original parton
72470 C...and new daughter (arbitrary choice for g->gg or g->qqbar).
72471 C...Do not bookkeep radiated photon, since it cannot radiate further.
72472  k(i,1)=k(i,1)+10
72473  k(ir,1)=k(ir,1)+10
72474  DO 460 ip=1,npart
72475  IF(ipart(ip).EQ.i) ipart(ip)=inew
72476  IF(ipart(ip).EQ.ir) ipart(ip)=irnew
72477  460 CONTINUE
72478  IF(kcha.EQ.0) THEN
72479  npart=npart+1
72480  ipart(npart)=ignew
72481  ENDIF
72482 
72483 C...Initialize colour flow of branching.
72484 C...Use both old and new style colour tags for flexibility.
72485  k(inew,4)=0
72486  k(ignew,4)=0
72487  k(inew,5)=0
72488  k(ignew,5)=0
72489  jcolp=4+(1-kcol)/2
72490  jcoln=9-jcolp
72491  mct(inew,1)=0
72492  mct(inew,2)=0
72493  mct(ignew,1)=0
72494  mct(ignew,2)=0
72495  mct(irnew,1)=0
72496  mct(irnew,2)=0
72497 
72498 C...Trivial colour flow for l->lgamma and q->qgamma.
72499  IF(iabs(kcha).EQ.3) THEN
72500  k(i,4)=inew
72501  k(i,5)=ignew
72502  ELSEIF(kcha.NE.0) THEN
72503  IF(k(i,4).NE.0) THEN
72504  k(i,4)=k(i,4)+inew
72505  k(inew,4)=mstu(5)*i
72506  mct(inew,1)=mct(i,1)
72507  ENDIF
72508  IF(k(i,5).NE.0) THEN
72509  k(i,5)=k(i,5)+inew
72510  k(inew,5)=mstu(5)*i
72511  mct(inew,2)=mct(i,2)
72512  ENDIF
72513 
72514 C...Set colour flow for q->qg and g->gg.
72515  ELSEIF(kfq.EQ.0) THEN
72516  k(i,jcolp)=k(i,jcolp)+ignew
72517  k(ignew,jcolp)=mstu(5)*i
72518  k(inew,jcolp)=mstu(5)*ignew
72519  k(ignew,jcoln)=mstu(5)*inew
72520  mct(ignew,jcolp-3)=mct(i,jcolp-3)
72521  nct=nct+1
72522  mct(inew,jcolp-3)=nct
72523  mct(ignew,jcoln-3)=nct
72524  IF(moct.GE.1) THEN
72525  k(i,jcoln)=k(i,jcoln)+inew
72526  k(inew,jcoln)=mstu(5)*i
72527  mct(inew,jcoln-3)=mct(i,jcoln-3)
72528  ENDIF
72529 
72530 C...Set colour flow for g->qqbar.
72531  ELSE
72532  k(i,jcoln)=k(i,jcoln)+inew
72533  k(inew,jcoln)=mstu(5)*i
72534  k(i,jcolp)=k(i,jcolp)+ignew
72535  k(ignew,jcolp)=mstu(5)*i
72536  mct(inew,jcoln-3)=mct(i,jcoln-3)
72537  mct(ignew,jcolp-3)=mct(i,jcolp-3)
72538  ENDIF
72539 
72540 C...Daughter info for colourless recoiling parton.
72541  IF(k(ir,4).EQ.0.AND.k(ir,5).EQ.0) THEN
72542  k(ir,4)=irnew
72543  k(ir,5)=irnew
72544  k(irnew,4)=0
72545  k(irnew,5)=0
72546 
72547 C...Colour of recoiling parton sails through unchanged.
72548  ELSE
72549  IF(k(ir,4).NE.0) THEN
72550  k(ir,4)=k(ir,4)+irnew
72551  k(irnew,4)=mstu(5)*ir
72552  mct(irnew,1)=mct(ir,1)
72553  ENDIF
72554  IF(k(ir,5).NE.0) THEN
72555  k(ir,5)=k(ir,5)+irnew
72556  k(irnew,5)=mstu(5)*ir
72557  mct(irnew,2)=mct(ir,2)
72558  ENDIF
72559  ENDIF
72560 
72561 C...Vertex information trivial.
72562  DO 470 j=1,5
72563  v(inew,j)=v(i,j)
72564  v(ignew,j)=v(i,j)
72565  v(irnew,j)=v(ir,j)
72566  470 CONTINUE
72567 
72568 C...Update list of old radiators.
72569  DO 480 ievol=1,nevol
72570 C... A) radiator-recoiler mother pair for this branching
72571  IF(ipos(ievol).EQ.i.AND.irec(ievol).EQ.ir) THEN
72572  ipos(ievol)=inew
72573 C... A2) QCD branching and color side matches, radiated parton follows recoiler
72574  IF(kcol.NE.0.AND.iscol(ievol).EQ.kcol) ipos(ievol)=ignew
72575  irec(ievol)=irnew
72576  iflg(ievol)=0
72577  ELSEIF(ipos(ievol).EQ.i) THEN
72578 C... B) other dipoles with I as radiator simply get INEW as new radiator
72579  ipos(ievol)=inew
72580  iflg(ievol)=0
72581  ELSEIF(ipos(ievol).EQ.ir.AND.irec(ievol).EQ.i) THEN
72582 C... C) the "mirror image" of the parent dipole
72583  ipos(ievol)=irnew
72584  irec(ievol)=inew
72585 C... C2) QCD branching and color side matches, radiated parton follows recoiler
72586  IF(kcol.NE.0.AND.iscol(ievol).NE.kcol.AND.iscol(ievol).NE.0)
72587  & irec(ievol)=ignew
72588  iflg(ievol)=0
72589  ELSEIF(ipos(ievol).EQ.ir) THEN
72590 C... D) other dipoles with IR as radiator simply get IRNEW as new radiator
72591  ipos(ievol)=irnew
72592  iflg(ievol)=0
72593  ENDIF
72594 C... Update links of old connected partons.
72595  IF(irec(ievol).EQ.i) THEN
72596  irec(ievol)=inew
72597  iflg(ievol)=0
72598  ELSEIF(irec(ievol).EQ.ir) THEN
72599  irec(ievol)=irnew
72600  iflg(ievol)=0
72601  ENDIF
72602  480 CONTINUE
72603 
72604 C...q->qg or g->gg: create new gluon radiators.
72605  IF(kcol.NE.0.AND.kfq.EQ.0) THEN
72606  nevol=nevol+1
72607  ipos(nevol)=inew
72608  irec(nevol)=ignew
72609  iflg(nevol)=0
72610  iscol(nevol)=kcol
72611  ischg(nevol)=0
72612  ptsca(nevol)=sqrt(pt2)
72613  nevol=nevol+1
72614  ipos(nevol)=ignew
72615  irec(nevol)=inew
72616  iflg(nevol)=0
72617  iscol(nevol)=-kcol
72618  ischg(nevol)=0
72619  ptsca(nevol)=ptsca(nevol-1)
72620 C...g->qqbar: create new photon radiators.
72621  ELSEIF(kcol.EQ.2.AND.kfq.NE.0) THEN
72622  nevol=nevol+1
72623  ipos(nevol)=inew
72624  irec(nevol)=ignew
72625  iflg(nevol)=0
72626  iscol(nevol)=0
72627  ischg(nevol)=pyk(inew,6)
72628  ptsca(nevol)=sqrt(pt2)
72629  nevol=nevol+1
72630  ipos(nevol)=ignew
72631  irec(nevol)=inew
72632  iflg(nevol)=0
72633  iscol(nevol)=0
72634  ischg(nevol)=pyk(ignew,6)
72635  ptsca(nevol)=sqrt(pt2)
72636  CALL pylist(4)
72637  print*, 'created new QED dipole ',inew,'<->',ignew
72638  ENDIF
72639 
72640 C...Check color and charge connections,
72641 C...Rewire if better partners can be found (screening, etc)
72642  DO 500 ievol=1,nevol
72643  kcol = iscol(ievol)
72644  kcha = ischg(ievol)
72645  irtmp = irec(ievol)
72646  itmp = ipos(ievol)
72647 C...Do not modify QED dipoles
72648  IF (kcha.NE.0) THEN
72649  goto 500
72650 C...Also skip dipole ends that are switched off
72651  ELSEIF (iflg(ievol).LE.-1) THEN
72652  goto 500
72653  ELSEIF (kcol.NE.0) THEN
72654 C...QCD dipoles. Check if current recoiler has appropriate color charge
72655  kcolr = pyk(irtmp,12)
72656  IF (kcolr.EQ.2.OR.kcolr.EQ.-kcol) goto 500
72657 C...If not, look for closest recoiler with appropriate color charge
72658  rm2min = psum(5)**2
72659  jmx = 0
72660  isgood = 0
72661  DO 490 jevol=1,nevol
72662 C...Skip self
72663  IF (jevol.EQ.ievol) goto 490
72664  jtmp = ipos(jevol)
72665  IF (jtmp.EQ.itmp) goto 490
72666  jcol = iscol(jevol)
72667 C...Skip dipole ends that are switched off
72668  IF (iflg(jevol).LE.-1) goto 490
72669 C...Skip QED dipole ends
72670  IF (ischg(jevol).NE.0) goto 490
72671 C... Skip wrong-color if at least one correct-color partner already found
72672  IF (isgood.NE.0.AND.jcol.NE.-kcol.AND.jcol.NE.2) goto 490
72673 C...Accept if smallest m2 so far, or if first with correct color
72674  rm2 = dotp(itmp,jtmp)
72675  isgnow = 0
72676  IF (jcol.EQ.-kcol.OR.jcol.EQ.2) isgnow=1
72677  IF (rm2.LT.rm2min.OR.isgnow.GT.isgood) THEN
72678  isgood = isgnow
72679  rm2min = rm2
72680  jmx = jevol
72681  ENDIF
72682  490 CONTINUE
72683 C...Update recoiler and reset dipole if new best partner found
72684  IF (jmx.NE.0) THEN
72685  irec(ievol) = ipos(jmx)
72686  iflg(ievol) = 0
72687  ENDIF
72688  ENDIF
72689  500 CONTINUE
72690 
72691 C...TMP! print out list of dipoles
72692 C DO 580 IEVOL=1,NEVOL
72693 C KCHA = ISCHG(IEVOL)
72694 C IF (KCHA.NE.0) THEN
72695 C print*, 'qed dip',IPOS(IEVOL),IREC(IEVOL)
72696 C ELSE
72697 C print*, 'qcd dip',IPOS(IEVOL),IREC(IEVOL)
72698 C ENDIF
72699 C 580 CONTINUE
72700 
72701 C...Update matrix elements parton list and add new for g/gamma->qqbar.
72702  DO 510 ime=1,nmesys
72703  IF(mesys(ime,1).EQ.i) mesys(ime,1)=inew
72704  IF(mesys(ime,2).EQ.i) mesys(ime,2)=inew
72705  IF(mesys(ime,1).EQ.ir) mesys(ime,1)=irnew
72706  IF(mesys(ime,2).EQ.ir) mesys(ime,2)=irnew
72707  510 CONTINUE
72708  IF(kfq.NE.0) THEN
72709  nmesys=nmesys+1
72710  mesys(nmesys,0)=66
72711  mesys(nmesys,1)=inew
72712  mesys(nmesys,2)=ignew
72713  nmesys=nmesys+1
72714  mesys(nmesys,0)=102
72715  mesys(nmesys,1)=inew
72716  mesys(nmesys,2)=ignew
72717  ENDIF
72718 
72719 C...Global statistics.
72720  mint(353)=mint(353)+1
72721  vint(353)=vint(353)+ptcor
72722  IF (mint(353).EQ.1) vint(358)=ptcor
72723 
72724 C...Loopback for more emissions if enough space.
72725  pt2cmx=pt2
72726  IF(npart.LT.maxnur-1.AND.nevol.LT.2*maxnur-2.AND.
72727  &nmesys.LT.maxnur-2.AND.n.LT.mstu(4)-mstu(32)-5) THEN
72728  goto 300
72729  ELSE
72730  CALL pyerrm(11,'(PYPTFS:) no more memory left for shower')
72731  ENDIF
72732 
72733 C...Done.
72734  520 CONTINUE
72735 
72736  RETURN
72737  END
72738 
72739 C*********************************************************************
72740 
72741 C...PYMAEL
72742 C...Auxiliary to PYSHOW and PYPTFS.
72743 C...Matrix elements for gluon (or photon) emission from
72744 C...a two-body state; to be used by the parton shower routine.
72745 C...Here X_i = 2 E_i/E_cm, R_i = m_i/E_cm and
72746 C...1/sigma_0 d(sigma)/d(x_1)d(x_2) =
72747 C... = (alpha-strong/2 pi) * CF * PYMAEL,
72748 C...i.e. normalization is such that one recovers the familiar
72749 C...(X1**2+X2**2)/((1-X1)*(1-X2)) for the massless case.
72750 C...Coupling structure:
72751 C...NI = 6- 9 : eikonal soft-gluon expression (spin-independent)
72752 C... = 11-14 : V -> q qbar (V = vector/axial vector colour singlet)
72753 C... = 16-19 : q -> q V
72754 C... = 21-24 : S -> q qbar (S = scalar/pseudoscalar colour singlet)
72755 C... = 26-29 : q -> q S
72756 C... = 31-34 : V -> ~q ~qbar (~q = squark)
72757 C... = 36-39 : ~q -> ~q V
72758 C... = 41-44 : S -> ~q ~qbar
72759 C... = 46-49 : ~q -> ~q S
72760 C... = 51-54 : chi -> q ~qbar (chi = neutralino/chargino)
72761 C... = 56-59 : ~q -> q chi
72762 C... = 61-64 : q -> ~q chi
72763 C... = 66-69 : ~g -> q ~qbar
72764 C... = 71-74 : ~q -> q ~g
72765 C... = 76-79 : q -> ~q ~g
72766 C... = 81-84 : (9/4)*(eikonal) for gg -> ~g ~g
72767 C...Note that the order of the decay products is important.
72768 C...In each set of four, the variants are ordered as:
72769 C...ICOMBI = 1 : pure non-gamma5, i.e. vector/scalar/...
72770 C... = 2 : pure gamma5, i.e. axial vector/pseudoscalar/....
72771 C... = 3 : mixture alpha*(ICOMBI=1) + (1-alpha)*(ICOMBI=2)
72772 C... = 4 : mixture (ICOMBI=1) +- (ICOMBI=2)
72773 
72774  FUNCTION pymael(NI,X1,X2,R1,R2,ALPHA)
72775 
72776 C...Double precision and integer declarations.
72777  IMPLICIT DOUBLE PRECISION(a-h, o-z)
72778  IMPLICIT INTEGER(i-n)
72779 
72780 C...Check input values. Return zero outside allowed phase space.
72781  pymael=0d0
72782  IF(x1.LE.2d0*r1.OR.x1.GE.1d0+r1**2-r2**2) RETURN
72783  IF(x2.LE.2d0*r2.OR.x2.GE.1d0+r2**2-r1**2) RETURN
72784  IF(x1+x2.LE.1d0+(r1+r2)**2) RETURN
72785  IF((2d0-2d0*x1-2d0*x2+x1*x2+2d0*r1**2+2d0*r2**2)**2.GE.
72786  &(x1**2-4d0*r1**2)*(x2**2-4d0*r2**2)) RETURN
72787  alpcor=max(0d0,min(1d0,alpha))
72788 
72789 C...Initial values and flags.
72790  iclass=ni/5
72791  icombi=ni-5*iclass
72792  isset1=0
72793  isset2=0
72794  isset4=0
72795 
72796 C... Phase space.
72797  ps=sqrt((1d0-(r1+r2)**2)*(1d0-(r1-r2)**2))
72798 
72799 C...Eikonal expression; also acts as default.
72800  IF(iclass.LE.1.OR.iclass.GE.17.OR.icombi.EQ.0) THEN
72801  rlo=ps
72802  IF(icombi.EQ.0.OR.icombi.EQ.1) THEN
72803  anum=0d0
72804  ELSEIF(icombi.EQ.2) THEN
72805  anum=(2d0-x1-x2)**2
72806  ELSEIF(icombi.EQ.3) THEN
72807  anum=alpcor*(2d0-x1-x2)**2
72808  ELSE
72809  anum=0.5d0*(2d0-x1-x2)**2
72810  ENDIF
72811  rfo=ps*2d0*((x1+x2-1d0+anum-r1**2-r2**2)/
72812  & ((1d0+r1**2-r2**2-x1)*(1d0+r2**2-r1**2-x2))-
72813  & r1**2/(1d0+r2**2-r1**2-x2)**2-
72814  & r2**2/(1d0+r1**2-r2**2-x1)**2)
72815  icombi=0
72816 
72817 C...V -> q qbar (V = gamma*/Z0/W+-/...).
72818  ELSEIF(iclass.EQ.2) THEN
72819  IF(icombi.EQ.1.OR.icombi.EQ.3) THEN
72820  rlo1=ps*(2-r1**2-r1**4+6*r1*r2-r2**2+2*r1**2*r2**2-r2**4)/2.d0
72821  rfo1=-1.d0*(3+6*r1**2+r1**4-6*r1*r2+6*r1**3*r2-2*r2**2
72822  & -6*r1**2*r2**2+6*r1*r2**3+r2**4-3*x1+6*r1*r2*x1
72823  & +2*r2**2*x1+x1**2-2*r1**2*x1**2+3*r1**2*(2-x1-x2)
72824  & +6*r1*r2*(2-x1-x2)-r2**2*(2-x1-x2)-2*x1*(2-x1-x2)
72825  & -5*r1**2*x1*(2-x1-x2)+r2**2*x1*(2-x1-x2)+x1**2*(2-x1-x2)
72826  & -3*(2-x1-x2)**2-3*r1**2*(2-x1-x2)**2+r2**2*(2-x1-x2)**2
72827  & +2*x1*(2-x1-x2)**2+(2-x1-x2)**3-x2)/
72828  & (-1+r1**2-r2**2+x2)**2
72829  rfo1=rfo1-2*(-3+r1**2-6*r1*r2+6*r1**3*r2+3*r2**2-4*r1**2*r2**2
72830  & +6*r1*r2**3+2*x1+3*r1**2*x1+r2**2*x1-x1**2-r1**2*x1**2
72831  & -r2**2*x1**2+4*(2-x1-x2)+2*r1**2*(2-x1-x2)+3*r1*r2*(2-x1
72832  & -x2)-r2**2*(2-x1-x2)-3*x1*(2-x1-x2)-2*r1**2*x1*(2-x1-x2)
72833  & +x1**2*(2-x1-x2)-(2-x1-x2)**2-r1**2*(2-x1-x2)**2+r1*r2*(2
72834  & -x1-x2)**2+x1*(2-x1-x2)**2)/
72835  & (-1-r1**2+r2**2+x1)/(-1+r1**2-r2**2+x2)
72836  rfo1=rfo1-1.d0*(-1+2*r1**2+r1**4+6*r1*r2+6*r1**3*r2-2*r2**2
72837  & -6*r1**2*r2**2+6*r1*r2**3+r2**4-x1-2*r1**2*x1-6*r1*r2*x1
72838  & +8*r2**2*x1+x1**2-2*r2**2*x1**2-r1**2*(2-x1-x2)+r2**2*(2
72839  & -x1-x2)-r1**2*x1*(2-x1-x2)+r2**2*x1*(2-x1-x2)+x1**2*
72840  & (2-x1-x2)+x2)/(-1-r1**2+r2**2+x1)**2
72841  rfo1=rfo1/2.d0
72842  isset1=1
72843  ENDIF
72844  IF(icombi.EQ.2.OR.icombi.EQ.3) THEN
72845  rlo2=ps*(2-r1**2-r1**4-6*r1*r2-r2**2+2*r1**2*r2**2-r2**4)/2.d0
72846  rfo2=-1*(3+6*r1**2+r1**4+6*r1*r2-6*r1**3*r2-2*r2**2
72847  & -6*r1**2*r2**2-6*r1*r2**3+r2**4-3*x1-6*r1*r2*x1+2*r2**2*x1
72848  & +x1**2-2*r1**2*x1**2+3*r1**2*(2-x1-x2)-6*r1*r2*(2-x1-x2)
72849  & -r2**2*(2-x1-x2)-2*x1*(2-x1-x2)-5*r1**2*x1*(2-x1-x2)
72850  & +r2**2*x1*(2-x1-x2)+x1**2*(2-x1-x2)-3*(2-x1-x2)**2
72851  & -3*r1**2*(2-x1-x2)**2+r2**2*(2-x1-x2)**2+2*x1*(2-x1-x2)**2
72852  & +(2-x1-x2)**3-x2)/(-1+r1**2-r2**2+x2)**2
72853  rfo2=rfo2-2*(-3+r1**2+6*r1*r2-6*r1**3*r2+3*r2**2-4*r1**2*r2**2
72854  & -6*r1*r2**3+2*x1+3*r1**2*x1+r2**2*x1-x1**2-r1**2*x1**2
72855  & -r2**2*x1**2+4*(2-x1-x2)+2*r1**2*(2-x1-x2)-3*r1*r2*(2-x1
72856  & -x2)-r2**2*(2-x1-x2)-3*x1*(2-x1-x2)-2*r1**2*x1*(2-x1-x2)
72857  & +x1**2*(2-x1-x2)-(2-x1-x2)**2-r1**2*(2-x1-x2)**2-r1*r2*(2
72858  & -x1-x2)**2+x1*(2-x1-x2)**2)/
72859  & (-1-r1**2+r2**2+x1)/(-1+r1**2-r2**2+x2)
72860  rfo2=rfo2-1*(-1+2*r1**2+r1**4-6*r1*r2-6*r1**3*r2-2*r2**2
72861  & -6*r1**2*r2**2-6*r1*r2**3+r2**4-x1-2*r1**2*x1+6*r1*r2*x1
72862  & +8*r2**2*x1+x1**2-2*r2**2*x1**2-r1**2*(2-x1-x2)+r2**2*(2-x1
72863  & -x2)-r1**2*x1*(2-x1-x2)+r2**2*x1*(2-x1-x2)+x1**2*(2-x1-x2)
72864  & +x2)/(-1-r1**2+r2**2+x1)**2
72865  rfo2=rfo2/2.d0
72866  isset2=1
72867  ENDIF
72868  IF(icombi.EQ.4) THEN
72869  rlo4=ps*(2d0-r1**2-r1**4-r2**2+2d0*r1**2*r2**2-r2**4)/2d0
72870  rfo4=(1-r1**4+6*r1**2*r2**2-r2**4+x1+3*r1**2*x1-9*r2**2*x1
72871  & -3*x1**2-r1**2*x1**2+3*r2**2*x1**2+x1**3-x2-r1**2*x2
72872  & +r2**2*x2-r1**2*x1*x2+r2**2*x1*x2+x1**2*x2)/
72873  & (-1-r1**2+r2**2+x1)**2
72874  rfo4=rfo4
72875  & -2*(1+r1**2+r2**2-4*r1**2*r2**2+r1**2*x1+2*r2**2*x1-x1**2
72876  & -r2**2*x1**2+2*r1**2*x2+r2**2*x2-3*x1*x2+x1**2*x2-x2**2
72877  & -r1**2*x2**2+x1*x2**2)/
72878  & (-1-r1**2+r2**2+x1)/(-1+r1**2-r2**2+x2)
72879  rfo4=rfo4+(1-r1**4+6*r1**2*r2**2-r2**4-x1+r1**2*x1-r2**2*x1+x2
72880  & -9*r1**2*x2+3*r2**2*x2+r1**2*x1*x2-r2**2*x1*x2-3*x2**2
72881  & +3*r1**2*x2**2-r2**2*x2**2+x1*x2**2+x2**3)/
72882  & (-1+r1**2-r2**2+x2)**2
72883  rfo4=rfo4/2.d0
72884  isset4=1
72885  ENDIF
72886 
72887 C...q -> q V.
72888  ELSEIF(iclass.EQ.3) THEN
72889  IF(icombi.EQ.1.OR.icombi.EQ.3) THEN
72890  rlo1=ps*(1d0-2d0*r1**2+r1**4+r2**2-6d0*r1*r2**2
72891  & +r1**2*r2**2-2d0*r2**4)
72892  rfo1=2*(-1+r1-2*r1**2+2*r1**3-r1**4+r1**5-r2**2+r1*r2**2
72893  & -5*r1**2*r2**2+r1**3*r2**2-2*r1*r2**4+2*x1-2*r1*x1
72894  & +2*r1**2*x1-2*r1**3*x1+2*r2**2*x1+5*r1*r2**2*x1
72895  & +r1**2*r2**2*x1+2*r2**4*x1-x1**2+r1*x1**2-r2**2*x1**2+3*x2
72896  & +4*r1**2*x2+r1**4*x2+2*r2**2*x2+2*r1**2*r2**2*x2-4*x1*x2
72897  & -2*r1**2*x1*x2-r2**2*x1*x2+x1**2*x2-2*x2**2
72898  & -2*r1**2*x2**2+x1*x2**2)/(1-r1**2+r2**2-x2)/(-2+x1+x2)
72899  rfo1=rfo1+(2*r2**2+6*r1*r2**2-6*r1**2*r2**2+6*r1**3*r2**2
72900  & +2*r2**4+6*r1*r2**4-r2**2*x1+r1**2*r2**2*x1-r2**4*x1+x2
72901  & -r1**4*x2-3*r2**2*x2-6*r1*r2**2*x2+9*r1**2*r2**2*x2
72902  & -2*r2**4*x2-x1*x2+r1**2*x1*x2-x2**2-3*r1**2*x2**2
72903  & +2*r2**2*x2**2+x1*x2**2)/(-1+r1**2-r2**2+x2)**2
72904  rfo1=rfo1+(-4-8*r1**2-4*r1**4+4*r2**2-4*r1**2*r2**2+8*r2**4
72905  & +9*x1+10*r1**2*x1+r1**4*x1-3*r2**2*x1+6*r1*r2**2*x1
72906  & +r1**2*r2**2*x1-2*r2**4*x1-6*x1**2-2*r1**2*x1**2+x1**3
72907  & +7*x2+8*r1**2*x2+r1**4*x2-7*r2**2*x2+6*r1*r2**2*x2
72908  & +r1**2*r2**2*x2-2*r2**4*x2-9*x1*x2-3*r1**2*x1*x2
72909  & +2*r2**2*x1*x2+2*x1**2*x2-3*x2**2-r1**2*x2**2
72910  & +2*r2**2*x2**2+x1*x2**2)/(-2+x1+x2)**2
72911  isset1=1
72912  ENDIF
72913  IF(icombi.EQ.2.OR.icombi.EQ.3) THEN
72914  rlo2=ps*(1d0-2d0*r1**2+r1**4+r2**2+6d0*r1*r2**2
72915  & +r1**2*r2**2-2d0*r2**4)
72916  rfo2=2*(1+r1+2*r1**2+2*r1**3+r1**4+r1**5+r2**2+r1*r2**2
72917  & +5*r1**2*r2**2+r1**3*r2**2-2*r1*r2**4-2*x1-2*r1*x1
72918  & -2*r1**2*x1-2*r1**3*x1-2*r2**2*x1+5*r1*r2**2*x1
72919  & -r1**2*r2**2*x1-2*r2**4*x1+x1**2+r1*x1**2+r2**2*x1**2-3*x2
72920  & -4*r1**2*x2-r1**4*x2-2*r2**2*x2-2*r1**2*r2**2*x2+4*x1*x2
72921  & +2*r1**2*x1*x2+r2**2*x1*x2-x1**2*x2+2*x2**2+2*r1**2*x2**2
72922  & -x1*x2**2)/(-1+r1**2-r2**2+x2)/(-2+x1+x2)
72923  rfo2=rfo2+(2*r2**2-6*r1*r2**2-6*r1**2*r2**2-6*r1**3*r2**2
72924  & +2*r2**4-6*r1*r2**4-r2**2*x1+r1**2*r2**2*x1-r2**4*x1+x2
72925  & -r1**4*x2-3*r2**2*x2+6*r1*r2**2*x2+9*r1**2*r2**2*x2
72926  & -2*r2**4*x2-x1*x2+r1**2*x1*x2-x2**2-3*r1**2*x2**2
72927  & +2*r2**2*x2**2+x1*x2**2)/(-1+r1**2-r2**2+x2)**2
72928  rfo2=rfo2+(-4-8*r1**2-4*r1**4+4*r2**2-4*r1**2*r2**2+8*r2**4+9*x1
72929  & +10*r1**2*x1+r1**4*x1-3*r2**2*x1-6*r1*r2**2*x1
72930  & +r1**2*r2**2*x1-2*r2**4*x1-6*x1**2-2*r1**2*x1**2+x1**3
72931  & +7*x2+8*r1**2*x2+r1**4*x2-7*r2**2*x2-6*r1*r2**2*x2
72932  & +r1**2*r2**2*x2-2*r2**4*x2-9*x1*x2-3*r1**2*x1*x2
72933  & +2*r2**2*x1*x2+2*x1**2*x2-3*x2**2-r1**2*x2**2+2*r2**2*x2**2
72934  & +x1*x2**2)/(-2+x1+x2)**2
72935  isset2=1
72936  ENDIF
72937  IF(icombi.EQ.4) THEN
72938  rlo4=ps*(1.d0-2.d0*r1**2+r1**4+r2**2+r1**2*r2**2-2.d0*r2**4)
72939  rfo4=2*(1+2*r1**2+r1**4+r2**2+5*r1**2*r2**2-2*x1-2*r1**2*x1
72940  & -2*r2**2*x1-r1**2*r2**2*x1-2*r2**4*x1+x1**2+r2**2*x1**2
72941  & -3*x2-4*r1**2*x2-r1**4*x2-2*r2**2*x2-2*r1**2*r2**2*x2
72942  & +4*x1*x2+2*r1**2*x1*x2+r2**2*x1*x2-x1**2*x2+2*x2**2
72943  & +2*r1**2*x2**2-x1*x2**2)/(-1+r1**2-r2**2+x2)/(-2+x1+x2)
72944  rfo4=rfo4+(2*r2**2-6*r1**2*r2**2+2*r2**4-r2**2*x1+r1**2*r2**2*x1
72945  & -r2**4*x1+x2-r1**4*x2-3*r2**2*x2+9*r1**2*r2**2*x2
72946  & -2*r2**4*x2-x1*x2+r1**2*x1*x2-x2**2-3*r1**2*x2**2
72947  & +2*r2**2*x2**2+x1*x2**2)/(-1+r1**2-r2**2+x2)**2
72948  rfo4=rfo4+(-4-8*r1**2-4*r1**4+4*r2**2-4*r1**2*r2**2+8*r2**4+9*x1
72949  & +10*r1**2*x1+r1**4*x1-3*r2**2*x1+r1**2*r2**2*x1-2*r2**4*x1
72950  & -6*x1**2-2*r1**2*x1**2+x1**3+7*x2+8*r1**2*x2+r1**4*x2
72951  & -7*r2**2*x2+r1**2*r2**2*x2-2*r2**4*x2-9*x1*x2-3*r1**2*x1*x2
72952  & +2*r2**2*x1*x2+2*x1**2*x2-3*x2**2-r1**2*x2**2+2*r2**2*x2**2
72953  & +x1*x2**2)/(2-x1-x2)**2
72954  isset4=1
72955  ENDIF
72956 
72957 C...S -> q qbar (S = h0/H0/A0/H+-/...).
72958  ELSEIF(iclass.EQ.4) THEN
72959  IF(icombi.EQ.1.OR.icombi.EQ.3) THEN
72960  rlo1=ps*(1d0-r1**2-r2**2-2d0*r1*r2)
72961  rfo1=-(-1+r1**4-2*r1*r2-2*r1**3*r2-6*r1**2*r2**2-2*r1*r2**3
72962  & +r2**4+x1-r1**2*x1+2*r1*r2*x1+3*r2**2*x1+x2+r1**2*x2
72963  & -r2**2*x2-x1*x2)/(-1-r1**2+r2**2+x1)**2
72964  & -2*(r1**2+r1**4-2*r1**3*r2+r2**2-6*r1**2*r2**2-2*r1*r2**3
72965  & +r2**4-r1**2*x1+r1*r2*x1+2*r2**2*x1+2*r1**2*x2+r1*r2*x2
72966  & -r2**2*x2-x1*x2)/(-1-r1**2+r2**2+x1)/(-1+r1**2-r2**2+x2)
72967  & -(-1+r1**4-2*r1*r2-2*r1**3*r2-6*r1**2*r2**2-2*r1*r2**3
72968  & +r2**4+x1-r1**2*x1+r2**2*x1+x2+3*r1**2*x2+2*r1*r2*x2
72969  & -r2**2*x2-x1*x2)/(-1+r1**2-r2**2+x2)**2
72970  isset1=1
72971  ENDIF
72972  IF(icombi.EQ.2.OR.icombi.EQ.3) THEN
72973  rlo2=ps*(1d0-r1**2-r2**2+2d0*r1*r2)
72974  rfo2=-(-1+r1**4+2*r1*r2+2*r1**3*r2-6*r1**2*r2**2+2*r1*r2**3
72975  & +r2**4+x1-r1**2*x1-2*r1*r2*x1+3*r2**2*x1+x2+r1**2*x2
72976  & -r2**2*x2-x1*x2)/(-1-r1**2+r2**2+x1)**2
72977  & -(-1+r1**4+2*r1*r2+2*r1**3*r2-6*r1**2*r2**2+2*r1*r2**3
72978  & +r2**4+x1-r1**2*x1+r2**2*x1+x2+3*r1**2*x2-2*r1*r2*x2
72979  & -r2**2*x2-x1*x2)/(-1+r1**2-r2**2+x2)**2
72980  & +2*(-r1**2-r1**4-2*r1**3*r2-r2**2+6*r1**2*r2**2
72981  & -2*r1*r2**3-r2**4+r1**2*x1+r1*r2*x1-2*r2**2*x1
72982  & -2*r1**2*x2+r1*r2*x2+r2**2*x2+x1*x2)/
72983  & (-1-r1**2+r2**2+x1)/(-1+r1**2-r2**2+x2)
72984  isset2=1
72985  ENDIF
72986  IF(icombi.EQ.4) THEN
72987  rlo4=ps*(1d0-r1**2-r2**2)
72988  rfo4=-(-1+r1**4-6*r1**2*r2**2+r2**4+x1-r1**2*x1+3*r2**2*x1+x2
72989  & +r1**2*x2-r2**2*x2-x1*x2)/(-1-r1**2+r2**2+x1)**2
72990  & -2*(r1**2+r1**4+r2**2-6*r1**2*r2**2+r2**4-r1**2*x1
72991  & +2*r2**2*x1+2*r1**2*x2-r2**2*x2-x1*x2)/
72992  & (-1-r1**2+r2**2+x1)/(-1+r1**2-r2**2+x2)
72993  & -(-1+r1**4-6*r1**2*r2**2+r2**4+x1-r1**2*x1+r2**2*x1
72994  & +x2+3*r1**2*x2-r2**2*x2-x1*x2)/(-1+r1**2-r2**2+x2)**2
72995  isset4=1
72996  ENDIF
72997 
72998 C...q -> q S.
72999  ELSEIF(iclass.EQ.5) THEN
73000  IF(icombi.EQ.1.OR.icombi.EQ.3) THEN
73001  rlo1=ps*(1d0+r1**2-r2**2+2d0*r1)
73002  rfo1=(4-4*r1**2+4*r2**2-3*x1-2*r1*x1+r1**2*x1-r2**2*x1-5*x2
73003  & -2*r1*x2+r1**2*x2-r2**2*x2+x1*x2+x2**2)/(-2+x1+x2)**2
73004  & +2*(3-r1-5*r1**2-r1**3+3*r2**2+r1*r2**2-2*x1-r1*x1
73005  & +r1**2*x1-4*x2+2*r1**2*x2-r2**2*x2+x1*x2+x2**2)/
73006  & (1-r1**2+r2**2-x2)/(-2+x1+x2)
73007  & +(2-2*r1-6*r1**2-2*r1**3+2*r2**2-2*r1*r2**2-x1+r1**2*x1
73008  & -r2**2*x1-3*x2+2*r1*x2+3*r1**2*x2-r2**2*x2+x1*x2+x2**2)/
73009  & (-1+r1**2-r2**2+x2)**2
73010  isset1=1
73011  ENDIF
73012  IF(icombi.EQ.2.OR.icombi.EQ.3) THEN
73013  rlo2=ps*(1d0+r1**2-r2**2-2d0*r1)
73014  rfo2=(4-4*r1**2+4*r2**2-3*x1+2*r1*x1+r1**2*x1-r2**2*x1-5*x2
73015  & +2*r1*x2+r1**2*x2-r2**2*x2+x1*x2+x2**2)/(-2+x1+x2)**2
73016  & +2*(3+r1-5*r1**2+r1**3+3*r2**2-r1*r2**2-2*x1+r1*x1
73017  & +r1**2*x1-4*x2+2*r1**2*x2-r2**2*x2+x1*x2+x2**2)/
73018  & (1-r1**2+r2**2-x2)/(-2+x1+x2)
73019  & +(2+2*r1-6*r1**2+2*r1**3+2*r2**2+2*r1*r2**2-x1+r1**2*x1
73020  & -r2**2*x1-3*x2-2*r1*x2+3*r1**2*x2-r2**2*x2+x1*x2+x2**2)/
73021  & (-1+r1**2-r2**2+x2)**2
73022  isset2=1
73023  ENDIF
73024  IF(icombi.EQ.4) THEN
73025  rlo4=ps*(1d0+r1**2-r2**2)
73026  rfo4=(4-4*r1**2+4*r2**2-3*x1+r1**2*x1-r2**2*x1-5*x2+r1**2*x2
73027  & -r2**2*x2+x1*x2+x2**2)/(-2+x1+x2)**2
73028  & +2*(3-5*r1**2+3*r2**2-2*x1+r1**2*x1-4*x2+2*r1**2*x2
73029  & -r2**2*x2+x1*x2+x2**2)/(1-r1**2+r2**2-x2)/(-2+x1+x2)
73030  & +(2-6*r1**2+2*r2**2-x1+r1**2*x1-r2**2*x1-3*x2+3*r1**2*x2
73031  & -r2**2*x2+x1*x2+x2**2)/(-1+r1**2-r2**2+x2)**2
73032  isset4=1
73033  ENDIF
73034 
73035 C...V -> ~q ~qbar (~q = squark).
73036  ELSEIF(iclass.EQ.6) THEN
73037  rlo1=ps*(1d0-2d0*r1**2+r1**4-2d0*r2**2-2d0*r1**2*r2**2+r2**4)
73038  rfo1=2d0*3d0+(1+r1**2+r2**2-x1)*(4*r1**2-x1**2)/
73039  & (-1-r1**2+r2**2+x1)**2
73040  & -2d0*(-1-3*r1**2-r2**2+x1+x1**2/2+x2-x1*x2/2)/
73041  & (-1-r1**2+r2**2+x1)
73042  & +(1+r1**2+r2**2-x2)*(4*r2**2-x2**2)
73043  & /(-1+r1**2-r2**2+x2)**2
73044  & -2d0*(-1-r1**2-3*r2**2+x1+x2-x1*x2/2+x2**2/2)/
73045  & (-1+r1**2-r2**2+x2)
73046  & -(-4*r1**2-4*r1**4-4*r2**2-8*r1**2*r2**2-4*r2**4+2*x1
73047  & +6*r1**2*x1+6*r2**2*x1-2*x1**2+2*x2+6*r1**2*x2+6*r2**2*x2
73048  & -4*x1*x2-2*r1**2*x1*x2-2*r2**2*x1*x2+x1**2*x2-2*x2**2
73049  & +x1*x2**2)/(-1-r1**2+r2**2+x1)/(-1+r1**2-r2**2+x2)
73050  isset1=1
73051 
73052 C...~q -> ~q V.
73053  ELSEIF(iclass.EQ.7) THEN
73054  rlo1=ps*(1d0-2d0*r1**2+r1**4-2d0*r2**2-2d0*r1**2*r2**2+r2**4)
73055  rfo1=16*r2**2+8*(4*r2**2+2*r2**2*x1+x2+r1**2*x2+r2**2*x2-x1*x2
73056  & -2*x2**2)/(3*(-1+r1**2-r2**2+x2))+8*(1+r1**2+r2**2-x2)*
73057  & (4*r2**2-x2**2)/(3*(-1+r1**2-r2**2+x2)**2)+8*(x1+x2)*
73058  & (-1-2*r1**2-r1**4-2*r2**2+2*r1**2*r2**2-r2**4+2*x1
73059  & +2*r1**2*x1+2*r2**2*x1-x1**2+2*x2+2*r1**2*x2+2*r2**2*x2
73060  & -2*x1*x2-x2**2)/(3*(-2+x1+x2)**2)+8*(-1-r1**2+r2**2-x1)*
73061  & (2*r2**2*x1+x2+r1**2*x2+r2**2*x2-x1*x2-x2**2)/
73062  & (3*(-1+r1**2-r2**2+x2)*(-2+x1+x2))+8*(1+2*r1**2+r1**4
73063  & +2*r2**2-2*r1**2*r2**2+r2**4-2*x1-2*r1**2*x1-4*r2**2*x1
73064  & +x1**2-3*x2-3*r1**2*x2-3*r2**2*x2+3*x1*x2+2*x2**2)/
73065  & (3*(-2+x1+x2))
73066  rfo1=3d0*rfo1/8d0
73067  isset1=1
73068 
73069 C...S -> ~q ~qbar.
73070  ELSEIF(iclass.EQ.8) THEN
73071  rlo1=ps
73072  rfo1=(-1-2*r1**2-r1**4-2*r2**2+2*r1**2*r2**2-r2**4+2*x1
73073  & +2*r1**2*x1+2*r2**2*x1-x1**2-r2**2*x1**2+2*x2+2*r1**2*x2
73074  & +2*r2**2*x2-3*x1*x2-r1**2*x1*x2-r2**2*x1*x2+x1**2*x2-x2**2
73075  & -r1**2*x2**2+x1*x2**2)/
73076  & (1+r1**2-r2**2-x1)**2/(-1+r1**2-r2**2+x2)**2
73077  rfo1=2d0*rfo1
73078  isset1=1
73079 
73080 C...~q -> ~q S.
73081  ELSEIF(iclass.EQ.9) THEN
73082  rlo1=ps
73083  rfo1=(-1-r1**2-r2**2+x2)/(-1+r1**2-r2**2+x2)**2
73084  & +(1+r1**2-r2**2+x1)/(-1+r1**2-r2**2+x2)/(-2+x1+x2)
73085  & -(x1+x2)/(-2+x1+x2)**2
73086  isset1=1
73087 
73088 C...chi -> q ~qbar (chi = neutralino/chargino).
73089  ELSEIF(iclass.EQ.10) THEN
73090  IF(icombi.EQ.1.OR.icombi.EQ.3) THEN
73091  rlo1=ps*(1d0+r1**2-r2**2+2d0*r1)
73092  rfo1=(2*r1+x1)*(-1-r1**2-r2**2+x1)/(-1-r1**2+r2**2+x1)**2
73093  & +2*(-1-r1**2-2*r1**3-r2**2-2*r1*r2**2+3*x1/2+r1*x1
73094  & -r1**2*x1/2-r2**2*x1/2+x2+r1*x2+r1**2*x2-x1*x2/2)/
73095  & (-1-r1**2+r2**2+x1)/(-1+r1**2-r2**2+x2)
73096  & +(2-2*r1-6*r1**2-2*r1**3+2*r2**2-2*r1*r2**2-x1+r1**2*x1
73097  & -r2**2*x1-3*x2+2*r1*x2+3*r1**2*x2-r2**2*x2+x1*x2+x2**2)/
73098  & (-1+r1**2-r2**2+x2)**2
73099  isset1=1
73100  ENDIF
73101  IF(icombi.EQ.2.OR.icombi.EQ.3) THEN
73102  rlo2=ps*(1d0-2d0*r1+r1**2-r2**2)
73103  rfo2=(2*r1-x1)*(1+r1**2+r2**2-x1)/(-1-r1**2+r2**2+x1)**2
73104  & +2*(-1-r1**2+2*r1**3-r2**2+2*r1*r2**2+3*x1/2-r1*x1
73105  & -r1**2*x1/2-r2**2*x1/2+x2-r1*x2+r1**2*x2-x1*x2/2)/
73106  & (-1-r1**2+r2**2+x1)/(-1+r1**2-r2**2+x2)
73107  & +(2+2*r1-6*r1**2+2*r1**3+2*r2**2+2*r1*r2**2-x1+r1**2*x1
73108  & -r2**2*x1-3*x2-2*r1*x2+3*r1**2*x2-r2**2*x2+x1*x2+x2**2)/
73109  & (-1+r1**2-r2**2+x2)**2
73110  isset2=1
73111  ENDIF
73112  IF(icombi.EQ.4) THEN
73113  rlo4=ps*(1+r1**2-r2**2)
73114  rfo4=x1*(-1-r1**2-r2**2+x1)/(-1-r1**2+r2**2+x1)**2
73115  & +2d0*(-1-r1**2-r2**2+3*x1/2-r1**2*x1/2-r2**2*x1/2
73116  & +x2+r1**2*x2-x1*x2/2)/
73117  & (-1-r1**2+r2**2+x1)/(-1+r1**2-r2**2+x2)
73118  & +(2-6*r1**2+2*r2**2-x1+r1**2*x1-r2**2*x1-3*x2+3*r1**2*x2
73119  & -r2**2*x2+x1*x2+x2**2)/(-1+r1**2-r2**2+x2)**2
73120  isset4=1
73121  ENDIF
73122 
73123 C...~q -> q chi.
73124  ELSEIF(iclass.EQ.11) THEN
73125  IF(icombi.EQ.1.OR.icombi.EQ.3) THEN
73126  rlo1=ps*(1d0-(r1+r2)**2)
73127  rfo1=(1+r1**2+2*r1*r2+r2**2-x1-x2)*(x1+x2)/(-2+x1+x2)**2
73128  & -(-1+r1**4-2*r1*r2-2*r1**3*r2-6*r1**2*r2**2-2*r1*r2**3
73129  & +r2**4+x1-r1**2*x1+r2**2*x1+x2+3*r1**2*x2+2*r1*r2*x2
73130  & -r2**2*x2-x1*x2)/(-1+r1**2-r2**2+x2)**2
73131  & +(-1-2*r1**2-r1**4-2*r1*r2-2*r1**3*r2+2*r1*r2**3+r2**4
73132  & +x1+r1**2*x1-2*r1*r2*x1-3*r2**2*x1+2*r1**2*x2-2*r2**2*x2
73133  & +x1*x2+x2**2)/(-1+r1**2-r2**2+x2)/(-2+x1+x2)
73134  isset1=1
73135  ENDIF
73136  IF(icombi.EQ.2.OR.icombi.EQ.3) THEN
73137  rlo2=ps*(1d0-(r1-r2)**2)
73138  rfo2=(1+r1**2-2*r1*r2+r2**2-x1-x2)*(x1+x2)/
73139  & (-2+x1+x2)**2
73140  & -(-1+r1**4+2*r1*r2+2*r1**3*r2-6*r1**2*r2**2+2*r1*r2**3
73141  & +r2**4+x1-r1**2*x1+r2**2*x1+x2+3*r1**2*x2-2*r1*r2*x2
73142  & -r2**2*x2-x1*x2)/(-1+r1**2-r2**2+x2)**2
73143  & +(-1-2*r1**2-r1**4+2*r1*r2+2*r1**3*r2-2*r1*r2**3+r2**4
73144  & +x1+r1**2*x1+2*r1*r2*x1-3*r2**2*x1+2*r1**2*x2-2*r2**2*x2
73145  & +x1*x2+x2**2)/(-1+r1**2-r2**2+x2)/(-2+x1+x2)
73146  isset2=1
73147  ENDIF
73148  IF(icombi.EQ.4) THEN
73149  rlo4=ps*(1d0-r1**2-r2**2)
73150  rfo4=(1+r1**2+r2**2-x1-x2)*(x1+x2)/(-2+x1+x2)**2
73151  & -(-1+r1**4-6*r1**2*r2**2+r2**4+x1-r1**2*x1+r2**2*x1+x2
73152  & +3*r1**2*x2-r2**2*x2-x1*x2)/
73153  & (-1+r1**2-r2**2+x2)**2
73154  & -(-1-2*r1**2-r1**4+r2**4+x1+r1**2*x1-3*r2**2*x1
73155  & +2*r1**2*x2-2*r2**2*x2+x1*x2+x2**2)/
73156  & (2-x1-x2)/(-1+r1**2-r2**2+x2)
73157  isset4=1
73158  ENDIF
73159 
73160 C...q -> ~q chi.
73161  ELSEIF(iclass.EQ.12) THEN
73162  IF(icombi.EQ.1.OR.icombi.EQ.3) THEN
73163  rlo1=ps*(1d0-r1**2+r2**2+2d0*r2)
73164  rfo1=(2*r2+x2)*(-1-r1**2-r2**2+x2)/(-1+r1**2-r2**2+x2)**2
73165  & +(4+4*r1**2-4*r2**2-5*x1-r1**2*x1-2*r2*x1+r2**2*x1+x1**2
73166  & -3*x2-r1**2*x2-2*r2*x2+r2**2*x2+x1*x2)/
73167  & (-2+x1+x2)**2-2*(-1-r1**2+r2+r1**2*r2-r2**2-r2**3+x1
73168  & +r2*x1+r2**2*x1+2*x2+r1**2*x2-x1*x2/2-x2**2/2)/
73169  & (2-x1-x2)/(-1+r1**2-r2**2+x2)
73170  isset1=1
73171  END IF
73172  IF(icombi.EQ.2.OR.icombi.EQ.3) THEN
73173  rlo2=ps*(1d0-r1**2+r2**2-2d0*r2)
73174  rfo2=(2*r2-x2)*(1+r1**2+r2**2-x2)/(-1+r1**2-r2**2+x2)**2
73175  & +(4+4*r1**2-4*r2**2-5*x1-r1**2*x1+2*r2*x1+r2**2*x1+x1**2
73176  & -3*x2-r1**2*x2+2*r2*x2+r2**2*x2+x1*x2)/
73177  & (-2+x1+x2)**2-2*(-1-r1**2-r2-r1**2*r2-r2**2+r2**3+x1
73178  & -r2*x1+r2**2*x1+2*x2+r1**2*x2-x1*x2/2-x2**2/2)/
73179  & (2-x1-x2)/(-1+r1**2-r2**2+x2)
73180  isset2=1
73181  END IF
73182  IF(icombi.EQ.4) THEN
73183  rlo4=ps*(1d0-r1**2+r2**2)
73184  rfo4=x2*(-1-r1**2-r2**2+x2)/(-1+r1**2-r2**2+x2)**2
73185  & +(4+4*r1**2-4*r2**2-5*x1-r1**2*x1+r2**2*x1+x1**2
73186  & -3*x2-r1**2*x2+r2**2*x2+x1*x2)/
73187  & (-2+x1+x2)**2-2*(-1-r1**2-r2**2+x1+r2**2*x1+2*x2
73188  & +r1**2*x2-x1*x2/2-x2**2/2)/
73189  & (2-x1-x2)/(-1+r1**2-r2**2+x2)
73190  isset4=1
73191  END IF
73192 
73193 C...~g -> q ~qbar.
73194  ELSEIF(iclass.EQ.13) THEN
73195  IF(icombi.EQ.1.OR.icombi.EQ.3) THEN
73196  rlo1=ps*(1d0+r1**2-r2**2+2d0*r1)
73197  rfo1=4*(2*r1+x1)*(-1-r1**2-r2**2+x1)/(3*(-1-r1**2+r2**2+x1)**2)
73198  & -(-1-r1**2-2*r1**3-r2**2-2*r1*r2**2+3*x1/2+r1*x1-r1**2*x1/2
73199  & -r2**2*x1/2+x2+r1*x2+r1**2*x2-x1*x2/2)/(3*(-1-r1**2+r2**2
73200  & +x1)*(-1+r1**2-r2**2+x2))-3*(-1+r1-r1**2-r1**3-r2**2
73201  & +r1*r2**2+2*x1+r2**2*x1-x1**2/2+x2+r1*x2+r1**2*x2-x1*x2/2)/
73202  & ((-1-r1**2+r2**2+x1)*(2-x1-x2))+3*(4-4*r1**2+4*r2**2-3*x1
73203  & -2*r1*x1+r1**2*x1-r2**2*x1-5*x2-2*r1*x2+r1**2*x2-r2**2*x2
73204  & +x1*x2+x2**2)/(-2+x1+x2)**2+3*(3-r1-5*r1**2-r1**3+3*r2**2
73205  & +r1*r2**2-2*x1-r1*x1+r1**2*x1-4*x2+2*r1**2*x2-r2**2*x2
73206  & +x1*x2+x2**2)/((1-r1**2+r2**2-x2)*(-2+x1+x2))+4*(2-2*r1
73207  & -6*r1**2-2*r1**3+2*r2**2-2*r1*r2**2-x1+r1**2*x1-r2**2*x1
73208  & -3*x2+2*r1*x2+3*r1**2*x2-r2**2*x2+x1*x2+x2**2)/
73209  & (3*(-1+r1**2-r2**2+x2)**2)
73210  rfo1=3d0*rfo1/4d0
73211  isset1=1
73212  ENDIF
73213  IF(icombi.EQ.2.OR.icombi.EQ.3) THEN
73214  rlo2=ps*(1d0+r1**2-r2**2-2d0*r1)
73215  rfo2=4*(2*r1-x1)*(1+r1**2+r2**2-x1)/(3*(-1-r1**2+r2**2+x1)**2)
73216  & -3*(-1-r1-r1**2+r1**3-r2**2-r1*r2**2+2*x1+r2**2*x1-x1**2/2
73217  & +x2-r1*x2+r1**2*x2-x1*x2/2)/((-1-r1**2+r2**2+x1)*(2-x1-x2))
73218  & +(2+2*r1**2-4*r1**3+2*r2**2-4*r1*r2**2-3*x1+2*r1*x1
73219  & +r1**2*x1+r2**2*x1-2*x2+2*r1*x2-2*r1**2*x2+x1*x2)/
73220  & (6*(-1-r1**2+r2**2+x1)*(-1+r1**2-r2**2+x2))+3*(4-4*r1**2
73221  & +4*r2**2-3*x1+2*r1*x1+r1**2*x1-r2**2*x1-5*x2+2*r1*x2
73222  & +r1**2*x2-r2**2*x2+x1*x2+x2**2)/(-2+x1+x2)**2+3*(3+r1
73223  & -5*r1**2+r1**3+3*r2**2-r1*r2**2-2*x1+r1*x1+r1**2*x1-4*x2
73224  & +2*r1**2*x2-r2**2*x2+x1*x2+x2**2)/
73225  & ((1-r1**2+r2**2-x2)*(-2+x1+x2))+4*(2+2*r1-6*r1**2+2*r1**3
73226  & +2*r2**2+2*r1*r2**2-x1+r1**2*x1-r2**2*x1-3*x2-2*r1*x2
73227  & +3*r1**2*x2-r2**2*x2+x1*x2+x2**2)/
73228  & (3*(-1+r1**2-r2**2+x2)**2)
73229  rfo2=3d0*rfo2/4d0
73230  isset2=1
73231  ENDIF
73232  IF(icombi.EQ.4) THEN
73233  rlo4=ps*(1d0+r1**2-r2**2)
73234  rfo4=8*x1*(-1-r1**2-r2**2+x1)/(3*(-1-r1**2+r2**2+x1)**2)-6*(-1
73235  & -r1**2-r2**2+2*x1+r2**2*x1-x1**2/2+x2+r1**2*x2-x1*x2/2)/
73236  & ((-1-r1**2+r2**2+x1)*(2-x1-x2))+(2+2*r1**2+2*r2**2-3*x1
73237  & +r1**2*x1+r2**2*x1-2*x2-2*r1**2*x2+x1*x2)/(3*(-1-r1**2
73238  & +r2**2+x1)*(-1+r1**2-r2**2+x2))+6*(4-4*r1**2+4*r2**2-3*x1
73239  & +r1**2*x1-r2**2*x1-5*x2+r1**2*x2-r2**2*x2+x1*x2+x2**2)/
73240  & (-2+x1+x2)**2+6*(3-5*r1**2+3*r2**2-2*x1+r1**2*x1-4*x2
73241  & +2*r1**2*x2-r2**2*x2+x1*x2+x2**2)/
73242  & ((1-r1**2+r2**2-x2)*(-2+x1+x2))+8*(2-6*r1**2+2*r2**2-x1
73243  & +r1**2*x1-r2**2*x1-3*x2+3*r1**2*x2-r2**2*x2+x1*x2+x2**2)/
73244  & (3*(-1+r1**2-r2**2+x2)**2)
73245  rfo4=3d0*rfo4/8d0
73246  isset4=1
73247  ENDIF
73248 
73249 C...~q -> q ~g.
73250  ELSEIF(iclass.EQ.14) THEN
73251  IF(icombi.EQ.1.OR.icombi.EQ.3) THEN
73252  rlo1=ps*(1-r1**2-r2**2-2d0*r1*r2)
73253  rfo1=64*(1+r1**2+2*r1*r2+r2**2-x1-x2)*(x1+x2)/(9*(-2+x1+x2)**2)
73254  & -16*(-1+r1**4-2*r1*r2-2*r1**3*r2-6*r1**2*r2**2-2*r1*r2**3
73255  & +r2**4+x1-r1**2*x1+2*r1*r2*x1+3*r2**2*x1+x2+r1**2*x2
73256  & -r2**2*x2-x1*x2)/(-1-r1**2+r2**2+x1)**2-16*(r1**2+r1**4
73257  & -2*r1**3*r2+r2**2-6*r1**2*r2**2-2*r1*r2**3+r2**4
73258  & -r1**2*x1+r1*r2*x1+2*r2**2*x1+2*r1**2*x2+r1*r2*x2-r2**2*x2
73259  & -x1*x2)/((-1-r1**2+r2**2+x1)*(-1+r1**2-r2**2+x2))
73260  & -64*(-1+r1**4-2*r1*r2-2*r1**3*r2-6*r1**2*r2**2-2*r1*r2**3
73261  & +r2**4+x1-r1**2*x1+r2**2*x1+x2+3*r1**2*x2+2*r1*r2*x2
73262  & -r2**2*x2-x1*x2)/(9*(-1+r1**2-r2**2+x2)**2)
73263  & +8*(-1+r1**4-2*r1*r2+2*r1**3*r2-2*r2**2-2*r1*r2**3-r2**4
73264  & -2*r1**2*x1+2*r2**2*x1+x1**2+x2-3*r1**2*x2-2*r1*r2*x2
73265  & +r2**2*x2+x1*x2)/((-1-r1**2+r2**2+x1)*(-2+x1+x2))
73266  rfo1=rfo1
73267  & +8*(-1-2*r1**2-r1**4-2*r1*r2-2*r1**3*r2+2*r1*r2**3+r2**4
73268  & +x1+r1**2*x1-2*r1*r2*x1-3*r2**2*x1+2*r1**2*x2-2*r2**2*x2
73269  & +x1*x2+x2**2)/(9*(2-x1-x2)*(-1+r1**2-r2**2+x2))
73270  rfo1=9d0*rfo1/64d0
73271  isset1=1
73272  ENDIF
73273  IF(icombi.EQ.2.OR.icombi.EQ.3) THEN
73274  rlo2=ps*(1-r1**2-r2**2+2d0*r1*r2)
73275  rfo2=64*(1+r1**2-2*r1*r2+r2**2-x1-x2)*(x1+x2)/(9*(-2+x1+x2)**2)
73276  & -16*(-1+r1**4+2*r1*r2+2*r1**3*r2-6*r1**2*r2**2+2*r1*r2**3
73277  & +r2**4+x1-r1**2*x1-2*r1*r2*x1+3*r2**2*x1+x2+r1**2*x2
73278  & -r2**2*x2-x1*x2)/(-1-r1**2+r2**2+x1)**2-64*(-1+r1**4
73279  & +2*r1*r2+2*r1**3*r2-6*r1**2*r2**2+2*r1*r2**3+r2**4+x1
73280  & -r1**2*x1+r2**2*x1+x2+3*r1**2*x2-2*r1*r2*x2-r2**2*x2
73281  & -x1*x2)/(9*(-1+r1**2-r2**2+x2)**2)+16*(-r1**2-r1**4
73282  & -2*r1**3*r2-r2**2+6*r1**2*r2**2-2*r1*r2**3-r2**4+r1**2*x1
73283  & +r1*r2*x1-2*r2**2*x1-2*r1**2*x2+r1*r2*x2+r2**2*x2+x1*x2)/
73284  & ((-1-r1**2+r2**2+x1)*(-1+r1**2-r2**2+x2))
73285  rfo2=rfo2
73286  & +8*(-1+r1**4+2*r1*r2-2*r1**3*r2-2*r2**2+2*r1*r2**3-r2**4
73287  & -2*r1**2*x1+2*r2**2*x1+x1**2+x2-3*r1**2*x2+2*r1*r2*x2
73288  & +r2**2*x2+x1*x2)/((-1-r1**2+r2**2+x1)*(-2+x1+x2))
73289  & +8*(-1-2*r1**2-r1**4+2*r1*r2+2*r1**3*r2-2*r1*r2**3
73290  & +r2**4+x1+r1**2*x1+2*r1*r2*x1-3*r2**2*x1+2*r1**2*x2
73291  & -2*r2**2*x2+x1*x2+x2**2)/(9*(2-x1-x2)*(-1+r1**2-r2**2+x2))
73292  rfo2=9d0*rfo2/64d0
73293  isset2=1
73294  ENDIF
73295  IF(icombi.EQ.4) THEN
73296  rlo4=ps*(1-r1**2-r2**2)
73297  rfo4=128*(1+r1**2+r2**2-x1-x2)*(x1+x2)/(9*(-2+x1+x2)**2)-32*(-1
73298  & +r1**4-6*r1**2*r2**2+r2**4+x1-r1**2*x1+3*r2**2*x1+x2
73299  & +r1**2*x2-r2**2*x2-x1*x2)/(-1-r1**2+r2**2+x1)**2
73300  & -32*(r1**2+r1**4+r2**2-6*r1**2*r2**2+r2**4-r1**2*x1
73301  & +2*r2**2*x1+2*r1**2*x2-r2**2*x2-x1*x2)/
73302  & ((-1-r1**2+r2**2+x1)*(-1+r1**2-r2**2+x2))-128*(-1+r1**4
73303  & -6*r1**2*r2**2+r2**4+x1-r1**2*x1+r2**2*x1+x2+3*r1**2*x2
73304  & -r2**2*x2-x1*x2)/(9*(-1+r1**2-r2**2+x2)**2)
73305  & +16*(-1+r1**4-2*r2**2-r2**4-2*r1**2*x1+2*r2**2*x1+x1**2
73306  & +x2-3*r1**2*x2+r2**2*x2+x1*x2)/
73307  & ((-1-r1**2+r2**2+x1)*(-2+x1+ x2))
73308  rfo4=rfo4+16*(-1-2*r1**2-r1**4+r2**4+x1+r1**2*x1-3*r2**2*x1
73309  & +2*r1**2*x2-2*r2**2*x2+x1*x2+x2**2)/
73310  & (9*(1-r1**2+r2**2-x2)*(-2+x1+x2))
73311  rfo4=9d0*rfo4/128d0
73312  isset4=1
73313  ENDIF
73314 
73315 C...q -> ~q ~g.
73316  ELSEIF(iclass.EQ.15) THEN
73317  IF(icombi.EQ.1.OR.icombi.EQ.3) THEN
73318  rlo1=ps*(1d0-r1**2+r2**2+2d0*r2)
73319  rfo1=32*(2*r2+x2)*(-1-r1**2-r2**2+x2)/(9*(-1+r1**2-r2**2+x2)**2)
73320  & +8*(-1-r1**2-2*r1**2*r2-r2**2-2*r2**3+x1+r2*x1+r2**2*x1
73321  & +3*x2/2-r1**2*x2/2+r2*x2-r2**2*x2/2-x1*x2/2)/
73322  & ((-1-r1**2+r2**2+x1)*(-1+r1**2-r2**2+x2))+8*(2+2*r1**2-2*r2
73323  & -2*r1**2*r2-6*r2**2-2*r2**3-3*x1-r1**2*x1+2*r2*x1
73324  & +3*r2**2*x1+x1**2-x2-r1**2*x2+r2**2*x2+x1*x2)/
73325  & (-1-r1**2+r2**2+x1)**2+32*(4+4*r1**2-4*r2**2-5*x1
73326  & -r1**2*x1-2*r2*x1+r2**2*x1+x1**2-3*x2-r1**2*x2-2*r2*x2
73327  & +r2**2*x2+x1*x2)/(9*(-2+x1+x2)**2)
73328  rfo1=rfo1+8*(3+3*r1**2-r2+r1**2*r2-5*r2**2-r2**3-4*x1-r1**2*x1
73329  & +2*r2**2*x1+x1**2-2*x2-r2*x2+r2**2*x2+x1*x2)/
73330  & ((-1-r1**2+r2**2+x1)*(2-x1-x2))+8*(-1-r1**2+r2+r1**2*r2
73331  & -r2**2-r2**3+x1+r2*x1+r2**2*x1+2*x2+r1**2*x2-x1*x2/2
73332  & -x2**2/2)/(9*(2-x1-x2)*(-1+r1**2-r2**2+x2))
73333  rfo1=9d0*rfo1/32d0
73334  isset1=1
73335  END IF
73336  IF(icombi.EQ.2.OR.icombi.EQ.3) THEN
73337  rlo2=ps*(1d0-r1**2+r2**2-2d0*r2)
73338  rfo2=32*(2*r2-x2)*(1+r1**2+r2**2-x2)/(9*(-1+r1**2-r2**2+x2)**2)
73339  & +8*(-1-r1**2+2*r1**2*r2-r2**2+2*r2**3+x1-r2*x1+r2**2*x1
73340  & +3*x2/2-r1**2*x2/2-r2*x2-r2**2*x2/2-x1*x2/2)/
73341  & ((-1-r1**2+r2**2+x1)*(-1+r1**2-r2**2+x2))+8*(2+2*r1**2+2*r2
73342  & +2*r1**2*r2-6*r2**2+2*r2**3-3*x1-r1**2*x1-2*r2*x1
73343  & +3*r2**2*x1+x1**2-x2-r1**2*x2+r2**2*x2+x1*x2)/
73344  & (-1-r1**2+r2**2+x1)**2+8*(3+3*r1**2+r2-r1**2*r2-5*r2**2
73345  & +r2**3-4*x1-r1**2*x1+2*r2**2*x1+x1**2-2*x2+r2*x2+r2**2*x2
73346  & +x1*x2)/((-1-r1**2+r2**2+x1)*(2-x1-x2))
73347  rfo2=rfo2+32*(4+4*r1**2-4*r2**2-5*x1-r1**2*x1+2*r2*x1+r2**2*x1
73348  & +x1**2-3*x2-r1**2*x2+2*r2*x2+r2**2*x2+x1*x2)/
73349  & (9*(-2+x1+x2)**2)+8*(-1-r1**2-r2-r1**2*r2-r2**2+r2**3+x1
73350  & -r2*x1+r2**2*x1+2*x2+r1**2*x2-x1*x2/2-x2**2/2)/
73351  & (9*(2-x1-x2)*(-1+r1**2-r2**2+x2))
73352  rfo2=9d0*rfo2/32d0
73353  isset2=1
73354  END IF
73355  IF(icombi.EQ.4) THEN
73356  rlo4=ps*(1d0-r1**2+r2**2)
73357  rfo4=64*x2*(-1-r1**2-r2**2+x2)/(9*(-1+r1**2-r2**2+x2)**2)
73358  & +16*(-1-r1**2-r2**2+x1+r2**2*x1+3*x2/2-r1**2*x2/2
73359  & -r2**2*x2/2-x1*x2/2)/
73360  & ((-1-r1**2+r2**2+x1)*(-1+r1**2-r2**2+x2))+16*(3+3*r1**2
73361  & -5*r2**2-4*x1-r1**2*x1+2*r2**2*x1+x1**2-2*x2+r2**2*x2
73362  & +x1*x2)/((-1-r1**2+r2**2+x1)*(2-x1-x2))
73363  & +64*(4+4*r1**2-4*r2**2-5*x1-r1**2*x1+r2**2*x1+x1**2-3*x2
73364  & -r1**2*x2+r2**2*x2+x1*x2)/(9*(-2+x1+x2)**2)
73365  rfo4=rfo4+16*(2+2*r1**2-6*r2**2-3*x1-r1**2*x1+3*r2**2*x1+x1**2
73366  & -x2-r1**2*x2+r2**2*x2+x1*x2)/(-1-r1**2+r2**2+x1)**2
73367  & +16*(-1-r1**2-r2**2+x1+r2**2*x1+2*x2+r1**2*x2-x1*x2/2
73368  & -x2**2/2)/(9*(2-x1-x2)*(-1+r1**2-r2**2+x2))
73369  rfo4=9d0*rfo4/64d0
73370  isset4=1
73371  END IF
73372 
73373 C...g -> ~g ~g. Use (9/4)*eikonal. May be changed in the future.
73374  ELSEIF(iclass.EQ.16) THEN
73375  rlo=ps
73376  IF(icombi.EQ.0.OR.icombi.EQ.1) THEN
73377  anum=0d0
73378  ELSEIF(icombi.EQ.2) THEN
73379  anum=(2d0-x1-x2)**2
73380  ELSEIF(icombi.EQ.3) THEN
73381  anum=alpcor*(2d0-x1-x2)**2
73382  ELSE
73383  anum=0.5d0*(2d0-x1-x2)**2
73384  ENDIF
73385  rfo=ps*2d0*((x1+x2-1d0+anum-r1**2-r2**2)/
73386  & ((1d0+r1**2-r2**2-x1)*(1d0+r2**2-r1**2-x2))-
73387  & r1**2/(1d0+r2**2-r1**2-x2)**2-
73388  & r2**2/(1d0+r1**2-r2**2-x1)**2)
73389  rfo=9d0*rfo/4d0
73390  icombi=0
73391  ENDIF
73392 
73393 C...Find relevant LO and FO expression.
73394  IF(icombi.EQ.0) THEN
73395  ELSEIF(icombi.EQ.1.AND.isset1.EQ.1) THEN
73396  rlo=rlo1
73397  rfo=rfo1
73398  ELSEIF(icombi.EQ.2.AND.isset2.EQ.1) THEN
73399  rlo=rlo2
73400  rfo=rfo2
73401  ELSEIF(icombi.EQ.3.AND.isset1.EQ.1.AND.isset2.EQ.1) THEN
73402  rlo=alpcor*rlo1+(1d0-alpcor)*rlo2
73403  rfo=alpcor*rfo1+(1d0-alpcor)*rfo2
73404  ELSEIF(isset4.EQ.1) THEN
73405  rlo=rlo4
73406  rfo=rfo4
73407  ELSEIF(icombi.EQ.4.AND.isset1.EQ.1.AND.isset2.EQ.1) THEN
73408  rlo=0.5d0*(rlo1+rlo2)
73409  rfo=0.5d0*(rfo1+rfo2)
73410  ELSEIF(isset1.EQ.1) THEN
73411  rlo=rlo1
73412  rfo=rfo1
73413  ELSE
73414  CALL pyerrm(16,'(PYMAEL:) not implemented ME code')
73415  rlo=1d0
73416  rfo=0d0
73417  ENDIF
73418 
73419 C...Output.
73420  pymael=rfo/rlo
73421 
73422  RETURN
73423  END
73424 
73425 C*********************************************************************
73426 
73427 C...PYBOEI
73428 C...Modifies an event so as to approximately take into account
73429 C...Bose-Einstein effects according to a simple phenomenological
73430 C...parametrization.
73431 
73432  SUBROUTINE pyboei(NSAV)
73433 
73434 C...Double precision and integer declarations.
73435  IMPLICIT DOUBLE PRECISION(a-h, o-z)
73436  IMPLICIT INTEGER(i-n)
73437  INTEGER pyk,pychge,pycomp
73438 C...Parameter statement to help give large particle numbers.
73439  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
73440  &kexcit=4000000,kdimen=5000000)
73441 C...Commonblocks.
73442  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
73443  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
73444  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
73445  common/pyint1/mint(400),vint(400)
73446  SAVE /pyjets/,/pydat1/,/pydat2/,/pyint1/
73447 C...Local arrays and data.
73448  dimension dps(4),kfbe(9),nbe(0:10),bei(100),bei3(100),
73449  &beiw(100),bei3w(100)
73450  DATA kfbe/211,-211,111,321,-321,130,310,221,331/
73451 C...Statement function: squared invariant mass.
73452  sdip(i,j)=((p(i,4)+p(j,4))**2-(p(i,3)+p(j,3))**2-
73453  &(p(i,2)+p(j,2))**2-(p(i,1)+p(j,1))**2)
73454 
73455 C...Boost event to overall CM frame. Calculate CM energy.
73456  IF((mstj(51).NE.1.AND.mstj(51).NE.2).OR.n-nsav.LE.1) RETURN
73457  DO 100 j=1,4
73458  dps(j)=0d0
73459  100 CONTINUE
73460  DO 120 i=1,n
73461  kfa=iabs(k(i,2))
73462  IF(k(i,1).LE.10.AND.((kfa.GT.10.AND.kfa.LE.20).OR.kfa.EQ.22)
73463  & .AND.k(i,3).GT.0) THEN
73464  kfma=iabs(k(k(i,3),2))
73465  IF(kfma.GT.10.AND.kfma.LE.80) k(i,1)=-k(i,1)
73466  ENDIF
73467  IF(k(i,1).LE.0.OR.k(i,1).GT.10) goto 120
73468  DO 110 j=1,4
73469  dps(j)=dps(j)+p(i,j)
73470  110 CONTINUE
73471  120 CONTINUE
73472  CALL pyrobo(0,0,0d0,0d0,-dps(1)/dps(4),-dps(2)/dps(4),
73473  &-dps(3)/dps(4))
73474  pecm=0d0
73475  DO 130 i=1,n
73476  IF(k(i,1).GE.1.AND.k(i,1).LE.10) pecm=pecm+p(i,4)
73477  130 CONTINUE
73478 
73479 C...Check if we have separated strings
73480 
73481 C...Reserve copy of particles by species at end of record.
73482  iwp=0
73483  iwn=0
73484  nbe(0)=n+mstu(3)
73485  nmax=nbe(0)
73486  smmin=pecm
73487  DO 190 ibe=1,min(10,mstj(52)+1)
73488  nbe(ibe)=nbe(ibe-1)
73489  DO 180 i=nsav+1,n
73490  IF(ibe.EQ.min(10,mstj(52)+1)) THEN
73491  DO 140 iibe=1,ibe-1
73492  IF(k(i,2).EQ.kfbe(iibe)) goto 180
73493  140 CONTINUE
73494  ELSE
73495  IF(k(i,2).NE.kfbe(ibe)) goto 180
73496  ENDIF
73497  IF(k(i,1).LE.0.OR.k(i,1).GT.10) goto 180
73498  IF(nbe(ibe).GE.mstu(4)-mstu(32)-5) THEN
73499  CALL pyerrm(11,'(PYBOEI:) no more memory left in PYJETS')
73500  RETURN
73501  ENDIF
73502  nbe(ibe)=nbe(ibe)+1
73503  nmax=nbe(ibe)
73504  k(nbe(ibe),1)=i
73505  k(nbe(ibe),2)=0
73506  k(nbe(ibe),3)=0
73507  k(nbe(ibe),4)=0
73508  k(nbe(ibe),5)=0
73509  p(nbe(ibe),1)=0.0d0
73510  p(nbe(ibe),2)=0.0d0
73511  p(nbe(ibe),3)=0.0d0
73512  p(nbe(ibe),4)=0.0d0
73513  p(nbe(ibe),5)=0.0d0
73514  smmin=min(smmin,p(i,5))
73515 C...Check if particles comes from different W's or Z's
73516  IF((mstj(53).NE.0.OR.mstj(56).GT.0).AND.mint(32).EQ.0) THEN
73517  im=i
73518  150 IF(k(im,3).GT.0) THEN
73519  im=k(im,3)
73520  IF(abs(k(im,2)).NE.24.AND.k(im,2).NE.23) goto 150
73521  k(nbe(ibe),5)=im
73522  IF(iwp.EQ.0.AND.k(im,2).EQ.24) iwp=im
73523  IF(iwn.EQ.0.AND.k(im,2).EQ.-24) iwn=im
73524  IF(iwp.EQ.0.AND.k(im,2).EQ.23) iwp=im
73525  IF(iwn.EQ.0.AND.k(im,2).EQ.23.AND.im.NE.iwp) iwn=im
73526  ENDIF
73527  ENDIF
73528 C...Check if particles comes from different strings.
73529  IF(parj(94).GT.0.0d0) THEN
73530  im=i
73531  160 IF(k(im,3).GT.0) THEN
73532  im=k(im,3)
73533  IF(k(im,2).NE.92.AND.k(im,2).NE.91) goto 160
73534  k(nbe(ibe),5)=im
73535  ENDIF
73536  ENDIF
73537  DO 170 j=1,3
73538  p(nbe(ibe),j)=0d0
73539  v(nbe(ibe),j)=0d0
73540  170 CONTINUE
73541  p(nbe(ibe),5)=-1.0d0
73542  180 CONTINUE
73543  190 CONTINUE
73544  IF(nbe(min(9,mstj(52)))-nbe(0).LE.1) goto 510
73545 
73546 C...Calculate separation between W+ and W- or between two Z0's.
73547 C...No separation if there has been re-connections.
73548  sigw=parj(93)
73549  IF(iwp.GT.0.AND.iwn.GT.0.AND.mstj(56).GT.0.AND.mint(32).EQ.0) THEN
73550  IF(k(iwp,2).EQ.23) THEN
73551  dmw=pmas(23,1)
73552  dgw=pmas(23,2)
73553  ELSE
73554  dmw=pmas(24,1)
73555  dgw=pmas(24,2)
73556  ENDIF
73557  dmp=p(iwp,5)
73558  dmn=p(iwn,5)
73559  taupd=dmp/sqrt((dmp**2-dmw**2)**2+(dgw*(dmp**2)/dmw)**2)
73560  taund=dmn/sqrt((dmn**2-dmw**2)**2+(dgw*(dmn**2)/dmw)**2)
73561  taup=-taupd*log(pyr(idum))
73562  taun=-taund*log(pyr(idum))
73563  dxp=taup*pyp(iwp,8)/dmp
73564  dxn=taun*pyp(iwn,8)/dmn
73565  dx=dxp+dxn
73566  sigw=1.0d0/(1.0d0/parj(93)+REAL(mstj(56))*dx)
73567  IF(parj(94).LT.0.0d0) sigw=1.0d0/(1.0d0/sigw-1.0d0/parj(94))
73568  ENDIF
73569 
73570 C...Add separation between strings.
73571  IF(parj(94).GT.0.0d0) THEN
73572  sigw=1.0d0/(1.0d0/sigw+1.0d0/parj(94))
73573  iwp=-1
73574  iwn=-1
73575  ENDIF
73576 
73577  IF(mstj(57).EQ.1.AND.mstj(54).LT.0) THEN
73578  DO 220 ibe=1,min(9,mstj(52))
73579  DO 210 i1m=nbe(ibe-1)+1,nbe(ibe)
73580  q2min=pecm**2
73581  i1=k(i1m,1)
73582  DO 200 i2m=nbe(ibe-1)+1,nbe(ibe)
73583  IF(i2m.EQ.i1m) goto 200
73584  i2=k(i2m,1)
73585  q2=(p(i1,4)+p(i2,4))**2-(p(i1,1)+p(i2,1))**2-
73586  & (p(i1,2)+p(i2,2))**2-(p(i1,3)+p(i2,3))**2-
73587  & (p(i1,5)+p(i2,5))**2
73588  IF(q2.GT.0.0d0.AND.q2.LT.q2min) THEN
73589  q2min=q2
73590  ENDIF
73591  200 CONTINUE
73592  p(i1m,5)=q2min
73593  210 CONTINUE
73594  220 CONTINUE
73595  ENDIF
73596 
73597 C...Tabulate integral for subsequent momentum shift.
73598  DO 400 ibe=1,min(9,mstj(52))
73599  IF(ibe.NE.1.AND.ibe.NE.4.AND.ibe.LE.7) goto 270
73600  IF(ibe.EQ.1.AND.max(nbe(1)-nbe(0),nbe(2)-nbe(1),nbe(3)-nbe(2))
73601  & .LE.1) goto 270
73602  IF(ibe.EQ.4.AND.max(nbe(4)-nbe(3),nbe(5)-nbe(4),nbe(6)-nbe(5),
73603  & nbe(7)-nbe(6)).LE.1) goto 270
73604  IF(ibe.GE.8.AND.nbe(ibe)-nbe(ibe-1).LE.1) goto 270
73605  IF(ibe.EQ.1) pmhq=2d0*pymass(211)
73606  IF(ibe.EQ.4) pmhq=2d0*pymass(321)
73607  IF(ibe.EQ.8) pmhq=2d0*pymass(221)
73608  IF(ibe.EQ.9) pmhq=2d0*pymass(331)
73609  qdel=0.1d0*min(pmhq,parj(93))
73610  qdel3=0.1d0*min(pmhq,parj(93)*3.0d0)
73611  qdelw=0.1d0*min(pmhq,sigw)
73612  qdel3w=0.1d0*min(pmhq,sigw*3.0d0)
73613  IF(mstj(51).EQ.1) THEN
73614  nbin=min(100,nint(9d0*parj(93)/qdel))
73615  nbin3=min(100,nint(27d0*parj(93)/qdel3))
73616  nbinw=min(100,nint(9d0*sigw/qdelw))
73617  nbin3w=min(100,nint(27d0*sigw/qdel3w))
73618  beex=exp(0.5d0*qdel/parj(93))
73619  beex3=exp(0.5d0*qdel3/(3.0d0*parj(93)))
73620  beexw=exp(0.5d0*qdelw/sigw)
73621  beex3w=exp(0.5d0*qdel3w/(3.0d0*sigw))
73622  bert=exp(-qdel/parj(93))
73623  bert3=exp(-qdel3/(3.0d0*parj(93)))
73624  bertw=exp(-qdelw/sigw)
73625  bert3w=exp(-qdel3w/(3.0d0*sigw))
73626  ELSE
73627  nbin=min(100,nint(3d0*parj(93)/qdel))
73628  nbin3=min(100,nint(9d0*parj(93)/qdel3))
73629  nbinw=min(100,nint(3d0*sigw/qdelw))
73630  nbin3w=min(100,nint(9d0*sigw/qdel3w))
73631  ENDIF
73632  DO 230 ibin=1,nbin
73633  qbin=qdel*(ibin-0.5d0)
73634  bei(ibin)=qdel*(qbin**2+qdel**2/12d0)/sqrt(qbin**2+pmhq**2)
73635  IF(mstj(51).EQ.1) THEN
73636  beex=beex*bert
73637  bei(ibin)=bei(ibin)*beex
73638  ELSE
73639  bei(ibin)=bei(ibin)*exp(-(qbin/parj(93))**2)
73640  ENDIF
73641  IF(ibin.GE.2) bei(ibin)=bei(ibin)+bei(ibin-1)
73642  230 CONTINUE
73643  DO 240 ibin=1,nbin3
73644  qbin=qdel3*(ibin-0.5d0)
73645  bei3(ibin)=qdel3*(qbin**2+qdel3**2/12d0)/sqrt(qbin**2+pmhq**2)
73646  IF(mstj(51).EQ.1) THEN
73647  beex3=beex3*bert3
73648  bei3(ibin)=bei3(ibin)*beex3
73649  ELSE
73650  bei3(ibin)=bei3(ibin)*exp(-(qbin/(3.0d0*parj(93)))**2)
73651  ENDIF
73652  IF(ibin.GE.2) bei3(ibin)=bei3(ibin)+bei3(ibin-1)
73653  240 CONTINUE
73654  DO 250 ibin=1,nbinw
73655  qbin=qdelw*(ibin-0.5d0)
73656  beiw(ibin)=qdelw*(qbin**2+qdelw**2/12d0)/sqrt(qbin**2+pmhq**2)
73657  IF(mstj(51).EQ.1) THEN
73658  beexw=beexw*bertw
73659  beiw(ibin)=beiw(ibin)*beexw
73660  ELSE
73661  beiw(ibin)=beiw(ibin)*exp(-(qbin/sigw)**2)
73662  ENDIF
73663  IF(ibin.GE.2) beiw(ibin)=beiw(ibin)+beiw(ibin-1)
73664  250 CONTINUE
73665  DO 260 ibin=1,nbin3w
73666  qbin=qdel3w*(ibin-0.5d0)
73667  bei3w(ibin)=qdel3w*(qbin**2+qdel3w**2/12d0)/
73668  & sqrt(qbin**2+pmhq**2)
73669  IF(mstj(51).EQ.1) THEN
73670  beex3w=beex3w*bert3w
73671  bei3w(ibin)=bei3w(ibin)*beex3w
73672  ELSE
73673  bei3w(ibin)=bei3w(ibin)*exp(-(qbin/(3.0d0*sigw))**2)
73674  ENDIF
73675  IF(ibin.GE.2) bei3w(ibin)=bei3w(ibin)+bei3w(ibin-1)
73676  260 CONTINUE
73677 
73678 C...Loop through particle pairs and find old relative momentum.
73679  270 DO 390 i1m=nbe(ibe-1)+1,nbe(ibe)-1
73680  i1=k(i1m,1)
73681  DO 380 i2m=i1m+1,nbe(ibe)
73682  IF(mstj(53).EQ.1.AND.k(i1m,5).NE.k(i2m,5)) goto 380
73683  IF(mstj(53).EQ.2.AND.k(i1m,5).EQ.k(i2m,5)) goto 380
73684  i2=k(i2m,1)
73685  q2old=(p(i1,4)+p(i2,4))**2-(p(i1,1)+p(i2,1))**2-(p(i1,2)+
73686  & p(i2,2))**2-(p(i1,3)+p(i2,3))**2-(p(i1,5)+p(i2,5))**2
73687  IF(q2old.LE.0.0d0) goto 380
73688  qold=sqrt(q2old)
73689 
73690 C...Calculate new relative momentum.
73691  qmov=0.0d0
73692  qmov3=0.0d0
73693  qmovw=0.0d0
73694  qmov3w=0.0d0
73695  IF(qold.LT.1d-3*qdel) THEN
73696  goto 280
73697  ELSEIF(qold.LE.qdel) THEN
73698  qmov=qold/3d0
73699  ELSEIF(qold.LT.(nbin-0.1d0)*qdel) THEN
73700  rbin=qold/qdel
73701  ibin=rbin
73702  rinp=(rbin**3-ibin**3)/(3*ibin*(ibin+1)+1)
73703  qmov=(bei(ibin)+rinp*(bei(ibin+1)-bei(ibin)))*
73704  & sqrt(q2old+pmhq**2)/q2old
73705  ELSE
73706  qmov=bei(nbin)*sqrt(q2old+pmhq**2)/q2old
73707  ENDIF
73708  280 q2new=q2old*(qold/(qold+3d0*parj(92)*qmov))**(2d0/3d0)
73709  IF(qold.LT.1d-3*qdel3) THEN
73710  goto 290
73711  ELSEIF(qold.LE.qdel3) THEN
73712  qmov3=qold/3d0
73713  ELSEIF(qold.LT.(nbin3-0.1d0)*qdel3) THEN
73714  rbin3=qold/qdel3
73715  ibin3=rbin3
73716  rinp3=(rbin3**3-ibin3**3)/(3*ibin3*(ibin3+1)+1)
73717  qmov3=(bei3(ibin3)+rinp3*(bei3(ibin3+1)-bei3(ibin3)))*
73718  & sqrt(q2old+pmhq**2)/q2old
73719  ELSE
73720  qmov3=bei3(nbin3)*sqrt(q2old+pmhq**2)/q2old
73721  ENDIF
73722  290 q2new3=q2old*(qold/(qold+3d0*parj(92)*qmov3))**(2d0/3d0)
73723  rscale=1.0d0
73724  IF(mstj(54).EQ.2)
73725  & rscale=1.0d0-exp(-(qold/(2d0*parj(93)))**2)
73726  IF((iwp.NE.-1.AND.mstj(56).LE.0).OR.iwp.EQ.0.OR.iwn.EQ.0.OR.
73727  & k(i1m,5).EQ.k(i2m,5)) goto 320
73728 
73729  IF(qold.LT.1d-3*qdelw) THEN
73730  goto 300
73731  ELSEIF(qold.LE.qdelw) THEN
73732  qmovw=qold/3d0
73733  ELSEIF(qold.LT.(nbinw-0.1d0)*qdelw) THEN
73734  rbinw=qold/qdelw
73735  ibinw=rbinw
73736  rinpw=(rbinw**3-ibinw**3)/(3*ibinw*(ibinw+1)+1)
73737  qmovw=(beiw(ibinw)+rinpw*(beiw(ibinw+1)-beiw(ibinw)))*
73738  & sqrt(q2old+pmhq**2)/q2old
73739  ELSE
73740  qmovw=beiw(nbinw)*sqrt(q2old+pmhq**2)/q2old
73741  ENDIF
73742  300 q2new=q2old*(qold/(qold+3d0*parj(92)*qmovw))**(2d0/3d0)
73743  IF(qold.LT.1d-3*qdel3w) THEN
73744  goto 310
73745  ELSEIF(qold.LE.qdel3w) THEN
73746  qmov3w=qold/3d0
73747  ELSEIF(qold.LT.(nbin3w-0.1d0)*qdel3w) THEN
73748  rbin3w=qold/qdel3w
73749  ibin3w=rbin3w
73750  rinp3w=(rbin3w**3-ibin3w**3)/(3*ibin3w*(ibin3w+1)+1)
73751  qmov3w=(bei3w(ibin3w)+rinp3w*(bei3w(ibin3w+1)-
73752  & bei3w(ibin3w)))*sqrt(q2old+pmhq**2)/q2old
73753  ELSE
73754  qmov3w=bei3w(nbin3w)*sqrt(q2old+pmhq**2)/q2old
73755  ENDIF
73756  310 q2new3=q2old*(qold/(qold+3d0*parj(92)*qmov3w))**(2d0/3d0)
73757  IF(mstj(54).EQ.2)
73758  & rscale=1.0d0-exp(-(qold/(2d0*sigw))**2)
73759 
73760  320 CALL pybesq(i1,i2,nmax,q2old,q2new)
73761  DO 330 j=1,3
73762  p(i1m,j)=p(i1m,j)+p(nmax+1,j)
73763  p(i2m,j)=p(i2m,j)+p(nmax+2,j)
73764  330 CONTINUE
73765  IF(mstj(54).GE.1) THEN
73766  CALL pybesq(i1,i2,nmax,q2old,q2new3)
73767  DO 340 j=1,3
73768  v(i1m,j)=v(i1m,j)+p(nmax+1,j)*rscale
73769  v(i2m,j)=v(i2m,j)+p(nmax+2,j)*rscale
73770  340 CONTINUE
73771  ELSEIF(mstj(54).LE.-1) THEN
73772  edel=p(i1,4)+p(i2,4)-
73773  & sqrt(max(q2new-q2old+(p(i1,4)+p(i2,4))**2,0.0d0))
73774  a2=(p(i1,1)-p(i2,1))**2+(p(i1,2)-p(i2,2))**2+
73775  & (p(i1,3)-p(i2,3))**2
73776  wmax=-1.0d20
73777  mi3=0
73778  mi4=0
73779  s12=sdip(i1,i2)
73780  sm1=(p(i1,5)+smmin)**2
73781  DO 360 i3m=nbe(0)+1,nbe(min(10,mstj(52)+1))
73782  IF(i3m.EQ.i1m.OR.i3m.EQ.i2m) goto 360
73783  IF(mstj(53).EQ.1.AND.k(i3m,5).NE.k(i1m,5)) goto 360
73784  IF(mstj(53).EQ.-2.AND.k(i1m,5).EQ.k(i2m,5).AND.
73785  & k(i3m,5).NE.k(i1m,5)) goto 360
73786  i3=k(i3m,1)
73787  IF(k(i3,2).EQ.k(i1,2)) goto 360
73788  s13=sdip(i1,i3)
73789  s23=sdip(i2,i3)
73790  sm3=(p(i3,5)+smmin)**2
73791  IF(mstj(54).EQ.-2) THEN
73792  wi=(min(s12*sm3,s13*min(sm1,sm3),
73793  & s23*min(sm1,sm3))*sm1)
73794  ELSE
73795  wi=((p(i1,4)+p(i2,4)+p(i3,4))**2-
73796  & (p(i1,3)+p(i2,3)+p(i3,3))**2-
73797  & (p(i1,2)+p(i2,2)+p(i3,2))**2-
73798  & (p(i1,1)+p(i2,1)+p(i3,1))**2)
73799  ENDIF
73800  IF(mstj(57).EQ.1.AND.p(i3m,5).GT.0) THEN
73801  IF (wmax*wi.GE.(1.0d0-exp(-p(i3m,5)/(parj(93)**2))))
73802  & goto 360
73803  ELSE
73804  IF(wmax*wi.GE.1.0) goto 360
73805  ENDIF
73806  DO 350 i4m=i3m+1,nbe(min(10,mstj(52)+1))
73807  IF(i4m.EQ.i1m.OR.i4m.EQ.i2m) goto 350
73808  IF(mstj(53).EQ.1.AND.k(i4m,5).NE.k(i1m,5)) goto 350
73809  IF(mstj(53).EQ.-2.AND.k(i1m,5).EQ.k(i2m,5).AND.
73810  & k(i4m,5).NE.k(i1m,5)) goto 350
73811  i4=k(i4m,1)
73812  IF(k(i3,2).EQ.k(i4,2).OR.k(i4,2).EQ.k(i1,2))
73813  & goto 350
73814  IF((p(i3,4)+p(i4,4)+edel)**2.LT.
73815  & (p(i3,1)+p(i4,1))**2+(p(i3,2)+p(i4,2))**2+
73816  & (p(i3,3)+p(i4,3))**2+(p(i3,5)+p(i4,5))**2)
73817  & goto 350
73818  IF(mstj(54).EQ.-2) THEN
73819  s14=sdip(i1,i4)
73820  s24=sdip(i2,i4)
73821  s34=sdip(i3,i4)
73822  w=s12*min(min(s23,s24),min(s13,s14))*s34
73823  w=min(w,s13*min(min(s23,s34),s12)*s24)
73824  w=min(w,s14*min(min(s24,s34),s12)*s23)
73825  w=min(w,min(s23,s24)*s13*s14)
73826  w=1.0d0/w
73827  ELSE
73828 C...weight=1-cos(theta)/mtot2
73829  s1234=(p(i1,4)+p(i2,4)+p(i3,4)+p(i4,4))**2-
73830  & (p(i1,3)+p(i2,3)+p(i3,3)+p(i4,3))**2-
73831  & (p(i1,2)+p(i2,2)+p(i3,2)+p(i4,2))**2-
73832  & (p(i1,1)+p(i2,1)+p(i3,1)+p(i4,1))**2
73833  w=1.0d0/s1234
73834  IF(w.LE.wmax) goto 350
73835  ENDIF
73836  IF(mstj(57).EQ.1.AND.p(i3m,5).GT.0)
73837  & w=w*(1.0d0-exp(-p(i3m,5)/(parj(93)**2)))
73838  IF(mstj(57).EQ.1.AND.p(i4m,5).GT.0)
73839  & w=w*(1.0d0-exp(-p(i4m,5)/(parj(93)**2)))
73840  IF(w.LE.wmax) goto 350
73841  mi3=i3m
73842  mi4=i4m
73843  wmax=w
73844  350 CONTINUE
73845  360 CONTINUE
73846  IF(mi4.EQ.0) goto 380
73847  i3=k(mi3,1)
73848  i4=k(mi4,1)
73849  eold=p(i3,4)+p(i4,4)
73850  enew=eold+edel
73851  p2=(p(i3,1)+p(i4,1))**2+(p(i3,2)+p(i4,2))**2+
73852  & (p(i3,3)+p(i4,3))**2
73853  q2newp=max(0.0d0,enew**2-p2-(p(i3,5)+p(i4,5))**2)
73854  q2oldp=max(0.0d0,eold**2-p2-(p(i3,5)+p(i4,5))**2)
73855  CALL pybesq(i3,i4,nmax,q2oldp,q2newp)
73856  DO 370 j=1,3
73857  v(mi3,j)=v(mi3,j)+p(nmax+1,j)
73858  v(mi4,j)=v(mi4,j)+p(nmax+2,j)
73859  370 CONTINUE
73860  ENDIF
73861  380 CONTINUE
73862  390 CONTINUE
73863  400 CONTINUE
73864 
73865 C...Shift momenta and recalculate energies.
73866  esump=0.0d0
73867  esum=0.0d0
73868  prod=0.0d0
73869  DO 430 im=nbe(0)+1,nbe(min(10,mstj(52)+1))
73870  i=k(im,1)
73871  esump=esump+p(i,4)
73872  DO 410 j=1,3
73873  p(i,j)=p(i,j)+p(im,j)
73874  410 CONTINUE
73875  p(i,4)=sqrt(p(i,5)**2+p(i,1)**2+p(i,2)**2+p(i,3)**2)
73876  esum=esum+p(i,4)
73877  DO 420 j=1,3
73878  prod=prod+v(im,j)*p(i,j)/p(i,4)
73879  420 CONTINUE
73880  430 CONTINUE
73881 
73882  parj(96)=0.0d0
73883  IF(mstj(54).NE.0.AND.prod.NE.0.0d0) THEN
73884  440 alpha=(esump-esum)/prod
73885  parj(96)=parj(96)+alpha
73886  prod=0.0d0
73887  esum=0.0d0
73888  DO 470 im=nbe(0)+1,nbe(min(10,mstj(52)+1))
73889  i=k(im,1)
73890  DO 450 j=1,3
73891  p(i,j)=p(i,j)+alpha*v(im,j)
73892  450 CONTINUE
73893  p(i,4)=sqrt(p(i,5)**2+p(i,1)**2+p(i,2)**2+p(i,3)**2)
73894  esum=esum+p(i,4)
73895  DO 460 j=1,3
73896  prod=prod+v(im,j)*p(i,j)/p(i,4)
73897  460 CONTINUE
73898  470 CONTINUE
73899  IF(prod.NE.0.0d0.AND.abs(esump-esum)/pecm.GT.0.00001d0)
73900  & goto 440
73901  ENDIF
73902 
73903 C...Rescale all momenta for energy conservation.
73904  pes=0d0
73905  pqs=0d0
73906  DO 480 i=1,n
73907  IF(k(i,1).LE.0.OR.k(i,1).GT.10) goto 480
73908  pes=pes+p(i,4)
73909  pqs=pqs+p(i,5)**2/p(i,4)
73910  480 CONTINUE
73911  parj(95)=pes-pecm
73912  fac=(pecm-pqs)/(pes-pqs)
73913  DO 500 i=1,n
73914  IF(k(i,1).LE.0.OR.k(i,1).GT.10) goto 500
73915  DO 490 j=1,3
73916  p(i,j)=fac*p(i,j)
73917  490 CONTINUE
73918  p(i,4)=sqrt(p(i,5)**2+p(i,1)**2+p(i,2)**2+p(i,3)**2)
73919  500 CONTINUE
73920 
73921 C...Boost back to correct reference frame.
73922  510 CALL pyrobo(0,0,0d0,0d0,dps(1)/dps(4),dps(2)/dps(4),dps(3)/dps(4))
73923  DO 520 i=1,n
73924  IF(k(i,1).LT.0) k(i,1)=-k(i,1)
73925  520 CONTINUE
73926 
73927  RETURN
73928  END
73929 
73930 C*********************************************************************
73931 
73932 C...PYBESQ
73933 C...Calculates the momentum shift in a system of two particles assuming
73934 C...the relative momentum squared should be shifted to Q2NEW. NI is the
73935 C...last position occupied in /PYJETS/.
73936 
73937  SUBROUTINE pybesq(I1,I2,NI,Q2OLD,Q2NEW)
73938 
73939 C...Double precision and integer declarations.
73940  IMPLICIT DOUBLE PRECISION(a-h, o-z)
73941  IMPLICIT INTEGER(i-n)
73942  INTEGER pyk,pychge,pycomp
73943 C...Parameter statement to help give large particle numbers.
73944  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
73945  &kexcit=4000000,kdimen=5000000)
73946 C...Commonblocks.
73947  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
73948  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
73949  SAVE /pyjets/,/pydat1/
73950 C...Local arrays and data.
73951  dimension dp(5)
73952  SAVE hc1
73953 
73954  IF(mstj(55).EQ.0) THEN
73955  dq2=q2new-q2old
73956  dp2=(p(i1,1)-p(i2,1))**2+(p(i1,2)-p(i2,2))**2+
73957  & (p(i1,3)-p(i2,3))**2
73958  dp12=p(i1,1)**2+p(i1,2)**2+p(i1,3)**2
73959  & -p(i2,1)**2-p(i2,2)**2-p(i2,3)**2
73960  se=p(i1,4)+p(i2,4)
73961  de=p(i1,4)-p(i2,4)
73962  dq2se=dq2+se**2
73963  da=se*de*dp12-dp2*dq2se
73964  db=dp2*dq2se-dp12**2
73965  ha=(da+sqrt(max(da**2+dq2*(dq2+se**2-de**2)*db,0d0)))/(2d0*db)
73966  DO 100 j=1,3
73967  pd=ha*(p(i1,j)-p(i2,j))
73968  p(ni+1,j)=pd
73969  p(ni+2,j)=-pd
73970  100 CONTINUE
73971  RETURN
73972  ENDIF
73973 
73974  k(ni+1,1)=1
73975  k(ni+2,1)=1
73976  DO 110 j=1,5
73977  p(ni+1,j)=p(i1,j)
73978  p(ni+2,j)=p(i2,j)
73979  dp(j)=p(i1,j)+p(i2,j)
73980  110 CONTINUE
73981 
73982 C...Boost to cms and rotate first particle to z-axis
73983  CALL pyrobo(ni+1,ni+2,0.0d0,0.0d0,
73984  &-dp(1)/dp(4),-dp(2)/dp(4),-dp(3)/dp(4))
73985  phi=pyangl(p(ni+1,1),p(ni+1,2))
73986  the=pyangl(p(ni+1,3),sqrt(p(ni+1,1)**2+p(ni+1,2)**2))
73987  s=q2new+(p(i1,5)+p(i2,5))**2
73988  pz=0.5d0*sqrt(q2new*(s-(p(i1,5)-p(i2,5))**2)/s)
73989  p(ni+1,1)=0.0d0
73990  p(ni+1,2)=0.0d0
73991  p(ni+1,3)=pz
73992  p(ni+1,4)=sqrt(pz**2+p(i1,5)**2)
73993  p(ni+2,1)=0.0d0
73994  p(ni+2,2)=0.0d0
73995  p(ni+2,3)=-pz
73996  p(ni+2,4)=sqrt(pz**2+p(i2,5)**2)
73997  dp(4)=sqrt(dp(1)**2+dp(2)**2+dp(3)**2+s)
73998  CALL pyrobo(ni+1,ni+2,the,phi,
73999  &dp(1)/dp(4),dp(2)/dp(4),dp(3)/dp(4))
74000 
74001  DO 120 j=1,3
74002  p(ni+1,j)=p(ni+1,j)-p(i1,j)
74003  p(ni+2,j)=p(ni+2,j)-p(i2,j)
74004  120 CONTINUE
74005 
74006  RETURN
74007  END
74008 
74009 C*********************************************************************
74010 
74011 C...PYMASS
74012 C...Gives the mass of a particle/parton.
74013 
74014  FUNCTION pymass(KF)
74015 
74016 C...Double precision and integer declarations.
74017  IMPLICIT DOUBLE PRECISION(a-h, o-z)
74018  IMPLICIT INTEGER(i-n)
74019  INTEGER pyk,pychge,pycomp
74020 C...Commonblocks.
74021  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
74022  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
74023  SAVE /pydat1/,/pydat2/
74024 
74025 C...Reset variables. Compressed code. Special case for popcorn diquarks.
74026  pymass=0d0
74027  kfa=iabs(kf)
74028  kc=pycomp(kf)
74029  IF(kc.EQ.0) THEN
74030  mstj(93)=0
74031  RETURN
74032  ENDIF
74033 
74034 C...Guarantee use of constituent masses for internal checks.
74035  IF((mstj(93).EQ.1.OR.mstj(93).EQ.2).AND.
74036  &(kfa.LE.10.OR.mod(kfa/10,10).EQ.0)) THEN
74037  IF(kfa.LE.5) THEN
74038  pymass=parf(100+kfa)
74039  IF(mstj(93).EQ.2) pymass=max(0d0,pymass-parf(121))
74040  ELSEIF(kfa.LE.10) THEN
74041  pymass=pmas(kfa,1)
74042  ELSEIF(mstj(93).EQ.1) THEN
74043  pymass=parf(100+mod(kfa/1000,10))+parf(100+mod(kfa/100,10))
74044  ELSE
74045  pymass=max(0d0,pmas(kc,1)-parf(122)-2d0*parf(112)/3d0)
74046  ENDIF
74047 
74048 C...Other masses can be read directly off table.
74049  ELSE
74050  pymass=pmas(kc,1)
74051  ENDIF
74052 
74053 C...Optional mass broadening according to truncated Breit-Wigner
74054 C...(either in m or in m^2).
74055  IF(mstj(24).GE.1.AND.pmas(kc,2).GT.1d-4) THEN
74056  IF(mstj(24).EQ.1.OR.(mstj(24).EQ.2.AND.kfa.GT.100)) THEN
74057  pymass=pymass+0.5d0*pmas(kc,2)*tan((2d0*pyr(0)-1d0)*
74058  & atan(2d0*pmas(kc,3)/pmas(kc,2)))
74059  ELSE
74060  pm0=pymass
74061  pmlow=atan((max(0d0,pm0-pmas(kc,3))**2-pm0**2)/
74062  & (pm0*pmas(kc,2)))
74063  pmupp=atan(((pm0+pmas(kc,3))**2-pm0**2)/(pm0*pmas(kc,2)))
74064  pymass=sqrt(max(0d0,pm0**2+pm0*pmas(kc,2)*tan(pmlow+
74065  & (pmupp-pmlow)*pyr(0))))
74066  ENDIF
74067  ENDIF
74068  mstj(93)=0
74069 
74070  RETURN
74071  END
74072 
74073 C*********************************************************************
74074 
74075 C...PYMRUN
74076 C...Gives the running, current-algebra mass of a d, u, s, c or b quark,
74077 C...for Higgs couplings. Everything else sent on to PYMASS.
74078 
74079  FUNCTION pymrun(KF,Q2)
74080 
74081 C...Double precision and integer declarations.
74082  IMPLICIT DOUBLE PRECISION(a-h, o-z)
74083  IMPLICIT INTEGER(i-n)
74084  INTEGER pyk,pychge,pycomp
74085 C...Commonblocks.
74086  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
74087  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
74088  common/pypars/mstp(200),parp(200),msti(200),pari(200)
74089  SAVE /pydat1/,/pydat2/,/pypars/
74090 
74091 C...Most masses not handled here.
74092  kfa=iabs(kf)
74093  IF(kfa.EQ.0.OR.kfa.GT.6) THEN
74094  pymrun=pymass(kf)
74095 
74096 C...Current-algebra masses, but no Q2 dependence.
74097  ELSEIF(mstp(37).NE.1.OR.mstp(2).LE.0) THEN
74098  pymrun=parf(90+kfa)
74099 
74100 C...Running current-algebra masses.
74101  ELSE
74102  as=pyalps(q2)
74103  pymrun=parf(90+kfa)*
74104  & (log(max(4d0,parp(37)**2*parf(90+kfa)**2/paru(117)**2))/
74105  & log(max(4d0,q2/paru(117)**2)))**(12d0/(33d0-2d0*mstu(118)))
74106  ENDIF
74107 
74108  RETURN
74109  END
74110 
74111 C*********************************************************************
74112 
74113 C...PYNAME
74114 C...Gives the particle/parton name as a character string.
74115 
74116  SUBROUTINE pyname(KF,CHAU)
74117 
74118 C...Double precision and integer declarations.
74119  IMPLICIT DOUBLE PRECISION(a-h, o-z)
74120  IMPLICIT INTEGER(i-n)
74121  INTEGER pyk,pychge,pycomp
74122 C...Commonblocks.
74123  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
74124  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
74125  common/pydat4/chaf(500,2)
74126  CHARACTER chaf*16
74127  SAVE /pydat1/,/pydat2/,/pydat4/
74128 C...Local character variable.
74129  CHARACTER chau*16
74130 
74131 C...Read out code with distinction particle/antiparticle.
74132  chau=' '
74133  kc=pycomp(kf)
74134  IF(kc.NE.0) chau=chaf(kc,(3-isign(1,kf))/2)
74135 
74136 
74137  RETURN
74138  END
74139 
74140 C*********************************************************************
74141 
74142 C...PYCHGE
74143 C...Gives three times the charge for a particle/parton.
74144 
74145  FUNCTION pychge(KF)
74146 
74147 C...Double precision and integer declarations.
74148  IMPLICIT DOUBLE PRECISION(a-h, o-z)
74149  IMPLICIT INTEGER(i-n)
74150  INTEGER pyk,pychge,pycomp
74151 C...Commonblocks.
74152  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
74153  SAVE /pydat2/
74154 
74155 C...Read out charge and change sign for antiparticle.
74156  pychge=0
74157  kc=pycomp(kf)
74158  IF(kc.NE.0) pychge=kchg(kc,1)*isign(1,kf)
74159 
74160  RETURN
74161  END
74162 
74163 C*********************************************************************
74164 
74165 C...PYCOMP
74166 C...Compress the standard KF codes for use in mass and decay arrays;
74167 C...also checks whether a given code actually is defined.
74168 
74169  FUNCTION pycomp(KF)
74170 
74171 C...Double precision and integer declarations.
74172  IMPLICIT DOUBLE PRECISION(a-h, o-z)
74173  IMPLICIT INTEGER(i-n)
74174  INTEGER pyk,pychge,pycomp
74175 C...Commonblocks.
74176  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
74177  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
74178  SAVE /pydat1/,/pydat2/
74179 C...Local arrays and saved data.
74180  dimension kford(100:500),kcord(101:500)
74181  SAVE kford,kcord,nford,kflast,kclast
74182 
74183 C...Whenever necessary reorder codes for faster search.
74184  IF(mstu(20).EQ.0) THEN
74185  nford=100
74186  kford(100)=0
74187  DO 120 i=101,500
74188  kfa=kchg(i,4)
74189  IF(kfa.LE.100) goto 120
74190  nford=nford+1
74191  DO 100 i1=nford-1,0,-1
74192  IF(kfa.GE.kford(i1)) goto 110
74193  kford(i1+1)=kford(i1)
74194  kcord(i1+1)=kcord(i1)
74195  100 CONTINUE
74196  110 kford(i1+1)=kfa
74197  kcord(i1+1)=i
74198  120 CONTINUE
74199  mstu(20)=1
74200  kflast=0
74201  kclast=0
74202  ENDIF
74203 
74204 C...Fast action if same code as in latest call.
74205  IF(kf.EQ.kflast) THEN
74206  pycomp=kclast
74207  RETURN
74208  ENDIF
74209 
74210 C...Starting values. Remove internal diquark flags.
74211  pycomp=0
74212  kfa=iabs(kf)
74213  IF(mod(kfa/10,10).EQ.0.AND.kfa.LT.100000
74214  & .AND.mod(kfa/1000,10).GT.0) kfa=mod(kfa,10000)
74215 
74216 C...Simple cases: direct translation.
74217  IF(kfa.GT.kford(nford)) THEN
74218  ELSEIF(kfa.LE.100) THEN
74219  pycomp=kfa
74220 
74221 C...Else binary search.
74222  ELSE
74223  imin=100
74224  imax=nford+1
74225  130 iavg=(imin+imax)/2
74226  IF(kford(iavg).GT.kfa) THEN
74227  imax=iavg
74228  IF(imax.GT.imin+1) goto 130
74229  ELSEIF(kford(iavg).LT.kfa) THEN
74230  imin=iavg
74231  IF(imax.GT.imin+1) goto 130
74232  ELSE
74233  pycomp=kcord(iavg)
74234  ENDIF
74235  ENDIF
74236 
74237 C...Check if antiparticle allowed.
74238  IF(pycomp.NE.0.AND.kf.LT.0) THEN
74239  IF(kchg(pycomp,3).EQ.0) pycomp=0
74240  ENDIF
74241 
74242 C...Save codes for possible future fast action.
74243  kflast=kf
74244  kclast=pycomp
74245 
74246  RETURN
74247  END
74248 
74249 C*********************************************************************
74250 
74251 C...PYERRM
74252 C...Informs user of errors in program execution.
74253 
74254  SUBROUTINE pyerrm(MERR,CHMESS)
74255 
74256 C...Double precision and integer declarations.
74257  IMPLICIT DOUBLE PRECISION(a-h, o-z)
74258  IMPLICIT INTEGER(i-n)
74259  INTEGER pyk,pychge,pycomp
74260 C...Commonblocks.
74261  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
74262  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
74263  SAVE /pyjets/,/pydat1/
74264 C...Local character variable.
74265  CHARACTER chmess*(*)
74266 
74267 C...Write first few warnings, then be silent.
74268  IF(merr.LE.10) THEN
74269  mstu(27)=mstu(27)+1
74270  mstu(28)=merr
74271  IF(mstu(25).EQ.1.AND.mstu(27).LE.mstu(26)) WRITE(mstu(11),5000)
74272  & merr,mstu(31),chmess
74273 
74274 C...Write first few errors, then be silent or stop program.
74275  ELSEIF(merr.LE.20) THEN
74276  IF(mstu(29).EQ.0) mstu(23)=mstu(23)+1
74277  mstu(30)=mstu(30)+1
74278  mstu(24)=merr-10
74279  IF(mstu(21).GE.1.AND.mstu(23).LE.mstu(22)) WRITE(mstu(11),5100)
74280  & merr-10,mstu(31),chmess
74281  IF(mstu(21).GE.2.AND.mstu(23).GT.mstu(22)) THEN
74282  WRITE(mstu(11),5100) merr-10,mstu(31),chmess
74283  WRITE(mstu(11),5200)
74284  IF(merr.NE.17) CALL pylist(2)
74285  CALL pystop(3)
74286  ENDIF
74287 
74288 C...Stop program in case of irreparable error.
74289  ELSE
74290  WRITE(mstu(11),5300) merr-20,mstu(31),chmess
74291  CALL pystop(3)
74292  ENDIF
74293 
74294 C...Formats for output.
74295  5000 FORMAT(/5x,'Advisory warning type',i2,' given after',i9,
74296  &' PYEXEC calls:'/5x,a)
74297  5100 FORMAT(/5x,'Error type',i2,' has occured after',i9,
74298  &' PYEXEC calls:'/5x,a)
74299  5200 FORMAT(5x,'Execution will be stopped after listing of last ',
74300  &'event!')
74301  5300 FORMAT(/5x,'Fatal error type',i2,' has occured after',i9,
74302  &' PYEXEC calls:'/5x,a/5x,'Execution will now be stopped!')
74303 
74304  RETURN
74305  END
74306 
74307 C*********************************************************************
74308 
74309 C...PYALEM
74310 C...Calculates the running alpha_electromagnetic.
74311 
74312  FUNCTION pyalem(Q2)
74313 
74314 C...Double precision and integer declarations.
74315  IMPLICIT DOUBLE PRECISION(a-h, o-z)
74316  IMPLICIT INTEGER(i-n)
74317  INTEGER pyk,pychge,pycomp
74318 C...Commonblocks.
74319  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
74320  SAVE /pydat1/
74321 
74322 C...Calculate real part of photon vacuum polarization.
74323 C...For leptons simplify by using asymptotic (Q^2 >> m^2) expressions.
74324 C...For hadrons use parametrization of H. Burkhardt et al.
74325 C...See R. Kleiss et al, CERN 89-08, vol. 3, pp. 129-131.
74326  aempi=paru(101)/(3d0*paru(1))
74327  IF(mstu(101).LE.0.OR.q2.LT.2d-6) THEN
74328  rpigg=0d0
74329  ELSEIF(mstu(101).EQ.2.AND.q2.LT.paru(104)) THEN
74330  rpigg=0d0
74331  ELSEIF(mstu(101).EQ.2) THEN
74332  rpigg=1d0-paru(101)/paru(103)
74333  ELSEIF(q2.LT.0.09d0) THEN
74334  rpigg=aempi*(13.4916d0+log(q2))+0.00835d0*log(1d0+q2)
74335  ELSEIF(q2.LT.9d0) THEN
74336  rpigg=aempi*(16.3200d0+2d0*log(q2))+
74337  & 0.00238d0*log(1d0+3.927d0*q2)
74338  ELSEIF(q2.LT.1d4) THEN
74339  rpigg=aempi*(13.4955d0+3d0*log(q2))+0.00165d0+
74340  & 0.00299d0*log(1d0+q2)
74341  ELSE
74342  rpigg=aempi*(13.4955d0+3d0*log(q2))+0.00221d0+
74343  & 0.00293d0*log(1d0+q2)
74344  ENDIF
74345 
74346 C...Calculate running alpha_em.
74347  pyalem=paru(101)/(1d0-rpigg)
74348  paru(108)=pyalem
74349 
74350  RETURN
74351  END
74352 
74353 C*********************************************************************
74354 
74355 C...PYALPS
74356 C...Gives the value of alpha_strong.
74357 
74358  FUNCTION pyalps(Q2)
74359 
74360 C...Double precision and integer declarations.
74361  IMPLICIT DOUBLE PRECISION(a-h, o-z)
74362  IMPLICIT INTEGER(i-n)
74363  INTEGER pyk,pychge,pycomp
74364 C...Commonblocks.
74365  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
74366  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
74367  SAVE /pydat1/,/pydat2/
74368 C...Coefficients for second-order threshold matching.
74369 C...From W.J. Marciano, Phys. Rev. D29 (1984) 580.
74370  dimension stepdn(6),stepup(6)
74371 c DATA STEPDN/0D0,0D0,(2D0*107D0/2025D0),(2D0*963D0/14375D0),
74372 c &(2D0*321D0/3703D0),0D0/
74373 c DATA STEPUP/0D0,0D0,0D0,(-2D0*107D0/1875D0),
74374 c &(-2D0*963D0/13225D0),(-2D0*321D0/3381D0)/
74375  DATA stepdn/0d0,0d0,0.10568d0,0.13398d0,0.17337d0,0d0/
74376  DATA stepup/0d0,0d0,0d0,-0.11413d0,-0.14563d0,-0.18988d0/
74377 
74378 C...Constant alpha_strong trivial. Pick artificial Lambda.
74379  IF(mstu(111).LE.0) THEN
74380  pyalps=paru(111)
74381  mstu(118)=mstu(112)
74382  paru(117)=0.2d0
74383  IF(q2.GT.0.04d0) paru(117)=sqrt(q2)*exp(-6d0*paru(1)/
74384  & ((33d0-2d0*mstu(112))*paru(111)))
74385  paru(118)=paru(111)
74386  RETURN
74387  ENDIF
74388 
74389 C...Find effective Q2, number of flavours and Lambda.
74390  q2eff=q2
74391  IF(mstu(115).GE.2) q2eff=max(q2,paru(114))
74392  nf=mstu(112)
74393  alam2=paru(112)**2
74394  100 IF(nf.GT.max(3,mstu(113))) THEN
74395  q2thr=paru(113)*pmas(nf,1)**2
74396  IF(q2eff.LT.q2thr) THEN
74397  nf=nf-1
74398  q2rat=q2thr/alam2
74399  alam2=alam2*q2rat**(2d0/(33d0-2d0*nf))
74400  IF(mstu(111).EQ.2) alam2=alam2*log(q2rat)**stepdn(nf)
74401  goto 100
74402  ENDIF
74403  ENDIF
74404  110 IF(nf.LT.min(6,mstu(114))) THEN
74405  q2thr=paru(113)*pmas(nf+1,1)**2
74406  IF(q2eff.GT.q2thr) THEN
74407  nf=nf+1
74408  q2rat=q2thr/alam2
74409  alam2=alam2*q2rat**(-2d0/(33d0-2d0*nf))
74410  IF(mstu(111).EQ.2) alam2=alam2*log(q2rat)**stepup(nf)
74411  goto 110
74412  ENDIF
74413  ENDIF
74414  IF(mstu(115).EQ.1) q2eff=q2eff+alam2
74415  paru(117)=sqrt(alam2)
74416 
74417 C...Evaluate first or second order alpha_strong.
74418  b0=(33d0-2d0*nf)/6d0
74419  algq=log(max(1.0001d0,q2eff/alam2))
74420  IF(mstu(111).EQ.1) THEN
74421  pyalps=min(paru(115),paru(2)/(b0*algq))
74422  ELSE
74423  b1=(153d0-19d0*nf)/6d0
74424  pyalps=min(paru(115),paru(2)/(b0*algq)*(1d0-b1*log(algq)/
74425  & (b0**2*algq)))
74426  ENDIF
74427  mstu(118)=nf
74428  paru(118)=pyalps
74429 
74430  RETURN
74431  END
74432 
74433 C*********************************************************************
74434 
74435 C...PYANGL
74436 C...Reconstructs an angle from given x and y coordinates.
74437 
74438  FUNCTION pyangl(X,Y)
74439 
74440 C...Double precision and integer declarations.
74441  IMPLICIT DOUBLE PRECISION(a-h, o-z)
74442  IMPLICIT INTEGER(i-n)
74443  INTEGER pyk,pychge,pycomp
74444 C...Commonblocks.
74445  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
74446  SAVE /pydat1/
74447 
74448  pyangl=0d0
74449  r=sqrt(x**2+y**2)
74450  IF(r.LT.1d-20) RETURN
74451  IF(abs(x)/r.LT.0.8d0) THEN
74452  pyangl=sign(acos(x/r),y)
74453  ELSE
74454  pyangl=asin(y/r)
74455  IF(x.LT.0d0.AND.pyangl.GE.0d0) THEN
74456  pyangl=paru(1)-pyangl
74457  ELSEIF(x.LT.0d0) THEN
74458  pyangl=-paru(1)-pyangl
74459  ENDIF
74460  ENDIF
74461 
74462  RETURN
74463  END
74464 
74465 C*********************************************************************
74466 
74467 C...PYR
74468 C...Generates random numbers uniformly distributed between
74469 C...0 and 1, excluding the endpoints.
74470 
74471  FUNCTION pyr(IDUMMY)
74472 
74473 C...Double precision and integer declarations.
74474  IMPLICIT DOUBLE PRECISION(a-h, o-z)
74475  IMPLICIT INTEGER(i-n)
74476  INTEGER pyk,pychge,pycomp
74477 C...Commonblocks.
74478  common/pydatr/mrpy(6),rrpy(100)
74479  SAVE /pydatr/
74480 C...Equivalence between commonblock and local variables.
74481  equivalence(mrpy1,mrpy(1)),(mrpy2,mrpy(2)),(mrpy3,mrpy(3)),
74482  &(mrpy4,mrpy(4)),(mrpy5,mrpy(5)),(mrpy6,mrpy(6)),
74483  &(rrpy98,rrpy(98)),(rrpy99,rrpy(99)),(rrpy00,rrpy(100))
74484 
74485 C...Initialize generation from given seed.
74486  IF(mrpy2.EQ.0) THEN
74487  ij=mod(mrpy1/30082,31329)
74488  kl=mod(mrpy1,30082)
74489  i=mod(ij/177,177)+2
74490  j=mod(ij,177)+2
74491  k=mod(kl/169,178)+1
74492  l=mod(kl,169)
74493  DO 110 ii=1,97
74494  s=0d0
74495  t=0.5d0
74496  DO 100 jj=1,48
74497  m=mod(mod(i*j,179)*k,179)
74498  i=j
74499  j=k
74500  k=m
74501  l=mod(53*l+1,169)
74502  IF(mod(l*m,64).GE.32) s=s+t
74503  t=0.5d0*t
74504  100 CONTINUE
74505  rrpy(ii)=s
74506  110 CONTINUE
74507  twom24=1d0
74508  DO 120 i24=1,24
74509  twom24=0.5d0*twom24
74510  120 CONTINUE
74511  rrpy98=362436d0*twom24
74512  rrpy99=7654321d0*twom24
74513  rrpy00=16777213d0*twom24
74514  mrpy2=1
74515  mrpy3=0
74516  mrpy4=97
74517  mrpy5=33
74518  ENDIF
74519 
74520 C...Generate next random number.
74521  130 runi=rrpy(mrpy4)-rrpy(mrpy5)
74522  IF(runi.LT.0d0) runi=runi+1d0
74523  rrpy(mrpy4)=runi
74524  mrpy4=mrpy4-1
74525  IF(mrpy4.EQ.0) mrpy4=97
74526  mrpy5=mrpy5-1
74527  IF(mrpy5.EQ.0) mrpy5=97
74528  rrpy98=rrpy98-rrpy99
74529  IF(rrpy98.LT.0d0) rrpy98=rrpy98+rrpy00
74530  runi=runi-rrpy98
74531  IF(runi.LT.0d0) runi=runi+1d0
74532  IF(runi.LE.0d0.OR.runi.GE.1d0) goto 130
74533 
74534 C...Update counters. Random number to output.
74535  mrpy3=mrpy3+1
74536  IF(mrpy3.EQ.1000000000) THEN
74537  mrpy2=mrpy2+1
74538  mrpy3=0
74539  ENDIF
74540  pyr=runi
74541 
74542  RETURN
74543  END
74544 
74545 C*********************************************************************
74546 
74547 C...PYRGET
74548 C...Dumps the state of the random number generator on a file
74549 C...for subsequent startup from this state onwards.
74550 
74551  SUBROUTINE pyrget(LFN,MOVE)
74552 
74553 C...Double precision and integer declarations.
74554  IMPLICIT DOUBLE PRECISION(a-h, o-z)
74555  IMPLICIT INTEGER(i-n)
74556  INTEGER pyk,pychge,pycomp
74557 C...Commonblocks.
74558  common/pydatr/mrpy(6),rrpy(100)
74559  SAVE /pydatr/
74560 C...Local character variable.
74561  CHARACTER cherr*8
74562 
74563 C...Backspace required number of records (or as many as there are).
74564  IF(move.LT.0) THEN
74565  nbck=min(mrpy(6),-move)
74566  DO 100 ibck=1,nbck
74567  backspace(lfn,err=110,iostat=ierr)
74568  100 CONTINUE
74569  mrpy(6)=mrpy(6)-nbck
74570  ENDIF
74571 
74572 C...Unformatted write on unit LFN.
74573  WRITE(lfn,err=110,iostat=ierr) (mrpy(i1),i1=1,5),
74574  &(rrpy(i2),i2=1,100)
74575  mrpy(6)=mrpy(6)+1
74576  RETURN
74577 
74578 C...Write error.
74579  110 WRITE(cherr,'(I8)') ierr
74580  CALL pyerrm(18,'(PYRGET:) error when accessing file, IOSTAT ='//
74581  &cherr)
74582 
74583  RETURN
74584  END
74585 
74586 C*********************************************************************
74587 
74588 C...PYRSET
74589 C...Reads a state of the random number generator from a file
74590 C...for subsequent generation from this state onwards.
74591 
74592  SUBROUTINE pyrset(LFN,MOVE)
74593 
74594 C...Double precision and integer declarations.
74595  IMPLICIT DOUBLE PRECISION(a-h, o-z)
74596  IMPLICIT INTEGER(i-n)
74597  INTEGER pyk,pychge,pycomp
74598 C...Commonblocks.
74599  common/pydatr/mrpy(6),rrpy(100)
74600  SAVE /pydatr/
74601 C...Local character variable.
74602  CHARACTER cherr*8
74603 
74604 C...Backspace required number of records (or as many as there are).
74605  IF(move.LT.0) THEN
74606  nbck=min(mrpy(6),-move)
74607  DO 100 ibck=1,nbck
74608  backspace(lfn,err=120,iostat=ierr)
74609  100 CONTINUE
74610  mrpy(6)=mrpy(6)-nbck
74611  ENDIF
74612 
74613 C...Unformatted read from unit LFN.
74614  nfor=1+max(0,move)
74615  DO 110 ifor=1,nfor
74616  READ(lfn,err=120,iostat=ierr) (mrpy(i1),i1=1,5),
74617  & (rrpy(i2),i2=1,100)
74618  110 CONTINUE
74619  mrpy(6)=mrpy(6)+nfor
74620  RETURN
74621 
74622 C...Write error.
74623  120 WRITE(cherr,'(I8)') ierr
74624  CALL pyerrm(18,'(PYRSET:) error when accessing file, IOSTAT ='//
74625  &cherr)
74626 
74627  RETURN
74628  END
74629 
74630 C*********************************************************************
74631 
74632 C...PYROBO
74633 C...Performs rotations and boosts.
74634 
74635  SUBROUTINE pyrobo(IMI,IMA,THE,PHI,BEX,BEY,BEZ)
74636 
74637 C...Double precision and integer declarations.
74638  IMPLICIT DOUBLE PRECISION(a-h, o-z)
74639  IMPLICIT INTEGER(i-n)
74640  INTEGER pyk,pychge,pycomp
74641 C...Commonblocks.
74642  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
74643  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
74644  SAVE /pyjets/,/pydat1/
74645 C...Local arrays.
74646  dimension rot(3,3),pr(3),vr(3),dp(4),dv(4)
74647 
74648 C...Find and check range of rotation/boost.
74649  imin=imi
74650  IF(imin.LE.0) imin=1
74651  IF(mstu(1).GT.0) imin=mstu(1)
74652  imax=ima
74653  IF(imax.LE.0) imax=n
74654  IF(mstu(2).GT.0) imax=mstu(2)
74655  IF(imin.GT.mstu(4).OR.imax.GT.mstu(4)) THEN
74656  CALL pyerrm(11,'(PYROBO:) range outside PYJETS memory')
74657  RETURN
74658  ENDIF
74659 
74660 C...Optional resetting of V (when not set before.)
74661  IF(mstu(33).NE.0) THEN
74662  DO 110 i=min(imin,mstu(4)),min(imax,mstu(4))
74663  DO 100 j=1,5
74664  v(i,j)=0d0
74665  100 CONTINUE
74666  110 CONTINUE
74667  mstu(33)=0
74668  ENDIF
74669 
74670 C...Rotate, typically from z axis to direction (theta,phi).
74671  IF(the**2+phi**2.GT.1d-20) THEN
74672  rot(1,1)=cos(the)*cos(phi)
74673  rot(1,2)=-sin(phi)
74674  rot(1,3)=sin(the)*cos(phi)
74675  rot(2,1)=cos(the)*sin(phi)
74676  rot(2,2)=cos(phi)
74677  rot(2,3)=sin(the)*sin(phi)
74678  rot(3,1)=-sin(the)
74679  rot(3,2)=0d0
74680  rot(3,3)=cos(the)
74681  DO 140 i=imin,imax
74682  IF(k(i,1).LE.0) goto 140
74683  DO 120 j=1,3
74684  pr(j)=p(i,j)
74685  vr(j)=v(i,j)
74686  120 CONTINUE
74687  DO 130 j=1,3
74688  p(i,j)=rot(j,1)*pr(1)+rot(j,2)*pr(2)+rot(j,3)*pr(3)
74689  v(i,j)=rot(j,1)*vr(1)+rot(j,2)*vr(2)+rot(j,3)*vr(3)
74690  130 CONTINUE
74691  140 CONTINUE
74692  ENDIF
74693 
74694 C...Boost, typically from rest to momentum/energy=beta.
74695  IF(bex**2+bey**2+bez**2.GT.1d-20) THEN
74696  dbx=bex
74697  dby=bey
74698  dbz=bez
74699  db=sqrt(dbx**2+dby**2+dbz**2)
74700  eps1=1d0-1d-12
74701  IF(db.GT.eps1) THEN
74702 C...Rescale boost vector if too close to unity.
74703  CALL pyerrm(3,'(PYROBO:) boost vector too large')
74704  dbx=dbx*(eps1/db)
74705  dby=dby*(eps1/db)
74706  dbz=dbz*(eps1/db)
74707  db=eps1
74708  ENDIF
74709  dga=1d0/sqrt(1d0-db**2)
74710  DO 160 i=imin,imax
74711  IF(k(i,1).LE.0) goto 160
74712  DO 150 j=1,4
74713  dp(j)=p(i,j)
74714  dv(j)=v(i,j)
74715  150 CONTINUE
74716  dbp=dbx*dp(1)+dby*dp(2)+dbz*dp(3)
74717  dgabp=dga*(dga*dbp/(1d0+dga)+dp(4))
74718  p(i,1)=dp(1)+dgabp*dbx
74719  p(i,2)=dp(2)+dgabp*dby
74720  p(i,3)=dp(3)+dgabp*dbz
74721  p(i,4)=dga*(dp(4)+dbp)
74722  dbv=dbx*dv(1)+dby*dv(2)+dbz*dv(3)
74723  dgabv=dga*(dga*dbv/(1d0+dga)+dv(4))
74724  v(i,1)=dv(1)+dgabv*dbx
74725  v(i,2)=dv(2)+dgabv*dby
74726  v(i,3)=dv(3)+dgabv*dbz
74727  v(i,4)=dga*(dv(4)+dbv)
74728  160 CONTINUE
74729  ENDIF
74730 
74731  RETURN
74732  END
74733 
74734 C*********************************************************************
74735 
74736 C...PYEDIT
74737 C...Performs global manipulations on the event record, in particular
74738 C...to exclude unstable or undetectable partons/particles.
74739 
74740  SUBROUTINE pyedit(MEDIT)
74741 
74742 C...Double precision and integer declarations.
74743  IMPLICIT DOUBLE PRECISION(a-h, o-z)
74744  IMPLICIT INTEGER(i-n)
74745  INTEGER pyk,pychge,pycomp
74746 C...Parameter statement to help give large particle numbers.
74747  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
74748  &kexcit=4000000,kdimen=5000000)
74749 C...Commonblocks.
74750  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
74751  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
74752  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
74753  common/pyctag/nct,mct(4000,2)
74754  SAVE /pyjets/,/pydat1/,/pydat2/,/pyctag/
74755 C...Local arrays.
74756  dimension ns(2),pts(2),pls(2)
74757 
74758 C...Remove unwanted partons/particles.
74759  IF((medit.GE.0.AND.medit.LE.3).OR.medit.EQ.5) THEN
74760  imax=n
74761  IF(mstu(2).GT.0) imax=mstu(2)
74762  i1=max(1,mstu(1))-1
74763  DO 110 i=max(1,mstu(1)),imax
74764  IF(k(i,1).EQ.0.OR.(k(i,1).GE.21.AND.k(i,1).LE.40)) goto 110
74765  IF(medit.EQ.1) THEN
74766  IF(k(i,1).GT.10.AND.k(i,1).NE.41.AND.k(i,1).NE.42) goto 110
74767  ELSEIF(medit.EQ.2) THEN
74768  IF(k(i,1).GT.10.AND.k(i,1).NE.41.AND.k(i,1).NE.42) goto 110
74769  kc=pycomp(k(i,2))
74770  IF(kc.EQ.0.OR.kc.EQ.12.OR.kc.EQ.14.OR.kc.EQ.16.OR.
74771  & kc.EQ.18.OR.k(i,2).EQ.ksusy1+22.OR.k(i,2).EQ.39.OR.
74772  & k(i,2).EQ.ksusy1+39) goto 110
74773  ELSEIF(medit.EQ.3) THEN
74774  IF(k(i,1).GT.10.AND.k(i,1).NE.41.AND.k(i,1).NE.42) goto 110
74775  kc=pycomp(k(i,2))
74776  IF(kc.EQ.0) goto 110
74777  IF(kchg(kc,2).EQ.0.AND.pychge(k(i,2)).EQ.0) goto 110
74778  ELSEIF(medit.EQ.5) THEN
74779  IF(k(i,1).EQ.13.OR.k(i,1).EQ.14.OR.k(i,1).EQ.52) goto 110
74780  kc=pycomp(k(i,2))
74781  IF(kc.EQ.0) goto 110
74782  IF(k(i,1).GT.10.AND.k(i,1).NE.41.AND.k(i,1).NE.42.AND.
74783  & kchg(kc,2).EQ.0) goto 110
74784  ENDIF
74785 
74786 C...Pack remaining partons/particles. Origin no longer known.
74787  i1=i1+1
74788  DO 100 j=1,5
74789  k(i1,j)=k(i,j)
74790  p(i1,j)=p(i,j)
74791  v(i1,j)=v(i,j)
74792  100 CONTINUE
74793  k(i1,3)=0
74794  110 CONTINUE
74795  IF(i1.LT.n) mstu(3)=0
74796  IF(i1.LT.n) mstu(70)=0
74797  n=i1
74798 
74799 C...Selective removal of class of entries. New position of retained.
74800  ELSEIF(medit.GE.11.AND.medit.LE.15) THEN
74801  i1=0
74802  DO 120 i=1,n
74803  k(i,3)=mod(k(i,3),mstu(5))
74804  IF(medit.EQ.11.AND.k(i,1).LT.0) goto 120
74805  IF(medit.EQ.12.AND.k(i,1).EQ.0) goto 120
74806  IF(medit.EQ.13.AND.(k(i,1).EQ.11.OR.k(i,1).EQ.12.OR.
74807  & k(i,1).EQ.15.OR.k(i,1).EQ.51).AND.k(i,2).NE.94) goto 120
74808  IF(medit.EQ.14.AND.(k(i,1).EQ.13.OR.k(i,1).EQ.14.OR.
74809  & k(i,1).EQ.52.OR.k(i,2).EQ.94)) goto 120
74810  IF(medit.EQ.15.AND.k(i,1).GE.21.AND.k(i,1).LE.40) goto 120
74811  i1=i1+1
74812  k(i,3)=k(i,3)+mstu(5)*i1
74813  120 CONTINUE
74814 
74815 C...Find new event history information and replace old.
74816  DO 140 i=1,n
74817  IF(k(i,1).LE.0.OR.(k(i,1).GE.21.AND.k(i,1).LE.40).OR.
74818  & k(i,3)/mstu(5).EQ.0) goto 140
74819  id=i
74820  130 im=mod(k(id,3),mstu(5))
74821  IF(medit.EQ.13.AND.im.GT.0.AND.im.LE.n) THEN
74822  IF((k(im,1).EQ.11.OR.k(im,1).EQ.12.OR.k(im,1).EQ.15.OR.
74823  & k(im,1).EQ.51).AND.k(im,2).NE.94) THEN
74824  id=im
74825  goto 130
74826  ENDIF
74827  ELSEIF(medit.EQ.14.AND.im.GT.0.AND.im.LE.n) THEN
74828  IF(k(im,1).EQ.13.OR.k(im,1).EQ.14.OR.k(im,1).EQ.52.OR.
74829  & k(im,2).EQ.94) THEN
74830  id=im
74831  goto 130
74832  ENDIF
74833  ENDIF
74834  k(i,3)=mstu(5)*(k(i,3)/mstu(5))
74835  IF(im.NE.0) k(i,3)=k(i,3)+k(im,3)/mstu(5)
74836  IF(k(i,1).NE.3.AND.k(i,1).NE.13.AND.k(i,1).NE.14.AND.
74837  & k(i,1).NE.42.AND.k(i,1).NE.52) THEN
74838  IF(k(i,4).GT.0.AND.k(i,4).LE.mstu(4)) k(i,4)=
74839  & k(k(i,4),3)/mstu(5)
74840  IF(k(i,5).GT.0.AND.k(i,5).LE.mstu(4)) k(i,5)=
74841  & k(k(i,5),3)/mstu(5)
74842  ELSE
74843  kcm=mod(k(i,4)/mstu(5),mstu(5))
74844  IF(kcm.GT.0.AND.kcm.LE.mstu(4).AND.k(i,1).NE.42.AND.
74845  & k(i,1).NE.52) kcm=k(kcm,3)/mstu(5)
74846  kcd=mod(k(i,4),mstu(5))
74847  IF(kcd.GT.0.AND.kcd.LE.mstu(4)) kcd=k(kcd,3)/mstu(5)
74848  k(i,4)=mstu(5)**2*(k(i,4)/mstu(5)**2)+mstu(5)*kcm+kcd
74849  kcm=mod(k(i,5)/mstu(5),mstu(5))
74850  IF(kcm.GT.0.AND.kcm.LE.mstu(4)) kcm=k(kcm,3)/mstu(5)
74851  kcd=mod(k(i,5),mstu(5))
74852  IF(kcd.GT.0.AND.kcd.LE.mstu(4)) kcd=k(kcd,3)/mstu(5)
74853  k(i,5)=mstu(5)**2*(k(i,5)/mstu(5)**2)+mstu(5)*kcm+kcd
74854  ENDIF
74855  140 CONTINUE
74856 
74857 C...Pack remaining entries.
74858  i1=0
74859  mstu90=mstu(90)
74860  mstu(90)=0
74861  DO 170 i=1,n
74862  IF(k(i,3)/mstu(5).EQ.0) goto 170
74863  i1=i1+1
74864  DO 150 j=1,5
74865  k(i1,j)=k(i,j)
74866  p(i1,j)=p(i,j)
74867  v(i1,j)=v(i,j)
74868  150 CONTINUE
74869 C...Also update LHA1 colour tags
74870  mct(i1,1)=mct(i,1)
74871  mct(i1,2)=mct(i,2)
74872  k(i1,3)=mod(k(i1,3),mstu(5))
74873  DO 160 iz=1,mstu90
74874  IF(i.EQ.mstu(90+iz)) THEN
74875  mstu(90)=mstu(90)+1
74876  mstu(90+mstu(90))=i1
74877  paru(90+mstu(90))=paru(90+iz)
74878  ENDIF
74879  160 CONTINUE
74880  170 CONTINUE
74881  IF(i1.LT.n) mstu(3)=0
74882  IF(i1.LT.n) mstu(70)=0
74883  n=i1
74884 
74885 C...Fill in some missing daughter pointers (lost in colour flow).
74886  ELSEIF(medit.EQ.16) THEN
74887  DO 220 i=1,n
74888  IF(k(i,1).LE.10.OR.(k(i,1).GE.21.AND.k(i,1).LE.50)) goto 220
74889  IF(k(i,4).NE.0.OR.k(i,5).NE.0) goto 220
74890 C...Find daughters who point to mother.
74891  DO 180 i1=i+1,n
74892  IF(k(i1,3).NE.i) THEN
74893  ELSEIF(k(i,4).EQ.0) THEN
74894  k(i,4)=i1
74895  ELSE
74896  k(i,5)=i1
74897  ENDIF
74898  180 CONTINUE
74899  IF(k(i,5).EQ.0) k(i,5)=k(i,4)
74900  IF(k(i,4).NE.0) goto 220
74901 C...Find daughters who point to documentation version of mother.
74902  im=k(i,3)
74903  IF(im.LE.0.OR.im.GE.i) goto 220
74904  IF(k(im,1).LE.20.OR.k(im,1).GT.30) goto 220
74905  IF(k(im,2).NE.k(i,2).OR.abs(p(im,5)-p(i,5)).GT.1d-2) goto 220
74906  DO 190 i1=i+1,n
74907  IF(k(i1,3).NE.im) THEN
74908  ELSEIF(k(i,4).EQ.0) THEN
74909  k(i,4)=i1
74910  ELSE
74911  k(i,5)=i1
74912  ENDIF
74913  190 CONTINUE
74914  IF(k(i,5).EQ.0) k(i,5)=k(i,4)
74915  IF(k(i,4).NE.0) goto 220
74916 C...Find daughters who point to documentation daughters who,
74917 C...in their turn, point to documentation mother.
74918  id1=im
74919  id2=im
74920  DO 200 i1=im+1,i-1
74921  IF(k(i1,3).EQ.im.AND.k(i1,1).GE.21.AND.k(i1,1).LE.30) THEN
74922  id2=i1
74923  IF(id1.EQ.im) id1=i1
74924  ENDIF
74925  200 CONTINUE
74926  DO 210 i1=i+1,n
74927  IF(k(i1,3).NE.id1.AND.k(i1,3).NE.id2) THEN
74928  ELSEIF(k(i,4).EQ.0) THEN
74929  k(i,4)=i1
74930  ELSE
74931  k(i,5)=i1
74932  ENDIF
74933  210 CONTINUE
74934  IF(k(i,5).EQ.0) k(i,5)=k(i,4)
74935  220 CONTINUE
74936 
74937 C...Save top entries at bottom of PYJETS commonblock.
74938  ELSEIF(medit.EQ.21) THEN
74939  IF(2*n.GE.mstu(4)) THEN
74940  CALL pyerrm(11,'(PYEDIT:) no more memory left in PYJETS')
74941  RETURN
74942  ENDIF
74943  DO 240 i=1,n
74944  DO 230 j=1,5
74945  k(mstu(4)-i,j)=k(i,j)
74946  p(mstu(4)-i,j)=p(i,j)
74947  v(mstu(4)-i,j)=v(i,j)
74948  230 CONTINUE
74949  240 CONTINUE
74950  mstu(32)=n
74951 
74952 C...Restore bottom entries of commonblock PYJETS to top.
74953  ELSEIF(medit.EQ.22) THEN
74954  DO 260 i=1,mstu(32)
74955  DO 250 j=1,5
74956  k(i,j)=k(mstu(4)-i,j)
74957  p(i,j)=p(mstu(4)-i,j)
74958  v(i,j)=v(mstu(4)-i,j)
74959  250 CONTINUE
74960  260 CONTINUE
74961  n=mstu(32)
74962 
74963 C...Mark primary entries at top of commonblock PYJETS as untreated.
74964  ELSEIF(medit.EQ.23) THEN
74965  i1=0
74966  DO 270 i=1,n
74967  kh=k(i,3)
74968  IF(kh.GE.1) THEN
74969  IF(k(kh,1).GE.21.AND.k(kh,1).LE.30) kh=0
74970  ENDIF
74971  IF(kh.NE.0) goto 280
74972  i1=i1+1
74973  IF(k(i,1).GE.11.AND.k(i,1).LE.20) k(i,1)=k(i,1)-10
74974  IF(k(i,1).GE.51.AND.k(i,1).LE.60) k(i,1)=k(i,1)-10
74975  270 CONTINUE
74976  280 n=i1
74977 
74978 C...Place largest axis along z axis and second largest in xy plane.
74979  ELSEIF(medit.EQ.31.OR.medit.EQ.32) THEN
74980  CALL pyrobo(1,n+mstu(3),0d0,-pyangl(p(mstu(61),1),
74981  & p(mstu(61),2)),0d0,0d0,0d0)
74982  CALL pyrobo(1,n+mstu(3),-pyangl(p(mstu(61),3),
74983  & p(mstu(61),1)),0d0,0d0,0d0,0d0)
74984  CALL pyrobo(1,n+mstu(3),0d0,-pyangl(p(mstu(61)+1,1),
74985  & p(mstu(61)+1,2)),0d0,0d0,0d0)
74986  IF(medit.EQ.31) RETURN
74987 
74988 C...Rotate to put slim jet along +z axis.
74989  DO 290 is=1,2
74990  ns(is)=0
74991  pts(is)=0d0
74992  pls(is)=0d0
74993  290 CONTINUE
74994  DO 300 i=1,n
74995  IF(k(i,1).LE.0.OR.k(i,1).GT.10) goto 300
74996  IF(mstu(41).GE.2) THEN
74997  kc=pycomp(k(i,2))
74998  IF(kc.EQ.0.OR.kc.EQ.12.OR.kc.EQ.14.OR.kc.EQ.16.OR.
74999  & kc.EQ.18.OR.k(i,2).EQ.ksusy1+22.OR.k(i,2).EQ.39.OR.
75000  & k(i,2).EQ.ksusy1+39) goto 300
75001  IF(mstu(41).GE.3.AND.kchg(kc,2).EQ.0.AND.pychge(k(i,2))
75002  & .EQ.0) goto 300
75003  ENDIF
75004  is=2d0-sign(0.5d0,p(i,3))
75005  ns(is)=ns(is)+1
75006  pts(is)=pts(is)+sqrt(p(i,1)**2+p(i,2)**2)
75007  300 CONTINUE
75008  IF(ns(1)*pts(2)**2.LT.ns(2)*pts(1)**2)
75009  & CALL pyrobo(1,n+mstu(3),paru(1),0d0,0d0,0d0,0d0)
75010 
75011 C...Rotate to put second largest jet into -z,+x quadrant.
75012  DO 310 i=1,n
75013  IF(p(i,3).GE.0d0) goto 310
75014  IF(k(i,1).LE.0.OR.k(i,1).GT.10) goto 310
75015  IF(mstu(41).GE.2) THEN
75016  kc=pycomp(k(i,2))
75017  IF(kc.EQ.0.OR.kc.EQ.12.OR.kc.EQ.14.OR.kc.EQ.16.OR.
75018  & kc.EQ.18.OR.k(i,2).EQ.ksusy1+22.OR.k(i,2).EQ.39.OR.
75019  & k(i,2).EQ.ksusy1+39) goto 310
75020  IF(mstu(41).GE.3.AND.kchg(kc,2).EQ.0.AND.pychge(k(i,2))
75021  & .EQ.0) goto 310
75022  ENDIF
75023  is=2d0-sign(0.5d0,p(i,1))
75024  pls(is)=pls(is)-p(i,3)
75025  310 CONTINUE
75026  IF(pls(2).GT.pls(1)) CALL pyrobo(1,n+mstu(3),0d0,paru(1),
75027  & 0d0,0d0,0d0)
75028  ENDIF
75029 
75030  RETURN
75031  END
75032 
75033 C*********************************************************************
75034 
75035 C...PYLIST
75036 C...Gives program heading, or lists an event, or particle
75037 C...data, or current parameter values.
75038 
75039  SUBROUTINE pylist(MLIST)
75040 
75041 C...Double precision and integer declarations.
75042  IMPLICIT DOUBLE PRECISION(a-h, o-z)
75043  IMPLICIT INTEGER(i-n)
75044  INTEGER pyk,pychge,pycomp
75045 C...Parameter statement to help give large particle numbers.
75046  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
75047  &kexcit=4000000,kdimen=5000000)
75048 
75049 C...HEPEVT commonblock.
75050  parameter(nmxhep=4000)
75051  common/hepevt/nevhep,nhep,isthep(nmxhep),idhep(nmxhep),
75052  &jmohep(2,nmxhep),jdahep(2,nmxhep),phep(5,nmxhep),vhep(4,nmxhep)
75053  DOUBLE PRECISION phep,vhep
75054  SAVE /hepevt/
75055 
75056 C...User process event common block.
75057  INTEGER maxnup
75058  parameter(maxnup=500)
75059  INTEGER nup,idprup,idup,istup,mothup,icolup
75060  DOUBLE PRECISION xwgtup,scalup,aqedup,aqcdup,pup,vtimup,spinup
75061  common/hepeup/nup,idprup,xwgtup,scalup,aqedup,aqcdup,idup(maxnup),
75062  &istup(maxnup),mothup(2,maxnup),icolup(2,maxnup),pup(5,maxnup),
75063  &vtimup(maxnup),spinup(maxnup)
75064  SAVE /hepeup/
75065 
75066 C...Commonblocks.
75067  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
75068  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
75069  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
75070  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
75071  common/pyctag/nct,mct(4000,2)
75072  SAVE /pyjets/,/pydat1/,/pydat2/,/pydat3/,/pyctag/
75073 C...Local arrays, character variables and data.
75074  CHARACTER chap*16,chac*16,chan*16,chad(5)*16,chdl(7)*4
75075  dimension ps(6)
75076  DATA chdl/'(())',' ','()','!!','<>','==','(==)'/
75077 
75078 C...Initialization printout: version number and date of last change.
75079  IF(mlist.EQ.0.OR.mstu(12).EQ.1) THEN
75080  CALL pylogo
75081  mstu(12)=12345
75082  IF(mlist.EQ.0) RETURN
75083  ENDIF
75084 
75085 C...List event data, including additional lines after N.
75086  IF(mlist.GE.1.AND.mlist.LE.4) THEN
75087  IF(mlist.EQ.1) WRITE(mstu(11),5100)
75088  IF(mlist.EQ.2) WRITE(mstu(11),5200)
75089  IF(mlist.EQ.3) WRITE(mstu(11),5300)
75090  IF(mlist.EQ.4) WRITE(mstu(11),5400)
75091  lmx=12
75092  IF(mlist.GE.2) lmx=16
75093  istr=0
75094  imax=n
75095  IF(mstu(2).GT.0) imax=mstu(2)
75096  DO 120 i=max(1,mstu(1)),max(imax,n+max(0,mstu(3)))
75097  IF(i.GT.imax.AND.i.LE.n) goto 120
75098  IF(mstu(15).EQ.0.AND.k(i,1).LE.0) goto 120
75099  IF(mstu(15).EQ.1.AND.k(i,1).LT.0) goto 120
75100 
75101 C...Get particle name, pad it and check it is not too long.
75102  CALL pyname(k(i,2),chap)
75103  len=0
75104  DO 100 lem=1,16
75105  IF(chap(lem:lem).NE.' ') len=lem
75106  100 CONTINUE
75107  mdl=(k(i,1)+19)/10
75108  ldl=0
75109  IF(mdl.EQ.2.OR.mdl.GE.8) THEN
75110  chac=chap
75111  IF(len.GT.lmx) chac(lmx:lmx)='?'
75112  ELSE
75113  ldl=1
75114  IF(mdl.EQ.1.OR.mdl.EQ.7) ldl=2
75115  IF(len.EQ.0) THEN
75116  chac=chdl(mdl)(1:2*ldl)//' '
75117  ELSE
75118  chac=chdl(mdl)(1:ldl)//chap(1:min(len,lmx-2*ldl))//
75119  & chdl(mdl)(ldl+1:2*ldl)//' '
75120  IF(len+2*ldl.GT.lmx) chac(lmx:lmx)='?'
75121  ENDIF
75122  ENDIF
75123 
75124 C...Add information on string connection.
75125  IF(k(i,1).EQ.1.OR.k(i,1).EQ.2.OR.k(i,1).EQ.11.OR.k(i,1).EQ.12)
75126  & THEN
75127  kc=pycomp(k(i,2))
75128  kcc=0
75129  IF(kc.NE.0) kcc=kchg(kc,2)
75130  IF(iabs(k(i,2)).EQ.39) THEN
75131  IF(len+2*ldl+3.LE.lmx) chac(lmx-1:lmx-1)='X'
75132  ELSEIF(kcc.NE.0.AND.istr.EQ.0) THEN
75133  istr=1
75134  IF(len+2*ldl+3.LE.lmx) chac(lmx-1:lmx-1)='A'
75135  ELSEIF(kcc.NE.0.AND.(k(i,1).EQ.2.OR.k(i,1).EQ.12)) THEN
75136  IF(len+2*ldl+3.LE.lmx) chac(lmx-1:lmx-1)='I'
75137  ELSEIF(kcc.NE.0) THEN
75138  istr=0
75139  IF(len+2*ldl+3.LE.lmx) chac(lmx-1:lmx-1)='V'
75140  ENDIF
75141  ENDIF
75142  IF((k(i,1).EQ.41.OR.k(i,1).EQ.51).AND.len+2*ldl+3.LE.lmx)
75143  & chac(lmx-1:lmx-1)='I'
75144 
75145 C...Write data for particle/jet.
75146  IF(mlist.EQ.1.AND.abs(p(i,4)).LT.9999d0) THEN
75147  WRITE(mstu(11),5500) i,chac(1:12),(k(i,j1),j1=1,3),
75148  & (p(i,j2),j2=1,5)
75149  ELSEIF(mlist.EQ.1.AND.abs(p(i,4)).LT.99999d0) THEN
75150  WRITE(mstu(11),5600) i,chac(1:12),(k(i,j1),j1=1,3),
75151  & (p(i,j2),j2=1,5)
75152  ELSEIF(mlist.EQ.1) THEN
75153  WRITE(mstu(11),5700) i,chac(1:12),(k(i,j1),j1=1,3),
75154  & (p(i,j2),j2=1,5)
75155  ELSEIF(mstu(5).EQ.10000.AND.(k(i,1).EQ.3.OR.k(i,1).EQ.13.OR.
75156  & k(i,1).EQ.14.OR.k(i,1).EQ.42.OR.k(i,1).EQ.52)) THEN
75157  IF(mlist.NE.4) WRITE(mstu(11),5800) i,chac,(k(i,j1),j1=1,3),
75158  & k(i,4)/100000000,mod(k(i,4)/10000,10000),mod(k(i,4),10000),
75159  & k(i,5)/100000000,mod(k(i,5)/10000,10000),mod(k(i,5),10000),
75160  & (p(i,j2),j2=1,5)
75161  IF(mlist.EQ.4) WRITE(mstu(11),5900) i,chac,(k(i,j1),j1=1,3),
75162  & k(i,4)/100000000,mod(k(i,4)/10000,10000),mod(k(i,4),10000),
75163  & k(i,5)/100000000,mod(k(i,5)/10000,10000),mod(k(i,5)
75164  & ,10000),mct(i,1),mct(i,2)
75165  ELSE
75166  IF(mlist.NE.4) WRITE(mstu(11),6000) i,chac,(k(i,j1),j1=1,5),
75167  & (p(i,j2),j2=1,5)
75168  IF(mlist.EQ.4) WRITE(mstu(11),6100) i,chac,(k(i,j1),j1=1,5)
75169  & ,mct(i,1),mct(i,2)
75170  ENDIF
75171  IF(mlist.EQ.3) WRITE(mstu(11),6200) (v(i,j),j=1,5)
75172 
75173 C...Insert extra separator lines specified by user.
75174  IF(mstu(70).GE.1) THEN
75175  isep=0
75176  DO 110 j=1,min(10,mstu(70))
75177  IF(i.EQ.mstu(70+j)) isep=1
75178  110 CONTINUE
75179  IF(isep.EQ.1) THEN
75180  IF(mlist.EQ.1) WRITE(mstu(11),6300)
75181  IF(mlist.EQ.2.OR.mlist.EQ.3) WRITE(mstu(11),6400)
75182  IF(mlist.EQ.4) WRITE(mstu(11),6500)
75183  ENDIF
75184  ENDIF
75185  120 CONTINUE
75186 
75187 C...Sum of charges and momenta.
75188  DO 130 j=1,6
75189  ps(j)=pyp(0,j)
75190  130 CONTINUE
75191  IF(mlist.EQ.1.AND.abs(ps(4)).LT.9999d0) THEN
75192  WRITE(mstu(11),6600) ps(6),(ps(j),j=1,5)
75193  ELSEIF(mlist.EQ.1.AND.abs(ps(4)).LT.99999d0) THEN
75194  WRITE(mstu(11),6700) ps(6),(ps(j),j=1,5)
75195  ELSEIF(mlist.EQ.1) THEN
75196  WRITE(mstu(11),6800) ps(6),(ps(j),j=1,5)
75197  ELSEIF(mlist.LE.3) THEN
75198  WRITE(mstu(11),6900) ps(6),(ps(j),j=1,5)
75199  ELSE
75200  WRITE(mstu(11),7000) ps(6)
75201  ENDIF
75202 
75203 C...Simple listing of HEPEVT entries (mainly for test purposes).
75204  ELSEIF(mlist.EQ.5) THEN
75205  WRITE(mstu(11),7100)
75206  DO 140 i=1,nhep
75207  IF(isthep(i).EQ.0) goto 140
75208  WRITE(mstu(11),7200) i,isthep(i),idhep(i),jmohep(1,i),
75209  & jmohep(2,i),jdahep(1,i),jdahep(2,i),(phep(j,i),j=1,5)
75210  140 CONTINUE
75211 
75212 
75213 C...Simple listing of user-process entries (mainly for test purposes).
75214  ELSEIF(mlist.EQ.7) THEN
75215  WRITE(mstu(11),7300)
75216  DO 150 i=1,nup
75217  WRITE(mstu(11),7400) i,istup(i),idup(i),mothup(1,i),
75218  & mothup(2,i),icolup(1,i),icolup(2,i),(pup(j,i),j=1,5)
75219  150 CONTINUE
75220 
75221 C...Give simple list of KF codes defined in program.
75222  ELSEIF(mlist.EQ.11) THEN
75223  WRITE(mstu(11),7500)
75224  DO 160 kf=1,80
75225  CALL pyname(kf,chap)
75226  CALL pyname(-kf,chan)
75227  IF(chap.NE.' '.AND.chan.EQ.' ') WRITE(mstu(11),7600) kf,chap
75228  IF(chan.NE.' ') WRITE(mstu(11),7600) kf,chap,-kf,chan
75229  160 CONTINUE
75230  DO 190 kfls=1,3,2
75231  DO 180 kfla=1,5
75232  DO 170 kflb=1,kfla-(3-kfls)/2
75233  kf=1000*kfla+100*kflb+kfls
75234  CALL pyname(kf,chap)
75235  CALL pyname(-kf,chan)
75236  WRITE(mstu(11),7600) kf,chap,-kf,chan
75237  170 CONTINUE
75238  180 CONTINUE
75239  190 CONTINUE
75240  DO 220 kmul=0,5
75241  kfls=3
75242  IF(kmul.EQ.0.OR.kmul.EQ.3) kfls=1
75243  IF(kmul.EQ.5) kfls=5
75244  kflr=0
75245  IF(kmul.EQ.2.OR.kmul.EQ.3) kflr=1
75246  IF(kmul.EQ.4) kflr=2
75247  DO 210 kflb=1,5
75248  DO 200 kflc=1,kflb-1
75249  kf=10000*kflr+100*kflb+10*kflc+kfls
75250  CALL pyname(kf,chap)
75251  CALL pyname(-kf,chan)
75252  WRITE(mstu(11),7600) kf,chap,-kf,chan
75253  IF(kf.EQ.311) THEN
75254  kfk=130
75255  CALL pyname(kfk,chap)
75256  WRITE(mstu(11),7600) kfk,chap
75257  kfk=310
75258  CALL pyname(kfk,chap)
75259  WRITE(mstu(11),7600) kfk,chap
75260  ENDIF
75261  200 CONTINUE
75262  kf=10000*kflr+110*kflb+kfls
75263  CALL pyname(kf,chap)
75264  WRITE(mstu(11),7600) kf,chap
75265  210 CONTINUE
75266  220 CONTINUE
75267  kf=100443
75268  CALL pyname(kf,chap)
75269  WRITE(mstu(11),7600) kf,chap
75270  kf=100553
75271  CALL pyname(kf,chap)
75272  WRITE(mstu(11),7600) kf,chap
75273  DO 260 kflsp=1,3
75274  kfls=2+2*(kflsp/3)
75275  DO 250 kfla=1,5
75276  DO 240 kflb=1,kfla
75277  DO 230 kflc=1,kflb
75278  IF(kflsp.EQ.1.AND.(kfla.EQ.kflb.OR.kflb.EQ.kflc))
75279  & goto 230
75280  IF(kflsp.EQ.2.AND.kfla.EQ.kflc) goto 230
75281  IF(kflsp.EQ.1) kf=1000*kfla+100*kflc+10*kflb+kfls
75282  IF(kflsp.GE.2) kf=1000*kfla+100*kflb+10*kflc+kfls
75283  CALL pyname(kf,chap)
75284  CALL pyname(-kf,chan)
75285  WRITE(mstu(11),7600) kf,chap,-kf,chan
75286  230 CONTINUE
75287  240 CONTINUE
75288  250 CONTINUE
75289  260 CONTINUE
75290  DO 270 kc=1,500
75291  kf=kchg(kc,4)
75292  IF(kf.LT.1000000) goto 270
75293  CALL pyname(kf,chap)
75294  CALL pyname(-kf,chan)
75295  IF(chap.NE.' '.AND.chan.EQ.' ') WRITE(mstu(11),7600) kf,chap
75296  IF(chan.NE.' ') WRITE(mstu(11),7600) kf,chap,-kf,chan
75297  270 CONTINUE
75298 
75299 C...List parton/particle data table. Check whether to be listed.
75300  ELSEIF(mlist.EQ.12) THEN
75301  WRITE(mstu(11),7700)
75302  DO 300 kc=1,mstu(6)
75303  kf=kchg(kc,4)
75304  IF(kf.EQ.0) goto 300
75305  IF(kf.LT.mstu(1).OR.(mstu(2).GT.0.AND.kf.GT.mstu(2)))
75306  & goto 300
75307 
75308 C...Find particle name and mass. Print information.
75309  CALL pyname(kf,chap)
75310  IF(kf.LE.100.AND.chap.EQ.' '.AND.mdcy(kc,2).EQ.0) goto 300
75311  CALL pyname(-kf,chan)
75312  WRITE(mstu(11),7800) kf,kc,chap,chan,(kchg(kc,j1),j1=1,3),
75313  & (pmas(kc,j2),j2=1,4),mdcy(kc,1)
75314 
75315 C...Particle decay: channel number, branching ratios, matrix element,
75316 C...decay products.
75317  DO 290 idc=mdcy(kc,2),mdcy(kc,2)+mdcy(kc,3)-1
75318  DO 280 j=1,5
75319  CALL pyname(kfdp(idc,j),chad(j))
75320  280 CONTINUE
75321  WRITE(mstu(11),7900) idc,mdme(idc,1),mdme(idc,2),brat(idc),
75322  & (chad(j),j=1,5)
75323  290 CONTINUE
75324  300 CONTINUE
75325 
75326 C...List parameter value table.
75327  ELSEIF(mlist.EQ.13) THEN
75328  WRITE(mstu(11),8000)
75329  DO 310 i=1,200
75330  WRITE(mstu(11),8100) i,mstu(i),paru(i),mstj(i),parj(i),parf(i)
75331  310 CONTINUE
75332  ENDIF
75333 
75334 C...Format statements for output on unit MSTU(11) (by default 6).
75335  5100 FORMAT(///28x,'Event listing (summary)'//4x,'I particle/jet KS',
75336  &5x,'KF orig p_x p_y p_z E m'/)
75337  5200 FORMAT(///28x,'Event listing (standard)'//4x,'I particle/jet',
75338  &' K(I,1) K(I,2) K(I,3) K(I,4) K(I,5) P(I,1)',
75339  &' P(I,2) P(I,3) P(I,4) P(I,5)'/)
75340  5300 FORMAT(///28x,'Event listing (with vertices)'//4x,'I particle/j',
75341  &'et K(I,1) K(I,2) K(I,3) K(I,4) K(I,5) P(I,1)',
75342  &' P(I,2) P(I,3) P(I,4) P(I,5)'/73x,
75343  &'V(I,1) V(I,2) V(I,3) V(I,4) V(I,5)'/)
75344  5400 FORMAT(///28x,'Event listing (no momenta)'//4x,'I particle/jet',
75345  & ' K(I,1) K(I,2) K(I,3) K(I,4) K(I,5)',1x
75346  & ,' C tag AC tag'/)
75347  5500 FORMAT(1x,i4,1x,a12,1x,i2,i8,1x,i4,5f9.3)
75348  5600 FORMAT(1x,i4,1x,a12,1x,i2,i8,1x,i4,5f9.2)
75349  5700 FORMAT(1x,i4,1x,a12,1x,i2,i8,1x,i4,5f9.1)
75350  5800 FORMAT(1x,i4,2x,a16,1x,i3,1x,i9,1x,i4,2(3x,i1,2i4),5f13.5)
75351  5900 FORMAT(1x,i4,2x,a16,1x,i3,1x,i9,1x,i4,2(3x,i1,2i4),1x,2i8)
75352  6000 FORMAT(1x,i4,2x,a16,1x,i3,1x,i9,1x,i4,2(3x,i9),5f13.5)
75353  6100 FORMAT(1x,i4,2x,a16,1x,i3,1x,i9,1x,i4,2(3x,i9),1x,2i8)
75354  6200 FORMAT(66x,5(1x,f12.3))
75355  6300 FORMAT(1x,78('='))
75356  6400 FORMAT(1x,130('='))
75357  6500 FORMAT(1x,65('='))
75358  6600 FORMAT(19x,'sum:',f6.2,5x,5f9.3)
75359  6700 FORMAT(19x,'sum:',f6.2,5x,5f9.2)
75360  6800 FORMAT(19x,'sum:',f6.2,5x,5f9.1)
75361  6900 FORMAT(19x,'sum charge:',f6.2,3x,'sum momentum and inv. mass:',
75362  &5f13.5)
75363  7000 FORMAT(19x,'sum charge:',f6.2)
75364  7100 FORMAT(/10x,'Event listing of HEPEVT common block (simplified)'
75365  &//' I IST ID Mothers Daughters p_x p_y p_z',
75366  &' E m')
75367  7200 FORMAT(1x,i4,i2,i8,4i5,5f9.3)
75368  7300 FORMAT(/10x,'Event listing of user process at input (simplified)'
75369  &//' I IST ID Mothers Colours p_x p_y p_z',
75370  &' E m')
75371  7400 FORMAT(1x,i3,i3,i8,2i4,2i5,5f9.3)
75372  7500 FORMAT(///20x,'List of KF codes in program'/)
75373  7600 FORMAT(4x,i9,4x,a16,6x,i9,4x,a16)
75374  7700 FORMAT(///30x,'Particle/parton data table'//8x,'KF',5x,'KC',4x,
75375  &'particle',8x,'antiparticle',6x,'chg col anti',8x,'mass',7x,
75376  &'width',7x,'w-cut',5x,'lifetime',1x,'decay'/11x,'IDC',1x,'on/off',
75377  &1x,'ME',3x,'Br.rat.',4x,'decay products')
75378  7800 FORMAT(/1x,i9,3x,i4,4x,a16,a16,3i5,1x,f12.5,2(1x,f11.5),
75379  &1x,1p,e13.5,3x,i2)
75380  7900 FORMAT(10x,i4,2x,i3,2x,i3,2x,f10.6,4x,5a16)
75381  8000 FORMAT(///20x,'Parameter value table'//4x,'I',3x,'MSTU(I)',
75382  &8x,'PARU(I)',3x,'MSTJ(I)',8x,'PARJ(I)',8x,'PARF(I)')
75383  8100 FORMAT(1x,i4,1x,i9,1x,f14.5,1x,i9,1x,f14.5,1x,f14.5)
75384 
75385  RETURN
75386  END
75387 
75388 C*********************************************************************
75389 
75390 C...PYLOGO
75391 C...Writes a logo for the program.
75392 
75393  SUBROUTINE pylogo
75394 
75395 C...Double precision and integer declarations.
75396  IMPLICIT DOUBLE PRECISION(a-h, o-z)
75397  IMPLICIT INTEGER(i-n)
75398  INTEGER pyk,pychge,pycomp
75399 C...Parameter for length of information block.
75400  parameter(irefer=19)
75401 C...Commonblocks.
75402  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
75403  common/pypars/mstp(200),parp(200),msti(200),pari(200)
75404  SAVE /pydat1/,/pypars/
75405 C...Local arrays and character variables.
75406  INTEGER idati(6)
75407  CHARACTER month(12)*3, logo(48)*32, refer(2*irefer)*36, line*79,
75408  &vers*1, subv*3, date*2, year*4, hour*2, minu*2, seco*2
75409 
75410 C...Data on months, logo, titles, and references.
75411  DATA month/'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep',
75412  &'Oct','Nov','Dec'/
75413  DATA (logo(j),j=1,19)/
75414  &' *......* ',
75415  &' *:::!!:::::::::::* ',
75416  &' *::::::!!::::::::::::::* ',
75417  &' *::::::::!!::::::::::::::::* ',
75418  &' *:::::::::!!:::::::::::::::::* ',
75419  &' *:::::::::!!:::::::::::::::::* ',
75420  &' *::::::::!!::::::::::::::::*! ',
75421  &' *::::::!!::::::::::::::* !! ',
75422  &' !! *:::!!:::::::::::* !! ',
75423  &' !! !* -><- * !! ',
75424  &' !! !! !! ',
75425  &' !! !! !! ',
75426  &' !! !! ',
75427  &' !! lh !! ',
75428  &' !! !! ',
75429  &' !! hh !! ',
75430  &' !! ll !! ',
75431  &' !! !! ',
75432  &' !! '/
75433  DATA (logo(j),j=20,38)/
75434  &'Welcome to the Lund Monte Carlo!',
75435  &' ',
75436  &'PPP Y Y TTTTT H H III A ',
75437  &'P P Y Y T H H I A A ',
75438  &'PPP Y T HHHHH I AAAAA',
75439  &'P Y T H H I A A',
75440  &'P Y T H H III A A',
75441  &' ',
75442  &'This is PYTHIA version x.xxx ',
75443  &'Last date of change: xx xxx 201x',
75444  &' ',
75445  &'Now is xx xxx 201x at xx:xx:xx ',
75446  &' ',
75447  &'Disclaimer: this program comes ',
75448  &'without any guarantees. Beware ',
75449  &'of errors and use common sense ',
75450  &'when interpreting results. ',
75451  &' ',
75452  &'Copyright T. Sjostrand (2011) '/
75453  DATA (refer(j),j=1,14)/
75454  &'An archive of program versions and d',
75455  &'ocumentation is found on the web: ',
75456  &'http://www.thep.lu.se/~torbjorn/Pyth',
75457  &'ia.html ',
75458  &' ',
75459  &' ',
75460  &'When you cite this program, the offi',
75461  &'cial reference is to the 6.4 manual:',
75462  &'T. Sjostrand, S. Mrenna and P. Skand',
75463  &'s, JHEP05 (2006) 026 ',
75464  &'(LU TP 06-13, FERMILAB-PUB-06-052-CD',
75465  &'-T) [hep-ph/0603175]. ',
75466  &' ',
75467  &' '/
75468  DATA (refer(j),j=15,32)/
75469  &'Also remember that the program, to a',
75470  &' large extent, represents original ',
75471  &'physics research. Other publications',
75472  &' of special relevance to your ',
75473  &'studies may therefore deserve separa',
75474  &'te mention. ',
75475  &' ',
75476  &' ',
75477  &'Main author: Torbjorn Sjostrand; Dep',
75478  &'artment of Theoretical Physics, ',
75479  &' Lund University, Solvegatan 14A, S',
75480  &'-223 62 Lund, Sweden; ',
75481  &' phone: + 46 - 46 - 222 48 16; e-ma',
75482  &'il: torbjorn@thep.lu.se ',
75483  &'Author: Stephen Mrenna; Computing Di',
75484  &'vision, GDS Group, ',
75485  &' Fermi National Accelerator Laborat',
75486  &'ory, MS 234, Batavia, IL 60510, USA;'/
75487  DATA (refer(j),j=33,2*irefer)/
75488  &' phone: + 1 - 630 - 840 - 2556; e-m',
75489  &'ail: mrenna@fnal.gov ',
75490  &'Author: Peter Skands; CERN/PH-TH, CH',
75491  &'-1211 Geneva, Switzerland ',
75492  &' phone: + 41 - 22 - 767 24 47; e-ma',
75493  &'il: peter.skands@cern.ch '/
75494 
75495 C...Check that PYDATA linked (check we are in the year 20xx)
75496  IF(mstp(183)/100.NE.20) THEN
75497  WRITE(*,'(1X,A)')
75498  & 'Error: PYDATA has not been linked.'
75499  WRITE(*,'(1X,A)') 'Execution stopped!'
75500  CALL pystop(8)
75501 
75502 C...Write current version number and current date+time.
75503  ELSE
75504  WRITE(vers,'(I1)') mstp(181)
75505  logo(28)(24:24)=vers
75506  WRITE(subv,'(I3)') mstp(182)
75507  logo(28)(26:28)=subv
75508  IF(mstp(182).LT.100) logo(28)(26:26)='0'
75509  WRITE(date,'(I2)') mstp(185)
75510  logo(29)(22:23)=date
75511  logo(29)(25:27)=month(mstp(184))
75512  WRITE(year,'(I4)') mstp(183)
75513  logo(29)(29:32)=year
75514  CALL pytime(idati)
75515  IF(idati(1).LE.0) THEN
75516  logo(31)=' '
75517  ELSE
75518  WRITE(date,'(I2)') idati(3)
75519  logo(31)(8:9)=date
75520  logo(31)(11:13)=month(max(1,min(12,idati(2))))
75521  WRITE(year,'(I4)') idati(1)
75522  logo(31)(15:18)=year
75523  WRITE(hour,'(I2)') idati(4)
75524  logo(31)(23:24)=hour
75525  WRITE(minu,'(I2)') idati(5)
75526  logo(31)(26:27)=minu
75527  IF(idati(5).LT.10) logo(31)(26:26)='0'
75528  WRITE(seco,'(I2)') idati(6)
75529  logo(31)(29:30)=seco
75530  IF(idati(6).LT.10) logo(31)(29:29)='0'
75531  ENDIF
75532  ENDIF
75533 
75534 
75535  WRITE(mstu(11),'(A79)')
75536  &'+++++++++++++++++++++++++++++++++++++++++++++++++'//
75537  &'+++++++++++++++++++++++++++++'
75538  WRITE(mstu(11),'(A79)')
75539  &'++ This is a modified version of PYTHIA that may'//
75540  & ' only be used with JEWEL. ++'
75541  WRITE(mstu(11),'(A79)')
75542  &'+++++++++++++++++++++++++++++++++++++++++++++++++'//
75543  &'+++++++++++++++++++++++++++++'
75544 
75545 C...Loop over lines in header. Define page feed and side borders.
75546  DO 100 ilin=1,29+irefer
75547  line=' '
75548  IF(ilin.EQ.1) THEN
75549  line(1:1)='1'
75550  ELSE
75551  line(2:3)='**'
75552  line(78:79)='**'
75553  ENDIF
75554 
75555 C...Separator lines and logos.
75556  IF(ilin.EQ.2.OR.ilin.EQ.3.OR.ilin.GE.28+irefer) THEN
75557  line(4:77)='***********************************************'//
75558  & '***************************'
75559  ELSEIF(ilin.GE.6.AND.ilin.LE.24) THEN
75560  line(6:37)=logo(ilin-5)
75561  line(44:75)=logo(ilin+14)
75562  ELSEIF(ilin.GE.26.AND.ilin.LE.25+irefer) THEN
75563  line(5:40)=refer(2*ilin-51)
75564  line(41:76)=refer(2*ilin-50)
75565  ENDIF
75566 
75567 C...Write lines to appropriate unit.
75568  WRITE(mstu(11),'(A79)') line
75569  100 CONTINUE
75570 
75571  RETURN
75572  END
75573 
75574 C*********************************************************************
75575 
75576 C...PYUPDA
75577 C...Facilitates the updating of particle and decay data
75578 C...by allowing it to be done in an external file.
75579 
75580  SUBROUTINE pyupda(MUPDA,LFN)
75581 
75582 C...Double precision and integer declarations.
75583  IMPLICIT DOUBLE PRECISION(a-h, o-z)
75584  IMPLICIT INTEGER(i-n)
75585  INTEGER pyk,pychge,pycomp
75586 C...Commonblocks.
75587  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
75588  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
75589  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
75590  common/pydat4/chaf(500,2)
75591  CHARACTER chaf*16
75592  common/pyint4/mwid(500),wids(500,5)
75593  SAVE /pydat1/,/pydat2/,/pydat3/,/pydat4/,/pyint4/
75594 C...Local arrays, character variables and data.
75595  CHARACTER chinl*120,chkf*9,chvar(22)*9,chlin*72,
75596  &chblk(20)*72,chold*16,chtmp*16,chnew*16,chcom*24
75597  DATA chvar/ 'KCHG(I,1)','KCHG(I,2)','KCHG(I,3)','KCHG(I,4)',
75598  &'PMAS(I,1)','PMAS(I,2)','PMAS(I,3)','PMAS(I,4)','MDCY(I,1)',
75599  &'MDCY(I,2)','MDCY(I,3)','MDME(I,1)','MDME(I,2)','BRAT(I) ',
75600  &'KFDP(I,1)','KFDP(I,2)','KFDP(I,3)','KFDP(I,4)','KFDP(I,5)',
75601  &'CHAF(I,1)','CHAF(I,2)','MWID(I) '/
75602 
75603 C...Write header if not yet done.
75604  IF(mstu(12).NE.12345) CALL pylist(0)
75605 
75606 C...Write information on file for editing.
75607  IF(mupda.EQ.1) THEN
75608  DO 110 kc=1,500
75609  WRITE(lfn,5000) kchg(kc,4),(chaf(kc,j1),j1=1,2),
75610  & (kchg(kc,j2),j2=1,3),(pmas(kc,j3),j3=1,4),
75611  & mwid(kc),mdcy(kc,1)
75612  DO 100 idc=mdcy(kc,2),mdcy(kc,2)+mdcy(kc,3)-1
75613  WRITE(lfn,5100) mdme(idc,1),mdme(idc,2),brat(idc),
75614  & (kfdp(idc,j),j=1,5)
75615  100 CONTINUE
75616  110 CONTINUE
75617 
75618 C...Read complete set of information from edited file or
75619 C...read partial set of new or updated information from edited file.
75620  ELSEIF(mupda.EQ.2.OR.mupda.EQ.3) THEN
75621 
75622 C...Reset counters.
75623  kcc=100
75624  ndc=0
75625  chkf=' '
75626  IF(mupda.EQ.2) THEN
75627  DO 120 i=1,mstu(6)
75628  kchg(i,4)=0
75629  120 CONTINUE
75630  ELSE
75631  DO 130 kc=1,mstu(6)
75632  IF(kc.GT.100.AND.kchg(kc,4).GT.100) kcc=kc
75633  ndc=max(ndc,mdcy(kc,2)+mdcy(kc,3)-1)
75634  130 CONTINUE
75635  ENDIF
75636 
75637 C...Begin of loop: read new line; unknown whether particle or
75638 C...decay data.
75639  140 READ(lfn,5200,end=190) chinl
75640 
75641 C...Identify particle code and whether already defined (for MUPDA=3).
75642  IF(chinl(2:10).NE.' ') THEN
75643  chkf=chinl(2:10)
75644  READ(chkf,5300) kf
75645  IF(mupda.EQ.2) THEN
75646  IF(kf.LE.100) THEN
75647  kc=kf
75648  ELSE
75649  kcc=kcc+1
75650  kc=kcc
75651  ENDIF
75652  ELSE
75653  kcrep=0
75654  IF(kf.LE.100) THEN
75655  kcrep=kf
75656  ELSE
75657  DO 150 kcr=101,kcc
75658  IF(kchg(kcr,4).EQ.kf) kcrep=kcr
75659  150 CONTINUE
75660  ENDIF
75661 C...Remove duplicate old decay data.
75662  IF(kcrep.NE.0.AND.mdcy(kcrep,3).GT.0) THEN
75663  idcrep=mdcy(kcrep,2)
75664  ndcrep=mdcy(kcrep,3)
75665  DO 160 i=1,kcc
75666  IF(mdcy(i,2).GT.idcrep) mdcy(i,2)=mdcy(i,2)-ndcrep
75667  160 CONTINUE
75668  DO 180 i=idcrep,ndc-ndcrep
75669  mdme(i,1)=mdme(i+ndcrep,1)
75670  mdme(i,2)=mdme(i+ndcrep,2)
75671  brat(i)=brat(i+ndcrep)
75672  DO 170 j=1,5
75673  kfdp(i,j)=kfdp(i+ndcrep,j)
75674  170 CONTINUE
75675  180 CONTINUE
75676  ndc=ndc-ndcrep
75677  kc=kcrep
75678  ELSEIF(kcrep.NE.0) THEN
75679  kc=kcrep
75680  ELSE
75681  kcc=kcc+1
75682  kc=kcc
75683  ENDIF
75684  ENDIF
75685 
75686 C...Study line with particle data.
75687  IF(kc.GT.mstu(6)) CALL pyerrm(27,
75688  & '(PYUPDA:) Particle arrays full by KF ='//chkf)
75689  READ(chinl,5000) kchg(kc,4),(chaf(kc,j1),j1=1,2),
75690  & (kchg(kc,j2),j2=1,3),(pmas(kc,j3),j3=1,4),
75691  & mwid(kc),mdcy(kc,1)
75692  mdcy(kc,2)=0
75693  mdcy(kc,3)=0
75694 
75695 C...Study line with decay data.
75696  ELSE
75697  ndc=ndc+1
75698  IF(ndc.GT.mstu(7)) CALL pyerrm(27,
75699  & '(PYUPDA:) Decay data arrays full by KF ='//chkf)
75700  IF(mdcy(kc,2).EQ.0) mdcy(kc,2)=ndc
75701  mdcy(kc,3)=mdcy(kc,3)+1
75702  READ(chinl,5100) mdme(ndc,1),mdme(ndc,2),brat(ndc),
75703  & (kfdp(ndc,j),j=1,5)
75704  ENDIF
75705 
75706 C...End of loop; ensure that PYCOMP tables are updated.
75707  goto 140
75708  190 CONTINUE
75709  mstu(20)=0
75710 
75711 C...Perform possible tests that new information is consistent.
75712  DO 220 kc=1,mstu(6)
75713  kf=kchg(kc,4)
75714  IF(kf.EQ.0) goto 220
75715  WRITE(chkf,5300) kf
75716  IF(min(pmas(kc,1),pmas(kc,2),pmas(kc,3),pmas(kc,1)-pmas(kc,3),
75717  & pmas(kc,4)).LT.0d0.OR.mdcy(kc,3).LT.0) CALL pyerrm(17,
75718  & '(PYUPDA:) Mass/width/life/(# channels) wrong for KF ='//chkf)
75719  brsum=0d0
75720  DO 210 idc=mdcy(kc,2),mdcy(kc,2)+mdcy(kc,3)-1
75721  IF(mdme(idc,2).GT.80) goto 210
75722  kq=kchg(kc,1)
75723  pms=pmas(kc,1)-pmas(kc,3)-parj(64)
75724  merr=0
75725  DO 200 j=1,5
75726  kp=kfdp(idc,j)
75727  IF(kp.EQ.0.OR.kp.EQ.81.OR.iabs(kp).EQ.82) THEN
75728  IF(kp.EQ.81) kq=0
75729  ELSEIF(pycomp(kp).EQ.0) THEN
75730  merr=3
75731  ELSE
75732  kq=kq-pychge(kp)
75733  kpc=pycomp(kp)
75734  pms=pms-pmas(kpc,1)
75735  IF(mstj(24).GT.0) pms=pms+0.5d0*min(pmas(kpc,2),
75736  & pmas(kpc,3))
75737  ENDIF
75738  200 CONTINUE
75739  IF(kq.NE.0) merr=max(2,merr)
75740  IF(mwid(kc).EQ.0.AND.kf.NE.311.AND.pms.LT.0d0)
75741  & merr=max(1,merr)
75742  IF(merr.EQ.3) CALL pyerrm(17,
75743  & '(PYUPDA:) Unknown particle code in decay of KF ='//chkf)
75744  IF(merr.EQ.2) CALL pyerrm(17,
75745  & '(PYUPDA:) Charge not conserved in decay of KF ='//chkf)
75746  IF(merr.EQ.1) CALL pyerrm(7,
75747  & '(PYUPDA:) Kinematically unallowed decay of KF ='//chkf)
75748  brsum=brsum+brat(idc)
75749  210 CONTINUE
75750  WRITE(chtmp,5500) brsum
75751  IF(abs(brsum).GT.0.0005d0.AND.abs(brsum-1d0).GT.0.0005d0)
75752  & CALL pyerrm(7,'(PYUPDA:) Sum of branching ratios is '//
75753  & chtmp(9:16)//' for KF ='//chkf)
75754  220 CONTINUE
75755 
75756 C...Write DATA statements for inclusion in program.
75757  ELSEIF(mupda.EQ.4) THEN
75758 
75759 C...Find out how many codes and decay channels are actually used.
75760  kcc=0
75761  ndc=0
75762  DO 230 i=1,mstu(6)
75763  IF(kchg(i,4).NE.0) THEN
75764  kcc=i
75765  ndc=max(ndc,mdcy(i,2)+mdcy(i,3)-1)
75766  ENDIF
75767  230 CONTINUE
75768 
75769 C...Initialize writing of DATA statements for inclusion in program.
75770  DO 300 ivar=1,22
75771  ndim=mstu(6)
75772  IF(ivar.GE.12.AND.ivar.LE.19) ndim=mstu(7)
75773  nlin=1
75774  chlin=' '
75775  chlin(7:35)='DATA ('//chvar(ivar)//',I= 1, )/'
75776  llin=35
75777  chold='START'
75778 
75779 C...Loop through variables for conversion to characters.
75780  DO 280 idim=1,ndim
75781  IF(ivar.EQ.1) WRITE(chtmp,5400) kchg(idim,1)
75782  IF(ivar.EQ.2) WRITE(chtmp,5400) kchg(idim,2)
75783  IF(ivar.EQ.3) WRITE(chtmp,5400) kchg(idim,3)
75784  IF(ivar.EQ.4) WRITE(chtmp,5400) kchg(idim,4)
75785  IF(ivar.EQ.5) WRITE(chtmp,5500) pmas(idim,1)
75786  IF(ivar.EQ.6) WRITE(chtmp,5500) pmas(idim,2)
75787  IF(ivar.EQ.7) WRITE(chtmp,5500) pmas(idim,3)
75788  IF(ivar.EQ.8) WRITE(chtmp,5500) pmas(idim,4)
75789  IF(ivar.EQ.9) WRITE(chtmp,5400) mdcy(idim,1)
75790  IF(ivar.EQ.10) WRITE(chtmp,5400) mdcy(idim,2)
75791  IF(ivar.EQ.11) WRITE(chtmp,5400) mdcy(idim,3)
75792  IF(ivar.EQ.12) WRITE(chtmp,5400) mdme(idim,1)
75793  IF(ivar.EQ.13) WRITE(chtmp,5400) mdme(idim,2)
75794  IF(ivar.EQ.14) WRITE(chtmp,5600) brat(idim)
75795  IF(ivar.EQ.15) WRITE(chtmp,5400) kfdp(idim,1)
75796  IF(ivar.EQ.16) WRITE(chtmp,5400) kfdp(idim,2)
75797  IF(ivar.EQ.17) WRITE(chtmp,5400) kfdp(idim,3)
75798  IF(ivar.EQ.18) WRITE(chtmp,5400) kfdp(idim,4)
75799  IF(ivar.EQ.19) WRITE(chtmp,5400) kfdp(idim,5)
75800  IF(ivar.EQ.20) chtmp=chaf(idim,1)
75801  IF(ivar.EQ.21) chtmp=chaf(idim,2)
75802  IF(ivar.EQ.22) WRITE(chtmp,5400) mwid(idim)
75803 
75804 C...Replace variables beyond what is properly defined.
75805  IF(ivar.LE.4) THEN
75806  IF(idim.GT.kcc) chtmp=' 0'
75807  ELSEIF(ivar.LE.8) THEN
75808  IF(idim.GT.kcc) chtmp=' 0.0'
75809  ELSEIF(ivar.LE.11) THEN
75810  IF(idim.GT.kcc) chtmp=' 0'
75811  ELSEIF(ivar.LE.13) THEN
75812  IF(idim.GT.ndc) chtmp=' 0'
75813  ELSEIF(ivar.LE.14) THEN
75814  IF(idim.GT.ndc) chtmp=' 0.0'
75815  ELSEIF(ivar.LE.19) THEN
75816  IF(idim.GT.ndc) chtmp=' 0'
75817  ELSEIF(ivar.LE.21) THEN
75818  IF(idim.GT.kcc) chtmp=' '
75819  ELSE
75820  IF(idim.GT.kcc) chtmp=' 0'
75821  ENDIF
75822 
75823 C...Length of variable, trailing decimal zeros, quotation marks.
75824  llow=1
75825  lhig=1
75826  DO 240 ll=1,16
75827  IF(chtmp(17-ll:17-ll).NE.' ') llow=17-ll
75828  IF(chtmp(ll:ll).NE.' ') lhig=ll
75829  240 CONTINUE
75830  chnew=chtmp(llow:lhig)//' '
75831  lnew=1+lhig-llow
75832  IF((ivar.GE.5.AND.ivar.LE.8).OR.ivar.EQ.14) THEN
75833  lnew=lnew+1
75834  250 lnew=lnew-1
75835  IF(lnew.GE.2.AND.chnew(lnew:lnew).EQ.'0') goto 250
75836  IF(chnew(lnew:lnew).EQ.'.') lnew=lnew-1
75837  IF(lnew.EQ.0) THEN
75838  chnew(1:3)='0D0'
75839  lnew=3
75840  ELSE
75841  chnew(lnew+1:lnew+2)='D0'
75842  lnew=lnew+2
75843  ENDIF
75844  ELSEIF(ivar.EQ.20.OR.ivar.EQ.21) THEN
75845  DO 260 ll=lnew,1,-1
75846  IF(chnew(ll:ll).EQ.'''') THEN
75847  chtmp=chnew
75848  chnew=chtmp(1:ll)//''''//chtmp(ll+1:11)
75849  lnew=lnew+1
75850  ENDIF
75851  260 CONTINUE
75852  lnew=min(14,lnew)
75853  chtmp=chnew
75854  chnew(1:lnew+2)=''''//chtmp(1:lnew)//''''
75855  lnew=lnew+2
75856  ENDIF
75857 
75858 C...Form composite character string, often including repetition counter.
75859  IF(chnew.NE.chold) THEN
75860  nrpt=1
75861  chold=chnew
75862  chcom=chnew
75863  lcom=lnew
75864  ELSE
75865  lrpt=lnew+1
75866  IF(nrpt.GE.2) lrpt=lnew+3
75867  IF(nrpt.GE.10) lrpt=lnew+4
75868  IF(nrpt.GE.100) lrpt=lnew+5
75869  IF(nrpt.GE.1000) lrpt=lnew+6
75870  llin=llin-lrpt
75871  nrpt=nrpt+1
75872  WRITE(chtmp,5400) nrpt
75873  lrpt=1
75874  IF(nrpt.GE.10) lrpt=2
75875  IF(nrpt.GE.100) lrpt=3
75876  IF(nrpt.GE.1000) lrpt=4
75877  chcom(1:lrpt+1+lnew)=chtmp(17-lrpt:16)//'*'//chnew(1:lnew)
75878  lcom=lrpt+1+lnew
75879  ENDIF
75880 
75881 C...Add characters to end of line, to new line (after storing old line),
75882 C...or to new block of lines (after writing old block).
75883  IF(llin+lcom.LE.70) THEN
75884  chlin(llin+1:llin+lcom+1)=chcom(1:lcom)//','
75885  llin=llin+lcom+1
75886  ELSEIF(nlin.LE.19) THEN
75887  chlin(llin+1:72)=' '
75888  chblk(nlin)=chlin
75889  nlin=nlin+1
75890  chlin(6:6+lcom+1)='&'//chcom(1:lcom)//','
75891  llin=6+lcom+1
75892  ELSE
75893  chlin(llin:72)='/'//' '
75894  chblk(nlin)=chlin
75895  WRITE(chtmp,5400) idim-nrpt
75896  chblk(1)(30:33)=chtmp(13:16)
75897  DO 270 ilin=1,nlin
75898  WRITE(lfn,5700) chblk(ilin)
75899  270 CONTINUE
75900  nlin=1
75901  chlin=' '
75902  chlin(7:35+lcom+1)='DATA ('//chvar(ivar)//
75903  & ',I= , )/'//chcom(1:lcom)//','
75904  WRITE(chtmp,5400) idim-nrpt+1
75905  chlin(25:28)=chtmp(13:16)
75906  llin=35+lcom+1
75907  ENDIF
75908  280 CONTINUE
75909 
75910 C...Write final block of lines.
75911  chlin(llin:72)='/'//' '
75912  chblk(nlin)=chlin
75913  WRITE(chtmp,5400) ndim
75914  chblk(1)(30:33)=chtmp(13:16)
75915  DO 290 ilin=1,nlin
75916  WRITE(lfn,5700) chblk(ilin)
75917  290 CONTINUE
75918  300 CONTINUE
75919  ENDIF
75920 
75921 C...Formats for reading and writing particle data.
75922  5000 FORMAT(1x,i9,2x,a16,2x,a16,3i3,3f12.5,1p,e13.5,2i3)
75923  5100 FORMAT(10x,2i5,f12.6,5i10)
75924  5200 FORMAT(a120)
75925  5300 FORMAT(i9)
75926  5400 FORMAT(i16)
75927  5500 FORMAT(f16.5)
75928  5600 FORMAT(f16.6)
75929  5700 FORMAT(a72)
75930 
75931  RETURN
75932  END
75933 
75934 C*********************************************************************
75935 
75936 C...PYK
75937 C...Provides various integer-valued event related data.
75938 
75939  FUNCTION pyk(I,J)
75940 
75941 C...Double precision and integer declarations.
75942  IMPLICIT DOUBLE PRECISION(a-h, o-z)
75943  IMPLICIT INTEGER(i-n)
75944  INTEGER pyk,pychge,pycomp
75945 C...Commonblocks.
75946  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
75947  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
75948  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
75949  SAVE /pyjets/,/pydat1/,/pydat2/
75950 
75951 C...Default value. For I=0 number of entries, number of stable entries
75952 C...or 3 times total charge.
75953  pyk=0
75954  IF(i.LT.0.OR.i.GT.mstu(4).OR.j.LE.0) THEN
75955  ELSEIF(i.EQ.0.AND.j.EQ.1) THEN
75956  pyk=n
75957  ELSEIF(i.EQ.0.AND.(j.EQ.2.OR.j.EQ.6)) THEN
75958  DO 100 i1=1,n
75959  IF(j.EQ.2.AND.k(i1,1).GE.1.AND.k(i1,1).LE.10) pyk=pyk+1
75960  IF(j.EQ.6.AND.k(i1,1).GE.1.AND.k(i1,1).LE.10) pyk=pyk+
75961  & pychge(k(i1,2))
75962  100 CONTINUE
75963  ELSEIF(i.EQ.0) THEN
75964 
75965 C...For I > 0 direct readout of K matrix or charge.
75966  ELSEIF(j.LE.5) THEN
75967  pyk=k(i,j)
75968  ELSEIF(j.EQ.6) THEN
75969  pyk=pychge(k(i,2))
75970 
75971 C...Status (existing/fragmented/decayed), parton/hadron separation.
75972  ELSEIF(j.LE.8) THEN
75973  IF(k(i,1).GE.1.AND.k(i,1).LE.10) pyk=1
75974  IF(j.EQ.8) pyk=pyk*k(i,2)
75975  ELSEIF(j.LE.12) THEN
75976  kfa=iabs(k(i,2))
75977  kc=pycomp(kfa)
75978  kq=0
75979  IF(kc.NE.0) kq=kchg(kc,2)
75980  IF(j.EQ.9.AND.kc.NE.0.AND.kq.NE.0) pyk=k(i,2)
75981  IF(j.EQ.10.AND.kc.NE.0.AND.kq.EQ.0) pyk=k(i,2)
75982  IF(j.EQ.11) pyk=kc
75983  IF(j.EQ.12) pyk=kq*isign(1,k(i,2))
75984 
75985 C...Heaviest flavour in hadron/diquark.
75986  ELSEIF(j.EQ.13) THEN
75987  kfa=iabs(k(i,2))
75988  pyk=mod(kfa/100,10)*(-1)**mod(kfa/100,10)
75989  IF(kfa.LT.10) pyk=kfa
75990  IF(mod(kfa/1000,10).NE.0) pyk=mod(kfa/1000,10)
75991  pyk=pyk*isign(1,k(i,2))
75992 
75993 C...Particle history: generation, ancestor, rank.
75994  ELSEIF(j.LE.15) THEN
75995  i2=i
75996  i1=i
75997  110 pyk=pyk+1
75998  i2=i1
75999  i1=k(i1,3)
76000  IF(i1.GT.0) THEN
76001  IF(k(i1,1).GT.0.AND.k(i1,1).LE.20) goto 110
76002  ENDIF
76003  IF(j.EQ.15) pyk=i2
76004  ELSEIF(j.EQ.16) THEN
76005  kfa=iabs(k(i,2))
76006  IF(k(i,1).LE.20.AND.((kfa.GE.11.AND.kfa.LE.20).OR.kfa.EQ.22.OR.
76007  & (kfa.GT.100.AND.mod(kfa/10,10).NE.0))) THEN
76008  i1=i
76009  120 i2=i1
76010  i1=k(i1,3)
76011  IF(i1.GT.0) THEN
76012  kfam=iabs(k(i1,2))
76013  ilp=1
76014  IF(kfam.NE.0.AND.kfam.LE.10) ilp=0
76015  IF(kfam.EQ.21.OR.kfam.EQ.91.OR.kfam.EQ.92.OR.kfam.EQ.93)
76016  & ilp=0
76017  IF(kfam.GT.100.AND.mod(kfam/10,10).EQ.0) ilp=0
76018  IF(ilp.EQ.1) goto 120
76019  ENDIF
76020  IF(k(i1,1).EQ.12) THEN
76021  DO 130 i3=i1+1,i2
76022  IF(k(i3,3).EQ.k(i2,3).AND.k(i3,2).NE.91.AND.k(i3,2).NE.92
76023  & .AND.k(i3,2).NE.93) pyk=pyk+1
76024  130 CONTINUE
76025  ELSE
76026  i3=i2
76027  140 pyk=pyk+1
76028  i3=i3+1
76029  IF(i3.LT.n.AND.k(i3,3).EQ.k(i2,3)) goto 140
76030  ENDIF
76031  ENDIF
76032 
76033 C...Particle coming from collapsing jet system or not.
76034  ELSEIF(j.EQ.17) THEN
76035  i1=i
76036  150 pyk=pyk+1
76037  i3=i1
76038  i1=k(i1,3)
76039  i0=max(1,i1)
76040  kc=pycomp(k(i0,2))
76041  IF(i1.EQ.0.OR.k(i0,1).LE.0.OR.k(i0,1).GT.20.OR.kc.EQ.0) THEN
76042  IF(pyk.EQ.1) pyk=-1
76043  IF(pyk.GT.1) pyk=0
76044  RETURN
76045  ENDIF
76046  IF(kchg(kc,2).EQ.0) goto 150
76047  IF(k(i1,1).NE.12) pyk=0
76048  IF(k(i1,1).NE.12) RETURN
76049  i2=i1
76050  160 i2=i2+1
76051  IF(i2.LT.n.AND.k(i2,1).NE.11) goto 160
76052  k3m=k(i3-1,3)
76053  IF(k3m.GE.i1.AND.k3m.LE.i2) pyk=0
76054  k3p=k(i3+1,3)
76055  IF(i3.LT.n.AND.k3p.GE.i1.AND.k3p.LE.i2) pyk=0
76056 
76057 C...Number of decay products. Colour flow.
76058  ELSEIF(j.EQ.18) THEN
76059  IF(k(i,1).EQ.11.OR.k(i,1).EQ.12) pyk=max(0,k(i,5)-k(i,4)+1)
76060  IF(k(i,4).EQ.0.OR.k(i,5).EQ.0) pyk=0
76061  ELSEIF(j.LE.22) THEN
76062  IF(k(i,1).NE.3.AND.k(i,1).NE.13.AND.k(i,1).NE.14) RETURN
76063  IF(j.EQ.19) pyk=mod(k(i,4)/mstu(5),mstu(5))
76064  IF(j.EQ.20) pyk=mod(k(i,5)/mstu(5),mstu(5))
76065  IF(j.EQ.21) pyk=mod(k(i,4),mstu(5))
76066  IF(j.EQ.22) pyk=mod(k(i,5),mstu(5))
76067  ELSE
76068  ENDIF
76069 
76070  RETURN
76071  END
76072 
76073 C*********************************************************************
76074 
76075 C...PYP
76076 C...Provides various real-valued event related data.
76077 
76078  FUNCTION pyp(I,J)
76079 
76080 C...Double precision and integer declarations.
76081  IMPLICIT DOUBLE PRECISION(a-h, o-z)
76082  IMPLICIT INTEGER(i-n)
76083  INTEGER pyk,pychge,pycomp
76084 C...Commonblocks.
76085  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
76086  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
76087  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
76088  SAVE /pyjets/,/pydat1/,/pydat2/
76089 C...Local array.
76090  dimension psum(4)
76091 
76092 C...Set default value. For I = 0 sum of momenta or charges,
76093 C...or invariant mass of system.
76094  pyp=0d0
76095  IF(i.LT.0.OR.i.GT.mstu(4).OR.j.LE.0) THEN
76096  ELSEIF(i.EQ.0.AND.j.LE.4) THEN
76097  DO 100 i1=1,n
76098  IF(k(i1,1).GT.0.AND.k(i1,1).LE.10) pyp=pyp+p(i1,j)
76099  100 CONTINUE
76100  ELSEIF(i.EQ.0.AND.j.EQ.5) THEN
76101  DO 120 j1=1,4
76102  psum(j1)=0d0
76103  DO 110 i1=1,n
76104  IF(k(i1,1).GT.0.AND.k(i1,1).LE.10) psum(j1)=psum(j1)+
76105  & p(i1,j1)
76106  110 CONTINUE
76107  120 CONTINUE
76108  pyp=sqrt(max(0d0,psum(4)**2-psum(1)**2-psum(2)**2-psum(3)**2))
76109  ELSEIF(i.EQ.0.AND.j.EQ.6) THEN
76110  DO 130 i1=1,n
76111  IF(k(i1,1).GT.0.AND.k(i1,1).LE.10) pyp=pyp+pychge(k(i1,2))/3d0
76112  130 CONTINUE
76113  ELSEIF(i.EQ.0) THEN
76114 
76115 C...Direct readout of P matrix.
76116  ELSEIF(j.LE.5) THEN
76117  pyp=p(i,j)
76118 
76119 C...Charge, total momentum, transverse momentum, transverse mass.
76120  ELSEIF(j.LE.12) THEN
76121  IF(j.EQ.6) pyp=pychge(k(i,2))/3d0
76122  IF(j.EQ.7.OR.j.EQ.8) pyp=p(i,1)**2+p(i,2)**2+p(i,3)**2
76123  IF(j.EQ.9.OR.j.EQ.10) pyp=p(i,1)**2+p(i,2)**2
76124  IF(j.EQ.11.OR.j.EQ.12) pyp=p(i,5)**2+p(i,1)**2+p(i,2)**2
76125  IF(j.EQ.8.OR.j.EQ.10.OR.j.EQ.12) pyp=sqrt(pyp)
76126 
76127 C...Theta and phi angle in radians or degrees.
76128  ELSEIF(j.LE.16) THEN
76129  IF(j.LE.14) pyp=pyangl(p(i,3),sqrt(p(i,1)**2+p(i,2)**2))
76130  IF(j.GE.15) pyp=pyangl(p(i,1),p(i,2))
76131  IF(j.EQ.14.OR.j.EQ.16) pyp=pyp*180d0/paru(1)
76132 
76133 C...True rapidity, rapidity with pion mass, pseudorapidity.
76134  ELSEIF(j.LE.19) THEN
76135  pmr=0d0
76136  IF(j.EQ.17) pmr=p(i,5)
76137  IF(j.EQ.18) pmr=pymass(211)
76138  pr=max(1d-20,pmr**2+p(i,1)**2+p(i,2)**2)
76139  pyp=sign(log(min((sqrt(pr+p(i,3)**2)+abs(p(i,3)))/sqrt(pr),
76140  & 1d20)),p(i,3))
76141 
76142 C...Energy and momentum fractions (only to be used in CM frame).
76143  ELSEIF(j.LE.25) THEN
76144  IF(j.EQ.20) pyp=2d0*sqrt(p(i,1)**2+p(i,2)**2+p(i,3)**2)/paru(21)
76145  IF(j.EQ.21) pyp=2d0*p(i,3)/paru(21)
76146  IF(j.EQ.22) pyp=2d0*sqrt(p(i,1)**2+p(i,2)**2)/paru(21)
76147  IF(j.EQ.23) pyp=2d0*p(i,4)/paru(21)
76148  IF(j.EQ.24) pyp=(p(i,4)+p(i,3))/paru(21)
76149  IF(j.EQ.25) pyp=(p(i,4)-p(i,3))/paru(21)
76150  ENDIF
76151 
76152  RETURN
76153  END
76154 
76155 C*********************************************************************
76156 
76157 C...PYSPHE
76158 C...Performs sphericity tensor analysis to give sphericity,
76159 C...aplanarity and the related event axes.
76160 
76161  SUBROUTINE pysphe(SPH,APL)
76162 
76163 C...Double precision and integer declarations.
76164  IMPLICIT DOUBLE PRECISION(a-h, o-z)
76165  IMPLICIT INTEGER(i-n)
76166  INTEGER pyk,pychge,pycomp
76167 C...Parameter statement to help give large particle numbers.
76168  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
76169  &kexcit=4000000,kdimen=5000000)
76170 C...Commonblocks.
76171  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
76172  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
76173  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
76174  SAVE /pyjets/,/pydat1/,/pydat2/
76175 C...Local arrays.
76176  dimension sm(3,3),sv(3,3)
76177 
76178 C...Calculate matrix to be diagonalized.
76179  np=0
76180  DO 110 j1=1,3
76181  DO 100 j2=j1,3
76182  sm(j1,j2)=0d0
76183  100 CONTINUE
76184  110 CONTINUE
76185  ps=0d0
76186  DO 140 i=1,n
76187  IF(k(i,1).LE.0.OR.k(i,1).GT.10) goto 140
76188  IF(mstu(41).GE.2) THEN
76189  kc=pycomp(k(i,2))
76190  IF(kc.EQ.0.OR.kc.EQ.12.OR.kc.EQ.14.OR.kc.EQ.16.OR.
76191  & kc.EQ.18.OR.k(i,2).EQ.ksusy1+22.OR.k(i,2).EQ.39.OR.
76192  & k(i,2).EQ.ksusy1+39) goto 140
76193  IF(mstu(41).GE.3.AND.kchg(kc,2).EQ.0.AND.pychge(k(i,2)).EQ.0)
76194  & goto 140
76195  ENDIF
76196  np=np+1
76197  pa=sqrt(p(i,1)**2+p(i,2)**2+p(i,3)**2)
76198  pwt=1d0
76199  IF(abs(paru(41)-2d0).GT.0.001d0) pwt=
76200  & max(1d-10,pa)**(paru(41)-2d0)
76201  DO 130 j1=1,3
76202  DO 120 j2=j1,3
76203  sm(j1,j2)=sm(j1,j2)+pwt*p(i,j1)*p(i,j2)
76204  120 CONTINUE
76205  130 CONTINUE
76206  ps=ps+pwt*pa**2
76207  140 CONTINUE
76208 
76209 C...Very low multiplicities (0 or 1) not considered.
76210  IF(np.LE.1) THEN
76211  CALL pyerrm(8,'(PYSPHE:) too few particles for analysis')
76212  sph=-1d0
76213  apl=-1d0
76214  RETURN
76215  ENDIF
76216  DO 160 j1=1,3
76217  DO 150 j2=j1,3
76218  sm(j1,j2)=sm(j1,j2)/ps
76219  150 CONTINUE
76220  160 CONTINUE
76221 
76222 C...Find eigenvalues to matrix (third degree equation).
76223  sq=(sm(1,1)*sm(2,2)+sm(1,1)*sm(3,3)+sm(2,2)*sm(3,3)-
76224  &sm(1,2)**2-sm(1,3)**2-sm(2,3)**2)/3d0-1d0/9d0
76225  sr=-0.5d0*(sq+1d0/9d0+sm(1,1)*sm(2,3)**2+sm(2,2)*sm(1,3)**2+
76226  &sm(3,3)*sm(1,2)**2-sm(1,1)*sm(2,2)*sm(3,3))+
76227  &sm(1,2)*sm(1,3)*sm(2,3)+1d0/27d0
76228  sp=cos(acos(max(min(sr/sqrt(-sq**3),1d0),-1d0))/3d0)
76229  p(n+1,4)=1d0/3d0+sqrt(-sq)*max(2d0*sp,sqrt(3d0*(1d0-sp**2))-sp)
76230  p(n+3,4)=1d0/3d0+sqrt(-sq)*min(2d0*sp,-sqrt(3d0*(1d0-sp**2))-sp)
76231  p(n+2,4)=1d0-p(n+1,4)-p(n+3,4)
76232  IF(p(n+2,4).LT.1d-5) THEN
76233  CALL pyerrm(8,'(PYSPHE:) all particles back-to-back')
76234  sph=-1d0
76235  apl=-1d0
76236  RETURN
76237  ENDIF
76238 
76239 C...Find first and last eigenvector by solving equation system.
76240  DO 240 i=1,3,2
76241  DO 180 j1=1,3
76242  sv(j1,j1)=sm(j1,j1)-p(n+i,4)
76243  DO 170 j2=j1+1,3
76244  sv(j1,j2)=sm(j1,j2)
76245  sv(j2,j1)=sm(j1,j2)
76246  170 CONTINUE
76247  180 CONTINUE
76248  smax=0d0
76249  DO 200 j1=1,3
76250  DO 190 j2=1,3
76251  IF(abs(sv(j1,j2)).LE.smax) goto 190
76252  ja=j1
76253  jb=j2
76254  smax=abs(sv(j1,j2))
76255  190 CONTINUE
76256  200 CONTINUE
76257  smax=0d0
76258  DO 220 j3=ja+1,ja+2
76259  j1=j3-3*((j3-1)/3)
76260  rl=sv(j1,jb)/sv(ja,jb)
76261  DO 210 j2=1,3
76262  sv(j1,j2)=sv(j1,j2)-rl*sv(ja,j2)
76263  IF(abs(sv(j1,j2)).LE.smax) goto 210
76264  jc=j1
76265  smax=abs(sv(j1,j2))
76266  210 CONTINUE
76267  220 CONTINUE
76268  jb1=jb+1-3*(jb/3)
76269  jb2=jb+2-3*((jb+1)/3)
76270  p(n+i,jb1)=-sv(jc,jb2)
76271  p(n+i,jb2)=sv(jc,jb1)
76272  p(n+i,jb)=-(sv(ja,jb1)*p(n+i,jb1)+sv(ja,jb2)*p(n+i,jb2))/
76273  & sv(ja,jb)
76274  pa=sqrt(p(n+i,1)**2+p(n+i,2)**2+p(n+i,3)**2)
76275  sgn=(-1d0)**int(pyr(0)+0.5d0)
76276  DO 230 j=1,3
76277  p(n+i,j)=sgn*p(n+i,j)/pa
76278  230 CONTINUE
76279  240 CONTINUE
76280 
76281 C...Middle axis orthogonal to other two. Fill other codes.
76282  sgn=(-1d0)**int(pyr(0)+0.5d0)
76283  p(n+2,1)=sgn*(p(n+1,2)*p(n+3,3)-p(n+1,3)*p(n+3,2))
76284  p(n+2,2)=sgn*(p(n+1,3)*p(n+3,1)-p(n+1,1)*p(n+3,3))
76285  p(n+2,3)=sgn*(p(n+1,1)*p(n+3,2)-p(n+1,2)*p(n+3,1))
76286  DO 260 i=1,3
76287  k(n+i,1)=31
76288  k(n+i,2)=95
76289  k(n+i,3)=i
76290  k(n+i,4)=0
76291  k(n+i,5)=0
76292  p(n+i,5)=0d0
76293  DO 250 j=1,5
76294  v(i,j)=0d0
76295  250 CONTINUE
76296  260 CONTINUE
76297 
76298 C...Calculate sphericity and aplanarity. Select storing option.
76299  sph=1.5d0*(p(n+2,4)+p(n+3,4))
76300  apl=1.5d0*p(n+3,4)
76301  mstu(61)=n+1
76302  mstu(62)=np
76303  IF(mstu(43).LE.1) mstu(3)=3
76304  IF(mstu(43).GE.2) n=n+3
76305 
76306  RETURN
76307  END
76308 
76309 C*********************************************************************
76310 
76311 C...PYTHRU
76312 C...Performs thrust analysis to give thrust, oblateness
76313 C...and the related event axes.
76314 
76315  SUBROUTINE pythru(THR,OBL)
76316 
76317 C...Double precision and integer declarations.
76318  IMPLICIT DOUBLE PRECISION(a-h, o-z)
76319  IMPLICIT INTEGER(i-n)
76320  INTEGER pyk,pychge,pycomp
76321 C...Parameter statement to help give large particle numbers.
76322  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
76323  &kexcit=4000000,kdimen=5000000)
76324 C...Commonblocks.
76325  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
76326  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
76327  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
76328  SAVE /pyjets/,/pydat1/,/pydat2/
76329 C...Local arrays.
76330  dimension tdi(3),tpr(3)
76331 
76332 C...Take copy of particles that are to be considered in thrust analysis.
76333  np=0
76334  ps=0d0
76335  DO 100 i=1,n
76336  IF(k(i,1).LE.0.OR.k(i,1).GT.10) goto 100
76337  IF(mstu(41).GE.2) THEN
76338  kc=pycomp(k(i,2))
76339  IF(kc.EQ.0.OR.kc.EQ.12.OR.kc.EQ.14.OR.kc.EQ.16.OR.
76340  & kc.EQ.18.OR.k(i,2).EQ.ksusy1+22.OR.k(i,2).EQ.39.OR.
76341  & k(i,2).EQ.ksusy1+39) goto 100
76342  IF(mstu(41).GE.3.AND.kchg(kc,2).EQ.0.AND.pychge(k(i,2)).EQ.0)
76343  & goto 100
76344  ENDIF
76345  IF(n+np+mstu(44)+15.GE.mstu(4)-mstu(32)-5) THEN
76346  CALL pyerrm(11,'(PYTHRU:) no more memory left in PYJETS')
76347  thr=-2d0
76348  obl=-2d0
76349  RETURN
76350  ENDIF
76351  np=np+1
76352  k(n+np,1)=23
76353  p(n+np,1)=p(i,1)
76354  p(n+np,2)=p(i,2)
76355  p(n+np,3)=p(i,3)
76356  p(n+np,4)=sqrt(p(i,1)**2+p(i,2)**2+p(i,3)**2)
76357  p(n+np,5)=1d0
76358  IF(abs(paru(42)-1d0).GT.0.001d0) p(n+np,5)=
76359  & p(n+np,4)**(paru(42)-1d0)
76360  ps=ps+p(n+np,4)*p(n+np,5)
76361  100 CONTINUE
76362 
76363 C...Very low multiplicities (0 or 1) not considered.
76364  IF(np.LE.1) THEN
76365  CALL pyerrm(8,'(PYTHRU:) too few particles for analysis')
76366  thr=-1d0
76367  obl=-1d0
76368  RETURN
76369  ENDIF
76370 
76371 C...Loop over thrust and major. T axis along z direction in latter case.
76372  DO 320 ild=1,2
76373  IF(ild.EQ.2) THEN
76374  k(n+np+1,1)=31
76375  phi=pyangl(p(n+np+1,1),p(n+np+1,2))
76376  mstu(33)=1
76377  CALL pyrobo(n+1,n+np+1,0d0,-phi,0d0,0d0,0d0)
76378  the=pyangl(p(n+np+1,3),p(n+np+1,1))
76379  CALL pyrobo(n+1,n+np+1,-the,0d0,0d0,0d0,0d0)
76380  ENDIF
76381 
76382 C...Find and order particles with highest p (pT for major).
76383  DO 110 ilf=n+np+4,n+np+mstu(44)+4
76384  p(ilf,4)=0d0
76385  110 CONTINUE
76386  DO 160 i=n+1,n+np
76387  IF(ild.EQ.2) p(i,4)=sqrt(p(i,1)**2+p(i,2)**2)
76388  DO 130 ilf=n+np+mstu(44)+3,n+np+4,-1
76389  IF(p(i,4).LE.p(ilf,4)) goto 140
76390  DO 120 j=1,5
76391  p(ilf+1,j)=p(ilf,j)
76392  120 CONTINUE
76393  130 CONTINUE
76394  ilf=n+np+3
76395  140 DO 150 j=1,5
76396  p(ilf+1,j)=p(i,j)
76397  150 CONTINUE
76398  160 CONTINUE
76399 
76400 C...Find and order initial axes with highest thrust (major).
76401  DO 170 ilg=n+np+mstu(44)+5,n+np+mstu(44)+15
76402  p(ilg,4)=0d0
76403  170 CONTINUE
76404  nc=2**(min(mstu(44),np)-1)
76405  DO 250 ilc=1,nc
76406  DO 180 j=1,3
76407  tdi(j)=0d0
76408  180 CONTINUE
76409  DO 200 ilf=1,min(mstu(44),np)
76410  sgn=p(n+np+ilf+3,5)
76411  IF(2**ilf*((ilc+2**(ilf-1)-1)/2**ilf).GE.ilc) sgn=-sgn
76412  DO 190 j=1,4-ild
76413  tdi(j)=tdi(j)+sgn*p(n+np+ilf+3,j)
76414  190 CONTINUE
76415  200 CONTINUE
76416  tds=tdi(1)**2+tdi(2)**2+tdi(3)**2
76417  DO 220 ilg=n+np+mstu(44)+min(ilc,10)+4,n+np+mstu(44)+5,-1
76418  IF(tds.LE.p(ilg,4)) goto 230
76419  DO 210 j=1,4
76420  p(ilg+1,j)=p(ilg,j)
76421  210 CONTINUE
76422  220 CONTINUE
76423  ilg=n+np+mstu(44)+4
76424  230 DO 240 j=1,3
76425  p(ilg+1,j)=tdi(j)
76426  240 CONTINUE
76427  p(ilg+1,4)=tds
76428  250 CONTINUE
76429 
76430 C...Iterate direction of axis until stable maximum.
76431  p(n+np+ild,4)=0d0
76432  ilg=0
76433  260 ilg=ilg+1
76434  thp=0d0
76435  270 thps=thp
76436  DO 280 j=1,3
76437  IF(thp.LE.1d-10) tdi(j)=p(n+np+mstu(44)+4+ilg,j)
76438  IF(thp.GT.1d-10) tdi(j)=tpr(j)
76439  tpr(j)=0d0
76440  280 CONTINUE
76441  DO 300 i=n+1,n+np
76442  sgn=sign(p(i,5),tdi(1)*p(i,1)+tdi(2)*p(i,2)+tdi(3)*p(i,3))
76443  DO 290 j=1,4-ild
76444  tpr(j)=tpr(j)+sgn*p(i,j)
76445  290 CONTINUE
76446  300 CONTINUE
76447  thp=sqrt(tpr(1)**2+tpr(2)**2+tpr(3)**2)/ps
76448  IF(thp.GE.thps+paru(48)) goto 270
76449 
76450 C...Save good axis. Try new initial axis until a number of tries agree.
76451  IF(thp.LT.p(n+np+ild,4)-paru(48).AND.ilg.LT.min(10,nc)) goto 260
76452  IF(thp.GT.p(n+np+ild,4)+paru(48)) THEN
76453  iagr=0
76454  sgn=(-1d0)**int(pyr(0)+0.5d0)
76455  DO 310 j=1,3
76456  p(n+np+ild,j)=sgn*tpr(j)/(ps*thp)
76457  310 CONTINUE
76458  p(n+np+ild,4)=thp
76459  p(n+np+ild,5)=0d0
76460  ENDIF
76461  iagr=iagr+1
76462  IF(iagr.LT.mstu(45).AND.ilg.LT.min(10,nc)) goto 260
76463  320 CONTINUE
76464 
76465 C...Find minor axis and value by orthogonality.
76466  sgn=(-1d0)**int(pyr(0)+0.5d0)
76467  p(n+np+3,1)=-sgn*p(n+np+2,2)
76468  p(n+np+3,2)=sgn*p(n+np+2,1)
76469  p(n+np+3,3)=0d0
76470  thp=0d0
76471  DO 330 i=n+1,n+np
76472  thp=thp+p(i,5)*abs(p(n+np+3,1)*p(i,1)+p(n+np+3,2)*p(i,2))
76473  330 CONTINUE
76474  p(n+np+3,4)=thp/ps
76475  p(n+np+3,5)=0d0
76476 
76477 C...Fill axis information. Rotate back to original coordinate system.
76478  DO 350 ild=1,3
76479  k(n+ild,1)=31
76480  k(n+ild,2)=96
76481  k(n+ild,3)=ild
76482  k(n+ild,4)=0
76483  k(n+ild,5)=0
76484  DO 340 j=1,5
76485  p(n+ild,j)=p(n+np+ild,j)
76486  v(n+ild,j)=0d0
76487  340 CONTINUE
76488  350 CONTINUE
76489  CALL pyrobo(n+1,n+3,the,phi,0d0,0d0,0d0)
76490 
76491 C...Calculate thrust and oblateness. Select storing option.
76492  thr=p(n+1,4)
76493  obl=p(n+2,4)-p(n+3,4)
76494  mstu(61)=n+1
76495  mstu(62)=np
76496  IF(mstu(43).LE.1) mstu(3)=3
76497  IF(mstu(43).GE.2) n=n+3
76498 
76499  RETURN
76500  END
76501 
76502 C*********************************************************************
76503 
76504 C...PYCLUS
76505 C...Subdivides the particle content of an event into jets/clusters.
76506 
76507  SUBROUTINE pyclus(NJET)
76508 
76509 C...Double precision and integer declarations.
76510  IMPLICIT DOUBLE PRECISION(a-h, o-z)
76511  IMPLICIT INTEGER(i-n)
76512  INTEGER pyk,pychge,pycomp
76513 C...Parameter statement to help give large particle numbers.
76514  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
76515  &kexcit=4000000,kdimen=5000000)
76516 C...Commonblocks.
76517  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
76518  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
76519  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
76520  SAVE /pyjets/,/pydat1/,/pydat2/
76521 C...Local arrays and saved variables.
76522  dimension ps(5)
76523  SAVE nsav,np,ps,pss,rinit,npre,nrem
76524 
76525 C...Functions: distance measure in pT, (pseudo)mass or Durham pT.
76526  r2t(i1,i2)=(p(i1,5)*p(i2,5)-p(i1,1)*p(i2,1)-p(i1,2)*p(i2,2)-
76527  &p(i1,3)*p(i2,3))*2d0*p(i1,5)*p(i2,5)/(0.0001d0+p(i1,5)+p(i2,5))**2
76528  r2m(i1,i2)=2d0*p(i1,4)*p(i2,4)*(1d0-(p(i1,1)*p(i2,1)+p(i1,2)*
76529  &p(i2,2)+p(i1,3)*p(i2,3))/max(1d-10,p(i1,5)*p(i2,5)))
76530  r2d(i1,i2)=2d0*min(p(i1,4),p(i2,4))**2*(1d0-(p(i1,1)*p(i2,1)+
76531  &p(i1,2)*p(i2,2)+p(i1,3)*p(i2,3))/max(1d-10,p(i1,5)*p(i2,5)))
76532 
76533 C...If first time, reset. If reentering, skip preliminaries.
76534  IF(mstu(48).LE.0) THEN
76535  np=0
76536  DO 100 j=1,5
76537  ps(j)=0d0
76538  100 CONTINUE
76539  pss=0d0
76540  pimass=pmas(pycomp(211),1)
76541  ELSE
76542  njet=nsav
76543  IF(mstu(43).GE.2) n=n-njet
76544  DO 110 i=n+1,n+njet
76545  p(i,5)=sqrt(p(i,1)**2+p(i,2)**2+p(i,3)**2)
76546  110 CONTINUE
76547  IF(mstu(46).LE.3.OR.mstu(46).EQ.5) THEN
76548  r2acc=paru(44)**2
76549  ELSE
76550  r2acc=paru(45)*ps(5)**2
76551  ENDIF
76552  nloop=0
76553  goto 300
76554  ENDIF
76555 
76556 C...Find which particles are to be considered in cluster search.
76557  DO 140 i=1,n
76558  IF(k(i,1).LE.0.OR.k(i,1).GT.10) goto 140
76559  IF(mstu(41).GE.2) THEN
76560  kc=pycomp(k(i,2))
76561  IF(kc.EQ.0.OR.kc.EQ.12.OR.kc.EQ.14.OR.kc.EQ.16.OR.
76562  & kc.EQ.18.OR.k(i,2).EQ.ksusy1+22.OR.k(i,2).EQ.39.OR.
76563  & k(i,2).EQ.ksusy1+39) goto 140
76564  IF(mstu(41).GE.3.AND.kchg(kc,2).EQ.0.AND.pychge(k(i,2)).EQ.0)
76565  & goto 140
76566  ENDIF
76567  IF(n+2*np.GE.mstu(4)-mstu(32)-5) THEN
76568  CALL pyerrm(11,'(PYCLUS:) no more memory left in PYJETS')
76569  njet=-1
76570  RETURN
76571  ENDIF
76572 
76573 C...Take copy of these particles, with space left for jets later on.
76574  np=np+1
76575  k(n+np,3)=i
76576  DO 120 j=1,5
76577  p(n+np,j)=p(i,j)
76578  120 CONTINUE
76579  IF(mstu(42).EQ.0) p(n+np,5)=0d0
76580  IF(mstu(42).EQ.1.AND.k(i,2).NE.22) p(n+np,5)=pimass
76581  p(n+np,4)=sqrt(p(n+np,5)**2+p(i,1)**2+p(i,2)**2+p(i,3)**2)
76582  p(n+np,5)=sqrt(p(i,1)**2+p(i,2)**2+p(i,3)**2)
76583  DO 130 j=1,4
76584  ps(j)=ps(j)+p(n+np,j)
76585  130 CONTINUE
76586  pss=pss+p(n+np,5)
76587  140 CONTINUE
76588  DO 160 i=n+1,n+np
76589  k(i+np,3)=k(i,3)
76590  DO 150 j=1,5
76591  p(i+np,j)=p(i,j)
76592  150 CONTINUE
76593  160 CONTINUE
76594  ps(5)=sqrt(max(0d0,ps(4)**2-ps(1)**2-ps(2)**2-ps(3)**2))
76595 
76596 C...Very low multiplicities not considered.
76597  IF(np.LT.mstu(47)) THEN
76598  CALL pyerrm(8,'(PYCLUS:) too few particles for analysis')
76599  njet=-1
76600  RETURN
76601  ENDIF
76602 
76603 C...Find precluster configuration. If too few jets, make harder cuts.
76604  nloop=0
76605  IF(mstu(46).LE.3.OR.mstu(46).EQ.5) THEN
76606  r2acc=paru(44)**2
76607  ELSE
76608  r2acc=paru(45)*ps(5)**2
76609  ENDIF
76610  rinit=1.25d0*paru(43)
76611  IF(np.LE.mstu(47)+2) rinit=0d0
76612  170 rinit=0.8d0*rinit
76613  npre=0
76614  nrem=np
76615  DO 180 i=n+np+1,n+2*np
76616  k(i,4)=0
76617  180 CONTINUE
76618 
76619 C...Sum up small momentum region. Jet if enough absolute momentum.
76620  IF(mstu(46).LE.2) THEN
76621  DO 190 j=1,4
76622  p(n+1,j)=0d0
76623  190 CONTINUE
76624  DO 210 i=n+np+1,n+2*np
76625  IF(p(i,5).GT.2d0*rinit) goto 210
76626  nrem=nrem-1
76627  k(i,4)=1
76628  DO 200 j=1,4
76629  p(n+1,j)=p(n+1,j)+p(i,j)
76630  200 CONTINUE
76631  210 CONTINUE
76632  p(n+1,5)=sqrt(p(n+1,1)**2+p(n+1,2)**2+p(n+1,3)**2)
76633  IF(p(n+1,5).GT.2d0*rinit) npre=1
76634  IF(rinit.GE.0.2d0*paru(43).AND.npre+nrem.LT.mstu(47)) goto 170
76635  IF(nrem.EQ.0) goto 170
76636  ENDIF
76637 
76638 C...Find fastest remaining particle.
76639  220 npre=npre+1
76640  pmax=0d0
76641  DO 230 i=n+np+1,n+2*np
76642  IF(k(i,4).NE.0.OR.p(i,5).LE.pmax) goto 230
76643  imax=i
76644  pmax=p(i,5)
76645  230 CONTINUE
76646  DO 240 j=1,5
76647  p(n+npre,j)=p(imax,j)
76648  240 CONTINUE
76649  nrem=nrem-1
76650  k(imax,4)=npre
76651 
76652 C...Sum up precluster around it according to pT separation.
76653  IF(mstu(46).LE.2) THEN
76654  DO 260 i=n+np+1,n+2*np
76655  IF(k(i,4).NE.0) goto 260
76656  r2=r2t(i,imax)
76657  IF(r2.GT.rinit**2) goto 260
76658  nrem=nrem-1
76659  k(i,4)=npre
76660  DO 250 j=1,4
76661  p(n+npre,j)=p(n+npre,j)+p(i,j)
76662  250 CONTINUE
76663  260 CONTINUE
76664  p(n+npre,5)=sqrt(p(n+npre,1)**2+p(n+npre,2)**2+p(n+npre,3)**2)
76665 
76666 C...Sum up precluster around it according to mass or
76667 C...Durham pT separation.
76668  ELSE
76669  270 imin=0
76670  r2min=rinit**2
76671  DO 280 i=n+np+1,n+2*np
76672  IF(k(i,4).NE.0) goto 280
76673  IF(mstu(46).LE.4) THEN
76674  r2=r2m(i,n+npre)
76675  ELSE
76676  r2=r2d(i,n+npre)
76677  ENDIF
76678  IF(r2.GE.r2min) goto 280
76679  imin=i
76680  r2min=r2
76681  280 CONTINUE
76682  IF(imin.NE.0) THEN
76683  DO 290 j=1,4
76684  p(n+npre,j)=p(n+npre,j)+p(imin,j)
76685  290 CONTINUE
76686  p(n+npre,5)=sqrt(p(n+npre,1)**2+p(n+npre,2)**2+p(n+npre,3)**2)
76687  nrem=nrem-1
76688  k(imin,4)=npre
76689  goto 270
76690  ENDIF
76691  ENDIF
76692 
76693 C...Check if more preclusters to be found. Start over if too few.
76694  IF(rinit.GE.0.2d0*paru(43).AND.npre+nrem.LT.mstu(47)) goto 170
76695  IF(nrem.GT.0) goto 220
76696  njet=npre
76697 
76698 C...Reassign all particles to nearest jet. Sum up new jet momenta.
76699  300 tsav=0d0
76700  psjt=0d0
76701  310 IF(mstu(46).LE.1) THEN
76702  DO 330 i=n+1,n+njet
76703  DO 320 j=1,4
76704  v(i,j)=0d0
76705  320 CONTINUE
76706  330 CONTINUE
76707  DO 360 i=n+np+1,n+2*np
76708  r2min=pss**2
76709  DO 340 ijet=n+1,n+njet
76710  IF(p(ijet,5).LT.rinit) goto 340
76711  r2=r2t(i,ijet)
76712  IF(r2.GE.r2min) goto 340
76713  imin=ijet
76714  r2min=r2
76715  340 CONTINUE
76716  k(i,4)=imin-n
76717  DO 350 j=1,4
76718  v(imin,j)=v(imin,j)+p(i,j)
76719  350 CONTINUE
76720  360 CONTINUE
76721  psjt=0d0
76722  DO 380 i=n+1,n+njet
76723  DO 370 j=1,4
76724  p(i,j)=v(i,j)
76725  370 CONTINUE
76726  p(i,5)=sqrt(p(i,1)**2+p(i,2)**2+p(i,3)**2)
76727  psjt=psjt+p(i,5)
76728  380 CONTINUE
76729  ENDIF
76730 
76731 C...Find two closest jets.
76732  r2min=2d0*max(r2acc,ps(5)**2)
76733  DO 400 itry1=n+1,n+njet-1
76734  DO 390 itry2=itry1+1,n+njet
76735  IF(mstu(46).LE.2) THEN
76736  r2=r2t(itry1,itry2)
76737  ELSEIF(mstu(46).LE.4) THEN
76738  r2=r2m(itry1,itry2)
76739  ELSE
76740  r2=r2d(itry1,itry2)
76741  ENDIF
76742  IF(r2.GE.r2min) goto 390
76743  imin1=itry1
76744  imin2=itry2
76745  r2min=r2
76746  390 CONTINUE
76747  400 CONTINUE
76748 
76749 C...If allowed, join two closest jets and start over.
76750  IF(njet.GT.mstu(47).AND.r2min.LT.r2acc) THEN
76751  irec=min(imin1,imin2)
76752  idel=max(imin1,imin2)
76753  DO 410 j=1,4
76754  p(irec,j)=p(imin1,j)+p(imin2,j)
76755  410 CONTINUE
76756  p(irec,5)=sqrt(p(irec,1)**2+p(irec,2)**2+p(irec,3)**2)
76757  DO 430 i=idel+1,n+njet
76758  DO 420 j=1,5
76759  p(i-1,j)=p(i,j)
76760  420 CONTINUE
76761  430 CONTINUE
76762  IF(mstu(46).GE.2) THEN
76763  DO 440 i=n+np+1,n+2*np
76764  iori=n+k(i,4)
76765  IF(iori.EQ.idel) k(i,4)=irec-n
76766  IF(iori.GT.idel) k(i,4)=k(i,4)-1
76767  440 CONTINUE
76768  ENDIF
76769  njet=njet-1
76770  goto 300
76771 
76772 C...Divide up broad jet if empty cluster in list of final ones.
76773  ELSEIF(njet.EQ.mstu(47).AND.mstu(46).LE.1.AND.nloop.LE.2) THEN
76774  DO 450 i=n+1,n+njet
76775  k(i,5)=0
76776  450 CONTINUE
76777  DO 460 i=n+np+1,n+2*np
76778  k(n+k(i,4),5)=k(n+k(i,4),5)+1
76779  460 CONTINUE
76780  iemp=0
76781  DO 470 i=n+1,n+njet
76782  IF(k(i,5).EQ.0) iemp=i
76783  470 CONTINUE
76784  IF(iemp.NE.0) THEN
76785  nloop=nloop+1
76786  ispl=0
76787  r2max=0d0
76788  DO 480 i=n+np+1,n+2*np
76789  IF(k(n+k(i,4),5).LE.1.OR.p(i,5).LT.rinit) goto 480
76790  ijet=n+k(i,4)
76791  r2=r2t(i,ijet)
76792  IF(r2.LE.r2max) goto 480
76793  ispl=i
76794  r2max=r2
76795  480 CONTINUE
76796  IF(ispl.NE.0) THEN
76797  ijet=n+k(ispl,4)
76798  DO 490 j=1,4
76799  p(iemp,j)=p(ispl,j)
76800  p(ijet,j)=p(ijet,j)-p(ispl,j)
76801  490 CONTINUE
76802  p(iemp,5)=p(ispl,5)
76803  p(ijet,5)=sqrt(p(ijet,1)**2+p(ijet,2)**2+p(ijet,3)**2)
76804  IF(nloop.LE.2) goto 300
76805  ENDIF
76806  ENDIF
76807  ENDIF
76808 
76809 C...If generalized thrust has not yet converged, continue iteration.
76810  IF(mstu(46).LE.1.AND.nloop.LE.2.AND.psjt/pss.GT.tsav+paru(48))
76811  &THEN
76812  tsav=psjt/pss
76813  goto 310
76814  ENDIF
76815 
76816 C...Reorder jets according to energy.
76817  DO 510 i=n+1,n+njet
76818  DO 500 j=1,5
76819  v(i,j)=p(i,j)
76820  500 CONTINUE
76821  510 CONTINUE
76822  DO 540 inew=n+1,n+njet
76823  pemax=0d0
76824  DO 520 itry=n+1,n+njet
76825  IF(v(itry,4).LE.pemax) goto 520
76826  imax=itry
76827  pemax=v(itry,4)
76828  520 CONTINUE
76829  k(inew,1)=31
76830  k(inew,2)=97
76831  k(inew,3)=inew-n
76832  k(inew,4)=0
76833  DO 530 j=1,5
76834  p(inew,j)=v(imax,j)
76835  530 CONTINUE
76836  v(imax,4)=-1d0
76837  k(imax,5)=inew
76838  540 CONTINUE
76839 
76840 C...Clean up particle-jet assignments and jet information.
76841  DO 550 i=n+np+1,n+2*np
76842  iori=k(n+k(i,4),5)
76843  k(i,4)=iori-n
76844  IF(k(k(i,3),1).NE.3) k(k(i,3),4)=iori-n
76845  k(iori,4)=k(iori,4)+1
76846  550 CONTINUE
76847  iemp=0
76848  psjt=0d0
76849  DO 570 i=n+1,n+njet
76850  k(i,5)=0
76851  psjt=psjt+p(i,5)
76852  p(i,5)=sqrt(max(p(i,4)**2-p(i,5)**2,0d0))
76853  DO 560 j=1,5
76854  v(i,j)=0d0
76855  560 CONTINUE
76856  IF(k(i,4).EQ.0) iemp=i
76857  570 CONTINUE
76858 
76859 C...Select storing option. Output variables. Check for failure.
76860  mstu(61)=n+1
76861  mstu(62)=np
76862  mstu(63)=npre
76863  paru(61)=ps(5)
76864  paru(62)=psjt/pss
76865  paru(63)=sqrt(r2min)
76866  IF(njet.LE.1) paru(63)=0d0
76867  IF(iemp.NE.0) THEN
76868  CALL pyerrm(8,'(PYCLUS:) failed to reconstruct as requested')
76869  njet=-1
76870  RETURN
76871  ENDIF
76872  IF(mstu(43).LE.1) mstu(3)=max(0,njet)
76873  IF(mstu(43).GE.2) n=n+max(0,njet)
76874  nsav=njet
76875 
76876  RETURN
76877  END
76878 
76879 C*********************************************************************
76880 
76881 C...PYCELL
76882 C...Provides a simple way of jet finding in eta-phi-ET coordinates,
76883 C...as used for calorimeters at hadron colliders.
76884 
76885  SUBROUTINE pycell(NJET)
76886 
76887 C...Double precision and integer declarations.
76888  IMPLICIT DOUBLE PRECISION(a-h, o-z)
76889  IMPLICIT INTEGER(i-n)
76890  INTEGER pyk,pychge,pycomp
76891 C...Parameter statement to help give large particle numbers.
76892  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
76893  &kexcit=4000000,kdimen=5000000)
76894 C...Commonblocks.
76895  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
76896  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
76897  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
76898  SAVE /pyjets/,/pydat1/,/pydat2/
76899 
76900 C...Loop over all particles. Find cell that was hit by given particle.
76901  ptlrat=1d0/sinh(paru(51))**2
76902  np=0
76903  nc=n
76904  DO 110 i=1,n
76905  IF(k(i,1).LE.0.OR.k(i,1).GT.10) goto 110
76906  IF(p(i,1)**2+p(i,2)**2.LE.ptlrat*p(i,3)**2) goto 110
76907  IF(mstu(41).GE.2) THEN
76908  kc=pycomp(k(i,2))
76909  IF(kc.EQ.0.OR.kc.EQ.12.OR.kc.EQ.14.OR.kc.EQ.16.OR.
76910  & kc.EQ.18.OR.k(i,2).EQ.ksusy1+22.OR.k(i,2).EQ.39.OR.
76911  & k(i,2).EQ.ksusy1+39) goto 110
76912  IF(mstu(41).GE.3.AND.kchg(kc,2).EQ.0.AND.pychge(k(i,2)).EQ.0)
76913  & goto 110
76914  ENDIF
76915  np=np+1
76916  pt=sqrt(p(i,1)**2+p(i,2)**2)
76917  eta=sign(log((sqrt(pt**2+p(i,3)**2)+abs(p(i,3)))/pt),p(i,3))
76918  ieta=max(1,min(mstu(51),1+int(mstu(51)*0.5d0*
76919  & (eta/paru(51)+1d0))))
76920  phi=pyangl(p(i,1),p(i,2))
76921  iphi=max(1,min(mstu(52),1+int(mstu(52)*0.5d0*
76922  & (phi/paru(1)+1d0))))
76923  ietph=mstu(52)*ieta+iphi
76924 
76925 C...Add to cell already hit, or book new cell.
76926  DO 100 ic=n+1,nc
76927  IF(ietph.EQ.k(ic,3)) THEN
76928  k(ic,4)=k(ic,4)+1
76929  p(ic,5)=p(ic,5)+pt
76930  goto 110
76931  ENDIF
76932  100 CONTINUE
76933  IF(nc.GE.mstu(4)-mstu(32)-5) THEN
76934  CALL pyerrm(11,'(PYCELL:) no more memory left in PYJETS')
76935  njet=-2
76936  RETURN
76937  ENDIF
76938  nc=nc+1
76939  k(nc,3)=ietph
76940  k(nc,4)=1
76941  k(nc,5)=2
76942  p(nc,1)=(paru(51)/mstu(51))*(2*ieta-1-mstu(51))
76943  p(nc,2)=(paru(1)/mstu(52))*(2*iphi-1-mstu(52))
76944  p(nc,5)=pt
76945  110 CONTINUE
76946 
76947 C...Smear true bin content by calorimeter resolution.
76948  IF(mstu(53).GE.1) THEN
76949  DO 130 ic=n+1,nc
76950  pei=p(ic,5)
76951  IF(mstu(53).EQ.2) pei=p(ic,5)*cosh(p(ic,1))
76952  120 pef=pei+paru(55)*sqrt(-2d0*log(max(1d-10,pyr(0)))*pei)*
76953  & cos(paru(2)*pyr(0))
76954  IF(pef.LT.0d0.OR.pef.GT.paru(56)*pei) goto 120
76955  p(ic,5)=pef
76956  IF(mstu(53).EQ.2) p(ic,5)=pef/cosh(p(ic,1))
76957  130 CONTINUE
76958  ENDIF
76959 
76960 C...Remove cells below threshold.
76961  IF(paru(58).GT.0d0) THEN
76962  ncc=nc
76963  nc=n
76964  DO 140 ic=n+1,ncc
76965  IF(p(ic,5).GT.paru(58)) THEN
76966  nc=nc+1
76967  k(nc,3)=k(ic,3)
76968  k(nc,4)=k(ic,4)
76969  k(nc,5)=k(ic,5)
76970  p(nc,1)=p(ic,1)
76971  p(nc,2)=p(ic,2)
76972  p(nc,5)=p(ic,5)
76973  ENDIF
76974  140 CONTINUE
76975  ENDIF
76976 
76977 C...Find initiator cell: the one with highest pT of not yet used ones.
76978  nj=nc
76979  150 etmax=0d0
76980  DO 160 ic=n+1,nc
76981  IF(k(ic,5).NE.2) goto 160
76982  IF(p(ic,5).LE.etmax) goto 160
76983  icmax=ic
76984  eta=p(ic,1)
76985  phi=p(ic,2)
76986  etmax=p(ic,5)
76987  160 CONTINUE
76988  IF(etmax.LT.paru(52)) goto 220
76989  IF(nj.GE.mstu(4)-mstu(32)-5) THEN
76990  CALL pyerrm(11,'(PYCELL:) no more memory left in PYJETS')
76991  njet=-2
76992  RETURN
76993  ENDIF
76994  k(icmax,5)=1
76995  nj=nj+1
76996  k(nj,4)=0
76997  k(nj,5)=1
76998  p(nj,1)=eta
76999  p(nj,2)=phi
77000  p(nj,3)=0d0
77001  p(nj,4)=0d0
77002  p(nj,5)=0d0
77003 
77004 C...Sum up unused cells within required distance of initiator.
77005  DO 170 ic=n+1,nc
77006  IF(k(ic,5).EQ.0) goto 170
77007  IF(abs(p(ic,1)-eta).GT.paru(54)) goto 170
77008  dphia=abs(p(ic,2)-phi)
77009  IF(dphia.GT.paru(54).AND.dphia.LT.paru(2)-paru(54)) goto 170
77010  phic=p(ic,2)
77011  IF(dphia.GT.paru(1)) phic=phic+sign(paru(2),phi)
77012  IF((p(ic,1)-eta)**2+(phic-phi)**2.GT.paru(54)**2) goto 170
77013  k(ic,5)=-k(ic,5)
77014  k(nj,4)=k(nj,4)+k(ic,4)
77015  p(nj,3)=p(nj,3)+p(ic,5)*p(ic,1)
77016  p(nj,4)=p(nj,4)+p(ic,5)*phic
77017  p(nj,5)=p(nj,5)+p(ic,5)
77018  170 CONTINUE
77019 
77020 C...Reject cluster below minimum ET, else accept.
77021  IF(p(nj,5).LT.paru(53)) THEN
77022  nj=nj-1
77023  DO 180 ic=n+1,nc
77024  IF(k(ic,5).LT.0) k(ic,5)=-k(ic,5)
77025  180 CONTINUE
77026  ELSEIF(mstu(54).LE.2) THEN
77027  p(nj,3)=p(nj,3)/p(nj,5)
77028  p(nj,4)=p(nj,4)/p(nj,5)
77029  IF(abs(p(nj,4)).GT.paru(1)) p(nj,4)=p(nj,4)-sign(paru(2),
77030  & p(nj,4))
77031  DO 190 ic=n+1,nc
77032  IF(k(ic,5).LT.0) k(ic,5)=0
77033  190 CONTINUE
77034  ELSE
77035  DO 200 j=1,4
77036  p(nj,j)=0d0
77037  200 CONTINUE
77038  DO 210 ic=n+1,nc
77039  IF(k(ic,5).GE.0) goto 210
77040  p(nj,1)=p(nj,1)+p(ic,5)*cos(p(ic,2))
77041  p(nj,2)=p(nj,2)+p(ic,5)*sin(p(ic,2))
77042  p(nj,3)=p(nj,3)+p(ic,5)*sinh(p(ic,1))
77043  p(nj,4)=p(nj,4)+p(ic,5)*cosh(p(ic,1))
77044  k(ic,5)=0
77045  210 CONTINUE
77046  ENDIF
77047  goto 150
77048 
77049 C...Arrange clusters in falling ET sequence.
77050  220 DO 250 i=1,nj-nc
77051  etmax=0d0
77052  DO 230 ij=nc+1,nj
77053  IF(k(ij,5).EQ.0) goto 230
77054  IF(p(ij,5).LT.etmax) goto 230
77055  ijmax=ij
77056  etmax=p(ij,5)
77057  230 CONTINUE
77058  k(ijmax,5)=0
77059  k(n+i,1)=31
77060  k(n+i,2)=98
77061  k(n+i,3)=i
77062  k(n+i,4)=k(ijmax,4)
77063  k(n+i,5)=0
77064  DO 240 j=1,5
77065  p(n+i,j)=p(ijmax,j)
77066  v(n+i,j)=0d0
77067  240 CONTINUE
77068  250 CONTINUE
77069  njet=nj-nc
77070 
77071 C...Convert to massless or massive four-vectors.
77072  IF(mstu(54).EQ.2) THEN
77073  DO 260 i=n+1,n+njet
77074  eta=p(i,3)
77075  p(i,1)=p(i,5)*cos(p(i,4))
77076  p(i,2)=p(i,5)*sin(p(i,4))
77077  p(i,3)=p(i,5)*sinh(eta)
77078  p(i,4)=p(i,5)*cosh(eta)
77079  p(i,5)=0d0
77080  260 CONTINUE
77081  ELSEIF(mstu(54).GE.3) THEN
77082  DO 270 i=n+1,n+njet
77083  p(i,5)=sqrt(max(0d0,p(i,4)**2-p(i,1)**2-p(i,2)**2-p(i,3)**2))
77084  270 CONTINUE
77085  ENDIF
77086 
77087 C...Information about storage.
77088  mstu(61)=n+1
77089  mstu(62)=np
77090  mstu(63)=nc-n
77091  IF(mstu(43).LE.1) mstu(3)=max(0,njet)
77092  IF(mstu(43).GE.2) n=n+max(0,njet)
77093 
77094  RETURN
77095  END
77096 
77097 C*********************************************************************
77098 
77099 C...PYJMAS
77100 C...Determines, approximately, the two jet masses that minimize
77101 C...the sum m_H^2 + m_L^2, a la Clavelli and Wyler.
77102 
77103  SUBROUTINE pyjmas(PMH,PML)
77104 
77105 C...Double precision and integer declarations.
77106  IMPLICIT DOUBLE PRECISION(a-h, o-z)
77107  IMPLICIT INTEGER(i-n)
77108  INTEGER pyk,pychge,pycomp
77109 C...Parameter statement to help give large particle numbers.
77110  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
77111  &kexcit=4000000,kdimen=5000000)
77112 C...Commonblocks.
77113  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
77114  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
77115  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
77116  SAVE /pyjets/,/pydat1/,/pydat2/
77117 C...Local arrays.
77118  dimension sm(3,3),sax(3),ps(3,5)
77119 
77120 C...Reset.
77121  np=0
77122  DO 120 j1=1,3
77123  DO 100 j2=j1,3
77124  sm(j1,j2)=0d0
77125  100 CONTINUE
77126  DO 110 j2=1,4
77127  ps(j1,j2)=0d0
77128  110 CONTINUE
77129  120 CONTINUE
77130  pss=0d0
77131  pimass=pmas(pycomp(211),1)
77132 
77133 C...Take copy of particles that are to be considered in mass analysis.
77134  DO 170 i=1,n
77135  IF(k(i,1).LE.0.OR.k(i,1).GT.10) goto 170
77136  IF(mstu(41).GE.2) THEN
77137  kc=pycomp(k(i,2))
77138  IF(kc.EQ.0.OR.kc.EQ.12.OR.kc.EQ.14.OR.kc.EQ.16.OR.
77139  & kc.EQ.18.OR.k(i,2).EQ.ksusy1+22.OR.k(i,2).EQ.39.OR.
77140  & k(i,2).EQ.ksusy1+39) goto 170
77141  IF(mstu(41).GE.3.AND.kchg(kc,2).EQ.0.AND.pychge(k(i,2)).EQ.0)
77142  & goto 170
77143  ENDIF
77144  IF(n+np+1.GE.mstu(4)-mstu(32)-5) THEN
77145  CALL pyerrm(11,'(PYJMAS:) no more memory left in PYJETS')
77146  pmh=-2d0
77147  pml=-2d0
77148  RETURN
77149  ENDIF
77150  np=np+1
77151  DO 130 j=1,5
77152  p(n+np,j)=p(i,j)
77153  130 CONTINUE
77154  IF(mstu(42).EQ.0) p(n+np,5)=0d0
77155  IF(mstu(42).EQ.1.AND.k(i,2).NE.22) p(n+np,5)=pimass
77156  p(n+np,4)=sqrt(p(n+np,5)**2+p(i,1)**2+p(i,2)**2+p(i,3)**2)
77157 
77158 C...Fill information in sphericity tensor and total momentum vector.
77159  DO 150 j1=1,3
77160  DO 140 j2=j1,3
77161  sm(j1,j2)=sm(j1,j2)+p(i,j1)*p(i,j2)
77162  140 CONTINUE
77163  150 CONTINUE
77164  pss=pss+(p(i,1)**2+p(i,2)**2+p(i,3)**2)
77165  DO 160 j=1,4
77166  ps(3,j)=ps(3,j)+p(n+np,j)
77167  160 CONTINUE
77168  170 CONTINUE
77169 
77170 C...Very low multiplicities (0 or 1) not considered.
77171  IF(np.LE.1) THEN
77172  CALL pyerrm(8,'(PYJMAS:) too few particles for analysis')
77173  pmh=-1d0
77174  pml=-1d0
77175  RETURN
77176  ENDIF
77177  paru(61)=sqrt(max(0d0,ps(3,4)**2-ps(3,1)**2-ps(3,2)**2-
77178  &ps(3,3)**2))
77179 
77180 C...Find largest eigenvalue to matrix (third degree equation).
77181  DO 190 j1=1,3
77182  DO 180 j2=j1,3
77183  sm(j1,j2)=sm(j1,j2)/pss
77184  180 CONTINUE
77185  190 CONTINUE
77186  sq=(sm(1,1)*sm(2,2)+sm(1,1)*sm(3,3)+sm(2,2)*sm(3,3)-
77187  &sm(1,2)**2-sm(1,3)**2-sm(2,3)**2)/3d0-1d0/9d0
77188  sr=-0.5d0*(sq+1d0/9d0+sm(1,1)*sm(2,3)**2+sm(2,2)*sm(1,3)**2+
77189  &sm(3,3)*sm(1,2)**2-sm(1,1)*sm(2,2)*sm(3,3))+
77190  &sm(1,2)*sm(1,3)*sm(2,3)+1d0/27d0
77191  sp=cos(acos(max(min(sr/sqrt(-sq**3),1d0),-1d0))/3d0)
77192  sma=1d0/3d0+sqrt(-sq)*max(2d0*sp,sqrt(3d0*(1d0-sp**2))-sp)
77193 
77194 C...Find largest eigenvector by solving equation system.
77195  DO 210 j1=1,3
77196  sm(j1,j1)=sm(j1,j1)-sma
77197  DO 200 j2=j1+1,3
77198  sm(j2,j1)=sm(j1,j2)
77199  200 CONTINUE
77200  210 CONTINUE
77201  smax=0d0
77202  DO 230 j1=1,3
77203  DO 220 j2=1,3
77204  IF(abs(sm(j1,j2)).LE.smax) goto 220
77205  ja=j1
77206  jb=j2
77207  smax=abs(sm(j1,j2))
77208  220 CONTINUE
77209  230 CONTINUE
77210  smax=0d0
77211  DO 250 j3=ja+1,ja+2
77212  j1=j3-3*((j3-1)/3)
77213  rl=sm(j1,jb)/sm(ja,jb)
77214  DO 240 j2=1,3
77215  sm(j1,j2)=sm(j1,j2)-rl*sm(ja,j2)
77216  IF(abs(sm(j1,j2)).LE.smax) goto 240
77217  jc=j1
77218  smax=abs(sm(j1,j2))
77219  240 CONTINUE
77220  250 CONTINUE
77221  jb1=jb+1-3*(jb/3)
77222  jb2=jb+2-3*((jb+1)/3)
77223  sax(jb1)=-sm(jc,jb2)
77224  sax(jb2)=sm(jc,jb1)
77225  sax(jb)=-(sm(ja,jb1)*sax(jb1)+sm(ja,jb2)*sax(jb2))/sm(ja,jb)
77226 
77227 C...Divide particles into two initial clusters by hemisphere.
77228  DO 270 i=n+1,n+np
77229  psax=p(i,1)*sax(1)+p(i,2)*sax(2)+p(i,3)*sax(3)
77230  is=1
77231  IF(psax.LT.0d0) is=2
77232  k(i,3)=is
77233  DO 260 j=1,4
77234  ps(is,j)=ps(is,j)+p(i,j)
77235  260 CONTINUE
77236  270 CONTINUE
77237  pms=max(1d-10,ps(1,4)**2-ps(1,1)**2-ps(1,2)**2-ps(1,3)**2)+
77238  &max(1d-10,ps(2,4)**2-ps(2,1)**2-ps(2,2)**2-ps(2,3)**2)
77239 
77240 C...Reassign one particle at a time; find maximum decrease of m^2 sum.
77241  280 pmd=0d0
77242  im=0
77243  DO 290 j=1,4
77244  ps(3,j)=ps(1,j)-ps(2,j)
77245  290 CONTINUE
77246  DO 300 i=n+1,n+np
77247  pps=p(i,4)*ps(3,4)-p(i,1)*ps(3,1)-p(i,2)*ps(3,2)-p(i,3)*ps(3,3)
77248  IF(k(i,3).EQ.1) pmdi=2d0*(p(i,5)**2-pps)
77249  IF(k(i,3).EQ.2) pmdi=2d0*(p(i,5)**2+pps)
77250  IF(pmdi.LT.pmd) THEN
77251  pmd=pmdi
77252  im=i
77253  ENDIF
77254  300 CONTINUE
77255 
77256 C...Loop back if significant reduction in sum of m^2.
77257  IF(pmd.LT.-paru(48)*pms) THEN
77258  pms=pms+pmd
77259  is=k(im,3)
77260  DO 310 j=1,4
77261  ps(is,j)=ps(is,j)-p(im,j)
77262  ps(3-is,j)=ps(3-is,j)+p(im,j)
77263  310 CONTINUE
77264  k(im,3)=3-is
77265  goto 280
77266  ENDIF
77267 
77268 C...Final masses and output.
77269  mstu(61)=n+1
77270  mstu(62)=np
77271  ps(1,5)=sqrt(max(0d0,ps(1,4)**2-ps(1,1)**2-ps(1,2)**2-ps(1,3)**2))
77272  ps(2,5)=sqrt(max(0d0,ps(2,4)**2-ps(2,1)**2-ps(2,2)**2-ps(2,3)**2))
77273  pmh=max(ps(1,5),ps(2,5))
77274  pml=min(ps(1,5),ps(2,5))
77275 
77276  RETURN
77277  END
77278 
77279 C*********************************************************************
77280 
77281 C...PYFOWO
77282 C...Calculates the first few Fox-Wolfram moments.
77283 
77284  SUBROUTINE pyfowo(H10,H20,H30,H40)
77285 
77286 C...Double precision and integer declarations.
77287  IMPLICIT DOUBLE PRECISION(a-h, o-z)
77288  IMPLICIT INTEGER(i-n)
77289  INTEGER pyk,pychge,pycomp
77290 C...Parameter statement to help give large particle numbers.
77291  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
77292  &kexcit=4000000,kdimen=5000000)
77293 C...Commonblocks.
77294  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
77295  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
77296  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
77297  SAVE /pyjets/,/pydat1/,/pydat2/
77298 
77299 C...Copy momenta for particles and calculate H0.
77300  np=0
77301  h0=0d0
77302  hd=0d0
77303  DO 110 i=1,n
77304  IF(k(i,1).LE.0.OR.k(i,1).GT.10) goto 110
77305  IF(mstu(41).GE.2) THEN
77306  kc=pycomp(k(i,2))
77307  IF(kc.EQ.0.OR.kc.EQ.12.OR.kc.EQ.14.OR.kc.EQ.16.OR.
77308  & kc.EQ.18.OR.k(i,2).EQ.ksusy1+22.OR.k(i,2).EQ.39.OR.
77309  & k(i,2).EQ.ksusy1+39) goto 110
77310  IF(mstu(41).GE.3.AND.kchg(kc,2).EQ.0.AND.pychge(k(i,2)).EQ.0)
77311  & goto 110
77312  ENDIF
77313  IF(n+np.GE.mstu(4)-mstu(32)-5) THEN
77314  CALL pyerrm(11,'(PYFOWO:) no more memory left in PYJETS')
77315  h10=-1d0
77316  h20=-1d0
77317  h30=-1d0
77318  h40=-1d0
77319  RETURN
77320  ENDIF
77321  np=np+1
77322  DO 100 j=1,3
77323  p(n+np,j)=p(i,j)
77324  100 CONTINUE
77325  p(n+np,4)=sqrt(p(i,1)**2+p(i,2)**2+p(i,3)**2)
77326  h0=h0+p(n+np,4)
77327  hd=hd+p(n+np,4)**2
77328  110 CONTINUE
77329  h0=h0**2
77330 
77331 C...Very low multiplicities (0 or 1) not considered.
77332  IF(np.LE.1) THEN
77333  CALL pyerrm(8,'(PYFOWO:) too few particles for analysis')
77334  h10=-1d0
77335  h20=-1d0
77336  h30=-1d0
77337  h40=-1d0
77338  RETURN
77339  ENDIF
77340 
77341 C...Calculate H1 - H4.
77342  h10=0d0
77343  h20=0d0
77344  h30=0d0
77345  h40=0d0
77346  DO 130 i1=n+1,n+np
77347  DO 120 i2=i1+1,n+np
77348  cthe=(p(i1,1)*p(i2,1)+p(i1,2)*p(i2,2)+p(i1,3)*p(i2,3))/
77349  & (p(i1,4)*p(i2,4))
77350  h10=h10+p(i1,4)*p(i2,4)*cthe
77351  h20=h20+p(i1,4)*p(i2,4)*(1.5d0*cthe**2-0.5d0)
77352  h30=h30+p(i1,4)*p(i2,4)*(2.5d0*cthe**3-1.5d0*cthe)
77353  h40=h40+p(i1,4)*p(i2,4)*(4.375d0*cthe**4-3.75d0*cthe**2+
77354  & 0.375d0)
77355  120 CONTINUE
77356  130 CONTINUE
77357 
77358 C...Calculate H1/H0 - H4/H0. Output.
77359  mstu(61)=n+1
77360  mstu(62)=np
77361  h10=(hd+2d0*h10)/h0
77362  h20=(hd+2d0*h20)/h0
77363  h30=(hd+2d0*h30)/h0
77364  h40=(hd+2d0*h40)/h0
77365 
77366  RETURN
77367  END
77368 
77369 C*********************************************************************
77370 
77371 C...PYTABU
77372 C...Evaluates various properties of an event, with statistics
77373 C...accumulated during the course of the run and
77374 C...printed at the end.
77375 
77376  SUBROUTINE pytabu(MTABU)
77377 
77378 C...Double precision and integer declarations.
77379  IMPLICIT DOUBLE PRECISION(a-h, o-z)
77380  IMPLICIT INTEGER(i-n)
77381  INTEGER pyk,pychge,pycomp
77382 C...Parameter statement to help give large particle numbers.
77383  parameter(ksusy1=1000000,ksusy2=2000000,ktechn=3000000,
77384  &kexcit=4000000,kdimen=5000000)
77385 C...Commonblocks.
77386  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
77387  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
77388  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
77389  common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
77390  SAVE /pyjets/,/pydat1/,/pydat2/,/pydat3/
77391 C...Local arrays, character variables, saved variables and data.
77392  dimension kfis(100,2),npis(100,0:10),kffs(400),npfs(400,4),
77393  &fevfm(10,4),fm1fm(3,10,4),fm2fm(3,10,4),fmoma(4),fmoms(4),
77394  &fevee(50),fe1ec(50),fe2ec(50),fe1ea(25),fe2ea(25),
77395  &kfdm(8),kfdc(200,0:8),npdc(200)
77396  SAVE nevis,nkfis,kfis,npis,nevfs,nprfs,nfifs,nchfs,nkffs,
77397  &kffs,npfs,nevfm,nmufm,fm1fm,fm2fm,nevee,fe1ec,fe2ec,fe1ea,
77398  &fe2ea,nevdc,nkfdc,nredc,kfdc,npdc
77399  CHARACTER chau*16,chis(2)*12,chdc(8)*12
77400  DATA nevis/0/,nkfis/0/,nevfs/0/,nprfs/0/,nfifs/0/,nchfs/0/,
77401  &nkffs/0/,nevfm/0/,nmufm/0/,fm1fm/120*0d0/,fm2fm/120*0d0/,
77402  &nevee/0/,fe1ec/50*0d0/,fe2ec/50*0d0/,fe1ea/25*0d0/,fe2ea/25*0d0/,
77403  &nevdc/0/,nkfdc/0/,nredc/0/
77404 
77405 C...Reset statistics on initial parton state.
77406  IF(mtabu.EQ.10) THEN
77407  nevis=0
77408  nkfis=0
77409 
77410 C...Identify and order flavour content of initial state.
77411  ELSEIF(mtabu.EQ.11) THEN
77412  nevis=nevis+1
77413  kfm1=2*iabs(mstu(161))
77414  IF(mstu(161).GT.0) kfm1=kfm1-1
77415  kfm2=2*iabs(mstu(162))
77416  IF(mstu(162).GT.0) kfm2=kfm2-1
77417  kfmn=min(kfm1,kfm2)
77418  kfmx=max(kfm1,kfm2)
77419  DO 100 i=1,nkfis
77420  IF(kfmn.EQ.kfis(i,1).AND.kfmx.EQ.kfis(i,2)) THEN
77421  ikfis=-i
77422  goto 110
77423  ELSEIF(kfmn.LT.kfis(i,1).OR.(kfmn.EQ.kfis(i,1).AND.
77424  & kfmx.LT.kfis(i,2))) THEN
77425  ikfis=i
77426  goto 110
77427  ENDIF
77428  100 CONTINUE
77429  ikfis=nkfis+1
77430  110 IF(ikfis.LT.0) THEN
77431  ikfis=-ikfis
77432  ELSE
77433  IF(nkfis.GE.100) RETURN
77434  DO 130 i=nkfis,ikfis,-1
77435  kfis(i+1,1)=kfis(i,1)
77436  kfis(i+1,2)=kfis(i,2)
77437  DO 120 j=0,10
77438  npis(i+1,j)=npis(i,j)
77439  120 CONTINUE
77440  130 CONTINUE
77441  nkfis=nkfis+1
77442  kfis(ikfis,1)=kfmn
77443  kfis(ikfis,2)=kfmx
77444  DO 140 j=0,10
77445  npis(ikfis,j)=0
77446  140 CONTINUE
77447  ENDIF
77448  npis(ikfis,0)=npis(ikfis,0)+1
77449 
77450 C...Count number of partons in initial state.
77451  np=0
77452  DO 160 i=1,n
77453  IF(k(i,1).LE.0.OR.k(i,1).GT.12) THEN
77454  ELSEIF(iabs(k(i,2)).GT.80.AND.iabs(k(i,2)).LE.100) THEN
77455  ELSEIF(iabs(k(i,2)).GT.100.AND.mod(iabs(k(i,2))/10,10).NE.0)
77456  & THEN
77457  ELSE
77458  im=i
77459  150 im=k(im,3)
77460  IF(im.LE.0.OR.im.GT.n) THEN
77461  np=np+1
77462  ELSEIF(k(im,1).LE.0.OR.k(im,1).GT.20) THEN
77463  np=np+1
77464  ELSEIF(iabs(k(im,2)).GT.80.AND.iabs(k(im,2)).LE.100) THEN
77465  ELSEIF(iabs(k(im,2)).GT.100.AND.mod(iabs(k(im,2))/10,10)
77466  & .NE.0) THEN
77467  ELSE
77468  goto 150
77469  ENDIF
77470  ENDIF
77471  160 CONTINUE
77472  npco=max(np,1)
77473  IF(np.GE.6) npco=6
77474  IF(np.GE.8) npco=7
77475  IF(np.GE.11) npco=8
77476  IF(np.GE.16) npco=9
77477  IF(np.GE.26) npco=10
77478  npis(ikfis,npco)=npis(ikfis,npco)+1
77479  mstu(62)=np
77480 
77481 C...Write statistics on initial parton state.
77482  ELSEIF(mtabu.EQ.12) THEN
77483  fac=1d0/max(1,nevis)
77484  WRITE(mstu(11),5000) nevis
77485  DO 170 i=1,nkfis
77486  kfmn=kfis(i,1)
77487  IF(kfmn.EQ.0) kfmn=kfis(i,2)
77488  kfm1=(kfmn+1)/2
77489  IF(2*kfm1.EQ.kfmn) kfm1=-kfm1
77490  CALL pyname(kfm1,chau)
77491  chis(1)=chau(1:12)
77492  IF(chau(13:13).NE.' ') chis(1)(12:12)='?'
77493  kfmx=kfis(i,2)
77494  IF(kfis(i,1).EQ.0) kfmx=0
77495  kfm2=(kfmx+1)/2
77496  IF(2*kfm2.EQ.kfmx) kfm2=-kfm2
77497  CALL pyname(kfm2,chau)
77498  chis(2)=chau(1:12)
77499  IF(chau(13:13).NE.' ') chis(2)(12:12)='?'
77500  WRITE(mstu(11),5100) chis(1),chis(2),fac*npis(i,0),
77501  & (npis(i,j)/dble(npis(i,0)),j=1,10)
77502  170 CONTINUE
77503 
77504 C...Copy statistics on initial parton state into /PYJETS/.
77505  ELSEIF(mtabu.EQ.13) THEN
77506  fac=1d0/max(1,nevis)
77507  DO 190 i=1,nkfis
77508  kfmn=kfis(i,1)
77509  IF(kfmn.EQ.0) kfmn=kfis(i,2)
77510  kfm1=(kfmn+1)/2
77511  IF(2*kfm1.EQ.kfmn) kfm1=-kfm1
77512  kfmx=kfis(i,2)
77513  IF(kfis(i,1).EQ.0) kfmx=0
77514  kfm2=(kfmx+1)/2
77515  IF(2*kfm2.EQ.kfmx) kfm2=-kfm2
77516  k(i,1)=32
77517  k(i,2)=99
77518  k(i,3)=kfm1
77519  k(i,4)=kfm2
77520  k(i,5)=npis(i,0)
77521  DO 180 j=1,5
77522  p(i,j)=fac*npis(i,j)
77523  v(i,j)=fac*npis(i,j+5)
77524  180 CONTINUE
77525  190 CONTINUE
77526  n=nkfis
77527  DO 200 j=1,5
77528  k(n+1,j)=0
77529  p(n+1,j)=0d0
77530  v(n+1,j)=0d0
77531  200 CONTINUE
77532  k(n+1,1)=32
77533  k(n+1,2)=99
77534  k(n+1,5)=nevis
77535  mstu(3)=1
77536 
77537 C...Reset statistics on number of particles/partons.
77538  ELSEIF(mtabu.EQ.20) THEN
77539  nevfs=0
77540  nprfs=0
77541  nfifs=0
77542  nchfs=0
77543  nkffs=0
77544 
77545 C...Identify whether particle/parton is primary or not.
77546  ELSEIF(mtabu.EQ.21) THEN
77547  nevfs=nevfs+1
77548  mstu(62)=0
77549  DO 260 i=1,n
77550  IF(k(i,1).LE.0.OR.k(i,1).GT.20.OR.k(i,1).EQ.13) goto 260
77551  mstu(62)=mstu(62)+1
77552  kc=pycomp(k(i,2))
77553  mpri=0
77554  IF(k(i,3).LE.0.OR.k(i,3).GT.n) THEN
77555  mpri=1
77556  ELSEIF(k(k(i,3),1).LE.0.OR.k(k(i,3),1).GT.20) THEN
77557  mpri=1
77558  ELSEIF(k(k(i,3),2).GE.91.AND.k(k(i,3),2).LE.93) THEN
77559  mpri=1
77560  ELSEIF(kc.EQ.0) THEN
77561  ELSEIF(k(k(i,3),1).EQ.13) THEN
77562  im=k(k(i,3),3)
77563  IF(im.LE.0.OR.im.GT.n) THEN
77564  mpri=1
77565  ELSEIF(k(im,1).LE.0.OR.k(im,1).GT.20) THEN
77566  mpri=1
77567  ENDIF
77568  ELSEIF(kchg(kc,2).EQ.0) THEN
77569  kcm=pycomp(k(k(i,3),2))
77570  IF(kcm.NE.0) THEN
77571  IF(kchg(kcm,2).NE.0) mpri=1
77572  ENDIF
77573  ENDIF
77574  IF(kc.NE.0.AND.mpri.EQ.1) THEN
77575  IF(kchg(kc,2).EQ.0) nprfs=nprfs+1
77576  ENDIF
77577  IF(k(i,1).LE.10) THEN
77578  nfifs=nfifs+1
77579  IF(pychge(k(i,2)).NE.0) nchfs=nchfs+1
77580  ENDIF
77581 
77582 C...Fill statistics on number of particles/partons in event.
77583  kfa=iabs(k(i,2))
77584  kfs=3-isign(1,k(i,2))-mpri
77585  DO 210 ip=1,nkffs
77586  IF(kfa.EQ.kffs(ip)) THEN
77587  ikffs=-ip
77588  goto 220
77589  ELSEIF(kfa.LT.kffs(ip)) THEN
77590  ikffs=ip
77591  goto 220
77592  ENDIF
77593  210 CONTINUE
77594  ikffs=nkffs+1
77595  220 IF(ikffs.LT.0) THEN
77596  ikffs=-ikffs
77597  ELSE
77598  IF(nkffs.GE.400) RETURN
77599  DO 240 ip=nkffs,ikffs,-1
77600  kffs(ip+1)=kffs(ip)
77601  DO 230 j=1,4
77602  npfs(ip+1,j)=npfs(ip,j)
77603  230 CONTINUE
77604  240 CONTINUE
77605  nkffs=nkffs+1
77606  kffs(ikffs)=kfa
77607  DO 250 j=1,4
77608  npfs(ikffs,j)=0
77609  250 CONTINUE
77610  ENDIF
77611  npfs(ikffs,kfs)=npfs(ikffs,kfs)+1
77612  260 CONTINUE
77613 
77614 C...Write statistics on particle/parton composition of events.
77615  ELSEIF(mtabu.EQ.22) THEN
77616  fac=1d0/max(1,nevfs)
77617  WRITE(mstu(11),5200) nevfs,fac*nprfs,fac*nfifs,fac*nchfs
77618  DO 270 i=1,nkffs
77619  CALL pyname(kffs(i),chau)
77620  kc=pycomp(kffs(i))
77621  mdcyf=0
77622  IF(kc.NE.0) mdcyf=mdcy(kc,1)
77623  WRITE(mstu(11),5300) kffs(i),chau,mdcyf,(fac*npfs(i,j),j=1,4),
77624  & fac*(npfs(i,1)+npfs(i,2)+npfs(i,3)+npfs(i,4))
77625  270 CONTINUE
77626 
77627 C...Copy particle/parton composition information into /PYJETS/.
77628  ELSEIF(mtabu.EQ.23) THEN
77629  fac=1d0/max(1,nevfs)
77630  DO 290 i=1,nkffs
77631  k(i,1)=32
77632  k(i,2)=99
77633  k(i,3)=kffs(i)
77634  k(i,4)=0
77635  k(i,5)=npfs(i,1)+npfs(i,2)+npfs(i,3)+npfs(i,4)
77636  DO 280 j=1,4
77637  p(i,j)=fac*npfs(i,j)
77638  v(i,j)=0d0
77639  280 CONTINUE
77640  p(i,5)=fac*k(i,5)
77641  v(i,5)=0d0
77642  290 CONTINUE
77643  n=nkffs
77644  DO 300 j=1,5
77645  k(n+1,j)=0
77646  p(n+1,j)=0d0
77647  v(n+1,j)=0d0
77648  300 CONTINUE
77649  k(n+1,1)=32
77650  k(n+1,2)=99
77651  k(n+1,5)=nevfs
77652  p(n+1,1)=fac*nprfs
77653  p(n+1,2)=fac*nfifs
77654  p(n+1,3)=fac*nchfs
77655  mstu(3)=1
77656 
77657 C...Reset factorial moments statistics.
77658  ELSEIF(mtabu.EQ.30) THEN
77659  nevfm=0
77660  nmufm=0
77661  DO 330 im=1,3
77662  DO 320 ib=1,10
77663  DO 310 ip=1,4
77664  fm1fm(im,ib,ip)=0d0
77665  fm2fm(im,ib,ip)=0d0
77666  310 CONTINUE
77667  320 CONTINUE
77668  330 CONTINUE
77669 
77670 C...Find particles to include, with (pion,pseudo)rapidity and azimuth.
77671  ELSEIF(mtabu.EQ.31) THEN
77672  nevfm=nevfm+1
77673  nlow=n+mstu(3)
77674  nupp=nlow
77675  DO 410 i=1,n
77676  IF(k(i,1).LE.0.OR.k(i,1).GT.10) goto 410
77677  IF(mstu(41).GE.2) THEN
77678  kc=pycomp(k(i,2))
77679  IF(kc.EQ.0.OR.kc.EQ.12.OR.kc.EQ.14.OR.kc.EQ.16.OR.
77680  & kc.EQ.18.OR.k(i,2).EQ.ksusy1+22.OR.k(i,2).EQ.39.OR.
77681  & k(i,2).EQ.ksusy1+39) goto 410
77682  IF(mstu(41).GE.3.AND.kchg(kc,2).EQ.0.AND.
77683  & pychge(k(i,2)).EQ.0) goto 410
77684  ENDIF
77685  pmr=0d0
77686  IF(mstu(42).EQ.1.AND.k(i,2).NE.22) pmr=pymass(211)
77687  IF(mstu(42).GE.2) pmr=p(i,5)
77688  pr=max(1d-20,pmr**2+p(i,1)**2+p(i,2)**2)
77689  yeta=sign(log(min((sqrt(pr+p(i,3)**2)+abs(p(i,3)))/sqrt(pr),
77690  & 1d20)),p(i,3))
77691  IF(abs(yeta).GT.paru(57)) goto 410
77692  phi=pyangl(p(i,1),p(i,2))
77693  iyeta=512d0*(yeta+paru(57))/(2d0*paru(57))
77694  iyeta=max(0,min(511,iyeta))
77695  iphi=512d0*(phi+paru(1))/paru(2)
77696  iphi=max(0,min(511,iphi))
77697  iyep=0
77698  DO 340 ib=0,9
77699  iyep=iyep+4**ib*(2*mod(iyeta/2**ib,2)+mod(iphi/2**ib,2))
77700  340 CONTINUE
77701 
77702 C...Order particles in (pseudo)rapidity and/or azimuth.
77703  IF(nupp.GT.mstu(4)-5-mstu(32)) THEN
77704  CALL pyerrm(11,'(PYTABU:) no more memory left in PYJETS')
77705  RETURN
77706  ENDIF
77707  nupp=nupp+1
77708  IF(nupp.EQ.nlow+1) THEN
77709  k(nupp,1)=iyeta
77710  k(nupp,2)=iphi
77711  k(nupp,3)=iyep
77712  ELSE
77713  DO 350 i1=nupp-1,nlow+1,-1
77714  IF(iyeta.GE.k(i1,1)) goto 360
77715  k(i1+1,1)=k(i1,1)
77716  350 CONTINUE
77717  360 k(i1+1,1)=iyeta
77718  DO 370 i1=nupp-1,nlow+1,-1
77719  IF(iphi.GE.k(i1,2)) goto 380
77720  k(i1+1,2)=k(i1,2)
77721  370 CONTINUE
77722  380 k(i1+1,2)=iphi
77723  DO 390 i1=nupp-1,nlow+1,-1
77724  IF(iyep.GE.k(i1,3)) goto 400
77725  k(i1+1,3)=k(i1,3)
77726  390 CONTINUE
77727  400 k(i1+1,3)=iyep
77728  ENDIF
77729  410 CONTINUE
77730  k(nupp+1,1)=2**10
77731  k(nupp+1,2)=2**10
77732  k(nupp+1,3)=4**10
77733 
77734 C...Calculate sum of factorial moments in event.
77735  DO 480 im=1,3
77736  DO 430 ib=1,10
77737  DO 420 ip=1,4
77738  fevfm(ib,ip)=0d0
77739  420 CONTINUE
77740  430 CONTINUE
77741  DO 450 ib=1,10
77742  IF(im.LE.2) ibin=2**(10-ib)
77743  IF(im.EQ.3) ibin=4**(10-ib)
77744  iagr=k(nlow+1,im)/ibin
77745  nagr=1
77746  DO 440 i=nlow+2,nupp+1
77747  icut=k(i,im)/ibin
77748  IF(icut.EQ.iagr) THEN
77749  nagr=nagr+1
77750  ELSE
77751  IF(nagr.EQ.1) THEN
77752  ELSEIF(nagr.EQ.2) THEN
77753  fevfm(ib,1)=fevfm(ib,1)+2d0
77754  ELSEIF(nagr.EQ.3) THEN
77755  fevfm(ib,1)=fevfm(ib,1)+6d0
77756  fevfm(ib,2)=fevfm(ib,2)+6d0
77757  ELSEIF(nagr.EQ.4) THEN
77758  fevfm(ib,1)=fevfm(ib,1)+12d0
77759  fevfm(ib,2)=fevfm(ib,2)+24d0
77760  fevfm(ib,3)=fevfm(ib,3)+24d0
77761  ELSE
77762  fevfm(ib,1)=fevfm(ib,1)+nagr*(nagr-1d0)
77763  fevfm(ib,2)=fevfm(ib,2)+nagr*(nagr-1d0)*(nagr-2d0)
77764  fevfm(ib,3)=fevfm(ib,3)+nagr*(nagr-1d0)*(nagr-2d0)*
77765  & (nagr-3d0)
77766  fevfm(ib,4)=fevfm(ib,4)+nagr*(nagr-1d0)*(nagr-2d0)*
77767  & (nagr-3d0)*(nagr-4d0)
77768  ENDIF
77769  iagr=icut
77770  nagr=1
77771  ENDIF
77772  440 CONTINUE
77773  450 CONTINUE
77774 
77775 C...Add results to total statistics.
77776  DO 470 ib=10,1,-1
77777  DO 460 ip=1,4
77778  IF(fevfm(1,ip).LT.0.5d0) THEN
77779  fevfm(ib,ip)=0d0
77780  ELSEIF(im.LE.2) THEN
77781  fevfm(ib,ip)=2d0**((ib-1)*ip)*fevfm(ib,ip)/fevfm(1,ip)
77782  ELSE
77783  fevfm(ib,ip)=4d0**((ib-1)*ip)*fevfm(ib,ip)/fevfm(1,ip)
77784  ENDIF
77785  fm1fm(im,ib,ip)=fm1fm(im,ib,ip)+fevfm(ib,ip)
77786  fm2fm(im,ib,ip)=fm2fm(im,ib,ip)+fevfm(ib,ip)**2
77787  460 CONTINUE
77788  470 CONTINUE
77789  480 CONTINUE
77790  nmufm=nmufm+(nupp-nlow)
77791  mstu(62)=nupp-nlow
77792 
77793 C...Write accumulated statistics on factorial moments.
77794  ELSEIF(mtabu.EQ.32) THEN
77795  fac=1d0/max(1,nevfm)
77796  IF(mstu(42).LE.0) WRITE(mstu(11),5400) nevfm,'eta'
77797  IF(mstu(42).EQ.1) WRITE(mstu(11),5400) nevfm,'ypi'
77798  IF(mstu(42).GE.2) WRITE(mstu(11),5400) nevfm,'y '
77799  DO 510 im=1,3
77800  WRITE(mstu(11),5500)
77801  DO 500 ib=1,10
77802  byeta=2d0*paru(57)
77803  IF(im.NE.2) byeta=byeta/2**(ib-1)
77804  bphi=paru(2)
77805  IF(im.NE.1) bphi=bphi/2**(ib-1)
77806  IF(im.LE.2) bnave=fac*nmufm/dble(2**(ib-1))
77807  IF(im.EQ.3) bnave=fac*nmufm/dble(4**(ib-1))
77808  DO 490 ip=1,4
77809  fmoma(ip)=fac*fm1fm(im,ib,ip)
77810  fmoms(ip)=sqrt(max(0d0,fac*(fac*fm2fm(im,ib,ip)-
77811  & fmoma(ip)**2)))
77812  490 CONTINUE
77813  WRITE(mstu(11),5600) byeta,bphi,bnave,(fmoma(ip),fmoms(ip),
77814  & ip=1,4)
77815  500 CONTINUE
77816  510 CONTINUE
77817 
77818 C...Copy statistics on factorial moments into /PYJETS/.
77819  ELSEIF(mtabu.EQ.33) THEN
77820  fac=1d0/max(1,nevfm)
77821  DO 540 im=1,3
77822  DO 530 ib=1,10
77823  i=10*(im-1)+ib
77824  k(i,1)=32
77825  k(i,2)=99
77826  k(i,3)=1
77827  IF(im.NE.2) k(i,3)=2**(ib-1)
77828  k(i,4)=1
77829  IF(im.NE.1) k(i,4)=2**(ib-1)
77830  k(i,5)=0
77831  p(i,1)=2d0*paru(57)/k(i,3)
77832  v(i,1)=paru(2)/k(i,4)
77833  DO 520 ip=1,4
77834  p(i,ip+1)=fac*fm1fm(im,ib,ip)
77835  v(i,ip+1)=sqrt(max(0d0,fac*(fac*fm2fm(im,ib,ip)-
77836  & p(i,ip+1)**2)))
77837  520 CONTINUE
77838  530 CONTINUE
77839  540 CONTINUE
77840  n=30
77841  DO 550 j=1,5
77842  k(n+1,j)=0
77843  p(n+1,j)=0d0
77844  v(n+1,j)=0d0
77845  550 CONTINUE
77846  k(n+1,1)=32
77847  k(n+1,2)=99
77848  k(n+1,5)=nevfm
77849  mstu(3)=1
77850 
77851 C...Reset statistics on Energy-Energy Correlation.
77852  ELSEIF(mtabu.EQ.40) THEN
77853  nevee=0
77854  DO 560 j=1,25
77855  fe1ec(j)=0d0
77856  fe2ec(j)=0d0
77857  fe1ec(51-j)=0d0
77858  fe2ec(51-j)=0d0
77859  fe1ea(j)=0d0
77860  fe2ea(j)=0d0
77861  560 CONTINUE
77862 
77863 C...Find particles to include, with proper assumed mass.
77864  ELSEIF(mtabu.EQ.41) THEN
77865  nevee=nevee+1
77866  nlow=n+mstu(3)
77867  nupp=nlow
77868  ecm=0d0
77869  DO 570 i=1,n
77870  IF(k(i,1).LE.0.OR.k(i,1).GT.10) goto 570
77871  IF(mstu(41).GE.2) THEN
77872  kc=pycomp(k(i,2))
77873  IF(kc.EQ.0.OR.kc.EQ.12.OR.kc.EQ.14.OR.kc.EQ.16.OR.
77874  & kc.EQ.18.OR.k(i,2).EQ.ksusy1+22.OR.k(i,2).EQ.39.OR.
77875  & k(i,2).EQ.ksusy1+39) goto 570
77876  IF(mstu(41).GE.3.AND.kchg(kc,2).EQ.0.AND.
77877  & pychge(k(i,2)).EQ.0) goto 570
77878  ENDIF
77879  pmr=0d0
77880  IF(mstu(42).EQ.1.AND.k(i,2).NE.22) pmr=pymass(211)
77881  IF(mstu(42).GE.2) pmr=p(i,5)
77882  IF(nupp.GT.mstu(4)-5-mstu(32)) THEN
77883  CALL pyerrm(11,'(PYTABU:) no more memory left in PYJETS')
77884  RETURN
77885  ENDIF
77886  nupp=nupp+1
77887  p(nupp,1)=p(i,1)
77888  p(nupp,2)=p(i,2)
77889  p(nupp,3)=p(i,3)
77890  p(nupp,4)=sqrt(pmr**2+p(i,1)**2+p(i,2)**2+p(i,3)**2)
77891  p(nupp,5)=max(1d-10,sqrt(p(i,1)**2+p(i,2)**2+p(i,3)**2))
77892  ecm=ecm+p(nupp,4)
77893  570 CONTINUE
77894  IF(nupp.EQ.nlow) RETURN
77895 
77896 C...Analyze Energy-Energy Correlation in event.
77897  fac=(2d0/ecm**2)*50d0/paru(1)
77898  DO 580 j=1,50
77899  fevee(j)=0d0
77900  580 CONTINUE
77901  DO 600 i1=nlow+2,nupp
77902  DO 590 i2=nlow+1,i1-1
77903  cthe=(p(i1,1)*p(i2,1)+p(i1,2)*p(i2,2)+p(i1,3)*p(i2,3))/
77904  & (p(i1,5)*p(i2,5))
77905  the=acos(max(-1d0,min(1d0,cthe)))
77906  ithe=max(1,min(50,1+int(50d0*the/paru(1))))
77907  fevee(ithe)=fevee(ithe)+fac*p(i1,4)*p(i2,4)
77908  590 CONTINUE
77909  600 CONTINUE
77910  DO 610 j=1,25
77911  fe1ec(j)=fe1ec(j)+fevee(j)
77912  fe2ec(j)=fe2ec(j)+fevee(j)**2
77913  fe1ec(51-j)=fe1ec(51-j)+fevee(51-j)
77914  fe2ec(51-j)=fe2ec(51-j)+fevee(51-j)**2
77915  fe1ea(j)=fe1ea(j)+(fevee(51-j)-fevee(j))
77916  fe2ea(j)=fe2ea(j)+(fevee(51-j)-fevee(j))**2
77917  610 CONTINUE
77918  mstu(62)=nupp-nlow
77919 
77920 C...Write statistics on Energy-Energy Correlation.
77921  ELSEIF(mtabu.EQ.42) THEN
77922  fac=1d0/max(1,nevee)
77923  WRITE(mstu(11),5700) nevee
77924  DO 620 j=1,25
77925  feec1=fac*fe1ec(j)
77926  fees1=sqrt(max(0d0,fac*(fac*fe2ec(j)-feec1**2)))
77927  feec2=fac*fe1ec(51-j)
77928  fees2=sqrt(max(0d0,fac*(fac*fe2ec(51-j)-feec2**2)))
77929  feeca=fac*fe1ea(j)
77930  feesa=sqrt(max(0d0,fac*(fac*fe2ea(j)-feeca**2)))
77931  WRITE(mstu(11),5800) 3.6d0*(j-1),3.6d0*j,feec1,fees1,
77932  & feec2,fees2,feeca,feesa
77933  620 CONTINUE
77934 
77935 C...Copy statistics on Energy-Energy Correlation into /PYJETS/.
77936  ELSEIF(mtabu.EQ.43) THEN
77937  fac=1d0/max(1,nevee)
77938  DO 630 i=1,25
77939  k(i,1)=32
77940  k(i,2)=99
77941  k(i,3)=0
77942  k(i,4)=0
77943  k(i,5)=0
77944  p(i,1)=fac*fe1ec(i)
77945  v(i,1)=sqrt(max(0d0,fac*(fac*fe2ec(i)-p(i,1)**2)))
77946  p(i,2)=fac*fe1ec(51-i)
77947  v(i,2)=sqrt(max(0d0,fac*(fac*fe2ec(51-i)-p(i,2)**2)))
77948  p(i,3)=fac*fe1ea(i)
77949  v(i,3)=sqrt(max(0d0,fac*(fac*fe2ea(i)-p(i,3)**2)))
77950  p(i,4)=paru(1)*(i-1)/50d0
77951  p(i,5)=paru(1)*i/50d0
77952  v(i,4)=3.6d0*(i-1)
77953  v(i,5)=3.6d0*i
77954  630 CONTINUE
77955  n=25
77956  DO 640 j=1,5
77957  k(n+1,j)=0
77958  p(n+1,j)=0d0
77959  v(n+1,j)=0d0
77960  640 CONTINUE
77961  k(n+1,1)=32
77962  k(n+1,2)=99
77963  k(n+1,5)=nevee
77964  mstu(3)=1
77965 
77966 C...Reset statistics on decay channels.
77967  ELSEIF(mtabu.EQ.50) THEN
77968  nevdc=0
77969  nkfdc=0
77970  nredc=0
77971 
77972 C...Identify and order flavour content of final state.
77973  ELSEIF(mtabu.EQ.51) THEN
77974  nevdc=nevdc+1
77975  nds=0
77976  DO 670 i=1,n
77977  IF(k(i,1).LE.0.OR.k(i,1).GE.6) goto 670
77978  nds=nds+1
77979  IF(nds.GT.8) THEN
77980  nredc=nredc+1
77981  RETURN
77982  ENDIF
77983  kfm=2*iabs(k(i,2))
77984  IF(k(i,2).LT.0) kfm=kfm-1
77985  DO 650 ids=nds-1,1,-1
77986  iin=ids+1
77987  IF(kfm.LT.kfdm(ids)) goto 660
77988  kfdm(ids+1)=kfdm(ids)
77989  650 CONTINUE
77990  iin=1
77991  660 kfdm(iin)=kfm
77992  670 CONTINUE
77993 
77994 C...Find whether old or new final state.
77995  DO 690 idc=1,nkfdc
77996  IF(nds.LT.kfdc(idc,0)) THEN
77997  ikfdc=idc
77998  goto 700
77999  ELSEIF(nds.EQ.kfdc(idc,0)) THEN
78000  DO 680 i=1,nds
78001  IF(kfdm(i).LT.kfdc(idc,i)) THEN
78002  ikfdc=idc
78003  goto 700
78004  ELSEIF(kfdm(i).GT.kfdc(idc,i)) THEN
78005  goto 690
78006  ENDIF
78007  680 CONTINUE
78008  ikfdc=-idc
78009  goto 700
78010  ENDIF
78011  690 CONTINUE
78012  ikfdc=nkfdc+1
78013  700 IF(ikfdc.LT.0) THEN
78014  ikfdc=-ikfdc
78015  ELSEIF(nkfdc.GE.200) THEN
78016  nredc=nredc+1
78017  RETURN
78018  ELSE
78019  DO 720 idc=nkfdc,ikfdc,-1
78020  npdc(idc+1)=npdc(idc)
78021  DO 710 i=0,8
78022  kfdc(idc+1,i)=kfdc(idc,i)
78023  710 CONTINUE
78024  720 CONTINUE
78025  nkfdc=nkfdc+1
78026  kfdc(ikfdc,0)=nds
78027  DO 730 i=1,nds
78028  kfdc(ikfdc,i)=kfdm(i)
78029  730 CONTINUE
78030  npdc(ikfdc)=0
78031  ENDIF
78032  npdc(ikfdc)=npdc(ikfdc)+1
78033 
78034 C...Write statistics on decay channels.
78035  ELSEIF(mtabu.EQ.52) THEN
78036  fac=1d0/max(1,nevdc)
78037  WRITE(mstu(11),5900) nevdc
78038  DO 750 idc=1,nkfdc
78039  DO 740 i=1,kfdc(idc,0)
78040  kfm=kfdc(idc,i)
78041  kf=(kfm+1)/2
78042  IF(2*kf.NE.kfm) kf=-kf
78043  CALL pyname(kf,chau)
78044  chdc(i)=chau(1:12)
78045  IF(chau(13:13).NE.' ') chdc(i)(12:12)='?'
78046  740 CONTINUE
78047  WRITE(mstu(11),6000) fac*npdc(idc),(chdc(i),i=1,kfdc(idc,0))
78048  750 CONTINUE
78049  IF(nredc.NE.0) WRITE(mstu(11),6100) fac*nredc
78050 
78051 C...Copy statistics on decay channels into /PYJETS/.
78052  ELSEIF(mtabu.EQ.53) THEN
78053  fac=1d0/max(1,nevdc)
78054  DO 780 idc=1,nkfdc
78055  k(idc,1)=32
78056  k(idc,2)=99
78057  k(idc,3)=0
78058  k(idc,4)=0
78059  k(idc,5)=kfdc(idc,0)
78060  DO 760 j=1,5
78061  p(idc,j)=0d0
78062  v(idc,j)=0d0
78063  760 CONTINUE
78064  DO 770 i=1,kfdc(idc,0)
78065  kfm=kfdc(idc,i)
78066  kf=(kfm+1)/2
78067  IF(2*kf.NE.kfm) kf=-kf
78068  IF(i.LE.5) p(idc,i)=kf
78069  IF(i.GE.6) v(idc,i-5)=kf
78070  770 CONTINUE
78071  v(idc,5)=fac*npdc(idc)
78072  780 CONTINUE
78073  n=nkfdc
78074  DO 790 j=1,5
78075  k(n+1,j)=0
78076  p(n+1,j)=0d0
78077  v(n+1,j)=0d0
78078  790 CONTINUE
78079  k(n+1,1)=32
78080  k(n+1,2)=99
78081  k(n+1,5)=nevdc
78082  v(n+1,5)=fac*nredc
78083  mstu(3)=1
78084  ENDIF
78085 
78086 C...Format statements for output on unit MSTU(11) (default 6).
78087  5000 FORMAT(///20x,'Event statistics - initial state'/
78088  &20x,'based on an analysis of ',i6,' events'//
78089  &3x,'Main flavours after',8x,'Fraction',4x,'Subfractions ',
78090  &'according to fragmenting system multiplicity'/
78091  &4x,'hard interaction',24x,'1',7x,'2',7x,'3',7x,'4',7x,'5',
78092  &6x,'6-7',5x,'8-10',3x,'11-15',3x,'16-25',4x,'>25'/)
78093  5100 FORMAT(3x,a12,1x,a12,f10.5,1x,10f8.4)
78094  5200 FORMAT(///20x,'Event statistics - final state'/
78095  &20x,'based on an analysis of ',i7,' events'//
78096  &5x,'Mean primary multiplicity =',f10.4/
78097  &5x,'Mean final multiplicity =',f10.4/
78098  &5x,'Mean charged multiplicity =',f10.4//
78099  &5x,'Number of particles produced per event (directly and via ',
78100  &'decays/branchings)'/
78101  &8x,'KF Particle/jet MDCY',10x,'Particles',13x,'Antiparticles',
78102  &8x,'Total'/35x,'prim seco prim seco'/)
78103  5300 FORMAT(1x,i9,4x,a16,i2,5(1x,f11.6))
78104  5400 FORMAT(///20x,'Factorial moments analysis of multiplicity'/
78105  &20x,'based on an analysis of ',i6,' events'//
78106  &3x,'delta-',a3,' delta-phi <n>/bin',10x,'<F2>',18x,'<F3>',
78107  &18x,'<F4>',18x,'<F5>'/35x,4(' value error '))
78108  5500 FORMAT(10x)
78109  5600 FORMAT(2x,2f10.4,f12.4,4(f12.4,f10.4))
78110  5700 FORMAT(///20x,'Energy-Energy Correlation and Asymmetry'/
78111  &20x,'based on an analysis of ',i6,' events'//
78112  &2x,'theta range',8x,'EEC(theta)',8x,'EEC(180-theta)',7x,
78113  &'EECA(theta)'/2x,'in degrees ',3(' value error')/)
78114  5800 FORMAT(2x,f4.1,' - ',f4.1,3(f11.4,f9.4))
78115  5900 FORMAT(///20x,'Decay channel analysis - final state'/
78116  &20x,'based on an analysis of ',i6,' events'//
78117  &2x,'Probability',10x,'Complete final state'/)
78118  6000 FORMAT(2x,f9.5,5x,8(a12,1x))
78119  6100 FORMAT(2x,f9.5,5x,'into other channels (more than 8 particles ',
78120  &'or table overflow)')
78121 
78122  RETURN
78123  END
78124 
78125 C*********************************************************************
78126 
78127 C...PYEEVT
78128 C...Handles the generation of an e+e- annihilation jet event.
78129 
78130  SUBROUTINE pyeevt(KFL,ECM)
78131 
78132 C...Double precision and integer declarations.
78133  IMPLICIT DOUBLE PRECISION(a-h, o-z)
78134  IMPLICIT INTEGER(i-n)
78135  INTEGER pyk,pychge,pycomp
78136 C...Commonblocks.
78137  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
78138  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
78139  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
78140  SAVE /pyjets/,/pydat1/,/pydat2/
78141 
78142 C...Check input parameters.
78143  IF(mstu(12).NE.12345) CALL pylist(0)
78144  IF(kfl.LT.0.OR.kfl.GT.8) THEN
78145  CALL pyerrm(16,'(PYEEVT:) called with unknown flavour code')
78146  IF(mstu(21).GE.1) RETURN
78147  ENDIF
78148  IF(kfl.LE.5) ecmmin=parj(127)+2.02d0*parf(100+max(1,kfl))
78149  IF(kfl.GE.6) ecmmin=parj(127)+2.02d0*pmas(kfl,1)
78150  IF(ecm.LT.ecmmin) THEN
78151  CALL pyerrm(16,'(PYEEVT:) called with too small CM energy')
78152  IF(mstu(21).GE.1) RETURN
78153  ENDIF
78154 
78155 C...Check consistency of MSTJ options set.
78156  IF(mstj(109).EQ.2.AND.mstj(110).NE.1) THEN
78157  CALL pyerrm(6,
78158  & '(PYEEVT:) MSTJ(109) value requires MSTJ(110) = 1')
78159  mstj(110)=1
78160  ENDIF
78161  IF(mstj(109).EQ.2.AND.mstj(111).NE.0) THEN
78162  CALL pyerrm(6,
78163  & '(PYEEVT:) MSTJ(109) value requires MSTJ(111) = 0')
78164  mstj(111)=0
78165  ENDIF
78166 
78167 C...Initialize alpha_strong and total cross-section.
78168  mstu(111)=mstj(108)
78169  IF(mstj(108).EQ.2.AND.(mstj(101).EQ.0.OR.mstj(101).EQ.1))
78170  &mstu(111)=1
78171  paru(112)=parj(121)
78172  IF(mstu(111).EQ.2) paru(112)=parj(122)
78173  IF(mstj(116).GT.0.AND.(mstj(116).GE.2.OR.abs(ecm-parj(151)).GE.
78174  &parj(139).OR.10*mstj(102)+kfl.NE.mstj(119))) CALL pyxtee(kfl,ecm,
78175  &xtot)
78176  IF(mstj(116).GE.3) mstj(116)=1
78177  parj(171)=0d0
78178 
78179 C...Add initial e+e- to event record (documentation only).
78180  ntry=0
78181  100 ntry=ntry+1
78182  IF(ntry.GT.100) THEN
78183  CALL pyerrm(14,'(PYEEVT:) caught in an infinite loop')
78184  RETURN
78185  ENDIF
78186  mstu(24)=0
78187  nc=0
78188  IF(mstj(115).GE.2) THEN
78189  nc=nc+2
78190  CALL py1ent(nc-1,11,0.5d0*ecm,0d0,0d0)
78191  k(nc-1,1)=21
78192  CALL py1ent(nc,-11,0.5d0*ecm,paru(1),0d0)
78193  k(nc,1)=21
78194  ENDIF
78195 
78196 C...Radiative photon (in initial state).
78197  mk=0
78198  ecmc=ecm
78199  IF(mstj(107).GE.1.AND.mstj(116).GE.1) CALL pyradk(ecm,mk,pak,
78200  &thek,phik,alpk)
78201  IF(mk.EQ.1) ecmc=sqrt(ecm*(ecm-2d0*pak))
78202  IF(mstj(115).GE.1.AND.mk.EQ.1) THEN
78203  nc=nc+1
78204  CALL py1ent(nc,22,pak,thek,phik)
78205  k(nc,3)=min(mstj(115)/2,1)
78206  ENDIF
78207 
78208 C...Virtual exchange boson (gamma or Z0).
78209  IF(mstj(115).GE.3) THEN
78210  nc=nc+1
78211  kf=22
78212  IF(mstj(102).EQ.2) kf=23
78213  mstu10=mstu(10)
78214  mstu(10)=1
78215  p(nc,5)=ecmc
78216  CALL py1ent(nc,kf,ecmc,0d0,0d0)
78217  k(nc,1)=21
78218  k(nc,3)=1
78219  mstu(10)=mstu10
78220  ENDIF
78221 
78222 C...Choice of flavour and jet configuration.
78223  CALL pyxkfl(kfl,ecm,ecmc,kflc)
78224  IF(kflc.EQ.0) goto 100
78225  CALL pyxjet(ecmc,njet,cut)
78226  kfln=21
78227  IF(njet.EQ.4) CALL pyx4jt(njet,cut,kflc,ecmc,kfln,x1,x2,x4,
78228  &x12,x14)
78229  IF(njet.EQ.3) CALL pyx3jt(njet,cut,kflc,ecmc,x1,x3)
78230  IF(njet.EQ.2) mstj(120)=1
78231 
78232 C...Fill jet configuration and origin.
78233  IF(njet.EQ.2.AND.mstj(101).NE.5) CALL py2ent(nc+1,kflc,-kflc,ecmc)
78234  IF(njet.EQ.2.AND.mstj(101).EQ.5) CALL py2ent(-(nc+1),kflc,-kflc,
78235  &ecmc)
78236  IF(njet.EQ.3) CALL py3ent(nc+1,kflc,21,-kflc,ecmc,x1,x3)
78237  IF(njet.EQ.4.AND.kfln.EQ.21) CALL py4ent(nc+1,kflc,kfln,kfln,
78238  &-kflc,ecmc,x1,x2,x4,x12,x14)
78239  IF(njet.EQ.4.AND.kfln.NE.21) CALL py4ent(nc+1,kflc,-kfln,kfln,
78240  &-kflc,ecmc,x1,x2,x4,x12,x14)
78241  IF(mstu(24).NE.0) goto 100
78242  DO 110 ip=nc+1,n
78243  k(ip,3)=k(ip,3)+min(mstj(115)/2,1)+(mstj(115)/3)*(nc-1)
78244  110 CONTINUE
78245 
78246 C...Angular orientation according to matrix element.
78247  IF(mstj(106).EQ.1) THEN
78248  CALL pyxdif(nc,njet,kflc,ecmc,chi,the,phi)
78249  CALL pyrobo(nc+1,n,0d0,chi,0d0,0d0,0d0)
78250  CALL pyrobo(nc+1,n,the,phi,0d0,0d0,0d0)
78251  ENDIF
78252 
78253 C...Rotation and boost from radiative photon.
78254  IF(mk.EQ.1) THEN
78255  dbek=-pak/(ecm-pak)
78256  nmin=nc+1-mstj(115)/3
78257  CALL pyrobo(nmin,n,0d0,-phik,0d0,0d0,0d0)
78258  CALL pyrobo(nmin,n,alpk,0d0,dbek*sin(thek),0d0,dbek*cos(thek))
78259  CALL pyrobo(nmin,n,0d0,phik,0d0,0d0,0d0)
78260  ENDIF
78261 
78262 C...Generate parton shower. Rearrange along strings and check.
78263  IF(mstj(101).EQ.5) THEN
78264  CALL pyshow(n-1,n,ecmc)
78265  mstj14=mstj(14)
78266  IF(mstj(105).EQ.-1) mstj(14)=-1
78267  IF(mstj(105).GE.0) mstu(28)=0
78268  CALL pyprep(0)
78269  mstj(14)=mstj14
78270  IF(mstj(105).GE.0.AND.mstu(28).NE.0) goto 100
78271  ENDIF
78272 
78273 C...Fragmentation/decay generation. Information for PYTABU.
78274  IF(mstj(105).EQ.1) CALL pyexec
78275  mstu(161)=kflc
78276  mstu(162)=-kflc
78277 
78278  RETURN
78279  END
78280 
78281 C*********************************************************************
78282 
78283 C...PYXTEE
78284 C...Calculates total cross-section, including initial state
78285 C...radiation effects.
78286 
78287  SUBROUTINE pyxtee(KFL,ECM,XTOT)
78288 
78289 C...Double precision and integer declarations.
78290  IMPLICIT DOUBLE PRECISION(a-h, o-z)
78291  IMPLICIT INTEGER(i-n)
78292  INTEGER pyk,pychge,pycomp
78293 C...Commonblocks.
78294  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
78295  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
78296  SAVE /pydat1/,/pydat2/
78297 
78298 C...Status, (optimized) Q^2 scale, alpha_strong.
78299  parj(151)=ecm
78300  mstj(119)=10*mstj(102)+kfl
78301  IF(mstj(111).EQ.0) THEN
78302  q2r=ecm**2
78303  ELSEIF(mstu(111).EQ.0) THEN
78304  parj(168)=min(1d0,max(parj(128),exp(-12d0*paru(1)/
78305  & ((33d0-2d0*mstu(112))*paru(111)))))
78306  q2r=parj(168)*ecm**2
78307  ELSE
78308  parj(168)=min(1d0,max(parj(128),paru(112)/ecm,
78309  & (2d0*paru(112)/ecm)**2))
78310  q2r=parj(168)*ecm**2
78311  ENDIF
78312  alspi=pyalps(q2r)/paru(1)
78313 
78314 C...QCD corrections factor in R.
78315  IF(mstj(101).EQ.0.OR.mstj(109).EQ.1) THEN
78316  rqcd=1d0
78317  ELSEIF(iabs(mstj(101)).EQ.1.AND.mstj(109).EQ.0) THEN
78318  rqcd=1d0+alspi
78319  ELSEIF(mstj(109).EQ.0) THEN
78320  rqcd=1d0+alspi+(1.986d0-0.115d0*mstu(118))*alspi**2
78321  IF(mstj(111).EQ.1) rqcd=max(1d0,rqcd+(33d0-2d0*mstu(112))/12d0*
78322  & log(parj(168))*alspi**2)
78323  ELSEIF(iabs(mstj(101)).EQ.1) THEN
78324  rqcd=1d0+(3d0/4d0)*alspi
78325  ELSE
78326  rqcd=1d0+(3d0/4d0)*alspi-(3d0/32d0+0.519d0*mstu(118))*alspi**2
78327  ENDIF
78328 
78329 C...Calculate Z0 width if default value not acceptable.
78330  IF(mstj(102).GE.3) THEN
78331  rva=3d0*(3d0+(4d0*paru(102)-1d0)**2)+6d0*rqcd*(2d0+
78332  & (1d0-8d0*paru(102)/3d0)**2+(4d0*paru(102)/3d0-1d0)**2)
78333  DO 100 kflc=5,6
78334  vq=1d0
78335  IF(mod(mstj(103),2).EQ.1) vq=sqrt(max(0d0,1d0-
78336  & (2d0*pymass(kflc)/ ecm)**2))
78337  IF(kflc.EQ.5) vf=4d0*paru(102)/3d0-1d0
78338  IF(kflc.EQ.6) vf=1d0-8d0*paru(102)/3d0
78339  rva=rva+3d0*rqcd*(0.5d0*vq*(3d0-vq**2)*vf**2+vq**3)
78340  100 CONTINUE
78341  parj(124)=paru(101)*parj(123)*rva/(48d0*paru(102)*
78342  & (1d0-paru(102)))
78343  ENDIF
78344 
78345 C...Calculate propagator and related constants for QFD case.
78346  poll=1d0-parj(131)*parj(132)
78347  IF(mstj(102).GE.2) THEN
78348  sff=1d0/(16d0*paru(102)*(1d0-paru(102)))
78349  sfw=ecm**4/((ecm**2-parj(123)**2)**2+(parj(123)*parj(124))**2)
78350  sfi=sfw*(1d0-(parj(123)/ecm)**2)
78351  ve=4d0*paru(102)-1d0
78352  sf1i=sff*(ve*poll+parj(132)-parj(131))
78353  sf1w=sff**2*((ve**2+1d0)*poll+2d0*ve*(parj(132)-parj(131)))
78354  hf1i=sfi*sf1i
78355  hf1w=sfw*sf1w
78356  ENDIF
78357 
78358 C...Loop over different flavours: charge, velocity.
78359  rtot=0d0
78360  rqq=0d0
78361  rqv=0d0
78362  rva=0d0
78363  DO 110 kflc=1,max(mstj(104),kfl)
78364  IF(kfl.GT.0.AND.kflc.NE.kfl) goto 110
78365  mstj(93)=1
78366  pmq=pymass(kflc)
78367  IF(ecm.LT.2d0*pmq+parj(127)) goto 110
78368  qf=kchg(kflc,1)/3d0
78369  vq=1d0
78370  IF(mod(mstj(103),2).EQ.1) vq=sqrt(1d0-(2d0*pmq/ecm)**2)
78371 
78372 C...Calculate R and sum of charges for QED or QFD case.
78373  rqq=rqq+3d0*qf**2*poll
78374  IF(mstj(102).LE.1) THEN
78375  rtot=rtot+3d0*0.5d0*vq*(3d0-vq**2)*qf**2*poll
78376  ELSE
78377  vf=sign(1d0,qf)-4d0*qf*paru(102)
78378  rqv=rqv-6d0*qf*vf*sf1i
78379  rva=rva+3d0*(vf**2+1d0)*sf1w
78380  rtot=rtot+3d0*(0.5d0*vq*(3d0-vq**2)*(qf**2*poll-
78381  & 2d0*qf*vf*hf1i+vf**2*hf1w)+vq**3*hf1w)
78382  ENDIF
78383  110 CONTINUE
78384  rsum=rqq
78385  IF(mstj(102).GE.2) rsum=rqq+sfi*rqv+sfw*rva
78386 
78387 C...Calculate cross-section, including QCD corrections.
78388  parj(141)=rqq
78389  parj(142)=rtot
78390  parj(143)=rtot*rqcd
78391  parj(144)=parj(143)
78392  parj(145)=parj(141)*86.8d0/ecm**2
78393  parj(146)=parj(142)*86.8d0/ecm**2
78394  parj(147)=parj(143)*86.8d0/ecm**2
78395  parj(148)=parj(147)
78396  parj(157)=rsum*rqcd
78397  parj(158)=0d0
78398  parj(159)=0d0
78399  xtot=parj(147)
78400  IF(mstj(107).LE.0) RETURN
78401 
78402 C...Virtual cross-section.
78403  xkl=parj(135)
78404  xku=min(parj(136),1d0-(2d0*parj(127)/ecm)**2)
78405  ale=2d0*log(ecm/pymass(11))-1d0
78406  sigv=ale/3d0+2d0*log(ecm**2/(pymass(13)*pymass(15)))/3d0-4d0/3d0+
78407  &1.526d0*log(ecm**2/0.932d0)
78408 
78409 C...Soft and hard radiative cross-section in QED case.
78410  IF(mstj(102).LE.1) THEN
78411  sigv=1.5d0*ale-0.5d0+paru(1)**2/3d0+2d0*sigv
78412  sigs=ale*(2d0*log(xkl)-log(1d0-xkl)-xkl)
78413  sigh=ale*(2d0*log(xku/xkl)-log((1d0-xku)/(1d0-xkl))-(xku-xkl))
78414 
78415 C...Soft and hard radiative cross-section in QFD case.
78416  ELSE
78417  szm=1d0-(parj(123)/ecm)**2
78418  szw=parj(123)*parj(124)/ecm**2
78419  parj(161)=-rqq/rsum
78420  parj(162)=-(rqq+rqv+rva)/rsum
78421  parj(163)=(rqv*(1d0-0.5d0*szm-sfi)+rva*(1.5d0-szm-sfw))/rsum
78422  parj(164)=(rqv*szw**2*(1d0-2d0*sfw)+rva*(2d0*sfi+szw**2-
78423  & 4d0+3d0*szm-szm**2))/(szw*rsum)
78424  sigv=1.5d0*ale-0.5d0+paru(1)**2/3d0+((2d0*rqq+sfi*rqv)/
78425  & rsum)*sigv+(szw*sfw*rqv/rsum)*paru(1)*20d0/9d0
78426  sigs=ale*(2d0*log(xkl)+parj(161)*log(1d0-xkl)+parj(162)*xkl+
78427  & parj(163)*log(((xkl-szm)**2+szw**2)/(szm**2+szw**2))+
78428  & parj(164)*(atan((xkl-szm)/szw)-atan(-szm/szw)))
78429  sigh=ale*(2d0*log(xku/xkl)+parj(161)*log((1d0-xku)/
78430  & (1d0-xkl))+parj(162)*(xku-xkl)+parj(163)*
78431  & log(((xku-szm)**2+szw**2)/((xkl-szm)**2+szw**2))+
78432  & parj(164)*(atan((xku-szm)/szw)-atan((xkl-szm)/szw)))
78433  ENDIF
78434 
78435 C...Total cross-section and fraction of hard photon events.
78436  parj(160)=sigh/(paru(1)/paru(101)+sigv+sigs+sigh)
78437  parj(157)=rsum*(1d0+(paru(101)/paru(1))*(sigv+sigs+sigh))*rqcd
78438  parj(144)=parj(157)
78439  parj(148)=parj(144)*86.8d0/ecm**2
78440  xtot=parj(148)
78441 
78442  RETURN
78443  END
78444 
78445 C*********************************************************************
78446 
78447 C...PYRADK
78448 C...Generates initial state photon radiation.
78449 
78450  SUBROUTINE pyradk(ECM,MK,PAK,THEK,PHIK,ALPK)
78451 
78452 C...Double precision and integer declarations.
78453  IMPLICIT DOUBLE PRECISION(a-h, o-z)
78454  IMPLICIT INTEGER(i-n)
78455  INTEGER pyk,pychge,pycomp
78456 C...Commonblocks.
78457  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
78458  SAVE /pydat1/
78459 
78460 C...Function: cumulative hard photon spectrum in QFD case.
78461  fxk(xx)=2d0*log(xx)+parj(161)*log(1d0-xx)+parj(162)*xx+
78462  &parj(163)*log((xx-szm)**2+szw**2)+parj(164)*atan((xx-szm)/szw)
78463 
78464 C...Determine whether radiative photon or not.
78465  mk=0
78466  pak=0d0
78467  IF(parj(160).LT.pyr(0)) RETURN
78468  mk=1
78469 
78470 C...Photon energy range. Find photon momentum in QED case.
78471  xkl=parj(135)
78472  xku=min(parj(136),1d0-(2d0*parj(127)/ecm)**2)
78473  IF(mstj(102).LE.1) THEN
78474  100 xk=1d0/(1d0+(1d0/xkl-1d0)*((1d0/xku-1d0)/(1d0/xkl-1d0))**pyr(0))
78475  IF(1d0+(1d0-xk)**2.LT.2d0*pyr(0)) goto 100
78476 
78477 C...Ditto in QFD case, by numerical inversion of integrated spectrum.
78478  ELSE
78479  szm=1d0-(parj(123)/ecm)**2
78480  szw=parj(123)*parj(124)/ecm**2
78481  fxkl=fxk(xkl)
78482  fxku=fxk(xku)
78483  fxkd=1d-4*(fxku-fxkl)
78484  fxkr=fxkl+pyr(0)*(fxku-fxkl)
78485  nxk=0
78486  110 nxk=nxk+1
78487  xk=0.5d0*(xkl+xku)
78488  fxkv=fxk(xk)
78489  IF(fxkv.GT.fxkr) THEN
78490  xku=xk
78491  fxku=fxkv
78492  ELSE
78493  xkl=xk
78494  fxkl=fxkv
78495  ENDIF
78496  IF(nxk.LT.15.AND.fxku-fxkl.GT.fxkd) goto 110
78497  xk=xkl+(xku-xkl)*(fxkr-fxkl)/(fxku-fxkl)
78498  ENDIF
78499  pak=0.5d0*ecm*xk
78500 
78501 C...Photon polar and azimuthal angle.
78502  pme=2d0*(pymass(11)/ecm)**2
78503  120 cthm=pme*(2d0/pme)**pyr(0)
78504  IF(1d0-(xk**2*cthm*(1d0-0.5d0*cthm)+2d0*(1d0-xk)*pme/max(pme,
78505  &cthm*(1d0-0.5d0*cthm)))/(1d0+(1d0-xk)**2).LT.pyr(0)) goto 120
78506  cthe=1d0-cthm
78507  IF(pyr(0).GT.0.5d0) cthe=-cthe
78508  sthe=sqrt(max(0d0,(cthm-pme)*(2d0-cthm)))
78509  thek=pyangl(cthe,sthe)
78510  phik=paru(2)*pyr(0)
78511 
78512 C...Rotation angle for hadronic system.
78513  sgn=1d0
78514  IF(0.5d0*(2d0-xk*(1d0-cthe))**2/((2d0-xk)**2+(xk*cthe)**2).GT.
78515  &pyr(0)) sgn=-1d0
78516  alpk=asin(sgn*sthe*(xk-sgn*(2d0*sqrt(1d0-xk)-2d0+xk)*cthe)/
78517  &(2d0-xk*(1d0-sgn*cthe)))
78518 
78519  RETURN
78520  END
78521 
78522 C*********************************************************************
78523 
78524 C...PYXKFL
78525 C...Selects flavour for produced qqbar pair.
78526 
78527  SUBROUTINE pyxkfl(KFL,ECM,ECMC,KFLC)
78528 
78529 C...Double precision and integer declarations.
78530  IMPLICIT DOUBLE PRECISION(a-h, o-z)
78531  IMPLICIT INTEGER(i-n)
78532  INTEGER pyk,pychge,pycomp
78533 C...Commonblocks.
78534  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
78535  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
78536  SAVE /pydat1/,/pydat2/
78537 
78538 C...Calculate maximum weight in QED or QFD case.
78539  IF(mstj(102).LE.1) THEN
78540  rfmax=4d0/9d0
78541  ELSE
78542  poll=1d0-parj(131)*parj(132)
78543  sff=1d0/(16d0*paru(102)*(1d0-paru(102)))
78544  sfw=ecmc**4/((ecmc**2-parj(123)**2)**2+(parj(123)*parj(124))**2)
78545  sfi=sfw*(1d0-(parj(123)/ecmc)**2)
78546  ve=4d0*paru(102)-1d0
78547  hf1i=sfi*sff*(ve*poll+parj(132)-parj(131))
78548  hf1w=sfw*sff**2*((ve**2+1d0)*poll+2d0*ve*(parj(132)-parj(131)))
78549  rfmax=max(4d0/9d0*poll-4d0/3d0*(1d0-8d0*paru(102)/3d0)*hf1i+
78550  & ((1d0-8d0*paru(102)/3d0)**2+1d0)*hf1w,1d0/9d0*poll+2d0/3d0*
78551  & (-1d0+4d0*paru(102)/3d0)*hf1i+((-1d0+4d0*paru(102)/3d0)**2+
78552  & 1d0)*hf1w)
78553  ENDIF
78554 
78555 C...Choose flavour. Gives charge and velocity.
78556  ntry=0
78557  100 ntry=ntry+1
78558  IF(ntry.GT.100) THEN
78559  CALL pyerrm(14,'(PYXKFL:) caught in an infinite loop')
78560  kflc=0
78561  RETURN
78562  ENDIF
78563  kflc=kfl
78564  IF(kfl.LE.0) kflc=1+int(mstj(104)*pyr(0))
78565  mstj(93)=1
78566  pmq=pymass(kflc)
78567  IF(ecm.LT.2d0*pmq+parj(127)) goto 100
78568  qf=kchg(kflc,1)/3d0
78569  vq=1d0
78570  IF(mod(mstj(103),2).EQ.1) vq=sqrt(max(0d0,1d0-(2d0*pmq/ecmc)**2))
78571 
78572 C...Calculate weight in QED or QFD case.
78573  IF(mstj(102).LE.1) THEN
78574  rf=qf**2
78575  rfv=0.5d0*vq*(3d0-vq**2)*qf**2
78576  ELSE
78577  vf=sign(1d0,qf)-4d0*qf*paru(102)
78578  rf=qf**2*poll-2d0*qf*vf*hf1i+(vf**2+1d0)*hf1w
78579  rfv=0.5d0*vq*(3d0-vq**2)*(qf**2*poll-2d0*qf*vf*hf1i+vf**2*hf1w)+
78580  & vq**3*hf1w
78581  IF(rfv.GT.0d0) parj(171)=min(1d0,vq**3*hf1w/rfv)
78582  ENDIF
78583 
78584 C...Weighting or new event (radiative photon). Cross-section update.
78585  IF(kfl.LE.0.AND.rf.LT.pyr(0)*rfmax) goto 100
78586  parj(158)=parj(158)+1d0
78587  IF(ecmc.LT.2d0*pmq+parj(127).OR.rfv.LT.pyr(0)*rf) kflc=0
78588  IF(mstj(107).LE.0.AND.kflc.EQ.0) goto 100
78589  IF(kflc.NE.0) parj(159)=parj(159)+1d0
78590  parj(144)=parj(157)*parj(159)/parj(158)
78591  parj(148)=parj(144)*86.8d0/ecm**2
78592 
78593  RETURN
78594  END
78595 
78596 C*********************************************************************
78597 
78598 C...PYXJET
78599 C...Selects number of jets in matrix element approach.
78600 
78601  SUBROUTINE pyxjet(ECM,NJET,CUT)
78602 
78603 C...Double precision and integer declarations.
78604  IMPLICIT DOUBLE PRECISION(a-h, o-z)
78605  IMPLICIT INTEGER(i-n)
78606  INTEGER pyk,pychge,pycomp
78607 C...Commonblocks.
78608  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
78609  SAVE /pydat1/
78610 C...Local array and data.
78611  dimension zhut(5)
78612  DATA zhut/3.0922d0, 6.2291d0, 7.4782d0, 7.8440d0, 8.2560d0/
78613 
78614 C...Trivial result for two-jets only, including parton shower.
78615  IF(mstj(101).EQ.0.OR.mstj(101).EQ.5) THEN
78616  cut=0d0
78617 
78618 C...QCD and Abelian vector gluon theory: Q^2 for jet rate and R.
78619  ELSEIF(mstj(109).EQ.0.OR.mstj(109).EQ.2) THEN
78620  cf=4d0/3d0
78621  IF(mstj(109).EQ.2) cf=1d0
78622  IF(mstj(111).EQ.0) THEN
78623  q2=ecm**2
78624  q2r=ecm**2
78625  ELSEIF(mstu(111).EQ.0) THEN
78626  parj(169)=min(1d0,parj(129))
78627  q2=parj(169)*ecm**2
78628  parj(168)=min(1d0,max(parj(128),exp(-12d0*paru(1)/
78629  & ((33d0-2d0*mstu(112))*paru(111)))))
78630  q2r=parj(168)*ecm**2
78631  ELSE
78632  parj(169)=min(1d0,max(parj(129),(2d0*paru(112)/ecm)**2))
78633  q2=parj(169)*ecm**2
78634  parj(168)=min(1d0,max(parj(128),paru(112)/ecm,
78635  & (2d0*paru(112)/ecm)**2))
78636  q2r=parj(168)*ecm**2
78637  ENDIF
78638 
78639 C...alpha_strong for R and R itself.
78640  alspi=(3d0/4d0)*cf*pyalps(q2r)/paru(1)
78641  IF(iabs(mstj(101)).EQ.1) THEN
78642  rqcd=1d0+alspi
78643  ELSEIF(mstj(109).EQ.0) THEN
78644  rqcd=1d0+alspi+(1.986d0-0.115d0*mstu(118))*alspi**2
78645  IF(mstj(111).EQ.1) rqcd=max(1d0,rqcd+
78646  & (33d0-2d0*mstu(112))/12d0*log(parj(168))*alspi**2)
78647  ELSE
78648  rqcd=1d0+alspi-(3d0/32d0+0.519d0*mstu(118))*(4d0*alspi/3d0)**2
78649  ENDIF
78650 
78651 C...alpha_strong for jet rate. Initial value for y cut.
78652  alspi=(3d0/4d0)*cf*pyalps(q2)/paru(1)
78653  cut=max(0.001d0,parj(125),(parj(126)/ecm)**2)
78654  IF(iabs(mstj(101)).LE.1.OR.(mstj(109).EQ.0.AND.mstj(111).EQ.0))
78655  & cut=max(cut,exp(-sqrt(0.75d0/alspi))/2d0)
78656  IF(mstj(110).EQ.2) cut=max(0.01d0,min(0.05d0,cut))
78657 
78658 C...Parametrization of first order three-jet cross-section.
78659  100 IF(mstj(101).EQ.0.OR.cut.GE.0.25d0) THEN
78660  parj(152)=0d0
78661  ELSE
78662  parj(152)=(2d0*alspi/3d0)*((3d0-6d0*cut+2d0*log(cut))*
78663  & log(cut/(1d0-2d0*cut))+(2.5d0+1.5d0*cut-6.571d0)*
78664  & (1d0-3d0*cut)+5.833d0*(1d0-3d0*cut)**2-3.894d0*
78665  & (1d0-3d0*cut)**3+1.342d0*(1d0-3d0*cut)**4)/rqcd
78666  IF(mstj(109).EQ.2.AND.(mstj(101).EQ.2.OR.mstj(101).LE.-2))
78667  & parj(152)=0d0
78668  ENDIF
78669 
78670 C...Parametrization of second order three-jet cross-section.
78671  IF(iabs(mstj(101)).LE.1.OR.mstj(101).EQ.3.OR.mstj(109).EQ.2.OR.
78672  & cut.GE.0.25d0) THEN
78673  parj(153)=0d0
78674  ELSEIF(mstj(110).LE.1) THEN
78675  ct=log(1d0/cut-2d0)
78676  parj(153)=alspi**2*ct**2*(2.419d0+0.5989d0*ct+0.6782d0*ct**2-
78677  & 0.2661d0*ct**3+0.01159d0*ct**4)/rqcd
78678 
78679 C...Interpolation in second/first order ratio for Zhu parametrization.
78680  ELSEIF(mstj(110).EQ.2) THEN
78681  iza=0
78682  DO 110 iy=1,5
78683  IF(abs(cut-0.01d0*iy).LT.0.0001d0) iza=iy
78684  110 CONTINUE
78685  IF(iza.NE.0) THEN
78686  zhurat=zhut(iza)
78687  ELSE
78688  iz=100d0*cut
78689  zhurat=zhut(iz)+(100d0*cut-iz)*(zhut(iz+1)-zhut(iz))
78690  ENDIF
78691  parj(153)=alspi*parj(152)*zhurat
78692  ENDIF
78693 
78694 C...Shift in second order three-jet cross-section with optimized Q^2.
78695  IF(mstj(111).EQ.1.AND.iabs(mstj(101)).GE.2.AND.mstj(101).NE.3
78696  & .AND.cut.LT.0.25d0) parj(153)=parj(153)+
78697  & (33d0-2d0*mstu(112))/12d0*log(parj(169))*alspi*parj(152)
78698 
78699 C...Parametrization of second order four-jet cross-section.
78700  IF(iabs(mstj(101)).LE.1.OR.cut.GE.0.125d0) THEN
78701  parj(154)=0d0
78702  ELSE
78703  ct=log(1d0/cut-5d0)
78704  IF(cut.LE.0.018d0) THEN
78705  xqqgg=6.349d0-4.330d0*ct+0.8304d0*ct**2
78706  IF(mstj(109).EQ.2) xqqgg=(4d0/3d0)**2*(3.035d0-2.091d0*ct+
78707  & 0.4059d0*ct**2)
78708  xqqqq=1.25d0*(-0.1080d0+0.01486d0*ct+0.009364d0*ct**2)
78709  IF(mstj(109).EQ.2) xqqqq=8d0*xqqqq
78710  ELSE
78711  xqqgg=-0.09773d0+0.2959d0*ct-0.2764d0*ct**2+0.08832d0*ct**3
78712  IF(mstj(109).EQ.2) xqqgg=(4d0/3d0)**2*(-0.04079d0+
78713  & 0.1340d0*ct-0.1326d0*ct**2+0.04365d0*ct**3)
78714  xqqqq=1.25d0*(0.003661d0-0.004888d0*ct-0.001081d0*ct**2+
78715  & 0.002093d0*ct**3)
78716  IF(mstj(109).EQ.2) xqqqq=8d0*xqqqq
78717  ENDIF
78718  parj(154)=alspi**2*ct**2*(xqqgg+xqqqq)/rqcd
78719  parj(155)=xqqqq/(xqqgg+xqqqq)
78720  ENDIF
78721 
78722 C...If negative three-jet rate, change y' optimization parameter.
78723  IF(mstj(111).EQ.1.AND.parj(152)+parj(153).LT.0d0.AND.
78724  & parj(169).LT.0.99d0) THEN
78725  parj(169)=min(1d0,1.2d0*parj(169))
78726  q2=parj(169)*ecm**2
78727  alspi=(3d0/4d0)*cf*pyalps(q2)/paru(1)
78728  goto 100
78729  ENDIF
78730 
78731 C...If too high cross-section, use harder cuts, or fail.
78732  IF(parj(152)+parj(153)+parj(154).GE.1) THEN
78733  IF(mstj(110).EQ.2.AND.cut.GT.0.0499d0.AND.mstj(111).EQ.1.AND.
78734  & parj(169).LT.0.99d0) THEN
78735  parj(169)=min(1d0,1.2d0*parj(169))
78736  q2=parj(169)*ecm**2
78737  alspi=(3d0/4d0)*cf*pyalps(q2)/paru(1)
78738  goto 100
78739  ELSEIF(mstj(110).EQ.2.AND.cut.GT.0.0499d0) THEN
78740  CALL pyerrm(26,
78741  & '(PYXJET:) no allowed y cut value for Zhu parametrization')
78742  ENDIF
78743  cut=0.26d0*(4d0*cut)**(parj(152)+parj(153)+
78744  & parj(154))**(-1d0/3d0)
78745  IF(mstj(110).EQ.2) cut=max(0.01d0,min(0.05d0,cut))
78746  goto 100
78747  ENDIF
78748 
78749 C...Scalar gluon (first order only).
78750  ELSE
78751  alspi=pyalps(ecm**2)/paru(1)
78752  cut=max(0.001d0,parj(125),(parj(126)/ecm)**2,exp(-3d0/alspi))
78753  parj(152)=0d0
78754  IF(cut.LT.0.25d0) parj(152)=(alspi/3d0)*((1d0-2d0*cut)*
78755  & log((1d0-2d0*cut)/cut)+0.5d0*(9d0*cut**2-1d0))
78756  parj(153)=0d0
78757  parj(154)=0d0
78758  ENDIF
78759 
78760 C...Select number of jets.
78761  parj(150)=cut
78762  IF(mstj(101).EQ.0.OR.mstj(101).EQ.5) THEN
78763  njet=2
78764  ELSEIF(mstj(101).LE.0) THEN
78765  njet=min(4,2-mstj(101))
78766  ELSE
78767  rnj=pyr(0)
78768  njet=2
78769  IF(parj(152)+parj(153)+parj(154).GT.rnj) njet=3
78770  IF(parj(154).GT.rnj) njet=4
78771  ENDIF
78772 
78773  RETURN
78774  END
78775 
78776 C*********************************************************************
78777 
78778 C...PYX3JT
78779 C...Selects the kinematical variables of three-jet events.
78780 
78781  SUBROUTINE pyx3jt(NJET,CUT,KFL,ECM,X1,X2)
78782 
78783 C...Double precision and integer declarations.
78784  IMPLICIT DOUBLE PRECISION(a-h, o-z)
78785  IMPLICIT INTEGER(i-n)
78786  INTEGER pyk,pychge,pycomp
78787 C...Commonblocks.
78788  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
78789  SAVE /pydat1/
78790 C...Local array.
78791  dimension zhup(5,12)
78792 
78793 C...Coefficients of Zhu second order parametrization.
78794  DATA ((zhup(ic1,ic2),ic2=1,12),ic1=1,5)/
78795  &18.29d0, 89.56d0, 4.541d0, -52.09d0, -109.8d0, 24.90d0,
78796  &11.63d0, 3.683d0, 17.50d0,0.002440d0, -1.362d0,-0.3537d0,
78797  &11.42d0, 6.299d0, -22.55d0, -8.915d0, 59.25d0, -5.855d0,
78798  &-32.85d0, -1.054d0, -16.90d0,0.006489d0,-0.8156d0,0.01095d0,
78799  &7.847d0, -3.964d0, -35.83d0, 1.178d0, 29.39d0, 0.2806d0,
78800  &47.82d0, -12.36d0, -56.72d0, 0.04054d0,-0.4365d0, 0.6062d0,
78801  &5.441d0, -56.89d0, -50.27d0, 15.13d0, 114.3d0, -18.19d0,
78802  &97.05d0, -1.890d0, -139.9d0, 0.08153d0,-0.4984d0, 0.9439d0,
78803  &-17.65d0, 51.44d0, -58.32d0, 70.95d0, -255.7d0, -78.99d0,
78804  &476.9d0, 29.65d0, -239.3d0, 0.4745d0, -1.174d0, 6.081d0/
78805 
78806 C...Dilogarithm of x for x<0.5 (x>0.5 obtained by analytic trick).
78807  dilog(x)=x+x**2/4d0+x**3/9d0+x**4/16d0+x**5/25d0+x**6/36d0+
78808  &x**7/49d0
78809 
78810 C...Event type. Mass effect factors and other common constants.
78811  mstj(120)=2
78812  mstj(121)=0
78813  pmq=pymass(kfl)
78814  qme=(2d0*pmq/ecm)**2
78815  IF(mstj(109).NE.1) THEN
78816  cutl=log(cut)
78817  cutd=log(1d0/cut-2d0)
78818  IF(mstj(109).EQ.0) THEN
78819  cf=4d0/3d0
78820  cn=3d0
78821  tr=2d0
78822  wtmx=min(20d0,37d0-6d0*cutd)
78823  IF(mstj(110).EQ.2) wtmx=2d0*(7.5d0+80d0*cut)
78824  ELSE
78825  cf=1d0
78826  cn=0d0
78827  tr=12d0
78828  wtmx=0d0
78829  ENDIF
78830 
78831 C...Alpha_strong and effects of optimized Q^2 scale. Maximum weight.
78832  als2pi=paru(118)/paru(2)
78833  wtopt=0d0
78834  IF(mstj(111).EQ.1) wtopt=(33d0-2d0*mstu(112))/6d0*
78835  & log(parj(169))*als2pi
78836  wtmax=max(0d0,1d0+wtopt+als2pi*wtmx)
78837 
78838 C...Choose three-jet events in allowed region.
78839  100 njet=3
78840  110 y13l=cutl+cutd*pyr(0)
78841  y23l=cutl+cutd*pyr(0)
78842  y13=exp(y13l)
78843  y23=exp(y23l)
78844  y12=1d0-y13-y23
78845  IF(y12.LE.cut) goto 110
78846  IF(y13**2+y23**2+2d0*y12.LE.2d0*pyr(0)) goto 110
78847 
78848 C...Second order corrections.
78849  IF(mstj(101).EQ.2.AND.mstj(110).LE.1) THEN
78850  y12l=log(y12)
78851  y13m=log(1d0-y13)
78852  y23m=log(1d0-y23)
78853  y12m=log(1d0-y12)
78854  IF(y13.LE.0.5d0) y13i=dilog(y13)
78855  IF(y13.GE.0.5d0) y13i=1.644934d0-y13l*y13m-dilog(1d0-y13)
78856  IF(y23.LE.0.5d0) y23i=dilog(y23)
78857  IF(y23.GE.0.5d0) y23i=1.644934d0-y23l*y23m-dilog(1d0-y23)
78858  IF(y12.LE.0.5d0) y12i=dilog(y12)
78859  IF(y12.GE.0.5d0) y12i=1.644934d0-y12l*y12m-dilog(1d0-y12)
78860  wt1=(y13**2+y23**2+2d0*y12)/(y13*y23)
78861  wt2=cf*(-2d0*(cutl-y12l)**2-3d0*cutl-1d0+3.289868d0+
78862  & 2d0*(2d0*cutl-y12l)*cut/y12)+
78863  & cn*((cutl-y12l)**2-(cutl-y13l)**2-(cutl-y23l)**2-
78864  & 11d0*cutl/6d0+67d0/18d0+1.644934d0-(2d0*cutl-y12l)*cut/y12+
78865  & (2d0*cutl-y13l)*cut/y13+(2d0*cutl-y23l)*cut/y23)+
78866  & tr*(2d0*cutl/3d0-10d0/9d0)+
78867  & cf*(y12/(y12+y13)+y12/(y12+y23)+(y12+y23)/y13+(y12+y13)/y23+
78868  & y13l*(4d0*y12**2+2d0*y12*y13+4d0*y12*y23+y13*y23)/
78869  & (y12+y23)**2+y23l*(4d0*y12**2+2d0*y12*y23+4d0*y12*y13+
78870  & y13*y23)/(y12+y13)**2)/wt1+
78871  & cn*(y13l*y13/(y12+y23)+y23l*y23/(y12+y13))/wt1+(cn-2d0*cf)*
78872  & ((y12**2+(y12+y13)**2)*(y12l*y23l-y12l*y12m-y23l*
78873  & y23m+1.644934d0-y12i-y23i)/(y13*y23)+(y12**2+(y12+y23)**2)*
78874  & (y12l*y13l-y12l*y12m-y13l*y13m+1.644934d0-y12i-y13i)/
78875  & (y13*y23)+(y13**2+y23**2)/(y13*y23*(y13+y23))-
78876  & 2d0*y12l*y12**2/(y13+y23)**2-4d0*y12l*y12/(y13+y23))/wt1-
78877  & cn*(y13l*y23l-y13l*y13m-y23l*y23m+1.644934d0-y13i-y23i)
78878  IF(1d0+wtopt+als2pi*wt2.LE.0d0) mstj(121)=1
78879  IF(1d0+wtopt+als2pi*wt2.LE.wtmax*pyr(0)) goto 110
78880  parj(156)=(wtopt+als2pi*wt2)/(1d0+wtopt+als2pi*wt2)
78881 
78882  ELSEIF(mstj(101).EQ.2.AND.mstj(110).EQ.2) THEN
78883 C...Second order corrections; Zhu parametrization of ERT.
78884  zx=(y23-y13)**2
78885  zy=1d0-y12
78886  iza=0
78887  DO 120 iy=1,5
78888  IF(abs(cut-0.01d0*iy).LT.0.0001d0) iza=iy
78889  120 CONTINUE
78890  IF(iza.NE.0) THEN
78891  iz=iza
78892  wt2=zhup(iz,1)+zhup(iz,2)*zx+zhup(iz,3)*zx**2+(zhup(iz,4)+
78893  & zhup(iz,5)*zx)*zy+(zhup(iz,6)+zhup(iz,7)*zx)*zy**2+
78894  & (zhup(iz,8)+zhup(iz,9)*zx)*zy**3+zhup(iz,10)/(zx-zy**2)+
78895  & zhup(iz,11)/(1d0-zy)+zhup(iz,12)/zy
78896  ELSE
78897  iz=100d0*cut
78898  wtl=zhup(iz,1)+zhup(iz,2)*zx+zhup(iz,3)*zx**2+(zhup(iz,4)+
78899  & zhup(iz,5)*zx)*zy+(zhup(iz,6)+zhup(iz,7)*zx)*zy**2+
78900  & (zhup(iz,8)+zhup(iz,9)*zx)*zy**3+zhup(iz,10)/(zx-zy**2)+
78901  & zhup(iz,11)/(1d0-zy)+zhup(iz,12)/zy
78902  iz=iz+1
78903  wtu=zhup(iz,1)+zhup(iz,2)*zx+zhup(iz,3)*zx**2+(zhup(iz,4)+
78904  & zhup(iz,5)*zx)*zy+(zhup(iz,6)+zhup(iz,7)*zx)*zy**2+
78905  & (zhup(iz,8)+zhup(iz,9)*zx)*zy**3+zhup(iz,10)/(zx-zy**2)+
78906  & zhup(iz,11)/(1d0-zy)+zhup(iz,12)/zy
78907  wt2=wtl+(wtu-wtl)*(100d0*cut+1d0-iz)
78908  ENDIF
78909  IF(1d0+wtopt+2d0*als2pi*wt2.LE.0d0) mstj(121)=1
78910  IF(1d0+wtopt+2d0*als2pi*wt2.LE.wtmax*pyr(0)) goto 110
78911  parj(156)=(wtopt+2d0*als2pi*wt2)/(1d0+wtopt+2d0*als2pi*wt2)
78912  ENDIF
78913 
78914 C...Impose mass cuts (gives two jets). For fixed jet number new try.
78915  x1=1d0-y23
78916  x2=1d0-y13
78917  x3=1d0-y12
78918  IF(4d0*y23*y13*y12/x3**2.LE.qme) njet=2
78919  IF(mod(mstj(103),4).GE.2.AND.iabs(mstj(101)).LE.1.AND.qme*x3+
78920  & 0.5d0*qme**2+(0.5d0*qme+0.25d0*qme**2)*((1d0-x2)/(1d0-x1)+
78921  & (1d0-x1)/(1d0-x2)).GT.(x1**2+x2**2)*pyr(0)) njet=2
78922  IF(mstj(101).EQ.-1.AND.njet.EQ.2) goto 100
78923 
78924 C...Scalar gluon model (first order only, no mass effects).
78925  ELSE
78926  130 njet=3
78927  140 x3=sqrt(4d0*cut**2+pyr(0)*((1d0-cut)**2-4d0*cut**2))
78928  IF(log((x3-cut)/cut).LE.pyr(0)*log((1d0-2d0*cut)/cut)) goto 140
78929  yd=sign(2d0*cut*((x3-cut)/cut)**pyr(0)-x3,pyr(0)-0.5d0)
78930  x1=1d0-0.5d0*(x3+yd)
78931  x2=1d0-0.5d0*(x3-yd)
78932  IF(4d0*(1d0-x1)*(1d0-x2)*(1d0-x3)/x3**2.LE.qme) njet=2
78933  IF(mstj(102).GE.2) THEN
78934  IF(x3**2-2d0*(1d0+x3)*(1d0-x1)*(1d0-x2)*parj(171).LT.
78935  & x3**2*pyr(0)) njet=2
78936  ENDIF
78937  IF(mstj(101).EQ.-1.AND.njet.EQ.2) goto 130
78938  ENDIF
78939 
78940  RETURN
78941  END
78942 
78943 C*********************************************************************
78944 
78945 C...PYX4JT
78946 C...Selects the kinematical variables of four-jet events.
78947 
78948  SUBROUTINE pyx4jt(NJET,CUT,KFL,ECM,KFLN,X1,X2,X4,X12,X14)
78949 
78950 C...Double precision and integer declarations.
78951  IMPLICIT DOUBLE PRECISION(a-h, o-z)
78952  IMPLICIT INTEGER(i-n)
78953  INTEGER pyk,pychge,pycomp
78954 C...Commonblocks.
78955  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
78956  SAVE /pydat1/
78957 C...Local arrays.
78958  dimension wta(4),wtb(4),wtc(4),wtd(4),wte(4)
78959 
78960 C...Common constants. Colour factors for QCD and Abelian gluon theory.
78961  pmq=pymass(kfl)
78962  qme=(2d0*pmq/ecm)**2
78963  ct=log(1d0/cut-5d0)
78964  IF(mstj(109).EQ.0) THEN
78965  cf=4d0/3d0
78966  cn=3d0
78967  tr=2.5d0
78968  ELSE
78969  cf=1d0
78970  cn=0d0
78971  tr=15d0
78972  ENDIF
78973 
78974 C...Choice of process (qqbargg or qqbarqqbar).
78975  100 njet=4
78976  it=1
78977  IF(parj(155).GT.pyr(0)) it=2
78978  IF(mstj(101).LE.-3) it=-mstj(101)-2
78979  IF(it.EQ.1) wtmx=0.7d0/cut**2
78980  IF(it.EQ.1.AND.mstj(109).EQ.2) wtmx=0.6d0/cut**2
78981  IF(it.EQ.2) wtmx=0.1125d0*cf*tr/cut**2
78982  id=1
78983 
78984 C...Sample the five kinematical variables (for qqgg preweighted in y34).
78985  110 y134=3d0*cut+(1d0-6d0*cut)*pyr(0)
78986  y234=3d0*cut+(1d0-6d0*cut)*pyr(0)
78987  IF(it.EQ.1) y34=(1d0-5d0*cut)*exp(-ct*pyr(0))
78988  IF(it.EQ.2) y34=cut+(1d0-6d0*cut)*pyr(0)
78989  IF(y34.LE.y134+y234-1d0.OR.y34.GE.y134*y234) goto 110
78990  vt=pyr(0)
78991  cp=cos(paru(1)*pyr(0))
78992  y14=(y134-y34)*vt
78993  y13=y134-y14-y34
78994  vb=y34*(1d0-y134-y234+y34)/((y134-y34)*(y234-y34))
78995  y24=0.5d0*(y234-y34)*(1d0-4d0*sqrt(max(0d0,vt*(1d0-vt)*
78996  &vb*(1d0-vb)))*cp-(1d0-2d0*vt)*(1d0-2d0*vb))
78997  y23=y234-y34-y24
78998  y12=1d0-y134-y23-y24
78999  IF(min(y12,y13,y14,y23,y24).LE.cut) goto 110
79000  y123=y12+y13+y23
79001  y124=y12+y14+y24
79002 
79003 C...Calculate matrix elements for qqgg or qqqq process.
79004  ic=0
79005  wttot=0d0
79006  120 ic=ic+1
79007  IF(it.EQ.1) THEN
79008  wta(ic)=(y12*y34**2-y13*y24*y34+y14*y23*y34+3d0*y12*y23*y34+
79009  & 3d0*y12*y14*y34+4d0*y12**2*y34-y13*y23*y24+2d0*y12*y23*y24-
79010  & y13*y14*y24-2d0*y12*y13*y24+2d0*y12**2*y24+y14*y23**2+2d0*y12*
79011  & y23**2+y14**2*y23+4d0*y12*y14*y23+4d0*y12**2*y23+2d0*y12*y14**2+
79012  & 2d0*y12*y13*y14+4d0*y12**2*y14+2d0*y12**2*y13+2d0*y12**3)/
79013  & (2d0*y13*y134*y234*y24)+(y24*y34+y12*y34+y13*y24-
79014  & y14*y23+y12*y13)/(y13*y134**2)+2d0*y23*(1d0-y13)/
79015  & (y13*y134*y24)+y34/(2d0*y13*y24)
79016  wtb(ic)=(y12*y24*y34+y12*y14*y34-y13*y24**2+y13*y14*y24+2d0*y12*
79017  & y14*y24)/(y13*y134*y23*y14)+y12*(1d0+y34)*y124/(y134*y234*y14*
79018  & y24)-(2d0*y13*y24+y14**2+y13*y23+2d0*y12*y13)/(y13*y134*y14)+
79019  & y12*y123*y124/(2d0*y13*y14*y23*y24)
79020  wtc(ic)=-(5d0*y12*y34**2+2d0*y12*y24*y34+2d0*y12*y23*y34+
79021  & 2d0*y12*y14*y34+2d0*y12*y13*y34+4d0*y12**2*y34-y13*y24**2+
79022  & y14*y23*y24+y13*y23*y24+y13*y14*y24-y12*y14*y24-y13**2*y24-
79023  & 3d0*y12*y13*y24-y14*y23**2-y14**2*y23+y13*y14*y23-
79024  & 3d0*y12*y14*y23-y12*y13*y23)/(4d0*y134*y234*y34**2)+
79025  & (3d0*y12*y34**2-3d0*y13*y24*y34+3d0*y12*y24*y34+
79026  & 3d0*y14*y23*y34-y13*y24**2-y12*y23*y34+6d0*y12*y14*y34+
79027  & 2d0*y12*y13*y34-2d0*y12**2*y34+y14*y23*y24-3d0*y13*y23*y24-
79028  & 2d0*y13*y14*y24+4d0*y12*y14*y24+2d0*y12*y13*y24+
79029  & 3d0*y14*y23**2+2d0*y14**2*y23+2d0*y14**2*y12+
79030  & 2d0*y12**2*y14+6d0*y12*y14*y23-2d0*y12*y13**2-
79031  & 2d0*y12**2*y13)/(4d0*y13*y134*y234*y34)
79032  wtc(ic)=wtc(ic)+(2d0*y12*y34**2-2d0*y13*y24*y34+y12*y24*y34+
79033  & 4d0*y13*y23*y34+4d0*y12*y14*y34+2d0*y12*y13*y34+2d0*y12**2*y34-
79034  & y13*y24**2+3d0*y14*y23*y24+4d0*y13*y23*y24-2d0*y13*y14*y24+
79035  & 4d0*y12*y14*y24+2d0*y12*y13*y24+2d0*y14*y23**2+4d0*y13*y23**2+
79036  & 2d0*y13*y14*y23+2d0*y12*y14*y23+4d0*y12*y13*y23+2d0*y12*y14**2+
79037  & 4d0*y12**2*y13+4d0*y12*y13*y14+2d0*y12**2*y14)/
79038  & (4d0*y13*y134*y24*y34)-(y12*y34**2-2d0*y14*y24*y34-
79039  & 2d0*y13*y24*y34-y14*y23*y34+y13*y23*y34+y12*y14*y34+
79040  & 2d0*y12*y13*y34-2d0*y14**2*y24-4d0*y13*y14*y24-
79041  & 4d0*y13**2*y24-y14**2*y23-y13**2*y23+y12*y13*y14-
79042  & y12*y13**2)/(2d0*y13*y34*y134**2)+(y12*y34**2-
79043  & 4d0*y14*y24*y34-2d0*y13*y24*y34-2d0*y14*y23*y34-
79044  & 4d0*y13*y23*y34-4d0*y12*y14*y34-4d0*y12*y13*y34-
79045  & 2d0*y13*y14*y24+2d0*y13**2*y24+2d0*y14**2*y23-
79046  & 2d0*y13*y14*y23-y12*y14**2-6d0*y12*y13*y14-
79047  & y12*y13**2)/(4d0*y34**2*y134**2)
79048  wttot=wttot+y34*cf*(cf*wta(ic)+(cf-0.5d0*cn)*wtb(ic)+
79049  & cn*wtc(ic))/8d0
79050  ELSE
79051  wtd(ic)=(y13*y23*y34+y12*y23*y34-y12**2*y34+y13*y23*y24+2d0*y12*
79052  & y23*y24-y14*y23**2+y12*y13*y24+y12*y14*y23+y12*y13*y14)/(y13**2*
79053  & y123**2)-(y12*y34**2-y13*y24*y34+y12*y24*y34-y14*y23*y34-y12*
79054  & y23*y34-y13*y24**2+y14*y23*y24-y13*y23*y24-y13**2*y24+y14*
79055  & y23**2)/(y13**2*y123*y134)+(y13*y14*y12+y34*y14*y12-y34**2*y12+
79056  & y13*y14*y24+2d0*y34*y14*y24-y23*y14**2+y34*y13*y24+y34*y23*y14+
79057  & y34*y13*y23)/(y13**2*y134**2)-(y34*y12**2-y13*y24*y12+y34*y24*
79058  & y12-y23*y14*y12-y34*y14*y12-y13*y24**2+y23*y14*y24-y13*y14*y24-
79059  & y13**2*y24+y23*y14**2)/(y13**2*y134*y123)
79060  wte(ic)=(y12*y34*(y23-y24+y14+y13)+y13*y24**2-y14*y23*y24+y13*
79061  & y23*y24+y13*y14*y24+y13**2*y24-y14*y23*(y14+y23+y13))/(y13*y23*
79062  & y123*y134)-y12*(y12*y34-y23*y24-y13*y24-y14*y23-y14*y13)/(y13*
79063  & y23*y123**2)-(y14+y13)*(y24+y23)*y34/(y13*y23*y134*y234)+
79064  & (y12*y34*(y14-y24+y23+y13)+y13*y24**2-y23*y14*y24+y13*y14*y24+
79065  & y13*y23*y24+y13**2*y24-y23*y14*(y14+y23+y13))/(y13*y14*y134*
79066  & y123)-y34*(y34*y12-y14*y24-y13*y24-y23*y14-y23*y13)/(y13*y14*
79067  & y134**2)-(y23+y13)*(y24+y14)*y12/(y13*y14*y123*y124)
79068  wttot=wttot+cf*(tr*wtd(ic)+(cf-0.5d0*cn)*wte(ic))/16d0
79069  ENDIF
79070 
79071 C...Permutations of momenta in matrix element. Weighting.
79072  130 IF(ic.EQ.1.OR.ic.EQ.3.OR.id.EQ.2.OR.id.EQ.3) THEN
79073  ysav=y13
79074  y13=y14
79075  y14=ysav
79076  ysav=y23
79077  y23=y24
79078  y24=ysav
79079  ysav=y123
79080  y123=y124
79081  y124=ysav
79082  ENDIF
79083  IF(ic.EQ.2.OR.ic.EQ.4.OR.id.EQ.3.OR.id.EQ.4) THEN
79084  ysav=y13
79085  y13=y23
79086  y23=ysav
79087  ysav=y14
79088  y14=y24
79089  y24=ysav
79090  ysav=y134
79091  y134=y234
79092  y234=ysav
79093  ENDIF
79094  IF(ic.LE.3) goto 120
79095  IF(id.EQ.1.AND.wttot.LT.pyr(0)*wtmx) goto 110
79096  ic=5
79097 
79098 C...qqgg events: string configuration and event type.
79099  IF(it.EQ.1) THEN
79100  IF(mstj(109).EQ.0.AND.id.EQ.1) THEN
79101  parj(156)=y34*(2d0*(wta(1)+wta(2)+wta(3)+wta(4))+4d0*(wtc(1)+
79102  & wtc(2)+wtc(3)+wtc(4)))/(9d0*wttot)
79103  IF(wta(2)+wta(4)+2d0*(wtc(2)+wtc(4)).GT.pyr(0)*(wta(1)+wta(2)+
79104  & wta(3)+wta(4)+2d0*(wtc(1)+wtc(2)+wtc(3)+wtc(4)))) id=2
79105  IF(id.EQ.2) goto 130
79106  ELSEIF(mstj(109).EQ.2.AND.id.EQ.1) THEN
79107  parj(156)=y34*(wta(1)+wta(2)+wta(3)+wta(4))/(8d0*wttot)
79108  IF(wta(2)+wta(4).GT.pyr(0)*(wta(1)+wta(2)+wta(3)+wta(4))) id=2
79109  IF(id.EQ.2) goto 130
79110  ENDIF
79111  mstj(120)=3
79112  IF(mstj(109).EQ.0.AND.0.5d0*y34*(wtc(1)+wtc(2)+wtc(3)+
79113  & wtc(4)).GT.pyr(0)*wttot) mstj(120)=4
79114  kfln=21
79115 
79116 C...Mass cuts. Kinematical variables out.
79117  IF(y12.LE.cut+qme) njet=2
79118  IF(njet.EQ.2) goto 150
79119  q12=0.5d0*(1d0-sqrt(1d0-qme/y12))
79120  x1=1d0-(1d0-q12)*y234-q12*y134
79121  x4=1d0-(1d0-q12)*y134-q12*y234
79122  x2=1d0-y124
79123  x12=(1d0-q12)*y13+q12*y23
79124  x14=y12-0.5d0*qme
79125  IF(y134*y234/((1d0-x1)*(1d0-x4)).LE.pyr(0)) njet=2
79126 
79127 C...qqbarqqbar events: string configuration, choose new flavour.
79128  ELSE
79129  IF(id.EQ.1) THEN
79130  wtr=pyr(0)*(wtd(1)+wtd(2)+wtd(3)+wtd(4))
79131  IF(wtr.LT.wtd(2)+wtd(3)+wtd(4)) id=2
79132  IF(wtr.LT.wtd(3)+wtd(4)) id=3
79133  IF(wtr.LT.wtd(4)) id=4
79134  IF(id.GE.2) goto 130
79135  ENDIF
79136  mstj(120)=5
79137  parj(156)=cf*tr*(wtd(1)+wtd(2)+wtd(3)+wtd(4))/(16d0*wttot)
79138  140 kfln=1+int(5d0*pyr(0))
79139  IF(kfln.NE.kfl.AND.0.2d0*parj(156).LE.pyr(0)) goto 140
79140  IF(kfln.EQ.kfl.AND.1d0-0.8d0*parj(156).LE.pyr(0)) goto 140
79141  IF(kfln.GT.mstj(104)) njet=2
79142  pmqn=pymass(kfln)
79143  qmen=(2d0*pmqn/ecm)**2
79144 
79145 C...Mass cuts. Kinematical variables out.
79146  IF(y24.LE.cut+qme.OR.y13.LE.1.1d0*qmen) njet=2
79147  IF(njet.EQ.2) goto 150
79148  q24=0.5d0*(1d0-sqrt(1d0-qme/y24))
79149  q13=0.5d0*(1d0-sqrt(1d0-qmen/y13))
79150  x1=1d0-(1d0-q24)*y123-q24*y134
79151  x4=1d0-(1d0-q24)*y134-q24*y123
79152  x2=1d0-(1d0-q13)*y234-q13*y124
79153  x12=(1d0-q24)*((1d0-q13)*y14+q13*y34)+q24*((1d0-q13)*y12+
79154  & q13*y23)
79155  x14=y24-0.5d0*qme
79156  x34=(1d0-q24)*((1d0-q13)*y23+q13*y12)+q24*((1d0-q13)*y34+
79157  & q13*y14)
79158  IF(pmq**2+pmqn**2+min(x12,x34)*ecm**2.LE.
79159  & (parj(127)+pmq+pmqn)**2) njet=2
79160  IF(y123*y134/((1d0-x1)*(1d0-x4)).LE.pyr(0)) njet=2
79161  ENDIF
79162  150 IF(mstj(101).LE.-2.AND.njet.EQ.2) goto 100
79163 
79164  RETURN
79165  END
79166 
79167 C*********************************************************************
79168 
79169 C...PYXDIF
79170 C...Gives the angular orientation of events.
79171 
79172  SUBROUTINE pyxdif(NC,NJET,KFL,ECM,CHI,THE,PHI)
79173 
79174 C...Double precision and integer declarations.
79175  IMPLICIT DOUBLE PRECISION(a-h, o-z)
79176  IMPLICIT INTEGER(i-n)
79177  INTEGER pyk,pychge,pycomp
79178 C...Commonblocks.
79179  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
79180  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
79181  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
79182  SAVE /pyjets/,/pydat1/,/pydat2/
79183 
79184 C...Charge. Factors depending on polarization for QED case.
79185  qf=kchg(kfl,1)/3d0
79186  poll=1d0-parj(131)*parj(132)
79187  pold=parj(132)-parj(131)
79188  IF(mstj(102).LE.1.OR.mstj(109).EQ.1) THEN
79189  hf1=poll
79190  hf2=0d0
79191  hf3=parj(133)**2
79192  hf4=0d0
79193 
79194 C...Factors depending on flavour, energy and polarization for QFD case.
79195  ELSE
79196  sff=1d0/(16d0*paru(102)*(1d0-paru(102)))
79197  sfw=ecm**4/((ecm**2-parj(123)**2)**2+(parj(123)*parj(124))**2)
79198  sfi=sfw*(1d0-(parj(123)/ecm)**2)
79199  ae=-1d0
79200  ve=4d0*paru(102)-1d0
79201  af=sign(1d0,qf)
79202  vf=af-4d0*qf*paru(102)
79203  hf1=qf**2*poll-2d0*qf*vf*sfi*sff*(ve*poll-ae*pold)+
79204  & (vf**2+af**2)*sfw*sff**2*((ve**2+ae**2)*poll-2d0*ve*ae*pold)
79205  hf2=-2d0*qf*af*sfi*sff*(ae*poll-ve*pold)+2d0*vf*af*sfw*sff**2*
79206  & (2d0*ve*ae*poll-(ve**2+ae**2)*pold)
79207  hf3=parj(133)**2*(qf**2-2d0*qf*vf*sfi*sff*ve+(vf**2+af**2)*
79208  & sfw*sff**2*(ve**2-ae**2))
79209  hf4=-parj(133)**2*2d0*qf*vf*sfw*(parj(123)*parj(124)/ecm**2)*
79210  & sff*ae
79211  ENDIF
79212 
79213 C...Mass factor. Differential cross-sections for two-jet events.
79214  sq2=sqrt(2d0)
79215  qme=0d0
79216  IF(mstj(103).GE.4.AND.iabs(mstj(101)).LE.1.AND.mstj(102).LE.1.AND.
79217  &mstj(109).NE.1) qme=(2d0*pymass(kfl)/ecm)**2
79218  IF(njet.EQ.2) THEN
79219  sigu=4d0*sqrt(1d0-qme)
79220  sigl=2d0*qme*sqrt(1d0-qme)
79221  sigt=0d0
79222  sigi=0d0
79223  siga=0d0
79224  sigp=4d0
79225 
79226 C...Kinematical variables. Reduce four-jet event to three-jet one.
79227  ELSE
79228  IF(njet.EQ.3) THEN
79229  x1=2d0*p(nc+1,4)/ecm
79230  x2=2d0*p(nc+3,4)/ecm
79231  ELSE
79232  ecmr=p(nc+1,4)+p(nc+4,4)+sqrt((p(nc+2,1)+p(nc+3,1))**2+
79233  & (p(nc+2,2)+p(nc+3,2))**2+(p(nc+2,3)+p(nc+3,3))**2)
79234  x1=2d0*p(nc+1,4)/ecmr
79235  x2=2d0*p(nc+4,4)/ecmr
79236  ENDIF
79237 
79238 C...Differential cross-sections for three-jet (or reduced four-jet).
79239  xq=(1d0-x1)/(1d0-x2)
79240  ct12=(x1*x2-2d0*x1-2d0*x2+2d0+qme)/sqrt((x1**2-qme)*(x2**2-qme))
79241  st12=sqrt(1d0-ct12**2)
79242  IF(mstj(109).NE.1) THEN
79243  sigu=2d0*x1**2+x2**2*(1d0+ct12**2)-qme*(3d0+ct12**2-x1-x2)-
79244  & qme*x1/xq+0.5d0*qme*((x2**2-qme)*st12**2-2d0*x2)*xq
79245  sigl=(x2*st12)**2-qme*(3d0-ct12**2-2.5d0*(x1+x2)+x1*x2+qme)+
79246  & 0.5d0*qme*(x1**2-x1-qme)/xq+0.5d0*qme*((x2**2-qme)*ct12**2-
79247  & x2)*xq
79248  sigt=0.5d0*(x2**2-qme-0.5d0*qme*(x2**2-qme)/xq)*st12**2
79249  sigi=((1d0-0.5d0*qme*xq)*(x2**2-qme)*st12*ct12+
79250  & qme*(1d0-x1-x2+0.5d0*x1*x2+0.5d0*qme)*st12/ct12)/sq2
79251  siga=x2**2*st12/sq2
79252  sigp=2d0*(x1**2-x2**2*ct12)
79253 
79254 C...Differential cross-sect for scalar gluons (no mass effects).
79255  ELSE
79256  x3=2d0-x1-x2
79257  xt=x2*st12
79258  ct13=sqrt(max(0d0,1d0-(xt/x3)**2))
79259  sigu=(1d0-parj(171))*(x3**2-0.5d0*xt**2)+
79260  & parj(171)*(x3**2-0.5d0*xt**2-4d0*(1d0-x1)*(1d0-x2)**2/x1)
79261  sigl=(1d0-parj(171))*0.5d0*xt**2+
79262  & parj(171)*0.5d0*(1d0-x1)**2*xt**2
79263  sigt=(1d0-parj(171))*0.25d0*xt**2+
79264  & parj(171)*0.25d0*xt**2*(1d0-2d0*x1)
79265  sigi=-(0.5d0/sq2)*((1d0-parj(171))*xt*x3*ct13+
79266  & parj(171)*xt*((1d0-2d0*x1)*x3*ct13-x1*(x1-x2)))
79267  siga=(0.25d0/sq2)*xt*(2d0*(1d0-x1)-x1*x3)
79268  sigp=x3**2-2d0*(1d0-x1)*(1d0-x2)/x1
79269  ENDIF
79270  ENDIF
79271 
79272 C...Upper bounds for differential cross-section.
79273  hf1a=abs(hf1)
79274  hf2a=abs(hf2)
79275  hf3a=abs(hf3)
79276  hf4a=abs(hf4)
79277  sigmax=(2d0*hf1a+hf3a+hf4a)*abs(sigu)+2d0*(hf1a+hf3a+hf4a)*
79278  &abs(sigl)+2d0*(hf1a+2d0*hf3a+2d0*hf4a)*abs(sigt)+2d0*sq2*
79279  &(hf1a+2d0*hf3a+2d0*hf4a)*abs(sigi)+4d0*sq2*hf2a*abs(siga)+
79280  &2d0*hf2a*abs(sigp)
79281 
79282 C...Generate angular orientation according to differential cross-sect.
79283  100 chi=paru(2)*pyr(0)
79284  cthe=2d0*pyr(0)-1d0
79285  phi=paru(2)*pyr(0)
79286  cchi=cos(chi)
79287  schi=sin(chi)
79288  c2chi=cos(2d0*chi)
79289  s2chi=sin(2d0*chi)
79290  the=acos(cthe)
79291  sthe=sin(the)
79292  c2phi=cos(2d0*(phi-parj(134)))
79293  s2phi=sin(2d0*(phi-parj(134)))
79294  sig=((1d0+cthe**2)*hf1+sthe**2*(c2phi*hf3-s2phi*hf4))*sigu+
79295  &2d0*(sthe**2*hf1-sthe**2*(c2phi*hf3-s2phi*hf4))*sigl+
79296  &2d0*(sthe**2*c2chi*hf1+((1d0+cthe**2)*c2chi*c2phi-2d0*cthe*s2chi*
79297  &s2phi)*hf3-((1d0+cthe**2)*c2chi*s2phi+2d0*cthe*s2chi*c2phi)*hf4)*
79298  &sigt-2d0*sq2*(2d0*sthe*cthe*cchi*hf1-2d0*sthe*(cthe*cchi*c2phi-
79299  &schi*s2phi)*hf3+2d0*sthe*(cthe*cchi*s2phi+schi*c2phi)*hf4)*sigi+
79300  &4d0*sq2*sthe*cchi*hf2*siga+2d0*cthe*hf2*sigp
79301  IF(sig.LT.sigmax*pyr(0)) goto 100
79302 
79303  RETURN
79304  END
79305 
79306 C*********************************************************************
79307 
79308 C...PYONIA
79309 C...Generates Upsilon and toponium decays into three gluons
79310 C...or two gluons and a photon.
79311 
79312  SUBROUTINE pyonia(KFL,ECM)
79313 
79314 C...Double precision and integer declarations.
79315  IMPLICIT DOUBLE PRECISION(a-h, o-z)
79316  IMPLICIT INTEGER(i-n)
79317  INTEGER pyk,pychge,pycomp
79318 C...Commonblocks.
79319  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
79320  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
79321  common/pydat2/kchg(500,4),pmas(500,4),parf(2000),vckm(4,4)
79322  SAVE /pyjets/,/pydat1/,/pydat2/
79323 
79324 C...Printout. Check input parameters.
79325  IF(mstu(12).NE.12345) CALL pylist(0)
79326  IF(kfl.LT.0.OR.kfl.GT.8) THEN
79327  CALL pyerrm(16,'(PYONIA:) called with unknown flavour code')
79328  IF(mstu(21).GE.1) RETURN
79329  ENDIF
79330  IF(ecm.LT.parj(127)+2.02d0*parf(101)) THEN
79331  CALL pyerrm(16,'(PYONIA:) called with too small CM energy')
79332  IF(mstu(21).GE.1) RETURN
79333  ENDIF
79334 
79335 C...Initial e+e- and onium state (optional).
79336  nc=0
79337  IF(mstj(115).GE.2) THEN
79338  nc=nc+2
79339  CALL py1ent(nc-1,11,0.5d0*ecm,0d0,0d0)
79340  k(nc-1,1)=21
79341  CALL py1ent(nc,-11,0.5d0*ecm,paru(1),0d0)
79342  k(nc,1)=21
79343  ENDIF
79344  kflc=iabs(kfl)
79345  IF(mstj(115).GE.3.AND.kflc.GE.5) THEN
79346  nc=nc+1
79347  kf=110*kflc+3
79348  mstu10=mstu(10)
79349  mstu(10)=1
79350  p(nc,5)=ecm
79351  CALL py1ent(nc,kf,ecm,0d0,0d0)
79352  k(nc,1)=21
79353  k(nc,3)=1
79354  mstu(10)=mstu10
79355  ENDIF
79356 
79357 C...Choose x1 and x2 according to matrix element.
79358  ntry=0
79359  100 x1=pyr(0)
79360  x2=pyr(0)
79361  x3=2d0-x1-x2
79362  IF(x3.GE.1d0.OR.((1d0-x1)/(x2*x3))**2+((1d0-x2)/(x1*x3))**2+
79363  &((1d0-x3)/(x1*x2))**2.LE.2d0*pyr(0)) goto 100
79364  ntry=ntry+1
79365  njet=3
79366  IF(mstj(101).LE.4) CALL py3ent(nc+1,21,21,21,ecm,x1,x3)
79367  IF(mstj(101).GE.5) CALL py3ent(-(nc+1),21,21,21,ecm,x1,x3)
79368 
79369 C...Photon-gluon-gluon events. Small system modifications. Jet origin.
79370  mstu(111)=mstj(108)
79371  IF(mstj(108).EQ.2.AND.(mstj(101).EQ.0.OR.mstj(101).EQ.1))
79372  &mstu(111)=1
79373  paru(112)=parj(121)
79374  IF(mstu(111).EQ.2) paru(112)=parj(122)
79375  qf=0d0
79376  IF(kflc.NE.0) qf=kchg(kflc,1)/3d0
79377  rgam=7.2d0*qf**2*paru(101)/pyalps(ecm**2)
79378  mk=0
79379  ecmc=ecm
79380  IF(pyr(0).GT.rgam/(1d0+rgam)) THEN
79381  IF(1d0-max(x1,x2,x3).LE.max((parj(126)/ecm)**2,parj(125)))
79382  & njet=2
79383  IF(njet.EQ.2.AND.mstj(101).LE.4) CALL py2ent(nc+1,21,21,ecm)
79384  IF(njet.EQ.2.AND.mstj(101).GE.5) CALL py2ent(-(nc+1),21,21,ecm)
79385  ELSE
79386  mk=1
79387  ecmc=sqrt(1d0-x1)*ecm
79388  IF(ecmc.LT.2d0*parj(127)) goto 100
79389  k(nc+1,1)=1
79390  k(nc+1,2)=22
79391  k(nc+1,4)=0
79392  k(nc+1,5)=0
79393  IF(mstj(101).GE.5) k(nc+2,4)=mstu(5)*(nc+3)
79394  IF(mstj(101).GE.5) k(nc+2,5)=mstu(5)*(nc+3)
79395  IF(mstj(101).GE.5) k(nc+3,4)=mstu(5)*(nc+2)
79396  IF(mstj(101).GE.5) k(nc+3,5)=mstu(5)*(nc+2)
79397  njet=2
79398  IF(ecmc.LT.4d0*parj(127)) THEN
79399  mstu10=mstu(10)
79400  mstu(10)=1
79401  p(nc+2,5)=ecmc
79402  CALL py1ent(nc+2,83,0.5d0*(x2+x3)*ecm,paru(1),0d0)
79403  mstu(10)=mstu10
79404  njet=0
79405  ENDIF
79406  ENDIF
79407  DO 110 ip=nc+1,n
79408  k(ip,3)=k(ip,3)+(mstj(115)/2)+(kflc/5)*(mstj(115)/3)*(nc-1)
79409  110 CONTINUE
79410 
79411 C...Differential cross-sections. Upper limit for cross-section.
79412  IF(mstj(106).EQ.1) THEN
79413  sq2=sqrt(2d0)
79414  hf1=1d0-parj(131)*parj(132)
79415  hf3=parj(133)**2
79416  ct13=(x1*x3-2d0*x1-2d0*x3+2d0)/(x1*x3)
79417  st13=sqrt(1d0-ct13**2)
79418  sigl=0.5d0*x3**2*((1d0-x2)**2+(1d0-x3)**2)*st13**2
79419  sigu=(x1*(1d0-x1))**2+(x2*(1d0-x2))**2+(x3*(1d0-x3))**2-sigl
79420  sigt=0.5d0*sigl
79421  sigi=(sigl*ct13/st13+0.5d0*x1*x3*(1d0-x2)**2*st13)/sq2
79422  sigmax=(2d0*hf1+hf3)*abs(sigu)+2d0*(hf1+hf3)*abs(sigl)+2d0*(hf1+
79423  & 2d0*hf3)*abs(sigt)+2d0*sq2*(hf1+2d0*hf3)*abs(sigi)
79424 
79425 C...Angular orientation of event.
79426  120 chi=paru(2)*pyr(0)
79427  cthe=2d0*pyr(0)-1d0
79428  phi=paru(2)*pyr(0)
79429  cchi=cos(chi)
79430  schi=sin(chi)
79431  c2chi=cos(2d0*chi)
79432  s2chi=sin(2d0*chi)
79433  the=acos(cthe)
79434  sthe=sin(the)
79435  c2phi=cos(2d0*(phi-parj(134)))
79436  s2phi=sin(2d0*(phi-parj(134)))
79437  sig=((1d0+cthe**2)*hf1+sthe**2*c2phi*hf3)*sigu+2d0*(sthe**2*hf1-
79438  & sthe**2*c2phi*hf3)*sigl+2d0*(sthe**2*c2chi*hf1+((1d0+cthe**2)*
79439  & c2chi*c2phi-2d0*cthe*s2chi*s2phi)*hf3)*sigt-
79440  & 2d0*sq2*(2d0*sthe*cthe*cchi*hf1-2d0*sthe*
79441  & (cthe*cchi*c2phi-schi*s2phi)*hf3)*sigi
79442  IF(sig.LT.sigmax*pyr(0)) goto 120
79443  CALL pyrobo(nc+1,n,0d0,chi,0d0,0d0,0d0)
79444  CALL pyrobo(nc+1,n,the,phi,0d0,0d0,0d0)
79445  ENDIF
79446 
79447 C...Generate parton shower. Rearrange along strings and check.
79448  IF(mstj(101).GE.5.AND.njet.GE.2) THEN
79449  CALL pyshow(nc+mk+1,-njet,ecmc)
79450  mstj14=mstj(14)
79451  IF(mstj(105).EQ.-1) mstj(14)=-1
79452  IF(mstj(105).GE.0) mstu(28)=0
79453  CALL pyprep(0)
79454  mstj(14)=mstj14
79455  IF(mstj(105).GE.0.AND.mstu(28).NE.0) goto 100
79456  ENDIF
79457 
79458 C...Generate fragmentation. Information for PYTABU:
79459  IF(mstj(105).EQ.1) CALL pyexec
79460  mstu(161)=110*kflc+3
79461  mstu(162)=0
79462 
79463  RETURN
79464  END
79465 
79466 C*********************************************************************
79467 
79468 C...PYBOOK
79469 C...Books a histogram.
79470 
79471  SUBROUTINE pybook(ID,TITLE,NX,XL,XU)
79472 
79473 C...Double precision declaration.
79474  IMPLICIT DOUBLE PRECISION(a-h, o-z)
79475  IMPLICIT INTEGER(i-n)
79476 C...Commonblock.
79477  common/pybins/ihist(4),indx(1000),bin(20000)
79478  SAVE /pybins/
79479 C...Local character variables.
79480  CHARACTER title*(*), titfx*60
79481 
79482 C...Check that input is sensible. Find initial address in memory.
79483  IF(id.LE.0.OR.id.GT.ihist(1)) CALL pyerrm(28,
79484  &'(PYBOOK:) not allowed histogram number')
79485  IF(nx.LE.0.OR.nx.GT.100) CALL pyerrm(28,
79486  &'(PYBOOK:) not allowed number of bins')
79487  IF(xl.GE.xu) CALL pyerrm(28,
79488  &'(PYBOOK:) x limits in wrong order')
79489  indx(id)=ihist(4)
79490  ihist(4)=ihist(4)+28+nx
79491  IF(ihist(4).GT.ihist(2)) CALL pyerrm(28,
79492  &'(PYBOOK:) out of histogram space')
79493  is=indx(id)
79494 
79495 C...Store histogram size and reset contents.
79496  bin(is+1)=nx
79497  bin(is+2)=xl
79498  bin(is+3)=xu
79499  bin(is+4)=(xu-xl)/nx
79500  CALL pynull(id)
79501 
79502 C...Store title by conversion to integer to double precision.
79503  titfx=title//' '
79504  DO 100 it=1,20
79505  bin(is+8+nx+it)=256**2*ichar(titfx(3*it-2:3*it-2))+
79506  & 256*ichar(titfx(3*it-1:3*it-1))+ichar(titfx(3*it:3*it))
79507  100 CONTINUE
79508 
79509  RETURN
79510  END
79511 
79512 C*********************************************************************
79513 
79514 C...PYFILL
79515 C...Fills entry in histogram.
79516 
79517  SUBROUTINE pyfill(ID,X,W)
79518 
79519 C...Double precision declaration.
79520  IMPLICIT DOUBLE PRECISION(a-h, o-z)
79521  IMPLICIT INTEGER(i-n)
79522 C...Commonblock.
79523  common/pybins/ihist(4),indx(1000),bin(20000)
79524  SAVE /pybins/
79525 
79526 C...Find initial address in memory. Increase number of entries.
79527  IF(id.LE.0.OR.id.GT.ihist(1)) CALL pyerrm(28,
79528  &'(PYFILL:) not allowed histogram number')
79529  is=indx(id)
79530  IF(is.EQ.0) CALL pyerrm(28,
79531  &'(PYFILL:) filling unbooked histogram')
79532  bin(is+5)=bin(is+5)+1d0
79533 
79534 C...Find bin in x, including under/overflow, and fill.
79535  IF(x.LT.bin(is+2)) THEN
79536  bin(is+6)=bin(is+6)+w
79537  ELSEIF(x.GE.bin(is+3)) THEN
79538  bin(is+8)=bin(is+8)+w
79539  ELSE
79540  bin(is+7)=bin(is+7)+w
79541  ix=(x-bin(is+2))/bin(is+4)
79542  ix=max(0,min(nint(bin(is+1))-1,ix))
79543  bin(is+9+ix)=bin(is+9+ix)+w
79544  ENDIF
79545 
79546  RETURN
79547  END
79548 
79549 C*********************************************************************
79550 
79551 C...PYFACT
79552 C...Multiplies histogram contents by factor.
79553 
79554  SUBROUTINE pyfact(ID,F)
79555 
79556 C...Double precision declaration.
79557  IMPLICIT DOUBLE PRECISION(a-h, o-z)
79558  IMPLICIT INTEGER(i-n)
79559 C...Commonblock.
79560  common/pybins/ihist(4),indx(1000),bin(20000)
79561  SAVE /pybins/
79562 
79563 C...Find initial address in memory. Multiply all contents bins.
79564  IF(id.LE.0.OR.id.GT.ihist(1)) CALL pyerrm(28,
79565  &'(PYFACT:) not allowed histogram number')
79566  is=indx(id)
79567  IF(is.EQ.0) CALL pyerrm(28,
79568  &'(PYFACT:) scaling unbooked histogram')
79569  DO 100 ix=is+6,is+8+nint(bin(is+1))
79570  bin(ix)=f*bin(ix)
79571  100 CONTINUE
79572 
79573  RETURN
79574  END
79575 
79576 C*********************************************************************
79577 
79578 C...PYOPER
79579 C...Performs operations between histograms.
79580 
79581  SUBROUTINE pyoper(ID1,OPER,ID2,ID3,F1,F2)
79582 
79583 C...Double precision declaration.
79584  IMPLICIT DOUBLE PRECISION(a-h, o-z)
79585  IMPLICIT INTEGER(i-n)
79586 C...Commonblock.
79587  common/pybins/ihist(4),indx(1000),bin(20000)
79588  SAVE /pybins/
79589 C...Character variable.
79590  CHARACTER oper*(*)
79591 
79592 C...Find initial addresses in memory, and histogram size.
79593  IF(id1.LE.0.OR.id1.GT.ihist(1)) CALL pyerrm(28,
79594  &'(PYFACT:) not allowed histogram number')
79595  is1=indx(id1)
79596  is2=indx(min(ihist(1),max(1,id2)))
79597  is3=indx(min(ihist(1),max(1,id3)))
79598  nx=nint(bin(is3+1))
79599  IF(oper.EQ.'M'.AND.id3.EQ.0) nx=nint(bin(is2+1))
79600 
79601 C...Update info on number of histogram entries.
79602  IF(oper.EQ.'+'.OR.oper.EQ.'-'.OR.oper.EQ.'*'.OR.oper.EQ.'/') THEN
79603  bin(is3+5)=bin(is1+5)+bin(is2+5)
79604  ELSEIF(oper.EQ.'A'.OR.oper.EQ.'S'.OR.oper.EQ.'L') THEN
79605  bin(is3+5)=bin(is1+5)
79606  ENDIF
79607 
79608 C...Operations on pair of histograms: addition, subtraction,
79609 C...multiplication, division.
79610  IF(oper.EQ.'+') THEN
79611  DO 100 ix=6,8+nx
79612  bin(is3+ix)=f1*bin(is1+ix)+f2*bin(is2+ix)
79613  100 CONTINUE
79614  ELSEIF(oper.EQ.'-') THEN
79615  DO 110 ix=6,8+nx
79616  bin(is3+ix)=f1*bin(is1+ix)-f2*bin(is2+ix)
79617  110 CONTINUE
79618  ELSEIF(oper.EQ.'*') THEN
79619  DO 120 ix=6,8+nx
79620  bin(is3+ix)=f1*bin(is1+ix)*f2*bin(is2+ix)
79621  120 CONTINUE
79622  ELSEIF(oper.EQ.'/') THEN
79623  DO 130 ix=6,8+nx
79624  fa2=f2*bin(is2+ix)
79625  IF(abs(fa2).LE.1d-20) THEN
79626  bin(is3+ix)=0d0
79627  ELSE
79628  bin(is3+ix)=f1*bin(is1+ix)/fa2
79629  ENDIF
79630  130 CONTINUE
79631 
79632 C...Operations on single histogram: multiplication+addition,
79633 C...square root+addition, logarithm+addition.
79634  ELSEIF(oper.EQ.'A') THEN
79635  DO 140 ix=6,8+nx
79636  bin(is3+ix)=f1*bin(is1+ix)+f2
79637  140 CONTINUE
79638  ELSEIF(oper.EQ.'S') THEN
79639  DO 150 ix=6,8+nx
79640  bin(is3+ix)=f1*sqrt(max(0d0,bin(is1+ix)))+f2
79641  150 CONTINUE
79642  ELSEIF(oper.EQ.'L') THEN
79643  zmin=1d20
79644  DO 160 ix=9,8+nx
79645  IF(bin(is1+ix).LT.zmin.AND.bin(is1+ix).GT.1d-20)
79646  & zmin=0.8d0*bin(is1+ix)
79647  160 CONTINUE
79648  DO 170 ix=6,8+nx
79649  bin(is3+ix)=f1*log10(max(zmin,bin(is1+ix)))+f2
79650  170 CONTINUE
79651 
79652 C...Operation on two or three histograms: average and
79653 C...standard deviation.
79654  ELSEIF(oper.EQ.'M') THEN
79655  DO 180 ix=6,8+nx
79656  IF(abs(bin(is1+ix)).LE.1d-20) THEN
79657  bin(is2+ix)=0d0
79658  ELSE
79659  bin(is2+ix)=bin(is2+ix)/bin(is1+ix)
79660  ENDIF
79661  IF(id3.NE.0) THEN
79662  IF(abs(bin(is1+ix)).LE.1d-20) THEN
79663  bin(is3+ix)=0d0
79664  ELSE
79665  bin(is3+ix)=sqrt(max(0d0,bin(is3+ix)/bin(is1+ix)-
79666  & bin(is2+ix)**2))
79667  ENDIF
79668  ENDIF
79669  bin(is1+ix)=f1*bin(is1+ix)
79670  180 CONTINUE
79671  ENDIF
79672 
79673  RETURN
79674  END
79675 
79676 C*********************************************************************
79677 
79678 C...PYHIST
79679 C...Prints and resets all histograms.
79680 
79681  SUBROUTINE pyhist
79682 
79683 C...Double precision declaration.
79684  IMPLICIT DOUBLE PRECISION(a-h, o-z)
79685  IMPLICIT INTEGER(i-n)
79686 C...Commonblock.
79687  common/pybins/ihist(4),indx(1000),bin(20000)
79688  SAVE /pybins/
79689 
79690 C...Loop over histograms, print and reset used ones.
79691  DO 100 id=1,ihist(1)
79692  is=indx(id)
79693  IF(is.NE.0.AND.nint(bin(is+5)).GT.0) THEN
79694  CALL pyplot(id)
79695  CALL pynull(id)
79696  ENDIF
79697  100 CONTINUE
79698 
79699  RETURN
79700  END
79701 
79702 C*********************************************************************
79703 
79704 C...PYPLOT
79705 C...Prints a histogram (but does not reset it).
79706 
79707  SUBROUTINE pyplot(ID)
79708 
79709 C...Double precision declaration.
79710  IMPLICIT DOUBLE PRECISION(a-h, o-z)
79711  IMPLICIT INTEGER(i-n)
79712 C...Commonblocks.
79713  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
79714  common/pybins/ihist(4),indx(1000),bin(20000)
79715  SAVE /pydat1/,/pybins/
79716 C...Local arrays and character variables.
79717  dimension idati(6), irow(100), ifra(100), dyac(10)
79718  CHARACTER title*60, out*100, cha(0:11)*1
79719 
79720 C...Steps in histogram scale. Character sequence.
79721  DATA dyac/.04,.05,.06,.08,.10,.12,.15,.20,.25,.30/
79722  DATA cha/'0','1','2','3','4','5','6','7','8','9','X','-'/
79723 
79724 C...Find initial address in memory; skip if empty histogram.
79725  IF(id.LE.0.OR.id.GT.ihist(1)) RETURN
79726  is=indx(id)
79727  IF(is.EQ.0) RETURN
79728  IF(nint(bin(is+5)).LE.0) THEN
79729  WRITE(mstu(11),5000) id
79730  RETURN
79731  ENDIF
79732 
79733 C...Number of histogram lines and x bins.
79734  lin=ihist(3)-18
79735  nx=nint(bin(is+1))
79736 
79737 C...Extract title by conversion from double precision via integer.
79738  DO 100 it=1,20
79739  ieq=nint(bin(is+8+nx+it))
79740  title(3*it-2:3*it)=char(ieq/256**2)//char(mod(ieq,256**2)/256)
79741  & //char(mod(ieq,256))
79742  100 CONTINUE
79743 
79744 C...Find time; print title.
79745  CALL pytime(idati)
79746  IF(idati(1).GT.0) THEN
79747  WRITE(mstu(11),5100) id, title, (idati(j),j=1,5)
79748  ELSE
79749  WRITE(mstu(11),5200) id, title
79750  ENDIF
79751 
79752 C...Find minimum and maximum bin content.
79753  ymin=bin(is+9)
79754  ymax=bin(is+9)
79755  DO 110 ix=is+10,is+8+nx
79756  IF(bin(ix).LT.ymin) ymin=bin(ix)
79757  IF(bin(ix).GT.ymax) ymax=bin(ix)
79758  110 CONTINUE
79759 
79760 C...Determine scale and step size for y axis.
79761  IF(ymax-ymin.GT.lin*dyac(1)*1d-9) THEN
79762  IF(ymin.GT.0d0.AND.ymin.LT.0.1d0*ymax) ymin=0d0
79763  IF(ymax.LT.0d0.AND.ymax.GT.0.1d0*ymin) ymax=0d0
79764  ipot=int(log10(ymax-ymin)+10d0)-10
79765  IF(ymax-ymin.LT.lin*dyac(1)*10d0**ipot) ipot=ipot-1
79766  IF(ymax-ymin.GT.lin*dyac(10)*10d0**ipot) ipot=ipot+1
79767  dely=dyac(1)
79768  DO 120 idel=1,9
79769  IF(ymax-ymin.GE.lin*dyac(idel)*10d0**ipot) dely=dyac(idel+1)
79770  120 CONTINUE
79771  dy=dely*10d0**ipot
79772 
79773 C...Convert bin contents to integer form; fractional fill in top row.
79774  DO 130 ix=1,nx
79775  cta=abs(bin(is+8+ix))/dy
79776  irow(ix)=sign(cta+0.95d0,bin(is+8+ix))
79777  ifra(ix)=10d0*(cta+1.05d0-dble(int(cta+0.95d0)))
79778  130 CONTINUE
79779  irmi=sign(abs(ymin)/dy+0.95d0,ymin)
79780  irma=sign(abs(ymax)/dy+0.95d0,ymax)
79781 
79782 C...Print histogram row by row.
79783  DO 150 ir=irma,irmi,-1
79784  IF(ir.EQ.0) goto 150
79785  out=' '
79786  DO 140 ix=1,nx
79787  IF(ir.EQ.irow(ix)) out(ix:ix)=cha(ifra(ix))
79788  IF(ir*(irow(ix)-ir).GT.0) out(ix:ix)=cha(10)
79789  140 CONTINUE
79790  WRITE(mstu(11),5300) ir*dely, ipot, out
79791  150 CONTINUE
79792 
79793 C...Print sign and value of bin contents.
79794  ipot=int(log10(max(ymax,-ymin))+10.0001d0)-10
79795  out=' '
79796  DO 160 ix=1,nx
79797  IF(bin(is+8+ix).LT.-10d0**(ipot-4)) out(ix:ix)=cha(11)
79798  irow(ix)=nint(10d0**(3-ipot)*abs(bin(is+8+ix)))
79799  160 CONTINUE
79800  WRITE(mstu(11),5400) out
79801  DO 180 ir=4,1,-1
79802  DO 170 ix=1,nx
79803  out(ix:ix)=cha(mod(irow(ix),10**ir)/10**(ir-1))
79804  170 CONTINUE
79805  WRITE(mstu(11),5500) ipot+ir-4, out
79806  180 CONTINUE
79807 
79808 C...Print sign and value of lower bin edge.
79809  ipot=int(log10(max(-bin(is+2),bin(is+3)-bin(is+4)))+
79810  & 10.0001d0)-10
79811  out=' '
79812  DO 190 ix=1,nx
79813  IF(bin(is+2)+(ix-1)*bin(is+4).LT.-10d0**(ipot-3))
79814  & out(ix:ix)=cha(11)
79815  irow(ix)=nint(10d0**(2-ipot)*abs(bin(is+2)+(ix-1)*bin(is+4)))
79816  190 CONTINUE
79817  WRITE(mstu(11),5600) out
79818  DO 210 ir=3,1,-1
79819  DO 200 ix=1,nx
79820  out(ix:ix)=cha(mod(irow(ix),10**ir)/10**(ir-1))
79821  200 CONTINUE
79822  WRITE(mstu(11),5500) ipot+ir-3, out
79823  210 CONTINUE
79824  ENDIF
79825 
79826 C...Calculate and print statistics.
79827  csum=0d0
79828  cxsum=0d0
79829  cxxsum=0d0
79830  DO 220 ix=1,nx
79831  cta=abs(bin(is+8+ix))
79832  x=bin(is+2)+(ix-0.5d0)*bin(is+4)
79833  csum=csum+cta
79834  cxsum=cxsum+cta*x
79835  cxxsum=cxxsum+cta*x**2
79836  220 CONTINUE
79837  xmean=cxsum/max(csum,1d-20)
79838  xrms=sqrt(max(0d0,cxxsum/max(csum,1d-20)-xmean**2))
79839  WRITE(mstu(11),5700) nint(bin(is+5)),xmean,bin(is+6),
79840  &bin(is+2),bin(is+7),xrms,bin(is+8),bin(is+3)
79841 
79842 C...Formats for output.
79843  5000 FORMAT(/5x,'Histogram no',i5,' : no entries')
79844  5100 FORMAT('1'/5x,'Histogram no',i5,6x,a60,5x,i4,'-',i2,'-',i2,1x,
79845  &i2,':',i2/)
79846  5200 FORMAT('1'/5x,'Histogram no',i5,6x,a60/)
79847  5300 FORMAT(2x,f7.2,'*10**',i2,3x,a100)
79848  5400 FORMAT(/8x,'Contents',3x,a100)
79849  5500 FORMAT(9x,'*10**',i2,3x,a100)
79850  5600 FORMAT(/8x,'Low edge',3x,a100)
79851  5700 FORMAT(/5x,'Entries =',i12,1p,6x,'Mean =',d12.4,6x,'Underflow ='
79852  &,d12.4,6x,'Low edge =',d12.4/5x,'All chan =',d12.4,6x,
79853  &'Rms =',d12.4,6x,'Overflow =',d12.4,6x,'High edge =',d12.4)
79854 
79855  RETURN
79856  END
79857 
79858 C*********************************************************************
79859 
79860 C...PYNULL
79861 C...Resets bin contents of a histogram.
79862 
79863  SUBROUTINE pynull(ID)
79864 
79865 C...Double precision declaration.
79866  IMPLICIT DOUBLE PRECISION(a-h, o-z)
79867  IMPLICIT INTEGER(i-n)
79868 C...Commonblock.
79869  common/pybins/ihist(4),indx(1000),bin(20000)
79870  SAVE /pybins/
79871 
79872  IF(id.LE.0.OR.id.GT.ihist(1)) RETURN
79873  is=indx(id)
79874  IF(is.EQ.0) RETURN
79875  DO 100 ix=is+5,is+8+nint(bin(is+1))
79876  bin(ix)=0d0
79877  100 CONTINUE
79878 
79879  RETURN
79880  END
79881 
79882 C*********************************************************************
79883 
79884 C...PYDUMP
79885 C...Dumps histogram contents on file for reading by other program.
79886 C...Can also read back own dump.
79887 
79888  SUBROUTINE pydump(MDUMP,LFN,NHI,IHI)
79889 
79890 C...Double precision declaration.
79891  IMPLICIT DOUBLE PRECISION(a-h, o-z)
79892  IMPLICIT INTEGER(i-n)
79893 C...Commonblock.
79894  common/pybins/ihist(4),indx(1000),bin(20000)
79895  SAVE /pybins/
79896 C...Local arrays and character variables.
79897  dimension ihi(*),iss(100),val(5)
79898  CHARACTER title*60,format*13
79899 
79900 C...Dump all histograms that have been booked,
79901 C...including titles and ranges, one after the other.
79902  IF(mdump.EQ.1) THEN
79903 
79904 C...Loop over histograms and find which are wanted and booked.
79905  IF(nhi.LE.0) THEN
79906  nw=ihist(1)
79907  ELSE
79908  nw=nhi
79909  ENDIF
79910  DO 130 iw=1,nw
79911  IF(nhi.EQ.0) THEN
79912  id=iw
79913  ELSE
79914  id=ihi(iw)
79915  ENDIF
79916  is=indx(id)
79917  IF(is.NE.0) THEN
79918 
79919 C...Write title, histogram size, filling statistics.
79920  nx=nint(bin(is+1))
79921  DO 100 it=1,20
79922  ieq=nint(bin(is+8+nx+it))
79923  title(3*it-2:3*it)=char(ieq/256**2)//
79924  & char(mod(ieq,256**2)/256)//char(mod(ieq,256))
79925  100 CONTINUE
79926  WRITE(lfn,5100) id,title
79927  WRITE(lfn,5200) nx,bin(is+2),bin(is+3)
79928  WRITE(lfn,5300) nint(bin(is+5)),bin(is+6),bin(is+7),
79929  & bin(is+8)
79930 
79931 
79932 C...Write histogram contents, in groups of five.
79933  DO 120 ixg=1,(nx+4)/5
79934  DO 110 ixv=1,5
79935  ix=5*ixg+ixv-5
79936  IF(ix.LE.nx) THEN
79937  val(ixv)=bin(is+8+ix)
79938  ELSE
79939  val(ixv)=0d0
79940  ENDIF
79941  110 CONTINUE
79942  WRITE(lfn,5400) (val(ixv),ixv=1,5)
79943  120 CONTINUE
79944 
79945 C...Go to next histogram; finish.
79946  ELSEIF(nhi.GT.0) THEN
79947  CALL pyerrm(8,'(PYDUMP:) unknown histogram number')
79948  ENDIF
79949  130 CONTINUE
79950 
79951 C...Read back in histograms dumped MDUMP=1.
79952  ELSEIF(mdump.EQ.2) THEN
79953 
79954 C...Read histogram number, title and range, and book.
79955  140 READ(lfn,5100,end=170) id,title
79956  READ(lfn,5200) nx,xl,xu
79957  CALL pybook(id,title,nx,xl,xu)
79958  is=indx(id)
79959 
79960 C...Read filling statistics.
79961  READ(lfn,5300) nentry,bin(is+6),bin(is+7),bin(is+8)
79962  bin(is+5)=dble(nentry)
79963 
79964 C...Read histogram contents, in groups of five.
79965  DO 160 ixg=1,(nx+4)/5
79966  READ(lfn,5400) (val(ixv),ixv=1,5)
79967  DO 150 ixv=1,5
79968  ix=5*ixg+ixv-5
79969  IF(ix.LE.nx) bin(is+8+ix)=val(ixv)
79970  150 CONTINUE
79971  160 CONTINUE
79972 
79973 C...Go to next histogram; finish.
79974  goto 140
79975  170 CONTINUE
79976 
79977 C...Write histogram contents in column format,
79978 C...convenient e.g. for GNUPLOT input.
79979  ELSEIF(mdump.EQ.3) THEN
79980 
79981 C...Find addresses to wanted histograms.
79982  nss=0
79983  IF(nhi.LE.0) THEN
79984  nw=ihist(1)
79985  ELSE
79986  nw=nhi
79987  ENDIF
79988  DO 180 iw=1,nw
79989  IF(nhi.EQ.0) THEN
79990  id=iw
79991  ELSE
79992  id=ihi(iw)
79993  ENDIF
79994  is=indx(id)
79995  IF(is.NE.0.AND.nss.LT.100) THEN
79996  nss=nss+1
79997  iss(nss)=is
79998  ELSEIF(nss.GE.100) THEN
79999  CALL pyerrm(8,'(PYDUMP:) too many histograms requested')
80000  ELSEIF(nhi.GT.0) THEN
80001  CALL pyerrm(8,'(PYDUMP:) unknown histogram number')
80002  ENDIF
80003  180 CONTINUE
80004 
80005 C...Check that they have common number of x bins. Fix format.
80006  nx=nint(bin(iss(1)+1))
80007  DO 190 iw=2,nss
80008  IF(nint(bin(iss(iw)+1)).NE.nx) THEN
80009  CALL pyerrm(8,'(PYDUMP:) different number of bins')
80010  RETURN
80011  ENDIF
80012  190 CONTINUE
80013  format='(1P,000E12.4)'
80014  WRITE(FORMAT(5:7),'(I3)') nss+1
80015 
80016 C...Write histogram contents; first column x values.
80017  DO 200 ix=1,nx
80018  x=bin(iss(1)+2)+(ix-0.5d0)*bin(iss(1)+4)
80019  WRITE(lfn,format) x, (bin(iss(iw)+8+ix),iw=1,nss)
80020  200 CONTINUE
80021 
80022  ENDIF
80023 
80024 C...Formats for output.
80025  5100 FORMAT(i5,5x,a60)
80026  5200 FORMAT(i5,1p,2d12.4)
80027  5300 FORMAT(i12,1p,3d12.4)
80028  5400 FORMAT(1p,5d12.4)
80029 
80030  RETURN
80031  END
80032 
80033 C*********************************************************************
80034 
80035 C...PYSTOP
80036 C...Allows users to handle STOP statemens
80037 
80038  SUBROUTINE pystop(MCOD)
80039 
80040 C...Double precision and integer declarations.
80041  IMPLICIT DOUBLE PRECISION(a-h, o-z)
80042  IMPLICIT INTEGER(i-n)
80043  INTEGER pyk,pychge,pycomp
80044 C...Commonblocks.
80045  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
80046  SAVE /pydat1/
80047 
80048 
80049 C...Write message, then stop
80050  WRITE(mstu(11),5000) mcod
80051  stop
80052 
80053 
80054 C...Formats for output.
80055  5000 FORMAT(/5x,'PYSTOP called with code: ',i4)
80056  END
80057 
80058 C*********************************************************************
80059 
80060 C...PYKCUT
80061 C...Dummy routine, which the user can replace in order to make cuts on
80062 C...the kinematics on the parton level before the matrix elements are
80063 C...evaluated and the event is generated. The cross-section estimates
80064 C...will automatically take these cuts into account, so the given
80065 C...values are for the allowed phase space region only. MCUT=0 means
80066 C...that the event has passed the cuts, MCUT=1 that it has failed.
80067 
80068  SUBROUTINE pykcut(MCUT)
80069 
80070 C...Double precision and integer declarations.
80071  IMPLICIT DOUBLE PRECISION(a-h, o-z)
80072  IMPLICIT INTEGER(i-n)
80073  INTEGER pyk,pychge,pycomp
80074 C...Commonblocks.
80075  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
80076  common/pyint1/mint(400),vint(400)
80077  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
80078  SAVE /pydat1/,/pyint1/,/pyint2/
80079 
80080 C...Set default value (accepting event) for MCUT.
80081  mcut=0
80082 
80083 C...Read out subprocess number.
80084  isub=mint(1)
80085  istsb=iset(isub)
80086 
80087 C...Read out tau, y*, cos(theta), tau' (where defined, else =0).
80088  tau=vint(21)
80089  yst=vint(22)
80090  cth=0d0
80091  IF(istsb.EQ.2.OR.istsb.EQ.4) cth=vint(23)
80092  taup=0d0
80093  IF(istsb.GE.3.AND.istsb.LE.5) taup=vint(26)
80094 
80095 C...Calculate x_1, x_2, x_F.
80096  IF(istsb.LE.2.OR.istsb.GE.5) THEN
80097  x1=sqrt(tau)*exp(yst)
80098  x2=sqrt(tau)*exp(-yst)
80099  ELSE
80100  x1=sqrt(taup)*exp(yst)
80101  x2=sqrt(taup)*exp(-yst)
80102  ENDIF
80103  xf=x1-x2
80104 
80105 C...Calculate shat, that, uhat, p_T^2.
80106  shat=tau*vint(2)
80107  sqm3=vint(63)
80108  sqm4=vint(64)
80109  rm3=sqm3/shat
80110  rm4=sqm4/shat
80111  be34=sqrt(max(0d0,(1d0-rm3-rm4)**2-4d0*rm3*rm4))
80112  rpts=4d0*vint(71)**2/shat
80113  be34l=sqrt(max(0d0,(1d0-rm3-rm4)**2-4d0*rm3*rm4-rpts))
80114  rm34=2d0*rm3*rm4
80115  rsqm=1d0+rm34
80116  rthm=(4d0*rm3*rm4+rpts)/(1d0-rm3-rm4+be34l)
80117  that=-0.5d0*shat*max(rthm,1d0-rm3-rm4-be34*cth)
80118  uhat=-0.5d0*shat*max(rthm,1d0-rm3-rm4+be34*cth)
80119  pt2=max(vint(71)**2,0.25d0*shat*be34**2*(1d0-cth**2))
80120 
80121 C...Decisions by user to be put here.
80122 
80123 C...Stop program if this routine is ever called.
80124 C...You should not copy these lines to your own routine.
80125  WRITE(mstu(11),5000)
80126  CALL pystop(6)
80127 
80128 C...Format for error printout.
80129  5000 FORMAT(1x,'Error: you did not link your PYKCUT routine ',
80130  &'correctly.'/1x,'Dummy routine in PYTHIA file called instead.'/
80131  &1x,'Execution stopped!')
80132 
80133  RETURN
80134  END
80135 
80136 ! C*********************************************************************
80137 !
80138 ! C...PYEVWT
80139 ! C...Dummy routine, which the user can replace in order to multiply the
80140 ! C...standard PYTHIA differential cross-section by a process- and
80141 ! C...kinematics-dependent factor WTXS. For MSTP(142)=1 this corresponds
80142 ! C...to generation of weighted events, with weight 1/WTXS, while for
80143 ! C...MSTP(142)=2 it corresponds to a modification of the underlying
80144 ! C...physics.
80145 !
80146 ! SUBROUTINE PYEVWT(WTXS)
80147 !
80148 ! C...Double precision and integer declarations.
80149 ! IMPLICIT DOUBLE PRECISION(A-H, O-Z)
80150 ! IMPLICIT INTEGER(I-N)
80151 ! INTEGER PYK,PYCHGE,PYCOMP
80152 ! C...Commonblocks.
80153 ! COMMON/PYDAT1/MSTU(200),PARU(200),MSTJ(200),PARJ(200)
80154 ! COMMON/PYINT1/MINT(400),VINT(400)
80155 ! COMMON/PYINT2/ISET(500),KFPR(500,2),COEF(500,20),ICOL(40,4,2)
80156 ! SAVE /PYDAT1/,/PYINT1/,/PYINT2/
80157 !
80158 ! C...Set default weight for WTXS.
80159 ! WTXS=1D0
80160 !
80161 ! C...Read out subprocess number.
80162 ! ISUB=MINT(1)
80163 ! ISTSB=ISET(ISUB)
80164 !
80165 ! C...Read out tau, y*, cos(theta), tau' (where defined, else =0).
80166 ! TAU=VINT(21)
80167 ! YST=VINT(22)
80168 ! CTH=0D0
80169 ! IF(ISTSB.EQ.2.OR.ISTSB.EQ.4) CTH=VINT(23)
80170 ! TAUP=0D0
80171 ! IF(ISTSB.GE.3.AND.ISTSB.LE.5) TAUP=VINT(26)
80172 !
80173 ! C...Read out x_1, x_2, x_F, shat, that, uhat, p_T^2.
80174 ! X1=VINT(41)
80175 ! X2=VINT(42)
80176 ! XF=X1-X2
80177 ! SHAT=VINT(44)
80178 ! THAT=VINT(45)
80179 ! UHAT=VINT(46)
80180 ! PT2=VINT(48)
80181 !
80182 ! C...Modifications by user to be put here.
80183 !
80184 ! C...Stop program if this routine is ever called.
80185 ! C...You should not copy these lines to your own routine.
80186 ! WRITE(MSTU(11),5000)
80187 ! CALL PYSTOP(4)
80188 !
80189 ! C...Format for error printout.
80190 ! 5000 FORMAT(1X,'Error: you did not link your PYEVWT routine ',
80191 ! &'correctly.'/1X,'Dummy routine in PYTHIA file called instead.'/
80192 ! &1X,'Execution stopped!')
80193 !
80194 ! RETURN
80195 ! END
80196 
80197 
80198  SUBROUTINE pyevwt(WTXS)
80199 
80200 C...Double precision and integer declarations.
80201  IMPLICIT DOUBLE PRECISION(a-h, o-z)
80202  IMPLICIT INTEGER(i-n)
80203  INTEGER pyk,pychge,pycomp
80204 C...Commonblocks.
80205  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
80206  common/pyint1/mint(400),vint(400)
80207  common/pyint2/iset(500),kfpr(500,2),coef(500,20),icol(40,4,2)
80208  SAVE /pydat1/,/pyint1/,/pyint2/
80209 C--event weight exponent
80210  common/wexpo/weightex
80211  DOUBLE PRECISION weightex
80212 
80213 C...Read out p_T^2
80214  pt2=vint(48)
80215  wtxs=pt2**(weightex/2.d0)
80216  RETURN
80217  END
80218 
80219 C*********************************************************************
80220 
80221 C...UPINIT
80222 C...Dummy routine, to be replaced by a user implementing external
80223 C...processes. Is supposed to fill the HEPRUP commonblock with info
80224 C...on incoming beams and allowed processes.
80225 
80226 C...New example: handles a standard Les Houches Events File.
80227 
80228  SUBROUTINE upinit
80229 
80230 C...Double precision and integer declarations.
80231  IMPLICIT DOUBLE PRECISION(a-h, o-z)
80232  IMPLICIT INTEGER(i-n)
80233 
80234 C...PYTHIA commonblock: only used to provide read unit MSTP(161).
80235  common/pypars/mstp(200),parp(200),msti(200),pari(200)
80236  SAVE /pypars/
80237 
80238 C...User process initialization commonblock.
80239  INTEGER maxpup
80240  parameter(maxpup=100)
80241  INTEGER idbmup,pdfgup,pdfsup,idwtup,nprup,lprup
80242  DOUBLE PRECISION ebmup,xsecup,xerrup,xmaxup
80243  common/heprup/idbmup(2),ebmup(2),pdfgup(2),pdfsup(2),
80244  &idwtup,nprup,xsecup(maxpup),xerrup(maxpup),xmaxup(maxpup),
80245  &lprup(maxpup)
80246  SAVE /heprup/
80247 
80248 C...Lines to read in assumed never longer than 200 characters.
80249  parameter(maxlen=200)
80250  CHARACTER*(MAXLEN) string
80251 
80252 C...Format for reading lines.
80253  CHARACTER*6 strfmt
80254  strfmt='(A000)'
80255  WRITE(strfmt(3:5),'(I3)') maxlen
80256 
80257 C...Loop until finds line beginning with "<init>" or "<init ".
80258  100 READ(mstp(161),strfmt,end=130,err=130) string
80259  ibeg=0
80260  110 ibeg=ibeg+1
80261 C...Allow indentation.
80262  IF(string(ibeg:ibeg).EQ.' '.AND.ibeg.LT.maxlen-5) goto 110
80263  IF(string(ibeg:ibeg+5).NE.'<init>'.AND.
80264  &string(ibeg:ibeg+5).NE.'<init ') goto 100
80265 
80266 C...Read first line of initialization info.
80267  READ(mstp(161),*,end=130,err=130) idbmup(1),idbmup(2),ebmup(1),
80268  &ebmup(2),pdfgup(1),pdfgup(2),pdfsup(1),pdfsup(2),idwtup,nprup
80269 
80270 C...Read NPRUP subsequent lines with information on each process.
80271  DO 120 ipr=1,nprup
80272  READ(mstp(161),*,end=130,err=130) xsecup(ipr),xerrup(ipr),
80273  & xmaxup(ipr),lprup(ipr)
80274  120 CONTINUE
80275  RETURN
80276 
80277 C...Error exit: give up if initalization does not work.
80278  130 WRITE(*,*) ' Failed to read LHEF initialization information.'
80279  WRITE(*,*) ' Event generation will be stopped.'
80280  CALL pystop(12)
80281 
80282  RETURN
80283  END
80284 
80285 C...Old example: handles a simple Pythia 6.4 initialization file.
80286 
80287 c SUBROUTINE UPINIT
80288 
80289 C...Double precision and integer declarations.
80290 c IMPLICIT DOUBLE PRECISION(A-H, O-Z)
80291 c IMPLICIT INTEGER(I-N)
80292 
80293 C...Commonblocks.
80294 c COMMON/PYDAT1/MSTU(200),PARU(200),MSTJ(200),PARJ(200)
80295 c COMMON/PYPARS/MSTP(200),PARP(200),MSTI(200),PARI(200)
80296 c SAVE /PYDAT1/,/PYPARS/
80297 
80298 C...User process initialization commonblock.
80299 c INTEGER MAXPUP
80300 c PARAMETER (MAXPUP=100)
80301 c INTEGER IDBMUP,PDFGUP,PDFSUP,IDWTUP,NPRUP,LPRUP
80302 c DOUBLE PRECISION EBMUP,XSECUP,XERRUP,XMAXUP
80303 c COMMON/HEPRUP/IDBMUP(2),EBMUP(2),PDFGUP(2),PDFSUP(2),
80304 c &IDWTUP,NPRUP,XSECUP(MAXPUP),XERRUP(MAXPUP),XMAXUP(MAXPUP),
80305 c &LPRUP(MAXPUP)
80306 c SAVE /HEPRUP/
80307 
80308 C...Read info from file.
80309 c IF(MSTP(161).GT.0) THEN
80310 c READ(MSTP(161),*,END=110,ERR=110) IDBMUP(1),IDBMUP(2),EBMUP(1),
80311 c & EBMUP(2),PDFGUP(1),PDFGUP(2),PDFSUP(1),PDFSUP(2),IDWTUP,NPRUP
80312 c DO 100 IPR=1,NPRUP
80313 c READ(MSTP(161),*,END=110,ERR=110) XSECUP(IPR),XERRUP(IPR),
80314 c & XMAXUP(IPR),LPRUP(IPR)
80315 c 100 CONTINUE
80316 c RETURN
80317 C...Error or prematurely reached end of file.
80318 c 110 WRITE(MSTU(11),5000)
80319 c STOP
80320 
80321 C...Else not implemented.
80322 c ELSE
80323 c WRITE(MSTU(11),5100)
80324 c STOP
80325 c ENDIF
80326 
80327 C...Format for error printout.
80328 c 5000 FORMAT(1X,'Error: UPINIT routine failed to read information'/
80329 c &1X,'Execution stopped!')
80330 c 5100 FORMAT(1X,'Error: You have not implemented UPINIT routine'/
80331 c &1X,'Dummy routine in PYTHIA file called instead.'/
80332 c &1X,'Execution stopped!')
80333 
80334 c RETURN
80335 c END
80336 
80337 C*********************************************************************
80338 
80339 C...UPEVNT
80340 C...Dummy routine, to be replaced by a user implementing external
80341 C...processes. Depending on cross section model chosen, it either has
80342 C...to generate a process of the type IDPRUP requested, or pick a type
80343 C...itself and generate this event. The event is to be stored in the
80344 C...HEPEUP commonblock, including (often) an event weight.
80345 
80346 C...New example: handles a standard Les Houches Events File.
80347 
80348  SUBROUTINE upevnt
80349 
80350 C...Double precision and integer declarations.
80351  IMPLICIT DOUBLE PRECISION(a-h, o-z)
80352  IMPLICIT INTEGER(i-n)
80353 
80354 C...PYTHIA commonblock: only used to provide read unit MSTP(162).
80355  common/pypars/mstp(200),parp(200),msti(200),pari(200)
80356  SAVE /pypars/
80357 
80358 C...User process event common block.
80359  INTEGER maxnup
80360  parameter(maxnup=500)
80361  INTEGER nup,idprup,idup,istup,mothup,icolup
80362  DOUBLE PRECISION xwgtup,scalup,aqedup,aqcdup,pup,vtimup,spinup
80363  common/hepeup/nup,idprup,xwgtup,scalup,aqedup,aqcdup,idup(maxnup),
80364  &istup(maxnup),mothup(2,maxnup),icolup(2,maxnup),pup(5,maxnup),
80365  &vtimup(maxnup),spinup(maxnup)
80366  SAVE /hepeup/
80367 
80368 C...Lines to read in assumed never longer than 200 characters.
80369  parameter(maxlen=200)
80370  CHARACTER*(MAXLEN) string
80371 
80372 C...Format for reading lines.
80373  CHARACTER*6 strfmt
80374  strfmt='(A000)'
80375  WRITE(strfmt(3:5),'(I3)') maxlen
80376 
80377 C...Loop until finds line beginning with "<event>" or "<event ".
80378  100 READ(mstp(162),strfmt,end=130,err=130) string
80379  ibeg=0
80380  110 ibeg=ibeg+1
80381 C...Allow indentation.
80382  IF(string(ibeg:ibeg).EQ.' '.AND.ibeg.LT.maxlen-6) goto 110
80383  IF(string(ibeg:ibeg+6).NE.'<event>'.AND.
80384  &string(ibeg:ibeg+6).NE.'<event ') goto 100
80385 
80386 C...Read first line of event info.
80387  READ(mstp(162),*,end=130,err=130) nup,idprup,xwgtup,scalup,
80388  &aqedup,aqcdup
80389 
80390 C...Read NUP subsequent lines with information on each particle.
80391  DO 120 i=1,nup
80392  READ(mstp(162),*,end=130,err=130) idup(i),istup(i),
80393  & mothup(1,i),mothup(2,i),icolup(1,i),icolup(2,i),
80394  & (pup(j,i),j=1,5),vtimup(i),spinup(i)
80395  120 CONTINUE
80396  RETURN
80397 
80398 C...Error exit, typically when no more events.
80399  130 WRITE(*,*) ' Failed to read LHEF event information.'
80400  WRITE(*,*) ' Will assume end of file has been reached.'
80401  nup=0
80402  msti(51)=1
80403 
80404  RETURN
80405  END
80406 
80407 C...Old example: handles a simple Pythia 6.4 event file.
80408 
80409 c SUBROUTINE UPEVNT
80410 
80411 C...Double precision and integer declarations.
80412 c IMPLICIT DOUBLE PRECISION(A-H, O-Z)
80413 c IMPLICIT INTEGER(I-N)
80414 
80415 C...Commonblocks.
80416 c COMMON/PYDAT1/MSTU(200),PARU(200),MSTJ(200),PARJ(200)
80417 c COMMON/PYPARS/MSTP(200),PARP(200),MSTI(200),PARI(200)
80418 c SAVE /PYDAT1/,/PYPARS/
80419 
80420 C...User process event common block.
80421 c INTEGER MAXNUP
80422 c PARAMETER (MAXNUP=500)
80423 c INTEGER NUP,IDPRUP,IDUP,ISTUP,MOTHUP,ICOLUP
80424 c DOUBLE PRECISION XWGTUP,SCALUP,AQEDUP,AQCDUP,PUP,VTIMUP,SPINUP
80425 c COMMON/HEPEUP/NUP,IDPRUP,XWGTUP,SCALUP,AQEDUP,AQCDUP,IDUP(MAXNUP),
80426 c &ISTUP(MAXNUP),MOTHUP(2,MAXNUP),ICOLUP(2,MAXNUP),PUP(5,MAXNUP),
80427 c &VTIMUP(MAXNUP),SPINUP(MAXNUP)
80428 c SAVE /HEPEUP/
80429 
80430 C...Read info from file.
80431 c IF(MSTP(162).GT.0) THEN
80432 c READ(MSTP(162),*,END=110,ERR=110) NUP,IDPRUP,XWGTUP,SCALUP,
80433 c & AQEDUP,AQCDUP
80434 c DO 100 I=1,NUP
80435 c READ(MSTP(162),*,END=110,ERR=110) IDUP(I),ISTUP(I),
80436 c & MOTHUP(1,I),MOTHUP(2,I),ICOLUP(1,I),ICOLUP(2,I),
80437 c & (PUP(J,I),J=1,5),VTIMUP(I),SPINUP(I)
80438 c 100 CONTINUE
80439 c RETURN
80440 C...Special when reached end of file or other error.
80441 c 110 NUP=0
80442 
80443 C...Else not implemented.
80444 c ELSE
80445 c WRITE(MSTU(11),5000)
80446 c STOP
80447 c ENDIF
80448 
80449 C...Format for error printout.
80450 c 5000 FORMAT(1X,'Error: You have not implemented UPEVNT routine'/
80451 c &1X,'Dummy routine in PYTHIA file called instead.'/
80452 c &1X,'Execution stopped!')
80453 
80454 c RETURN
80455 c END
80456 
80457 C*********************************************************************
80458 
80459 C...UPVETO
80460 C...Dummy routine, to be replaced by user, to veto event generation
80461 C...on the parton level, after parton showers but before multiple
80462 C...interactions, beam remnants and hadronization is added.
80463 C...If resonances like W, Z, top, Higgs and SUSY particles are handed
80464 C...undecayed from UPEVNT, or are generated by PYTHIA, they will also
80465 C...be undecayed at this stage; if decayed their decay products will
80466 C...have been allowed to shower.
80467 
80468 C...All partons at the end of the shower phase are stored in the
80469 C...HEPEVT commonblock. The interesting information is
80470 C...NHEP = the number of such partons, in entries 1 <= i <= NHEP,
80471 C...IDHEP(I) = the particle ID code according to PDG conventions,
80472 C...PHEP(J,I) = the (p_x, p_y, p_z, E, m) of the particle.
80473 C...All ISTHEP entries are 1, while the rest is zeroed.
80474 
80475 C...The user decision is to be conveyed by the IVETO value.
80476 C...IVETO = 0 : retain current event and generate in full;
80477 C... = 1 : abort generation of current event and move to next.
80478 
80479  SUBROUTINE upveto(IVETO)
80480 
80481 C...HEPEVT commonblock.
80482  parameter(nmxhep=4000)
80483  common/hepevt/nevhep,nhep,isthep(nmxhep),idhep(nmxhep),
80484  &jmohep(2,nmxhep),jdahep(2,nmxhep),phep(5,nmxhep),vhep(4,nmxhep)
80485  DOUBLE PRECISION phep,vhep
80486  SAVE /hepevt/
80487 
80488 C...Next few lines allow you to see what info PYVETO extracted from
80489 C...the full event record for the first two events.
80490 C...Delete if you don't want it.
80491  DATA nlist/0/
80492  SAVE nlist
80493  IF(nlist.LE.2) THEN
80494  WRITE(*,*) ' Full event record at time of UPVETO call:'
80495  CALL pylist(1)
80496  WRITE(*,*) ' Part of event record made available to UPVETO:'
80497  CALL pylist(5)
80498  nlist=nlist+1
80499  ENDIF
80500 
80501 C...Make decision here.
80502  iveto = 0
80503 
80504  RETURN
80505  END
80506 
80507 ! C*********************************************************************
80508 !
80509 ! C...PDFSET
80510 ! C...Dummy routine, to be removed when PDFLIB is to be linked.
80511 !
80512 ! SUBROUTINE PDFSET(PARM,VALUE)
80513 !
80514 ! C...Double precision and integer declarations.
80515 ! IMPLICIT DOUBLE PRECISION(A-H, O-Z)
80516 ! IMPLICIT INTEGER(I-N)
80517 ! INTEGER PYK,PYCHGE,PYCOMP
80518 ! C...Commonblocks.
80519 ! COMMON/PYDAT1/MSTU(200),PARU(200),MSTJ(200),PARJ(200)
80520 ! SAVE /PYDAT1/
80521 ! C...Local arrays and character variables.
80522 ! CHARACTER*20 PARM(20)
80523 ! DOUBLE PRECISION VALUE(20)
80524 !
80525 ! C...Stop program if this routine is ever called.
80526 ! WRITE(MSTU(11),5000)
80527 ! CALL PYSTOP(5)
80528 ! PARM(20)=PARM(1)
80529 ! VALUE(20)=VALUE(1)
80530 !
80531 ! C...Format for error printout.
80532 ! 5000 FORMAT(1X,'Error: you did not link PDFLIB correctly.'/
80533 ! &1X,'Dummy routine PDFSET in PYTHIA file called instead.'/
80534 ! &1X,'Execution stopped!')
80535 !
80536 ! RETURN
80537 ! END
80538 !
80539 ! C*********************************************************************
80540 !
80541 ! C...STRUCTM
80542 ! C...Dummy routine, to be removed when PDFLIB is to be linked.
80543 !
80544 ! SUBROUTINE STRUCTM(XX,QQ,UPV,DNV,USEA,DSEA,STR,CHM,BOT,TOP,GLU)
80545 !
80546 ! C...Double precision and integer declarations.
80547 ! IMPLICIT DOUBLE PRECISION(A-H, O-Z)
80548 ! IMPLICIT INTEGER(I-N)
80549 ! INTEGER PYK,PYCHGE,PYCOMP
80550 ! C...Commonblocks.
80551 ! COMMON/PYDAT1/MSTU(200),PARU(200),MSTJ(200),PARJ(200)
80552 ! SAVE /PYDAT1/
80553 ! C...Local variables
80554 ! DOUBLE PRECISION XX,QQ,UPV,DNV,USEA,DSEA,STR,CHM,BOT,TOP,GLU
80555 !
80556 ! C...Stop program if this routine is ever called.
80557 ! WRITE(MSTU(11),5000)
80558 ! CALL PYSTOP(5)
80559 ! UPV=XX+QQ
80560 ! DNV=XX+2D0*QQ
80561 ! USEA=XX+3D0*QQ
80562 ! DSEA=XX+4D0*QQ
80563 ! STR=XX+5D0*QQ
80564 ! CHM=XX+6D0*QQ
80565 ! BOT=XX+7D0*QQ
80566 ! TOP=XX+8D0*QQ
80567 ! GLU=XX+9D0*QQ
80568 !
80569 ! C...Format for error printout.
80570 ! 5000 FORMAT(1X,'Error: you did not link PDFLIB correctly.'/
80571 ! &1X,'Dummy routine STRUCTM in PYTHIA file called instead.'/
80572 ! &1X,'Execution stopped!')
80573 !
80574 ! RETURN
80575 ! END
80576 !
80577 ! C*********************************************************************
80578 !
80579 ! C...STRUCTP
80580 ! C...Dummy routine, to be removed when PDFLIB is to be linked.
80581 !
80582 ! SUBROUTINE STRUCTP(XX,QQ2,P2,IP2,UPV,DNV,USEA,DSEA,STR,CHM,
80583 ! &BOT,TOP,GLU)
80584 !
80585 ! C...Double precision and integer declarations.
80586 ! IMPLICIT DOUBLE PRECISION(A-H, O-Z)
80587 ! IMPLICIT INTEGER(I-N)
80588 ! INTEGER PYK,PYCHGE,PYCOMP
80589 ! C...Commonblocks.
80590 ! COMMON/PYDAT1/MSTU(200),PARU(200),MSTJ(200),PARJ(200)
80591 ! SAVE /PYDAT1/
80592 ! C...Local variables
80593 ! DOUBLE PRECISION XX,QQ2,P2,UPV,DNV,USEA,DSEA,STR,CHM,BOT,
80594 ! &TOP,GLU
80595 !
80596 ! C...Stop program if this routine is ever called.
80597 ! WRITE(MSTU(11),5000)
80598 ! CALL PYSTOP(5)
80599 ! UPV=XX+QQ2
80600 ! DNV=XX+2D0*QQ2
80601 ! USEA=XX+3D0*QQ2
80602 ! DSEA=XX+4D0*QQ2
80603 ! STR=XX+5D0*QQ2
80604 ! CHM=XX+6D0*QQ2
80605 ! BOT=XX+7D0*QQ2
80606 ! TOP=XX+8D0*QQ2
80607 ! GLU=XX+9D0*QQ2
80608 !
80609 ! C...Format for error printout.
80610 ! 5000 FORMAT(1X,'Error: you did not link PDFLIB correctly.'/
80611 ! &1X,'Dummy routine STRUCTP in PYTHIA file called instead.'/
80612 ! &1X,'Execution stopped!')
80613 !
80614 ! RETURN
80615 ! END
80616 
80617 C*********************************************************************
80618 
80619 C...SUGRA
80620 C...Dummy routine, to be removed when ISAJET (ISASUSY) is to be linked.
80621 
80622  SUBROUTINE sugra(MZERO,MHLF,AZERO,TANB,SGNMU,MTOP,IMODL)
80623  IMPLICIT DOUBLE PRECISION(a-h, o-z)
80624  IMPLICIT INTEGER(i-n)
80625  REAL mzero,mhlf,azero,tanb,sgnmu,mtop
80626  INTEGER imodl
80627 C...Commonblocks.
80628  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
80629  SAVE /pydat1/
80630 
80631 C...Stop program if this routine is ever called.
80632  WRITE(mstu(11),5000)
80633  CALL pystop(110)
80634 
80635 C...Format for error printout.
80636  5000 FORMAT(1x,'Error: you did not link ISAJET correctly.'/
80637  &1x,'Dummy routine SUGRA in PYTHIA file called instead.'/
80638  &1x,'Execution stopped!')
80639 
80640  RETURN
80641  END
80642 
80643 C*********************************************************************
80644 
80645 C...VISAJE
80646 C...Dummy function, to be removed when ISAJET (ISASUSY) is to be linked.
80647 
80648  FUNCTION visaje()
80649  IMPLICIT DOUBLE PRECISION(a-h, o-z)
80650  IMPLICIT INTEGER(i-n)
80651  CHARACTER*40 visaje
80652 
80653 C...Commonblocks.
80654  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
80655  SAVE /pydat1/
80656 
80657 C...Assign default value.
80658  visaje='Undefined'
80659 
80660 C...Stop program if this routine is ever called.
80661  WRITE(mstu(11),5000)
80662  CALL pystop(110)
80663 
80664 C...Format for error printout.
80665  5000 FORMAT(1x,'Error: you did not link ISAJET correctly.'/
80666  &1x,'Dummy function VISAJE in PYTHIA file called instead.'/
80667  &1x,'Execution stopped!')
80668 
80669  RETURN
80670  END
80671 
80672 C*********************************************************************
80673 
80674 C...SSMSSM
80675 C...Dummy function, to be removed when ISAJET (ISASUSY) is to be linked.
80676 
80677  SUBROUTINE ssmssm(RDUM1,RDUM2,RDUM3,RDUM4,RDUM5,RDUM6,RDUM7,
80678  &rdum8,rdum9,rdum10,rdum11,rdum12,rdum13,rdum14,rdum15,rdum16,
80679  &rdum17,rdum18,rdum19,rdum20,rdum21,rdum22,rdum23,rdum24,rdum25,
80680  &idum1,idum2)
80681  IMPLICIT DOUBLE PRECISION(a-h, o-z)
80682  IMPLICIT INTEGER(i-n)
80683  REAL rdum1,rdum2,rdum3,rdum4,rdum5,rdum6,rdum7,rdum8,rdum9,
80684  &rdum10,rdum11,rdum12,rdum13,rdum14,rdum15,rdum16,rdum17,rdum18,
80685  &rdum19,rdum20,rdum21,rdum22,rdum23,rdum24,rdum25
80686 C...Commonblocks.
80687  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
80688  SAVE /pydat1/
80689 
80690 C...Stop program if this routine is ever called.
80691  WRITE(mstu(11),5000)
80692  CALL pystop(110)
80693 
80694 C...Format for error printout.
80695  5000 FORMAT(1x,'Error: you did not link ISAJET correctly.'/
80696  &1x,'Dummy routine SSMSSM in PYTHIA file called instead.'/
80697  &1x,'Execution stopped!')
80698  RETURN
80699  END
80700 
80701 C*********************************************************************
80702 
80703 C...FHSETFLAGS
80704 C...Dummy function, to be removed when FEYNHIGGS is to be linked.
80705 
80706  SUBROUTINE fhsetflags(IERR,IMSP,IFR,ITBR,IHMX,IP2A,ILP,ITR,IBR)
80707  IMPLICIT DOUBLE PRECISION(a-h, o-z)
80708  IMPLICIT INTEGER(i-n)
80709 Cmssmpart = 4 # full MSSM [recommended]
80710 Cfieldren = 0 # MSbar field ren. [strongly recommended]
80711 Ctanbren = 0 # MSbar TB-ren. [strongly recommended]
80712 Chiggsmix = 2 # 2x2 (h0-HH) mixing in the neutral Higgs sector
80713 Cp2approx = 0 # no approximation [recommended]
80714 Clooplevel= 2 # include 2-loop corrections
80715 Ctl_running_mt= 1 # running top mass in 2-loop corrections [recommended]
80716 Ctl_bot_resum = 1 # resummed MB in 2-loop corrections [recommended]
80717 
80718 C...Commonblocks.
80719  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
80720  SAVE /pydat1/
80721 
80722 C...Stop program if this routine is ever called.
80723  WRITE(mstu(11),5000)
80724  CALL pystop(103)
80725 
80726 C...Format for error printout.
80727  5000 FORMAT(1x,'Error: you did not link FEYNHIGGS correctly.'/
80728  &1x,'Dummy routine FHSETFLAGS in PYTHIA file called instead.'/
80729  &1x,'Execution stopped!')
80730  RETURN
80731  END
80732 
80733 C*********************************************************************
80734 
80735 C...FHSETPARA
80736 C...Dummy function, to be removed when FEYNHIGGS is to be linked.
80737 
80738  SUBROUTINE fhsetpara(IER,SCF,DMT,DMB,DMW,DMZ,DTANB,DMA,DMH,DM3L,
80739  & dm3e,dm3q,dm3u,dm3d,dm2l,dm2e,dm2q,dm2u, dm2d,dm1l,dm1e,dm1q,
80740  & dm1u,dm1d,dmu,ae33,au33,ad33,ae22,au22,ad22,ae11,au11,ad11,
80741  & dm1,dm2,dm3,rlt,rlb,qtau,qt,qb)
80742  IMPLICIT DOUBLE PRECISION(a-h, o-z)
80743  IMPLICIT INTEGER(i-n)
80744 
80745  DOUBLE COMPLEX saeff, uhiggs(3,3)
80746  DOUBLE COMPLEX dmu,
80747  & ae33, au33, ad33, ae22, au22, ad22, ae11, au11, ad11,
80748  & dm1, dm2, dm3
80749 
80750 C...Commonblocks.
80751  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
80752  SAVE /pydat1/
80753 
80754 C...Stop program if this routine is ever called.
80755  WRITE(mstu(11),5000)
80756  CALL pystop(103)
80757 
80758 C...Format for error printout.
80759  5000 FORMAT(1x,'Error: you did not link FEYNHIGGS correctly.'/
80760  &1x,'Dummy routine FHSETPARA in PYTHIA file called instead.'/
80761  &1x,'Execution stopped!')
80762  RETURN
80763  END
80764 
80765 C*********************************************************************
80766 
80767 C...FHHIGGSCORR
80768 C...Dummy function, to be removed when FEYNHIGGS is to be linked.
80769 
80770  SUBROUTINE fhhiggscorr(IERR, RMHIGG, SAEFF, UHIGGS)
80771  IMPLICIT DOUBLE PRECISION(a-h, o-z)
80772  IMPLICIT INTEGER(i-n)
80773 
80774 C...FeynHiggs variables
80775  DOUBLE PRECISION rmhigg(4)
80776  DOUBLE COMPLEX saeff, uhiggs(3,3)
80777  DOUBLE COMPLEX dmu,
80778  & ae33, au33, ad33, ae22, au22, ad22, ae11, au11, ad11,
80779  & dm1, dm2, dm3
80780 
80781 C...Commonblocks.
80782  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
80783  SAVE /pydat1/
80784 
80785 C...Stop program if this routine is ever called.
80786  WRITE(mstu(11),5000)
80787  CALL pystop(103)
80788 
80789 C...Format for error printout.
80790  5000 FORMAT(1x,'Error: you did not link FEYNHIGGS correctly.'/
80791  &1x,'Dummy routine FHSETPARA in PYTHIA file called instead.'/
80792  &1x,'Execution stopped!')
80793  RETURN
80794  END
80795 
80796 C*********************************************************************
80797 
80798 C...PYTAUD
80799 C...Dummy routine, to be replaced by user, to handle the decay of a
80800 C...polarized tau lepton.
80801 C...Input:
80802 C...ITAU is the position where the decaying tau is stored in /PYJETS/.
80803 C...IORIG is the position where the mother of the tau is stored;
80804 C... is 0 when the mother is not stored.
80805 C...KFORIG is the flavour of the mother of the tau;
80806 C... is 0 when the mother is not known.
80807 C...Note that IORIG=0 does not necessarily imply KFORIG=0;
80808 C... e.g. in B hadron semileptonic decays the W propagator
80809 C... is not explicitly stored but the W code is still unambiguous.
80810 C...Output:
80811 C...NDECAY is the number of decay products in the current tau decay.
80812 C...These decay products should be added to the /PYJETS/ common block,
80813 C...in positions N+1 through N+NDECAY. For each product I you must
80814 C...give the flavour codes K(I,2) and the five-momenta P(I,1), P(I,2),
80815 C...P(I,3), P(I,4) and P(I,5). The rest will be stored automatically.
80816 
80817  SUBROUTINE pytaud(ITAU,IORIG,KFORIG,NDECAY)
80818 
80819 C...Double precision and integer declarations.
80820  IMPLICIT DOUBLE PRECISION(a-h, o-z)
80821  IMPLICIT INTEGER(i-n)
80822  INTEGER pyk,pychge,pycomp
80823 C...Commonblocks.
80824  common/pyjets/n,npad,k(23000,5),p(23000,5),v(23000,5)
80825  common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
80826  SAVE /pyjets/,/pydat1/
80827 
80828 C...Stop program if this routine is ever called.
80829 C...You should not copy these lines to your own routine.
80830  ndecay=itau+iorig+kforig
80831  WRITE(mstu(11),5000)
80832  CALL pystop(10)
80833 
80834 C...Format for error printout.
80835  5000 FORMAT(1x,'Error: you did not link your PYTAUD routine ',
80836  &'correctly.'/1x,'Dummy routine in PYTHIA file called instead.'/
80837  &1x,'Execution stopped!')
80838 
80839  RETURN
80840  END
80841 
80842 C*********************************************************************
80843 
80844 C...PYTIME
80845 C...Finds current date and time.
80846 C...Since this task is not standardized in Fortran 77, the routine
80847 C...is dummy, to be replaced by the user. Examples are given for
80848 C...the Fortran 90 routine and DEC Fortran 77, and what to do if
80849 C...you do not have access to suitable routines.
80850 
80851  SUBROUTINE pytime(IDATI)
80852 
80853 C...Double precision and integer declarations.
80854  IMPLICIT DOUBLE PRECISION(a-h, o-z)
80855  IMPLICIT INTEGER(i-n)
80856  INTEGER pyk,pychge,pycomp
80857  CHARACTER*8 atime
80858 C...Local array.
80859  INTEGER idati(6),idtemp(3),ival(8)
80860 
80861 C...Example 0: if you do not have suitable routines.
80862  DO 100 j=1,6
80863  idati(j)=0
80864  100 CONTINUE
80865 
80866 C...Example 1: Fortran 90 routine.
80867 C CALL DATE_AND_TIME(VALUES=IVAL)
80868 C IDATI(1)=IVAL(1)
80869 C IDATI(2)=IVAL(2)
80870 C IDATI(3)=IVAL(3)
80871 C IDATI(4)=IVAL(5)
80872 C IDATI(5)=IVAL(6)
80873 C IDATI(6)=IVAL(7)
80874 
80875 C...Example 2: DEC Fortran 77. AIX.
80876 C CALL IDATE(IMON,IDAY,IYEAR)
80877 C IDATI(1)=IYEAR
80878 C IDATI(2)=IMON
80879 C IDATI(3)=IDAY
80880 C CALL ITIME(IHOUR,IMIN,ISEC)
80881 C IDATI(4)=IHOUR
80882 C IDATI(5)=IMIN
80883 C IDATI(6)=ISEC
80884 
80885 C...Example 3: DEC Fortran, IRIX, IRIX64.
80886 C CALL IDATE(IMON,IDAY,IYEAR)
80887 C IDATI(1)=IYEAR
80888 C IDATI(2)=IMON
80889 C IDATI(3)=IDAY
80890 C CALL TIME(ATIME)
80891 C IHOUR=0
80892 C IMIN=0
80893 C ISEC=0
80894 C READ(ATIME(1:2),'(I2)') IHOUR
80895 C READ(ATIME(4:5),'(I2)') IMIN
80896 C READ(ATIME(7:8),'(I2)') ISEC
80897 C IDATI(4)=IHOUR
80898 C IDATI(5)=IMIN
80899 C IDATI(6)=ISEC
80900 
80901 C...Example 4: GNU LINUX libU77, SunOS.
80902 C CALL IDATE(IDTEMP)
80903 C IDATI(1)=IDTEMP(3)
80904 C IDATI(2)=IDTEMP(2)
80905 C IDATI(3)=IDTEMP(1)
80906 C CALL ITIME(IDTEMP)
80907 C IDATI(4)=IDTEMP(1)
80908 C IDATI(5)=IDTEMP(2)
80909 C IDATI(6)=IDTEMP(3)
80910 
80911 C...Common code to ensure right century.
80912  idati(1)=2000+mod(idati(1),100)
80913 
80914  RETURN
80915  END