]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PMD/AliPMDUtility.cxx
new classes are added
[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 "AliPMDUtility.h"
26 #include "TMath.h"
27 #include <stdio.h>
28 #include <math.h>
29
30
31 ClassImp(AliPMDUtility)
32
33 AliPMDUtility::AliPMDUtility()
34 {
35   // Default constructor
36   fPx    = 0.;
37   fPy    = 0.;
38   fPz    = 0.;
39   fTheta = 0.;
40   fEta   = 0.;
41   fPhi   = 0.;
42 }
43
44 AliPMDUtility::AliPMDUtility(Float_t px, Float_t py, Float_t pz)
45 {
46   // Constructor
47   fPx = px;
48   fPy = py;
49   fPz = pz;
50   fTheta = 0.;
51   fEta   = 0.;
52   fPhi   = 0.;
53 }
54
55 AliPMDUtility::~AliPMDUtility()
56 {
57   // Default destructor
58 }
59
60 void AliPMDUtility::RectGeomCellPos(Int_t ism, Int_t ium, Int_t xpad, Int_t ypad, Float_t &xpos, Float_t &ypos)
61 {
62   // This routine finds the cell eta,phi for the new PMD rectangular 
63   // geometry in ALICE
64   // Authors : Bedanga Mohanty and Dipak Mishra - 29.4.2003
65   // modified by B. K. Nnadi for change of coordinate sys
66   //
67   // SMA  ---> Supermodule Type A           ( SM - 0)
68   // SMAR ---> Supermodule Type A ROTATED   ( SM - 1)
69   // SMB  ---> Supermodule Type B           ( SM - 2)
70   // SMBR ---> Supermodule Type B ROTATED   ( SM - 3)
71   //
72   // ism   : number of supermodules in one plane = 4
73   // ium   : number of unitmodules  in one SM    = 6
74   // gbum  : (global) unit module numbering in a supermodule
75   //
76
77   Int_t gbum = ism*6 + ium;
78   Int_t irow  = xpad;
79   Int_t icol  = ypad;
80
81   // Corner positions (x,y) of the 24 unit moudles in ALICE PMD
82
83
84
85   double xcorner[24] =
86     {
87       74.8833,  53.0045, 31.1255,    //Type-A
88       74.8833,  53.0045, 31.1255,    //Type-A
89       -74.8833, -53.0044, -31.1255,  //Type-AR
90       -74.8833, -53.0044, -31.1255,  //Type-AR
91       8.9165, -33.7471,            //Type-B
92       8.9165, -33.7471,            //Type-B
93       8.9165, -33.7471,            //Type-B
94       -8.9165, 33.7471,            //Type-BR
95       -8.9165, 33.7471,            //Type-BR
96       -8.9165, 33.7471,            //Type-BR
97     };
98
99   
100   double ycorner[24] =
101     {
102       86.225,  86.225,  86.225,      //Type-A
103       37.075,  37.075,  37.075,      //Type-A
104       -86.225, -86.225, -86.225,     //Type-AR
105       -37.075, -37.075, -37.075,     //Type-AR
106       86.225,  86.225,               //Type-B
107       61.075,  61.075,               //Type-B
108       35.925,  35.925,               //Type-B
109       -86.225, -86.225,              //Type-BR
110       -61.075, -61.075,              //Type-BR
111       -35.925, -35.925               //Type-BR
112     };
113
114   
115   const Float_t kSqroot3      = 1.73205;  // sqrt(3.);
116   const Float_t kCellRadius   = 0.25;
117   
118   //
119   //Every even row of cells is shifted and placed
120   //in geant so this condition
121   //
122   Float_t cellRadius = 0.25;
123   Float_t shift = 0.0;
124   if(irow%2 == 0)
125     {
126       shift = -cellRadius/2.0;
127     }
128   else
129     {
130       shift = 0.0;
131     }
132
133   if(ism == 0)
134     {
135       ypos = ycorner[gbum] - irow*kCellRadius*2.0 + shift;
136       xpos = xcorner[gbum] - icol*kSqroot3*kCellRadius;
137     }
138   else if(ism == 1)
139     {
140       ypos = ycorner[gbum] + irow*kCellRadius*2.0 + shift;
141       xpos = xcorner[gbum] + icol*kSqroot3*kCellRadius;
142     }
143   else if(ism == 2)
144     {
145       ypos = ycorner[gbum] - irow*kCellRadius*2.0 + shift;
146       xpos = xcorner[gbum] - icol*kSqroot3*kCellRadius;
147     }
148   else if(ism == 3)
149     {
150       ypos = ycorner[gbum] + irow*kCellRadius*2.0 + shift;
151       xpos = xcorner[gbum] + icol*kSqroot3*kCellRadius;
152     }
153
154 }
155
156 void AliPMDUtility::RectGeomCellPos(Int_t ism, Int_t ium, Float_t xpad, Float_t ypad, Float_t &xpos, Float_t &ypos)
157 {
158   // If the xpad and ypad inputs are float, then 0.5 is added to it
159   // to find the layer which is shifted.
160   // This routine finds the cell eta,phi for the new PMD rectangular 
161   // geometry in ALICE
162   // Authors : Bedanga Mohanty and Dipak Mishra - 29.4.2003
163   // modified by B. K. Nnadi for change of coordinate sys
164   //
165   // SMA  ---> Supermodule Type A           ( SM - 0)
166   // SMAR ---> Supermodule Type A ROTATED   ( SM - 1)
167   // SMB  ---> Supermodule Type B           ( SM - 2)
168   // SMBR ---> Supermodule Type B ROTATED   ( SM - 3)
169   //
170   // ism   : number of supermodules in one plane = 4
171   // ium   : number of unitmodules  in one SM    = 6
172   // gbum  : (global) unit module numbering in a supermodule
173   //
174
175   Int_t gbum    = ism*6 + ium;
176   Float_t irow  = xpad;
177   Float_t icol  = ypad;
178
179   // Corner positions (x,y) of the 24 unit moudles in ALICE PMD
180
181
182   double xcorner[24] =
183     {
184       74.8833,  53.0045, 31.1255,    //Type-A
185       74.8833,  53.0045, 31.1255,    //Type-A
186       -74.8833, -53.0044, -31.1255,  //Type-AR
187       -74.8833, -53.0044, -31.1255,  //Type-AR
188       8.9165, -33.7471,            //Type-B
189       8.9165, -33.7471,            //Type-B
190       8.9165, -33.7471,            //Type-B
191       -8.9165, 33.7471,            //Type-BR
192       -8.9165, 33.7471,            //Type-BR
193       -8.9165, 33.7471,            //Type-BR
194     };
195
196   
197
198   double ycorner[24] =
199     {
200       86.225,  86.225,  86.225,      //Type-A
201       37.075,  37.075,  37.075,      //Type-A
202       -86.225, -86.225, -86.225,     //Type-AR
203       -37.075, -37.075, -37.075,     //Type-AR
204       86.225,  86.225,               //Type-B
205       61.075,  61.075,               //Type-B
206       35.925,  35.925,               //Type-B
207       -86.225, -86.225,              //Type-BR
208       -61.075, -61.075,              //Type-BR
209       -35.925, -35.925               //Type-BR
210     };
211
212
213   const Float_t kSqroot3    = 1.73205;  // sqrt(3.);
214   const Float_t kCellRadius = 0.25;
215   
216   //
217   //Every even row of cells is shifted and placed
218   //in geant so this condition
219   //
220   Float_t cellRadius = 0.25;
221   Float_t shift = 0.0;
222   Int_t iirow = (Int_t) (irow+0.5);
223   if(iirow%2 == 0)
224     {
225       shift = -cellRadius/2.0;
226     }
227   else
228     {
229       shift = 0.0;
230     }
231
232
233   if(ism == 0)
234     {
235       ypos = ycorner[gbum] - irow*kCellRadius*2.0 + shift;
236       xpos = xcorner[gbum] - icol*kSqroot3*kCellRadius;
237     }
238   else if(ism == 1)
239     {
240       ypos = ycorner[gbum] + irow*kCellRadius*2.0 + shift;
241       xpos = xcorner[gbum] + icol*kSqroot3*kCellRadius;
242     }
243   else if(ism == 2)
244     {
245       ypos = ycorner[gbum] - irow*kCellRadius*2.0 + shift;
246       xpos = xcorner[gbum] - icol*kSqroot3*kCellRadius;
247     }
248   else if(ism == 3)
249     {
250       ypos = ycorner[gbum] + irow*kCellRadius*2.0 + shift;
251       xpos = xcorner[gbum] + icol*kSqroot3*kCellRadius;
252     }
253
254
255
256 }
257
258 void AliPMDUtility::SetPxPyPz(Float_t px, Float_t py, Float_t pz)
259 {
260   fPx = px;
261   fPy = py;
262   fPz = pz;
263 }
264
265 void AliPMDUtility::SetXYZ(Float_t xpos, Float_t ypos, Float_t zpos)
266 {
267   fPx = xpos;
268   fPy = ypos;
269   fPz = zpos;
270 }
271 void AliPMDUtility::CalculateEta()
272 {
273   Float_t rpxpy, theta, eta;
274
275   rpxpy  = TMath::Sqrt(fPx*fPx + fPy*fPy);
276   theta  = TMath::ATan2(rpxpy,fPz);
277   eta    = -TMath::Log(TMath::Tan(0.5*theta));
278   fTheta = theta;
279   fEta   = eta;
280 }
281 void AliPMDUtility::CalculatePhi()
282 {
283   Float_t pybypx, phi = 0., phi1;
284
285   if(fPx==0)
286     {
287       if(fPy>0) phi = 90.;
288       if(fPy<0) phi = 270.;
289     }
290   if(fPx != 0)
291     {
292       pybypx = fPy/fPx;
293       if(pybypx < 0) pybypx = - pybypx;
294       phi1 = TMath::ATan(pybypx)*180./3.14159;
295
296       if(fPx > 0 && fPy > 0) phi = phi1;        // 1st Quadrant
297       if(fPx < 0 && fPy > 0) phi = 180 - phi1;  // 2nd Quadrant
298       if(fPx < 0 && fPy < 0) phi = 180 + phi1;  // 3rd Quadrant
299       if(fPx > 0 && fPy < 0) phi = 360 - phi1;  // 4th Quadrant
300
301     }
302   phi = phi*3.14159/180.;
303
304   fPhi = phi;
305
306 }
307 void AliPMDUtility::CalculateEtaPhi()
308 {
309   Float_t rpxpy, theta, eta;
310   Float_t pybypx, phi = 0., phi1;
311
312   rpxpy = TMath::Sqrt(fPx*fPx + fPy*fPy);
313   theta = TMath::ATan2(rpxpy,fPz);
314   eta   = -TMath::Log(TMath::Tan(0.5*theta));
315   
316   if(fPx==0)
317     {
318       if(fPy>0) phi = 90.;
319       if(fPy<0) phi = 270.;
320     }
321   if(fPx != 0)
322     {
323       pybypx = fPy/fPx;
324       if(pybypx < 0) pybypx = - pybypx;
325       phi1 = TMath::ATan(pybypx)*180./3.14159;
326       if(fPx > 0 && fPy > 0) phi = phi1;        // 1st Quadrant
327       if(fPx < 0 && fPy > 0) phi = 180 - phi1;  // 2nd Quadrant
328       if(fPx < 0 && fPy < 0) phi = 180 + phi1;  // 3rd Quadrant
329       if(fPx > 0 && fPy < 0) phi = 360 - phi1;  // 4th Quadrant
330
331     }
332   phi = phi*3.14159/180.;
333
334   fTheta = theta;
335   fEta   = eta;
336   fPhi   = phi;
337 }
338 Float_t AliPMDUtility::GetTheta() const
339 {
340   return fTheta;
341 }
342 Float_t AliPMDUtility::GetEta() const
343 {
344   return fEta;
345 }
346 Float_t AliPMDUtility::GetPhi() const
347 {
348   return fPhi;
349 }
350