Changeset View
Changeset View
Standalone View
Standalone View
src/EvtGenExternal/EvtPythiaEngine.cpp
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | EvtPythiaEngine::EvtPythiaEngine( std::string xmlDir, bool convertPhysCodes, | ||||
EvtGenReport( EVTGEN_INFO, "EvtGen" ) | EvtGenReport( EVTGEN_INFO, "EvtGen" ) | ||||
<< "Creating generic Pythia generator" << endl; | << "Creating generic Pythia generator" << endl; | ||||
_genericPythiaGen = std::make_unique<Pythia8::Pythia>( xmlDir ); | _genericPythiaGen = std::make_unique<Pythia8::Pythia>( xmlDir ); | ||||
EvtGenReport( EVTGEN_INFO, "EvtGen" ) | EvtGenReport( EVTGEN_INFO, "EvtGen" ) | ||||
<< "Creating alias Pythia generator" << endl; | << "Creating alias Pythia generator" << endl; | ||||
_aliasPythiaGen = std::make_unique<Pythia8::Pythia>( xmlDir, false ); | _aliasPythiaGen = std::make_unique<Pythia8::Pythia>( xmlDir, false ); | ||||
_thePythiaGenerator = 0; | _thePythiaGenerator = nullptr; | ||||
_daugPDGVector.clear(); | _daugPDGVector.clear(); | ||||
_daugP4Vector.clear(); | _daugP4Vector.clear(); | ||||
_convertPhysCodes = convertPhysCodes; | _convertPhysCodes = convertPhysCodes; | ||||
// Specify if we are going to use the random number generator (engine) | // Specify if we are going to use the random number generator (engine) | ||||
// from EvtGen for Pythia 8. | // from EvtGen for Pythia 8. | ||||
_useEvtGenRandom = useEvtGenRandom; | _useEvtGenRandom = useEvtGenRandom; | ||||
▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | bool EvtPythiaEngine::doDecay( EvtParticle* theParticle ) | ||||
// the total frequency for each Pythia decay mode will normalise correctly to what | // the total frequency for each Pythia decay mode will normalise correctly to what | ||||
// we wanted via the specifications made to the decay.dec file, even though event-by-event | // we wanted via the specifications made to the decay.dec file, even though event-by-event | ||||
// the EvtGen decay channel and the Pythia decay channel may be different. | // the EvtGen decay channel and the Pythia decay channel may be different. | ||||
if ( _initialised == false ) { | if ( _initialised == false ) { | ||||
this->initialise(); | this->initialise(); | ||||
} | } | ||||
if ( theParticle == 0 ) { | if ( theParticle == nullptr ) { | ||||
EvtGenReport( EVTGEN_INFO, "EvtGen" ) | EvtGenReport( EVTGEN_INFO, "EvtGen" ) | ||||
<< "Error in EvtPythiaEngine::doDecay. The mother particle is null. Not doing any Pythia decay." | << "Error in EvtPythiaEngine::doDecay. The mother particle is null. Not doing any Pythia decay." | ||||
<< endl; | << endl; | ||||
return false; | return false; | ||||
} | } | ||||
// Delete EvtParticle daughters if they already exist | // Delete EvtParticle daughters if they already exist | ||||
if ( theParticle->getNDaug() != 0 ) { | if ( theParticle->getNDaug() != 0 ) { | ||||
▲ Show 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | for ( daugIter = daugList.begin(); daugIter != daugList.end(); ++daugIter ) { | ||||
} // Status code != 1000 | } // Status code != 1000 | ||||
} | } | ||||
} | } | ||||
} | } | ||||
void EvtPythiaEngine::createDaughterEvtParticles( EvtParticle* theParent ) | void EvtPythiaEngine::createDaughterEvtParticles( EvtParticle* theParent ) | ||||
{ | { | ||||
if ( theParent == 0 ) { | if ( theParent == nullptr ) { | ||||
EvtGenReport( EVTGEN_INFO, "EvtGen" ) | EvtGenReport( EVTGEN_INFO, "EvtGen" ) | ||||
<< "Error in EvtPythiaEngine::createDaughterEvtParticles. The parent is null" | << "Error in EvtPythiaEngine::createDaughterEvtParticles. The parent is null" | ||||
<< endl; | << endl; | ||||
return; | return; | ||||
} | } | ||||
// Get the list of Pythia decay modes defined for this particle id alias. | // Get the list of Pythia decay modes defined for this particle id alias. | ||||
// It would be easier to just use the decay channel number that Pythia chose to use | // It would be easier to just use the decay channel number that Pythia chose to use | ||||
Show All 31 Lines | for ( modeIter = pythiaModes.begin(); modeIter != pythiaModes.end(); | ||||
break; | break; | ||||
} | } | ||||
int pythiaModeInt = *modeIter; | int pythiaModeInt = *modeIter; | ||||
EvtDecayBase* decayModel = EvtDecayTable::getInstance()->findDecayModel( | EvtDecayBase* decayModel = EvtDecayTable::getInstance()->findDecayModel( | ||||
aliasInt, pythiaModeInt ); | aliasInt, pythiaModeInt ); | ||||
if ( decayModel != 0 ) { | if ( decayModel != nullptr ) { | ||||
int nModeDaug = decayModel->getNDaug(); | int nModeDaug = decayModel->getNDaug(); | ||||
// We need to make sure that the number of daughters match | // We need to make sure that the number of daughters match | ||||
if ( nDaughters == nModeDaug ) { | if ( nDaughters == nModeDaug ) { | ||||
int iModeDaug( 0 ); | int iModeDaug( 0 ); | ||||
for ( iModeDaug = 0; iModeDaug < nModeDaug; iModeDaug++ ) { | for ( iModeDaug = 0; iModeDaug < nModeDaug; iModeDaug++ ) { | ||||
EvtId daugId = decayModel->getDaug( iModeDaug ); | EvtId daugId = decayModel->getDaug( iModeDaug ); | ||||
int daugPDGId = EvtPDL::getStdHep( daugId ); | int daugPDGId = EvtPDL::getStdHep( daugId ); | ||||
Show All 38 Lines | void EvtPythiaEngine::createDaughterEvtParticles( EvtParticle* theParent ) | ||||
// Now set the 4-momenta of the daughters. | // Now set the 4-momenta of the daughters. | ||||
int iDaug( 0 ); | int iDaug( 0 ); | ||||
// Can use an iterator here, but we already had to use the vector size... | // Can use an iterator here, but we already had to use the vector size... | ||||
for ( iDaug = 0; iDaug < nDaughters; iDaug++ ) { | for ( iDaug = 0; iDaug < nDaughters; iDaug++ ) { | ||||
EvtParticle* theDaughter = theParent->getDaug( iDaug ); | EvtParticle* theDaughter = theParent->getDaug( iDaug ); | ||||
// Set the correct 4-momentum for each daughter particle. | // Set the correct 4-momentum for each daughter particle. | ||||
if ( theDaughter != 0 ) { | if ( theDaughter != nullptr ) { | ||||
EvtId theDaugId = daugAliasIdVect[iDaug]; | EvtId theDaugId = daugAliasIdVect[iDaug]; | ||||
const EvtVector4R theDaugP4 = _daugP4Vector[iDaug]; | const EvtVector4R theDaugP4 = _daugP4Vector[iDaug]; | ||||
theDaughter->init( theDaugId, theDaugP4 ); | theDaughter->init( theDaugId, theDaugP4 ); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
void EvtPythiaEngine::updateParticleLists() | void EvtPythiaEngine::updateParticleLists() | ||||
Show All 37 Lines | for ( iPDL = 0; iPDL < nPDL; iPDL++ ) { | ||||
ParticleDataEntryPtr entry_generic = | ParticleDataEntryPtr entry_generic = | ||||
_genericPythiaGen->particleData.particleDataEntryPtr( PDGCode ); | _genericPythiaGen->particleData.particleDataEntryPtr( PDGCode ); | ||||
ParticleDataEntryPtr entry_alias = | ParticleDataEntryPtr entry_alias = | ||||
_aliasPythiaGen->particleData.particleDataEntryPtr( PDGCode ); | _aliasPythiaGen->particleData.particleDataEntryPtr( PDGCode ); | ||||
// Check that the PDG code is not zero/null and exclude other | // Check that the PDG code is not zero/null and exclude other | ||||
// special cases, e.g. those reserved for internal generator use | // special cases, e.g. those reserved for internal generator use | ||||
if ( entry_generic != 0 && this->validPDGCode( PDGCode ) ) { | if ( entry_generic != nullptr && this->validPDGCode( PDGCode ) ) { | ||||
entry_generic->setM0( mass ); | entry_generic->setM0( mass ); | ||||
entry_generic->setMWidth( width ); | entry_generic->setMWidth( width ); | ||||
entry_generic->setTau0( lifetime ); | entry_generic->setTau0( lifetime ); | ||||
if ( std::fabs( width ) > 0.0 ) { | if ( std::fabs( width ) > 0.0 ) { | ||||
entry_generic->setMMin( mmin ); | entry_generic->setMMin( mmin ); | ||||
entry_generic->setMMax( mmax ); | entry_generic->setMMax( mmax ); | ||||
} | } | ||||
} | } | ||||
// Check that the PDG code is not zero/null and exclude other | // Check that the PDG code is not zero/null and exclude other | ||||
// special cases, e.g. those reserved for internal generator use | // special cases, e.g. those reserved for internal generator use | ||||
if ( entry_alias != 0 && this->validPDGCode( PDGCode ) ) { | if ( entry_alias != nullptr && this->validPDGCode( PDGCode ) ) { | ||||
entry_alias->setM0( mass ); | entry_alias->setM0( mass ); | ||||
entry_alias->setMWidth( width ); | entry_alias->setMWidth( width ); | ||||
entry_alias->setTau0( lifetime ); | entry_alias->setTau0( lifetime ); | ||||
if ( std::fabs( width ) > 0.0 ) { | if ( std::fabs( width ) > 0.0 ) { | ||||
entry_alias->setMMin( mmin ); | entry_alias->setMMin( mmin ); | ||||
entry_alias->setMMax( mmax ); | entry_alias->setMMax( mmax ); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | void EvtPythiaEngine::updatePythiaDecayTable( EvtId& particleId, int aliasInt, | ||||
// Keep track of which decay modes are Pythia decays for each aliasInt | // Keep track of which decay modes are Pythia decays for each aliasInt | ||||
std::vector<int> pythiaModes( 0 ); | std::vector<int> pythiaModes( 0 ); | ||||
// Loop over the decay modes for this particle | // Loop over the decay modes for this particle | ||||
for ( iMode = 0; iMode < nModes; iMode++ ) { | for ( iMode = 0; iMode < nModes; iMode++ ) { | ||||
EvtDecayBase* decayModel = | EvtDecayBase* decayModel = | ||||
EvtDecayTable::getInstance()->findDecayModel( aliasInt, iMode ); | EvtDecayTable::getInstance()->findDecayModel( aliasInt, iMode ); | ||||
if ( decayModel != 0 ) { | if ( decayModel != nullptr ) { | ||||
int nDaug = decayModel->getNDaug(); | int nDaug = decayModel->getNDaug(); | ||||
// If the decay mode has no daughters, then that means that there will be | // If the decay mode has no daughters, then that means that there will be | ||||
// no entries for any submode re-definitions for Pythia. | // no entries for any submode re-definitions for Pythia. | ||||
// This sometimes occurs for any mode using non-standard Pythia 6 codes. | // This sometimes occurs for any mode using non-standard Pythia 6 codes. | ||||
// Do not refine the decay mode, i.e. accept the Pythia 8 default (if it exists). | // Do not refine the decay mode, i.e. accept the Pythia 8 default (if it exists). | ||||
if ( nDaug > 0 ) { | if ( nDaug > 0 ) { | ||||
// Check to see if we have a Pythia decay mode | // Check to see if we have a Pythia decay mode | ||||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | void EvtPythiaEngine::updatePythiaDecayTable( EvtId& particleId, int aliasInt, | ||||
_thePythiaGenerator->readString( rescaleStr.str() ); | _thePythiaGenerator->readString( rescaleStr.str() ); | ||||
} | } | ||||
int EvtPythiaEngine::getModeInt( EvtDecayBase* decayModel ) | int EvtPythiaEngine::getModeInt( EvtDecayBase* decayModel ) | ||||
{ | { | ||||
int tmpModeInt( 0 ), modeInt( 0 ); | int tmpModeInt( 0 ), modeInt( 0 ); | ||||
if ( decayModel != 0 ) { | if ( decayModel != nullptr ) { | ||||
int nVars = decayModel->getNArg(); | int nVars = decayModel->getNArg(); | ||||
// Just read the first integer, which specifies the Pythia decay model. | // Just read the first integer, which specifies the Pythia decay model. | ||||
// Ignore any other values. | // Ignore any other values. | ||||
if ( nVars > 0 ) { | if ( nVars > 0 ) { | ||||
tmpModeInt = static_cast<int>( decayModel->getArg( 0 ) ); | tmpModeInt = static_cast<int>( decayModel->getArg( 0 ) ); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 197 Lines • Show Last 20 Lines |