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 **************************************************************************/
19 // General Root includes
20 #include <Riostream.h>
23 #include <TFile.h> // only required for Tracking function?
24 #include <TObjArray.h>
25 #include <TClonesArray.h>
26 #include <TLorentzVector.h>
27 #include <TObjString.h>
28 // Root Geometry includes
29 #include <TGeoManager.h>
30 #include <TGeoVolume.h>
33 #include <TGeoTube.h> // contaings TGeoTubeSeg
35 #include <TGeoCompositeShape.h>
36 #include <TGeoMatrix.h>
38 #include <TGeoMaterial.h>
39 #include <TGeoMedium.h>
40 #include "AliITSBaseGeometry.h"
41 #include "AliITSv11Geometry.h"
43 ClassImp(AliITSv11Geometry)
44 //______________________________________________________________________
45 Double_t AliITSv11Geometry::RmaxFrom2Points(TGeoPcon *p,Int_t i1,Int_t i2,Double_t z){
46 // functions Require at parts of Volume A to be already defined.
47 // Retruns the value of Rmax corresponding to point z alone the line
48 // defined by the two points p.Rmax(i1),p-GetZ(i1) and p->GetRmax(i2),
52 d0 = p->GetRmax(i1)-p->GetRmax(i2);// cout <<"L263: d0="<<d0<<endl;
53 d1 = z-p->GetZ(i2);// cout <<"L264: d1="<<d1<<endl;
54 d2 = p->GetZ(i1)-p->GetZ(i2);// cout <<"L265: d2="<<d2<<endl;
55 r = p->GetRmax(i2) + d1*d0/d2;// cout <<"L266: r="<<r<<endl;
58 //______________________________________________________________________
59 Double_t AliITSv11Geometry::RminFrom2Points(TGeoPcon *p,Int_t i1,Int_t i2,Double_t z){
60 // Retruns the value of Rmin corresponding to point z alone the line
61 // defined by the two points p->GetRmin(i1),p->GetZ(i1) and
62 // p->GetRmin(i2), p->GetZ(i2).
64 return p->GetRmin(i2)+(p->GetRmin(i1)-p->GetRmin(i2))*(z-p->GetZ(i2))/
65 (p->GetZ(i1)-p->GetZ(i2));
67 //______________________________________________________________________
68 Double_t AliITSv11Geometry::RFrom2Points(Double_t *p,Double_t *Z,Int_t i1,
70 // Retruns the value of Rmin corresponding to point z alone the line
71 // defined by the two points p->GetRmin(i1),p->GetZ(i1) and
72 // p->GetRmin(i2), p->GetZ(i2).
74 return p[i2]+(p[i1]-p[i2])*(z-Z[i2])/(Z[i1]-Z[i2]);
76 //______________________________________________________________________
77 Double_t AliITSv11Geometry::Zfrom2MinPoints(TGeoPcon *p,Int_t i1,Int_t i2,Double_t r){
78 // Retruns the value of Z corresponding to point R alone the line
79 // defined by the two points p->GetRmin(i1),p->GetZ(i1) and
80 // p->GetRmin(i2),p->GetZ(i2)
82 return p->GetZ(i2)+(p->GetZ(i1)-p->GetZ(i2))*(r-p->GetRmin(i2))/
83 (p->GetRmin(i1)-p->GetRmin(i2));
85 //______________________________________________________________________
86 Double_t AliITSv11Geometry::Zfrom2MaxPoints(TGeoPcon *p,Int_t i1,Int_t i2,Double_t r){
87 // Retruns the value of Z corresponding to point R alone the line
88 // defined by the two points p->GetRmax(i1),p->GetZ(i1) and
89 // p->GetRmax(i2),p->GetZ(i2)
91 return p->GetZ(i2)+(p->GetZ(i1)-p->GetZ(i2))*(r-p->GetRmax(i2))/
92 (p->GetRmax(i1)-p->GetRmax(i2));
94 //______________________________________________________________________
95 Double_t AliITSv11Geometry::Zfrom2Points(Double_t *Z,Double_t *p,Int_t i1,
97 // Retruns the value of Z corresponding to point R alone the line
98 // defined by the two points p->GetRmax(i1),p->GetZ(i1) and
99 // p->GetRmax(i2),p->GetZ(i2)
101 return Z[i2]+(Z[i1]-Z[i2])*(r-p[i2])/(p[i1]-p[i2]);
103 //______________________________________________________________________
104 Double_t AliITSv11Geometry::RmaxFromZpCone(TGeoPcon *p,int ip,Double_t tc,Double_t z,
106 // General SSD Outer Cone surface equation Rmax.
107 Double_t tantc = TMath::Tan(tc*TMath::DegToRad());
108 Double_t costc = TMath::Cos(tc*TMath::DegToRad());
110 return -tantc*(z-p->GetZ(ip))+p->GetRmax(ip)+th/costc;
112 //______________________________________________________________________
113 Double_t AliITSv11Geometry::RFromZpCone(Double_t *GetRmax,Double_t *GetZ,int ip,
114 Double_t tc,Double_t z,Double_t th){
115 // General SSD Outer Cone surface equation Rmax.
116 Double_t tantc = TMath::Tan(tc*TMath::DegToRad());
117 Double_t costc = TMath::Cos(tc*TMath::DegToRad());
119 return -tantc*(z-GetZ[ip])+GetRmax[ip]+th/costc;
121 //______________________________________________________________________
122 Double_t AliITSv11Geometry::RminFromZpCone(TGeoPcon *p,Int_t ip,Double_t tc,Double_t z,
124 // General SSD Inner Cone surface equation Rmin.
125 Double_t tantc = TMath::Tan(tc*TMath::DegToRad());
126 Double_t costc = TMath::Cos(tc*TMath::DegToRad());
128 return -tantc*(z-p->GetZ(ip))+p->GetRmin(ip)+th/costc;
130 //______________________________________________________________________
131 Double_t AliITSv11Geometry::ZFromRmaxpCone(TGeoPcon *p,int ip,Double_t tc,Double_t r,
133 // General SSD Outer cone Surface equation for z.
134 Double_t tantc = TMath::Tan(tc*TMath::DegToRad());
135 Double_t costc = TMath::Cos(tc*TMath::DegToRad());
137 return p->GetZ(ip)+(p->GetRmax(ip)+th/costc-r)/tantc;
139 //______________________________________________________________________
140 Double_t AliITSv11Geometry::ZFromRmaxpCone(Double_t *GetRmax,Double_t *GetZ,int ip,
141 Double_t tc,Double_t r,Double_t th){
142 // General SSD Outer cone Surface equation for z.
143 Double_t tantc = TMath::Tan(tc*TMath::DegToRad());
144 Double_t costc = TMath::Cos(tc*TMath::DegToRad());
146 return GetZ[ip]+(GetRmax[ip]+th/costc-r)/tantc;
148 //______________________________________________________________________
149 Double_t AliITSv11Geometry::ZFromRminpCone(TGeoPcon *p,int ip,Double_t tc,Double_t r,
151 // General SSD Inner cone Surface equation for z.
152 Double_t tantc = TMath::Tan(tc*TMath::DegToRad());
153 Double_t costc = TMath::Cos(tc*TMath::DegToRad());
155 return p->GetZ(ip)+(p->GetRmin(ip)+th/costc-r)/tantc;
157 //______________________________________________________________________
158 void AliITSv11Geometry::RadiusOfCurvature(Double_t rc,Double_t theta0,Double_t z0,
159 Double_t r0,Double_t theta1,Double_t &z1,
161 // Given a initial point z0,r0, the initial angle theta0, and the radius
162 // of curvature, returns the point z1, r1 at the angle theta1. Theta
163 // measured from the r axis in the clock wise direction [degrees].
164 Double_t sin0 = TMath::Sin(theta0*TMath::DegToRad());
165 Double_t cos0 = TMath::Cos(theta0*TMath::DegToRad());
166 Double_t sin1 = TMath::Sin(theta1*TMath::DegToRad());
167 Double_t cos1 = TMath::Cos(theta1*TMath::DegToRad());
169 z1 = rc*(sin1-sin0)+z0;
170 r1 = rc*(cos1-cos0)+r0;
173 //______________________________________________________________________
174 void AliITSv11Geometry::InsidePoint(TGeoPcon *p,Int_t i1,Int_t i2,Int_t i3,
175 Double_t c,TGeoPcon *q,Int_t j1,Bool_t max){
176 // Given two lines defined by the points i1, i2,i3 in the TGeoPcon
177 // class p that intersect at point p->GetZ(i2) return the point z,r
178 // that is Cthick away in the TGeoPcon class q. If points i1=i2
179 // and max == kTRUE, then p->GetRmin(i1) and p->GetRmax(i2) are used.
180 // if points i2=i3 and max=kTRUE then points p->GetRmax(i2) and
181 // p->GetRmin(i3) are used. If i2=i3 and max=kFALSE, then p->GetRmin(i2)
182 // and p->GetRmax(i3) are used.
184 // TGeoPcon *p Class where points i1, i2, and i3 are taken from
185 // Int_t i1 First point in class p
186 // Int_t i2 Second point in class p
187 // Int_t i3 Third point in class p
188 // Double_t c Distance inside the outer surface/inner suface
189 // that the point j1 is to be computed for.
190 // TGeoPcon *q Pointer to class for results to be put into.
191 // Int_t j1 Point in class q where data is to be stored.
192 // Bool_t max if kTRUE, then a Rmax value is computed,
193 // else a Rmin valule is computed.
195 // TGeoPcon *q Pointer to class for results to be put into.
198 Double_t x0,y0,x1,y1,x2,y2,x,y;
201 c = -c; //cout <<"L394 c="<<c<<endl;
203 if(i1==i2) y0 = p->GetRmin(i1); //cout <<"L396 y0="<<y0<<endl;
204 y1 = p->GetRmax(i2); //cout <<"L397 y1="<<y1<<endl;
205 y2 = p->GetRmax(i3); //cout <<"L398 y2="<<y2<<endl;
206 if(i2==i3) y2 = p->GetRmin(i3); //cout <<"L399 y2="<<y2<<endl;
208 y0 = p->GetRmin(i1); //cout <<"L401 y0="<<y0<<endl;
209 y1 = p->GetRmin(i2); //cout <<"L402 y1="<<y1<<endl;
211 if(i2==i3) y2 = p->GetRmax(i3); //cout <<"L404 y2="<<y2<<endl;
213 x0 = p->GetZ(i1); //cout <<"L406 x0="<<x0<<endl;
214 x1 = p->GetZ(i2); //cout <<"L407 x1="<<x1<<endl;
215 x2 = p->GetZ(i3); //cout <<"L408 x2="<<x2<<endl;
217 InsidePoint(x0,y0,x1,y1,x2,y2,c,x,y);
219 if(max) q->Rmax(j1) = y;
220 else q->Rmin(j1) = y;
223 //----------------------------------------------------------------------
224 void AliITSv11Geometry::InsidePoint(Double_t x0,Double_t y0,Double_t x1,Double_t y1,
225 Double_t x2,Double_t y2,Double_t c,
226 Double_t &x,Double_t &y){
227 // Given two intersecting lines defined by the points (x0,y0), (x1,y1) and
228 // (x1,y1), (x1,y2) {intersecting at (x1,y1)} the point (x,y) a distance
229 // c away is returned such that two lines a distance c away from the
230 // lines defined above intersect at (x,y).
232 // Double_t x0 X point on the first intersecting sets of lines
233 // Double_t y0 Y point on the first intersecting sets of lines
234 // Double_t x1 X point on the first/second intersecting sets of lines
235 // Double_t y1 Y point on the first/second intersecting sets of lines
236 // Double_t x2 X point on the second intersecting sets of lines
237 // Double_t y2 Y point on the second intersecting sets of lines
238 // Double_t c Distance the two sets of lines are from each other
240 // Double_t x X point for the intersecting sets of parellel lines
241 // Double_t y Y point for the intersecting sets of parellel lines
244 Double_t dx01,dx12,dy01,dy12,R01,R12,m;
245 dx01 = x0-x1; //cout <<"L410 dx01="<<dx01<<endl;
246 dx12 = x1-x2; //cout <<"L411 dx12="<<dx12<<endl;
247 dy01 = y0-y1; //cout <<"L412 dy01="<<dy01<<endl;
248 dy12 = y1-y2; //cout <<"L413 dy12="<<dy12<<endl;
249 R01 = TMath::Sqrt(dy01*dy01+dx01*dx01); //cout <<"L414 R01="<<R01<<endl;
250 R12 = TMath::Sqrt(dy12*dy12+dx12*dx12); //cout <<"L415 R12="<<R12<<endl;
251 m = dx12*dy01-dy12*dx01;
252 if(m*m<DBL_EPSILON){ // m == n
253 if(dy01==0.0){ // line are =
254 x = x1+c; //cout <<"L419 x="<<x<<endl;
255 y = y1; //cout <<"L420 y="<<y<<endl;
261 }else{ // dx01!=0 and dy01 !=0.
262 x = x1-0.5*c*R01/dy01; //cout <<"L434 x="<<x<<endl;
263 y = y1+0.5*c*R01/dx01; //cout <<"L435 y="<<y<<endl;
267 x = x1-c*(dx12*R01-dx01*R12)/m; //cout <<"L442 x="<<x<<endl;
268 y = y1-c*(dy12*R01-dy01*R12)/m; //cout <<"L443 y="<<y<<endl;
269 //cout <<"=============================================="<<endl;
272 //----------------------------------------------------------------------
273 void AliITSv11Geometry:: printArb8(TGeoArb8 *A){
275 cout << A->GetName() << ":";
276 for(Int_t iii=0;iii<8;iii+=2){
277 cout <<"("<<A->GetVertices()[iii]<<","
278 <<A->GetVertices()[iii+1]<<","<<-A->GetDz()<<")";
280 for(Int_t iii=8;iii<16;iii+=2){
281 cout <<"("<<A->GetVertices()[iii]<<","
282 <<A->GetVertices()[iii+1]<<","<<A->GetDz()<<")";
287 //----------------------------------------------------------------------
288 void AliITSv11Geometry:: printPcon(TGeoPcon *A){
289 if(GetDebug()) return;
290 cout << A->GetName() << ": N=" << A->GetNz() << " Phi1=" << A->GetPhi1()
291 << ", Dphi=" << A->GetDphi() << endl;
292 cout << "i\t Z \t Rmin \t Rmax" << endl;
293 for(Int_t iii=0;iii<A->GetNz();iii++){
294 cout << iii << "\t" << A->GetZ(iii) << "\t" << A->GetRmin(iii)
295 << "\t" << A->GetRmax(iii) << endl;
298 //----------------------------------------------------------------------
299 void AliITSv11Geometry::printTube(TGeoTube *A){
300 if(GetDebug()) return;
301 cout << A->GetName() <<": Rmin="<<A->GetRmin()
302 <<" Rmax=" <<A->GetRmax()<<" Dz="<<A->GetDz()<<endl;
304 //----------------------------------------------------------------------
305 void AliITSv11Geometry::printTubeSeg(TGeoTubeSeg *A){
306 if(GetDebug()) return;
307 cout << A->GetName() <<": Phi1="<<A->GetPhi1()<<
308 " Phi2="<<A->GetPhi2()<<" Rmin="<<A->GetRmin()
309 <<" Rmax=" <<A->GetRmax()<<" Dz="<<A->GetDz()<<endl;
311 //----------------------------------------------------------------------
312 void AliITSv11Geometry::printConeSeg(TGeoConeSeg *A){
313 if(GetDebug()) return;
314 cout << A->GetName() <<": Phi1="<<A->GetPhi1()<<
315 " Phi2="<<A->GetPhi2()<<" Rmin1="<<A->GetRmin1()
316 <<" Rmax1=" <<A->GetRmax1()<<" Rmin2="<<A->GetRmin2()
317 <<" Rmax2=" <<A->GetRmax2()<<" Dz="<<A->GetDz()<<endl;
319 //----------------------------------------------------------------------
320 void AliITSv11Geometry::printBBox(TGeoBBox *A){
321 if(GetDebug()) return;
322 cout << A->GetName() <<": Dx="<<A->GetDX()<<
323 " Dy="<<A->GetDY()<<" Dz="<<A->GetDZ() <<endl;