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