ECCE @ 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 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 
9 #include <utility>
10 
15 
16 // implementation for pure virtual destructor of ISurfaceGridLookup
18 
20  std::unique_ptr<ISurfaceGridLookup> gridLookup,
21  std::vector<std::shared_ptr<const Surface>> surfaces,
22  std::shared_ptr<const Transform3D> transform)
23  : p_gridLookup(std::move(gridLookup)),
24  m_surfaces(std::move(surfaces)),
25  m_surfacesRawPointers(unpack_shared_vector(m_surfaces)),
26  m_transform(std::move(transform)) {}
27 
28 Acts::SurfaceArray::SurfaceArray(std::shared_ptr<const Surface> srf)
29  : p_gridLookup(
30  static_cast<ISurfaceGridLookup*>(new SingleElementLookup(srf.get()))),
31  m_surfaces({std::move(srf)}) {
32  m_surfacesRawPointers.push_back(m_surfaces.at(0).get());
33 }
34 
35 std::ostream& Acts::SurfaceArray::toStream(const GeometryContext& /*gctx*/,
36  std::ostream& sl) const {
37  sl << std::fixed << std::setprecision(4);
38  sl << "SurfaceArray:" << std::endl;
39  sl << " - no surfaces: " << m_surfaces.size() << std::endl;
40  sl << " - grid dim: " << p_gridLookup->dimensions() << std::endl;
41 
42  auto axes = p_gridLookup->getAxes();
43 
44  for (size_t j = 0; j < axes.size(); ++j) {
45  detail::AxisBoundaryType bdt = axes.at(j)->getBoundaryType();
46  sl << " - axis " << (j + 1) << std::endl;
47  sl << " - boundary type: ";
48  if (bdt == detail::AxisBoundaryType::Open) {
49  sl << "open";
50  }
51  if (bdt == detail::AxisBoundaryType::Bound) {
52  sl << "bound";
53  }
54  if (bdt == detail::AxisBoundaryType::Closed) {
55  sl << "closed";
56  }
57  sl << std::endl;
58  sl << " - type: "
59  << (axes.at(j)->isEquidistant() ? "equidistant" : "variable")
60  << std::endl;
61  sl << " - n bins: " << axes.at(j)->getNBins() << std::endl;
62  sl << " - bin edges: [ ";
63  auto binEdges = axes.at(j)->getBinEdges();
64  for (size_t i = 0; i < binEdges.size(); ++i) {
65  if (i > 0) {
66  sl << ", ";
67  }
68  auto binEdge = binEdges.at(i);
69  // Do not display negative zeroes
70  sl << ((std::abs(binEdge) >= 5e-4) ? binEdge : 0.0);
71  }
72  sl << " ]" << std::endl;
73  }
74  return sl;
75 }