Alignment framework (C.Cheshkov). More information is available in http://agenda...
[u/mrichter/AliRoot.git] / STEER / AliAlignObj.cxx
CommitLineData
c18195b9 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//-----------------------------------------------------------------
befe2c08 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.
c18195b9 21//-----------------------------------------------------------------
fdf65bb5 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 *****************************************************************************/
c18195b9 31
32#include "AliAlignObj.h"
33//#include "AliLog.h"
98937d93 34
c18195b9 35ClassImp(AliAlignObj)
36
98937d93 37Int_t AliAlignObj::fgLayerSize[kLastLayer - kFirstLayer] = {
38 80, 160, // ITS SPD
39 84, 176, // ITS SDD
40 748, 950, // ITS SSD
41 36, 36, // TPC
42 90, 90, 90, 90, 90, 90, // TRD
43 1, // TOF ??
44 1, 1, // PHOS ??
45 1, // RICH ??
46 1 // MUON ??
47};
48
49const 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",
56 "TOF layer",
57 "?","?",
58 "?",
59 "?"
60};
61
c18195b9 62//_____________________________________________________________________________
63AliAlignObj::AliAlignObj():
64 fVolUID(0)
65{
66 // dummy constructor
67}
68
69//_____________________________________________________________________________
70AliAlignObj::AliAlignObj(const AliAlignObj& theAlignObj) :
71 TObject(theAlignObj)
72{
73 //copy constructor
74 fVolPath = theAlignObj.GetVolPath();
75 fVolUID = theAlignObj.GetVolUID();
76}
77
78//_____________________________________________________________________________
79AliAlignObj &AliAlignObj::operator =(const AliAlignObj& theAlignObj)
80{
81 // assignment operator
82 if(this==&theAlignObj) return *this;
83 fVolPath = theAlignObj.GetVolPath();
84 fVolUID = theAlignObj.GetVolUID();
85 return *this;
86}
87
88//_____________________________________________________________________________
89AliAlignObj::~AliAlignObj()
90{
91 // dummy destructor
92}
93
befe2c08 94//_____________________________________________________________________________
95void AliAlignObj::SetVolUID(ELayerID detId, Int_t modId)
96{
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).
101 //
102 fVolUID = LayerToVolUID(detId,modId);
103}
104
105//_____________________________________________________________________________
106void AliAlignObj::GetVolUID(ELayerID &layerId, Int_t &modId) const
107{
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).
112 //
113 layerId = VolUIDToLayer(fVolUID,modId);
114}
115
c18195b9 116//_____________________________________________________________________________
117void AliAlignObj::AnglesToMatrix(const Double_t *angles, Double_t *rot) const
118{
fdf65bb5 119 // Calculates the rotation matrix using the
120 // Euler angles in "x y z" notation
c18195b9 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]);
128
129 rot[0] = costhe*cosphi;
130 rot[1] = -costhe*sinphi;
131 rot[2] = sinthe;
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;
138}
139
140//_____________________________________________________________________________
141Bool_t AliAlignObj::MatrixToAngles(const Double_t *rot, Double_t *angles) const
142{
fdf65bb5 143 // Calculates the Euler angles in "x y z" notation
144 // using the rotation matrix
c18195b9 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]);
150 return kTRUE;
151}
152
153//_____________________________________________________________________________
154void AliAlignObj::Print(Option_t *) const
155{
156 // Print the contents of the
157 // alignment object in angles and
158 // matrix representations
159 Double_t tr[3];
160 GetTranslation(tr);
161 Double_t angles[3];
162 GetAngles(angles);
163 TGeoHMatrix m;
164 GetMatrix(m);
165 const Double_t *rot = m.GetRotationMatrix();
befe2c08 166// printf("Volume=%s ID=%u\n", GetVolPath(),GetVolUID());
b1f9140d 167 ELayerID layerId;
168 Int_t modId;
169 GetVolUID(layerId,modId);
170 printf("Volume=%s LayerID=%d ModuleID=%d\n", GetVolPath(),layerId,modId);
c18195b9 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]);
174
175}
176
c18195b9 177//_____________________________________________________________________________
befe2c08 178UShort_t AliAlignObj::LayerToVolUID(ELayerID layerId, Int_t modId)
c18195b9 179{
befe2c08 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).
c18195b9 184 //
befe2c08 185 return ((UShort_t(layerId) << 11) | UShort_t(modId));
c18195b9 186}
187
188//_____________________________________________________________________________
befe2c08 189AliAlignObj::ELayerID AliAlignObj::VolUIDToLayer(UShort_t voluid, Int_t &modId)
c18195b9 190{
befe2c08 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).
195 //
196 modId = voluid & 0x7ff;
c18195b9 197
befe2c08 198 return VolUIDToLayer(voluid);
c18195b9 199}
200
201//_____________________________________________________________________________
befe2c08 202AliAlignObj::ELayerID AliAlignObj::VolUIDToLayer(UShort_t voluid)
c18195b9 203{
befe2c08 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).
208 //
209 return ELayerID((voluid >> 11) & 0x1f);
c18195b9 210}