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