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