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