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 "AliPMDUtility.h" |
26 | #include "TMath.h" |
27 | #include <stdio.h> |
a918d77a |
28 | #include <math.h> |
29 | |
638f6e9b |
30 | |
31 | ClassImp(AliPMDUtility) |
32 | |
5d35baec |
33 | AliPMDUtility::AliPMDUtility(): |
34 | fPx(0.), |
35 | fPy(0.), |
36 | fPz(0.), |
37 | fTheta(0.), |
38 | fEta(0.), |
39 | fPhi(0.) |
638f6e9b |
40 | { |
a918d77a |
41 | // Default constructor |
638f6e9b |
42 | } |
43 | |
5d35baec |
44 | AliPMDUtility::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.) |
638f6e9b |
51 | { |
a918d77a |
52 | // Constructor |
638f6e9b |
53 | } |
5d35baec |
54 | AliPMDUtility::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 | } |
64 | AliPMDUtility & 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 | } |
638f6e9b |
78 | AliPMDUtility::~AliPMDUtility() |
79 | { |
a918d77a |
80 | // Default destructor |
638f6e9b |
81 | } |
afb8e3a0 |
82 | |
01c4d84a |
83 | void AliPMDUtility::RectGeomCellPos(Int_t ism, Int_t xpad, Int_t ypad, Float_t &xpos, Float_t &ypos) |
afb8e3a0 |
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 |
01c4d84a |
88 | // modified by B. K. Nandi for change of coordinate sys |
afb8e3a0 |
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 | // |
01c4d84a |
95 | // ism : Serial module number from 0 to 23 for each plane |
afb8e3a0 |
96 | |
01c4d84a |
97 | |
afb8e3a0 |
98 | // Corner positions (x,y) of the 24 unit moudles in ALICE PMD |
f117e3aa |
99 | |
f117e3aa |
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 | |
afb8e3a0 |
114 | |
f117e3aa |
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 | |
afb8e3a0 |
129 | |
a918d77a |
130 | const Float_t kSqroot3 = 1.73205; // sqrt(3.); |
131 | const Float_t kCellRadius = 0.25; |
afb8e3a0 |
132 | |
133 | // |
134 | //Every even row of cells is shifted and placed |
135 | //in geant so this condition |
136 | // |
f117e3aa |
137 | Float_t cellRadius = 0.25; |
a2441c6e |
138 | Float_t shift = 0.0; |
01c4d84a |
139 | if(xpad%2 == 0) |
afb8e3a0 |
140 | { |
f117e3aa |
141 | shift = -cellRadius/2.0; |
afb8e3a0 |
142 | } |
143 | else |
144 | { |
145 | shift = 0.0; |
146 | } |
afb8e3a0 |
147 | |
01c4d84a |
148 | |
149 | if(ism < 6) |
f117e3aa |
150 | { |
01c4d84a |
151 | ypos = ycorner[ism] - (Float_t) xpad*kCellRadius*2.0 + shift; |
152 | xpos = xcorner[ism] - (Float_t) ypad*kSqroot3*kCellRadius; |
afb8e3a0 |
153 | } |
01c4d84a |
154 | else if(ism >=6 && ism < 12) |
afb8e3a0 |
155 | { |
01c4d84a |
156 | ypos = ycorner[ism] + (Float_t) xpad*kCellRadius*2.0 + shift; |
157 | xpos = xcorner[ism] + (Float_t) ypad*kSqroot3*kCellRadius; |
f117e3aa |
158 | } |
01c4d84a |
159 | else if(ism >= 12 && ism < 18) |
f117e3aa |
160 | { |
01c4d84a |
161 | ypos = ycorner[ism] - (Float_t) xpad*kCellRadius*2.0 + shift; |
162 | xpos = xcorner[ism] - (Float_t) ypad*kSqroot3*kCellRadius; |
a2441c6e |
163 | } |
01c4d84a |
164 | else if(ism >= 18 && ism < 24) |
f117e3aa |
165 | { |
01c4d84a |
166 | ypos = ycorner[ism] + (Float_t) xpad*kCellRadius*2.0 + shift; |
167 | xpos = xcorner[ism] + (Float_t) ypad*kSqroot3*kCellRadius; |
f117e3aa |
168 | } |
169 | |
a2441c6e |
170 | } |
171 | |
01c4d84a |
172 | void AliPMDUtility::RectGeomCellPos(Int_t ism, Float_t xpad, Float_t ypad, Float_t &xpos, Float_t &ypos) |
a2441c6e |
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 | // |
01c4d84a |
186 | // ism : Serial Module number from 0 to 23 for each plane |
a2441c6e |
187 | |
188 | // Corner positions (x,y) of the 24 unit moudles in ALICE PMD |
f117e3aa |
189 | |
f117e3aa |
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 | |
a2441c6e |
204 | |
f117e3aa |
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 | |
a918d77a |
221 | const Float_t kSqroot3 = 1.73205; // sqrt(3.); |
222 | const Float_t kCellRadius = 0.25; |
a2441c6e |
223 | |
224 | // |
225 | //Every even row of cells is shifted and placed |
226 | //in geant so this condition |
227 | // |
f117e3aa |
228 | Float_t cellRadius = 0.25; |
a2441c6e |
229 | Float_t shift = 0.0; |
01c4d84a |
230 | Int_t iirow = (Int_t) (xpad+0.5); |
a2441c6e |
231 | if(iirow%2 == 0) |
232 | { |
f117e3aa |
233 | shift = -cellRadius/2.0; |
a2441c6e |
234 | } |
235 | else |
236 | { |
237 | shift = 0.0; |
238 | } |
a2441c6e |
239 | |
01c4d84a |
240 | if(ism < 6) |
f117e3aa |
241 | { |
01c4d84a |
242 | ypos = ycorner[ism] - xpad*kCellRadius*2.0 + shift; |
243 | xpos = xcorner[ism] - ypad*kSqroot3*kCellRadius; |
a2441c6e |
244 | } |
01c4d84a |
245 | else if(ism >=6 && ism < 12) |
a2441c6e |
246 | { |
01c4d84a |
247 | ypos = ycorner[ism] + xpad*kCellRadius*2.0 + shift; |
248 | xpos = xcorner[ism] + ypad*kSqroot3*kCellRadius; |
f117e3aa |
249 | } |
01c4d84a |
250 | else if(ism >= 12 && ism < 18) |
f117e3aa |
251 | { |
01c4d84a |
252 | ypos = ycorner[ism] - xpad*kCellRadius*2.0 + shift; |
253 | xpos = xcorner[ism] - ypad*kSqroot3*kCellRadius; |
f117e3aa |
254 | } |
01c4d84a |
255 | else if(ism >= 18 && ism < 24) |
f117e3aa |
256 | { |
01c4d84a |
257 | ypos = ycorner[ism] + xpad*kCellRadius*2.0 + shift; |
258 | xpos = xcorner[ism] + ypad*kSqroot3*kCellRadius; |
afb8e3a0 |
259 | } |
f117e3aa |
260 | |
afb8e3a0 |
261 | } |
5d35baec |
262 | void 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 | } |
270 | void AliPMDUtility::ApplyAlignment() |
271 | { |
272 | // Not implemented |
273 | } |
638f6e9b |
274 | |
a918d77a |
275 | void AliPMDUtility::SetPxPyPz(Float_t px, Float_t py, Float_t pz) |
638f6e9b |
276 | { |
a918d77a |
277 | fPx = px; |
278 | fPy = py; |
279 | fPz = pz; |
638f6e9b |
280 | } |
281 | |
a918d77a |
282 | void AliPMDUtility::SetXYZ(Float_t xpos, Float_t ypos, Float_t zpos) |
638f6e9b |
283 | { |
a918d77a |
284 | fPx = xpos; |
285 | fPy = ypos; |
286 | fPz = zpos; |
638f6e9b |
287 | } |
288 | void 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 | } |
298 | void 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; |
afb8e3a0 |
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 | |
638f6e9b |
318 | } |
319 | phi = phi*3.14159/180.; |
320 | |
321 | fPhi = phi; |
322 | |
323 | } |
324 | void 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 | |
5d35baec |
333 | if(fPx == 0) |
638f6e9b |
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; |
afb8e3a0 |
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 | |
638f6e9b |
348 | } |
349 | phi = phi*3.14159/180.; |
350 | |
351 | fTheta = theta; |
352 | fEta = eta; |
353 | fPhi = phi; |
354 | } |
5d35baec |
355 | void 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 | } |
638f6e9b |
371 | Float_t AliPMDUtility::GetTheta() const |
372 | { |
373 | return fTheta; |
374 | } |
375 | Float_t AliPMDUtility::GetEta() const |
376 | { |
377 | return fEta; |
378 | } |
379 | Float_t AliPMDUtility::GetPhi() const |
380 | { |
381 | return fPhi; |
382 | } |
5d35baec |
383 | Float_t AliPMDUtility::GetX() const |
384 | { |
385 | return fPx; |
386 | } |
387 | Float_t AliPMDUtility::GetY() const |
388 | { |
389 | return fPy; |
390 | } |
391 | Float_t AliPMDUtility::GetZ() const |
392 | { |
393 | return fPz; |
394 | } |
638f6e9b |
395 | |