1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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 //-----------------------------------------------------------------
22 #include "AliAlignObj.h"
23 #include "AliAlignObjParams.h"
25 ClassImp(AliAlignObjParams)
27 //_____________________________________________________________________________
28 AliAlignObjParams::AliAlignObjParams() : AliAlignObj()
30 // default constructor
32 fTranslation[0]=fTranslation[1]=fTranslation[2]=0.;
33 fRotation[0]=fRotation[1]=fRotation[2]=0.;
36 //_____________________________________________________________________________
37 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) throw (const Char_t *) : AliAlignObj(symname,volUId)
39 // standard constructor with 3 translation + 3 rotation parameters
40 // If the user explicitly sets the global variable to kFALSE then the
41 // parameters are interpreted as giving the local transformation.
42 // This requires to have a gGeoMenager active instance, otherwise the
43 // constructor will fail (no object created)
46 SetPars(x, y, z, psi, theta, phi);
48 if(!SetLocalPars(x,y,z,psi,theta,phi)) throw "Alignment object creation failed (TGeo instance needed)!\n";
52 //_____________________________________________________________________________
53 AliAlignObjParams::AliAlignObjParams(const char* symname, UShort_t volUId, TGeoMatrix& m, Bool_t global) throw (const Char_t *) : AliAlignObj(symname,volUId)
55 // standard constructor with TGeoMatrix
56 // If the user explicitly sets the global variable to kFALSE then the
57 // parameters are interpreted as giving the local transformation.
58 // This requires to have a gGeoMenager active instance, otherwise the
59 // constructor will fail (no object created)
62 if (!SetMatrix(m)) throw "Alignment object creation failed (can't extract roll-pitch-yall angles from the matrix)!\n";
65 if (!SetLocalPars(fTranslation[0],fTranslation[1],fTranslation[2],fRotation[0],fRotation[1],fRotation[2])) throw "Alignment object creation failed (TGeo instance needed)!\n";
69 //_____________________________________________________________________________
70 AliAlignObjParams::AliAlignObjParams(const AliAlignObj& theAlignObj) :
71 AliAlignObj(theAlignObj)
76 theAlignObj.GetTranslation(tr);
77 SetTranslation(tr[0],tr[1],tr[2]);
79 if (theAlignObj.GetAngles(rot))
80 SetRotation(rot[0],rot[1],rot[2]);
82 fRotation[0]=fRotation[1]=fRotation[2]=0.;
85 //_____________________________________________________________________________
86 AliAlignObjParams &AliAlignObjParams::operator =(const AliAlignObj& theAlignObj)
88 // assignment operator
90 if(this==&theAlignObj) return *this;
91 ((AliAlignObj *)this)->operator=(theAlignObj);
94 theAlignObj.GetTranslation(tr);
95 SetTranslation(tr[0],tr[1],tr[2]);
97 if (theAlignObj.GetAngles(rot))
98 SetRotation(rot[0],rot[1],rot[2]);
103 //_____________________________________________________________________________
104 AliAlignObjParams::~AliAlignObjParams()
106 // default destructor
110 //_____________________________________________________________________________
111 void AliAlignObjParams::SetTranslation(const TGeoMatrix& m)
113 // set the translation parameters extracting them from the matrix
114 // passed as argument
116 if(m.IsTranslation()){
117 const Double_t* tr = m.GetTranslation();
118 fTranslation[0]=tr[0]; fTranslation[1]=tr[1]; fTranslation[2]=tr[2];
120 fTranslation[0] = fTranslation[1] = fTranslation[2] = 0.;
124 //_____________________________________________________________________________
125 Bool_t AliAlignObjParams::SetRotation(const TGeoMatrix& m)
127 // set the rotation parameters extracting them from the matrix
128 // passed as argument
131 const Double_t* rot = m.GetRotationMatrix();
132 return MatrixToAngles(rot,fRotation);
134 fRotation[0] = fRotation[1] = fRotation[2] = 0.;
139 //_____________________________________________________________________________
140 void AliAlignObjParams::GetMatrix(TGeoHMatrix& m) const
142 // get the transformation matrix from the data memebers parameters
143 m.SetTranslation(&fTranslation[0]);
145 AnglesToMatrix(fRotation,rot);
149 //_____________________________________________________________________________
150 AliAlignObj& AliAlignObjParams::Inverse() const
152 // Return a temporary "inverse" of the alignment object, that is return
153 // an object with inverted transformation matrix.
155 static AliAlignObjParams a;
160 a.SetMatrix(m.Inverse());