StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
VinciaFSR.h
1 // VinciaFSR.h is a part of the PYTHIA event generator.
2 // Copyright (C) 2020 Peter Skands, Torbjorn Sjostrand.
3 // PYTHIA is licenced under the GNU GPL v2 or later, see COPYING for details.
4 // Please respect the MCnet Guidelines, see GUIDELINES for details.
5 
6 // This file contains header information for the VinciaFSR class for
7 // QCD final-state antenna showers, and auxiliary classes.
8 
9 #ifndef Pythia8_VinciaFSR_H
10 #define Pythia8_VinciaFSR_H
11 
12 #include "Pythia8/TimeShower.h"
13 #include "Pythia8/VinciaAntennaFunctions.h"
14 #include "Pythia8/VinciaCommon.h"
15 #include "Pythia8/VinciaISR.h"
16 #include "Pythia8/VinciaQED.h"
17 #include "Pythia8/VinciaWeights.h"
18 #include "Pythia8/VinciaDiagnostics.h"
19 
20 namespace Pythia8 {
21 
22 // Forward declarations.
23 class VinciaISR;
24 class ResScaleHook;
25 
26 //==========================================================================
27 
28 // UserHooks that are used to set the scale in resonance decays.
29 
30 class ResScaleHook : public UserHooks {
31 public:
32 
33  // Constructor.
34  ResScaleHook() {;}
35 
36  // Destructors.
37  virtual ~ResScaleHook() {;}
38 
39  // Start resonance showers at a scale of m.
40  bool canSetResonanceScale() {return true;}
41  virtual double scaleResonance(int iRes, const Event& event) {
42  return event[iRes].m();}
43 
44 };
45 
46 //==========================================================================
47 
48 // Helper struct for passing trial-alphaS information to Brancher
49 // class. Vectors of evolutionWindow could be encapsulated in a
50 // class, containing only a single instance of Rndm.
51 
53 
54  int runMode;
55  double alphaSmax, b0, kMu2, lambda2, qMin;
56  map<int, double> mass;
57 
58 };
59 
60 //==========================================================================
61 
62 // Helper struct to store information about junctions that involved
63 // resonances that have now decayed.
64 
66 
67  // Number of junction in event record.
68  int iJunction;
69  // Which of the three ends of iJunction are we talking about.
70  int iEndCol;
71  // What is the colour tag of iEndCol in iJunctions.
72  int iEndColTag;
73  // Pythia index of quark that should be on the end. Specifically it
74  // should be the quark from the decay of the resonance.
75  int iEndQuark;
76  // iEndColTag and iEnd Quark will get updated as the quark radiates.
77  // Cector of colours lines between res and end quark, needed in
78  // order to track if a gluon in chain splits to find correct
79  // junction end.
80  vector<int> colours;
81 
82 };
83 
84 //==========================================================================
85 
86 // The Brancher class, base class containing a generic set of "parent
87 // partons" as well as virtual methods for generating trial
88 // branchings.
89 
90 class Brancher {
91 
92 public:
93 
94  // Default constructor.
95  Brancher() : hasTrialSav(false), swapped(false) {;}
96 
97  // Create branch elemental for antenna(e) with arbitrary parents in iIn.
98  Brancher(int iSysIn, Event& event, vector<int> iIn) {
99  reset(iSysIn, event, iIn);}
100 
101  // Wrapper for simple 2- (or 3-) parton antennae.
102  Brancher(int iSysIn, Event& event, int i0In, int i1In, int i2In = 0) {
103  vector<int> iIn {i0In, i1In}; if (i2In >= 1) iIn.push_back(i2In);
104  reset(iSysIn,event,iIn);}
105 
106  // Destructor.
107  virtual ~Brancher() {;}
108 
109  // Reset (common functionality implemented in base class).
110  virtual void reset(int iSysIn, Event& event, vector<int> iIn);
111 
112  // Wrapper for simple 2- (or 3-) parton antennae.
113  void reset(int iSysIn, Event& event, int i0In, int i1In, int i2In = 0) {
114  vector<int> iIn {i0In, i1In}; if (i2In >= 1) iIn.push_back(i2In);
115  reset(iSysIn,event,iIn);}
116 
117  // Methods to get (explicit for up to 3 parents, otherwise just use iVec).
118  int i0() const {return (iSav.size() >= 1) ? iSav[0] : -1;}
119  int i1() const {return (iSav.size() >= 2) ? iSav[1] : -1;}
120  int i2() const {return (iSav.size() >= 3) ? iSav[2] : -1;}
121  int iVec(unsigned int i) const {return (iSav.size() > i) ? iSav[i] : -1;}
122  vector<int> iVec() {return iSav;}
123  int id0() const {return (idSav.size() >= 1) ? idSav[0] : -1;}
124  int id1() const {return (idSav.size() >= 2) ? idSav[1] : -1;}
125  int id2() const {return (idSav.size() >= 3) ? idSav[2] : -1;}
126  vector<int> idVec() const {return idSav;}
127  int colType0() const {return (colTypeSav.size() >= 1) ? colTypeSav[0] : -1;}
128  int colType1() const {return (colTypeSav.size() >= 2) ? colTypeSav[1] : -1;}
129  int colType2() const {return (colTypeSav.size() >= 3) ? colTypeSav[2] : -1;}
130  vector<int> colTypeVec() const {return colTypeSav;}
131  int col0() const {return (colSav.size() >= 1) ? colSav[0] : 0;}
132  int col1() const {return (colSav.size() >= 2) ? colSav[1] : 0;}
133  int col2() const {return (colSav.size() >= 3) ? colSav[2] : 0;}
134  vector<int> colVec() const {return colSav;}
135  int acol0() const {return (acolSav.size() >= 1) ? acolSav[0] : 0;}
136  int acol1() const {return (acolSav.size() >= 2) ? acolSav[1] : 0;}
137  int acol2() const {return (acolSav.size() >= 3) ? acolSav[2] : 0;}
138  vector<int> acolVec() const {return acolSav;}
139  int h0() const {return (hSav.size() >= 1) ? hSav[0] : -1;}
140  int h1() const {return (hSav.size() >= 2) ? hSav[1] : -1;}
141  int h2() const {return (hSav.size() >= 3) ? hSav[2] : -1;}
142  vector<int> hVec() const {return hSav;}
143  double m0() const {return (mSav.size() >= 1) ? mSav[0] : -1;}
144  double m1() const {return (mSav.size() >= 2) ? mSav[1] : -1;}
145  double m2() const {return (mSav.size() >= 3) ? mSav[2] : -1;}
146  vector<double> mVec() const {return mSav;}
147  vector<double> getmPostVec() {return mPostSav;}
148  int colTag() {return colTagSav;}
149 
150  // Method to get maximum value of evolution scale for this brancher.
151  // Must be redefined in base classes.
152  virtual double getQ2Max(int) = 0;
153 
154  // Methods to return saved/derived quantities.
155  int system() const {return systemSav;}
156  double mAnt() const {return mAntSav;}
157  double m2Ant() const {return m2AntSav;}
158  double sAnt() const {return sAntSav;}
159  double kallenFac() const {return kallenFacSav;}
160  double enhanceFac() const {return enhanceSav;}
161  double q2Trial() const {return q2NewSav;}
162  int iAntPhys() const {return iAntSav;}
163 
164  // Init (for functionality specific to derived classes).
165  virtual void init() = 0;
166 
167  // Generate a new Q2 scale.
168  virtual double genQ2(int evTypeIn, double Q2MaxNow, Rndm* rndmPtr,
169  const EvolutionWindow* evWindowPtrIn, double colFac,
170  vector<double> headroomIn, vector<double> enhanceFacIn,
171  int verboseIn) = 0;
172 
173  // Generate complementary invariant(s) for saved trial. Return false
174  // if no physical kinematics possible. Base class returns false.
175  virtual bool genInvariants(vector<double>& invariants, Rndm*, int) {
176  invariants.clear(); return false;}
177 
178  // Compute antPhys/antTrial, given an input value for antPhys. Base
179  // class returns 0.
180  virtual double pAccept(const double, int = 0) {return 0.;}
181 
182  // Compute pT scale of trial branching.
183  virtual double getpTscale();
184 
185  // Return Xj.
186  virtual double getXj();
187 
188  // What kind of particle(s) are being created, e.g. return 21 for
189  // gluon emission, quark flavour for splitting, etc.
190  virtual int idNew() const {return 0;}
191  virtual double mNew() const {return 0.0;}
192 
193  // Return new particles, must be implemented by derived class.
194  virtual bool getNewParticles(Event& event, vector<Vec4> momIn,
195  vector<int> hIn, vector<Particle> &pNew,Rndm* rndmPtr,
196  Colour* colourPtr) = 0;
197 
198  // Simple print utility, showing the contents of the Brancher. Base
199  // class implementation allows for up to three explicit parents.
200  virtual void list(string header="none") const;
201 
202  // Set post-branching IDs and masses. Base class is for gluon emission.
203  virtual void setidPost();
204  virtual vector<double> setmPostVec();
205  virtual void setStatPost();
206  virtual void setMaps(int);
207 
208  // Return index of new particle (slightly arbitrary choice for splittings).
209  virtual int iNew();
210 
211  // Method returns pos of resonance if there is one participating in
212  // decay, -1 otherwise.
213  virtual int posR() {return -1;}
214 
215  // Method returns pos of colour-connected daughter to resonance if
216  // there is one participating in decay, -1 otherwise.
217  virtual int posF() {return -1;}
218 
219  // Return branch type.
220  int getBranchType() {return branchType;}
221  // Check if swapped.
222  bool isSwapped() {return swapped;}
223  // Return the saved invariants.
224  vector<double> getInvariants() {return invariantsSav;}
225 
226  // This method allows to reset enhanceFac if we do an accept/reject.
227  void resetEnhanceFac(const double enhanceIn) {enhanceSav = enhanceIn;}
228 
229  // Method to see if a saved trial has been generated, and to erase
230  // memory of it.
231  bool hasTrial() const {return hasTrialSav;}
232  // Method to mark new trial needed *without* erasing current one.
233  void needsNewTrial() {hasTrialSav = false;}
234  // Method to mark new trial needed *and* erase current one.
235  void eraseTrial() {hasTrialSav = false; q2NewSav = 0.;}
236 
237  // Publicly accessible members for storing mother/daughter connections.
238  map<int, pair<int, int> > mothers2daughters;
239  map<int, pair<int, int> > daughters2mothers;
240 
241 protected:
242 
243  // Data members for storing information about parent partons.
244  int systemSav;
245  vector<int> iSav, idSav, colTypeSav, hSav, colSav, acolSav;
246  vector<int> idPostSav, statPostSav;
247  vector<double> mSav, mPostSav;
248  int colTagSav, evTypeSav;
249 
250  // All alphaS information.
251  const EvolutionWindow* evWindowSav;
252 
253  // Saved antenna mass parameters.
254  double mAntSav, m2AntSav, kallenFacSav, sAntSav;
255 
256  // Data members for storing information about generated trial branching.
257  bool hasTrialSav;
258  double headroomSav, enhanceSav, q2BegSav, q2NewSav;
259  vector<double> invariantsSav;
260 
261  // Find out which branching type we are doing.
262  // 1: QCD emission
263  // 2: QCD splitting
264  // 3: QED emission
265  // 4: QED splitting
266  // 5: QCD resonance emission
267  int branchType;
268 
269  // Indices of FF antenna functions.
270  // 0: iQQemitFF
271  // 1: iQGemitFF
272  // 2: iGQemitFF
273  // 3: iGGemitFF
274  // 4: iGXsplitFF
275  // 5: iQQemitRF
276  // 6: iQGemitRF
277  // 7: iXGsplitRF
278  int iAntSav;
279 
280  // If true, flip identities of A and B.
281  bool swapped;
282 
283 };
284 
285 //==========================================================================
286 
287 // Class BrancherEmitFF, branch elemental for 2->3 gluon emissions.
288 
289 class BrancherEmitFF : public Brancher {
290 
291 public:
292 
293  // Create branch elemental for antenna(e) with parents in iIn.
294  BrancherEmitFF(int iSysIn, Event& event, vector<int> iIn) {
295  reset(iSysIn, event, iIn);}
296 
297  // Wrapper to provide simple 2-parton systems as parents.
298  BrancherEmitFF(int iSysIn, Event& event, int i0In, int i1In) {
299  reset(iSysIn, event, i0In, i1In);}
300 
301  // Destructor.
302  virtual ~BrancherEmitFF() {;}
303 
304  // Method to initialise members specific to BrancherEmitFF.
305  virtual void init();
306 
307  // Generate a new Q2 value, soft-eikonal 2/yij/yjk implementation.
308  double genQ2(int evTypeIn, double Q2MaxNow, Rndm* rndmPtr,
309  const EvolutionWindow* evWindowPtrIn, double colFac,
310  vector<double> headroomIn, vector<double> enhanceFacIn,int verboseIn);
311 
312  // Generate invariants. Method to generate complementary
313  // invariant(s) for saved trial scale for gluon emission. Return
314  // false if no physical kinematics possible.
315  virtual bool genInvariants(vector<double>& invariants, Rndm* rndmPtr,
316  int verboseIn);
317 
318  // Compute antPhys/antTrial for gluon emissions, given
319  // antPhys. Note, antPhys should be normalised to include charge and
320  // coupling factors.
321  virtual double pAccept(const double antPhys, int = 0);
322 
323  // Return the maximum Q2.
324  double getQ2Max(int evType);
325 
326  // Method to make mothers2daughters and daughters2mothers pairs.
327  virtual void setMaps(int sizeOld);
328 
329  // Flavour and mass of emitted particle
330  virtual int idNew() const {return 21;}
331  virtual double mNew() const {return 0.0;}
332 
333  // Generic getter method. Assumes setter methods called earlier.
334  virtual bool getNewParticles(Event& event, vector<Vec4> momIn,
335  vector<int> hIn, vector<Particle> &pNew,Rndm* rndmPtr,Colour* colourPtr);
336 
337 private:
338 
339  // Data members to store information about generated trials.
340  double colFacSav{};
341 
342 };
343 
344 //==========================================================================
345 
346 // Class BrancherSplitFF, branch elemental for 2->3 gluon splittings.
347 
348 class BrancherSplitFF : public Brancher {
349 
350 public:
351 
352  // Create branch elemental for antenna(e) with parents in iIn.
353  BrancherSplitFF(int iSysIn, Event& event, vector<int> iIn) {
354  reset(iSysIn, event, iIn);}
355 
356  // Wrapper to provide simple 2-parton systems as parents. Set if it
357  // is the anticolour or colour side of the gluon that participates
358  // in the antenna (used to decide pTj or pTi measure).
359  BrancherSplitFF(int iSysIn, Event& event, int i0In, int i1In,
360  bool col2acol) { reset(iSysIn, event, i0In, i1In); isXGsav = !col2acol; }
361 
362  // Destructor.
363  virtual ~BrancherSplitFF() {;}
364 
365  // Method to initialise data members specific to BrancherSplitFF.
366  virtual void init();
367 
368  // Method to check if this antenna corresponds to splitting off the
369  // colour (true) or anticolour side (false) of the parent gluon.
370  virtual bool isXG() const {return isXGsav;}
371 
372  // Flavour and mass of emitted particle.
373  virtual int idNew() const {return idFlavSav;}
374  virtual double mNew() const {return mFlavSav;}
375 
376  // Generate a new Q2 scale (collinear 1/(2q2) implementation) with
377  // constant trial alphaS.
378  double genQ2(int evTypeIn, double Q2MaxNow, Rndm* rndmPtr,
379  const EvolutionWindow* evWindowPtrIn, double colFac,
380  vector<double> headroomIn, vector<double> enhanceFacIn,int verboseIn);
381 
382  // Generate complementary invariant(s) for saved trial scale for
383  // gluon splitting. Return false if no physical kinematics possible.
384  virtual bool genInvariants(vector<double>& invariants, Rndm* rnmdPtr,
385  int verboseIn);
386 
387  // Compute antPhys/antTrial for gluon splittings, given antPhys.
388  // Note, antPhys should be normalised to include charge and coupling
389  // factors.
390  virtual double pAccept(const double antPhys, int);
391 
392  // Getter and setter methods.
393  double getQ2Max(int evType);
394  virtual vector<double> setmPostVec();
395  virtual void setidPost();
396  virtual void setStatPost();
397  virtual void setMaps(int sizeOld);
398 
399  // Generic getter method. Assumes setter methods called earlier.
400  virtual bool getNewParticles(Event& event, vector<Vec4> momIn,
401  vector<int> hIn, vector<Particle> &pNew, Rndm*, Colour*);
402 
403  private:
404 
405  // Data members for storing information on generated trials.
406  int idFlavSav{};
407  double mFlavSav{};
408 
409  // Data member to store whether this is really an XG antenna or a GX
410  // one, i.e. if it is the anticolour or colour side of the gluon
411  // which is participating in the LC antenna. In the former case, we
412  // use pT(qbar) = pTj as the measure, in the latter pT(q) = pTi.
413  bool isXGsav{};
414 
415 };
416 
417 //==========================================================================
418 
419 // BrancherEmitRF class for storing information on antennae between a
420 // coloured resonance and final state parton, and generating a new
421 // emission.
422 
423 class BrancherEmitRF : public Brancher {
424 
425 public:
426 
427  // Constructor.
428  BrancherEmitRF() = default;
429 
430  // Constructor.
431  BrancherEmitRF(int iSysIn, Event& event, vector<int> allIn,
432  unsigned int posResIn, unsigned int posFIn, double Q2cut) {
433  reset(iSysIn, event, allIn); init(event, allIn, posResIn, posFIn, Q2cut);}
434 
435  // Destructor.
436  ~BrancherEmitRF() {;}
437 
438  // Reset the brancher.
439  void resetResBrancher(int iSysIn, Event& event, vector<int> allIn,
440  unsigned int posResIn, unsigned int posFIn, double Q2cut) {
441  reset(iSysIn, event, allIn); init(event,allIn,posResIn,posFIn,Q2cut);}
442 
443  // Overloaded version of init, does nothing.
444  void init() {;}
445 
446  // Method to initialise data members specific to BrancherEmitRF.
447  virtual void init(Event& event, vector<int> allIn, unsigned int posResIn,
448  unsigned int posFIn, double Q2cut);
449 
450  // Setter methods.
451  virtual vector<double> setmPostVec();
452  virtual void setidPost();
453  virtual void setStatPost();
454  virtual int iNew();
455  virtual void setMaps(int sizeOld);
456 
457  // Generic method, assumes setter methods called earlier.
458  virtual bool getNewParticles(Event& event, vector<Vec4> momIn,
459  vector<int> hIn, vector<Particle> &pNew, Rndm* rndmPtr, Colour*);
460 
461  // Return position of resonance.
462  int posR() {return int(posRes);}
463 
464  // Function returns position of colour-connected daughter to resonance.
465  int posF() {return int(posFinal);}
466 
467  // Return maximum Q2.
468  double getQ2Max(int evType) {return evType == 1 ? Q2MaxSav : 0.;}
469 
470  // Generate a new Q2 scale.
471  virtual double genQ2(int evTypeIn, double Q2MaxNow, Rndm* rndmPtr,
472  const EvolutionWindow* evWindowPtrIn, double colFac,
473  vector<double> headroomIn, vector<double> enhanceFacIn,
474  int verboseIn);
475 
476  // Generate complementary invariant(s) for saved trial scale. Return
477  // false if no physical kinematics possible.
478  virtual bool genInvariants(vector<double>& invariants,Rndm* rndmPtr,
479  int verboseIn);
480 
481  // Compute antPhys/antTrial, given antPhys. Note, antPhys should be
482  // normalised to include charge and coupling factors.
483  virtual double pAccept(const double,int);
484 
485 protected:
486 
487  // Protected helper methods for internal class use.
488  double KallenFunction(double x, double y, double z);
489  virtual double zetaIntSingleLim(double zetaLim);
490  double zetaIntegral(double zLow, double zHigh);
491  double getsAK(double mA, double mK, double mAK);
492  double zetaMinCalc(double mA, double mK, double mAK,double Q2cut);
493  double zetaMaxCalc(double mA, double mK, double mAK);
494  virtual double getZetaNext(Rndm* rndmPtr);
495  virtual double calcQ2Max(double mA, double mAK, double mK);
496 
497  // Veto point if outside available phase space.
498  bool vetoPhSpPoint(double saj, double sjk, double sak,int verboseIn);
499 
500  // Calculate maximum gluon energy in the centre of mass frame of res
501  // given cos theta.
502  double getEjMax(double cosTheta, double mA, double mAK, double mK);
503 
504  // Save reference to position in vectors of resonance and colour
505  // connected parton.
506  unsigned int posRes{}, posFinal{};
507  // Mass of resonance.
508  double mRes{};
509  // Mass of final state parton in antennae.
510  double mFinal{};
511  // Collective mass of rest of downstream decay products of resonance
512  // these will just take recoil.
513  double mRecoilers{};
514  double sAK{};
515  // Limits of zeta Integral.
516  double zetaMin{}, zetaMax{};
517  // Max Q2 for this brancher, still an overestimate.
518  double Q2MaxSav{};
519  // Integral of zeta over whole phase space.
520  double zetaIntSave{};
521  double colFacSav{};
522  // Store whether the colour flow is from R to F (e.g. t -> bW+) or F
523  // to R (e.g. tbar -> bbarW-).
524  bool colFlowRtoF{};
525  map<unsigned int,unsigned int> posNewtoOld{};
526 
527 };
528 
529 //==========================================================================
530 
531 // BrancherSplitRF class for storing information on antennae between a
532 // coloured resonance and final state parton, and generating a new
533 // emission.
534 
536 
537 public:
538 
539  // Constructor.
540  BrancherSplitRF(int iSysIn, Event& event, vector<int> allIn,
541  unsigned int posResIn, unsigned int posFIn, double Q2cut) {
542  reset(iSysIn, event, allIn); init(event,allIn,posResIn,posFIn,Q2cut);}
543 
544  // Destructor.
545  ~BrancherSplitRF(){;}
546 
547  // Overloaded version of init, does nothing.
548  void init() {;}
549 
550  // Method to initialise data members specific to BrancherSplitRF.
551  void init(Event& event, vector<int> allIn, unsigned int posResIn,
552  unsigned int posFIn, double Q2cut);
553 
554  // Setter methods.
555  vector<double> setmPostVec();
556  virtual void setidPost();
557  virtual void setStatPost();
558 
559  // Generic method, assumes setter methods called earlier.
560  virtual bool getNewParticles(Event& event, vector<Vec4> momIn,
561  vector<int> hIn, vector<Particle>& pNew, Rndm*, Colour*);
562 
563  // Generate a new Q2 scale.
564  double genQ2(int evTypeIn, double Q2MaxNow, Rndm* rndmPtr,
565  const EvolutionWindow* evWindowPtrIn, double colFac,
566  vector<double> headroomIn, vector<double> enhanceFacIn,
567  int verboseIn);
568 
569  // Generate complementary invariant(s) for saved trial scale. Return
570  // false if no physical kinematics possible.
571  bool genInvariants(vector<double>& invariants, Rndm* rndmPtr, int verboseIn);
572 
573  // Compute antPhys/antTrial, given antPhys. Note, antPhys should be
574  // normalised to include charge and coupling factors.
575  double pAccept(const double,int);
576 
577 protected:
578 
579  // Zeta integral for splitters is just flat.
580  virtual double getZetaNext(Rndm* rndmPtr) {
581  return zetaMin + rndmPtr->flat()*(zetaMax - zetaMin);}
582 
583  // Calculate for massless j (underestimate for zetamin).
584  double zetaMinCalc(double mA, double mK, double mAK,double Q2cut){
585  double sajMax = mA*mA -(mAK + mK)*(mAK + mK);
586  return Q2cut/sajMax + 1.- sajMax/sAK;}
587 
588  // Members.
589  int idFlavSav{};
590  double mFlavSav{};
591 
592 };
593 
594 //==========================================================================
595 
596 // The VinciaFSR class for resonant decays. Inherits from TimeShower
597 // in Pythia 8 so can be used as alternative to TimeShower.
598 // Methods that must replace ones in TimeShower are marked with override.
599 
600 class VinciaFSR : public TimeShower {
601 
602  // Allow VinciaISR to access private information.
603  friend class VinciaISR;
604 
605 public:
606 
607  // Constructor.
608  VinciaFSR() {verbose = 0; headerIsPrinted = false; isInit = false;
609  isPrepared = false; diagnosticsPtr = 0;}
610 
611  // Destructor.
612  ~VinciaFSR() {;}
613 
614  // The following methods control main flow of shower and are
615  // inherited from TimeShower. Any method re-implementing a
616  // TimeShower method is appended with (TimeShower).
617 
618  // Initialize alphaStrong and related pTmin parameters (TimeShower).
619  void init(BeamParticle* beamAPtrIn = 0, BeamParticle* beamBPtrIn = 0)
620  override;
621 
622  // Possible limitation of first emission (TimeShower, last two
623  // arguments purely dummy in Vincia implementation). Determines if
624  // max pT limit should be imposed on first emission. Note, not set
625  // up to handle Pythia's explicit DPS processes yet.
626  bool limitPTmax(Event& event, double Q2Fac = 0., double Q2Ren = 0.) override;
627 
628  // Top-level routine to do a full time-like shower in resonance
629  // decay (TimeShower).
630  int shower( int iBeg, int iEnd, Event& event, double pTmax,
631  int nBranchMax = 0) override;
632 
633  // Method to add QED showers in hadron decays (TimeShower).
634  int showerQED(int iBeg, int iEnd, Event& event, double pTmax) override;
635 
636  // Method to add QED showers to partons below colour resolution
637  // scale (TimeShower).
638  int showerQEDafterRemnants(Event& event) override;
639 
640  // Used for global recoil scheme (TimeShower, no Vincia implementation yet).
641  // void prepareGlobal(Event&);
642 
643  // Prepare system for evolution (TimeShower).
644  void prepare( int iSys, Event& event, bool limitPTmaxIn) override;
645 
646  // Update antenna list after a multiple interactions rescattering
647  // (TimeShower, no Vincia implementation yet).
648  // void rescatterUpdate( int iSys, Event& event);
649 
650  // Update antenna list after each ISR emission (TimeShower).
651  void update( int iSys, Event& event, bool hasWeakRad = false) override;
652 
653  // Select next pT in downwards evolution (TimeShower).
654  double pTnext( Event& event, double pTbegAll, double pTendAll,
655  bool isFirstTrial = false, bool doTrialIn = false) override;
656 
657  // Branch event, including accept/reject veto (TimeShower).
658  bool branch( Event& event, bool isInterleaved = false) override;
659 
660  // Utility to print antenna list; for debug mainly (TimeShower).
661  void list() const override;
662 
663  // Initialize data members for calculation of uncertainty bands
664  // (TimeShower, no Vincia implementation yet).
665  // virtual bool initUncertainties();
666 
667  // Tell whether FSR has done a weak emission (TimeShower, no Vincia
668  // implementation yet.)
669  // virtual bool getHasWeaklyRadiated() {return hasWeaklyRadiated;}
670 
671  // Tell which system was the last processed one (TimeShower).
672  int system() const override {return iSysWin;}
673 
674  // Potential enhancement factor of pTmax scale for hardest emission.
675  // Used if limitPTmax = true (TimeShower).
676  double enhancePTmax() override {return pTmaxFudge;}
677 
678  // Provide the pT scale of the last branching in the above shower
679  // (TimeShower).
680  double pTLastInShower() override {return pTLastAcceptedSav;}
681 
682  // The following methods for merging not yet implemented in Vincia:
683  // Event clustered()
684  // map<string, double> getStateVariables (const Event &, int, int, int,
685  // string)
686  // bool isTimelike()
687  // vector<string> getSplittingName()
688  // double getSplittingProb()
689  // bool allowedSplitting()
690  // vector<int> getRecoilers()
691  // The remaining public functions Vincia only, i.e. not inherited
692  // from Pythia 8.
693 
694  // Initialise pointers to Vincia objects.
695  void initVinciaPtrs(Colour* colourPtrIn, shared_ptr<VinciaISR> isrPtrIn,
696  QEDShower* qedPtrIn,MECs* mecsPtrIn,Resolution* resolutionPtrIn,
697  VinciaCommon* vinComPtrIn,VinciaWeights* vinWeightsPtrIn);
698 
699  // Initialize pointers to antenna sets.
700  void initAntPtr(AntennaSetFSR* antSetIn) {antSetPtr = antSetIn;}
701 
702  // Wrapper function to return a specific antenna inside an antenna set.
703  AntennaFunction* getAnt(int iAnt) {return antSetPtr->getAnt(iAnt);}
704  // Wrapper to return all iAntSav that are contained in antSetPtr.
705  vector<int> getIant() {return antSetPtr->getIant();}
706 
707  // Print header information (version, settings, parameters, etc.).
708  void header();
709 
710  // Print final statistics information.
711  void printInfo( bool pluginCall = false );
712 
713  // Print internal and diagnostic histrograms.
714  void printHistos();
715 
716  // Write internal and diagnostic histrograms to file.
717  void writeHistos(string fileName = "vincia", string suffix = "dat");
718 
719  // Get diagnostic histogram.
720  const Hist& getDiagnosticHistogram(string name) {return vinciaHistos[name];}
721  // Get number of systems.
722  int getNsys() {return nBranchFSR.size();}
723  // Get number of branchings in a system (return -1 if no such
724  // system). If iSys < 0, sum over all.
725  int getNbranch(int iSys = -1);
726  // Get scale of branchings; use (0,1) for first branching in 1st
727  // system. Could be extended so (i,0) would return starting scale
728  // for system i.
729  double getQbranch(int iSys, int iBranch) {
730  return (iSys < 4 && iSys >= 0 && iBranch <= 10 && iBranch >= 1) ?
731  qBranch[iSys][iBranch] : 0.;}
732  double getPTphys(int iSys, int iBranch) {
733  return (iSys < 4 && iSys >= 0 && iBranch <= 10 && iBranch >= 1) ?
734  pTphys[iSys][iBranch] : 0.;}
735  // Force quit from shower.
736  void doforceQuit(int nBranchQuitIn) {
737  allowforceQuit = true; nBranchQuit = nBranchQuitIn;}
738  // Set the diagnostics pointer.
739  void setDiagnostics(shared_ptr<VinciaDiagnostics> diagnosticsPtrIn) {
740  diagnosticsPtr = diagnosticsPtrIn;
741  if (diagnosticsPtr != nullptr) {
742  doDiagnostics = true;
743  if (verbose >= normal)
744  printOut(__METHOD_NAME__, "Diagnostics enabled...");
745  diagnosticsPtr->init();
746  } else {
747  doDiagnostics = false;
748  if (verbose >= normal)
749  printOut(__METHOD_NAME__, "Diagnostics disabled...");
750  }
751  }
752 
753  // Check event.
754  bool check(Event &event);
755 
756  // Set verbosity level.
757  void setVerbose(int verboseIn) {verbose = verboseIn;}
758 
759 private:
760 
761  // Initialize evolution windows.
762  void initEvolutionWindows(void);
763  // Return window Q2.
764  double getQ2Window(int iWindow, double q2cutoff);
765  // Return Lambda value.
766  double getLambda(int nFin, AlphaStrong* aSptr);
767  // Method to return renormalisation-scale prefactor.
768  double getkMu2(bool isEmit);
769  // Method to return renormalisation scale. Default scale is kMu *
770  // evolution scale.
771  double getMu2(bool isEmit);
772  // Reset (or clear) sizes of all containers.
773  void clearContainers();
774  // Method to set up antennae, called in prepare.
775  bool getAntennae(int iSys, Event& event);
776  // Set starting scale of shower (power vs wimpy) for system iSys.
777  void setStartScale(int iSys, Event& event);
778 
779  // Auxiliary methods to generate trial scales for various shower
780  // components.
781  bool q2NextEmit(const double q2Begin, double q2End);
782  bool q2NextSplit(const double q2Begin, double q2End);
783  bool q2NextResEmit(const double q2Begin, const double q2End);
784  bool q2NextResSplit(const double q2Begin, const double q2End);
785  bool q2NextEmitQED(double q2Begin, const double q2End);
786  bool q2NextSplitQED(double q2Begin, const double q2End);
787 
788  // Return the Q2 for the next branching.
789  template <class Brancher> bool q2NextBranch( vector<Brancher> &brancherVec,
790  const map<double, EvolutionWindow>& evWindows, const int evType,
791  const double q2Begin, const double q2End, bool isEmit);
792  // Perform a QED branching.
793  bool branchQED(Event& event);
794  // Perform an early antenna rejection.
795  bool rejectEarly(AntennaFunction* &antFunPtr,bool doMEC);
796  // Compute physical antenna function.
797  double getAntPhys(AntennaFunction* &antFunPtr);
798  // Calculate acceptance probability.
799  double pAcceptCalc(double antPhys);
800  // Generate the full kinematics.
801  bool genFullKinematics(int kineMap, Event event, vector<Vec4> &pPost);
802  // Check if a trial is accepted.
803  bool acceptTrial(Event& event);
804  // Generate new particles for the antenna.
805  bool getNewParticles(Event& event, AntennaFunction* antFunPtr,
806  vector<Particle> &newParts);
807 
808  // Generate new helicities for the antenna. Default is to set same
809  // as before, with a new unpolarised emission inserted. If helicity
810  // shower is off, this will correspond to all unpolarised. Do it
811  // this way because in case of resonance decays rest of vector
812  // includes whole resonance system, whose polarisations we don't
813  // want to change, i.e. they only recoil kinematically.
814  vector<int> genHelicities(AntennaFunction* antFunPtr);
815 
816  // TODO: include ME corrections method.
817  // double getMEC();
818 
819  // Update the event.
820  bool updateEvent(Event& event,resJunctionInfo & junctionInfoIn);
821  // Update the parton systems.
822  void updatePartonSystems();
823  // Create a new emission brancher.
824  void saveEmitter(int iSysIn, Event& event, int i0, int i1);
825  // Create a new resonance emission brancher.
826  void saveResEmitter(int iSys, Event& event, vector<int> allIn,
827  unsigned int posResIn, unsigned int posFIn,bool colMode);
828  // Create a new resonance splitter.
829  void saveResSplitter(int iSysIn, Event& event, vector<int> allIn,
830  unsigned int posResIn, unsigned int posFIn,bool colMode);
831  // Create a new splitter brancher.
832  void saveSplitter(int iSysIn, Event& event, int i0, int i1, bool col2acol);
833  // Update the branchers.
834  template <class Brancher> void updateBranchers(vector<Brancher>& brancherVec,
835  map<pair<int, bool>, unsigned int>& lookupBrancher, Event& event, int iOld,
836  int iNew);
837  // Update a single brancher.
838  template <class Brancher> void updateBrancher(vector<Brancher>& brancherVec,
839  map<pair<int, bool>, unsigned int>& lookupBrancher, Event& event,
840  int iOld1, int iOld2, int iNew1, int iNew2);
841  // Update emission branchers due to a recoiled parton.
842  void updateEmitters(Event& event, int iOld, int iNew);
843  // Update emission brancher due to an emission.
844  void updateEmitter(Event& event, int iOld1, int iOld2, int iNew1, int iNew2);
845  // Update splitter branchers due to a recoiled parton.
846  void updateSplitters(Event& event, int iOld, int iNew);
847  // Update splitter brancher due to an emission.
848  void updateSplitter(Event& event, int iOld1, int iOld2, int iNew1, int iNew2,
849  bool col2acol);
850  // Remove a splitter due to a gluon that has branched, assumes that
851  // iRemove is splitting gluon.
852  void removeSplitter(int iRemove);
853  // Update resonance emitter due to changed downstream decay products.
854  bool updateResBranchers(int iSysRes, Event& event, int iRes);
855  // Update resonance emitter due to changed downstream decay products.
856  void updateResBranchers(int iSysRes, Event& event, vector<int> resSysAll,
857  unsigned int posRes, unsigned int posPartner, bool isCol);
858  // Update the antennae.
859  bool updateAntennae(Event& event);
860  // Update systems of QCD antennae after a QED branching.
861  bool updateAfterQED(Event& event, int sizeOld);
862  // Print a brancher lookup.
863  void printLookup(map< pair<int, bool>, unsigned int > lookupBrancher,
864  string name);
865  // Print the brancher lookup maps.
866  void printLookup();
867  // Calculate the headroom factor.
868  vector<double> getHeadroom(int iSys, bool isEmit, double q2Next);
869  // Calculate the enhancement factor.
870  vector<double> getEnhance(int iSys, bool isEmit, double q2Next);
871 
872  // Flags if initialized and prepared.
873  bool isInit, isPrepared;
874 
875  // Beam pointers and info.
876  BeamParticle* beamAPtr;
877  BeamParticle* beamBPtr;
878  double eCMBeamsSav, m2BeamsSav;
879 
880  // Main on/off switches.
881  bool doFF, doRF, doII, doIF, doQED;
882 
883  // Parameter setting which kind of 2->4 modifications (if any) are used.
884  int mode2to4;
885 
886  // Shower parameters.
887  bool helicityShower, sectorShower;
888  int evTypeEmit, evTypeSplit, nGluonToQuark;
889  double q2CutoffEmit, q2CutoffSplit;
890  int nFlavZeroMass;
891  map<int,int> resSystems;
892  int kMapResEmit;
893  int kMapResSplit;
894 
895  // Factorization scale and shower starting settings.
896  int pTmaxMatch;
897  double pTmaxFudge, pT2maxFudge, pT2maxFudgeMPI;
898 
899  // AlphaS parameters.
900  bool useCMW;
901  int alphaSorder;
902  double alphaSvalue, alphaSmax, alphaSmuFreeze, alphaSmuMin;
903  double aSkMu2Emit, aSkMu2Split;
904 
905  // Calculated alphaS values.
906  double mu2freeze, mu2min;
907 
908  // Map of qmin evolution window.
909  map<double, EvolutionWindow> evWindowsEmit;
910  map<double, EvolutionWindow> evWindowsSplit;
911 
912  // Lists of different types of antennae.
913  vector<BrancherEmitRF> resEmitters;
914  vector<BrancherSplitRF> resSplitters;
915  vector<BrancherEmitFF> emitters;
916  vector<BrancherSplitFF> splitters;
917 
918  // Look up resonance emitter, bool switches between R (true) or F
919  // (false), n.b. multiply resonance index by sign of colour index
920  // involved in branching to avoid a multiple-valued map.
921  map< pair<int, bool>, unsigned int > lookupBrancherRF;
922  map< pair<int, bool>, unsigned int > lookupSplitterRF;
923  // Look up emitter, bool switches between col and anticol end
924  map< pair<int, bool>, unsigned int > lookupBrancherFF;
925  // Lookup splitter, bool switches between splitter and recoiler.
926  map< pair<int, bool>, unsigned int > lookupSplitter;
927 
928  // Current winner.
929  Brancher* winnerPtr;
930  bool winnerQED;
931  double q2WinSav, pTLastAcceptedSav;
932 
933  // Variables set by branch().
934  int iSysWin, iAntWin;
935 
936  // Index of latest emission (slightly arbritrary for splittings but
937  // only used to populate some internal histograms.
938  int iNewSav;
939 
940  // Storage of the post-branching configuration while it is being built.
941  vector<Particle> pNew;
942  // Total and MEC accept probability.
943  vector<double> pAccept;
944 
945  // Colour reconnection parameters.
946  bool doCR, CRjunctions;
947 
948  // Enhancement switches and parameters.
949  bool enhanceInHard, enhanceInResDec, enhanceInMPI;
950  double enhanceAll, enhanceBottom, enhanceCharm, enhanceCutoff;
951 
952  // Possibility to allow user veto of emission step.
953  bool hasUserHooks, canVetoEmission;
954 
955  // Flags to tell a few basic properties of each parton system.
956  map<int, bool> isHardSys, isResonanceSys, polarisedSys, doMECsSys;
957  map<int, bool> stateChangeSys;
958  bool stateChangeLast;
959 
960  // Save initial FSR starting scale system by system.
961  map<int, double> Q2hat;
962 
963  // Count the number of branchings in the system.
964  map<int, int> nBranch, nBranchFSR;
965 
966  // Total mass of showering system.
967  map<int, double> mSystem;
968 
969  // Count numbers of quarks and gluons.
970  map<int, int> nG, nQ, nLep, nGam;
971 
972  // Save headroom and enhancement factors for each system for both
973  // emission and splitting branchers.
974  map< pair<int, pair<bool,bool> > , vector<double> > headroomSav;
975  map< pair<int, pair<bool,bool> > , vector<double> > enhanceSav;
976 
977  // Information iabout resonances that participate in junctions.
978  map<int, bool> hasResJunction;
979  map<int, resJunctionInfo> junctionInfo;
980 
981  // Verbose settings.
982  int verbose;
983  bool headerIsPrinted;
984 
985  // Internal histograms.
986  shared_ptr<VinciaDiagnostics> diagnosticsPtr;
987  bool doDiagnostics;
988  map<string,Hist> vinciaHistos;
989 
990  // Bool to know whether we have binned the first QBranch already.
991  bool firstQBranchBinned;
992  double qBranch[4][11], pTphys[4][11];
993 
994  // Statistics.
995  long nTrialsSum;
996  vector<long> nTrials, nTrialsAccepted, nFailedVeto, nFailedHull, nFailedKine;
997  vector<long> nFailedMass, nFailedCutoff, nClosePSforHQ, nSectorReject;
998 
999  // Counter for numbers of events.
1000  long nAccepted, nSelected;
1001  int nVetoUserHooks, nFailHadLevel, nCallPythiaNext;
1002 
1003  // Debug settings.
1004  bool allowforceQuit, forceQuit;
1005  int nBranchQuit;
1006 
1007  // Pointers to VINCIA objects.
1008  AntennaSetFSR* antSetPtr;
1009  MECs* mecsPtr;
1010  Colour* colourPtr;
1011  Resolution* resolutionPtr;
1012  shared_ptr<VinciaISR> isrPtr;
1013  QEDShower* qedShowerPtr;
1014  VinciaCommon* vinComPtr;
1015  VinciaWeights* weightsPtr;
1016 
1017  // Pointer to AlphaS instances.
1018  AlphaStrong* aSemitPtr;
1019  AlphaStrong* aSsplitPtr;
1020 
1021 };
1022 
1023 //==========================================================================
1024 
1025 } // end namespace Pythia8
1026 
1027 #endif // end Pythia8_VinciaFSR_H