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