AliPhysics  1909eaa (1909eaa)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Function Struct Reference

Public Types

enum  {
  kC, kDelta, kXi, kSigma,
  kN, kA
}
 

Public Member Functions

Double_t NEstimate (Double_t x, Double_t delta, Double_t xi, Double_t sigma, Int_t n, Double_t *a)
 
Double_t Evaluate (Double_t x) const
 
Double_t Evaluate (Double_t x, Double_t &e) const
 
Double_t EstimateNParticles (Double_t x, Short_t maxN=-1)
 
Double_t EstimateNParticles (Double_t x, Double_t &e, Short_t maxN=-1)
 
Double_t RandomEstimateNParticles (Double_t x, Short_t maxN=-1)
 
void Draw (Option_t *option="")
 
Double_t GetC () const
 
Double_t GetDelta () const
 
Double_t GetXi () const
 
Double_t GetSigma () const
 
UShort_t GetN () const
 
Double_t GetA (Int_t i) const
 
Double_tGetAs () const
 
Double_t GetEC () const
 
Double_t GetEDelta () const
 
Double_t GetEXi () const
 
Double_t GetESigma () const
 
UShort_t GetEN () const
 
Double_t GetEA (Int_t i) const
 
Double_tGetEAs () const
 

Static Public Member Functions

static Double_t Landau (Double_t x, Double_t delta, Double_t xi)
 
static Double_t LandauGaus (Double_t x, Double_t delta, Double_t xi, Double_t sigma)
 
static Double_t ILandauGaus (Int_t i, Double_t x, Double_t delta, Double_t xi, Double_t sigma)
 
static Double_t IdLandauGausdPar (Int_t i, Double_t x, UShort_t ipar, Double_t dPar, Double_t delta, Double_t xi, Double_t sigma)
 
static Double_t NLandauGaus (Double_t x, Double_t delta, Double_t xi, Double_t sigma, Int_t n, Double_t *a)
 

Public Attributes

TF1 * fF
 

Static Public Attributes

static const Double_t fgkMPShift = -0.22278298
 MP shift. More...
 
static const Double_t fgkInvRoot2Pi = 1. / TMath::Sqrt(2*TMath::Pi())
 1 / sqrt(2 * pi) More...
 
static const Double_t fgkConvNSigma = 5
 Number of sigmas to integrate over. More...
 
static const Double_t fgkConvNSteps = 100
 Number of steps in integration. More...
 

Detailed Description

Definition at line 40 of file TestELossDist.C.

Member Enumeration Documentation

anonymous enum

Enumeration of parameters

Enumerator
kC 

Constant.

kDelta 

MPV of landau.

kXi 

Width of landau.

kSigma 

Sigma of gaussian.

kN 

Number of particles.

kA 

Weights.

Definition at line 46 of file TestELossDist.C.

Member Function Documentation

void Function::Draw ( Option_t option = "")
inline

Draw the function

Parameters
optionDrawing option

Definition at line 689 of file TestELossDist.C.

Referenced by Generator::Draw().

Double_t Function::EstimateNParticles ( Double_t  x,
Short_t  maxN = -1 
)
inline

Evaluate

\[ E(x;\Delta,\xi,\sigma,\mathbf{a}) = \frac{\sum_{i=1}^{n} i a_i f_i(x;\Delta,\xi,\sigma)}{ f_N(x;\Delta,\xi,\sigma)} = \frac{\sum_{i=1}^{n} i a_i f(x;\Delta_i,\xi_i,\sigma_i)}{ \sum_{i=1}^{n} a_i f(x;\Delta_i,\xi_i,\sigma_i)} \]

If the denominator is less than \(10^{-4}\), then 0 is returned.

Parameters
xWhere to evaluate \( E\)
maxNMaximum number of weights
Returns
\( E(x;\Delta,\xi,\sigma,\mathbf{a})\)

Definition at line 576 of file TestELossDist.C.

Referenced by Generator::Draw().

Double_t Function::EstimateNParticles ( Double_t  x,
Double_t e,
Short_t  maxN = -1 
)
inline

Evaluate

