File indexing completed on 2025-01-18 10:06:33
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef Pythia8_VinciaCommon_H
0010 #define Pythia8_VinciaCommon_H
0011
0012
0013 #include <limits>
0014
0015
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
0024
0025 namespace VinciaConstants {
0026
0027
0028
0029
0030
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
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
0046 const double gammaE = 0.577215664901532860606512090082402431042;
0047
0048
0049 const int DEBUG = 4;
0050
0051
0052 const int DASHLEN = 80;
0053
0054 }
0055
0056
0057
0058 namespace Pythia8 {
0059
0060
0061 class VinciaCommon;
0062
0063
0064
0065
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
0076
0077 typedef unsigned int uint;
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
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
0143
0144 inline std::string methodName(const std::string& prettyFunction, bool
0145 withPythia=false) {
0146 size_t colons = prettyFunction.find("::");
0147
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
0156
0157
0158
0159
0160
0161
0162 void printOut(string,string,int nPad=0,char padChar='-');
0163
0164
0165 string num2str(int,int width=4) ;
0166 string num2str(double,int width=9) ;
0167 string bool2str(bool, int width=3) ;
0168
0169
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
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
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
0209
0210
0211 class VinciaColour {
0212
0213 public:
0214
0215
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
0226 bool init();
0227
0228
0229
0230
0231 bool colourise(int iSys, Event& event);
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241 vector<int> colourSort(vector<Particle*>);
0242
0243
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
0249 bool inherit01(double s01, double s12);
0250
0251
0252 void setVerbose(int verboseIn) {verbose = verboseIn;};
0253
0254 private:
0255
0256
0257 int inheritMode{};
0258
0259
0260 bool isInitPtr{false}, isInit{false};
0261
0262
0263 Info* infoPtr;
0264 ParticleData* particleDataPtr;
0265 Settings* settingsPtr;
0266 PartonSystems* partonSystemsPtr;
0267 Rndm* rndmPtr;
0268
0269
0270 int verbose{};
0271
0272 };
0273
0274
0275
0276
0277
0278 struct VinciaClustering {
0279
0280
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
0286 void setMothers(int idMot1In, int idMot2In) {
0287 idMot1 = idMot1In;
0288 idMot2 = idMot2In;
0289 }
0290
0291
0292 void setAntenna(bool isFSRin, enum AntFunType antFunTypeIn) {
0293 isFSR = isFSRin;
0294 antFunType = antFunTypeIn;
0295 }
0296
0297
0298 bool initInvariantAndMassVecs();
0299
0300
0301 void setInvariantsAndMasses(const Event& state);
0302 void setInvariantsAndMasses(const vector<Particle>& state);
0303
0304
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
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
0342 bool is2to3() const { return true; }
0343
0344
0345 int dau1{}, dau2{}, dau3{};
0346
0347
0348 bool isFSR{true};
0349 AntFunType antFunType{NoFun};
0350
0351
0352 int idMot1{}, idMot2{};
0353
0354
0355 vector<int> helDau = {9, 9, 9};
0356 vector<int> helMot = {9, 9};
0357
0358
0359 vector<double> mDau;
0360 vector<double> mMot;
0361
0362
0363 double saj{}, sjb{}, sab{};
0364
0365 vector<double> invariants;
0366
0367
0368 double q2res{};
0369
0370
0371 double q2evol{};
0372
0373
0374 int kMapType{};
0375
0376 };
0377
0378
0379
0380
0381
0382 class Resolution {
0383
0384 public:
0385
0386
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
0397 bool init();
0398
0399
0400 double q2evol(VinciaClustering& clus);
0401
0402
0403
0404
0405 double xTevol(VinciaClustering& clus);
0406
0407
0408 double q2sector(VinciaClustering& clus);
0409
0410
0411
0412
0413 VinciaClustering findSector(vector<Particle>& state,
0414 map<int,int> flavsBorn);
0415
0416
0417
0418 VinciaClustering findSector(vector<Particle>& state,
0419 int nqpMin = 0, int ngMin = 0);
0420
0421
0422 VinciaClustering getMinSector(vector<VinciaClustering>& clusterings);
0423
0424
0425
0426
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
0437 void setVerbose(int verboseIn) {verbose = verboseIn;}
0438
0439 private:
0440
0441
0442
0443
0444 double q2sector2to3FF(VinciaClustering& clus);
0445 double q2sector2to3RF(VinciaClustering& clus);
0446 double q2sector2to3IF(VinciaClustering& clus);
0447 double q2sector2to3II(VinciaClustering& clus);
0448
0449
0450
0451
0452
0453
0454
0455
0456
0457
0458
0459
0460
0461
0462
0463
0464
0465
0466
0467
0468
0469
0470
0471 bool isInitPtr{false}, isInit{false};
0472
0473
0474 Settings* settingsPtr{};
0475 Info* infoPtr{};
0476 Logger* loggerPtr{};
0477
0478
0479 VinciaCommon* vinComPtr{};
0480
0481
0482 int nFlavZeroMassSav{};
0483
0484
0485 int verbose{};
0486
0487 };
0488
0489
0490
0491
0492
0493
0494 class VinciaCommon {
0495
0496 public:
0497
0498
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
0511 bool init();
0512
0513
0514
0515 double mHadMin(const int id1, const int id2);
0516
0517
0518
0519 bool showerChecks(Event& event, bool ISR);
0520
0521
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
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
0544 double getShowerStartingScale(int iSys, const Event& event,
0545 double sbbSav);
0546
0547
0548
0549
0550 vector<VinciaClustering> findClusterings(const vector<Particle>& state,
0551 map<int, int> nFlavsBorn);
0552
0553
0554 vector<VinciaClustering> findClusterings(const vector<Particle>& state,
0555 int nqpMin = 0, int ngMin = 0);
0556
0557
0558 bool isValidClustering(const VinciaClustering& clus,
0559 const Event& event, int verboseIn);
0560
0561
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
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
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
0589
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
0601
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
0612
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
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
0628 bool map1to2RF(vector<Vec4>& pNew, const Vec4 pRes, double m1,
0629 double m2, double theta, double phi);
0630
0631
0632 bool onShellCM(Vec4& p1, Vec4& p2, double m1, double m2, double tol = 1e-6);
0633
0634
0635 bool mapToMassless(int iSys, Event& event, bool makeNewCopies);
0636
0637
0638
0639 bool mapToMassive(Vec4& p1, Vec4& p2, double m1, double m2) {
0640 return (!onShellCM(p1,p2,m1,m2,1e-9));
0641 }
0642
0643
0644
0645
0646
0647
0648
0649
0650
0651
0652
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
0658
0659
0660
0661
0662 vector<VinciaClustering> findAntennae(Event& state, int i1, int i2, int i3);
0663
0664
0665 bool colourConnected(const Particle& ptcl1, const Particle& ptcl2);
0666
0667
0668 void list(const vector<Particle>& state, string title = "",
0669 bool footer = true);
0670
0671
0672 void list(const vector<VinciaClustering>& clusterings, string title = "",
0673 bool footer = true);
0674
0675
0676 int getVerbose() {return verbose; };
0677 void setVerbose(int verboseIn) { verbose = verboseIn;};
0678
0679
0680
0681 AlphaStrong alphaStrong{}, alphaStrongCMW{}, alphaStrongDef{},
0682 alphaStrongDefCMW{};
0683
0684
0685 AlphaStrong alphaS{};
0686 AlphaEM alphaEM{};
0687 double mu2freeze{}, mu2min{}, alphaSmax{};
0688
0689
0690 double ms{}, mc{}, mb{}, mt{};
0691 int nFlavZeroMass{};
0692
0693
0694 double epTolErr{}, epTolWarn{}, mTolErr{}, mTolWarn{};
0695
0696 private:
0697
0698
0699
0700
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
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
0723
0724
0725 Info* infoPtr{};
0726 Settings* settingsPtr{};
0727 ParticleData* particleDataPtr{};
0728 Rndm* rndmPtr{};
0729 Logger* loggerPtr{};
0730 PartonSystems* partonSystemsPtr{};
0731
0732
0733 int nUnkownPDG{}, nIncorrectCol{}, nNAN{}, nVertex{}, nChargeCons{},
0734 nMotDau{};
0735 vector<int> nUnmatchedMass, nEPcons;
0736
0737
0738 bool isInitPtr{false}, isInit{false};
0739 int verbose{};
0740
0741 };
0742
0743
0744
0745 }
0746
0747 #endif