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