]>
Commit | Line | Data |
---|---|---|
d3c7bfac | 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 | **************************************************************************/ | |
15 | ||
16 | /* | |
17 | $Log$ | |
a6a9820c | 18 | Revision 1.2 2006/02/28 10:38:00 decaro |
19 | AliTOFGeometry::fAngles, AliTOFGeometry::fHeights, AliTOFGeometry::fDistances arrays: dimension definition in the right location | |
20 | ||
4402e7cb | 21 | Revision 1.1 2005/12/15 08:55:33 decaro |
22 | New TOF geometry description (V5) -G. Cara Romeo and A. De Caro | |
23 | ||
d3c7bfac | 24 | Revision 0.1 2005/07/19 A. De Caro |
25 | Modify Global methods IsInsideThePad & DistanceToPad | |
26 | according to the PPR TOF geometry | |
27 | Implement Global methods GetPadDx & GetPadDy & GetPadDz | |
28 | Modify Global methods GetDetID & GetPlate & GetSector & | |
29 | GetStrip & GetPadX & GetPadZ | |
30 | according to the PPR TOF geometry | |
31 | Modify Global methods GetPos & GetX & GetY & GetZ | |
32 | according to the PPR TOF geometry | |
33 | */ | |
34 | ||
35 | #include <stdlib.h> | |
36 | #include <Riostream.h> | |
37 | /////////////////////////////////////////////////////////////////////////////// | |
38 | // // | |
39 | // TOF Geometry class (PPR version) // | |
40 | // // | |
41 | /////////////////////////////////////////////////////////////////////////////// | |
42 | ||
43 | #include "AliLog.h" | |
44 | #include "AliConst.h" | |
45 | ||
46 | #include "AliTOFGeometry.h" | |
47 | #include "AliTOFGeometryV4.h" | |
48 | ||
49 | ClassImp(AliTOFGeometryV4) | |
50 | ||
51 | const Int_t AliTOFGeometryV4::kNStripC = 20; // number of strips in C type module | |
d3c7bfac | 52 | |
53 | const Float_t AliTOFGeometryV4::fgkZlenA = 106.0; // length (cm) of the A module | |
54 | const Float_t AliTOFGeometryV4::fgkZlenB = 141.0; // length (cm) of the B module | |
55 | const Float_t AliTOFGeometryV4::fgkZlenC = 177.5; // length (cm) of the C module | |
56 | const Float_t AliTOFGeometryV4::fgkMaxhZtof = 371.5; // Max half z-size of TOF (cm) | |
d3c7bfac | 57 | |
58 | const Float_t AliTOFGeometryV4::fgkDeadBndX = 1.0; // Dead Boundaries of a Strip along X direction (length) (cm) | |
59 | const Float_t AliTOFGeometryV4::fgkDeadBndZ = 1.5; // Dead Boundaries of a Strip along Z direction (width) (cm) | |
60 | const Float_t AliTOFGeometryV4::fgkOverSpc = 15.3; // Space available for sensitive layers in radial direction (cm) | |
61 | ||
62 | const Float_t AliTOFGeometryV4::fgkDprecMin = 0.0000075;//num.prec.tolerance on Thmin | |
63 | const Float_t AliTOFGeometryV4::fgkDprecMax = 0.0000100;//num.prec.tolerance on Thma | |
64 | const Float_t AliTOFGeometryV4::fgkDprecCen = 0.0000005;//num.prec.tolerance on <Theta> | |
65 | ||
66 | const Float_t AliTOFGeometryV4::fgkxTOF = 371.; // Inner radius of the TOF for Reconstruction (cm) | |
67 | const Float_t AliTOFGeometryV4::fgkRmin = 370.; // Inner radius of the TOF (cm) | |
68 | const Float_t AliTOFGeometryV4::fgkRmax = 399.; // Outer radius of the TOF (cm) | |
69 | ||
70 | //_____________________________________________________________________________ | |
71 | AliTOFGeometryV4::AliTOFGeometryV4() | |
72 | :AliTOFGeometry() | |
73 | { | |
74 | // | |
75 | // AliTOFGeometryV4 default constructor | |
76 | // | |
77 | ||
78 | AliTOFGeometry::kNStripC = kNStripC; // number of strips in C type module | |
d3c7bfac | 79 | |
80 | AliTOFGeometry::kZlenA = fgkZlenA; // length (cm) of the A module | |
81 | AliTOFGeometry::kZlenB = fgkZlenB; // length (cm) of the B module | |
82 | AliTOFGeometry::kZlenC = fgkZlenC; // length (cm) of the C module | |
83 | AliTOFGeometry::kMaxhZtof = fgkMaxhZtof; // Max half z-size of TOF (cm) | |
d3c7bfac | 84 | |
85 | AliTOFGeometry::fgkxTOF = fgkxTOF; // Inner radius of the TOF for Reconstruction (cm) | |
86 | AliTOFGeometry::fgkRmin = fgkRmin; // Inner radius of the TOF (cm) | |
87 | AliTOFGeometry::fgkRmax = fgkRmax; // Outer radius of the TOF (cm) | |
88 | ||
89 | Init(); | |
90 | ||
91 | } | |
92 | ||
93 | //_____________________________________________________________________________ | |
94 | AliTOFGeometryV4::~AliTOFGeometryV4() | |
95 | { | |
96 | // | |
97 | // AliTOFGeometryV4 destructor | |
98 | // | |
99 | ||
100 | } | |
101 | //_____________________________________________________________________________ | |
a6a9820c | 102 | void AliTOFGeometryV4::ImportGeometry(){ |
103 | TGeoManager::Import("geometry.root"); | |
104 | } | |
105 | //_____________________________________________________________________________ | |
d3c7bfac | 106 | void AliTOFGeometryV4::Init() |
107 | { | |
108 | // | |
109 | // Initialize strip Tilt Angles and Heights | |
110 | // | |
111 | // Strips Tilt Angles | |
112 | ||
113 | Float_t const kangles[kNPlates][kMaxNstrip] ={ | |
114 | ||
115 | {44.494, 43.725, 42.946, 42.156, 41.357, 40.548, 39.729, 38.899, | |
116 | 38.060, 37.211, 36.353, 35.484, 34.606, 33.719, 32.822, 31.916, | |
117 | 31.001, 30.077, 29.144, 28.202 }, | |
118 | ||
119 | {26.884, 25.922, 24.952, 23.975, 22.989, 22.320, 21.016, 20.309, | |
120 | 19.015, 18.270, 16.989, 16.205, 14.941, 14.117, 12.871, 12.008, | |
121 | 10.784, 9.8807, 8.681, 0.0 }, | |
122 | ||
123 | { 7.5835, 6.4124, 5.4058, 4.2809, 3.2448, 2.1424, 1.078, -0., -1.078, | |
124 | -2.1424, -3.2448, -4.2809, -5.4058, -6.4124, -7.5835, 0.0, 0.0, 0.0, | |
125 | 0.0, 0.0 }, | |
126 | ||
127 | {-8.681, -9.8807, -10.784, -12.008, -12.871, -14.117, -14.941, -16.205, | |
128 | -16.989, -18.27, -19.015, -20.309, -21.016, -22.32, -22.989, | |
129 | -23.975, -24.952, -25.922, -26.884, 0. }, | |
130 | ||
131 | {-28.202, -29.144, -30.077, -31.001, -31.916, -32.822, -33.719, -34.606, | |
132 | -35.484, -36.353, -37.211, -38.06, -38.899, -39.729, -40.548, | |
133 | -41.357, -42.156, -42.946, -43.725, -44.494 }}; | |
134 | ||
135 | ||
136 | //Strips Heights | |
137 | ||
138 | Float_t const kheights[kNPlates][kMaxNstrip]= { | |
139 | ||
140 | {-5.5, -5.5, -5.5, -5.5, -5.5, -5.5, -5.5, -5.5, -5.5, -5.5, | |
141 | -5.5, -5.5, -5.5, -5.5, -5.5, -5.5, -5.5, -5.5, -5.5, -5.5 }, | |
142 | ||
143 | {-6.3, -7.1, -7.9, -8.7, -9.5, -3, -9.5, -3, -9.5, -3, | |
144 | -9.5, -3.0, -9.5, -3.0, -9.5, -3, -9.5, -3, -9 , 0.}, | |
145 | ||
146 | { -3, -9, -4.5, -9, -4.5, -9, -4.5, -9, -4.5, -9, | |
147 | -4.5, -9, -4.5, -9, -3, 0.0, 0.0, 0.0, 0.0, 0.0 }, | |
148 | ||
149 | { -9, -3, -9.5, -3, -9.5, -3, -9.5, -3, -9.5, -3, -9.5, | |
150 | -3, -9.5, -3, -9.5, -8.7, -7.9, -7.1, -6.3, 0. }, | |
151 | ||
152 | {-5.5, -5.5, -5.5, -5.5, -5.5, -5.5, -5.5, -5.5, -5.5, -5.5, | |
153 | -5.5, -5.5, -5.5, -5.5, -5.5, -5.5, -5.5, -5.5, -5.5, -5.5 }}; | |
154 | ||
155 | // Deposit in fAngles, fHeights | |
156 | ||
d3c7bfac | 157 | for (Int_t iplate = 0; iplate < kNPlates; iplate++) { |
158 | for (Int_t istrip = 0; istrip < kMaxNstrip; istrip++) { | |
159 | AliTOFGeometry::fAngles[iplate][istrip] = kangles[iplate][istrip]; | |
160 | AliTOFGeometry::fHeights[iplate][istrip] = kheights[iplate][istrip]; | |
161 | } | |
162 | } | |
163 | ||
164 | } | |
165 | ||
166 | //_____________________________________________________________________________ | |
a6a9820c | 167 | Float_t AliTOFGeometryV4::DistanceToPadPar(Int_t *det, Float_t *pos, Float_t *dist3d) |
d3c7bfac | 168 | { |
169 | // | |
170 | // Returns distance of space point with coor pos (x,y,z) (cm) wrt | |
171 | // pad with Detector Indices idet (iSect,iPlate,iStrip,iPadX,iPadZ) | |
172 | // | |
173 | ||
174 | //Transform pos into Sector Frame | |
175 | ||
176 | Float_t x = pos[0]; | |
177 | Float_t y = pos[1]; | |
178 | Float_t z = pos[2]; | |
179 | ||
180 | Float_t radius = TMath::Sqrt(x*x+y*y); | |
181 | Float_t phi=TMath::ATan2(y,x); | |
182 | if(phi<0) phi=2.*TMath::Pi()+phi; | |
183 | // Get the local angle in the sector philoc | |
184 | Float_t angle = phi*kRaddeg-( Int_t (kRaddeg*phi/fPhiSec) + 0.5)*fPhiSec; | |
185 | Float_t xs = radius*TMath::Cos(angle/kRaddeg); | |
186 | Float_t ys = radius*TMath::Sin(angle/kRaddeg); | |
187 | Float_t zs = z; | |
188 | ||
189 | // Do the same for the selected pad | |
190 | ||
191 | Float_t g[3]; | |
a6a9820c | 192 | GetPosPar(det,g); |
d3c7bfac | 193 | |
194 | Float_t padRadius = TMath::Sqrt(g[0]*g[0]+g[1]*g[1]); | |
195 | Float_t padPhi=TMath::ATan2(g[1],g[0]); | |
196 | if(padPhi<0) padPhi=2.*TMath::Pi()+padPhi; | |
197 | // Get the local angle in the sector philoc | |
198 | Float_t padAngle = padPhi*kRaddeg-( Int_t (padPhi*kRaddeg/fPhiSec)+ 0.5) * fPhiSec; | |
199 | Float_t padxs = padRadius*TMath::Cos(padAngle/kRaddeg); | |
200 | Float_t padys = padRadius*TMath::Sin(padAngle/kRaddeg); | |
201 | Float_t padzs = g[2]; | |
202 | ||
203 | //Now move to local pad coordinate frame. Translate: | |
204 | ||
205 | Float_t xt = xs-padxs; | |
206 | Float_t yt = ys-padys; | |
207 | Float_t zt = zs-padzs; | |
208 | //Now Rotate: | |
209 | ||
210 | Float_t alpha = GetAngles(det[1],det[2]); | |
211 | Float_t xr = xt*TMath::Cos(alpha/kRaddeg)+zt*TMath::Sin(alpha/kRaddeg); | |
212 | Float_t yr = yt; | |
213 | Float_t zr = -xt*TMath::Sin(alpha/kRaddeg)+zt*TMath::Cos(alpha/kRaddeg); | |
214 | ||
215 | Float_t dist = TMath::Sqrt(xr*xr+yr*yr+zr*zr); | |
d3c7bfac | 216 | if (dist3d){ |
217 | dist3d[0] = xr; | |
218 | dist3d[1] = yr; | |
219 | dist3d[2] = zr; | |
220 | } | |
221 | ||
222 | return dist; | |
223 | ||
224 | } | |
225 | ||
226 | //_____________________________________________________________________________ | |
a6a9820c | 227 | Bool_t AliTOFGeometryV4::IsInsideThePadPar(Int_t *det, Float_t *pos) |
d3c7bfac | 228 | { |
229 | // | |
230 | // Returns true if space point with coor pos (x,y,z) (cm) falls | |
231 | // inside pad with Detector Indices idet (iSect,iPlate,iStrip,iPadX,iPadZ) | |
232 | // | |
233 | ||
234 | Bool_t isInside=false; | |
235 | ||
236 | //Transform pos into Sector Frame | |
237 | ||
238 | Float_t x = pos[0]; | |
239 | Float_t y = pos[1]; | |
240 | Float_t z = pos[2]; | |
241 | ||
242 | Float_t radius = TMath::Sqrt(x*x+y*y); | |
243 | Float_t phi=TMath::ATan2(y,x); | |
244 | if(phi<0) phi=2.*TMath::Pi()+phi; | |
245 | // Get the local angle in the sector philoc | |
246 | Float_t angle = phi*kRaddeg-( Int_t (kRaddeg*phi/fPhiSec) + 0.5) *fPhiSec; | |
247 | Float_t xs = radius*TMath::Cos(angle/kRaddeg); | |
248 | Float_t ys = radius*TMath::Sin(angle/kRaddeg); | |
249 | Float_t zs = z; | |
250 | ||
251 | // Do the same for the selected pad | |
252 | ||
253 | Float_t g[3]; | |
a6a9820c | 254 | GetPosPar(det,g); |
d3c7bfac | 255 | |
256 | Float_t padRadius = TMath::Sqrt(g[0]*g[0]+g[1]*g[1]); | |
257 | Float_t padPhi=TMath::ATan2(g[1],g[0]); | |
258 | if(padPhi<0) padPhi=2.*TMath::Pi()+padPhi; | |
259 | // Get the local angle in the sector philoc | |
260 | Float_t padAngle = padPhi*kRaddeg-( Int_t (padPhi*kRaddeg/fPhiSec)+ 0.5) * fPhiSec; | |
261 | Float_t padxs = padRadius*TMath::Cos(padAngle/kRaddeg); | |
262 | Float_t padys = padRadius*TMath::Sin(padAngle/kRaddeg); | |
263 | Float_t padzs = g[2]; | |
264 | ||
265 | //Now move to local pad coordinate frame. Translate: | |
266 | ||
267 | Float_t xt = xs-padxs; | |
268 | Float_t yt = ys-padys; | |
269 | Float_t zt = zs-padzs; | |
270 | ||
271 | //Now Rotate: | |
272 | ||
273 | Float_t alpha = GetAngles(det[1],det[2]); | |
274 | Float_t xr = xt*TMath::Cos(alpha/kRaddeg)+zt*TMath::Sin(alpha/kRaddeg); | |
275 | Float_t yr = yt; | |
276 | Float_t zr = -xt*TMath::Sin(alpha/kRaddeg)+zt*TMath::Cos(alpha/kRaddeg); | |
277 | ||
278 | if(TMath::Abs(xr)<=0.75 && TMath::Abs(yr)<= (fgkXPad*0.5) && TMath::Abs(zr)<= (fgkZPad*0.5)) | |
279 | isInside=true; | |
280 | return isInside; | |
281 | ||
282 | } | |
283 | ||
a6a9820c | 284 | |
285 | //_____________________________________________________________________________ | |
286 | Float_t AliTOFGeometryV4::DistanceToPad(Int_t *det, TGeoHMatrix mat, Float_t *pos, Float_t *dist3d) | |
287 | { | |
288 | // | |
289 | // Returns distance of space point with coor pos (x,y,z) (cm) wrt | |
290 | // pad with Detector Indices idet (iSect,iPlate,iStrip,iPadX,iPadZ) | |
291 | // | |
292 | if (!gGeoManager) { | |
293 | printf("ERROR: no TGeo\n"); | |
294 | return 0.; | |
295 | } | |
296 | Double_t vecg[3]; | |
297 | vecg[0]=pos[0]; | |
298 | vecg[1]=pos[1]; | |
299 | vecg[2]=pos[2]; | |
300 | Double_t veclr[3]={-1.,-1.,-1.}; | |
301 | Double_t vecl[3]={-1.,-1.,-1.}; | |
302 | mat.MasterToLocal(vecg,veclr); | |
303 | vecl[0]=veclr[1]; | |
304 | vecl[1]=veclr[0]; | |
305 | vecl[2]=-veclr[2]; | |
306 | //Take into account reflections | |
307 | if(det[1]>2){ | |
308 | vecl[1]=-veclr[0]; | |
309 | vecl[2]= veclr[2]; | |
310 | } | |
311 | ||
312 | Float_t dist = TMath::Sqrt(vecl[0]*vecl[0]+vecl[1]*vecl[1]+vecl[2]*vecl[2]); | |
313 | ||
314 | ||
315 | if (dist3d){ | |
316 | dist3d[0] = vecl[0]; | |
317 | dist3d[1] = vecl[1]; | |
318 | dist3d[2] = vecl[2]; | |
319 | } | |
320 | ||
321 | return dist; | |
322 | ||
323 | } | |
324 | ||
325 | ||
326 | //_____________________________________________________________________________ | |
327 | Bool_t AliTOFGeometryV4::IsInsideThePad( Int_t *det, TGeoHMatrix mat, Float_t *pos) | |
328 | { | |
329 | // | |
330 | // Returns true if space point with coor pos (x,y,z) (cm) falls | |
331 | // inside pad with Detector Indices idet (iSect,iPlate,iStrip,iPadX,iPadZ) | |
332 | // | |
333 | ||
334 | const Float_t khsensmy = 0.5; // heigth of Sensitive Layer | |
335 | ||
336 | Double_t vecg[3]; | |
337 | vecg[0]=pos[0]; | |
338 | vecg[1]=pos[1]; | |
339 | vecg[2]=pos[2]; | |
340 | Double_t veclr[3]={-1.,-1.,-1.}; | |
341 | Double_t vecl[3]={-1.,-1.,-1.}; | |
342 | mat.MasterToLocal(vecg,veclr); | |
343 | vecl[0]=veclr[1]; | |
344 | vecl[1]=veclr[0]; | |
345 | vecl[2]=-veclr[2]; | |
346 | //Take into account reflections | |
347 | if(det[1]>2){ | |
348 | vecl[1]=-veclr[0]; | |
349 | vecl[2]= veclr[2]; | |
350 | } | |
351 | ||
352 | Float_t xr = vecl[0]; | |
353 | Float_t yr = vecl[1]; | |
354 | Float_t zr = vecl[2]; | |
355 | ||
356 | Bool_t isInside=false; | |
357 | if(TMath::Abs(xr)<= khsensmy*0.5 && TMath::Abs(yr)<= (fgkXPad*0.5) && TMath::Abs(zr)<= (fgkZPad*0.5)) | |
358 | isInside=true; | |
359 | return isInside; | |
360 | ||
361 | } | |
d3c7bfac | 362 | //_____________________________________________________________________________ |
363 | Float_t AliTOFGeometryV4::GetX(Int_t *det) | |
364 | { | |
365 | // | |
366 | // Returns X coordinate (cm) | |
367 | // | |
368 | ||
369 | Int_t isector = det[0]; | |
370 | Int_t iplate = det[1]; | |
371 | Int_t istrip = det[2]; | |
372 | Int_t ipadz = det[3]; | |
373 | Int_t ipadx = det[4]; | |
374 | ||
375 | // Find out distance d on the plane wrt median phi: | |
376 | Float_t d = (ipadx+0.5)*fgkXPad-(kNpadX*fgkXPad)*0.5; | |
377 | ||
378 | // The radius r in xy plane: | |
379 | Float_t r = (fgkRmin+fgkRmax)/2.+fHeights[iplate][istrip]+ | |
380 | (ipadz-0.5)*fgkZPad*TMath::Sin(fAngles[iplate][istrip]/kRaddeg)-0.25; | |
381 | ||
382 | // local azimuthal angle in the sector philoc | |
383 | Float_t philoc = TMath:: ATan(d/r); | |
384 | ||
385 | // azimuthal angle in the global frame phi | |
386 | Float_t phi = philoc*kRaddeg+(isector+0.5 )*fPhiSec; | |
387 | ||
388 | Float_t xCoor = r/TMath::Cos(philoc)*TMath::Cos(phi/kRaddeg); | |
389 | ||
390 | return xCoor; | |
391 | ||
392 | } | |
393 | //_____________________________________________________________________________ | |
394 | Float_t AliTOFGeometryV4::GetY(Int_t *det) | |
395 | { | |
396 | // | |
397 | // Returns Y coordinate (cm) | |
398 | // | |
399 | ||
400 | Int_t isector = det[0]; | |
401 | Int_t iplate = det[1]; | |
402 | Int_t istrip = det[2]; | |
403 | Int_t ipadz = det[3]; | |
404 | Int_t ipadx = det[4]; | |
405 | ||
406 | // Find out distance d on the plane wrt median phi: | |
407 | Float_t d = (ipadx+0.5)*fgkXPad-(kNpadX*fgkXPad)*0.5; | |
408 | ||
409 | // The radius r in xy plane: | |
410 | Float_t r = (fgkRmin+fgkRmax)/2.+fHeights[iplate][istrip]+ | |
411 | (ipadz-0.5)*fgkZPad*TMath::Sin(fAngles[iplate][istrip]/kRaddeg)-0.25; | |
412 | ||
413 | // local azimuthal angle in the sector philoc | |
414 | Float_t philoc = TMath:: ATan(d/r); | |
415 | ||
416 | // azimuthal angle in the global frame phi | |
417 | Float_t phi = philoc*kRaddeg+(isector+0.5 )*fPhiSec; | |
418 | ||
419 | Float_t yCoor = r/TMath::Cos(philoc)*TMath::Sin(phi/kRaddeg); | |
420 | ||
421 | return yCoor; | |
422 | ||
423 | } | |
424 | ||
425 | //_____________________________________________________________________________ | |
426 | Float_t AliTOFGeometryV4::GetZ(Int_t *det) | |
427 | { | |
428 | // | |
429 | // Returns Z coordinate (cm) | |
430 | // | |
431 | ||
432 | Int_t iplate = det[1]; | |
433 | Int_t istrip = det[2]; | |
434 | Int_t ipadz = det[3]; | |
435 | ||
436 | // The radius r in xy plane: | |
437 | Float_t r = (fgkRmin+fgkRmax)/2.+fHeights[iplate][istrip]; | |
438 | ||
439 | Float_t zCoor = r*TMath::Tan(0.5*TMath::Pi()-GetStripTheta(iplate,istrip))- | |
440 | (ipadz-0.5)*fgkZPad*TMath::Cos(fAngles[iplate][istrip]/kRaddeg); | |
441 | return zCoor; | |
442 | ||
443 | } | |
444 | ||
445 | //_____________________________________________________________________________ | |
446 | Int_t AliTOFGeometryV4::GetSector(Float_t *pos) | |
447 | { | |
448 | // | |
449 | // Returns the Sector index | |
450 | // | |
451 | ||
452 | Int_t iSect = -1; | |
453 | ||
454 | Float_t x = pos[0]; | |
455 | Float_t y = pos[1]; | |
456 | ||
457 | Float_t phi = TMath::ATan2(y,x); | |
458 | if(phi<0.) phi=2.*TMath::Pi()+phi; | |
459 | iSect = (Int_t) (phi*kRaddeg/fPhiSec); | |
460 | ||
461 | return iSect; | |
462 | ||
463 | } | |
464 | ||
465 | //_____________________________________________________________________________ | |
466 | Int_t AliTOFGeometryV4::GetPadX(Float_t *pos) | |
467 | { | |
468 | // | |
469 | // Returns the Pad index along X | |
470 | // | |
471 | ||
472 | Int_t iPadX = -1; | |
473 | ||
474 | Float_t x = pos[0]; | |
475 | Float_t y = pos[1]; | |
476 | Float_t z = pos[2]; | |
477 | ||
478 | Int_t isector = GetSector(pos); | |
479 | if(isector == -1){ | |
480 | AliError("Detector Index could not be determined"); | |
481 | return iPadX;} | |
482 | Int_t iplate = GetPlate(pos); | |
483 | if(iplate == -1){ | |
484 | AliError("Detector Index could not be determined"); | |
485 | return iPadX;} | |
486 | Int_t istrip = GetStrip(pos); | |
487 | if(istrip == -1){ | |
488 | AliError("Detector Index could not be determined"); | |
489 | return iPadX;} | |
490 | ||
491 | ||
492 | Float_t rho=TMath::Sqrt(x*x+y*y); | |
493 | Float_t phi = TMath::ATan2(y,x); | |
494 | if(phi<0.) phi=2.*TMath::Pi()+phi; | |
495 | ||
496 | // Get the local angle in the sector philoc | |
497 | Float_t philoc = phi*kRaddeg-(isector+0.5)*fPhiSec; | |
498 | philoc*=TMath::Pi()/180.; | |
499 | // theta projected on the median of the sector | |
500 | Float_t theta = TMath::ATan2(rho*TMath::Cos(philoc),z); | |
501 | // The radius r in xy plane: | |
502 | Float_t r = (fgkRmin+fgkRmax)/2.+fHeights[iplate][istrip]+ | |
503 | (theta-GetStripTheta(iplate, istrip))/ | |
504 | (GetMaxStripTheta(iplate, istrip)-GetMinStripTheta(iplate, istrip)) | |
505 | * 2.*fgkZPad*TMath::Sin(fAngles[iplate][istrip]/kRaddeg)-0.25; | |
506 | ||
507 | // Find out distance projected onto the strip plane | |
508 | Float_t d = (r*TMath::Tan(philoc)+(kNpadX*fgkXPad)*0.5); | |
509 | ||
510 | iPadX = (Int_t) ( d/fgkXPad); | |
511 | return iPadX; | |
512 | ||
513 | } | |
514 | //_____________________________________________________________________________ | |
515 | Int_t AliTOFGeometryV4::GetPlate(Float_t *pos) | |
516 | { | |
517 | // | |
518 | // Returns the Plate index | |
519 | // | |
520 | Int_t iPlate=-1; | |
521 | ||
522 | Int_t isector = GetSector(pos); | |
523 | if(isector == -1){ | |
524 | AliError("Detector Index could not be determined"); | |
525 | return iPlate;} | |
526 | ||
527 | Float_t x = pos[0]; | |
528 | Float_t y = pos[1]; | |
529 | Float_t z = pos[2]; | |
530 | ||
531 | Float_t rho=TMath::Sqrt(x*x+y*y); | |
532 | Float_t phi=TMath::ATan2(y,x); | |
533 | if(phi<0) phi=2.*TMath::Pi()+phi; | |
534 | // Get the local angle in the sector philoc | |
535 | Float_t philoc = phi*kRaddeg-(isector+0.5)*fPhiSec; | |
536 | philoc*=TMath::Pi()/180.; | |
537 | // theta projected on the median of the sector | |
538 | Float_t theta=TMath::ATan2(rho*TMath::Cos(philoc),z); | |
539 | ||
540 | for (Int_t i=0; i<kNPlates; i++){ | |
541 | if ( GetMaxPlateTheta(i) >= theta && | |
542 | GetMinPlateTheta(i) <= theta)iPlate=i; | |
543 | } | |
544 | ||
545 | return iPlate; | |
546 | ||
547 | } | |
548 | ||
549 | //_____________________________________________________________________________ | |
550 | Int_t AliTOFGeometryV4::GetStrip(Float_t *pos) | |
551 | { | |
552 | // | |
553 | // Returns the Strip index | |
554 | // | |
555 | ||
556 | Int_t iStrip=-1; | |
557 | ||
558 | ||
559 | Int_t isector = GetSector(pos); | |
560 | if(isector == -1){ | |
561 | AliError("Detector Index could not be determined"); | |
562 | return iStrip;} | |
563 | Int_t iplate = GetPlate(pos); | |
564 | if(iplate == -1){ | |
565 | AliError("Detector Index could not be determined"); | |
566 | return iStrip;} | |
567 | ||
568 | ||
569 | Float_t x = pos[0]; | |
570 | Float_t y = pos[1]; | |
571 | Float_t z = pos[2]; | |
572 | ||
573 | Int_t nstrips=0; | |
574 | if(iplate==0 || iplate == 4)nstrips=kNStripC; | |
575 | if(iplate==1 || iplate == 3)nstrips=kNStripB; | |
576 | if(iplate==2) nstrips=kNStripA; | |
577 | ||
578 | Float_t rho=TMath::Sqrt(x*x+y*y); | |
579 | Float_t phi=TMath::ATan2(y,x); | |
580 | if(phi<0) phi=2.*TMath::Pi()+phi; | |
581 | // Get the local angle in the sector philoc | |
582 | Float_t philoc = phi*kRaddeg-(isector+0.5)*fPhiSec; | |
583 | philoc*=TMath::Pi()/180.; | |
584 | // theta projected on the median of the sector | |
585 | Float_t theta=TMath::ATan2(rho*TMath::Cos(philoc),z); | |
586 | ||
587 | for (Int_t istrip=0; istrip<nstrips; istrip++){ | |
588 | ||
589 | if( | |
590 | GetMaxStripTheta(iplate,istrip) >= theta | |
591 | && | |
592 | GetMinStripTheta(iplate,istrip) <= theta ) iStrip = istrip; | |
593 | ||
594 | } | |
595 | ||
596 | return iStrip; | |
597 | ||
598 | } | |
599 | //_____________________________________________________________________________ | |
600 | Int_t AliTOFGeometryV4::GetPadZ(Float_t *pos) | |
601 | { | |
602 | // | |
603 | // Returns the Pad index along Z | |
604 | // | |
605 | Int_t iPadZ = -1; | |
606 | ||
607 | Int_t isector = GetSector(pos); | |
608 | if(isector == -1){ | |
609 | AliError("Detector Index could not be determined"); | |
610 | return iPadZ;} | |
611 | Int_t iplate = GetPlate(pos); | |
612 | if(iplate == -1){ | |
613 | AliError("Detector Index could not be determined"); | |
614 | return iPadZ;} | |
615 | Int_t istrip = GetStrip(pos); | |
616 | if(istrip == -1){ | |
617 | AliError("Detector Index could not be determined"); | |
618 | return iPadZ;} | |
619 | ||
620 | ||
621 | Float_t x = pos[0]; | |
622 | Float_t y = pos[1]; | |
623 | Float_t z = pos[2]; | |
624 | ||
625 | Float_t rho=TMath::Sqrt(x*x+y*y); | |
626 | Float_t phi=TMath::ATan2(y,x); | |
627 | if(phi<0) phi=2.*TMath::Pi()+phi; | |
628 | Float_t philoc = phi*kRaddeg-(isector+0.5)*fPhiSec; | |
629 | philoc*=TMath::Pi()/180.; | |
630 | Float_t theta=TMath::ATan2(rho*TMath::Cos(philoc),z); | |
631 | ||
632 | if (theta >= GetStripTheta(iplate, istrip))iPadZ=1; | |
633 | else iPadZ=0; | |
634 | ||
635 | return iPadZ; | |
636 | ||
637 | } | |
638 | //_____________________________________________________________________________ | |
639 | Float_t AliTOFGeometryV4::GetMinPlateTheta(Int_t iPlate) | |
640 | { | |
641 | // | |
642 | // Returns the minimum theta angle of a given plate iPlate (rad) | |
643 | // | |
644 | ||
645 | ||
646 | Int_t index=0; | |
647 | ||
648 | Float_t delta =0.; | |
649 | if(iPlate==0)delta = -1. ; | |
650 | if(iPlate==1)delta = -0.5; | |
651 | if(iPlate==3)delta = +0.5; | |
652 | if(iPlate==4)delta = +1. ; | |
653 | ||
654 | Float_t z=(fgkRmin+2.)*TMath::Tan(fAngles[iPlate][index]/kRaddeg)+delta; | |
655 | Float_t r=(fgkRmin+fgkRmax)/2.+fHeights[iPlate][index]; | |
656 | z =z+fgkZPad*TMath::Cos(fAngles[iPlate][index]/kRaddeg); | |
657 | r =r-fgkZPad*TMath::Sin(fAngles[iPlate][index]/kRaddeg); | |
658 | ||
659 | Float_t thmin = 0.5*TMath::Pi()-TMath::ATan(z/r)-fgkDprecMin; | |
660 | return thmin; | |
661 | ||
662 | } | |
663 | //_____________________________________________________________________________ | |
664 | Float_t AliTOFGeometryV4::GetMaxPlateTheta(Int_t iPlate) | |
665 | { | |
666 | // | |
667 | // Returns the maximum theta angle of a given plate iPlate (rad) | |
668 | ||
669 | Int_t index=0; | |
670 | if(iPlate==0 ||iPlate == 4)index=kNStripC-1; | |
671 | if(iPlate==1 ||iPlate == 3)index=kNStripB-1; | |
672 | if(iPlate==2) index=kNStripA-1; | |
673 | ||
674 | Float_t delta =0.; | |
675 | if(iPlate==0)delta = -1. ; | |
676 | if(iPlate==1)delta = -0.5; | |
677 | if(iPlate==3)delta = +0.5; | |
678 | if(iPlate==4)delta = +1. ; | |
679 | ||
680 | Float_t z=(fgkRmin+2.)*TMath::Tan(fAngles[iPlate][index]/kRaddeg)+delta; | |
681 | Float_t r=(fgkRmin+fgkRmax)/2.+fHeights[iPlate][index]; | |
682 | z =z-fgkZPad*TMath::Cos(fAngles[iPlate][index]/kRaddeg); | |
683 | r= r+fgkZPad*TMath::Sin(fAngles[iPlate][index]/kRaddeg); | |
684 | ||
685 | Float_t thmax = 0.5*TMath::Pi()-TMath::ATan(z/r)+fgkDprecMax; | |
686 | ||
687 | return thmax; | |
688 | ||
689 | } | |
690 | //_____________________________________________________________________________ | |
691 | Float_t AliTOFGeometryV4::GetMaxStripTheta(Int_t iPlate, Int_t iStrip) | |
692 | { | |
693 | // | |
694 | // Returns the maximum theta angle of a given strip iStrip (rad) | |
695 | // | |
696 | ||
697 | ||
698 | Float_t delta =0.; | |
699 | if(iPlate==0)delta = -1. ; | |
700 | if(iPlate==1)delta = -0.5; | |
701 | if(iPlate==3)delta = +0.5; | |
702 | if(iPlate==4)delta = +1. ; | |
703 | ||
704 | Float_t r =(fgkRmin+fgkRmax)/2.+fHeights[iPlate][iStrip]; | |
705 | Float_t z =(fgkRmin+2.)*TMath::Tan(fAngles[iPlate][iStrip]/kRaddeg)+delta; | |
706 | z = z-fgkZPad*TMath::Cos(fAngles[iPlate][iStrip]/kRaddeg); | |
707 | r = r+fgkZPad*TMath::Sin(fAngles[iPlate][iStrip]/kRaddeg); | |
708 | Float_t thmax =0.5*TMath::Pi()-TMath::ATan(z/r)+fgkDprecMax; | |
709 | return thmax; | |
710 | ||
711 | } | |
712 | //_____________________________________________________________________________ | |
713 | Float_t AliTOFGeometryV4::GetMinStripTheta(Int_t iPlate, Int_t iStrip) | |
714 | { | |
715 | // | |
716 | // Returns the minimum theta angle of a given Strip iStrip (rad) | |
717 | // | |
718 | ||
719 | ||
720 | Float_t delta =0.; | |
721 | if(iPlate==0)delta = -1. ; | |
722 | if(iPlate==1)delta = -0.5; | |
723 | if(iPlate==3)delta = +0.5; | |
724 | if(iPlate==4)delta = +1. ; | |
725 | ||
726 | ||
727 | Float_t r =(fgkRmin+fgkRmax)/2.+fHeights[iPlate][iStrip]; | |
728 | Float_t z =(fgkRmin+2.)*TMath::Tan(fAngles[iPlate][iStrip]/kRaddeg)+delta; | |
729 | z =z+fgkZPad*TMath::Cos(fAngles[iPlate][iStrip]/kRaddeg); | |
730 | r =r-fgkZPad*TMath::Sin(fAngles[iPlate][iStrip]/kRaddeg); | |
731 | Float_t thmin =0.5*TMath::Pi()-TMath::ATan(z/r)-fgkDprecMin; | |
732 | ||
733 | return thmin; | |
734 | ||
735 | } | |
736 | //_____________________________________________________________________________ | |
737 | Float_t AliTOFGeometryV4::GetStripTheta(Int_t iPlate, Int_t iStrip) | |
738 | { | |
739 | // | |
740 | // returns the median theta angle of a given strip iStrip (rad) | |
741 | // | |
742 | ||
743 | ||
744 | Float_t delta =0.; | |
745 | if(iPlate==0)delta = -1. ; | |
746 | if(iPlate==1)delta = -0.5; | |
747 | if(iPlate==3)delta = +0.5; | |
748 | if(iPlate==4)delta = +1. ; | |
749 | ||
750 | Float_t r =(fgkRmin+fgkRmax)/2.+fHeights[iPlate][iStrip]; | |
751 | Float_t z =(fgkRmin+2.)*TMath::Tan(fAngles[iPlate][iStrip]/kRaddeg)+delta; | |
752 | Float_t theta =0.5*TMath::Pi()-TMath::ATan(z/r); | |
753 | if(iPlate != 2){ | |
754 | if(theta > 0.5*TMath::Pi() )theta+=fgkDprecCen; | |
755 | if(theta < 0.5*TMath::Pi() )theta-=fgkDprecCen; | |
756 | } | |
757 | return theta; | |
758 | ||
759 | } | |
760 | //_____________________________________________________________________________ | |
a6a9820c | 761 | void AliTOFGeometryV4::GetVolumePath(Int_t *ind, Char_t *path ) { |
762 | //-------------------------------------------------------------------- | |
763 | // This function returns the colume path of a given pad | |
764 | //-------------------------------------------------------------------- | |
765 | Int_t sector = ind[0]; | |
766 | Char_t string1[100]; | |
767 | Char_t string2[100]; | |
768 | Char_t string3[100]; | |
769 | Char_t string4[100]; | |
770 | Int_t nstrB = NStripB(); | |
771 | Int_t nstrC = NStripC(); | |
772 | ||
773 | Int_t icopy=-1; | |
774 | ||
775 | if(sector<3){ | |
776 | icopy=sector+1; | |
777 | sprintf(string1,"/ALIC_1/B077_1/B075_%i/BTO3_1",icopy); | |
778 | } | |
779 | else if(sector<11){ | |
780 | // icopy=sector-2; | |
781 | icopy=sector+3; | |
782 | sprintf(string1,"/ALIC_1/B077_1/B071_%i/BTO1_1",icopy); | |
783 | } | |
784 | else if(sector==11 || sector==12){ | |
785 | icopy=sector-10; | |
786 | sprintf(string1,"/ALIC_1/B077_1/B074_%i/BTO2_1",icopy); | |
787 | } | |
788 | else { | |
789 | // icopy=sector-4; | |
790 | icopy=sector-12; | |
791 | sprintf(string1,"/ALIC_1/B077_1/B071_%i/BTO1_1",icopy); | |
792 | } | |
793 | ||
794 | Int_t modnum=ind[1]; | |
795 | Int_t istrip=ind[2]; | |
796 | ||
797 | if( modnum ==0){ | |
798 | sprintf(string2,"FTOC_1/FLTC_0"); | |
799 | icopy= nstrC - istrip; | |
800 | sprintf(string3,"FSTR_%i",icopy); | |
801 | } | |
802 | else if( modnum ==1){ | |
803 | sprintf(string2,"FTOB_1/FLTB_0"); | |
804 | icopy= nstrB - istrip; | |
805 | sprintf(string3,"FSTR_%i",icopy); | |
806 | } | |
807 | else if( modnum ==2){ | |
808 | sprintf(string2,"FTOA_0/FLTA_0"); | |
809 | icopy= istrip+1; | |
810 | sprintf(string3,"FSTR_%i",icopy); | |
811 | } | |
812 | else if( modnum ==3){ | |
813 | sprintf(string2,"FTOB_2/FLTB_0"); | |
814 | icopy= istrip+1; | |
815 | sprintf(string3,"FSTR_%i",icopy); | |
816 | } | |
817 | else if( modnum ==4){ | |
818 | sprintf(string2,"FTOC_2/FLTC_0"); | |
819 | icopy= istrip+1; | |
820 | sprintf(string3,"FSTR_%i",icopy); | |
821 | } | |
822 | ||
823 | ||
824 | Int_t padz = ind[3]+1; | |
825 | Int_t padx = ind[4]+1; | |
826 | if(modnum==3 || modnum==4){ | |
827 | padz = NpadZ() -ind[3]; | |
828 | padx = NpadX() -ind[4]; | |
829 | } | |
830 | sprintf(string4,"FSEN_0/FSEZ_%i/FSEX_%i",padz,padx); | |
831 | sprintf(path,"%s/%s/%s/%s",string1,string2,string3,string4); | |
832 | ||
833 | } | |
834 | ||
835 | //_____________________________________________________________________________ | |
836 | void AliTOFGeometryV4::GetPos(Int_t *det, Float_t *pos) | |
837 | { | |
838 | // | |
839 | // Returns space point coor (x,y,z) (cm) for Detector | |
840 | // Indices (iSect,iPlate,iStrip,iPadX,iPadZ) | |
841 | // | |
842 | Char_t path[100]; | |
843 | GetVolumePath(det,path ); | |
844 | if (!gGeoManager) { | |
845 | printf("ERROR: no TGeo\n"); | |
846 | } | |
847 | gGeoManager->cd(path); | |
848 | TGeoHMatrix global; | |
849 | global = *gGeoManager->GetCurrentMatrix(); | |
850 | const Double_t *tr = global.GetTranslation(); | |
851 | ||
852 | pos[0]=tr[0]; | |
853 | pos[1]=tr[1]; | |
854 | pos[2]=tr[2]; | |
855 | } | |
856 | //_____________________________________________________________________________ |