Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrackingGeometryBuilder.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TrackingGeometryBuilder.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2016-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 
10 
12 
13 #include <functional>
14 #include <stdexcept>
15 #include <utility>
16 
19  std::unique_ptr<const Logger> logger)
20  : m_cfg(), m_logger(std::move(logger)) {
21  setConfiguration(cgbConfig);
22 }
23 
26  return m_cfg;
27 }
28 
30  const Acts::TrackingGeometryBuilder::Config& cgbConfig) {
31  if (cgbConfig.trackingVolumeBuilders.empty()) {
32  throw std::invalid_argument("Invalid configuration: no volume builders");
33  }
34  m_cfg = cgbConfig;
35 }
36 
38  std::unique_ptr<const Logger> newLogger) {
39  m_logger = std::move(newLogger);
40 }
41 
42 std::unique_ptr<const Acts::TrackingGeometry>
44  const GeometryContext& gctx) const {
45  MutableTrackingVolumePtr highestVolume = nullptr;
46  // loop over the builders and wrap one around the other
47  for (auto& volumeBuilder : m_cfg.trackingVolumeBuilders) {
48  // assign a new highest volume (and potentially wrap around the given
49  // highest volume so far)
50  auto volume = volumeBuilder(gctx, highestVolume, nullptr);
51  if (!volume) {
52  ACTS_INFO(
53  "Received nullptr volume from builder, keeping previous highest "
54  "volume");
55  } else {
56  highestVolume = std::move(volume);
57  }
58  }
59 
60  // create the TrackingGeometry & decorate it with the material
61  if (highestVolume) {
62  return std::make_unique<TrackingGeometry>(
63  highestVolume,
64  m_cfg.materialDecorator ? m_cfg.materialDecorator.get() : nullptr,
65  *m_cfg.geometryIdentifierHook, logger());
66  } else {
67  throw std::runtime_error(
68  "Unable to construct tracking geometry: no tracking volume");
69  }
70 }