]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliAlignObjMatrix.cxx
Parameters of miscalibration in the head of the file (Marian)
[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//_____________________________________________________________________________
fe12e09c 29AliAlignObjMatrix::AliAlignObjMatrix() :
30 AliAlignObj(),
31 fMatrix()
befe2c08 32{
33 // Default constructor
34 //
35}
36
37//_____________________________________________________________________________
fe12e09c 38AliAlignObjMatrix::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),
40 fMatrix()
befe2c08 41{
42 // standard constructor with 3 translation + 3 rotation parameters
43 //
befe2c08 44 SetTranslation(x, y, z);
45 SetRotation(psi, theta, phi);
46}
47
48//_____________________________________________________________________________
fe12e09c 49AliAlignObjMatrix::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),
51 fMatrix()
befe2c08 52{
53 // standard constructor with 3 translation + 3 rotation parameters
48c8e89a 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)
58 //
48c8e89a 59 if(global){
60 SetTranslation(x, y, z);
61 SetRotation(psi, theta, phi);
62 }else{
63 if(!SetLocalPars(x,y,z,psi,theta,phi)) throw "Alignment object creation failed (TGeo instance needed)!\n";
64 }
befe2c08 65}
66
48c8e89a 67
befe2c08 68//_____________________________________________________________________________
fe12e09c 69AliAlignObjMatrix::AliAlignObjMatrix(const char* volpath, UShort_t volUID, TGeoMatrix& m) :
70 AliAlignObj(volpath,volUID),
71 fMatrix()
d9cc42ed 72{
73 // standard constructor with TGeoMatrix
74 //
75 SetTranslation(m);
76 SetRotation(m);
77}
78
79//_____________________________________________________________________________
fe12e09c 80AliAlignObjMatrix::AliAlignObjMatrix(const char* volpath, ELayerID layerId, Int_t volId, TGeoMatrix& m) :
81 AliAlignObj(volpath,layerId,volId),
82 fMatrix()
befe2c08 83{
84 // standard constructor with TGeoMatrix
85 //
befe2c08 86 SetTranslation(m);
87 SetRotation(m);
88}
89
90//_____________________________________________________________________________
c5304981 91AliAlignObjMatrix::AliAlignObjMatrix(const AliAlignObj& theAlignObj) :
fe12e09c 92 AliAlignObj(theAlignObj),
93 fMatrix()
befe2c08 94{
95 //copy constructor
96 //
97 Double_t tr[3];
98 theAlignObj.GetTranslation(tr);
99 SetTranslation(tr[0],tr[1],tr[2]);
100 Double_t rot[3];
101 theAlignObj.GetAngles(rot);
102 SetRotation(rot[0],rot[1],rot[2]);
103}
104
105//_____________________________________________________________________________
c5304981 106AliAlignObjMatrix &AliAlignObjMatrix::operator =(const AliAlignObj& theAlignObj)
befe2c08 107{
108 // assignment operator
109 //
110 if(this==&theAlignObj) return *this;
111 ((AliAlignObj *)this)->operator=(theAlignObj);
112 Double_t tr[3];
113 theAlignObj.GetTranslation(tr);
114 SetTranslation(tr[0],tr[1],tr[2]);
115 Double_t rot[3];
116 theAlignObj.GetAngles(rot);
117 SetRotation(rot[0],rot[1],rot[2]);
118 return *this;
119}
120
121//_____________________________________________________________________________
122AliAlignObjMatrix::~AliAlignObjMatrix()
123{
124 // Destructor
125 //
126}
127
128//_____________________________________________________________________________
129void AliAlignObjMatrix::SetTranslation(Double_t x, Double_t y, Double_t z)
130{
131 Double_t tr[3];
132 tr[0]=x; tr[1]=y; tr[2]=z;
133 fMatrix.SetTranslation(tr);
134}
135
136//_____________________________________________________________________________
137void AliAlignObjMatrix::SetTranslation(const TGeoMatrix& m)
138{
139 const Double_t *tr = m.GetTranslation();
140 fMatrix.SetTranslation(tr);
141}
142
143//_____________________________________________________________________________
144void AliAlignObjMatrix::SetRotation(Double_t psi, Double_t theta, Double_t phi)
145{
146 Double_t angles[3] = {psi, theta, phi};
147 Double_t rot[9];
148 AnglesToMatrix(angles,rot);
149 fMatrix.SetRotation(rot);
150}
151
152//_____________________________________________________________________________
153Bool_t AliAlignObjMatrix::SetRotation(const TGeoMatrix& m)
154{
155 const Double_t* rot = m.GetRotationMatrix();
156 fMatrix.SetRotation(rot);
157 return kTRUE;
158}
159
160//_____________________________________________________________________________
161void AliAlignObjMatrix::SetMatrix(const TGeoMatrix& m)
162{
163 // Set rotation matrix and translation
164 // using TGeoMatrix
165 SetTranslation(m);
166 SetRotation(m);
167}
168
169//_____________________________________________________________________________
170void AliAlignObjMatrix::SetPars(Double_t x, Double_t y, Double_t z,
171 Double_t psi, Double_t theta, Double_t phi)
172{
173 // Set rotation matrix and translation
174 // using 3 angles and 3 translations
175 SetTranslation(x,y,z);
176 SetRotation(psi,theta,phi);
177}
178
179//_____________________________________________________________________________
180void AliAlignObjMatrix::GetTranslation(Double_t *tr) const
181{
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];
187}
188
189//_____________________________________________________________________________
190Bool_t AliAlignObjMatrix::GetAngles(Double_t *angles) const
191{
192 // Get rotation angles from the TGeoHMatrix
193 const Double_t* rot = fMatrix.GetRotationMatrix();
194 return MatrixToAngles(rot,angles);
195}
196
197//_____________________________________________________________________________
198void AliAlignObjMatrix::GetPars(Double_t tr[], Double_t angles[]) const
199{
200 GetTranslation(tr);
201 GetAngles(angles);
202}
203
204//_____________________________________________________________________________
205void AliAlignObjMatrix::GetMatrix(TGeoHMatrix& m) const
206{
207 // Get TGeoHMatrix
208 //
209 const Double_t *tr = fMatrix.GetTranslation();
210 m.SetTranslation(tr);
211 const Double_t *rot = fMatrix.GetRotationMatrix();
212 m.SetRotation(rot);
213}
214
03b18860 215//_____________________________________________________________________________
216AliAlignObj& AliAlignObjMatrix::Inverse() const
217{
218 // Return a temporary inverse of the alignment
219 // object. This means 'mis
220 static AliAlignObjMatrix a;
221 a = *this;
222
223 TGeoHMatrix m;
224 GetMatrix(m);
225 a.SetMatrix(m.Inverse());
226
227 return a;
228}