]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PMD/AliPMDUtility.cxx
variables are initialised at creation
[u/mrichter/AliRoot.git] / PMD / AliPMDUtility.cxx
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 //                                                     //
18 //  Date   : August 05 2003                            //
19 //                                                     //
20 //  Utility code for ALICE-PMD                         //
21 //                                                     //
22 //-----------------------------------------------------//
23
24 #include "Riostream.h"
25 #include "TMath.h"
26 #include "TText.h"
27 #include "TLine.h"
28 #include <TClonesArray.h>
29
30 #include <stdio.h>
31 #include <math.h>
32
33 #include "AliPMDUtility.h"
34 #include "AliAlignObjMatrix.h"
35 #include "AliCDBManager.h"
36 #include "AliCDBEntry.h"
37 #include "AliLog.h"
38
39
40 ClassImp(AliPMDUtility)
41
42 AliPMDUtility::AliPMDUtility():
43   fAlObj(GetAlignObj()),
44   fPx(0.),
45   fPy(0.),
46   fPz(0.),
47   fTheta(0.),
48   fEta(0.),
49   fPhi(0.),
50   fWriteModule(1)
51 {
52   // Default constructor
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
61 }
62
63 AliPMDUtility::AliPMDUtility(Float_t px, Float_t py, Float_t pz):
64   fAlObj(GetAlignObj()),
65   fPx(px),
66   fPy(py),
67   fPz(pz),
68   fTheta(0.),
69   fEta(0.),
70   fPhi(0.),
71   fWriteModule(1)
72 {
73   // Constructor
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
82 }
83 AliPMDUtility::AliPMDUtility(const AliPMDUtility &pmdutil):
84   TObject(pmdutil),
85   fAlObj(pmdutil.GetAlignObj()),
86   fPx(pmdutil.fPx),
87   fPy(pmdutil.fPy),
88   fPz(pmdutil.fPz),
89   fTheta(pmdutil.fTheta),
90   fEta(pmdutil.fEta),
91   fPhi(pmdutil.fPhi),
92   fWriteModule(pmdutil.fWriteModule)
93 {
94   // copy constructor
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
103 }
104 AliPMDUtility & 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;
115       fWriteModule = pmdutil.fWriteModule;
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
124     }
125   return *this;
126 }
127 AliPMDUtility::~AliPMDUtility()
128 {
129   // Default destructor
130 }
131
132 void AliPMDUtility::RectGeomCellPos(Int_t ism, Int_t xpad, Int_t ypad, Float_t &xpos, Float_t &ypos)
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
137   // modified by B. K. Nandi for change of coordinate sys
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   //
144   // ism   : Serial module number from 0 to 23 for each plane
145
146  
147   // Corner positions (x,y) of the 24 unit moudles in ALICE PMD
148
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
163   
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
178   
179   const Float_t kSqroot3      = 1.73205;  // sqrt(3.);
180   const Float_t kCellRadius   = 0.25;
181   
182   //
183   //Every even row of cells is shifted and placed
184   //in geant so this condition
185   //
186   Float_t cellRadius = 0.25;
187   Float_t shift = 0.0;
188   if(xpad%2 == 0)
189     {
190       shift = -cellRadius/2.0;
191     }
192   else
193     {
194       shift = 0.0;
195     }
196
197
198   if(ism < 6)
199     {
200       ypos = ycorner[ism] - (Float_t) xpad*kCellRadius*2.0 + shift;
201       xpos = xcorner[ism] - (Float_t) ypad*kSqroot3*kCellRadius;
202     }
203   else if(ism >=6 && ism < 12)
204     {
205       ypos = ycorner[ism] + (Float_t) xpad*kCellRadius*2.0 + shift;
206       xpos = xcorner[ism] + (Float_t) ypad*kSqroot3*kCellRadius;
207     }
208   else if(ism >= 12 && ism < 18)
209     {
210       ypos = ycorner[ism] - (Float_t) xpad*kCellRadius*2.0 + shift;
211       xpos = xcorner[ism] - (Float_t) ypad*kSqroot3*kCellRadius;
212     }
213   else if(ism >= 18 && ism < 24)
214     {
215       ypos = ycorner[ism] + (Float_t) xpad*kCellRadius*2.0 + shift;
216       xpos = xcorner[ism] + (Float_t) ypad*kSqroot3*kCellRadius;
217     }
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     }
239
240 }
241 // ---------------------------------------------------------- 
242 void AliPMDUtility::RectGeomCellPos(Int_t ism, Float_t xpad, Float_t ypad, Float_t &xpos, Float_t &ypos)
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   //
256   // ism   : Serial Module number from 0 to 23 for each plane
257
258   // Corner positions (x,y) of the 24 unit moudles in ALICE PMD
259
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
274   
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
291   const Float_t kSqroot3    = 1.73205;  // sqrt(3.);
292   const Float_t kCellRadius = 0.25;
293   
294   //
295   //Every even row of cells is shifted and placed
296   //in geant so this condition
297   //
298   Float_t cellRadius = 0.25;
299   Float_t shift = 0.0;
300   Int_t iirow = (Int_t) (xpad+0.5);
301   if(iirow%2 == 0)
302     {
303       shift = -cellRadius/2.0;
304     }
305   else
306     {
307       shift = 0.0;
308     }
309
310   if(ism < 6)
311     {
312       ypos = ycorner[ism] - xpad*kCellRadius*2.0 + shift;
313       xpos = xcorner[ism] - ypad*kSqroot3*kCellRadius;
314     }
315   else if(ism >=6 && ism < 12)
316     {
317       ypos = ycorner[ism] + xpad*kCellRadius*2.0 + shift;
318       xpos = xcorner[ism] + ypad*kSqroot3*kCellRadius;
319     }
320   else if(ism >= 12 && ism < 18)
321     {
322       ypos = ycorner[ism] - xpad*kCellRadius*2.0 + shift;
323       xpos = xcorner[ism] - ypad*kSqroot3*kCellRadius;
324     }
325   else if(ism >= 18 && ism < 24)
326     {
327       ypos = ycorner[ism] + xpad*kCellRadius*2.0 + shift;
328       xpos = xcorner[ism] + ypad*kSqroot3*kCellRadius;
329     }
330
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
357 void 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
476 }
477 // -------------------------------------------------------- //
478
479 void 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;
487     Float_t dxism = 0., dyism = 0.;
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
564 void AliPMDUtility::DrawPMDModule(Int_t idet)
565 {
566
567     Float_t x1ism = 0., x2ism = 0., y1ism = 0., y2ism = 0.;
568     Float_t deltaX = 0., deltaY = 0.;
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         {
588           if(idet == 0)
589             {
590               sprintf(smnumber,"%d",ism);
591             }
592           else if (idet == 1)
593             {
594               sprintf(smnumber,"%d",24+ism);
595             }
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
609 void 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 }
617 void AliPMDUtility::ApplyAlignment()
618 {
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     }
635 }
636
637 void AliPMDUtility::SetPxPyPz(Float_t px, Float_t py, Float_t pz)
638 {
639   fPx = px;
640   fPy = py;
641   fPz = pz;
642 }
643
644 void AliPMDUtility::SetXYZ(Float_t xpos, Float_t ypos, Float_t zpos)
645 {
646   fPx = xpos;
647   fPy = ypos;
648   fPz = zpos;
649 }
650 void AliPMDUtility::SetWriteModule(Int_t wrmod)
651 {
652     fWriteModule = wrmod;
653 }
654 void AliPMDUtility::CalculateEta()
655 {
656   Float_t rpxpy  = TMath::Sqrt(fPx*fPx + fPy*fPy);
657   Float_t theta  = TMath::ATan2(rpxpy,fPz);
658   Float_t eta    = -TMath::Log(TMath::Tan(0.5*theta));
659   fTheta = theta;
660   fEta   = eta;
661 }
662 void AliPMDUtility::CalculatePhi()
663 {
664   Float_t pybypx = 0., phi = 0., phi1 = 0.;
665
666   if(fPx==0)
667     {
668       if(fPy>0) phi = 90.;
669       if(fPy<0) phi = 270.;
670     }
671   if(fPx != 0)
672     {
673       pybypx = fPy/fPx;
674       if(pybypx < 0) pybypx = - pybypx;
675       phi1 = TMath::ATan(pybypx)*180./3.14159;
676
677       if(fPx > 0 && fPy > 0) phi = phi1;        // 1st Quadrant
678       if(fPx < 0 && fPy > 0) phi = 180 - phi1;  // 2nd Quadrant
679       if(fPx < 0 && fPy < 0) phi = 180 + phi1;  // 3rd Quadrant
680       if(fPx > 0 && fPy < 0) phi = 360 - phi1;  // 4th Quadrant
681
682     }
683   phi = phi*3.14159/180.;
684
685   fPhi = phi;
686
687 }
688 void AliPMDUtility::CalculateEtaPhi()
689 {
690   Float_t pybypx = 0., phi = 0., phi1 = 0.;
691
692   Float_t rpxpy = TMath::Sqrt(fPx*fPx + fPy*fPy);
693   Float_t theta = TMath::ATan2(rpxpy,fPz);
694   Float_t eta   = -TMath::Log(TMath::Tan(0.5*theta));
695   
696   if(fPx == 0)
697     {
698       if(fPy>0) phi = 90.;
699       if(fPy<0) phi = 270.;
700     }
701   if(fPx != 0)
702     {
703       pybypx = fPy/fPx;
704       if(pybypx < 0) pybypx = - pybypx;
705       phi1 = TMath::ATan(pybypx)*180./3.14159;
706       if(fPx > 0 && fPy > 0) phi = phi1;        // 1st Quadrant
707       if(fPx < 0 && fPy > 0) phi = 180 - phi1;  // 2nd Quadrant
708       if(fPx < 0 && fPy < 0) phi = 180 + phi1;  // 3rd Quadrant
709       if(fPx > 0 && fPy < 0) phi = 360 - phi1;  // 4th Quadrant
710
711     }
712   phi = phi*3.14159/180.;
713
714   fTheta = theta;
715   fEta   = eta;
716   fPhi   = phi;
717 }
718 void AliPMDUtility::CalculateXY(Float_t eta, Float_t phi, Float_t zpos)
719 {
720   // Not implemented
721
722   //  eta   = -TMath::Log(TMath::Tan(0.5*theta));
723
724   Float_t xpos = 0., ypos = 0.;
725
726   //  Float_t theta = 2.0*TMath::ATan(TMath::Log(-eta));
727
728   fEta = eta;
729   fPhi = phi;
730   fPx  = xpos;
731   fPy  = ypos;
732   fPz  = zpos;
733 }
734 Float_t AliPMDUtility::GetTheta() const
735 {
736   return fTheta;
737 }
738 Float_t AliPMDUtility::GetEta() const
739 {
740   return fEta;
741 }
742 Float_t AliPMDUtility::GetPhi() const
743 {
744   return fPhi;
745 }
746 Float_t AliPMDUtility::GetX() const
747 {
748   return fPx;
749 }
750 Float_t AliPMDUtility::GetY() const
751 {
752   return fPy;
753 }
754 Float_t AliPMDUtility::GetZ() const
755 {
756   return fPz;
757 }
758 //--------------------------------------------------------------------//
759 TClonesArray* AliPMDUtility::GetAlignObj() const
760 {
761   // The run number will be centralized in AliCDBManager,
762   // you don't need to set it here!
763   AliCDBEntry  *entry = AliCDBManager::Instance()->Get("PMD/Align/Data");
764   
765   if(!entry) AliFatal("Alignment object retrieval failed!");
766   
767   TClonesArray *alobj = 0;
768   if (entry) alobj = (TClonesArray*) entry->GetObject();
769   
770   if (!alobj)  AliFatal("No alignment data from  database !");
771   
772   return alobj;
773 }
774
775