]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PMD/AliPMDUtility.cxx
coverity defects fixed
[u/mrichter/AliRoot.git] / PMD / AliPMDUtility.cxx
index 86498729aa6bdd8d154adb12db0a85171ca69f3a..b16c3ce223f6358c726585d51b9e260c53aa62d5 100644 (file)
 //-----------------------------------------------------//
 
 #include "Riostream.h"
-#include "AliPMDUtility.h"
 #include "TMath.h"
+#include "TText.h"
+#include "TLine.h"
+
 #include <stdio.h>
 #include <math.h>
 
+#include "AliPMDUtility.h"
 
 ClassImp(AliPMDUtility)
 
-AliPMDUtility::AliPMDUtility()
+AliPMDUtility::AliPMDUtility():
+  fPx(0.),
+  fPy(0.),
+  fPz(0.),
+  fTheta(0.),
+  fEta(0.),
+  fPhi(0.),
+  fWriteModule(1)
 {
   // Default constructor
-  fPx    = 0.;
-  fPy    = 0.;
-  fPz    = 0.;
-  fTheta = 0.;
-  fEta   = 0.;
-  fPhi   = 0.;
+  for (Int_t i = 0; i < 4; i++)
+    {
+      for (Int_t j = 0; j < 3; j++)
+       {
+         fSecTr[i][j] = 0.;
+       }
+    }
+
 }
 
-AliPMDUtility::AliPMDUtility(Float_t px, Float_t py, Float_t pz)
+AliPMDUtility::AliPMDUtility(Float_t px, Float_t py, Float_t pz):
+  fPx(px),
+  fPy(py),
+  fPz(pz),
+  fTheta(0.),
+  fEta(0.),
+  fPhi(0.),
+  fWriteModule(1)
 {
   // Constructor
-  fPx = px;
-  fPy = py;
-  fPz = pz;
-  fTheta = 0.;
-  fEta   = 0.;
-  fPhi   = 0.;
+  for (Int_t i = 0; i < 4; i++)
+    {
+      for (Int_t j = 0; j < 3; j++)
+       {
+         fSecTr[i][j] = 0.;
+       }
+    }
+
 }
+AliPMDUtility::AliPMDUtility(const AliPMDUtility &pmdutil):
+  TObject(pmdutil),
+  fPx(pmdutil.fPx),
+  fPy(pmdutil.fPy),
+  fPz(pmdutil.fPz),
+  fTheta(pmdutil.fTheta),
+  fEta(pmdutil.fEta),
+  fPhi(pmdutil.fPhi),
+  fWriteModule(pmdutil.fWriteModule)
+{
+  // copy constructor
+    for (Int_t i = 0; i < 4; i++)
+    {
+      for (Int_t j = 0; j < 3; j++)
+       {
+         fSecTr[i][j] = pmdutil.fSecTr[i][j];
+       }
+    }
+
+}
+AliPMDUtility & AliPMDUtility::operator=(const AliPMDUtility &pmdutil)
+{
+  // assignment operator
+  if(this != &pmdutil)
+    {
+      fPx = pmdutil.fPx;
+      fPy = pmdutil.fPy;
+      fPz = pmdutil.fPz;
+      fTheta = pmdutil.fTheta;
+      fEta = pmdutil.fEta;
+      fPhi = pmdutil.fPhi;
+      fWriteModule = pmdutil.fWriteModule;
+      for (Int_t i = 0; i < 4; i++)
+       {
+         for (Int_t j = 0; j < 3; j++)
+           {
+             fSecTr[i][j] = pmdutil.fSecTr[i][j];
+           }
+       }
 
+    }
+  return *this;
+}
 AliPMDUtility::~AliPMDUtility()
 {
   // Default destructor
 }
