From 959fbac55c99883f629c3c4797ac5b89fd3ab079 Mon Sep 17 00:00:00 2001 From: fca Date: Wed, 3 Nov 1999 14:23:18 +0000 Subject: [PATCH] New version of RALICE introduced --- RALICE/Ali3Vector.cxx | 376 ++++++++++++++++++++++- RALICE/Ali3Vector.h | 58 +--- RALICE/Ali3VectorObj.cxx | 91 ++++++ RALICE/Ali3VectorObj.h | 22 ++ RALICE/Ali4Vector.cxx | 616 ++++++++++++++++++++++++++++++++------ RALICE/Ali4Vector.h | 83 ++--- RALICE/Ali4VectorObj.cxx | 93 ++++++ RALICE/Ali4VectorObj.h | 22 ++ RALICE/AliBoost.cxx | 228 +++++++++++--- RALICE/AliBoost.h | 53 +--- RALICE/AliCalcluster.cxx | 65 +++- RALICE/AliCalcluster.h | 16 +- RALICE/AliCalmodule.cxx | 33 +- RALICE/AliCalmodule.h | 13 +- RALICE/AliCalorimeter.cxx | 146 +++++++-- RALICE/AliCalorimeter.h | 46 +-- RALICE/AliInvmass.cxx | 89 ++++++ RALICE/AliInvmass.h | 88 +----- RALICE/AliJet.cxx | 40 +++ RALICE/AliJet.h | 39 +-- RALICE/AliMath.cxx | 21 ++ RALICE/AliMath.h | 20 +- RALICE/AliPosition.cxx | 66 ++++ RALICE/AliPosition.h | 53 +--- RALICE/AliPositionObj.cxx | 91 ++++++ RALICE/AliPositionObj.h | 22 ++ RALICE/AliRandom.cxx | 95 +++++- RALICE/AliRandom.h | 92 +----- RALICE/AliSample.cxx | 29 ++ RALICE/AliSample.h | 26 -- RALICE/AliSignal.cxx | 221 +++++++++++++- RALICE/AliSignal.h | 53 ++-- RALICE/AliTrack.cxx | 268 +++++++++++++++-- RALICE/AliTrack.h | 70 ++--- RALICE/AliVertex.cxx | 104 ++++++- RALICE/AliVertex.h | 93 +----- RALICE/Makefile | 3 +- RALICE/RALICELinkDef.h | 9 +- RALICE/history.txt | 44 +++ html/.rootrc | 2 +- 40 files changed, 2633 insertions(+), 966 deletions(-) create mode 100644 RALICE/Ali3VectorObj.cxx create mode 100644 RALICE/Ali3VectorObj.h create mode 100644 RALICE/Ali4VectorObj.cxx create mode 100644 RALICE/Ali4VectorObj.h create mode 100644 RALICE/AliPositionObj.cxx create mode 100644 RALICE/AliPositionObj.h diff --git a/RALICE/Ali3Vector.cxx b/RALICE/Ali3Vector.cxx index f7d50c61709..1bb0c72a40f 100644 --- a/RALICE/Ali3Vector.cxx +++ b/RALICE/Ali3Vector.cxx @@ -15,8 +15,72 @@ /* $Log$ +Revision 1.2 1999/09/29 09:24:28 fca +Introduction of the Copyright and cvs Log + */ +/////////////////////////////////////////////////////////////////////////// +// Class Ali3Vector +// Handling of 3-vectors in various reference frames. +// +// This class is meant to serve as a base class for ALICE objects +// that have 3-dimensional vector characteristics. +// Error propagation is performed automatically. +// +// Note : +// ------ +// Vectors (v), Errors (e) and reference frames (f) are specified via +// SetVector(Float_t* v,TString f) +// SetErrors(Float_t* e,TString f) +// under the following conventions : +// +// f="car" ==> v in Cartesian coordinates (x,y,z) +// f="sph" ==> v in Spherical coordinates (r,theta,phi) +// f="cyl" ==> v in Cylindrical coordinates (rho,phi,z) +// +// All angles are in radians. +// +// Example : +// --------- +// +// Ali3Vector a; +// Float_t v[3]={-1,25,7}; +// Float_t e[3]={0.03,0.5,0.21}; +// a.SetVector(v,"car"); +// a.SetErrors(e,"car"); +// a.Info(); +// +// Float_t vec[3]; +// Float_t err[3]; +// a.GetVector(vec,"sph"); +// a.GetErrors(vec,"sph"); +// +// Ali3Vector b; +// Float_t v2[3]={6,-18,33}; +// Float_t e2[3]={0.19,0.45,0.93}; +// b.SetVector(v2,"car"); +// b.SetErrors(e2,"car"); +// +// Float_t dotpro=a.Dot(b); +// Float_t doterror=a.GetResultError(); +// +// Ali3Vector c=a.Cross(b); +// c.Info("sph"); +// c.GetVector(vec,"cyl"); +// c.GetErrors(err,"cyl"); +// +// Float_t norm=c.GetNorm(); +// Float_t normerror=c.GetResultError(); +// +// c=a+b; +// c=a-b; +// c=a*5; +// +//--- Author: Nick van Eijndhoven 30-mar-1999 UU-SAP Utrecht +//- Modified: NvE 25-oct-1999 UU-SAP Utrecht +/////////////////////////////////////////////////////////////////////////// + #include "Ali3Vector.h" ClassImp(Ali3Vector) // Class implementation to enable ROOT I/O @@ -24,9 +88,14 @@ ClassImp(Ali3Vector) // Class implementation to enable ROOT I/O Ali3Vector::Ali3Vector() { // Creation of an Ali3Vector object and initialisation of parameters +// All attributes initialised to 0 fV=0; fTheta=0; fPhi=0; + fDx=0; + fDy=0; + fDz=0; + fDresult=0; } /////////////////////////////////////////////////////////////////////////// Ali3Vector::~Ali3Vector() @@ -37,7 +106,14 @@ Ali3Vector::~Ali3Vector() void Ali3Vector::SetVector(Double_t* v,TString f) { // Store vector according to reference frame f +// All errors will be reset to 0 + fDx=0; + fDy=0; + fDz=0; + fDresult=0; + Double_t pi=acos(-1.); + Int_t frame=0; if (f == "car") frame=1; if (f == "sph") frame=2; @@ -144,6 +220,7 @@ void Ali3Vector::GetVector(Double_t* v,TString f) void Ali3Vector::SetVector(Float_t* v,TString f) { // Store vector according to reference frame f +// All errors will be reset to 0 Double_t vec[3]; for (Int_t i=0; i<3; i++) { @@ -163,15 +240,179 @@ void Ali3Vector::GetVector(Float_t* v,TString f) } } /////////////////////////////////////////////////////////////////////////// +void Ali3Vector::SetErrors(Double_t* e,TString f) +{ +// Store errors according to reference frame f +// The error on scalar results is reset to 0 + fDresult=0; + + Int_t frame=0; + if (f == "car") frame=1; + if (f == "sph") frame=2; + if (f == "cyl") frame=3; + + Double_t dx2,dy2,dz2,rho; + + switch (frame) + { + case 1: // Cartesian coordinates + fDx=fabs(e[0]); + fDy=fabs(e[1]); + fDz=fabs(e[2]); + break; + + case 2: // Spherical coordinates + dx2=pow((cos(fPhi)*sin(fTheta)*e[0]),2)+pow((fV*cos(fTheta)*cos(fPhi)*e[1]),2) + +pow((fV*sin(fTheta)*sin(fPhi)*e[2]),2); + dy2=pow((sin(fPhi)*sin(fTheta)*e[0]),2)+pow((fV*cos(fTheta)*sin(fPhi)*e[1]),2) + +pow((fV*sin(fTheta)*cos(fPhi)*e[2]),2); + dz2=pow((cos(fTheta)*e[0]),2)+pow((fV*sin(fTheta)*e[1]),2); + fDx=sqrt(dx2); + fDy=sqrt(dy2); + fDz=sqrt(dz2); + break; + + case 3: // Cylindrical coordinates + rho=fV*sin(fTheta); + dx2=pow((cos(fPhi)*e[0]),2)+pow((rho*sin(fPhi)*e[1]),2); + dy2=pow((sin(fPhi)*e[0]),2)+pow((rho*cos(fPhi)*e[1]),2); + fDx=sqrt(dx2); + fDy=sqrt(dy2); + fDz=fabs(e[2]); + break; + + default: // Unsupported reference frame + cout << "*Ali3Vector::SetErrors* Unsupported frame : " << f << endl + << " Possible frames are 'car', 'sph' and 'cyl'." << endl; + fDx=0; + fDy=0; + fDz=0; + break; + } +} +/////////////////////////////////////////////////////////////////////////// +void Ali3Vector::GetErrors(Double_t* e,TString f) +{ +// Provide errors according to reference frame f + Int_t frame=0; + if (f == "car") frame=1; + if (f == "sph") frame=2; + if (f == "cyl") frame=3; + + Double_t dr2,dtheta2,dphi2,rho,drho2; + Double_t v[3]; + + switch (frame) + { + case 1: // Cartesian coordinates + e[0]=fDx; + e[1]=fDy; + e[2]=fDz; + break; + + case 2: // Spherical coordinates + GetVector(v,"car"); + if (fV) + { + dr2=(pow((v[0]*fDx),2)+pow((v[1]*fDy),2)+pow((v[2]*fDz),2))/(fV*fV); + } + else + { + dr2=0; + } + if (v[2]-fV) + { + dtheta2=(v[2]*v[2]/(pow(fV,4)-pow(v[2],2)*pow(fV,2)))*dr2 + +pow(fDz,2)/(pow(fV,2)-pow(v[2],2)); + } + else + { +// dr2=fDz*fDz; + dtheta2=0; + } + if (v[0] || v[1]) + { + dphi2=(pow((v[1]*fDx),2)+pow((v[0]*fDy),2))/(pow(v[0],2)+pow(v[1],2)); + } + else + { + dphi2=0; + } + e[0]=sqrt(dr2); + e[1]=sqrt(dtheta2); + e[2]=sqrt(dphi2); + break; + + case 3: // Cylindrical coordinates + GetVector(v,"car"); + rho=fV*sin(fTheta); + if (rho) + { + drho2=(pow((v[0]*fDx),2)+pow((v[1]*fDy),2))/(rho*rho); + } + else + { + drho2=0; + } + if (v[0] || v[1]) + { + dphi2=(pow((v[1]*fDx),2)+pow((v[0]*fDy),2))/(pow(v[0],2)+pow(v[1],2)); + } + else + { + dphi2=0; + } + e[0]=sqrt(drho2); + e[1]=sqrt(dphi2); + e[2]=fDz; + break; + + default: // Unsupported reference frame + cout << "*Ali3Vector::GetErrors* Unsupported frame : " << f << endl + << " Possible frames are 'car', 'sph' and 'cyl'." << endl; + for (Int_t i=0; i<3; i++) + { + e[i]=0; + } + break; + } +} +/////////////////////////////////////////////////////////////////////////// +void Ali3Vector::SetErrors(Float_t* e,TString f) +{ +// Store errors according to reference frame f +// The error on scalar results is reset to 0 + Double_t vec[3]; + for (Int_t i=0; i<3; i++) + { + vec[i]=e[i]; + } + SetErrors(vec,f); +} +/////////////////////////////////////////////////////////////////////////// +void Ali3Vector::GetErrors(Float_t* e,TString f) +{ +// Provide errors according to reference frame f + Double_t vec[3]; + GetErrors(vec,f); + for (Int_t i=0; i<3; i++) + { + e[i]=vec[i]; + } +} +/////////////////////////////////////////////////////////////////////////// void Ali3Vector::Info(TString f) { // Print vector components according to reference frame f if (f=="car" || f=="sph" || f=="cyl") { - Double_t vec[3]; + Double_t vec[3],err[3]; GetVector(vec,f); + GetErrors(err,f); cout << " Vector in " << f << " coordinates : " << vec[0] << " " << vec[1] << " " << vec[2] << endl; + cout << " Err. in " << f << " coordinates : " + << err[0] << " " << err[1] << " " << err[2] << endl; } else { @@ -182,39 +423,106 @@ void Ali3Vector::Info(TString f) /////////////////////////////////////////////////////////////////////////// Double_t Ali3Vector::GetNorm() { +// Provide the norm of the current vector +// The error on the scalar result (norm) is updated accordingly + Double_t e[3]; + GetErrors(e,"sph"); + fDresult=e[0]; return fV; } /////////////////////////////////////////////////////////////////////////// +Double_t Ali3Vector::GetPseudoRapidity() +{ +// Provide the pseudo-rapidity w.r.t. the z-axis. +// In other words : eta=-log(tan(theta/2)) +// The error on the scalar result (pseudo-rap.) is updated accordingly + Double_t v[3]; + GetVector(v,"sph"); + Double_t thetahalf=v[1]/2.; + Double_t arg=tan(thetahalf); + Double_t eta=0; + if (arg>0) eta=-log(arg); + Double_t e[3]; + GetErrors(e,"sph"); + Double_t prod=cos(thetahalf)*sin(thetahalf); + fDresult=0; + if (prod) fDresult=fabs(e[1]/2.*prod); + return eta; +} +/////////////////////////////////////////////////////////////////////////// Double_t Ali3Vector::Dot(Ali3Vector& q) { // Provide the dot product of the current vector with vector q - Double_t a[3],b[3]; +// The error on the scalar result (dotproduct) is updated accordingly + Double_t dotpro=0; - GetVector(a,"car"); - q.GetVector(b,"car"); - for (Int_t i=0; i<3; i++) + if ((this) == &q) // Check for special case v.Dot(v) { - dotpro+=a[i]*b[i]; + Double_t norm=GetNorm(); + Double_t dnorm=GetResultError(); + dotpro=pow(norm,2); + fDresult=2.*norm*dnorm; } - + else + { + Double_t a[3],b[3]; + Double_t ea[3],eb[3]; + Double_t d2=0; + + GetVector(a,"car"); + GetErrors(ea,"car"); + q.GetVector(b,"car"); + q.GetErrors(eb,"car"); + for (Int_t i=0; i<3; i++) + { + dotpro+=a[i]*b[i]; + d2+=pow(b[i]*ea[i],2)+pow(a[i]*eb[i],2); + } + fDresult=sqrt(d2); + } + return dotpro; } /////////////////////////////////////////////////////////////////////////// +Double_t Ali3Vector::GetResultError() +{ +// Provide the error on the result of an operation yielding a scalar +// E.g. GetNorm() or Dot() + return fDresult; +} +/////////////////////////////////////////////////////////////////////////// Ali3Vector Ali3Vector::Cross(Ali3Vector& q) { // Provide the cross product of the current vector with vector q +// Error propagation is performed automatically Double_t a[3],b[3],c[3]; + Double_t ea[3],eb[3],ec[3],d2; GetVector(a,"car"); + GetErrors(ea,"car"); q.GetVector(b,"car"); + q.GetErrors(eb,"car"); c[0]=a[1]*b[2]-a[2]*b[1]; c[1]=a[2]*b[0]-a[0]*b[2]; c[2]=a[0]*b[1]-a[1]*b[0]; + d2=pow(b[2]*ea[1],2)+pow(a[1]*eb[2],2) + +pow(b[1]*ea[2],2)+pow(a[2]*eb[1],2); + ec[0]=sqrt(d2); + + d2=pow(b[0]*ea[2],2)+pow(a[2]*eb[0],2) + +pow(b[2]*ea[0],2)+pow(a[0]*eb[2],2); + ec[1]=sqrt(d2); + + d2=pow(b[1]*ea[0],2)+pow(a[0]*eb[1],2) + +pow(b[0]*ea[1],2)+pow(a[1]*eb[0],2); + ec[2]=sqrt(d2); + Ali3Vector v; v.SetVector(c,"car"); + v.SetErrors(ec,"car"); return v; } @@ -222,18 +530,23 @@ Ali3Vector Ali3Vector::Cross(Ali3Vector& q) Ali3Vector Ali3Vector::operator+(Ali3Vector& q) { // Add vector q to the current vector - Double_t a[3],b[3]; +// Error propagation is performed automatically + Double_t a[3],b[3],ea[3],eb[3]; GetVector(a,"car"); + GetErrors(ea,"car"); q.GetVector(b,"car"); + q.GetErrors(eb,"car"); for (Int_t i=0; i<3; i++) { a[i]+=b[i]; + ea[i]=sqrt(pow(ea[i],2)+pow(eb[i],2)); } Ali3Vector v; v.SetVector(a,"car"); + v.SetErrors(ea,"car"); return v; } @@ -241,36 +554,45 @@ Ali3Vector Ali3Vector::operator+(Ali3Vector& q) Ali3Vector Ali3Vector::operator-(Ali3Vector& q) { // Subtract vector q from the current vector - Double_t a[3],b[3]; +// Error propagation is performed automatically + Double_t a[3],b[3],ea[3],eb[3]; GetVector(a,"car"); + GetErrors(ea,"car"); q.GetVector(b,"car"); + q.GetErrors(eb,"car"); for (Int_t i=0; i<3; i++) { a[i]-=b[i]; + ea[i]=sqrt(pow(ea[i],2)+pow(eb[i],2)); } Ali3Vector v; v.SetVector(a,"car"); + v.SetErrors(ea,"car"); return v; } /////////////////////////////////////////////////////////////////////////// Ali3Vector Ali3Vector::operator*(Double_t s) { -// Multiply the current vector with a scalar s - Double_t a[3]; +// Multiply the current vector with a scalar s. +// Error propagation is performed automatically. + Double_t a[3],ea[3]; GetVector(a,"car"); + GetErrors(ea,"car"); for (Int_t i=0; i<3; i++) { a[i]*=s; + ea[i]*=s; } Ali3Vector v; v.SetVector(a,"car"); + v.SetErrors(ea,"car"); return v; } @@ -278,6 +600,7 @@ Ali3Vector Ali3Vector::operator*(Double_t s) Ali3Vector Ali3Vector::operator/(Double_t s) { // Divide the current vector by a scalar s +// Error propagation is performed automatically if (fabs(s)<1.e-20) // Protect against division by 0 { @@ -286,17 +609,20 @@ Ali3Vector Ali3Vector::operator/(Double_t s) } else { - Double_t a[3]; + Double_t a[3],ea[3]; GetVector(a,"car"); + GetErrors(ea,"car"); for (Int_t i=0; i<3; i++) { a[i]/=s; + ea[i]/=s; } Ali3Vector v; v.SetVector(a,"car"); + v.SetErrors(ea,"car"); return v; } @@ -305,17 +631,22 @@ Ali3Vector Ali3Vector::operator/(Double_t s) Ali3Vector& Ali3Vector::operator+=(Ali3Vector& q) { // Add vector q to the current vector - Double_t a[3],b[3]; +// Error propagation is performed automatically + Double_t a[3],b[3],ea[3],eb[3]; GetVector(a,"car"); + GetErrors(ea,"car"); q.GetVector(b,"car"); + q.GetErrors(eb,"car"); for (Int_t i=0; i<3; i++) { a[i]+=b[i]; + ea[i]=sqrt(pow(ea[i],2)+pow(eb[i],2)); } SetVector(a,"car"); + SetErrors(ea,"car"); return *this; } @@ -323,17 +654,22 @@ Ali3Vector& Ali3Vector::operator+=(Ali3Vector& q) Ali3Vector& Ali3Vector::operator-=(Ali3Vector& q) { // Subtract vector q from the current vector - Double_t a[3],b[3]; +// Error propagation is performed automatically + Double_t a[3],b[3],ea[3],eb[3]; GetVector(a,"car"); + GetErrors(ea,"car"); q.GetVector(b,"car"); + q.GetErrors(eb,"car"); for (Int_t i=0; i<3; i++) { a[i]-=b[i]; + ea[i]=sqrt(pow(ea[i],2)+pow(eb[i],2)); } SetVector(a,"car"); + SetErrors(ea,"car"); return *this; } @@ -341,16 +677,20 @@ Ali3Vector& Ali3Vector::operator-=(Ali3Vector& q) Ali3Vector& Ali3Vector::operator*=(Double_t s) { // Multiply the current vector with a scalar s - Double_t a[3]; +// Error propagation is performed automatically + Double_t a[3],ea[3]; GetVector(a,"car"); + GetErrors(ea,"car"); for (Int_t i=0; i<3; i++) { a[i]*=s; + ea[i]*=s; } SetVector(a,"car"); + SetErrors(ea,"car"); return *this; } @@ -358,6 +698,7 @@ Ali3Vector& Ali3Vector::operator*=(Double_t s) Ali3Vector& Ali3Vector::operator/=(Double_t s) { // Divide the current vector by a scalar s +// Error propagation is performed automatically if (fabs(s)<1.e-20) // Protect against division by 0 { @@ -366,16 +707,19 @@ Ali3Vector& Ali3Vector::operator/=(Double_t s) } else { - Double_t a[3]; + Double_t a[3],ea[3]; GetVector(a,"car"); + GetErrors(ea,"car"); for (Int_t i=0; i<3; i++) { a[i]/=s; + ea[i]/=s; } SetVector(a,"car"); + SetErrors(ea,"car"); return *this; } diff --git a/RALICE/Ali3Vector.h b/RALICE/Ali3Vector.h index 3970430cffc..6c8c593bd8e 100644 --- a/RALICE/Ali3Vector.h +++ b/RALICE/Ali3Vector.h @@ -5,52 +5,6 @@ /* $Id$ */ -/////////////////////////////////////////////////////////////////////////// -// Class Ali3Vector -// Handling of 3-vectors in various reference frames. -// -// This class is meant to serve as a base class for ALICE objects -// that have 3-dimensional vector characteristics. -// -// Note : -// ------ -// Vectors (v) and reference frames (f) are specified via -// SetVector(Float_t* v,TString f) under the following conventions : -// -// f="car" ==> v in Cartesian coordinates (x,y,z) -// f="sph" ==> v in Spherical coordinates (r,theta,phi) -// f="cyl" ==> v in Cylindrical coordinates (rho,phi,z) -// -// All angles are in radians. -// -// Example : -// --------- -// -// Ali3Vector a; -// Float_t v[3]={-1,25,7}; -// a.SetVector(v,"car"); -// a.Info(); -// -// Float_t vec[3]; -// a.GetVector(vec,"sph"); -// -// Ali3Vector b; -// Float_t v2[3]={6,-18,33}; -// b.SetVector(v2,"car"); -// -// Float_t dotpro=a.Dot(b); -// -// Ali3Vector c=a.Cross(b); -// c.Info("sph"); -// c.GetVector(vec,"cyl"); -// Float_t norm=c.GetNorm(); -// c=a+b; -// c=a-b; -// c=a*5; -// -//--- NvE 30-mar-1999 UU-SAP Utrecht -/////////////////////////////////////////////////////////////////////////// - #include #include @@ -66,9 +20,15 @@ class Ali3Vector virtual void GetVector(Double_t* v,TString f); // Provide vector v in frame f virtual void SetVector(Float_t* v,TString f); // Store vector v in frame f virtual void GetVector(Float_t* v,TString f); // Provide vector v in frame f + virtual void SetErrors(Double_t* e,TString f); // Store errors of vector in frame f + virtual void GetErrors(Double_t* e,TString f); // Provide errors of vector in frame f + virtual void SetErrors(Float_t* e,TString f); // Store errors of vector in frame f + virtual void GetErrors(Float_t* e,TString f); // Provide errors of vector in frame f virtual void Info(TString f="car"); // Print vector components in frame f Double_t GetNorm(); // Provide norm of the vector Double_t Dot(Ali3Vector& q); // Provide dot product with q + Double_t GetPseudoRapidity(); // Provide the pseudorapidity w.r.t z-axis + Double_t GetResultError(); // Provide error on scalar result (e.g. norm) Ali3Vector Cross(Ali3Vector& q); // Provide cross product with q Ali3Vector operator+(Ali3Vector& q); // Add vector q Ali3Vector operator-(Ali3Vector& q); // Subtract vector q @@ -80,8 +40,10 @@ class Ali3Vector Ali3Vector& operator/=(Double_t s); // Divide by scalar s protected: - Double_t fV,fTheta,fPhi; // Vector in spherical coordinates + Double_t fV,fTheta,fPhi; // Vector in spherical coordinates + Double_t fDx,fDy,fDz; // Errors on Cartesian coordinates + Double_t fDresult; // Error on scalar result (e.g. norm or dotproduct) - ClassDef(Ali3Vector,1) // Class definition to enable ROOT I/O + ClassDef(Ali3Vector,1) // Handling of 3-vectors in various reference frames. }; #endif diff --git a/RALICE/Ali3VectorObj.cxx b/RALICE/Ali3VectorObj.cxx new file mode 100644 index 00000000000..e0c371a6095 --- /dev/null +++ b/RALICE/Ali3VectorObj.cxx @@ -0,0 +1,91 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* +$Log$ +*/ + +/////////////////////////////////////////////////////////////////////////// +// Class Ali3VectorObj +// Handling of 3-vectors in various reference frames. +// +// This class is meant to provide an Ali3Vector object which is derived +// from TObject such that it can be stored in e.g. TObjArray etc... +// and that it can be written out using the ROOT I/O machinery. +// +// Example : +// ========= +// +// Float_t a[3]={1,2,3}; +// Float_t ea[3]={0.01,0.02,0.03}; +// Float_t b[3]={4,5,6}; +// Float_t eb[3]={0.04,0.05,0.06}; +// +// Ali3Vector v,w; +// +// v.SetVector(a,"car"); +// v.SetErrors(ea,"car"); +// w.SetVector(b,"car"); +// w.SetErrors(eb,"car"); +// +// Ali3Vector cross=v.Cross(w); +// +// Ali3Vector add=v+w; +// +// Ali3VectorObj vec1(cross); +// +// Ali3VectorObj vec2; +// vec2.Load(add); +// +// vec1.Info(); +// vec2.Info(); +// +//--- Author: Nick van Eijndhoven 18-oct-1999 UU-SAP Utrecht +/////////////////////////////////////////////////////////////////////////// + +#include "Ali3VectorObj.h" + +ClassImp(Ali3VectorObj) // Class implementation to enable ROOT I/O + +Ali3VectorObj::Ali3VectorObj() +{ +// Creation of an Ali3VectorObj object and initialisation of parameters. +// All attributes initialised to 0. +} +/////////////////////////////////////////////////////////////////////////// +Ali3VectorObj::Ali3VectorObj(Ali3Vector& q) +{ +// Creation of an Ali3VectorObj object and initialisation of parameters. +// All attributes are initialised to the values of the input Ali3Vector. + Load(q); +} +/////////////////////////////////////////////////////////////////////////// +Ali3VectorObj::~Ali3VectorObj() +{ +// Destructor to delete dynamically allocated memory. +} +/////////////////////////////////////////////////////////////////////////// +void Ali3VectorObj::Load(Ali3Vector& q) +{ +// Load all attributes of the input Ali3Vector into this Ali3VectorObj object. + Double_t temp=q.GetResultError(); + Double_t a[3]; + q.GetVector(a,"sph"); + SetVector(a,"sph"); + q.GetErrors(a,"car"); + SetErrors(a,"car"); + fDresult=temp; +} +/////////////////////////////////////////////////////////////////////////// diff --git a/RALICE/Ali3VectorObj.h b/RALICE/Ali3VectorObj.h new file mode 100644 index 00000000000..156fbc4438d --- /dev/null +++ b/RALICE/Ali3VectorObj.h @@ -0,0 +1,22 @@ +#ifndef ALI3VECTOROBJ_H +#define ALI3VECTOROBJ_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +#include "TObject.h" + +#include "Ali3Vector.h" + +class Ali3VectorObj : public TObject,public Ali3Vector +{ + public: + Ali3VectorObj(); // Default constructor + Ali3VectorObj(Ali3Vector& q); // Constructor + ~Ali3VectorObj(); // Destructor + void Load(Ali3Vector& q); // Load all attributes of input Ali3Vector + + ClassDef(Ali3VectorObj,1) // Handling of 3-vectors in various reference frames. +}; +#endif diff --git a/RALICE/Ali4Vector.cxx b/RALICE/Ali4Vector.cxx index a62b302f077..44d6c82eb65 100644 --- a/RALICE/Ali4Vector.cxx +++ b/RALICE/Ali4Vector.cxx @@ -15,16 +15,141 @@ /* $Log$ +Revision 1.2 1999/09/29 09:24:28 fca +Introduction of the Copyright and cvs Log + */ +/////////////////////////////////////////////////////////////////////////// +// Class Ali4Vector +// Handling of Lorentz 4-vectors in various reference frames. +// +// This class is meant to serve as a base class for ALICE objects +// that have Lorentz 4-vector characteristics. +// Error propagation is performed automatically. +// +// All 4-vectors are treated in the contravariant form and the convention +// for the metric and the 4-vector components is according to the one +// used in the book "Classical Electrodynamics" by J.D. Jackson. +// +// A 4-vector is said to have a scalar part and a 3-vector part, +// which is indicated by the notation +// +// x^i = (x^0,x^1,x^2,x^3) +// +// The scalar part = x^0 +// The 3-vector part = (x^1,x^2,x^3) +// +// In view of accuracy and the fact that e.g. particle identity (mass) +// is preserved in many physics processes, the Lorentz invariant +// (x^i*x_i) is internally saved together with the scalar part. +// +// This allows the following two modes of functionality : +// +// Scalar mode : The scalar part and the 3-vector part are considered +// as basic quantities and the invariant with its error +// is derived from these. +// Invariant mode : The invariant and the 3-vector part are considered +// as basic quantities and the scalar with its error +// is derived from these. +// +// The philosophy followed here is the following : +// =============================================== +// +// 1) Invokation of SetVector() sets the scalar and 3-vector parts +// and the invariant is calculated from these. +// Automatically the scalar mode is selected and invokation of +// SetErrors() will calculate the error on the invariant. +// +// 2) In case the scalar part is modified via SetScalar(), scalar mode is +// automatically selected and the Lorentz invariant (x^i*x_i) and its +// error are updated accordingly. +// The 3-vector part is NOT modified. +// This situation arises when one e.g. precisely determines the time +// or energy (x^0). +// +// 3) In case the Lorentz invariant (x^i*x_i) is modified via SetInvariant(), +// invariant mode is selected automatically and the scalar part and its +// error are updated accordingly. +// The 3-vector part is NOT modified. +// This situation arises when one e.g. precisely determines the mass. +// +// 4) In case the vector part is modified via Set3Vector(), then the +// current mode determines whether the scalar or the invariant is updated. +// Scalar mode : The Lorentz invariant (x^i*x_i) and its error are updated; +// the scalar part and its error are NOT modified. +// This situation arises when one e.g. improves the 3-position +// vector for a particle with a very precise timing. +// Invariant mode : The scalar part and its error are updated; +// the Lorentz invariant (x^i*x_i) and its error are NOT modified. +// This situation arises when one e.g. improves the 3-momentum +// vector for a particle with known mass. +// +// The dotproduct is defined such that p.Dot(p) yields the Lorentz invariant +// scalar of the 4-vector p (i.e. m**2 in case p is a 4-momentum). +// +// Note : +// ------ +// Vectors (v), Errors (e) and reference frames (f) are specified via +// SetVector(Float_t* v,TString f) +// SetErrors(Float_t* e,TString f) +// under the following conventions : +// +// f="car" ==> 3-vector part of v in Cartesian coordinates (x,y,z) +// f="sph" ==> 3-vector part of v in Spherical coordinates (r,theta,phi) +// f="cyl" ==> 3-vector part of v in Cylindrical coordinates (rho,phi,z) +// +// All angles are in radians. +// +// Example : +// --------- +// +// Ali4Vector a; +// +// Float_t v[4]={25,-1,3,7}; +// a.SetVector(v,"car"); +// +// Float_t vec[4]; +// a.GetVector(vec,"sph"); +// +// Ali4Vector b; +// Float_t v2[4]={33,6,-18,2}; +// b.SetVector(v2,"car"); +// +// Float_t dotpro=a.Dot(b); +// +// Float_t x0=16; +// Ali3Vector x; +// Float_t vec2[3]={1,2,3}; +// x.SetVector(vec2,"car"); +// +// Ali4Vector c; +// c.SetVector(x0,x); +// c.GetVector(vec,"car"); +// c.Info("cyl"); +// c=a+b; +// c=a-b; +// c=a*5; +// +//--- Author: Nick van Eijndhoven 01-apr-1999 UU-SAP Utrecht +//- Modified: NvE 15-oct-1999 UU-SAP Utrecht +/////////////////////////////////////////////////////////////////////////// + #include "Ali4Vector.h" ClassImp(Ali4Vector) // Class implementation to enable ROOT I/O Ali4Vector::Ali4Vector() { -// Creation of a contravariant 4-vector and initialisation of parameters +// Creation of a contravariant 4-vector and initialisation of parameters. +// All values are initialised to 0. +// Scalar mode is initially selected. + fScalar=1; + fV2=0; + fDv2=0; fV0=0; + fDv0=0; + fDresult=0; Double_t a[3]={0,0,0}; fV.SetVector(a,"sph"); } @@ -36,27 +161,53 @@ Ali4Vector::~Ali4Vector() /////////////////////////////////////////////////////////////////////////// void Ali4Vector::SetVector(Double_t v0,Ali3Vector v) { -// Store contravariant vector +// Store contravariant vector. +// The error on the scalar part is initialised to 0. +// The errors on the vector part are taken from the input Ali3Vector. +// Scalar mode is automatically selected. +// The error on scalar result operations is reset to 0. + fScalar=1; fV0=v0; fV=v; + fV2=pow(v0,2)-fV.Dot(fV); + SetScalarError(0); } /////////////////////////////////////////////////////////////////////////// void Ali4Vector::SetVector(Double_t* v,TString f) { -// Store vector according to reference frame f - fV0=v[0]; +// Store vector according to reference frame f. +// All errors are initialised to 0. +// Scalar mode is automatically selected. +// The error on scalar result operations is reset to 0. + fScalar=1; Double_t a[3]; for (Int_t i=0; i<3; i++) { a[i]=v[i+1]; } + fV0=v[0]; fV.SetVector(a,f); + fV2=pow(fV0,2)-fV.Dot(fV); + fDv2=0; + fDv0=0; + fDresult=0; } /////////////////////////////////////////////////////////////////////////// void Ali4Vector::GetVector(Double_t* v,TString f) { -// Provide vector according to reference frame f - v[0]=fV0; +// Provide 4-vector components according to reference frame f +// and according to the current mode. +// Scalar mode : The scalar part is directly returned via v[0]. +// Invariant mode : The scalar part is re-calculated via the value +// of the Lorentz invariant and then returned via v[0]. + if (fScalar) + { + v[0]=fV0; + } + else + { + v[0]=sqrt(fV.Dot(fV)+fV2); + } Double_t a[3]; fV.GetVector(a,f); for (Int_t i=0; i<3; i++) @@ -67,7 +218,10 @@ void Ali4Vector::GetVector(Double_t* v,TString f) /////////////////////////////////////////////////////////////////////////// void Ali4Vector::SetVector(Float_t* v,TString f) { -// Store vector according to reference frame f +// Store vector according to reference frame f. +// All errors are initialised to 0. +// Scalar mode is automatically selected. +// The error on scalar result operations is reset to 0. Double_t vec[4]; for (Int_t i=0; i<4; i++) { @@ -78,7 +232,11 @@ void Ali4Vector::SetVector(Float_t* v,TString f) /////////////////////////////////////////////////////////////////////////// void Ali4Vector::GetVector(Float_t* v,TString f) { -// Provide vector according to reference frame f +// Provide 4-vector components according to reference frame f +// and according to the current mode. +// Scalar mode : The scalar part is directly returned via v[0]. +// Invariant mode : The scalar part is re-calculated via the value +// of the Lorentz invariant and then returned via v[0]. Double_t vec[4]; GetVector(vec,f); for (Int_t i=0; i<4; i++) @@ -89,8 +247,168 @@ void Ali4Vector::GetVector(Float_t* v,TString f) /////////////////////////////////////////////////////////////////////////// Double_t Ali4Vector::GetScalar() { -// Provide the scalar part - return fV0; +// Provide the scalar part. +// The error on the scalar value is available via GetResultError() +// after invokation of GetScalar(). + if (fScalar) + { + fDresult=fDv0; + return fV0; + } + else + { + Double_t dot=fV.Dot(fV); + Double_t ddot=fV.GetResultError(); + Double_t v02=dot+fV2; + Double_t dv02=sqrt(pow(ddot,2)+pow(fDv2,2)); + Double_t v0=sqrt(fabs(v02)); + Double_t dv0=0; + if (v0) dv0=dv02/(2.*v0); + fDresult=dv0; + return v0; + } +} +/////////////////////////////////////////////////////////////////////////// +Double_t Ali4Vector::GetResultError() +{ +// Provide the error on the result of an operation yielding a scalar +// E.g. GetScalar(), GetInvariant() or Dot() + return fDresult; +} +/////////////////////////////////////////////////////////////////////////// +void Ali4Vector::SetScalar(Double_t v0,Double_t dv0) +{ +// Modify the scalar part (v0) and its error (dv0). +// The default value for dv0 is 0. +// The vector part is not modified. +// Scalar mode is automatically selected +// ==> Lorentz invariant and its error are updated. +// The error on scalar result operations is reset to 0. + fScalar=1; + fV0=v0; + fV2=pow(v0,2)-fV.Dot(fV); + SetScalarError(dv0); +} +/////////////////////////////////////////////////////////////////////////// +void Ali4Vector::SetScalarError(Double_t dv0) +{ +// Set the error on the scalar part. +// If in scalar mode, update error on the invariant accordingly. +// The error on scalar result operations is reset to 0. + fDv0=dv0; + if (fScalar) + { + Double_t norm=fV.GetNorm(); + Double_t dnorm=fV.GetResultError(); + fDv2=sqrt(pow(2.*fV0*fDv0,2)+pow(2.*norm*dnorm,2)); + } + fDresult=0; +} +/////////////////////////////////////////////////////////////////////////// +void Ali4Vector::Set3Vector(Ali3Vector v) +{ +// Set the 3-vector part, the errors are taken from the input Ali3Vector +// Scalar mode : The scalar part and its error are not modified, +// the Lorentz invariantand its error are re-calculated. +// Invariant mode : The Lorentz invariant and its error are not modified, +// the scalar part and its error are re-calculated. +// The error on scalar result operations is reset to 0. + fV=v; + if (fScalar) + { + SetScalar(fV0,fDv0); + } + else + { + SetInvariant(fV2,fDv2); + } +} +/////////////////////////////////////////////////////////////////////////// +void Ali4Vector::Set3Vector(Double_t* v,TString f) +{ +// Set the 3-vector part according to reference frame f +// The errors on the vector part are initialised to 0 +// Scalar mode : The scalar part and its error are not modified, +// the Lorentz invariantand its error are re-calculated. +// Invariant mode : The Lorentz invariant and its error are not modified, +// the scalar part and its error are re-calculated. +// The error on scalar result operations is reset to 0. + Double_t a[3]; + for (Int_t i=0; i<3; i++) + { + a[i]=v[i]; + } + fV.SetVector(a,f); + + if (fScalar) + { + SetScalar(fV0,fDv0); + } + else + { + SetInvariant(fV2,fDv2); + } +} +/////////////////////////////////////////////////////////////////////////// +void Ali4Vector::Set3Vector(Float_t* v,TString f) +{ +// Set the 3-vector part according to reference frame f +// The errors on the vector part are initialised to 0 +// The Lorentz invariant is not modified +// The error on scalar result operations is reset to 0. + Double_t vec[3]; + for (Int_t i=0; i<3; i++) + { + vec[i]=v[i]; + } + Set3Vector(vec,f); +} +/////////////////////////////////////////////////////////////////////////// +void Ali4Vector::SetInvariant(Double_t v2,Double_t dv2) +{ +// Modify the Lorentz invariant (v2) quantity v^i*v_i and its error (dv2). +// The default value for the error dv2 is 0. +// The vector part is not modified. +// Invariant mode is automatically selected +// ==> the scalar part and its error are updated. +// The error on scalar result operations is reset to 0. +// + fScalar=0; + fV2=v2; + fDv2=dv2; + fV0=GetScalar(); + fDv0=GetResultError(); + fDresult=0; +} +/////////////////////////////////////////////////////////////////////////// +void Ali4Vector::SetInvariantError(Double_t dv2) +{ +// Set the error on the Lorentz invariant. +// If in invariant mode, update error on the scalar part accordingly. +// The error on scalar result operations is reset to 0. + fDv2=dv2; + if (!fScalar) + { + fDv0=GetResultError(); + } + fDresult=0; +} +/////////////////////////////////////////////////////////////////////////// +Double_t Ali4Vector::GetInvariant() +{ +// Provide the Lorentz invariant v^i*v_i. +// The error on the Lorentz invariant is available via GetResultError() +// after invokation of GetInvariant(). + if (!fScalar) + { + fDresult=fDv2; + return fV2; + } + else + { + Double_t inv=Dot(*this); + return inv; + } } /////////////////////////////////////////////////////////////////////////// Ali3Vector Ali4Vector::Get3Vector() @@ -99,15 +417,85 @@ Ali3Vector Ali4Vector::Get3Vector() return fV; } /////////////////////////////////////////////////////////////////////////// +void Ali4Vector::SetErrors(Double_t* e,TString f) +{ +// Store errors for vector v^i according to reference frame f +// If in scalar mode, update error on the invariant accordingly. +// The error on scalar result operations is reset to 0. + Double_t a[3]; + for (Int_t i=0; i<3; i++) + { + a[i]=e[i+1]; + } + SetScalarError(e[0]); + fV.SetErrors(a,f); +} +/////////////////////////////////////////////////////////////////////////// +void Ali4Vector::SetErrors(Float_t* e,TString f) +{ +// Store errors for vector v^i according to reference frame f +// If in scalar mode, update error on the invariant accordingly. +// The error on scalar result operations is reset to 0. + Double_t a[4]; + for (Int_t i=0; i<4; i++) + { + a[i]=e[i]; + } + SetErrors(a,f); +} +/////////////////////////////////////////////////////////////////////////// +void Ali4Vector::GetErrors(Double_t* e,TString f) +{ +// Provide errors for vector v^i according to reference frame f +// and according to the current mode. +// Scalar mode : The error on the scalar part is directly returned via e[0]. +// Invariant mode : The error on the scalar part is re-calculated via the error +// value on the Lorentz invariant and then returned via e[0]. + Double_t a[3]; + fV.GetErrors(a,f); + + e[0]=GetResultError(); + for (Int_t i=0; i<3; i++) + { + e[i+1]=a[i]; + } +} +/////////////////////////////////////////////////////////////////////////// +void Ali4Vector::GetErrors(Float_t* e,TString f) +{ +// Provide errors for vector v^i according to reference frame f +// and according to the current mode. +// Scalar mode : The error on the scalar part is directly returned via e[0]. +// Invariant mode : The error on the scalar part is re-calculated via the error +// value on the Lorentz invariant and then returned via e[0]. + Double_t a[4]; + GetErrors(a,f); + for (Int_t i=0; i<4; i++) + { + e[i]=a[i]; + } +} +/////////////////////////////////////////////////////////////////////////// void Ali4Vector::Info(TString f) { -// Print contravariant vector components according to reference frame f +// Print contravariant vector components and errors according to +// reference frame f and according to the current mode. +// Scalar mode : The scalar part and its error are directly returned. +// Invariant mode : The scalar part and its error are re-calculated via the +// value (and error) of the Lorentz invariant. + if (f=="car" || f=="sph" || f=="cyl") { - Double_t vec[4]; + Double_t vec[4],err[4]; GetVector(vec,f); + GetErrors(err,f); + Double_t inv=GetInvariant(); + Double_t dinv=GetResultError(); cout << " Contravariant vector in " << f << " coordinates : " << vec[0] << " " << vec[1] << " " << vec[2] << " " << vec[3] << endl; + cout << " ------------- Errors in " << f << " coordinates : " + << err[0] << " " << err[1] << " " << err[2] << " " << err[3] << endl; + cout << " --- Lorentz invariant (v^i*v_i) : " << inv << " error : " << dinv << endl; } else { @@ -119,73 +507,90 @@ void Ali4Vector::Info(TString f) Double_t Ali4Vector::Dot(Ali4Vector& q) { // Provide the dot product of the current vector with vector q - Double_t a[4],b[4]; - Double_t dotpro; + Double_t dotpro=0; + Double_t a0=GetScalar(); + Double_t da0=GetResultError(); + if ((this) == &q) // Check for special case v.Dot(v) + { + Double_t norm=fV.GetNorm(); + Double_t dnorm=fV.GetResultError(); + dotpro=pow(a0,2)-pow(norm,2); + fDresult=sqrt(pow(2.*a0*da0,2)+pow(2.*norm*dnorm,2)); + } + else + { + Double_t b0=q.GetScalar(); + Double_t db0=q.GetResultError(); + Ali3Vector b=q.Get3Vector(); - GetVector(a,"car"); - q.GetVector(b,"car"); + Double_t dot=fV.Dot(b); + Double_t ddot=fV.GetResultError(); - dotpro=a[0]*b[0]; - for (Int_t i=1; i<4; i++) - { - dotpro-=a[i]*b[i]; + dotpro=a0*b0-dot; + + fDresult=sqrt(pow(b0*da0,2)+pow(a0*db0,2)+pow(ddot,2)); } - + return dotpro; } /////////////////////////////////////////////////////////////////////////// Ali4Vector Ali4Vector::operator+(Ali4Vector& q) { -// Add vector q to the current vector - Double_t a[4],b[4]; +// Add 4-vector q to the current 4-vector +// Error propagation is performed automatically + Double_t a0=GetScalar(); + Double_t da0=GetResultError(); + Ali3Vector a=Get3Vector(); + Double_t b0=q.GetScalar(); + Double_t db0=q.GetResultError(); + Ali3Vector b=q.Get3Vector(); - GetVector(a,"car"); - q.GetVector(b,"car"); - - for (Int_t i=0; i<4; i++) - { - a[i]+=b[i]; - } + Double_t c0=a0+b0; + Ali3Vector c=a+b; + Double_t dc0=sqrt(pow(da0,2)+pow(db0,2)); Ali4Vector v; - v.SetVector(a,"car"); - + v.SetVector(c0,c); + v.SetScalarError(dc0); return v; } /////////////////////////////////////////////////////////////////////////// Ali4Vector Ali4Vector::operator-(Ali4Vector& q) { -// Subtract vector q from the current vector - Double_t a[4],b[4]; +// Subtract 4-vector q from the current 4-vector +// Error propagation is performed automatically + Double_t a0=GetScalar(); + Double_t da0=GetResultError(); + Ali3Vector a=Get3Vector(); + Double_t b0=q.GetScalar(); + Double_t db0=q.GetResultError(); + Ali3Vector b=q.Get3Vector(); - GetVector(a,"car"); - q.GetVector(b,"car"); - - for (Int_t i=0; i<4; i++) - { - a[i]-=b[i]; - } + Double_t c0=a0-b0; + Ali3Vector c=a-b; + Double_t dc0=sqrt(pow(da0,2)+pow(db0,2)); Ali4Vector v; - v.SetVector(a,"car"); - + v.SetVector(c0,c); + v.SetScalarError(dc0); return v; } /////////////////////////////////////////////////////////////////////////// Ali4Vector Ali4Vector::operator*(Double_t s) { -// Multiply the current vector with a scalar s - Double_t a[4]; +// Multiply the current 4-vector with a scalar s +// Error propagation is performed automatically + Double_t a0=GetScalar(); + Double_t da0=GetResultError(); + Ali3Vector a=Get3Vector(); - GetVector(a,"car"); - - for (Int_t i=0; i<4; i++) - { - a[i]*=s; - } + a0*=s; + a*=s; + da0*=s; Ali4Vector v; - v.SetVector(a,"car"); + v.SetVector(a0,a); + v.SetScalarError(da0); return v; } @@ -193,6 +598,7 @@ Ali4Vector Ali4Vector::operator*(Double_t s) Ali4Vector Ali4Vector::operator/(Double_t s) { // Divide the current vector by a scalar s +// Error propagation is performed automatically if (fabs(s)<1.e-20) // Protect against division by 0 { @@ -201,17 +607,17 @@ Ali4Vector Ali4Vector::operator/(Double_t s) } else { - Double_t a[4]; - - GetVector(a,"car"); + Double_t a0=GetScalar(); + Double_t da0=GetResultError(); + Ali3Vector a=Get3Vector(); - for (Int_t i=0; i<4; i++) - { - a[i]/=s; - } + a0/=s; + a/=s; + da0/=s; Ali4Vector v; - v.SetVector(a,"car"); + v.SetVector(a0,a); + v.SetScalarError(da0); return v; } @@ -219,80 +625,94 @@ Ali4Vector Ali4Vector::operator/(Double_t s) /////////////////////////////////////////////////////////////////////////// Ali4Vector& Ali4Vector::operator+=(Ali4Vector& q) { -// Add vector q to the current vector - Double_t a[4],b[4]; +// Add 4-vector q to the current 4-vector +// Error propagation is performed automatically + Double_t a0=GetScalar(); + Double_t da0=GetResultError(); + Ali3Vector a=Get3Vector(); + Double_t b0=q.GetScalar(); + Double_t db0=q.GetResultError(); + Ali3Vector b=q.Get3Vector(); - GetVector(a,"car"); - q.GetVector(b,"car"); + Double_t c0=a0+b0; + Ali3Vector c=a+b; + Double_t dc0=sqrt(pow(da0,2)+pow(db0,2)); - for (Int_t i=0; i<4; i++) - { - a[i]+=b[i]; - } - - SetVector(a,"car"); + SetVector(c0,c); + SetScalarError(dc0); return *this; } /////////////////////////////////////////////////////////////////////////// Ali4Vector& Ali4Vector::operator-=(Ali4Vector& q) { -// Subtract vector q from the current vector - Double_t a[4],b[4]; +// Subtract 4-vector q from the current 4-vector +// Error propagation is performed automatically + Double_t a0=GetScalar(); + Double_t da0=GetResultError(); + Ali3Vector a=Get3Vector(); + Double_t b0=q.GetScalar(); + Double_t db0=q.GetResultError(); + Ali3Vector b=q.Get3Vector(); - GetVector(a,"car"); - q.GetVector(b,"car"); + Double_t c0=a0-b0; + Ali3Vector c=a-b; + Double_t dc0=sqrt(pow(da0,2)+pow(db0,2)); - for (Int_t i=0; i<4; i++) - { - a[i]-=b[i]; - } + SetVector(c0,c); + SetScalarError(dc0); - SetVector(a,"car"); - return *this; } /////////////////////////////////////////////////////////////////////////// Ali4Vector& Ali4Vector::operator*=(Double_t s) { -// Multiply the current vector with a scalar s - Double_t a[4]; +// Multiply the current 4-vector with a scalar s +// Error propagation is performed automatically + Double_t a0=GetScalar(); + Double_t da0=GetResultError(); + Ali3Vector a=Get3Vector(); - GetVector(a,"car"); + a0*=s; + a*=s; + da0*=s; - for (Int_t i=0; i<4; i++) - { - a[i]*=s; - } + SetVector(a0,a); + SetScalarError(da0); - SetVector(a,"car"); - return *this; } /////////////////////////////////////////////////////////////////////////// Ali4Vector& Ali4Vector::operator/=(Double_t s) { // Divide the current vector by a scalar s +// Error propagation is performed automatically if (fabs(s)<1.e-20) // Protect against division by 0 { - cout << " *Ali4Vector::/=* Division by 0 detected. No action taken." << endl; + cout << " *Ali4Vector::/* Division by 0 detected. No action taken." << endl; return *this; } else { - Double_t a[4]; + Double_t a0=GetScalar(); + Double_t da0=GetResultError(); + Ali3Vector a=Get3Vector(); - GetVector(a,"car"); + a0/=s; + a/=s; + da0/=s; - for (Int_t i=0; i<4; i++) - { - a[i]/=s; - } - - SetVector(a,"car"); + SetVector(a0,a); + SetScalarError(da0); return *this; } } /////////////////////////////////////////////////////////////////////////// +Int_t Ali4Vector::GetScalarFlag() +{ +// Provide the value of the fScalar flag (for internal use only). + return fScalar; +} +/////////////////////////////////////////////////////////////////////////// diff --git a/RALICE/Ali4Vector.h b/RALICE/Ali4Vector.h index b60ae926a74..9eff7c6f8a3 100644 --- a/RALICE/Ali4Vector.h +++ b/RALICE/Ali4Vector.h @@ -5,64 +5,6 @@ /* $Id$ */ -/////////////////////////////////////////////////////////////////////////// -// Class Ali4Vector -// Handling of Lorentz 4-vectors in various reference frames. -// -// This class is meant to serve as a base class for ALICE objects -// that have Lorentz 4-vector characteristics. -// -// All 4-vectors are treated in the contravariant form and the convention -// for the metric and the 4-vector components is according to the one -// used in the book "Classical Electrodynamics" by J.D. Jackson. -// -// The dotproduct is defined such that p.Dot(p) yields the Lorentz invariant -// scalar of the 4-vector p (i.e. m**2 in case p is a 4-momentum). -// -// Note : -// ------ -// Vectors (v) and reference frames (f) are specified via -// SetVector(Float_t* v,TString f) under the following conventions : -// -// f="car" ==> 3-vector part of v in Cartesian coordinates (x,y,z) -// f="sph" ==> 3-vector part of v in Spherical coordinates (r,theta,phi) -// f="cyl" ==> 3-vector part of v in Cylindrical coordinates (rho,phi,z) -// -// All angles are in radians. -// -// Example : -// --------- -// -// Ali4Vector a; -// -// Float_t v[4]={25,-1,3,7}; -// a.SetVector(v,"car"); -// -// Float_t vec[4]; -// a.GetVector(vec,"sph"); -// -// Ali4Vector b; -// Float_t v2[4]={33,6,-18,2}; -// b.SetVector(v2,"car"); -// -// Float_t dotpro=a.Dot(b); -// -// Float_t x0=16; -// Ali3Vector x; -// Float_t vec2[3]={1,2,3}; -// x.SetVector(vec2,"car"); -// -// Ali4Vector c; -// c.SetVector(x0,x); -// c.GetVector(vec,"car"); -// c.Info("cyl"); -// c=a+b; -// c=a-b; -// c=a*5; -// -//--- NvE 01-apr-1999 UU-SAP Utrecht -/////////////////////////////////////////////////////////////////////////// - #include #include @@ -78,10 +20,23 @@ class Ali4Vector virtual void GetVector(Double_t* v,TString f); // Provide contravariant vector v^i in frame f virtual void SetVector(Float_t* v,TString f); // Store contravariant vector v^i in frame f virtual void GetVector(Float_t* v,TString f); // Provide contravariant vector v^i in frame f + virtual void SetScalar(Double_t v0,Double_t dv0=0); // Set the scalar part (with error) of v + virtual void SetScalarError(Double_t dv0); // Set error on the scalar part of v Double_t GetScalar(); // Provide the scalar part of v + virtual void Set3Vector(Ali3Vector v); // Set the 3-vector part of v + virtual void Set3Vector(Double_t* v,TString f); // Set the 3-vector part of v in frame f + virtual void Set3Vector(Float_t* v,TString f); // Set the 3-vector part of v in frame f Ali3Vector Get3Vector(); // Provide the 3-vector part of v + virtual void SetInvariant(Double_t v2,Double_t dv2=0); // Set the Lorentz invariant (with error) + virtual void SetInvariantError(Double_t dv2); // Set error on the Lorentz invariant + Double_t GetInvariant(); // Provide the Lorentz invariant + virtual void SetErrors(Double_t* v,TString f); // Store errors of vector v^i in frame f + virtual void GetErrors(Double_t* v,TString f); // Provide errors of vector v^i in frame f + virtual void SetErrors(Float_t* v,TString f); // Store errors of vector v^i in frame f + virtual void GetErrors(Float_t* v,TString f); // Provide errors of vector v^i in frame f virtual void Info(TString f="car"); // Print contravariant components in frame f Double_t Dot(Ali4Vector& q); // Provide dot product v^i*q_i + Double_t GetResultError(); // Provide error on scalar result (e.g. Dot) Ali4Vector operator+(Ali4Vector& q); // Add contravariant vector q Ali4Vector operator-(Ali4Vector& q); // Subtract contravariant vector q Ali4Vector operator*(Double_t s); // Multiply contravariant vector with scalar s @@ -90,11 +45,17 @@ class Ali4Vector Ali4Vector& operator-=(Ali4Vector& q); // Subtract contravariant vector q Ali4Vector& operator*=(Double_t s); // Multiply with scalar s Ali4Vector& operator/=(Double_t s); // Divide by scalar s + Int_t GetScalarFlag(); // Provide the fScalar flag value protected: - Double_t fV0; // The scalar part - Ali3Vector fV; // The 3-vector part + Double_t fV2; // The Lorentz invariant (v^i*v_i) + Double_t fV0; // The scalar part + Ali3Vector fV; // The 3-vector part + Double_t fDv2; // The error on the Lorentz invariant + Double_t fDv0; // The error on the scalar part + Double_t fDresult; // The error on the scalar result of an operation (e.g. dotproduct) + Int_t fScalar; // Flag denoting scalar mode - ClassDef(Ali4Vector,1) // Class definition to enable ROOT I/O + ClassDef(Ali4Vector,1) // Handling of Lorentz 4-vectors in various reference frames. }; #endif diff --git a/RALICE/Ali4VectorObj.cxx b/RALICE/Ali4VectorObj.cxx new file mode 100644 index 00000000000..b7fec056be1 --- /dev/null +++ b/RALICE/Ali4VectorObj.cxx @@ -0,0 +1,93 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* +$Log$ +*/ + +/////////////////////////////////////////////////////////////////////////// +// Class Ali4VectorObj +// Handling of Lorentz 4-vectors in various reference frames. +// +// This class is meant to provide an Ali4Vector object which is derived +// from TObject such that it can be stored in e.g. TObjArray etc... +// and that it can be written out using the ROOT I/O machinery. +// +// Example : +// ========= +// +// Float_t a[4]={5,1,2,3}; +// Float_t ea[4]={0.05,0.01,0.02,0.03}; +// Float_t b[4]={10,4,5,6}; +// Float_t eb[4]={0.1,0.04,0.05,0.06}; +// +// Ali4Vector v,w; +// +// v.SetVector(a,"car"); +// v.SetErrors(ea,"car"); +// w.SetVector(b,"car"); +// w.SetErrors(eb,"car"); +// +// Ali4Vector add=v+w; +// +// Ali4Vector sub=v-w; +// +// Ali4VectorObj vec1(add); +// +// Ali4VectorObj vec2; +// vec2.Load(sub); +// +// vec1.Info(); +// vec2.Info(); +// +//--- Author: Nick van Eijndhoven 18-oct-1999 UU-SAP Utrecht +/////////////////////////////////////////////////////////////////////////// + +#include "Ali4VectorObj.h" + +ClassImp(Ali4VectorObj) // Class implementation to enable ROOT I/O + +Ali4VectorObj::Ali4VectorObj() +{ +// Creation of an Ali4VectorObj object and initialisation of parameters. +// All attributes initialised to 0. +} +/////////////////////////////////////////////////////////////////////////// +Ali4VectorObj::Ali4VectorObj(Ali4Vector& q) +{ +// Creation of an Ali3VectorObj object and initialisation of parameters. +// All attributes are initialised to the values of the input Ali3Vector. + Load(q); +} +/////////////////////////////////////////////////////////////////////////// +Ali4VectorObj::~Ali4VectorObj() +{ +// Destructor to delete dynamically allocated memory. +} +/////////////////////////////////////////////////////////////////////////// +void Ali4VectorObj::Load(Ali4Vector& q) +{ +// Load all attributes of the input Ali4Vector into this Ali4VectorObj object. + Int_t temp1=q.GetScalarFlag(); + Double_t temp2=q.GetResultError(); + Double_t a[4]; + q.GetVector(a,"sph"); + SetVector(a,"sph"); + q.GetErrors(a,"car"); + SetErrors(a,"car"); + fScalar=temp1; + fDresult=temp2; +} +/////////////////////////////////////////////////////////////////////////// diff --git a/RALICE/Ali4VectorObj.h b/RALICE/Ali4VectorObj.h new file mode 100644 index 00000000000..6b23953f22a --- /dev/null +++ b/RALICE/Ali4VectorObj.h @@ -0,0 +1,22 @@ +#ifndef ALI4VECTOROBJ_H +#define ALI4VECTOROBJ_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +#include "TObject.h" + +#include "Ali4Vector.h" + +class Ali4VectorObj : public TObject,public Ali4Vector +{ + public: + Ali4VectorObj(); // Default constructor + Ali4VectorObj(Ali4Vector& q); // Constructor + ~Ali4VectorObj(); // Destructor + void Load(Ali4Vector& q); // Load all attributes of input Ali4Vector + + ClassDef(Ali4VectorObj,1) // Handling of Lorentz 4-vectors in various reference frames. +}; +#endif diff --git a/RALICE/AliBoost.cxx b/RALICE/AliBoost.cxx index 670a61c7028..c03a61b8586 100644 --- a/RALICE/AliBoost.cxx +++ b/RALICE/AliBoost.cxx @@ -15,60 +15,106 @@ /* $Log$ +Revision 1.2 1999/09/29 09:24:28 fca +Introduction of the Copyright and cvs Log + */ +/////////////////////////////////////////////////////////////////////////// +// Class AliBoost +// Perform various Lorentz transformations. +// +// Example : +// ========= +// +// Float_t a[3]={0.1,0.2,0.3}; +// Float_t ea[3]={0.01,0.02,0.03}; +// Ali3Vector beta; +// beta.SetVector(a,"car"); +// beta.SetErrors(ea,"car"); +// +// AliBoost b1; +// b1.SetBeta(beta); +// b1.Info(); +// +// Float_t b[4]={14,1,2,3}; +// Float_t eb[4]={1.4,0.1,0.2,0.3}; +// Ali4Vector p; +// p.SetVector(b,"car"); +// p.SetErrors(eb,"car"); +// Ali4Vector pprim=b1.Boost(p); +// p.Info(); +// pprim.Info(); +// +// p=b1.Inverse(pprim); +// pprim.Info(); +// p.Info(); +// +// Float_t c[4]={5,0,0,4}; +// Float_t ec[4]={0.5,0,0,0.4}; +// Ali4Vector q; +// q.SetVector(c,"car"); +// q.SetErrors(ec,"car"); +// +// AliBoost b2; +// b2.Set4Momentum(q); +// b2.Info("sph"); +// +//--- Author: Nick van Eijndhoven 14-may-1996 UU-SAP Utrecht +//- Modified: NvE 24-oct-1999 UU-SAP Utrecht +/////////////////////////////////////////////////////////////////////////// + #include "AliBoost.h" ClassImp(AliBoost) // Class implementation to enable ROOT I/O AliBoost::AliBoost() { -// Creation of a Lorentz boost object and initialisation of parameters - fGamma=1; - fBeta2=0; +// Creation of a Lorentz boost object and initialisation of parameters. +// Beta is set to (0,0,0) and consequently Gamma=1. +// All errors are initialised to 0. Double_t a[3]={0,0,0}; fBeta.SetVector(a,"sph"); + fGamma=1; + fDgamma=0; + fDresult=0; } /////////////////////////////////////////////////////////////////////////// AliBoost::~AliBoost() { -// Default destructor +// Default destructor. } /////////////////////////////////////////////////////////////////////////// void AliBoost::SetBeta(Ali3Vector b) { -// Setting of boost parameters on basis of beta 3-vector - fBeta2=b.Dot(b); +// Setting of boost parameters on basis of beta 3-vector. +// The errors on the beta 3-vector are taken from the input 3-vector. +// The gamma value and its error are calculated accordingly. fBeta=b; + Double_t beta2=fBeta.Dot(fBeta); + Double_t dbeta2=fBeta.GetResultError(); - if (fBeta2 > 1.) + if (beta2 > 1.) { cout << " *AliBoost::SetBeta* beta > 1." << endl; } - Double_t test=1.-fBeta2; fGamma=0; - if (test > 0.) fGamma=sqrt(1./test); -} -/////////////////////////////////////////////////////////////////////////// -void AliBoost::SetGamma(Double_t g,Ali3Vector v) -{ -// Setting of boost parameters on basis of gamma and direction 3-vector - if (g >= 1.) - { - fGamma=g; - fBeta2=1.-(1./(fGamma*fGamma)); - fBeta=v*sqrt(fBeta2); - } - else + fDgamma=0; + Double_t temp=1.-beta2; + if (temp > 0.) { - cout << " *AliBoost::SetGamma* Invalid input gamma = " << g << endl; + fGamma=sqrt(1./temp); + fDgamma=fabs(dbeta2/(2.*pow(temp,1.5))); } } /////////////////////////////////////////////////////////////////////////// void AliBoost::Set4Momentum(Ali4Vector& p) { -// Setting of boost parameters on basis of momentum 4-vector data +// Setting of boost parameters on basis of momentum 4-vector data. +// The errors of the input 4-vector are used to calculate the +// errors on the beta 3-vector and the gamma factor. Double_t E=p.GetScalar(); + Double_t dE=p.GetResultError(); if (E <= 0.) { cout << " *AliBoost::Set4Momentum* Unphysical situation." << endl; @@ -77,57 +123,112 @@ void AliBoost::Set4Momentum(Ali4Vector& p) else { Ali3Vector b=p.Get3Vector(); + Double_t vb[3],eb[3]; + b.GetVector(vb,"car"); + b.GetErrors(eb,"car"); b=b/E; + for (Int_t i=0; i<3; i++) + { + eb[i]=sqrt(pow(eb[i]/E,2)+pow(vb[i]*dE/(E*E),2)); + } + b.SetErrors(eb,"car"); SetBeta(b); } } /////////////////////////////////////////////////////////////////////////// Ali3Vector AliBoost::GetBetaVector() { -// Provide the the beta 3-vector +// Provide the beta 3-vector. return fBeta; } /////////////////////////////////////////////////////////////////////////// Double_t AliBoost::GetBeta() { -// Provide the norm of the beta 3-vector - return sqrt(fBeta2); +// Provide the norm of the beta 3-vector. +// The error on the value can be obtained via GetResultError(). + Double_t norm=fBeta.GetNorm(); + fDresult=fBeta.GetResultError(); + return norm; } /////////////////////////////////////////////////////////////////////////// Double_t AliBoost::GetGamma() { -// Provide the gamma factor +// Provide the gamma factor. +// The error on the value can be obtained via GetResultError(). + fDresult=fDgamma; return fGamma; } /////////////////////////////////////////////////////////////////////////// +Double_t AliBoost::GetResultError() +{ +// Provide the error on the result of an operation yielding a scalar. +// E.g. GetBeta() or GetGamma() + return fDresult; +} +/////////////////////////////////////////////////////////////////////////// void AliBoost::Info(TString f) { -// Printing of the boost parameter info in coordinate frame f - - cout << " *AliBoost::Info* beta = " << sqrt(fBeta2) << " gamma = " << fGamma << endl - << " Beta"; +// Printing of the boost parameter info in coordinate frame f. + Double_t beta=fBeta.GetNorm(); + Double_t dbeta=fBeta.GetResultError(); + cout << " *AliBoost::Info* beta : " << beta << " error : " << dbeta + << " gamma : " << fGamma << " error : " << fDgamma << endl; + cout << " Beta"; fBeta.Info(f); } /////////////////////////////////////////////////////////////////////////// Ali4Vector AliBoost::Boost(Ali4Vector& v) { -// Perform the Lorentz boost on the 4-vector v - if (fBeta2 > 1.e-20) +// Perform the Lorentz boost on the 4-vector v. +// Error propagation is performed automatically. +// Note : As an approximation Beta and p.Dot(Beta) are considered as +// independent quantities. + + Double_t beta=fBeta.GetNorm(); + Double_t dbeta=fBeta.GetResultError(); + + Double_t beta2=pow(beta,2); + + if (beta > 1.e-10) { Double_t E=v.GetScalar(); + Double_t dE=v.GetResultError(); + Ali3Vector p=v.Get3Vector(); + Double_t pdotbeta=p.Dot(fBeta); + Double_t dpdotbeta=p.GetResultError(); + + // Determine the new vector components + Double_t Eprim=fGamma*(E-pdotbeta); + + Double_t z=((fGamma-1.)*pdotbeta/beta2)-fGamma*E; + Ali3Vector add=fBeta*z; + + // Determine errors on the new vector components + Double_t dEprim=sqrt(pow((E-pdotbeta)*fDgamma,2)+pow(fGamma*dE,2) + +pow(fGamma*dpdotbeta,2)); + Double_t dz=sqrt( pow(((fGamma-1.)/beta2)*dpdotbeta,2) + pow(fGamma*dE,2) + +pow(( + ((2./beta)-(4.*pow(beta,3)-6.*pow(beta,5))/(2.*pow((pow(beta,4)-pow(beta,6)),1.5)))*pdotbeta + +beta*E/pow(fGamma,3))*dbeta,2) ); - Double_t Eprim; - Eprim=fGamma*(E-pdotbeta); + Double_t vb[3],eb[3]; + fBeta.GetVector(vb,"car"); + fBeta.GetErrors(eb,"car"); + for (Int_t i=0; i<3; i++) + { + eb[i]=sqrt(pow(z*eb[i],2)+pow(vb[i]*dz,2)); + } + add.SetErrors(eb,"car"); - Ali3Vector term1,term2,pprim; - term1=fBeta*((fGamma-1.)*pdotbeta/fBeta2); - term2=fBeta*(fGamma*E); - pprim=p+term1-term2; + // Calculate the new 3-vector + Ali3Vector pprim=p+add; + // Set the components and errors of the new 4-vector Ali4Vector w; w.SetVector(Eprim,pprim); + w.SetScalarError(dEprim); return w; } @@ -139,23 +240,56 @@ Ali4Vector AliBoost::Boost(Ali4Vector& v) /////////////////////////////////////////////////////////////////////////// Ali4Vector AliBoost::Inverse(Ali4Vector& vprim) { -// Perform the inverse Lorentz boost on the 4-vector vprim - if (fBeta2 > 1.e-20) +// Perform the inverse Lorentz boost on the 4-vector vprim. +// Error propagation is performed automatically. +// Note : As an approximation Beta and pprim.Dot(Beta) are considered as +// independent quantities. + + Double_t beta=fBeta.GetNorm(); + Double_t dbeta=fBeta.GetResultError(); + + Double_t beta2=pow(beta,2); + + if (beta > 1.e-10) { Double_t Eprim=vprim.GetScalar(); + Double_t dEprim=vprim.GetResultError(); + Ali3Vector pprim=vprim.Get3Vector(); + Double_t pprimdotbeta=pprim.Dot(fBeta); + Double_t dpprimdotbeta=pprim.GetResultError(); + + // Determine the new vector components + Double_t E=fGamma*(Eprim+pprimdotbeta); + + Double_t z=((fGamma-1.)*pprimdotbeta/beta2)+fGamma*Eprim; + Ali3Vector add=fBeta*z; + + // Determine errors on the prime-vector components + Double_t dE=sqrt(pow((Eprim+pprimdotbeta)*fDgamma,2)+pow(fGamma*dEprim,2) + +pow(fGamma*dpprimdotbeta,2)); + Double_t dz=sqrt( pow(((fGamma-1.)/beta2)*dpprimdotbeta,2) + pow(fGamma*dEprim,2) + +pow(( + ((2./beta)-(4.*pow(beta,3)-6.*pow(beta,5))/(2.*pow((pow(beta,4)-pow(beta,6)),1.5)))*pprimdotbeta + -beta*Eprim/pow(fGamma,3))*dbeta,2) ); - Double_t E; - E=fGamma*(Eprim+pprimdotbeta); + Double_t vb[3],eb[3]; + fBeta.GetVector(vb,"car"); + fBeta.GetErrors(eb,"car"); + for (Int_t i=0; i<3; i++) + { + eb[i]=sqrt(pow(z*eb[i],2)+pow(vb[i]*dz,2)); + } + add.SetErrors(eb,"car"); - Ali3Vector term1,term2,p; - term1=fBeta*((fGamma-1.)*pprimdotbeta/fBeta2); - term2=fBeta*(fGamma*Eprim); - p=pprim+term1+term2; + // Calculate the new 3-vector + Ali3Vector p=pprim+add; + // Set the components and errors of the new 4-vector Ali4Vector w; w.SetVector(E,p); + w.SetScalarError(dE); return w; } diff --git a/RALICE/AliBoost.h b/RALICE/AliBoost.h index cd16e00b049..83b7bda88c3 100644 --- a/RALICE/AliBoost.h +++ b/RALICE/AliBoost.h @@ -5,48 +5,6 @@ /* $Id$ */ -/////////////////////////////////////////////////////////////////////////// -// Class AliBoost -// Perform various Lorentz transformations. -// -// Example : -// ========= -// -// Float_t a[3]={0.1,0.2,0.3}; -// Ali3Vector beta; -// beta.SetVector(a,"car"); -// -// AliBoost b1; -// b1.SetBeta(beta); -// cout << " Boost b1 :" << endl; -// b1.Info(); -// -// Float_t b[4]={14,1,2,3}; -// Ali4Vector p; -// p.SetVector(b,"car"); -// Ali4Vector pprim=b1.Boost(p); -// cout << " Boost b1 result p,pprim :" << endl; -// p.Info(); -// pprim.Info(); -// -// p=b1.Inverse(pprim); -// cout << " Inverse b1 result pprim,p :" << endl; -// pprim.Info(); -// p.Info(); -// -// Float_t c[4]={5,0,0,4}; -// Ali4Vector q; -// q.SetVector(c,"car"); -// -// AliBoost b2; -// b2.Set4Momentum(q); -// cout << " Lorbo b2 : " << endl; -// b2.Info("sph"); -// -//--- NvE 14-may-1996 UU-SAP Utrecht -//--- Modified : NvE 01-apr-1999 UU-SAP Utrecht using Ali3Vector/Ali4Vector -/////////////////////////////////////////////////////////////////////////// - #include #include @@ -60,7 +18,6 @@ class AliBoost : public TObject AliBoost(); // Default constructor ~AliBoost(); // Default destructor void SetBeta(Ali3Vector b); // Set boost parameters by beta 3-vector - void SetGamma(Double_t g,Ali3Vector v); // Set boost parameters by gamma and direction 3-vector void Set4Momentum(Ali4Vector& p); // Set boost parameters by 4-momentum Ali3Vector GetBetaVector(); // Provide the beta 3-vector Double_t GetBeta(); // Provide norm of beta 3-vector @@ -68,12 +25,14 @@ class AliBoost : public TObject void Info(TString f="car"); // Print boost parameter info in coord. frame f Ali4Vector Boost(Ali4Vector& v); // Perform Lorentz boost on 4-vector v Ali4Vector Inverse(Ali4Vector& v); // Perform inverse Lorentz boost on 4-vector v + Double_t GetResultError(); // Provide error on scalar result protected: - Ali3Vector fBeta; // The beta 3-vector - Double_t fBeta2; // beta**2 - Double_t fGamma; // The gamma factor + Ali3Vector fBeta; // The beta 3-vector + Double_t fGamma; // The gamma factor + Double_t fDgamma; // Error on the gamma value + Double_t fDresult; // Error on scalar result - ClassDef(AliBoost,1) // Class definition to enable ROOT I/O + ClassDef(AliBoost,1) // Perform various Lorentz transformations. }; #endif diff --git a/RALICE/AliCalcluster.cxx b/RALICE/AliCalcluster.cxx index 31362affbdf..afe3770ef72 100644 --- a/RALICE/AliCalcluster.cxx +++ b/RALICE/AliCalcluster.cxx @@ -15,8 +15,24 @@ /* $Log$ +Revision 1.2 1999/09/29 09:24:28 fca +Introduction of the Copyright and cvs Log + */ +/////////////////////////////////////////////////////////////////////////// +// Class AliCalcluster +// Description of a cluster of calorimeter modules. +// A matrix geometry is assumed in which a cluster center +// is identified by (row,col) and contains sig as signal +// being the signal of the complete cluster. +// Some info about cluster topology is provided in order +// to enable EM or hadronic cluster identification. +// +//--- Author: Nick van Eijndhoven 13-jun-1997 UU-SAP Utrecht +//- Modified: NvE 31-oct-1999 UU-SAP Utrecht +/////////////////////////////////////////////////////////////////////////// + #include "AliCalcluster.h" ClassImp(AliCalcluster) // Class implementation to enable ROOT I/O @@ -174,14 +190,14 @@ Float_t AliCalcluster::GetColumnDispersion() /////////////////////////////////////////////////////////////////////////// void AliCalcluster::Start(AliCalmodule& m) { -// Reset cluster data and start with module m +// Reset cluster data and start with module m. // A module can only start a cluster when it contains -// a signal, has not been used in a cluster yet and is not -// situated at a detector edge +// a signal, has not been used in a cluster yet, is not +// situated at a detector edge and is not declared dead. Float_t pos[3]={0,0,0}; - if ((m.GetClusteredSignal() > 0.) && (m.GetEdgeValue() == 0)) + if (m.GetClusteredSignal()>0. && m.GetEdgeValue()==0 && m.GetDeadValue()==0) { fCenter=&m; m.GetPosition(pos,"sph"); @@ -231,7 +247,9 @@ void AliCalcluster::Add(AliCalmodule& m) /////////////////////////////////////////////////////////////////////////// void AliCalcluster::AddVetoSignal(Float_t* r,TString f,Float_t s) { -// Associate an (extrapolated) AliSignal at location r as veto to the cluster +// Associate an (extrapolated) AliSignal at location r as veto to the cluster. +// The signal value s indicates the confidence level of hit association +// and has to be provided by the user. // Note : The default signal value (s) is 0 if (!fVetos) { @@ -239,7 +257,7 @@ void AliCalcluster::AddVetoSignal(Float_t* r,TString f,Float_t s) fVetos=new TObjArray(); } - fVetos->Add(new AliSignal); + fVetos->Add(new AliSignal(1)); fNvetos++; ((AliSignal*)fVetos->At(fNvetos-1))->SetPosition(r,f); @@ -254,8 +272,8 @@ Int_t AliCalcluster::GetNvetos() /////////////////////////////////////////////////////////////////////////// AliSignal* AliCalcluster::GetVetoSignal(Int_t i) { -// Provide access to the i-th veto signal of this cluster -// Note : The first hit corresponds to i=1 +// Provide access to the i-th veto signal of this cluster. +// Note : The first hit corresponds to i=1. if (i>0 && i<=fNvetos) { @@ -270,3 +288,34 @@ AliSignal* AliCalcluster::GetVetoSignal(Int_t i) } } /////////////////////////////////////////////////////////////////////////// +Float_t AliCalcluster::GetVetoLevel() +{ +// Provide the confidence level of best associated veto signal. + Float_t cl=0; + Float_t clmax=0; + if (fVetos) + { + for (Int_t i=0; iAt(i))->GetSignal(); + if (cl>clmax) clmax=cl; + } + } + return clmax; +} +/////////////////////////////////////////////////////////////////////////// +Int_t AliCalcluster::HasVetoHit(Double_t cl) +{ +// Investigate if cluster has an associated veto hit with conf. level > cl. +// Returns 1 if there is such an associated veto hit, otherwise returns 0. +// Note : This function is faster than GetVetoLevel(). + if (fVetos) + { + for (Int_t i=0; iAt(i))->GetSignal() > cl) return 1; + } + } + return 0; +} +/////////////////////////////////////////////////////////////////////////// diff --git a/RALICE/AliCalcluster.h b/RALICE/AliCalcluster.h index 42004e4cca8..24bd3497de7 100644 --- a/RALICE/AliCalcluster.h +++ b/RALICE/AliCalcluster.h @@ -5,18 +5,6 @@ /* $Id$ */ -/////////////////////////////////////////////////////////////////////////// -// Class AliCalcluster -// Description of a cluster of calorimeter modules. -// A matrix geometry is assumed in which a cluster center -// is identified by (row,col) and contains sig as signal -// being the signal of the complete cluster. -// Some info about cluster topology is provided in order -// to enable EM or hadronic cluster identification -// -//--- NvE 13-jun-1997 UU-SAP Utrecht -/////////////////////////////////////////////////////////////////////////// - #include #include @@ -43,6 +31,8 @@ class AliCalcluster : public TObject,public AliPosition void AddVetoSignal(Float_t* r,TString f,Float_t s=0); // Associate (extrapolated) signal AliSignal* GetVetoSignal(Int_t j); // Access to veto signal number j Int_t GetNvetos(); // Provide the number of veto signals + Float_t GetVetoLevel(); // Provide confidence level of best associated veto hit + Int_t HasVetoHit(Double_t cl); // Check for ass. veto hit with conf. level > cl protected: AliCalmodule* fCenter; // Pointer to the central module of the cluster @@ -56,6 +46,6 @@ class AliCalcluster : public TObject,public AliPosition Int_t fNvetos; // The number of associated veto signals TObjArray* fVetos; // The array of associated veto signals - ClassDef(AliCalcluster,1) // Class definition to enable ROOT I/O + ClassDef(AliCalcluster,1) // Description of a cluster of calorimeter modules. }; #endif diff --git a/RALICE/AliCalmodule.cxx b/RALICE/AliCalmodule.cxx index 8eff3e8892f..12fd89222e4 100644 --- a/RALICE/AliCalmodule.cxx +++ b/RALICE/AliCalmodule.cxx @@ -15,8 +15,22 @@ /* $Log$ +Revision 1.2 1999/09/29 09:24:28 fca +Introduction of the Copyright and cvs Log + */ +/////////////////////////////////////////////////////////////////////////// +// Class AliCalmodule +// Description of a module in a calorimeter system. +// A matrix geometry is assumed, such that a module +// is identified by (row,col) and contains a certain signal. +// Note : row and col start counting at 1. +// +//--- Author: Nick van Eijndhoven 13-jun-1997 UU-SAP Utrecht +//- Modified: NvE 31-oct-1999 UU-SAP Utrecht +/////////////////////////////////////////////////////////////////////////// + #include "AliCalmodule.h" ClassImp(AliCalmodule) // Class implementation to enable ROOT I/O @@ -42,7 +56,7 @@ AliCalmodule::AliCalmodule(Int_t row,Int_t col,Float_t sig) // Module constructor with initialisation of module data fRow=row; fCol=col; - fSignal=sig; + AliSignal::SetSignal(sig); fSigc=sig; fEdge=0; fDead=0; @@ -66,7 +80,7 @@ void AliCalmodule::SetSignal(Int_t row,Int_t col,Float_t sig) // Set or change the data of the module fRow=row; fCol=col; - fSignal=sig; + AliSignal::SetSignal(sig); fSigc=sig; } /////////////////////////////////////////////////////////////////////////// @@ -75,7 +89,7 @@ void AliCalmodule::AddSignal(Int_t row,Int_t col,Float_t sig) // Add or change the data of the module fRow=row; fCol=col; - fSignal+=sig; + AliSignal::AddSignal(sig); fSigc+=sig; } /////////////////////////////////////////////////////////////////////////// @@ -141,19 +155,6 @@ Int_t AliCalmodule::GetColumn() return fCol; } /////////////////////////////////////////////////////////////////////////// -Float_t AliCalmodule::GetSignal() -{ -// Provide the signal value of the module - if (!fDead) - { - return fSignal; - } - else - { - return 0; - } -} -/////////////////////////////////////////////////////////////////////////// Float_t AliCalmodule::GetClusteredSignal() { // Provide the signal of the module after clustering diff --git a/RALICE/AliCalmodule.h b/RALICE/AliCalmodule.h index e756044000f..28780fdd640 100644 --- a/RALICE/AliCalmodule.h +++ b/RALICE/AliCalmodule.h @@ -5,16 +5,6 @@ /* $Id$ */ -/////////////////////////////////////////////////////////////////////////// -// Class AliCalmodule -// Description of a module in a calorimeter system. -// A matrix geometry is assumed, such that a module -// is identified by (row,col) and contains a certain signal -// Note : row and col start counting at 1 -// -//--- NvE 13-jun-1997 UU-SAP Utrecht -/////////////////////////////////////////////////////////////////////////// - #include #include "AliSignal.h" @@ -31,7 +21,6 @@ class AliCalmodule : public AliSignal void SetColumn(Int_t i); // Set the column number of the module Int_t GetRow(); // Return the row number of the module Int_t GetColumn(); // Return the column number of the module - Float_t GetSignal(); // Return the signal value of the module void SetClusteredSignal(Float_t val); // Set the signal of the module after clustering Float_t GetClusteredSignal(); // Return module signal after clustering void SetEdgeOn(); // Set flag to indicate modules at edges @@ -53,6 +42,6 @@ class AliCalmodule : public AliSignal Int_t fDead; // Flag to indicate dead module (1=dead 0=alive) Float_t fGain; // Gain of the module's readout system - ClassDef(AliCalmodule,1) // Class definition to enable ROOT I/O + ClassDef(AliCalmodule,1) // Description of a module in a calorimeter system. }; #endif diff --git a/RALICE/AliCalorimeter.cxx b/RALICE/AliCalorimeter.cxx index 0d31dd9192f..0744218feff 100644 --- a/RALICE/AliCalorimeter.cxx +++ b/RALICE/AliCalorimeter.cxx @@ -15,10 +15,49 @@ /* $Log$ +Revision 1.2 1999/09/29 09:24:28 fca +Introduction of the Copyright and cvs Log + */ +/////////////////////////////////////////////////////////////////////////// +// Class AliCalorimeter +// Description of a modular calorimeter system. +// A matrix geometry is used in which a module is identified by (row,col). +// Note : First module is identified as (1,1). +// +// This is the way to define and enter signals into a calorimeter : +// +// AliCalorimeter cal(10,15); // Calorimeter of 10x15 modules +// // All module signals set to 0. +// cal.AddSignal(5,7,85.4); +// cal.AddSignal(5,7,25.9); +// cal.AddSignal(3,5,1000); +// cal.SetSignal(5,7,10.3); +// cal.Reset(3,5); // Reset module (3,5) as being 'not fired' +// // All module data are re-initialised. +// cal.SetEdgeOn(1,1); // Declare module (1,1) as an 'edge module' +// cal.SetDead(8,3); +// cal.SetGain(2,8,3.2); +// +// Float_t vec[3]={6,1,20}; +// cal.SetPosition(2,8,vec,"car"); +// +// Float_t loc[3]={-1,12,3}; +// cal.AddVetoSignal(loc,"car"); // Associate (extrapolated) position as a veto +// +// cal.Group(2); // Group 'fired' modules into clusters +// // Perform grouping over 2 rings around the center +// cal.Reset(); // Reset the complete calorimeter +// // Normally to prepare for the next event data +// // Note : Module gain, edge and dead flags remain +// +//--- Author: Nick van Eijndhoven 13-jun-1997 UU-SAP Utrecht +//- Modified: NvE 31-oct-1999 UU-SAP Utrecht +/////////////////////////////////////////////////////////////////////////// + #include "AliCalorimeter.h" - + ClassImp(AliCalorimeter) // Class implementation to enable ROOT I/O AliCalorimeter::AliCalorimeter() @@ -170,8 +209,12 @@ void AliCalorimeter::Reset(Int_t row, Int_t col) if (row>0 && row<=fNrows && col>0 && col<=fNcolumns) { fMatrix[row-1][col-1].SetSignal(row,col,0); - fNsignals--; - fModules->Remove(&(fMatrix[row-1][col-1])); + AliCalmodule* m=(AliCalmodule*)fModules->Remove(&(fMatrix[row-1][col-1])); + if (m) + { + fNsignals--; + fModules->Compress(); + } } else { @@ -218,13 +261,17 @@ void AliCalorimeter::Reset() /////////////////////////////////////////////////////////////////////////// Float_t AliCalorimeter::GetSignal(Int_t row, Int_t col) { -// Provide the signal of a certain calorimeter module +// Provide the signal of a certain calorimeter module. +// In case the module was marked dead, 0 is returned. if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input if (row>0 && row<=fNrows && col>0 && col<=fNcolumns) { - return fMatrix[row-1][col-1].GetSignal(); + Int_t dead=fMatrix[row-1][col-1].GetDeadValue(); + Float_t signal=0; + if (!dead) signal=fMatrix[row-1][col-1].GetSignal(); + return signal; } else { @@ -501,8 +548,9 @@ void AliCalorimeter::Group(Int_t n) if (fNclusters > 0) Ungroup(); // Restore unclustered situation if needed // Order the modules with decreasing signal - AliCalmodule* ordered=new AliCalmodule[fNsignals]; // temp. array for ordered modules - Sortm(ordered); + AliCalmodule** ordered=new AliCalmodule*[fNsignals]; // temp. array for ordered modules + Int_t nord=0; + Sortm(ordered,nord); // Clustering of modules. Start with the highest signal. if (fClusters) @@ -516,10 +564,10 @@ void AliCalorimeter::Group(Int_t n) Int_t row=0; Int_t col=0; AliCalcluster* c=0; - for (Int_t i=0; iGetRow(); // row number of cluster center + col=ordered[i]->GetColumn(); // column number of cluster center if (row>0 && row<=fNrows && col>0 && col<=fNcolumns) { // only use modules not yet used in a cluster @@ -543,25 +591,32 @@ void AliCalorimeter::Group(Int_t n) } // Delete the temp. array - delete [] ordered; + if (ordered) + { + for (Int_t j=0; jGetSignal()) continue; nord++; - for (Int_t k=nord-1; k>j; k--) {ordered[k]=ordered[k-1];} // create empty position - ordered[j]=fMatrix[i][ii]; // put module at empty position + for (Int_t k=nord-1; k>j; k--) // create empty position + { + ordered[k]=ordered[k-1]; + } + ordered[j]=&(fMatrix[i][ii]); // put module at empty position break; // go for next matrix module } } @@ -605,7 +663,7 @@ void AliCalorimeter::AddRing(Int_t row, Int_t col, Int_t n) for (Int_t j=lcol; j<=ucol; j++) { // add module(i,j) to cluster if the signal <= signal(row,col) - if (fMatrix[i-1][j-1].GetSignal() <= signal) + if (GetSignal(i,j) <= signal) { ((AliCalcluster*)fClusters->At(fNclusters-1))->Add(fMatrix[i-1][j-1]); } @@ -655,6 +713,25 @@ AliCalmodule* AliCalorimeter::GetModule(Int_t j) } } /////////////////////////////////////////////////////////////////////////// +AliCalmodule* AliCalorimeter::GetModule(Int_t row,Int_t col) +{ +// Provide access to module (row,col). +// Note : first module is at (1,1). + + if (!fMatrix) LoadMatrix(); // Restore matrix data in case of reading input + + if (row>=1 && row<=fNrows && col>=1 && col<=fNcolumns) + { + return &(fMatrix[row-1][col-1]); + } + else + { + cout << " *AliCalorimeter::GetModule* row,col : " << row << ", " << col + << " out of range." << endl; + return 0; + } +} +/////////////////////////////////////////////////////////////////////////// TH2F* AliCalorimeter::DrawModules() { // Provide a lego plot of the module signals @@ -673,6 +750,7 @@ TH2F* AliCalorimeter::DrawModules() AliCalmodule* m; Float_t row,col,signal; + Int_t dead; for (Int_t i=0; iAt(i); @@ -680,7 +758,9 @@ TH2F* AliCalorimeter::DrawModules() { row=float(m->GetRow()); col=float(m->GetColumn()); - signal=m->GetSignal(); + dead=m->GetDeadValue(); + signal=0; + if (!dead) signal=m->GetSignal(); if (signal>0.) fHmodules->Fill(col,row,signal); } } @@ -726,7 +806,7 @@ TH2F* AliCalorimeter::DrawClusters() void AliCalorimeter::LoadMatrix() { // Load the Calorimeter module matrix data back from the TObjArray - + // Create the module matrix space if (fMatrix) { @@ -743,17 +823,23 @@ void AliCalorimeter::LoadMatrix() } // Copy the module data back into the matrix - AliCalmodule* m; - Int_t row; - Int_t col; - for (Int_t j=0; jGetSize(); + for (Int_t j=0; jAt(j); - row=m->GetRow(); - col=m->GetColumn(); - fMatrix[row-1][col-1]=*m; - fModules->AddAt(&(fMatrix[row-1][col-1]),j); // Store new pointer + if (m) + { + row=m->GetRow(); + col=m->GetColumn(); + fMatrix[row-1][col-1]=*m; + fModules->AddAt(&(fMatrix[row-1][col-1]),j); // Store new pointer + } } + } /////////////////////////////////////////////////////////////////////////// void AliCalorimeter::Ungroup() diff --git a/RALICE/AliCalorimeter.h b/RALICE/AliCalorimeter.h index f7abedd640e..3e66c4bba9e 100644 --- a/RALICE/AliCalorimeter.h +++ b/RALICE/AliCalorimeter.h @@ -5,41 +5,6 @@ /* $Id$ */ -/////////////////////////////////////////////////////////////////////////// -// Class AliCalorimeter -// Description of a modular calorimeter system. -// A matrix geometry is used in which a module is identified by (row,col). -// Note : First module is identified as (1,1). -// -// This is the way to define and enter signals into a calorimeter : -// -// AliCalorimeter cal(10,15); // Calorimeter of 10x15 modules -// // All module signals set to 0. -// cal.AddSignal(5,7,85.4); -// cal.AddSignal(5,7,25.9); -// cal.AddSignal(3,5,1000); -// cal.SetSignal(5,7,10.3); -// cal.Reset(3,5); // Reset module (3,5) as being 'not fired' -// // All module data are re-initialised. -// cal.SetEdgeOn(1,1); // Declare module (1,1) as an 'edge module' -// cal.SetDead(8,3); -// cal.SetGain(2,8,3.2); -// -// Float_t vec[3]={6,1,20}; -// cal.SetPosition(2,8,vec,"car"); -// -// Float_t loc[3]={-1,12,3}; -// cal.AddVetoSignal(loc,"car"); // Associate (extrapolated) position as a veto -// -// cal.Group(2); // Group 'fired' modules into clusters -// // Perform grouping over 2 rings around the center -// cal.Reset(); // Reset the complete calorimeter -// // Normally to prepare for the next event data -// // Note : Module gain, edge and dead flags remain -// -//--- NvE 13-jun-1997 UU-SAP Utrecht -/////////////////////////////////////////////////////////////////////////// - #include #include @@ -47,14 +12,12 @@ #include "TObjArray.h" #include "TH2.h" #include "TString.h" - -#include "AliDetector.h" - + #include "AliCalmodule.h" #include "AliCalcluster.h" #include "AliSignal.h" -class AliCalorimeter : public AliDetector +class AliCalorimeter : public TObject { public: AliCalorimeter(); // Default constructor @@ -73,6 +36,7 @@ class AliCalorimeter : public AliDetector Float_t GetClusteredSignal(Int_t row,Int_t col); // Provide module signal after clustering AliCalcluster* GetCluster(Int_t j); // Access to cluster number j AliCalmodule* GetModule(Int_t j); // Access to 'fired' module number j + AliCalmodule* GetModule(Int_t row,Int_t col); // Access to module at (row,col) void SetEdgeOn(Int_t row,Int_t col); // Indicate module as 'edge module' void SetEdgeOff(Int_t row,Int_t col); // Indicate module as 'non-edge module' Int_t GetEdgeValue(Int_t row,Int_t col); // Provide the edge flag of a module @@ -95,7 +59,7 @@ class AliCalorimeter : public AliDetector Int_t fNsignals; // The number of modules with a signal Int_t fNclusters; // The number of clusters AliCalmodule** fMatrix; //! The matrix of modules for internal use - void Sortm(AliCalmodule*); // Order the modules with decreasing signal + void Sortm(AliCalmodule** a,Int_t& n); // Order the modules with decreasing signal TObjArray* fClusters; // The array of clusters void AddRing(Int_t row,Int_t col,Int_t n); // add signals of n rings around cluster center TObjArray* fModules; // The array of modules for output @@ -106,6 +70,6 @@ class AliCalorimeter : public AliDetector Int_t fNvetos; // The number of associated veto signals TObjArray* fVetos; // The array of associated (extrapolated) veto signals - ClassDef(AliCalorimeter,1) // Class definition to enable ROOT I/O + ClassDef(AliCalorimeter,1) // Description of a modular calorimeter system. }; #endif diff --git a/RALICE/AliInvmass.cxx b/RALICE/AliInvmass.cxx index c782b885177..a54c867e316 100644 --- a/RALICE/AliInvmass.cxx +++ b/RALICE/AliInvmass.cxx @@ -15,8 +15,97 @@ /* $Log$ +Revision 1.2 1999/09/29 09:24:28 fca +Introduction of the Copyright and cvs Log + */ +//////////////////////////////////////////////////////////////////////////////// +// Class AliInvmass +// Construction of invariant mass and combinatorial background. +// +// Example : +// --------- +// +// TObjArray* photons=new TObjArray(); // Array with photon tracks for pi0 rec. +// +// // Code to create some photon tracks from pi0 decays +// Int_t ntracks=200; +// for (Int_t i=0; iAdd(new Alitrack); +// ... +// ... +// ... +// } +// +// // Perform the invariant mass and comb. bkg. reconstruction +// +// TObjArray* allm=q.Invmass(photons,photons); // All reconstructed invariant masses +// +// TH1F* hall=new TH1F("hall","hall",200,0,2); // Histo with M_inv of all combinations +// +// Int_t nall=0; +// if (allm) nall=allm->GetEntries(); +// +// AliTrack* t; +// Float_t minv; +// for (Int_t j=0; jAt(j); +// if (t) +// { +// minv=t->GetMass(); +// hall->Fill(minv); +// } +// } +// +// TObjArray* bkgm=q.CombBkg(photons,photons); // Reconstructed comb. background +// +// TH1F* hbkg=new TH1F("hbkg","hbkg",200,0,2); // Histo with M_inv. of comb. background +// +// Int_t nbkg=0; +// if (bkgm) nbkg=bkgm->GetEntries(); +// +// for (Int_t j=0; jAt(j); +// if (t) +// { +// minv=t->GetMass(); +// hbkg->Fill(minv); +// } +// } +// +// TH1F* hsig=new TH1F("sig","sig",200,0,2); // Histo with the bkg. subtracted signal +// hsig->Sumw2(); +// hsig->Add(hall,hbkg,1,-1); +// +// +// Note : By default the storage of the reconstructed information is performed +// in separate TObjArrays for the signal and comb. background resp. +// In order to limit the memory usage, AliInvmass::SetStorageMode(1) may be +// used to activate only a single TObjArray to store the reconstructed information. +// Consequently, the following statements +// +// TObjArray* allm=q.Invmass(photons,photons); +// TObjArray* bkgm=q.CombBkg(photons,photons); +// +// will result in the fact that after he invokation of CombBkg +// the information of "allm" is lost due to the fact that the storage is +// is re-used for "bkgm" in case the "single storage" option has been selected. +// Usage of the, in that case invalid, pointer "allm" may cause your +// program to crash. +// +// * Thus : In case of single storage usage, all invokations of the returned +// array pointer have to be completed before invoking any memberfunction +// of the same AliInvmass object again. +// +// +// +//--- Author: Nick van Eijndhoven 12-apr-1999 UU-SAP Utrecht +//////////////////////////////////////////////////////////////////////////////// + #include "AliInvmass.h" ClassImp(AliInvmass) // Class implementation to enable ROOT I/O diff --git a/RALICE/AliInvmass.h b/RALICE/AliInvmass.h index 08140bc017d..b069219c137 100644 --- a/RALICE/AliInvmass.h +++ b/RALICE/AliInvmass.h @@ -5,92 +5,6 @@ /* $Id$ */ -//////////////////////////////////////////////////////////////////////////////// -// Class AliInvmass -// Construction of invariant mass and combinatorial background. -// -// Example : -// --------- -// -// TObjArray* photons=new TObjArray(); // Array with photon tracks for pi0 rec. -// -// // Code to create some photon tracks from pi0 decays -// Int_t ntracks=200; -// for (Int_t i=0; iAdd(new Alitrack); -// ... -// ... -// ... -// } -// -// // Perform the invariant mass and comb. bkg. reconstruction -// -// TObjArray* allm=q.Invmass(photons,photons); // All reconstructed invariant masses -// -// TH1F* hall=new TH1F("hall","hall",200,0,2); // Histo with M_inv of all combinations -// -// Int_t nall=0; -// if (allm) nall=allm->GetEntries(); -// -// AliTrack* t; -// Float_t minv; -// for (Int_t j=0; jAt(j); -// if (t) -// { -// minv=t->GetMass(); -// hall->Fill(minv); -// } -// } -// -// TObjArray* bkgm=q.CombBkg(photons,photons); // Reconstructed comb. background -// -// TH1F* hbkg=new TH1F("hbkg","hbkg",200,0,2); // Histo with M_inv. of comb. background -// -// Int_t nbkg=0; -// if (bkgm) nbkg=bkgm->GetEntries(); -// -// for (Int_t j=0; jAt(j); -// if (t) -// { -// minv=t->GetMass(); -// hbkg->Fill(minv); -// } -// } -// -// TH1F* hsig=new TH1F("sig","sig",200,0,2); // Histo with the bkg. subtracted signal -// hsig->Sumw2(); -// hsig->Add(hall,hbkg,1,-1); -// -// -// Note : By default the storage of the reconstructed information is performed -// in separate TObjArrays for the signal and comb. background resp. -// In order to limit the memory usage, AliInvmass::SetStorageMode(1) may be -// used to activate only a single TObjArray to store the reconstructed information. -// Consequently, the following statements -// -// TObjArray* allm=q.Invmass(photons,photons); -// TObjArray* bkgm=q.CombBkg(photons,photons); -// -// will result in the fact that after he invokation of CombBkg -// the information of "allm" is lost due to the fact that the storage is -// is re-used for "bkgm" in case the "single storage" option has been selected. -// Usage of the, in that case invalid, pointer "allm" may cause your -// program to crash. -// -// * Thus : In case of single storage usage, all invokations of the returned -// array pointer have to be completed before invoking any memberfunction -// of the same AliInvmass object again. -// -// -// -//--- NvE 12-apr-1999 UU-SAP Utrecht -//////////////////////////////////////////////////////////////////////////////// - #include #include @@ -127,6 +41,6 @@ class AliInvmass : public TObject private: void Combine(TObjArray* a1,TObjArray* a2); // Make two-particle combinations - ClassDef(AliInvmass,1) // Class definition to enable ROOT I/O + ClassDef(AliInvmass,1) // Construction of invariant mass and combinatorial background. }; #endif diff --git a/RALICE/AliJet.cxx b/RALICE/AliJet.cxx index 0419e56b3f3..8d0f17080e2 100644 --- a/RALICE/AliJet.cxx +++ b/RALICE/AliJet.cxx @@ -15,8 +15,48 @@ /* $Log$ +Revision 1.2 1999/09/29 09:24:28 fca +Introduction of the Copyright and cvs Log + */ +/////////////////////////////////////////////////////////////////////////// +// Class AliJet +// Creation and investigation of a jet of particle tracks. +// An AliJet can be constructed by adding AliTracks. +// +// Coding example to make 2 jets j1 and j2. +// ---------------------------------------- +// j1 contains the AliTracks 1 and 2 +// j2 contains the AliTracks 3 and 4 +// +// AliTrack t1,t2,t3,t4; +// ... +// ... // code to fill the AliTrack data +// ... +// AliJet j1(5); +// AliJet j2(12); +// j1.Add(t1); +// j1.Add(t2); +// j2.Add(t3); +// j2.Add(t4); +// +// j1.Info(); +// j2.Info("sph"); +// +// Float_t e1=j1.GetEnergy(); +// Float_t pnorm=j1->GetMomentum(); +// Ali3Vector p=j1->Get3Momentum(); +// Float_t m=j1.GetInvmass(); +// Int_t ntk=j1.GetNtracks(); +// AliTrack* tj=j1.GetTrack(1); +// +// Note : All quantities are in GeV, GeV/c or GeV/c**2 +// +//--- Author: Nick van Eijndhoven 10-jul-1997 UU-SAP Utrecht +//- Modified: NvE 06-apr-1999 UU-SAP Utrecht to inherit from Ali4Vector +/////////////////////////////////////////////////////////////////////////// + #include "AliJet.h" ClassImp(AliJet) // Class implementation to enable ROOT I/O diff --git a/RALICE/AliJet.h b/RALICE/AliJet.h index 80ca681c577..7190b3c22ef 100644 --- a/RALICE/AliJet.h +++ b/RALICE/AliJet.h @@ -4,43 +4,6 @@ * See cxx source for full Copyright notice */ /* $Id$ */ - -/////////////////////////////////////////////////////////////////////////// -// Class AliJet -// Creation and investigation of a jet of particle tracks. -// An AliJet can be constructed by adding AliTracks. -// -// Coding example to make 2 jets j1 and j2. -// ---------------------------------------- -// j1 contains the AliTracks 1 and 2 -// j2 contains the AliTracks 3 and 4 -// -// AliTrack t1,t2,t3,t4; -// ... -// ... // code to fill the AliTrack data -// ... -// AliJet j1(5); -// AliJet j2(12); -// j1.Add(t1); -// j1.Add(t2); -// j2.Add(t3); -// j2.Add(t4); -// -// j1.Info(); -// j2.Info("sph"); -// -// Float_t e1=j1.GetEnergy(); -// Float_t pnorm=j1->GetMomentum(); -// Ali3Vector p=j1->Get3Momentum(); -// Float_t m=j1.GetInvmass(); -// Int_t ntk=j1.GetNtracks(); -// AliTrack* tj=j1.GetTrack(1); -// -// Note : All quantities are in GeV, GeV/c or GeV/c**2 -// -//--- NvE 10-jul-1997 UU-SAP Utrecht -//--- Modified : NvE 06-apr-1999 UU-SAP Utrecht to inherit from Ali4Vector -/////////////////////////////////////////////////////////////////////////// #include #include @@ -79,6 +42,6 @@ class AliJet : public TObject,public Ali4Vector Int_t fNtrk; // The number of tracks in the jet TObjArray* fTracks; // Array to hold the pointers to the tracks of the jet - ClassDef(AliJet,1) // Class definition to enable ROOT I/O + ClassDef(AliJet,1) // Creation and investigation of a jet of particle tracks. }; #endif diff --git a/RALICE/AliMath.cxx b/RALICE/AliMath.cxx index 9ad15edf688..0826a0a3233 100644 --- a/RALICE/AliMath.cxx +++ b/RALICE/AliMath.cxx @@ -15,8 +15,29 @@ /* $Log$ +Revision 1.2 1999/09/29 09:24:28 fca +Introduction of the Copyright and cvs Log + */ +/////////////////////////////////////////////////////////////////////////// +// Class AliMath +// Various mathematical tools which may be very convenient while +// performing physics analysis. +// +// Example : Probability of a Chi-squared value +// ========= +// +// AliMath M; +// Float_t chi2=20; // The chi-squared value +// Int_t ndf=12; // The number of degrees of freedom +// Float_t p=M.Prob(chi2,ndf); // The probability that at least a Chi-squared +// // value of chi2 will be observed, even for a +// // correct model +// +//--- Author: Nick van Eijndhoven 14-nov-1998 UU-SAP Utrecht +/////////////////////////////////////////////////////////////////////////// + #include "AliMath.h" ClassImp(AliMath) // Class implementation to enable ROOT I/O diff --git a/RALICE/AliMath.h b/RALICE/AliMath.h index f29aaaced11..4b3485da5d0 100644 --- a/RALICE/AliMath.h +++ b/RALICE/AliMath.h @@ -5,24 +5,6 @@ /* $Id$ */ -/////////////////////////////////////////////////////////////////////////// -// Class AliMath -// Various mathematical tools which may be very convenient while -// performing physics analysis. -// -// Example : Probability of a Chi-squared value -// ========= -// -// AliMath M; -// Float_t chi2=20 ; // The chi-squared value -// Int_t ndf=12; // The number of degrees of freedom -// Float_t p=M.Prob(chi2,ndf); // The probability that at least a Chi-squared -// // value of chi2 will be observed, even for a -// // correct model -// -//--- NvE 14-nov-1998 UU-SAP Utrecht -/////////////////////////////////////////////////////////////////////////// - #include #include @@ -44,7 +26,7 @@ class AliMath : public TObject Float_t GamSer(Float_t a,Float_t x); // Compute P(a,x) via serial representation Float_t GamCf(Float_t a,Float_t x); // Compute P(a,x) via continued fractions - ClassDef(AliMath,1) // Class definition to enable ROOT I/O + ClassDef(AliMath,1) // Various mathematical tools for physics analysis. }; #endif diff --git a/RALICE/AliPosition.cxx b/RALICE/AliPosition.cxx index bec52b28d47..75e9745b425 100644 --- a/RALICE/AliPosition.cxx +++ b/RALICE/AliPosition.cxx @@ -15,8 +15,48 @@ /* $Log$ +Revision 1.2 1999/09/29 09:24:28 fca +Introduction of the Copyright and cvs Log + */ +/////////////////////////////////////////////////////////////////////////// +// Class AliPosition +// Handling of positions in various reference frames. +// +// This class is meant to serve as a base class for ALICE objects +// that have a unique position in 3-dimensional space. +// +// Note : +// ------ +// Positions (r), errors (e) and reference frames (f) are specified via +// +// SetPosition(Float_t* r,TString f) +// SetPositionErrors(Float_t* e,TString f) +// +// under the following conventions : +// +// f="car" ==> r in Cartesian coordinates (x,y,z) +// f="sph" ==> r in Spherical coordinates (r,theta,phi) +// f="cyl" ==> r in Cylindrical coordinates (rho,phi,z) +// +// All angles are in radians. +// +// Example : +// --------- +// +// AliPosition q; +// Float_t pos[3]={-1,25,7}; +// Float_t err[3]={0.08,1.85,0.5}; +// q.SetPosition(pos,"car"); +// q.SetPositionErrors(pos,"car"); +// Float_t loc[3],dloc[3]; +// q.GetPosition(loc,"sph"); +// q.GetPositionErrors(dloc,"sph"); +// +//--- Author: Nick van Eijndhoven 06-feb-1999 UU-SAP Utrecht +/////////////////////////////////////////////////////////////////////////// + #include "AliPosition.h" ClassImp(AliPosition) // Class implementation to enable ROOT I/O @@ -67,5 +107,31 @@ void AliPosition::SetPosition(Ali3Vector& r) Double_t a[3]; r.GetVector(a,"sph"); SetVector(a,"sph"); + r.GetErrors(a,"car"); + SetErrors(a,"car"); +} +/////////////////////////////////////////////////////////////////////////// +void AliPosition::SetPositionErrors(Double_t* r,TString f) +{ +// Store position errors according to reference frame f + SetErrors(r,f); +} +/////////////////////////////////////////////////////////////////////////// +void AliPosition::GetPositionErrors(Double_t* r,TString f) +{ +// Provide position errors according to reference frame f + GetErrors(r,f); +} +/////////////////////////////////////////////////////////////////////////// +void AliPosition::SetPositionErrors(Float_t* r,TString f) +{ +// Store position errors according to reference frame f + SetErrors(r,f); +} +/////////////////////////////////////////////////////////////////////////// +void AliPosition::GetPositionErrors(Float_t* r,TString f) +{ +// Provide position errors according to reference frame f + GetErrors(r,f); } /////////////////////////////////////////////////////////////////////////// diff --git a/RALICE/AliPosition.h b/RALICE/AliPosition.h index 37bc1664946..e3efa3aa4c9 100644 --- a/RALICE/AliPosition.h +++ b/RALICE/AliPosition.h @@ -5,36 +5,6 @@ /* $Id$ */ -/////////////////////////////////////////////////////////////////////////// -// Class AliPosition -// Handling of positions in various reference frames. -// -// This class is meant to serve as a base class for ALICE objects -// that have a unique position in 3-dimensional space. -// -// Note : -// ------ -// Positions (r) and reference frames (f) are specified via -// SetPosition(Float_t* r,TString f) under the following conventions : -// -// f="car" ==> r in Cartesian coordinates (x,y,z) -// f="sph" ==> r in Spherical coordinates (r,theta,phi) -// f="cyl" ==> r in Cylindrical coordinates (rho,phi,z) -// -// All angles are in radians. -// -// Example : -// --------- -// -// AliPosition q; -// Float_t pos[3]={-1,25,7}; -// q.SetPosition(pos,"car"); -// Float_t loc[3]; -// q.GetPosition(loc,"sph"); -// -//--- NvE 06-feb-1999 UU-SAP Utrecht -/////////////////////////////////////////////////////////////////////////// - #include #include @@ -46,15 +16,20 @@ class AliPosition : public Ali3Vector { public: - AliPosition(); // Default constructor - virtual ~AliPosition(); // Destructor - virtual void SetPosition(Double_t* r,TString f); // Store position r in frame f - virtual void GetPosition(Double_t* r,TString f); // Provide position r in frame f - virtual void SetPosition(Float_t* r,TString f); // Store position r in frame f - virtual void GetPosition(Float_t* r,TString f); // Provide position r in frame f - AliPosition& GetPosition(); // Provide position - virtual void SetPosition(Ali3Vector& r); // Store position r + AliPosition(); // Default constructor + virtual ~AliPosition(); // Destructor + virtual void SetPosition(Double_t* r,TString f); // Store position r in frame f + virtual void GetPosition(Double_t* r,TString f); // Provide position r in frame f + virtual void SetPosition(Float_t* r,TString f); // Store position r in frame f + virtual void GetPosition(Float_t* r,TString f); // Provide position r in frame f + AliPosition& GetPosition(); // Provide position + virtual void SetPosition(Ali3Vector& r); // Store position r + + virtual void SetPositionErrors(Double_t* r,TString f); // Store position r in frame f + virtual void GetPositionErrors(Double_t* r,TString f); // Provide position r in frame f + virtual void SetPositionErrors(Float_t* r,TString f); // Store position r in frame f + virtual void GetPositionErrors(Float_t* r,TString f); // Provide position r in frame f - ClassDef(AliPosition,1) // Class definition to enable ROOT I/O + ClassDef(AliPosition,1) // Handling of positions in various reference frames. }; #endif diff --git a/RALICE/AliPositionObj.cxx b/RALICE/AliPositionObj.cxx new file mode 100644 index 00000000000..1fcc77194d1 --- /dev/null +++ b/RALICE/AliPositionObj.cxx @@ -0,0 +1,91 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* +$Log$ +*/ + +/////////////////////////////////////////////////////////////////////////// +// Class AliPositionObj +// Handling of positions in various reference frames. +// +// This class is meant to provide an AliPosition object which is derived +// from TObject such that it can be stored in e.g. TObjArray etc... +// and that it can be written out using the ROOT I/O machinery. +// +// Example : +// ========= +// +// Float_t a[3]={1,2,3}; +// Float_t ea[3]={0.01,0.02,0.03}; +// Float_t b[3]={4,5,6}; +// Float_t eb[3]={0.04,0.05,0.06}; +// +// AliPosition r1,r2; +// +// r1.SetPosition(a,"car"); +// r1.SetPositionErrors(ea,"car"); +// r2.SetPosition(b,"car"); +// r2.SetPositionErrors(eb,"car"); +// +// Ali3Vector sum=r1+r2; +// Ali3Vector rel=r1-r2; +// +// AliPositionObj rr1(r1); +// AliPositionObj rr2; +// rr2.Load(r2); +// AliPositionObj ssum(r1+r2); +// +// rr1.Info(); +// rr2.Info(); +// ssum.Info(); +// +//--- Author: Nick van Eijndhoven 18-oct-1999 UU-SAP Utrecht +/////////////////////////////////////////////////////////////////////////// + +#include "AliPositionObj.h" + +ClassImp(AliPositionObj) // Class implementation to enable ROOT I/O + +AliPositionObj::AliPositionObj() +{ +// Creation of an AliPositionObj object and initialisation of parameters. +// All attributes initialised to 0. +} +/////////////////////////////////////////////////////////////////////////// +AliPositionObj::AliPositionObj(Ali3Vector& q) +{ +// Creation of an AliPositionObj object and initialisation of parameters. +// All attributes are initialised to the values of the input Ali3Vector. + Load(q); +} +/////////////////////////////////////////////////////////////////////////// +AliPositionObj::~AliPositionObj() +{ +// Destructor to delete dynamically allocated memory. +} +/////////////////////////////////////////////////////////////////////////// +void AliPositionObj::Load(Ali3Vector& q) +{ +// Load all attributes of the input Ali3Vector into this AliPositionObj object. + Double_t temp=q.GetResultError(); + Double_t a[3]; + q.GetVector(a,"sph"); + SetPosition(a,"sph"); + q.GetErrors(a,"car"); + SetPositionErrors(a,"car"); + fDresult=temp; +} +/////////////////////////////////////////////////////////////////////////// diff --git a/RALICE/AliPositionObj.h b/RALICE/AliPositionObj.h new file mode 100644 index 00000000000..4c69e9495bd --- /dev/null +++ b/RALICE/AliPositionObj.h @@ -0,0 +1,22 @@ +#ifndef ALIPOSITIONOBJ_H +#define ALIPOSITIONOBJ_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +#include "TObject.h" + +#include "AliPosition.h" + +class AliPositionObj : public TObject,public AliPosition +{ + public: + AliPositionObj(); // Default constructor + AliPositionObj(Ali3Vector& q); // Constructor + ~AliPositionObj(); // Destructor + void Load(Ali3Vector& q); // Load all attributes of input AliPosition + + ClassDef(AliPositionObj,1) // Handling of positions in various reference frames. +}; +#endif diff --git a/RALICE/AliRandom.cxx b/RALICE/AliRandom.cxx index 0a203118d22..3ccce9bdf60 100644 --- a/RALICE/AliRandom.cxx +++ b/RALICE/AliRandom.cxx @@ -15,15 +15,108 @@ /* $Log$ +Revision 1.2 1999/09/29 09:24:28 fca +Introduction of the Copyright and cvs Log + */ +/////////////////////////////////////////////////////////////////////////// +// Class AliRandom +// Generate universal random numbers on all common machines. +// Available distributions : Uniform, Gaussian, Poisson and +// User defined function +// +// Features : +// ---------- +// 1) Period = 2**144 +// 2) Same sequence of 24-bit real numbers on all common machines +// +// Reference : +// ----------- +// G.Marsaglia and A.Zaman, FSU-SCRI-87-50, Florida State University, 1987. +// +// Coding example : +// ---------------- +// +// Float_t rndm; // Variable to hold a single random number +// const Int_t n=1000; +// Float_t rvec[n]; // Vector to hold n random numbers +// +// AliRandom r; // Create a Random object with default sequence +// +// rndm=r.Uniform(); // Provide a uniform random number in <0,1> +// Float_t a=3.; +// Float_t b=5.; +// rndm=r.Uniform(a,b); // Provide a uniform random number in +// r.Uniform(rvec,n); // Provide n uniform randoms in <0,1> in rvec +// r.Uniform(rvec,n,a,b); // Provide n uniform randoms in in rvec +// +// rndm=r.Gauss(); // Provide a Gaussian random number with +// // mean=0 and sigma=1 +// Float_t mean=25.; +// Float_t sigma=5.; +// rndm=r.Gauss(mean,sigma); // Provide a Gaussian random number +// // with specified mean and sigma +// r.Gauss(rvec,n); // n Gaussian randoms mean=0 sigma=1 +// r.Gauss(rvec,n,mean,sigma); // n Gaussian randoms with specified +// // mean and sigma +// +// rndm=r.Poisson(mean); // Provide a Poisson random number with +// // specified mean +// r.Poisson(rvec,nmean); // n Poisson randoms with specified mean +// +// Int_t seed=1837724 +// AliRandom p(seed); // Create a Random object with specified seed. +// // The sequence is started from scratch. +// Int_t cnt1=25; +// Int_t cnt2=8; +// AliRandom q(seed,cnt1,cnt2); // Create a Random object with specified seed +// // The sequence is started at the location +// // denoted by the counters cnt1 and cnt2. +// +// q.Info(); // Print the current seed, cnt1 and cnt2 values. +// q.GetSeed(); // Provide the current seed value. +// q.GetCnt1(); // Provide the current cnt1 value. +// q.GetCnt2(); // Provide the current cnt2 value. +// +// Float_t udist(Float_t x) // A user defined distribution +// { +// return x*x-4.*x; +// } +// +// Int_t nbins=100; +// q.SetUser(a,b,nbins,udist); // Initialise generator for udist distribution +// q.User(); // Provide a random number according to the udist distribution +// q.User(rvec,n); // Provide n randoms according to the udist distribution +// +// Float_t* x=new Float_t[nbins]; +// Float_t* y=new Float_t[nbins]; +// +// ... code to fill x[] and y[] .. +// +// AliRandom s; +// s.SetUser(x,y,nbins); // Initialise generator for (x[i],y[i]) distribution +// s.User(); // Provide a random number according to the user distribution +// s.User(rvec,n); // Provide n randoms according to the user distribution +// +// Notes : +// ------- +// 1) Allowed seed values : 0 <= seed <= 921350143 +// Default seed = 53310452 +// 2) To ensure a unique sequence for each run, one can automatically +// construct a seed value by e.g. using the date and time. +// 3) Using the rvec facility saves a lot of CPU time for large n values. +// +//--- Author: Nick van Eijndhoven 11-oct-1997 UU-SAP Utrecht +/////////////////////////////////////////////////////////////////////////// + #include "AliRandom.h" ClassImp(AliRandom) // Class implementation to enable ROOT I/O AliRandom::AliRandom() { -// Creation of an AliRandom object and default initialisation +// Creation of an AliRandom object and default initialisation. // // A seed is used to create the initial u[97] table. // This seed is converted into four startup parameters i j k and l diff --git a/RALICE/AliRandom.h b/RALICE/AliRandom.h index 13ca3b4de5e..0963c2c005b 100644 --- a/RALICE/AliRandom.h +++ b/RALICE/AliRandom.h @@ -5,96 +5,6 @@ /* $Id$ */ -/////////////////////////////////////////////////////////////////////////// -// Class AliRandom -// Generate universal random numbers on all common machines. -// Available distributions : Uniform, Gaussian, Poisson and -// User defined function -// -// Features : -// ---------- -// 1) Period = 2**144 -// 2) Same sequence of 24-bit real numbers on all common machines -// -// Reference : -// ----------- -// G.Marsaglia and A.Zaman, FSU-SCRI-87-50, Florida State University, 1987. -// -// Coding example : -// ---------------- -// -// Float_t rndm; // Variable to hold a single random number -// const Int_t n=1000; -// Float_t rvec[n]; // Vector to hold n random numbers -// -// AliRandom r; // Create a Random object with default sequence -// -// rndm=r.Uniform(); // Provide a uniform random number in <0,1> -// Float_t a=3.; -// Float_t b=5.; -// rndm=r.Uniform(a,b); // Provide a uniform random number in -// r.Uniform(rvec,n); // Provide n uniform randoms in <0,1> in rvec -// r.Uniform(rvec,n,a,b); // Provide n uniform randoms in in rvec -// -// rndm=r.Gauss(); // Provide a Gaussian random number with -// // mean=0 and sigma=1 -// Float_t mean=25.; -// Float_t sigma=5.; -// rndm=r.Gauss(mean,sigma); // Provide a Gaussian random number -// // with specified mean and sigma -// r.Gauss(rvec,n); // n Gaussian randoms mean=0 sigma=1 -// r.Gauss(rvec,n,mean,sigma); // n Gaussian randoms with specified -// // mean and sigma -// -// rndm=r.Poisson(mean); // Provide a Poisson random number with -// // specified mean -// r.Poisson(rvec,nmean); // n Poisson randoms with specified mean -// -// Int_t seed=1837724 -// AliRandom p(seed); // Create a Random object with specified seed. -// // The sequence is started from scratch. -// Int_t cnt1=25; -// Int_t cnt2=8; -// AliRandom q(seed,cnt1,cnt2); // Create a Random object with specified seed -// // The sequence is started at the location -// // denoted by the counters cnt1 and cnt2. -// -// q.Info(); // Print the current seed, cnt1 and cnt2 values. -// q.GetSeed(); // Provide the current seed value. -// q.GetCnt1(); // Provide the current cnt1 value. -// q.GetCnt2(); // Provide the current cnt2 value. -// -// Float_t udist(Float_t x) // A user defined distribution -// { -// return x*x-4.*x; -// } -// -// Int_t nbins=100; -// q.SetUser(a,b,nbins,udist); // Initialise generator for udist distribution -// q.User(); // Provide a random number according to the udist distribution -// q.User(rvec,n); // Provide n randoms according to the udist distribution -// -// Float_t* x=new Float_t[nbins]; -// Float_t* y=new Float_t[nbins]; -// -// ... code to fill x[] and y[] .. -// -// AliRandom s; -// s.SetUser(x,y,nbins); // Initialise generator for (x[i],y[i]) distribution -// s.User(); // Provide a random number according to the user distribution -// s.User(rvec,n); // Provide n randoms according to the user distribution -// -// Notes : -// ------- -// 1) Allowed seed values : 0 <= seed <= 921350143 -// Default seed = 53310452 -// 2) To ensure a unique sequence for each run, one can automatically -// construct a seed value by e.g. using the date and time. -// 3) Using the rvec facility saves a lot of CPU time for large n values. -// -//--- NvE 11-oct-1997 UU-SAP Utrecht -/////////////////////////////////////////////////////////////////////////// - #include #include @@ -138,6 +48,6 @@ class AliRandom : public TObject Float_t fYamin,fYamax; //! The min. and max. y values of the area function Int_t* fIbins; //! The bin numbers of the random x candidates - ClassDef(AliRandom,1) // Class definition to enable ROOT I/O + ClassDef(AliRandom,1) // Generate universal random numbers on all common machines. }; #endif diff --git a/RALICE/AliSample.cxx b/RALICE/AliSample.cxx index 2b1cb25c7f1..b4c624cdb46 100644 --- a/RALICE/AliSample.cxx +++ b/RALICE/AliSample.cxx @@ -15,8 +15,37 @@ /* $Log$ +Revision 1.2 1999/09/29 09:24:28 fca +Introduction of the Copyright and cvs Log + */ +/////////////////////////////////////////////////////////////////////////// +// Class AliSample +// Perform statistics on various multi-dimensional data samples +// A data sample can be filled using the "Enter" and/or "Remove" functions, +// whereas the "Reset" function resets the complete sample to 'empty'. +// The info which can be extracted from a certain data sample are the +// sum, mean, variance, sigma, covariance and correlation. +// The "Info" function provides all statistics data for a certain sample. +// The variables for which these stat. parameters have to be calculated +// are indicated by the index of the variable which is passed as an +// argument to the various member functions. +// The index convention for a data point (x,y) is : x=1 y=2 +// +// Example : +// --------- +// For an AliSample s a data point (x,y) can be entered as s.Enter(x,y) and +// the mean_x can be obtained as s.GetMean(1) whereas the mean_y is obtained +// via s.GetMean(2). +// The correlation between x and y is available via s.GetCor(1,2). +// The x-statistics are obtained via s.Info(1), y-statistics via s.Info(2), +// and the covariance and correlation between x and y via s.Info(1,2). +// All statistics of a sample are obtained via s.Info(). +// +//--- Author: Nick van Eijndhoven 30-mar-1996 CERN Geneva +/////////////////////////////////////////////////////////////////////////// + #include "AliSample.h" AliSample::AliSample() diff --git a/RALICE/AliSample.h b/RALICE/AliSample.h index 09a94572150..a99c24ffbf5 100644 --- a/RALICE/AliSample.h +++ b/RALICE/AliSample.h @@ -5,32 +5,6 @@ /* $Id$ */ -/////////////////////////////////////////////////////////////////////////// -// Class AliSample -// Perform statistics on various multi-dimensional data samples -// A data sample can be filled using the "Enter" and/or "Remove" functions, -// whereas the "Reset" function resets the complete sample to 'empty'. -// The info which can be extracted from a certain data sample are the -// sum, mean, variance, sigma, covariance and correlation. -// The "Info" function provides all statistics data for a certain sample. -// The variables for which these stat. parameters have to be calculated -// are indicated by the index of the variable which is passed as an -// argument to the various member functions. -// The index convention for a data point (x,y) is : x=1 y=2 -// -// Example : -// --------- -// For an AliSample s a data point (x,y) can be entered as s.Enter(x,y) and -// the mean_x can be obtained as s.GetMean(1) whereas the mean_y is obtained -// via s.GetMean(2). -// The correlation between x and y is available via s.GetCor(1,2). -// The x-statistics are obtained via s.Info(1), y-statistics via s.Info(2), -// and the covariance and correlation between x and y via s.Info(1,2). -// All statistics of a sample are obtained via s.Info(). -// -//--- NvE 30-mar-1996 CERN Geneva -/////////////////////////////////////////////////////////////////////////// - #include #include diff --git a/RALICE/AliSignal.cxx b/RALICE/AliSignal.cxx index 377c199c413..3a7c3a6f1e9 100644 --- a/RALICE/AliSignal.cxx +++ b/RALICE/AliSignal.cxx @@ -15,40 +15,237 @@ /* $Log$ +Revision 1.2 1999/09/29 09:24:28 fca +Introduction of the Copyright and cvs Log + */ +/////////////////////////////////////////////////////////////////////////// +// Class AliSignal +// Handling of ALICE (extrapolated) signals. +// +// Note : +// ------ +// Signal positions (r) and reference frames (f) are specified via +// SetPosition(r,f) under the following conventions : +// +// f="car" ==> r is Cartesian (x,y,z) +// f="sph" ==> r is Spherical (r,theta,phi) +// f="cyl" ==> r is Cylindrical (rho,phi,z) +// +// The same holds for SetPositionErrors(). +// +// All angles are in radians. +// +// Example : +// --------- +// +// AliSignal s; +// Float_t pos[3]={-1,25,7}; +// Float_t err[3]={0.03,0.7,0.18}; +// Float_t signal=120.8; +// Float_t error=1.73; +// s.SetPosition(pos,"car"); +// s.SetPositionErrors(err,"car"); +// s.SetSignal(signal); +// s.SetSignalError(error); +// Float_t loc[3],dr[3],sigma; +// s.GetPosition(loc,"sph"); +// s.GetPositionErrors(dr,"sph"); +// Float_t adc=s.GetSignal(); +// Float_t sigma=s.GetSignalError(); +// +// AliSignal q(3); // q can store 3 signal values with their errors +// // In the example below a signal contains the +// // following data : timing, ADC and dE/dx +// q.SetPosition(pos,"car"); +// q.SetPositionErrors(err,"car"); +// signal=82.5; // e.q. signal time in ns +// error=2.01; +// q.SetSignal(signal,1); +// q.SetSignalError(error,1); +// signal=268.1; // e.g. ADC value of signal +// error=3.75; +// q.SetSignal(signal,2); +// q.SetSignalError(error,2); +// signal=23.7; // e.g. corresponding dE/dx value +// error=0.48; +// q.SetSignal(signal,3); +// q.SetSignalError(error,3); +// +//--- Author: Nick van Eijndhoven 23-jan-1999 UU-SAP Utrecht +//- Modified: NvE 30-oct-1999 UU-SAP Utrecht +/////////////////////////////////////////////////////////////////////////// + #include "AliSignal.h" ClassImp(AliSignal) // Class implementation to enable ROOT I/O -AliSignal::AliSignal() +AliSignal::AliSignal(Int_t n) { -// Creation of an AliSignal object and initialisation of parameters - Reset(); +// Creation of an AliSignal object and initialisation of parameters. +// A total of n (default n=1) values (with errors) can be stored. + fNvalues=n; + fSignal=0; + fDsignal=0; } /////////////////////////////////////////////////////////////////////////// AliSignal::~AliSignal() { // Destructor to delete dynamically allocated memory + if (fSignal) + { + delete fSignal; + fSignal=0; + } + if (fDsignal) + { + delete fDsignal; + fDsignal=0; + } } /////////////////////////////////////////////////////////////////////////// void AliSignal::Reset() { -// Reset all values - Float_t r[3]={0,0,0}; +// Reset all signal and position values and errors to 0. +// The data arrays are also created if not already existing. + + if (!fSignal) fSignal=new TArrayF(fNvalues); + if (!fDsignal) fDsignal=new TArrayF(fNvalues); + + Double_t r[3]={0,0,0}; SetPosition(r,"sph"); - fSignal=0; + SetErrors(r,"car"); + for (Int_t i=0; iGetSize(); i++) + { + fSignal->AddAt(0,i); + fDsignal->AddAt(0,i); + } +} +/////////////////////////////////////////////////////////////////////////// +void AliSignal::ResetSignals() +{ +// Reset all signal values and errors to 0. +// The data arrays are also created if not already existing. + + if (!fSignal) fSignal=new TArrayF(fNvalues); + if (!fDsignal) fDsignal=new TArrayF(fNvalues); + + for (Int_t i=0; iGetSize(); i++) + { + fSignal->AddAt(0,i); + fDsignal->AddAt(0,i); + } } /////////////////////////////////////////////////////////////////////////// -void AliSignal::SetSignal(Float_t sig) +void AliSignal::ResetPosition() { -// Store signal value - fSignal=sig; +// Reset position and errors to 0. + Double_t r[3]={0,0,0}; + SetPosition(r,"sph"); + SetErrors(r,"car"); } /////////////////////////////////////////////////////////////////////////// -Float_t AliSignal::GetSignal() +void AliSignal::SetSignal(Double_t sig,Int_t j) { -// Provide signal value - return fSignal; +// Store j-th (default j=1) signal value. +// Note : The first signal value is at j=1. + + if (!fSignal) ResetSignals(); + + Int_t size=fSignal->GetSize(); + if (j<=size) + { + fSignal->AddAt(float(sig),j-1); + } + else + { + cout << "*AliSignal::SetSignal* Index mismatch j : " << j + << " size : " << size << endl; + } } /////////////////////////////////////////////////////////////////////////// +void AliSignal::AddSignal(Double_t sig,Int_t j) +{ +// Add value to j-th (default j=1) signal value. +// Note : The first signal value is at j=1. + + if (!fSignal) ResetSignals(); + + Int_t size=fSignal->GetSize(); + if (j<=size) + { + Float_t sum=(fSignal->At(j-1))+sig; + fSignal->AddAt(sum,j-1); + } + else + { + cout << "*AliSignal::AddSignal* Index mismatch j : " << j + << " size : " << size << endl; + } +} +/////////////////////////////////////////////////////////////////////////// +Float_t AliSignal::GetSignal(Int_t j) +{ +// Provide j-th (default j=1) signal value. +// Note : The first signal value is at j=1. + if (fSignal) + { + return fSignal->At(j-1); + } + else + { + return 0; + } +} +/////////////////////////////////////////////////////////////////////////// +void AliSignal::SetSignalError(Double_t dsig,Int_t j) +{ +// Store error on j-th (default j=1) signal value. +// Note : The error on the first signal value is at j=1. + + if (!fDsignal) ResetSignals(); + + Int_t size=fDsignal->GetSize(); + if (j<=size) + { + fDsignal->AddAt(float(dsig),j-1); + } + else + { + cout << "*AliSignal::SetSignalError* Index mismatch j : " << j + << " size : " << size << endl; + } +} +/////////////////////////////////////////////////////////////////////////// +Float_t AliSignal::GetSignalError(Int_t j) +{ +// Provide error on the j-th (default j=1) signal value. +// Note : The error on the first signal value is at j=1. + if (fDsignal) + { + return fDsignal->At(j-1); + } + else + { + return 0; + } +} +/////////////////////////////////////////////////////////////////////////// +void AliSignal::Info(TString f) +{ +// Provide signal information within the coordinate frame f + cout << " *AliSignal::Info* " << endl; + cout << " Position"; + Ali3Vector::Info(f); + + if (fSignal && fDsignal) + { + for (Int_t i=0; iGetSize(); i++) + { + cout << " Signal value : " << fSignal->At(i) + << " error : " << fDsignal->At(i) << endl; + } + } +} +/////////////////////////////////////////////////////////////////////////// diff --git a/RALICE/AliSignal.h b/RALICE/AliSignal.h index 4892fc55308..f37eec0fe21 100644 --- a/RALICE/AliSignal.h +++ b/RALICE/AliSignal.h @@ -5,50 +5,31 @@ /* $Id$ */ -/////////////////////////////////////////////////////////////////////////// -// Class AliSignal -// Handling of ALICE (extrapolated) signals. -// -// Note : -// ------ -// Signal positions (r) and reference frames (f) are specified via -// SetPosition(r,f) under the following conventions : -// -// f="car" ==> r is Cartesian (x,y,z) -// f="sph" ==> r is Spherical (r,theta,phi) -// f="cyl" ==> r is Cylindrical (rho,phi,z) -// -// All angles are in radians. -// -// Example : -// --------- -// -// AliSignal s; -// Float_t pos[3]={-1,25,7}; -// Float_t signal=120.8; -// s.SetPosition(pos,"car"); -// s.SetSignal(signal); -// Float_t loc[3]; -// s.GetPosition(loc,"sph"); -// Float_t adc=s.GetSignal(); -// -//--- NvE 23-jan-1999 UU-SAP Utrecht -/////////////////////////////////////////////////////////////////////////// +#include "TObject.h" +#include "TArrayF.h" #include "AliPosition.h" class AliSignal : public TObject,public AliPosition { public: - AliSignal(); // Default constructor - ~AliSignal(); // Destructor - virtual void SetSignal(Float_t sig); // Store signal value - virtual Float_t GetSignal(); // Provide signal value - virtual void Reset(); // Reset all values to 0 + AliSignal(Int_t n=1); // Default constructor + ~AliSignal(); // Destructor + virtual void SetSignal(Double_t sig,Int_t j=1); // Store j-th signal value + virtual void AddSignal(Double_t sig,Int_t j=1); // Add value to j-th signal value + virtual Float_t GetSignal(Int_t j=1); // Provide j-th signal value + virtual void SetSignalError(Double_t dsig,Int_t j=1); // Store error on j-th signal value + virtual Float_t GetSignalError(Int_t j=1); // Provide error j-th signal value + virtual void ResetSignals(); // Reset all signal values and errors to 0 + virtual void ResetPosition(); // Reset position and errors to 0 + virtual void Reset(); // Reset signal and pos. values and errors + void Info(TString f="car"); // Print signal info for coord. frame f protected: - Float_t fSignal; // Signal value + Int_t fNvalues; // The number of values per signal + TArrayF* fSignal; // Signal values + TArrayF* fDsignal; // Errors on signal values - ClassDef(AliSignal,1) // Class definition to enable ROOT I/O + ClassDef(AliSignal,1) // Handling of ALICE (extrapolated) signals. }; #endif diff --git a/RALICE/AliTrack.cxx b/RALICE/AliTrack.cxx index 8477b3eb665..fe4f949582d 100644 --- a/RALICE/AliTrack.cxx +++ b/RALICE/AliTrack.cxx @@ -15,8 +15,85 @@ /* $Log$ +Revision 1.2 1999/09/29 09:24:28 fca +Introduction of the Copyright and cvs Log + */ +/////////////////////////////////////////////////////////////////////////// +// Class AliTrack +// Handling of the attributes of a reconstructed particle track. +// +// Coding example : +// ---------------- +// +// Float_t a[4]={195.,1.2,-0.04,8.5}; +// Ali4Vector pmu; +// pmu.SetVector(a,"car"); +// AliTrack t1; +// t1.Set4Momentum(pmu); +// +// Float_t b[3]={1.2,-0.04,8.5}; +// Ali3Vector p; +// p.SetVector(b,"car"); +// AliTrack t2; +// t2.Set3Momentum(p); +// t2.SetCharge(0); +// t2.SetMass(1.115); +// +// t1.Info(); +// t2.Info(); +// +// Float_t pi=acos(-1.); +// Float_t thcms=0.2*pi; // decay theta angle in cms +// Float_t phicms=pi/4.; // decay theta angle in cms +// Float_t m1=0.938; +// Float_t m2=0.140; +// t2.Decay(m1,m2,thcms,phicms); // Track t2 decay : Lambda -> proton + pion +// +// t2.List(); +// +// Int_t ndec=t2.GetNdecay(); +// AliTrack* d1=t2.GetDecayTrack(1); // Access to decay track number 1 +// AliTrack* d2=t2.GetDecayTrack(2); // Access to decay track number 2 +// +// AliSignal s1,s2,s3,s4; +// +// .... // Code (e.g. detector readout) to fill AliSignal data +// +// AliTrack trec; // Track which will be reconstructed from signals +// trec.AddSignal(s1); +// trec.AddSignal(s3); +// trec.AddSignal(s4); +// +// Ali3Vector P; +// Float_t Q,M; +// +// ... // Code which accesses signals from trec and reconstructs +// 3-momentum P, charge Q, mass M etc... +// +// trec.Set3Momentum(P); +// trec.SetCharge(Q); +// trec.SetMass(M); +// +// Float_t r1[3]={1.6,-3.8,25.7}; +// Float_t er1[3]={0.2,0.5,1.8}; +// Float_t r2[3]={8.6,23.8,-6.7}; +// Float_t er2[3]={0.93,1.78,0.8}; +// AliPosition begin,end; +// begin.SetPosition(r1,"car"); +// begin.SetPositionErrors(er1,"car"); +// end.SetPosition(r2,"car"); +// end.SetPositionErrors(er2,"car"); +// trec.SetBeginPoint(begin); +// trec.SetEndPoint(end); +// +// Note : All quantities are in GeV, GeV/c or GeV/c**2 +// +//--- Author: Nick van Eijndhoven 10-jul-1997 UU-SAP Utrecht +//- Modified: NvE 29-oct-1999 UU-SAP Utrecht +/////////////////////////////////////////////////////////////////////////// + #include "AliTrack.h" ClassImp(AliTrack) // Class implementation to enable ROOT I/O @@ -26,6 +103,7 @@ AliTrack::AliTrack() // Default constructor // All variables initialised to 0 fDecays=0; + fSignals=0; Reset(); } /////////////////////////////////////////////////////////////////////////// @@ -38,14 +116,20 @@ AliTrack::~AliTrack() delete fDecays; fDecays=0; } + if (fSignals) + { + fSignals->Clear(); + delete fSignals; + fSignals=0; + } } /////////////////////////////////////////////////////////////////////////// void AliTrack::Reset() { // Reset all variables to 0 - fM=0; fQ=0; fNdec=0; + fNsig=0; Double_t a[4]={0,0,0,0}; SetVector(a,"sph"); if (fDecays) @@ -54,34 +138,40 @@ void AliTrack::Reset() delete fDecays; fDecays=0; } + if (fSignals) + { + fSignals->Clear(); + delete fSignals; + fSignals=0; + } + Double_t b[3]={0,0,0}; + fBegin.SetPosition(b,"sph"); + fEnd.SetPosition(b,"sph"); } /////////////////////////////////////////////////////////////////////////// void AliTrack::Set3Momentum(Ali3Vector& p) { // Set the track parameters according to the 3-momentum p - Double_t E=sqrt(p.Dot(p)+fM*fM); - SetVector(E,p); + Set3Vector(p); } /////////////////////////////////////////////////////////////////////////// void AliTrack::Set4Momentum(Ali4Vector& p) { // Set the track parameters according to the 4-momentum p Double_t E=p.GetScalar(); + Double_t dE=p.GetResultError(); Ali3Vector pv=p.Get3Vector(); SetVector(E,pv); - - Double_t m2=p.Dot(p); - fM=0; - if (m2 > 0.) fM=sqrt(m2); + SetScalarError(dE); } /////////////////////////////////////////////////////////////////////////// -void AliTrack::SetMass(Double_t m) +void AliTrack::SetMass(Double_t m,Double_t dm) { // Set the particle mass - fM=m; - Ali3Vector p=Get3Vector(); - Double_t E=sqrt(p.Dot(p)+fM*fM); - SetVector(E,p); +// The default value for the error dm is 0. + Double_t inv=pow(m,2); + Double_t dinv=fabs(2.*m*dm); + SetInvariant(inv,dinv); } /////////////////////////////////////////////////////////////////////////// void AliTrack::SetCharge(Float_t q) @@ -93,9 +183,12 @@ void AliTrack::SetCharge(Float_t q) void AliTrack::Info(TString f) { // Provide track information within the coordinate frame f - cout << " *AliTrack::Info* Mass : " << fM << " Charge : " << fQ - << " Momentum : " << GetMomentum() << " Ntracks : " << fNdec << endl; - cout << " "; + Double_t m=GetMass(); + Double_t dm=GetResultError(); + cout << " *AliTrack::Info* Mass : " << m + << " error : " << dm << " Charge : " << fQ + << " Momentum : " << GetMomentum() << " Ntracks : " << fNdec + << " Nsignals : " << fNsig << endl; Ali4Vector::Info(f); } /////////////////////////////////////////////////////////////////////////// @@ -113,7 +206,6 @@ void AliTrack::List(TString f) if (td) { cout << " ---Level 1 sec. track no. " << id << endl; - cout << " "; td->Info(f); } else @@ -128,6 +220,12 @@ void AliTrack::ListAll(TString f) // Provide complete track and decay information within the coordinate frame f Info(f); // Information of the current track + cout << " Begin-point :"; fBegin.Info(f); + cout << " End-point :"; fEnd.Info(f); + for (Int_t is=1; is<=GetNsignals(); is++) + { + ((AliSignal*)GetSignal(is))->Info(f); + } AliTrack* t=this; Dump(t,1,f); // Information of all decay products @@ -143,8 +241,11 @@ void AliTrack::Dump(AliTrack* t,Int_t n,TString f) if (td) { cout << " ---Level " << n << " sec. track no. " << id << endl; - cout << " "; td->Info(f); + for (Int_t is=1; is<=td->GetNsignals(); is++) + { + ((AliSignal*)td->GetSignal(is))->Info(f); + } // Go for next decay level of this decay track recursively Dump(td,n+1,f); @@ -158,9 +259,14 @@ void AliTrack::Dump(AliTrack* t,Int_t n,TString f) ////////////////////////////////////////////////////////////////////////// Double_t AliTrack::GetMomentum() { -// Provide the value of the track 3-momentum - Ali3Vector p=Get3Vector(); - return sqrt(p.Dot(p)); +// Provide the value of the track 3-momentum. +// The error can be obtained by invoking GetResultError() after +// invokation of GetMomentum(). + +// Ali3Vector p=Get3Vector(); +// return sqrt(p.Dot(p)); + Double_t norm=fV.GetNorm(); + return norm; } /////////////////////////////////////////////////////////////////////////// Ali3Vector AliTrack::Get3Momentum() @@ -171,8 +277,26 @@ Ali3Vector AliTrack::Get3Momentum() /////////////////////////////////////////////////////////////////////////// Double_t AliTrack::GetMass() { -// Provide the particle mass - return fM; +// Provide the particle mass. +// The error can be obtained by invoking GetResultError() after +// invokation of GetMass(). + Double_t inv=GetInvariant(); + Double_t dinv=GetResultError(); + Double_t dm=0; + if (inv >= 0) + { + Double_t m=sqrt(inv); + if (m) dm=dinv/(2.*m); + fDresult=dm; + return m; + } + else + { + cout << "*AliTrack::GetMass* Unphysical situation m**2 = " << inv << endl; + cout << " Value 0 will be returned." << endl; + fDresult=dm; + return 0; + } } /////////////////////////////////////////////////////////////////////////// Float_t AliTrack::GetCharge() @@ -183,8 +307,20 @@ Float_t AliTrack::GetCharge() /////////////////////////////////////////////////////////////////////////// Double_t AliTrack::GetEnergy() { -// Provide the particle's energy - return GetScalar(); +// Provide the particle's energy. +// The error can be obtained by invoking GetResultError() after +// invokation of GetEnergy(). + Double_t E=GetScalar(); + if (E>0) + { + return E; + } + else + { + cout << "*AliTrack::GetEnergy* Unphysical situation E = " << E << endl; + cout << " Value 0 will be returned." << endl; + return 0; + } } /////////////////////////////////////////////////////////////////////////// void AliTrack::Decay(Double_t m1,Double_t m2,Double_t thcms,Double_t phicms) @@ -196,11 +332,15 @@ void AliTrack::Decay(Double_t m1,Double_t m2,Double_t thcms,Double_t phicms) // phicms : cms phi decay angle (in rad.) of m1 fNdec=2; // it's a 2-body decay + + Double_t M=GetMass(); // Compute the 4-momenta of the decay products in the cms // Note : p2=p1=pnorm for a 2-body decay - Double_t e1=((fM*fM)+(m1*m1)-(m2*m2))/(2.*fM); - Double_t e2=((fM*fM)+(m2*m2)-(m1*m1))/(2.*fM); + Double_t e1=0; + if (M) e1=((M*M)+(m1*m1)-(m2*m2))/(2.*M); + Double_t e2=0; + if (M) e2=((M*M)+(m2*m2)-(m1*m1))/(2.*M); Double_t pnorm=(e1*e1)-(m1*m1); if (pnorm>0.) { @@ -220,13 +360,15 @@ void AliTrack::Decay(Double_t m1,Double_t m2,Double_t thcms,Double_t phicms) Ali4Vector pprim1; pprim1.SetVector(e1,p); + pprim1.SetInvariant(m1*m1); Ali4Vector pprim2; p*=-1; pprim2.SetVector(e2,p); + pprim2.SetInvariant(m2*m2); // Determine boost parameters from the parent particle - Double_t E=GetScalar(); + Double_t E=GetEnergy(); p=Get3Vector(); Ali4Vector pmu; pmu.SetVector(E,p); @@ -247,11 +389,9 @@ void AliTrack::Decay(Double_t m1,Double_t m2,Double_t thcms,Double_t phicms) fDecays->Add(new AliTrack); ((AliTrack*)fDecays->At(0))->Set4Momentum(p1); + ((AliTrack*)fDecays->At(0))->SetMass(m1); fDecays->Add(new AliTrack); ((AliTrack*)fDecays->At(1))->Set4Momentum(p2); - -// Set the mass values to m1 and m2 to omit roundoff errors - ((AliTrack*)fDecays->At(0))->SetMass(m1); ((AliTrack*)fDecays->At(1))->SetMass(m2); } /////////////////////////////////////////////////////////////////////////// @@ -277,3 +417,71 @@ AliTrack* AliTrack::GetDecayTrack(Int_t j) } } /////////////////////////////////////////////////////////////////////////// +void AliTrack::AddSignal(AliSignal& s) +{ +// Relate an AliSignal object to this track. + if (!fSignals) fSignals=new TObjArray(); + fNsig++; + fSignals->Add(&s); +} +/////////////////////////////////////////////////////////////////////////// +void AliTrack::RemoveSignal(AliSignal& s) +{ +// Remove related AliSignal object to this track. + if (fSignals) + { + AliSignal* test=(AliSignal*)fSignals->Remove(&s); + if (test) + { + fNsig--; + fSignals->Compress(); + } + } +} +/////////////////////////////////////////////////////////////////////////// +Int_t AliTrack::GetNsignals() +{ +// Provide the number of related AliSignals. + return fNsig; +} +/////////////////////////////////////////////////////////////////////////// +AliSignal* AliTrack::GetSignal(Int_t j) +{ +// Provide the related AliSignal number j. +// Note : j=1 denotes the first signal. + if ((j >= 1) && (j <= fNsig)) + { + return (AliSignal*)fSignals->At(j-1); + } + else + { + cout << " *AliTrack* signal number : " << j << " out of range." << endl; + cout << " -- Signal number 1 (if any) returned." << endl; + return (AliSignal*)fDecays->At(0); + } +} +/////////////////////////////////////////////////////////////////////////// +void AliTrack::SetBeginPoint(AliPosition p) +{ +// Store the position of the track begin-point. + fBegin=p; +} +/////////////////////////////////////////////////////////////////////////// +AliPosition AliTrack::GetBeginPoint() +{ +// Provide the position of the track begin-point. + return fBegin; +} +/////////////////////////////////////////////////////////////////////////// +void AliTrack::SetEndPoint(AliPosition p) +{ +// Store the position of the track end-point. + fEnd=p; +} +/////////////////////////////////////////////////////////////////////////// +AliPosition AliTrack::GetEndPoint() +{ +// Provide the position of the track end-point. + return fEnd; +} +/////////////////////////////////////////////////////////////////////////// diff --git a/RALICE/AliTrack.h b/RALICE/AliTrack.h index 8bc4736bfcb..c018a7913c3 100644 --- a/RALICE/AliTrack.h +++ b/RALICE/AliTrack.h @@ -1,57 +1,18 @@ #ifndef ALITRACK_H #define ALITRACK_H + /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * * See cxx source for full Copyright notice */ /* $Id$ */ -/////////////////////////////////////////////////////////////////////////// -// Class AliTrack -// Handling of the attributes of a reconstructed particle track. -// -// Coding example : -// ---------------- -// -// Float_t a[4]={195.,1.2,-0.04,8.5}; -// Ali4Vector pmu; -// pmu.SetVector(a,"car"); -// AliTrack t1; -// t1.Set4Momentum(pmu); -// -// Float_t b[3]={1.2,-0.04,8.5}; -// Ali3Vector p; -// p.SetVector(b,"car"); -// AliTrack t2; -// t2.Set3Momentum(p); -// t2.SetCharge(0); -// t2.SetMass(1.115); -// -// t1.Info(); -// t2.Info(); -// -// Float_t pi=acos(-1.); -// Float_t thcms=0.2*pi; // decay theta angle in cms -// Float_t phicms=pi/4.; // decay theta angle in cms -// Float_t m1=0.938; -// Float_t m2=0.140; -// t2.Decay(m1,m2,thcms,phicms); // Track t2 decay : Lambda -> proton + pion -// -// t2.List(); -// -// Int_t ndec=t2.GetNdecay(); -// AliTrack* d1=t2.GetDecayTrack(1); // Access to decay track number 1 -// AliTrack* d2=t2.GetDecayTrack(2); // Access to decay track number 2 -// -// Note : All quantities are in GeV, GeV/c or GeV/c**2 -// -//--- NvE 10-jul-1997 UU-SAP Utrecht -//--- Modified : NvE 06-apr-1999 UU-SAP Utrecht to inherit from Ali4Vector -/////////////////////////////////////////////////////////////////////////// - + #include "TObject.h" #include "TObjArray.h" +#include "AliSignal.h" #include "AliBoost.h" +#include "AliPosition.h" class AliTrack : public TObject,public Ali4Vector { @@ -61,7 +22,7 @@ class AliTrack : public TObject,public Ali4Vector void Reset(); // Reset all values to 0 void Set4Momentum(Ali4Vector& p); // Set track 4-momentum void Set3Momentum(Ali3Vector& p); // Set track 3-momentum - void SetMass(Double_t m); // Set particle mass + void SetMass(Double_t m,Double_t dm=0); // Set particle mass and error void SetCharge(Float_t q); // Set particle charge void Info(TString f="car"); // Print track information for coord. frame f void List(TString f="car"); // Print track and decay level 1 information for coord. frame f @@ -74,16 +35,27 @@ class AliTrack : public TObject,public Ali4Vector void Decay(Double_t m1,Double_t m2,Double_t thcms,Double_t phicms); // Perform 2-body decay Int_t GetNdecay(); // Provide number of decay products AliTrack* GetDecayTrack(Int_t j); // Access to decay produced track number j + void AddSignal(AliSignal& s); // Relate an AliSignal to this track + void RemoveSignal(AliSignal& s); // Remove related AliSignal from this track + Int_t GetNsignals(); // Provide number of related AliSignals + AliSignal* GetSignal(Int_t j); // Access to the related AliSignal number j + void SetBeginPoint(AliPosition p);// Set the track begin-point + AliPosition GetBeginPoint(); // Provide the track begin-point + void SetEndPoint(AliPosition p); // Set the track end-point + AliPosition GetEndPoint(); // Provide the track end-point protected: - Double_t fM; // The mass of the particle - Float_t fQ; // The charge of the particle - Int_t fNdec; // The number of decay products - TObjArray* fDecays; // The array of decay produced tracks for output + Float_t fQ; // The charge of the particle + Int_t fNdec; // The number of decay products + TObjArray* fDecays; // The array of decay produced tracks + Int_t fNsig; // The number of related AliSignals + TObjArray* fSignals; // The array of related AliSignals + AliPosition fBegin; // The begin-point of the track + AliPosition fEnd; // The end-point of the track private: void Dump(AliTrack* t,Int_t n,TString f); // Recursively print all decay levels - ClassDef(AliTrack,1) // Class definition to enable ROOT I/O + ClassDef(AliTrack,1) // Handling of the attributes of a reconstructed particle track. }; #endif diff --git a/RALICE/AliVertex.cxx b/RALICE/AliVertex.cxx index 12d534df0b0..a670151e78f 100644 --- a/RALICE/AliVertex.cxx +++ b/RALICE/AliVertex.cxx @@ -15,18 +15,112 @@ /* $Log$ +Revision 1.3 1999/09/29 09:24:28 fca +Introduction of the Copyright and cvs Log + */ +/////////////////////////////////////////////////////////////////////////// +// Class AliVertex +// Creation and investigation of an AliVertex. +// An AliVertex can be constructed by adding AliTracks and/or AliJets. +// +// Note : Also (secondary) vertices can be added to a vertex. +// +// Coding example to make 3 vertices v1, v2 and v3. +// ------------------------------------------------ +// v1 contains the tracks 1,2,3 and 4 +// v2 contains the tracks 5,6 and 7 +// v3 contains the jets 1 and 2 +// +// AliTrack t1,t2,t3,t4,t5,t6,t7; +// ... +// ... // code to fill the track data +// ... +// +// AliJet j1,j2; +// ... +// ... // code to fill the jet data +// ... +// +// AliVertex v1(5); +// +// v1.Add(t1); +// v1.Add(t2); +// v1.Add(t3); +// v1.Add(t4); +// +// Float_t r1[3]={2.4,0.1,-8.5}; +// v1.SetPosition(r1,"car"); +// +// AliVertex v2(2); +// v2.Add(t5); +// v2.Add(t6); +// v2.Add(t7); +// +// Float_t r2[3]={1.6,-3.2,5.7}; +// v2.SetPosition(r2,"car"); +// +// AliVertex v3; +// +// v3.Add(j1); +// v3.Add(j2); +// +// Float_t r3[3]={6.2,4.8,1.3}; +// v3.SetPosition(r3,"car"); +// +// v1.Info("sph"); +// v2.ListAll(); +// v3.List("cyl"); +// +// Float_t e1=v1.GetEnergy(); +// Ali3Vector p1=v1.Get3Momentum(); +// Float_t loc[3]; +// v1.GetPosition(loc,"sph"); +// AliPosition r=v2.GetPosition(); +// r.Info(); +// Int_t nt=v2.GetNtracks(); +// AliTrack* tv=v2.GetTrack(1); // Access track number 1 of Vertex v2 +// +// Specify the vertices v2 and v3 as secondary vertices of v1 +// +// v1.Add(v2); +// v1.Add(v3); +// +// v1.List(); +// +// Int_t nv=v1.GetNvtx(); +// AliVertex* vx=v1.GetVertex(1); // Access 1st secondary vertex of v1 +// Float_t e=vx->GetEnergy(); +// +// Float_t M=v1.GetInvmass(); +// +// Reconstruct Vertex v1 from scratch +// +// v1.Reset(); +// v1.SetNvmax(25); // Increase initial no. of sec. vertices +// v1.Add(t3); +// v1.Add(t7); +// v1.Add(j2); +// Float_t pos[3]={7,9,4}; +// v1.SetPosition(pos,"car"); +// +// Note : All quantities are in GeV, GeV/c or GeV/c**2 +// +//--- Author: Nick van Eijndhoven 04-apr-1998 UU-SAP Utrecht +//- Modified: NvE 08-apr-1999 UU-SAP Utrecht to inherit from AliJet +/////////////////////////////////////////////////////////////////////////// + #include "AliVertex.h" ClassImp(AliVertex) // Class implementation to enable ROOT I/O AliVertex::AliVertex() { -// Default constructor -// All variables initialised to 0 -// Initial maximum number of tracks is set to the default value -// Initial maximum number of sec. vertices is set to the default value +// Default constructor. +// All variables initialised to 0. +// Initial maximum number of tracks is set to the default value. +// Initial maximum number of sec. vertices is set to the default value. fNvmax=0; fVertices=0; Reset(); @@ -120,7 +214,7 @@ void AliVertex::Add(AliVertex& v) // Update 4-momentum for current vertex fNvtx++; fVertices->Add(&v); - (*(Ali4Vector*)this)+=v; + (Ali4Vector)(*this)+=v; } /////////////////////////////////////////////////////////////////////////// void AliVertex::Info(TString f) diff --git a/RALICE/AliVertex.h b/RALICE/AliVertex.h index a02822c7102..3c36fbfbb8f 100644 --- a/RALICE/AliVertex.h +++ b/RALICE/AliVertex.h @@ -5,97 +5,6 @@ /* $Id$ */ -/////////////////////////////////////////////////////////////////////////// -// Class AliVertex -// Creation and investigation of an AliVertex. -// An AliVertex can be constructed by adding AliTracks and/or AliJets. -// -// Note : Also (secondary) vertices can be added to a vertex. -// -// Coding example to make 3 vertices v1, v2 and v3. -// ------------------------------------------------ -// v1 contains the tracks 1,2,3 and 4 -// v2 contains the tracks 5,6 and 7 -// v3 contains the jets 1 and 2 -// -// AliTrack t1,t2,t3,t4,t5,t6,t7; -// ... -// ... // code to fill the track data -// ... -// -// AliJet j1,j2; -// ... -// ... // code to fill the jet data -// ... -// -// AliVertex v1(5); -// -// v1.Add(t1); -// v1.Add(t2); -// v1.Add(t3); -// v1.Add(t4); -// -// Float_t r1[3]={2.4,0.1,-8.5}; -// v1.SetPosition(r1,"car"); -// -// AliVertex v2(2); -// v2.Add(t5); -// v2.Add(t6); -// v2.Add(t7); -// -// Float_t r2[3]={1.6,-3.2,5.7}; -// v2.SetPosition(r2,"car"); -// -// AliVertex v3; -// -// v3.Add(j1); -// v3.Add(j2); -// -// Float_t r3[3]={6.2,4.8,1.3}; -// v3.SetPosition(r3,"car"); -// -// v1.Info("sph"); -// v2.ListAll(); -// v3.List("cyl"); -// -// Float_t e1=v1.GetEnergy(); -// Ali3Vector p1=v1.Get3Momentum(); -// Float_t loc[3]; -// v1.GetPosition(loc,"sph"); -// AliPosition r=v2.GetPosition(); -// r.Info(); -// Int_t nt=v2.GetNtracks(); -// AliTrack* tv=v2.GetTrack(1); // Access track number 1 of Vertex v2 -// -// Specify the vertices v2 and v3 as secondary vertices of v1 -// -// v1.Add(v2); -// v1.Add(v3); -// -// v1.List(); -// -// Int_t nv=v1.GetNvtx(); -// AliVertex* vx=v1.GetVertex(1); // Access 1st secondary vertex of v1 -// Float_t e=vx->GetEnergy(); -// -// Float_t M=v1.GetInvmass(); -// -// Reconstruct Vertex v1 from scratch -// -// v1.Reset(); -// v1.SetNvmax(25); // Increase initial no. of sec. vertices -// v1.Add(t3); -// v1.Add(t7); -// v1.Add(j2); -// Float_t pos[3]={7,9,4}; -// v1.SetPosition(pos,"car"); -// -// Note : All quantities are in GeV, GeV/c or GeV/c**2 -// -//--- NvE 04-apr-1998 UU-SAP Utrecht -//--- Modified : NvE 08-apr-1999 UU-SAP Utrecht to inherit from AliJet -/////////////////////////////////////////////////////////////////////////// - #include #include @@ -131,6 +40,6 @@ class AliVertex : public AliJet,public AliPosition private: void Dump(AliVertex* v,Int_t n,TString f); // Recursively print all sec. vertices - ClassDef(AliVertex,1) // Class definition to enable ROOT I/O + ClassDef(AliVertex,1) // Creation and investigation of an AliVertex. }; #endif diff --git a/RALICE/Makefile b/RALICE/Makefile index 3c939f6b1e6..da380ea13b3 100644 --- a/RALICE/Makefile +++ b/RALICE/Makefile @@ -12,7 +12,8 @@ PACKAGE = RALICE SRCS = Ali3Vector.cxx Ali4Vector.cxx AliBoost.cxx AliCalcluster.cxx \ AliCalmodule.cxx AliCalorimeter.cxx AliInvmass.cxx AliJet.cxx \ AliMath.cxx AliPosition.cxx AliRandom.cxx AliSample.cxx AliSignal.cxx \ - AliTrack.cxx AliVertex.cxx + AliTrack.cxx AliVertex.cxx Ali3VectorObj.cxx Ali4VectorObj.cxx \ + AliPositionObj.cxx # C++ Headers diff --git a/RALICE/RALICELinkDef.h b/RALICE/RALICELinkDef.h index 2a7ce24820a..31d52dffa09 100644 --- a/RALICE/RALICELinkDef.h +++ b/RALICE/RALICELinkDef.h @@ -1,18 +1,20 @@ -#ifdef __CINT__ //////////////////////////////////////////////////////////////////////////////// // All classes of RALICE // This class list is used to create the RALICE dictionary via rootcint // in the automatic installation of the ROOT loadable library. // -// Note : Headers have also to be entered into the list in file allhead.h +// Note : Headers have also to be entered into the list in the file +// RALICEHeaders.h // //--- NvE 12-apr-1998 UU-SAP Utrecht //////////////////////////////////////////////////////////////////////////////// + /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * * See cxx source for full Copyright notice */ /* $Id$ */ +#ifdef __CINT__ #pragma link off all globals; #pragma link off all classes; #pragma link off all functions; @@ -21,9 +23,12 @@ #pragma link C++ class AliSample; #pragma link C++ class AliRandom; #pragma link C++ class Ali3Vector; + #pragma link C++ class Ali3VectorObj; #pragma link C++ class Ali4Vector; + #pragma link C++ class Ali4VectorObj; #pragma link C++ class AliBoost; #pragma link C++ class AliPosition; + #pragma link C++ class AliPositionObj; #pragma link C++ class AliSignal; #pragma link C++ class AliCalorimeter; #pragma link C++ class AliCalmodule; diff --git a/RALICE/history.txt b/RALICE/history.txt index 268a1c1819b..692cd42544b 100644 --- a/RALICE/history.txt +++ b/RALICE/history.txt @@ -177,3 +177,47 @@ 28-jun-1999 NvE Ali4Vector casting changed in AliVertex::Add() and some explicit type conversions added and an unused variable removed in AliInvmass to prevent g++ errors/warnings (thanks to Eugene van der Pijll). +23-sep-1999 NvE Errors and error propagation introduced in Ali3Vector in view of track + reconstruction/extrapolation development. + Also AliPosition and AliSignal updated accordingly by introducing the + SetPositionErrors(), SetSignalErrors() and Get memberfunctions. + Note : Errors (propagation) not yet fully implemented in Ali4Vector and + AliBoost. +24-sep-1999 NvE In Ali4Vector internally the Lorentz invariant (x^mu x_mu) is now stored + instead of the scalar part x^0. This will yield better precision and + e.g. automatically conserves the particle identity (mass) in elastic + collisions. +08-oct-1999 NvE GetResultError() introduced in Ali3Vector to provide error information + on results obtained from operations which yield a scalar. + Examples are the error on the norm (GetNorm) and the dotproduct (Dot). +13-oct-1999 NvE Errors and error propagation fully implemented in Ali4Vector. +15-oct-1999 NvE Algorithms for error calculations optimised for accuracy in Ali3Vector + and Ali4Vector. + Also particle mass datamember removed from AliTrack, since this is now + automatically handled via the SetInvariant()/GetInvariant() memberfunctions + of Ali4Vector. +16-oct-1999 NvE Storage of multiple signal values (with errors) implemented in AliSignal + and AliCalmodule updated accordingly. + All documentation moved from the .h files into the .cxx files and also + Copyright and cvs logs introduced. + Html documentation generated for all classes using the ROOT automatic + documentation generator facility. +18-oct-1999 NvE Classes Ali3VectorObj, Ali4VectorObj and AliPositionObj introduced. +20-oct-1999 NvE AliTrack::AddSignal() & co. added to enable relating AliSignals to a certain + AliTrack object in view of track reconstruction development. + Also memberfunction Info() added to AliSignal. +24-oct-1999 NvE Full error propagation implemented in AliBoost and obsolete memberfunction + AliBoost::SetGamma() removed. +25-oct-1999 NvE Undefined "dtheta2" fixed in Ali3Vector::GetErrors() thanks to Rene Brun. +29-oct-1999 NvE Compress() invoked for TObjArray fModules after removal of a single module + in AliCalorimeter::Reset(). + Begin- and endpoint introduced for AliTrack. +30-oct-1999 NvE Pointer handling introduced instead of object copying in AliCalorimeter::Sortm + to enhance speed. Also AliCalorimeter::GetModule(row,col) introduced. + Array creation moved out of default constructor of AliSignal to comply with + ROOT I/O requirements. +31-oct-1999 NvE AliCalmodule::GetSignal() removed; the AliSignal memberfunction is used + instead and AliCalorimeter::GetSignal() takes care of the dead modules. + AliCalcluster::Start updated accordingly. + New memberfunctions GetVetoLevel() and HasVetoHit() introduced + for AliCalcluster. diff --git a/html/.rootrc b/html/.rootrc index 954b01683e8..ca60dce9e40 100644 --- a/html/.rootrc +++ b/html/.rootrc @@ -9,7 +9,7 @@ WinNT.*.Root.MacroPath: ./;$(ROOTSYS)/macros # THtml specific settings. Root.Html.OutputDir: roothtml -Unix.*.Root.Html.SourceDir: ../ALIROOT/:../CASTOR/:../EVGEN/:../FMD/:../ITS/:../MUON/:../PDF/:../PHOS/:../PMD/:../RICH/:../STEER/:../STRUCT/:../TGeant3/:../TOF/:../TPC/:../TRD/:../ZDC/:../CPV:../START +Unix.*.Root.Html.SourceDir: ../ALIROOT/:../CASTOR/:../EVGEN/:../FMD/:../ITS/:../MUON/:../PDF/:../PHOS/:../PMD/:../RICH/:../STEER/:../STRUCT/:../TGeant3/:../TOF/:../TPC/:../TRD/:../ZDC/:../CPV:../START:../RALICE #WinNT.*.Root.Html.SourceDir: ./ #Root.Html.Author: //*-- Author : #Root.Html.Author: Fons Rademakers -- 2.43.0