]>
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 | // | |
f7006443 | 18 | // -------------------------------------- |
e118b27e | 19 | // Class AliMUONGeometryDetElement |
20 | // -------------------------------------- | |
21 | // The class defines the detection element. | |
e118b27e | 22 | // Author: Ivana Hrivnacova, IPN Orsay |
23 | ||
8c0e3489 | 24 | #include "AliMUONGeometryDetElement.h" |
e118b27e | 25 | |
26 | #include "AliLog.h" | |
27 | ||
8c0e3489 | 28 | #include <TGeoMatrix.h> |
29 | #include <Riostream.h> | |
30 | ||
31 | #include <sstream> | |
e118b27e | 32 | |
33 | ClassImp(AliMUONGeometryDetElement) | |
34 | ||
35 | //______________________________________________________________________________ | |
36 | AliMUONGeometryDetElement::AliMUONGeometryDetElement( | |
37 | Int_t detElemId, | |
8c0e3489 | 38 | const TString& volumePath) |
e118b27e | 39 | : TObject(), |
8c0e3489 | 40 | fVolumePath(volumePath), |
e118b27e | 41 | fLocalTransformation(0), |
42 | fGlobalTransformation(0) | |
43 | { | |
692de412 | 44 | /// Standard constructor |
e118b27e | 45 | |
46 | SetUniqueID(detElemId); | |
e118b27e | 47 | } |
48 | ||
49 | //______________________________________________________________________________ | |
50 | AliMUONGeometryDetElement::AliMUONGeometryDetElement() | |
51 | : TObject(), | |
8c0e3489 | 52 | fVolumePath(), |
e118b27e | 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( | |
8c0e3489 | 98 | const TGeoHMatrix* transform) const |
e118b27e | 99 | { |
692de412 | 100 | /// Prints the detection element transformation |
e118b27e | 101 | |
102 | cout << "DetElemId: " << GetUniqueID(); | |
8c0e3489 | 103 | cout << " name: " << fVolumePath << endl; |
104 | ||
105 | if ( !transform ) { | |
106 | cout << " Transformation not defined." << endl; | |
107 | return; | |
108 | } | |
e118b27e | 109 | |
110 | const double* translation = transform->GetTranslation(); | |
111 | cout << " translation: " | |
112 | #if defined (__DECCXX) | |
113 | << translation[0] << ", " | |
114 | << translation[1] << ", " | |
115 | << translation[2] << endl; | |
116 | #else | |
117 | << std::fixed | |
118 | << std::setw(7) << std::setprecision(4) << translation[0] << ", " | |
119 | << std::setw(7) << std::setprecision(4) << translation[1] << ", " | |
120 | << std::setw(7) << std::setprecision(4) << translation[2] << endl; | |
121 | #endif | |
122 | ||
123 | const double* rotation = transform->GetRotationMatrix(); | |
124 | cout << " rotation matrix: " | |
125 | #if defined (__DECCXX) | |
126 | << rotation[0] << ", " << rotation[1] << ", " << rotation[2] << endl | |
127 | << " " | |
128 | << rotation[3] << ", " << rotation[4] << ", " << rotation[5] << endl | |
129 | << " " | |
130 | << rotation[6] << ", " << rotation[7] << ", " << rotation[8] << endl; | |
131 | #else | |
132 | << std::fixed | |
133 | << std::setw(7) << std::setprecision(4) | |
134 | << rotation[0] << ", " << rotation[1] << ", " << rotation[2] << endl | |
135 | << " " | |
136 | << rotation[3] << ", " << rotation[4] << ", " << rotation[5] << endl | |
137 | << " " | |
138 | << rotation[6] << ", " << rotation[7] << ", " << rotation[8] << endl; | |
139 | #endif | |
140 | } | |
141 | ||
142 | // | |
143 | // public methods | |
144 | // | |
145 | ||
146 | //______________________________________________________________________________ | |
147 | void AliMUONGeometryDetElement::Global2Local( | |
148 | Float_t xg, Float_t yg, Float_t zg, | |
149 | Float_t& xl, Float_t& yl, Float_t& zl) const | |
150 | { | |
692de412 | 151 | /// Transforms point from the global reference frame (ALIC) |
152 | /// to the local reference frame of the detection element specified | |
153 | /// by detElemId. | |
e118b27e | 154 | |
155 | Double_t dxg = xg; | |
156 | Double_t dyg = yg; | |
157 | Double_t dzg = zg; | |
158 | ||
159 | Double_t dxl, dyl, dzl; | |
160 | Global2Local(dxg, dyg, dzg, dxl, dyl, dzl); | |
161 | ||
162 | xl = dxl; | |
163 | yl = dyl; | |
164 | zl = dzl; | |
165 | } | |
166 | ||
167 | //______________________________________________________________________________ | |
168 | void AliMUONGeometryDetElement::Global2Local( | |
169 | Double_t xg, Double_t yg, Double_t zg, | |
170 | Double_t& xl, Double_t& yl, Double_t& zl) const | |
171 | { | |
692de412 | 172 | /// Transforms point from the global reference frame (ALIC) |
173 | /// to the local reference frame of the detection element specified | |
174 | /// by detElemId. | |
e118b27e | 175 | |
176 | // Check transformation | |
177 | if (!fGlobalTransformation) { | |
178 | AliError(Form("Global transformation for detection element %d not defined.", | |
179 | GetUniqueID())); | |
180 | return; | |
181 | } | |
182 | ||
183 | // Transform point | |
184 | Double_t pg[3] = { xg, yg, zg }; | |
185 | Double_t pl[3] = { 0., 0., 0. }; | |
186 | fGlobalTransformation->MasterToLocal(pg, pl); | |
187 | ||
188 | // Return transformed point | |
189 | xl = pl[0]; | |
190 | yl = pl[1]; | |
191 | zl = pl[2]; | |
192 | } | |
193 | ||
194 | //______________________________________________________________________________ | |
195 | void AliMUONGeometryDetElement::Local2Global( | |
196 | Float_t xl, Float_t yl, Float_t zl, | |
197 | Float_t& xg, Float_t& yg, Float_t& zg) const | |
198 | { | |
692de412 | 199 | /// Transforms point from the local reference frame of the detection element |
200 | /// specified by detElemId to the global reference frame (ALIC). | |
e118b27e | 201 | |
202 | Double_t dxl = xl; | |
203 | Double_t dyl = yl; | |
204 | Double_t dzl = zl; | |
205 | ||
206 | Double_t dxg, dyg, dzg; | |
207 | Local2Global(dxl, dyl, dzl, dxg, dyg, dzg); | |
208 | ||
209 | xg = dxg; | |
210 | yg = dyg; | |
211 | zg = dzg; | |
212 | } | |
213 | ||
214 | //______________________________________________________________________________ | |
215 | void AliMUONGeometryDetElement::Local2Global( | |
216 | Double_t xl, Double_t yl, Double_t zl, | |
217 | Double_t& xg, Double_t& yg, Double_t& zg) const | |
218 | { | |
692de412 | 219 | /// Transforms point from the local reference frame of the detection element |
220 | /// specified by detElemId to the global reference frame (ALIC). | |
e118b27e | 221 | |
222 | // Check transformation | |
223 | if (!fGlobalTransformation) { | |
224 | AliError(Form("Global transformation for detection element %d not defined.", | |
225 | GetUniqueID())); | |
226 | return; | |
227 | } | |
228 | ||
229 | // Transform point | |
230 | Double_t pl[3] = { xl, yl, zl }; | |
231 | Double_t pg[3] = { 0., 0., 0. }; | |
232 | fGlobalTransformation->LocalToMaster(pl, pg); | |
233 | ||
234 | // Return transformed point | |
235 | xg = pg[0]; | |
236 | yg = pg[1]; | |
237 | zg = pg[2]; | |
238 | } | |
239 | ||
8c0e3489 | 240 | //______________________________________________________________________________ |
241 | void AliMUONGeometryDetElement::SetLocalTransformation( | |
242 | const TGeoHMatrix& transform) | |
243 | { | |
244 | /// Sets global transformation; | |
245 | /// gives warning if the global transformation is already defined. | |
246 | ||
247 | if (fLocalTransformation) { | |
248 | delete fLocalTransformation; | |
249 | AliWarning("Local transformation already defined was deleted."); | |
250 | } | |
251 | ||
252 | fLocalTransformation = new TGeoHMatrix(transform); | |
253 | } | |
254 | ||
e118b27e | 255 | //______________________________________________________________________________ |
256 | void AliMUONGeometryDetElement::SetGlobalTransformation( | |
8c0e3489 | 257 | const TGeoHMatrix& transform) |
e118b27e | 258 | { |
692de412 | 259 | /// Sets global transformation; |
260 | /// gives warning if the global transformation is already defined. | |
e118b27e | 261 | |
262 | if (fGlobalTransformation) { | |
263 | delete fGlobalTransformation; | |
264 | AliWarning("Global transformation already defined was deleted."); | |
265 | } | |
266 | ||
8c0e3489 | 267 | fGlobalTransformation = new TGeoHMatrix(transform); |
e118b27e | 268 | } |
269 | ||
270 | //______________________________________________________________________________ | |
271 | void AliMUONGeometryDetElement::PrintLocalTransform() const | |
272 | { | |
692de412 | 273 | /// Prints detection element relative transformation |
274 | /// (the transformation wrt module frame) | |
e118b27e | 275 | |
276 | PrintTransform(fLocalTransformation); | |
277 | } | |
278 | ||
279 | //______________________________________________________________________________ | |
280 | void AliMUONGeometryDetElement::PrintGlobalTransform() const | |
281 | { | |
692de412 | 282 | /// Prints detection element global transformation |
283 | /// (the transformation wrt global frame) | |
e118b27e | 284 | |
a42ddaa5 | 285 | PrintTransform(fGlobalTransformation); |
e118b27e | 286 | } |
8c0e3489 | 287 | |
288 | //______________________________________________________________________________ | |
289 | TString AliMUONGeometryDetElement::GetVolumeName() const | |
290 | { | |
291 | /// Extract volume name from the path | |
292 | ||
293 | std::string volPath = fVolumePath.Data(); | |
294 | std::string::size_type first = volPath.rfind('/')+1; | |
295 | std::string::size_type last = volPath.rfind('_'); | |
296 | ||
297 | return volPath.substr(first, last-first ); | |
298 | } | |
299 | ||
300 | //______________________________________________________________________________ | |
301 | Int_t AliMUONGeometryDetElement::GetVolumeCopyNo() const | |
302 | { | |
303 | /// Extract volume copyNo from the path | |
304 | ||
305 | string volPath = fVolumePath.Data(); | |
306 | std::string::size_type first = volPath.rfind('_'); | |
307 | std::string copyNoStr = volPath.substr(first+1, volPath.length()); | |
308 | std::istringstream in(copyNoStr); | |
309 | Int_t copyNo; | |
310 | in >> copyNo; | |
311 | ||
312 | return copyNo; | |
313 | } | |
314 |