Class: PDG::Particle

Inherits:
Object
  • Object
show all
Defined in:
lib/pdg/particle.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#chargeObject (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

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/pdg/particle.rb', line 5

def id
  @id
end

#massObject Also known as: m

Returns the value of attribute mass.



5
6
7
# File 'lib/pdg/particle.rb', line 5

def mass
  @mass
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/pdg/particle.rb', line 5

def name
  @name
end

#texObject (readonly)

Returns the value of attribute tex.



5
6
7
# File 'lib/pdg/particle.rb', line 5

def tex
  @tex
end

#widthObject

Returns the value of attribute width.



6
7
8
# File 'lib/pdg/particle.rb', line 6

def width
  @width
end

Instance Method Details

#ctauObject

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

#lifetimeObject 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_sObject

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