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 **************************************************************************/
20 #include <Riostream.h>
21 #include "AliITSsegmentationSSD.h"
22 #include "AliITSgeom.h"
24 #include "AliModule.h"
26 ClassImp(AliITSsegmentationSSD)
27 AliITSsegmentationSSD::AliITSsegmentationSSD(){
28 // default constructor
33 //----------------------------------------------------------------------
34 AliITSsegmentationSSD::AliITSsegmentationSSD(AliITSgeom *geom){
44 //______________________________________________________________________
45 AliITSsegmentationSSD& AliITSsegmentationSSD::operator=(
46 AliITSsegmentationSSD &source){
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
66 //______________________________________________________________________
67 AliITSsegmentationSSD::AliITSsegmentationSSD(AliITSsegmentationSSD &source):
68 AliITSsegmentation(source){
72 //----------------------------------------------------------------------
73 void AliITSsegmentationSSD::Init(){
74 // standard initalizer
80 //----------------------------------------------------------------------
81 void AliITSsegmentationSSD::Angles(Float_t &aP,Float_t &aN){
92 //----------------------------------------------------------------------
93 void AliITSsegmentationSSD::SetLayer(Int_t l){
98 //----------------------------------------------------------------------
99 void 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..
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
121 // expects x, z in microns
123 Float_t StereoP, StereoN;
124 Angles(StereoP,StereoN);
125 Float_t tanP = TMath::Tan(StereoP);
126 Float_t tanN = TMath::Tan(-StereoN);
131 x = (x1 - z1*tanP)/fPitch;
132 z = (x1 - tanN*(z1 - fDz))/fPitch;
134 //----------------------------------------------------------------------
135 void AliITSsegmentationSSD::GetPadIxz(Float_t x,Float_t z,Int_t &iP,Int_t &iN){
136 // returns P and N sided strip numbers for a given location.
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
156 // expects x, z in microns
159 Float_t StereoP, StereoN;
160 Angles(StereoP,StereoN);
161 Float_t tanP=TMath::Tan(StereoP);
162 Float_t tanN=TMath::Tan(StereoN);
166 Float_t ldX = x1 - z1*tanP; // distance from left-down edge
167 iP = (Int_t)(ldX/fPitch);
169 iP = (iP>fNstrips)? -1: iP;
171 ldX = x1 - tanN*(fDz - z1);
172 iN = (Int_t)(ldX/fPitch);
174 iN = (iN>fNstrips)? -1: iN;
177 //-------------------------------------------------------
178 void AliITSsegmentationSSD::GetPadCxz(Int_t iP,Int_t iN,Float_t &x,Float_t &z){
179 // actually this is the GetCrossing(Float_t &,Float_t &)
180 // returns local x, z in microns !
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);
193 x = xP + kP*(Dz*kN-xP+xN)/(kP+kN);
194 z = (Dz*kN-xP+xN)/(kP+kN);
197 //if(TMath::Abs(z) > Dz/2) cout<<"Warning, wrong z local ="<<z<<endl;
198 // Check that zL is inside the detector for the
199 // correspondent xP and xN coordinates
203 //______________________________________________________________________
204 void 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..
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
227 const Double_t kconst = 1.0E-04; // convert microns to cm.
229 x /= kconst; // convert to microns
230 z /= kconst; // convert to microns
231 this->GetPadTxz(x,z);
235 if(iP<0 || iP>=fNstrips) iP=-1; // strip number must be in range.
238 if(iN<0 || iN>=fNstrips) iN=-1; // strip number must be in range.
241 //----------------------------------------------------------------------
242 void 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..
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
267 // x = a + b + z*tan(fStereoP); a = Dpx(iP)*(iP+0.5)-dx; b = dz*th;
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);
276 z = 0.0; // Strip center in z.
277 if(iPN<0 || iPN>1){// if error return full detector size in x.
281 if(ix<0 || ix>=fNstrips) { // if error return full detector size in x.
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);
292 }else if(iPN==1){ // N-side
293 th = TMath::Tan(-StereoN);
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;
302 for(Int_t j=0;j<4;j++){
303 if(xb[j]>=-dx && xb[j]<=dx && zb[j]>=-dz && zb[j]<=dz){
312 //----------------------------------------------------------------------
313 Bool_t AliITSsegmentationSSD::GetCrossing(Int_t iP,Int_t iN,
314 Float_t &x,Float_t &z,
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].
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
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/
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);
346 thp = TMath::Tan(StereoP);
347 thn = TMath::Tan(-StereoN);
349 if(th==0.0) { // parall strips then never cross.
352 c[0][0] = c[1][0] = c[0][1] = c[1][1] = 0.0;
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