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