]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSsegmentationSPD.cxx
Changes to remove Effective C++ warnings
[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 "AliITSsegmentationSPD.h"
17 //#include "AliITSgeom.h"
18 //////////////////////////////////////////////////////
19 // Segmentation class for                           //
20 // pixels                                           //
21 //                                                  //
22 //////////////////////////////////////////////////////
23 ClassImp(AliITSsegmentationSPD)
24
25 //_____________________________________________________________________________
26   AliITSsegmentationSPD::AliITSsegmentationSPD(): AliITSsegmentation(),
27 fNpx(0),
28 fNpz(0){
29   // Default constructor
30   for(Int_t k=0; k<256; k++){
31     fCellSizeX[k] = 0.;
32     fCellSizeZ[k] = 0.;
33   }
34 }
35
36 //_____________________________________________________________________________
37 Float_t AliITSsegmentationSPD::ColFromZ300(Float_t z) const {
38 // Get column number for each z-coordinate taking into account the 
39 // extra pixels in z direction assuming 300 micron sized pixels.
40      Float_t col = 0.0;
41      Float_t pitchz = 300.0;
42      col = Float_t (z/pitchz);
43      return col;
44 }
45 //_____________________________________________________________________________
46 Float_t AliITSsegmentationSPD::ZFromCol300(Int_t col) const {
47 // same comments as above
48 // Get z-coordinate for each colunm number
49   Float_t pitchz = 300.0;
50   Float_t z = 0.0;
51   z = (col+0.5)*pitchz;
52   return z;
53 }
54 //_____________________________________________________________________________
55 Float_t AliITSsegmentationSPD::ZpitchFromCol300(Int_t col) const {
56   // returns Z pixel pitch for 300 micron pixels.
57
58     col = 0; // done to remove unused variable warning.
59     return 300.0;
60 }
61 //_____________________________________________________________________________
62 Float_t AliITSsegmentationSPD::ColFromZ(Float_t z) const {
63     // hard-wired - keep it like this till we can parametrise 
64     // and get rid of AliITSgeomSPD425
65     // Get column number for each z-coordinate taking into account the 
66     // extra pixels in z direction 
67     Int_t i;
68     Float_t s,col;
69
70     if(z<0||z>fDz){
71         AliError(Form("z=%f outside of range 0.0<=z<fDz=%f",z,fDz));
72         return 0.0; // error
73     } // end if outsize of detector
74     s = 0.0;
75     i = -1;
76     while(z>s){
77         i++;
78         s += fCellSizeZ[i];
79     } // end while
80     s -= fCellSizeZ[i];
81     col = (Float_t) i + (z-s)/fCellSizeZ[i];
82     return col;
83
84 /*
85   Float_t col = 0;
86   Float_t pitchz = 425;
87   if( z < 13175) {
88     col = Float_t(z/pitchz);
89   } else if( z < 14425) {  
90     pitchz = 625;
91     col = 31 + (z - 13175)/pitchz;
92   } else if( z < 27175) {  
93     col = 33 + (z - 14425)/pitchz;
94   } else if( z < 28425) {  
95     pitchz = 625;
96     col = 63 + (z - 27175)/pitchz;
97   } else if( z < 41175) {  
98     col = 65 + (z - 28425)/pitchz;
99   } else if( z < 42425) {  
100     pitchz = 625;
101     col = 95 + (z - 41175)/pitchz;
102   } else if( z < 55175) {  
103     col = 97 + (z - 42425)/pitchz;
104   } else if( z < 56425) {  
105     pitchz = 625;
106     col = 127 + (z - 55175)/pitchz;
107   } else if( z < 69175) {  
108     col = 129 + (z - 56425)/pitchz;
109   } else if( z < 70425) {  
110     pitchz = 625;
111     col = 159 + (z - 69175)/pitchz;
112   } else if( z < 83600) {  
113     col = 161 + (z - 70425)/pitchz;
114   }   
115   return TMath::Abs(col);*/
116 }
117
118 //_____________________________________________________________________________
119 Float_t AliITSsegmentationSPD::ZFromCol(Int_t col) const {
120     // same comments as above
121     // Get z-coordinate for each colunm number
122     Int_t i;
123     Float_t z;
124
125     if(col<0||col>=fNpz){
126         AliError(Form("col=%d outside of range 0<=col<fNpZ=%d",col,fNpz));
127         return 0.0; // error
128     } // end if outsize of detector
129     z = 0.0;
130     for(i=0;i<col;i++) z += fCellSizeZ[i];
131     z += 0.5*fCellSizeZ[col];
132     return z;
133
134 /* 
135   Float_t pitchz = 425;
136   Float_t z = 0;
137   if( col >=0 && col <= 30 ) {  
138     z = (col + 0.5)*pitchz;    
139   } else if( col >= 31 && col <= 32) {  
140     pitchz = 625;
141     z = 13175 + (col -31 + 0.5)*pitchz;    
142   } else if( col >= 33 && col <= 62) {  
143     z = 14425 + (col -33 + 0.5)*pitchz;    
144   } else if( col >= 63 && col <= 64) {  
145     pitchz = 625;
146     z = 27175 + (col -63 + 0.5)*pitchz;    
147   } else if( col >= 65 && col <= 94) {  
148     z = 28425 + (col -65 + 0.5)*pitchz;    
149   } else if( col >= 95 && col <= 96) {  
150     pitchz = 625;
151     z = 41175 + (col -95 + 0.5)*pitchz;    
152   } else if( col >= 97 && col <= 126) {  
153     z = 42425 + (col -97 + 0.5)*pitchz;    
154   } else if( col >= 127 && col <= 128) {  
155     pitchz = 625;
156     z = 55175 + (col -127 + 0.5)*pitchz;    
157   } else if( col >= 129 && col <= 158) {  
158     z = 56425 + (col -129 + 0.5)*pitchz;    
159   } else if( col >= 159 && col <= 160) {  
160     pitchz = 625;
161     z = 69175 + (col -159 + 0.5)*pitchz;    
162   } else if( col >= 161 && col <= 191) {  
163     z = 70425 + (col -161 + 0.5)*pitchz;    
164   }
165
166   return z;*/
167 }
168 //______________________________________________________________________
169 Float_t AliITSsegmentationSPD::ZpitchFromCol(Int_t col) const {
170     // Get pitch size in z direction for each colunm
171
172    Float_t pitchz = 425.;
173     if(col < 0){
174         pitchz = 0.0;
175     } else if(col >=  31 && col <=  32) {
176         pitchz = 625.;
177     } else if(col >=  63 && col <=  64) {
178         pitchz = 625.;
179     } else if(col >=  95 && col <=  96) {
180         pitchz = 625.;
181     } else if(col >= 127 && col <= 128) {
182         pitchz = 625.;
183     } else if(col >= 159 && col <= 160) {
184         pitchz = 625.;
185     } else if(col>=192){
186         pitchz = 425.;
187     }
188     return pitchz;
189 }
190 //______________________________________________________________________
191 AliITSsegmentationSPD::AliITSsegmentationSPD(AliITSgeom *gm):
192 AliITSsegmentation(gm),
193 fNpx(0),
194 fNpz(0){
195   // Constructor
196    fCorr=0;
197    Init(); 
198 }
199 //______________________________________________________________________
200 void AliITSsegmentationSPD::Copy(TObject &obj) const {
201   // protected method. copy this to obj
202   AliITSsegmentation::Copy(obj);
203   ((AliITSsegmentationSPD& ) obj).fNpx  = fNpx;
204   ((AliITSsegmentationSPD& ) obj).fNpz  = fNpz;
205   Int_t i;
206   for(i=0;i<256;i++) 
207          ((AliITSsegmentationSPD& ) obj).fCellSizeX[i] = fCellSizeX[i];
208   for(i=0;i<280;i++) 
209          ((AliITSsegmentationSPD& ) obj).fCellSizeZ[i] = fCellSizeZ[i];
210 }
211
212 //______________________________________________________________________
213 AliITSsegmentationSPD& AliITSsegmentationSPD::operator=(const AliITSsegmentationSPD &source){
214    // = operator
215    if(this==&source) return *this;
216    source.Copy(*this);
217    return *this;
218 }
219 //____________________________________________________________________________
220 AliITSsegmentationSPD::AliITSsegmentationSPD(const AliITSsegmentationSPD &source) :
221     AliITSsegmentation(source),
222 fNpx(0),
223 fNpz(0){
224   // copy constructor
225   source.Copy(*this);
226 }
227 //----------------------------------------------------------------------
228 void AliITSsegmentationSPD::SetBinSize(Float_t *x,Float_t *z){
229     // Fills the array of pixel sizes in x, microns
230     // The input array x must have 256 elements.
231     Int_t i;
232
233     for(i=0;i<256;i++) fCellSizeX[i] = x[i];
234     for(i=0;i<280;i++) fCellSizeZ[i] = z[i];
235     return;
236 }
237 //----------------------------------------------------------------------
238 void AliITSsegmentationSPD::Init300(){
239 // Initialize infromation for 6 read out chip 300X50 micron pixel SPD 
240 // detectors. This chip is 150 microns thick by 1.28 cm in x by 8.37 cm
241 // long. It has 256  50 micron pixels in x and 279 300 micron size
242 // pixels in z.
243
244     //const Float_t kconv=10000.;
245     Int_t i;
246     fNpx = 256; // The number of X pixel Cell same as in fCellSizeX array size
247     fNpz = 279; // The number of Z pixel Cell same as in fCellSizeZ array size
248     for(i=0;i<fNpx;i++) fCellSizeX[i] = 50.0; // microns all the same
249     for(i=0;i<280;i++) fCellSizeZ[i] = ZpitchFromCol300(i); // microns
250 //    for(i=fNpz;i<280;i++) fCellSizeZ[i] = 0.0; // zero out rest of array
251     fDx = 0;
252     for(i=0;i<fNpx;i++) fDx += fCellSizeX[i];
253     fDz = 0;
254     for(i=0;i<fNpz;i++) fDz += fCellSizeZ[i];
255     fDy = 300.0; //microns  SPD sensitive layer thickness
256 }
257
258 //------------------------------
259 void AliITSsegmentationSPD::Init(){
260 // Initialize infromation for 6 read out chip 425X50 micron pixel SPD 
261 // detectors. This chip is 150 microns thick by 1.28 cm in x by 8.375 cm
262 // long. It has 256  50 micron pixels in x and 197 mostly 425 micron size
263 // pixels in z. The two pixels between each readout chip are 625 microns long.
264
265     //const Float_t kconv=10000.;
266     Int_t i;
267     fNpx = 256; // The number of X pixel Cell same as in fCellSizeX array size
268     fNpz = 192; // The number of Z pixel Cell same as in fCellSizeZ array size
269     for(i=0;i<fNpx;i++) fCellSizeX[i] = 50.0; // microns all the same
270     for(i=0;i<280;i++) fCellSizeZ[i] = ZpitchFromCol(i); // microns
271 //    for(i=fNpz;i<280;i++) fCellSizeZ[i] = 0.0; // zero out rest of array
272     fDx = 0;
273     for(i=0;i<fNpx;i++) fDx += fCellSizeX[i];
274     fDz = 0;
275     for(i=0;i<fNpz;i++) fDz += fCellSizeZ[i];
276     fDy = 300.0; //microns  SPD sensitive layer thickness
277     //printf(" AliITSsegmentationSPD - Init: fNpx fNpz fDx fDz %d %d %f %f\n",fNpx, fNpz, fDx, fDz);
278
279 }
280 //------------------------------
281 void AliITSsegmentationSPD::SetNPads(Int_t p1, Int_t p2){
282   // for SPD this function should be used ONLY when a beam test setup 
283   // configuration is studied
284
285     fNpx=p1;
286     fNpz=p2;
287
288 }
289
290 //------------------------------
291 Float_t AliITSsegmentationSPD::Dpx(Int_t i) const {
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) const {
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) const {
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) const{
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) const {
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]) const {
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 Bool_t AliITSsegmentationSPD::LocalToDet(Float_t x,Float_t z,
384                                          Int_t &ix,Int_t &iz) const {
385     // Transformation from Geant detector centered local coordinates (cm) to
386     // Pixel cell numbers ix and iz.
387     // Input:
388     //    Float_t   x        detector local coordinate x in cm with respect to
389     //                       the center of the sensitive volume.
390     //    Float_t   z        detector local coordinate z in cm with respect to
391     //                       the center of the sensitive volulme.
392     // Output:
393     //    Int_t    ix        detector x cell coordinate. Has the range 
394     //                       0<=ix<fNpx.
395     //    Int_t    iz        detector z cell coordinate. Has the range 
396     //                       0<=iz<fNpz.
397     // Return:
398     //   kTRUE if point x,z is inside sensitive volume, kFALSE otherwise.
399     //   A value of -1 for ix or iz indecates that this point is outside of the
400     //   detector segmentation as defined.
401     Int_t i,j;
402     Float_t dx,dz;
403     const Float_t kconv = 1.0E-04; // converts microns to cm.
404
405     dx = -0.5*kconv*Dx();
406     dz = -0.5*kconv*Dz();
407     ix = -1;
408     iz = -1;
409     if(x<dx) return kFALSE; // outside x range.
410     if(z<dz) return kFALSE; // outside z range.
411     for(i=0;i<Npx();i++){
412         dx += kconv*fCellSizeX[i];
413         if(x<dx) break;
414     } // end for i
415     if(i>=Npx()) return kFALSE; // outside x range.
416     for(j=0;j<Npz();j++){
417         dz += kconv*fCellSizeZ[j];
418         if(z<dz) break;
419     } // end for j
420     if(j>=Npz()) return kFALSE; // outside z range.
421     ix = i;
422     iz = j;
423     return kTRUE; // Found ix and iz, return.
424 }
425 //______________________________________________________________________
426 void AliITSsegmentationSPD::DetToLocal(Int_t ix,Int_t iz,Float_t &x,Float_t &z) const
427 {
428 // Transformation from Detector cell coordiantes to Geant detector centerd 
429 // local coordinates (cm).
430 // Input:
431 // Int_t    ix        detector x cell coordinate. Has the range 0<=ix<fNpx.
432 // Int_t    iz        detector z cell coordinate. Has the range 0<=iz<fNpz.
433 // Output:
434 // Float_t   x        detector local coordinate x in cm with respect to the
435 //                    center of the sensitive volume.
436 // Float_t   z        detector local coordinate z in cm with respect to the
437 //                    center of the sensitive volulme.
438 // If ix and or iz is outside of the segmentation range a value of -0.5*Dx()
439 // or -0.5*Dz() is returned.
440     Int_t i,j;
441     const Float_t kconv = 1.0E-04; // converts microns to cm.
442
443     x = -0.5*kconv*Dx(); // default value.
444     z = -0.5*kconv*Dz(); // default value.
445     if(ix<0 || ix>=Npx()) return; // outside of detector
446     if(iz<0 || iz>=Npz()) return; // outside of detctor
447     for(i=0;i<ix;i++) x += kconv*fCellSizeX[i]; // sum up to cell ix-1
448     x += 0.5*kconv*fCellSizeX[ix]; // add 1/2 of cell ix for center location.
449     for(j=0;j<iz;j++) z += kconv*fCellSizeZ[j]; // sum up cell iz-1
450     z += 0.5*kconv*fCellSizeZ[iz]; // add 1/2 of cell iz for center location.
451     return; // Found x and z, return.
452 }
453 //______________________________________________________________________
454 void AliITSsegmentationSPD::CellBoundries(Int_t ix,Int_t iz,
455                                           Double_t &xl,Double_t &xu,
456                                           Double_t &zl,Double_t &zu) const
457 {
458 // Transformation from Detector cell coordiantes to Geant detector centerd 
459 // local coordinates (cm).
460 // Input:
461 // Int_t    ix        detector x cell coordinate. Has the range 0<=ix<fNpx.
462 // Int_t    iz        detector z cell coordinate. Has the range 0<=iz<fNpz.
463 // Output:
464 // Double_t   xl       detector local coordinate cell lower bounds x in cm
465 //                    with respect to the center of the sensitive volume.
466 // Double_t   xu       detector local coordinate cell upper bounds x in cm 
467 //                    with respect to the center of the sensitive volume.
468 // Double_t   zl       detector local coordinate lower bounds z in cm with
469 //                    respect to the center of the sensitive volulme.
470 // Double_t   zu       detector local coordinate upper bounds z in cm with 
471 //                    respect to the center of the sensitive volulme.
472 // If ix and or iz is outside of the segmentation range a value of -0.5*Dx()
473 // and -0.5*Dx() or -0.5*Dz() and -0.5*Dz() are returned.
474     Int_t i,j;
475     const Float_t kconv = 1.0E-04; // converts microns to cm.
476     Float_t x,z;
477
478     xl = xu = x = -0.5*kconv*Dx(); // default value.
479     zl = zu = z = -0.5*kconv*Dz(); // default value.
480     if(ix<0 || ix>=Npx()) return; // outside of detector
481     if(iz<0 || iz>=Npz()) return; // outside of detctor
482     for(i=0;i<ix;i++) x += kconv*fCellSizeX[i]; // sum up to cell ix-1
483     xl = x;
484     x += kconv*fCellSizeX[ix];
485     xu = x;
486     for(j=0;j<iz;j++) z += kconv*fCellSizeZ[j]; // sum up cell iz-1
487     zl = z;
488     z += kconv*fCellSizeZ[iz];
489     zu = z;
490     return; // Found x and z, return.
491 }