]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliAlignObjAngles.cxx
Possibility to specify local parameters added also to the constructor AliAlignObj...
[u/mrichter/AliRoot.git] / STEER / AliAlignObjAngles.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 concrete representation of alignment object class
19 //   AliAlignObjAngles derived from the base class AliAlignObj
20 //-----------------------------------------------------------------
21
22 #include "AliAlignObj.h"
23 #include "AliAlignObjAngles.h"
24 //#include "AliLog.h"
25
26 ClassImp(AliAlignObjAngles)
27
28 //_____________________________________________________________________________
29 AliAlignObjAngles::AliAlignObjAngles() : AliAlignObj()
30 {
31   // default constructor
32   //
33   fTranslation[0]=fTranslation[1]=fTranslation[2]=0.;
34   fRotation[0]=fRotation[1]=fRotation[2]=0.;
35 }
36
37 //_____________________________________________________________________________
38 AliAlignObjAngles::AliAlignObjAngles(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()
39 {
40   // standard constructor with 3 translation + 3 rotation parameters
41   //
42   fVolPath=volpath;
43   fVolUID=voluid;
44   fTranslation[0]=x; fTranslation[1]=y; fTranslation[2]=z;
45   fRotation[0]=psi; fRotation[1]=theta; fRotation[2]=phi;
46 }
47
48 //_____________________________________________________________________________
49 AliAlignObjAngles::AliAlignObjAngles(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()
50 {
51   // standard constructor with 3 translation + 3 rotation parameters
52   // If the user explicitly sets the global variable to kFALSE then the
53   // parameters are interpreted as giving the local transformation.
54   // This requires to have a gGeoMenager active instance, otherwise the
55   // constructor will fail (no object created)
56   // 
57   fVolPath=volpath;
58   SetVolUID(detId,volId);
59   if(global){
60     fTranslation[0]=x; fTranslation[1]=y; fTranslation[2]=z;
61     fRotation[0]=psi; fRotation[1]=theta; fRotation[2]=phi;
62   }else{
63     if(!SetLocalPars(x,y,z,psi,theta,phi)) throw "Alignment object creation failed (TGeo instance needed)!\n";
64   }
65 }
66
67 //_____________________________________________________________________________
68 AliAlignObjAngles::AliAlignObjAngles(const char* volpath, UShort_t voluid, TGeoMatrix& m) : AliAlignObj()
69 {
70   // standard constructor with TGeoMatrix
71   //
72   fVolPath=volpath;
73   fVolUID=voluid;
74   SetTranslation(m);
75   SetRotation(m);
76 }
77
78 //_____________________________________________________________________________
79 AliAlignObjAngles::AliAlignObjAngles(const AliAlignObj& theAlignObj) :
80   AliAlignObj(theAlignObj)
81 {
82   // copy constructor
83   //
84   Double_t tr[3];
85   theAlignObj.GetTranslation(tr);
86   SetTranslation(tr[0],tr[1],tr[2]);
87   Double_t rot[3];
88   theAlignObj.GetAngles(rot);
89   SetRotation(rot[0],rot[1],rot[2]);
90 }
91
92 //_____________________________________________________________________________
93 AliAlignObjAngles &AliAlignObjAngles::operator =(const AliAlignObj& theAlignObj)
94 {
95   // assignment operator
96   //
97   if(this==&theAlignObj) return *this;
98   ((AliAlignObj *)this)->operator=(theAlignObj);
99
100   Double_t tr[3];
101   theAlignObj.GetTranslation(tr);
102   SetTranslation(tr[0],tr[1],tr[2]);
103   Double_t rot[3];
104   theAlignObj.GetAngles(rot);
105   SetRotation(rot[0],rot[1],rot[2]);
106   return *this;
107 }
108
109 //_____________________________________________________________________________
110 AliAlignObjAngles::~AliAlignObjAngles()
111 {
112   // default destructor
113   //
114 }
115
116 //_____________________________________________________________________________
117 void AliAlignObjAngles::SetTranslation(const TGeoMatrix& m)
118 {
119   if(m.IsTranslation()){
120     const Double_t* tr = m.GetTranslation();
121     fTranslation[0]=tr[0];  fTranslation[1]=tr[1]; fTranslation[2]=tr[2];
122   }else{
123 //     AliWarning("Argument matrix is not a translation! Setting zero-translation.");
124     fTranslation[0] = fTranslation[1] = fTranslation[2] = 0.;
125   }
126 }
127
128 //_____________________________________________________________________________
129 Bool_t AliAlignObjAngles::SetRotation(const TGeoMatrix& m)
130 {
131   if(m.IsRotation()){
132     const Double_t* rot = m.GetRotationMatrix();
133     return MatrixToAngles(rot,fRotation);
134   }else{
135 //     AliWarning("Argument matrix is not a rotation! Setting yaw-pitch-roll to zero.");
136     fRotation[0] = fRotation[1] = fRotation[2] = 0.;
137     return kTRUE;
138   }
139 }
140
141 //_____________________________________________________________________________
142 void AliAlignObjAngles::SetMatrix(const TGeoMatrix& m)
143 {
144   SetTranslation(m);
145   SetRotation(m);
146 }
147
148 //_____________________________________________________________________________
149 void AliAlignObjAngles::GetPars(Double_t tr[], Double_t angles[]) const
150 {
151   GetTranslation(tr);
152   GetAngles(angles);
153 }
154
155 //_____________________________________________________________________________
156 void AliAlignObjAngles::GetMatrix(TGeoHMatrix& m) const
157 {
158   m.SetTranslation(&fTranslation[0]);
159   Double_t rot[9];
160   AnglesToMatrix(fRotation,rot);
161   m.SetRotation(rot);
162 }
163
164 //_____________________________________________________________________________
165 AliAlignObj& AliAlignObjAngles::Inverse() const
166 {
167   // Return a temporary inverse of the alignment
168   // object. This means 'mis
169    static AliAlignObjAngles a;
170    a = *this;
171
172    TGeoHMatrix m;
173    GetMatrix(m);
174    a.SetMatrix(m.Inverse());
175
176    return a;
177 }