DAS  3.0
Das Analysis System
CrystalBall

#include <RoccoR.h>

Public Member Functions

 CrystalBall ()
 
void init ()
 
double pdf (double x) const
 
double pdf (double x, double ks, double dm) const
 
double cdf (double x) const
 
double invcdf (double u) const
 

Public Attributes

double m
 
double s
 
double a
 
double n
 
double B
 
double C
 
double D
 
double N
 
double NA
 
double Ns
 
double NC
 
double F
 
double G
 
double k
 
double cdfMa
 
double cdfPa
 

Static Public Attributes

static const double pi = M_PI
 
static const double sqrtPiOver2 = 0.8862269254527579
 
static const double sqrt2 = 1.4142135623730951
 

Constructor & Destructor Documentation

◆ CrystalBall()

CrystalBall ( )
inline
31  :m(0),s(1),a(10),n(10){
32  init();
33  }

Member Function Documentation

◆ cdf()

double cdf ( double  x) const
inline
73  {
74  double d = (x-m)/s;
75  if(d<-a) return NC / pow(F-s*d/G, n-1);
76  if(d>a) return NC * (C - pow(F+s*d/G, 1-n) );
77  return Ns * (D - sqrtPiOver2 * erf(-d/sqrt2));
78  }

◆ init()

void init ( )
inline
35  {
36  double fa = fabs(a);
37  double ex = exp(-fa*fa/2);
38  double A = pow(n/fa, n) * ex;
39  double C1 = n/fa/(n-1) * ex;
40  double D1 = 2 * sqrtPiOver2 * erf(fa/sqrt2);
41 
42  B = n/fa-fa;
43  C = (D1+2*C1)/C1;
44  D = (D1+2*C1)/2;
45 
46  N = 1.0/s/(D1+2*C1);
47  k = 1.0/(n-1);
48 
49  NA = N*A;
50  Ns = N*s;
51  NC = Ns*C1;
52  F = 1-fa*fa/n;
53  G = s*n/fa;
54 
55  cdfMa = cdf(m-a*s);
56  cdfPa = cdf(m+a*s);
57  }

◆ invcdf()

double invcdf ( double  u) const
inline
80  {
81  if(u<cdfMa) return m + G*(F - pow(NC/u, k));
82  if(u>cdfPa) return m - G*(F - pow(C-u/NC, -k) );
83  return m - sqrt2 * s * boost::math::erf_inv((D - u/Ns )/sqrtPiOver2);
84  }

◆ pdf() [1/2]

double pdf ( double  x) const
inline
59  {
60  double d=(x-m)/s;
61  if(d<-a) return NA*pow(B-d, -n);
62  if(d>a) return NA*pow(B+d, -n);
63  return N*exp(-d*d/2);
64  }

◆ pdf() [2/2]

double pdf ( double  x,
double  ks,
double  dm 
) const
inline
66  {
67  double d=(x-m-dm)/(s*ks);
68  if(d<-a) return NA/ks*pow(B-d, -n);
69  if(d>a) return NA/ks*pow(B+d, -n);
70  return N/ks*exp(-d*d/2);
71  }

Member Data Documentation

◆ a

double a

◆ B

double B

◆ C

double C

◆ cdfMa

double cdfMa

◆ cdfPa

double cdfPa

◆ D

double D

◆ F

double F

◆ G

double G

◆ k

double k

◆ m

double m

◆ n

double n

◆ N

double N

◆ NA

double NA

◆ NC

double NC

◆ Ns

double Ns

◆ pi

constexpr double pi = M_PI
staticconstexpr

◆ s

double s

◆ sqrt2

constexpr double sqrt2 = 1.4142135623730951
staticconstexpr

◆ sqrtPiOver2

constexpr double sqrtPiOver2 = 0.8862269254527579
staticconstexpr

The documentation for this struct was generated from the following files:
CrystalBall::NA
double NA
Definition: RoccoR.h:21
CrystalBall::cdf
double cdf(double x) const
Definition: RoccoR.h:73
CrystalBall::D
double D
Definition: RoccoR.h:18
CrystalBall::F
double F
Definition: RoccoR.h:24
CrystalBall::Ns
double Ns
Definition: RoccoR.h:22
CrystalBall::a
double a
Definition: RoccoR.h:13
CrystalBall::B
double B
Definition: RoccoR.h:16
CrystalBall::cdfMa
double cdfMa
Definition: RoccoR.h:28
tauExample.dm
dm
Definition: tauExample.py:24
CrystalBall::cdfPa
double cdfPa
Definition: RoccoR.h:29
CrystalBall::sqrt2
static const double sqrt2
Definition: RoccoR.h:9
CrystalBall::k
double k
Definition: RoccoR.h:26
CrystalBall::init
void init()
Definition: RoccoR.h:35
CrystalBall::NC
double NC
Definition: RoccoR.h:23
CrystalBall::s
double s
Definition: RoccoR.h:12
CrystalBall::sqrtPiOver2
static const double sqrtPiOver2
Definition: RoccoR.h:8
CrystalBall::m
double m
Definition: RoccoR.h:11
CrystalBall::n
double n
Definition: RoccoR.h:14
CrystalBall::N
double N
Definition: RoccoR.h:19
CrystalBall::G
double G
Definition: RoccoR.h:25
CrystalBall::C
double C
Definition: RoccoR.h:17