-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVinciaFSR.cc
5982 lines (5142 loc) · 206 KB
/
VinciaFSR.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
// VinciaFSR.cc is a part of the PYTHIA event generator.
// Copyright (C) 2024 Peter Skands, 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 VinciaFSR class
// and auxiliary classes.
#include "Pythia8/VinciaFSR.h"
namespace Pythia8 {
using namespace VinciaConstants;
// Max loop counter (for interleaved resonance decays).
const int VinciaFSR::NLOOPMAX = 10000;
//==========================================================================
// The Brancher class, base class containing a generic set of "parent
// partons" as well as virtual methods for generating trial
// branchings.
//--------------------------------------------------------------------------
// Reset.
void Brancher::reset(int iSysIn, Event& event, vector<int> iIn) {
// Save info on parents and resize vectors.
iSav = iIn;
hasTrialSav = false;
systemSav = iSysIn;
Vec4 pSum;
int nMassive = 0;
idSav.resize(iIn.size());
hSav.resize(iIn.size());
colTypeSav.resize(iIn.size());
colSav.resize(iIn.size());
acolSav.resize(iIn.size());
mSav.resize(iIn.size());
for (unsigned int i = 0; i < iIn.size(); ++i) {
idSav[i] = event[iIn[i]].id();
hSav[i] = event[iIn[i]].pol();
colTypeSav[i] = event[iIn[i]].colType();
colSav[i] = event[iIn[i]].col();
acolSav[i] = event[iIn[i]].acol();
mSav[i] = event[iIn[i]].m();
if (mSav[i] != 0.0) nMassive += 1;
// Compute and store antenna invariant mass.
pSum += event[iIn[i]].p();
}
m2AntSav = pSum.m2Calc();
mAntSav = (m2AntSav >= 0) ? sqrt(m2AntSav) : -sqrt(-m2AntSav);
// Massless parents: sIK = m2IK and kallenFac = 1.0.
sAntSav = m2AntSav;
kallenFacSav = 1.0;
// Mass corrections to sAnt and kallenFac.
if (nMassive != 0) {
// sIK = m2IK - m2I - m2K.
for (unsigned int i = 0; i < iIn.size(); ++i) sAntSav -= pow2(mSav[i]);
// Phase-space correction non-unity if both parents massive.
// Note, so far only defined for 2-parton systems.
if (nMassive == 2 && iIn.size() == 2)
kallenFacSav = sAntSav/sqrt(pow2(sAntSav) - 4*pow2(mSav[0]*mSav[1]));
}
}
//--------------------------------------------------------------------------
// Compute pT scale of trial branching.
double Brancher::getpTscale() {
if (invariantsSav.size() == 3) {
double sIK = invariantsSav[0];
double y12 = invariantsSav[1] / sIK;
double y23 = invariantsSav[2] / sIK;
return sIK * y12 * y23;
} else return 0.;
}
//--------------------------------------------------------------------------
// Return Xj.
double Brancher::getXj() {
if (invariantsSav.size() == 3) {
double sIK = invariantsSav[0];
double y12 = invariantsSav[1] / sIK;
double y23 = invariantsSav[2] / sIK;
return y12 + y23;
} else return 1.0;
}
//--------------------------------------------------------------------------
// Simple print utility, showing the contents of the Brancher.
void Brancher::list(string header, bool withLegend) const {
// Check if we are asked to output a header.
if (header != "none") {
cout << " -------- " << std::left << setw(34) << header
<< " ---------------------------------------------------- \n";
if (withLegend) {
cout << " sys type mothers ID codes "
<< "colTypes hels m qNewSav \n";
}
}
cout << fixed << std::right << setprecision(3);
cout << setw(5) << system() << " ";
// Mothers in iSav list. Baseline 2->3 but also allow for 3->4.
// (Set up for right-justified printing.)
int jP0 = -1;
int jP1 = 0;
int jP2 = 1;
if ( iSav.size() == 3 ) {
jP0 = 0;
jP1 = 1;
jP2 = 2;
}
string type = "FF";
// Resonance-Final antennae R and F mothers + list of recoilers.
if ( posR() >= 0 ) {
type = "RF";
jP0 = -1;
jP1 = posR();
jP2 = posF();
}
else if ( iSav.size() == 3 ) type = "FFF";
else if ( iSav.size() >= 4 ) type = "?";
cout << setw(4) << type;
cout << " " << setw(5) << (jP0 >= 0 ? num2str(iSav[jP0],5) : " ")
<< " " << setw(5) << iSav[jP1] << " " << setw(5) << iSav[jP2];
cout << setw(9) << (jP0 >= 0 ? num2str(idSav[jP0],9) : " ")
<< setw(9) << idSav[jP1] << setw(9) << idSav[jP2];
cout << " " << setw(3) << (jP0 >= 0 ? num2str(colTypeSav[jP0],3) : " ")
<< " " << setw(3) << colTypeSav[jP1]
<< " " << setw(3) << colTypeSav[jP2];
cout << " " << setw(2) << (jP0 >= 0 ? num2str(hSav[jP0],2) : " ")
<< " " << setw(2) << hSav[jP1] << " " << setw(2) << hSav[jP2];
cout << " " << num2str(mAnt(), 10);
if (hasTrial()) {
if (q2NewSav > 0.) cout << " " << num2str(sqrt(q2NewSav), 10);
else cout << " " << num2str(0.0, 10);
}
else cout << " " << setw(10) << "-";
cout << endl;
}
//--------------------------------------------------------------------------
// Set post-branching IDs and masses. Base class is for gluon emission.
void Brancher::setidPost() {
idPostSav.clear();
idPostSav.push_back(id0());
idPostSav.push_back(21);
idPostSav.push_back(id1());
}
vector<double> Brancher::setmPostVec() {
mPostSav.clear();
mPostSav.push_back(mSav[0]); // mi
mPostSav.push_back(0.0); // mj
mPostSav.push_back(mSav[1]); // mk
return mPostSav;
}
void Brancher::setStatPost() {
statPostSav.resize(iSav.size() + 1, 51);}
void Brancher::setMaps(int) {
mothers2daughters.clear(); daughters2mothers.clear();}
//--------------------------------------------------------------------------
// Return index of new particle (slightly arbitrary choice for splittings).
int Brancher::iNew() {
if (i0() > 0) {
if (mothers2daughters.find(i0()) != mothers2daughters.end())
return mothers2daughters[i0()].second;
else return 0;
}
else return 0;
}
//==========================================================================
// Class BrancherEmitFF, branch elemental for 2->3 gluon emissions.
//--------------------------------------------------------------------------
// Method to initialise members specific to BrancherEmitFF.
void BrancherEmitFF::initBrancher(ZetaGeneratorSet* zetaGenSet) {
branchType = BranchType::Emit;
if (colType0() == 2 && colType1() == 2) antFunTypeSav = GGEmitFF;
else if (colType1() == 2) antFunTypeSav = QGEmitFF;
else if (colType0() == 2) antFunTypeSav = GQEmitFF;
else antFunTypeSav = QQEmitFF;
trialGenPtr = make_shared<TrialGeneratorFF>(sectorShower, branchType,
zetaGenSet);
}
//--------------------------------------------------------------------------
// Generate a new Q2 value, soft-eikonal 2/yij/yjk implementation.
double BrancherEmitFF::genQ2(int evTypeIn, double q2BegIn, Rndm* rndmPtr,
Logger* loggerPtr, const EvolutionWindow* evWindowIn, double colFacIn,
vector<double> headroomIn, vector<double> enhanceIn,
int verboseIn) {
// Set current phase space limits and active sectors.
double q2MinNow = pow2(evWindowIn->qMin);
trialGenPtr->reset(q2MinNow,sAntSav,mSav,antFunTypeSav);
// Initialise output value and save input parameters.
evTypeSav = evTypeIn;
evWindowSav = evWindowIn;
colFacSav = colFacIn;
q2BegSav = q2BegIn;
headroomSav = (headroomIn.size() >=1) ? headroomIn[0] : 1.0 ;
enhanceSav = (enhanceIn.size() >=1) ? enhanceIn[0] : 1.0 ;
double wtNow = headroomSav * enhanceSav;
// Generate Q2 and save winning sector.
q2NewSav = trialGenPtr->genQ2(q2BegSav,rndmPtr,evWindowIn,
colFacSav,wtNow,loggerPtr,verboseIn);
iSectorWinner = trialGenPtr->getSector();
// Sanity checks.
if (q2NewSav > q2BegIn) {
loggerPtr->ERROR_MSG("generated q2New > q2BegIn; returning 0");
q2NewSav = 0.;
}
if (q2NewSav > 0.) {
// Set flag that this call produces a saved trial.
hasTrialSav = true;
}
return q2NewSav;
}
//--------------------------------------------------------------------------
// Generate invariants.
bool BrancherEmitFF::genInvariants(vector<double>& invariants,
Rndm* rndmPtr, int verboseIn, Logger* loggerPtr) {
// Clear output vector, check if we have a sensible q2New scale.
invariants.clear();
if (q2NewSav <= 0.) return false;
// pT evolution.
if (evTypeSav == 1) {
//TODO: better overestimate for constant trial alphaS?
if (!trialGenPtr->genInvariants(sAntSav,setmPostVec(),
invariantsSav,rndmPtr, loggerPtr, verboseIn)) {
if (verboseIn >= VinciaConstants::DEBUG) {
printOut(__METHOD_NAME__,"Trial failed.");
}
return false;
}
// Veto if the point outside the available phase space.
double det = gramDet(invariantsSav[1],invariantsSav[2],invariantsSav[3],
mPostSav[0],mPostSav[1],mPostSav[2]);
if (det > 0.) {
invariants = invariantsSav;
return true;
}
else return false;
}
else return false;
}
//--------------------------------------------------------------------------
// Compute antPhys / antTrial for gluon emissions, given antPhys.
double BrancherEmitFF::pAccept(const double antPhys, Logger* loggerPtr,
int verboseIn) {
// pT evolution.
if (evTypeSav == 1) {
double antTrial = trialGenPtr->aTrial(invariantsSav,mPostSav,
verboseIn);
antTrial *= headroomSav;
if (antTrial==0.) loggerPtr->ERROR_MSG("trial antenna is zero");
if (std::isnan(antTrial))
loggerPtr->ERROR_MSG("trial antenna not a number");
return antPhys/antTrial;
}
return 0.;
}
//--------------------------------------------------------------------------
// Return the maximum Q2.
double BrancherEmitFF::getQ2Max(int evType) {
if (evType == 1) return sAntSav/4.;
else if (evType == 2) return sAntSav/9.;
else if (evType == 3) return sAntSav/2.;
else return 0.;
}
//--------------------------------------------------------------------------
// Method to make mothers2daughters and daughters2mothers pairs.
void BrancherEmitFF::setMaps(int sizeOld) {
mothers2daughters.clear();
daughters2mothers.clear();
// For updating the children of existing parents.
mothers2daughters[i0()] = make_pair(sizeOld, sizeOld + 1);
mothers2daughters[i1()] = make_pair(sizeOld + 1, sizeOld + 2);
// For adding mothers of new children.
daughters2mothers[sizeOld] = make_pair(i0(), 0);
daughters2mothers[sizeOld+1] = make_pair(i0(), i1());
daughters2mothers[sizeOld+2] = make_pair(i1(), 0);
}
//--------------------------------------------------------------------------
// Generic getter method. Assumes setter methods called earlier.
bool BrancherEmitFF::getNewParticles(Event& event, vector<Vec4> momIn,
vector<int> hIn, vector<Particle> &pNew, Rndm* rndmPtr, VinciaColour*
colourPtr) {
// Initialize.
unsigned int nPost = iSav.size() + 1;
pNew.clear();
pNew.resize(nPost);
setidPost();
setStatPost();
double scaleNew = sqrt(q2NewSav);
setMaps(event.size());
// Check everything set.
if (momIn.size() != nPost || hIn.size() != nPost ||
mPostSav.size() != nPost || idPostSav.size() != nPost ||
statPostSav.size() != nPost || invariantsSav.size() < 3) return false;
// Who inherits the colour?
double sij = invariantsSav[1];
double sjk = invariantsSav[2];
bool inh01 = colourPtr->inherit01(sij,sjk);
int lastTag = event.lastColTag();
vector<int> col(nPost, 0);
vector<int> acol(nPost, 0);
acol[0] = event[i0()].acol();
col[0] = event[i0()].col();
acol[2] = event[i1()].acol();
col[2] = event[i1()].col();
// Generate a new colour tag.
int colNew = lastTag + 1 + rndmPtr->flat()*10;
// 0 keeps colour.
if (inh01) {
while (colNew%10 == col[2]%10 || colNew%10 == 0)
colNew = lastTag + 1 + rndmPtr->flat()*10;
acol[1]=col[0];
col[1]=colNew;
acol[2]=colNew;
// 2 keeps colour.
} else {
while (colNew%10 == acol[0]%10 || colNew%10 == 0)
colNew = lastTag + 1 + rndmPtr->flat()*10;
col[0]=colNew;
acol[1]=colNew;
col[1]=acol[2];
}
// Now populate particle vector.
for (unsigned int ipart = 0; ipart < nPost; ++ipart) {
pNew[ipart].status(statPostSav[ipart]);
pNew[ipart].id(idPostSav[ipart]);
pNew[ipart].pol(hIn[ipart]);
pNew[ipart].p(momIn[ipart]);
pNew[ipart].m(mPostSav[ipart]);
pNew[ipart].setEvtPtr(&event);
pNew[ipart].scale(scaleNew);
pNew[ipart].daughters(0,0);
pNew[ipart].col(col[ipart]);
pNew[ipart].acol(acol[ipart]);
}
colTagSav = colNew;
return true;
}
//==========================================================================
// Class BrancherSplitFF, branch elemental for 2->3 gluon splittings.
//--------------------------------------------------------------------------
// Method to initialise data members specific to BrancherSplitFF.
void BrancherSplitFF::initBrancher(ZetaGeneratorSet* zetaGenSet,
bool col2acolIn) {
branchType = BranchType::SplitF;
antFunTypeSav = GXSplitFF;
isXGsav = !col2acolIn;
swapped = false;
trialGenPtr = make_shared<TrialGeneratorFF>(sectorShower, branchType,
zetaGenSet);
}
//--------------------------------------------------------------------------
// Generate a new Q2 value .
double BrancherSplitFF::genQ2(int evTypeIn, double q2BegIn,
Rndm* rndmPtr, Logger* loggerPtr, const EvolutionWindow* evWindowIn,
double colFac, vector<double> headroomFlav,
vector<double> enhanceFlav, int verboseIn) {
// Set current phase space limits and active sectors.
double q2MinNow = pow2(evWindowIn->qMin);
trialGenPtr->reset(q2MinNow, sAntSav, mSav, antFunTypeSav);
// Initialise output value and save input parameters.
q2NewSav = 0.;
evTypeSav = evTypeIn;
q2BegSav = q2BegIn;
evWindowSav = evWindowIn;
// Total splitting weight summed over flavours
double wtSum = 0.0;
vector<double> wtFlav;
unsigned int nFlav = headroomFlav.size();
if (nFlav != enhanceFlav.size()) {
loggerPtr->ERROR_MSG(
"inconsistent size of headroom and enhancement vectors");
return 0.;
}
// First check if there is any phase space open for this flavour
for (unsigned int iFlav = 0; iFlav < nFlav; ++iFlav) {
double mFlav = evWindowSav->mass.at(iFlav+1);
if (mAnt() - m0() - m1() < 2.*mFlav) {
wtFlav.push_back(0.); continue;
} else {
double wt = headroomFlav[iFlav] * enhanceFlav[iFlav];
wtFlav.push_back(wt);
wtSum += wt;
}
}
// pT evolution.
if (evTypeSav == 1) {
// Generate Q2 and save winning sector.
q2NewSav = trialGenPtr->genQ2(q2BegSav, rndmPtr, evWindowIn,
colFac, wtSum, loggerPtr, verboseIn);
iSectorWinner = trialGenPtr->getSector();
}
// Select flavour.
double ranFlav = rndmPtr->flat() * wtSum;
for (int iFlav = nFlav - 1; iFlav >= 0; --iFlav) {
ranFlav -= wtFlav[iFlav];
if (ranFlav < 0) {
idFlavSav = iFlav+1;
// Set quark masses.
mFlavSav = evWindowSav->mass.at(idFlavSav);
// Save corresponding headroom and enhancement factors.
enhanceSav = enhanceFlav[iFlav];
headroomSav = headroomFlav[iFlav];
break;
}
}
if (q2NewSav > q2BegIn) {
loggerPtr->ERROR_MSG("generated q2New > q2Beg; returning 0");
q2NewSav = 0.;
}
// Sanity checks.
if (q2NewSav > q2BegIn) {
loggerPtr->ERROR_MSG("generated q2New > q2BegIn; returning 0");
q2NewSav = 0.;
}
if (q2NewSav > 0.) {
// Set flag that this call produces a saved trial.
hasTrialSav = true;
}
return q2NewSav;
}
//--------------------------------------------------------------------------
// Generate complementary invariant(s) for saved trial scale
// for gluon splitting. Return false if no physical kinematics possible.
bool BrancherSplitFF::genInvariants(vector<double>& invariants,
Rndm* rndmPtr, int verboseIn, Logger* loggerPtr) {
// Clear output vector, and check if we have a sensible q2New scale.
invariants.clear();
if (q2NewSav <= 0.) return false;
// pT evolution.
if (evTypeSav == 1) {
if (!trialGenPtr->genInvariants(sAntSav,setmPostVec(),invariants,rndmPtr,
loggerPtr, verboseIn)) {
if (verboseIn >= VinciaConstants::DEBUG) {
printOut(__METHOD_NAME__,"Trial Failed.");
}
return false;
}
// Here i=q, j=qbar is always the case, but change def for sjk,
// sik depending on who is colour connected to the recoiler.
if (!isXGsav) std::swap(invariants[1],invariants[2]);
invariantsSav = invariants;
// Veto if point outside the available phase space.
double det = gramDet(invariantsSav[0],invariantsSav[1],invariantsSav[2],
mPostSav[0],mPostSav[1],mPostSav[2]);
if (det > 0.) return true;
else return false;
}
else return false;
}
//--------------------------------------------------------------------------
// Compute antPhys/antTrial for gluon splittings, given antPhys.
// Note, antPhys should be normalised to include charge and coupling
// factors.
double BrancherSplitFF::pAccept(const double antPhys, Logger* loggerPtr,
int verboseIn) {
// pT evolution.
if (evTypeSav == 1) {
double antTrial = trialGenPtr->aTrial(invariantsSav,mPostSav,
verboseIn);
antTrial *= headroomSav;
if (antTrial==0.) loggerPtr->ERROR_MSG("trial antenna is zero");
if (std::isnan(antTrial))
loggerPtr->ERROR_MSG("trial antenna not a number");
return antPhys/antTrial;
}
return 0.;
}
//--------------------------------------------------------------------------
// Getter and setter methods.
double BrancherSplitFF::getQ2Max(int evType) {
if (evType == 1) return sAntSav/4.;
else if (evType == 2) return sAntSav;
else if (evType == 3) return sAntSav;
else return 0.;
}
vector<double> BrancherSplitFF::setmPostVec() {
mPostSav.clear();
mPostSav.push_back(mFlavSav); // mi
mPostSav.push_back(mFlavSav); // mj
mPostSav.push_back(mSav[1]); // mk
return mPostSav;
}
void BrancherSplitFF::setidPost() {
idPostSav.clear();
idPostSav.push_back(idFlavSav);
idPostSav.push_back(-idFlavSav);
idPostSav.push_back(id1());
}
void BrancherSplitFF::setStatPost() {
statPostSav.resize(iSav.size() + 1, 51);
statPostSav[2] = 52;
}
void BrancherSplitFF::setMaps(int sizeOld) {
// For updating the children of existing parents.
mothers2daughters.clear();
daughters2mothers.clear();
mothers2daughters[i0()] = make_pair(sizeOld, sizeOld+1);
mothers2daughters[i1()] = make_pair(sizeOld+2,sizeOld+2);
// For adding mothers of new children.
daughters2mothers[sizeOld] = make_pair(i0(),0);
daughters2mothers[sizeOld+1] = make_pair(i0(),0);
daughters2mothers[sizeOld+2] = make_pair(i1(),i1());
}
//--------------------------------------------------------------------------
// Generic getter method. Assumes setter methods called earlier.
bool BrancherSplitFF::getNewParticles(Event& event, vector<Vec4> momIn,
vector<int> hIn, vector<Particle> &pNew, Rndm*, VinciaColour*) {
// Initialize.
unsigned int nPost = iSav.size() + 1;
pNew.clear();
pNew.resize(nPost);
setidPost();
setStatPost();
double scaleNew = sqrt(q2NewSav);
setMaps(event.size());
// Check everything set.
if (momIn.size()!=nPost || hIn.size()!=nPost ||
mPostSav.size() !=nPost || idPostSav.size() != nPost ||
statPostSav.size() != nPost || invariantsSav.size() < 3) return false;
vector<int> col(nPost,0);
vector<int> acol(nPost,0);
acol[0] = 0;
col[0] = event[i0()].col();
acol[1] = event[i0()].acol();
col[1] = 0;
acol[2] = event[i1()].acol();
col[2] = event[i1()].col();
// Now populate particle vector.
for (unsigned int ipart = 0; ipart < nPost; ++ipart) {
pNew[ipart].status(statPostSav[ipart]);
pNew[ipart].id(idPostSav[ipart]);
pNew[ipart].pol(hIn[ipart]);
pNew[ipart].p(momIn[ipart]);
pNew[ipart].m(mPostSav[ipart]);
pNew[ipart].setEvtPtr(&event);
pNew[ipart].scale(scaleNew);
pNew[ipart].daughters(0,0);
pNew[ipart].col(col[ipart]);
pNew[ipart].acol(acol[ipart]);
}
colTagSav = 0;
return true;
}
//==========================================================================
// BrancherRF base class for storing information on antennae between a
// coloured resonance and final state parton.
//--------------------------------------------------------------------------
// Return index of new particle (slightly arbitrary choice for splittings).
int BrancherRF::iNew() {
if (posFinal > 0 && iSav[posFinal] > 0
&& mothers2daughters.find(iSav[posFinal]) != mothers2daughters.end())
return mothers2daughters[iSav[posFinal]].second;
return 0;
}
//--------------------------------------------------------------------------
// Method to make mothers2daughters and daughters2mothers pairs.
void BrancherRF::setMaps(int sizeOld) {
mothers2daughters.clear();
daughters2mothers.clear();
posNewtoOld.clear();
// For updating the children of existing parents. Save children of
// F (treat like 1->2 splitting).
mothers2daughters[iSav[posFinal]] = make_pair(sizeOld, sizeOld + 1);
daughters2mothers[sizeOld] = make_pair(iSav[posFinal], 0);
daughters2mothers[sizeOld+1] = make_pair(iSav[posFinal], 0);
//Save recoilers and insert the new emission at position 1.
int iInsert = sizeOld + 2;
unsigned int posNewEmit = 1;
for (unsigned int pos = 0; pos < iSav.size(); pos++) {
if (pos >= posNewEmit) posNewtoOld[pos + 1] = pos;
else posNewtoOld[pos] = pos;
if (pos == posRes || pos == posFinal) continue;
else {
mothers2daughters[iSav[pos]] = make_pair(iInsert, iInsert);
daughters2mothers[iInsert] = make_pair(iSav[pos], iSav[pos]);
iInsert++;
}
}
}
//--------------------------------------------------------------------------
// Protected helper methods for internal class use.
double BrancherRF::getsAK(double mA, double mK, double mAK) {
return mA*mA +mK*mK - mAK*mAK;}
double BrancherRF::calcQ2Max(double mA, double mAK, double mK) {
double aM2 = (mA-mAK)*(mA-mAK) - mK*mK;
double bM2 = mAK*(mA-mAK) + mK*mK;
double cM = mA-mAK;
return aM2*aM2*mA/(2.0*cM*bM2);
}
//--------------------------------------------------------------------------
// Veto point if outside available phase space.
bool BrancherRF::vetoPhSpPoint(const vector<double>& invariants,
int verboseIn) {
if (invariants.size()!=4) {
return false;
}
double saj = invariants[1];
double sjk = invariants[2];
double sak = invariants[3];
// Make copies of masses (just for compactness of notation).
double mAK = mRecoilers;
double ma = mPostSav[0];
double mj = mPostSav[1];
double mk = mPostSav[2];
// Common sense: saj, sjk > 0. Not an error for splitters - mass
// effects can make negative and push outside generated phase space.
if (saj<0. || sjk<0.) {
if (verboseIn >= VinciaConstants::DEBUG) {
stringstream ss;
ss << "Negative invariants. saj = " << saj << " sjk = " << sjk;
printOut(__METHOD_NAME__, ss.str());
}
return true;
}
// On-shell X condition.
double invDiff = ma*ma + mj*mj + mk*mk - saj - sak + sjk - mAK*mAK;
if (invDiff > MILLI) {
if (verboseIn >= VinciaConstants::DEBUG)
printOut(__METHOD_NAME__, "Failed on-shell AK condition.");
return true;
}
// On-shell j,k conditions.
double Ek = sak/(2.0*ma);
if (Ek*Ek < mk*mk) {
if (verboseIn >= VinciaConstants::DEBUG)
printOut(__METHOD_NAME__, "Failed on-shell k condition.");
return true;
}
double Ej = saj/(2.0*ma);
if (Ej*Ej < mj*mj) {
if (verboseIn >= VinciaConstants::DEBUG)
printOut(__METHOD_NAME__, "Failed on-shell j condition.");
return true;
}
// When |cosTheta| < 1.
double cosTheta = costheta(Ej,Ek,mj,mk,sjk);
if (abs(cosTheta) > 1.0) {
if (verboseIn >= VinciaConstants::DEBUG)
printOut(__METHOD_NAME__, "Failed cos theta condition.");
return true;
}
// This condition may be sufficient to remove above conditions.
// TODO use gramdet here
double det = saj*sjk*sak - saj*saj*mk*mk - sjk*sjk*ma*ma - sak*sak*mj*mj
+ 4.0*ma*ma*mj*mj*mk*mk;
if (det <= 0.) {
if (verboseIn >= VinciaConstants::DEBUG)
printOut(__METHOD_NAME__, "Gram det < 0 : Outside phase space");
}
return false;
}
//==========================================================================
// BrancherEmitRF class for storing information on antennae between a
// coloured resonance and final state parton, and generating a new
// emission.
//--------------------------------------------------------------------------
// Method to initialise data members specific to BrancherEmitRF.
void BrancherEmitRF::initBrancher(Event& event, vector<int> allIn,
unsigned int posResIn, unsigned int posFIn, double q2cut,
ZetaGeneratorSet* zetaGenSet) {
// Get Pythia indices of res and final.
posRes = posResIn;
posFinal = posFIn;
int iRes = allIn.at(posRes);
int iFinal = allIn.at(posFinal);
// Is colour flow from R to F, or from F to R?
colFlowRtoF = event[iRes].col() == event[iFinal].col() && event[iRes].col()
!= 0;
// Check if R and F swapped (explicit way to force reverse colour flow
// e.g., for second antenna in gluino -> gluon neutralino.)
if (event[iRes].status() > 0 ) {
posRes = posFIn;
posFinal = posResIn;
iRes = allIn.at(posRes);
iFinal = allIn.at(posFinal);
colFlowRtoF = false;
}
// Extract the momenta of the (set of) recoiler(s).
Vec4 recoilVec(0., 0., 0., 0.);
for (vector<int>::iterator pos = allIn.begin(); pos != allIn.end(); ++pos) {
if ((*pos == iRes) || (*pos == iFinal)) continue;
recoilVec += event[*pos].p();
}
// This is not necesssarily p(res). In the case where one particle
// always recieves the recoil e.g. W in t->bWX it is p_t -p_X.
Vec4 resVec = recoilVec + event[iFinal].p();
// Calculate the masses.
mRes = resVec.mCalc();
mFinal = event[iFinal].mCalc();
mRecoilers = recoilVec.mCalc();
sAK = getsAK(mRes, mFinal, mRecoilers);
vector<double> massesPre;
massesPre.push_back(mRes);
massesPre.push_back(mFinal);
massesPre.push_back(mRecoilers);
// Calculate q2max.
q2MaxSav = calcQ2Max(mRes, mRecoilers, mFinal);
branchType = BranchType::Emit;
// TODO: swapped should be redundant since save posRes, posFinal.
// R = Q.
if (abs(colTypeSav[posRes]) == 1) {
// F = Q.
if (abs(colTypeSav[posFinal]) == 1) {
antFunTypeSav = QQEmitRF;
swapped = false;
// F = g.
} else if (colTypeSav[posFinal] == 2) {
antFunTypeSav = QGEmitRF;
swapped = posRes != 0;
// Some other final state - don't know what to do with this yet!
} else {
antFunTypeSav = NoFun;
swapped = false;
}
// Some other resonance. Don't know what to do with this yet!
} else {
antFunTypeSav = NoFun;
swapped = false;
}
// Set up and initialise trial generator.
trialGenPtr = make_shared<TrialGeneratorRF>(sectorShower, branchType,
zetaGenSet);
trialGenPtr->reset(q2cut,sAK, massesPre, antFunTypeSav);
}
//--------------------------------------------------------------------------
// Setter methods.
vector<double> BrancherEmitRF::setmPostVec() {
mPostSav.clear();
mPostSav.push_back(mRes); // ma
mPostSav.push_back(0.0); // mj
mPostSav.push_back(mFinal); // mk
mPostSav.push_back(mRecoilers); // mAK
return mPostSav;
}
void BrancherEmitRF::setidPost() {
idPostSav.clear();
idPostSav = idSav;
// Insert gluon in second position.
idPostSav.insert(idPostSav.begin() + 1, 21);
}
void BrancherEmitRF::setStatPost() {
statPostSav.resize(iSav.size() + 1, 52);
statPostSav[posFinal] = 51;
statPostSav[posFinal+1] = 51;
}
//--------------------------------------------------------------------------
// Generic method, assumes setter methods called earlier.
bool BrancherEmitRF::getNewParticles(Event& event, vector<Vec4> momIn,
vector<int> hIn, vector<Particle> &pNew, Rndm* rndmPtr, VinciaColour*) {
// Initialize.
unsigned int nPost = iSav.size() + 1;
pNew.clear();
setidPost();
setStatPost();
double scaleNew = sqrt(q2NewSav);
setMaps(event.size());
// Check everything set.
if (momIn.size() != nPost || hIn.size() != nPost ||
idPostSav.size() != nPost || statPostSav.size() != nPost) return false;
// Generate new colour tag.
int lastTag = event.lastColTag();
int resTag = 0;
int newTag = 0;
if (colFlowRtoF) resTag = event[iSav[posRes]].col();
else resTag = event[iSav[posRes]].acol();
// New tag can't be same colour as neighbour.
while (newTag%10 == resTag%10 || newTag%10 == 0)
newTag = lastTag + 1 + rndmPtr->flat()*10;
// Now populate particle vector.
for (unsigned int ipart = 0; ipart < nPost; ++ipart) {
Particle newPart;
// Set mass and colours (we have repurposed mPost for antenna
// function mass scales). This is new emission.
if (posNewtoOld.find(ipart) == posNewtoOld.end()) {
newPart.m(0.0);
if (colFlowRtoF) newPart.cols(resTag, newTag);
else newPart.cols(newTag, resTag);
// Skip the resonance.
} else if (posNewtoOld[ipart] == posRes) continue;
else {
newPart.m(mSav[posNewtoOld[ipart]]);
int colNow = event[iSav[posNewtoOld[ipart]]].col();
int acolNow = event[iSav[posNewtoOld[ipart]]].acol();
if (posNewtoOld[ipart] == posFinal) {
if (colFlowRtoF) colNow = newTag;
else acolNow = newTag;
}
newPart.cols(colNow,acolNow);
}
// Set other pre-determined particle properties.
newPart.status(statPostSav[ipart]);
newPart.id(idPostSav[ipart]);
newPart.pol(hIn[ipart]);
newPart.p(momIn[ipart]);
newPart.setEvtPtr(&event);
newPart.scale(scaleNew);
newPart.daughters(0,0);
if (abs(newPart.m() - newPart.mCalc()) > MILLI) return false;
pNew.push_back(newPart);
}
colTagSav=newTag;
return true;
}
//--------------------------------------------------------------------------
// Generate a new Q2 scale.
double BrancherEmitRF::genQ2(int, double q2MaxNow, Rndm* rndmPtr,
Logger* loggerPtr, const EvolutionWindow* evWindowPtrIn, double colFac,
vector<double> headroomIn, vector<double> enhanceIn,