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 // Class AliMUONGeometryDetElement
19 // --------------------------------------
20 // The class defines the detection element.
22 // Author: Ivana Hrivnacova, IPN Orsay
24 #include <TGeoMatrix.h>
25 #include <Riostream.h>
29 #include "AliMUONGeometryDetElement.h"
31 ClassImp(AliMUONGeometryDetElement)
33 //______________________________________________________________________________
34 AliMUONGeometryDetElement::AliMUONGeometryDetElement(
36 const TString& alignedVolume,
37 const TGeoCombiTrans& relTransform)
39 fAlignedVolume(alignedVolume),
40 fLocalTransformation(0),
41 fGlobalTransformation(0)
43 /// Standard constructor
45 SetUniqueID(detElemId);
46 fLocalTransformation = new TGeoCombiTrans(relTransform);
49 //______________________________________________________________________________
50 AliMUONGeometryDetElement::AliMUONGeometryDetElement()
53 fLocalTransformation(0),
54 fGlobalTransformation(0)
56 /// Default constructor
59 //______________________________________________________________________________
60 AliMUONGeometryDetElement::AliMUONGeometryDetElement(
61 const AliMUONGeometryDetElement& rhs)
64 /// Protected copy constructor
66 AliFatal("Copy constructor is not implemented.");
69 //______________________________________________________________________________
70 AliMUONGeometryDetElement::~AliMUONGeometryDetElement()
74 delete fLocalTransformation;
75 delete fGlobalTransformation;
78 //______________________________________________________________________________
79 AliMUONGeometryDetElement&
80 AliMUONGeometryDetElement::operator = (const AliMUONGeometryDetElement& rhs)
82 /// Protected assignement operator
84 // check assignement to self
85 if (this == &rhs) return *this;
87 AliFatal("Assignment operator is not implemented.");
96 //______________________________________________________________________________
97 void AliMUONGeometryDetElement::PrintTransform(
98 const TGeoCombiTrans* transform) const
100 /// Prints the detection element transformation
102 cout << "DetElemId: " << GetUniqueID();
103 cout << " name: " << fAlignedVolume << endl;
105 const double* translation = transform->GetTranslation();
106 cout << " translation: "
107 #if defined (__DECCXX)
108 << translation[0] << ", "
109 << translation[1] << ", "
110 << translation[2] << endl;
113 << std::setw(7) << std::setprecision(4) << translation[0] << ", "
114 << std::setw(7) << std::setprecision(4) << translation[1] << ", "
115 << std::setw(7) << std::setprecision(4) << translation[2] << endl;
118 const double* rotation = transform->GetRotationMatrix();
119 cout << " rotation matrix: "
120 #if defined (__DECCXX)
121 << rotation[0] << ", " << rotation[1] << ", " << rotation[2] << endl
123 << rotation[3] << ", " << rotation[4] << ", " << rotation[5] << endl
125 << rotation[6] << ", " << rotation[7] << ", " << rotation[8] << endl;
128 << std::setw(7) << std::setprecision(4)
129 << rotation[0] << ", " << rotation[1] << ", " << rotation[2] << endl
131 << rotation[3] << ", " << rotation[4] << ", " << rotation[5] << endl
133 << rotation[6] << ", " << rotation[7] << ", " << rotation[8] << endl;
141 //______________________________________________________________________________
142 void AliMUONGeometryDetElement::Global2Local(
143 Float_t xg, Float_t yg, Float_t zg,
144 Float_t& xl, Float_t& yl, Float_t& zl) const
146 /// Transforms point from the global reference frame (ALIC)
147 /// to the local reference frame of the detection element specified
154 Double_t dxl, dyl, dzl;
155 Global2Local(dxg, dyg, dzg, dxl, dyl, dzl);
162 //______________________________________________________________________________
163 void AliMUONGeometryDetElement::Global2Local(
164 Double_t xg, Double_t yg, Double_t zg,
165 Double_t& xl, Double_t& yl, Double_t& zl) const
167 /// Transforms point from the global reference frame (ALIC)
168 /// to the local reference frame of the detection element specified
171 // Check transformation
172 if (!fGlobalTransformation) {
173 AliError(Form("Global transformation for detection element %d not defined.",
179 Double_t pg[3] = { xg, yg, zg };
180 Double_t pl[3] = { 0., 0., 0. };
181 fGlobalTransformation->MasterToLocal(pg, pl);
183 // Return transformed point
189 //______________________________________________________________________________
190 void AliMUONGeometryDetElement::Local2Global(
191 Float_t xl, Float_t yl, Float_t zl,
192 Float_t& xg, Float_t& yg, Float_t& zg) const
194 /// Transforms point from the local reference frame of the detection element
195 /// specified by detElemId to the global reference frame (ALIC).
201 Double_t dxg, dyg, dzg;
202 Local2Global(dxl, dyl, dzl, dxg, dyg, dzg);
209 //______________________________________________________________________________
210 void AliMUONGeometryDetElement::Local2Global(
211 Double_t xl, Double_t yl, Double_t zl,
212 Double_t& xg, Double_t& yg, Double_t& zg) const
214 /// Transforms point from the local reference frame of the detection element
215 /// specified by detElemId to the global reference frame (ALIC).
217 // Check transformation
218 if (!fGlobalTransformation) {
219 AliError(Form("Global transformation for detection element %d not defined.",
225 Double_t pl[3] = { xl, yl, zl };
226 Double_t pg[3] = { 0., 0., 0. };
227 fGlobalTransformation->LocalToMaster(pl, pg);
229 // Return transformed point
235 //______________________________________________________________________________
236 void AliMUONGeometryDetElement::SetGlobalTransformation(
237 const TGeoCombiTrans& transform)
239 /// Sets global transformation;
240 /// gives warning if the global transformation is already defined.
242 if (fGlobalTransformation) {
243 delete fGlobalTransformation;
244 AliWarning("Global transformation already defined was deleted.");
247 fGlobalTransformation = new TGeoCombiTrans(transform);
250 //______________________________________________________________________________
251 void AliMUONGeometryDetElement::PrintLocalTransform() const
253 /// Prints detection element relative transformation
254 /// (the transformation wrt module frame)
256 PrintTransform(fLocalTransformation);
259 //______________________________________________________________________________
260 void AliMUONGeometryDetElement::PrintGlobalTransform() const
262 /// Prints detection element global transformation
263 /// (the transformation wrt global frame)
265 PrintTransform(fLocalTransformation);