Class: PDG::Particle
- Inherits:
-
Object
- Object
- PDG::Particle
- Defined in:
- lib/pdg/particle.rb
Instance Attribute Summary collapse
-
#charge ⇒ Object
(also: #q)
readonly
Returns the value of attribute charge.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#mass ⇒ Object
(also: #m)
Returns the value of attribute mass.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#tex ⇒ Object
readonly
Returns the value of attribute tex.
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
-
#ctau ⇒ Object
Returns c tau distance in mm (10^-3 m).
-
#initialize(properties) ⇒ Particle
constructor
A new instance of Particle.
-
#lifetime ⇒ Object
(also: #tau)
Returns the lifetime in picoseconds (10^-12 s) by Gamma = hbar / tau.
-
#mean_distance(energy) ⇒ Object
Returns the mean displacement, in mm, of the particle with energy ‘energy` in GeV.
-
#to_s ⇒ Object
TODO pretty printing.
Constructor Details
#initialize(properties) ⇒ Particle
Returns a new instance of Particle.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/pdg/particle.rb', line 11 def initialize(properties) properties.update(properties) { |key, val| val.nil? ? 0 : val } @id = properties[:id].to_i @name = properties[:name] @charge = case properties[:charge] when "+" 1.0 when "++" 2.0 when "-" -1.0 when "--" -2.0 # Either 0 or something like -1/3, +2/3 else fraction_to_float properties[:charge] end # The mass and width keys may not be present, but never fear as: # nil.to_f => 0.0 @mass = properties[:mass].to_f @width = properties[:width].to_f @tex = name_to_tex end |
Instance Attribute Details
#charge ⇒ Object (readonly) Also known as: q
Returns the value of attribute charge.
5 6 7 |
# File 'lib/pdg/particle.rb', line 5 def charge @charge end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/pdg/particle.rb', line 5 def id @id end |
#mass ⇒ Object Also known as: m
Returns the value of attribute mass.
5 6 7 |
# File 'lib/pdg/particle.rb', line 5 def mass @mass end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/pdg/particle.rb', line 5 def name @name end |
#tex ⇒ Object (readonly)
Returns the value of attribute tex.
5 6 7 |
# File 'lib/pdg/particle.rb', line 5 def tex @tex end |
#width ⇒ Object
Returns the value of attribute width.
6 7 8 |
# File 'lib/pdg/particle.rb', line 6 def width @width end |
Instance Method Details
#ctau ⇒ Object
Returns c tau distance in mm (10^-3 m)
45 46 47 |
# File 'lib/pdg/particle.rb', line 45 def ctau @ctau ||= @lifetime == 0.0 ? 0.0 : SPEED_OF_LIGHT * lifetime end |
#lifetime ⇒ Object Also known as: tau
Returns the lifetime in picoseconds (10^-12 s) by Gamma = hbar / tau. Returns 0 for zero lifetimes. (The PDG represent inifinite lifetimes, like that of the proton, as zero.)
39 40 41 |
# File 'lib/pdg/particle.rb', line 39 def lifetime @lifetime ||= @width == 0.0 ? 0.0 : HBAR / @width end |
#mean_distance(energy) ⇒ Object
Returns the mean displacement, in mm, of the particle with energy ‘energy` in GeV
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/pdg/particle.rb', line 50 def mean_distance(energy) return 0.0 if lifetime == 0.0 if energy < @mass raise LorentzViolation, "Energy #{energy} GeV is less than particle mass #{@mass} GeV for particle #{self}" end gamma = energy.to_f / @mass beta = Math.sqrt(1.0 - (gamma**-2)) ctau * beta * gamma end |
#to_s ⇒ Object
TODO pretty printing
63 64 65 |
# File 'lib/pdg/particle.rb', line 63 def to_s "#{@name}: ID=#{@id}, m=#{@mass} GeV, q=#{@charge}, width=#{@width} GeV" end |