-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTimeShower.cc
5862 lines (5157 loc) · 219 KB
/
TimeShower.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
// TimeShower.cc is a part of the PYTHIA event generator.
// Copyright (C) 2018 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 TimeShower class.
#include "Pythia8/TimeShower.h"
namespace Pythia8 {
//==========================================================================
// The TimeShower class.
//--------------------------------------------------------------------------
// Constants: could be changed here if desired, but normally should not.
// These are of technical nature, as described for each.
// Minimal allowed c and b quark masses, for flavour thresholds.
const double TimeShower::MCMIN = 1.2;
const double TimeShower::MBMIN = 4.0;
// For small x approximate 1 - sqrt(1 - x) by x/2.
const double TimeShower::SIMPLIFYROOT = 1e-8;
// Do not allow x too close to 0 or 1 in matrix element expressions.
// Warning: cuts into phase space for E_CM > 2 * pTmin * sqrt(1/XMARGIN),
// i.e. will become problem roughly for E_CM > 10^6 GeV.
const double TimeShower::XMARGIN = 1e-12;
const double TimeShower::XMARGINCOMB = 1e-4;
// Lower limit on PDF value in order to avoid division by zero.
const double TimeShower::TINYPDF = 1e-10;
// Big starting value in search for smallest invariant-mass pair.
const double TimeShower::LARGEM2 = 1e20;
// In g -> q qbar or gamma -> f fbar require m2_pair > this * m2_q/f.
const double TimeShower::THRESHM2 = 4.004;
// Never pick pT so low that alphaS is evaluated too close to Lambda_3.
const double TimeShower::LAMBDA3MARGIN = 1.1;
// Rescatter: rescattering + ISR + FSR + primordial kT can lead to
// systems not locally conserving momentum.
// Fix up momentum in intermediate systems with rescattering
const bool TimeShower::FIXRESCATTER = true;
// Veto negative energies when using FIXRESCATTER option.
const bool TimeShower::VETONEGENERGY = false;
// Do not allow too large time- or spacelike virtualities in fixing-up.
const double TimeShower::MAXVIRTUALITYFRACTION = 0.5;
// Do not allow too large negative spacelike energy in system rest frame.
const double TimeShower::MAXNEGENERGYFRACTION = 0.7;
// Fudge extra weight for overestimation of weak shower t-channel correction.
const double TimeShower::WEAKPSWEIGHT = 5.;
// Extra overestimate of g -> q qbar branching rate for DGLAP comparison.
const double TimeShower::WG2QEXTRA = 20.;
// Limit on size of number of rejections for uncertainty variations.
const double TimeShower::REJECTFACTOR = 0.1;
// Limit on probability for uncertainty variations.
const double TimeShower::PROBLIMIT = 0.99;
//--------------------------------------------------------------------------
// Initialize alphaStrong, alphaEM and related pTmin parameters.
void TimeShower::init( BeamParticle* beamAPtrIn,
BeamParticle* beamBPtrIn) {
// Store input pointers for future use.
beamAPtr = beamAPtrIn;
beamBPtr = beamBPtrIn;
// Main flags.
doQCDshower = settingsPtr->flag("TimeShower:QCDshower");
doQEDshowerByQ = settingsPtr->flag("TimeShower:QEDshowerByQ");
doQEDshowerByL = settingsPtr->flag("TimeShower:QEDshowerByL");
doQEDshowerByOther = settingsPtr->flag("TimeShower:QEDshowerByOther");
doQEDshowerByGamma = settingsPtr->flag("TimeShower:QEDshowerByGamma");
doWeakShower = settingsPtr->flag("TimeShower:weakShower");
doMEcorrections = settingsPtr->flag("TimeShower:MEcorrections");
doMEextended = settingsPtr->flag("TimeShower:MEextended");
if (!doMEcorrections) doMEextended = false;
doMEafterFirst = settingsPtr->flag("TimeShower:MEafterFirst");
doPhiPolAsym = settingsPtr->flag("TimeShower:phiPolAsym");
doPhiPolAsymHard = settingsPtr->flag("TimeShower:phiPolAsymHard");
doInterleave = settingsPtr->flag("TimeShower:interleave");
allowBeamRecoil = settingsPtr->flag("TimeShower:allowBeamRecoil");
dampenBeamRecoil = settingsPtr->flag("TimeShower:dampenBeamRecoil");
recoilToColoured = settingsPtr->flag("TimeShower:recoilToColoured");
allowMPIdipole = settingsPtr->flag("TimeShower:allowMPIdipole");
// If SpaceShower does dipole recoil then TimeShower must adjust.
doDipoleRecoil = settingsPtr->flag("SpaceShower:dipoleRecoil");
if (doDipoleRecoil) allowBeamRecoil = true;
if (doDipoleRecoil) dampenBeamRecoil = false;
// Matching in pT of hard interaction or MPI to shower evolution.
pTmaxMatch = settingsPtr->mode("TimeShower:pTmaxMatch");
pTdampMatch = settingsPtr->mode("TimeShower:pTdampMatch");
pTmaxFudge = settingsPtr->parm("TimeShower:pTmaxFudge");
pTmaxFudgeMPI = settingsPtr->parm("TimeShower:pTmaxFudgeMPI");
pTdampFudge = settingsPtr->parm("TimeShower:pTdampFudge");
// Charm and bottom mass thresholds.
mc = max( MCMIN, particleDataPtr->m0(4));
mb = max( MBMIN, particleDataPtr->m0(5));
m2c = mc * mc;
m2b = mb * mb;
// Parameters of scale choices.
renormMultFac = settingsPtr->parm("TimeShower:renormMultFac");
factorMultFac = settingsPtr->parm("TimeShower:factorMultFac");
useFixedFacScale = settingsPtr->flag("TimeShower:useFixedFacScale");
fixedFacScale2 = pow2(settingsPtr->parm("TimeShower:fixedFacScale"));
// Parameters of alphaStrong generation.
alphaSvalue = settingsPtr->parm("TimeShower:alphaSvalue");
alphaSorder = settingsPtr->mode("TimeShower:alphaSorder");
alphaSnfmax = settingsPtr->mode("StandardModel:alphaSnfmax");
alphaSuseCMW = settingsPtr->flag("TimeShower:alphaSuseCMW");
alphaS2pi = 0.5 * alphaSvalue / M_PI;
// Initialize alphaStrong generation.
alphaS.init( alphaSvalue, alphaSorder, alphaSnfmax, alphaSuseCMW);
// Lambda for 5, 4 and 3 flavours.
Lambda3flav = alphaS.Lambda3();
Lambda4flav = alphaS.Lambda4();
Lambda5flav = alphaS.Lambda5();
Lambda5flav2 = pow2(Lambda5flav);
Lambda4flav2 = pow2(Lambda4flav);
Lambda3flav2 = pow2(Lambda3flav);
// Parameters of QCD evolution. Warn if pTmin must be raised.
nGluonToQuark = settingsPtr->mode("TimeShower:nGluonToQuark");
weightGluonToQuark = settingsPtr->mode("TimeShower:weightGluonToQuark");
scaleGluonToQuark = settingsPtr->parm("TimeShower:scaleGluonToQuark");
extraGluonToQuark = (weightGluonToQuark%4 == 3) ? WG2QEXTRA : 1.;
recoilDeadCone = settingsPtr->flag("TimeShower:recoilDeadCone");
pTcolCutMin = settingsPtr->parm("TimeShower:pTmin");
if (pTcolCutMin > LAMBDA3MARGIN * Lambda3flav / sqrt(renormMultFac))
pTcolCut = pTcolCutMin;
else {
pTcolCut = LAMBDA3MARGIN * Lambda3flav / sqrt(renormMultFac);
ostringstream newPTcolCut;
newPTcolCut << fixed << setprecision(3) << pTcolCut;
infoPtr->errorMsg("Warning in TimeShower::init: pTmin too low",
", raised to " + newPTcolCut.str() );
infoPtr->setTooLowPTmin(true);
}
pT2colCut = pow2(pTcolCut);
// Parameters of alphaEM generation.
alphaEMorder = settingsPtr->mode("TimeShower:alphaEMorder");
// Initialize alphaEM generation.
alphaEM.init( alphaEMorder, settingsPtr);
// Parameters of QED evolution.
nGammaToQuark = settingsPtr->mode("TimeShower:nGammaToQuark");
nGammaToLepton = settingsPtr->mode("TimeShower:nGammaToLepton");
pTchgQCut = settingsPtr->parm("TimeShower:pTminChgQ");
pT2chgQCut = pow2(pTchgQCut);
pTchgLCut = settingsPtr->parm("TimeShower:pTminChgL");
pT2chgLCut = pow2(pTchgLCut);
mMaxGamma = settingsPtr->parm("TimeShower:mMaxGamma");
m2MaxGamma = pow2(mMaxGamma);
// Parameters of weak evolution.
weakMode = settingsPtr->mode("TimeShower:weakShowerMode");
pTweakCut = settingsPtr->parm("TimeShower:pTminWeak");
pT2weakCut = pow2(pTweakCut);
weakEnhancement = settingsPtr->parm("WeakShower:enhancement");
singleWeakEmission = settingsPtr->flag("WeakShower:singleEmission");
vetoWeakJets = settingsPtr->flag("WeakShower:vetoWeakJets");
vetoWeakDeltaR2 = pow2(settingsPtr->parm("WeakShower:vetoWeakDeltaR"));
weakExternal = settingsPtr->flag("WeakShower:externalSetup");
// Consisteny check for gamma -> f fbar variables.
if (nGammaToQuark <= 0 && nGammaToLepton <= 0) doQEDshowerByGamma = false;
// Possibility of a global recoil stategy, e.g. for MC@NLO.
globalRecoil = settingsPtr->flag("TimeShower:globalRecoil");
nMaxGlobalRecoil = settingsPtr->mode("TimeShower:nMaxGlobalRecoil");
// Number of splittings produced with global recoil.
nMaxGlobalBranch = settingsPtr->mode("TimeShower:nMaxGlobalBranch");
// Number of partons in Born-like events, to distinguish between S and H.
nFinalBorn = settingsPtr->mode("TimeShower:nPartonsInBorn");
// Flag to allow to start from a scale smaller than scalup.
globalRecoilMode = settingsPtr->mode("TimeShower:globalRecoilMode");
// Flag to allow to start from a scale smaller than scalup.
limitMUQ = settingsPtr->flag("TimeShower:limitPTmaxGlobal");
// Fraction and colour factor of gluon emission off onium octat state.
octetOniumFraction = settingsPtr->parm("TimeShower:octetOniumFraction");
octetOniumColFac = settingsPtr->parm("TimeShower:octetOniumColFac");
// Z0 and W+- properties needed for gamma/Z0 mixing and weak showers.
mZ = particleDataPtr->m0(23);
gammaZ = particleDataPtr->mWidth(23);
thetaWRat = 1. / (16. * coupSMPtr->sin2thetaW()
* coupSMPtr->cos2thetaW());
mW = particleDataPtr->m0(24);
gammaW = particleDataPtr->mWidth(24);
// May have to fix up recoils related to rescattering.
allowRescatter = settingsPtr->flag("PartonLevel:MPI")
&& settingsPtr->flag("MultipartonInteractions:allowRescatter");
// Hidden Valley scenario with further shower activity.
doHVshower = settingsPtr->flag("HiddenValley:FSR");
nCHV = settingsPtr->mode("HiddenValley:Ngauge");
alphaHVfix = settingsPtr->parm("HiddenValley:alphaFSR");
alphaHVorder = (nCHV > 1 )
? settingsPtr->mode("HiddenValley:alphaOrder") : 0;
nFlavHV = settingsPtr->mode("HiddenValley:nFlav");
LambdaHV = settingsPtr->parm("HiddenValley:Lambda");
pThvCut = settingsPtr->parm("HiddenValley:pTminFSR");
CFHV = (nCHV == 1) ? 1. : (nCHV * nCHV - 1.)/(2. * nCHV);
idHV = (nCHV == 1) ? 4900022 : 4900021;
mHV = particleDataPtr->m0(idHV);
brokenHVsym = (nCHV == 1 && mHV > 0.);
if (pThvCut < LambdaHV) {
pThvCut = LAMBDA3MARGIN * LambdaHV;
ostringstream newPTcolCut;
newPTcolCut << fixed << setprecision(3) << pThvCut;
infoPtr->errorMsg("Warning in TimeShower::init: Hidden Valley pTmin ",
"too low, raised to " + newPTcolCut.str() );
}
pT2hvCut = pThvCut * pThvCut;
// Possibility of two predetermined hard emissions in event.
doSecondHard = settingsPtr->flag("SecondHard:generate");
// Possibility to allow user veto of emission step.
hasUserHooks = (userHooksPtr != 0);
canVetoEmission = hasUserHooks && userHooksPtr->canVetoFSREmission();
// Set initial value, just in case.
dopTdamp = false;
pT2damp = 0.;
// Default values for the weak shower.
hasWeaklyRadiated = false;
// Disallow simultaneous splitting and trial emission enhancements.
canEnhanceEmission = hasUserHooks && userHooksPtr->canEnhanceEmission();
canEnhanceTrial = hasUserHooks && userHooksPtr->canEnhanceTrial();
if (canEnhanceEmission && canEnhanceTrial) {
infoPtr->errorMsg("Error in SpaceShower::init: Enhance for both actual "
"and trial emissions not possible. Both switched off.");
canEnhanceEmission = false;
canEnhanceTrial = false;
}
// Properties for enhanced emissions.
splittingNameSel = "";
splittingNameNow = "";
enhanceFactors.clear();
// Enable automated uncertainty variations.
nVarQCD = 0;
doUncertainties = settingsPtr->flag("UncertaintyBands:doVariations")
&& initUncertainties();
doUncertaintiesNow = doUncertainties;
uVarNflavQ = settingsPtr->mode("UncertaintyBands:nFlavQ");
uVarMPIshowers = settingsPtr->flag("UncertaintyBands:MPIshowers");
cNSpTmin = settingsPtr->parm("UncertaintyBands:cNSpTmin");
uVarpTmin2 = pT2colCut;
uVarpTmin2 *= settingsPtr->parm("UncertaintyBands:FSRpTmin2Fac");
int varType = settingsPtr->mode("UncertaintyBands:type");
noResVariations = (varType == 1) ? true: false;
noProcVariations = (varType == 2) ? true: false;
overFactor = settingsPtr->parm("UncertaintyBands:overSampleFSR");
// Possibility to set parton vertex information.
doPartonVertex = settingsPtr->flag("PartonVertex:setVertex")
&& (partonVertexPtr != 0);
}
//--------------------------------------------------------------------------
// Find whether to limit maximum scale of emissions.
// Also allow for dampening at factorization or renormalization scale.
bool TimeShower::limitPTmax( Event& event, double Q2Fac, double Q2Ren) {
// Find whether to limit pT. Begin by user-set cases.
bool dopTlimit = false;
dopTlimit1 = dopTlimit2 = false;
int nHeavyCol = 0;
if (pTmaxMatch == 1) dopTlimit = dopTlimit1 = dopTlimit2 = true;
else if (pTmaxMatch == 2) dopTlimit = dopTlimit1 = dopTlimit2 = false;
// Always restrict SoftQCD processes.
else if (infoPtr->isNonDiffractive() || infoPtr->isDiffractiveA()
|| infoPtr->isDiffractiveB() || infoPtr->isDiffractiveC() )
dopTlimit = dopTlimit1 = dopTlimit2 = true;
// Look if any quark (u, d, s, c, b), gluon or photon in final state.
// Also count number of heavy coloured particles, like top.
else {
int n21 = 0;
int iBegin = 5 + beamOffset;
for (int i = iBegin; i < event.size(); ++i) {
if (event[i].status() == -21) ++n21;
else if (n21 == 0) {
int idAbs = event[i].idAbs();
if (idAbs <= 5 || idAbs == 21 || idAbs == 22) dopTlimit1 = true;
if ( (event[i].col() != 0 || event[i].acol() != 0)
&& idAbs > 5 && idAbs != 21 ) ++nHeavyCol;
} else if (n21 == 2) {
int idAbs = event[i].idAbs();
if (idAbs <= 5 || idAbs == 21 || idAbs == 22) dopTlimit2 = true;
}
}
dopTlimit = (doSecondHard) ? (dopTlimit1 && dopTlimit2) : dopTlimit1;
}
// Dampening at factorization or renormalization scale; only for hardest.
dopTdamp = false;
pT2damp = 0.;
if (!dopTlimit1 && (pTdampMatch == 1 || pTdampMatch == 2)) {
dopTdamp = true;
pT2damp = pow2(pTdampFudge) * ((pTdampMatch == 1) ? Q2Fac : Q2Ren);
}
if (!dopTlimit1 && nHeavyCol > 1 && (pTdampMatch == 3 || pTdampMatch == 4)) {
dopTdamp = true;
pT2damp = pow2(pTdampFudge) * ((pTdampMatch == 3) ? Q2Fac : Q2Ren);
}
// Done.
return dopTlimit;
}
//--------------------------------------------------------------------------
// Top-level routine to do a full time-like shower in resonance decay.
int TimeShower::shower( int iBeg, int iEnd, Event& event, double pTmax,
int nBranchMax) {
// Add new system, automatically with two empty beam slots.
int iSys = partonSystemsPtr->addSys();
// Loop over allowed range to find all final-state particles.
Vec4 pSum;
for (int i = iBeg; i <= iEnd; ++i) if (event[i].isFinal()) {
partonSystemsPtr->addOut( iSys, i);
pSum += event[i].p();
}
partonSystemsPtr->setSHat( iSys, pSum.m2Calc() );
// Let prepare routine do the setup.
dopTlimit1 = true;
dopTlimit2 = true;
dopTdamp = false;
hasWeaklyRadiated = false;
prepare( iSys, event, true);
// Begin evolution down in pT from hard pT scale.
int nBranch = 0;
pTLastBranch = 0.;
do {
double pTtimes = pTnext( event, pTmax, 0.);
// Do a final-state emission (if allowed).
if (pTtimes > 0.) {
if (branch( event)) {
++nBranch;
pTLastBranch = pTtimes;
}
pTmax = pTtimes;
}
// Keep on evolving until nothing is left to be done.
else pTmax = 0.;
} while (pTmax > 0. && (nBranchMax <= 0 || nBranch < nBranchMax));
// Return number of emissions that were performed.
return nBranch;
}
//--------------------------------------------------------------------------
// Top-level routine for QED radiation in hadronic decay to two leptons.
// Intentionally only does photon radiation, i.e. no photon branchings.
int TimeShower::showerQED( int i1, int i2, Event& event, double pTmax) {
// Add new system, automatically with two empty beam slots.
int iSys = partonSystemsPtr->addSys();
partonSystemsPtr->addOut( iSys, i1);
partonSystemsPtr->addOut( iSys, i2);
partonSystemsPtr->setSHat( iSys, m2(event[i1], event[i2]) );
// Charge type of two leptons tells whether MEtype is gamma*/Z0 or W+-.
int iChg1 = event[i1].chargeType();
int iChg2 = event[i2].chargeType();
int MEtype = (iChg1 + iChg2 == 0) ? 102 : 101;
// Fill dipole-ends list.
dipEnd.resize(0);
if (iChg1 != 0) dipEnd.push_back( TimeDipoleEnd(i1, i2, pTmax,
0, iChg1, 0, 0, 0, iSys, MEtype, i2) );
if (iChg2 != 0) dipEnd.push_back( TimeDipoleEnd(i2, i1, pTmax,
0, iChg2, 0, 0, 0, iSys, MEtype, i1) );
// Begin evolution down in pT from hard pT scale.
int nBranch = 0;
pTLastBranch = 0.;
do {
// Begin loop over all possible radiating dipole ends.
dipSel = 0;
iDipSel = -1;
double pT2sel = 0.;
for (int iDip = 0; iDip < int(dipEnd.size()); ++iDip) {
TimeDipoleEnd& dip = dipEnd[iDip];
// Dipole properties.
dip.mRad = event[dip.iRadiator].m();
dip.mRec = event[dip.iRecoiler].m();
dip.mDip = m( event[dip.iRadiator], event[dip.iRecoiler] );
dip.m2Rad = pow2(dip.mRad);
dip.m2Rec = pow2(dip.mRec);
dip.m2Dip = pow2(dip.mDip);
// Find maximum evolution scale for dipole.
dip.m2DipCorr = pow2(dip.mDip - dip.mRec) - dip.m2Rad;
double pTbegDip = min( pTmax, dip.pTmax );
double pT2begDip = min( pow2(pTbegDip), 0.25 * dip.m2DipCorr);
// Do QED evolution where relevant.
dip.pT2 = 0.;
if (pT2begDip > pT2sel) {
pT2nextQED( pT2begDip, pT2sel, dip, event);
// Update if found larger pT than current maximum. End dipole loop.
if (dip.pT2 > pT2sel) {
pT2sel = dip.pT2;
dipSel = &dip;
iDipSel = iDip;
}
}
}
double pTsel = (dipSel == 0) ? 0. : sqrt(pT2sel);
// Do a final-state emission (if allowed).
if (pTsel > 0.) {
// Find initial radiator and recoiler particles in dipole branching.
int iRadBef = dipSel->iRadiator;
int iRecBef = dipSel->iRecoiler;
Particle& radBef = event[iRadBef];
Particle& recBef = event[iRecBef];
Vec4 pRadBef = event[iRadBef].p();
Vec4 pRecBef = event[iRecBef].p();
// Construct kinematics in dipole rest frame; massless emitter.
double pTorig = sqrt( dipSel->pT2);
double eRadPlusEmt = 0.5 * (dipSel->m2Dip + dipSel->m2 - dipSel->m2Rec)
/ dipSel->mDip;
double e2RadPlusEmt = pow2(eRadPlusEmt);
double pzRadPlusEmt = 0.5 * sqrtpos( pow2(dipSel->m2Dip - dipSel->m2
- dipSel->m2Rec) - 4. * dipSel->m2 * dipSel->m2Rec ) / dipSel->mDip;
double pT2corr = dipSel->m2 * (e2RadPlusEmt * dipSel->z
* (1. - dipSel->z) - 0.25 * dipSel->m2) / pow2(pzRadPlusEmt);
double pTcorr = sqrtpos( pT2corr );
double pzRad = (e2RadPlusEmt * dipSel->z - 0.5 * dipSel->m2)
/ pzRadPlusEmt;
double pzEmt = (e2RadPlusEmt * (1. - dipSel->z)
- 0.5 * dipSel->m2) / pzRadPlusEmt;
double mRad = dipSel->mRad;
double mEmt = 0.;
// Kinematics reduction for radiator mass.
double m2Ratio = dipSel->m2Rad / dipSel->m2;
pTorig *= 1. - m2Ratio;
pTcorr *= 1. - m2Ratio;
pzRad += pzEmt * m2Ratio;
pzEmt *= 1. - m2Ratio;
// Store kinematics of branching in dipole rest frame.
double phi = 2. * M_PI * rndmPtr->flat();
Vec4 pRad = Vec4( pTcorr * cos(phi), pTcorr * sin(phi), pzRad,
sqrt( pow2(pTcorr) + pow2(pzRad) + pow2(mRad) ) );
Vec4 pEmt = Vec4( -pRad.px(), -pRad.py(), pzEmt,
sqrt( pow2(pTcorr) + pow2(pzEmt) + pow2(mEmt) ) );
Vec4 pRec = Vec4( 0., 0., -pzRadPlusEmt,
sqrt( pow2(pzRadPlusEmt) + dipSel->m2Rec ) );
// Rotate and boost dipole products to the event frame.
RotBstMatrix M;
M.fromCMframe(pRadBef, pRecBef);
pRad.rotbst(M);
pEmt.rotbst(M);
pRec.rotbst(M);
// Define new particles from dipole branching.
Particle rad = Particle(radBef.id(), 51, iRadBef, 0, 0, 0,
radBef.col(), radBef.acol(), pRad, mRad, pTsel);
Particle emt = Particle(22, 51, iRadBef, 0, 0, 0,
0, 0, pEmt, mEmt, pTsel);
Particle rec = Particle(recBef.id(), 52, iRecBef, iRecBef, 0, 0,
recBef.col(), recBef.acol(), pRec, dipSel->mRec, pTsel);
// ME corrections can lead to branching being rejected.
if (dipSel->MEtype == 0
|| findMEcorr( dipSel, rad, rec, emt, false) > rndmPtr->flat() ) {
// Shower may occur at a displaced vertex, or for unstable particle.
if (radBef.hasVertex()) {
rad.vProd( radBef.vProd() );
emt.vProd( radBef.vProd() );
}
if (recBef.hasVertex()) rec.vProd( recBef.vProd() );
rad.tau( event[iRadBef].tau() );
rec.tau( event[iRecBef].tau() );
// Put new particles into the event record.
int iRad = event.append(rad);
int iEmt = event.append(emt);
event[iRadBef].statusNeg();
event[iRadBef].daughters( iRad, iEmt);
int iRec = event.append(rec);
event[iRecBef].statusNeg();
event[iRecBef].daughters( iRec, iRec);
// Update to new dipole ends.
dipSel->iRadiator = iRad;
dipSel->iRecoiler = iRec;
dipSel->pTmax = pTsel;
// Update other dipoles that also involved the radiator or recoiler.
for (int i = 0; i < int(dipEnd.size()); ++i) if (i != iDipSel) {
if (dipEnd[i].iRadiator == iRadBef) dipEnd[i].iRadiator = iRad;
if (dipEnd[i].iRecoiler == iRadBef) dipEnd[i].iRecoiler = iRad;
if (dipEnd[i].iMEpartner == iRadBef) dipEnd[i].iMEpartner = iRad;
if (dipEnd[i].iRadiator == iRecBef) dipEnd[i].iRadiator = iRec;
if (dipEnd[i].iRecoiler == iRecBef) dipEnd[i].iRecoiler = iRec;
if (dipEnd[i].iMEpartner == iRecBef) dipEnd[i].iMEpartner = iRec;
}
// Done with branching
++nBranch;
pTLastBranch = pTsel;
}
pTmax = pTsel;
}
// Keep on evolving until nothing is left to be done.
else pTmax = 0.;
} while (pTmax > 0.);
// Return number of emissions that were performed.
return nBranch;
}
//--------------------------------------------------------------------------
// Global recoil: reset counters and store locations of outgoing partons.
void TimeShower::prepareGlobal( Event& event) {
// Global recoils: reset some counters.
nGlobal = 0;
nHard = 0;
nProposed.clear();
hardPartons.resize(0);
nFinalBorn = settingsPtr->mode("TimeShower:nPartonsInBorn");
// Global recoils: store positions of hard outgoing partons.
// No global recoil for H events.
int nHeavyCol = 0;
if (globalRecoil) {
for (int i = 0; i < event.size(); ++i) {
if (event[i].isFinal() && event[i].colType() != 0)
hardPartons.push_back(i);
if ( event[i].isFinal() && event[i].idAbs() > 5 && event[i].idAbs() != 21
&& (event[i].col() != 0 || event[i].acol() != 0))
++nHeavyCol;
}
nHard = hardPartons.size();
if (nFinalBorn > 0 && nHard > nFinalBorn) {
hardPartons.resize(0);
nHard = 0;
}
}
// Reset nFinalBorn on an event-by-event basis.
string nNow = infoPtr->getEventAttribute("npNLO",true);
if (nNow != "" && nFinalBorn == -1){
nFinalBorn = max(0, atoi((char*)nNow.c_str()));
// Add number of heavy coloured objects in lowest multiplicity state.
nFinalBorn += nHeavyCol;
}
}
//--------------------------------------------------------------------------
// Prepare system for evolution; identify ME.
void TimeShower::prepare( int iSys, Event& event, bool limitPTmaxIn) {
// Reset W/Z radiation flag at first call for new event.
if (iSys == 0) hasWeaklyRadiated = false;
// Reset dipole-ends list for first interaction and for resonance decays.
int iInA = partonSystemsPtr->getInA(iSys);
int iInB = partonSystemsPtr->getInB(iSys);
if (iSys == 0 || iInA == 0) dipEnd.resize(0);
int dipEndSizeBeg = dipEnd.size();
// No dipoles for 2 -> 1 processes.
if (partonSystemsPtr->sizeOut(iSys) < 2) return;
// In case of DPS overwrite limitPTmaxIn by saved value.
if (doSecondHard && iSys == 0) limitPTmaxIn = dopTlimit1;
if (doSecondHard && iSys == 1) limitPTmaxIn = dopTlimit2;
// Reset number of proposed splittings. Used for global recoil.
// First check if this system belongs to the hard scattering.
bool isHard = false;
for (int i = 0; i < partonSystemsPtr->sizeOut(iSys); ++i) {
int ii = partonSystemsPtr->getOut( iSys, i);
for (int iHard = 0; iHard < int(hardPartons.size()); ++iHard) {
if ( event[ii].isAncestor(hardPartons[iHard])
|| ii == hardPartons[iHard]){
isHard = true;
break;
}
}
if (isHard) break;
}
// If the system belongs to the hard scattering, initialise
// counter of proposed emissions.
if (isHard && nProposed.find(iSys) == nProposed.end() )
nProposed.insert(make_pair(iSys,0));
// Loop through final state of system to find possible dipole ends.
for (int i = 0; i < partonSystemsPtr->sizeOut(iSys); ++i) {
int iRad = partonSystemsPtr->getOut( iSys, i);
if (event[iRad].isFinal() && event[iRad].scale() > 0.) {
// Identify colour octet onium state. Check whether QCD shower allowed.
int idRad = event[iRad].id();
int idRadAbs = abs(idRad);
bool isOctetOnium = particleDataPtr->isOctetHadron(idRad);
bool doQCD = doQCDshower;
if (doQCD && isOctetOnium)
doQCD = (rndmPtr->flat() < octetOniumFraction);
// Find dipole end formed by colour index.
int colTag = event[iRad].col();
if (doQCD && colTag > 0) setupQCDdip( iSys, i, colTag, 1, event,
isOctetOnium, limitPTmaxIn);
// Find dipole end formed by anticolour index.
int acolTag = event[iRad].acol();
if (doQCD && acolTag > 0) setupQCDdip( iSys, i, acolTag, -1, event,
isOctetOnium, limitPTmaxIn);
// Find "charge-dipole" and "photon-dipole" ends.
int chgType = event[iRad].chargeType();
bool doChgDip = (chgType != 0)
&& ( ( doQEDshowerByQ && event[iRad].isQuark() )
|| ( doQEDshowerByL && event[iRad].isLepton() )
|| ( doQEDshowerByOther && event[iRad].isResonance() ) );
int gamType = (idRad == 22) ? 1 : 0;
bool doGamDip = (gamType == 1) && doQEDshowerByGamma;
if (doChgDip || doGamDip) setupQEDdip( iSys, i, chgType, gamType,
event, limitPTmaxIn);
// Find weak diple ends.
if (doWeakShower && (iSys == 0 || !partonSystemsPtr->hasInAB(iSys))
&& (event[iRad].isQuark() || event[iRad].isLepton())
&& (!weakExternal || iSys != 0) ) {
if (weakMode == 0 || weakMode == 1)
setupWeakdip( iSys, i, 1, event, limitPTmaxIn);
if (weakMode == 0 || weakMode == 2)
setupWeakdip( iSys, i, 2, event, limitPTmaxIn);
}
// Find Hidden Valley dipole ends.
bool isHVrad = (idRadAbs > 4900000 && idRadAbs < 4900007)
|| (idRadAbs > 4900010 && idRadAbs < 4900017)
|| (idRadAbs > 4900100 && idRadAbs < 4900109);
if (doHVshower && isHVrad) setupHVdip( iSys, i, event, limitPTmaxIn);
// End loop over system final state. Have now found the dipole ends.
}
}
// Special setup for weak dipoles if they are setup externally.
if (doWeakShower && weakExternal && iSys == 0)
setupWeakdipExternal(event, limitPTmaxIn);
// Loop through dipole ends to find matrix element corrections.
for (int iDip = dipEndSizeBeg; iDip < int(dipEnd.size()); ++iDip)
findMEtype( event, dipEnd[iDip]);
// Update dipole list after a multiparton interactions rescattering.
if (iSys > 0 && ( (iInA > 0 && event[iInA].status() == -34)
|| (iInB > 0 && event[iInB].status() == -34) ) )
rescatterUpdate( iSys, event);
}
//--------------------------------------------------------------------------
// Update dipole list after a multiparton interactions rescattering.
void TimeShower::rescatterUpdate( int iSys, Event& event) {
// Loop over two incoming partons in system; find their rescattering mother.
// (iOut is outgoing from old system = incoming iIn of rescattering system.)
for (int iResc = 0; iResc < 2; ++iResc) {
int iIn = (iResc == 0) ? partonSystemsPtr->getInA(iSys)
: partonSystemsPtr->getInB(iSys);
if (iIn == 0 || event[iIn].status() != -34) continue;
int iOut = event[iIn].mother1();
// Loop over all dipoles.
int dipEndSize = dipEnd.size();
for (int iDip = 0; iDip < dipEndSize; ++iDip) {
TimeDipoleEnd& dipNow = dipEnd[iDip];
// Kill dipoles where rescattered parton is radiator.
if (dipNow.iRadiator == iOut) {
dipNow.colType = 0;
dipNow.chgType = 0;
dipNow.gamType = 0;
continue;
}
// No matrix element for dipoles between scatterings.
if (dipNow.iMEpartner == iOut) {
dipNow.MEtype = 0;
dipNow.iMEpartner = -1;
}
// Update dipoles where outgoing rescattered parton is recoiler.
if (dipNow.iRecoiler == iOut) {
int iRad = dipNow.iRadiator;
// Colour dipole: recoil in final state, initial state or new.
if (dipNow.colType > 0) {
int colTag = event[iRad].col();
bool done = false;
for (int i = 0; i < partonSystemsPtr->sizeOut(iSys); ++i) {
int iRecNow = partonSystemsPtr->getOut( iSys, i);
if (event[iRecNow].acol() == colTag) {
dipNow.iRecoiler = iRecNow;
dipNow.systemRec = iSys;
dipNow.MEtype = 0;
done = true;
break;
}
}
if (!done) {
int iIn2 = (iResc == 0) ? partonSystemsPtr->getInB(iSys)
: partonSystemsPtr->getInA(iSys);
if (event[iIn2].col() == colTag) {
dipNow.iRecoiler = iIn2;
dipNow.systemRec = iSys;
dipNow.MEtype = 0;
int isrType = event[iIn2].mother1();
// This line in case mother is a rescattered parton.
while (isrType > 2 + beamOffset)
isrType = event[isrType].mother1();
if (isrType > 2) isrType -= beamOffset;
dipNow.isrType = isrType;
done = true;
}
}
// If above options failed, then create new dipole.
if (!done) {
int iRadNow = partonSystemsPtr->getIndexOfOut(dipNow.system, iRad);
if (iRadNow != -1)
setupQCDdip(dipNow.system, iRadNow, event[iRad].col(), 1,
event, dipNow.isOctetOnium, true);
else
infoPtr->errorMsg("Warning in TimeShower::rescatterUpdate: "
"failed to locate radiator in system");
dipNow.colType = 0;
dipNow.chgType = 0;
dipNow.gamType = 0;
infoPtr->errorMsg("Warning in TimeShower::rescatterUpdate: "
"failed to locate new recoiling colour partner");
}
// Anticolour dipole: recoil in final state, initial state or new.
} else if (dipNow.colType < 0) {
int acolTag = event[iRad].acol();
bool done = false;
for (int i = 0; i < partonSystemsPtr->sizeOut(iSys); ++i) {
int iRecNow = partonSystemsPtr->getOut( iSys, i);
if (event[iRecNow].col() == acolTag) {
dipNow.iRecoiler = iRecNow;
dipNow.systemRec = iSys;
dipNow.MEtype = 0;
done = true;
break;
}
}
if (!done) {
int iIn2 = (iResc == 0) ? partonSystemsPtr->getInB(iSys)
: partonSystemsPtr->getInA(iSys);
if (event[iIn2].acol() == acolTag) {
dipNow.iRecoiler = iIn2;
dipNow.systemRec = iSys;
dipNow.MEtype = 0;
int isrType = event[iIn2].mother1();
// This line in case mother is a rescattered parton.
while (isrType > 2 + beamOffset)
isrType = event[isrType].mother1();
if (isrType > 2) isrType -= beamOffset;
dipNow.isrType = isrType;
done = true;
}
}
// If above options failed, then create new dipole.
if (!done) {
int iRadNow = partonSystemsPtr->getIndexOfOut(dipNow.system, iRad);
if (iRadNow != -1)
setupQCDdip(dipNow.system, iRadNow, event[iRad].acol(), -1,
event, dipNow.isOctetOnium, true);
else
infoPtr->errorMsg("Warning in TimeShower::rescatterUpdate: "
"failed to locate radiator in system");
dipNow.colType = 0;
dipNow.chgType = 0;
dipNow.gamType = 0;
infoPtr->errorMsg("Warning in TimeShower::rescatterUpdate: "
"failed to locate new recoiling colour partner");
}
// Charge or photon dipoles: same flavour in final or initial state.
} else if (dipNow.chgType != 0 || dipNow.gamType != 0) {
int idTag = event[dipNow.iRecoiler].id();
bool done = false;
for (int i = 0; i < partonSystemsPtr->sizeOut(iSys); ++i) {
int iRecNow = partonSystemsPtr->getOut( iSys, i);
if (event[iRecNow].id() == idTag) {
dipNow.iRecoiler = iRecNow;
dipNow.systemRec = iSys;
dipNow.MEtype = 0;
done = true;
break;
}
}
if (!done) {
int iIn2 = (iResc == 0) ? partonSystemsPtr->getInB(iSys)
: partonSystemsPtr->getInA(iSys);
if (event[iIn2].id() == -idTag) {
dipNow.iRecoiler = iIn2;
dipNow.systemRec = iSys;
dipNow.MEtype = 0;
int isrType = event[iIn2].mother1();
// This line in case mother is a rescattered parton.
while (isrType > 2 + beamOffset)
isrType = event[isrType].mother1();
if (isrType > 2) isrType -= beamOffset;
dipNow.isrType = isrType;
done = true;
}
}
// If above options failed, then create new dipole
if (!done) {
int iRadNow = partonSystemsPtr->getIndexOfOut(dipNow.system, iRad);
if (iRadNow != -1)
setupQEDdip(dipNow.system, iRadNow, dipNow.chgType,
dipNow.gamType, event, true);
else
infoPtr->errorMsg("Warning in TimeShower::rescatterUpdate: "
"failed to locate radiator in system");
dipNow.colType = 0;
dipNow.chgType = 0;
dipNow.gamType = 0;
infoPtr->errorMsg("Warning in TimeShower::rescatterUpdate: "
"failed to locate new recoiling charge partner");
}
}
}
// End of loop over dipoles and two incoming sides.
}
}
}
//--------------------------------------------------------------------------
// Update dipole list after each ISR emission (so not used for resonances).
void TimeShower::update( int iSys, Event& event, bool hasWeakRad) {
// Start list of rescatterers that gave further changed systems in ISR.
vector<int> iRescatterer;
// Find new and old positions of incoming partons in the system.
vector<int> iNew, iOld;
iNew.push_back( partonSystemsPtr->getInA(iSys) );
iOld.push_back( event[iNew[0]].daughter2() );
iNew.push_back( partonSystemsPtr->getInB(iSys) );
iOld.push_back( event[iNew[1]].daughter2() );
// Ditto for outgoing partons, except the newly created one.
int sizeOut = partonSystemsPtr->sizeOut(iSys) - 1;
for (int i = 0; i < sizeOut; ++i) {
int iNow = partonSystemsPtr->getOut(iSys, i);
iNew.push_back( iNow );
iOld.push_back( event[iNow].mother1() );
// Add non-final to list of rescatterers.
if (!event[iNow].isFinal()) iRescatterer.push_back( iNow );
}
int iNewNew = partonSystemsPtr->getOut(iSys, sizeOut);
// Swap beams to let 0 be side on which branching occured.
if (event[iNew[0]].status() != -41) {
swap( iNew[0], iNew[1]);
swap( iOld[0], iOld[1]);
}
// Loop over all dipole ends belonging to the system
// or to the recoil system, if different.
for (int iDip = 0; iDip < int(dipEnd.size()); ++iDip)
if (dipEnd[iDip].system == iSys || dipEnd[iDip].systemRec == iSys) {
TimeDipoleEnd& dipNow = dipEnd[iDip];
// Replace radiator (always in final state so simple).
for (int i = 2; i < 2 + sizeOut; ++i)
if (dipNow.iRadiator == iOld[i]) {
dipNow.iRadiator = iNew[i];
break;
}
// Replace ME partner (always in final state, if exists, so simple).
for (int i = 2; i < 2 + sizeOut; ++i)
if (dipNow.iMEpartner == iOld[i]) {
dipNow.iMEpartner = iNew[i];
break;
}
// Recoiler: by default pick old one, only moved. Note excluded beam.
int iRec = 0;
if (dipNow.systemRec == iSys) {
for (int i = 1; i < 2 + sizeOut; ++i)
if (dipNow.iRecoiler == iOld[i]) {
iRec = iNew[i];
break;
}
// QCD recoiler: check if colour hooks up with new final parton.
if ( dipNow.colType > 0
&& event[dipNow.iRadiator].col() == event[iNewNew].acol() ) {
iRec = iNewNew;
dipNow.isrType = 0;
}
if ( dipNow.colType < 0
&& event[dipNow.iRadiator].acol() == event[iNewNew].col() ) {
iRec = iNewNew;
dipNow.isrType = 0;
}
// QCD recoiler: check if colour hooks up with new beam parton.
if ( iRec == 0 && dipNow.colType > 0
&& event[dipNow.iRadiator].col() == event[iNew[0]].col() )
iRec = iNew[0];
if ( iRec == 0 && dipNow.colType < 0
&& event[dipNow.iRadiator].acol() == event[iNew[0]].acol() )
iRec = iNew[0];
// QED/photon recoiler: either to new particle or remains to beam.
if ( iRec == 0 && (dipNow.chgType != 0 || dipNow.gamType != 0) ) {
if ( event[iNew[0]].chargeType() == 0 ) {
iRec = iNewNew;
dipNow.isrType = 0;
} else {
iRec = iNew[0];
}