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 // AliAlignObjAngles derived from the base class AliAlignObj
20 //-----------------------------------------------------------------
22 #include "AliAlignObj.h"
23 #include "AliAlignObjAngles.h"
26 ClassImp(AliAlignObjAngles)
28 //_____________________________________________________________________________
29 AliAlignObjAngles::AliAlignObjAngles() : AliAlignObj()
31 // default constructor
33 fTranslation[0]=fTranslation[1]=fTranslation[2]=0.;
34 fRotation[0]=fRotation[1]=fRotation[2]=0.;
37 //_____________________________________________________________________________
38 AliAlignObjAngles::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)
40 // standard constructor with 3 translation + 3 rotation parameters
42 fTranslation[0]=x; fTranslation[1]=y; fTranslation[2]=z;
43 fRotation[0]=psi; fRotation[1]=theta; fRotation[2]=phi;
46 //_____________________________________________________________________________
47 AliAlignObjAngles::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)
49 // standard constructor with 3 translation + 3 rotation parameters
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)
56 fTranslation[0]=x; fTranslation[1]=y; fTranslation[2]=z;
57 fRotation[0]=psi; fRotation[1]=theta; fRotation[2]=phi;
59 if(!SetLocalPars(x,y,z,psi,theta,phi)) throw "Alignment object creation failed (TGeo instance needed)!\n";
63 //_____________________________________________________________________________
64 AliAlignObjAngles::AliAlignObjAngles(const char* volpath, UShort_t voluid, TGeoMatrix& m) : AliAlignObj()
66 // standard constructor with TGeoMatrix
74 //_____________________________________________________________________________
75 AliAlignObjAngles::AliAlignObjAngles(const char* volpath, ELayerID layerId, Int_t volId, TGeoMatrix& m) : AliAlignObj(volpath,layerId,volId)
77 // standard constructor with TGeoMatrix
83 //_____________________________________________________________________________
84 AliAlignObjAngles::AliAlignObjAngles(const AliAlignObj& theAlignObj) :
85 AliAlignObj(theAlignObj)
90 theAlignObj.GetTranslation(tr);
91 SetTranslation(tr[0],tr[1],tr[2]);
93 theAlignObj.GetAngles(rot);
94 SetRotation(rot[0],rot[1],rot[2]);
97 //_____________________________________________________________________________
98 AliAlignObjAngles &AliAlignObjAngles::operator =(const AliAlignObj& theAlignObj)
100 // assignment operator
102 if(this==&theAlignObj) return *this;
103 ((AliAlignObj *)this)->operator=(theAlignObj);
106 theAlignObj.GetTranslation(tr);
107 SetTranslation(tr[0],tr[1],tr[2]);
109 theAlignObj.GetAngles(rot);
110 SetRotation(rot[0],rot[1],rot[2]);
114 //_____________________________________________________________________________
115 AliAlignObjAngles::~AliAlignObjAngles()
117 // default destructor
121 //_____________________________________________________________________________
122 void AliAlignObjAngles::SetTranslation(const TGeoMatrix& m)
124 if(m.IsTranslation()){
125 const Double_t* tr = m.GetTranslation();
126 fTranslation[0]=tr[0]; fTranslation[1]=tr[1]; fTranslation[2]=tr[2];
128 // AliWarning("Argument matrix is not a translation! Setting zero-translation.");
129 fTranslation[0] = fTranslation[1] = fTranslation[2] = 0.;
133 //_____________________________________________________________________________
134 Bool_t AliAlignObjAngles::SetRotation(const TGeoMatrix& m)
137 const Double_t* rot = m.GetRotationMatrix();
138 return MatrixToAngles(rot,fRotation);
140 // AliWarning("Argument matrix is not a rotation! Setting yaw-pitch-roll to zero.");
141 fRotation[0] = fRotation[1] = fRotation[2] = 0.;
146 //_____________________________________________________________________________
147 void AliAlignObjAngles::SetMatrix(const TGeoMatrix& m)
153 //_____________________________________________________________________________
154 void AliAlignObjAngles::GetPars(Double_t tr[], Double_t angles[]) const
160 //_____________________________________________________________________________
161 void AliAlignObjAngles::GetMatrix(TGeoHMatrix& m) const
163 m.SetTranslation(&fTranslation[0]);
165 AnglesToMatrix(fRotation,rot);
169 //_____________________________________________________________________________
170 AliAlignObj& AliAlignObjAngles::Inverse() const
172 // Return a temporary inverse of the alignment
173 // object. This means 'mis
174 static AliAlignObjAngles a;
179 a.SetMatrix(m.Inverse());