Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:09:34

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2023 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 http://mozilla.org/MPL/2.0/.
0008 
0009 #include "Acts/Detector/DetectorBuilder.hpp"
0010 
0011 #include "Acts/Detector/Detector.hpp"
0012 #include "Acts/Detector/DetectorVolume.hpp"
0013 #include "Acts/Detector/interface/IGeometryIdGenerator.hpp"
0014 #include "Acts/Navigation/DetectorVolumeFinders.hpp"
0015 
0016 #include <stdexcept>
0017 
0018 Acts::Experimental::DetectorBuilder::DetectorBuilder(
0019     const Acts::Experimental::DetectorBuilder::Config& cfg,
0020     std::unique_ptr<const Acts::Logger> mlogger)
0021     : IDetectorBuilder(), m_cfg(cfg), m_logger(std::move(mlogger)) {
0022   if (m_cfg.builder == nullptr) {
0023     throw std::invalid_argument(
0024         "DetectorBuilder: no top level builder defined.");
0025   }
0026 }
0027 
0028 std::shared_ptr<const Acts::Experimental::Detector>
0029 Acts::Experimental::DetectorBuilder::construct(
0030     const GeometryContext& gctx) const {
0031   // Screen printout of the auxiliary information
0032   if (!m_cfg.auxiliary.empty()) {
0033     ACTS_DEBUG(m_cfg.auxiliary);
0034   }
0035   ACTS_DEBUG("Building a detector with name " << m_cfg.name);
0036 
0037   auto [volumes, portals, roots] = m_cfg.builder->construct(gctx);
0038 
0039   if (m_cfg.geoIdGenerator != nullptr) {
0040     ACTS_DEBUG("Assigning geometry ids to the detector");
0041     auto cache = m_cfg.geoIdGenerator->generateCache();
0042     std::for_each(roots.volumes.begin(), roots.volumes.end(), [&](auto& v) {
0043       ACTS_VERBOSE("-> Assigning geometry id to volume " << v->name());
0044       m_cfg.geoIdGenerator->assignGeometryId(cache, *v);
0045     });
0046   }
0047 
0048   return Detector::makeShared(m_cfg.name, std::move(roots.volumes),
0049                               std::move(roots.volumeFinder));
0050 }