Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:25:36

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/Units.hpp"
0012 #include "ActsPlugins/Root/TGeoMaterialConverter.hpp"
0013 #include "ActsTests/CommonHelpers/FloatComparisons.hpp"
0014 
0015 #include <string>
0016 #include <vector>
0017 
0018 #include "TGeoManager.h"
0019 #include "TGeoMaterial.h"
0020 
0021 using namespace Acts;
0022 using namespace ActsPlugins;
0023 using namespace Acts::UnitLiterals;
0024 
0025 namespace ActsTests {
0026 
0027 BOOST_AUTO_TEST_SUITE(RootSuite)
0028 
0029 BOOST_AUTO_TEST_CASE(TGeoMaterialConverter_materialSlab) {
0030   new TGeoManager("gm", "garbage collector");
0031 
0032   double A = 26.98;
0033   double Z = 13.;
0034   TGeoMaterial *mat = new TGeoMaterial("Al", A, Z, 2.7);
0035 
0036   // ROOT calculates the radiation/int length in cm
0037   // That's actually depending on the ROOT version
0038   CHECK_CLOSE_ABS(mat->GetRadLen(), 8.85, 0.1_mm);
0039   CHECK_CLOSE_ABS(mat->GetIntLen(), 38.8, 0.1_mm);
0040 
0041   TGeoMaterialConverter::Options options;
0042   options.unitLengthScalor = 1_cm;
0043   options.unitMassScalor = 1.;
0044 
0045   // Assume we describe a 10 mm thick box as a 10 mm thick slab
0046   double tInX0 = 10_mm / (mat->GetRadLen() * options.unitLengthScalor);
0047   double tInL0 = 10_mm / (mat->GetIntLen() * options.unitLengthScalor);
0048   double rho = 2.7 * options.unitMassScalor / pow(options.unitLengthScalor, 3);
0049 
0050   MaterialSlab slab_10_10 =
0051       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   MaterialSlab slab_10_1 =
0062       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 BOOST_AUTO_TEST_SUITE_END()
0082 
0083 }  // namespace ActsTests