23-nov-2003 NvE New memberfunctions GetBetaVector(), GetBeta() and GetGamma() introduced in Ali4Vector.
03-dec-2003 NvE Message removed from AliEvent::GetDevice in case there are no devices present.
return eta;
}
///////////////////////////////////////////////////////////////////////////
+Ali3Vector Ali4Vector::GetBetaVector()
+{
+// Provide the beta 3-vector corresponding to this 4-vector.
+ Ali3Vector beta;
+ if (fabs(fV0)>0.) beta=fV/fV0;
+ if (fabs(fDv0)>0.)
+ {
+ Double_t vecv[3],errv[3],errb[3];
+ Double_t sqerr=0;
+ fV.GetVector(vecv,"car");
+ fV.GetErrors(errv,"car");
+ for (Int_t i=0; i<3; i++)
+ {
+ sqerr=pow((errv[i]/fV0),2)+pow((vecv[i]*fDv0/(fV0*fV0)),2);
+ errb[i]=sqrt(sqerr);
+ }
+ beta.SetErrors(errb,"car");
+ }
+ return beta;
+}
+///////////////////////////////////////////////////////////////////////////
+Double_t Ali4Vector::GetBeta()
+{
+// Provide the beta value (i.e. v/c) corresponding to this 4-vector.
+ Ali3Vector beta=GetBetaVector();
+ Double_t val=beta.GetNorm();
+ fDresult=beta.GetResultError();
+ return val;
+}
+///////////////////////////////////////////////////////////////////////////
+Double_t Ali4Vector::GetGamma()
+{
+// Provide the Lorentz gamma factor corresponding to this 4-vector.
+// In case the gamma factor is infinite a value of -1 is returned.
+ Double_t gamma=-1;
+ fDresult=0;
+ Double_t inv=sqrt(fabs(fV2));
+ if (inv>0.)
+ {
+ Double_t dinv=fDv2/(2.*inv);
+ gamma=fV0/inv;
+ Double_t sqerr=pow((fDv0/inv),2)+pow((fV0*dinv/fV2),2);
+ fDresult=sqrt(sqerr);
+ }
+ return gamma;
+}
+///////////////////////////////////////////////////////////////////////////
Ali3Vector GetVecTrans(); // Provide transverse vector part w.r.t. z-axis
Ali3Vector GetVecLong(); // Provide longitudinal vector part w.r.t. z-axis
Double_t GetPseudoRapidity(); // Provide pseudorapidity of vector part w.r.t z-axis
+ Ali3Vector GetBetaVector(); // Provide the beta 3-vector
+ Double_t GetBeta(); // Provide the norm of the beta 3-vector, i.e. v/c
+ Double_t GetGamma(); // Provide the Lorentz gamma factor
protected:
Double_t fV2; // The Lorentz invariant (v^i*v_i)
Double_t GetScaTrans(); // Provide "transverse value" of scalar part w.r.t. z-axis
Double_t GetScaLong(); // Provide "longitudinal value" of scalar part w.r.t. z-axis
- ClassDef(Ali4Vector,5) // Handling of Lorentz 4-vectors in various reference frames.
+ ClassDef(Ali4Vector,6) // Handling of Lorentz 4-vectors in various reference frames.
};
#endif
* provided "as is" without express or implied warranty. *
**************************************************************************/
-// $Id: AliEvent.cxx,v 1.14 2003/10/26 14:53:44 nick Exp $
+// $Id: AliEvent.cxx,v 1.15 2003/11/21 14:20:10 nick Exp $
///////////////////////////////////////////////////////////////////////////
// Class AliEvent
// Note : All quantities are in GeV, GeV/c or GeV/c**2
//
//--- Author: Nick van Eijndhoven 27-may-2001 UU-SAP Utrecht
-//- Modified: NvE $Date: 2003/10/26 14:53:44 $ UU-SAP Utrecht
+//- Modified: NvE $Date: 2003/11/21 14:20:10 $ UU-SAP Utrecht
///////////////////////////////////////////////////////////////////////////
#include "AliEvent.h"
if (!fDevices)
{
- cout << " *AliEvent::GetDevice* No devices present." << endl;
return 0;
}
else
// Return the device with name tag "name"
if (!fDevices)
{
- cout << " *" << ClassName() << "::GetDevice* No devices present." << endl;
return 0;
}
else
return v;
}
///////////////////////////////////////////////////////////////////////////
-Double_t AliMath::Prob(Double_t chi2,Int_t ndf)
+Double_t AliMath::Prob(Double_t chi2,Int_t ndf,Int_t mode)
{
// Computation of the probability for a certain Chi-squared (chi2)
// and number of degrees of freedom (ndf).
//
-// Calculations are based on the incomplete gamma function P(a,x),
-// where a=ndf/2 and x=chi2/2.
+// According to the value of the parameter "mode" various algorithms
+// can be selected.
+//
+// mode = 0 : Calculations are based on the incomplete gamma function P(a,x),
+// where a=ndf/2 and x=chi2/2.
+//
+// 1 : Same as for mode=0. However, in case ndf=1 an exact expression
+// based on the error function Erf() is used.
+//
+// 2 : Same as for mode=0. However, in case ndf>30 a Gaussian approximation
+// is used instead of the gamma function.
+//
+// When invoked as Prob(chi2,ndf) the default mode=1 is used.
//
// P(a,x) represents the probability that the observed Chi-squared
// for a correct model should be less than the value chi2.
return 1;
}
}
+
+ Double_t v=-1.;
+
+ switch (mode)
+ {
+ case 1: // Exact expression for ndf=1 as alternative for the gamma function
+ if (ndf==1) v=1.-Erf(sqrt(chi2)/sqrt(2.));
+ break;
+
+ case 2: // Gaussian approximation for large ndf (i.e. ndf>30) as alternative for the gamma function
+ if (ndf>30)
+ {
+ Double_t q=sqrt(2.*chi2)-sqrt(double(2*ndf-1));
+ if (q>0.) v=0.5*(1.-Erf(q/sqrt(2.)));
+ }
+ break;
+ }
-// Alternative which is exact
-// This code may be activated in case the gamma function gives problems
-// if (ndf==1)
-// {
-// Double_t v=1.-Erf(sqrt(chi2)/sqrt(2.));
-// return v;
-// }
-
-// Gaussian approximation for large ndf
-// This code may be activated in case the gamma function shows a problem
-// Double_t q=sqrt(2.*chi2)-sqrt(double(2*ndf-1));
-// if (n>30 && q>0.)
-// {
-// Double_t v=0.5*(1.-Erf(q/sqrt(2.)));
-// return v;
-// }
-
- // Evaluate the incomplete gamma function
- Double_t a=double(ndf)/2.;
- Double_t x=chi2/2.;
- return (1.-Gamma(a,x));
+ if (v<0.)
+ {
+ // Evaluate the incomplete gamma function
+ Double_t a=double(ndf)/2.;
+ Double_t x=chi2/2.;
+ v=1.-Gamma(a,x);
+ }
+
+ return v;
}
///////////////////////////////////////////////////////////////////////////
Double_t AliMath::BesselI0(Double_t x)
class AliMath : public TObject
{
public:
- AliMath(); // Default constructor
- virtual ~AliMath(); // Destructor
- AliMath(AliMath& m); // Copy constructor
- Double_t Gamma(Double_t z); // Standard gamma function Gamma(z)
- Double_t Gamma(Double_t a,Double_t x); // Incomplete gamma function P(a,x)
- Double_t LnGamma(Double_t z); // Compute ln[Gamma(z)]
- Double_t Erf(Double_t x); // Error function erf(x)
- Double_t Erfc(Double_t x); // Complementary error function erfc(x)
- Double_t Prob(Double_t chi2,Int_t ndf); // Compute Chi-squared probability
- Double_t BesselI(Int_t n,Double_t x); // Compute integer order modified Bessel function I_n(x)
- Double_t BesselK(Int_t n,Double_t x); // Compute integer order modified Bessel function K_n(x)
+ AliMath(); // Default constructor
+ virtual ~AliMath(); // Destructor
+ AliMath(AliMath& m); // Copy constructor
+ Double_t Gamma(Double_t z); // Standard gamma function Gamma(z)
+ Double_t Gamma(Double_t a,Double_t x); // Incomplete gamma function P(a,x)
+ Double_t LnGamma(Double_t z); // Compute ln[Gamma(z)]
+ Double_t Erf(Double_t x); // Error function erf(x)
+ Double_t Erfc(Double_t x); // Complementary error function erfc(x)
+ Double_t Prob(Double_t chi2,Int_t ndf,Int_t mode=1); // Compute Chi-squared probability
+ Double_t BesselI(Int_t n,Double_t x); // Compute integer order modified Bessel function I_n(x)
+ Double_t BesselK(Int_t n,Double_t x); // Compute integer order modified Bessel function K_n(x)
protected:
Double_t GamSer(Double_t a,Double_t x); // Compute P(a,x) via serial representation
21-nov-2003 NvE Variable names of type "const" started with the character "k" in various
memberfunctions of AliMath in order to comply with the strict Alice
coding conventions.
+22-nov-2003 NvE Support for various computation modes introduced in AliMath::Prob.
+23-nov-2003 NvE New memberfunctions GetBetaVector(), GetBeta() and GetGamma() introduced in Ali4Vector.
+03-dec-2003 NvE Message removed from AliEvent::GetDevice in case there are no devices present.