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"
25 ClassImp(AliAlignObjMatrix)
27 //_____________________________________________________________________________
28 AliAlignObjMatrix::AliAlignObjMatrix() :
32 // Default constructor
36 //_____________________________________________________________________________
37 AliAlignObjMatrix::AliAlignObjMatrix(const char* symname, 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 *) :
38 AliAlignObj(symname,volUId),
41 // standard constructor with 3 translation + 3 rotation parameters
42 // If the user explicitly sets the global variable to kFALSE then the
43 // parameters are interpreted as giving the local transformation.
44 // This requires to have a gGeoMenager active instance, otherwise the
45 // constructor will fail (no object created)
48 SetPars(x, y, z, psi, theta, phi);
50 if(!SetLocalPars(x,y,z,psi,theta,phi)) throw "Alignment object creation failed (TGeo instance needed)!\n";
55 //_____________________________________________________________________________
56 AliAlignObjMatrix::AliAlignObjMatrix(const char* symname, UShort_t volUId, TGeoMatrix& m, Bool_t global) throw (const Char_t *) :
57 AliAlignObj(symname,volUId),
60 // standard constructor with TGeoMatrix
61 // If the user explicitly sets the global variable to kFALSE then the
62 // parameters are interpreted as giving the local transformation.
63 // This requires to have a gGeoMenager active instance, otherwise the
64 // constructor will fail (no object created)
71 if (!SetLocalMatrix(m)) throw "Alignment object creation failed (TGeo instance needed)!\n";
75 //_____________________________________________________________________________
76 AliAlignObjMatrix::AliAlignObjMatrix(const AliAlignObj& theAlignObj) :
77 AliAlignObj(theAlignObj),
83 theAlignObj.GetTranslation(tr);
84 SetTranslation(tr[0],tr[1],tr[2]);
86 if (theAlignObj.GetAngles(rot))
87 SetRotation(rot[0],rot[1],rot[2]);
90 //_____________________________________________________________________________
91 AliAlignObjMatrix &AliAlignObjMatrix::operator =(const AliAlignObj& theAlignObj)
93 // assignment operator
95 if(this==&theAlignObj) return *this;
96 ((AliAlignObj *)this)->operator=(theAlignObj);
98 theAlignObj.GetTranslation(tr);
99 SetTranslation(tr[0],tr[1],tr[2]);
101 if (theAlignObj.GetAngles(rot))
102 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)
117 // set the translation coefficients of the data member matrix
118 // from the parameters passed as arguments
121 tr[0]=x; tr[1]=y; tr[2]=z;
122 fMatrix.SetTranslation(tr);
125 //_____________________________________________________________________________
126 void AliAlignObjMatrix::SetTranslation(const TGeoMatrix& m)
128 // set the translation coefficients of the data member matrix
129 // from the matrix passed as argument
131 const Double_t *tr = m.GetTranslation();
132 fMatrix.SetTranslation(tr);
135 //_____________________________________________________________________________
136 void AliAlignObjMatrix::SetRotation(Double_t psi, Double_t theta, Double_t phi)
138 // set the rotation parameters from the parameters passed as arguments
140 Double_t angles[3] = {psi, theta, phi};
142 AnglesToMatrix(angles,rot);
143 fMatrix.SetRotation(rot);
146 //_____________________________________________________________________________
147 Bool_t AliAlignObjMatrix::SetRotation(const TGeoMatrix& m)
149 // set the rotation coefficients of the data member matrix
150 // from the matrix passed as argument
152 const Double_t* rot = m.GetRotationMatrix();
153 fMatrix.SetRotation(rot);
157 //_____________________________________________________________________________
158 void AliAlignObjMatrix::GetTranslation(Double_t *tr) const
160 // Get Translation from TGeoMatrix
161 const Double_t* translation = fMatrix.GetTranslation();
162 tr[0] = translation[0];
163 tr[1] = translation[1];
164 tr[2] = translation[2];
167 //_____________________________________________________________________________
168 Bool_t AliAlignObjMatrix::GetAngles(Double_t *angles) const
170 // Get rotation angles from the TGeoHMatrix
171 const Double_t* rot = fMatrix.GetRotationMatrix();
172 return MatrixToAngles(rot,angles);
175 //_____________________________________________________________________________
176 void AliAlignObjMatrix::GetMatrix(TGeoHMatrix& m) const
180 const Double_t *tr = fMatrix.GetTranslation();
181 m.SetTranslation(tr);
182 const Double_t *rot = fMatrix.GetRotationMatrix();
186 //_____________________________________________________________________________
187 AliAlignObj& AliAlignObjMatrix::Inverse() const
189 // Return a temporary "inverse" of the alignment object, that is return
190 // an object with inverted transformation matrix.
192 static AliAlignObjMatrix a;
197 a.SetMatrix(m.Inverse());