diff --git a/Detectors/EMCAL/base/include/EMCALBase/Geometry.h b/Detectors/EMCAL/base/include/EMCALBase/Geometry.h index da7f6d2d1b9d4..6615c054ffbe4 100644 --- a/Detectors/EMCAL/base/include/EMCALBase/Geometry.h +++ b/Detectors/EMCAL/base/include/EMCALBase/Geometry.h @@ -222,7 +222,7 @@ class Geometry Int_t GetNCells() const { return mNCells; } Float_t GetLongModuleSize() const { return mLongModuleSize; } Float_t GetTrd1Angle() const { return mTrd1Angle; } - Float_t Get2Trd1Dx2() const { return m2Trd1Dx2; } + Double_t Get2Trd1Dx2() const { return m2Trd1Dx2; } Float_t GetTrd1AlFrontThick() const { return mTrd1AlFrontThick; } Float_t GetTrd1BondPaperThick() const { return mTrd1BondPaperThick; } // -- @@ -699,7 +699,7 @@ class Geometry // TRD1 options - 30-sep-04 Float_t mTrd1Angle = 0; ///< angle in x-z plane (in degree) - Float_t m2Trd1Dx2 = 0; ///< 2*dx2 for TRD1 + Double_t m2Trd1Dx2 = 0; ///< 2*dx2 for TRD1 Float_t mPhiGapForSM = 0; ///< Gap betweeen supermodules in phi direction // Oct 26,2010 diff --git a/Detectors/EMCAL/base/src/ShishKebabTrd1Module.cxx b/Detectors/EMCAL/base/src/ShishKebabTrd1Module.cxx index 1e5f077748894..15750f389aa46 100644 --- a/Detectors/EMCAL/base/src/ShishKebabTrd1Module.cxx +++ b/Detectors/EMCAL/base/src/ShishKebabTrd1Module.cxx @@ -189,7 +189,7 @@ void ShishKebabTrd1Module::DefineFirstModule(const Int_t key) mTheta = 89.25 * TMath::DegToRad(); Double_t al1 = sangle / 2.; Double_t x = 0.5 * (sa * TMath::Cos(al1) + sb * TMath::Sin(al1)); - Double_t y = 0.5 * (sb + sa * TMath::Sin(al1)) * TMath::Cos(al1); + Double_t y = 0.5 * (sb * TMath::Cos(al1) + sa * TMath::Sin(al1)); // inner right corner on r = sr, as in Init() mOK.Set(x, sr + y); // parameters of right line : y = A*z + B in system where zero point is IP. mThetaA = mTheta - sangle / 2.; @@ -223,7 +223,7 @@ Bool_t ShishKebabTrd1Module::SetParameters() sr += mGeometry->GetSteelFrontThickness(); - sa2 = Double_t(mGeometry->Get2Trd1Dx2()); + sa2 = mGeometry->Get2Trd1Dx2(); // PH PrintShish(0); return kTRUE; } diff --git a/Detectors/EMCAL/base/test/testGeometry.cxx b/Detectors/EMCAL/base/test/testGeometry.cxx index f297410b6959f..4cc4a025fb324 100644 --- a/Detectors/EMCAL/base/test/testGeometry.cxx +++ b/Detectors/EMCAL/base/test/testGeometry.cxx @@ -14,6 +14,9 @@ #include #include #include "EMCALBase/Geometry.h" +#include "EMCALBase/ShishKebabTrd1Module.h" +#include +#include #include #include @@ -63,4 +66,37 @@ std::tuple GetRefCellIndex(int CellId) } return std::make_tuple(smod, mod, iphi, ieta); -} \ No newline at end of file +} + +/// \macro Test that neighbouring EMCAL modules touch exactly +/// +/// Test coverage: +/// - the eta side faces of adjacent ShishKebabTrd1Modules coincide +/// - the first module's inner face starts on the inner radius and its left face lies on z = 0 +BOOST_AUTO_TEST_CASE(ModuleFaces_test) +{ + auto geo = o2::emcal::Geometry::GetInstanceFromRunNumber(300000); + const auto& modules = geo->GetShishKebabTrd1Modules(); + const double dx1 = geo->GetEtaModuleSize() / 2., dx2 = geo->Get2Trd1Dx2() / 2., dz = geo->GetLongModuleSize() / 2.; + const double r0 = geo->GetIPDistance() + geo->GetSteelFrontThickness(); + // corner of a module in (z, r): s = -1 inner / +1 outer end, t = -1 small z / +1 large z side + auto corner = [&](const o2::emcal::ShishKebabTrd1Module& m, int s, int t) { + const double th = m.GetTheta(), dx = s < 0 ? dx1 : dx2; + const auto& c = m.GetCenterOfModule(); + return std::array{c.X() + s * dz * std::cos(th) + t * dx * std::sin(th), + c.Y() + s * dz * std::sin(th) - t * dx * std::cos(th)}; + }; + const double tolerance = 1e-10; // cm + BOOST_CHECK_SMALL(corner(modules[0], -1, +1)[1] - r0, tolerance); + BOOST_CHECK_SMALL(corner(modules[0], -1, -1)[0], tolerance); + BOOST_CHECK_SMALL(corner(modules[0], +1, -1)[0], tolerance); + for (std::size_t i = 0; i + 1 < modules.size(); ++i) { + // distance of the next module's small-z face corners from this module's large-z face + const auto a = corner(modules[i], -1, +1), b = corner(modules[i], +1, +1); + const double nz = b[1] - a[1], nr = -(b[0] - a[0]), norm = std::hypot(nz, nr); + for (int s : {-1, +1}) { + const auto p = corner(modules[i + 1], s, -1); + BOOST_CHECK_SMALL(((p[0] - a[0]) * nz + (p[1] - a[1]) * nr) / norm, tolerance); + } + } +}