1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //-----------------------------------------------------------------------------
19 // Class AliMUONGeometryModuleTransformer
20 // -------------------------------------
21 // Class for definition of the detector module transformations
22 // Author: Ivana Hrivnacova, IPN Orsay
23 //-----------------------------------------------------------------------------
25 #include "AliMUONGeometryModuleTransformer.h"
26 #include "AliMUONGeometryDetElement.h"
28 #include "AliMpExMap.h"
32 #include <TVirtualMC.h>
33 #include <TGeoMatrix.h>
34 #include <TObjArray.h>
36 #include <Riostream.h>
39 ClassImp(AliMUONGeometryModuleTransformer)
46 //______________________________________________________________________________
47 const TString& AliMUONGeometryModuleTransformer::GetModuleNamePrefix()
49 /// Geometry module name prefix
50 static const TString kModuleNamePrefix = "GM";
51 return kModuleNamePrefix;
54 //______________________________________________________________________________
55 TString AliMUONGeometryModuleTransformer::GetModuleName(Int_t moduleId)
57 /// Return the module name for given moduleId
59 TString moduleName(GetModuleNamePrefix());
60 moduleName += moduleId;
68 //______________________________________________________________________________
69 AliMUONGeometryModuleTransformer::AliMUONGeometryModuleTransformer(Int_t moduleId)
72 fModuleName(GetModuleName(moduleId)),
77 /// Standard constructor
79 // Chamber transformation
80 fTransformation = new TGeoHMatrix("");
82 // Det elements transformation stores
83 fDetElements = new AliMpExMap;
87 //______________________________________________________________________________
88 AliMUONGeometryModuleTransformer::AliMUONGeometryModuleTransformer(TRootIOCtor* /*ioCtor*/)
96 /// Root IO constructor
100 //______________________________________________________________________________
101 AliMUONGeometryModuleTransformer::~AliMUONGeometryModuleTransformer()
105 delete fTransformation;
113 //______________________________________________________________________________
114 void AliMUONGeometryModuleTransformer::Global2Local(Int_t detElemId,
115 Float_t xg, Float_t yg, Float_t zg,
116 Float_t& xl, Float_t& yl, Float_t& zl) const
118 /// Transform point from the global reference frame (ALIC)
119 /// to the local reference frame of the detection element specified
122 // Get detection element
123 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
124 if (!detElement) return;
127 detElement->Global2Local(xg, yg, zg, xl, yl, zl);
130 //______________________________________________________________________________
131 void AliMUONGeometryModuleTransformer::Global2Local(Int_t detElemId,
132 Double_t xg, Double_t yg, Double_t zg,
133 Double_t& xl, Double_t& yl, Double_t& zl) const
135 /// Transform point from the global reference frame (ALIC)
136 /// to the local reference frame of the detection element specified
139 // Get detection element
140 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
141 if (!detElement) return;
144 detElement->Global2Local(xg, yg, zg, xl, yl, zl);
147 //______________________________________________________________________________
148 void AliMUONGeometryModuleTransformer::Local2Global(Int_t detElemId,
149 Float_t xl, Float_t yl, Float_t zl,
150 Float_t& xg, Float_t& yg, Float_t& zg) const
152 /// Transform point from the local reference frame of the detection element
153 /// specified by detElemId to the global reference frame (ALIC).
155 // Get detection element
156 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
157 if (!detElement) return;
160 detElement->Local2Global(xl, yl, zl, xg, yg, zg);
163 //______________________________________________________________________________
164 void AliMUONGeometryModuleTransformer::Local2Global(Int_t detElemId,
165 Double_t xl, Double_t yl, Double_t zl,
166 Double_t& xg, Double_t& yg, Double_t& zg) const
168 /// Transform point from the local reference frame of the detection element
169 /// specified by detElemId to the global reference frame (ALIC).
171 // Get detection element
172 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
173 if (!detElement) return;
176 detElement->Local2Global(xl, yl, zl, xg, yg, zg);
179 //______________________________________________________________________________
180 void AliMUONGeometryModuleTransformer::SetTransformation(
181 const TGeoHMatrix& transform)
183 /// Set the module position wrt world.
185 *fTransformation = transform;
188 //______________________________________________________________________________
189 TString AliMUONGeometryModuleTransformer::GetVolumeName() const
191 /// Extract volume name from the path
193 std::string volPath = fVolumePath.Data();
194 std::string::size_type first = volPath.rfind('/')+1;
195 std::string::size_type last = volPath.rfind('_');
197 return volPath.substr(first, last-first );
200 //______________________________________________________________________________
201 TString AliMUONGeometryModuleTransformer::GetMotherVolumeName() const
203 /// Extract mother volume name from the path
205 std::string volPath = fVolumePath.Data();
206 std::string::size_type first = volPath.rfind('/');
207 if ( first != std::string::npos )
208 volPath = volPath.substr(0, first);
210 std::string::size_type next = volPath.rfind('/')+1;
211 std::string::size_type last = volPath.rfind('_');
213 return volPath.substr(next, last-next );
216 //______________________________________________________________________________
217 AliMUONGeometryDetElement*
218 AliMUONGeometryModuleTransformer::GetDetElement(Int_t detElemId, Bool_t warn) const
220 /// Return the detection element specified by detElemId.
221 /// Give error if detection element is not defined and warn is true.
223 // Get detection element
224 AliMUONGeometryDetElement* detElement
225 = (AliMUONGeometryDetElement*) fDetElements->GetValue(detElemId);
230 << "Detection element " << detElemId
231 << " not found in module " << fModuleId << endl;