]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSgeom.h
Added some include files. Needed due to new forward declorations in other
[u/mrichter/AliRoot.git] / ITS / AliITSgeom.h
CommitLineData
b79e4bc3 1#ifndef ALIITSGEOM_H
2#define ALIITSGEOM_H
3da30618 3/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
5
6/* $Id$ */
7
58005f18 8/////////////////////////////////////////////////////////////////////////
9// ITS geometry manipulation routines.
10// Created April 15 1999.
11// version: 0.0.0
12// By: Bjorn S. Nilsen
13//
14// A package of geometry routines to do transformations between
15// local, detector active area, and ALICE global coordinate system in such
16// a way as to allow for detector alignment studies and the like. All of
17// the information needed to do the coordinate transformation are kept in
18// a specialized structure for ease of implementation.
19/////////////////////////////////////////////////////////////////////////
5c9c741e 20#include <iostream.h>
5cf7bbad 21#include <fstream.h>
e8189707 22#include <TObjArray.h>
23#include <TVector.h>
24
269f57ed 25#include "AliITSgeomMatrix.h"
58005f18 26
8253cd9a 27
5c9c741e 28typedef enum {kSPD=0, kSDD=1, kSSD=2, kSSDp=3,kSDDp=4} AliITSDetector;
58005f18 29
30//_______________________________________________________________________
31
32class AliITSgeom : public TObject {
b79e4bc3 33
58005f18 34 public:
269f57ed 35 AliITSgeom(); // Default constructor
36 AliITSgeom(const char *filename); // Constructor
8253cd9a 37 AliITSgeom(Int_t itype,Int_t nlayers,Int_t *nlads,Int_t *ndets,
38 Int_t nmods); // Constructor
39 // this function allocates a AliITSgeomMatrix for a particular
40 // module.
41 void CreatMatrix(Int_t mod,Int_t lay,Int_t lad,Int_t det,
42 AliITSDetector idet,Double_t tran[3],Double_t rot[10]);
43 void ReadNewFile(const char *filename); // Constructor for new format.
44 void WriteNewFile(const char *filename); // Output for new format.
269f57ed 45 AliITSgeom(AliITSgeom &source); // Copy constructor
46 void operator=(AliITSgeom &source);// = operator
47 virtual ~AliITSgeom(); // Default destructor
48// Getters
49 Int_t GetTransformationType() const {return fTrans;}
50//
8253cd9a 51 // returns kTRUE if the tranformation defined by this class is
52 // for Global Geant coordiante system to the local Geant coordinate system
53 // of the detector. These are the transformation used by GEANT.
269f57ed 54 Bool_t IsGeantToGeant() const {return (fTrans == 0);}
8253cd9a 55 // returns kTRUE if the tranformation defined by this class is
56 // for Global Geant coordiante system to the local "Tracking" coordinate
57 // system of the detector. These are the transformation used by the
58 // Tracking code.
269f57ed 59 Bool_t IsGeantToTracking() const {return ((fTrans&&0xfffe)!= 0);}
8253cd9a 60 // returns kTRUE if the tranformation defined by this class is
61 // for Global Geant coordiante system to the local Geant coordinate system
62 // of the detector but may have been displaced by some typicaly small
63 // abount. These are modified transformation simular to that used by GEANT.
269f57ed 64 Bool_t IsGeantToDisplaced() const {return ((fTrans&&0xfffd)!= 0);}
8253cd9a 65 // returns kTRUE if the shape defined by ishape has been defined in this
66 // set of transformations. Typical values of ishape are kSPD, kSDD, kSSD,
67 // SSD2.
68 Bool_t IsShapeDefined(Int_t ishape){
5c9c741e 69 if(fShape!=0){return ((fShape->At(ishape))!=0);}else return kFALSE;}
269f57ed 70//
8253cd9a 71 // This function returns a pointer to the particular AliITSgeomMatrix
72 // class for a specific module index.
73 AliITSgeomMatrix *GetGeomMatrix(Int_t index){
74 return (AliITSgeomMatrix*)(fGm->At(index));}
269f57ed 75 // This function returns the number of detectors/ladder for a give
76 // layer. In particular it returns fNdet[layer-1].
77 Int_t GetNdetectors(const Int_t lay) const {return fNdet[lay-1];}
78 // This function returns the number of ladders for a give layer. In
79 // particular it returns fNlad[layer-1].
80 Int_t GetNladders(const Int_t lay) const {return fNlad[lay-1];}
81 // This function returns the number of layers defined in the ITS
82 // geometry. In particular it returns fNlayers.
83 Int_t GetNlayers() const {return fNlayers;}
84 Int_t GetModuleIndex(const Int_t lay,const Int_t lad,const Int_t det);
85 // This function returns the module index number given the layer,
86 // ladder and detector numbers put into the array id[3].
87 Int_t GetModuleIndex(const Int_t *id){
88 return GetModuleIndex(id[0],id[1],id[2]);}
89 void GetModuleId(const Int_t index,Int_t &lay,Int_t &lad,Int_t &det);
90//
91 Int_t GetStartDet(const Int_t dtype );
92 Int_t GetLastDet(const Int_t dtype);
93 // Returns the starting module index number for SPD detector,
94 // assuming the modules are placed in the "standard" cylindrical
95 // ITS structure.
96 Int_t GetStartSPD() {return GetModuleIndex(1,1,1);}
97 // Returns the ending module index number for SPD detector,
98 // assuming the modules are placed in the "standard" cylindrical
99 // ITS structure.
100 Int_t GetLastSPD() {return GetModuleIndex(2,fNlad[1],fNdet[1]);}
101 // Returns the starting module index number for SDD detector,
102 // assuming the modules are placed in the "standard" cylindrical
103 // ITS structure.
104 Int_t GetStartSDD() {return GetModuleIndex(3,1,1);}
105 // Returns the ending module index number for SDD detector,
106 // assuming the modules are placed in the "standard" cylindrical
107 // ITS structure.
108 Int_t GetLastSDD() {return GetModuleIndex(4,fNlad[3],fNdet[3]);}
109 // Returns the starting module index number for SSD detector,
110 // assuming the modules are placed in the "standard" cylindrical
111 // ITS structure.
112 Int_t GetStartSSD() {return GetModuleIndex(5,1,1);}
113 // Returns the ending module index number for SSD detector,
114 // assuming the modules are placed in the "standard" cylindrical
115 // ITS structure.
116 Int_t GetLastSSD() {return GetModuleIndex(6,fNlad[5],fNdet[5]);}
117 // Returns the last module index number.
118 Int_t GetIndexMax() {return fNmodules;}
119//
120 // This function returns the rotation angles for a give module
121 // in the Double point array ang[3]. The angles are in radians
122 void GetAngles(const Int_t index,Double_t *ang) {
8253cd9a 123 GetGeomMatrix(index)->GetAngles(ang);}
269f57ed 124 // This function returns the rotation angles for a give module
125 // in the three floating point variables provided. rx = frx,
126 // fy = fry, rz = frz. The angles are in radians
127 void GetAngles(const Int_t index,Float_t &rx,Float_t &ry,Float_t &rz) {
128 Double_t a[3];GetAngles(index,a);
129 rx = a[0];ry = a[1];rz = a[2];}
130 // This function returns the rotation angles for a give detector on
131 // a give ladder in a give layer in the three floating point variables
132 // provided. rx = frx, fy = fry, rz = frz. The angles are in radians
133 void GetAngles(const Int_t lay,const Int_t lad,const Int_t det,
134 Float_t &rx,Float_t &ry,Float_t &rz) {
135 GetAngles(GetModuleIndex(lay,lad,det),rx,ry,rz);}
136//
137 // This function returns the 6 GEANT rotation angles for a give
138 // module in the double point array ang[3]. The angles are in degrees
139 void GetGeantAngles(const Int_t index,Double_t *ang){
8253cd9a 140 GetGeomMatrix(index)->SixAnglesFromMatrix(ang);}
269f57ed 141//
142 // This function returns the Cartesian translation for a give
143 // module in the Double array t[3]. The units are
144 // those of the Monte Carlo, generally cm.
145 void GetTrans(const Int_t index,Double_t *t) {
8253cd9a 146 GetGeomMatrix(index)->GetTranslation(t);}
269f57ed 147 // This function returns the Cartesian translation for a give
148 // module index in the three floating point variables provided.
149 // x = fx0, y = fy0, z = fz0. The units are those of the Mont
150 // Carlo, generally cm.
151 void GetTrans(const Int_t index,Float_t &x,Float_t &y,Float_t &z) {
152 Double_t t[3];GetTrans(index,t);
153 x = t[0];y = t[1];z = t[2];}
154 // This function returns the Cartesian translation for a give
155 // detector on a give ladder in a give layer in the three floating
156 // point variables provided. x = fx0, y = fy0, z = fz0. The units are
157 // those of the Monte Carlo, generally cm.
158 void GetTrans(const Int_t lay,const Int_t lad,const Int_t det,
159 Float_t &x,Float_t &y,Float_t &z) {
160 GetTrans(GetModuleIndex(lay,lad,det),x,y,z);}
d8cc8493 161//
162 // This function returns the Cartesian translation for a give
163 // module in the Double array t[3]. The units are
164 // those of the Monte Carlo, generally cm.
165 void GetTransCyln(const Int_t index,Double_t *t) {
166 GetGeomMatrix(index)->GetTranslationCylinderical(t);}
167 // This function returns the Cartesian translation for a give
168 // module index in the three floating point variables provided.
169 // x = fx0, y = fy0, z = fz0. The units are those of the Mont
170 // Carlo, generally cm.
171 void GetTransCyln(const Int_t index,Float_t &x,Float_t &y,Float_t &z) {
172 Double_t t[3];GetTransCyln(index,t);
173 x = t[0];y = t[1];z = t[2];}
174 // This function returns the Cartesian translation for a give
175 // detector on a give ladder in a give layer in the three floating
176 // point variables provided. x = fx0, y = fy0, z = fz0. The units are
177 // those of the Monte Carlo, generally cm.
178 void GetTransCyln(const Int_t lay,const Int_t lad,const Int_t det,
179 Float_t &x,Float_t &y,Float_t &z) {
180 GetTransCyln(GetModuleIndex(lay,lad,det),x,y,z);}
269f57ed 181//
182 // This function returns the Cartesian translation [cm] and the
183 // 6 GEANT rotation angles [degrees]for a given layer ladder and
184 // detector number, in the TVector x (at least 9 elements large).
185 void GetCenterThetaPhi(const Int_t lay,const Int_t lad,const Int_t det,
186 TVector &x){Double_t t[3],ang[6];
187 Int_t index=GetModuleIndex(lay,lad,det);
188 GetTrans(index,t);GetGeantAngles(index,ang);
189 x(0) = t[0];x(1) = t[1];x(2) = t[2];
190 x(3) = ang[0];x(4) = ang[1];x(5) = ang[2];
191 x(6) = ang[3];x(7) = ang[4];x(8) = ang[5];}
192//
193 // This function returns the rotation matrix in Double
194 // precision for a given module.
195 void GetRotMatrix(const Int_t index,Double_t mat[3][3]){
8253cd9a 196 GetGeomMatrix(index)->GetMatrix(mat);}
269f57ed 197 // This function returns the rotation matrix in a Double
198 // precision pointer for a given module. mat[i][j] => mat[3*i+j].
199 void GetRotMatrix(const Int_t index,Double_t *mat){
200 Double_t rot[3][3];GetRotMatrix(index,rot);
201 for(Int_t i=0;i<3;i++)for(Int_t j=0;j<3;j++) mat[3*i+j] = rot[i][j];}
202 // This function returns the rotation matrix in a floating
203 // precision pointer for a given layer ladder and detector module.
204 // mat[i][j] => mat[3*i+j].
205 void GetRotMatrix(const Int_t lay,const Int_t lad,const Int_t det,
206 Float_t *mat){GetRotMatrix(GetModuleIndex(lay,lad,det),mat);}
207 // This function returns the rotation matrix in a Double
208 // precision pointer for a given layer ladder and detector module.
209 // mat[i][j] => mat[3*i+j].
210 void GetRotMatrix(const Int_t lay,const Int_t lad,const Int_t det,
211 Double_t *mat){GetRotMatrix(GetModuleIndex(lay,lad,det),mat);}
212 // This function returns the rotation matrix in a floating
213 // precision pointer for a given module. mat[i][j] => mat[3*i+j].
214 void GetRotMatrix(const Int_t index,Float_t *mat){
8253cd9a 215 Double_t rot[3][3];
216 GetGeomMatrix(index)->GetMatrix(rot);
269f57ed 217 for(Int_t i=0;i<3;i++)for(Int_t j=0;j<3;j++) mat[3*i+j] = rot[i][j];}
218//
8253cd9a 219 // Will define fShape if it isn't already defined.
220 void DefineShapes(const Int_t size=4)
221 {if(fShape==0) fShape = new TObjArray(size);else fShape->Expand(size);}
222 // this function returns a pointer to the class decribing a particluar
223 // detectory type based on AliITSDetector value. This will return a pointer
224 // to one of the classes AliITSgeomSPD, AliITSgeomSDD, or AliITSgeomSSD,
225 // for example.
226 virtual TObject *GetShape(const AliITSDetector idet)
227 {return fShape->At((Int_t)idet);};
269f57ed 228 // This function returns a pointer to the class describing the
229 // detector for a particular module index. This will return a pointer
230 // to one of the classes AliITSgeomSPD, AliITSgeomSDD, or AliITSgeomSSD,
231 // for example.
8253cd9a 232 virtual TObject *GetShape(const Int_t index){
233 return fShape->At(GetGeomMatrix(index)->
234 GetDetectorIndex());}
269f57ed 235 // This function returns a pointer to the class describing the
236 // detector for a particular layer ladder and detector numbers. This
237 // will return a pointer to one of the classes AliITSgeomSPD,
238 // AliITSgeomSDD, or AliITSgeomSSD, for example.
239 virtual TObject *GetShape(const Int_t lay,const Int_t lad,const Int_t det)
240 {return GetShape(GetModuleIndex(lay,lad,det));}
269f57ed 241//
242// Setters
243 // Sets the rotation angles and matrix for a give module index
244 // via the double precision array a[3] [radians].
245 void SetByAngles(const Int_t index,const Double_t a[]){
8253cd9a 246 GetGeomMatrix(index)->SetAngles(a);}
269f57ed 247 // Sets the rotation angles and matrix for a give module index
248 // via the 3 floating precision variables rx, ry, and rz [radians].
249 void SetByAngles(const Int_t index,
250 const Float_t rx,const Float_t ry,const Float_t rz) {
251 Double_t a[3];a[0] = rx;a[1] = ry;a[2] = rz;
8253cd9a 252 GetGeomMatrix(index)->SetAngles(a);}
269f57ed 253 // Sets the rotation angles and matrix for a give layer, ladder,
254 // and detector numbers via the 3 floating precision variables rx,
255 // ry, and rz [radians].
256 void SetByAngles(const Int_t lay,const Int_t lad,const Int_t det,
257 const Float_t rx,const Float_t ry,const Float_t rz) {
258 SetByAngles(GetModuleIndex(lay,lad,det),rx,ry,rz);}
259//
260 // Sets the rotation angles and matrix for a give module index
261 // via the Double precision array a[6] [degree]. The angles are those
262 // defined by GEANT 3.12.
263 void SetByGeantAngles(const Int_t index,const Double_t *ang){
8253cd9a 264 GetGeomMatrix(index)->MatrixFromSixAngles(ang);}
269f57ed 265 // Sets the rotation angles and matrix for a give layer, ladder
266 // and detector, in the array id[3] via the Double precision array
267 // a[6] [degree]. The angles are those defined by GEANT 3.12.
268 void SetByGeantAngles(const Int_t *id,const Double_t *ang){
269 SetByGeantAngles(GetModuleIndex(id),ang);}
270 // Sets the rotation angles and matrix for a give layer, ladder
271 // and detector, via the Double precision array a[6] [degree]. The
272 // angles are those defined by GEANT 3.12.
273 void SetByGeantAngles(const Int_t lay,const Int_t lad,const Int_t det,
274 const Double_t *ang){
275 SetByGeantAngles(GetModuleIndex(lay,lad,det),ang);}
276//
277 // This function sets a new translation vector, given by the
278 // array x[3], for the Cartesian coordinate transformation
279 // for a give module index.
280 void SetTrans(const Int_t index,Double_t x[]){
8253cd9a 281 GetGeomMatrix(index)->SetTranslation(x);}
269f57ed 282 // This function sets a new translation vector, given by the three
283 // variables x, y, and z, for the Cartesian coordinate transformation
284 // for the detector defined by layer, ladder and detector.
285 void SetTrans(const Int_t lay,const Int_t lad,const Int_t det,
286 Float_t x,Float_t y,Float_t z){Double_t t[3];
287 t[0] = x;t[1] = y;t[2] = z;
288 SetTrans(GetModuleIndex(lay,lad,det),t);}
289//
290 // This function adds one more shape element to the TObjArray
291 // fShape. It is primarily used in the constructor functions of the
292 // AliITSgeom class. The pointer *shape can be the pointer to any
293 // class that is derived from TObject (this is true for nearly every
294 // ROOT class). This does not appear to be working properly at this time.
295 void AddShape(TObject *shp){fShape->AddLast(shp);}
296 // This function deletes an existing shape element, of type TObject,
297 // and replaces it with the one specified. This is primarily used to
298 // changes the parameters to the segmentation class for a particular
299 // type of detector.
300 void ReSetShape(const Int_t dtype,TObject *shp){
301 fShape->RemoveAt(dtype);fShape->AddAt(shp,dtype);}
302//
303// transformations
304 // Transforms from the ALICE Global coordinate system
305 // to the detector local coordinate system for the detector
306 // defined by the layer, ladder, and detector numbers. The
307 // global and local coordinate are given in two floating point
308 // arrays g[3], and l[3].
309 void GtoL(const Int_t lay,const Int_t lad,const Int_t det,
310 const Float_t *g,Float_t *l){
311 GtoL(GetModuleIndex(lay,lad,det),g,l);}
312 // Transforms from the ALICE Global coordinate system
313 // to the detector local coordinate system for the detector
314 // defined by the id[0], id[1], and id[2] numbers. The
315 // global and local coordinate are given in two floating point
316 // arrays g[3], and l[3].
317 void GtoL(const Int_t *id,const Float_t *g,Float_t *l){
318 GtoL(GetModuleIndex(id),g,l);}
319 // Transforms from the ALICE Global coordinate system
320 // to the detector local coordinate system for the detector
321 // module index number. The global and local coordinate are
322 // given in two floating point arrays g[3], and l[3].
323 void GtoL(const Int_t index,const Float_t *g,Float_t *l){
d962cab4 324 Double_t dg[3],dl[3];Int_t i;for(i=0;i<3;i++) dg[i] = g[i];
8253cd9a 325 GetGeomMatrix(index)->GtoLPosition(dg,dl);
d962cab4 326 for(i=0;i<3;i++) l[i] =dl[i];}
269f57ed 327 // Transforms from the ALICE Global coordinate system
328 // to the detector local coordinate system for the detector
329 // defined by the layer, ladder, and detector numbers. The
330 // global and local coordinate are given in two Double point
331 // arrays g[3], and l[3].
332 void GtoL(const Int_t lay,const Int_t lad,const Int_t det,
333 const Double_t *g,Double_t *l){
334 GtoL(GetModuleIndex(lay,lad,det),g,l);}
335 // Transforms from the ALICE Global coordinate system
336 // to the detector local coordinate system for the detector
337 // defined by the id[0], id[1], and id[2] numbers. The
338 // global and local coordinate are given in two Double point
339 // arrays g[3], and l[3].
340 void GtoL(const Int_t *id,const Double_t *g,Double_t *l){
341 GtoL(GetModuleIndex(id),g,l);}
342 // Transforms from the ALICE Global coordinate system
343 // to the detector local coordinate system for the detector
344 // module index number. The global and local coordinate are
345 // given in two Double point arrays g[3], and l[3].
346 void GtoL(const Int_t index,const Double_t *g,Double_t *l){
d962cab4 347 Double_t dg[3],dl[3];Int_t i;for(i=0;i<3;i++) dg[i] = g[i];
8253cd9a 348 GetGeomMatrix(index)->GtoLPosition(dg,dl);
d962cab4 349 for(i=0;i<3;i++) l[i] =dl[i];}
269f57ed 350//
351 // Transforms from the ALICE Global coordinate system
352 // to the detector local coordinate system (used for ITS tracking)
353 // for the detector module index number. The global and local
354 // coordinate are given in two Double point arrays g[3], and l[3].
355 void GtoLtracking(const Int_t index,const Double_t *g,Double_t *l){
356 if(IsGeantToTracking()) GtoL(index,g,l);
8253cd9a 357 else GetGeomMatrix(index)->GtoLPositionTracking(g,l);}
269f57ed 358 // Transforms from the ALICE Global coordinate system
359 // to the detector local coordinate system (used for ITS tracking)
360 // for the detector id[3]. The global and local
361 // coordinate are given in two Double point arrays g[3], and l[3].
362 void GtoLtracking(const Int_t *id,const Double_t *g,Double_t *l){
363 GtoLtracking(GetModuleIndex(id),g,l);}
364 // Transforms from the ALICE Global coordinate system
365 // to the detector local coordinate system (used for ITS tracking)
366 // for the detector layer ladder and detector numbers. The global
367 // and local coordinate are given in two Double point arrays g[3],
368 // and l[3].
369 void GtoLtracking(const Int_t lay,const Int_t lad,const Int_t det,
370 const Double_t *g,Double_t *l){
371 GtoLtracking(GetModuleIndex(lay,lad,det),g,l);}
372//
373 // Transforms of momentum types of quantities from the ALICE
374 // Global coordinate system to the detector local coordinate system
375 // for the detector layer ladder and detector numbers. The global
376 // and local coordinate are given in two float point arrays g[3],
377 // and l[3].
378 void GtoLMomentum(const Int_t lay,const Int_t lad,const Int_t det,
379 const Float_t *g,Float_t *l){
380 GtoLMomentum(GetModuleIndex(lay,lad,det),g,l);}
381 // Transforms of momentum types of quantities from the ALICE
382 // Global coordinate system to the detector local coordinate system
383 // for the detector module index number. The global and local
384 // coordinate are given in two float point arrays g[3], and l[3].
385 void GtoLMomentum(const Int_t index,const Float_t *g,Float_t *l){
d962cab4 386 Double_t dg[3],dl[3];Int_t i;for(i=0;i<3;i++) dg[i] = g[i];
8253cd9a 387 GetGeomMatrix(index)->GtoLMomentum(dg,dl);
d962cab4 388 for(i=0;i<3;i++) l[i] =dl[i];}
269f57ed 389 // Transforms of momentum types of quantities from the ALICE
390 // Global coordinate system to the detector local coordinate system
391 // for the detector layer ladder and detector numbers. The global
392 // and local coordinate are given in two Double point arrays g[3],
393 // and l[3].
394 void GtoLMomentum(const Int_t lay,const Int_t lad,const Int_t det,
395 const Double_t *g,Double_t *l){
396 GtoLMomentum(GetModuleIndex(lay,lad,det),g,l);}
397 // Transforms of momentum types of quantities from the ALICE
398 // Global coordinate system to the detector local coordinate system
399 // for the detector module index number. The global and local
400 // coordinate are given in two Double point arrays g[3], and l[3].
401 void GtoLMomentum(const Int_t index,const Double_t *g,Double_t *l){
d962cab4 402 Double_t dg[3],dl[3];Int_t i;for(i=0;i<3;i++) dg[i] = g[i];
8253cd9a 403 GetGeomMatrix(index)->GtoLMomentum(dg,dl);
d962cab4 404 for(i=0;i<3;i++) l[i] =dl[i];}
269f57ed 405//
406 // Transforms of momentum types of quantities from the ALICE
407 // Global coordinate system to the detector local coordinate system
408 // (used for ITS tracking) for the detector module index number.
409 // The global and local coordinate are given in two Double point
410 // arrays g[3], and l[3].
411 void GtoLMomentumTracking(const Int_t index,const Double_t *g,Double_t *l){
412 if(IsGeantToTracking()) GtoLMomentum(index,g,l);
8253cd9a 413 else GetGeomMatrix(index)->GtoLMomentumTracking(g,l);}
269f57ed 414 // Transforms of momentum types of quantities from the ALICE
415 // Global coordinate system to the detector local coordinate system
416 // (used for ITS tracking) for the detector id[3].
417 // The global and local coordinate are given in two Double point
418 // arrays g[3], and l[3].
419 void GtoLMomentumTracking(const Int_t *id,const Double_t *g,Double_t *l){
420 GtoLMomentumTracking(GetModuleIndex(id),g,l);}
421 // Transforms of momentum types of quantities from the ALICE
422 // Global coordinate system to the detector local coordinate system
423 // (used for ITS tracking) for the detector layer ladder and detector
424 // numbers. The global and local coordinate are given in two Double point
425 // arrays g[3], and l[3].
426 void GtoLMomentumTracking(const Int_t lay,const Int_t lad,const Int_t det,
427 const Double_t *g,Double_t *l){
428 GtoLMomentumTracking(GetModuleIndex(lay,lad,det),g,l);}
429//
430 // Transforms from the detector local coordinate system
431 // to the ALICE Global coordinate system for the detector
432 // defined by the layer, ladder, and detector numbers. The
433 // global and local coordinate are given in two floating point
434 // arrays g[3], and l[3].
435 void LtoG(const Int_t lay,const Int_t lad,const Int_t det,
436 const Float_t *l,Float_t *g){
437 LtoG(GetModuleIndex(lay,lad,det),l,g);}
438 // Transforms from the detector local coordinate system
439 // to the ALICE Global coordinate system for the detector
440 // defined by the id[0], id[1], and id[2] numbers. The
441 // global and local coordinate are given in two floating point
442 // arrays g[3], and l[3].
443 void LtoG(const Int_t *id,const Float_t *l,Float_t *g){
444 LtoG(GetModuleIndex(id),l,g);}
445 // Transforms from the detector local coordinate system
446 // to the ALICE Global coordinate system for the detector
447 // module index number. The global and local coordinate are
448 // given in two floating point arrays g[3], and l[3].
449 void LtoG(const Int_t index,const Float_t *l,Float_t *g){
d962cab4 450 Double_t dg[3],dl[3];Int_t i;for(i=0;i<3;i++) dl[i] = l[i];
8253cd9a 451 GetGeomMatrix(index)->LtoGPosition(dl,dg);
d962cab4 452 for(i=0;i<3;i++) g[i] =dg[i];}
269f57ed 453 // Transforms from the detector local coordinate system
454 // to the ALICE Global coordinate system for the detector
455 // defined by the layer, ladder, and detector numbers. The
456 // global and local coordinate are given in two Double point
457 // arrays g[3], and l[3].
458 void LtoG(const Int_t lay,const Int_t lad,const Int_t det,
459 const Double_t *l,Double_t *g){
460 LtoG(GetModuleIndex(lay,lad,det),l,g);}
461 // Transforms from the detector local coordinate system
462 // to the ALICE Global coordinate system for the detector
463 // defined by the id[0], id[1], and id[2] numbers. The
464 // global and local coordinate are given in two Double point
465 // arrays g[3], and l[3].
466 void LtoG(const Int_t *id,const Double_t *l,Double_t *g){
467 LtoG(GetModuleIndex(id),l,g);}
468 // Transforms from the detector local coordinate system
469 // to the ALICE Global coordinate system for the detector
470 // module index number. The global and local coordinate are
471 // given in two Double point arrays g[3], and l[3].
472 void LtoG(const Int_t index,const Double_t *l,Double_t *g){
d962cab4 473 Double_t dg[3],dl[3];Int_t i;for(i=0;i<3;i++) dl[i] = l[i];
8253cd9a 474 GetGeomMatrix(index)->LtoGPosition(dl,dg);
d962cab4 475 for(i=0;i<3;i++) g[i] =dg[i];}
269f57ed 476//
477 // Transforms from the detector local coordinate system (used
478 // for ITS tracking) to the ALICE Global coordinate system
479 // for the detector module index number. The global and local
480 // coordinate are given in two Double point arrays g[3], and l[3].
481 void LtoGtracking(const Int_t index,const Double_t *l,Double_t *g){
482 if(IsGeantToTracking()) LtoG(index,l,g);
8253cd9a 483 else GetGeomMatrix(index)->LtoGPositionTracking(l,g);}
269f57ed 484 // Transforms from the detector local coordinate system (used
485 // for ITS tracking) to the ALICE Global coordinate system
486 // for the detector id[3]. The global and local
487 // coordinate are given in two Double point arrays g[3], and l[3].
488 void LtoGtracking(const Int_t *id,const Double_t *l,Double_t *g){
489 LtoGtracking(GetModuleIndex(id),l,g);}
490 // Transforms from the detector local coordinate system (used
491 // for ITS tracking) to the detector local coordinate system
492 // for the detector layer ladder and detector numbers. The global
493 // and local coordinate are given in two Double point arrays g[3],
494 // and l[3].
495 void LtoGtracking(const Int_t lay,const Int_t lad,const Int_t det,
496 const Double_t *l,Double_t *g){
497 LtoGtracking(GetModuleIndex(lay,lad,det),l,g);}
498//
499 // Transforms of momentum types of quantities from the detector
500 // local coordinate system to the ALICE Global coordinate system
501 // for the detector layer ladder and detector numbers. The global
502 // and local coordinate are given in two float point arrays g[3],
503 // and l[3].
504 void LtoGMomentum(const Int_t lay,const Int_t lad,const Int_t det,
505 const Float_t *l,Float_t *g){
506 LtoGMomentum(GetModuleIndex(lay,lad,det),l,g);}
507 // Transforms of momentum types of quantities from the detector
508 // local coordinate system to the ALICE Global coordinate system
509 // for the detector module index number. The global and local
510 // coordinate are given in two float point arrays g[3], and l[3].
511 void LtoGMomentum(const Int_t index,const Float_t *l,Float_t *g){
d962cab4 512 Double_t dg[3],dl[3];Int_t i;for(i=0;i<3;i++) dl[i] = l[i];
8253cd9a 513 GetGeomMatrix(index)->LtoGMomentum(dl,dg);
d962cab4 514 for(i=0;i<3;i++) g[i] =dg[i];}
269f57ed 515 // Transforms of momentum types of quantities from the detector
516 // local coordinate system to the ALICE Global coordinate system
517 // for the detector layer ladder and detector numbers. The global
518 // and local coordinate are given in two Double point arrays g[3],
519 // and l[3].
520 void LtoGMomentum(const Int_t lay,const Int_t lad,const Int_t det,
521 const Double_t *l,Double_t *g){
522 LtoGMomentum(GetModuleIndex(lay,lad,det),l,g);}
523 // Transforms of momentum types of quantities from the detector
524 // local coordinate system to the ALICE Global coordinate system
525 // for the detector module index number. The global and local
526 // coordinate are given in two Double point arrays g[3], and l[3].
527 void LtoGMomentum(const Int_t index,const Double_t *l,Double_t *g){
8253cd9a 528 GetGeomMatrix(index)->LtoGMomentum(l,g);}
269f57ed 529//
530 // Transforms of momentum types of quantities from the detector
531 // local coordinate system (used for ITS tracking) to the detector
532 // system ALICE Global for the detector module index number.
533 // The global and local coordinate are given in two Double point
534 // arrays g[3], and l[3].
535 void LtoGMomentumTracking(const Int_t index,const Double_t *l,Double_t *g){
536 if(IsGeantToTracking()) LtoGMomentum(index,l,g);
8253cd9a 537 else GetGeomMatrix(index)->LtoGMomentumTracking(l,g);}
269f57ed 538 // Transforms of momentum types of quantities from the detector
539 // local coordinate system (used for ITS tracking) to the ALICE
540 // Global coordinate system for the detector id[3].
541 // The global and local coordinate are given in two Double point
542 // arrays g[3], and l[3].
543 void LtoGMomentumTracking(const Int_t *id,const Double_t *l,Double_t *g){
544 LtoGMomentumTracking(GetModuleIndex(id),l,g);}
545 // Transforms of momentum types of quantities from the detector
546 // local coordinate system (used for ITS tracking) to the ALICE
547 // Global coordinate system for the detector layer ladder and detector
548 // numbers. The global and local coordinate are given in two Double point
549 // arrays g[3], and l[3].
550 void LtoGMomentumTracking(const Int_t lay,const Int_t lad,const Int_t det,
551 const Double_t *l,Double_t *g){
552 LtoGMomentumTracking(GetModuleIndex(lay,lad,det),l,g);}
553//
554 // Transforms from one detector local coordinate system
555 // to another detector local coordinate system for the detector
556 // module index1 number to the detector module index2 number. The
557 // local coordinates are given in two Double point arrays l1[3],
558 // and l2[3].
559 void LtoL(const Int_t index1,const Int_t index2,Double_t *l1,Double_t *l2){
560 Double_t g[3]; LtoG(index1,l1,g);GtoL(index2,g,l2);}
561 // Transforms from one detector local coordinate system
562 // to another detector local coordinate system for the detector
563 // id1[3] to the detector id2[3]. The local coordinates are given
564 // in two Double point arrays l1[3], and l2[3].
565 void LtoL(const Int_t *id1,const Int_t *id2,Double_t *l1,Double_t *l2){
566 LtoL(GetModuleIndex(id1[0],id1[1],id1[2]),
567 GetModuleIndex(id2[0],id2[1],id2[2]),l1,l2);}
568//
569 // Transforms from one detector local coordinate system (used for
570 // ITS tracking) to another detector local coordinate system (used
571 // for ITS tracking) for the detector module index1 number to the
572 // detector module index2 number. The local coordinates are given
573 // in two Double point arrays l1[3], and l2[3].
574 void LtoLtracking(const Int_t index1,const Int_t index2,
575 Double_t *l1,Double_t *l2){
576 Double_t g[3]; LtoGtracking(index1,l1,g);GtoLtracking(index2,g,l2);}
577 // Transforms from one detector local coordinate system (used for
578 // ITS tracking) to another detector local coordinate system (used
579 // for ITS tracking) for the detector id1[3] to the detector id2[3].
580 // The local coordinates are given in two Double point arrays l1[3],
581 // and l2[3].
582 void LtoLtracking(const Int_t *id1,const Int_t *id2,
583 Double_t *l1,Double_t *l2){
584 LtoLtracking(GetModuleIndex(id1[0],id1[1],id1[2]),
585 GetModuleIndex(id2[0],id2[1],id2[2]),l1,l2);}
586//
587 // Transforms of momentum types of quantities from one detector
588 // local coordinate system to another detector local coordinate
589 // system for the detector module index1 number to the detector
590 // module index2 number. The local coordinates are given in two
591 // Double point arrays l1[3], and l2[3].
592 void LtoLMomentum(const Int_t index1,const Int_t index2,
593 const Double_t *l1,Double_t *l2){
594 Double_t g[3]; LtoGMomentum(index1,l1,g);GtoLMomentum(index2,g,l2);}
595 // Transforms of momentum types of quantities from one detector
596 // local coordinate system to another detector local coordinate
597 // system for the detector id1[3] to the detector id2[3]. The local
598 // coordinates are given in two Double point arrays l1[3], and l2[3].
b79e4bc3 599 void LtoLMomentum(const Int_t *id1,const Int_t *id2,
269f57ed 600 const Double_t *l1,Double_t *l2){
601 LtoLMomentum(GetModuleIndex(id1[0],id1[1],id1[2]),
602 GetModuleIndex(id2[0],id2[1],id2[2]),l1,l2);}
603//
604 // Transforms of momentum types of quantities from one detector
605 // local coordinate system (used by ITS tracking) to another detector
606 // local coordinate system (used by ITS tracking) for the detector
607 // module index1 number to the detector module index2 number. The
608 // local coordinates are given in two Double point arrays l1[3],
609 // and l2[3].
610 void LtoLMomentumTracking(const Int_t index1,const Int_t index2,
611 Double_t *l1,Double_t *l2){
612 Double_t g[3]; LtoGMomentumTracking(index1,l1,g);
613 GtoLMomentumTracking(index2,g,l2);}
614 // Transforms of momentum types of quantities from one detector
615 // local coordinate system (used by ITS tracking) to another detector
616 // local coordinate system (used by ITS tracking) for the detector
617 // id1[3] to the detector id2[3]. The local coordinates are given in
618 // two Double point arrays l1[3], and l2[3].
619 void LtoLMomentumTracking(const Int_t *id1,const Int_t *id2,
620 Double_t *l1,Double_t *l2){
621 LtoLMomentumTracking(GetModuleIndex(id1[0],id1[1],id1[2]),
622 GetModuleIndex(id2[0],id2[1],id2[2]),l1,l2);}
623//
624 // Transforms a matrix, like an Uncertainty or Error matrix from
625 // the ALICE Global coordinate system to a detector local coordinate
626 // system. The specific detector is determined by the module index
627 // number.
628 void GtoLErrorMatrix(const Int_t index,const Double_t **g,Double_t **l){
8253cd9a 629 GetGeomMatrix(index)->GtoLPositionError((Double_t (*)[3])g,(Double_t (*)[3])l);}
269f57ed 630//
631 // Transforms a matrix, like an Uncertainty or Error matrix from
632 // the ALICE Global coordinate system to a detector local coordinate
633 // system (used by ITS tracking). The specific detector is determined
634 // by the module index number.
635 void GtoLErrorMatrixTracking(const Int_t index,const Double_t **g,
636 Double_t **l){
8253cd9a 637 if(IsGeantToTracking()) GetGeomMatrix(index)->GtoLPositionError((
d962cab4 638 Double_t (*)[3])g,(Double_t (*)[3])l);
8253cd9a 639 else GetGeomMatrix(index)->GtoLPositionErrorTracking(
d962cab4 640 (Double_t (*)[3])g,(Double_t (*)[3])l);}
269f57ed 641//
642 // Transforms a matrix, like an Uncertainty or Error matrix from
643 // the detector local coordinate system to a ALICE Global coordinate
644 // system. The specific detector is determined by the module index
645 // number.
646 void LtoGErrorMatrix(const Int_t index,const Double_t **l,Double_t **g){
8253cd9a 647 GetGeomMatrix(index)->LtoGPositionError((Double_t (*)[3])l,(Double_t (*)[3])g);}
269f57ed 648//
649 // Transforms a matrix, like an Uncertainty or Error matrix from
650 // the detector local coordinate system (used by ITS tracking) to a
651 // ALICE Global coordinate system. The specific detector is determined
652 // by the module index number.
653 void LtoGErrorMatrixTracking(const Int_t index,const Double_t **l,
654 Double_t **g){
8253cd9a 655 if(IsGeantToTracking()) GetGeomMatrix(index)->LtoGPositionError((
d962cab4 656 Double_t (*)[3])g,(Double_t (*)[3])l);
8253cd9a 657 else GetGeomMatrix(index)->LtoGPositionErrorTracking((Double_t (*)[3])l,
d962cab4 658 (Double_t (*)[3])g);}
269f57ed 659//
660 // Transforms a matrix, like an Uncertainty or Error matrix from
661 // one detector local coordinate system to another detector local
662 // coordinate system. The specific detector is determined by the
663 // two module index number index1 and index2.
b79e4bc3 664 void LtoLErrorMatrix(const Int_t index1,const Int_t index2,
269f57ed 665 const Double_t **l1,Double_t **l2){
666 Double_t g[3][3];
667 LtoGErrorMatrix(index1,l1,(Double_t **)g);
668 GtoLErrorMatrix(index2,(const Double_t **)g,l2);}
669//
670 // Transforms a matrix, like an Uncertainty or Error matrix from
671 // one detector local coordinate system (used by ITS tracking) to
672 // another detector local coordinate system (used by ITS tracking).
673 // The specific detector is determined by the two module index number
674 // index1 and index2.
675 void LtoLErrorMatrixTraking(const Int_t index1,const Int_t index2,
676 const Double_t **l1,Double_t **l2){Double_t g[3][3];
677 LtoGErrorMatrixTracking(index1,l1,(Double_t **)g);
678 GtoLErrorMatrixTracking(index2,(const Double_t **)g,l2);}
679// Find Specific Modules
680 Int_t GetNearest(const Double_t g[3],const Int_t lay=0);
681 void GetNearest27(const Double_t g[3],Int_t n[27],const Int_t lay=0);
682 // Returns the distance [cm] between the point g[3] and the center of
683 // the detector/module specified by the the module index number.
684 Double_t Distance(const Int_t index,const Double_t g[3]){
8253cd9a 685 return TMath::Sqrt(GetGeomMatrix(index)->Distance2(g));}
269f57ed 686// Geometry manipulation
687 void GlobalChange(const Float_t *tran,const Float_t *rot);
688 void GlobalCylindericalChange(const Float_t *tran,const Float_t *rot);
689 void RandomChange(const Float_t *stran,const Float_t *srot);
690 void RandomCylindericalChange(const Float_t *stran,const Float_t *srot);
691 void GeantToTracking(AliITSgeom &source); // This converts the geometry
692// Other routines.
58005f18 693 void PrintComparison(FILE *fp,AliITSgeom *other);
269f57ed 694 void PrintData(FILE *fp,const Int_t lay,const Int_t lad,const Int_t det);
58005f18 695 ofstream &PrintGeom(ofstream &out);
696 ifstream &ReadGeom(ifstream &in);
e8189707 697
085bb6ed 698 private:
8253cd9a 699 char fVersion[20];// Transformation version.
700 Int_t fTrans; // Flag to keep track of which transformation
701 Int_t fNmodules;// The total number of modules
702 Int_t fNlayers; // The number of layers.
703 Int_t *fNlad; //[fNlayers] Array of the number of ladders/layer(layer)
704 Int_t *fNdet; //[fNlayers] Array of the number of detectors/ladder(layer)
705 TObjArray *fGm; // Structure of trans. and rotation.
706 TObjArray *fShape; // Array of shapes and detector information.
707
269f57ed 708 ClassDef(AliITSgeom,2) // ITS geometry class
58005f18 709};
710
711#endif