go-hep.org/x/hep@v0.38.1/heppdt/resonance.go (about)

     1  // Copyright ©2017 The go-hep Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package heppdt
     6  
     7  // Resonance holds mass and width informations for a Breit-Wigner
     8  // distribution about a given mass
     9  type Resonance struct {
    10  	Mass  Measurement // mass measurement
    11  	Width Measurement // total width measurement
    12  	Lower float64     // lower cutoff of allowed width values
    13  	Upper float64     // upper cutoff of allowed width values
    14  }
    15  
    16  // Lifetime computes and returns the lifetime from the total width
    17  func (r *Resonance) Lifetime() Measurement {
    18  	// lifetime = hbar / totalwidth
    19  	const hbar = 6.58211889e-25 // in GeV s
    20  	var lt Measurement
    21  	lt.Value = hbar / r.Width.Value
    22  	lt.Sigma = lt.Value * r.Width.Sigma / r.Width.Value
    23  	return lt
    24  }
    25  
    26  func (r *Resonance) SetTotalWidthFromLifetime(lifetime Measurement) {
    27  	// totalwidth = hbar / lifetime
    28  	const epsilon = 1.0e-20
    29  	const hbar = 6.58211889e-25 // in GeV s
    30  	var width float64
    31  	var sigma float64
    32  
    33  	// make no changes if lifetime is not greater than zero
    34  	if lifetime.Value < epsilon {
    35  		return
    36  	}
    37  
    38  	width = hbar / lifetime.Value
    39  
    40  	if lifetime.Sigma < epsilon {
    41  		sigma = 0.0
    42  	} else {
    43  		sigma = (lifetime.Sigma / lifetime.Value) * width
    44  	}
    45  	r.Width = Measurement{
    46  		Value: width,
    47  		Sigma: sigma,
    48  	}
    49  }