\[ E(x;\Delta,\xi,\sigma,\mathbf{a}) = \frac{\sum_{i=1}^{n} i a_i f_i(x;\Delta,\xi,\sigma)}{ f_N(x;\Delta,\xi,\sigma,\mathbf{a})} = \frac{\sum_{i=1}^{n} i a_i f(x;\Delta_i,\xi_i,\sigma_i)}{ \sum_{i=1}^{n} a_i f(x;\Delta_i,\xi_i,\sigma_i)} \]

If \(f_N(x;\Delta,\xi,\sigma,\mathbf{a})<10^{-4}\) then 0 is returned.

This also calculatues the error \(\delta E\) of the function value at \(x\):

\[ \delta^2 E = \left(\frac{\partial E}{\partial\Delta_p}\right)^2\delta^2\Delta_p+ \left(\frac{\partial E}{\partial\xi }\right)^2\delta^2\xi+ \left(\frac{\partial E}{\partial\sigma }\right)^2\delta^2\sigma+ \sum_{i=2}^N\left(\frac{\partial E}{\partial a_i}\right)^2\delta^2a_i \]

The partial derivatives are evaluated numerically.

Parameters
xWhere to evaluate \( E\)
eOn return, \(\delta E|_{x}\)
maxNMaximum number of weights
Returns
\( E(x;\Delta,\xi,\sigma,\mathbf{a})\)

Definition at line 615 of file TestELossDist.C.

Double_t Function::Evaluate ( Double_t  x) const
inline

Calculate the partial derivative of the function \(E(\Delta;\Delta_p,\xi,\sigma,\mathbf{a})\) with respect to one of the parameters \(\Delta_{p}\), \(\xi\), \(\sigma\), or \(a_i\). Note for that

