Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SurfaceMaterialMapperTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file SurfaceMaterialMapperTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2017-2018 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/unit_test.hpp>
10 
30 
31 #include <map>
32 #include <memory>
33 #include <string>
34 #include <utility>
35 #include <vector>
36 
37 namespace Acts {
38 
40 std::shared_ptr<const TrackingGeometry> trackingGeometry() {
41  using namespace Acts::UnitLiterals;
42 
43  BinUtility zbinned(8, -40, 40, open, binZ);
44  auto matProxy = std::make_shared<const ProtoSurfaceMaterial>(zbinned);
45 
46  Logging::Level surfaceLLevel = Logging::INFO;
47  Logging::Level layerLLevel = Logging::INFO;
48  Logging::Level volumeLLevel = Logging::INFO;
49 
50  // configure surface array creator
51  auto surfaceArrayCreator = std::make_shared<const SurfaceArrayCreator>(
52  getDefaultLogger("SurfaceArrayCreator", surfaceLLevel));
53  // configure the layer creator that uses the surface array creator
54  LayerCreator::Config lcConfig;
55  lcConfig.surfaceArrayCreator = surfaceArrayCreator;
56  auto layerCreator = std::make_shared<const LayerCreator>(
57  lcConfig, getDefaultLogger("LayerCreator", layerLLevel));
58  // configure the layer array creator
59  LayerArrayCreator::Config lacConfig;
60  auto layerArrayCreator = std::make_shared<const LayerArrayCreator>(
61  lacConfig, getDefaultLogger("LayerArrayCreator", layerLLevel));
62 
63  // tracking volume array creator
65  auto tVolumeArrayCreator = std::make_shared<const TrackingVolumeArrayCreator>(
66  tvacConfig, getDefaultLogger("TrackingVolumeArrayCreator", volumeLLevel));
67  // configure the cylinder volume helper
69  cvhConfig.layerArrayCreator = layerArrayCreator;
70  cvhConfig.trackingVolumeArrayCreator = tVolumeArrayCreator;
71  auto cylinderVolumeHelper = std::make_shared<const CylinderVolumeHelper>(
72  cvhConfig, getDefaultLogger("CylinderVolumeHelper", volumeLLevel));
73 
74  PassiveLayerBuilder::Config layerBuilderConfig;
75  layerBuilderConfig.layerIdentification = "CentralBarrel";
76  layerBuilderConfig.centralLayerRadii = {10., 20., 30.};
77  layerBuilderConfig.centralLayerHalflengthZ = {40., 40., 40.};
78  layerBuilderConfig.centralLayerThickness = {1., 1., 1.};
79  layerBuilderConfig.centralLayerMaterial = {matProxy, matProxy, matProxy};
80  auto layerBuilder = std::make_shared<const PassiveLayerBuilder>(
81  layerBuilderConfig,
82  getDefaultLogger("CentralBarrelBuilder", layerLLevel));
83  // create the volume for the beam pipe
85  cvbConfig.trackingVolumeHelper = cylinderVolumeHelper;
86  cvbConfig.volumeName = "BeamPipe";
87  cvbConfig.layerBuilder = layerBuilder;
88  cvbConfig.layerEnvelopeR = {1_mm, 1_mm};
89  cvbConfig.buildToRadiusZero = true;
90  cvbConfig.volumeSignature = 0;
91  auto centralVolumeBuilder = std::make_shared<const CylinderVolumeBuilder>(
92  cvbConfig, getDefaultLogger("CentralVolumeBuilder", volumeLLevel));
93 
94  // create the bounds and the volume
95  auto centralVolumeBounds =
96  std::make_shared<const CylinderVolumeBounds>(0., 40., 110.);
97 
98  GeometryContext gCtx;
99  auto centralVolume =
100  centralVolumeBuilder->trackingVolume(gCtx, nullptr, centralVolumeBounds);
101 
102  return std::make_shared<const TrackingGeometry>(centralVolume);
103 }
104 
105 std::shared_ptr<const TrackingGeometry> tGeometry = trackingGeometry();
106 
107 namespace Test {
108 
110 BOOST_AUTO_TEST_CASE(SurfaceMaterialMapper_tests) {
112  Navigator navigator({tGeometry});
115  stepper, std::move(navigator));
116 
119  SurfaceMaterialMapper smMapper(smmConfig, std::move(propagator));
120 
122  GeometryContext gCtx;
123  MagneticFieldContext mfCtx;
124 
126  auto mState = smMapper.createState(gCtx, mfCtx, *tGeometry);
127 
129  BOOST_CHECK_EQUAL(mState.accumulatedMaterial.size(), 3u);
130 }
131 
132 } // namespace Test
133 
134 } // namespace Acts