Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:13:04

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 "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
0018 #include "ActsFatras/Digitization/PlanarSurfaceDrift.hpp"
0019 
0020 #include <array>
0021 #include <memory>
0022 
0023 namespace ActsFatras {
0024 
0025 BOOST_AUTO_TEST_SUITE(Digitization)
0026 
0027 BOOST_AUTO_TEST_CASE(PlanarSurfaceDrift) {
0028   Acts::GeometryContext geoCtx;
0029 
0030   ActsFatras::PlanarSurfaceDrift psd;
0031 
0032   Acts::Vector3 cPosition = Acts::Vector3(10., 50., 12.);
0033   Acts::Vector3 cNormal = Acts::Vector3(1., 1., 1.).normalized();
0034 
0035   auto planeSurface =
0036       Acts::CurvilinearSurface(cPosition, cNormal).planeSurface();
0037 
0038   double depletion = 0.250;
0039 
0040   // Nominal intersection
0041   Acts::Vector3 noDrift(0., 0., 0.);
0042   Acts::Vector3 holeDrift = Acts::Vector3(0.5, 0., 1.).normalized();
0043   Acts::Vector3 chargeDrift = Acts::Vector3(0.5, 0., -1.).normalized();
0044 
0045   // Intersect surface at normal direction and no drift
0046   //
0047   // -> resulting segment must have entry & exit at (0,0) local coordinates
0048   auto noDriftSegment = psd.toReadout(geoCtx, *planeSurface, depletion,
0049                                       cPosition, cNormal, noDrift);
0050 
0051   CHECK_CLOSE_ABS(noDriftSegment[0].x(), 0., Acts::s_epsilon);
0052   CHECK_CLOSE_ABS(noDriftSegment[0].y(), 0., Acts::s_epsilon);
0053   CHECK_CLOSE_ABS(noDriftSegment[1].x(), 0., Acts::s_epsilon);
0054   CHECK_CLOSE_ABS(noDriftSegment[1].y(), 0., Acts::s_epsilon);
0055 
0056   Acts::Vector3 particleDir = Acts::Vector3(2., 1., 1.).normalized();
0057 
0058   // Intersect surface at particleDirection != normal and no drift
0059   //
0060   // -> local segment must be symmetric around (0,0)
0061   noDriftSegment = psd.toReadout(geoCtx, *planeSurface, depletion, cPosition,
0062                                  particleDir, noDrift);
0063 
0064   CHECK_CLOSE_ABS(noDriftSegment[0].x(), -noDriftSegment[1].x(),
0065                   Acts::s_epsilon);
0066   CHECK_CLOSE_ABS(noDriftSegment[0].y(), -noDriftSegment[1].y(),
0067                   Acts::s_epsilon);
0068 
0069   // Intersect surface at particleDirection != normal and a drift somewhat along
0070   // the normal and x
0071   //
0072   // -> local segment must not be symmetric around (0,0)
0073   // -> segment exit at pos local z remains unchanged
0074   // -> segment entry at neg local z changes in x, remains unchanged in y
0075   auto driftedSegment = psd.toReadout(geoCtx, *planeSurface, depletion,
0076                                       cPosition, particleDir, holeDrift);
0077 
0078   BOOST_CHECK(std::abs(driftedSegment[0].x() - driftedSegment[1].x()) >
0079               Acts::s_epsilon);
0080   BOOST_CHECK(std::abs(driftedSegment[0].y() - driftedSegment[1].y()) >
0081               Acts::s_epsilon);
0082   CHECK_CLOSE_ABS(noDriftSegment[1].x(), driftedSegment[1].x(),
0083                   Acts::s_epsilon);
0084   CHECK_CLOSE_ABS(noDriftSegment[1].y(), driftedSegment[1].y(),
0085                   Acts::s_epsilon);
0086   BOOST_CHECK(std::abs(driftedSegment[0].x() - noDriftSegment[0].x()) >
0087               Acts::s_epsilon);
0088   CHECK_CLOSE_ABS(driftedSegment[0].y(), noDriftSegment[0].y(),
0089                   Acts::s_epsilon);
0090 
0091   // Intersect surface at particleDirection != normal and a drift somewhat
0092   // opposite the normal and y
0093   //
0094   // -> local segment must not be symmetric around (0,0)
0095   // -> segment entry at neg local z remains unchanged
0096   // -> segment exit at pos local z changes in x, remains unchanged in y
0097   driftedSegment = psd.toReadout(geoCtx, *planeSurface, depletion, cPosition,
0098                                  particleDir, chargeDrift);
0099 
0100   BOOST_CHECK(std::abs(driftedSegment[0].x() - driftedSegment[1].x()) >
0101               Acts::s_epsilon);
0102   BOOST_CHECK(std::abs(driftedSegment[0].y() - driftedSegment[1].y()) >
0103               Acts::s_epsilon);
0104   CHECK_CLOSE_ABS(noDriftSegment[0].x(), driftedSegment[0].x(),
0105                   Acts::s_epsilon);
0106   CHECK_CLOSE_ABS(noDriftSegment[0].y(), driftedSegment[0].y(),
0107                   Acts::s_epsilon);
0108   BOOST_CHECK(std::abs(driftedSegment[1].x() - noDriftSegment[1].x()) >
0109               Acts::s_epsilon);
0110   CHECK_CLOSE_ABS(driftedSegment[1].y(), noDriftSegment[1].y(),
0111                   Acts::s_epsilon);
0112 }
0113 
0114 BOOST_AUTO_TEST_SUITE_END()
0115 
0116 }  // namespace ActsFatras