//
// Note :
// ------
-// Positions (r), errors (e) and reference frames (f) are specified via
+// Positions (r), errors (e), reference frames (f) and angular units (u)
+// are specified via
//
-// SetPosition(Float_t* r,TString f)
-// SetPositionErrors(Float_t* e,TString f)
+// SetPosition(Float_t* r,TString f,TString u)
+// SetPositionErrors(Float_t* e,TString f,TString u)
//
// under the following conventions :
//
// f="sph" ==> r in Spherical coordinates (r,theta,phi)
// f="cyl" ==> r in Cylindrical coordinates (rho,phi,z)
//
-// All angles are in radians.
+// u="rad" ==> angles in radians
+// u="deg" ==> angles in degrees
//
-// The unit scale for the coordinates can be defined by the user
+// The "f" and "u" facilities only serve as a convenient user interface.
+// Internally the actual storage of the various components is performed
+// in a unique way. This allows setting/retrieval of vector components in a
+// user selected frame/unit convention at any time.
+//
+// The metric unit scale for the coordinates can be defined by the user
// via the SetUnitScale() memberfunction.
// This enables standardised expressions using numerical values of
// physical constants by means of the GetUnitScale() memberfunction.
-// By default the unit scale is set to cm, corresponding to invokation
-// of SetUnitScale(0.01).
+// By default the unit scale is set to meter, corresponding to invokation
+// of SetUnitScale(1).
+// The user can specify a certain required metric unit scale in retreiving
+// position components and/or distances.
+// Please refer to the corresponding member functions for further details.
//
//
// Example :
// q.SetPosition(pos,"car");
// q.SetPositionErrors(pos,"car");
// Float_t loc[3],dloc[3];
-// q.GetPosition(loc,"sph");
-// q.GetPositionErrors(dloc,"sph");
+// q.GetPosition(loc,"sph","deg");
+// q.GetPositionErrors(dloc,"sph","deg");
//
//--- Author: Nick van Eijndhoven 06-feb-1999 UU-SAP Utrecht
//- Modified: NvE $Date$ UU-SAP Utrecht
{
// Creation of an AliPosition object and initialisation of parameters.
// The unit scale for position coordinates is initialised to cm.
- fScale=0.01;
+ fScale=1;
+ fTstamp=0;
}
///////////////////////////////////////////////////////////////////////////
AliPosition::~AliPosition()
{
// Destructor to delete dynamically allocated memory
+ if (fTstamp)
+ {
+ delete fTstamp;
+ fTstamp=0;
+ }
}
///////////////////////////////////////////////////////////////////////////
AliPosition::AliPosition(const AliPosition& p) : Ali3Vector(p)
{
// Copy constructor
fScale=p.fScale;
+ fTstamp=0;
+ if (p.fTstamp) fTstamp=new AliTimestamp(*(p.fTstamp));
}
///////////////////////////////////////////////////////////////////////////
-void AliPosition::SetPosition(Double_t* r,TString f)
+void AliPosition::SetPosition(Double_t* r,TString f,TString u)
{
// Store position according to reference frame f
- SetVector(r,f);
+//
+// The string argument "u" allows to choose between different angular units
+// in case e.g. a spherical frame is selected.
+// u = "rad" : angles provided in radians
+// "deg" : angles provided in degrees
+//
+// The default is u="rad".
+
+ SetVector(r,f,u);
}
///////////////////////////////////////////////////////////////////////////
-void AliPosition::GetPosition(Double_t* r,TString f) const
+void AliPosition::GetPosition(Double_t* r,TString f,TString u,Float_t scale) const
{
// Provide position according to reference frame f
- GetVector(r,f);
+//
+// The string argument "u" allows to choose between different angular units
+// in case e.g. a spherical frame is selected.
+// u = "rad" : angles provided in radians
+// "deg" : angles provided in degrees
+//
+// The default is u="rad".
+//
+// By default the coordinates will be provided in the metric unit scale as
+// stored in the AliPosition object.
+// However, the user can select a different metric unit scale by
+// specification of the scale parameter.
+// The convention is that scale=1 corresponds to meter, so specification
+// of scale=0.01 will provide the position coordinates in cm.
+
+ Ali3Vector v=(Ali3Vector)(*this);
+ if (scale>0) v*=fScale/scale;
+ v.GetVector(r,f,u);
}
///////////////////////////////////////////////////////////////////////////
-void AliPosition::SetPosition(Float_t* r,TString f)
+void AliPosition::SetPosition(Float_t* r,TString f,TString u)
{
// Store position according to reference frame f
- SetVector(r,f);
+//
+// The string argument "u" allows to choose between different angular units
+// in case e.g. a spherical frame is selected.
+// u = "rad" : angles provided in radians
+// "deg" : angles provided in degrees
+//
+// The default is u="rad".
+
+ SetVector(r,f,u);
}
///////////////////////////////////////////////////////////////////////////
-void AliPosition::GetPosition(Float_t* r,TString f) const
+void AliPosition::GetPosition(Float_t* r,TString f,TString u,Float_t scale) const
{
// Provide position according to reference frame f
- GetVector(r,f);
+//
+// The string argument "u" allows to choose between different angular units
+// in case e.g. a spherical frame is selected.
+// u = "rad" : angles provided in radians
+// "deg" : angles provided in degrees
+//
+// The default is u="rad".
+//
+// By default the coordinates will be provided in the metric unit scale as
+// stored in the AliPosition object.
+// However, the user can select a different metric unit scale by
+// specification of the scale parameter.
+// The convention is that scale=1 corresponds to meter, so specification
+// of scale=0.01 will provide the position coordinates in cm.
+
+ Ali3Vector v=(Ali3Vector)(*this);
+ if (scale>0) v*=fScale/scale;
+ v.GetVector(r,f,u);
}
///////////////////////////////////////////////////////////////////////////
AliPosition& AliPosition::GetPosition()
SetErrors(a,"car");
}
///////////////////////////////////////////////////////////////////////////
-void AliPosition::SetPositionErrors(Double_t* r,TString f)
+void AliPosition::SetPositionErrors(Double_t* r,TString f,TString u)
{
// Store position errors according to reference frame f
- SetErrors(r,f);
+//
+// The string argument "u" allows to choose between different angular units
+// in case e.g. a spherical frame is selected.
+// u = "rad" : angles provided in radians
+// "deg" : angles provided in degrees
+//
+// The default is u="rad".
+
+ SetErrors(r,f,u);
}
///////////////////////////////////////////////////////////////////////////
-void AliPosition::GetPositionErrors(Double_t* r,TString f) const
+void AliPosition::GetPositionErrors(Double_t* r,TString f,TString u,Float_t scale) const
{
// Provide position errors according to reference frame f
- GetErrors(r,f);
+//
+// The string argument "u" allows to choose between different angular units
+// in case e.g. a spherical frame is selected.
+// u = "rad" : angles provided in radians
+// "deg" : angles provided in degrees
+//
+// The default is u="rad".
+//
+// By default the coordinate errors will be provided in the metric unit scale as
+// stored in the AliPosition object.
+// However, the user can select a different metric unit scale by
+// specification of the scale parameter.
+// The convention is that scale=1 corresponds to meter, so specification
+// of scale=0.01 will provide the position coordinate errors in cm.
+
+ Ali3Vector v=(Ali3Vector)(*this);
+ if (scale>0) v*=fScale/scale;
+ v.GetErrors(r,f,u);
}
///////////////////////////////////////////////////////////////////////////
-void AliPosition::SetPositionErrors(Float_t* r,TString f)
+void AliPosition::SetPositionErrors(Float_t* r,TString f,TString u)
{
// Store position errors according to reference frame f
- SetErrors(r,f);
+//
+// The string argument "u" allows to choose between different angular units
+// in case e.g. a spherical frame is selected.
+// u = "rad" : angles provided in radians
+// "deg" : angles provided in degrees
+//
+// The default is u="rad".
+
+ SetErrors(r,f,u);
}
///////////////////////////////////////////////////////////////////////////
-void AliPosition::GetPositionErrors(Float_t* r,TString f) const
+void AliPosition::GetPositionErrors(Float_t* r,TString f,TString u,Float_t scale) const
{
// Provide position errors according to reference frame f
- GetErrors(r,f);
+//
+// The string argument "u" allows to choose between different angular units
+// in case e.g. a spherical frame is selected.
+// u = "rad" : angles provided in radians
+// "deg" : angles provided in degrees
+//
+// The default is u="rad".
+//
+// By default the coordinate errors will be provided in the metric unit scale as
+// stored in the AliPosition object.
+// However, the user can select a different metric unit scale by
+// specification of the scale parameter.
+// The convention is that scale=1 corresponds to meter, so specification
+// of scale=0.01 will provide the position coordinate errors in cm.
+
+ Ali3Vector v=(Ali3Vector)(*this);
+ if (scale>0) v*=fScale/scale;
+ v.GetErrors(r,f,u);
}
///////////////////////////////////////////////////////////////////////////
void AliPosition::ResetPosition()
SetErrors(r,"car");
}
///////////////////////////////////////////////////////////////////////////
-Double_t AliPosition::GetDistance(AliPosition& p)
+Double_t AliPosition::GetDistance(AliPosition& p,Float_t scale)
{
// Provide distance of the current AliPosition to position p.
// The error on the result can be obtained as usual by invoking
// GetResultError() afterwards.
//
-// In the case of two positions with different unit scales, the distance
-// will be provided in the unit scale of the current AliPosition.
-// This implies that in such cases the results of r.GetDistance(q) and
-// q.GetDistance(r) will be numerically different.
-// As such it is possible to obtain a correctly computed distance between
-// positions which have different unit scales.
+// By default the distance will be provided in the metric unit scale of
+// the current AliPosition.
+// This implies that the results of r1.GetDistance(r2) and r2.GetDistance(r1)
+// may be numerically different in case r1 and r2 have different metric units.
+// However, the user can specify a required metric unit scale by specification
+// of the scale parameter.
+// The convention is that scale=1 corresponds to meter, so specification
+// of scale=0.01 will provide the distance in cm.
+// As such it is possible to obtain a correctly computed distance even in case
+// the position coordinates have a different unit scale.
// However, it is recommended to work always with one single unit scale.
//
Ali3Vector d=(Ali3Vector)p;
d=d-q;
Double_t dist=d.GetNorm();
fDresult=d.GetResultError();
+
+ if (scale>0)
+ {
+ dist*=fScale/scale;
+ fDresult*=fScale/scale;
+ }
return dist;
}
///////////////////////////////////////////////////////////////////////////
// Set the unit scale for the position coordinates.
// The scale is normalised w.r.t. the meter, so setting the unit scale
// to 0.01 means that all position coordinates are in cm.
-// By default the unit scale is set to cm in the AliPosition constructor.
+// By default the unit scale is set to meter in the AliPosition constructor.
// It is recommended to use one single unit scale throughout a complete
// analysis and/or simulation project.
//
return fScale;
}
///////////////////////////////////////////////////////////////////////////
+void AliPosition::SetTimestamp(AliTimestamp& t)
+{
+// Store the timestamp for this position.
+ if (fTstamp) delete fTstamp;
+ fTstamp=new AliTimestamp(t);
+}
+///////////////////////////////////////////////////////////////////////////
+AliTimestamp* AliPosition::GetTimestamp()
+{
+// Provide the timestamp of this position.
+ return fTstamp;
+}
+///////////////////////////////////////////////////////////////////////////
+void AliPosition::RemoveTimestamp()
+{
+// Remove the timestamp from this postion.
+ if (fTstamp)
+ {
+ delete fTstamp;
+ fTstamp=0;
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+void AliPosition::Data(TString f,TString u) const
+{
+// Provide all position/time information within the coordinate frame f.
+//
+// The string argument "u" allows to choose between different angular units
+// in case e.g. a spherical frame is selected.
+// u = "rad" : angles provided in radians
+// "deg" : angles provided in degrees
+//
+// The defaults are f="car" and u="rad".
+
+ Ali3Vector::Data(f,u);
+ cout << " Metric unit : " << fScale << " meter" << endl;
+ if (fTstamp) fTstamp->Date(1);
+}
+///////////////////////////////////////////////////////////////////////////