]>
Commit | Line | Data |
---|---|---|
e118b27e | 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 | // $Id$ | |
17 | // | |
18 | // Class AliMUONGeometryDetElement | |
19 | // -------------------------------------- | |
20 | // The class defines the detection element. | |
21 | // | |
22 | // Author: Ivana Hrivnacova, IPN Orsay | |
23 | ||
24 | #include <TGeoMatrix.h> | |
25 | #include <Riostream.h> | |
26 | ||
27 | #include "AliLog.h" | |
28 | ||
29 | #include "AliMUONGeometryDetElement.h" | |
30 | ||
31 | ClassImp(AliMUONGeometryDetElement) | |
32 | ||
33 | //______________________________________________________________________________ | |
34 | AliMUONGeometryDetElement::AliMUONGeometryDetElement( | |
35 | Int_t detElemId, | |
36 | const TString& alignedVolume, | |
37 | const TGeoCombiTrans& relTransform) | |
38 | : TObject(), | |
39 | fAlignedVolume(alignedVolume), | |
40 | fLocalTransformation(0), | |
41 | fGlobalTransformation(0) | |
42 | { | |
692de412 | 43 | /// Standard constructor |
e118b27e | 44 | |
45 | SetUniqueID(detElemId); | |
46 | fLocalTransformation = new TGeoCombiTrans(relTransform); | |
47 | } | |
48 | ||
49 | //______________________________________________________________________________ | |
50 | AliMUONGeometryDetElement::AliMUONGeometryDetElement() | |
51 | : TObject(), | |
52 | fAlignedVolume(), | |
53 | fLocalTransformation(0), | |
54 | fGlobalTransformation(0) | |
55 | { | |
692de412 | 56 | /// Default constructor |
e118b27e | 57 | } |
58 | ||
59 | //______________________________________________________________________________ | |
60 | AliMUONGeometryDetElement::AliMUONGeometryDetElement( | |
61 | const AliMUONGeometryDetElement& rhs) | |
62 | : TObject(rhs) | |
63 | { | |
692de412 | 64 | /// Protected copy constructor |
65 | ||
e118b27e | 66 | AliFatal("Copy constructor is not implemented."); |
67 | } | |
68 | ||
69 | //______________________________________________________________________________ | |
692de412 | 70 | AliMUONGeometryDetElement::~AliMUONGeometryDetElement() |
71 | { | |
72 | /// Destructor | |
73 | ||
e118b27e | 74 | delete fLocalTransformation; |
75 | delete fGlobalTransformation; | |
76 | } | |
77 | ||
78 | //______________________________________________________________________________ | |
79 | AliMUONGeometryDetElement& | |
80 | AliMUONGeometryDetElement::operator = (const AliMUONGeometryDetElement& rhs) | |
81 | { | |
692de412 | 82 | /// Protected assignement operator |
83 | ||
e118b27e | 84 | // check assignement to self |
85 | if (this == &rhs) return *this; | |
86 | ||
87 | AliFatal("Assignment operator is not implemented."); | |
88 | ||
89 | return *this; | |
90 | } | |
91 | ||
92 | // | |
93 | // private methods | |
94 | // | |
95 | ||
96 | //______________________________________________________________________________ | |
97 | void AliMUONGeometryDetElement::PrintTransform( | |
98 | const TGeoCombiTrans* transform) const | |
99 | { | |
692de412 | 100 | /// Prints the detection element transformation |
e118b27e | 101 | |
102 | cout << "DetElemId: " << GetUniqueID(); | |
103 | cout << " name: " << fAlignedVolume << endl; | |
104 | ||
105 | const double* translation = transform->GetTranslation(); | |
106 | cout << " translation: " | |
107 | #if defined (__DECCXX) | |
108 | << translation[0] << ", " | |
109 | << translation[1] << ", " | |
110 | << translation[2] << endl; | |
111 | #else | |
112 | << std::fixed | |
113 | << std::setw(7) << std::setprecision(4) << translation[0] << ", " | |
114 | << std::setw(7) << std::setprecision(4) << translation[1] << ", " | |
115 | << std::setw(7) << std::setprecision(4) << translation[2] << endl; | |
116 | #endif | |
117 | ||
118 | const double* rotation = transform->GetRotationMatrix(); | |
119 | cout << " rotation matrix: " | |
120 | #if defined (__DECCXX) | |
121 | << rotation[0] << ", " << rotation[1] << ", " << rotation[2] << endl | |
122 | << " " | |
123 | << rotation[3] << ", " << rotation[4] << ", " << rotation[5] << endl | |
124 | << " " | |
125 | << rotation[6] << ", " << rotation[7] << ", " << rotation[8] << endl; | |
126 | #else | |
127 | << std::fixed | |
128 | << std::setw(7) << std::setprecision(4) | |
129 | << rotation[0] << ", " << rotation[1] << ", " << rotation[2] << endl | |
130 | << " " | |
131 | << rotation[3] << ", " << rotation[4] << ", " << rotation[5] << endl | |
132 | << " " | |
133 | << rotation[6] << ", " << rotation[7] << ", " << rotation[8] << endl; | |
134 | #endif | |
135 | } | |
136 | ||
137 | // | |
138 | // public methods | |
139 | // | |
140 | ||
141 | //______________________________________________________________________________ | |
142 | void AliMUONGeometryDetElement::Global2Local( | |
143 | Float_t xg, Float_t yg, Float_t zg, | |
144 | Float_t& xl, Float_t& yl, Float_t& zl) const | |
145 | { | |
692de412 | 146 | /// Transforms point from the global reference frame (ALIC) |
147 | /// to the local reference frame of the detection element specified | |
148 | /// by detElemId. | |
e118b27e | 149 | |
150 | Double_t dxg = xg; | |
151 | Double_t dyg = yg; | |
152 | Double_t dzg = zg; | |
153 | ||
154 | Double_t dxl, dyl, dzl; | |
155 | Global2Local(dxg, dyg, dzg, dxl, dyl, dzl); | |
156 | ||
157 | xl = dxl; | |
158 | yl = dyl; | |
159 | zl = dzl; | |
160 | } | |
161 | ||
162 | //______________________________________________________________________________ | |
163 | void AliMUONGeometryDetElement::Global2Local( | |
164 | Double_t xg, Double_t yg, Double_t zg, | |
165 | Double_t& xl, Double_t& yl, Double_t& zl) const | |
166 | { | |
692de412 | 167 | /// Transforms point from the global reference frame (ALIC) |
168 | /// to the local reference frame of the detection element specified | |
169 | /// by detElemId. | |
e118b27e | 170 | |
171 | // Check transformation | |
172 | if (!fGlobalTransformation) { | |
173 | AliError(Form("Global transformation for detection element %d not defined.", | |
174 | GetUniqueID())); | |
175 | return; | |
176 | } | |
177 | ||
178 | // Transform point | |
179 | Double_t pg[3] = { xg, yg, zg }; | |
180 | Double_t pl[3] = { 0., 0., 0. }; | |
181 | fGlobalTransformation->MasterToLocal(pg, pl); | |
182 | ||
183 | // Return transformed point | |
184 | xl = pl[0]; | |
185 | yl = pl[1]; | |
186 | zl = pl[2]; | |
187 | } | |
188 | ||
189 | //______________________________________________________________________________ | |
190 | void AliMUONGeometryDetElement::Local2Global( | |
191 | Float_t xl, Float_t yl, Float_t zl, | |
192 | Float_t& xg, Float_t& yg, Float_t& zg) const | |
193 | { | |
692de412 | 194 | /// Transforms point from the local reference frame of the detection element |
195 | /// specified by detElemId to the global reference frame (ALIC). | |
e118b27e | 196 | |
197 | Double_t dxl = xl; | |
198 | Double_t dyl = yl; | |
199 | Double_t dzl = zl; | |
200 | ||
201 | Double_t dxg, dyg, dzg; | |
202 | Local2Global(dxl, dyl, dzl, dxg, dyg, dzg); | |
203 | ||
204 | xg = dxg; | |
205 | yg = dyg; | |
206 | zg = dzg; | |
207 | } | |
208 | ||
209 | //______________________________________________________________________________ | |
210 | void AliMUONGeometryDetElement::Local2Global( | |
211 | Double_t xl, Double_t yl, Double_t zl, | |
212 | Double_t& xg, Double_t& yg, Double_t& zg) const | |
213 | { | |
692de412 | 214 | /// Transforms point from the local reference frame of the detection element |
215 | /// specified by detElemId to the global reference frame (ALIC). | |
e118b27e | 216 | |
217 | // Check transformation | |
218 | if (!fGlobalTransformation) { | |
219 | AliError(Form("Global transformation for detection element %d not defined.", | |
220 | GetUniqueID())); | |
221 | return; | |
222 | } | |
223 | ||
224 | // Transform point | |
225 | Double_t pl[3] = { xl, yl, zl }; | |
226 | Double_t pg[3] = { 0., 0., 0. }; | |
227 | fGlobalTransformation->LocalToMaster(pl, pg); | |
228 | ||
229 | // Return transformed point | |
230 | xg = pg[0]; | |
231 | yg = pg[1]; | |
232 | zg = pg[2]; | |
233 | } | |
234 | ||
235 | //______________________________________________________________________________ | |
236 | void AliMUONGeometryDetElement::SetGlobalTransformation( | |
237 | const TGeoCombiTrans& transform) | |
238 | { | |
692de412 | 239 | /// Sets global transformation; |
240 | /// gives warning if the global transformation is already defined. | |
e118b27e | 241 | |
242 | if (fGlobalTransformation) { | |
243 | delete fGlobalTransformation; | |
244 | AliWarning("Global transformation already defined was deleted."); | |
245 | } | |
246 | ||
247 | fGlobalTransformation = new TGeoCombiTrans(transform); | |
248 | } | |
249 | ||
250 | //______________________________________________________________________________ | |
251 | void AliMUONGeometryDetElement::PrintLocalTransform() const | |
252 | { | |
692de412 | 253 | /// Prints detection element relative transformation |
254 | /// (the transformation wrt module frame) | |
e118b27e | 255 | |
256 | PrintTransform(fLocalTransformation); | |
257 | } | |
258 | ||
259 | //______________________________________________________________________________ | |
260 | void AliMUONGeometryDetElement::PrintGlobalTransform() const | |
261 | { | |
692de412 | 262 | /// Prints detection element global transformation |
263 | /// (the transformation wrt global frame) | |
e118b27e | 264 | |
a42ddaa5 | 265 | PrintTransform(fGlobalTransformation); |
e118b27e | 266 | } |