22-nov-2003 NvE Support for various computation modes introduced in AliMath::Prob.
authornick <nick@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 3 Dec 2003 14:30:26 +0000 (14:30 +0000)
committernick <nick@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 3 Dec 2003 14:30:26 +0000 (14:30 +0000)
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.

RALICE/Ali4Vector.cxx
RALICE/Ali4Vector.h
RALICE/AliEvent.cxx
RALICE/AliMath.cxx
RALICE/AliMath.h
RALICE/history.txt

index 015a6f2ca364dad3013bde312f98ebd096a815bc..334e554299c64ded821ee70ff75d090ccda751c6 100644 (file)
@@ -820,3 +820,50 @@ Double_t Ali4Vector::GetPseudoRapidity()
  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;
+}
+///////////////////////////////////////////////////////////////////////////
index d6ce9f1169effddee89731b4c705136213f1f07c..c1a1a6edb684f95a4228d8749b0f623a435b9ed8 100644 (file)
@@ -51,6 +51,9 @@ class Ali4Vector
   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)
@@ -63,6 +66,6 @@ class Ali4Vector
   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
index bfe920ead8ef8f0b5f472fcac7453323068148d4..20ff1ff80433f8ae43a17cb41a59d66231e932ad 100644 (file)
@@ -13,7 +13,7 @@
  * 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"
@@ -603,7 +603,6 @@ TObject* AliEvent::GetDevice(Int_t i)
 
  if (!fDevices)
  {
-  cout << " *AliEvent::GetDevice* No devices present." << endl;
   return 0;
  }
  else
@@ -627,7 +626,6 @@ TObject* AliEvent::GetDevice(TString name)
 // Return the device with name tag "name"
  if (!fDevices)
  {
-  cout << " *" << ClassName() << "::GetDevice* No devices present." << endl;
   return 0;
  }
  else
index b86710302b675d6839ff54b19a3f987d87ea81f2..0c5dca572f15212aca25e08e91115909cc0d72ab 100644 (file)
@@ -283,13 +283,24 @@ Double_t AliMath::Erfc(Double_t x)
  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.
@@ -313,28 +324,33 @@ Double_t AliMath::Prob(Double_t chi2,Int_t ndf)
    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)
index 888ce97e26d47b4fb3fa4e7fe6966f509fe5bdd7..8c5b310fb0f94204a657b0a81f854c6b6fb4b62c 100644 (file)
 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
index 64364917b2b6d4621ace99e0686ac319aceb0eae..3bf42749fbc2daacddbbd10002b809e1d7f43f10 100644 (file)
 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.