\begin{eqnarray*} \frac{\partial E}{\partial C} & \equiv & 0\\ \frac{\partial E}{\partial a_1} & \equiv & 0\\ \frac{\partial E}{\partial N} & \equiv & 0\\ @f{eqnarray*} @param x Where to evaluate the derivative @param ipar Parameter to differentiate relative to @param dPar Variation in parameter to use in calculation @param delta @f$\Delta_{p}@f$ @param xi @f$\xi@f$ @param sigma @f$\sigma@f$ @param n @f$N@f$ @param a @f$\mathbf{a} = (a_2,...,a_N)@f$ @return @f$\partial E/\partial p|_{x}@f$ */ Double_t DEstimatePar(Double_t x, Int_t ipar, Double_t delta, Double_t xi, Double_t sigma, UShort_t n, Double_t* a, Double_t dPar=0.001) { Double_t dp = dPar; Double_t d2 = dPar / 2; Double_t y1 = 0; Double_t y2 = 0; Double_t y3 = 0; Double_t y4 = 0; switch (ipar) { case Function::kC: case Function::kN: return 0; case Function::kDelta: y1 = NEstimate(x, delta+dp, xi, sigma, n, a); y2 = NEstimate(x, delta+d2, xi, sigma, n, a); y3 = NEstimate(x, delta-d2, xi, sigma, n, a); y4 = NEstimate(x, delta-dp, xi, sigma, n, a); break; case Function::kXi: y1 = NEstimate(x, delta, xi+dp, sigma, n, a); y2 = NEstimate(x, delta, xi+d2, sigma, n, a); y3 = NEstimate(x, delta, xi-d2, sigma, n, a); y4 = NEstimate(x, delta, xi-dp, sigma, n, a); break; case Function::kSigma: y1 = NEstimate(x, delta, xi, sigma+dp, n, a); y2 = NEstimate(x, delta, xi, sigma+d2, n, a); y3 = NEstimate(x, delta, xi, sigma-d2, n, a); y4 = NEstimate(x, delta, xi, sigma-dp, n, a); break; default: { Int_t j = ipar-kA; if (j+1 > n) return 0; Double_t aa = a[j]; a[j] = aa+dp; y1 = NEstimate(x, delta, xi, sigma, n, a); a[j] = aa+d2; y2 = NEstimate(x, delta, xi, sigma, n, a); a[j] = aa-d2; y3 = NEstimate(x, delta, xi, sigma, n, a); a[j] = aa-dp; y4 = NEstimate(x, delta, xi, sigma, n, a); a[j] = aa; } break; } Double_t d0 = y1 - y4; Double_t d1 = 2 * (y2 - y3); Double_t g = 1/(2*dp) * (4*d1 - d0) / 3; return g; } /** Generate a TF1 object of @f$ f_I@f$ @param n @f$ n@f$ - the number of particles @param c Constant @param delta @f$ \Delta@f$ @param xi @f$ \xi_1@f$ @param sigma @f$ \sigma_1@f$ @param a Array of @f$a_i@f$ for @f$i > 1@f$ @param xmin Least value of range @param xmax Largest value of range @return Newly allocated TF1 object */ static TF1* MakeFunc(Int_t n, Double_t c, Double_t delta, Double_t xi, Double_t sigma, Double_t* a, Double_t xmin, Double_t xmax) { Int_t nPar = kN + n; TF1* f = new TF1(Form("landGaus%d",n), &landauGausN, xmin, xmax, nPar); f->SetNpx(500); f->SetParName(kC, "C"); f->SetParName(kDelta, "#Delta_{p}"); f->SetParName(kXi, "#xi"); f->SetParName(kSigma, "#sigma"); f->SetParName(kN, "N"); f->SetParameter(kC, c); f->SetParameter(kDelta, delta); f->SetParameter(kXi, xi); f->SetParameter(kSigma, sigma); f->FixParameter(kN, n); f->SetParLimits(kDelta, xmin, 4); f->SetParLimits(kXi, 0.00, 4); f->SetParLimits(kSigma, 0.01, 0.11); for (Int_t i = 2; i <= n; i++) { Int_t j = i-2; f->SetParName(kA+j, Form("a_{%d}", i)); f->SetParameter(kA+j, a[j]); f->SetParLimits(kA+j, 0, 1); } return f; } /** Make a ROOT TF1 function object corresponding to a single component for @f$ i@f$ particles @param i Number of particles @param c @f$C@f$ @param delta @f$ \Delta@f$ @param xi @f$ \xi_1@f$ @param sigma @f$ \sigma_1@f$ @param xmin Minimum of range of @f$\Delta@f$ @param xmax Maximum of range of @f$\Delta@f$ @return Pointer to newly allocated ROOT TF1 object */ static TF1* MakeIFunc(Int_t i, Double_t c, Double_t delta, Double_t xi, Double_t sigma, Double_t xmin, Double_t xmax) { Int_t nPar = 5; TF1* f = new TF1(Form("landGausI%d",i), &landauGausI, xmin, xmax, nPar); f->SetNpx(100); f->SetParName(kC, "C"); f->SetParName(kDelta, "#Delta_{p}"); f->SetParName(kXi, "#xi"); f->SetParName(kSigma, "#sigma"); f->SetParName(kN, "N"); f->SetParameter(kC, c); f->SetParameter(kDelta, delta); f->SetParameter(kXi, xi); f->SetParameter(kSigma, sigma); f->FixParameter(kN, i); return f; } // --- Object code ------------------------------------------------- /** Constructor @param n @param c @param delta @param xi @param sigma @param a @param xmin @param xmax @return */ Function(Int_t n, Double_t c, Double_t delta, Double_t xi, Double_t sigma, Double_t* a, Double_t xmin, Double_t xmax) : fF(MakeFunc(n, c, delta, xi, sigma, a, xmin, xmax)) {} Function(TF1* f) : fF(f) {} /** Get pointer to ROOT TF1 object @return Pointer to TF1 object */ TF1* GetF1() { return fF; } /** Evaluate the function at @a x @f[ f_N(x;\Delta,\xi,\sigma) = \sum_{i=1}^{n} a_i f(x;\Delta_i,\xi_i,\sigma_i) \]

Parameters
xWhere to evaluate
Returns

Definition at line 503 of file TestELossDist.C.

Referenced by Generator::Draw(), and RandomEstimateNParticles().

