]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSsegmentationSSD.cxx
updated
[u/mrichter/AliRoot.git] / ITS / AliITSsegmentationSSD.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 **************************************************************************/
4ae5bbc4 15
88cb7938 16/* $Id$ */
b0f5e3fc 17
4ae5bbc4 18#include <Riostream.h>
55d2c544 19#include <TMath.h>
c9649d1e 20#include <TGeoManager.h>
21#include <TGeoVolume.h>
22#include <TGeoBBox.h>
b0f5e3fc 23#include "AliITSsegmentationSSD.h"
55d2c544 24
25//////////////////////////////////////////////////////
26// Segmentation class for //
27// silicon strips //
28// //
29//////////////////////////////////////////////////////
30const Float_t AliITSsegmentationSSD::fgkDxDefault = 72960.;
31const Float_t AliITSsegmentationSSD::fgkDzDefault = 40000.;
32const Float_t AliITSsegmentationSSD::fgkDyDefault = 300.;
33const Float_t AliITSsegmentationSSD::fgkPitchDefault = 95.;
34const Int_t AliITSsegmentationSSD::fgkNstripsDefault = 768;
6d38396a 35const Int_t AliITSsegmentationSSD::fgkNchipsPerSide = 6;
36const Int_t AliITSsegmentationSSD::fgkNstripsPerChip = 128;
fd61217e 37
b0f5e3fc 38ClassImp(AliITSsegmentationSSD)
c9649d1e 39AliITSsegmentationSSD::AliITSsegmentationSSD(Option_t *opt): AliITSsegmentation(),
e56160b8 40fNstrips(0),
41fStereoP(0),
42fStereoN(0),
43fPitch(0),
44fStereoPl5(0),
45fStereoNl5(0),
46fStereoPl6(0),
47fStereoNl6(0),
48fLayer(0){
179578b2 49 // default constructor
c9649d1e 50 SetDetSize(fgkDxDefault,fgkDzDefault,fgkDyDefault);
51 SetPadSize(fgkPitchDefault,0.);
52 SetNPads(fgkNstripsDefault,0);
53 SetAngles();
54 if(strstr(opt,"TGeo")){
55 if(!gGeoManager){
56 AliError("Geometry is not initialized\n");
57 return;
58 }
59 TGeoVolume *v=NULL;
60 v = gGeoManager->GetVolume("ITSssdSensitivL5");
61 if(!v){
62 AliWarning("TGeo volumeITSssdSensitivL5 not found (hint: use v11Hybrid geometry)\n Using hardwired default values");
63 }
64 else {
65 TGeoBBox *s=(TGeoBBox*)v->GetShape();
66 SetDetSize(s->GetDX()*20000.,s->GetDZ()*20000.,s->GetDY()*20000.);
67 }
68 }
b0f5e3fc 69}
179578b2 70//----------------------------------------------------------------------
e56160b8 71AliITSsegmentationSSD::AliITSsegmentationSSD(AliITSgeom *geom):
f6b6d58e 72AliITSsegmentation(geom),
e56160b8 73fNstrips(0),
74fStereoP(0),
75fStereoN(0),
76fPitch(0),
77fStereoPl5(0),
78fStereoNl5(0),
79fStereoPl6(0),
80fStereoNl6(0),
81fLayer(0){
179578b2 82 // constuctor
55d2c544 83 SetDetSize(fgkDxDefault,fgkDzDefault,fgkDyDefault);
84 SetPadSize(fgkPitchDefault,0.);
85 SetNPads(fgkNstripsDefault,0);
179578b2 86 SetAngles();
b0f5e3fc 87}
55d2c544 88//______________________________________________________________________
89void AliITSsegmentationSSD::Copy(TObject &obj) const {
90 // protected method. copy this to obj
91 AliITSsegmentation::Copy(obj);
92 ((AliITSsegmentationSSD& ) obj).Clear();
93 ((AliITSsegmentationSSD& ) obj).fNstrips = fNstrips;
94 ((AliITSsegmentationSSD& ) obj).fStereoP = fStereoP;
95 ((AliITSsegmentationSSD& ) obj).fStereoN = fStereoN;
96 ((AliITSsegmentationSSD& ) obj).fStereoPl5 = fStereoPl5;
97 ((AliITSsegmentationSSD& ) obj).fStereoNl5 = fStereoNl5;
98 ((AliITSsegmentationSSD& ) obj).fStereoPl6 = fStereoPl6;
99 ((AliITSsegmentationSSD& ) obj).fStereoNl6 = fStereoNl6;
100 ((AliITSsegmentationSSD& ) obj).fLayer = fLayer;
101 ((AliITSsegmentationSSD& ) obj).fPitch = fPitch;
102 ((AliITSsegmentationSSD& ) obj).fLayer = fLayer;
103
104}
105
179578b2 106//______________________________________________________________________
107AliITSsegmentationSSD& AliITSsegmentationSSD::operator=(
55d2c544 108 const AliITSsegmentationSSD &source){
0315d466 109// Operator =
55d2c544 110 if(this != &source){
111 source.Copy(*this);
112 }
113 return *this;
b0f5e3fc 114}
179578b2 115//______________________________________________________________________
55d2c544 116AliITSsegmentationSSD::AliITSsegmentationSSD(const AliITSsegmentationSSD &source):
e56160b8 117 AliITSsegmentation(source),
118fNstrips(0),
119fStereoP(0),
120fStereoN(0),
121fPitch(0),
122fStereoPl5(0),
123fStereoNl5(0),
124fStereoPl6(0),
125fStereoNl6(0),
126fLayer(0){
179578b2 127 // copy constructor
55d2c544 128 source.Copy(*this);
b0f5e3fc 129}
179578b2 130//----------------------------------------------------------------------
b0f5e3fc 131void AliITSsegmentationSSD::Init(){
179578b2 132 // standard initalizer
b0f5e3fc 133
55d2c544 134 SetPadSize(fgkPitchDefault,0.);
135 SetNPads(fgkNstripsDefault,0);
b0f5e3fc 136 SetAngles();
179578b2 137}
138//----------------------------------------------------------------------
55d2c544 139void AliITSsegmentationSSD::Angles(Float_t &aP,Float_t &aN) const{
140 // P and N side stereo angles
179578b2 141 if (fLayer == 5){
142 aP = fStereoPl5;
143 aN = fStereoNl5;
144 } // end if
145 if (fLayer == 6){
146 aP = fStereoPl6;
147 aN = fStereoNl6;
148 } // end if
0315d466 149}
179578b2 150//----------------------------------------------------------------------
151void AliITSsegmentationSSD::SetLayer(Int_t l){
55d2c544 152 //set fLayer data member (only 5 or 6 are allowed)
179578b2 153 if (l==5) fLayer =5;
154 if (l==6) fLayer =6;
f6b6d58e 155 if((l!=5) && (l!=6))AliError(Form("Layer can be 5 or 6, not %d",l));
179578b2 156}
157//----------------------------------------------------------------------
55d2c544 158void AliITSsegmentationSSD::GetPadTxz(Float_t &x,Float_t &z) const{
179578b2 159 // returns P and N sided strip numbers for a given location.
160 // Transformation from microns detector center local coordinates
161 // to detector P and N side strip numbers..
162 /* _- Z
163 + angle / ^
164 fNstrips v | N-Side ...0
165 \-------/------------|-----------\--------\
166 |\\\\\\/////////////.|\\\\\\\\\\\\\\\\\\\\|
167 |0\\\\/////////////..|.\\\\\\\\\\\\\\\\\\\|
168 |00\\/////////////...|..\\\\\\\\\\\\\\\\\\|
169 X <--|000/////////////... |...\\\\\\\\\\\\\\\\\|
170 |00/////////////... | ...\\\\\\\\\\\\\\\\|
171 |0/////////////... | ...\\\\\\\\\\\\\\\|
172 |//////////////... | ...\\\\\\\\\\\\\\\|
173 /-----\--------------|--------------------/
174 fNstrips-1 P-Side ...0
175 |0\
176 |00\
177 Dead region: |000/
178 |00/
179 |0/
180 // expects x, z in microns
181 */
55d2c544 182 Float_t stereoP, stereoN;
183 Angles(stereoP,stereoN);
184 Float_t tanP = TMath::Tan(stereoP);
185 Float_t tanN = TMath::Tan(-stereoN);
179578b2 186 Float_t x1 = x;
187 Float_t z1 = z;
188 x1 += fDx/2;
189 z1 += fDz/2;
190 x = (x1 - z1*tanP)/fPitch;
191 z = (x1 - tanN*(z1 - fDz))/fPitch;
192}
193//----------------------------------------------------------------------
55d2c544 194void AliITSsegmentationSSD::GetPadIxz(Float_t x,Float_t z,Int_t &iP,Int_t &iN) const {
0315d466 195 // returns P and N sided strip numbers for a given location.
179578b2 196 /* _- Z
197 + angle / ^
198 fNstrips v | N-Side ...0
199 \-------/------------|-----------\--------\
200 |\\\\\\/////////////.|\\\\\\\\\\\\\\\\\\\\|
201 |0\\\\/////////////..|.\\\\\\\\\\\\\\\\\\\|
202 |00\\/////////////...|..\\\\\\\\\\\\\\\\\\|
203 X <--|000/////////////... |...\\\\\\\\\\\\\\\\\|
204 |00/////////////... | ...\\\\\\\\\\\\\\\\|
205 |0/////////////... | ...\\\\\\\\\\\\\\\|
206 |//////////////... | ...\\\\\\\\\\\\\\\|
207 /-----\--------------|--------------------/
208 fNstrips-1 P-Side ...0
209 |0\
210 |00\
211 Dead region: |000/
212 |00/
213 |0/
b0f5e3fc 214
215 // expects x, z in microns
179578b2 216 */
c1c63494 217
55d2c544 218 Float_t stereoP, stereoN;
219 Angles(stereoP,stereoN);
220 Float_t tanP=TMath::Tan(stereoP);
221 Float_t tanN=TMath::Tan(stereoN);
0315d466 222 Float_t x1=x,z1=z;
223 x1 += fDx/2;
224 z1 += fDz/2;
225 Float_t ldX = x1 - z1*tanP; // distance from left-down edge
226 iP = (Int_t)(ldX/fPitch);
b0f5e3fc 227 iP = (iP<0)? -1: iP;
228 iP = (iP>fNstrips)? -1: iP;
0315d466 229
230 ldX = x1 - tanN*(fDz - z1);
231 iN = (Int_t)(ldX/fPitch);
b0f5e3fc 232 iN = (iN<0)? -1: iN;
233 iN = (iN>fNstrips)? -1: iN;
0315d466 234
b0f5e3fc 235}
0315d466 236//-------------------------------------------------------
55d2c544 237void AliITSsegmentationSSD::GetPadCxz(Int_t iP,Int_t iN,Float_t &x,Float_t &z) const {
179578b2 238 // actually this is the GetCrossing(Float_t &,Float_t &)
0315d466 239 // returns local x, z in microns !
b0f5e3fc 240
55d2c544 241 Float_t lDx = fDx; // detector size in x direction, microns
242 Float_t lDz = fDz; // detector size in z direction, microns
179578b2 243 Float_t xP; // x coordinate in the P side from the first P strip
244 Float_t xN; // x coordinate in the N side from the first N strip
55d2c544 245 Float_t stereoP, stereoN;
246 Angles(stereoP,stereoN);
247 Float_t kP=TMath::Tan(stereoP);
248 Float_t kN=TMath::Tan(stereoN);
b0f5e3fc 249
0315d466 250 xP=iP*fPitch;
251 xN=iN*fPitch;
55d2c544 252 x = xP + kP*(lDz*kN-xP+xN)/(kP+kN);
253 z = (lDz*kN-xP+xN)/(kP+kN);
254 x -= lDx/2;
255 z -= lDz/2;
66da7685 256 //if(TMath::Abs(z) > Dz/2) cout<<"Warning, wrong z local ="<<z<<endl;
0315d466 257 // Check that zL is inside the detector for the
258 // correspondent xP and xN coordinates
b0f5e3fc 259
260 return;
261}
179578b2 262//______________________________________________________________________
aacedc3e 263Bool_t AliITSsegmentationSSD::LocalToDet(Float_t x,Float_t z,
55d2c544 264 Int_t &iP,Int_t &iN) const {
179578b2 265 // Transformation from Geant cm detector center local coordinates
266 // to detector P and N side strip numbers..
267 /* _- Z
268 + angle / ^
269 fNstrips v | N-Side ...0
270 \-------/------------|-----------\--------\
271 |\\\\\\/////////////.|\\\\\\\\\\\\\\\\\\\\|
272 |0\\\\/////////////..|.\\\\\\\\\\\\\\\\\\\|
273 |00\\/////////////...|..\\\\\\\\\\\\\\\\\\|
274 X <--|000/////////////... |...\\\\\\\\\\\\\\\\\|
275 |00/////////////... | ...\\\\\\\\\\\\\\\\|
276 |0/////////////... | ...\\\\\\\\\\\\\\\|
277 |//////////////... | ...\\\\\\\\\\\\\\\|
278 /-----\--------------|--------------------/
279 fNstrips-1 P-Side ...0
280 |0\
281 |00\
282 Dead region: |000/
283 |00/
284 |0/
285 */
6d38396a 286 Float_t dx,dz;
287 const Double_t kconst = 1.0E-04; // convert microns to cm.
288 dx = 0.5*kconst*Dx();
289 dz = 0.5*kconst*Dz();
290 if( (x<-dx) || (x>dx) ) { iP=-1; return kTRUE; } // outside x range.
291 if( (z<-dz) || (z>dz) ) { iN=-1; return kTRUE; } // outside z range.
292
293 x /= kconst; // convert to microns
294 z /= kconst; // convert to microns
295 this->GetPadTxz(x,z);
296
297 // first for P side
298 iP = (Int_t) x;
299 if(iP<0 || iP>=fNstrips) iP=-1; // strip number must be in range.
300 // Now for N side)
301 iN = (Int_t) z;
302 if(iN<0 || iN>=fNstrips) iN=-1; // strip number must be in range.
303 return kTRUE;
179578b2 304}
305//----------------------------------------------------------------------
306void AliITSsegmentationSSD::DetToLocal(Int_t ix,Int_t iPN,
55d2c544 307 Float_t &x,Float_t &z) const{
179578b2 308 // Transformation from detector segmentation/cell coordiantes starting
309 // from 0. iPN=0 for P side and 1 for N side strip. Returned is z=0.0
310 // and the corresponding x value..
311 /* _- Z
312 + angle / ^
313 fNstrips v | N-Side ...0
314 \-------/------------|-----------\--------\
315 |\\\\\\/////////////.|\\\\\\\\\\\\\\\\\\\\|
316 |0\\\\/////////////..|.\\\\\\\\\\\\\\\\\\\|
317 |00\\/////////////...|..\\\\\\\\\\\\\\\\\\|
318 X <--|000/////////////... |...\\\\\\\\\\\\\\\\\|
319 |00/////////////... | ...\\\\\\\\\\\\\\\\|
320 |0/////////////... | ...\\\\\\\\\\\\\\\|
321 |//////////////... | ...\\\\\\\\\\\\\\\|
322 /-----\--------------|--------------------/
323 fNstrips-1 P-Side ...0
324 |0\
325 |00\
326 Dead region: |000/
327 |00/
328 |0/
329 */
330 // for strips p-side
331 // x = a + b + z*tan(fStereoP); a = Dpx(iP)*(iP+0.5)-dx; b = dz*th;
332 // for strips n-side
333 // x = a + b + z*tan(fStereoP); a = Dpx(iN)*(iN+0.5)-dx; b = -dz*th;
334 const Double_t kconst = 1.0E-04; // convert microns to cm.
335 Float_t flag=kconst*Dx(); // error value
336 Double_t th=0.0,dx,dz,i,a,b=0.0,xb[4],zb[4];
55d2c544 337 Float_t stereoP, stereoN;
338 Angles(stereoP,stereoN);
5752a110 339
179578b2 340 z = 0.0; // Strip center in z.
341 if(iPN<0 || iPN>1){// if error return full detector size in x.
342 x = z = flag;
343 return;
344 } // end if
345 if(ix<0 || ix>=fNstrips) { // if error return full detector size in x.
346 x = z = flag;
347 return;
348 } // end if
349 i = (Double_t) ix; // convert to double
350 dx = 0.5*kconst*Dx(); // half distance in x in cm
351 dz = 0.5*kconst*Dz(); // half distance in z in cm
352 a = kconst*Dpx(ix)*(i+0.5)-dx; // Min x value.
353 if(iPN==0){ //P-side angle defined backwards.
55d2c544 354 th = TMath::Tan(stereoP);
179578b2 355 b = dz*th;
356 }else if(iPN==1){ // N-side
55d2c544 357 th = TMath::Tan(-stereoN);
179578b2 358 b = -dz*th;
359 } // end if
360 // compute average/center position of the strip.
361 xb[0] = +dx; if(th!=0.0) zb[0] = (+dx-a-b)/th; else zb[0] = 0.0;
362 xb[1] = -dx; if(th!=0.0) zb[1] = (-dx-a-b)/th; else zb[1] = 0.0;
363 xb[2] = a+b+dz*th; zb[2] = +dz;
364 xb[3] = a+b-dz*th; zb[3] = -dz;
365 x = 0.0; z = 0.0;
366 for(Int_t j=0;j<4;j++){
367 if(xb[j]>=-dx && xb[j]<=dx && zb[j]>=-dz && zb[j]<=dz){
368 x += xb[j];
369 z += zb[j];
370 } // end if
371 } // end for
372 x *= 0.5;
373 z *= 0.5;
374 return;
375}
376//----------------------------------------------------------------------
377Bool_t AliITSsegmentationSSD::GetCrossing(Int_t iP,Int_t iN,
378 Float_t &x,Float_t &z,
379 Float_t c[2][2]){
380 // Given one P side strip and one N side strip, Returns kTRUE if they
381 // cross each other and the location of the two crossing strips and
382 // their correxlation matrix c[2][2].
383 /* _- Z
384 + angle / ^
385 fNstrips v | N-Side ...0
386 \-------/------------|-----------\--------\
387 |\\\\\\/////////////.|\\\\\\\\\\\\\\\\\\\\|
388 |0\\\\/////////////..|.\\\\\\\\\\\\\\\\\\\|
389 |00\\/////////////...|..\\\\\\\\\\\\\\\\\\|
390 X <--|000/////////////... |...\\\\\\\\\\\\\\\\\|
391 |00/////////////... | ...\\\\\\\\\\\\\\\\|
392 |0/////////////... | ...\\\\\\\\\\\\\\\|
393 |//////////////... | ...\\\\\\\\\\\\\\\|
394 /-----\--------------|--------------------/
395 fNstrips-1 P-Side ...0
396 |0\
397 |00\
398 Dead region: |000/
399 |00/
400 |0/
401 c[2][2] is defined as follows
402 /c[0][0] c[0][1]\ /delta iP\ = /delta x\
403 \c[1][0] c[1][1]/ \delta iN/ = \delta z/
404 */
405 const Double_t kconst = 1.0E-04; // convert microns to cm.
406 Double_t thp,thn,th,dx,dz,p,ip,in;
55d2c544 407 Float_t stereoP, stereoN;
408 Angles(stereoP,stereoN);
179578b2 409
55d2c544 410 thp = TMath::Tan(stereoP);
411 thn = TMath::Tan(-stereoN);
179578b2 412 th = thp-thn;
413 if(th==0.0) { // parall strips then never cross.
414 x = 0.0;
415 z = 0.0;
416 c[0][0] = c[1][0] = c[0][1] = c[1][1] = 0.0;
417 return kFALSE;
418 } // end if
419 // The strips must cross some place in space.
420 ip = (Double_t) iP; // convert to double now for speed
421 in = (Double_t) iN; // convert to double now for speed
422 dx = 0.5*kconst*Dx(); // half distance in x in cm
423 dz = 0.5*kconst*Dz(); // half distance in z in cm
424 p = kconst*Dpx(iP); // Get strip spacing/pitch now
425 x = 0.5*p+dx + (p*(in*thp-ip*thn)-2.0*dz*thp*thn)/th;
426 z =(p*(in-ip)-dz*(thp+thn))/th;
427 // compute correlations.
428 c[0][0] = -thn*p/th; // dx/diP
429 c[1][1] = p/th; // dz/diN
430 c[0][1] = p*thp/th; // dx/diN
431 c[1][0] = -p/th; // dz/diP
432 if(x<-dx || x>dx || z<-dz || z>dz) return kFALSE; // crossing is outside
433 // of the detector so
434 // these strips don't
435 // cross.
436 return kTRUE;
437}
55d2c544 438
6d38396a 439//----------------------------------------------------------------------
440Int_t AliITSsegmentationSSD::GetChipFromChannel(Int_t ix, Int_t iz) const {
441 // returns chip number (in range 0-11) starting from channel number
442
443 if( (iz>=fgkNstripsDefault) || (iz<0) || (ix<0) || (ix>1) ) {
444 AliError("Bad cell number");
445 return -1;
446 }
447
448 if(ix==1) iz = 1535-iz;
449 Int_t theChip =iz/fgkNstripsPerChip;
450 return theChip;
451
452}
453//----------------------------------------------------------------------
454Int_t AliITSsegmentationSSD::GetChipFromLocal(Float_t xloc, Float_t zloc) const
455{
456 // returns chip numbers starting from local coordinates
457 // The two Nside chip number and Pside chip number are
458 // coded as chip=Nchip*10+Pchip
459
460 Int_t iP=0;
461 Int_t iN=0;
462 if (!LocalToDet(xloc,zloc,iP,iN) ||
463 (iP<0) || (iP>=fNstrips) || (iN<0) || (iN>=fNstrips) ) {
464 AliWarning("Bad local coordinate");
465 return -1;
466 }
467
468 Int_t iChip = GetChipFromChannel(0,iP);
469 iChip += 10*GetChipFromChannel(1,iN); // add Nside
470
471 return iChip;
472
473}
474//
475
55d2c544 476//----------------------------------------------------------------------
477void AliITSsegmentationSSD::PrintDefaultParameters() const {
478// Print default values for parameters.
479// Values specified as static const data members are shown
480
481 cout<<"fgkDxDefault = "<<fgkDxDefault<<endl;
482 cout<<"fgkDzDefault = "<<fgkDzDefault<<endl;
483 cout<<"fgkDyDefault = "<<fgkDyDefault<<endl;
484 cout<<"fgkPitchDefault = "<<fgkPitchDefault<<endl;
485 cout<<"fgkNstripsDefault = "<<fgkNstripsDefault<<endl;
486}