Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:12:43

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/Common.hpp"
0013 #include "Acts/Definitions/Direction.hpp"
0014 #include "Acts/Material/HomogeneousSurfaceMaterial.hpp"
0015 #include "Acts/Material/Material.hpp"
0016 #include "Acts/Material/MaterialSlab.hpp"
0017 #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
0018 
0019 #include <utility>
0020 
0021 namespace Acts::Test {
0022 
0023 /// Test the constructors
0024 BOOST_AUTO_TEST_CASE(HomogeneousSurfaceMaterial_construction_test) {
0025   // construct the material properties from arguments
0026   Material mat = Material::fromMolarDensity(1., 2., 3., 4., 5.);
0027   MaterialSlab mp(mat, 0.1);
0028 
0029   // Constructor from arguments
0030   HomogeneousSurfaceMaterial hsm(mp, 1.);
0031   // Copy constructor
0032   HomogeneousSurfaceMaterial hsmCopy(hsm);
0033   // Test equality of the copy
0034   BOOST_CHECK_EQUAL(hsm, hsmCopy);
0035   // Copy move constructor
0036   HomogeneousSurfaceMaterial hsmCopyMoved(std::move(hsmCopy));
0037   // Test equality of the copy
0038   BOOST_CHECK_EQUAL(hsm, hsmCopyMoved);
0039   // Assignment constructor
0040   HomogeneousSurfaceMaterial hsmAssigned = hsm;
0041   // Test equality of the assignment
0042   BOOST_CHECK_EQUAL(hsm, hsmAssigned);
0043   // Assignment move constructor
0044   HomogeneousSurfaceMaterial hsmAssignedMoved(std::move(hsmAssigned));
0045   // Test equality of the copy
0046   BOOST_CHECK_EQUAL(hsm, hsmAssignedMoved);
0047 }
0048 
0049 // Test the Scaling
0050 BOOST_AUTO_TEST_CASE(HomogeneousSurfaceMaterial_scaling_test) {
0051   MaterialSlab mat(Material::fromMolarDensity(1., 2., 3., 4., 5.), 0.1);
0052   MaterialSlab matHalf = mat;
0053   matHalf.scaleThickness(0.5);
0054 
0055   HomogeneousSurfaceMaterial hsm(mat, 1.);
0056   hsm.scale(0.5);
0057 
0058   auto matBin = hsm.materialSlab(Vector3(0., 0., 0.));
0059 
0060   BOOST_CHECK_EQUAL(matBin, matHalf);
0061   BOOST_CHECK_NE(matBin, mat);
0062 }
0063 
0064 // Test the Access
0065 BOOST_AUTO_TEST_CASE(HomogeneousSurfaceMaterial_access_test) {
0066   // construct the material properties from arguments
0067   MaterialSlab mat(Material::fromMolarDensity(1., 2., 3., 4., 5.), 0.1);
0068   MaterialSlab matHalf = mat;
0069   matHalf.scaleThickness(0.5);
0070 
0071   MaterialSlab vacuum = MaterialSlab();
0072 
0073   // Constructor from arguments
0074   HomogeneousSurfaceMaterial hsmfwd(mat, 1.);
0075   HomogeneousSurfaceMaterial hsmhalf(mat, 0.5);
0076   HomogeneousSurfaceMaterial hsmbwd(mat, 0.);
0077 
0078   auto mat2d = hsmfwd.materialSlab(Vector2{0., 0.});
0079   auto mat3d = hsmfwd.materialSlab(Vector3{0., 0., 0.});
0080 
0081   // Test equality of the copy
0082   BOOST_CHECK_EQUAL(mat, mat2d);
0083   BOOST_CHECK_EQUAL(mat, mat3d);
0084 
0085   Direction fDir = Direction::Forward();
0086   Direction bDir = Direction::Backward();
0087 
0088   MaterialUpdateStage pre = MaterialUpdateStage::PreUpdate;
0089   MaterialUpdateStage full = MaterialUpdateStage::FullUpdate;
0090   MaterialUpdateStage post = MaterialUpdateStage::PostUpdate;
0091 
0092   // (a) Forward factor material test
0093   BOOST_CHECK_EQUAL(hsmfwd.factor(fDir, full), 1.);
0094   BOOST_CHECK_EQUAL(hsmfwd.factor(fDir, pre), 0.);
0095   BOOST_CHECK_EQUAL(hsmfwd.factor(fDir, post), 1.);
0096 
0097   BOOST_CHECK_EQUAL(hsmfwd.factor(bDir, full), 1.);
0098   BOOST_CHECK_EQUAL(hsmfwd.factor(bDir, pre), 1.);
0099   BOOST_CHECK_EQUAL(hsmfwd.factor(bDir, post), 0.);
0100 
0101   auto matFwdFull = hsmfwd.materialSlab(Vector3{0., 0., 0.}, fDir, full);
0102   auto matBwdFull = hsmfwd.materialSlab(Vector3{0., 0., 0.}, bDir, full);
0103 
0104   auto matFwdPost = hsmfwd.materialSlab(Vector3{0., 0., 0.}, fDir, post);
0105   auto matBwdPost = hsmfwd.materialSlab(Vector3{0., 0., 0.}, bDir, post);
0106 
0107   auto matFwdPre = hsmfwd.materialSlab(Vector3{0., 0., 0.}, fDir, pre);
0108   auto matBwdPre = hsmfwd.materialSlab(Vector3{0., 0., 0.}, bDir, pre);
0109 
0110   BOOST_CHECK_EQUAL(mat, matFwdFull);
0111   BOOST_CHECK_EQUAL(mat, matBwdFull);
0112 
0113   BOOST_CHECK_EQUAL(mat, matFwdPost);
0114   BOOST_CHECK_EQUAL(vacuum, matBwdPost);
0115 
0116   BOOST_CHECK_EQUAL(vacuum, matFwdPre);
0117   BOOST_CHECK_EQUAL(mat, matBwdPre);
0118 
0119   // (b) Split factor material test
0120   BOOST_CHECK_EQUAL(hsmhalf.factor(fDir, full), 1.);
0121   CHECK_CLOSE_REL(hsmhalf.factor(fDir, pre), 0.5, 1e-6);
0122   CHECK_CLOSE_REL(hsmhalf.factor(fDir, post), 0.5, 1e-6);
0123 
0124   BOOST_CHECK_EQUAL(hsmhalf.factor(bDir, full), 1.);
0125   CHECK_CLOSE_REL(hsmhalf.factor(bDir, pre), 0.5, 1e-6);
0126   CHECK_CLOSE_REL(hsmhalf.factor(bDir, post), 0.5, 1e-6);
0127 
0128   matFwdFull = hsmhalf.materialSlab(Vector3{0., 0., 0.}, fDir, full);
0129   matBwdFull = hsmhalf.materialSlab(Vector3{0., 0., 0.}, bDir, full);
0130 
0131   matFwdPost = hsmhalf.materialSlab(Vector3{0., 0., 0.}, fDir, post);
0132   matBwdPost = hsmhalf.materialSlab(Vector3{0., 0., 0.}, bDir, post);
0133 
0134   matFwdPre = hsmhalf.materialSlab(Vector3{0., 0., 0.}, fDir, pre);
0135   matBwdPre = hsmhalf.materialSlab(Vector3{0., 0., 0.}, bDir, pre);
0136 
0137   BOOST_CHECK_EQUAL(mat, matFwdFull);
0138   BOOST_CHECK_EQUAL(mat, matBwdFull);
0139 
0140   BOOST_CHECK_EQUAL(matHalf, matFwdPost);
0141   BOOST_CHECK_EQUAL(matHalf, matBwdPost);
0142 
0143   BOOST_CHECK_EQUAL(matHalf, matFwdPre);
0144   BOOST_CHECK_EQUAL(matHalf, matBwdPre);
0145 
0146   // c) Forward factor material test
0147   BOOST_CHECK_EQUAL(hsmbwd.factor(fDir, full), 1.);
0148   BOOST_CHECK_EQUAL(hsmbwd.factor(fDir, pre), 1.);
0149   BOOST_CHECK_EQUAL(hsmbwd.factor(fDir, post), 0.);
0150 
0151   BOOST_CHECK_EQUAL(hsmbwd.factor(bDir, full), 1.);
0152   BOOST_CHECK_EQUAL(hsmbwd.factor(bDir, pre), 0.);
0153   BOOST_CHECK_EQUAL(hsmbwd.factor(bDir, post), 1.);
0154 
0155   matFwdFull = hsmbwd.materialSlab(Vector3{0., 0., 0.}, fDir, full);
0156   matBwdFull = hsmbwd.materialSlab(Vector3{0., 0., 0.}, bDir, full);
0157 
0158   matFwdPost = hsmbwd.materialSlab(Vector3{0., 0., 0.}, fDir, post);
0159   matBwdPost = hsmbwd.materialSlab(Vector3{0., 0., 0.}, bDir, post);
0160 
0161   matFwdPre = hsmbwd.materialSlab(Vector3{0., 0., 0.}, fDir, pre);
0162   matBwdPre = hsmbwd.materialSlab(Vector3{0., 0., 0.}, bDir, pre);
0163 
0164   BOOST_CHECK_EQUAL(mat, matFwdFull);
0165   BOOST_CHECK_EQUAL(mat, matBwdFull);
0166 
0167   BOOST_CHECK_EQUAL(vacuum, matFwdPost);
0168   BOOST_CHECK_EQUAL(mat, matBwdPost);
0169 
0170   BOOST_CHECK_EQUAL(mat, matFwdPre);
0171   BOOST_CHECK_EQUAL(vacuum, matBwdPre);
0172 }
0173 }  // namespace Acts::Test