File indexing completed on 2026-05-06 08:48:45
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef Pythia8_Pythia_H
0010 #define Pythia8_Pythia_H
0011
0012
0013 #define PYTHIA_VERSION 8.316
0014 #define PYTHIA_VERSION_INTEGER 8316
0015
0016
0017 #include "Pythia8/Analysis.h"
0018 #include "Pythia8/Basics.h"
0019 #include "Pythia8/BeamParticle.h"
0020 #include "Pythia8/BeamSetup.h"
0021 #include "Pythia8/Event.h"
0022 #include "Pythia8/FragmentationFlavZpT.h"
0023 #include "Pythia8/HadronLevel.h"
0024 #include "Pythia8/HadronWidths.h"
0025 #include "Pythia8/Info.h"
0026 #include "Pythia8/JunctionSplitting.h"
0027 #include "Pythia8/LesHouches.h"
0028 #include "Pythia8/Logger.h"
0029 #include "Pythia8/SigmaLowEnergy.h"
0030 #include "Pythia8/Merging.h"
0031 #include "Pythia8/MergingHooks.h"
0032 #include "Pythia8/PartonLevel.h"
0033 #include "Pythia8/ParticleData.h"
0034 #include "Pythia8/PartonDistributions.h"
0035 #include "Pythia8/PartonSystems.h"
0036 #include "Pythia8/PartonVertex.h"
0037 #include "Pythia8/PhysicsBase.h"
0038 #include "Pythia8/ProcessLevel.h"
0039 #include "Pythia8/PythiaStdlib.h"
0040 #include "Pythia8/ResonanceWidths.h"
0041 #include "Pythia8/RHadrons.h"
0042 #include "Pythia8/Ropewalk.h"
0043 #include "Pythia8/Settings.h"
0044 #include "Pythia8/ShowerModel.h"
0045 #include "Pythia8/SigmaTotal.h"
0046 #include "Pythia8/SimpleSpaceShower.h"
0047 #include "Pythia8/SimpleTimeShower.h"
0048 #include "Pythia8/SpaceShower.h"
0049 #include "Pythia8/StandardModel.h"
0050 #include "Pythia8/StringInteractions.h"
0051 #include "Pythia8/SusyCouplings.h"
0052 #include "Pythia8/SLHAinterface.h"
0053 #include "Pythia8/ThermalFragmentation.h"
0054 #include "Pythia8/TimeShower.h"
0055 #include "Pythia8/UserHooks.h"
0056 #include "Pythia8/VinciaCommon.h"
0057 #include "Pythia8/Weights.h"
0058
0059 namespace Pythia8 {
0060
0061
0062
0063
0064 class HeavyIons;
0065 class HIUserHooks;
0066
0067
0068 class PythiaParallel;
0069
0070
0071
0072 class Pythia {
0073
0074 public:
0075
0076
0077 Pythia(string xmlDir = "../share/Pythia8/xmldoc", bool printBanner = true);
0078
0079
0080
0081 Pythia(Settings& settingsIn, ParticleData& particleDataIn,
0082 bool printBanner = true);
0083
0084
0085 Pythia( istream& settingsStrings, istream& particleDataStrings,
0086 bool printBanner = true);
0087
0088
0089 ~Pythia() {}
0090
0091
0092 Pythia(const Pythia&) = delete;
0093 Pythia& operator=(const Pythia&) = delete;
0094
0095
0096 bool checkVersion();
0097
0098
0099 inline bool readString(string line, bool warn = true,
0100 int subrun = SUBRUNDEFAULT) {
0101 return isConstructed ? settings.readString(line, warn, subrun) : false;}
0102
0103
0104 inline bool readFile(string fileName, bool warn = true,
0105 int subrun = SUBRUNDEFAULT) {
0106 return isConstructed ? settings.readFile(fileName, warn, subrun) : false;}
0107 inline bool readFile(string fileName, int subrun) {
0108 return readFile(fileName, true, subrun);}
0109 inline bool readFile(istream& is = cin, bool warn = true,
0110 int subrun = SUBRUNDEFAULT) {
0111 return isConstructed ? settings.readFile(is, warn, subrun) : false;}
0112 inline bool readFile(istream& is, int subrun) {
0113 return readFile(is, true, subrun);}
0114
0115
0116 inline bool setPDFPtr(PDFPtr pdfAPtrIn, PDFPtr pdfBPtrIn,
0117 PDFPtr pdfHardAPtrIn = nullptr, PDFPtr pdfHardBPtrIn = nullptr,
0118 PDFPtr pdfPomAPtrIn = nullptr, PDFPtr pdfPomBPtrIn = nullptr,
0119 PDFPtr pdfGamAPtrIn = nullptr, PDFPtr pdfGamBPtrIn = nullptr,
0120 PDFPtr pdfHardGamAPtrIn = nullptr, PDFPtr pdfHardGamBPtrIn = nullptr,
0121 PDFPtr pdfUnresAPtrIn = nullptr, PDFPtr pdfUnresBPtrIn = nullptr,
0122 PDFPtr pdfUnresGamAPtrIn = nullptr, PDFPtr pdfUnresGamBPtrIn = nullptr,
0123 PDFPtr pdfVMDAPtrIn = nullptr, PDFPtr pdfVMDBPtrIn = nullptr) {
0124 return beamSetup.setPDFPtr( pdfAPtrIn, pdfBPtrIn, pdfHardAPtrIn,
0125 pdfHardBPtrIn, pdfPomAPtrIn, pdfPomBPtrIn, pdfGamAPtrIn, pdfGamBPtrIn,
0126 pdfHardGamAPtrIn, pdfHardGamBPtrIn, pdfUnresAPtrIn, pdfUnresBPtrIn,
0127 pdfUnresGamAPtrIn, pdfUnresGamBPtrIn, pdfVMDAPtrIn, pdfVMDBPtrIn); }
0128 inline bool setPDFAPtr( PDFPtr pdfAPtrIn ) {
0129 return beamSetup.setPDFAPtr( pdfAPtrIn); }
0130 inline bool setPDFBPtr( PDFPtr pdfBPtrIn ) {
0131 return beamSetup.setPDFBPtr( pdfBPtrIn); }
0132
0133
0134 inline bool setPhotonFluxPtr(PDFPtr photonFluxAIn, PDFPtr photonFluxBIn) {
0135 return beamSetup.setPhotonFluxPtr( photonFluxAIn, photonFluxBIn); }
0136
0137
0138 inline bool setLHAupPtr(LHAupPtr lhaUpPtrIn) {
0139 lhaUpPtr = lhaUpPtrIn;
0140 useNewLHA = false;
0141 return beamSetup.setLHAupPtr(lhaUpPtrIn);}
0142
0143
0144 inline bool setDecayPtr(DecayHandlerPtr decayHandlePtrIn,
0145 vector<int> handledParticlesIn = {}) {
0146 decayHandlePtr = decayHandlePtrIn;
0147 handledParticles = handledParticlesIn.size() == 0 ?
0148 decayHandlePtrIn->handledParticles() : handledParticlesIn; return true;}
0149
0150
0151 inline bool setRndmEnginePtr(RndmEnginePtr rndmEnginePtrIn) {
0152 return rndm.rndmEnginePtr(rndmEnginePtrIn);}
0153
0154
0155 inline bool setUserHooksPtr(UserHooksPtr userHooksPtrIn) {
0156 userHooksPtr = userHooksPtrIn; return true;}
0157
0158
0159 inline bool addUserHooksPtr(UserHooksPtr userHooksPtrIn) {
0160 if ( !userHooksPtrIn ) return false;
0161 if ( !userHooksPtr ) return setUserHooksPtr(userHooksPtrIn);
0162 shared_ptr<UserHooksVector> uhv =
0163 dynamic_pointer_cast<UserHooksVector>(userHooksPtr);
0164 if ( !uhv ) { uhv = make_shared<UserHooksVector>();
0165 uhv->hooks.push_back(userHooksPtr); userHooksPtr = uhv; }
0166 uhv->hooks.push_back(userHooksPtrIn); return true;}
0167
0168
0169 inline bool insertUserHooksPtr(int idx, UserHooksPtr userHooksPtrIn) {
0170 if ( !userHooksPtrIn || !userHooksPtr ) return false;
0171 shared_ptr<UserHooksVector> uhv =
0172 dynamic_pointer_cast<UserHooksVector>(userHooksPtr);
0173 if ( !uhv || idx < 0 || idx > (int)uhv->hooks.size() ) return false;
0174 uhv->hooks.insert(uhv->hooks.begin() + idx, userHooksPtrIn); return true;}
0175
0176
0177 inline bool setMergingPtr(MergingPtr mergingPtrIn) {
0178 mergingPtr = mergingPtrIn; return true;}
0179
0180
0181 inline bool setMergingHooksPtr(MergingHooksPtr mergingHooksPtrIn) {
0182 mergingHooksPtr = mergingHooksPtrIn; return true;}
0183
0184
0185 inline bool setBeamShapePtr(BeamShapePtr beamShapePtrIn) {
0186 return beamSetup.setBeamShapePtr(beamShapePtrIn);}
0187
0188
0189
0190 inline bool setSigmaPtr(SigmaProcessPtr sigmaPtrIn,
0191 PhaseSpacePtr phaseSpacePtrIn = nullptr) {
0192 sigmaPtrs.resize(0), phaseSpacePtrs.resize(0);
0193 sigmaPtrs.push_back(sigmaPtrIn);
0194 phaseSpacePtrs.push_back(phaseSpacePtrIn); return true;}
0195
0196
0197 inline bool addSigmaPtr(SigmaProcessPtr sigmaPtrIn,
0198 PhaseSpacePtr phaseSpacePtrIn = nullptr) {
0199 sigmaPtrs.push_back(sigmaPtrIn);
0200 phaseSpacePtrs.push_back(phaseSpacePtrIn); return true;}
0201
0202
0203
0204 inline bool insertSigmaPtr(int idx, SigmaProcessPtr sigmaPtrIn,
0205 PhaseSpacePtr phaseSpacePtrIn = nullptr) {
0206 if (idx < 0 || idx > (int)sigmaPtrs.size()) return false;
0207 sigmaPtrs.insert(sigmaPtrs.begin() + idx, sigmaPtrIn);
0208 phaseSpacePtrs.insert(phaseSpacePtrs.begin() + idx, phaseSpacePtrIn);
0209 return true;}
0210
0211
0212 inline bool setResonancePtr(ResonanceWidthsPtr resonancePtrIn) {
0213 resonancePtrs.resize(0);
0214 resonancePtrs.push_back( resonancePtrIn); return true;}
0215
0216
0217 inline bool addResonancePtr(ResonanceWidthsPtr resonancePtrIn) {
0218 resonancePtrs.push_back( resonancePtrIn); return true;}
0219
0220
0221 inline bool insertResonancePtr(int idx, ResonanceWidthsPtr resonancePtrIn) {
0222 if (idx < 0 || idx > (int)resonancePtrs.size()) return false;
0223 resonancePtrs.insert( resonancePtrs.begin() + idx, resonancePtrIn);
0224 return true;}
0225
0226
0227 inline bool setShowerModelPtr(ShowerModelPtr showerModelPtrIn) {
0228 showerModelPtr = showerModelPtrIn; return true;}
0229
0230
0231 inline bool setFragmentationPtr(FragmentationModelPtr fragmentationPtrIn) {
0232 fragPtrs.resize(0);
0233 fragPtrs.push_back(fragmentationPtrIn); return true;}
0234
0235
0236 inline bool addFragmentationPtr(FragmentationModelPtr fragmentationPtrIn) {
0237 fragPtrs.push_back(fragmentationPtrIn); return true;}
0238
0239
0240 inline bool insertFragmentationPtr(int idx,
0241 FragmentationModelPtr fragmentationPtrIn) {
0242 if (idx < 0 || idx > (int)fragPtrs.size()) return false;
0243 fragPtrs.insert( fragPtrs.begin() + idx, fragmentationPtrIn);
0244 return true;}
0245
0246
0247 inline bool setHeavyIonsPtr(HeavyIonsPtr heavyIonsPtrIn) {
0248 heavyIonsPtr = heavyIonsPtrIn; return true;}
0249
0250
0251
0252 inline bool setHIHooks(HIUserHooksPtr hiHooksPtrIn) {
0253 hiHooksPtr = hiHooksPtrIn; return true; }
0254
0255
0256
0257 inline HeavyIonsPtr getHeavyIonsPtr() { return heavyIonsPtr;}
0258
0259
0260 inline BeamShapePtr getBeamShapePtr() { return beamSetup.getBeamShapePtr();}
0261
0262
0263 inline ShowerModelPtr getShowerModelPtr() { return showerModelPtr;}
0264
0265
0266 inline LHAupPtr getLHAupPtr() { return lhaUpPtr;}
0267
0268
0269 inline bool setPartonVertexPtr( PartonVertexPtr partonVertexPtrIn) {
0270 partonVertexPtr = partonVertexPtrIn; return true;}
0271
0272
0273 bool init();
0274
0275
0276 inline bool next() { return next(0); }
0277 bool next(int procTypeIn);
0278
0279
0280 bool setBeamIDs( int idAin, int idBin = 0);
0281
0282
0283 bool setKinematics(double eCMIn);
0284 bool setKinematics(double eAIn, double eBIn);
0285 bool setKinematics(double pxAIn, double pyAIn, double pzAIn,
0286 double pxBIn, double pyBIn, double pzBIn);
0287 bool setKinematics(Vec4 pAIn, Vec4 pBIn);
0288
0289
0290 inline int forceTimeShower( int iBeg, int iEnd, double pTmax,
0291 int nBranchMax = 0) {
0292 if (!isInit) {
0293 logger.ERROR_MSG("Pythia is not properly initialized");
0294 return 0;
0295 }
0296 partonSystems.clear();
0297 infoPrivate.setScalup( 0, pTmax);
0298 return timesDecPtr->shower(iBeg, iEnd, event, pTmax, nBranchMax);}
0299
0300
0301 bool forceHadronLevel( bool findJunctions = true);
0302
0303
0304 bool moreDecays() {return hadronLevel.moreDecays(event);}
0305 bool moreDecays(int index) {return hadronLevel.decay(index, event);}
0306
0307
0308 bool forceRHadronDecays() {return doRHadronDecays();}
0309
0310
0311 inline bool doLowEnergyProcess(int i1, int i2, int procTypeIn) {
0312 if (!isInit) {
0313 logger.ERROR_MSG("Pythia is not properly initialized"); return false; }
0314 return hadronLevel.doLowEnergyProcess( i1, i2, procTypeIn, event); }
0315
0316
0317 inline double getSigmaTotal() {
0318 return getSigmaTotal(beamSetup.idA, beamSetup.idB, beamSetup.eCM, 0);}
0319 inline double getSigmaTotal(double eCM12, int mixLoHi = 0) {
0320 return getSigmaTotal(beamSetup.idA, beamSetup.idB, eCM12, mixLoHi);}
0321 inline double getSigmaTotal(int id1, int id2, double eCM12,
0322 int mixLoHi = 0) {
0323 return getSigmaTotal(id1, id2, eCM12, particleData.m0(id1),
0324 particleData.m0(id2), mixLoHi); }
0325 inline double getSigmaTotal(int id1, int id2, double eCM12, double m1,
0326 double m2, int mixLoHi = 0) {
0327 if (!isInit) {
0328 logger.ERROR_MSG("Pythia is not properly initialized"); return 0.; }
0329 return sigmaCmb.sigmaTotal(id1, id2, eCM12, m1, m2, mixLoHi); }
0330
0331
0332
0333 inline double getSigmaPartial(int procTypeIn) {
0334 return getSigmaPartial(beamSetup.idA, beamSetup.idB, beamSetup.eCM,
0335 procTypeIn, 0); }
0336 inline double getSigmaPartial(double eCM12, int procTypeIn,
0337 int mixLoHi = 0) {return getSigmaPartial(
0338 beamSetup.idA, beamSetup.idB, eCM12, procTypeIn, mixLoHi); }
0339 inline double getSigmaPartial(int id1, int id2, double eCM12, int procTypeIn,
0340 int mixLoHi = 0) {return getSigmaPartial(id1, id2, eCM12,
0341 particleData.m0(id1), particleData.m0(id2), procTypeIn, mixLoHi); }
0342 inline double getSigmaPartial(int id1, int id2, double eCM12, double m1,
0343 double m2, int procTypeIn, int mixLoHi = 0) {
0344 if (!isInit) {
0345 logger.ERROR_MSG("Pythia is not properly initialized"); return 0.;}
0346 return sigmaCmb.sigmaPartial(
0347 id1, id2, eCM12, m1, m2, procTypeIn, mixLoHi);}
0348
0349
0350 inline PDFPtr getPDFPtr(int idIn, int sequence = 1, string beam = "A",
0351 bool resolved = true) {
0352 return beamSetup.getPDFPtr( idIn, sequence, beam, resolved); }
0353
0354
0355 inline void LHAeventList() { if (lhaUpPtr != 0) lhaUpPtr->listEvent();}
0356
0357
0358 inline bool LHAeventSkip(int nSkip) {
0359 if (lhaUpPtr != 0) return lhaUpPtr->skipEvent(nSkip);
0360 return false;}
0361
0362
0363 void stat();
0364
0365
0366 bool flag(string key) {return settings.flag(key);}
0367 int mode(string key) {return settings.mode(key);}
0368 double parm(string key) {return settings.parm(key);}
0369 string word(string key) {return settings.word(key);}
0370
0371
0372 Event process = {};
0373
0374
0375 Event event = {};
0376
0377
0378 const Info& info = infoPrivate;
0379
0380
0381 Logger logger = {};
0382
0383
0384 Settings settings = {};
0385
0386
0387 ParticleData particleData = {};
0388
0389
0390 Rndm rndm = {};
0391
0392
0393 CoupSM coupSM = {};
0394
0395
0396 CoupSUSY coupSUSY = {};
0397
0398
0399 SLHAinterface slhaInterface = {};
0400
0401
0402 PartonSystems partonSystems = {};
0403
0404
0405 MergingPtr mergingPtr = {};
0406
0407
0408
0409 MergingHooksPtr mergingHooksPtr;
0410
0411
0412 HeavyIonsPtr heavyIonsPtr = {};
0413
0414
0415 HIUserHooksPtr hiHooksPtr = {};
0416
0417
0418 HadronWidths hadronWidths = {};
0419
0420
0421 const BeamParticle& beamA = beamSetup.beamA;
0422 const BeamParticle& beamB = beamSetup.beamB;
0423
0424 private:
0425
0426
0427 friend class PythiaParallel;
0428 friend class PhysicsBase;
0429
0430
0431
0432 WeightContainer weightContainer = {};
0433
0434
0435
0436
0437 Info infoPrivate = {};
0438
0439
0440 void initPtrs();
0441
0442
0443 void initFragPtrs();
0444
0445
0446 void initPlugins();
0447
0448
0449 void beginEvent();
0450 void endEvent(PhysicsBase::Status status);
0451
0452
0453 inline void registerPhysicsBase(PhysicsBase &pb) {
0454 if (find(physicsPtrs.begin(), physicsPtrs.end(), &pb) != physicsPtrs.end())
0455 return;
0456 pb.initInfoPtr(infoPrivate);
0457 physicsPtrs.push_back(&pb);
0458 }
0459
0460
0461
0462 void pushInfo();
0463
0464
0465 static const double VERSIONNUMBERHEAD, VERSIONNUMBERCODE;
0466
0467
0468 static const int NTRY = 10;
0469
0470
0471 string xmlPath = {};
0472 bool doProcessLevel = {}, doPartonLevel = {}, doHadronLevel = {},
0473 doLowEnergy = {}, doSoftQCDall = {}, doSoftQCDinel = {},
0474 doCentralDiff = {}, doDiffraction = {}, doSoftQCD = {},
0475 doHardDiff = {}, doResDec = {}, doFSRinRes = {}, decayRHadrons = {},
0476 doPartonVertex = {}, abortIfVeto = {}, checkEvent = {},
0477 checkHistory = {}, doNonPert = {};
0478 int nErrList = {};
0479 double epTolErr = {}, epTolWarn = {}, mTolErr = {}, mTolWarn = {};
0480
0481
0482 bool isConstructed = {}, isInit = {}, showSaV = {}, showMaD = {},
0483 doReconnect = {}, forceHadronLevelCR = {};
0484 int nCount = {}, nShowLHA = {}, nShowInfo = {}, nShowProc = {},
0485 nShowEvt = {}, reconnectMode = {};
0486
0487
0488 int nErrEvent = {};
0489 vector<int> iErrId = {}, iErrCol = {}, iErrEpm = {}, iErrNan = {},
0490 iErrNanVtx = {};
0491
0492
0493 BeamSetup beamSetup = {};
0494
0495
0496 bool doLHA = false;
0497 bool useNewLHA = false;
0498 LHAupPtr lhaUpPtr = {};
0499
0500
0501 DecayHandlerPtr decayHandlePtr = {};
0502 vector<int> handledParticles = {};
0503
0504
0505 UserHooksPtr userHooksPtr = {};
0506 bool doVetoProcess = {}, doVetoPartons = {},
0507 retryPartonLevel = {}, canVetoHadronization = {};
0508
0509
0510 BeamShapePtr beamShapePtr = {};
0511 bool doVertexSpread = {};
0512 double eMinPert = {}, eWidthPert = {};
0513
0514
0515 vector<SigmaProcessPtr> sigmaPtrs = {};
0516
0517
0518
0519 vector<PhaseSpacePtr> phaseSpacePtrs = {};
0520
0521
0522 vector<ResonanceWidthsPtr> resonancePtrs = {};
0523
0524
0525
0526
0527
0528
0529 ShowerModelPtr showerModelPtr = {};
0530 TimeShowerPtr timesDecPtr = {};
0531 TimeShowerPtr timesPtr = {};
0532 SpaceShowerPtr spacePtr = {};
0533
0534
0535 vector<FragmentationModelPtr> fragPtrs = {};
0536
0537
0538 PartonVertexPtr partonVertexPtr;
0539
0540
0541 ProcessLevel processLevel = {};
0542
0543
0544 PartonLevel partonLevel = {};
0545
0546
0547 PartonLevel trialPartonLevel = {};
0548
0549
0550 bool doMerging = {};
0551
0552
0553 StringIntPtr stringInteractionsPtr;
0554
0555
0556 ColRecPtr colourReconnectionPtr = {};
0557
0558
0559 JunctionSplitting junctionSplitting = {};
0560
0561
0562 HadronLevel hadronLevel = {};
0563
0564
0565 SigmaTotal sigmaTot = {};
0566 SigmaLowEnergy sigmaLowEnergy;
0567 NucleonExcitations nucleonExcitations = {};
0568 SigmaCombined sigmaCmb = {};
0569
0570
0571 LundFragmentationPtr fragPtr{};
0572
0573
0574 RHadronsPtr rHadronsPtr{};
0575
0576
0577 bool hasHeavyIons = {}, doHeavyIons = {};
0578
0579
0580 void banner();
0581
0582
0583 void checkSettings();
0584
0585
0586 bool nextNonPert(int procTypeIn = 0);
0587
0588
0589 bool doRHadronDecays();
0590
0591
0592 bool check();
0593
0594
0595 bool initSLHA();
0596 stringstream particleDataBuffer;
0597
0598
0599 vector<PhysicsBase*> physicsPtrs = {};
0600
0601
0602 mutex mainMutex;
0603
0604 };
0605
0606
0607
0608 }
0609
0610 #endif