]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSgeom.cxx
update for the NUA
[u/mrichter/AliRoot.git] / ITS / AliITSgeom.cxx
index bee4a80502246706b61d4d8e119f323b088d4386..502f8b0716c010abe6b23d0f4dc8388f51369293 100644 (file)
@@ -23,7 +23,7 @@
 // version: 0.0.1                                                    //
 // Updated May 27 1999.                                              //
 // Added Cylindrical random and global based changes.                //
-// Added  function PrintComparison.                                  //
+//                                                                   //
 // Modified and added functions Feb. 7 2006                          //
 ///////////////////////////////////////////////////////////////////////
 
@@ -111,28 +111,14 @@ pixel coordinate system.
 // all of the necessary information about the detector and it's coordinate
 // transformations.
 //
-// TObjArray fShape containting objects of type AliITSgeom
-//     A pointer to an array of TObjects containing the detailed shape
-// information for each type of detector used in the ITS. For example
-// I have created AliITSgeomSPD, AliITSgeomSDD, and 
-// AliITSsegmenttionSSD as example structures, derived from TObjects, 
-// to hold the detector information. I would recommend that one element 
-// in each of these structures, that which describes the shape of the 
-// active volume, be one of the ROOT classes derived from TShape. In this 
-// way it would be easy to have the display program display the correct 
-// active ITS volumes. See the example classes AliITSgeomSPD, 
-// AliITSgeomSDD, and AliITSgeomSSD for a more detailed 
-// example.
 ////////////////////////////////////////////////////////////////////////
 #include <Riostream.h>
+#include <ctype.h>
 
 #include <TRandom.h>
 #include <TSystem.h>
 #include <TArrayI.h>
 
-#include "AliITSgeomSPD.h"
-#include "AliITSgeomSDD.h"
-#include "AliITSgeomSSD.h"
 #include "AliITSgeom.h"
 #include "AliLog.h"
 
@@ -147,8 +133,7 @@ fNmodules(0),    // The total number of modules
 fNlayers(0),     // The number of layers.
 fNlad(),         //[] Array of the number of ladders/layer(layer)
 fNdet(),         //[] Array of the number of detector/ladder(layer)
-fGm(0,0),        // Structure of translation. and rotation.
-fShape(0,0)      // Array of shapes and detector information.
+fGm(0,0)        // Structure of translation. and rotation.
 {
     //     The default constructor for the AliITSgeom class. It, by default,
     // sets fNlayers to zero and zeros all pointers.
@@ -161,9 +146,9 @@ fShape(0,0)      // Array of shapes and detector information.
     //    a zeroed AliITSgeom object.
 
     fGm.SetOwner(kTRUE);
-    fShape.SetOwner(kTRUE);
     return;
 }
+
 //______________________________________________________________________
 AliITSgeom::AliITSgeom(Int_t itype,Int_t nlayers,const Int_t *nlads,
                        const Int_t *ndets,Int_t mods):
@@ -174,21 +159,22 @@ fNmodules(mods),     // The total number of modules
 fNlayers(nlayers),   // The number of layers.
 fNlad(nlayers,nlads),//[] Array of the number of ladders/layer(layer)
 fNdet(nlayers,ndets),//[] Array of the number of detector/ladder(layer)
-fGm(mods,0),         // Structure of translation. and rotation.
-fShape(5,0)          // Array of shapes and detector information.
+fGm(mods,0)         // Structure of translation. and rotation.
 {
     //     A simple constructor to set basic geometry class variables
     // Inputs:
     //      Int_t itype   the type of transformation kept.
     //                    bit 0 => Standard GEANT
     //                    bit 1 => ITS tracking
-    //                    bit 2 => A change in the coordinate system has been made.
-    //                    others are still to be defined as needed.
-    //      Int_t nlayers The number of ITS layers also set the size of the arrays
-    //      Int_t *nlads  an array of the number of ladders for each layer. This
-    //                    array must be nlayers long.
-    //      Int_t *ndets  an array of the number of detectors per ladder for each
+    //                    bit 2 => A change in the coordinate system 
+    //                    has been made. others are still to be defined 
+    //                    as needed.
+    //      Int_t nlayers The number of ITS layers also set the size of 
+    //                    the arrays
+    //      Int_t *nlads  an array of the number of ladders for each 
     //                    layer. This array must be nlayers long.
+    //      Int_t *ndets  an array of the number of detectors per ladder
+    //                    for each layer. This array must be nlayers long.
     //      Int_t mods    The number of modules. Typically the sum of all the 
     //                    detectors on every layer and ladder.
     // Outputs:
@@ -197,7 +183,6 @@ fShape(5,0)          // Array of shapes and detector information.
     //     A properly inilized AliITSgeom object.
 
     fGm.SetOwner(kTRUE);
-    fShape.SetOwner(kTRUE);
     return;
 }
 //______________________________________________________________________
