Back to home page

EIC code displayed by LXR

 
 

    


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

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