forked from alisw/POWHEG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfind_regions.f
1480 lines (1414 loc) · 48.7 KB
/
find_regions.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
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
c program testfindregions
c implicit none
c integer n
c parameter (n=6)
c integer rflav(n),nregions,iregions(2,n*(n-1)/2),i
c character * 30 process
c
c process = 'u~ u -> e- e+ u u~'
c call from_madgraph_to_number(process,rflav)
c call find_regions(n,rflav,nregions,iregions)
c
c write(*,*) nregions
c do i=1,nregions
c write(*,*) iregions(1,i),iregions(2,i)
c enddo
c call genflavreglist
c end
subroutine find_regions(a,ares,atags,indexreal,nregions,iregions)
c Finds all singular regions for the real graph indexed by indexreal.
c a(nlegreal,*): input array of real graph structures
c ares(nlegreal,*): input, if an entry is > 0, it points to the mother resonance
c of the given parton (if it is 0 the parton comes from the
c hard reaction. This array describes the structure of the event
c from the point of view of resonance decays
c atags(nlegreal,*): it is use to tag fermion lines to appear as being different,
c even if they have the same flavour (see arXiv:0911.5299)
c It returns:
c integer nregions
c integer iregion(2,nregions): the indices of particles forming singular
c regions i,j (i<j).
c For initial state singularities, if the
c emitter can be both of the initial state
c particles,
c and if the radiated particle is a gluon,
c only one region is generated with first
c index equal to zero.
implicit none
include 'nlegborn.h'
include 'pwhg_flst.h'
integer a(nlegreal,*),ares(nlegreal,*),atags(nlegreal,*)
integer indexreal,nregions,iregions(2,maxregions)
logical ireg(2)
logical validBorn
external validBorn
integer itag,iret,i,j,k,ibornfl,iborn,flrad,
1 bflav(nlegborn),res(nlegborn),tags(nlegborn)
nregions=0
c final state regions
do i=flst_lightpart,nlegreal
do j=i+1,nlegreal
c find if they can arise from the same splitting
call same_splitting(a,ares,atags,
1 indexreal,i,j,ibornfl,itag,iret)
c cannot come from the same splitting
if(iret.lt.0) then
goto 10
endif
c build the underlying born flavour structure in bflav
iborn=0
do k=1,nlegreal
if(k.eq.i) then
iborn=iborn+1
bflav(iborn)=ibornfl
res(iborn)=ares(k,indexreal)
tags(iborn)=itag
elseif(k.ne.j) then
iborn=iborn+1
bflav(iborn)=a(k,indexreal)
res(iborn)=ares(k,indexreal)
tags(iborn)=atags(k,indexreal)
endif
enddo
if(validBorn(bflav,res,tags)) then
nregions=nregions+1
iregions(1,nregions)=i
iregions(2,nregions)=j
endif
10 continue
enddo
enddo
c initial state region
do j=flst_lightpart,nlegreal
do i=1,2
ireg(i)=.false.
call same_splitting(a,ares,atags,
1 indexreal,i,j,ibornfl,itag,iret)
if(iret.lt.0) then
goto 11
endif
iborn=0
do k=1,nlegreal
if(k.eq.i) then
iborn=iborn+1
bflav(iborn)=ibornfl
res(iborn)=0
tags(iborn)=itag
elseif(k.ne.j) then
iborn=iborn+1
bflav(iborn)=a(k,indexreal)
res(iborn)=ares(k,indexreal)
tags(iborn)=atags(k,indexreal)
endif
enddo
if(validBorn(bflav,res,tags)) then
ireg(i)=.true.
endif
11 continue
enddo
flrad=a(j,indexreal)
if(ireg(1).and.ireg(2).and.(flrad.eq.0.or.flrad.eq.22))
1 then
c if both regions are singular and the radiated parton is a gluon
c or a photon emit a single region with emitter 0
nregions=nregions+1
iregions(1,nregions)=0
iregions(2,nregions)=j
else
if(ireg(1)) then
nregions=nregions+1
iregions(1,nregions)=1
iregions(2,nregions)=j
endif
if(ireg(2)) then
nregions=nregions+1
iregions(1,nregions)=2
iregions(2,nregions)=j
endif
endif
enddo
end
subroutine ubornflav(alr)
implicit none
integer alr
include 'nlegborn.h'
include 'pwhg_flst.h'
c finds the underlying Born flavour of the alr region in flst_alr
c stores it in flst_uborn,flst_uborntags,flst_ubornres
c integer n: number of legs in real graph
c integer rflav(n): flavours of legs in real graph
c (1 and 2 incoming)
integer itag,ibornfl,iret,l,n,j
c j: singularity in region j,n
c j=0 (1 and 2), j=1, j=2: initial state sing.
c j>2 final state sing.
j=flst_emitter(alr)
c if it is both 1 and 2, pretend it is 1
if(j.eq.0) j=1
iret=0
n=nlegreal
c this is only to find itag and ibornfl. We already now that j and n
c come from the same splitting.
if(j.eq.1.or.j.eq.2) then
call same_splitting0('isr',flst_alr(j,alr),flst_alr(n,alr),
1 flst_alrtags(j,alr),flst_alrtags(n,alr),itag,ibornfl,iret)
elseif(j.gt.2) then
call same_splitting0('fsr',flst_alr(j,alr),flst_alr(n,alr),
1 flst_alrtags(j,alr),flst_alrtags(n,alr),itag,ibornfl,iret)
endif
if(iret.lt.0) then
write(*,*) ' ubornflav: error'
write(*,*) ' j: ',j
call print_lists(nlegreal,flst_alr(l,alr),
1 flst_alrres(l,alr),flst_alrtags(l,alr))
write(*,*) ' emitter:',flst_emitter(alr)
call exit(-1)
endif
do l=1,nlegborn
if(l.eq.j) then
flst_uborn(l,alr)=ibornfl
flst_uborntags(l,alr)=itag
flst_ubornres(l,alr)=flst_alrres(l,alr)
else
flst_uborn(l,alr)=flst_alr(l,alr)
flst_uborntags(l,alr)=flst_alrtags(l,alr)
flst_ubornres(l,alr)=flst_alrres(l,alr)
endif
enddo
return
998 continue
end
recursive function rec_ident(n,ia,ib,a,ares,atags,b,bres,btags)
1 result(result)
c This recursive function checks if entry ia is equivalent to entry ib in the arrays a and b.
c It properly accounts the fact that identical resonances should also have identical
c decay products recursively.
implicit none
logical result
integer, intent(in)::
1 n,ia,ib,a(n),ares(n),atags(n),b(n),bres(n),btags(n)
c The following variables are local even if -save or -fno-automatic
c is used in compilation, so that recursion works properly.
c Only an explicit save statement could prevent that.
c Notice also that arguments are passed by reference: we always
c pass the same copy of the arrays a,ares,atags and b,bres,btags to the ident
c function.
integer ndeca,ndecb
integer bmarked(n)
integer ka,kb
if(a(ia) /= b(ib) .or. atags(ia) /= btags(ib)) then
result = .false.
return
endif
c First check if ia and ib have the same number of decay product.
c If not, they can't be equivalent. If they don't have decay products,
c they are equivalent (tags are the same, from previous condition).
c
c count how many decay products of ia
ndeca = 0
do ka=1,n
if(ares(ka).eq.ia) ndeca = ndeca + 1
enddo
c count how many decay products of ib
ndecb = 0
do kb=1,n
if(bres(kb).eq.ib) ndecb = ndecb + 1
enddo
c no decay products, they are equivalent
if(ndeca.eq.0.and.ndecb.eq.0) then
result = .true.
return
endif
c different number of decay products: they are inequivalent
if(ndeca.ne.ndecb) then
result = .false.
return
endif
c now ka goes through all elements that come from the decay
c of ia.
do ka=1,n
if(ares(ka).eq.ia) then
c For each decay product of ia, see if there is an identical (recursively!)
c decay product of ib. If found, mark it in the array bmarked, so as not to
c usit more than once
bmarked = 0
do kb=1,n
if( bres(kb) == ib .and. bmarked(kb) == 0) then
c see if they are equal
if(rec_ident(n,ka,kb,a,ares,atags,b,bres,btags)) then
bmarked(kb)=1
exit
endif
endif
enddo
if(kb == n+1) then
result = .false.
return
endif
endif
enddo
result = .true.
return
end
function flavequivl(m,n,ja,jb,arr,arrres,arrtags)
c arr(m,*),arrres(m,*),arrtags(m,*) are the flavour list,
c the resonance list, and the tag list
c returns true if the ja and jb arr(1:n,ja) arr(1:n,jb)
c are equivalent up to a permutation, false otherwise
c equivalent up to a permutation of the final state lines,
c false otherwise. The resonance structure and the tag assignments
c should also be equivalent for a positive outcome.
implicit none
logical flavequivl
integer m,n,ja,jb,arr(m,*),arrres(m,*),arrtags(m,*)
logical flavequivr
flavequivl = flavequivr(n,arr(:,ja),arrres(:,ja),arrtags(:,ja),
1 arr(:,jb),arrres(:,jb),arrtags(:,jb))
end
function flavequivr(n,a,ares,atags,b,bres,btags)
c a,ares,atags and b,bres,btags are the flavour list,
c the resonance list, and the tag list, and
c returns true if the a and b arrays
c equivalent up to a permutation of the final state lines,
c false otherwise.
implicit none
logical flavequivr
integer n,a(n),ares(n),atags(n),b(n),bres(n),btags(n)
integer bmarked(n)
integer j,k
logical rec_ident
external rec_ident
c first two entries must be identical
do j=1,2
if(a(j) /= b(j) .or. atags(j) /= btags(j)) then
flavequivr = .false.
return
endif
enddo
bmarked = 0
c final state entries can be in different order. Compare only
c primary particles (i.e., not sons of resonances); the recursive comparison
c takes care of the rest.
do j=3,n
if(ares(j).eq.0) then
do k=3,n
if(bres(k).eq.0) then
if(bmarked(k) == 0) then
if(rec_ident(n,j,k,a,ares,atags,b,bres,btags)) then
bmarked(k) = 1
exit
endif
endif
endif
enddo
if(k.eq.n+1) then
flavequivr = .false.
return
endif
endif
enddo
flavequivr = .true.
end
function validBorn(bflav,res,tags)
c Find if the flavour structure bflav is equivalent to an element
c in the list of Born processes. Equivalence means that it can be
c made identical with a permutation of final state particles.
implicit none
include 'nlegborn.h'
include 'pwhg_flst.h'
integer bflav(nlegborn),tags(nlegborn),res(nlegborn)
logical validBorn
integer kb
logical flavequivr
do kb=1,flst_nborn
if(flavequivr(nlegborn,bflav,res,tags,
1 flst_born(:,kb),flst_bornres(:,kb),flst_borntags(:,kb))
2 ) then
validBorn = .true.
return
endif
enddo
validBorn = .false.
end
c -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6
c t~ b~ c~ s~ u~ d~ g d u s c b t
subroutine from_madgraph_to_number(stringa,ferm_flav)
implicit none
integer nmax
parameter (nmax=30)
character stringa(nmax)
integer ferm_flav(*)
integer i, parton
character *2 flav(-5:5)
real * 8 charge(-5:5)
common/flav_ordering/charge,flav
parton = 0
do i=1,nmax
if (stringa(i).eq.'g') then
parton = parton + 1
ferm_flav(parton) = 0
elseif (stringa(i).eq.'H') then
parton = parton + 1
ferm_flav(parton) = 503
elseif (stringa(i).eq.'d') then
parton = parton + 1
ferm_flav(parton) = +1
elseif (stringa(i).eq.'u') then
parton = parton + 1
ferm_flav(parton) = +2
elseif (stringa(i).eq.'s') then
parton = parton + 1
ferm_flav(parton) = +3
elseif (stringa(i).eq.'c') then
parton = parton + 1
ferm_flav(parton) = +4
elseif (stringa(i).eq.'b') then
parton = parton + 1
ferm_flav(parton) = +5
elseif (stringa(i).eq.'t') then
parton = parton + 1
ferm_flav(parton) = +6
elseif (stringa(i).eq.'~') then
ferm_flav(parton) = -ferm_flav(parton)
elseif (stringa(i).eq.' ') then
elseif (stringa(i).eq.'Z') then
parton = parton + 1
ferm_flav(parton) = +10
parton = parton + 1
ferm_flav(parton) = -10
elseif (stringa(i).eq.'e') then
parton = parton + 1
ferm_flav(parton) = +10
elseif (stringa(i).eq.'+') then
ferm_flav(parton) = -ferm_flav(parton)
elseif (stringa(i).eq.'/') then
return
endif
enddo
end
function isalightparton(ipart)
implicit none
include 'pwhg_st.h'
logical isalightparton
integer ipart
if(abs(ipart).le.st_nlight) then
isalightparton=.true.
return
endif
if(ipart.eq.22) then
isalightparton=.true.
return
endif
if(abs(ipart).ge.11.and.abs(ipart).le.16) then
isalightparton=.true.
return
endif
isalightparton=.false.
end
function check_consistent_res(n,resl)
implicit none
logical check_consistent_res
integer n,resl(n)
integer j,k,itmp
c See if the list of resonance pointers is consistent; it should describe
c a tree, i.e. going up in the resonance chain it should always end with 0
c (i.e., no cicles)
do j=1,n
if(resl(j) /= 0) then
itmp = resl(j)
do k=1,n
if(resl(itmp) /= 0) then
itmp = resl(itmp)
else
exit
endif
enddo
if(k == n+1) then
check_consistent_res = .false.
return
endif
endif
enddo
check_consistent_res = .true.
end
subroutine genflavreglist
implicit none
include 'pwhg_flg.h'
include 'pwhg_st.h'
include 'nlegborn.h'
include 'pwhg_flst.h'
integer nregions,iregions(2,maxregions)
integer iflregl,k,l,ipart,j,itmp,nreg,iret,tmpfl,fl1,fl2
logical equalintlists
external equalintlists
logical verbose
parameter (verbose=.true.)
logical flavequivl,isalightparton,equiv_entry_alr_real,
1 equal_lists,check_consistent_res
external flavequivl,isalightparton,equiv_entry_alr_real,
2 equal_lists,check_consistent_res
c check that there are no coloured light partons before flst_lightpart
c do j=1,flst_nreal
c do ipart=3,flst_lightpart -1
c if(isalightparton(flst_real(ipart,j))) then
c write(*,*)
c 1 ' genflavreglist: light parton before flst_lightpart'
c stop
c endif
c enddo
c do ipart=flst_lightpart,nlegreal
c if(.not.isalightparton(flst_real(ipart,j))) then
c write(*,*)
c 1 ' genflavreglist: not a light parton after flst_lightpart'
c stop
c endif
c enddo
c enddo
c do j=1,flst_nborn
c do ipart=3,flst_lightpart-1
c if(isalightparton(flst_born(ipart,j))) then
c write(*,*)
c 1 ' genflavreglist: light parton before flst_lightpart'
c stop
c endif
c enddo
c do ipart=flst_lightpart,nlegborn
c if(.not.isalightparton(flst_born(ipart,j))) then
c write(*,*)
c 1 ' genflavreglist: not a light parton after flst_lightpart'
c stop
c endif
c enddo
c enddo
c sanity check on real flavour configurations;
c they should all be inequivalent
do j=1,flst_nreal
if(.not.check_consistent_res(nlegreal,flst_realres(:,j))) then
write(*,*)
1 'resonances assignments for reals are not consistent'
call pwhg_exit(-1)
endif
enddo
do j=1,flst_nreal
do k=j+1,flst_nreal
if(flavequivl(nlegreal,nlegreal,j,k,flst_real,
1 flst_realres,flst_realtags)) then
write(*,*)'found two equivalent real flavour processes:'
write(*,*)'processes',j,k
call print_lists(nlegreal,flst_real(1,j)
1 ,flst_realres(1,j),flst_realtags(1,j))
call print_lists(nlegreal,flst_real(1,k)
1 ,flst_realres(1,k),flst_realtags(1,k))
call exit(-1)
endif
enddo
enddo
c check if resonance assignments are consistent
do j=1,flst_nborn
if(.not.check_consistent_res(nlegborn,flst_bornres(:,j))) then
write(*,*)
1 'resonances assignments for borns are not consistent'
call pwhg_exit(-1)
endif
enddo
c at the moment, all born flavours should have the same resonance assignment
c structure
do j=2,flst_nborn
do k=1,nlegborn
if(flst_bornres(k,j).ne.flst_bornres(k,1)) then
write(*,*)
1 'Found born flavour structures '//
2 'with inequivalent resonance assignment'
write(*,*) 'This is not allowed in the present '//
1 'implementation'
call pwhg_exit(-1)
endif
enddo
enddo
c sanity check on Born flavour configurations;
c they should all be inequivalent
do j=1,flst_nborn
do k=j+1,flst_nborn
if(flavequivl(nlegborn,nlegborn,j,k,flst_born,flst_bornres,
1 flst_borntags)) then
write(*,*)'found two equivalent Born flavour processes:'
write(*,*)'processes',j,k
call print_lists(nlegborn,flst_born(1,j),
1 flst_bornres(1,j),flst_borntags(1,j))
call print_lists(nlegborn,flst_born(1,k),
1 flst_bornres(1,k),flst_borntags(1,k))
call exit(-1)
endif
enddo
enddo
c Start search for regions (i.e. alr)
c current number of alr found
iflregl=0
flst_nregular=0
if(flst_nreal.gt.maxprocreal) then
write(*,*)' genflavreglist: increase maxprocreal'
stop
endif
flg_withreg=.false.
do k=1,flst_nreal
call find_regions(flst_real,flst_realres,flst_realtags,
1 k,nregions,iregions)
if(nregions.eq.0) then
flst_nregular=flst_nregular+1
c There are remnants! set up the appropriate flag:
flg_withreg=.true.
call intassign
#(nlegreal,flst_real(1,k),flst_regular(1,flst_nregular))
call intassign
#(nlegreal,flst_realres(1,k),flst_regularres(1,flst_nregular))
call intassign
#(nlegreal,flst_realtags(1,k),flst_regulartags(1,flst_nregular))
endif
do l=1,nregions
if(iflregl.ge.maxalr) then
write(*,*)' genflavreglist: increase maxalr'
stop
endif
iflregl=iflregl+1
if(iregions(1,l).le.2) then
flst_emitter(iflregl)=iregions(1,l)
else
flst_emitter(iflregl)=nlegreal-1
endif
ipart=0
c final state singularity
if(iregions(1,l).gt.2) then
do j=1,nlegreal
if(j.ne.iregions(1,l)
# .and.j.ne.iregions(2,l)) then
ipart=ipart+1
flst_alr(ipart,iflregl)=flst_real(j,k)
flst_alrres(ipart,iflregl)=flst_realres(j,k)
flst_alrtags(ipart,iflregl)=flst_realtags(j,k)
endif
enddo
ipart=ipart+1
flst_alr(ipart,iflregl)=flst_real(iregions(1,l),k)
flst_alrres(ipart,iflregl)=flst_realres(iregions(1,l),k)
flst_alrtags(ipart,iflregl)=
1 flst_realtags(iregions(1,l),k)
ipart=ipart+1
flst_alr(ipart,iflregl)=flst_real(iregions(2,l),k)
flst_alrres(ipart,iflregl)=flst_realres(iregions(2,l),k)
flst_alrtags(ipart,iflregl)=
1 flst_realtags(iregions(2,l),k)
if(flg_doublefsr) then
c c emit regions with opposite ordering for q g and q q~
if(flst_alr(nlegreal,iflregl)*
1 flst_alr(nlegreal-1,iflregl).ne.0
2 .or.flst_alr(nlegreal,iflregl).ne.0 .or.
3 flst_alr(nlegreal-1,iflregl).ne.0) then
if(iflregl.ge.maxalr) then
write(*,*)' genflavreglist: increase maxalr'
call exit(-1)
endif
flst_alr(:,iflregl+1)=flst_alr(:,iflregl)
flst_alrres(:,iflregl+1)=flst_alrres(:,iflregl)
flst_alrtags(:,iflregl+1)=flst_alrtags(:,iflregl)
iflregl = iflregl+1
call exchange_ind(nlegreal,nlegreal,nlegreal-1,
1 flst_alr(1,iflregl),flst_alrres(1,iflregl),
2 flst_alrtags(1,iflregl))
flst_emitter(iflregl)=nlegreal-1
endif
else
c put always in the order q g and q q~, i.e. fl(i)>fl(j)
fl1=flst_alr(nlegreal-1,iflregl)
fl2=flst_alr(nlegreal,iflregl)
if( (fl2.ne.22 .and. fl2.ne.0) .and.
1 ( (fl1.eq.0 .or. fl1.eq.22) .or.
1 (fl1.lt.fl2) ) ) then
call exchange_ind(nlegreal,nlegreal,nlegreal-1,
1 flst_alr(1,iflregl),flst_alrres(1,iflregl),
2 flst_alrtags(1,iflregl))
endif
endif
else
c initial state singularity
do j=1,nlegreal
if(j.ne.iregions(2,l)) then
ipart=ipart+1
flst_alr(ipart,iflregl)=flst_real(j,k)
flst_alrres(ipart,iflregl)=flst_realres(j,k)
flst_alrtags(ipart,iflregl)=flst_realtags(j,k)
endif
enddo
ipart=ipart+1
flst_alr(ipart,iflregl)=flst_real(iregions(2,l),k)
flst_alrres(ipart,iflregl)=flst_realres(iregions(2,l),k)
flst_alrtags(ipart,iflregl)=
1 flst_realtags(iregions(2,l),k)
endif
c write(*,*) (flst_alr(ipart,iflregl),ipart=1,nlegreal),
c # ' em:',flst_emitter(iflregl)
enddo
enddo
nreg=iflregl
flst_nalr=nreg
write(*,*) ' **** Minimum maxalr allowed: ',nreg,' *********'
write(*,*) ' **** Number of born graphs: ',flst_nborn
write(*,*) ' **** Number of real graphs: ',flst_nreal
write(*,*) ' **** Number of regular regions:',flst_nregular
call pretty_print_flst
c bunch together identical elements, increasing their multiplicities
do j=1,nreg
flst_mult(j)=1
enddo
do j=1,nreg
if(flst_mult(j).gt.0) then
do k=j+1,nreg
c Previously was:
c if(flst_emitter(j).eq.flst_emitter(k).and.
c # equalintlists(nlegreal,flst_alr(1,j),flst_alr(1,k))) then
c now accounts for equivalence by permutation of final state lines.
c Notice: identity of emitter and radiated parton must be valid
c without permutations
if(flst_mult(k).ne.0) then
if(flst_emitter(j).eq.flst_emitter(k).and.
c ISR: is ISR, has same radiated parton, is equivalent
c (excluding the radiated parton)
1 ( (flst_emitter(j).le.2 .and.
2 equiv_entry_alr_real(nlegreal,j,k).and.
3 flavequivl(nlegreal,nlegreal-1,j,k,
4 flst_alr,flst_alrres,flst_alrtags))
5 .or.
c FSR: has the same radiated and emitter parton, is equivalent
c (excluding emitter and emitted parton)
6 (flst_emitter(j).gt.2 .and.
7 equiv_entry_alr_real(nlegreal,j,k).and.
8 equiv_entry_alr_real(nlegreal-1,j,k).and.
9 flavequivl(nlegreal,nlegreal-2,j,k,
1 flst_alr,flst_alrres,flst_alrtags))
2 )) then
c
c call print_lists(nlegreal,flst_alr(1,j),
c 1 flst_alrres(1,j),flst_alrtags(1,j))
c
c call print_lists(nlegreal,flst_alr(1,k),
c 1 flst_alrres(1,k),flst_alrtags(1,k))
c
flst_mult(j)=flst_mult(j)+flst_mult(k)
flst_mult(k)=0
endif
endif
enddo
endif
enddo
c browse the list, put together identical elements, compute
c associated underlying Born
flst_nalr=nreg
call pretty_print_flst
iflregl=0
do j=1,nreg
if(flst_mult(j).gt.0) then
iflregl=iflregl+1
if(j.gt.iflregl) then
flst_emitter(iflregl)=flst_emitter(j)
call alr_move(j,iflregl)
flst_mult(iflregl) = flst_mult(j)
endif
call ubornflav(iflregl)
endif
enddo
flst_nalr=iflregl
call pretty_print_flst
c
c Build unique list of underlying Born; reorder flavours in alpha_r, uborn, emitter
c so that the underlying Born matches exactly a Born flavour structure in the flst_born array
c flavour structures arising as underlying Born
do j=1,flst_nalr
do k=1,flst_nborn
c are they the same permutation?
call reorder_regions(j,k,iret)
c if(iret.eq.1) write(*,*) ' reordering took place'
if(iret.ne.-1) goto 11
enddo
c they are inequivalent
write(*,*) ' error: underlying born not present in born list'
call print_lists(nlegborn,flst_uborn(1,j),flst_ubornres(1,j),
1 flst_uborntags(1,j))
call pwhg_exit(-1)
11 continue
enddo
call pretty_print_flst
c Build pointers from alpha_r -> born
do j=1,flst_nalr
flst_alr2born(j) = 0
do k=1,flst_nborn
if(equal_lists(nlegborn,j,k,
1 flst_uborn,flst_ubornres,flst_uborntags,
2 flst_born,flst_bornres,flst_borntags)) then
if(flst_alr2born(j).ne.0) then
write(*,*) ' genflavreglist:'
write(*,*)
1 ' error: alr',j,'has more then 1 underlying Born'
call pwhg_exit(-1)
endif
flst_alr2born(j)=k
endif
enddo
enddo
do j=1,flst_nalr
if(flst_alr2born(j).eq.0) then
write(*,*) ' genflavreglist:'
write(*,*) ' error: alr without underlying Born'
write(*,*) ' alr=',j
write(*,*) flst_alr(:,j)
write(*,*) flst_alrres(:,j)
write(*,*) flst_alrtags(:,j)
call pwhg_exit(-1)
endif
enddo
c Build pointers from born -> alpha_r
do j=1,flst_nborn
flst_born2alr(0,j)=0
do k=1,flst_nalr
if(equal_lists(nlegborn,k,j,
1 flst_uborn,flst_ubornres,flst_uborntags,
2 flst_born,flst_bornres,flst_borntags)) then
flst_born2alr(0,j)=flst_born2alr(0,j)+1
flst_born2alr(flst_born2alr(0,j),j)=k
endif
enddo
c Sanity check: each Born should be the underlying Born of some alr
if(flst_born2alr(0,j).eq.0) then
write(*,*) ' Born graph ',j,' is never the underlying Born'
# //' of some alr'
call print_lists(nlegborn,flst_born(1,j),
1 flst_bornres(1,j),flst_borntags(1,j))
c stop
endif
enddo
c Find regions for each alpha_r
do j=1,flst_nalr
call find_regions(flst_alr,flst_alrres,flst_alrtags,
1 j,nregions,iregions)
do k=1,nregions
flst_allreg(1,k,j)=iregions(1,k)
flst_allreg(2,k,j)=iregions(2,k)
enddo
flst_allreg(1,0,j)=nregions
enddo
c For each region, compute the underlying Born multiplicity
do j=1,flst_nalr
if(flst_emitter(j).gt.2) then
flst_ubmult(j)=0
c find flavour of emitter IN THE UNDERLYING BORN
do k=3,nlegborn
if(flst_uborn(k,j).eq.flst_uborn(flst_emitter(j),j)
1 .and. flst_ubornres(k,j).eq.flst_ubornres(flst_emitter(j),j)
2 .and. flst_uborntags(k,j).eq.flst_uborntags(flst_emitter(j),j))
3 then
flst_ubmult(j)=flst_ubmult(j)+1
endif
enddo
else
flst_ubmult(j)=1
endif
enddo
c debug information
if (verbose) then
call pretty_print_flst
endif
end
function equal_lists(n,j,k,a,ares,atags,b,bres,btags)
logical equal_lists
integer n,j,k,a(n,*),ares(n,*),atags(n,*),
1 b(n,*),bres(n,*),btags(n,*)
integer l
do l=1,n
if(a(l,j).ne.b(l,k) .or.
1 ares(l,j).ne.bres(l,k) .or.
1 atags(l,j).ne.btags(l,k)) then
equal_lists=.false.
return
endif
enddo
equal_lists=.true.
end
subroutine from_number_to_madgraph(n,flav,emitter,string)
implicit none
integer n,flav(n),emitter
include 'nlegborn.h'
character * (*) string
integer min_partnames,max_partnames
parameter (min_partnames=-25)
parameter (max_partnames=25)
character * 3 partnames(min_partnames:max_partnames)
data partnames/
& ' ','W- ',' ',' ',' ',' ',' ',' ',' ',
$ 'vt~','ta+','vm~','mu+','ve~','e+',' ',' ',' ',
$ ' ','t~','b~','c~','s~','u~','d~','g ','d ','u ','s ' ,'c ',
$ 'b ','t ',' ',' ','',' ','e-','ve','mu-','vmu','ta-','vta',
$ ' ',' ',' ',' ',' ','gam',' ','W+ ','H '/
integer lastnb,j,next
external lastnb
string=' '
if(emitter.eq.0) then
string='('//partnames(flav(1))//' '//partnames(flav(2))//').'
elseif(emitter.eq.1) then
string='('//partnames(flav(1))//')'//partnames(flav(2))//' .'
elseif(emitter.eq.2) then
string=' '//partnames(flav(1))//'('//partnames(flav(2))//').'
else
string=' '//partnames(flav(1))//' '//partnames(flav(2))//' .'
endif
next=lastnb(string)
string(next:)=' ==> .'
next=lastnb(string)
do j=3,n
if(emitter.eq.j) then
if(flav(j).gt.max_partnames.or.flav(j).lt.min_partnames
1 .or. partnames(flav(j)).eq.' ') then
string(next:)='(XXX)'
else
string(next:)='('//partnames(flav(j))//').'
endif
else
if(flav(j).gt.max_partnames.or.flav(j).lt.min_partnames
1 .or. partnames(flav(j)).eq.' ') then
string(next:)='XXX'
else
string(next:)=' '//partnames(flav(j))//' .'
endif
endif
next=lastnb(string)
enddo
string(next:)=' |'
end
function lastnb(string)
implicit none
integer lastnb
character *(*) string
integer ll,l
ll=len(string)
do l=ll,1,-1
if(string(l:l).ne.' ') then
lastnb=l
return
endif
enddo
end
subroutine pretty_print_flst
implicit none
include 'nlegborn.h'
character * 200 string,stringb
include 'pwhg_flst.h'
integer j,k,l,iun,lstring,lstringb,lastnb
external lastnb
c logical ini
c data ini/.true./
c save ini,iun
c if(ini) then
call newunit(iun)
open(unit=iun,file='FlavRegList',status='unknown')
c ini=.false.
c endif
c write(unit=iun,fmt=*) ' index= ',index
do j=1,flst_nalr
call from_number_to_madgraph
# (nlegreal,flst_alr(1,j),flst_emitter(j),string)
call from_number_to_madgraph
# (nlegborn,flst_uborn(1,j),-1,stringb)
lstring=lastnb(string)
lstringb=lastnb(stringb)
if(flst_emitter(j).gt.0) then
if(flst_alrres(flst_emitter(j),j).ne.0) then
write(string(lstring:),'(a,i2)')
1 'res. ',flst_alrres(flst_emitter(j),j)
endif
endif
lstring=lastnb(string)
write(iun,'(a,i3)') string(1:lstring)//' mult=', flst_mult(j)
write(iun,'(a,i3)') stringb(1:lstringb)//' uborn, mult=',
1 flst_ubmult(j)
write(iun,'(20(1x,2(1x,i2)))')
# ((flst_allreg(l,k,j),l=1,2),k=1,flst_allreg(1,0,j))
if(.not.all(flst_alrtags(:,j)==0)) then
write(iun,*) ' alr tags: ', flst_alrtags(:,j)
write(iun,*) ' uborn tags:', flst_uborntags(:,j)
endif
enddo
close(iun)
end
subroutine intassign(n,iarr1,iarr2)
implicit none
integer n,iarr1(n),iarr2(n)
integer j
do j=1,n
iarr2(j)=iarr1(j)
enddo
end
function equalintlists(n,iarr1,iarr2)
implicit none
integer n,iarr1(n),iarr2(n)
logical equalintlists
integer j
do j=1,n
if(iarr2(j).ne.iarr1(j)) then
equalintlists=.false.
return
endif
enddo
equalintlists=.true.
end
subroutine reorder_regions(alr,iborn,iret)
c It reorders the particles in the alr region in such
c a way that the corresponding underlying born is present with the
c same ordering in the flst_born(:,iborn) element.
c It also updates correspondingly
c the underlying born array, and the res and tags arrays