Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // VinciaCommon.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 global constants for the Vincia antenna shower as
0007 // well as various auxiliary classes used by the Vincia shower model.
0008 
0009 #ifndef Pythia8_VinciaCommon_H
0010 #define Pythia8_VinciaCommon_H
0011 
0012 // Maths headers.
0013 #include <limits>
0014 
0015 // Include Pythia 8 headers.
0016 #include "Pythia8/Event.h"
0017 #include "Pythia8/Info.h"
0018 #include "Pythia8/ParticleData.h"
0019 #include "Pythia8/PartonSystems.h"
0020 #include "Pythia8/PythiaStdlib.h"
0021 #include "Pythia8/StandardModel.h"
0022 
0023 // Global Vincia constants, defined to live in a Vincia-specific
0024 // namespace to avoid potential clashes with anything else defined in Pythia8.
0025 namespace VinciaConstants {
0026 
0027 // Global numerical precision targets (should be kept within a
0028 // reasonable margin of machine precision).  Large values may result
0029 // in strange results due to non-zero terms being artificially forced
0030 // to zero.
0031 const double UNITY = 1.0;
0032 const double DECI  = 1.0e-1;
0033 const double CENTI = 1.0e-2;
0034 const double MILLI = 1.0e-3;
0035 const double MICRO = 1.0e-6;
0036 const double NANO  = 1.0e-9;
0037 const double PICO  = 1.0e-12;
0038 
0039 // Colour factors in Vincia normalization.
0040 const double CA = 3.0;
0041 const double CF = 8.0/3.0;
0042 const double TR = 1.0;
0043 const double NC = 3.0;
0044 
0045 // Mathematical constants (Euler–Mascheroni constant).
0046 const double gammaE = 0.577215664901532860606512090082402431042;
0047 
0048 // Verbosity levels. Vincia has one more level (debug) beyond report.
0049 const int DEBUG   = 4;
0050 
0051 // Padding length for dashes in standardised Vincia verbose output.
0052 const int DASHLEN = 80;
0053 
0054 }
0055 
0056 // Everything else lives in the Pythia 8 namespace.
0057 
0058 namespace Pythia8 {
0059 
0060 // Forward declaration.
0061 class VinciaCommon;
0062 
0063 //==========================================================================
0064 
0065 // Enumerator for antenna function types, with "void" member NoFun.
0066 enum AntFunType { NoFun,
0067                   QQEmitFF, QGEmitFF, GQEmitFF, GGEmitFF, GXSplitFF,
0068                   QQEmitRF, QGEmitRF, XGSplitRF,
0069                   QQEmitII, GQEmitII, GGEmitII, QXConvII, GXConvII,
0070                   QQEmitIF, QGEmitIF, GQEmitIF, GGEmitIF, QXConvIF,
0071                   GXConvIF, XGSplitIF };
0072 
0073 //==========================================================================
0074 
0075 // Convenient typedef for unsigned integers.
0076 
0077 typedef unsigned int uint;
0078 
0079 //==========================================================================
0080 
0081 // Print a method name using the appropritae pre-processor macro.
0082 
0083 //  The following method was modified from
0084 //  boost/current_function.hpp - BOOST_CURRENT_FUNCTION
0085 //
0086 //  Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
0087 //
0088 //  Distributed under the Boost Software License, Version 1.0.
0089 //  Boost Software License - Version 1.0 - August 17th, 2003
0090 //
0091 //  Permission is hereby granted, free of charge, to any person or
0092 //  organization obtaining a copy of the software and accompanying
0093 //  documentation covered by this license (the "Software") to use,
0094 //  reproduce, display, distribute, execute, and transmit the
0095 //  Software, and to prepare derivative works of the Software, and to
0096 //  permit third-parties to whom the Software is furnished to do so,
0097 //  all subject to the following:
0098 //
0099 //  The copyright notices in the Software and this entire statement,
0100 //  including the above license grant, this restriction and the
0101 //  following disclaimer, must be included in all copies of the
0102 //  Software, in whole or in part, and all derivative works of the
0103 //  Software, unless such copies or derivative works are solely in the
0104 //  form of machine-executable object code generated by a source
0105 //  language processor.
0106 //
0107 //  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
0108 //  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
0109 //  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
0110 //  NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
0111 //  ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR
0112 //  OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING
0113 //  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0114 //  OTHER DEALINGS IN THE SOFTWARE.
0115 //
0116 //  http://www.boost.org/libs/utility/current_function.html
0117 //
0118 //  Note that Boost Software License - Version 1.0 is fully compatible
0119 //  with GPLV2
0120 //  For more information see https://www.gnu.org/licenses/license-list.en.html
0121 
0122 #ifndef __METHOD_NAME__
0123 
0124 #ifndef VINCIA_FUNCTION
0125 #if ( defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) \
0126 || (defined(__ICC) && (__ICC >= 600)) )
0127 # define VINCIA_FUNCTION __PRETTY_FUNCTION__
0128 #elif defined(__DMC__) && (__DMC__ >= 0x810)
0129 # define VINCIA_FUNCTION __PRETTY_FUNCTION__
0130 #elif defined(__FUNCSIG__)
0131 # define VINCIA_FUNCTION __FUNCSIG__
0132 #elif ( (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 600)) \
0133 || (defined(__IBMCPP__) && (__IBMCPP__ >= 500)) )
0134 # define VINCIA_FUNCTION __FUNCTION__
0135 #elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x550)
0136 # define VINCIA_FUNCTION __FUNC__
0137 #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)
0138 # define VINCIA_FUNCTION __func__
0139 #else
0140 # define VINCIA_FUNCTION "unknown"
0141 #endif
0142 #endif // end VINCIA_FUNCTION
0143 
0144 inline std::string methodName(const std::string& prettyFunction, bool
0145   withPythia=false) {
0146   size_t colons = prettyFunction.find("::");
0147   // Include Pythia8:: or not.
0148   size_t begin = colons + 2;
0149   if (withPythia) begin = prettyFunction.substr(0,colons).rfind(" ") + 1;
0150   size_t end = prettyFunction.rfind("(") - begin;
0151   return prettyFunction.substr(begin,end) + "()";
0152 }
0153 
0154 #define __METHOD_NAME__ methodName(VINCIA_FUNCTION)
0155 #endif // end __METHOD_NAME__
0156 
0157 //==========================================================================
0158 
0159 // Global functions accessible in the Vincia namespace.
0160 
0161 // Utilities for printing out VINCIA Messages.
0162 void printOut(string,string,int nPad=0,char padChar='-');
0163 
0164 // String utilities.
0165 string num2str(int,int width=4) ;
0166 string num2str(double,int width=9) ;
0167 string bool2str(bool, int width=3) ;
0168 
0169 // Search and replace a string.
0170 inline string replaceString(string subject, const string& search,
0171   const string& replace) {
0172   string::size_type pos = 0;
0173   while ((pos = subject.find(search, pos)) != string::npos) {
0174     subject.replace(pos, search.length(), replace);
0175     pos += replace.length();
0176   }
0177   return subject;
0178 
0179 }
0180 
0181 // Remove ":" and "/" from a file name.
0182 inline string sanitizeFileName(string fileName) {
0183   map<string, string> rep;
0184   rep["/"] = "_div_";
0185   rep[":"] = "_colon_";
0186   string retVal = fileName;
0187   for (map<string, string>::const_iterator it = rep.begin(); it != rep.end();
0188        ++it) {
0189     retVal = replaceString(retVal, it->first, it->second);
0190   }
0191   return retVal;
0192 
0193 }
0194 
0195 // Utility for checking if a file exists.
0196 inline bool fileExists(const std::string& name) {
0197   if (FILE *file = fopen(name.c_str(), "r")) {
0198     fclose(file);
0199     return true;
0200   } else {
0201     return false;
0202   }
0203 
0204 }
0205 
0206 //==========================================================================
0207 
0208 // A class to store and process colour information, e.g. colour maps,
0209 // reconnections, etc.
0210 
0211 class VinciaColour {
0212 
0213 public:
0214 
0215   // Initialize pointers (must be done before init).
0216   void initPtr(Info* infoPtrIn) {
0217     infoPtr       = infoPtrIn;
0218     particleDataPtr  = infoPtr->particleDataPtr;
0219     settingsPtr      = infoPtr->settingsPtr;
0220     partonSystemsPtr = infoPtr->partonSystemsPtr;
0221     rndmPtr          = infoPtr->rndmPtr;
0222     isInitPtr=true;
0223   }
0224 
0225   // Initialize.
0226   bool init();
0227 
0228   // Get translation map from ordinary Les Houches tags to antenna
0229   // indices (tags always ending on [1-9] with gluons having
0230   // non-identical colour and anticolour indices).
0231   bool colourise(int iSys, Event& event);
0232 
0233   // Method to sort list of partons in Vincia colour order. Returns
0234   // vector<int> with indices in following order:
0235   //   (1) colourless incoming particles
0236   //   (2) triplet-ngluon-antitriplet contractions
0237   //   (3) ngluon rings
0238   //   (4) colourless outgoing particles
0239   // No specific order is imposed on the relative ordering inside each
0240   // of the four classes.
0241   vector<int> colourSort(vector<Particle*>);
0242 
0243   // Method to create LC colour map and list of LC antennae.
0244   void makeColourMaps(const int iSysIn, const Event& event,
0245     map<int,int>& indexOfAcol, map<int,int>& indexOfCol,
0246     vector< pair<int,int> >& antLC, const bool findFF, const bool findIX);
0247 
0248   // Determine whether 01 or 12 inherit the colour tag from a parent.
0249   bool inherit01(double s01, double s12);
0250 
0251   // Set verbose level.
0252   void setVerbose(int verboseIn) {verbose = verboseIn;};
0253 
0254 private:
0255 
0256   // Internal parameters.
0257   int inheritMode{};
0258 
0259   // Is initialized.
0260   bool isInitPtr{false}, isInit{false};
0261 
0262   // Pointers to PYTHIA 8 objects.
0263   Info*          infoPtr;
0264   ParticleData*  particleDataPtr;
0265   Settings*      settingsPtr;
0266   PartonSystems* partonSystemsPtr;
0267   Rndm*          rndmPtr;
0268 
0269   // Verbose level.
0270   int verbose{};
0271 
0272 };
0273 
0274 //==========================================================================
0275 
0276 // Simple struct to store information about a 3 -> 2 clustering.
0277 
0278 struct VinciaClustering {
0279 
0280   // Set information about daughters from current event and daughters indices.
0281   void setDaughters(const Event& state, int dau1In, int dau2In, int dau3In);
0282   void setDaughters(const vector<Particle>& state, int dau1In, int dau2In,
0283     int dau3In);
0284 
0285   // Set mother particle ids.
0286   void setMothers(int idMot1In, int idMot2In) {
0287     idMot1 = idMot1In;
0288     idMot2 = idMot2In;
0289   }
0290 
0291   // Set antenna information.
0292   void setAntenna(bool isFSRin, enum AntFunType antFunTypeIn) {
0293     isFSR = isFSRin;
0294     antFunType = antFunTypeIn;
0295   }
0296 
0297   // Initialise vectors of invariants and masses.
0298   bool initInvariantAndMassVecs();
0299 
0300   // Set invariants and masses.
0301   void setInvariantsAndMasses(const Event& state);
0302   void setInvariantsAndMasses(const vector<Particle>& state);
0303 
0304   // Swap 1 <-> 3, including information about parents.
0305   void swap13() {
0306     swap(dau1,dau3);
0307     swap(idMot1,idMot2);
0308     swap(saj,sjb);
0309     if (mDau.size() == 3)
0310       swap(mDau[0],mDau[2]);
0311     if (mMot.size() == 2)
0312       swap(mMot[0],mMot[1]);
0313     if (invariants.size() == 3) {
0314       swap(invariants[1],invariants[2]);
0315     }
0316   }
0317 
0318   // Methods to get antenna type.
0319   bool isFF() const {
0320     if (!isFSR) return false;
0321     else if (antFunType >= QQEmitFF && antFunType < QQEmitRF) return true;
0322     else return false;
0323   }
0324   bool isRF() const {
0325     if (!isFSR) return false;
0326     else if (antFunType >= QQEmitRF && antFunType < QQEmitII) return true;
0327     else return false;
0328   }
0329   bool isII() const {
0330     if (isFSR) return false;
0331     else if (antFunType >= QQEmitII && antFunType < QQEmitIF) return true;
0332     return false;
0333   }
0334   bool isIF() const {
0335     if (isFSR) return false;
0336     else if (antFunType >= QQEmitIF) return true;
0337     else return false;
0338   }
0339   string getAntName() const;
0340 
0341   // Methods to get branching type (currently only 2 -> 3).
0342   bool is2to3() const { return true; }
0343 
0344   // Branching daughter information (indices in event record).
0345   int dau1{}, dau2{}, dau3{};
0346 
0347   // Antenna information.
0348   bool isFSR{true};
0349   AntFunType antFunType{NoFun};
0350 
0351   // Mother ids.
0352   int idMot1{}, idMot2{};
0353 
0354   // Helicities.
0355   vector<int> helDau = {9, 9, 9};
0356   vector<int> helMot = {9, 9};
0357 
0358   // Masses.
0359   vector<double> mDau;
0360   vector<double> mMot;
0361 
0362   // Invariants.
0363   double saj{}, sjb{}, sab{};
0364   // Vector of invariants (stored as sAB, saj, sjb, sab).
0365   vector<double> invariants;
0366 
0367   // Value of sector resolution variable that this clustering produces.
0368   double q2res{};
0369 
0370   // Value of evolution variable that this clustering produces.
0371   double q2evol{};
0372 
0373   // Kinematic map (only used for FF).
0374   int kMapType{};
0375 
0376 };
0377 
0378 //==========================================================================
0379 
0380 // A simple class for containing evolution variable definitions.
0381 
0382 class Resolution {
0383 
0384 public:
0385 
0386   // Initialize pointers (must be done before init).
0387   void initPtr(Settings* settingsPtrIn, Info* infoPtrIn,
0388     VinciaCommon* vinComPtrIn) {
0389     settingsPtr = settingsPtrIn;
0390     infoPtr     = infoPtrIn;
0391     loggerPtr   = infoPtrIn->loggerPtr;
0392     vinComPtr   = vinComPtrIn;
0393     isInitPtr   = true;
0394   }
0395 
0396   // Initialize.
0397   bool init();
0398 
0399   // Method to calculate (and set) evolution variable.
0400   double q2evol(VinciaClustering& clus);
0401 
0402   // Method to calculate dimensionless evolution variable.
0403   // Note: calls q2evol(), so will set dimensionful evolution
0404   // variable in the VinciaClustering object.
0405   double xTevol(VinciaClustering& clus);
0406 
0407   // Top-level function to calculate (and set) sector resolution.
0408   double q2sector(VinciaClustering& clus);
0409 
0410   // Find sector with minimal resolution.
0411   // Optionally resolve Born: avoid clusterings that would not lead
0412   // to a specified (Born) configuration.
0413   VinciaClustering findSector(vector<Particle>& state,
0414     map<int,int> flavsBorn);
0415   // Find sector with minimal resolution.
0416   // Optionally avoid sectors that cluster beyond a minimal number
0417   // of quark pairs or gluons.
0418   VinciaClustering findSector(vector<Particle>& state,
0419     int nqpMin = 0, int ngMin = 0);
0420 
0421   // Find sector with minimal q2sector in list of clusterings.
0422   VinciaClustering getMinSector(vector<VinciaClustering>& clusterings);
0423 
0424   // Sector veto to check whether given value of resolution is minimal,
0425   // given we want to preserve a certain Born configuration.
0426   // Returns true = vetoed, and false = not vetoed.
0427   bool sectorVeto(double q2In, vector<Particle>& state,
0428     map<int,int> nFlavsBorn) {
0429     VinciaClustering clusMin = findSector(state, nFlavsBorn);
0430     if (q2In > clusMin.q2res) return true;
0431     else return false;
0432   }
0433   bool sectorVeto(const VinciaClustering& clusMin,
0434     const VinciaClustering& clus);
0435 
0436   // Set verbosity level.
0437   void setVerbose(int verboseIn) {verbose = verboseIn;}
0438 
0439 private:
0440 
0441   // Member functions.
0442 
0443   // Sector resolution for 2 -> 3 branchings.
0444   double q2sector2to3FF(VinciaClustering& clus);
0445   double q2sector2to3RF(VinciaClustering& clus);
0446   double q2sector2to3IF(VinciaClustering& clus);
0447   double q2sector2to3II(VinciaClustering& clus);
0448 
0449   // Sector resolution function for 3->4 branchings (currently only
0450   // used for gluon splitting, with m2qq as the measure).
0451   //TODO: currently disabled.
0452   //   double q2sector3to4(const Particle*, const Particle*,
0453   //     const Particle* j1, const Particle* j2) {return -1.;}
0454 
0455   // Sector resolution function for 2->4 branchings (double emission).
0456   // Assume j1 and j2 are colour connected, with a and b hard
0457   // recoilers.
0458   //TODO: currently disabled.
0459   //   double q2sector2to4(const Particle* a, const Particle* b,
0460   //     const Particle* j1, const Particle* j2) {return -1.;}
0461 
0462   // Sector resolution function for 3->5 branchings (emission +
0463   // splitting).
0464   //TODO: currently disabled.
0465   //   double q2sector3to5(Particle* a, Particle* b,
0466   //     Particle* j1, Particle* j2, Particle* j3) {return -1;}
0467 
0468   // Members.
0469 
0470   // Initialized.
0471   bool isInitPtr{false}, isInit{false};
0472 
0473   // Pointer to PYTHIA 8 settings database.
0474   Settings* settingsPtr{};
0475   Info* infoPtr{};
0476   Logger* loggerPtr{};
0477 
0478   // Pointer to VinciaCommon.
0479   VinciaCommon* vinComPtr{};
0480 
0481   // Number of flavours to be treated as massless.
0482   int nFlavZeroMassSav{};
0483 
0484   // Verbosity level.
0485   int verbose{};
0486 
0487 };
0488 
0489 //==========================================================================
0490 
0491 // Class which contains functions and variables shared by the
0492 // VinciaShower and VinciaMatching classes.
0493 
0494 class VinciaCommon {
0495 
0496 public:
0497 
0498   // Initialize pointers.
0499   bool initPtr(Info* infoPtrIn) {
0500     infoPtr          = infoPtrIn;
0501     particleDataPtr  = infoPtr->particleDataPtr;
0502     settingsPtr      = infoPtr->settingsPtr;
0503     loggerPtr        = infoPtr->loggerPtr;
0504     rndmPtr          = infoPtr->rndmPtr;
0505     partonSystemsPtr = infoPtr->partonSystemsPtr;
0506     isInitPtr        = true;
0507     return true;
0508   }
0509 
0510   // Initialize data members.
0511   bool init();
0512 
0513   // Function to check for the hadronization cutoff for a colour
0514   // connected parton pair.
0515   double mHadMin(const int id1, const int id2);
0516 
0517   // Function to check the event after each branching. Added by NF to
0518   // see if certain Pythia warnings/error are caused by the shower.
0519   bool showerChecks(Event& event, bool ISR);
0520 
0521   // Function to reset counters (print once every event for now).
0522   void resetCounters() {
0523     nUnkownPDG    = 0;
0524     nIncorrectCol = 0;
0525     nNAN          = 0;
0526     nVertex       = 0;
0527     nChargeCons   = 0;
0528     nMotDau       = 0;
0529     for (int i=0; i<2; i++) {
0530       nUnmatchedMass[i] = 0;
0531       nEPcons[i]        = 0;
0532     }
0533   }
0534 
0535   // Get number of active flavors at a given Q scale.
0536   int getNf(double q) {
0537     if (q <= mc) return 3;
0538     else if (q <= mb) return 4;
0539     else if (q <= mt) return 5;
0540     else return 6;
0541   }
0542 
0543   // Get the shower starting scale.
0544   double getShowerStartingScale(int iSys, const Event& event,
0545     double sbbSav);
0546 
0547   // Method to find all possible clusterings for a given system,
0548   // given we want to resolve a certain Born configuration, i.e.,
0549   // not cluster more gluons or quark flavours as we had in the Born.
0550   vector<VinciaClustering> findClusterings(const vector<Particle>& state,
0551     map<int, int> nFlavsBorn);
0552   // Method to find all possible clusterings while retaining a certain
0553   // minimal number of quark pairs and gluons.
0554   vector<VinciaClustering> findClusterings(const vector<Particle>& state,
0555     int nqpMin = 0, int ngMin = 0);
0556 
0557   // Check if clustering is sensible, i.e., corresponds to an existing antenna.
0558   bool isValidClustering(const VinciaClustering& clus,
0559     const Event& event, int verboseIn);
0560 
0561   // Perform a clustering.
0562   bool clus3to2(const VinciaClustering& clus, const Event& event,
0563     vector<Particle>& pClustered);
0564   bool clus3to2(const VinciaClustering& clus, const vector<Particle>& state,
0565     vector<Particle>& pClustered);
0566   // Helper functions to perform clustering.
0567   bool getCols3to2(const Particle* a, const Particle* j, const Particle* b,
0568     const VinciaClustering& clus, pair<int,int>& colsA, pair<int,int>& colsB);
0569   bool getMomenta3to2(vector<Vec4>& momNow, vector<Vec4>& momClus,
0570     const VinciaClustering& clus, int iOffset = 0);
0571 
0572   // 3->2 clustering maps.
0573   bool map3to2FF(vector<Vec4>& pClu, const vector<Vec4> pIn,
0574     int kMapType, int a=0, int r=1, int b=2, double mI=0.0, double mK=0.0) {
0575     if (mI == 0. && mK == 0.)
0576       return map3to2FFmassless(pClu, pIn, kMapType, a, r, b);
0577     else
0578       return map3to2FFmassive(pClu, pIn, kMapType, mI, mK, a, r, b);
0579   }
0580   bool map3to2RF(vector<Vec4>& pClu, const vector<Vec4>& pIn, int a=0,
0581     int r=1, int b=2, double mK = 0.);
0582   bool map3to2IF(vector<Vec4>& pClu, const vector<Vec4>& pIn,
0583     int a = 0, int r = 1, int b = 2,
0584     double mj = 0., double mk = 0., double mK = 0.);
0585   bool map3to2II(vector<Vec4>& pClu, const vector<Vec4>& pIn, bool doBoost,
0586     int a = 0, int r = 2, int b = 1, double mj = 0.);
0587 
0588   // 2->3 kinematics maps for FF branchings. Original implementations;
0589   // massless by Skands, massive by Ritzmann.
0590   bool map2to3FF(vector<Vec4>& pNew, const vector<Vec4>& pOld, int kMapType,
0591     const vector<double>& invariants, double phi, vector<double> masses) {
0592     if ( masses.size() <= 2 || ( masses[0] == 0.0 && masses[1] == 0.0
0593         && masses[2] == 0.0 )) {
0594       return map2to3FFmassless(pNew, pOld, kMapType, invariants, phi);
0595     } else {
0596       return map2to3FFmassive(pNew, pOld, kMapType, invariants, phi, masses);
0597     }
0598   }
0599 
0600   // 2->3 kinematics maps for II branchings. Original implementations:
0601   // massless by Fischer, massive by Verheyen.
0602   bool map2to3II(vector<Vec4>& pNew, vector<Vec4>& pRec,
0603     vector<Vec4>& pOld, double sAB, double saj, double sjb, double sab,
0604     double phi, double m2j = 0.0) {
0605     if (m2j == 0.0)
0606       return map2to3IImassless(pNew, pRec, pOld, sAB, saj, sjb, sab, phi);
0607     else
0608       return map2to3IImassive(pNew, pRec, pOld, sAB, saj, sjb, sab, phi, m2j);
0609   }
0610 
0611   // 2->3 kinematics maps for IF branchings. General massive case
0612   // implemented by Verheyen.
0613   bool map2to3IFlocal(vector<Vec4>& pNew, const vector<Vec4>& pOld,
0614     double sOldAK, double saj, double sjk, double sak, double phi,
0615     double m2oldK, double m2j, double m2k);
0616   bool map2to3IFglobal(vector<Vec4>& pNew, vector<Vec4>& pRec,
0617     const vector<Vec4>& pOld, const Vec4 &pB,
0618     double sAK, double saj, double sjk, double sak, double phi,
0619     double mK2, double mj2, double mk2);
0620 
0621   // Resonance decay kinematic maps.
0622   bool map2toNRF(vector<Vec4>& pAfter, const vector<Vec4> pBefore,
0623     unsigned int posR, unsigned int posF,
0624     const vector<double> invariants, double phi,
0625     const vector<double> masses);
0626 
0627   // 1->2 decay map for (already offshell) resonance decay
0628   bool map1to2RF(vector<Vec4>& pNew, const Vec4 pRes, double m1,
0629     double m2, double theta, double phi);
0630 
0631   // Check if 2-particle system is on-shell and rescale if not.
0632   bool onShellCM(Vec4& p1, Vec4& p2, double m1, double m2, double tol = 1e-6);
0633 
0634   // Force initial-state and light-flavour partons to be massless.
0635   bool mapToMassless(int iSys, Event& event, bool makeNewCopies);
0636 
0637   // Map a massless antenna to equivalent massive one. Boolean
0638   // returns true if a modification was made.
0639   bool mapToMassive(Vec4& p1, Vec4& p2, double m1, double m2) {
0640     return (!onShellCM(p1,p2,m1,m2,1e-9));
0641   }
0642 
0643   // Make list of particles as vector<Particle>.
0644   //   First 1 or 2 entries : incoming particle(s).
0645   //   Subseqent entries    : outgoing particles.
0646   // The two last arguments are optional and allow to specify a list
0647   // of indices to be ignored, and a set of particles to be added, e.g.
0648   // in the context of setting up a trial state after a branching.
0649   // The newly added particles are then at the end of the respective
0650   // lists, i.e. a newly added incoming particle is the last incoming
0651   // one and newly added outgoing ones are the last among the outgoing
0652   // ones.
0653   vector<Particle> makeParticleList(const int iSys, const Event& event,
0654     const vector<Particle> &pNew = vector<Particle>(),
0655     const vector<int> &iOld = vector<int>());
0656 
0657   // Method to find all antennae that can produce a branching.
0658   //   IN: indices of clustering in event, where i2 is the emission.
0659   //  OUT: vector of VinciaClusterings.
0660   // Also swap daughters to match antenna function convention if needed
0661   // (e.g. for GXSplitFF, when dau2 and dau3 form the quark pair).
0662   vector<VinciaClustering> findAntennae(Event& state, int i1, int i2, int i3);
0663 
0664   // Check whether two particles are colour connected.
0665   bool colourConnected(const Particle& ptcl1, const Particle& ptcl2);
0666 
0667   // Print a list of Particles.
0668   void list(const vector<Particle>& state, string title = "",
0669     bool footer = true);
0670 
0671   // Print a list of VinciaClusterings.
0672   void list(const vector<VinciaClustering>& clusterings, string title = "",
0673     bool footer = true);
0674 
0675   // Get/set verbose parameter.
0676   int getVerbose() {return verbose; };
0677   void setVerbose(int verboseIn) { verbose = verboseIn;};
0678 
0679   // Public data members: strong coupling in MSbar and CMW schemes,
0680   // user and default choices,
0681   AlphaStrong alphaStrong{}, alphaStrongCMW{}, alphaStrongDef{},
0682     alphaStrongDefCMW{};
0683 
0684   // Couplings for use in merging.
0685   AlphaStrong alphaS{};
0686   AlphaEM     alphaEM{};
0687   double mu2freeze{}, mu2min{}, alphaSmax{};
0688 
0689   // Quark masses.
0690   double ms{}, mc{}, mb{}, mt{};
0691   int nFlavZeroMass{};
0692 
0693   // Checks.
0694   double epTolErr{}, epTolWarn{}, mTolErr{}, mTolWarn{};
0695 
0696 private:
0697 
0698   // Functions.
0699 
0700   // Special cases of 3 -> 2 maps.
0701   bool map3to2FFmassive(vector<Vec4>& pClu, const vector<Vec4> pIn,
0702     int kMapType, double mI, double mK, int a=0, int r=1, int b=2);
0703   bool map3to2FFmassless(vector<Vec4>& pClu, const vector<Vec4> pIn,
0704     int kMapType, int a=0, int r=1, int b=2);
0705 
0706   // Special cases of 2 -> 3 maps.
0707   bool map2to3FFmassive(vector<Vec4>& pNew, const vector<Vec4>& pOld,
0708     int kMapType, const vector<double>& invariants, double phi,
0709     vector<double> masses);
0710   bool map2to3FFmassless(vector<Vec4>& pNew, const vector<Vec4>& pOld,
0711     int kMapType, const vector<double>& invariants, double phi);
0712   bool map2to3IImassive(vector<Vec4>& pNew, vector<Vec4>& pRec,
0713     vector<Vec4>& pOld, double sAB, double saj, double sjb, double sab,
0714     double phi, double m2j = 0.0);
0715   bool map2to3IImassless(vector<Vec4>& pNew, vector<Vec4>& pRec,
0716     vector<Vec4>& pOld, double sAB, double saj, double sjb, double sab,
0717     double phi);
0718   bool map2to3RF(vector<Vec4>& pThree, const vector<Vec4> pTwo,
0719     const vector<double> invariants, double phi,
0720     const vector<double> masses);
0721 
0722   // Members.
0723 
0724   // Pointers.
0725   Info*          infoPtr{};
0726   Settings*      settingsPtr{};
0727   ParticleData*  particleDataPtr{};
0728   Rndm*          rndmPtr{};
0729   Logger*        loggerPtr{};
0730   PartonSystems* partonSystemsPtr{};
0731 
0732   // Counter for output control.
0733   int nUnkownPDG{}, nIncorrectCol{}, nNAN{}, nVertex{}, nChargeCons{},
0734     nMotDau{};
0735   vector<int> nUnmatchedMass, nEPcons;
0736 
0737   // Internal flags and settings.
0738   bool isInitPtr{false}, isInit{false};
0739   int verbose{};
0740 
0741 };
0742 
0743 //==========================================================================
0744 
0745 } // end namespace Pythia8
0746 
0747 #endif // Pythia8_VinciaCommon_H