Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DD4hepVolumeStructure.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DD4hepVolumeStructure.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 
10 
12 
13 #include <DD4hep/DetElement.h>
14 
16  std::unique_ptr<const Logger> mlogger)
17  : m_logger(std::move(mlogger)) {
18  ACTS_DEBUG("UnitLength conversion factor (DD4hep -> Acts): " << unitLength);
19 }
20 
21 std::shared_ptr<Acts::Experimental::VolumeStructureBuilder>
23  const dd4hep::DetElement& dd4hepElement, const Options& options) const {
24  // The configuration
26  if (recursiveParse(vsbConfig, dd4hepElement)) {
27  ACTS_DEBUG("ProtoVolume description successfully parsed.");
28  }
29  // Return the structure builder
30  return std::make_shared<VolumeStructureBuilder>(
31  vsbConfig, getDefaultLogger(options.name, options.logLevel));
32 }
33 
36  const dd4hep::DetElement& dd4hepElement) const {
37  // Deal with a proto volume if detected
38  bool actsVolume = getParamOr<bool>("acts_volume", dd4hepElement, false);
39  if (actsVolume) {
40  auto bValueInt =
41  getParamOr<int>("acts_volume_type", dd4hepElement,
42  static_cast<int>(VolumeBounds::BoundsType::eOther));
43  auto bValueType = static_cast<VolumeBounds::BoundsType>(bValueInt);
44  if (bValueType < VolumeBounds::BoundsType::eOther) {
45  auto bValues = extractSeries<ActsScalar>(
46  dd4hepElement, "acts_volume_bvalues", unitLength);
47  // Set the parameters for the config
48  vsbConfig.boundsType = bValueType;
49  vsbConfig.boundValues = bValues;
50  }
51  vsbConfig.transform =
52  extractTransform(dd4hepElement, "acts_volume_pos", unitLength);
53  return true;
54  } else {
55  ACTS_VERBOSE("No ProtoVolume description detected.");
56  }
57 
58  // Parse through children
59  const dd4hep::DetElement::Children& children = dd4hepElement.children();
60  if (!children.empty()) {
61  ACTS_VERBOSE(children.size() << " children detected.");
62  for (auto& child : children) {
63  dd4hep::DetElement childDetElement = child.second;
64  if (recursiveParse(vsbConfig, childDetElement)) {
65  return true;
66  }
67  }
68  }
69 
70  return false;
71 }