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