DAS  3.0
Das Analysis System
Baseabstract

Description

Base functor for any Double Crystal Ball function

The idea is manyfold:

  • store the values of the parameters and of the intermediate steps of the calculation for potential debugging
  • keep the same structure for the distribution itself as well as for the integral of for the derivative

#include <DoubleCrystalBall.h>

+ Inheritance diagram for Base:

Public Member Functions

double Z (double x)
 
void SetParameters (double *p)
 
virtual void Eval (double *x)=0
 
double operator() (double *x, double *p)
 
 Base (TF1 *f=nullptr)
 
void dump ()
 
virtual ~Base ()=default
 

Public Attributes

double N
 
double mu
 
double sigma
 
double kL
 
double nL
 
double kR
 
double nR
 
double AL
 
double AR
 
double BL
 
double BR
 
double z
 
double aR
 
double aL
 
double expaR2
 
double expaL2
 
double CR
 
double CL
 
double DD
 
double K
 
double result
 

Constructor & Destructor Documentation

◆ Base()

Base ( TF1 *  f = nullptr)

If a TF1 is given, then the parameters are taken from f.

60  :
61  N(1), mu(0), sigma(1), kL(-dinf), nL(2), kR(dinf), nR(2), // basic parameters
62  z(0), aR(dinf), aL(-dinf), // normalised parameters
63  expaR2(0), expaL2(0), // values of core at transition points
64  CR(0), CL(0), DD(sqrt(2*M_PI)), // normalisation
65  result(0)
66 {
67  if (f == nullptr) return;
68  assert(f->GetNpar() == 7);
69  double * p = f->GetParameters();
71 }

◆ ~Base()

virtual ~Base ( )
virtualdefault

Default destructor will be taken from the daughter class.

Member Function Documentation

◆ dump()

void dump ( )

Just dump all internal parameters AND the last result.

74 {
75  cout << setw(10) << N
76  << setw(10) << mu
77  << setw(10) << sigma
78  << setw(10) << kL
79  << setw(10) << nL
80  << setw(10) << kR
81  << setw(10) << nR
82 
83  << setw(10) << z
84  << setw(10) << aR
85  << setw(10) << aL
86 
87  << setw(10) << expaR2
88  << setw(10) << expaL2
89 
90  << setw(10) << CR
91  << setw(10) << CL
92  << setw(10) << DD
93 
94  << setw(10) << result
95 
96  << endl;
97 }

◆ Eval()

virtual void Eval ( double *  x)
pure virtual

Virtual method to calculate the value of the function, given the internal set of parameters and the value of x given as parameter.

Implemented in DLog, Integral, and Distribution.

◆ operator()()

double operator() ( double *  x,
double *  p 
)

Standard form as requested from ROOT TF1 objects.

53 {
54  SetParameters(p); // store all parameters (also for external use)
55  z = Z(*x);
56  Eval(x); // this changes according to the derived class
57  return result;
58 }

◆ SetParameters()

void SetParameters ( double *  p)

Retrieves the parameters from p and calculate all intermediate steps of the calculation.

20 {
21  N = p[0];
22  mu = p[1];
23  sigma = max(1e-8,abs(p[2]));
24  assert(sigma > 0);
25  kL = min(mu-1e-8,p[3]);
26  nL = max(1+deps,p[4]);
27  kR = max(mu+1e-8,p[5]);
28  nR = max(1+deps,p[6]);
29 
30  aR = abs(Z(kR));
31  aL = abs(Z(kL));
32 
33  expaR2 = exp(-pow(aR,2)/2.);
34  expaL2 = exp(-pow(aL,2)/2.);
35 
36  AR = pow(nR/aR,nR) * expaR2;
37  AL = pow(nL/aL,nL) * expaL2;
38  BR = nR/aR - aR;
39  BL = nL/aL + aL;
40  // these parameters are usually used in the analytical formula
41  // e.g. on Wikipedia
42  // but in practice the n^n factor can get too large
43  // therefore we actually do not use them in practice
44  // but we still calculate them
45 
46  CR = nR * expaR2 / (aR*(nR-1));
47  CL = nL * expaL2 / (aL*(nL-1));
48  DD = sqrt(M_PI/2.)*(erf(aR/sqrt(2)) + erf(aL/sqrt(2)));
49  K = CR + CL + DD;
50 }

◆ Z()

double Z ( double  x)
inline

Calculate the normalised version of x for Gaussian core.

45  {
46  return (x-mu)/sigma;
47  }

Member Data Documentation

◆ AL

double AL