Double_t Function::Evaluate ( Double_t  x,
Double_t e 
) const
inline

Evaluate the function at x

\[ f_N(x;\Delta,\xi,\sigma) = \sum_{i=1}^{n} a_i f(x;\Delta_i,\xi_i,\sigma_i) \]

This also calculates the error on the point like

\[ \delta^2 f_N = \left(\frac{\partial f_N}{\partial\Delta_p}\right)^2\delta^2\Delta_p+ \left(\frac{\partial f_N}{\partial\xi }\right)^2\delta^2\xi+ \left(\frac{\partial f_N}{\partial\sigma }\right)^2\delta^2\sigma+ \sum_{i=2}^N\left(\frac{\partial f_N}{\partial a_i}\right)^2\delta^2a_i \]

Parameters
xWhere to evaluate
eOn return, contains the error \(\delta f_N\) on the function value
Returns
\( f_N(x;\Delta,\xi,\sigma)\)

Definition at line 529 of file TestELossDist.C.

Double_t Function::GetA ( Int_t  i) const
inline
Returns
\(a_{i}\)

Definition at line 701 of file TestELossDist.C.

Referenced by Generator::Draw(), Evaluate(), and RandomEstimateNParticles().

Double_t* Function::GetAs ( ) const
inline
Returns
\(a_2,...,a_N\)

Definition at line 703 of file TestELossDist.C.

Referenced by EstimateNParticles().

Double_t Function::GetC ( ) const
inline
Returns
\(C\)

Definition at line 691 of file TestELossDist.C.

Referenced by Generator::Draw().

Double_t Function::GetDelta ( ) const
inline
Returns
\(\Delta_{mp}\)

Definition at line 693 of file TestELossDist.C.

Referenced by Generator::Draw(), EstimateNParticles(), Evaluate(), and RandomEstimateNParticles().

Double_t Function::GetEA ( Int_t  i) const
inline
Returns
\(\Delta a_{i}\)

Definition at line 715 of file TestELossDist.C.

Referenced by EstimateNParticles(), and Evaluate().

Double_t* Function::GetEAs ( ) const
inline
Returns
\(\Delta a_2,...,\Delta a_N\)

Definition at line 717 of file TestELossDist.C.

Double_t Function::GetEC ( ) const
inline
Returns
\(\Delta C\)

Definition at line 705 of file TestELossDist.C.

Double_t Function::GetEDelta ( ) const
inline
Returns
\(\Delta \Delta_{mp}\)

Definition at line 707 of file TestELossDist.C.

Referenced by EstimateNParticles(), and Evaluate().

UShort_t Function::GetEN ( ) const
inline
Returns
\(\Delta N\)

Definition at line 713 of file TestELossDist.C.

Double_t Function::GetESigma ( ) const
inline
Returns
\(\Delta \sigma\)

Definition at line 711 of file TestELossDist.C.

Referenced by EstimateNParticles(), and Evaluate().

Double_t Function::GetEXi ( ) const
inline
Returns
\(\Delta \xi\)

Definition at line 709 of file TestELossDist.C.

Referenced by EstimateNParticles(), and Evaluate().

UShort_t Function::GetN ( ) const
inline
Returns
\(N\)

Definition at line 699 of file TestELossDist.C.

Referenced by EstimateNParticles(), Evaluate(), and RandomEstimateNParticles().

Double_t Function::GetSigma ( ) const
inline
Returns
\(\sigma\)

Definition at line 697 of file TestELossDist.C.

Referenced by Generator::Draw(), EstimateNParticles(), Evaluate(), and RandomEstimateNParticles().

Double_t Function::GetXi ( ) const
inline
Returns
\(\xi\)

Definition at line 695 of file TestELossDist.C.

Referenced by Generator::Draw(), EstimateNParticles(), Evaluate(), and RandomEstimateNParticles().

static Double_t Function::IdLandauGausdPar ( Int_t  i,
Double_t  x,
UShort_t  ipar,
Double_t  dPar,
Double_t  delta,
Double_t  xi,
Double_t  sigma 
)
inlinestatic

Numerically evaluate

