Improved version of alignmnet object classes (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//_____________________________________________________________________________
29AliAlignObjAngles::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//_____________________________________________________________________________
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)
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//_____________________________________________________________________________
49AliAlignObjAngles::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)
50{
51 // standard constructor with 3 translation + 3 rotation parameters
52 //
53 fVolPath=volpath;
54 SetVolUID(detId,volId);
55 fTranslation[0]=x; fTranslation[1]=y; fTranslation[2]=z;
56 fRotation[0]=psi; fRotation[1]=theta; fRotation[2]=phi;
57}
58
59//_____________________________________________________________________________
60AliAlignObjAngles::AliAlignObjAngles(const char* volpath, UShort_t voluid, TGeoMatrix& m)
61{
62 // standard constructor with TGeoMatrix
63 //
64 fVolPath=volpath;
65 fVolUID=voluid;
66 SetTranslation(m);
67 SetRotation(m);
68}
69
70//_____________________________________________________________________________
71AliAlignObjAngles::AliAlignObjAngles(const AliAlignObjAngles& theAlignObj) :
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];
80 theAlignObj.GetAngles(rot);
81 SetRotation(rot[0],rot[1],rot[2]);
82}
83
84//_____________________________________________________________________________
85AliAlignObjAngles &AliAlignObjAngles::operator =(const AliAlignObjAngles& theAlignObj)
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];
96 theAlignObj.GetAngles(rot);
97 SetRotation(rot[0],rot[1],rot[2]);
98 return *this;
99}
100
101//_____________________________________________________________________________
102AliAlignObjAngles::~AliAlignObjAngles()
103{
104 // default destructor
105 //
106}
107
108//_____________________________________________________________________________
109void AliAlignObjAngles::SetTranslation(const TGeoMatrix& m)
110{
111 if(m.IsTranslation()){
112 const Double_t* tr = m.GetTranslation();
113 fTranslation[0]=tr[0]; fTranslation[1]=tr[1]; fTranslation[2]=tr[2];
114 }else{
115// AliWarning("Argument matrix is not a translation! Setting zero-translation.");
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{
127// AliWarning("Argument matrix is not a rotation! Setting yaw-pitch-roll to zero.");
128 fRotation[0] = fRotation[1] = fRotation[2] = 0.;
129 return kTRUE;
130 }
131}
132
133//_____________________________________________________________________________
134void AliAlignObjAngles::SetMatrix(const TGeoMatrix& m)
135{
136 SetTranslation(m);
137 SetRotation(m);
138}
139
140//_____________________________________________________________________________
141void AliAlignObjAngles::GetPars(Double_t tr[], Double_t angles[]) const
142{
143 GetTranslation(tr);
144 GetAngles(angles);
145}
146
147//_____________________________________________________________________________
148void AliAlignObjAngles::GetMatrix(TGeoHMatrix& m) const
149{
150 m.SetTranslation(&fTranslation[0]);
151 Double_t rot[9];
152 AnglesToMatrix(fRotation,rot);
153 m.SetRotation(rot);
154}
155