LHS tail normalisation.

◆ aL

double aL

normalised LHS turn-on point

◆ AR

double AR

RHS tail normalisation.

◆ aR

double aR

normalised RHS turn-on point

◆ BL

double BL

LHS offset.

◆ BR

double BR

RHS offset.

◆ CL

double CL

area in LHS tail

◆ CR

double CR

area in RHS tail

◆ DD

double DD

area in core

◆ expaL2

double expaL2

value of core at normalised LHS turn-on point

◆ expaR2

double expaR2

value of core at normalised RHS turn-on point

◆ K

double K

total normalisation

◆ kL

double kL

LHS turn-on point.

◆ kR

double kR

RHS turn-on point.

◆ mu

double mu

mean

◆ N

double N

global normalisation (best is to fix it to one)

◆ nL

double nL

LHS power.

◆ nR

double nR

RHS power.

◆ result

double result

store last evaludation

◆ sigma

double sigma

width

◆ z

double z

normalised resolution


The documentation for this struct was generated from the following files:
DAS::DoubleCrystalBall::Base::SetParameters
void SetParameters(double *p)
Definition: DoubleCrystalBall.cc:19
DAS::DoubleCrystalBall::Base::BL
double BL
LHS offset.
Definition: DoubleCrystalBall.h:25
DAS::DoubleCrystalBall::Base::Z
double Z(double x)
Calculate the normalised version of x for Gaussian core.
Definition: DoubleCrystalBall.h:44
Ntupliser_cfg.p
p
Definition: Ntupliser_cfg.py:358
Ntupliser_cfg.f
f
Definition: Ntupliser_cfg.py:252
DAS::DoubleCrystalBall::Base::sigma
double sigma
width
Definition: DoubleCrystalBall.h:17
DAS::DoubleCrystalBall::Base::aL
double aL
normalised LHS turn-on point
Definition: DoubleCrystalBall.h:30
DAS::DoubleCrystalBall::Base::expaR2
double expaR2
value of core at normalised RHS turn-on point
Definition: DoubleCrystalBall.h:32
DAS::DoubleCrystalBall::Base::DD
double DD
area in core
Definition: DoubleCrystalBall.h:37
dinf
static const double dinf
Definition: DoubleCrystalBall.cc:14
DAS::DoubleCrystalBall::Base::Eval
virtual void Eval(double *x)=0
DAS::DoubleCrystalBall::Base::CL
double CL
area in LHS tail
Definition: DoubleCrystalBall.h:36
DAS::DoubleCrystalBall::Base::BR
double BR
RHS offset.
Definition: DoubleCrystalBall.h:26
DAS::DoubleCrystalBall::Base::kL
double kL
LHS turn-on point.
Definition: DoubleCrystalBall.h:18
DAS::DoubleCrystalBall::Base::aR
double aR
normalised RHS turn-on point
Definition: DoubleCrystalBall.h:29
DAS::DoubleCrystalBall::Base::z
double z
normalised resolution
Definition: DoubleCrystalBall.h:28
DAS::DoubleCrystalBall::Base::mu
double mu
mean
Definition: DoubleCrystalBall.h:16
DAS::DoubleCrystalBall::Base::AL
double AL
LHS tail normalisation.
Definition: DoubleCrystalBall.h:23
DAS::DoubleCrystalBall::Base::nR
double nR
RHS power.
Definition: DoubleCrystalBall.h:21
DAS::DoubleCrystalBall::Base::result
double result
store last evaludation
Definition: DoubleCrystalBall.h:40
DAS::DoubleCrystalBall::Base::N
double N
global normalisation (best is to fix it to one)
Definition: DoubleCrystalBall.h:15
DAS::DoubleCrystalBall::Base::CR
double CR
area in RHS tail
Definition: DoubleCrystalBall.h:35
DAS::DoubleCrystalBall::Base::expaL2
double expaL2
value of core at normalised LHS turn-on point
Definition: DoubleCrystalBall.h:33
DAS::DoubleCrystalBall::Base::nL
double nL
LHS power.
Definition: DoubleCrystalBall.h:19
DAS::DoubleCrystalBall::Base::AR
double AR
RHS tail normalisation.
Definition: DoubleCrystalBall.h:24
DAS::DoubleCrystalBall::Base::kR
double kR
RHS turn-on point.
Definition: DoubleCrystalBall.h:20
DAS::DoubleCrystalBall::Base::K
double K
total normalisation
Definition: DoubleCrystalBall.h:38
deps
static const double deps
Definition: DoubleCrystalBall.cc:15