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 = 72960.;
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)
39 AliITSsegmentationSSD::AliITSsegmentationSSD(Option_t *opt): AliITSsegmentation(),
49 // default constructor
50 SetDetSize(fgkDxDefault,fgkDzDefault,fgkDyDefault);
51 SetPadSize(fgkPitchDefault,0.);
52 SetNPads(fgkNstripsDefault,0);
54 if(strstr(opt,"TGeo")){
56 AliError("Geometry is not initialized\n");
60 v = gGeoManager->GetVolume("ITSssdSensitivL5");
62 AliWarning("TGeo volumeITSssdSensitivL5 not found (hint: use v11Hybrid geometry)\n Using hardwired default values");
65 TGeoBBox *s=(TGeoBBox*)v->GetShape();
66 SetDetSize(s->GetDX()*20000.,s->GetDZ()*20000.,s->GetDY()*20000.);
70 //----------------------------------------------------------------------
71 AliITSsegmentationSSD::AliITSsegmentationSSD(AliITSgeom *geom):
72 AliITSsegmentation(geom),
83 SetDetSize(fgkDxDefault,fgkDzDefault,fgkDyDefault);
84 SetPadSize(fgkPitchDefault,0.);
85 SetNPads(fgkNstripsDefault,0);
88 //______________________________________________________________________
89 void 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;
106 //______________________________________________________________________
107 AliITSsegmentationSSD& AliITSsegmentationSSD::operator=(
108 const AliITSsegmentationSSD &source){
115 //______________________________________________________________________
116 AliITSsegmentationSSD::AliITSsegmentationSSD(const AliITSsegmentationSSD &source):
117 AliITSsegmentation(source),
130 //----------------------------------------------------------------------
131 void AliITSsegmentationSSD::Init(){
132 // standard initalizer
134 SetPadSize(fgkPitchDefault,0.);
135 SetNPads(fgkNstripsDefault,0);
138 //----------------------------------------------------------------------
139 void AliITSsegmentationSSD::Angles(Float_t &aP,Float_t &aN) const{
140 // P and N side stereo angles
150 //----------------------------------------------------------------------
151 void AliITSsegmentationSSD::SetLayer(Int_t l){
152 //set fLayer data member (only 5 or 6 are allowed)
155 if((l!=5) && (l!=6))AliError(Form("Layer can be 5 or 6, not %d",l));
157 //----------------------------------------------------------------------
158 void AliITSsegmentationSSD::GetPadTxz(Float_t &x,Float_t &z) const{
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..
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
180 // expects x, z in microns
182 Float_t stereoP, stereoN;
183 Angles(stereoP,stereoN);
184 Float_t tanP = TMath::Tan(stereoP);
185 Float_t tanN = TMath::Tan(-stereoN);
190 x = (x1 - z1*tanP)/fPitch;
191 z = (x1 - tanN*(z1 - fDz))/fPitch;
193 //----------------------------------------------------------------------
194 void AliITSsegmentationSSD::GetPadIxz(Float_t x,Float_t z,Int_t &iP,Int_t &iN) const {
195 // returns P and N sided strip numbers for a given location.
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
215 // expects x, z in microns
218 Float_t stereoP, stereoN;
219 Angles(stereoP,stereoN);
220 Float_t tanP=TMath::Tan(stereoP);
221 Float_t tanN=TMath::Tan(stereoN);
225 Float_t ldX = x1 - z1*tanP; // distance from left-down edge
226 iP = (Int_t)(ldX/fPitch);
228 iP = (iP>fNstrips)? -1: iP;
230 ldX = x1 - tanN*(fDz - z1);
231 iN = (Int_t)(ldX/fPitch);
233 iN = (iN>fNstrips)? -1: iN;
236 //-------------------------------------------------------
237 void AliITSsegmentationSSD::GetPadCxz(Int_t iP,Int_t iN,Float_t &x,Float_t &z) const {
238 // actually this is the GetCrossing(Float_t &,Float_t &)
239 // returns local x, z in microns !
241 Float_t lDx = fDx; // detector size in x direction, microns
242 Float_t lDz = fDz; // detector size in z direction, microns
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
245 Float_t stereoP, stereoN;
246 Angles(stereoP,stereoN);
247 Float_t kP=TMath::Tan(stereoP);
248 Float_t kN=TMath::Tan(stereoN);
252 x = xP + kP*(lDz*kN-xP+xN)/(kP+kN);
253 z = (lDz*kN-xP+xN)/(kP+kN);
256 //if(TMath::Abs(z) > Dz/2) cout<<"Warning, wrong z local ="<<z<<endl;
257 // Check that zL is inside the detector for the
258 // correspondent xP and xN coordinates
262 //______________________________________________________________________
263 Bool_t AliITSsegmentationSSD::LocalToDet(Float_t x,Float_t z,
264 Int_t &iP,Int_t &iN) const {
265 // Transformation from Geant cm detector center local coordinates
266 // to detector P and N side strip numbers..
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
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.
293 x /= kconst; // convert to microns
294 z /= kconst; // convert to microns
295 this->GetPadTxz(x,z);
299 if(iP<0 || iP>=fNstrips) iP=-1; // strip number must be in range.
302 if(iN<0 || iN>=fNstrips) iN=-1; // strip number must be in range.
305 //----------------------------------------------------------------------
306 void AliITSsegmentationSSD::DetToLocal(Int_t ix,Int_t iPN,
307 Float_t &x,Float_t &z) const{
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..
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
331 // x = a + b + z*tan(fStereoP); a = Dpx(iP)*(iP+0.5)-dx; b = dz*th;
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];
337 Float_t stereoP, stereoN;
338 Angles(stereoP,stereoN);
340 z = 0.0; // Strip center in z.
341 if(iPN<0 || iPN>1){// if error return full detector size in x.
345 if(ix<0 || ix>=fNstrips) { // if error return full detector size in x.
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.
354 th = TMath::Tan(stereoP);
356 }else if(iPN==1){ // N-side
357 th = TMath::Tan(-stereoN);
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;
366 for(Int_t j=0;j<4;j++){
367 if(xb[j]>=-dx && xb[j]<=dx && zb[j]>=-dz && zb[j]<=dz){
376 //----------------------------------------------------------------------
377 Bool_t AliITSsegmentationSSD::GetCrossing(Int_t iP,Int_t iN,
378 Float_t &x,Float_t &z,
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].
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
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/
405 const Double_t kconst = 1.0E-04; // convert microns to cm.
406 Double_t thp,thn,th,dx,dz,p,ip,in;
407 Float_t stereoP, stereoN;
408 Angles(stereoP,stereoN);
410 thp = TMath::Tan(stereoP);
411 thn = TMath::Tan(-stereoN);
413 if(th==0.0) { // parall strips then never cross.
416 c[0][0] = c[1][0] = c[0][1] = c[1][1] = 0.0;
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
439 //----------------------------------------------------------------------
440 Int_t AliITSsegmentationSSD::GetChipFromChannel(Int_t ix, Int_t iz) const {
441 // returns chip number (in range 0-11) starting from channel number
443 if( (iz>=fgkNstripsDefault) || (iz<0) || (ix<0) || (ix>1) ) {
444 AliError("Bad cell number");
448 if(ix==1) iz = 1535-iz;
449 Int_t theChip =iz/fgkNstripsPerChip;
453 //----------------------------------------------------------------------
454 Int_t AliITSsegmentationSSD::GetChipFromLocal(Float_t xloc, Float_t zloc) const
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
462 if (!LocalToDet(xloc,zloc,iP,iN) ||
463 (iP<0) || (iP>=fNstrips) || (iN<0) || (iN>=fNstrips) ) {
464 AliWarning("Bad local coordinate");
468 Int_t iChip = GetChipFromChannel(0,iP);
469 iChip += 10*GetChipFromChannel(1,iN); // add Nside
476 //----------------------------------------------------------------------
477 void AliITSsegmentationSSD::PrintDefaultParameters() const {
478 // Print default values for parameters.
479 // Values specified as static const data members are shown
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;