befe2c08 |
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 | //----------------------------------------------------------------- |
17 | // Implementation of the alignment object class through |
18 | // the derived concrete representation of alignment object class: |
19 | // AliAlignObjMatrix derived from the base class AliAlignObj |
20 | //----------------------------------------------------------------- |
21 | |
22 | #include "AliAlignObj.h" |
23 | #include "AliAlignObjMatrix.h" |
24 | //#include "AliLog.h" |
25 | |
26 | ClassImp(AliAlignObjMatrix) |
27 | |
28 | //_____________________________________________________________________________ |
29 | AliAlignObjMatrix::AliAlignObjMatrix() : AliAlignObj() |
30 | { |
31 | // Default constructor |
32 | // |
33 | } |
34 | |
35 | //_____________________________________________________________________________ |
d9cc42ed |
36 | AliAlignObjMatrix::AliAlignObjMatrix(const char* volpath, UShort_t voluid, Double_t x, Double_t y, Double_t z, Double_t psi, Double_t theta, Double_t phi) : AliAlignObj(volpath, voluid) |
befe2c08 |
37 | { |
38 | // standard constructor with 3 translation + 3 rotation parameters |
39 | // |
befe2c08 |
40 | SetTranslation(x, y, z); |
41 | SetRotation(psi, theta, phi); |
42 | } |
43 | |
44 | //_____________________________________________________________________________ |
d9cc42ed |
45 | AliAlignObjMatrix::AliAlignObjMatrix(const char* volpath, ELayerID layerId, Int_t volId, Double_t x, Double_t y, Double_t z, Double_t psi, Double_t theta, Double_t phi, Bool_t global) throw (const Char_t *) : AliAlignObj(volpath,layerId,volId) |
befe2c08 |
46 | { |
47 | // standard constructor with 3 translation + 3 rotation parameters |
48c8e89a |
48 | // If the user explicitly sets the global variable to kFALSE then the |
49 | // parameters are interpreted as giving the local transformation. |
50 | // This requires to have a gGeoMenager active instance, otherwise the |
51 | // constructor will fail (no object created) |
52 | // |
48c8e89a |
53 | if(global){ |
54 | SetTranslation(x, y, z); |
55 | SetRotation(psi, theta, phi); |
56 | }else{ |
57 | if(!SetLocalPars(x,y,z,psi,theta,phi)) throw "Alignment object creation failed (TGeo instance needed)!\n"; |
58 | } |
befe2c08 |
59 | } |
60 | |
48c8e89a |
61 | |
befe2c08 |
62 | //_____________________________________________________________________________ |
d9cc42ed |
63 | AliAlignObjMatrix::AliAlignObjMatrix(const char* volpath, UShort_t volUID, TGeoMatrix& m) : AliAlignObj(volpath,volUID) |
64 | { |
65 | // standard constructor with TGeoMatrix |
66 | // |
67 | SetTranslation(m); |
68 | SetRotation(m); |
69 | } |
70 | |
71 | //_____________________________________________________________________________ |
72 | AliAlignObjMatrix::AliAlignObjMatrix(const char* volpath, ELayerID layerId, Int_t volId, TGeoMatrix& m) : AliAlignObj(volpath,layerId,volId) |
befe2c08 |
73 | { |
74 | // standard constructor with TGeoMatrix |
75 | // |
befe2c08 |
76 | SetTranslation(m); |
77 | SetRotation(m); |
78 | } |
79 | |
80 | //_____________________________________________________________________________ |
c5304981 |
81 | AliAlignObjMatrix::AliAlignObjMatrix(const AliAlignObj& theAlignObj) : |
befe2c08 |
82 | AliAlignObj(theAlignObj) |
83 | { |
84 | //copy constructor |
85 | // |
86 | Double_t tr[3]; |
87 | theAlignObj.GetTranslation(tr); |
88 | SetTranslation(tr[0],tr[1],tr[2]); |
89 | Double_t rot[3]; |
90 | theAlignObj.GetAngles(rot); |
91 | SetRotation(rot[0],rot[1],rot[2]); |
92 | } |
93 | |
94 | //_____________________________________________________________________________ |
c5304981 |
95 | AliAlignObjMatrix &AliAlignObjMatrix::operator =(const AliAlignObj& theAlignObj) |
befe2c08 |
96 | { |
97 | // assignment operator |
98 | // |
99 | if(this==&theAlignObj) return *this; |
100 | ((AliAlignObj *)this)->operator=(theAlignObj); |
101 | Double_t tr[3]; |
102 | theAlignObj.GetTranslation(tr); |
103 | SetTranslation(tr[0],tr[1],tr[2]); |
104 | Double_t rot[3]; |
105 | theAlignObj.GetAngles(rot); |
106 | SetRotation(rot[0],rot[1],rot[2]); |
107 | return *this; |
108 | } |
109 | |
110 | //_____________________________________________________________________________ |
111 | AliAlignObjMatrix::~AliAlignObjMatrix() |
112 | { |
113 | // Destructor |
114 | // |
115 | } |
116 | |
117 | //_____________________________________________________________________________ |
118 | void AliAlignObjMatrix::SetTranslation(Double_t x, Double_t y, Double_t z) |
119 | { |
120 | Double_t tr[3]; |
121 | tr[0]=x; tr[1]=y; tr[2]=z; |
122 | fMatrix.SetTranslation(tr); |
123 | } |
124 | |
125 | //_____________________________________________________________________________ |
126 | void AliAlignObjMatrix::SetTranslation(const TGeoMatrix& m) |
127 | { |
128 | const Double_t *tr = m.GetTranslation(); |
129 | fMatrix.SetTranslation(tr); |
130 | } |
131 | |
132 | //_____________________________________________________________________________ |
133 | void AliAlignObjMatrix::SetRotation(Double_t psi, Double_t theta, Double_t phi) |
134 | { |
135 | Double_t angles[3] = {psi, theta, phi}; |
136 | Double_t rot[9]; |
137 | AnglesToMatrix(angles,rot); |
138 | fMatrix.SetRotation(rot); |
139 | } |
140 | |
141 | //_____________________________________________________________________________ |
142 | Bool_t AliAlignObjMatrix::SetRotation(const TGeoMatrix& m) |
143 | { |
144 | const Double_t* rot = m.GetRotationMatrix(); |
145 | fMatrix.SetRotation(rot); |
146 | return kTRUE; |
147 | } |
148 | |
149 | //_____________________________________________________________________________ |
150 | void AliAlignObjMatrix::SetMatrix(const TGeoMatrix& m) |
151 | { |
152 | // Set rotation matrix and translation |
153 | // using TGeoMatrix |
154 | SetTranslation(m); |
155 | SetRotation(m); |
156 | } |
157 | |
158 | //_____________________________________________________________________________ |
159 | void AliAlignObjMatrix::SetPars(Double_t x, Double_t y, Double_t z, |
160 | Double_t psi, Double_t theta, Double_t phi) |
161 | { |
162 | // Set rotation matrix and translation |
163 | // using 3 angles and 3 translations |
164 | SetTranslation(x,y,z); |
165 | SetRotation(psi,theta,phi); |
166 | } |
167 | |
168 | //_____________________________________________________________________________ |
169 | void AliAlignObjMatrix::GetTranslation(Double_t *tr) const |
170 | { |
171 | // Get Translation from TGeoMatrix |
172 | const Double_t* translation = fMatrix.GetTranslation(); |
173 | tr[0] = translation[0]; |
174 | tr[1] = translation[1]; |
175 | tr[2] = translation[2]; |
176 | } |
177 | |
178 | //_____________________________________________________________________________ |
179 | Bool_t AliAlignObjMatrix::GetAngles(Double_t *angles) const |
180 | { |
181 | // Get rotation angles from the TGeoHMatrix |
182 | const Double_t* rot = fMatrix.GetRotationMatrix(); |
183 | return MatrixToAngles(rot,angles); |
184 | } |
185 | |
186 | //_____________________________________________________________________________ |
187 | void AliAlignObjMatrix::GetPars(Double_t tr[], Double_t angles[]) const |
188 | { |
189 | GetTranslation(tr); |
190 | GetAngles(angles); |
191 | } |
192 | |
193 | //_____________________________________________________________________________ |
194 | void AliAlignObjMatrix::GetMatrix(TGeoHMatrix& m) const |
195 | { |
196 | // Get TGeoHMatrix |
197 | // |
198 | const Double_t *tr = fMatrix.GetTranslation(); |
199 | m.SetTranslation(tr); |
200 | const Double_t *rot = fMatrix.GetRotationMatrix(); |
201 | m.SetRotation(rot); |
202 | } |
203 | |
03b18860 |
204 | //_____________________________________________________________________________ |
205 | AliAlignObj& AliAlignObjMatrix::Inverse() const |
206 | { |
207 | // Return a temporary inverse of the alignment |
208 | // object. This means 'mis |
209 | static AliAlignObjMatrix a; |
210 | a = *this; |
211 | |
212 | TGeoHMatrix m; |
213 | GetMatrix(m); |
214 | a.SetMatrix(m.Inverse()); |
215 | |
216 | return a; |
217 | } |