]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PMD/AliPMDUtility.cxx
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / PMD / AliPMDUtility.cxx
CommitLineData
a918d77a 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 **************************************************************************/
638f6e9b 15//-----------------------------------------------------//
16// //
17// //
18// Date : August 05 2003 //
19// //
20// Utility code for ALICE-PMD //
21// //
22//-----------------------------------------------------//
23
a918d77a 24#include "Riostream.h"
638f6e9b 25#include "TMath.h"
2c08d1c1 26#include "TText.h"
27#include "TLine.h"
28
638f6e9b 29#include <stdio.h>
a918d77a 30#include <math.h>
31
2c08d1c1 32#include "AliPMDUtility.h"
638f6e9b 33
34ClassImp(AliPMDUtility)
35
5d35baec 36AliPMDUtility::AliPMDUtility():
37 fPx(0.),
38 fPy(0.),
39 fPz(0.),
40 fTheta(0.),
41 fEta(0.),
2c08d1c1 42 fPhi(0.),
43 fWriteModule(1)
638f6e9b 44{
a918d77a 45 // Default constructor
dc461f61 46 for (Int_t i = 0; i < 4; i++)
47 {
48 for (Int_t j = 0; j < 3; j++)
49 {
50 fSecTr[i][j] = 0.;
51 }
52 }
53
638f6e9b 54}
55
5d35baec 56AliPMDUtility::AliPMDUtility(Float_t px, Float_t py, Float_t pz):
57 fPx(px),
58 fPy(py),
59 fPz(pz),
60 fTheta(0.),
61 fEta(0.),
2c08d1c1 62 fPhi(0.),
63 fWriteModule(1)
638f6e9b 64{
a918d77a 65 // Constructor
dc461f61 66 for (Int_t i = 0; i < 4; i++)
67 {
68 for (Int_t j = 0; j < 3; j++)
69 {
70 fSecTr[i][j] = 0.;
71 }
72 }
73
638f6e9b 74}
5d35baec 75AliPMDUtility::AliPMDUtility(const AliPMDUtility &pmdutil):
dc461f61 76 TObject(pmdutil),
5d35baec 77 fPx(pmdutil.fPx),
78 fPy(pmdutil.fPy),
79 fPz(pmdutil.fPz),
80 fTheta(pmdutil.fTheta),
81 fEta(pmdutil.fEta),
2c08d1c1 82 fPhi(pmdutil.fPhi),
83 fWriteModule(pmdutil.fWriteModule)
5d35baec 84{
85 // copy constructor
dc461f61 86 for (Int_t i = 0; i < 4; i++)
87 {
88 for (Int_t j = 0; j < 3; j++)
89 {
90 fSecTr[i][j] = pmdutil.fSecTr[i][j];
91 }
92 }
93
5d35baec 94}
95AliPMDUtility & AliPMDUtility::operator=(const AliPMDUtility &pmdutil)
96{
97 // assignment operator
98 if(this != &pmdutil)
99 {
100 fPx = pmdutil.fPx;
101 fPy = pmdutil.fPy;
102 fPz = pmdutil.fPz;
103 fTheta = pmdutil.fTheta;
104 fEta = pmdutil.fEta;
105 fPhi = pmdutil.fPhi;
2c08d1c1 106 fWriteModule = pmdutil.fWriteModule;
dc461f61 107 for (Int_t i = 0; i < 4; i++)
108 {
109 for (Int_t j = 0; j < 3; j++)
110 {
111 fSecTr[i][j] = pmdutil.fSecTr[i][j];
112 }
113 }
114
5d35baec 115 }
116 return *this;
117}
638f6e9b 118AliPMDUtility::~AliPMDUtility()
119{
a918d77a 120 // Default destructor
638f6e9b 121}
afb8e3a0 122
01c4d84a 123void AliPMDUtility::RectGeomCellPos(Int_t ism, Int_t xpad, Int_t ypad, Float_t &xpos, Float_t &ypos)
afb8e3a0 124{
125 // This routine finds the cell eta,phi for the new PMD rectangular
126 // geometry in ALICE
127 // Authors : Bedanga Mohanty and Dipak Mishra - 29.4.2003
01c4d84a 128 // modified by B. K. Nandi for change of coordinate sys
afb8e3a0 129 //
130 // SMA ---> Supermodule Type A ( SM - 0)
131 // SMAR ---> Supermodule Type A ROTATED ( SM - 1)
132 // SMB ---> Supermodule Type B ( SM - 2)
133 // SMBR ---> Supermodule Type B ROTATED ( SM - 3)
134 //
01c4d84a 135 // ism : Serial module number from 0 to 23 for each plane
afb8e3a0 136
01c4d84a 137
afb8e3a0 138 // Corner positions (x,y) of the 24 unit moudles in ALICE PMD
f117e3aa 139
f117e3aa 140 double xcorner[24] =
141 {
142 74.8833, 53.0045, 31.1255, //Type-A
143 74.8833, 53.0045, 31.1255, //Type-A
144 -74.8833, -53.0044, -31.1255, //Type-AR
145 -74.8833, -53.0044, -31.1255, //Type-AR
146 8.9165, -33.7471, //Type-B
147 8.9165, -33.7471, //Type-B
148 8.9165, -33.7471, //Type-B
149 -8.9165, 33.7471, //Type-BR
150 -8.9165, 33.7471, //Type-BR
151 -8.9165, 33.7471, //Type-BR
152 };
153
afb8e3a0 154
f117e3aa 155 double ycorner[24] =
156 {
157 86.225, 86.225, 86.225, //Type-A
158 37.075, 37.075, 37.075, //Type-A
159 -86.225, -86.225, -86.225, //Type-AR
160 -37.075, -37.075, -37.075, //Type-AR
161 86.225, 86.225, //Type-B
162 61.075, 61.075, //Type-B
163 35.925, 35.925, //Type-B
164 -86.225, -86.225, //Type-BR
165 -61.075, -61.075, //Type-BR
166 -35.925, -35.925 //Type-BR
167 };
168
afb8e3a0 169
a918d77a 170 const Float_t kSqroot3 = 1.73205; // sqrt(3.);
171 const Float_t kCellRadius = 0.25;
afb8e3a0 172
173 //
174 //Every even row of cells is shifted and placed
175 //in geant so this condition
176 //
f117e3aa 177 Float_t cellRadius = 0.25;
a2441c6e 178 Float_t shift = 0.0;
01c4d84a 179 if(xpad%2 == 0)
afb8e3a0 180 {
f117e3aa 181 shift = -cellRadius/2.0;
afb8e3a0 182 }
183 else
184 {
185 shift = 0.0;
186 }
afb8e3a0 187
01c4d84a 188
189 if(ism < 6)
f117e3aa 190 {
01c4d84a 191 ypos = ycorner[ism] - (Float_t) xpad*kCellRadius*2.0 + shift;
192 xpos = xcorner[ism] - (Float_t) ypad*kSqroot3*kCellRadius;
afb8e3a0 193 }
01c4d84a 194 else if(ism >=6 && ism < 12)
afb8e3a0 195 {
01c4d84a 196 ypos = ycorner[ism] + (Float_t) xpad*kCellRadius*2.0 + shift;
197 xpos = xcorner[ism] + (Float_t) ypad*kSqroot3*kCellRadius;
f117e3aa 198 }
01c4d84a 199 else if(ism >= 12 && ism < 18)
f117e3aa 200 {
01c4d84a 201 ypos = ycorner[ism] - (Float_t) xpad*kCellRadius*2.0 + shift;
202 xpos = xcorner[ism] - (Float_t) ypad*kSqroot3*kCellRadius;
a2441c6e 203 }
01c4d84a 204 else if(ism >= 18 && ism < 24)
f117e3aa 205 {
01c4d84a 206 ypos = ycorner[ism] + (Float_t) xpad*kCellRadius*2.0 + shift;
207 xpos = xcorner[ism] + (Float_t) ypad*kSqroot3*kCellRadius;
f117e3aa 208 }
dc461f61 209 // Apply the alignment here to the x, y values
210 if(ism < 6)
211 {
212 xpos += fSecTr[0][0];
213 ypos += fSecTr[0][1];
214 }
215 else if(ism >= 6 && ism < 12)
216 {
217 xpos += fSecTr[1][0];
218 ypos += fSecTr[1][1];
219 }
220 else if(ism >=12 && ism < 18)
221 {
222 xpos += fSecTr[2][0];
223 ypos += fSecTr[2][1];
224 }
225 else if(ism >= 18 && ism < 24)
226 {
227 xpos += fSecTr[3][0];
228 ypos += fSecTr[3][1];
229 }
f117e3aa 230
a2441c6e 231}
dc461f61 232// ----------------------------------------------------------
01c4d84a 233void AliPMDUtility::RectGeomCellPos(Int_t ism, Float_t xpad, Float_t ypad, Float_t &xpos, Float_t &ypos)
a2441c6e 234{
235 // If the xpad and ypad inputs are float, then 0.5 is added to it
236 // to find the layer which is shifted.
237 // This routine finds the cell eta,phi for the new PMD rectangular
238 // geometry in ALICE
239 // Authors : Bedanga Mohanty and Dipak Mishra - 29.4.2003
240 // modified by B. K. Nnadi for change of coordinate sys
241 //
242 // SMA ---> Supermodule Type A ( SM - 0)
243 // SMAR ---> Supermodule Type A ROTATED ( SM - 1)
244 // SMB ---> Supermodule Type B ( SM - 2)
245 // SMBR ---> Supermodule Type B ROTATED ( SM - 3)
246 //
01c4d84a 247 // ism : Serial Module number from 0 to 23 for each plane
a2441c6e 248
249 // Corner positions (x,y) of the 24 unit moudles in ALICE PMD
f117e3aa 250
f117e3aa 251 double xcorner[24] =
252 {
253 74.8833, 53.0045, 31.1255, //Type-A
254 74.8833, 53.0045, 31.1255, //Type-A
255 -74.8833, -53.0044, -31.1255, //Type-AR
256 -74.8833, -53.0044, -31.1255, //Type-AR
257 8.9165, -33.7471, //Type-B
258 8.9165, -33.7471, //Type-B
259 8.9165, -33.7471, //Type-B
260 -8.9165, 33.7471, //Type-BR
261 -8.9165, 33.7471, //Type-BR
262 -8.9165, 33.7471, //Type-BR
263 };
264
a2441c6e 265
f117e3aa 266
267 double ycorner[24] =
268 {
269 86.225, 86.225, 86.225, //Type-A
270 37.075, 37.075, 37.075, //Type-A
271 -86.225, -86.225, -86.225, //Type-AR
272 -37.075, -37.075, -37.075, //Type-AR
273 86.225, 86.225, //Type-B
274 61.075, 61.075, //Type-B
275 35.925, 35.925, //Type-B
276 -86.225, -86.225, //Type-BR
277 -61.075, -61.075, //Type-BR
278 -35.925, -35.925 //Type-BR
279 };
280
281
a918d77a 282 const Float_t kSqroot3 = 1.73205; // sqrt(3.);
283 const Float_t kCellRadius = 0.25;
a2441c6e 284
285 //
286 //Every even row of cells is shifted and placed
287 //in geant so this condition
288 //
f117e3aa 289 Float_t cellRadius = 0.25;
a2441c6e 290 Float_t shift = 0.0;
01c4d84a 291 Int_t iirow = (Int_t) (xpad+0.5);
a2441c6e 292 if(iirow%2 == 0)
293 {
f117e3aa 294 shift = -cellRadius/2.0;
a2441c6e 295 }
296 else
297 {
298 shift = 0.0;
299 }
a2441c6e 300
01c4d84a 301 if(ism < 6)
f117e3aa 302 {
01c4d84a 303 ypos = ycorner[ism] - xpad*kCellRadius*2.0 + shift;
304 xpos = xcorner[ism] - ypad*kSqroot3*kCellRadius;
a2441c6e 305 }
01c4d84a 306 else if(ism >=6 && ism < 12)
a2441c6e 307 {
01c4d84a 308 ypos = ycorner[ism] + xpad*kCellRadius*2.0 + shift;
309 xpos = xcorner[ism] + ypad*kSqroot3*kCellRadius;
f117e3aa 310 }
01c4d84a 311 else if(ism >= 12 && ism < 18)
f117e3aa 312 {
01c4d84a 313 ypos = ycorner[ism] - xpad*kCellRadius*2.0 + shift;
314 xpos = xcorner[ism] - ypad*kSqroot3*kCellRadius;
f117e3aa 315 }
01c4d84a 316 else if(ism >= 18 && ism < 24)
f117e3aa 317 {
01c4d84a 318 ypos = ycorner[ism] + xpad*kCellRadius*2.0 + shift;
319 xpos = xcorner[ism] + ypad*kSqroot3*kCellRadius;
afb8e3a0 320 }
f117e3aa 321
dc461f61 322 // Apply the alignment here to the x, y values
323 if(ism < 6)
324 {
325 xpos += fSecTr[0][0];
326 ypos += fSecTr[0][1];
327 }
328 else if(ism >= 6 && ism < 12)
329 {
330 xpos += fSecTr[1][0];
331 ypos += fSecTr[1][1];
332 }
333 else if(ism >=12 && ism < 18)
334 {
335 xpos += fSecTr[2][0];
336 ypos += fSecTr[2][1];
337 }
338 else if(ism >= 18 && ism < 24)
339 {
340 xpos += fSecTr[3][0];
341 ypos += fSecTr[3][1];
342 }
343
344}
345
346// -------------------------------------------------------- //
347
348void AliPMDUtility::RectGeomCellPos(Int_t ism, Float_t xpad,
349 Float_t ypad, Float_t &xpos,
350 Float_t &ypos, Float_t & zpos)
351{
352 // If the xpad and ypad inputs are float, then 0.5 is added to it
353 // to find the layer which is shifted.
354 // This routine finds the cell eta,phi for the new PMD rectangular
355 // geometry in ALICE
356 // Authors : Bedanga Mohanty and Dipak Mishra - 29.4.2003
357 // modified by B. K. Nnadi for change of coordinate sys
358 //
359 // SMA ---> Supermodule Type A ( SM - 0)
360 // SMAR ---> Supermodule Type A ROTATED ( SM - 1)
361 // SMB ---> Supermodule Type B ( SM - 2)
362 // SMBR ---> Supermodule Type B ROTATED ( SM - 3)
363 //
364 // ism : Serial Module number from 0 to 23 for each plane
365
366 // Corner positions (x,y) of the 24 unit moudles in ALICE PMD
367
368 double xcorner[24] =
369 {
370 74.8833, 53.0045, 31.1255, //Type-A
371 74.8833, 53.0045, 31.1255, //Type-A
372 -74.8833, -53.0044, -31.1255, //Type-AR
373 -74.8833, -53.0044, -31.1255, //Type-AR
374 8.9165, -33.7471, //Type-B
375 8.9165, -33.7471, //Type-B
376 8.9165, -33.7471, //Type-B
377 -8.9165, 33.7471, //Type-BR
378 -8.9165, 33.7471, //Type-BR
379 -8.9165, 33.7471, //Type-BR
380 };
381
382
383
384 double ycorner[24] =
385 {
386 86.225, 86.225, 86.225, //Type-A
387 37.075, 37.075, 37.075, //Type-A
388 -86.225, -86.225, -86.225, //Type-AR
389 -37.075, -37.075, -37.075, //Type-AR
390 86.225, 86.225, //Type-B
391 61.075, 61.075, //Type-B
392 35.925, 35.925, //Type-B
393 -86.225, -86.225, //Type-BR
394 -61.075, -61.075, //Type-BR
395 -35.925, -35.925 //Type-BR
396 };
397
398
399 const Float_t kSqroot3 = 1.73205; // sqrt(3.);
400 const Float_t kCellRadius = 0.25;
401
402 //
403 //Every even row of cells is shifted and placed
404 //in geant so this condition
405 //
406 Float_t cellRadius = 0.25;
407 Float_t shift = 0.0;
408 Int_t iirow = (Int_t) (xpad+0.5);
409 if(iirow%2 == 0)
410 {
411 shift = -cellRadius/2.0;
412 }
413 else
414 {
415 shift = 0.0;
416 }
417
418 if(ism < 6)
419 {
420 ypos = ycorner[ism] - xpad*kCellRadius*2.0 + shift;
421 xpos = xcorner[ism] - ypad*kSqroot3*kCellRadius;
422 }
423 else if(ism >=6 && ism < 12)
424 {
425 ypos = ycorner[ism] + xpad*kCellRadius*2.0 + shift;
426 xpos = xcorner[ism] + ypad*kSqroot3*kCellRadius;
427 }
428 else if(ism >= 12 && ism < 18)
429 {
430 ypos = ycorner[ism] - xpad*kCellRadius*2.0 + shift;
431 xpos = xcorner[ism] - ypad*kSqroot3*kCellRadius;
432 }
433 else if(ism >= 18 && ism < 24)
434 {
435 ypos = ycorner[ism] + xpad*kCellRadius*2.0 + shift;
436 xpos = xcorner[ism] + ypad*kSqroot3*kCellRadius;
437 }
438
439 // Apply the alignment here to the x, y, and z values
440 if(ism < 6)
441 {
442 xpos += fSecTr[0][0];
443 ypos += fSecTr[0][1];
444 zpos += fSecTr[0][2];
445 }
446 else if(ism >= 6 && ism < 12)
447 {
448 xpos += fSecTr[1][0];
449 ypos += fSecTr[1][1];
450 zpos += fSecTr[1][2];
451 }
452 else if(ism >=12 && ism < 18)
453 {
454 xpos += fSecTr[2][0];
455 ypos += fSecTr[2][1];
456 zpos += fSecTr[2][2];
457 }
458 else if(ism >= 18 && ism < 24)
459 {
460 xpos += fSecTr[3][0];
461 ypos += fSecTr[3][1];
462 zpos += fSecTr[3][2];
463 }
464
465
466
afb8e3a0 467}
2c08d1c1 468// -------------------------------------------------------- //
469
470void AliPMDUtility::GenerateBoundaryPoints(Int_t ism, Float_t &x1ism,
471 Float_t &y1ism, Float_t &x2ism,
472 Float_t &y2ism)
473{
474 // Generate bounding-box.
475
476
477 Float_t xism = 0, yism = 0;
89f0ae35 478 Float_t dxism = 0., dyism = 0.;
2c08d1c1 479
480 const Float_t kRad = 0.25;
481 const Float_t kSqRoot3 = 1.732050808;
482 const Float_t kDia = 0.50;
483
484
485 const Double_t kXcorner[24] =
486 {
487 74.8833, 53.0045, 31.1255, //Type-A
488 74.8833, 53.0045, 31.1255, //Type-A
489 -74.8833, -53.0044, -31.1255, //Type-AR
490 -74.8833, -53.0044, -31.1255, //Type-AR
491 8.9165, -33.7471, //Type-B
492 8.9165, -33.7471, //Type-B
493 8.9165, -33.7471, //Type-B
494 -8.9165, 33.7471, //Type-BR
495 -8.9165, 33.7471, //Type-BR
496 -8.9165, 33.7471, //Type-BR
497 };
498
499
500 const Double_t kYcorner[24] =
501 {
502 86.225, 86.225, 86.225, //Type-A
503 37.075, 37.075, 37.075, //Type-A
504 -86.225, -86.225, -86.225, //Type-AR
505 -37.075, -37.075, -37.075, //Type-AR
506 86.225, 86.225, //Type-B
507 61.075, 61.075, //Type-B
508 35.925, 35.925, //Type-B
509 -86.225, -86.225, //Type-BR
510 -61.075, -61.075, //Type-BR
511 -35.925, -35.925 //Type-BR
512 };
513
514
515 if (ism > 23) ism -= 24;
516
517
518 if (ism < 6)
519 {
520 xism = kXcorner[ism] + kRad;
521 yism = kYcorner[ism] + kRad;
522 dxism = -kRad*kSqRoot3*48.;
523 dyism = -kDia*96. - kRad;
524 }
525 if (ism >= 6 && ism < 12)
526 {
527 xism = kXcorner[ism] - kRad;
528 yism = kYcorner[ism] - kRad;
529 dxism = kRad*kSqRoot3*48.;
530 dyism = kDia*96. + kRad;
531 }
532 if (ism >= 12 && ism < 18)
533 {
534 xism = kXcorner[ism] + kRad;
535 yism = kYcorner[ism] + kRad;
536 dxism = -kRad*kSqRoot3*96.;
537 dyism = -kDia*48. - kRad;
538 }
539 if (ism >= 18 && ism < 24)
540 {
541 xism = kXcorner[ism] - kRad;
542 yism = kYcorner[ism] - kRad;
543 dxism = kRad*kSqRoot3*96.;
544 dyism = kDia*48. + kRad;
545 }
546
547 x1ism = xism;
548 x2ism = xism + dxism;
549 y1ism = yism;
550 y2ism = yism + dyism;
551
552}
553// ------------------------------------------------------------------- //
554
27f6261d 555void AliPMDUtility::DrawPMDModule(Int_t idet)
2c08d1c1 556{
557
be8b7039 558 Float_t x1ism = 0., x2ism = 0., y1ism = 0., y2ism = 0.;
559 Float_t deltaX = 0., deltaY = 0.;
2c08d1c1 560
561 //TH2F *h2 = new TH2F("h2","Y vs. X",200,-100.,100.,200,-100.,100.);
562 //h2->Draw();
563
564 TLine t;
565 t.SetLineColor(2);
566
567 TText tt;
568 tt.SetTextColor(4);
569
570 Char_t smnumber[10];
571
572 for(Int_t ism=0; ism < 24; ism++)
573 {
574 GenerateBoundaryPoints(ism, x1ism, y1ism, x2ism, y2ism);
575 deltaX = (x2ism - x1ism)/2.;
576 deltaY = (y2ism - y1ism)/2.;
577 if (fWriteModule == 1)
578 {
27f6261d 579 if(idet == 0)
580 {
4e2efa25 581 snprintf(smnumber,10,"%d",ism);
27f6261d 582 }
583 else if (idet == 1)
584 {
4e2efa25 585 snprintf(smnumber,10,"%d",24+ism);
27f6261d 586 }
2c08d1c1 587 tt.DrawText(x1ism+deltaX,y1ism+deltaY,smnumber);
588 }
589 t.DrawLine(x1ism, y1ism, x1ism, y2ism);
590 t.DrawLine(x1ism, y1ism, x2ism, y1ism);
591 t.DrawLine(x2ism, y1ism, x2ism, y2ism);
592 t.DrawLine(x1ism, y2ism, x2ism, y2ism);
593 }
594
595}
596
597// ------------------------------------------------------------------- //
598
599
5d35baec 600void AliPMDUtility::ApplyVertexCorrection(Float_t vertex[], Float_t xpos,
601 Float_t ypos, Float_t zpos)
602{
603 // Not implemented
604 fPx = xpos - vertex[0];
605 fPy = ypos - vertex[1];
606 fPz = zpos - vertex[2];
607}
32b0cad8 608void AliPMDUtility::ApplyAlignment(Double_t sectr[][3])
5d35baec 609{
dc461f61 610 // Get the alignment stuff here
611
dc461f61 612 for (Int_t isector=0; isector<4; isector++)
613 {
dc461f61 614 for(Int_t ixyz=0; ixyz < 3; ixyz++)
615 {
32b0cad8 616 fSecTr[isector][ixyz] = (Float_t) sectr[isector][ixyz];
dc461f61 617 }
618 }
5d35baec 619}
638f6e9b 620
a918d77a 621void AliPMDUtility::SetPxPyPz(Float_t px, Float_t py, Float_t pz)
638f6e9b 622{
a918d77a 623 fPx = px;
624 fPy = py;
625 fPz = pz;
638f6e9b 626}
627
a918d77a 628void AliPMDUtility::SetXYZ(Float_t xpos, Float_t ypos, Float_t zpos)
638f6e9b 629{
a918d77a 630 fPx = xpos;
631 fPy = ypos;
632 fPz = zpos;
638f6e9b 633}
2c08d1c1 634void AliPMDUtility::SetWriteModule(Int_t wrmod)
635{
636 fWriteModule = wrmod;
637}
638f6e9b 638void AliPMDUtility::CalculateEta()
639{
be8b7039 640 Float_t rpxpy = TMath::Sqrt(fPx*fPx + fPy*fPy);
641 Float_t theta = TMath::ATan2(rpxpy,fPz);
642 Float_t eta = -TMath::Log(TMath::Tan(0.5*theta));
638f6e9b 643 fTheta = theta;
644 fEta = eta;
645}
646void AliPMDUtility::CalculatePhi()
647{
be8b7039 648 Float_t pybypx = 0., phi = 0., phi1 = 0.;
638f6e9b 649
650 if(fPx==0)
651 {
652 if(fPy>0) phi = 90.;
653 if(fPy<0) phi = 270.;
654 }
655 if(fPx != 0)
656 {
657 pybypx = fPy/fPx;
658 if(pybypx < 0) pybypx = - pybypx;
659 phi1 = TMath::ATan(pybypx)*180./3.14159;
afb8e3a0 660
661 if(fPx > 0 && fPy > 0) phi = phi1; // 1st Quadrant
662 if(fPx < 0 && fPy > 0) phi = 180 - phi1; // 2nd Quadrant
663 if(fPx < 0 && fPy < 0) phi = 180 + phi1; // 3rd Quadrant
664 if(fPx > 0 && fPy < 0) phi = 360 - phi1; // 4th Quadrant
665
638f6e9b 666 }
667 phi = phi*3.14159/180.;
668
669 fPhi = phi;
670
671}
672void AliPMDUtility::CalculateEtaPhi()
673{
be8b7039 674 Float_t pybypx = 0., phi = 0., phi1 = 0.;
638f6e9b 675
be8b7039 676 Float_t rpxpy = TMath::Sqrt(fPx*fPx + fPy*fPy);
677 Float_t theta = TMath::ATan2(rpxpy,fPz);
678 Float_t eta = -TMath::Log(TMath::Tan(0.5*theta));
638f6e9b 679
5d35baec 680 if(fPx == 0)
638f6e9b 681 {
682 if(fPy>0) phi = 90.;
683 if(fPy<0) phi = 270.;
684 }
685 if(fPx != 0)
686 {
687 pybypx = fPy/fPx;
688 if(pybypx < 0) pybypx = - pybypx;
689 phi1 = TMath::ATan(pybypx)*180./3.14159;
afb8e3a0 690 if(fPx > 0 && fPy > 0) phi = phi1; // 1st Quadrant
691 if(fPx < 0 && fPy > 0) phi = 180 - phi1; // 2nd Quadrant
692 if(fPx < 0 && fPy < 0) phi = 180 + phi1; // 3rd Quadrant
693 if(fPx > 0 && fPy < 0) phi = 360 - phi1; // 4th Quadrant
694
638f6e9b 695 }
696 phi = phi*3.14159/180.;
697
698 fTheta = theta;
699 fEta = eta;
700 fPhi = phi;
701}
5d35baec 702void AliPMDUtility::CalculateXY(Float_t eta, Float_t phi, Float_t zpos)
703{
704 // Not implemented
705
706 // eta = -TMath::Log(TMath::Tan(0.5*theta));
707
708 Float_t xpos = 0., ypos = 0.;
709
710 // Float_t theta = 2.0*TMath::ATan(TMath::Log(-eta));
711
712 fEta = eta;
713 fPhi = phi;
714 fPx = xpos;
715 fPy = ypos;
716 fPz = zpos;
717}
6d4a951b 718
719void AliPMDUtility::GetEtaIndexXY(Int_t smn, Int_t row, Int_t col, Float_t &xp, Float_t &yp, Double_t &eta, Int_t &etaindex) {
720 // Takes smn, row, col
721 // Calculates x, y, eta and etabin into 10.
722 // Use only in raw Data.
723
724 Float_t xx = 0., yy = 0.;
725 Int_t xpad = -1, ypad = -1;
726
727 if(smn <12) {
728 xpad = col;
729 ypad = row;
730 }
731 else if(smn >=12 && smn < 24) {
732 xpad = row;
733 ypad = col;
734 }
735
736
737
738 RectGeomCellPos(smn,xpad,ypad,xx,yy);
739 xp = xx;
740 yp = yy;
741
742 Float_t rpxpy = TMath::Sqrt(xx*xx + yy*yy);
743 Float_t theta = TMath::ATan2(rpxpy,365.0);
744 eta = -TMath::Log(TMath::Tan(0.5*theta));
745
746 Int_t etaBin = -1;
747
748 if( eta > 2.1 && eta < 2.3) etaBin = 0;
749 else if( eta > 2.3 && eta < 2.5) etaBin = 1;
750 else if( eta > 2.5 && eta < 2.7) etaBin = 2;
751 else if( eta > 2.7 && eta < 2.9) etaBin = 3;
752 else if( eta > 2.9 && eta < 3.1) etaBin = 4;
753 else if( eta > 3.1 && eta < 3.3) etaBin = 5;
754 else if( eta > 3.3 && eta < 3.5) etaBin = 6;
755 else if( eta > 3.5 && eta < 3.7) etaBin = 7;
756 else if( eta > 3.7 && eta < 3.9) etaBin = 8;
757 else if( eta > 3.9 && eta < 4.1) etaBin = 9;
758 else etaBin = 13;
759
760 etaindex = etaBin;
761
762
763}
764
765//_____________________________________________________
766
638f6e9b 767Float_t AliPMDUtility::GetTheta() const
768{
769 return fTheta;
770}
771Float_t AliPMDUtility::GetEta() const
772{
773 return fEta;
774}
775Float_t AliPMDUtility::GetPhi() const
776{
777 return fPhi;
778}
5d35baec 779Float_t AliPMDUtility::GetX() const
780{
781 return fPx;
782}
783Float_t AliPMDUtility::GetY() const
784{
785 return fPy;
786}
787Float_t AliPMDUtility::GetZ() const
788{
789 return fPz;
790}
dc461f61 791//--------------------------------------------------------------------//