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