]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSsegmentationSPD.cxx
Fixes to coding conventions violations
[u/mrichter/AliRoot.git] / ITS / AliITSsegmentationSPD.cxx
CommitLineData
b0f5e3fc 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>
1ca7869b 17#include <TF1.h>
b0f5e3fc 18
19#include "AliITSsegmentationSPD.h"
1ca7869b 20#include "AliITSgeom.h"
b0f5e3fc 21
22ClassImp(AliITSsegmentationSPD)
23
24
f1e07e4b 25Float_t AliITSsegmentationSPD::ColFromZ300(Float_t z) {
b0f5e3fc 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//_____________________________________________________________________________
f1e07e4b 34Float_t AliITSsegmentationSPD::ZFromCol300(Int_t col) {
b0f5e3fc 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//_____________________________________________________________________________
f1e07e4b 43Float_t AliITSsegmentationSPD::ZpitchFromCol300(Int_t col) {
b0f5e3fc 44 // returns Z pixel pitch for 300 micron pixels.
ac74f489 45
46 col = 0; // done to remove unused variable warning.
47 return 300.0;
b0f5e3fc 48}
49//_____________________________________________________________________________
f1e07e4b 50Float_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;
5d3918d6 57
f1e07e4b 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/*
b0f5e3fc 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 }
f1e07e4b 103 return TMath::Abs(col);*/
b0f5e3fc 104}
105
106//_____________________________________________________________________________
f1e07e4b 107Float_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;
5d3918d6 112
f1e07e4b 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/*
b0f5e3fc 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;
5752a110 152 }
b0f5e3fc 153
f1e07e4b 154 return z;*/
b0f5e3fc 155}
5752a110 156//______________________________________________________________________
f1e07e4b 157Float_t AliITSsegmentationSPD::ZpitchFromCol(Int_t col) {
158 // Get pitch size in z direction for each colunm
b0f5e3fc 159
87663651 160 Float_t pitchz = 425.;
5752a110 161 if(col < 0){
162 pitchz = 0.0;
91378d45 163 } else if(col >= 31 && col <= 32) {
87663651 164 pitchz = 625.;
91378d45 165 } else if(col >= 63 && col <= 64) {
87663651 166 pitchz = 625.;
91378d45 167 } else if(col >= 95 && col <= 96) {
87663651 168 pitchz = 625.;
91378d45 169 } else if(col >= 127 && col <= 128) {
87663651 170 pitchz = 625.;
91378d45 171 } else if(col >= 159 && col <= 160) {
87663651 172 pitchz = 625.;
f1e07e4b 173 } else if(col>=192){
87663651 174 pitchz = 425.;
5752a110 175 }
176 return pitchz;
b0f5e3fc 177}
5752a110 178//______________________________________________________________________
b0f5e3fc 179AliITSsegmentationSPD::AliITSsegmentationSPD(){
180 // Default constructor
181 fNpx = 0;
182 fNpz = 0;
183 fCorr=0;
184 fGeom = 0;
185
186}
5752a110 187//______________________________________________________________________
b0f5e3fc 188AliITSsegmentationSPD::AliITSsegmentationSPD(AliITSgeom *gm){
189 // Constructor
190 fCorr=0;
191 fNpx = 0;
192 fNpz = 0;
193 Init();
194 fGeom = gm;
195
196}
5752a110 197//______________________________________________________________________
b0f5e3fc 198AliITSsegmentationSPD& AliITSsegmentationSPD::operator=(AliITSsegmentationSPD &source){
199 // = operator
b0f5e3fc 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;
e8189707 205 Int_t i;
b0f5e3fc 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//____________________________________________________________________________
ac74f489 213AliITSsegmentationSPD::AliITSsegmentationSPD(AliITSsegmentationSPD &source) :
214 AliITSsegmentation(source){
b0f5e3fc 215 // copy constructor
216 *this = source;
217}
91378d45 218//----------------------------------------------------------------------
219void 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];
7775613f 225 for(i=0;i<280;i++) fCellSizeZ[i] = z[i];
91378d45 226 return;
227}
228//----------------------------------------------------------------------
b0f5e3fc 229void 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
b0f5e3fc 235 //const Float_t kconv=10000.;
e8189707 236 Int_t i;
b0f5e3fc 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
f1e07e4b 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
b0f5e3fc 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//------------------------------
250void 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
b0f5e3fc 256 //const Float_t kconv=10000.;
e8189707 257 Int_t i;
b0f5e3fc 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
f1e07e4b 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
b0f5e3fc 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
e8189707 268 //printf(" AliITSsegmentationSPD - Init: fNpx fNpz fDx fDz %d %d %f %f\n",fNpx, fNpz, fDx, fDz);
b0f5e3fc 269
270}
271//------------------------------
e8189707 272void AliITSsegmentationSPD::SetNPads(Int_t p1, Int_t p2){
b0f5e3fc 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//------------------------------
281void 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//------------------------------
291Float_t AliITSsegmentationSPD::Dpx(Int_t i){
f1e07e4b 292 //returs x pixel pitch for a give pixel
293 if(i<0||i>=256) return 0.0;
294 return fCellSizeX[i];
b0f5e3fc 295}
296//------------------------------
297Float_t AliITSsegmentationSPD::Dpz(Int_t i){
f1e07e4b 298 // returns z pixel pitch for a give pixel
299 if(i<0||i>=280) return 0.0;
300 return fCellSizeZ[i];
b0f5e3fc 301}
302//------------------------------
e8189707 303void AliITSsegmentationSPD::GetPadIxz(Float_t x,Float_t z,Int_t &ix,Int_t &iz){
b0f5e3fc 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
b0f5e3fc 315
316 if (iz > fNpz) iz= fNpz;
317 if (ix > fNpx) ix= fNpx;
b0f5e3fc 318 /*
319 if (iz < -fNpz) iz= -fNpz;
320 if (ix < -fNpx) ix=-fNpx;
321 */
322}
323
324//------------------------------
e8189707 325void 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//------------------------------
339void AliITSsegmentationSPD::GetPadCxz(Int_t ix,Int_t iz,Float_t &x,Float_t&z){
b0f5e3fc 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//------------------------------
352void AliITSsegmentationSPD::
353Neighbours(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}
5752a110 382//______________________________________________________________________
383void 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//______________________________________________________________________
421void 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}
bd8ff387 448//______________________________________________________________________
449void 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}