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>
36 #include <TGeoTube.h> // contaings TGeoTubeSeg
38 #include <TPolyMarker.h>
39 #include <TPolyLine.h>
40 #include "AliITSv11Geometry.h"
42 ClassImp(AliITSv11Geometry)
43 //______________________________________________________________________
44 Double_t AliITSv11Geometry::Yfrom2Points(Double_t x0,Double_t y0,
45 Double_t x1,Double_t y1,
47 // Given the two points (x0,y0) and (x1,y1) and the location x, returns
48 // the value y corresponding to that point x on the line defined by the
51 // Double_t x0 The first x value defining the line
52 // Double_t y0 The first y value defining the line
53 // Double_t x1 The second x value defining the line
54 // Double_t y1 The second y value defining the line
55 // Double_t x The x value for which the y value is wanted.
59 // The value y corresponding to the point x on the line defined by
60 // the two points (x0,y0) and (x1,y1).
62 if(x0==x1 && y0==y1) {
63 printf("Error: AliITSv11Geometry::Yfrom2Ponts The two points are "
64 "the same (%e,%e) and (%e,%e)",x0,y0,x1,y1);
68 printf("Warning: AliITSv11Geometry::Yfrom2Points x0=%e == x1=%e. "
69 "line vertical ""returning mean y",x0,x1);
72 Double_t m = (y0-y1)/(x0-x1);
75 //______________________________________________________________________
76 Double_t AliITSv11Geometry::Xfrom2Points(Double_t x0,Double_t y0,
77 Double_t x1,Double_t y1,
79 // Given the two points (x0,y0) and (x1,y1) and the location y, returns
80 // the value x corresponding to that point y on the line defined by the
83 // Double_t x0 The first x value defining the line
84 // Double_t y0 The first y value defining the line
85 // Double_t x1 The second x value defining the line
86 // Double_t y1 The second y value defining the line
87 // Double_t y The y value for which the x value is wanted.
91 // The value x corresponding to the point y on the line defined by
92 // the two points (x0,y0) and (x1,y1).
94 if(x0==x1 && y0==y1) {
95 printf("Error: AliITSv11Geometry::Yfrom2Ponts The two points are "
96 "the same (%e,%e) and (%e,%e)",x0,y0,x1,y1);
100 printf("Warrning: AliITSv11Geometry::Yfrom2Points y0=%e == y1=%e. "
101 "line horizontal returning mean x",y0,y1);
104 Double_t m = (x0-x1)/(y0-y1);
107 //______________________________________________________________________
108 Double_t AliITSv11Geometry::RmaxFrom2Points(const TGeoPcon *p,Int_t i1,
109 Int_t i2,Double_t z){
110 // functions Require at parts of Volume A to be already defined.
111 // Retruns the value of Rmax corresponding to point z alone the line
112 // defined by the two points p.Rmax(i1),p-GetZ(i1) and p->GetRmax(i2),
115 // TGeoPcon *p The Polycone where the two points come from
118 // Double_t z The value of z for which Rmax is to be found
122 // Double_t Rmax the value corresponding to z
125 d0 = p->GetRmax(i1)-p->GetRmax(i2);// cout <<"L263: d0="<<d0<<endl;
126 d1 = z-p->GetZ(i2);// cout <<"L264: d1="<<d1<<endl;
127 d2 = p->GetZ(i1)-p->GetZ(i2);// cout <<"L265: d2="<<d2<<endl;
128 r = p->GetRmax(i2) + d1*d0/d2;// cout <<"L266: r="<<r<<endl;
131 //______________________________________________________________________
132 Double_t AliITSv11Geometry::RminFrom2Points(const TGeoPcon *p,Int_t i1,
133 Int_t i2,Double_t z){
134 // Retruns the value of Rmin corresponding to point z alone the line
135 // defined by the two points p->GetRmin(i1),p->GetZ(i1) and
136 // p->GetRmin(i2), p->GetZ(i2).
138 // TGeoPcon *p The Polycone where the two points come from
141 // Double_t z The value of z for which Rmax is to be found
145 // Double_t Rmax the value corresponding to z
147 return p->GetRmin(i2)+(p->GetRmin(i1)-p->GetRmin(i2))*(z-p->GetZ(i2))/
148 (p->GetZ(i1)-p->GetZ(i2));
150 //______________________________________________________________________
151 Double_t AliITSv11Geometry::RFrom2Points(const Double_t *p,const Double_t *az,
152 Int_t i1,Int_t i2,Double_t z){
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 // Double_t az Array of z values
158 // Double_t r Array of r values
159 // Int_t i1 First Point in arrays
160 // Int_t i2 Second Point in arrays
161 // Double_t z Value z at which r is to be found
165 // The value r corresponding to z and the line defined by the two points
167 return p[i2]+(p[i1]-p[i2])*(z-az[i2])/(az[i1]-az[i2]);
169 //______________________________________________________________________
170 Double_t AliITSv11Geometry::Zfrom2MinPoints(const TGeoPcon *p,Int_t i1,
171 Int_t i2,Double_t r){
172 // Retruns the value of Z corresponding to point R alone the line
173 // defined by the two points p->GetRmin(i1),p->GetZ(i1) and
174 // p->GetRmin(i2),p->GetZ(i2)
176 // TGeoPcon *p The Poly cone where the two points come from.
177 // Int_t i1 First Point in arrays
178 // Int_t i2 Second Point in arrays
179 // Double_t r Value r min at which z is to be found
183 // The value z corresponding to r min and the line defined by
186 return p->GetZ(i2)+(p->GetZ(i1)-p->GetZ(i2))*(r-p->GetRmin(i2))/
187 (p->GetRmin(i1)-p->GetRmin(i2));
189 //______________________________________________________________________
190 Double_t AliITSv11Geometry::Zfrom2MaxPoints(const TGeoPcon *p,Int_t i1,
191 Int_t i2,Double_t r){
192 // Retruns the value of Z corresponding to point R alone the line
193 // defined by the two points p->GetRmax(i1),p->GetZ(i1) and
194 // p->GetRmax(i2),p->GetZ(i2)
196 // TGeoPcon *p The Poly cone where the two points come from.
197 // Int_t i1 First Point in arrays
198 // Int_t i2 Second Point in arrays
199 // Double_t r Value r max at which z is to be found
203 // The value z corresponding to r max and the line defined by
206 return p->GetZ(i2)+(p->GetZ(i1)-p->GetZ(i2))*(r-p->GetRmax(i2))/
207 (p->GetRmax(i1)-p->GetRmax(i2));
209 //______________________________________________________________________
210 Double_t AliITSv11Geometry::Zfrom2Points(const Double_t *z,const Double_t *ar,
211 Int_t i1,Int_t i2,Double_t r){
212 // Retruns the value of z corresponding to point R alone the line
213 // defined by the two points p->GetRmax(i1),p->GetZ(i1) and
214 // p->GetRmax(i2),p->GetZ(i2)
216 // Double_t z Array of z values
217 // Double_t ar Array of r values
218 // Int_t i1 First Point in arrays
219 // Int_t i2 Second Point in arrays
220 // Double_t r Value r at which z is to be found
224 // The value z corresponding to r and the line defined by the two points
226 return z[i2]+(z[i1]-z[i2])*(r-ar[i2])/(ar[i1]-ar[i2]);
228 //______________________________________________________________________
229 Double_t AliITSv11Geometry::RmaxFromZpCone(const TGeoPcon *p,int ip,
230 Double_t tc,Double_t z,
232 // General Outer Cone surface equation Rmax.
234 // TGeoPcon *p The poly cone where the initial point comes from
235 // Int_t ip The index in p to get the point location
236 // Double_t tc The angle of that part of the cone is at
237 // Double_t z The value of z to compute Rmax from
238 // Double_t th The perpendicular distance the parralell line is
239 // from the point ip.
243 // The value Rmax correstponding to the line at angle th, offeset by
244 // th, and the point p->GetZ/Rmin[ip] at the location z.
245 Double_t tantc = TanD(tc);
246 Double_t costc = CosD(tc);
248 return -tantc*(z-p->GetZ(ip))+p->GetRmax(ip)+th/costc;
250 //______________________________________________________________________
251 Double_t AliITSv11Geometry::RFromZpCone(const Double_t *ar,
252 const Double_t *az,int ip,
253 Double_t tc,Double_t z,
255 // General Cone surface equation R(z).
257 // Double_t ar The array of R values
258 // Double_t az The array of Z values
259 // Int_t ip The index in p to get the point location
260 // Double_t tc The angle of that part of the cone is at
261 // Double_t z The value of z to compute R from
262 // Double_t th The perpendicular distance the parralell line is
263 // from the point ip.
267 // The value R correstponding to the line at angle th, offeset by
268 // th, and the point p->GetZ/Rmax[ip] at the locatin z.
269 Double_t tantc = TanD(tc);
270 Double_t costc = CosD(tc);
272 return -tantc*(z-az[ip])+ar[ip]+th/costc;
274 //______________________________________________________________________
275 Double_t AliITSv11Geometry::RminFromZpCone(const TGeoPcon *p,Int_t ip,
276 Double_t tc,Double_t z,
278 // General Inner Cone surface equation Rmin.
280 // TGeoPcon *p The poly cone where the initial point comes from
281 // Int_t ip The index in p to get the point location
282 // Double_t tc The angle of that part of the cone is at
283 // Double_t z The value of z to compute Rmin from
284 // Double_t th The perpendicular distance the parralell line is
285 // from the point ip.
289 // The value Rmin correstponding to the line at angle th, offeset by
290 // th, and the point p->GetZ/Rmin[ip] at the location z.
291 Double_t tantc = TanD(tc);
292 Double_t costc = CosD(tc);
294 return -tantc*(z-p->GetZ(ip))+p->GetRmin(ip)+th/costc;
296 //______________________________________________________________________
297 Double_t AliITSv11Geometry::ZFromRmaxpCone(const TGeoPcon *p,int ip,
298 Double_t tc,Double_t r,
300 // General Outer cone Surface equation for z.
302 // TGeoPcon *p The poly cone where the initial point comes from
303 // Int_t ip The index in p to get the point location
304 // Double_t tc The angle of that part of the cone is at
305 // Double_t r The value of Rmax to compute z from
306 // Double_t th The perpendicular distance the parralell line is
307 // from the point ip.
311 // The value Z correstponding to the line at angle th, offeset by
312 // th, and the point p->GetZ/Rmax[ip] at the location r.
313 Double_t tantc = TanD(tc);
314 Double_t costc = CosD(tc);
316 return p->GetZ(ip)+(p->GetRmax(ip)+th/costc-r)/tantc;
318 //______________________________________________________________________
319 Double_t AliITSv11Geometry::ZFromRmaxpCone(const Double_t *ar,
320 const Double_t *az,int ip,
321 Double_t tc,Double_t r,
323 // General Outer cone Surface equation for z.
325 // Double_t ar The array of R values
326 // Double_t az The array of Z values
327 // Int_t ip The index in p to get the point location
328 // Double_t tc The angle of that part of the cone is at
329 // Double_t r The value of Rmax to compute z from
330 // Double_t th The perpendicular distance the parralell line is
331 // from the point ip.
335 // The value Z correstponding to the line at angle th, offeset by
336 // th, and the point p->GetZ/Rmax[ip] at the locatin r.
337 Double_t tantc = TanD(tc);
338 Double_t costc = CosD(tc);
340 return az[ip]+(ar[ip]+th/costc-r)/tantc;
342 //______________________________________________________________________
343 Double_t AliITSv11Geometry::ZFromRminpCone(const TGeoPcon *p,int ip,
344 Double_t tc,Double_t r,
346 // General Inner cone Surface equation for z.
348 // TGeoPcon *p The poly cone where the initial point comes from
349 // Int_t ip The index in p to get the point location
350 // Double_t tc The angle of that part of the cone is at
351 // Double_t r The value of Rmin to compute z from
352 // Double_t th The perpendicular distance the parralell line is
353 // from the point ip.
357 // The value Z correstponding to the line at angle th, offeset by
358 // th, and the point p->GetZ/Rmin[ip] at the location r.
359 Double_t tantc = TanD(tc);
360 Double_t costc = CosD(tc);
362 return p->GetZ(ip)+(p->GetRmin(ip)+th/costc-r)/tantc;
364 //______________________________________________________________________
365 void AliITSv11Geometry::RadiusOfCurvature(Double_t rc,Double_t theta0,
366 Double_t z0,Double_t r0,
367 Double_t theta1,Double_t &z1,
369 // Given a initial point z0,r0, the initial angle theta0, and the radius
370 // of curvature, returns the point z1, r1 at the angle theta1. Theta
371 // measured from the r axis in the clock wise direction [degrees].
373 // Double_t rc The radius of curvature
374 // Double_t theta0 The starting angle (degrees)
375 // Double_t z0 The value of z at theta0
376 // Double_t r0 The value of r at theta0
377 // Double_t theta1 The ending angle (degrees)
379 // Double_t &z1 The value of z at theta1
380 // Double_t &r1 The value of r at theta1
384 z1 = rc*(SinD(theta1)-SinD(theta0))+z0;
385 r1 = rc*(CosD(theta1)-CosD(theta0))+r0;
388 //______________________________________________________________________
389 void AliITSv11Geometry::InsidePoint(const TGeoPcon *p,Int_t i1,Int_t i2,
390 Int_t i3,Double_t c,TGeoPcon *q,Int_t j1,
392 // Given two lines defined by the points i1, i2,i3 in the TGeoPcon
393 // class p that intersect at point p->GetZ(i2) return the point z,r
394 // that is Cthick away in the TGeoPcon class q. If points i1=i2
395 // and max == kTRUE, then p->GetRmin(i1) and p->GetRmax(i2) are used.
396 // if points i2=i3 and max=kTRUE then points p->GetRmax(i2) and
397 // p->GetRmin(i3) are used. If i2=i3 and max=kFALSE, then p->GetRmin(i2)
398 // and p->GetRmax(i3) are used.
400 // TGeoPcon *p Class where points i1, i2, and i3 are taken from
401 // Int_t i1 First point in class p
402 // Int_t i2 Second point in class p
403 // Int_t i3 Third point in class p
404 // Double_t c Distance inside the outer surface/inner suface
405 // that the point j1 is to be computed for.
406 // TGeoPcon *q Pointer to class for results to be put into.
407 // Int_t j1 Point in class q where data is to be stored.
408 // Bool_t max if kTRUE, then a Rmax value is computed,
409 // else a Rmin valule is computed.
411 // TGeoPcon *q Pointer to class for results to be put into.
414 Double_t x0,y0,x1,y1,x2,y2,x,y;
417 c = -c; //cout <<"L394 c="<<c<<endl;
419 if(i1==i2) y0 = p->GetRmin(i1); //cout <<"L396 y0="<<y0<<endl;
420 y1 = p->GetRmax(i2); //cout <<"L397 y1="<<y1<<endl;
421 y2 = p->GetRmax(i3); //cout <<"L398 y2="<<y2<<endl;
422 if(i2==i3) y2 = p->GetRmin(i3); //cout <<"L399 y2="<<y2<<endl;
424 y0 = p->GetRmin(i1); //cout <<"L401 y0="<<y0<<endl;
425 y1 = p->GetRmin(i2); //cout <<"L402 y1="<<y1<<endl;
427 if(i2==i3) y2 = p->GetRmax(i3); //cout <<"L404 y2="<<y2<<endl;
429 x0 = p->GetZ(i1); //cout <<"L406 x0="<<x0<<endl;
430 x1 = p->GetZ(i2); //cout <<"L407 x1="<<x1<<endl;
431 x2 = p->GetZ(i3); //cout <<"L408 x2="<<x2<<endl;
433 InsidePoint(x0,y0,x1,y1,x2,y2,c,x,y);
435 if(max) q->Rmax(j1) = y;
436 else q->Rmin(j1) = y;
439 //----------------------------------------------------------------------
440 void AliITSv11Geometry::InsidePoint(Double_t x0,Double_t y0,
441 Double_t x1,Double_t y1,
442 Double_t x2,Double_t y2,Double_t c,
443 Double_t &x,Double_t &y){
444 // Given two intersecting lines defined by the points (x0,y0), (x1,y1) and
445 // (x1,y1), (x1,y2) {intersecting at (x1,y1)} the point (x,y) a distance
446 // c away is returned such that two lines a distance c away from the
447 // lines defined above intersect at (x,y).
449 // Double_t x0 X point on the first intersecting sets of lines
450 // Double_t y0 Y point on the first intersecting sets of lines
451 // Double_t x1 X point on the first/second intersecting sets of lines
452 // Double_t y1 Y point on the first/second intersecting sets of lines
453 // Double_t x2 X point on the second intersecting sets of lines
454 // Double_t y2 Y point on the second intersecting sets of lines
455 // Double_t c Distance the two sets of lines are from each other
457 // Double_t x X point for the intersecting sets of parellel lines
458 // Double_t y Y point for the intersecting sets of parellel lines
461 Double_t dx01,dx12,dy01,dy12,r01,r12,m;
462 dx01 = x0-x1; //cout <<"L410 dx01="<<dx01<<endl;
463 dx12 = x1-x2; //cout <<"L411 dx12="<<dx12<<endl;
464 dy01 = y0-y1; //cout <<"L412 dy01="<<dy01<<endl;
465 dy12 = y1-y2; //cout <<"L413 dy12="<<dy12<<endl;
466 r01 = TMath::Sqrt(dy01*dy01+dx01*dx01); //cout <<"L414 r01="<<r01<<endl;
467 r12 = TMath::Sqrt(dy12*dy12+dx12*dx12); //cout <<"L415 r12="<<r12<<endl;
468 m = dx12*dy01-dy12*dx01;
469 if(m*m<DBL_EPSILON){ // m == n
470 if(dy01==0.0){ // line are =
471 x = x1+c; //cout <<"L419 x="<<x<<endl;
472 y = y1; //cout <<"L420 y="<<y<<endl;
478 }else{ // dx01!=0 and dy01 !=0.
479 x = x1-0.5*c*r01/dy01; //cout <<"L434 x="<<x<<endl;
480 y = y1+0.5*c*r01/dx01; //cout <<"L435 y="<<y<<endl;
484 x = x1-c*(dx12*r01-dx01*r12)/m; //cout <<"L442 x="<<x<<endl;
485 y = y1-c*(dy12*r01-dy01*r12)/m; //cout <<"L443 y="<<y<<endl;
486 //cout <<"=============================================="<<endl;
489 //----------------------------------------------------------------------
490 void AliITSv11Geometry:: PrintArb8(const TGeoArb8 *a)const{
491 // Prints out the content of the TGeoArb8. Usefull for debugging.
500 printf("%s",a->GetName());
505 //----------------------------------------------------------------------
506 void AliITSv11Geometry:: PrintPcon(const TGeoPcon *a)const{
507 // Prints out the content of the TGeoPcon. Usefull for debugging.
515 if(GetDebug()) return;
516 cout << a->GetName() << ": N=" << a->GetNz() << " Phi1=" << a->GetPhi1()
517 << ", Dphi=" << a->GetDphi() << endl;
518 cout << "i\t Z \t Rmin \t Rmax" << endl;
519 for(Int_t iii=0;iii<a->GetNz();iii++){
520 cout << iii << "\t" << a->GetZ(iii) << "\t" << a->GetRmin(iii)
521 << "\t" << a->GetRmax(iii) << endl;
525 //----------------------------------------------------------------------
526 void AliITSv11Geometry::PrintTube(const TGeoTube *a)const{
527 // Prints out the content of the TGeoTube. Usefull for debugging.
535 if(GetDebug()) return;
536 cout << a->GetName() <<": Rmin="<<a->GetRmin()
537 <<" Rmax=" <<a->GetRmax()<<" Dz="<<a->GetDz()<<endl;
540 //----------------------------------------------------------------------
541 void AliITSv11Geometry::PrintTubeSeg(const TGeoTubeSeg *a)const{
542 // Prints out the content of the TGeoTubeSeg. Usefull for debugging.
550 if(GetDebug()) return;
551 cout << a->GetName() <<": Phi1="<<a->GetPhi1()<<
552 " Phi2="<<a->GetPhi2()<<" Rmin="<<a->GetRmin()
553 <<" Rmax=" <<a->GetRmax()<<" Dz="<<a->GetDz()<<endl;
556 //----------------------------------------------------------------------
557 void AliITSv11Geometry::PrintConeSeg(const TGeoConeSeg *a)const{
558 // Prints out the content of the TGeoConeSeg. Usefull for debugging.
566 if(GetDebug()) return;
567 cout << a->GetName() <<": Phi1="<<a->GetPhi1()<<
568 " Phi2="<<a->GetPhi2()<<" Rmin1="<<a->GetRmin1()
569 <<" Rmax1=" <<a->GetRmax1()<<" Rmin2="<<a->GetRmin2()
570 <<" Rmax2=" <<a->GetRmax2()<<" Dz="<<a->GetDz()<<endl;
573 //----------------------------------------------------------------------
574 void AliITSv11Geometry::PrintBBox(const TGeoBBox *a)const{
575 // Prints out the content of the TGeoBBox. Usefull for debugging.
583 if(GetDebug()) return;
584 cout << a->GetName() <<": Dx="<<a->GetDX()<<
585 " Dy="<<a->GetDY()<<" Dz="<<a->GetDZ() <<endl;
588 //---------------------------------------------------------------------
589 void AliITSv11Geometry::DrawCrossSection(const TGeoPcon *p,
590 Int_t fillc,Int_t fills,
591 Int_t linec,Int_t lines,Int_t linew,
592 Int_t markc,Int_t marks,Float_t marksize)const{
593 // Draws a cross sectional view of the TGeoPcon, Primarily for debugging.
594 // A TCanvas should exist first.
596 // TGeoPcon *p The TGeoPcon to be "drawn"
597 // Int_t fillc The fill color to be used
598 // Int_t fills The fill style to be used
599 // Int_t linec The line color to be used
600 // Int_t lines The line style to be used
601 // Int_t linew The line width to be used
602 // Int_t markc The markder color to be used
603 // Int_t marks The markder style to be used
604 // Float_t marksize The marker size
622 r[i] = p->GetRmax(i);
623 z[i+n] = p->GetZ(n-1-i);
624 r[i+n] = p->GetRmin(n-1-i);
629 line = new TPolyLine(n,z,r);
630 pts = new TPolyMarker(n,z,r);
632 line->SetFillColor(fillc);
633 line->SetFillStyle(fills);
634 line->SetLineColor(linec);
635 line->SetLineStyle(lines);
636 line->SetLineWidth(linew);
637 pts->SetMarkerColor(markc);
638 pts->SetMarkerStyle(marks);
639 pts->SetMarkerSize(marksize);
648 cout<<"Hit Return to continue"<<endl;
654 //----------------------------------------------------------------------