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"
34 ClassImp(AliPMDUtility)
36 AliPMDUtility::AliPMDUtility():
45 // Default constructor
46 for (Int_t i = 0; i < 4; i++)
48 for (Int_t j = 0; j < 3; j++)
56 AliPMDUtility::AliPMDUtility(Float_t px, Float_t py, Float_t pz):
66 for (Int_t i = 0; i < 4; i++)
68 for (Int_t j = 0; j < 3; j++)
75 AliPMDUtility::AliPMDUtility(const AliPMDUtility &pmdutil):
80 fTheta(pmdutil.fTheta),
83 fWriteModule(pmdutil.fWriteModule)
86 for (Int_t i = 0; i < 4; i++)
88 for (Int_t j = 0; j < 3; j++)
90 fSecTr[i][j] = pmdutil.fSecTr[i][j];
95 AliPMDUtility & AliPMDUtility::operator=(const AliPMDUtility &pmdutil)
97 // assignment operator
103 fTheta = pmdutil.fTheta;
106 fWriteModule = pmdutil.fWriteModule;
107 for (Int_t i = 0; i < 4; i++)
109 for (Int_t j = 0; j < 3; j++)
111 fSecTr[i][j] = pmdutil.fSecTr[i][j];
118 AliPMDUtility::~AliPMDUtility()
120 // Default destructor
123 void AliPMDUtility::RectGeomCellPos(Int_t ism, Int_t xpad, Int_t ypad, Float_t &xpos, Float_t &ypos)
125 // This routine finds the cell eta,phi for the new PMD rectangular
127 // Authors : Bedanga Mohanty and Dipak Mishra - 29.4.2003
128 // modified by B. K. Nandi for change of coordinate sys
130 // SMA ---> Supermodule Type A ( SM - 0)
131 // SMAR ---> Supermodule Type A ROTATED ( SM - 1)
132 // SMB ---> Supermodule Type B ( SM - 2)
133 // SMBR ---> Supermodule Type B ROTATED ( SM - 3)
135 // ism : Serial module number from 0 to 23 for each plane
138 // Corner positions (x,y) of the 24 unit moudles in ALICE PMD
142 74.8833, 53.0045, 31.1255, //Type-A
143 74.8833, 53.0045, 31.1255, //Type-A
144 -74.8833, -53.0044, -31.1255, //Type-AR
145 -74.8833, -53.0044, -31.1255, //Type-AR
146 8.9165, -33.7471, //Type-B
147 8.9165, -33.7471, //Type-B
148 8.9165, -33.7471, //Type-B
149 -8.9165, 33.7471, //Type-BR
150 -8.9165, 33.7471, //Type-BR
151 -8.9165, 33.7471, //Type-BR
157 86.225, 86.225, 86.225, //Type-A
158 37.075, 37.075, 37.075, //Type-A
159 -86.225, -86.225, -86.225, //Type-AR
160 -37.075, -37.075, -37.075, //Type-AR
161 86.225, 86.225, //Type-B
162 61.075, 61.075, //Type-B
163 35.925, 35.925, //Type-B
164 -86.225, -86.225, //Type-BR
165 -61.075, -61.075, //Type-BR
166 -35.925, -35.925 //Type-BR
170 const Float_t kSqroot3 = 1.73205; // sqrt(3.);
171 const Float_t kCellRadius = 0.25;
174 //Every even row of cells is shifted and placed
175 //in geant so this condition
177 Float_t cellRadius = 0.25;
181 shift = -cellRadius/2.0;
191 ypos = ycorner[ism] - (Float_t) xpad*kCellRadius*2.0 + shift;
192 xpos = xcorner[ism] - (Float_t) ypad*kSqroot3*kCellRadius;
194 else if(ism >=6 && ism < 12)
196 ypos = ycorner[ism] + (Float_t) xpad*kCellRadius*2.0 + shift;
197 xpos = xcorner[ism] + (Float_t) ypad*kSqroot3*kCellRadius;
199 else if(ism >= 12 && ism < 18)
201 ypos = ycorner[ism] - (Float_t) xpad*kCellRadius*2.0 + shift;
202 xpos = xcorner[ism] - (Float_t) ypad*kSqroot3*kCellRadius;
204 else if(ism >= 18 && ism < 24)
206 ypos = ycorner[ism] + (Float_t) xpad*kCellRadius*2.0 + shift;
207 xpos = xcorner[ism] + (Float_t) ypad*kSqroot3*kCellRadius;
209 // Apply the alignment here to the x, y values
212 xpos += fSecTr[0][0];
213 ypos += fSecTr[0][1];
215 else if(ism >= 6 && ism < 12)
217 xpos += fSecTr[1][0];
218 ypos += fSecTr[1][1];
220 else if(ism >=12 && ism < 18)
222 xpos += fSecTr[2][0];
223 ypos += fSecTr[2][1];
225 else if(ism >= 18 && ism < 24)
227 xpos += fSecTr[3][0];
228 ypos += fSecTr[3][1];
232 // ----------------------------------------------------------
233 void AliPMDUtility::RectGeomCellPos(Int_t ism, Float_t xpad, Float_t ypad, Float_t &xpos, Float_t &ypos)
235 // If the xpad and ypad inputs are float, then 0.5 is added to it
236 // to find the layer which is shifted.
237 // This routine finds the cell eta,phi for the new PMD rectangular
239 // Authors : Bedanga Mohanty and Dipak Mishra - 29.4.2003
240 // modified by B. K. Nnadi for change of coordinate sys
242 // SMA ---> Supermodule Type A ( SM - 0)
243 // SMAR ---> Supermodule Type A ROTATED ( SM - 1)
244 // SMB ---> Supermodule Type B ( SM - 2)
245 // SMBR ---> Supermodule Type B ROTATED ( SM - 3)
247 // ism : Serial Module number from 0 to 23 for each plane
249 // Corner positions (x,y) of the 24 unit moudles in ALICE PMD
253 74.8833, 53.0045, 31.1255, //Type-A
254 74.8833, 53.0045, 31.1255, //Type-A
255 -74.8833, -53.0044, -31.1255, //Type-AR
256 -74.8833, -53.0044, -31.1255, //Type-AR
257 8.9165, -33.7471, //Type-B
258 8.9165, -33.7471, //Type-B
259 8.9165, -33.7471, //Type-B
260 -8.9165, 33.7471, //Type-BR
261 -8.9165, 33.7471, //Type-BR
262 -8.9165, 33.7471, //Type-BR
269 86.225, 86.225, 86.225, //Type-A
270 37.075, 37.075, 37.075, //Type-A
271 -86.225, -86.225, -86.225, //Type-AR
272 -37.075, -37.075, -37.075, //Type-AR
273 86.225, 86.225, //Type-B
274 61.075, 61.075, //Type-B
275 35.925, 35.925, //Type-B
276 -86.225, -86.225, //Type-BR
277 -61.075, -61.075, //Type-BR
278 -35.925, -35.925 //Type-BR
282 const Float_t kSqroot3 = 1.73205; // sqrt(3.);
283 const Float_t kCellRadius = 0.25;
286 //Every even row of cells is shifted and placed
287 //in geant so this condition
289 Float_t cellRadius = 0.25;
291 Int_t iirow = (Int_t) (xpad+0.5);
294 shift = -cellRadius/2.0;
303 ypos = ycorner[ism] - xpad*kCellRadius*2.0 + shift;
304 xpos = xcorner[ism] - ypad*kSqroot3*kCellRadius;
306 else if(ism >=6 && ism < 12)
308 ypos = ycorner[ism] + xpad*kCellRadius*2.0 + shift;
309 xpos = xcorner[ism] + ypad*kSqroot3*kCellRadius;
311 else if(ism >= 12 && ism < 18)
313 ypos = ycorner[ism] - xpad*kCellRadius*2.0 + shift;
314 xpos = xcorner[ism] - ypad*kSqroot3*kCellRadius;
316 else if(ism >= 18 && ism < 24)
318 ypos = ycorner[ism] + xpad*kCellRadius*2.0 + shift;
319 xpos = xcorner[ism] + ypad*kSqroot3*kCellRadius;
322 // Apply the alignment here to the x, y values
325 xpos += fSecTr[0][0];
326 ypos += fSecTr[0][1];
328 else if(ism >= 6 && ism < 12)
330 xpos += fSecTr[1][0];
331 ypos += fSecTr[1][1];
333 else if(ism >=12 && ism < 18)
335 xpos += fSecTr[2][0];
336 ypos += fSecTr[2][1];
338 else if(ism >= 18 && ism < 24)
340 xpos += fSecTr[3][0];
341 ypos += fSecTr[3][1];
346 // -------------------------------------------------------- //
348 void AliPMDUtility::RectGeomCellPos(Int_t ism, Float_t xpad,
349 Float_t ypad, Float_t &xpos,
350 Float_t &ypos, Float_t & zpos)
352 // If the xpad and ypad inputs are float, then 0.5 is added to it
353 // to find the layer which is shifted.
354 // This routine finds the cell eta,phi for the new PMD rectangular
356 // Authors : Bedanga Mohanty and Dipak Mishra - 29.4.2003
357 // modified by B. K. Nnadi for change of coordinate sys
359 // SMA ---> Supermodule Type A ( SM - 0)
360 // SMAR ---> Supermodule Type A ROTATED ( SM - 1)
361 // SMB ---> Supermodule Type B ( SM - 2)
362 // SMBR ---> Supermodule Type B ROTATED ( SM - 3)
364 // ism : Serial Module number from 0 to 23 for each plane
366 // Corner positions (x,y) of the 24 unit moudles in ALICE PMD
370 74.8833, 53.0045, 31.1255, //Type-A
371 74.8833, 53.0045, 31.1255, //Type-A
372 -74.8833, -53.0044, -31.1255, //Type-AR
373 -74.8833, -53.0044, -31.1255, //Type-AR
374 8.9165, -33.7471, //Type-B
375 8.9165, -33.7471, //Type-B
376 8.9165, -33.7471, //Type-B
377 -8.9165, 33.7471, //Type-BR
378 -8.9165, 33.7471, //Type-BR
379 -8.9165, 33.7471, //Type-BR
386 86.225, 86.225, 86.225, //Type-A
387 37.075, 37.075, 37.075, //Type-A
388 -86.225, -86.225, -86.225, //Type-AR
389 -37.075, -37.075, -37.075, //Type-AR
390 86.225, 86.225, //Type-B
391 61.075, 61.075, //Type-B
392 35.925, 35.925, //Type-B
393 -86.225, -86.225, //Type-BR
394 -61.075, -61.075, //Type-BR
395 -35.925, -35.925 //Type-BR
399 const Float_t kSqroot3 = 1.73205; // sqrt(3.);
400 const Float_t kCellRadius = 0.25;
403 //Every even row of cells is shifted and placed
404 //in geant so this condition
406 Float_t cellRadius = 0.25;
408 Int_t iirow = (Int_t) (xpad+0.5);
411 shift = -cellRadius/2.0;
420 ypos = ycorner[ism] - xpad*kCellRadius*2.0 + shift;
421 xpos = xcorner[ism] - ypad*kSqroot3*kCellRadius;
423 else if(ism >=6 && ism < 12)
425 ypos = ycorner[ism] + xpad*kCellRadius*2.0 + shift;
426 xpos = xcorner[ism] + ypad*kSqroot3*kCellRadius;
428 else if(ism >= 12 && ism < 18)
430 ypos = ycorner[ism] - xpad*kCellRadius*2.0 + shift;
431 xpos = xcorner[ism] - ypad*kSqroot3*kCellRadius;
433 else if(ism >= 18 && ism < 24)
435 ypos = ycorner[ism] + xpad*kCellRadius*2.0 + shift;
436 xpos = xcorner[ism] + ypad*kSqroot3*kCellRadius;
439 // Apply the alignment here to the x, y, and z values
442 xpos += fSecTr[0][0];
443 ypos += fSecTr[0][1];
444 zpos += fSecTr[0][2];
446 else if(ism >= 6 && ism < 12)
448 xpos += fSecTr[1][0];
449 ypos += fSecTr[1][1];
450 zpos += fSecTr[1][2];
452 else if(ism >=12 && ism < 18)
454 xpos += fSecTr[2][0];
455 ypos += fSecTr[2][1];
456 zpos += fSecTr[2][2];
458 else if(ism >= 18 && ism < 24)
460 xpos += fSecTr[3][0];
461 ypos += fSecTr[3][1];
462 zpos += fSecTr[3][2];
468 // -------------------------------------------------------- //
470 void AliPMDUtility::GenerateBoundaryPoints(Int_t ism, Float_t &x1ism,
471 Float_t &y1ism, Float_t &x2ism,
474 // Generate bounding-box.
477 Float_t xism = 0, yism = 0;
478 Float_t dxism = 0., dyism = 0.;
480 const Float_t kRad = 0.25;
481 const Float_t kSqRoot3 = 1.732050808;
482 const Float_t kDia = 0.50;
485 const Double_t kXcorner[24] =
487 74.8833, 53.0045, 31.1255, //Type-A
488 74.8833, 53.0045, 31.1255, //Type-A
489 -74.8833, -53.0044, -31.1255, //Type-AR
490 -74.8833, -53.0044, -31.1255, //Type-AR
491 8.9165, -33.7471, //Type-B
492 8.9165, -33.7471, //Type-B
493 8.9165, -33.7471, //Type-B
494 -8.9165, 33.7471, //Type-BR
495 -8.9165, 33.7471, //Type-BR
496 -8.9165, 33.7471, //Type-BR
500 const Double_t kYcorner[24] =
502 86.225, 86.225, 86.225, //Type-A
503 37.075, 37.075, 37.075, //Type-A
504 -86.225, -86.225, -86.225, //Type-AR
505 -37.075, -37.075, -37.075, //Type-AR
506 86.225, 86.225, //Type-B
507 61.075, 61.075, //Type-B
508 35.925, 35.925, //Type-B
509 -86.225, -86.225, //Type-BR
510 -61.075, -61.075, //Type-BR
511 -35.925, -35.925 //Type-BR
515 if (ism > 23) ism -= 24;
520 xism = kXcorner[ism] + kRad;
521 yism = kYcorner[ism] + kRad;
522 dxism = -kRad*kSqRoot3*48.;
523 dyism = -kDia*96. - kRad;
525 if (ism >= 6 && ism < 12)
527 xism = kXcorner[ism] - kRad;
528 yism = kYcorner[ism] - kRad;
529 dxism = kRad*kSqRoot3*48.;
530 dyism = kDia*96. + kRad;
532 if (ism >= 12 && ism < 18)
534 xism = kXcorner[ism] + kRad;
535 yism = kYcorner[ism] + kRad;
536 dxism = -kRad*kSqRoot3*96.;
537 dyism = -kDia*48. - kRad;
539 if (ism >= 18 && ism < 24)
541 xism = kXcorner[ism] - kRad;
542 yism = kYcorner[ism] - kRad;
543 dxism = kRad*kSqRoot3*96.;
544 dyism = kDia*48. + kRad;
548 x2ism = xism + dxism;
550 y2ism = yism + dyism;
553 // ------------------------------------------------------------------- //
555 void AliPMDUtility::DrawPMDModule(Int_t idet)
558 Float_t x1ism = 0., x2ism = 0., y1ism = 0., y2ism = 0.;
559 Float_t deltaX = 0., deltaY = 0.;
561 //TH2F *h2 = new TH2F("h2","Y vs. X",200,-100.,100.,200,-100.,100.);
572 for(Int_t ism=0; ism < 24; ism++)
574 GenerateBoundaryPoints(ism, x1ism, y1ism, x2ism, y2ism);
575 deltaX = (x2ism - x1ism)/2.;
576 deltaY = (y2ism - y1ism)/2.;
577 if (fWriteModule == 1)
581 snprintf(smnumber,10,"%d",ism);
585 snprintf(smnumber,10,"%d",24+ism);
587 tt.DrawText(x1ism+deltaX,y1ism+deltaY,smnumber);
589 t.DrawLine(x1ism, y1ism, x1ism, y2ism);
590 t.DrawLine(x1ism, y1ism, x2ism, y1ism);
591 t.DrawLine(x2ism, y1ism, x2ism, y2ism);
592 t.DrawLine(x1ism, y2ism, x2ism, y2ism);
597 // ------------------------------------------------------------------- //
600 void AliPMDUtility::ApplyVertexCorrection(Float_t vertex[], Float_t xpos,
601 Float_t ypos, Float_t zpos)
604 fPx = xpos - vertex[0];
605 fPy = ypos - vertex[1];
606 fPz = zpos - vertex[2];
608 void AliPMDUtility::ApplyAlignment(Double_t sectr[][3])
610 // Get the alignment stuff here
612 for (Int_t isector=0; isector<4; isector++)
614 for(Int_t ixyz=0; ixyz < 3; ixyz++)
616 fSecTr[isector][ixyz] = (Float_t) sectr[isector][ixyz];
621 void AliPMDUtility::SetPxPyPz(Float_t px, Float_t py, Float_t pz)
628 void AliPMDUtility::SetXYZ(Float_t xpos, Float_t ypos, Float_t zpos)
634 void AliPMDUtility::SetWriteModule(Int_t wrmod)
636 fWriteModule = wrmod;
638 void AliPMDUtility::CalculateEta()
640 Float_t rpxpy = TMath::Sqrt(fPx*fPx + fPy*fPy);
641 Float_t theta = TMath::ATan2(rpxpy,fPz);
642 Float_t eta = -TMath::Log(TMath::Tan(0.5*theta));
646 void AliPMDUtility::CalculatePhi()
648 Float_t pybypx = 0., phi = 0., phi1 = 0.;
653 if(fPy<0) phi = 270.;
658 if(pybypx < 0) pybypx = - pybypx;
659 phi1 = TMath::ATan(pybypx)*180./3.14159;
661 if(fPx > 0 && fPy > 0) phi = phi1; // 1st Quadrant
662 if(fPx < 0 && fPy > 0) phi = 180 - phi1; // 2nd Quadrant
663 if(fPx < 0 && fPy < 0) phi = 180 + phi1; // 3rd Quadrant
664 if(fPx > 0 && fPy < 0) phi = 360 - phi1; // 4th Quadrant
667 phi = phi*3.14159/180.;
672 void AliPMDUtility::CalculateEtaPhi()
674 Float_t pybypx = 0., phi = 0., phi1 = 0.;
676 Float_t rpxpy = TMath::Sqrt(fPx*fPx + fPy*fPy);
677 Float_t theta = TMath::ATan2(rpxpy,fPz);
678 Float_t eta = -TMath::Log(TMath::Tan(0.5*theta));
683 if(fPy<0) phi = 270.;
688 if(pybypx < 0) pybypx = - pybypx;
689 phi1 = TMath::ATan(pybypx)*180./3.14159;
690 if(fPx > 0 && fPy > 0) phi = phi1; // 1st Quadrant
691 if(fPx < 0 && fPy > 0) phi = 180 - phi1; // 2nd Quadrant
692 if(fPx < 0 && fPy < 0) phi = 180 + phi1; // 3rd Quadrant
693 if(fPx > 0 && fPy < 0) phi = 360 - phi1; // 4th Quadrant
696 phi = phi*3.14159/180.;
702 void AliPMDUtility::CalculateXY(Float_t eta, Float_t phi, Float_t zpos)
706 // eta = -TMath::Log(TMath::Tan(0.5*theta));
708 Float_t xpos = 0., ypos = 0.;
710 // Float_t theta = 2.0*TMath::ATan(TMath::Log(-eta));
719 void AliPMDUtility::GetEtaIndexXY(Int_t smn, Int_t row, Int_t col, Float_t &xp, Float_t &yp, Double_t &eta, Int_t &etaindex) {
720 // Takes smn, row, col
721 // Calculates x, y, eta and etabin into 10.
722 // Use only in raw Data.
724 Float_t xx = 0., yy = 0.;
725 Int_t xpad = -1, ypad = -1;
731 else if(smn >=12 && smn < 24) {
738 RectGeomCellPos(smn,xpad,ypad,xx,yy);
742 Float_t rpxpy = TMath::Sqrt(xx*xx + yy*yy);
743 Float_t theta = TMath::ATan2(rpxpy,365.0);
744 eta = -TMath::Log(TMath::Tan(0.5*theta));
748 if( eta > 2.1 && eta < 2.3) etaBin = 0;
749 else if( eta > 2.3 && eta < 2.5) etaBin = 1;
750 else if( eta > 2.5 && eta < 2.7) etaBin = 2;
751 else if( eta > 2.7 && eta < 2.9) etaBin = 3;
752 else if( eta > 2.9 && eta < 3.1) etaBin = 4;
753 else if( eta > 3.1 && eta < 3.3) etaBin = 5;
754 else if( eta > 3.3 && eta < 3.5) etaBin = 6;
755 else if( eta > 3.5 && eta < 3.7) etaBin = 7;
756 else if( eta > 3.7 && eta < 3.9) etaBin = 8;
757 else if( eta > 3.9 && eta < 4.1) etaBin = 9;
765 //_____________________________________________________
767 Float_t AliPMDUtility::GetTheta() const
771 Float_t AliPMDUtility::GetEta() const
775 Float_t AliPMDUtility::GetPhi() const
779 Float_t AliPMDUtility::GetX() const
783 Float_t AliPMDUtility::GetY() const
787 Float_t AliPMDUtility::GetZ() const
791 //--------------------------------------------------------------------//