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