-void AliPMDUtility::HexGeomCellPos(Int_t ism, Int_t xpad, Int_t ypad, Float_t &xpos, Float_t &ypos)
+
+void AliPMDUtility::RectGeomCellPos(Int_t ism, Int_t xpad, Int_t ypad, Float_t &xpos, Float_t &ypos)
 {
-  // This converts PMD cluster or CELL coordinates
-  // to Global coordinates.
-  // Written by Prof. S.C. Phatak
-
-  const Float_t  kCellDia = 0.5;
-  const Float_t  kPi      = TMath::Pi();    //3.14159;
-  const Double_t kSqroot3by2   = 0.8660254;  // sqrth = sqrt(3.)/2.
-
-  Int_t i;
-  Int_t j = xpad;
-  Int_t k = ypad;
-
-  /*
-    Supermodeule number starting from 0
-    ism --> supermodule no ( 0 - 26 )
-    idet --> detector ( pmd or cpv : not required now )
-    j --> xpad ( goes from 1 to 72 )
-    k --> ypad ( goes from 1 to 72 )
-    xp --> global x coordinate
-    yp --> global y coordinate
-    
-    (xp0,yp0) corner positions of all supermodules in global
-    coordinate system. That is the origin
-    of the local ( supermodule ) coordinate system.
-  */ 
-  
-  Float_t xp0[27] = 
-  {
-    -17.9084, 18.2166, 54.3416, -35.9709, 0.154144, 
-    36.2791, -54.0334, -17.9084, 18.2166, 36.7791, 
-    18.7166, 0.654194, 72.9041, 54.8416, 36.7792, 
-    109.029, 90.9666, 72.9042, -18.8708, -36.9334, 
-    -54.996, -36.9332, -54.9958, -73.0584, -54.9956, 
-    -73.0582, -91.1208
-  };
-
-  Float_t yp0[27] = 
-  {
-    -32.1395, -32.1395, -32.1395, -63.4247, -63.4247, 
-    -63.4247, -94.7098, -94.7098, -94.7098, 0.545689, 
-    31.8309, 63.1161, 0.545632, 31.8308, 63.116, 
-    0.545573, 31.8308, 63.116, 31.5737, 0.288616, 
-    -30.9965, 62.859, 31.5738, 0.288733, 94.1442, 
-    62.8591, 31.574
-  };
-
-  /* 
-     angles of rotation for three sets of supermodules
-     The angle is same for first nine, next nine and last nine 
-     supermodules 
-  */
+  // This routine finds the cell eta,phi for the new PMD rectangular 
+  // geometry in ALICE
+  // Authors : Bedanga Mohanty and Dipak Mishra - 29.4.2003
+  // modified by B. K. Nandi for change of coordinate sys
+  //
+  // SMA  ---> Supermodule Type A           ( SM - 0)
+  // SMAR ---> Supermodule Type A ROTATED   ( SM - 1)
+  // SMB  ---> Supermodule Type B           ( SM - 2)
+  // SMBR ---> Supermodule Type B ROTATED   ( SM - 3)
+  //
+  // ism   : Serial module number from 0 to 23 for each plane
+
+  // Corner positions (x,y) of the 24 unit moudles in ALICE PMD
+
+  double xcorner[24] =
+    {
+      74.8833,  53.0045, 31.1255,    //Type-A
+      74.8833,  53.0045, 31.1255,    //Type-A
+      -74.8833, -53.0044, -31.1255,  //Type-AR
+      -74.8833, -53.0044, -31.1255,  //Type-AR
+      8.9165, -33.7471,            //Type-B
+      8.9165, -33.7471,            //Type-B
+      8.9165, -33.7471,            //Type-B
+      -8.9165, 33.7471,            //Type-BR
+      -8.9165, 33.7471,            //Type-BR
+      -8.9165, 33.7471,            //Type-BR
+    };
+
   
-  Float_t th[3] = {0., -2.*kPi/3., 2.*kPi/3.};
-  Float_t xr, yr, xinit, yinit, cs, sn;
+  double ycorner[24] =
+    {
+      86.225,  86.225,  86.225,      //Type-A
+      37.075,  37.075,  37.075,      //Type-A
+      -86.225, -86.225, -86.225,     //Type-AR
+      -37.075, -37.075, -37.075,     //Type-AR
+      86.225,  86.225,               //Type-B
+      61.075,  61.075,               //Type-B
+      35.925,  35.925,               //Type-B
+      -86.225, -86.225,              //Type-BR
+      -61.075, -61.075,              //Type-BR
+      -35.925, -35.925               //Type-BR
+    };
+
   
-  /* 
-     xinit and yinit are coordinates of the cell in local coordinate system
-  */
+  const Float_t kSqroot3      = 1.73205;  // sqrt(3.);
+  const Float_t kCellRadius   = 0.25;
   
-  xinit = (j)*kCellDia+(k)/2.*kCellDia;
-  yinit = kSqroot3by2*(k)/2.;
-  i=ism/9;
-  cs=cos(th[i]);
-  sn=sin(th[i]);
   //
-  // rotate first
-  //
-  xr=cs*xinit+sn*yinit;
-  yr=-sn*xinit+cs*yinit;
-  //
-  // then translate
+  //Every even row of cells is shifted and placed
+  //in geant so this condition
   //
-  xpos=xr+xp0[ism];
-  ypos=yr+yp0[ism];
+  Float_t cellRadius = 0.25;
+  Float_t shift = 0.0;
+  if(xpad%2 == 0)
+    {
+      shift = -cellRadius/2.0;
+    }
+  else
+    {
+      shift = 0.0;
+    }
 
-}
 
