]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliAlignObjMatrix.cxx
Possibility to specify local parameters added also to the constructor AliAlignObj...
[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//_____________________________________________________________________________
48c8e89a 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, Bool_t global) throw (const Char_t *) : AliAlignObj()
befe2c08 48{
49 // standard constructor with 3 translation + 3 rotation parameters
48c8e89a 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)
54 //
befe2c08 55 fVolPath=volpath;
56 SetVolUID(detId,volId);
48c8e89a 57 if(global){
58 SetTranslation(x, y, z);
59 SetRotation(psi, theta, phi);
60 }else{
61 if(!SetLocalPars(x,y,z,psi,theta,phi)) throw "Alignment object creation failed (TGeo instance needed)!\n";
62 }
befe2c08 63}
64
48c8e89a 65
befe2c08 66//_____________________________________________________________________________
03b18860 67AliAlignObjMatrix::AliAlignObjMatrix(const char* volpath, UShort_t voluid, TGeoMatrix& m) : AliAlignObj()
befe2c08 68{
69 // standard constructor with TGeoMatrix
70 //
71 fVolPath=volpath;
72 fVolUID=voluid;
73 SetTranslation(m);
74 SetRotation(m);
75}
76
77//_____________________________________________________________________________
c5304981 78AliAlignObjMatrix::AliAlignObjMatrix(const AliAlignObj& theAlignObj) :
befe2c08 79 AliAlignObj(theAlignObj)
80{
81 //copy constructor
82 //
83 Double_t tr[3];
84 theAlignObj.GetTranslation(tr);
85 SetTranslation(tr[0],tr[1],tr[2]);
86 Double_t rot[3];
87 theAlignObj.GetAngles(rot);
88 SetRotation(rot[0],rot[1],rot[2]);
89}
90
91//_____________________________________________________________________________
c5304981 92AliAlignObjMatrix &AliAlignObjMatrix::operator =(const AliAlignObj& theAlignObj)
befe2c08 93{
94 // assignment operator
95 //
96 if(this==&theAlignObj) return *this;
97 ((AliAlignObj *)this)->operator=(theAlignObj);
98 Double_t tr[3];
99 theAlignObj.GetTranslation(tr);
100 SetTranslation(tr[0],tr[1],tr[2]);
101 Double_t rot[3];
102 theAlignObj.GetAngles(rot);
103 SetRotation(rot[0],rot[1],rot[2]);
104 return *this;
105}
106
107//_____________________________________________________________________________
108AliAlignObjMatrix::~AliAlignObjMatrix()
109{
110 // Destructor
111 //
112}
113
114//_____________________________________________________________________________
115void AliAlignObjMatrix::SetTranslation(Double_t x, Double_t y, Double_t z)
116{
117 Double_t tr[3];
118 tr[0]=x; tr[1]=y; tr[2]=z;
119 fMatrix.SetTranslation(tr);
120}
121
122//_____________________________________________________________________________
123void AliAlignObjMatrix::SetTranslation(const TGeoMatrix& m)
124{
125 const Double_t *tr = m.GetTranslation();
126 fMatrix.SetTranslation(tr);
127}
128
129//_____________________________________________________________________________
130void AliAlignObjMatrix::SetRotation(Double_t psi, Double_t theta, Double_t phi)
131{
132 Double_t angles[3] = {psi, theta, phi};
133 Double_t rot[9];
134 AnglesToMatrix(angles,rot);
135 fMatrix.SetRotation(rot);
136}
137
138//_____________________________________________________________________________
139Bool_t AliAlignObjMatrix::SetRotation(const TGeoMatrix& m)
140{
141 const Double_t* rot = m.GetRotationMatrix();
142 fMatrix.SetRotation(rot);
143 return kTRUE;
144}
145
146//_____________________________________________________________________________
147void AliAlignObjMatrix::SetMatrix(const TGeoMatrix& m)
148{
149 // Set rotation matrix and translation
150 // using TGeoMatrix
151 SetTranslation(m);
152 SetRotation(m);
153}
154
155//_____________________________________________________________________________
156void AliAlignObjMatrix::SetPars(Double_t x, Double_t y, Double_t z,
157 Double_t psi, Double_t theta, Double_t phi)
158{
159 // Set rotation matrix and translation
160 // using 3 angles and 3 translations
161 SetTranslation(x,y,z);
162 SetRotation(psi,theta,phi);
163}
164
165//_____________________________________________________________________________
166void AliAlignObjMatrix::GetTranslation(Double_t *tr) const
167{
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];
173}
174
175//_____________________________________________________________________________
176Bool_t AliAlignObjMatrix::GetAngles(Double_t *angles) const
177{
178 // Get rotation angles from the TGeoHMatrix
179 const Double_t* rot = fMatrix.GetRotationMatrix();
180 return MatrixToAngles(rot,angles);
181}
182
183//_____________________________________________________________________________
184void AliAlignObjMatrix::GetPars(Double_t tr[], Double_t angles[]) const
185{
186 GetTranslation(tr);
187 GetAngles(angles);
188}
189
190//_____________________________________________________________________________
191void AliAlignObjMatrix::GetMatrix(TGeoHMatrix& m) const
192{
193 // Get TGeoHMatrix
194 //
195 const Double_t *tr = fMatrix.GetTranslation();
196 m.SetTranslation(tr);
197 const Double_t *rot = fMatrix.GetRotationMatrix();
198 m.SetRotation(rot);
199}
200
03b18860 201//_____________________________________________________________________________
202AliAlignObj& AliAlignObjMatrix::Inverse() const
203{
204 // Return a temporary inverse of the alignment
205 // object. This means 'mis
206 static AliAlignObjMatrix a;
207 a = *this;
208
209 TGeoHMatrix m;
210 GetMatrix(m);
211 a.SetMatrix(m.Inverse());
212
213 return a;
214}