1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 /* $Id: AliITSsegmentationPixUpg.cxx 47180 2011-02-08 09:42:29Z masera $ */
17 #include <TGeoManager.h>
18 #include <TGeoVolume.h>
20 #include "AliITSsegmentationPixUpg.h"
22 ////////////////////////////////////////////////////////////////////////////////////////////////////////////
23 // Segmentation class for pixels //
24 // Questions to solve: are guardrings needed and do they belong to the sensor or to the module in TGeo //
25 // At the moment assume that the local coord syst. is located at bottom left corner //
26 // of the ACTIVE matrix. If the guardring to be accounted in the local coords, in //
27 // the Z and X conversions one needs to first subtract the fGuardLft and fGuardBot //
28 // from the local Z,X coordinates //
30 ////////////////////////////////////////////////////////////////////////////////////////////////////////////
32 ClassImp(AliITSsegmentationPixUpg)
34 //_____________________________________________________________________________RS
35 AliITSsegmentationPixUpg::AliITSsegmentationPixUpg(int nchips,int ncol,int nrow,
36 double pitchX,double pitchZ,
37 double pitchLftC,double pitchRgtC,
39 double edgL,double edgR,double edgT,double edgB)
40 : AliITSsegmentation()
47 ,fPitchZLftCol(pitchLftC<0 ? pitchZ:pitchLftC)
48 ,fPitchZRgtCol(pitchRgtC<0 ? pitchZ:pitchRgtC)
51 ,fNColPerChip(nchips>0 ? ncol/nchips:0)
55 // Default constructor, sizes in microns
56 fChipDZ = (fNColPerChip-2)*fPitchZ + fPitchZLftCol + fPitchZRgtCol;
57 SetDetSize( fNRow*fPitchX /*+fGuardTop+fGuardBot*/,
58 fNChips*fChipDZ /*+fGuardLft+fGuardRgt*/,
63 //_____________________________________________________________________________RS
64 void AliITSsegmentationPixUpg::GetPadIxz(Float_t x,Float_t z,Int_t &ix,Int_t &iz) const
66 // Returns pixel coordinates (ix,iz) for given real local coordinates (x,z)
67 // expects x, z in microns
68 ix = int(x/fPitchX) + 1;
69 iz = int(Z2Col(z)) + 1;
71 if (iz > fNCol) iz= fNCol;
72 if (ix > fNRow) ix= fNRow;
76 //_____________________________________________________________________________RS
77 void AliITSsegmentationPixUpg::GetPadTxz(Float_t &x,Float_t &z) const
79 // local transformation of real local coordinates (x,z)
80 // expects x, z in microns
86 //_____________________________________________________________________________RS
87 void AliITSsegmentationPixUpg::GetPadCxz(Int_t ix,Int_t iz,Float_t &x,Float_t&z) const
89 // Transform from pixel to real local coordinates
90 // returns x, z in microns
91 x = (ix>0) ? Float_t((ix-0.5)*fPitchX) : Float_t((ix+0.5)*fPitchX);
96 //_____________________________________________________________________________RS
97 Float_t AliITSsegmentationPixUpg::Z2Col(Float_t z) const
99 // get column number (from 0) from local Z
100 int chip = z/fChipDZ;
101 float col = chip*fNColPerChip;
103 if (z<fPitchZLftCol) col += z/fPitchZLftCol;
107 if (z<(fChipDZ-fPitchZRgtCol)) col += 1+z/fPitchZ;
108 else col += 1+(z - (fNColPerChip-2)*fPitchZ)/fPitchZRgtCol;
113 //_____________________________________________________________________________RS
114 Float_t AliITSsegmentationPixUpg::Col2Z(Int_t col) const
116 // convert column number (from 0) to Z coordinate
117 int nchip = col/fNColPerChip;
119 float z = nchip*fChipDZ;
120 if (!col) z -= fPitchZRgtCol/2;
121 else if (col==1) z += fPitchZLftCol/2;
122 else if (col==fNColPerChip-1) z += fChipDZ - fPitchZRgtCol/2;
123 else z += fPitchZLftCol + (col-0.5)*fChipDZ;
128 //______________________________________________________________________RS
129 AliITSsegmentationPixUpg& AliITSsegmentationPixUpg::operator=(const AliITSsegmentationPixUpg &src)
132 if(this==&src) return *this;
133 AliITSsegmentation::operator=(src);
136 fNColPerChip = src.fNColPerChip;
137 fNChips = src.fNChips;
138 fChipDZ = src.fChipDZ;
139 fPitchZRgtCol = src.fPitchZRgtCol;
140 fPitchZLftCol = src.fPitchZLftCol;
141 fPitchZ = src.fPitchZ;
142 fPitchX = src.fPitchX;
144 fGuardBot = src.fGuardBot;
145 fGuardTop = src.fGuardTop;
146 fGuardRgt = src.fGuardRgt;
147 fGuardLft = src.fGuardLft;
152 //____________________________________________________________________________RS
153 AliITSsegmentationPixUpg::AliITSsegmentationPixUpg(const AliITSsegmentationPixUpg &src) :
154 AliITSsegmentation(src)
155 ,fGuardLft(src.fGuardLft)
156 ,fGuardRgt(src.fGuardRgt)
157 ,fGuardTop(src.fGuardTop)
158 ,fGuardBot(src.fGuardBot)
159 ,fPitchX(src.fPitchX)
160 ,fPitchZ(src.fPitchZ)
161 ,fPitchZLftCol(src.fPitchZLftCol)
162 ,fPitchZRgtCol(src.fPitchZRgtCol)
163 ,fChipDZ(src.fChipDZ)
164 ,fNChips(src.fNChips)
165 ,fNColPerChip(src.fNColPerChip)
171 //____________________________________________________________________________RS
172 Float_t AliITSsegmentationPixUpg::Dpx(Int_t ) const
174 //returs x pixel pitch for a give pixel
178 //____________________________________________________________________________RS
179 Float_t AliITSsegmentationPixUpg::Dpz(Int_t col) const
181 // returns z pixel pitch for a given pixel (cols starts from 0)
183 if (!col) return fPitchZLftCol;
184 if (col==fNColPerChip-1) return fPitchZRgtCol;
189 //------------------------------
190 void AliITSsegmentationPixUpg::Neighbours(Int_t iX, Int_t iZ, Int_t* nlist, Int_t xlist[8], Int_t zlist[8]) const
192 // returns the neighbouring pixels for use in Cluster Finders and the like.
195 xlist[0]=xlist[1]=iX;
200 zlist[2]=zlist[3]=iZ;
216 //______________________________________________________________________
217 Bool_t AliITSsegmentationPixUpg::LocalToDet(Float_t x,Float_t z,Int_t &ix,Int_t &iz) const
219 // Transformation from Geant detector centered local coordinates (cm) to
220 // Pixel cell numbers ix and iz.
222 // Float_t x detector local coordinate x in cm with respect to
223 // the center of the sensitive volume.
224 // Float_t z detector local coordinate z in cm with respect to
225 // the center of the sensitive volulme.
227 // Int_t ix detector x cell coordinate. Has the range
229 // Int_t iz detector z cell coordinate. Has the range
232 // kTRUE if point x,z is inside sensitive volume, kFALSE otherwise.
233 // A value of -1 for ix or iz indecates that this point is outside of the
234 // detector segmentation as defined.
235 x = x*kCM2MC+0.5*Dx();
236 z = z*kCM2MC+0.5*Dz();
238 if(x<0 || x>Dx()) return kFALSE; // outside x range.
239 if(z<0 || z>Dz()) return kFALSE; // outside z range.
242 return kTRUE; // Found ix and iz, return.
245 //______________________________________________________________________
246 void AliITSsegmentationPixUpg::DetToLocal(Int_t ix,Int_t iz,Float_t &x,Float_t &z) const
248 // Transformation from Detector cell coordiantes to Geant detector centerd
249 // local coordinates (cm).
251 // Int_t ix detector x cell coordinate. Has the range 0<=ix<fNRow.
252 // Int_t iz detector z cell coordinate. Has the range 0<=iz<fNCol.
254 // Float_t x detector local coordinate x in cm with respect to the
255 // center of the sensitive volume.
256 // Float_t z detector local coordinate z in cm with respect to the
257 // center of the sensitive volulme.
258 // If ix and or iz is outside of the segmentation range a value of -0.5*Dx()
259 // or -0.5*Dz() is returned.
261 x = -0.5/kCM2MC*Dx(); // default value.
262 z = -0.5/kCM2MC*Dz(); // default value.
263 // RS: to check: why we don't do strict check for [0:n)
264 if(ix<0 || ix>=fNRow) return; // outside of detector
265 if(iz<0 || iz>=fNCol) return; // outside of detctor
266 x += (ix+0.5)*fPitchX*(1./kCM2MC); // RS: we go to the center of the pad, i.e. + pitch/2, not to the boundary as in SPD
267 z += Col2Z(iz)*(1./kCM2MC);
268 return; // Found x and z, return.
271 //______________________________________________________________________
272 void AliITSsegmentationPixUpg::CellBoundries(Int_t ix,Int_t iz,Double_t &xl,Double_t &xu,Double_t &zl,Double_t &zu) const
274 // Transformation from Detector cell coordiantes to Geant detector centerd
275 // local coordinates (cm).
277 // Int_t ix detector x cell coordinate. Has the range 0<=ix<fNRow.
278 // Int_t iz detector z cell coordinate. Has the range 0<=iz<fNCol.
280 // Double_t xl detector local coordinate cell lower bounds x in cm
281 // with respect to the center of the sensitive volume.
282 // Double_t xu detector local coordinate cell upper bounds x in cm
283 // with respect to the center of the sensitive volume.
284 // Double_t zl detector local coordinate lower bounds z in cm with
285 // respect to the center of the sensitive volulme.
286 // Double_t zu detector local coordinate upper bounds z in cm with
287 // respect to the center of the sensitive volulme.
288 // If ix and or iz is outside of the segmentation range a value of -0.5*Dx()
289 // and -0.5*Dx() or -0.5*Dz() and -0.5*Dz() are returned.
291 DetToLocal(ix,iz,x,z);
293 if( ix<0 || ix>=fNRow || iz<0 || iz>=fNCol) {
294 xl = xu = -0.5/kCM2MC*Dx(); // default value.
295 zl = zu = -0.5/kCM2MC*Dz(); // default value.
296 return; // outside of detctor
298 float zpitchH = Dpz(iz)/2./kCM2MC;
299 float xpitchH = fPitchX/2./kCM2MC;
304 return; // Found x and z, return.
307 //______________________________________________________________________
308 Int_t AliITSsegmentationPixUpg::GetChipFromChannel(Int_t, Int_t iz) const
310 // returns chip number (in range 0-4) starting from channel number
311 if(iz>=fNCol || iz<0 ){
312 AliWarning("Bad cell number");
315 return iz/fNColPerChip;
318 //______________________________________________________________________
319 Int_t AliITSsegmentationPixUpg::GetChipFromLocal(Float_t, Float_t zloc) const
321 // returns chip number (in range 0-4) starting from local coordinates
323 if (!LocalToDet(0,zloc,ix0,iz)) {
324 AliWarning("Bad local coordinate");
327 return GetChipFromChannel(ix0,iz);
330 //______________________________________________________________________
331 Int_t AliITSsegmentationPixUpg::GetChipsInLocalWindow(Int_t* array, Float_t zmin, Float_t zmax, Float_t, Float_t) const
333 // returns the number of chips containing a road defined by given local coordinate limits
335 const Float_t kconv = 1./kCM2MC; // converts microns to cm.
338 AliWarning("Bad coordinate limits: zmin>zmax!");
344 Float_t zminDet = -0.5*kconv*Dz();
345 Float_t zmaxDet = 0.5*kconv*Dz();
346 if(zmin<zminDet) zmin=zminDet;
347 if(zmax>zmaxDet) zmax=zmaxDet;
349 Int_t n1 = GetChipFromLocal(0,zmin);
350 array[nChipInW] = n1;
353 Int_t n2 = GetChipFromLocal(0,zmax);
356 Int_t imin=TMath::Min(n1,n2);
357 Int_t imax=TMath::Max(n1,n2);
358 for(Int_t ichip=imin; ichip<=imax; ichip++){
359 if(ichip==n1) continue;
360 array[nChipInW]=ichip;
368 //______________________________________________________________________
369 void AliITSsegmentationPixUpg::Init()