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