]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/STEER/AliAlignObjMatrix.cxx
Restore the processing statistics per event
[u/mrichter/AliRoot.git] / STEER / STEER / AliAlignObjMatrix.cxx
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
25 ClassImp(AliAlignObjMatrix)
26
27 //_____________________________________________________________________________
28 AliAlignObjMatrix::AliAlignObjMatrix() : 
29   AliAlignObj(),
30   fMatrix()
31 {
32   // Default constructor
33   //
34 }
35
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),
39   fMatrix()
40 {
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)
46   // 
47   if(global){
48     SetPars(x, y, z, psi, theta, phi);
49   }else{
50     if(!SetLocalPars(x,y,z,psi,theta,phi)) throw "Alignment object creation failed (TGeo instance needed)!\n";
51   }
52 }
53
54
55 //_____________________________________________________________________________
56 AliAlignObjMatrix::AliAlignObjMatrix(const char* symname, UShort_t volUId, TGeoMatrix& m, Bool_t global) throw (const Char_t *) :
57   AliAlignObj(symname,volUId),
58   fMatrix()
59 {
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)
65   //
66
67   if (global) {
68     SetMatrix(m);
69   }
70   else {
71     if (!SetLocalMatrix(m)) throw "Alignment object creation failed (TGeo instance needed)!\n";
72   }
73 }
74
75 //_____________________________________________________________________________
76 AliAlignObjMatrix::AliAlignObjMatrix(const AliAlignObj& theAlignObj) :
77   AliAlignObj(theAlignObj),
78   fMatrix()
79 {
80   //copy constructor
81   //
82   Double_t tr[3];
83   theAlignObj.GetTranslation(tr);
84   SetTranslation(tr[0],tr[1],tr[2]);
85   Double_t rot[3];
86   if (theAlignObj.GetAngles(rot))
87     SetRotation(rot[0],rot[1],rot[2]);
88 }
89
90 //_____________________________________________________________________________
91 AliAlignObjMatrix &AliAlignObjMatrix::operator =(const AliAlignObj& theAlignObj)
92 {  
93   // assignment operator
94   //
95   if(this==&theAlignObj) return *this;
96   ((AliAlignObj *)this)->operator=(theAlignObj);
97   Double_t tr[3];
98   theAlignObj.GetTranslation(tr);
99   SetTranslation(tr[0],tr[1],tr[2]);
100   Double_t rot[3];
101   if (theAlignObj.GetAngles(rot))
102     SetRotation(rot[0],rot[1],rot[2]);
103
104   return *this;
105 }
106
107 //_____________________________________________________________________________
108 AliAlignObjMatrix::~AliAlignObjMatrix()
109 {
110   // Destructor
111   //
112 }
113
114 //_____________________________________________________________________________
115 void AliAlignObjMatrix::SetTranslation(Double_t x, Double_t y, Double_t z)
116 {
117   // set the translation coefficients of the data member matrix
118   // from the parameters passed as arguments
119   // 
120   Double_t tr[3];
121   tr[0]=x; tr[1]=y; tr[2]=z;
122   fMatrix.SetTranslation(tr);
123 }
124
125 //_____________________________________________________________________________
126 void AliAlignObjMatrix::SetTranslation(const TGeoMatrix& m)
127 {
128   // set the translation coefficients of the data member matrix
129   // from the matrix passed as argument
130   // 
131   const Double_t *tr = m.GetTranslation();
132   fMatrix.SetTranslation(tr);
133 }
134
135 //_____________________________________________________________________________
136 void AliAlignObjMatrix::SetRotation(Double_t psi, Double_t theta, Double_t phi)
137 {
138   // set the rotation parameters from the parameters passed as arguments
139   // 
140   Double_t angles[3] = {psi, theta, phi};
141   Double_t rot[9];
142   AnglesToMatrix(angles,rot);
143   fMatrix.SetRotation(rot);
144 }
145
146 //_____________________________________________________________________________
147 Bool_t AliAlignObjMatrix::SetRotation(const TGeoMatrix& m)
148 {
149   // set the rotation coefficients of the data member matrix
150   // from the matrix passed as argument
151   // 
152   const Double_t* rot = m.GetRotationMatrix();
153   fMatrix.SetRotation(rot);
154   return kTRUE;
155 }
156
157 //_____________________________________________________________________________
158 void AliAlignObjMatrix::GetTranslation(Double_t *tr) const
159 {
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];
165 }
166
167 //_____________________________________________________________________________
168 Bool_t AliAlignObjMatrix::GetAngles(Double_t *angles) const
169 {
170   // Get rotation angles from the TGeoHMatrix
171   const Double_t* rot = fMatrix.GetRotationMatrix();
172   return MatrixToAngles(rot,angles);
173 }
174
175 //_____________________________________________________________________________
176 void AliAlignObjMatrix::GetMatrix(TGeoHMatrix& m) const
177 {
178   // Get TGeoHMatrix
179   //
180   const Double_t *tr = fMatrix.GetTranslation();
181   m.SetTranslation(tr);
182   const Double_t *rot = fMatrix.GetRotationMatrix();
183   m.SetRotation(rot);
184 }
185
186 //_____________________________________________________________________________
187 AliAlignObj& AliAlignObjMatrix::Inverse() const
188 {
189   // Return a temporary "inverse" of the alignment object, that is return
190   // an object with inverted transformation matrix.
191   //
192    static AliAlignObjMatrix a;
193    a = *this;
194
195    TGeoHMatrix m;
196    GetMatrix(m);
197    a.SetMatrix(m.Inverse());
198
199    return a;
200 }