]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSsegmentationSPD.cxx
TPCNoiseMapComponent included into build (Kelly)
[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
2b6642a2 16/* $Id$ */
c9649d1e 17#include <TGeoManager.h>
18#include <TGeoVolume.h>
19#include <TGeoBBox.h>
b0f5e3fc 20#include "AliITSsegmentationSPD.h"
55d2c544 21//#include "AliITSgeom.h"
22//////////////////////////////////////////////////////
23// Segmentation class for //
24// pixels //
25// //
26//////////////////////////////////////////////////////
2b6642a2 27const Int_t AliITSsegmentationSPD::fgkNchipsPerModule = 5;
28const Int_t AliITSsegmentationSPD::fgkNcolumnsPerChip = 32;
b0f5e3fc 29ClassImp(AliITSsegmentationSPD)
30
55d2c544 31//_____________________________________________________________________________
c9649d1e 32 AliITSsegmentationSPD::AliITSsegmentationSPD(Option_t *opt): AliITSsegmentation(),
e56160b8 33fNpx(0),
34fNpz(0){
55d2c544 35 // Default constructor
c9649d1e 36
a5e51e90 37 // Initialization to default values
38 Init();
39
40 // Initialization of detector dimensions from TGeo
c9649d1e 41 if(strstr(opt,"TGeo")){
42 if(!gGeoManager){
a5e51e90 43 AliError("Geometry is not initialized\n Using hardwired default values");
c9649d1e 44 return;
45 }
46 TGeoVolume *v=NULL;
47 v = gGeoManager->GetVolume("ITSSPDlay1-sensor");
48 if(!v){
49 AliWarning("TGeo volume ITSSPDlay1-sensor not found (hint: use v11Hybrid geometry)\n Using hardwired default values");
c9649d1e 50 }
51 else {
52 TGeoBBox *s=(TGeoBBox*)v->GetShape();
53 SetDetSize(s->GetDX()*20000.,s->GetDZ()*20000.,s->GetDY()*20000.);
54 }
c9649d1e 55 }
55d2c544 56}
b0f5e3fc 57
a5e51e90 58//______________________________________________________________________
59AliITSsegmentationSPD::AliITSsegmentationSPD(AliITSgeom *gm):
60AliITSsegmentation(gm),
61fNpx(0),
62fNpz(0){
63 // Constructor
64 fCorr=0;
65 Init();
66}
67
55d2c544 68//_____________________________________________________________________________
69Float_t AliITSsegmentationSPD::ColFromZ300(Float_t z) const {
b0f5e3fc 70// Get column number for each z-coordinate taking into account the
71// extra pixels in z direction assuming 300 micron sized pixels.
72 Float_t col = 0.0;
73 Float_t pitchz = 300.0;
74 col = Float_t (z/pitchz);
75 return col;
76}
77//_____________________________________________________________________________
55d2c544 78Float_t AliITSsegmentationSPD::ZFromCol300(Int_t col) const {
b0f5e3fc 79// same comments as above
80// Get z-coordinate for each colunm number
81 Float_t pitchz = 300.0;
82 Float_t z = 0.0;
83 z = (col+0.5)*pitchz;
84 return z;
85}
86//_____________________________________________________________________________
55d2c544 87Float_t AliITSsegmentationSPD::ZpitchFromCol300(Int_t col) const {
b0f5e3fc 88 // returns Z pixel pitch for 300 micron pixels.
ac74f489 89
90 col = 0; // done to remove unused variable warning.
91 return 300.0;
b0f5e3fc 92}
93//_____________________________________________________________________________
55d2c544 94Float_t AliITSsegmentationSPD::ColFromZ(Float_t z) const {
f1e07e4b 95 // hard-wired - keep it like this till we can parametrise
96 // and get rid of AliITSgeomSPD425
97 // Get column number for each z-coordinate taking into account the
98 // extra pixels in z direction
99 Int_t i;
100 Float_t s,col;
5d3918d6 101
f1e07e4b 102 if(z<0||z>fDz){
f6b6d58e 103 AliError(Form("z=%f outside of range 0.0<=z<fDz=%f",z,fDz));
f1e07e4b 104 return 0.0; // error
105 } // end if outsize of detector
106 s = 0.0;
107 i = -1;
108 while(z>s){
109 i++;
110 s += fCellSizeZ[i];
111 } // end while
112 s -= fCellSizeZ[i];
113 col = (Float_t) i + (z-s)/fCellSizeZ[i];
114 return col;
115
116/*
b0f5e3fc 117 Float_t col = 0;
118 Float_t pitchz = 425;
119 if( z < 13175) {
120 col = Float_t(z/pitchz);
121 } else if( z < 14425) {
122 pitchz = 625;
123 col = 31 + (z - 13175)/pitchz;
124 } else if( z < 27175) {
125 col = 33 + (z - 14425)/pitchz;
126 } else if( z < 28425) {
127 pitchz = 625;
128 col = 63 + (z - 27175)/pitchz;
129 } else if( z < 41175) {
130 col = 65 + (z - 28425)/pitchz;
131 } else if( z < 42425) {
132 pitchz = 625;
133 col = 95 + (z - 41175)/pitchz;
134 } else if( z < 55175) {
135 col = 97 + (z - 42425)/pitchz;
136 } else if( z < 56425) {
137 pitchz = 625;
138 col = 127 + (z - 55175)/pitchz;
139 } else if( z < 69175) {
140 col = 129 + (z - 56425)/pitchz;
141 } else if( z < 70425) {
142 pitchz = 625;
143 col = 159 + (z - 69175)/pitchz;
144 } else if( z < 83600) {
145 col = 161 + (z - 70425)/pitchz;
146 }
f1e07e4b 147 return TMath::Abs(col);*/
b0f5e3fc 148}
149
150//_____________________________________________________________________________
55d2c544 151Float_t AliITSsegmentationSPD::ZFromCol(Int_t col) const {
f1e07e4b 152 // same comments as above
153 // Get z-coordinate for each colunm number
154 Int_t i;
155 Float_t z;
5d3918d6 156
f1e07e4b 157 if(col<0||col>=fNpz){
f6b6d58e 158 AliError(Form("col=%d outside of range 0<=col<fNpZ=%d",col,fNpz));
f1e07e4b 159 return 0.0; // error
160 } // end if outsize of detector
161 z = 0.0;
162 for(i=0;i<col;i++) z += fCellSizeZ[i];
163 z += 0.5*fCellSizeZ[col];
164 return z;
165
166/*
b0f5e3fc 167 Float_t pitchz = 425;
168 Float_t z = 0;
169 if( col >=0 && col <= 30 ) {
170 z = (col + 0.5)*pitchz;
171 } else if( col >= 31 && col <= 32) {
172 pitchz = 625;
173 z = 13175 + (col -31 + 0.5)*pitchz;
174 } else if( col >= 33 && col <= 62) {
175 z = 14425 + (col -33 + 0.5)*pitchz;
176 } else if( col >= 63 && col <= 64) {
177 pitchz = 625;
178 z = 27175 + (col -63 + 0.5)*pitchz;
179 } else if( col >= 65 && col <= 94) {
180 z = 28425 + (col -65 + 0.5)*pitchz;
181 } else if( col >= 95 && col <= 96) {
182 pitchz = 625;
183 z = 41175 + (col -95 + 0.5)*pitchz;
184 } else if( col >= 97 && col <= 126) {
185 z = 42425 + (col -97 + 0.5)*pitchz;
186 } else if( col >= 127 && col <= 128) {
187 pitchz = 625;
188 z = 55175 + (col -127 + 0.5)*pitchz;
189 } else if( col >= 129 && col <= 158) {
190 z = 56425 + (col -129 + 0.5)*pitchz;
191 } else if( col >= 159 && col <= 160) {
192 pitchz = 625;
193 z = 69175 + (col -159 + 0.5)*pitchz;
194 } else if( col >= 161 && col <= 191) {
195 z = 70425 + (col -161 + 0.5)*pitchz;
5752a110 196 }
b0f5e3fc 197
f1e07e4b 198 return z;*/
b0f5e3fc 199}
5752a110 200//______________________________________________________________________
55d2c544 201Float_t AliITSsegmentationSPD::ZpitchFromCol(Int_t col) const {
f1e07e4b 202 // Get pitch size in z direction for each colunm
b0f5e3fc 203
87663651 204 Float_t pitchz = 425.;
5752a110 205 if(col < 0){
206 pitchz = 0.0;
91378d45 207 } else if(col >= 31 && col <= 32) {
87663651 208 pitchz = 625.;
91378d45 209 } else if(col >= 63 && col <= 64) {
87663651 210 pitchz = 625.;
91378d45 211 } else if(col >= 95 && col <= 96) {
87663651 212 pitchz = 625.;
91378d45 213 } else if(col >= 127 && col <= 128) {
87663651 214 pitchz = 625.;
91378d45 215 } else if(col >= 159 && col <= 160) {
87663651 216 pitchz = 625.;
f1e07e4b 217 } else if(col>=192){
87663651 218 pitchz = 425.;
5752a110 219 }
220 return pitchz;
b0f5e3fc 221}
a5e51e90 222
5752a110 223//______________________________________________________________________
55d2c544 224void AliITSsegmentationSPD::Copy(TObject &obj) const {
225 // protected method. copy this to obj
226 AliITSsegmentation::Copy(obj);
227 ((AliITSsegmentationSPD& ) obj).fNpx = fNpx;
228 ((AliITSsegmentationSPD& ) obj).fNpz = fNpz;
229 Int_t i;
230 for(i=0;i<256;i++)
231 ((AliITSsegmentationSPD& ) obj).fCellSizeX[i] = fCellSizeX[i];
232 for(i=0;i<280;i++)
233 ((AliITSsegmentationSPD& ) obj).fCellSizeZ[i] = fCellSizeZ[i];
234}
235
236//______________________________________________________________________
237AliITSsegmentationSPD& AliITSsegmentationSPD::operator=(const AliITSsegmentationSPD &source){
b0f5e3fc 238 // = operator
b0f5e3fc 239 if(this==&source) return *this;
55d2c544 240 source.Copy(*this);
b0f5e3fc 241 return *this;
242}
243//____________________________________________________________________________
55d2c544 244AliITSsegmentationSPD::AliITSsegmentationSPD(const AliITSsegmentationSPD &source) :
e56160b8 245 AliITSsegmentation(source),
246fNpx(0),
247fNpz(0){
b0f5e3fc 248 // copy constructor
55d2c544 249 source.Copy(*this);
b0f5e3fc 250}
91378d45 251//----------------------------------------------------------------------
252void AliITSsegmentationSPD::SetBinSize(Float_t *x,Float_t *z){
253 // Fills the array of pixel sizes in x, microns
254 // The input array x must have 256 elements.
255 Int_t i;
256
257 for(i=0;i<256;i++) fCellSizeX[i] = x[i];
7775613f 258 for(i=0;i<280;i++) fCellSizeZ[i] = z[i];
91378d45 259 return;
260}
261//----------------------------------------------------------------------
b0f5e3fc 262void AliITSsegmentationSPD::Init300(){
263// Initialize infromation for 6 read out chip 300X50 micron pixel SPD
264// detectors. This chip is 150 microns thick by 1.28 cm in x by 8.37 cm
265// long. It has 256 50 micron pixels in x and 279 300 micron size
266// pixels in z.
267
b0f5e3fc 268 //const Float_t kconv=10000.;
e8189707 269 Int_t i;
b0f5e3fc 270 fNpx = 256; // The number of X pixel Cell same as in fCellSizeX array size
271 fNpz = 279; // The number of Z pixel Cell same as in fCellSizeZ array size
272 for(i=0;i<fNpx;i++) fCellSizeX[i] = 50.0; // microns all the same
f1e07e4b 273 for(i=0;i<280;i++) fCellSizeZ[i] = ZpitchFromCol300(i); // microns
274// for(i=fNpz;i<280;i++) fCellSizeZ[i] = 0.0; // zero out rest of array
b0f5e3fc 275 fDx = 0;
276 for(i=0;i<fNpx;i++) fDx += fCellSizeX[i];
277 fDz = 0;
278 for(i=0;i<fNpz;i++) fDz += fCellSizeZ[i];
279 fDy = 300.0; //microns SPD sensitive layer thickness
280}
281
282//------------------------------
283void AliITSsegmentationSPD::Init(){
2b6642a2 284// Initialize information for 5 read out chip 425X50 micron pixel SPD
285// detectors (ladder).
286// Each readout chip is 150 micron thick.
287// The ladder sensor is 200 micron thick by 1.28 cm in x by 6.96 cm in z.
288// It has 256 50 micron pixels in x and 160 mostly 425 micron pixels in z.
289// The two pixels at boundary between two adjacent readout chips are
290// 625 micron long.
b0f5e3fc 291
a5e51e90 292 Float_t bx[256],bz[280];
293 Int_t i;
294 SetNPads(256,160); // Number of Bins in x and z
295 for(i=000;i<256;i++) bx[i] = 50.0; // in x all are 50 microns.
296 for(i=000;i<160;i++) bz[i] = 425.0; // most are 425 microns except below
297 for(i=160;i<280;i++) bz[i] = 0.0; // Outside of detector.
298 bz[ 31] = bz[ 32] = 625.0; // first chip boundary
299 bz[ 63] = bz[ 64] = 625.0; // first chip boundary
300 bz[ 95] = bz[ 96] = 625.0; // first chip boundary
301 bz[127] = bz[128] = 625.0; // first chip boundary
302 bz[160] = 425.0; // Set so that there is no zero pixel size for fNz.
303 SetBinSize(bx,bz);
304 SetDetSize(12800,69600,200); // full lengths (x,z,y) in microns
b0f5e3fc 305
306}
307//------------------------------
e8189707 308void AliITSsegmentationSPD::SetNPads(Int_t p1, Int_t p2){
b0f5e3fc 309 // for SPD this function should be used ONLY when a beam test setup
310 // configuration is studied
311
312 fNpx=p1;
313 fNpz=p2;
314
315}
b0f5e3fc 316
b0f5e3fc 317//------------------------------
55d2c544 318Float_t AliITSsegmentationSPD::Dpx(Int_t i) const {
f1e07e4b 319 //returs x pixel pitch for a give pixel
320 if(i<0||i>=256) return 0.0;
321 return fCellSizeX[i];
b0f5e3fc 322}
323//------------------------------
55d2c544 324Float_t AliITSsegmentationSPD::Dpz(Int_t i) const {
f1e07e4b 325 // returns z pixel pitch for a give pixel
326 if(i<0||i>=280) return 0.0;
327 return fCellSizeZ[i];
b0f5e3fc 328}
329//------------------------------
55d2c544 330void AliITSsegmentationSPD::GetPadIxz(Float_t x,Float_t z,Int_t &ix,Int_t &iz) const {
b0f5e3fc 331// Returns pixel coordinates (ix,iz) for given real local coordinates (x,z)
332//
333
334 // expects x, z in microns
335
336 // same segmentation on x
337 Float_t dpx=Dpx(0);
338 ix = (Int_t)(x/dpx + 1);
339 // different segmentation on z
340 iz = (Int_t)(ColFromZ(z) + 1);
341
b0f5e3fc 342
343 if (iz > fNpz) iz= fNpz;
344 if (ix > fNpx) ix= fNpx;
b0f5e3fc 345 /*
346 if (iz < -fNpz) iz= -fNpz;
347 if (ix < -fNpx) ix=-fNpx;
348 */
349}
350
351//------------------------------
55d2c544 352void AliITSsegmentationSPD::GetPadTxz(Float_t &x,Float_t &z) const{
e8189707 353// local transformation of real local coordinates (x,z)
354//
355
356 // expects x, z in microns
357
358 // same segmentation on x
359 Float_t dpx=Dpx(0);
360
361 x /= dpx;
362 z = ColFromZ(z);
363
364}
365//------------------------------
55d2c544 366void AliITSsegmentationSPD::GetPadCxz(Int_t ix,Int_t iz,Float_t &x,Float_t&z) const {
b0f5e3fc 367 // Transform from pixel to real local coordinates
368
369 // returns x, z in microns
370
371 Float_t dpx=Dpx(0);
372
373 x = (ix>0) ? Float_t(ix*dpx)-dpx/2. : Float_t(ix*dpx)+dpx/2.;
374 z = ZFromCol(iz);
375
376
377}
378//------------------------------
379void AliITSsegmentationSPD::
55d2c544 380Neighbours(Int_t iX, Int_t iZ, Int_t* Nlist, Int_t Xlist[8], Int_t Zlist[8]) const {
b0f5e3fc 381 // returns the neighbouring pixels for use in Cluster Finders and the like.
382 /*
383 *Nlist=4;Xlist[0]=Xlist[1]=iX;Xlist[2]=iX-1;Xlist[3]=iX+1;
384 Zlist[0]=iZ-1;Zlist[1]=iZ+1;Zlist[2]=Zlist[3]=iZ;
385 */
386
387
388 *Nlist=8;
389 Xlist[0]=Xlist[1]=iX;
390 Xlist[2]=iX-1;
391 Xlist[3]=iX+1;
392 Zlist[0]=iZ-1;
393 Zlist[1]=iZ+1;
394 Zlist[2]=Zlist[3]=iZ;
395
396 // Diagonal elements
397 Xlist[4]=iX+1;
398 Zlist[4]=iZ+1;
399
400 Xlist[5]=iX-1;
401 Zlist[5]=iZ-1;
402
403 Xlist[6]=iX-1;
404 Zlist[6]=iZ+1;
405
406 Xlist[7]=iX+1;
407 Zlist[7]=iZ-1;
408}
5752a110 409//______________________________________________________________________
aacedc3e 410Bool_t AliITSsegmentationSPD::LocalToDet(Float_t x,Float_t z,
411 Int_t &ix,Int_t &iz) const {
412 // Transformation from Geant detector centered local coordinates (cm) to
413 // Pixel cell numbers ix and iz.
414 // Input:
415 // Float_t x detector local coordinate x in cm with respect to
416 // the center of the sensitive volume.
417 // Float_t z detector local coordinate z in cm with respect to
418 // the center of the sensitive volulme.
419 // Output:
420 // Int_t ix detector x cell coordinate. Has the range
421 // 0<=ix<fNpx.
422 // Int_t iz detector z cell coordinate. Has the range
423 // 0<=iz<fNpz.
424 // Return:
425 // kTRUE if point x,z is inside sensitive volume, kFALSE otherwise.
426 // A value of -1 for ix or iz indecates that this point is outside of the
427 // detector segmentation as defined.
5752a110 428 Int_t i,j;
429 Float_t dx,dz;
430 const Float_t kconv = 1.0E-04; // converts microns to cm.
431
432 dx = -0.5*kconv*Dx();
433 dz = -0.5*kconv*Dz();
434 ix = -1;
435 iz = -1;
aacedc3e 436 if(x<dx) return kFALSE; // outside x range.
437 if(z<dz) return kFALSE; // outside z range.
5752a110 438 for(i=0;i<Npx();i++){
439 dx += kconv*fCellSizeX[i];
440 if(x<dx) break;
441 } // end for i
aacedc3e 442 if(i>=Npx()) return kFALSE; // outside x range.
5752a110 443 for(j=0;j<Npz();j++){
444 dz += kconv*fCellSizeZ[j];
445 if(z<dz) break;
446 } // end for j
aacedc3e 447 if(j>=Npz()) return kFALSE; // outside z range.
5752a110 448 ix = i;
449 iz = j;
aacedc3e 450 return kTRUE; // Found ix and iz, return.
5752a110 451}
452//______________________________________________________________________
55d2c544 453void AliITSsegmentationSPD::DetToLocal(Int_t ix,Int_t iz,Float_t &x,Float_t &z) const
5752a110 454{
455// Transformation from Detector cell coordiantes to Geant detector centerd
456// local coordinates (cm).
457// Input:
458// Int_t ix detector x cell coordinate. Has the range 0<=ix<fNpx.
459// Int_t iz detector z cell coordinate. Has the range 0<=iz<fNpz.
460// Output:
461// Float_t x detector local coordinate x in cm with respect to the
462// center of the sensitive volume.
463// Float_t z detector local coordinate z in cm with respect to the
464// center of the sensitive volulme.
465// If ix and or iz is outside of the segmentation range a value of -0.5*Dx()
466// or -0.5*Dz() is returned.
467 Int_t i,j;
468 const Float_t kconv = 1.0E-04; // converts microns to cm.
469
470 x = -0.5*kconv*Dx(); // default value.
471 z = -0.5*kconv*Dz(); // default value.
472 if(ix<0 || ix>=Npx()) return; // outside of detector
473 if(iz<0 || iz>=Npz()) return; // outside of detctor
474 for(i=0;i<ix;i++) x += kconv*fCellSizeX[i]; // sum up to cell ix-1
475 x += 0.5*kconv*fCellSizeX[ix]; // add 1/2 of cell ix for center location.
476 for(j=0;j<iz;j++) z += kconv*fCellSizeZ[j]; // sum up cell iz-1
477 z += 0.5*kconv*fCellSizeZ[iz]; // add 1/2 of cell iz for center location.
478 return; // Found x and z, return.
479}
bd8ff387 480//______________________________________________________________________
481void AliITSsegmentationSPD::CellBoundries(Int_t ix,Int_t iz,
482 Double_t &xl,Double_t &xu,
55d2c544 483 Double_t &zl,Double_t &zu) const
bd8ff387 484{
485// Transformation from Detector cell coordiantes to Geant detector centerd
486// local coordinates (cm).
487// Input:
488// Int_t ix detector x cell coordinate. Has the range 0<=ix<fNpx.
489// Int_t iz detector z cell coordinate. Has the range 0<=iz<fNpz.
490// Output:
491// Double_t xl detector local coordinate cell lower bounds x in cm
492// with respect to the center of the sensitive volume.
493// Double_t xu detector local coordinate cell upper bounds x in cm
494// with respect to the center of the sensitive volume.
495// Double_t zl detector local coordinate lower bounds z in cm with
496// respect to the center of the sensitive volulme.
497// Double_t zu detector local coordinate upper bounds z in cm with
498// respect to the center of the sensitive volulme.
499// If ix and or iz is outside of the segmentation range a value of -0.5*Dx()
500// and -0.5*Dx() or -0.5*Dz() and -0.5*Dz() are returned.
501 Int_t i,j;
502 const Float_t kconv = 1.0E-04; // converts microns to cm.
503 Float_t x,z;
504
505 xl = xu = x = -0.5*kconv*Dx(); // default value.
506 zl = zu = z = -0.5*kconv*Dz(); // default value.
507 if(ix<0 || ix>=Npx()) return; // outside of detector
508 if(iz<0 || iz>=Npz()) return; // outside of detctor
509 for(i=0;i<ix;i++) x += kconv*fCellSizeX[i]; // sum up to cell ix-1
510 xl = x;
511 x += kconv*fCellSizeX[ix];
512 xu = x;
513 for(j=0;j<iz;j++) z += kconv*fCellSizeZ[j]; // sum up cell iz-1
514 zl = z;
515 z += kconv*fCellSizeZ[iz];
516 zu = z;
517 return; // Found x and z, return.
518}
2b6642a2 519//----------------------------------------------------------------------
520Int_t AliITSsegmentationSPD::GetChipFromChannel(Int_t, Int_t iz) const {
521 // returns chip number (in range 0-4) starting from channel number
522 if(iz>=fNpz || iz<0 ){
523 AliWarning("Bad cell number");
524 return -1;
525 }
526 Int_t theChip=iz/fgkNcolumnsPerChip;
527 return theChip;
528}
529//----------------------------------------------------------------------
530Int_t AliITSsegmentationSPD::GetChipFromLocal(Float_t, Float_t zloc) const {
531 // returns chip number (in range 0-4) starting from local coordinates
532 Int_t ix0,iz;
533 if (!LocalToDet(0,zloc,ix0,iz)) {
534 AliWarning("Bad local coordinate");
535 return -1;
536 }
537 return GetChipFromChannel(ix0,iz);
538}
539//----------------------------------------------------------------------