]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - ITS/AliITSgeom.h
set reco param on an event by event basis
[u/mrichter/AliRoot.git] / ITS / AliITSgeom.h
... / ...
CommitLineData
1#ifndef ALIITSGEOM_H
2#define ALIITSGEOM_H
3/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
5
6/* $Id$ */
7
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/////////////////////////////////////////////////////////////////////////
20#include <Riostream.h>
21#include <TObject.h>
22#include <TObjArray.h>
23#include <TVector.h>
24#include <TString.h>
25#include <TArrayI.h>
26#include <TMath.h>
27//
28#include "AliITSgeomMatrix.h"
29#include "AliLog.h"
30
31typedef enum {kND=-1,kSPD=0, kSDD=1, kSSD=2, kSSDp=3,kSDDp=4} AliITSDetector;
32
33//_______________________________________________________________________
34
35class AliITSgeom : public TObject {
36
37 public:
38 AliITSgeom(); // Default constructor
39 AliITSgeom(Int_t itype,Int_t nlayers,const Int_t *nlads,const Int_t *ndets,
40 Int_t nmods); // Constructor
41 AliITSgeom(const AliITSgeom &source); // Copy constructor
42 AliITSgeom& operator=(const AliITSgeom &source);// = operator
43 virtual ~AliITSgeom(); // Default destructor
44 // Zero and reinitilizes this class.
45 void Init(Int_t itype,Int_t nlayers,const Int_t *nlads,
46 const Int_t *ndets,Int_t mods);
47 // this function allocates a AliITSgeomMatrix for a particular module.
48 void CreateMatrix(Int_t mod,Int_t lay,Int_t lad,Int_t det,
49 AliITSDetector idet,const Double_t tran[3],
50 const Double_t rot[10]);
51 // Getters
52 Int_t GetTransformationType() const {return fTrans;}
53 //
54 // returns kTRUE if the transformation defined by this class is
55 // for Global GEANT coordinate system to the local GEANT coordinate system
56 // of the detector. These are the transformation used by GEANT.
57 Bool_t IsGeantToGeant() const {return (fTrans == 0);}
58 // returns kTRUE if the transformation defined by this class is
59 // for Global GEANT coordinate system to the local "Tracking" coordinate
60 // system of the detector. These are the transformation used by the
61 // Tracking code.
62 Bool_t IsGeantToTracking() const {return ((fTrans&&0xfffe)!= 0);}
63 // returns kTRUE if the transformation defined by this class is
64 // for Global GEANT coordinate system to the local GEANT coordinate system
65 // of the detector but may have been displaced by some typically small
66 // amount. These are modified transformation similar to that used by GEANT.
67 Bool_t IsGeantToDisplaced() const {return ((fTrans&&0xfffd)!= 0);}
68 //
69 // This function returns a pointer to the particular AliITSgeomMatrix
70 // class for a specific module index.
71 AliITSgeomMatrix *GetGeomMatrix(Int_t index){if(index<fGm.GetSize()&&
72 index>=0)
73 return (AliITSgeomMatrix*)(fGm.At(index));else
74 Error("GetGeomMatrix","index=%d<0||>=GetSize()=%d",
75 index,fGm.GetSize());return 0;}
76 AliITSgeomMatrix *GetGeomMatrix(Int_t index)const{if(index<fGm.GetSize()
77 &&index>=0)
78 return (AliITSgeomMatrix*)(fGm.At(index));else
79 Error("GetGeomMatrix","index=%d<0||>=GetSize()=%d",
80 index,fGm.GetSize());return 0;}
81 // This function find and return the number of detector types only.
82 Int_t GetNDetTypes()const{Int_t max;return GetNDetTypes(max);};
83 // This function find and return the number of detector types and the
84 // maximum det type value.
85 Int_t GetNDetTypes(Int_t &max)const;
86 // This function finds and return the number of detector types and the
87 // and the number of each type in the TArrayI and their types.
88 Int_t GetNDetTypes(TArrayI &maxs,AliITSDetector *types)const;
89 // This function returns the number of detectors/ladder for a give
90 // layer. In particular it returns fNdet[layer-1].
91 Int_t GetNdetectors(Int_t lay) const {return fNdet[lay-1];}
92 // This function returns the number of ladders for a give layer. In
93 // particular it returns fNlad[layer-1].
94 Int_t GetNladders(Int_t lay) const {return fNlad[lay-1];};
95 // This function returns the number of layers defined in the ITS
96 // geometry. In particular it returns fNlayers.
97 Int_t GetNlayers() const {return fNlayers;}
98 Int_t GetModuleIndex(Int_t lay,Int_t lad,Int_t det)const;
99 // This function returns the module index number given the layer,
100 // ladder and detector numbers put into the array id[3].
101 Int_t GetModuleIndex(const Int_t *id)const{
102 return GetModuleIndex(id[0],id[1],id[2]);}
103 void GetModuleId(Int_t index,Int_t &lay,Int_t &lad,Int_t &det)const;
104 // Returns the detector type
105 //Int_t GetModuleType(Int_t index)const{
106 // return GetGeomMatrix(index)->GetDetectorIndex();}
107 AliITSDetector GetModuleType(Int_t index)const{
108 return (AliITSDetector)(GetGeomMatrix(index)->GetDetectorIndex());}
109 // Returns the detector type as a string
110 const char * GetModuleTypeName(Int_t index)const{
111 return GetDetectorTypeName(GetModuleType(index));}
112 // Returns the detector type as a string
113 const char * GetDetectorTypeName(Int_t index)const{switch(index) {
114 case kSPD : return "kSPD" ; case kSDD : return "kSDD" ;
115 case kSSD : return "kSSD" ; case kSSDp: return "kSSDp";
116 case kSDDp: return "kSDDp"; default : return "Undefined";};}
117 //
118 Int_t GetStartDet(Int_t dtype )const;
119 Int_t GetLastDet(Int_t dtype)const;
120 // Returns the starting module index number for SPD detector,
121 // assuming the modules are placed in the "standard" cylindrical
122 // ITS structure.
123 Int_t GetStartSPD()const{return GetStartDet(kSPD);}
124 // Returns the ending module index number for SPD detector,
125 // assuming the modules are placed in the "standard" cylindrical
126 // ITS structure.
127 Int_t GetLastSPD()const{return GetLastDet(kSPD);}
128 // Returns the starting module index number for SDD detector,
129 // assuming the modules are placed in the "standard" cylindrical
130 // ITS structure.
131 Int_t GetStartSDD()const{return GetStartDet(kSDD);}
132 // Returns the ending module index number for SDD detector,
133 // assuming the modules are placed in the "standard" cylindrical
134 // ITS structure.
135 Int_t GetLastSDD()const{return GetLastDet(kSDD);}
136 // Returns the starting module index number for SSD detector,
137 // assuming the modules are placed in the "standard" cylindrical
138 // ITS structure.
139 Int_t GetStartSSD()const{return GetStartDet(kSSD);}
140 // Returns the ending module index number for SSD detector,
141 // assuming the modules are placed in the "standard" cylindrical
142 // ITS structure.
143 Int_t GetLastSSD()const{return GetLastDet(kSSD);}
144 // Returns the last module index number.
145 Int_t GetIndexMax() const {return fNmodules;}
146 //
147 // This function returns the rotation angles for a give module
148 // in the Double point array ang[3]. The angles are in radians
149 void GetAngles(Int_t index,Double_t *ang)const{
150 GetGeomMatrix(index)->GetAngles(ang);}
151 // This function returns the rotation angles for a give module
152 // in the three floating point variables provided. rx = frx,
153 // fy = fry, rz = frz. The angles are in radians
154 void GetAngles(Int_t index,Float_t &rx,Float_t &ry,Float_t &rz)const{
155 Double_t a[3];GetAngles(index,a);rx = a[0];ry = a[1];rz = a[2];}
156 // This function returns the rotation angles for a give detector on
157 // a give ladder in a give layer in the three floating point variables
158 // provided. rx = frx, fy = fry, rz = frz. The angles are in radians
159 void GetAngles(Int_t lay,Int_t lad,Int_t det,
160 Float_t &rx,Float_t &ry,Float_t &rz)const{
161 GetAngles(GetModuleIndex(lay,lad,det),rx,ry,rz);}
162 //
163 // This function returns the 6 GEANT rotation angles for a give
164 // module in the double point array ang[3]. The angles are in degrees
165 void GetGeantAngles(Int_t index,Double_t *ang)const{
166 GetGeomMatrix(index)->SixAnglesFromMatrix(ang);}
167 //
168 // This function returns the Cartesian translation for a give
169 // module in the Double array t[3]. The units are
170 // those of the Monte Carlo, generally cm.
171 void GetTrans(Int_t index,Double_t *t)const{
172 GetGeomMatrix(index)->GetTranslation(t);}
173 // This function returns the Cartesian translation for a give
174 // module index in the three floating point variables provided.
175 // x = fx0, y = fy0, z = fz0. The units are those of the Mont
176 // Carlo, generally cm.
177 void GetTrans(Int_t index,Float_t &x,Float_t &y,Float_t &z)const{
178 Double_t t[3];GetTrans(index,t);x = t[0];y = t[1];z = t[2];}
179 // This function returns the Cartesian translation for a give
180 // detector on a give ladder in a give layer in the three floating
181 // point variables provided. x = fx0, y = fy0, z = fz0. The units are
182 // those of the Monte Carlo, generally cm.
183 void GetTrans(Int_t lay,Int_t lad,Int_t det,
184 Float_t &x,Float_t &y,Float_t &z)const{
185 GetTrans(GetModuleIndex(lay,lad,det),x,y,z);}
186 //
187 // This function returns the Cartesian translation for a give
188 // module in the Double array t[3]. The units are
189 // those of the Monte Carlo, generally cm.
190 void GetTransCyln(Int_t index,Double_t *t)const{
191 GetGeomMatrix(index)->GetTranslationCylinderical(t);}
192 // This function returns the Cartesian translation for a give
193 // module index in the three floating point variables provided.
194 // x = fx0, y = fy0, z = fz0. The units are those of the Mont
195 // Carlo, generally cm.
196 void GetTransCyln(Int_t index,Float_t &x,Float_t &y,Float_t &z)const{
197 Double_t t[3];GetTransCyln(index,t);x = t[0];y = t[1];z = t[2];}
198 // This function returns the Cartesian translation for a give
199 // detector on a give ladder in a give layer in the three floating
200 // point variables provided. x = fx0, y = fy0, z = fz0. The units are
201 // those of the Monte Carlo, generally cm.
202 void GetTransCyln(Int_t lay,Int_t lad,Int_t det,
203 Float_t &x,Float_t &y,Float_t &z)const{
204 GetTransCyln(GetModuleIndex(lay,lad,det),x,y,z);}
205 //
206 // This function returns the Cartesian translation [cm] and the
207 // 6 GEANT rotation angles [degrees]for a given layer ladder and
208 // detector number, in the TVector x (at least 9 elements large).
209 // This function is required to be in-lined for speed.
210 void GetCenterThetaPhi(Int_t lay,Int_t lad,Int_t det,TVector &x)const{
211 Double_t t[3],a[6];Int_t i=GetModuleIndex(lay,lad,det);GetTrans(i,t);
212 GetGeantAngles(i,a);x(0)=t[0];x(1)=t[1];x(2)=t[2];x(3)=a[0];x(4)=a[1];
213 x(5)=a[2];x(6)=a[3];x(7)=a[4];x(8)=a[5];}
214 //
215 // This function returns the rotation matrix in Double
216 // precision for a given module.
217 void GetRotMatrix(Int_t index,Double_t mat[3][3])const{
218 GetGeomMatrix(index)->GetMatrix(mat);}
219 // This function returns the rotation matrix in a Double
220 // precision pointer for a given module. mat[i][j] => mat[3*i+j].
221 void GetRotMatrix(Int_t index,Double_t *mat)const{
222 Double_t rot[3][3];GetRotMatrix(index,rot);
223 for(Int_t i=0;i<3;i++)for(Int_t j=0;j<3;j++) mat[3*i+j] = rot[i][j];}
224 // This function returns the rotation matrix in a floating
225 // precision pointer for a given layer ladder and detector module.
226 // mat[i][j] => mat[3*i+j].
227 void GetRotMatrix(Int_t lay,Int_t lad,Int_t det,Float_t *mat)const{
228 GetRotMatrix(GetModuleIndex(lay,lad,det),mat);}
229 // This function returns the rotation matrix in a Double
230 // precision pointer for a given layer ladder and detector module.
231 // mat[i][j] => mat[3*i+j].
232 void GetRotMatrix(Int_t lay,Int_t lad,Int_t det,Double_t *mat)const{
233 GetRotMatrix(GetModuleIndex(lay,lad,det),mat);}
234 // This function returns the rotation matrix in a floating
235 // precision pointer for a given module. mat[i][j] => mat[3*i+j].
236 void GetRotMatrix(Int_t index,Float_t *mat)const{
237 Double_t rot[3][3];
238 GetGeomMatrix(index)->GetMatrix(rot);
239 for(Int_t i=0;i<3;i++)for(Int_t j=0;j<3;j++) mat[3*i+j] = rot[i][j];}
240 // This function sets the rotation matrix in a Double
241 // precision pointer for a given module. mat[i][j] => mat[3*i+j].
242 void SetRotMatrix(Int_t index,Double_t *mat){Double_t rot[3][3];
243 for(Int_t i=0;i<3;i++)for(Int_t j=0;j<3;j++) rot[i][j]=mat[3*i+j];
244 GetGeomMatrix(index)->SetMatrix(rot);}
245 // Return the normal for a specific module
246 void GetGlobalNormal(Int_t index,Double_t n[3]){
247 GetGeomMatrix(index)->GetGlobalNormal(n[0],n[1],n[2]);}
248 //
249 //
250 // Setters
251 // Sets the rotation angles and matrix for a give module index
252 // via the double precision array a[3] [radians].
253 void SetByAngles(Int_t index,const Double_t a[]){
254 GetGeomMatrix(index)->SetAngles(a);}
255 // Sets the rotation angles and matrix for a give module index
256 // via the 3 floating precision variables rx, ry, and rz [radians].
257 void SetByAngles(Int_t index,Float_t rx, Float_t ry, Float_t rz) {
258 Double_t a[3];a[0] = rx;a[1] = ry;a[2] = rz;
259 GetGeomMatrix(index)->SetAngles(a);}
260 // Sets the rotation angles and matrix for a give layer, ladder,
261 // and detector numbers via the 3 floating precision variables rx,
262 // ry, and rz [radians].
263 void SetByAngles(Int_t lay,Int_t lad,Int_t det,
264 Float_t rx, Float_t ry, Float_t rz) {
265 SetByAngles(GetModuleIndex(lay,lad,det),rx,ry,rz);}
266 //
267 // Sets the rotation angles and matrix for a give module index
268 // via the Double precision array a[6] [degree]. The angles are those
269 // defined by GEANT 3.12.
270 void SetByGeantAngles(Int_t index,const Double_t *ang){
271 GetGeomMatrix(index)->MatrixFromSixAngles(ang);}
272 // Sets the rotation angles and matrix for a give layer, ladder
273 // and detector, in the array id[3] via the Double precision array
274 // a[6] [degree]. The angles are those defined by GEANT 3.12.
275 void SetByGeantAngles(const Int_t *id,const Double_t *ang){
276 SetByGeantAngles(GetModuleIndex(id),ang);}
277 // Sets the rotation angles and matrix for a give layer, ladder
278 // and detector, via the Double precision array a[6] [degree]. The
279 // angles are those defined by GEANT 3.12.
280 void SetByGeantAngles(Int_t lay,Int_t lad,Int_t det,
281 const Double_t *ang){
282 SetByGeantAngles(GetModuleIndex(lay,lad,det),ang);}
283 //
284 // This function sets a new translation vector, given by the
285 // array x[3], for the Cartesian coordinate transformation
286 // for a give module index.
287 void SetTrans(Int_t index,Double_t x[]){
288 GetGeomMatrix(index)->SetTranslation(x);}
289 // This function sets a new translation vector, given by the three
290 // variables x, y, and z, for the Cartesian coordinate transformation
291 // for the detector defined by layer, ladder and detector.
292 void SetTrans(Int_t lay,Int_t lad,Int_t det,
293 Float_t x,Float_t y,Float_t z){Double_t t[3];
294 t[0] = x;t[1] = y;t[2] = z;
295 SetTrans(GetModuleIndex(lay,lad,det),t);}
296 //
297 // transformations
298 // Transforms from the ALICE Global coordinate system
299 // to the detector local coordinate system for the detector
300 // defined by the layer, ladder, and detector numbers. The
301 // global and local coordinate are given in two floating point
302 // arrays g[3], and l[3].
303 void GtoL(Int_t lay,Int_t lad,Int_t det,
304 const Float_t *g,Float_t *l)const{
305 GtoL(GetModuleIndex(lay,lad,det),g,l);}
306 // Transforms from the ALICE Global coordinate system
307 // to the detector local coordinate system for the detector
308 // defined by the id[0], id[1], and id[2] numbers. The
309 // global and local coordinate are given in two floating point
310 // arrays g[3], and l[3].
311 void GtoL(const Int_t *id,const Float_t *g,Float_t *l)const{
312 GtoL(GetModuleIndex(id),g,l);}
313 // Transforms from the ALICE Global coordinate system
314 // to the detector local coordinate system for the detector
315 // module index number. The global and local coordinate are
316 // given in two floating point arrays g[3], and l[3].
317 void GtoL(Int_t index,const Float_t *g,Float_t *l)const{
318 Double_t dg[3],dl[3];Int_t i;for(i=0;i<3;i++) dg[i] = g[i];
319 GetGeomMatrix(index)->GtoLPosition(dg,dl);
320 for(i=0;i<3;i++) l[i] =dl[i];}
321 // Transforms from the ALICE Global coordinate system
322 // to the detector local coordinate system for the detector
323 // defined by the layer, ladder, and detector numbers. The
324 // global and local coordinate are given in two Double point
325 // arrays g[3], and l[3].
326 void GtoL(Int_t lay,Int_t lad,Int_t det,
327 const Double_t *g,Double_t *l)const{
328 GtoL(GetModuleIndex(lay,lad,det),g,l);}
329 // Transforms from the ALICE Global coordinate system
330 // to the detector local coordinate system for the detector
331 // defined by the id[0], id[1], and id[2] numbers. The
332 // global and local coordinate are given in two Double point
333 // arrays g[3], and l[3].
334 void GtoL(const Int_t *id,const Double_t *g,Double_t *l)const{
335 GtoL(GetModuleIndex(id),g,l);}
336 // Transforms from the ALICE Global coordinate system
337 // to the detector local coordinate system for the detector
338 // module index number. The global and local coordinate are
339 // given in two Double point arrays g[3], and l[3].
340 void GtoL(Int_t index,const Double_t g[3],Double_t l[3])const{
341 GetGeomMatrix(index)->GtoLPosition(g,l);}
342 //
343 // Transforms from the ALICE Global coordinate system
344 // to the detector local coordinate system (used for ITS tracking)
345 // for the detector module index number. The global and local
346 // coordinate are given in two Double point arrays g[3], and l[3].
347 void GtoLtracking(Int_t index,const Double_t *g,Double_t *l)const{
348 if(IsGeantToTracking()) GtoL(index,g,l);
349 else GetGeomMatrix(index)->GtoLPositionTracking(g,l);}
350 // Transforms from the ALICE Global coordinate system
351 // to the detector local coordinate system (used for ITS tracking)
352 // for the detector id[3]. The global and local
353 // coordinate are given in two Double point arrays g[3], and l[3].
354 void GtoLtracking(const Int_t *id,const Double_t *g,Double_t *l)const{
355 GtoLtracking(GetModuleIndex(id),g,l);}
356 // Transforms from the ALICE Global coordinate system
357 // to the detector local coordinate system (used for ITS tracking)
358 // for the detector layer ladder and detector numbers. The global
359 // and local coordinate are given in two Double point arrays g[3],
360 // and l[3].
361 void GtoLtracking(Int_t lay,Int_t lad,Int_t det,
362 const Double_t *g,Double_t *l)const{
363 GtoLtracking(GetModuleIndex(lay,lad,det),g,l);}
364 //
365 // Transforms of momentum types of quantities from the ALICE
366 // Global coordinate system to the detector local coordinate system
367 // for the detector layer ladder and detector numbers. The global
368 // and local coordinate are given in two float point arrays g[3],
369 // and l[3].
370 void GtoLMomentum(Int_t lay,Int_t lad,Int_t det,
371 const Float_t *g,Float_t *l)const{
372 GtoLMomentum(GetModuleIndex(lay,lad,det),g,l);}
373 // Transforms of momentum types of quantities from the ALICE
374 // Global coordinate system to the detector local coordinate system
375 // for the detector module index number. The global and local
376 // coordinate are given in two float point arrays g[3], and l[3].
377 void GtoLMomentum(Int_t index,const Float_t *g,Float_t *l)const{
378 Double_t dg[3],dl[3];Int_t i;for(i=0;i<3;i++) dg[i] = g[i];
379 GetGeomMatrix(index)->GtoLMomentum(dg,dl);
380 for(i=0;i<3;i++) l[i] =dl[i];}
381 // Transforms of momentum types of quantities from the ALICE
382 // Global coordinate system to the detector local coordinate system
383 // for the detector layer ladder and detector numbers. The global
384 // and local coordinate are given in two Double point arrays g[3],
385 // and l[3].
386 void GtoLMomentum(Int_t lay,Int_t lad,Int_t det,
387 const Double_t *g,Double_t *l)const{
388 GtoLMomentum(GetModuleIndex(lay,lad,det),g,l);}
389 // Transforms of momentum types of quantities from the ALICE
390 // Global coordinate system to the detector local coordinate system
391 // for the detector module index number. The global and local
392 // coordinate are given in two Double point arrays g[3], and l[3].
393 void GtoLMomentum(Int_t index,const Double_t *g,Double_t *l)const{
394 Double_t dg[3],dl[3];Int_t i;for(i=0;i<3;i++) dg[i] = g[i];
395 GetGeomMatrix(index)->GtoLMomentum(dg,dl);
396 for(i=0;i<3;i++) l[i] =dl[i];}
397 //
398 // Transforms of momentum types of quantities from the ALICE
399 // Global coordinate system to the detector local coordinate system
400 // (used for ITS tracking) for the detector module index number.
401 // The global and local coordinate are given in two Double point
402 // arrays g[3], and l[3].
403 void GtoLMomentumTracking(Int_t index,const Double_t *g,Double_t *l)const{
404 if(IsGeantToTracking()) GtoLMomentum(index,g,l);
405 else GetGeomMatrix(index)->GtoLMomentumTracking(g,l);}
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 id[3].
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 *id,
412 const Double_t *g,Double_t *l)const{
413 GtoLMomentumTracking(GetModuleIndex(id),g,l);}
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 layer ladder and detector
417 // numbers. The global and local coordinate are given in two Double point
418 // arrays g[3], and l[3].
419 void GtoLMomentumTracking(Int_t lay,Int_t lad,Int_t det,
420 const Double_t *g,Double_t *l)const{
421 GtoLMomentumTracking(GetModuleIndex(lay,lad,det),g,l);}
422 //
423 // Transforms from the detector local coordinate system
424 // to the ALICE Global coordinate system for the detector
425 // defined by the layer, ladder, and detector numbers. The
426 // global and local coordinate are given in two floating point
427 // arrays g[3], and l[3].
428 void LtoG(Int_t lay,Int_t lad,Int_t det,
429 const Float_t *l,Float_t *g)const{
430 LtoG(GetModuleIndex(lay,lad,det),l,g);}
431 // Transforms from the detector local coordinate system
432 // to the ALICE Global coordinate system for the detector
433 // defined by the id[0], id[1], and id[2] numbers. The
434 // global and local coordinate are given in two floating point
435 // arrays g[3], and l[3].
436 void LtoG(const Int_t *id,const Float_t *l,Float_t *g)const{
437 LtoG(GetModuleIndex(id),l,g);}
438 // Transforms from the detector local coordinate system
439 // to the ALICE Global coordinate system for the detector
440 // module index number. The global and local coordinate are
441 // given in two floating point arrays g[3], and l[3].
442 void LtoG(Int_t index,const Float_t *l,Float_t *g)const{
443 Double_t dg[3],dl[3];Int_t i;for(i=0;i<3;i++) dl[i] = l[i];
444 GetGeomMatrix(index)->LtoGPosition(dl,dg);
445 for(i=0;i<3;i++) g[i] =dg[i];}
446 // Transforms from the detector local coordinate system
447 // to the ALICE Global coordinate system for the detector
448 // defined by the layer, ladder, and detector numbers. The
449 // global and local coordinate are given in two Double point
450 // arrays g[3], and l[3].
451 void LtoG(Int_t lay,Int_t lad,Int_t det,
452 const Double_t *l,Double_t *g)const{
453 LtoG(GetModuleIndex(lay,lad,det),l,g);}
454 // Transforms from the detector local coordinate system
455 // to the ALICE Global coordinate system for the detector
456 // defined by the id[0], id[1], and id[2] numbers. The
457 // global and local coordinate are given in two Double point
458 // arrays g[3], and l[3].
459 void LtoG(const Int_t *id,const Double_t *l,Double_t *g)const{
460 LtoG(GetModuleIndex(id),l,g);}
461 // Transforms from the detector local coordinate system
462 // to the ALICE Global coordinate system for the detector
463 // module index number. The global and local coordinate are
464 // given in two Double point arrays g[3], and l[3].
465 void LtoG(Int_t index,const Double_t *l,Double_t *g)const{
466 GetGeomMatrix(index)->LtoGPosition(l,g);}
467 //
468 // Transforms from the detector local coordinate system (used
469 // for ITS tracking) to the ALICE Global coordinate system
470 // for the detector module index number. The global and local
471 // coordinate are given in two Double point arrays g[3], and l[3].
472 void LtoGtracking(Int_t index,const Double_t *l,Double_t *g)const{
473 if(IsGeantToTracking()) LtoG(index,l,g);
474 else GetGeomMatrix(index)->LtoGPositionTracking(l,g);}
475 // Transforms from the detector local coordinate system (used
476 // for ITS tracking) to the ALICE Global coordinate system
477 // for the detector id[3]. The global and local
478 // coordinate are given in two Double point arrays g[3], and l[3].
479 void LtoGtracking(const Int_t *id,const Double_t *l,Double_t *g)const{
480 LtoGtracking(GetModuleIndex(id),l,g);}
481 // Transforms from the detector local coordinate system (used
482 // for ITS tracking) to the detector local coordinate system
483 // for the detector layer ladder and detector numbers. The global
484 // and local coordinate are given in two Double point arrays g[3],
485 // and l[3].
486 void LtoGtracking(Int_t lay,Int_t lad,Int_t det,
487 const Double_t *l,Double_t *g)const{
488 LtoGtracking(GetModuleIndex(lay,lad,det),l,g);}
489 //
490 // Transforms of momentum types of quantities from the detector
491 // local coordinate system to the ALICE Global coordinate system
492 // for the detector layer ladder and detector numbers. The global
493 // and local coordinate are given in two float point arrays g[3],
494 // and l[3].
495 void LtoGMomentum(Int_t lay,Int_t lad,Int_t det,
496 const Float_t *l,Float_t *g)const{
497 LtoGMomentum(GetModuleIndex(lay,lad,det),l,g);}
498 // Transforms of momentum types of quantities from the detector
499 // local coordinate system to the ALICE Global coordinate system
500 // for the detector module index number. The global and local
501 // coordinate are given in two float point arrays g[3], and l[3].
502 void LtoGMomentum(Int_t index,const Float_t *l,Float_t *g)const{
503 Double_t dg[3],dl[3];Int_t i;for(i=0;i<3;i++) dl[i] = l[i];
504 GetGeomMatrix(index)->LtoGMomentum(dl,dg);
505 for(i=0;i<3;i++) g[i] =dg[i];}
506 // Transforms of momentum types of quantities from the detector
507 // local coordinate system to the ALICE Global coordinate system
508 // for the detector layer ladder and detector numbers. The global
509 // and local coordinate are given in two Double point arrays g[3],
510 // and l[3].
511 void LtoGMomentum(Int_t lay,Int_t lad,Int_t det,
512 const Double_t *l,Double_t *g)const{
513 LtoGMomentum(GetModuleIndex(lay,lad,det),l,g);}
514 // Transforms of momentum types of quantities from the detector
515 // local coordinate system to the ALICE Global coordinate system
516 // for the detector module index number. The global and local
517 // coordinate are given in two Double point arrays g[3], and l[3].
518 void LtoGMomentum(Int_t index,const Double_t *l,Double_t *g)const{
519 GetGeomMatrix(index)->LtoGMomentum(l,g);}
520 //
521 // Transforms of momentum types of quantities from the detector
522 // local coordinate system (used for ITS tracking) to the detector
523 // system ALICE Global for the detector module index number.
524 // The global and local coordinate are given in two Double point
525 // arrays g[3], and l[3].
526 void LtoGMomentumTracking(Int_t index,const Double_t *l,Double_t *g)const{
527 if(IsGeantToTracking()) LtoGMomentum(index,l,g);
528 else GetGeomMatrix(index)->LtoGMomentumTracking(l,g);}
529 // Transforms of momentum types of quantities from the detector
530 // local coordinate system (used for ITS tracking) to the ALICE
531 // Global coordinate system for the detector id[3].
532 // The global and local coordinate are given in two Double point
533 // arrays g[3], and l[3].
534 void LtoGMomentumTracking(const Int_t *id,const Double_t *l,Double_t *g)
535 const{LtoGMomentumTracking(GetModuleIndex(id),l,g);}
536 // Transforms of momentum types of quantities from the detector
537 // local coordinate system (used for ITS tracking) to the ALICE
538 // Global coordinate system for the detector layer ladder and detector
539 // numbers. The global and local coordinate are given in two Double point
540 // arrays g[3], and l[3].
541 void LtoGMomentumTracking(Int_t lay,Int_t lad,Int_t det,
542 const Double_t *l,Double_t *g)const{
543 LtoGMomentumTracking(GetModuleIndex(lay,lad,det),l,g);}
544 //
545 // Transforms from one detector local coordinate system
546 // to another detector local coordinate system for the detector
547 // module index1 number to the detector module index2 number. The
548 // local coordinates are given in two Double point arrays l1[3],
549 // and l2[3].
550 void LtoL(Int_t index1,Int_t index2,Double_t *l1,Double_t *l2)const{
551 Double_t g[3]; LtoG(index1,l1,g);GtoL(index2,g,l2);}
552 // Transforms from one detector local coordinate system
553 // to another detector local coordinate system for the detector
554 // id1[3] to the detector id2[3]. The local coordinates are given
555 // in two Double point arrays l1[3], and l2[3].
556 void LtoL(const Int_t *id1,const Int_t *id2,Double_t *l1,Double_t *l2)
557 const{LtoL(GetModuleIndex(id1[0],id1[1],id1[2]),
558 GetModuleIndex(id2[0],id2[1],id2[2]),l1,l2);}
559 //
560 // Transforms from one detector local coordinate system (used for
561 // ITS tracking) to another detector local coordinate system (used
562 // for ITS tracking) for the detector module index1 number to the
563 // detector module index2 number. The local coordinates are given
564 // in two Double point arrays l1[3], and l2[3].
565 void LtoLtracking(Int_t index1,Int_t index2,
566 Double_t *l1,Double_t *l2)const{
567 Double_t g[3]; LtoGtracking(index1,l1,g);GtoLtracking(index2,g,l2);}
568 // Transforms from one detector local coordinate system (used for
569 // ITS tracking) to another detector local coordinate system (used
570 // for ITS tracking) for the detector id1[3] to the detector id2[3].
571 // The local coordinates are given in two Double point arrays l1[3],
572 // and l2[3].
573 void LtoLtracking(const Int_t *id1,const Int_t *id2,
574 Double_t *l1,Double_t *l2)const{
575 LtoLtracking(GetModuleIndex(id1[0],id1[1],id1[2]),
576 GetModuleIndex(id2[0],id2[1],id2[2]),l1,l2);}
577 //
578 // Transforms of momentum types of quantities from one detector
579 // local coordinate system to another detector local coordinate
580 // system for the detector module index1 number to the detector
581 // module index2 number. The local coordinates are given in two
582 // Double point arrays l1[3], and l2[3].
583 void LtoLMomentum(Int_t index1,Int_t index2,
584 const Double_t *l1,Double_t *l2)const{
585 Double_t g[3]; LtoGMomentum(index1,l1,g);GtoLMomentum(index2,g,l2);}
586 // Transforms of momentum types of quantities from one detector
587 // local coordinate system to another detector local coordinate
588 // system for the detector id1[3] to the detector id2[3]. The local
589 // coordinates are given in two Double point arrays l1[3], and l2[3].
590 void LtoLMomentum(const Int_t *id1,const Int_t *id2,
591 const Double_t *l1,Double_t *l2)const{
592 LtoLMomentum(GetModuleIndex(id1[0],id1[1],id1[2]),
593 GetModuleIndex(id2[0],id2[1],id2[2]),l1,l2);}
594 //
595 // Transforms of momentum types of quantities from one detector
596 // local coordinate system (used by ITS tracking) to another detector
597 // local coordinate system (used by ITS tracking) for the detector
598 // module index1 number to the detector module index2 number. The
599 // local coordinates are given in two Double point arrays l1[3],
600 // and l2[3].
601 void LtoLMomentumTracking(Int_t index1,Int_t index2,
602 Double_t *l1,Double_t *l2)const{
603 Double_t g[3]; LtoGMomentumTracking(index1,l1,g);
604 GtoLMomentumTracking(index2,g,l2);}
605 // Transforms of momentum types of quantities from one detector
606 // local coordinate system (used by ITS tracking) to another detector
607 // local coordinate system (used by ITS tracking) for the detector
608 // id1[3] to the detector id2[3]. The local coordinates are given in
609 // two Double point arrays l1[3], and l2[3].
610 void LtoLMomentumTracking(const Int_t *id1,const Int_t *id2,
611 Double_t *l1,Double_t *l2)const{
612 LtoLMomentumTracking(GetModuleIndex(id1[0],id1[1],id1[2]),
613 GetModuleIndex(id2[0],id2[1],id2[2]),l1,l2);}
614 //
615 // Transforms a matrix, like an Uncertainty or Error matrix from
616 // the ALICE Global coordinate system to a detector local coordinate
617 // system. The specific detector is determined by the module index
618 // number.
619 void GtoLErrorMatrix(Int_t index,const Double_t **g,Double_t **l)const{
620 GetGeomMatrix(index)->GtoLPositionError(
621 (Double_t (*)[3])g,(Double_t (*)[3])l);}
622 //
623 // Transforms a matrix, like an Uncertainty or Error matrix from
624 // the ALICE Global coordinate system to a detector local coordinate
625 // system (used by ITS tracking). The specific detector is determined
626 // by the module index number.
627 void GtoLErrorMatrixTracking(Int_t index,const Double_t **g,
628 Double_t **l)const{
629 if(IsGeantToTracking()) GetGeomMatrix(index)->GtoLPositionError((
630 Double_t (*)[3])g,(Double_t (*)[3])l);
631 else GetGeomMatrix(index)->GtoLPositionErrorTracking(
632 (Double_t (*)[3])g,(Double_t (*)[3])l);}
633 //
634 // Transforms a matrix, like an Uncertainty or Error matrix from
635 // the detector local coordinate system to a ALICE Global coordinate
636 // system. The specific detector is determined by the module index
637 // number.
638 void LtoGErrorMatrix(Int_t index,const Double_t **l,Double_t **g)const{
639 GetGeomMatrix(index)->LtoGPositionError(
640 (Double_t (*)[3])l,(Double_t (*)[3])g);}
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(Int_t index,const Double_t l[3][3],Double_t g[3][3])
647 const{
648 GetGeomMatrix(index)->LtoGPositionError(
649 (Double_t (*)[3])l,(Double_t (*)[3])g);}
650
651 //
652 // Transforms a matrix, like an Uncertainty or Error matrix from
653 // the detector local coordinate system (used by ITS tracking) to a
654 // ALICE Global coordinate system. The specific detector is determined
655 // by the module index number.
656 void LtoGErrorMatrixTracking(Int_t index,const Double_t **l,
657 Double_t **g)const{
658 if(IsGeantToTracking()) GetGeomMatrix(index)->LtoGPositionError(
659 (Double_t (*)[3])g,(Double_t (*)[3])l);
660 else GetGeomMatrix(index)->LtoGPositionErrorTracking(
661 (Double_t (*)[3])l,(Double_t (*)[3])g);}
662 //
663 // Transforms a matrix, like an Uncertainty or Error matrix from
664 // the detector local coordinate system (used by ITS tracking) to a
665 // ALICE Global coordinate system. The specific detector is determined
666 // by the module index number.
667 void LtoGErrorMatrixTracking(Int_t index,const Double_t l[3][3],
668 Double_t g[3][3])const{
669 if(IsGeantToTracking()) GetGeomMatrix(index)->LtoGPositionError(
670 (Double_t (*)[3])g,(Double_t (*)[3])l);
671 else GetGeomMatrix(index)->LtoGPositionErrorTracking(
672 (Double_t (*)[3])l,(Double_t (*)[3])g);}
673 //
674 // Transforms a matrix, like an Uncertainty or Error matrix from
675 // one detector local coordinate system to another detector local
676 // coordinate system. The specific detector is determined by the
677 // two module index number index1 and index2.
678 void LtoLErrorMatrix(Int_t index1,Int_t index2,
679 const Double_t **l1,Double_t **l2)const{
680 Double_t g[3][3];
681 LtoGErrorMatrix(index1,l1,(Double_t **)g);
682 GtoLErrorMatrix(index2,(const Double_t **)g,l2);}
683 //
684 // Transforms a matrix, like an Uncertainty or Error matrix from
685 // one detector local coordinate system (used by ITS tracking) to
686 // another detector local coordinate system (used by ITS tracking).
687 // The specific detector is determined by the two module index number
688 // index1 and index2.
689 void LtoLErrorMatrixTraking(Int_t index1,Int_t index2,
690 const Double_t **l1,Double_t **l2)const{
691 Double_t g[3][3];
692 LtoGErrorMatrixTracking(index1,l1,(Double_t **)g);
693 GtoLErrorMatrixTracking(index2,(const Double_t **)g,l2);}
694 // Find Specific Modules
695 // Locate the nearest module to the point g, in ALICE global Cartesian
696 // coordinates [cm] in a give layer. If layer = 0 then it search in
697 // all layers.
698 Int_t GetNearest(const Double_t g[3],Int_t lay=0)const;
699 // Locates the nearest 27 modules, in nearest order, to the point g, in
700 // ALICE global Cartesian coordinates [cm] in a give layer. If layer = 0
701 // then it searches in all layers. (there are 27 elements in a 3x3x3
702 // cube.
703 void GetNearest27(const Double_t g[3],Int_t n[27],Int_t lay=0)const;
704 // Returns the distance [cm] between the point g[3] and the center of
705 // the detector/module specified by the the module index number.
706 Double_t Distance(Int_t index,const Double_t g[3])const{
707 return TMath::Sqrt(GetGeomMatrix(index)->Distance2(g));}
708 // Geometry manipulation
709 // This function performs a Cartesian translation and rotation of
710 // the full ITS from its default position by an amount determined by
711 // the three element arrays tran and rot.
712 void GlobalChange(const Float_t *tran,const Float_t *rot);
713 // This function performs a Cylindrical translation and rotation of
714 // the full ITS from its default position by an amount determined by
715 // the three element arrays tran and rot.
716 void GlobalCylindericalChange(const Float_t *tran,const Float_t *rot);
717 // This function performs a Gaussian random displacement and/or
718 // rotation about the present global position of each active
719 // volume/detector of the ITS with variances given by stran and srot.
720 void RandomChange(const Float_t *stran,const Float_t *srot);
721 // This function performs a Gaussian random displacement and/or
722 // rotation about the present global position of each active
723 // volume/detector of the ITS with variances given by stran and srot.
724 // But in Cylindrical coordinates.
725 void RandomCylindericalChange(const Float_t *stran,const Float_t *srot);
726 // This function converts these transformations from Alice global and
727 // local to Tracking global and local.
728 //
729 // This converts the geometry
730 void GeantToTracking(const AliITSgeom &source);
731 // Other routines.
732 // This routine prints, to a file, the contents of this class.
733 void PrintData(FILE *fp,Int_t lay,Int_t lad,Int_t det)const;
734 // This function prints out this class in a single stream. This steam
735 // can be read by ReadGeom.
736 // (Coverity warnings) void PrintGeom(ostream *out)const;
737
738 //Conversion from det. local coordinates to local ("V2") coordinates
739 //used for tracking
740
741 void DetLToTrackingV2(Int_t md,Float_t xin,Float_t zin,
742 Float_t &yout, Float_t &zout);
743
744 void TrackingV2ToDetL(Int_t md,Float_t yin,Float_t zin,
745 Float_t &xout,Float_t &zout);
746
747 private:
748 TString fVersion; // Transformation version.
749 Int_t fTrans; // Flag to keep track of which transformation
750 Int_t fNmodules;// The total number of modules
751 Int_t fNlayers; // The number of layers.
752 TArrayI fNlad; // Array of the number of ladders/layer(layer)
753 TArrayI fNdet; // Array of the number of detector/ladder(layer)
754 TObjArray fGm; // Structure of translation. and rotation.
755
756 ClassDef(AliITSgeom,4) // ITS geometry class
757};
758// Input and output function for standard C++ input/output.
759
760#endif