9 #include "Pythia8/ParticleData.h"
10 #include "Pythia8/ResonanceWidths.h"
11 #include "Pythia8/StandardModel.h"
12 #include "Pythia8/SusyResonanceWidths.h"
13 #include "Pythia8/ResonanceWidthsDM.h"
29 bool DecayChannel::contains(
int id1)
const {
32 for (
int i = 0; i < nProd; ++i)
if (prod[i] == id1) found1 =
true;
42 bool DecayChannel::contains(
int id1,
int id2)
const {
46 for (
int i = 0; i < nProd; ++i) {
47 if (!found1 && prod[i] == id1) {found1 =
true;
continue;}
48 if (!found2 && prod[i] == id2) {found2 =
true;
continue;}
50 return found1 && found2;
59 bool DecayChannel::contains(
int id1,
int id2,
int id3)
const {
64 for (
int i = 0; i < nProd; ++i) {
65 if (!found1 && prod[i] == id1) {found1 =
true;
continue;}
66 if (!found2 && prod[i] == id2) {found2 =
true;
continue;}
67 if (!found3 && prod[i] == id3) {found3 =
true;
continue;}
69 return found1 && found2 && found3;
86 const int ParticleDataEntry::INVISIBLENUMBER = 62;
87 const int ParticleDataEntry::INVISIBLETABLE[80] = {
88 12, 14, 16, 18, 23, 25, 32, 33,
89 35, 36, 39, 41, 45, 46, 51, 52,
90 53, 54, 55, 56, 57, 58, 59, 60,
91 1000012, 1000014, 1000016, 1000018, 1000022, 1000023, 1000025, 1000035,
92 1000045, 1000039, 2000012, 2000014, 2000016, 2000018, 4900012, 4900014,
93 4900016, 4900021, 4900022, 4900101, 4900102, 4900103, 4900104, 4900105,
94 4900106, 4900107, 4900108, 4900111, 4900113, 4900211, 4900213, 4900991,
95 5000039, 5100039, 9900012, 9900014, 9900016, 9900023, 0, 0,
96 0, 0, 0, 0, 0, 0, 0, 0,
97 0, 0, 0, 0, 0, 0, 0, 0
102 const int ParticleDataEntry::KNOWNNOWIDTH[3] = {10313, 10323, 10333};
105 const double ParticleDataEntry::MAXTAU0FORDECAY = 1000.;
108 const double ParticleDataEntry::MINMASSRESONANCE = 20.;
111 const double ParticleDataEntry::NARROWMASS = 1e-6;
114 const double ParticleDataEntry::CONSTITUENTMASSTABLE[10]
115 = {0., 0.325, 0.325, 0.50, 1.60, 5.00, 0., 0., 0., 0.7};
121 ParticleDataEntry::~ParticleDataEntry() {
122 if (resonancePtr != 0)
delete resonancePtr;
129 void ParticleDataEntry::setDefaults() {
132 isResonanceSave = (m0Save > MINMASSRESONANCE);
135 mayDecaySave = (tau0Save < MAXTAU0FORDECAY);
138 doExternalDecaySave =
false;
141 isVisibleSave =
true;
142 for (
int i = 0; i < INVISIBLENUMBER; ++i)
143 if (idSave == INVISIBLETABLE[i]) isVisibleSave =
false;
146 doForceWidthSave =
false;
149 setConstituentMass();
162 bool ParticleDataEntry::isHadron()
const {
164 if (idSave <= 100 || (idSave >= 1000000 && idSave <= 9000000)
165 || idSave >= 9900000)
return false;
166 if (idSave == 130 || idSave == 310)
return true;
167 if (idSave%10 == 0 || (idSave/10)%10 == 0 || (idSave/100)%10 == 0)
178 bool ParticleDataEntry::isMeson()
const {
180 if (idSave <= 100 || (idSave >= 1000000 && idSave <= 9000000)
181 || idSave >= 9900000)
return false;
182 if (idSave == 130 || idSave == 310)
return true;
183 if (idSave%10 == 0 || (idSave/10)%10 == 0 || (idSave/100)%10 == 0
184 || (idSave/1000)%10 != 0)
return false;
194 bool ParticleDataEntry::isBaryon()
const {
196 if (idSave <= 1000 || (idSave >= 1000000 && idSave <= 9000000)
197 || idSave >= 9900000)
return false;
198 if (idSave%10 == 0 || (idSave/10)%10 == 0 || (idSave/100)%10 == 0
199 || (idSave/1000)%10 == 0)
return false;
209 int ParticleDataEntry::heaviestQuark(
int idIn)
const {
211 if (!isHadron())
return 0;
215 if ( (idSave/1000)%10 == 0 ) {
216 hQ = (idSave/100)%10;
217 if (idSave == 130) hQ = 3;
218 if (hQ%2 == 1) hQ = -hQ;
221 }
else hQ = (idSave/1000)%10;
224 return (idIn > 0) ? hQ : -hQ;
232 int ParticleDataEntry::baryonNumberType(
int idIn)
const {
235 if (isQuark())
return (idIn > 0) ? 1 : -1;
238 if (isDiquark())
return (idIn > 0) ? 2 : -2;
241 if (isBaryon())
return (idIn > 0) ? 3 : -3;
253 int ParticleDataEntry::nQuarksInCode(
int idQIn)
const {
256 int idQ = abs(idQIn);
257 int idNow = abs(idSave);
261 if (isQuark())
return (idQ == idNow) ? 1 : 0;
265 if ( (idNow/1000) % 10 == idQ) ++nQ;
266 if ( (idNow/100) % 10 == idQ) ++nQ;
272 if ( (idNow/100) % 10 == idQ) ++nQ;
273 if ( (idNow/10) % 10 == idQ) ++nQ;
279 if ( (idNow/1000) % 10 == idQ) ++nQ;
280 if ( (idNow/100) % 10 == idQ) ++nQ;
281 if ( (idNow/10) % 10 == idQ) ++nQ;
295 void ParticleDataEntry::initBWmass() {
298 if (modeTau0now == 0) modeTau0now = (particleDataPtr->setRapidDecayVertex
299 && tau0Save == 0. && channels.size() > 0) ? 2 : 1;
300 if (modeTau0now == 2) tau0Save = (mWidthSave > NARROWMASS)
301 ? HBARC * FM2MM / mWidthSave : particleDataPtr->intermediateTau0;
304 modeBWnow = particleDataPtr->modeBreitWigner;
305 if ( m0Save < NARROWMASS ) mWidthSave = 0.;
306 if ( mWidthSave < NARROWMASS || (mMaxSave > mMinSave
307 && mMaxSave - mMinSave < NARROWMASS) ) modeBWnow = 0;
308 if (modeBWnow == 0)
return;
312 atanLow = atan( 2. * (mMinSave - m0Save) / mWidthSave );
313 double atanHigh = (mMaxSave > mMinSave)
314 ? atan( 2. * (mMaxSave - m0Save) / mWidthSave ) : 0.5 * M_PI;
315 atanDif = atanHigh - atanLow;
317 atanLow = atan( (pow2(mMinSave) - pow2(m0Save))
318 / (m0Save * mWidthSave) );
319 double atanHigh = (mMaxSave > mMinSave)
320 ? atan( (pow2(mMaxSave) - pow2(m0Save)) / (m0Save * mWidthSave) )
322 atanDif = atanHigh - atanLow;
326 if (modeBWnow%2 == 1)
return;
331 for (
int i = 0; i < int(channels.size()); ++i)
332 if (channels[i].onMode() > 0) {
333 bRatSum += channels[i].bRatio();
334 double mChannelSum = 0.;
335 for (
int j = 0; j < channels[i].multiplicity(); ++j)
336 mChannelSum += particleDataPtr->m0( channels[i].product(j) );
337 mThrSum += channels[i].bRatio() * mChannelSum;
339 mThr = (bRatSum == 0.) ? 0. : mThrSum / bRatSum;
342 if (mThr + NARROWMASS > m0Save && !isResonanceSave) {
344 bool knownProblem =
false;
345 for (
int i = 0; i < 3; ++i)
if (idSave == KNOWNNOWIDTH[i])
348 ostringstream osWarn;
349 osWarn <<
"for id = " << idSave;
350 particleDataPtr->infoPtr->errorMsg(
"Warning in ParticleDataEntry::"
351 "initBWmass: switching off width", osWarn.str(),
true);
362 double ParticleDataEntry::mSel() {
365 if (modeBWnow == 0 || mWidthSave < NARROWMASS)
return m0Save;
369 if (modeBWnow == 1) {
370 mNow = m0Save + 0.5 * mWidthSave
371 * tan( atanLow + atanDif * particleDataPtr->rndmPtr->flat() );
374 }
else if (modeBWnow == 2) {
375 double mWidthNow, fixBW, runBW;
376 double m0ThrS = m0Save*m0Save - mThr*mThr;
378 mNow = m0Save + 0.5 * mWidthSave
379 * tan( atanLow + atanDif * particleDataPtr->rndmPtr->flat() );
380 mWidthNow = mWidthSave * sqrtpos( (mNow*mNow - mThr*mThr) / m0ThrS );
381 fixBW = mWidthSave / (pow2(mNow - m0Save) + pow2(0.5 * mWidthSave));
382 runBW = mWidthNow / (pow2(mNow - m0Save) + pow2(0.5 * mWidthNow));
383 }
while (runBW < particleDataPtr->rndmPtr->flat()
384 * particleDataPtr->maxEnhanceBW * fixBW);
387 }
else if (modeBWnow == 3) {
388 m2Now = m0Save*m0Save + m0Save * mWidthSave
389 * tan( atanLow + atanDif * particleDataPtr->rndmPtr->flat() );
390 mNow = sqrtpos( m2Now);
394 double mwNow, fixBW, runBW;
395 double m2Ref = m0Save * m0Save;
396 double mwRef = m0Save * mWidthSave;
397 double m2Thr = mThr * mThr;
399 m2Now = m2Ref + mwRef * tan( atanLow + atanDif
400 * particleDataPtr->rndmPtr->flat() );
401 mNow = sqrtpos( m2Now);
402 mwNow = mNow * mWidthSave
403 * sqrtpos( (m2Now - m2Thr) / (m2Ref - m2Thr) );
404 fixBW = mwRef / (pow2(m2Now - m2Ref) + pow2(mwRef));
405 runBW = mwNow / (pow2(m2Now - m2Ref) + pow2(mwNow));
406 }
while (runBW < particleDataPtr->rndmPtr->flat()
407 * particleDataPtr->maxEnhanceBW * fixBW);
418 double ParticleDataEntry::mRun(
double mHat) {
421 if (idSave > 6)
return m0Save;
422 double mQRun = particleDataPtr->mQRun[idSave];
423 double Lam5 = particleDataPtr->Lambda5Run;
426 if (idSave < 4)
return mQRun * pow ( log(2. / Lam5)
427 / log(max(2., mHat) / Lam5), 12./23.);
430 return mQRun * pow ( log(mQRun / Lam5)
431 / log(max(mQRun, mHat) / Lam5), 12./23.);
439 void ParticleDataEntry::rescaleBR(
double newSumBR) {
442 double oldSumBR = 0.;
443 for (
int i = 0; i < int(channels.size()); ++ i)
444 oldSumBR += channels[i].bRatio();
445 double rescaleFactor = newSumBR / oldSumBR;
446 for (
int i = 0; i < int(channels.size()); ++ i)
447 channels[i].rescaleBR(rescaleFactor);
455 bool ParticleDataEntry::preparePick(
int idSgn,
double mHat,
int idInFlav) {
461 if (isResonanceSave && resonancePtr != 0) {
462 resonancePtr->widthStore(idSgn, mHat, idInFlav);
463 for (
int i = 0; i < int(channels.size()); ++i)
464 currentBRSum += channels[i].currentBR();
470 for (
int i = 0; i < int(channels.size()); ++i) {
471 onMode = channels[i].onMode();
473 if ( idSgn > 0 && (onMode == 1 || onMode == 2) )
474 currentBRNow = channels[i].bRatio();
475 else if ( idSgn < 0 && (onMode == 1 || onMode == 3) )
476 currentBRNow = channels[i].bRatio();
477 channels[i].currentBR(currentBRNow);
478 currentBRSum += currentBRNow;
483 return (currentBRSum > 0.);
491 DecayChannel& ParticleDataEntry::pickChannel() {
494 int size = channels.size();
495 double rndmBR = currentBRSum * particleDataPtr->rndmPtr->flat();
497 do rndmBR -= channels[++i].currentBR();
498 while (rndmBR > 0. && i < size);
501 if (i == size) i = 0;
511 void ParticleDataEntry::setResonancePtr(
512 ResonanceWidths* resonancePtrIn) {
513 if (resonancePtr == resonancePtrIn)
return;
514 if (resonancePtr != 0)
delete resonancePtr;
515 resonancePtr = resonancePtrIn;
518 void ParticleDataEntry::resInit(Info* infoPtrIn, Settings* settingsPtrIn,
519 ParticleData* particleDataPtrIn, Couplings* couplingsPtrIn) {
520 if (resonancePtr != 0) resonancePtr->init(infoPtrIn, settingsPtrIn,
521 particleDataPtrIn, couplingsPtrIn);
524 double ParticleDataEntry::resWidth(
int idSgn,
double mHat,
int idIn,
525 bool openOnly,
bool setBR) {
526 return (resonancePtr != 0) ? resonancePtr->width( idSgn, mHat,
527 idIn, openOnly, setBR) : 0.;
530 double ParticleDataEntry::resWidthOpen(
int idSgn,
double mHat,
int idIn) {
531 return (resonancePtr != 0) ? resonancePtr->widthOpen( idSgn, mHat, idIn)
535 double ParticleDataEntry::resWidthStore(
int idSgn,
double mHat,
int idIn) {
536 return (resonancePtr != 0) ? resonancePtr->widthStore( idSgn, mHat, idIn)
540 double ParticleDataEntry::resOpenFrac(
int idSgn) {
541 return (resonancePtr != 0) ? resonancePtr->openFrac(idSgn) : 1.;
544 double ParticleDataEntry::resWidthRescaleFactor() {
545 return (resonancePtr != 0) ? resonancePtr->widthRescaleFactor() : 1.;
548 double ParticleDataEntry::resWidthChan(
double mHat,
int idAbs1,
550 return (resonancePtr != 0) ? resonancePtr->widthChan( mHat, idAbs1,
561 void ParticleDataEntry::setConstituentMass() {
564 constituentMassSave = m0Save;
567 if (idSave < 6) constituentMassSave = CONSTITUENTMASSTABLE[idSave];
568 if (idSave == 21) constituentMassSave = CONSTITUENTMASSTABLE[9];
571 if (idSave > 1000 && idSave < 10000 && (idSave/10)%10 == 0) {
572 int id1 = idSave/1000;
573 int id2 = (idSave/100)%10;
574 if (id1 <6 && id2 < 6) constituentMassSave
575 = CONSTITUENTMASSTABLE[id1] + CONSTITUENTMASSTABLE[id2];
593 void ParticleData::initCommon() {
596 modeBreitWigner = settingsPtr->mode(
"ParticleData:modeBreitWigner");
599 maxEnhanceBW = settingsPtr->parm(
"ParticleData:maxEnhanceBW");
602 mQRun[1] = settingsPtr->parm(
"ParticleData:mdRun");
603 mQRun[2] = settingsPtr->parm(
"ParticleData:muRun");
604 mQRun[3] = settingsPtr->parm(
"ParticleData:msRun");
605 mQRun[4] = settingsPtr->parm(
"ParticleData:mcRun");
606 mQRun[5] = settingsPtr->parm(
"ParticleData:mbRun");
607 mQRun[6] = settingsPtr->parm(
"ParticleData:mtRun");
610 double alphaSvalue = settingsPtr->parm(
"ParticleData:alphaSvalueMRun");
612 alphaS.init( alphaSvalue, 1, 5,
false);
613 Lambda5Run = alphaS.Lambda5();
616 setRapidDecayVertex = settingsPtr->flag(
"Fragmentation:setVertices")
617 && settingsPtr->flag(
"HadronVertex:rapidDecays");
618 intermediateTau0 = settingsPtr->parm(
"HadronVertex:intermediateTau0");
628 void ParticleData::initWidths( vector<ResonanceWidths*> resonancePtrs) {
635 ResonanceWidths* resonancePtr = 0;
636 for (map<int, ParticleDataEntry>::iterator pdtEntry = pdt.begin();
637 pdtEntry != pdt.end(); ++pdtEntry) {
638 ParticleDataEntry& pdtNow = pdtEntry->second;
642 resonancePtr = pdtNow.getResonancePtr();
643 if (resonancePtr != 0) pdtNow.setResonancePtr(0);
648 resonancePtr =
new ResonanceGmZ(23);
649 setResonancePtr( 23, resonancePtr);
650 resonancePtr =
new ResonanceW(24);
651 setResonancePtr( 24, resonancePtr);
652 resonancePtr =
new ResonanceTop(6);
653 setResonancePtr( 6, resonancePtr);
656 if (!settingsPtr->flag(
"Higgs:useBSM")) {
657 resonancePtr =
new ResonanceH(0, 25);
658 setResonancePtr( 25, resonancePtr);
662 resonancePtr =
new ResonanceH(1, 25);
663 setResonancePtr( 25, resonancePtr);
664 resonancePtr =
new ResonanceH(2, 35);
665 setResonancePtr( 35, resonancePtr);
666 resonancePtr =
new ResonanceH(3, 36);
667 setResonancePtr( 36, resonancePtr);
668 resonancePtr =
new ResonanceHchg(37);
669 setResonancePtr( 37, resonancePtr);
670 resonancePtr =
new ResonanceH(4, 45);
671 setResonancePtr( 45, resonancePtr);
672 resonancePtr =
new ResonanceH(5, 46);
673 setResonancePtr( 46, resonancePtr);
677 resonancePtr =
new ResonanceFour(7);
678 setResonancePtr( 7, resonancePtr);
679 resonancePtr =
new ResonanceFour(8);
680 setResonancePtr( 8, resonancePtr);
681 resonancePtr =
new ResonanceFour(17);
682 setResonancePtr( 17, resonancePtr);
683 resonancePtr =
new ResonanceFour(18);
684 setResonancePtr( 18, resonancePtr);
687 resonancePtr =
new ResonanceZprime(32);
688 setResonancePtr( 32, resonancePtr);
689 resonancePtr =
new ResonanceWprime(34);
690 setResonancePtr( 34, resonancePtr);
691 resonancePtr =
new ResonanceRhorizontal(41);
692 setResonancePtr( 41, resonancePtr);
695 resonancePtr =
new ResonanceLeptoquark(42);
696 setResonancePtr( 42, resonancePtr);
699 resonancePtr =
new ResonanceZp(55);
700 setResonancePtr( 55, resonancePtr);
701 resonancePtr =
new ResonanceS(54);
702 setResonancePtr( 54, resonancePtr);
706 resonancePtr =
new ResonanceGmZ(93);
707 setResonancePtr( 93, resonancePtr);
708 resonancePtr =
new ResonanceW(94);
709 setResonancePtr( 94, resonancePtr);
713 for(
int i = 1; i < 7; i++){
714 resonancePtr =
new ResonanceSquark(1000000 + i);
715 setResonancePtr( 1000000 + i, resonancePtr);
716 resonancePtr =
new ResonanceSquark(2000000 + i);
717 setResonancePtr( 2000000 + i, resonancePtr);
721 for(
int i = 1; i < 7; i++){
722 resonancePtr =
new ResonanceSlepton(1000010 + i);
723 setResonancePtr( 1000010 + i, resonancePtr);
724 resonancePtr =
new ResonanceSlepton(2000010 + i);
725 setResonancePtr( 2000010 + i, resonancePtr);
729 resonancePtr =
new ResonanceGluino(1000021);
730 setResonancePtr( 1000021, resonancePtr);
733 resonancePtr =
new ResonanceChar(1000024);
734 setResonancePtr( 1000024, resonancePtr);
735 resonancePtr =
new ResonanceChar(1000037);
736 setResonancePtr( 1000037, resonancePtr);
739 if (isResonance(1000022)) {
740 resonancePtr =
new ResonanceNeut(1000022);
741 setResonancePtr( 1000022, resonancePtr);
743 resonancePtr =
new ResonanceNeut(1000023);
744 setResonancePtr( 1000023, resonancePtr);
745 resonancePtr =
new ResonanceNeut(1000025);
746 setResonancePtr( 1000025, resonancePtr);
747 resonancePtr =
new ResonanceNeut(1000035);
748 setResonancePtr( 1000035, resonancePtr);
749 resonancePtr =
new ResonanceNeut(1000045);
750 setResonancePtr( 1000045, resonancePtr);
753 for (
int i = 1; i < 7; ++i) {
754 resonancePtr =
new ResonanceExcited(4000000 + i);
755 setResonancePtr( 4000000 + i, resonancePtr);
757 for (
int i = 11; i < 17; ++i) {
758 resonancePtr =
new ResonanceExcited(4000000 + i);
759 setResonancePtr( 4000000 + i, resonancePtr);
763 resonancePtr =
new ResonanceGraviton(5100039);
764 setResonancePtr( 5100039, resonancePtr);
765 resonancePtr =
new ResonanceKKgluon(5100021);
766 setResonancePtr( 5100021, resonancePtr);
770 resonancePtr =
new ResonanceNuRight(9900012);
771 setResonancePtr( 9900012, resonancePtr);
772 resonancePtr =
new ResonanceNuRight(9900014);
773 setResonancePtr( 9900014, resonancePtr);
774 resonancePtr =
new ResonanceNuRight(9900016);
775 setResonancePtr( 9900016, resonancePtr);
776 resonancePtr =
new ResonanceZRight(9900023);
777 setResonancePtr( 9900023, resonancePtr);
778 resonancePtr =
new ResonanceWRight(9900024);
779 setResonancePtr( 9900024, resonancePtr);
780 resonancePtr =
new ResonanceHchgchgLeft(9900041);
781 setResonancePtr( 9900041, resonancePtr);
782 resonancePtr =
new ResonanceHchgchgRight(9900042);
783 setResonancePtr( 9900042, resonancePtr);
786 for (
int i = 0; i < int(resonancePtrs.size()); ++i) {
787 int idNow = resonancePtrs[i]->id();
788 resonancePtrs[i]->initBasic(idNow);
789 setResonancePtr( idNow, resonancePtrs[i]);
793 vector<int> idOrdered;
794 vector<double> m0Ordered;
797 idOrdered.push_back(23);
798 m0Ordered.push_back(m0(23));
799 idOrdered.push_back(24);
800 m0Ordered.push_back(m0(24));
803 for (map<int, ParticleDataEntry>::iterator pdtEntry = pdt.begin();
804 pdtEntry != pdt.end(); ++pdtEntry) {
805 ParticleDataEntry& pdtNow = pdtEntry->second;
806 int idNow = pdtNow.id();
809 if (pdtNow.isResonance() && pdtNow.getResonancePtr() == 0) {
810 resonancePtr =
new ResonanceGeneric(idNow);
811 setResonancePtr( idNow, resonancePtr);
815 if (pdtNow.getResonancePtr() != 0 && idNow != 23 && idNow != 24) {
816 double m0Now = pdtNow.m0();
817 idOrdered.push_back(idNow);
818 m0Ordered.push_back(m0Now);
819 for (
int i =
int(idOrdered.size()) - 2; i > 1; --i) {
820 if (m0Ordered[i] < m0Now)
break;
821 swap( idOrdered[i], idOrdered[i + 1]);
822 swap( m0Ordered[i], m0Ordered[i + 1]);
828 for (
int i = 0; i < int(idOrdered.size()); ++i) {
829 resInit( idOrdered[i]);
830 ParticleDataEntry* pdtPtrNow = particleDataEntryPtr( idOrdered[i]);
831 pdtPtrNow->initBWmass();
840 bool ParticleData::readXML(
string inFile,
bool reset) {
843 if (!loadXML(inFile,reset))
return false;
846 if (!processXML(reset))
return false;
856 bool ParticleData::readXML(istream &inStr,
bool reset) {
859 if (!loadXML(inStr,reset))
return false;
862 if (!processXML(reset))
return false;
872 bool ParticleData::copyXML(
const ParticleData &particleDataIn) {
877 readStringHistory.resize(0);
878 readStringSubrun.clear();
880 xmlFileSav=particleDataIn.xmlFileSav;
883 if (!processXML(
true))
return false;
892 bool ParticleData::loadXML(istream& is,
bool reset) {
898 readStringHistory.resize(0);
899 readStringSubrun.clear();
905 infoPtr->errorMsg(
"Error in ParticleData::readXML:"
906 " did not find data");
913 while ( getline(is, line) ) {
916 istringstream getfirst(line);
921 if (word1 ==
"<file") {
922 string file = attributeValue(line,
"name");
927 xmlFileSav.push_back(line);
941 bool ParticleData::loadXML(
string inFile,
bool reset) {
943 const char* cstring = inFile.c_str();
944 ifstream is(cstring);
946 return loadXML(is, reset);
953 bool ParticleData::processXML(
bool reset) {
956 int nLines = xmlFileSav.size();
961 while (++i < nLines) {
964 string line = xmlFileSav[i];
967 istringstream getfirst(line);
972 if (word1 ==
"<particle") {
973 while (line.find(
">") == string::npos) {
974 if (++i >= nLines)
break;
975 string addLine = xmlFileSav[i];
980 int idTmp = intAttributeValue( line,
"id");
981 string nameTmp = attributeValue( line,
"name");
982 string antiNameTmp = attributeValue( line,
"antiName");
983 if (antiNameTmp ==
"") antiNameTmp =
"void";
984 int spinTypeTmp = intAttributeValue( line,
"spinType");
985 int chargeTypeTmp = intAttributeValue( line,
"chargeType");
986 int colTypeTmp = intAttributeValue( line,
"colType");
987 double m0Tmp = doubleAttributeValue( line,
"m0");
988 double mWidthTmp = doubleAttributeValue( line,
"mWidth");
989 double mMinTmp = doubleAttributeValue( line,
"mMin");
990 double mMaxTmp = doubleAttributeValue( line,
"mMax");
991 double tau0Tmp = doubleAttributeValue( line,
"tau0");
994 if (isParticle(idTmp)) pdt.erase(idTmp);
997 addParticle( idTmp, nameTmp, antiNameTmp, spinTypeTmp, chargeTypeTmp,
998 colTypeTmp, m0Tmp, mWidthTmp, mMinTmp, mMaxTmp, tau0Tmp);
999 particlePtr = particleDataEntryPtr(idTmp);
1002 }
else if (word1 ==
"<channel") {
1003 while (line.find(
">") == string::npos) {
1004 if (++i >= nLines)
break;
1005 string addLine = xmlFileSav[i];
1010 int onMode = intAttributeValue( line,
"onMode");
1011 double bRatio = doubleAttributeValue( line,
"bRatio");
1012 int meMode = intAttributeValue( line,
"meMode");
1013 string products = attributeValue( line,
"products");
1016 istringstream prodStream(products);
1017 int prod0 = 0;
int prod1 = 0;
int prod2 = 0;
int prod3 = 0;
1018 int prod4 = 0;
int prod5 = 0;
int prod6 = 0;
int prod7 = 0;
1019 prodStream >> prod0 >> prod1 >> prod2 >> prod3 >> prod4 >> prod5
1022 infoPtr->errorMsg(
"Error in ParticleData::readXML:"
1023 " incomplete decay channel", line);
1028 if (particlePtr == 0) {
1029 infoPtr->errorMsg(
"Error in ParticleData::readXML:"
1030 " orphan decay channel", line);
1033 particlePtr->addChannel(onMode, bRatio, meMode, prod0, prod1,
1034 prod2, prod3, prod4, prod5, prod6, prod7);
1041 if (reset)
for (map<int, ParticleDataEntry>::iterator pdtEntry
1042 = pdt.begin(); pdtEntry != pdt.end(); ++pdtEntry) {
1043 particlePtr = &pdtEntry->second;
1044 particlePtr->setHasChanged(
false);
1057 void ParticleData::listXML(
string outFile) {
1060 const char* cstring = outFile.c_str();
1061 ofstream os(cstring);
1064 for (map<int, ParticleDataEntry>::iterator pdtEntry
1065 = pdt.begin(); pdtEntry != pdt.end(); ++pdtEntry) {
1066 particlePtr = &pdtEntry->second;
1069 os <<
"<particle id=\"" << particlePtr->id() <<
"\""
1070 <<
" name=\"" << particlePtr->name() <<
"\"";
1071 if (particlePtr->hasAnti())
1072 os <<
" antiName=\"" << particlePtr->name(-1) <<
"\"";
1073 os <<
" spinType=\"" << particlePtr->spinType() <<
"\""
1074 <<
" chargeType=\"" << particlePtr->chargeType() <<
"\""
1075 <<
" colType=\"" << particlePtr->colType() <<
"\"\n";
1077 double m0Now = particlePtr->m0();
1078 if (m0Now == 0 || (m0Now > 0.1 && m0Now < 1000.))
1079 os << fixed << setprecision(5);
1080 else os << scientific << setprecision(3);
1081 os <<
" m0=\"" << m0Now <<
"\"";
1082 if (particlePtr->mWidth() > 0.)
1083 os <<
" mWidth=\"" << particlePtr->mWidth() <<
"\""
1084 <<
" mMin=\"" << particlePtr->mMin() <<
"\""
1085 <<
" mMax=\"" << particlePtr->mMax() <<
"\"";
1086 if (particlePtr->tau0() > 0.) os << scientific << setprecision(5)
1087 <<
" tau0=\"" << particlePtr->tau0() <<
"\"";
1091 if (particlePtr->sizeChannels() > 0) {
1092 for (
int i = 0; i < particlePtr->sizeChannels(); ++i) {
1093 const DecayChannel& channel = particlePtr->channel(i);
1094 int mult = channel.multiplicity();
1097 os <<
" <channel onMode=\"" << channel.onMode() <<
"\""
1098 << fixed << setprecision(7)
1099 <<
" bRatio=\"" << channel.bRatio() <<
"\"";
1100 if (channel.meMode() > 0)
1101 os <<
" meMode=\"" << channel.meMode() <<
"\"";
1102 os <<
" products=\"";
1103 for (
int j = 0; j < mult; ++j) {
1104 os << channel.product(j);
1105 if (j < mult - 1) os <<
" ";
1114 os <<
"</particle>\n\n";
1124 bool ParticleData::readFF(istream& is,
bool reset) {
1129 readStringHistory.resize(0);
1130 readStringSubrun.clear();
1135 infoPtr->errorMsg(
"Error in ParticleData::readFF:"
1136 " did not find stream");
1143 bool readParticle =
false;
1144 while ( getline(is, line) ) {
1147 if (line.find_first_not_of(
" \n\t\v\b\r\f\a") == string::npos) {
1148 readParticle =
true;
1153 istringstream readLine(line);
1160 string nameTmp, antiNameTmp;
1161 int spinTypeTmp, chargeTypeTmp, colTypeTmp;
1162 double m0Tmp, mWidthTmp, mMinTmp, mMaxTmp, tau0Tmp;
1166 readLine >> idTmp >> nameTmp >> antiNameTmp >> spinTypeTmp
1167 >> chargeTypeTmp >> colTypeTmp >> m0Tmp >> mWidthTmp
1168 >> mMinTmp >> mMaxTmp >> tau0Tmp;
1172 infoPtr->errorMsg(
"Error in ParticleData::readFF:"
1173 " incomplete particle", line);
1178 if (isParticle(idTmp)) pdt.erase(idTmp);
1181 addParticle( idTmp, nameTmp, antiNameTmp, spinTypeTmp, chargeTypeTmp,
1182 colTypeTmp, m0Tmp, mWidthTmp, mMinTmp, mMaxTmp, tau0Tmp);
1183 particlePtr = particleDataEntryPtr(idTmp);
1184 readParticle =
false;
1193 int prod0 = 0;
int prod1 = 0;
int prod2 = 0;
int prod3 = 0;
1194 int prod4 = 0;
int prod5 = 0;
int prod6 = 0;
int prod7 = 0;
1197 readLine >> onMode >> bRatio >> meMode >> prod0;
1199 infoPtr->errorMsg(
"Error in ParticleData::readFF:"
1200 " incomplete decay channel", line);
1203 readLine >> prod1 >> prod2 >> prod3 >> prod4 >> prod5
1207 if (particlePtr == 0) {
1208 infoPtr->errorMsg(
"Error in ParticleData::readFF:"
1209 " orphan decay channel", line);
1212 particlePtr->addChannel(onMode, bRatio, meMode, prod0, prod1,
1213 prod2, prod3, prod4, prod5, prod6, prod7);
1232 bool ParticleData::readFF(
string inFile,
bool reset) {
1234 const char* cstring = inFile.c_str();
1235 ifstream is(cstring);
1237 return readFF(is,reset);
1244 void ParticleData::listFF(
string outFile) {
1247 const char* cstring = outFile.c_str();
1248 ofstream os(cstring);
1251 for (map<int, ParticleDataEntry>::iterator pdtEntry
1252 = pdt.begin(); pdtEntry != pdt.end(); ++pdtEntry) {
1253 particlePtr = &pdtEntry->second;
1256 double m0Now = particlePtr->m0();
1257 if (m0Now == 0 || (m0Now > 0.1 && m0Now < 1000.))
1258 os << fixed << setprecision(5);
1259 else os << scientific << setprecision(3);
1262 os <<
"\n" << setw(8) << particlePtr->id() <<
" "
1263 << left << setw(16) << particlePtr->name() <<
" "
1264 << setw(16) << particlePtr->name(-1) <<
" "
1265 << right << setw(2) << particlePtr->spinType() <<
" "
1266 << setw(2) << particlePtr->chargeType() <<
" "
1267 << setw(2) << particlePtr->colType() <<
" "
1268 << setw(10) << particlePtr->m0() <<
" "
1269 << setw(10) << particlePtr->mWidth() <<
" "
1270 << setw(10) << particlePtr->mMin() <<
" "
1271 << setw(10) << particlePtr->mMax() <<
" "
1272 << scientific << setprecision(5)
1273 << setw(12) << particlePtr->tau0() <<
"\n";
1276 if (particlePtr->sizeChannels() > 0) {
1277 for (
int i = 0; i < particlePtr->sizeChannels(); ++i) {
1278 const DecayChannel& channel = particlePtr->channel(i);
1279 os <<
" " << setw(6) << channel.onMode()
1280 <<
" " << fixed << setprecision(7) << setw(10)
1281 << channel.bRatio() <<
" "
1282 << setw(3) << channel.meMode() <<
" ";
1283 for (
int j = 0; j < channel.multiplicity(); ++j)
1284 os << setw(8) << channel.product(j) <<
" ";
1298 bool ParticleData::readString(
string lineIn,
bool warn) {
1301 if (lineIn.find_first_not_of(
" \n\t\v\b\r\f\a") == string::npos)
return true;
1304 string line = lineIn;
1307 int firstChar = line.find_first_not_of(
" \n\t\v\b\r\f\a");
1308 if (!isdigit(line[firstChar]))
return true;
1311 for (
int j = 0; j < int(line.size()); ++ j)
1312 if (line[j] ==
':' || line[j] ==
'=') line[j] =
' ';
1317 istringstream getWord(line);
1318 getWord >> idTmp >> property;
1319 toLowerRep(property);
1322 if ( (!isParticle(idTmp) && property !=
"all" && property !=
"new")
1324 if (warn) cout <<
"\n PYTHIA Error: input particle not found in Particle"
1325 <<
" Data Table:\n " << lineIn <<
"\n";
1326 readingFailedSave =
true;
1331 readStringHistory.push_back(line);
1332 int subrun = max( -1, settingsPtr->mode(
"Main:subrun"));
1333 if (readStringSubrun.find(subrun) == readStringSubrun.end())
1334 readStringSubrun[subrun] = vector<string>();
1335 readStringSubrun[subrun].push_back(line);
1338 if (property ==
"name") {
1341 pdt[idTmp].setName(nameTmp);
1344 if (property ==
"antiname") {
1346 getWord >> antiNameTmp;
1347 pdt[idTmp].setAntiName(antiNameTmp);
1350 if (property ==
"names") {
1351 string nameTmp, antiNameTmp;
1352 getWord >> nameTmp >> antiNameTmp;
1353 pdt[idTmp].setNames(nameTmp, antiNameTmp);
1356 if (property ==
"spintype") {
1358 getWord >> spinTypeTmp;
1359 pdt[idTmp].setSpinType(spinTypeTmp);
1362 if (property ==
"chargetype") {
1364 getWord >> chargeTypeTmp;
1365 pdt[idTmp].setChargeType(chargeTypeTmp);
1368 if (property ==
"coltype") {
1370 getWord >> colTypeTmp;
1371 pdt[idTmp].setColType(colTypeTmp);
1374 if (property ==
"m0") {
1377 pdt[idTmp].setM0(m0Tmp);
1380 if (property ==
"mwidth") {
1382 getWord >> mWidthTmp;
1383 pdt[idTmp].setMWidth(mWidthTmp);
1386 if (property ==
"mmin") {
1389 pdt[idTmp].setMMin(mMinTmp);
1392 if (property ==
"mmax") {
1395 pdt[idTmp].setMMax(mMaxTmp);
1398 if (property ==
"tau0") {
1401 pdt[idTmp].setTau0(tau0Tmp);
1404 if (property ==
"isresonance") {
1406 getWord >> isresTmp;
1407 bool isResonanceTmp = boolString(isresTmp);
1408 pdt[idTmp].setIsResonance(isResonanceTmp);
1411 if (property ==
"maydecay") {
1414 bool mayDecayTmp = boolString(mayTmp);
1415 pdt[idTmp].setMayDecay(mayDecayTmp);
1418 if (property ==
"doexternaldecay") {
1420 getWord >> extdecTmp;
1421 bool doExternalDecayTmp = boolString(extdecTmp);
1422 pdt[idTmp].setDoExternalDecay(doExternalDecayTmp);
1425 if (property ==
"isvisible") {
1427 getWord >> isvisTmp;
1428 bool isVisibleTmp = boolString(isvisTmp);
1429 pdt[idTmp].setIsVisible(isVisibleTmp);
1432 if (property ==
"doforcewidth") {
1434 getWord >> doforceTmp;
1435 bool doForceWidthTmp = boolString(doforceTmp);
1436 pdt[idTmp].setDoForceWidth(doForceWidthTmp);
1441 if (property ==
"all" || property ==
"new") {
1444 string nameTmp =
"void";
1445 string antiNameTmp =
"void";
1446 int spinTypeTmp = 0;
1447 int chargeTypeTmp = 0;
1450 double mWidthTmp = 0.;
1451 double mMinTmp = 0.;
1452 double mMaxTmp = 0.;
1453 double tau0Tmp = 0.;
1456 getWord >> nameTmp >> antiNameTmp >> spinTypeTmp >> chargeTypeTmp
1457 >> colTypeTmp >> m0Tmp >> mWidthTmp >> mMinTmp >> mMaxTmp
1461 if (property ==
"all" && isParticle(idTmp)) {
1462 setAll( idTmp, nameTmp, antiNameTmp, spinTypeTmp, chargeTypeTmp,
1463 colTypeTmp, m0Tmp, mWidthTmp, mMinTmp, mMaxTmp, tau0Tmp);
1467 if (isParticle(idTmp)) pdt.erase(idTmp);
1468 addParticle( idTmp, nameTmp, antiNameTmp, spinTypeTmp, chargeTypeTmp,
1469 colTypeTmp, m0Tmp, mWidthTmp, mMinTmp, mMaxTmp, tau0Tmp);
1475 if (property ==
"onmode") {
1478 getWord >> onModeIn;
1480 if (isdigit(onModeIn[0])) {
1481 istringstream getOnMode(onModeIn);
1482 getOnMode >> onMode;
1483 }
else onMode = (boolString(onModeIn)) ? 1 : 0;
1484 for (
int i = 0; i < pdt[idTmp].sizeChannels(); ++i)
1485 pdt[idTmp].channel(i).onMode(onMode);
1491 if (property ==
"offifany" || property ==
"onifany" ||
1492 property ==
"onposifany" || property ==
"onnegifany") matchKind = 1;
1493 if (property ==
"offifall" || property ==
"onifall" ||
1494 property ==
"onposifall" || property ==
"onnegifall") matchKind = 2;
1495 if (property ==
"offifmatch" || property ==
"onifmatch" ||
1496 property ==
"onposifmatch" || property ==
"onnegifmatch") matchKind = 3;
1497 if (matchKind > 0) {
1499 if (property ==
"onifany" || property ==
"onifall"
1500 || property ==
"onifmatch") onMode = 1;
1501 if (property ==
"onposifany" || property ==
"onposifall"
1502 || property ==
"onposifmatch") onMode = 2;
1503 if (property ==
"onnegifany" || property ==
"onnegifall"
1504 || property ==
"onnegifmatch") onMode = 3;
1507 vector<int> idToMatch;
1511 if (!getWord)
break;
1512 idToMatch.push_back(abs(idRead));
1514 int nToMatch = idToMatch.size();
1517 for (
int i = 0; i < pdt[idTmp].sizeChannels(); ++i) {
1518 int multi = pdt[idTmp].channel(i).multiplicity();
1521 if (matchKind == 1) {
1522 bool foundMatch =
false;
1523 for (
int j = 0; j < multi; ++j) {
1524 int idNow = abs(pdt[idTmp].channel(i).product(j));
1525 for (
int k = 0; k < nToMatch; ++k)
1526 if (idNow == idToMatch[k]) {foundMatch =
true;
break;}
1527 if (foundMatch)
break;
1529 if (foundMatch) pdt[idTmp].channel(i).onMode(onMode);
1533 int nUnmatched = nToMatch;
1534 if (multi < nToMatch);
1535 else if (multi > nToMatch && matchKind == 3);
1537 vector<int> idUnmatched;
1538 for (
int k = 0; k < nToMatch; ++k)
1539 idUnmatched.push_back(idToMatch[k]);
1540 for (
int j = 0; j < multi; ++j) {
1541 int idNow = abs(pdt[idTmp].channel(i).product(j));
1542 for (
int k = 0; k < nUnmatched; ++k)
1543 if (idNow == idUnmatched[k]) {
1544 idUnmatched[k] = idUnmatched[--nUnmatched];
1547 if (nUnmatched == 0)
break;
1550 if (nUnmatched == 0) pdt[idTmp].channel(i).onMode(onMode);
1557 if (property ==
"rescalebr") {
1560 pdt[idTmp].rescaleBR(factor);
1565 if (property ==
"onechannel") pdt[idTmp].clearChannels();
1568 if (property ==
"addchannel" || property ==
"onechannel"
1569 || isdigit(property[0])) {
1571 if (property ==
"addchannel" || property ==
"onechannel") {
1572 pdt[idTmp].addChannel();
1573 channel = pdt[idTmp].sizeChannels() - 1;
1576 istringstream getChannel(property);
1577 getChannel >> channel;
1578 getWord >> property;
1579 toLowerRep(property);
1583 if (channel < 0 || channel >= pdt[idTmp].sizeChannels())
return false;
1587 if (property ==
"onmode" || property ==
"all") {
1590 getWord >> onModeIn;
1592 if (isdigit(onModeIn[0])) {
1593 istringstream getOnMode(onModeIn);
1594 getOnMode >> onMode;
1595 }
else onMode = (boolString(onModeIn)) ? 1 : 0;
1596 pdt[idTmp].channel(channel).onMode(onMode);
1597 if (property ==
"onmode")
return true;
1599 if (property ==
"bratio" || property ==
"all") {
1602 pdt[idTmp].channel(channel).bRatio(bRatio);
1603 if (property ==
"bratio")
return true;
1605 if (property ==
"memode" || property ==
"all") {
1608 pdt[idTmp].channel(channel).meMode(meMode);
1609 if (property ==
"memode")
return true;
1613 if (property ==
"products" || property ==
"all") {
1615 for (
int iProd = 0; iProd < 8; ++iProd) {
1618 if (!getWord)
break;
1619 pdt[idTmp].channel(channel).product(iProd, idProd);
1622 for (
int iProd = nProd; iProd < 8; ++iProd)
1623 pdt[idTmp].channel(channel).product(iProd, 0);
1624 pdt[idTmp].channel(channel).multiplicity(nProd);
1629 if (property ==
"rescalebr") {
1632 pdt[idTmp].channel(channel).rescaleBR(factor);
1638 if (warn) cout <<
"\n PYTHIA Error: input property not found in Particle"
1639 <<
" Data Table:\n " << lineIn <<
"\n";
1640 readingFailedSave =
true;
1649 void ParticleData::list(
bool changedOnly,
bool changedRes) {
1653 cout <<
"\n -------- PYTHIA Particle Data Table (complete) --------"
1654 <<
"------------------------------------------------------------"
1655 <<
"--------------\n \n";
1658 cout <<
"\n -------- PYTHIA Particle Data Table (changed only) ----"
1659 <<
"------------------------------------------------------------"
1660 <<
"--------------\n \n";
1662 cout <<
" id name antiName spn chg col m0"
1663 <<
" mWidth mMin mMax tau0 res dec ext "
1664 <<
"vis wid\n no onMode bRatio meMode products \n";
1668 for (map<int, ParticleDataEntry>::iterator pdtEntry
1669 = pdt.begin(); pdtEntry != pdt.end(); ++pdtEntry) {
1670 particlePtr = &pdtEntry->second;
1671 if ( !changedOnly || particlePtr->hasChanged() ||
1672 ( changedRes && particlePtr->getResonancePtr() != 0 ) ) {
1675 double m0Now = particlePtr->m0();
1676 if (m0Now == 0 || (m0Now > 0.1 && m0Now < 1000.))
1677 cout << fixed << setprecision(5);
1678 else cout << scientific << setprecision(3);
1682 cout <<
"\n" << setw(8) << particlePtr->id() <<
" " << left;
1683 if (particlePtr->name(-1) ==
"void")
1684 cout << setw(33) << particlePtr->name() <<
" ";
1685 else cout << setw(16) << particlePtr->name() <<
" "
1686 << setw(16) << particlePtr->name(-1) <<
" ";
1687 cout << right << setw(2) << particlePtr->spinType() <<
" "
1688 << setw(2) << particlePtr->chargeType() <<
" "
1689 << setw(2) << particlePtr->colType() <<
" "
1690 << setw(10) << particlePtr->m0() <<
" "
1691 << setw(10) << particlePtr->mWidth() <<
" "
1692 << setw(10) << particlePtr->mMin() <<
" "
1693 << setw(10) << particlePtr->mMax() <<
" "
1694 << scientific << setprecision(5)
1695 << setw(12) << particlePtr->tau0() <<
" " << setw(2)
1696 << particlePtr->isResonance() <<
" " << setw(2)
1697 << (particlePtr->mayDecay() && particlePtr->canDecay())
1698 <<
" " << setw(2) << particlePtr->doExternalDecay() <<
" "
1699 << setw(2) << particlePtr->isVisible()<<
" "
1700 << setw(2) << particlePtr->doForceWidth() <<
"\n";
1703 if (particlePtr->sizeChannels() > 0) {
1704 for (
int i = 0; i < int(particlePtr->sizeChannels()); ++i) {
1705 const DecayChannel& channel = particlePtr->channel(i);
1706 cout <<
" " << setprecision(7) << setw(5) << i
1707 << setw(6) << channel.onMode() << fixed<< setw(12)
1708 << channel.bRatio() << setw(5) << channel.meMode() <<
" ";
1709 for (
int j = 0; j < channel.multiplicity(); ++j)
1710 cout << setw(8) << channel.product(j) <<
" ";
1719 if (changedOnly && nList == 0) cout <<
"\n no particle data has been "
1720 <<
"changed from its default value \n";
1721 cout <<
"\n -------- End PYTHIA Particle Data Table -----------------"
1722 <<
"--------------------------------------------------------------"
1723 <<
"----------\n" << endl;
1731 void ParticleData::list(vector<int> idList) {
1734 cout <<
"\n -------- PYTHIA Particle Data Table (partial) ---------"
1735 <<
"------------------------------------------------------------"
1736 <<
"--------------\n \n";
1737 cout <<
" id name antiName spn chg col m0"
1738 <<
" mWidth mMin mMax tau0 res dec ext "
1739 <<
"vis wid\n no onMode bRatio meMode products \n";
1742 for (
int i = 0; i < int(idList.size()); ++i) {
1743 particlePtr = particleDataEntryPtr(idList[i]);
1746 double m0Now = particlePtr->m0();
1747 if (m0Now == 0 || (m0Now > 0.1 && m0Now < 1000.))
1748 cout << fixed << setprecision(5);
1749 else cout << scientific << setprecision(3);
1752 cout <<
"\n" << setw(8) << particlePtr->id() <<
" " << left;
1753 if (particlePtr->name(-1) ==
"void")
1754 cout << setw(33) << particlePtr->name() <<
" ";
1755 else cout << setw(16) << particlePtr->name() <<
" "
1756 << setw(16) << particlePtr->name(-1) <<
" ";
1757 cout << right << setw(2) << particlePtr->spinType() <<
" "
1758 << setw(2) << particlePtr->chargeType() <<
" "
1759 << setw(2) << particlePtr->colType() <<
" "
1760 << setw(10) << particlePtr->m0() <<
" "
1761 << setw(10) << particlePtr->mWidth() <<
" "
1762 << setw(10) << particlePtr->mMin() <<
" "
1763 << setw(10) << particlePtr->mMax() <<
" "
1764 << scientific << setprecision(5)
1765 << setw(12) << particlePtr->tau0() <<
" " << setw(2)
1766 << particlePtr->isResonance() <<
" " << setw(2)
1767 << (particlePtr->mayDecay() && particlePtr->canDecay())
1768 <<
" " << setw(2) << particlePtr->doExternalDecay() <<
" "
1769 << setw(2) << particlePtr->isVisible() <<
" "
1770 << setw(2) << particlePtr->doForceWidth() <<
"\n";
1773 if (particlePtr->sizeChannels() > 0) {
1774 for (
int j = 0; j < int(particlePtr->sizeChannels()); ++j) {
1775 const DecayChannel& channel = particlePtr->channel(j);
1776 cout <<
" " << setprecision(7) << setw(5) << j
1777 << setw(6) << channel.onMode() << fixed << setw(12)
1778 << channel.bRatio() << setw(5) << channel.meMode() <<
" ";
1779 for (
int k = 0; k < channel.multiplicity(); ++k)
1780 cout << setw(8) << channel.product(k) <<
" ";
1788 cout <<
"\n -------- End PYTHIA Particle Data Table -----------------"
1789 <<
"--------------------------------------------------------------"
1790 <<
"----------\n" << endl;
1805 void ParticleData::checkTable(
int verbosity) {
1808 cout <<
"\n -------- PYTHIA Check of Particle Data Table ------------"
1813 for (map<int, ParticleDataEntry>::iterator pdtEntry
1814 = pdt.begin(); pdtEntry != pdt.end(); ++pdtEntry) {
1815 particlePtr = &pdtEntry->second;
1818 int idNow = particlePtr->id();
1819 bool hasAntiNow = particlePtr->hasAnti();
1820 int spinTypeNow = particlePtr->spinType();
1821 int chargeTypeNow = particlePtr->chargeType();
1822 int baryonTypeNow = particlePtr->baryonNumberType();
1823 double m0Now = particlePtr->m0();
1824 double mMinNow = particlePtr->mMin();
1825 double mMaxNow = particlePtr->mMax();
1826 double mWidthNow = particlePtr->mWidth();
1827 double tau0Now = particlePtr->tau0();
1828 bool isResonanceNow = particlePtr->isResonance();
1829 bool hasPrinted =
false;
1830 bool studyCloser = verbosity > 10 || !isResonanceNow;
1833 string particleName = particlePtr->name(1);
1834 if (particleName.size() > 16) {
1835 cout <<
" Warning: particle " << idNow <<
" has name " << particleName
1836 <<
" of length " << particleName.size() <<
"\n";
1842 for (
int i = 0; i < int(particleName.size()); ++i) {
1843 if (particleName[i] ==
'+') ++nPos;
1844 if (particleName[i] ==
'-') ++nNeg;
1846 if ( (nPos > 0 && nNeg > 0) || ( nPos + nNeg > 0
1847 && 3 * (nPos - nNeg) != chargeTypeNow )) {
1848 cout <<
" Warning: particle " << idNow <<
" has name " << particleName
1849 <<
" inconsistent with charge type " << chargeTypeNow <<
"\n";
1856 particleName = particlePtr->name(-1);
1857 if (particleName.size() > 16) {
1858 cout <<
" Warning: particle " << idNow <<
" has name " << particleName
1859 <<
" of length " << particleName.size() <<
"\n";
1865 for (
int i = 0; i < int(particleName.size()); ++i) {
1866 if (particleName[i] ==
'+') ++nPos;
1867 if (particleName[i] ==
'-') ++nNeg;
1869 if ( (nPos > 0 && nNeg > 0) || ( nPos + nNeg > 0
1870 && 3 * (nPos - nNeg) != -chargeTypeNow )) {
1871 cout <<
" Warning: particle " << -idNow <<
" has name "
1872 << particleName <<
" inconsistent with charge type "
1873 << -chargeTypeNow <<
"\n";
1880 if (particlePtr->useBreitWigner()) {
1881 if (mMinNow > m0Now) {
1882 cout <<
" Error: particle " << idNow <<
" has mMin "
1883 << fixed << setprecision(5) << mMinNow
1884 <<
" larger than m0 " << m0Now <<
"\n";
1888 if (mMaxNow > mMinNow && mMaxNow < m0Now) {
1889 cout <<
" Error: particle " << idNow <<
" has mMax "
1890 << fixed << setprecision(5) << mMaxNow
1891 <<
" smaller than m0 " << m0Now <<
"\n";
1895 if (mMaxNow > mMinNow && mMaxNow - mMinNow < mWidthNow) {
1896 cout <<
" Warning: particle " << idNow <<
" has mMax - mMin "
1897 << fixed << setprecision(5) << mMaxNow - mMinNow
1898 <<
" smaller than mWidth " << mWidthNow <<
"\n";
1905 if (mWidthNow > 0. && tau0Now > 0.) {
1906 cout <<
" Warning: particle " << idNow <<
" has both nonvanishing width "
1907 << scientific << setprecision(5) << mWidthNow <<
" and lifetime "
1914 if (particlePtr->sizeChannels() > 0) {
1917 double bRatioSum = 0.;
1918 double bRatioPos = 0.;
1919 double bRatioNeg = 0.;
1920 bool hasPosBR =
false;
1921 bool hasNegBR =
false;
1922 double threshMass = 0.;
1923 bool openChannel =
false;
1924 for (
int i = 0; i < particlePtr->sizeChannels(); ++i) {
1927 int onMode = particlePtr->channel(i).onMode();
1928 double bRatio = particlePtr->channel(i).bRatio();
1929 int meMode = particlePtr->channel(i).meMode();
1930 int mult = particlePtr->channel(i).multiplicity();
1932 for (
int j = 0; j < 8; ++j)
1933 prod[j] = particlePtr->channel(i).product(j);
1936 if (onMode == 0 || onMode == 1) bRatioSum += bRatio;
1937 else if (onMode == 2) {bRatioPos += bRatio; hasPosBR =
true;}
1938 else if (onMode == 3) {bRatioNeg += bRatio; hasNegBR =
true;}
1941 for (
int j = 0; j < 8; ++j) {
1942 if ( prod[j] != 0 && !isParticle(prod[j]) ) {
1943 cout <<
" Error: unknown decay product for " << idNow
1944 <<
" -> " << prod[j] <<
"\n";
1953 for (
int j = 0; j < 8; ++j)
1954 if (prod[j] != 0) nLast = j + 1;
1955 if (mult == 0 || mult != nLast) {
1956 cout <<
" Error: corrupted decay product list for "
1957 << particlePtr->id() <<
" -> ";
1958 for (
int j = 0; j < 8; ++j) cout << prod[j] <<
" ";
1966 int chargeTypeSum = -chargeTypeNow;
1967 int baryonTypeSum = -baryonTypeNow;
1968 double avgFinalMass = 0.;
1969 double minFinalMass = 0.;
1970 bool canHandle =
true;
1971 for (
int j = 0; j < mult; ++j) {
1972 chargeTypeSum += chargeType( prod[j] );
1973 baryonTypeSum += baryonNumberType( prod[j] );
1974 avgFinalMass += m0( prod[j] );
1975 minFinalMass += m0Min( prod[j] );
1976 if (prod[j] == 81 || prod[j] == 82 || prod[j] == 83)
1979 threshMass += bRatio * avgFinalMass;
1982 if (chargeTypeSum != 0 && canHandle) {
1983 cout <<
" Error: 3*charge changed by " << chargeTypeSum
1984 <<
" in " << idNow <<
" -> ";
1985 for (
int j = 0; j < mult; ++j) cout << prod[j] <<
" ";
1991 if ( baryonTypeSum != 0 && canHandle && particlePtr->isHadron() ) {
1992 cout <<
" Error: 3*baryon number changed by " << baryonTypeSum
1993 <<
" in " << idNow <<
" -> ";
1994 for (
int j = 0; j < mult; ++j) cout << prod[j] <<
" ";
2002 bool correctME =
true;
2005 if (meMode == 0 && !isResonanceNow) {
2006 bool hasPartons =
false;
2007 for (
int j = 0; j < mult; ++j) {
2008 int idAbs = abs(prod[j]);
2009 if ( idAbs < 10 || idAbs == 21 || idAbs == 81 || idAbs == 82
2010 || idAbs == 83 || (idAbs > 1000 && idAbs < 10000
2011 && (idAbs/10)%10 == 0) ) hasPartons =
true;
2013 if (hasPartons) correctME =
false;
2017 bool useME1 = ( mult == 3 && spinTypeNow == 3 && idNow > 100
2019 && particlePtr->channel(i).contains(211, -211, 111) );
2020 if ( meMode == 1 && !useME1 ) correctME =
false;
2021 if ( meMode != 1 && useME1 ) correctME =
false;
2024 bool useME2 = ( mult == 2 && spinTypeNow == 3 && idNow > 100
2025 && idNow < 1000 && spinType(prod[0]) == 1
2026 && spinType(prod[1]) == 1 );
2027 if ( meMode == 2 && !useME2 ) correctME =
false;
2028 if ( meMode != 2 && useME2 ) correctME =
false;
2033 bool useME11 = ( mult == 3 && !isResonanceNow
2034 && (prod[1] == 11 || prod[1] == 13 || prod[1] == 15)
2035 && prod[2] == -prod[1] );
2036 bool useME12 = ( mult > 3 && !isResonanceNow
2037 && (prod[mult - 2] == 11 || prod[mult - 2] == 13
2038 || prod[mult - 2] == 15) && prod[mult - 1] == -prod[mult - 2] );
2039 bool useME13 = ( mult == 4 && !isResonanceNow
2040 && (prod[0] == 11 || prod[0] == 13) && prod[1] == -prod[0]
2041 && (prod[2] == 11 || prod[2] == 13) && prod[3] == -prod[2] );
2042 if (useME13) useME12 =
false;
2043 if ( meMode == 11 && !useME11 ) correctME =
false;
2044 if ( meMode != 11 && useME11 ) correctME =
false;
2045 if ( meMode == 12 && !useME12 ) correctME =
false;
2046 if ( meMode != 12 && useME12 ) correctME =
false;
2047 if ( meMode == 13 && !useME13 ) correctME =
false;
2048 if ( meMode != 13 && useME13 ) correctME =
false;
2051 bool useME21 = (idNow == 15 && mult > 2 && prod[0] == 16
2052 && abs(prod[1]) > 100);
2053 if ( meMode == 21 && !useME21 ) correctME =
false;
2054 if ( meMode != 21 && useME21 ) correctME =
false;
2058 if ( isLepton(prod[0]) && isLepton(prod[1]) ) {
2059 bool useME22 =
false;
2063 if (particlePtr->isLepton()) {
2064 typeA = (idNow > 0) ? 1 + (idNow-1)%2 : -1 - (1-idNow)%2;
2065 }
else if (particlePtr->isHadron()) {
2066 int hQ = particlePtr->heaviestQuark();
2068 if (idNow == 541 && heaviestQuark(prod[2]) == -5) hQ = 4;
2069 typeA = (hQ > 0) ? 1 + (hQ-1)%2 : -1 - (1-hQ)%2;
2071 typeB = (prod[0] > 0) ? 1 + (prod[0]-1)%2 : -1 - (1-prod[0])%2;
2072 typeC = (prod[1] > 0) ? 1 + (prod[1]-1)%2 : -1 - (1-prod[1])%2;
2074 if ( (idNow == 130 || idNow == 310) && typeC * typeA < 0)
2076 if (mult == 3 && idNow == 2112 && prod[2] == 2212)
2078 if (mult == 3 && idNow == 3222 && prod[2] == 3122)
2080 if (mult > 2 && typeC == typeA && typeB * typeC < 0
2081 && (typeB + typeC)%2 != 0) useME22 =
true;
2082 if ( meMode == 22 && !useME22 ) correctME =
false;
2083 if ( meMode != 22 && useME22 ) correctME =
false;
2089 for (
int j = 0; j < mult; ++j)
if (prod[j] == 22) ++nGamma;
2090 if (nGamma != 1) correctME =
false;
2094 if ( !isResonanceNow && (meMode < 0 || (meMode > 2 && meMode <= 10)
2095 || (meMode > 13 && meMode <= 20) || (meMode > 23 && meMode <= 30)
2096 || (meMode > 31 && meMode <= 41) || meMode == 51 || meMode == 61
2097 || meMode == 71 || (meMode > 80 && meMode <= 90)
2098 || (!particlePtr->isOctetHadron() && meMode > 92) ) )
2103 cout <<
" Warning: meMode " << meMode <<
" used for "
2105 for (
int j = 0; j < mult; ++j) cout << prod[j] <<
" ";
2112 if ( studyCloser && verbosity > 0 && canHandle && onMode > 0
2113 && particlePtr->m0Min() - minFinalMass < 0. ) {
2114 if (particlePtr->m0Max() - minFinalMass < 0.)
2115 cout <<
" Error: decay never possible for ";
2116 else cout <<
" Warning: decay sometimes not possible for ";
2117 cout << idNow <<
" -> ";
2118 for (
int j = 0; j < mult; ++j) cout << prod[j] <<
" ";
2125 if (onMode > 0 && bRatio > 0.) openChannel =
true;
2129 if (verbosity%10 > 1 && particlePtr->useBreitWigner()) {
2130 threshMass /= bRatioSum;
2131 cout <<
" Info: particle " << idNow << fixed << setprecision(5)
2132 <<
" has average mass threshold " << threshMass
2133 <<
" while mMin is " << mMinNow <<
"\n";
2138 if (studyCloser && !openChannel) {
2139 cout <<
" Error: no acceptable decay channel found for particle "
2146 if (studyCloser && (!hasAntiNow || (!hasPosBR && !hasNegBR))
2147 && abs(bRatioSum + bRatioPos - 1.) > 1e-8) {
2148 cout <<
" Warning: particle " << idNow << fixed << setprecision(8)
2149 <<
" has branching ratio sum " << bRatioSum <<
"\n";
2152 }
else if (studyCloser && hasAntiNow
2153 && (abs(bRatioSum + bRatioPos - 1.) > 1e-8
2154 || abs(bRatioSum + bRatioNeg - 1.) > 1e-8)) {
2155 cout <<
" Warning: particle " << idNow << fixed << setprecision(8)
2156 <<
" has branching ratio sum " << bRatioSum + bRatioPos
2157 <<
" while its antiparticle has " << bRatioSum + bRatioNeg
2165 if (hasPrinted) cout <<
"\n";
2169 cout <<
" Total number of errors and warnings is " << nErr <<
"\n";
2170 cout <<
"\n -------- End PYTHIA Check of Particle Data Table --------"
2171 <<
"------\n" << endl;
2179 int ParticleData::nextId(
int idIn) {
2182 if (idIn < 0 || (idIn > 0 && !isParticle(idIn)))
return 0;
2183 if (idIn == 0)
return pdt.begin()->first;
2186 map<int, ParticleDataEntry>::const_iterator pdtIn = pdt.find(idIn);
2187 if (pdtIn == pdt.end())
return 0;
2189 if (pdtIn == pdt.end())
return 0;
2190 return pdtIn->first;
2198 double ParticleData::resOpenFrac(
int id1In,
int id2In,
int id3In) {
2204 if ( ParticleDataEntry* ptr = findParticle(id1In) )
2205 answer = ptr->resOpenFrac(id1In);
2208 if ( ParticleDataEntry* ptr = findParticle(id2In) )
2209 answer *= ptr->resOpenFrac(id2In);
2212 if ( ParticleDataEntry* ptr = findParticle(id3In) )
2213 answer *= ptr->resOpenFrac(id3In);
2224 string ParticleData::attributeValue(
string line,
string attribute) {
2226 if (line.find(attribute) == string::npos)
return "";
2227 int iBegAttri = line.find(attribute);
2228 int iBegQuote = line.find(
"\"", iBegAttri + 1);
2229 int iEndQuote = line.find(
"\"", iBegQuote + 1);
2230 return line.substr(iBegQuote + 1, iEndQuote - iBegQuote - 1);
2238 bool ParticleData::boolAttributeValue(
string line,
string attribute) {
2240 string valString = attributeValue(line, attribute);
2241 if (valString ==
"")
return false;
2242 return boolString(valString);
2250 int ParticleData::intAttributeValue(
string line,
string attribute) {
2251 string valString = attributeValue(line, attribute);
2252 if (valString ==
"")
return 0;
2253 istringstream valStream(valString);
2255 valStream >> intVal;
2264 double ParticleData::doubleAttributeValue(
string line,
string attribute) {
2265 string valString = attributeValue(line, attribute);
2266 if (valString ==
"")
return 0.;
2267 istringstream valStream(valString);
2269 valStream >> doubleVal;