1 /***************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 //-----------------------------------------------------//
18 // Date : August 05 2003 //
20 // Utility code for ALICE-PMD //
22 //-----------------------------------------------------//
24 #include "Riostream.h"
25 #include "AliPMDUtility.h"
31 ClassImp(AliPMDUtility)
33 AliPMDUtility::AliPMDUtility():
41 // Default constructor
44 AliPMDUtility::AliPMDUtility(Float_t px, Float_t py, Float_t pz):
54 AliPMDUtility::AliPMDUtility(const AliPMDUtility &pmdutil):
58 fTheta(pmdutil.fTheta),
64 AliPMDUtility & AliPMDUtility::operator=(const AliPMDUtility &pmdutil)
66 // assignment operator
72 fTheta = pmdutil.fTheta;
78 AliPMDUtility::~AliPMDUtility()
83 void AliPMDUtility::RectGeomCellPos(Int_t ism, Int_t xpad, Int_t ypad, Float_t &xpos, Float_t &ypos)
85 // This routine finds the cell eta,phi for the new PMD rectangular
87 // Authors : Bedanga Mohanty and Dipak Mishra - 29.4.2003
88 // modified by B. K. Nandi for change of coordinate sys
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)
95 // ism : Serial module number from 0 to 23 for each plane
98 // Corner positions (x,y) of the 24 unit moudles in ALICE PMD
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
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
130 const Float_t kSqroot3 = 1.73205; // sqrt(3.);
131 const Float_t kCellRadius = 0.25;
134 //Every even row of cells is shifted and placed
135 //in geant so this condition
137 Float_t cellRadius = 0.25;
141 shift = -cellRadius/2.0;
151 ypos = ycorner[ism] - (Float_t) xpad*kCellRadius*2.0 + shift;
152 xpos = xcorner[ism] - (Float_t) ypad*kSqroot3*kCellRadius;
154 else if(ism >=6 && ism < 12)
156 ypos = ycorner[ism] + (Float_t) xpad*kCellRadius*2.0 + shift;
157 xpos = xcorner[ism] + (Float_t) ypad*kSqroot3*kCellRadius;
159 else if(ism >= 12 && ism < 18)
161 ypos = ycorner[ism] - (Float_t) xpad*kCellRadius*2.0 + shift;
162 xpos = xcorner[ism] - (Float_t) ypad*kSqroot3*kCellRadius;
164 else if(ism >= 18 && ism < 24)
166 ypos = ycorner[ism] + (Float_t) xpad*kCellRadius*2.0 + shift;
167 xpos = xcorner[ism] + (Float_t) ypad*kSqroot3*kCellRadius;
172 void AliPMDUtility::RectGeomCellPos(Int_t ism, Float_t xpad, Float_t ypad, Float_t &xpos, Float_t &ypos)
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
178 // Authors : Bedanga Mohanty and Dipak Mishra - 29.4.2003
179 // modified by B. K. Nnadi for change of coordinate sys
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)
186 // ism : Serial Module number from 0 to 23 for each plane
188 // Corner positions (x,y) of the 24 unit moudles in ALICE PMD
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
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
221 const Float_t kSqroot3 = 1.73205; // sqrt(3.);
222 const Float_t kCellRadius = 0.25;
225 //Every even row of cells is shifted and placed
226 //in geant so this condition
228 Float_t cellRadius = 0.25;
230 Int_t iirow = (Int_t) (xpad+0.5);
233 shift = -cellRadius/2.0;
242 ypos = ycorner[ism] - xpad*kCellRadius*2.0 + shift;
243 xpos = xcorner[ism] - ypad*kSqroot3*kCellRadius;
245 else if(ism >=6 && ism < 12)
247 ypos = ycorner[ism] + xpad*kCellRadius*2.0 + shift;
248 xpos = xcorner[ism] + ypad*kSqroot3*kCellRadius;
250 else if(ism >= 12 && ism < 18)
252 ypos = ycorner[ism] - xpad*kCellRadius*2.0 + shift;
253 xpos = xcorner[ism] - ypad*kSqroot3*kCellRadius;
255 else if(ism >= 18 && ism < 24)
257 ypos = ycorner[ism] + xpad*kCellRadius*2.0 + shift;
258 xpos = xcorner[ism] + ypad*kSqroot3*kCellRadius;
262 void AliPMDUtility::ApplyVertexCorrection(Float_t vertex[], Float_t xpos,
263 Float_t ypos, Float_t zpos)
266 fPx = xpos - vertex[0];
267 fPy = ypos - vertex[1];
268 fPz = zpos - vertex[2];
270 void AliPMDUtility::ApplyAlignment()
275 void AliPMDUtility::SetPxPyPz(Float_t px, Float_t py, Float_t pz)
282 void AliPMDUtility::SetXYZ(Float_t xpos, Float_t ypos, Float_t zpos)
288 void AliPMDUtility::CalculateEta()
290 Float_t rpxpy, theta, eta;
292 rpxpy = TMath::Sqrt(fPx*fPx + fPy*fPy);
293 theta = TMath::ATan2(rpxpy,fPz);
294 eta = -TMath::Log(TMath::Tan(0.5*theta));
298 void AliPMDUtility::CalculatePhi()
300 Float_t pybypx, phi = 0., phi1;
305 if(fPy<0) phi = 270.;
310 if(pybypx < 0) pybypx = - pybypx;
311 phi1 = TMath::ATan(pybypx)*180./3.14159;
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
319 phi = phi*3.14159/180.;
324 void AliPMDUtility::CalculateEtaPhi()
326 Float_t rpxpy, theta, eta;
327 Float_t pybypx, phi = 0., phi1;
329 rpxpy = TMath::Sqrt(fPx*fPx + fPy*fPy);
330 theta = TMath::ATan2(rpxpy,fPz);
331 eta = -TMath::Log(TMath::Tan(0.5*theta));
336 if(fPy<0) phi = 270.;
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
349 phi = phi*3.14159/180.;
355 void AliPMDUtility::CalculateXY(Float_t eta, Float_t phi, Float_t zpos)
359 // eta = -TMath::Log(TMath::Tan(0.5*theta));
361 Float_t xpos = 0., ypos = 0.;
363 // Float_t theta = 2.0*TMath::ATan(TMath::Log(-eta));
371 Float_t AliPMDUtility::GetTheta() const
375 Float_t AliPMDUtility::GetEta() const
379 Float_t AliPMDUtility::GetPhi() const
383 Float_t AliPMDUtility::GetX() const
387 Float_t AliPMDUtility::GetY() const
391 Float_t AliPMDUtility::GetZ() const