-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHistory.cc
9601 lines (8148 loc) · 344 KB
/
History.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
// History.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.
// This file is written by Stefan Prestel.
// Function definitions (not found in the header) for the
// Clustering and History classes.
#include "Pythia8/History.h"
#include "Pythia8/SharedPointers.h"
namespace Pythia8 {
//==========================================================================
// The Clustering class.
//--------------------------------------------------------------------------
// Declaration of Clustering class
// This class holds information about one radiator, recoiler,
// emitted system.
// This class is a container class for History class use.
// print for debug
void Clustering::list() const {
cout << " emt " << emitted
<< " rad " << emittor
<< " rec " << recoiler
<< " partner " << partner
<< " pTscale " << pTscale << endl;
}
//==========================================================================
// The History class.
// A History object represents an event in a given step in the CKKW-L
// clustering procedure. It defines a tree-like recursive structure,
// where the root node represents the state with n jets as given by
// the matrix element generator, and is characterized by the member
// variable mother being null. The leaves on the tree corresponds to a
// fully clustered paths where the original n-jets has been clustered
// down to the Born-level state. Also states which cannot be clustered
// down to the Born-level are possible - these will be called
// incomplete. The leaves are characterized by the vector of children
// being empty.
//--------------------------------------------------------------------------
// Number of trial emission to use for calculating the average number of
// emissions
const int History::NTRIAL = 1;
//--------------------------------------------------------------------------
// Declaration of History class
// The only constructor. Default arguments are used when creating
// the initial history node. The \a depth is the maximum number of
// clusterings requested. \a scalein is the scale at which the \a
// statein was clustered (should be set to the merging scale for the
// initial history node. \a beamAIn and beamBIn are needed to
// calcutate PDF ratios, \a particleDataIn to have access to the
// correct masses of particles. If \a isOrdered is true, the previous
// clusterings has been ordered. \a is the PDF ratio for this
// clustering (=1 for FSR clusterings). \a probin is the accumulated
// probabilities for the previous clusterings, and \ mothin is the
// previous history node (null for the initial node).
History::History( int depthIn,
double scalein,
Event statein,
Clustering c,
MergingHooksPtr mergingHooksPtrIn,
BeamParticle beamAIn,
BeamParticle beamBIn,
ParticleData* particleDataPtrIn,
Info* infoPtrIn,
PartonLevel* showersIn,
CoupSM* coupSMPtrIn,
bool isOrdered = true,
bool isStronglyOrdered = true,
bool isAllowed = true,
bool isNextInInput = true,
double probin = 1.0,
History * mothin = 0)
: state(statein),
mother(mothin),
selectedChild(-1),
sumpath(0.0),
sumGoodBranches(0.0),
sumBadBranches(0.0),
foundOrderedPath(false),
foundStronglyOrderedPath(false),
foundAllowedPath(false),
foundCompletePath(false),
scale(scalein),
nextInInput(isNextInInput),
prob(probin),
clusterIn(c),
iReclusteredOld(0),
iReclusteredNew(),
doInclude(true),
mergingHooksPtr(mergingHooksPtrIn),
beamA(beamAIn),
beamB(beamBIn),
particleDataPtr(particleDataPtrIn),
infoPtr(infoPtrIn),
loggerPtr(infoPtrIn->loggerPtr),
showers(showersIn),
coupSMPtr(coupSMPtrIn),
probMaxSave(-1.),
depth(depthIn),
minDepthSave(-1)
{
// Initialise beam particles
setupBeams();
// Update probability with PDF ratio
if (mother && mergingHooksPtr->includeRedundant()) prob *= pdfForSudakov();
// Minimal scalar sum of pT used in Herwig to choose history
// Keep track of scalar PT
if (mother) {
double acoll = (mother->state[clusterIn.emittor].isFinal())
? mergingHooksPtr->herwigAcollFSR()
: mergingHooksPtr->herwigAcollISR();
sumScalarPT = mother->sumScalarPT + acoll*scale;
} else
sumScalarPT = 0.0;
// Remember reclustered radiator in lower multiplicity state
if ( mother ) iReclusteredOld = mother->iReclusteredNew;
// Check if more steps should be taken.
int nFinalP = 0, nFinalW = 0, nFinalZ = 0;
for ( int i = 0; i < int(state.size()); ++i )
if ( state[i].isFinal() ) {
if ( state[i].colType() != 0 )
nFinalP++;
if ( state[i].idAbs() == 23 )
nFinalZ++;
if ( state[i].idAbs() == 24 )
nFinalW++;
}
if ( mergingHooksPtr->doWeakClustering()
&& nFinalP == 2 && nFinalW == 0 && nFinalZ == 0) depth = 0;
// Stop clustering at 2->1 massive.
// Stop clustering at 2->2 massless.
bool qcd = ( nFinalP > mergingHooksPtr->hardProcess->nQuarksOut() );
// If this is not the fully clustered state, try to find possible
// QCD clusterings.
vector<Clustering> clusterings;
if ( qcd && depth > 0 ) clusterings = getAllQCDClusterings();
bool dow = ( mergingHooksPtr->doWeakClustering()
&& nFinalP > 1 && nFinalW+nFinalZ > 0 );
// If necessary, try to find possible EW clusterings.
vector<Clustering> clusteringsEW;
if ( depth > 0 && dow )
clusteringsEW = getAllEWClusterings();
if ( !clusteringsEW.empty() ) {
clusterings.insert( clusterings.end(), clusteringsEW.begin(),
clusteringsEW.end() );
}
// If necessary, try to find possible SQCD clusterings.
vector<Clustering> clusteringsSQCD;
if ( depth > 0 && mergingHooksPtr->doSQCDClustering() )
clusteringsSQCD = getAllSQCDClusterings();
if ( !clusteringsSQCD.empty() )
clusterings.insert( clusterings.end(), clusteringsSQCD.begin(),
clusteringsSQCD.end() );
// If no clusterings were found, the recursion is done and we
// register this node.
if ( clusterings.empty() ) {
// Multiply with hard process matrix element.
prob *= hardProcessME(state);
if (registerPath( *this, isOrdered, isStronglyOrdered, isAllowed,
depth == 0 )) updateMinDepth(depth);
return;
}
// We'll now order the clusterings in such a way that an ordered
// history is found more rapidly. Following the branches with small pT is
// a good heuristic, as is following ISR clusterings.
multimap<double, Clustering *> sort;
for (unsigned int i = 0; i < clusterings.size(); ++i) {
double t = clusterings[i].pT();
double index = t;
//// This might be a marginally faster ordering.
//double z = getCurrentZ(clusterings[i].emittor,
// clusterings[i].recoiler,
// clusterings[i].emitted,
// clusterings[i].flavRadBef);
//double index = t/z;
//if (!state[clusterings[i].emittor].isFinal())
// sort.insert(make_pair(-1./index, &clusterings[i]));
//else
// sort.insert(make_pair(index, &clusterings[i]));
sort.insert(make_pair(index, &clusterings[i]));
}
for ( multimap<double, Clustering *>::iterator it = sort.begin();
it != sort.end(); ++it ) {
double t = it->second->pT();
// If this path is not strongly ordered and we already have found an
// ordered path, then we don't need to continue along this path.
bool stronglyOrdered = isStronglyOrdered;
if ( mergingHooksPtr->enforceStrongOrdering()
&& ( !stronglyOrdered
|| ( mother && ( t <
mergingHooksPtr->scaleSeparationFactor()*scale ) ))) {
if ( onlyStronglyOrderedPaths() ) continue;
stronglyOrdered = false;
}
// Check if reclustering follows ordered sequence.
bool ordered = isOrdered;
if ( mergingHooksPtr->orderInRapidity()
&& mergingHooksPtr->orderHistories() ) {
// Get new z value
double z = getCurrentZ((*it->second).emittor,
(*it->second).recoiler,(*it->second).emitted,
(*it->second).flavRadBef);
// Get z value of splitting that produced this state
double zOld = (!mother) ? 0. : mother->getCurrentZ(clusterIn.emittor,
clusterIn.recoiler,clusterIn.emitted,
clusterIn.flavRadBef);
// If this path is not ordered in pT and y, and we already have found
// an ordered path, then we don't need to continue along this path.
if ( !ordered || ( mother && (t < scale
|| t < pow(1. - z,2) / (z * (1. - zOld ))*scale ))) {
if ( onlyOrderedPaths() ) continue;
ordered = false;
}
} else if ( mergingHooksPtr->orderHistories() ) {
// If this path is not ordered in pT and we already have found an
// ordered path, then we don't need to continue along this path, unless
// we have not yet found an allowed path.
if ( !ordered || ( mother && (t < scale) ) ) {
if ( depth >= minDepth() && onlyOrderedPaths() && onlyAllowedPaths() )
continue;
ordered = false;
}
}
// Check if reclustered state should be disallowed.
bool doCut = mergingHooksPtr->canCutOnRecState()
|| mergingHooksPtr->allowCutOnRecState();
bool allowed = isAllowed;
if ( doCut
&& mergingHooksPtr->doCutOnRecState(cluster(*it->second)) ) {
if ( onlyAllowedPaths() ) continue;
allowed = false;
}
// Skip if this branch is already strongly suppressed.
double p = getProb(*it->second);
if (abs(p)*prob < 1e-10*probMax()) continue;
updateProbMax(abs(p)*prob,depth==0);
// Skip clusterings with vanishing probability.
if (p==0.) continue;
// Create new state - already here, to catch errors when clustering.
Event newState(cluster(*it->second));
if (newState.size()<3) continue;
// Perform the clustering and recurse and construct the next
// history node.
children.push_back(new History(depth - 1, t, newState,
*it->second, mergingHooksPtr, beamA, beamB, particleDataPtr,
infoPtr, showers, coupSMPtr, ordered, stronglyOrdered, allowed,
true, prob*p, this ));
}
}
//--------------------------------------------------------------------------
// Function to project all possible paths onto only the desired paths.
bool History::projectOntoDesiredHistories() {
// At the moment, only trim histories.
return trimHistories();
}
//--------------------------------------------------------------------------
// In the initial history node, select one of the paths according to
// the probabilities. This function should be called for the initial
// history node.
// IN trialShower* : Previously initialised trialShower object,
// to perform trial showering and as
// repository of pointers to initialise alphaS
// PartonSystems* : PartonSystems object needed to initialise
// shower objects
// OUT double : (Sukadov) , (alpha_S ratios) , (PDF ratios)
vector<double> History::weightCKKWL(PartonLevel* trial, AlphaStrong * asFSR,
AlphaStrong * asISR, AlphaEM * aemFSR, AlphaEM * aemISR, double RN) {
if ( mergingHooksPtr->canCutOnRecState() && !foundAllowedPath ) {
loggerPtr->WARNING_MSG(
"no allowed history found. Using disallowed history");
}
if ( mergingHooksPtr->orderHistories() && !foundOrderedPath ) {
loggerPtr->WARNING_MSG(
"no ordered history found. Using unordered history");
}
if ( mergingHooksPtr->canCutOnRecState()
&& mergingHooksPtr->orderHistories()
&& !foundAllowedPath && !foundOrderedPath ) {
loggerPtr->WARNING_MSG("no allowed or ordered history found");
}
// Read alpha_S in ME calculation and maximal scale (eCM)
double asME = infoPtr->alphaS();
double aemME = infoPtr->alphaEM();
double maxScale = (foundCompletePath) ? infoPtr->eCM()
: mergingHooksPtr->muFinME();
// Select a path of clusterings
History * selected = select(RN);
// Set scales in the states to the scales pythia would have set
selected->setScalesInHistory();
int nWgts = mergingHooksPtr->nWgts;
// Get weight.
vector<double> sudakov( nWgts, 1. );
vector<double> asWeight( nWgts, 1. );
vector<double> aemWeight( nWgts, 1. );
vector<double> pdfWeight( nWgts, 1. );
// Do trial shower, calculation of alpha_S ratios, PDF ratios
sudakov = selected->weightTree( trial, asME, aemME, maxScale,
selected->clusterIn.pT(), asFSR, asISR, aemFSR, aemISR, asWeight,
aemWeight, pdfWeight );
// MPI no-emission probability
int njetsMaxMPI = mergingHooksPtr->nMinMPI();
vector<double> mpiwt = selected->weightTreeEmissions( trial, -1, 0,
njetsMaxMPI, maxScale );
// Set hard process renormalisation scale to default Pythia value.
bool resetScales = mergingHooksPtr->resetHardQRen();
// For pure QCD dijet events, evaluate the coupling of the hard process at
// a more reasonable pT, rather than evaluation \alpha_s at a fixed
// arbitrary scale.
if ( resetScales
&& mergingHooksPtr->getProcessString().compare("pp>jj") == 0) {
// Reset to a running coupling. Here we choose FSR for simplicity.
double newQ2Ren = pow2( selected->hardRenScale(selected->state) );
double runningCoupling = (*asFSR).alphaS(newQ2Ren) / asME;
for (double& asW: asWeight) asW *= pow2(runningCoupling);
} else if (isQCD2to2(selected->state)) {
// Reset to a running coupling. Here we choose FSR for simplicity.
double newQ2Ren = pow2( selected->hardRenScale(selected->state) );
double runningCoupling = (*asFSR).alphaS(newQ2Ren) / asME;
for (double& asW: asWeight) asW *= pow2(runningCoupling);
}
// For W clustering, correct the \alpha_em.
if (isEW2to1(selected->state)) {
// Reset to a running coupling. Here we choose FSR for simplicity.
double newQ2Ren = pow2( selected->hardRenScale(selected->state) );
double runningCoupling = (*aemFSR).alphaEM(newQ2Ren) / aemME;
for (double& aemW: aemWeight) aemW *= runningCoupling;
}
// For prompt photon events, evaluate the coupling of the hard process at
// a more reasonable pT, rather than evaluation \alpha_s at a fixed
// arbitrary scale.
if ( resetScales
&& mergingHooksPtr->getProcessString().compare("pp>aj") == 0) {
// Reset to a running coupling. In prompt photon always ISR.
double newQ2Ren = pow2( selected->hardRenScale(selected->state) );
double runningCoupling =
(*asISR).alphaS( newQ2Ren + pow(mergingHooksPtr->pT0ISR(),2) ) / asME;
for (double& asW: asWeight) asW *= runningCoupling;
}
// Done
vector<double> ret;
for (int iVar = 0; iVar < nWgts; ++iVar)
ret.push_back(sudakov[iVar]*asWeight[iVar]*aemWeight[iVar]*pdfWeight[iVar]*
mpiwt[iVar]);
return ret;
}
//--------------------------------------------------------------------------
// Function to return weight of virtual correction and subtractive events
// for NL3 merging
vector<double> History::weightNL3Loop(PartonLevel* trial, double RN ) {
if ( mergingHooksPtr->canCutOnRecState() && !foundAllowedPath ) {
loggerPtr->WARNING_MSG(
"no allowed history found. Using disallowed history");
}
// Select a path of clusterings
History * selected = select(RN);
// Set scales in the states to the scales pythia would have set
selected->setScalesInHistory();
// So far, no reweighting
int nWgts = mergingHooksPtr->nWgts;
vector<double> wt( nWgts, 1. );
// Only reweighting with MPI no-emission probability
double maxScale = (foundCompletePath) ? infoPtr->eCM()
: mergingHooksPtr->muFinME();
int njetsMaxMPI = mergingHooksPtr->nMinMPI();
vector<double> mpiwt = selected->weightTreeEmissions( trial, -1, 0,
njetsMaxMPI, maxScale );
wt = mpiwt;
// Done
return wt;
}
//--------------------------------------------------------------------------
// Function to calculate O(\alpha_s)-term of CKKWL-weight for NLO merging
vector<double> History::weightNL3First(PartonLevel* trial, AlphaStrong* asFSR,
AlphaStrong* asISR, AlphaEM* , AlphaEM* , double RN,
Rndm* rndmPtr ) {
// Read alpha_S in ME calculation and maximal scale (eCM)
double asME = infoPtr->alphaS();
double muR = mergingHooksPtr->muRinME();
double maxScale = (foundCompletePath)
? infoPtr->eCM()
: mergingHooksPtr->muFinME();
// Pick path of clusterings
History * selected = select(RN);
// Set scales in the states to the scales pythia would have set
selected->setScalesInHistory();
int nSteps = mergingHooksPtr->getNumberOfClusteringSteps(state);
// Get the lowest order k-factor and add first two terms in expansion
double kFactor = asME * mergingHooksPtr->k1Factor(nSteps);
// If using Bbar, which includes a tree-level part, subtract an
// additional one, i.e. the O(\as^0) contribution as well
double wt = 1. + kFactor;
// Calculate sum of O(alpha) terms
double wtFirst = selected->weightFirst(trial,asME, muR, maxScale, asFSR,
asISR, rndmPtr );
// Get starting scale for trial showers.
double startingScale = (selected->mother) ? state.scale()
: infoPtr->eCM();
// Count emissions: New variant
// Generate true average, not only one-point
bool fixpdf = true;
bool fixas = true;
double nWeight1 = 0.;
for(int i=0; i < NTRIAL; ++i) {
// Get number of emissions
vector<double> unresolvedEmissionTerm = countEmissions( trial,
startingScale, mergingHooksPtr->tms(), 2, asME, asFSR, asISR, 3,
fixpdf, fixas );
nWeight1 += unresolvedEmissionTerm[1];
}
wtFirst += nWeight1/double(NTRIAL);
// Introduce vector to allow variation of coefficient
int nWgts = mergingHooksPtr->nWgts;
vector<double> wtVec({wt+wtFirst});
// Use the varied scale in the coefficient around which we expand
for (int iVar = 1; iVar < nWgts; ++iVar) {
double asFix = asFSR->alphaS(pow2(muR*mergingHooksPtr->
muRVarFactors[iVar-1])) / asME;
wtVec.push_back( wt + asFix*wtFirst );
}
// Introduce variation of stong coupling that is not done in Born input
for ( int iVar = 1; iVar < nWgts; ++iVar ) {
double corrFac = std::pow(asFSR->alphaS(pow2(muR*mergingHooksPtr->
muRVarFactors[iVar-1])) / asME, nSteps);
wtVec[iVar] *= corrFac;
}
// Done
return wtVec;
}
//--------------------------------------------------------------------------
vector<double> History::weightNL3Tree(PartonLevel* trial, AlphaStrong*
asFSR, AlphaStrong * asISR, AlphaEM * aemFSR, AlphaEM * aemISR,
double RN) {
// No difference to CKKW-L. Recycle CKKW-L function.
return weightCKKWL( trial, asFSR, asISR, aemFSR, aemISR, RN);
}
//--------------------------------------------------------------------------
vector<double> History::weightUMEPSTree(PartonLevel* trial, AlphaStrong*
asFSR, AlphaStrong * asISR, AlphaEM * aemFSR, AlphaEM * aemISR,
double RN) {
// No difference to CKKW-L. Recycle CKKW-L function.
return weightCKKWL( trial, asFSR, asISR, aemFSR, aemISR, RN);
}
//--------------------------------------------------------------------------
// Function to return weight of virtual correction events for NLO merging
vector<double> History::weightUMEPSSubt(PartonLevel* trial, AlphaStrong*
asFSR, AlphaStrong * asISR, AlphaEM * aemFSR, AlphaEM * aemISR,
double RN ) {
// Read alpha_S in ME calculation and maximal scale (eCM)
double asME = infoPtr->alphaS();
double aemME = infoPtr->alphaEM();
double maxScale = (foundCompletePath) ? infoPtr->eCM()
: mergingHooksPtr->muFinME();
// Select a path of clusterings
History * selected = select(RN);
// Set scales in the states to the scales pythia would have set
selected->setScalesInHistory();
// Get weight.
int nWgts = mergingHooksPtr->nWgts;
vector<double> sudakov( nWgts, 1.);
vector<double> asWeight( nWgts, 1.);
vector<double> aemWeight( nWgts, 1.);
vector<double> pdfWeight( nWgts, 1.);
// Do trial shower, calculation of alpha_S ratios, PDF ratios
sudakov = selected->weightTree(trial, asME, aemME, maxScale,
selected->clusterIn.pT(), asFSR, asISR, aemFSR, aemISR, asWeight,
aemWeight, pdfWeight);
// MPI no-emission probability.
int njetsMaxMPI = mergingHooksPtr->nMinMPI()+1;
vector<double> mpiwt = selected->weightTreeEmissions( trial, -1, 0,
njetsMaxMPI, maxScale );
// Set hard process renormalisation scale to default Pythia value.
bool resetScales = mergingHooksPtr->resetHardQRen();
// For pure QCD dijet events, evaluate the coupling of the hard process at
// a more reasonable pT, rather than evaluation \alpha_s at a fixed
// arbitrary scale.
if ( resetScales
&& mergingHooksPtr->getProcessString().compare("pp>jj") == 0) {
// Reset to a running coupling. Here we choose FSR for simplicity.
double newQ2Ren = pow2( selected->hardRenScale(selected->state) );
double runningCoupling = (*asFSR).alphaS(newQ2Ren) / asME;
for (double& asW: asWeight) asW *= pow(runningCoupling,2);
}
// For prompt photon events, evaluate the coupling of the hard process at
// a more reasonable pT, rather than evaluation \alpha_s at a fixed
// arbitrary scale.
if ( resetScales
&& mergingHooksPtr->getProcessString().compare("pp>aj") == 0) {
// Reset to a running coupling. In prompt photon always ISR.
double newQ2Ren = pow2( selected->hardRenScale(selected->state) );
double runningCoupling =
(*asISR).alphaS( newQ2Ren + pow(mergingHooksPtr->pT0ISR(),2) ) / asME;
for (double& asW: asWeight) asW *= runningCoupling;
}
// Done
vector<double> ret;
for (int iVar = 0; iVar < nWgts; ++iVar)
ret.push_back(sudakov[iVar]*asWeight[iVar]*aemWeight[iVar]*pdfWeight[iVar]*
mpiwt[iVar]);
return ret;
}
//--------------------------------------------------------------------------
vector<double> History::weightUNLOPSTree(PartonLevel* trial, AlphaStrong*
asFSR, AlphaStrong* asISR, AlphaEM * aemFSR, AlphaEM * aemISR, double RN,
int depthIn) {
if ( mergingHooksPtr->canCutOnRecState() && !foundAllowedPath ) {
loggerPtr->WARNING_MSG(
"no allowed history found. Using disallowed history");
}
if ( mergingHooksPtr->orderHistories() && !foundOrderedPath ) {
loggerPtr->WARNING_MSG(
"no ordered history found. Using unordered history");
}
if ( mergingHooksPtr->canCutOnRecState()
&& mergingHooksPtr->orderHistories()
&& !foundAllowedPath && !foundOrderedPath ) {
loggerPtr->WARNING_MSG("no allowed or ordered history found");
}
// Read alpha_S in ME calculation and maximal scale (eCM)
double asME = infoPtr->alphaS();
double aemME = infoPtr->alphaEM();
double maxScale = (foundCompletePath) ? infoPtr->eCM()
: mergingHooksPtr->muFinME();
// Select a path of clusterings
History * selected = select(RN);
// Set scales in the states to the scales pythia would have set
selected->setScalesInHistory();
// Get weight.
int nWgts = mergingHooksPtr->nWgts;
vector<double> asWeight( nWgts, 1. );
vector<double> aemWeight( nWgts, 1. );
vector<double> pdfWeight( nWgts, 1. );
// Do trial shower, calculation of alpha_S ratios, PDF ratios
vector<double> wt( nWgts, 1.);
if (depthIn < 0) wt = selected->weightTree(trial, asME, aemME, maxScale,
selected->clusterIn.pT(), asFSR, asISR, aemFSR, aemISR, asWeight,
aemWeight, pdfWeight);
else {
wt = selected->weightTreeEmissions( trial, 1, 0, depthIn, maxScale );
if (wt[0] != 0.) {
asWeight = selected->weightTreeAlphaS( asME, asFSR, asISR, depthIn);
aemWeight = selected->weightTreeAlphaEM( aemME, aemFSR, aemISR, depthIn);
pdfWeight = selected->weightTreePDFs( maxScale,
selected->clusterIn.pT(), depthIn);
}
}
// MPI no-emission probability.
int njetsMaxMPI = mergingHooksPtr->nMinMPI();
vector<double> mpiwt = selected->weightTreeEmissions( trial, -1, 0,
njetsMaxMPI, maxScale );
// Set hard process renormalisation scale to default Pythia value.
bool resetScales = mergingHooksPtr->resetHardQRen();
// For pure QCD dijet events, evaluate the coupling of the hard process at
// a more reasonable pT, rather than evaluation \alpha_s at a fixed
// arbitrary scale.
if ( resetScales
&& mergingHooksPtr->getProcessString().compare("pp>jj") == 0) {
// Reset to a running coupling. Here we choose FSR for simplicity.
double newQ2Ren = pow2( selected->hardRenScale(selected->state) );
double runningCoupling = (*asFSR).alphaS(newQ2Ren) / asME;
for (double& asW: asWeight) asW *= pow(runningCoupling,2);
}
// For prompt photon events, evaluate the coupling of the hard process at
// a more reasonable pT, rather than evaluation \alpha_s at a fixed
// arbitrary scale.
if ( resetScales
&& mergingHooksPtr->getProcessString().compare("pp>aj") == 0) {
// Reset to a running coupling. In prompt photon always ISR.
double newQ2Ren = pow2( selected->hardRenScale(selected->state) );
double runningCoupling =
(*asISR).alphaS( newQ2Ren + pow(mergingHooksPtr->pT0ISR(),2) ) / asME;
for (double& asW: asWeight) asW *= runningCoupling;
}
// Done
vector<double> ret;
for (int iVar = 0; iVar < nWgts; ++iVar)
ret.push_back(wt[iVar]*asWeight[iVar]*aemWeight[iVar]*pdfWeight[iVar]*
mpiwt[iVar]);
// For tree level, undo as variation applied to ME component to avoid double
// ratios when combining later.
int nSteps = mergingHooksPtr->getNumberOfClusteringSteps(state);
double muR = mergingHooksPtr->muRinME();
for (int iVar = 1; iVar < nWgts; ++iVar)
asWeight[iVar] *= std::pow((*asFSR).alphaS(muR*muR) /
(*asFSR).alphaS(pow2(muR*mergingHooksPtr->muRVarFactors[iVar-1])),
nSteps);
// Save weight vectors internally for UNLOPS-P and -PC
mergingHooksPtr->individualWeights.wtSave = wt;
mergingHooksPtr->individualWeights.asWeightSave = asWeight;
mergingHooksPtr->individualWeights.aemWeightSave = aemWeight;
mergingHooksPtr->individualWeights.pdfWeightSave = pdfWeight;
mergingHooksPtr->individualWeights.mpiWeightSave = mpiwt;
return ret;
}
//--------------------------------------------------------------------------
vector<double> History::weightUNLOPSLoop(PartonLevel* trial, AlphaStrong*
asFSR, AlphaStrong* asISR, AlphaEM * aemFSR, AlphaEM * aemISR, double RN,
int depthIn) {
// No difference to default NL3
if (depthIn < 0) return weightNL3Loop(trial, RN);
// Read alpha_S in ME calculation and maximal scale (eCM)
double asME = infoPtr->alphaS();
double aemME = infoPtr->alphaEM();
double maxScale = (foundCompletePath) ? infoPtr->eCM() :
mergingHooksPtr->muFinME();
// Select a path of clusterings
History * selected = select(RN);
// Set scales in the status to the scales pythia would have set
selected->setScalesInHistory();
// Get weight.
int nWgts = mergingHooksPtr->nWgts;
vector<double> wt( nWgts, 1.);
vector<double> asWeight( nWgts, 1.);
vector<double> aemWeight( nWgts, 1.);
vector<double> pdfWeight( nWgts, 1.);
// Do trial shower, calculation of alpha_S ratios, PDF ratios.
wt = selected->weightTreeEmissions( trial, 1, 0, depthIn, maxScale );
if (wt[0] != 0.) {
asWeight = selected->weightTreeAlphaS( asME, asFSR, asISR, depthIn,
true);
aemWeight = selected->weightTreeAlphaEM( aemME, aemFSR, aemISR, depthIn);
pdfWeight = selected->weightTreePDFs( maxScale,
selected->clusterIn.pT(), depthIn);
}
// MPI no-emission probability.
int njetsMaxMPI = mergingHooksPtr->nMinMPI();
vector<double> mpiwt = selected->weightTreeEmissions( trial, -1, 0,
njetsMaxMPI, maxScale );
// Set hard process renormalisation scale to default Pythia value.
bool resetScales = mergingHooksPtr->resetHardQRen();
// For pure QCD dijet events, evaluate the coupling of the hard process at
// a more reasonable pT, rather than evaluation \alpha_s at a fixed
// arbitrary scale.
if ( resetScales
&& mergingHooksPtr->getProcessString().compare("pp>jj") == 0) {
// Reset to a running coupling. Here we choose FSR for simplicity.
double newQ2Ren = pow2( selected->hardRenScale(selected->state) );
double runningCoupling = (*asFSR).alphaS(newQ2Ren) / asME;
for (double& asW: asWeight) asW *= pow(runningCoupling,2);
}
// For prompt photon events, evaluate the coupling of the hard process at
// a more reasonable pT, rather than evaluation \alpha_s at a fixed
// arbitrary scale.
if ( resetScales
&& mergingHooksPtr->getProcessString().compare("pp>aj") == 0) {
// Reset to a running coupling. In prompt photon always ISR.
double newQ2Ren = pow2( selected->hardRenScale(selected->state) );
double runningCoupling =
(*asISR).alphaS( newQ2Ren + pow(mergingHooksPtr->pT0ISR(),2) ) / asME;
for (double& asW: asWeight) asW *= runningCoupling;
}
// Done
vector<double> ret;
for (int iVar = 0; iVar < nWgts; ++iVar)
ret.push_back(wt[iVar]*asWeight[iVar]*aemWeight[iVar]*pdfWeight[iVar]*
mpiwt[iVar]);
// Save weight vectors interally for UNLOPS-P and -PC
mergingHooksPtr->individualWeights.wtSave = wt;
mergingHooksPtr->individualWeights.asWeightSave = asWeight;
mergingHooksPtr->individualWeights.aemWeightSave = aemWeight;
mergingHooksPtr->individualWeights.pdfWeightSave = pdfWeight;
mergingHooksPtr->individualWeights.mpiWeightSave = mpiwt;
return ret;
}
//--------------------------------------------------------------------------
vector<double> History::weightUNLOPSSubt(PartonLevel* trial, AlphaStrong*
asFSR, AlphaStrong* asISR, AlphaEM * aemFSR, AlphaEM * aemISR, double RN,
int depthIn) {
// Select a path of clusterings
History* selected = select(RN);
// Set scales in the states to the scales pythia would have set
selected->setScalesInHistory();
// Read alpha_S in ME calculation and maximal scale (eCM)
double asME = infoPtr->alphaS();
double aemME = infoPtr->alphaEM();
double maxScale = (foundCompletePath)
? infoPtr->eCM()
: mergingHooksPtr->muFinME();
int nWgts = mergingHooksPtr->nWgts;
// Only allow two clusterings if all intermediate states above the
// merging scale.
int nSteps = mergingHooksPtr->getNumberOfClusteringSteps(state);
if ( nSteps == 2 && mergingHooksPtr->nRecluster() == 2
&& ( !foundCompletePath
|| !selected->allIntermediateAboveRhoMS( mergingHooksPtr->tms() )) )
return vector<double>( nWgts, 0. );
// Get weights: alpha_S ratios and PDF ratios
vector<double> asWeight( nWgts, 1.);
vector<double> aemWeight( nWgts, 1.);
vector<double> pdfWeight( nWgts, 1.);
// Do trial shower, calculation of alpha_S ratios, PDF ratios
vector<double> wt( nWgts, 1.);
if (depthIn < 0)
wt = selected->weightTree(trial, asME, aemME, maxScale,
selected->clusterIn.pT(), asFSR, asISR, aemFSR, aemISR, asWeight,
aemWeight, pdfWeight);
else {
wt = selected->weightTreeEmissions( trial, 1, 0, depthIn, maxScale );
if (wt[0] > 0.) {
asWeight = selected->weightTreeAlphaS( asME, asFSR, asISR, depthIn);
aemWeight = selected->weightTreeAlphaEM( aemME, aemFSR, aemISR, depthIn);
pdfWeight = selected->weightTreePDFs( maxScale,
selected->clusterIn.pT(), depthIn);
}
}
// MPI no-emission probability.
int njetsMaxMPI = mergingHooksPtr->nMinMPI()+1;
vector<double> mpiwt = selected->weightTreeEmissions( trial, -1, 0,
njetsMaxMPI, maxScale );
// Set weight
vector<double> ret;
if (mergingHooksPtr->nRecluster() == 2 )
ret = wt = asWeight = aemWeight = pdfWeight = mpiwt =
vector<double>( nWgts, 1. );
else {
for (int iVar = 0; iVar < nWgts; ++iVar)
ret.push_back(asWeight[iVar]*aemWeight[iVar]*pdfWeight[iVar]*
wt[iVar]*mpiwt[iVar]);
}
// For tree level, undo as variation applied to ME component to avoid double
// ratios when combining later.
double muR = mergingHooksPtr->muRinME();
for (int iVar = 1; iVar < nWgts; ++iVar)
asWeight[iVar] *= std::pow((*asFSR).alphaS(muR*muR) /
(*asFSR).alphaS(pow2(muR*mergingHooksPtr->muRVarFactors[iVar-1])),
nSteps);
// Save weight vectors interally for UNLOPS-P and -PC
mergingHooksPtr->individualWeights.wtSave = wt;
mergingHooksPtr->individualWeights.asWeightSave = asWeight;
mergingHooksPtr->individualWeights.aemWeightSave = aemWeight;
mergingHooksPtr->individualWeights.pdfWeightSave = pdfWeight;
mergingHooksPtr->individualWeights.mpiWeightSave = mpiwt;
// Done
return ret;
}
//--------------------------------------------------------------------------
vector<double> History::weightUNLOPSSubtNLO(PartonLevel* trial, AlphaStrong*
asFSR, AlphaStrong* asISR, AlphaEM * aemFSR, AlphaEM * aemISR, double RN,
int depthIn) {
// So far, no reweighting
int nWgts = mergingHooksPtr->nWgts;
vector<double> wt( nWgts, 1. );
if (depthIn < 0) {
// Select a path of clusterings
History * selected = select(RN);
// Set scales in the states to the scales pythia would have set
selected->setScalesInHistory();
// Only reweighting with MPI no-emission probability
double maxScale = (foundCompletePath) ? infoPtr->eCM()
: mergingHooksPtr->muFinME();
int njetsMaxMPI = mergingHooksPtr->nMinMPI()+1;
vector<double> mpiwt = selected->weightTreeEmissions
( trial, -1, 0, njetsMaxMPI, maxScale );
wt = mpiwt;
// Done
return wt;
}
// Select a path of clusterings
History* selected = select(RN);
// Set scales in the states to the scales pythia would have set
selected->setScalesInHistory();
// Read alpha_S in ME calculation and maximal scale (eCM)
double asME = infoPtr->alphaS();
double aemME = infoPtr->alphaEM();
double maxScale = (foundCompletePath)
? infoPtr->eCM()
: mergingHooksPtr->muFinME();
// Only allow two clusterings if all intermediate states above the
// merging scale.
double nSteps = mergingHooksPtr->getNumberOfClusteringSteps(state);
if ( nSteps == 2 && mergingHooksPtr->nRecluster() == 2
&& ( !foundCompletePath
|| !selected->allIntermediateAboveRhoMS( mergingHooksPtr->tms() )) )
return vector<double>( nWgts, 0. );
// Get weights: alpha_S ratios and PDF ratios
vector<double> asWeight( nWgts, 1.);
vector<double> aemWeight( nWgts, 1.);
vector<double> pdfWeight( nWgts, 1.);
// Do trial shower, calculation of alpha_S ratios, PDF ratios
wt = selected->weightTreeEmissions( trial, 1, 0, depthIn, maxScale );
if (wt[0] > 0.) {
asWeight = selected->weightTreeAlphaS( asME, asFSR, asISR, depthIn,
true);
aemWeight = selected->weightTreeAlphaEM( aemME, aemFSR, aemISR, depthIn);
pdfWeight = selected->weightTreePDFs( maxScale,
selected->clusterIn.pT(), depthIn);
}
// MPI no-emission probability.
int njetsMaxMPI = mergingHooksPtr->nMinMPI()+1;
vector<double> mpiwt = selected->weightTreeEmissions( trial, -1, 0,
njetsMaxMPI, maxScale );
// Set weight
vector<double> ret;
if (mergingHooksPtr->nRecluster() == 2 )
ret = wt = asWeight = aemWeight = pdfWeight = mpiwt =
vector<double>( nWgts, 1. );
else {
for (int iVar = 0; iVar < nWgts; ++iVar)
ret.push_back(asWeight[iVar]*aemWeight[iVar]*pdfWeight[iVar]*
wt[iVar]*mpiwt[iVar]);
}
// Save weight vectors interally for UNLOPS-P and -PC
mergingHooksPtr->individualWeights.wtSave = wt;
mergingHooksPtr->individualWeights.asWeightSave = asWeight;
mergingHooksPtr->individualWeights.aemWeightSave = aemWeight;
mergingHooksPtr->individualWeights.pdfWeightSave = pdfWeight;
mergingHooksPtr->individualWeights.mpiWeightSave = mpiwt;
// Done
return ret;
}
//--------------------------------------------------------------------------
// Function to calculate O(\alpha_s)-term of CKKWL-weight for NLO merging
vector<double> History::weightUNLOPSFirst( int order, PartonLevel*
trial, AlphaStrong* asFSR, AlphaStrong* asISR, AlphaEM*, AlphaEM*,
double RN, Rndm* rndmPtr ) {
int nWgts = mergingHooksPtr->nWgts;
// Already done if no correction should be calculated
if ( order < 0 ) return vector<double>( nWgts, 0. );
// Read alpha_S in ME calculation and maximal scale (eCM)
double asME = infoPtr->alphaS();
//double aemME = infoPtr->alphaEM();
double muR = mergingHooksPtr->muRinME();
double maxScale = (foundCompletePath)
? infoPtr->eCM()
: mergingHooksPtr->muFinME();
// Pick path of clusterings
History * selected = select(RN);
// Set scales in the states to the scales pythia would have set
selected->setScalesInHistory();
double nSteps = mergingHooksPtr->getNumberOfClusteringSteps(state);
// Get the lowest order k-factor and add first two terms in expansion
double kFactor = asME * mergingHooksPtr->k1Factor(nSteps);
// If using Bbar, which includes a tree-level part, subtract an
// additional one, i.e. the O(\as^0) contribution as well
double wt = 1;
// Set up vector for order == 0 case.
vector<double> wtVec(nWgts, wt);
if (order > 0) {
// Start by adding the O(\alpha_s^1)-term of the k-factor.
if ( mergingHooksPtr->orderHistories() && foundOrderedPath )
wt += kFactor;