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"
26 #include "AliMUONGeometryStore.h"
30 #include <TVirtualMC.h>
31 #include <TGeoMatrix.h>
32 #include <TObjArray.h>
34 #include <Riostream.h>
36 ClassImp(AliMUONGeometryModuleTransformer)
38 //______________________________________________________________________________
39 AliMUONGeometryModuleTransformer::AliMUONGeometryModuleTransformer(Int_t moduleId)
46 /// Standard constructor
48 // Chamber transformation
49 fTransformation = new TGeoHMatrix("");
51 // Det elements transformation stores
52 fDetElements = new AliMUONGeometryStore(true);
56 //______________________________________________________________________________
57 AliMUONGeometryModuleTransformer::AliMUONGeometryModuleTransformer()
64 /// Default constructor
68 //______________________________________________________________________________
69 AliMUONGeometryModuleTransformer::AliMUONGeometryModuleTransformer(
70 const AliMUONGeometryModuleTransformer& rhs)
73 /// Protected copy constructor
75 AliFatal("Copy constructor is not implemented.");
78 //______________________________________________________________________________
79 AliMUONGeometryModuleTransformer::~AliMUONGeometryModuleTransformer()
83 delete fTransformation;
87 //______________________________________________________________________________
88 AliMUONGeometryModuleTransformer&
89 AliMUONGeometryModuleTransformer::operator = (
90 const AliMUONGeometryModuleTransformer& rhs)
92 /// Protected assignement operator
94 // check assignement to self
95 if (this == &rhs) return *this;
97 AliFatal("Assignment operator is not implemented.");
106 //______________________________________________________________________________
107 void AliMUONGeometryModuleTransformer::Global2Local(Int_t detElemId,
108 Float_t xg, Float_t yg, Float_t zg,
109 Float_t& xl, Float_t& yl, Float_t& zl) const
111 /// Transform point from the global reference frame (ALIC)
112 /// to the local reference frame of the detection element specified
115 // Get detection element
116 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
117 if (!detElement) return;
120 detElement->Global2Local(xg, yg, zg, xl, yl, zl);
123 //______________________________________________________________________________
124 void AliMUONGeometryModuleTransformer::Global2Local(Int_t detElemId,
125 Double_t xg, Double_t yg, Double_t zg,
126 Double_t& xl, Double_t& yl, Double_t& zl) const
128 /// Transform point from the global reference frame (ALIC)
129 /// to the local reference frame of the detection element specified
132 // Get detection element
133 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
134 if (!detElement) return;
137 detElement->Global2Local(xg, yg, zg, xl, yl, zl);
140 //______________________________________________________________________________
141 void AliMUONGeometryModuleTransformer::Local2Global(Int_t detElemId,
142 Float_t xl, Float_t yl, Float_t zl,
143 Float_t& xg, Float_t& yg, Float_t& zg) const
145 /// Transform point from the local reference frame of the detection element
146 /// specified by detElemId to the global reference frame (ALIC).
148 // Get detection element
149 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
150 if (!detElement) return;
153 detElement->Local2Global(xl, yl, zl, xg, yg, zg);
156 //______________________________________________________________________________
157 void AliMUONGeometryModuleTransformer::Local2Global(Int_t detElemId,
158 Double_t xl, Double_t yl, Double_t zl,
159 Double_t& xg, Double_t& yg, Double_t& zg) const
161 /// Transform point from the local reference frame of the detection element
162 /// specified by detElemId to the global reference frame (ALIC).
164 // Get detection element
165 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
166 if (!detElement) return;
169 detElement->Local2Global(xl, yl, zl, xg, yg, zg);
172 //______________________________________________________________________________
173 void AliMUONGeometryModuleTransformer::SetTransformation(
174 const TGeoHMatrix& transform)
176 /// Set the module position wrt world.
178 *fTransformation = transform;
181 //______________________________________________________________________________
182 TString AliMUONGeometryModuleTransformer::GetVolumeName() const
184 /// Extract volume name from the path
186 std::string volPath = fVolumePath.Data();
187 std::string::size_type first = volPath.rfind('/')+1;
188 std::string::size_type last = volPath.rfind('_');
190 return volPath.substr(first, last-first );
193 //______________________________________________________________________________
194 TString AliMUONGeometryModuleTransformer::GetMotherVolumeName() const
196 /// Extract volume name from the path
198 std::string volPath = fVolumePath.Data();
199 std::string::size_type first = volPath.rfind('/');
200 volPath = volPath.substr(0, first);
202 std::string::size_type next = volPath.rfind('/')+1;
203 std::string::size_type last = volPath.rfind('_');
205 return volPath.substr(next, last-next );
208 //______________________________________________________________________________
209 AliMUONGeometryDetElement*
210 AliMUONGeometryModuleTransformer::GetDetElement(Int_t detElemId, Bool_t warn) const
212 /// Return the detection element specified by detElemId.
213 /// Give error if detection element is not defined.
215 // Get detection element
216 AliMUONGeometryDetElement* detElement
217 = (AliMUONGeometryDetElement*) fDetElements->Get(detElemId, warn);
222 << "Detection element " << detElemId
223 << " not found in module " << fModuleId << endl;