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 **************************************************************************/
21 ////////////////////////////////////////////////////////////////////////
22 // This class is a base class for the ITS geometry version 11. It
23 // contains common/standard functions used in many places in defining
24 // the ITS geometry, version 11. Large posions of the ITS geometry,
25 // version 11, should be derived from this class so as to make maximum
26 // use of these common functions. This class also defines the proper
27 // conversion valuse such, to cm and degrees, such that the most usefull
28 // units, those used in the Engineering drawings, can be used.
29 ////////////////////////////////////////////////////////////////////////
32 #include <Riostream.h>
41 #include <TGeoTube.h> // contaings TGeoTubeSeg
43 #include <TPolyMarker.h>
44 #include <TPolyLine.h>
45 #include "AliITSv11Geometry.h"
47 ClassImp(AliITSv11Geometry)
49 const Double_t AliITSv11Geometry::fgkmicron = 1.0E-4;
50 const Double_t AliITSv11Geometry::fgkmm = 0.10;
51 const Double_t AliITSv11Geometry::fgkcm = 1.00;
52 const Double_t AliITSv11Geometry::fgkDegree = 1.0;
53 const Double_t AliITSv11Geometry::fgkRadian = 180./3.14159265358979323846;
54 const Double_t AliITSv11Geometry::fgkgcm3 = 1.0; // assume default is g/cm^3
55 const Double_t AliITSv11Geometry::fgkCelsius = 1.0; // Assume default is C
56 const Double_t AliITSv11Geometry::fgkPascal = 1.0E-3; // Assume kPascal
57 const Double_t AliITSv11Geometry::fgkKPascal = 1.0; // Asume kPascal
58 const Double_t AliITSv11Geometry::fgkeV = 1.0E-9; // GeV default
59 const Double_t AliITSv11Geometry::fgkKeV = 1.0e-6; // GeV default
60 const Double_t AliITSv11Geometry::fgkMeV = 1.0e-3; // GeV default
61 const Double_t AliITSv11Geometry::fgkGeV = 1.0; // GeV default
62 //______________________________________________________________________
63 Double_t AliITSv11Geometry::Yfrom2Points(Double_t x0,Double_t y0,
64 Double_t x1,Double_t y1,
66 // Given the two points (x0,y0) and (x1,y1) and the location x, returns
67 // the value y corresponding to that point x on the line defined by the
70 // Double_t x0 The first x value defining the line
71 // Double_t y0 The first y value defining the line
72 // Double_t x1 The second x value defining the line
73 // Double_t y1 The second y value defining the line
74 // Double_t x The x value for which the y value is wanted.
78 // The value y corresponding to the point x on the line defined by
79 // the two points (x0,y0) and (x1,y1).
81 if(x0==x1 && y0==y1) {
82 printf("Error: AliITSv11Geometry::Yfrom2Ponts The two points are "
83 "the same (%e,%e) and (%e,%e)",x0,y0,x1,y1);
87 printf("Warning: AliITSv11Geometry::Yfrom2Points x0=%e == x1=%e. "
88 "line vertical ""returning mean y",x0,x1);
91 Double_t m = (y0-y1)/(x0-x1);
94 //______________________________________________________________________
95 Double_t AliITSv11Geometry::Xfrom2Points(Double_t x0,Double_t y0,
96 Double_t x1,Double_t y1,
98 // Given the two points (x0,y0) and (x1,y1) and the location y, returns
99 // the value x corresponding to that point y on the line defined by the
102 // Double_t x0 The first x value defining the line
103 // Double_t y0 The first y value defining the line
104 // Double_t x1 The second x value defining the line
105 // Double_t y1 The second y value defining the line
106 // Double_t y The y value for which the x value is wanted.
110 // The value x corresponding to the point y on the line defined by
111 // the two points (x0,y0) and (x1,y1).
113 if(x0==x1 && y0==y1) {
114 printf("Error: AliITSv11Geometry::Yfrom2Ponts The two points are "
115 "the same (%e,%e) and (%e,%e)",x0,y0,x1,y1);
119 printf("Warrning: AliITSv11Geometry::Yfrom2Points y0=%e == y1=%e. "
120 "line horizontal returning mean x",y0,y1);
123 Double_t m = (x0-x1)/(y0-y1);
126 //______________________________________________________________________
127 Double_t AliITSv11Geometry::RmaxFrom2Points(const TGeoPcon *p,Int_t i1,
128 Int_t i2,Double_t z)const{
129 // functions Require at parts of Volume A to be already defined.
130 // Retruns the value of Rmax corresponding to point z alone the line
131 // defined by the two points p.Rmax(i1),p-GetZ(i1) and p->GetRmax(i2),
134 // TGeoPcon *p The Polycone where the two points come from
137 // Double_t z The value of z for which Rmax is to be found
141 // Double_t Rmax the value corresponding to z
144 d0 = p->GetRmax(i1)-p->GetRmax(i2);// cout <<"L263: d0="<<d0<<endl;
145 d1 = z-p->GetZ(i2);// cout <<"L264: d1="<<d1<<endl;
146 d2 = p->GetZ(i1)-p->GetZ(i2);// cout <<"L265: d2="<<d2<<endl;
147 r = p->GetRmax(i2) + d1*d0/d2;// cout <<"L266: r="<<r<<endl;
150 //______________________________________________________________________
151 Double_t AliITSv11Geometry::RminFrom2Points(const TGeoPcon *p,Int_t i1,
152 Int_t i2,Double_t z)const{
153 // Retruns the value of Rmin corresponding to point z alone the line
154 // defined by the two points p->GetRmin(i1),p->GetZ(i1) and
155 // p->GetRmin(i2), p->GetZ(i2).
157 // TGeoPcon *p The Polycone where the two points come from
160 // Double_t z The value of z for which Rmax is to be found
164 // Double_t Rmax the value corresponding to z
166 return p->GetRmin(i2)+(p->GetRmin(i1)-p->GetRmin(i2))*(z-p->GetZ(i2))/
167 (p->GetZ(i1)-p->GetZ(i2));
169 //______________________________________________________________________
170 Double_t AliITSv11Geometry::RFrom2Points(const Double_t *p,const Double_t *az,
171 Int_t i1,Int_t i2,Double_t z)const{
172 // Retruns the value of Rmin corresponding to point z alone the line
173 // defined by the two points p->GetRmin(i1),p->GetZ(i1) and
174 // p->GetRmin(i2), p->GetZ(i2).
176 // Double_t az Array of z values
177 // Double_t r Array of r values
178 // Int_t i1 First Point in arrays
179 // Int_t i2 Second Point in arrays
180 // Double_t z Value z at which r is to be found
184 // The value r corresponding to z and the line defined by the two points
186 return p[i2]+(p[i1]-p[i2])*(z-az[i2])/(az[i1]-az[i2]);
188 //______________________________________________________________________
189 Double_t AliITSv11Geometry::Zfrom2MinPoints(const TGeoPcon *p,Int_t i1,
190 Int_t i2,Double_t r)const{
191 // Retruns the value of Z corresponding to point R alone the line
192 // defined by the two points p->GetRmin(i1),p->GetZ(i1) and
193 // p->GetRmin(i2),p->GetZ(i2)
195 // TGeoPcon *p The Poly cone where the two points come from.
196 // Int_t i1 First Point in arrays
197 // Int_t i2 Second Point in arrays
198 // Double_t r Value r min at which z is to be found
202 // The value z corresponding to r min and the line defined by
205 return p->GetZ(i2)+(p->GetZ(i1)-p->GetZ(i2))*(r-p->GetRmin(i2))/
206 (p->GetRmin(i1)-p->GetRmin(i2));
208 //______________________________________________________________________
209 Double_t AliITSv11Geometry::Zfrom2MaxPoints(const TGeoPcon *p,Int_t i1,
210 Int_t i2,Double_t r)const{
211 // Retruns the value of Z corresponding to point R alone the line
212 // defined by the two points p->GetRmax(i1),p->GetZ(i1) and
213 // p->GetRmax(i2),p->GetZ(i2)
215 // TGeoPcon *p The Poly cone where the two points come from.
216 // Int_t i1 First Point in arrays
217 // Int_t i2 Second Point in arrays
218 // Double_t r Value r max at which z is to be found
222 // The value z corresponding to r max and the line defined by
225 return p->GetZ(i2)+(p->GetZ(i1)-p->GetZ(i2))*(r-p->GetRmax(i2))/
226 (p->GetRmax(i1)-p->GetRmax(i2));
228 //______________________________________________________________________
229 Double_t AliITSv11Geometry::Zfrom2Points(const Double_t *z,const Double_t *ar,
230 Int_t i1,Int_t i2,Double_t r)const{
231 // Retruns the value of z corresponding to point R alone the line
232 // defined by the two points p->GetRmax(i1),p->GetZ(i1) and
233 // p->GetRmax(i2),p->GetZ(i2)
235 // Double_t z Array of z values
236 // Double_t ar Array of r values
237 // Int_t i1 First Point in arrays
238 // Int_t i2 Second Point in arrays
239 // Double_t r Value r at which z is to be found
243 // The value z corresponding to r and the line defined by the two points
245 return z[i2]+(z[i1]-z[i2])*(r-ar[i2])/(ar[i1]-ar[i2]);
247 //______________________________________________________________________
248 Double_t AliITSv11Geometry::RmaxFromZpCone(const TGeoPcon *p,int ip,
249 Double_t tc,Double_t z,
251 // General Outer Cone surface equation Rmax.
253 // TGeoPcon *p The poly cone where the initial point comes from
254 // Int_t ip The index in p to get the point location
255 // Double_t tc The angle of that part of the cone is at
256 // Double_t z The value of z to compute Rmax from
257 // Double_t th The perpendicular distance the parralell line is
258 // from the point ip.
262 // The value Rmax correstponding to the line at angle th, offeset by
263 // th, and the point p->GetZ/Rmin[ip] at the location z.
264 Double_t tantc = TMath::Tan(tc*TMath::DegToRad());
265 Double_t costc = TMath::Cos(tc*TMath::DegToRad());
267 return -tantc*(z-p->GetZ(ip))+p->GetRmax(ip)+th/costc;
269 //______________________________________________________________________
270 Double_t AliITSv11Geometry::RFromZpCone(const Double_t *ar,
271 const Double_t *az,int ip,
272 Double_t tc,Double_t z,
274 // General Cone surface equation R(z).
276 // Double_t ar The array of R values
277 // Double_t az The array of Z values
278 // Int_t ip The index in p to get the point location
279 // Double_t tc The angle of that part of the cone is at
280 // Double_t z The value of z to compute R from
281 // Double_t th The perpendicular distance the parralell line is
282 // from the point ip.
286 // The value R correstponding to the line at angle th, offeset by
287 // th, and the point p->GetZ/Rmax[ip] at the locatin z.
288 Double_t tantc = TMath::Tan(tc*TMath::DegToRad());
289 Double_t costc = TMath::Cos(tc*TMath::DegToRad());
291 return -tantc*(z-az[ip])+ar[ip]+th/costc;
293 //______________________________________________________________________
294 Double_t AliITSv11Geometry::RminFromZpCone(const TGeoPcon *p,Int_t ip,
295 Double_t tc,Double_t z,
297 // General Inner Cone surface equation Rmin.
299 // TGeoPcon *p The poly cone where the initial point comes from
300 // Int_t ip The index in p to get the point location
301 // Double_t tc The angle of that part of the cone is at
302 // Double_t z The value of z to compute Rmin from
303 // Double_t th The perpendicular distance the parralell line is
304 // from the point ip.
308 // The value Rmin correstponding to the line at angle th, offeset by
309 // th, and the point p->GetZ/Rmin[ip] at the location z.
310 Double_t tantc = TMath::Tan(tc*TMath::DegToRad());
311 Double_t costc = TMath::Cos(tc*TMath::DegToRad());
313 return -tantc*(z-p->GetZ(ip))+p->GetRmin(ip)+th/costc;
315 //______________________________________________________________________
316 Double_t AliITSv11Geometry::ZFromRmaxpCone(const TGeoPcon *p,int ip,
317 Double_t tc,Double_t r,
319 // General Outer cone Surface equation for z.
321 // TGeoPcon *p The poly cone where the initial point comes from
322 // Int_t ip The index in p to get the point location
323 // Double_t tc The angle of that part of the cone is at
324 // Double_t r The value of Rmax to compute z from
325 // Double_t th The perpendicular distance the parralell line is
326 // from the point ip.
330 // The value Z correstponding to the line at angle th, offeset by
331 // th, and the point p->GetZ/Rmax[ip] at the location r.
332 Double_t tantc = TMath::Tan(tc*TMath::DegToRad());
333 Double_t costc = TMath::Cos(tc*TMath::DegToRad());
335 return p->GetZ(ip)+(p->GetRmax(ip)+th/costc-r)/tantc;
337 //______________________________________________________________________
338 Double_t AliITSv11Geometry::ZFromRmaxpCone(const Double_t *ar,
339 const Double_t *az,int ip,
340 Double_t tc,Double_t r,
342 // General Outer cone Surface equation for z.
344 // Double_t ar The array of R values
345 // Double_t az The array of Z values
346 // Int_t ip The index in p to get the point location
347 // Double_t tc The angle of that part of the cone is at
348 // Double_t r The value of Rmax to compute z from
349 // Double_t th The perpendicular distance the parralell line is
350 // from the point ip.
354 // The value Z correstponding to the line at angle th, offeset by
355 // th, and the point p->GetZ/Rmax[ip] at the locatin r.
356 Double_t tantc = TMath::Tan(tc*TMath::DegToRad());
357 Double_t costc = TMath::Cos(tc*TMath::DegToRad());
359 return az[ip]+(ar[ip]+th/costc-r)/tantc;
361 //______________________________________________________________________
362 Double_t AliITSv11Geometry::ZFromRminpCone(const TGeoPcon *p,int ip,
363 Double_t tc,Double_t r,
365 // General Inner cone Surface equation for z.
367 // TGeoPcon *p The poly cone where the initial point comes from
368 // Int_t ip The index in p to get the point location
369 // Double_t tc The angle of that part of the cone is at
370 // Double_t r The value of Rmin to compute z from
371 // Double_t th The perpendicular distance the parralell line is
372 // from the point ip.
376 // The value Z correstponding to the line at angle th, offeset by
377 // th, and the point p->GetZ/Rmin[ip] at the location r.
378 Double_t tantc = TMath::Tan(tc*TMath::DegToRad());
379 Double_t costc = TMath::Cos(tc*TMath::DegToRad());
381 return p->GetZ(ip)+(p->GetRmin(ip)+th/costc-r)/tantc;
383 //______________________________________________________________________
384 void AliITSv11Geometry::RadiusOfCurvature(Double_t rc,Double_t theta0,
385 Double_t z0,Double_t r0,
386 Double_t theta1,Double_t &z1,
388 // Given a initial point z0,r0, the initial angle theta0, and the radius
389 // of curvature, returns the point z1, r1 at the angle theta1. Theta
390 // measured from the r axis in the clock wise direction [degrees].
392 // Double_t rc The radius of curvature
393 // Double_t theta0 The starting angle (degrees)
394 // Double_t z0 The value of z at theta0
395 // Double_t r0 The value of r at theta0
396 // Double_t theta1 The ending angle (degrees)
398 // Double_t &z1 The value of z at theta1
399 // Double_t &r1 The value of r at theta1
403 z1 = rc*(TMath::Sin(theta1*TMath::DegToRad())-TMath::Sin(theta0*TMath::DegToRad()))+z0;
404 r1 = rc*(TMath::Cos(theta1*TMath::DegToRad())-TMath::Cos(theta0*TMath::DegToRad()))+r0;
407 //______________________________________________________________________
408 void AliITSv11Geometry::InsidePoint(const TGeoPcon *p,Int_t i1,Int_t i2,
409 Int_t i3,Double_t c,TGeoPcon *q,Int_t j1,
411 // Given two lines defined by the points i1, i2,i3 in the TGeoPcon
412 // class p that intersect at point p->GetZ(i2) return the point z,r
413 // that is Cthick away in the TGeoPcon class q. If points i1=i2
414 // and max == kTRUE, then p->GetRmin(i1) and p->GetRmax(i2) are used.
415 // if points i2=i3 and max=kTRUE then points p->GetRmax(i2) and
416 // p->GetRmin(i3) are used. If i2=i3 and max=kFALSE, then p->GetRmin(i2)
417 // and p->GetRmax(i3) are used.
419 // TGeoPcon *p Class where points i1, i2, and i3 are taken from
420 // Int_t i1 First point in class p
421 // Int_t i2 Second point in class p
422 // Int_t i3 Third point in class p
423 // Double_t c Distance inside the outer surface/inner suface
424 // that the point j1 is to be computed for.
425 // TGeoPcon *q Pointer to class for results to be put into.
426 // Int_t j1 Point in class q where data is to be stored.
427 // Bool_t max if kTRUE, then a Rmax value is computed,
428 // else a Rmin valule is computed.
430 // TGeoPcon *q Pointer to class for results to be put into.
433 Double_t x0,y0,x1,y1,x2,y2,x,y;
436 c = -c; //cout <<"L394 c="<<c<<endl;
438 if(i1==i2) y0 = p->GetRmin(i1); //cout <<"L396 y0="<<y0<<endl;
439 y1 = p->GetRmax(i2); //cout <<"L397 y1="<<y1<<endl;
440 y2 = p->GetRmax(i3); //cout <<"L398 y2="<<y2<<endl;
441 if(i2==i3) y2 = p->GetRmin(i3); //cout <<"L399 y2="<<y2<<endl;
443 y0 = p->GetRmin(i1); //cout <<"L401 y0="<<y0<<endl;
444 y1 = p->GetRmin(i2); //cout <<"L402 y1="<<y1<<endl;
446 if(i2==i3) y2 = p->GetRmax(i3); //cout <<"L404 y2="<<y2<<endl;
448 x0 = p->GetZ(i1); //cout <<"L406 x0="<<x0<<endl;
449 x1 = p->GetZ(i2); //cout <<"L407 x1="<<x1<<endl;
450 x2 = p->GetZ(i3); //cout <<"L408 x2="<<x2<<endl;
452 InsidePoint(x0,y0,x1,y1,x2,y2,c,x,y);
454 if(max) q->Rmax(j1) = y;
455 else q->Rmin(j1) = y;
458 //----------------------------------------------------------------------
459 void AliITSv11Geometry::InsidePoint(Double_t x0,Double_t y0,
460 Double_t x1,Double_t y1,
461 Double_t x2,Double_t y2,Double_t c,
462 Double_t &x,Double_t &y)const{
463 // Given two intersecting lines defined by the points (x0,y0), (x1,y1) and
464 // (x1,y1), (x2,y2) {intersecting at (x1,y1)} the point (x,y) a distance
465 // c away is returned such that two lines a distance c away from the
466 // lines defined above intersect at (x,y).
468 // Double_t x0 X point on the first intersecting sets of lines
469 // Double_t y0 Y point on the first intersecting sets of lines
470 // Double_t x1 X point on the first/second intersecting sets of lines
471 // Double_t y1 Y point on the first/second intersecting sets of lines
472 // Double_t x2 X point on the second intersecting sets of lines
473 // Double_t y2 Y point on the second intersecting sets of lines
474 // Double_t c Distance the two sets of lines are from each other
476 // Double_t x X point for the intersecting sets of parellel lines
477 // Double_t y Y point for the intersecting sets of parellel lines
480 Double_t dx01,dx12,dy01,dy12,r01,r12,m;
482 //printf("InsidePoint: x0=% #12.7g y0=% #12.7g x1=% #12.7g y1=% #12.7g "
483 // "x2=% #12.7g y2=% #12.7g c=% #12.7g ",x0,y0,x1,y2,x2,y2,c);
484 dx01 = x0-x1; //cout <<"L410 dx01="<<dx01<<endl;
485 dx12 = x1-x2; //cout <<"L411 dx12="<<dx12<<endl;
486 dy01 = y0-y1; //cout <<"L412 dy01="<<dy01<<endl;
487 dy12 = y1-y2; //cout <<"L413 dy12="<<dy12<<endl;
488 r01 = TMath::Sqrt(dy01*dy01+dx01*dx01); //cout <<"L414 r01="<<r01<<endl;
489 r12 = TMath::Sqrt(dy12*dy12+dx12*dx12); //cout <<"L415 r12="<<r12<<endl;
490 m = dx12*dy01-dy12*dx01;
491 if(m*m<DBL_EPSILON){ // m == n
492 if(dy01==0.0){ // line are =
493 x = x1+c; //cout <<"L419 x="<<x<<endl;
494 y = y1; //cout <<"L420 y="<<y<<endl;
495 //printf("dy01==0.0 x=% #12.7g y=% #12.7g\n",x,y);
500 //printf("dx01==0.0 x=% #12.7g y=% #12.7g\n",x,y);
502 }else{ // dx01!=0 and dy01 !=0.
503 x = x1-0.5*c*r01/dy01; //cout <<"L434 x="<<x<<endl;
504 y = y1+0.5*c*r01/dx01; //cout <<"L435 y="<<y<<endl;
505 //printf("m*m<DBL_E x=% #12.7g y=% #12.7g\n",x,y);
509 x = x1+c*(dx12*r01-dx01*r12)/m; //cout <<"L442 x="<<x<<endl;
510 y = y1+c*(dy12*r01-dy01*r12)/m; //cout <<"L443 y="<<y<<endl;
511 //printf(" x=% #12.7g y=% #12.7g\n",x,y);
512 //cout <<"=============================================="<<endl;
515 //----------------------------------------------------------------------
516 void AliITSv11Geometry:: PrintArb8(const TGeoArb8 *a)const{
517 // Prints out the content of the TGeoArb8. Usefull for debugging.
525 if(!GetDebug()) return;
526 printf("%s",a->GetName());
530 //----------------------------------------------------------------------
531 void AliITSv11Geometry:: PrintPcon(const TGeoPcon *a)const{
532 // Prints out the content of the TGeoPcon. Usefull for debugging.
540 if(!GetDebug()) return;
541 cout << a->GetName() << ": N=" << a->GetNz() << " Phi1=" << a->GetPhi1()
542 << ", Dphi=" << a->GetDphi() << endl;
543 cout << "i\t Z \t Rmin \t Rmax" << endl;
544 for(Int_t iii=0;iii<a->GetNz();iii++){
545 cout << iii << "\t" << a->GetZ(iii) << "\t" << a->GetRmin(iii)
546 << "\t" << a->GetRmax(iii) << endl;
550 //----------------------------------------------------------------------
551 void AliITSv11Geometry::PrintTube(const TGeoTube *a)const{
552 // Prints out the content of the TGeoTube. Usefull for debugging.
560 if(!GetDebug()) return;
561 cout << a->GetName() <<": Rmin="<<a->GetRmin()
562 <<" Rmax=" <<a->GetRmax()<<" Dz="<<a->GetDz()<<endl;
565 //----------------------------------------------------------------------
566 void AliITSv11Geometry::PrintTubeSeg(const TGeoTubeSeg *a)const{
567 // Prints out the content of the TGeoTubeSeg. Usefull for debugging.
575 if(!GetDebug()) return;
576 cout << a->GetName() <<": Phi1="<<a->GetPhi1()<<
577 " Phi2="<<a->GetPhi2()<<" Rmin="<<a->GetRmin()
578 <<" Rmax=" <<a->GetRmax()<<" Dz="<<a->GetDz()<<endl;
581 //----------------------------------------------------------------------
582 void AliITSv11Geometry::PrintConeSeg(const TGeoConeSeg *a)const{
583 // Prints out the content of the TGeoConeSeg. Usefull for debugging.
591 if(!GetDebug()) return;
592 cout << a->GetName() <<": Phi1="<<a->GetPhi1()<<
593 " Phi2="<<a->GetPhi2()<<" Rmin1="<<a->GetRmin1()
594 <<" Rmax1=" <<a->GetRmax1()<<" Rmin2="<<a->GetRmin2()
595 <<" Rmax2=" <<a->GetRmax2()<<" Dz="<<a->GetDz()<<endl;
598 //----------------------------------------------------------------------
599 void AliITSv11Geometry::PrintBBox(const TGeoBBox *a)const{
600 // Prints out the content of the TGeoBBox. Usefull for debugging.
608 if(!GetDebug()) return;
609 cout << a->GetName() <<": Dx="<<a->GetDX()<<
610 " Dy="<<a->GetDY()<<" Dz="<<a->GetDZ() <<endl;
613 //---------------------------------------------------------------------
614 void AliITSv11Geometry::DrawCrossSection(const TGeoPcon *p,
615 Int_t fillc,Int_t fills,
616 Int_t linec,Int_t lines,Int_t linew,
617 Int_t markc,Int_t marks,Float_t marksize)const{
618 // Draws a cross sectional view of the TGeoPcon, Primarily for debugging.
619 // A TCanvas should exist first.
621 // TGeoPcon *p The TGeoPcon to be "drawn"
622 // Int_t fillc The fill color to be used
623 // Int_t fills The fill style to be used
624 // Int_t linec The line color to be used
625 // Int_t lines The line style to be used
626 // Int_t linew The line width to be used
627 // Int_t markc The markder color to be used
628 // Int_t marks The markder style to be used
629 // Float_t marksize The marker size
647 r[i] = p->GetRmax(i);
648 z[i+n] = p->GetZ(n-1-i);
649 r[i+n] = p->GetRmin(n-1-i);
654 line = new TPolyLine(n,z,r);
655 pts = new TPolyMarker(n,z,r);
657 line->SetFillColor(fillc);
658 line->SetFillStyle(fills);
659 line->SetLineColor(linec);
660 line->SetLineStyle(lines);
661 line->SetLineWidth(linew);
662 pts->SetMarkerColor(markc);
663 pts->SetMarkerStyle(marks);
664 pts->SetMarkerSize(marksize);
673 cout<<"Hit Return to continue"<<endl;
679 //______________________________________________________________________
680 Bool_t AliITSv11Geometry::AngleOfIntersectionWithLine(Double_t x0,Double_t y0,
681 Double_t x1,Double_t y1,
682 Double_t xc,Double_t yc,
683 Double_t rc,Double_t &t0,
685 // Computes the angles, t0 and t1 corresponding to the intersection of
686 // the line, defined by {x0,y0} {x1,y1}, and the circle, defined by
687 // its center {xc,yc} and radius r. If the line does not intersect the
688 // line, function returns kFALSE, otherwise it returns kTRUE. If the
689 // line is tangent to the circle, the angles t0 and t1 will be the same.
691 // Double_t x0 X of first point defining the line
692 // Double_t y0 Y of first point defining the line
693 // Double_t x1 X of Second point defining the line
694 // Double_t y1 Y of Second point defining the line
695 // Double_t xc X of Circle center point defining the line
696 // Double_t yc Y of Circle center point defining the line
697 // Double_t r radius of circle
699 // Double_t &t0 First angle where line intersects circle
700 // Double_t &t1 Second angle where line intersects circle
702 // kTRUE, line intersects circle, kFALSE line does not intersect circle
703 // or the line is not properly defined point {x0,y0} and {x1,y1}
704 // are the same point.
705 Double_t dx,dy,cx,cy,s2,t[4];
706 Double_t a0,b0,c0,a1,b1,c1,sinthp,sinthm,costhp,costhm;
716 if(s2==0.0) return kFALSE;
719 if(a0==0.0) return kFALSE;
720 b0 = 2.0*rc*dx*(dx*cy-cx*dy);
721 c0 = dx*dx*cy*cy-2.0*dy*dx*cy*cx+cx*cx*dy*dy-rc*rc*dy*dy;
722 c0 = 0.25*b0*b0/(a0*a0)-c0/a0;
723 if(c0<0.0) return kFALSE;
724 sinthp = -0.5*b0/a0+TMath::Sqrt(c0);
725 sinthm = -0.5*b0/a0-TMath::Sqrt(c0);
728 if(a1==0.0) return kFALSE;
729 b1 = 2.0*rc*dy*(dy*cx-dx*cy);
730 c1 = dy*dy*cx*cx-2.0*dy*dx*cy*cx+dx*dx*cy*cy-rc*rc*dx*dx;
731 c1 = 0.25*b1*b1/(a1*a1)-c1/a1;
732 if(c1<0.0) return kFALSE;
733 costhp = -0.5*b1/a1+TMath::Sqrt(c1);
734 costhm = -0.5*b1/a1-TMath::Sqrt(c1);
736 t[0] = t[1] = t[2] = t[3] = 400.;
737 a0 = TMath::ATan2(sinthp,costhp); if(a0<0.0) a0 += 2.0*TMath::Pi();
738 a1 = TMath::ATan2(sinthp,costhm); if(a1<0.0) a1 += 2.0*TMath::Pi();
739 b0 = TMath::ATan2(sinthm,costhp); if(b0<0.0) b0 += 2.0*TMath::Pi();
740 b1 = TMath::ATan2(sinthm,costhm); if(b1<0.0) b1 += 2.0*TMath::Pi();
741 x1 = xc+rc*TMath::Cos(a0);
742 y1 = yc+rc*TMath::Sin(a0);
743 s2 = dx*(y1-y0)-dy*(x1-x0);
744 if(s2*s2<DBL_EPSILON) t[0] = a0*TMath::RadToDeg();
745 x1 = xc+rc*TMath::Cos(a1);
746 y1 = yc+rc*TMath::Sin(a1);
747 s2 = dx*(y1-y0)-dy*(x1-x0);
748 if(s2*s2<DBL_EPSILON) t[1] = a1*TMath::RadToDeg();
749 x1 = xc+rc*TMath::Cos(b0);
750 y1 = yc+rc*TMath::Sin(b0);
751 s2 = dx*(y1-y0)-dy*(x1-x0);
752 if(s2*s2<DBL_EPSILON) t[2] = b0*TMath::RadToDeg();
753 x1 = xc+rc*TMath::Cos(b1);
754 y1 = yc+rc*TMath::Sin(b1);
755 s2 = dx*(y1-y0)-dy*(x1-x0);
756 if(s2*s2<DBL_EPSILON) t[3] = b1*TMath::RadToDeg();
757 for(i=0;i<4;i++)for(j=i+1;j<4;j++){
758 if(t[i]>t[j]) {t0 = t[i];t[i] = t[j];t[j] = t0;}
765 //______________________________________________________________________
766 Double_t AliITSv11Geometry::AngleForRoundedCorners0(Double_t dx,Double_t dy,
768 // Basic function used to determine the ending angle and starting angles
769 // for rounded corners given the relative distance between the centers
770 // of the circles and the difference/sum of their radii. Case 0.
772 // Double_t dx difference in x locations of the circle centers
773 // Double_t dy difference in y locations of the circle centers
774 // Double_t sdr difference or sum of the circle radii
778 // the angle in Degrees
781 b = dy*dy+dx*dx-sdr*sdr;
782 if(b<0.0) Error("AngleForRoundedCorners0",
783 "dx^2(%e)+dy^2(%e)-sdr^2(%e)=b=%e<0",dx,dy,sdr,b);
787 return TMath::ATan2(a,b)*TMath::RadToDeg();
790 //______________________________________________________________________
791 Double_t AliITSv11Geometry::AngleForRoundedCorners1(Double_t dx,Double_t dy,
793 // Basic function used to determine the ending angle and starting angles
794 // for rounded corners given the relative distance between the centers
795 // of the circles and the difference/sum of their radii. Case 1.
797 // Double_t dx difference in x locations of the circle centers
798 // Double_t dy difference in y locations of the circle centers
799 // Double_t sdr difference or sum of the circle radii
803 // the angle in Degrees
806 b = dy*dy+dx*dx-sdr*sdr;
807 if(b<0.0) Error("AngleForRoundedCorners1",
808 "dx^2(%e)+dy^2(%e)-sdr^2(%e)=b=%e<0",dx,dy,sdr,b);
812 return TMath::ATan2(a,b)*TMath::RadToDeg();
815 //----------------------------------------------------------------------
816 void AliITSv11Geometry::AnglesForRoundedCorners(Double_t x0,Double_t y0,
817 Double_t r0,Double_t x1,
818 Double_t y1,Double_t r1,
819 Double_t &t0,Double_t &t1)
821 // Function to compute the ending angle, for arc 0, and starting angle,
822 // for arc 1, such that a straight line will connect them with no
826 <img src="picts/ITS/AliITSv11Geometry_AnglesForRoundedCorners.gif">
830 // Double_t x0 X Coordinate of arc 0 center.
831 // Double_t y0 Y Coordinate of arc 0 center.
832 // Double_t r0 Radius of curvature of arc 0. For signe see figure.
833 // Double_t x1 X Coordinate of arc 1 center.
834 // Double_t y1 Y Coordinate of arc 1 center.
835 // Double_t r1 Radius of curvature of arc 1. For signe see figure.
837 // Double_t t0 Ending angle of arch 0, with respect to x axis, Degrees.
838 // Double_t t1 Starting angle of arch 1, with respect to x axis,
844 if(r0>=0.0&&r1>=0.0) { // Inside to inside ++
845 t = AngleForRoundedCorners1(x1-x0,y1-y0,r1-r0);
848 }else if(r0>=0.0&&r1<=0.0){ // Inside to Outside +-
849 r1 = -r1; // make positive
850 t = AngleForRoundedCorners0(x1-x0,y1-y0,r1+r0);
852 if(t0<0.0) t += 360.;
856 }else if(r0<=0.0&&r1>=0.0){ // Outside to Inside -+
857 r0 = - r0; // make positive
858 t = AngleForRoundedCorners1(x1-x0,y1-y0,r1+r0);
860 if(t0>180.) t0 -= 360.;
861 if(t >180.) t -= 360.;
864 }else if(r0<=0.0&&r1<=0.0) { // Outside to outside --
865 r0 = -r0; // make positive
866 r1 = -r1; // make positive
867 t = AngleForRoundedCorners0(x1-x0,y1-y0,r1-r0);
873 //----------------------------------------------------------------------
874 void AliITSv11Geometry::MakeFigure1(Double_t x0,Double_t y0,Double_t r0,
875 Double_t x1,Double_t y1,Double_t r1){
876 // Function to create the figure discribing how the function
877 // AnglesForRoundedCorners works.
880 // Double_t x0 X Coordinate of arc 0 center.
881 // Double_t y0 Y Coordinate of arc 0 center.
882 // Double_t r0 Radius of curvature of arc 0. For signe see figure.
883 // Double_t x1 X Coordinate of arc 1 center.
884 // Double_t y1 Y Coordinate of arc 1 center.
885 // Double_t r1 Radius of curvature of arc 1. For signe see figure.
890 Double_t t0[4],t1[4],xa0[4],ya0[4],xa1[4],ya1[4],ra0[4],ra1[4];
891 Double_t xmin,ymin,xmax,ymax,h;
895 ra0[j] = r0; if(j%2) ra0[j] = -r0;
896 ra1[j] = r1; if(j>1) ra1[j] = -r1;
897 AnglesForRoundedCorners(x0,y0,ra0[j],x1,y1,ra1[j],t0[j],t1[j]);
898 xa0[j] = TMath::Abs(r0)*CosD(t0[j])+x0;
899 ya0[j] = TMath::Abs(r0)*SinD(t0[j])+y0;
900 xa1[j] = TMath::Abs(r1)*CosD(t1[j])+x1;
901 ya1[j] = TMath::Abs(r1)*SinD(t1[j])+y1;
905 xmin = TMath::Min(x0 - r0,x1-r1);
906 ymin = TMath::Min(y0 - r0,y1-r1);
907 xmax = TMath::Max(x0 + r0,x1+r1);
908 ymax = TMath::Max(y0 + r0,y1+r1);
910 xmin = TMath::Min(xmin,xa0[j]);
911 xmin = TMath::Min(xmin,xa1[j]);
912 ymin = TMath::Min(ymin,ya0[j]);
913 ymin = TMath::Min(ymin,ya1[j]);
915 xmax = TMath::Max(xmax,xa0[j]);
916 xmax = TMath::Max(xmax,xa1[j]);
917 ymax = TMath::Max(ymax,ya0[j]);
918 ymax = TMath::Max(ymax,ya1[j]);
920 if(xmin<0.0) xmin *= 1.1; else xmin *= 0.9;
921 if(ymin<0.0) ymin *= 1.1; else ymin *= 0.9;
922 if(xmax<0.0) xmax *= 0.9; else xmax *= 1.1;
923 if(ymax<0.0) ymax *= 0.9; else ymax *= 1.1;
924 j = (Int_t)(500.0*(ymax-ymin)/(xmax-xmin));
925 TCanvas *can = new TCanvas("AliITSv11Geometry_AnglesForRoundedCorners",
926 "Figure for AliITSv11Geometry",500,j);
927 h = ymax-ymin; if(h<0) h = -h;
928 can->Range(xmin,ymin,xmax,ymax);
929 TArc *c0 = new TArc(x0,y0,r0);
930 TArc *c1 = new TArc(x1,y1,r1);
935 ar0[j] = new TArrow(x0,y0,xa0[j],ya0[j]);
936 ar1[j] = new TArrow(x1,y1,xa1[j],ya1[j]);
937 line[j] = new TLine(xa0[j],ya0[j],xa1[j],ya1[j]);
938 ar0[j]->SetLineColor(j+1);
939 ar0[j]->SetArrowSize(0.1*r0/h);
940 ar1[j]->SetLineColor(j+1);
941 ar1[j]->SetArrowSize(0.1*r1/h);
942 line[j]->SetLineColor(j+1);
951 TText *t = new TText();
952 t->SetTextSize(0.02);
954 sprintf(txt,"(x0=%5.2f,y0=%5.2f)",x0,y0);
955 t->DrawText(x0,y0,txt);
956 sprintf(txt,"(x1=%5.2f,y1=%5.2f)",x1,y1);
958 t->SetTextColor(j+1);
959 t->DrawText(x1,y1,txt);
960 sprintf(txt,"r0=%5.2f",ra0[j]);
961 t->DrawText(0.5*(x0+xa0[j]),0.5*(y0+ya0[j]),txt);
962 sprintf(txt,"r1=%5.2f",ra1[j]);
963 t->DrawText(0.5*(x1+xa1[j]),0.5*(y1+ya1[j]),txt);