Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TGeoMaterialConverterTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TGeoMaterialConverterTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2023 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #include <boost/test/data/test_case.hpp>
10 #include <boost/test/unit_test.hpp>
11 
15 
16 #include <string>
17 #include <vector>
18 
19 #include "TGeoManager.h"
20 #include "TGeoMaterial.h"
21 
22 namespace Acts {
23 
24 using namespace UnitLiterals;
25 
26 namespace Test {
27 
28 BOOST_AUTO_TEST_CASE(TGeoMaterialConverter_materialSlab) {
29  new TGeoManager("gm", "garbage collector");
30 
31  ActsScalar A = 26.98;
32  ActsScalar Z = 13.;
33  TGeoMaterial *mat = new TGeoMaterial("Al", A, Z, 2.7);
34 
35  // ROOT calculates the radiation/int length in cm
36  // That's actually depending on the ROOT version
37  CHECK_CLOSE_ABS(mat->GetRadLen(), 8.85, 0.1_mm);
38  CHECK_CLOSE_ABS(mat->GetIntLen(), 38.8, 0.1_mm);
39 
41  options.unitLengthScalor = 1_cm;
42  options.unitMassScalor = 1.;
43 
44  // Assume we describe a 10 mm thick box as a 10 mm thick slab
45  ActsScalar tInX0 = 10_mm / (mat->GetRadLen() * options.unitLengthScalor);
46  ActsScalar tInL0 = 10_mm / (mat->GetIntLen() * options.unitLengthScalor);
47  ActsScalar rho =
48  2.7 * options.unitMassScalor / pow(options.unitLengthScalor, 3);
49 
50  Acts::MaterialSlab slab_10_10 =
51  Acts::TGeoMaterialConverter::materialSlab(*mat, 10_mm, 10_mm, options);
52  CHECK_CLOSE_ABS(88.7_mm, slab_10_10.material().X0(), 0.1_mm);
53  CHECK_CLOSE_ABS(388_mm, slab_10_10.material().L0(), 1_mm);
54  CHECK_CLOSE_ABS(A, slab_10_10.material().Ar(), 1e-5);
55  CHECK_CLOSE_ABS(Z, slab_10_10.material().Z(), 1e-5);
56  CHECK_CLOSE_ABS(tInX0, slab_10_10.thicknessInX0(), 1e-5);
57  CHECK_CLOSE_ABS(tInL0, slab_10_10.thicknessInL0(), 1e-5);
58  CHECK_CLOSE_ABS(rho, slab_10_10.material().massDensity(), 1e-5);
59 
60  // Assume we describe a 10 mm thick box as a 1 mm thick slab
61  Acts::MaterialSlab slab_10_1 =
62  Acts::TGeoMaterialConverter::materialSlab(*mat, 10_mm, 1_mm, options);
63  // Radiation/interaction lengths are divided by 10
64  CHECK_CLOSE_ABS(8.87_mm, slab_10_1.material().X0(), 0.1_mm);
65  CHECK_CLOSE_ABS(38.8_mm, slab_10_1.material().L0(), 1_mm);
66  // Density is scaled up by 10
67  CHECK_CLOSE_ABS(10 * rho, slab_10_1.material().massDensity(), 1e-5);
68  // A and Z remain unchanged
69  CHECK_CLOSE_ABS(A, slab_10_1.material().Ar(), 1e-5);
70  CHECK_CLOSE_ABS(Z, slab_10_1.material().Z(), 1e-5);
71 
72  // Thickness in X0/L0 is unchanged -> same scattering
73  CHECK_CLOSE_ABS(tInX0, slab_10_1.thicknessInX0(), 1e-5);
74  CHECK_CLOSE_ABS(tInL0, slab_10_1.thicknessInL0(), 1e-5);
75  // Thickness * rho is unchanged -> same energy loss
76  CHECK_CLOSE_ABS(slab_10_10.material().massDensity() * slab_10_10.thickness(),
77  slab_10_1.material().massDensity() * slab_10_1.thickness(),
78  1e-5);
79 }
80 
81 } // namespace Test
82 } // namespace Acts