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