Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:10:45

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