+//______________________________________________________________________
+Bool_t AliITSsegmentationSPD::LocalToDet(Float_t x,Float_t z,
+ Int_t &ix,Int_t &iz) const {
+ // 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.
+ // Return:
+ // kTRUE if point x,z is inside sensitive volume, kFALSE otherwise.
+ // 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 kFALSE; // outside x range.
+ if(z<dz) return kFALSE; // outside z range.
+ for(i=0;i<Npx();i++){
+ dx += kconv*fCellSizeX[i];
+ if(x<dx) break;
+ } // end for i
+ if(i>=Npx()) return kFALSE; // outside x range.
+ for(j=0;j<Npz();j++){
+ dz += kconv*fCellSizeZ[j];
+ if(z<dz) break;
+ } // end for j
+ if(j>=Npz()) return kFALSE; // outside z range.
+ ix = i;
+ iz = j;
+ return kTRUE; // Found ix and iz, return.
+}
+//______________________________________________________________________
+void AliITSsegmentationSPD::DetToLocal(Int_t ix,Int_t iz,Float_t &x,Float_t &z) const
+{
+// 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.
+}
+//______________________________________________________________________
+void AliITSsegmentationSPD::CellBoundries(Int_t ix,Int_t iz,
+ Double_t &xl,Double_t &xu,
+ Double_t &zl,Double_t &zu) const
+{
+// 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:
+// Double_t xl detector local coordinate cell lower bounds x in cm
+// with respect to the center of the sensitive volume.
+// Double_t xu detector local coordinate cell upper bounds x in cm
+// with respect to the center of the sensitive volume.
+// Double_t zl detector local coordinate lower bounds z in cm with
+// respect to the center of the sensitive volulme.
+// Double_t zu detector local coordinate upper bounds 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()
+// and -0.5*Dx() or -0.5*Dz() and -0.5*Dz() are returned.
+ Int_t i,j;
+ const Float_t kconv = 1.0E-04; // converts microns to cm.
+ Float_t x,z;
+
+ xl = xu = x = -0.5*kconv*Dx(); // default value.
+ zl = zu = 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
+ xl = x;
+ x += kconv*fCellSizeX[ix];
+ xu = x;
+ for(j=0;j<iz;j++) z += kconv*fCellSizeZ[j]; // sum up cell iz-1
+ zl = z;
+ z += kconv*fCellSizeZ[iz];
+ zu = z;
+ return; // Found x and z, return.
+}