1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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 //-----------------------------------------------------------------
22 #include "AliAlignObj.h"
23 #include "AliAlignObjMatrix.h"
26 ClassImp(AliAlignObjMatrix)
28 //_____________________________________________________________________________
29 AliAlignObjMatrix::AliAlignObjMatrix() :
33 // Default constructor
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) :
39 AliAlignObj(volpath, voluid),
42 // standard constructor with 3 translation + 3 rotation parameters
44 SetTranslation(x, y, z);
45 SetRotation(psi, theta, phi);
48 //_____________________________________________________________________________
49 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 *) :
50 AliAlignObj(volpath,layerId,volId),
53 // standard constructor with 3 translation + 3 rotation parameters
54 // If the user explicitly sets the global variable to kFALSE then the
55 // parameters are interpreted as giving the local transformation.
56 // This requires to have a gGeoMenager active instance, otherwise the
57 // constructor will fail (no object created)
60 SetTranslation(x, y, z);
61 SetRotation(psi, theta, phi);
63 if(!SetLocalPars(x,y,z,psi,theta,phi)) throw "Alignment object creation failed (TGeo instance needed)!\n";
68 //_____________________________________________________________________________
69 AliAlignObjMatrix::AliAlignObjMatrix(const char* volpath, UShort_t volUID, TGeoMatrix& m) :
70 AliAlignObj(volpath,volUID),
73 // standard constructor with TGeoMatrix
79 //_____________________________________________________________________________
80 AliAlignObjMatrix::AliAlignObjMatrix(const char* volpath, ELayerID layerId, Int_t volId, TGeoMatrix& m) :
81 AliAlignObj(volpath,layerId,volId),
84 // standard constructor with TGeoMatrix
90 //_____________________________________________________________________________
91 AliAlignObjMatrix::AliAlignObjMatrix(const AliAlignObj& theAlignObj) :
92 AliAlignObj(theAlignObj),
98 theAlignObj.GetTranslation(tr);
99 SetTranslation(tr[0],tr[1],tr[2]);
101 theAlignObj.GetAngles(rot);
102 SetRotation(rot[0],rot[1],rot[2]);
105 //_____________________________________________________________________________
106 AliAlignObjMatrix &AliAlignObjMatrix::operator =(const AliAlignObj& theAlignObj)
108 // assignment operator
110 if(this==&theAlignObj) return *this;
111 ((AliAlignObj *)this)->operator=(theAlignObj);
113 theAlignObj.GetTranslation(tr);
114 SetTranslation(tr[0],tr[1],tr[2]);
116 theAlignObj.GetAngles(rot);
117 SetRotation(rot[0],rot[1],rot[2]);
121 //_____________________________________________________________________________
122 AliAlignObjMatrix::~AliAlignObjMatrix()
128 //_____________________________________________________________________________
129 void AliAlignObjMatrix::SetTranslation(Double_t x, Double_t y, Double_t z)
132 tr[0]=x; tr[1]=y; tr[2]=z;
133 fMatrix.SetTranslation(tr);
136 //_____________________________________________________________________________
137 void AliAlignObjMatrix::SetTranslation(const TGeoMatrix& m)
139 const Double_t *tr = m.GetTranslation();
140 fMatrix.SetTranslation(tr);
143 //_____________________________________________________________________________
144 void AliAlignObjMatrix::SetRotation(Double_t psi, Double_t theta, Double_t phi)
146 Double_t angles[3] = {psi, theta, phi};
148 AnglesToMatrix(angles,rot);
149 fMatrix.SetRotation(rot);
152 //_____________________________________________________________________________
153 Bool_t AliAlignObjMatrix::SetRotation(const TGeoMatrix& m)
155 const Double_t* rot = m.GetRotationMatrix();
156 fMatrix.SetRotation(rot);
160 //_____________________________________________________________________________
161 void AliAlignObjMatrix::SetMatrix(const TGeoMatrix& m)
163 // Set rotation matrix and translation
169 //_____________________________________________________________________________
170 void AliAlignObjMatrix::SetPars(Double_t x, Double_t y, Double_t z,
171 Double_t psi, Double_t theta, Double_t phi)
173 // Set rotation matrix and translation
174 // using 3 angles and 3 translations
175 SetTranslation(x,y,z);
176 SetRotation(psi,theta,phi);
179 //_____________________________________________________________________________
180 void AliAlignObjMatrix::GetTranslation(Double_t *tr) const
182 // Get Translation from TGeoMatrix
183 const Double_t* translation = fMatrix.GetTranslation();
184 tr[0] = translation[0];
185 tr[1] = translation[1];
186 tr[2] = translation[2];
189 //_____________________________________________________________________________
190 Bool_t AliAlignObjMatrix::GetAngles(Double_t *angles) const
192 // Get rotation angles from the TGeoHMatrix
193 const Double_t* rot = fMatrix.GetRotationMatrix();
194 return MatrixToAngles(rot,angles);
197 //_____________________________________________________________________________
198 void AliAlignObjMatrix::GetPars(Double_t tr[], Double_t angles[]) const
204 //_____________________________________________________________________________
205 void AliAlignObjMatrix::GetMatrix(TGeoHMatrix& m) const
209 const Double_t *tr = fMatrix.GetTranslation();
210 m.SetTranslation(tr);
211 const Double_t *rot = fMatrix.GetRotationMatrix();
215 //_____________________________________________________________________________
216 AliAlignObj& AliAlignObjMatrix::Inverse() const
218 // Return a temporary inverse of the alignment
219 // object. This means 'mis
220 static AliAlignObjMatrix a;
225 a.SetMatrix(m.Inverse());