]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliAlignObjAngles.cxx
Avoid mixing up trigger and tracks replacing the option "CP" by
[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"
befe2c08 24
25ClassImp(AliAlignObjAngles)
26
27//_____________________________________________________________________________
03b18860 28AliAlignObjAngles::AliAlignObjAngles() : AliAlignObj()
befe2c08 29{
30 // default constructor
31 //
32 fTranslation[0]=fTranslation[1]=fTranslation[2]=0.;
33 fRotation[0]=fRotation[1]=fRotation[2]=0.;
34}
35
36//_____________________________________________________________________________
b760c02e 37AliAlignObjAngles::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 38{
39 // standard constructor with 3 translation + 3 rotation parameters
48c8e89a 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)
44 //
48c8e89a 45 if(global){
b760c02e 46 SetPars(x, y, z, psi, theta, phi);
48c8e89a 47 }else{
48 if(!SetLocalPars(x,y,z,psi,theta,phi)) throw "Alignment object creation failed (TGeo instance needed)!\n";
49 }
befe2c08 50}
51
52//_____________________________________________________________________________
b760c02e 53AliAlignObjAngles::AliAlignObjAngles(const char* volpath, UShort_t volUId, TGeoMatrix& m, Bool_t global) throw (const Char_t *) : AliAlignObj(volpath,volUId)
befe2c08 54{
55 // standard constructor with TGeoMatrix
b760c02e 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)
befe2c08 60 //
befe2c08 61
b760c02e 62 if (!SetMatrix(m)) throw "Alignment object creation failed (can't extract roll-pitch-yall angles from the matrix)!\n";
63
64 if (!global) {
65 if (!SetLocalPars(fTranslation[0],fTranslation[1],fTranslation[2],fRotation[0],fRotation[1],fRotation[2])) throw "Alignment object creation failed (TGeo instance needed)!\n";
66 }
d9cc42ed 67}
68
befe2c08 69//_____________________________________________________________________________
c5304981 70AliAlignObjAngles::AliAlignObjAngles(const AliAlignObj& theAlignObj) :
befe2c08 71 AliAlignObj(theAlignObj)
72{
73 // copy constructor
74 //
75 Double_t tr[3];
76 theAlignObj.GetTranslation(tr);
77 SetTranslation(tr[0],tr[1],tr[2]);
78 Double_t rot[3];
b760c02e 79 if (theAlignObj.GetAngles(rot))
80 SetRotation(rot[0],rot[1],rot[2]);
befe2c08 81}
82
83//_____________________________________________________________________________
c5304981 84AliAlignObjAngles &AliAlignObjAngles::operator =(const AliAlignObj& theAlignObj)
befe2c08 85{
86 // assignment operator
87 //
88 if(this==&theAlignObj) return *this;
89 ((AliAlignObj *)this)->operator=(theAlignObj);
90
91 Double_t tr[3];
92 theAlignObj.GetTranslation(tr);
93 SetTranslation(tr[0],tr[1],tr[2]);
94 Double_t rot[3];
b760c02e 95 if (theAlignObj.GetAngles(rot))
96 SetRotation(rot[0],rot[1],rot[2]);
97
befe2c08 98 return *this;
99}
100
101//_____________________________________________________________________________
102AliAlignObjAngles::~AliAlignObjAngles()
103{
104 // default destructor
105 //
106}
107
108//_____________________________________________________________________________
109void AliAlignObjAngles::SetTranslation(const TGeoMatrix& m)
110{
ff2dbca1 111 // set the translation parameters extracting them from the matrix
112 // passed as argument
113 //
befe2c08 114 if(m.IsTranslation()){
115 const Double_t* tr = m.GetTranslation();
116 fTranslation[0]=tr[0]; fTranslation[1]=tr[1]; fTranslation[2]=tr[2];
117 }else{
befe2c08 118 fTranslation[0] = fTranslation[1] = fTranslation[2] = 0.;
119 }
120}
121
122//_____________________________________________________________________________
123Bool_t AliAlignObjAngles::SetRotation(const TGeoMatrix& m)
124{
ff2dbca1 125 // set the rotation parameters extracting them from the matrix
126 // passed as argument
127 //
befe2c08 128 if(m.IsRotation()){
129 const Double_t* rot = m.GetRotationMatrix();
130 return MatrixToAngles(rot,fRotation);
131 }else{
befe2c08 132 fRotation[0] = fRotation[1] = fRotation[2] = 0.;
133 return kTRUE;
134 }
135}
136
befe2c08 137//_____________________________________________________________________________
138void AliAlignObjAngles::GetMatrix(TGeoHMatrix& m) const
139{
ff2dbca1 140 // get the transformation matrix from the data memebers parameters
befe2c08 141 m.SetTranslation(&fTranslation[0]);
142 Double_t rot[9];
143 AnglesToMatrix(fRotation,rot);
144 m.SetRotation(rot);
145}
146
03b18860 147//_____________________________________________________________________________
148AliAlignObj& AliAlignObjAngles::Inverse() const
149{
ff2dbca1 150 // Return a temporary "inverse" of the alignment object, that is return
151 // an object with inverted transformation matrix.
152 //
03b18860 153 static AliAlignObjAngles a;
154 a = *this;
155
156 TGeoHMatrix m;
157 GetMatrix(m);
158 a.SetMatrix(m.Inverse());
159
160 return a;
161}