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