EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SurfaceArray.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file SurfaceArray.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2018-2020 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 
14 
15 #include <utility>
16 
17 // implementation for pure virtual destructor of ISurfaceGridLookup
19 
21  std::unique_ptr<ISurfaceGridLookup> gridLookup,
22  std::vector<std::shared_ptr<const Surface>> surfaces,
23  const Transform3D& transform)
24  : p_gridLookup(std::move(gridLookup)),
25  m_surfaces(std::move(surfaces)),
26  m_surfacesRawPointers(unpack_shared_vector(m_surfaces)),
27  m_transform(transform) {}
28 
29 Acts::SurfaceArray::SurfaceArray(std::shared_ptr<const Surface> srf)
30  : p_gridLookup(
31  static_cast<ISurfaceGridLookup*>(new SingleElementLookup(srf.get()))),
32  m_surfaces({std::move(srf)}) {
33  m_surfacesRawPointers.push_back(m_surfaces.at(0).get());
34 }
35 
36 std::ostream& Acts::SurfaceArray::toStream(const GeometryContext& /*gctx*/,
37  std::ostream& sl) const {
38  sl << std::fixed << std::setprecision(4);
39  sl << "SurfaceArray:" << std::endl;
40  sl << " - no surfaces: " << m_surfaces.size() << std::endl;
41  sl << " - grid dim: " << p_gridLookup->dimensions() << std::endl;
42 
43  auto axes = p_gridLookup->getAxes();
44 
45  for (size_t j = 0; j < axes.size(); ++j) {
46  detail::AxisBoundaryType bdt = axes.at(j)->getBoundaryType();
47  sl << " - axis " << (j + 1) << std::endl;
48  sl << " - boundary type: ";
49  if (bdt == detail::AxisBoundaryType::Open) {
50  sl << "open";
51  }
52  if (bdt == detail::AxisBoundaryType::Bound) {
53  sl << "bound";
54  }
55  if (bdt == detail::AxisBoundaryType::Closed) {
56  sl << "closed";
57  }
58  sl << std::endl;
59  sl << " - type: "
60  << (axes.at(j)->isEquidistant() ? "equidistant" : "variable")
61  << std::endl;
62  sl << " - n bins: " << axes.at(j)->getNBins() << std::endl;
63  sl << " - bin edges: [ ";
64  auto binEdges = axes.at(j)->getBinEdges();
65  for (size_t i = 0; i < binEdges.size(); ++i) {
66  if (i > 0) {
67  sl << ", ";
68  }
69  auto binEdge = binEdges.at(i);
70  // Do not display negative zeroes
71  sl << ((std::abs(binEdge) >= 5e-4) ? binEdge : 0.0);
72  }
73  sl << " ]" << std::endl;
74  }
75  return sl;
76 }