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 AliFatal("Copy constructor is not implemented.");
67 //______________________________________________________________________________
68 AliMUONGeometryDetElement::~AliMUONGeometryDetElement() {
70 delete fLocalTransformation;
71 delete fGlobalTransformation;
74 //______________________________________________________________________________
75 AliMUONGeometryDetElement&
76 AliMUONGeometryDetElement::operator = (const AliMUONGeometryDetElement& rhs)
78 // check assignement to self
79 if (this == &rhs) return *this;
81 AliFatal("Assignment operator is not implemented.");
90 //______________________________________________________________________________
91 void AliMUONGeometryDetElement::PrintTransform(
92 const TGeoCombiTrans* transform) const
94 // Prints the detection element transformation
97 cout << "DetElemId: " << GetUniqueID();
98 cout << " name: " << fAlignedVolume << endl;
100 const double* translation = transform->GetTranslation();
101 cout << " translation: "
102 #if defined (__DECCXX)
103 << translation[0] << ", "
104 << translation[1] << ", "
105 << translation[2] << endl;
108 << std::setw(7) << std::setprecision(4) << translation[0] << ", "
109 << std::setw(7) << std::setprecision(4) << translation[1] << ", "
110 << std::setw(7) << std::setprecision(4) << translation[2] << endl;
113 const double* rotation = transform->GetRotationMatrix();
114 cout << " rotation matrix: "
115 #if defined (__DECCXX)
116 << rotation[0] << ", " << rotation[1] << ", " << rotation[2] << endl
118 << rotation[3] << ", " << rotation[4] << ", " << rotation[5] << endl
120 << rotation[6] << ", " << rotation[7] << ", " << rotation[8] << endl;
123 << std::setw(7) << std::setprecision(4)
124 << rotation[0] << ", " << rotation[1] << ", " << rotation[2] << endl
126 << rotation[3] << ", " << rotation[4] << ", " << rotation[5] << endl
128 << rotation[6] << ", " << rotation[7] << ", " << rotation[8] << endl;
136 //______________________________________________________________________________
137 void AliMUONGeometryDetElement::Global2Local(
138 Float_t xg, Float_t yg, Float_t zg,
139 Float_t& xl, Float_t& yl, Float_t& zl) const
141 // Transforms point from the global reference frame (ALIC)
142 // to the local reference frame of the detection element specified
150 Double_t dxl, dyl, dzl;
151 Global2Local(dxg, dyg, dzg, dxl, dyl, dzl);
158 //______________________________________________________________________________
159 void AliMUONGeometryDetElement::Global2Local(
160 Double_t xg, Double_t yg, Double_t zg,
161 Double_t& xl, Double_t& yl, Double_t& zl) const
163 // Transforms point from the global reference frame (ALIC)
164 // to the local reference frame of the detection element specified
168 // Check transformation
169 if (!fGlobalTransformation) {
170 AliError(Form("Global transformation for detection element %d not defined.",
176 Double_t pg[3] = { xg, yg, zg };
177 Double_t pl[3] = { 0., 0., 0. };
178 fGlobalTransformation->MasterToLocal(pg, pl);
180 // Return transformed point
186 //______________________________________________________________________________
187 void AliMUONGeometryDetElement::Local2Global(
188 Float_t xl, Float_t yl, Float_t zl,
189 Float_t& xg, Float_t& yg, Float_t& zg) const
191 // Transforms point from the local reference frame of the detection element
192 // specified by detElemId to the global reference frame (ALIC).
199 Double_t dxg, dyg, dzg;
200 Local2Global(dxl, dyl, dzl, dxg, dyg, dzg);
207 //______________________________________________________________________________
208 void AliMUONGeometryDetElement::Local2Global(
209 Double_t xl, Double_t yl, Double_t zl,
210 Double_t& xg, Double_t& yg, Double_t& zg) const
212 // Transforms point from the local reference frame of the detection element
213 // specified by detElemId to the global reference frame (ALIC).
216 // Check transformation
217 if (!fGlobalTransformation) {
218 AliError(Form("Global transformation for detection element %d not defined.",
224 Double_t pl[3] = { xl, yl, zl };
225 Double_t pg[3] = { 0., 0., 0. };
226 fGlobalTransformation->LocalToMaster(pl, pg);
228 // Return transformed point
234 //______________________________________________________________________________
235 void AliMUONGeometryDetElement::SetGlobalTransformation(
236 const TGeoCombiTrans& transform)
238 // Sets global transformation;
239 // 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)
257 PrintTransform(fLocalTransformation);
260 //______________________________________________________________________________
261 void AliMUONGeometryDetElement::PrintGlobalTransform() const
263 // Prints detection element global transformation
264 // (the transformation wrt global frame)
267 PrintTransform(fLocalTransformation);