ra4_draw
4bd0201e3d922d42bd545d4b045ed44db33454a4
|
Represents a yield and uncertainty obtained by counting weighted events. More...
#include <gamma_params.hpp>
Public Member Functions | |
GammaParams () | |
Standard constructor initializing to unweighted count = 0, weight = 0. More... | |
GammaParams (double n_effective, double weight) | |
Constructs GammaParams with given number of unweighted events and weight. More... | |
GammaParams (const GammaParams &)=default | |
GammaParams & | operator= (const GammaParams &)=default |
GammaParams (GammaParams &&)=default | |
GammaParams & | operator= (GammaParams &&)=default |
~GammaParams ()=default | |
void | SetNEffectiveAndWeight (double n_effective, double weight) |
Sets GammaParams by unweighted event count and weight. More... | |
void | SetYieldAndUncertainty (double yield, double uncertainty) |
Sets GammaParams by yield and uncertainty. More... | |
double | Yield () const |
Get the yield/rate. More... | |
void | Yield (double yield) |
Set the yield/rate. More... | |
double | Uncertainty () const |
Get the "sqrt(N)"-like uncertainty on the yield/rate. More... | |
void | Uncertainty (double uncertainty) |
Set the "sqrt(N)"-like uncertainty on the yield/rate. More... | |
double | NEffective () const |
Get the effective number of unweighted events. More... | |
void | NEffective (double n_effective) |
Set the effective number of unweighted events. More... | |
double | Weight () const |
Get the effective weight for the sample. More... | |
void | Weight (double weight) |
Set the effective weight for the sample. More... | |
double | CorrectedUncertainty () const |
Get the "sqrt(N+1)"-like uncertainty on the yield/rate. More... | |
GammaParams & | operator+= (const GammaParams &gp) |
Adds another GammaParams to *this. More... | |
GammaParams & | operator*= (double scale) |
Scale/multiply *this by a constant. More... | |
Private Attributes | |
double | n_effective_ |
double | weight_ |
Represents a yield and uncertainty obtained by counting weighted events.
GammaParams uses two different representations of rate: one using the rate/yield and uncertainty and another using the number of unweighted events and the weight. In the case that all events have the same weight, the conversion is:
In the case of events having different weights, GammaParams uses an approximation to get an effective number of unweighted events and an effective weight for the combination in the same way as ROOT's Sumw2;
The GammaParams::Uncertainty() method returns the "sqrt(N)"-like uncertainty on a Poisson mean correspdoning to a prior of Gamma(alpha=0, beta=0). This is the uncertainty used by the uncertainty getter and setter methods. The GammaParams::CorrectedUncertainty() returns the "sqrt(N+1)"-like uncertainty corresponding to a prior of Gamma(alpha=1, beta=0).
Definition at line 6 of file gamma_params.hpp.
GammaParams::GammaParams | ( | ) |
Standard constructor initializing to unweighted count = 0, weight = 0.
Definition at line 35 of file gamma_params.cpp.
GammaParams::GammaParams | ( | double | n_effective, |
double | weight | ||
) |
Constructs GammaParams with given number of unweighted events and weight.
[in] | n_effective | Effective number of unweighted events |
[in] | weight | Effective weight of sample |
Definition at line 47 of file gamma_params.cpp.
|
default |
|
default |
|
default |
double GammaParams::CorrectedUncertainty | ( | ) | const |
Get the "sqrt(N+1)"-like uncertainty on the yield/rate.
Definition at line 161 of file gamma_params.cpp.
References n_effective_, and weight_.
Referenced by operator<<().
double GammaParams::NEffective | ( | ) | const |
Get the effective number of unweighted events.
Definition at line 127 of file gamma_params.cpp.
References n_effective_.
Referenced by operator*=(), operator+=(), operator<<(), and Weight().
void GammaParams::NEffective | ( | double | n_effective | ) |
Set the effective number of unweighted events.
[in] | n_effective | Effective number of unweighted events |
Definition at line 135 of file gamma_params.cpp.
References SetNEffectiveAndWeight(), and Weight().
GammaParams & GammaParams::operator*= | ( | double | scale | ) |
Scale/multiply *this by a constant.
The yield and uncertainty scale linearly.
[in] | scale | Amount by which to scale *this |
Definition at line 193 of file gamma_params.cpp.
References NEffective(), SetNEffectiveAndWeight(), and Weight().
GammaParams & GammaParams::operator+= | ( | const GammaParams & | gp | ) |
Adds another GammaParams to *this.
Uses a Sumw2-like approximation to obtain effective number of unweighted events and weight. The resulting yield is the sum of the original two yields. The resulting uncertainty is the square-root-of-the-sum-of-squares of the original uncertainties.
[in] | gp | GammaParams to add to *this |
Definition at line 176 of file gamma_params.cpp.
References NEffective(), SetNEffectiveAndWeight(), SetYieldAndUncertainty(), Uncertainty(), Weight(), and Yield().
|
default |
|
default |
void GammaParams::SetNEffectiveAndWeight | ( | double | n_effective, |
double | weight | ||
) |
Sets GammaParams by unweighted event count and weight.
Resets the yield/rate and uncertainty to corresponding values.
[in] | n_effective | The effective number of _unweighted_events. It need not be an integer. |
[in] | weight | The effective weight of the sample |
Definition at line 82 of file gamma_params.cpp.
References n_effective_, and weight_.
Referenced by NEffective(), operator*=(), operator+=(), and Weight().
void GammaParams::SetYieldAndUncertainty | ( | double | yield, |
double | uncertainty | ||
) |
Sets GammaParams by yield and uncertainty.
Resets the number of unweighted events and effective weight to corresponding values.
[in] | yield | The weighted number of events |
[in] | uncertainty | The "sqrt(N)"-like uncertainty on the yield/rate. |
Definition at line 63 of file gamma_params.cpp.
References n_effective_, and weight_.
Referenced by operator+=(), Uncertainty(), and Yield().
double GammaParams::Uncertainty | ( | ) | const |
Get the "sqrt(N)"-like uncertainty on the yield/rate.
Definition at line 109 of file gamma_params.cpp.
References n_effective_, and weight_.
Referenced by operator+=(), and Yield().
void GammaParams::Uncertainty | ( | double | uncertainty | ) |
Set the "sqrt(N)"-like uncertainty on the yield/rate.
[in] | uncertainty | The "sqrt(N)"-like uncertainty corresponding to a prior of Gamma(alpha=0, beta=0) on the Poisson rate. This is the uncertainty used by GammaParams::Uncertainty(). |
Definition at line 119 of file gamma_params.cpp.
References SetYieldAndUncertainty(), and Yield().
double GammaParams::Weight | ( | ) | const |
Get the effective weight for the sample.
Definition at line 143 of file gamma_params.cpp.
References weight_.
Referenced by NEffective(), operator*=(), operator+=(), and operator<<().
void GammaParams::Weight | ( | double | weight | ) |
Set the effective weight for the sample.
[in] | weight | The effective weight for the sample |
Definition at line 151 of file gamma_params.cpp.
References NEffective(), and SetNEffectiveAndWeight().
double GammaParams::Yield | ( | ) | const |
Get the yield/rate.
Definition at line 91 of file gamma_params.cpp.
References n_effective_, and weight_.
Referenced by operator+=(), operator<<(), and Uncertainty().
void GammaParams::Yield | ( | double | yield | ) |
Set the yield/rate.
[in] | yield | The weighted number of events |
Definition at line 99 of file gamma_params.cpp.
References SetYieldAndUncertainty(), and Uncertainty().
|
private |
Definition at line 37 of file gamma_params.hpp.
Referenced by CorrectedUncertainty(), NEffective(), SetNEffectiveAndWeight(), SetYieldAndUncertainty(), Uncertainty(), and Yield().
|
private |
Definition at line 38 of file gamma_params.hpp.
Referenced by CorrectedUncertainty(), SetNEffectiveAndWeight(), SetYieldAndUncertainty(), Uncertainty(), Weight(), and Yield().