]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliAlignObjAngles.cxx
moved AliSelector, AliSelectorRL to STEER
[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//_____________________________________________________________________________
b760c02e 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, Bool_t global) throw (const Char_t *) : AliAlignObj(volpath,volUId)
befe2c08 39{
40 // standard constructor with 3 translation + 3 rotation parameters
48c8e89a 41 // If the user explicitly sets the global variable to kFALSE then the
42 // parameters are interpreted as giving the local transformation.
43 // This requires to have a gGeoMenager active instance, otherwise the
44 // constructor will fail (no object created)
45 //
48c8e89a 46 if(global){
b760c02e 47 SetPars(x, y, z, psi, theta, phi);
48c8e89a 48 }else{
49 if(!SetLocalPars(x,y,z,psi,theta,phi)) throw "Alignment object creation failed (TGeo instance needed)!\n";
50 }
befe2c08 51}
52
53//_____________________________________________________________________________
b760c02e 54AliAlignObjAngles::AliAlignObjAngles(const char* volpath, UShort_t volUId, TGeoMatrix& m, Bool_t global) throw (const Char_t *) : AliAlignObj(volpath,volUId)
befe2c08 55{
56 // standard constructor with TGeoMatrix
b760c02e 57 // If the user explicitly sets the global variable to kFALSE then the
58 // parameters are interpreted as giving the local transformation.
59 // This requires to have a gGeoMenager active instance, otherwise the
60 // constructor will fail (no object created)
befe2c08 61 //
befe2c08 62
b760c02e 63 if (!SetMatrix(m)) throw "Alignment object creation failed (can't extract roll-pitch-yall angles from the matrix)!\n";
64
65 if (!global) {
66 if (!SetLocalPars(fTranslation[0],fTranslation[1],fTranslation[2],fRotation[0],fRotation[1],fRotation[2])) throw "Alignment object creation failed (TGeo instance needed)!\n";
67 }
d9cc42ed 68}
69
befe2c08 70//_____________________________________________________________________________
c5304981 71AliAlignObjAngles::AliAlignObjAngles(const AliAlignObj& theAlignObj) :
befe2c08 72 AliAlignObj(theAlignObj)
73{
74 // copy constructor
75 //
76 Double_t tr[3];
77 theAlignObj.GetTranslation(tr);
78 SetTranslation(tr[0],tr[1],tr[2]);
79 Double_t rot[3];
b760c02e 80 if (theAlignObj.GetAngles(rot))
81 SetRotation(rot[0],rot[1],rot[2]);
befe2c08 82}
83
84//_____________________________________________________________________________
c5304981 85AliAlignObjAngles &AliAlignObjAngles::operator =(const AliAlignObj& theAlignObj)
befe2c08 86{
87 // assignment operator
88 //
89 if(this==&theAlignObj) return *this;
90 ((AliAlignObj *)this)->operator=(theAlignObj);
91
92 Double_t tr[3];
93 theAlignObj.GetTranslation(tr);
94 SetTranslation(tr[0],tr[1],tr[2]);
95 Double_t rot[3];
b760c02e 96 if (theAlignObj.GetAngles(rot))
97 SetRotation(rot[0],rot[1],rot[2]);
98
befe2c08 99 return *this;
100}
101
102//_____________________________________________________________________________
103AliAlignObjAngles::~AliAlignObjAngles()
104{
105 // default destructor
106 //
107}
108
109//_____________________________________________________________________________
110void AliAlignObjAngles::SetTranslation(const TGeoMatrix& m)
111{
112 if(m.IsTranslation()){
113 const Double_t* tr = m.GetTranslation();
114 fTranslation[0]=tr[0]; fTranslation[1]=tr[1]; fTranslation[2]=tr[2];
115 }else{
befe2c08 116 fTranslation[0] = fTranslation[1] = fTranslation[2] = 0.;
117 }
118}
119
120//_____________________________________________________________________________
121Bool_t AliAlignObjAngles::SetRotation(const TGeoMatrix& m)
122{
123 if(m.IsRotation()){
124 const Double_t* rot = m.GetRotationMatrix();
125 return MatrixToAngles(rot,fRotation);
126 }else{
befe2c08 127 fRotation[0] = fRotation[1] = fRotation[2] = 0.;
128 return kTRUE;
129 }
130}
131
befe2c08 132//_____________________________________________________________________________
133void AliAlignObjAngles::GetMatrix(TGeoHMatrix& m) const
134{
135 m.SetTranslation(&fTranslation[0]);
136 Double_t rot[9];
137 AnglesToMatrix(fRotation,rot);
138 m.SetRotation(rot);
139}
140
03b18860 141//_____________________________________________________________________________
142AliAlignObj& AliAlignObjAngles::Inverse() const
143{
144 // Return a temporary inverse of the alignment
145 // object. This means 'mis
146 static AliAlignObjAngles a;
147 a = *this;
148
149 TGeoHMatrix m;
150 GetMatrix(m);
151 a.SetMatrix(m.Inverse());
152
153 return a;
154}