-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen_radiation.f
660 lines (642 loc) · 20.3 KB
/
gen_radiation.f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
subroutine pwhgevent
implicit none
include 'pwhg_math.h'
include 'nlegborn.h'
include 'pwhg_flst.h'
include 'pwhg_flg.h'
include 'pwhg_kn.h'
include 'pwhg_rad.h'
include 'LesHouches.h'
integer iret,iun
real * 8 suppfact
real * 8 random,powheginput
external random,powheginput
integer mcalls,icalls
real * 8 pwhg_pt2,pt2max_regular
external pwhg_pt2,pt2max_regular
real * 8 weight
integer i
if(idwtup.eq.3) then
weight=1
elseif(idwtup.eq.-4) then
weight=rad_totgen * rad_branching
else
write(*,*) ' only 3 and -4 are allowed for idwtup'
call exit(-1)
endif
c store current random seeds. To be used to restart at problematic events
call savecurrentrandom
if(random().gt.rad_totrm/rad_totgen) then
c generate underlying Born kinematics
call gen_btilde(mcalls,icalls)
c generate underlying Born flavour
call gen_uborn_idx
c
if(powheginput('#testsuda').eq.1) then
call testsuda
endif
c generate radiation
call gen_radiation
c add a random azimuthal rotation around beam axis
call add_azimuth
c --- set up les houches interface
rad_pt2max=pwhg_pt2()
call gen_leshouches
c if negative weight, flip the sign of weight
if(rad_btilde_sign(rad_ubornidx).eq.-1) then
weight=-weight
endif
c rad_type=1 for btilde events (used only for debugging purposes)
rad_type=1
call increasecnt("btilde event")
else
c generate remnant n+1 body cross section
call gen_sigremnant
c pick a configuration according to its cross section
c iret=1: rem contribution (leftover from damping factor on R)
c iret=2: reg contribution (real graphs without singular regions)
call gen_remnant(iret)
c if (pwhg_pt2().lt.rad_ptsqmin) then
c write(*,*) '****************************************'
c write(*,*) 'WARNING in gen_remnant'
c write(*,*) 'pwhg_pt2 < rad_ptsqmin ',
c # pwhg_pt2(),' < ',rad_ptsqmin
c write(*,*) (flst_alr(i,rad_realalr),i=1,nlegreal)
c write(*,*) 'To generate this event, use the following seeds'
c call printcurrentrandom
c write(*,*) '****************************************'
c endif
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
call add_azimuth
if(iret.eq.1) then
c set st_muren2 equal to pt2 for scalup value
rad_pt2max=max(rad_ptsqmin,pwhg_pt2())
call set_rad_scales(rad_pt2max)
call gen_leshouches
c rad_type=2 for remnants
rad_type=2
call increasecnt("remnant event")
else
c set st_muren2 for scalup value for regular contributions
rad_pt2max=max(rad_ptsqmin,pt2max_regular())
call set_rad_scales(rad_pt2max)
call gen_leshouches_reg
c rad_type=3 for regular contributions
rad_type=3
call increasecnt("regular event")
endif
endif
if(flg_weightedev) then
call born_suppression(suppfact)
if(suppfact.eq.0) then
write(*,*) ' 0 suppression factor in event generation'
write(*,*) ' aborting'
call exit(-1)
endif
weight=weight/suppfact
endif
xwgtup = weight
end
subroutine gen_radiation
implicit none
include 'pwhg_math.h'
include 'nlegborn.h'
include 'pwhg_flst.h'
include 'pwhg_kn.h'
include 'pwhg_rad.h'
real * 8 t,csi,y,azi,sig,born
real * 8 tmax
common/ctmax/tmax
integer kinreg,firstreg,lastreg
logical ini
data ini/.true./
real * 8 pwhg_pt2,powheginput
external pwhg_pt2,powheginput
save ini,firstreg,lastreg
if(ini) then
firstreg=powheginput("#radregion")
if(firstreg.le.0) then
firstreg=1
lastreg=rad_nkinreg
else
lastreg=firstreg
endif
ini=.false.
endif
c Use highest bid procedure (see appendix B of FNO2006)
tmax=0
kinreg=0
do rad_kinreg=firstreg,lastreg
if(rad_kinreg_on(rad_kinreg)) then
if(rad_kinreg.eq.1) then
c initial state radiation
call gen_rad_isr(t)
else
c final state radiation
call gen_rad_fsr(t)
endif
if(t.gt.tmax) then
tmax=t
kinreg=rad_kinreg
csi=kn_csi
y=kn_y
azi=kn_azi
endif
endif
enddo
c Set up radiation kinematics
if(tmax.eq.0) then
c Generate a Born like event
kn_csi=0
rad_kinreg=0
return
else
rad_kinreg=kinreg
kn_csi=csi
kn_y=y
kn_azi=azi
t=tmax
if(rad_kinreg.eq.1) then
call gen_real_phsp_isr_rad
else
call gen_real_phsp_fsr_rad
endif
call set_rad_scales(t)
c We call sigborn_rad now, becayse the real may depend
c upon the Born throught the soft and collinear terms,
c that are used in the real if bornzerodamp is used.
c Failing to do so may cause problems in picking the
c flavour
call sigborn_rad(born)
call sigreal_rad(sig)
call gen_real_idx
endif
end
function pwhg_pt2()
implicit none
real * 8 pwhg_pt2
include 'pwhg_math.h'
include 'nlegborn.h'
include 'pwhg_flst.h'
include 'pwhg_kn.h'
include 'pwhg_rad.h'
if(rad_kinreg.eq.1) then
pwhg_pt2=(kn_sreal/4)*(1-kn_y**2)*kn_csi**2
else
pwhg_pt2=(kn_sreal/2)*(1-kn_y)*kn_csi**2
endif
end
function pwhg_upperb_rad()
implicit none
real * 8 pwhg_upperb_rad
include 'pwhg_math.h'
include 'nlegborn.h'
include 'pwhg_flst.h'
include 'pwhg_kn.h'
include 'pwhg_rad.h'
include 'pwhg_st.h'
real * 8 x,y,csi
csi=kn_csi
x=1-csi
y=kn_y
if(rad_kinreg.eq.1) then
if(rad_iupperisr.eq.1) then
pwhg_upperb_rad = st_alpha/((1-x)*(1-y**2))
c Possible alternatives:
c rad_iupper=2 pwhg_upperb_rad = st_alpha/(x*(1-x)*(1-y**2))
c
c rad_iupper=3: pwhg_upperb_rad = st_alpha/(x**2*(1-x)*(1-y**2))
else
write(*,*) ' rad_iupper=',rad_iupperisr,
1 'alternative not implemented'
call exit(1)
endif
else
c for now use the same
if(rad_iupperfsr.eq.1) then
pwhg_upperb_rad = st_alpha/(csi*(1-y))
elseif(rad_iupperfsr.eq.2) then
pwhg_upperb_rad = st_alpha/(csi**2*(1-y)*(1-csi/2*(1-y))**2)
2 *csi
elseif(rad_iupperfsr.eq.3) then
pwhg_upperb_rad = st_alpha/(csi*(1-y)*
2 (1-csi/2*(1-y)))
else
write(*,*) ' rad_iupper=',rad_iupperfsr,
1 'alternative not implemented'
call exit(1)
endif
endif
end
function pt2solve(pt2,i)
c Returns xlr - log(Delta^{(tilde{V})}) , see eq. D14, D15 in ZZ paper
c We use it to find its zero in pt2.
implicit none
include 'nlegborn.h'
include 'pwhg_flst.h'
include 'pwhg_kn.h'
include 'pwhg_rad.h'
include 'pwhg_math.h'
real * 8 pt2solve,pt2
c i set by dzero: 1 for first call, 2 for subsequent calls, 3 for last call
c before a normal exit; not used here
integer i
real * 8 xlr,q2,xlam2c,kt2max,cunorm
integer nlc
common/cpt2solve/xlr,q2,kt2max,xlam2c,cunorm,nlc
real * 8 b0,sborn,xm,p
sborn=kn_sborn
b0=(11*CA-4*TF*nlc)/(12*pi)
if(rad_kinreg.eq.1) then
if(rad_iupperisr.eq.1) then
c see Notes/upperbounding-isr.pdf
if(pt2.lt.sborn) then
if(sborn.lt.kt2max) then
pt2solve=cunorm*pi/b0*(
# (log(2*sborn/xlam2c)*log(log(sborn/xlam2c)/log(pt2/xlam2c))
# - log(sborn/pt2)) +
# log(2d0)*log(log(kt2max/xlam2c)/log(sborn/xlam2c)))
# + xlr
else
pt2solve=cunorm*pi/b0*(
# (log(2*sborn/xlam2c)*log(log(kt2max/xlam2c)/log(pt2/xlam2c))
# - log(kt2max/pt2)) )
# + xlr
endif
else
pt2solve=cunorm*pi/b0*(log(2d0)
# *log(log(kt2max/xlam2c)/log(pt2/xlam2c)))
# + xlr
endif
else
write(*,*) ' rad_iupper=',rad_iupperisr,' not implemented'
call exit(1)
c Alternatives: rad_iupper=2
c pt2solve=cunorm*pi/b0/2
c # *(log(q2/xlam2c)*log(log(kt2max/xlam2c)/log(pt2/xlam2c))
c # - log(kt2max/pt2)) + xlr
endif
else
if(rad_iupperfsr.eq.1) then
c final state radiation
pt2solve=cunorm*pi/b0*(
# (log(kt2max/xlam2c)*log(log(kt2max/xlam2c)/log(pt2/xlam2c))
# - log(kt2max/pt2)) )
# + xlr
elseif(rad_iupperfsr.eq.2) then
xm=kn_csimax
p=sqrt(pt2/sborn)
pt2solve=cunorm*2*pi*2*(
3 (log(xm-xm**2)+(2*xm-2)*log(xm)-2*log(1-xm)*xm-2)/xm/2.d+0
1 -(p*log(xm-p**2)+(2*p*log(p)-2*log(1-p)*p-2)*xm-2*p*log(p))
2 /(p*xm)/2.d+0) + xlr
elseif(rad_iupperfsr.eq.3) then
xm=kn_csimax
p=sqrt(pt2/sborn)
pt2solve=cunorm*2*pi*2*(
3 (log(xm-xm**2)+(2*xm-2)*log(xm)-2*log(1-xm)*xm-2)/xm/2.d+0
1 -(p*log(xm-p**2)+(2*p*log(p)-2*log(1-p)*p-2)*xm-2*p*log(p))
2 /(p*xm)/2.d+0) + xlr
else
write(*,*) ' rad_iupper=',rad_iupperfsr,' not implemented'
call exit(1)
endif
endif
end
subroutine gen_rad_isr(t)
c Generates hard radiation kinematics according to
c appendix D in ZZ paper.
c
c common/cptmin/ptminsq: minimum pt^2 accepted
c
implicit none
include 'pwhg_math.h'
include 'nlegborn.h'
include 'pwhg_flst.h'
include 'pwhg_kn.h'
include 'pwhg_rad.h'
include 'pwhg_st.h'
real * 8 t
real * 8 x,y,x1b,x2b
real * 8 xlr,q2,xlam2c,kt2max,unorm
integer nlc
common/cpt2solve/xlr,q2,kt2max,xlam2c,unorm,nlc
real * 8 xmin,rv,xp,xm,chi,tk,uk,ubound,ufct,
# sborn,value,err,tmp1,tmp2,tmp,rvalue,born,sig
common/cdfxmin/xmin
real * 8 tmax
common/ctmax/tmax
real * 8 random,pt2solve,dfxmin,pwhg_alphas0,pwhg_upperb_rad
external random,pt2solve,dfxmin,pwhg_alphas0,pwhg_upperb_rad
unorm=rad_norms(rad_kinreg,rad_ubornidx)
sborn=kn_sborn
x1b=kn_xb1
x2b=kn_xb2
c See Notes/kt2max.pdf
kt2max = sborn*(1-x2b**2)*(1-x1b**2)/(x1b+x2b)**2
if(kt2max.lt.rad_ptsqmin.or.kt2max.lt.tmax) then
t=-1
goto 3
endif
c upper bound is log(q2/t)
if(rad_iupperisr.eq.1) then
q2=2*sborn
elseif(rad_iupperisr.eq.2) then
write(*,*) ' rad_iupper=',rad_iupperisr,' not implemented'
call exit(1)
c Alternative rad_iupper=2
c q2=4*sborn/min(x1b,x2b)**2
endif
c see section 4 in ZZ paper, last paragraph
xlam2c=rad_lamll**2
nlc=5
xlr=0
1 continue
xlr=xlr+log(random())
c CERNLIB voodoo:
call KERSET('C205. ',0,0,101)
c solve for zero of pt2solve
c dzero(xmin,xmax,x,err,eps,maxcalls,function)
c err: on exit if no error occours: |y-y0|<err
c error C205.1 function(xmin)*function(xmax)>0,
c x=0 and r=-2(ymax-ymin)
c error C205.2 Number of calls to F exceeds maxcalls,
c x=0 and r=-(xmax-xmin)/2
c eps: required accuracy
call dzero(rad_ptsqmin,kt2max,t,err,1d-8,1000000,pt2solve)
c error conditions
if(t.eq.0.and.err.lt.0d0
# .and.err.gt.rad_ptsqmin-kt2max) then
write(*,*) 'DZERO fails'
write(*,*) ' number of calls exceeded'
call exit(1)
endif
3 if(t.lt.rad_ptsqmin.or.t.lt.tmax) then
c below cut (either below absolute minimum, or below previously generated
c radiation in highest bid loop): generate a born event
t=-1
kn_csi=0
return
endif
c vetoes:
rv=random()
xp=(sqrt(1+t/sborn)+sqrt(t/sborn))**2
xm=(sqrt(1+t/sborn)-sqrt(t/sborn))**2
c tmp1: V(t)/tilde{V}(t) in appendix D of ZZ paper;
c (typo: in D.13, log log -> log
xmin=min(x1b,x2b)/(2*sqrt(1+t/sborn))
if(rad_iupperisr.eq.1) then
tmp1=log((sqrt(xp-xmin)+sqrt(xm-xmin))
# /(sqrt(xp-xmin)-sqrt(xm-xmin)))
if(t.lt.sborn) then
tmp1=tmp1/(log(2*sborn/t)/2)
else
tmp1=tmp1/(log(2d0)/2)
endif
elseif(rad_iupperisr.eq.2) then
tmp1=log(2/xmin*(sqrt((xp-xmin)*(xm-xmin))
# +1-xmin/2*(xp+xm))/(xp-xm)) /(log(q2/t)/2)
endif
c compare with D.11-D.12
c to set xmuren2:
call set_rad_scales(t)
tmp2=st_alpha / pwhg_alphas0(t,rad_lamll,nlc)
tmp=tmp1*tmp2
if(tmp.gt.1) then
write(*,*) ' Error: upper bound lower than actual value',
# tmp,tmp1,tmp2,t
call exit(1)
endif
if(rv.gt.tmp) then
goto 1
endif
c At this stage: pt generated according to D.2
c generate x proportional to 1/(x sqrt((xp-x)*(xm-x)))
c in the range xmin < x < xm (cf. D.5)
c Generate in d sqrt(xm-x) /sqrt(xp-x) (rad_iupper=1) or d sqrt(xm-x) /(x sqrt(xp-x)) (rad_iupper=2)
c using d sqrt(xm-x) /sqrt(xp-xm) (rad_iupper=1) or d sqrt(xm-x) /(xmin sqrt(xp-xm)) (rad_iupper=2) as upper bound using hit and miss
2 chi=sqrt(xm-xmin)*random()
x=xm-chi**2
if(rad_iupperisr.eq.1) then
if(random().gt.sqrt(xp-xm)/sqrt(xp-x)) goto 2
elseif(rad_iupperisr.eq.2) then
if(random().gt.(xmin*sqrt(xp-xm))/(x*sqrt(xp-x))) goto 2
endif
c get y (abs to avoid tiny negative values)
y=sqrt(abs(1-4*x/(1-x)**2*t/sborn))
if(random().gt.0.5d0) y=-y
c At this point an x-y pair is generated according to the
c distribution upper().
c
c Veto if out of range (x1>1 or x2>1)
tk=-1d0/2*(1-x)*(1-y)
uk=-1d0/2*(1-x)*(1+y)
if( x1b*sqrt((1+tk)/(1+uk)/x) .gt. 1
# .or. x2b*sqrt((1+uk)/(1+tk)/x) .gt. 1) then
goto 1
endif
c extra suppression factor of upper bounding function (may depend upon radiation variables)
call uboundfct(ufct,1-x,y)
if(random().gt.ufct) goto 1
c Veto from upper bound to real value. Count how many vetoes,
c since these may be expensive.
call sigborn_rad(born)
if(born.lt.0) then
born=0
endif
if(born.eq.0) then
c bizarre situation that may arise when the scale gets so low
c that some pdf vanish (typically heavy flavour pdf's)
t=-1
goto 3
endif
kn_y=y
kn_csi=1-x
kn_azi=2*pi*random()
ubound=born*pwhg_upperb_rad()*unorm*ufct
call gen_real_phsp_isr_rad
call sigreal_rad(sig)
value=sig*kn_jacreal
if(value.gt.ubound) then
call increasecnt(
# 'upper bound failures in generation of radiation')
endif
rvalue=random()*ubound
if(rvalue.gt.value) then
call increasecnt('vetoed radiation')
goto 1
endif
end
subroutine gen_rad_fsr(t)
c Generates final state hard radiation kinematics according to
c Notes/upperbounding-fsr.pdf
c
implicit none
include 'pwhg_math.h'
include 'nlegborn.h'
include 'pwhg_flst.h'
include 'pwhg_kn.h'
include 'pwhg_rad.h'
include 'pwhg_st.h'
real * 8 t
real * 8 csi,y
real * 8 xlr,q2,xlam2c,kt2max,unorm
integer nlc
common/cpt2solve/xlr,q2,kt2max,xlam2c,unorm,nlc
real * 8 xmin,rv,ubound,ufct,
# s,value,err,tmp,rvalue,born,sig
common/cdfxmin/xmin
real * 8 tmax
common/ctmax/tmax
real * 8 random,pt2solve,pwhg_alphas0,pwhg_upperb_rad
external random,pt2solve,pwhg_alphas0,pwhg_upperb_rad
unorm=rad_norms(rad_kinreg,rad_ubornidx)
c kn_sborn=kn_sreal:
s=kn_sborn
kn_emitter=flst_lightpart+rad_kinreg-2
kn_csimax=kn_csimax_arr(kn_emitter)
c See Notes/kt2max.pdf
kt2max = kn_csimax**2*s
if(kt2max.lt.rad_ptsqmin.or.kt2max.lt.tmax) then
t=-1
goto 3
endif
c see section 4 in ZZ paper, last paragraph
xlam2c=rad_lamll**2
nlc=5
xlr=0
1 continue
xlr=xlr+log(random())
c CERNLIB voodoo:
call KERSET('C205. ',0,0,101)
c solve for zero of pt2solve
c dzero(xmin,xmax,x,err,eps,maxcalls,function)
c err: on exit if no error occours: |y-y0|<err
c error C205.1 function(xmin)*function(xmax)>0,
c x=0 and r=-2(ymax-ymin)
c error C205.2 Number of calls to F exceeds maxcalls,
c x=0 and r=-(xmax-xmin)/2
c eps: required accuracy
call dzero(rad_ptsqmin,kt2max,t,err,1d-8,1000000,pt2solve)
c error conditions
if(t.eq.0.and.err.lt.0d0
# .and.err.gt.rad_ptsqmin-kt2max) then
write(*,*) 'DZERO fails'
write(*,*) ' number of calls exceeded'
call exit(1)
endif
3 if(t.lt.rad_ptsqmin.or.t.lt.tmax) then
c below cut (either below absolute minimum, or below previously generated
c radiation in highest bid loop): generate a born event
t=-1
kn_csi=0
return
endif
c vetoes:
rv=random()
call set_rad_scales(t)
if(rad_iupperfsr.eq.1) then
tmp=st_alpha / pwhg_alphas0(t,rad_lamll,nlc)
elseif(rad_iupperfsr.eq.2) then
tmp=st_alpha
elseif(rad_iupperfsr.eq.3) then
tmp=st_alpha
endif
if(tmp.gt.1) then
write(*,*) ' Error: upper bound lower than actual value',
# tmp,t
call exit(1)
endif
if(rv.gt.tmp) then
goto 1
endif
if(rad_iupperfsr.eq.1) then
c At this stage: pt generated according to (1) of upperbounding-fsr.pdf;
c generate csi uniformly in 1/csi
c in the range t/s < csi^2 < csimax^2
rv=random()
csi=exp(rv*log(t/s)/2+(1-rv)*log(kn_csimax))
c get y
y=1-2*t/(s*csi**2)
c At this point a csi-y pair is generated according to the
c distribution upper(). It is automatically within range.
elseif(rad_iupperfsr.eq.2) then
c csi distributed uniformly in 1/(csi-t/s)
rv=random()
csi=1/(rv/(sqrt(t/s)-t/s)+(1-rv)/(kn_csimax-t/s))+t/s
c extra csi dependent factor
if(random().gt.csi) goto 1
c get y
y=1-2*t/(s*csi**2)
c At this point a csi-y pair is generated according to the
c distribution upper(). It is automatically within range.
elseif(rad_iupperfsr.eq.3) then
c csi distributed uniformly in 1/(csi-t/s)
rv=random()
csi=1/(rv/(sqrt(t/s)-t/s)+(1-rv)/(kn_csimax-t/s))+t/s
c get y
y=1-2*t/(s*csi**2)
if(random().gt.(csi-t/s)) goto 1
else
write(*,*) ' gen_rad_fsr: rad_iupper=',rad_iupperfsr,
1 ' invalid'
endif
c
c extra suppression factor of upper bounding function (may depend upon radiation variables)
call uboundfct(ufct,csi,y)
if(random().gt.ufct) goto 1
c Veto from upper bound to real value. Count how many vetoes,
c since these may be expensive.
c write(*,*) ' genrad_fsr: y and csi ',y,csi
call sigborn_rad(born)
if(born.lt.0) then
born=0
endif
if(born.eq.0) then
c bizarre situation that may arise when the scale gets so low
c that some pdf vanish (typically heavy flavour pdf's)
t=-1
goto 3
endif
kn_y=y
kn_csi=csi
kn_azi=2*pi*random()
ubound=born*pwhg_upperb_rad()*unorm*ufct
call gen_real_phsp_fsr_rad
call sigreal_rad(sig)
value=sig*kn_jacreal
if(value.gt.ubound) then
call increasecnt(
# 'upper bound failures in generation of radiation')
endif
rvalue=random()*ubound
if(rvalue.gt.value) then
call increasecnt('vetoed radiation')
goto 1
endif
end
subroutine add_azimuth
implicit none
include 'nlegborn.h'
include 'pwhg_flst.h'
include 'pwhg_math.h'
include 'pwhg_kn.h'
integer ileg
real * 8 azi,sazi,cazi
real * 8 dir(3)
data dir/0d0,0d0,1d0/
real * 8 random
external random
azi=2d0*pi*random()
sazi = sin(azi)
cazi = cos(azi)
if (kn_csi.eq.0d0) then
do ileg=1, nlegborn
call mrotate(dir,sazi,cazi,kn_pborn(1,ileg))
enddo
else
do ileg=1, nlegreal
call mrotate(dir,sazi,cazi,kn_preal(1,ileg))
enddo
endif
end