BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
|
Wrapper for particle definition. More...
#include <BDSParticleDefinition.hh>
Public Member Functions | |
BDSParticleDefinition (G4ParticleDefinition *particleIn, G4double totalEnergyIn, G4double kineticEnergyIn, G4double momentumIn, G4double ffact, BDSIonDefinition *ionDefinitionIn=nullptr, G4int ionPDGID=0) | |
BDSParticleDefinition (const G4String &nameIn, G4double massIn, G4double chargeIn, G4double totalEnergyIn, G4double kineticEnergyIn, G4double momentumIn, G4double ffact, BDSIonDefinition *ionDefinitionIn=nullptr, G4int ionPDGID=0) | |
void | SetEnergies (G4double totalEnergyIn, G4double kineticEnergyIn, G4double momentumIn) |
void | UpdateG4ParticleDefinition (G4ParticleDefinition *particleIn) |
G4int | PDGID () const |
BDSParticleDefinition (const BDSParticleDefinition &other) | |
Copy, move and assignment constructors specified as we have to copy the ionDefinition if it exists. More... | |
BDSParticleDefinition (BDSParticleDefinition &&other) noexcept | |
Copy, move and assignment constructors specified as we have to copy the ionDefinition if it exists. More... | |
BDSParticleDefinition & | operator= (BDSParticleDefinition &&other) noexcept |
Copy, move and assignment constructors specified as we have to copy the ionDefinition if it exists. More... | |
G4ParticleDefinition * | ParticleDefinition () const |
Accessor. More... | |
BDSIonDefinition * | IonDefinition () const |
Accessor. More... | |
G4String | Name () const |
Accessor. More... | |
G4double | Mass () const |
Accessor. More... | |
G4double | Charge () const |
Accessor. More... | |
G4double | TotalEnergy () const |
Accessor. More... | |
G4double | KineticEnergy () const |
Accessor. More... | |
G4double | Momentum () const |
Accessor. More... | |
G4double | Gamma () const |
Accessor. More... | |
G4double | Beta () const |
Accessor. More... | |
G4double | BRho () const |
Accessor. More... | |
G4double | FFact () const |
Accessor. More... | |
G4bool | IsAnIon () const |
Accessor. More... | |
G4bool | NElectrons () const |
Accessor. More... | |
Private Member Functions | |
BDSParticleDefinition ()=delete | |
No default constructor. | |
void | CalculateMomentum () |
Calculate and set momentum based on totalEnergy and mass. More... | |
void | CalculateRigidity (const G4double &ffactIn) |
Calculate and set rigidity based on charge and momentum. More... | |
void | CalculateLorentzFactors () |
Calculate and set lorentz factors. More... | |
Private Attributes | |
G4ParticleDefinition * | particle |
Does not own. More... | |
BDSIonDefinition * | ionDefinition |
Optional ion definition. Does own. More... | |
G4int | ionPDGID |
Cache this for ions only. More... | |
G4String | name |
Particle name. More... | |
G4double | mass |
Particle mass. More... | |
G4double | charge |
Particle charge. More... | |
G4double | totalEnergy |
Particle total energy. More... | |
G4double | kineticEnergy |
Particle kinetic energy. More... | |
G4double | momentum |
Particle momentum. More... | |
G4double | gamma |
Relativistic gamma. More... | |
G4double | beta |
Relativistic beta. More... | |
G4double | brho |
Particle rigidity. More... | |
G4double | ffact |
Flip factor. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &out, BDSParticleDefinition const &def) |
Output stream operator implementation. More... | |
Wrapper for particle definition.
Used to calculate momentum and kinetic energy and associate any other information required along with a G4ParticleDefinition instance.
Bad construction can throw a BDSException.
Definition at line 40 of file BDSParticleDefinition.hh.
BDSParticleDefinition::BDSParticleDefinition | ( | G4ParticleDefinition * | particleIn, |
G4double | totalEnergyIn, | ||
G4double | kineticEnergyIn, | ||
G4double | momentumIn, | ||
G4double | ffact, | ||
BDSIonDefinition * | ionDefinitionIn = nullptr , |
||
G4int | ionPDGID = 0 |
||
) |
Constructor requires G4 particle definition as well as one of total energy, kineticEnergy or momentum. Only 1 of these can be non-zero (will throw exception otherwise). The others are calculated using the mass. The optional ion definition may be supplied to override the charge of the ion. The PDGID should also be supplied in this case too. ffact is typically 1 or -1 to flip the rigidity for convention.
Definition at line 37 of file BDSParticleDefinition.cc.
References BDSIonDefinition::Charge(), charge, ionDefinition, BDSIonDefinition::OverrideCharge(), particle, and SetEnergies().
BDSParticleDefinition::BDSParticleDefinition | ( | const G4String & | nameIn, |
G4double | massIn, | ||
G4double | chargeIn, | ||
G4double | totalEnergyIn, | ||
G4double | kineticEnergyIn, | ||
G4double | momentumIn, | ||
G4double | ffact, | ||
BDSIonDefinition * | ionDefinitionIn = nullptr , |
||
G4int | ionPDGID = 0 |
||
) |
Alternative constructor for when we don't have access to the particle table information. G4ParticleDefinition can be updated later. Developer responsibility to ensure this matches the contents of this class. ffact is typically 1 or -1 to flip the rigidity for convention. As before only one of totalEnergy, kineticEnergy or momentum should be specified.
Definition at line 69 of file BDSParticleDefinition.cc.
References ionDefinition, and SetEnergies().
BDSParticleDefinition::BDSParticleDefinition | ( | const BDSParticleDefinition & | other | ) |
Copy, move and assignment constructors specified as we have to copy the ionDefinition if it exists.
Definition at line 143 of file BDSParticleDefinition.cc.
References ionDefinition.
|
noexcept |
Copy, move and assignment constructors specified as we have to copy the ionDefinition if it exists.
Definition at line 163 of file BDSParticleDefinition.cc.
BDSParticleDefinition::~BDSParticleDefinition | ( | ) |
Definition at line 205 of file BDSParticleDefinition.cc.
|
inline |
Accessor.
Definition at line 101 of file BDSParticleDefinition.hh.
References beta.
Referenced by BDSComponentFactoryUser::SetDesignParticle(), BDSBunch::SetOptions(), and BDSBunchPtc::SetOptions().
|
inline |
Accessor.
Definition at line 102 of file BDSParticleDefinition.hh.
References brho.
Referenced by BDSFieldFactory::BDSFieldFactory(), BDSOutput::FillEventPrimaryOnly(), BDSIM::Initialise(), and BDSComponentFactoryUser::SetDesignParticle().
|
private |
Calculate and set lorentz factors.
Definition at line 255 of file BDSParticleDefinition.cc.
References beta, gamma, mass, and totalEnergy.
Referenced by SetEnergies().
|
private |
Calculate and set momentum based on totalEnergy and mass.
Definition at line 235 of file BDSParticleDefinition.cc.
References mass, momentum, and totalEnergy.
Referenced by SetEnergies().
|
private |
Calculate and set rigidity based on charge and momentum.
Definition at line 243 of file BDSParticleDefinition.cc.
References brho, charge, BDS::cOverGeV, BDS::IsFinite(), and momentum.
Referenced by SetEnergies().
|
inline |
Accessor.
Definition at line 96 of file BDSParticleDefinition.hh.
References charge.
Referenced by BDSOutput::FillEventPrimaryOnly(), BDSLinkPrimaryGeneratorAction::GeneratePrimaries(), and BDSPrimaryGeneratorAction::GeneratePrimaries().
|
inline |
|
inline |
Accessor.
Definition at line 100 of file BDSParticleDefinition.hh.
References gamma.
Referenced by BDSBunch::SetEmittances().
|
inline |
Accessor.
Definition at line 93 of file BDSParticleDefinition.hh.
References ionDefinition.
Referenced by BDSOutput::FillEventPrimaryOnly(), BDSBunchSixTrackLink::UpdateGeant4ParticleDefinition(), BDSBunch::UpdateIonDefinition(), and BDSBunchSixTrackLink::UpdateIonDefinition().
|
inline |
Accessor.
Definition at line 104 of file BDSParticleDefinition.hh.
References ionDefinition.
Referenced by BDSBunch::BeamParticleIsAnIon(), BDSOutput::FillEventPrimaryOnly(), BDSIM::Initialise(), BDSBunchSixTrackLink::UpdateGeant4ParticleDefinition(), BDSBunch::UpdateIonDefinition(), and BDSBunchSixTrackLink::UpdateIonDefinition().
|
inline |
Accessor.
Definition at line 98 of file BDSParticleDefinition.hh.
References kineticEnergy.
Referenced by BDSIM::Initialise(), and BDSBunch::SetOptions().
|
inline |
Accessor.
Definition at line 95 of file BDSParticleDefinition.hh.
References mass.
Referenced by BDSPTCOneTurnMap::BDSPTCOneTurnMap(), BDSOutput::FillEventPrimaryOnly(), BDSLinkPrimaryGeneratorAction::GeneratePrimaries(), BDSPrimaryGeneratorAction::GeneratePrimaries(), BDSBunch::GetNextParticleValid(), and BDSBunchUserFile< T >::SetOptions().
|
inline |
Accessor.
Definition at line 99 of file BDSParticleDefinition.hh.
References momentum.
Referenced by BDSPTCOneTurnMap::BDSPTCOneTurnMap(), BDSOutput::FillEventPrimaryOnly(), and BDSBunch::SetOptions().
|
inline |
Accessor.
Definition at line 94 of file BDSParticleDefinition.hh.
References name.
Referenced by BDSIM::Initialise(), and BDSIMLink::Initialise().
|
inline |
Accessor.
Definition at line 105 of file BDSParticleDefinition.hh.
References ionDefinition, and BDSIonDefinition::NElectrons().
Referenced by BDSOutput::FillEventPrimaryOnly().
|
noexcept |
Copy, move and assignment constructors specified as we have to copy the ionDefinition if it exists.
Definition at line 181 of file BDSParticleDefinition.cc.
References BDSIonDefinition::charge, and ionDefinition.
|
inline |
Accessor.
Definition at line 92 of file BDSParticleDefinition.hh.
References particle.
Referenced by BDS::FixGeant105ThreshholdsForBeamParticle(), BDSLinkPrimaryGeneratorAction::GeneratePrimaries(), and BDSPrimaryGeneratorAction::GeneratePrimaries().
G4int BDSParticleDefinition::PDGID | ( | ) | const |
Safely access the PDG ID of the particle. If the physics table isn't ready then we might not have the G4ParticleDefinition object in the case of an ion. In this case if there's an ion definition return the cache ion PDG ID, else return 0 as default.
Definition at line 210 of file BDSParticleDefinition.cc.
References ionDefinition, ionPDGID, and particle.
Referenced by BDSOutput::FillEventPrimaryOnly().
void BDSParticleDefinition::SetEnergies | ( | G4double | totalEnergyIn, |
G4double | kineticEnergyIn, | ||
G4double | momentumIn | ||
) |
Check in order whether totalEnergy, kineticEnergy or momentum are specified and copy that parameter to the member variable. Then calculate the other two and set them to the member variables.
Definition at line 97 of file BDSParticleDefinition.cc.
References CalculateLorentzFactors(), CalculateMomentum(), CalculateRigidity(), ffact, BDS::IsFinite(), kineticEnergy, mass, momentum, name, and totalEnergy.
Referenced by BDSParticleDefinition(), and BDSBunchUserFile< T >::GetNextParticleLocal().
|
inline |
Accessor.
Definition at line 97 of file BDSParticleDefinition.hh.
References totalEnergy.
Referenced by BDSBunchUserFile< T >::GetNextParticleLocal(), and BDSBunch::SetOptions().
|
inline |
Update the G4 particle definition member. Developer responsibility to ensure this matches the contents of the class.
Definition at line 89 of file BDSParticleDefinition.hh.
References particle.
Referenced by BDSBunchSixTrackLink::UpdateGeant4ParticleDefinition(), BDSBunch::UpdateIonDefinition(), and BDSBunchSixTrackLink::UpdateIonDefinition().
|
friend |
Output stream operator implementation.
Definition at line 220 of file BDSParticleDefinition.cc.
|
private |
Relativistic beta.
Definition at line 140 of file BDSParticleDefinition.hh.
Referenced by Beta(), and CalculateLorentzFactors().
|
private |
Particle rigidity.
Definition at line 141 of file BDSParticleDefinition.hh.
Referenced by BRho(), and CalculateRigidity().
|
private |
Particle charge.
Definition at line 135 of file BDSParticleDefinition.hh.
Referenced by BDSParticleDefinition(), CalculateRigidity(), and Charge().
|
private |
Flip factor.
Definition at line 142 of file BDSParticleDefinition.hh.
Referenced by FFact(), and SetEnergies().
|
private |
Relativistic gamma.
Definition at line 139 of file BDSParticleDefinition.hh.
Referenced by CalculateLorentzFactors(), and Gamma().
|
private |
Optional ion definition. Does own.
Definition at line 130 of file BDSParticleDefinition.hh.
Referenced by BDSParticleDefinition(), IonDefinition(), IsAnIon(), NElectrons(), operator=(), and PDGID().
|
private |
Cache this for ions only.
Definition at line 131 of file BDSParticleDefinition.hh.
Referenced by PDGID().
|
private |
Particle kinetic energy.
Definition at line 137 of file BDSParticleDefinition.hh.
Referenced by KineticEnergy(), and SetEnergies().
|
private |
Particle mass.
Definition at line 134 of file BDSParticleDefinition.hh.
Referenced by CalculateLorentzFactors(), CalculateMomentum(), Mass(), and SetEnergies().
|
private |
Particle momentum.
Definition at line 138 of file BDSParticleDefinition.hh.
Referenced by CalculateMomentum(), CalculateRigidity(), Momentum(), and SetEnergies().
|
private |
Particle name.
Definition at line 133 of file BDSParticleDefinition.hh.
Referenced by Name(), and SetEnergies().
|
private |
Does not own.
Definition at line 129 of file BDSParticleDefinition.hh.
Referenced by BDSParticleDefinition(), ParticleDefinition(), PDGID(), and UpdateG4ParticleDefinition().
|
private |
Particle total energy.
Definition at line 136 of file BDSParticleDefinition.hh.
Referenced by CalculateLorentzFactors(), CalculateMomentum(), SetEnergies(), and TotalEnergy().