]>
Commit | Line | Data |
---|---|---|
4f8b0abb | 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$ | |
3d1463c8 | 17 | |
18 | //----------------------------------------------------------------------------- | |
4f8b0abb | 19 | // Class AliMUONGeometryModuleTransformer |
20 | // ------------------------------------- | |
21 | // Class for definition of the detector module transformations | |
4f8b0abb | 22 | // Author: Ivana Hrivnacova, IPN Orsay |
3d1463c8 | 23 | //----------------------------------------------------------------------------- |
4f8b0abb | 24 | |
ab488200 | 25 | #include "AliMUONGeometryModuleTransformer.h" |
26 | #include "AliMUONGeometryDetElement.h" | |
fa66b479 | 27 | |
28 | #include "AliMpExMap.h" | |
ab488200 | 29 | |
30 | #include "AliLog.h" | |
31 | ||
4f8b0abb | 32 | #include <TVirtualMC.h> |
33 | #include <TGeoMatrix.h> | |
34 | #include <TObjArray.h> | |
35 | #include <TArrayI.h> | |
36 | #include <Riostream.h> | |
37 | ||
b80faac0 | 38 | using std::endl; |
a9aad96e | 39 | /// \cond CLASSIMP |
4f8b0abb | 40 | ClassImp(AliMUONGeometryModuleTransformer) |
a9aad96e | 41 | /// \endcond |
4f8b0abb | 42 | |
31edb2d7 | 43 | // |
44 | // static methods | |
45 | // | |
46 | ||
47 | //______________________________________________________________________________ | |
48 | const TString& AliMUONGeometryModuleTransformer::GetModuleNamePrefix() | |
49 | { | |
50 | /// Geometry module name prefix | |
d53c7bc2 | 51 | static const TString kModuleNamePrefix = "GM"; |
31edb2d7 | 52 | return kModuleNamePrefix; |
53 | } | |
eb288296 | 54 | |
1f687625 | 55 | //______________________________________________________________________________ |
56 | TString AliMUONGeometryModuleTransformer::GetModuleName(Int_t moduleId) | |
57 | { | |
58 | /// Return the module name for given moduleId | |
59 | ||
31edb2d7 | 60 | TString moduleName(GetModuleNamePrefix()); |
1f687625 | 61 | moduleName += moduleId; |
62 | return moduleName; | |
63 | } | |
64 | ||
31edb2d7 | 65 | // |
66 | // ctor, dtor | |
67 | // | |
68 | ||
4f8b0abb | 69 | //______________________________________________________________________________ |
70 | AliMUONGeometryModuleTransformer::AliMUONGeometryModuleTransformer(Int_t moduleId) | |
71 | : TObject(), | |
72 | fModuleId(moduleId), | |
1f687625 | 73 | fModuleName(GetModuleName(moduleId)), |
ab488200 | 74 | fVolumePath(), |
4f8b0abb | 75 | fTransformation(0), |
76 | fDetElements(0) | |
77 | { | |
78 | /// Standard constructor | |
79 | ||
80 | // Chamber transformation | |
ab488200 | 81 | fTransformation = new TGeoHMatrix(""); |
4f8b0abb | 82 | |
83 | // Det elements transformation stores | |
630711ed | 84 | fDetElements = new AliMpExMap; |
4f8b0abb | 85 | } |
86 | ||
87 | ||
88 | //______________________________________________________________________________ | |
1f687625 | 89 | AliMUONGeometryModuleTransformer::AliMUONGeometryModuleTransformer(TRootIOCtor* /*ioCtor*/) |
4f8b0abb | 90 | : TObject(), |
91 | fModuleId(0), | |
eb288296 | 92 | fModuleName(), |
ab488200 | 93 | fVolumePath(), |
4f8b0abb | 94 | fTransformation(0), |
95 | fDetElements(0) | |
96 | { | |
1f687625 | 97 | /// Root IO constructor |
4f8b0abb | 98 | } |
99 | ||
100 | ||
4f8b0abb | 101 | //______________________________________________________________________________ |
102 | AliMUONGeometryModuleTransformer::~AliMUONGeometryModuleTransformer() | |
103 | { | |
104 | /// Destructor | |
105 | ||
106 | delete fTransformation; | |
107 | delete fDetElements; | |
108 | } | |
109 | ||
4f8b0abb | 110 | // |
111 | // public methods | |
112 | // | |
113 | ||
114 | //______________________________________________________________________________ | |
115 | void AliMUONGeometryModuleTransformer::Global2Local(Int_t detElemId, | |
116 | Float_t xg, Float_t yg, Float_t zg, | |
117 | Float_t& xl, Float_t& yl, Float_t& zl) const | |
118 | { | |
119 | /// Transform point from the global reference frame (ALIC) | |
120 | /// to the local reference frame of the detection element specified | |
121 | /// by detElemId. | |
122 | ||
123 | // Get detection element | |
124 | AliMUONGeometryDetElement* detElement = GetDetElement(detElemId); | |
125 | if (!detElement) return; | |
126 | ||
127 | // Transform point | |
128 | detElement->Global2Local(xg, yg, zg, xl, yl, zl); | |
129 | } | |
130 | ||
131 | //______________________________________________________________________________ | |
132 | void AliMUONGeometryModuleTransformer::Global2Local(Int_t detElemId, | |
133 | Double_t xg, Double_t yg, Double_t zg, | |
134 | Double_t& xl, Double_t& yl, Double_t& zl) const | |
135 | { | |
136 | /// Transform point from the global reference frame (ALIC) | |
137 | /// to the local reference frame of the detection element specified | |
138 | /// by detElemId. | |
139 | ||
140 | // Get detection element | |
141 | AliMUONGeometryDetElement* detElement = GetDetElement(detElemId); | |
142 | if (!detElement) return; | |
143 | ||
144 | // Transform point | |
145 | detElement->Global2Local(xg, yg, zg, xl, yl, zl); | |
146 | } | |
147 | ||
148 | //______________________________________________________________________________ | |
149 | void AliMUONGeometryModuleTransformer::Local2Global(Int_t detElemId, | |
150 | Float_t xl, Float_t yl, Float_t zl, | |
151 | Float_t& xg, Float_t& yg, Float_t& zg) const | |
152 | { | |
153 | /// Transform point from the local reference frame of the detection element | |
154 | /// specified by detElemId to the global reference frame (ALIC). | |
155 | ||
156 | // Get detection element | |
157 | AliMUONGeometryDetElement* detElement = GetDetElement(detElemId); | |
158 | if (!detElement) return; | |
159 | ||
160 | // Transform point | |
161 | detElement->Local2Global(xl, yl, zl, xg, yg, zg); | |
162 | } | |
163 | ||
164 | //______________________________________________________________________________ | |
165 | void AliMUONGeometryModuleTransformer::Local2Global(Int_t detElemId, | |
166 | Double_t xl, Double_t yl, Double_t zl, | |
167 | Double_t& xg, Double_t& yg, Double_t& zg) const | |
168 | { | |
169 | /// Transform point from the local reference frame of the detection element | |
170 | /// specified by detElemId to the global reference frame (ALIC). | |
171 | ||
172 | // Get detection element | |
173 | AliMUONGeometryDetElement* detElement = GetDetElement(detElemId); | |
174 | if (!detElement) return; | |
175 | ||
176 | // Transform point | |
177 | detElement->Local2Global(xl, yl, zl, xg, yg, zg); | |
178 | } | |
179 | ||
180 | //______________________________________________________________________________ | |
181 | void AliMUONGeometryModuleTransformer::SetTransformation( | |
ab488200 | 182 | const TGeoHMatrix& transform) |
4f8b0abb | 183 | { |
184 | /// Set the module position wrt world. | |
185 | ||
186 | *fTransformation = transform; | |
187 | } | |
188 | ||
ab488200 | 189 | //______________________________________________________________________________ |
190 | TString AliMUONGeometryModuleTransformer::GetVolumeName() const | |
191 | { | |
192 | /// Extract volume name from the path | |
193 | ||
194 | std::string volPath = fVolumePath.Data(); | |
195 | std::string::size_type first = volPath.rfind('/')+1; | |
196 | std::string::size_type last = volPath.rfind('_'); | |
197 | ||
198 | return volPath.substr(first, last-first ); | |
199 | } | |
200 | ||
201 | //______________________________________________________________________________ | |
202 | TString AliMUONGeometryModuleTransformer::GetMotherVolumeName() const | |
203 | { | |
a9aad96e | 204 | /// Extract mother volume name from the path |
ab488200 | 205 | |
206 | std::string volPath = fVolumePath.Data(); | |
207 | std::string::size_type first = volPath.rfind('/'); | |
1a8a2a9e | 208 | if ( first != std::string::npos ) |
209 | volPath = volPath.substr(0, first); | |
ab488200 | 210 | |
211 | std::string::size_type next = volPath.rfind('/')+1; | |
212 | std::string::size_type last = volPath.rfind('_'); | |
213 | ||
214 | return volPath.substr(next, last-next ); | |
215 | } | |
216 | ||
4f8b0abb | 217 | //______________________________________________________________________________ |
218 | AliMUONGeometryDetElement* | |
b75f649b | 219 | AliMUONGeometryModuleTransformer::GetDetElement(Int_t detElemId, Bool_t warn) const |
4f8b0abb | 220 | { |
221 | /// Return the detection element specified by detElemId. | |
a9aad96e | 222 | /// Give error if detection element is not defined and warn is true. |
4f8b0abb | 223 | |
224 | // Get detection element | |
225 | AliMUONGeometryDetElement* detElement | |
fa66b479 | 226 | = (AliMUONGeometryDetElement*) fDetElements->GetValue(detElemId); |
4f8b0abb | 227 | |
228 | if (!detElement) { | |
b75f649b | 229 | if (warn) |
230 | AliErrorStream() | |
231 | << "Detection element " << detElemId | |
232 | << " not found in module " << fModuleId << endl; | |
4f8b0abb | 233 | return 0; |
234 | } | |
235 | ||
236 | return detElement; | |
237 | } |