]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PMD/AliPMDUtility.cxx
method RectGeomCellPos in float is added
[u/mrichter/AliRoot.git] / PMD / AliPMDUtility.cxx
CommitLineData
638f6e9b 1//-----------------------------------------------------//
2// //
3// //
4// Date : August 05 2003 //
5// //
6// Utility code for ALICE-PMD //
7// //
8//-----------------------------------------------------//
9
10#include "AliPMDUtility.h"
11#include "TMath.h"
12#include <stdio.h>
13
14ClassImp(AliPMDUtility)
15
16AliPMDUtility::AliPMDUtility()
17{
18 fPx = 0.;
19 fPy = 0.;
20 fPz = 0.;
21 fTheta = 0.;
22 fEta = 0.;
23 fPhi = 0.;
24}
25
26AliPMDUtility::AliPMDUtility(Float_t Px, Float_t Py, Float_t Pz)
27{
28 fPx = Px;
29 fPy = Py;
30 fPz = Pz;
31 fTheta = 0.;
32 fEta = 0.;
33 fPhi = 0.;
34}
35
36AliPMDUtility::~AliPMDUtility()
37{
38
39}
afb8e3a0 40void AliPMDUtility::HexGeomCellPos(Int_t ism, Int_t xpad, Int_t ypad, Float_t &xpos, Float_t &ypos)
41{
42
43 Int_t j = xpad;
44 Int_t k = ypad;
45
46 // Supermodeule number starting from 0
47
48 /*
49 This converts PMD cluster or CELL coordinates
50 to Global coordinates.
51 Written by Prof. S.C. Phatak
52 */
53
54 Int_t i;
55 Float_t celldia = 0.5;
56 const Float_t pi = 3.14159;
57 const double sqrth=0.8660254; // sqrth = sqrt(3.)/2.
58 /*
59 ism --> supermodule no ( 0 - 26 )
60 idet --> detector ( pmd or cpv : not required now )
61 j --> xpad ( goes from 1 to 72 )
62 k --> ypad ( goes from 1 to 72 )
63 xp --> global x coordinate
64 yp --> global y coordinate
65
66 (xp0,yp0) corner positions of all supermodules in global
67 coordinate system. That is the origin
68 of the local ( supermodule ) coordinate system.
69*/
70
71 Float_t xp0[27] =
72 {
73 -17.9084, 18.2166, 54.3416, -35.9709, 0.154144,
74 36.2791, -54.0334, -17.9084, 18.2166, 36.7791,
75 18.7166, 0.654194, 72.9041, 54.8416, 36.7792,
76 109.029, 90.9666, 72.9042, -18.8708, -36.9334,
77 -54.996, -36.9332, -54.9958, -73.0584, -54.9956,
78 -73.0582, -91.1208
79 };
80
81 Float_t yp0[27] =
82 {
83 -32.1395, -32.1395, -32.1395, -63.4247, -63.4247,
84 -63.4247, -94.7098, -94.7098, -94.7098, 0.545689,
85 31.8309, 63.1161, 0.545632, 31.8308, 63.116,
86 0.545573, 31.8308, 63.116, 31.5737, 0.288616,
87 -30.9965, 62.859, 31.5738, 0.288733, 94.1442,
88 62.8591, 31.574
89 };
90
91 /*
92 angles of rotation for three sets of supermodules
93 The angle is same for first nine, next nine and last nine
94 supermodules
95 */
96
97 Float_t th[3] = {0., -2.*pi/3., 2.*pi/3.};
98 Float_t xr, yr, xinit, yinit, cs, sn;
99
100 /*
101 xinit and yinit are coordinates of the cell in local coordinate system
102 */
103
104 xinit = (j)*celldia+(k)/2.*celldia;
105 yinit = sqrth*(k)/2.;
106 i=ism/9;
107 cs=cos(th[i]);
108 sn=sin(th[i]);
109 //
110 // rotate first
111 //
112 xr=cs*xinit+sn*yinit;
113 yr=-sn*xinit+cs*yinit;
114 //
115 // then translate
116 //
117 xpos=xr+xp0[ism];
118 ypos=yr+yp0[ism];
119
120}
121
122void AliPMDUtility::RectGeomCellPos(Int_t ism, Int_t ium, Int_t xpad, Int_t ypad, Float_t &xpos, Float_t &ypos)
123{
124 // This routine finds the cell eta,phi for the new PMD rectangular
125 // geometry in ALICE
126 // Authors : Bedanga Mohanty and Dipak Mishra - 29.4.2003
127 // modified by B. K. Nnadi for change of coordinate sys
128 //
129 // SMA ---> Supermodule Type A ( SM - 0)
130 // SMAR ---> Supermodule Type A ROTATED ( SM - 1)
131 // SMB ---> Supermodule Type B ( SM - 2)
132 // SMBR ---> Supermodule Type B ROTATED ( SM - 3)
133 //
134 // ism : number of supermodules in one plane = 4
135 // ium : number of unitmodules in one SM = 6
136 // gb_um : (global) unit module numbering in a supermodule
137 //
138
139 Int_t gb_um = ism*6 + ium;
140 Int_t irow = xpad;
141 Int_t icol = ypad;
142
143 // Corner positions (x,y) of the 24 unit moudles in ALICE PMD
144
145 double xcorner[24] =
146 {
147 85.15, 60.85, 36.55, 85.15, 60.85, 36.55, //SMA
148 -85.15, -60.85, -36.55, -85.15, -60.85, -36.55, //SMAR
149 84.90, 36.60, 84.90, 36.60, 84.90, 36.60, //SMB
150 -84.90, -36.60, -84.90, -36.60, -84.90, -36.60 //SMBR
151 };
152
153 double ycorner[24] =
154 {
155 32.45708755, 32.45708755, 32.45708755, //SMA
156 -9.30645245, -9.30645245, -9.30645245, //SMA
157 -32.45708755, -32.45708755, -32.45708755, //SMAR
158 9.30645245, 9.30645245, 9.30645245, //SMAR
159 -31.63540818, -31.63540818, -52.61435544, //SMB
160 -52.61435544, -73.59330270, -73.59330270, //SMB
161 31.63540818, 31.63540818, 52.61435544, //SMBR
162 52.61435544, 73.59330270, 73.59330270 //SMBR
163 };
164
165 const Float_t root_3 = 1.73205; // sqrt(3.);
166 const Float_t cell_radius = 0.25;
167
168 //
169 //Every even row of cells is shifted and placed
170 //in geant so this condition
171 //
a2441c6e 172 Float_t shift = 0.0;
afb8e3a0 173 if(irow%2 == 0)
174 {
175 shift = 0.25;
176 }
177 else
178 {
179 shift = 0.0;
180 }
181 if(ism == 0 || ism == 2)
182 {
183 ypos = ycorner[gb_um] +
184 irow*cell_radius*root_3;
185
186 xpos = xcorner[gb_um] -
187 icol*2.0*cell_radius - shift;
188 }
189 else if(ism == 1 || ism == 3)
190 {
191 ypos = ycorner[gb_um] -
192 irow*cell_radius*root_3;
193
194 xpos = xcorner[gb_um] +
a2441c6e 195 icol*2.0*cell_radius + shift;
196 }
197}
198
199void AliPMDUtility::RectGeomCellPos(Int_t ism, Int_t ium, Float_t xpad, Float_t ypad, Float_t &xpos, Float_t &ypos)
200{
201 // If the xpad and ypad inputs are float, then 0.5 is added to it
202 // to find the layer which is shifted.
203 // This routine finds the cell eta,phi for the new PMD rectangular
204 // geometry in ALICE
205 // Authors : Bedanga Mohanty and Dipak Mishra - 29.4.2003
206 // modified by B. K. Nnadi for change of coordinate sys
207 //
208 // SMA ---> Supermodule Type A ( SM - 0)
209 // SMAR ---> Supermodule Type A ROTATED ( SM - 1)
210 // SMB ---> Supermodule Type B ( SM - 2)
211 // SMBR ---> Supermodule Type B ROTATED ( SM - 3)
212 //
213 // ism : number of supermodules in one plane = 4
214 // ium : number of unitmodules in one SM = 6
215 // gb_um : (global) unit module numbering in a supermodule
216 //
217
218 Int_t gb_um = ism*6 + ium;
219 Float_t irow = xpad;
220 Float_t icol = ypad;
221
222 // Corner positions (x,y) of the 24 unit moudles in ALICE PMD
223
224 double xcorner[24] =
225 {
226 85.15, 60.85, 36.55, 85.15, 60.85, 36.55, //SMA
227 -85.15, -60.85, -36.55, -85.15, -60.85, -36.55, //SMAR
228 84.90, 36.60, 84.90, 36.60, 84.90, 36.60, //SMB
229 -84.90, -36.60, -84.90, -36.60, -84.90, -36.60 //SMBR
230 };
231
232 double ycorner[24] =
233 {
234 32.45708755, 32.45708755, 32.45708755, //SMA
235 -9.30645245, -9.30645245, -9.30645245, //SMA
236 -32.45708755, -32.45708755, -32.45708755, //SMAR
237 9.30645245, 9.30645245, 9.30645245, //SMAR
238 -31.63540818, -31.63540818, -52.61435544, //SMB
239 -52.61435544, -73.59330270, -73.59330270, //SMB
240 31.63540818, 31.63540818, 52.61435544, //SMBR
241 52.61435544, 73.59330270, 73.59330270 //SMBR
242 };
243
244 const Float_t root_3 = 1.73205; // sqrt(3.);
245 const Float_t cell_radius = 0.25;
246
247 //
248 //Every even row of cells is shifted and placed
249 //in geant so this condition
250 //
251 Float_t shift = 0.0;
252 Int_t iirow = (Int_t) (irow+0.5);
253 if(iirow%2 == 0)
254 {
255 shift = 0.25;
256 }
257 else
258 {
259 shift = 0.0;
260 }
261 if(ism == 0 || ism == 2)
262 {
263 ypos = ycorner[gb_um] +
264 irow*cell_radius*root_3;
265
266 xpos = xcorner[gb_um] -
267 icol*2.0*cell_radius - shift;
268 }
269 else if(ism == 1 || ism == 3)
270 {
271 ypos = ycorner[gb_um] -
272 irow*cell_radius*root_3;
273
274 xpos = xcorner[gb_um] +
afb8e3a0 275 icol*2.0*cell_radius + shift;
276 }
277}
638f6e9b 278
279void AliPMDUtility::SetPxPyPz(Float_t Px, Float_t Py, Float_t Pz)
280{
281 fPx = Px;
282 fPy = Py;
283 fPz = Pz;
284}
285
286void AliPMDUtility::SetXYZ(Float_t xPos, Float_t yPos, Float_t zPos)
287{
288 fPx = xPos;
289 fPy = yPos;
290 fPz = zPos;
291}
292void AliPMDUtility::CalculateEta()
293{
294 Float_t rpxpy, theta, eta;
295
296 rpxpy = TMath::Sqrt(fPx*fPx + fPy*fPy);
297 theta = TMath::ATan2(rpxpy,fPz);
298 eta = -TMath::Log(TMath::Tan(0.5*theta));
299 fTheta = theta;
300 fEta = eta;
301}
302void AliPMDUtility::CalculatePhi()
303{
304 Float_t pybypx, phi = 0., phi1;
305
306 if(fPx==0)
307 {
308 if(fPy>0) phi = 90.;
309 if(fPy<0) phi = 270.;
310 }
311 if(fPx != 0)
312 {
313 pybypx = fPy/fPx;
314 if(pybypx < 0) pybypx = - pybypx;
315 phi1 = TMath::ATan(pybypx)*180./3.14159;
afb8e3a0 316
317 if(fPx > 0 && fPy > 0) phi = phi1; // 1st Quadrant
318 if(fPx < 0 && fPy > 0) phi = 180 - phi1; // 2nd Quadrant
319 if(fPx < 0 && fPy < 0) phi = 180 + phi1; // 3rd Quadrant
320 if(fPx > 0 && fPy < 0) phi = 360 - phi1; // 4th Quadrant
321
638f6e9b 322 }
323 phi = phi*3.14159/180.;
324
325 fPhi = phi;
326
327}
328void AliPMDUtility::CalculateEtaPhi()
329{
330 Float_t rpxpy, theta, eta;
331 Float_t pybypx, phi = 0., phi1;
332
333 rpxpy = TMath::Sqrt(fPx*fPx + fPy*fPy);
334 theta = TMath::ATan2(rpxpy,fPz);
335 eta = -TMath::Log(TMath::Tan(0.5*theta));
336
337 if(fPx==0)
338 {
339 if(fPy>0) phi = 90.;
340 if(fPy<0) phi = 270.;
341 }
342 if(fPx != 0)
343 {
344 pybypx = fPy/fPx;
345 if(pybypx < 0) pybypx = - pybypx;
346 phi1 = TMath::ATan(pybypx)*180./3.14159;
afb8e3a0 347 if(fPx > 0 && fPy > 0) phi = phi1; // 1st Quadrant
348 if(fPx < 0 && fPy > 0) phi = 180 - phi1; // 2nd Quadrant
349 if(fPx < 0 && fPy < 0) phi = 180 + phi1; // 3rd Quadrant
350 if(fPx > 0 && fPy < 0) phi = 360 - phi1; // 4th Quadrant
351
638f6e9b 352 }
353 phi = phi*3.14159/180.;
354
355 fTheta = theta;
356 fEta = eta;
357 fPhi = phi;
358}
359Float_t AliPMDUtility::GetTheta() const
360{
361 return fTheta;
362}
363Float_t AliPMDUtility::GetEta() const
364{
365 return fEta;
366}
367Float_t AliPMDUtility::GetPhi() const
368{
369 return fPhi;
370}
371