1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 Revision 1.14 2001/05/14 06:21:49 barbera
18 Some unuseful printout commented
20 Revision 1.13 2001/05/14 05:44:11 barbera
21 Version 1.11 reput in place to avoid problem with reconstruction
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.
27 Revision 1.10 2001/05/01 22:42:22 nilsen
28 Update of SSD simulation and reconstruction code by Boris and Enrico.
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.
38 #include "AliITSsegmentationSSD.h"
39 #include "AliITSgeom.h"
41 #include "AliModule.h"
43 ClassImp(AliITSsegmentationSSD)
44 AliITSsegmentationSSD::AliITSsegmentationSSD(){
45 // default constructor
50 //----------------------------------------------------------------------
51 AliITSsegmentationSSD::AliITSsegmentationSSD(AliITSgeom *geom){
61 //______________________________________________________________________
62 AliITSsegmentationSSD& AliITSsegmentationSSD::operator=(
63 AliITSsegmentationSSD &source){
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
83 //______________________________________________________________________
84 AliITSsegmentationSSD::AliITSsegmentationSSD(AliITSsegmentationSSD &source){
88 //----------------------------------------------------------------------
89 void AliITSsegmentationSSD::Init(){
90 // standard initalizer
96 //----------------------------------------------------------------------
97 void AliITSsegmentationSSD::Angles(Float_t &aP,Float_t &aN){
108 //----------------------------------------------------------------------
109 void AliITSsegmentationSSD::SetLayer(Int_t l){
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..
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
137 // expects x, z in microns
139 Float_t StereoP, StereoN;
140 Angles(StereoP,StereoN);
141 Float_t tanP = TMath::Tan(StereoP);
142 Float_t tanN = TMath::Tan(-StereoN);
147 x = (x1 - z1*tanP)/fPitch;
148 z = (x1 - tanN*(z1 - fDz))/fPitch;
150 //----------------------------------------------------------------------
151 void AliITSsegmentationSSD::GetPadIxz(Float_t x,Float_t z,Int_t &iP,Int_t &iN){
152 // returns P and N sided strip numbers for a given location.
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
172 // expects x, z in microns
175 Float_t StereoP, StereoN;
176 Angles(StereoP,StereoN);
177 Float_t tanP=TMath::Tan(StereoP);
178 Float_t tanN=TMath::Tan(StereoN);
182 Float_t ldX = x1 - z1*tanP; // distance from left-down edge
183 iP = (Int_t)(ldX/fPitch);
185 iP = (iP>fNstrips)? -1: iP;
187 ldX = x1 - tanN*(fDz - z1);
188 iN = (Int_t)(ldX/fPitch);
190 iN = (iN>fNstrips)? -1: iN;
193 //-------------------------------------------------------
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 &)
196 // returns local x, z in microns !
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);
209 x = xP + kP*(Dz*kN-xP+xN)/(kP+kN);
210 z = (Dz*kN-xP+xN)/(kP+kN);
213 //if(TMath::Abs(z) > Dz/2) cout<<"Warning, wrong z local ="<<z<<endl;
214 // Check that zL is inside the detector for the
215 // correspondent xP and xN coordinates
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..
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
243 const Double_t kconst = 1.0E-04; // convert microns to cm.
245 x /= kconst; // convert to microns
246 z /= kconst; // convert to microns
247 this->GetPadTxz(x,z);
251 if(iP<0 || iP>=fNstrips) iP=-1; // strip number must be in range.
254 if(iN<0 || iN>=fNstrips) iN=-1; // strip number must be in range.
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..
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
283 // x = a + b + z*tan(fStereoP); a = Dpx(iP)*(iP+0.5)-dx; b = dz*th;
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);
292 z = 0.0; // Strip center in z.
293 if(iPN<0 || iPN>1){// if error return full detector size in x.
297 if(ix<0 || ix>=fNstrips) { // if error return full detector size in x.
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);
308 }else if(iPN==1){ // N-side
309 th = TMath::Tan(-StereoN);
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;
318 for(Int_t j=0;j<4;j++){
319 if(xb[j]>=-dx && xb[j]<=dx && zb[j]>=-dz && zb[j]<=dz){
328 //----------------------------------------------------------------------
329 Bool_t AliITSsegmentationSSD::GetCrossing(Int_t iP,Int_t iN,
330 Float_t &x,Float_t &z,
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].
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
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/
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);
362 thp = TMath::Tan(StereoP);
363 thn = TMath::Tan(-StereoN);
365 if(th==0.0) { // parall strips then never cross.
368 c[0][0] = c[1][0] = c[0][1] = c[1][1] = 0.0;
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