28 const int Pythia::NTRY = 10;
31 const int Pythia::SUBRUNDEFAULT = -999;
37 Pythia::Pythia(
string xmlDir) {
42 useNewPdfHard =
false;
43 useNewPdfPomA =
false;
44 useNewPdfPomB =
false;
58 couplingsPtr = &couplings;
68 hasMergingHooks =
false;
69 hasOwnMergingHooks =
false;
73 useNewBeamShape =
false;
86 const char* PYTHIA8DATA =
"PYTHIA8DATA";
87 char* envPath = getenv(PYTHIA8DATA);
88 if (envPath != 0 && *envPath !=
'\0') {
90 while (*(envPath+i) !=
'\0') xmlPath += *(envPath+(i++));
92 else xmlPath = xmlDir;
93 if (xmlPath[ xmlPath.length() - 1 ] !=
'/') xmlPath +=
"/";
96 settings.initPtr( &info);
97 string initFile = xmlPath +
"Index.xml";
98 isConstructed = settings.init( initFile);
100 info.errorMsg(
"Abort from Pythia::Pythia: settings unavailable");
105 particleData.initPtr( &info, &settings, &rndm, couplingsPtr);
106 string dataFile = xmlPath +
"ParticleData.xml";
107 isConstructed = particleData.init( dataFile);
108 if (!isConstructed) {
109 info.errorMsg(
"Abort from Pythia::Pythia: particle data unavailable");
129 if (useNewPdfHard && pdfHardAPtr != pdfAPtr)
delete pdfHardAPtr;
130 if (useNewPdfHard && pdfHardBPtr != pdfBPtr)
delete pdfHardBPtr;
131 if (useNewPdfA)
delete pdfAPtr;
132 if (useNewPdfB)
delete pdfBPtr;
133 if (useNewPdfPomA)
delete pdfPomAPtr;
134 if (useNewPdfPomB)
delete pdfPomBPtr;
137 if (useNewLHA)
delete lhaUpPtr;
140 if (hasOwnMergingHooks)
delete mergingHooksPtr;
143 if (useNewBeamShape)
delete beamShapePtr;
146 if (useNewTimes)
delete timesPtr;
147 if (useNewSpace)
delete spacePtr;
155 bool Pythia::readString(
string line,
bool warn) {
158 if (!isConstructed)
return false;
161 if (line.find_first_not_of(
" \n\t\v\b\r\f\a") == string::npos)
return true;
164 int firstChar = line.find_first_not_of(
" \n\t\v\b\r\f\a");
165 if (!isalnum(line[firstChar]))
return true;
168 if (isdigit(line[firstChar]))
169 return particleData.readString(line, warn);
172 return settings.readString(line, warn);
180 bool Pythia::readFile(
string fileName,
bool warn,
int subrun) {
183 if (!isConstructed)
return false;
186 const char* cstring = fileName.c_str();
187 ifstream is(cstring);
189 info.errorMsg(
"Error in Pythia::readFile: did not find file", fileName);
194 return readFile( is, warn, subrun);
203 bool Pythia::readFile(istream& is,
bool warn,
int subrun) {
206 if (!isConstructed)
return false;
210 bool accepted =
true;
211 int subrunNow = SUBRUNDEFAULT;
212 while ( getline(is, line) ) {
215 int subrunLine = readSubrun( line, warn);
216 if (subrunLine >= 0) subrunNow = subrunLine;
219 if ( (subrunNow == subrun || subrunNow == SUBRUNDEFAULT)
220 && !readString( line, warn) ) accepted =
false;
232 bool Pythia::setPDFPtr( PDF* pdfAPtrIn, PDF* pdfBPtrIn, PDF* pdfHardAPtrIn,
233 PDF* pdfHardBPtrIn, PDF* pdfPomAPtrIn, PDF* pdfPomBPtrIn) {
236 if (useNewPdfHard && pdfHardAPtr != pdfAPtr)
delete pdfHardAPtr;
237 if (useNewPdfHard && pdfHardBPtr != pdfBPtr)
delete pdfHardBPtr;
238 if (useNewPdfA)
delete pdfAPtr;
239 if (useNewPdfB)
delete pdfBPtr;
240 if (useNewPdfPomA)
delete pdfPomAPtr;
241 if (useNewPdfPomB)
delete pdfPomBPtr;
246 useNewPdfHard =
false;
247 useNewPdfPomA =
false;
248 useNewPdfPomB =
false;
257 if (pdfAPtrIn == 0 && pdfBPtrIn == 0)
return true;
260 if (pdfAPtrIn == pdfBPtrIn)
return false;
267 pdfHardAPtr = pdfAPtrIn;
268 pdfHardBPtr = pdfBPtrIn;
271 if (pdfHardAPtrIn != 0 && pdfHardBPtrIn != 0) {
272 if (pdfHardAPtrIn == pdfHardBPtrIn)
return false;
273 pdfHardAPtr = pdfHardAPtrIn;
274 pdfHardBPtr = pdfHardBPtrIn;
278 if (pdfPomAPtrIn != 0 && pdfPomBPtrIn != 0) {
279 if (pdfPomAPtrIn == pdfPomBPtrIn)
return false;
280 pdfPomAPtr = pdfPomAPtrIn;
281 pdfPomBPtr = pdfPomBPtrIn;
292 bool Pythia::init() {
296 if (!isConstructed) {
297 info.errorMsg(
"Abort from Pythia::init: constructur "
298 "initialization failed");
304 frameType = mode(
"Beams:frameType");
307 if (frameType < 4 ) {
309 boostType = frameType;
310 idA = mode(
"Beams:idA");
311 idB = mode(
"Beams:idB");
312 eCM = parm(
"Beams:eCM");
313 eA = parm(
"Beams:eA");
314 eB = parm(
"Beams:eB");
315 pxA = parm(
"Beams:pxA");
316 pyA = parm(
"Beams:pyA");
317 pzA = parm(
"Beams:pzA");
318 pxB = parm(
"Beams:pxB");
319 pyB = parm(
"Beams:pyB");
320 pzB = parm(
"Beams:pzB");
326 string lhef = word(
"Beams:LHEF");
327 bool skipInit = flag(
"Beams:newLHEFsameInit");
330 if (frameType == 4) {
331 if (useNewLHA)
delete lhaUpPtr;
332 const char* cstring = lhef.c_str();
333 lhaUpPtr =
new LHAupLHEF(cstring);
337 if (!lhaUpPtr->fileFound()) {
338 info.errorMsg(
"Abort from Pythia::init: "
339 "Les Houches Event File not found");
346 info.errorMsg(
"Abort from Pythia::init: "
347 "LHAup object not found");
353 lhaUpPtr->setPtr( &info);
354 processLevel.setLHAPtr( lhaUpPtr);
364 if (frameType == 4) {
365 doUserMerging = settings.flag(
"Merging:doUserMerging");
366 doMGMerging = settings.flag(
"Merging:doMGMerging");
367 doKTMerging = settings.flag(
"Merging:doKTMerging");
368 doMerging = doUserMerging || doMGMerging || doKTMerging;
370 if (mergingHooksPtr)
delete mergingHooksPtr;
371 mergingHooksPtr =
new MergingHooks();
372 hasOwnMergingHooks =
true;
374 hasMergingHooks = (mergingHooksPtr > 0);
375 if (hasMergingHooks) mergingHooksPtr->setLHEInputFile( lhef);
379 if (!lhaUpPtr->setInit()) {
380 info.errorMsg(
"Abort from Pythia::init: "
381 "Les Houches initialization failed");
386 idA = lhaUpPtr->idBeamA();
387 idB = lhaUpPtr->idBeamB();
388 eA = lhaUpPtr->eBeamA();
389 eB = lhaUpPtr->eBeamB();
395 info.setTooLowPTmin(
false);
396 info.setSigma( 0, 0, 0, 0., 0., 0.);
399 doProcessLevel = settings.flag(
"ProcessLevel:all");
400 doPartonLevel = settings.flag(
"PartonLevel:all");
401 doHadronLevel = settings.flag(
"HadronLevel:all");
402 doDiffraction = settings.flag(
"SoftQCD:all")
403 || settings.flag(
"SoftQCD:singleDiffractive")
404 || settings.flag(
"SoftQCD:doubleDiffractive");
405 decayRHadrons = settings.flag(
"RHadrons:allowDecay");
406 doMomentumSpread = settings.flag(
"Beams:allowMomentumSpread");
407 doVertexSpread = settings.flag(
"Beams:allowVertexSpread");
408 abortIfVeto = settings.flag(
"Check:abortIfVeto");
409 checkEvent = settings.flag(
"Check:event");
410 nErrList = settings.mode(
"Check:nErrList");
411 epTolErr = settings.parm(
"Check:epTolErr");
412 epTolWarn = settings.parm(
"Check:epTolWarn");
415 if (hasMergingHooks && doMerging)
416 mergingHooksPtr->init( settings, &info, &particleData );
419 if ( settings.flag(
"Random:setSeed") )
420 rndm.init( settings.mode(
"Random:seed") );
427 if( !initSLHA()) info.errorMsg(
"Error in Pythia::init: "
428 "Could not read SLHA file");
429 if (couplingsPtr->isSUSY) {
431 coupSUSY.init( settings, &rndm);
432 coupSUSY.initSUSY(&slha, &settings, &particleData);
433 couplingsPtr = (Couplings *) &coupSUSY;
436 couplingsPtr->init( settings, &rndm);
440 particleData.initPtr( &info, &settings, &rndm, couplingsPtr);
443 int startColTag = settings.mode(
"Event:startColTag");
444 process.init(
"(hard process)", &particleData, startColTag);
445 event.init(
"(complete event)", &particleData, startColTag);
448 particleData.initWidths( resonancePtrs);
451 rHadrons.init( &info, settings, &particleData, &rndm);
454 hasUserHooks = (userHooksPtr > 0);
455 doVetoProcess = (hasUserHooks)
456 ? userHooksPtr->canVetoProcessLevel() :
false;
457 doVetoPartons = (hasUserHooks)
458 ? userHooksPtr->canVetoPartonLevel() :
false;
459 if (hasUserHooks) userHooksPtr->initPtr( &info, &settings, &particleData,
460 &rndm, &beamA, &beamB, &beamPomA, &beamPomB, couplingsPtr, &partonSystems,
464 if (timesDecPtr == 0 || timesPtr == 0) {
465 TimeShower* timesNow =
new TimeShower();
466 if (timesDecPtr == 0) timesDecPtr = timesNow;
467 if (timesPtr == 0) timesPtr = timesNow;
471 spacePtr =
new SpaceShower();
476 timesPtr->initPtr( &info, &settings, &particleData, &rndm, couplingsPtr,
477 &partonSystems, userHooksPtr);
478 timesDecPtr->initPtr( &info, &settings, &particleData, &rndm, couplingsPtr,
479 &partonSystems, userHooksPtr);
480 spacePtr->initPtr( &info, &settings, &particleData, &rndm,
481 &partonSystems, userHooksPtr);
482 timesDecPtr->init( 0, 0);
485 if (beamShapePtr == 0) {
486 beamShapePtr =
new BeamShape();
487 useNewBeamShape =
true;
489 beamShapePtr->init( settings, &rndm);
493 info.errorMsg(
"Abort from Pythia::init: "
494 "checkBeams initialization failed");
499 if (!doProcessLevel) boostType = 1;
503 if (!initKinematics()) {
504 info.errorMsg(
"Abort from Pythia::init: "
505 "kinematics initialization failed");
511 info.errorMsg(
"Abort from Pythia::init: PDF initialization failed");
516 StringFlav* flavSelPtr = hadronLevel.getStringFlavPtr();
517 beamA.init( idA, pzAcm, eA, mA, &info, settings, &particleData, &rndm,
518 pdfAPtr, pdfHardAPtr, isUnresolvedA, flavSelPtr);
519 beamB.init( idB, pzBcm, eB, mB, &info, settings, &particleData, &rndm,
520 pdfBPtr, pdfHardBPtr, isUnresolvedB, flavSelPtr);
523 if ( doDiffraction) {
524 beamPomA.init( 990, 0.5 * eCM, 0.5 * eCM, 0., &info, settings,
525 &particleData, &rndm, pdfPomAPtr, pdfPomAPtr,
false, flavSelPtr);
526 beamPomB.init( 990, -0.5 * eCM, 0.5 * eCM, 0., &info, settings,
527 &particleData, &rndm, pdfPomBPtr, pdfPomBPtr,
false, flavSelPtr);
532 if ( doProcessLevel && !processLevel.init( &info, settings, &particleData,
533 &rndm, &beamA, &beamB, couplingsPtr, &sigmaTot, doLHA, &slha, userHooksPtr,
535 info.errorMsg(
"Abort from Pythia::init: "
536 "processLevel initialization failed");
541 if ( doPartonLevel && doProcessLevel && !partonLevel.init( &info, settings,
542 &particleData, &rndm, &beamA, &beamB, &beamPomA, &beamPomB, couplingsPtr,
543 &partonSystems, &sigmaTot, timesDecPtr, timesPtr, spacePtr, &rHadrons,
544 userHooksPtr, mergingHooksPtr,
false) ) {
545 info.errorMsg(
"Abort from Pythia::init: "
546 "partonLevel initialization failed" );
551 if ( doMerging && !trialPartonLevel.init( &info, settings, &particleData,
552 &rndm, &beamA, &beamB, &beamPomA, &beamPomB, couplingsPtr, &partonSystems,
553 &sigmaTot, timesDecPtr, timesPtr, spacePtr, &rHadrons, NULL,
554 mergingHooksPtr,
true) ) {
555 info.errorMsg(
"Abort from Pythia::init: "
556 "trialPartonLevel initialization failed");
562 if ( !hadronLevel.init( &info, settings, &particleData, &rndm,
563 couplingsPtr, timesDecPtr, &rHadrons, decayHandlePtr,
564 handledParticles) ) {
565 info.errorMsg(
"Abort from Pythia::init: "
566 "hadronLevel initialization failed");
571 if ( settings.flag(
"Check:particleData") )
572 particleData.checkTable( settings.mode(
"Check:levelParticleData") );
575 bool showCS = settings.flag(
"Init:showChangedSettings");
576 bool showAS = settings.flag(
"Init:showAllSettings");
577 bool showCPD = settings.flag(
"Init:showChangedParticleData");
578 bool showCRD = settings.flag(
"Init:showChangedResonanceData");
579 bool showAPD = settings.flag(
"Init:showAllParticleData");
580 int show1PD = settings.mode(
"Init:showOneParticleData");
581 bool showPro = settings.flag(
"Init:showProcesses");
582 if (showCS) settings.listChanged();
583 if (showAS) settings.listAll();
584 if (show1PD > 0) particleData.list(show1PD);
585 if (showCPD) particleData.listChanged(showCRD);
586 if (showAPD) particleData.listAll();
589 nCount = settings.mode(
"Next:numberCount");
590 nShowLHA = settings.mode(
"Next:numberShowLHA");
591 nShowInfo = settings.mode(
"Next:numberShowInfo");
592 nShowProc = settings.mode(
"Next:numberShowProcess");
593 nShowEvt = settings.mode(
"Next:numberShowEvent");
594 showSaV = settings.flag(
"Next:showScaleAndVertex");
595 showMaD = settings.flag(
"Next:showMothersAndDaughters");
600 if (useNewLHA && showPro) lhaUpPtr->listInit();
609 bool Pythia::init(
int idAin,
int idBin,
double eCMin) {
612 settings.mode(
"Beams:idA", idAin);
613 settings.mode(
"Beams:idB", idBin);
614 settings.mode(
"Beams:frameType", 1);
615 settings.parm(
"Beams:eCM", eCMin);
626 bool Pythia::init(
int idAin,
int idBin,
double eAin,
double eBin) {
629 settings.mode(
"Beams:idA", idAin);
630 settings.mode(
"Beams:idB", idBin);
631 settings.mode(
"Beams:frameType", 2);
632 settings.parm(
"Beams:eA", eAin);
633 settings.parm(
"Beams:eB", eBin);
644 bool Pythia::init(
int idAin,
int idBin,
double pxAin,
double pyAin,
645 double pzAin,
double pxBin,
double pyBin,
double pzBin) {
648 settings.mode(
"Beams:idA", idAin);
649 settings.mode(
"Beams:idB", idBin);
650 settings.mode(
"Beams:frameType", 3);
651 settings.parm(
"Beams:pxA", pxAin);
652 settings.parm(
"Beams:pyA", pyAin);
653 settings.parm(
"Beams:pzA", pzAin);
654 settings.parm(
"Beams:pxB", pxBin);
655 settings.parm(
"Beams:pyB", pyBin);
656 settings.parm(
"Beams:pzB", pzBin);
667 bool Pythia::init(
string LesHouchesEventFile,
bool skipInit) {
670 settings.mode(
"Beams:frameType", 4);
671 settings.word(
"Beams:LHEF", LesHouchesEventFile);
672 settings.flag(
"Beams:newLHEFsameInit", skipInit);
683 bool Pythia::init( LHAup* lhaUpPtrIn) {
686 setLHAupPtr( lhaUpPtrIn);
687 settings.mode(
"Beams:frameType", 5);
698 void Pythia::checkSettings() {
701 if ((settings.flag(
"PartonLevel:ISR") || settings.flag(
"PartonLevel:FSR"))
702 && settings.flag(
"MultipartonInteractions:allowDoubleRescatter")) {
703 info.errorMsg(
"Warning in Pythia::checkSettings: "
704 "double rescattering switched off since showering is on");
705 settings.flag(
"MultipartonInteractions:allowDoubleRescatter",
false);
714 bool Pythia::checkBeams() {
717 int idAabs = abs(idA);
718 int idBabs = abs(idB);
719 if (!doProcessLevel)
return true;
722 bool isLeptonA = (idAabs > 10 && idAabs < 17);
723 bool isLeptonB = (idBabs > 10 && idBabs < 17);
724 bool isUnresLep = !settings.flag(
"PDF:lepton");
725 isUnresolvedA = isLeptonA && (idAabs%2 == 0 || isUnresLep);
726 isUnresolvedB = isLeptonB && (idBabs%2 == 0 || isUnresLep);
729 if (isLeptonA && isLeptonB && isUnresolvedA == isUnresolvedB)
return true;
732 bool isHadronA = (idAabs == 2212) || (idA == 111) || (idAabs == 211)
734 bool isHadronB = (idBabs == 2212) || (idA == 111)|| (idBabs == 211)
736 if (isHadronA && isHadronB)
return true;
739 info.errorMsg(
"Error in Pythia::init: cannot handle this beam combination");
748 bool Pythia::initKinematics() {
751 mA = particleData.m0(idA);
752 mB = particleData.m0(idB);
757 if (boostType == 2) {
760 pzA = sqrt(eA*eA - mA*mA);
761 pzB = -sqrt(eB*eB - mB*mB);
762 pAinit = Vec4( 0., 0., pzA, eA);
763 pBinit = Vec4( 0., 0., pzB, eB);
764 eCM = sqrt( pow2(eA + eB) - pow2(pzA + pzB) );
767 betaZ = (pzA + pzB) / (eA + eB);
768 gammaZ = (eA + eB) / eCM;
769 if (abs(betaZ) < 1e-10) boostType = 1;
773 else if (boostType == 3) {
774 eA = sqrt( pxA*pxA + pyA*pyA + pzA*pzA + mA*mA);
775 eB = sqrt( pxB*pxB + pyB*pyB + pzB*pzB + mB*mB);
776 pAinit = Vec4( pxA, pyA, pzA, eA);
777 pBinit = Vec4( pxB, pyB, pzB, eB);
778 eCM = (pAinit + pBinit).mCalc();
782 MfromCM.fromCMframe( pAinit, pBinit);
789 info.errorMsg(
"Error in Pythia::initKinematics: too low energy");
794 pzAcm = 0.5 * sqrtpos( (eCM + mA + mB) * (eCM - mA - mB)
795 * (eCM - mA + mB) * (eCM + mA - mB) ) / eCM;
797 eA = sqrt(mA*mA + pzAcm*pzAcm);
798 eB = sqrt(mB*mB + pzBcm*pzBcm);
801 if (boostType != 2 && boostType != 3) {
802 pAinit = Vec4( 0., 0., pzAcm, eA);
803 pBinit = Vec4( 0., 0., pzBcm, eB);
807 info.setBeamA( idA, pzAcm, eA, mA);
808 info.setBeamB( idB, pzBcm, eB, mB);
812 if (doMomentumSpread) boostType = 3;
823 bool Pythia::initPDFs() {
827 if (pdfHardAPtr != pdfAPtr) {
831 if (pdfHardBPtr != pdfBPtr) {
835 useNewPdfHard =
false;
849 useNewPdfPomA =
false;
854 useNewPdfPomB =
false;
860 pdfAPtr = getPDFPtr(idA);
861 if (pdfAPtr == 0 || !pdfAPtr->isSetup()) {
862 info.errorMsg(
"Error in Pythia::init: "
863 "could not set up PDF for beam A");
866 pdfHardAPtr = pdfAPtr;
870 pdfBPtr = getPDFPtr(idB);
871 if (pdfBPtr == 0 || !pdfBPtr->isSetup()) {
872 info.errorMsg(
"Error in Pythia::init: "
873 "could not set up PDF for beam B");
876 pdfHardBPtr = pdfBPtr;
881 if (settings.flag(
"PDF:useHard") && useNewPdfA && useNewPdfB) {
882 pdfHardAPtr = getPDFPtr(idA, 2);
883 if (!pdfHardAPtr->isSetup())
return false;
884 pdfHardBPtr = getPDFPtr(idB, 2);
885 if (!pdfHardBPtr->isSetup())
return false;
886 useNewPdfHard =
true;
890 if ( doDiffraction) {
891 if (pdfPomAPtr == 0) {
892 pdfPomAPtr = getPDFPtr(990);
893 useNewPdfPomA =
true;
895 if (pdfPomBPtr == 0) {
896 pdfPomBPtr = getPDFPtr(990);
897 useNewPdfPomB =
true;
910 bool Pythia::next() {
913 int nPrevious = info.getCounter(3);
914 if (nCount > 0 && nPrevious > 0 && nPrevious%nCount == 0)
915 cout <<
"\n Pythia::next(): " << nPrevious
916 <<
" events have been generated " << endl;
920 for (
int i = 10; i < 13; ++i) info.setCounter(i);
923 if (!doProcessLevel) {
930 for (
int i = 1; i <
event.size(); ++i)
931 if (event[i].isFinal()) pSum += event[i].p();
933 event[0].m( pSum.mCalc() );
936 bool status = forceHadronLevel();
937 if (status) info.addCounter(4);
938 if (status && nPrevious < nShowEvt)
event.list(showSaV, showMaD);
946 partonSystems.clear();
954 info.errorMsg(
"Abort from Pythia::next: "
955 "not properly initialized so cannot generate events");
960 if (doMomentumSpread || doVertexSpread) beamShapePtr->pick();
963 if (doMomentumSpread) nextKinematics();
968 bool hasVetoed =
false;
974 if ( !processLevel.next( process) ) {
975 if (doLHA && info.atEndOfFile()) info.errorMsg(
"Abort from "
976 "Pythia::next: reached end of Les Houches Events File");
977 else info.errorMsg(
"Abort from Pythia::next: "
978 "processLevel failed; giving up");
986 hasVetoed = mergeProcess();
988 if (abortIfVeto)
return false;
995 hasVetoed = userHooksPtr->doVetoProcessLevel( process);
997 if (abortIfVeto)
return false;
1003 if (!doPartonLevel) {
1004 boostAndVertex(
true,
true);
1005 processLevel.accumulate();
1007 if (doLHA && nPrevious < nShowLHA) lhaUpPtr->listEvent();
1008 if (nPrevious < nShowInfo) info.list();
1009 if (nPrevious < nShowProc) process.list(showSaV, showMaD);
1014 Event processSave = process;
1015 info.addCounter(12);
1016 for (
int i = 14; i < 19; ++i) info.setCounter(i);
1019 bool physical =
true;
1020 for (
int iTry = 0; iTry < NTRY; ++ iTry) {
1021 info.addCounter(14);
1025 if (iTry > 0) process = processSave;
1033 partonSystems.clear();
1036 if ( !partonLevel.next( process, event) ) {
1038 hasVetoed = partonLevel.hasVetoed();
1040 if (abortIfVeto)
return false;
1044 info.errorMsg(
"Error in Pythia::next: "
1045 "partonLevel failed; try again");
1049 info.addCounter(15);
1052 if (doVetoPartons) {
1053 hasVetoed = userHooksPtr->doVetoPartonLevel( event);
1055 if (abortIfVeto)
return false;
1061 boostAndVertex(
true,
true);
1064 if (!doHadronLevel) {
1065 processLevel.accumulate();
1066 partonLevel.accumulate();
1069 if (checkEvent && !check()) {
1070 info.errorMsg(
"Abort from Pythia::next: "
1071 "check of event revealed problems");
1075 if (doLHA && nPrevious < nShowLHA) lhaUpPtr->listEvent();
1076 if (nPrevious < nShowInfo) info.list();
1077 if (nPrevious < nShowProc) process.list(showSaV, showMaD);
1078 if (nPrevious < nShowEvt)
event.list(showSaV, showMaD);
1083 info.addCounter(16);
1084 if ( !hadronLevel.next( event) ) {
1085 info.errorMsg(
"Error in Pythia::next: "
1086 "hadronLevel failed; try again");
1092 if (decayRHadrons && rHadrons.exist() && !doRHadronDecays()) {
1093 info.errorMsg(
"Error in Pythia::next: "
1094 "decayRHadrons failed; try again");
1098 info.addCounter(17);
1101 if (checkEvent && !check()) {
1102 info.errorMsg(
"Error in Pythia::next: "
1103 "check of event revealed problems");
1109 info.addCounter(18);
1115 if (abortIfVeto)
return false;
1121 info.errorMsg(
"Abort from Pythia::next: "
1122 "parton+hadronLevel failed; giving up");
1127 processLevel.accumulate();
1128 partonLevel.accumulate();
1129 event.scale( process.scale() );
1132 info.addCounter(13);
1137 if (doLHA && nPrevious < nShowLHA) lhaUpPtr->listEvent();
1138 if (nPrevious < nShowInfo) info.list();
1139 if (nPrevious < nShowProc) process.list(showSaV,showMaD);
1140 if (nPrevious < nShowEvt)
event.list(showSaV, showMaD);
1153 bool Pythia::forceHadronLevel(
bool findJunctions) {
1157 info.errorMsg(
"Abort from Pythia::forceHadronLevel: "
1158 "not properly initialized so cannot generate events");
1163 if (findJunctions) {
1164 event.clearJunctions();
1165 processLevel.findJunctions( event);
1169 Event spareEvent = event;
1172 bool physical =
true;
1173 for (
int iTry = 0; iTry < NTRY; ++ iTry) {
1177 if (hadronLevel.next( event))
break;
1180 info.errorMsg(
"Error in Pythia::forceHadronLevel: "
1181 "hadronLevel failed; try again");
1188 info.errorMsg(
"Abort from Pythia::forceHadronLevel: "
1189 "hadronLevel failed; giving up");
1194 if (checkEvent && !check()) {
1195 info.errorMsg(
"Abort from Pythia::forceHadronLevel: "
1196 "check of event revealed problems");
1209 void Pythia::nextKinematics() {
1212 pAnow = pAinit + beamShapePtr->deltaPA();
1213 pAnow.e( sqrt(pAnow.pAbs2() + mA * mA) );
1214 pBnow = pBinit + beamShapePtr->deltaPB();
1215 pBnow.e( sqrt(pBnow.pAbs2() + mB * mB) );
1218 eCM = (pAnow + pBnow).mCalc();
1219 pzAcm = 0.5 * sqrtpos( (eCM + mA + mB) * (eCM - mA - mB)
1220 * (eCM - mA + mB) * (eCM + mA - mB) ) / eCM;
1222 eA = sqrt(mA*mA + pzAcm*pzAcm);
1223 eB = sqrt(mB*mB + pzBcm*pzBcm);
1226 info.setBeamA( idA, pzAcm, eA, mA);
1227 info.setBeamB( idB, pzBcm, eB, mB);
1229 beamA.newPzE( pzAcm, eA);
1230 beamB.newPzE( pzBcm, eB);
1234 MfromCM.fromCMframe( pAnow, pBnow);
1244 void Pythia::boostAndVertex(
bool toLab,
bool setVertex) {
1248 if (boostType == 2) process.bst(0., 0., betaZ, gammaZ);
1249 else if (boostType == 3) process.rotbst(MfromCM);
1252 if (event.size() > 0) {
1253 if (boostType == 2)
event.bst(0., 0., betaZ, gammaZ);
1254 else if (boostType == 3)
event.rotbst(MfromCM);
1259 if (boostType == 2) process.bst(0., 0., -betaZ, gammaZ);
1260 else if (boostType == 3) process.rotbst(MtoCM);
1263 if (event.size() > 0) {
1264 if (boostType == 2)
event.bst(0., 0., -betaZ, gammaZ);
1265 else if (boostType == 3)
event.rotbst(MtoCM);
1270 if (setVertex && doVertexSpread) {
1271 Vec4
vertex = beamShapePtr->vertex();
1272 for (
int i = 0; i < process.size(); ++i) process[i].vProd( vertex);
1273 for (
int i = 0; i <
event.size(); ++i) event[i].vProd( vertex);
1282 bool Pythia::doRHadronDecays( ) {
1285 if ( !rHadrons.exist() )
return true;
1288 if ( !rHadrons.decay( event) )
return false;
1291 if ( !partonLevel.resonanceShowers( process, event,
false) )
return false;
1294 if ( !hadronLevel.next( event) )
return false;
1305 void Pythia::stat() {
1308 bool showPrL = settings.flag(
"Stat:showProcessLevel");
1309 bool showPaL = settings.flag(
"Stat:showPartonLevel");
1310 bool showErr = settings.flag(
"Stat:showErrors");
1311 bool reset = settings.flag(
"Stat:reset");
1314 if (doProcessLevel) {
1315 if (showPrL) processLevel.statistics(
false);
1316 if (reset) processLevel.resetStatistics();
1320 if (showPaL) partonLevel.statistics(
false);
1321 if (reset) partonLevel.resetStatistics();
1324 if (showErr) info.errorStatistics();
1325 if (reset) info.errorReset();
1333 void Pythia::statistics(
bool all,
bool reset) {
1336 if (doProcessLevel) processLevel.statistics(reset);
1339 if (all) partonLevel.statistics(reset);
1342 info.errorStatistics();
1343 if (reset) info.errorReset();
1351 void Pythia::banner(ostream& os) {
1354 double versionNumber = settings.parm(
"Pythia:versionNumber");
1355 int versionDate = settings.mode(
"Pythia:versionDate");
1356 string month[12] = {
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
1357 "Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"};
1362 strftime(dateNow,12,
"%d %b %Y",localtime(&t));
1364 strftime(timeNow,9,
"%H:%M:%S",localtime(&t));
1367 <<
" *-------------------------------------------"
1368 <<
"-----------------------------------------* \n"
1371 <<
" | *----------------------------------------"
1372 <<
"--------------------------------------* | \n"
1377 <<
" | | PPP Y Y TTTTT H H III A "
1378 <<
" Welcome to the Lund Monte Carlo! | | \n"
1379 <<
" | | P P Y Y T H H I A A "
1380 <<
" This is PYTHIA version " << fixed << setprecision(3)
1381 << setw(5) << versionNumber <<
" | | \n"
1382 <<
" | | PPP Y T HHHHH I AAAAA"
1383 <<
" Last date of change: " << setw(2) << versionDate%100
1384 <<
" " << month[ (versionDate/100)%100 - 1 ]
1385 <<
" " << setw(4) << versionDate/10000 <<
" | | \n"
1386 <<
" | | P Y T H H I A A"
1388 <<
" | | P Y T H H III A A"
1389 <<
" Now is " << dateNow <<
" at " << timeNow <<
" | | \n"
1392 <<
" | | Torbjorn Sjostrand; Department of As"
1393 <<
"tronomy and Theoretical Physics, | | \n"
1394 <<
" | | Lund University, Solvegatan 14A, S"
1395 <<
"E-223 62 Lund, Sweden; | | \n"
1396 <<
" | | phone: + 46 - 46 - 222 48 16; e-ma"
1397 <<
"il: torbjorn@thep.lu.se | | \n"
1398 <<
" | | Stefan Ask; Department of Physics, U"
1399 <<
"niversity of Cambridge, | | \n"
1400 <<
" | | Cavendish Laboratory, JJ Thomson A"
1401 <<
"ve., Cambridge CB3 0HE, UK; | | \n"
1402 <<
" | | phone: + 41 - 22 - 767 6707; e-mai"
1403 <<
"l: Stefan.Ask@cern.ch | | \n"
1404 <<
" | | Richard Corke; Department of Astrono"
1405 <<
"my and Theoretical Physics, | | \n"
1406 <<
" | | Lund University, Solvegatan 14A, S"
1407 <<
"E-223 62 Lund, Sweden; | | \n"
1408 <<
" | | e-mail: richard.corke@thep.lu.se "
1410 <<
" | | Stephen Mrenna; Computing Division, "
1411 <<
"Simulations Group, | | \n"
1412 <<
" | | Fermi National Accelerator Laborat"
1413 <<
"ory, MS 234, Batavia, IL 60510, USA; | | \n"
1414 <<
" | | phone: + 1 - 630 - 840 - 2556; e-m"
1415 <<
"ail: mrenna@fnal.gov | | \n"
1416 <<
" | | Stefan Prestel; Department of Astron"
1417 <<
"omy and Theoretical Physics, | | \n"
1418 <<
" | | Lund University, Solvegatan 14A, S"
1419 <<
"E-223 62 Lund, Sweden; | | \n"
1420 <<
" | | phone: + 46 - 46 - 222 06 64; e-ma"
1421 <<
"il: stefan.prestel@thep.lu.se | | \n"
1422 <<
" | | Peter Skands; Theoretical Physics, C"
1423 <<
"ERN, CH-1211 Geneva 23, Switzerland; | | \n"
1424 <<
" | | phone: + 41 - 22 - 767 2447; e-mai"
1425 <<
"l: peter.skands@cern.ch | | \n"
1428 <<
" | | The main program reference is the 'Br"
1429 <<
"ief Introduction to PYTHIA 8.1', | | \n"
1430 <<
" | | T. Sjostrand, S. Mrenna and P. Skands"
1431 <<
", Comput. Phys. Comm. 178 (2008) 85 | | \n"
1432 <<
" | | [arXiv:0710.3820] "
1436 <<
" | | The main physics reference is the 'PY"
1437 <<
"THIA 6.4 Physics and Manual', | | \n"
1438 <<
" | | T. Sjostrand, S. Mrenna and P. Skands"
1439 <<
", JHEP05 (2006) 026 [hep-ph/0603175]. | | \n"
1442 <<
" | | An archive of program versions and do"
1443 <<
"cumentation is found on the web: | | \n"
1444 <<
" | | http://www.thep.lu.se/~torbjorn/Pythi"
1448 <<
" | | This program is released under the GN"
1449 <<
"U General Public Licence version 2. | | \n"
1450 <<
" | | Please respect the MCnet Guidelines f"
1451 <<
"or Event Generator Authors and Users. | | \n"
1454 <<
" | | Disclaimer: this program comes withou"
1455 <<
"t any guarantees. | | \n"
1456 <<
" | | Beware of errors and use common sense"
1457 <<
" when interpreting results. | | \n"
1460 <<
" | | Copyright (C) 2012 Torbjorn Sjostrand"
1466 <<
" | *----------------------------------------"
1467 <<
"--------------------------------------* | \n"
1470 <<
" *-------------------------------------------"
1471 <<
"-----------------------------------------* \n" << endl;
1479 int Pythia::readSubrun(
string line,
bool warn, ostream& os) {
1482 int subrunLine = SUBRUNDEFAULT;
1483 if (line.find_first_not_of(
" \n\t\v\b\r\f\a") == string::npos)
1487 string lineNow = line;
1488 int firstChar = lineNow.find_first_not_of(
" \n\t\v\b\r\f\a");
1489 if (!isalpha(lineNow[firstChar]))
return subrunLine;
1492 while (lineNow.find(
"=") != string::npos) {
1493 int firstEqual = lineNow.find_first_of(
"=");
1494 lineNow.replace(firstEqual, 1,
" ");
1498 istringstream splitLine(lineNow);
1503 while (name.find(
"::") != string::npos) {
1504 int firstColonColon = name.find_first_of(
"::");
1505 name.replace(firstColonColon, 2,
":");
1509 for (
int i = 0; i < int(name.length()); ++i)
1510 name[i] = std::tolower(name[i]);
1513 if (name !=
"main:subrun")
return subrunLine;
1516 splitLine >> subrunLine;
1518 if (warn) os <<
"\n PYTHIA Warning: Main:subrun number not"
1519 <<
" recognized; skip:\n " << line << endl;
1520 subrunLine = SUBRUNDEFAULT;
1531 bool Pythia::check(ostream& os) {
1534 bool physical =
true;
1535 bool listVertices =
false;
1536 bool listSystems =
false;
1537 bool listBeams =
false;
1541 iErrNanVtx.resize(0);
1543 double chargeSum = 0.;
1546 if (doProcessLevel) {
1547 pSum = - (
event[1].p() +
event[2].p());
1548 chargeSum = - (
event[1].charge() +
event[2].charge());
1551 }
else if (process.size() > 0) {
1552 pSum = - process[0].p();
1553 for (
int i = 0; i < process.size(); ++i)
1554 if (process[i].isFinal()) chargeSum -= process[i].charge();
1558 pSum = -
event[0].p();
1559 for (
int i = 1; i <
event.size(); ++i)
1560 if (event[i].statusAbs() < 10 ||
event[i].statusAbs() == 23)
1561 chargeSum -= event[i].charge();
1563 double eLab = abs(pSum.e());
1566 for (
int i = 0; i <
event.size(); ++i) {
1569 int id =
event[i].id();
1570 if (
id == 0 || !particleData.isParticle(
id)) {
1571 ostringstream errCode;
1572 errCode <<
", id = " << id;
1573 info.errorMsg(
"Error in Pythia::check: "
1574 "unknown particle code", errCode.str());
1576 iErrId.push_back(i);
1580 int colType =
event[i].colType();
1581 int col =
event[i].col();
1582 int acol =
event[i].acol();
1583 if ( (colType == 0 && (col > 0 || acol > 0))
1584 || (colType == 1 && (col <= 0 || acol > 0))
1585 || (colType == -1 && (col > 0 || acol <= 0))
1586 || (colType == 2 && (col <= 0 || acol <= 0)) ) {
1587 ostringstream errCode;
1588 errCode <<
", id = " <<
id <<
" cols = " << col <<
" " << acol;
1589 info.errorMsg(
"Error in Pythia::check: "
1590 "incorrect colours", errCode.str());
1592 iErrCol.push_back(i);
1597 if (abs(event[i].px()) >= 0. && abs(event[i].py()) >= 0.
1598 && abs(event[i].pz()) >= 0. && abs(event[i].e()) >= 0.
1599 && abs(event[i].m()) >= 0.) ;
1601 info.errorMsg(
"Error in Pythia::check: "
1602 "not-a-number energy/momentum/mass");
1604 iErrNan.push_back(i);
1608 if (abs(event[i].xProd()) >= 0. && abs(event[i].yProd()) >= 0.
1609 && abs(event[i].zProd()) >= 0. && abs(event[i].tProd()) >= 0.
1610 && abs(event[i].tau()) >= 0.) ;
1612 info.errorMsg(
"Error in Pythia::check: "
1613 "not-a-number vertex/lifetime");
1615 listVertices =
true;
1616 iErrNanVtx.push_back(i);
1620 if (event[i].isFinal()) {
1621 pSum +=
event[i].p();
1622 chargeSum +=
event[i].charge();
1629 double epDev = abs(pSum.e()) + abs(pSum.px()) + abs(pSum.py())
1631 if (epDev > epTolErr * eLab) {
1632 info.errorMsg(
"Error in Pythia::check: energy-momentum not conserved");
1634 }
else if (epDev > epTolWarn * eLab) {
1635 info.errorMsg(
"Warning in Pythia::check: "
1636 "energy-momentum not quite conserved");
1638 if (abs(chargeSum) > 0.1) {
1639 info.errorMsg(
"Error in Pythia::check: charge not conserved");
1645 if (info.isResolved())
1646 for (
int iSys = 0; iSys < beamA.sizeInit(); ++iSys) {
1647 int eventANw = partonSystems.getInA(iSys);
1648 int eventBNw = partonSystems.getInB(iSys);
1649 int beamANw = beamA[iSys].iPos();
1650 int beamBNw = beamB[iSys].iPos();
1651 if (eventANw != beamANw || eventBNw != beamBNw) {
1652 info.errorMsg(
"Error in Pythia::check: "
1653 "event and beams records disagree");
1661 if (physical)
return true;
1664 if (nErrEvent < nErrList) {
1665 os <<
" PYTHIA erroneous event info: \n";
1666 if (iErrId.size() > 0) {
1667 os <<
" unknown particle codes in lines ";
1668 for (
int i = 0; i < int(iErrId.size()); ++i)
1669 os << iErrId[i] <<
" ";
1672 if (iErrCol.size() > 0) {
1673 os <<
" incorrect colour assignments in lines ";
1674 for (
int i = 0; i < int(iErrCol.size()); ++i)
1675 os << iErrCol[i] <<
" ";
1678 if (iErrNan.size() > 0) {
1679 os <<
" not-a-number energy/momentum/mass in lines ";
1680 for (
int i = 0; i < int(iErrNan.size()); ++i)
1681 os << iErrNan[i] <<
" ";
1684 if (iErrNanVtx.size() > 0) {
1685 os <<
" not-a-number vertex/lifetime in lines ";
1686 for (
int i = 0; i < int(iErrNanVtx.size()); ++i)
1687 os << iErrNanVtx[i] <<
" ";
1690 if (epDev > epTolErr * eLab) os << scientific << setprecision(3)
1691 <<
" total energy-momentum non-conservation = " << epDev <<
"\n";
1692 if (abs(chargeSum) > 0.1) os << fixed << setprecision(2)
1693 <<
" total charge non-conservation = " << chargeSum <<
"\n";
1695 event.list(listVertices);
1696 if (listSystems) partonSystems.list();
1697 if (listBeams) beamA.list();
1698 if (listBeams) beamB.list();
1711 PDF* Pythia::getPDFPtr(
int idIn,
int sequence) {
1714 PDF* tempPDFPtr = 0;
1717 if (idIn == 990 && settings.mode(
"PDF:PomSet") == 2) idIn = 111;
1720 if (abs(idIn) == 2212 && sequence == 1) {
1721 int pSet = settings.mode(
"PDF:pSet");
1722 bool useLHAPDF = settings.flag(
"PDF:useLHAPDF");
1726 if (pSet == 1) tempPDFPtr =
new GRV94L(idIn);
1727 else if (pSet == 2) tempPDFPtr =
new CTEQ5L(idIn);
1729 tempPDFPtr =
new MSTWpdf(idIn, pSet - 2, xmlPath, &info);
1730 else tempPDFPtr =
new CTEQ6pdf(idIn, pSet - 6, xmlPath, &info);
1735 string LHAPDFset = settings.word(
"PDF:LHAPDFset");
1736 int LHAPDFmember = settings.mode(
"PDF:LHAPDFmember");
1737 tempPDFPtr =
new LHAPDF(idIn, LHAPDFset, LHAPDFmember, 1, &info);
1740 tempPDFPtr->setExtrapolate( settings.flag(
"PDF:extrapolateLHAPDF") );
1745 else if (abs(idIn) == 2212) {
1746 int pSet = settings.mode(
"PDF:pHardSet");
1747 bool useLHAPDF = settings.flag(
"PDF:useHardLHAPDF");
1751 if (pSet == 1) tempPDFPtr =
new GRV94L(idIn);
1752 else if (pSet == 2) tempPDFPtr =
new CTEQ5L(idIn);
1754 tempPDFPtr =
new MSTWpdf(idIn, pSet - 2, xmlPath, &info);
1755 else tempPDFPtr =
new CTEQ6pdf(idIn, pSet - 6, xmlPath, &info);
1760 string LHAPDFset = settings.word(
"PDF:hardLHAPDFset");
1761 int LHAPDFmember = settings.mode(
"PDF:hardLHAPDFmember");
1762 tempPDFPtr =
new LHAPDF(idIn, LHAPDFset, LHAPDFmember, 2, &info);
1765 tempPDFPtr->setExtrapolate( settings.flag(
"PDF:extrapolateLHAPDF") );
1770 else if (abs(idIn) == 211 || idIn == 111) {
1771 bool useLHAPDF = settings.flag(
"PDF:piUseLHAPDF");
1775 tempPDFPtr =
new GRVpiL(idIn);
1780 string LHAPDFset = settings.word(
"PDF:piLHAPDFset");
1781 int LHAPDFmember = settings.mode(
"PDF:piLHAPDFmember");
1782 tempPDFPtr =
new LHAPDF(idIn, LHAPDFset, LHAPDFmember, 1, &info);
1785 tempPDFPtr->setExtrapolate( settings.flag(
"PDF:extrapolateLHAPDF") );
1790 else if (idIn == 990) {
1791 int pomSet = settings.mode(
"PDF:PomSet");
1792 double rescale = settings.parm(
"PDF:PomRescale");
1796 double gluonA = settings.parm(
"PDF:PomGluonA");
1797 double gluonB = settings.parm(
"PDF:PomGluonB");
1798 double quarkA = settings.parm(
"PDF:PomQuarkA");
1799 double quarkB = settings.parm(
"PDF:PomQuarkB");
1800 double quarkFrac = settings.parm(
"PDF:PomQuarkFrac");
1801 double strangeSupp = settings.parm(
"PDF:PomStrangeSupp");
1802 tempPDFPtr =
new PomFix( 990, gluonA, gluonB, quarkA, quarkB,
1803 quarkFrac, strangeSupp);
1807 else if (pomSet == 3 || pomSet == 4)
1808 tempPDFPtr =
new PomH1FitAB( 990, pomSet - 2, rescale, xmlPath, &info);
1809 else if (pomSet == 5)
1810 tempPDFPtr =
new PomH1Jets( 990, rescale, xmlPath, &info);
1811 else if (pomSet == 6)
1812 tempPDFPtr =
new PomH1FitAB( 990, 3, rescale, xmlPath, &info);
1816 else if (abs(idIn) > 10 && abs(idIn) < 17) {
1817 if (abs(idIn)%2 == 0) tempPDFPtr =
new NeutrinoPoint(idIn);
1818 else if (settings.flag(
"PDF:lepton")) tempPDFPtr =
new Lepton(idIn);
1819 else tempPDFPtr =
new LeptonPoint(idIn);
1823 else tempPDFPtr = 0;
1833 bool Pythia::initSLHA() {
1838 int readFrom = settings.mode(
"SLHA:readFrom");
1839 string lhefFile = settings.word(
"Beams:LHEF");
1840 string slhaFile = settings.word(
"SLHA:file");
1841 int verboseSLHA = settings.mode(
"SLHA:verbose");
1842 bool slhaUseDec = settings.flag(
"SLHA:useDecayTable");
1845 couplingsPtr->isSUSY =
false;
1848 if (readFrom == 0)
return true;
1851 if (readFrom == 1 && lhefFile !=
"void") {
1852 ifailLHE = slha.readFile(lhefFile, verboseSLHA, slhaUseDec );
1856 if (ifailLHE == 0) {
1858 couplingsPtr->isSUSY =
true;
1862 if ( settings.word(
"SLHA:file") ==
"none"
1863 || settings.word(
"SLHA:file") ==
"void"
1864 || settings.word(
"SLHA:file") ==
""
1865 || settings.word(
"SLHA:file") ==
" ")
return true;
1866 ifailSpc = slha.readFile(slhaFile,verboseSLHA, slhaUseDec);
1870 if (ifailSpc != 0) {
1871 info.errorMsg(
"Error in Pythia::initSLHA: "
1872 "problem reading SLHA file", slhaFile);
1875 couplingsPtr->isSUSY =
true;
1879 ifailSpc = slha.checkSpectrum();
1882 if (ifailSpc == 1) {
1884 couplingsPtr->isSUSY =
false;
1885 info.errorMsg(
"Warning in Pythia::initSLHA: "
1886 "No MODSEL found, keeping internal SUSY switched off");
1887 }
else if (ifailSpc >= 2) {
1889 info.errorMsg(
"Warning in Pythia::initSLHA: "
1890 "Problem with SLHA MASS or QNUMBERS.");
1891 couplingsPtr->isSUSY =
false;
1894 else if (ifailSpc == 0) {
1896 slha.printSpectrum(0);
1898 else if (ifailSpc < 0) {
1899 info.errorMsg(
"Warning in Pythia::initSLHA: "
1900 "Problem with SLHA spectrum.",
1901 "\n Only using masses and switching off SUSY.");
1902 settings.flag(
"SUSY:all",
false);
1903 couplingsPtr->isSUSY =
false;
1904 slha.printSpectrum(ifailSpc);
1908 if ( (ifailSpc == 1 || ifailSpc == 0) && slha.qnumbers.size() > 0) {
1909 for (
int iQnum=0; iQnum < int(slha.qnumbers.size()); iQnum++) {
1911 int id = abs(slha.qnumbers[iQnum](0));
1912 ostringstream idCode;
1914 if (particleData.isParticle(
id)) {
1915 info.errorMsg(
"Warning in Pythia::initSLHA: "
1916 "ignoring QNUMBERS",
"for id = "+idCode.str()
1917 +
" (already exists)",
true);
1919 int qEM3 = slha.qnumbers[iQnum](1);
1920 int nSpins = slha.qnumbers[iQnum](2);
1921 int colRep = slha.qnumbers[iQnum](3);
1922 int hasAnti = slha.qnumbers[iQnum](4);
1925 if (colRep == 3) colType = 1;
1926 else if (colRep == -3) colType = -1;
1927 else if (colRep == 8) colType = 2;
1928 else if (colRep == 6) colType = 3;
1929 else if (colRep == -6) colType = -3;
1931 string name, antiName;
1932 ostringstream idStream;
1934 name = idStream.str();
1935 antiName =
"-"+name;
1936 if (iQnum <
int(slha.qnumbersName.size())) {
1937 name = slha.qnumbersName[iQnum];
1938 if (iQnum <
int(slha.qnumbersAntiName.size()))
1939 antiName = slha.qnumbersAntiName[iQnum];
1940 if (antiName ==
"") {
1941 if (name.find(
"+") != string::npos) {
1943 antiName.replace(antiName.find(
"+"),1,
"-");
1944 }
else if (name.find(
"-") != string::npos) {
1946 antiName.replace(antiName.find(
"+"),1,
"-");
1948 antiName = name+
"bar";
1952 if ( hasAnti == 0) {
1954 particleData.addParticle(
id, name, nSpins, qEM3, colType);
1956 particleData.addParticle(
id, name, antiName, nSpins, qEM3, colType);
1963 bool keepSM = settings.flag(
"SLHA:keepSM");
1964 double minMassSM = settings.parm(
"SLHA:minMassSM");
1965 double massMargin = settings.parm(
"SLHA:minDecayDeltaM");
1966 if (ifailSpc == 1 || ifailSpc == 0) {
1969 int id = slha.mass.first();
1970 for (
int i = 1; i <= slha.mass.size() ; i++) {
1971 double mass = abs(slha.mass(
id));
1975 if (keepSM && (
id < 25 || (
id > 80 &&
id < 1000000))) ;
1976 else if (
id < 1000000 && particleData.m0(
id) < minMassSM) {
1977 ostringstream idCode;
1979 info.errorMsg(
"Warning in Pythia::initSLHA: "
1980 "ignoring MASS entry",
"for id = "+idCode.str()
1981 +
" (m0 < SLHA:minMassSM)",
true);
1983 else particleData.m0(
id,mass);
1984 id = slha.mass.next();
1990 for (
int iTable=0; iTable < int(slha.decays.size()); iTable++) {
1993 LHdecayTable* slhaTable=&(slha.decays[iTable]);
1996 int idRes = slhaTable->getId();
1997 ParticleDataEntry* particlePtr
1998 = particleData.particleDataEntryPtr(idRes);
2002 if (keepSM && (idRes < 25 || (idRes > 80 && idRes < 1000000)))
continue;
2003 else if (idRes < 1000000 && particleData.m0(idRes) < minMassSM) {
2004 ostringstream idCode;
2006 info.errorMsg(
"Warning in Pythia::initSLHA: "
2007 "ignoring DECAY table",
"for id = " + idCode.str()
2008 +
" (m0 < SLHA:minMassSM)",
true);
2013 double widRes = abs(slhaTable->getWidth());
2014 particlePtr->setMWidth(widRes);
2017 if (slhaTable->size() > 0) {
2018 particlePtr->clearChannels();
2019 particleData.mayDecay(idRes,
true);
2020 particleData.isResonance(idRes,
true);
2024 if (slhaTable->getWidth() <= 0.0) particleData.mayDecay(idRes,
false);
2027 double brWTsum = 0.;
2028 double massWTsum = 0.;
2033 for (
int iChannel=0 ; iChannel<slhaTable->size(); iChannel++) {
2034 LHdecayChannel slhaChannel = slhaTable->getChannel(iChannel);
2035 double brat = slhaChannel.getBrat();
2036 vector<int> idDa = slhaChannel.getIdDa();
2037 if (idDa.size() >= 9) {
2038 info.errorMsg(
"Error in Pythia::initSLHA: "
2039 "max number of decay products is 8.");
2040 }
else if (idDa.size() <= 1) {
2041 info.errorMsg(
"Error in Pythia::initSLHA: "
2042 "min number of decay products is 2.");
2046 if (brat < 0.0) onMode = 0;
2049 double massSum = massMargin;
2050 for (
int jDa=0; jDa<int(idDa.size()); ++jDa)
2051 massSum += particleData.m0( idDa[jDa] );
2052 if (onMode == 1 && brat > 0.0 && massSum > particleData.m0(idRes) ) {
2054 ostringstream errCode;
2055 errCode << idRes <<
" ->";
2056 for (
int jDa=0; jDa<int(idDa.size()); ++jDa) errCode<<
" "<<idDa[jDa];
2057 info.errorMsg(
"Warning in Pythia::initSLHA: switching off decay",
2058 errCode.str() +
" (mRes - mDa < minDecayDeltaM)"
2059 "\n (Note: cross sections will be scaled by remaining"
2060 " open branching fractions!)" ,
true);
2065 brWTsum += abs(brat);
2066 massWTsum += abs(brat) * massSum;
2071 int id2 = (idDa.size() >= 3) ? idDa[2] : 0;
2072 int id3 = (idDa.size() >= 4) ? idDa[3] : 0;
2073 int id4 = (idDa.size() >= 5) ? idDa[4] : 0;
2074 int id5 = (idDa.size() >= 6) ? idDa[5] : 0;
2075 int id6 = (idDa.size() >= 7) ? idDa[6] : 0;
2076 int id7 = (idDa.size() >= 8) ? idDa[7] : 0;
2077 particlePtr->addChannel(onMode,abs(brat),101,
2078 id0,id1,id2,id3,id4,id5,id6,id7);
2084 if (slhaTable->size() > 0) {
2085 double massAvg = massWTsum / brWTsum;
2086 double massMin = min( massAvg, particlePtr->m0()) - massMargin;
2087 particlePtr->setMMin(massMin);
2099 bool Pythia::mergeProcess() {
2102 mergingHooksPtr->setWeight(1.);
2103 info.setMergingWeight(1.);
2107 mergingHooksPtr->storeHardProcessCandidates( process);
2110 int nSteps = mergingHooksPtr->getNumberOfClusteringSteps( process);
2113 int nQuarks = mergingHooksPtr->nHardOutPartons();
2114 int nLeptons = mergingHooksPtr->nHardOutLeptons();
2115 bool isHadronic = (mergingHooksPtr->nHardInLeptons() == 0);
2120 for(
int i=0; i < process.size(); ++i)
2121 if(process[i].isFinal() && process[i].colType() != 0) {
2122 pT = process[i].pT();
2129 for(
int i=0; i < process.size(); ++i)
2130 if(process[i].isFinal() && process[i].idAbs() == 6) ++nTops;
2133 double RN = rndm.flat();
2137 History FullHistory( nSteps, 0.0, process, Clustering(), mergingHooksPtr,
2138 beamA, beamB, &particleData, &info,
true,
true, 1.0, 0);
2142 wgt = FullHistory.weightTREE( &trialPartonLevel,
2143 mergingHooksPtr->AlphaS_FSR(), mergingHooksPtr->AlphaS_ISR(), RN);
2147 FullHistory.getStartingConditions( RN, process );
2151 double dampWeight = mergingHooksPtr->dampenIfFailCuts(
2152 FullHistory.lowestMultProc(RN) );
2161 if ( isHadronic && nQuarks == 2 && nLeptons == 0 && nTops == 0
2162 && nSteps == 0 ) process.scale(pT);
2165 mergingHooksPtr->setWeight(wgt);
2166 info.setMergingWeight(wgt);
2169 if(wgt == 0.)
return true;