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