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>
37 ClassImp(AliMUONGeometryModuleTransformer)
40 //______________________________________________________________________________
41 AliMUONGeometryModuleTransformer::AliMUONGeometryModuleTransformer(Int_t moduleId)
48 /// Standard constructor
50 // Chamber transformation
51 fTransformation = new TGeoHMatrix("");
53 // Det elements transformation stores
54 fDetElements = new AliMUONGeometryStore(true);
58 //______________________________________________________________________________
59 AliMUONGeometryModuleTransformer::AliMUONGeometryModuleTransformer()
66 /// Default constructor
70 //______________________________________________________________________________
71 AliMUONGeometryModuleTransformer::~AliMUONGeometryModuleTransformer()
75 delete fTransformation;
83 //______________________________________________________________________________
84 void AliMUONGeometryModuleTransformer::Global2Local(Int_t detElemId,
85 Float_t xg, Float_t yg, Float_t zg,
86 Float_t& xl, Float_t& yl, Float_t& zl) const
88 /// Transform point from the global reference frame (ALIC)
89 /// to the local reference frame of the detection element specified
92 // Get detection element
93 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
94 if (!detElement) return;
97 detElement->Global2Local(xg, yg, zg, xl, yl, zl);
100 //______________________________________________________________________________
101 void AliMUONGeometryModuleTransformer::Global2Local(Int_t detElemId,
102 Double_t xg, Double_t yg, Double_t zg,
103 Double_t& xl, Double_t& yl, Double_t& zl) const
105 /// Transform point from the global reference frame (ALIC)
106 /// to the local reference frame of the detection element specified
109 // Get detection element
110 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
111 if (!detElement) return;
114 detElement->Global2Local(xg, yg, zg, xl, yl, zl);
117 //______________________________________________________________________________
118 void AliMUONGeometryModuleTransformer::Local2Global(Int_t detElemId,
119 Float_t xl, Float_t yl, Float_t zl,
120 Float_t& xg, Float_t& yg, Float_t& zg) const
122 /// Transform point from the local reference frame of the detection element
123 /// specified by detElemId to the global reference frame (ALIC).
125 // Get detection element
126 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
127 if (!detElement) return;
130 detElement->Local2Global(xl, yl, zl, xg, yg, zg);
133 //______________________________________________________________________________
134 void AliMUONGeometryModuleTransformer::Local2Global(Int_t detElemId,
135 Double_t xl, Double_t yl, Double_t zl,
136 Double_t& xg, Double_t& yg, Double_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::SetTransformation(
151 const TGeoHMatrix& transform)
153 /// Set the module position wrt world.
155 *fTransformation = transform;
158 //______________________________________________________________________________
159 TString AliMUONGeometryModuleTransformer::GetVolumeName() const
161 /// Extract volume name from the path
163 std::string volPath = fVolumePath.Data();
164 std::string::size_type first = volPath.rfind('/')+1;
165 std::string::size_type last = volPath.rfind('_');
167 return volPath.substr(first, last-first );
170 //______________________________________________________________________________
171 TString AliMUONGeometryModuleTransformer::GetMotherVolumeName() const
173 /// Extract mother volume name from the path
175 std::string volPath = fVolumePath.Data();
176 std::string::size_type first = volPath.rfind('/');
177 volPath = volPath.substr(0, first);
179 std::string::size_type next = volPath.rfind('/')+1;
180 std::string::size_type last = volPath.rfind('_');
182 return volPath.substr(next, last-next );
185 //______________________________________________________________________________
186 AliMUONGeometryDetElement*
187 AliMUONGeometryModuleTransformer::GetDetElement(Int_t detElemId, Bool_t warn) const
189 /// Return the detection element specified by detElemId.
190 /// Give error if detection element is not defined and warn is true.
192 // Get detection element
193 AliMUONGeometryDetElement* detElement
194 = (AliMUONGeometryDetElement*) fDetElements->Get(detElemId, warn);
199 << "Detection element " << detElemId
200 << " not found in module " << fModuleId << endl;