AliRoot Core  v5-06-30 (35d6c57)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMUONGeometryModuleTransformer.cxx
Go to the documentation of this file.
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 //-----------------------------------------------------------------------------
19 // Class AliMUONGeometryModuleTransformer
20 // -------------------------------------
21 // Class for definition of the detector module transformations
22 // Author: Ivana Hrivnacova, IPN Orsay
23 //-----------------------------------------------------------------------------
24 
27 
28 #include "AliMpExMap.h"
29 
30 #include "AliLog.h"
31 
32 #include <TVirtualMC.h>
33 #include <TGeoMatrix.h>
34 #include <TObjArray.h>
35 #include <TArrayI.h>
36 #include <Riostream.h>
37 
38 using std::endl;
42 
43 //
44 // static methods
45 //
46 
47 //______________________________________________________________________________
48 const TString& AliMUONGeometryModuleTransformer::GetModuleNamePrefix()
49 {
51  static const TString kModuleNamePrefix = "GM";
52  return kModuleNamePrefix;
53 }
54 
55 //______________________________________________________________________________
57 {
59 
60  TString moduleName(GetModuleNamePrefix());
61  moduleName += moduleId;
62  return moduleName;
63 }
64 
65 //
66 // ctor, dtor
67 //
68 
69 //______________________________________________________________________________
71  : TObject(),
72  fModuleId(moduleId),
73  fModuleName(GetModuleName(moduleId)),
74  fVolumePath(),
75  fTransformation(0),
76  fDetElements(0)
77 {
79 
80  // Chamber transformation
81  fTransformation = new TGeoHMatrix("");
82 
83  // Det elements transformation stores
85 }
86 
87 
88 //______________________________________________________________________________
90  : TObject(),
91  fModuleId(0),
92  fModuleName(),
93  fVolumePath(),
94  fTransformation(0),
95  fDetElements(0)
96 {
98 }
99 
100 
101 //______________________________________________________________________________
103 {
105 
106  delete fTransformation;
107  delete fDetElements;
108 }
109 
110 //
111 // public methods
112 //
113 
114 //______________________________________________________________________________
116  Float_t xg, Float_t yg, Float_t zg,
117  Float_t& xl, Float_t& yl, Float_t& zl) const
118 {
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 //______________________________________________________________________________
133  Double_t xg, Double_t yg, Double_t zg,
134  Double_t& xl, Double_t& yl, Double_t& zl) const
135 {
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 //______________________________________________________________________________
150  Float_t xl, Float_t yl, Float_t zl,
151  Float_t& xg, Float_t& yg, Float_t& zg) const
152 {
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 //______________________________________________________________________________
166  Double_t xl, Double_t yl, Double_t zl,
167  Double_t& xg, Double_t& yg, Double_t& zg) const
168 {
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 //______________________________________________________________________________
182  const TGeoHMatrix& transform)
183 {
185 
186  *fTransformation = transform;
187 }
188 
189 //______________________________________________________________________________
191 {
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 //______________________________________________________________________________
203 {
205 
206  std::string volPath = fVolumePath.Data();
207  std::string::size_type first = volPath.rfind('/');
208  if ( first != std::string::npos )
209  volPath = volPath.substr(0, first);
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 
217 //______________________________________________________________________________
219 AliMUONGeometryModuleTransformer::GetDetElement(Int_t detElemId, Bool_t warn) const
220 {
223 
224  // Get detection element
225  AliMUONGeometryDetElement* detElement
227 
228  if (!detElement) {
229  if (warn)
230  AliErrorStream()
231  << "Detection element " << detElemId
232  << " not found in module " << fModuleId << endl;
233  return 0;
234  }
235 
236  return detElement;
237 }
void Local2Global(Float_t xl, Float_t yl, Float_t zl, Float_t &xg, Float_t &yg, Float_t &zg) const
Geometry transformer for a detector module.
void Local2Global(Int_t detElemId, Float_t xl, Float_t yl, Float_t zl, Float_t &xg, Float_t &yg, Float_t &zg) const
void Global2Local(Int_t detElemId, Float_t xg, Float_t yg, Float_t zg, Float_t &xl, Float_t &yl, Float_t &zl) const
AliMUONGeometryModuleTransformer()
Not implemented.
AliMpExMap * fDetElements
detection elements
TGeoHMatrix * fTransformation
the module transformation wrt to top volume (world)
TString fVolumePath
the full path of aligned module volume or envelope in geometry
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
void Global2Local(Float_t xg, Float_t yg, Float_t zg, Float_t &xl, Float_t &yl, Float_t &zl) const
TObject * GetValue(Int_t keyFirst, Int_t keySecond) const
Definition: AliMpExMap.cxx:364
TString GetModuleName() const
Return module name.
void SetTransformation(const TGeoHMatrix &transform)
Class for storing detection element transformations.
AliMUONGeometryDetElement * GetDetElement(Int_t detElemId, Bool_t warn=true) const
Helper class making Root persistent TExMap.
Definition: AliMpExMap.h:28