]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONGeometryModuleTransformer.cxx
Add buspatch length & change patch module interface needed for station 2
[u/mrichter/AliRoot.git] / MUON / AliMUONGeometryModuleTransformer.cxx
CommitLineData
4f8b0abb 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16// $Id$
17//
f7006443 18// -------------------------------------
4f8b0abb 19// Class AliMUONGeometryModuleTransformer
20// -------------------------------------
21// Class for definition of the detector module transformations
4f8b0abb 22// Author: Ivana Hrivnacova, IPN Orsay
23
ab488200 24#include "AliMUONGeometryModuleTransformer.h"
25#include "AliMUONGeometryDetElement.h"
fa66b479 26
27#include "AliMpExMap.h"
ab488200 28
29#include "AliLog.h"
30
4f8b0abb 31#include <TVirtualMC.h>
32#include <TGeoMatrix.h>
33#include <TObjArray.h>
34#include <TArrayI.h>
35#include <Riostream.h>
36
a9aad96e 37/// \cond CLASSIMP
4f8b0abb 38ClassImp(AliMUONGeometryModuleTransformer)
a9aad96e 39/// \endcond
4f8b0abb 40
eb288296 41const TString AliMUONGeometryModuleTransformer::fgkModuleNamePrefix = "GM";
42
1f687625 43//______________________________________________________________________________
44TString AliMUONGeometryModuleTransformer::GetModuleName(Int_t moduleId)
45{
46/// Return the module name for given moduleId
47
48 TString moduleName(fgkModuleNamePrefix);
49 moduleName += moduleId;
50 return moduleName;
51}
52
4f8b0abb 53//______________________________________________________________________________
54AliMUONGeometryModuleTransformer::AliMUONGeometryModuleTransformer(Int_t moduleId)
55 : TObject(),
56 fModuleId(moduleId),
1f687625 57 fModuleName(GetModuleName(moduleId)),
ab488200 58 fVolumePath(),
4f8b0abb 59 fTransformation(0),
60 fDetElements(0)
61{
62/// Standard constructor
63
64 // Chamber transformation
ab488200 65 fTransformation = new TGeoHMatrix("");
4f8b0abb 66
67 // Det elements transformation stores
fa66b479 68 fDetElements = new AliMpExMap(true);
4f8b0abb 69}
70
71
72//______________________________________________________________________________
1f687625 73AliMUONGeometryModuleTransformer::AliMUONGeometryModuleTransformer(TRootIOCtor* /*ioCtor*/)
4f8b0abb 74 : TObject(),
75 fModuleId(0),
eb288296 76 fModuleName(),
ab488200 77 fVolumePath(),
4f8b0abb 78 fTransformation(0),
79 fDetElements(0)
80{
1f687625 81/// Root IO constructor
4f8b0abb 82}
83
84
4f8b0abb 85//______________________________________________________________________________
86AliMUONGeometryModuleTransformer::~AliMUONGeometryModuleTransformer()
87{
88/// Destructor
89
90 delete fTransformation;
91 delete fDetElements;
92}
93
4f8b0abb 94//
95// public methods
96//
97
98//______________________________________________________________________________
99void 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
102{
103/// Transform point from the global reference frame (ALIC)
104/// to the local reference frame of the detection element specified
105/// by detElemId.
106
107 // Get detection element
108 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
109 if (!detElement) return;
110
111 // Transform point
112 detElement->Global2Local(xg, yg, zg, xl, yl, zl);
113}
114
115//______________________________________________________________________________
116void 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
119{
120/// Transform point from the global reference frame (ALIC)
121/// to the local reference frame of the detection element specified
122/// by detElemId.
123
124 // Get detection element
125 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
126 if (!detElement) return;
127
128 // Transform point
129 detElement->Global2Local(xg, yg, zg, xl, yl, zl);
130}
131
132//______________________________________________________________________________
133void 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
136{
137/// Transform point from the local reference frame of the detection element
138/// specified by detElemId to the global reference frame (ALIC).
139
140 // Get detection element
141 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
142 if (!detElement) return;
143
144 // Transform point
145 detElement->Local2Global(xl, yl, zl, xg, yg, zg);
146}
147
148//______________________________________________________________________________
149void 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
152{
153/// Transform point from the local reference frame of the detection element
154/// specified by detElemId to the global reference frame (ALIC).
155
156 // Get detection element
157 AliMUONGeometryDetElement* detElement = GetDetElement(detElemId);
158 if (!detElement) return;
159
160 // Transform point
161 detElement->Local2Global(xl, yl, zl, xg, yg, zg);
162}
163
164//______________________________________________________________________________
165void AliMUONGeometryModuleTransformer::SetTransformation(
ab488200 166 const TGeoHMatrix& transform)
4f8b0abb 167{
168/// Set the module position wrt world.
169
170 *fTransformation = transform;
171}
172
ab488200 173//______________________________________________________________________________
174TString AliMUONGeometryModuleTransformer::GetVolumeName() const
175{
176/// Extract volume name from the path
177
178 std::string volPath = fVolumePath.Data();
179 std::string::size_type first = volPath.rfind('/')+1;
180 std::string::size_type last = volPath.rfind('_');
181
182 return volPath.substr(first, last-first );
183}
184
185//______________________________________________________________________________
186TString AliMUONGeometryModuleTransformer::GetMotherVolumeName() const
187{
a9aad96e 188/// Extract mother volume name from the path
ab488200 189
190 std::string volPath = fVolumePath.Data();
191 std::string::size_type first = volPath.rfind('/');
192 volPath = volPath.substr(0, first);
193
194 std::string::size_type next = volPath.rfind('/')+1;
195 std::string::size_type last = volPath.rfind('_');
196
197 return volPath.substr(next, last-next );
198}
199
4f8b0abb 200//______________________________________________________________________________
201AliMUONGeometryDetElement*
b75f649b 202AliMUONGeometryModuleTransformer::GetDetElement(Int_t detElemId, Bool_t warn) const
4f8b0abb 203{
204/// Return the detection element specified by detElemId.
a9aad96e 205/// Give error if detection element is not defined and warn is true.
4f8b0abb 206
207 // Get detection element
208 AliMUONGeometryDetElement* detElement
fa66b479 209 = (AliMUONGeometryDetElement*) fDetElements->GetValue(detElemId);
4f8b0abb 210
211 if (!detElement) {
b75f649b 212 if (warn)
213 AliErrorStream()
214 << "Detection element " << detElemId
215 << " not found in module " << fModuleId << endl;
4f8b0abb 216 return 0;
217 }
218
219 return detElement;
220}