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() : AliAlignObj()
31 // Default constructor
35 //_____________________________________________________________________________
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()
38 // standard constructor with 3 translation + 3 rotation parameters
42 SetTranslation(x, y, z);
43 SetRotation(psi, theta, phi);
46 //_____________________________________________________________________________
47 AliAlignObjMatrix::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()
49 // standard constructor with 3 translation + 3 rotation parameters
52 SetVolUID(detId,volId);
53 SetTranslation(x, y, z);
54 SetRotation(psi, theta, phi);
57 //_____________________________________________________________________________
58 AliAlignObjMatrix::AliAlignObjMatrix(const char* volpath, UShort_t voluid, TGeoMatrix& m) : AliAlignObj()
60 // standard constructor with TGeoMatrix
68 //_____________________________________________________________________________
69 AliAlignObjMatrix::AliAlignObjMatrix(const AliAlignObj& theAlignObj) :
70 AliAlignObj(theAlignObj)
75 theAlignObj.GetTranslation(tr);
76 SetTranslation(tr[0],tr[1],tr[2]);
78 theAlignObj.GetAngles(rot);
79 SetRotation(rot[0],rot[1],rot[2]);
82 //_____________________________________________________________________________
83 AliAlignObjMatrix &AliAlignObjMatrix::operator =(const AliAlignObj& theAlignObj)
85 // assignment operator
87 if(this==&theAlignObj) return *this;
88 ((AliAlignObj *)this)->operator=(theAlignObj);
90 theAlignObj.GetTranslation(tr);
91 SetTranslation(tr[0],tr[1],tr[2]);
93 theAlignObj.GetAngles(rot);
94 SetRotation(rot[0],rot[1],rot[2]);
98 //_____________________________________________________________________________
99 AliAlignObjMatrix::~AliAlignObjMatrix()
105 //_____________________________________________________________________________
106 void AliAlignObjMatrix::SetTranslation(Double_t x, Double_t y, Double_t z)
109 tr[0]=x; tr[1]=y; tr[2]=z;
110 fMatrix.SetTranslation(tr);
113 //_____________________________________________________________________________
114 void AliAlignObjMatrix::SetTranslation(const TGeoMatrix& m)
116 const Double_t *tr = m.GetTranslation();
117 fMatrix.SetTranslation(tr);
120 //_____________________________________________________________________________
121 void AliAlignObjMatrix::SetRotation(Double_t psi, Double_t theta, Double_t phi)
123 Double_t angles[3] = {psi, theta, phi};
125 AnglesToMatrix(angles,rot);
126 fMatrix.SetRotation(rot);
129 //_____________________________________________________________________________
130 Bool_t AliAlignObjMatrix::SetRotation(const TGeoMatrix& m)
132 const Double_t* rot = m.GetRotationMatrix();
133 fMatrix.SetRotation(rot);
137 //_____________________________________________________________________________
138 void AliAlignObjMatrix::SetMatrix(const TGeoMatrix& m)
140 // Set rotation matrix and translation
146 //_____________________________________________________________________________
147 void AliAlignObjMatrix::SetPars(Double_t x, Double_t y, Double_t z,
148 Double_t psi, Double_t theta, Double_t phi)
150 // Set rotation matrix and translation
151 // using 3 angles and 3 translations
152 SetTranslation(x,y,z);
153 SetRotation(psi,theta,phi);
156 //_____________________________________________________________________________
157 void AliAlignObjMatrix::GetTranslation(Double_t *tr) const
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];
166 //_____________________________________________________________________________
167 Bool_t AliAlignObjMatrix::GetAngles(Double_t *angles) const
169 // Get rotation angles from the TGeoHMatrix
170 const Double_t* rot = fMatrix.GetRotationMatrix();
171 return MatrixToAngles(rot,angles);
174 //_____________________________________________________________________________
175 void AliAlignObjMatrix::GetPars(Double_t tr[], Double_t angles[]) const
181 //_____________________________________________________________________________
182 void AliAlignObjMatrix::GetMatrix(TGeoHMatrix& m) const
186 const Double_t *tr = fMatrix.GetTranslation();
187 m.SetTranslation(tr);
188 const Double_t *rot = fMatrix.GetRotationMatrix();
192 //_____________________________________________________________________________
193 AliAlignObj& AliAlignObjMatrix::Inverse() const
195 // Return a temporary inverse of the alignment
196 // object. This means 'mis
197 static AliAlignObjMatrix a;
202 a.SetMatrix(m.Inverse());