1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////
20 // Handling of positions in various reference frames.
22 // This class is meant to serve as a base class for ALICE objects
23 // that have a unique position in 3-dimensional space.
27 // Positions (r), errors (e) and reference frames (f) are specified via
29 // SetPosition(Float_t* r,TString f)
30 // SetPositionErrors(Float_t* e,TString f)
32 // under the following conventions :
34 // f="car" ==> r in Cartesian coordinates (x,y,z)
35 // f="sph" ==> r in Spherical coordinates (r,theta,phi)
36 // f="cyl" ==> r in Cylindrical coordinates (rho,phi,z)
38 // All angles are in radians.
44 // Float_t pos[3]={-1,25,7};
45 // Float_t err[3]={0.08,1.85,0.5};
46 // q.SetPosition(pos,"car");
47 // q.SetPositionErrors(pos,"car");
48 // Float_t loc[3],dloc[3];
49 // q.GetPosition(loc,"sph");
50 // q.GetPositionErrors(dloc,"sph");
52 //--- Author: Nick van Eijndhoven 06-feb-1999 UU-SAP Utrecht
53 //- Modified: NvE $Date$ UU-SAP Utrecht
54 ///////////////////////////////////////////////////////////////////////////
56 #include "AliPosition.h"
57 #include "Riostream.h"
59 ClassImp(AliPosition) // Class implementation to enable ROOT I/O
61 AliPosition::AliPosition()
63 // Creation of an AliPosition object and initialisation of parameters
65 ///////////////////////////////////////////////////////////////////////////
66 AliPosition::~AliPosition()
68 // Destructor to delete dynamically allocated memory
70 ///////////////////////////////////////////////////////////////////////////
71 AliPosition::AliPosition(const AliPosition& p) : Ali3Vector(p)
75 ///////////////////////////////////////////////////////////////////////////
76 void AliPosition::SetPosition(Double_t* r,TString f)
78 // Store position according to reference frame f
81 ///////////////////////////////////////////////////////////////////////////
82 void AliPosition::GetPosition(Double_t* r,TString f)
84 // Provide position according to reference frame f
87 ///////////////////////////////////////////////////////////////////////////
88 void AliPosition::SetPosition(Float_t* r,TString f)
90 // Store position according to reference frame f
93 ///////////////////////////////////////////////////////////////////////////
94 void AliPosition::GetPosition(Float_t* r,TString f)
96 // Provide position according to reference frame f
99 ///////////////////////////////////////////////////////////////////////////
100 AliPosition& AliPosition::GetPosition()
105 ///////////////////////////////////////////////////////////////////////////
106 void AliPosition::SetPosition(Ali3Vector& r)
110 r.GetVector(a,"sph");
112 r.GetErrors(a,"car");
115 ///////////////////////////////////////////////////////////////////////////
116 void AliPosition::SetPositionErrors(Double_t* r,TString f)
118 // Store position errors according to reference frame f
121 ///////////////////////////////////////////////////////////////////////////
122 void AliPosition::GetPositionErrors(Double_t* r,TString f)
124 // Provide position errors according to reference frame f
127 ///////////////////////////////////////////////////////////////////////////
128 void AliPosition::SetPositionErrors(Float_t* r,TString f)
130 // Store position errors according to reference frame f
133 ///////////////////////////////////////////////////////////////////////////
134 void AliPosition::GetPositionErrors(Float_t* r,TString f)
136 // Provide position errors according to reference frame f
139 ///////////////////////////////////////////////////////////////////////////
140 void AliPosition::ResetPosition()
142 // Reset the position and corresponding errors to 0.
143 Double_t r[3]={0,0,0};
147 ///////////////////////////////////////////////////////////////////////////
148 Double_t AliPosition::GetDistance(AliPosition& p)
150 // Provide distance to position p.
151 // The error on the result can be obtained as usual by invoking
152 // GetResultError() afterwards.
153 Ali3Vector d=(Ali3Vector)((*this)-p);
154 Double_t dist=d.GetNorm();
155 fDresult=d.GetResultError();
158 ///////////////////////////////////////////////////////////////////////////