\[ \left.\frac{\partial f_i}{\partial p_i}\right|_{x} \]

where \( p_i\) is the \( i^{\mbox{th}}\) parameter. The mapping of the parameters is given by

  • 0: \(\Delta\)
  • 1: \(\xi\)
  • 2: \(\sigma\)

This is the partial derivative with respect to the parameter of the response function corresponding to \( i\) particles i.e., with the substitutions

\[ \Delta \rightarrow \Delta_i = i(\Delta + \xi\log(i))\\ \xi \rightarrow \xi_i = i \xi\\ \sigma \rightarrow \sigma_i = \sqrt{i}\sigma\\ \]

Parameters
i\( i\)
xWhere to evaluate
iparParameter number
dPar\( \epsilon\delta p_i\) for some value of \(\epsilon\)
delta\( \Delta\)
xi\( \xi\)
sigma\( \sigma\)
Returns
\( f_i\) evaluated

Definition at line 206 of file TestELossDist.C.

Referenced by Evaluate().

static Double_t Function::ILandauGaus ( Int_t  i,
Double_t  x,
Double_t  delta,
Double_t  xi,
Double_t  sigma 
)
inlinestatic

Evaluate

\[ f_i(x;\Delta,\xi,\sigma) = f(x;\Delta_i,\xi_i,\sigma_i) \]

corresponding to \( i\) particles i.e., with the substitutions

\begin{eqnarray*} \Delta \rightarrow \Delta_i &=& i(\Delta + \xi\log(i))\\ \xi \rightarrow \xi_i &=& i \xi\\ \sigma \rightarrow \sigma_i &=& \sqrt{i}\sigma\\ \end{eqnarray*}

Parameters
xWhere to evaluate
delta\( \Delta\)
xi\( \xi\)
sigma\( \sigma\)
i\( i \)
Returns
\( f_i \) evaluated *

Definition at line 160 of file TestELossDist.C.

Referenced by Evaluate(), IdLandauGausdPar(), landauGausI(), NEstimate(), NLandauGaus(), and RandomEstimateNParticles().

static Double_t Function::Landau ( Double_t  x,
Double_t  delta,
Double_t  xi 
)
inlinestatic

Evaluate shifted landay

