Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:06:35

0001 // VinciaISR.h is a part of the PYTHIA event generator.
0002 // Copyright (C) 2024 Peter Skands, Torbjorn Sjostrand.
0003 // PYTHIA is licenced under the GNU GPL v2 or later, see COPYING for details.
0004 // Please respect the MCnet Guidelines, see GUIDELINES for details.
0005 
0006 // This file contains header information for the VinciaISR class for
0007 // QCD initial-state antenna showers (II and IF), and auxiliary classes.
0008 
0009 #ifndef Pythia8_VinciaISR_H
0010 #define Pythia8_VinciaISR_H
0011 
0012 #include "Pythia8/SpaceShower.h"
0013 #include "Pythia8/VinciaAntennaFunctions.h"
0014 #include "Pythia8/VinciaCommon.h"
0015 #include "Pythia8/VinciaDiagnostics.h"
0016 #include "Pythia8/VinciaQED.h"
0017 #include "Pythia8/VinciaEW.h"
0018 #include "Pythia8/VinciaWeights.h"
0019 
0020 namespace Pythia8 {
0021 
0022 // Forward declarations.
0023 class VinciaFSR;
0024 
0025 //==========================================================================
0026 
0027 // Base class for initial-state trial generators. Note, base class is
0028 // coded for a soft-eikonal trial function.
0029 
0030 class TrialGeneratorISR {
0031 
0032 public:
0033 
0034   // Constructor.
0035   TrialGeneratorISR() : isInit(false) {;}
0036   virtual ~TrialGeneratorISR() {;}
0037 
0038   // Initialize pointers.
0039   void initPtr(Info* infoPtrIn);
0040 
0041   // Name of trial generator.
0042   virtual string name() {return "TrialGeneratorISR";}
0043 
0044   // Initialize.
0045   virtual void init(double mcIn, double mbIn);
0046 
0047   // Trial antenna function. Convention for what is coded here:
0048   //   when using x*PDF ratio <= const : aTrial
0049   //   when using PDF ratio   <= const : aTrial * sab / sAB
0050   // Base class implements soft eikonal with PDF ratio as overestimate.
0051   virtual double aTrial(double saj, double sjb, double sAB);
0052 
0053   // Evolution scale.
0054   virtual double getQ2(double saj, double sjb, double sAB) {
0055     return (saj*sjb/(saj + sjb + sAB));}
0056   virtual double getQ2max(double sAB, double, double) {
0057     return (0.25*pow2(shhSav - sAB)/shhSav);}
0058 
0059   // Generate new Q value, with first-order running alphaS.
0060   virtual double genQ2run(double q2old, double sAB, double zMin, double zMax,
0061     double colFac, double PDFratio, double b0, double kR, double Lambda,
0062     double eA, double eB, double headroomFac = 1.0, double enhanceFac = 1.0);
0063 
0064   // Generate new Q value, with constant trial alphaS.
0065   virtual double genQ2(double q2old, double sAB, double zMin, double zMax,
0066     double colFac, double alphaSvalue, double PDFratio, double eA, double eB,
0067     double headroomFac = 1.0, double enhanceFac = 1.0);
0068 
0069   // Generate new Q value, with running of the PDFs towards the mass
0070   // threshold.
0071   virtual double genQ2thres(double q2old, double sAB, double zMin,
0072     double zMax, double colFac, double alphaSvalue, double PDFratio, int idA,
0073     int idB, double eA, double eB, bool useMpdf, double headroomFac = 1.0,
0074     double enhanceFac = 1.0);
0075 
0076   // Generate a new zeta value in [zMin,zMax].
0077   virtual double genZ(double zMin, double zMax);
0078 
0079   // The zeta integral.
0080   virtual double getIz(double zMin, double zMax);
0081 
0082   // The zeta boundaries, for a given value of the evolution scale.
0083   virtual double getZmin(double Qt2, double sAB, double eA, double eBeamUsed);
0084   virtual double getZmax(double Qt2, double sAB, double eA, double eBeamUsed);
0085 
0086   // Inverse transforms to obtain saj and sjb from Qt2 and zeta.
0087   virtual double getS1j(double Qt2, double zeta, double sAB);
0088   virtual double getSj2(double Qt2, double zeta, double sAB);
0089 
0090   // Compute trial PDF ratio.
0091   virtual double trialPDFratio(BeamParticle* beamAPtr, BeamParticle* beamBPtr,
0092     int iSys, int idA, int idB, double eA, double eB,
0093     double Qt2A, double Qt2B);
0094 
0095   // Return last trial PDF ratio.
0096   virtual double getTrialPDFratio() {return trialPDFratioSav;}
0097 
0098   // Check initialization.
0099   bool checkInit();
0100 
0101   // Return the last trial flavor.
0102   int trialFlav() {return trialFlavSav;}
0103 
0104  protected:
0105 
0106   // Pointers.
0107   Info*     infoPtr{};
0108   Rndm*     rndmPtr{};
0109   Settings* settingsPtr{};
0110   Logger*   loggerPtr{};
0111 
0112   // Use m or pT evolution for collinear singularities.
0113   bool useMevolSav;
0114 
0115   // s for hadron hadron.
0116   double shhSav;
0117 
0118   // For conversion trial generators.
0119   int trialFlavSav;
0120   int nGtoQISRSav;
0121 
0122   // Masses.
0123   double mbSav;
0124   double mcSav;
0125 
0126   // Doing a sector shower?
0127   bool sectorShower;
0128 
0129   // Saved trial PDF ratio and trial tolerance.
0130   double trialPDFratioSav;
0131   double TINYPDFtrial;
0132 
0133  private:
0134 
0135   // Status.
0136   bool isInit;
0137 
0138   // Verbosity level.
0139   int verbose;
0140 
0141 };
0142 
0143 //==========================================================================
0144 
0145 // Soft-eikonal trial function for II (clone of base class but with
0146 // name change).
0147 
0148 class TrialIISoft : public TrialGeneratorISR {
0149 
0150 public:
0151 
0152   // Name of trial generator.
0153   virtual string name() override {return "TrialIISoft";}
0154 
0155 };
0156 
0157 //==========================================================================
0158 
0159 // A collinear trial function for initial-initial.
0160 
0161 class TrialIIGCollA : public TrialGeneratorISR {
0162 
0163 public:
0164 
0165   // Name of trial generator.
0166   virtual string name() override {return "TrialIIGCollA";}
0167 
0168   // Trial antenna function for g->gg (collinear to beam A).
0169   // Used with x*PDF <= const, so no extra x-factor.
0170   virtual double aTrial(double saj, double sjb, double sAB) override;
0171 
0172   // Evolution scale
0173   virtual double getQ2(double saj, double sjb, double sAB) override {
0174     return (saj*sjb/(saj + sjb + sAB));}
0175   virtual double getQ2max(double sAB, double, double) override {
0176     return (0.25*pow2(shhSav - sAB)/shhSav);}
0177 
0178   // Generate a new Q value, with first-order running alphaS.
0179   virtual double genQ2run(double q2old, double sAB, double zMin, double zMax,
0180     double colFac, double PDFratio, double b0, double kR, double Lambda,
0181     double eA, double eB, double headroomFac = 1.0, double enhanceFac = 1.0)
0182     override;
0183 
0184   // Generate a new Q value, with constant trial alphaS.
0185   virtual double genQ2(double q2old, double sAB, double zMin, double zMax,
0186     double colFac, double alphaSvalue, double PDFratio,
0187     double eA, double eB, double headroomFac = 1.0, double enhanceFac = 1.0)
0188     override;
0189 
0190   // Generate a new zeta value in [zMin,zMax].
0191   virtual double genZ(double zMin, double zMax) override;
0192 
0193   // The zeta integral.
0194   virtual double getIz(double zMin, double zMax) override;
0195 
0196   // The zeta boundaries, for a given value of the evolution scale
0197   virtual double getZmin(double Qt2, double sAB, double eA, double eBeamUsed)
0198     override;
0199   virtual double getZmax(double Qt2, double sAB, double eA, double eBeamUsed)
0200     override;
0201 
0202   // Inverse transforms to obtain saj and sjb from Qt2 and zeta.
0203   virtual double getS1j(double Qt2, double zeta, double sAB) override;
0204   virtual double getSj2(double Qt2, double zeta, double sAB) override;
0205 
0206 };
0207 
0208 //==========================================================================
0209 
0210 // B collinear trial function for initial-initial.
0211 
0212 class TrialIIGCollB : public TrialIIGCollA {
0213 
0214 public:
0215 
0216   // Name of trial generator.
0217   virtual string name() override {return "TrialIIGCollB";}
0218 
0219   // Trial antenna function.
0220   virtual double aTrial(double saj, double sjb, double sAB) override {
0221     // Note: arguments reversed intentionally!
0222     return TrialIIGCollA::aTrial(sjb, saj, sAB);}
0223 
0224   // Inverse transforms to obtain saj and sjb from Qt2 and zeta.
0225   virtual double getS1j(double Qt2, double zeta, double sAB) override {
0226     return TrialIIGCollA::getSj2(Qt2, zeta, sAB);}
0227   virtual double getSj2(double Qt2, double zeta, double sAB) override {
0228     return TrialIIGCollA::getS1j(Qt2, zeta, sAB);}
0229 
0230   // Trial PDF ratio.
0231   virtual double trialPDFratio(BeamParticle* beamAPtr, BeamParticle* beamBPtr,
0232     int iSys, int idA, int idB, double eA, double eB,
0233     double Qt2A, double Qt2B) override {
0234     // Note: arguments reversed intentionally!
0235     return TrialIIGCollA::trialPDFratio(
0236       beamBPtr, beamAPtr, iSys, idB, idA, eB, eA, Qt2B, Qt2A);}
0237 
0238 };
0239 
0240 //==========================================================================
0241 
0242 // A splitting trial function for initial-initial, q -> gqbar.
0243 
0244 class TrialIISplitA : public TrialGeneratorISR {
0245 
0246 public:
0247 
0248   // Name of trial generator.
0249   virtual string name() override {return "TrialIISplitA";}
0250 
0251   // Trial antenna function. This trial used with PDF ratio <= const,
0252   // so has sab/sAB prefactor.
0253   virtual double aTrial(double saj, double sjb, double sAB) override;
0254 
0255   // Evolution scale.
0256   virtual double getQ2(double saj, double sjb, double sAB) override {
0257     return ((useMevolSav) ? saj : saj*sjb/(saj + sjb + sAB));}
0258   virtual double getQ2max(double sAB, double, double) override {
0259     return ((useMevolSav) ? shhSav-sAB : 0.25*pow2(shhSav-sAB)/shhSav);}
0260 
0261   // Generate new Q value, with first-order running alphaS. Same
0262   // expression for QT and QA; Iz is different.
0263   virtual double genQ2run(double q2old, double sAB, double zMin, double zMax,
0264     double colFac, double PDFratio, double b0, double kR, double Lambda,
0265     double eA, double eB, double headroomFac = 1.0, double enhanceFac = 1.0)
0266     override;
0267 
0268   // Generate new Q value, with constant trial alphaS.
0269   virtual double genQ2(double q2old, double sAB, double zMin, double zMax,
0270     double colFac, double alphaSvalue, double PDFratio,
0271     double eA, double eB, double headroomFac = 1.0, double enhanceFac = 1.0)
0272     override;
0273 
0274   // Generate new Q value, with running of the PDFs towards the mass
0275   // threshold.
0276   virtual double genQ2thres(double q2old, double sAB,
0277     double zMin, double zMax, double colFac, double alphaSvalue,
0278     double PDFratio, int idA, int idB, double eA, double eB, bool useMpdf,
0279     double headroomFac = 1.0, double enhanceFac = 1.0) override;
0280 
0281   // Generate a new zeta value in [zMin,zMax]. For QT 1/(1+z3)
0282   // distribution; for QA 1/z4 distribution.
0283   virtual double genZ(double zMin, double zMax) override;
0284 
0285   // The zeta integral (with alpha = 0). For QT integral dz4 1/(1+z3),
0286   // for QA integral dz4 1/z4.
0287   virtual double getIz(double zMin, double zMax) override;
0288 
0289   // The zeta boundaries, for a given value of the evolution scale.
0290   virtual double getZmin(double Qt2, double sAB, double eA, double eBeamUsed)
0291     override;
0292   virtual double getZmax(double Qt2, double sAB, double eA, double eBeamUsed)
0293     override;
0294 
0295   // Inverse transforms to obtain saj and sjb from Qt2 and zeta.
0296   virtual double getS1j(double Qt2, double zeta, double sAB) override;
0297   virtual double getSj2(double Qt2, double zeta, double sAB) override;
0298 
0299   // Trial PDF ratio.
0300   virtual double trialPDFratio(BeamParticle* beamAPtr, BeamParticle* beamBPtr,
0301     int iSys, int idA, int idB, double eA, double eB,
0302     double Qt2A, double Qt2B) override;
0303 
0304 };
0305 
0306 //==========================================================================
0307 
0308 // B splitting trial function for initial-initial, q -> gqbar.
0309 
0310 class TrialIISplitB : public TrialIISplitA {
0311 
0312 public:
0313 
0314   // Name of trial generator.
0315   virtual string name() override {return "TrialIISplitB";}
0316 
0317   // Trial antenna function.
0318   virtual double aTrial(double saj, double sjb, double sAB) override {
0319     // Note: arguments reversed intentionally!
0320     return TrialIISplitA::aTrial(sjb, saj, sAB);}
0321 
0322   // Evolution scale.
0323   virtual double getQ2(double saj, double sjb, double sAB) override {
0324     // Note: arguments reversed intentionally!
0325     return TrialIISplitA::getQ2(sjb, saj, sAB);}
0326 
0327   // Generate new Q value, with first-order running alphaS.
0328   virtual double genQ2run(double q2old, double sAB, double zMin, double zMax,
0329     double colFac, double PDFratio, double b0, double kR, double Lambda,
0330     double eA, double eB, double headroomFac = 1.0, double enhanceFac = 1.0)
0331     override {return TrialIISplitA::genQ2run(q2old, sAB, zMin, zMax, colFac,
0332       PDFratio, b0, kR, Lambda, eB, eA, headroomFac, enhanceFac);}
0333 
0334   // Generate new Q value, with constant trial alphaS.
0335   virtual double genQ2(double q2old, double sAB, double zMin, double zMax,
0336     double colFac, double alphaSvalue, double PDFratio,
0337     double eA, double eB, double headroomFac = 1.0, double enhanceFac = 1.0)
0338     override {return TrialIISplitA::genQ2(q2old, sAB, zMin, zMax, colFac,
0339       alphaSvalue, PDFratio, eB, eA, headroomFac, enhanceFac);}
0340 
0341   // Generate new Q value, with running of the PDFs towards the mass
0342   // threshold.
0343   virtual double genQ2thres(double q2old, double sAB,
0344     double zMin, double zMax, double colFac, double alphaSvalue,
0345     double PDFratio, int idA, int idB, double eA, double eB, bool useMpdf,
0346     double headroomFac = 1.0, double enhanceFac = 1.0) override {
0347     return TrialIISplitA::genQ2thres(q2old, sAB, zMin, zMax, colFac,
0348       alphaSvalue, PDFratio, idB, idA, eB, eA, useMpdf, headroomFac,
0349       enhanceFac);}
0350 
0351   // Inverse transforms to obtain saj and sjb from Qt2 and zeta.
0352   virtual double getS1j(double Qt2, double zeta, double sAB) override {
0353     return TrialIISplitA::getSj2(Qt2, zeta, sAB);}
0354   virtual double getSj2(double Qt2, double zeta, double sAB) override {
0355     return TrialIISplitA::getS1j(Qt2, zeta, sAB);}
0356 
0357   // Trial PDF ratio.
0358   virtual double trialPDFratio(BeamParticle* beamAPtr, BeamParticle* beamBPtr,
0359     int iSys, int idA, int idB, double eA, double eB, double Qt2A, double Qt2B)
0360     override {
0361     // Note: arguments reversed intentionally!
0362     return TrialIISplitA::trialPDFratio(beamBPtr, beamAPtr, iSys,
0363       idB, idA, eB, eA, Qt2B, Qt2A);}
0364 
0365 };
0366 
0367 //==========================================================================
0368 
0369 // A conversion trial function for initial-initial, g -> qqbar.
0370 
0371 class TrialIIConvA : public TrialGeneratorISR {
0372 
0373 public:
0374 
0375   // Name of trial generator
0376   virtual string name() override {return "TrialIIConvA";}
0377 
0378   // Trial antenna function. Used with x*PDF ratio <= const, so no
0379   // extra prefactor.
0380   virtual double aTrial(double saj, double sjb, double sAB) override;
0381 
0382   // Evolution scale.
0383   virtual double getQ2(double saj, double sjb, double sAB) override {
0384     return ((useMevolSav) ? saj : (saj*sjb/(saj + sjb + sAB)));}
0385   virtual double getQ2max(double sAB, double, double) override {
0386     return ((useMevolSav) ? (shhSav - sAB) : 0.25*pow2(shhSav - sAB)/shhSav);}
0387 
0388   // Generate a new Q value, with first-order running alphaS.
0389   virtual double genQ2run(double q2old, double sAB, double zMin, double zMax,
0390     double colFac, double PDFratio, double b0, double kR, double Lambda,
0391     double eA, double eB, double headroomFac = 1.0, double enhanceFac = 1.0)
0392     override;
0393 
0394   // Generate a new Q value, with constant trial alphaS. Same
0395   // expression for QT and QA; Iz is different.
0396   virtual double genQ2(double q2old, double sAB, double zMin, double zMax,
0397     double colFac, double alphaSvalue, double PDFratio,
0398     double eA, double eB, double headroomFac = 1.0, double enhanceFac = 1.0)
0399     override;
0400 
0401   // Generate a new zeta value in [zMin,zMax].
0402   virtual double genZ(double zMin, double zMax) override;
0403 
0404   // The zeta integral.
0405   virtual double getIz(double zMin, double zMax) override;
0406 
0407   // The zeta boundaries, for a given value of the evolution scale.
0408   virtual double getZmin(double Qt2, double sAB, double eA, double eBeamUsed)
0409     override;
0410   virtual double getZmax(double Qt2, double sAB, double eA, double eBeamUsed)
0411     override;
0412 
0413   // Inverse transforms to obtain saj and sjb from Qt2 and zeta.
0414   virtual double getS1j(double Qt2, double zeta, double sAB) override;
0415   virtual double getSj2(double Qt2, double zeta, double sAB) override;
0416 
0417   // Trial PDF ratio.
0418   virtual double trialPDFratio(BeamParticle* beamAPtr, BeamParticle* beamBPtr,
0419     int iSys, int idA, int idB, double eA, double eB,
0420     double Qt2A, double Qt2B) override;
0421 
0422 };
0423 
0424 //==========================================================================
0425 
0426 // B conversion trial function for initial-initial, g -> qqbar.
0427 
0428 class TrialIIConvB : public TrialIIConvA {
0429 
0430 public:
0431 
0432   // Name of trial generator.
0433   virtual string name() override {return "TrialIIConvB";}
0434 
0435   // Trial antenna function.
0436   virtual double aTrial(double saj, double sjb, double sAB) override {
0437     // Note: arguments reversed intentionally!
0438     return TrialIIConvA::aTrial(sjb, saj, sAB);}
0439 
0440   // Evolution scale.
0441   virtual double getQ2(double saj, double sjb, double sAB) override {
0442     // Note: arguments reversed intentionally!
0443     return TrialIIConvA::getQ2(sjb, saj, sAB);}
0444 
0445   // Generate a new Q value, with first-order running alphaS
0446   virtual double genQ2run(double q2old, double sAB, double zMin, double zMax,
0447     double colFac, double PDFratio, double b0, double kR, double Lambda,
0448     double eA, double eB, double headroomFac = 1.0, double enhanceFac = 1.0)
0449     override {return TrialIIConvA::genQ2run(q2old, sAB, zMin, zMax, colFac,
0450       PDFratio, b0, kR, Lambda, eB, eA, headroomFac, enhanceFac);}
0451 
0452   // Generate a new Q value, with constant trial alphaS.
0453   virtual double genQ2(double q2old, double sAB, double zMin, double zMax,
0454     double colFac, double alphaSvalue, double PDFratio,
0455     double eA, double eB, double headroomFac = 1.0, double enhanceFac = 1.0)
0456     override {return TrialIIConvA::genQ2(q2old, sAB, zMin, zMax, colFac,
0457       alphaSvalue, PDFratio, eB, eA, headroomFac, enhanceFac);}
0458 
0459   // Inverse transforms: to obtain saj and sjb from Qt2 and zeta.
0460   virtual double getS1j(double Qt2, double zeta, double sAB) override {
0461     return TrialIIConvA::getSj2(Qt2, zeta, sAB);}
0462   virtual double getSj2(double Qt2, double zeta, double sAB) override {
0463     return TrialIIConvA::getS1j(Qt2, zeta, sAB);}
0464 
0465   // Trial PDF ratio
0466   virtual double trialPDFratio(BeamParticle* beamAPtr, BeamParticle* beamBPtr,
0467     int iSys, int idA, int idB, double eA, double eB,
0468     double Qt2A, double Qt2B) override {
0469     // Note: arguments reversed intentionally!
0470     return TrialIIConvA::trialPDFratio(
0471       beamBPtr, beamAPtr, iSys, idB, idA, eB, eA, Qt2B, Qt2A);}
0472 
0473 };
0474 
0475 //==========================================================================
0476 
0477 // Soft-eikonal trial function for initial-final.
0478 
0479 class TrialIFSoft : public TrialGeneratorISR {
0480 
0481 public:
0482 
0483   // Name of trial generator.
0484   virtual string name() override {return "TrialIFSoft";}
0485 
0486   // Trial antenna function. This trial generator uses x*PDF <= const
0487   // as overestimate => no x-factor.
0488   virtual double aTrial(double saj, double sjk, double sAK) override;
0489 
0490   // Evolution scale.
0491   virtual double getQ2(double saj, double sjk, double sAK) override {
0492     return (saj*sjk/(sAK+sjk));}
0493   virtual double getQ2max(double sAK, double eA, double eBeamUsed) override {
0494     double eAmax = ((sqrt(shhSav)/2.0) - (eBeamUsed-eA));
0495     return (sAK*(eAmax-eA)/eA);}
0496 
0497   // Generate a new Q value, with first-order running alphaS.
0498   virtual double genQ2run(double q2old, double sAK, double zMin, double zMax,
0499     double colFac, double PDFratio, double b0, double kR, double Lambda,
0500     double eA, double eK, double headroomFac = 1.0, double enhanceFac = 1.0)
0501     override;
0502 
0503   // Generate a new Q value, with constant trial alphaS.
0504   virtual double genQ2(double q2old, double sAK, double zMin, double zMax,
0505     double colFac, double alphaSvalue, double PDFratio,
0506     double eA, double eK, double headroomFac = 1.0, double enhanceFac = 1.0)
0507     override;
0508 
0509   // Generate a new zeta value in [zMin,zMax].
0510   virtual double genZ(double zMin, double zMax) override;
0511 
0512   // The zeta integral: dzeta/zeta/(zeta-1).
0513   virtual double getIz(double zMin, double zMax) override;
0514 
0515   // The zeta boundaries, for a given value of the evolution scale.
0516   virtual double getZmin(double Qt2, double sAK, double eA, double eBeamUsed)
0517     override;
0518   virtual double getZmax(double Qt2, double sAK, double eA, double eBeamUsed)
0519     override;
0520 
0521   // Inverse transforms to obtain saj and sjk from Qt2 and zeta.
0522   virtual double getS1j(double Qt2, double zeta, double sAK) override;
0523   virtual double getSj2(double Qt2, double zeta, double sAK) override;
0524 
0525   // Trial PDF ratio.
0526   virtual double trialPDFratio(BeamParticle* beamAPtr, BeamParticle* beamBPtr,
0527     int iSys, int idA, int idK, double eA, double eK,
0528     double Qt2A, double Qt2B) override;
0529 
0530 };
0531 
0532 //==========================================================================
0533 
0534 // Specialised soft-eikonal trial function for initial-final when
0535 // initial-state parton is a valence quark.
0536 
0537 class TrialVFSoft : public TrialIFSoft {
0538 
0539 public:
0540 
0541   // Name of trial generator.
0542   virtual string name() override {return "TrialVFSoft";}
0543 
0544   // Trial antenna function. This trial generator uses PDF <= const as
0545   // overestimate => x-factor.
0546   virtual double aTrial(double saj, double sjk, double sAK) override;
0547 
0548   // Generate a new zeta value in [zMin,zMax].
0549   virtual double genZ(double zMin, double zMax) override;
0550 
0551   // The zeta integral: dzeta/(zeta-1).
0552   virtual double getIz(double zMin, double zMax) override;
0553 
0554 };
0555 
0556 //==========================================================================
0557 
0558 // A gluon collinear trial function for initial-final.
0559 
0560 class TrialIFGCollA : public TrialGeneratorISR {
0561 
0562  public:
0563 
0564   // Name of trial generator.
0565   virtual string name() override {return "TrialIFGCollA";}
0566 
0567   // Trial antenna function. This trial generator uses x*PDF ratio <=
0568   // const as overestimate so the trial function has no extra
0569   // x-factor.
0570   virtual double aTrial(double saj, double sjk, double sAK) override;
0571 
0572   // Evolution scale.
0573   virtual double getQ2(double saj, double sjk, double sAK) override {
0574     return (saj*sjk/(sAK+sjk));}
0575   virtual double getQ2max(double sAK, double eA, double eBeamUsed) override {
0576     double eAmax = ( (sqrt(shhSav)/2.0) - (eBeamUsed-eA) );
0577     return (sAK*(eAmax-eA)/eA);}
0578 
0579   // Generate a new Q value, with first-order running alphaS.
0580   virtual double genQ2run(double q2old, double sAK, double zMin, double zMax,
0581     double colFac, double PDFratio, double b0, double kR, double Lambda,
0582     double eA, double eK, double headroomFac = 1.0, double enhanceFac = 1.0)
0583     override;
0584 
0585   // Generate a new Q value, with constant trial alphaS.
0586   virtual double genQ2(double q2old, double sAK, double zMin, double zMax,
0587     double colFac, double alphaSvalue, double PDFratio,
0588     double eA, double eK, double headroomFac = 1.0, double enhanceFac = 1.0)
0589     override;
0590 
0591   // Generate a new zeta value in [zMin,zMax].
0592   virtual double genZ(double zMin, double zMax) override;
0593 
0594   // The zeta integral.
0595   virtual double getIz(double zMin, double zMax) override;
0596 
0597   // The zeta boundaries, for a given value of the evolution scale.
0598   virtual double getZmin(double Qt2, double sAK, double eA, double eBeamUsed)
0599     override;
0600   virtual double getZmax(double Qt2, double sAK, double eA, double eBeamUsed)
0601     override;
0602 
0603   // Inverse transforms to obtain saj and sjk from Qt2 and zeta.
0604   virtual double getS1j(double Qt2, double zeta, double sAK) override;
0605   virtual double getSj2(double Qt2, double zeta, double sAK) override;
0606 
0607   // Trial PDF ratio (= just a simple headroom factor).
0608   virtual double trialPDFratio(BeamParticle* beamAPtr, BeamParticle* beamBPtr,
0609     int iSys, int idA, int idK, double eA, double eK,
0610     double Qt2A, double Qt2B) override;
0611 
0612 };
0613 
0614 //==========================================================================
0615 
0616 // K gluon collinear trial function for initial-final sector shower.
0617 
0618 class TrialIFGCollK : public TrialGeneratorISR {
0619 
0620  public:
0621 
0622   // Name of trial generator.
0623   virtual string name() override {return "TrialIFGCollK";}
0624 
0625   // Trial antenna function.
0626   virtual double aTrial(double saj, double sjk, double sAK) override;
0627 
0628   // Evolution scale.
0629   virtual double getQ2(double saj, double sjk, double sAK) override {
0630     return (saj*sjk/(sAK+sjk));
0631   }
0632   virtual double getQ2max(double sAK, double eA, double eAused) override {
0633     double eAmax = ( (sqrt(shhSav)/2.0) - (eAused-eA) );
0634     return (sAK*(eAmax-eA)/eA);}
0635 
0636   // Generate a new Q value, with first-order running alphaS.
0637   virtual double genQ2run(double q2old, double sAK, double zMin, double zMax,
0638     double colFac, double PDFratio, double b0, double kR, double Lambda,
0639     double eA, double eK, double headroomFac=1.0, double enhanceFac=1.0)
0640     override;
0641 
0642   // Generate a new Q value, with constant trial alphaS.
0643   virtual double genQ2(double q2old, double sAK, double zMin, double zMax,
0644     double colFac, double alphaSvalue, double PDFratio,
0645     double eA, double eK, double headroomFac=1.0, double enhanceFac=1.0)
0646     override;
0647 
0648   // Generate a new zeta value in [zMin,zMax].
0649   virtual double genZ(double zMin, double zMax) override;
0650 
0651   // The zeta integral.
0652   virtual double getIz(double zMin, double zMax) override;
0653 
0654   // The zeta boundaries, for a given value of the evolution scale.
0655   virtual double getZmin(double Qt2, double sAK, double eA, double eAused)
0656     override;
0657   virtual double getZmax(double Qt2, double sAK, double eA, double eAused)
0658     override;
0659 
0660   // Inverse transforms to obtain saj and sjk from Qt2 and zeta.
0661   virtual double getS1j(double Qt2, double zeta, double sAK) override;
0662   virtual double getSj2(double Qt2, double zeta, double sAK) override;
0663 
0664   // Trial PDF ratio.
0665   virtual double trialPDFratio(BeamParticle* beamAPtr, BeamParticle* beamBPtr,
0666     int iSys, int idA, int idK, double eA, double eK,
0667     double Qt2A, double Qt2B) override;
0668 };
0669 
0670 //==========================================================================
0671 
0672 // A splitting trial function for initial-final, q -> gqbar.
0673 
0674 class TrialIFSplitA : public TrialGeneratorISR {
0675 
0676 public:
0677 
0678   // Name of trial generator.
0679   virtual string name() override {return "TrialIFSplitA";}
0680 
0681   // Trial antenna function. This trial generator uses the xf
0682   // overestimate so no extra x-factor.
0683   virtual double aTrial(double saj, double sjk, double sAK) override;
0684 
0685   // Evolution scale.
0686   virtual double getQ2(double saj, double sjk, double sAK) override {
0687     return ((useMevolSav) ? saj : saj*sjk/(sAK + sjk));}
0688   virtual double getQ2max(double sAK, double eA, double eBeamUsed) override {
0689     double xA    = eA/(sqrt(shhSav)/2.0);
0690     double eAmax = ((sqrt(shhSav)/2.0) - (eBeamUsed - eA));
0691     return ((useMevolSav) ? sAK/xA : sAK*(eAmax - eA)/eA);}
0692 
0693   // Generate new Q value, with first-order running alphaS.
0694   virtual double genQ2run(double q2old, double sAK, double zMin, double zMax,
0695     double colFac, double PDFratio, double b0, double kR, double Lambda,
0696     double eA, double eK, double headroomFac = 1.0, double enhanceFac = 1.0)
0697     override;
0698 
0699   // Generate new Q value, with constant trial alphaS.
0700   virtual double genQ2(double q2old, double sAK, double zMin, double zMax,
0701     double colFac, double alphaSvalue, double PDFratio,
0702     double eA, double eK, double headroomFac = 1.0, double enhanceFac = 1.0)
0703     override;
0704 
0705   // Generate new Q value, with running of the PDFs towards the mass
0706   // threshold.
0707   virtual double genQ2thres(double q2old, double sAK,
0708     double zMin, double zMax, double colFac, double alphaSvalue,
0709     double PDFratio, int idA, int idK, double eA, double eK, bool useMpdf,
0710     double headroomFac = 1.0, double enhanceFac = 1.0) override;
0711 
0712   // Generate a new zeta value in [zMin,zMax].
0713   virtual double genZ(double zMin, double zMax) override;
0714 
0715   // The zeta integral.
0716   virtual double getIz(double zMin, double zMax) override;
0717 
0718   // The zeta boundaries, for a given value of the evolution scale.
0719   virtual double getZmin(double Qt2, double sAK, double eA, double eBeamUsed)
0720     override;
0721   virtual double getZmax(double Qt2, double sAK, double eA, double eBeamUsed)
0722     override;
0723 
0724   // Inverse transforms to obtain saj and sjk from Qt2 and zeta.
0725   virtual double getS1j(double Qt2, double zeta, double sAK) override;
0726   virtual double getSj2(double Qt2, double zeta, double sAK) override;
0727 
0728   // Trial PDF ratio.
0729   virtual double trialPDFratio(BeamParticle* beamAPtr, BeamParticle* beamBPtr,
0730     int iSys, int idA, int idK, double eA, double eK,
0731     double Qt2A, double Qt2B) override;
0732 
0733 };
0734 
0735 //==========================================================================
0736 
0737 // K splitting trial function for initial-final, g -> qqbar.
0738 
0739 class TrialIFSplitK : public TrialGeneratorISR {
0740 
0741  public:
0742 
0743   // Name of trial generator.
0744   virtual string name() override {return "TrialIFSplitK";}
0745 
0746   // Trial antenna function. This trial uses the xf overestimate so no
0747   // extra x factor.
0748   virtual double aTrial(double saj, double sjk, double sAK) override;
0749 
0750   // Evolution scale.
0751   virtual double getQ2(double saj, double sjk, double sAK) override {
0752     return ((useMevolSav) ? sjk : saj*sjk/(sAK + sjk));}
0753   virtual double getQ2max(double sAK, double eA, double eBeamUsed) override {
0754     double xA    = eA/(sqrt(shhSav)/2.0);
0755     double eAmax = ((sqrt(shhSav)/2.0) - (eBeamUsed - eA));
0756     return ((useMevolSav) ? sAK*(1.0 - xA)/xA : sAK*(eAmax - eA)/eA);}
0757 
0758   // Generate a new Q value, with first-order running alphaS.
0759   virtual double genQ2run(double q2old, double sAK, double zMin, double zMax,
0760     double colFac, double PDFratio, double b0, double kR, double Lambda,
0761     double eA, double eK, double headroomFac = 1.0, double enhanceFac = 1.0)
0762     override;
0763 
0764   // Generate a new Q value, with constant trial alphaS.
0765   virtual double genQ2(double q2old, double sAK, double zMin, double zMax,
0766     double colFac, double alphaSvalue, double PDFratio,
0767     double eA, double eK, double headroomFac = 1.0, double enhanceFac = 1.0)
0768     override;
0769 
0770   // Generate a new zeta value in [zMin,zMax].
0771   virtual double genZ(double zMin, double zMax) override;
0772 
0773   // The zeta integral.
0774   virtual double getIz(double zMin, double zMax) override;
0775 
0776   // The zeta boundaries, for a given value of the evolution scale.
0777   virtual double getZmin(double Qt2, double sAK, double eA, double eBeamUsed)
0778     override;
0779   virtual double getZmax(double Qt2, double sAK, double eA, double eBeamUsed)
0780     override;
0781 
0782   // Inverse transforms to obtain saj and sjk from Qt2 and zeta.
0783   virtual double getS1j(double Qt2, double zeta, double sAK) override;
0784   virtual double getSj2(double Qt2, double zeta, double sAK) override;
0785 
0786   // Trial PDF ratio.
0787   virtual double trialPDFratio(BeamParticle* beamAPtr, BeamParticle* beamBPtr,
0788     int iSys, int idA, int idK, double eA, double eK,
0789     double Qt2A, double Qt2B) override;
0790 
0791 };
0792 
0793 //==========================================================================
0794 
0795 // A conversion trial function for initial-final, g -> qqbar.
0796 
0797 class TrialIFConvA : public TrialGeneratorISR {
0798 
0799 public:
0800 
0801   // Name of trial generator.
0802   virtual string name() override {return "TrialIFConvA";}
0803 
0804   // Trial antenna function. This trial currently uses the xf
0805   // overestimate so no extra x-factor (but could be changed to use
0806   // the f overestimate if many violations, and/or for valence
0807   // flavours).
0808   virtual double aTrial(double saj, double sjk, double sAK) override;
0809 
0810   // Evolution scale.
0811   virtual double getQ2(double saj, double sjk, double sAK) override {
0812     return ((useMevolSav) ? saj : saj*sjk/(sAK + sjk));}
0813   virtual double getQ2max(double sAK, double eA, double eBeamUsed) override {
0814     double xA    = eA/(sqrt(shhSav)/2.0);
0815     double eAmax = ((sqrt(shhSav)/2.0) - (eBeamUsed - eA));
0816     return ((useMevolSav) ? sAK/xA : sAK*(eAmax-eA)/eA);}
0817 
0818   // Generate a new Q value, with first-order running alphaS.
0819   virtual double genQ2run(double q2old, double sAK, double zMin, double zMax,
0820     double colFac, double PDFratio, double b0, double kR, double Lambda,
0821     double eA, double eK, double headroomFac = 1.0, double enhanceFac = 1.0)
0822     override;
0823 
0824   // Generate a new Q value, with constant trial alphaS.
0825   virtual double genQ2(double q2old, double sAK, double zMin, double zMax,
0826     double colFac, double alphaSvalue, double PDFratio,
0827     double eA, double eK, double headroomFac = 1.0, double enhanceFac = 1.0)
0828     override;
0829 
0830   // Generate a new zeta value in [zMin,zMax].
0831   virtual double genZ(double zMin, double zMax) override;
0832 
0833   // The zeta integral.
0834   virtual double getIz(double zMin, double zMax) override;
0835 
0836   // The zeta boundaries, for a given value of the evolution scale.
0837   virtual double getZmin(double Qt2, double sAK, double eA, double eBeamUsed)
0838     override;
0839   virtual double getZmax(double Qt2, double sAK, double eA, double eBeamUsed)
0840     override;
0841 
0842   // Inverse transforms to obtain saj and sjk from Qt2 and zeta.
0843   virtual double getS1j(double Qt2, double zeta, double sAK) override;
0844   virtual double getSj2(double Qt2, double zeta, double sAK) override;
0845 
0846   // Trial PDF ratio.
0847   virtual double trialPDFratio(BeamParticle* beamAPtr, BeamParticle* beamBPtr,
0848     int iSys, int idA, int idK, double eA, double eK,
0849     double Qt2A, double Qt2B) override;
0850 
0851 };
0852 
0853 //==========================================================================
0854 
0855 // The BranchElementalISR class, container for 2 -> 3 trial branchings.
0856 
0857 // Input: i1In     carries colour (or incoming anticolour)
0858 //        i2In     carries anticolour (or incoming colour)
0859 //        colIn    colour tag
0860 //        isVal1In (true if i1In is incoming and is a valence parton on its
0861 //                  side/system)
0862 //        isVal2In (true if i2In is incoming and is a valence parton on its
0863 //                  side/system)
0864 // Internal storage for II:
0865 //        i1sav: whichever of i1In, i2In has positive pz
0866 //        i2sav: whichever of i1In, i2In has negative pz
0867 //        is1A : always true (i1sav always has positive pz)
0868 //        isII : true
0869 // Internal storage for IF:
0870 //        i1sav: whichever of i1In, i2In is the initial-state leg
0871 //        i2sav: whichever of i1In, i2In is the final-state leg
0872 //        is1A : true if i1sav has positive pz, false if it has negative pz
0873 //        isII : false
0874 
0875 class BranchElementalISR {
0876 
0877 public:
0878 
0879   // Constructors.
0880   BranchElementalISR() = default;
0881   BranchElementalISR(int iSysIn, Event& event, int iOld1In,
0882     int iOld2In, int colIn, bool isVal1In, bool isVal2In) {
0883     reset(iSysIn, event, iOld1In, iOld2In, colIn, isVal1In, isVal2In);}
0884 
0885   // Main method to initialize/reset a BranchElemental.
0886   void reset(int iSysIn, Event& event, int i1In, int i2In, int colIn,
0887     bool isVal1In, bool isVal2In);
0888 
0889   // Antenna mass (negative if spacelike virtual).
0890   double mAnt()  const {return mAntSav;}
0891   double m2Ant() const {return m2AntSav;}
0892   double sAnt()  const {return sAntSav;}
0893   // Dot products of daughters.
0894   double s12() const {return 2*new1.p()*new2.p();}
0895   double s23() const {return 2*new2.p()*new3.p();}
0896   double s13() const {return 2*new1.p()*new3.p();}
0897 
0898   // This is an II or an IF type.
0899   bool isII() const {return isIIsav;}
0900   // Is 1 a side A (p+) guy (need to know for pdfs in IF).
0901   bool is1A() const {return is1Asav;}
0902   // Valence.
0903   bool isVal1()  const {return isVal1sav;}
0904   bool isVal2()  const {return isVal2sav;}
0905   int colType1() const {return colType1sav;}
0906   int colType2() const {return colType2sav;}
0907   int col() const {return colSav;}
0908   int geti1() {return i1sav;}
0909   int geti2() {return i2sav;}
0910   int getId1() {return id1sav;}
0911   int getId2() {return id2sav;}
0912   int getSystem() {return system;}
0913 
0914   // Function to reset all trial generators for this branch elemental.
0915   void clearTrialGenerators();
0916 
0917   // Add a trial generator to this BranchElemental.
0918   void addTrialGenerator(enum AntFunType antFunTypeIn, bool swapIn,
0919     TrialGeneratorISR* trialGenPtrIn);
0920 
0921   // Add to and get rescue levels.
0922   void addRescue(int iTrial) {nShouldRescue[iTrial]++;}
0923   int getNshouldRescue(int iTrial) {return nShouldRescue[iTrial];}
0924   void resetRescue() {
0925     for (int i=0; i<(int)nShouldRescue.size(); i++) nShouldRescue[i] = 0;}
0926 
0927   // Function to return number of trial generators for this antenna.
0928   int nTrialGenerators() const {return trialGenPtrsSav.size();}
0929 
0930   // Save a generated trial branching.
0931   void saveTrial(int iTrial, double qOld, double qTrial, double zMin=0.,
0932     double zMax=0., double colFac=0.,double alphaEff=0., double pdfRatio=0.,
0933     int trialFlav=0, double extraMpdf=0., double headroom = 1.0,
0934     double enhanceFac = 1.0);
0935 
0936   // Add the physical pdf ratio.
0937   void addPDF(int iTrial,double pdfRatio) {physPDFratioSav[iTrial] = pdfRatio;}
0938 
0939   // Generate invariants for saved branching.
0940   bool genTrialInvariants(double& s1j, double& sj2,
0941     double eBeamUsed, int iTrial = -1);
0942 
0943   // Get trial function index of winner.
0944   int getTrialIndex() const;
0945 
0946   // Check if a saved trial exists for a particular trialGenerator.
0947   bool hasTrial(int iTrial) const {
0948     if (iTrial < int(hasSavedTrial.size())) return hasSavedTrial[iTrial];
0949     else return false;}
0950 
0951   // Get whether physical antenna is swapped.
0952   bool getIsSwapped(int iTrial = -1) const {
0953     if (iTrial <= -1) iTrial = getTrialIndex();
0954     return isSwappedSav[iTrial];}
0955 
0956   // Get physical antenna function index of winner.
0957   enum AntFunType antFunTypePhys(int iTrial = -1) const {
0958     if (iTrial <= -1) iTrial = getTrialIndex();
0959     return antFunTypePhysSav[iTrial];}
0960 
0961   // Get scale for a specific saved trial.
0962   double getTrialScale(int iTrial) const {
0963     if (iTrial < int(scaleSav.size())) return scaleSav[iTrial];
0964     else return -1.0;}
0965 
0966   // Get scale of winner.
0967   double getTrialScale() const;
0968 
0969   // Get colour factor.
0970   double getColFac(int iTrial = -1) {
0971     if (iTrial <= -1) iTrial = getTrialIndex();
0972     return colFacSav[iTrial];}
0973 
0974   // Get headroom factor.
0975   double getHeadroomFac(int iTrial = -1) {
0976     if (iTrial <= -1) iTrial = getTrialIndex();
0977     return headroomSav[iTrial];}
0978 
0979   // Get headroom factor.
0980   double getEnhanceFac(int iTrial = -1) {
0981     if (iTrial <= -1) iTrial = getTrialIndex();
0982     return enhanceFacSav[iTrial];}
0983 
0984   // Get alpha S.
0985   double getAlphaTrial(int iTrial = -1) {
0986     if (iTrial <= -1) iTrial = getTrialIndex();
0987     return alphaSav[iTrial];}
0988 
0989   // Get pdf ratio.
0990   double getPDFratioTrial(int iTrial = -1) {
0991     if (iTrial <= -1) iTrial = getTrialIndex();
0992     return trialPDFratioSav[iTrial];}
0993 
0994   // For gluon conversions, get ID of quark flavour to convert to.
0995   int getTrialFlav(int iTrial = -1) {
0996     if (iTrial <= -1) iTrial = getTrialIndex();
0997     return trialFlavSav[iTrial];}
0998 
0999   // Get pdf ratio.
1000   double getPDFratioPhys(int iTrial = -1) {
1001     if (iTrial <= -1) iTrial = getTrialIndex();
1002     return physPDFratioSav[iTrial];}
1003 
1004   // Get the extra factor when getting rid of the heavy quarks.
1005   double getExtraMassPDFfactor(int iTrial = -1) {
1006     if (iTrial <= -1) iTrial = getTrialIndex();
1007     return extraMassPDFfactorSav[iTrial];}
1008 
1009   // Flag to set if a saved trial should be ignored and a new one generated.
1010   // Default value -1 : force all trials to renew.
1011   void renewTrial(int iTrial = -1) {
1012     if (iTrial >= 0) hasSavedTrial[iTrial] = false;
1013     else for (iTrial = 0; iTrial < int(hasSavedTrial.size()); ++iTrial)
1014            hasSavedTrial[iTrial] = false;}
1015 
1016   // List function.
1017   void list(bool header = false, bool footer = false) const;
1018 
1019   // Data storage members.
1020   int i1sav{}, i2sav{}, id1sav{}, id2sav{}, colType1sav{}, colType2sav{},
1021   h1sav{}, h2sav{};
1022   double e1sav{}, e2sav{};
1023   bool isVal1sav{}, isVal2sav{}, isIIsav{}, is1Asav{};
1024   Particle new1{}, new2{}, new3{};
1025   // Colour, not obvious, since for e.g. gg -> H we have two II antennae.
1026   int colSav{};
1027   // System and counter for vetos.
1028   int system{0}, nVeto{}, nHull{}, nHadr{};
1029   // We have to force a splitting (heavy quarks).
1030   bool forceSplittingSav{};
1031 
1032   // Trial Generators and properties of saved trials.
1033   vector<TrialGeneratorISR*> trialGenPtrsSav{};
1034   vector<double> zMinSav{}, zMaxSav{}, colFacSav{}, alphaSav{};
1035   vector<double> physPDFratioSav{}, trialPDFratioSav{};
1036   vector<double> extraMassPDFfactorSav{};
1037   vector<double> scaleSav{}, scaleOldSav{}, headroomSav{}, enhanceFacSav{};
1038   vector<bool> hasSavedTrial{}, isSwappedSav{};
1039   vector<enum AntFunType> antFunTypePhysSav{};
1040   vector<int> nShouldRescue{}, trialFlavSav{};
1041   // Note: isSwapped = true for II means physical antenna function is
1042   // coded for side A but trial generator is for side B.  For IF, is1A
1043   // = true for 1 being on side A, false for 1 being on side B.
1044 
1045  private:
1046 
1047   // Saved antenna invariant mass value.
1048   double m2AntSav{}, mAntSav{}, sAntSav{};
1049 
1050 };
1051 
1052 //==========================================================================
1053 
1054 // The VinciaISR class.
1055 // Main shower class for initial-state (II and IF) antenna showers
1056 // Inherits from SpaceShower in Pythia 8 so can be used as alternative to
1057 // SpaceShower.
1058 // Methods that must replace ones in SpaceShower are marked with override.
1059 
1060 class VinciaISR : public SpaceShower {
1061 
1062   // Allow VinciaFSR to access private information.
1063   friend class VinciaFSR;
1064   friend class VinciaHistory;
1065 
1066 public:
1067 
1068   // Constructor.
1069   VinciaISR() : isInit(false) {;}
1070 
1071   // Destructor.
1072   virtual ~VinciaISR() {;}
1073 
1074   // Initialize shower. Possibility to force re-initialization by hand.
1075   void init(BeamParticle* beamAPtrIn, BeamParticle* beamBPtrIn) override;
1076 
1077   // Force reset at beginning of each event.
1078   void onBeginEvent() override { isPrepared = false; }
1079 
1080   // Possible limitation of first emission.
1081   bool limitPTmax(Event& event, double Q2Fac = 0., double Q2Ren = 0.) override;
1082 
1083   // Prepare system for evolution; identify ME.
1084   void prepare(int iSys, Event& event, bool limitPTmaxIn = false) override;
1085 
1086   // Update dipole list after each ISR emission.
1087   void update( int iSys, Event& event, bool hasWeakRad = false) override;
1088 
1089   // Select next pT in downwards evolution.
1090   double pTnext(Event& event, double pTbegAll, double pTendAll,
1091     int nRadIn = -1, bool doTrialIn = false) override;
1092 
1093   // Perform a branching (as defined by current "winner"). Returns
1094   // true of the branching was accepted and false if rejected.
1095   bool branch(Event& event) override;
1096 
1097   // Print a list of II and IF dipole-antennae.
1098   void list() const override;
1099 
1100   // Initialize data members for calculation of uncertainty bands. So
1101   // far purely dummy in Vincia.
1102   bool initUncertainties() override {return false;}
1103 
1104   // Flag for failure in branch(...) that will force a retry of parton
1105   // level. Returns false in base class, and rescatterFail in
1106   // simpleTimeShower. Not implemented in Vincia yet since we do not
1107   // do rescattering.
1108   bool doRestart() const override {return false;}
1109 
1110   // Flag for last ISR branching being gamma -> qqbar. Not implemented
1111   // in Vincia's QED evolution yet.
1112   bool wasGamma2qqbar() override {return false;}
1113 
1114   // Tell whether ISR has done a weak emission. Not implemented in Vincia yet.
1115   bool getHasWeaklyRadiated() override {return false;}
1116 
1117   // Tell which system was the last processed one.
1118   int system() const override {return iSysWin;}
1119 
1120   // Potential enhancement factor of pTmax scale for hardest emission.
1121   // Used if limitPTmax = true.
1122   double enhancePTmax() const override {return pTmaxFudge;}
1123 
1124   // Initialise pointers to Vincia objects.
1125   void initVinciaPtrs(VinciaColour* colourPtrIn,
1126     shared_ptr<VinciaFSR> fsrPtrIn, MECs* mecsPtrIn,
1127     Resolution* resolutionPtrIn, VinciaCommon* vinComPtrIn,
1128     VinciaWeights* vinWeightsPtrIn);
1129 
1130   // Set pointer to object to use for diagnostics and profiling.
1131   void setDiagnosticsPtr(shared_ptr<VinciaDiagnostics> diagnosticsPtrIn) {
1132     diagnosticsPtr = diagnosticsPtrIn;
1133   }
1134 
1135   // Set EW shower module.
1136   void setEWShowerPtr(VinciaModulePtr ewShowerPtrIn) {
1137     ewShowerPtr = ewShowerPtrIn;
1138   }
1139 
1140   // Set QED shower module for hard process and resonance decays.
1141   void setQEDShowerHardPtr(VinciaModulePtr qedShowerPtrIn) {
1142     qedShowerHardPtr = qedShowerPtrIn;
1143   }
1144 
1145   // Set QED shower module for MPI and hadronisation.
1146   void setQEDShowerSoftPtr(VinciaModulePtr qedShowerPtrIn) {
1147     qedShowerSoftPtr = qedShowerPtrIn;
1148   }
1149 
1150   // Clear all containers.
1151   void clearContainers();
1152 
1153   // Initialize pointers to antenna sets.
1154   void initAntPtr(AntennaSetISR* antSetIn) {antSetPtr = antSetIn;}
1155 
1156   // Function to tell if VinciaISR::prepare() has treated this system.
1157   bool prepared(int iSys) {
1158     if (hasPrepared.find(iSys) != hasPrepared.end()) return hasPrepared[iSys];
1159     else return false;}
1160 
1161   // Wrapper function to return a specific antenna inside antenna set
1162   AntennaFunctionIX* getAntFunPtr(enum AntFunType antFunType) {
1163     return antSetPtr->getAntFunPtr(antFunType);}
1164 
1165   // Evolution windows, phase space region boundaries.
1166   int getRegion(double q) {
1167     for (int i=1; i<(int)regMinScalesSav.size(); i++)
1168       if (q < regMinScalesSav[i]) return i-1;
1169     return (int)regMinScalesSav.size() - 1;}
1170 
1171   // Evolution window, phase space region boundaries.
1172   double getQmin(int iRegion) {
1173     iRegion = max(0,iRegion);
1174     iRegion = min(iRegion,(int)regMinScalesSav.size()-1);
1175     return regMinScalesSav[iRegion];}
1176 
1177   // Number of active flavors.
1178   int getNf(int iRegion) {
1179     if (iRegion <= 1) return 3;
1180     else if (iRegion <= 2) return 4;
1181     else if (iRegion <= 4) return 5;
1182     else return 6;}
1183 
1184   // Lambda value
1185   double getLambda(int nFin) {
1186     if (nFin <= 3) return alphaSptr->Lambda3();
1187     else if (nFin <= 4) return alphaSptr->Lambda4();
1188     else if (nFin <= 5) return alphaSptr->Lambda5();
1189     else return alphaSptr->Lambda6();}
1190 
1191   // Add trial functions to a BranchElemental.
1192   void resetTrialGenerators(shared_ptr<BranchElementalISR> trial);
1193 
1194   // Method to check if a gluon splitting in the initial state (to get
1195   // rid of heavy quarks) is still possible after the current
1196   // branching.
1197   bool checkHeavyQuarkPhaseSpace(vector<Particle> parts, int iSyst);
1198 
1199   // Method to check if heavy quark left after passing the evolution window.
1200   bool heavyQuarkLeft(double qTrial);
1201 
1202   // Function to ask if a system is hard.
1203   bool isSysHard(int iSys) {
1204     if (!isInit) return false;
1205     if ((int)isHardSys.size() <= iSys) return false;
1206     return isHardSys[iSys];}
1207 
1208   // Return a vector of the masses.
1209   vector<double> getMasses() {return vector<double> {mt, mtb, mb, mc, ms};}
1210 
1211   // Get number of systems.
1212   int getNsys() {return nBranchISR.size();}
1213   // Get number of branchings in a system (return -1 if no such system).
1214   int getNbranch(int iSys = -1) {
1215     int n = 0;
1216     if (iSys < 0) for (int i = 0; i < (int)nBranchISR.size(); ++i)
1217                     n += nBranchISR[iSys];
1218     else if (iSys < (int)nBranchISR.size()) n = nBranchISR[iSys];
1219     else n = -1;
1220     return n;}
1221 
1222   // Communicate information about trial showers for merging.
1223   void setIsTrialShower(bool isTrialIn){ isTrialShower = isTrialIn; }
1224   void setIsTrialShowerRes(bool isTrialIn){ isTrialShowerRes = isTrialIn; }
1225 
1226   // Save the flavour content of system in Born state
1227   // (needed for sector shower).
1228   void saveBornState(Event& born, int iSys);
1229   // Save the flavour content of Born for trial shower.
1230   void saveBornForTrialShower(Event& born);
1231 
1232   // Set verbosity level.
1233   void setVerbose(int verboseIn) {verbose = verboseIn;}
1234 
1235   // Check the antennae.
1236   bool checkAntennae(const Event& event);
1237 
1238   // Pointer to global AlphaStrong instance.
1239   AlphaStrong* alphaSptr;
1240 
1241 private:
1242 
1243   // Set starting scale of shower (power vs wimpy) for system iSys.
1244   void setStartScale(int iSys, Event& event);
1245 
1246   // Function to return headroom factor.
1247   double getHeadroomFac(int iSys, enum AntFunType antFunTypePhysIn,
1248     double qMinNow);
1249 
1250   // Generate trial branching kinematics and check physical phase space
1251   bool generateKinematics(Event& event,
1252     shared_ptr<BranchElementalISR> trialPtr, vector<Vec4>& pRec) {
1253     return ( trialPtr->isII()
1254       ? generateKinematicsII(event, trialPtr, pRec)
1255       : generateKinematicsIF(event, trialPtr, pRec) ); }
1256 
1257   // Generate kinematics (II) and set flavours and masses.
1258   bool generateKinematicsII(Event& event,
1259     shared_ptr<BranchElementalISR> trialPtr, vector<Vec4>& pRec);
1260 
1261   // Generate kinematics (IF) and set flavours and masses.
1262   bool generateKinematicsIF(Event& event,
1263     shared_ptr<BranchElementalISR> trialPtr, vector<Vec4>& pRec);
1264 
1265   // Main trial accept function.
1266   bool acceptTrial(const Event& event,
1267     shared_ptr<BranchElementalISR> winnerPtr);
1268 
1269   // Method to assign colour flow.
1270   bool assignColourFlow(Event& event, shared_ptr<BranchElementalISR> trialPtr);
1271 
1272   // Initialised.
1273   bool isInit;
1274   bool isPrepared;
1275 
1276   // Possibility to allow user veto of emission step.
1277   bool hasUserHooks, canVetoEmission;
1278 
1279   // Beams, saved as positive and negative pz respectively.
1280   int beamFrameType;
1281   double eBeamA, eBeamB, eCMBeamsSav, m2BeamsSav;
1282   double TINYPDF;
1283 
1284   // Main Vincia ISR on/off switches.
1285   bool doII, doIF, doQED;
1286 
1287   // Map of which systems ISR::prepare() has treated.
1288   map<int, bool> hasPrepared;
1289 
1290   // Shower parameters.
1291   bool helicityShower, sectorShower, convGluonToQuarkI, convQuarkToGluonI;
1292   bool kineMapIFretry;
1293   int nGluonToQuark;
1294   double cutoffScaleII, cutoffScaleIF;
1295   int nFlavZeroMass;
1296 
1297   // Shower starting-scale settings.
1298   int    pTmaxMatch{}, pTdampMatch{};
1299   double pTmaxFudge{}, pT2maxFudge{}, pT2maxFudgeMPI{}, pTdampFudge{};
1300 
1301   // AlphaS parameters.
1302   bool useCMW;
1303   int alphaSorder;
1304   double alphaSvalue, alphaSmax, alphaSmuFreeze, alphaSmuMin;
1305   double aSkMu2EmitI, aSkMu2SplitI, aSkMu2SplitF, aSkMu2Conv;
1306   double mt, mtb, ms, mb, mc;
1307   // Calculated values.
1308   double mu2freeze, mu2min;
1309 
1310   // Trial generators.
1311   TrialIISoft    trialIISoft;
1312   TrialIIGCollA  trialIIGCollA;
1313   TrialIIGCollB  trialIIGCollB;
1314   TrialIISplitA  trialIISplitA;
1315   TrialIISplitB  trialIISplitB;
1316   TrialIIConvA   trialIIConvA;
1317   TrialIIConvB   trialIIConvB;
1318   TrialIFSoft    trialIFSoft;
1319   TrialVFSoft    trialVFSoft;
1320   TrialIFGCollA  trialIFGCollA;
1321   TrialIFSplitA  trialIFSplitA;
1322   TrialIFSplitK  trialIFSplitK;
1323   TrialIFConvA   trialIFConvA;
1324 
1325   // Trial generators for the sector shower.
1326   TrialIFGCollK  trialIFGCollK;
1327 
1328   // Enhancing switches and parameters.
1329   bool enhanceInHard, enhanceInResDec, enhanceInMPI;
1330   double enhanceAll, enhanceBottom, enhanceCharm, enhanceCutoff;
1331 
1332   // Pointer to VINCIA objects.
1333   AntennaSetISR*        antSetPtr{};
1334   MECs*                 mecsPtr{};
1335   VinciaColour*         colourPtr{};
1336   Resolution*           resolutionPtr{};
1337   shared_ptr<VinciaFSR> fsrPtr{};
1338   VinciaCommon*         vinComPtr{};
1339   VinciaWeights*        weightsPtr{};
1340 
1341   // Diagnostics and Profiling.
1342   shared_ptr<VinciaDiagnostics> diagnosticsPtr;
1343 
1344   // Electroweak shower pointers.
1345   VinciaModulePtr       ewShowerPtr;
1346   VinciaModulePtr       qedShowerHardPtr;
1347   VinciaModulePtr       qedShowerSoftPtr;
1348 
1349   // Total and MEC accept probability.
1350   vector<double> Paccept;
1351 
1352   // Evolution windows.
1353   vector<double> regMinScalesMtSav;
1354   vector<double> regMinScalesSav;
1355   vector<double> regMinScalesNow;
1356 
1357   // Vector of dipoles (with trial branchings, 4 at most).
1358   vector<shared_ptr<BranchElementalISR> > branchElementals;
1359 
1360   // Current winner.
1361   shared_ptr<BranchElementalISR> winnerPtr{};
1362   int indxWin;
1363   int iSysWin;
1364   vector<Particle> stateNew;
1365   VinciaClustering minClus;
1366 
1367   // Flags to tell a few basic properties of each parton system.
1368   map<int, bool> isHardSys{}, isResonanceSys{}, polarisedSys{}, doMECsSys{};
1369 
1370   // Saved particle state and number in event record.
1371   map<int, vector< Particle > > partsSav{};
1372   map<int, vector< int      > > indexSav{};
1373 
1374   // Save initial ISR starting scale system by system.
1375   map<int, double> q2Hat{};
1376   vector<bool> doPTlimit{}, doPTdamp{};
1377   map<int, double> pT2damp{};
1378 
1379   // Count the number of branchings in the system.
1380   map<int, int> nBranch, nBranchISR;
1381 
1382   // Saved incoming guys.
1383   map<int, Particle> initialA;
1384   map<int, Particle> initialB;
1385   double eBeamAUsed, eBeamBUsed;
1386 
1387   // Count numbers of quarks and gluons.
1388   map<int, int> nG, nQQ;
1389 
1390   // Partons present in the Born (needed in sector shower).
1391   map<int, bool> savedBorn;
1392   map<int, bool> resolveBorn;
1393   map<int, map<int, int>> nFlavsBorn;
1394 
1395   // Flags used in merging
1396   bool doMerging, isTrialShower, isTrialShowerRes;
1397 
1398   // Rescue mechanism.
1399   bool doRescue;
1400   int nRescue;
1401   double rescueMin;
1402 
1403   // Verbose setting.
1404   int verbose;
1405 
1406 };
1407 
1408 //==========================================================================
1409 
1410 } // end namespace Pythia8
1411 
1412 #endif // Pythia8_VinciaISR_H