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