BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSParticleDefinition.hh
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) BDSIM Collaboration, 2001 - 2026.
3
4This file is part of BDSIM.
5
6BDSIM is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published
8by the Free Software Foundation version 3 of the License.
9
10BDSIM is distributed in the hope that it will be useful, but
11WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef BDSPARTICLEDEFINITION_H
19#define BDSPARTICLEDEFINITION_H
20#include "BDSIonDefinition.hh"
21
22#include "CLHEP/Units/PhysicalConstants.h"
23
24#include "globals.hh"
25
26#include <ostream>
27
28class G4ParticleDefinition;
29
42{
43public:
50 BDSParticleDefinition(G4ParticleDefinition* particleIn,
51 G4double totalEnergyIn,
52 G4double kineticEnergyIn,
53 G4double momentumIn,
54 G4double ffact,
55 BDSIonDefinition* ionDefinitionIn = nullptr,
56 G4int ionPDGID = 0);
57
63 BDSParticleDefinition(const G4String& nameIn,
64 G4double massIn,
65 G4double chargeIn,
66 G4double totalEnergyIn,
67 G4double kineticEnergyIn,
68 G4double momentumIn,
69 G4double ffact,
70 BDSIonDefinition* ionDefinitionIn = nullptr,
71 G4int ionPDGID = 0);
72
78
80
84 void SetEnergies(G4double totalEnergyIn,
85 G4double kineticEnergyIn,
86 G4double momentumIn);
87
90 void UpdateG4ParticleDefinition(G4ParticleDefinition* particleIn) {particle = particleIn;}
91
92
94 void ApplyChangeInKineticEnergy(G4double dEk);
95
97 inline G4ParticleDefinition* ParticleDefinition() const {return particle;}
99 inline G4String Name() const {return name;}
100 inline G4double Mass() const {return mass;}
101 inline G4double Charge() const {return charge;}
102 inline G4double TotalEnergy() const {return totalEnergy;}
103 inline G4double KineticEnergy() const {return kineticEnergy;}
104 inline G4double Momentum() const {return momentum;}
105 inline G4double Gamma() const {return gamma;}
106 inline G4double Beta() const {return beta;}
107 inline G4double BRho() const {return brho;}
108 inline G4double FFact() const {return ffact;}
109 inline G4bool IsAnIon() const {return ionDefinition != nullptr;}
110 inline G4bool NElectrons() const {return ionDefinition != nullptr ? ionDefinition->NElectrons() : 0;}
111 inline G4double Velocity() const {return Beta() * CLHEP::c_light;}
112 inline G4bool Forwards() const {return forwards;}
114
118 G4int PDGID() const;
119
121 friend std::ostream& operator<< (std::ostream& out, BDSParticleDefinition const& def);
122
123private:
126
128 void CalculateMomentum();
129
131 void CalculateRigidity(const G4double& ffactIn);
132
135
136 G4ParticleDefinition* particle;
138 G4int ionPDGID;
139
140 G4String name;
141 G4double mass;
142 G4double charge;
143 G4double totalEnergy;
144 G4double kineticEnergy;
145 G4double momentum;
146 G4double gamma;
147 G4double beta;
148 G4double brho;
149 G4double ffact;
150 G4bool forwards;
151};
152
153#endif
Class to parse an ion particle definition.
G4int NElectrons() const
Accessor.
Wrapper for particle definition.
void CalculateRigidity(const G4double &ffactIn)
Calculate and set rigidity based on charge and momentum.
G4String Name() const
Accessor.
G4double Mass() const
Accessor.
G4bool NElectrons() const
Accessor.
G4double beta
Relativistic beta.
G4double Momentum() const
Accessor.
G4double Charge() const
Accessor.
G4double totalEnergy
Particle total energy.
G4double KineticEnergy() const
Accessor.
G4ParticleDefinition * ParticleDefinition() const
Accessor.
G4double FFact() const
Accessor.
G4double BRho() const
Accessor.
void CalculateLorentzFactors()
Calculate and set lorentz factors.
G4double gamma
Relativistic gamma.
void SetEnergies(G4double totalEnergyIn, G4double kineticEnergyIn, G4double momentumIn)
G4double momentum
Particle momentum.
G4double Beta() const
Accessor.
G4bool Forwards() const
Accessor.
BDSIonDefinition * ionDefinition
Optional ion definition. Does own.
G4double charge
Particle charge.
BDSParticleDefinition()=delete
No default constructor.
friend std::ostream & operator<<(std::ostream &out, BDSParticleDefinition const &def)
Output stream operator implementation.
G4double Velocity() const
Accessor.
G4double mass
Particle mass.
BDSParticleDefinition & operator=(BDSParticleDefinition &&other) noexcept
Copy, move and assignment constructors specified as we have to copy the ionDefinition if it exists.
G4bool forwards
In case of change of direction.
void ApplyChangeInKineticEnergy(G4double dEk)
Utility function to update quantities by adding on dEK (can be negative).
G4String name
Particle name.
G4double Gamma() const
Accessor.
BDSIonDefinition * IonDefinition() const
Accessor.
G4double brho
Particle rigidity.
G4int ionPDGID
Cache this for ions only.
G4double TotalEnergy() const
Accessor.
G4ParticleDefinition * particle
Does not own.
void CalculateMomentum()
Calculate and set momentum based on totalEnergy and mass.
G4double kineticEnergy
Particle kinetic energy.
G4bool IsAnIon() const
Accessor.
void UpdateG4ParticleDefinition(G4ParticleDefinition *particleIn)