StFemtoPhysicalHelix.cxx 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. //
  2. // StFemtoPhysicalHelix is a parametrization of a particle that moves along the helix
  3. //
  4. // C++ headers
  5. #include <math.h>
  6. // FemtoDst headers
  7. #include "StFemtoHelix.h"
  8. #include "StFemtoPhysicalHelix.h"
  9. #ifdef _VANILLA_ROOT_
  10. #include "PhysicalConstants.h"
  11. #include "SystemOfUnits.h"
  12. #else
  13. #include "StarClassLibrary/PhysicalConstants.h"
  14. #include "StarClassLibrary/SystemOfUnits.h"
  15. #endif
  16. ClassImpT(StFemtoPhysicalHelix, Double_t);
  17. //_________________
  18. StFemtoPhysicalHelix::StFemtoPhysicalHelix(){
  19. /* no-op */
  20. }
  21. //_________________
  22. StFemtoPhysicalHelix::~StFemtoPhysicalHelix() {
  23. /* no-op */
  24. }
  25. //_________________
  26. StFemtoPhysicalHelix::StFemtoPhysicalHelix(const TVector3& p,
  27. const TVector3& o,
  28. Double_t B, Double_t q) {
  29. mH = (q*B <= 0) ? 1 : -1;
  30. if(p.y() == 0 && p.x() == 0) {
  31. setPhase((M_PI/4)*(1-2.*mH));
  32. }
  33. else {
  34. setPhase(atan2(p.y(),p.x())-mH*M_PI/2);
  35. }
  36. setDipAngle(atan2(p.z(),p.Perp()));
  37. mOrigin = o;
  38. #ifndef ST_NO_NAMESPACES
  39. {
  40. using namespace units;
  41. #endif
  42. setCurvature( ::fabs( (c_light*nanosecond/meter*q*B/tesla) /
  43. ( p.Mag()/GeV*mCosDipAngle) / meter) );
  44. #ifndef ST_NO_NAMESPACES
  45. }
  46. #endif
  47. }
  48. //_________________
  49. StFemtoPhysicalHelix::StFemtoPhysicalHelix(Double_t c, Double_t d,
  50. Double_t phase, const TVector3& o,
  51. Int_t h) : StFemtoHelix(c, d, phase, o, h) {
  52. /* no-op */
  53. }
  54. //_________________
  55. TVector3 StFemtoPhysicalHelix::momentum(Double_t B) const {
  56. if (mSingularity) {
  57. return(TVector3(0,0,0));
  58. }
  59. else {
  60. #ifndef ST_NO_NAMESPACES
  61. {
  62. using namespace units;
  63. #endif
  64. Double_t pt = GeV*fabs(c_light*nanosecond/meter*B/tesla)/(fabs(mCurvature)*meter);
  65. return ( TVector3( pt*cos(mPhase+mH*M_PI/2), // pos part pos field
  66. pt*sin(mPhase+mH*M_PI/2),
  67. pt*tan(mDipAngle) ) );
  68. #ifndef ST_NO_NAMESPACES
  69. }
  70. #endif
  71. } //else
  72. }
  73. //_________________
  74. TVector3 StFemtoPhysicalHelix::momentumAt(Double_t S, Double_t B) const {
  75. // Obtain phase-shifted momentum from phase-shift of origin
  76. StFemtoPhysicalHelix tmp(*this);
  77. tmp.moveOrigin(S);
  78. return tmp.momentum(B);
  79. }
  80. //_________________
  81. Int_t StFemtoPhysicalHelix::charge(Double_t B) const {
  82. return (B > 0 ? -mH : mH);
  83. }
  84. //_________________
  85. Double_t StFemtoPhysicalHelix::geometricSignedDistance(Double_t x, Double_t y) {
  86. // Geometric signed distance
  87. Double_t thePath = this->pathLength(x,y);
  88. TVector3 DCA2dPosition = this->at(thePath);
  89. DCA2dPosition.SetZ(0);
  90. TVector3 position(x,y,0);
  91. TVector3 DCAVec = (DCA2dPosition-position);
  92. TVector3 momVec;
  93. // Deal with straight tracks
  94. if (this->mSingularity) {
  95. momVec = this->at(1)- this->at(0);
  96. momVec.SetZ(0);
  97. }
  98. else {
  99. momVec = this->momentumAt(thePath,1./tesla); // Don't care about Bmag. Helicity is what matters.
  100. momVec.SetZ(0);
  101. }
  102. Double_t cross = DCAVec.x()*momVec.y() - DCAVec.y()*momVec.x();
  103. Double_t theSign = (cross>=0) ? 1. : -1.;
  104. return theSign*DCAVec.Perp();
  105. }
  106. //_________________
  107. Double_t StFemtoPhysicalHelix::curvatureSignedDistance(Double_t x, Double_t y) {
  108. // Protect against mH = 0 or zero field
  109. if (this->mSingularity || abs(this->mH)<=0) {
  110. return ( this->geometricSignedDistance(x,y) );
  111. }
  112. else {
  113. return ( this->geometricSignedDistance(x,y) ) / (this->mH);
  114. }
  115. }
  116. //_________________
  117. Double_t StFemtoPhysicalHelix::geometricSignedDistance(const TVector3& pos) {
  118. Double_t sdca2d = this->geometricSignedDistance(pos.x(),pos.y());
  119. Double_t theSign = (sdca2d>=0) ? 1. : -1.;
  120. return (this->distance(pos))*theSign;
  121. }
  122. //_________________
  123. Double_t StFemtoPhysicalHelix::curvatureSignedDistance(const TVector3& pos) {
  124. Double_t sdca2d = this->curvatureSignedDistance(pos.x(),pos.y());
  125. Double_t theSign = (sdca2d>=0) ? 1. : -1.;
  126. return (this->distance(pos))*theSign;
  127. }