-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoales_40.f90
More file actions
6035 lines (5470 loc) · 230 KB
/
Coales_40.f90
File metadata and controls
6035 lines (5470 loc) · 230 KB
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
!! Coales_40.f90 is a part of the PACIAE event generator.
!! Copyright (C) 2024 PACIAE Group.
!! PACIAE is licensed under the GNU GPL v2 or later, see LICENSE for details.
!! Open source: https://github.com/ArcsaberHep/PACIAE4
!! Author: Ben-Hao Sa, June 2004 - January 2025.
!> This is the program to perform the coalescence hadronization via the
!! phenomenological coalescence model of PACIAE.
!! By Ben-Hao at CIAE on 04/06/2004
!! Last updated by An-Ke at UiO on 17/01/2025
subroutine coales( i_coal )
!! A phenomenological coalescence model.
!
! It was written by Sa Ben-Hao on 04/06/2004.
! Its input messages are in 'PYJETS'.
! Its storing array is 'PYJETS'.
! Its output message is in 'sa1_h' (in 'PYJETS' too).
! iii: the run number
!
! i_coal=1 or 0: whether to perform the gluon splitting and quark
! deexcitation or not (different for the new coales).
IMPLICIT DOUBLE PRECISION(A-H, O-Z)
IMPLICIT INTEGER(I-N)
PARAMETER (KSZJ=80000)
COMMON/PYDAT1/MSTU(200),PARU(200),MSTJ(200),PARJ(200)
COMMON/PYDAT2/KCHG(500,4),PMAS(500,4),PARF(2000),VCKM(4,4)
COMMON/PYDAT3/MDCY(500,3),MDME(8000,2),BRAT(8000),KFDP(8000,5)
COMMON/PYJETS/N,NPAD,K(KSZJ,5),P(KSZJ,5),V(KSZJ,5)
common/sa1/kjp21,non1,bp,iii,neve,nout,nosc
common/sa1_h/nn,non1_h,kn(kszj,5),pn(kszj,5),rn(kszj,5)
common/sa4_c/kqh(80,2),kfh(80,2),proh(80,2),amash(80,2),imc
common/sa5_c/kqb(80,3),kfb(80,2),prob(80,2),amasb(80,2),ibc
common/sa6_c/ithroq,ithrob,ich,non6_c,throe(4)
common/sa6_p/ithroq_p,ithrob_p,ich_p,non6_p,throe_p(4)
common/sa18/i_deex,n_deex_step,i_pT_coal,i_pT_endpoint,a_FF,aPS_c,aPS_b
common/sa24/adj1(40),nnstop,non24,zstop
common/sa28/nstr,nstra(kszj),nstrv(kszj),nstr0, &
nstr1,nstr1a(kszj),nstr1v(kszj)
common/sa36/nglu,nongu,kglu(kszj,5),pglu(kszj,5),vglu(kszj,5)
common/sa37/nth,npadth,kth(kszj,5),pth(kszj,5),vth(kszj,5)
common/sbe/nbe,nonbe,kbe(kszj,5),pbe(kszj,5),vbe(kszj,5)
common/sbh/nbh,nonh,kbh(kszj,5),pbh(kszj,5),vbh(kszj,5)
common/syspar/ipden,itden,suppm,suptm,suppc,suptc,r0p,r0t, &
napp,natt,nzpp,nztt,pio
! Arrays of freeze-out particle information.
COMMON/PYJETS_FO/ N_FO, NPAD_FO, &
K_FO(KSZJ,8), P_FO(KSZJ,7), V_FO(KSZJ,5)
!===============================================================================
! New method
call coales_new( i_coal )
return
! The following old method is no longer used.
!===============================================================================
iadj12=int(adj1(12))
! Do gluon splitting and energetic quark deexcitation only, without
! the real coalescence (i_coal=0).
if( i_coal == 0 ) goto 888
!-------------------------------------------------------------------------------
!------------------------- Variables Initialization ------------------------
rrp = 1.16
nn = 0
nth = 0
iphas = INT(adj1(21))
!------------------------- Variables Initialization ------------------------
!-------------------------------------------------------------------------------
!-------------------------------------------------------------------------------
!---------------------------- Junctions Removing ---------------------------
if( INT(adj1(40)) == 3 .or. iadj12 == 1 )then
! Remove junctions.
jb = 0
2010 do i1=jb+1,N,1
kf = K(i1,2)
if(kf /= 88)then
jb = jb + 1
goto 2020
end if
! "updad_pyj" is in sfm_30.f90.
call updad_pyj(N,i1+1,1)
N = N - 1
goto 2010
2020 end do
end if
!---------------------------- Junctions Removing ---------------------------
!-------------------------------------------------------------------------------
! g-splitting and q-deexcitation have been done before "parcas".
! So jumps out them when do the real coalescence (i_coal=1).
888 if( iadj12 == 2 .AND. i_coal == 1 ) goto 1000
!-------------------------------------------------------------------------------
!----------------------------- Gluon Splitting -----------------------------
n00 = N ! Original total entries in PYJETS
! Move gluons from 'PYJEST' to 'sa36'.
call remo_glu
! Break-up gluon (with E_g>2E_u in 'sa36') -> qqbar string
! (filling in 'PYJETS').
call break_glu
! So far, the parton list ('PYJETS') is composed of q and qbar only.
i_deex_gen = INT( adj1(16) ) ! 180923 Lei
adj17 = adj1(17)
! adj17=max(4.0,adj17)
! Shares 4-momentum in "throe_p" among partons.
if( iadj12 == 1 ) call share_p_PYJETS
!----------------------------- Gluon Splitting -----------------------------
!-------------------------------------------------------------------------------
!-------------------------------------------------------------------------------
!--------------------------- Quark Deexcitation ----------------------------
! energetic q (qbar) de-excitation
i_call_deex = 0
! the #-th newly produced daughter qqbar
i_daught_gen = 1
! the number of successful deexcitation
n_deex = 0
jb = 0
! Current total entries in PYJETS
n0 = N
if( i_deex_gen == 0 ) goto 900
700 continue
do i1=jb+1,n0,1
kf0 = K(i1,2)
ee = P(i1,4)
iflav = 1
if( kf0 < 0 ) iflav = -1
! iflav = 1 : if source parton is quark
! =-1 : if source parton is anti-quark
if( ee > adj17 )then
if( i_deex == 1 ) call deexcitation_W( i1, nstep )
if( i_deex == 2 ) call deexcitation_E( i1, nstep )
if( i_deex == 3 ) call deexcitation_PZ( i1, nstep )
if( nstep > 0 ) n_deex = n_deex + 1
! times of 'call deexcitation'
i_call_deex = i_call_deex + 1
endif
! nstep : number of deexcitation steps per source q (qbar)
! Updates n0 and does deexcitation for newly produced qqbar pairs.
if( i1 == n0 .AND. N > n0 .AND. i_daught_gen < i_deex_gen)then
jb = i1
i_daught_gen = i_daught_gen + 1
n0 = N
goto 700
end if
enddo
900 continue
! energetic q (qbar) de-excitation, finished.
! Shares the 4-momentum in 'throe_p' among partons.
if( iadj12 == 1 ) call share_p_PYJETS
if( iadj12 == 3 )then
! Records the location (line numbers) of new strings (qqbar).
do i1=n00+1,N,2
nstr1 = nstr1 + 1
nstr1a( nstr1 ) = i1
nstr1v( nstr1 ) = i1 + 1
end do
nstr0 = nstr1
! Updates "sbe".
do ii=n00+1,N,1
nbe = nbe + 1
do jj=1,5,1
kbe( nbe, jj ) = K(ii,jj)
pbe( nbe, jj ) = P(ii,jj)
vbe( nbe, jj ) = V(ii,jj)
end do
end do
end if
!--------------------------- Quark Deexcitation ----------------------------
!-------------------------------------------------------------------------------
! Just do the g-splitting and quark deexcitation, without real coalescence
1000 if( i_coal == 0 ) return
!-------------------------------------------------------------------------------
!----------------------------- Parton Sorting ------------------------------
! Sorts out PYJETS randomly. Lower case only. (In coales.f90)
call PASORT( 1, N, "pyjets", "null", "random" )
!----------------------------- Parton Sorting ------------------------------
!-------------------------------------------------------------------------------
!-------------------------------------------------------------------------------
!---------------------------- Parton coalescence ---------------------------
! Load the table of hadron (meson: pseudoscalar-spin 0 & vector-spin 1
! only, baryon: octet-spin 1/2 & decuplet-spin 3/2 only).
if( iii == 1 ) call tabhb
! iii is the event number.
! Normal coalescence process.
call hadpro(iphas)
! ithroq : the total number of quarks thrown away
! ithrob : the total number of anti-quarks thrown away
! throe : total 4-momentum of the partons thrown away
! ich : total charge of the partons thrown away
! Re-coalesce failed parton after last 'call hadpro'.
! Try coalescence without phase-space constraint agian for those partons
! failed in the normal coalescence process.
if( iphas /= 0 .AND. nth >= 2 )then
call hadpro(0)
endif
!---------------------------- Parton coalescence ---------------------------
!-------------------------------------------------------------------------------
!-------------------------------------------------------------------------------
!------------------------------ Data dumping -------------------------------
! 'sa1_h' to 'PYJETS'.
N = nn
do j2=1,5,1
do j1=1,nn,1
K(j1,j2) = kn(j1,j2)
P(j1,j2) = pn(j1,j2)
V(j1,j2) = rn(j1,j2)
enddo
enddo
!------------------------------ Data dumping -------------------------------
!-------------------------------------------------------------------------------
! Decay of unstable hadrons.
call decayh(rrp)
! Updates the freeze-out information in "PYJETS_FO" to be the
! same as the ones in "PYJETS".
do j=1,5,1
do i=1,N,1
K_FO(i,j) = K(i,j)
P_FO(i,j) = P(i,j)
V_FO(i,j) = V(i,j)
end do
end do
N_FO = N
return
end
!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
subroutine coales_new( mode_coal )
!! New coalescence model.
IMPLICIT DOUBLE PRECISION(A-H, O-Z)
IMPLICIT INTEGER(I-N)
LOGICAL IS_QUARK
PARAMETER (KSZJ=80000)
COMMON/PYJETS/N,NPAD,K(KSZJ,5),P(KSZJ,5),V(KSZJ,5)
common/sa1_h/nn,non1_h,kn(kszj,5),pn(kszj,5),rn(kszj,5)
common/sa6_p/ithroq_p,ithrob_p,ich_p,non6_p,throe_p(4)
common/sa24/adj1(40),nnstop,non24,zstop
common/sa37/nth,npadth,kth(kszj,5),pth(kszj,5),vth(kszj,5)
common/sa2/nsa,non2,ksa(kszj,5),psa(kszj,5),vsa(kszj,5)
! For the simulation control.
COMMON/SA1_PY8/ i_mode, i_tune, KF_woDecay(100), &
KF_proj, KF_targ, win, energy_B, psno, b_min, b_max
nn = 0
nth = 0
! Moves non-q/qbar (gluons, diquarks. etc.) from "PYJETS" to "aaff".
call PASORT( 1, N, "pyjets", "|kf|", "min_to_max" )
i_non_q_begin = N + 1
do i=1,N,1
KF = K(i,2)
if( IS_QUARK(KF) ) cycle
i_non_q_begin = i
exit
end do
nsa = 0
do i = i_non_q_begin, N, 1
nsa = nsa + 1
do j=1,5,1
ksa( nsa, j ) = K(i,j)
psa( nsa, j ) = P(i,j)
vsa( nsa, j ) = V(i,j)
end do
end do
N = i_non_q_begin - 1
! Normal coalescence process.
i_constraint = INT( adj1(21) )
call do_coalescence( i_constraint, mode_coal )
! Tries the coalescence without phase-space constraint agian for
! partons failed in the normal coalescence process.
if( i_constraint /= 0 .AND. nth >= 2 ) &
call do_coalescence( 0, mode_coal )
! "sa1_h" to "PYJETS".
N = nn
do j=1,5,1
do i=1,nn,1
K(i,j) = kn(i,j)
P(i,j) = pn(i,j)
V(i,j) = rn(i,j)
end do
end do
nn = 0
! Decay of unstable hadrons. (In Pythia8_fort_interface.f90)
call PADECY
! "sa2" to "PYJETS".
do i = 1, nsa, 1
N = N + 1
do j=1,5,1
K( N, j ) = ksa(i,j)
P( N, j ) = psa(i,j)
V( N, j ) = vsa(i,j)
end do
end do
nsa = 0
return
end
!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
subroutine do_gluon_splitting
!! Splits the gluons to qqbar in "PYJETS" and apends them to the end.
!! According to the Altarelli-Parisi splitting function.
!! Adjusts "sbe", the diquark list and the string list for thje specical
!! version of SFM, too.
! i_pT_split: transverse direction (pT sampling method)
! = 0, collinear.
! = 1, Gaussian.
! = 2, Exponential.
! i_Z_split: longitudinal direction (W / pz splitting method).
! = 0, random 3-momentum (ignore i_pT_split).
! = 1, Altarelli-Parisi splitting function with light cone
! momentum scheme in the rotated frame.
! = 2, Lund/FF/PS functions etc. with light cone momentum.
! = 3, random Z fraction with light cone momentum.
! = 11, Altarelli-Parisi splitting function with
! energy scheme in the rotated frame.
! = 22, Lund/FF/PS functions etc. with energy.
! = 33, random Z fraction with energy.
! = 111, Altarelli-Parisi splitting function with logitudinal
! momentum scheme in the rotated frame.
! = 222, Lund/FF/PS functions etc. with logitudinal momentum.
! = 333, random Z fraction with logitudinal momentum.
IMPLICIT DOUBLE PRECISION(A-H, O-Z)
IMPLICIT INTEGER(I-N)
PARAMETER (KSZJ=80000)
COMMON/PYDAT1/MSTU(200),PARU(200),MSTJ(200),PARJ(200)
COMMON/PYJETS/N,NPAD,K(KSZJ,5),P(KSZJ,5),V(KSZJ,5)
common/sa1/kjp21,non1,bp,iii,neve,nout,nosc
common/sa6_p/ithroq_p,ithrob_p,ich_p,non6_p,throe_p(4)
common/sa18/i_deex,n_deex_step,i_pT_coal,i_pT_endpoint,a_FF,aPS_c,aPS_b
common/sa24/adj1(40),nnstop,non24,zstop
common/sa28/nstr,nstra(kszj),nstrv(kszj),nstr0, &
nstr1,nstr1a(kszj),nstr1v(kszj)
common/sa36/nglu,nongu,kglu(kszj,5),pglu(kszj,5),vglu(kszj,5)
common/sbe/nbe,nonbe,kbe(kszj,5),pbe(kszj,5),vbe(kszj,5)
common/papr/t0,cspipiKK,dep,ddt,edipi,epin,ecsnn,ekn,ecspsn,ecspsm, &
rnt,rnp,rao,rou0,vneu,vneum,ecsspn,ecsspm,ecsen
real(kind=8) :: mass, mT2, P00(5), V00(5), rr(3)
! Hadronization model.
i_had_model = INT( adj1(12) )
! For the debug.
if( i_had_model == 1 .AND. i_deex > 99 ) return
! Splitting threshold energy.
E_threshold = adj1(39)
dm_uubar = 2D0 * amass(2)
if( E_threshold < dm_uubar ) E_threshold = dm_uubar
! Move gluons from "PYJEST" to "sa36".
call remo_glu
! Sorts gluons by energy from min to max.
call PASORT( 1, nglu, "sa36", "e", "min_to_max" )
! Width of pT sampling.
i_pT_split = i_pT_coal
! i_pT_split = 0
pT_width = adj1(35)
! The spliting method (hardcode: Altarelli-Parisi splitting function).
i_Z_split = 111
if( i_deex == 1 )then
i_Z_split = 1
else if( i_deex == 2 )then
i_Z_split = 11
end if
! Function for selecting z.
i_function_z = INT( adj1(29) )
! Backup.
PARJ41 = PARJ(41)
PARJ42 = PARJ(42)
PARJ51 = PARJ(51)
PARJ52 = PARJ(52)
PARJ53 = PARJ(53)
PARJ54 = PARJ(54)
PARJ55 = PARJ(55)
PARJ(41) = adj1(8)
PARJ(42) = adj1(9)
PARJ(51) = a_FF
PARJ(52) = a_FF
PARJ(53) = a_FF
PARJ(54) = -aPS_c
PARJ(55) = -aPS_b
!-------------------------------------------------------------------------------
!----------------------------- Gluon Splitting -----------------------------
N0 = N
nglu0 = nglu
N_SHARE = 0
! g -> qqbar
loop_gluon: do i = 1, nglu0, 1
eg = pglu(i,4)
! Too low energy to split.
if( eg <= E_threshold )then
! Shares its 4-mom to the gluon with the next lowest energy.
do j=1,4,1
pglu( i+1, j ) = pglu( i+1, j ) + pglu( i, j )
end do
! Throws it away directly. (Better y midrapidity)
! do j=1,4,1
! throe_p(j) = throe_p(j) + pglu( i, j )
! end do
! Collects gluon with too low energy.
! nglu = nglu + 1
! do j=1,4,1
! pglu( nglu, j ) = pglu( nglu, j ) + pglu( i, j )
! end do
N_SHARE = N_SHARE + 1
cycle loop_gluon
end if
! Records original information.
do j=1,5,1
P00(j) = pglu(i,j)
V00(j) = vglu(i,j)
end do
! Rotates the gluon to the frame in which px* = py* = 0,
! pz* = |p|, and the light-cone momentum W* = E+ pz* = E+ |p|.
pxg = pglu(i,1)
pyg = pglu(i,2)
pzg = pglu(i,3)
pg = SQRT( pxg**2 + pyg**2 + pzg**2 )
Wg = eg + pg
pxq = 0D0
pyq = 0D0
pzq = 0D0
pq = 0D0
eq = 0D0
Wq = 0D0
px_qbar = 0D0
py_qbar = 0D0
pz_qbar = 0D0
p_qbar = 0D0
e_qbar = 0D0
W_qbar = 0D0
KF = 0D0
mass = 0D0
!------------------------ Splitted Flavor Sampling -------------------------
N_TRY_KF = 0
100 continue
N_TRY_KF = N_TRY_KF + 1
! No more than 50 times.
if( N_TRY_KF > 50 )then
write(22,*) "Warning, N_TRY_KF > 50 in g-splitting, " &
// "i-event, i-entry, KF, px py pz e m =", &
iii, i, 21, ( P00(j), j=1, 5, 1 )
! Shares its 4-mom to the gluon with the next lowest energy.
do j=1,4,1
pglu( i+1, j ) = pglu( i+1, j ) + pglu( i, j )
end do
N_SHARE = N_SHARE + 1
cycle loop_gluon
end if
! Finds flavors of the splitted qqbar.
call break_f( eg, KF, mass )
if( PYR(1) > 0.5D0 ) KF = -KF
mass = amass( KF )
!------------------------ Splitted Flavor Sampling -------------------------
!-------------------------- Splitted pT Sampling ---------------------------
N_TRY_PT = 0
200 continue
N_TRY_PT = N_TRY_PT + 1
! No more than 50 times.
if( N_TRY_PT > 50 ) goto 100
! Generates compensated px py for splitted qqbar.
call PAPTDI( i_pT_split, pT_width, pxq, pyq, pTq )
px_qbar = -pxq
py_qbar = -pyq
mT2 = mass**2 + pxq**2 + pyq**2
!-------------------------- Splitted pT Sampling ---------------------------
!--------------------------- Splitted Z Sampling ---------------------------
N_TRY_Z = 0
loop_try_pz: do while(.true.)
N_TRY_Z = N_TRY_Z + 1
! No more than 50 times.
if( N_TRY_Z > 50 ) goto 200
! Altarelli-Parisi splitting function.
if( i_Z_split ==1 .OR. i_Z_split ==11 .OR. i_Z_split ==111 )then
do while(.true.)
Z = PYR(1)
Zg2qqbar = Z**2 + ( 1D0 - Z )**2
if( PYR(1) <= Zg2qqbar ) exit
end do
! Approximation.
! Z = PYR(1)**( 1D0/3D0 )
! Lund/FF/PS functions etc.
else if( i_Z_split==2 .OR.i_Z_split==22 .OR.i_Z_split==222 )then
dmT2_qqbar = (2D0 * mass)**2
call PAZDIS( i_function_z, 0D0, KF, -KF, dmT2_qqbar, Z )
else
! Z = 0.5D0
Z = PYR(1)
end if
! Light cone momentum scheme.
if( i_Z_split == 1 .OR. i_Z_split == 2 .OR. i_Z_split == 3 )then
Wq = Wg * Z
pzq = 0.5D0*( Wq - mT2 / MAX( 1D-4, Wq ) )
eq = 0.5D0*( Wq + mT2 / MAX( 1D-4, Wq ) )
W_qbar = Wg - Wq
pz_qbar = 0.5D0*( W_qbar - mT2 / MAX( 1D-4, W_qbar ) )
e_qbar = 0.5D0*( W_qbar + mT2 / MAX( 1D-4, W_qbar ) )
! Checks if pz acceptable.
if( pzq > 0D0 .AND. pz_qbar > 0D0 )then
exit loop_try_pz
end if
! Energy scheme.
else if(i_Z_split==11 .OR. i_Z_split==22 .OR. i_Z_split==33)then
eq = eg * Z
pzq2 = eq**2 - mass**2 - pxq**2 - pyq**2
e_qbar = eg - eq
pz_qbar2 = e_qbar**2 - mass**2 - px_qbar**2 - py_qbar**2
! Checks if pz acceptable.
if( pzq2 > 0D0 .AND. pz_qbar2 > 0D0 )then
pzq = SQRT( pzq2 )
pz_qbar = SQRT( pz_qbar2 )
exit loop_try_pz
end if
! Logitudinal momentum (pz) scheme.
else if(i_Z_split==111.OR.i_Z_split==222.OR.i_Z_split==333)then
pzq = pg * Z
pz_qbar = pg - pzq
exit loop_try_pz
! Random 3-momentum (badly sharp midrapidity).
else
! Same fraction.
! rndm = PYR(1)
! pxq = pxg * rndm
! pyq = pyg * rndm
! pzq = pzg * rndm
pxq = pxg * PYR(1)
pyq = pyg * PYR(1)
pzq = pzg * PYR(1)
px_qbar = pxg - pxq
py_qbar = pyg - pyq
pz_qbar = pzg - pzq
exit loop_try_pz
end if
end do loop_try_pz
! Ensures on-shell.
eq = SQRT( mass**2 + pxq**2 + pyq**2 + pzq**2 )
e_qbar = SQRT( mass**2 + px_qbar**2 + py_qbar**2 + pz_qbar**2 )
!--------------------------- Splitted Z Sampling ---------------------------
! Gives splitted qqbar properties.
K( N+1, 1 ) = 2
K( N+1, 2 ) = KF
K( N+1, 3 ) = 0
K( N+1, 4 ) = 0
K( N+1, 5 ) = 0
K( N+2, 1 ) = 1
K( N+2, 2 ) = -KF
K( N+2, 3 ) = 0
K( N+2, 4 ) = 0
K( N+2, 5 ) = 0
P( N+1, 1 ) = pxq
P( N+1, 2 ) = pyq
P( N+1, 3 ) = pzq
P( N+1, 4 ) = eq
P( N+1, 5 ) = mass
P( N+2, 1 ) = px_qbar
P( N+2, 2 ) = py_qbar
P( N+2, 3 ) = pz_qbar
P( N+2, 4 ) = e_qbar
P( N+2, 5 ) = mass
! Rotates the qqbar back to the original frame.
if( i_Z_split /= 0 )then
theta = PYANGL( P00(3), SQRT( P00(1)**2 + P00(2)**2 ) )
phi = PYANGL( P00(1), P00(2) )
beta_x = 0D0 ! + P00(1) / P00(4)
beta_y = 0D0 ! + P00(2) / P00(4)
beta_z = 0D0 ! + P00(3) / P00(4)
MSTU(33) = 1
call PYROBO( N+1, N+2, theta, phi, beta_x, beta_y, beta_z )
end if
! Collects the lost 4-momentum.
do j=1,4,1
throe_p(j) = throe_p(j) + ( P00(j) - P(N+1,j) - P(N+2,j) )
end do
! Gives four-positions to the splitted qqbar.
! Arranged around the source gluon within 0-0.5 fm randomly
! in each one of the three positions.
do ii = N+1, N+2, 1
do j=1,3
rr(j) = PYR(1)*0.5D0
V(ii,j) = V00(j) + rr(j)
if( PYR(1) > 0.5D0 ) V(ii,j) = V00(j) - rr(j)
end do
V(ii,4) = V00(4)
V(ii,5) = 0D0
!TODO(Lei20241016): gives formation time.
! IF( .true. )THEN
IF( .false. )THEN
i_tau = 1
! Formation time method 1.
! Proper formation time of t0/10 was assumed for partons.
if( i_tau == 1 )then
tau0 = t0 / 10D0
V(ii,4) = V00(4) + tau0 * P(ii,4) / mass
V(ii,5) = 0D0
! Formation time method 2, tau = E/mT^2.
else if( i_tau == 2 )then
V(ii,4) = V00(4) &
+ P(ii,4) / ( P(ii,1)**2 + P(ii,2)**2 + P(ii,5)**2 ) &
* PARU(3)
end if
END IF
! For the special version of SFM.
if( i_had_model == 3 )then
! Updates them to "sbe".
nbe = nbe + 1
do j=1,5,1
kbe( nbe, j ) = K(ii,j)
pbe( nbe, j ) = P(ii,j)
vbe( nbe, j ) = V(ii,j)
end do
end if
end do
! For the special version of SFM.
if( i_had_model == 3 )then
! Updates the sting list.
nstr1 = nstr1 + 1
nstr1a( nstr1 ) = nbe - 1
nstr1v( nstr1 ) = nbe
end if
N = N + 2
end do loop_gluon
nglu = 0
!----------------------------- Gluon Splitting -----------------------------
!-------------------------------------------------------------------------------
! Recovers.
PARJ(41) = PARJ41
PARJ(42) = PARJ42
PARJ(51) = PARJ51
PARJ(52) = PARJ52
PARJ(53) = PARJ53
PARJ(54) = PARJ54
PARJ(55) = PARJ55
return
end
!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
subroutine do_quark_deexcitation
!! Performs the deexcitation of exited quarks/anti-quarks.
IMPLICIT DOUBLE PRECISION(A-H, O-Z)
IMPLICIT INTEGER(I-N)
LOGICAL IS_QUARK
PARAMETER (KSZJ=80000)
COMMON/PYJETS/N,NPAD,K(KSZJ,5),P(KSZJ,5),V(KSZJ,5)
common/sa18/i_deex,n_deex_step,i_pT_coal,i_pT_endpoint,a_FF,aPS_c,aPS_b
common/sa24/adj1(40),nnstop,non24,zstop
common/sa28/nstr,nstra(kszj),nstrv(kszj),nstr0, &
nstr1,nstr1a(kszj),nstr1v(kszj)
common/sbe/nbe,nonbe,kbe(kszj,5),pbe(kszj,5),vbe(kszj,5)
! Hadronization model.
i_had_model = INT( adj1(12) )
! For the debug.
if( i_had_model == 1 .AND. i_deex > 99 ) return
! Allowed generations of q/qbar to be deexcited.
i_deex_generation = INT( adj1(16) )
! No deexcitation.
if( i_deex_generation == 0 .OR. n_deex_step == 0 ) return
! Deexcitation scheme.
i_deex_scheme = i_deex
! Generation counter of the newly produced daughter qqbars.
i_daught_generation = 1
! Original total entries in "PYJETS".
N00 = N
i_call_deex = 0
! The number of successful deexcitations.
n_deex_succ = 0
i_begin = 0
! Current total entries in PYJETS.
N0 = N
! Threshold energy.
E_threshold = adj1(17)
! Kinemtical mass of uubar ~ 2*0.33 = 0.66 GeV.
dm_uubar = 2D0 * amass(2)
if( E_threshold <= dm_uubar ) E_threshold = dm_uubar
! Performs the deexcitation.
700 continue
do i = i_begin+1, N0, 1
KF0 = K(i,2)
! Only quarks temporarily.
if( .NOT.IS_QUARK(KF0) ) cycle
! Light-cone momentum scheme (W).
ee = SQRT( P(i,4)**2 + P(i,1)**2 + P(i,2)**2 + P(i,3)**2 )
! Energy scheme (E).
if( i_deex_scheme == 2 )then
ee = P(i,4)
! Momentum scheme (PZ).
else if( i_deex_scheme == 3 )then
ee = SQRT( P(i,1)**2 + P(i,2)**2 + P(i,3)**2 )
end if
if( ee > E_threshold )then
select case( i_deex_scheme )
case(1)
call deexcitation_W( i, nstep )
case(2)
call deexcitation_E( i, nstep )
case(3)
call deexcitation_PZ( i, nstep )
case default
call deexcitation_W( i, nstep )
end select
! nstep : number of deexcitation steps actually occurred.
if( nstep > 0 ) n_deex_succ = n_deex_succ + 1
! Number of "call deexcitation".
i_call_deex = i_call_deex + 1
end if
! For the special version of SFM.
if( N > N0 .AND. i_had_model == 3 )then
! Updates them to "sbe" and the string list.
do ii = N0+1, N, 2
nbe = nbe + 1
do j=1,5,1
kbe( nbe, j ) = K(ii,j)
pbe( nbe, j ) = P(ii,j)
vbe( nbe, j ) = V(ii,j)
end do
nbe = nbe + 1
do j=1,5,1
kbe( nbe, j ) = K( ii+1, j )
pbe( nbe, j ) = P( ii+1, j )
vbe( nbe, j ) = V( ii+1, j )
end do
nstr1 = nstr1 + 1
nstr1a( nstr1 ) = nbe - 1
nstr1v( nstr1 ) = nbe
end do
end if
! Updates N0 and does the deexcitation for newly produced qqbar pairs.
if( i == N0 .AND. N > N0 &
.AND. i_daught_generation < i_deex_generation )then
i_begin = i
i_daught_generation = i_daught_generation + 1
N0 = N
goto 700
end if
end do
return
end
!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
subroutine compensate_conservation
!! Compensates the lost 4-momentum in "throe_p" for "PYJETS".
IMPLICIT DOUBLE PRECISION(A-H, O-Z)
IMPLICIT INTEGER(I-N)
PARAMETER (KSZJ=80000)
COMMON/PYJETS/N,NPAD,K(KSZJ,5),P(KSZJ,5),V(KSZJ,5)
common/sa6_p/ithroq_p,ithrob_p,ich_p,non6_p,throe_p(4)
real(kind=8) :: ps0(6), ps1(6)
! Counts (original) sums of 4-momentum.
ps0 = 0D0
do j=1,4,1
do i=1,N,1
ps0(j) = ps0(j) + P(i,j)
end do
ps0(j) = ps0(j) + throe_p(j)
end do
throe_p = 0D0
n_column = KSZJ
n_row = 5
call conse_c( P, n_column, n_row, ps0, 1, N, 1 )
! Counts sums of 4-momentum after adjustments and collects the lost ones.
ps1 = 0D0
do j=1,4,1
do i=1,N,1
ps1(j) = ps1(j) + P(i,j)
end do
throe_p(j) = ps0(j) - ps1(j)
end do
return
end
!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
subroutine do_coalescence( i_constraint, mode_coal )
!! Performs the parton coalescence hadronization.
IMPLICIT DOUBLE PRECISION(A-H, O-Z)
IMPLICIT INTEGER(I-N)
! mode_coal: = 1-5, traversal coalescence.
! other, random coalescence.
! Old scheme.
if( mode_coal >= 1 .AND. mode_coal <= 5 )then
call do_traversal_coalescence( i_constraint )
! New scheme.
else
call do_random_coalescence( i_constraint )
end if
return
end
!ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
subroutine do_traversal_coalescence( iphas )
!! Performs the parton coalescence hadronization via the list traversal.
! iphas: = 1, complete phase space constraint
! = 2, position constraint only
! = 3, momentum constraint only
! ithroq : total number of quarks thrown away
! ithrob : total number of anti-quarks thrown away
! throe : total four momentum of the partons thrown away
! ich : total charge of the partons thrown away
IMPLICIT DOUBLE PRECISION(A-H, O-Z)
IMPLICIT INTEGER(I-N)
INTEGER PYCHGE
PARAMETER (KSZJ=80000)
COMMON/PYDAT1/MSTU(200),PARU(200),MSTJ(200),PARJ(200)
COMMON/PYDAT2/KCHG(500,4),PMAS(500,4),PARF(2000),VCKM(4,4)
COMMON/PYJETS/N,NPAD,K(KSZJ,5),P(KSZJ,5),V(KSZJ,5)
common/sa1/kjp21,non1,bp,iii,neve,nout,nosc
common/sa1_h/nn,non1_h,kn(kszj,5),pn(kszj,5),rn(kszj,5)
common/sa4_c/kqh(80,2),kfh(80,2),proh(80,2),amash(80,2),imc
common/sa5_c/kqb(80,3),kfb(80,2),prob(80,2),amasb(80,2),ibc
common/sa6_c/ithroq,ithrob,ich,non6_c,throe(4)
common/sa6_p/ithroq_p,ithrob_p,ich_p,non6_p,throe_p(4)
common/sa24/adj1(40),nnstop,non24,zstop
common/sa37/nth,npadth,kth(kszj,5),pth(kszj,5),vth(kszj,5)
common/coal1/bmrat,i_mm
logical is_fail_try
!-------------------------------------------------------------------------------
!------------------------- Variables Initializing --------------------------
ithroq = 0
ithrob = 0
ich = 0
throe = 0D0
! Appends last failed quarks to the list, i.e. PYJETS + sa37.
do i=1,nth,1
N = N + 1
do j=1,5,1
K(N,j) = kth(i,j)
P(N,j) = pth(i,j)
V(N,j) = vth(i,j)
end do
end do
nth = 0
!------------------------- Variables Initializing --------------------------
!-------------------------------------------------------------------------------
!-------------------------------------------------------------------------------
!----------------------------- Parton Sorting ------------------------------
! Sorts out PYJETS randomly. Lower case only. (In coales.f90)
call PASORT( 1, N, "pyjets", "null", "random" )
!----------------------------- Parton Sorting ------------------------------
!-------------------------------------------------------------------------------
!-------------------------------------------------------------------------------
!------------------------------- Coalescence -------------------------------
! Numer of baryon generated (baryon plus).
n_baryon_p = 0
! Number of anti-baryon generated (baryon minus).
n_baryon_m = 0
n_baryon = 0
! Number of meson generated.
n_meson = 0
i_iteration = 0
i_fail_iteration = 0
max_fail_iteration = 50
if( iphas /= 0 ) max_fail_iteration = 10
is_fail_try = .false.
100 continue
i_iteration = i_iteration + 1
! Re-coalesces the failed q & qbar. No more than 50 / 10 times.
if( is_fail_try ) i_fail_iteration = i_fail_iteration + 1
do i1 = 1, N-1, 1
KF1 = K(i1,2)
do i2 = i1+1, N, 1
KF2 = K(i2,2)
isucc = 0
!----------------------------- Meson Producing -----------------------------
! Tries to produce a meason.
if( KF1 * KF2 < 0 )then
rand = PYR(1)
! bmrat: controls the ratio of baryon to meson
! if( rand <= bmrat ) cycle
sume0 = P(i1,4) + P(i2,4)
sump1 = P(i1,1) + P(i2,1)
sump2 = P(i1,2) + P(i2,2)
sump3 = P(i1,3) + P(i2,3)
cm = sume0**2 - sump1**2 - sump2**2 - sump3**2
if( cm <= 0D0 )then
write(*,*) "Warning, cm <= 0 in coal=", cm
cycle
end if
cm = SQRT(cm)
! Finds the meson state.
call findm( KF1, KF2, cm, KF_out, dmass_out, isucc )
! Failed (meson).
if( isucc == 0 ) cycle
! Phase space adjudgment.
if( iphas /= 0 )then
i_M_or_B = 2
call phas( i1, i2, 0, isucc, i_M_or_B, iphas )
! Failed (meson).
if( isucc == 0 ) cycle
end if
! Gives properties to the primary meson.
nn = nn + 1
kn(nn,1) = 1
kn(nn,2) = KF_out
kn(nn,3) = 0
kn(nn,4) = 0
kn(nn,5) = 0
pn(nn,5) = PYMASS( KF_out )
pn(nn,1) = sump1
pn(nn,2) = sump2
pn(nn,3) = sump3
e2 = sump1**2 + sump2**2 + sump3**2 + PYMASS( KF_out )**2