New version of the PMD geometry (Basanta)
[u/mrichter/AliRoot.git] / PMD / AliPMDUtility.cxx
CommitLineData
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
31ClassImp(AliPMDUtility)
32
33AliPMDUtility::AliPMDUtility()
34{
a918d77a 35 // Default constructor
638f6e9b 36 fPx = 0.;
37 fPy = 0.;
38 fPz = 0.;
39 fTheta = 0.;
40 fEta = 0.;
41 fPhi = 0.;
42}
43
a918d77a 44AliPMDUtility::AliPMDUtility(Float_t px, Float_t py, Float_t pz)
638f6e9b 45{
a918d77a 46 // Constructor
47 fPx = px;
48 fPy = py;
49 fPz = pz;
638f6e9b 50 fTheta = 0.;
51 fEta = 0.;
52 fPhi = 0.;
53}
54
55AliPMDUtility::~AliPMDUtility()
56{
a918d77a 57 // Default destructor
638f6e9b 58}
afb8e3a0 59
60void 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
a918d77a 74 // gbum : (global) unit module numbering in a supermodule
afb8e3a0 75 //
76
a918d77a 77 Int_t gbum = ism*6 + ium;
afb8e3a0 78 Int_t irow = xpad;
79 Int_t icol = ypad;
80
81 // Corner positions (x,y) of the 24 unit moudles in ALICE PMD
f117e3aa 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
afb8e3a0 99
f117e3aa 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
afb8e3a0 114
a918d77a 115 const Float_t kSqroot3 = 1.73205; // sqrt(3.);
116 const Float_t kCellRadius = 0.25;
afb8e3a0 117
118 //
119 //Every even row of cells is shifted and placed
120 //in geant so this condition
121 //
f117e3aa 122 Float_t cellRadius = 0.25;
a2441c6e 123 Float_t shift = 0.0;
afb8e3a0 124 if(irow%2 == 0)
125 {
f117e3aa 126 shift = -cellRadius/2.0;
afb8e3a0 127 }
128 else
129 {
130 shift = 0.0;
131 }
afb8e3a0 132
f117e3aa 133 if(ism == 0)
134 {
135 ypos = ycorner[gbum] - irow*kCellRadius*2.0 + shift;
136 xpos = xcorner[gbum] - icol*kSqroot3*kCellRadius;
afb8e3a0 137 }
f117e3aa 138 else if(ism == 1)
afb8e3a0 139 {
f117e3aa 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;
a2441c6e 147 }
f117e3aa 148 else if(ism == 3)
149 {
150 ypos = ycorner[gbum] + irow*kCellRadius*2.0 + shift;
151 xpos = xcorner[gbum] + icol*kSqroot3*kCellRadius;
152 }
153
a2441c6e 154}
155
156void 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
a918d77a 172 // gbum : (global) unit module numbering in a supermodule
a2441c6e 173 //
174
a918d77a 175 Int_t gbum = ism*6 + ium;
a2441c6e 176 Float_t irow = xpad;
177 Float_t icol = ypad;
178
179 // Corner positions (x,y) of the 24 unit moudles in ALICE PMD
f117e3aa 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
a2441c6e 196
f117e3aa 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
a918d77a 213 const Float_t kSqroot3 = 1.73205; // sqrt(3.);
214 const Float_t kCellRadius = 0.25;
a2441c6e 215
216 //
217 //Every even row of cells is shifted and placed
218 //in geant so this condition
219 //
f117e3aa 220 Float_t cellRadius = 0.25;
a2441c6e 221 Float_t shift = 0.0;
222 Int_t iirow = (Int_t) (irow+0.5);
223 if(iirow%2 == 0)
224 {
f117e3aa 225 shift = -cellRadius/2.0;
a2441c6e 226 }
227 else
228 {
229 shift = 0.0;
230 }
a2441c6e 231
f117e3aa 232
233 if(ism == 0)
234 {
235 ypos = ycorner[gbum] - irow*kCellRadius*2.0 + shift;
236 xpos = xcorner[gbum] - icol*kSqroot3*kCellRadius;
a2441c6e 237 }
f117e3aa 238 else if(ism == 1)
a2441c6e 239 {
f117e3aa 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;
afb8e3a0 252 }
f117e3aa 253
254
255
afb8e3a0 256}
638f6e9b 257
a918d77a 258void AliPMDUtility::SetPxPyPz(Float_t px, Float_t py, Float_t pz)
638f6e9b 259{
a918d77a 260 fPx = px;
261 fPy = py;
262 fPz = pz;
638f6e9b 263}
264
a918d77a 265void AliPMDUtility::SetXYZ(Float_t xpos, Float_t ypos, Float_t zpos)
638f6e9b 266{
a918d77a 267 fPx = xpos;
268 fPy = ypos;
269 fPz = zpos;
638f6e9b 270}
271void 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}
281void 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;
afb8e3a0 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
638f6e9b 301 }
302 phi = phi*3.14159/180.;
303
304 fPhi = phi;
305
306}
307void 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;
afb8e3a0 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
638f6e9b 331 }
332 phi = phi*3.14159/180.;
333
334 fTheta = theta;
335 fEta = eta;
336 fPhi = phi;
337}
338Float_t AliPMDUtility::GetTheta() const
339{
340 return fTheta;
341}
342Float_t AliPMDUtility::GetEta() const
343{
344 return fEta;
345}
346Float_t AliPMDUtility::GetPhi() const
347{
348 return fPhi;
349}
350