8 #include "Pythia8/Pythia.h"
9 #include "Pythia8/HeavyIons.h"
26 const double Pythia::VERSIONNUMBERHEAD = PYTHIA_VERSION;
27 const double Pythia::VERSIONNUMBERCODE = 8.235;
35 const int Pythia::NTRY = 10;
38 const int Pythia::SUBRUNDEFAULT = -999;
44 Pythia::Pythia(
string xmlDir,
bool printBanner) {
53 const char* PYTHIA8DATA =
"PYTHIA8DATA";
54 char* envPath = getenv(PYTHIA8DATA);
55 if (envPath != 0 && *envPath !=
'\0') {
57 while (*(envPath+i) !=
'\0') xmlPath += *(envPath+(i++));
59 if (xmlDir[ xmlDir.length() - 1 ] !=
'/') xmlDir +=
"/";
61 ifstream xmlFile((xmlPath +
"Index.xml").c_str());
62 if (!xmlFile.good()) xmlPath = XMLDIR;
65 if (xmlPath[ xmlPath.length() - 1 ] !=
'/') xmlPath +=
"/";
68 settings.initPtr( &info);
69 string initFile = xmlPath +
"Index.xml";
70 isConstructed = settings.init( initFile);
72 info.errorMsg(
"Abort from Pythia::Pythia: settings unavailable");
77 settings.addWord(
"xmlPath", xmlPath);
80 if (!checkVersion())
return;
83 particleData.initPtr( &info, &settings, &rndm, couplingsPtr);
84 string dataFile = xmlPath +
"ParticleData.xml";
85 isConstructed = particleData.init( dataFile);
87 info.errorMsg(
"Abort from Pythia::Pythia: particle data unavailable");
92 if (printBanner) banner();
106 Pythia::Pythia(Settings& settingsIn, ParticleData& particleDataIn,
113 xmlPath = settingsIn.word(
"xmlPath");
116 settings = settingsIn;
117 settings.initPtr( &info);
118 isConstructed = settings.getIsInit();
119 if (!isConstructed) {
120 info.errorMsg(
"Abort from Pythia::Pythia: settings unavailable");
125 if (!checkVersion())
return;
128 particleData = particleDataIn;
129 particleData.initPtr( &info, &settings, &rndm, couplingsPtr);
130 isConstructed = particleData.getIsInit();
131 if (!isConstructed) {
132 info.errorMsg(
"Abort from Pythia::Pythia: particle data unavailable");
137 if (printBanner) banner();
149 Pythia::Pythia( istream& settingsStrings, istream& particleDataStrings,
156 settings.init( settingsStrings );
159 settings.initPtr( &info);
160 isConstructed = settings.getIsInit();
161 if (!isConstructed) {
162 info.errorMsg(
"Abort from Pythia::Pythia: settings unavailable");
167 if (!checkVersion())
return;
170 particleData.initPtr( &info, &settings, &rndm, couplingsPtr);
171 isConstructed = particleData.init( particleDataStrings );
172 if (!isConstructed) {
173 info.errorMsg(
"Abort from Pythia::Pythia: particle data unavailable");
178 if (printBanner) banner();
193 if (useNewPdfHard && pdfHardAPtr != pdfAPtr)
delete pdfHardAPtr;
194 if (useNewPdfHard && pdfHardBPtr != pdfBPtr)
delete pdfHardBPtr;
195 if (useNewPdfA)
delete pdfAPtr;
196 if (useNewPdfB)
delete pdfBPtr;
197 if (useNewPdfPomA)
delete pdfPomAPtr;
198 if (useNewPdfPomB)
delete pdfPomBPtr;
199 if (useNewPdfGamA)
delete pdfGamAPtr;
200 if (useNewPdfGamB)
delete pdfGamBPtr;
201 if (useNewPdfUnresA)
delete pdfUnresAPtr;
202 if (useNewPdfUnresB)
delete pdfUnresBPtr;
203 if (useNewPdfUnresGamA)
delete pdfUnresGamAPtr;
204 if (useNewPdfUnresGamB)
delete pdfUnresGamBPtr;
205 if (useNewPdfVMDA)
delete pdfVMDAPtr;
206 if (useNewPdfVMDB)
delete pdfVMDBPtr;
209 if (useNewLHA)
delete lhaUpPtr;
212 if (hasUserHooksVector)
delete userHooksPtr;
215 if (hasOwnMerging)
delete mergingPtr;
218 if (hasOwnMergingHooks)
delete mergingHooksPtr;
221 if (hasOwnHeavyIons)
delete heavyIonsPtr;
224 if (useNewBeamShape)
delete beamShapePtr;
227 if (useNewTimesDec)
delete timesDecPtr;
228 if (useNewTimes && !useNewTimesDec)
delete timesPtr;
229 if (useNewSpace)
delete spacePtr;
232 if (useNewPartonVertex)
delete partonVertexPtr;
240 void Pythia::initPtrs() {
245 useNewPdfHard =
false;
246 useNewPdfPomA =
false;
247 useNewPdfPomB =
false;
248 useNewPdfGamA =
false;
249 useNewPdfGamB =
false;
250 useNewPdfHardGamA =
false;
251 useNewPdfHardGamB =
false;
252 useNewPdfUnresA =
false;
253 useNewPdfUnresB =
false;
254 useNewPdfUnresGamA =
false;
255 useNewPdfUnresGamB =
false;
256 useNewPdfVMDA =
false;
257 useNewPdfVMDB =
false;
285 couplingsPtr = &couplings;
292 hasUserHooksVector =
false;
297 hasOwnMerging =
false;
299 hasMergingHooks =
false;
300 hasOwnMergingHooks =
false;
305 hasHeavyIons =
false;
306 hasOwnHeavyIons =
false;
311 useNewBeamShape =
false;
315 useNewTimesDec =
false;
323 useNewPartonVertex =
false;
332 bool Pythia::checkVersion() {
335 double versionNumberXML = parm(
"Pythia:versionNumber");
336 isConstructed = (abs(versionNumberXML - VERSIONNUMBERCODE) < 0.0005);
337 if (!isConstructed) {
338 ostringstream errCode;
339 errCode << fixed << setprecision(3) <<
": in code " << VERSIONNUMBERCODE
340 <<
" but in XML " << versionNumberXML;
341 info.errorMsg(
"Abort from Pythia::Pythia: unmatched version numbers",
347 isConstructed = (abs(VERSIONNUMBERHEAD - VERSIONNUMBERCODE) < 0.0005);
348 if (!isConstructed) {
349 ostringstream errCode;
350 errCode << fixed << setprecision(3) <<
": in code " << VERSIONNUMBERCODE
351 <<
" but in header " << VERSIONNUMBERHEAD;
352 info.errorMsg(
"Abort from Pythia::Pythia: unmatched version numbers",
366 bool Pythia::readString(
string line,
bool warn) {
369 if (!isConstructed)
return false;
372 if (line.find_first_not_of(
" \n\t\v\b\r\f\a") == string::npos)
return true;
375 if (settings.unfinishedInput())
return settings.readString(line, warn);
378 int firstChar = line.find_first_not_of(
" \n\t\v\b\r\f\a");
379 if (!isalnum(line[firstChar]))
return true;
382 if (isdigit(line[firstChar])) {
383 bool passed = particleData.readString(line, warn);
384 if (passed) particleDataBuffer << line << endl;
389 return settings.readString(line, warn);
397 bool Pythia::readFile(
string fileName,
bool warn,
int subrun) {
400 if (!isConstructed)
return false;
403 const char* cstring = fileName.c_str();
404 ifstream is(cstring);
406 info.errorMsg(
"Error in Pythia::readFile: did not find file", fileName);
411 return readFile( is, warn, subrun);
420 bool Pythia::readFile(istream& is,
bool warn,
int subrun) {
423 if (!isConstructed)
return false;
427 bool isCommented =
false;
428 bool accepted =
true;
429 int subrunNow = SUBRUNDEFAULT;
430 while ( getline(is, line) ) {
433 int commentLine = readCommented( line);
434 if (commentLine == +1) isCommented =
true;
435 else if (commentLine == -1) isCommented =
false;
436 else if (isCommented) ;
440 int subrunLine = readSubrun( line, warn);
441 if (subrunLine >= 0) subrunNow = subrunLine;
444 if ( (subrunNow == subrun || subrunNow == SUBRUNDEFAULT)
445 && !readString( line, warn) ) accepted =
false;
458 bool Pythia::setPDFPtr( PDF* pdfAPtrIn, PDF* pdfBPtrIn, PDF* pdfHardAPtrIn,
459 PDF* pdfHardBPtrIn, PDF* pdfPomAPtrIn, PDF* pdfPomBPtrIn,
460 PDF* pdfGamAPtrIn, PDF* pdfGamBPtrIn, PDF* pdfHardGamAPtrIn,
461 PDF* pdfHardGamBPtrIn, PDF* pdfUnresAPtrIn, PDF* pdfUnresBPtrIn,
462 PDF* pdfUnresGamAPtrIn, PDF* pdfUnresGamBPtrIn, PDF* pdfVMDAPtrIn,
466 if (useNewPdfHard && pdfHardAPtr != pdfAPtr)
delete pdfHardAPtr;
467 if (useNewPdfHard && pdfHardBPtr != pdfBPtr)
delete pdfHardBPtr;
468 if (useNewPdfA)
delete pdfAPtr;
469 if (useNewPdfB)
delete pdfBPtr;
470 if (useNewPdfPomA)
delete pdfPomAPtr;
471 if (useNewPdfPomB)
delete pdfPomBPtr;
472 if (useNewPdfGamA)
delete pdfGamAPtr;
473 if (useNewPdfGamB)
delete pdfGamBPtr;
474 if (useNewPdfUnresA)
delete pdfUnresAPtr;
475 if (useNewPdfUnresB)
delete pdfUnresBPtr;
476 if (useNewPdfUnresGamA)
delete pdfUnresGamAPtr;
477 if (useNewPdfUnresGamB)
delete pdfUnresGamBPtr;
478 if (useNewPdfHardGamA && pdfHardGamAPtr != pdfGamAPtr)
delete pdfHardGamAPtr;
479 if (useNewPdfHardGamB && pdfHardGamBPtr != pdfGamBPtr)
delete pdfHardGamBPtr;
480 if (useNewPdfVMDA)
delete pdfVMDAPtr;
481 if (useNewPdfVMDB)
delete pdfVMDBPtr;
486 useNewPdfHard =
false;
487 useNewPdfPomA =
false;
488 useNewPdfPomB =
false;
489 useNewPdfGamA =
false;
490 useNewPdfGamB =
false;
491 useNewPdfHardGamA =
false;
492 useNewPdfHardGamB =
false;
493 useNewPdfUnresA =
false;
494 useNewPdfUnresB =
false;
495 useNewPdfUnresGamA =
false;
496 useNewPdfUnresGamB =
false;
497 useNewPdfVMDA =
false;
498 useNewPdfVMDB =
false;
517 if (pdfAPtrIn == 0 && pdfBPtrIn == 0)
return true;
520 if (pdfAPtrIn == pdfBPtrIn)
return false;
527 pdfHardAPtr = pdfAPtrIn;
528 pdfHardBPtr = pdfBPtrIn;
531 if (pdfHardAPtrIn != 0 && pdfHardBPtrIn != 0) {
532 if (pdfHardAPtrIn == pdfHardBPtrIn)
return false;
533 pdfHardAPtr = pdfHardAPtrIn;
534 pdfHardBPtr = pdfHardBPtrIn;
538 if (pdfPomAPtrIn != 0 && pdfPomBPtrIn != 0) {
539 if (pdfPomAPtrIn == pdfPomBPtrIn)
return false;
540 pdfPomAPtr = pdfPomAPtrIn;
541 pdfPomBPtr = pdfPomBPtrIn;
545 if (pdfGamAPtrIn != 0 && pdfGamBPtrIn != 0) {
546 if (pdfGamAPtrIn == pdfGamBPtrIn)
return false;
547 pdfGamAPtr = pdfGamAPtrIn;
548 pdfGamBPtr = pdfGamBPtrIn;
552 if (pdfHardGamAPtrIn != 0 && pdfHardGamBPtrIn != 0) {
553 if (pdfHardGamAPtrIn == pdfHardGamBPtrIn)
return false;
554 pdfHardGamAPtr = pdfHardGamAPtrIn;
555 pdfHardGamBPtr = pdfHardGamBPtrIn;
559 if (pdfUnresAPtrIn != 0 && pdfUnresBPtrIn != 0) {
560 if (pdfUnresAPtrIn == pdfUnresBPtrIn)
return false;
561 pdfUnresAPtr = pdfUnresAPtrIn;
562 pdfUnresBPtr = pdfUnresBPtrIn;
566 if (pdfUnresGamAPtrIn != 0 && pdfUnresGamBPtrIn != 0) {
567 if (pdfUnresGamAPtrIn == pdfUnresGamBPtrIn)
return false;
568 pdfUnresGamAPtr = pdfUnresGamAPtrIn;
569 pdfUnresGamBPtr = pdfUnresGamBPtrIn;
573 if (pdfVMDAPtrIn != 0 && pdfVMDBPtrIn != 0) {
574 if (pdfVMDAPtrIn == pdfVMDBPtrIn)
return false;
575 pdfVMDAPtr = pdfVMDAPtrIn;
576 pdfVMDBPtr = pdfVMDBPtrIn;
587 bool Pythia::init() {
591 if (!isConstructed) {
592 info.errorMsg(
"Abort from Pythia::init: constructor "
593 "initialization failed");
599 settings.mode(
"HeavyIon:mode") == 2;
601 if ( !heavyIonsPtr ) {
602 heavyIonsPtr =
new Angantyr(*
this);
603 hasOwnHeavyIons =
true;
606 if ( !heavyIonsPtr->
init() ) doHeavyIons =
false;
610 doProcessLevel = settings.flag(
"ProcessLevel:all");
613 if (settings.unfinishedInput()) {
614 info.errorMsg(
"Abort from Pythia::init: opening { not matched by "
618 if (settings.readingFailed()) {
619 info.errorMsg(
"Abort from Pythia::init: some user settings "
620 "did not make sense");
623 if (particleData.readingFailed()) {
624 info.errorMsg(
"Abort from Pythia::init: some user particle data "
625 "did not make sense");
630 if ( settings.flag(
"Random:setSeed") )
631 rndm.init( settings.mode(
"Random:seed") );
635 frameType = mode(
"Beams:frameType");
638 bool doUserMerging = settings.flag(
"Merging:doUserMerging");
639 bool doMGMerging = settings.flag(
"Merging:doMGMerging");
640 bool doKTMerging = settings.flag(
"Merging:doKTMerging");
641 bool doPTLundMerging = settings.flag(
"Merging:doPTLundMerging");
642 bool doCutBasedMerging = settings.flag(
"Merging:doCutBasedMerging");
644 bool doUMEPSTree = settings.flag(
"Merging:doUMEPSTree");
645 bool doUMEPSSubt = settings.flag(
"Merging:doUMEPSSubt");
647 bool doNL3Tree = settings.flag(
"Merging:doNL3Tree");
648 bool doNL3Loop = settings.flag(
"Merging:doNL3Loop");
649 bool doNL3Subt = settings.flag(
"Merging:doNL3Subt");
651 bool doUNLOPSTree = settings.flag(
"Merging:doUNLOPSTree");
652 bool doUNLOPSLoop = settings.flag(
"Merging:doUNLOPSLoop");
653 bool doUNLOPSSubt = settings.flag(
"Merging:doUNLOPSSubt");
654 bool doUNLOPSSubtNLO = settings.flag(
"Merging:doUNLOPSSubtNLO");
655 bool doXSectionEst = settings.flag(
"Merging:doXSectionEstimate");
656 doMerging = doUserMerging || doMGMerging || doKTMerging
657 || doPTLundMerging || doCutBasedMerging || doUMEPSTree || doUMEPSSubt
658 || doNL3Tree || doNL3Loop || doNL3Subt || doUNLOPSTree
659 || doUNLOPSLoop || doUNLOPSSubt || doUNLOPSSubtNLO || doXSectionEst;
662 bool inputMergingHooks = (mergingHooksPtr != 0);
663 if (doMerging && !inputMergingHooks) {
664 if (hasOwnMergingHooks && mergingHooksPtr)
delete mergingHooksPtr;
665 mergingHooksPtr =
new MergingHooks();
666 hasOwnMergingHooks =
true;
669 hasMergingHooks = (mergingHooksPtr != 0);
672 if (doMerging && !hasMergingHooks) {
673 info.errorMsg(
"Abort from Pythia::init: "
674 "no merging hooks object has been provided");
676 }
else if (doMerging) {
677 mergingHooksPtr->setLHEInputFile(
"");
681 bool inputMerging = (mergingPtr != 0);
682 if (doMerging && !inputMerging) {
683 if (hasOwnMerging && mergingPtr)
delete mergingPtr;
684 mergingPtr =
new Merging();
685 hasOwnMerging =
true;
687 hasMerging = (mergingPtr != 0);
690 if (frameType < 4 ) {
692 boostType = frameType;
693 idA = mode(
"Beams:idA");
694 idB = mode(
"Beams:idB");
695 eCM = parm(
"Beams:eCM");
696 eA = parm(
"Beams:eA");
697 eB = parm(
"Beams:eB");
698 pxA = parm(
"Beams:pxA");
699 pyA = parm(
"Beams:pyA");
700 pzA = parm(
"Beams:pzA");
701 pxB = parm(
"Beams:pxB");
702 pyB = parm(
"Beams:pyB");
703 pzB = parm(
"Beams:pzB");
709 string lhef = word(
"Beams:LHEF");
710 string lhefHeader = word(
"Beams:LHEFheader");
711 bool readHeaders = flag(
"Beams:readLHEFheaders");
712 bool setScales = flag(
"Beams:setProductionScalesFromLHEF");
713 bool skipInit = flag(
"Beams:newLHEFsameInit");
714 int nSkipAtInit = mode(
"Beams:nSkipLHEFatInit");
717 if (frameType == 4) {
718 const char* cstring1 = lhef.c_str();
719 bool useExternal = (lhaUpPtr && !useNewLHA && lhaUpPtr->useExternal());
720 if (!useExternal && useNewLHA && skipInit)
721 lhaUpPtr->newEventFile(cstring1);
722 else if (!useExternal) {
723 if (useNewLHA)
delete lhaUpPtr;
725 const char* cstring2 = (lhefHeader ==
"void")
726 ? NULL : lhefHeader.c_str();
727 lhaUpPtr =
new LHAupLHEF(&info, cstring1, cstring2, readHeaders,
733 if (!lhaUpPtr->fileFound()) {
734 info.errorMsg(
"Abort from Pythia::init: "
735 "Les Houches Event File not found");
742 info.errorMsg(
"Abort from Pythia::init: "
743 "LHAup object not found");
748 if (!lhaUpPtr->fileFound()) {
749 info.errorMsg(
"Abort from Pythia::init: "
750 "LHAup initialisation error");
756 lhaUpPtr->setPtr( &info);
757 processLevel.setLHAPtr( lhaUpPtr);
764 if (nSkipAtInit > 0) lhaUpPtr->skipEvent(nSkipAtInit);
769 if (frameType == 4 || frameType == 5) {
773 string lhefIn = (frameType == 4) ? lhef :
"";
774 mergingHooksPtr->setLHEInputFile( lhefIn);
780 if ( !lhaUpPtr->setInit()) {
781 info.errorMsg(
"Abort from Pythia::init: "
782 "Les Houches initialization failed");
787 idA = lhaUpPtr->idBeamA();
788 idB = lhaUpPtr->idBeamB();
789 int idRenameBeams = settings.mode(
"LesHouches:idRenameBeams");
790 if (abs(idA) == idRenameBeams) idA = 16;
791 if (abs(idB) == idRenameBeams) idB = -16;
792 if (idA == 0 || idB == 0) doProcessLevel =
false;
793 eA = lhaUpPtr->eBeamA();
794 eB = lhaUpPtr->eBeamB();
797 if (nSkipAtInit > 0) lhaUpPtr->skipEvent(nSkipAtInit);
801 hasUserHooks = (userHooksPtr != 0);
802 doVetoProcess =
false;
803 doVetoPartons =
false;
804 retryPartonLevel =
false;
806 userHooksPtr->initPtr( &info, &settings, &particleData, &rndm, &beamA,
807 &beamB, &beamPomA, &beamPomB, couplingsPtr, &partonSystems, &sigmaTot);
808 if (!userHooksPtr->initAfterBeams()) {
809 info.errorMsg(
"Abort from Pythia::init: could not initialise UserHooks");
812 doVetoProcess = userHooksPtr->canVetoProcessLevel();
813 doVetoPartons = userHooksPtr->canVetoPartonLevel();
814 retryPartonLevel = userHooksPtr->retryPartonLevel();
819 info.setTooLowPTmin(
false);
823 doPartonLevel = settings.flag(
"PartonLevel:all");
824 doHadronLevel = settings.flag(
"HadronLevel:all");
825 doCentralDiff = settings.flag(
"SoftQCD:centralDiffractive");
826 doSoftQCDall = settings.flag(
"SoftQCD:all");
827 doSoftQCDinel = settings.flag(
"SoftQCD:inelastic");
828 doDiffraction = settings.flag(
"SoftQCD:singleDiffractive")
829 || settings.flag(
"SoftQCD:doubleDiffractive")
830 || doSoftQCDall || doSoftQCDinel || doCentralDiff;
831 doSoftQCD = doDiffraction ||
832 settings.flag(
"SoftQCD:nonDiffractive");
833 doHardDiff = settings.flag(
"Diffraction:doHard");
834 doResDec = settings.flag(
"ProcessLevel:resonanceDecays");
835 doFSRinRes = doPartonLevel && settings.flag(
"PartonLevel:FSR")
836 && settings.flag(
"PartonLevel:FSRinResonances");
837 decayRHadrons = settings.flag(
"RHadrons:allowDecay");
838 doMomentumSpread = settings.flag(
"Beams:allowMomentumSpread");
839 doVertexSpread = settings.flag(
"Beams:allowVertexSpread");
840 abortIfVeto = settings.flag(
"Check:abortIfVeto");
841 checkEvent = settings.flag(
"Check:event");
842 checkHistory = settings.flag(
"Check:history");
843 nErrList = settings.mode(
"Check:nErrList");
844 epTolErr = settings.parm(
"Check:epTolErr");
845 epTolWarn = settings.parm(
"Check:epTolWarn");
846 mTolErr = settings.parm(
"Check:mTolErr");
847 mTolWarn = settings.parm(
"Check:mTolWarn");
850 beamHasGamma = settings.flag(
"PDF:lepton2gamma");
851 gammaMode = settings.mode(
"Photon:ProcessType");
852 bool beamAneedResGamma = (gammaMode == 1) || (gammaMode == 2)
854 bool beamBneedResGamma = (gammaMode == 1) || (gammaMode == 3)
856 beamAisResGamma = beamAneedResGamma && idA == 22;
857 beamBisResGamma = beamBneedResGamma && idB == 22;
858 bool isChargedLeptonA = (abs(idA) == 11 || abs(idA) == 13 || abs(idA) == 15);
859 bool isChargedLeptonB = (abs(idB) == 11 || abs(idB) == 13 || abs(idB) == 15);
860 beamAhasResGamma = beamAneedResGamma && beamHasGamma && isChargedLeptonA;
861 beamBhasResGamma = beamBneedResGamma && beamHasGamma && isChargedLeptonB;
862 doVMDsideA = doSoftQCD && (beamAisResGamma || beamAhasResGamma);
863 doVMDsideB = doSoftQCD && (beamBisResGamma || beamBhasResGamma);
866 if (doVMDsideA || doVMDsideB) {
868 info.errorMsg(
"Warning in Pythia::init: "
869 "Central diffractive events not implemented for gamma + p/gamma");
873 info.errorMsg(
"Warning in Pythia::init: "
874 "Central diffractive events not implemented for gamma + p/gamma");
875 settings.flag(
"SoftQCD:all",
false);
876 settings.flag(
"SoftQCD:elastic",
true);
877 settings.flag(
"SoftQCD:nonDiffractive",
true);
878 settings.flag(
"SoftQCD:singleDiffractive",
true);
879 settings.flag(
"SoftQCD:doubleDiffractive",
true);
882 info.errorMsg(
"Warning in Pythia::init: "
883 "Central diffractive events not implemented for gamma + p/gamma");
884 settings.flag(
"SoftQCD:inelastic",
false);
885 settings.flag(
"SoftQCD:nonDiffractive",
true);
886 settings.flag(
"SoftQCD:singleDiffractive",
true);
887 settings.flag(
"SoftQCD:doubleDiffractive",
true);
892 if ( doMerging && (hasMergingHooks || hasOwnMergingHooks) ) {
893 mergingHooksPtr->initPtr( &settings, &info, &particleData, &partonSystems);
894 mergingHooksPtr->init();
901 couplingsPtr->init( settings, &rndm );
904 bool useSLHAcouplings =
false;
905 slhaInterface = SLHAinterface();
906 slhaInterface.setPtr( &info );
907 slhaInterface.init( settings, &rndm, couplingsPtr, &particleData,
908 useSLHAcouplings, particleDataBuffer );
909 if (useSLHAcouplings) couplingsPtr = slhaInterface.couplingsPtr;
912 particleData.initPtr( &info, &settings, &rndm, couplingsPtr);
913 if (hasUserHooks) userHooksPtr->initPtr( &info, &settings, &particleData,
914 &rndm, &beamA, &beamB, &beamPomA, &beamPomB, couplingsPtr,
915 &partonSystems, &sigmaTot);
918 int startColTag = settings.mode(
"Event:startColTag");
919 process.init(
"(hard process)", &particleData, startColTag);
920 event.init(
"(complete event)", &particleData, startColTag);
923 particleData.initWidths( resonancePtrs);
926 rHadrons.init( &info, settings, &particleData, &rndm);
929 if (settings.flag(
"PartonVertex:setVertex")) {
930 if (partonVertexPtr == 0) {
931 partonVertexPtr =
new PartonVertex();
932 useNewPartonVertex =
true;
934 partonVertexPtr->initPtr( &info, &settings, &rndm);
935 partonVertexPtr->init();
939 if (timesDecPtr == 0 || timesPtr == 0) {
940 TimeShower* timesNow =
new TimeShower();
941 if (timesDecPtr == 0) {
942 timesDecPtr = timesNow;
943 useNewTimesDec =
true;
951 spacePtr =
new SpaceShower();
956 timesPtr->initPtr( &info, &settings, &particleData, &rndm, couplingsPtr,
957 &partonSystems, userHooksPtr, mergingHooksPtr, partonVertexPtr);
958 timesDecPtr->initPtr( &info, &settings, &particleData, &rndm, couplingsPtr,
959 &partonSystems, userHooksPtr, mergingHooksPtr, partonVertexPtr);
960 spacePtr->initPtr( &info, &settings, &particleData, &rndm, couplingsPtr,
961 &partonSystems, userHooksPtr, mergingHooksPtr, partonVertexPtr);
964 if (beamShapePtr == 0) {
965 beamShapePtr =
new BeamShape();
966 useNewBeamShape =
true;
968 beamShapePtr->init( settings, &rndm);
972 info.errorMsg(
"Abort from Pythia::init: "
973 "checkBeams initialization failed");
978 if (!doProcessLevel) boostType = 1;
982 if (!initKinematics()) {
983 info.errorMsg(
"Abort from Pythia::init: "
984 "kinematics initialization failed");
990 info.errorMsg(
"Abort from Pythia::init: PDF initialization failed");
995 StringFlav* flavSelPtr = hadronLevel.getStringFlavPtr();
996 beamA.init( idA, pzAcm, eA, mA, &info, settings, &particleData, &rndm,
997 pdfAPtr, pdfHardAPtr, isUnresolvedA, flavSelPtr);
998 beamB.init( idB, pzBcm, eB, mB, &info, settings, &particleData, &rndm,
999 pdfBPtr, pdfHardBPtr, isUnresolvedB, flavSelPtr);
1002 if ( ( beamA.isGamma() || beamAhasResGamma )
1003 && ( gammaMode == 0 || gammaMode == 3 || gammaMode == 4 ) )
1004 beamA.initUnres( pdfUnresAPtr);
1005 if ( ( beamB.isGamma() || beamBhasResGamma )
1006 && ( gammaMode == 0 || gammaMode == 2 || gammaMode == 4 ) )
1007 beamB.initUnres( pdfUnresBPtr);
1010 if ( doDiffraction || doHardDiff ) {
1011 beamPomA.init( 990, 0.5 * eCM, 0.5 * eCM, 0., &info, settings,
1012 &particleData, &rndm, pdfPomAPtr, pdfPomAPtr,
false, flavSelPtr);
1013 beamPomB.init( 990, -0.5 * eCM, 0.5 * eCM, 0., &info, settings,
1014 &particleData, &rndm, pdfPomBPtr, pdfPomBPtr,
false, flavSelPtr);
1019 beamVMDA.init( 111, 0.5 * eCM, 0.5 * eCM, 0., &info, settings,
1020 &particleData, &rndm, pdfVMDAPtr, pdfVMDAPtr,
false, flavSelPtr);
1022 beamVMDB.init( 111, 0.5 * eCM, 0.5 * eCM, 0., &info, settings,
1023 &particleData, &rndm, pdfVMDBPtr, pdfVMDBPtr,
false, flavSelPtr);
1026 if (beamHasGamma && gammaMode < 4) {
1027 if ( !(beamA.isHadron()) )
1028 beamGamA.init( 22, 0.5 * eCM, 0.5 * eCM, 0., &info, settings,
1029 &particleData, &rndm, pdfGamAPtr, pdfHardGamAPtr, !beamAisResGamma,
1031 if ( !(beamB.isHadron()) )
1032 beamGamB.init( 22, 0.5 * eCM, 0.5 * eCM, 0., &info, settings,
1033 &particleData, &rndm, pdfGamBPtr, pdfHardGamBPtr, !beamBisResGamma,
1037 if ( gammaMode == 0 || gammaMode == 3 )
1038 beamGamA.initUnres( pdfUnresGamAPtr);
1039 if ( gammaMode == 0 || gammaMode == 2 )
1040 beamGamB.initUnres( pdfUnresGamBPtr);
1046 if ( doProcessLevel && !processLevel.init( &info, settings, &particleData,
1047 &rndm, &beamA, &beamB, &beamGamA, &beamGamB, &beamVMDA, &beamVMDB,
1048 couplingsPtr, &sigmaTot, doLHA, &slhaInterface, userHooksPtr,
1049 sigmaPtrs, phaseSpacePtrs) ) {
1050 info.errorMsg(
"Abort from Pythia::init: "
1051 "processLevel initialization failed");
1057 timesDecPtr->init( &beamA, &beamB);
1060 if ( !doProcessLevel) processLevel.initDecays( &info, settings,
1061 &particleData, &rndm, lhaUpPtr);
1064 if ( doPartonLevel && doProcessLevel && !partonLevel.init( &info, settings,
1065 &particleData, &rndm, &beamA, &beamB, &beamPomA, &beamPomB, &beamGamA,
1066 &beamGamB, &beamVMDA, &beamVMDB, couplingsPtr, &partonSystems, &sigmaTot,
1067 timesDecPtr, timesPtr, spacePtr, &rHadrons, userHooksPtr, mergingHooksPtr,
1068 partonVertexPtr,
false) ) {
1069 info.errorMsg(
"Abort from Pythia::init: "
1070 "partonLevel initialization failed" );
1075 if ( doMerging && (hasMergingHooks || hasOwnMergingHooks) )
1076 mergingHooksPtr->setShowerPointer(&partonLevel);
1079 if ( !doProcessLevel || !doPartonLevel) partonLevel.init( &info, settings,
1080 &particleData, &rndm, 0, 0, 0, 0, 0, 0, 0, 0, couplingsPtr, &partonSystems,
1081 0, timesDecPtr, 0, 0, &rHadrons, 0, 0, partonVertexPtr,
false);
1084 if ( doMerging && !trialPartonLevel.init( &info, settings, &particleData,
1085 &rndm, &beamA, &beamB, &beamPomA, &beamPomB, &beamGamA, &beamGamB,
1086 &beamVMDA, &beamVMDB, couplingsPtr, &partonSystems, &sigmaTot,
1087 timesDecPtr, timesPtr, spacePtr, &rHadrons, userHooksPtr,
1088 mergingHooksPtr, partonVertexPtr,
true) ) {
1089 info.errorMsg(
"Abort from Pythia::init: "
1090 "trialPartonLevel initialization failed");
1096 mergingPtr->initPtr( &settings, &info, &particleData, &rndm,
1097 &beamA, &beamB, mergingHooksPtr, &trialPartonLevel, couplingsPtr );
1103 if ( !hadronLevel.init( &info, settings, &particleData, &rndm,
1104 couplingsPtr, timesDecPtr, &rHadrons, decayHandlePtr,
1105 handledParticles, userHooksPtr) ) {
1106 info.errorMsg(
"Abort from Pythia::init: "
1107 "hadronLevel initialization failed");
1112 if ( settings.flag(
"Check:particleData") )
1113 particleData.checkTable( settings.mode(
"Check:levelParticleData") );
1116 bool showCS = settings.flag(
"Init:showChangedSettings");
1117 bool showAS = settings.flag(
"Init:showAllSettings");
1118 bool showCPD = settings.flag(
"Init:showChangedParticleData");
1119 bool showCRD = settings.flag(
"Init:showChangedResonanceData");
1120 bool showAPD = settings.flag(
"Init:showAllParticleData");
1121 int show1PD = settings.mode(
"Init:showOneParticleData");
1122 bool showPro = settings.flag(
"Init:showProcesses");
1123 if (showCS) settings.listChanged();
1124 if (showAS) settings.listAll();
1125 if (show1PD > 0) particleData.list(show1PD);
1126 if (showCPD) particleData.listChanged(showCRD);
1127 if (showAPD) particleData.listAll();
1130 nCount = settings.mode(
"Next:numberCount");
1131 nShowLHA = settings.mode(
"Next:numberShowLHA");
1132 nShowInfo = settings.mode(
"Next:numberShowInfo");
1133 nShowProc = settings.mode(
"Next:numberShowProcess");
1134 nShowEvt = settings.mode(
"Next:numberShowEvent");
1135 showSaV = settings.flag(
"Next:showScaleAndVertex");
1136 showMaD = settings.flag(
"Next:showMothersAndDaughters");
1139 colourReconnection.init( &info, settings, &rndm, &particleData,
1140 &beamA, &beamB, &partonSystems);
1141 junctionSplitting.init(&info, settings, &rndm, &particleData);
1144 doReconnect = settings.flag(
"ColourReconnection:reconnect");
1145 reconnectMode = settings.mode(
"ColourReconnection:mode");
1146 forceHadronLevelCR = settings.flag(
"ColourReconnection:forceHadronLevelCR");
1151 if (useNewLHA && showPro) lhaUpPtr->listInit();
1160 void Pythia::checkSettings() {
1163 if ((settings.flag(
"PartonLevel:ISR") || settings.flag(
"PartonLevel:FSR"))
1164 && settings.flag(
"MultipartonInteractions:allowDoubleRescatter")) {
1165 info.errorMsg(
"Warning in Pythia::checkSettings: "
1166 "double rescattering switched off since showering is on");
1167 settings.flag(
"MultipartonInteractions:allowDoubleRescatter",
false);
1171 if ( (idA == 22 && !beamAisResGamma) || (idB == 22 && !beamBisResGamma) ) {
1174 if ( settings.flag(
"PartonLevel:MPI") ) {
1175 info.errorMsg(
"Warning in Pythia::checkSettings: "
1176 "MPIs turned off for collision with unresolved photon");
1177 settings.flag(
"PartonLevel:MPI",
false);
1181 if ( settings.flag(
"SoftQCD:nonDiffractive") ) {
1182 info.errorMsg(
"Warning in Pythia::checkSettings: "
1183 "Soft QCD processes turned off for collision with unresolved photon");
1184 settings.flag(
"SoftQCD:nonDiffractive",
false);
1190 if ( ( (abs(idA) > 10 && abs(idA) < 17)
1191 && !beamAhasResGamma && beamHasGamma)
1192 || ( (abs(idB) > 10 && abs(idB) < 17)
1193 && !beamBhasResGamma && beamHasGamma) ) {
1196 if ( settings.flag(
"PartonLevel:MPI") ) {
1197 info.errorMsg(
"Warning in Pythia::checkSettings: MPIs turned off for "
1198 "collision with unresolved photon");
1199 settings.flag(
"PartonLevel:MPI",
false);
1203 if ( settings.flag(
"SoftQCD:nonDiffractive") ) {
1204 info.errorMsg(
"Warning in Pythia::checkSettings: "
1205 "Soft QCD processes turned off for collision with unresolved photon");
1206 settings.flag(
"SoftQCD:nonDiffractive",
false);
1217 bool Pythia::checkBeams() {
1220 int idAabs = abs(idA);
1221 int idBabs = abs(idB);
1222 if (!doProcessLevel)
return true;
1225 bool isLeptonA = (idAabs > 10 && idAabs < 17);
1226 bool isLeptonB = (idBabs > 10 && idBabs < 17);
1227 bool isUnresLep = !settings.flag(
"PDF:lepton");
1228 bool isGammaA = idAabs == 22;
1229 bool isGammaB = idBabs == 22;
1230 isUnresolvedA = ( isLeptonA && (idAabs%2 == 0 || isUnresLep) );
1231 isUnresolvedB = ( isLeptonB && (idBabs%2 == 0 || isUnresLep) );
1234 if ( idAabs == 22 && !beamAisResGamma ) isUnresolvedA =
true;
1235 if ( idBabs == 22 && !beamBisResGamma ) isUnresolvedB =
true;
1238 if ( beamAhasResGamma ) isUnresolvedA =
false;
1239 if ( beamBhasResGamma ) isUnresolvedB =
false;
1242 if (idAabs > 50 && idAabs < 61) isLeptonA = isUnresolvedA =
true;
1243 if (idBabs > 50 && idBabs < 61) isLeptonB = isUnresolvedB =
true;
1246 if (isLeptonA && isLeptonB ) {
1252 if ( (!beamAhasResGamma || !beamBhasResGamma)
1253 && settings.flag(
"SoftQCD:nonDiffractive") ) {
1254 info.errorMsg(
"Error in Pythia::init: Soft QCD only with resolved"
1255 " photons with lepton beams.");
1264 else if (isUnresolvedA == isUnresolvedB)
return true;
1268 int PomFlux = settings.mode(
"SigmaDiffractive:PomFlux");
1270 bool ispp = (idAabs == 2212 && idBabs == 2212);
1271 bool ispbarpbar = (idA == -2212 && idB == -2212);
1272 if (ispp && !ispbarpbar)
return true;
1273 info.errorMsg(
"Error in Pythia::init: cannot handle this beam combination"
1274 " with PomFlux == 5");
1279 bool isHadronA = (idAabs == 2212) || (idAabs == 2112) || (idA == 111)
1280 || (idAabs == 211) || (idA == 990);
1281 bool isHadronB = (idBabs == 2212) || (idBabs == 2112) || (idB == 111)
1282 || (idBabs == 211) || (idB == 990);
1283 int modeUnresolvedHadron = settings.mode(
"BeamRemnants:unresolvedHadron");
1284 if (isHadronA && modeUnresolvedHadron%2 == 1) isUnresolvedA =
true;
1285 if (isHadronB && modeUnresolvedHadron > 1) isUnresolvedB =
true;
1286 if (isHadronA && isHadronB) {
1289 info.errorMsg(
"Error in Pythia::init: lepton2gamma should be off for"
1290 " hadron+hadron collision");
1298 if ( (idAabs == 22) && (idBabs == 22) ) {
1301 if ( ( !beamAisResGamma || !beamBisResGamma )
1302 && settings.flag(
"SoftQCD:nonDiffractive") ) {
1303 info.errorMsg(
"Error in Pythia::init: Soft QCD only with resolved"
1309 info.errorMsg(
"Error in Pythia::init: lepton2gamma should be off for"
1310 " hadron+hadron collision");
1319 if ( (isGammaA && isHadronB) || (isGammaB && isHadronA) )
1324 if ( (isLeptonA && isHadronB) || (isHadronA && isLeptonB) ) {
1325 bool doDIS = settings.flag(
"WeakBosonExchange:all")
1326 || settings.flag(
"WeakBosonExchange:ff2ff(t:gmZ)")
1327 || settings.flag(
"WeakBosonExchange:ff2ff(t:W)")
1328 || (frameType == 4);
1329 if (doDIS || beamHasGamma )
return true;
1333 info.errorMsg(
"Error in Pythia::init: cannot handle this beam combination");
1342 bool Pythia::initKinematics() {
1345 mA = particleData.m0(idA);
1346 mB = particleData.m0(idB);
1351 if (boostType == 2) {
1354 pzA = sqrt(eA*eA - mA*mA);
1355 pzB = -sqrt(eB*eB - mB*mB);
1356 pAinit = Vec4( 0., 0., pzA, eA);
1357 pBinit = Vec4( 0., 0., pzB, eB);
1358 eCM = sqrt( pow2(eA + eB) - pow2(pzA + pzB) );
1361 betaZ = (pzA + pzB) / (eA + eB);
1362 gammaZ = (eA + eB) / eCM;
1363 if (abs(betaZ) < 1e-10) boostType = 1;
1367 else if (boostType == 3) {
1368 eA = sqrt( pxA*pxA + pyA*pyA + pzA*pzA + mA*mA);
1369 eB = sqrt( pxB*pxB + pyB*pyB + pzB*pzB + mB*mB);
1370 pAinit = Vec4( pxA, pyA, pzA, eA);
1371 pBinit = Vec4( pxB, pyB, pzB, eB);
1372 eCM = (pAinit + pBinit).mCalc();
1376 MfromCM.fromCMframe( pAinit, pBinit);
1382 if (eCM < mA + mB) {
1383 info.errorMsg(
"Error in Pythia::initKinematics: too low energy");
1388 pzAcm = 0.5 * sqrtpos( (eCM + mA + mB) * (eCM - mA - mB)
1389 * (eCM - mA + mB) * (eCM + mA - mB) ) / eCM;
1391 eA = sqrt(mA*mA + pzAcm*pzAcm);
1392 eB = sqrt(mB*mB + pzBcm*pzBcm);
1395 if (boostType != 2 && boostType != 3) {
1396 pAinit = Vec4( 0., 0., pzAcm, eA);
1397 pBinit = Vec4( 0., 0., pzBcm, eB);
1401 info.setBeamA( idA, pzAcm, eA, mA);
1402 info.setBeamB( idB, pzBcm, eB, mB);
1406 if (doMomentumSpread) boostType = 3;
1417 bool Pythia::initPDFs() {
1420 if (useNewPdfHard) {
1421 if (pdfHardAPtr != pdfAPtr) {
1425 if (pdfHardBPtr != pdfBPtr) {
1429 useNewPdfHard =
false;
1441 if (useNewPdfPomA) {
1443 useNewPdfPomA =
false;
1446 if (useNewPdfPomB) {
1448 useNewPdfPomB =
false;
1451 if (useNewPdfGamA) {
1453 useNewPdfGamA =
false;
1456 if (useNewPdfGamB) {
1458 useNewPdfGamB =
false;
1461 if (useNewPdfHardGamA) {
1462 delete pdfHardGamAPtr;
1463 useNewPdfHardGamA =
false;
1466 if (useNewPdfHardGamB) {
1467 delete pdfHardGamBPtr;
1468 useNewPdfHardGamB =
false;
1471 if (useNewPdfUnresA) {
1472 delete pdfUnresAPtr;
1473 useNewPdfUnresA =
false;
1476 if (useNewPdfUnresB) {
1477 delete pdfUnresBPtr;
1478 useNewPdfUnresB =
false;
1481 if (useNewPdfUnresGamA) {
1482 delete pdfUnresGamAPtr;
1483 useNewPdfUnresGamA =
false;
1484 pdfUnresGamAPtr = 0;
1486 if (useNewPdfUnresGamB) {
1487 delete pdfUnresGamBPtr;
1488 useNewPdfUnresGamB =
false;
1489 pdfUnresGamBPtr = 0;
1491 if (useNewPdfVMDA) {
1493 useNewPdfVMDA =
false;
1496 if (useNewPdfVMDB) {
1498 useNewPdfVMDB =
false;
1505 bool setupGammaBeams = (settings.flag(
"PDF:lepton2gamma")
1506 && (gammaMode < 4) );
1507 if (setupGammaBeams) {
1508 if ( (abs(idA) == 11 || abs(idA) == 13 || abs(idA) == 15)
1509 && pdfGamAPtr == 0 ) {
1510 pdfGamAPtr = getPDFPtr(22, 1,
"A");
1511 if (!pdfGamAPtr->isSetup())
return false;
1512 useNewPdfGamA =
true;
1515 if (gammaMode != 1) {
1516 pdfUnresGamAPtr = getPDFPtr(22, 1,
"A",
false);
1517 if (!pdfUnresGamAPtr->isSetup())
return false;
1518 useNewPdfUnresGamA =
true;
1522 if (settings.flag(
"PDF:useHard")) {
1523 pdfHardGamAPtr = getPDFPtr(22, 2);
1524 if (!pdfHardGamAPtr->isSetup())
return false;
1525 useNewPdfHardGamA =
true;
1526 }
else pdfHardGamAPtr = pdfGamAPtr;
1528 if ( (abs(idB) == 11 || abs(idB) == 13 || abs(idB) == 15)
1529 && pdfGamBPtr == 0 ) {
1530 pdfGamBPtr = getPDFPtr(22, 1,
"B");
1531 if (!pdfGamBPtr->isSetup())
return false;
1532 useNewPdfGamB =
true;
1535 if (gammaMode != 1) {
1536 pdfUnresGamBPtr = getPDFPtr(22, 1,
"B",
false);
1537 if (!pdfUnresGamBPtr->isSetup())
return false;
1538 useNewPdfUnresGamB =
true;
1542 if (settings.flag(
"PDF:useHard")) {
1543 pdfHardGamBPtr = getPDFPtr(22, 2,
"B");
1544 if (!pdfHardGamBPtr->isSetup())
return false;
1545 useNewPdfHardGamB =
true;
1546 }
else pdfHardGamBPtr = pdfGamBPtr;
1552 pdfAPtr = getPDFPtr(idA);
1553 if (pdfAPtr == 0 || !pdfAPtr->isSetup()) {
1554 info.errorMsg(
"Error in Pythia::init: "
1555 "could not set up PDF for beam A");
1558 pdfHardAPtr = pdfAPtr;
1562 pdfBPtr = getPDFPtr(idB, 1,
"B");
1563 if (pdfBPtr == 0 || !pdfBPtr->isSetup()) {
1564 info.errorMsg(
"Error in Pythia::init: "
1565 "could not set up PDF for beam B");
1568 pdfHardBPtr = pdfBPtr;
1573 if (settings.flag(
"PDF:useHard") && useNewPdfA && useNewPdfB) {
1574 pdfHardAPtr = getPDFPtr(idA, 2);
1575 if (!pdfHardAPtr->isSetup())
return false;
1576 pdfHardBPtr = getPDFPtr(idB, 2,
"B");
1577 if (!pdfHardBPtr->isSetup())
return false;
1578 useNewPdfHard =
true;
1582 if (settings.flag(
"PDF:useHardNPDFA")) {
1583 int idANucleus = settings.mode(
"PDF:nPDFBeamA");
1584 pdfHardAPtr = getPDFPtr(idANucleus, 2,
"A");
1585 if (!pdfHardAPtr->isSetup()) {
1586 info.errorMsg(
"Error in Pythia::init: "
1587 "could not set up nuclear PDF for beam A");
1590 useNewPdfHard =
true;
1592 if (settings.flag(
"PDF:useHardNPDFB")) {
1593 int idBNucleus = settings.mode(
"PDF:nPDFBeamB");
1594 pdfHardBPtr = getPDFPtr(idBNucleus, 2,
"B");
1595 if (!pdfHardBPtr->isSetup()) {
1596 info.errorMsg(
"Error in Pythia::init: "
1597 "could not set up nuclear PDF for beam B");
1600 useNewPdfHard =
true;
1604 if ( (idA == 22 || idB == 22) && gammaMode != 1 ) {
1605 if ( idA == 22 && pdfUnresAPtr == 0 ) {
1606 pdfUnresAPtr = getPDFPtr(idA, 1,
"A",
false);
1607 if (!pdfUnresAPtr->isSetup())
return false;
1608 useNewPdfUnresA =
true;
1610 if ( idB == 22 && pdfUnresBPtr == 0 ) {
1611 pdfUnresBPtr = getPDFPtr(idB, 1,
"B",
false);
1612 if (!pdfUnresBPtr->isSetup())
return false;
1613 useNewPdfUnresB =
true;
1618 if ( (abs(idA) == 11 || abs(idA) == 13 || abs(idA) == 15)
1619 && beamHasGamma && gammaMode != 1 ) {
1620 if ( pdfUnresAPtr == 0 ) {
1621 pdfUnresAPtr = getPDFPtr(idA, 1,
"A",
false);
1622 if (!pdfUnresAPtr->isSetup())
return false;
1623 useNewPdfUnresA =
true;
1626 if ( (abs(idB) == 11 || abs(idB) == 13 || abs(idB) == 15)
1627 && beamHasGamma && gammaMode != 1 ) {
1628 if ( pdfUnresBPtr == 0 ) {
1629 pdfUnresBPtr = getPDFPtr(idB, 1,
"B",
false);
1630 if (!pdfUnresBPtr->isSetup())
return false;
1631 useNewPdfUnresB =
true;
1636 if ( doDiffraction || doHardDiff) {
1637 if (pdfPomAPtr == 0) {
1638 pdfPomAPtr = getPDFPtr(990);
1639 useNewPdfPomA =
true;
1641 if (pdfPomBPtr == 0) {
1642 pdfPomBPtr = getPDFPtr(990);
1643 useNewPdfPomB =
true;
1648 if ( doSoftQCD && (doVMDsideA || doVMDsideB)) {
1649 if (pdfVMDAPtr == 0) {
1650 pdfVMDAPtr = getPDFPtr(111);
1651 useNewPdfVMDA =
true;
1653 if (pdfVMDBPtr == 0) {
1654 pdfVMDBPtr = getPDFPtr(111);
1655 useNewPdfVMDB =
true;
1668 bool Pythia::next() {
1671 if (!isConstructed)
return false;
1676 if ( doHeavyIons ) {
1677 doHeavyIons =
false;
1678 bool ok = heavyIonsPtr->
next();
1684 int nPrevious = info.getCounter(3);
1685 if (nCount > 0 && nPrevious > 0 && nPrevious%nCount == 0)
1686 cout <<
"\n Pythia::next(): " << nPrevious
1687 <<
" events have been generated " << endl;
1691 for (
int i = 10; i < 13; ++i) info.setCounter(i);
1694 if (!doProcessLevel) {
1697 if (doLHA && !processLevel.nextLHAdec( event)) {
1698 if (info.atEndOfFile()) info.errorMsg(
"Abort from Pythia::next:"
1699 " reached end of Les Houches Events File");
1705 partonSystems.clear();
1709 for (
int i = 1; i <
event.size(); ++i)
1710 if (event[i].isFinal()) pSum += event[i].p();
1712 event[0].m( pSum.mCalc() );
1715 bool status = forceHadronLevel();
1716 if (status) info.addCounter(4);
1717 if (status && nPrevious < nShowEvt)
event.list(showSaV, showMaD);
1725 partonSystems.clear();
1736 beamA.newValenceContent();
1737 beamB.newValenceContent();
1738 if ( doDiffraction || doHardDiff) {
1739 beamPomA.newValenceContent();
1740 beamPomB.newValenceContent();
1742 if (doVMDsideA) beamVMDA.newValenceContent();
1743 if (doVMDsideB) beamVMDB.newValenceContent();
1747 info.errorMsg(
"Abort from Pythia::next: "
1748 "not properly initialized so cannot generate events");
1753 if (doMomentumSpread || doVertexSpread) beamShapePtr->pick();
1756 if (doMomentumSpread) nextKinematics();
1761 info.addCounter(10);
1762 bool hasVetoed =
false;
1763 bool hasVetoedDiff =
false;
1768 partonSystems.clear();
1772 info.setLHEF3EventInfo();
1774 if ( !processLevel.next( process) ) {
1775 if (doLHA && info.atEndOfFile()) info.errorMsg(
"Abort from "
1776 "Pythia::next: reached end of Les Houches Events File");
1777 else info.errorMsg(
"Abort from Pythia::next: "
1778 "processLevel failed; giving up");
1782 info.addCounter(11);
1786 processLevel.accumulate(
false);
1789 if (doVetoProcess) {
1790 hasVetoed = userHooksPtr->doVetoProcessLevel( process);
1792 if (abortIfVeto)
return false;
1799 int veto = mergingPtr->mergeProcess( process );
1803 if (abortIfVeto)
return false;
1806 }
else if (veto == 0) {
1813 if (veto == 2 && doResDec) processLevel.nextDecays( process);
1817 if (!doPartonLevel) {
1818 boostAndVertex(
true,
true);
1819 processLevel.accumulate();
1821 if (doLHA && nPrevious < nShowLHA) lhaUpPtr->listEvent();
1822 if (nPrevious < nShowInfo) info.list();
1823 if (nPrevious < nShowProc) process.list(showSaV, showMaD);
1828 Event processSave = process;
1829 int sizeMPI = info.sizeMPIarrays();
1830 info.addCounter(12);
1831 for (
int i = 14; i < 19; ++i) info.setCounter(i);
1834 bool physical =
true;
1835 for (
int iTry = 0; iTry < NTRY; ++iTry) {
1837 info.addCounter(14);
1842 if (iTry > 0) process = processSave;
1843 if (iTry > 0) info.resizeMPIarrays( sizeMPI);
1855 partonSystems.clear();
1858 if ( !partonLevel.next( process, event) ) {
1861 if (info.getAbortPartonLevel())
return false;
1865 hasVetoed = partonLevel.hasVetoed();
1867 if (retryPartonLevel) {
1871 if (abortIfVeto)
return false;
1876 hasVetoedDiff = partonLevel.hasVetoedDiff();
1877 if (hasVetoedDiff) {
1878 info.errorMsg(
"Warning in Pythia::next: "
1879 "discarding hard diffractive event from partonLevel; try again");
1884 info.errorMsg(
"Error in Pythia::next: "
1885 "partonLevel failed; try again");
1889 info.addCounter(15);
1892 if (doVetoPartons) {
1893 hasVetoed = userHooksPtr->doVetoPartonLevel( event);
1895 if (abortIfVeto)
return false;
1901 boostAndVertex(
true,
true);
1904 if (!doHadronLevel) {
1905 processLevel.accumulate();
1906 partonLevel.accumulate();
1908 if (checkEvent && !check()) {
1909 info.errorMsg(
"Abort from Pythia::next: "
1910 "check of event revealed problems");
1914 if (doLHA && nPrevious < nShowLHA) lhaUpPtr->listEvent();
1915 if (nPrevious < nShowInfo) info.list();
1916 if (nPrevious < nShowProc) process.list(showSaV, showMaD);
1917 if (nPrevious < nShowEvt)
event.list(showSaV, showMaD);
1922 info.addCounter(16);
1923 if ( !hadronLevel.next( event) ) {
1924 info.errorMsg(
"Error in Pythia::next: "
1925 "hadronLevel failed; try again");
1931 if (decayRHadrons && rHadrons.exist() && !doRHadronDecays()) {
1932 info.errorMsg(
"Error in Pythia::next: "
1933 "decayRHadrons failed; try again");
1937 info.addCounter(17);
1940 if (checkEvent && !check()) {
1941 info.errorMsg(
"Error in Pythia::next: "
1942 "check of event revealed problems");
1948 info.addCounter(18);
1953 if (hasVetoed || hasVetoedDiff) {
1954 if (abortIfVeto)
return false;
1960 info.errorMsg(
"Abort from Pythia::next: "
1961 "parton+hadronLevel failed; giving up");
1966 processLevel.accumulate();
1967 partonLevel.accumulate();
1968 event.scale( process.scale() );
1971 info.addCounter(13);
1976 if (doLHA && nPrevious < nShowLHA) lhaUpPtr->listEvent();
1977 if (nPrevious < nShowInfo) info.list();
1978 if (nPrevious < nShowProc) process.list(showSaV,showMaD);
1979 if (nPrevious < nShowEvt)
event.list(showSaV, showMaD);
1992 bool Pythia::forceHadronLevel(
bool findJunctions) {
1996 info.errorMsg(
"Abort from Pythia::forceHadronLevel: "
1997 "not properly initialized so cannot generate events");
2003 if (findJunctions) {
2004 event.clearJunctions();
2005 for (
int i = 0; i <
event.size(); ++i)
2006 if (event[i].isFinal()
2007 && (
event[i].col() != 0 ||
event[i].acol() != 0)) {
2008 processLevel.findJunctions( event);
2014 if (forceHadronLevelCR) {
2018 if (reconnectMode == 3 || reconnectMode == 4) {
2019 partonSystems.clear();
2020 partonSystems.addSys();
2021 partonSystems.addSys();
2022 for (
int i = 5;i <
event.size();++i) {
2023 if (event[i].mother1() - 3 < 0 ||
event[i].mother1() - 3 > 1) {
2024 info.errorMsg(
"Error in Pythia::forceHadronLevel: "
2025 " Event is not setup correctly for SK-I or SK-II CR");
2028 partonSystems.addOut(event[i].mother1() - 3,i);
2033 Event spareEvent = event;
2034 bool colCorrect =
false;
2037 for (
int iTry = 0; iTry < NTRY; ++ iTry) {
2038 colourReconnection.next(event, 0);
2039 if (junctionSplitting.checkColours(event)) {
2043 else event = spareEvent;
2047 info.errorMsg(
"Error in Pythia::forceHadronLevel: "
2048 "Colour reconnection failed.");
2054 Event spareEvent = event;
2057 bool physical =
true;
2058 for (
int iTry = 0; iTry < NTRY; ++ iTry) {
2064 processLevel.nextDecays( process);
2067 if (process.size() >
event.size()) {
2069 partonLevel.setupShowerSys( process, event);
2070 partonLevel.resonanceShowers( process, event,
false);
2071 }
else event = process;
2076 if (hadronLevel.next( event))
break;
2079 info.errorMsg(
"Error in Pythia::forceHadronLevel: "
2080 "hadronLevel failed; try again");
2087 info.errorMsg(
"Abort from Pythia::forceHadronLevel: "
2088 "hadronLevel failed; giving up");
2093 if (checkEvent && !check()) {
2094 info.errorMsg(
"Abort from Pythia::forceHadronLevel: "
2095 "check of event revealed problems");
2108 void Pythia::nextKinematics() {
2111 pAnow = pAinit + beamShapePtr->deltaPA();
2112 pAnow.e( sqrt(pAnow.pAbs2() + mA * mA) );
2113 pBnow = pBinit + beamShapePtr->deltaPB();
2114 pBnow.e( sqrt(pBnow.pAbs2() + mB * mB) );
2117 eCM = (pAnow + pBnow).mCalc();
2118 pzAcm = 0.5 * sqrtpos( (eCM + mA + mB) * (eCM - mA - mB)
2119 * (eCM - mA + mB) * (eCM + mA - mB) ) / eCM;
2121 eA = sqrt(mA*mA + pzAcm*pzAcm);
2122 eB = sqrt(mB*mB + pzBcm*pzBcm);
2125 info.setBeamA( idA, pzAcm, eA, mA);
2126 info.setBeamB( idB, pzBcm, eB, mB);
2128 beamA.newPzE( pzAcm, eA);
2129 beamB.newPzE( pzBcm, eB);
2133 MfromCM.fromCMframe( pAnow, pBnow);
2143 void Pythia::boostAndVertex(
bool toLab,
bool setVertex) {
2147 if (boostType == 2) process.bst(0., 0., betaZ, gammaZ);
2148 else if (boostType == 3) process.rotbst(MfromCM);
2151 if (event.size() > 0) {
2152 if (boostType == 2)
event.bst(0., 0., betaZ, gammaZ);
2153 else if (boostType == 3)
event.rotbst(MfromCM);
2158 if (boostType == 2) process.bst(0., 0., -betaZ, gammaZ);
2159 else if (boostType == 3) process.rotbst(MtoCM);
2162 if (event.size() > 0) {
2163 if (boostType == 2)
event.bst(0., 0., -betaZ, gammaZ);
2164 else if (boostType == 3)
event.rotbst(MtoCM);
2169 if (setVertex && doVertexSpread) {
2170 Vec4
vertex = beamShapePtr->vertex();
2171 for (
int i = 0; i < process.size(); ++i) process[i].vProd( vertex);
2172 for (
int i = 0; i <
event.size(); ++i) event[i].vProd( vertex);
2181 bool Pythia::doRHadronDecays( ) {
2184 if ( !rHadrons.exist() )
return true;
2187 if ( !rHadrons.decay( event) )
return false;
2190 if ( !partonLevel.resonanceShowers( process, event,
false) )
return false;
2193 if ( !hadronLevel.next( event) )
return false;
2204 void Pythia::stat() {
2206 if ( doHeavyIons ) {
2207 heavyIonsPtr->stat();
2212 bool showPrL = settings.flag(
"Stat:showProcessLevel");
2213 bool showPaL = settings.flag(
"Stat:showPartonLevel");
2214 bool showErr = settings.flag(
"Stat:showErrors");
2215 bool reset = settings.flag(
"Stat:reset");
2218 if (doProcessLevel) {
2219 if (showPrL) processLevel.statistics(
false);
2220 if (reset) processLevel.resetStatistics();
2224 if (showPaL) partonLevel.statistics(
false);
2225 if (reset) partonLevel.resetStatistics();
2228 if (doMerging) mergingPtr->statistics();
2231 if (showErr) info.errorStatistics();
2232 if (reset) info.errorReset();
2240 void Pythia::banner() {
2243 double versionNumber = settings.parm(
"Pythia:versionNumber");
2244 int versionDate = settings.mode(
"Pythia:versionDate");
2245 string month[12] = {
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
2246 "Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"};
2251 strftime(dateNow,12,
"%d %b %Y",localtime(&t));
2253 strftime(timeNow,9,
"%H:%M:%S",localtime(&t));
2256 <<
" *-------------------------------------------"
2257 <<
"-----------------------------------------* \n"
2260 <<
" | *----------------------------------------"
2261 <<
"--------------------------------------* | \n"
2266 <<
" | | PPP Y Y TTTTT H H III A "
2267 <<
" Welcome to the Lund Monte Carlo! | | \n"
2268 <<
" | | P P Y Y T H H I A A "
2269 <<
" This is PYTHIA version " << fixed << setprecision(3)
2270 << setw(5) << versionNumber <<
" | | \n"
2271 <<
" | | PPP Y T HHHHH I AAAAA"
2272 <<
" Last date of change: " << setw(2) << versionDate%100
2273 <<
" " << month[ (versionDate/100)%100 - 1 ]
2274 <<
" " << setw(4) << versionDate/10000 <<
" | | \n"
2275 <<
" | | P Y T H H I A A"
2277 <<
" | | P Y T H H III A A"
2278 <<
" Now is " << dateNow <<
" at " << timeNow <<
" | | \n"
2281 <<
" | | Christian Bierlich; Department of As"
2282 <<
"tronomy and Theoretical Physics, | | \n"
2283 <<
" | | Lund University, Solvegatan 14A, S"
2284 <<
"E-223 62 Lund, Sweden; | | \n"
2285 <<
" | | e-mail: christian.bierlich@thep.lu"
2287 <<
" | | Nishita Desai; Laboratoire Charles C"
2288 <<
"oulomb (L2C), | | \n"
2289 <<
" | | CNRS-Universite de Montpellier, 34"
2290 <<
"090 Montpellier, France; | | \n"
2291 <<
" | | e-mail: nishita.desai@umontpellier"
2293 <<
" | | Nadine Fischer; School of Physics, "
2295 <<
" | | Monash University, PO Box 27, 3800"
2296 <<
" Melbourne, Australia; | | \n"
2297 <<
" | | e-mail: nadine.fischer@monash.edu "
2299 <<
" | | Ilkka Helenius; Institute for Theore"
2300 <<
"tical Physics, | | \n"
2301 <<
" | | Tuebingen University, Auf der Morge"
2302 <<
"nstelle 14, 72076 Tuebingen, Germany; | | \n"
2303 <<
" | | e-mail: ilkka.helenius@uni-tuebing"
2305 <<
" | | Philip Ilten; School of Physics and "
2306 <<
"Astronomy, | | \n"
2307 <<
" | | University of Birmingham, Birmingh"
2308 <<
"am, B152 2TT, UK; | | \n"
2309 <<
" | | e-mail: philten@cern.ch "
2311 <<
" | | Leif Lonnblad; Department of Astrono"
2312 <<
"my and Theoretical Physics, | | \n"
2313 <<
" | | Lund University, Solvegatan 14A, S"
2314 <<
"E-223 62 Lund, Sweden; | | \n"
2315 <<
" | | e-mail: leif.lonnblad@thep.lu.se "
2317 <<
" | | Stephen Mrenna; Computing Division, "
2318 <<
"Simulations Group, | | \n"
2319 <<
" | | Fermi National Accelerator Laborat"
2320 <<
"ory, MS 234, Batavia, IL 60510, USA; | | \n"
2321 <<
" | | e-mail: mrenna@fnal.gov "
2323 <<
" | | Stefan Prestel; Theoretical Physics "
2324 <<
"Department, | | \n"
2325 <<
" | | Fermi National Accelerator Laborat"
2326 <<
"ory, MS 106, Batavia, IL 60510, USA; | | \n"
2327 <<
" | | e-mail: sprestel@fnal.gov "
2329 <<
" | | Christine O. Rasmussen; Department o"
2330 <<
"f Astronomy and Theoretical Physics, | | \n"
2331 <<
" | | Lund University, Solvegatan 14A, S"
2332 <<
"E-223 62 Lund, Sweden; | | \n"
2333 <<
" | | e-mail: christine.rasmussen@thep.l"
2335 <<
" | | Torbjorn Sjostrand; Department of As"
2336 <<
"tronomy and Theoretical Physics, | | \n"
2337 <<
" | | Lund University, Solvegatan 14A, S"
2338 <<
"E-223 62 Lund, Sweden; | | \n"
2339 <<
" | | e-mail: torbjorn@thep.lu.se "
2341 <<
" | | Peter Skands; School of Physics, "
2343 <<
" | | Monash University, PO Box 27, 3800"
2344 <<
" Melbourne, Australia; | | \n"
2345 <<
" | | e-mail: peter.skands@monash.edu "
2349 <<
" | | The main program reference is 'An Int"
2350 <<
"roduction to PYTHIA 8.2', | | \n"
2351 <<
" | | T. Sjostrand et al, Comput. Phys. Com"
2352 <<
"mun. 191 (2015) 159 | | \n"
2353 <<
" | | [arXiv:1410.3012 [hep-ph]] "
2357 <<
" | | The main physics reference is the 'PY"
2358 <<
"THIA 6.4 Physics and Manual', | | \n"
2359 <<
" | | T. Sjostrand, S. Mrenna and P. Skands"
2360 <<
", JHEP05 (2006) 026 [hep-ph/0603175] | | \n"
2363 <<
" | | An archive of program versions and do"
2364 <<
"cumentation is found on the web: | | \n"
2365 <<
" | | http://www.thep.lu.se/Pythia "
2369 <<
" | | This program is released under the GN"
2370 <<
"U General Public Licence version 2. | | \n"
2371 <<
" | | Please respect the MCnet Guidelines f"
2372 <<
"or Event Generator Authors and Users. | | \n"
2375 <<
" | | Disclaimer: this program comes withou"
2376 <<
"t any guarantees. | | \n"
2377 <<
" | | Beware of errors and use common sense"
2378 <<
" when interpreting results. | | \n"
2381 <<
" | | Copyright (C) 2018 Torbjorn Sjostrand"
2387 <<
" | *----------------------------------------"
2388 <<
"--------------------------------------* | \n"
2391 <<
" *-------------------------------------------"
2392 <<
"-----------------------------------------* \n" << endl;
2400 int Pythia::readSubrun(
string line,
bool warn) {
2403 int subrunLine = SUBRUNDEFAULT;
2404 if (line.find_first_not_of(
" \n\t\v\b\r\f\a") == string::npos)
2408 string lineNow = line;
2409 int firstChar = lineNow.find_first_not_of(
" \n\t\v\b\r\f\a");
2410 if (!isalpha(lineNow[firstChar]))
return subrunLine;
2413 while (lineNow.find(
"=") != string::npos) {
2414 int firstEqual = lineNow.find_first_of(
"=");
2415 lineNow.replace(firstEqual, 1,
" ");
2419 istringstream splitLine(lineNow);
2424 while (name.find(
"::") != string::npos) {
2425 int firstColonColon = name.find_first_of(
"::");
2426 name.replace(firstColonColon, 2,
":");
2430 if (toLower(name) !=
"main:subrun")
return subrunLine;
2433 splitLine >> subrunLine;
2435 if (warn) cout <<
"\n PYTHIA Warning: Main:subrun number not"
2436 <<
" recognized; skip:\n " << line << endl;
2437 subrunLine = SUBRUNDEFAULT;
2448 int Pythia::readCommented(
string line) {
2451 if (line.find_first_not_of(
" \n\t\v\b\r\f\a") == string::npos)
return 0;
2452 int firstChar = line.find_first_not_of(
" \n\t\v\b\r\f\a");
2453 if (
int(line.size()) < firstChar + 2)
return 0;
2456 if (line.substr(firstChar, 2) ==
"/*")
return +1;
2457 if (line.substr(firstChar, 2) ==
"*/")
return -1;
2469 bool Pythia::check() {
2472 bool physical =
true;
2473 bool listVertices =
false;
2474 bool listHistory =
false;
2475 bool listSystems =
false;
2476 bool listBeams =
false;
2481 iErrNanVtx.resize(0);
2483 double chargeSum = 0.;
2486 if (doProcessLevel) {
2487 pSum = - (
event[1].p() +
event[2].p());
2488 chargeSum = - (
event[1].charge() +
event[2].charge());
2491 }
else if (process.size() > 0) {
2492 pSum = - process[0].p();
2493 for (
int i = 0; i < process.size(); ++i)
2494 if (process[i].isFinal()) chargeSum -= process[i].charge();
2498 pSum = -
event[0].p();
2499 for (
int i = 1; i <
event.size(); ++i)
2500 if (event[i].statusAbs() < 10 ||
event[i].statusAbs() == 23)
2501 chargeSum -= event[i].charge();
2503 double eLab = abs(pSum.e());
2506 for (
int i = 0; i <
event.size(); ++i) {
2509 int id =
event[i].id();
2510 if (
id == 0 || !particleData.isParticle(
id)) {
2511 ostringstream errCode;
2512 errCode <<
", i = " << i <<
", id = " << id;
2513 info.errorMsg(
"Error in Pythia::check: "
2514 "unknown particle code", errCode.str());
2516 iErrId.push_back(i);
2520 int colType =
event[i].colType();
2521 int col =
event[i].col();
2522 int acol =
event[i].acol();
2523 if ( event[i].statusAbs() / 10 == 8 ) acol = col = 0;
2524 if ( (colType == 0 && (col > 0 || acol > 0))
2525 || (colType == 1 && (col <= 0 || acol > 0))
2526 || (colType == -1 && (col > 0 || acol <= 0))
2527 || (colType == 2 && (col <= 0 || acol <= 0)) ) {
2528 ostringstream errCode;
2529 errCode <<
", i = " << i <<
", id = " <<
id <<
" cols = " << col
2531 info.errorMsg(
"Error in Pythia::check: "
2532 "incorrect colours", errCode.str());
2534 iErrCol.push_back(i);
2539 bool checkMass =
event[i].statusAbs() != 49 &&
event[i].statusAbs() != 59;
2542 if (abs(event[i].px()) >= 0. && abs(event[i].py()) >= 0.
2543 && abs(event[i].pz()) >= 0. && abs(event[i].e()) >= 0.
2544 && abs(event[i].m()) >= 0.) {
2545 double errMass = abs(event[i].mCalc() - event[i].m())
2546 / max( 1.0, event[i].e());
2547 if (checkMass && errMass > mTolErr) {
2548 info.errorMsg(
"Error in Pythia::check: "
2549 "unmatched particle energy/momentum/mass");
2551 iErrEpm.push_back(i);
2552 }
else if (checkMass && errMass > mTolWarn) {
2553 info.errorMsg(
"Warning in Pythia::check: "
2554 "not quite matched particle energy/momentum/mass");
2557 info.errorMsg(
"Error in Pythia::check: "
2558 "not-a-number energy/momentum/mass");
2560 iErrNan.push_back(i);
2564 if (abs(event[i].xProd()) >= 0. && abs(event[i].yProd()) >= 0.
2565 && abs(event[i].zProd()) >= 0. && abs(event[i].tProd()) >= 0.
2566 && abs(event[i].tau()) >= 0.) ;
2568 info.errorMsg(
"Error in Pythia::check: "
2569 "not-a-number vertex/lifetime");
2571 listVertices =
true;
2572 iErrNanVtx.push_back(i);
2576 if (event[i].isFinal()) {
2577 pSum +=
event[i].p();
2578 chargeSum +=
event[i].charge();
2585 double epDev = abs(pSum.e()) + abs(pSum.px()) + abs(pSum.py())
2587 if (epDev > epTolErr * eLab) {
2588 info.errorMsg(
"Error in Pythia::check: energy-momentum not conserved");
2590 }
else if (epDev > epTolWarn * eLab) {
2591 info.errorMsg(
"Warning in Pythia::check: "
2592 "energy-momentum not quite conserved");
2594 if (abs(chargeSum) > 0.1) {
2595 info.errorMsg(
"Error in Pythia::check: charge not conserved");
2601 if (info.isResolved() && !info.hasUnresolvedBeams())
2602 for (
int iSys = 0; iSys < beamA.sizeInit(); ++iSys) {
2603 int eventANw = partonSystems.getInA(iSys);
2604 int eventBNw = partonSystems.getInB(iSys);
2606 int beamANw = ( beamA.getGammaMode() == 0 || !beamHasGamma
2607 || (beamA.getGammaMode() == 2 && beamB.getGammaMode() == 2)) ?
2608 beamA[iSys].iPos() : beamGamA[iSys].iPos();
2609 int beamBNw = ( beamB.getGammaMode() == 0 || !beamHasGamma
2610 || (beamB.getGammaMode() == 2 && beamA.getGammaMode() == 2)) ?
2611 beamB[iSys].iPos() : beamGamB[iSys].iPos();
2612 if (eventANw != beamANw || eventBNw != beamBNw) {
2613 info.errorMsg(
"Error in Pythia::check: "
2614 "event and beams records disagree");
2624 vector< pair<int,int> > noMotDau;
2628 bool hasBeams =
false;
2629 for (
int i = 0; i <
event.size(); ++i) {
2630 int status =
event[i].status();
2631 if (abs(status) == 12) hasBeams =
true;
2634 vector<int> mList =
event[i].motherList();
2635 vector<int> dList =
event[i].daughterList();
2636 if (mList.size() == 0 && abs(status) != 11 && abs(status) != 12)
2638 if (dList.size() == 0 && status < 0 && status != -11)
2642 for (
int j = 0; j < int(mList.size()); ++j) {
2643 if ( event[mList[j]].daughter1() <= i
2644 &&
event[mList[j]].daughter2() >= i )
continue;
2645 vector<int> dmList =
event[mList[j]].daughterList();
2646 bool foundMatch =
false;
2647 for (
int k = 0; k < int(dmList.size()); ++k)
2648 if (dmList[k] == i) {
2652 if (!hasBeams && mList.size() == 1 && mList[0] == 0) foundMatch =
true;
2654 bool oldPair =
false;
2655 for (
int k = 0; k < int(noMotDau.size()); ++k)
2656 if (noMotDau[k].first == mList[j] && noMotDau[k].second == i) {
2660 if (!oldPair) noMotDau.push_back( make_pair( mList[j], i) );
2665 for (
int j = 0; j < int(dList.size()); ++j) {
2666 if ( event[dList[j]].statusAbs() > 80
2667 &&
event[dList[j]].statusAbs() < 90
2668 &&
event[dList[j]].mother1() <= i
2669 &&
event[dList[j]].mother2() >= i)
continue;
2670 vector<int> mdList =
event[dList[j]].motherList();
2671 bool foundMatch =
false;
2672 for (
int k = 0; k < int(mdList.size()); ++k)
2673 if (mdList[k] == i) {
2678 bool oldPair =
false;
2679 for (
int k = 0; k < int(noMotDau.size()); ++k)
2680 if (noMotDau[k].first == i && noMotDau[k].second == dList[j]) {
2684 if (!oldPair) noMotDau.push_back( make_pair( i, dList[j]) );
2690 if (noMot.size() > 0 || noDau.size() > 0 || noMotDau.size() > 0) {
2691 info.errorMsg(
"Error in Pythia::check: "
2692 "mismatch in daughter and mother lists");
2699 if (physical)
return true;
2702 if (nErrEvent < nErrList) {
2703 cout <<
"\n PYTHIA erroneous event info: \n";
2704 if (iErrId.size() > 0) {
2705 cout <<
" unknown particle codes in lines ";
2706 for (
int i = 0; i < int(iErrId.size()); ++i)
2707 cout << iErrId[i] <<
" ";
2710 if (iErrCol.size() > 0) {
2711 cout <<
" incorrect colour assignments in lines ";
2712 for (
int i = 0; i < int(iErrCol.size()); ++i)
2713 cout << iErrCol[i] <<
" ";
2716 if (iErrEpm.size() > 0) {
2717 cout <<
" mismatch between energy/momentum/mass in lines ";
2718 for (
int i = 0; i < int(iErrEpm.size()); ++i)
2719 cout << iErrEpm[i] <<
" ";
2722 if (iErrNan.size() > 0) {
2723 cout <<
" not-a-number energy/momentum/mass in lines ";
2724 for (
int i = 0; i < int(iErrNan.size()); ++i)
2725 cout << iErrNan[i] <<
" ";
2728 if (iErrNanVtx.size() > 0) {
2729 cout <<
" not-a-number vertex/lifetime in lines ";
2730 for (
int i = 0; i < int(iErrNanVtx.size()); ++i)
2731 cout << iErrNanVtx[i] <<
" ";
2734 if (epDev > epTolErr * eLab) cout << scientific << setprecision(3)
2735 <<
" total energy-momentum non-conservation = " << epDev <<
"\n";
2736 if (abs(chargeSum) > 0.1) cout << fixed << setprecision(2)
2737 <<
" total charge non-conservation = " << chargeSum <<
"\n";
2738 if (noMot.size() > 0) {
2739 cout <<
" missing mothers for particles ";
2740 for (
int i = 0; i < int(noMot.size()); ++i) cout << noMot[i] <<
" ";
2743 if (noDau.size() > 0) {
2744 cout <<
" missing daughters for particles ";
2745 for (
int i = 0; i < int(noDau.size()); ++i) cout << noDau[i] <<
" ";
2748 if (noMotDau.size() > 0) {
2749 cout <<
" inconsistent history for (mother,daughter) pairs ";
2750 for (
int i = 0; i < int(noMotDau.size()); ++i)
2751 cout <<
"(" << noMotDau[i].first <<
"," << noMotDau[i].second <<
") ";
2757 event.list(listVertices, listHistory);
2758 if (listSystems) partonSystems.list();
2759 if (listBeams) beamA.list();
2760 if (listBeams) beamB.list();
2773 PDF* Pythia::getPDFPtr(
int idIn,
int sequence,
string beam,
bool resolved) {
2776 PDF* tempPDFPtr = 0;
2779 if (idIn == 990 && settings.word(
"PDF:PomSet") ==
"2") idIn = 111;
2782 if (abs(idIn) == 2212 || abs(idIn) == 2112) {
2783 string pWord = settings.word(
"PDF:p"
2784 +
string(sequence == 1 ?
"" :
"Hard") +
"Set" + beam);
2785 if (pWord ==
"void" && sequence != 1 && beam ==
"B")
2786 pWord = settings.word(
"PDF:pHardSet");
2787 if (pWord ==
"void") pWord = settings.word(
"PDF:pSet");
2788 istringstream pStream(pWord);
2793 if (pSet == 0 && pWord.length() > 9
2794 && toLower(pWord).substr(0,9) ==
"lhagrid1:")
2795 tempPDFPtr =
new LHAGrid1(idIn, pWord, xmlPath, &info);
2798 else if (pSet == 0) tempPDFPtr =
new LHAPDF(idIn, pWord, &info);
2801 else if (pSet == 1) tempPDFPtr =
new GRV94L(idIn);
2802 else if (pSet == 2) tempPDFPtr =
new CTEQ5L(idIn);
2804 tempPDFPtr =
new MSTWpdf(idIn, pSet - 2, xmlPath, &info);
2805 else if (pSet <= 12)
2806 tempPDFPtr =
new CTEQ6pdf(idIn, pSet - 6, 1., xmlPath, &info);
2807 else if (pSet <= 16)
2808 tempPDFPtr =
new NNPDF(idIn, pSet - 12, xmlPath, &info);
2809 else if (pSet <= 21)
2810 tempPDFPtr =
new LHAGrid1(idIn, pWord, xmlPath, &info);
2811 else tempPDFPtr = 0;
2815 else if (abs(idIn) == 211 || idIn == 111) {
2816 string piWord = settings.word(
"PDF:piSet" + beam);
2817 if (piWord ==
"void" && beam ==
"B") piWord = settings.word(
"PDF:piSet");
2818 istringstream piStream(piWord);
2824 double rescale = (doVMDsideA || doVMDsideB) ? 0.00402068 : 1.;
2827 if (piSet == 0 && piWord.length() > 9
2828 && toLower(piWord).substr(0,9) ==
"lhagrid1:")
2829 tempPDFPtr =
new LHAGrid1(idIn, piWord, xmlPath, &info);
2832 else if (piSet == 0) tempPDFPtr =
new LHAPDF(idIn, piWord, &info);
2835 else if (piSet == 1) tempPDFPtr =
new GRVpiL(idIn, rescale);
2836 else tempPDFPtr = 0;
2840 else if (idIn == 990) {
2841 string pomWord = settings.word(
"PDF:PomSet");
2842 double rescale = settings.parm(
"PDF:PomRescale");
2843 istringstream pomStream(pomWord);
2845 pomStream >> pomSet;
2848 if (pomSet == 0 && pomWord.length() > 9
2849 && toLower(pomWord).substr(0,9) ==
"lhagrid1:")
2850 tempPDFPtr =
new LHAGrid1(idIn, pomWord, xmlPath, &info);
2853 else if (pomSet == 0) tempPDFPtr =
new LHAPDF(idIn, pomWord, &info);
2856 else if (pomSet == 1) {
2857 double gluonA = settings.parm(
"PDF:PomGluonA");
2858 double gluonB = settings.parm(
"PDF:PomGluonB");
2859 double quarkA = settings.parm(
"PDF:PomQuarkA");
2860 double quarkB = settings.parm(
"PDF:PomQuarkB");
2861 double quarkFrac = settings.parm(
"PDF:PomQuarkFrac");
2862 double strangeSupp = settings.parm(
"PDF:PomStrangeSupp");
2863 tempPDFPtr =
new PomFix( 990, gluonA, gluonB, quarkA, quarkB,
2864 quarkFrac, strangeSupp);
2868 else if (pomSet == 3 || pomSet == 4)
2869 tempPDFPtr =
new PomH1FitAB( 990, pomSet - 2, rescale, xmlPath, &info);
2870 else if (pomSet == 5)
2871 tempPDFPtr =
new PomH1Jets( 990, 1, rescale, xmlPath, &info);
2872 else if (pomSet == 6)
2873 tempPDFPtr =
new PomH1FitAB( 990, 3, rescale, xmlPath, &info);
2875 else if (pomSet > 6 && pomSet < 11) {
2876 tempPDFPtr =
new CTEQ6pdf( 990, pomSet + 4, rescale, xmlPath, &info);
2877 info.errorMsg(
"Warning: Pomeron flux parameters forced for ACTW PDFs");
2878 settings.mode(
"SigmaDiffractive:PomFlux", 4);
2879 double pomFluxEps = (pomSet == 10) ? 0.19 : 0.14;
2880 settings.parm(
"SigmaDiffractive:PomFluxEpsilon", pomFluxEps);
2881 settings.parm(
"SigmaDiffractive:PomFluxAlphaPrime", 0.25);
2883 else if (pomSet == 11 )
2884 tempPDFPtr =
new PomHISASD(990, getPDFPtr(2212), settings, &info);
2885 else if (pomSet == 12 || pomSet == 13)
2886 tempPDFPtr =
new LHAGrid1(idIn,
"1" + pomWord, xmlPath, &info);
2887 else tempPDFPtr = 0;
2891 else if (idIn > 100000000) {
2894 int nPDFSet = (beam ==
"B") ? settings.mode(
"PDF:nPDFSetB")
2895 : settings.mode(
"PDF:nPDFSetA");
2898 PDF* tempProtonPDFPtr = (beam ==
"B") ? pdfHardBPtr : pdfHardAPtr;
2899 if (nPDFSet == 0) tempPDFPtr =
new Isospin(idIn, tempProtonPDFPtr);
2900 else if (nPDFSet == 1 || nPDFSet == 2) tempPDFPtr =
new EPS09(idIn,
2901 nPDFSet, 1, xmlPath, tempProtonPDFPtr, &info);
2902 else if (nPDFSet == 3) tempPDFPtr =
new EPPS16(idIn, 1, xmlPath,
2903 tempProtonPDFPtr, &info);
2904 else tempPDFPtr = 0;
2908 else if (abs(idIn) == 22) {
2912 tempPDFPtr =
new GammaPoint(idIn);
2914 int gammaSet = settings.mode(
"PDF:GammaSet");
2917 bool beamAisPoint = ( !beamAisResGamma && !beamAhasResGamma );
2918 bool beamBisPoint = ( !beamBisResGamma && !beamBhasResGamma );
2919 bool beamIsPoint = ( beamAisPoint && !(beam ==
"B") )
2920 || ( beamBisPoint && (beam ==
"B") );
2923 if ( sequence == 2) {
2926 string gmWord = settings.word(
"PDF:GammaHardSet");
2928 if (gmWord ==
"void") gmSet = settings.mode(
"PDF:GammaSet");
2930 istringstream gmStream(gmWord);
2935 if (gmSet == 0 && !beamIsPoint) {
2936 tempPDFPtr =
new LHAPDF(idIn, gmWord, &info);
2945 if (beamIsPoint) tempPDFPtr =
new GammaPoint(idIn);
2946 else if (gammaSet == 1) tempPDFPtr =
new CJKL(idIn, &rndm);
2947 else tempPDFPtr = 0;
2953 else if (abs(idIn) > 10 && abs(idIn) < 17) {
2954 if (abs(idIn)%2 == 0) tempPDFPtr =
new NeutrinoPoint(idIn);
2957 if ( beamAhasResGamma && !(beam ==
"B") && resolved ) {
2960 PDF* tempGammaPDFPtr = 0;
2961 if ( sequence == 2) tempGammaPDFPtr = pdfHardGamAPtr;
2962 else tempGammaPDFPtr = pdfGamAPtr;
2965 double m2beam = pow2(particleData.m0(idIn));
2966 double Q2maxGamma = settings.parm(
"Photon:Q2max");
2969 if (settings.mode(
"PDF:lepton2gammaSet") == 1) {
2970 tempPDFPtr =
new Lepton2gamma(idIn, m2beam, Q2maxGamma,
2971 tempGammaPDFPtr, &info, &rndm);
2975 }
else if ( settings.mode(
"PDF:lepton2gammaSet") == 2 ) {
2976 PDF* tempGammaFluxPtr = pdfGamFluxAPtr;
2977 if ( tempGammaFluxPtr != 0) tempPDFPtr =
new EPAexternal(idIn, m2beam,
2978 tempGammaFluxPtr, tempGammaPDFPtr, &settings, &info, &rndm );
2981 info.errorMsg(
"Error in Pythia::getPDFPtr: "
2982 "No external photon flux provided with PDF:lepton2gammaSet == 2");
2984 }
else tempPDFPtr = 0;
2987 }
else if ( beamBhasResGamma && (beam ==
"B") && resolved ) {
2990 PDF* tempGammaPDFPtr = 0;
2991 if ( sequence == 2) tempGammaPDFPtr = pdfHardGamBPtr;
2992 else tempGammaPDFPtr = pdfGamBPtr;
2995 double m2beam = pow2(particleData.m0(idIn));
2996 double Q2maxGamma = settings.parm(
"Photon:Q2max");
2999 if (settings.mode(
"PDF:lepton2gammaSet") == 1) {
3000 tempPDFPtr =
new Lepton2gamma(idIn, m2beam, Q2maxGamma,
3001 tempGammaPDFPtr, &info, &rndm);
3004 }
else if ( settings.mode(
"PDF:lepton2gammaSet") == 2 ) {
3005 PDF* tempGammaFluxPtr = pdfGamFluxBPtr;
3006 if ( tempGammaFluxPtr != 0) tempPDFPtr =
new EPAexternal(idIn, m2beam,
3007 tempGammaFluxPtr, tempGammaPDFPtr, &settings, &info, &rndm );
3010 info.errorMsg(
"Error in Pythia::getPDFPtr: "
3011 "No external photon flux provided with PDF:lepton2gammaSet == 2");
3013 }
else tempPDFPtr = 0;
3016 }
else if (settings.flag(
"PDF:lepton")) {
3017 double m2beam = pow2(particleData.m0(idIn));
3018 double Q2maxGamma = settings.parm(
"Photon:Q2max");
3019 if (settings.mode(
"PDF:lepton2gammaSet") == 1 ) {
3020 tempPDFPtr =
new Lepton(idIn, Q2maxGamma, &info, &rndm);
3023 }
else if (settings.mode(
"PDF:lepton2gammaSet") == 2 ) {
3024 PDF* tempGammaPDFPtr = 0;
3025 PDF* tempGammaFluxPtr = (beam ==
"B") ?
3026 pdfGamFluxBPtr : pdfGamFluxAPtr;
3027 if ( tempGammaFluxPtr != 0) tempPDFPtr =
new EPAexternal(idIn, m2beam,
3028 tempGammaFluxPtr, tempGammaPDFPtr, &settings, &info, &rndm );
3031 info.errorMsg(
"Error in Pythia::getPDFPtr: "
3032 "No external photon flux provided with PDF:lepton2gammaSet == 2");
3034 }
else tempPDFPtr = 0;
3036 else tempPDFPtr =
new LeptonPoint(idIn);
3039 }
else if (abs(idIn) > 50 && abs(idIn) < 60) {
3040 tempPDFPtr =
new LeptonPoint(idIn);
3045 tempPDFPtr->setExtrapolate( settings.flag(
"PDF:extrapolate") );
bool setHIUserHooksPtr(HIUserHooks *userHooksPtrIn)
Possibility to pass in pointer for special heavy ion user hooks.
static void addSpecialSettings(Settings &settings)
static bool isHeavyIon(Settings &settings)