-void AliPMDUtility::RectGeomCellPos(Int_t ism, Int_t ium, Int_t xpad, Int_t ypad, Float_t &xpos, Float_t &ypos)
+  if(ism < 6)
+    {
+      ypos = ycorner[ism] - (Float_t) xpad*kCellRadius*2.0 + shift;
+      xpos = xcorner[ism] - (Float_t) ypad*kSqroot3*kCellRadius;
+    }
+  else if(ism >=6 && ism < 12)
+    {
+      ypos = ycorner[ism] + (Float_t) xpad*kCellRadius*2.0 + shift;
+      xpos = xcorner[ism] + (Float_t) ypad*kSqroot3*kCellRadius;
+    }
+  else if(ism >= 12 && ism < 18)
+    {
+      ypos = ycorner[ism] - (Float_t) xpad*kCellRadius*2.0 + shift;
+      xpos = xcorner[ism] - (Float_t) ypad*kSqroot3*kCellRadius;
+    }
+  else if(ism >= 18 && ism < 24)
+    {
+      ypos = ycorner[ism] + (Float_t) xpad*kCellRadius*2.0 + shift;
+      xpos = xcorner[ism] + (Float_t) ypad*kSqroot3*kCellRadius;
+    }
+  // Apply the alignment here to the x, y values
+  if(ism < 6)
+    {
+      xpos += fSecTr[0][0];
+      ypos += fSecTr[0][1];
+    }
+  else if(ism >= 6 && ism < 12)
+    {
+      xpos += fSecTr[1][0];
+      ypos += fSecTr[1][1];
+    }
+  else if(ism >=12 && ism < 18)
+    {
+      xpos += fSecTr[2][0];
+      ypos += fSecTr[2][1];
+    }
+  else if(ism >= 18 && ism < 24)
+    {
+      xpos += fSecTr[3][0];
+      ypos += fSecTr[3][1];
+    }
+
+}
+// ---------------------------------------------------------- 
+void AliPMDUtility::RectGeomCellPos(Int_t ism, Float_t xpad, Float_t ypad, Float_t &xpos, Float_t &ypos)
 {
+  // If the xpad and ypad inputs are float, then 0.5 is added to it
+  // to find the layer which is shifted.
   // This routine finds the cell eta,phi for the new PMD rectangular 
   // geometry in ALICE
   // Authors : Bedanga Mohanty and Dipak Mishra - 29.4.2003
@@ -147,72 +244,110 @@ void AliPMDUtility::RectGeomCellPos(Int_t ism, Int_t ium, Int_t xpad, Int_t ypad
   // SMB  ---> Supermodule Type B           ( SM - 2)
   // SMBR ---> Supermodule Type B ROTATED   ( SM - 3)
   //
-  // ism   : number of supermodules in one plane = 4
-  // ium   : number of unitmodules  in one SM    = 6
-  // gbum  : (global) unit module numbering in a supermodule
-  //
-
-  Int_t gbum = ism*6 + ium;
-  Int_t irow  = xpad;
-  Int_t icol  = ypad;
+  // ism   : Serial Module number from 0 to 23 for each plane
 
   // Corner positions (x,y) of the 24 unit moudles in ALICE PMD
+
+  double xcorner[24] =
+    {
+      74.8833,  53.0045, 31.1255,    //Type-A
+      74.8833,  53.0045, 31.1255,    //Type-A
+      -74.8833, -53.0044, -31.1255,  //Type-AR
+      -74.8833, -53.0044, -31.1255,  //Type-AR
+      8.9165, -33.7471,            //Type-B
+      8.9165, -33.7471,            //Type-B
+      8.9165, -33.7471,            //Type-B
+      -8.9165, 33.7471,            //Type-BR
+      -8.9165, 33.7471,            //Type-BR
+      -8.9165, 33.7471,            //Type-BR
+    };
+
   
-  Double_t xcorner[24] =
-  {
-    85.15,  60.85,  36.55,  85.15,  60.85,  36.55, //SMA 
-    -85.15, -60.85, -36.55, -85.15, -60.85, -36.55, //SMAR
-    84.90,  36.60,  84.90,  36.60,  84.90,  36.60, //SMB
-    -84.90, -36.60, -84.90, -36.60, -84.90, -36.60  //SMBR
-  };
-  
-  Double_t ycorner[24] =
-  { 
-    32.45708755,  32.45708755,  32.45708755,        //SMA
-    -9.30645245,  -9.30645245,  -9.30645245,        //SMA
-    -32.45708755, -32.45708755, -32.45708755,        //SMAR
-    9.30645245,   9.30645245,   9.30645245,        //SMAR
-    -31.63540818, -31.63540818, -52.61435544,        //SMB
-    -52.61435544, -73.59330270, -73.59330270,        //SMB
-    31.63540818,  31.63540818,  52.61435544,        //SMBR
-    52.61435544,  73.59330270,  73.59330270         //SMBR
-  };
-  
-  const Float_t kSqroot3      = 1.73205;  // sqrt(3.);
-  const Float_t kCellRadius   = 0.25;
+
+  double ycorner[24] =
+    {
+      86.225,  86.225,  86.225,      //Type-A
+      37.075,  37.075,  37.075,      //Type-A
+      -86.225, -86.225, -86.225,     //Type-AR
+      -37.075, -37.075, -37.075,     //Type-AR
+      86.225,  86.225,               //Type-B
+      61.075,  61.075,               //Type-B
+      35.925,  35.925,               //Type-B
+      -86.225, -86.225,              //Type-BR
+      -61.075, -61.075,              //Type-BR
+      -35.925, -35.925               //Type-BR
+    };
+
+
+  const Float_t kSqroot3    = 1.73205;  // sqrt(3.);
+  const Float_t kCellRadius = 0.25;
   
   //
   //Every even row of cells is shifted and placed
   //in geant so this condition
   //
+  Float_t cellRadius = 0.25;
   Float_t shift = 0.0;
-  if(irow%2 == 0)
+  Int_t iirow = (Int_t) (xpad+0.5);
+  if(iirow%2 == 0)
     {
-      shift = 0.25;
+      shift = -cellRadius/2.0;
     }
   else
     {
       shift = 0.0;
     }
-  if(ism == 0 || ism == 2)
-    {
-      ypos = ycorner[gbum] + 
-       irow*kCellRadius*kSqroot3;
 
-      xpos = xcorner[gbum] - 
-       icol*2.0*kCellRadius - shift;
+  if(ism < 6)
+    {
+      ypos = ycorner[ism] - xpad*kCellRadius*2.0 + shift;
+      xpos = xcorner[ism] - ypad*kSqroot3*kCellRadius;
+    }
+  else if(ism >=6 && ism < 12)
+    {
+      ypos = ycorner[ism] + xpad*kCellRadius*2.0 + shift;
+      xpos = xcorner[ism] + ypad*kSqroot3*kCellRadius;
+    }
+  else if(ism >= 12 && ism < 18)
+    {
+      ypos = ycorner[ism] - xpad*kCellRadius*2.0 + shift;
+      xpos = xcorner[ism] - ypad*kSqroot3*kCellRadius;
     }
-  else if(ism == 1 || ism == 3)
+  else if(ism >= 18 && ism < 24)
     {
-      ypos = ycorner[gbum] -
-       irow*kCellRadius*kSqroot3;
+      ypos = ycorner[ism] + xpad*kCellRadius*2.0 + shift;
+      xpos = xcorner[ism] + ypad*kSqroot3*kCellRadius;
+    }
 
-      xpos = xcorner[gbum] +
-       icol*2.0*kCellRadius + shift;
+  // Apply the alignment here to the x, y values
+  if(ism < 6)
+    {
+      xpos += fSecTr[0][0];
+      ypos += fSecTr[0][1];
+    }
+  else if(ism >= 6 && ism < 12)
+    {
+      xpos += fSecTr[1][0];
+      ypos += fSecTr[1][1];
+    }
+  else if(ism >=12 && ism < 18)
+    {
+      xpos += fSecTr[2][0];
+      ypos += fSecTr[2][1];
     }
+  else if(ism >= 18 && ism < 24)
+    {
+      xpos += fSecTr[3][0];
+      ypos += fSecTr[3][1];
+    }
+
 }
 
-void AliPMDUtility::RectGeomCellPos(Int_t ism, Int_t ium, Float_t xpad, Float_t ypad, Float_t &xpos, Float_t &ypos)
+// -------------------------------------------------------- //
+
+void AliPMDUtility::RectGeomCellPos(Int_t ism, Float_t xpad,
+                                   Float_t ypad, Float_t &xpos,
+                                   Float_t &ypos, Float_t & zpos)
 {
   // If the xpad and ypad inputs are float, then 0.5 is added to it
   // to find the layer which is shifted.
@@ -226,37 +361,41 @@ void AliPMDUtility::RectGeomCellPos(Int_t ism, Int_t ium, Float_t xpad, Float_t
   // SMB  ---> Supermodule Type B           ( SM - 2)
   // SMBR ---> Supermodule Type B ROTATED   ( SM - 3)
   //
-  // ism   : number of supermodules in one plane = 4
-  // ium   : number of unitmodules  in one SM    = 6
-  // gbum  : (global) unit module numbering in a supermodule
-  //
-
-  Int_t gbum    = ism*6 + ium;
-  Float_t irow  = xpad;
-  Float_t icol  = ypad;
+  // ism   : Serial Module number from 0 to 23 for each plane
 
   // Corner positions (x,y) of the 24 unit moudles in ALICE PMD
+
+  double xcorner[24] =
+    {
+      74.8833,  53.0045, 31.1255,    //Type-A
+      74.8833,  53.0045, 31.1255,    //Type-A
+      -74.8833, -53.0044, -31.1255,  //Type-AR
+      -74.8833, -53.0044, -31.1255,  //Type-AR
+      8.9165, -33.7471,            //Type-B
+      8.9165, -33.7471,            //Type-B
+      8.9165, -33.7471,            //Type-B
+      -8.9165, 33.7471,            //Type-BR
+      -8.9165, 33.7471,            //Type-BR
+      -8.9165, 33.7471,            //Type-BR
+    };
+
   
-  Double_t xcorner[24] =
-  {
-    85.15,  60.85,  36.55,  85.15,  60.85,  36.55, //SMA 
-    -85.15, -60.85, -36.55, -85.15, -60.85, -36.55, //SMAR
-    84.90,  36.60,  84.90,  36.60,  84.90,  36.60, //SMB
-    -84.90, -36.60, -84.90, -36.60, -84.90, -36.60  //SMBR
-  };
-  
-  Double_t ycorner[24] =
-  { 
-    32.45708755,  32.45708755,  32.45708755,        //SMA
-    -9.30645245,  -9.30645245,  -9.30645245,        //SMA
-    -32.45708755, -32.45708755, -32.45708755,        //SMAR
-    9.30645245,   9.30645245,   9.30645245,        //SMAR
-    -31.63540818, -31.63540818, -52.61435544,        //SMB
-    -52.61435544, -73.59330270, -73.59330270,        //SMB
-    31.63540818,  31.63540818,  52.61435544,        //SMBR
-    52.61435544,  73.59330270,  73.59330270         //SMBR
-  };
-  
+
+  double ycorner[24] =
+    {
+      86.225,  86.225,  86.225,      //Type-A
+      37.075,  37.075,  37.075,      //Type-A
+      -86.225, -86.225, -86.225,     //Type-AR
+      -37.075, -37.075, -37.075,     //Type-AR
+      86.225,  86.225,               //Type-B
+      61.075,  61.075,               //Type-B
+      35.925,  35.925,               //Type-B
+      -86.225, -86.225,              //Type-BR
+      -61.075, -61.075,              //Type-BR
+      -35.925, -35.925               //Type-BR
+    };
+
+
   const Float_t kSqroot3    = 1.73205;  // sqrt(3.);
   const Float_t kCellRadius = 0.25;
   
@@ -264,31 +403,218 @@ void AliPMDUtility::RectGeomCellPos(Int_t ism, Int_t ium, Float_t xpad, Float_t
   //Every even row of cells is shifted and placed
   //in geant so this condition
   //
+  Float_t cellRadius = 0.25;
   Float_t shift = 0.0;
-  Int_t iirow = (Int_t) (irow+0.5);
+  Int_t iirow = (Int_t) (xpad+0.5);
   if(iirow%2 == 0)
     {
-      shift = 0.25;
+      shift = -cellRadius/2.0;
     }
   else
     {
       shift = 0.0;
     }
-  if(ism == 0 || ism == 2)
+
+  if(ism < 6)
+    {
+      ypos = ycorner[ism] - xpad*kCellRadius*2.0 + shift;
+      xpos = xcorner[ism] - ypad*kSqroot3*kCellRadius;
+    }
+  else if(ism >=6 && ism < 12)
     {
-      ypos = ycorner[gbum] + 
-       irow*kCellRadius*kSqroot3;
+      ypos = ycorner[ism] + xpad*kCellRadius*2.0 + shift;
+      xpos = xcorner[ism] + ypad*kSqroot3*kCellRadius;
+    }
+  else if(ism >= 12 && ism < 18)
+    {
+      ypos = ycorner[ism] - xpad*kCellRadius*2.0 + shift;
+      xpos = xcorner[ism] - ypad*kSqroot3*kCellRadius;
+    }
+  else if(ism >= 18 && ism < 24)
+    {
+      ypos = ycorner[ism] + xpad*kCellRadius*2.0 + shift;
+      xpos = xcorner[ism] + ypad*kSqroot3*kCellRadius;
+    }
 
-      xpos = xcorner[gbum] - 
-       icol*2.0*kCellRadius - shift;
+  // Apply the alignment here to the x, y, and z values
+  if(ism < 6)
+    {
+      xpos += fSecTr[0][0];
+      ypos += fSecTr[0][1];
+      zpos += fSecTr[0][2];
+    }
+  else if(ism >= 6 && ism < 12)
+    {
+      xpos += fSecTr[1][0];
+      ypos += fSecTr[1][1];
+      zpos += fSecTr[1][2];
+    }
+  else if(ism >=12 && ism < 18)
+    {
+      xpos += fSecTr[2][0];
+      ypos += fSecTr[2][1];
+      zpos += fSecTr[2][2];
+    }
+  else if(ism >= 18 && ism < 24)
+    {
+      xpos += fSecTr[3][0];
+      ypos += fSecTr[3][1];
+      zpos += fSecTr[3][2];
     }
-  else if(ism == 1 || ism == 3)
+
+
+
+}
+// -------------------------------------------------------- //
+
+void AliPMDUtility::GenerateBoundaryPoints(Int_t ism, Float_t &x1ism, 
+                                          Float_t &y1ism, Float_t &x2ism,
+                                          Float_t &y2ism)
+{
+  // Generate bounding-box.
+
+
+    Float_t xism = 0, yism = 0;
+    Float_t dxism = 0., dyism = 0.;
+
+    const Float_t kRad     = 0.25;
+    const Float_t kSqRoot3 = 1.732050808;
+    const Float_t kDia     = 0.50;
+
+
+  const Double_t kXcorner[24] =
+    {
+      74.8833,  53.0045, 31.1255,    //Type-A
+      74.8833,  53.0045, 31.1255,    //Type-A
+      -74.8833, -53.0044, -31.1255,  //Type-AR
+      -74.8833, -53.0044, -31.1255,  //Type-AR
+      8.9165, -33.7471,            //Type-B
+      8.9165, -33.7471,            //Type-B
+      8.9165, -33.7471,            //Type-B
+      -8.9165, 33.7471,            //Type-BR
+      -8.9165, 33.7471,            //Type-BR
+      -8.9165, 33.7471,            //Type-BR
+    };
+
+
+  const Double_t kYcorner[24] =
     {
-      ypos = ycorner[gbum] -
-       irow*kCellRadius*kSqroot3;
+      86.225,  86.225,  86.225,      //Type-A
+      37.075,  37.075,  37.075,      //Type-A
+      -86.225, -86.225, -86.225,     //Type-AR
+      -37.075, -37.075, -37.075,     //Type-AR
+      86.225,  86.225,               //Type-B
+      61.075,  61.075,               //Type-B
+      35.925,  35.925,               //Type-B
+      -86.225, -86.225,              //Type-BR
+      -61.075, -61.075,              //Type-BR
+      -35.925, -35.925               //Type-BR
+    };
 
-      xpos = xcorner[gbum] +
-       icol*2.0*kCellRadius + shift;
+
+  if (ism > 23) ism -= 24;
+
+
+  if (ism < 6)
+    {
+      xism  = kXcorner[ism] + kRad;
+      yism  = kYcorner[ism] + kRad;
+      dxism = -kRad*kSqRoot3*48.;
+      dyism = -kDia*96. - kRad;
+  }
+  if (ism >= 6 && ism < 12)
+    {
+      xism  = kXcorner[ism] - kRad;
+      yism  = kYcorner[ism] - kRad;
+      dxism = kRad*kSqRoot3*48.;
+      dyism = kDia*96. + kRad;
+  }
+  if (ism >= 12 && ism < 18)
+    {
+      xism  = kXcorner[ism] + kRad;
+      yism  = kYcorner[ism] + kRad;
+      dxism = -kRad*kSqRoot3*96.;
+      dyism = -kDia*48. - kRad;
+  }
+  if (ism >= 18 && ism < 24)
+    {
+      xism  = kXcorner[ism] - kRad;
+      yism  = kYcorner[ism] - kRad;
+      dxism = kRad*kSqRoot3*96.;
+      dyism = kDia*48. + kRad;
+  }
+
+  x1ism = xism;
+  x2ism = xism + dxism;
+  y1ism = yism;
+  y2ism = yism + dyism;
+
+}
+// ------------------------------------------------------------------- //
+
+void AliPMDUtility::DrawPMDModule(Int_t idet)
+{
+
+    Float_t x1ism = 0., x2ism = 0., y1ism = 0., y2ism = 0.;
+    Float_t deltaX = 0., deltaY = 0.;
+    
+    //TH2F *h2 = new TH2F("h2","Y vs. X",200,-100.,100.,200,-100.,100.);
+    //h2->Draw();
+
+    TLine t;
+    t.SetLineColor(2);
+
+    TText tt;
+    tt.SetTextColor(4);
+
+    Char_t smnumber[10];
+
+    for(Int_t ism=0; ism < 24; ism++)
+    {
+       GenerateBoundaryPoints(ism, x1ism, y1ism, x2ism, y2ism);
+       deltaX = (x2ism - x1ism)/2.;
+       deltaY = (y2ism - y1ism)/2.;
+       if (fWriteModule == 1)
+       {
+         if(idet == 0)
+           {
+             snprintf(smnumber,10,"%d",ism);
+           }
+         else if (idet == 1)
+           {
+             snprintf(smnumber,10,"%d",24+ism);
+           }
+           tt.DrawText(x1ism+deltaX,y1ism+deltaY,smnumber);
+       }
+       t.DrawLine(x1ism, y1ism, x1ism, y2ism);
+       t.DrawLine(x1ism, y1ism, x2ism, y1ism);
+       t.DrawLine(x2ism, y1ism, x2ism, y2ism);
+       t.DrawLine(x1ism, y2ism, x2ism, y2ism);
+    }
+
+}
+
+// ------------------------------------------------------------------- //
+
+
+void AliPMDUtility::ApplyVertexCorrection(Float_t vertex[], Float_t xpos,
+                                         Float_t ypos, Float_t zpos)
+{
+  // Not implemented
+  fPx = xpos - vertex[0];
+  fPy = ypos - vertex[1];
+  fPz = zpos - vertex[2];
+}
+void AliPMDUtility::ApplyAlignment(Double_t sectr[][3])
+{
+  // Get the alignment stuff here
+
+  for (Int_t isector=0; isector<4; isector++)
+    {
+      for(Int_t ixyz=0; ixyz < 3; ixyz++)
+       {
+         fSecTr[isector][ixyz] = (Float_t) sectr[isector][ixyz];
+       }
     }
 }
 
@@ -305,19 +631,21 @@ void AliPMDUtility::SetXYZ(Float_t xpos, Float_t ypos, Float_t zpos)
   fPy = ypos;
   fPz = zpos;
 }
+void AliPMDUtility::SetWriteModule(Int_t wrmod)
+{
+    fWriteModule = wrmod;
+}
 void AliPMDUtility::CalculateEta()
 {
-  Float_t rpxpy, theta, eta;
-
-  rpxpy  = TMath::Sqrt(fPx*fPx + fPy*fPy);
-  theta  = TMath::ATan2(rpxpy,fPz);
-  eta    = -TMath::Log(TMath::Tan(0.5*theta));
+  Float_t rpxpy  = TMath::Sqrt(fPx*fPx + fPy*fPy);
+  Float_t theta  = TMath::ATan2(rpxpy,fPz);
+  Float_t eta    = -TMath::Log(TMath::Tan(0.5*theta));
   fTheta = theta;
   fEta   = eta;
 }
 void AliPMDUtility::CalculatePhi()
 {
-  Float_t pybypx, phi = 0., phi1;
+  Float_t pybypx = 0., phi = 0., phi1 = 0.;
 
   if(fPx==0)
     {
@@ -343,14 +671,13 @@ void AliPMDUtility::CalculatePhi()
 }
 void AliPMDUtility::CalculateEtaPhi()
 {
-  Float_t rpxpy, theta, eta;
-  Float_t pybypx, phi = 0., phi1;
+  Float_t pybypx = 0., phi = 0., phi1 = 0.;
 
-  rpxpy = TMath::Sqrt(fPx*fPx + fPy*fPy);
-  theta = TMath::ATan2(rpxpy,fPz);
-  eta   = -TMath::Log(TMath::Tan(0.5*theta));
+  Float_t rpxpy = TMath::Sqrt(fPx*fPx + fPy*fPy);
+  Float_t theta = TMath::ATan2(rpxpy,fPz);
+  Float_t eta   = -TMath::Log(TMath::Tan(0.5*theta));
   
-  if(fPx==0)
+  if(fPx == 0)
     {
       if(fPy>0) phi = 90.;
       if(fPy<0) phi = 270.;
@@ -372,6 +699,22 @@ void AliPMDUtility::CalculateEtaPhi()
   fEta   = eta;
   fPhi   = phi;
 }
+void AliPMDUtility::CalculateXY(Float_t eta, Float_t phi, Float_t zpos)
+{
+  // Not implemented
+
+  //  eta   = -TMath::Log(TMath::Tan(0.5*theta));
+
+  Float_t xpos = 0., ypos = 0.;
+
+  //  Float_t theta = 2.0*TMath::ATan(TMath::Log(-eta));
+
+  fEta = eta;
+  fPhi = phi;
+  fPx  = xpos;
+  fPy  = ypos;
+  fPz  = zpos;
+}
 Float_t AliPMDUtility::GetTheta() const
 {
   return fTheta;
@@ -384,4 +727,16 @@ Float_t AliPMDUtility::GetPhi() const
 {
   return fPhi;
 }
-
+Float_t AliPMDUtility::GetX() const
+{
+  return fPx;
+}
+Float_t AliPMDUtility::GetY() const
+{
+  return fPy;
+}
+Float_t AliPMDUtility::GetZ() const
+{
+  return fPz;
+}
+//--------------------------------------------------------------------//