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)
42 const TString AliMUONGeometryModuleTransformer::fgkModuleNamePrefix = "GM";
44 //______________________________________________________________________________
45 TString AliMUONGeometryModuleTransformer::GetModuleName(Int_t moduleId)
47 /// Return the module name for given moduleId
49 TString moduleName(fgkModuleNamePrefix);
50 moduleName += moduleId;
54 //______________________________________________________________________________
55 AliMUONGeometryModuleTransformer::AliMUONGeometryModuleTransformer(Int_t moduleId)
58 fModuleName(GetModuleName(moduleId)),
63 /// Standard constructor
65 // Chamber transformation
66 fTransformation = new TGeoHMatrix("");
68 // Det elements transformation stores
69 fDetElements = new AliMpExMap;
73 //______________________________________________________________________________
74 AliMUONGeometryModuleTransformer::AliMUONGeometryModuleTransformer(TRootIOCtor* /*ioCtor*/)
82 /// Root IO constructor
86 //______________________________________________________________________________
87 AliMUONGeometryModuleTransformer::~AliMUONGeometryModuleTransformer()
91 delete fTransformation;
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
104 /// Transform point from the global reference frame (ALIC)
105 /// to the local reference frame of the detection element specified
108 // Get detection element
109 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
110 if (!detElement) return;
113 detElement->Global2Local(xg, yg, zg, xl, yl, zl);
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
121 /// Transform point from the global reference frame (ALIC)
122 /// to the local reference frame of the detection element specified
125 // Get detection element
126 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
127 if (!detElement) return;
130 detElement->Global2Local(xg, yg, zg, xl, yl, zl);
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
138 /// Transform point from the local reference frame of the detection element
139 /// specified by detElemId to the global reference frame (ALIC).
141 // Get detection element
142 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
143 if (!detElement) return;
146 detElement->Local2Global(xl, yl, zl, xg, yg, zg);
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
154 /// Transform point from the local reference frame of the detection element
155 /// specified by detElemId to the global reference frame (ALIC).
157 // Get detection element
158 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
159 if (!detElement) return;
162 detElement->Local2Global(xl, yl, zl, xg, yg, zg);
165 //______________________________________________________________________________
166 void AliMUONGeometryModuleTransformer::SetTransformation(
167 const TGeoHMatrix& transform)
169 /// Set the module position wrt world.
171 *fTransformation = transform;
174 //______________________________________________________________________________
175 TString AliMUONGeometryModuleTransformer::GetVolumeName() const
177 /// Extract volume name from the path
179 std::string volPath = fVolumePath.Data();
180 std::string::size_type first = volPath.rfind('/')+1;
181 std::string::size_type last = volPath.rfind('_');
183 return volPath.substr(first, last-first );
186 //______________________________________________________________________________
187 TString AliMUONGeometryModuleTransformer::GetMotherVolumeName() const
189 /// Extract mother volume name from the path
191 std::string volPath = fVolumePath.Data();
192 std::string::size_type first = volPath.rfind('/');
193 volPath = volPath.substr(0, first);
195 std::string::size_type next = volPath.rfind('/')+1;
196 std::string::size_type last = volPath.rfind('_');
198 return volPath.substr(next, last-next );
201 //______________________________________________________________________________
202 AliMUONGeometryDetElement*
203 AliMUONGeometryModuleTransformer::GetDetElement(Int_t detElemId, Bool_t warn) const
205 /// Return the detection element specified by detElemId.
206 /// Give error if detection element is not defined and warn is true.
208 // Get detection element
209 AliMUONGeometryDetElement* detElement
210 = (AliMUONGeometryDetElement*) fDetElements->GetValue(detElemId);
215 << "Detection element " << detElemId
216 << " not found in module " << fModuleId << endl;