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>
40 ClassImp(AliMUONGeometryModuleTransformer)
47 //______________________________________________________________________________
48 const TString& AliMUONGeometryModuleTransformer::GetModuleNamePrefix()
50 /// Geometry module name prefix
51 static const TString kModuleNamePrefix = "GM";
52 return kModuleNamePrefix;
55 //______________________________________________________________________________
56 TString AliMUONGeometryModuleTransformer::GetModuleName(Int_t moduleId)
58 /// Return the module name for given moduleId
60 TString moduleName(GetModuleNamePrefix());
61 moduleName += moduleId;
69 //______________________________________________________________________________
70 AliMUONGeometryModuleTransformer::AliMUONGeometryModuleTransformer(Int_t moduleId)
73 fModuleName(GetModuleName(moduleId)),
78 /// Standard constructor
80 // Chamber transformation
81 fTransformation = new TGeoHMatrix("");
83 // Det elements transformation stores
84 fDetElements = new AliMpExMap;
88 //______________________________________________________________________________
89 AliMUONGeometryModuleTransformer::AliMUONGeometryModuleTransformer(TRootIOCtor* /*ioCtor*/)
97 /// Root IO constructor
101 //______________________________________________________________________________
102 AliMUONGeometryModuleTransformer::~AliMUONGeometryModuleTransformer()
106 delete fTransformation;
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
119 /// Transform point from the global reference frame (ALIC)
120 /// to the local reference frame of the detection element specified
123 // Get detection element
124 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
125 if (!detElement) return;
128 detElement->Global2Local(xg, yg, zg, xl, yl, zl);
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
136 /// Transform point from the global reference frame (ALIC)
137 /// to the local reference frame of the detection element specified
140 // Get detection element
141 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
142 if (!detElement) return;
145 detElement->Global2Local(xg, yg, zg, xl, yl, zl);
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
153 /// Transform point from the local reference frame of the detection element
154 /// specified by detElemId to the global reference frame (ALIC).
156 // Get detection element
157 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
158 if (!detElement) return;
161 detElement->Local2Global(xl, yl, zl, xg, yg, zg);
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
169 /// Transform point from the local reference frame of the detection element
170 /// specified by detElemId to the global reference frame (ALIC).
172 // Get detection element
173 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
174 if (!detElement) return;
177 detElement->Local2Global(xl, yl, zl, xg, yg, zg);
180 //______________________________________________________________________________
181 void AliMUONGeometryModuleTransformer::SetTransformation(
182 const TGeoHMatrix& transform)
184 /// Set the module position wrt world.
186 *fTransformation = transform;
189 //______________________________________________________________________________
190 TString AliMUONGeometryModuleTransformer::GetVolumeName() const
192 /// Extract volume name from the path
194 std::string volPath = fVolumePath.Data();
195 std::string::size_type first = volPath.rfind('/')+1;
196 std::string::size_type last = volPath.rfind('_');
198 return volPath.substr(first, last-first );
201 //______________________________________________________________________________
202 TString AliMUONGeometryModuleTransformer::GetMotherVolumeName() const
204 /// Extract mother volume name from the path
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);
211 std::string::size_type next = volPath.rfind('/')+1;
212 std::string::size_type last = volPath.rfind('_');
214 return volPath.substr(next, last-next );
217 //______________________________________________________________________________
218 AliMUONGeometryDetElement*
219 AliMUONGeometryModuleTransformer::GetDetElement(Int_t detElemId, Bool_t warn) const
221 /// Return the detection element specified by detElemId.
222 /// Give error if detection element is not defined and warn is true.
224 // Get detection element
225 AliMUONGeometryDetElement* detElement
226 = (AliMUONGeometryDetElement*) fDetElements->GetValue(detElemId);
231 << "Detection element " << detElemId
232 << " not found in module " << fModuleId << endl;