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
24 #include "AliMUONGeometryModuleTransformer.h"
25 #include "AliMUONGeometryDetElement.h"
27 #include "AliMpExMap.h"
31 #include <TVirtualMC.h>
32 #include <TGeoMatrix.h>
33 #include <TObjArray.h>
35 #include <Riostream.h>
38 ClassImp(AliMUONGeometryModuleTransformer)
41 const TString AliMUONGeometryModuleTransformer::fgkModuleNamePrefix = "GM";
43 //______________________________________________________________________________
44 TString AliMUONGeometryModuleTransformer::GetModuleName(Int_t moduleId)
46 /// Return the module name for given moduleId
48 TString moduleName(fgkModuleNamePrefix);
49 moduleName += moduleId;
53 //______________________________________________________________________________
54 AliMUONGeometryModuleTransformer::AliMUONGeometryModuleTransformer(Int_t moduleId)
57 fModuleName(GetModuleName(moduleId)),
62 /// Standard constructor
64 // Chamber transformation
65 fTransformation = new TGeoHMatrix("");
67 // Det elements transformation stores
68 fDetElements = new AliMpExMap(true);
72 //______________________________________________________________________________
73 AliMUONGeometryModuleTransformer::AliMUONGeometryModuleTransformer(TRootIOCtor* /*ioCtor*/)
81 /// Root IO constructor
85 //______________________________________________________________________________
86 AliMUONGeometryModuleTransformer::~AliMUONGeometryModuleTransformer()
90 delete fTransformation;
98 //______________________________________________________________________________
99 void AliMUONGeometryModuleTransformer::Global2Local(Int_t detElemId,
100 Float_t xg, Float_t yg, Float_t zg,
101 Float_t& xl, Float_t& yl, Float_t& zl) const
103 /// Transform point from the global reference frame (ALIC)
104 /// to the local reference frame of the detection element specified
107 // Get detection element
108 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
109 if (!detElement) return;
112 detElement->Global2Local(xg, yg, zg, xl, yl, zl);
115 //______________________________________________________________________________
116 void AliMUONGeometryModuleTransformer::Global2Local(Int_t detElemId,
117 Double_t xg, Double_t yg, Double_t zg,
118 Double_t& xl, Double_t& yl, Double_t& zl) const
120 /// Transform point from the global reference frame (ALIC)
121 /// to the local reference frame of the detection element specified
124 // Get detection element
125 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
126 if (!detElement) return;
129 detElement->Global2Local(xg, yg, zg, xl, yl, zl);
132 //______________________________________________________________________________
133 void AliMUONGeometryModuleTransformer::Local2Global(Int_t detElemId,
134 Float_t xl, Float_t yl, Float_t zl,
135 Float_t& xg, Float_t& yg, Float_t& zg) const
137 /// Transform point from the local reference frame of the detection element
138 /// specified by detElemId to the global reference frame (ALIC).
140 // Get detection element
141 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
142 if (!detElement) return;
145 detElement->Local2Global(xl, yl, zl, xg, yg, zg);
148 //______________________________________________________________________________
149 void AliMUONGeometryModuleTransformer::Local2Global(Int_t detElemId,
150 Double_t xl, Double_t yl, Double_t zl,
151 Double_t& xg, Double_t& yg, Double_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::SetTransformation(
166 const TGeoHMatrix& transform)
168 /// Set the module position wrt world.
170 *fTransformation = transform;
173 //______________________________________________________________________________
174 TString AliMUONGeometryModuleTransformer::GetVolumeName() const
176 /// Extract volume name from the path
178 std::string volPath = fVolumePath.Data();
179 std::string::size_type first = volPath.rfind('/')+1;
180 std::string::size_type last = volPath.rfind('_');
182 return volPath.substr(first, last-first );
185 //______________________________________________________________________________
186 TString AliMUONGeometryModuleTransformer::GetMotherVolumeName() const
188 /// Extract mother volume name from the path
190 std::string volPath = fVolumePath.Data();
191 std::string::size_type first = volPath.rfind('/');
192 volPath = volPath.substr(0, first);
194 std::string::size_type next = volPath.rfind('/')+1;
195 std::string::size_type last = volPath.rfind('_');
197 return volPath.substr(next, last-next );
200 //______________________________________________________________________________
201 AliMUONGeometryDetElement*
202 AliMUONGeometryModuleTransformer::GetDetElement(Int_t detElemId, Bool_t warn) const
204 /// Return the detection element specified by detElemId.
205 /// Give error if detection element is not defined and warn is true.
207 // Get detection element
208 AliMUONGeometryDetElement* detElement
209 = (AliMUONGeometryDetElement*) fDetElements->GetValue(detElemId);
214 << "Detection element " << detElemId
215 << " not found in module " << fModuleId << endl;