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