AliRoot Core  edcc906 (edcc906)
AliAlignObjParams.cxx
Go to the documentation of this file.
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 // AliAlignObjParams derived from the base class AliAlignObj
20 //-----------------------------------------------------------------
21 
22 #include "AliLog.h"
23 #include "AliAlignObj.h"
24 #include "AliAlignObjParams.h"
25 
26 ClassImp(AliAlignObjParams)
27 
28 //_____________________________________________________________________________
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 AliAlignObjParams::AliAlignObjParams(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) : AliAlignObj(symname,volUId)
39 {
40  // standard constructor with 3 translation + 3 rotation parameters
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  //
46  if(global){
47  SetPars(x, y, z, psi, theta, phi);
48  }else{
49  if(!SetLocalPars(x,y,z,psi,theta,phi)) { AliFatal("Alignment object creation failed (TGeo instance needed)!"); }
50  }
51 }
52 
53 //_____________________________________________________________________________
54 AliAlignObjParams::AliAlignObjParams(const char* symname, UShort_t volUId, TGeoMatrix& m, Bool_t global) : AliAlignObj(symname,volUId)
55 {
56  // standard constructor with TGeoMatrix
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)
61  //
62 
63  if (!SetMatrix(m)) { AliFatal("Alignment object creation failed (can't extract roll-pitch-yall angles from the matrix)!");}
64 
65  if (!global) {
66  if (!SetLocalPars(fTranslation[0],fTranslation[1],fTranslation[2],fRotation[0],fRotation[1],fRotation[2])) { AliFatal ("Alignment object creation failed (TGeo instance needed)!"); }
67  }
68 }
69 
70 //_____________________________________________________________________________
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  if (theAlignObj.GetAngles(rot))
81  SetRotation(rot[0],rot[1],rot[2]);
82  else
83  fRotation[0]=fRotation[1]=fRotation[2]=0.;
84 }
85 
86 //_____________________________________________________________________________
88 {
89  // assignment operator
90  //
91  if(this==&theAlignObj) return *this;
92  ((AliAlignObj *)this)->operator=(theAlignObj);
93 
94  Double_t tr[3];
95  theAlignObj.GetTranslation(tr);
96  SetTranslation(tr[0],tr[1],tr[2]);
97  Double_t rot[3];
98  if (theAlignObj.GetAngles(rot))
99  SetRotation(rot[0],rot[1],rot[2]);
100 
101  return *this;
102 }
103 
104 //_____________________________________________________________________________
106 {
107  // default destructor
108  //
109 }
110 
111 //_____________________________________________________________________________
112 void AliAlignObjParams::SetTranslation(const TGeoMatrix& m)
113 {
114  // set the translation parameters extracting them from the matrix
115  // passed as argument
116  //
117  if(m.IsTranslation()){
118  const Double_t* tr = m.GetTranslation();
119  fTranslation[0]=tr[0]; fTranslation[1]=tr[1]; fTranslation[2]=tr[2];
120  }else{
121  fTranslation[0] = fTranslation[1] = fTranslation[2] = 0.;
122  }
123 }
124 
125 //_____________________________________________________________________________
126 Bool_t AliAlignObjParams::SetRotation(const TGeoMatrix& m)
127 {
128  // set the rotation parameters extracting them from the matrix
129  // passed as argument
130  //
131  if(m.IsRotation()){
132  const Double_t* rot = m.GetRotationMatrix();
133  return MatrixToAngles(rot,fRotation);
134  }else{
135  fRotation[0] = fRotation[1] = fRotation[2] = 0.;
136  return kTRUE;
137  }
138 }
139 
140 //_____________________________________________________________________________
141 void AliAlignObjParams::GetMatrix(TGeoHMatrix& m) const
142 {
143  // get the transformation matrix from the data memebers parameters
144  m.SetTranslation(&fTranslation[0]);
145  Double_t rot[9];
147  m.SetRotation(rot);
148 }
149 
150 //_____________________________________________________________________________
152 {
153  // Return a temporary "inverse" of the alignment object, that is return
154  // an object with inverted transformation matrix.
155  //
156  static AliAlignObjParams a;
157  a = *this;
158 
159  TGeoHMatrix m;
160  GetMatrix(m);
161  a.SetMatrix(m.Inverse());
162 
163  return a;
164 }
Bool_t MatrixToAngles(const Double_t *rot, Double_t *angles) const
void AnglesToMatrix(const Double_t *angles, Double_t *rot) const
virtual void GetMatrix(TGeoHMatrix &m) const
virtual void SetPars(Double_t x, Double_t y, Double_t z, Double_t psi, Double_t theta, Double_t phi)
virtual void SetTranslation(Double_t x, Double_t y, Double_t z)
AliAlignObjParams & operator=(const AliAlignObj &theAlignObj)
virtual Bool_t SetMatrix(const TGeoMatrix &m)
virtual Bool_t GetAngles(Double_t *angles) const =0
#define AliFatal(message)
Definition: AliLog.h:640
Double_t fTranslation[3]
virtual void GetTranslation(Double_t *tr) const =0
virtual AliAlignObj & Inverse() const
virtual Bool_t SetLocalPars(Double_t x, Double_t y, Double_t z, Double_t psi, Double_t theta, Double_t phi)
virtual void SetRotation(Double_t psi, Double_t theta, Double_t phi)