]>
Commit | Line | Data |
---|---|---|
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 | // Example : | |
41 | // --------- | |
42 | // | |
43 | // AliPosition q; | |
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"); | |
51 | // | |
52 | //--- Author: Nick van Eijndhoven 06-feb-1999 UU-SAP Utrecht | |
53 | //- Modified: NvE $Date$ UU-SAP Utrecht | |
54 | /////////////////////////////////////////////////////////////////////////// | |
55 | ||
56 | #include "AliPosition.h" | |
57 | #include "Riostream.h" | |
58 | ||
59 | ClassImp(AliPosition) // Class implementation to enable ROOT I/O | |
60 | ||
61 | AliPosition::AliPosition() | |
62 | { | |
63 | // Creation of an AliPosition object and initialisation of parameters | |
64 | } | |
65 | /////////////////////////////////////////////////////////////////////////// | |
66 | AliPosition::~AliPosition() | |
67 | { | |
68 | // Destructor to delete dynamically allocated memory | |
69 | } | |
70 | /////////////////////////////////////////////////////////////////////////// | |
71 | AliPosition::AliPosition(const AliPosition& p) : Ali3Vector(p) | |
72 | { | |
73 | // Copy constructor | |
74 | } | |
75 | /////////////////////////////////////////////////////////////////////////// | |
76 | void AliPosition::SetPosition(Double_t* r,TString f) | |
77 | { | |
78 | // Store position according to reference frame f | |
79 | SetVector(r,f); | |
80 | } | |
81 | /////////////////////////////////////////////////////////////////////////// | |
82 | void AliPosition::GetPosition(Double_t* r,TString f) | |
83 | { | |
84 | // Provide position according to reference frame f | |
85 | GetVector(r,f); | |
86 | } | |
87 | /////////////////////////////////////////////////////////////////////////// | |
88 | void AliPosition::SetPosition(Float_t* r,TString f) | |
89 | { | |
90 | // Store position according to reference frame f | |
91 | SetVector(r,f); | |
92 | } | |
93 | /////////////////////////////////////////////////////////////////////////// | |
94 | void AliPosition::GetPosition(Float_t* r,TString f) | |
95 | { | |
96 | // Provide position according to reference frame f | |
97 | GetVector(r,f); | |
98 | } | |
99 | /////////////////////////////////////////////////////////////////////////// | |
100 | AliPosition& AliPosition::GetPosition() | |
101 | { | |
102 | // Provide position | |
103 | return (*this); | |
104 | } | |
105 | /////////////////////////////////////////////////////////////////////////// | |
106 | void AliPosition::SetPosition(Ali3Vector& r) | |
107 | { | |
108 | // Set position | |
109 | Double_t a[3]; | |
110 | r.GetVector(a,"sph"); | |
111 | SetVector(a,"sph"); | |
112 | r.GetErrors(a,"car"); | |
113 | SetErrors(a,"car"); | |
114 | } | |
115 | /////////////////////////////////////////////////////////////////////////// | |
116 | void AliPosition::SetPositionErrors(Double_t* r,TString f) | |
117 | { | |
118 | // Store position errors according to reference frame f | |
119 | SetErrors(r,f); | |
120 | } | |
121 | /////////////////////////////////////////////////////////////////////////// | |
122 | void AliPosition::GetPositionErrors(Double_t* r,TString f) | |
123 | { | |
124 | // Provide position errors according to reference frame f | |
125 | GetErrors(r,f); | |
126 | } | |
127 | /////////////////////////////////////////////////////////////////////////// | |
128 | void AliPosition::SetPositionErrors(Float_t* r,TString f) | |
129 | { | |
130 | // Store position errors according to reference frame f | |
131 | SetErrors(r,f); | |
132 | } | |
133 | /////////////////////////////////////////////////////////////////////////// | |
134 | void AliPosition::GetPositionErrors(Float_t* r,TString f) | |
135 | { | |
136 | // Provide position errors according to reference frame f | |
137 | GetErrors(r,f); | |
138 | } | |
139 | /////////////////////////////////////////////////////////////////////////// | |
140 | void AliPosition::ResetPosition() | |
141 | { | |
142 | // Reset the position and corresponding errors to 0. | |
143 | Double_t r[3]={0,0,0}; | |
144 | SetVector(r,"sph"); | |
145 | SetErrors(r,"car"); | |
146 | } | |
147 | /////////////////////////////////////////////////////////////////////////// | |
148 | Double_t AliPosition::GetDistance(AliPosition& p) | |
149 | { | |
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(); | |
156 | return dist; | |
157 | } | |
158 | /////////////////////////////////////////////////////////////////////////// |