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 the abstract
18 // class AliAlignObj. From it two derived concrete representation of
19 // alignment object class (AliAlignObjAngles, AliAlignObjMatrix) are
20 // derived in separate files.
21 //-----------------------------------------------------------------
22 /*****************************************************************************
23 * AliAlignObjAngles: derived alignment class storing alignment information *
24 * for a single volume in form of three doubles for the translation *
25 * and three doubles for the rotation expressed with the euler angles *
26 * in the xyz-convention (http://mathworld.wolfram.com/EulerAngles.html), *
27 * also known as roll, pitch, yaw. PLEASE NOTE THE ANGLES SIGNS ARE *
28 * INVERSE WITH RESPECT TO THIS REFERENCE!!! In this way the representation*
29 * is fully consistent with the TGeo Rotation methods. *
30 *****************************************************************************/
32 #include "AliAlignObj.h"
37 Int_t AliAlignObj::fgLayerSize[kLastLayer - kFirstLayer] = {
42 90, 90, 90, 90, 90, 90, // TRD
49 const char* AliAlignObj::fgLayerName[kLastLayer - kFirstLayer] = {
50 "ITS inner pixels layer", "ITS outer pixels layer",
51 "ITS inner drifts layer", "ITS outer drifts layer",
52 "ITS inner strips layer", "ITS outer strips layer",
53 "TPC inner chambers layer", "TPC outer chambers layer",
54 "TRD chambers layer 1", "TRD chambers layer 2", "TRD chambers layer 3",
55 "TRD chambers layer 4", "TRD chambers layer 5", "TRD chambers layer 6",
62 //_____________________________________________________________________________
63 AliAlignObj::AliAlignObj():
69 //_____________________________________________________________________________
70 AliAlignObj::AliAlignObj(const AliAlignObj& theAlignObj) :
74 fVolPath = theAlignObj.GetVolPath();
75 fVolUID = theAlignObj.GetVolUID();
78 //_____________________________________________________________________________
79 AliAlignObj &AliAlignObj::operator =(const AliAlignObj& theAlignObj)
81 // assignment operator
82 if(this==&theAlignObj) return *this;
83 fVolPath = theAlignObj.GetVolPath();
84 fVolUID = theAlignObj.GetVolUID();
88 //_____________________________________________________________________________
89 AliAlignObj::~AliAlignObj()
94 //_____________________________________________________________________________
95 void AliAlignObj::SetVolUID(ELayerID detId, Int_t modId)
97 // From detector name and module number (according to detector numbering)
98 // build fVolUID, unique numerical identity of that volume inside ALICE
99 // fVolUID is 16 bits, first 5 reserved for detID (32 possible values),
100 // remaining 11 for module ID inside det (2048 possible values).
102 fVolUID = LayerToVolUID(detId,modId);
105 //_____________________________________________________________________________
106 void AliAlignObj::GetVolUID(ELayerID &layerId, Int_t &modId) const
108 // From detector name and module number (according to detector numbering)
109 // build fVolUID, unique numerical identity of that volume inside ALICE
110 // fVolUID is 16 bits, first 5 reserved for detID (32 possible values),
111 // remaining 11 for module ID inside det (2048 possible values).
113 layerId = VolUIDToLayer(fVolUID,modId);
116 //_____________________________________________________________________________
117 void AliAlignObj::AnglesToMatrix(const Double_t *angles, Double_t *rot) const
119 // Calculates the rotation matrix using the
120 // Euler angles in "x y z" notation
121 Double_t degrad = TMath::DegToRad();
122 Double_t sinpsi = TMath::Sin(degrad*angles[0]);
123 Double_t cospsi = TMath::Cos(degrad*angles[0]);
124 Double_t sinthe = TMath::Sin(degrad*angles[1]);
125 Double_t costhe = TMath::Cos(degrad*angles[1]);
126 Double_t sinphi = TMath::Sin(degrad*angles[2]);
127 Double_t cosphi = TMath::Cos(degrad*angles[2]);
129 rot[0] = costhe*cosphi;
130 rot[1] = -costhe*sinphi;
132 rot[3] = sinpsi*sinthe*cosphi + cospsi*sinphi;
133 rot[4] = -sinpsi*sinthe*sinphi + cospsi*cosphi;
134 rot[5] = -costhe*sinpsi;
135 rot[6] = -cospsi*sinthe*cosphi + sinpsi*sinphi;
136 rot[7] = cospsi*sinthe*sinphi + sinpsi*cosphi;
137 rot[8] = costhe*cospsi;
140 //_____________________________________________________________________________
141 Bool_t AliAlignObj::MatrixToAngles(const Double_t *rot, Double_t *angles) const
143 // Calculates the Euler angles in "x y z" notation
144 // using the rotation matrix
145 if(rot[0]<1e-7 || rot[8]<1e-7) return kFALSE;
146 Double_t raddeg = TMath::RadToDeg();
147 angles[0]=raddeg*TMath::ATan2(-rot[5],rot[8]);
148 angles[1]=raddeg*TMath::ASin(rot[2]);
149 angles[2]=raddeg*TMath::ATan2(-rot[1],rot[0]);
153 //_____________________________________________________________________________
154 void AliAlignObj::Print(Option_t *) const
156 // Print the contents of the
157 // alignment object in angles and
158 // matrix representations
165 const Double_t *rot = m.GetRotationMatrix();
166 // printf("Volume=%s ID=%u\n", GetVolPath(),GetVolUID());
169 GetVolUID(layerId,modId);
170 printf("Volume=%s LayerID=%d ModuleID=%d\n", GetVolPath(),layerId,modId);
171 printf("%12.6f%12.6f%12.6f Tx = %12.6f Psi = %12.6f\n", rot[0], rot[1], rot[2], tr[0], angles[0]);
172 printf("%12.6f%12.6f%12.6f Ty = %12.6f Theta = %12.6f\n", rot[3], rot[4], rot[5], tr[1], angles[1]);
173 printf("%12.6f%12.6f%12.6f Tz = %12.6f Phi = %12.6f\n", rot[6], rot[7], rot[8], tr[2], angles[2]);
177 //_____________________________________________________________________________
178 UShort_t AliAlignObj::LayerToVolUID(ELayerID layerId, Int_t modId)
180 // From detector (layer) name and module number (according to detector numbering)
181 // build fVolUID, unique numerical identity of that volume inside ALICE
182 // fVolUID is 16 bits, first 5 reserved for layerID (32 possible values),
183 // remaining 11 for module ID inside det (2048 possible values).
185 return ((UShort_t(layerId) << 11) | UShort_t(modId));
188 //_____________________________________________________________________________
189 AliAlignObj::ELayerID AliAlignObj::VolUIDToLayer(UShort_t voluid, Int_t &modId)
191 // From detector (layer) name and module number (according to detector numbering)
192 // build fVolUID, unique numerical identity of that volume inside ALICE
193 // fVolUID is 16 bits, first 5 reserved for layerID (32 possible values),
194 // remaining 11 for module ID inside det (2048 possible values).
196 modId = voluid & 0x7ff;
198 return VolUIDToLayer(voluid);
201 //_____________________________________________________________________________
202 AliAlignObj::ELayerID AliAlignObj::VolUIDToLayer(UShort_t voluid)
204 // From detector (layer) name and module number (according to detector numbering)
205 // build fVolUID, unique numerical identity of that volume inside ALICE
206 // fVolUID is 16 bits, first 5 reserved for layerID (32 possible values),
207 // remaining 11 for module ID inside det (2048 possible values).
209 return ELayerID((voluid >> 11) & 0x1f);