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) |
void | ApplyChangeInKineticEnergy (G4double dEk) |
Utility function to update quantities by adding on dEK (can be negative). | |
G4int | PDGID () const |
BDSParticleDefinition (const BDSParticleDefinition &other) | |
Copy, move and assignment constructors specified as we have to copy the ionDefinition if it exists. | |
BDSParticleDefinition (BDSParticleDefinition &&other) noexcept | |
Copy, move and assignment constructors specified as we have to copy the ionDefinition if it exists. | |
BDSParticleDefinition & | operator= (BDSParticleDefinition &&other) noexcept |
Copy, move and assignment constructors specified as we have to copy the ionDefinition if it exists. | |
G4ParticleDefinition * | ParticleDefinition () const |
Accessor. | |
BDSIonDefinition * | IonDefinition () const |
Accessor. | |
G4String | Name () const |
Accessor. | |
G4double | Mass () const |
Accessor. | |
G4double | Charge () const |
Accessor. | |
G4double | TotalEnergy () const |
Accessor. | |
G4double | KineticEnergy () const |
Accessor. | |
G4double | Momentum () const |
Accessor. | |
G4double | Gamma () const |
Accessor. | |
G4double | Beta () const |
Accessor. | |
G4double | BRho () const |
Accessor. | |
G4double | FFact () const |
Accessor. | |
G4bool | IsAnIon () const |
Accessor. | |
G4bool | NElectrons () const |
Accessor. | |
G4double | Velocity () const |
Accessor. | |
G4bool | Forwards () const |
Accessor. | |
Private Member Functions | |
BDSParticleDefinition ()=delete | |
No default constructor. | |
void | CalculateMomentum () |
Calculate and set momentum based on totalEnergy and mass. | |
void | CalculateRigidity (const G4double &ffactIn) |
Calculate and set rigidity based on charge and momentum. | |
void | CalculateLorentzFactors () |
Calculate and set lorentz factors. | |
Private Attributes | |
G4ParticleDefinition * | particle |
Does not own. | |
BDSIonDefinition * | ionDefinition |
Optional ion definition. Does own. | |
G4int | ionPDGID |
Cache this for ions only. | |
G4String | name |
Particle name. | |
G4double | mass |
Particle mass. | |
G4double | charge |
Particle charge. | |
G4double | totalEnergy |
Particle total energy. | |
G4double | kineticEnergy |
Particle kinetic energy. | |
G4double | momentum |
Particle momentum. | |
G4double | gamma |
Relativistic gamma. | |
G4double | beta |
Relativistic beta. | |
G4double | brho |
Particle rigidity. | |
G4double | ffact |
Flip factor. | |
G4bool | forwards |
In case of change of direction. | |
Friends | |
std::ostream & | operator<< (std::ostream &out, BDSParticleDefinition const &def) |
Output stream operator implementation. | |
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 42 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 38 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 71 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 146 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 167 of file BDSParticleDefinition.cc.
BDSParticleDefinition::~BDSParticleDefinition | ( | ) |
Definition at line 211 of file BDSParticleDefinition.cc.
void BDSParticleDefinition::ApplyChangeInKineticEnergy | ( | G4double | dEk | ) |
Utility function to update quantities by adding on dEK (can be negative).
Definition at line 269 of file BDSParticleDefinition.cc.
References forwards, kineticEnergy, and SetEnergies().
Referenced by BDSBeamlineIntegral::Integrate().
|
inline |
Accessor.
Definition at line 107 of file BDSParticleDefinition.hh.
References beta.
Referenced by BDSBeamlineIntegral::Integrate(), BDSComponentFactoryUser::SetDesignParticle(), BDSBunch::SetOptions(), BDSBunchPtc::SetOptions(), and Velocity().
|
inline |
Accessor.
Definition at line 108 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 262 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 242 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 250 of file BDSParticleDefinition.cc.
References brho, charge, BDS::cOverGeV, BDS::IsFinite(), and momentum.
Referenced by SetEnergies().
|
inline |
Accessor.
Definition at line 102 of file BDSParticleDefinition.hh.
References charge.
Referenced by BDSOutput::FillEventPrimaryOnly(), BDSLinkPrimaryGeneratorAction::GeneratePrimaries(), BDSPrimaryGeneratorAction::GeneratePrimaries(), and BDSBeamlineIntegral::Integrate().
|
inline |
|
inline |
|
inline |
Accessor.
Definition at line 106 of file BDSParticleDefinition.hh.
References gamma.
Referenced by BDSBunch::SetEmittances().
|
inline |
Accessor.
Definition at line 99 of file BDSParticleDefinition.hh.
References ionDefinition.
Referenced by BDSOutput::FillEventPrimaryOnly(), BDSBunchSixTrackLink::UpdateGeant4ParticleDefinition(), BDSBunch::UpdateIonDefinition(), and BDSBunchSixTrackLink::UpdateIonDefinition().
|
inline |
Accessor.
Definition at line 110 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 104 of file BDSParticleDefinition.hh.
References kineticEnergy.
Referenced by BDSIM::Initialise(), and BDSBunch::SetOptions().
|
inline |
Accessor.
Definition at line 101 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 105 of file BDSParticleDefinition.hh.
References momentum.
Referenced by BDSPTCOneTurnMap::BDSPTCOneTurnMap(), BDSOutput::FillEventPrimaryOnly(), and BDSBunch::SetOptions().
|
inline |
Accessor.
Definition at line 100 of file BDSParticleDefinition.hh.
References name.
Referenced by BDSIM::Initialise(), and BDSIMLink::Initialise().
|
inline |
Accessor.
Definition at line 111 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 186 of file BDSParticleDefinition.cc.
References BDSIonDefinition::charge, and ionDefinition.
|
inline |
Accessor.
Definition at line 98 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 216 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 100 of file BDSParticleDefinition.cc.
References CalculateLorentzFactors(), CalculateMomentum(), CalculateRigidity(), ffact, BDS::IsFinite(), kineticEnergy, mass, momentum, name, and totalEnergy.
Referenced by ApplyChangeInKineticEnergy(), BDSParticleDefinition(), and BDSBunchUserFile< T >::GetNextParticleLocal().
|
inline |
Accessor.
Definition at line 103 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 91 of file BDSParticleDefinition.hh.
References particle.
Referenced by BDSBunchSixTrackLink::UpdateGeant4ParticleDefinition(), BDSBunch::UpdateIonDefinition(), and BDSBunchSixTrackLink::UpdateIonDefinition().
|
inline |
Accessor.
Definition at line 112 of file BDSParticleDefinition.hh.
References Beta().
Referenced by BDSBeamlineIntegral::Integrate().
|
friend |
Output stream operator implementation.
Definition at line 226 of file BDSParticleDefinition.cc.
|
private |
Relativistic beta.
Definition at line 148 of file BDSParticleDefinition.hh.
Referenced by Beta(), and CalculateLorentzFactors().
|
private |
Particle rigidity.
Definition at line 149 of file BDSParticleDefinition.hh.
Referenced by BRho(), and CalculateRigidity().
|
private |
Particle charge.
Definition at line 143 of file BDSParticleDefinition.hh.
Referenced by BDSParticleDefinition(), CalculateRigidity(), and Charge().
|
private |
Flip factor.
Definition at line 150 of file BDSParticleDefinition.hh.
Referenced by FFact(), and SetEnergies().
|
private |
In case of change of direction.
Definition at line 151 of file BDSParticleDefinition.hh.
Referenced by ApplyChangeInKineticEnergy(), and Forwards().
|
private |
Relativistic gamma.
Definition at line 147 of file BDSParticleDefinition.hh.
Referenced by CalculateLorentzFactors(), and Gamma().
|
private |
Optional ion definition. Does own.
Definition at line 138 of file BDSParticleDefinition.hh.
Referenced by BDSParticleDefinition(), IonDefinition(), IsAnIon(), NElectrons(), operator=(), and PDGID().
|
private |
Cache this for ions only.
Definition at line 139 of file BDSParticleDefinition.hh.
Referenced by PDGID().
|
private |
Particle kinetic energy.
Definition at line 145 of file BDSParticleDefinition.hh.
Referenced by ApplyChangeInKineticEnergy(), KineticEnergy(), and SetEnergies().
|
private |
Particle mass.
Definition at line 142 of file BDSParticleDefinition.hh.
Referenced by CalculateLorentzFactors(), CalculateMomentum(), Mass(), and SetEnergies().
|
private |
Particle momentum.
Definition at line 146 of file BDSParticleDefinition.hh.
Referenced by CalculateMomentum(), CalculateRigidity(), Momentum(), and SetEnergies().
|
private |
Particle name.
Definition at line 141 of file BDSParticleDefinition.hh.
Referenced by Name(), and SetEnergies().
|
private |
Does not own.
Definition at line 137 of file BDSParticleDefinition.hh.
Referenced by BDSParticleDefinition(), ParticleDefinition(), PDGID(), and UpdateG4ParticleDefinition().
|
private |
Particle total energy.
Definition at line 144 of file BDSParticleDefinition.hh.
Referenced by CalculateLorentzFactors(), CalculateMomentum(), SetEnergies(), and TotalEnergy().