]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONGeometryDetElement.cxx
Removing extrap.F (Christian)
[u/mrichter/AliRoot.git] / MUON / AliMUONGeometryDetElement.cxx
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 //
18 // Class AliMUONGeometryDetElement
19 // --------------------------------------
20 // The class defines the detection element.
21 //
22 // Author: Ivana Hrivnacova, IPN Orsay
23
24 #include <TGeoMatrix.h>
25 #include <Riostream.h>
26
27 #include "AliLog.h"
28
29 #include "AliMUONGeometryDetElement.h"
30
31 ClassImp(AliMUONGeometryDetElement)
32
33 //______________________________________________________________________________
34 AliMUONGeometryDetElement::AliMUONGeometryDetElement(
35                                         Int_t detElemId,
36                                         const TString& alignedVolume, 
37                                         const TGeoCombiTrans& relTransform)
38  : TObject(),
39    fAlignedVolume(alignedVolume),
40    fLocalTransformation(0),
41    fGlobalTransformation(0)
42
43 // Standard constructor
44
45   SetUniqueID(detElemId);
46   fLocalTransformation = new TGeoCombiTrans(relTransform);
47 }
48
49 //______________________________________________________________________________
50 AliMUONGeometryDetElement::AliMUONGeometryDetElement()
51  : TObject(),
52    fAlignedVolume(),
53    fLocalTransformation(0),
54    fGlobalTransformation(0)
55 {
56 // Default constructor
57 }
58
59 //______________________________________________________________________________
60 AliMUONGeometryDetElement::AliMUONGeometryDetElement(
61                                    const AliMUONGeometryDetElement& rhs)
62   : TObject(rhs)
63 {
64   AliFatal("Copy constructor is not implemented.");
65 }
66
67 //______________________________________________________________________________
68 AliMUONGeometryDetElement::~AliMUONGeometryDetElement() {
69 //
70   delete fLocalTransformation;
71   delete fGlobalTransformation;
72 }
73
74 //______________________________________________________________________________
75 AliMUONGeometryDetElement& 
76 AliMUONGeometryDetElement::operator = (const AliMUONGeometryDetElement& rhs) 
77 {
78   // check assignement to self
79   if (this == &rhs) return *this;
80
81   AliFatal("Assignment operator is not implemented.");
82     
83   return *this;  
84 }
85
86 //
87 // private methods
88 //
89
90 //______________________________________________________________________________
91 void  AliMUONGeometryDetElement::PrintTransform(
92                                             const TGeoCombiTrans* transform) const
93 {
94 // Prints the detection element transformation
95 // ---
96
97   cout << "DetElemId: " << GetUniqueID();
98   cout << "  name: " << fAlignedVolume << endl;
99
100   const double* translation = transform->GetTranslation();
101   cout << "   translation: "
102 #if defined (__DECCXX)
103        << translation[0] << ", " 
104        << translation[1] << ", "
105        << translation[2] << endl;
106 #else
107        << std::fixed
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;
111 #endif
112          
113   const double* rotation = transform->GetRotationMatrix();
114   cout << "   rotation matrix:  "
115 #if defined (__DECCXX)
116        << rotation[0] << ", " << rotation[1] << ", " << rotation[2] << endl
117        << "                     "           
118        << rotation[3] << ", " << rotation[4] << ", " << rotation[5] << endl         
119        << "                     "           
120        << rotation[6] << ", " << rotation[7] << ", " << rotation[8] << endl;
121 #else
122        << std::fixed
123        << std::setw(7) << std::setprecision(4) 
124        << rotation[0] << ", " << rotation[1] << ", " << rotation[2] << endl
125        << "                     "           
126        << rotation[3] << ", " << rotation[4] << ", " << rotation[5] << endl         
127        << "                     "           
128        << rotation[6] << ", " << rotation[7] << ", " << rotation[8] << endl;
129 #endif
130 }     
131
132 //
133 // public methods
134 //
135
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
140 {
141 // Transforms point from the global reference frame (ALIC)
142 // to the local reference frame of the detection element specified
143 // by detElemId.
144 // ---
145
146   Double_t dxg = xg;
147   Double_t dyg = yg;
148   Double_t dzg = zg;
149
150   Double_t dxl, dyl, dzl;
151   Global2Local(dxg, dyg, dzg, dxl, dyl, dzl);  
152   
153   xl = dxl;
154   yl = dyl;
155   zl = dzl;
156 }
157                                   
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
162 {
163 // Transforms point from the global reference frame (ALIC)
164 // to the local reference frame of the detection element specified
165 // by detElemId.
166 // ---
167
168    // Check transformation
169    if (!fGlobalTransformation) {
170      AliError(Form("Global transformation for detection element %d not defined.",
171                     GetUniqueID()));
172      return;
173    }  
174    
175    // Transform point 
176    Double_t pg[3] = { xg, yg, zg };
177    Double_t pl[3] = { 0., 0., 0. };
178    fGlobalTransformation->MasterToLocal(pg, pl);
179    
180    // Return transformed point
181    xl = pl[0];
182    yl = pl[1];     
183    zl = pl[2];  
184 }
185                                   
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
190 {
191 // Transforms point from the local reference frame of the detection element 
192 // specified by detElemId to the global reference frame (ALIC).
193 // ---
194
195   Double_t dxl = xl;
196   Double_t dyl = yl;
197   Double_t dzl = zl;
198
199   Double_t dxg, dyg, dzg;
200   Local2Global(dxl, dyl, dzl, dxg, dyg, dzg);  
201   
202   xg = dxg;
203   yg = dyg;
204   zg = dzg;
205 }
206
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
211 {
212 // Transforms point from the local reference frame of the detection element 
213 // specified by detElemId to the global reference frame (ALIC).
214 // ---
215
216    // Check transformation
217    if (!fGlobalTransformation) {
218      AliError(Form("Global transformation for detection element %d not defined.",
219                     GetUniqueID()));
220      return;
221    }  
222    
223    // Transform point 
224    Double_t pl[3] = { xl, yl, zl };
225    Double_t pg[3] = { 0., 0., 0. };
226    fGlobalTransformation->LocalToMaster(pl, pg);
227    
228    // Return transformed point
229    xg = pg[0];
230    yg = pg[1];     
231    zg = pg[2];  
232 }
233
234 //______________________________________________________________________________
235 void AliMUONGeometryDetElement::SetGlobalTransformation(
236                                                 const TGeoCombiTrans& transform)
237
238 // Sets global transformation;
239 // gives warning if the global transformation is already defined.
240 // ---
241  
242   if (fGlobalTransformation) {
243     delete fGlobalTransformation;
244     AliWarning("Global transformation already defined was deleted.");
245   }  
246
247   fGlobalTransformation = new TGeoCombiTrans(transform);
248 }  
249                                               
250 //______________________________________________________________________________
251 void AliMUONGeometryDetElement::PrintLocalTransform() const
252 {
253 // Prints detection element relative transformation
254 // (the transformation wrt module frame)
255 //
256
257   PrintTransform(fLocalTransformation);
258 }  
259
260 //______________________________________________________________________________
261 void AliMUONGeometryDetElement::PrintGlobalTransform() const
262 {
263 // Prints detection element global transformation
264 // (the transformation wrt global frame)
265 //
266
267   PrintTransform(fLocalTransformation);
268 }