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 //_____________________________________________________________________________
38 AliAlignObj::AliAlignObj():
44 //_____________________________________________________________________________
45 AliAlignObj::AliAlignObj(const AliAlignObj& theAlignObj) :
49 fVolPath = theAlignObj.GetVolPath();
50 fVolUID = theAlignObj.GetVolUID();
53 //_____________________________________________________________________________
54 AliAlignObj &AliAlignObj::operator =(const AliAlignObj& theAlignObj)
56 // assignment operator
57 if(this==&theAlignObj) return *this;
58 fVolPath = theAlignObj.GetVolPath();
59 fVolUID = theAlignObj.GetVolUID();
63 //_____________________________________________________________________________
64 AliAlignObj::~AliAlignObj()
69 //_____________________________________________________________________________
70 void AliAlignObj::SetVolUID(ELayerID detId, Int_t modId)
72 // From detector name and module number (according to detector numbering)
73 // build fVolUID, unique numerical identity of that volume inside ALICE
74 // fVolUID is 16 bits, first 5 reserved for detID (32 possible values),
75 // remaining 11 for module ID inside det (2048 possible values).
77 fVolUID = LayerToVolUID(detId,modId);
80 //_____________________________________________________________________________
81 void AliAlignObj::GetVolUID(ELayerID &layerId, Int_t &modId) const
83 // From detector name and module number (according to detector numbering)
84 // build fVolUID, unique numerical identity of that volume inside ALICE
85 // fVolUID is 16 bits, first 5 reserved for detID (32 possible values),
86 // remaining 11 for module ID inside det (2048 possible values).
88 layerId = VolUIDToLayer(fVolUID,modId);
91 //_____________________________________________________________________________
92 void AliAlignObj::AnglesToMatrix(const Double_t *angles, Double_t *rot) const
94 // Calculates the rotation matrix using the
95 // Euler angles in "x y z" notation
96 Double_t degrad = TMath::DegToRad();
97 Double_t sinpsi = TMath::Sin(degrad*angles[0]);
98 Double_t cospsi = TMath::Cos(degrad*angles[0]);
99 Double_t sinthe = TMath::Sin(degrad*angles[1]);
100 Double_t costhe = TMath::Cos(degrad*angles[1]);
101 Double_t sinphi = TMath::Sin(degrad*angles[2]);
102 Double_t cosphi = TMath::Cos(degrad*angles[2]);
104 rot[0] = costhe*cosphi;
105 rot[1] = -costhe*sinphi;
107 rot[3] = sinpsi*sinthe*cosphi + cospsi*sinphi;
108 rot[4] = -sinpsi*sinthe*sinphi + cospsi*cosphi;
109 rot[5] = -costhe*sinpsi;
110 rot[6] = -cospsi*sinthe*cosphi + sinpsi*sinphi;
111 rot[7] = cospsi*sinthe*sinphi + sinpsi*cosphi;
112 rot[8] = costhe*cospsi;
115 //_____________________________________________________________________________
116 Bool_t AliAlignObj::MatrixToAngles(const Double_t *rot, Double_t *angles) const
118 // Calculates the Euler angles in "x y z" notation
119 // using the rotation matrix
120 if(rot[0]<1e-7 || rot[8]<1e-7) return kFALSE;
121 Double_t raddeg = TMath::RadToDeg();
122 angles[0]=raddeg*TMath::ATan2(-rot[5],rot[8]);
123 angles[1]=raddeg*TMath::ASin(rot[2]);
124 angles[2]=raddeg*TMath::ATan2(-rot[1],rot[0]);
128 //_____________________________________________________________________________
129 void AliAlignObj::Print(Option_t *) const
131 // Print the contents of the
132 // alignment object in angles and
133 // matrix representations
140 const Double_t *rot = m.GetRotationMatrix();
141 // printf("Volume=%s ID=%u\n", GetVolPath(),GetVolUID());
144 GetVolUID(layerId,modId);
145 printf("Volume=%s LayerID=%d ModuleID=%d\n", GetVolPath(),layerId,modId);
146 printf("%12.6f%12.6f%12.6f Tx = %12.6f Psi = %12.6f\n", rot[0], rot[1], rot[2], tr[0], angles[0]);
147 printf("%12.6f%12.6f%12.6f Ty = %12.6f Theta = %12.6f\n", rot[3], rot[4], rot[5], tr[1], angles[1]);
148 printf("%12.6f%12.6f%12.6f Tz = %12.6f Phi = %12.6f\n", rot[6], rot[7], rot[8], tr[2], angles[2]);
152 //_____________________________________________________________________________
153 UShort_t AliAlignObj::LayerToVolUID(ELayerID layerId, Int_t modId)
155 // From detector (layer) name and module number (according to detector numbering)
156 // build fVolUID, unique numerical identity of that volume inside ALICE
157 // fVolUID is 16 bits, first 5 reserved for layerID (32 possible values),
158 // remaining 11 for module ID inside det (2048 possible values).
160 return ((UShort_t(layerId) << 11) | UShort_t(modId));
163 //_____________________________________________________________________________
164 AliAlignObj::ELayerID AliAlignObj::VolUIDToLayer(UShort_t voluid, Int_t &modId)
166 // From detector (layer) name and module number (according to detector numbering)
167 // build fVolUID, unique numerical identity of that volume inside ALICE
168 // fVolUID is 16 bits, first 5 reserved for layerID (32 possible values),
169 // remaining 11 for module ID inside det (2048 possible values).
171 modId = voluid & 0x7ff;
173 return VolUIDToLayer(voluid);
176 //_____________________________________________________________________________
177 AliAlignObj::ELayerID AliAlignObj::VolUIDToLayer(UShort_t voluid)
179 // From detector (layer) name and module number (according to detector numbering)
180 // build fVolUID, unique numerical identity of that volume inside ALICE
181 // fVolUID is 16 bits, first 5 reserved for layerID (32 possible values),
182 // remaining 11 for module ID inside det (2048 possible values).
184 return ELayerID((voluid >> 11) & 0x1f);