ra4_draw  4bd0201e3d922d42bd545d4b045ed44db33454a4
Public Member Functions | Private Attributes | List of all members
GammaParams Class Reference

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
 
GammaParamsoperator= (const GammaParams &)=default
 
 GammaParams (GammaParams &&)=default
 
GammaParamsoperator= (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...
 
GammaParamsoperator+= (const GammaParams &gp)
 Adds another GammaParams to *this. More...
 
GammaParamsoperator*= (double scale)
 Scale/multiply *this by a constant. More...
 

Private Attributes

double n_effective_
 
double weight_
 

Detailed Description

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.

Constructor & Destructor Documentation

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.

Parameters
[in]n_effectiveEffective number of unweighted events
[in]weightEffective weight of sample

Definition at line 47 of file gamma_params.cpp.

GammaParams::GammaParams ( const GammaParams )
default
GammaParams::GammaParams ( GammaParams &&  )
default
GammaParams::~GammaParams ( )
default

Member Function Documentation

double GammaParams::CorrectedUncertainty ( ) const

Get the "sqrt(N+1)"-like uncertainty on the yield/rate.

Returns
The "sqrt(N+1)"-like uncertainty corresponding to a prior of Gamma(alpha=1, beta=0) on the Poisson rate. This is not the uncertainty used by the GammaParams setter methods.

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.

Returns
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.

Parameters
[in]n_effectiveEffective 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.

Parameters
[in]scaleAmount by which to scale *this
Returns
Reference to *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.

Parameters
[in]gpGammaParams to add to *this
Returns
Reference to *this

Definition at line 176 of file gamma_params.cpp.

References NEffective(), SetNEffectiveAndWeight(), SetYieldAndUncertainty(), Uncertainty(), Weight(), and Yield().

GammaParams& GammaParams::operator= ( const GammaParams )
default
GammaParams& GammaParams::operator= ( GammaParams &&  )
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.

Parameters
[in]n_effectiveThe effective number of _unweighted_events. It need not be an integer.
[in]weightThe 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.

Parameters
[in]yieldThe weighted number of events
[in]uncertaintyThe "sqrt(N)"-like uncertainty on the yield/rate.
See also
GammaParams::Uncertainty()

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.

Returns
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 the GammaParams setter methods.

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.

Parameters
[in]uncertaintyThe "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.

Returns
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.

Parameters
[in]weightThe 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.

Returns
The yield or 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.

Parameters
[in]yieldThe weighted number of events

Definition at line 99 of file gamma_params.cpp.

References SetYieldAndUncertainty(), and Uncertainty().

Member Data Documentation

double GammaParams::n_effective_
private
double GammaParams::weight_
private

The documentation for this class was generated from the following files: