1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 #include <Riostream.h>
20 #include <TGeoManager.h>
21 #include <TGeoVolume.h>
23 #include "AliITSsegmentationSSD.h"
25 //////////////////////////////////////////////////////
26 // Segmentation class for //
29 //////////////////////////////////////////////////////
30 const Float_t AliITSsegmentationSSD::fgkDxDefault = 73000.;
31 const Float_t AliITSsegmentationSSD::fgkDzDefault = 40000.;
32 const Float_t AliITSsegmentationSSD::fgkDyDefault = 300.;
33 const Float_t AliITSsegmentationSSD::fgkPitchDefault = 95.;
34 const Int_t AliITSsegmentationSSD::fgkNstripsDefault = 768;
35 const Int_t AliITSsegmentationSSD::fgkNchipsPerSide = 6;
36 const Int_t AliITSsegmentationSSD::fgkNstripsPerChip = 128;
38 ClassImp(AliITSsegmentationSSD)
40 AliITSsegmentationSSD::AliITSsegmentationSSD(Option_t *opt): AliITSsegmentation(),
50 // default constructor
51 SetDetSize(fgkDxDefault,fgkDzDefault,fgkDyDefault);
52 SetPadSize(fgkPitchDefault,0.);
53 SetNPads(fgkNstripsDefault,0);
55 if(strstr(opt,"TGeo")){
57 AliError("Geometry is not initialized\n");
61 v = gGeoManager->GetVolume("ITSssdSensitivL5");
63 AliWarning("TGeo volumeITSssdSensitivL5 not found (hint: use v11Hybrid geometry)\n Using hardwired default values");
66 TGeoBBox *s=(TGeoBBox*)v->GetShape();
67 SetDetSize(s->GetDX()*20000.,s->GetDZ()*20000.,s->GetDY()*20000.);
72 //______________________________________________________________________
73 void AliITSsegmentationSSD::Copy(TObject &obj) const {
74 // protected method. copy this to obj
75 AliITSsegmentation::Copy(obj);
76 ((AliITSsegmentationSSD& ) obj).Clear();
77 ((AliITSsegmentationSSD& ) obj).fNstrips = fNstrips;
78 ((AliITSsegmentationSSD& ) obj).fStereoP = fStereoP;
79 ((AliITSsegmentationSSD& ) obj).fStereoN = fStereoN;
80 ((AliITSsegmentationSSD& ) obj).fStereoPl5 = fStereoPl5;
81 ((AliITSsegmentationSSD& ) obj).fStereoNl5 = fStereoNl5;
82 ((AliITSsegmentationSSD& ) obj).fStereoPl6 = fStereoPl6;
83 ((AliITSsegmentationSSD& ) obj).fStereoNl6 = fStereoNl6;
84 ((AliITSsegmentationSSD& ) obj).fLayer = fLayer;
85 ((AliITSsegmentationSSD& ) obj).fPitch = fPitch;
86 ((AliITSsegmentationSSD& ) obj).fLayer = fLayer;
90 //______________________________________________________________________
91 AliITSsegmentationSSD& AliITSsegmentationSSD::operator=(
92 const AliITSsegmentationSSD &source){
99 //______________________________________________________________________
100 AliITSsegmentationSSD::AliITSsegmentationSSD(const AliITSsegmentationSSD &source):
101 AliITSsegmentation(source),
114 //----------------------------------------------------------------------
115 void AliITSsegmentationSSD::Init(){
116 // standard initalizer
118 SetPadSize(fgkPitchDefault,0.);
119 SetNPads(fgkNstripsDefault,0);
122 //----------------------------------------------------------------------
123 void AliITSsegmentationSSD::Angles(Float_t &aP,Float_t &aN) const{
124 // P and N side stereo angles
129 else if (fLayer == 6){
134 AliWarning("SSD layer not set in segmentation. Setting angles for layer 5");
139 //----------------------------------------------------------------------
140 void AliITSsegmentationSSD::SetLayer(Int_t l){
141 //set fLayer data member (only 5 or 6 are allowed)
144 if((l!=5) && (l!=6))AliError(Form("Layer can be 5 or 6, not %d",l));
146 //----------------------------------------------------------------------
147 void AliITSsegmentationSSD::GetPadTxz(Float_t &x,Float_t &z) const{
148 // returns P and N sided strip numbers for a given location.
149 // Transformation from microns detector center local coordinates
150 // to detector P and N side strip numbers..
153 fNstrips v | N-Side ...0
154 \-------/------------|-----------\--------\
155 |\\\\\\/////////////.|\\\\\\\\\\\\\\\\\\\\|
156 |0\\\\/////////////..|.\\\\\\\\\\\\\\\\\\\|
157 |00\\/////////////...|..\\\\\\\\\\\\\\\\\\|
158 X <--|000/////////////... |...\\\\\\\\\\\\\\\\\|
159 |00/////////////... | ...\\\\\\\\\\\\\\\\|
160 |0/////////////... | ...\\\\\\\\\\\\\\\|
161 |//////////////... | ...\\\\\\\\\\\\\\\|
162 /-----\--------------|--------------------/
163 fNstrips-1 P-Side ...0
169 // expects x, z in microns
171 Float_t stereoP, stereoN;
172 Angles(stereoP,stereoN);
173 Float_t tanP = TMath::Tan(stereoP);
174 Float_t tanN = TMath::Tan(-stereoN);
179 x = (x1 - z1*tanP)/fPitch;
180 z = (x1 - tanN*(z1 - fDz))/fPitch;
182 //----------------------------------------------------------------------
183 void AliITSsegmentationSSD::GetPadIxz(Float_t x,Float_t z,Int_t &iP,Int_t &iN) const {
184 // returns P and N sided strip numbers for a given location.
187 fNstrips v | N-Side ...0
188 \-------/------------|-----------\--------\
189 |\\\\\\/////////////.|\\\\\\\\\\\\\\\\\\\\|
190 |0\\\\/////////////..|.\\\\\\\\\\\\\\\\\\\|
191 |00\\/////////////...|..\\\\\\\\\\\\\\\\\\|
192 X <--|000/////////////... |...\\\\\\\\\\\\\\\\\|
193 |00/////////////... | ...\\\\\\\\\\\\\\\\|
194 |0/////////////... | ...\\\\\\\\\\\\\\\|
195 |//////////////... | ...\\\\\\\\\\\\\\\|
196 /-----\--------------|--------------------/
197 fNstrips-1 P-Side ...0
204 // expects x, z in microns
207 Float_t stereoP, stereoN;
208 Angles(stereoP,stereoN);
209 Float_t tanP=TMath::Tan(stereoP);
210 Float_t tanN=TMath::Tan(stereoN);
214 Float_t ldX = x1 - z1*tanP; // distance from left-down edge
215 iP = (Int_t)(ldX/fPitch);
217 iP = (iP>fNstrips)? -1: iP;
219 ldX = x1 - tanN*(fDz - z1);
220 iN = (Int_t)(ldX/fPitch);
222 iN = (iN>fNstrips)? -1: iN;
225 //-------------------------------------------------------
226 void AliITSsegmentationSSD::GetPadCxz(Int_t iP,Int_t iN,Float_t &x,Float_t &z) const {
227 // actually this is the GetCrossing(Float_t &,Float_t &)
228 // returns local x, z in microns !
230 Float_t lDx = fDx; // detector size in x direction, microns
231 Float_t lDz = fDz; // detector size in z direction, microns
232 Float_t xP; // x coordinate in the P side from the first P strip
233 Float_t xN; // x coordinate in the N side from the first N strip
234 Float_t stereoP, stereoN;
235 Angles(stereoP,stereoN);
236 Float_t kP=TMath::Tan(stereoP);
237 Float_t kN=TMath::Tan(stereoN);
241 x = xP + kP*(lDz*kN-xP+xN)/(kP+kN);
242 z = (lDz*kN-xP+xN)/(kP+kN);
245 //if(TMath::Abs(z) > Dz/2) cout<<"Warning, wrong z local ="<<z<<endl;
246 // Check that zL is inside the detector for the
247 // correspondent xP and xN coordinates
251 //______________________________________________________________________
252 Bool_t AliITSsegmentationSSD::LocalToDet(Float_t x,Float_t z,
253 Int_t &iP,Int_t &iN) const {
254 // Transformation from Geant cm detector center local coordinates
255 // to detector P and N side strip numbers..
258 fNstrips v | N-Side ...0
259 \-------/------------|-----------\--------\
260 |\\\\\\/////////////.|\\\\\\\\\\\\\\\\\\\\|
261 |0\\\\/////////////..|.\\\\\\\\\\\\\\\\\\\|
262 |00\\/////////////...|..\\\\\\\\\\\\\\\\\\|
263 X <--|000/////////////... |...\\\\\\\\\\\\\\\\\|
264 |00/////////////... | ...\\\\\\\\\\\\\\\\|
265 |0/////////////... | ...\\\\\\\\\\\\\\\|
266 |//////////////... | ...\\\\\\\\\\\\\\\|
267 /-----\--------------|--------------------/
268 fNstrips-1 P-Side ...0
276 const Double_t kconst = 1.0E-04; // convert microns to cm.
277 dx = 0.5*kconst*Dx();
278 dz = 0.5*kconst*Dz();
279 if( (x<-dx) || (x>dx) ) {
281 AliWarning(Form("Input argument %f out of range (%f, %f)",x,dx,-dx));
282 return kFALSE; // outside of defined volume.
283 } // outside x range.
284 if( (z<-dz) || (z>dz) ) {
286 AliWarning(Form("Input argument %f out of range (%f, %f)",z,dz,-dz));
287 return kFALSE; // outside of defined volume.
290 x /= kconst; // convert to microns
291 z /= kconst; // convert to microns
292 this->GetPadTxz(x,z);
296 if(iP<0 || iP>=fNstrips) iP=-1; // strip number must be in range.
299 if(iN<0 || iN>=fNstrips) iN=-1; // strip number must be in range.
302 //----------------------------------------------------------------------
303 void AliITSsegmentationSSD::DetToLocal(Int_t ix,Int_t iPN,
304 Float_t &x,Float_t &z) const{
305 // Transformation from detector segmentation/cell coordiantes starting
306 // from 0. iPN=0 for P side and 1 for N side strip. Returned is z=0.0
307 // and the corresponding x value..
310 fNstrips v | N-Side ...0
311 \-------/------------|-----------\--------\
312 |\\\\\\/////////////.|\\\\\\\\\\\\\\\\\\\\|
313 |0\\\\/////////////..|.\\\\\\\\\\\\\\\\\\\|
314 |00\\/////////////...|..\\\\\\\\\\\\\\\\\\|
315 X <--|000/////////////... |...\\\\\\\\\\\\\\\\\|
316 |00/////////////... | ...\\\\\\\\\\\\\\\\|
317 |0/////////////... | ...\\\\\\\\\\\\\\\|
318 |//////////////... | ...\\\\\\\\\\\\\\\|
319 /-----\--------------|--------------------/
320 fNstrips-1 P-Side ...0
328 // x = a + b + z*tan(fStereoP); a = Dpx(iP)*(iP+0.5)-dx; b = dz*th;
330 // x = a + b + z*tan(fStereoP); a = Dpx(iN)*(iN+0.5)-dx; b = -dz*th;
331 const Double_t kconst = 1.0E-04; // convert microns to cm.
332 Float_t flag=kconst*Dx(); // error value
333 Double_t th=0.0,dx,dz,i,a,b=0.0,xb[4],zb[4];
334 Float_t stereoP, stereoN;
335 Angles(stereoP,stereoN);
337 z = 0.0; // Strip center in z.
338 if(iPN<0 || iPN>1){// if error return full detector size in x.
342 if(ix<0 || ix>=fNstrips) { // if error return full detector size in x.
346 i = (Double_t) ix; // convert to double
347 dx = 0.5*kconst*Dx(); // half distance in x in cm
348 dz = 0.5*kconst*Dz(); // half distance in z in cm
349 a = kconst*Dpx(ix)*(i+0.5)-dx; // Min x value.
350 if(iPN==0){ //P-side angle defined backwards.
351 th = TMath::Tan(stereoP);
353 }else if(iPN==1){ // N-side
354 th = TMath::Tan(-stereoN);
357 // compute average/center position of the strip.
358 xb[0] = +dx; if(th!=0.0) zb[0] = (+dx-a-b)/th; else zb[0] = 0.0;
359 xb[1] = -dx; if(th!=0.0) zb[1] = (-dx-a-b)/th; else zb[1] = 0.0;
360 xb[2] = a+b+dz*th; zb[2] = +dz;
361 xb[3] = a+b-dz*th; zb[3] = -dz;
363 for(Int_t j=0;j<4;j++){
364 if(xb[j]>=-dx && xb[j]<=dx && zb[j]>=-dz && zb[j]<=dz){
373 //----------------------------------------------------------------------
374 Bool_t AliITSsegmentationSSD::GetCrossing(Int_t iP,Int_t iN,
375 Float_t &x,Float_t &z,
377 // Given one P side strip and one N side strip, Returns kTRUE if they
378 // cross each other and the location of the two crossing strips and
379 // their correxlation matrix c[2][2].
382 fNstrips v | N-Side ...0
383 \-------/------------|-----------\--------\
384 |\\\\\\/////////////.|\\\\\\\\\\\\\\\\\\\\|
385 |0\\\\/////////////..|.\\\\\\\\\\\\\\\\\\\|
386 |00\\/////////////...|..\\\\\\\\\\\\\\\\\\|
387 X <--|000/////////////... |...\\\\\\\\\\\\\\\\\|
388 |00/////////////... | ...\\\\\\\\\\\\\\\\|
389 |0/////////////... | ...\\\\\\\\\\\\\\\|
390 |//////////////... | ...\\\\\\\\\\\\\\\|
391 /-----\--------------|--------------------/
392 fNstrips-1 P-Side ...0
398 c[2][2] is defined as follows
399 /c[0][0] c[0][1]\ /delta iP\ = /delta x\
400 \c[1][0] c[1][1]/ \delta iN/ = \delta z/
402 const Double_t kconst = 1.0E-04; // convert microns to cm.
403 Double_t thp,thn,th,dx,dz,p,ip,in;
404 Float_t stereoP, stereoN;
405 Angles(stereoP,stereoN);
407 thp = TMath::Tan(stereoP);
408 thn = TMath::Tan(-stereoN);
410 if(th==0.0) { // parall strips then never cross.
413 c[0][0] = c[1][0] = c[0][1] = c[1][1] = 0.0;
416 // The strips must cross some place in space.
417 ip = (Double_t) iP; // convert to double now for speed
418 in = (Double_t) iN; // convert to double now for speed
419 dx = 0.5*kconst*Dx(); // half distance in x in cm
420 dz = 0.5*kconst*Dz(); // half distance in z in cm
421 p = kconst*Dpx(iP); // Get strip spacing/pitch now
422 x = 0.5*p+dx + (p*(in*thp-ip*thn)-2.0*dz*thp*thn)/th;
423 z =(p*(in-ip)-dz*(thp+thn))/th;
424 // compute correlations.
425 c[0][0] = -thn*p/th; // dx/diP
426 c[1][1] = p/th; // dz/diN
427 c[0][1] = p*thp/th; // dx/diN
428 c[1][0] = -p/th; // dz/diP
429 if(x<-dx || x>dx || z<-dz || z>dz) return kFALSE; // crossing is outside
430 // of the detector so
431 // these strips don't
436 //----------------------------------------------------------------------
437 Int_t AliITSsegmentationSSD::GetChipFromChannel(Int_t ix, Int_t iz) const {
438 // returns chip number (in range 0-11) starting from channel number
440 if( (iz>=fgkNstripsDefault) || (iz<0) || (ix<0) || (ix>1) ) {
441 AliError("Bad cell number");
445 if(ix==1) iz = 1535-iz;
446 Int_t theChip =iz/fgkNstripsPerChip;
450 //----------------------------------------------------------------------
451 Int_t AliITSsegmentationSSD::GetChipFromLocal(Float_t xloc, Float_t zloc) const
453 // returns chip numbers starting from local coordinates
454 // The two Nside chip number and Pside chip number are
455 // coded as chip=Nchip*10+Pchip
459 if (!LocalToDet(xloc,zloc,iP,iN) ||
460 (iP<0) || (iP>=fNstrips) || (iN<0) || (iN>=fNstrips) ) {
461 //AliWarning("Bad local coordinate");
465 Int_t iChip = GetChipFromChannel(0,iP);
466 iChip += 10*GetChipFromChannel(1,iN); // add Nside
473 Int_t AliITSsegmentationSSD::GetChipsInLocalWindow(Int_t* array, Float_t zmin, Float_t zmax,
474 Float_t xmin, Float_t xmax) const {
478 Float_t zminDet=-fDz*1.0E-04/2.;
479 Float_t zmaxDet=fDz*1.0E-04/2.;
480 if(zmin<zminDet) zmin=zminDet;
481 if(zmax>zmaxDet) zmax=zmaxDet;
483 Float_t xminDet=-fDx*1.0E-04/2;
484 Float_t xmaxDet=fDx*1.0E-04/2;
485 if(xmin<xminDet) xmin=xminDet;
486 if(xmax>xmaxDet) xmax=xmaxDet;
490 Int_t n1=GetChipFromLocal(xmin,zmin);
491 if(n1!=-1) { // Note! Recpoint can be on the sensor but in the dead area not covered by strips!
492 n1N = (Int_t) (n1/10); // N-side chip coded as 10*chip_index
493 n1P = n1 - 10 * n1N; // P-side chip coded 0-5
502 Int_t n2=GetChipFromLocal(xmin,zmax);
503 if(n2!=-1) { // Note! Recpoint can be on the sensor but in the dead area not covered by strips!
504 n2N = (Int_t) (n2/10); // N-side chip coded as 10*chip_index
505 n2P = n2 - 10 * n2N; // P-side chip coded 0-5
506 if(n2P!=n1P) { array[nChipInW]=n2P; nChipInW++;}
507 if(n2N!=n1N) { array[nChipInW]=n2N; nChipInW++;}
512 Int_t n3=GetChipFromLocal(xmax,zmin);
514 n3N=(Int_t) (n3/10); // N-side chip coded as 10*chip_index
515 n3P=n3 - 10 * n3N; // P-side chip coded 0-5
516 if((n3P!=n1P)&&(n3P!=n2P)) { array[nChipInW]=n3P; nChipInW++;}
517 if((n3N!=n1N)&&(n3N!=n2N)) { array[nChipInW]=n3N; nChipInW++;}
522 Int_t n4=GetChipFromLocal(xmax,zmax);
524 n4N=(Int_t) (n4/10); // N-side chip coded as 10*chip_index
525 n4P=n4 - 10 * n4N; // P-side chip coded 0-5
526 if((n4P!=n1P)&&(n4P!=n2P)&&(n4P!=n3P)) { array[nChipInW]=n4P; nChipInW++;}
527 if((n4N!=n1N)&&(n4N!=n2N)&&(n4N!=n3N)) { array[nChipInW]=n4N; nChipInW++;}
534 //----------------------------------------------------------------------
535 void AliITSsegmentationSSD::PrintDefaultParameters() const {
536 // Print default values for parameters.
537 // Values specified as static const data members are shown
539 cout<<"fgkDxDefault = "<<fgkDxDefault<<endl;
540 cout<<"fgkDzDefault = "<<fgkDzDefault<<endl;
541 cout<<"fgkDyDefault = "<<fgkDyDefault<<endl;
542 cout<<"fgkPitchDefault = "<<fgkPitchDefault<<endl;
543 cout<<"fgkNstripsDefault = "<<fgkNstripsDefault<<endl;