]>
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 | |
a9aad96e | 33 | /// \cond CLASSIMP |
e118b27e | 34 | ClassImp(AliMUONGeometryDetElement) |
a9aad96e | 35 | /// \endcond |
e118b27e | 36 | |
e9a283f7 | 37 | const TString AliMUONGeometryDetElement::fgkDENamePrefix = "DE"; |
38 | ||
ccc0dd0a | 39 | //______________________________________________________________________________ |
40 | TString AliMUONGeometryDetElement::GetDEName(Int_t detElemId) | |
41 | { | |
42 | /// Return the module name for given moduleId | |
43 | ||
44 | TString deName(fgkDENamePrefix); | |
45 | deName += detElemId; | |
46 | return deName; | |
47 | } | |
48 | ||
49 | //______________________________________________________________________________ | |
50 | AliMUONGeometryDetElement::AliMUONGeometryDetElement(Int_t detElemId) | |
51 | : TObject(), | |
52 | fDEName(GetDEName(detElemId)), | |
53 | fVolumePath(), | |
54 | fLocalTransformation(0), | |
55 | fGlobalTransformation(0) | |
56 | { | |
57 | /// Standard constructor | |
58 | ||
59 | SetUniqueID(detElemId); | |
60 | } | |
61 | ||
e118b27e | 62 | //______________________________________________________________________________ |
63 | AliMUONGeometryDetElement::AliMUONGeometryDetElement( | |
64 | Int_t detElemId, | |
8c0e3489 | 65 | const TString& volumePath) |
e118b27e | 66 | : TObject(), |
ccc0dd0a | 67 | fDEName(GetDEName(detElemId)), |
8c0e3489 | 68 | fVolumePath(volumePath), |
e118b27e | 69 | fLocalTransformation(0), |
70 | fGlobalTransformation(0) | |
71 | { | |
692de412 | 72 | /// Standard constructor |
e118b27e | 73 | |
74 | SetUniqueID(detElemId); | |
e118b27e | 75 | } |
76 | ||
77 | //______________________________________________________________________________ | |
ccc0dd0a | 78 | AliMUONGeometryDetElement::AliMUONGeometryDetElement(TRootIOCtor* /*ioCtor*/) |
e118b27e | 79 | : TObject(), |
ee04aaf6 | 80 | fDEName(), |
8c0e3489 | 81 | fVolumePath(), |
e118b27e | 82 | fLocalTransformation(0), |
83 | fGlobalTransformation(0) | |
84 | { | |
ccc0dd0a | 85 | /// Root IO constructor |
e118b27e | 86 | } |
87 | ||
e118b27e | 88 | //______________________________________________________________________________ |
692de412 | 89 | AliMUONGeometryDetElement::~AliMUONGeometryDetElement() |
90 | { | |
91 | /// Destructor | |
92 | ||
e118b27e | 93 | delete fLocalTransformation; |
94 | delete fGlobalTransformation; | |
95 | } | |
96 | ||
e118b27e | 97 | // |
98 | // private methods | |
99 | // | |
100 | ||
101 | //______________________________________________________________________________ | |
102 | void AliMUONGeometryDetElement::PrintTransform( | |
8c0e3489 | 103 | const TGeoHMatrix* transform) const |
e118b27e | 104 | { |
a9aad96e | 105 | /// Print the detection element transformation |
e118b27e | 106 | |
107 | cout << "DetElemId: " << GetUniqueID(); | |
8c0e3489 | 108 | cout << " name: " << fVolumePath << endl; |
109 | ||
110 | if ( !transform ) { | |
111 | cout << " Transformation not defined." << endl; | |
112 | return; | |
113 | } | |
e118b27e | 114 | |
115 | const double* translation = transform->GetTranslation(); | |
116 | cout << " translation: " | |
117 | #if defined (__DECCXX) | |
118 | << translation[0] << ", " | |
119 | << translation[1] << ", " | |
120 | << translation[2] << endl; | |
121 | #else | |
122 | << std::fixed | |
123 | << std::setw(7) << std::setprecision(4) << translation[0] << ", " | |
124 | << std::setw(7) << std::setprecision(4) << translation[1] << ", " | |
125 | << std::setw(7) << std::setprecision(4) << translation[2] << endl; | |
126 | #endif | |
127 | ||
128 | const double* rotation = transform->GetRotationMatrix(); | |
129 | cout << " rotation matrix: " | |
130 | #if defined (__DECCXX) | |
131 | << rotation[0] << ", " << rotation[1] << ", " << rotation[2] << endl | |
132 | << " " | |
133 | << rotation[3] << ", " << rotation[4] << ", " << rotation[5] << endl | |
134 | << " " | |
135 | << rotation[6] << ", " << rotation[7] << ", " << rotation[8] << endl; | |
136 | #else | |
137 | << std::fixed | |
138 | << std::setw(7) << std::setprecision(4) | |
139 | << rotation[0] << ", " << rotation[1] << ", " << rotation[2] << endl | |
140 | << " " | |
141 | << rotation[3] << ", " << rotation[4] << ", " << rotation[5] << endl | |
142 | << " " | |
143 | << rotation[6] << ", " << rotation[7] << ", " << rotation[8] << endl; | |
144 | #endif | |
145 | } | |
146 | ||
147 | // | |
148 | // public methods | |
149 | // | |
150 | ||
151 | //______________________________________________________________________________ | |
152 | void AliMUONGeometryDetElement::Global2Local( | |
153 | Float_t xg, Float_t yg, Float_t zg, | |
154 | Float_t& xl, Float_t& yl, Float_t& zl) const | |
155 | { | |
a9aad96e | 156 | /// Transform point from the global reference frame (ALIC) |
157 | /// to the local reference frame of this detection element. | |
e118b27e | 158 | |
159 | Double_t dxg = xg; | |
160 | Double_t dyg = yg; | |
161 | Double_t dzg = zg; | |
162 | ||
163 | Double_t dxl, dyl, dzl; | |
164 | Global2Local(dxg, dyg, dzg, dxl, dyl, dzl); | |
165 | ||
166 | xl = dxl; | |
167 | yl = dyl; | |
168 | zl = dzl; | |
169 | } | |
170 | ||
171 | //______________________________________________________________________________ | |
172 | void AliMUONGeometryDetElement::Global2Local( | |
173 | Double_t xg, Double_t yg, Double_t zg, | |
174 | Double_t& xl, Double_t& yl, Double_t& zl) const | |
175 | { | |
a9aad96e | 176 | /// Transform point from the global reference frame (ALIC) |
177 | /// to the local reference frame of this detection element | |
e118b27e | 178 | |
179 | // Check transformation | |
180 | if (!fGlobalTransformation) { | |
181 | AliError(Form("Global transformation for detection element %d not defined.", | |
182 | GetUniqueID())); | |
183 | return; | |
184 | } | |
185 | ||
186 | // Transform point | |
187 | Double_t pg[3] = { xg, yg, zg }; | |
188 | Double_t pl[3] = { 0., 0., 0. }; | |
189 | fGlobalTransformation->MasterToLocal(pg, pl); | |
190 | ||
191 | // Return transformed point | |
192 | xl = pl[0]; | |
193 | yl = pl[1]; | |
194 | zl = pl[2]; | |
195 | } | |
196 | ||
197 | //______________________________________________________________________________ | |
198 | void AliMUONGeometryDetElement::Local2Global( | |
199 | Float_t xl, Float_t yl, Float_t zl, | |
200 | Float_t& xg, Float_t& yg, Float_t& zg) const | |
201 | { | |
a9aad96e | 202 | /// Transform point from the local reference frame of this detection element |
203 | /// to the global reference frame (ALIC). | |
e118b27e | 204 | |
205 | Double_t dxl = xl; | |
206 | Double_t dyl = yl; | |
207 | Double_t dzl = zl; | |
208 | ||
209 | Double_t dxg, dyg, dzg; | |
210 | Local2Global(dxl, dyl, dzl, dxg, dyg, dzg); | |
211 | ||
212 | xg = dxg; | |
213 | yg = dyg; | |
214 | zg = dzg; | |
215 | } | |
216 | ||
217 | //______________________________________________________________________________ | |
218 | void AliMUONGeometryDetElement::Local2Global( | |
219 | Double_t xl, Double_t yl, Double_t zl, | |
220 | Double_t& xg, Double_t& yg, Double_t& zg) const | |
221 | { | |
a9aad96e | 222 | /// Transform point from the local reference frame of this detection element |
223 | /// to the global reference frame (ALIC). | |
e118b27e | 224 | |
225 | // Check transformation | |
226 | if (!fGlobalTransformation) { | |
227 | AliError(Form("Global transformation for detection element %d not defined.", | |
228 | GetUniqueID())); | |
229 | return; | |
230 | } | |
231 | ||
232 | // Transform point | |
233 | Double_t pl[3] = { xl, yl, zl }; | |
234 | Double_t pg[3] = { 0., 0., 0. }; | |
235 | fGlobalTransformation->LocalToMaster(pl, pg); | |
236 | ||
237 | // Return transformed point | |
238 | xg = pg[0]; | |
239 | yg = pg[1]; | |
240 | zg = pg[2]; | |
241 | } | |
242 | ||
8c0e3489 | 243 | //______________________________________________________________________________ |
244 | void AliMUONGeometryDetElement::SetLocalTransformation( | |
245 | const TGeoHMatrix& transform) | |
246 | { | |
a9aad96e | 247 | /// Set local transformation; |
248 | /// give warning if the global transformation is already defined. | |
8c0e3489 | 249 | |
250 | if (fLocalTransformation) { | |
251 | delete fLocalTransformation; | |
252 | AliWarning("Local transformation already defined was deleted."); | |
253 | } | |
254 | ||
255 | fLocalTransformation = new TGeoHMatrix(transform); | |
256 | } | |
257 | ||
e118b27e | 258 | //______________________________________________________________________________ |
259 | void AliMUONGeometryDetElement::SetGlobalTransformation( | |
8c0e3489 | 260 | const TGeoHMatrix& transform) |
e118b27e | 261 | { |
a9aad96e | 262 | /// Set global transformation; |
263 | /// give warning if the global transformation is already defined. | |
e118b27e | 264 | |
265 | if (fGlobalTransformation) { | |
266 | delete fGlobalTransformation; | |
267 | AliWarning("Global transformation already defined was deleted."); | |
268 | } | |
269 | ||
8c0e3489 | 270 | fGlobalTransformation = new TGeoHMatrix(transform); |
e118b27e | 271 | } |
272 | ||
273 | //______________________________________________________________________________ | |
274 | void AliMUONGeometryDetElement::PrintLocalTransform() const | |
275 | { | |
a9aad96e | 276 | /// Print detection element relative transformation |
692de412 | 277 | /// (the transformation wrt module frame) |
e118b27e | 278 | |
279 | PrintTransform(fLocalTransformation); | |
280 | } | |
281 | ||
282 | //______________________________________________________________________________ | |
283 | void AliMUONGeometryDetElement::PrintGlobalTransform() const | |
284 | { | |
a9aad96e | 285 | /// Print detection element global transformation |
692de412 | 286 | /// (the transformation wrt global frame) |
e118b27e | 287 | |
a42ddaa5 | 288 | PrintTransform(fGlobalTransformation); |
e118b27e | 289 | } |
8c0e3489 | 290 | |
291 | //______________________________________________________________________________ | |
292 | TString AliMUONGeometryDetElement::GetVolumeName() const | |
293 | { | |
294 | /// Extract volume name from the path | |
295 | ||
296 | std::string volPath = fVolumePath.Data(); | |
297 | std::string::size_type first = volPath.rfind('/')+1; | |
298 | std::string::size_type last = volPath.rfind('_'); | |
299 | ||
300 | return volPath.substr(first, last-first ); | |
301 | } | |
302 | ||
303 | //______________________________________________________________________________ | |
304 | Int_t AliMUONGeometryDetElement::GetVolumeCopyNo() const | |
305 | { | |
306 | /// Extract volume copyNo from the path | |
307 | ||
308 | string volPath = fVolumePath.Data(); | |
309 | std::string::size_type first = volPath.rfind('_'); | |
310 | std::string copyNoStr = volPath.substr(first+1, volPath.length()); | |
311 | std::istringstream in(copyNoStr); | |
312 | Int_t copyNo; | |
313 | in >> copyNo; | |
314 | ||
315 | return copyNo; | |
316 | } | |
317 |