TpcLheCMPoint.cxx 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. #include <Riostream.h>
  2. #include "TMath.h"
  3. #include "TpcLheHit.h"
  4. #include "TpcLheCMPoint.h"
  5. using namespace std;
  6. ClassImp(TpcLheCMPoint)
  7. //________________________________________________________________
  8. TpcLheCMPoint::TpcLheCMPoint() : TpcLheHit() {
  9. //--- clean all
  10. SetPhi(0.);
  11. SetTheta(0.);
  12. fXprime = 0.;
  13. fYprime =0.;
  14. fXprimeerr = 0.;
  15. fYprimeerr = 0.;
  16. SetIntPoint(0., 0., 0., 0., 0., 0.);
  17. SetShiftedCoord();
  18. SetDist(0., 0.);
  19. }
  20. //________________________________________________________________
  21. TpcLheCMPoint::TpcLheCMPoint(TpcLheHit *point) :
  22. TpcLheHit( *point) {
  23. //---
  24. }
  25. //________________________________________________________________
  26. TpcLheCMPoint::~TpcLheCMPoint() {
  27. //---
  28. }
  29. //________________________________________________________________
  30. void TpcLheCMPoint::SetIntPoint(const Double_t in_x,
  31. const Double_t in_y,
  32. const Double_t in_z,
  33. const Double_t in_x_err,
  34. const Double_t in_y_err,
  35. const Double_t in_z_err) {
  36. // Defines a new interaction point. This point is needed to
  37. // calculate the conformal coordinates.
  38. SetXt(in_x);
  39. SetYt(in_y);
  40. SetZt(in_z);
  41. SetXterr(in_x_err);
  42. SetYterr(in_y_err);
  43. SetZterr(in_z_err);
  44. }
  45. //________________________________________________________________
  46. void TpcLheCMPoint::SetAllCoord(const TpcLheCMPoint *hit) {
  47. // Sets the interaction point, the shifted coordinates,
  48. // and the conformal mapping coordinates.
  49. // These values are calculated from the interaction point of the given hit
  50. // which should be already found hit on the same track.
  51. SetIntPoint(hit->GetX(),
  52. hit->GetY(),
  53. hit->GetZ(),
  54. hit->GetXerr(),
  55. hit->GetYerr(),
  56. hit->GetZerr());
  57. SetShiftedCoord();
  58. SetConfCoord();
  59. }
  60. //________________________________________________________________
  61. void TpcLheCMPoint::SetShiftedCoord() {
  62. // Sets the coordinates with respect to the given vertex point
  63. SetXv(GetX() - fXt);
  64. SetYv(GetY() - fYt);
  65. SetZv(GetZ() - fZt);
  66. SetXverr(TMath::Sqrt(GetXerr()*GetXerr() + fXterr*fXterr));
  67. SetYverr(TMath::Sqrt(GetYerr()*GetYerr() + fYterr*fYterr));
  68. SetZverr(TMath::Sqrt(GetZerr()*GetZerr() + fZterr*fZterr));
  69. }
  70. //________________________________________________________________
  71. void TpcLheCMPoint::SetConfCoord() {
  72. // Calculates the conformal coordinates of one hit.
  73. Double_t r2 = fXv*fXv + fYv*fYv;
  74. if (r2 != 0.) {
  75. fXprime = fXv / r2;
  76. fYprime = -fYv / r2;
  77. fXprimeerr = TMath::Sqrt(TMath::Power((-fXv * fXv + fYv*fYv) * fXverr, 2) +
  78. TMath::Power( 2*fXv*fYv*fYverr, 2)) /
  79. TMath::Power(fXv*fXv + fYv*fYv, 2);
  80. fYprimeerr = TMath::Sqrt(TMath::Power((-fXv * fXv - 3*fYv*fYv) * fYverr, 2) +
  81. TMath::Power(-2*fXv*fYv*fXverr, 2)) /
  82. TMath::Power(fXv*fXv + fYv*fYv, 2);
  83. }
  84. else {
  85. fXprime = 0.;
  86. fYprime = 0.;
  87. fXprimeerr = 0.;
  88. fYprimeerr = 0.;
  89. }
  90. }
  91. //________________________________________________________________
  92. void TpcLheCMPoint::SetAngles() {
  93. // Calculates the azimutal angle phi and the polar theta for each hit.
  94. TVector3 v(fXv, fYv, fZv);
  95. fPhi = (v.Phi() > 0.) ? fPhi = v.Phi() : fPhi = v.Phi()+ 2.*TMath::Pi();
  96. fTheta = v.Theta();
  97. }
  98. //________________________________________________________________
  99. void TpcLheCMPoint::Setup(TpcLhePoint *vertex) {
  100. // --- right order is important
  101. SetIntPoint(vertex->GetX(), vertex->GetY(), vertex->GetZ(),
  102. vertex->GetXerr(), vertex->GetYerr(), vertex->GetZerr());
  103. // The angles are set properly if they are set after the interaction
  104. // point and the shifted coordinates
  105. SetShiftedCoord();
  106. SetConfCoord();
  107. SetAngles();
  108. SetDist(0., 0.);
  109. }
  110. //________________________________________________________________
  111. void TpcLheCMPoint::Print() {
  112. cout << flush;
  113. cout << " " << this->GetTrackID();
  114. cout << " " << this->GetHitNumber();
  115. cout << " " << this->GetUsage() ;
  116. cout.setf(ios::right, ios::floatfield);
  117. cout.precision(3);
  118. cout << " " << setw(7) << this->GetX();
  119. cout << " " << setw(7) << this->GetY();
  120. cout << " " << setw(5) << this->GetZ();
  121. cout.setf(ios::scientific);
  122. cout.precision(5);
  123. cout << " " << setw(10) << fPhi;
  124. cout << " " << setw(10) << fTheta;
  125. cout << endl;
  126. cout.setf(ios::right, ios::floatfield);
  127. }