Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:09:57

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 #pragma once
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/Common.hpp"
0013 #include "Acts/Detector/ProtoBinning.hpp"
0014 #include "Acts/Geometry/VolumeBounds.hpp"
0015 #include "Acts/Utilities/BinningData.hpp"
0016 #include "Acts/Utilities/StringHelpers.hpp"
0017 
0018 #include <map>
0019 #include <memory>
0020 #include <string>
0021 #include <vector>
0022 
0023 namespace Acts::Experimental {
0024 
0025 class IGeometryIdGenerator;
0026 class IInternalStructureBuilder;
0027 class IRootVolumeFinderBuilder;
0028 
0029 /// A Blueprint is an instruction tree that allows you to defina a tree sequence
0030 /// of volume building using the provided tools.
0031 ///
0032 /// It follows tree nomenclature and can define:
0033 ///
0034 /// - a root node (the top of the tree)
0035 /// - a branch node (also called inner node)
0036 /// - leaf node (also called terminal node)
0037 ///
0038 /// Leaf nodes can have internal builders attached, while all the external
0039 /// builders will be created when the blueprint is interpreted.
0040 namespace Blueprint {
0041 
0042 struct Node final {
0043   /// Branch constructor
0044   ///
0045   /// @param n name of the node
0046   /// @param t the transform
0047   /// @param bt the boundary type
0048   /// @param bv the boundary values
0049   /// @param bss the binning values
0050   /// @param cs the children of the node
0051   Node(const std::string& n, const Transform3& t, VolumeBounds::BoundsType bt,
0052        const std::vector<ActsScalar>& bv, const std::vector<BinningValue>& bss,
0053        std::vector<std::unique_ptr<Node>> cs = {})
0054       : name(n),
0055         transform(t),
0056         boundsType(bt),
0057         boundaryValues(bv),
0058         children(std::move(cs)),
0059         binning(bss) {
0060     for_each(children.begin(), children.end(),
0061              [this](std::unique_ptr<Node>& c) { c->parent = this; });
0062   }
0063 
0064   /// Leaf constructor
0065   ///
0066   /// @param n name of the node
0067   /// @param t the transform
0068   /// @param bt the boundary type
0069   /// @param bv the boundary values
0070   /// @param isb the internal structure builder (optional)
0071   Node(const std::string& n, const Transform3& t, VolumeBounds::BoundsType bt,
0072        const std::vector<ActsScalar>& bv,
0073        std::shared_ptr<const IInternalStructureBuilder> isb = nullptr)
0074       : name(n),
0075         transform(t),
0076         boundsType(bt),
0077         boundaryValues(bv),
0078         internalsBuilder(std::move(isb)) {}
0079 
0080   /// Name identification of this node
0081   std::string name = "";
0082   /// Transform definition of this node
0083   Transform3 transform = Transform3::Identity();
0084   /// Boundary definition of this node
0085   VolumeBounds::BoundsType boundsType = VolumeBounds::eOther;
0086   /// The boundary type
0087   std::vector<ActsScalar> boundaryValues = {};
0088   /// Parent node - nullptr for root only
0089   const Node* parent = nullptr;
0090   /// Branch definitions: children
0091   std::vector<std::unique_ptr<Node>> children = {};
0092   /// Branch definition binning
0093   std::vector<BinningValue> binning = {};
0094 
0095   /// Portal proto material binning
0096   std::map<unsigned int, BinningDescription> portalMaterialBinning = {};
0097 
0098   /// Auxiliary information
0099   std::vector<std::string> auxiliary = {};
0100 
0101   /// Builders and helper tools that can be attached
0102   std::shared_ptr<const IRootVolumeFinderBuilder> rootVolumeFinderBuilder =
0103       nullptr;
0104   /// Geometry id generator
0105   std::shared_ptr<const IGeometryIdGenerator> geoIdGenerator = nullptr;
0106   /// Internal structure builder - for leaf nodes
0107   std::shared_ptr<const IInternalStructureBuilder> internalsBuilder = nullptr;
0108 
0109   /// @brief Check if it is a leaf node
0110   bool isLeaf() const { return children.empty(); }
0111 
0112   /// @brief Check is it is a root
0113   bool isRoot() const { return parent == nullptr; }
0114 
0115   /// @brief Method to add a child to this branch
0116   /// @param c the child to be added
0117   void add(std::unique_ptr<Node> c) {
0118     c->parent = this;
0119     children.push_back(std::move(c));
0120   }
0121 };
0122 
0123 }  // namespace Blueprint
0124 }  // namespace Acts::Experimental