BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Public Member Functions | Private Member Functions | Private Attributes | Friends
BDSParticleDefinition Class Reference

Wrapper for particle definition. More...

#include <BDSParticleDefinition.hh>

Collaboration diagram for BDSParticleDefinition:
Collaboration graph

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...
 
BDSParticleDefinitionoperator= (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...
 
BDSIonDefinitionIonDefinition () 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...
 
BDSIonDefinitionionDefinition
 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...
 

Detailed Description

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.

Author
Laurie Nevay

Definition at line 40 of file BDSParticleDefinition.hh.

Constructor & Destructor Documentation

◆ BDSParticleDefinition() [1/4]

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().

Here is the call graph for this function:

◆ BDSParticleDefinition() [2/4]

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().

Here is the call graph for this function:

◆ BDSParticleDefinition() [3/4]

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.

◆ BDSParticleDefinition() [4/4]

BDSParticleDefinition::BDSParticleDefinition ( BDSParticleDefinition &&  other)
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::~BDSParticleDefinition ( )

Definition at line 205 of file BDSParticleDefinition.cc.

Member Function Documentation

◆ Beta()

G4double BDSParticleDefinition::Beta ( ) const
inline

Accessor.

Definition at line 101 of file BDSParticleDefinition.hh.

References beta.

Referenced by BDSComponentFactoryUser::SetDesignParticle(), BDSBunch::SetOptions(), and BDSBunchPtc::SetOptions().

Here is the caller graph for this function:

◆ BRho()

G4double BDSParticleDefinition::BRho ( ) const
inline

Accessor.

Definition at line 102 of file BDSParticleDefinition.hh.

References brho.

Referenced by BDSFieldFactory::BDSFieldFactory(), BDSOutput::FillEventPrimaryOnly(), BDSIM::Initialise(), and BDSComponentFactoryUser::SetDesignParticle().

Here is the caller graph for this function:

◆ CalculateLorentzFactors()

void BDSParticleDefinition::CalculateLorentzFactors ( )
private

Calculate and set lorentz factors.

Definition at line 255 of file BDSParticleDefinition.cc.

References beta, gamma, mass, and totalEnergy.

Referenced by SetEnergies().

Here is the caller graph for this function:

◆ CalculateMomentum()

void BDSParticleDefinition::CalculateMomentum ( )
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().

Here is the caller graph for this function:

◆ CalculateRigidity()

void BDSParticleDefinition::CalculateRigidity ( const G4double &  ffactIn)
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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Charge()

G4double BDSParticleDefinition::Charge ( ) const
inline

Accessor.

Definition at line 96 of file BDSParticleDefinition.hh.

References charge.

Referenced by BDSOutput::FillEventPrimaryOnly(), BDSLinkPrimaryGeneratorAction::GeneratePrimaries(), and BDSPrimaryGeneratorAction::GeneratePrimaries().

Here is the caller graph for this function:

◆ FFact()

G4double BDSParticleDefinition::FFact ( ) const
inline

Accessor.

Definition at line 103 of file BDSParticleDefinition.hh.

References ffact.

◆ Gamma()

G4double BDSParticleDefinition::Gamma ( ) const
inline

Accessor.

Definition at line 100 of file BDSParticleDefinition.hh.

References gamma.

Referenced by BDSBunch::SetEmittances().

Here is the caller graph for this function:

◆ IonDefinition()

BDSIonDefinition * BDSParticleDefinition::IonDefinition ( ) const
inline

◆ IsAnIon()

G4bool BDSParticleDefinition::IsAnIon ( ) const
inline

◆ KineticEnergy()

G4double BDSParticleDefinition::KineticEnergy ( ) const
inline

Accessor.

Definition at line 98 of file BDSParticleDefinition.hh.

References kineticEnergy.

Referenced by BDSIM::Initialise(), and BDSBunch::SetOptions().

Here is the caller graph for this function:

◆ Mass()

G4double BDSParticleDefinition::Mass ( ) const
inline

◆ Momentum()

G4double BDSParticleDefinition::Momentum ( ) const
inline

Accessor.

Definition at line 99 of file BDSParticleDefinition.hh.

References momentum.

Referenced by BDSPTCOneTurnMap::BDSPTCOneTurnMap(), BDSOutput::FillEventPrimaryOnly(), and BDSBunch::SetOptions().

Here is the caller graph for this function:

◆ Name()

G4String BDSParticleDefinition::Name ( ) const
inline

Accessor.

Definition at line 94 of file BDSParticleDefinition.hh.

References name.

Referenced by BDSIM::Initialise(), and BDSIMLink::Initialise().

Here is the caller graph for this function:

◆ NElectrons()

G4bool BDSParticleDefinition::NElectrons ( ) const
inline

Accessor.

Definition at line 105 of file BDSParticleDefinition.hh.

References ionDefinition, and BDSIonDefinition::NElectrons().

Referenced by BDSOutput::FillEventPrimaryOnly().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

BDSParticleDefinition & BDSParticleDefinition::operator= ( BDSParticleDefinition &&  other)
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.

◆ ParticleDefinition()

G4ParticleDefinition * BDSParticleDefinition::ParticleDefinition ( ) const
inline

Accessor.

Definition at line 92 of file BDSParticleDefinition.hh.

References particle.

Referenced by BDS::FixGeant105ThreshholdsForBeamParticle(), BDSLinkPrimaryGeneratorAction::GeneratePrimaries(), and BDSPrimaryGeneratorAction::GeneratePrimaries().

Here is the caller graph for this function:

◆ PDGID()

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().

Here is the caller graph for this function:

◆ SetEnergies()

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TotalEnergy()

G4double BDSParticleDefinition::TotalEnergy ( ) const
inline

Accessor.

Definition at line 97 of file BDSParticleDefinition.hh.

References totalEnergy.

Referenced by BDSBunchUserFile< T >::GetNextParticleLocal(), and BDSBunch::SetOptions().

Here is the caller graph for this function:

◆ UpdateG4ParticleDefinition()

void BDSParticleDefinition::UpdateG4ParticleDefinition ( G4ParticleDefinition *  particleIn)
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().

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  out,
BDSParticleDefinition const &  def 
)
friend

