TShieldGeometryOperators.cxx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // -------------------------------------------------------------------------
  2. // ----- TShieldGeometry source file -----
  3. // ----- Created by D. Sosnov -----
  4. // -------------------------------------------------------------------------
  5. #include "TShieldGeometry.h"
  6. namespace tgeanttoshield {
  7. //Operators for comparsion floating point values
  8. bool doubleNE(const double &l, const double &r){return (abs(l-r)>1E-15);}
  9. bool doubleEQ(const double &l, const double &r){return !doubleNE(l,r);}
  10. bool doubleLT(const double &l, const double &r){return (doubleNE(l,r) && (l<r));}
  11. bool doubleLE(const double &l, const double &r){return ((l<r) || doubleEQ(l,r));}
  12. bool doubleGT(const double &l, const double &r){return !doubleLE(l,r);}
  13. bool doubleGE(const double &l, const double &r){return !doubleLT(l,r);}
  14. TGeoHMatrix operator*(TGeoHMatrix &matrixR, const TGeoMatrix &matrixL) {
  15. TGeoHMatrix mm = TGeoHMatrix(matrixR);
  16. mm.Multiply(&matrixL);
  17. return TGeoHMatrix(mm);
  18. }
  19. TGeoHMatrix operator*(TGeoHMatrix &matrixR, const TGeoHMatrix &matrixL) {
  20. TGeoHMatrix mm = TGeoHMatrix(matrixR);
  21. return mm *= matrixL;
  22. }
  23. TGeoHMatrix operator*(const TGeoMatrix &matrixR, const TGeoMatrix &matrixL) {
  24. TGeoHMatrix hmr = TGeoHMatrix(matrixR);
  25. return hmr * matrixL;
  26. }
  27. TGeoHMatrix operator*(const TGeoMatrix &matrixR, const TGeoHMatrix &matrixL) {
  28. TGeoHMatrix hmr = TGeoHMatrix(matrixR);
  29. return hmr * matrixL;
  30. }
  31. TGeoTranslation operator+(const TGeoTranslation &matrixR, const TGeoTranslation &matrixL) {
  32. TGeoTranslation m = TGeoTranslation(matrixR);
  33. m.Add(&matrixL);
  34. return TGeoTranslation(m);
  35. }
  36. TGeoTranslation operator-(const TGeoTranslation matrixR, const TGeoTranslation &matrixL) {
  37. return matrixR + matrixL.Inverse();
  38. }
  39. TGeoTranslation operator+(const TGeoTranslation matrixR, const TGeoMatrix &matrixL) {
  40. return matrixR + TGeoTranslation(matrixL);
  41. }
  42. TGeoTranslation operator*(const TGeoTranslation matrixR, const Double_t &scale) {
  43. Double_t* tmp1 = (Double_t*)matrixR.GetTranslation();
  44. return TGeoTranslation(tmp1[0]*scale,tmp1[1]*scale,tmp1[2]*scale);
  45. }
  46. void addVectorToElement(SGeoBody &body, unsigned int position, TGeoTranslation vector){
  47. body.parameters[position] = (double)(vector.GetTranslation()[0]);
  48. body.parameters[position+1] = (double)(vector.GetTranslation()[1]);
  49. body.parameters[position+2] = (double)(vector.GetTranslation()[2]);
  50. }
  51. }