Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2023 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/data/test_case.hpp>
0010 #include <boost/test/unit_test.hpp>
0011 
0012 #include "Acts/Definitions/Units.hpp"
0013 #include "Acts/Plugins/TGeo/TGeoMaterialConverter.hpp"
0014 #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
0015 
0016 #include <string>
0017 #include <vector>
0018 
0019 #include "TGeoManager.h"
0020 #include "TGeoMaterial.h"
0021 
0022 namespace Acts {
0023 
0024 using namespace UnitLiterals;
0025 
0026 namespace Test {
0027 
0028 BOOST_AUTO_TEST_CASE(TGeoMaterialConverter_materialSlab) {
0029   new TGeoManager("gm", "garbage collector");
0030 
0031   ActsScalar A = 26.98;
0032   ActsScalar Z = 13.;
0033   TGeoMaterial *mat = new TGeoMaterial("Al", A, Z, 2.7);
0034 
0035   // ROOT calculates the radiation/int length in cm
0036   // That's actually depending on the ROOT version
0037   CHECK_CLOSE_ABS(mat->GetRadLen(), 8.85, 0.1_mm);
0038   CHECK_CLOSE_ABS(mat->GetIntLen(), 38.8, 0.1_mm);
0039 
0040   Acts::TGeoMaterialConverter::Options options;
0041   options.unitLengthScalor = 1_cm;
0042   options.unitMassScalor = 1.;
0043 
0044   // Assume we describe a 10 mm thick box as a 10 mm thick slab
0045   ActsScalar tInX0 = 10_mm / (mat->GetRadLen() * options.unitLengthScalor);
0046   ActsScalar tInL0 = 10_mm / (mat->GetIntLen() * options.unitLengthScalor);
0047   ActsScalar rho =
0048       2.7 * options.unitMassScalor / pow(options.unitLengthScalor, 3);
0049 
0050   Acts::MaterialSlab slab_10_10 =
0051       Acts::TGeoMaterialConverter::materialSlab(*mat, 10_mm, 10_mm, options);
0052   CHECK_CLOSE_ABS(88.7_mm, slab_10_10.material().X0(), 0.1_mm);
0053   CHECK_CLOSE_ABS(388_mm, slab_10_10.material().L0(), 1_mm);
0054   CHECK_CLOSE_ABS(A, slab_10_10.material().Ar(), 1e-5);
0055   CHECK_CLOSE_ABS(Z, slab_10_10.material().Z(), 1e-5);
0056   CHECK_CLOSE_ABS(tInX0, slab_10_10.thicknessInX0(), 1e-5);
0057   CHECK_CLOSE_ABS(tInL0, slab_10_10.thicknessInL0(), 1e-5);
0058   CHECK_CLOSE_ABS(rho, slab_10_10.material().massDensity(), 1e-5);
0059 
0060   // Assume we describe a 10 mm thick box as a 1 mm thick slab
0061   Acts::MaterialSlab slab_10_1 =
0062       Acts::TGeoMaterialConverter::materialSlab(*mat, 10_mm, 1_mm, options);
0063   // Radiation/interaction lengths are divided by 10
0064   CHECK_CLOSE_ABS(8.87_mm, slab_10_1.material().X0(), 0.1_mm);
0065   CHECK_CLOSE_ABS(38.8_mm, slab_10_1.material().L0(), 1_mm);
0066   // Density is scaled up by 10
0067   CHECK_CLOSE_ABS(10 * rho, slab_10_1.material().massDensity(), 1e-5);
0068   // A and Z remain unchanged
0069   CHECK_CLOSE_ABS(A, slab_10_1.material().Ar(), 1e-5);
0070   CHECK_CLOSE_ABS(Z, slab_10_1.material().Z(), 1e-5);
0071 
0072   // Thickness in X0/L0 is unchanged -> same scattering
0073   CHECK_CLOSE_ABS(tInX0, slab_10_1.thicknessInX0(), 1e-5);
0074   CHECK_CLOSE_ABS(tInL0, slab_10_1.thicknessInL0(), 1e-5);
0075   // Thickness * rho is unchanged -> same energy loss
0076   CHECK_CLOSE_ABS(slab_10_10.material().massDensity() * slab_10_10.thickness(),
0077                   slab_10_1.material().massDensity() * slab_10_1.thickness(),
0078                   1e-5);
0079 }
0080 
0081 }  // namespace Test
0082 }  // namespace Acts