Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:11:30

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(unpack_shared_vector(m_surfaces)),
0028       m_transform(transform) {}
0029 
0030 SurfaceArray::SurfaceArray(std::shared_ptr<const Surface> srf)
0031     : p_gridLookup(
0032           static_cast<ISurfaceGridLookup*>(new SingleElementLookup(srf.get()))),
0033       m_surfaces({std::move(srf)}) {
0034   m_surfacesRawPointers.push_back(m_surfaces.at(0).get());
0035 }
0036 
0037 std::ostream& SurfaceArray::toStream(const GeometryContext& /*gctx*/,
0038                                      std::ostream& sl) const {
0039   sl << std::fixed << std::setprecision(4);
0040   sl << "SurfaceArray:" << std::endl;
0041   sl << " - no surfaces: " << m_surfaces.size() << std::endl;
0042   sl << " - grid dim:    " << p_gridLookup->dimensions() << std::endl;
0043 
0044   auto axes = p_gridLookup->getAxes();
0045 
0046   for (std::size_t j = 0; j < axes.size(); ++j) {
0047     AxisBoundaryType bdt = axes.at(j)->getBoundaryType();
0048     sl << " - axis " << (j + 1) << std::endl;
0049     sl << "   - boundary type: ";
0050     if (bdt == AxisBoundaryType::Open) {
0051       sl << "open";
0052     }
0053     if (bdt == AxisBoundaryType::Bound) {
0054       sl << "bound";
0055     }
0056     if (bdt == AxisBoundaryType::Closed) {
0057       sl << "closed";
0058     }
0059     sl << std::endl;
0060     sl << "   - type: "
0061        << (axes.at(j)->isEquidistant() ? "equidistant" : "variable")
0062        << std::endl;
0063     sl << "   - n bins: " << axes.at(j)->getNBins() << std::endl;
0064     sl << "   - bin edges: [ ";
0065     auto binEdges = axes.at(j)->getBinEdges();
0066     for (std::size_t i = 0; i < binEdges.size(); ++i) {
0067       if (i > 0) {
0068         sl << ", ";
0069       }
0070       auto binEdge = binEdges.at(i);
0071       // Do not display negative zeroes
0072       sl << ((std::abs(binEdge) >= 5e-4) ? binEdge : 0.0);
0073     }
0074     sl << " ]" << std::endl;
0075   }
0076   return sl;
0077 }
0078 
0079 }  // namespace Acts