diff --git a/GeoSpecialShapes/CMakeLists.txt b/GeoSpecialShapes/CMakeLists.txt index 258e2f7daa25bf8fd982da576b9455cf42307759..5811a699a25e398bf465f53ac9a3ed8967fbf6e4 100644 --- a/GeoSpecialShapes/CMakeLists.txt +++ b/GeoSpecialShapes/CMakeLists.txt @@ -5,7 +5,7 @@ # Package: GeoSpecialShapes ################################################################################ -find_package(CLHEP) +#find_package(CLHEP) # Use the GNU install directory names. include( GNUInstallDirs ) # it defines CMAKE_INSTALL_LIBDIR diff --git a/GeoSpecialShapes/GeoSpecialShapes/LArWheelCalculator.h b/GeoSpecialShapes/GeoSpecialShapes/LArWheelCalculator.h index 3a85bd8939f9ab36edda6ceebfac6f3a072aa3cc..bcbebd1f48b82a15763e653a104f8559209e4e1f 100644 --- a/GeoSpecialShapes/GeoSpecialShapes/LArWheelCalculator.h +++ b/GeoSpecialShapes/GeoSpecialShapes/LArWheelCalculator.h @@ -7,7 +7,8 @@ #include <vector> -#include "CLHEP/Vector/ThreeVector.h" +//#include "CLHEP/Vector/ThreeVector.h" +#include "GeoModelKernel/GeoDefinitions.h" //#ifndef XAOD_STANDALONE // #include "AthenaKernel/CLASS_DEF.h" //#endif // XAOD_STANDALONE @@ -108,21 +109,21 @@ class LArWheelCalculator /// Determines the nearest to the input point fan. /// Rotates point p to the localFan coordinates and returns the /// fan number to out_fan_number parameter. - double DistanceToTheNearestFan(CLHEP::Hep3Vector &p, int & out_fan_number) const; + double DistanceToTheNearestFan(GeoTrf::Vector3D &p, int & out_fan_number) const; /// Calculates aproximate, probably underestimate, distance to the /// neutral fibre of the vertical fan. Sign of return value means /// side of the fan; negative - lower phi. - double DistanceToTheNeutralFibre(const CLHEP::Hep3Vector &p, int fan_number) const; + double DistanceToTheNeutralFibre(const GeoTrf::Vector3D &p, int fan_number) const; - CLHEP::Hep3Vector NearestPointOnNeutralFibre(const CLHEP::Hep3Vector &p, + GeoTrf::Vector3D NearestPointOnNeutralFibre(const GeoTrf::Vector3D &p, int fan_number) const; - std::vector<double> NearestPointOnNeutralFibre_asVector(const CLHEP::Hep3Vector &p, + std::vector<double> NearestPointOnNeutralFibre_asVector(const GeoTrf::Vector3D &p, int fan_number) const; - int GetPhiGap(const CLHEP::Hep3Vector &p) const { return GetPhiGapAndSide(p).first; } + int GetPhiGap(const GeoTrf::Vector3D &p) const { return GetPhiGapAndSide(p).first; } int PhiGapNumberForWheel(int) const; - std::pair<int, int> GetPhiGapAndSide(const CLHEP::Hep3Vector &p) const; - double AmplitudeOfSurface(const CLHEP::Hep3Vector& P, int side, int fan_number) const; + std::pair<int, int> GetPhiGapAndSide(const GeoTrf::Vector3D &p) const; + double AmplitudeOfSurface(const GeoTrf::Vector3D& P, int side, int fan_number) const; /// @} diff --git a/GeoSpecialShapes/src/LArWheelCalculatorGeometry.cxx b/GeoSpecialShapes/src/LArWheelCalculatorGeometry.cxx index 0ff84d52bb8687fe9a62dbf007248156cb5d8360..d5767f7f58a9b0908ca8d600ff31f3e6d30b160f 100644 --- a/GeoSpecialShapes/src/LArWheelCalculatorGeometry.cxx +++ b/GeoSpecialShapes/src/LArWheelCalculatorGeometry.cxx @@ -17,6 +17,8 @@ #include "./LArWheelCalculator_Impl/IDistanceCalculator.h" #include "./LArWheelCalculator_Impl/IFanCalculator.h" +#include "GeoModelKernel/GeoDefinitions.h" + #ifdef HARDDEBUG #include<stdio.h> #endif @@ -92,7 +94,7 @@ double LArWheelCalculator::parameterized_slant_angle(double r) const // Returns distance to the nearest fan. Vector p is set to nearest fan coord. // system. // m_fan_number is set to nearest fan number -double LArWheelCalculator::DistanceToTheNearestFan(CLHEP::Hep3Vector &p, int & out_fan_number) const +double LArWheelCalculator::DistanceToTheNearestFan(GeoTrf::Vector3D &p, int & out_fan_number) const { return m_fanCalcImpl->DistanceToTheNearestFan(p, out_fan_number); } @@ -100,7 +102,7 @@ double LArWheelCalculator::DistanceToTheNearestFan(CLHEP::Hep3Vector &p, int & o // Relays on the fact that each two fans have a fan of a different type between // them. // Affects m_fan_number. -std::pair<int, int> LArWheelCalculator::GetPhiGapAndSide(const CLHEP::Hep3Vector &p) const +std::pair<int, int> LArWheelCalculator::GetPhiGapAndSide(const GeoTrf::Vector3D &p) const { return m_fanCalcImpl->GetPhiGapAndSide(p); } @@ -110,19 +112,19 @@ std::pair<int, int> LArWheelCalculator::GetPhiGapAndSide(const CLHEP::Hep3Vector // side of the fan; negative - lower phi. // // Uses m_fan_number to compute sagging. -double LArWheelCalculator::DistanceToTheNeutralFibre(const CLHEP::Hep3Vector& P, int fan_number) const +double LArWheelCalculator::DistanceToTheNeutralFibre(const GeoTrf::Vector3D& P, int fan_number) const { return m_distanceCalcImpl->DistanceToTheNeutralFibre(P, fan_number); } -CLHEP::Hep3Vector LArWheelCalculator::NearestPointOnNeutralFibre(const CLHEP::Hep3Vector &P, int fan_number) const +GeoTrf::Vector3D LArWheelCalculator::NearestPointOnNeutralFibre(const GeoTrf::Vector3D &P, int fan_number) const { return m_distanceCalcImpl->NearestPointOnNeutralFibre(P, fan_number); } -std::vector<double> LArWheelCalculator::NearestPointOnNeutralFibre_asVector(const CLHEP::Hep3Vector &p, int fan_number) const +std::vector<double> LArWheelCalculator::NearestPointOnNeutralFibre_asVector(const GeoTrf::Vector3D &p, int fan_number) const { - CLHEP::Hep3Vector np = NearestPointOnNeutralFibre(p, fan_number); + GeoTrf::Vector3D np = NearestPointOnNeutralFibre(p, fan_number); return std::vector<double> { np.x(), np.y(), np.z() }; } @@ -132,7 +134,7 @@ side: < 0 - lower phi > 0 - greater phi = 0 - neutral fibre */ -double LArWheelCalculator::AmplitudeOfSurface(const CLHEP::Hep3Vector& P, int side, int fan_number) const +double LArWheelCalculator::AmplitudeOfSurface(const GeoTrf::Vector3D& P, int side, int fan_number) const { return m_distanceCalcImpl->AmplitudeOfSurface(P, side, fan_number); } diff --git a/GeoSpecialShapes/src/LArWheelCalculator_Impl/DistanceCalculatorSaggingOff.cxx b/GeoSpecialShapes/src/LArWheelCalculator_Impl/DistanceCalculatorSaggingOff.cxx index 8d0da45b83dfa6a6addfb9717fde8c10ff625b18..47289c4589b0173bf938533fd5c75361086de19f 100644 --- a/GeoSpecialShapes/src/LArWheelCalculator_Impl/DistanceCalculatorSaggingOff.cxx +++ b/GeoSpecialShapes/src/LArWheelCalculator_Impl/DistanceCalculatorSaggingOff.cxx @@ -4,6 +4,7 @@ #include "DistanceCalculatorSaggingOff.h" #include "GeoSpecialShapes/LArWheelCalculator.h" +#include "GeoModelKernel/GeoDefinitions.h" //#include "GaudiKernel/PhysicalConstants.h" #include<cassert> @@ -35,9 +36,9 @@ namespace LArWheelCalculator_Impl } #ifndef LARWC_DTNF_NEW - double DistanceCalculatorSaggingOff::DistanceToTheNeutralFibre(const CLHEP::Hep3Vector& P, int /*fan_number*/) const + double DistanceCalculatorSaggingOff::DistanceToTheNeutralFibre(const GeoTrf::Vector3D& P, int /*fan_number*/) const #else - double DistanceCalculatorSaggingOff::DistanceToTheNeutralFibre_ref(const CLHEP::Hep3Vector& P, int /*fan_number*/) const + double DistanceCalculatorSaggingOff::DistanceToTheNeutralFibre_ref(const GeoTrf::Vector3D& P, int /*fan_number*/) const #endif { assert(P.y() > 0.); @@ -151,9 +152,9 @@ namespace LArWheelCalculator_Impl // IMPROVED PERFORMANCE #ifdef LARWC_DTNF_NEW - double DistanceCalculatorSaggingOff::DistanceToTheNeutralFibre(const CLHEP::Hep3Vector& P, int /*fan_number*/) const + double DistanceCalculatorSaggingOff::DistanceToTheNeutralFibre(const GeoTrf::Vector3D& P, int /*fan_number*/) const #else - double DistanceCalculatorSaggingOff::DistanceToTheNeutralFibre_ref(const CLHEP::Hep3Vector& P, int /*fan_number*/) const + double DistanceCalculatorSaggingOff::DistanceToTheNeutralFibre_ref(const GeoTrf::Vector3D& P, int /*fan_number*/) const #endif { double z = P.z() - lwc()->m_StraightStartSection; @@ -243,9 +244,9 @@ namespace LArWheelCalculator_Impl std::abort(); } - CLHEP::Hep3Vector DistanceCalculatorSaggingOff::NearestPointOnNeutralFibre(const CLHEP::Hep3Vector &P, int /*fan_number*/) const + GeoTrf::Vector3D DistanceCalculatorSaggingOff::NearestPointOnNeutralFibre(const GeoTrf::Vector3D &P, int /*fan_number*/) const { - CLHEP::Hep3Vector result; + GeoTrf::Vector3D result; double z = P.z() - lwc()->m_StraightStartSection; double x = P.x(); double y = P.y(); @@ -279,18 +280,33 @@ namespace LArWheelCalculator_Impl const double x_prime = x * cos_a - z * sin_a; const double straight_part = (lwc()->m_QuarterWaveLength - lwc()->m_FanFoldRadius * sin_a) / cos_a; const double dz = straight_part - z_prime; - if (dz > 0) result.set(0., y, z_prime); + if (dz > 0) { + //result.set(0., y, z_prime); + result(0)=0.; + result(1)=y; + result(2)=z_prime; + } + else { double a = atan(fabs(dz / (x_prime + lwc()->m_FanFoldRadius))); - result.set(lwc()->m_FanFoldRadius * (cos(a) - 1), y, straight_part + lwc()->m_FanFoldRadius * sin(a)); + //result.set(lwc()->m_FanFoldRadius * (cos(a) - 1), y, straight_part + lwc()->m_FanFoldRadius * sin(a)); + result(0) = lwc()->m_FanFoldRadius * (cos(a) - 1); + result(1) = y; + result(2) = straight_part + lwc()->m_FanFoldRadius * sin(a); } - result.rotateY(asin(sin_a)); + //result.rotateY(asin(sin_a)); + result = GeoTrf::RotateY3D (asin(sin_a))* result; if(begin_qw){ - result.setX(-result.x()); - result.setZ(-result.z()); + //result.setX(-result.x()); + //result.setZ(-result.z()); + result(0) = - result(0) ; + result(2) = - result(2) ; } - if((nqwave % 2) == 0) result.setX(-result.x()); - result.setZ(result.z() + nqwave * lwc()->m_HalfWaveLength); + if((nqwave % 2) == 0) + //result.setX(-result.x()); + result(0) = - result(0) ; + //result.setZ(result.z() + nqwave * lwc()->m_HalfWaveLength); + result(2) = result(2) + nqwave * lwc()->m_HalfWaveLength ; } else { if(nqwave == 0) x = -x; else z = lwc()->m_ActiveLength - z; @@ -300,7 +316,10 @@ namespace LArWheelCalculator_Impl ( x < lwc()->m_FanFoldRadius || x < - lwc()->m_StraightStartSection * z / local_straight_section / tan_beta)) { - result.set(0., y, z); + //result.set(0., y, z); + result(0) = 0.; + result(1) = y; + result(2) = z; } else { const double z_prime = z * cos_a + x * sin_a; @@ -308,32 +327,47 @@ namespace LArWheelCalculator_Impl if(z_prime < local_straight_section) { double a = fabs(atan((local_straight_section - z_prime) / (x_prime - lwc()->m_FanFoldRadius))); - result.set(lwc()->m_FanFoldRadius * (1 - cos(a)), y, local_straight_section - lwc()->m_FanFoldRadius * sin(a)); + //result.set(lwc()->m_FanFoldRadius * (1 - cos(a)), y, local_straight_section - lwc()->m_FanFoldRadius * sin(a)); + result(0) = lwc()->m_FanFoldRadius * (1 - cos(a)); + result(1) = y; + result(2) = local_straight_section - lwc()->m_FanFoldRadius * sin(a); + } else { double straight_part = (lwc()->m_QuarterWaveLength - lwc()->m_FanFoldRadius * sin_a) / cos_a; if(z_prime <= straight_part) { - result.set(0., y, z_prime); + //result.set(0., y, z_prime); + result(0) = 0.; + result(1) = y; + result(2) = z_prime; + } else { double a = fabs(atan((straight_part - z_prime) / (x_prime + lwc()->m_FanFoldRadius)) ); - result.set(lwc()->m_FanFoldRadius * (cos(a) - 1), y, straight_part + lwc()->m_FanFoldRadius * sin(a)); + //result.set(lwc()->m_FanFoldRadius * (cos(a) - 1), y, straight_part + lwc()->m_FanFoldRadius * sin(a)); + result(0) = lwc()->m_FanFoldRadius * (cos(a) - 1); + result(1) = y; + result(2) = straight_part + lwc()->m_FanFoldRadius * sin(a); } } - result.rotateY(asin(sin_a)); + //result.rotateY(asin(sin_a)); + result = GeoTrf::RotateY3D (asin(sin_a))* result; } if(nqwave != 0){ - result.setZ(lwc()->m_ActiveLength - result.z()); + //result.setZ(lwc()->m_ActiveLength - result.z()); + result(2) = lwc()->m_ActiveLength - result(2); } else { - result.setX(-result.x()); + //result.setX(-result.x()); + result(0) = - result(0); } } - result.setZ(result.z() + lwc()->m_StraightStartSection); + //result.setZ(result.z() + lwc()->m_StraightStartSection); + result(2) = result(2)+ lwc()->m_StraightStartSection; return result; } // IMPROVED VERSION - CLHEP::Hep3Vector DistanceCalculatorSaggingOff::NearestPointOnNeutralFibre_ref(const CLHEP::Hep3Vector &P, int /*fan_number*/) const + GeoTrf::Vector3D DistanceCalculatorSaggingOff::NearestPointOnNeutralFibre_ref(const GeoTrf::Vector3D &P, int /*fan_number*/) const { - CLHEP::Hep3Vector result; + GeoTrf::Vector3D result; double z = P.z() - lwc()->m_StraightStartSection; double x = P.x(); double y = P.y(); @@ -364,10 +398,16 @@ namespace LArWheelCalculator_Impl double a1 = atan(fabs(dz / (x_prime + lwc()->m_FanFoldRadius))); const double x1 = lwc()->m_FanFoldRadius * (cos(a1) - 1.); const double z1 = straight_part + lwc()->m_FanFoldRadius * sin(a1); - result.set(x1*cos_a - z1*sin_a, y, z1*cos_a + z1*sin_a); + //result.set(x1*cos_a - z1*sin_a, y, z1*cos_a + z1*sin_a); + result(0) = x1*cos_a - z1*sin_a; + result(1) = y; + result(2) = z1*cos_a + z1*sin_a; return result; } else if(z_prime > -straight_part){ // straight part - result.set(-z_prime * sin_a, y, z_prime*cos_a + zshift); + //result.set(-z_prime * sin_a, y, z_prime*cos_a + zshift); + result(0) = -z_prime * sin_a; + result(1) = y; + result(2) = z_prime*cos_a + zshift; return result; } else { // low fold const double x_prime = x * cos_a - z * sin_a; @@ -375,7 +415,10 @@ namespace LArWheelCalculator_Impl double a1 = atan(fabs(dz / (x_prime + lwc()->m_FanFoldRadius))); const double x1 = lwc()->m_FanFoldRadius * (cos(a1) - 1.); const double z1 = straight_part + lwc()->m_FanFoldRadius * sin(a1); - result.set(x1*cos_a - z1*sin_a, y, z1*cos_a + z1*sin_a); + //result.set(x1*cos_a - z1*sin_a, y, z1*cos_a + z1*sin_a); + result(0) = x1*cos_a - z1*sin_a; + result(1) = y; + result(2) = z1*cos_a + z1*sin_a; return result; } } else { // ending quarter-wave @@ -393,28 +436,46 @@ namespace LArWheelCalculator_Impl (x < lwc()->m_FanFoldRadius || x < - lwc()->m_StraightStartSection * z / local_straight_section / tan_beta)) { - result.set(0., y, z); + //result.set(0., y, z); + result(0) = 0.; + result(1) = y ; + result(2) = z ; } else { const double z_prime = z * cos_a + x * sin_a; const double x_prime = x * cos_a - z * sin_a; if(z_prime < local_straight_section) { double a = fabs(atan((local_straight_section - z_prime) / (x_prime - lwc()->m_FanFoldRadius))); - result.set(lwc()->m_FanFoldRadius * (1 - cos(a)), y, local_straight_section - lwc()->m_FanFoldRadius * sin(a)); + //result.set(lwc()->m_FanFoldRadius * (1 - cos(a)), y, local_straight_section - lwc()->m_FanFoldRadius * sin(a)); + result(0) = lwc()->m_FanFoldRadius * (1 - cos(a)); + result(1) = y ; + result(2) = local_straight_section - lwc()->m_FanFoldRadius * sin(a) ; } else { double straight_part = (lwc()->m_QuarterWaveLength - lwc()->m_FanFoldRadius * sin_a) / cos_a; if(z_prime <= straight_part) { - result.set(0., y, z_prime); + //result.set(0., y, z_prime); + result(0) = 0.; + result(1) = y ; + result(2) = z_prime; } else { double a = fabs(atan((straight_part - z_prime) / (x_prime + lwc()->m_FanFoldRadius)) ); - result.set(lwc()->m_FanFoldRadius * (cos(a) - 1), y, straight_part + lwc()->m_FanFoldRadius * sin(a)); + //result.set(lwc()->m_FanFoldRadius * (cos(a) - 1), y, straight_part + lwc()->m_FanFoldRadius * sin(a)); + result(0) = lwc()->m_FanFoldRadius * (cos(a) - 1); + result(1) = y ; + result(2) = straight_part + lwc()->m_FanFoldRadius * sin(a) ; } } - result.rotateY(asin(sin_a)); + //result.rotateY(asin(sin_a)); + result = GeoTrf::RotateY3D (asin(sin_a)) * result; } - if(sqw) result.setX(-result.x()); - else result.setZ(lwc()->m_ActiveLength - result.z()); - result.setZ(result.z() + lwc()->m_StraightStartSection); + if(sqw) + //result.setX(-result.x()); + result(0) = - result(0); + else + //result.setZ(lwc()->m_ActiveLength - result.z()); + result(2) = lwc()->m_ActiveLength - result(2); + //result.setZ(result.z() + lwc()->m_StraightStartSection); + result(2) = result(2) + lwc()->m_StraightStartSection ; return result; } @@ -424,7 +485,7 @@ namespace LArWheelCalculator_Impl > 0 - greater phi = 0 - neutral fibre */ - double DistanceCalculatorSaggingOff::AmplitudeOfSurface(const CLHEP::Hep3Vector& P, int side, int /*fan_number*/) const + double DistanceCalculatorSaggingOff::AmplitudeOfSurface(const GeoTrf::Vector3D& P, int side, int /*fan_number*/) const { double result = 0.; double rho = lwc()->m_FanFoldRadius; diff --git a/GeoSpecialShapes/src/LArWheelCalculator_Impl/DistanceCalculatorSaggingOff.h b/GeoSpecialShapes/src/LArWheelCalculator_Impl/DistanceCalculatorSaggingOff.h index a09257e59e1cc46df8237365bc18e2c83764eaca..6812002641b741a90376f0f18497db702ad47298 100644 --- a/GeoSpecialShapes/src/LArWheelCalculator_Impl/DistanceCalculatorSaggingOff.h +++ b/GeoSpecialShapes/src/LArWheelCalculator_Impl/DistanceCalculatorSaggingOff.h @@ -7,6 +7,7 @@ #include "IDistanceCalculator.h" +#include "GeoModelKernel/GeoDefinitions.h" //#include "RDBAccessSvc/IRDBAccessSvc.h" //#include "GeoModelUtilities/DecodeVersionKey.h" @@ -31,11 +32,11 @@ namespace LArWheelCalculator_Impl /// @name Geometry methods /// @{ - virtual double DistanceToTheNeutralFibre(const CLHEP::Hep3Vector &p, int fan_number) const; - virtual double DistanceToTheNeutralFibre_ref(const CLHEP::Hep3Vector &p, int fan_number) const; - virtual CLHEP::Hep3Vector NearestPointOnNeutralFibre(const CLHEP::Hep3Vector &p, int fan_number) const; - virtual CLHEP::Hep3Vector NearestPointOnNeutralFibre_ref(const CLHEP::Hep3Vector &p, int fan_number) const; - virtual double AmplitudeOfSurface(const CLHEP::Hep3Vector& P, int side, int fan_number) const; + virtual double DistanceToTheNeutralFibre(const GeoTrf::Vector3D &p, int fan_number) const; + virtual double DistanceToTheNeutralFibre_ref(const GeoTrf::Vector3D &p, int fan_number) const; + virtual GeoTrf::Vector3D NearestPointOnNeutralFibre(const GeoTrf::Vector3D &p, int fan_number) const; + virtual GeoTrf::Vector3D NearestPointOnNeutralFibre_ref(const GeoTrf::Vector3D &p, int fan_number) const; + virtual double AmplitudeOfSurface(const GeoTrf::Vector3D& P, int side, int fan_number) const; /// @} /// Return the calculator: diff --git a/GeoSpecialShapes/src/LArWheelCalculator_Impl/DistanceCalculatorSaggingOn.cxx b/GeoSpecialShapes/src/LArWheelCalculator_Impl/DistanceCalculatorSaggingOn.cxx index 03c66928c55c835930dfb13a45a40ad93f45a296..c7cf211be4d4387a8c7030d59eeb523c11ae7709 100644 --- a/GeoSpecialShapes/src/LArWheelCalculator_Impl/DistanceCalculatorSaggingOn.cxx +++ b/GeoSpecialShapes/src/LArWheelCalculator_Impl/DistanceCalculatorSaggingOn.cxx @@ -7,7 +7,8 @@ //#include "GaudiKernel/MsgStream.h" #include "DistanceCalculatorSaggingOn.h" -#include "CLHEP/Vector/ThreeVector.h" +//#include "CLHEP/Vector/ThreeVector.h" +#include "GeoModelKernel/GeoDefinitions.h" #include <vector> #include <stdexcept> @@ -124,23 +125,23 @@ namespace LArWheelCalculator_Impl // side of the fan; negative - lower phi. // // Uses m_fan_number to compute sagging. - double DistanceCalculatorSaggingOn::DistanceToTheNeutralFibre(const CLHEP::Hep3Vector &p, int fan_number) const { - CLHEP::Hep3Vector sagging_corrected( p.x()+get_sagging(p, fan_number), p.y(), p.z() ); + double DistanceCalculatorSaggingOn::DistanceToTheNeutralFibre(const GeoTrf::Vector3D &p, int fan_number) const { + GeoTrf::Vector3D sagging_corrected( p.x()+get_sagging(p, fan_number), p.y(), p.z() ); return parent::DistanceToTheNeutralFibre(sagging_corrected, fan_number); } - CLHEP::Hep3Vector DistanceCalculatorSaggingOn::NearestPointOnNeutralFibre(const CLHEP::Hep3Vector &p, int fan_number) const { - CLHEP::Hep3Vector sagging_corrected( p.x()+get_sagging(p, fan_number), p.y(), p.z() ); + GeoTrf::Vector3D DistanceCalculatorSaggingOn::NearestPointOnNeutralFibre(const GeoTrf::Vector3D &p, int fan_number) const { + GeoTrf::Vector3D sagging_corrected( p.x()+get_sagging(p, fan_number), p.y(), p.z() ); return parent::NearestPointOnNeutralFibre(sagging_corrected, fan_number); } - double DistanceCalculatorSaggingOn::AmplitudeOfSurface(const CLHEP::Hep3Vector& p, int side, int fan_number) const { + double DistanceCalculatorSaggingOn::AmplitudeOfSurface(const GeoTrf::Vector3D& p, int side, int fan_number) const { return parent::AmplitudeOfSurface(p, side, fan_number) - get_sagging(p, fan_number); } // the function uses m_fan_number for phi-dependent sagging computation - double DistanceCalculatorSaggingOn::get_sagging(const CLHEP::Hep3Vector &P, int fan_number) const { + double DistanceCalculatorSaggingOn::get_sagging(const GeoTrf::Vector3D &P, int fan_number) const { #ifdef HARDDEBUG std::cout << "get_sagging: MFN = " << fan_number << std::endl; #endif @@ -154,7 +155,9 @@ namespace LArWheelCalculator_Impl //if(n >= m_NumberOfFans) n -= m_NumberOfFans; //const std::vector<double>& sp = m_sagging_parameter[n]; const std::vector<double>& sp = m_sagging_parameter[fan_number]; - double R = P.r() / SYSTEM_OF_UNITS::mm; + + //double R = P.r() / SYSTEM_OF_UNITS::mm; + double R = std::sqrt(P(0)*P(0) + P(1)*P(1) + P(2)*P(2)) / SYSTEM_OF_UNITS::mm; double r = R; double result = sp[0]; result += R * sp[1]; diff --git a/GeoSpecialShapes/src/LArWheelCalculator_Impl/DistanceCalculatorSaggingOn.h b/GeoSpecialShapes/src/LArWheelCalculator_Impl/DistanceCalculatorSaggingOn.h index e10c79d26da8db1753316e3f27ead24e9f7cd1e6..7ca04481fc05dfbc1ffa5a18ae59404957aa5b28 100644 --- a/GeoSpecialShapes/src/LArWheelCalculator_Impl/DistanceCalculatorSaggingOn.h +++ b/GeoSpecialShapes/src/LArWheelCalculator_Impl/DistanceCalculatorSaggingOn.h @@ -6,6 +6,7 @@ #define __LArWheelCalculator_Impl_DistanceCalculatorSaggingOn_H__ #include "DistanceCalculatorSaggingOff.h" +#include "GeoModelKernel/GeoDefinitions.h" #include <vector> class LArWheelCalculator; @@ -32,14 +33,14 @@ namespace LArWheelCalculator_Impl /// @name Geometry methods /// @{ - virtual double DistanceToTheNeutralFibre(const CLHEP::Hep3Vector &p, int fan_number) const; - virtual CLHEP::Hep3Vector NearestPointOnNeutralFibre(const CLHEP::Hep3Vector &p, int fan_number) const; - virtual double AmplitudeOfSurface(const CLHEP::Hep3Vector& P, int side, int fan_number) const; + virtual double DistanceToTheNeutralFibre(const GeoTrf::Vector3D &p, int fan_number) const; + virtual GeoTrf::Vector3D NearestPointOnNeutralFibre(const GeoTrf::Vector3D &p, int fan_number) const; + virtual double AmplitudeOfSurface(const GeoTrf::Vector3D& P, int side, int fan_number) const; /// @} private: - double get_sagging(const CLHEP::Hep3Vector &P, int fan_number) const; + double get_sagging(const GeoTrf::Vector3D &P, int fan_number) const; void init_sagging_parameters(); std::vector<std::vector<double> > m_sagging_parameter; diff --git a/GeoSpecialShapes/src/LArWheelCalculator_Impl/IDistanceCalculator.h b/GeoSpecialShapes/src/LArWheelCalculator_Impl/IDistanceCalculator.h index d45f4743c22d4051719065ca51c55ffb4d88c7a3..4bc81b21653cc4dabf03437d0dc5e0356716b91c 100644 --- a/GeoSpecialShapes/src/LArWheelCalculator_Impl/IDistanceCalculator.h +++ b/GeoSpecialShapes/src/LArWheelCalculator_Impl/IDistanceCalculator.h @@ -6,7 +6,8 @@ #define __LArWheelCalculator_Impl_IDistanceCalculator_H__ -#include "CLHEP/Vector/ThreeVector.h" +//#include "CLHEP/Vector/ThreeVector.h" +#include "GeoModelKernel/GeoDefinitions.h" namespace LArWheelCalculator_Impl { @@ -26,13 +27,13 @@ namespace LArWheelCalculator_Impl /// @name Geometry methods /// @{ - virtual double DistanceToTheNeutralFibre(const CLHEP::Hep3Vector &p, + virtual double DistanceToTheNeutralFibre(const GeoTrf::Vector3D &p, int fan_number) const = 0; - virtual CLHEP::Hep3Vector NearestPointOnNeutralFibre(const CLHEP::Hep3Vector &p, + virtual GeoTrf::Vector3D NearestPointOnNeutralFibre(const GeoTrf::Vector3D &p, int fan_number) const = 0; - virtual double AmplitudeOfSurface(const CLHEP::Hep3Vector& p, int side, + virtual double AmplitudeOfSurface(const GeoTrf::Vector3D& p, int side, int fan_number) const = 0; /// @} diff --git a/GeoSpecialShapes/src/LArWheelCalculator_Impl/IFanCalculator.h b/GeoSpecialShapes/src/LArWheelCalculator_Impl/IFanCalculator.h index 4cd70f9643594ab4df7054c5d3dab955f43b25a9..cd0f7dc84b3fc4971fca685c26ac4850b8537dea 100644 --- a/GeoSpecialShapes/src/LArWheelCalculator_Impl/IFanCalculator.h +++ b/GeoSpecialShapes/src/LArWheelCalculator_Impl/IFanCalculator.h @@ -6,7 +6,8 @@ #define __LArWheelCalculator_Impl_IFanCalculator_H__ -#include "CLHEP/Vector/ThreeVector.h" +//#include "CLHEP/Vector/ThreeVector.h" +#include "GeoModelKernel/GeoDefinitions.h" namespace LArWheelCalculator_Impl { @@ -26,12 +27,12 @@ namespace LArWheelCalculator_Impl /// @name Geometry methods /// @{ - virtual double DistanceToTheNearestFan(CLHEP::Hep3Vector &p, + virtual double DistanceToTheNearestFan(GeoTrf::Vector3D &p, int & out_fan_number) const = 0; virtual int PhiGapNumberForWheel(int i) const = 0; - virtual std::pair<int, int> GetPhiGapAndSide(const CLHEP::Hep3Vector &p) const = 0; + virtual std::pair<int, int> GetPhiGapAndSide(const GeoTrf::Vector3D &p) const = 0; /// @} diff --git a/GeoSpecialShapes/src/LArWheelCalculator_Impl/ModuleFanCalculator.cxx b/GeoSpecialShapes/src/LArWheelCalculator_Impl/ModuleFanCalculator.cxx index 04f19f603a8f06117b01c4e811593bfe90f24203..3008f524a7db23c842152e2e201d2a2eab13f724 100644 --- a/GeoSpecialShapes/src/LArWheelCalculator_Impl/ModuleFanCalculator.cxx +++ b/GeoSpecialShapes/src/LArWheelCalculator_Impl/ModuleFanCalculator.cxx @@ -5,6 +5,8 @@ #include "ModuleFanCalculator.h" #include "GeoSpecialShapes/LArWheelCalculator.h" +#include "GeoModelKernel/GeoDefinitions.h" +//#include "CLHEP/Vector/ThreeVector.h" //#include "GaudiKernel/PhysicalConstants.h" //using namespace Gaudi::Units; @@ -27,14 +29,17 @@ namespace LArWheelCalculator_Impl { } - double ModuleFanCalculator::DistanceToTheNearestFan(CLHEP::Hep3Vector &p, int & out_fan_number) const + double ModuleFanCalculator::DistanceToTheNearestFan(GeoTrf::Vector3D &p, int & out_fan_number) const { - int fan_number = int((p.phi() - SYSTEM_OF_UNITS::halfpi - lwc()->m_ZeroFanPhi_ForDetNeaFan) / lwc()->m_FanStepOnPhi); + //int fan_number = int((p.phi() - SYSTEM_OF_UNITS::halfpi - lwc()->m_ZeroFanPhi_ForDetNeaFan) / lwc()->m_FanStepOnPhi); + int fan_number = int((std::atan2(p(1),p(0)) - SYSTEM_OF_UNITS::halfpi - lwc()->m_ZeroFanPhi_ForDetNeaFan) / lwc()->m_FanStepOnPhi); double angle = lwc()->m_FanStepOnPhi * fan_number + lwc()->m_ZeroFanPhi_ForDetNeaFan; #ifdef HARDDEBUG printf("DistanceToTheNearestFan: initial FN %4d\n", fan_number); #endif - p.rotateZ(-angle); + //p.rotateZ(-angle); + p=GeoTrf::RotateZ3D(-angle)*p; + // determine search direction double d0 = lwc()->DistanceToTheNeutralFibre(p, lwc()->adjust_fan_number(fan_number)); double d1 = d0; @@ -42,7 +47,8 @@ namespace LArWheelCalculator_Impl if(d0 < 0.) delta = -1; // search direction has been determined angle = - lwc()->m_FanStepOnPhi * delta; do { // search: - p.rotateZ(angle); + //p.rotateZ(angle); + p = GeoTrf::RotateZ3D(angle)*p; fan_number += delta; d1 = lwc()->DistanceToTheNeutralFibre(p, lwc()->adjust_fan_number(fan_number)); } while(d0 * d1 > 0.); @@ -51,14 +57,19 @@ namespace LArWheelCalculator_Impl int adj_fan_number = fan_number; if(adj_fan_number < lwc()->m_FirstFan) { - p.rotateZ((adj_fan_number - lwc()->m_FirstFan) * lwc()->m_FanStepOnPhi); + //p.rotateZ((adj_fan_number - lwc()->m_FirstFan) * lwc()->m_FanStepOnPhi); + p = GeoTrf::RotateZ3D((adj_fan_number - lwc()->m_FirstFan) * lwc()->m_FanStepOnPhi)*p; + //p.RotateZ3D((adj_fan_number - lwc()->m_FirstFan) * lwc()->m_FanStepOnPhi); + p = GeoTrf::RotateZ3D((adj_fan_number - lwc()->m_FirstFan) * lwc()->m_FanStepOnPhi)*p; adj_fan_number = lwc()->m_FirstFan; } else if(adj_fan_number >= lwc()->m_LastFan) { - p.rotateZ((adj_fan_number - lwc()->m_LastFan + 1) * lwc()->m_FanStepOnPhi); + //p.rotateZ((adj_fan_number - lwc()->m_LastFan + 1) * lwc()->m_FanStepOnPhi); + p = GeoTrf::RotateZ3D((adj_fan_number - lwc()->m_LastFan + 1) * lwc()->m_FanStepOnPhi)*p; adj_fan_number = lwc()->m_LastFan - 1; } - p.rotateZ(-0.5 * angle); + //p.rotateZ(-0.5 * angle); + p = GeoTrf::RotateZ3D(-0.5 * angle)*p; out_fan_number = adj_fan_number; return lwc()->DistanceToTheNeutralFibre(p, adj_fan_number); } @@ -71,17 +82,18 @@ namespace LArWheelCalculator_Impl return i; } - std::pair<int, int> ModuleFanCalculator::GetPhiGapAndSide(const CLHEP::Hep3Vector &p) const + std::pair<int, int> ModuleFanCalculator::GetPhiGapAndSide(const GeoTrf::Vector3D &p) const { // Note: this object was changed from static to local for thread-safety. // If this is found to be too costly we can re-evaluate. - CLHEP::Hep3Vector p1 = p; - - int fan_number = int((p.phi() - SYSTEM_OF_UNITS::halfpi - lwc()->m_ZeroFanPhi) / lwc()->m_FanStepOnPhi); + GeoTrf::Vector3D p1 = p; + //int fan_number = int((p.phi() - SYSTEM_OF_UNITS::halfpi - lwc()->m_ZeroFanPhi) / lwc()->m_FanStepOnPhi); + int fan_number = int((std::atan2(p(1),p(0)) - SYSTEM_OF_UNITS::halfpi - lwc()->m_ZeroFanPhi) / lwc()->m_FanStepOnPhi); double angle = lwc()->m_FanStepOnPhi * fan_number + lwc()->m_ZeroFanPhi; - p1.rotateZ(-angle); - + //p1.rotateZ(-angle); + p1 =GeoTrf::RotateZ3D(-angle) * p1; + double d0 = lwc()->DistanceToTheNeutralFibre(p1, lwc()->adjust_fan_number(fan_number)); double d1 = d0; @@ -89,7 +101,8 @@ namespace LArWheelCalculator_Impl if(d0 < 0.) delta = -1; angle = - lwc()->m_FanStepOnPhi * delta; do { - p1.rotateZ(angle); + //p1.rotateZ(angle); + p1 = GeoTrf::RotateZ3D(angle)*p1; fan_number += delta; d1 = lwc()->DistanceToTheNeutralFibre(p1, lwc()->adjust_fan_number(fan_number)); } while(d0 * d1 > 0.); @@ -100,7 +113,8 @@ namespace LArWheelCalculator_Impl if(adj_fan_number < lwc()->m_FirstFan) adj_fan_number = lwc()->m_FirstFan - 1; else if(adj_fan_number > lwc()->m_LastFan) adj_fan_number = lwc()->m_LastFan; - p1.rotateZ(-0.5 * angle); + //p1.rotateZ(-0.5 * angle); + p1 = GeoTrf::RotateZ3D(-0.5 * angle) * p1; double dd = lwc()->DistanceToTheNeutralFibre(p1, adj_fan_number); int side = dd < 0.? -1: 1; #ifdef HARDDEBUG diff --git a/GeoSpecialShapes/src/LArWheelCalculator_Impl/ModuleFanCalculator.h b/GeoSpecialShapes/src/LArWheelCalculator_Impl/ModuleFanCalculator.h index 327c70cb0e84383fcfc00ee077f6cbd63e657697..da2cfbce683a9d16a1c594b4ca344c2202a9ef85 100644 --- a/GeoSpecialShapes/src/LArWheelCalculator_Impl/ModuleFanCalculator.h +++ b/GeoSpecialShapes/src/LArWheelCalculator_Impl/ModuleFanCalculator.h @@ -8,6 +8,7 @@ #include "IFanCalculator.h" //#include "RDBAccessSvc/IRDBAccessSvc.h" //#include "GeoModelUtilities/DecodeVersionKey.h" +#include "GeoModelKernel/GeoDefinitions.h" class LArWheelCalculator; @@ -23,9 +24,9 @@ namespace LArWheelCalculator_Impl const DecodeVersionKey & larVersionKey*/); // geometry methods: - virtual double DistanceToTheNearestFan(CLHEP::Hep3Vector &p, int & out_fan_number) const; + virtual double DistanceToTheNearestFan(GeoTrf::Vector3D &p, int & out_fan_number) const; virtual int PhiGapNumberForWheel(int i) const; - virtual std::pair<int, int> GetPhiGapAndSide(const CLHEP::Hep3Vector &p) const; + virtual std::pair<int, int> GetPhiGapAndSide(const GeoTrf::Vector3D &p) const; inline const LArWheelCalculator *lwc() const { return m_lwc; }; diff --git a/GeoSpecialShapes/src/LArWheelCalculator_Impl/WheelFanCalculator.h b/GeoSpecialShapes/src/LArWheelCalculator_Impl/WheelFanCalculator.h index 98632d26b85396d5a9a45a9360e58f1526eff729..c3721425dafe76e5d119f664428d0200bf4d5939 100644 --- a/GeoSpecialShapes/src/LArWheelCalculator_Impl/WheelFanCalculator.h +++ b/GeoSpecialShapes/src/LArWheelCalculator_Impl/WheelFanCalculator.h @@ -9,6 +9,7 @@ //#include "RDBAccessSvc/IRDBAccessSvc.h" //#include "GeoModelUtilities/DecodeVersionKey.h" #include "GeoSpecialShapes/LArWheelCalculator.h" +#include "GeoModelKernel/GeoDefinitions.h" //#include "GaudiKernel/PhysicalConstants.h" // Physical constants @@ -33,7 +34,7 @@ namespace LArWheelCalculator_Impl class DistanceToTheNeutralFibre_OfFan<SaggingOn_t> { public: - static inline double calculate(const LArWheelCalculator* lwc, int fan_number, CLHEP::Hep3Vector &p) { + static inline double calculate(const LArWheelCalculator* lwc, int fan_number, GeoTrf::Vector3D &p) { //lwc->set_m_fan_number(fan_number); return lwc->DistanceToTheNeutralFibre(p, lwc->adjust_fan_number(fan_number)); } @@ -42,7 +43,7 @@ namespace LArWheelCalculator_Impl template<> class DistanceToTheNeutralFibre_OfFan<SaggingOff_t> { public: - static inline double calculate(const LArWheelCalculator* lwc, int /*fan_number*/, CLHEP::Hep3Vector &p) { + static inline double calculate(const LArWheelCalculator* lwc, int /*fan_number*/, GeoTrf::Vector3D &p) { // saggingOff distance calculations does not use fan_number, use arbitrary recognisible magic number return lwc->DistanceToTheNeutralFibre(p, -531135); } @@ -115,9 +116,11 @@ namespace LArWheelCalculator_Impl /// @todo Needs documentation template <typename SaggingType, FanSearchDirection_t dir, class NFDistance > inline void rotate_to_nearest_fan(const LArWheelCalculator* lwc, int &fan_number, - const double angle, CLHEP::Hep3Vector &p) + const double angle, GeoTrf::Vector3D &p) { - p.rotateZ(angle); + + //p.rotateZ(angle); + p=GeoTrf::RotateZ3D(angle)*p; StepFan<SaggingType, dir>::next(fan_number); //fan_number += delta; double d1 = NFDistance::calculate(lwc, fan_number, p); @@ -125,7 +128,8 @@ namespace LArWheelCalculator_Impl //while(d0 * d1 > 0.) -> dir*d1 > 0 -> FORWARD: d1 > 0., BACKWARD: d1 < 0. while ( DoSearch<dir>::pred(d1) ) { // search: - p.rotateZ(angle); + //p.rotateZ(angle); + p=GeoTrf::RotateZ3D(angle)*p; StepFan<SaggingType, dir>::next(fan_number); //fan_number += delta; @@ -156,15 +160,17 @@ namespace LArWheelCalculator_Impl /// @name Geometry methods /// @{ - virtual double DistanceToTheNearestFan(CLHEP::Hep3Vector &p, int & out_fan_number) const + virtual double DistanceToTheNearestFan(GeoTrf::Vector3D &p, int & out_fan_number) const { //using Gaudi::Units::halfpi; - int fan_number = int((p.phi() - SYSTEM_OF_UNITS::halfpi - lwc()->m_ZeroFanPhi_ForDetNeaFan) / lwc()->m_FanStepOnPhi); + //int fan_number = int((p.phi() - SYSTEM_OF_UNITS::halfpi - lwc()->m_ZeroFanPhi_ForDetNeaFan) / lwc()->m_FanStepOnPhi); + int fan_number = int((std::atan2(p(1),p(0)) - SYSTEM_OF_UNITS::halfpi - lwc()->m_ZeroFanPhi_ForDetNeaFan) / lwc()->m_FanStepOnPhi); const double angle = lwc()->m_FanStepOnPhi * fan_number + lwc()->m_ZeroFanPhi_ForDetNeaFan; #ifdef HARDDEBUG printf("DistanceToTheNearestFan: initial FN %4d\n", fan_number); #endif - p.rotateZ(-angle); + //p.rotateZ(-angle); + p=GeoTrf::RotateZ3D(- angle)*p; // determine search direction typedef DistanceToTheNeutralFibre_OfFan<SaggingType> NFDistance; @@ -202,7 +208,8 @@ namespace LArWheelCalculator_Impl if(delta > 0) fan_number --; */ - p.rotateZ(-0.5 * step_angle); + //p.rotateZ(-0.5 * step_angle); + p=GeoTrf::RotateZ3D(-0.5 * step_angle)*p; #ifdef HARDDEBUG printf("DistanceToTheNearestFan: final FN %4d\n", fan_number); #endif @@ -216,14 +223,16 @@ namespace LArWheelCalculator_Impl return i; } - virtual std::pair<int, int> GetPhiGapAndSide(const CLHEP::Hep3Vector &p) const + virtual std::pair<int, int> GetPhiGapAndSide(const GeoTrf::Vector3D &p) const { //using Gaudi::Units::halfpi; - CLHEP::Hep3Vector p1 = p; - - int fan_number = int((p.phi() - SYSTEM_OF_UNITS::halfpi - lwc()->m_ZeroFanPhi) / lwc()->m_FanStepOnPhi); + GeoTrf::Vector3D p1 = p; + //int fan_number = int((p.phi() - SYSTEM_OF_UNITS::halfpi - lwc()->m_ZeroFanPhi) / lwc()->m_FanStepOnPhi); + int fan_number = int((std::atan2(p(1),p(0)) - SYSTEM_OF_UNITS::halfpi - lwc()->m_ZeroFanPhi) / lwc()->m_FanStepOnPhi); const double angle = lwc()->m_FanStepOnPhi * fan_number + lwc()->m_ZeroFanPhi; - p1.rotateZ(-angle); + p1=GeoTrf::RotateZ3D(- angle)*p1; + //p1.rotateZ(-angle); + typedef DistanceToTheNeutralFibre_OfFan<SaggingType> NFDistance; @@ -238,7 +247,8 @@ namespace LArWheelCalculator_Impl //if(d0 < 0.) delta = -1; const double step_angle = - lwc()->m_FanStepOnPhi * delta; do { - p1.rotateZ(step_angle); + //p1.rotateZ(step_angle); + p1 = GeoTrf::RotateZ3D(step_angle)*p1; fan_number += delta; d1 = NFDistance::calculate(lwc(), fan_number, p1); //lwc()->set_m_fan_number(fan_number); @@ -248,7 +258,8 @@ namespace LArWheelCalculator_Impl if(delta > 0) fan_number --; if(!lwc()->m_isElectrode) fan_number ++; - p1.rotateZ(-0.5 * step_angle); + //p1.rotateZ(-0.5 * step_angle); + p1 = GeoTrf::RotateZ3D(-0.5 * step_angle)*p1; const int a_fan_number = lwc()->adjust_fan_number(fan_number); double dd = lwc()->DistanceToTheNeutralFibre(p1, a_fan_number);