ApplyDisplacements method renamed to ApplyAlignObjsToGeom. Automatic check of overlap...
[u/mrichter/AliRoot.git] / STEER / AliAlignObjMatrix.cxx
CommitLineData
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
26ClassImp(AliAlignObjMatrix)
27
28//_____________________________________________________________________________
29AliAlignObjMatrix::AliAlignObjMatrix() : AliAlignObj()
30{
31 // Default constructor
32 //
33}
34
35//_____________________________________________________________________________
03b18860 36AliAlignObjMatrix::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()
befe2c08 37{
38 // standard constructor with 3 translation + 3 rotation parameters
39 //
40 fVolPath=volpath;
41 fVolUID=voluid;
42 SetTranslation(x, y, z);
43 SetRotation(psi, theta, phi);
44}
45
46//_____________________________________________________________________________
03b18860 47AliAlignObjMatrix::AliAlignObjMatrix(const char* volpath, ELayerID detId, Int_t volId, Double_t x, Double_t y, Double_t z, Double_t psi, Double_t theta, Double_t phi) : AliAlignObj()
befe2c08 48{
49 // standard constructor with 3 translation + 3 rotation parameters
50 //
51 fVolPath=volpath;
52 SetVolUID(detId,volId);
53 SetTranslation(x, y, z);
54 SetRotation(psi, theta, phi);
55}
56
57//_____________________________________________________________________________
03b18860 58AliAlignObjMatrix::AliAlignObjMatrix(const char* volpath, UShort_t voluid, TGeoMatrix& m) : AliAlignObj()
befe2c08 59{
60 // standard constructor with TGeoMatrix
61 //
62 fVolPath=volpath;
63 fVolUID=voluid;
64 SetTranslation(m);
65 SetRotation(m);
66}
67
68//_____________________________________________________________________________
c5304981 69AliAlignObjMatrix::AliAlignObjMatrix(const AliAlignObj& theAlignObj) :
befe2c08 70 AliAlignObj(theAlignObj)
71{
72 //copy constructor
73 //
74 Double_t tr[3];
75 theAlignObj.GetTranslation(tr);
76 SetTranslation(tr[0],tr[1],tr[2]);
77 Double_t rot[3];
78 theAlignObj.GetAngles(rot);
79 SetRotation(rot[0],rot[1],rot[2]);
80}
81
82//_____________________________________________________________________________
c5304981 83AliAlignObjMatrix &AliAlignObjMatrix::operator =(const AliAlignObj& theAlignObj)
befe2c08 84{
85 // assignment operator
86 //
87 if(this==&theAlignObj) return *this;
88 ((AliAlignObj *)this)->operator=(theAlignObj);
89 Double_t tr[3];
90 theAlignObj.GetTranslation(tr);
91 SetTranslation(tr[0],tr[1],tr[2]);
92 Double_t rot[3];
93 theAlignObj.GetAngles(rot);
94 SetRotation(rot[0],rot[1],rot[2]);
95 return *this;
96}
97
98//_____________________________________________________________________________
99AliAlignObjMatrix::~AliAlignObjMatrix()
100{
101 // Destructor
102 //
103}
104
105//_____________________________________________________________________________
106void AliAlignObjMatrix::SetTranslation(Double_t x, Double_t y, Double_t z)
107{
108 Double_t tr[3];
109 tr[0]=x; tr[1]=y; tr[2]=z;
110 fMatrix.SetTranslation(tr);
111}
112
113//_____________________________________________________________________________
114void AliAlignObjMatrix::SetTranslation(const TGeoMatrix& m)
115{
116 const Double_t *tr = m.GetTranslation();
117 fMatrix.SetTranslation(tr);
118}
119
120//_____________________________________________________________________________
121void AliAlignObjMatrix::SetRotation(Double_t psi, Double_t theta, Double_t phi)
122{
123 Double_t angles[3] = {psi, theta, phi};
124 Double_t rot[9];
125 AnglesToMatrix(angles,rot);
126 fMatrix.SetRotation(rot);
127}
128
129//_____________________________________________________________________________
130Bool_t AliAlignObjMatrix::SetRotation(const TGeoMatrix& m)
131{
132 const Double_t* rot = m.GetRotationMatrix();
133 fMatrix.SetRotation(rot);
134 return kTRUE;
135}
136
137//_____________________________________________________________________________
138void AliAlignObjMatrix::SetMatrix(const TGeoMatrix& m)
139{
140 // Set rotation matrix and translation
141 // using TGeoMatrix
142 SetTranslation(m);
143 SetRotation(m);
144}
145
146//_____________________________________________________________________________
147void AliAlignObjMatrix::SetPars(Double_t x, Double_t y, Double_t z,
148 Double_t psi, Double_t theta, Double_t phi)
149{
150 // Set rotation matrix and translation
151 // using 3 angles and 3 translations
152 SetTranslation(x,y,z);
153 SetRotation(psi,theta,phi);
154}
155
156//_____________________________________________________________________________
157void AliAlignObjMatrix::GetTranslation(Double_t *tr) const
158{
159 // Get Translation from TGeoMatrix
160 const Double_t* translation = fMatrix.GetTranslation();
161 tr[0] = translation[0];
162 tr[1] = translation[1];
163 tr[2] = translation[2];
164}
165
166//_____________________________________________________________________________
167Bool_t AliAlignObjMatrix::GetAngles(Double_t *angles) const
168{
169 // Get rotation angles from the TGeoHMatrix
170 const Double_t* rot = fMatrix.GetRotationMatrix();
171 return MatrixToAngles(rot,angles);
172}
173
174//_____________________________________________________________________________
175void AliAlignObjMatrix::GetPars(Double_t tr[], Double_t angles[]) const
176{
177 GetTranslation(tr);
178 GetAngles(angles);
179}
180
181//_____________________________________________________________________________
182void AliAlignObjMatrix::GetMatrix(TGeoHMatrix& m) const
183{
184 // Get TGeoHMatrix
185 //
186 const Double_t *tr = fMatrix.GetTranslation();
187 m.SetTranslation(tr);
188 const Double_t *rot = fMatrix.GetRotationMatrix();
189 m.SetRotation(rot);
190}
191
03b18860 192//_____________________________________________________________________________
193AliAlignObj& AliAlignObjMatrix::Inverse() const
194{
195 // Return a temporary inverse of the alignment
196 // object. This means 'mis
197 static AliAlignObjMatrix a;
198 a = *this;
199
200 TGeoHMatrix m;
201 GetMatrix(m);
202 a.SetMatrix(m.Inverse());
203
204 return a;
205}