]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSsegmentationSPD.cxx
ConstructModules() corrected (both single and dependent modules are configured first...
[u/mrichter/AliRoot.git] / ITS / AliITSsegmentationSPD.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15
16 #include <TMath.h>
17 #include <TF1.h>
18
19 #include "AliITSsegmentationSPD.h"
20 #include "AliITSgeom.h"
21
22 ClassImp(AliITSsegmentationSPD)
23
24
25 Float_t ColFromZ300(Float_t z) {
26 // Get column number for each z-coordinate taking into account the 
27 // extra pixels in z direction assuming 300 micron sized pixels.
28      Float_t col = 0.0;
29      Float_t pitchz = 300.0;
30      col = Float_t (z/pitchz);
31      return col;
32 }
33 //_____________________________________________________________________________
34 Float_t ZFromCol300(Int_t col) {
35 // same comments as above
36 // Get z-coordinate for each colunm number
37   Float_t pitchz = 300.0;
38   Float_t z = 0.0;
39   z = (col+0.5)*pitchz;
40   return z;
41 }
42 //_____________________________________________________________________________
43 Float_t ZpitchFromCol300(Int_t col) {
44   // returns Z pixel pitch for 300 micron pixels.
45   return 300.0;
46 }
47 //_____________________________________________________________________________
48 Float_t ColFromZ(Float_t z) {
49 // hard-wired - keep it like this till we can parametrise 
50 // and get rid of AliITSgeomSPD425
51 // Get column number for each z-coordinate taking into account the 
52 // extra pixels in z direction 
53
54   Float_t col = 0;
55   Float_t pitchz = 425;
56   if( z < 13175) {
57     col = Float_t(z/pitchz);
58   } else if( z < 14425) {  
59     pitchz = 625;
60     col = 31 + (z - 13175)/pitchz;
61   } else if( z < 27175) {  
62     col = 33 + (z - 14425)/pitchz;
63   } else if( z < 28425) {  
64     pitchz = 625;
65     col = 63 + (z - 27175)/pitchz;
66   } else if( z < 41175) {  
67     col = 65 + (z - 28425)/pitchz;
68   } else if( z < 42425) {  
69     pitchz = 625;
70     col = 95 + (z - 41175)/pitchz;
71   } else if( z < 55175) {  
72     col = 97 + (z - 42425)/pitchz;
73   } else if( z < 56425) {  
74     pitchz = 625;
75     col = 127 + (z - 55175)/pitchz;
76   } else if( z < 69175) {  
77     col = 129 + (z - 56425)/pitchz;
78   } else if( z < 70425) {  
79     pitchz = 625;
80     col = 159 + (z - 69175)/pitchz;
81   } else if( z < 83600) {  
82     col = 161 + (z - 70425)/pitchz;
83   }   
84   return TMath::Abs(col);
85 }
86
87 //_____________________________________________________________________________
88 Float_t ZFromCol(Int_t col) {
89 // same comments as above
90 // Get z-coordinate for each colunm number
91
92   Float_t pitchz = 425;
93   Float_t z = 0;
94   if( col >=0 && col <= 30 ) {  
95     z = (col + 0.5)*pitchz;    
96   } else if( col >= 31 && col <= 32) {  
97     pitchz = 625;
98     z = 13175 + (col -31 + 0.5)*pitchz;    
99   } else if( col >= 33 && col <= 62) {  
100     z = 14425 + (col -33 + 0.5)*pitchz;    
101   } else if( col >= 63 && col <= 64) {  
102     pitchz = 625;
103     z = 27175 + (col -63 + 0.5)*pitchz;    
104   } else if( col >= 65 && col <= 94) {  
105     z = 28425 + (col -65 + 0.5)*pitchz;    
106   } else if( col >= 95 && col <= 96) {  
107     pitchz = 625;
108     z = 41175 + (col -95 + 0.5)*pitchz;    
109   } else if( col >= 97 && col <= 126) {  
110     z = 42425 + (col -97 + 0.5)*pitchz;    
111   } else if( col >= 127 && col <= 128) {  
112     pitchz = 625;
113     z = 55175 + (col -127 + 0.5)*pitchz;    
114   } else if( col >= 129 && col <= 158) {  
115     z = 56425 + (col -129 + 0.5)*pitchz;    
116   } else if( col >= 159 && col <= 160) {  
117     pitchz = 625;
118     z = 69175 + (col -159 + 0.5)*pitchz;    
119   } else if( col >= 161 && col <= 191) {  
120     z = 70425 + (col -161 + 0.5)*pitchz;    
121   }
122
123   return z;
124 }
125 //______________________________________________________________________
126 Float_t ZpitchFromCol(Int_t col) {
127 // Get pitch size in z direction for each colunm
128
129     Float_t pitchz = 425;
130     if(col < 0){
131         pitchz = 0.0;
132     } else if(col >=  31 && col <=  32) {
133         pitchz = 625;
134     } else if(col >=  63 && col <=  64) {
135         pitchz = 625;
136     } else if(col >=  95 && col <=  96) {
137         pitchz = 625;
138     } else if(col >= 127 && col <= 128) {
139         pitchz = 625;
140     } else if(col >= 159 && col <= 160) {
141         pitchz = 625;
142     } else if(col>=192){
143         pitchz = 0.0;
144     }
145     return pitchz;
146 }
147 //______________________________________________________________________
148 AliITSsegmentationSPD::AliITSsegmentationSPD(){
149   // Default constructor
150    fNpx = 0;
151    fNpz = 0;
152    fCorr=0;
153    fGeom = 0;
154
155 }
156 //______________________________________________________________________
157 AliITSsegmentationSPD::AliITSsegmentationSPD(AliITSgeom *gm){
158   // Constructor
159    fCorr=0;
160    fNpx = 0;
161    fNpz = 0;
162    Init(); 
163    fGeom = gm;
164
165 }
166 //______________________________________________________________________
167 AliITSsegmentationSPD& AliITSsegmentationSPD::operator=(AliITSsegmentationSPD &source){
168    // = operator
169    if(this==&source) return *this;
170    this->fNpx  = source.fNpx;
171    this->fNpz  = source.fNpz;
172    this->fDx   = source.fDx;
173    this->fDy   = source.fDy;
174    Int_t i;
175    for(i=0;i<256;i++) this->fCellSizeX[i] = source.fCellSizeX[i];
176    for(i=0;i<280;i++) this->fCellSizeZ[i] = source.fCellSizeZ[i];
177    this->fCorr = new TF1(*(source.fCorr));// make a proper copy of the function
178    this->fGeom = source.fGeom; // copy only the pointers.
179    return *this;
180 }
181 //____________________________________________________________________________
182 AliITSsegmentationSPD::AliITSsegmentationSPD(AliITSsegmentationSPD &source){
183   // copy constructor
184    *this = source;
185 }
186 //----------------------------------------------------------------------
187 void AliITSsegmentationSPD::SetBinSize(Float_t *x,Float_t *z){
188     // Fills the array of pixel sizes in x, microns
189     // The input array x must have 256 elements.
190     Int_t i;
191
192     for(i=0;i<256;i++) fCellSizeX[i] = x[i];
193     for(i=0;i<280;i++) fCellSizeX[i] = z[i];
194     return;
195 }
196 //----------------------------------------------------------------------
197 void AliITSsegmentationSPD::Init300(){
198 // Initialize infromation for 6 read out chip 300X50 micron pixel SPD 
199 // detectors. This chip is 150 microns thick by 1.28 cm in x by 8.37 cm
200 // long. It has 256  50 micron pixels in x and 279 300 micron size
201 // pixels in z.
202
203     //const Float_t kconv=10000.;
204     Int_t i;
205     fNpx = 256; // The number of X pixel Cell same as in fCellSizeX array size
206     fNpz = 279; // The number of Z pixel Cell same as in fCellSizeZ array size
207     for(i=0;i<fNpx;i++) fCellSizeX[i] = 50.0; // microns all the same
208     for(i=0;i<fNpz;i++) fCellSizeZ[i] = ZpitchFromCol300(i); // microns
209     for(i=fNpz;i<280;i++) fCellSizeZ[i] = 0.0; // zero out rest of array
210     fDx = 0;
211     for(i=0;i<fNpx;i++) fDx += fCellSizeX[i];
212     fDz = 0;
213     for(i=0;i<fNpz;i++) fDz += fCellSizeZ[i];
214     fDy = 300.0; //microns  SPD sensitive layer thickness
215 }
216
217 //------------------------------
218 void AliITSsegmentationSPD::Init(){
219 // Initialize infromation for 6 read out chip 425X50 micron pixel SPD 
220 // detectors. This chip is 150 microns thick by 1.28 cm in x by 8.375 cm
221 // long. It has 256  50 micron pixels in x and 197 mostly 425 micron size
222 // pixels in z. The two pixels between each readout chip are 625 microns long.
223
224     //const Float_t kconv=10000.;
225     Int_t i;
226     fNpx = 256; // The number of X pixel Cell same as in fCellSizeX array size
227     fNpz = 192; // The number of Z pixel Cell same as in fCellSizeZ array size
228     for(i=0;i<fNpx;i++) fCellSizeX[i] = 50.0; // microns all the same
229     for(i=0;i<fNpz;i++) fCellSizeZ[i] = ZpitchFromCol(i); // microns
230     for(i=fNpz;i<280;i++) fCellSizeZ[i] = 0.0; // zero out rest of array
231     fDx = 0;
232     for(i=0;i<fNpx;i++) fDx += fCellSizeX[i];
233     fDz = 0;
234     for(i=0;i<fNpz;i++) fDz += fCellSizeZ[i];
235     fDy = 300.0; //microns  SPD sensitive layer thickness
236     //printf(" AliITSsegmentationSPD - Init: fNpx fNpz fDx fDz %d %d %f %f\n",fNpx, fNpz, fDx, fDz);
237
238 }
239 //------------------------------
240 void AliITSsegmentationSPD::SetNPads(Int_t p1, Int_t p2){
241   // for SPD this function should be used ONLY when a beam test setup 
242   // configuration is studied
243
244     fNpx=p1;
245     fNpz=p2;
246
247 }
248 //------------------------------
249 void AliITSsegmentationSPD::SetDetSize(Float_t p1, Float_t p2, Float_t p3){
250   // for SPD this function should be used ONLY when a beam test setup 
251   // configuration is studied
252
253     fDx=p1;
254     fDz=p2;
255     fDy=p3;
256
257 }
258 //------------------------------
259 Float_t AliITSsegmentationSPD::Dpx(Int_t i){
260    //returs x pixel pitch for a give pixel
261    return fCellSizeX[i];
262 }
263 //------------------------------
264 Float_t AliITSsegmentationSPD::Dpz(Int_t i){
265   // returns z pixel pitch for a give pixel
266    return ZpitchFromCol(i);
267 }
268 //------------------------------
269 void AliITSsegmentationSPD::GetPadIxz(Float_t x,Float_t z,Int_t &ix,Int_t &iz){
270 //  Returns pixel coordinates (ix,iz) for given real local coordinates (x,z)
271 //
272
273     // expects x, z in microns
274
275     // same segmentation on x
276     Float_t dpx=Dpx(0);
277     ix = (Int_t)(x/dpx + 1);
278     // different segmentation on z
279     iz = (Int_t)(ColFromZ(z) + 1);
280
281
282     if (iz >  fNpz) iz= fNpz;
283     if (ix >  fNpx) ix= fNpx;
284     /*
285     if (iz < -fNpz) iz= -fNpz;
286     if (ix < -fNpx) ix=-fNpx;
287     */
288 }
289
290 //------------------------------
291 void AliITSsegmentationSPD::GetPadTxz(Float_t &x,Float_t &z){
292 //  local transformation of real local coordinates (x,z)
293 //
294
295     // expects x, z in microns
296
297     // same segmentation on x
298     Float_t dpx=Dpx(0);
299
300     x /= dpx;
301     z = ColFromZ(z);
302
303 }
304 //------------------------------
305 void AliITSsegmentationSPD::GetPadCxz(Int_t ix,Int_t iz,Float_t &x,Float_t&z){
306     // Transform from pixel to real local coordinates
307
308     // returns x, z in microns
309
310     Float_t dpx=Dpx(0);
311
312     x = (ix>0) ? Float_t(ix*dpx)-dpx/2. : Float_t(ix*dpx)+dpx/2.;
313     z = ZFromCol(iz);
314
315
316 }
317 //------------------------------
318 void AliITSsegmentationSPD::
319 Neighbours(Int_t iX, Int_t iZ, Int_t* Nlist, Int_t Xlist[8], Int_t Zlist[8]){
320   // returns the neighbouring pixels for use in Cluster Finders and the like.
321   /*
322     *Nlist=4;Xlist[0]=Xlist[1]=iX;Xlist[2]=iX-1;Xlist[3]=iX+1;
323     Zlist[0]=iZ-1;Zlist[1]=iZ+1;Zlist[2]=Zlist[3]=iZ;
324   */
325
326
327     *Nlist=8;
328     Xlist[0]=Xlist[1]=iX;
329     Xlist[2]=iX-1;
330     Xlist[3]=iX+1;
331     Zlist[0]=iZ-1;
332     Zlist[1]=iZ+1;
333     Zlist[2]=Zlist[3]=iZ;
334
335    // Diagonal elements
336     Xlist[4]=iX+1;
337     Zlist[4]=iZ+1;
338
339     Xlist[5]=iX-1;
340     Zlist[5]=iZ-1;
341
342     Xlist[6]=iX-1;
343     Zlist[6]=iZ+1;
344
345     Xlist[7]=iX+1;
346     Zlist[7]=iZ-1;
347 }
348 //______________________________________________________________________
349 void AliITSsegmentationSPD::LocalToDet(Float_t x,Float_t z,Int_t &ix,Int_t &iz){
350 // Transformation from Geant detector centered local coordinates (cm) to
351 // Pixel cell numbers ix and iz.
352 // Input:
353 // Float_t   x        detector local coordinate x in cm with respect to the
354 //                    center of the sensitive volume.
355 // Float_t   z        detector local coordinate z in cm with respect to the
356 //                    center of the sensitive volulme.
357 // Output:
358 // Int_t    ix        detector x cell coordinate. Has the range 0<=ix<fNpx.
359 // Int_t    iz        detector z cell coordinate. Has the range 0<=iz<fNpz.
360 //   A value of -1 for ix or iz indecates that this point is outside of the
361 // detector segmentation as defined.
362     Int_t i,j;
363     Float_t dx,dz;
364     const Float_t kconv = 1.0E-04; // converts microns to cm.
365
366     dx = -0.5*kconv*Dx();
367     dz = -0.5*kconv*Dz();
368     ix = -1;
369     iz = -1;
370     if(x<dx) return; // outside x range.
371     if(z<dz) return; // outside z range.
372     for(i=0;i<Npx();i++){
373         dx += kconv*fCellSizeX[i];
374         if(x<dx) break;
375     } // end for i
376     if(i>=Npx()) return; // outside x range.
377     for(j=0;j<Npz();j++){
378         dz += kconv*fCellSizeZ[j];
379         if(z<dz) break;
380     } // end for j
381     if(j>=Npz()) return; // outside z range.
382     ix = i;
383     iz = j;
384     return; // Found ix and iz, return.
385 }
386 //______________________________________________________________________
387 void AliITSsegmentationSPD::DetToLocal(Int_t ix,Int_t iz,Float_t &x,Float_t &z)
388 {
389 // Transformation from Detector cell coordiantes to Geant detector centerd 
390 // local coordinates (cm).
391 // Input:
392 // Int_t    ix        detector x cell coordinate. Has the range 0<=ix<fNpx.
393 // Int_t    iz        detector z cell coordinate. Has the range 0<=iz<fNpz.
394 // Output:
395 // Float_t   x        detector local coordinate x in cm with respect to the
396 //                    center of the sensitive volume.
397 // Float_t   z        detector local coordinate z in cm with respect to the
398 //                    center of the sensitive volulme.
399 // If ix and or iz is outside of the segmentation range a value of -0.5*Dx()
400 // or -0.5*Dz() is returned.
401     Int_t i,j;
402     const Float_t kconv = 1.0E-04; // converts microns to cm.
403
404     x = -0.5*kconv*Dx(); // default value.
405     z = -0.5*kconv*Dz(); // default value.
406     if(ix<0 || ix>=Npx()) return; // outside of detector
407     if(iz<0 || iz>=Npz()) return; // outside of detctor
408     for(i=0;i<ix;i++) x += kconv*fCellSizeX[i]; // sum up to cell ix-1
409     x += 0.5*kconv*fCellSizeX[ix]; // add 1/2 of cell ix for center location.
410     for(j=0;j<iz;j++) z += kconv*fCellSizeZ[j]; // sum up cell iz-1
411     z += 0.5*kconv*fCellSizeZ[iz]; // add 1/2 of cell iz for center location.
412     return; // Found x and z, return.
413 }