rivet is hosted by Hepforge, IPPP Durham
MathUtils.hh File Reference
#include "Rivet/Math/MathHeader.hh"
#include "Rivet/Tools/RivetBoost.hh"
#include <cassert>
Include dependency graph for MathUtils.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  Rivet
namespace  Rivet::BWHelpers

Functions

double CDF (double x, double mu, double gamma)
 CDF for the Breit-Wigner distribution.
double antiCDF (double p, double mu, double gamma)
 inverse CDF for the Breit-Wigner distribution
Comparison functions for safe (floating point) equality tests
template<typename NUM >
boost::enable_if_c
< boost::is_floating_point
< NUM >::value, bool >::type 
isZero (NUM val, double tolerance=1e-8)
 Compare a number to zero.
template<typename NUM >
boost::enable_if_c
< boost::is_integral< NUM >
::value, bool >::type 
isZero (NUM val, double UNUSED(tolerance)=1e-8)
 Compare a number to zero.
template<typename N1 , typename N2 >
boost::enable_if_c
< boost::is_arithmetic< N1 >
::value &&boost::is_arithmetic
< N2 >::value
&&(boost::is_floating_point
< N1 >::value||boost::is_floating_point
< N2 >::value), bool >::type 
fuzzyEquals (N1 a, N2 b, double tolerance=1e-5)
 Compare two numbers for equality with a degree of fuzziness.
template<typename N1 , typename N2 >
boost::enable_if_c
< boost::is_integral< N1 >
::value &&boost::is_integral
< N2 >::value, bool >::type 
fuzzyEquals (N1 a, N2 b, double UNUSED(tolerance)=1e-5)
 Compare two numbers for equality with a degree of fuzziness.
template<typename N1 , typename N2 >
boost::enable_if_c
< boost::is_arithmetic< N1 >
::value &&boost::is_arithmetic
< N2 >::value, bool >::type 
fuzzyGtrEquals (N1 a, N2 b, double tolerance=1e-5)
 Compare two numbers for >= with a degree of fuzziness.
template<typename N1 , typename N2 >
boost::enable_if_c
< boost::is_arithmetic< N1 >
::value &&boost::is_arithmetic
< N2 >::value, bool >::type 
fuzzyLessEquals (N1 a, N2 b, double tolerance=1e-5)
 Compare two floating point numbers for <= with a degree of fuzziness.
Miscellaneous numerical helpers
template<typename NUM >
boost::enable_if_c
< boost::is_arithmetic< NUM >
::value, NUM >::type 
sqr (NUM a)
 Named number-type squaring operation.
template<typename NUM >
boost::enable_if_c
< boost::is_arithmetic< NUM >
::value, NUM >::type 
add_quad (NUM a, NUM b)
 Named number-type addition in quadrature operation.
template<typename NUM >
boost::enable_if_c
< boost::is_arithmetic< NUM >
::value, NUM >::type 
add_quad (NUM a, NUM b, NUM c)
double safediv (double num, double den, double fail=0.0)
template<typename NUM >
boost::enable_if_c
< boost::is_arithmetic< NUM >
::value, NUM >::type 
intpow (NUM val, unsigned int exp)
 A more efficient version of pow for raising numbers to integer powers.
template<typename NUM >
boost::enable_if_c
< boost::is_arithmetic< NUM >
::value, int >::type 
sign (NUM val)
 Find the sign of a number.
Binning helper functions
vector< double > linspace (size_t nbins, double start, double end, bool include_end=true)
 Make a list of nbins + 1 values equally spaced between start and end inclusive.
vector< double > logspace (size_t nbins, double start, double end, bool include_end=true)
 Make a list of nbins + 1 values exponentially spaced between start and end inclusive.
vector< double > BWspace (size_t nbins, double start, double end, double mu, double gamma)
 Make a list of nbins + 1 values spaced for equal area Breit-Wigner binning between start and end inclusive. mu and gamma are the Breit-Wigner parameters.
template<typename NUM >
int index_between (const NUM &val, const vector< NUM > &binedges)
 Return the bin index of the given value, val, given a vector of bin edges.
Statistics functions
double mean (const vector< int > &sample)
 Calculate the mean of a sample.
double mean_err (const vector< int > &sample)
double covariance (const vector< int > &sample1, const vector< int > &sample2)
 Calculate the covariance (variance) between two samples.
double covariance_err (const vector< int > &sample1, const vector< int > &sample2)
 Calculate the error on the covariance (variance) of two samples, assuming poissonian errors.
double correlation (const vector< int > &sample1, const vector< int > &sample2)
 Calculate the correlation strength between two samples.
double correlation_err (const vector< int > &sample1, const vector< int > &sample2)
 Calculate the error of the correlation strength between two samples assuming Poissonian errors.
Angle range mappings
double _mapAngleM2PITo2Pi (double angle)
 Reduce any number to the range [-2PI, 2PI].
double mapAngleMPiToPi (double angle)
 Map an angle into the range (-PI, PI].
double mapAngle0To2Pi (double angle)
 Map an angle into the range [0, 2PI).
double mapAngle0ToPi (double angle)
 Map an angle into the range [0, PI].
double mapAngle (double angle, PhiMapping mapping)
 Map an angle into the enum-specified range.
Phase space measure helpers
double deltaPhi (double phi1, double phi2)
 Calculate the difference between two angles in radians.
double deltaEta (double eta1, double eta2)
double deltaRap (double y1, double y2)
double deltaR (double rap1, double phi1, double rap2, double phi2)
double rapidity (double E, double pz)
 Calculate a rapidity value from the supplied energy E and longitudinal momentum pz.

Ranges and intervals

enum  RangeBoundary { OPEN = 0, SOFT = 0, CLOSED = 1, HARD = 1 }
template<typename N1 , typename N2 , typename N3 >
boost::enable_if_c
< boost::is_arithmetic< N1 >
::value &&boost::is_arithmetic
< N2 >::value
&&boost::is_arithmetic< N3 >
::value, bool >::type 
inRange (N1 value, N2 low, N3 high, RangeBoundary lowbound=CLOSED, RangeBoundary highbound=OPEN)
 Determine if value is in the range low to high, for floating point numbers.
template<typename N1 , typename N2 , typename N3 >
boost::enable_if_c
< boost::is_arithmetic< N1 >
::value &&boost::is_arithmetic
< N2 >::value
&&boost::is_arithmetic< N3 >
::value, bool >::type 
inRange (N1 value, pair< N2, N3 > lowhigh, RangeBoundary lowbound=CLOSED, RangeBoundary highbound=OPEN)
 Alternative version of inRange which accepts a pair for the range arguments.