Set Reading of AliITSgeom data from Geant3 common blocks as the default and
[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);}
161//
162 // This function returns the Cartesian translation [cm] and the
163 // 6 GEANT rotation angles [degrees]for a given layer ladder and
164 // detector number, in the TVector x (at least 9 elements large).
165 void GetCenterThetaPhi(const Int_t lay,const Int_t lad,const Int_t det,
166 TVector &x){Double_t t[3],ang[6];
167 Int_t index=GetModuleIndex(lay,lad,det);
168 GetTrans(index,t);GetGeantAngles(index,ang);
169 x(0) = t[0];x(1) = t[1];x(2) = t[2];
170 x(3) = ang[0];x(4) = ang[1];x(5) = ang[2];
171 x(6) = ang[3];x(7) = ang[4];x(8) = ang[5];}
172//
173 // This function returns the rotation matrix in Double
174 // precision for a given module.
175 void GetRotMatrix(const Int_t index,Double_t mat[3][3]){
8253cd9a 176 GetGeomMatrix(index)->GetMatrix(mat);}
269f57ed 177 // This function returns the rotation matrix in a Double
178 // precision pointer for a given module. mat[i][j] => mat[3*i+j].
179 void GetRotMatrix(const Int_t index,Double_t *mat){
180 Double_t rot[3][3];GetRotMatrix(index,rot);
181 for(Int_t i=0;i<3;i++)for(Int_t j=0;j<3;j++) mat[3*i+j] = rot[i][j];}
182 // This function returns the rotation matrix in a floating
183 // precision pointer for a given layer ladder and detector module.
184 // mat[i][j] => mat[3*i+j].
185 void GetRotMatrix(const Int_t lay,const Int_t lad,const Int_t det,
186 Float_t *mat){GetRotMatrix(GetModuleIndex(lay,lad,det),mat);}
187 // This function returns the rotation matrix in a Double
188 // precision pointer for a given layer ladder and detector module.
189 // mat[i][j] => mat[3*i+j].
190 void GetRotMatrix(const Int_t lay,const Int_t lad,const Int_t det,
191 Double_t *mat){GetRotMatrix(GetModuleIndex(lay,lad,det),mat);}
192 // This function returns the rotation matrix in a floating
193 // precision pointer for a given module. mat[i][j] => mat[3*i+j].
194 void GetRotMatrix(const Int_t index,Float_t *mat){
8253cd9a 195 Double_t rot[3][3];
196 GetGeomMatrix(index)->GetMatrix(rot);
269f57ed 197 for(Int_t i=0;i<3;i++)for(Int_t j=0;j<3;j++) mat[3*i+j] = rot[i][j];}
198//
8253cd9a 199 // Will define fShape if it isn't already defined.
200 void DefineShapes(const Int_t size=4)
201 {if(fShape==0) fShape = new TObjArray(size);else fShape->Expand(size);}
202 // this function returns a pointer to the class decribing a particluar
203 // detectory type based on AliITSDetector value. This will return a pointer
204 // to one of the classes AliITSgeomSPD, AliITSgeomSDD, or AliITSgeomSSD,
205 // for example.
206 virtual TObject *GetShape(const AliITSDetector idet)
207 {return fShape->At((Int_t)idet);};
269f57ed 208 // This function returns a pointer to the class describing the
209 // detector for a particular module index. This will return a pointer
210 // to one of the classes AliITSgeomSPD, AliITSgeomSDD, or AliITSgeomSSD,
211 // for example.
8253cd9a 212 virtual TObject *GetShape(const Int_t index){
213 return fShape->At(GetGeomMatrix(index)->
214 GetDetectorIndex());}
269f57ed 215 // This function returns a pointer to the class describing the
216 // detector for a particular layer ladder and detector numbers. This
217 // will return a pointer to one of the classes AliITSgeomSPD,
218 // AliITSgeomSDD, or AliITSgeomSSD, for example.
219 virtual TObject *GetShape(const Int_t lay,const Int_t lad,const Int_t det)
220 {return GetShape(GetModuleIndex(lay,lad,det));}
221//
269f57ed 222// Setters
223 // Sets the rotation angles and matrix for a give module index
224 // via the double precision array a[3] [radians].
225 void SetByAngles(const Int_t index,const Double_t a[]){
8253cd9a 226 GetGeomMatrix(index)->SetAngles(a);}
269f57ed 227 // Sets the rotation angles and matrix for a give module index
228 // via the 3 floating precision variables rx, ry, and rz [radians].
229 void SetByAngles(const Int_t index,
230 const Float_t rx,const Float_t ry,const Float_t rz) {
231 Double_t a[3];a[0] = rx;a[1] = ry;a[2] = rz;
8253cd9a 232 GetGeomMatrix(index)->SetAngles(a);}
269f57ed 233 // Sets the rotation angles and matrix for a give layer, ladder,
234 // and detector numbers via the 3 floating precision variables rx,
235 // ry, and rz [radians].
236 void SetByAngles(const Int_t lay,const Int_t lad,const Int_t det,
237 const Float_t rx,const Float_t ry,const Float_t rz) {
238 SetByAngles(GetModuleIndex(lay,lad,det),rx,ry,rz);}
239//
240 // Sets the rotation angles and matrix for a give module index
241 // via the Double precision array a[6] [degree]. The angles are those
242 // defined by GEANT 3.12.
243 void SetByGeantAngles(const Int_t index,const Double_t *ang){
8253cd9a 244 GetGeomMatrix(index)->MatrixFromSixAngles(ang);}
269f57ed 245 // Sets the rotation angles and matrix for a give layer, ladder
246 // and detector, in the array id[3] via the Double precision array
247 // a[6] [degree]. The angles are those defined by GEANT 3.12.
248 void SetByGeantAngles(const Int_t *id,const Double_t *ang){
249 SetByGeantAngles(GetModuleIndex(id),ang);}
250 // Sets the rotation angles and matrix for a give layer, ladder
251 // and detector, via the Double precision array a[6] [degree]. The
252 // angles are those defined by GEANT 3.12.
253 void SetByGeantAngles(const Int_t lay,const Int_t lad,const Int_t det,
254 const Double_t *ang){
255 SetByGeantAngles(GetModuleIndex(lay,lad,det),ang);}
256//
257 // This function sets a new translation vector, given by the
258 // array x[3], for the Cartesian coordinate transformation
259 // for a give module index.
260 void SetTrans(const Int_t index,Double_t x[]){
8253cd9a 261 GetGeomMatrix(index)->SetTranslation(x);}
269f57ed 262 // This function sets a new translation vector, given by the three
263 // variables x, y, and z, for the Cartesian coordinate transformation
264 // for the detector defined by layer, ladder and detector.
265 void SetTrans(const Int_t lay,const Int_t lad,const Int_t det,
266 Float_t x,Float_t y,Float_t z){Double_t t[3];
267 t[0] = x;t[1] = y;t[2] = z;
268 SetTrans(GetModuleIndex(lay,lad,det),t);}
269//
270 // This function adds one more shape element to the TObjArray
271 // fShape. It is primarily used in the constructor functions of the
272 // AliITSgeom class. The pointer *shape can be the pointer to any
273 // class that is derived from TObject (this is true for nearly every
274 // ROOT class). This does not appear to be working properly at this time.
275 void AddShape(TObject *shp){fShape->AddLast(shp);}
276 // This function deletes an existing shape element, of type TObject,
277 // and replaces it with the one specified. This is primarily used to
278 // changes the parameters to the segmentation class for a particular
279 // type of detector.
280 void ReSetShape(const Int_t dtype,TObject *shp){
281 fShape->RemoveAt(dtype);fShape->AddAt(shp,dtype);}
282//
283// transformations
284 // Transforms from the ALICE Global coordinate system
285 // to the detector local coordinate system for the detector
286 // defined by the layer, ladder, and detector numbers. The
287 // global and local coordinate are given in two floating point
288 // arrays g[3], and l[3].
289 void GtoL(const Int_t lay,const Int_t lad,const Int_t det,
290 const Float_t *g,Float_t *l){
291 GtoL(GetModuleIndex(lay,lad,det),g,l);}
292 // Transforms from the ALICE Global coordinate system
293 // to the detector local coordinate system for the detector
294 // defined by the id[0], id[1], and id[2] numbers. The
295 // global and local coordinate are given in two floating point
296 // arrays g[3], and l[3].
297 void GtoL(const Int_t *id,const Float_t *g,Float_t *l){
298 GtoL(GetModuleIndex(id),g,l);}
299 // Transforms from the ALICE Global coordinate system
300 // to the detector local coordinate system for the detector
301 // module index number. The global and local coordinate are
302 // given in two floating point arrays g[3], and l[3].
303 void GtoL(const Int_t index,const Float_t *g,Float_t *l){
d962cab4 304 Double_t dg[3],dl[3];Int_t i;for(i=0;i<3;i++) dg[i] = g[i];
8253cd9a 305 GetGeomMatrix(index)->GtoLPosition(dg,dl);
d962cab4 306 for(i=0;i<3;i++) l[i] =dl[i];}
269f57ed 307 // Transforms from the ALICE Global coordinate system
308 // to the detector local coordinate system for the detector
309 // defined by the layer, ladder, and detector numbers. The
310 // global and local coordinate are given in two Double point
311 // arrays g[3], and l[3].
312 void GtoL(const Int_t lay,const Int_t lad,const Int_t det,
313 const Double_t *g,Double_t *l){
314 GtoL(GetModuleIndex(lay,lad,det),g,l);}
315 // Transforms from the ALICE Global coordinate system
316 // to the detector local coordinate system for the detector
317 // defined by the id[0], id[1], and id[2] numbers. The
318 // global and local coordinate are given in two Double point
319 // arrays g[3], and l[3].
320 void GtoL(const Int_t *id,const Double_t *g,Double_t *l){
321 GtoL(GetModuleIndex(id),g,l);}
322 // Transforms from the ALICE Global coordinate system
323 // to the detector local coordinate system for the detector
324 // module index number. The global and local coordinate are
325 // given in two Double point arrays g[3], and l[3].
326 void GtoL(const Int_t index,const Double_t *g,Double_t *l){
d962cab4 327 Double_t dg[3],dl[3];Int_t i;for(i=0;i<3;i++) dg[i] = g[i];
8253cd9a 328 GetGeomMatrix(index)->GtoLPosition(dg,dl);
d962cab4 329 for(i=0;i<3;i++) l[i] =dl[i];}
269f57ed 330//
331 // Transforms from the ALICE Global coordinate system
332 // to the detector local coordinate system (used for ITS tracking)
333 // for the detector module index number. The global and local
334 // coordinate are given in two Double point arrays g[3], and l[3].
335 void GtoLtracking(const Int_t index,const Double_t *g,Double_t *l){
336 if(IsGeantToTracking()) GtoL(index,g,l);
8253cd9a 337 else GetGeomMatrix(index)->GtoLPositionTracking(g,l);}
269f57ed 338 // Transforms from the ALICE Global coordinate system
339 // to the detector local coordinate system (used for ITS tracking)
340 // for the detector id[3]. The global and local
341 // coordinate are given in two Double point arrays g[3], and l[3].
342 void GtoLtracking(const Int_t *id,const Double_t *g,Double_t *l){
343 GtoLtracking(GetModuleIndex(id),g,l);}
344 // Transforms from the ALICE Global coordinate system
345 // to the detector local coordinate system (used for ITS tracking)
346 // for the detector layer ladder and detector numbers. The global
347 // and local coordinate are given in two Double point arrays g[3],
348 // and l[3].
349 void GtoLtracking(const Int_t lay,const Int_t lad,const Int_t det,
350 const Double_t *g,Double_t *l){
351 GtoLtracking(GetModuleIndex(lay,lad,det),g,l);}
352//
353 // Transforms of momentum types of quantities from the ALICE
354 // Global coordinate system to the detector local coordinate system
355 // for the detector layer ladder and detector numbers. The global
356 // and local coordinate are given in two float point arrays g[3],
357 // and l[3].
358 void GtoLMomentum(const Int_t lay,const Int_t lad,const Int_t det,
359 const Float_t *g,Float_t *l){
360 GtoLMomentum(GetModuleIndex(lay,lad,det),g,l);}
361 // Transforms of momentum types of quantities from the ALICE
362 // Global coordinate system to the detector local coordinate system
363 // for the detector module index number. The global and local
364 // coordinate are given in two float point arrays g[3], and l[3].
365 void GtoLMomentum(const Int_t index,const Float_t *g,Float_t *l){
d962cab4 366 Double_t dg[3],dl[3];Int_t i;for(i=0;i<3;i++) dg[i] = g[i];
8253cd9a 367 GetGeomMatrix(index)->GtoLMomentum(dg,dl);
d962cab4 368 for(i=0;i<3;i++) l[i] =dl[i];}
269f57ed 369 // Transforms of momentum types of quantities from the ALICE
370 // Global coordinate system to the detector local coordinate system
371 // for the detector layer ladder and detector numbers. The global
372 // and local coordinate are given in two Double point arrays g[3],
373 // and l[3].
374 void GtoLMomentum(const Int_t lay,const Int_t lad,const Int_t det,
375 const Double_t *g,Double_t *l){
376 GtoLMomentum(GetModuleIndex(lay,lad,det),g,l);}
377 // Transforms of momentum types of quantities from the ALICE
378 // Global coordinate system to the detector local coordinate system
379 // for the detector module index number. The global and local
380 // coordinate are given in two Double point arrays g[3], and l[3].
381 void GtoLMomentum(const Int_t index,const Double_t *g,Double_t *l){
d962cab4 382 Double_t dg[3],dl[3];Int_t i;for(i=0;i<3;i++) dg[i] = g[i];
8253cd9a 383 GetGeomMatrix(index)->GtoLMomentum(dg,dl);
d962cab4 384 for(i=0;i<3;i++) l[i] =dl[i];}
269f57ed 385//
386 // Transforms of momentum types of quantities from the ALICE
387 // Global coordinate system to the detector local coordinate system
388 // (used for ITS tracking) for the detector module index number.
389 // The global and local coordinate are given in two Double point
390 // arrays g[3], and l[3].
391 void GtoLMomentumTracking(const Int_t index,const Double_t *g,Double_t *l){
392 if(IsGeantToTracking()) GtoLMomentum(index,g,l);
8253cd9a 393 else GetGeomMatrix(index)->GtoLMomentumTracking(g,l);}
269f57ed 394 // Transforms of momentum types of quantities from the ALICE
395 // Global coordinate system to the detector local coordinate system
396 // (used for ITS tracking) for the detector id[3].
397 // The global and local coordinate are given in two Double point
398 // arrays g[3], and l[3].
399 void GtoLMomentumTracking(const Int_t *id,const Double_t *g,Double_t *l){
400 GtoLMomentumTracking(GetModuleIndex(id),g,l);}
401 // Transforms of momentum types of quantities from the ALICE
402 // Global coordinate system to the detector local coordinate system
403 // (used for ITS tracking) for the detector layer ladder and detector
404 // numbers. The global and local coordinate are given in two Double point
405 // arrays g[3], and l[3].
406 void GtoLMomentumTracking(const Int_t lay,const Int_t lad,const Int_t det,
407 const Double_t *g,Double_t *l){
408 GtoLMomentumTracking(GetModuleIndex(lay,lad,det),g,l);}
409//
410 // Transforms from the detector local coordinate system
411 // to the ALICE Global coordinate system for the detector
412 // defined by the layer, ladder, and detector numbers. The
413 // global and local coordinate are given in two floating point
414 // arrays g[3], and l[3].
415 void LtoG(const Int_t lay,const Int_t lad,const Int_t det,
416 const Float_t *l,Float_t *g){
417 LtoG(GetModuleIndex(lay,lad,det),l,g);}
418 // Transforms from the detector local coordinate system
419 // to the ALICE Global coordinate system for the detector
420 // defined by the id[0], id[1], and id[2] numbers. The
421 // global and local coordinate are given in two floating point
422 // arrays g[3], and l[3].
423 void LtoG(const Int_t *id,const Float_t *l,Float_t *g){
424 LtoG(GetModuleIndex(id),l,g);}
425 // Transforms from the detector local coordinate system
426 // to the ALICE Global coordinate system for the detector
427 // module index number. The global and local coordinate are
428 // given in two floating point arrays g[3], and l[3].
429 void LtoG(const Int_t index,const Float_t *l,Float_t *g){
d962cab4 430 Double_t dg[3],dl[3];Int_t i;for(i=0;i<3;i++) dl[i] = l[i];
8253cd9a 431 GetGeomMatrix(index)->LtoGPosition(dl,dg);
d962cab4 432 for(i=0;i<3;i++) g[i] =dg[i];}
269f57ed 433 // Transforms from the detector local coordinate system
434 // to the ALICE Global coordinate system for the detector
435 // defined by the layer, ladder, and detector numbers. The
436 // global and local coordinate are given in two Double point
437 // arrays g[3], and l[3].
438 void LtoG(const Int_t lay,const Int_t lad,const Int_t det,
439 const Double_t *l,Double_t *g){
440 LtoG(GetModuleIndex(lay,lad,det),l,g);}
441 // Transforms from the detector local coordinate system
442 // to the ALICE Global coordinate system for the detector
443 // defined by the id[0], id[1], and id[2] numbers. The
444 // global and local coordinate are given in two Double point
445 // arrays g[3], and l[3].
446 void LtoG(const Int_t *id,const Double_t *l,Double_t *g){
447 LtoG(GetModuleIndex(id),l,g);}
448 // Transforms from the detector local coordinate system
449 // to the ALICE Global coordinate system for the detector
450 // module index number. The global and local coordinate are
451 // given in two Double point arrays g[3], and l[3].
452 void LtoG(const Int_t index,const Double_t *l,Double_t *g){
d962cab4 453 Double_t dg[3],dl[3];Int_t i;for(i=0;i<3;i++) dl[i] = l[i];
8253cd9a 454 GetGeomMatrix(index)->LtoGPosition(dl,dg);
d962cab4 455 for(i=0;i<3;i++) g[i] =dg[i];}
269f57ed 456//
457 // Transforms from the detector local coordinate system (used
458 // for ITS tracking) to the ALICE Global coordinate system
459 // for the detector module index number. The global and local
460 // coordinate are given in two Double point arrays g[3], and l[3].
461 void LtoGtracking(const Int_t index,const Double_t *l,Double_t *g){
462 if(IsGeantToTracking()) LtoG(index,l,g);
8253cd9a 463 else GetGeomMatrix(index)->LtoGPositionTracking(l,g);}
269f57ed 464 // Transforms from the detector local coordinate system (used
465 // for ITS tracking) to the ALICE Global coordinate system
466 // for the detector id[3]. The global and local
467 // coordinate are given in two Double point arrays g[3], and l[3].
468 void LtoGtracking(const Int_t *id,const Double_t *l,Double_t *g){
469 LtoGtracking(GetModuleIndex(id),l,g);}
470 // Transforms from the detector local coordinate system (used
471 // for ITS tracking) to the detector local coordinate system
472 // for the detector layer ladder and detector numbers. The global
473 // and local coordinate are given in two Double point arrays g[3],
474 // and l[3].
475 void LtoGtracking(const Int_t lay,const Int_t lad,const Int_t det,
476 const Double_t *l,Double_t *g){
477 LtoGtracking(GetModuleIndex(lay,lad,det),l,g);}
478//
479 // Transforms of momentum types of quantities from the detector
480 // local coordinate system to the ALICE Global coordinate system
481 // for the detector layer ladder and detector numbers. The global
482 // and local coordinate are given in two float point arrays g[3],
483 // and l[3].
484 void LtoGMomentum(const Int_t lay,const Int_t lad,const Int_t det,
485 const Float_t *l,Float_t *g){
486 LtoGMomentum(GetModuleIndex(lay,lad,det),l,g);}
487 // Transforms of momentum types of quantities from the detector
488 // local coordinate system to the ALICE Global coordinate system
489 // for the detector module index number. The global and local
490 // coordinate are given in two float point arrays g[3], and l[3].
491 void LtoGMomentum(const Int_t index,const Float_t *l,Float_t *g){
d962cab4 492 Double_t dg[3],dl[3];Int_t i;for(i=0;i<3;i++) dl[i] = l[i];
8253cd9a 493 GetGeomMatrix(index)->LtoGMomentum(dl,dg);
d962cab4 494 for(i=0;i<3;i++) g[i] =dg[i];}
269f57ed 495 // Transforms of momentum types of quantities from the detector
496 // local coordinate system to the ALICE Global coordinate system
497 // for the detector layer ladder and detector numbers. The global
498 // and local coordinate are given in two Double point arrays g[3],
499 // and l[3].
500 void LtoGMomentum(const Int_t lay,const Int_t lad,const Int_t det,
501 const Double_t *l,Double_t *g){
502 LtoGMomentum(GetModuleIndex(lay,lad,det),l,g);}
503 // Transforms of momentum types of quantities from the detector
504 // local coordinate system to the ALICE Global coordinate system
505 // for the detector module index number. The global and local
506 // coordinate are given in two Double point arrays g[3], and l[3].
507 void LtoGMomentum(const Int_t index,const Double_t *l,Double_t *g){
8253cd9a 508 GetGeomMatrix(index)->LtoGMomentum(l,g);}
269f57ed 509//
510 // Transforms of momentum types of quantities from the detector
511 // local coordinate system (used for ITS tracking) to the detector
512 // system ALICE Global for the detector module index number.
513 // The global and local coordinate are given in two Double point
514 // arrays g[3], and l[3].
515 void LtoGMomentumTracking(const Int_t index,const Double_t *l,Double_t *g){
516 if(IsGeantToTracking()) LtoGMomentum(index,l,g);
8253cd9a 517 else GetGeomMatrix(index)->LtoGMomentumTracking(l,g);}
269f57ed 518 // Transforms of momentum types of quantities from the detector
519 // local coordinate system (used for ITS tracking) to the ALICE
520 // Global coordinate system for the detector id[3].
521 // The global and local coordinate are given in two Double point
522 // arrays g[3], and l[3].
523 void LtoGMomentumTracking(const Int_t *id,const Double_t *l,Double_t *g){
524 LtoGMomentumTracking(GetModuleIndex(id),l,g);}
525 // Transforms of momentum types of quantities from the detector
526 // local coordinate system (used for ITS tracking) to the ALICE
527 // Global coordinate system for the detector layer ladder and detector
528 // numbers. The global and local coordinate are given in two Double point
529 // arrays g[3], and l[3].
530 void LtoGMomentumTracking(const Int_t lay,const Int_t lad,const Int_t det,
531 const Double_t *l,Double_t *g){
532 LtoGMomentumTracking(GetModuleIndex(lay,lad,det),l,g);}
533//
534 // Transforms from one detector local coordinate system
535 // to another detector local coordinate system for the detector
536 // module index1 number to the detector module index2 number. The
537 // local coordinates are given in two Double point arrays l1[3],
538 // and l2[3].
539 void LtoL(const Int_t index1,const Int_t index2,Double_t *l1,Double_t *l2){
540 Double_t g[3]; LtoG(index1,l1,g);GtoL(index2,g,l2);}
541 // Transforms from one detector local coordinate system
542 // to another detector local coordinate system for the detector
543 // id1[3] to the detector id2[3]. The local coordinates are given
544 // in two Double point arrays l1[3], and l2[3].
545 void LtoL(const Int_t *id1,const Int_t *id2,Double_t *l1,Double_t *l2){
546 LtoL(GetModuleIndex(id1[0],id1[1],id1[2]),
547 GetModuleIndex(id2[0],id2[1],id2[2]),l1,l2);}
548//
549 // Transforms from one detector local coordinate system (used for
550 // ITS tracking) to another detector local coordinate system (used
551 // for ITS tracking) for the detector module index1 number to the
552 // detector module index2 number. The local coordinates are given
553 // in two Double point arrays l1[3], and l2[3].
554 void LtoLtracking(const Int_t index1,const Int_t index2,
555 Double_t *l1,Double_t *l2){
556 Double_t g[3]; LtoGtracking(index1,l1,g);GtoLtracking(index2,g,l2);}
557 // Transforms from one detector local coordinate system (used for
558 // ITS tracking) to another detector local coordinate system (used
559 // for ITS tracking) for the detector id1[3] to the detector id2[3].
560 // The local coordinates are given in two Double point arrays l1[3],
561 // and l2[3].
562 void LtoLtracking(const Int_t *id1,const Int_t *id2,
563 Double_t *l1,Double_t *l2){
564 LtoLtracking(GetModuleIndex(id1[0],id1[1],id1[2]),
565 GetModuleIndex(id2[0],id2[1],id2[2]),l1,l2);}
566//
567 // Transforms of momentum types of quantities from one detector
568 // local coordinate system to another detector local coordinate
569 // system for the detector module index1 number to the detector
570 // module index2 number. The local coordinates are given in two
571 // Double point arrays l1[3], and l2[3].
572 void LtoLMomentum(const Int_t index1,const Int_t index2,
573 const Double_t *l1,Double_t *l2){
574 Double_t g[3]; LtoGMomentum(index1,l1,g);GtoLMomentum(index2,g,l2);}
575 // Transforms of momentum types of quantities from one detector
576 // local coordinate system to another detector local coordinate
577 // system for the detector id1[3] to the detector id2[3]. The local
578 // coordinates are given in two Double point arrays l1[3], and l2[3].
b79e4bc3 579 void LtoLMomentum(const Int_t *id1,const Int_t *id2,
269f57ed 580 const Double_t *l1,Double_t *l2){
581 LtoLMomentum(GetModuleIndex(id1[0],id1[1],id1[2]),
582 GetModuleIndex(id2[0],id2[1],id2[2]),l1,l2);}
583//
584 // Transforms of momentum types of quantities from one detector
585 // local coordinate system (used by ITS tracking) to another detector
586 // local coordinate system (used by ITS tracking) for the detector
587 // module index1 number to the detector module index2 number. The
588 // local coordinates are given in two Double point arrays l1[3],
589 // and l2[3].
590 void LtoLMomentumTracking(const Int_t index1,const Int_t index2,
591 Double_t *l1,Double_t *l2){
592 Double_t g[3]; LtoGMomentumTracking(index1,l1,g);
593 GtoLMomentumTracking(index2,g,l2);}
594 // Transforms of momentum types of quantities from one detector
595 // local coordinate system (used by ITS tracking) to another detector
596 // local coordinate system (used by ITS tracking) for the detector
597 // id1[3] to the detector id2[3]. The local coordinates are given in
598 // two Double point arrays l1[3], and l2[3].
599 void LtoLMomentumTracking(const Int_t *id1,const Int_t *id2,
600 Double_t *l1,Double_t *l2){
601 LtoLMomentumTracking(GetModuleIndex(id1[0],id1[1],id1[2]),
602 GetModuleIndex(id2[0],id2[1],id2[2]),l1,l2);}
603//
604 // Transforms a matrix, like an Uncertainty or Error matrix from
605 // the ALICE Global coordinate system to a detector local coordinate
606 // system. The specific detector is determined by the module index
607 // number.
608 void GtoLErrorMatrix(const Int_t index,const Double_t **g,Double_t **l){
8253cd9a 609 GetGeomMatrix(index)->GtoLPositionError((Double_t (*)[3])g,(Double_t (*)[3])l);}
269f57ed 610//
611 // Transforms a matrix, like an Uncertainty or Error matrix from
612 // the ALICE Global coordinate system to a detector local coordinate
613 // system (used by ITS tracking). The specific detector is determined
614 // by the module index number.
615 void GtoLErrorMatrixTracking(const Int_t index,const Double_t **g,
616 Double_t **l){
8253cd9a 617 if(IsGeantToTracking()) GetGeomMatrix(index)->GtoLPositionError((
d962cab4 618 Double_t (*)[3])g,(Double_t (*)[3])l);
8253cd9a 619 else GetGeomMatrix(index)->GtoLPositionErrorTracking(
d962cab4 620 (Double_t (*)[3])g,(Double_t (*)[3])l);}
269f57ed 621//
622 // Transforms a matrix, like an Uncertainty or Error matrix from
623 // the detector local coordinate system to a ALICE Global coordinate
624 // system. The specific detector is determined by the module index
625 // number.
626 void LtoGErrorMatrix(const Int_t index,const Double_t **l,Double_t **g){
8253cd9a 627 GetGeomMatrix(index)->LtoGPositionError((Double_t (*)[3])l,(Double_t (*)[3])g);}
269f57ed 628//
629 // Transforms a matrix, like an Uncertainty or Error matrix from
630 // the detector local coordinate system (used by ITS tracking) to a
631 // ALICE Global coordinate system. The specific detector is determined
632 // by the module index number.
633 void LtoGErrorMatrixTracking(const Int_t index,const Double_t **l,
634 Double_t **g){
8253cd9a 635 if(IsGeantToTracking()) GetGeomMatrix(index)->LtoGPositionError((
d962cab4 636 Double_t (*)[3])g,(Double_t (*)[3])l);
8253cd9a 637 else GetGeomMatrix(index)->LtoGPositionErrorTracking((Double_t (*)[3])l,
d962cab4 638 (Double_t (*)[3])g);}
269f57ed 639//
640 // Transforms a matrix, like an Uncertainty or Error matrix from
641 // one detector local coordinate system to another detector local
642 // coordinate system. The specific detector is determined by the
643 // two module index number index1 and index2.
b79e4bc3 644 void LtoLErrorMatrix(const Int_t index1,const Int_t index2,
269f57ed 645 const Double_t **l1,Double_t **l2){
646 Double_t g[3][3];
647 LtoGErrorMatrix(index1,l1,(Double_t **)g);
648 GtoLErrorMatrix(index2,(const Double_t **)g,l2);}
649//
650 // Transforms a matrix, like an Uncertainty or Error matrix from
651 // one detector local coordinate system (used by ITS tracking) to
652 // another detector local coordinate system (used by ITS tracking).
653 // The specific detector is determined by the two module index number
654 // index1 and index2.
655 void LtoLErrorMatrixTraking(const Int_t index1,const Int_t index2,
656 const Double_t **l1,Double_t **l2){Double_t g[3][3];
657 LtoGErrorMatrixTracking(index1,l1,(Double_t **)g);
658 GtoLErrorMatrixTracking(index2,(const Double_t **)g,l2);}
659// Find Specific Modules
660 Int_t GetNearest(const Double_t g[3],const Int_t lay=0);
661 void GetNearest27(const Double_t g[3],Int_t n[27],const Int_t lay=0);
662 // Returns the distance [cm] between the point g[3] and the center of
663 // the detector/module specified by the the module index number.
664 Double_t Distance(const Int_t index,const Double_t g[3]){
8253cd9a 665 return TMath::Sqrt(GetGeomMatrix(index)->Distance2(g));}
269f57ed 666// Geometry manipulation
667 void GlobalChange(const Float_t *tran,const Float_t *rot);
668 void GlobalCylindericalChange(const Float_t *tran,const Float_t *rot);
669 void RandomChange(const Float_t *stran,const Float_t *srot);
670 void RandomCylindericalChange(const Float_t *stran,const Float_t *srot);
671 void GeantToTracking(AliITSgeom &source); // This converts the geometry
672// Other routines.
58005f18 673 void PrintComparison(FILE *fp,AliITSgeom *other);
269f57ed 674 void PrintData(FILE *fp,const Int_t lay,const Int_t lad,const Int_t det);
58005f18 675 ofstream &PrintGeom(ofstream &out);
676 ifstream &ReadGeom(ifstream &in);
e8189707 677
085bb6ed 678 private:
8253cd9a 679 char fVersion[20];// Transformation version.
680 Int_t fTrans; // Flag to keep track of which transformation
681 Int_t fNmodules;// The total number of modules
682 Int_t fNlayers; // The number of layers.
683 Int_t *fNlad; //[fNlayers] Array of the number of ladders/layer(layer)
684 Int_t *fNdet; //[fNlayers] Array of the number of detectors/ladder(layer)
685 TObjArray *fGm; // Structure of trans. and rotation.
686 TObjArray *fShape; // Array of shapes and detector information.
687
269f57ed 688 ClassDef(AliITSgeom,2) // ITS geometry class
58005f18 689};
690
691#endif