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.15 2001/05/16 14:57:16 alibrary
18 New files for folders and Stack
20 Revision 1.14 2001/05/14 06:21:49 barbera
21 Some unuseful printout commented
23 Revision 1.13 2001/05/14 05:44:11 barbera
24 Version 1.11 reput in place to avoid problem with reconstruction
26 Revision 1.11 2001/05/03 16:12:37 nilsen
27 Fixed up LocalToDet, DetToLocal, GetCrossing, GetPadTxz to work with different
28 angles in layer 5 and 6.
30 Revision 1.10 2001/05/01 22:42:22 nilsen
31 Update of SSD simulation and reconstruction code by Boris and Enrico.
33 Revision 1.9 2001/04/27 14:16:50 nilsen
34 Remove dead and/or unused code and printout lines. i.e. cleaned it up a bit.
40 #include <Riostream.h>
41 #include "AliITSsegmentationSSD.h"
42 #include "AliITSgeom.h"
44 #include "AliModule.h"
46 ClassImp(AliITSsegmentationSSD)
47 AliITSsegmentationSSD::AliITSsegmentationSSD(){
48 // default constructor
53 //----------------------------------------------------------------------
54 AliITSsegmentationSSD::AliITSsegmentationSSD(AliITSgeom *geom){
64 //______________________________________________________________________
65 AliITSsegmentationSSD& AliITSsegmentationSSD::operator=(
66 AliITSsegmentationSSD &source){
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
86 //______________________________________________________________________
87 AliITSsegmentationSSD::AliITSsegmentationSSD(AliITSsegmentationSSD &source){
91 //----------------------------------------------------------------------
92 void AliITSsegmentationSSD::Init(){
93 // standard initalizer
99 //----------------------------------------------------------------------
100 void AliITSsegmentationSSD::Angles(Float_t &aP,Float_t &aN){
111 //----------------------------------------------------------------------
112 void AliITSsegmentationSSD::SetLayer(Int_t l){
117 //----------------------------------------------------------------------
118 void 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..
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
140 // expects x, z in microns
142 Float_t StereoP, StereoN;
143 Angles(StereoP,StereoN);
144 Float_t tanP = TMath::Tan(StereoP);
145 Float_t tanN = TMath::Tan(-StereoN);
150 x = (x1 - z1*tanP)/fPitch;
151 z = (x1 - tanN*(z1 - fDz))/fPitch;
153 //----------------------------------------------------------------------
154 void AliITSsegmentationSSD::GetPadIxz(Float_t x,Float_t z,Int_t &iP,Int_t &iN){
155 // returns P and N sided strip numbers for a given location.
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
175 // expects x, z in microns
178 Float_t StereoP, StereoN;
179 Angles(StereoP,StereoN);
180 Float_t tanP=TMath::Tan(StereoP);
181 Float_t tanN=TMath::Tan(StereoN);
185 Float_t ldX = x1 - z1*tanP; // distance from left-down edge
186 iP = (Int_t)(ldX/fPitch);
188 iP = (iP>fNstrips)? -1: iP;
190 ldX = x1 - tanN*(fDz - z1);
191 iN = (Int_t)(ldX/fPitch);
193 iN = (iN>fNstrips)? -1: iN;
196 //-------------------------------------------------------
197 void AliITSsegmentationSSD::GetPadCxz(Int_t iP,Int_t iN,Float_t &x,Float_t &z){
198 // actually this is the GetCrossing(Float_t &,Float_t &)
199 // returns local x, z in microns !
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);
212 x = xP + kP*(Dz*kN-xP+xN)/(kP+kN);
213 z = (Dz*kN-xP+xN)/(kP+kN);
216 //if(TMath::Abs(z) > Dz/2) cout<<"Warning, wrong z local ="<<z<<endl;
217 // Check that zL is inside the detector for the
218 // correspondent xP and xN coordinates
222 //______________________________________________________________________
223 void 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..
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
246 const Double_t kconst = 1.0E-04; // convert microns to cm.
248 x /= kconst; // convert to microns
249 z /= kconst; // convert to microns
250 this->GetPadTxz(x,z);
254 if(iP<0 || iP>=fNstrips) iP=-1; // strip number must be in range.
257 if(iN<0 || iN>=fNstrips) iN=-1; // strip number must be in range.
260 //----------------------------------------------------------------------
261 void 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..
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
286 // x = a + b + z*tan(fStereoP); a = Dpx(iP)*(iP+0.5)-dx; b = dz*th;
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);
295 z = 0.0; // Strip center in z.
296 if(iPN<0 || iPN>1){// if error return full detector size in x.
300 if(ix<0 || ix>=fNstrips) { // if error return full detector size in x.
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);
311 }else if(iPN==1){ // N-side
312 th = TMath::Tan(-StereoN);
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;
321 for(Int_t j=0;j<4;j++){
322 if(xb[j]>=-dx && xb[j]<=dx && zb[j]>=-dz && zb[j]<=dz){
331 //----------------------------------------------------------------------
332 Bool_t AliITSsegmentationSSD::GetCrossing(Int_t iP,Int_t iN,
333 Float_t &x,Float_t &z,
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].
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
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/
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);
365 thp = TMath::Tan(StereoP);
366 thn = TMath::Tan(-StereoN);
368 if(th==0.0) { // parall strips then never cross.
371 c[0][0] = c[1][0] = c[0][1] = c[1][1] = 0.0;
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