Output stream operator implementation.

Definition at line 220 of file BDSParticleDefinition.cc.

Field Documentation

◆ beta

G4double BDSParticleDefinition::beta
private

Relativistic beta.

Definition at line 140 of file BDSParticleDefinition.hh.

Referenced by Beta(), and CalculateLorentzFactors().

◆ brho

G4double BDSParticleDefinition::brho
private

Particle rigidity.

Definition at line 141 of file BDSParticleDefinition.hh.

Referenced by BRho(), and CalculateRigidity().

◆ charge

G4double BDSParticleDefinition::charge
private

Particle charge.

Definition at line 135 of file BDSParticleDefinition.hh.

Referenced by BDSParticleDefinition(), CalculateRigidity(), and Charge().

◆ ffact

G4double BDSParticleDefinition::ffact
private

Flip factor.

Definition at line 142 of file BDSParticleDefinition.hh.

Referenced by FFact(), and SetEnergies().

◆ gamma

G4double BDSParticleDefinition::gamma
private

Relativistic gamma.

Definition at line 139 of file BDSParticleDefinition.hh.

Referenced by CalculateLorentzFactors(), and Gamma().

◆ ionDefinition

BDSIonDefinition* BDSParticleDefinition::ionDefinition
private

Optional ion definition. Does own.

Definition at line 130 of file BDSParticleDefinition.hh.

Referenced by BDSParticleDefinition(), IonDefinition(), IsAnIon(), NElectrons(), operator=(), and PDGID().

◆ ionPDGID

G4int BDSParticleDefinition::ionPDGID
private

Cache this for ions only.

Definition at line 131 of file BDSParticleDefinition.hh.

Referenced by PDGID().

◆ kineticEnergy

G4double BDSParticleDefinition::kineticEnergy
private

Particle kinetic energy.

Definition at line 137 of file BDSParticleDefinition.hh.

Referenced by KineticEnergy(), and SetEnergies().

◆ mass

G4double BDSParticleDefinition::mass
private

Particle mass.

Definition at line 134 of file BDSParticleDefinition.hh.

Referenced by CalculateLorentzFactors(), CalculateMomentum(), Mass(), and SetEnergies().

◆ momentum

G4double BDSParticleDefinition::momentum
private

Particle momentum.

Definition at line 138 of file BDSParticleDefinition.hh.

Referenced by CalculateMomentum(), CalculateRigidity(), Momentum(), and SetEnergies().

◆ name

G4String BDSParticleDefinition::name
private

Particle name.

Definition at line 133 of file BDSParticleDefinition.hh.

Referenced by Name(), and SetEnergies().

◆ particle

G4ParticleDefinition* BDSParticleDefinition::particle
private

Does not own.

Definition at line 129 of file BDSParticleDefinition.hh.

Referenced by BDSParticleDefinition(), ParticleDefinition(), PDGID(), and UpdateG4ParticleDefinition().

◆ totalEnergy

G4double BDSParticleDefinition::totalEnergy
private

Particle total energy.

Definition at line 136 of file BDSParticleDefinition.hh.

Referenced by CalculateLorentzFactors(), CalculateMomentum(), SetEnergies(), and TotalEnergy().


The documentation for this class was generated from the following files: