-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFragmentationFlavZpT.cc
2074 lines (1780 loc) · 78.9 KB
/
FragmentationFlavZpT.cc
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
// FragmentationFlavZpT.cc is a part of the PYTHIA event generator.
// Copyright (C) 2024 Torbjorn Sjostrand.
// PYTHIA is licenced under the GNU GPL v2 or later, see COPYING for details.
// Please respect the MCnet Guidelines, see GUIDELINES for details.
// Function definitions (not found in the header) for the
// StringFlav, StringZ and StringPT classes.
#include "Pythia8/FragmentationFlavZpT.h"
namespace Pythia8 {
//==========================================================================
// Functions for unnormalised and average Lund FF.
//--------------------------------------------------------------------------
// The unnormalised Lund FF
double LundFFRaw(double z, double a, double b, double c, double mT2) {
if (z <= 0. || z >= 1.) return 0.;
return pow(1. - z, a) / pow(z, c) * exp(-b * mT2 / z);
}
//--------------------------------------------------------------------------
// Average, <z>, of Lund FF.
double LundFFAvg(double a, double b, double c,
double mT2, double tol = 1.e-6) {
// Checks whether the integration succeeded.
bool check;
// Define lundFF as a function of only z, fixing a, b, c, mT2 as parameters
// Note that c must be captured by reference, since it is modified later.
auto lundFF = [=, &c](double z) { return LundFFRaw(z, a, b, c, mT2); };
// Get denominator.
double denominator = 1.;
check = integrateGauss(denominator, lundFF, 0, 1, tol);
if (!check || denominator <= 0.) return -1.;
// Get numerator
c -= 1;
double numerator = 0.;
check = integrateGauss(numerator, lundFF, 0., 1., tol);
if (!check || numerator <= 0.) return -1.;
// Done.
return numerator / denominator;
}
//==========================================================================
// The StringFlav class.
//--------------------------------------------------------------------------
// Constants: could be changed here if desired, but normally should not.
// These are of technical nature, as described for each.
// Offset for different meson multiplet id values.
const int StringFlav::mesonMultipletCode[6]
= { 1, 3, 10003, 10001, 20003, 5};
// Clebsch-Gordan coefficients for baryon octet and decuplet are
// fixed once and for all, so only weighted sum needs to be edited.
// Order: ud0 + u, ud0 + s, uu1 + u, uu1 + d, ud1 + u, ud1 + s.
const double StringFlav::baryonCGOct[6]
= { 0.75, 0.5, 0., 0.1667, 0.0833, 0.1667};
const double StringFlav::baryonCGDec[6]
= { 0., 0., 1., 0.3333, 0.6667, 0.3333};
//--------------------------------------------------------------------------
// Initialize data members of the flavour generation.
void StringFlav::init() {
// Basic parameters for generation of new flavour.
probQQtoQ = parm("StringFlav:probQQtoQ");
probStoUD = parm("StringFlav:probStoUD");
probSQtoQQ = parm("StringFlav:probSQtoQQ");
probQQ1toQQ0 = parm("StringFlav:probQQ1toQQ0");
// Spin parameters for combining two quarks to a diquark.
vector<double> pQQ1tmp = settingsPtr->pvec("StringFlav:probQQ1toQQ0join");
for (int i = 0; i < 4; ++i)
probQQ1join[i] = 3. * pQQ1tmp[i] / (1. + 3. * pQQ1tmp[i]);
// Parameters for normal meson production.
for (int i = 0; i < 4; ++i) mesonRate[i][0] = 1.;
mesonRate[0][1] = parm("StringFlav:mesonUDvector");
mesonRate[1][1] = parm("StringFlav:mesonSvector");
mesonRate[2][1] = parm("StringFlav:mesonCvector");
mesonRate[3][1] = parm("StringFlav:mesonBvector");
// Parameters for L=1 excited-meson production.
mesonRate[0][2] = parm("StringFlav:mesonUDL1S0J1");
mesonRate[1][2] = parm("StringFlav:mesonSL1S0J1");
mesonRate[2][2] = parm("StringFlav:mesonCL1S0J1");
mesonRate[3][2] = parm("StringFlav:mesonBL1S0J1");
mesonRate[0][3] = parm("StringFlav:mesonUDL1S1J0");
mesonRate[1][3] = parm("StringFlav:mesonSL1S1J0");
mesonRate[2][3] = parm("StringFlav:mesonCL1S1J0");
mesonRate[3][3] = parm("StringFlav:mesonBL1S1J0");
mesonRate[0][4] = parm("StringFlav:mesonUDL1S1J1");
mesonRate[1][4] = parm("StringFlav:mesonSL1S1J1");
mesonRate[2][4] = parm("StringFlav:mesonCL1S1J1");
mesonRate[3][4] = parm("StringFlav:mesonBL1S1J1");
mesonRate[0][5] = parm("StringFlav:mesonUDL1S1J2");
mesonRate[1][5] = parm("StringFlav:mesonSL1S1J2");
mesonRate[2][5] = parm("StringFlav:mesonCL1S1J2");
mesonRate[3][5] = parm("StringFlav:mesonBL1S1J2");
// Store sum over multiplets for Monte Carlo generation.
for (int i = 0; i < 4; ++i) mesonRateSum[i]
= mesonRate[i][0] + mesonRate[i][1] + mesonRate[i][2]
+ mesonRate[i][3] + mesonRate[i][4] + mesonRate[i][5];
// Parameters for uubar - ddbar - ssbar meson mixing.
for (int spin = 0; spin < 6; ++spin) {
double theta;
if (spin == 0) theta = parm("StringFlav:thetaPS");
else if (spin == 1) theta = parm("StringFlav:thetaV");
else if (spin == 2) theta = parm("StringFlav:thetaL1S0J1");
else if (spin == 3) theta = parm("StringFlav:thetaL1S1J0");
else if (spin == 4) theta = parm("StringFlav:thetaL1S1J1");
else theta = parm("StringFlav:thetaL1S1J2");
double alpha = (spin == 0) ? 90. - (theta + 54.7) : theta + 54.7;
alpha *= M_PI / 180.;
// Fill in (flavour, spin)-dependent probability of producing
// the lightest or the lightest two mesons of the nonet.
mesonMix1[0][spin] = 0.5;
mesonMix2[0][spin] = 0.5 * (1. + pow2(sin(alpha)));
mesonMix1[1][spin] = 0.;
mesonMix2[1][spin] = pow2(cos(alpha));
// Fill in rates for multiplication.
mesMixRate1[0][spin] = mesonMix1[0][spin];
mesMixRate2[0][spin] = mesonMix2[0][spin] - mesonMix1[0][spin];
mesMixRate3[0][spin] = 1.0 - mesMixRate1[0][spin] - mesMixRate2[0][spin];
mesMixRate1[1][spin] = mesonMix1[1][spin];
mesMixRate2[1][spin] = mesonMix2[1][spin] - mesonMix1[1][spin];
mesMixRate3[1][spin] = 1.0 - mesMixRate1[1][spin] - mesMixRate2[1][spin];
}
// Additional suppression of eta and etaPrime.
etaSup = parm("StringFlav:etaSup");
etaPrimeSup = parm("StringFlav:etaPrimeSup");
// Sum of baryon octet and decuplet weights.
decupletSup = parm("StringFlav:decupletSup");
for (int i = 0; i < 6; ++i) baryonCGSum[i]
= baryonCGOct[i] + decupletSup * baryonCGDec[i];
// Maximum SU(6) weight for ud0, ud1, uu1 types.
baryonCGMax[0] = max( baryonCGSum[0], baryonCGSum[1]);
baryonCGMax[1] = baryonCGMax[0];
baryonCGMax[2] = max( baryonCGSum[2], baryonCGSum[3]);
baryonCGMax[3] = baryonCGMax[2];
baryonCGMax[4] = max( baryonCGSum[4], baryonCGSum[5]);
baryonCGMax[5] = baryonCGMax[4];
// Popcorn baryon parameters.
popcornRate = parm("StringFlav:popcornRate");
popcornSpair = parm("StringFlav:popcornSpair");
popcornSmeson = parm("StringFlav:popcornSmeson");
// Suppression of leading (= first-rank) baryons.
suppressLeadingB = flag("StringFlav:suppressLeadingB");
lightLeadingBSup = parm("StringFlav:lightLeadingBSup");
heavyLeadingBSup = parm("StringFlav:heavyLeadingBSup");
// Use Gaussian model but with mT2 suppression?
mT2suppression = flag("StringPT:mT2suppression");
sigmaHad = (sqrt(2.0)*parm("StringPT:sigma"));
widthPreStrange = parm("StringPT:widthPreStrange");
widthPreDiquark = parm("StringPT:widthPreDiquark");
useWidthPre = (widthPreStrange > 1.0) || (widthPreDiquark > 1.0);
// Enhanced-rate prefactor for MPIs and/or nearby string pieces.
closePacking = flag("ClosePacking:doClosePacking");
closePackingFacPT2 = pow2( parm("ClosePacking:facPT") );
qqKappa = flag("ClosePacking:qqKappa");
closePackingFacQQ2 = pow2(parm("ClosePacking:facQQ"));
exponentMPI = parm("ClosePacking:expMPI");
exponentNSP = parm("ClosePacking:expNSP");
// Save "vacuum" parameters for closepacking init() function.
probStoUDSav = probStoUD;
probQQtoQSav = probQQtoQ;
probSQtoQQSav = probSQtoQQ;
probQQ1toQQ0Sav = probQQ1toQQ0;
alphaQQSav = (1. + 2. * probSQtoQQ * probStoUD + 9. * probQQ1toQQ0
+ 6. * probSQtoQQ * probQQ1toQQ0 * probStoUD
+ 3. * probQQ1toQQ0 * pow2(probSQtoQQ * probStoUD)) / (2. + probStoUD);
// Calculate derived parameters.
initDerived();
// Use thermal model?
thermalModel = flag("StringPT:thermalModel");
if (thermalModel || mT2suppression) {
// Temperature parameters for thermal model.
temperature = parm("StringPT:temperature");
tempPreFactor = parm("StringPT:tempPreFactor");
// Hadron multiplets in thermal model.
mesonNonetL1 = flag("StringFlav:mesonNonetL1");
nNewQuark = mode("StringFlav:nQuark");
// Fill list of possible hadrons that are allowed to be produced.
// Also include a list of "emergency" hadrons that are needed to get
// rid of all possible endpoint (di)quarks.
vector<int> hadIDsProd, hadIDsHvyC, hadIDsHvyB;
// Baryon octet and decuplet.
int baryonLight[18] = { 2112, 2212, 3112, 3122, 3212, 3222, 3312, 3322,
1114, 2114, 2214, 2224, 3114, 3214, 3224, 3314,
3324, 3334 };
int baryonHvyC[22] = { 4112, 4122, 4132, 4212, 4222, 4232, 4312, 4322,
4332, 4412, 4422, 4432,
4114, 4214, 4224, 4314, 4324, 4334, 4414, 4424,
4434, 4444 };
int baryonHvyB[35] = { 5112, 5122, 5132, 5142, 5212, 5222, 5232, 5242,
5312, 5322, 5332, 5342, 5412, 5422, 5432, 5442,
5512, 5522, 5532, 5542,
5114, 5214, 5224, 5314, 5324, 5334, 5414, 5424,
5434, 5444, 5514, 5524, 5534, 5544, 5554 };
for (int i = 0; i < 18; i++) hadIDsProd.push_back( baryonLight[i] );
// Check how many heavy baryons to include.
if (nNewQuark > 4) {
for (int i = 0; i < 35; i++) hadIDsProd.push_back( baryonHvyB[i] );
} else {
// Only include lightest combinations.
int bBar[9] = { 5112, 5122, 5132, 5212, 5222, 5232, 5312, 5322, 5332 };
for (int i = 0; i < 9; i++) {
hadIDsHvyB.push_back( bBar[i] );
hadIDsHvyB.push_back( -bBar[i] );
}
}
if (nNewQuark > 3) {
for (int i = 0; i < 22; i++) hadIDsProd.push_back( baryonHvyC[i] );
} else {
// Only include lightest combinations.
int cBar[9] = { 4112, 4122, 4132, 4212, 4222, 4232, 4312, 4322, 4332 };
for (int i = 0; i < 9; i++) {
hadIDsHvyC.push_back( cBar[i] );
hadIDsHvyC.push_back( -cBar[i] );
}
}
// Antibaryons.
int sizeNow = int(hadIDsProd.size());
for (int i = 0; i < sizeNow; i++) hadIDsProd.push_back( -hadIDsProd[i] );
// Mesons nonets. Take pseudoscalar PDG codes as basis.
int mesonPSLight[9] = { 311, 321, 211, -311, -321, -211, 111, 221, 331 };
int mesonPSHvyC[7] = { 411, 421, 431, -411, -421, -431, 441 };
int mesonPSHvyB[9] = { 511, 521, 531, 541, -511, -521, -531, -541, 551 };
vector<int> mesonPS;
for (int i = 0; i < 9; i++) mesonPS.push_back( mesonPSLight[i] );
// Check how many heavy mesons to include. If not included in ordinary
// production, fill minimal list with "emergency" hadrons
if (nNewQuark > 4) {
for (int i = 0; i < 9; i++) mesonPS.push_back( mesonPSHvyB[i] );
} else {
// Include all possible combinations, only pseudoscalar as they
// are the lightest ones.
int bMes[10] = { 511, 521, 531, 541, -511, -521, -531, -541, 551 };
for (int i = 0; i < 10; i++) hadIDsHvyB.push_back( bMes[i] );
}
if (nNewQuark > 3) {
for (int i = 0; i < 7; i++) mesonPS.push_back( mesonPSHvyC[i] );
} else {
// Include all possible combinations, only pseudoscalar as they
// are the lightest ones.
int cMes[8] = { 411, 421, 431, -411, -421, -431, 441 };
for (int i = 0; i < 8; i++) hadIDsHvyC.push_back( cMes[i] );
}
int nMeson = int(mesonPS.size());
// Pseudoscalar nonet J=0, S=0, L=0.
for (int i = 0; i < nMeson; i++)
hadIDsProd.push_back( mesonPS[i] );
// Vector nonet J=1, S=1, L=0.
for (int i = 0; i < nMeson; i++)
hadIDsProd.push_back( mesonPS[i] + (mesonPS[i] > 0 ? 2 : -2) );
// Include L=1 nonets?
if (mesonNonetL1) {
// Pseudovector nonet J=1, S=0, L=1.
for (int i = 0; i < nMeson; i++)
hadIDsProd.push_back( mesonPS[i] + (mesonPS[i] > 0 ? 10002 : -10002) );
// Scalar nonet J=0, S=1, L=1.
for (int i = 0; i < nMeson; i++)
hadIDsProd.push_back( mesonPS[i] + (mesonPS[i] > 0 ? 10000 : -10000) );
// Pseudovector nonet J=1, S=1, L=1.
for (int i = 0; i < nMeson; i++)
hadIDsProd.push_back( mesonPS[i] + (mesonPS[i] > 0 ? 20002 : -20002) );
// Tensor nonet J=2, S=1, L=1.
for (int i = 0; i < nMeson; i++)
hadIDsProd.push_back( mesonPS[i] + (mesonPS[i] > 0 ? 4 : -4) );
}
// Fill list of all hadrons ids (ordinary and "emergency").
vector<int> hadIDsAll;
for (int i = 0; i < int(hadIDsProd.size()); i++)
hadIDsAll.push_back( hadIDsProd[i] );
for (int i = 0; i < int(hadIDsHvyC.size()); i++)
hadIDsAll.push_back( hadIDsHvyC[i] );
for (int i = 0; i < int(hadIDsHvyB.size()); i++)
hadIDsAll.push_back( hadIDsHvyB[i] );
// Fill map with IDs of hadron constituents for all hadrons.
for (int i = 0; i < int(hadIDsAll.size()); i++) {
int id = hadIDsAll[i];
int idAbs = abs(id);
vector< pair<int,int> > quarkCombis;
// Baryon can be split into q + qq in several different ways.
if (particleDataPtr->isBaryon(id)) {
bool isOctet = ( (idAbs % 10) == 2 );
int q3 = (idAbs/10) % 10;
int q2 = (idAbs/100) % 10;
int q1 = (idAbs/1000) % 10;
bool threeFlav = q1 != q2 && q1 != q3 && q2 != q3;
// Baryon octet J=1/2.
if (isOctet) {
if (threeFlav) {
// Add (q2+q3)_0/1 + q1.
// if (q2 < q3) (q2+q3)_0 and if (q2 > q3) (q2+q3)_1.
int j = (q2 < q3) ? 1 : 3;
int qn[2] = { min( q3, q2), max( q3, q2) };
addQuarkDiquark(quarkCombis, q1,
1000 * qn[1] + 100 * qn[0] + j, id);
// Add other combinations. Can be both, J=0 or J=1.
for (j = 1; j < 4; j += 2) {
// (q1+q3)j + q2
addQuarkDiquark(quarkCombis, q2, 1000 * q1 + 100 * q3 + j, id);
// (q1+q2)j + q3
addQuarkDiquark(quarkCombis, q3, 1000 * q1 + 100 * q2 + j, id);
}
} else {
// Quarks with the same flavour form J=1,
// all other combinations can be both, J=0 or J=1.
for (int j = 1; j < 4; j += 2) {
// (q1+q2)1 + q3
if ( j == 3 || q1 != q2 )
addQuarkDiquark(quarkCombis, q3, 1000 * q1 + 100 * q2 + j, id);
// (q1+q3)1 + q2
if ( j == 3 || q1 != q3 )
addQuarkDiquark(quarkCombis, q2, 1000 * q1 + 100 * q3 + j, id);
// (q2+q3)1 + q1
if ( j == 3 || q2 != q3 )
addQuarkDiquark(quarkCombis, q1, 1000 * q2 + 100 * q3 + j, id);
}
}
}
// Baryon decuplet J=3/2.
else {
// All quark pairs form diquarks with J=1.
// (q1+q2)1 + q3
addQuarkDiquark(quarkCombis, q3, 1000 * q1 + 100 * q2 + 3, id);
// (q1+q3)1 + q2
addQuarkDiquark(quarkCombis, q2, 1000 * q1 + 100 * q3 + 3, id);
// (q2+q3)1 + q1
addQuarkDiquark(quarkCombis, q1, 1000 * q2 + 100 * q3 + 3, id);
}
// Mesons usually have a trivial subdivision into quark + antiquark.
// Mixing of diagonal mesons is taken into account later.
} else {
int q1 = (idAbs/100) % 10;
bool uptype1 = (q1 % 2 == 0);
int q2 = (idAbs/10) % 10;
bool uptype2 = (q2 % 2 == 0);
int quark = q1;
int antiQuark = q2;
// id > 0: downtype+uptype: up = quark, down = antiquark (default)
// id > 0: same type -> larger id decides
if ( uptype2 && !uptype1 ) swap( quark, antiQuark);
if ( (q1 > q2 && !uptype1 && !uptype2)
|| (q2 > q1 && uptype2 && uptype1) ) swap( quark, antiQuark);
if (id < 0) swap( quark, antiQuark);
quarkCombis.push_back( make_pair( quark, -antiQuark) );
}
hadronConstIDs[id] = quarkCombis;
}
// Copy into smaller versions (one for ordinary production, two for
// "emergency")
map< int, vector< pair<int,int> > > hadConstIDsC, hadConstIDsB,
hadConstIDsProd;
for (int i=0; i<int(hadIDsAll.size()); i++) {
int id = hadIDsAll[i];
if (find(hadIDsProd.begin(), hadIDsProd.end(), id) != hadIDsProd.end())
hadConstIDsProd[id] = hadronConstIDs[id];
if (find(hadIDsHvyC.begin(), hadIDsHvyC.end(), id) != hadIDsHvyC.end())
hadConstIDsC[id] = hadronConstIDs[id];
if (find(hadIDsHvyB.begin(), hadIDsHvyB.end(), id) != hadIDsHvyB.end())
hadConstIDsB[id] = hadronConstIDs[id];
}
map< int, map< int, vector< pair<int,int> > > > hadConstIDsHvy;
hadConstIDsHvy[4] = hadConstIDsC;
hadConstIDsHvy[5] = hadConstIDsB;
// List with all possible initial (di)quarks we could get.
int inIDs[26] = { 1, 2, 3, 4, 5, 1103, 2203, 3303, 2101, 2103, 3101,
3103, 3201, 3203, 4101, 4103, 4201, 4203, 4301,
4303, 5101, 5103, 5201, 5203, 5301, 5303 };
int inIDsHvyC[2] = { 4403, -4403 };
int inIDsHvyB[6] = { 5503, -5503, 5401, -5401, 5403, -5403 };
vector<int> incomingIDs;
for (int i = 0; i < 26; i++) {
incomingIDs.push_back( inIDs[i]);
incomingIDs.push_back(-inIDs[i]);
}
// If we include heavy quark hadrons we include the following diquarks in
// addition.
if (nNewQuark > 3) {
for (int i = 0; i < 2; i++) incomingIDs.push_back(inIDsHvyC[i]);
if (nNewQuark > 4) {
for (int i = 0; i < 6; i++) incomingIDs.push_back( inIDsHvyB[i]);
}
}
int nIncome = int(incomingIDs.size());
// Loop over list with all possible initial (di)quarks.
// Fill map possibleHadrons with
// key = initial (di)quark id, value = list of possible hadron ids
// + nr in hadronConstIDs.
for (int iIDin = 0; iIDin < nIncome; iIDin++) {
int idIn = incomingIDs[iIDin];
int idInAbs = abs(idIn);
map< int, vector< pair<int,int> > > hadConstIDsNow = hadConstIDsProd;
// For heavy quarks add "emergency" list, if needed.
for (int iHvy = nNewQuark+1; iHvy <= 5; iHvy++) {
if (particleDataPtr->nQuarksInCode(idInAbs, iHvy) > 0)
for (map< int, vector< pair<int,int> > >::iterator
it = hadConstIDsHvy[iHvy].begin();
it != hadConstIDsHvy[iHvy].end(); ++it)
hadConstIDsNow[it->first] = it->second;
}
// Fill list: first parameter of pair is hadron ID, second is nr of
// hadron constituents in the list.
vector< pair<int,int> > possibleHadronIDs;
// Loop through list with hadrons and their (di)quark content,
// check if possible to produce given the choice of initial (di)quark.
for (map< int, vector< pair<int,int> > >::iterator
it = hadConstIDsNow.begin(); it != hadConstIDsNow.end(); ++it) {
vector< pair<int,int> > constituentIDs = it->second;
int nConst = int(constituentIDs.size());
int hadronID = it->first;
// Loop over constituent IDs.
for (int iConst = 0; iConst < nConst; iConst++) {
int ID1 = constituentIDs[iConst].first;
int ID2 = constituentIDs[iConst].second;
if ( (ID1 == idIn) || (ID2 == idIn) ) {
possibleHadronIDs.push_back( make_pair(hadronID,iConst) );
// To include uubar-ddbar-ssbar mixing include all diagonal mesons.
if ( (idInAbs < 4) && (ID1 == -ID2) ) {
if (idInAbs == 1) {
possibleHadronIDs.push_back( make_pair(hadronID+110,iConst) );
possibleHadronIDs.push_back( make_pair(hadronID+220,iConst) );
} else if (idInAbs == 2) {
possibleHadronIDs.push_back( make_pair(hadronID-110,iConst) );
possibleHadronIDs.push_back( make_pair(hadronID+110,iConst) );
} else if (idInAbs == 3) {
possibleHadronIDs.push_back( make_pair(hadronID-220,iConst) );
possibleHadronIDs.push_back( make_pair(hadronID-110,iConst) );
}
}
}
}
}
if (int(possibleHadronIDs.size()) < 1)
loggerPtr->ERROR_MSG("no possible hadrons found");
possibleHadrons[idIn] = possibleHadronIDs;
}
// Calculate baryon octet and decuplet weighting factors
// based on Clebsch-Gordan coefficients and spin counting.
// Parameters: qDi1 qDi2 q3 spin.
// Zero for flavour=0 and same flavour diquarks with J=0.
for (int q1 = 0; q1 < 6; q1++) {
for (int q2 = 0; q2 < 6; q2++) {
baryonOctWeight[q1][q1][q2][0] = 0.0; // qq0 + r
baryonDecWeight[q1][q1][q2][0] = 0.0; // qq0 + r
for (int spin = 0; spin < 1; spin++) {
baryonOctWeight[ 0][q1][q2][spin] = 0.0;
baryonOctWeight[q1][ 0][q2][spin] = 0.0;
baryonOctWeight[q1][q2][ 0][spin] = 0.0;
baryonDecWeight[ 0][q1][q2][spin] = 0.0;
baryonDecWeight[q1][ 0][q2][spin] = 0.0;
baryonDecWeight[q1][q2][ 0][spin] = 0.0;
}
}
}
// Clebsch-Gordon for the rest.
for (int q1 = 1; q1 < 6; q1++) {
baryonOctWeight[q1][q1][q1][1] = 0.0; // qq1 + q
baryonDecWeight[q1][q1][q1][1] = 1.0;
for (int q2 = 1; q2 < 6; q2++) if (q1!=q2) {
baryonOctWeight[q1][q1][q2][1] = 0.1667; // qq1 + r
baryonDecWeight[q1][q1][q2][1] = 0.3333;
baryonOctWeight[q1][q2][q1][0] = 0.75; // qr0 + q
baryonDecWeight[q1][q2][q1][0] = 0.0;
baryonOctWeight[q2][q1][q1][0] = 0.75; // rq0 + q
baryonDecWeight[q2][q1][q1][0] = 0.0;
baryonOctWeight[q1][q2][q1][1] = 0.0833; // qr1 + q
baryonDecWeight[q1][q2][q1][1] = 0.6667;
baryonOctWeight[q2][q1][q1][1] = 0.0833; // rq1 + q
baryonDecWeight[q2][q1][q1][1] = 0.6667;
for (int q3 = 0; q3 < 6; q3++) if ((q1 != q3) && (q2 != q3)) {
baryonOctWeight[q1][q2][q3][0] = 0.5; // qr0 + s
baryonDecWeight[q1][q2][q3][0] = 0.0;
baryonOctWeight[q1][q2][q3][1] = 0.1667; // qr1 + s
baryonDecWeight[q1][q2][q3][1] = 0.3333;
}
}
}
// Spin 1 diquarks get extra factor of 3. And all factors
// get relative baryon-to-meson ratio.
double BtoMratio = parm("StringFlav:BtoMratio");
for (int q1 = 0; q1 < 6; q1++) {
for (int q2 = 0; q2 < 6; q2++) {
for (int q3 = 0; q3 < 6; q3++) {
for (int spin = 0; spin < 2; spin++) {
baryonOctWeight[q1][q2][q3][spin] *= BtoMratio;
baryonDecWeight[q1][q2][q3][spin] *= BtoMratio;
if (spin == 1) {
baryonOctWeight[q1][q2][q3][1] *= 3.0;
baryonDecWeight[q1][q2][q3][1] *= 3.0;
}
}
}
}
}
// Go through the list of possible hadrons and calculate the prefactor
// that will multiply the rate.
double strSup = parm("StringFlav:StrangeSuppression");
for (int iIDin = 0; iIDin < nIncome; iIDin++) {
int idIn = incomingIDs[iIDin];
int idInAbs = abs(idIn);
vector< pair<int,int> > possibleHadronsNow = possibleHadrons[idIn];
vector<double> prefactors;
for (int iHad = 0; iHad < int(possibleHadronsNow.size()); iHad++) {
double prefacNow = 1.0;
// Get hadron and constituents.
int hadronID = possibleHadronsNow[iHad].first;
int hadronIDabs = abs(hadronID);
int iConst = possibleHadronsNow[iHad].second;
int ID1 = hadronConstIDs[hadronID][iConst].first;
int ID2 = hadronConstIDs[hadronID][iConst].second;
// Extra suppression factor for s/c/b quarks.
double nHeavy = 0.0;
for (int i = 3; i <= 5; i++) {
nHeavy += particleDataPtr->nQuarksInCode( ID1, i);
nHeavy += particleDataPtr->nQuarksInCode( ID2, i);
}
prefacNow *= pow(strSup, nHeavy);
if (particleDataPtr->isMeson(hadronID)) {
// Extra factor according to last digit for spin counting.
prefacNow *= (abs(hadronID) % 10);
// Include correct uubar-ddbar-ssbar mixing factor;
if ( (idInAbs < 4) && (ID1 == -ID2) ) {
int flav = ( (idInAbs < 3) ? 0 : 1 );
// Get spin used as counter for the different multiplets
int spin = getMesonSpinCounter(hadronID);
double mesonMix[3] = { mesMixRate1[flav][spin],
mesMixRate2[flav][spin],
mesMixRate3[flav][spin] };
prefacNow *= mesonMix[abs(ID1)-1];
}
} else {
// Check if baryon is octet or decuplet.
bool isOct = ((hadronIDabs % 10) == 2);
// Make sure ID2 is diquark.
if (abs(ID2) < abs(ID1)) swap(ID1,ID2);
// Extract quark flavours and spin from diquark.
int Q1 = ( (abs(ID2)/1000) % 10 );
int Q2 = ( (abs(ID2)/100) % 10 );
if (Q1 > 5 || Q2 > 5) {
loggerPtr->ERROR_MSG("invalid quark content flavours for diquark");
continue;
}
int diqSpin = ( ((abs(ID2) % 10) == 1) ? 0 : 1 );
// Single quark.
int Q3 = abs(ID1);
// Find Clebsch-Gordan: q1 in DQ | q2 in DQ | q3 | S of DQ
if (isOct) prefacNow *= baryonOctWeight[Q1][Q2][Q3][diqSpin];
else prefacNow *= baryonDecWeight[Q1][Q2][Q3][diqSpin];
// Special cases for Lamda (312) and Sigma (321) or the like.
if ( isOct && (Q1!=Q2) && (Q1!=Q3) && (Q2!=Q3) ) {
// Extract the two lightest quarks from hadron.
int Qhad1 = ( (hadronIDabs/10) % 10 );
int Qhad2 = ( (hadronIDabs/100) % 10 );
int QhadMin = min(Qhad1,Qhad2);
int QhadMax = max(Qhad1,Qhad2);
// Extract the two quarks from the diquark.
int QdiqMin = min(Q1,Q2);
int QdiqMax = max(Q1,Q2);
// Don't do anything if (12) or (21) is diquark.
if ( !((QdiqMin == QhadMin) && (QdiqMax == QhadMax)) ) {
// Sigma (321)
if (Qhad2 > Qhad1) prefacNow *= ( (diqSpin == 0) ? 0.75 : 0.25 );
// Lamda (312)
else prefacNow *= ( (diqSpin == 0) ? 0.25 : 0.27 );
}
}
}
// Save prefactor.
prefactors.push_back(prefacNow);
}
possibleRatePrefacs[idIn] = prefactors;
}
// Now the same again for joining the last two (di)quarks into hadron.
for (int iIDin1 = 0; iIDin1 < nIncome; iIDin1++) {
int idIn1 = incomingIDs[iIDin1];
int idIn1Abs = abs(idIn1);
// Loop over possible partners, start with next quark.
for (int iIDin2 = iIDin1+1; iIDin2 < nIncome; iIDin2++) {
int idIn2 = incomingIDs[iIDin2];
int idIn2Abs = abs(idIn2);
int idInNow[2] = { min(idIn1,idIn2), max(idIn1,idIn2) };
pair<int,int> inPair = pair<int,int>(idInNow[0], idInNow[1]);
// Skip all combinations with two diquarks.
if ( (idIn1Abs > 1000) && (idIn2Abs > 1000) ) continue;
// Skip all combinations with two quarks or two antiquarks.
if ( ( ((idIn1 > 0) && (idIn2 > 0)) || ((idIn1 < 0) && (idIn2 < 0)) )
&& (idIn1Abs < 10) && (idIn2Abs < 10) ) continue;
// Skip all combinations with quark-antidiquark and
// antiquark-diquark. (1 = diquark, 2 = quark not possible).
if ( ((idIn2 > 1000) && (idIn1Abs < 10) && (idIn1 < 0)) ||
((idIn2 < -1000) && (idIn1Abs < 10) && (idIn1 > 0)) ) continue;
// If we are not including heavy quarks skip combinations
// of heavy quark - diquark with heavy quark.
if ((idIn1Abs < 10) && (idIn2Abs > 1000)) {
vector< pair<int,int> > hvyCombs;
if (nNewQuark < 5) {
hvyCombs.push_back(make_pair(4,4));
if (nNewQuark < 4) {
hvyCombs.push_back(make_pair(5,4));
hvyCombs.push_back(make_pair(4,5));
hvyCombs.push_back(make_pair(5,5));
}
}
bool skip = false;
for (int iComb = 0; iComb < int(hvyCombs.size()); iComb++) {
int idNow[2] = { hvyCombs[iComb].first, hvyCombs[iComb].second };
if ( (particleDataPtr->nQuarksInCode(idIn2Abs,idNow[0]) > 0) &&
(idIn1Abs == idNow[1]) ) skip = true;
}
if (skip) continue;
}
// Now decide which list of possible hadrons to use.
// As we might have to use the special list for heavy quarks we
// use the maximum of the absolute ids in case of two quarks and
// check the maximum flavour in case of quark - diquark pair.
int idUse;
if ( (idIn1Abs < 10) && (idIn2Abs < 10) ) { // quark - quark
idUse = ( (idIn1Abs > idIn2Abs) ? idIn1 : idIn2 );
} else { // quark - diquark
// Check if diquark contains a heavier flavour than the quark.
bool useDiquark = false;
for (int plus = 1; plus < 5; plus++)
if (particleDataPtr->nQuarksInCode(idIn2Abs, idIn1Abs + plus) > 0)
useDiquark = true;
idUse = ( useDiquark ? idIn2 : idIn1 );
}
vector<double> possibleRatePrefacsNow = possibleRatePrefacs[idUse];
vector< pair<int,int> > possibleHadronsNow = possibleHadrons[idUse];
// New list to fill.
vector< pair<int,int> > possibleHadronsNew;
vector<double> possibleRatePrefacsNew;
// Now loop over possible hadrons and check if other (di)quark
// in constituents matches idIn2.
for (int iHad = 0; iHad < int(possibleHadronsNow.size()); iHad++) {
// Get constituents.
int hadronID = possibleHadronsNow[iHad].first;
int iConst = possibleHadronsNow[iHad].second;
int ID1 = hadronConstIDs[hadronID][iConst].first;
int ID2 = hadronConstIDs[hadronID][iConst].second;
if ( ((ID1 == idIn1) && (ID2 == idIn2)) ||
((ID1 == idIn2) && (ID2 == idIn1)) ) {
// Can take this combination.
possibleHadronsNew.push_back(possibleHadronsNow[iHad]);
possibleRatePrefacsNew.push_back(possibleRatePrefacsNow[iHad]);
}
}
if (int(possibleHadronsNew.size()) < 1)
loggerPtr->ERROR_MSG("no possible hadrons found for last two");
// Save.
possibleRatePrefacsLast[inPair] = possibleRatePrefacsNew;
possibleHadronsLast[inPair] = possibleHadronsNew;
}
}
}
// Initialize winning parameters.
hadronIDwin = 0;
idNewWin = 0;
hadronMassWin = -1.0;
}
//--------------------------------------------------------------------------
// Initialise parameters when using close packing.
void StringFlav::init(double kappaRatio, double strangeFac, double probQQmod) {
double kappaInvRatio = 1. / pow(kappaRatio, 2*exponentNSP);
// Altered probabilities with close packing.
probStoUD = pow(probStoUDSav, kappaInvRatio * (1 - strangeFac));
probSQtoQQ = pow(probSQtoQQSav, kappaInvRatio);
probQQ1toQQ0 = pow(probQQ1toQQ0Sav, kappaInvRatio);
probQQtoQ = probQQtoQSav;
// If allowing effective kappa to enhance baryon production, do this.
if (qqKappa) {
double alphaQQ = 1. + 2. * probSQtoQQ * probStoUD + 9. * probQQ1toQQ0
+ 6. * probSQtoQQ * probQQ1toQQ0 * probStoUD
+ 3. * probQQ1toQQ0 * pow2(probSQtoQQ * probStoUD);
alphaQQ *= 1. / (2 + probStoUD);
// Diquark scaling power controlled by closePackingFacQQ.
double kappaRatioQQ = 1. + closePackingFacQQ2 * ( kappaRatio - 1.);
double kappaInvRatioQQ = 1. / pow(kappaRatioQQ, 2*exponentNSP);
probQQtoQ = alphaQQ * pow( (probQQtoQSav / alphaQQSav ), kappaInvRatioQQ);
}
// Probability of a diquark being formed can scale with the probability
// of a fluctuation on a string to not connect (and break) a nearby string.
// for x probability of reconnection,
// probability of diquark survival scales with 1/2 * [(1-x)^nG + (1-x)^nB]
probQQtoQ = probQQmod * probQQtoQ;
// Calculate derived parameters.
initDerived();
}
//--------------------------------------------------------------------------
// Pick a new flavour (including diquarks) given an incoming one for
// Gaussian pTq^2 distribution.
FlavContainer StringFlav::pickGauss(FlavContainer& flavOld, bool allowPop) {
// Initial values for new flavour.
FlavContainer flavNew;
flavNew.rank = flavOld.rank + 1;
// For original diquark assign popcorn quark and whether popcorn meson.
int idOld = abs(flavOld.id);
if (flavOld.rank == 0 && idOld > 1000 && allowPop) assignPopQ(flavOld);
// Diquark exists, to be forced into baryon now.
bool doOldBaryon = (idOld > 1000 && flavOld.nPop == 0);
// Diquark exists, but do meson now.
bool doPopcornMeson = flavOld.nPop > 0;
// Newly created diquark gives baryon now, antibaryon later.
bool doNewBaryon = false;
// Choose whether to generate a new meson or a new baryon.
if (!doOldBaryon && !doPopcornMeson && probQandQQ * rndmPtr->flat() > 1.) {
doNewBaryon = true;
if ((1. + popFrac) * rndmPtr->flat() > 1.) flavNew.nPop = 1;
}
// Optional suppression of first-rank baryon.
if (flavOld.rank == 0 && doNewBaryon && suppressLeadingB) {
double leadingBSup = (idOld < 4) ? lightLeadingBSup : heavyLeadingBSup;
if (rndmPtr->flat() > leadingBSup) {
doNewBaryon = false;
flavNew.nPop = 0;
}
}
// Single quark for new meson or for baryon where diquark already exists.
if (!doPopcornMeson && !doNewBaryon) {
flavNew.id = pickLightQ();
if ( (flavOld.id > 0 && flavOld.id < 9) || flavOld.id < -1000 )
flavNew.id = -flavNew.id;
// Caclulate variations, then done for simple-quark case.
variations(abs(flavNew.id), true, doOldBaryon);
return flavNew;
}
// Case: 0 = q -> B B, 1 = q -> B M B, 2 = qq -> M B.
int iCase = flavNew.nPop;
if (flavOld.nPop == 1) iCase = 2;
// Flavour of popcorn quark (= q shared between B and Bbar).
if (doNewBaryon) {
double sPopWT = dWT[iCase][0];
if (iCase == 1) sPopWT *= scbBM[0] * popcornSpair;
double rndmFlav = (2. + sPopWT) * rndmPtr->flat();
flavNew.idPop = 1;
if (rndmFlav > 1.) flavNew.idPop = 2;
if (rndmFlav > 2.) flavNew.idPop = 3;
} else flavNew.idPop = flavOld.idPop;
// Flavour of vertex quark.
double sVtxWT = dWT[iCase][1];
if (flavNew.idPop >= 3) sVtxWT = dWT[iCase][2];
if (flavNew.idPop > 3) sVtxWT *= 0.5 * (1. + 1./dWT[iCase][4]);
double rndmFlav = (2. + sVtxWT) * rndmPtr->flat();
flavNew.idVtx = 1;
if (rndmFlav > 1.) flavNew.idVtx = 2;
if (rndmFlav > 2.) flavNew.idVtx = 3;
// Special case for light flavours, possibly identical.
if (flavNew.idPop < 3 && flavNew.idVtx < 3) {
flavNew.idVtx = flavNew.idPop;
if (rndmPtr->flat() > dWT[iCase][3]) flavNew.idVtx = 3 - flavNew.idPop;
}
// Pick 2 * spin + 1.
int spin = 3;
if (flavNew.idVtx != flavNew.idPop) {
double spinWT = dWT[iCase][6];
if (flavNew.idVtx == 3) spinWT = dWT[iCase][5];
if (flavNew.idPop >= 3) spinWT = dWT[iCase][4];
if ((1. + spinWT) * rndmPtr->flat() < 1.) spin = 1;
}
// Form outgoing diquark. Calculate variations. Done.
flavNew.id = 1000 * max(flavNew.idVtx, flavNew.idPop)
+ 100 * min(flavNew.idVtx, flavNew.idPop) + spin;
if ( (flavOld.id < 0 && flavOld.id > -9) || flavOld.id > 1000 )
flavNew.id = -flavNew.id;
variations(abs(flavNew.id), false, doOldBaryon);
return flavNew;
}
//--------------------------------------------------------------------------
// Pick a hadron, based on generated pT value and initial (di)quark.
// Check all possible hadrons and calculate their relative suppression
// based on exp(-mThadron/T), possibly multiplied by spin counting, meson
// mixing or baryon weighting factors.
// First return value is hadron ID, second new (di)quark ID.
FlavContainer StringFlav::pickThermal(FlavContainer& flavOld,
double pT, double kappaRatio) {
// Initial values for new flavour.
FlavContainer flavNew;
flavNew.rank = flavOld.rank + 1;
int idIn = flavOld.id;
int idInAbs = abs(idIn);
double temprNow = temperature;
// Temperature increase to work against asymmetry. Apply for
// s/c/b and diquarks.
if (idInAbs > 2) temprNow *= tempPreFactor;
// Enhanced-rate prefactor for MPIs and/or nearby string pieces.
if (closePacking) {
temprNow *= pow(max(1.0,double(infoPtr->nMPI())), exponentMPI);
temprNow *= pow(max(1.0,kappaRatio), exponentNSP);
}
// Get Gaussian width in case of mT2 suppression.
double sigmaNow = sigmaHad;
// Prefactor for strange quarks and diquarks.
if (useWidthPre) {
if (abs(idIn) > 10) sigmaNow *= widthPreDiquark;
sigmaNow *= pow(widthPreStrange,
particleDataPtr->nQuarksInCode(idIn,3) );
}
// Enhanced-rate prefactor for MPIs and/or nearby string pieces.
if (closePacking) {
sigmaNow *= pow(max(1.0,double(infoPtr->nMPI())), exponentMPI);
sigmaNow *= pow(max(1.0,kappaRatio), exponentNSP);
}
// Get the list of allowed hadrons and constituents for that
// initial (di)quark. First parameter of pair is hadron ID, second
// is nr of hadron constituents in the list.
vector<double> possibleRatePrefacsNow = possibleRatePrefacs[idIn];
vector< pair<int,int> > possibleHadronsNow = possibleHadrons[idIn];
int nPossHads = int(possibleHadronsNow.size());
if (nPossHads < 1) {
loggerPtr->ERROR_MSG("no possible hadrons found");
return 0;
}
// Vector with hadron masses. Is -1.0 if m0 is use for calculating
// the suppression rate and mSel if mSel is used.
vector<double> possibleHadronMasses;
// Calculate rates/suppression factors for given pT.
vector<double> rates;
double rateSum = 0.0;
for (int iHad = 0; iHad < nPossHads; iHad++) {
int hadronID = possibleHadronsNow[iHad].first;
// Pick mass and calculate suppression factor.
double mass = particleDataPtr->mSel(hadronID);
possibleHadronMasses.push_back(mass);
double rate = exp( -sqrt(pow2(pT)+pow2(mass))/temprNow );
// mT2 suppression with Gaussian pT?
if (mT2suppression) rate = exp( -(pow2(pT)+pow2(mass))/pow2(sigmaNow) );
// Multiply rate with prefactor.
rate *= possibleRatePrefacsNow[iHad];
// Save rate and add to sum
rates.push_back(rate);
rateSum += rate;
}
// Normalize rates
for (int iHad = 0; iHad < nPossHads; iHad++) rates[iHad] /= rateSum;
// Get accumulated rates
vector<double> accumRates;
for (int iHad = 0; iHad < nPossHads; iHad++) accumRates.push_back(0);
for (int iHad1 = 0; iHad1 < nPossHads; iHad1++)
for (int iHad2 = 0; iHad2 <= iHad1; iHad2++)
accumRates[iHad1] += rates[iHad2];
// Random number to decide which hadron to pick
double rand = rndmPtr->flat();
int hadronID = 0;
int iConst = 0;
double hadronMass = -1.0;
for (int iHad = 0; iHad < nPossHads; iHad++) {
if (rand <= accumRates[iHad]) {
hadronID = possibleHadronsNow[iHad].first;
iConst = possibleHadronsNow[iHad].second;
hadronMass = possibleHadronMasses[iHad];
break;
}
}
// Get flavour of (di)quark to use next time.
int idNext = 0;
vector< pair<int,int> > constituentIDs = hadronConstIDs[hadronID];
// Mesons
if (particleDataPtr->isMeson(hadronID)) {
int ID1 = constituentIDs[0].first;
int ID2 = constituentIDs[0].second;
// Special case for diagonal meson, flavour remains
if (ID1 == -ID2) idNext = idIn;
else idNext = (idIn == ID1 ? -ID2 : -ID1);
}
// Baryons
else {
int ID1 = constituentIDs[iConst].first;
int ID2 = constituentIDs[iConst].second;
if (ID1 == idIn) idNext = -ID2;
if (ID2 == idIn) idNext = -ID1;
}
// Save new flavour and hadron.
flavNew.id = -idNext; // id used to build hadron
hadronIDwin = hadronID;
idNewWin = idNext; // id used in next step
hadronMassWin = hadronMass;
// Done.
return flavNew;
}
//--------------------------------------------------------------------------
// Combine two flavours (including diquarks) to produce a hadron.
// The weighting of the combination may fail, giving output 0.
int StringFlav::combine(FlavContainer& flav1, FlavContainer& flav2) {
// Recognize largest and smallest flavour.
int id1Abs = abs(flav1.id);
int id2Abs = abs(flav2.id);
int idMax = max(id1Abs, id2Abs);
int idMin = min(id1Abs, id2Abs);
// Construct a meson.
if (idMax < 9 || idMin > 1000) {
// Popcorn meson: use only vertex quarks. Fail if none.
if (idMin > 1000) {
id1Abs = flav1.idVtx;
id2Abs = flav2.idVtx;
idMax = max(id1Abs, id2Abs);
idMin = min(id1Abs, id2Abs);
if (idMin == 0) return 0;
}
// Pick spin state and preliminary code.
int flav = (idMax < 3) ? 0 : idMax - 2;
double rndmSpin = mesonRateSum[flav] * rndmPtr->flat();
int spin = -1;
do rndmSpin -= mesonRate[flav][++spin];
while (rndmSpin > 0.);
int idMeson = 100 * idMax + 10 * idMin + mesonMultipletCode[spin];