TShieldOpt.cxx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. // -------------------------------------------------------------------------
  2. // ----- TShield source file -----
  3. // ----- Created by A. Timofeev -----
  4. // -------------------------------------------------------------------------
  5. #include "TShield.h"
  6. void TShield::SetAutoSeed(bool flag) {
  7. autoseed = flag;
  8. }
  9. void TShield::SetRandomSeed() {
  10. SetRandomSeed(clock() + time(0));
  11. }
  12. void TShield::SetRandomSeed(Int_t seed) {
  13. if (seed < 0) seed = - seed;
  14. shield_set_randomseed(seed);
  15. }
  16. Int_t TShield::GetRandomSeed() {
  17. return shield_get_randomseed();
  18. }
  19. void TShield::SetLuxCount(Int_t luxcnt) {
  20. shield_set_luxcount(luxcnt);
  21. }
  22. Int_t TShield::GetLuxCount() {
  23. return shield_get_luxcount();
  24. }
  25. void TShield::SetLCASC(Int_t lcasc) {
  26. shield_set_lcasc(lcasc);
  27. }
  28. Int_t TShield::GetLCASC() {
  29. return shield_get_lcasc();
  30. }
  31. void TShield::SetIncidentParticle(Int_t jpart) {
  32. shield_set_incidentparticle(jpart);
  33. }
  34. Int_t TShield::GetIncidentParticle() {
  35. return shield_get_incidentparticle();
  36. }
  37. void TShield::SetEnergy(Float_t energy) {
  38. shield_set_energy(energy);
  39. }
  40. Float_t TShield::GetEnergy() {
  41. return shield_get_energy();
  42. }
  43. void SetStatistics(Int_t nstat){
  44. shield_set_statistics(nstat);
  45. }
  46. Int_t GetStatistics(){
  47. return shield_get_statistics();
  48. }
  49. void TShield::SetAProj(Float_t aproj) {
  50. shield_set_aproj(aproj);
  51. }
  52. void TShield::SetZProj(Float_t zproj) {
  53. shield_set_zproj(zproj);
  54. }
  55. Float_t TShield::GetAProj() {
  56. return shield_get_aproj();
  57. }
  58. Float_t TShield::GetZProj() {
  59. return shield_get_zproj();
  60. }
  61. void TShield::SetStartPoint(Float_t x, Float_t y, Float_t z) {
  62. shield_set_runpoint(x, y, z);
  63. }
  64. void TShield::SetDirectionVector(Float_t cx, Float_t cy, Float_t cz) {
  65. Float_t norm = sqrt(cx * cx + cy * cy + cz * cz);
  66. cx /= norm; cy /= norm; cz /= norm;
  67. Float_t sin_theta = sqrt(1 - cz * cz);
  68. if (sin_theta != 0.0) {
  69. shield_set_rundirection(cz, cy / sin_theta, cx / sin_theta);
  70. } else {
  71. shield_set_rundirection(1, 0, 1);
  72. }
  73. }
  74. void TShield::SetDirection(Float_t cos_theta, Float_t sin_phi, Float_t cos_phi) {
  75. shield_set_rundirection(cos_theta, sin_phi, cos_phi);
  76. }
  77. void TShield::SetDirection(Float_t phi, Float_t theta) {
  78. shield_set_rundirection(cos(theta), sin(phi), cos(phi));
  79. }
  80. void TShield::SetParticleFromPdgCode(Int_t pdg_code){
  81. float a, z;
  82. int type = hadgen_get_nuclei_parameters_by_pdg_code(pdg_code, &a, &z);
  83. if(type == 0){
  84. printf("TShield: Unknown pdg code for beam");
  85. return;
  86. // } else if(type != 25){ //Disabled, because a and z should be null
  87. // SetIncidentParticle(type); SetAProj(0); SetZProj(0);
  88. // }
  89. } else{
  90. SetIncidentParticle(type);
  91. SetAProj(a);
  92. SetZProj(z);
  93. }
  94. return;
  95. }
  96. void TShield::SetParticleFromPdgCode(Int_t pdg_code, Float_t A, Float_t Z){
  97. float _a, _z;
  98. int type = hadgen_get_nuclei_parameters_by_pdg_code(pdg_code, &_a, &_z);
  99. if(type == 25){
  100. SetIncidentParticle(type);
  101. SetAProj(_a);
  102. SetZProj(_z);
  103. }else if(type != 0){
  104. SetIncidentParticle(type);
  105. SetAProj(_a);
  106. SetZProj(_z);
  107. }else{ //if(type == 0)
  108. SetIncidentParticle(25);
  109. SetAProj(A);
  110. SetZProj(Z);
  111. }
  112. return;
  113. }