+//______________________________________________________________________
+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.
+}
+//----------------------------------------------------------------------
+Int_t AliITSsegmentationSPD::GetChipFromChannel(Int_t, Int_t iz) const {
+ // returns chip number (in range 0-4) starting from channel number
+ if(iz>=fNpz || iz<0 ){
+ AliWarning("Bad cell number");
+ return -1;
+ }
+ Int_t theChip=iz/fgkNcolumnsPerChip;
+ return theChip;
+}
+//----------------------------------------------------------------------
+Int_t AliITSsegmentationSPD::GetChipFromLocal(Float_t, Float_t zloc) const {
+ // returns chip number (in range 0-4) starting from local coordinates
+ Int_t ix0,iz;
+ if (!LocalToDet(0,zloc,ix0,iz)) {
+ AliWarning("Bad local coordinate");
+ return -1;
+ }
+ return GetChipFromChannel(ix0,iz);
+}
+//----------------------------------------------------------------------
+Int_t AliITSsegmentationSPD::GetChipsInLocalWindow(Int_t* array, Float_t zmin, Float_t zmax, Float_t, Float_t) const {
+ // returns the number of chips containing a road defined by given local coordinate limits
+
+ const Float_t kconv = 1.0E-04; // converts microns to cm.
+
+ if (zmin>zmax) {
+ AliWarning("Bad coordinate limits: zmin>zmax!");
+ return -1;
+ }
+
+ Int_t nChipInW = 0;
+
+ Float_t zminDet = -0.5*kconv*Dz();
+ Float_t zmaxDet = 0.5*kconv*Dz();
+ if(zmin<zminDet) zmin=zminDet;
+ if(zmax>zmaxDet) zmax=zmaxDet;
+
+ Int_t n1 = GetChipFromLocal(0,zmin);
+ array[nChipInW] = n1;
+ nChipInW++;
+
+ Int_t n2 = GetChipFromLocal(0,zmax);
+
+ if(n2!=n1){
+ Int_t imin=TMath::Min(n1,n2);
+ Int_t imax=TMath::Max(n1,n2);
+ for(Int_t ichip=imin; ichip<=imax; ichip++){
+ if(ichip==n1) continue;
+ array[nChipInW]=ichip;
+ nChipInW++;
+ }
+ }
+
+ return nChipInW;
+}
+//----------------------------------------------------------------------