URun.cxx 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. // C++ headers
  2. #include <iostream>
  3. // ROOT headers
  4. #include "TMath.h"
  5. // UNI headers
  6. #include "URun.h"
  7. ClassImp(URun);
  8. Double_t URun::mProtMass = 0.938272029;
  9. Double_t URun::mNeutMass = 0.939565360;
  10. Double_t URun::mPionMass = 0.13957018;
  11. //----------------
  12. URun::URun() : TNamed("run", "Run Header" ),
  13. fGenerator( "" ), fComment( "" ), fDecayer( "" ),
  14. fAProj( 0 ), fZProj( 0 ), fPProj( 0 ),
  15. fATarg( 0 ), fZTarg( 0 ), fPTarg( 0 ),
  16. fBMin( 0 ), fBMax( 0 ), fBWeight( 0 ),
  17. fPhiMin( 0 ), fPhiMax( 0 ), fXSection( 0 ), fNEvents( 0 ) {
  18. // Default constructor. Should not be used
  19. std::cout << "Warning: Default constructor of URun should not be used!"
  20. << std::endl;
  21. }
  22. //----------------
  23. URun::URun(const char* generator, const char* comment, const Int_t& aProj,
  24. const Int_t& zProj, const Double_t& pProj, const Int_t& aTarg,
  25. const Int_t& zTarg, const Double_t& pTarg, const Double_t& bMin,
  26. const Double_t& bMax, const Int_t& bWeight, const Double_t& phiMin,
  27. const Double_t& phiMax, const Double_t& sigma, const Int_t& nEvents)
  28. : TNamed("run", "Run Header") {
  29. // Standard constructor
  30. fGenerator = generator;
  31. fComment = comment;
  32. fAProj = ( ( TMath::Abs( aProj ) >= std::numeric_limits<short>::max() ) ?
  33. std::numeric_limits<short>::max() : (Short_t)aProj ) ;
  34. fZProj = ( ( TMath::Abs( zProj ) >= std::numeric_limits<short>::max() ) ?
  35. std::numeric_limits<short>::max() : (Short_t)zProj );
  36. fPProj = (Float_t)pProj;
  37. fATarg = ( ( TMath::Abs( aTarg ) >= std::numeric_limits<short>::max() ) ?
  38. std::numeric_limits<short>::max() : (Short_t)aTarg );
  39. fZTarg = ( ( TMath::Abs( zTarg ) >= std::numeric_limits<short>::max() ) ?
  40. std::numeric_limits<short>::max() : (Short_t)zTarg );
  41. fPTarg = (Float_t)pTarg;
  42. fBMin = (Float_t)bMin;
  43. fBMax = (Float_t)bMax;
  44. fBWeight = bWeight;
  45. fPhiMin = (Float_t)phiMin;
  46. fPhiMax = (Float_t)phiMax;
  47. fXSection = (Float_t)sigma;
  48. fNEvents = nEvents;
  49. }
  50. //----------------
  51. URun::~URun() {
  52. // Destructor
  53. }
  54. //----------------
  55. void URun::print(Option_t* option) {
  56. // Print all data members to the standard output
  57. std::cout << "--------------------------------------------------" << std::endl
  58. << "-I- Run Header -I-" << std::endl
  59. << "Generator : " << fGenerator << std::endl
  60. << "Comment : " << fComment << std::endl
  61. << "Decayer : " << fDecayer << std::endl
  62. << "Projectile mass : " << fAProj << std::endl
  63. << "Projectile charge : " << fZProj << std::endl
  64. << "Projectile momentum (AGeV/c) : " << fPProj << std::endl
  65. << "Target mass : " << fATarg << std::endl
  66. << "Target charge : " << fZTarg << std::endl
  67. << "Target momentum (AGeV/c) : " << fPTarg << std::endl
  68. << "Minimal impact parameter (fm) : " << fBMin << std::endl
  69. << "Maximal impact parameter (fm) : " << fBMax << std::endl
  70. << "Impact parameter weighting : " << fBWeight << std::endl
  71. << "Minimal azimuthal angle (rad) : " << fPhiMin << std::endl
  72. << "Maximal azimuthal angle (rad) : " << fPhiMax << std::endl
  73. << "Cross-section (mb) : " << fXSection << std::endl
  74. << "Requested number of events : " << fNEvents << std::endl
  75. << "--------------------------------------------------" << std::endl;
  76. }
  77. //----------------
  78. Double_t URun::projectileEnergy() {
  79. // Get the projectile energy
  80. Double_t eProj = 0.;
  81. if ( fAProj > 0 ) // nucleus
  82. eProj = fZProj * TMath::Sqrt( fPProj*fPProj + mProtMass*mProtMass ) +
  83. (fAProj - fZProj) * TMath::Sqrt( fPProj*fPProj + mNeutMass*mNeutMass );
  84. else if ( fAProj == 0 ) // photon
  85. eProj = fPProj;
  86. else if ( fAProj == -1 ) // pion
  87. eProj = TMath::Sqrt( fPProj*fPProj + mPionMass*mPionMass );
  88. else std::cout << "Warning:: URun: Projectile mass " << fAProj
  89. << " not valid! " << std::endl;
  90. return eProj;
  91. }
  92. //----------------
  93. Double_t URun::targetEnergy() {
  94. // Get the target energy
  95. Double_t eTarg = 0.;
  96. if ( fATarg > 0 ) // nucleus
  97. eTarg = fZTarg * TMath::Sqrt( fPTarg*fPTarg + mProtMass*mProtMass ) +
  98. (fATarg - fZTarg) * TMath::Sqrt( fPTarg*fPTarg + mNeutMass*mNeutMass );
  99. else if ( fAProj == 0 ) // photon
  100. eTarg = fPTarg;
  101. else if ( fAProj == -1 ) // pion
  102. eTarg = TMath::Sqrt( fPTarg*fPTarg + mPionMass*mPionMass );
  103. else std::cout << "Warning:: URun: Target mass " << fATarg
  104. << " not valid! " << std::endl;
  105. return eTarg;
  106. }
  107. //----------------
  108. Double_t URun::nnSqrtS() {
  109. // Get the cm energy
  110. Double_t eSum = ( TMath::Sqrt( fPTarg*fPTarg + mProtMass*mProtMass ) +
  111. TMath::Sqrt( fPProj*fPProj + mNeutMass*mNeutMass ) );
  112. Double_t pSum = Double_t(fPProj + fPTarg);
  113. Double_t ecm = TMath::Sqrt( eSum*eSum - pSum*pSum );
  114. return ecm;
  115. }
  116. //----------------
  117. Double_t URun::sqrtS() {
  118. // Get the cm energy
  119. Double_t eSum = projectileEnergy() + targetEnergy();
  120. Double_t pSum = Double_t(fAProj) * fPProj + Double_t(fATarg) * fPTarg;
  121. Double_t ecm = TMath::Sqrt( eSum*eSum - pSum*pSum );
  122. return ecm;
  123. }
  124. //----------------
  125. Double_t URun::betaCM() {
  126. // Get cm velocity
  127. Double_t eSum = projectileEnergy() + targetEnergy();
  128. Double_t pSum = Double_t(fAProj) * fPProj + Double_t(fATarg) * fPTarg;
  129. return pSum / eSum;
  130. }
  131. //----------------
  132. Double_t URun::gammaCM() {
  133. // Get cm gamma factor
  134. return 1. / TMath::Sqrt( 1. - betaCM()*betaCM() );
  135. }