1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////
19 // ITS geometry manipulation routines. //
20 // Created April 15 1999. //
22 // By: Bjorn S. Nilsen //
24 // Updated May 27 1999. //
25 // Added Cylindrical random and global based changes. //
27 // Modified and added functions Feb. 7 2006 //
28 ///////////////////////////////////////////////////////////////////////
31 ////////////////////////////////////////////////////////////////////////
32 // The local coordinate system by, default, is show in the following
33 // figures. Also shown are the ladder numbering scheme.
36 <img src="picts/ITS/AliITSgeomMatrix_L1.gif">
39 <font size=+2 color=blue>
40 <p>This shows the relative geometry differences between the ALICE Global
41 coordinate system and the local detector coordinate system.
46 <img src="picts/ITS/its1+2_convention_front_5.gif">
49 <font size=+2 color=blue>
50 <p>This shows the front view of the SPDs and the orientation of the local
51 pixel coordinate system. Note that the inner pixel layer has its y coordinate
52 in the opposite direction from all of the other layers.
57 <img src="picts/ITS/its3+4_convention_front_5.gif">
60 <font size=+2 color=blue>
61 <p>This shows the front view of the SDDs and the orientation of the local
62 pixel coordinate system.
67 <img src="picts/ITS/its5+6_convention_front_5.gif">
70 <font size=+2 color=blue>
71 <p>This shows the front view of the SSDs and the orientation of the local
72 pixel coordinate system.
78 ////////////////////////////////////////////////////////////////////////
80 ////////////////////////////////////////////////////////////////////////
83 // Written by Bjorn S. Nilsen
88 // Transformation version.
90 // Flag to keep track of which transformation
92 // The total number of modules
94 // The number of ITS layers for this geometry. By default this
95 // is 6, but can be modified by the creator function if there are
96 // more layers defined.
99 // A pointer to an array fNlayers long containing the number of
100 // ladders for each layer. This array is typically created and filled
101 // by the AliITSgeom creator function.
104 // A pointer to an array fNlayers long containing the number of
105 // active detector volumes for each ladder. This array is typically
106 // created and filled by the AliITSgeom creator function.
108 // TObjArray fGm containing objects of type AliITSgeomMatrix
109 // A pointer to an array of AliITSgeomMatrix classes. One element
110 // per module (detector) in the ITS. AliITSgeomMatrix basicly contains
111 // all of the necessary information about the detector and it's coordinate
114 ////////////////////////////////////////////////////////////////////////
115 #include <Riostream.h>
122 #include "AliITSgeom.h"
127 //______________________________________________________________________
128 AliITSgeom::AliITSgeom():
130 fVersion("GEANT"),// Transformation version.
131 fTrans(0), // Flag to keep track of which transformation
132 fNmodules(0), // The total number of modules
133 fNlayers(0), // The number of layers.
134 fNlad(), //[] Array of the number of ladders/layer(layer)
135 fNdet(), //[] Array of the number of detector/ladder(layer)
136 fGm(0,0) // Structure of translation. and rotation.
138 // The default constructor for the AliITSgeom class. It, by default,
139 // sets fNlayers to zero and zeros all pointers.
140 // Do not allocate anything zero everything.
146 // a zeroed AliITSgeom object.
152 //______________________________________________________________________
153 AliITSgeom::AliITSgeom(Int_t itype,Int_t nlayers,const Int_t *nlads,
154 const Int_t *ndets,Int_t mods):
156 fVersion("GEANT"), // Transformation version.
157 fTrans(itype), // Flag to keep track of which transformation
158 fNmodules(mods), // The total number of modules
159 fNlayers(nlayers), // The number of layers.
160 fNlad(nlayers,nlads),//[] Array of the number of ladders/layer(layer)
161 fNdet(nlayers,ndets),//[] Array of the number of detector/ladder(layer)
162 fGm(mods,0) // Structure of translation. and rotation.
164 // A simple constructor to set basic geometry class variables
166 // Int_t itype the type of transformation kept.
167 // bit 0 => Standard GEANT
168 // bit 1 => ITS tracking
169 // bit 2 => A change in the coordinate system
170 // has been made. others are still to be defined
172 // Int_t nlayers The number of ITS layers also set the size of
174 // Int_t *nlads an array of the number of ladders for each
175 // layer. This array must be nlayers long.
176 // Int_t *ndets an array of the number of detectors per ladder
177 // for each layer. This array must be nlayers long.
178 // Int_t mods The number of modules. Typically the sum of all the
179 // detectors on every layer and ladder.
183 // A properly inilized AliITSgeom object.
188 //______________________________________________________________________
189 void AliITSgeom::Init(Int_t itype,Int_t nlayers,const Int_t *nlads,
190 const Int_t *ndets,Int_t mods){
191 // A simple Inilizer to set basic geometry class variables
193 // Int_t itype the type of transformation kept.
194 // bit 0 => Standard GEANT
195 // bit 1 => ITS tracking
196 // bit 2 => A change in the coordinate system
197 // has been made. others are still to be defined
199 // Int_t nlayers The number of ITS layers also set the size of
201 // Int_t *nlads an array of the number of ladders for each
202 // layer. This array must be nlayers long.
203 // Int_t *ndets an array of the number of detectors per ladder
204 // for each layer. This array must be nlayers long.
205 // Int_t mods The number of modules. Typically the sum of all the
206 // detectors on every layer and ladder.
210 // A properly inilized AliITSgeom object.
212 fVersion = "GEANT"; // Transformation version.
213 fTrans = itype; // Flag to keep track of which transformation
214 fNmodules = mods; // The total number of modules
215 fNlayers = nlayers; // The number of layers.
216 fNlad.Set(nlayers,nlads);//[] Array of the number of ladders/layer(layer)
217 fNdet.Set(nlayers,ndets);//[] Array of the number of detector/ladder(layer)
219 fGm.Expand(mods); // Structure of translation. and rotation.
223 //______________________________________________________________________
224 void AliITSgeom::CreateMatrix(Int_t mod,Int_t lay,Int_t lad,Int_t det,
225 AliITSDetector idet,const Double_t tran[3],
226 const Double_t rot[10]){
227 // Given the translation vector tran[3] and the rotation matrix rot[1],
228 // this function creates and adds to the TObject Array fGm the
229 // AliITSgeomMatrix object.
230 // The rot[10] matrix is set up like:
231 /* / rot[0] rot[1] rot[2] \
232 // | rot[3] rot[4] rot[5] |
233 // \ rot[6] rot[7] rot[8] / if(rot[9]!=0) then the Identity matrix
234 // is used regardless of the values in rot[0]-rot[8].
237 // Int_t mod The module number. The location in TObjArray
238 // Int_t lay The layer where this module is
239 // Int_t lad On which ladder this module is
240 // Int_t det Which detector on this ladder this module is
241 // AliITSDetector idet The type of detector see AliITSgeom.h
242 // Double_t tran[3] The translation vector
243 // Double_t rot[10] The rotation matrix.
249 Double_t r[3][3] = {{1.0,0.0,0.0},{0.0,1.0,0.0},{0.0,0.0,1.0}};
251 if(mod<0||mod>=fGm.GetSize()){
252 Error("CreateMatrix","mod=%d is out of bounds max value=%d",mod,
257 id[0] = lay; id[1] = lad; id[2] = det;
258 if(rot[9]!=0.0) { // null rotation
259 r[0][0] = rot[0]; r[0][1] = rot[1]; r[0][2] = rot[2];
260 r[1][0] = rot[3]; r[1][1] = rot[4]; r[1][2] = rot[5];
261 r[2][0] = rot[6]; r[2][1] = rot[7]; r[2][2] = rot[8];
263 fGm.AddAt(new AliITSgeomMatrix(idet,id,r,tran),mod);
265 //______________________________________________________________________
266 AliITSgeom::~AliITSgeom(){
267 // The destructor for the AliITSgeom class. If the arrays fNlad,
268 // fNdet, or fGm have had memory allocated to them, there pointer values
269 // are non zero, then this memory space is freed and they are set
270 // to zero. In addition, fNlayers is set to zero. The destruction of
280 //______________________________________________________________________
281 AliITSgeom::AliITSgeom(const AliITSgeom &source) :
283 fVersion(source.fVersion), // Transformation version.
284 fTrans(source.fTrans), // Flag to keep track of which transformation
285 fNmodules(source.fNmodules),// The total number of modules
286 fNlayers(source.fNlayers), // The number of layers.
287 fNlad(source.fNlad), // Array of the number of ladders/layer(layer)
288 fNdet(source.fNdet), // Array of the number of detector/ladder(layer)
289 fGm(source.fGm.GetSize(),source.fGm.LowerBound())// Structure of
290 // translation and rotation.
292 // The copy constructor for the AliITSgeom class. It calls the
293 // = operator function. See the = operator function for more details.
295 // AliITSgeom &source The AliITSgeom class with which to make this
303 n = source.fGm.GetLast()+1;
304 for(i=source.fGm.LowerBound();i<n;i++){
305 fGm.AddAt(new AliITSgeomMatrix(*((AliITSgeomMatrix*)(
306 source.fGm.At(i)))),i);
311 //______________________________________________________________________
312 AliITSgeom& AliITSgeom::operator=(const AliITSgeom &source){
313 // The = operator function for the AliITSgeom class. It makes an
314 // independent copy of the class in such a way that any changes made
315 // to the copied class will not affect the source class in any way.
316 // This is required for many ITS alignment studies where the copied
317 // class is then modified by introducing some misalignment.
319 // AliITSgeom &source The AliITSgeom class with which to make this
324 // *this The a new copy of source.
327 if(this == &source) return *this; // don't assign to ones self.
329 // if there is an old structure allocated delete it first.
332 this->fVersion = source.fVersion;
333 this->fTrans = source.fTrans;
334 this->fNmodules = source.fNmodules;
335 this->fNlayers = source.fNlayers;
336 this->fNlad = source.fNlad;
337 this->fNdet = source.fNdet;
338 this->fGm.Expand(this->fNmodules);
339 for(i=source.fGm.LowerBound();i<source.fGm.GetLast();i++){
340 fGm.AddAt(new AliITSgeomMatrix(*((AliITSgeomMatrix*)(
341 source.fGm.At(i)))),i);
346 //______________________________________________________________________
347 Int_t AliITSgeom::GetModuleIndex(Int_t lay,Int_t lad,Int_t det)const{
348 // This routine computes the module index number from the layer,
349 // ladder, and detector numbers. The number of ladders and detectors
350 // per layer is determined when this geometry package is constructed,
351 // see AliITSgeom(const char *filename) for specifics.
353 // Int_t lay The layer number. Starting from 1.
354 // Int_t lad The ladder number. Starting from 1.
355 // Int_t det The detector number. Starting from 1.
359 // the module index number, starting from zero.
362 i = fNdet[lay-1] * (lad-1) + det - 1;
364 for(k=0;k<lay-1;k++) j += fNdet[k]*fNlad[k];
366 if(i>=fNmodules) return -1;
367 GetGeomMatrix(i)->GetIndex(id);
368 if(id[0]==lay&&id[1]==lad&&id[2]==det) return i;
369 // Array of modules fGm is not in expected order. Search for this index
370 for(i=0;i<fNmodules;i++){
371 GetGeomMatrix(i)->GetIndex(id);
372 if(id[0]==lay&&id[1]==lad&&id[2]==det) return i;
374 // This layer ladder and detector combination does not exist return -1.
377 //______________________________________________________________________
378 void AliITSgeom::GetModuleId(Int_t index,Int_t &lay,Int_t &lad,Int_t &det)
380 // This routine computes the layer, ladder and detector number
381 // given the module index number. The number of ladders and detectors
382 // per layer is determined when this geometry package is constructed,
383 // see AliITSgeom(const char *filename) for specifics.
385 // Int_t index The module index number, starting from zero.
387 // Int_t lay The layer number. Starting from 1.
388 // Int_t lad The ladder number. Starting from 1.
389 // Int_t det The detector number. Starting from 1.
393 AliITSgeomMatrix *g = GetGeomMatrix(index);
396 Error("GetModuleId","Can not get GeoMatrix for index = %d",index);
397 lay = -1; lad = -1; det = -1;
400 lay = id[0]; lad = id[1]; det = id[2];
403 // The old way kept for posterity.
407 for(k=0;k<fNlayers;k++){
408 j += fNdet[k]*fNlad[k];
412 i = index -j + fNdet[k]*fNlad[k];
414 for(k=0;k<fNlad[lay-1];k++){
419 det = 1+i-fNdet[lay-1]*k;
423 //______________________________________________________________________
424 Int_t AliITSgeom::GetNDetTypes(Int_t &max)const{
425 // Finds and returns the number of detector types used and the
426 // maximum detector type value. Only counts id >=0 (no undefined
427 // values. See AliITSgeom.h for list of AliITSDetecor enumerated types.
431 // The maximum detector type used
433 // The number of detector types used
437 for(i=0;i<GetIndexMax();i++){
438 id = GetModuleType(i);
441 n = new Int_t[max+1];
442 for(i=0;i<max;i++) n[i] = 0;
443 for(i=0;i<GetIndexMax();i++){
444 id = GetModuleType(i);
445 if(id>-1)n[id]++; // note id=-1 => undefined.
448 for(i=0;i<max;i++) if(n[i]!=0) id++;
452 //______________________________________________________________________
453 Int_t AliITSgeom::GetNDetTypes(TArrayI &maxs,AliITSDetector *types)const{
454 // Finds and returns the number of detector types used and the
455 // number of each detector type. Only counts id >=0 (no undefined
456 // values. See AliITSgeom.h for list of AliITSDetecor enumerated types.
460 // The maximum detector type used
462 // The number of detector types used
466 for(i=0;i<GetIndexMax();i++){
467 id = GetModuleType(i);
470 n = new Int_t[max+1];
471 for(i=0;i<max;i++) n[i] = 0;
472 for(i=0;i<GetIndexMax();i++){
473 id = GetModuleType(i);
474 if(id>-1)n[id]++; // note id=-1 => undefined.
477 for(i=0;i<=max;i++) if(n[i]!=0) id++;
480 for(i=0;i<=max;i++) if(n[i]!=0){
482 types[j++] = (AliITSDetector) i;
483 } // end for i/end if
487 //______________________________________________________________________
488 Int_t AliITSgeom::GetStartDet(Int_t dtype)const{
489 // returns the starting module index value for a give type of detector id.
490 // This assumes that the detector types are different on different layers
491 // and that they are not mixed up.
493 // Int_t dtype A detector type number. 0 for SPD, 1 for SDD,
498 // the module index for the first occurrence of that detector type.
502 return GetModuleIndex(1,1,1);
505 return GetModuleIndex(3,1,1);
508 return GetModuleIndex(5,1,1);
511 Warning("GetStartDet","undefined detector type %d",dtype);
515 Warning("GetStartDet","undefined detector type %d",dtype);
518 //______________________________________________________________________
519 Int_t AliITSgeom::GetLastDet(Int_t dtype)const{
520 // returns the last module index value for a give type of detector id.
521 // This assumes that the detector types are different on different layers
522 // and that they are not mixed up.
524 // Int_t dtype A detector type number. 0 for SPD, 1 for SDD,
528 // the module index for the last occurrence of that detector type.
530 switch((AliITSDetector)dtype){
532 return GetModuleIndex(3,1,1)-1;
535 return GetModuleIndex(5,1,1)-1;
538 return GetIndexMax()-1;
540 case kSSDp: case kSDDp: case kND:
542 Warning("GetLastDet","undefined detector type %d",dtype);
546 Warning("GetLastDet","undefined detector type %d",dtype);
550 //______________________________________________________________________
551 void AliITSgeom::PrintData(FILE *fp,Int_t lay,Int_t lad,Int_t det)const{
552 // This function prints out the coordinate transformations for
553 // the particular detector defined by layer, ladder, and detector
554 // to the file pointed to by the File pointer fp. fprintf statements
555 // are used to print out the numbers. The format is
556 // layer ladder detector Trans= fx0 fy0 fz0 rot= frx fry frz
558 // dfr= fr[0] fr[1] fr[2]
559 // dfr= fr[3] fr[4] fr[5]
560 // dfr= fr[6] fr[7] fr[8]
561 // By indicating which detector, some control over the information
562 // is given to the user. The output it written to the file pointed
563 // to by the file pointer fp. This can be set to stdout if you want.
565 // FILE *fp A file pointer to an opened file for
566 // writing in which the results of the
567 // comparison will be written.
568 // Int_t lay The layer number. Starting from 1.
569 // Int_t lad The ladder number. Starting from 1.
570 // Int_t det The detector number. Starting from 1.
575 AliITSgeomMatrix *gt;
576 Double_t t[3],r[3],m[3][3];
578 gt = this->GetGeomMatrix(GetModuleIndex(lay,lad,det));
579 gt->GetTranslation(t);
581 fprintf(fp,"%1.1d %2.2d %2.2d Trans=%f %f %f rot=%f %f %f Shape=%d\n",
582 lay,lad,det,t[0],t[1],t[2],r[0],r[1],r[2],
583 gt->GetDetectorIndex());
585 fprintf(fp," dfr= %e %e %e\n",m[0][0],m[0][1],m[0][2]);
586 fprintf(fp," dfr= %e %e %e\n",m[1][0],m[1][1],m[1][2]);
587 fprintf(fp," dfr= %e %e %e\n",m[2][0],m[2][1],m[2][2]);
591 //______________________________________________________________________
592 void AliITSgeom::PrintGeom(ostream *wb)const{
593 // Stream out an object of class AliITSgeom to standard output.
595 // ofstream *wb The output streaming buffer.
602 wb->setf(ios::scientific);
603 streamsize stsiz = wb->precision();
604 *wb << fTrans << " ";
605 *wb << fNmodules << " ";
606 *wb << fNlayers << " ";
607 for(i=0;i<fNlayers;i++) *wb << fNlad[i] << " ";
608 for(i=0;i<fNlayers;i++) *wb << fNdet[i] << "\n";
609 for(i=0;i<fNmodules;i++) {
610 *wb <<setprecision(16) << *(GetGeomMatrix(i)) << "\n";
612 *wb << setprecision (stsiz);
616 //______________________________________________________________________
617 // The following routines modify the transformation of "this"
618 // geometry transformations in a number of different ways.
619 //______________________________________________________________________
620 void AliITSgeom::GlobalChange(const Float_t *tran,const Float_t *rot){
621 // This function performs a Cartesian translation and rotation of
622 // the full ITS from its default position by an amount determined by
623 // the three element arrays tran and rot. If every element
624 // of tran and rot are zero then there is no change made
625 // the geometry. The change is global in that the exact same translation
626 // and rotation is done to every detector element in the exact same way.
627 // The units of the translation are those of the Monte Carlo, usually cm,
628 // and those of the rotation are in radians. The elements of tran
629 // are tran[0] = x, tran[1] = y, and tran[2] = z.
630 // The elements of rot are rot[0] = rx, rot[1] = ry, and
631 // rot[2] = rz. A change in x will move the hole ITS in the ALICE
632 // global x direction, the same for a change in y. A change in z will
633 // result in a translation of the ITS as a hole up or down the beam line.
634 // A change in the angles will result in the inclination of the ITS with
635 // respect to the beam line, except for an effective rotation about the
636 // beam axis which will just rotate the ITS as a hole about the beam axis.
638 // Float_t *tran A 3 element array representing the global
639 // translations. the elements are x,y,z in cm.
640 // Float_t *rot A 3 element array representing the global rotation
641 // angles about the three axis x,y,z in radians
650 fTrans = (fTrans && 0xfffd) + 2; // set bit 1 true.
651 for(i=0;i<fNmodules;i++){
652 g = this->GetGeomMatrix(i);
653 g->GetTranslation(t);
659 g->SetTranslation(t);
664 //______________________________________________________________________
665 void AliITSgeom::GlobalCylindericalChange(const Float_t *tran,
667 // This function performs a cylindrical translation and rotation of
668 // each ITS element by a fixed about in radius, rphi, and z from its
669 // default position by an amount determined by the three element arrays
670 // tran and rot. If every element of tran and
671 // rot are zero then there is no change made the geometry. The
672 // change is global in that the exact same distance change in translation
673 // and rotation is done to every detector element in the exact same way.
674 // The units of the translation are those of the Monte Carlo, usually cm,
675 // and those of the rotation are in radians. The elements of tran
676 // are tran[0] = r, tran[1] = rphi, and tran[2] = z.
677 // The elements of rot are rot[0] = rx, rot[1] = ry, and
678 // rot[2] = rz. A change in r will results in the increase of the
679 // radius of each layer by the same about. A change in rphi will results in
680 // the rotation of each layer by a different angle but by the same
681 // circumferential distance. A change in z will result in a translation
682 // of the ITS as a hole up or down the beam line. A change in the angles
683 // will result in the inclination of the ITS with respect to the beam
684 // line, except for an effective rotation about the beam axis which will
685 // just rotate the ITS as a hole about the beam axis.
687 // Float_t *tran A 3 element array representing the global
688 // translations. the elements are r,theta,z in
690 // Float_t *rot A 3 element array representing the global rotation
691 // angles about the three axis x,y,z in radians
697 Double_t t[3],ro[3],r,r0,phi,rphi;
700 fTrans = (fTrans && 0xfffd) + 2; // set bit 1 true.
701 for(i=0;i<fNmodules;i++){
702 g = this->GetGeomMatrix(i);
703 g->GetTranslation(t);
705 r = r0= TMath::Hypot(t[1],t[0]);
706 phi = TMath::ATan2(t[1],t[0]);
711 t[0] = r*TMath::Cos(phi);
712 t[1] = r*TMath::Sin(phi);
717 g->SetTranslation(t);
722 //______________________________________________________________________
723 void AliITSgeom::RandomChange(const Float_t *stran,const Float_t *srot){
724 // This function performs a Gaussian random displacement and/or
725 // rotation about the present global position of each active
726 // volume/detector of the ITS. The sigma of the random displacement
727 // is determined by the three element array stran, for the
728 // x y and z translations, and the three element array srot,
729 // for the three rotation about the axis x y and z.
731 // Float_t *stran A 3 element array representing the global
732 // translations variances. The elements are x,
734 // Float_t *srot A 3 element array representing the global rotation
735 // angles variances about the three axis x,y,z in
745 fTrans = (fTrans && 0xfffd) + 2; // set bit 1 true.
746 for(i=0;i<fNmodules;i++){
747 g = this->GetGeomMatrix(i);
748 g->GetTranslation(t);
751 t[j] += gRandom->Gaus(0.0,stran[j]);
752 r[j] += gRandom->Gaus(0.0, srot[j]);
754 g->SetTranslation(t);
759 //______________________________________________________________________
760 void AliITSgeom::RandomCylindericalChange(const Float_t *stran,
761 const Float_t *srot){
762 // This function performs a Gaussian random displacement and/or
763 // rotation about the present global position of each active
764 // volume/detector of the ITS. The sigma of the random displacement
765 // is determined by the three element array stran, for the
766 // r rphi and z translations, and the three element array srot,
767 // for the three rotation about the axis x y and z. This random change
768 // in detector position allow for the simulation of a random uncertainty
769 // in the detector positions of the ITS.
771 // Float_t *stran A 3 element array representing the global
772 // translations variances. The elements are r,
773 // theta,z in cm/radians.
774 // Float_t *srot A 3 element array representing the global rotation
775 // angles variances about the three axis x,y,z in
782 Double_t t[3],ro[3],r,r0,phi,rphi;
786 fTrans = (fTrans && 0xfffd) + 2; // set bit 1 true.
787 for(i=0;i<fNmodules;i++){
788 g = this->GetGeomMatrix(i);
789 g->GetTranslation(t);
791 r = r0= TMath::Hypot(t[1],t[0]);
792 phi = TMath::ATan2(t[1],t[0]);
794 r += ran.Gaus(0.0,stran[0]);
795 rphi += ran.Gaus(0.0,stran[1]);
797 t[0] = r*TMath::Cos(phi);
798 t[1] = r*TMath::Sin(phi);
799 t[2] += ran.Gaus(0.0,stran[2]);
801 ro[j] += ran.Gaus(0.0, srot[j]);
803 g->SetTranslation(t);
808 //______________________________________________________________________
809 void AliITSgeom::GeantToTracking(const AliITSgeom &source){
810 // Copy the geometry data but change it to go between the ALICE
811 // Global coordinate system to that used by the ITS tracking. A slightly
812 // different coordinate system is used when tracking. This coordinate
813 // system is only relevant when the geometry represents the cylindrical
814 // ALICE ITS geometry. For tracking the Z axis is left alone but X-> -Y
815 // and Y-> X such that X always points out of the ITS cylinder for every
816 // layer including layer 1 (where the detectors are mounted upside down).
819 <img src="picts/ITS/AliITSgeomMatrix_T1.gif">
823 // AliITSgeom &source The AliITSgeom class with which to make this
830 Double_t r0[3][3],r1[3][3];
831 Double_t a0[3][3] = {{0.,+1.,0.},{-1.,0.,0.},{0.,0.,+1.}};
832 Double_t a1[3][3] = {{0.,-1.,0.},{+1.,0.,0.},{0.,0.,+1.}};
834 *this = source; // copy everything
835 for(i=0;i<GetIndexMax();i++){
836 GetGeomMatrix(i)->GetIndex(id);
837 GetGeomMatrix(i)->GetMatrix(r0);
838 if(id[0]==1){ // Layer 1 is treated different from the others.
839 for(j=0;j<3;j++) for(k=0;k<3;k++){
841 for(l=0;l<3;l++) r1[j][k] += a0[j][l]*r0[l][k];
844 for(j=0;j<3;j++) for(k=0;k<3;k++){
846 for(l=0;l<3;l++) r1[j][k] += a1[j][l]*r0[l][k];
849 GetGeomMatrix(i)->SetMatrix(r1);
851 this->fTrans = (this->fTrans && 0xfffe) + 1; // set bit 0 true.
854 //______________________________________________________________________
855 Int_t AliITSgeom::GetNearest(const Double_t g[3],Int_t lay)const{
856 // Finds the Detector (Module) that is nearest the point g [cm] in
857 // ALICE Global coordinates. If layer !=0 then the search is restricted
858 // to Detectors (Modules) in that particular layer.
860 // Double_t g[3] The ALICE Cartesian global coordinate from which the
861 // distance is to be calculated with.
862 // Int_t lay The layer to restrict the search to. If layer=0 then
863 // all layers are searched. Default is lay=0.
867 // The module number representing the nearest module.
869 Double_t d,dn=1.0e10;
870 Bool_t t=lay!=0; // skip if lay = 0 default value check all layers.
872 for(i=0;i<fNmodules;i++){
873 if(t){GetModuleId(i,l,a,e);if(l!=lay) continue;}
874 if((d=GetGeomMatrix(i)->Distance2(g))<dn){
881 //______________________________________________________________________
882 void AliITSgeom::GetNearest27(const Double_t g[3],Int_t n[27],Int_t lay)const{
883 // Finds 27 Detectors (Modules) that are nearest the point g [cm] in
884 // ALICE Global coordinates. If layer !=0 then the search is restricted
885 // to Detectors (Modules) in that particular layer. The number 27 comes
886 // from including the nearest detector and all those around it (up, down,
887 // left, right, forwards, backwards, and the corners).
889 // Double_t g[3] The ALICE Cartesian global coordinate from which the
890 // distance is to be calculated with.
891 // Int_t lay The layer to restrict the search to. If layer=0 then
892 // all layers are searched. Default is lay=0.
894 // Int_t n[27] The module number representing the nearest 27 modules
898 Int_t i,l,a,e,in[27]={0,0,0,0,0,0,0,0,0,
901 Double_t d,dn[27]={1.0e10,1.0e10,1.0e10,1.0e10,1.0e10,1.0e10,
902 1.0e10,1.0e10,1.0e10,1.0e10,1.0e10,1.0e10,
903 1.0e10,1.0e10,1.0e10,1.0e10,1.0e10,1.0e10,
904 1.0e10,1.0e10,1.0e10,1.0e10,1.0e10,1.0e10,
905 1.0e10,1.0e10,1.0e10};
906 Bool_t t=(lay!=0); // skip if lay = 0 default value check all layers.
908 for(i=0;i<fNmodules;i++){
909 if(t){GetModuleId(i,l,a,e);if(l!=lay) continue;}
911 d = GetGeomMatrix(i)->Distance2(g);
913 for(e=26;e>a;e--){dn[e] = dn[e-1];in[e] = in[e-1];}
914 dn[a] = d; in[a] = i;
918 for(i=0;i<27;i++) n[i] = in[i];
920 //_______________________________________________________________________
921 void AliITSgeom::DetLToTrackingV2(Int_t md,Float_t xin,Float_t zin,
922 Float_t &yout,Float_t &zout) const {
924 //Conversion from local coordinates on detectors to local
925 //coordinates used for tracking ("v2")
927 // Int_t md Module number
928 // Float_t xin Standard local coordinate x
929 // Float_t zin Standard local coordinate z
931 // Float_t yout Tracking local coordinate y
932 // Float_t zout Tracking local coordinate z
940 al = TMath::ATan2(rt[1],rt[0])+TMath::Pi();
941 yout = -(-xin+(x*((Float_t)TMath::Cos(al))+y*((Float_t)TMath::Sin(al))));
942 if(md<(GetModuleIndex(2,1,1))) yout *= -1;
945 //_______________________________________________________________________
946 void AliITSgeom::TrackingV2ToDetL(Int_t md,Float_t yin,Float_t zin,
947 Float_t &xout,Float_t &zout) const {
948 //Conversion from local coordinates used for tracking ("v2") to
949 //local detector coordinates
951 // Int_t md Module number
952 // Float_t yin Tracking local coordinate y
953 // Float_t zin Tracking local coordinate z
955 // Float_t xout Standard local coordinate x
956 // Float_t zout Standard local coordinate z
964 al = TMath::ATan2(rt[1],rt[0])+TMath::Pi();
966 if(md<(GetModuleIndex(2,1,1))) xout = -xout;
967 xout += (x*((Float_t)TMath::Cos(al))+y*((Float_t)TMath::Sin(al)));
970 //----------------------------------------------------------------------