]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - RALICE/AliPosition.cxx
04-apr-2004 NvE SetMass() invoked from AliTrack::Set3Momentum to get also the energy...
[u/mrichter/AliRoot.git] / RALICE / AliPosition.cxx
... / ...
CommitLineData
1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16// $Id$
17
18///////////////////////////////////////////////////////////////////////////
19// Class AliPosition
20// Handling of positions in various reference frames.
21//
22// This class is meant to serve as a base class for ALICE objects
23// that have a unique position in 3-dimensional space.
24//
25// Note :
26// ------
27// Positions (r), errors (e) and reference frames (f) are specified via
28//
29// SetPosition(Float_t* r,TString f)
30// SetPositionErrors(Float_t* e,TString f)
31//
32// under the following conventions :
33//
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)
37//
38// All angles are in radians.
39//
40// The unit scale for the coordinates can be defined by the user
41// via the SetUnitScale() memberfunction.
42// This enables standardised expressions using numerical values of
43// physical constants by means of the GetUnitScale() memberfunction.
44// By default the unit scale is set to cm, corresponding to invokation
45// of SetUnitScale(0.01).
46//
47//
48// Example :
49// ---------
50//
51// AliPosition q;
52// Float_t pos[3]={-1,25,7};
53// Float_t err[3]={0.08,1.85,0.5};
54// q.SetPosition(pos,"car");
55// q.SetPositionErrors(pos,"car");
56// Float_t loc[3],dloc[3];
57// q.GetPosition(loc,"sph");
58// q.GetPositionErrors(dloc,"sph");
59//
60//--- Author: Nick van Eijndhoven 06-feb-1999 UU-SAP Utrecht
61//- Modified: NvE $Date$ UU-SAP Utrecht
62///////////////////////////////////////////////////////////////////////////
63
64#include "AliPosition.h"
65#include "Riostream.h"
66
67ClassImp(AliPosition) // Class implementation to enable ROOT I/O
68
69AliPosition::AliPosition()
70{
71// Creation of an AliPosition object and initialisation of parameters.
72// The unit scale for position coordinates is initialised to cm.
73 fScale=0.01;
74}
75///////////////////////////////////////////////////////////////////////////
76AliPosition::~AliPosition()
77{
78// Destructor to delete dynamically allocated memory
79}
80///////////////////////////////////////////////////////////////////////////
81AliPosition::AliPosition(const AliPosition& p) : Ali3Vector(p)
82{
83// Copy constructor
84 fScale=p.fScale;
85}
86///////////////////////////////////////////////////////////////////////////
87void AliPosition::SetPosition(Double_t* r,TString f)
88{
89// Store position according to reference frame f
90 SetVector(r,f);
91}
92///////////////////////////////////////////////////////////////////////////
93void AliPosition::GetPosition(Double_t* r,TString f) const
94{
95// Provide position according to reference frame f
96 GetVector(r,f);
97}
98///////////////////////////////////////////////////////////////////////////
99void AliPosition::SetPosition(Float_t* r,TString f)
100{
101// Store position according to reference frame f
102 SetVector(r,f);
103}
104///////////////////////////////////////////////////////////////////////////
105void AliPosition::GetPosition(Float_t* r,TString f) const
106{
107// Provide position according to reference frame f
108 GetVector(r,f);
109}
110///////////////////////////////////////////////////////////////////////////
111AliPosition& AliPosition::GetPosition()
112{
113// Provide position
114 return (*this);
115}
116///////////////////////////////////////////////////////////////////////////
117void AliPosition::SetPosition(Ali3Vector& r)
118{
119// Set position
120 Double_t a[3];
121 r.GetVector(a,"sph");
122 SetVector(a,"sph");
123 r.GetErrors(a,"car");
124 SetErrors(a,"car");
125}
126///////////////////////////////////////////////////////////////////////////
127void AliPosition::SetPositionErrors(Double_t* r,TString f)
128{
129// Store position errors according to reference frame f
130 SetErrors(r,f);
131}
132///////////////////////////////////////////////////////////////////////////
133void AliPosition::GetPositionErrors(Double_t* r,TString f) const
134{
135// Provide position errors according to reference frame f
136 GetErrors(r,f);
137}
138///////////////////////////////////////////////////////////////////////////
139void AliPosition::SetPositionErrors(Float_t* r,TString f)
140{
141// Store position errors according to reference frame f
142 SetErrors(r,f);
143}
144///////////////////////////////////////////////////////////////////////////
145void AliPosition::GetPositionErrors(Float_t* r,TString f) const
146{
147// Provide position errors according to reference frame f
148 GetErrors(r,f);
149}
150///////////////////////////////////////////////////////////////////////////
151void AliPosition::ResetPosition()
152{
153// Reset the position and corresponding errors to 0.
154 Double_t r[3]={0,0,0};
155 SetVector(r,"sph");
156 SetErrors(r,"car");
157}
158///////////////////////////////////////////////////////////////////////////
159Double_t AliPosition::GetDistance(AliPosition& p)
160{
161// Provide distance of the current AliPosition to position p.
162// The error on the result can be obtained as usual by invoking
163// GetResultError() afterwards.
164//
165// In the case of two positions with different unit scales, the distance
166// will be provided in the unit scale of the current AliPosition.
167// This implies that in such cases the results of r.GetDistance(q) and
168// q.GetDistance(r) will be numerically different.
169// As such it is possible to obtain a correctly computed distance between
170// positions which have different unit scales.
171// However, it is recommended to work always with one single unit scale.
172//
173 Ali3Vector d=(Ali3Vector)p;
174 Float_t pscale=p.GetUnitScale();
175 if ((pscale/fScale > 1.1) || (fScale/pscale > 1.1)) d=d*(pscale/fScale);
176 Ali3Vector q=(Ali3Vector)(*this);
177 d=d-q;
178 Double_t dist=d.GetNorm();
179 fDresult=d.GetResultError();
180 return dist;
181}
182///////////////////////////////////////////////////////////////////////////
183void AliPosition::SetUnitScale(Float_t s)
184{
185// Set the unit scale for the position coordinates.
186// The scale is normalised w.r.t. the meter, so setting the unit scale
187// to 0.01 means that all position coordinates are in cm.
188// By default the unit scale is set to cm in the AliPosition constructor.
189// It is recommended to use one single unit scale throughout a complete
190// analysis and/or simulation project.
191//
192// Note : This memberfunction does not modify the numerical values of
193// the position coordinates.
194// It only specifies their numerical meaning.
195//
196 if (s>0.)
197 {
198 fScale=s;
199 }
200 else
201 {
202 cout << " *AliPosition::SetUnitScale* Invalid argument s = " << s << endl;
203 }
204}
205///////////////////////////////////////////////////////////////////////////
206Float_t AliPosition::GetUnitScale() const
207{
208// Provide the unit scale for the position coordinates.
209// The scale is normalised w.r.t. the meter, so a unit scale of 0.01
210// means that all position coordinates are in cm.
211 return fScale;
212}
213///////////////////////////////////////////////////////////////////////////