]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSsegmentationSSD.cxx
Version 1.11 reput in place to avoid problem with reconstruction
[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 **************************************************************************/
179578b2 15/*
16$Log$
17Revision 1.11 2001/05/03 16:12:37 nilsen
18Fixed up LocalToDet, DetToLocal, GetCrossing, GetPadTxz to work with different
19angles in layer 5 and 6.
20
21Revision 1.10 2001/05/01 22:42:22 nilsen
22Update of SSD simulation and reconstruction code by Boris and Enrico.
23
24Revision 1.9 2001/04/27 14:16:50 nilsen
25Remove dead and/or unused code and printout lines. i.e. cleaned it up a bit.
26
27*/
b0f5e3fc 28
29#include <TMath.h>
1ca7869b 30#include <TF1.h>
fd61217e 31#include <iostream.h>
b0f5e3fc 32#include "AliITSsegmentationSSD.h"
33#include "AliITSgeom.h"
fd61217e 34
b0f5e3fc 35ClassImp(AliITSsegmentationSSD)
36AliITSsegmentationSSD::AliITSsegmentationSSD(){
179578b2 37 // default constructor
38 fGeom = 0;
39 fCorr = 0;
40 fLayer = 0;
b0f5e3fc 41}
179578b2 42//----------------------------------------------------------------------
b0f5e3fc 43AliITSsegmentationSSD::AliITSsegmentationSSD(AliITSgeom *geom){
179578b2 44 // constuctor
45 fGeom = geom;
46 fCorr = 0;
47 SetDetSize();
48 SetPadSize();
49 SetNPads();
50 SetAngles();
51 fLayer = 0;
b0f5e3fc 52}
179578b2 53//______________________________________________________________________
54AliITSsegmentationSSD& AliITSsegmentationSSD::operator=(
55 AliITSsegmentationSSD &source){
0315d466 56// Operator =
179578b2 57 if(this==&source) return *this;
58 this->fNstrips = source.fNstrips;
59 this->fStereoP = source.fStereoP;
60 this->fStereoN = source.fStereoN;
61 this->fStereoPl5 = source.fStereoPl5;
62 this->fStereoNl5 = source.fStereoNl5;
63 this->fStereoPl6 = source.fStereoPl6;
64 this->fStereoNl6 = source.fStereoNl6;
65 this->fLayer = source.fLayer;
66 this->fPitch = source.fPitch;
67 this->fDz = source.fDz;
68 this->fDx = source.fDx;
69 this->fDy = source.fDy;
70 this->fLayer = source.fLayer;
71 this->fGeom = source.fGeom; // copy only the pointer
72 this->fCorr = new TF1(*(source.fCorr)); // make a proper copy
73 return *this;
b0f5e3fc 74}
179578b2 75//______________________________________________________________________
b0f5e3fc 76AliITSsegmentationSSD::AliITSsegmentationSSD(AliITSsegmentationSSD &source){
179578b2 77 // copy constructor
78 *this = source;
b0f5e3fc 79}
179578b2 80//----------------------------------------------------------------------
b0f5e3fc 81void AliITSsegmentationSSD::Init(){
179578b2 82 // standard initalizer
b0f5e3fc 83
e8189707 84 SetPadSize();
85 SetNPads();
b0f5e3fc 86 SetAngles();
179578b2 87}
88//----------------------------------------------------------------------
89void AliITSsegmentationSSD::Angles(Float_t &aP,Float_t &aN){
0315d466 90
179578b2 91 if (fLayer == 5){
92 aP = fStereoPl5;
93 aN = fStereoNl5;
94 } // end if
95 if (fLayer == 6){
96 aP = fStereoPl6;
97 aN = fStereoNl6;
98 } // end if
0315d466 99}
179578b2 100//----------------------------------------------------------------------
101void AliITSsegmentationSSD::SetLayer(Int_t l){
0315d466 102
179578b2 103 if (l==5) fLayer =5;
104 if (l==6) fLayer =6;
105}
106//----------------------------------------------------------------------
107void AliITSsegmentationSSD::GetPadTxz(Float_t &x,Float_t &z){
108 // returns P and N sided strip numbers for a given location.
109 // Transformation from microns detector center local coordinates
110 // to detector P and N side strip numbers..
111 /* _- Z
112 + angle / ^
113 fNstrips v | N-Side ...0
114 \-------/------------|-----------\--------\
115 |\\\\\\/////////////.|\\\\\\\\\\\\\\\\\\\\|
116 |0\\\\/////////////..|.\\\\\\\\\\\\\\\\\\\|
117 |00\\/////////////...|..\\\\\\\\\\\\\\\\\\|
118 X <--|000/////////////... |...\\\\\\\\\\\\\\\\\|
119 |00/////////////... | ...\\\\\\\\\\\\\\\\|
120 |0/////////////... | ...\\\\\\\\\\\\\\\|
121 |//////////////... | ...\\\\\\\\\\\\\\\|
122 /-----\--------------|--------------------/
123 fNstrips-1 P-Side ...0
124 |0\
125 |00\
126 Dead region: |000/
127 |00/
128 |0/
129 // expects x, z in microns
130 */
131 Float_t StereoP, StereoN;
132 Angles(StereoP,StereoN);
133 Float_t tanP = TMath::Tan(StereoP);
134 Float_t tanN = TMath::Tan(-StereoN);
135 Float_t x1 = x;
136 Float_t z1 = z;
137 x1 += fDx/2;
138 z1 += fDz/2;
139 x = (x1 - z1*tanP)/fPitch;
140 z = (x1 - tanN*(z1 - fDz))/fPitch;
141}
142//----------------------------------------------------------------------
143void AliITSsegmentationSSD::GetPadIxz(Float_t x,Float_t z,Int_t &iP,Int_t &iN){
0315d466 144 // returns P and N sided strip numbers for a given location.
179578b2 145 /* _- Z
146 + angle / ^
147 fNstrips v | N-Side ...0
148 \-------/------------|-----------\--------\
149 |\\\\\\/////////////.|\\\\\\\\\\\\\\\\\\\\|
150 |0\\\\/////////////..|.\\\\\\\\\\\\\\\\\\\|
151 |00\\/////////////...|..\\\\\\\\\\\\\\\\\\|
152 X <--|000/////////////... |...\\\\\\\\\\\\\\\\\|
153 |00/////////////... | ...\\\\\\\\\\\\\\\\|
154 |0/////////////... | ...\\\\\\\\\\\\\\\|
155 |//////////////... | ...\\\\\\\\\\\\\\\|
156 /-----\--------------|--------------------/
157 fNstrips-1 P-Side ...0
158 |0\
159 |00\
160 Dead region: |000/
161 |00/
162 |0/
b0f5e3fc 163
164 // expects x, z in microns
179578b2 165 */
c1c63494 166
0315d466 167 Float_t StereoP, StereoN;
168 Angles(StereoP,StereoN);
169 Float_t tanP=TMath::Tan(StereoP);
170 Float_t tanN=TMath::Tan(StereoN);
171 Float_t x1=x,z1=z;
172 x1 += fDx/2;
173 z1 += fDz/2;
174 Float_t ldX = x1 - z1*tanP; // distance from left-down edge
175 iP = (Int_t)(ldX/fPitch);
b0f5e3fc 176 iP = (iP<0)? -1: iP;
177 iP = (iP>fNstrips)? -1: iP;
0315d466 178
179 ldX = x1 - tanN*(fDz - z1);
180 iN = (Int_t)(ldX/fPitch);
b0f5e3fc 181 iN = (iN<0)? -1: iN;
182 iN = (iN>fNstrips)? -1: iN;
0315d466 183
b0f5e3fc 184}
0315d466 185//-------------------------------------------------------
179578b2 186void AliITSsegmentationSSD::GetPadCxz(Int_t iP,Int_t iN,Float_t &x,Float_t &z){
187 // actually this is the GetCrossing(Float_t &,Float_t &)
0315d466 188 // returns local x, z in microns !
b0f5e3fc 189
179578b2 190 Float_t Dx = fDx; // detector size in x direction, microns
191 Float_t Dz = fDz; // detector size in z direction, microns
192 Float_t xP; // x coordinate in the P side from the first P strip
193 Float_t xN; // x coordinate in the N side from the first N strip
194 Float_t StereoP, StereoN;
195 Angles(StereoP,StereoN);
196 Float_t kP=TMath::Tan(StereoP);
197 Float_t kN=TMath::Tan(StereoN);
b0f5e3fc 198
0315d466 199 xP=iP*fPitch;
200 xN=iN*fPitch;
201 x = xP + kP*(Dz*kN-xP+xN)/(kP+kN);
202 z = (Dz*kN-xP+xN)/(kP+kN);
203 x -= Dx/2;
204 z -= Dz/2;
179578b2 205 if(TMath::Abs(z) > Dz/2) cout<<"Warning, wrong z local ="<<z<<endl;
0315d466 206 // Check that zL is inside the detector for the
207 // correspondent xP and xN coordinates
b0f5e3fc 208
209 return;
210}
179578b2 211//______________________________________________________________________
212void AliITSsegmentationSSD::LocalToDet(Float_t x,Float_t z,
213 Int_t &iP,Int_t &iN){
214 // Transformation from Geant cm detector center local coordinates
215 // to detector P and N side strip numbers..
216 /* _- Z
217 + angle / ^
218 fNstrips v | N-Side ...0
219 \-------/------------|-----------\--------\
220 |\\\\\\/////////////.|\\\\\\\\\\\\\\\\\\\\|
221 |0\\\\/////////////..|.\\\\\\\\\\\\\\\\\\\|
222 |00\\/////////////...|..\\\\\\\\\\\\\\\\\\|
223 X <--|000/////////////... |...\\\\\\\\\\\\\\\\\|
224 |00/////////////... | ...\\\\\\\\\\\\\\\\|
225 |0/////////////... | ...\\\\\\\\\\\\\\\|
226 |//////////////... | ...\\\\\\\\\\\\\\\|
227 /-----\--------------|--------------------/
228 fNstrips-1 P-Side ...0
229 |0\
230 |00\
231 Dead region: |000/
232 |00/
233 |0/
234 */
235 const Double_t kconst = 1.0E-04; // convert microns to cm.
236
237 x /= kconst; // convert to microns
238 z /= kconst; // convert to microns
239 this->GetPadTxz(x,z);
5752a110 240
179578b2 241 // first for P side
242 iP = (Int_t) x;
243 if(iP<0 || iP>=fNstrips) iP=-1; // strip number must be in range.
244 // Now for N side)
245 iN = (Int_t) z;
246 if(iN<0 || iN>=fNstrips) iN=-1; // strip number must be in range.
247 return;
248}
249//----------------------------------------------------------------------
250void AliITSsegmentationSSD::DetToLocal(Int_t ix,Int_t iPN,
251 Float_t &x,Float_t &z){
252 // Transformation from detector segmentation/cell coordiantes starting
253 // from 0. iPN=0 for P side and 1 for N side strip. Returned is z=0.0
254 // and the corresponding x value..
255 /* _- Z
256 + angle / ^
257 fNstrips v | N-Side ...0
258 \-------/------------|-----------\--------\
259 |\\\\\\/////////////.|\\\\\\\\\\\\\\\\\\\\|
260 |0\\\\/////////////..|.\\\\\\\\\\\\\\\\\\\|
261 |00\\/////////////...|..\\\\\\\\\\\\\\\\\\|
262 X <--|000/////////////... |...\\\\\\\\\\\\\\\\\|
263 |00/////////////... | ...\\\\\\\\\\\\\\\\|
264 |0/////////////... | ...\\\\\\\\\\\\\\\|
265 |//////////////... | ...\\\\\\\\\\\\\\\|
266 /-----\--------------|--------------------/
267 fNstrips-1 P-Side ...0
268 |0\
269 |00\
270 Dead region: |000/
271 |00/
272 |0/
273 */
274 // for strips p-side
275 // x = a + b + z*tan(fStereoP); a = Dpx(iP)*(iP+0.5)-dx; b = dz*th;
276 // for strips n-side
277 // x = a + b + z*tan(fStereoP); a = Dpx(iN)*(iN+0.5)-dx; b = -dz*th;
278 const Double_t kconst = 1.0E-04; // convert microns to cm.
279 Float_t flag=kconst*Dx(); // error value
280 Double_t th=0.0,dx,dz,i,a,b=0.0,xb[4],zb[4];
281 Float_t StereoP, StereoN;
282 Angles(StereoP,StereoN);
5752a110 283
179578b2 284 z = 0.0; // Strip center in z.
285 if(iPN<0 || iPN>1){// if error return full detector size in x.
286 x = z = flag;
287 return;
288 } // end if
289 if(ix<0 || ix>=fNstrips) { // if error return full detector size in x.
290 x = z = flag;
291 return;
292 } // end if
293 i = (Double_t) ix; // convert to double
294 dx = 0.5*kconst*Dx(); // half distance in x in cm
295 dz = 0.5*kconst*Dz(); // half distance in z in cm
296 a = kconst*Dpx(ix)*(i+0.5)-dx; // Min x value.
297 if(iPN==0){ //P-side angle defined backwards.
298 th = TMath::Tan(StereoP);
299 b = dz*th;
300 }else if(iPN==1){ // N-side
301 th = TMath::Tan(-StereoN);
302 b = -dz*th;
303 } // end if
304 // compute average/center position of the strip.
305 xb[0] = +dx; if(th!=0.0) zb[0] = (+dx-a-b)/th; else zb[0] = 0.0;
306 xb[1] = -dx; if(th!=0.0) zb[1] = (-dx-a-b)/th; else zb[1] = 0.0;
307 xb[2] = a+b+dz*th; zb[2] = +dz;
308 xb[3] = a+b-dz*th; zb[3] = -dz;
309 x = 0.0; z = 0.0;
310 for(Int_t j=0;j<4;j++){
311 if(xb[j]>=-dx && xb[j]<=dx && zb[j]>=-dz && zb[j]<=dz){
312 x += xb[j];
313 z += zb[j];
314 } // end if
315 } // end for
316 x *= 0.5;
317 z *= 0.5;
318 return;
319}
320//----------------------------------------------------------------------
321Bool_t AliITSsegmentationSSD::GetCrossing(Int_t iP,Int_t iN,
322 Float_t &x,Float_t &z,
323 Float_t c[2][2]){
324 // Given one P side strip and one N side strip, Returns kTRUE if they
325 // cross each other and the location of the two crossing strips and
326 // their correxlation matrix c[2][2].
327 /* _- Z
328 + angle / ^
329 fNstrips v | N-Side ...0
330 \-------/------------|-----------\--------\
331 |\\\\\\/////////////.|\\\\\\\\\\\\\\\\\\\\|
332 |0\\\\/////////////..|.\\\\\\\\\\\\\\\\\\\|
333 |00\\/////////////...|..\\\\\\\\\\\\\\\\\\|
334 X <--|000/////////////... |...\\\\\\\\\\\\\\\\\|
335 |00/////////////... | ...\\\\\\\\\\\\\\\\|
336 |0/////////////... | ...\\\\\\\\\\\\\\\|
337 |//////////////... | ...\\\\\\\\\\\\\\\|
338 /-----\--------------|--------------------/
339 fNstrips-1 P-Side ...0
340 |0\
341 |00\
342 Dead region: |000/
343 |00/
344 |0/
345 c[2][2] is defined as follows
346 /c[0][0] c[0][1]\ /delta iP\ = /delta x\
347 \c[1][0] c[1][1]/ \delta iN/ = \delta z/
348 */
349 const Double_t kconst = 1.0E-04; // convert microns to cm.
350 Double_t thp,thn,th,dx,dz,p,ip,in;
351 Float_t StereoP, StereoN;
352 Angles(StereoP,StereoN);
353
354 thp = TMath::Tan(StereoP);
355 thn = TMath::Tan(-StereoN);
356 th = thp-thn;
357 if(th==0.0) { // parall strips then never cross.
358 x = 0.0;
359 z = 0.0;
360 c[0][0] = c[1][0] = c[0][1] = c[1][1] = 0.0;
361 return kFALSE;
362 } // end if
363 // The strips must cross some place in space.
364 ip = (Double_t) iP; // convert to double now for speed
365 in = (Double_t) iN; // convert to double now for speed
366 dx = 0.5*kconst*Dx(); // half distance in x in cm
367 dz = 0.5*kconst*Dz(); // half distance in z in cm
368 p = kconst*Dpx(iP); // Get strip spacing/pitch now
369 x = 0.5*p+dx + (p*(in*thp-ip*thn)-2.0*dz*thp*thn)/th;
370 z =(p*(in-ip)-dz*(thp+thn))/th;
371 // compute correlations.
372 c[0][0] = -thn*p/th; // dx/diP
373 c[1][1] = p/th; // dz/diN
374 c[0][1] = p*thp/th; // dx/diN
375 c[1][0] = -p/th; // dz/diP
376 if(x<-dx || x>dx || z<-dz || z>dz) return kFALSE; // crossing is outside
377 // of the detector so
378 // these strips don't
379 // cross.
380 return kTRUE;
381}