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"
32 #include "AliPMDUtility.h"
35 ClassImp(AliPMDUtility)
37 AliPMDUtility::AliPMDUtility():
46 // Default constructor
49 AliPMDUtility::AliPMDUtility(Float_t px, Float_t py, Float_t pz):
60 AliPMDUtility::AliPMDUtility(const AliPMDUtility &pmdutil):
64 fTheta(pmdutil.fTheta),
67 fWriteModule(pmdutil.fWriteModule)
71 AliPMDUtility & AliPMDUtility::operator=(const AliPMDUtility &pmdutil)
73 // assignment operator
79 fTheta = pmdutil.fTheta;
82 fWriteModule = pmdutil.fWriteModule;
86 AliPMDUtility::~AliPMDUtility()
91 void AliPMDUtility::RectGeomCellPos(Int_t ism, Int_t xpad, Int_t ypad, Float_t &xpos, Float_t &ypos)
93 // This routine finds the cell eta,phi for the new PMD rectangular
95 // Authors : Bedanga Mohanty and Dipak Mishra - 29.4.2003
96 // modified by B. K. Nandi for change of coordinate sys
98 // SMA ---> Supermodule Type A ( SM - 0)
99 // SMAR ---> Supermodule Type A ROTATED ( SM - 1)
100 // SMB ---> Supermodule Type B ( SM - 2)
101 // SMBR ---> Supermodule Type B ROTATED ( SM - 3)
103 // ism : Serial module number from 0 to 23 for each plane
106 // Corner positions (x,y) of the 24 unit moudles in ALICE PMD
110 74.8833, 53.0045, 31.1255, //Type-A
111 74.8833, 53.0045, 31.1255, //Type-A
112 -74.8833, -53.0044, -31.1255, //Type-AR
113 -74.8833, -53.0044, -31.1255, //Type-AR
114 8.9165, -33.7471, //Type-B
115 8.9165, -33.7471, //Type-B
116 8.9165, -33.7471, //Type-B
117 -8.9165, 33.7471, //Type-BR
118 -8.9165, 33.7471, //Type-BR
119 -8.9165, 33.7471, //Type-BR
125 86.225, 86.225, 86.225, //Type-A
126 37.075, 37.075, 37.075, //Type-A
127 -86.225, -86.225, -86.225, //Type-AR
128 -37.075, -37.075, -37.075, //Type-AR
129 86.225, 86.225, //Type-B
130 61.075, 61.075, //Type-B
131 35.925, 35.925, //Type-B
132 -86.225, -86.225, //Type-BR
133 -61.075, -61.075, //Type-BR
134 -35.925, -35.925 //Type-BR
138 const Float_t kSqroot3 = 1.73205; // sqrt(3.);
139 const Float_t kCellRadius = 0.25;
142 //Every even row of cells is shifted and placed
143 //in geant so this condition
145 Float_t cellRadius = 0.25;
149 shift = -cellRadius/2.0;
159 ypos = ycorner[ism] - (Float_t) xpad*kCellRadius*2.0 + shift;
160 xpos = xcorner[ism] - (Float_t) ypad*kSqroot3*kCellRadius;
162 else if(ism >=6 && ism < 12)
164 ypos = ycorner[ism] + (Float_t) xpad*kCellRadius*2.0 + shift;
165 xpos = xcorner[ism] + (Float_t) ypad*kSqroot3*kCellRadius;
167 else if(ism >= 12 && ism < 18)
169 ypos = ycorner[ism] - (Float_t) xpad*kCellRadius*2.0 + shift;
170 xpos = xcorner[ism] - (Float_t) ypad*kSqroot3*kCellRadius;
172 else if(ism >= 18 && ism < 24)
174 ypos = ycorner[ism] + (Float_t) xpad*kCellRadius*2.0 + shift;
175 xpos = xcorner[ism] + (Float_t) ypad*kSqroot3*kCellRadius;
180 void AliPMDUtility::RectGeomCellPos(Int_t ism, Float_t xpad, Float_t ypad, Float_t &xpos, Float_t &ypos)
182 // If the xpad and ypad inputs are float, then 0.5 is added to it
183 // to find the layer which is shifted.
184 // This routine finds the cell eta,phi for the new PMD rectangular
186 // Authors : Bedanga Mohanty and Dipak Mishra - 29.4.2003
187 // modified by B. K. Nnadi for change of coordinate sys
189 // SMA ---> Supermodule Type A ( SM - 0)
190 // SMAR ---> Supermodule Type A ROTATED ( SM - 1)
191 // SMB ---> Supermodule Type B ( SM - 2)
192 // SMBR ---> Supermodule Type B ROTATED ( SM - 3)
194 // ism : Serial Module number from 0 to 23 for each plane
196 // Corner positions (x,y) of the 24 unit moudles in ALICE PMD
200 74.8833, 53.0045, 31.1255, //Type-A
201 74.8833, 53.0045, 31.1255, //Type-A
202 -74.8833, -53.0044, -31.1255, //Type-AR
203 -74.8833, -53.0044, -31.1255, //Type-AR
204 8.9165, -33.7471, //Type-B
205 8.9165, -33.7471, //Type-B
206 8.9165, -33.7471, //Type-B
207 -8.9165, 33.7471, //Type-BR
208 -8.9165, 33.7471, //Type-BR
209 -8.9165, 33.7471, //Type-BR
216 86.225, 86.225, 86.225, //Type-A
217 37.075, 37.075, 37.075, //Type-A
218 -86.225, -86.225, -86.225, //Type-AR
219 -37.075, -37.075, -37.075, //Type-AR
220 86.225, 86.225, //Type-B
221 61.075, 61.075, //Type-B
222 35.925, 35.925, //Type-B
223 -86.225, -86.225, //Type-BR
224 -61.075, -61.075, //Type-BR
225 -35.925, -35.925 //Type-BR
229 const Float_t kSqroot3 = 1.73205; // sqrt(3.);
230 const Float_t kCellRadius = 0.25;
233 //Every even row of cells is shifted and placed
234 //in geant so this condition
236 Float_t cellRadius = 0.25;
238 Int_t iirow = (Int_t) (xpad+0.5);
241 shift = -cellRadius/2.0;
250 ypos = ycorner[ism] - xpad*kCellRadius*2.0 + shift;
251 xpos = xcorner[ism] - ypad*kSqroot3*kCellRadius;
253 else if(ism >=6 && ism < 12)
255 ypos = ycorner[ism] + xpad*kCellRadius*2.0 + shift;
256 xpos = xcorner[ism] + ypad*kSqroot3*kCellRadius;
258 else if(ism >= 12 && ism < 18)
260 ypos = ycorner[ism] - xpad*kCellRadius*2.0 + shift;
261 xpos = xcorner[ism] - ypad*kSqroot3*kCellRadius;
263 else if(ism >= 18 && ism < 24)
265 ypos = ycorner[ism] + xpad*kCellRadius*2.0 + shift;
266 xpos = xcorner[ism] + ypad*kSqroot3*kCellRadius;
270 // -------------------------------------------------------- //
272 void AliPMDUtility::GenerateBoundaryPoints(Int_t ism, Float_t &x1ism,
273 Float_t &y1ism, Float_t &x2ism,
276 // Generate bounding-box.
279 Float_t xism = 0, yism = 0;
280 Float_t dxism = 0., dyism = 0.;
282 const Float_t kRad = 0.25;
283 const Float_t kSqRoot3 = 1.732050808;
284 const Float_t kDia = 0.50;
287 const Double_t kXcorner[24] =
289 74.8833, 53.0045, 31.1255, //Type-A
290 74.8833, 53.0045, 31.1255, //Type-A
291 -74.8833, -53.0044, -31.1255, //Type-AR
292 -74.8833, -53.0044, -31.1255, //Type-AR
293 8.9165, -33.7471, //Type-B
294 8.9165, -33.7471, //Type-B
295 8.9165, -33.7471, //Type-B
296 -8.9165, 33.7471, //Type-BR
297 -8.9165, 33.7471, //Type-BR
298 -8.9165, 33.7471, //Type-BR
302 const Double_t kYcorner[24] =
304 86.225, 86.225, 86.225, //Type-A
305 37.075, 37.075, 37.075, //Type-A
306 -86.225, -86.225, -86.225, //Type-AR
307 -37.075, -37.075, -37.075, //Type-AR
308 86.225, 86.225, //Type-B
309 61.075, 61.075, //Type-B
310 35.925, 35.925, //Type-B
311 -86.225, -86.225, //Type-BR
312 -61.075, -61.075, //Type-BR
313 -35.925, -35.925 //Type-BR
317 if (ism > 23) ism -= 24;
322 xism = kXcorner[ism] + kRad;
323 yism = kYcorner[ism] + kRad;
324 dxism = -kRad*kSqRoot3*48.;
325 dyism = -kDia*96. - kRad;
327 if (ism >= 6 && ism < 12)
329 xism = kXcorner[ism] - kRad;
330 yism = kYcorner[ism] - kRad;
331 dxism = kRad*kSqRoot3*48.;
332 dyism = kDia*96. + kRad;
334 if (ism >= 12 && ism < 18)
336 xism = kXcorner[ism] + kRad;
337 yism = kYcorner[ism] + kRad;
338 dxism = -kRad*kSqRoot3*96.;
339 dyism = -kDia*48. - kRad;
341 if (ism >= 18 && ism < 24)
343 xism = kXcorner[ism] - kRad;
344 yism = kYcorner[ism] - kRad;
345 dxism = kRad*kSqRoot3*96.;
346 dyism = kDia*48. + kRad;
350 x2ism = xism + dxism;
352 y2ism = yism + dyism;
355 // ------------------------------------------------------------------- //
357 void AliPMDUtility::DrawPMDModule()
360 Float_t x1ism, x2ism, y1ism, y2ism;
361 Float_t deltaX, deltaY;
363 //TH2F *h2 = new TH2F("h2","Y vs. X",200,-100.,100.,200,-100.,100.);
374 for(Int_t ism=0; ism < 24; ism++)
376 GenerateBoundaryPoints(ism, x1ism, y1ism, x2ism, y2ism);
377 deltaX = (x2ism - x1ism)/2.;
378 deltaY = (y2ism - y1ism)/2.;
379 if (fWriteModule == 1)
381 sprintf(smnumber,"%d",ism);
382 tt.DrawText(x1ism+deltaX,y1ism+deltaY,smnumber);
384 t.DrawLine(x1ism, y1ism, x1ism, y2ism);
385 t.DrawLine(x1ism, y1ism, x2ism, y1ism);
386 t.DrawLine(x2ism, y1ism, x2ism, y2ism);
387 t.DrawLine(x1ism, y2ism, x2ism, y2ism);
392 // ------------------------------------------------------------------- //
395 void AliPMDUtility::ApplyVertexCorrection(Float_t vertex[], Float_t xpos,
396 Float_t ypos, Float_t zpos)
399 fPx = xpos - vertex[0];
400 fPy = ypos - vertex[1];
401 fPz = zpos - vertex[2];
403 void AliPMDUtility::ApplyAlignment()
408 void AliPMDUtility::SetPxPyPz(Float_t px, Float_t py, Float_t pz)
415 void AliPMDUtility::SetXYZ(Float_t xpos, Float_t ypos, Float_t zpos)
421 void AliPMDUtility::SetWriteModule(Int_t wrmod)
423 fWriteModule = wrmod;
425 void AliPMDUtility::CalculateEta()
427 Float_t rpxpy, theta, eta;
429 rpxpy = TMath::Sqrt(fPx*fPx + fPy*fPy);
430 theta = TMath::ATan2(rpxpy,fPz);
431 eta = -TMath::Log(TMath::Tan(0.5*theta));
435 void AliPMDUtility::CalculatePhi()
437 Float_t pybypx, phi = 0., phi1;
442 if(fPy<0) phi = 270.;
447 if(pybypx < 0) pybypx = - pybypx;
448 phi1 = TMath::ATan(pybypx)*180./3.14159;
450 if(fPx > 0 && fPy > 0) phi = phi1; // 1st Quadrant
451 if(fPx < 0 && fPy > 0) phi = 180 - phi1; // 2nd Quadrant
452 if(fPx < 0 && fPy < 0) phi = 180 + phi1; // 3rd Quadrant
453 if(fPx > 0 && fPy < 0) phi = 360 - phi1; // 4th Quadrant
456 phi = phi*3.14159/180.;
461 void AliPMDUtility::CalculateEtaPhi()
463 Float_t rpxpy, theta, eta;
464 Float_t pybypx, phi = 0., phi1;
466 rpxpy = TMath::Sqrt(fPx*fPx + fPy*fPy);
467 theta = TMath::ATan2(rpxpy,fPz);
468 eta = -TMath::Log(TMath::Tan(0.5*theta));
473 if(fPy<0) phi = 270.;
478 if(pybypx < 0) pybypx = - pybypx;
479 phi1 = TMath::ATan(pybypx)*180./3.14159;
480 if(fPx > 0 && fPy > 0) phi = phi1; // 1st Quadrant
481 if(fPx < 0 && fPy > 0) phi = 180 - phi1; // 2nd Quadrant
482 if(fPx < 0 && fPy < 0) phi = 180 + phi1; // 3rd Quadrant
483 if(fPx > 0 && fPy < 0) phi = 360 - phi1; // 4th Quadrant
486 phi = phi*3.14159/180.;
492 void AliPMDUtility::CalculateXY(Float_t eta, Float_t phi, Float_t zpos)
496 // eta = -TMath::Log(TMath::Tan(0.5*theta));
498 Float_t xpos = 0., ypos = 0.;
500 // Float_t theta = 2.0*TMath::ATan(TMath::Log(-eta));
508 Float_t AliPMDUtility::GetTheta() const
512 Float_t AliPMDUtility::GetEta() const
516 Float_t AliPMDUtility::GetPhi() const
520 Float_t AliPMDUtility::GetX() const
524 Float_t AliPMDUtility::GetY() const
528 Float_t AliPMDUtility::GetZ() const