Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MultiWireStructureBuilder.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file MultiWireStructureBuilder.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2022-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 
10 
26 
27 #include <algorithm>
28 #include <functional>
29 #include <iostream>
30 #include <string>
31 #include <vector>
32 
35  public:
36  struct Config {
38  std::vector<std::shared_ptr<Acts::Surface>> iSurfaces;
39 
41  std::vector<Acts::Experimental::ProtoBinning> binning;
42 
45 
47  Acts::Transform3 transform = Acts::Transform3::Identity();
48  };
49 
50  // Constructor
51 
53  const Config& cfg,
54  std::unique_ptr<const Acts::Logger> mlogger = Acts::getDefaultLogger(
55  "MUltiWireInternalBuilder", Acts::Logging::INFO))
56  : Acts::Experimental::IInternalStructureBuilder(),
57  m_cfg(cfg),
58  m_logger(std::move(mlogger)) {}
59 
61  const Acts::GeometryContext& gctx) const final {
62  if (not m_cfg.auxiliary.empty()) {
64  }
65 
66  Acts::Experimental::DetectorVolumeUpdator internalVolumeUpdator =
68  // Create the indexed surfaces
69  auto internalSurfaces = m_cfg.iSurfaces;
71  decltype(internalSurfaces), Acts::Experimental::MultiLayerSurfacesImpl>
72  isg{internalSurfaces,
73  {},
74  {m_cfg.binning[0u].binValue, m_cfg.binning[1u].binValue},
75  {m_cfg.binning[0u].expansion, m_cfg.binning[1u].expansion}};
78  {m_cfg.binning[0u].edges.front(), m_cfg.binning[0u].edges.back()},
79  m_cfg.binning[0u].edges.size() - 1,
80  {m_cfg.binning[1u].edges.front(), m_cfg.binning[1u].edges.back()},
81  m_cfg.binning[1u].edges.size() - 1};
82 
83  auto sfCandidatesUpdator = isg(gctx, aGenerator, rGenerator);
84 
85  return {internalSurfaces,
86  {},
87  std::move(sfCandidatesUpdator),
88  std::move(internalVolumeUpdator)};
89  }
90 
91  private:
94 
96  const Acts::Logger& logger() const { return *m_logger; }
97 
99  std::unique_ptr<const Acts::Logger> m_logger;
100 };
101 
104  std::unique_ptr<const Acts::Logger> logger)
105  : mCfg(config), mLogger(std::move(logger)) {
106  // check if the surfaces are set
107  if (mCfg.mlSurfaces.empty()) {
108  throw std::invalid_argument(
109  "MultiWireStructureBuilder: No surfaces are given");
110  } else if (mCfg.mlBinning.size() != 2u) {
111  throw ::std::invalid_argument(
112  "MultiWireStructureBuilder: Invalid binning provided");
113  }
114 }
115 
118  const Acts::GeometryContext& gctx) {
119  if (mCfg.mlBounds.size() != 3u) {
120  throw std::invalid_argument(
121  "MultiWireStructureBuilder: Invalid dimension for bounds.");
122  }
123 
124  // Configure the external structure builder for the internal structure
127  vsConfig.transform = mCfg.transform;
128  vsConfig.boundValues = mCfg.mlBounds;
129  vsConfig.auxiliary = "Construct External Structure";
130 
131  // Configure the internal structure builder for the internal structure
133  iConfig.iSurfaces = mCfg.mlSurfaces;
134  iConfig.binning = mCfg.mlBinning;
135  iConfig.auxiliary = "Construct Internal Structure";
136 
138  dvConfig.auxiliary = "Construct Detector Volume";
139  dvConfig.name = mCfg.name;
140  dvConfig.internalsBuilder =
141  std::make_shared<MultiWireInternalStructureBuilder>(
142  iConfig,
143  Acts::getDefaultLogger("MultiWire Internal Structure Builder",
145  dvConfig.externalsBuilder =
146  std::make_shared<Acts::Experimental::VolumeStructureBuilder>(
147  vsConfig, Acts::getDefaultLogger("VolumeStructureBuilder",
149  auto dvBuilder = std::make_shared<Acts::Experimental::DetectorVolumeBuilder>(
150  dvConfig,
151  Acts::getDefaultLogger("DetectorVolumeBuilder", Acts::Logging::VERBOSE));
152 
153  auto dvComponent = dvBuilder->construct(gctx);
154 
155  return dvComponent;
156 }