Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 08:12:26

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 #include "Acts/Surfaces/SurfaceArray.hpp"
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Geometry/SurfaceArrayCreator.hpp"
0013 #include "Acts/Utilities/Helpers.hpp"
0014 
0015 #include <utility>
0016 
0017 namespace Acts {
0018 
0019 // implementation for pure virtual destructor of ISurfaceGridLookup
0020 SurfaceArray::ISurfaceGridLookup::~ISurfaceGridLookup() = default;
0021 
0022 SurfaceArray::SurfaceArray(std::unique_ptr<ISurfaceGridLookup> gridLookup,
0023                            std::vector<std::shared_ptr<const Surface>> surfaces,
0024                            const Transform3& transform)
0025     : p_gridLookup(std::move(gridLookup)),
0026       m_surfaces(std::move(surfaces)),
0027       m_surfacesRawPointers(unpackSmartPointers(m_surfaces)),
0028       m_transform(transform) {}
0029 
0030 SurfaceArray::SurfaceArray(std::shared_ptr<const Surface> srf)
0031     : p_gridLookup(std::make_unique<SingleElementLookup>(srf.get())),
0032       m_surfaces({std::move(srf)}) {
0033   m_surfacesRawPointers.push_back(m_surfaces.at(0).get());
0034 }
0035 
0036 std::ostream& SurfaceArray::toStream(const GeometryContext& /*gctx*/,
0037                                      std::ostream& sl) const {
0038   sl << std::fixed << std::setprecision(4);
0039   sl << "SurfaceArray:" << std::endl;
0040   sl << " - no surfaces: " << m_surfaces.size() << std::endl;
0041 
0042   auto axes = p_gridLookup->getAxes();
0043 
0044   for (std::size_t j = 0; j < axes.size(); ++j) {
0045     AxisBoundaryType bdt = axes.at(j)->getBoundaryType();
0046     sl << " - axis " << (j + 1) << std::endl;
0047     sl << "   - boundary type: ";
0048     if (bdt == AxisBoundaryType::Open) {
0049       sl << "open";
0050     }
0051     if (bdt == AxisBoundaryType::Bound) {
0052       sl << "bound";
0053     }
0054     if (bdt == AxisBoundaryType::Closed) {
0055       sl << "closed";
0056     }
0057     sl << std::endl;
0058     sl << "   - type: "
0059        << (axes.at(j)->isEquidistant() ? "equidistant" : "variable")
0060        << std::endl;
0061     sl << "   - n bins: " << axes.at(j)->getNBins() << std::endl;
0062     sl << "   - bin edges: [ ";
0063     auto binEdges = axes.at(j)->getBinEdges();
0064     for (std::size_t i = 0; i < binEdges.size(); ++i) {
0065       if (i > 0) {
0066         sl << ", ";
0067       }
0068       auto binEdge = binEdges.at(i);
0069       // Do not display negative zeroes
0070       sl << ((std::abs(binEdge) >= 5e-4) ? binEdge : 0.0);
0071     }
0072     sl << " ]" << std::endl;
0073   }
0074   return sl;
0075 }
0076 
0077 }  // namespace Acts