]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliAlignObjAngles.cxx
Corrected LUT for the alignable volume paths in TRD (R.Grosso)
[u/mrichter/AliRoot.git] / STEER / AliAlignObjAngles.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 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
26ClassImp(AliAlignObjAngles)
27
28//_____________________________________________________________________________
03b18860 29AliAlignObjAngles::AliAlignObjAngles() : AliAlignObj()
befe2c08 30{
31 // default constructor
32 //
33 fTranslation[0]=fTranslation[1]=fTranslation[2]=0.;
34 fRotation[0]=fRotation[1]=fRotation[2]=0.;
35}
36
37//_____________________________________________________________________________
d9cc42ed 38AliAlignObjAngles::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(volpath,volUID)
befe2c08 39{
40 // standard constructor with 3 translation + 3 rotation parameters
41 //
befe2c08 42 fTranslation[0]=x; fTranslation[1]=y; fTranslation[2]=z;
43 fRotation[0]=psi; fRotation[1]=theta; fRotation[2]=phi;
44}
45
46//_____________________________________________________________________________
d9cc42ed 47AliAlignObjAngles::AliAlignObjAngles(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 *) : AliAlignObj(volpath,layerId,volId)
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 //
48c8e89a 55 if(global){
56 fTranslation[0]=x; fTranslation[1]=y; fTranslation[2]=z;
57 fRotation[0]=psi; fRotation[1]=theta; fRotation[2]=phi;
58 }else{
59 if(!SetLocalPars(x,y,z,psi,theta,phi)) throw "Alignment object creation failed (TGeo instance needed)!\n";
60 }
befe2c08 61}
62
63//_____________________________________________________________________________
03b18860 64AliAlignObjAngles::AliAlignObjAngles(const char* volpath, UShort_t voluid, TGeoMatrix& m) : AliAlignObj()
befe2c08 65{
66 // standard constructor with TGeoMatrix
67 //
68 fVolPath=volpath;
69 fVolUID=voluid;
70 SetTranslation(m);
71 SetRotation(m);
72}
73
d9cc42ed 74//_____________________________________________________________________________
75AliAlignObjAngles::AliAlignObjAngles(const char* volpath, ELayerID layerId, Int_t volId, TGeoMatrix& m) : AliAlignObj(volpath,layerId,volId)
76{
77 // standard constructor with TGeoMatrix
78 //
79 SetTranslation(m);
80 SetRotation(m);
81}
82
befe2c08 83//_____________________________________________________________________________
c5304981 84AliAlignObjAngles::AliAlignObjAngles(const AliAlignObj& theAlignObj) :
befe2c08 85 AliAlignObj(theAlignObj)
86{
87 // copy constructor
88 //
89 Double_t tr[3];
90 theAlignObj.GetTranslation(tr);
91 SetTranslation(tr[0],tr[1],tr[2]);
92 Double_t rot[3];
93 theAlignObj.GetAngles(rot);
94 SetRotation(rot[0],rot[1],rot[2]);
95}
96
97//_____________________________________________________________________________
c5304981 98AliAlignObjAngles &AliAlignObjAngles::operator =(const AliAlignObj& theAlignObj)
befe2c08 99{
100 // assignment operator
101 //
102 if(this==&theAlignObj) return *this;
103 ((AliAlignObj *)this)->operator=(theAlignObj);
104
105 Double_t tr[3];
106 theAlignObj.GetTranslation(tr);
107 SetTranslation(tr[0],tr[1],tr[2]);
108 Double_t rot[3];
109 theAlignObj.GetAngles(rot);
110 SetRotation(rot[0],rot[1],rot[2]);
111 return *this;
112}
113
114//_____________________________________________________________________________
115AliAlignObjAngles::~AliAlignObjAngles()
116{
117 // default destructor
118 //
119}
120
121//_____________________________________________________________________________
122void AliAlignObjAngles::SetTranslation(const TGeoMatrix& m)
123{
124 if(m.IsTranslation()){
125 const Double_t* tr = m.GetTranslation();
126 fTranslation[0]=tr[0]; fTranslation[1]=tr[1]; fTranslation[2]=tr[2];
127 }else{
128// AliWarning("Argument matrix is not a translation! Setting zero-translation.");
129 fTranslation[0] = fTranslation[1] = fTranslation[2] = 0.;
130 }
131}
132
133//_____________________________________________________________________________
134Bool_t AliAlignObjAngles::SetRotation(const TGeoMatrix& m)
135{
136 if(m.IsRotation()){
137 const Double_t* rot = m.GetRotationMatrix();
138 return MatrixToAngles(rot,fRotation);
139 }else{
140// AliWarning("Argument matrix is not a rotation! Setting yaw-pitch-roll to zero.");
141 fRotation[0] = fRotation[1] = fRotation[2] = 0.;
142 return kTRUE;
143 }
144}
145
146//_____________________________________________________________________________
147void AliAlignObjAngles::SetMatrix(const TGeoMatrix& m)
148{
149 SetTranslation(m);
150 SetRotation(m);
151}
152
153//_____________________________________________________________________________
154void AliAlignObjAngles::GetPars(Double_t tr[], Double_t angles[]) const
155{
156 GetTranslation(tr);
157 GetAngles(angles);
158}
159
160//_____________________________________________________________________________
161void AliAlignObjAngles::GetMatrix(TGeoHMatrix& m) const
162{
163 m.SetTranslation(&fTranslation[0]);
164 Double_t rot[9];
165 AnglesToMatrix(fRotation,rot);
166 m.SetRotation(rot);
167}
168
03b18860 169//_____________________________________________________________________________
170AliAlignObj& AliAlignObjAngles::Inverse() const
171{
172 // Return a temporary inverse of the alignment
173 // object. This means 'mis
174 static AliAlignObjAngles a;
175 a = *this;
176
177 TGeoHMatrix m;
178 GetMatrix(m);
179 a.SetMatrix(m.Inverse());
180
181 return a;
182}