Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:11:23

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2022 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 http://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/ISurfaceMaterial.hpp"
0015 #include "Acts/Material/MaterialSlab.hpp"
0016 
0017 #include <cstddef>
0018 #include <ostream>
0019 
0020 namespace Acts::Test {
0021 
0022 class SurfaceMaterialStub : public ISurfaceMaterial {
0023   using ISurfaceMaterial::ISurfaceMaterial;
0024 
0025   ISurfaceMaterial& operator*=(double /*scale*/) override { return *this; };
0026 
0027   const MaterialSlab& materialSlab(const Vector2& /*lp*/) const override {
0028     return m_fullMaterial;
0029   }
0030 
0031   const MaterialSlab& materialSlab(const Vector3& /*gp*/) const override {
0032     return m_fullMaterial;
0033   }
0034 
0035   std::ostream& toStream(std::ostream& sl) const override {
0036     sl << "SurfaceMaterialStub";
0037     return sl;
0038   };
0039 
0040   MaterialSlab m_fullMaterial{};
0041 };
0042 
0043 /// Test the constructors
0044 BOOST_AUTO_TEST_CASE(ISurfaceMaterial_factor_test) {
0045   double splitFactor = 42.0;
0046   SurfaceMaterialStub stub{splitFactor};
0047 
0048   BOOST_CHECK_EQUAL(
0049       stub.factor(Direction::Forward, MaterialUpdateStage::FullUpdate), 1.0);
0050 
0051   BOOST_CHECK_EQUAL(
0052       stub.factor(Direction::Backward, MaterialUpdateStage::FullUpdate), 1.0);
0053 
0054   BOOST_CHECK_EQUAL(
0055       stub.factor(Direction::Forward, MaterialUpdateStage::PostUpdate),
0056       splitFactor);
0057 
0058   BOOST_CHECK_EQUAL(
0059       stub.factor(Direction::Backward, MaterialUpdateStage::PreUpdate),
0060       splitFactor);
0061 
0062   BOOST_CHECK_EQUAL(
0063       stub.factor(Direction::Forward, MaterialUpdateStage::PreUpdate),
0064       1 - splitFactor);
0065 
0066   BOOST_CHECK_EQUAL(
0067       stub.factor(Direction::Backward, MaterialUpdateStage::PostUpdate),
0068       1 - splitFactor);
0069 }
0070 
0071 }  // namespace Acts::Test