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, Bool_t global) throw (const Char_t *) : AliAlignObj()
49 // standard constructor with 3 translation + 3 rotation parameters
50 // If the user explicitly sets the global variable to kFALSE then the
51 // parameters are interpreted as giving the local transformation.
52 // This requires to have a gGeoMenager active instance, otherwise the
53 // constructor will fail (no object created)
56 SetVolUID(detId,volId);
58 SetTranslation(x, y, z);
59 SetRotation(psi, theta, phi);
61 if(!SetLocalPars(x,y,z,psi,theta,phi)) throw "Alignment object creation failed (TGeo instance needed)!\n";
66 //_____________________________________________________________________________
67 AliAlignObjMatrix::AliAlignObjMatrix(const char* volpath, UShort_t voluid, TGeoMatrix& m) : AliAlignObj()
69 // standard constructor with TGeoMatrix
77 //_____________________________________________________________________________
78 AliAlignObjMatrix::AliAlignObjMatrix(const AliAlignObj& theAlignObj) :
79 AliAlignObj(theAlignObj)
84 theAlignObj.GetTranslation(tr);
85 SetTranslation(tr[0],tr[1],tr[2]);
87 theAlignObj.GetAngles(rot);
88 SetRotation(rot[0],rot[1],rot[2]);
91 //_____________________________________________________________________________
92 AliAlignObjMatrix &AliAlignObjMatrix::operator =(const AliAlignObj& theAlignObj)
94 // assignment operator
96 if(this==&theAlignObj) return *this;
97 ((AliAlignObj *)this)->operator=(theAlignObj);
99 theAlignObj.GetTranslation(tr);
100 SetTranslation(tr[0],tr[1],tr[2]);
102 theAlignObj.GetAngles(rot);
103 SetRotation(rot[0],rot[1],rot[2]);
107 //_____________________________________________________________________________
108 AliAlignObjMatrix::~AliAlignObjMatrix()
114 //_____________________________________________________________________________
115 void AliAlignObjMatrix::SetTranslation(Double_t x, Double_t y, Double_t z)
118 tr[0]=x; tr[1]=y; tr[2]=z;
119 fMatrix.SetTranslation(tr);
122 //_____________________________________________________________________________
123 void AliAlignObjMatrix::SetTranslation(const TGeoMatrix& m)
125 const Double_t *tr = m.GetTranslation();
126 fMatrix.SetTranslation(tr);
129 //_____________________________________________________________________________
130 void AliAlignObjMatrix::SetRotation(Double_t psi, Double_t theta, Double_t phi)
132 Double_t angles[3] = {psi, theta, phi};
134 AnglesToMatrix(angles,rot);
135 fMatrix.SetRotation(rot);
138 //_____________________________________________________________________________
139 Bool_t AliAlignObjMatrix::SetRotation(const TGeoMatrix& m)
141 const Double_t* rot = m.GetRotationMatrix();
142 fMatrix.SetRotation(rot);
146 //_____________________________________________________________________________
147 void AliAlignObjMatrix::SetMatrix(const TGeoMatrix& m)
149 // Set rotation matrix and translation
155 //_____________________________________________________________________________
156 void AliAlignObjMatrix::SetPars(Double_t x, Double_t y, Double_t z,
157 Double_t psi, Double_t theta, Double_t phi)
159 // Set rotation matrix and translation
160 // using 3 angles and 3 translations
161 SetTranslation(x,y,z);
162 SetRotation(psi,theta,phi);
165 //_____________________________________________________________________________
166 void AliAlignObjMatrix::GetTranslation(Double_t *tr) const
168 // Get Translation from TGeoMatrix
169 const Double_t* translation = fMatrix.GetTranslation();
170 tr[0] = translation[0];
171 tr[1] = translation[1];
172 tr[2] = translation[2];
175 //_____________________________________________________________________________
176 Bool_t AliAlignObjMatrix::GetAngles(Double_t *angles) const
178 // Get rotation angles from the TGeoHMatrix
179 const Double_t* rot = fMatrix.GetRotationMatrix();
180 return MatrixToAngles(rot,angles);
183 //_____________________________________________________________________________
184 void AliAlignObjMatrix::GetPars(Double_t tr[], Double_t angles[]) const
190 //_____________________________________________________________________________
191 void AliAlignObjMatrix::GetMatrix(TGeoHMatrix& m) const
195 const Double_t *tr = fMatrix.GetTranslation();
196 m.SetTranslation(tr);
197 const Double_t *rot = fMatrix.GetRotationMatrix();
201 //_____________________________________________________________________________
202 AliAlignObj& AliAlignObjMatrix::Inverse() const
204 // Return a temporary inverse of the alignment
205 // object. This means 'mis
206 static AliAlignObjMatrix a;
211 a.SetMatrix(m.Inverse());