]>
Commit | Line | Data |
---|---|---|
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" | |
befe2c08 | 24 | |
25 | ClassImp(AliAlignObjMatrix) | |
26 | ||
27 | //_____________________________________________________________________________ | |
fe12e09c | 28 | AliAlignObjMatrix::AliAlignObjMatrix() : |
29 | AliAlignObj(), | |
30 | fMatrix() | |
befe2c08 | 31 | { |
32 | // Default constructor | |
33 | // | |
34 | } | |
35 | ||
36 | //_____________________________________________________________________________ | |
9c1d7300 | 37 | AliAlignObjMatrix::AliAlignObjMatrix(const char* symname, UShort_t volUId, 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 *) : |
38 | AliAlignObj(symname,volUId), | |
fe12e09c | 39 | fMatrix() |
befe2c08 | 40 | { |
41 | // standard constructor with 3 translation + 3 rotation parameters | |
48c8e89a | 42 | // If the user explicitly sets the global variable to kFALSE then the |
43 | // parameters are interpreted as giving the local transformation. | |
44 | // This requires to have a gGeoMenager active instance, otherwise the | |
45 | // constructor will fail (no object created) | |
46 | // | |
48c8e89a | 47 | if(global){ |
b760c02e | 48 | SetPars(x, y, z, psi, theta, phi); |
48c8e89a | 49 | }else{ |
50 | if(!SetLocalPars(x,y,z,psi,theta,phi)) throw "Alignment object creation failed (TGeo instance needed)!\n"; | |
51 | } | |
befe2c08 | 52 | } |
53 | ||
48c8e89a | 54 | |
befe2c08 | 55 | //_____________________________________________________________________________ |
9c1d7300 | 56 | AliAlignObjMatrix::AliAlignObjMatrix(const char* symname, UShort_t volUId, TGeoMatrix& m, Bool_t global) throw (const Char_t *) : |
57 | AliAlignObj(symname,volUId), | |
fe12e09c | 58 | fMatrix() |
d9cc42ed | 59 | { |
60 | // standard constructor with TGeoMatrix | |
b760c02e | 61 | // If the user explicitly sets the global variable to kFALSE then the |
62 | // parameters are interpreted as giving the local transformation. | |
63 | // This requires to have a gGeoMenager active instance, otherwise the | |
64 | // constructor will fail (no object created) | |
d9cc42ed | 65 | // |
d9cc42ed | 66 | |
b760c02e | 67 | if (global) { |
68 | SetMatrix(m); | |
69 | } | |
70 | else { | |
71 | if (!SetLocalMatrix(m)) throw "Alignment object creation failed (TGeo instance needed)!\n"; | |
72 | } | |
befe2c08 | 73 | } |
74 | ||
75 | //_____________________________________________________________________________ | |
c5304981 | 76 | AliAlignObjMatrix::AliAlignObjMatrix(const AliAlignObj& theAlignObj) : |
fe12e09c | 77 | AliAlignObj(theAlignObj), |
78 | fMatrix() | |
befe2c08 | 79 | { |
80 | //copy constructor | |
81 | // | |
82 | Double_t tr[3]; | |
83 | theAlignObj.GetTranslation(tr); | |
84 | SetTranslation(tr[0],tr[1],tr[2]); | |
85 | Double_t rot[3]; | |
b760c02e | 86 | if (theAlignObj.GetAngles(rot)) |
87 | SetRotation(rot[0],rot[1],rot[2]); | |
befe2c08 | 88 | } |
89 | ||
90 | //_____________________________________________________________________________ | |
c5304981 | 91 | AliAlignObjMatrix &AliAlignObjMatrix::operator =(const AliAlignObj& theAlignObj) |
befe2c08 | 92 | { |
93 | // assignment operator | |
94 | // | |
95 | if(this==&theAlignObj) return *this; | |
96 | ((AliAlignObj *)this)->operator=(theAlignObj); | |
97 | Double_t tr[3]; | |
98 | theAlignObj.GetTranslation(tr); | |
99 | SetTranslation(tr[0],tr[1],tr[2]); | |
100 | Double_t rot[3]; | |
b760c02e | 101 | if (theAlignObj.GetAngles(rot)) |
102 | SetRotation(rot[0],rot[1],rot[2]); | |
103 | ||
befe2c08 | 104 | return *this; |
105 | } | |
106 | ||
107 | //_____________________________________________________________________________ | |
108 | AliAlignObjMatrix::~AliAlignObjMatrix() | |
109 | { | |
110 | // Destructor | |
111 | // | |
112 | } | |
113 | ||
114 | //_____________________________________________________________________________ | |
115 | void AliAlignObjMatrix::SetTranslation(Double_t x, Double_t y, Double_t z) | |
116 | { | |
ff2dbca1 | 117 | // set the translation coefficients of the data member matrix |
118 | // from the parameters passed as arguments | |
119 | // | |
befe2c08 | 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 | { | |
ff2dbca1 | 128 | // set the translation coefficients of the data member matrix |
129 | // from the matrix passed as argument | |
130 | // | |
befe2c08 | 131 | const Double_t *tr = m.GetTranslation(); |
132 | fMatrix.SetTranslation(tr); | |
133 | } | |
134 | ||
135 | //_____________________________________________________________________________ | |
136 | void AliAlignObjMatrix::SetRotation(Double_t psi, Double_t theta, Double_t phi) | |
137 | { | |
ff2dbca1 | 138 | // set the rotation parameters from the parameters passed as arguments |
139 | // | |
befe2c08 | 140 | Double_t angles[3] = {psi, theta, phi}; |
141 | Double_t rot[9]; | |
142 | AnglesToMatrix(angles,rot); | |
143 | fMatrix.SetRotation(rot); | |
144 | } | |
145 | ||
146 | //_____________________________________________________________________________ | |
147 | Bool_t AliAlignObjMatrix::SetRotation(const TGeoMatrix& m) | |
148 | { | |
ff2dbca1 | 149 | // set the rotation coefficients of the data member matrix |
150 | // from the matrix passed as argument | |
151 | // | |
befe2c08 | 152 | const Double_t* rot = m.GetRotationMatrix(); |
153 | fMatrix.SetRotation(rot); | |
154 | return kTRUE; | |
155 | } | |
156 | ||
befe2c08 | 157 | //_____________________________________________________________________________ |
158 | void AliAlignObjMatrix::GetTranslation(Double_t *tr) const | |
159 | { | |
160 | // Get Translation from TGeoMatrix | |
161 | const Double_t* translation = fMatrix.GetTranslation(); | |
162 | tr[0] = translation[0]; | |
163 | tr[1] = translation[1]; | |
164 | tr[2] = translation[2]; | |
165 | } | |
166 | ||
167 | //_____________________________________________________________________________ | |
168 | Bool_t AliAlignObjMatrix::GetAngles(Double_t *angles) const | |
169 | { | |
170 | // Get rotation angles from the TGeoHMatrix | |
171 | const Double_t* rot = fMatrix.GetRotationMatrix(); | |
172 | return MatrixToAngles(rot,angles); | |
173 | } | |
174 | ||
befe2c08 | 175 | //_____________________________________________________________________________ |
176 | void AliAlignObjMatrix::GetMatrix(TGeoHMatrix& m) const | |
177 | { | |
178 | // Get TGeoHMatrix | |
179 | // | |
180 | const Double_t *tr = fMatrix.GetTranslation(); | |
181 | m.SetTranslation(tr); | |
182 | const Double_t *rot = fMatrix.GetRotationMatrix(); | |
183 | m.SetRotation(rot); | |
184 | } | |
185 | ||
03b18860 | 186 | //_____________________________________________________________________________ |
187 | AliAlignObj& AliAlignObjMatrix::Inverse() const | |
188 | { | |
ff2dbca1 | 189 | // Return a temporary "inverse" of the alignment object, that is return |
190 | // an object with inverted transformation matrix. | |
191 | // | |
03b18860 | 192 | static AliAlignObjMatrix a; |
193 | a = *this; | |
194 | ||
195 | TGeoHMatrix m; | |
196 | GetMatrix(m); | |
197 | a.SetMatrix(m.Inverse()); | |
198 | ||
199 | return a; | |
200 | } |