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