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