TpcLocalTransform.cxx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. // ROOT headers
  2. #include "TVector3.h"
  3. #include "TMath.h"
  4. //_________________
  5. int TpcLocalTransform(TVector3& aPoint, int& aSector, int& aRow,
  6. float& aU, double& aPhi) {
  7. static const int mNumberOfPadrows = 45;
  8. static const int mNumberOfPadrowsInner = 13;
  9. static const int mNumberOfSectors = 24;
  10. // Number of pad in a row for each padrow
  11. static int tNPadAtRow[mNumberOfPadrows] = {
  12. 88, 96, 104, 112, 118, 126, 134, 142, 150, 158, 166, 174, 182,
  13. 98, 100, 102, 104, 106, 106, 108, 110, 112, 112, 114, 116, 118, 120, 122, 122,
  14. 124, 126, 128, 128, 130, 132, 134, 136, 138, 138, 140, 142, 144, 144, 144, 144
  15. };
  16. // Phi angle of each of 24 sectors
  17. static double tSectToPhi[mNumberOfSectors] = {
  18. 2., 1., 0., 11., 10., 9., 8., 7., 6., 5., 4., 3.,
  19. 4., 5., 6., 7., 8., 9., 10., 11., 0., 1., 2., 3.
  20. };
  21. // Pad size for innner and outer sector
  22. static double tPadWidthInner = 0.335;
  23. static double tPadWidthOuter = 0.67;
  24. static double tPi = TMath::Pi();
  25. // Find sector number
  26. aPhi = aPoint.Phi();
  27. if (aPhi < 0.) {
  28. aPhi += (2 * tPi);
  29. }
  30. aPhi += tPi / 12.;
  31. if (aPhi > 2 * tPi) {
  32. aPhi -= 2 * tPi;
  33. }
  34. int tiPhi = (int) (aPhi / tPi * 6.);
  35. if (aPoint.Z() < 0) {
  36. aSector = (tiPhi < 3) ? 3 - tiPhi : 15 - tiPhi;
  37. } else {
  38. aSector = (tiPhi < 4) ? 21 + tiPhi : 9 + tiPhi;
  39. }
  40. aPhi = tSectToPhi[aSector - 1] * tPi / 6.;
  41. //if((fabs(aPhi-aPoint.phi())>(tPi/12)){
  42. //cout << "Sector missmatch " << aPhi << " " << aPoint.phi() << " "
  43. // << aSector << endl;
  44. //}
  45. // Calculate local coordinate
  46. float tR = aPoint.X() * TMath::Cos(aPhi) + aPoint.Y() * TMath::Sin(aPhi);
  47. aU = -aPoint.X() * TMath::Sin(aPhi) + aPoint.Y() * TMath::Cos(aPhi);
  48. // Find pad row
  49. if (tR < 57.6) {
  50. aRow = 0;
  51. return 1;
  52. }
  53. float radmax = 62.4;
  54. float spacing = 4.8;
  55. aRow = 1;
  56. while ((tR > radmax) && (aRow < 46)) {
  57. aRow++;
  58. if (aRow == 8) {
  59. radmax = 96.2;
  60. spacing = 5.2;
  61. } else {
  62. // Row 13 is the last one of the inner sector
  63. if (aRow == mNumberOfPadrowsInner) {
  64. radmax = 126.195;
  65. spacing = 2.0;
  66. } else {
  67. radmax += spacing;
  68. }
  69. } //else
  70. } //while ( ( tR > radmax) && ( aRow < 46 ) )
  71. if (aRow > mNumberOfPadrows) {
  72. //cout << "No pad row " << tR << endl;
  73. return 2;
  74. }
  75. // Check if u (=aU) inbound
  76. double tPadWidth = (aRow < 14) ? tPadWidthInner : tPadWidthOuter;
  77. if (TMath::Abs(aU) > (tNPadAtRow[aRow - 1] * tPadWidth / 2.)) {
  78. return 3;
  79. }
  80. return 0;
  81. }