ra4_stats  0341147a0dc35f80f4e12c6003afb76a38e2ed6e
gamma_params.cpp
Go to the documentation of this file.
1 #include "gamma_params.hpp"
2 
3 #include <cmath>
4 
6  n_effective_(0.),
7  weight_(0.){
8 }
9 
10 GammaParams::GammaParams(double n_effective, double weight):
11  n_effective_(n_effective),
12  weight_(weight){
13  }
14 
15 void GammaParams::SetYieldAndUncertainty(double yield, double uncertainty){
16  if(yield > 0.){
17  n_effective_ = (yield*yield)/(uncertainty*uncertainty);
18  weight_ = uncertainty*uncertainty/yield;
19  }else{
20  n_effective_ = 0.;
21  weight_ = hypot(yield, uncertainty);
22  }
23 }
24 
25 void GammaParams::SetNEffectiveAndWeight(double n_effective, double weight){
26  n_effective_ = n_effective;
27  weight_ = weight;
28 }
29 
30 double GammaParams::Yield() const{
31  return n_effective_*weight_;
32 }
33 
34 void GammaParams::Yield(double yield){
36 }
37 
38 double GammaParams::Uncertainty() const{
39  return sqrt(n_effective_)*weight_;
40 }
41 
42 void GammaParams::Uncertainty(double uncertainty){
43  SetYieldAndUncertainty(Yield(), uncertainty);
44 }
45 
46 double GammaParams::NEffective() const{
47  return n_effective_;
48 }
49 
50 void GammaParams::NEffective(double n_effective){
51  SetNEffectiveAndWeight(n_effective, Weight());
52 }
53 
54 double GammaParams::Weight() const{
55  return weight_;
56 }
57 
58 void GammaParams::Weight(double weight){
60 }
61 
63  return sqrt(n_effective_+1.)*weight_;
64 }
65 
67  if(NEffective() == 0. && gp.NEffective() == 0.){
68  SetNEffectiveAndWeight(0., hypot(Weight(), gp.Weight()));
69  }else{
71  }
72  return *this;
73 }
74 
77  return *this;
78 }
79 
81  return (gp1 += gp2);
82 }
83 
84 GammaParams operator*(double scale, GammaParams gp){
85  return (gp*=scale);
86 }
87 
88 GammaParams operator*(GammaParams gp, double scale){
89  return (gp*=scale);
90 }
91 
92 std::ostream & operator<<(std::ostream &stream, const GammaParams &gp){
93  stream << gp.Yield() << "+-" << gp.CorrectedUncertainty()
94  << " (N=" << gp.NEffective() << ", w=" << gp.Weight() << ")";
95  return stream;
96 }
double Weight() const
double weight_
double CorrectedUncertainty() const
GammaParams & operator+=(const GammaParams &gp)
void SetYieldAndUncertainty(double yield, double uncertainty)
GammaParams & operator*=(double scale)
double Yield() const
std::ostream & operator<<(std::ostream &stream, const GammaParams &gp)
double n_effective_
double Uncertainty() const
double NEffective() const
GammaParams operator+(GammaParams gp1, GammaParams gp2)
GammaParams operator*(double scale, GammaParams gp)
void SetNEffectiveAndWeight(double n_effective, double weight)