]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSsegmentationSPD.cxx
A typo corrected
[u/mrichter/AliRoot.git] / ITS / AliITSsegmentationSPD.cxx
index 69b0d4340ebf60a89182973348bb6a6d0383d2d6..129d952d89e1b90b77da33ee1231569bd0dcf561 100644 (file)
  **************************************************************************/
 
 #include <TMath.h>
+#include <TF1.h>
 
 #include "AliITSsegmentationSPD.h"
+#include "AliITSgeom.h"
 
 ClassImp(AliITSsegmentationSPD)
 
@@ -43,7 +45,7 @@ Float_t ZpitchFromCol300(Int_t col) {
   return 300.0;
 }
 //_____________________________________________________________________________
-Float_t ColFromZ(Float_t z) {
+Float_t  AliITSsegmentationSPD::ColFromZ(Float_t z) {
 // hard-wired - keep it like this till we can parametrise 
 // and get rid of AliITSgeomSPD425
 // Get column number for each z-coordinate taking into account the 
@@ -79,11 +81,11 @@ Float_t ColFromZ(Float_t z) {
   } else if( z < 83600) {  
     col = 161 + (z - 70425)/pitchz;
   }   
-  return col;
+  return TMath::Abs(col);
 }
 
 //_____________________________________________________________________________
-Float_t ZFromCol(Int_t col) {
+Float_t  AliITSsegmentationSPD::ZFromCol(Int_t col) {
 // same comments as above
 // Get z-coordinate for each colunm number
 
@@ -116,29 +118,33 @@ Float_t ZFromCol(Int_t col) {
     z = 69175 + (col -159 + 0.5)*pitchz;    
   } else if( col >= 161 && col <= 191) {  
     z = 70425 + (col -161 + 0.5)*pitchz;    
-  }   
+  }
 
   return z;
 }
-
-Float_t ZpitchFromCol(Int_t col) {
+//______________________________________________________________________
+Float_t AliITSsegmentationSPD::ZpitchFromCol(Int_t col) {
 // Get pitch size in z direction for each colunm
 
-  Float_t pitchz = 425;
-  if( col >=32 && col <= 33 ) {  
-    pitchz = 625;
-  } else if( col >= 64 && col <= 65) {  
-    pitchz = 625;
-  } else if( col >= 96 && col <= 97) {  
-    pitchz = 625;
-  } else if( col >= 128 && col <= 129) {  
-    pitchz = 625;
-  } else if( col >= 160 && col <= 161) {  
-    pitchz = 625;
-  }   
-  return pitchz;
+    Float_t pitchz = 425;
+    if(col < 0){
+       pitchz = 0.0;
+    } else if(col >=  31 && col <=  32) {  
+       pitchz = 625;
+    } else if(col >=  63 && col <=  64) {  
+       pitchz = 625;
+    } else if(col >=  95 && col <=  96) {  
+       pitchz = 625;
+    } else if(col >= 127 && col <= 128) {  
+       pitchz = 625;
+    } else if(col >= 159 && col <= 160) {  
+       pitchz = 625;
+    } else if(col>=192){
+       pitchz = 0.0;
+    }
+    return pitchz;
 }
-
+//______________________________________________________________________
 AliITSsegmentationSPD::AliITSsegmentationSPD(){
   // Default constructor
    fNpx = 0;
@@ -147,7 +153,7 @@ AliITSsegmentationSPD::AliITSsegmentationSPD(){
    fGeom = 0;
 
 }
-//____________________________________________________________________________
+//______________________________________________________________________
 AliITSsegmentationSPD::AliITSsegmentationSPD(AliITSgeom *gm){
   // Constructor
    fCorr=0;
@@ -157,15 +163,15 @@ AliITSsegmentationSPD::AliITSsegmentationSPD(AliITSgeom *gm){
    fGeom = gm;
 
 }
-//____________________________________________________________________________
+//______________________________________________________________________
 AliITSsegmentationSPD& AliITSsegmentationSPD::operator=(AliITSsegmentationSPD &source){
    // = operator
-   Int_t i;
    if(this==&source) return *this;
    this->fNpx  = source.fNpx;
    this->fNpz  = source.fNpz;
    this->fDx   = source.fDx;
    this->fDy   = source.fDy;
+   Int_t i;
    for(i=0;i<256;i++) this->fCellSizeX[i] = source.fCellSizeX[i];
    for(i=0;i<280;i++) this->fCellSizeZ[i] = source.fCellSizeZ[i];
    this->fCorr = new TF1(*(source.fCorr));// make a proper copy of the function
@@ -184,8 +190,8 @@ void AliITSsegmentationSPD::Init300(){
 // long. It has 256  50 micron pixels in x and 279 300 micron size
 // pixels in z.
 
-    Int_t i;
     //const Float_t kconv=10000.;
+    Int_t i;
     fNpx = 256; // The number of X pixel Cell same as in fCellSizeX array size
     fNpz = 279; // The number of Z pixel Cell same as in fCellSizeZ array size
     for(i=0;i<fNpx;i++) fCellSizeX[i] = 50.0; // microns all the same
@@ -205,8 +211,8 @@ void AliITSsegmentationSPD::Init(){
 // long. It has 256  50 micron pixels in x and 197 mostly 425 micron size
 // pixels in z. The two pixels between each readout chip are 625 microns long.
 
-    Int_t i;
     //const Float_t kconv=10000.;
+    Int_t i;
     fNpx = 256; // The number of X pixel Cell same as in fCellSizeX array size
     fNpz = 192; // The number of Z pixel Cell same as in fCellSizeZ array size
     for(i=0;i<fNpx;i++) fCellSizeX[i] = 50.0; // microns all the same
@@ -217,11 +223,11 @@ void AliITSsegmentationSPD::Init(){
     fDz = 0;
     for(i=0;i<fNpz;i++) fDz += fCellSizeZ[i];
     fDy = 300.0; //microns  SPD sensitive layer thickness
-    printf(" AliITSsegmentationSPD - Init: fNpx fNpz fDx fDz %d %d %f %f\n",fNpx, fNpz, fDx, fDz);
+    //printf(" AliITSsegmentationSPD - Init: fNpx fNpz fDx fDz %d %d %f %f\n",fNpx, fNpz, fDx, fDz);
 
 }
 //------------------------------
-void AliITSsegmentationSPD::SetNCells(Int_t p1, Int_t p2){
+void AliITSsegmentationSPD::SetNPads(Int_t p1, Int_t p2){
   // for SPD this function should be used ONLY when a beam test setup 
   // configuration is studied
 
@@ -250,7 +256,7 @@ Float_t AliITSsegmentationSPD::Dpz(Int_t i){
    return ZpitchFromCol(i);
 }
 //------------------------------
-void AliITSsegmentationSPD::GetCellIxz(Float_t &x,Float_t &z,Int_t &ix,Int_t &iz){
+void AliITSsegmentationSPD::GetPadIxz(Float_t x,Float_t z,Int_t &ix,Int_t &iz){
 //  Returns pixel coordinates (ix,iz) for given real local coordinates (x,z)
 //
 
@@ -262,12 +268,9 @@ void AliITSsegmentationSPD::GetCellIxz(Float_t &x,Float_t &z,Int_t &ix,Int_t &iz
     // different segmentation on z
     iz = (Int_t)(ColFromZ(z) + 1);
 
-    x /= dpx;
-    z = ColFromZ(z);
 
     if (iz >  fNpz) iz= fNpz;
     if (ix >  fNpx) ix= fNpx;
-
     /*
     if (iz < -fNpz) iz= -fNpz;
     if (ix < -fNpx) ix=-fNpx;
@@ -275,7 +278,21 @@ void AliITSsegmentationSPD::GetCellIxz(Float_t &x,Float_t &z,Int_t &ix,Int_t &iz
 }
 
 //------------------------------
-void AliITSsegmentationSPD::GetCellCxz(Int_t ix,Int_t iz,Float_t &x,Float_t&z){
+void AliITSsegmentationSPD::GetPadTxz(Float_t &x,Float_t &z){
+//  local transformation of real local coordinates (x,z)
+//
+
+    // expects x, z in microns
+
+    // same segmentation on x
+    Float_t dpx=Dpx(0);
+
+    x /= dpx;
+    z = ColFromZ(z);
+
+}
+//------------------------------
+void AliITSsegmentationSPD::GetPadCxz(Int_t ix,Int_t iz,Float_t &x,Float_t&z){
     // Transform from pixel to real local coordinates
 
     // returns x, z in microns
@@ -318,3 +335,69 @@ Neighbours(Int_t iX, Int_t iZ, Int_t* Nlist, Int_t Xlist[8], Int_t Zlist[8]){
     Xlist[7]=iX+1;
     Zlist[7]=iZ-1;
 }
+//______________________________________________________________________
+void AliITSsegmentationSPD::LocalToDet(Float_t x,Float_t z,Int_t &ix,Int_t &iz){
+// Transformation from Geant detector centered local coordinates (cm) to
+// Pixel cell numbers ix and iz.
+// Input:
+// Float_t   x        detector local coordinate x in cm with respect to the
+//                    center of the sensitive volume.
+// Float_t   z        detector local coordinate z in cm with respect to the
+//                    center of the sensitive volulme.
+// Output:
+// Int_t    ix        detector x cell coordinate. Has the range 0<=ix<fNpx.
+// Int_t    iz        detector z cell coordinate. Has the range 0<=iz<fNpz.
+//   A value of -1 for ix or iz indecates that this point is outside of the
+// detector segmentation as defined.
+    Int_t i,j;
+    Float_t dx,dz;
+    const Float_t kconv = 1.0E-04; // converts microns to cm.
+
+    dx = -0.5*kconv*Dx();
+    dz = -0.5*kconv*Dz();
+    ix = -1;
+    iz = -1;
+    if(x<dx) return; // outside x range.
+    if(z<dz) return; // outside z range.
+    for(i=0;i<Npx();i++){
+       dx += kconv*fCellSizeX[i];
+       if(x<dx) break;
+    } // end for i
+    if(i>=Npx()) return; // outside x range.
+    for(j=0;j<Npz();j++){
+       dz += kconv*fCellSizeZ[j];
+       if(z<dz) break;
+    } // end for j
+    if(j>=Npz()) return; // outside z range.
+    ix = i;
+    iz = j;
+    return; // Found ix and iz, return.
+}
+//______________________________________________________________________
+void AliITSsegmentationSPD::DetToLocal(Int_t ix,Int_t iz,Float_t &x,Float_t &z)
+{
+// Transformation from Detector cell coordiantes to Geant detector centerd 
+// local coordinates (cm).
+// Input:
+// Int_t    ix        detector x cell coordinate. Has the range 0<=ix<fNpx.
+// Int_t    iz        detector z cell coordinate. Has the range 0<=iz<fNpz.
+// Output:
+// Float_t   x        detector local coordinate x in cm with respect to the
+//                    center of the sensitive volume.
+// Float_t   z        detector local coordinate z in cm with respect to the
+//                    center of the sensitive volulme.
+// If ix and or iz is outside of the segmentation range a value of -0.5*Dx()
+// or -0.5*Dz() is returned.
+    Int_t i,j;
+    const Float_t kconv = 1.0E-04; // converts microns to cm.
+
+    x = -0.5*kconv*Dx(); // default value.
+    z = -0.5*kconv*Dz(); // default value.
+    if(ix<0 || ix>=Npx()) return; // outside of detector
+    if(iz<0 || iz>=Npz()) return; // outside of detctor
+    for(i=0;i<ix;i++) x += kconv*fCellSizeX[i]; // sum up to cell ix-1
+    x += 0.5*kconv*fCellSizeX[ix]; // add 1/2 of cell ix for center location.
+    for(j=0;j<iz;j++) z += kconv*fCellSizeZ[j]; // sum up cell iz-1
+    z += 0.5*kconv*fCellSizeZ[iz]; // add 1/2 of cell iz for center location.
+    return; // Found x and z, return.
+}