\[ f'_{L}(x;\Delta,\xi) = f_L(x;\Delta+0.22278298\xi) \]

where \( f_{L}\) is the ROOT implementation of the Landau distribution (known to have \( \Delta_{p}=-0.22278298\) for \(\Delta=0,\xi=1\).

Parameters
xWhere to evaluate \( f'_{L}\)
deltaMost probable value
xiThe 'width' of the distribution
Returns
\( f'_{L}(x;\Delta,\xi) \)

Definition at line 84 of file TestELossDist.C.

Referenced by ILandauGaus().

static Double_t Function::LandauGaus ( Double_t  x,
Double_t  delta,
Double_t  xi,
Double_t  sigma 
)
inlinestatic

Calculate the value of a Landau convolved with a Gaussian

\[ f(x;\Delta,\xi,\sigma') = \frac{1}{\sigma' \sqrt{2 \pi}} \int_{-\infty}^{+\infty} d\Delta' f'_{L}(x;\Delta',\xi) \exp{-\frac{(\Delta-\Delta')^2}{2\sigma^2}} \]

where \( f'_{L}\) is the Landau distribution, \( \Delta\) the energy loss, \( \xi\) the width of the Landau, and \(\sigma\) is the variance of the Gaussian.

Note that this function uses the constants fgkConvNSteps and fgkConvNSigma

References:

Parameters
xwhere to evaluate \( f\)
delta\( \Delta\) of \( f(x;\Delta,\xi,\sigma')\)
xi\( \xi\) of \( f(x;\Delta,\xi,\sigma')\)
sigma\( \sigma\) of Gaussian
Returns
\( f\) evaluated at \( x\).

Definition at line 118 of file TestELossDist.C.

Referenced by ILandauGaus(), landauGaus1(), NEstimate(), and NLandauGaus().

Double_t Function::NEstimate ( Double_t  x,
Double_t  delta,
Double_t  xi,
Double_t  sigma,
Int_t  n,
Double_t a 
)
inline

Calculate the the estimate of number of particle contribtutions at energy loss x

\[ E(\Delta;\Delta_p,\xi,\sigma,\mathbf{a}) = \frac{\sum_{i=1}^N i a_i f_i(x;\Delta_p,\xi,\sigma)}{ \sum_{i=1}^N a_i f_i(x;\Delta_p,\xi,\sigma)} \]

where \(a_1=1\)

Parameters
xEnergy loss \(\Delta\)
delta\(\Delta_{p}\)
xi\(\xi\)
sigma\(\sigma\)
nMaximum number of particles \(N\)
aWeights \(a_i\) for \(i=2,...,N\)
Returns
\(E(\Delta;\Delta_p,\xi,\sigma,\mathbf{a})\)

Definition at line 304 of file TestELossDist.C.

Referenced by EstimateNParticles().

static Double_t Function::NLandauGaus ( Double_t  x,
Double_t  delta,
Double_t  xi,
Double_t  sigma,
Int_t  n,
Double_t a 
)
inlinestatic

Evaluate

\[ f_N(x;\Delta,\xi,\sigma') = \sum_{i=1}^N a_i f_i(x;\Delta,\xi,\sigma'a) \]

where \( f(x;\Delta,\xi,\sigma')\) is the convolution of a Landau with a Gaussian (see LandauGaus). Note that \( a_1 = 1\), \(\Delta_i = i(\Delta_1 + \xi\log(i))\), \(\xi_i=i\xi_1\), and \(\sigma_i'^2 = \sigma_n^2 + i\sigma_1^2\).

References:

  • Nucl.Instrum.Meth.B1:16
  • Phys.Rev.A28:615
    Parameters
    xWhere to evaluate \( f_N\)
    delta\( \Delta_1\)
    xi\( \xi_1\)
    sigma\( \sigma_1\)
    n\( N\) in the sum above.
    aArray of size \( N-1\) of the weights \( a_i\) for \( i > 1\)
    Returns
    \( f_N(x;\Delta,\xi,\sigma)\)

Definition at line 277 of file TestELossDist.C.

Referenced by landauGausN().

Double_t Function::RandomEstimateNParticles ( Double_t  x,
Short_t  maxN = -1 
)
inline

Estimate the number of particles by calculating the weights

\[ w_i = a_i f_i(x;\Delta_p,\xi,\sigma) \]

and then draw a random number \(r\) in the range \([0,\sum_i^N w_i]\) and return the \(i\) for which \(w_{i-1} < @r \leq w_{i}\) (notem \(w_{-1}=0\)).

Parameters
xWhere to evaluate the component functions
maxNMaximum weight to use
Returns
Estimate of the number of particles using the procedure outlined above.

Definition at line 654 of file TestELossDist.C.

Referenced by Generator::Draw().

Member Data Documentation

TF1* Function::fF

The ROOT object

Definition at line 719 of file TestELossDist.C.

Referenced by Draw(), Evaluate(), GetA(), GetAs(), GetC(), GetDelta(), GetEA(), GetEAs(), GetEC(), GetEDelta(), GetESigma(), GetEXi(), GetN(), GetSigma(), and GetXi().

const Double_t Function::fgkConvNSigma = 5
static

Number of sigmas to integrate over.

Definition at line 65 of file TestELossDist.C.

Referenced by LandauGaus().

const Double_t Function::fgkConvNSteps = 100
static

Number of steps in integration.

Definition at line 67 of file TestELossDist.C.

Referenced by LandauGaus().

const Double_t Function::fgkInvRoot2Pi = 1. / TMath::Sqrt(2*TMath::Pi())
static

1 / sqrt(2 * pi)

Definition at line 63 of file TestELossDist.C.

Referenced by LandauGaus().

const Double_t Function::fgkMPShift = -0.22278298
static

MP shift.

Definition at line 61 of file TestELossDist.C.

Referenced by Landau(), and LandauGaus().


The documentation for this struct was generated from the following file: