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 AliMUONGeometryModuleTransformer::AliMUONGeometryModuleTransformer(Int_t moduleId)
52 /// Standard constructor
54 // Chamber transformation
55 fTransformation = new TGeoHMatrix("");
57 // Det elements transformation stores
58 fDetElements = new AliMpExMap(true);
60 // Compose module name
61 fModuleName = fgkModuleNamePrefix;
62 fModuleName += moduleId;
66 //______________________________________________________________________________
67 AliMUONGeometryModuleTransformer::AliMUONGeometryModuleTransformer()
75 /// Default constructor
79 //______________________________________________________________________________
80 AliMUONGeometryModuleTransformer::~AliMUONGeometryModuleTransformer()
84 delete fTransformation;
92 //______________________________________________________________________________
93 void AliMUONGeometryModuleTransformer::Global2Local(Int_t detElemId,
94 Float_t xg, Float_t yg, Float_t zg,
95 Float_t& xl, Float_t& yl, Float_t& zl) const
97 /// Transform point from the global reference frame (ALIC)
98 /// to the local reference frame of the detection element specified
101 // Get detection element
102 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
103 if (!detElement) return;
106 detElement->Global2Local(xg, yg, zg, xl, yl, zl);
109 //______________________________________________________________________________
110 void AliMUONGeometryModuleTransformer::Global2Local(Int_t detElemId,
111 Double_t xg, Double_t yg, Double_t zg,
112 Double_t& xl, Double_t& yl, Double_t& zl) const
114 /// Transform point from the global reference frame (ALIC)
115 /// to the local reference frame of the detection element specified
118 // Get detection element
119 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
120 if (!detElement) return;
123 detElement->Global2Local(xg, yg, zg, xl, yl, zl);
126 //______________________________________________________________________________
127 void AliMUONGeometryModuleTransformer::Local2Global(Int_t detElemId,
128 Float_t xl, Float_t yl, Float_t zl,
129 Float_t& xg, Float_t& yg, Float_t& zg) const
131 /// Transform point from the local reference frame of the detection element
132 /// specified by detElemId to the global reference frame (ALIC).
134 // Get detection element
135 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
136 if (!detElement) return;
139 detElement->Local2Global(xl, yl, zl, xg, yg, zg);
142 //______________________________________________________________________________
143 void AliMUONGeometryModuleTransformer::Local2Global(Int_t detElemId,
144 Double_t xl, Double_t yl, Double_t zl,
145 Double_t& xg, Double_t& yg, Double_t& zg) const
147 /// Transform point from the local reference frame of the detection element
148 /// specified by detElemId to the global reference frame (ALIC).
150 // Get detection element
151 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
152 if (!detElement) return;
155 detElement->Local2Global(xl, yl, zl, xg, yg, zg);
158 //______________________________________________________________________________
159 void AliMUONGeometryModuleTransformer::SetTransformation(
160 const TGeoHMatrix& transform)
162 /// Set the module position wrt world.
164 *fTransformation = transform;
167 //______________________________________________________________________________
168 TString AliMUONGeometryModuleTransformer::GetVolumeName() const
170 /// Extract volume name from the path
172 std::string volPath = fVolumePath.Data();
173 std::string::size_type first = volPath.rfind('/')+1;
174 std::string::size_type last = volPath.rfind('_');
176 return volPath.substr(first, last-first );
179 //______________________________________________________________________________
180 TString AliMUONGeometryModuleTransformer::GetMotherVolumeName() const
182 /// Extract mother volume name from the path
184 std::string volPath = fVolumePath.Data();
185 std::string::size_type first = volPath.rfind('/');
186 volPath = volPath.substr(0, first);
188 std::string::size_type next = volPath.rfind('/')+1;
189 std::string::size_type last = volPath.rfind('_');
191 return volPath.substr(next, last-next );
194 //______________________________________________________________________________
195 AliMUONGeometryDetElement*
196 AliMUONGeometryModuleTransformer::GetDetElement(Int_t detElemId, Bool_t warn) const
198 /// Return the detection element specified by detElemId.
199 /// Give error if detection element is not defined and warn is true.
201 // Get detection element
202 AliMUONGeometryDetElement* detElement
203 = (AliMUONGeometryDetElement*) fDetElements->GetValue(detElemId);
208 << "Detection element " << detElemId
209 << " not found in module " << fModuleId << endl;