Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-24 08:20:48

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #include <boost/test/unit_test.hpp>
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/Tolerance.hpp"
0013 #include "Acts/Geometry/GeometryContext.hpp"
0014 #include "Acts/Surfaces/CurvilinearSurface.hpp"
0015 #include "Acts/Surfaces/PlaneSurface.hpp"
0016 #include "Acts/Surfaces/Surface.hpp"
0017 #include "ActsFatras/Digitization/PlanarSurfaceDrift.hpp"
0018 #include "ActsTests/CommonHelpers/FloatComparisons.hpp"
0019 
0020 #include <array>
0021 #include <memory>
0022 
0023 using namespace ActsFatras;
0024 using namespace Acts;
0025 
0026 namespace ActsTests {
0027 
0028 BOOST_AUTO_TEST_SUITE(DigitizationSuite)
0029 
0030 BOOST_AUTO_TEST_CASE(PlanarSurfaceDriftCase) {
0031   GeometryContext geoCtx;
0032 
0033   PlanarSurfaceDrift psd;
0034 
0035   Vector3 cPosition = Vector3(10., 50., 12.);
0036   Vector3 cNormal = Vector3(1., 1., 1.).normalized();
0037 
0038   std::shared_ptr<PlaneSurface> planeSurface =
0039       CurvilinearSurface(cPosition, cNormal).planeSurface();
0040 
0041   double depletion = 0.250;
0042 
0043   // Nominal intersection
0044   Vector3 noDrift(0., 0., 0.);
0045   Vector3 holeDrift = Vector3(0.5, 0., 1.).normalized();
0046   Vector3 chargeDrift = Vector3(0.5, 0., -1.).normalized();
0047 
0048   // Intersect surface at normal direction and no drift
0049   //
0050   // -> resulting segment must have entry & exit at (0,0) local coordinates
0051   auto noDriftSegment = psd.toReadout(geoCtx, *planeSurface, depletion,
0052                                       cPosition, cNormal, noDrift);
0053 
0054   CHECK_CLOSE_ABS(noDriftSegment[0].x(), 0., s_epsilon);
0055   CHECK_CLOSE_ABS(noDriftSegment[0].y(), 0., s_epsilon);
0056   CHECK_CLOSE_ABS(noDriftSegment[1].x(), 0., s_epsilon);
0057   CHECK_CLOSE_ABS(noDriftSegment[1].y(), 0., s_epsilon);
0058 
0059   Vector3 particleDir = Vector3(2., 1., 1.).normalized();
0060 
0061   // Intersect surface at particleDirection != normal and no drift
0062   //
0063   // -> local segment must be symmetric around (0,0)
0064   noDriftSegment = psd.toReadout(geoCtx, *planeSurface, depletion, cPosition,
0065                                  particleDir, noDrift);
0066 
0067   CHECK_CLOSE_ABS(noDriftSegment[0].x(), -noDriftSegment[1].x(), s_epsilon);
0068   CHECK_CLOSE_ABS(noDriftSegment[0].y(), -noDriftSegment[1].y(), s_epsilon);
0069 
0070   // Intersect surface at particleDirection != normal and a drift somewhat along
0071   // the normal and x
0072   //
0073   // -> local segment must not be symmetric around (0,0)
0074   // -> segment exit at pos local z remains unchanged
0075   // -> segment entry at neg local z changes in x, remains unchanged in y
0076   auto driftedSegment = psd.toReadout(geoCtx, *planeSurface, depletion,
0077                                       cPosition, particleDir, holeDrift);
0078 
0079   BOOST_CHECK(std::abs(driftedSegment[0].x() - driftedSegment[1].x()) >
0080               s_epsilon);
0081   BOOST_CHECK(std::abs(driftedSegment[0].y() - driftedSegment[1].y()) >
0082               s_epsilon);
0083   CHECK_CLOSE_ABS(noDriftSegment[1].x(), driftedSegment[1].x(), s_epsilon);
0084   CHECK_CLOSE_ABS(noDriftSegment[1].y(), driftedSegment[1].y(), s_epsilon);
0085   BOOST_CHECK(std::abs(driftedSegment[0].x() - noDriftSegment[0].x()) >
0086               s_epsilon);
0087   CHECK_CLOSE_ABS(driftedSegment[0].y(), noDriftSegment[0].y(), s_epsilon);
0088 
0089   // Intersect surface at particleDirection != normal and a drift somewhat
0090   // opposite the normal and y
0091   //
0092   // -> local segment must not be symmetric around (0,0)
0093   // -> segment entry at neg local z remains unchanged
0094   // -> segment exit at pos local z changes in x, remains unchanged in y
0095   driftedSegment = psd.toReadout(geoCtx, *planeSurface, depletion, cPosition,
0096                                  particleDir, chargeDrift);
0097 
0098   BOOST_CHECK(std::abs(driftedSegment[0].x() - driftedSegment[1].x()) >
0099               s_epsilon);
0100   BOOST_CHECK(std::abs(driftedSegment[0].y() - driftedSegment[1].y()) >
0101               s_epsilon);
0102   CHECK_CLOSE_ABS(noDriftSegment[0].x(), driftedSegment[0].x(), s_epsilon);
0103   CHECK_CLOSE_ABS(noDriftSegment[0].y(), driftedSegment[0].y(), s_epsilon);
0104   BOOST_CHECK(std::abs(driftedSegment[1].x() - noDriftSegment[1].x()) >
0105               s_epsilon);
0106   CHECK_CLOSE_ABS(driftedSegment[1].y(), noDriftSegment[1].y(), s_epsilon);
0107 }
0108 
0109 BOOST_AUTO_TEST_SUITE_END()
0110 
0111 }  // namespace ActsTests