@@ -208,13 +193,15 @@ void AliITSgeom::Init(Int_t itype,Int_t nlayers,const Int_t *nlads,
     //      Int_t itype   the type of transformation kept.
     //                    bit 0 => Standard GEANT
     //                    bit 1 => ITS tracking
-    //                    bit 2 => A change in the coordinate system has been made.
-    //                    others are still to be defined as needed.
-    //      Int_t nlayers The number of ITS layers also set the size of the arrays
-    //      Int_t *nlads  an array of the number of ladders for each layer. This
-    //                    array must be nlayers long.
-    //      Int_t *ndets  an array of the number of detectors per ladder for each
+    //                    bit 2 => A change in the coordinate system 
+    //                    has been made. others are still to be defined 
+    //                    as needed.
+    //      Int_t nlayers The number of ITS layers also set the size of 
+    //                    the arrays
+    //      Int_t *nlads  an array of the number of ladders for each 
     //                    layer. This array must be nlayers long.
+    //      Int_t *ndets  an array of the number of detectors per ladder 
+    //                    for each layer. This array must be nlayers long.
     //      Int_t mods    The number of modules. Typically the sum of all the 
     //                    detectors on every layer and ladder.
     // Outputs:
@@ -231,9 +218,6 @@ void AliITSgeom::Init(Int_t itype,Int_t nlayers,const Int_t *nlads,
     fGm.Clear();
     fGm.Expand(mods);        // Structure of translation. and rotation.
     fGm.SetOwner(kTRUE);
-    fShape.Clear();
-    fShape.Expand(5);         // Array of shapes and detector information.
-    fShape.SetOwner(kTRUE);
     return;
 }
 //______________________________________________________________________
@@ -284,7 +268,6 @@ AliITSgeom::~AliITSgeom(){
     // fNdet, or fGm have had memory allocated to them, there pointer values
     // are non zero, then this memory space is freed and they are set
     // to zero. In addition, fNlayers is set to zero. The destruction of
-    // TObjArray fShape is, by default, handled by the TObjArray destructor.
     // Inputs:
     //    none.
     // Outputs:
@@ -295,331 +278,17 @@ AliITSgeom::~AliITSgeom(){
     return;
 }
 //______________________________________________________________________
-void AliITSgeom::ReadNewFile(const char *filename){
-    // It is generally preferred to define the geometry in AliITSgeom
-    // directly from the GEANT geometry, see AliITSvPPRasymm.cxx for
-    // and example. Under some circumstances this may not be possible.
-    // This function will read in a formatted file for all of the
-    // information needed to define the geometry in AliITSgeom.
-    // Unlike the older file format, this file may contain comments
-    // and the order of the data does not need to be completely
-    // respected. A file can be created using the function WriteNewFile
-    // defined below.
-    // Inputs:
-    //    const char *filename The file name of the file to be read in.
-    // Outputs:
-    //     none
-    // Return:
-    //     none.
-    Int_t ncmd=9;
-    const char *cmda[]={"Version"        ,"fTrans"  ,"fNmodules",
-                       "fNlayers"       ,"fNladers","fNdetectors",
-                       "fNDetectorTypes","fShape"  ,"Matrix"};
-    Int_t i,j,lNdetTypes,ldet;
-    char cmd[20],c;
-    AliITSgeomMatrix *m=0;
-    ifstream *fp=0;
-    char *filtmp=0;
-    Bool_t arrayGm = kFALSE, arrayShape = kFALSE;
-
-    filtmp = gSystem->ExpandPathName(filename);
-    AliInfo(Form("Reading New .det file %s",filtmp));
-    fp = new ifstream(filtmp,ios::in);  // open file to write
-    while(fp->get(c)!=NULL){ // for ever loop
-        if(c==' ') continue; // remove blanks
-        if(c=='\n') continue;
-        if(c=='#' || c=='!') {while(fp->get(c)) if(c=='\n') break; continue;}
-        if(c=='/'){
-            fp->get(c);{
-                if(c=='/') {while(fp->get(c)) if(c=='\n') break; continue;}
-                if(c=='*'){
-                  NotYet:
-                    while(fp->get(c)) if(c=='*') break;
-                    fp->get(c);{
-                        if(c=='/') continue;
-                        goto NotYet;
-                    } //
-                } // end if c=='*'
-            } // end if second /
-        } // end if first /
-        fp->putback(c);
-        *fp >> cmd;
-        for(i=0;i<ncmd;i++) if(strcmp(cmd,cmda[i])==0) break;
-        switch (i){
-        case 0:   // Version
-            *fp >> j;
-            fVersion.Resize(j);
-            for(j=0;j<fVersion.Length();j++) *fp >> fVersion[j];
-            break;
-        case 1:  // fTrans
-            *fp >> fTrans;
-            break;
-        case 2:  // fNModules
-            *fp >> fNmodules;
-            fGm.Clear();
-            fGm.Expand(fNmodules);
-            fGm.SetOwner(kTRUE);
-            arrayGm = kTRUE;
-            break;
-        case 3:  // fNlayers
-            *fp >> fNlayers;
-            fNlad.Set(fNlayers);
-            fNdet.Set(fNlayers);
-            break;
-        case 4:  // fNladers
-            for(j=0;j<fNlayers;j++) *fp >> fNlad[j];
-            break;
-        case 5:  // fNdetectors
-            for(j=0;j<fNlayers;j++) *fp >> fNdet[j];
-            break;
-        case 6:  // fNDetectorTypes
-            *fp >> lNdetTypes;
-            fShape.Clear();
-            fShape.Expand(lNdetTypes);
-            fShape.SetOwner(kTRUE);
-            arrayShape = kTRUE;
-            break;
-        case 7:  // fShape
-            *fp >> ldet;
-            if(!arrayShape) fShape.Expand(5);
-            fShape.SetOwner(kTRUE);
-            switch (ldet){
-            case kSPD :{
-                AliITSgeomSPD *spd = new AliITSgeomSPD();
-                *fp >> *spd;
-                ReSetShape(ldet,spd);
-            } break;
-            case kSDD : case kSDDp:{
-                AliITSgeomSDD *sdd = new AliITSgeomSDD();
-                *fp >> *sdd;
-                ReSetShape(ldet,sdd);
-            }break;
-            case kSSD : case kSSDp :{
-                AliITSgeomSSD *ssd = new AliITSgeomSSD();
-                *fp >> *ssd;
-                ReSetShape(ldet,ssd);
-            }break;
-            default:{
-                AliError(Form("Unknown fShape type number=%d c=%c",ldet,c));
-                while(fp->get(c)) if(c=='\n') break; // skip to end of line.
-            }break;
-            } // end switch
-            break;
-        case 8:  // Matrix
-            *fp >> ldet;
-            if(!arrayGm){
-                fGm.Clear();
-                fGm.Expand(2270);
-                arrayGm = kTRUE;
-            } // end if
-           if(ldet<0||ldet>=fGm.GetSize()){
-               Error("ReadNewFile","ldet<0||ldet>=fGm.GetSize()=%d",
-                     ldet,fGm.GetSize());
-               return;
-           } // end if
-            delete fGm.At(ldet);
-            fGm.AddAt((TObject*)new AliITSgeomMatrix(),ldet);
-            m = (AliITSgeomMatrix*) fGm.At(ldet);
-            *fp >> *m;
-            m = 0;
-            break;
-        default:
-            AliError(Form("ReadNewFile","Data line i=%d c=%c",i,c));
-            while(fp->get(c)) if(c=='\n') break; // skip this line
-            break;
-        } // end switch i
-    } // end while
-    delete fp;
-
-    return;
-}
-//______________________________________________________________________
-void AliITSgeom::WriteNewFile(const char *filename){
-    // Writes AliITSgeom, AliITSgeomMatrix, and the defined 
-    // AliITSgeomS*D classes to a file in a format that 
-    // is more readable and commendable.
-    // Inputs:
-    //     const char *filename The file name of the file to be write to.
-    // Outputs:
-    //     none
-    // Return:
-    //     none
-    ofstream *fp;
-    Int_t i;
-    char *filtmp;
-
-    filtmp = gSystem->ExpandPathName(filename);
-    fp = new ofstream(filtmp,ios::out);  // open file to write
-    *fp << "//Comment lines begin with two //, one #, or one !" << endl;
-    *fp << "#Blank lines are skipped including /* and */ sections." << endl;
-    *fp << "!and, in principle the order of the lines is not important" <<endl;
-    *fp << "/* In AliITSgeom.h are defined an enumerated type called" << endl;
-    *fp << " AliITSDetectors These are kSPD=" << (Int_t) kSPD ;
-    *fp << ", kSDD=" << (Int_t) kSDD << ", kSSD=" << (Int_t) kSSD;
-    *fp << ", kSSDp=" << (Int_t) kSSDp << ", and kSDDp=" << (Int_t) kSDDp;
-    *fp << "*/" << endl;
-    *fp << "Version "<< fVersion.Length()<<" " << fVersion.Data() << endl;//This should be consistent
-                                           // with the geometry version.
-    *fp << "fTrans " << fTrans << endl;
-    *fp << "fNmodules " << fNmodules << endl;
-    *fp << "fNlayers " << fNlayers << endl;
-    *fp << "fNladers ";
-    for(i=0;i<fNlayers;i++) *fp << fNlad[i] << " ";
-    *fp << endl;
-    *fp << "fNdetectors ";
-    for(i=0;i<fNlayers;i++) *fp << fNdet[i] << " ";
-    *fp << endl;
-    *fp << "fNDetectorTypes " << fShape.GetEntriesFast() << endl;
-    for(i=0;i<fShape.GetEntriesFast();i++){
-       if(!IsShapeDefined(i)) continue; // only print out used shapes.
-       switch (i){
-       case kSPD :
-           *fp << "fShape " << (Int_t) kSPD << " ";
-           *fp << *((AliITSgeomSPD*)(fShape.At(i)));
-           break;
-       case kSDD :
-           *fp << "fShape " << (Int_t) kSDD << " ";
-           *fp << *((AliITSgeomSDD*)(fShape.At(i)));
-           break;
-       case kSSD : case kSSDp :
-           *fp << "fShape " << i << " ";
-           *fp << *((AliITSgeomSSD*)(fShape.At(i)));
-           break;
-       default:
-           Error("AliITSgeom::WriteNewFile","Unknown Shape value");
-       } // end switch (i)
-    } // end for i
-    for(i=0;i<fNmodules;i++){
-       *fp << "Matrix " << i << " ";
-       *fp << *GetGeomMatrix(i);
-    } // end for i
-    *fp << "//End of File" << endl;;
-
-    delete fp;
-    return;
-}
-//______________________________________________________________________
-AliITSgeom::AliITSgeom(const char *filename):
-TObject(),
-fVersion("test"),// Transformation version.
-fTrans(0),       // Flag to keep track of which transformation 
-fNmodules(0),    // The total number of modules
-fNlayers(0),     // The number of layers.
-fNlad(),         // TArrayI of the number of ladders/layer(layer)
-fNdet(),         // TArrayI of the number of detector/ladder(layer)
-fGm(0,0),        // TObjArray Structure of translation. and rotation.
-fShape(0,0)      // TObjArray of detector geom.
+AliITSgeom::AliITSgeom(const AliITSgeom &source) : 
+TObject(source),
+fVersion(source.fVersion), // Transformation version.
+fTrans(source.fTrans),   // Flag to keep track of which transformation
+fNmodules(source.fNmodules),// The total number of modules
+fNlayers(source.fNlayers), // The number of layers.
+fNlad(source.fNlad),    // Array of the number of ladders/layer(layer)
+fNdet(source.fNdet),    // Array of the number of detector/ladder(layer)
+fGm(source.fGm.GetSize(),source.fGm.LowerBound())// Structure of 
+                                                  // translation and rotation.
 {
-    //     The constructor for the AliITSgeom class. All of the data to fill
-    // this structure is read in from the file given my the input filename.
-    // Inputs:
-    //    const char *filename The file name of the file to be read in.
-    // Outputs:
-    //    none
-    // Return:
-    //    An AliITSgeom class initialized from a file.
-    FILE     *pf=0;
-    Int_t    i,lm=0,id[3];
-    Int_t    l,a,d;
-    Float_t  x,y,z,o,p,q,r,s,t;
-    Double_t rot6[6],tran[3];
-    char     buf[200],*buff=0; // input character buffer;
-    char    *filtmp;
-
-    filtmp = gSystem->ExpandPathName(filename);
-    Info("AliITSgeom","reading old .det file %s",filtmp);
-    fVersion="GEANT5";
-    pf = fopen(filtmp,"r");
-
-    fNlayers = 6; // set default number of ladders
-  TryAgain:
-    fNlad.Set(fNlayers);
-    fNdet.Set(fNlayers);
-    fNmodules = 0;
-    // find the number of ladders and detectors in this geometry.
-    for(i=0;i<fNlayers;i++){fNlad[i]=fNdet[i]=0;} // zero out arrays
-    while(fgets(buf,200,pf)!=NULL){ // for ever loop
-        for(i=0;i<200;i++)if(buf[i]!=' '){ // remove blank spaces.
-            buff = &(buf[i]);
-            break;
-        } // end for i
-        // remove blank lines and comments.
-        if(buff[0]=='\n'||buff[0]=='#'||buff[0]=='!'||
-           (buff[0]=='/'&&buff[1]=='/')) continue;
-        if(isalpha(buff[0])) { // must be the new file formated file.
-            fclose(pf);
-            ReadNewFile(filename);
-            return;
-        } // end if isalpha(buff[0])
-        sscanf(buff,"%d %d %d %f %f %f %f %f %f %f %f %f",
-               &l,&a,&d,&x,&y,&z,&o,&p,&q,&r,&s,&t);
-        if(l>lm) lm = l;
-        if(l<1 || l>fNlayers) {
-            printf("error in file %s layer=%d min. is 1 max is %d\n",
-                   filename,l,fNlayers);
-            continue;
-        }// end if l
-        fNmodules++;
-        if(l<=fNlayers&&fNlad[l-1]<a) fNlad[l-1] = a;
-        if(l<=fNlayers&&fNdet[l-1]<d) fNdet[l-1] = d;
-    } // end while ever loop
-    if(lm>fNlayers){
-        fNlayers = lm;
-        goto TryAgain;
-    } // end if lm>fNlayers
-    // counted the number of ladders and detectors now allocate space.
-    fGm.Expand(fNmodules);
-    fGm.SetOwner(kTRUE);
-    fShape.SetOwner(kTRUE);
-
-    // Set up Shapes for a default configuration of 6 layers.
-    fTrans   = 0; // standard GEANT global/local coordinate system.
-    // prepare to read in transforms
-    lm = 0; // reuse lm as counter of modules.
-    rewind(pf); // start over reading file
-    while(fgets(buf,200,pf)!=NULL){ // for ever loop
-        for(i=0;i<200;i++)if(buf[i]!=' '){ // remove blank spaces.
-            buff = &(buf[i]);
-            break;
-        } // end for i
-        // remove blank lines and comments.
-        if(buff[0]=='\n'||buff[0]=='#'||buff[0]=='!'||
-           (buff[0]=='/'&&buff[1]=='/')) continue;
-        x = y = z = o = p = q = r = s = t = 0.0;
-        sscanf(buff,"%d %d %d %f %f %f %f %f %f %f %f %f",
-               &l,&a,&d,&x,&y,&z,&o,&p,&q,&r,&s,&t);
-        if(l<1 || l>fNlayers) {
-            Warning("AliITSgeom","error in file %s layer=%d min. is 1 max is %d",
-                   filename,l,fNlayers);
-            continue;
-        }// end if l
-        id[0] = l;id[1] = a;id[2] = d;
-        tran[0] = tran[1] = tran[2]  = 0.0;
-        tran[0] = (Double_t)x;tran[1] = (Double_t)y;tran[2] = (Double_t)z;
-        rot6[0] = rot6[1] = rot6[2] = rot6[3] = rot6[4] = rot6[5] =0.0;
-        rot6[0] = (Double_t)o;rot6[1] = (Double_t)p;rot6[2] = (Double_t)q;
-        rot6[3] = (Double_t)r;rot6[4] = (Double_t)s;rot6[5] = (Double_t)t;
-       if(lm<0||lm>=fGm.GetSize()){
-           Error("AliITSgeom(filename)","lm<0||lm>=fGm.GetSize()=%d",
-                 lm,fGm.GetSize());
-           return;
-       } // end if
-        switch (l){
-        case 1: case 2: // layer 1 or2 SPD
-            fGm.AddAt(new AliITSgeomMatrix(rot6,kSPD,id,tran),lm++);
-            break;
-        case 3: case 4: // layer 3 or 4 SDD
-            fGm.AddAt(new AliITSgeomMatrix(rot6,kSDD,id,tran),lm++);
-            break;
-        case 5: case 6: // layer 5 or 6 SSD
-            fGm.AddAt(new AliITSgeomMatrix(rot6,kSSD,id,tran),lm++);
-            break;
-        } // end switch
-    } // end while ever loop
-    fclose(pf);
-}
-//______________________________________________________________________
-AliITSgeom::AliITSgeom(const AliITSgeom &source) : TObject(source){
     //     The copy constructor for the AliITSgeom class. It calls the
     // = operator function. See the = operator function for more details.
     // Inputs:
@@ -629,8 +298,14 @@ AliITSgeom::AliITSgeom(const AliITSgeom &source) : TObject(source){
     //     none.
     // Return:
     //     none.
+    Int_t i,n;
 
-    *this = source;  // Just use the = operator for now.
+    n = source.fGm.GetLast()+1;
+    for(i=source.fGm.LowerBound();i<n;i++){
+        fGm.AddAt(new AliITSgeomMatrix(*((AliITSgeomMatrix*)(
+                                             source.fGm.At(i)))),i);
+    } // end for i
+    fGm.SetOwner(kTRUE);
     return;
 }
 //______________________________________________________________________
@@ -653,31 +328,23 @@ AliITSgeom& AliITSgeom::operator=(const AliITSgeom &source){
 
     // if there is an old structure allocated delete it first.
     this->fGm.Clear();
-    this->fShape.Clear();
 
     this->fVersion  = source.fVersion;
     this->fTrans    = source.fTrans;
     this->fNmodules = source.fNmodules;
-    this->fNlayers = source.fNlayers;
-    this->fNlad.Set(fNlayers,source.fNlad.GetArray());
-    this->fNdet.Set(fNlayers,source.fNdet.GetArray());
-    this->fShape.Expand(source.fShape.GetEntriesFast());
-    for(i=0;i<source.fShape.GetEntriesFast();i++)
-        this->fShape.AddAt(new TObject(*(source.fShape.At(i))),i);
-    this->fShape.SetOwner(kTRUE);
+    this->fNlayers  = source.fNlayers;
+    this->fNlad     = source.fNlad;
+    this->fNdet     = source.fNdet;
     this->fGm.Expand(this->fNmodules);
-    this->fGm.SetOwner(kTRUE);
-    for(i=0;i<this->fNmodules;i++)
-       if(i<0||i>=fGm.GetSize()){
-           Error("ReadNewFile","i<0||i>=fGm.GetSize()=%d",
-                 i,fGm.GetSize());
-           return *this;
-       } // end if
-        this->fGm.AddAt(new TObject(*(source.fGm.At(i))),i);
+    for(i=source.fGm.LowerBound();i<source.fGm.GetLast();i++){
+        fGm.AddAt(new AliITSgeomMatrix(*((AliITSgeomMatrix*)(
+                                             source.fGm.At(i)))),i);
+    } // end for i
+    fGm.SetOwner(kTRUE);
     return *this;
 }
 //______________________________________________________________________
-Int_t AliITSgeom::GetModuleIndex(Int_t lay,Int_t lad,Int_t det){
+Int_t AliITSgeom::GetModuleIndex(Int_t lay,Int_t lad,Int_t det)const{
     //      This routine computes the module index number from the layer,
     // ladder, and detector numbers. The number of ladders and detectors
     // per layer is determined when this geometry package is constructed,
@@ -708,7 +375,8 @@ Int_t AliITSgeom::GetModuleIndex(Int_t lay,Int_t lad,Int_t det){
     return -1;
 }
 //______________________________________________________________________
-void AliITSgeom::GetModuleId(Int_t index,Int_t &lay,Int_t &lad,Int_t &det){
+void AliITSgeom::GetModuleId(Int_t index,Int_t &lay,Int_t &lad,Int_t &det)
+const{
     //      This routine computes the layer, ladder and detector number 
     // given the module index number. The number of ladders and detectors
     // per layer is determined when this geometry package is constructed,
@@ -753,7 +421,7 @@ void AliITSgeom::GetModuleId(Int_t index,Int_t &lay,Int_t &lad,Int_t &det){
 */
 }
 //______________________________________________________________________
-Int_t AliITSgeom::GetNDetTypes(Int_t &max){
+Int_t AliITSgeom::GetNDetTypes(Int_t &max)const{
     // Finds and returns the number of detector types used and the
     // maximum detector type value. Only counts id >=0 (no undefined
     // values. See AliITSgeom.h for list of AliITSDetecor enumerated types.
@@ -782,7 +450,7 @@ Int_t AliITSgeom::GetNDetTypes(Int_t &max){
     return id+1;
 }
 //______________________________________________________________________
-Int_t AliITSgeom::GetNDetTypes(TArrayI &maxs,AliITSDetector *types){
+Int_t AliITSgeom::GetNDetTypes(TArrayI &maxs,AliITSDetector *types)const{
     // Finds and returns the number of detector types used and the
     // number of each detector type. Only counts id >=0 (no undefined
     // values. See AliITSgeom.h for list of AliITSDetecor enumerated types.
@@ -817,12 +485,13 @@ Int_t AliITSgeom::GetNDetTypes(TArrayI &maxs,AliITSDetector *types){
     return id;
 }
 //______________________________________________________________________
-Int_t AliITSgeom::GetStartDet(Int_t dtype){
+Int_t AliITSgeom::GetStartDet(Int_t dtype)const{
     // returns the starting module index value for a give type of detector id.
     // This assumes that the detector types are different on different layers
     // and that they are not mixed up.
     // Inputs:
-    //    Int_t dtype A detector type number. 0 for SPD, 1 for SDD, and 2 for SSD.
+    //    Int_t dtype A detector type number. 0 for SPD, 1 for SDD, 
+    //                and 2 for SSD.
     // Outputs:
     //    none.
     // Return:
@@ -847,26 +516,28 @@ Int_t AliITSgeom::GetStartDet(Int_t dtype){
     return 0;
 }
 //______________________________________________________________________
-Int_t AliITSgeom::GetLastDet(Int_t dtype){
+Int_t AliITSgeom::GetLastDet(Int_t dtype)const{
     // returns the last module index value for a give type of detector id.
     // This assumes that the detector types are different on different layers
     // and that they are not mixed up.
     // Inputs:
-    //     Int_t dtype A detector type number. 0 for SPD, 1 for SDD, and 2 for SSD.
+    //     Int_t dtype A detector type number. 0 for SPD, 1 for SDD, 
+    //                 and 2 for SSD.
     // Outputs:
     // Return:
     //     the module index for the last occurrence of that detector type.
 
-    switch(dtype){
-    case 0:
-        return GetLastSPD();
+    switch((AliITSDetector)dtype){
+    case kSPD:
+        return GetModuleIndex(3,1,1)-1;
         break;
-    case 1:
-        return GetLastSDD();
+    case kSDD:
+        return GetModuleIndex(5,1,1)-1;
         break;
-    case 2:
-        return GetLastSSD();
+    case kSSD:
+        return GetIndexMax()-1;
         break;
+    case kSSDp: case kSDDp: case kND:
     default:
         Warning("GetLastDet","undefined detector type %d",dtype);
         return 0;
@@ -875,78 +546,9 @@ Int_t AliITSgeom::GetLastDet(Int_t dtype){
     Warning("GetLastDet","undefined detector type %d",dtype);
     return 0;
 }
-//______________________________________________________________________
-void AliITSgeom::PrintComparison(FILE *fp,AliITSgeom *other){
-    //     This function was primarily created for diagnostic reasons. It
-    // print to a file pointed to by the file pointer fp the difference
-    // between two AliITSgeom classes. The format of the file is basically,
-    // define d? to be the difference between the same element of the two
-    // classes. For example dfrx = this->GetGeomMatrix(i)->frx 
-    // - other->GetGeomMatrix(i)->frx.
-    // if(at least one of dfx0, dfy0, dfz0,dfrx,dfry,dfrz are non zero) then
-    // print layer ladder detector dfx0 dfy0 dfz0 dfrx dfry dfrz
-    // if(at least one of the 9 elements of dfr[] are non zero) then print
-    // layer ladder detector dfr[0] dfr[1] dfr[2]
-    //                       dfr[3] dfr[4] dfr[5]
-    //                       dfr[6] dfr[7] dfr[8]
-    // Only non zero values are printed to save space. The differences are
-    // typical written to a file because there are usually a lot of numbers
-    // printed out and it is usually easier to read them in some nice editor
-    // rather than zooming quickly past you on a screen. fprintf is used to
-    // do the printing. The fShapeIndex difference is not printed at this time.
-    // Inputs:
-    //    FILE *fp           A file pointer to an opened file for writing in which
-    //                       the results of the comparison will be written.
-    //    AliITSgeom *other  The other AliITSgeom class to which this one is
-    //                       being compared.
-    // Outputs:
-    //    none.
-    // Return:
-    //    none.
-    Int_t    i,j,idt[3],ido[3];
-    Double_t tt[3],to[3];  // translation
-    Double_t rt[3],ro[3];  // phi in radians
-    Double_t mt[3][3],mo[3][3]; // matrices
-    AliITSgeomMatrix *gt,*go;
-    Bool_t   t;
 
-    for(i=0;i<this->fNmodules;i++){
-        gt  =  this->GetGeomMatrix(i);
-        go  = other->GetGeomMatrix(i);
-        gt->GetIndex(idt);
-        go->GetIndex(ido);
-        t = kFALSE;
-        for(i=0;i<3;i++) t = t&&idt[i]!=ido[i];
-        if(t) fprintf(fp,"%4.4d %1.1d %2.2d %2.2d %1.1d %2.2d %2.2d\n",i,
-                      idt[0],idt[1],idt[2],ido[0],ido[1],ido[2]);
-        gt->GetTranslation(tt);
-        go->GetTranslation(to);
-        gt->GetAngles(rt);
-        go->GetAngles(ro);
-        t = kFALSE;
-        for(i=0;i<3;i++) t = t&&tt[i]!=to[i];
-        if(t) fprintf(fp,"%1.1d %2.2d %2.2d dTrans=%f %f %f drot=%f %f %f\n",
-                      idt[0],idt[1],idt[2],
-                      tt[0]-to[0],tt[1]-to[1],tt[2]-to[2],
-                      rt[0]-ro[0],rt[1]-ro[1],rt[2]-ro[2]);
-        t = kFALSE;
-        gt->GetMatrix(mt);
-        go->GetMatrix(mo);
-        for(i=0;i<3;i++)for(j=0;j<3;j++)  t = mt[i][j] != mo[i][j];
-        if(t){
-            fprintf(fp,"%1.1d %2.2d %2.2d dfr= %e %e %e\n",
-                    idt[0],idt[1],idt[2],
-                    mt[0][0]-mo[0][0],mt[0][1]-mo[0][1],mt[0][2]-mo[0][2]);
-            fprintf(fp,"        dfr= %e %e %e\n",
-                    mt[1][0]-mo[1][0],mt[1][1]-mo[1][1],mt[1][2]-mo[1][2]);
-            fprintf(fp,"        dfr= %e %e %e\n",
-                    mt[2][0]-mo[2][0],mt[2][1]-mo[2][1],mt[2][2]-mo[2][2]);
-        } // end if t
-    } // end for i
-    return;
-}
 //______________________________________________________________________
-void AliITSgeom::PrintData(FILE *fp,Int_t lay,Int_t lad,Int_t det){
+void AliITSgeom::PrintData(FILE *fp,Int_t lay,Int_t lad,Int_t det)const{
     //     This function prints out the coordinate transformations for
     // the particular detector defined by layer, ladder, and detector
     // to the file pointed to by the File pointer fp. fprintf statements
@@ -960,8 +562,9 @@ void AliITSgeom::PrintData(FILE *fp,Int_t lay,Int_t lad,Int_t det){
     // is given to the user. The output it written to the file pointed
     // to by the file pointer fp. This can be set to stdout if you want.
     // Inputs:
-    //     FILE *fp           A file pointer to an opened file for writing in which
-    //                        the results of the comparison will be written.
+    //     FILE *fp           A file pointer to an opened file for 
+    //                        writing in which the results of the 
+    //                        comparison will be written.
     //     Int_t lay          The layer number. Starting from 1.
     //     Int_t lad          The ladder number. Starting from 1.
     //     Int_t det          The detector number. Starting from 1.
@@ -984,346 +587,9 @@ void AliITSgeom::PrintData(FILE *fp,Int_t lay,Int_t lad,Int_t det){
     fprintf(fp,"        dfr= %e %e %e\n",m[2][0],m[2][1],m[2][2]);
     return;
 }
-//______________________________________________________________________
-ofstream & AliITSgeom::PrintGeom(ofstream &rb){
-    //     Stream out an object of class AliITSgeom to standard output.
-    // Intputs:
-    //     ofstream &rb    The output streaming buffer.
-    // Outputs:
-    //     none.
-    // Return:
-    //     ofstream &rb    The output streaming buffer.
-    Int_t i,nshapes;
 
-    rb.setf(ios::scientific);
-    rb << fTrans << " ";
-    rb << fNmodules << " ";
-    rb << fNlayers << " ";
-    for(i=0;i<fNlayers;i++) rb << fNlad[i] << " ";
-    for(i=0;i<fNlayers;i++) rb << fNdet[i] << "\n";
-    for(i=0;i<fNmodules;i++) {
-        rb <<setprecision(16) << *(GetGeomMatrix(i)) << "\n";
-    } // end for i
-    nshapes = fShape.GetEntries();
-    rb << nshapes <<endl;
-    for(i=0;i<nshapes;i++) if(fShape.At(i)!=0) switch (i){
-    case kSPD:
-        rb << kSPD <<","<< (AliITSgeomSPD*)(fShape.At(kSPD));
-        break;
-    case kSDD:
-        rb << kSDD <<","<< (AliITSgeomSDD*)(fShape.At(kSDD));
-        break;
-    case kSSD:
-        rb << kSSD <<","<< (AliITSgeomSSD*)(fShape.At(kSSD));
-        break;
-    case kSSDp:
-        rb << kSSDp <<","<< (AliITSgeomSSD*)(fShape.At(kSSDp));
-        break;
-    case kSDDp:
-        rb << kSDDp <<","<< (AliITSgeomSDD*)(fShape.At(kSDDp));
-        break;
-    } // end for i / switch
-    return rb;
-}
 //______________________________________________________________________
-ifstream & AliITSgeom::ReadGeom(ifstream &rb){
-    //     Stream in an object of class AliITSgeom from standard input.
-    // Intputs:
-    //     ifstream &rb    The input streaming buffer.
-    // Outputs:
-    //     none.
-    // Return:
-    //     ifstream &rb    The input streaming buffer.
-    Int_t i,j;
-
-    fGm.Clear();
-
-    rb >> fTrans >> fNmodules >> fNlayers;
-    fNlad.Set(fNlayers);
-    fNdet.Set(fNlayers);
-    for(i=0;i<fNlayers;i++) rb >> fNlad[i];
-    for(i=0;i<fNlayers;i++) rb >> fNdet[i];
-    fGm.Expand(fNmodules);
-    fGm.SetOwner(kTRUE);
-    for(i=0;i<fNmodules;i++){
-       if(i<0||i>=fGm.GetSize()){
-           Error("ReadGeom","i<0||i>=fGm.GetSize()=%d",
-                 i,fGm.GetSize());
-           return rb;
-       } // end if
-        fGm.AddAt(new AliITSgeomMatrix,i);
-        rb >> *(GetGeomMatrix(i));
-    } // end for i
-    rb >> i;
-    fShape.Expand(i);
-    fShape.SetOwner(kTRUE);
-    for(i=0;i<fShape.GetEntries();i++) {
-        rb >> j;
-        switch (j){
-        case kSPD:{
-            AliITSgeomSPD *s = new AliITSgeomSPD();
-            rb >> *s;
-            fShape.AddAt(s,kSPD);}
-            break;
-        case kSDD:{
-            AliITSgeomSDD *s = new AliITSgeomSDD();
-            rb >> *s;
-            fShape.AddAt(s,kSDD);}
-            break;
-        case kSSD:{
-            AliITSgeomSSD *s = new AliITSgeomSSD();
-            rb >> *s;
-            fShape.AddAt(s,kSSD);}
-            break;
-        case kSSDp:{
-            AliITSgeomSSD *s = new AliITSgeomSSD();
-            rb >> *s;
-            fShape.AddAt(s,kSSDp);}
-            break;
-        case kSDDp:{
-            AliITSgeomSDD *s = new AliITSgeomSDD();
-            rb >> *s;
-            fShape.AddAt(s,kSDDp);}
-            break;
-        } // end  switch
-    } //  end for i
-    return rb;
-}
-//______________________________________________________________________
-//     The following routines modify the transformation of "this"
-// geometry transformations in a number of different ways.
-//______________________________________________________________________
-void AliITSgeom::GlobalChange(const Float_t *tran,const Float_t *rot){
-    //     This function performs a Cartesian translation and rotation of
-    // the full ITS from its default position by an amount determined by
-    // the three element arrays tran and rot. If every element
-    // of tran and rot are zero then there is no change made
-    // the geometry. The change is global in that the exact same translation
-    // and rotation is done to every detector element in the exact same way.
-    // The units of the translation are those of the Monte Carlo, usually cm,
-    // and those of the rotation are in radians. The elements of tran
-    // are tran[0] = x, tran[1] = y, and tran[2] = z.
-    // The elements of rot are rot[0] = rx, rot[1] = ry, and
-    // rot[2] = rz. A change in x will move the hole ITS in the ALICE
-    // global x direction, the same for a change in y. A change in z will
-    // result in a translation of the ITS as a hole up or down the beam line.
-    // A change in the angles will result in the inclination of the ITS with
-    // respect to the beam line, except for an effective rotation about the
-    // beam axis which will just rotate the ITS as a hole about the beam axis.
-    // Intputs:
-    //     Float_t *tran   A 3 element array representing the global translations.
-    //                     the elements are x,y,z in cm.
-    //     Float_t *rot    A 3 element array representing the global rotation
-    //                     angles about the three axis x,y,z in radians
-    // Outputs:
-    //     none.
-    // Return:
-    //     none.
-    Int_t    i,j;
-    Double_t t[3],r[3];
-    AliITSgeomMatrix *g;
-
-    fTrans = (fTrans && 0xfffd) + 2;  // set bit 1 true.
-    for(i=0;i<fNmodules;i++){
-        g = this->GetGeomMatrix(i);
-        g->GetTranslation(t);
-        g->GetAngles(r);
-        for(j=0;j<3;j++){
-            t[j] += tran[j];
-            r[j] += rot[j];
-        } // end for j
-        g->SetTranslation(t);
-        g->SetAngles(r);
-    } // end for i
-    return;
-}
-//______________________________________________________________________
-void AliITSgeom::GlobalCylindericalChange(const Float_t *tran,
-                                         const Float_t *rot){
-    //     This function performs a cylindrical translation and rotation of
-    // each ITS element by a fixed about in radius, rphi, and z from its
-    // default position by an amount determined by the three element arrays
-    // tran and rot. If every element of tran and
-    // rot are zero then there is no change made the geometry. The
-    // change is global in that the exact same distance change in translation
-    // and rotation is done to every detector element in the exact same way.
-    // The units of the translation are those of the Monte Carlo, usually cm,
-    // and those of the rotation are in radians. The elements of tran
-    // are tran[0] = r, tran[1] = rphi, and tran[2] = z.
-    // The elements of rot are rot[0] = rx, rot[1] = ry, and
-    // rot[2] = rz. A change in r will results in the increase of the
-    // radius of each layer by the same about. A change in rphi will results in
-    // the rotation of each layer by a different angle but by the same
-    // circumferential distance. A change in z will result in a translation
-    // of the ITS as a hole up or down the beam line. A change in the angles
-    // will result in the inclination of the ITS with respect to the beam
-    // line, except for an effective rotation about the beam axis which will
-    // just rotate the ITS as a hole about the beam axis.
-    // Intputs:
-    //     Float_t *tran   A 3 element array representing the global translations.
-    //                     the elements are r,theta,z in cm/radians.
-    //     Float_t *rot    A 3 element array representing the global rotation
-    //                     angles about the three axis x,y,z in radians
-    // Outputs:
-    //     none.
-    // Return:
-    //     none.
-    Int_t    i,j;
-    Double_t t[3],ro[3],r,r0,phi,rphi;
-    AliITSgeomMatrix *g;
-
-    fTrans = (fTrans && 0xfffd) + 2;  // set bit 1 true.
-    for(i=0;i<fNmodules;i++){
-        g = this->GetGeomMatrix(i);
-        g->GetTranslation(t);
-        g->GetAngles(ro);
-        r = r0= TMath::Hypot(t[1],t[0]);
-        phi   = TMath::ATan2(t[1],t[0]);
-        rphi  = r0*phi;
-        r    += tran[0];
-        rphi += tran[1];
-        phi   = rphi/r0;
-        t[0]  = r*TMath::Cos(phi);
-        t[1]  = r*TMath::Sin(phi);
-        t[2] += tran[2];
-        for(j=0;j<3;j++){
-            ro[j] += rot[j];
-        } // end for j
-        g->SetTranslation(t);
-        g->SetAngles(ro);
-    } // end for i
-    return;
-}
-//______________________________________________________________________
-void AliITSgeom::RandomChange(const Float_t *stran,const Float_t *srot){
-    //     This function performs a Gaussian random displacement and/or
-    // rotation about the present global position of each active
-    // volume/detector of the ITS. The sigma of the random displacement
-    // is determined by the three element array stran, for the
-    // x y and z translations, and the three element array srot,
-    // for the three rotation about the axis x y and z.
-    // Intputs:
-    //     Float_t *stran  A 3 element array representing the global translations
-    //                     variances. The elements are x,y,z in cm.
-    //     Float_t *srot   A 3 element array representing the global rotation
-    //                     angles variances about the three axis x,y,z in radians.
-    // Outputs:
-    //     none.
-    // Return:
-    //     none.
-    Int_t    i,j;
-    Double_t t[3],r[3];
-    AliITSgeomMatrix *g;
-
-    fTrans = (fTrans && 0xfffd) + 2;  // set bit 1 true.
-    for(i=0;i<fNmodules;i++){
-        g = this->GetGeomMatrix(i);
-        g->GetTranslation(t);
-        g->GetAngles(r);
-        for(j=0;j<3;j++){
-            t[j] += gRandom->Gaus(0.0,stran[j]);
-            r[j] += gRandom->Gaus(0.0, srot[j]);
-        } // end for j
-        g->SetTranslation(t);
-        g->SetAngles(r);
-    } // end for i
-    return;
-}
-//______________________________________________________________________
-void AliITSgeom::RandomCylindericalChange(const Float_t *stran,
-                                         const Float_t *srot){
-    //     This function performs a Gaussian random displacement and/or
-    // rotation about the present global position of each active
-    // volume/detector of the ITS. The sigma of the random displacement
-    // is determined by the three element array stran, for the
-    // r rphi and z translations, and the three element array srot,
-    // for the three rotation about the axis x y and z. This random change
-    // in detector position allow for the simulation of a random uncertainty
-    // in the detector positions of the ITS.
-    // Intputs:
-    //     Float_t *stran  A 3 element array representing the global translations
-    //                     variances. The elements are r,theta,z in cm/radians.
-    //     Float_t *srot   A 3 element array representing the global rotation
-    //                     angles variances about the three axis x,y,z in radians.
-    // Outputs:
-    //     none.
-    // Return:
-    //     none.
-    Int_t    i,j;
-    Double_t t[3],ro[3],r,r0,phi,rphi;
-    TRandom ran;
-    AliITSgeomMatrix *g;
-
-    fTrans = (fTrans && 0xfffd) + 2;  // set bit 1 true.
-    for(i=0;i<fNmodules;i++){
-        g = this->GetGeomMatrix(i);
-        g->GetTranslation(t);
-        g->GetAngles(ro);
-        r = r0= TMath::Hypot(t[1],t[0]);
-        phi   = TMath::ATan2(t[1],t[0]);
-        rphi  = r0*phi;
-        r    += ran.Gaus(0.0,stran[0]);
-        rphi += ran.Gaus(0.0,stran[1]);
-        phi   = rphi/r0;
-        t[0]  = r*TMath::Cos(phi);
-        t[1]  = r*TMath::Sin(phi);
-        t[2] += ran.Gaus(0.0,stran[2]);
-        for(j=0;j<3;j++){
-            ro[j] += ran.Gaus(0.0, srot[j]);
-        } // end for j
-        g->SetTranslation(t);
-        g->SetAngles(ro);
-    } // end for i
-    return;
-}
-//______________________________________________________________________
-void AliITSgeom::GeantToTracking(AliITSgeom &source){
-    //     Copy the geometry data but change it to go between the ALICE
-    // Global coordinate system to that used by the ITS tracking. A slightly
-    // different coordinate system is used when tracking. This coordinate 
-    // system is only relevant when the geometry represents the cylindrical
-    // ALICE ITS geometry. For tracking the Z axis is left alone but X-> -Y
-    // and Y-> X such that X always points out of the ITS cylinder for every
-    // layer including layer 1 (where the detectors are mounted upside down).
-    //Begin_Html
-    /*
-      <img src="picts/ITS/AliITSgeomMatrix_T1.gif">
-    */
-    //End_Html
-    // Input:
-    //     AliITSgeom &source  The AliITSgeom class with which to make this
-    //                         a copy of.
-    // Output:
-    //     none.
-    // Return:
-    //     none.
-    Int_t    i,j,k,l,id[3];
-    Double_t r0[3][3],r1[3][3];
-    Double_t a0[3][3] = {{0.,+1.,0.},{-1.,0.,0.},{0.,0.,+1.}};
-    Double_t a1[3][3] = {{0.,-1.,0.},{+1.,0.,0.},{0.,0.,+1.}};
-
-    *this = source;  // copy everything
-    for(i=0;i<GetIndexMax();i++){
-        GetGeomMatrix(i)->GetIndex(id);
-        GetGeomMatrix(i)->GetMatrix(r0);
-        if(id[0]==1){ // Layer 1 is treated different from the others.
-            for(j=0;j<3;j++) for(k=0;k<3;k++){
-                r1[j][k] = 0.;
-                for(l=0;l<3;l++) r1[j][k] += a0[j][l]*r0[l][k];
-            } // end for j,k
-        }else{
-            for(j=0;j<3;j++) for(k=0;k<3;k++){
-                r1[j][k] = 0.;
-                for(l=0;l<3;l++) r1[j][k] += a1[j][l]*r0[l][k];
-            } // end for j,k
-        } // end if
-        GetGeomMatrix(i)->SetMatrix(r1);
-    } // end for i
-    this->fTrans = (this->fTrans && 0xfffe) + 1;  // set bit 0 true.
-    return;
-}
-//______________________________________________________________________
-Int_t AliITSgeom::GetNearest(const Double_t g[3],Int_t lay){
+Int_t AliITSgeom::GetNearest(const Double_t g[3],Int_t lay)const{
     //      Finds the Detector (Module) that is nearest the point g [cm] in
     // ALICE Global coordinates. If layer !=0 then the search is restricted
     // to Detectors (Modules) in that particular layer.
@@ -1350,7 +616,7 @@ Int_t AliITSgeom::GetNearest(const Double_t g[3],Int_t lay){
     return in;
 }
 //______________________________________________________________________
-void AliITSgeom::GetNearest27(const Double_t g[3],Int_t n[27],Int_t lay){
+void AliITSgeom::GetNearest27(const Double_t g[3],Int_t n[27],Int_t lay)const{
     //      Finds 27 Detectors (Modules) that are nearest the point g [cm] in
     // ALICE Global coordinates. If layer !=0 then the search is restricted
     // to Detectors (Modules) in that particular layer. The number 27 comes 
@@ -1388,82 +654,55 @@ void AliITSgeom::GetNearest27(const Double_t g[3],Int_t n[27],Int_t lay){
     } // end for i
     for(i=0;i<27;i++) n[i] = in[i];
 }
-//----------------------------------------------------------------------
-Double_t AliITSgeom::GetAverageRadiusOfLayer(Int_t layer,Double_t &range){
-    // Loops over all modules for a given layer and computes the
-    // average cylindrical radius (about the z axis) and the range of
-    // radii covered by this layer. Units, [cm] the Alice default unit.
-    // Input:
-    //    Int_t layer     The layer for which the average radii is to be found
+//_______________________________________________________________________
+void AliITSgeom::DetLToTrackingV2(Int_t md,Float_t xin,Float_t zin,
+                                  Float_t &yout,Float_t &zout) const {
+
+    //Conversion from local coordinates on detectors to local
+    //coordinates used for tracking ("v2")
+    // Inputs:
+    //   Int_t   md      Module number
+    //   Float_t xin     Standard local coordinate x
+    //   Float_t zin     Standard local coordinate z
     // Output:
-    //    Double_t &range The range of radii covered by this layer
+    //   Float_t yout    Tracking local coordinate y
+    //   Float_t zout    Tracking local coordinate z
     // Return:
-    //    The average radii for this layer.
-    Double_t r=0.0,rmin=1.0e6,rmax=-1.0,rp,t[3],l[3],dl[3];
-    Int_t    n=0,i,j,lay,lad,det;
-
-    for(i=0;i<GetIndexMax();i++) {
-        GetModuleId(i,lay,lad,det);
-        if(lay!=layer) continue;
-        dl[0] = dl[1] = dl[2] = 0.0;
-        if(GetShape(i)!=0) {
-           switch(i){
-           case 0:{
-               dl[0] = ((AliITSgeomSPD*)GetShape(i))->GetDx();
-               dl[1] = ((AliITSgeomSPD*)GetShape(i))->GetDy();
-               dl[2] = ((AliITSgeomSPD*)GetShape(i))->GetDz();
-           } break;
-           case 1: case 4:{
-               dl[0] = ((AliITSgeomSDD*)GetShape(i))->GetDx();
-               dl[1] = ((AliITSgeomSDD*)GetShape(i))->GetDy();
-               dl[2] = ((AliITSgeomSDD*)GetShape(i))->GetDz();
-           } break;
-           case 2: case 3:{
-               dl[0] = ((AliITSgeomSSD*)GetShape(i))->GetDx();
-               dl[1] = ((AliITSgeomSSD*)GetShape(i))->GetDy();
-               dl[2] = ((AliITSgeomSSD*)GetShape(i))->GetDz();
-           } break;
-           }// end switch.
-        } // end of
-        n++;
-        GetTransCyln(i,t);
-        rp = t[0];
-        r += rp;
-        if(rmin>rp) rmin = rp;
-        if(rmax<rp) rmax = rp;
-        for(j=0;j<8;j++){ // loop over the corners
-            l[0] = dl[0];if(j%2==0) l[0] = -dl[0];
-            l[1] = dl[1];if(j==2||j==3||j==6||j==7) l[1] = -dl[1];
-            l[2] = dl[2];if(j>3) l[2] = -dl[2];
-            LtoG(i,l,t);
-            rp = TMath::Sqrt(t[0]*t[0]+t[1]*t[1]);
-            if(rmin>rp) rmin = rp;
-            if(rmax<rp) rmax = rp;
-        } // end for j
-    } // end for i
-    r /= (Double_t)n;
-    range = TMath::Max(rmax-r,r-rmin);
-    return r;
+    //   none.
+    Float_t x,y,z;
+    Double_t rt[9],al;
+
+    GetTrans(md,x,y,z);
+    GetRotMatrix(md,rt);
+    al = TMath::ATan2(rt[1],rt[0])+TMath::Pi();
+    yout = -(-xin+(x*((Float_t)TMath::Cos(al))+y*((Float_t)TMath::Sin(al))));
+    if(md<(GetModuleIndex(2,1,1))) yout *= -1; 
+    zout = -zin+z; 
 }
 //_______________________________________________________________________
-void AliITSgeom::DetLToTrackingV2(Int_t md, Float_t xin, Float_t zin, Float_t &yout, Float_t &zout) {
-
-  //Conversion from local coordinates on detectors to local
-  //coordinates used for tracking ("v2")
-  Float_t x,y,z; Double_t rt[9];GetTrans(md,x,y,z);GetRotMatrix(md,rt);
-  Double_t al=TMath::ATan2(rt[1],rt[0])+TMath::Pi();
-  yout=-(-xin+(x*TMath::Cos(al)+y*TMath::Sin(al)));
-  if(md<(GetModuleIndex(2,1,1)-1))yout*=-1; zout=-zin+(Double_t)z; 
+void AliITSgeom::TrackingV2ToDetL(Int_t md,Float_t yin,Float_t zin,
+                                  Float_t &xout,Float_t &zout) const {
+    //Conversion from local coordinates used for tracking ("v2") to
+    //local detector coordinates  
+    // Inputs:
+    //   Int_t   md      Module number
+    //   Float_t yin     Tracking local coordinate y
+    //   Float_t zin     Tracking local coordinate z
+    // Output:
+    //   Float_t xout    Standard local coordinate x
+    //   Float_t zout    Standard local coordinate z
+    // Return:
+    //   none.
+    Float_t x,y,z;
+    Double_t rt[9],al;
+
+    GetTrans(md,x,y,z);
+    GetRotMatrix(md,rt);
+    al = TMath::ATan2(rt[1],rt[0])+TMath::Pi();
+    xout = yin;
+    if(md<(GetModuleIndex(2,1,1))) xout = -xout;
+    xout += (x*((Float_t)TMath::Cos(al))+y*((Float_t)TMath::Sin(al)));
+    zout  = -zin+z; 
 }
+//----------------------------------------------------------------------
 
-//_______________________________________________________________________
-void AliITSgeom::TrackingV2ToDetL(Int_t md,Float_t yin,Float_t zin,Float_t &xout,Float_t &zout) {
-  //Conversion from local coordinates used for tracking ("v2") to
-  //local detector coordinates
-  
-  Float_t x,y,z; Double_t rt[9];GetTrans(md,x,y,z);GetRotMatrix(md,rt);
-  Double_t al=TMath::ATan2(rt[1],rt[0])+TMath::Pi();
-  xout=yin;if(md<(GetModuleIndex(2,1,1)-1))xout=-xout;
-  xout+=(x*TMath::Cos(al)+y*TMath::Sin(al));
-  zout=-zin+(Double_t)z; 
-}